예제 #1
0
    def test_status_check(self):
        service = models.Service()
        service.id = str(uuid.uuid4())
        service.engine_id = str(uuid.uuid4())
        service.binary = 'heat-engine'
        service.hostname = 'host.devstack.org'
        service.host = 'engine-1'
        service.report_interval = 60
        service.topic = 'engine'
        service.created_at = timeutils.utcnow()
        service.deleted_at = None
        service.updated_at = None

        service_dict = service_utils.format_service(service)
        self.assertEqual(service_dict['id'], service.id)
        self.assertEqual(service_dict['engine_id'], service.engine_id)
        self.assertEqual(service_dict['host'], service.host)
        self.assertEqual(service_dict['hostname'], service.hostname)
        self.assertEqual(service_dict['binary'], service.binary)
        self.assertEqual(service_dict['topic'], service.topic)
        self.assertEqual(service_dict['report_interval'],
                         service.report_interval)
        self.assertEqual(service_dict['created_at'], service.created_at)
        self.assertEqual(service_dict['updated_at'], service.updated_at)
        self.assertEqual(service_dict['deleted_at'], service.deleted_at)

        self.assertEqual(service_dict['status'], 'up')

        # check again within first report_interval time (60)
        service_dict = service_utils.format_service(service)
        self.assertEqual(service_dict['status'], 'up')

        # check update not happen within report_interval time (60+)
        service.created_at = (timeutils.utcnow() -
                              datetime.timedelta(0, 70))
        service_dict = service_utils.format_service(service)
        self.assertEqual(service_dict['status'], 'down')

        # check update happened after report_interval time (60+)
        service.updated_at = (timeutils.utcnow() -
                              datetime.timedelta(0, 70))
        service_dict = service_utils.format_service(service)
        self.assertEqual(service_dict['status'], 'down')

        # check update happened within report_interval time (60)
        service.updated_at = (timeutils.utcnow() -
                              datetime.timedelta(0, 50))
        service_dict = service_utils.format_service(service)
        self.assertEqual(service_dict['status'], 'up')
예제 #2
0
파일: manage.py 프로젝트: Hopebaytech/heat
 def service_clean(self):
     ctxt = context.get_admin_context()
     for service in service_objects.Service.get_all(ctxt):
         svc = service_utils.format_service(service)
         if svc['status'] == 'down':
             service_objects.Service.delete(ctxt, svc['id'])
     print(_('Dead engines are removed.'))
예제 #3
0
파일: manage.py 프로젝트: zzjeric/heat
    def service_list(self):
        ctxt = context.get_admin_context()
        services = [
            service_utils.format_service(service)
            for service in service_objects.Service.get_all(ctxt)
        ]

        print_format = "%-16s %-16s %-36s %-10s %-10s %-10s %-10s"
        print(print_format %
              (_('Hostname'), _('Binary'), _('Engine_Id'), _('Host'),
               _('Topic'), _('Status'), _('Updated At')))

        for svc in services:
            print(
                print_format %
                (svc['hostname'], svc['binary'], svc['engine_id'], svc['host'],
                 svc['topic'], svc['status'], svc['updated_at']))
예제 #4
0
파일: manage.py 프로젝트: Cindia-blue/heat
    def service_list(self):
        ctxt = context.get_admin_context()
        services = [service_utils.format_service(service)
                    for service in service_objects.Service.get_all(ctxt)]

        print_format = "%-16s %-16s %-36s %-10s %-10s %-10s %-10s"
        print(print_format % (_('Hostname'),
                              _('Binary'),
                              _('Engine_Id'),
                              _('Host'),
                              _('Topic'),
                              _('Status'),
                              _('Updated At')))

        for svc in services:
            print(print_format % (svc['hostname'],
                                  svc['binary'],
                                  svc['engine_id'],
                                  svc['host'],
                                  svc['topic'],
                                  svc['status'],
                                  svc['updated_at']))
예제 #5
0
 def active_service_count(cls, context):
     """Return the number of services reportedly active."""
     return len([
         svc for svc in cls.get_all(context)
         if service_utils.format_service(svc)['status'] == 'up'
     ])
예제 #6
0
 def active_service_count(cls, context):
     """Return the number of services reportedly active."""
     return len([
         svc for svc in cls.get_all(context)
         if service_utils.format_service(svc)['status'] == 'up'])