Skip to content

Commit

Permalink
Merge ef1ad03 into 930970e
Browse files Browse the repository at this point in the history
  • Loading branch information
balasankarrajaguru committed Sep 9, 2021
2 parents 930970e + ef1ad03 commit 88bd875
Show file tree
Hide file tree
Showing 22 changed files with 106 additions and 100 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
language: python
matrix:
include:
- python: 2.7
dist: trusty
- python: 3.5
dist: trusty
- python: 3.6
Expand Down
10 changes: 5 additions & 5 deletions lib/jnpr/junos/cfg/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,22 +196,22 @@ def catalog(self):

@property
def D(self):
""" returns the Device object bound to this resource/manager """
"""returns the Device object bound to this resource/manager"""
return self._junos

@property
def R(self):
""" returns the Device RPC meta object """
"""returns the Device RPC meta object"""
return self._junos.rpc

@property
def M(self):
""" returns the :Resource: manager associated to this resource """
"""returns the :Resource: manager associated to this resource"""
return self._manager

@property
def P(self):
""" returns the parent of the associated Junos object """
"""returns the parent of the associated Junos object"""
return self._parent

# -----------------------------------------------------------------------
Expand Down Expand Up @@ -554,7 +554,7 @@ def __repr__(self):
# ---------------------------------------------------------------------

def __iter__(self):
""" iterate through each Resource in the Manager list """
"""iterate through each Resource in the Manager list"""
for name in self.list:
yield self[name]

Expand Down
2 changes: 1 addition & 1 deletion lib/jnpr/junos/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def _tty_logout(self):
self._tty.logout()

def zeroize(self):
""" perform device ZEROIZE actions """
"""perform device ZEROIZE actions"""
logger.info("zeroize : ZEROIZE device, rebooting")
self._tty.nc.zeroize()
self._skip_logout = True
Expand Down
8 changes: 8 additions & 0 deletions lib/jnpr/junos/dcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from jnpr.junos.device import _Connection
from jnpr.junos.rpcmeta import _RpcMetaExec
from jnpr.junos.factcache import _FactCache
from jnpr.junos import exception as EzErrors
from jnpr.junos import jxml as JXML

from jnpr.junos.decorators import ignoreWarnDecorator
Expand Down Expand Up @@ -144,6 +145,13 @@ def _rpc_reply(self, rpc_cmd_e, *args, **kwargs):
di = self._grpc_types_pb2.DeviceInfo(UUID=self._dev_uuid)
exec = self._grpc_dcs_pb2.GetRequest(command=[rpc_cmd], device_info=di)
res = self._grpc_conn_stub.Get(request=exec, metadata=self._grpc_meta_data)
if res.error_code != self._grpc_types_pb2.NoError:
raise EzErrors.RpcError(
cmd=rpc_cmd,
errs="error-code: '{}' error: '{}'".format(
self._grpc_types_pb2.ErrorCode.Name(res.error_code), res.error
),
)
result = res.result[0].result
reply = RPCReply(result)
errors = reply.errors
Expand Down
8 changes: 4 additions & 4 deletions lib/jnpr/junos/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def ofacts(self):

@ofacts.setter
def ofacts(self, value):
""" read-only property """
"""read-only property"""
raise RuntimeError("facts is read-only!")

# ------------------------------------------------------------------------
Expand Down Expand Up @@ -339,7 +339,7 @@ def master(self):

@master.setter
def master(self, value):
""" read-only property """
"""read-only property"""
raise RuntimeError("master is read-only!")

# ------------------------------------------------------------------------
Expand Down Expand Up @@ -373,7 +373,7 @@ def uptime(self):

@uptime.setter
def uptime(self, value):
""" read-only property """
"""read-only property"""
raise RuntimeError("uptime is read-only!")

# ------------------------------------------------------------------------
Expand Down Expand Up @@ -438,7 +438,7 @@ def re_name(self):

@re_name.setter
def re_name(self, value):
""" read-only property """
"""read-only property"""
raise RuntimeError("re_name is read-only!")

def _sshconf_lkup(self):
Expand Down
8 changes: 4 additions & 4 deletions lib/jnpr/junos/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,22 +219,22 @@ def __init__(self, dev, msg=None):

@property
def user(self):
""" login user-name """
"""login user-name"""
return self.dev.user

@property
def host(self):
""" login host name/ipaddr """
"""login host name/ipaddr"""
return self.dev.hostname

@property
def port(self):
""" login SSH port """
"""login SSH port"""
return self.dev._port

@property
def msg(self):
""" login SSH port """
"""login SSH port"""
return self._orig

def __repr__(self):
Expand Down
12 changes: 6 additions & 6 deletions lib/jnpr/junos/factory/cfgtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def required_keys(self):

@property
def keys_required(self):
""" True/False - if this Table requires keys """
"""True/False - if this Table requires keys"""
return self.required_keys is not None

# -----------------------------------------------------------------------
Expand Down Expand Up @@ -258,15 +258,15 @@ def _validate_min_max_value(field_name, value, opt):
_validate_min_max_value(field_name, value, opt)

