コード例 #1
0
ファイル: test.py プロジェクト: dustin-cowles/openstack-nova
    def start_service(self, name, host=None, **kwargs):
        cell = None
        # if the host is None then the CONF.host remains defaulted to
        # 'fake-mini' (originally done in ConfFixture)
        if host is not None:
            # Make sure that CONF.host is relevant to the right hostname
            self.useFixture(nova_fixtures.ConfPatcher(host=host))

        if name == 'compute' and self.USES_DB:
            # NOTE(danms): We need to create the HostMapping first, because
            # otherwise we'll fail to update the scheduler while running
            # the compute node startup routines below.
            ctxt = context.get_context()
            cell_name = kwargs.pop('cell', CELL1_NAME) or CELL1_NAME
            cell = self.cell_mappings[cell_name]
            if (host or name) not in self.host_mappings:
                # NOTE(gibi): If the HostMapping does not exists then this is
                # the first start of the service so we create the mapping.
                hm = objects.HostMapping(context=ctxt,
                                         host=host or name,
                                         cell_mapping=cell)
                hm.create()
                self.host_mappings[hm.host] = hm
        svc = self.useFixture(
            nova_fixtures.ServiceFixture(name, host, cell=cell, **kwargs))

        return svc.service
コード例 #2
0
    def start_service(self, name, host=None, **kwargs):
        svc = self.useFixture(
            nova_fixtures.ServiceFixture(name, host, **kwargs))

        if name == 'compute' and self.USES_DB:
            ctxt = context.get_context()
            cell = self.cell_mappings[kwargs.pop('cell', CELL1_NAME)]
            hm = objects.HostMapping(context=ctxt,
                                     host=svc.service.host,
                                     cell_mapping=cell)
            hm.create()
            self.host_mappings[hm.host] = hm

        return svc.service
コード例 #3
0
ファイル: test.py プロジェクト: chuongntv/nova
    def start_service(self, name, host=None, **kwargs):
        if name == 'compute' and self.USES_DB:
            # NOTE(danms): We need to create the HostMapping first, because
            # otherwise we'll fail to update the scheduler while running
            # the compute node startup routines below.
            ctxt = context.get_context()
            cell = self.cell_mappings[kwargs.pop('cell', CELL1_NAME)]
            hm = objects.HostMapping(context=ctxt,
                                     host=host or name,
                                     cell_mapping=cell)
            hm.create()
            self.host_mappings[hm.host] = hm

        svc = self.useFixture(
            nova_fixtures.ServiceFixture(name, host, **kwargs))

        return svc.service
コード例 #4
0
ファイル: test.py プロジェクト: stackhpc/nova
    def start_service(self, name, host=None, cell_name=None, **kwargs):
        # Disallow starting multiple scheduler services
        if name == 'scheduler' and self._service_fixture_count[name]:
            raise TestingException("Duplicate start_service(%s)!" % name)

        cell = None
        # if the host is None then the CONF.host remains defaulted to
        # 'fake-mini' (originally done in ConfFixture)
        if host is not None:
            # Make sure that CONF.host is relevant to the right hostname
            self.useFixture(nova_fixtures.ConfPatcher(host=host))

        if name == 'compute' and self.USES_DB:
            # NOTE(danms): We need to create the HostMapping first, because
            # otherwise we'll fail to update the scheduler while running
            # the compute node startup routines below.
            ctxt = context.get_context()
            cell_name = cell_name or CELL1_NAME
            cell = self.cell_mappings[cell_name]
            if (host or name) not in self.host_mappings:
                # NOTE(gibi): If the HostMapping does not exists then this is
                # the first start of the service so we create the mapping.
                hm = objects.HostMapping(context=ctxt,
                                         host=host or name,
                                         cell_mapping=cell)
                hm.create()
                self.host_mappings[hm.host] = hm
        svc = self.useFixture(
            nova_fixtures.ServiceFixture(name, host, cell=cell, **kwargs))

        # Keep track of how many instances of this service are running.
        self._service_fixture_count[name] += 1
        real_stop = svc.service.stop

        # Make sure stopping the service decrements the active count, so that
        # start,stop,start doesn't trigger the "Duplicate start_service"
        # exception.
        def patch_stop(*a, **k):
            self._service_fixture_count[name] -= 1
            return real_stop(*a, **k)

        self.useFixture(
            fixtures.MockPatchObject(svc.service, 'stop', patch_stop))

        return svc.service
コード例 #5
0
ファイル: test.py プロジェクト: weizai118/nova
    def start_service(self, name, host=None, **kwargs):
        cell = None
        if name == 'compute' and self.USES_DB:
            # NOTE(danms): We need to create the HostMapping first, because
            # otherwise we'll fail to update the scheduler while running
            # the compute node startup routines below.
            ctxt = context.get_context()
            cell_name = kwargs.pop('cell', CELL1_NAME) or CELL1_NAME
            cell = self.cell_mappings[cell_name]
            hm = objects.HostMapping(context=ctxt,
                                     host=host or name,
                                     cell_mapping=cell)
            hm.create()
            self.host_mappings[hm.host] = hm
            if host is not None:
                # Make sure that CONF.host is relevant to the right hostname
                self.useFixture(nova_fixtures.ConfPatcher(host=host))
        svc = self.useFixture(
            nova_fixtures.ServiceFixture(name, host, cell=cell, **kwargs))

        return svc.service
コード例 #6
0
 def start_service(self, name, host=None, **kwargs):
     svc = self.useFixture(
         nova_fixtures.ServiceFixture(name, host, **kwargs))
     return svc.service
コード例 #7
0
 def test_service_isolation(self):
     self.flags(use_local=True, group='conductor')
     self.useFixture(fixtures.ServiceFixture('compute'))
コード例 #8
0
ファイル: test_test.py プロジェクト: bopopescu/nova-11
 def test_service_isolation(self):
     self.useFixture(fixtures.ServiceFixture('compute'))
コード例 #9
0
ファイル: test_test.py プロジェクト: wangyi4/stx-nova
 def test_service_isolation(self, mock_do_setup):
     self.useFixture(fixtures.ServiceFixture('compute'))