Beispiel #1
0
def parse_args(args):
    parser = ArgumentParser(description=debugVertexRoute.__doc__, add_help=True, formatter_class=RawTextHelpFormatter)
    parser.add_argument('--ri_fqname', help='FQName of the Routing Instance')
    parser.add_argument('--vn_fqname', help='FQName of the Virtual Network')
    parser.add_argument('--prefix', help='Route prefix to verify')
    parser.add_argument('--vrouters', help='List of vrouters to verify')
    return parser.parse_args(args)
Beispiel #2
0
def parse_args(args):
    parser = ArgumentParser(description='Debug utility for Flow', add_help=True)
    #parser.add_argument('--source_ip', help='Source IP of the flow', required=True)
    #parser.add_argument('--dest_ip', help='Destination IP of the flow', required=True)
    #parser.add_argument('--source_vn', help='VN of the source IP')
    #parser.add_argument('--dest_vn', help='VN of the destination IP')
    #parser.add_argument('--protocol', help='L3 Protocol of the flow')
    #parser.add_argument('--source_port', help='Source Port of the flow')
    #parser.add_argument('--dest_port', help='Destination Port of the flow')
    return parser.parse_args(args)
Beispiel #3
0
 def _start_redis_client(self):
     """
     启动redis client
     :return:
     """
     rc = redis_client.RedisClient.instance(
         ArgumentParser().args.redis_ip,
         ArgumentParser().args.redis_port,
         ArgumentParser().args.redis_db)
     ParamCacher().redis_client = rc
Beispiel #4
0
 def _start_orm(self):
     """
     orm初始化
     :return:
     """
     orm_engine = OrmEngine(ArgumentParser().args.db_host,
                            ArgumentParser().args.db_port,
                            ArgumentParser().args.db_name,
                            ArgumentParser().args.db_user,
                            ArgumentParser().args.db_password)
     ParamCacher().orm_engine = orm_engine
Beispiel #5
0
    def __init__(self, service_type, service_version, is_sm=False, db_update_dir_path=None,
                 use_mysqldb=False, use_orm=False, use_redis=False):
        self.service_type = service_type
        self.service_version = service_version
        self.thread_ls = []
        self.is_sm = is_sm
        self.db_update_dir_path = db_update_dir_path
        self.use_mysqldb = use_mysqldb
        self.use_orm = use_orm
        self.use_redis = use_redis

        self.adv = None
        self.sm_rpc = None

        logger.init_log(self.service_type, self.service_type)
        ExitHandler().add_exit_handler(self.stop_service)

        arg_parser = ArgumentParser()
        p = arg_parser.get_argparser()

        p.add_argument('--is_https', default=False, type=parser_boolean,  help="Is use http ssl connection")
        p.add_argument('--http_port', default=0, type=int,  help="The port of the http app listen")
        p.add_argument('--tcp_port', default=0, type=int,  help="The port of of the tcp rpc app listen")

        p.add_argument('--service_type', default=service_type, type=str, help="The type of the service")
        p.add_argument('--service_version', default=use_redis, type=str,  help="The version of the service")
        p.add_argument('--is_sm', default=is_sm, type=bool,  help="Whether it is the service manager")
        p.add_argument('--db_update_dir_path', default=db_update_dir_path, type=str,  help="The dir for db update use")
        p.add_argument('--use_mysqldb', default=use_mysqldb, type=parser_boolean,  help="Whether to use the mysqldb lib")
        p.add_argument('--use_orm', default=use_orm, type=parser_boolean,  help="Whether to use the orm db lib")
        p.add_argument('--use_redis', default=use_redis, type=parser_boolean,  help="Whether to use the redis cache")

        p.add_argument('--logger_err_2_mail', default=False, type=bool, help="whether logger 2 mail when error")
        p.add_argument('--logger_err_2_sms', default=False, type=bool, help="whether logger 2 sms when error")
        self.add_cmd_opts(p)

        IpFinder().is_extranet = arg_parser.args.is_extranet

        if self.db_update_dir_path:
            self._db_update()
        if self.use_mysqldb:
            self._start_mysqldb()
        if self.use_orm:
            self._start_orm()
        if self.use_redis:
            self._start_redis_client()

        args = arg_parser.args
        arg_parser.will_change = False

        self.prepare(args)
        self.init(args)
        self._set_logger(args)
        logger.set_logger_level(args.logger_level)
def parse_args(args):
    parser = ArgumentParser(description='Debug utility for Flow',
                            add_help=True)
    #parser.add_argument('--source_ip', help='Source IP of the flow', required=True)
    #parser.add_argument('--dest_ip', help='Destination IP of the flow', required=True)
    #parser.add_argument('--source_vn', help='VN of the source IP')
    #parser.add_argument('--dest_vn', help='VN of the destination IP')
    #parser.add_argument('--protocol', help='L3 Protocol of the flow')
    #parser.add_argument('--source_port', help='Source Port of the flow')
    #parser.add_argument('--dest_port', help='Destination Port of the flow')
    return parser.parse_args(args)
Beispiel #7
0
 def _db_update(self):
     """
     db版本文件更新
     :return:
     """
     # 按版本更新数据库结构或数据
     assert db_update.main(ArgumentParser().args.db_host,
                           ArgumentParser().args.db_port,
                           ArgumentParser().args.db_name,
                           ArgumentParser().args.db_user,
                           ArgumentParser().args.db_password,
                           self.db_update_dir_path)
Beispiel #8
0
 def _start_mysqldb(self):
     """
     mysql db引擎开启
     :return:
     """
     db_instance = DBInstance(db_host=ArgumentParser().args.db_host,
                              db_port=ArgumentParser().args.db_port,
                              db_name=ArgumentParser().args.db_name,
                              db_username=ArgumentParser().args.db_user,
                              db_password=ArgumentParser().args.db_password,
                              err_file=logger.fatal)
     db_instance.init()
     ParamCacher().db_instance = db_instance
Beispiel #9
0
    def start_service(self):
        """
        启动服务
        :return:
        """
        args = ArgumentParser().args
        try:
            Jobs().add_interval_job(UPDATE_INTERVAL, self.update)

            if not self.is_sm:
                port = {"tcp": args.tcp_port}
                port.update({"https": args.http_port} if args.
                            is_https else {"http": args.http_port})
                self.adv = ServiceAdvertiser(self.service_type, port,
                                             self.get_jid(),
                                             self.service_version)
                self.adv.advertise()

            checker_ls = []
            self.add_port_checker(args, checker_ls)
            PortChecker(checker_ls).start()

            self.services(args, self.thread_ls)
            self.__sys_services(args, self.thread_ls)

            logger.warn("start services for %s, args:%s" %
                        (self.service_type, args))

            gevent.joinall([thread.start() for thread in self.thread_ls])
        except:
            logger.error(traceback.format_exc())
            sys.exit(0)
Beispiel #10
0
    def start_service(self):
        """
        启动服务
        :return:
        """
        args = ArgumentParser().args
        try:
            Jobs().add_interval_job(UPDATE_INTERVAL, self.update)

            if not self.is_sm:
                self.adv = ServiceAdvertiser(args.service_id,
                                             self.service_version, args.port)
                self.adv.advertise()

            check_ports = {}
            if "tcp_port" in args:
                check_ports['tcp'] = args.tcp_port
            if "http_port" in args:
                if not args.is_https:
                    check_ports['http'] = args.http_port
                else:
                    check_ports['https'] = args.http_port
            PortChecker(check_ports).start()

            self.thread_ls.extend([Jobs()])

            self.services(args, self.thread_ls)

            logger.warn("start services for %s, args:%s" %
                        (self.service_type, args))
            gevent.joinall([thread.start() for thread in self.thread_ls])
        except:
            logger.error(traceback.format_exc())
            sys.exit(0)
Beispiel #11
0
    def stop_service(self, *args):
        """
        退出服务
        :param args: 参数
        :return:
        """
        # 保存数据
        self.update()

        self.exit()

        if not self.is_sm:
            self.adv.notify_shutdown()

            result = stop_service(ParamCacher().sm_rpc,
                                  ArgumentParser().args.service_id)
            assert result['result'] == error_code.ERROR_SUCCESS
        [thread.stop() for thread in self.thread_ls]
Beispiel #12
0
def parse_args(args):
    parser = ArgumentParser(description=debugVertexSG.__doc__, add_help=True, formatter_class=RawTextHelpFormatter)
    parser.add_argument('--display_name', help='Display name')
    return parser.parse_args(args)
Beispiel #13
0
def parse_args(args):
    parser = ArgumentParser(description=debugVertexSC.__doc__, add_help=True, formatter_class=RawTextHelpFormatter)
    parser.add_argument('--left_vn_fq_name', help='FQName of the Left VN', required=True)
    parser.add_argument('--right_vn_fq_name', help='FQName of the Right VN', required=True)
    parser.add_argument('--left_ip', help='Left CIDR specified in policy')
    parser.add_argument('--right_ip', help='Right CIDR specified in policy')
    parser.add_argument('--protocol', help='L3 Protocol of the flow')
    parser.add_argument('--left_port', help='Source Port of the flow')
    parser.add_argument('--right_port', help='Destination Port of the flow')
    return parser.parse_args(args)
Beispiel #14
0
 def __init__(self):
     parser = ArgumentParser(description='cluster status',
                             add_help=True,
                             formatter_class=RawTextHelpFormatter)
     self.args = []
     self.args = parser.parse_args(self.args)
Beispiel #15
0
    def __init__(self,
                 service_type,
                 service_version,
                 is_sm=False,
                 db_update_dir_path=None,
                 use_mysqldb=False,
                 use_orm=False,
                 use_redis=False):
        self.service_type = service_type
        self.service_version = service_version
        self.thread_ls = []
        self.is_sm = is_sm
        self.db_update_dir_path = db_update_dir_path
        self.use_mysqldb = use_mysqldb
        self.use_orm = use_orm
        self.use_redis = use_redis

        self.adv = None
        self.sm_rpc = None

        logger.init_log(self.service_type, self.service_type)
        ExitHandler().add_exit_handler(self.stop_service)

        arg_parser = ArgumentParser()
        p = arg_parser.get_argparser()

        self.add_cmd_opts(p)

        p.add_argument('--service_type',
                       default=service_type,
                       type=str,
                       help="The type of the service")
        p.add_argument('--service_version',
                       default=use_redis,
                       type=str,
                       help="The version of the service")
        p.add_argument('--is_sm',
                       default=is_sm,
                       type=bool,
                       help="Whether it is the service manager")
        p.add_argument('--db_update_dir_path',
                       default=db_update_dir_path,
                       type=str,
                       help="The dir for db update use")
        p.add_argument('--use_mysqldb',
                       default=use_mysqldb,
                       type=parser_boolean,
                       help="Whether to use the mysqldb lib")
        p.add_argument('--use_orm',
                       default=use_orm,
                       type=parser_boolean,
                       help="Whether to use the orm db lib")
        p.add_argument('--use_redis',
                       default=use_redis,
                       type=parser_boolean,
                       help="Whether to use the redis cache")

        p.add_argument('--logger_mask',
                       default='0000',
                       type=str,
                       help="The logger mask em es fm fs")

        IpFinder().is_extranet = arg_parser.args.is_extranet

        if not self.is_sm:
            SMParamParser(service_type=self.service_type,
                          sm_rpc=ParamCacher().sm_rpc,
                          arg_parser=p,
                          rdm_port_fun=get_random_port)

            self.add_cmd_opts_after_sm(p)

        if self.db_update_dir_path:
            self._db_update()
        if self.use_mysqldb:
            self._start_mysqldb()
        if self.use_redis:
            self._start_redis_client()

        args = arg_parser.args
        arg_parser.will_change = False

        self.init(args)
        logger.set_logger_level(args.logger_level)
 def __init__(self):
     parser = ArgumentParser(description='cluster status', 
                             add_help=True, 
                             formatter_class=RawTextHelpFormatter)
     self.args = []
     self.args = parser.parse_args(self.args)
Beispiel #17
0
def parse_args(args):
    parser = ArgumentParser(description=debugVertexVMI.__doc__,
                            add_help=True,
                            formatter_class=RawTextHelpFormatter)
    return parser.parse_args(args)
Beispiel #18
0
def parse_args(args):
    parser = ArgumentParser(description=debugVertexSG.__doc__,
                            add_help=True,
                            formatter_class=RawTextHelpFormatter)
    parser.add_argument('--display_name', help='Display name')
    return parser.parse_args(args)
Beispiel #19
0
def parse_args(args):
    parser = ArgumentParser(description=debugVertexVMI.__doc__, add_help=True, formatter_class=RawTextHelpFormatter)
    return parser.parse_args(args)
Beispiel #20
0
def parse_args(args):
    parser = ArgumentParser(description=debugVertexRoute.__doc__,
                            add_help=True,
                            formatter_class=RawTextHelpFormatter)
    parser.add_argument('--ri_fqname', help='FQName of the Routing Instance')
    parser.add_argument('--vn_fqname', help='FQName of the Virtual Network')
    parser.add_argument('--prefix', help='Route prefix to verify')
    parser.add_argument('--vrouters', help='List of vrouters to verify')
    return parser.parse_args(args)
