def setUp(self): super(TestLocalDeleteAttachedVolumes, self).setUp() self.useFixture(nova_fixtures.RealPolicyFixture()) # We need the CinderFixture to stub out the volume API. self.cinder = self.useFixture(nova_fixtures.CinderFixture(self)) # The NeutronFixture is needed to stub out validate_networks in API. self.useFixture(nova_fixtures.NeutronFixture(self)) # Use the PlacementFixture to avoid annoying warnings in the logs. self.useFixture(func_fixtures.PlacementFixture()) api_fixture = self.useFixture( nova_fixtures.OSAPIFixture(api_version='v2.1')) self.api = api_fixture.api # We want to use 2.37 for passing networks='none' on server create. # We also need this since you can only attach a volume to a # shelved-offloaded server in microversion 2.20+. self.api.microversion = 'latest' # the image fake backend needed for image discovery self.useFixture(nova_fixtures.GlanceFixture(self)) self.start_service('conductor') self.start_service('scheduler') self.start_service('compute') self.useFixture(nova_fixtures.CastAsCallFixture(self)) self.flavor_id = self.api.get_flavors()[0]['id']
def setUp(self): super(ComputeManagerTestCase, self).setUp() self.useFixture(nova_fixtures.SpawnIsSynchronousFixture()) self.useFixture(nova_fixtures.CastAsCallFixture(self)) self.conductor = self.start_service('conductor') self.start_service('scheduler') self.compute = self.start_service('compute') self.context = context.RequestContext('fake', 'fake') fake_server_actions.stub_out_action_events(self) fake_network.set_stub_network_methods(self) self.useFixture( fixtures.MockPatch( 'nova.network.neutron.API.get_instance_nw_info', return_value=network_model.NetworkInfo(), ))
def setUp(self): super(SchedulerOnlyChecksTargetTest, self).setUp() self.useFixture(nova_fixtures.RealPolicyFixture()) # The NeutronFixture is needed to stub out validate_networks in API. self.useFixture(nova_fixtures.NeutronFixture(self)) # We need the computes reporting into placement for the filter # scheduler to pick a host. self.useFixture(func_fixtures.PlacementFixture()) api_fixture = self.useFixture( nova_fixtures.OSAPIFixture(api_version='v2.1')) # The admin API is used to get the server details to verify the # host on which the server was built. self.admin_api = api_fixture.admin_api self.api = api_fixture.api # the image fake backend needed for image discovery self.useFixture(nova_fixtures.GlanceFixture(self)) self.start_service('conductor') # Use the latest microversion available to make sure something does # not regress in new microversions; cap as necessary. self.admin_api.microversion = 'latest' self.api.microversion = 'latest' # Define a very basic scheduler that only verifies if host is down. self.flags(enabled_filters=['ComputeFilter'], group='filter_scheduler') # NOTE(sbauza): Use the HostNameWeigherFixture so we are sure that # we prefer first host1 for the boot request and forget about any # other weigher. # Host2 should only be preferred over host3 if and only if that's the # only host we verify (as requested_destination does). self.useFixture( nova_fixtures.HostNameWeigherFixture(weights={ 'host1': 100, 'host2': 1, 'host3': 50 })) self.start_service('scheduler') # Let's now start three compute nodes as we said above. self.start_service('compute', host='host1') self.start_service('compute', host='host2') self.start_service('compute', host='host3') self.useFixture(nova_fixtures.CastAsCallFixture(self))
def setUp(self): super(TestServerUpdate, self).setUp() self.useFixture(nova_fixtures.RealPolicyFixture()) self.useFixture(nova_fixtures.NeutronFixture(self)) self.useFixture(nova_fixtures.GlanceFixture(self)) # Simulate requests coming in before the instance is scheduled by # using a no-op for conductor build_instances self.useFixture(nova_fixtures.NoopConductorFixture()) api_fixture = self.useFixture( nova_fixtures.OSAPIFixture(api_version='v2.1')) self.api = api_fixture.api self.useFixture(nova_fixtures.CastAsCallFixture(self)) self.image_id = self.api.get_images()[0]['id'] self.flavor_id = self.api.get_flavors()[0]['id']
def setUp(self): super(TestServerGet, self).setUp() self.useFixture(nova_fixtures.RealPolicyFixture()) self.useFixture(nova_fixtures.NeutronFixture(self)) self.useFixture(nova_fixtures.GlanceFixture(self)) api_fixture = self.useFixture( nova_fixtures.OSAPIFixture(api_version='v2.1')) self.api = api_fixture.api self.start_service('conductor') self.start_service('scheduler') self.compute = self.start_service('compute') self.useFixture(nova_fixtures.CastAsCallFixture(self)) self.image_id = self.api.get_images()[0]['id'] self.flavor_id = self.api.get_flavors()[0]['id']
def setUp(self): super(TestDeleteFromCell0CheckQuota, self).setUp() self.useFixture(nova_fixtures.RealPolicyFixture()) self.useFixture(nova_fixtures.NeutronFixture(self)) self.useFixture(nova_fixtures.GlanceFixture(self)) api_fixture = self.useFixture( nova_fixtures.OSAPIFixture(api_version='v2.1')) self.api = api_fixture.api self.start_service('conductor') self.start_service('scheduler') # We don't actually start a compute service; this way we don't have any # compute hosts to schedule the instance to and will go into error and # be put into cell0. self.useFixture(nova_fixtures.CastAsCallFixture(self)) self.image_id = self.api.get_images()[0]['id'] self.flavor_id = self.api.get_flavors()[0]['id']
def setUp(self): super(ServerListLimitMarkerCell0Test, self).setUp() self.useFixture(nova_fixtures.RealPolicyFixture()) # The NeutronFixture is needed to stub out validate_networks in API. self.useFixture(nova_fixtures.NeutronFixture(self)) api_fixture = self.useFixture( nova_fixtures.OSAPIFixture(api_version='v2.1')) self.api = api_fixture.api # the image fake backend needed for image discovery self.useFixture(nova_fixtures.GlanceFixture(self)) # Use the latest microversion available to make sure something does # not regress in new microversions; cap as necessary. self.api.microversion = 'latest' self.start_service('conductor') self.start_service('scheduler') # We don't start the compute service because we want NoValidHost so # all of the instances go into ERROR state and get put into cell0. self.useFixture(nova_fixtures.CastAsCallFixture(self))
def setUp(self): super(TestListServersIpFilter, self).setUp() self.useFixture(nova_fixtures.RealPolicyFixture()) self.useFixture(nova_fixtures.GlanceFixture(self)) self.neutron = self.useFixture(nova_fixtures.NeutronFixture(self)) # Add a 2nd port to the neutron fixture to have multiple ports self.neutron.create_port({'port': self.neutron.port_2}) api_fixture = self.useFixture( nova_fixtures.OSAPIFixture(api_version='v2.1')) self.api = api_fixture.api self.useFixture(func_fixtures.PlacementFixture()) self.start_service('conductor') self.flags(enabled_filters=['ComputeFilter'], group='filter_scheduler') self.start_service('scheduler') self.start_service('compute') self.useFixture(nova_fixtures.CastAsCallFixture(self)) self.image_id = self.api.get_images()[0]['id'] self.flavor_id = self.api.get_flavors()[0]['id']
def setUp(self): super(TestServerGet, self).setUp() self.useFixture(nova_fixtures.RealPolicyFixture()) self.useFixture(nova_fixtures.NeutronFixture(self)) self.useFixture(nova_fixtures.GlanceFixture(self)) self.useFixture(nova_fixtures.CastAsCallFixture(self)) # The non-admin API client is fine to stay at 2.1 since it just creates # and deletes the server. api_fixture = self.useFixture( nova_fixtures.OSAPIFixture(api_version='v2.1')) self.api = api_fixture.api self.admin_api = api_fixture.admin_api # The admin API client needs to be at microversion 2.16 to exhibit the # regression. self.admin_api.microversion = '2.16' self.start_service('conductor') self.start_service('scheduler') self.compute = self.start_service('compute') self.image_id = self.api.get_images()[0]['id'] self.flavor_id = self.api.get_flavors()[0]['id']
def setUp(self): super(TestSerialConsoleLiveMigrate, self).setUp() self.useFixture(nova_fixtures.RealPolicyFixture()) self.useFixture(nova_fixtures.NeutronFixture(self)) self.useFixture(nova_fixtures.GlanceFixture(self)) self.useFixture(func_fixtures.PlacementFixture()) api_fixture = self.useFixture( nova_fixtures.OSAPIFixture(api_version='v2.1')) # Replace libvirt with fakelibvirt self.useFixture( fixtures.MonkeyPatch('nova.virt.libvirt.driver.libvirt', fakelibvirt)) self.useFixture( fixtures.MonkeyPatch('nova.virt.libvirt.host.libvirt', fakelibvirt)) self.useFixture( fixtures.MonkeyPatch('nova.virt.libvirt.guest.libvirt', fakelibvirt)) self.useFixture(nova_fixtures.LibvirtFixture()) self.admin_api = api_fixture.admin_api self.api = api_fixture.api self.flags(compute_driver='libvirt.LibvirtDriver') self.flags(enabled=True, group="serial_console") self.flags(enabled=False, group="vnc") self.flags(enabled=False, group="spice") self.start_service('conductor') self.start_service('scheduler') self.compute = self.start_service('compute', host='test_compute1') self.useFixture(nova_fixtures.CastAsCallFixture(self)) self.image_id = self.api.get_images()[0]['id'] self.flavor_id = self.api.get_flavors()[0]['id']
def setUp(self): super(TestRetryBetweenComputeNodeBuilds, self).setUp() self.useFixture(nova_fixtures.RealPolicyFixture()) # The NeutronFixture is needed to stub out validate_networks in API. self.useFixture(nova_fixtures.NeutronFixture(self)) # This stubs out the network allocation in compute. fake_network.set_stub_network_methods(self) # We need the computes reporting into placement for the filter # scheduler to pick a host. self.useFixture(func_fixtures.PlacementFixture()) api_fixture = self.useFixture(nova_fixtures.OSAPIFixture( api_version='v2.1')) # The admin API is used to get the server details to verify the # host on which the server was built. self.admin_api = api_fixture.admin_api # the image fake backend needed for image discovery self.useFixture(nova_fixtures.GlanceFixture(self)) self.start_service('conductor') # We start two compute services because we're going to fake one # of them to fail the build so we can trigger the retry code. self.start_service('compute', host='host1') self.start_service('compute', host='host2') self.scheduler_service = self.start_service('scheduler') self.useFixture(nova_fixtures.CastAsCallFixture(self)) self.image_id = self.admin_api.get_images()[0]['id'] self.flavor_id = self.admin_api.get_flavors()[0]['id'] # This is our flag that we set when we hit the first host and # made it fail. self.failed_host = None self.attempts = 0 # We can't stub nova.compute.claims.Claims.__init__ because there is # a race where nova.compute.claims.NopClaim will be used instead, # see for details: # https://opendev.org/openstack/nova/src/commit/ # bb02d1110a9529217a5e9b1e1fe8ca25873cac59/ # nova/compute/resource_tracker.py#L121-L130 real_instance_claim = resource_tracker.ResourceTracker.instance_claim def fake_instance_claim(_self, *args, **kwargs): self.attempts += 1 if self.failed_host is None: # Set the failed_host value to the ResourceTracker.host value. self.failed_host = _self.host raise exception.ComputeResourcesUnavailable( reason='failure on host %s' % _self.host) return real_instance_claim(_self, *args, **kwargs) self.stub_out( 'nova.compute.resource_tracker.ResourceTracker.instance_claim', fake_instance_claim)
def setUp(self): super(ComputeVersion5xPinnedRpcTests, self).setUp() self.useFixture(nova_fixtures.CastAsCallFixture(self)) self.compute1 = self._start_compute(host='host1')