Revision 39a6388d

b/snf-cyclades-app/synnefo/api/management/commands/flavor-create.py
37 37

  
38 38
from synnefo.db.models import Flavor
39 39

  
40
from ._common import format_bool, format_date
41

  
42 40

  
43 41
class Command(BaseCommand):
42
    output_transaction = True
44 43
    args = "<cpu>[,<cpu>,...] " \
45 44
           "<ram>[,<ram>,...] " \
46 45
           "<disk>[,<disk>,...] " \
47 46
           "<disk template>[,<disk template>,...]"
48
    help = "Create one or more flavors"
49
    
47
    help = "Create one or more flavors.\n\nThe flavors that will be created are"\
48
           " those belonging to the cartesian product of the arguments"\
49

  
50 50
    def handle(self, *args, **options):
51 51
        if len(args) != 4:
52 52
            raise CommandError("Invalid number of arguments")
53
        
53

  
54 54
        cpus = args[0].split(',')
55 55
        rams = args[1].split(',')
56 56
        disks = args[2].split(',')
57 57
        templates = args[3].split(',')
58
        
58

  
59 59
        flavors = []
60 60
        for cpu, ram, disk, template in product(cpus, rams, disks, templates):
61 61
            try:
62 62
                flavors.append((int(cpu), int(ram), int(disk), template))
63 63
            except ValueError:
64 64
                raise CommandError("Invalid values")
65
        
65

  
66 66
        for cpu, ram, disk, template in flavors:
67 67
            flavor = Flavor.objects.create(cpu=cpu, ram=ram, disk=disk,
68 68
                                           disk_template=template)
b/snf-cyclades-app/synnefo/api/management/commands/server-create.py
41 41
from synnefo.api.util import get_image, allocate_public_address
42 42
from synnefo.api.faults import ItemNotFound
43 43

  
44
HELP_MSG = """
45

  
46
Create a new VM without authenticating the user or checking the resource
47
limits of the user. Also the allocator can be bypassed by specifing a
48
backend-id.
49
"""
50

  
44 51

  
45 52
class Command(BaseCommand):
46
    help = "Create a new VM."
53
    help = "Create a new VM." + HELP_MSG
47 54

  
48 55
    output_transaction = True
49 56

  
50 57
    option_list = BaseCommand.option_list + (
51 58
            make_option("--backend-id", dest="backend_id",
52
                        help="ID of the Ganeti backend"),
59
                        help="Unique identifier of the Ganeti backend."
60
                             " Use snf-manage backend-list to find out"
61
                             " available backends."),
53 62
            make_option("--name", dest="name",
54
                        help="Name of the server."),
63
                        help="An arbitrary string for naming the server"),
55 64
            make_option("--user-id", dest="user_id",
56
                        help="ID of the Owner of the server."),
65
                        help="Unique identifier of the owner of the server"),
57 66
            make_option("--image-id", dest="image_id",
58
                        help="ID of the image."),
67
                        help="Unique identifier of the image."
68
                             " Use snf-manage image-list to find out"
69
                             " available images."),
59 70
            make_option("--flavor-id", dest="flavor_id",
60
                        help="ID of the flavor"),
71
                        help="Unique identifier of the flavor"
72
                             " Use snf-manage flavor-list to find out"
73
                             " available flavors."),
61 74
            make_option("--password", dest="password",
62 75
                        help="Password for the new server")
63 76
        )
b/snf-cyclades-app/synnefo/api/management/commands/server-modify.py
37 37

  
38 38
from synnefo.db.models import VirtualMachine
39 39

  
40
from ._common import format_bool, format_date
41

  
42 40

  
43 41
class Command(BaseCommand):
44 42
    args = "<server ID>"
45 43
    help = "Modify a server"
46
    
44

  
47 45
    option_list = BaseCommand.option_list + (
48 46
        make_option('--name',
49 47
            dest='name',
......
74 72
            dest='unsuspended',
75 73
            help="Mark a server as not suspended")
76 74
        )
77
    
75

  
78 76
    def handle(self, *args, **options):
79 77
        if len(args) != 1:
80 78
            raise CommandError("Please provide a server ID")
81
        
79

  
82 80
        try:
83 81
            server_id = int(args[0])
84 82
            server = VirtualMachine.objects.get(id=server_id)
85 83
        except (ValueError, VirtualMachine.DoesNotExist):
86 84
            raise CommandError("Invalid server ID")
87
        
85

  
88 86
        name = options.get('name')
89 87
        if name is not None:
90 88
            server.name = name
91
        
89

  
92 90
        owner = options.get('owner')
93 91
        if owner is not None:
94 92
            server.userid = owner
95
        
93

  
96 94
        state = options.get('state')
97 95
        if state is not None:
98 96
            allowed = [x[0] for x in VirtualMachine.OPER_STATES]
......
100 98
                msg = "Invalid state, must be one of %s" % ', '.join(allowed)
101 99
                raise CommandError(msg)
102 100
            server.operstate = state
103
        
101

  
104 102
        if options.get('deleted'):
105 103
            server.deleted = True
106 104
        elif options.get('undeleted'):
107 105
            server.deleted = False
108
        
106

  
109 107
        if options.get('suspended'):
110 108
            server.suspended = True
111 109
        elif options.get('unsuspended'):
112 110
            server.suspended = False
113
        
111

  
114 112
        server.save()
b/snf-cyclades-app/synnefo/logic/management/commands/backend-update-status.py
48 48
                   help="Update statistics of only this backend"),
49 49
        make_option('--older-than', dest='older_than', metavar="MINUTES",
50 50
                   help="Update only backends that have not been updated for\
51
                   MINUTES. Set to 0 to force update.")
51
                   MINUTES. Set to 0 to force update."),
52
        make_option('--include-drained', dest='drained',
53
                    default=False,
54
                    action='store_true',
55
                    help="Also update statistics of drained backends")
52 56
        )
53 57

  
54 58
    def handle(self, **options):
......
62 66
            except Backend.DoesNotExist:
63 67
                raise CommandError("Backend not found in DB")
64 68
        else:
65
            # XXX:filter drained ?
66
            backends = Backend.objects.all()
69
            backends = Backend.objects.filter(offline=False)
70

  
71
        if not options['drained']:
72
            backends = backends.filter(drained=False)
67 73

  
68 74
        now = datetime.datetime.now()
69 75
        if options['older_than'] is not None:
b/snf-cyclades-app/synnefo/plankton/management/commands/image-show.py
36 36

  
37 37
class Command(BaseCommand):
38 38
    args = "<image_id>"
39
    help = "Display available information about an image"
39 40

  
40 41
    def handle(self, *args, **options):
41 42

  

Also available in: Unified diff