Commit 38c5f0b9 authored by Devaev Maxim's avatar Devaev Maxim

Config options refactoring

parent 52b4069a
...@@ -95,11 +95,11 @@ class CommonInfo(service.FunctionObject) : ...@@ -95,11 +95,11 @@ class CommonInfo(service.FunctionObject) :
### Private ### ### Private ###
def lsbOption(self, option) : def lsbOption(self, option) :
proc_args = "%s %s" % (config.value(SERVICE_NAME, "lsb_release_prog_path"), option) proc_args = "%s %s" % (config.value(SERVICE_NAME, "lsb_release_bin"), option)
return ":".join(tools.process.execProcess(proc_args)[0].split(":")[1:]).strip() return ":".join(tools.process.execProcess(proc_args)[0].split(":")[1:]).strip()
def unameOption(self, option) : def unameOption(self, option) :
proc_args = "%s %s" % (config.value(SERVICE_NAME, "uname_prog_path"), option) proc_args = "%s %s" % (config.value(SERVICE_NAME, "uname_bin"), option)
return tools.process.execProcess(proc_args)[0].strip() return tools.process.execProcess(proc_args)[0].strip()
...@@ -120,7 +120,7 @@ class Service(service.Service) : ...@@ -120,7 +120,7 @@ class Service(service.Service) :
@classmethod @classmethod
def options(self) : def options(self) :
return [ return [
(SERVICE_NAME, "lsb_release_prog_path", "/usr/bin/lsb_release", str), (SERVICE_NAME, "lsb_release_bin", "/usr/bin/lsb_release", str),
(SERVICE_NAME, "uname_prog_path", "/bin/uname", str) (SERVICE_NAME, "uname_bin", "/bin/uname", str)
] ]
...@@ -37,7 +37,7 @@ class DateTime(service.FunctionObject) : ...@@ -37,7 +37,7 @@ class DateTime(service.FunctionObject) :
@service.functionMethod(SYSTEM_CLOCK_METHODS_NAMESPACE, in_signature="iiiiii", out_signature="i") @service.functionMethod(SYSTEM_CLOCK_METHODS_NAMESPACE, in_signature="iiiiii", out_signature="i")
def setUtcTime(self, month, monthday, hour, minute, year, second) : def setUtcTime(self, month, monthday, hour, minute, year, second) :
proc_args = "%s -u %02d%02d%02d%02d%04d.%02d" % ( config.value(SERVICE_NAME, "date_prog_path"), proc_args = "%s -u %02d%02d%02d%02d%04d.%02d" % ( config.value(SERVICE_NAME, "date_bin"),
month, monthday, hour, minute, year, second ) month, monthday, hour, minute, year, second )
return tools.process.execProcess(proc_args, False)[2] return tools.process.execProcess(proc_args, False)[2]
...@@ -50,35 +50,35 @@ class DateTime(service.FunctionObject) : ...@@ -50,35 +50,35 @@ class DateTime(service.FunctionObject) :
@service.functionMethod(ZONE_METHODS_NAMESPACE, in_signature="s") @service.functionMethod(ZONE_METHODS_NAMESPACE, in_signature="s")
def setTimeZone(self, zone) : def setTimeZone(self, zone) :
if not os.access(os.path.join(config.value(SERVICE_NAME, "zoneinfo_dir_path"), zone), os.F_OK) : if not os.access(os.path.join(config.value(SERVICE_NAME, "zoneinfo_dir"), zone), os.F_OK) :
raise InvalidTimeZone("Unknown time zone \"%s\"" % (zone)) raise InvalidTimeZone("Unknown time zone \"%s\"" % (zone))
os.remove(config.value(SERVICE_NAME, "localtime_file_path")) os.remove(config.value(SERVICE_NAME, "localtime_file"))
os.symlink(os.path.join(config.value(SERVICE_NAME, "zoneinfo_dir_path"), zone), os.symlink(os.path.join(config.value(SERVICE_NAME, "zoneinfo_dir"), zone),
config.value(SERVICE_NAME, "localtime_file_path")) config.value(SERVICE_NAME, "localtime_file"))
time_zone_editor = tools.editors.PlainEditor(spaces_list=[]) time_zone_editor = tools.editors.PlainEditor(spaces_list=[])
time_zone_editor.open(config.value(SERVICE_NAME, "clock_config_file_path"), time_zone_editor.open(config.value(SERVICE_NAME, "clock_conf"),
config.value(SERVICE_NAME, "sample_clock_config_file_path")) config.value(SERVICE_NAME, "clock_conf_sample"))
time_zone_editor.setValue("ZONE", zone) time_zone_editor.setValue("ZONE", zone)
time_zone_editor.save() time_zone_editor.save()
time_zone_editor.close() time_zone_editor.close()
@service.functionMethod(ZONE_METHODS_NAMESPACE, out_signature="s") @service.functionMethod(ZONE_METHODS_NAMESPACE, out_signature="s")
def timeZone(self) : def timeZone(self) :
if os.access(config.value(SERVICE_NAME, "clock_config_file_path"), os.F_OK) : if os.access(config.value(SERVICE_NAME, "clock_conf"), os.F_OK) :
time_zone_editor = tools.editors.PlainEditor(spaces_list=[]) time_zone_editor = tools.editors.PlainEditor(spaces_list=[])
time_zone_editor.open(config.value(SERVICE_NAME, "clock_config_file_path")) time_zone_editor.open(config.value(SERVICE_NAME, "clock_conf"))
zones_list = time_zone_editor.value("ZONE") zones_list = time_zone_editor.value("ZONE")
time_zone_editor.close() time_zone_editor.close()
if len(zones_list) > 0 : if len(zones_list) > 0 :
return os.path.normpath(zones_list[-1]) return os.path.normpath(zones_list[-1])
try : try :
zoneinfo_dir_path = os.path.normpath(os.readlink(config.value(SERVICE_NAME, "localtime_file_path"))) zoneinfo_dir_path = os.path.normpath(os.readlink(config.value(SERVICE_NAME, "localtime_file")))
except : except :
zoneinfo_cache_dict = {} zoneinfo_cache_dict = {}
for (root_dir_path, dirs_list, files_list) in os.walk(config.value(SERVICE_NAME, "zoneinfo_dir_path")) : for (root_dir_path, dirs_list, files_list) in os.walk(config.value(SERVICE_NAME, "zoneinfo_dir")) :
for files_list_item in files_list : for files_list_item in files_list :
zone_file_path = os.path.normpath(os.path.join(root_dir_path, files_list_item)) zone_file_path = os.path.normpath(os.path.join(root_dir_path, files_list_item))
zone_file = open(zone_file_path) zone_file = open(zone_file_path)
...@@ -87,7 +87,7 @@ class DateTime(service.FunctionObject) : ...@@ -87,7 +87,7 @@ class DateTime(service.FunctionObject) :
zone_file.close() zone_file.close()
except : pass except : pass
zone_file = open(config.value(SERVICE_NAME, "localtime_file_path")) zone_file = open(config.value(SERVICE_NAME, "localtime_file"))
zone_file_hash = hashlib.sha1(zone_file.read()).hexdigest() zone_file_hash = hashlib.sha1(zone_file.read()).hexdigest()
try : try :
zone_file.close() zone_file.close()
...@@ -95,14 +95,14 @@ class DateTime(service.FunctionObject) : ...@@ -95,14 +95,14 @@ class DateTime(service.FunctionObject) :
zoneinfo_dir_path = ( zoneinfo_cache_dict[zone_file_hash] if zoneinfo_cache_dict.has_key(zone_file_hash) else "" ) zoneinfo_dir_path = ( zoneinfo_cache_dict[zone_file_hash] if zoneinfo_cache_dict.has_key(zone_file_hash) else "" )
zoneinfo_dir_path_regexp_str = r"^%s/+(.*)" % (config.value(SERVICE_NAME, "zoneinfo_dir_path")) zoneinfo_dir_path_regexp_str = r"^%s/+(.*)" % (config.value(SERVICE_NAME, "zoneinfo_dir"))
return os.path.normpath(re.sub(zoneinfo_dir_path_regexp_str, r"\1", zoneinfo_dir_path)) return os.path.normpath(re.sub(zoneinfo_dir_path_regexp_str, r"\1", zoneinfo_dir_path))
### ###
@service.functionMethod(HARDWARE_CLOCK_METHODS_NAMESPACE, out_signature="i") @service.functionMethod(HARDWARE_CLOCK_METHODS_NAMESPACE, out_signature="i")
def syncWithSystem(self) : def syncWithSystem(self) :
return tools.process.execProcess("%s --systohc" % (config.value(SERVICE_NAME, "hwclock_prog_path")), False)[0] return tools.process.execProcess("%s --systohc" % (config.value(SERVICE_NAME, "hwclock_bin")), False)[0]
##### Public classes ##### ##### Public classes #####
...@@ -123,12 +123,12 @@ class Service(service.Service) : ...@@ -123,12 +123,12 @@ class Service(service.Service) :
@classmethod @classmethod
def options(self) : def options(self) :
return [ return [
(SERVICE_NAME, "date_prog_path", "/bin/date", str), (SERVICE_NAME, "date_bin", "/bin/date", str),
(SERVICE_NAME, "hwclock_prog_path", "/usr/sbin/hwclock", str), (SERVICE_NAME, "hwclock_bin", "/usr/sbin/hwclock", str),
(SERVICE_NAME, "localtime_file_path", "/etc/localtime", str), (SERVICE_NAME, "localtime_file", "/etc/localtime", str),
(SERVICE_NAME, "zoneinfo_dir_path", "/usr/share/zoneinfo", str), (SERVICE_NAME, "zoneinfo_dir", "/usr/share/zoneinfo", str),
(SERVICE_NAME, "clock_config_file_path", "/etc/sysconfig/clock", str), (SERVICE_NAME, "clock_conf", "/etc/sysconfig/clock", str),
(SERVICE_NAME, "sample_clock_config_file_path", os.path.join(const.FUNCTIONS_DATA_DIR, SERVICE_NAME, "clock"), str) (SERVICE_NAME, "clock_conf_sample", os.path.join(const.FUNCTIONS_DATA_DIR, SERVICE_NAME, "clock"), str)
] ]
...@@ -38,7 +38,7 @@ class Disk(service.FunctionObject) : ...@@ -38,7 +38,7 @@ class Disk(service.FunctionObject) :
@service.functionMethod(SMART_METHODS_NAMESPACE, out_signature="a(isiiiissss)") @service.functionMethod(SMART_METHODS_NAMESPACE, out_signature="a(isiiiissss)")
def attributes(self) : def attributes(self) :
proc_args = "%s -A %s" % (config.value(SERVICE_NAME, "smartctl_prog_path"), self.__device_file_path) proc_args = "%s -A %s" % (config.value(SERVICE_NAME, "smartctl_bin"), self.__device_file_path)
attrs_list = [] attrs_list = []
attrs_found_flag = False attrs_found_flag = False
...@@ -65,7 +65,7 @@ class Disk(service.FunctionObject) : ...@@ -65,7 +65,7 @@ class Disk(service.FunctionObject) :
@service.functionMethod(SMART_METHODS_NAMESPACE, out_signature="b") @service.functionMethod(SMART_METHODS_NAMESPACE, out_signature="b")
def health(self) : def health(self) :
proc_args = "%s -H %s" % (config.value(SERVICE_NAME, "smartctl_prog_path"), self.__device_file_path) proc_args = "%s -H %s" % (config.value(SERVICE_NAME, "smartctl_bin"), self.__device_file_path)
disk_health_flag = False disk_health_flag = False
health_found_flag = False health_found_flag = False
...@@ -135,14 +135,14 @@ class Service(service.Service) : ...@@ -135,14 +135,14 @@ class Service(service.Service) :
def options(self) : def options(self) :
return [ return [
(SERVICE_NAME, "disks_filter", "^[(sd)(hd)][a-z]+$", str), (SERVICE_NAME, "disks_filter", "^[(sd)(hd)][a-z]+$", str),
(SERVICE_NAME, "smartctl_prog_path", "/usr/sbin/smartctl", str) (SERVICE_NAME, "smartctl_bin", "/usr/sbin/smartctl", str)
] ]
### Private ### ### Private ###
def smartAvailable(self, device_file_path) : def smartAvailable(self, device_file_path) :
proc_args = "%s %s" % (config.value(SERVICE_NAME, "smartctl_prog_path"), device_file_path) proc_args = "%s %s" % (config.value(SERVICE_NAME, "smartctl_bin"), device_file_path)
return not bool(tools.process.execProcess(proc_args, False)[2]) return not bool(tools.process.execProcess(proc_args, False)[2])
### ###
......
...@@ -91,8 +91,8 @@ class SimpleDnsmasqConfig(service.FunctionObject) : ...@@ -91,8 +91,8 @@ class SimpleDnsmasqConfig(service.FunctionObject) :
static_host += ( ",%s" % (name) if len(name) != 0 else "" ) static_host += ( ",%s" % (name) if len(name) != 0 else "" )
dnsmasq_editor = tools.editors.PlainEditor(spaces_list = [], quotes_list = []) dnsmasq_editor = tools.editors.PlainEditor(spaces_list = [], quotes_list = [])
dnsmasq_editor.open(config.value(SERVICE_NAME, "dnsmasq_config_file_path"), dnsmasq_editor.open(config.value(SERVICE_NAME, "dnsmasq_conf"),
config.value(SERVICE_NAME, "sample_dnsmasq_config_file_path")) config.value(SERVICE_NAME, "dnsmasq_conf_sample"))
dnsmasq_editor.setValue("dhcp-host", dnsmasq_editor.value("dhcp_host") + [static_host]) dnsmasq_editor.setValue("dhcp-host", dnsmasq_editor.value("dhcp_host") + [static_host])
dnsmasq_editor.save() dnsmasq_editor.save()
dnsmasq_editor.close() dnsmasq_editor.close()
...@@ -145,15 +145,15 @@ class SimpleDnsmasqConfig(service.FunctionObject) : ...@@ -145,15 +145,15 @@ class SimpleDnsmasqConfig(service.FunctionObject) :
def setConfigValue(self, variable_name, values_list) : def setConfigValue(self, variable_name, values_list) :
dnsmasq_editor = tools.editors.PlainEditor(spaces_list = [], quotes_list = []) dnsmasq_editor = tools.editors.PlainEditor(spaces_list = [], quotes_list = [])
dnsmasq_editor.open(config.value(SERVICE_NAME, "dnsmasq_config_file_path"), dnsmasq_editor.open(config.value(SERVICE_NAME, "dnsmasq_conf"),
config.value(SERVICE_NAME, "sample_dnsmasq_config_file_path")) config.value(SERVICE_NAME, "dnsmasq_conf_sample"))
dnsmasq_editor.setValue(variable_name, values_list) dnsmasq_editor.setValue(variable_name, values_list)
dnsmasq_editor.save() dnsmasq_editor.save()
dnsmasq_editor.close() dnsmasq_editor.close()
def configValue(self, variable_name) : def configValue(self, variable_name) :
dnsmasq_editor = tools.editors.PlainEditor(spaces_list = [], quotes_list = []) dnsmasq_editor = tools.editors.PlainEditor(spaces_list = [], quotes_list = [])
dnsmasq_editor.open(config.value(SERVICE_NAME, "dnsmasq_config_file_path")) dnsmasq_editor.open(config.value(SERVICE_NAME, "dnsmasq_conf"))
values_list = dnsmasq_editor.value(variable_name) values_list = dnsmasq_editor.value(variable_name)
dnsmasq_editor.close() dnsmasq_editor.close()
return values_list return values_list
...@@ -177,8 +177,8 @@ class Service(service.Service) : ...@@ -177,8 +177,8 @@ class Service(service.Service) :
@classmethod @classmethod
def options(self) : def options(self) :
return [ return [
(SERVICE_NAME, "dnsmasq_config_file_path", "/etc/dnsmasq.conf", str), (SERVICE_NAME, "dnsmasq_conf", "/etc/dnsmasq.conf", str),
(SERVICE_NAME, "sample_dnsmasq_config_file_path", os.path.join(const.FUNCTIONS_DATA_DIR, SERVICE_NAME, "dnsmasq.conf"), str) (SERVICE_NAME, "dnsmasq_conf_sample", os.path.join(const.FUNCTIONS_DATA_DIR, SERVICE_NAME, "dnsmasq.conf"), str)
] ]
...@@ -54,7 +54,7 @@ class LocalGroup(service.FunctionObject) : ...@@ -54,7 +54,7 @@ class LocalGroup(service.FunctionObject) :
logger.verbose("{mod}: Request to change gid for local group \"%s\", new gid=%d" % (self.__group_name, gid)) logger.verbose("{mod}: Request to change gid for local group \"%s\", new gid=%d" % (self.__group_name, gid))
return tools.process.execProcess("%s -g %d %s" % ( config.value(SERVICE_NAME, "groupmod_prog_path"), return tools.process.execProcess("%s -g %d %s" % ( config.value(SERVICE_NAME, "groupmod_bin"),
gid, self.__group_name ), False)[2] gid, self.__group_name ), False)[2]
@service.functionMethod(LOCAL_GROUP_METHODS_NAMESPACE, out_signature="i") @service.functionMethod(LOCAL_GROUP_METHODS_NAMESPACE, out_signature="i")
...@@ -68,7 +68,7 @@ class LocalGroup(service.FunctionObject) : ...@@ -68,7 +68,7 @@ class LocalGroup(service.FunctionObject) :
user_name = validators.os.validUserName(user_name) user_name = validators.os.validUserName(user_name)
logger.verbose("{mod}: Request to add user \"%s\" to local group \"%s\"" % (user_name, self.__group_name)) logger.verbose("{mod}: Request to add user \"%s\" to local group \"%s\"" % (user_name, self.__group_name))
return tools.process.execProcess("%s -a -G %s %s" % ( config.value(SERVICE_NAME, "usermod_prog_path"), return tools.process.execProcess("%s -a -G %s %s" % ( config.value(SERVICE_NAME, "usermod_bin"),
self.__group_name, user_name ), False)[2] self.__group_name, user_name ), False)[2]
@service.functionMethod(LOCAL_GROUP_METHODS_NAMESPACE, in_signature="s", out_signature="i") @service.functionMethod(LOCAL_GROUP_METHODS_NAMESPACE, in_signature="s", out_signature="i")
...@@ -79,7 +79,7 @@ class LocalGroup(service.FunctionObject) : ...@@ -79,7 +79,7 @@ class LocalGroup(service.FunctionObject) :
users_list.remove(self.__group_name) users_list.remove(self.__group_name)
logger.verbose("{mod}: Request to remove user \"%s\" from local group \"%s\"" % (user_name, self.__group_name)) logger.verbose("{mod}: Request to remove user \"%s\" from local group \"%s\"" % (user_name, self.__group_name))
return tools.process.execProcess("%s -G %s %s" % ( config.value(SERVICE_NAME, "usermod_prog_path"), return tools.process.execProcess("%s -G %s %s" % ( config.value(SERVICE_NAME, "usermod_bin"),
",".join(users_list), user_name ), False)[2] ",".join(users_list), user_name ), False)[2]
@service.functionMethod(LOCAL_GROUP_METHODS_NAMESPACE, out_signature="as") @service.functionMethod(LOCAL_GROUP_METHODS_NAMESPACE, out_signature="as")
...@@ -98,14 +98,14 @@ class LocalGroups(service.FunctionObject) : ...@@ -98,14 +98,14 @@ class LocalGroups(service.FunctionObject) :
logger.verbose("{mod}: Request to add local group \"%s\" with gid=%s" % (group_name, gid_str)) logger.verbose("{mod}: Request to add local group \"%s\" with gid=%s" % (group_name, gid_str))
return tools.process.execProcess("%s %s %s" % (config.value(SERVICE_NAME, "groupadd_prog_path"), gid_arg, group_name)) return tools.process.execProcess("%s %s %s" % (config.value(SERVICE_NAME, "groupadd_bin"), gid_arg, group_name))
@service.functionMethod(LOCAL_GROUPS_METHODS_NAMESPACE, in_signature="s", out_signature="i") @service.functionMethod(LOCAL_GROUPS_METHODS_NAMESPACE, in_signature="s", out_signature="i")
def removeGroup(self, group_name) : def removeGroup(self, group_name) :
group_name = validators.os.validGroupName(group_name) group_name = validators.os.validGroupName(group_name)
logger.verbose("{mod}: Request to remove local group \"%s\"" % (group_name)) logger.verbose("{mod}: Request to remove local group \"%s\"" % (group_name))
return tools.process.execProcess("%s %s" % (config.value(SERVICE_NAME, "groupdel_prog_path"), group_name), False)[2] return tools.process.execProcess("%s %s" % (config.value(SERVICE_NAME, "groupdel_bin"), group_name), False)[2]
### ###
...@@ -137,7 +137,7 @@ class LocalGroups(service.FunctionObject) : ...@@ -137,7 +137,7 @@ class LocalGroups(service.FunctionObject) :
def loginDefsValue(self, variable_name) : def loginDefsValue(self, variable_name) :
editor = tools.editors.PlainEditor(delimiter = "", quotes_list = []) editor = tools.editors.PlainEditor(delimiter = "", quotes_list = [])
editor.open(config.value(SERVICE_NAME, "login_defs_config_file_path")) editor.open(config.value(SERVICE_NAME, "login_defs_conf"))
values_list = editor.value(variable_name) values_list = editor.value(variable_name)
editor.close() editor.close()
return ( int(values_list[-1]) if len(values_list) > 0 else -1 ) return ( int(values_list[-1]) if len(values_list) > 0 else -1 )
...@@ -173,13 +173,13 @@ class Service(service.Service, pyinotify.ThreadedNotifier) : ...@@ -173,13 +173,13 @@ class Service(service.Service, pyinotify.ThreadedNotifier) :
group_count += 1 group_count += 1
logger.verbose("{mod}: Added %d local groups" % (group_count)) logger.verbose("{mod}: Added %d local groups" % (group_count))
group_config_subdir_path = os.path.dirname(config.value(SERVICE_NAME, "group_config_file_path")) group_config_subdir_path = os.path.dirname(config.value(SERVICE_NAME, "group_conf"))
self.__watch_manager.add_watch(group_config_subdir_path, pyinotify.IN_DELETE|pyinotify.IN_CREATE|pyinotify.IN_MOVED_TO, rec=True) self.__watch_manager.add_watch(group_config_subdir_path, pyinotify.IN_DELETE|pyinotify.IN_CREATE|pyinotify.IN_MOVED_TO, rec=True)
self.start() self.start()
logger.verbose("{mod}: Start polling inotify events for \"%s\"" % (group_config_subdir_path)) logger.verbose("{mod}: Start polling inotify events for \"%s\"" % (group_config_subdir_path))
def closeService(self) : def closeService(self) :
group_config_subdir_path = os.path.dirname(config.value(SERVICE_NAME, "group_config_file_path")) group_config_subdir_path = os.path.dirname(config.value(SERVICE_NAME, "group_conf"))
self.__watch_manager.rm_watch(self.__watch_manager.get_wd(group_config_subdir_path)) self.__watch_manager.rm_watch(self.__watch_manager.get_wd(group_config_subdir_path))
self.stop() self.stop()
logger.verbose("{mod}: Stop polling inotify events for \"%s\"" % (group_config_subdir_path)) logger.verbose("{mod}: Stop polling inotify events for \"%s\"" % (group_config_subdir_path))
...@@ -193,20 +193,20 @@ class Service(service.Service, pyinotify.ThreadedNotifier) : ...@@ -193,20 +193,20 @@ class Service(service.Service, pyinotify.ThreadedNotifier) :
@classmethod @classmethod
def options(self) : def options(self) :
return [ return [
(SERVICE_NAME, "groupadd_prog_path", "/usr/sbin/groupadd", str), (SERVICE_NAME, "groupadd_bin", "/usr/sbin/groupadd", str),
(SERVICE_NAME, "groupdel_prog_path", "/usr/sbin/groupdel", str), (SERVICE_NAME, "groupdel_bin", "/usr/sbin/groupdel", str),
(SERVICE_NAME, "groupmod_prog_path", "/usr/sbin/groupmod", str), (SERVICE_NAME, "groupmod_bin", "/usr/sbin/groupmod", str),
(SERVICE_NAME, "usermod_prog_path", "/usr/sbin/usermod", str), (SERVICE_NAME, "usermod_bin", "/usr/sbin/usermod", str),
(SERVICE_NAME, "group_config_file_path", "/etc/group", str), (SERVICE_NAME, "group_conf", "/etc/group", str),
(SERVICE_NAME, "login_defs_config_file_path", "/etc/login.defs", str) (SERVICE_NAME, "login_defs_conf", "/etc/login.defs", str)
] ]
### Private ### ### Private ###
def inotifyEvent(self, event) : def inotifyEvent(self, event) :
if event.dir or not event.pathname in ( config.value(SERVICE_NAME, "group_config_file_path"), if event.dir or not event.pathname in ( config.value(SERVICE_NAME, "group_conf"),
config.value(SERVICE_NAME, "login_defs_config_file_path") ) : config.value(SERVICE_NAME, "login_defs_conf") ) :
return return
...@@ -235,7 +235,7 @@ class Service(service.Service, pyinotify.ThreadedNotifier) : ...@@ -235,7 +235,7 @@ class Service(service.Service, pyinotify.ThreadedNotifier) :
def localGroups(self) : def localGroups(self) :
group_name_regexp = re.compile(r"(^[a-z_][a-z0-9_-]*):") group_name_regexp = re.compile(r"(^[a-z_][a-z0-9_-]*):")
group_config_file = open(config.value(SERVICE_NAME, "group_config_file_path")) group_config_file = open(config.value(SERVICE_NAME, "group_conf"))
group_names_list = [] group_names_list = []
for group_record in group_config_file.read().split("\n") : for group_record in group_config_file.read().split("\n") :
......
...@@ -55,7 +55,7 @@ class LocalUser(service.FunctionObject) : ...@@ -55,7 +55,7 @@ class LocalUser(service.FunctionObject) :
logger.verbose("{mod}: Request to change uid for local user \"%s\", new uid=%d" % (self.__user_name, uid)) logger.verbose("{mod}: Request to change uid for local user \"%s\", new uid=%d" % (self.__user_name, uid))
return tools.process.execProcess("%s -u %d %s" % ( config.value(SERVICE_NAME, "usermod_prog_path"), return tools.process.execProcess("%s -u %d %s" % ( config.value(SERVICE_NAME, "usermod_bin"),
uid, self.__user_name ), False)[2] uid, self.__user_name ), False)[2]
@service.functionMethod(LOCAL_USER_METHODS_NAMESPACE, out_signature="i") @service.functionMethod(LOCAL_USER_METHODS_NAMESPACE, out_signature="i")
...@@ -71,7 +71,7 @@ class LocalUser(service.FunctionObject) : ...@@ -71,7 +71,7 @@ class LocalUser(service.FunctionObject) :
logger.verbose("{mod}: Request to change gid for local user \"%s\", new gid=%d" % (self.__user_name, gid)) logger.verbose("{mod}: Request to change gid for local user \"%s\", new gid=%d" % (self.__user_name, gid))
return tools.process.execProcess("%s -g %d %s" % ( config.value(SERVICE_NAME, "usermod_prog_path"), return tools.process.execProcess("%s -g %d %s" % ( config.value(SERVICE_NAME, "usermod_bin"),
gid, self.__user_name ), False)[2] gid, self.__user_name ), False)[2]
@service.functionMethod(LOCAL_USER_METHODS_NAMESPACE, out_signature="i") @service.functionMethod(LOCAL_USER_METHODS_NAMESPACE, out_signature="i")
...@@ -87,7 +87,7 @@ class LocalUser(service.FunctionObject) : ...@@ -87,7 +87,7 @@ class LocalUser(service.FunctionObject) :
logger.verbose("{mod}: Request to change home for local user \"%s\", new home=\"%s\"" % (self.__user_name, path)) logger.verbose("{mod}: Request to change home for local user \"%s\", new home=\"%s\"" % (self.__user_name, path))
return tools.process.execProcess("%s -d \'%s\' %s" % ( config.value(SERVICE_NAME, "usermod_prog_path"), return tools.process.execProcess("%s -d \'%s\' %s" % ( config.value(SERVICE_NAME, "usermod_bin"),
path, self.__user_name ), False)[2] path, self.__user_name ), False)[2]
@service.functionMethod(LOCAL_USER_METHODS_NAMESPACE, out_signature="s") @service.functionMethod(LOCAL_USER_METHODS_NAMESPACE, out_signature="s")
...@@ -101,7 +101,7 @@ class LocalUser(service.FunctionObject) : ...@@ -101,7 +101,7 @@ class LocalUser(service.FunctionObject) :
logger.verbose("{mod}: Request to change shell for local user \"%s\", new shell=\"%s\"" % (self.__user_name, path)) logger.verbose("{mod}: Request to change shell for local user \"%s\", new shell=\"%s\"" % (self.__user_name, path))
return tools.process.execProcess("%s -s \'%s\' %s" % ( config.value(SERVICE_NAME, "usermod_prog_path"), return tools.process.execProcess("%s -s \'%s\' %s" % ( config.value(SERVICE_NAME, "usermod_bin"),
path, self.__user_name ), False)[2] path, self.__user_name ), False)[2]
@service.functionMethod(LOCAL_USER_METHODS_NAMESPACE, out_signature="s") @service.functionMethod(LOCAL_USER_METHODS_NAMESPACE, out_signature="s")
...@@ -117,7 +117,7 @@ class LocalUser(service.FunctionObject) : ...@@ -117,7 +117,7 @@ class LocalUser(service.FunctionObject) :
logger.verbose("{mod}: Request to change comment for local user \"%s\", new comment=\"%s\"" % (self.__user_name, text)) logger.verbose("{mod}: Request to change comment for local user \"%s\", new comment=\"%s\"" % (self.__user_name, text))
return tools.process.execProcess("%s -c \'%s\' %s" % ( config.value(SERVICE_NAME, "usermod_prog_path"), return tools.process.execProcess("%s -c \'%s\' %s" % ( config.value(SERVICE_NAME, "usermod_bin"),
text, self.__user_name ), False)[2] text, self.__user_name ), False)[2]
@service.functionMethod(LOCAL_USER_METHODS_NAMESPACE, out_signature="s") @service.functionMethod(LOCAL_USER_METHODS_NAMESPACE, out_signature="s")
...@@ -132,7 +132,7 @@ class LocalUser(service.FunctionObject) : ...@@ -132,7 +132,7 @@ class LocalUser(service.FunctionObject) :
logger.verbose("{mod}: Request to %s local user \"%s\"" % (lock_str)) logger.verbose("{mod}: Request to %s local user \"%s\"" % (lock_str))
return tools.process.execProcess("%s %s %s" % ( config.value(SERVICE_NAME, "usermod_prog_path"), return tools.process.execProcess("%s %s %s" % ( config.value(SERVICE_NAME, "usermod_bin"),
lock_arg, self.__user_name ), False)[2] lock_arg, self.__user_name ), False)[2]
@service.functionMethod(LOCAL_USER_METHODS_NAMESPACE, out_signature="b") @service.functionMethod(LOCAL_USER_METHODS_NAMESPACE, out_signature="b")
...@@ -156,7 +156,7 @@ class LocalUsers(service.FunctionObject) : ...@@ -156,7 +156,7 @@ class LocalUsers(service.FunctionObject) :
logger.verbose("{mod}: Request to add local user \"%s\" with uid=%s and gid=%s" % (user_name, uid_str, gid_str)) logger.verbose("{mod}: Request to add local user \"%s\" with uid=%s and gid=%s" % (user_name, uid_str, gid_str))
return tools.process.execProcess("%s %s %s %s" % (config.value(SERVICE_NAME, "useradd_prog_path"), return tools.process.execProcess("%s %s %s %s" % (config.value(SERVICE_NAME, "useradd_bin"),
uid_arg, gid_arg, user_name)) uid_arg, gid_arg, user_name))
@service.functionMethod(LOCAL_USERS_METHODS_NAMESPACE, in_signature="sb", out_signature="i") @service.functionMethod(LOCAL_USERS_METHODS_NAMESPACE, in_signature="sb", out_signature="i")
...@@ -165,7 +165,7 @@ class LocalUsers(service.FunctionObject) : ...@@ -165,7 +165,7 @@ class LocalUsers(service.FunctionObject) :
(remove_data_arg, remove_data_str) = ( ("-r", " and its data") if remove_data_flag else ("", "") ) (remove_data_arg, remove_data_str) = ( ("-r", " and its data") if remove_data_flag else ("", "") )
logger.verbose("{mod}: Request to remove local user \"%s\"%s" % (user_name, remove_data_str)) logger.verbose("{mod}: Request to remove local user \"%s\"%s" % (user_name, remove_data_str))
return tools.process.execProcess("%s %s %s" % (config.value(SERVICE_NAME, "userdel_prog_path"), return tools.process.execProcess("%s %s %s" % (config.value(SERVICE_NAME, "userdel_bin"),
remove_data_arg, user_name), False)[2] remove_data_arg, user_name), False)[2]
### ###
...@@ -198,7 +198,7 @@ class LocalUsers(service.FunctionObject) : ...@@ -198,7 +198,7 @@ class LocalUsers(service.FunctionObject) :
def loginDefsValue(self, variable_name) : def loginDefsValue(self, variable_name) :
editor = tools.editors.PlainEditor(delimiter = "", quotes_list = []) editor = tools.editors.PlainEditor(delimiter = "", quotes_list = [])
editor.open(config.value(SERVICE_NAME, "login_defs_config_file_path")) editor.open(config.value(SERVICE_NAME, "login_defs_conf"))
values_list = editor.value(variable_name) values_list = editor.value(variable_name)
editor.close() editor.close()
return ( int(values_list[-1]) if len(values_list) > 0 else -1 ) return ( int(values_list[-1]) if len(values_list) > 0 else -1 )
...@@ -234,13 +234,13 @@ class Service(service.Service, pyinotify.ThreadedNotifier) : ...@@ -234,13 +234,13 @@ class Service(service.Service, pyinotify.ThreadedNotifier) :
user_count += 1 user_count += 1
logger.verbose("{mod}: Added %d local users" % (user_count)) logger.verbose("{mod}: Added %d local users" % (user_count))
passwd_config_subdir_path = os.path.dirname(config.value(SERVICE_NAME, "passwd_config_file_path")) passwd_config_subdir_path = os.path.dirname(config.value(SERVICE_NAME, "passwd_conf"))
self.__watch_manager.add_watch(passwd_config_subdir_path, pyinotify.IN_DELETE|pyinotify.IN_CREATE|pyinotify.IN_MOVED_TO, rec=True) self.__watch_manager.add_watch(passwd_config_subdir_path, pyinotify.IN_DELETE|pyinotify.IN_CREATE|pyinotify.IN_MOVED_TO, rec=True)
self.start() self.start()
logger.verbose("{mod}: Start polling inotify events for \"%s\"" % (passwd_config_subdir_path)) logger.verbose("{mod}: Start polling inotify events for \"%s\"" % (passwd_config_subdir_path))
def closeService(self) : def closeService(self) :
passwd_config_subdir_path = os.path.dirname(config.value(SERVICE_NAME, "passwd_config_file_path")) passwd_config_subdir_path = os.path.dirname(config.value(SERVICE_NAME, "passwd_conf"))
self.__watch_manager.rm_watch(self.__watch_manager.get_wd(passwd_config_subdir_path)) self.__watch_manager.rm_watch(self.__watch_manager.get_wd(passwd_config_subdir_path))
self.stop() self.stop()
logger.verbose("{mod}: Stop polling inotify events for \"%s\"" % (passwd_config_subdir_path)) logger.verbose("{mod}: Stop polling inotify events for \"%s\"" % (passwd_config_subdir_path))
...@@ -254,21 +254,20 @@ class Service(service.Service, pyinotify.ThreadedNotifier) : ...@@ -254,21 +254,20 @@ class Service(service.Service, pyinotify.ThreadedNotifier) :
@classmethod @classmethod
def options(self) : def options(self) :
return [ return [
(SERVICE_NAME, "useradd_prog_path", "/usr/sbin/useradd", str), (SERVICE_NAME, "useradd_bin", "/usr/sbin/useradd", str),
(SERVICE_NAME, "userdel_prog_path", "/usr/sbin/userdel", str), (SERVICE_NAME, "userdel_bin", "/usr/sbin/userdel", str),
(SERVICE_NAME, "usermod_prog_path", "/usr/sbin/usermod", str), (SERVICE_NAME, "usermod_bin", "/usr/sbin/usermod", str),
(SERVICE_NAME, "passwd_config_file_path", "/etc/passwd", str), (SERVICE_NAME, "passwd_conf", "/etc/passwd", str),
(SERVICE_NAME, "shadow_config_file_path", "/etc/shadow", str), (SERVICE_NAME, "shadow_conf", "/etc/shadow", str),
(SERVICE_NAME, "login_defs_config_file_path", "/etc/login.defs", str) (SERVICE_NAME, "login_defs_conf", "/etc/login.defs", str)
] ]
### Private ### ### Private ###
def inotifyEvent(self, event) : def inotifyEvent(self, event) :
if event.dir or not event.pathname in ( config.value(SERVICE_NAME, "passwd_config_file_path"), if event.dir or not event.pathname in ( config.value(SERVICE_NAME, "passwd_conf"),
config.value(SERVICE_NAME, "shadow_config_file_path"), config.value(SERVICE_NAME, "shadow_conf"), config.value(SERVICE_NAME, "login_defs_conf") ) :
config.value(SERVICE_NAME, "login_defs_config_file_path") ) :
return return
...@@ -297,7 +296,7 @@ class Service(service.Service, pyinotify.ThreadedNotifier) : ...@@ -297,7 +296,7 @@ class Service(service.Service, pyinotify.ThreadedNotifier) :
def localUsers(self) : def localUsers(self) :
user_name_regexp = re.compile(r"(^[a-z_][a-z0-9_-]*):") user_name_regexp = re.compile(r"(^[a-z_][a-z0-9_-]*):")
passwd_config_file = open(config.value(SERVICE_NAME, "passwd_config_file_path")) passwd_config_file = open(config.value(SERVICE_NAME, "passwd_conf"))
user_names_list = [] user_names_list = []
for passwd_record in passwd_config_file.read().split("\n") : for passwd_record in passwd_config_file.read().split("\n") :
......
...@@ -29,30 +29,30 @@ class Machine(service.FunctionObject) : ...@@ -29,30 +29,30 @@ class Machine(service.FunctionObject) :
@service.functionMethod(POWER_METHODS_NAMESPACE, out_signature="i") @service.functionMethod(POWER_METHODS_NAMESPACE, out_signature="i")
def shutdown(self) : def shutdown(self) :
return tools.process.execProcess("%s -h now" % (config.value(SERVICE_NAME, "shutdown_prog_path")), False)[2] return tools.process.execProcess("%s -h now" % (config.value(SERVICE_NAME, "shutdown_bin")), False)[2]
@service.functionMethod(POWER_METHODS_NAMESPACE, out_signature="i") @service.functionMethod(POWER_METHODS_NAMESPACE, out_signature="i")
def reboot(self) : def reboot(self) :
return tools.process.execProcess("%s -r now" % (config.value(SERVICE_NAME, "shutdown_prog_path")), False)[2] return tools.process.execProcess("%s -r now" % (config.value(SERVICE_NAME, "shutdown_bin")), False)[2]
@service.functionMethod(POWER_METHODS_NAMESPACE, out_signature="i") @service.functionMethod(POWER_METHODS_NAMESPACE, out_signature="i")
def suspend(self) : def suspend(self) :
return tools.process.execProcess(config.value(SERVICE_NAME, "pm_suspend_prog_path"), False)[2] return tools.process.execProcess(config.value(SERVICE_NAME, "pm_suspend_bin"), False)[2]
@service.functionMethod(POWER_METHODS_NAMESPACE, out_signature="i") @service.functionMethod(POWER_METHODS_NAMESPACE, out_signature="i")
def hibernate(self) : def hibernate(self) :
return tools.process.execProcess(config.value(SERVICE_NAME, "pm_hibernate_prog_path"), False)[2] return tools.process.execProcess(config.value(SERVICE_NAME, "pm_hibernate_bin"), False)[2]
### ###
@service.functionMethod(RUNLEVELS_METHODS_NAMESPACE, in_signature="i", out_signature="i") @service.functionMethod(RUNLEVELS_METHODS_NAMESPACE, in_signature="i", out_signature="i")
def switchTo(self, level) : def switchTo(self, level) :
proc_args = "%s %s" % (config.value(SERVICE_NAME, "telinit_prog_path"), validators.common.validRange(str(level), RUNLEVELS)) proc_args = "%s %s" % (config.value(SERVICE_NAME, "telinit_bin"), validators.common.validRange(str(level), RUNLEVELS))
return tools.process.execProcess(proc_args, False)[2] return tools.process.execProcess(proc_args, False)[2]
@service.functionMethod(RUNLEVELS_METHODS_NAMESPACE, out_signature="i") @service.functionMethod(RUNLEVELS_METHODS_NAMESPACE, out_signature="i")
def currentLevel(self) : def currentLevel(self) :
proc_args = config.value(SERVICE_NAME, "runlevel_prog_path") proc_args = config.value(SERVICE_NAME, "runlevel_bin")
level_pairs_list = tools.process.execProcess(proc_args)[0].strip().split(" ") level_pairs_list = tools.process.execProcess(proc_args)[0].strip().split(" ")
if len(level_pairs_list) != 2 or not level_pairs_list[1] in RUNLEVELS : if len(level_pairs_list) != 2 or not level_pairs_list[1] in RUNLEVELS :
...@@ -63,7 +63,7 @@ class Machine(service.FunctionObject) : ...@@ -63,7 +63,7 @@ class Machine(service.FunctionObject) :
@service.functionMethod(RUNLEVELS_METHODS_NAMESPACE, out_signature="i") @service.functionMethod(RUNLEVELS_METHODS_NAMESPACE, out_signature="i")
def previousLevel(self) : def previousLevel(self) :
proc_args = config.value(SERVICE_NAME, "runlevel_prog_path") proc_args = config.value(SERVICE_NAME, "runlevel_bin")
level_pairs_list = tools.process.execProcess(proc_args)[0].strip().split(" ") level_pairs_list = tools.process.execProcess(proc_args)[0].strip().split(" ")
if len(level_pairs_list) != 2 or not level_pairs_list[1] in RUNLEVELS+"N" : if len(level_pairs_list) != 2 or not level_pairs_list[1] in RUNLEVELS+"N" :
...@@ -90,10 +90,10 @@ class Service(service.Service) : ...@@ -90,10 +90,10 @@ class Service(service.Service) :
@classmethod @classmethod
def options(self) : def options(self) :
return [ return [
(SERVICE_NAME, "shutdown_prog_path", "/sbin/shutdown", str), (SERVICE_NAME, "shutdown_bin", "/sbin/shutdown", str),
(SERVICE_NAME, "pm_suspend_prog_path", "/usr/sbin/pm-suspend", str), (SERVICE_NAME, "pm_suspend_bin", "/usr/sbin/pm-suspend", str),
(SERVICE_NAME, "pm_hibernate_prog_path", "/usr/sbin/pm-hibernate", str), (SERVICE_NAME, "pm_hibernate_bin", "/usr/sbin/pm-hibernate", str),
(SERVICE_NAME, "telinit_prog_path", "/sbin/telinit", str), (SERVICE_NAME, "telinit_bin", "/sbin/telinit", str),
(SERVICE_NAME, "runlevel_prog_path", "/sbin/runlevel", str) (SERVICE_NAME, "runlevel_bin", "/sbin/runlevel", str)
] ]
...@@ -29,8 +29,7 @@ class NtpConfig(service.FunctionObject) : ...@@ -29,8 +29,7 @@ class NtpConfig(service.FunctionObject) :
@service.functionMethod(NTP_METHODS_NAMESPACE, in_signature="as") @service.functionMethod(NTP_METHODS_NAMESPACE, in_signature="as")
def setServers(self, servers_list) : def setServers(self, servers_list) :
ntp_editor = tools.editors.PlainEditor(delimiter = "", quotes_list = []) ntp_editor = tools.editors.PlainEditor(delimiter = "", quotes_list = [])
ntp_editor.open(config.value(SERVICE_NAME, "ntp_config_file_path"), ntp_editor.open(config.value(SERVICE_NAME, "ntp_conf"), config.value(SERVICE_NAME, "ntp_conf_sample"))
config.value(SERVICE_NAME, "sample_ntp_config_file_path"))
ntp_editor.setValue("server", servers_list) ntp_editor.setValue("server", servers_list)
ntp_editor.save() ntp_editor.save()
ntp_editor.close() ntp_editor.close()
...@@ -38,7 +37,7 @@ class NtpConfig(service.FunctionObject) : ...@@ -38,7 +37,7 @@ class NtpConfig(service.FunctionObject) :
@service.functionMethod(NTP_METHODS_NAMESPACE, out_signature="as") @service.functionMethod(NTP_METHODS_NAMESPACE, out_signature="as")
def servers(self) : def servers(self) :
ntp_editor = tools.editors.PlainEditor(delimiter = "", quotes_list = []) ntp_editor = tools.editors.PlainEditor(delimiter = "", quotes_list = [])
ntp_editor.open(config.value(SERVICE_NAME, "ntp_config_file_path")) ntp_editor.open(config.value(SERVICE_NAME, "ntp_conf"))
servers_list = ntp_editor.value("server") servers_list = ntp_editor.value("server")
ntp_editor.close() ntp_editor.close()
return servers_list return servers_list
...@@ -47,7 +46,7 @@ class NtpConfig(service.FunctionObject) : ...@@ -47,7 +46,7 @@ class NtpConfig(service.FunctionObject) :
@service.functionMethod(NTP_METHODS_NAMESPACE) @service.functionMethod(NTP_METHODS_NAMESPACE)
def request(self) : def request(self) :
proc_args = "%s %s" % (config.value(SERVICE_NAME, "ntpdate_prog_path"), " ".join(self.servers())) proc_args = "%s %s" % (config.value(SERVICE_NAME, "ntpdate_bin"), " ".join(self.servers()))
tools.process.execProcess(proc_args) tools.process.execProcess(proc_args)
...@@ -69,9 +68,9 @@ class Service(service.Service) : ...@@ -69,9 +68,9 @@ class Service(service.Service) :
@classmethod @classmethod
def options(self) : def options(self) :
return [ return [
(SERVICE_NAME, "ntpdate_prog_path", "/usr/sbin/ntpdate", str), (SERVICE_NAME, "ntpdate_bin", "/usr/sbin/ntpdate", str),
(SERVICE_NAME, "ntp_config_file_path", "/etc/ntp.conf", str), (SERVICE_NAME, "ntp_conf", "/etc/ntp.conf", str),
(SERVICE_NAME, "sample_ntp_config_file_path", os.path.join(const.FUNCTIONS_DATA_DIR, SERVICE_NAME, "ntp.conf"), str) (SERVICE_NAME, "ntp_conf_sample", os.path.join(const.FUNCTIONS_DATA_DIR, SERVICE_NAME, "ntp.conf"), str)
] ]
...@@ -164,15 +164,14 @@ class RTorrentd(service.FunctionObject) : ...@@ -164,15 +164,14 @@ class RTorrentd(service.FunctionObject) :
def setConfigValue(self, variable_name, values_list) : def setConfigValue(self, variable_name, values_list) :
rtorrentd_editor = tools.editors.PlainEditor(spaces_list = []) rtorrentd_editor = tools.editors.PlainEditor(spaces_list = [])
rtorrentd_editor.open(config.value(SERVICE_NAME, "rtorrentd_config_file_path"), rtorrentd_editor.open(config.value(SERVICE_NAME, "rtorrentd_conf"), config.value(SERVICE_NAME, "rtorrentd_conf_sample"))
config.value(SERVICE_NAME, "sample_rtorrentd_config_file_path"))
rtorrentd_editor.setValue(variable_name, values_list) rtorrentd_editor.setValue(variable_name, values_list)
rtorrentd_editor.save() rtorrentd_editor.save()
rtorrentd_editor.close() rtorrentd_editor.close()
def configValue(self, variable_name) : def configValue(self, variable_name) :
rtorrentd_editor = tools.editors.PlainEditor(spaces_list = []) rtorrentd_editor = tools.editors.PlainEditor(spaces_list = [])
rtorrentd_editor.open(config.value(SERVICE_NAME, "rtorrentd_config_file_path")) rtorrentd_editor.open(config.value(SERVICE_NAME, "rtorrentd_conf"))
values_list = rtorrentd_editor.value(variable_name) values_list = rtorrentd_editor.value(variable_name)
rtorrentd_editor.close() rtorrentd_editor.close()
return values_list return values_list
...@@ -196,8 +195,8 @@ class Service(service.Service) : ...@@ -196,8 +195,8 @@ class Service(service.Service) :
@classmethod @classmethod
def options(self) : def options(self) :
return [ return [
(SERVICE_NAME, "rtorrentd_config_file_path", "/etc/sysconfig/rtorrent", str), (SERVICE_NAME, "rtorrentd_conf", "/etc/sysconfig/rtorrent", str),
(SERVICE_NAME, "sample_rtorrentd_config_file_path", os.path.join(const.FUNCTIONS_DATA_DIR, SERVICE_NAME, "rtorrent"), str) (SERVICE_NAME, "rtorrentd_conf_sample", os.path.join(const.FUNCTIONS_DATA_DIR, SERVICE_NAME, "rtorrent"), str)
] ]
...@@ -55,7 +55,7 @@ class SystemService(service.FunctionObject) : ...@@ -55,7 +55,7 @@ class SystemService(service.FunctionObject) :
@service.functionMethod(SYSTEM_SERVICE_METHODS_NAMESPACE, out_signature="s") @service.functionMethod(SYSTEM_SERVICE_METHODS_NAMESPACE, out_signature="s")
def levelsMap(self) : def levelsMap(self) :
proc_args = "%s --list %s" % (config.value(SERVICE_NAME, "chkconfig_prog_path"), self.__system_service_name) proc_args = "%s --list %s" % (config.value(SERVICE_NAME, "chkconfig_bin"), self.__system_service_name)
(proc_stdout, proc_stderr, proc_returncode) = tools.process.execProcess(proc_args) (proc_stdout, proc_stderr, proc_returncode) = tools.process.execProcess(proc_args)
service_record_list = re.split(r"\s+", proc_stdout.split("\n")[0]) service_record_list = re.split(r"\s+", proc_stdout.split("\n")[0])
...@@ -81,18 +81,18 @@ class SystemService(service.FunctionObject) : ...@@ -81,18 +81,18 @@ class SystemService(service.FunctionObject) :
@service.functionMethod(SYSTEM_SERVICE_METHODS_NAMESPACE, out_signature="i") @service.functionMethod(SYSTEM_SERVICE_METHODS_NAMESPACE, out_signature="i")
def start(self) : def start(self) :
logger.verbose("{mod}: Request to start service \"%s\"" % (self.__system_service_name)) logger.verbose("{mod}: Request to start service \"%s\"" % (self.__system_service_name))
return tools.process.execProcess("%s start" % ( os.path.join(config.value(SERVICE_NAME, "initd_dir_path"), return tools.process.execProcess("%s start" % ( os.path.join(config.value(SERVICE_NAME, "initd_dir"),
self.__system_service_name) ), False)[2] self.__system_service_name) ), False)[2]
@service.functionMethod(SYSTEM_SERVICE_METHODS_NAMESPACE, out_signature="i") @service.functionMethod(SYSTEM_SERVICE_METHODS_NAMESPACE, out_signature="i")
def stop(self) : def stop(self) :
logger.verbose("{mod}: Request to stop service \"%s\"" % (self.__system_service_name)) logger.verbose("{mod}: Request to stop service \"%s\"" % (self.__system_service_name))
return tools.process.execProcess("%s stop" % ( os.path.join(config.value(SERVICE_NAME, "initd_dir_path"), return tools.process.execProcess("%s stop" % ( os.path.join(config.value(SERVICE_NAME, "initd_dir"),
self.__system_service_name) ), False)[2] self.__system_service_name) ), False)[2]
@service.functionMethod(SYSTEM_SERVICE_METHODS_NAMESPACE, out_signature="i") @service.functionMethod(SYSTEM_SERVICE_METHODS_NAMESPACE, out_signature="i")
def status(self) : def status(self) :
return tools.process.execProcess("%s status" % ( os.path.join(config.value(SERVICE_NAME, "initd_dir_path"), return tools.process.execProcess("%s status" % ( os.path.join(config.value(SERVICE_NAME, "initd_dir"),
self.__system_service_name) ), False)[2] self.__system_service_name) ), False)[2]
...@@ -104,7 +104,7 @@ class SystemService(service.FunctionObject) : ...@@ -104,7 +104,7 @@ class SystemService(service.FunctionObject) :
logger.verbose("Request to %s service \"%s\" on runlevels \"%s\"" % ( ( "enable" if enabled_flag else "disable" ), logger.verbose("Request to %s service \"%s\" on runlevels \"%s\"" % ( ( "enable" if enabled_flag else "disable" ),
self.__system_service_name, ( levels if levels != None else "default" ) )) self.__system_service_name, ( levels if levels != None else "default" ) ))
proc_args = "%s %s %s %s" % ( config.value(SERVICE_NAME, "chkconfig_prog_path"), proc_args = "%s %s %s %s" % ( config.value(SERVICE_NAME, "chkconfig_bin"),
( "--level %s" % (levels) if levels != None else "" ), ( "--level %s" % (levels) if levels != None else "" ),
self.__system_service_name, ( "on" if enabled_flag else "off" ) ) self.__system_service_name, ( "on" if enabled_flag else "off" ) )
return tools.process.execProcess(proc_args, False)[2] return tools.process.execProcess(proc_args, False)[2]
...@@ -151,7 +151,7 @@ class Service(service.Service, pyinotify.ThreadedNotifier) : ...@@ -151,7 +151,7 @@ class Service(service.Service, pyinotify.ThreadedNotifier) :
shared.Functions.addShared(SYSTEM_SERVICES_SHARED_NAME) shared.Functions.addShared(SYSTEM_SERVICES_SHARED_NAME)
shared.Functions.addSharedObject(SYSTEM_SERVICES_OBJECT_NAME, self.__system_services) shared.Functions.addSharedObject(SYSTEM_SERVICES_OBJECT_NAME, self.__system_services)
initd_dir_path = config.value(SERVICE_NAME, "initd_dir_path") initd_dir_path = config.value(SERVICE_NAME, "initd_dir")
logger.verbose("{mod}: First services requset...") logger.verbose("{mod}: First services requset...")
system_services_shared = shared.Functions.shared(SYSTEM_SERVICES_SHARED_NAME) system_services_shared = shared.Functions.shared(SYSTEM_SERVICES_SHARED_NAME)
...@@ -174,7 +174,7 @@ class Service(service.Service, pyinotify.ThreadedNotifier) : ...@@ -174,7 +174,7 @@ class Service(service.Service, pyinotify.ThreadedNotifier) :
logger.verbose("{mod}: Start polling inotify events for \"%s\"" % (initd_dir_path)) logger.verbose("{mod}: Start polling inotify events for \"%s\"" % (initd_dir_path))
def closeService(self) : def closeService(self) :
initd_dir_path = config.value(SERVICE_NAME, "initd_dir_path") initd_dir_path = config.value(SERVICE_NAME, "initd_dir")
self.__watch_manager.rm_watch(self.__watch_manager.get_wd(initd_dir_path)) self.__watch_manager.rm_watch(self.__watch_manager.get_wd(initd_dir_path))
self.stop() self.stop()
logger.verbose("{mod}: Stop polling inotify events for \"%s\"" % (initd_dir_path)) logger.verbose("{mod}: Stop polling inotify events for \"%s\"" % (initd_dir_path))
...@@ -188,8 +188,8 @@ class Service(service.Service, pyinotify.ThreadedNotifier) : ...@@ -188,8 +188,8 @@ class Service(service.Service, pyinotify.ThreadedNotifier) :
@classmethod @classmethod
def options(self) : def options(self) :
return [ return [
(SERVICE_NAME, "initd_dir_path", "/etc/rc.d/init.d", str), (SERVICE_NAME, "initd_dir", "/etc/rc.d/init.d", str),
(SERVICE_NAME, "chkconfig_prog_path", "/sbin/chkconfig", str) (SERVICE_NAME, "chkconfig_bin", "/sbin/chkconfig", str)
] ]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment