Commit b5a40679 by Chif Gergő

Fix multiple creation in vm module

parent 200ae4f7
Pipeline #802 failed with stage
in 38 seconds
...@@ -9,7 +9,6 @@ class OpenStackConnection(object): ...@@ -9,7 +9,6 @@ class OpenStackConnection(object):
The connection only connects when something called in it.""" The connection only connects when something called in it."""
def __init__(self, auth): def __init__(self, auth):
super(OpenStackConnection, self).__init__()
self.openstack = openstack.connect(auth_url=auth["auth_url"], self.openstack = openstack.connect(auth_url=auth["auth_url"],
username=auth["username"], username=auth["username"],
password=auth["password"], password=auth["password"],
......
...@@ -50,7 +50,7 @@ class OSVirtualMachineManager(InstanceInterface, OpenStackConnection): ...@@ -50,7 +50,7 @@ class OSVirtualMachineManager(InstanceInterface, OpenStackConnection):
@openstackError @openstackError
def create_vm_from_template(self, name, image, flavor, networks): def create_vm_from_template(self, name, image, flavor, networks):
return self.create_multiple_vm_from_template(name, image, flavor, return self.create_multiple_vm_from_template(name, image, flavor,
networks, 1) networks, 1)[0]
@openstackError @openstackError
def create_multiple_vm_from_template(self, name, image, flavor, networks, def create_multiple_vm_from_template(self, name, image, flavor, networks,
...@@ -62,13 +62,18 @@ class OSVirtualMachineManager(InstanceInterface, OpenStackConnection): ...@@ -62,13 +62,18 @@ class OSVirtualMachineManager(InstanceInterface, OpenStackConnection):
if not image: if not image:
raise ValueError("The template not found") raise ValueError("The template not found")
server_ids = []
# TODO: Maybe we need parallel execution of multiple creation
for i in range(0, number):
new_server = compute.create_server(name=name, new_server = compute.create_server(name=name,
flavorRef=flav.id, flavorRef=flav.id,
imageRef=image.id, imageRef=image.id,
networks=networks, networks=networks,
min_count=number,
) )
return self.convert_server_to_instance(new_server) server_ids.append(new_server.id)
return server_ids
@openstackError @openstackError
def create_flavor(self, name, ram, vcpus, initial_disk): def create_flavor(self, name, ram, vcpus, initial_disk):
......
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 sign in to comment