Ejemplo n.º 1
0
 def setUp(self):
     super(GetNetworkWithTheNameTestCase, self).setUp()
     fake.reset()
     self.stubs.Set(driver.VMwareAPISession, "vim", stubs.fake_vim_prop)
     self.stubs.Set(driver.VMwareAPISession, "_is_vim_object",
                    stubs.fake_is_vim_object)
     self._session = driver.VMwareAPISession()
Ejemplo n.º 2
0
 def setUp(self):
     super(GetNetworkWithTheNameTestCase, self).setUp()
     fake.reset()
     self.stubs.Set(driver.VMwareAPISession, "vim", stubs.fake_vim_prop)
     self.stubs.Set(driver.VMwareAPISession, "_is_vim_object",
                    stubs.fake_is_vim_object)
     self._session = driver.VMwareAPISession()
Ejemplo n.º 3
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()
Ejemplo n.º 4
0
    def setUp(self):
        super(OVSvAppVMOpsTestCase, self).setUp()
        fake_ds_ref = vmwareapi_fake.ManagedObjectReference('fake-ds')
        vmwareapi_fake.reset()
        cluster = vmwareapi_fake.create_cluster('fake_cluster', fake_ds_ref)
        self.flags(enabled=True, group='vnc')
        self.flags(image_cache_subdirectory_name='vmware_base',
                   my_ip='',
                   flat_injected=True)
        self._context = context.RequestContext('fake_user', 'fake_project')
        self._session = driver.VMwareAPISession()

        self._virtapi = mock.Mock()
        self._image_id = nova.tests.unit.image.fake.get_valid_image_id()
        self._instance_values = {
            'name': 'fake_name',
            'display_name': 'fake_display_name',
            'uuid': self._uuid,
            'vcpus': 1,
            'memory_mb': 512,
            'image_ref': self._image_id,
            'root_gb': 10,
            'node': '%s(%s)' % (cluster.mo_id, cluster.name),
            'expected_attrs': ['system_metadata'],
        }
        self._instance = fake_instance.fake_instance_obj(
            self._context, **self._instance_values)
        self._image_meta = objects.ImageMeta.from_dict({'id': self._image_id})
        self._flavor = objects.Flavor(name='m1.small', memory_mb=512, vcpus=1,
                                      root_gb=10, ephemeral_gb=0, swap=0,
                                      extra_specs={})
        self._instance.flavor = self._flavor
        self._vmops = ovsvapp_vmops.OVSvAppVMOps(self._session, self._virtapi,
                                                 None, cluster=cluster.obj)
Ejemplo n.º 5
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()
Ejemplo n.º 6
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'}
Ejemplo n.º 7
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'}
Ejemplo n.º 8
0
 def setUp(self):
     super(GetNetworkWithTheNameTestCase, self).setUp()
     fake.reset()
     self.stub_out('nova.virt.vmwareapi.driver.VMwareAPISession.vim',
                   stubs.fake_vim_prop)
     self.stub_out(
         'nova.virt.vmwareapi.driver.'
         'VMwareAPISession.is_vim_object', stubs.fake_is_vim_object)
     self._session = driver.VMwareAPISession()
Ejemplo n.º 9
0
 def setUp(self):
     super(GetNetworkWithTheNameTestCase, self).setUp()
     fake.reset()
     self.stub_out('nova.virt.vmwareapi.driver.VMwareAPISession.vim',
                   stubs.fake_vim_prop)
     self.stub_out('nova.virt.vmwareapi.driver.'
                   'VMwareAPISession.is_vim_object',
                    stubs.fake_is_vim_object)
     self._session = driver.VMwareAPISession()
Ejemplo n.º 10
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)
def reset_fakes():
    vmwareapi_fake.reset()
    vmwareapi_fake._db_content["DistributedVirtualPortgroup"] = {}
    vmwareapi_fake._db_content["VmwareDistributedVirtualSwitch"] = {}
    create_distributed_virtual_portgroup()
    create_distributed_virtual_switch()

    # Add DistributedVirtualPortgroup reference to existing HostSystem Object
    host_ref = (vmwareapi_fake._db_content["HostSystem"]
                [vmwareapi_fake._db_content["HostSystem"].keys()[0]])
    for prop in host_ref.propSet:
        if prop.name == "network":
            net_key = (vmwareapi_fake.
                       _db_content["DistributedVirtualPortgroup"].keys()[0])
            net_ref = (vmwareapi_fake.
                       _db_content["DistributedVirtualPortgroup"][net_key].obj)
            prop.val.ManagedObjectReference.append(net_ref)
            break
