How to use the aj.plugins.services.api.ServiceManager function in aj

To help you get started, we’ve selected a few aj examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ajenti / ajenti / plugins / services / managers / systemd_manager.py View on Github external
import subprocess

from jadi import component
from aj.plugins.services.api import ServiceManager, Service


@component(ServiceManager)
class SystemdServiceManager(ServiceManager):
    id = 'systemd'
    name = 'systemd'

    @classmethod
    def __verify__(cls):
        return subprocess.call(['which', 'systemctl']) == 0

    def __init__(self, context):
        pass

    def list(self, units=None):
        if not units:
            units = [x.split()[0] for x in subprocess.check_output(['systemctl', 'list-unit-files', '--no-legend', '--no-pager', '-la']).splitlines() if x]
            units = [x for x in units if x.endswith(b'.service') and b'@' not in x]
            units = list(set(units))
github ajenti / ajenti / plugins / services / managers / systemd_manager.py View on Github external
import subprocess

from jadi import component
from aj.plugins.services.api import ServiceManager, Service


@component(ServiceManager)
class SystemdServiceManager(ServiceManager):
    id = 'systemd'
    name = 'systemd'

    @classmethod
    def __verify__(cls):
        return subprocess.call(['which', 'systemctl']) == 0

    def __init__(self, context):
        pass

    def list(self, units=None):
        if not units:
            units = [x.split()[0] for x in subprocess.check_output(['systemctl', 'list-unit-files', '--no-legend', '--no-pager', '-la']).splitlines() if x]
            units = [x for x in units if x.endswith(b'.service') and b'@' not in x]
            units = list(set(units))
github ajenti / ajenti / plugins / supervisor / api.py View on Github external
from supervisor.options import ClientOptions

from jadi import component
from aj.plugins.services.api import ServiceManager, Service, ServiceOperationError


@component(ServiceManager)
class SupervisorServiceManager(ServiceManager):
    id = 'supervisor'
    name = 'Supervisor'

    def __init__(self, context):
        options = ClientOptions()
        options.realize([])
        self.supervisor = options.getServerProxy().supervisor

    def list(self):
        for info in self.supervisor.getAllProcessInfo():
            yield self.__make_service(info)

    def __make_service(self, info):
        svc = Service(self)
        svc.id = info['name']
        svc.name = info['name']
github ajenti / ajenti / plugins / services / views.py View on Github external
def __init__(self, context):
        self.context = context
        self.managers = dict((x.id, x) for x in ServiceManager.all(self.context))
github ajenti / ajenti / plugins / supervisor / api.py View on Github external
from supervisor.options import ClientOptions

from jadi import component
from aj.plugins.services.api import ServiceManager, Service, ServiceOperationError


@component(ServiceManager)
class SupervisorServiceManager(ServiceManager):
    id = 'supervisor'
    name = 'Supervisor'

    def __init__(self, context):
        options = ClientOptions()
        options.realize([])
        self.supervisor = options.getServerProxy().supervisor

    def list(self):
        for info in self.supervisor.getAllProcessInfo():
            yield self.__make_service(info)

    def __make_service(self, info):
        svc = Service(self)
        svc.id = info['name']
github ajenti / ajenti / plugins / services / managers / upstart_manager.py View on Github external
from dbus.exceptions import DBusException
from upstart.system import UpstartSystem, DirectUpstartBus
from upstart.job import UpstartJob

from jadi import component
from aj.plugins.services.api import ServiceManager, Service, ServiceOperationError


@component(ServiceManager)
class UpstartServiceManager(ServiceManager):
    id = 'upstart'
    name = 'Upstart'

    @classmethod
    def __verify__(cls):
        try:
            UpstartSystem()
            return True
        except:
            try:
                UpstartSystem(bus=DirectUpstartBus())
                return True
            except:
                return False
github ajenti / ajenti / plugins / services / managers / sysv_manager.py View on Github external
import os
import subprocess

from jadi import component
from aj.plugins.services.api import ServiceManager, Service


INIT_D = '/etc/init.d'
UPSTART_PATTERN = '/etc/init/%s.conf'


@component(ServiceManager)
class SysVServiceManager(ServiceManager):
    id = 'sysv'
    name = 'System V'

    @classmethod
    def __verify__(cls):
        return os.path.exists(INIT_D)

    def __init__(self, context):
        pass

    def list(self):
        for _id in os.listdir(INIT_D):
            path = os.path.join(INIT_D, _id)
            if _id.startswith('.'):
                continue
            if _id.startswith('rc'):
github ajenti / ajenti / plugins / services / managers / sysv_manager.py View on Github external
import os
import subprocess

from jadi import component
from aj.plugins.services.api import ServiceManager, Service


INIT_D = '/etc/init.d'
UPSTART_PATTERN = '/etc/init/%s.conf'


@component(ServiceManager)
class SysVServiceManager(ServiceManager):
    id = 'sysv'
    name = 'System V'

    @classmethod
    def __verify__(cls):
        return os.path.exists(INIT_D)

    def __init__(self, context):
        pass

    def list(self):
        for _id in os.listdir(INIT_D):
            path = os.path.join(INIT_D, _id)
            if _id.startswith('.'):
                continue
github ajenti / ajenti / plugins / services / managers / upstart_manager.py View on Github external
from dbus.exceptions import DBusException
from upstart.system import UpstartSystem, DirectUpstartBus
from upstart.job import UpstartJob

from jadi import component
from aj.plugins.services.api import ServiceManager, Service, ServiceOperationError


@component(ServiceManager)
class UpstartServiceManager(ServiceManager):
    id = 'upstart'
    name = 'Upstart'

    @classmethod
    def __verify__(cls):
        try:
            UpstartSystem()
            return True
        except:
            try:
                UpstartSystem(bus=DirectUpstartBus())
                return True
            except:
                return False

    def __init__(self, context):