Commit 0be24b70 by Belákovics Ádám

Fix conversion error

parent e1cdc179
Pipeline #713 failed with stage
in 38 seconds
......@@ -44,10 +44,10 @@ class OSVirtualMachineManager(InstanceInterface):
devices.append(b_device)
flavor = self.get_flavor(flavor)
new_server = self.openstack.compute.create_server(name=name,
flavorRef=flavor.id,
networks=networks,
block_device_mapping=devices
)
flavorRef=flavor.id,
networks=networks,
block_device_mapping=devices
)
return self.convert_server_to_instance(new_server)
@openstackError
......@@ -97,7 +97,7 @@ class OSVirtualMachineManager(InstanceInterface):
flavors = []
for flavor in self.openstack.compute.flavors():
flavors.append(Flavor(flavor.name, flavor.id, flavor.ram,
flavor.vcpus, flavor.disk))
flavor.vcpus, flavor.disk))
return flavors
@openstackError
......@@ -190,8 +190,11 @@ class OSVirtualMachineManager(InstanceInterface):
def attach_volume(self, server_id, volume_id, device=None):
self.openstack.compute.create_volume_attachment(server_id,
{"volumeId": volume_id,
"device": device
# server = interface.openstack.compute.get_server("8e94c162-f8ed-4872-b9e5-50bf33040b5b")
#
# print(server) "device": device
})
@openstackError
def detach_volume(self, server_id, volume_id, device=None):
self.openstack.compute.delete_volume_attachment(server_id,
......@@ -199,17 +202,16 @@ class OSVirtualMachineManager(InstanceInterface):
"device": device
})
def convert_server_to_instance(self, server):
if not server.image:
image_id = None
else:
image_id = server.image.id
image_id = server.image_id
return Instance(id=server.id,
flavor=server.flavor.id,
flavor=server.flavor_id,
name=server.name,
image_id=image_id,
disks=server.volumes,
disks=server.attached_volumes,
status=server.status,
launched_at=server.launched_at,
terminated_at=server.terminated_at,
......
......@@ -23,14 +23,20 @@ print('#'*40)
# interface.create_vm_from_template('new_server', resource, "cirros-0.4.0-x86_64-disk")
# interface.stop_vm('a6bc504f-a422-4492-b429-e5dad2df12f4')
# server = interface.get_vm("8e94c162-f8ed-4872-b9e5-50bf33040b5b")
# server = interface.openstack.compute.get_server("8e94c162-f8ed-4872-b9e5-50bf33040b5b")
#
# print(server)
# print(interface.delete_flavor("flavorTest"))
for flavor in interface.list_flavors():
print(flavor.JSON())
# print(interface.create_base_vm("BaseTest", "2", networks, block_dev_map))
for vm in interface.list_all_vm():
print(vm.JSON())
print("*" * 50)
print(interface.create_base_vm("BaseTest", "2", networks, block_dev_map).JSON())
# print(interface.convert_server_to_instance(server).JSON())
......
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