def reset_fakes():
    vmwareapi_fake.reset()
    vmwareapi_fake._db_content["DistributedVirtualPortgroup"] = {}
    vmwareapi_fake._db_content["VmwareDistributedVirtualSwitch"] = {}
    create_distributed_virtual_portgroup()
    create_distributed_virtual_switch()

    # Add DistributedVirtualPortgroup reference to existing HostSystem Object
    host_ref = (vmwareapi_fake._db_content["HostSystem"][
        vmwareapi_fake._db_content["HostSystem"].keys()[0]])
    for prop in host_ref.propSet:
        if prop.name == "network":
            net_key = (vmwareapi_fake.
                       _db_content["DistributedVirtualPortgroup"].keys()[0])
            net_ref = (vmwareapi_fake.
                       _db_content["DistributedVirtualPortgroup"][net_key].obj)
            prop.val.ManagedObjectReference.append(net_ref)
            break
Ejemplo n.º 13
0
    def setUp(self):

        super(VMwareVolumeOpsTestCase, self).setUp()
        vmwareapi_fake.reset()
        stubs.set_stubs(self.stubs)
        self._session = driver.VMwareAPISession()
        self._context = context.RequestContext("fake_user", "fake_project")

        self._volumeops = volumeops.VMwareVolumeOps(self._session)
        self._image_id = image_fake.get_valid_image_id()
        self._instance_values = {
            "name": "fake_name",
            "uuid": "fake_uuid",
            "vcpus": 1,
            "memory_mb": 512,
            "image_ref": self._image_id,
            "root_gb": 10,
            "node": "respool-1001(MyResPoolName)",
            "expected_attrs": ["system_metadata"],
        }
        self._instance = fake_instance.fake_instance_obj(self._context, **self._instance_values)
Ejemplo n.º 14
0
    def setUp(self):

        super(VMwareVolumeOpsTestCase, self).setUp()
        vmwareapi_fake.reset()
        stubs.set_stubs(self)
        self._session = driver.VMwareAPISession()
        self._context = context.RequestContext('fake_user', 'fake_project')

        self._volumeops = volumeops.VMwareVolumeOps(self._session)
        self._image_id = image_fake.get_valid_image_id()
        self._instance_values = {
            'name': 'fake_name',
            'uuid': uuidsentinel.foo,
            'vcpus': 1,
            'memory_mb': 512,
            'image_ref': self._image_id,
            'root_gb': 10,
            'node': 'respool-1001(MyResPoolName)',
            'expected_attrs': ['system_metadata'],
        }
        self._instance = fake_instance.fake_instance_obj(self._context,
            **self._instance_values)
    def setUp(self):
        super(VMwareVifTestCase, self).setUp()
        self.flags(vlan_interface='vmnet0', group='vmware')
        network = network_model.Network(id=0,
                                        bridge='fa0',
                                        label='fake',
                                        vlan=3,
                                        bridge_interface='eth0',
                                        injected=True)

        self.vif = 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)
        ])[0]
        fake.reset()
        self.session = fake.FakeSession()
        self.cluster = None
Ejemplo n.º 16
0
    def setUp(self):

        super(VMwareVolumeOpsTestCase, self).setUp()
        vmwareapi_fake.reset()
        stubs.set_stubs(self.stubs)
        self._session = driver.VMwareAPISession()
        self._context = context.RequestContext('fake_user', 'fake_project')

        self._volumeops = volumeops.VMwareVolumeOps(self._session)
        self._image_id = image_fake.get_valid_image_id()
        self._instance_values = {
            'name': 'fake_name',
            'uuid': 'fake_uuid',
            'vcpus': 1,
            'memory_mb': 512,
            'image_ref': self._image_id,
            'root_gb': 10,
            'node': 'respool-1001(MyResPoolName)',
            'expected_attrs': ['system_metadata'],
        }
        self._instance = fake_instance.fake_instance_obj(self._context,
            **self._instance_values)
Ejemplo n.º 17
0
 def setUp(self):
     super(VMwareVIMUtilTestCase, self).setUp()
     fake.reset()
     self.vim = fake.FakeVim()
     self.vim._login()
Ejemplo n.º 18
0
 def tearDown(self):
     super(DsUtilTestCase, self).tearDown()
     fake.reset()
Ejemplo n.º 19
0
 def setUp(self):
     super(DsUtilTestCase, self).setUp()
     self.session = fake.FakeSession()
     self.flags(api_retry_count=1, group='vmware')
     fake.reset()
Ejemplo n.º 20
0
 def tearDown(self):
     super(DsUtilTestCase, self).tearDown()
     fake.reset()
Ejemplo n.º 21
0
 def setUp(self):
     super(DsUtilTestCase, self).setUp()
     self.session = fake.FakeSession()
     self.flags(api_retry_count=1, group='vmware')
     fake.reset()
