def get_vm_name_by_uuid(vm_uuid): """ Returns vm_name for given vm_uuid, or None """ si = vmdk_ops.get_si() try: return vmdk_ops.vm_uuid2name(vm_uuid) except: return None
def get_vm_name_by_uuid(vm_uuid): """ Returns vm_name for given vm_uuid, or None TODO: Need to refactor further (can be a redundant method) """ si = vmdk_ops.get_si() try: return vmdk_ops.vm_uuid2name(vm_uuid) except: return None
def get_attached_to(metadata): """ Return which VM a volume is attached to based on its metadata. """ try: vm_name = vmdk_ops.vm_uuid2name(metadata[kv.ATTACHED_VM_UUID]) if not vm_name: if metadata[kv.ATTACHED_VM_UUID]: return metadata[kv.ATTACHED_VM_UUID] return kv.DETACHED return vm_name except: return kv.DETACHED
def get_attached_to(metadata): """ Return which VM a volume is attached to based on its metadata. """ try: if kv.ATTACHED_VM_UUID in metadata: vm_name = vmdk_ops.vm_uuid2name(metadata[kv.ATTACHED_VM_UUID]) if vm_name: return vm_name # If vm name couldn't be retrieved through uuid, use name from KV elif kv.ATTACHED_VM_NAME in metadata: return metadata[kv.ATTACHED_VM_NAME] else: return metadata[kv.ATTACHED_VM_UUID] else: return kv.DETACHED except: return kv.DETACHED