Revision 9621c777 snf-cyclades-app/synnefo/api/management/commands/server-create.py
b/snf-cyclades-app/synnefo/api/management/commands/server-create.py | ||
---|---|---|
56 | 56 |
help = "Create a new VM." + HELP_MSG |
57 | 57 |
|
58 | 58 |
option_list = BaseCommand.option_list + ( |
59 |
make_option("--backend-id", dest="backend_id",
|
|
60 |
help="Unique identifier of the Ganeti backend."
|
|
61 |
" Use snf-manage backend-list to find out"
|
|
62 |
" available backends."),
|
|
63 |
make_option("--name", dest="name",
|
|
64 |
help="An arbitrary string for naming the server"),
|
|
65 |
make_option("--user-id", dest="user_id",
|
|
66 |
help="Unique identifier of the owner of the server"),
|
|
67 |
make_option("--image-id", dest="image_id",
|
|
68 |
help="Unique identifier of the image."
|
|
69 |
" Use snf-manage image-list to find out"
|
|
70 |
" available images."),
|
|
71 |
make_option("--flavor-id", dest="flavor_id",
|
|
72 |
help="Unique identifier of the flavor"
|
|
73 |
" Use snf-manage flavor-list to find out"
|
|
74 |
" available flavors."),
|
|
75 |
make_option("--password", dest="password",
|
|
76 |
help="Password for the new server")
|
|
77 |
)
|
|
59 |
make_option("--backend-id", dest="backend_id", |
|
60 |
help="Unique identifier of the Ganeti backend." |
|
61 |
" Use snf-manage backend-list to find out" |
|
62 |
" available backends."), |
|
63 |
make_option("--name", dest="name", |
|
64 |
help="An arbitrary string for naming the server"), |
|
65 |
make_option("--user-id", dest="user_id", |
|
66 |
help="Unique identifier of the owner of the server"), |
|
67 |
make_option("--image-id", dest="image_id", |
|
68 |
help="Unique identifier of the image." |
|
69 |
" Use snf-manage image-list to find out" |
|
70 |
" available images."), |
|
71 |
make_option("--flavor-id", dest="flavor_id", |
|
72 |
help="Unique identifier of the flavor" |
|
73 |
" Use snf-manage flavor-list to find out" |
|
74 |
" available flavors."), |
|
75 |
make_option("--password", dest="password", |
|
76 |
help="Password for the new server") |
|
77 |
) |
|
78 | 78 |
|
79 | 79 |
@transaction.commit_manually |
80 | 80 |
def handle(self, *args, **options): |
... | ... | |
106 | 106 |
image = {} |
107 | 107 |
image['backend_id'] = img['location'] |
108 | 108 |
image['format'] = img['disk_format'] |
109 |
image['metadata'] = dict((key.upper(), val) \
|
|
109 |
image['metadata'] = dict((key.upper(), val) |
|
110 | 110 |
for key, val in properties.items()) |
111 | 111 |
else: |
112 | 112 |
raise CommandError("image-id is mandatory") |
... | ... | |
136 | 136 |
# Get Public address |
137 | 137 |
(network, address) = util.allocate_public_address(backend) |
138 | 138 |
if address is None: |
139 |
raise CommandError("Can not allocate a public address."\
|
|
139 |
raise CommandError("Can not allocate a public address." |
|
140 | 140 |
" No available public network.") |
141 | 141 |
nic = {'ip': address, 'network': network.backend_id} |
142 | 142 |
|
Also available in: Unified diff