本文整理汇总了Python中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使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类base.simpletype.SimpleType
的用法示例。
在下文中一共展示了SimpleType.parse_multi_parameter_cli方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_multi_parameter_cli
# 需要导入模块: from base.simpletype import SimpleType [as 别名]
# 或者: from 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
'''
result = SimpleType.parse_multi_parameter_cli(self, cli)
if not result:
result = SimpleType.parse_multi_parameter_cli(self, cli,
alternate_asa_gen_template = ' '.join(self.asa_gen_template.split()[:3]))
return result
示例2: parse_multi_parameter_cli
# 需要导入模块: from base.simpletype import SimpleType [as 别名]
# 或者: from base.simpletype.SimpleType import parse_multi_parameter_cli [as 别名]
def parse_multi_parameter_cli(self, cli):
# 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 2, i.e. 'ipv6 address prefix or default'
assert len(tokens) > 2
if ' at ' in cli:
colon_index_list = [a for a,b in enumerate(tokens) if ':' in b]
d1 = self.get_date_without_year(' '.join(tokens[5:colon_index_list[0]+1]))
d2 = self.get_date_without_year(' '.join(tokens[(colon_index_list[0] + 1):colon_index_list[1]+1]))
result[(Type.PARAM, 'valid_lifetime_in_date', '')] = {'state': State.NOCHANGE, 'value': d1}
result[(Type.PARAM, 'prefered_lifetime_in_date', '')] = {'state': State.NOCHANGE, 'value': d2}
elif len(tokens) > 5 and (tokens[4].isdigit() or tokens[4] == 'infinite') and \
(tokens[5].isdigit() or tokens[5] == 'infinite'):
s1 = 'valid_lifetime_in_seconds' if tokens[5].isdigit() else 'valid_lifetime_never_expire'
s2 = 'prefered_lifetime_in_seconds' if tokens[5].isdigit() else 'prefered_lifetime_never_expire'
result[(Type.PARAM, s1, '')] = {'state': State.NOCHANGE, 'value': tokens[4]}
result[(Type.PARAM, s2, '')] = {'state': State.NOCHANGE, 'value': tokens[5]}
if 'no-advertise' in cli:
result[(Type.PARAM, 'no_advertise', '')] = {'state': State.NOCHANGE, 'value': 'enable'}
else:
if 'off-link' in cli:
result[(Type.PARAM, 'off-link', '')] = {'state': State.NOCHANGE, 'value': 'enable'}
if 'no-autoconfig' in cli:
result[(Type.PARAM, 'no-autoconfig', '')] = {'state': State.NOCHANGE, 'value': 'enable'}
return result
示例3: parse_multi_parameter_cli
# 需要导入模块: from base.simpletype import SimpleType [as 别名]
# 或者: from base.simpletype.SimpleType import parse_multi_parameter_cli [as 别名]
def parse_multi_parameter_cli(self, cli):
result = SimpleType.parse_multi_parameter_cli(self, cli, alternate_asa_gen_template = self.asa_gen_template)
tokens = cli.split()
if len(tokens) == 3:
return result # no optional parameter
result[(Type.PARAM, 'peer_mac', '')] = {'state': State.NOCHANGE, 'value': ''}
option = tokens[3:]
if 'mac' in option: # e.g. "peer ip 10.10.10.10 mac 1234.5678.9abc"
result[Type.PARAM, 'peer_mac', '']['value'] = option[1]
return result
示例4: parse_multi_parameter_cli
# 需要导入模块: from base.simpletype import SimpleType [as 别名]
# 或者: from 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 mandatory parameters is 3, i.e. 'ntp server 1.1.1.1'
if len(tokens) == 3:
return result # no optional parameter
for name in ["key", "prefer"]:
result[(Type.PARAM, name, "")] = {"state": State.NOCHANGE, "value": ""}
option = tokens[3:]
if "key" in option: # e.g. "ntp server 1.1.1.1 key 11
result[Type.PARAM, "key", ""]["value"] = option[1]
if "prefer" in option: # e.g. "ntp server 1.1.1.1 prefer
result[Type.PARAM, "prefer", ""]["value"] = "enable"
return result