/usr/lib/python2.7/dist-packages/jnpr/junos/cfg/phyport/switch.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 | # 3rd-party
from lxml.builder import E
# local
from jnpr.junos.cfg import Resource
from jnpr.junos import JXML
from jnpr.junos.cfg.phyport.base import PhyPortBase
class PhyPortSwitch(PhyPortBase):
PORT_SPEED = {
'auto': 'auto-negotiation',
'10m': 'ethernet-10m',
'100m': 'ethernet-100m',
'1g': 'ethernet-1g'
}
# -----------------------------------------------------------------------
# XML readers
# -----------------------------------------------------------------------
def _xml_to_py(self, has_xml, has_py):
PhyPortBase._xml_to_py(self, has_xml, has_py)
# speed, duplex, loopback are all under 'ether-options'
ethopts = has_xml.find('ether-options')
if ethopts is None:
return
if ethopts.find('loopback') is not None:
has_py['loopback'] = True
speed = ethopts.find('speed')
if speed is not None:
# take the first child element
has_py['speed'] = speed[0].tag
PhyPortBase._set_invert(has_py, 'speed', self.PORT_SPEED)
Resource.copyifexists(ethopts, 'link-mode', has_py, 'duplex')
if 'duplex' in has_py:
PhyPortBase._set_invert(has_py, 'duplex', self.PORT_DUPLEX)
# -----------------------------------------------------------------------
# XML writers
# -----------------------------------------------------------------------
def _xml_hook_build_change_begin(self, xml):
if any([this in self.should for this in ['speed', 'duplex',
'loopback']]):
self._ethopts = E('ether-options')
xml.append(self._ethopts)
def _xml_change_speed(self, xml):
speed_tag = self.PORT_SPEED.get(self.speed)
add_this = E.speed(
JXML.DEL) if speed_tag is None else E.speed(
E(speed_tag))
self._ethopts.append(add_this)
return True
def _xml_change_duplex(self, xml):
value = self.PORT_DUPLEX.get(self.duplex)
Resource.xml_set_or_delete(self._ethopts, 'link-mode', value)
return True
def _xml_change_loopback(self, xml):
self._ethopts.append(
Resource.xmltag_set_or_del(
'loopback',
self.loopback))
return True
|