コード例 #1
0
ファイル: system.py プロジェクト: linuxmap/StorLever
def put_service(request):
    service_name = request.matchdict["service_name"]
    cmd = get_params_from_request(request, service_mod_schema)

    service_mgr = servicemgr.service_mgr()  # get service manager
    service = service_mgr.get_service_by_name(service_name)

    if "state" in cmd:
        if cmd["state"]:
            service.start(request.client_addr)
        else:
            service.stop(request.client_addr)
    elif "restart" in cmd:
        if cmd["restart"]:
            service.restart(request.client_addr)
    elif "reload" in cmd:
        if cmd["restart"]:
            service.reload(request.client_addr)

    if "auto_start" in cmd:
        if cmd["auto_start"]:
            service.enable_auto_start(request.client_addr)
        else:
            service.disable_auto_start(request.client_addr)

    return Response(status=200)
コード例 #2
0
ファイル: system.py プロジェクト: OpenSight/StorLever
def put_service(request):
    service_name = request.matchdict["service_name"]
    cmd = get_params_from_request(request, service_mod_schema)

    service_mgr = servicemgr.service_mgr()      # get service manager
    service = service_mgr.get_service_by_name(service_name)

    if "state" in cmd:
        if cmd["state"]:
            service.start(request.client_addr)
        else:
            service.stop(request.client_addr)
    elif "restart" in cmd:
        if cmd["restart"]:
            service.restart(request.client_addr)
    elif "reload" in cmd:
        if cmd["restart"]:
            service.reload(request.client_addr)

    if "auto_start" in cmd:
        if cmd["auto_start"]:
            service.enable_auto_start(request.client_addr)
        else:
            service.disable_auto_start(request.client_addr)

    return Response(status=200)
コード例 #3
0
ファイル: test_servicemgr.py プロジェクト: linuxmap/StorLever
    def test_service_list(self):
        manager = service_mgr()
        service_list = manager.service_list()
        hasSshd = False
        for ser in service_list:
            if "sshd" in ser["name"]:
                hasSshd = True

        self.assertEquals(True, hasSshd)
コード例 #4
0
ファイル: test_servicemgr.py プロジェクト: dulton/StorLever
    def test_service_list(self):
        manager = service_mgr()
        service_list = manager.service_list()
        hasSshd = False
        for ser in service_list:
            if "sshd" in ser["name"]:
                hasSshd = True

        self.assertEquals(True, hasSshd)
コード例 #5
0
ファイル: system.py プロジェクト: OpenSight/StorLever
def get_service_info(request):
    service_name = request.matchdict["service_name"]
    service_mgr = servicemgr.service_mgr()      # get service manager
    service = service_mgr.get_service_by_name(service_name)

    service_dict = {
        "name": service_name,
        "comment": service.comment,
        "state": service.get_state(),
        "auto_start": service.get_auto_start()
    }

    return service_dict
コード例 #6
0
ファイル: system.py プロジェクト: linuxmap/StorLever
def get_service_info(request):
    service_name = request.matchdict["service_name"]
    service_mgr = servicemgr.service_mgr()  # get service manager
    service = service_mgr.get_service_by_name(service_name)

    service_dict = {
        "name": service_name,
        "comment": service.comment,
        "state": service.get_state(),
        "auto_start": service.get_auto_start()
    }

    return service_dict
コード例 #7
0
ファイル: test_servicemgr.py プロジェクト: dulton/StorLever
 def test_service_op(self):
     manager = service_mgr()
     ser = manager.get_service_by_name("sshd")
     org_state = ser.get_state()
     org_auto_start = ser.get_auto_start()
     ser.start()
     ser.enable_auto_start()
     self.assertEquals(True, ser.get_state())
     self.assertEquals(True, ser.get_auto_start())
     service_list = manager.service_list()
     for entry in service_list:
         if "sshd" == entry["name"]:
             self.assertEquals(True, entry["state"])
             self.assertEquals(True, entry["auto_start"])
     ser.stop()
     ser.disable_auto_start()
     self.assertEquals(False, ser.get_state())
     self.assertEquals(False, ser.get_auto_start())
     if org_state:
         ser.start()
     if org_auto_start:
         ser.enable_auto_start()
