Python ncclient.xml_.new_ele() Examples
The following are 7
code examples of ncclient.xml_.new_ele().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
ncclient.xml_
, or try the search function
.
Example #1
Source File: standard.py From netman with Apache License 2.0 | 6 votes |
def interface_update(self, name, unit, attributes=None, vlan_members=None): content = to_ele(""" <interface> <name>{interface}</name> <unit> <name>{unit}</name> <family> <ethernet-switching> </ethernet-switching> </family> </unit> </interface> """.format(interface=name, unit=unit)) ethernet_switching_node = first(content.xpath("//ethernet-switching")) for attribute in (attributes if attributes is not None else []): ethernet_switching_node.append(attribute) if vlan_members: vlan = new_ele("vlan") for attribute in vlan_members: vlan.append(attribute) ethernet_switching_node.append(vlan) return content
Example #2
Source File: ncclient3.py From pyplus_course with Apache License 2.0 | 5 votes |
def main(): """Test code that is testing NETCONF.""" conn = manager.connect( host="srx2.lasthop.io", username="pyclass", password=getpass(), device_params={"name": "junos"}, hostkey_verify=False, allow_agent=False, look_for_keys=False, port=830, timeout=60, ) ipdb.set_trace() rpc = new_ele("get-software-information") nc_out = conn.rpc(rpc) # It is an XML like thing print(nc_out.tostring.decode()) print(nc_out.find(".//product-name")) print(nc_out.find(".//product-name").text) print(nc_out.find(".//product-model").text) config = conn.get_config(source="running") config_xml = config.data_xml print(config_xml)
Example #3
Source File: mx.py From netman with Apache License 2.0 | 5 votes |
def all_vlans(self): return new_ele("bridge-domains")
Example #4
Source File: base.py From netman with Apache License 2.0 | 5 votes |
def _push(self, configuration): config = new_ele('config') config.append(configuration.root) self.logger.info("Sending edit : {}".format(to_xml(config))) try: self.netconf.edit_config(target="candidate", config=config) except RPCError as e: self.logger.info("An RPCError was raised : {}".format(e)) raise
Example #5
Source File: base.py From netman with Apache License 2.0 | 5 votes |
def query(self, *args): filter_node = new_ele("filter") conf = sub_ele(filter_node, "configuration") for arg in args: conf.append(arg()) return self.netconf.get_config(source="candidate" if self.in_transaction else "running", filter=filter_node)
Example #6
Source File: base.py From netman with Apache License 2.0 | 5 votes |
def all_interfaces(): return new_ele("interfaces")
Example #7
Source File: base.py From netman with Apache License 2.0 | 5 votes |
def __init__(self): self.root = new_ele("configuration") self.vlans_root = None self.interfaces_root = None self.protocols_root = None self.sub_protocol_roots = {}