本文整理汇总了Python中translator.base.simpletype.SimpleType.parse_multi_parameter_cli方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleType.parse_multi_parameter_cli方法的具体用法?Python SimpleType.parse_multi_parameter_cli怎么用?Python SimpleType.parse_multi_parameter_cli使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类translator.base.simpletype.SimpleType
的用法示例。
在下文中一共展示了SimpleType.parse_multi_parameter_cli方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_multi_parameter_cli
# 需要导入模块: from translator.base.simpletype import SimpleType [as 别名]
# 或者: from translator.base.simpletype.SimpleType import parse_multi_parameter_cli [as 别名]
def parse_multi_parameter_cli(self, cli):
"""
Override the default implementation in case the CLI does not match asa_gen_template due to optional parameter
"""
# Take care of the mandatory parameters
result = SimpleType.parse_multi_parameter_cli(self, cli, alternate_asa_gen_template=self.asa_gen_template)
"Take care of the optional parameters"
tokens = cli.split()
# The number of tokens must greater than 3, i.e. 'failover interface ip ...'
assert len(tokens) > 3
for name in ["interface_name", "active_ip", "standby_ip"]:
result[(Type.PARAM, name, "")] = {"state": State.NOCHANGE, "value": ""}
option = tokens[3:]
# for ipv4, option is: %(interface_name)s %(active_ip)s %(netmask)s standby %(standby_ip)s
# for ipv6, option is: %(interface_name)s %(active_ip)s standby %(standby_ip)s
result[Type.PARAM, "interface_name", ""]["value"] = option[0]
result[Type.PARAM, "active_ip", ""]["value"] = option[1]
if ":" not in option[1]: # ipv4
result[(Type.PARAM, "netmask", "")] = {"state": State.NOCHANGE, "value": ""}
result[Type.PARAM, "netmask", ""]["value"] = option[2]
# skip option[3], which should be the 'standby' keyword
result[Type.PARAM, "standby_ip", ""]["value"] = option[4]
else: # ipv6, no netmask
# skip option[2], which should be the 'standby' keyword
result[Type.PARAM, "standby_ip", ""]["value"] = option[3]
return result
示例2: parse_multi_parameter_cli
# 需要导入模块: from translator.base.simpletype import SimpleType [as 别名]
# 或者: from translator.base.simpletype.SimpleType import parse_multi_parameter_cli [as 别名]
def parse_multi_parameter_cli(self, cli, alternate_asa_gen_template = None):
'''
Override the default implementation in case the CLI does not match asa_gen_template due to optional parameter
'''
if not cli.endswith(AdvancedThreatDetection.THREAT_DETECTION_STATISTICS_TCP_INTERCEPT):
return SimpleType.parse_multi_parameter_cli(self, cli, alternate_asa_gen_template)
return self.parse_intercept_cli(cli)
示例3: parse_multi_parameter_cli
# 需要导入模块: from translator.base.simpletype import SimpleType [as 别名]
# 或者: from translator.base.simpletype.SimpleType import parse_multi_parameter_cli [as 别名]
def parse_multi_parameter_cli(self, cli):
'''Override the default implementation in case the CLI does not have optional max_retries value
'''
# Take care of the optional parameters
tokens = cli.split()
if len(tokens) < len(self.asa_gen_template.split()):
cli += ' ' + MAX_RETRIES_DEFAULT
return SimpleType.parse_multi_parameter_cli(self, cli, alternate_asa_gen_template = self.asa_gen_template)
示例4: parse_multi_parameter_cli
# 需要导入模块: from translator.base.simpletype import SimpleType [as 别名]
# 或者: from translator.base.simpletype.SimpleType import parse_multi_parameter_cli [as 别名]
def parse_multi_parameter_cli(self, cli):
'''
Override the default implementation in case the CLI does not match asa_gen_template due to optional parameter
'''
# Take care of the mandatory parameters
result = SimpleType.parse_multi_parameter_cli(self, cli, alternate_asa_gen_template = self.asa_gen_template)
'Take care of the optional parameters'
tokens = cli.split()
# The number of tokens must greater than 3, i.e. 'clacp system-mac [H.H.H | auto]'
assert len(tokens) > 3
option = tokens[3:]
if len(option) > 0:
result[(Type.PARAM, 'system-priority', '')] = {'state': State.NOCHANGE, 'value': ''}
result[Type.PARAM, 'system-priority', '']['value'] = option[0]
return result
示例5: parse_multi_parameter_cli
# 需要导入模块: from translator.base.simpletype import SimpleType [as 别名]
# 或者: from translator.base.simpletype.SimpleType import parse_multi_parameter_cli [as 别名]
def parse_multi_parameter_cli(self, cli):
'''Override the default implementation in case the CLI does not match asa_gen_template due to optional
parameter
'''
'Take care of the mandatory parameters'
result = SimpleType.parse_multi_parameter_cli(self, cli, alternate_asa_gen_template = 'ipv6 route %(interface)s %(prefix)s %(gateway)s')
'Take care of the optional parameters'
for name, value in self.defaults.iteritems():
result[(Type.PARAM, name, '')] = {'state': State.NOCHANGE, 'value': value}
tokens = cli.split()
if len(tokens) == 5:
return result #no optional parameter
option = tokens[5]
if option == 'tunneled':
result[Type.PARAM, 'tunneled', '']['value'] = option
elif option:
result[Type.PARAM, 'hop_count', '']['value'] = option
return result