Example #1
0
def main():
    options, args = parse_args()

    if options.action == None:
        print "Miss action params"
        sys.exit(-1)

    if options.filename == None:
        print "Miss config file params"
        sys.exit(-1)

    filename = options.filename
    front = options.front
    action = options.action

    if not os.path.exists(filename):
        print "Config file '%s' not exists" % filename
        sys.exit(-1)

    init_config(filename)

    init_logger()

    # 检查kernel标记
    check_kernel_flag()

    module = config.safe_get("system", "module")

    pidfile = "/var/run/smartmgr-%s.pid" % module
    stdlog = "/var/log/smartmgr/.%s.stdlog" % module
    daemon = S2SFrameDaemon(pidfile=pidfile,
                            stdout=stdlog,
                            stderr=stdlog,
                            front=front)

    if 'start' == action:
        daemon.start()
    elif 'stop' == action:
        daemon.stop()
    elif 'restart' == action:
        daemon.restart()
    elif 'status' == action:
        if daemon.status():
            sys.exit(0)
        else:
            sys.exit(1)
    else:
        print 'Unknown command'
        sys.exit(2)
    sys.exit(0)
Example #2
0
def main():
    options, args = parse_args()

    if options.action == None:
        print "Miss action params"
        sys.exit(-1)

    if options.filename == None:
        print "Miss config file params"
        sys.exit(-1)

    filename = options.filename
    front    = options.front
    action   = options.action

    if not os.path.exists(filename):
        print "Config file '%s' not exists" % filename
        sys.exit(-1)

    init_config(filename)

    check_netconfig(config.safe_get('network', 'listen-ip'))

    pidfile = "/var/run/smartmgr-api.pid"
    stdlog  = os.path.join(config.safe_get('log', 'path'), "%s.log" % config.safe_get("model-config","api-log-prefix"))

    daemon  = APIDaemon(pidfile=pidfile, stdout=stdlog, stderr=stdlog, front=front)

    if 'start' == action:
        daemon.start()
    elif 'stop' == action:
        daemon.stop()
    elif 'restart' == action:
        daemon.restart()
    elif 'status' == action:
        if daemon.status():
            sys.exit(0)
        else:
            sys.exit(1)
    else:
       print 'Unknown command'
       sys.exit(2)
    sys.exit(0)
Example #3
0
# -*- coding: utf-8 -*
# vim: tabstop=4 shiftwidth=4 softtabstop=4

import sys, os
sys.path.append(os.path.abspath(os.path.join(__file__, '../')))
sys.path.append(os.path.abspath(os.path.join(__file__, '../../../')))
sys.path.append(os.path.abspath(os.path.join(__file__, '../../../message/')))
from pdsframe import *
from pdsframe.common.config import init_config, config
import message.pds_pb2 as msg_pds
import message.demo_1_pb2 as msg_demo_1

from utest.base import send

init_config('../../files/conf/test/service.demo_1.ini')

if __name__ == "__main__":
    request = MakeRequest(msg_demo_1.DEMO1_DROP_NAME_REQUEST)
    request.body.Extensions[
        msg_demo_1.
        demo1_drop_name_request].name = "d2adccfa-6e7f-11e6-8d38-525400047e15"

    print send(request)
Example #4
0
# -*- coding: utf-8 -*
# vim: tabstop=4 shiftwidth=4 softtabstop=4

import sys, os, time, json

sys.path.append(os.path.abspath(os.path.join(__file__, '../../')))

from pdsframe.common.config import init_config, config

init_config('../files/conf/test/service.mds.215.ini')

import message.pds_pb2 as msg_pds
import message.mds_pb2 as msg_mds

if __name__ == "__main__":
    lun_info = msg_pds.LunInfo()
    lun_info.lun_name = "name"
    lun_export_info = msg_pds.LunExportInfo()
    lun_export_info.lun_name = "xx"
    lun_info.Extensions[msg_mds.ext_luninfo_lun_export_info].CopyFrom(
        lun_export_info)
    print dir(lun_info)
    print lun_info
    lun_info.ClearExtension(msg_mds.ext_luninfo_lun_export_info)
    print lun_info

    # print lun_info.HasExtension(msg_pds.ext_luninfo_basedisk_id)
    # print dir(lun_info)

    # disk_info = msg_pds.DiskInfo()
    # disk_info.dev_name = "/dev/x"
