コード例 #1
0
ファイル: test_vmwareapi.py プロジェクト: aneeshpu/nova
    def setUp(self):
        super(VMwareAPIVMTestCase, self).setUp()
        self.context = context.RequestContext('fake', 'fake', is_admin=False)
        self.flags(host_ip='test_url',
                   host_username='******',
                   host_password='******',
                   cluster_name='test_cluster',
                   use_linked_clone=False, group='vmware')
        self.flags(vnc_enabled=False)
        self.user_id = 'fake'
        self.project_id = 'fake'
        self.node_name = 'test_url'
        self.context = context.RequestContext(self.user_id, self.project_id)
        vmwareapi_fake.reset()
        db_fakes.stub_out_db_instance_api(self.stubs)
        stubs.set_stubs(self.stubs)
        self.conn = driver.VMwareESXDriver(fake.FakeVirtAPI)
        # NOTE(vish): none of the network plugging code is actually
        #             being tested
        self.network_info = utils.get_test_network_info()

        self.image = {
            'id': 'c1c8ce3d-c2e0-4247-890c-ccf5cc1c004c',
            'disk_format': 'vhd',
            'size': 512,
        }
        nova.tests.image.fake.stub_out_image_service(self.stubs)
        self.vnc_host = 'test_url'
コード例 #2
0
ファイル: test_vmwareapi.py プロジェクト: qingw/nova
    def setUp(self):
        super(VMwareAPIVMTestCase, self).setUp()
        self.context = context.RequestContext('fake', 'fake', is_admin=False)
        self.flags(host_ip='test_url',
                   host_username='******',
                   host_password='******',
                   cluster_name='test_cluster',
                   use_linked_clone=False, group='vmware')
        self.flags(vnc_enabled=False)
        self.user_id = 'fake'
        self.project_id = 'fake'
        self.node_name = 'test_url'
        self.context = context.RequestContext(self.user_id, self.project_id)
        vmwareapi_fake.reset()
        db_fakes.stub_out_db_instance_api(self.stubs)
        stubs.set_stubs(self.stubs)
        self.conn = driver.VMwareESXDriver(fake.FakeVirtAPI)
        # NOTE(vish): none of the network plugging code is actually
        #             being tested
        self.network_info = utils.get_test_network_info()

        self.image = {
            'id': 'c1c8ce3d-c2e0-4247-890c-ccf5cc1c004c',
            'disk_format': 'vhd',
            'size': 512,
        }
        nova.tests.image.fake.stub_out_image_service(self.stubs)
コード例 #3
0
ファイル: test_vmwareapi.py プロジェクト: slagle/nova
    def setUp(self):
        super(VMwareAPIVMTestCase, self).setUp()
        self.context = context.RequestContext("fake", "fake", is_admin=False)
        self.flags(
            host_ip="test_url",
            host_username="******",
            host_password="******",
            use_linked_clone=False,
            group="vmware",
        )
        self.flags(vnc_enabled=False)
        self.user_id = "fake"
        self.project_id = "fake"
        self.node_name = "test_url"
        self.context = context.RequestContext(self.user_id, self.project_id)
        vmwareapi_fake.reset()
        db_fakes.stub_out_db_instance_api(self.stubs)
        stubs.set_stubs(self.stubs)
        self.conn = driver.VMwareESXDriver(fake.FakeVirtAPI)
        # NOTE(vish): none of the network plugging code is actually
        #             being tested
        self.network_info = utils.get_test_network_info()

        self.image = {"id": "c1c8ce3d-c2e0-4247-890c-ccf5cc1c004c", "disk_format": "vhd", "size": 512}
        nova.tests.image.fake.stub_out_image_service(self.stubs)
コード例 #4
0
ファイル: test_vmops.py プロジェクト: frankiefang/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='')
        self._context = context.RequestContext('fake_user', 'fake_project')
        self._session = driver.VMwareAPISession()

        self._virtapi = mock.Mock()
        self._vmops = vmops.VMwareVMOps(self._session, self._virtapi, None)
        self._instance = {'name': 'fake_name', 'uuid': 'fake_uuid'}

        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)
                ])
コード例 #5
0
ファイル: test_vmwareapi.py プロジェクト: habuka036/nova
 def setUp(self):
     super(VMwareAPIHostTestCase, self).setUp()
     self.flags(
         vmwareapi_host_ip="test_url", vmwareapi_host_username="******", vmwareapi_host_password="******"
     )
     vmwareapi_fake.reset()
     stubs.set_stubs(self.stubs)
     self.conn = driver.VMwareESXDriver(False)
コード例 #6
0
ファイル: test_vmwareapi.py プロジェクト: qingw/nova
 def setUp(self):
     super(VMwareAPIHostTestCase, self).setUp()
     self.flags(host_ip='test_url',
                host_username='******',
                host_password='******', group='vmware')
     vmwareapi_fake.reset()
     stubs.set_stubs(self.stubs)
     self.conn = driver.VMwareESXDriver(False)
コード例 #7
0
ファイル: test_vmwareapi.py プロジェクト: aneeshpu/nova
 def setUp(self):
     super(VMwareAPIHostTestCase, self).setUp()
     self.flags(host_ip='test_url',
                host_username='******',
                host_password='******', group='vmware')
     vmwareapi_fake.reset()
     stubs.set_stubs(self.stubs)
     self.conn = driver.VMwareESXDriver(False)
