예제 #1
0
    def test_filter_datastores_specific_match(self):

        data = [
            ['VMFS', 'os-some-name', True, 987654321, 1234678],
            ['NFS', 'another-name', True, 9876543210, 123467890],
            ['BAD', 'some-name-bad', True, 98765432100, 1234678900],
            ['VMFS', 'some-name-good', True, 987654321, 12346789],
            ['VMFS', 'some-other-good', False, 987654321000, 12346789000],
        ]
        # only the DS some-name-good is accessible and matches the regex
        datastores = self.build_result_set(data)
        datastore_regex = re.compile('.*-good$')

        best_match = vm_util.DSRecord(datastore=None,
                                      name=None,
                                      capacity=None,
                                      freespace=0)
        rec = vm_util._select_datastore(datastores, best_match,
                                        datastore_regex)

        self.assertIsNotNone(rec, "could not find datastore!")
        self.assertEqual('ds-003', rec[0].value,
                         "didn't find the right datastore!")
        self.assertNotEqual('ds-004', rec[0].value,
                            "accepted an unreachable datastore!")
        self.assertEqual('some-name-good', rec[1])
        self.assertEqual(12346789, rec[3], "did not obtain correct freespace!")
        self.assertEqual(987654321, rec[2], "did not obtain correct capacity!")
예제 #2
0
    def test_filter_datastores_empty(self):
        data = []
        datastores = self.build_result_set(data)

        best_match = vm_util.DSRecord(
            datastore=None, name=None, type=None, capacity=None, freespace=0,
            accessible=False)
        rec = vm_util._select_datastore(datastores, best_match)

        self.assertEqual(rec, best_match)
예제 #3
0
 def test_is_valid_ds_record(self):
     data = [
         ['VMFS', 'spam-good', True, 20 * units.Gi, 10 * units.Gi],
         ['NFS', 'eggs-good', True, 40 * units.Gi, 15 * units.Gi],
         ['CFS', 'some-name-good', True, 50 * units.Gi, 5 * units.Gi],
         ['NFS', 'some-other-good', False, 10 * units.Gi, 10 * units.Gi],
     ]
     validated_recs = [vm_util._is_valid_ds_record(vm_util.DSRecord(
         datastore='ds-100', type=row[0], name=row[1], accessible=row[2],
         capacity=row[3], freespace=row[4])) for row in data]
     self.assertEqual([True, True, False, False], validated_recs)
예제 #4
0
    def test_filter_datastores_no_match(self):
        datastores = self.build_result_set(self.data)
        datastore_regex = re.compile('no_match.*')

        best_match = vm_util.DSRecord(datastore=None,
                                      name=None,
                                      capacity=None,
                                      freespace=0)
        rec = vm_util._select_datastore(datastores, best_match,
                                        datastore_regex)

        self.assertEqual(rec, best_match, "did not match datastore properly")
예제 #5
0
    def test_filter_datastores_simple(self):
        datastores = self.build_result_set(self.data)
        best_match = vm_util.DSRecord(
            datastore=None, name=None, capacity=None, freespace=0, type=None,
            accessible=True)
        rec = vm_util._select_datastore(datastores, best_match)

        self.assertIsNotNone(rec[0], "could not find datastore!")
        self.assertEqual('ds-001', rec[0].value,
                         "didn't find the right datastore!")
        self.assertEqual(123467890, rec[3],
                         "did not obtain correct freespace!")
예제 #6
0
    def test_filter_datastores_missing_props(self):
        data = [
            ['VMFS', 'os-some-name', 987654321, 1234678],
            ['NFS', 'another-name', 9876543210, 123467890],
        ]
        # no matches are expected when 'summary.accessible' is missing
        prop_names = ['summary.type', 'summary.name',
                      'summary.capacity', 'summary.freeSpace']
        datastores = self.build_result_set(data, prop_names)
        best_match = vm_util.DSRecord(
            datastore=None, name=None, capacity=None, freespace=None,
            type=None, accessible=False)

        rec = vm_util._select_datastore(datastores, best_match)
        self.assertEqual(rec, best_match, "no matches were expected")
