예제 #1
0
 def _check_systemd_services(self, services):
     def _get_services_with_suffix(_services):
         return {
             '{0}.service'.format(k): v for (k, v) in _services.items()
         }
     all_services = get_system_manager_services(
         BASE_SERVICES,
         OPTIONAL_SERVICES
     )
     all_services = _get_services_with_suffix(all_services)
     systemd_services = get_services(all_services)
     statuses = []
     for service in systemd_services:
         status = self._lookup_systemd_service_status(
             service, _get_services_with_suffix(OPTIONAL_SERVICES)
         )
         if status:
             services[service['display_name']] = {
                 'status': status,
                 'is_remote': False,
                 'extra_info': {
                     'systemd': service
                 }
             }
             statuses.append(status)
     return statuses
예제 #2
0
    def get(self, **kwargs):
        """Get the status of running system services"""
        if get_services:
            services = get_system_manager_services(BASE_SERVICES,
                                                   OPTIONAL_SERVICES)
            jobs = get_services(services)
            jobs = [
                job for job in jobs
                if should_be_in_services_output(job, OPTIONAL_SERVICES)
            ]
            # If PostgreSQL is not local, print it as 'remote'
            if not config.instance.postgresql_host.startswith(
                ('localhost', '127.0.0.1')):
                for job in jobs:
                    if job['display_name'] == 'PostgreSQL' \
                            and job['instances']:
                        job['instances'][0]['state'] = 'remote'

            broker_state = 'running' if broker_is_healthy() else 'failed'
            for job in jobs:
                if job['display_name'] == 'RabbitMQ' and job['instances']:
                    job['instances'][0]['state'] = broker_state
        else:
            jobs = ['undefined']

        return {'status': 'running', 'services': jobs}
예제 #3
0
 def _check_systemd_services(self, services):
     systemd_services = get_services(
         get_systemd_manager_services(BASE_SERVICES, OPTIONAL_SERVICES))
     statuses = []
     for service in systemd_services:
         if should_be_in_services_output(service, OPTIONAL_SERVICES):
             is_service_running = service['instances'] and (
                 service['instances'][0]['state'] == 'running')
             status = NodeServiceStatus.ACTIVE if is_service_running \
                 else NodeServiceStatus.INACTIVE
             services[service['display_name']] = {
                 'status': status,
                 'is_remote': False,
                 'extra_info': {
                     'systemd': service
                 }
             }
             statuses.append(status)
     return statuses
예제 #4
0
def get_systemd_services(service_names):
    """
    :param service_names: {'service_unit_id': 'service_display_name'}
    e.g., {'cloudify-rabbitmq.service': 'RabbitMQ'}
    """
    systemd_services = get_services(service_names)
    statuses = []
    services = {}
    for service in systemd_services:
        is_service_running = service['instances'] and (
            service['instances'][0]['state'] == 'running')
        status = NodeServiceStatus.ACTIVE if is_service_running \
            else NodeServiceStatus.INACTIVE
        services[service['display_name']] = {
            'status': status,
            'extra_info': {
                'systemd': service
            }
        }
        statuses.append(status)
    return services, statuses