コード例 #8
0
ファイル: test_servicemgr.py プロジェクト: linuxmap/StorLever
 def test_service_op(self):
     manager = service_mgr()
     ser = manager.get_service_by_name("sshd")
     org_state = ser.get_state()
     org_auto_start = ser.get_auto_start()
     ser.start()
     ser.enable_auto_start()
     self.assertEquals(True, ser.get_state())
     self.assertEquals(True, ser.get_auto_start())
     service_list = manager.service_list()
     for entry in service_list:
         if "sshd" == entry["name"]:
             self.assertEquals(True, entry["state"])
             self.assertEquals(True, entry["auto_start"])
     ser.stop()
     ser.disable_auto_start()
     self.assertEquals(False, ser.get_state())
     self.assertEquals(False, ser.get_auto_start())
     if org_state:
         ser.start()
     if org_auto_start:
         ser.enable_auto_start()
コード例 #9
0
            portal, sep, tag = line_list[0].partition(",")
            result.append({"portal": portal, "target": target})

        return result

    def system_restore_cb(self):
        check_output(
            "rm -rf " + os.path.join(ISCSI_INITIATOR_DB_PATH, "nodes/*"), True)
        check_output(
            "rm -rf " + os.path.join(ISCSI_INITIATOR_DB_PATH, "ifaces/*"),
            True)


IscsiInitiatorManager = IscsiInitiatorManager()

# register ftp manager callback functions to basic manager
cfg_mgr().register_system_restore_cb(IscsiInitiatorManager.system_restore_cb)
cfg_mgr().register_config_file(os.path.join(ISCSI_INITIATOR_DB_PATH,
                                            "ifaces/"))
cfg_mgr().register_config_file(os.path.join(ISCSI_INITIATOR_DB_PATH, "nodes/"))
service_mgr().register_service("iscsid", "iscsid", "iscsid",
                               "iSCSI Initiator daemon")
service_mgr().register_service("iscsi", "iscsi", "",
                               "iSCSI Initiator login Script")
ModuleManager.register_module(**MODULE_INFO)


def iscsi_initiator_mgr():
    """return the global block manager instance"""
    return IscsiInitiatorManager
コード例 #10
0
ファイル: zabbixagent.py プロジェクト: linuxmap/StorLever
            zabbix_agent_conf = self._load_conf()
            zabbix_agent_conf["active_check_server_list"] = servers
            # check config conflict
            zabbix_agent_conf = self.zabbix_agentd_conf_schema.validate(
                zabbix_agent_conf)

            # save new conf
            self._save_conf(zabbix_agent_conf)
            self._sync_to_system_conf(zabbix_agent_conf)

        logger.log(
            logging.INFO, logger.LOG_TYPE_CONFIG,
            "Zabbix agent active server list is updated by operator(%s)" %
            (operator))


ZabbixAgentManager = ZabbixAgentManager()

# register ftp manager callback functions to basic manager
cfg_mgr().register_restore_from_file_cb(ZabbixAgentManager.sync_to_system_conf)
cfg_mgr().register_system_restore_cb(ZabbixAgentManager.system_restore_cb)
service_mgr().register_service("zabbix-agent", "zabbix-agent",
                               "/usr/sbin/zabbix_agentd",
                               "zabbix agent for system/network monitor")
ModuleManager.register_module(**MODULE_INFO)


def zabbix_agent_mgr():
    """return the global user manager instance"""
    return ZabbixAgentManager
コード例 #11
0
ファイル: zabbixagent.py プロジェクト: OpenSight/StorLever
    def set_active_check_server_list(self, servers=[], operator="unkown",
                                     *args, **kwargs):
        with self.lock:
            zabbix_agent_conf = self._load_conf()
            zabbix_agent_conf["active_check_server_list"] = servers
            # check config conflict
            zabbix_agent_conf = self.zabbix_agentd_conf_schema.validate(zabbix_agent_conf)

            # save new conf
            self._save_conf(zabbix_agent_conf)
            self._sync_to_system_conf(zabbix_agent_conf)

        logger.log(logging.INFO, logger.LOG_TYPE_CONFIG,
                   "Zabbix agent active server list is updated by operator(%s)" %
                   (operator))

ZabbixAgentManager = ZabbixAgentManager()

# register ftp manager callback functions to basic manager
cfg_mgr().register_restore_from_file_cb(ZabbixAgentManager.sync_to_system_conf)
cfg_mgr().register_system_restore_cb(ZabbixAgentManager.system_restore_cb)
service_mgr().register_service("zabbix-agent", "zabbix-agent", "/usr/sbin/zabbix_agentd",
                               "zabbix agent for system/network monitor")
ModuleManager.register_module(**MODULE_INFO)

def zabbix_agent_mgr():
    """return the global user manager instance"""
    return ZabbixAgentManager

コード例 #12
0
ファイル: smbmgr.py プロジェクト: linuxmap/StorLever
        p = subprocess.Popen([PDBEDIT_CMD, '-at', '-u', username],
                             stdin=subprocess.PIPE,
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE)
        p.communicate('%s\n%s\n\n' % (password, password))
        if p.returncode != 0:
            raise StorLeverError("failed to add user(%s)" % (username), 400)

        logger.log(
            logging.INFO, logger.LOG_TYPE_CONFIG,
            "Samba user (%s) password is updated operator(%s)" %
            (username, operator))


SmbManager = SmbManager()

# register ftp manager callback functions to basic manager
cfg_mgr().register_restore_from_file_cb(SmbManager.sync_to_system_conf)
cfg_mgr().register_system_restore_cb(SmbManager.system_restore_cb)
service_mgr().register_service("smb", "smb", "smbd", "Samba Server")
service_mgr().register_service("nmb", "nmb", "smbd", "Netbios Name Server")
ModuleManager.register_module(**MODULE_INFO)

# disable selinux impact
set_selinux_permissive()


def smb_mgr():
    """return the global user manager instance"""
    return SmbManager
コード例 #13
0
ファイル: snmpagent.py プロジェクト: OpenSight/StorLever
                raise StorLeverError("Monitor (%s) Not Found" % (monitor_name), 404)

            if expression is not None:
                monitor_conf["expression"] = expression
            if option is not None:
                monitor_conf["option"] = option

            monitor_list[update_monitor_index] = \
                self.monitor_conf_schema.validate(monitor_conf)

            # save new conf
            self._save_conf(snmp_conf)
            self._sync_to_system_conf(snmp_conf)

        logger.log(logging.INFO, logger.LOG_TYPE_CONFIG,
                   "SNMP Monitor (%s) config is updated by operator(%s)" %
                   (monitor_name, operator))

SnmpAgentManager = SnmpAgentManager()

# register ftp manager callback functions to basic manager
cfg_mgr().register_restore_from_file_cb(SnmpAgentManager.sync_to_system_conf)
cfg_mgr().register_system_restore_cb(SnmpAgentManager.system_restore_cb)
service_mgr().register_service("snmpd", "snmpd", "/usr/sbin/snmpd", "SNMP Agent(NET-SNMP)")


def snmp_agent_mgr():
    """return the global user manager instance"""
    return SnmpAgentManager

コード例 #14
0
ファイル: smartdmgr.py プロジェクト: linuxmap/StorLever
                if monitor_conf["mail_exec"] != "" and not os.path.exists(
                        monitor_conf["mail_exec"]):
                    raise StorLeverError(
                        "mail_exec (%s) not found" %
                        (monitor_conf["mail_exec"]), 404)

            # save new conf
            self._save_conf(smartd_conf)
            self._sync_to_system_conf(smartd_conf)

        logger.log(
            logging.INFO, logger.LOG_TYPE_CONFIG,
            "Smartd monitor list is updated by operator(%s)" % (operator))


SmartdManager = SmartdManager()

# register ftp manager callback functions to basic manager
cfg_mgr().register_restore_from_file_cb(SmartdManager.sync_to_system_conf)
cfg_mgr().register_system_restore_cb(SmartdManager.system_restore_cb)
service_mgr().register_service(
    "smartd", "smartd", "/usr/sbin/smartd",
    "Monitor the hard drives which support SMART technology")
ModuleManager.register_module(**MODULE_INFO)


def smartd_mgr():
    """return the global user manager instance"""
    return SmartdManager
コード例 #15
0
ファイル: nfsmgr.py プロジェクト: linuxmap/StorLever
            # save new conf
            self._save_conf(nfs_conf)
            self._sync_to_system_conf(nfs_conf)

        logger.log(logging.INFO, logger.LOG_TYPE_CONFIG,
                   "NFS export (name:%s) config is updated by operator(%s)" %
                   (name, operator))


NfsManager = NfsManager()

# register ftp manager callback functions to basic manager
cfg_mgr().register_restore_from_file_cb(NfsManager.sync_to_system_conf)
cfg_mgr().register_system_restore_cb(NfsManager.system_restore_cb)
service_mgr().register_service("nfs", "nfs", "nfsd", "NFS Server")
service_mgr().register_service("rpcbind", "rpcbind", "rpcbind", "Universal addresses to RPC program number mapper")
service_mgr().register_service("nfslock", "nfslock", "rpc.statd", "NFS file locking service")
ModuleManager.register_module(**MODULE_INFO)

# disable selinux impact
set_selinux_permissive()

def nfs_mgr():
    """return the global user manager instance"""
    return NfsManager




コード例 #16
0
ファイル: system.py プロジェクト: OpenSight/StorLever
def get_service_list(request):
    service_mgr = servicemgr.service_mgr()      # get service manager
    return service_mgr.service_list()
コード例 #17
0
            if expression is not None:
                monitor_conf["expression"] = expression
            if option is not None:
                monitor_conf["option"] = option

            monitor_list[update_monitor_index] = \
                self.monitor_conf_schema.validate(monitor_conf)

            # save new conf
            self._save_conf(snmp_conf)
            self._sync_to_system_conf(snmp_conf)

        logger.log(
            logging.INFO, logger.LOG_TYPE_CONFIG,
            "SNMP Monitor (%s) config is updated by operator(%s)" %
            (monitor_name, operator))


SnmpAgentManager = SnmpAgentManager()

# register ftp manager callback functions to basic manager
cfg_mgr().register_restore_from_file_cb(SnmpAgentManager.sync_to_system_conf)
cfg_mgr().register_system_restore_cb(SnmpAgentManager.system_restore_cb)
service_mgr().register_service("snmpd", "snmpd", "/usr/sbin/snmpd",
                               "SNMP Agent(NET-SNMP)")


def snmp_agent_mgr():
    """return the global user manager instance"""
    return SnmpAgentManager
コード例 #18
0
ファイル: smartdmgr.py プロジェクト: OpenSight/StorLever
                    raise StorLeverError("Device (%s) not found" % (monitor_conf["dev"]), 404)
                else:
                    mode = os.stat(monitor_conf["dev"])[ST_MODE]
                    if not S_ISBLK(mode):
                        raise StorLeverError("Device (%s) not block device" % (monitor_conf["dev"]), 400)

                if monitor_conf["mail_exec"] != "" and not os.path.exists(monitor_conf["mail_exec"]):
                    raise StorLeverError("mail_exec (%s) not found" % (monitor_conf["mail_exec"]), 404)

            # save new conf
            self._save_conf(smartd_conf)
            self._sync_to_system_conf(smartd_conf)

        logger.log(logging.INFO, logger.LOG_TYPE_CONFIG,
                   "Smartd monitor list is updated by operator(%s)" %
                   (operator))

