Ejemplo n.º 1
0
 def test_get_by_topic(self):
     self.mox.StubOutWithMock(db, 'service_get_all_by_topic')
     db.service_get_all_by_topic(self.context, 'fake-topic').AndReturn(
         [fake_service])
     self.mox.ReplayAll()
     services = service.ServiceList.get_by_topic(self.context, 'fake-topic')
     self.assertEqual(1, len(services))
     self.compare_obj(services[0], fake_service, allow_missing=OPTIONAL)
Ejemplo n.º 2
0
    def test_hosts_up(self):
        service1 = {'host': 'host1'}
        service2 = {'host': 'host2'}
        services = [service1, service2]

        self.mox.StubOutWithMock(db, 'service_get_all_by_topic')
        self.mox.StubOutWithMock(servicegroup.API, 'service_is_up')

        db.service_get_all_by_topic(self.context,
                self.topic).AndReturn(services)
        self.servicegroup_api.service_is_up(service1).AndReturn(False)
        self.servicegroup_api.service_is_up(service2).AndReturn(True)

        self.mox.ReplayAll()
        result = self.driver.hosts_up(self.context, self.topic)
        self.assertEqual(result, ['host2'])
Ejemplo n.º 3
0
    def hosts_up(self, context, topic):
        """Return the list of hosts that have a running service for topic."""

        services = db.service_get_all_by_topic(context, topic)
        return [
            service['host'] for service in services
            if self.servicegroup_api.service_is_up(service)
        ]
Ejemplo n.º 4
0
 def get_by_topic(cls, context, topic):
     db_services = db.service_get_all_by_topic(context, topic)
     return base.obj_make_list(context, cls(context), objects.Service,
                               db_services)
Ejemplo n.º 5
0
 def get_by_topic(cls, context, topic):
     db_services = db.service_get_all_by_topic(context, topic)
     return base.obj_make_list(context, cls(context), objects.Service,
                               db_services)