def _grindkey(self, key_xpath, key_value):
""" returns list of XML elements for key values """
"""returns list of XML elements for key values"""
simple = lambda: [E(key_xpath.replace("_", "-"), key_value)]
composite = lambda: [
E(xp.replace("_", "-"), xv) for xp, xv in zip(key_xpath, key_value)
]
return simple() if isinstance(key_xpath, str) else composite()

def _grindxpath(self, key_xpath, key_value):
""" returns xpath elements for key values """
"""returns xpath elements for key values"""
simple = lambda: "[{}='{}']".format(key_xpath.replace("_", "-"), key_value)
composite = lambda: "[{}]".format(
" and ".join(
Expand All @@ -279,7 +279,7 @@ def _grindxpath(self, key_xpath, key_value):
return simple() if isinstance(key_xpath, str) else composite()

def _grindfield(self, xpath, value):
""" returns list of xml elements for field name-value pairs """
"""returns list of xml elements for field name-value pairs"""
lst = []
if isinstance(value, (list, tuple, set)):
for v in value:
Expand Down Expand Up @@ -359,7 +359,7 @@ def _encode_xpath(self, top, lst):
return dot

def _keyspec(self):
""" returns tuple (keyname-xpath, item-xpath) """
"""returns tuple (keyname-xpath, item-xpath)"""
return (self._data_dict.get("key", "name"), self._data_dict[self._type])

def _init_field(self):
Expand All @@ -371,7 +371,7 @@ def _init_field(self):
self.__dict__[fname] = opt["default"] if "default" in opt else None

def _mandatory_check(self):
""" Mandatory checks for set table/view """
"""Mandatory checks for set table/view"""
for key in self.key_field:
value = getattr(self, key)
if value is None:
Expand Down
22 changes: 11 additions & 11 deletions lib/jnpr/junos/factory/cmdtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,27 +170,27 @@ def get(self, *vargs, **kvargs):

@property
def D(self):
""" the Device instance """
"""the Device instance"""
return self._dev

@property
def CLI(self):
""" the Device.cli instance """
"""the Device.cli instance"""
return self.D.cli

@property
def RPC(self):
""" the Device.rpc instance """
"""the Device.rpc instance"""
return self.D.rpc

@property
def view(self):
""" returns the current view assigned to this table """
"""returns the current view assigned to this table"""
return self._view

@view.setter
def view(self, cls):
""" assigns a new view to the table """
"""assigns a new view to the table"""
if cls is None:
self._view = None
return
Expand All @@ -206,7 +206,7 @@ def hostname(self):

@property
def key_list(self):
""" the list of keys, as property for caching """
"""the list of keys, as property for caching"""
return self._key_list

# -------------------------------------------------------------------------
Expand All @@ -229,7 +229,7 @@ def _clearkeys(self):
# ------------------------------------------------------------------------

def _keys(self):
""" return a list of data item keys from the data string """
"""return a list of data item keys from the data string"""

return self.output.keys()

Expand All @@ -247,7 +247,7 @@ def keys(self):
# ------------------------------------------------------------------------

def values(self):
""" returns list of table entry items() """
"""returns list of table entry items()"""

self._assert_data()
return self.output.values()
Expand All @@ -257,7 +257,7 @@ def values(self):
# ------------------------------------------------------------------------

def items(self):
""" returns list of tuple(name,values) for each table entry """
"""returns list of tuple(name,values) for each table entry"""
return self.output.items()

def to_json(self):
Expand Down Expand Up @@ -287,7 +287,7 @@ def __len__(self):
return len(self.keys())

def __iter__(self):
""" iterate over each time in the table """
"""iterate over each time in the table"""
self._assert_data()

for key, value in self.output.items():
Expand All @@ -311,7 +311,7 @@ def __getitem__(self, value):
return self.output[value]

def __contains__(self, key):
""" membership for use with 'in' """
"""membership for use with 'in'"""
return bool(key in self.keys())

# ------------------------------------------------------------------------
Expand Down
16 changes: 8 additions & 8 deletions lib/jnpr/junos/factory/cmdview.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,45 +22,45 @@ class CMDView(object):

@property
def T(self):
""" return the Table instance for the View """
"""return the Table instance for the View"""
return self._table

@property
def D(self):
""" return the Device instance for this View """
"""return the Device instance for this View"""
return self.T.D

@property
def xml(self):
""" returns the XML associated to the item """
"""returns the XML associated to the item"""
return self._xml

# -------------------------------------------------------------------------
# METHODS
# -------------------------------------------------------------------------

def keys(self):
""" list of view keys, i.e. field names """
"""list of view keys, i.e. field names"""
return self.FIELDS.keys()

def values(self):
""" list of view values """
"""list of view values"""
return [getattr(self, field) for field in self.keys()]

def items(self):
""" list of tuple(key,value) """
"""list of tuple(key,value)"""
return zip(self.keys(), self.values())

def asview(self, view_cls):
""" create a new View object for this item """
"""create a new View object for this item"""
return view_cls(self._table, self._xml)

# -------------------------------------------------------------------------
# OVERLOADS
# -------------------------------------------------------------------------

def __repr__(self):
""" returns the name of the View with the associate item name """
"""returns the name of the View with the associate item name"""
return "%s:%s" % (self.__class__.__name__, self.name)

def __getitem__(self, name):
Expand Down

0 comments on commit 88bd875

Please sign in to comment.