Exemple #1
0
 def setUp(self):
     super(ImageCacheManagerTestCase, self).setUp()
     self._session = mock.Mock(name="session")
     self._imagecache = imagecache.ImageCacheManager(self._session, "fake-base-folder")
     self._time = datetime.datetime(2012, 11, 22, 12, 00, 00)
     self._file_name = "ts-2012-11-22-12-00-00"
     fake.reset()
Exemple #2
0
 def setUp(self):
     super(ImageCacheManagerTestCase, self).setUp()
     self._session = mock.Mock(name='session')
     self._imagecache = imagecache.ImageCacheManager(self._session,
                                                     'fake-base-folder')
     self._time = datetime.datetime(2012, 11, 22, 12, 00, 00)
     self._file_name = 'ts-2012-11-22-12-00-00'
     fake.reset()
Exemple #3
0
    def setUp(self):

        super(VMwareVolumeOpsTestCase, self).setUp()
        vmwareapi_fake.reset()
        stubs.set_stubs(self.stubs)
        self._session = driver.VMwareAPISession()

        self._volumeops = volumeops.VMwareVolumeOps(self._session)
        self.instance = {'name': 'fake_name', 'uuid': 'fake_uuid'}
Exemple #4
0
    def setUp(self):

        super(VMwareVolumeOpsTestCase, self).setUp()
        vmwareapi_fake.reset()
        stubs.set_stubs(self.stubs)
        self._session = driver.VMwareAPISession()

        self._volumeops = volumeops.VMwareVolumeOps(self._session)
        self.instance = {'name': 'fake_name', 'uuid': 'fake_uuid'}
Exemple #5
0
    def setUp(self):
        super(VMwareVMUtilGetHostRefTestCase, self).setUp()
        fake.reset()
        vm_util.vm_refs_cache_reset()

        self.session = driver.VMwareAPISession()

        # Create a fake VirtualMachine running on a known host
        self.host_ref = fake._db_content['HostSystem'].keys()[0]
        self.vm_ref = fake.create_vm(host_ref=self.host_ref)
Exemple #6
0
 def setUp(self):
     super(DsUtilTestCase, self).setUp()
     self.session = fake.FakeSession()
     self.flags(api_retry_count=1, group='vmware')
     fake.reset()
Exemple #7
0
    def setUp(self):
        super(ConfigDriveTestCase, self).setUp()
        vm_util.vm_refs_cache_reset()
        self.context = context.RequestContext('fake', 'fake', is_admin=False)
        cluster_name = 'test_cluster'
        self.flags(cluster_name=[cluster_name],
                   host_ip='test_url',
                   host_username='******',
                   host_password='******',
                   use_linked_clone=False,
                   group='vmware')
        self.flags(vnc_enabled=False)
        vmwareapi_fake.reset()
        stubs.set_stubs(self.stubs)
        nova.tests.image.fake.stub_out_image_service(self.stubs)
        self.conn = driver.VMwareVCDriver(fake.FakeVirtAPI)
        self.network_info = utils.get_test_network_info()
        self.vim = vmwareapi_fake.FakeVim()
        self.node_name = '%s(%s)' % (self.conn.dict_mors.keys()[0],
                                     cluster_name)
        image_ref = nova.tests.image.fake.get_valid_image_id()
        instance_values = {
            'vm_state': 'building',
            'project_id': 'fake',
            'user_id': 'fake',
            'name': '1',
            'kernel_id': '1',
            'ramdisk_id': '1',
            'mac_addresses': [{
                'address': 'de:ad:be:ef:be:ef'
            }],
            'memory_mb': 8192,
            'flavor': 'm1.large',
            'vcpus': 4,
            'root_gb': 80,
            'image_ref': image_ref,
            'host': 'fake_host',
            'task_state': 'scheduling',
            'reservation_id': 'r-3t8muvr0',
            'id': 1,
            'uuid': 'fake-uuid',
            'node': self.node_name,
            'metadata': []
        }
        self.test_instance = fake_instance.fake_instance_obj(
            self.context, **instance_values)

        (image_service,
         image_id) = glance.get_remote_image_service(context, image_ref)
        metadata = image_service.show(context, image_id)
        self.image = {
            'id': image_ref,
            'disk_format': 'vmdk',
            'size': int(metadata['size']),
        }

        class FakeInstanceMetadata(object):
            def __init__(self, instance, content=None, extra_md=None):
                pass

            def metadata_for_config_drive(self):
                return []

        self.useFixture(
            fixtures.MonkeyPatch('nova.api.metadata.base.InstanceMetadata',
                                 FakeInstanceMetadata))

        def fake_make_drive(_self, _path):
            pass

        # We can't actually make a config drive v2 because ensure_tree has
        # been faked out
        self.stubs.Set(nova.virt.configdrive.ConfigDriveBuilder, 'make_drive',
                       fake_make_drive)

        def fake_upload_iso_to_datastore(iso_path, instance, **kwargs):
            pass

        self.stubs.Set(vmware_images, 'upload_iso_to_datastore',
                       fake_upload_iso_to_datastore)
