From f2e5f5a97ef63e09e24a1d9e6ed8c6ed9a443e54 Mon Sep 17 00:00:00 2001 From: David Weinholz Date: Wed, 7 Aug 2019 12:01:39 +0200 Subject: [PATCH] feature(Snapshot):visual difference in snapshots and images --- VirtualMachineService/VirtualMachineHandler.py | 14 +++++++++----- VirtualMachineService/ttypes.py | 14 +++++++++++++- portal_client.thrift | 3 +++ 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/VirtualMachineService/VirtualMachineHandler.py b/VirtualMachineService/VirtualMachineHandler.py index 67c61364..9bfb03cf 100644 --- a/VirtualMachineService/VirtualMachineHandler.py +++ b/VirtualMachineService/VirtualMachineHandler.py @@ -260,6 +260,7 @@ def get_Images(self): metadata = img["metadata"] description = metadata.get("description") tags = img.get("tags") + image_type = img.get("image_type", "image") if description is None: self.logger.warning("No Description and for " + img["name"]) @@ -273,7 +274,10 @@ def get_Images(self): openstack_id=img["id"], description=description, tag=tags, + is_snapshot=image_type == "snapshot" ) + self.logger.info(image) + images.append(image) return images @@ -655,13 +659,13 @@ def create_and_deploy_playbook(self, private_key, play_source, openstack_id): status, stdout, stderr = playbook.run_it() self.delete_keypair(key_name=key_name) if status != 0: - # self.logger.exception(msg="Bioconda playbook for {0} encountered an error with status code {1}. The messages are:" - # "stdout: {2}" - # "stderr: {3}".format(openstack_id, status, stdout, stderr)) + # self.logger.exception(msg="Bioconda playbook for {0} encountered an error with status code {1}. The messages are:" + # "stdout: {2}" + # "stderr: {3}".format(openstack_id, status, stdout, stderr)) osi_key_dict[openstack_id]["status"] = self.BIOCONDA_FAILED else: - # self.logger.info("Finished Bioconda Playbook for (openstack_id): {0} with status code: {1}" - # .format(openstack_id, status)) + # self.logger.info("Finished Bioconda Playbook for (openstack_id): {0} with status code: {1}" + # .format(openstack_id, status)) osi_key_dict[openstack_id]["status"] = self.ACTIVE return status diff --git a/VirtualMachineService/ttypes.py b/VirtualMachineService/ttypes.py index 398bda72..74495977 100644 --- a/VirtualMachineService/ttypes.py +++ b/VirtualMachineService/ttypes.py @@ -175,11 +175,12 @@ class Image(object): - openstack_id: The openstack_id the image - description: The description of the image - tag: List of tags from image + - is_snapshot: If the Image is a snapshot """ - def __init__(self, name=None, min_disk=None, min_ram=None, status=None, created_at=None, updated_at=None, openstack_id=None, description=None, tag=None,): + def __init__(self, name=None, min_disk=None, min_ram=None, status=None, created_at=None, updated_at=None, openstack_id=None, description=None, tag=None, is_snapshot=None,): self.name = name self.min_disk = min_disk self.min_ram = min_ram @@ -189,6 +190,7 @@ def __init__(self, name=None, min_disk=None, min_ram=None, status=None, created_ self.openstack_id = openstack_id self.description = description self.tag = tag + self.is_snapshot = is_snapshot def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: @@ -249,6 +251,11 @@ def read(self, iprot): iprot.readListEnd() else: iprot.skip(ftype) + elif fid == 10: + if ftype == TType.BOOL: + self.is_snapshot = iprot.readBool() + else: + iprot.skip(ftype) else: iprot.skip(ftype) iprot.readFieldEnd() @@ -298,6 +305,10 @@ def write(self, oprot): oprot.writeString(iter13.encode('utf-8') if sys.version_info[0] == 2 else iter13) oprot.writeListEnd() oprot.writeFieldEnd() + if self.is_snapshot is not None: + oprot.writeFieldBegin('is_snapshot', TType.BOOL, 10) + oprot.writeBool(self.is_snapshot) + oprot.writeFieldEnd() oprot.writeFieldStop() oprot.writeStructEnd() @@ -1137,6 +1148,7 @@ def __ne__(self, other): (7, TType.STRING, 'openstack_id', 'UTF8', None, ), # 7 (8, TType.STRING, 'description', 'UTF8', None, ), # 8 (9, TType.LIST, 'tag', (TType.STRING, 'UTF8', False), None, ), # 9 + (10, TType.BOOL, 'is_snapshot', None, None, ), # 10 ) all_structs.append(VM) VM.thrift_spec = ( diff --git a/portal_client.thrift b/portal_client.thrift index 09edaeff..d8fd9ecd 100644 --- a/portal_client.thrift +++ b/portal_client.thrift @@ -67,6 +67,9 @@ struct Image{ /** List of tags from image */ 9: required list tag + + /** If the Image is a snapshot*/ + 10:optional bool is_snapshot } /** * This Struct defines a VirtualMachine.