Exemplo n.º 1
0
    def setUp(self):
        super(SchedulerOnlyChecksTargetTest, self).setUp()
        self.useFixture(policy_fixture.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
        image_fake.stub_out_image_service(self)
        self.addCleanup(image_fake.FakeImageService_reset)

        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(cast_as_call.CastAsCall(self))
Exemplo n.º 2
0
    def setUp(self):
        super(ServerFaultTestCase, self).setUp()
        self.useFixture(nova_fixtures.NeutronFixture(self))
        self.useFixture(func_fixtures.PlacementFixture())
        self.useFixture(nova_fixtures.GlanceFixture(self))
        self.useFixture(nova_fixtures.RealPolicyFixture())

        # Start the compute services.
        self.start_service('conductor')
        self.start_service('scheduler')
        self.compute = self.start_service('compute')
        api_fixture = self.useFixture(
            nova_fixtures.OSAPIFixture(api_version='v2.1'))
        self.api = api_fixture.api
        self.admin_api = api_fixture.admin_api
 def setUp(self):
     super(TestNeutronExternalNetworks, self).setUp()
     # Use the standard fixtures.
     self.useFixture(policy_fixture.RealPolicyFixture())
     self.useFixture(func_fixtures.PlacementFixture())
     self.useFixture(nova_fixtures.GlanceFixture(self))
     neutron = self.useFixture(nova_fixtures.NeutronFixture(self))
     self._setup_external_network(neutron)
     # Start nova controller services.
     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.start_service('compute', host='host1')
Exemplo n.º 4
0
    def setUp(self):
        super(TestMultiCreateServerGroupMemberOverQuota, self).setUp()
        self.flags(server_group_members=2, group='quota')
        self.useFixture(nova_fixtures.RealPolicyFixture())
        self.useFixture(nova_fixtures.NeutronFixture(self))
        self.glance = self.useFixture(nova_fixtures.GlanceFixture(self))
        self.useFixture(func_fixtures.PlacementFixture())

        api_fixture = self.useFixture(nova_fixtures.OSAPIFixture(
            api_version='v2.1'))
        self.api = api_fixture.api
        self.api.microversion = '2.37'  # so we can specify networks='none'

        group = {'name': 'test group', 'policies': ['soft-anti-affinity']}
        self.created_group = self.api.post_server_groups(group)
Exemplo n.º 5
0
    def setUp(self):
        super(FlavorManageFullstack, self).setUp()

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

        self.useFixture(policy_fixture.RealPolicyFixture())
        api_fixture = self.useFixture(
            nova_fixtures.OSAPIFixture(api_version=self.api_major_version))

        # NOTE(sdague): because this test is primarily an admin API
        # test default self.api to the admin api.
        self.api = api_fixture.admin_api
        self.user_api = api_fixture.api
Exemplo n.º 6
0
    def setUp(self):
        super(TestRequestSpecRetryReschedule, self).setUp()
        self.useFixture(policy_fixture.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
        image_fake.stub_out_image_service(self)
        self.addCleanup(image_fake.FakeImageService_reset)

        self.start_service('conductor')

        # We have to get the image before we use 2.latest otherwise we'll get
        # a 404 on the /images proxy API because of 2.36.
        self.image_id = self.api.get_images()[0]['id']

        # 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'

        # The consoleauth service is needed for deleting console tokens when
        # the server is deleted.
        self.start_service('consoleauth')

        # Use our custom weigher defined above to make sure that we have
        # a predictable scheduling sort order.
        self.flags(weight_classes=[__name__ + '.HostNameWeigher'],
                   group='filter_scheduler')
        self.start_service('scheduler')

        # Let's now start three compute nodes as we said above.
        self.addCleanup(fake.restore_nodes)
        for host in ['host1', 'host2', 'host3']:
            fake.set_nodes([host])
            self.start_service('compute', host=host)
Exemplo n.º 7
0
    def setUp(self):
        super(ServerTagsFilteringTest, self).setUp()
        self.useFixture(policy_fixture.RealPolicyFixture())
        # 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(nova_fixtures.PlacementFixture())
        api_fixture = self.useFixture(
            nova_fixtures.OSAPIFixture(api_version='v2.1'))
        self.api = api_fixture.api

        # the image fake backend needed for image discovery
        image_fake.stub_out_image_service(self)
        self.addCleanup(image_fake.FakeImageService_reset)
        # We have to get the image before we use 2.latest otherwise we'll get
        # a 404 on the /images proxy API because of 2.36.
        image_id = self.api.get_images()[0]['id']
        # 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')
        self.start_service('compute')
        # The consoleauth service is needed for deleting console tokens when
        # the server is deleted.
        self.start_service('consoleauth')

        # create two test servers
        self.servers = []
        for x in range(2):
            server = self.api.post_server(
                dict(server=self._build_minimal_create_server_request(
                    self.api,
                    'test-list-server-tag-filters%i' % x,
                    image_id,
                    networks='none')))
            self.addCleanup(self.api.delete_server, server['id'])
            server = self._wait_for_state_change(self.api, server, 'ACTIVE')
            self.servers.append(server)

        # now apply two tags to the first server
        self.two_tag_server = self.servers[0]
        self.api.put_server_tags(self.two_tag_server['id'], ['foo', 'bar'])
        # apply one tag to the second server which intersects with one tag
        # from the first server
        self.one_tag_server = self.servers[1]
        self.api.put_server_tags(self.one_tag_server['id'], ['foo'])
Exemplo n.º 8
0
    def test_end_to_end(self):
        """This test emulates a full end to end test showing that without this
        feature a vm cannot be spawning using a custom trait and then start a
        compute service that provides that trait.
        """

        self.useFixture(nova_fixtures.NeutronFixture(self))
        self.useFixture(nova_fixtures.GlanceFixture(self))

        # Start nova services.
        self.api = self.useFixture(
            nova_fixtures.OSAPIFixture(api_version='v2.1')).admin_api
        self.api.microversion = 'latest'
        self.start_service('conductor')
        # start nova-compute that will not have the additional trait.
        self._start_compute("fake-host-1")

        node_name = "fake-host-2"

        # create a config file with explicit name
        provider_config = self._create_config_entry(node_name,
                                                    id_method="name")
        self._place_config_file("provider_config.yaml", provider_config)

        self._create_flavor(name='CUSTOM_Flavor',
                            id=42,
                            vcpu=4,
                            memory_mb=4096,
                            disk=1024,
                            swap=0,
                            extra_spec={
                                f"trait:{os_traits.normalize_name(node_name)}":
                                "required"
                            })

        self._create_server(flavor_id=42,
                            expected_state='ERROR',
                            networks=[{
                                'port': self.neutron.port_1['id']
                            }])

        # start compute node that will report the custom trait.
        self._start_compute("fake-host-2")
        self._create_server(flavor_id=42,
                            expected_state='ACTIVE',
                            networks=[{
                                'port': self.neutron.port_1['id']
                            }])
Exemplo n.º 9
0
 def setUp(self):
     super(TestInstanceActionBuryInCell0, self).setUp()
     # Setup common fixtures.
     self.useFixture(func_fixtures.PlacementFixture())
     self.useFixture(nova_fixtures.NeutronFixture(self))
     self.useFixture(nova_fixtures.GlanceFixture(self))
     policy = self.useFixture(nova_fixtures.RealPolicyFixture())
     # Allow non-admins to see instance action events.
     policy.set_rules({
         'os_compute_api:os-instance-actions:events': 'rule:admin_or_owner'
     }, overwrite=False)
     # Setup controller services.
     self.start_service('conductor')
     self.start_service('scheduler')
     self.api = self.useFixture(
         nova_fixtures.OSAPIFixture(api_version='v2.1')).api
Exemplo n.º 10
0
 def setUp(self):
     super(CrossAZAttachTestCase, self).setUp()
     # Use the standard fixtures.
     self.useFixture(policy_fixture.RealPolicyFixture())
     self.useFixture(nova_fixtures.CinderFixture(self, az=self.az))
     self.useFixture(nova_fixtures.NeutronFixture(self))
     self.useFixture(func_fixtures.PlacementFixture())
     fake_image.stub_out_image_service(self)
     self.addCleanup(fake_image.FakeImageService_reset)
     # Start nova controller services.
     self.api = self.useFixture(
         nova_fixtures.OSAPIFixture(api_version='v2.1')).admin_api
     self.start_service('conductor')
     self.start_service('scheduler')
     # Start one compute service.
     self.start_service('compute', host='host1')
Exemplo n.º 11
0
    def setUp(self):
        super(VolumeBackedResizeDiskDown, self).setUp()
        self.flags(allow_resize_to_same_host=True)

        api_fixture = self.useFixture(
            nova_fixtures.OSAPIFixture(api_version='v2.1'))
        self.api = api_fixture.admin_api

        self.useFixture(nova_fixtures.NeutronFixture(self))
        self.useFixture(nova_fixtures.GlanceFixture(self))
        self.useFixture(nova_fixtures.CinderFixture(self))
        self.useFixture(func_fixtures.PlacementFixture())

        self.start_service('conductor')
        self.start_service('scheduler')
        self.start_service('compute')
Exemplo n.º 12
0
    def setUp(self):
        super(TestLocalDeleteAllocations, self).setUp()
        self.useFixture(nova_fixtures.RealPolicyFixture())
        # The NeutronFixture is needed to show security groups for a server.
        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.admin_api = api_fixture.admin_api
        # We need the latest microversion to force-down the compute service
        self.admin_api.microversion = 'latest'

        self.start_service('conductor')

        self.start_service('scheduler')
Exemplo n.º 13
0
    def setUp(self):
        super(ShowErrorServerWithTags, self).setUp()

        api_fixture = self.useFixture(
            nova_fixtures.OSAPIFixture(api_version='v2.1'))
        self.api = api_fixture.admin_api

        self.useFixture(nova_fixtures.NeutronFixture(self))
        self.useFixture(nova_fixtures.GlanceFixture(self))

        self.start_service('conductor')
        self.start_service('scheduler')

        self.image_id = self.api.get_images()[0]['id']

        self.api.microversion = 'latest'
Exemplo n.º 14
0
    def setUp(self):
        super(TestSerialConsoleLiveMigrate, self).setUp()
        self.useFixture(policy_fixture.RealPolicyFixture())
        self.useFixture(nova_fixtures.NeutronFixture(self))
        self.useFixture(nova_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_utils',
                                 fake_libvirt_utils))
        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(fakelibvirt.FakeLibvirtFixture())

        self.admin_api = api_fixture.admin_api
        self.api = api_fixture.api

        # the image fake backend needed for image discovery
        nova.tests.unit.image.fake.stub_out_image_service(self)
        nova.tests.unit.fake_network.set_stub_network_methods(self)

        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.flags(use_usb_tablet=False, group="libvirt")
        self.flags(host="test_compute1")

        self.start_service('conductor')
        self.flags(driver='chance_scheduler', group='scheduler')
        self.start_service('scheduler')
        self.compute = self.start_service('compute', host='test_compute1')
        self.consoleauth = self.start_service('consoleauth')

        self.useFixture(cast_as_call.CastAsCall(self))
        self.addCleanup(nova.tests.unit.image.fake.FakeImageService_reset)

        self.image_id = self.api.get_images()[0]['id']
        self.flavor_id = self.api.get_flavors()[0]['id']
Exemplo n.º 15
0
    def setUp(self):
        super(TestMultiCreateServerGroupMemberOverQuota, self).setUp()
        self.flags(server_group_members=2, group='quota')
        self.useFixture(policy_fixture.RealPolicyFixture())
        self.useFixture(nova_fixtures.NeutronFixture(self))
        self.useFixture(nova_fixtures.PlacementFixture())

        api_fixture = self.useFixture(nova_fixtures.OSAPIFixture(
            api_version='v2.1'))
        self.api = api_fixture.api
        self.api.microversion = '2.37'  # so we can specify networks='none'

        fake_image.stub_out_image_service(self)
        self.addCleanup(fake_image.FakeImageService_reset)

        group = {'name': 'test group', 'policies': ['soft-anti-affinity']}
        self.created_group = self.api.post_server_groups(group)
Exemplo n.º 16
0
    def setUp(self):
        super(BootFromVolumeOverQuotaRaceDeleteTest, self).setUp()
        # We need the cinder fixture for boot from volume testing.
        self.cinder_fixture = self.useFixture(
            nova_fixtures.CinderFixture(self))
        # Use the standard fixtures.
        self.useFixture(policy_fixture.RealPolicyFixture())
        self.useFixture(nova_fixtures.NeutronFixture(self))
        self.useFixture(func_fixtures.PlacementFixture())
        self.api = self.useFixture(nova_fixtures.OSAPIFixture(
            api_version='v2.1')).api
        # Use microversion 2.52 which allows creating a server with tags.
        self.api.microversion = '2.52'

        self.start_service('conductor')
        self.start_service('scheduler')
        self.start_service('compute')
    def setUp(self):
        super(ServerFaultTestCase, self).setUp()
        # Setup the standard fixtures.
        fake_image.stub_out_image_service(self)
        self.addCleanup(fake_image.FakeImageService_reset)
        self.useFixture(nova_fixtures.NeutronFixture(self))
        self.useFixture(func_fixtures.PlacementFixture())
        self.useFixture(policy_fixture.RealPolicyFixture())

        # Start the compute services.
        self.start_service('conductor')
        self.start_service('scheduler')
        self.compute = self.start_service('compute')
        api_fixture = self.useFixture(
            nova_fixtures.OSAPIFixture(api_version='v2.1'))
        self.api = api_fixture.api
        self.admin_api = api_fixture.admin_api
Exemplo n.º 18
0
    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']
Exemplo n.º 19
0
    def test_logs_under_exception(self, emit, v_index):
        """Ensure that logs still emit under unexpected failure.

        If we get an unexpected failure all the way up to the top, we should
        still have a record of that request via the except block.
        """

        emit.return_value = True
        v_index.side_effect = Exception("Unexpected Error")
        self.useFixture(conf_fixture.ConfFixture())
        self.useFixture(fixtures.RPCFixture('nova.test'))
        api = self.useFixture(fixtures.OSAPIFixture()).api

        api.api_request('/', strip_version=True)
        log1 = ('INFO [nova.api.openstack.requestlog] 127.0.0.1 "GET /"'
                ' status: 500 len: 0 microversion: - time:')
        self.assertIn(log1, self.stdlog.logger.output)
Exemplo n.º 20
0
    def setUp(self):
        super(TestServersPerUserQuota, self).setUp()
        self.useFixture(nova_fixtures.RealPolicyFixture())
        self.useFixture(nova_fixtures.NeutronFixture(self))
        self.useFixture(func_fixtures.PlacementFixture())
        self.glance = self.useFixture(nova_fixtures.GlanceFixture(self))

        api_fixture = self.useFixture(
            nova_fixtures.OSAPIFixture(api_version='v2.1'))
        self.api = api_fixture.api
        self.admin_api = api_fixture.admin_api
        self.api.microversion = '2.37'  # so we can specify networks='none'
        self.admin_api.microversion = '2.37'

        self.start_service('conductor')
        self.start_service('scheduler')
        self.start_service('compute')
Exemplo n.º 21
0
    def setUp(self):
        super(VolumeBackedResizeDiskDown, self).setUp()
        self.flags(allow_resize_to_same_host=True)

        api_fixture = self.useFixture(nova_fixtures.OSAPIFixture(
            api_version='v2.1'))
        self.api = api_fixture.admin_api

        self.useFixture(nova_fixtures.NeutronFixture(self))
        self.useFixture(nova_fixtures.CinderFixtureNewAttachFlow(self))
        self.useFixture(func_fixtures.PlacementFixture())
        fake_image.stub_out_image_service(self)
        self.addCleanup(fake_image.FakeImageService_reset)

        self.start_service('conductor')
        self.start_service('scheduler')
        self.start_service('compute')
Exemplo n.º 22
0
    def test_admin_snapshot_user_image_access_member(self):
        """Tests a scenario where a user in project A creates a server and
        an admin in project B creates a snapshot of the server. The user in
        project A should have member access to the image even though the admin
        project B is the owner of the image.
        """
        # Create a server using the tenant user project.
        server = self._build_minimal_create_server_request()
        server = self.api.post_server({"server": server})
        server = self._wait_for_state_change(server, 'BUILD')
        self.assertEqual('ACTIVE', server['status'])

        # Create an admin API fixture with a unique project ID.
        admin_api = self.useFixture(
            nova_fixtures.OSAPIFixture(
                project_id=uuids.admin_project)).admin_api

        # Create a snapshot of the server using the admin project.
        name = 'admin-created-snapshot'
        admin_api.post_server_action(server['id'],
                                     {'createImage': {
                                         'name': name
                                     }})
        # Confirm that the image was created.
        images = admin_api.get_images()
        for image in images:
            if image['name'] == name:
                break
        else:
            self.fail(
                'Expected snapshot image %s not found in images list %s' %
                (name, images))
        # Assert the owner is the admin project since the admin created the
        # snapshot. Note that the images API proxy puts stuff it does not know
        # about in the 'metadata' dict so that is where we will find owner.
        metadata = image['metadata']
        self.assertIn('owner', metadata)
        self.assertEqual(uuids.admin_project, metadata['owner'])
        # Assert the non-admin tenant user project is a member.
        self.assertIn('instance_owner', metadata)
        self.assertEqual(self.api_fixture.project_id,
                         metadata['instance_owner'])
        # Be sure we did not get a false positive by making sure the admin and
        # tenant user API fixtures are not using the same project_id.
        self.assertNotEqual(uuids.admin_project, self.api_fixture.project_id)
Exemplo n.º 23
0
    def setUp(self):
        super(TestAvailabilityZoneScheduling, self).setUp()

        self.useFixture(policy_fixture.RealPolicyFixture())
        self.useFixture(nova_fixtures.NeutronFixture(self))
        self.useFixture(func_fixtures.PlacementFixture())

        api_fixture = self.useFixture(
            nova_fixtures.OSAPIFixture(api_version='v2.1'))

        self.api = api_fixture.admin_api
        self.api.microversion = 'latest'

        fake_image.stub_out_image_service(self)
        self.addCleanup(fake_image.FakeImageService_reset)

        self.start_service('conductor')
        self.start_service('scheduler')
Exemplo n.º 24
0
    def setUp(self):
        super(TestServerGet, self).setUp()
        self.useFixture(policy_fixture.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(cast_as_call.CastAsCall(self))

        self.image_id = self.api.get_images()[0]['id']
        self.flavor_id = self.api.get_flavors()[0]['id']
Exemplo n.º 25
0
    def setUp(self):
        self.flags(compute_driver=self.compute_driver)
        super(AggregateRequestFiltersTest, self).setUp()

        self.useFixture(policy_fixture.RealPolicyFixture())
        self.useFixture(nova_fixtures.NeutronFixture(self))
        self.useFixture(nova_fixtures.AllServicesCurrent())

        placement = self.useFixture(func_fixtures.PlacementFixture())
        self.placement_api = placement.api
        api_fixture = self.useFixture(
            nova_fixtures.OSAPIFixture(api_version='v2.1'))

        self.admin_api = api_fixture.admin_api
        self.admin_api.microversion = self.microversion
        self.api = self.admin_api

        # the image fake backend needed for image discovery
        nova.tests.unit.image.fake.stub_out_image_service(self)

        self.start_service('conductor')
        self.scheduler_service = self.start_service('scheduler')

        self.computes = {}
        self.aggregates = {}

        self._start_compute('host1')
        self._start_compute('host2')

        self.context = nova_context.get_admin_context()
        self.report_client = report.SchedulerReportClient()

        self.flavors = self.api.get_flavors()

        # Aggregate with only host1
        self._create_aggregate('only-host1')
        self._add_host_to_aggregate('only-host1', 'host1')

        # Aggregate with only host2
        self._create_aggregate('only-host2')
        self._add_host_to_aggregate('only-host2', 'host2')

        # Aggregate with neither host
        self._create_aggregate('no-hosts')
Exemplo n.º 26
0
 def setUp(self):
     super(TestAntiAffinityLiveMigration, self).setUp()
     # Setup common fixtures.
     self.useFixture(policy_fixture.RealPolicyFixture())
     self.useFixture(nova_fixtures.NeutronFixture(self))
     self.useFixture(func_fixtures.PlacementFixture())
     # Setup API.
     api_fixture = self.useFixture(nova_fixtures.OSAPIFixture(
         api_version='v2.1'))
     self.api = api_fixture.api
     self.admin_api = api_fixture.admin_api
     # Fake out glance.
     nova.tests.unit.image.fake.stub_out_image_service(self)
     self.addCleanup(nova.tests.unit.image.fake.FakeImageService_reset)
     # Start conductor, scheduler and two computes.
     self.start_service('conductor')
     self.start_service('scheduler')
     for host in ('host1', 'host2'):
         self.start_service('compute', host=host)
Exemplo n.º 27
0
 def setUp(self):
     super(TestAggregateMultiTenancyIsolationFilter, self).setUp()
     # Stub out glance, placement and neutron.
     nova.tests.unit.image.fake.stub_out_image_service(self)
     self.addCleanup(nova.tests.unit.image.fake.FakeImageService_reset)
     self.useFixture(func_fixtures.PlacementFixture())
     self.useFixture(nova_fixtures.NeutronFixture(self))
     # Start nova services.
     self.start_service('conductor')
     self.admin_api = self.useFixture(
         nova_fixtures.OSAPIFixture(api_version='v2.1')).admin_api
     # Add the AggregateMultiTenancyIsolation to the list of enabled
     # filters since it is not enabled by default.
     enabled_filters = CONF.filter_scheduler.enabled_filters
     enabled_filters.append('AggregateMultiTenancyIsolation')
     self.flags(enabled_filters=enabled_filters, group='filter_scheduler')
     self.start_service('scheduler')
     for host in ('host1', 'host2'):
         self._start_compute(host)
Exemplo n.º 28
0
    def setUp(self):
        super(ServerGroupTestBase, self).setUp()
        self.flags(scheduler_default_filters=self._scheduler_default_filters)
        self.flags(service_down_time=self._service_down_time)
        self.flags(report_interval=self._report_interval)

        self.useFixture(policy_fixture.RealPolicyFixture())
        api_fixture = self.useFixture(nova_fixtures.OSAPIFixture())

        self.api = api_fixture.api
        self.admin_api = api_fixture.admin_api

        # the image fake backend needed for image discovery
        nova.tests.unit.image.fake.stub_out_image_service(self.stubs)

        self.start_service('conductor', manager=CONF.conductor.manager)
        self.start_service('scheduler')

        self.addCleanup(nova.tests.unit.image.fake.FakeImageService_reset)
Exemplo n.º 29
0
    def setUp(self):
        super(TestServerUpdate, self).setUp()
        self.useFixture(policy_fixture.RealPolicyFixture())
        # 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

        # the image fake backend needed for image discovery
        nova.tests.unit.image.fake.stub_out_image_service(self)

        self.useFixture(cast_as_call.CastAsCall(self.stubs))
        self.addCleanup(nova.tests.unit.image.fake.FakeImageService_reset)

        self.image_id = self.api.get_images()[0]['id']
        self.flavor_id = self.api.get_flavors()[0]['id']
Exemplo n.º 30
0
    def setUp(self):
        super(ServiceTestCase, self).setUp()
        # Use the standard fixtures.
        self.useFixture(policy_fixture.RealPolicyFixture())
        self.useFixture(nova_fixtures.NeutronFixture(self))
        self.useFixture(nova_fixtures.GlanceFixture(self))
        self.useFixture(func_fixtures.PlacementFixture())

        # Start nova controller services.
        self.api = self.useFixture(
            nova_fixtures.OSAPIFixture(api_version='v2.1')).api
        self.start_service('conductor')
        self.scheduler = self.start_service('scheduler')
        # Our OSAPIFixture does not use a WSGIService, so just use the metadata
        # server fixture (which uses WSGIService) for testing.
        self.metadata = self.useFixture(
            nova_fixtures.OSMetadataServer()).metadata
        # Start one compute service.
        self.start_service('compute')