Example #5
0
# -*- coding: utf-8 -*
# vim: tabstop=4 shiftwidth=4 softtabstop=4

import sys, os, time

sys.path.append(os.path.abspath(os.path.join(__file__, '../../../')))

from pdsframe.common.config import init_config, config
from pdsframe.common.dbclient import *
from pdsframe.common.logger import *
from pdsframe import *

init_config('../../files/conf/test/utest_ios.ini')
init_logger()
#init_dbservice()

from service_ios.base.apismartscsi import APISmartScsi
if __name__ == "__main__":
    x = APISmartScsi()
    print "---------add group------------"
    print x.add_group("test", ["yyyy"])
    print x.errmsg

    print "---------add lun------------"
    params = {}
    params['device_name'] = "su001_sdb1"
    params['path'] = "/dev/sdb1"
    params['t10_dev_id'] = "abc"
    params['group_name'] = "test"
    print x.add_lun(params)
    print x.errmsg
Example #6
0
def main():
    if "--help" in sys.argv:
        print "Usage: smartmgrcli [option]"
        sys.exit(0)

    cli = CLI()

    mds_config = "/opt/smartmgr/conf/service.mds.ini"

    if "--config" in sys.argv:
        if len(sys.argv) == sys.argv.index("--config") + 1:
            print "Miss config file"
            sys.exit(1)
        mds_config = sys.argv[sys.argv.index("--config") + 1]
        if not os.path.exists(mds_config):
            print "Please cheack your config file path"
            sys.exit(1)
        del sys.argv[sys.argv.index('--config') + 1]
        del sys.argv[sys.argv.index('--config')]

    init_config(mds_config)
    platform = load_platform()

    if platform.has_key('sys_mode') and platform.has_key('merge_mode'):
        cli.srv['role'] = platform['merge_mode']
    else:
        cli.srv['role'] = platform['sys_mode']
    cli.srv['platform'] = platform['platform']
    cli.srv['ip'] = config.safe_get('network', 'listen-ip')
    cli.srv['port'] = config.safe_get_int('network', 'listen-port')
    check_netconfig(cli.srv['ip'])

    cli_config = {'debug': False, 'json': False, 'detail': False}

    if "--debug" in sys.argv:
        del sys.argv[sys.argv.index('--debug')]
        cli_config['debug'] = True

    if "--detail" in sys.argv:
        del sys.argv[sys.argv.index('--detail')]
        cli_config['detail'] = True

    if "--json" in sys.argv:
        del sys.argv[sys.argv.index('--json')]
        cli_config['json'] = True

    cli.pre_init(cli_config)
    cli.post_init()

    # shell 命令行方式调用
    if len(sys.argv) > 1:
        try:
            cli._save_hist(' '.join(sys.argv[1:]))
            cli.onecmd(' '.join(sys.argv[1:]))
        except KeyboardInterrupt:
            print "Stopped.."
            cli.do_quit('')
    else:
        try:
            cli.cmdloop()
        except KeyboardInterrupt:
            print "Stopped.."
            cli.do_quit('')
Example #7
0
# -*- coding: utf-8 -*
# vim: tabstop=4 shiftwidth=4 softtabstop=4

import sys, os, time

sys.path.append(os.path.abspath(os.path.join(__file__, '../../')))

from pdsframe.common.config import init_config, config
init_config('/root/workspace/pds-mgr/files/conf/test/service.mds.81.ini')

import message.pds_pb2 as msg_pds
import message.mds_pb2 as msg_mds

if __name__ == "__main__":
    # for i in range(1000):
    #     mds_request = msg_mds.HeartbeatActiveInstancesRequest()
    #     for j in range(30):
    #         mds_request.instances_ids.append('sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss')
    # print "done"
    # time.sleep(20)
    # sys.exit()

    attach_info = msg_pds.AttachInfo()
    attach_info.node_id = "xxx"
    iscsimap_init_info_1 = attach_info.iscsimap_info.iscsimap_init_infos.add()
    iscsimap_init_info_1.init_name = "init-1"

    iscsimap_init_info_2 = attach_info.iscsimap_info.iscsimap_init_infos.add()
    iscsimap_init_info_2.init_name = "init-2"

    iscsimap_init_info_3 = attach_info.iscsimap_info.iscsimap_init_infos.add()