Tomas Golembiovsky has uploaded a new change for review. Change subject: v2v: Detect VM with snapshots ......................................................................
v2v: Detect VM with snapshots virt-v2v cannot properly handle conversion ov VMware machine with snapshots. Engine needs a way to know which machines have snapshots and which do not to filter them out and/or notify the user. Change-Id: I9aa4de2faff92625cd0de8e3ae2a10a2d58aa823 Signed-off-by: Tomáš Golembiovský <tgole...@redhat.com> --- M lib/api/vdsmapi-schema.json M lib/vdsm/v2v.py M tests/v2vTests.py 3 files changed, 36 insertions(+), 9 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/74/56574/1 diff --git a/lib/api/vdsmapi-schema.json b/lib/api/vdsmapi-schema.json index 4153f86..6ca50e2 100644 --- a/lib/api/vdsmapi-schema.json +++ b/lib/api/vdsmapi-schema.json @@ -4024,13 +4024,17 @@ # # @virtio_iso_path: #optional path for iso contains virtio guest drivers # +# @has_snapshots: Whether the VM has snapshots or not. +# (new in version 4.18.0) +# # Since: 4.17.0 ## {'type': 'ExternalVmInfo', 'data': {'vmName': 'str', 'status': 'VmStatus', 'vmId': 'UUID', 'smp': 'uint', 'memSize': 'uint', '*disks': ['ExternalDiskInfo'], '*networks': ['ExternalNetworkInfo'], '*format': 'VolumeFormat', - '*allocation': 'VolumeAllocation', '*virtio_iso_path': 'str'}} + '*allocation': 'VolumeAllocation', '*virtio_iso_path': 'str', + '*has_snapshots': 'bool'}} ## # @Host.getExternalVMs: diff --git a/lib/vdsm/v2v.py b/lib/vdsm/v2v.py index f96bda6..406b88c 100644 --- a/lib/vdsm/v2v.py +++ b/lib/vdsm/v2v.py @@ -802,6 +802,7 @@ except InvalidVMConfiguration as e: logging.error("error adding general info: %s", e) return + _add_has_snapshots(vm, params) _add_networks(root, params) _add_disks(root, params) for disk in params['disks']: @@ -897,6 +898,15 @@ params['networks'].append(i) +def _add_has_snapshots(vm, params): + try: + ret = vm.hasCurrentSnapshot() + except libvirt.libvirtError: + logging.exception("Error checking for existing snapshots") + else: + params['has_snapshots'] = ret > 0 + + def _read_ovf_from_ova(ova_path): """ virt-v2v support ova in tar, zip formats as well as diff --git a/tests/v2vTests.py b/tests/v2vTests.py index bad613f..d178c0d 100644 --- a/tests/v2vTests.py +++ b/tests/v2vTests.py @@ -41,13 +41,14 @@ import vmfakelib as fake -VmSpec = namedtuple('VmSpec', ['name', 'uuid', 'id', 'active']) +VmSpec = namedtuple('VmSpec', ['name', 'uuid', 'id', 'active', 'snapshots']) VM_SPECS = ( - VmSpec("RHEL_0", str(uuid.uuid4()), id=0, active=True), - VmSpec("RHEL_1", str(uuid.uuid4()), id=1, active=True), - VmSpec("RHEL_2", str(uuid.uuid4()), id=2, active=False), - VmSpec("RHEL_3", str(uuid.uuid4()), id=3, active=False) + VmSpec("RHEL_0", str(uuid.uuid4()), id=0, active=True, snapshots=False), + VmSpec("RHEL_1", str(uuid.uuid4()), id=1, active=True, snapshots=False), + VmSpec("RHEL_2", str(uuid.uuid4()), id=2, active=False, snapshots=False), + VmSpec("RHEL_3", str(uuid.uuid4()), id=3, active=False, snapshots=False), + VmSpec("RHEL_4", str(uuid.uuid4()), id=4, active=False, snapshots=True), ) FAKE_VIRT_V2V = CommandPath('fake-virt-v2v', @@ -68,12 +69,14 @@ def __init__(self, name="RHEL", vm_uuid="564d7cb4-8e3d-06ec-ce82-7b2b13c6a611", id=0, - active=False): + active=False, + snapshots=False): self._name = name self._uuid = vm_uuid self._mac_address = _mac_from_uuid(vm_uuid) self._id = id self._active = active + self._snapshots = snapshots def name(self): return self._name @@ -131,6 +134,9 @@ name=self._name, uuid=self._uuid, mac=self._mac_address) + + def hasCurrentSnapshot(self): + return self._snapshots # FIXME: extend vmfakelib allowing to set predefined domain in Connection class @@ -374,7 +380,12 @@ vms = v2v.get_external_vms('esx://mydomain', 'user', ProtectedPassword('password') )['vmList'] - self.assertEqual(len(vms), 2) + if methodname == 'lookupByName': + # Only active domains + self.assertEqual(len(vms), 2) + else: # if methodname == 'lookupByID' + # Only inactive domains + self.assertEqual(len(vms), 3) def testOutputParser(self): output = ''.join(['[ 0.0] Opening the source -i libvirt ://roo...\n', @@ -437,6 +448,7 @@ self.assertEquals(vm['smp'], 1) self.assertEquals(len(vm['disks']), 1) self.assertEquals(len(vm['networks']), 1) + self.assertEquals(vm['has_snapshots'], spec.snapshots) network = vm['networks'][0] self.assertEquals(network['type'], 'bridge') @@ -511,7 +523,8 @@ def test_list_defined_domains(self): vms = self._mock.listDefinedDomains() - self.assertEqual(len(vms), 2) + self.assertEqual(len(vms), + len([x for x in VM_SPECS if not x.active])) def test_list_domains_id(self): vms = self._mock.listDomainsID() -- To view, visit https://gerrit.ovirt.org/56574 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9aa4de2faff92625cd0de8e3ae2a10a2d58aa823 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Tomas Golembiovsky <tgole...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches