示例#1
0
    def to_etree(self, source):
        etree.register_namespace("junos", NS_JUNOS)

        return dict_2_etree({
            "data": {
                "configuration": {
                    XML_NS:
                    'http://xml.juniper.net/xnm/1.1/xnm',
                    XML_ATTRIBUTES: {
                        "xmlns": "http://xml.juniper.net/xnm/1.1/xnm",
                        "{" + NS_JUNOS + "}commit-seconds": "1411928899",
                        "{" + NS_JUNOS + "}commit-localtime":
                        "2014-09-28 14:28:19 EDT",
                        "{" + NS_JUNOS + "}commit-user": "******"
                    },
                    "interfaces": [{
                        "interface": self.interface_to_etree(port)
                    } for port in self.configurations[source].ports],
                    "protocols":
                    extract_protocols(self.configurations[source]),
                    "vlans": [{
                        "vlan": vlan_to_etree(vlan)
                    } for vlan in self.configurations[source].vlans]
                }
            }
        })
示例#2
0
    def to_etree(self, source):
        etree.register_namespace("junos", NS_JUNOS)

        configuration = {
            XML_NS: 'http://xml.juniper.net/xnm/1.1/xnm',
            XML_ATTRIBUTES: {
                "xmlns": "http://xml.juniper.net/xnm/1.1/xnm",
                "{" + NS_JUNOS + "}commit-seconds": "1411928899",
                "{" + NS_JUNOS + "}commit-localtime":
                "2014-09-28 14:28:19 EDT",
                "{" + NS_JUNOS + "}commit-user": "******"
            }
        }

        _add_if_not_empty(
            configuration, "interfaces",
            self._extract_interfaces(self.configurations[source]))

        _add_if_not_empty(configuration, "protocols",
                          extract_protocols(self.configurations[source]))

        _add_if_not_empty(configuration, "vlans", [{
            "vlan": vlan_to_etree(vlan)
        } for vlan in self.configurations[source].vlans])

        return dict_2_etree({"data": {"configuration": configuration}})
示例#3
0
 def get_interface_information_terse(self):
     return dict_2_etree({
         "interface-information": [{
             XML_ATTRIBUTES: {
                 "style": "terse"
             }
         }] + self._port_terse(self.configurations[RUNNING]) +
         self._aggregated_port_terse(self.configurations[RUNNING])
     })
    def to_etree(self, source):
        etree.register_namespace("junos", NS_JUNOS)

        return dict_2_etree({
            "data": {
                "configuration": {
                    XML_NS: 'http://xml.juniper.net/xnm/1.1/xnm',
                    XML_ATTRIBUTES: {
                        "xmlns":"http://xml.juniper.net/xnm/1.1/xnm",
                        "{" + NS_JUNOS + "}commit-seconds": "1411928899",
                        "{" + NS_JUNOS + "}commit-localtime": "2014-09-28 14:28:19 EDT",
                        "{" + NS_JUNOS + "}commit-user": "******"
                    },
                    "interfaces": [{"interface": self.interface_to_etree(port)} for port in self.configurations[source].ports],
                    "protocols": extract_protocols(self.configurations[source]),
                    "vlans": [{"vlan": vlan_to_etree(vlan)} for vlan in self.configurations[source].vlans]
                }
            }
        })
    def to_etree(self, source):
        etree.register_namespace("junos", NS_JUNOS)

        configuration = {
            XML_NS: 'http://xml.juniper.net/xnm/1.1/xnm',
            XML_ATTRIBUTES: {
                "xmlns":"http://xml.juniper.net/xnm/1.1/xnm",
                "{" + NS_JUNOS + "}commit-seconds": "1411928899",
                "{" + NS_JUNOS + "}commit-localtime": "2014-09-28 14:28:19 EDT",
                "{" + NS_JUNOS + "}commit-user": "******"
            }
        }

        _add_if_not_empty(configuration, "interfaces", self._extract_interfaces(self.configurations[source]))

        _add_if_not_empty(configuration, "protocols", extract_protocols(self.configurations[source]))

        _add_if_not_empty(configuration, "vlans",
                         [{"vlan": vlan_to_etree(vlan)} for vlan in self.configurations[source].vlans])

        return dict_2_etree({"data": {"configuration": configuration}})
 def get_interface_information_terse(self):
     return dict_2_etree({
         "interface-information":
             [{XML_ATTRIBUTES: {"style": "terse"}}]
             + self._port_terse(self.configurations[RUNNING])
             + self._aggregated_port_terse(self.configurations[RUNNING])})