本文整理汇总了Python中translator.base.simpletype.SimpleType类的典型用法代码示例。如果您正苦于以下问题:Python SimpleType类的具体用法?Python SimpleType怎么用?Python SimpleType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SimpleType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, ifc_key='ScanningThreatRate', asa_key = ScanningThreatDetection.THREAT_DETECTION_SCANNING_RATE):
'''Constructor'''
self.extra_cli = None
SimpleType.__init__(self, ifc_key = ifc_key, asa_key = asa_key,
asa_gen_template = ScanningThreatDetection.THREAT_DETECTION_SCANNING_RATE + ' rate-interval %(rate_interval)s average-rate %(average_rate)s burst-rate %(burst_rate)s',
response_parser = ScanningThreatDetection.ignore_msg_response_parser)
示例2: ifc2asa
def ifc2asa(self, no_asa_cfg_stack, asa_cfg_list, interfaces = None):
'''Generate ASA configuration from IFC configuration delta.
@see DMObject.ifc2asa for parameter details
'''
if not self.has_ifc_delta_cfg():
return
action = self.get_action()
if action == State.NOCHANGE:
return
if action == State.DESTROY and self.is_removable:
self.generate_cli(no_asa_cfg_stack, 'no ' + self.get_cli())
else:
self.generate_cli(asa_cfg_list, self.get_cli())
# apply the pool to the management interface
value = normalize_param_dict(self.delta_ifc_cfg_value['value'])
intf = self.get_top().get_mgmt_interface()
if not intf:
# default management interface: m0/0
intf = 'm0/0'
attr = self.get_mgmt_intf_attributes(intf)
if attr == None:
return
clii = CLIInteraction(mode_command='interface ' + util.normalize_interface_name(intf),
command='ip address ' + attr['ip'] + ' ' + attr['mask'] + ' cluster-pool ' + value['pool_name'],
response_parser=cluster_response_parser)
asa_cfg_list.append(clii)
SimpleType.ifc2asa(self, no_asa_cfg_stack, asa_cfg_list)
示例3: __init__
def __init__(self, name, asa_key = "flow-export destination"):
'''Constructor'''
self.interface = None
SimpleType.__init__(self, name, asa_key,
asa_gen_template = 'flow-export destination %(interface)s %(host)s %(port)s',
response_parser = TemplateAndCollectors.ignore_msg_response_parser)
示例4: __init__
def __init__(self, name):
SimpleType.__init__(
self,
name,
asa_gen_template="failover link %(interface_name)s %(interface)s",
response_parser=failover_response_parser,
)
示例5: __init__
def __init__(self):
'''
Constructor
'''
SimpleType.__init__(self, ifc_key = 'IPSSettings', asa_key = 'ips',
asa_gen_template='ips %(operate_mode)s %(fail_mode)s',
response_parser = cli_interaction.ignore_warning_response_parser)
示例6: __init__
def __init__(self, ifc_key='BasicThreatDetectionRateAclDrop', asa_key='threat-detection rate acl-drop'):
'''Constructor '''
self.rate_type = None
self.extra_cli = None
SimpleType.__init__(self, ifc_key, asa_key,
asa_gen_template = 'threat-detection rate %(rate)s rate-interval %(rate_interval)s average-rate %(average_rate)s burst-rate %(burst_rate)s',
response_parser = cli_interaction.ignore_warning_response_parser)
示例7: __init__
def __init__(self, name):
'''@todo: use Route.__init__ instead of SimpleType.__init__
Route.__init__(self, name, defaults=None, asa_gen_template = 'ipv6 route %(interface)s %(prefix)s %(gateway)s')
'''
SimpleType.__init__(self, name,
asa_gen_template = 'ipv6 route %(interface)s %(prefix)s %(gateway)s %(hop_count)s %(tunneled)s',
defaults = {'hop_count': '', 'tunneled': ''},
response_parser = static_route_response_parser)
示例8: create_cli
def create_cli(self, config, state):
''' Create the CLI using the config and the state '''
if state == State.NOCHANGE:
return ''
if not config:
return ''
result = AdvancedThreatDetection.THREAT_DETECTION_STATISTICS
if state == State.DESTROY:
if self.parent.is_audit():
if self.parent.statistics_exists('statistics'):
return None
return 'no ' + AdvancedThreatDetection.THREAT_DETECTION_STATISTICS + ' ' + self.stat_type
status = 'enable'
try:
if isinstance(config, dict):
status = config.get('status')
else:
return ''
except KeyError:
return SimpleType.get_cli(self)
if status and status.startswith('disable'):
return 'no ' + AdvancedThreatDetection.THREAT_DETECTION_STATISTICS + ' ' + self.stat_type
result += ' ' + self.stat_type
rate = config.get('number_of_rate')
if rate:
result += ' number-of-rate ' + str(rate)
return result
示例9: parse_multi_parameter_cli
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
'''
# 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()
if tokens[0] == 'no':
result = {(Type.PARAM, 'status', '') : {'state': State.NOCHANGE, 'value': 'disable'}}
return result
# The number of mandatory parameters is 3, i.e. 'threat-detection statistics host'
if len(tokens) == 3:
return result # no optional parameter
option = tokens[3:]
if 'number-of-rate' in option:
pos = option.index('number-of-rate') + 1
result = {(Type.PARAM, 'number_of_rate', '') : {'state': State.NOCHANGE, 'value': option[pos]}}
else:
return result
return result
示例10: parse_cli
def parse_cli(self, cli):
'''Override
'''
if cli.endswith(ScanningThreatDetection.THREAT_DETECTION_SCANNING):
return 'disable' if cli.startswith('no ') else 'enable'
return SimpleType.parse_cli(self, cli)
示例11: parse_multi_parameter_cli
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
示例12: parse_multi_parameter_cli
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)
示例13: get_cli
def get_cli(self):
'''
Generate the CLI for this single CLI with optional parameter 'reset'
'''
assert self.has_ifc_delta_cfg()
config = util.normalize_param_dict(self.delta_ifc_cfg_value['value'])
reset_option = (config.get('idle_reset') == 'enable') if config is not None else False # default value for reset: disable
reset_option = ' ' + TIMEOUT_RESET_CLI if reset_option else ''
return SimpleType.get_cli(self) + reset_option
示例14: get_cli
def get_cli(self):
"""Generate the CLI for this single failover ip config.
"""
assert self.has_ifc_delta_cfg()
config = util.normalize_param_dict(self.delta_ifc_cfg_value["value"])
netmask = config.get("netmask") if ":" not in config.get("active_ip") else ""
standby_ip = config.get("standby_ip")
result = SimpleType.get_cli(self)
result += " " + netmask + " standby " + standby_ip
return " ".join(result.split())
示例15: get_cli
def get_cli(self):
'''Generate the CLI for this single cluster ip config.
'''
assert self.has_ifc_delta_cfg()
config = util.normalize_param_dict(self.delta_ifc_cfg_value['value'])
mask = config.get('mask')
result = SimpleType.get_cli(self)
if mask:
result += ' mask ' + mask
return ' '.join(result.split())