本文整理汇总了Python中interface.Interface方法的典型用法代码示例。如果您正苦于以下问题:Python interface.Interface方法的具体用法?Python interface.Interface怎么用?Python interface.Interface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类interface
的用法示例。
在下文中一共展示了interface.Interface方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: auth_errors_table
# 需要导入模块: import interface [as 别名]
# 或者: from interface import Interface [as 别名]
def auth_errors_table(self):
tab = table.Table()
tab.add_row([
"Interface",
["Authentication", "Errors"],
["Error", "Count"],
["Error", "Rate"],
["Last Change"]
])
for intf in self.interfaces_by_name.values():
for counter in intf.auth_error_counters():
if not counter.is_zero():
tab.add_row([
intf.name,
counter.description(),
counter.value_display_str(),
counter.rate_display_str(),
counter.last_change_display_str()
])
return tab
示例2: set_mtu_ugly
# 需要导入模块: import interface [as 别名]
# 或者: from interface import Interface [as 别名]
def set_mtu_ugly(self, cap):
# sorry about this, this is a hack
# no better solution till the custom fragmentation is not implemented
interface = Interface()
interface.set_mtu(self.config.get("Global", "clientif"), cap)
cap -= 40 # IP+TCP
os.system("iptables -t mangle -F")
os.system("iptables -t mangle -A POSTROUTING -p tcp --tcp-flags SYN,RST SYN -o {0} -j TCPMSS --set-mss {1}".format(self.config.get("Global", "clientif"), cap))
return
# autotune control message handler
# this handler answers to the tune requests to find the best bandwidth
示例3: better_offer
# 需要导入模块: import interface [as 别名]
# 或者: from interface import Interface [as 别名]
def better_offer(self, offer1, offer2, three_way_only):
# Don't consider removed offers
if (offer1 is not None) and (offer1.removed):
offer1 = None
if (offer2 is not None) and (offer2.removed):
offer2 = None
# Don't consider offers that are marked "not a ZTP offer"
if (offer1 is not None) and (offer1.not_a_ztp_offer):
offer1 = None
if (offer2 is not None) and (offer2.not_a_ztp_offer):
offer2 = None
# If asked to do so, only consider offers from neighbors in state 3-way as valid candidates
if three_way_only:
if (offer1 is not None) and (offer1.state != interface.Interface.State.THREE_WAY):
offer1 = None
if (offer2 is not None) and (offer2.state != interface.Interface.State.THREE_WAY):
offer2 = None
# If there is only one candidate, it automatically wins. If there are no candidates, there
# is no best.
if offer1 is None:
return offer2
if offer2 is None:
return offer1
# Pick the offer with the highest level
if offer1.level > offer2.level:
return offer1
if offer2.level < offer1.level:
return offer2
# If the level is the same for both offers, pick offer with lowest system id as tie breaker
if offer1.system_id < offer2.system_id:
return offer1
return offer2
示例4: create_interface
# 需要导入模块: import interface [as 别名]
# 或者: from interface import Interface [as 别名]
def create_interface(self, interface_config):
interface_name = interface_config['name']
intf = interface.Interface(self, interface_config)
self.interfaces_by_name[interface_name] = intf
self.interfaces_by_id[intf.local_id] = intf
return intf
示例5: up_interfaces
# 需要导入模块: import interface [as 别名]
# 或者: from interface import Interface [as 别名]
def up_interfaces(self, interface_going_down):
for intf in self.interfaces_by_name.values():
if ((intf.fsm.state == interface.Interface.State.THREE_WAY) and
(intf != interface_going_down)):
yield intf
示例6: have_s_or_ew_adjacency
# 需要导入模块: import interface [as 别名]
# 或者: from interface import Interface [as 别名]
def have_s_or_ew_adjacency(self, interface_going_down):
# Does this node have at least one south-bound or east-west adjacency?
for intf in self.interfaces_by_name.values():
if ((intf.fsm.state == interface.Interface.State.THREE_WAY) and
(intf != interface_going_down)):
if intf.neighbor_direction() in [constants.DIR_SOUTH,
constants.DIR_EAST_WEST]:
return True
return False
示例7: have_ew_adjacency
# 需要导入模块: import interface [as 别名]
# 或者: from interface import Interface [as 别名]
def have_ew_adjacency(self):
# Does this node have at least one east-west adjacency?
return any(filter(lambda x: x.fsm.state == interface.Interface.State.THREE_WAY and
x.neighbor_direction() == constants.DIR_EAST_WEST,
self.interfaces_by_name.values()))
示例8: command_show_interface
# 需要导入模块: import interface [as 别名]
# 或者: from interface import Interface [as 别名]
def command_show_interface(self, cli_session, parameters):
interface_name = parameters['interface']
if not interface_name in self.interfaces_by_name:
cli_session.print("Error: interface {} not present".format(interface_name))
return
intf = self.interfaces_by_name[interface_name]
cli_session.print("Interface:")
cli_session.print(intf.cli_details_table().to_string())
neighbor_table = intf.cli_neighbor_details_table()
if neighbor_table:
cli_session.print("Neighbor:")
cli_session.print(neighbor_table.to_string())
示例9: command_show_interfaces
# 需要导入模块: import interface [as 别名]
# 或者: from interface import Interface [as 别名]
def command_show_interfaces(self, cli_session):
# TODO: Report neighbor uptime (time in THREE_WAY state)
tab = table.Table()
tab.add_row(interface.Interface.cli_summary_headers())
for intf in self.interfaces_by_name.values():
tab.add_row(intf.cli_summary_attributes())
cli_session.print(tab.to_string())
示例10: floodred_interfaces_table
# 需要导入模块: import interface [as 别名]
# 或者: from interface import Interface [as 别名]
def floodred_interfaces_table(self):
tab = table.Table()
tab.add_row(interface.Interface.cli_floodred_summary_headers())
for intf in self.interfaces_by_name.values():
tab.add_row(intf.cli_floodred_summary_attributes())
return tab
示例11: command_show_node_stats
# 需要导入模块: import interface [as 别名]
# 或者: from interface import Interface [as 别名]
def command_show_node_stats(self, cli_session, exclude_zero):
cli_session.print("Node ZTP FSM:")
tab = self.node_ztp_fsm_stats_group.table(exclude_zero, sort_by_description=True)
cli_session.print(tab.to_string())
cli_session.print("Node Interfaces Traffic:")
tab = self.intf_traffic_stats_group.table(exclude_zero)
cli_session.print(tab.to_string())
cli_session.print("Node Interfaces Security:")
tab = self.intf_security_stats_group.table(exclude_zero)
cli_session.print(tab.to_string())
cli_session.print("Node Interface LIE FSMs:")
tab = self.intf_lie_fsm_stats_group.table(exclude_zero, sort_by_description=True)
cli_session.print(tab.to_string())
示例12: update_lldp_neighbors
# 需要导入模块: import interface [as 别名]
# 或者: from interface import Interface [as 别名]
def update_lldp_neighbors(task):
url = constants.RESTCONF_ROOT + constants.OPENCONFIG_LLDP_NEIGHBORS_ENDPOINT
url = url.format(host=task.host.hostname)
response = requests.get(
url,
headers=constants.HEADERS,
auth=(task.host.username, task.host.password),
verify=False,
)
response.raise_for_status()
result = response.json()["openconfig-lldp:interface"]
device_name = task.host.name
host_interfaces = {}
task.host.data["interfaces"] = host_interfaces
for interface_info in result:
interface_name = interface_info["name"]
interface = Interface(interface_name, device_name)
neighbors = interface_info.get("neighbors")
if not neighbors:
continue
for neighbor_info in neighbors["neighbor"]:
neighbor_state = neighbor_info["state"]
remote_interface_name = neighbor_state["port-description"]
remote_device_fqdn = neighbor_state["system-name"]
remote_device_name = extract_hostname_from_fqdn(remote_device_fqdn)
remote_interface = Interface(remote_interface_name, remote_device_name)
interface.neighbors.append(remote_interface)
host_interfaces[interface.name] = interface
示例13: __init__
# 需要导入模块: import interface [as 别名]
# 或者: from interface import Interface [as 别名]
def __init__(self, interfaces: List["Interface"]) -> None:
self.interfaces = sorted(interfaces)
示例14: start_interface
# 需要导入模块: import interface [as 别名]
# 或者: from interface import Interface [as 别名]
def start_interface(self, server):
if server in self.interfaces.keys():
return
i = interface.Interface(server, self.config)
self.pending_servers.add(server)
i.start(self.queue)
return i
示例15: parse_cdp_neighbors
# 需要导入模块: import interface [as 别名]
# 或者: from interface import Interface [as 别名]
def parse_cdp_neighbors(task):
url = constants.RESTCONF_ROOT + constants.CDP_NEIGHBORS_ENDPOINT
url = url.format(host=task.host.hostname)
response = requests.get(
url,
headers=constants.HEADERS,
auth=(task.host.username, task.host.password),
verify=False,
)
response.raise_for_status()
cdp_entries = response.json().get("Cisco-IOS-XE-cdp-oper:cdp-neighbor-detail", [])
device_name = task.host.name
host_interfaces = {}
task.host.data["interfaces"] = host_interfaces
for cdp_entry in cdp_entries:
interface_name = cdp_entry["local-intf-name"]
if interface_name in host_interfaces:
interface = host_interfaces[interface_name]
else:
interface = Interface(interface_name, device_name)
host_interfaces[interface_name] = interface
remote_interface_name = cdp_entry["port-id"]
remote_device_fqdn = cdp_entry["device-name"]
remote_device_name = extract_hostname_from_fqdn(remote_device_fqdn)
remote_interface = Interface(remote_interface_name, remote_device_name)
interface.neighbors.append(remote_interface)