Exemplo n.º 1
0
    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
Exemplo n.º 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
Exemplo n.º 3
0
    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
Exemplo n.º 4
0
    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
Exemplo n.º 5
0
    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
 def start_service(self, name, host=None, **kwargs):
     svc = self.useFixture(
         nova_fixtures.ServiceFixture(name, host, **kwargs))
     return svc.service
Exemplo n.º 7
0
 def test_service_isolation(self):
     self.flags(use_local=True, group='conductor')
     self.useFixture(fixtures.ServiceFixture('compute'))
Exemplo n.º 8
0
 def test_service_isolation(self):
     self.useFixture(fixtures.ServiceFixture('compute'))
Exemplo n.º 9
0
 def test_service_isolation(self, mock_do_setup):
     self.useFixture(fixtures.ServiceFixture('compute'))