Esempio n. 1
0
    def _GET(self, *param, **params):
        host_id = self.chk_hostby1(param)
        if host_id is None: return web.notfound()

        self.view.host_id = host_id

        config = ServiceConfigParam(SERVICE_XML_FILE)
        config.load_xml_config()
        service = config.findby1service(param[1])
        if not service:
            self.logger.debug("Get service status failed. Service not found.")
            return web.notfound("Service not found")

        sysv = SysVInit_RH(service['system_name'], service['system_command'])
        status = {
            "status": sysv.status(),
            "autostart": sysv.onboot(),
            "readonly": service["system_readonly"],
        }

        if self.__template__["media"] == 'json':
            self.view.status = json_dumps(status)
        else:
            self.view.status = status

        return True
Esempio n. 2
0
    def _GET(self, *param, **params):
        host_id = self.chk_hostby1(param)
        if host_id is None: return web.notfound()

        config = ServiceConfigParam(SERVICE_XML_FILE)
        config.load_xml_config()

        displays = []
        for service in config.get_services():
            sysv = SysVInit_RH(service['system_name'],
                               service['system_command'])
            display = {
                'name': service['system_name'],
                'readonly': service['system_readonly'],
                'display_name': service['display_name'],
                'description': service['display_description'],
                'status': sysv.status(),
                'autostart': sysv.onboot(),
            }

            displays.append(display)

            self.view.services = displays

        return True
Esempio n. 3
0
    def process(self):
        (opts, args) = getopts()
        chkopts(opts)
        self.up_progress(10)
        config = ServiceConfigParam(SERVICE_XML_FILE)
        config.load_xml_config()

        service = config.findby1service(opts.name)
        self.up_progress(10)
        sysv = SysVInit_RH(service['system_name'], service['system_command'])

        if sysv.restart(force=False) is False:
            raise KssCommandException(str(sysv.error_msg))

        self.up_progress(50)
        self.logger.info('Restarted service. - service=%s' % (opts.name))
        print >> sys.stdout, _('Restarted service. - service=%s') % (opts.name)

        return True
Esempio n. 4
0
    def _GET(self, *param, **params):
        host_id = self.chk_hostby1(param)
        if host_id is None: return web.notfound()

        config = ServiceConfigParam(SERVICE_XML_FILE)
        config.load_xml_config()

        service = config.findby1service(param[1])
        if not service:
            self.logger.debug("Get service info failed. Service not found.")
            return web.notfound("Service not found")

        sysv = SysVInit_RH(service['system_name'], service['system_command'])
        display = {
            'name' : service['system_name'],
            'display_name' : service['display_name'],
            'description' : service['display_description'],
            'status' : sysv.status(),
            'autostart' : sysv.onboot(),
            }
        self.view.service = display

        return True
Esempio n. 5
0
    def process(self):
        (opts, args) = getopts()
        chkopts(opts)
        self.up_progress(10)

        config = ServiceConfigParam(SERVICE_XML_FILE)
        config.load_xml_config()

        service = config.findby1service(opts.name)
        if service is None:
            raise KssCommandException(
                "Service not found in xml file. service=%s" % (opts.name))

        self.up_progress(10)
        sysv = SysVInit_RH(service['system_name'], service['system_command'])

        flag = None
        if opts.enable:
            flag = True
        if opts.disable:
            flag = False

        retval = sysv.onboot(flag)
        if not (retval is False) and not (retval is True):
            raise KssCommandException(str(sysv.error_msg))

        self.up_progress(50)
        if flag is True:
            message = 'Enable service. - service=%s' % (opts.name)
        else:
            message = 'Disable service. - service=%s' % (opts.name)

        self.logger.info(message)
        print >> sys.stdout, _(message)

        return True