SmartdManager = SmartdManager()

# register ftp manager callback functions to basic manager
cfg_mgr().register_restore_from_file_cb(SmartdManager.sync_to_system_conf)
cfg_mgr().register_system_restore_cb(SmartdManager.system_restore_cb)
service_mgr().register_service("smartd", "smartd", "/usr/sbin/smartd",
                               "Monitor the hard drives which support SMART technology")
ModuleManager.register_module(**MODULE_INFO)

def smartd_mgr():
    """return the global user manager instance"""
    return SmartdManager

コード例 #19
0
ファイル: httpmgr.py プロジェクト: OpenSight/StorLever
"""
storlever.mngr.utils.httpmgr
~~~~~~~~~~~~~~~~

This module implements ntp server management.

:copyright: (c) 2014 by OpenSight (www.opensight.cn).
:license: AGPLv3, see LICENSE for more details.

"""

from storlever.mngr.system.servicemgr import service_mgr
from storlever.mngr.system.modulemgr import ModuleManager

MODULE_INFO = {
    "module_name": "http",
    "rpms": [
        "httpd"
    ],
    "comment": "Provides some simple support for the http server"
}


service_mgr().register_service("http", "httpd", "/usr/sbin/httpd", "HTTP Server(apache httpd)")
ModuleManager.register_module(**MODULE_INFO)



コード例 #20
0
"""
storlever.mngr.utils.httpmgr
~~~~~~~~~~~~~~~~

This module implements ntp server management.

:copyright: (c) 2014 by OpenSight (www.opensight.cn).
:license: AGPLv3, see LICENSE for more details.

"""

from storlever.mngr.system.servicemgr import service_mgr
from storlever.mngr.system.modulemgr import ModuleManager

MODULE_INFO = {
    "module_name": "http",
    "rpms": ["httpd"],
    "comment": "Provides some simple support for the http server"
}

service_mgr().register_service("http", "httpd", "/usr/sbin/httpd",
                               "HTTP Server(apache httpd)")
ModuleManager.register_module(**MODULE_INFO)
コード例 #21
0
            except Exception:
                when = 0

            connections.append({
                "state": l[0],
                "remote": s[0],
                "refid": s[1],
                "stratum": int(s[2]),
                "type": s[3],
                "when": when,
                "poll": int(s[5]),
                "reach": int(s[6], 8),
                "delay": float(s[7]),
                "offset": float(s[8]),
                "jitter": float(s[9])
            })
        return connections

NtpManager = NtpManager()

# register ftp manager callback functions to basic manager
cfg_mgr().register_restore_from_file_cb(NtpManager.sync_to_system_conf)
cfg_mgr().register_system_restore_cb(NtpManager.system_restore_cb)
service_mgr().register_service("ntp", "ntpd", "ntpd", "NTP Server(ntpd)")
ModuleManager.register_module(**MODULE_INFO)

def ntp_mgr():
    """return the global user manager instance"""
    return NtpManager

コード例 #22
0
ファイル: system.py プロジェクト: linuxmap/StorLever
def get_service_list(request):
    service_mgr = servicemgr.service_mgr()  # get service manager
    return service_mgr.service_list()
コード例 #23
0
ファイル: ftpmgr.py プロジェクト: linuxmap/StorLever
                user_conf["chroot_enable"] = chroot_enable

            # save new conf
            self._save_conf(ftp_conf)
            self._sync_to_system_conf(ftp_conf)

        logger.log(logging.INFO, logger.LOG_TYPE_CONFIG,
                   "ftp user (%s) config is updated by operator(%s)" %
                   (user_name, operator))

