/usr/lib/python2.7/dist-packages/jnpr/junos/cfg/phyport/base.py is in python-junos-eznc 2.0.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | # 3rd-party
from lxml.builder import E
# local module
from jnpr.junos.cfg.resource import Resource
class PhyPortBase(Resource):
"""
[edit interfaces <name>]
Resource name: str
<name> is the interface-name (IFD), e.g. 'ge-0/0/0'
"""
PROPERTIES = [
'admin', # True
'description', # str
'speed', # ['10m','100m','1g','10g']
'duplex', # ['full','half']
'mtu', # int
'loopback', # True
'$unit_count' # number of units defined
]
PORT_DUPLEX = {
'full': 'full-duplex',
'half': 'half-duplex'
}
@classmethod
def _set_invert(cls, in_this, item, from_this):
from_item = in_this[item]
in_this[item] = [
_k for _k,
_v in from_this.items() if _v == from_item][0]
# -----------------------------------------------------------------------
# XML readers
# -----------------------------------------------------------------------
def _xml_at_top(self):
return E.interfaces(E.interface(
E.name(self._name)
))
def _xml_at_res(self, xml):
return xml.find('.//interface')
def _xml_to_py(self, has_xml, has_py):
# common to all subclasses
Resource._r_has_xml_status(has_xml, has_py)
has_py['admin'] = bool(has_xml.find('disable') is None)
Resource.copyifexists(has_xml, 'description', has_py)
Resource.copyifexists(has_xml, 'mtu', has_py)
has_py['$unit_count'] = len(has_xml.findall('unit'))
# -----------------------------------------------------------------------
# XML writers
# -----------------------------------------------------------------------
# description handed by Resource
def _xml_change_admin(self, xml):
xml.append(
Resource.xmltag_set_or_del(
'disable',
(self.admin == False)))
return True
def _xml_change_mtu(self, xml):
Resource.xml_set_or_delete(xml, 'mtu', self.mtu)
return True
# -----------------------------------------------------------------------
# Manager List, Catalog
# -----------------------------------------------------------------------
def _r_list(self):
got = self.R.get_interface_information(
media=True,
interface_name="[xgf]e*")
self._rlist = [
name.text.strip() for name in got.xpath('physical-interface/name')]
|