コード例 #1
0
ファイル: api_sample_base.py プロジェクト: isyippee/nova
    def setUp(self):
        self.flags(
            use_ipv6=False, osapi_compute_link_prefix=self._get_host(), osapi_glance_link_prefix=self._get_glance_host()
        )
        if not self.all_extensions:
            self.flags(osapi_compute_extension=[])
            # Set the whitelist to ensure only the extensions we are
            # interested in are loaded so the api samples don't include
            # data from extensions we are not interested in
            whitelist = API_V3_CORE_EXTENSIONS.copy()
            if self.extension_name:
                whitelist.add(self.extension_name)
            if self.extra_extensions_to_load:
                whitelist.update(set(self.extra_extensions_to_load))

            CONF.set_override("extensions_whitelist", whitelist, "osapi_v21")
        expected_middleware = []
        if not hasattr(self, "_test") or (self._test == "v2.1"):
            # NOTE(gmann)For v2.1 API testing, override /v2 endpoint with v2.1
            self.useFixture(api_paste_fixture.ApiPasteFixture())
            expected_middleware = [compute.APIRouterV21]
        elif self._test == "v2.1_compatible":
            self.useFixture(api_paste_fixture.ApiPasteV2CompatibleFixture())
            expected_middleware = [openstack.LegacyV2CompatibleWrapper, compute.APIRouterV21]
        super(ApiSampleTestBaseV3, self).setUp()
        self.useFixture(test.SampleNetworks(host=self.network.host))
        fake_network.stub_compute_with_ips(self.stubs)
        fake_utils.stub_out_utils_spawn_n(self.stubs)
        self.generate_samples = os.getenv("GENERATE_SAMPLES") is not None
        if expected_middleware:
            self._check_api_endpoint("/v2", expected_middleware)
コード例 #2
0
ファイル: api_sample_base.py プロジェクト: kengon/nova
    def setUp(self):
        self.flags(use_ipv6=False,
                   osapi_compute_link_prefix=self._get_host(),
                   osapi_glance_link_prefix=self._get_glance_host())
        if not self.all_extensions:
            # Set the whitelist to ensure only the extensions we are
            # interested in are loaded so the api samples don't include
            # data from extensions we are not interested in
            whitelist = API_V21_CORE_EXTENSIONS.copy()
            if self.extension_name:
                whitelist.add(self.extension_name)
            if self.extra_extensions_to_load:
                whitelist.update(set(self.extra_extensions_to_load))

            CONF.set_override('extensions_whitelist', whitelist, 'osapi_v21')

        # load any additional fixtures specified by the scenario
        for fix in self._additional_fixtures:
            self.useFixture(fix())

        # super class call is delayed here so that we have the right
        # paste and conf before loading all the services, as we can't
        # change these later.
        super(ApiSampleTestBaseV21, self).setUp()

        self.useFixture(test.SampleNetworks(host=self.network.host))
        fake_network.stub_compute_with_ips(self.stubs)
        fake_utils.stub_out_utils_spawn_n(self.stubs)

        # this is used to generate sample docs
        self.generate_samples = os.getenv('GENERATE_SAMPLES') is not None
コード例 #3
0
ファイル: api_sample_base.py プロジェクト: Biswajeeban/nova
    def setUp(self):
        self.flags(use_ipv6=False,
                   osapi_compute_link_prefix=self._get_host(),
                   osapi_glance_link_prefix=self._get_glance_host())
        if not self.all_extensions:
            self.flags(osapi_compute_extension=[])
            # Set the whitelist to ensure only the extensions we are
            # interested in are loaded so the api samples don't include
            # data from extensions we are not interested in
            whitelist = API_V21_CORE_EXTENSIONS.copy()
            if self.extension_name:
                whitelist.add(self.extension_name)
            if self.extra_extensions_to_load:
                whitelist.update(set(self.extra_extensions_to_load))

            CONF.set_override('extensions_whitelist', whitelist,
                              'osapi_v21')

        # load any additional fixtures specified by the scenario
        for fix in self._additional_fixtures:
            self.useFixture(fix())

        # super class call is delayed here so that we have the right
        # paste and conf before loading all the services, as we can't
        # change these later.
        super(ApiSampleTestBaseV21, self).setUp()

        self.useFixture(test.SampleNetworks(host=self.network.host))
        fake_network.stub_compute_with_ips(self.stubs)
        fake_utils.stub_out_utils_spawn_n(self.stubs)

        # this is used to generate sample docs
        self.generate_samples = os.getenv('GENERATE_SAMPLES') is not None
コード例 #4
0
    def setUp(self):
        self.flags(use_ipv6=False,
                   osapi_compute_link_prefix=self._get_host(),
                   osapi_glance_link_prefix=self._get_glance_host())
        if not self.all_extensions:
            self.flags(osapi_compute_extension=[])
            # Set the whitelist to ensure only the extensions we are
            # interested in are loaded so the api samples don't include
            # data from extensions we are not interested in
            whitelist = API_V3_CORE_EXTENSIONS.copy()
            if self.extension_name:
                whitelist.add(self.extension_name)
            if self.extra_extensions_to_load:
                whitelist.update(set(self.extra_extensions_to_load))

            CONF.set_override('extensions_whitelist', whitelist,
                              'osapi_v21')
        expected_middleware = []
        if (not hasattr(self, '_test') or (self._test == 'v2.1')):
            # NOTE(gmann)For v2.1 API testing, override /v2 endpoint with v2.1
            self.useFixture(api_paste_fixture.ApiPasteFixture())
            expected_middleware = [compute.APIRouterV21]
        elif self._test == 'v2.1_compatible':
            self.useFixture(api_paste_fixture.ApiPasteV2CompatibleFixture())
            expected_middleware = [openstack.LegacyV2CompatibleWrapper,
                                   compute.APIRouterV21]
        super(ApiSampleTestBaseV3, self).setUp()
        self.useFixture(test.SampleNetworks(host=self.network.host))
        fake_network.stub_compute_with_ips(self.stubs)
        fake_utils.stub_out_utils_spawn_n(self.stubs)
        self.generate_samples = os.getenv('GENERATE_SAMPLES') is not None
        if expected_middleware:
            self._check_api_endpoint('/v2', expected_middleware)
コード例 #5
0
ファイル: api_sample_base.py プロジェクト: Milstein/nova
    def setUp(self):
        # TODO(gmann): Below condition is to skip the tests which running
        # for 'v2' and have not been merged yet. Once all tests are merged
        # this condition needs to be removed.
        if ((self._test == 'v2') and (self._api_version == 'v3')):
            raise testtools.TestCase.skipException('tests are not merged yet')
        self.flags(use_ipv6=False,
                   osapi_compute_link_prefix=self._get_host(),
                   osapi_glance_link_prefix=self._get_glance_host())
        if not self.all_extensions:
            self.flags(osapi_compute_extension=[])
            # Set the whitelist to ensure only the extensions we are
            # interested in are loaded so the api samples don't include
            # data from extensions we are not interested in
            whitelist = API_V3_CORE_EXTENSIONS.copy()
            if self.extension_name:
                whitelist.add(self.extension_name)
            if self.extra_extensions_to_load:
                whitelist.update(set(self.extra_extensions_to_load))

            CONF.set_override('extensions_whitelist', whitelist,
                              'osapi_v3')
        # TODO(gmann): Currently redirecting only merged tests
        # after merging all tests, second condition needs to be removed.
        if ((self._test == 'v2.1') and (self._api_version == 'v2')):
            # NOTE(gmann)For v2.1 API testing, override /v2 endpoint with v2.1
            self.useFixture(api_paste_fixture.ApiPasteFixture())
        super(ApiSampleTestBaseV3, self).setUp()
        self.useFixture(test.SampleNetworks(host=self.network.host))
        fake_network.stub_compute_with_ips(self.stubs)
        fake_utils.stub_out_utils_spawn_n(self.stubs)
        self.generate_samples = os.getenv('GENERATE_SAMPLES') is not None
コード例 #6
0
    def setUp(self):
        # TODO(gmann): Below condition is to skip the tests which running
        # for 'v2' and have not been merged yet. Once all tests are merged
        # this condition needs to be removed.
        if ((self._test == 'v2') and (self._api_version == 'v3')):
            raise testtools.TestCase.skipException('tests are not merged yet')
        self.flags(use_ipv6=False,
                   osapi_compute_link_prefix=self._get_host(),
                   osapi_glance_link_prefix=self._get_glance_host(),
                   osapi_compute_extension=[])
        if not self.all_extensions:
            # Set the whitelist to ensure only the extensions we are
            # interested in are loaded so the api samples don't include
            # data from extensions we are not interested in
            whitelist = API_V3_CORE_EXTENSIONS.copy()
            if self.extension_name:
                whitelist.add(self.extension_name)
            if self.extra_extensions_to_load:
                whitelist.update(set(self.extra_extensions_to_load))

            CONF.set_override('extensions_whitelist', whitelist,
                              'osapi_v3')
        # TODO(gmann): Currently redirecting only merged tests
        # after merging all tests, second condition needs to be removed.
        if ((self._test == 'v2.1') and (self._api_version == 'v2')):
            # NOTE(gmann)For v2.1 API testing, override /v2 endpoint with v2.1
            self.useFixture(api_paste_fixture.ApiPasteFixture())
        super(ApiSampleTestBaseV3, self).setUp()
        self.useFixture(test.SampleNetworks(host=self.network.host))
        fake_network.stub_compute_with_ips(self.stubs)
        fake_utils.stub_out_utils_spawn_n(self.stubs)
        self.generate_samples = os.getenv('GENERATE_SAMPLES') is not None
コード例 #7
0
ファイル: test_api_samples.py プロジェクト: kimjaejoong/nova
 def setUp(self):
     extends = []
     self.flags(use_ipv6=False,
                osapi_compute_link_prefix=self._get_host(),
                osapi_glance_link_prefix=self._get_glance_host())
     if not self.all_extensions:
         if hasattr(self, 'extends_name'):
             extends = [self.extends_name]
         ext = [self.extension_name] if self.extension_name else []
         self.flags(osapi_compute_extension=ext + extends)
     super(ApiSampleTestBaseV2, self).setUp()
     self.useFixture(test.SampleNetworks(host=self.network.host))
     fake_network.stub_compute_with_ips(self.stubs)
     fake_utils.stub_out_utils_spawn_n(self.stubs)
     self.generate_samples = os.getenv('GENERATE_SAMPLES') is not None
コード例 #8
0
ファイル: test_api_samples.py プロジェクト: scholery/nova
 def setUp(self):
     extends = []
     self.flags(use_ipv6=False,
                osapi_compute_link_prefix=self._get_host(),
                osapi_glance_link_prefix=self._get_glance_host())
     if not self.all_extensions:
         if hasattr(self, 'extends_name'):
             extends = [self.extends_name]
         ext = [self.extension_name] if self.extension_name else []
         self.flags(osapi_compute_extension=ext + extends)
     super(ApiSampleTestBaseV2, self).setUp()
     self.useFixture(test.SampleNetworks(host=self.network.host))
     fake_network.stub_compute_with_ips(self.stubs)
     fake_utils.stub_out_utils_spawn_n(self.stubs)
     self.generate_samples = os.getenv('GENERATE_SAMPLES') is not None
コード例 #9
0
ファイル: api_sample_base.py プロジェクト: 4everming/nova
    def setUp(self):
        self.flags(use_ipv6=False,
                   osapi_compute_link_prefix=self._get_host(),
                   osapi_glance_link_prefix=self._get_glance_host())

        # load any additional fixtures specified by the scenario
        for fix in self._additional_fixtures:
            self.useFixture(fix())

        # super class call is delayed here so that we have the right
        # paste and conf before loading all the services, as we can't
        # change these later.
        super(ApiSampleTestBaseV21, self).setUp()

        self.useFixture(test.SampleNetworks(host=self.network.host))
        fake_network.stub_compute_with_ips(self.stubs)
        fake_utils.stub_out_utils_spawn_n(self.stubs)

        # this is used to generate sample docs
        self.generate_samples = os.getenv('GENERATE_SAMPLES') is not None
コード例 #10
0
ファイル: api_sample_base.py プロジェクト: ryanlv01/nova
    def setUp(self):
        self.flags(use_ipv6=False,
                   osapi_compute_link_prefix=self._get_host(),
                   osapi_glance_link_prefix=self._get_glance_host())

        # load any additional fixtures specified by the scenario
        for fix in self._additional_fixtures:
            self.useFixture(fix())

        # super class call is delayed here so that we have the right
        # paste and conf before loading all the services, as we can't
        # change these later.
        super(ApiSampleTestBaseV21, self).setUp()

        self.useFixture(test.SampleNetworks(host=self.network.host))
        fake_network.stub_compute_with_ips(self.stubs)
        fake_utils.stub_out_utils_spawn_n(self.stubs)

        # this is used to generate sample docs
        self.generate_samples = os.getenv('GENERATE_SAMPLES') is not None
コード例 #11
0
    def setUp(self):
        self.flags(use_ipv6=False,
                   osapi_compute_link_prefix=self._get_host(),
                   osapi_glance_link_prefix=self._get_glance_host())
        if not self.all_extensions:
            # Set the whitelist to ensure only the extensions we are
            # interested in are loaded so the api samples don't include
            # data from extensions we are not interested in
            whitelist = API_V3_CORE_EXTENSIONS.copy()
            if self.extension_name:
                whitelist.add(self.extension_name)
            if self.extra_extensions_to_load:
                whitelist.update(set(self.extra_extensions_to_load))

            CONF.set_override('extensions_whitelist', whitelist, 'osapi_v3')

        super(ApiSampleTestBaseV3, self).setUp()
        self.useFixture(test.SampleNetworks(host=self.network.host))
        fake_network.stub_compute_with_ips(self.stubs)
        fake_utils.stub_out_utils_spawn_n(self.stubs)
        self.generate_samples = os.getenv('GENERATE_SAMPLES') is not None
コード例 #12
0
ファイル: api_sample_base.py プロジェクト: EdLeafe/nova
    def setUp(self):
        self.flags(use_ipv6=False,
                   osapi_compute_link_prefix=self._get_host(),
                   osapi_glance_link_prefix=self._get_glance_host())
        if not self.all_extensions:
            # Set the whitelist to ensure only the extensions we are
            # interested in are loaded so the api samples don't include
            # data from extensions we are not interested in
            whitelist = API_V3_CORE_EXTENSIONS.copy()
            if self.extension_name:
                whitelist.add(self.extension_name)
            if self.extra_extensions_to_load:
                whitelist.update(set(self.extra_extensions_to_load))

            CONF.set_override('extensions_whitelist', whitelist,
                              'osapi_v3')

        super(ApiSampleTestBaseV3, self).setUp()
        self.useFixture(test.SampleNetworks(host=self.network.host))
        fake_network.stub_compute_with_ips(self.stubs)
        fake_utils.stub_out_utils_spawn_n(self.stubs)
        self.generate_samples = os.getenv('GENERATE_SAMPLES') is not None
コード例 #13
0
ファイル: api_sample_base.py プロジェクト: qianlin/nova
    def setUp(self):
        self.flags(use_ipv6=False,
                   osapi_compute_link_prefix=self._get_host(),
                   osapi_glance_link_prefix=self._get_glance_host())
        if not self.all_extensions:
            self.flags(osapi_compute_extension=[])
            # Set the whitelist to ensure only the extensions we are
            # interested in are loaded so the api samples don't include
            # data from extensions we are not interested in
            whitelist = API_V3_CORE_EXTENSIONS.copy()
            if self.extension_name:
                whitelist.add(self.extension_name)
            if self.extra_extensions_to_load:
                whitelist.update(set(self.extra_extensions_to_load))

            CONF.set_override('extensions_whitelist', whitelist,
                              'osapi_v21')
        expected_middleware = []
        if (not hasattr(self, '_test') or (self._test == 'v2.1')):
            # NOTE(gmann): we should run v21 tests on /v2.1 but then we need
            # two sets of sample files as api version (v2 or v2.1) is being
            # added in response's link/namespace etc
            # override /v2 in compatibility mode with v2.1
            self.useFixture(api_paste_fixture.ApiPasteV21Fixture())
            expected_middleware = [compute.APIRouterV21]
        elif self._test == 'v2.1_compatible':
            expected_middleware = [openstack.LegacyV2CompatibleWrapper,
                                   compute.APIRouterV21]
        elif (self._test == 'v2' and self._api_version == 'v2'):
            # override /v2 in compatibility mode with v2 legacy
            self.useFixture(api_paste_fixture.ApiPasteLegacyV2Fixture())

        super(ApiSampleTestBaseV3, self).setUp()
        self.useFixture(test.SampleNetworks(host=self.network.host))
        fake_network.stub_compute_with_ips(self.stubs)
        fake_utils.stub_out_utils_spawn_n(self.stubs)
        self.generate_samples = os.getenv('GENERATE_SAMPLES') is not None
        if expected_middleware:
            self._check_api_endpoint('/v2', expected_middleware)
コード例 #14
0
    def setUp(self):
        super(CinderCloudTestCase, self).setUp()
        ec2utils.reset_cache()
        self.useFixture(fixtures.TempDir()).path
        fake_utils.stub_out_utils_spawn_n(self.stubs)
        self.flags(compute_driver='nova.virt.fake.FakeDriver',
                   volume_api_class='nova.tests.unit.fake_volume.API')

        def fake_show(meh, context, id, **kwargs):
            return {
                'id': id,
                'name': 'fake_name',
                'container_format': 'ami',
                'status': 'active',
                'properties': {
                    'kernel_id': 'cedef40a-ed67-4d10-800e-17455edce175',
                    'ramdisk_id': 'cedef40a-ed67-4d10-800e-17455edce175',
                    'type': 'machine',
                    'image_state': 'available'
                }
            }

        def fake_detail(_self, context, **kwargs):
            image = fake_show(None, context, None)
            image['name'] = kwargs.get('filters', {}).get('name')
            return [image]

        self.stubs.Set(fake._FakeImageService, 'show', fake_show)
        self.stubs.Set(fake._FakeImageService, 'detail', fake_detail)
        fake.stub_out_image_service(self.stubs)

        def dumb(*args, **kwargs):
            pass

        self.stubs.Set(compute_utils, 'notify_about_instance_usage', dumb)
        fake_network.set_stub_network_methods(self.stubs)

        # set up our cloud
        self.cloud = cloud.CloudController()
        self.flags(scheduler_driver='nova.scheduler.chance.ChanceScheduler')

        # Short-circuit the conductor service
        self.flags(use_local=True, group='conductor')

        # Stub out the notification service so we use the no-op serializer
        # and avoid lazy-load traces with the wrap_exception decorator in
        # the compute service.
        fake_notifier.stub_notifier(self.stubs)
        self.addCleanup(fake_notifier.reset)

        # set up services
        self.conductor = self.start_service('conductor',
                                            manager=CONF.conductor.manager)
        self.compute = self.start_service('compute')
        self.scheduler = self.start_service('scheduler')
        self.network = self.start_service('network')
        self.consoleauth = self.start_service('consoleauth')

        self.user_id = 'fake'
        self.project_id = 'fake'
        self.context = context.RequestContext(self.user_id,
                                              self.project_id,
                                              is_admin=True)
        self.volume_api = volume.API()
        self.volume_api.reset_fake_api(self.context)

        self.useFixture(cast_as_call.CastAsCall(self.stubs))

        # make sure we can map ami-00000001/2 to a uuid in FakeImageService
        db.s3_image_create(self.context,
                           'cedef40a-ed67-4d10-800e-17455edce175')
        db.s3_image_create(self.context,
                           '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6')
コード例 #15
0
ファイル: test_cinder_cloud.py プロジェクト: kitch/nova
    def setUp(self):
        super(CinderCloudTestCase, self).setUp()
        ec2utils.reset_cache()
        self.useFixture(fixtures.TempDir()).path
        fake_utils.stub_out_utils_spawn_n(self.stubs)
        self.flags(compute_driver='nova.virt.fake.FakeDriver',
                   volume_api_class='nova.tests.unit.fake_volume.API')

        def fake_show(meh, context, id, **kwargs):
            return {'id': id,
                    'name': 'fake_name',
                    'container_format': 'ami',
                    'status': 'active',
                    'properties': {
                        'kernel_id': 'cedef40a-ed67-4d10-800e-17455edce175',
                        'ramdisk_id': 'cedef40a-ed67-4d10-800e-17455edce175',
                        'type': 'machine',
                        'image_state': 'available'}}

        def fake_detail(_self, context, **kwargs):
            image = fake_show(None, context, None)
            image['name'] = kwargs.get('filters', {}).get('name')
            return [image]

        self.stubs.Set(fake._FakeImageService, 'show', fake_show)
        self.stubs.Set(fake._FakeImageService, 'detail', fake_detail)
        fake.stub_out_image_service(self)

        def dumb(*args, **kwargs):
            pass

        self.stubs.Set(compute_utils, 'notify_about_instance_usage', dumb)
        fake_network.set_stub_network_methods(self.stubs)

        # set up our cloud
        self.cloud = cloud.CloudController()
        self.flags(scheduler_driver='nova.scheduler.chance.ChanceScheduler')

        # Short-circuit the conductor service
        self.flags(use_local=True, group='conductor')

        # Stub out the notification service so we use the no-op serializer
        # and avoid lazy-load traces with the wrap_exception decorator in
        # the compute service.
        fake_notifier.stub_notifier(self.stubs)
        self.addCleanup(fake_notifier.reset)

        # set up services
        self.conductor = self.start_service('conductor',
                manager=CONF.conductor.manager)
        self.compute = self.start_service('compute')
        self.scheduler = self.start_service('scheduler')
        self.network = self.start_service('network')
        self.consoleauth = self.start_service('consoleauth')

        self.user_id = 'fake'
        self.project_id = 'fake'
        self.context = context.RequestContext(self.user_id,
                                              self.project_id,
                                              is_admin=True)
        self.volume_api = volume.API()
        self.volume_api.reset_fake_api(self.context)

        self.stubs.Set(compute_manager.ComputeManager,
                       '_update_scheduler_instance_info', dumb)
        self.stubs.Set(compute_manager.ComputeManager,
                       '_delete_scheduler_instance_info', dumb)
        self.stubs.Set(compute_manager.ComputeManager,
                       '_sync_scheduler_instance_info', dumb)
        self.useFixture(cast_as_call.CastAsCall(self.stubs))

        # make sure we can map ami-00000001/2 to a uuid in FakeImageService
        db.s3_image_create(self.context,
                               'cedef40a-ed67-4d10-800e-17455edce175')
        db.s3_image_create(self.context,
                               '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6')