Commit 0be24b70 by Belákovics Ádám

Fix conversion error

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