def setUp(self):
        self.flags(glance_link_prefix=self._get_glance_host(),
                   compute_link_prefix=self._get_host(),
                   group='api')

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

        if not self.SUPPORTS_CELLS:
            # NOTE(danms): Disable base automatic DB (and cells) config
            self.USES_DB = False
            self.USES_DB_SELF = True

        # 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()

        if not self.SUPPORTS_CELLS:
            self.useFixture(fixtures.Database())
            self.useFixture(fixtures.Database(database='api'))
            self.useFixture(fixtures.DefaultFlavorsFixture())
            self.useFixture(fixtures.SingleCellSimple())

        super(ApiSampleTestBaseV21, self)._setup_services()

        self.useFixture(fixtures.SpawnIsSynchronousFixture())
        # this is used to generate sample docs
        self.generate_samples = os.getenv('GENERATE_SAMPLES') is not None

        if self.availability_zones:
            self.useFixture(
                fixtures.AvailabilityZoneFixture(self.availability_zones))
Example #2
0
 def test_cross_az_attach_false_bfv_az_specified_mismatch(self):
     """Negative test where the server is being created in a specific AZ
     that does not match the volume being attached which results in a 400
     error response.
     """
     self.flags(cross_az_attach=False, group='cinder')
     # Do not need imageRef for boot from volume.
     server = self._build_server(image_uuid='', az='london')
     server['block_device_mapping_v2'] = [{
         'source_type':
         'volume',
         'destination_type':
         'volume',
         'boot_index':
         0,
         'uuid':
         nova_fixtures.CinderFixture.IMAGE_BACKED_VOL
     }]
     # Use the AZ fixture to fake out the london AZ.
     with nova_fixtures.AvailabilityZoneFixture(zones=['london', self.az]):
         ex = self.assertRaises(api_client.OpenStackApiException,
                                self.api.post_server, {'server': server})
     self.assertEqual(400, ex.response.status_code)
     self.assertIn(
         'Server and volumes are not in the same availability '
         'zone. Server is in: london. Volumes are in: %s' % self.az,
         six.text_type(ex))
    def setUp(self):
        self.flags(use_ipv6=False)
        self.flags(glance_link_prefix=self._get_glance_host(),
                   compute_link_prefix=self._get_host(),
                   group='api')

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

        if not self.SUPPORTS_CELLS:
            # NOTE(danms): Disable base automatic DB (and cells) config
            self.USES_DB = False
            self.USES_DB_SELF = True
        # This is to enable the network quota which is being registered
        # based on CONF.enable_network_quota. Need this to test the
        # network quota in quota sample tests.
        self.flags(enable_network_quota=True)
        self.useFixture(fixtures.RegisterNetworkQuota())

        # 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()

        if not self.SUPPORTS_CELLS:
            self.useFixture(fixtures.Database())
            self.useFixture(fixtures.Database(database='api'))
            self.useFixture(fixtures.DefaultFlavorsFixture())
            self.useFixture(fixtures.SingleCellSimple())

        super(ApiSampleTestBaseV21, self)._setup_services()

        if not self.USE_NEUTRON:
            # self.network is only setup if USE_NEUTRON=False
            self.useFixture(test.SampleNetworks(host=self.network.host))
        fake_network.stub_compute_with_ips(self)
        self.useFixture(fixtures.SpawnIsSynchronousFixture())
        # this is used to generate sample docs
        self.generate_samples = os.getenv('GENERATE_SAMPLES') is not None

        # NOTE(mikal): this is used to stub away privsep helpers
        def fake_noop(*args, **kwargs):
            return '', ''
        self.stub_out('nova.privsep.linux_net.add_bridge', fake_noop)
        self.stub_out('nova.privsep.linux_net.set_device_mtu', fake_noop)
        self.stub_out('nova.privsep.linux_net.set_device_enabled', fake_noop)
        self.stub_out('nova.privsep.linux_net.set_device_macaddr', fake_noop)
        self.stub_out('nova.privsep.linux_net.routes_show', fake_noop)
        self.stub_out('nova.privsep.linux_net.lookup_ip', fake_noop)
        self.stub_out('nova.privsep.linux_net.change_ip', fake_noop)
        self.stub_out('nova.privsep.linux_net.address_command_deprecated',
                      fake_noop)

        if self.availability_zones:
            self.useFixture(
                fixtures.AvailabilityZoneFixture(self.availability_zones))