Commit 4b466e90 authored by Giorgos Verigakis's avatar Giorgos Verigakis
Browse files

Allow create_server to set initial metadata

parent 3f65f5f1
......@@ -151,16 +151,18 @@ def create_server(request):
server = req['server']
name = server['name']
metadata = server.get('metadata', {})
assert isinstance(metadata, dict)
sourceimage = Image.objects.get(id=server['imageRef'])
flavor = Flavor.objects.get(id=server['flavorRef'])
except KeyError:
except (KeyError, AssertionError):
raise BadRequest('Malformed request.')
except Image.DoesNotExist:
raise ItemNotFound
except Flavor.DoesNotExist:
raise ItemNotFound
vm = VirtualMachine.objects.create(
vm = VirtualMachine(
......@@ -189,7 +191,10 @@ def create_server(request):
beparams=dict(auto_balance=True, vcpus=flavor.cpu, memory=flavor.ram))
for key, val in metadata.items():
VirtualMachineMetadata.objects.create(meta_key=key, meta_value=val, vm=vm)'created vm with %s cpus, %s ram and %s storage' % (flavor.cpu, flavor.ram, flavor.disk))
server = vm_to_dict(vm, detail=True)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment