コード例 #1
0
ファイル: test_aggregates.py プロジェクト: vwangyanweida/nova
    def test_filter_with_traits_image_flavor_disjoint_of_aggregates(self):
        """Test filter with image/flav required traits disjoint of aggregates.

        Image and flavor has a nonempty set of required traits that's disjoint
        set of the traits on the aggregates.
        """

        rp_uuid2 = self._get_provider_uuid_by_host('host2')
        self._set_provider_traits(rp_uuid2, ['HW_CPU_X86_VMX'])

        rp_uuid1 = self._get_provider_uuid_by_host('host1')
        self._set_provider_traits(rp_uuid1, ['HW_GPU_API_DXVA'])

        self._set_traits_on_aggregate('only-host1', ['HW_GPU_API_DXVA'])
        self._set_traits_on_aggregate('only-host2', ['HW_CPU_X86_VMX'])

        # Creating a new image and setting traits on it.
        with nova.utils.temporary_mutation(self.api, microversion='2.35'):
            self.ctxt = test_utils.get_test_admin_context()
            img_ref = self.glance.create(self.ctxt, {'name': 'image10'})
            image_id_with_trait = img_ref['id']
            self.addCleanup(self.glance.delete, self.ctxt, image_id_with_trait)
            self.api.api_put(
                '/images/%s/metadata' % image_id_with_trait,
                {'metadata': {
                    'trait:HW_CPU_X86_VMX': 'required'
                }})
        server = self._boot_server(flavor_id=self.flavor_with_trait_sgx['id'],
                                   image_id=image_id_with_trait,
                                   end_status='ERROR')

        self.assertIsNone(self._get_instance_host(server))
        self.assertIn('No valid host', server['fault']['message'])
コード例 #2
0
    def test_get_test_admin_context(self):
        # get_test_admin_context's return value behaves like admin context.
        ctxt = test_utils.get_test_admin_context()

        # TODO(soren): This should verify the full interface context
        # objects expose.
        self.assertTrue(ctxt.is_admin)
コード例 #3
0
ファイル: test_aggregates.py プロジェクト: vwangyanweida/nova
    def test_filter_with_traits_on_image_and_flavor(self):
        """Test filter with common traits set to image/flavor and aggregates.

        Required trait (HW_CPU_X86_SGX) set in flavor and
        required trait (HW_CPU_X86_VMX) set in image, so instance should be
        booted on host with exact matching required traits set on aggregates.
        """

        rp_uuid2 = self._get_provider_uuid_by_host('host2')
        self._set_provider_traits(rp_uuid2,
                                  ['HW_CPU_X86_VMX', 'HW_CPU_X86_SGX'])

        rp_uuid1 = self._get_provider_uuid_by_host('host1')
        self._set_provider_traits(rp_uuid1, ['HW_GPU_API_DXVA'])

        self._set_traits_on_aggregate('only-host1', ['HW_GPU_API_DXVA'])
        self._set_traits_on_aggregate('only-host2',
                                      ['HW_CPU_X86_VMX', 'HW_CPU_X86_SGX'])

        # Creating a new image and setting traits on it.
        with nova.utils.temporary_mutation(self.api, microversion='2.35'):
            self.ctxt = test_utils.get_test_admin_context()
            img_ref = self.glance.create(self.ctxt, {'name': 'image10'})
            image_id_with_trait = img_ref['id']
            self.addCleanup(self.glance.delete, self.ctxt, image_id_with_trait)
            self.api.api_put(
                '/images/%s/metadata' % image_id_with_trait,
                {'metadata': {
                    'trait:HW_CPU_X86_VMX': 'required'
                }})
        server = self._boot_server(flavor_id=self.flavor_with_trait_sgx['id'],
                                   image_id=image_id_with_trait)
        self.assertEqual('host2', self._get_instance_host(server))
コード例 #4
0
ファイル: test_test_utils.py プロジェクト: Chillisystems/nova
    def test_get_test_admin_context(self):
        # get_test_admin_context's return value behaves like admin context.
        ctxt = test_utils.get_test_admin_context()

        # TODO(soren): This should verify the full interface context
        # objects expose.
        self.assertTrue(ctxt.is_admin)
コード例 #5
0
ファイル: test_driver.py プロジェクト: epheo/nova-compute-lxd
    def setUp(self):
        super(LXDTestDriver, self).setUp()

        self.ctxt = utils.get_test_admin_context()
        fake_image.stub_out_image_service(self.stubs)

        self.flags(lxd_root_dir=self.useFixture(fixtures.TempDir()).path,
                    group='lxd')
        self.driver = driver.LXDDriver(None, None)