Ejemplo n.º 22
0
 def tearDown(self):
     super(ImageCacheManagerTestCase, self).tearDown()
     fake.reset()
Ejemplo n.º 23
0
 def setUp(self):
     super(VMwareVMUtilTestCase, self).setUp()
     fake.reset()
     stubs.set_stubs(self.stubs)
     vm_util.vm_refs_cache_reset()
Ejemplo n.º 24
0
 def tearDown(self):
     super(VMwareVMUtilPf9TestCase, self).tearDown()
     fake.reset()
Ejemplo n.º 25
0
    def setUp(self, mock_register, mock_service):
        super(ConfigDriveTestCase, self).setUp()
        vm_util.vm_refs_cache_reset()
        self.context = context.RequestContext('fake', 'fake', is_admin=False)
        self.flags(cluster_name='test_cluster',
                   host_ip='testhostname',
                   host_username='******',
                   host_password='******',
                   use_linked_clone=False,
                   group='vmware')
        self.flags(enabled=False, group='vnc')
        vmwareapi_fake.reset()
        stubs.set_stubs(self)
        nova.tests.unit.image.fake.stub_out_image_service(self)
        self.conn = driver.VMwareVCDriver(fake.FakeVirtAPI)
        self.network_info = utils.get_test_network_info()
        self.node_name = self.conn._nodename
        image_ref = nova.tests.unit.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': objects.Flavor(vcpus=4, extra_specs={}),
            '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': uuidsentinel.foo,
            'node': self.node_name,
            'metadata': [],
            'expected_attrs': ['system_metadata'],
        }
        self.test_instance = fake_instance.fake_instance_obj(
            self.context, **instance_values)
        self.test_instance.flavor = objects.Flavor(vcpus=4,
                                                   memory_mb=8192,
                                                   root_gb=80,
                                                   ephemeral_gb=0,
                                                   swap=0,
                                                   extra_specs={})

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

        class FakeInstanceMetadata(object):
            def __init__(self,
                         instance,
                         content=None,
                         extra_md=None,
                         network_info=None,
                         request_context=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.stub_out('nova.virt.configdrive.ConfigDriveBuilder.make_drive',
                      fake_make_drive)

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

        self.stub_out('nova.virt.vmwareapi.images.upload_iso_to_datastore',
                      fake_upload_iso_to_datastore)
Ejemplo n.º 26
0
    def setUp(self, mock_register, mock_service):
        super(ConfigDriveTestCase, self).setUp()
        vm_util.vm_refs_cache_reset()
        self.context = context.RequestContext('fake', 'fake', is_admin=False)
        self.flags(cluster_name='test_cluster',
                   host_ip='testhostname',
                   host_username='******',
                   host_password='******',
                   use_linked_clone=False, group='vmware')
        self.flags(enabled=False, group='vnc')
        vmwareapi_fake.reset()
        stubs.set_stubs(self)
        nova.tests.unit.image.fake.stub_out_image_service(self)
        self.conn = driver.VMwareVCDriver(fake.FakeVirtAPI)
        self.network_info = utils.get_test_network_info()
        self.node_name = self.conn._nodename
        image_ref = nova.tests.unit.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': objects.Flavor(vcpus=4, extra_specs={}),
            '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': uuidsentinel.foo,
            'node': self.node_name,
            'metadata': [],
            'expected_attrs': ['system_metadata'],
        }
        self.test_instance = fake_instance.fake_instance_obj(self.context,
                                                             **instance_values)
        self.test_instance.flavor = objects.Flavor(vcpus=4, memory_mb=8192,
                                                   root_gb=80,
                                                   ephemeral_gb=0, swap=0,
                                                   extra_specs={})

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

        class FakeInstanceMetadata(object):
            def __init__(self, instance, content=None, extra_md=None,
                         network_info=None, request_context=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.stub_out('nova.virt.configdrive.ConfigDriveBuilder.make_drive',
                      fake_make_drive)

        def fake_upload_iso_to_datastore(iso_path, instance, **kwargs):
            pass
        self.stub_out('nova.virt.vmwareapi.images.upload_iso_to_datastore',
                       fake_upload_iso_to_datastore)
Ejemplo n.º 27
0
 def setUp(self):
     super(VMwareVIMUtilTestCase, self).setUp()
     fake.reset()
     self.vim = fake.FakeVim()
     self.vim._login()
Ejemplo n.º 28
0
 def tearDown(self):
     super(ImageCacheManagerTestCase, self).tearDown()
     fake.reset()
Ejemplo n.º 29
0
 def setUp(self):
     super(VMwareVMUtilPf9TestCase, self).setUp()
     fake.reset()