Beispiel #21
0
def parse_args(args):
    parser = ArgumentParser(description=debugVertexFlow.__doc__, add_help=True, formatter_class=RawTextHelpFormatter)
    parser.add_argument('--source_ip', help='Source IP of the flow', required=True)
    parser.add_argument('--dest_ip', help='Destination IP of the flow', default='')
    parser.add_argument('--source_vn', help='VN of the source IP', required=True)
    parser.add_argument('--dest_vn', help='VN of the destination IP', default='')
    parser.add_argument('--protocol', help='L3 Protocol of the flow', default='')
    parser.add_argument('--source_port', help='Source Port of the flow', default='')
    parser.add_argument('--dest_port', help='Destination Port of the flow', default='')
    parser.add_argument('--source_ip_type', help='source ip type', default='')
    parser.add_argument('--dest_ip_type', help='dest ip type', default='')
    return parser.parse_args(args)
Beispiel #22
0
    def __init__(self,
                 service_type,
                 service_version,
                 is_sm=False,
                 db_update_dir_path=None,
                 use_mysqldb=False,
                 use_orm=False,
                 use_redis=False):
        self.service_type = service_type
        self.service_version = service_version
        self.thread_ls = []
        self.is_sm = is_sm
        self.db_update_dir_path = db_update_dir_path
        self.use_mysqldb = use_mysqldb
        self.use_orm = use_orm
        self.use_redis = use_redis

        self.adv = None
        self.sm_rpc = None

        setproctitle(self.service_type)

        logger.init_log(self.service_type, self.service_type)
        ExitHandler().add_exit_handler(self.stop_service)

        arg_parser = ArgumentParser()
        p = arg_parser.get_argparser()

        p.add_argument('--is_https',
                       default=False,
                       type=parser_boolean,
                       help="Is use http ssl connection")
        p.add_argument('--http_port',
                       default=0,
                       type=int,
                       help="The port of the http app listen")
        p.add_argument('--tcp_port',
                       default=0,
                       type=int,
                       help="The port of of the tcp rpc app listen")

        p.add_argument('--service_type',
                       default=service_type,
                       type=str,
                       help="The type of the service")
        p.add_argument('--service_version',
                       default=use_redis,
                       type=str,
                       help="The version of the service")
        p.add_argument('--is_sm',
                       default=is_sm,
                       type=bool,
                       help="Whether it is the service manager")
        p.add_argument('--db_update_dir_path',
                       default=db_update_dir_path,
                       type=str,
                       help="The dir for db update use")
        p.add_argument('--use_mysqldb',
                       default=use_mysqldb,
                       type=parser_boolean,
                       help="Whether to use the mysqldb lib")
        p.add_argument('--use_orm',
                       default=use_orm,
                       type=parser_boolean,
                       help="Whether to use the orm db lib")
        p.add_argument('--use_redis',
                       default=use_redis,
                       type=parser_boolean,
                       help="Whether to use the redis cache")

        p.add_argument('--logger_err_2_mail',
                       default=False,
                       type=bool,
                       help="whether logger 2 mail when error")
        p.add_argument('--logger_err_2_sms',
                       default=False,
                       type=bool,
                       help="whether logger 2 sms when error")
        self.add_cmd_opts(p)

        IpFinder().is_extranet = arg_parser.args.is_extranet

        if self.db_update_dir_path:
            self._db_update()
        if self.use_mysqldb:
            self._start_mysqldb()
        if self.use_orm:
            self._start_orm()
        if self.use_redis:
            self._start_redis_client()

        args = arg_parser.args
        arg_parser.will_change = False

        self.prepare(args)
        self.init(args)
        self._set_logger(args)
        logger.set_logger_level(args.logger_level)
Beispiel #23
0
def parse_args(args):
    parser = ArgumentParser(description=debugVertexIP.__doc__, add_help=True, formatter_class=RawTextHelpFormatter)
    parser.add_argument('--instance_ip_address', help='Instance ip address to debug')
    parser.add_argument('--virtual_network', help='Virtual network uuid')
    return parser.parse_args(args)
Beispiel #24
0
def parse_args(args):
    parser = ArgumentParser(description=debugVertexFIP.__doc__, add_help=True, formatter_class=RawTextHelpFormatter)
    parser.add_argument('--floating_ip_address', help='Floating ip address to debug')
    return parser.parse_args(args)