コード例 #8
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'}
コード例 #9
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'}
コード例 #10
0
ファイル: test_vmops.py プロジェクト: boosheng/nova
    def setUp(self):
        super(VMwareVMOpsTestCase, self).setUp()
        vmwareapi_fake.reset()
        stubs.set_stubs(self.stubs)
        self._session = driver.VMwareAPISession()

        self._vmops = vmops.VMwareVMOps(self._session, None, None)
        self._instance = {'name': 'fake_name', 'uuid': 'fake_uuid'}

        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)
                ])
        utils.reset_is_neutron()
コード例 #11
0
ファイル: test_vmops.py プロジェクト: gukai/su-nova
    def setUp(self):
        super(VMwareVMOpsTestCase, self).setUp()
        vmwareapi_fake.reset()
        stubs.set_stubs(self.stubs)
        self._session = driver.VMwareAPISession()

        self._vmops = vmops.VMwareVMOps(self._session, None, None)
        self._instance = {'name': 'fake_name', 'uuid': 'fake_uuid'}

        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)
        ])
        utils.reset_is_neutron()
コード例 #12
0
ファイル: test_volumeops.py プロジェクト: syotani/nova
    def setUp(self):
        def fake_del():
            return

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

        self._volumeops = volumeops.VMwareVolumeOps(self._session)
        self.instance = {"name": "fake_name", "uuid": "fake_uuid"}
コード例 #13
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)
                ])
コード例 #14
0
ファイル: test_configdrive.py プロジェクト: B-Rich/nova-1
    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(vc=True)
        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()
        self.test_instance = {
            "node": "test_url",
            "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": [],
        }

        (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)
コード例 #15
0
ファイル: test_vmops.py プロジェクト: davidyuan1989/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 = 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)
                ])
コード例 #16
0
    def setUp(self):
        super(ConfigDriveTestCase, self).setUp()
        self.context = context.RequestContext('fake', 'fake', is_admin=False)
        self.flags(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.image = {
            'id': 'c1c8ce3d-c2e0-4247-890c-ccf5cc1c004c',
            'disk_format': 'vhd',
            'size': 512,
        }
        self.test_instance = {
            'node': 'test_url',
            '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,
            'instance_type': 'm1.large',
            'vcpus': 4,
            'root_gb': 80,
            'image_ref': '1',
            'host': 'fake_host',
            'task_state': 'scheduling',
            'reservation_id': 'r-3t8muvr0',
            'id': 1,
            'uuid': 'fake-uuid'
        }

        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)
コード例 #17
0
ファイル: test_configdrive.py プロジェクト: Charu-Sharma/nova
    def setUp(self):
        super(ConfigDriveTestCase, self).setUp()
        self.context = context.RequestContext('fake', 'fake', is_admin=False)
        self.flags(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.image = {
            'id': 'c1c8ce3d-c2e0-4247-890c-ccf5cc1c004c',
            'disk_format': 'vhd',
            'size': 512,
        }
        self.test_instance = {'node': 'test_url',
                              '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,
                              'instance_type': 'm1.large',
                              'vcpus': 4,
                              'root_gb': 80,
                              'image_ref': '1',
                              'host': 'fake_host',
                              'task_state':
                                  'scheduling',
                              'reservation_id': 'r-3t8muvr0',
                              'id': 1,
                              'uuid': 'fake-uuid'}

        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)
コード例 #18
0
ファイル: test_vmops.py プロジェクト: VeenaSL/sriov
    def setUp(self):
        super(VMwareVMOpsTestCase, self).setUp()
        vmwareapi_fake.reset()
        stubs.set_stubs(self.stubs)
        self._session = driver.VMwareAPISession()

        self._vmops = vmops.VMwareVMOps(self._session, None, 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._context = context.RequestContext('fake_user', 'fake_project')
        self._instance = fake_instance.fake_instance_obj(self._context,
                                                         **values)

        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)
                ])
        utils.reset_is_neutron()
コード例 #19
0
ファイル: test_configdrive.py プロジェクト: Krylon360/nova
    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)
コード例 #20
0
ファイル: test_vmops.py プロジェクト: qyxia/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="")
        self._context = context.RequestContext("fake_user", "fake_project")
        self._session = driver.VMwareAPISession()

        self._virtapi = mock.Mock()
        self._vmops = vmops.VMwareVMOps(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._context = context.RequestContext("fake_user", "fake_project")
        self._instance = fake_instance.fake_instance_obj(self._context, **values)

        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,
                )
            ]
        )
コード例 #21
0
ファイル: test_vmops.py プロジェクト: hail100/nova
    def setUp(self):
        super(VMwareVMOpsTestCase, self).setUp()
        vmwareapi_fake.reset()
        stubs.set_stubs(self.stubs)
        self._session = driver.VMwareAPISession()

        self._vmops = vmops.VMwareVMOps(self._session, None, None)
        self._instance = {"name": "fake_name", "uuid": "fake_uuid"}

        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,
                )
            ]
        )
        utils.reset_is_neutron()
コード例 #22
0
    def setUp(self):
        super(VMwareVMOpsTestCase, self).setUp()
        vmwareapi_fake.reset()
        stubs.set_stubs(self.stubs)
        self._session = driver.VMwareAPISession()

        self._vmops = vmops.VMwareVMOps(self._session, None, 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._context = context.RequestContext('fake_user', 'fake_project')
        self._instance = fake_instance.fake_instance_obj(
            self._context, **values)

        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)
        ])
        utils.reset_is_neutron()
コード例 #23
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)
コード例 #24
0
ファイル: test_vm_util.py プロジェクト: Krylon360/nova
 def setUp(self):
     super(VMwareVMUtilTestCase, self).setUp()
     fake.reset()
     stubs.set_stubs(self.stubs)
     vm_util.vm_refs_cache_reset()