pynos package¶
Subpackages¶
- pynos.versions package
- Subpackages
- pynos.versions.base package
- Submodules
- pynos.versions.base.bgp module
- pynos.versions.base.fabric_service module
- pynos.versions.base.firmware module
- pynos.versions.base.interface module
- pynos.versions.base.lldp module
- pynos.versions.base.services module
- pynos.versions.base.snmp module
- pynos.versions.base.system module
- pynos.versions.base.vcs module
- Module contents
- pynos.versions.ver_5 package
- Subpackages
- pynos.versions.ver_5.ver_5_0_1 package
- Submodules
- pynos.versions.ver_5.ver_5_0_1.bgp module
- pynos.versions.ver_5.ver_5_0_1.fabric_service module
- pynos.versions.ver_5.ver_5_0_1.firmware module
- pynos.versions.ver_5.ver_5_0_1.interface module
- pynos.versions.ver_5.ver_5_0_1.lldp module
- pynos.versions.ver_5.ver_5_0_1.services module
- pynos.versions.ver_5.ver_5_0_1.snmp module
- pynos.versions.ver_5.ver_5_0_1.system module
- pynos.versions.ver_5.ver_5_0_1.vcs module
- Module contents
- pynos.versions.ver_5.ver_5_0_1 package
- Module contents
- Subpackages
- pynos.versions.ver_6 package
- Subpackages
- pynos.versions.ver_6.ver_6_0_1 package
- Submodules
- pynos.versions.ver_6.ver_6_0_1.bgp module
- pynos.versions.ver_6.ver_6_0_1.fabric_service module
- pynos.versions.ver_6.ver_6_0_1.firmware module
- pynos.versions.ver_6.ver_6_0_1.interface module
- pynos.versions.ver_6.ver_6_0_1.lldp module
- pynos.versions.ver_6.ver_6_0_1.services module
- pynos.versions.ver_6.ver_6_0_1.snmp module
- pynos.versions.ver_6.ver_6_0_1.system module
- pynos.versions.ver_6.ver_6_0_1.vcs module
- Module contents
- pynos.versions.ver_6.ver_6_0_1 package
- Module contents
- Subpackages
- pynos.versions.ver_7 package
- pynos.versions.base package
- Module contents
- Subpackages
Submodules¶
pynos.device module¶
Copyright 2015 Brocade Communications Systems, Inc.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
class
pynos.device.Device(**kwargs)[source]¶ Bases:
objectDevice object holds the state for a single NOS device.
-
bgp¶ BGP related actions and attributes.
-
interface¶ Interface related actions and attributes.
-
snmp¶ SNMP related actions and attributes.
-
lldp¶ LLDP related actions and attributes.
-
system¶ System level actions and attributes.
-
close()[source]¶ Close NETCONF session.
Parameters: None – Returns: None Raises: NoneExamples
>>> import pynos.device >>> conn = ('10.24.39.211', '22') >>> auth = ('admin', 'password') >>> dev = pynos.device.Device(conn=conn, auth=auth) >>> dev.connection True >>> dev.close() <?xml...<rpc-reply...<ok/>... >>> dev.connection False
-
connection¶ Poll if object is still connected to device in question.
Parameters: None – Returns: True if connected, False if not. Return type: bool Raises: None
-
find_interface_by_mac(**kwargs)[source]¶ Find the interface through which a MAC can be reached.
Parameters: mac_address (str) – A MAC address in ‘xx:xx:xx:xx:xx:xx’ format. Returns: a list of mac table data. Return type: list[dict] Raises: KeyError– if mac_address is not specified.Examples
>>> from pprint import pprint >>> import pynos.device >>> conn = ('10.24.39.211', '22') >>> auth = ('admin', 'password') >>> with pynos.device.Device(conn=conn, auth=auth) as dev: ... x = dev.find_interface_by_mac( ... mac_address='10:23:45:67:89:ab') ... pprint(x) [{'interface'...'mac_address'...'state'...'type'...'vlan'...}]
-
firmware_version¶ Returns firmware version.
Parameters: None – Returns: Dictionary Raises: None
-
mac_table¶ list[dict] – the MAC table of the device.
-
pynos.utilities module¶
Copyright 2015 Brocade Communications Systems, Inc.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
pynos.utilities.merge_xml(first_doc, second_doc)[source]¶ Merges two XML documents.
Parameters: - first_doc (str) – First XML document. second_doc is merged into this document.
- second_doc (str) – Second XML document. It is merged into the first.
Returns: The merged document.
Return type: XML Document
Raises: NoneExample
>>> import pynos.utilities >>> import lxml >>> import xml >>> x = xml.etree.ElementTree.fromstring('<config />') >>> y = lxml.etree.fromstring('<config><hello /></config>') >>> x = pynos.utilities.merge_xml(x, y)
-
pynos.utilities.print_xml_string(element_tree)[source]¶ Prints the string representation of an XML Element.
Parameters: element_tree (Element) – XML Element to be returned. If sent as a str, this function will attempt to convert it to anElement.Returns: An XML Element. Return type: Element Raises: AttributeError– if element_tree is not of typeElement.Examples
>>> import pynos.utilities >>> import xml.etree.ElementTree as ET >>> pynos.utilities.print_xml_string(ET.Element('config')) <config /> >>> pynos.utilities.print_xml_string( ... ['hodor']) Traceback (most recent call last): AttributeError
-
pynos.utilities.return_xml(element_tree)[source]¶ Return an XML Element.
Parameters: element_tree (Element) – XML Element to be returned. If sent as a str, this function will attempt to convert it to anElement.Returns: An XML Element. Return type: Element Raises: TypeError– if element_tree is not of typeElementand it cannot be converted from astr.Examples
>>> import pynos.utilities >>> import xml.etree.ElementTree as ET >>> ele = pynos.utilities.return_xml(ET.Element('config')) >>> assert isinstance(ele, ET.Element) >>> ele = pynos.utilities.return_xml('<config />') >>> assert isinstance(ele, ET.Element) >>> ele = pynos.utilities.return_xml( ... ['hodor']) Traceback (most recent call last): TypeError
-
pynos.utilities.valid_interface(int_type, name)[source]¶ Validates an interface type and name.
Parameters: - int_type (str) – Interface type. Examples: gigabitethernet, tengigabitethernet, port_channel.
- name (str) – Port designator. Examples: 225/0/1, 1/0/1, 1.
Returns: Trueif it is a valid interface.Falseif not.Return type: bool
Raises: NoneExamples
>>> import pynos.utilities >>> int_type = 'tengigabitethernet' >>> name = '225/0/1' >>> pynos.utilities.valid_interface(int_type, name) True >>> name = '5/0' >>> pynos.utilities.valid_interface(int_type, name) False >>> int_type = 'port_channel' >>> name = '1' >>> pynos.utilities.valid_interface(int_type, name) True >>> int_type = 'port_channel' >>> name = '1/0' >>> pynos.utilities.valid_interface(int_type, name) False
-
pynos.utilities.valid_physical_name(name)[source]¶ Validates a physical interface.
Do not use this method directly. Use
valid_interfaceinstead.Parameters: name (str) – Port designator. Examples: 225/0/1, 1/0/1. Returns: Trueif it is a valid physical interface.Falseif not.Return type: bool Raises: None
-
pynos.utilities.valid_port_channel_name(name)[source]¶ Validates a Port-Channel.
Do not use this method directly. Use
valid_interfaceinstead.Parameters: name (str) – Port designator. Examples: 1, 768, 3476. Returns: Trueif it is a valid port-channel.Falseif not.Return type: bool Raises: None
-
pynos.utilities.valid_vlan_id(vlan_id, extended=True)[source]¶ Validates a VLAN ID.
Parameters: - vlan_id (integer) – VLAN ID to validate. If passed as
str, it will be cast toint. - extended (bool) – If the VLAN ID range should be considered extended for Virtual Fabrics.
Returns: Trueif it is a valid VLAN ID.Falseif not.Return type: bool
Raises: NoneExamples
>>> import pynos.utilities >>> vlan = '565' >>> pynos.utilities.valid_vlan_id(vlan) True >>> extended = False >>> vlan = '6789' >>> pynos.utilities.valid_vlan_id(vlan, extended=extended) False >>> pynos.utilities.valid_vlan_id(vlan) True
- vlan_id (integer) – VLAN ID to validate. If passed as
Module contents¶
Copyright 2015 Brocade Communications Systems, Inc.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.