Exemple #8
0
 def setUp(self):
     super(VMwareVIMUtilTestCase, self).setUp()
     fake.reset(vc=True)
     self.vim = fake.FakeVim()
     self.vim._login()
Exemple #9
0
    def setUp(self):
        super(ConfigDriveTestCase, self).setUp()
        vm_util.vm_refs_cache_reset()
        self.context = context.RequestContext("fake", "fake", is_admin=False)
        cluster_name = "test_cluster"
        self.flags(
            cluster_name=[cluster_name],
            host_ip="test_url",
            host_username="******",
            host_password="******",
            use_linked_clone=False,
            group="vmware",
        )
        self.flags(vnc_enabled=False)
        vmwareapi_fake.reset()
        stubs.set_stubs(self.stubs)
        nova.tests.image.fake.stub_out_image_service(self.stubs)
        self.conn = driver.VMwareVCDriver(fake.FakeVirtAPI)
        self.network_info = utils.get_test_network_info()
        self.vim = vmwareapi_fake.FakeVim()
        self.node_name = "%s(%s)" % (self.conn.dict_mors.keys()[0], cluster_name)
        image_ref = nova.tests.image.fake.get_valid_image_id()
        instance_values = {
            "vm_state": "building",
            "project_id": "fake",
            "user_id": "fake",
            "name": "1",
            "kernel_id": "1",
            "ramdisk_id": "1",
            "mac_addresses": [{"address": "de:ad:be:ef:be:ef"}],
            "memory_mb": 8192,
            "flavor": "m1.large",
            "instance_type_id": 0,
            "vcpus": 4,
            "root_gb": 80,
            "image_ref": image_ref,
            "host": "fake_host",
            "task_state": "scheduling",
            "reservation_id": "r-3t8muvr0",
            "id": 1,
            "uuid": "fake-uuid",
            "node": self.node_name,
            "metadata": [],
        }
        self.test_instance = fake_instance.fake_instance_obj(self.context, **instance_values)

        (image_service, image_id) = glance.get_remote_image_service(context, image_ref)
        metadata = image_service.show(context, image_id)
        self.image = {"id": image_ref, "disk_format": "vmdk", "size": int(metadata["size"])}

        class FakeInstanceMetadata(object):
            def __init__(self, instance, content=None, extra_md=None):
                pass

            def metadata_for_config_drive(self):
                return []

        self.useFixture(fixtures.MonkeyPatch("nova.api.metadata.base.InstanceMetadata", FakeInstanceMetadata))

        def fake_make_drive(_self, _path):
            pass

        # We can't actually make a config drive v2 because ensure_tree has
        # been faked out
        self.stubs.Set(nova.virt.configdrive.ConfigDriveBuilder, "make_drive", fake_make_drive)

        def fake_upload_iso_to_datastore(iso_path, instance, **kwargs):
            pass

        self.stubs.Set(vmware_images, "upload_iso_to_datastore", fake_upload_iso_to_datastore)
Exemple #10
0
 def tearDown(self):
     super(DsUtilTestCase, self).tearDown()
     fake.reset()
Exemple #11
0
 def setUp(self):
     super(VMwareVMUtilTestCase, self).setUp()
     fake.reset()
     vm_util.vm_refs_cache_reset()