コード例 #6
0
ファイル: test_virt_drivers.py プロジェクト: anantk/nova
    def setUp(self):
        super(_VirtDriverTestCase, self).setUp()

        self.flags(instances_path=self.useFixture(fixtures.TempDir()).path)
        self.connection = importutils.import_object(self.driver_module, fake.FakeVirtAPI())
        self.ctxt = test_utils.get_test_admin_context()
        self.image_service = fake_image.FakeImageService()
        # NOTE(dripton): resolve_driver_format does some file reading and
        # writing and chowning that complicate testing too much by requiring
        # using real directories with proper permissions.  Just stub it out
        # here; we test it in test_imagebackend.py
        self.stubs.Set(imagebackend.Image, "resolve_driver_format", imagebackend.Image._get_driver_format)
コード例 #7
0
ファイル: test_common.py プロジェクト: cyx1231st/nova
    def test_check_img_metadata_properties_quota_valid_metadata(self):
        ctxt = utils.get_test_admin_context()
        metadata1 = {"key": "value"}
        actual = common.check_img_metadata_properties_quota(ctxt, metadata1)
        self.assertIsNone(actual)

        metadata2 = {"key": "v" * 260}
        actual = common.check_img_metadata_properties_quota(ctxt, metadata2)
        self.assertIsNone(actual)

        metadata3 = {"key": ""}
        actual = common.check_img_metadata_properties_quota(ctxt, metadata3)
        self.assertIsNone(actual)
コード例 #8
0
    def test_check_img_metadata_properties_quota_valid_metadata(self):
        ctxt = utils.get_test_admin_context()
        metadata1 = {"key": "value"}
        actual = common.check_img_metadata_properties_quota(ctxt, metadata1)
        self.assertIsNone(actual)

        metadata2 = {"key": "v" * 260}
        actual = common.check_img_metadata_properties_quota(ctxt, metadata2)
        self.assertIsNone(actual)

        metadata3 = {"key": ""}
        actual = common.check_img_metadata_properties_quota(ctxt, metadata3)
        self.assertIsNone(actual)
コード例 #9
0
ファイル: test_virt_drivers.py プロジェクト: zlzlnet/nova
    def setUp(self):
        super(_VirtDriverTestCase, self).setUp()

        self.flags(instances_path=self.useFixture(fixtures.TempDir()).path)
        self.connection = importutils.import_object(self.driver_module,
                                                    fake.FakeVirtAPI())
        self.ctxt = test_utils.get_test_admin_context()
        self.image_service = fake_image.FakeImageService()
        # NOTE(dripton): resolve_driver_format does some file reading and
        # writing and chowning that complicate testing too much by requiring
        # using real directories with proper permissions.  Just stub it out
        # here; we test it in test_imagebackend.py
        self.stubs.Set(imagebackend.Image, 'resolve_driver_format',
                       imagebackend.Image._get_driver_format)
コード例 #10
0
ファイル: test_common.py プロジェクト: cyx1231st/nova
    def test_check_img_metadata_properties_quota_inv_metadata(self):
        ctxt = utils.get_test_admin_context()
        metadata1 = {"a" * 260: "value"}
        self.assertRaises(webob.exc.HTTPBadRequest, common.check_img_metadata_properties_quota, ctxt, metadata1)

        metadata2 = {"": "value"}
        self.assertRaises(webob.exc.HTTPBadRequest, common.check_img_metadata_properties_quota, ctxt, metadata2)

        metadata3 = "invalid metadata"
        self.assertRaises(webob.exc.HTTPBadRequest, common.check_img_metadata_properties_quota, ctxt, metadata3)

        metadata4 = None
        self.assertIsNone(common.check_img_metadata_properties_quota(ctxt, metadata4))
        metadata5 = {}
        self.assertIsNone(common.check_img_metadata_properties_quota(ctxt, metadata5))
コード例 #11
0
    def test_check_img_metadata_properties_quota_inv_metadata(self):
        ctxt = utils.get_test_admin_context()
        metadata1 = {"a" * 260: "value"}
        self.assertRaises(webob.exc.HTTPBadRequest,
                common.check_img_metadata_properties_quota, ctxt, metadata1)

        metadata2 = {"": "value"}
        self.assertRaises(webob.exc.HTTPBadRequest,
                common.check_img_metadata_properties_quota, ctxt, metadata2)

        metadata3 = "invalid metadata"
        self.assertRaises(webob.exc.HTTPBadRequest,
                common.check_img_metadata_properties_quota, ctxt, metadata3)

        metadata4 = None
        self.assertIsNone(common.check_img_metadata_properties_quota(ctxt,
                                                        metadata4))
        metadata5 = {}
        self.assertIsNone(common.check_img_metadata_properties_quota(ctxt,
                                                        metadata5))
コード例 #12
0
 def test_get_test_instance(self):
     # get_test_instance's return value looks like an instance_ref.
     instance_ref = test_utils.get_test_instance()
     ctxt = test_utils.get_test_admin_context()
     db.instance_get(ctxt, instance_ref['id'])
コード例 #13
0
ファイル: test_test_utils.py プロジェクト: Chillisystems/nova
 def test_get_test_instance(self):
     # get_test_instance's return value looks like an instance_ref.
     instance_ref = test_utils.get_test_instance()
     ctxt = test_utils.get_test_admin_context()
     db.instance_get(ctxt, instance_ref['id'])