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
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
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
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
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
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
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
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