Exemple #12
0
 def tearDown(self):
     super(DsUtilTestCase, self).tearDown()
     fake.reset()
Exemple #13
0
    def setUp(self, mock_register):
        super(ConfigDriveTestCase, self).setUp()
        vm_util.vm_refs_cache_reset()
        self.context = context.RequestContext('fake', 'fake', is_admin=False)
        cluster_name = 'test_cluster'
        self.flags(cluster_name=[cluster_name],
                   host_ip='test_url',
                   host_username='******',
                   host_password='******',
                   use_linked_clone=False, group='vmware')
        self.flags(vnc_enabled=False)
        vmwareapi_fake.reset()
        stubs.set_stubs(self.stubs)
        nova.tests.image.fake.stub_out_image_service(self.stubs)
        self.conn = driver.VMwareVCDriver(fake.FakeVirtAPI)
        self.network_info = utils.get_test_network_info()
        self.node_name = '%s(%s)' % (self.conn.dict_mors.keys()[0],
                                     cluster_name)
        image_ref = nova.tests.image.fake.get_valid_image_id()
        instance_values = {
            'vm_state': 'building',
            'project_id': 'fake',
            'user_id': 'fake',
            'name': '1',
            'kernel_id': '1',
            'ramdisk_id': '1',
            'mac_addresses': [{'address': 'de:ad:be:ef:be:ef'}],
            'memory_mb': 8192,
            'flavor': 'm1.large',
            'instance_type_id': 0,
            'vcpus': 4,
            'root_gb': 80,
            'image_ref': image_ref,
            'host': 'fake_host',
            'task_state': 'scheduling',
            'reservation_id': 'r-3t8muvr0',
            'id': 1,
            'uuid': 'fake-uuid',
            'node': self.node_name,
            'metadata': [],
            'expected_attrs': ['system_metadata'],
        }
        self.test_instance = fake_instance.fake_instance_obj(self.context,
                                                             **instance_values)

        (image_service, image_id) = glance.get_remote_image_service(context,
                                    image_ref)
        metadata = image_service.show(context, image_id)
        self.image = {
            'id': image_ref,
            'disk_format': 'vmdk',
            'size': int(metadata['size']),
        }

        class FakeInstanceMetadata(object):
            def __init__(self, instance, content=None, extra_md=None):
                pass

            def metadata_for_config_drive(self):
                return []

        self.useFixture(fixtures.MonkeyPatch(
                'nova.api.metadata.base.InstanceMetadata',
                FakeInstanceMetadata))

        def fake_make_drive(_self, _path):
            pass
        # We can't actually make a config drive v2 because ensure_tree has
        # been faked out
        self.stubs.Set(nova.virt.configdrive.ConfigDriveBuilder,
                       'make_drive', fake_make_drive)

        def fake_upload_iso_to_datastore(iso_path, instance, **kwargs):
            pass
        self.stubs.Set(images,
                       'upload_iso_to_datastore',
                       fake_upload_iso_to_datastore)
Exemple #14
0
    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 = ds_util.Datastore(ref=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)
        ])
Exemple #15
0
 def setUp(self):
     super(VMwareVIMUtilTestCase, self).setUp()
     fake.reset()
     self.vim = fake.FakeVim()
     self.vim._login()
Exemple #16
0
 def tearDown(self):
     super(VMwareVMUtilTestCase, self).tearDown()
     fake.reset()
Exemple #17
0
 def setUp(self):
     super(VMwareVMUtilTestCase, self).setUp()
     fake.reset()
     vm_util.vm_refs_cache_reset()
Exemple #18
0
    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 = ds_util.Datastore(
                ref=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)
                ])
Exemple #19
0
 def tearDown(self):
     super(ImageCacheManagerTestCase, self).tearDown()
     fake.reset()
Exemple #20
0
 def tearDown(self):
     super(VMwareVMUtilTestCase, self).tearDown()
     fake.reset()
Exemple #21
0
 def setUp(self):
     super(DsUtilTestCase, self).setUp()
     self.session = fake.FakeSession()
     self.flags(api_retry_count=1, group='vmware')
     fake.reset()