本文整理汇总了Python中translator.base.simpletype.SimpleType类的典型用法代码示例。如果您正苦于以下问题:Python SimpleType类的具体用法?Python SimpleType怎么用?Python SimpleType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SimpleType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:AlexFengCisco,项目名称:ACI_REST_Project,代码行数:7,代码来源:scanning_threat_detect.py
示例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)
开发者ID:AlexFengCisco,项目名称:ACI_REST_Project,代码行数:28,代码来源:cluster.py
示例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)
开发者ID:AlexFengCisco,项目名称:ACI_REST_Project,代码行数:7,代码来源:netflow_objects.py
示例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,
)
开发者ID:AlexFengCisco,项目名称:ACI_REST_Project,代码行数:7,代码来源:failover.py
示例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)
开发者ID:AlexFengCisco,项目名称:ACI_REST_Project,代码行数:8,代码来源:ips_settings.py
示例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)
开发者ID:AlexFengCisco,项目名称:ACI_REST_Project,代码行数:8,代码来源:basic_threat_detect.py
示例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)
开发者ID:AlexFengCisco,项目名称:ACI_REST_Project,代码行数:8,代码来源:static_route.py
示例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
开发者ID:AlexFengCisco,项目名称:ACI_REST_Project,代码行数:31,代码来源:advanced_threat_detect.py
示例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
开发者ID:AlexFengCisco,项目名称:ACI_REST_Project,代码行数:28,代码来源:advanced_threat_detect.py
示例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)
开发者ID:AlexFengCisco,项目名称:ACI_REST_Project,代码行数:7,代码来源:scanning_threat_detect.py
示例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
开发者ID:AlexFengCisco,项目名称:ACI_REST_Project,代码行数:29,代码来源:failover.py
示例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)
开发者ID:AlexFengCisco,项目名称:ACI_REST_Project,代码行数:10,代码来源:connection_limits.py
示例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
开发者ID:AlexFengCisco,项目名称:ACI_REST_Project,代码行数:10,代码来源:connection_limits.py
示例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())
开发者ID:AlexFengCisco,项目名称:ACI_REST_Project,代码行数:10,代码来源:failover.py
示例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())
开发者ID:AlexFengCisco,项目名称:ACI_REST_Project,代码行数:10,代码来源:cluster.py
示例16: parse_single_parameter_cli
def parse_single_parameter_cli(self, cli):
''' Parse CLI '''
result = {}
find_id = cli.find(self.get_asa_key())
if find_id >= 0:
self.destination = cli[find_id + len(self.get_asa_key()) + 1:]
if find_id > 0:
self.status = 'disable'
else:
self.status = 'enable'
result[(Type.PARAM, 'status', '')] = {'state': State.NOCHANGE, 'value': self.status}
result[(Type.PARAM, 'event_destination', '')] = {'state': State.NOCHANGE, 'value': self.destination}
return result
return SimpleType.parse_cli(self, cli)
开发者ID:AlexFengCisco,项目名称:ACI_REST_Project,代码行数:16,代码来源:netflow_objects.py
示例17: 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. '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
开发者ID:AlexFengCisco,项目名称:ACI_REST_Project,代码行数:18,代码来源:cluster.py
示例18: 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 = '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
开发者ID:AlexFengCisco,项目名称:ACI_REST_Project,代码行数:21,代码来源:static_route.py
示例19: __init__
def __init__(self):
SimpleType.__init__(
self,
ifc_key=AccessGroupGlobal.__name__,
asa_key='access-group',
asa_gen_template='access-group %(access_list_name)s global')
开发者ID:AlexFengCisco,项目名称:ACI_REST_Project,代码行数:6,代码来源:access_rule.py
示例20: __init__
def __init__(self):
'''
Constructor
'''
SimpleType.__init__(self, 'timeout_dcd', 'set connection timeout dcd', asa_gen_template='set connection timeout dcd %(retry_interval)s %(max_retries)s', defaults={'retry_interval': RETRY_INTERVAL_DEFAULT, 'max_retries': MAX_RETRIES_DEFAULT})
开发者ID:AlexFengCisco,项目名称:ACI_REST_Project,代码行数:5,代码来源:connection_limits.py
注:本文中的translator.base.simpletype.SimpleType类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论