예제 #7
0
    def test_filter_datastores_best_match(self):
        data = [
            ['VMFS', 'spam-good', True, 20 * units.Gi, 10 * units.Gi],
            ['NFS', 'eggs-good', True, 40 * units.Gi, 15 * units.Gi],
            ['BAD', 'some-name-bad', True, 30 * units.Gi, 20 * units.Gi],
            ['VMFS', 'some-name-good', True, 50 * units.Gi, 5 * units.Gi],
            ['VMFS', 'some-other-good', True, 10 * units.Gi, 10 * units.Gi],
        ]

        datastores = self.build_result_set(data)
        datastore_regex = re.compile('.*-good$')

        # the current best match is better than all candidates
        best_match = vm_util.DSRecord(datastore='ds-100',
                                      name='best-ds-good',
                                      capacity=20 * units.Gi,
                                      freespace=19 * units.Gi)
        rec = vm_util._select_datastore(datastores, best_match,
                                        datastore_regex)
        self.assertEqual(rec, best_match, "did not match datastore properly")
예제 #8
0
파일: test_vmops.py 프로젝트: xzj675/nova
    def setUp(self):
        super(VMwareVMOpsTestCase, self).setUp()
        vmwareapi_fake.reset()
        stubs.set_stubs(self.stubs)
        self.flags(image_cache_subdirectory_name='vmware_base',
                   my_ip='',
                   flat_injected=True,
                   vnc_enabled=True)
        self._context = context.RequestContext('fake_user', 'fake_project')
        self._session = driver.VMwareAPISession()

        self._virtapi = mock.Mock()
        self._vmops = vmops.VMwareVCVMOps(self._session, self._virtapi, None)

        self._image_id = nova.tests.image.fake.get_valid_image_id()
        values = {
            'name': 'fake_name',
            'uuid': 'fake_uuid',
            'vcpus': 1,
            'memory_mb': 512,
            'image_ref': self._image_id,
            'root_gb': 1,
            'node': 'respool-1001(MyResPoolName)'
        }
        self._instance = fake_instance.fake_instance_obj(
                                 self._context, **values)

        fake_ds_ref = vmwareapi_fake.ManagedObjectReference('fake-ds')

        self._ds_record = vm_util.DSRecord(
                datastore=fake_ds_ref, name='fake_ds',
                capacity=10 * units.Gi,
                freespace=10 * units.Gi)
        self._dc_info = vmops.DcInfo(
                ref='fake_dc_ref', name='fake_dc',
                vmFolder='fake_vm_folder')

        subnet_4 = network_model.Subnet(cidr='192.168.0.1/24',
                                        dns=[network_model.IP('192.168.0.1')],
                                        gateway=
                                            network_model.IP('192.168.0.1'),
                                        ips=[
                                            network_model.IP('192.168.0.100')],
                                        routes=None)
        subnet_6 = network_model.Subnet(cidr='dead:beef::1/64',
                                        dns=None,
                                        gateway=
                                            network_model.IP('dead:beef::1'),
                                        ips=[network_model.IP(
                                            'dead:beef::dcad:beff:feef:0')],
                                        routes=None)
        network = network_model.Network(id=0,
                                        bridge='fa0',
                                        label='fake',
                                        subnets=[subnet_4, subnet_6],
                                        vlan=None,
                                        bridge_interface=None,
                                        injected=True)
        self.network_info = network_model.NetworkInfo([
                network_model.VIF(id=None,
                                  address='DE:AD:BE:EF:00:00',
                                  network=network,
                                  type=None,
                                  devname=None,
                                  ovs_interfaceid=None,
                                  rxtx_cap=3)
                ])
        pure_IPv6_network = network_model.Network(id=0,
                                        bridge='fa0',
                                        label='fake',
                                        subnets=[subnet_6],
                                        vlan=None,
                                        bridge_interface=None,
                                        injected=True)
        self.pure_IPv6_network_info = network_model.NetworkInfo([
                network_model.VIF(id=None,
                                  address='DE:AD:BE:EF:00:00',
                                  network=pure_IPv6_network,
                                  type=None,
                                  devname=None,
                                  ovs_interfaceid=None,
                                  rxtx_cap=3)
                ])