FtpManager = FtpManager()

# register ftp manager callback functions to basic manager
cfg_mgr().register_restore_from_file_cb(FtpManager.sync_to_system_conf)
cfg_mgr().register_system_restore_cb(FtpManager.system_restore_cb)
service_mgr().register_service("ftpd", "vsftpd", "/sbin/vsftpd", "FTP Server(vsftpd)")
ModuleManager.register_module(**MODULE_INFO)

# disable selinux impact
set_selinux_permissive()

def ftp_mgr():
    """return the global user manager instance"""
    return FtpManager






コード例 #24
0
ファイル: tgtmgr.py プロジェクト: OpenSight/StorLever
            self._sync_to_system_conf(tgt_conf)

        try:
            check_output([TGTADMIN_CMD, "-f", "--delete", iqn])
        except StorLeverError:
            pass

        logger.log(logging.INFO, logger.LOG_TYPE_CONFIG,
                   "tgt target (iqn:%s) is deleted by operator(%s)" %
                   (iqn, operator))

TgtManager = TgtManager()

# register ftp manager callback functions to basic manager
cfg_mgr().register_restore_from_file_cb(TgtManager.sync_to_system_conf)
cfg_mgr().register_system_restore_cb(TgtManager.system_restore_cb)
service_mgr().register_service("tgt", "tgtd", "tgtd", "iSCSI Target Server")
ModuleManager.register_module(**MODULE_INFO)

def tgt_mgr():
    """return the global user manager instance"""
    return TgtManager








コード例 #25
0
ファイル: initiatormgr.py プロジェクト: OpenSight/StorLever
            line_list = line.split()
            target = line_list[1]
            portal, sep, tag = line_list[0].partition(",")
            result.append({
                "portal": portal,
                "target": target
            })

        return result

    def system_restore_cb(self):
        check_output("rm -rf " + os.path.join(ISCSI_INITIATOR_DB_PATH, "nodes/*"), True)
        check_output("rm -rf " + os.path.join(ISCSI_INITIATOR_DB_PATH, "ifaces/*"), True)


IscsiInitiatorManager = IscsiInitiatorManager()

# register ftp manager callback functions to basic manager
cfg_mgr().register_system_restore_cb(IscsiInitiatorManager.system_restore_cb)
cfg_mgr().register_config_file(os.path.join(ISCSI_INITIATOR_DB_PATH, "ifaces/"))
cfg_mgr().register_config_file(os.path.join(ISCSI_INITIATOR_DB_PATH, "nodes/"))
service_mgr().register_service("iscsid", "iscsid", "iscsid", "iSCSI Initiator daemon")
service_mgr().register_service("iscsi", "iscsi", "", "iSCSI Initiator login Script")
ModuleManager.register_module(**MODULE_INFO)


def iscsi_initiator_mgr():
    """return the global block manager instance"""
    return IscsiInitiatorManager

コード例 #26
0
                                     404)
            else:
                tgt_conf["target_list"].remove(delete_conf)

            # save new conf
            self._save_conf(tgt_conf)
            self._sync_to_system_conf(tgt_conf)

        try:
            check_output([TGTADMIN_CMD, "-f", "--delete", iqn])
        except StorLeverError:
            pass

        logger.log(
            logging.INFO, logger.LOG_TYPE_CONFIG,
            "tgt target (iqn:%s) is deleted by operator(%s)" % (iqn, operator))


TgtManager = TgtManager()

# register ftp manager callback functions to basic manager
cfg_mgr().register_restore_from_file_cb(TgtManager.sync_to_system_conf)
cfg_mgr().register_system_restore_cb(TgtManager.system_restore_cb)
service_mgr().register_service("tgt", "tgtd", "tgtd", "iSCSI Target Server")
ModuleManager.register_module(**MODULE_INFO)


def tgt_mgr():
    """return the global user manager instance"""
    return TgtManager