Skip to content

Commit

Permalink
Fix namespace issue with pandevice/pan_device. Fix issue with error o…
Browse files Browse the repository at this point in the history
…n job checker. Fix issue with checking members without a list.
  • Loading branch information
btorresgil committed Jul 25, 2016
1 parent f722d37 commit 92ff1e2
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions pandevice/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ def element(self):
continue
# Create an element containing the value in the instance variable
if var.vartype == "member":
for member in value:
for member in pandevice.string_or_list(value):
ET.SubElement(nextelement, 'member').text = str(member)
elif var.vartype == "entry":
try:
Expand Down Expand Up @@ -520,11 +520,10 @@ def update(self, variable):
variable (str): The name of an instance variable to update on the device
"""
import ha
pandevice = self.pandevice()
logger.debug(pandevice.hostname + ": update called on %s object \"%s\" and variable \"%s\"" %
pan_device = self.pandevice()
logger.debug(pan_device.hostname + ": update called on %s object \"%s\" and variable \"%s\"" %
(type(self), getattr(self, self.NAME), variable))
pandevice.set_config_changed()
pan_device.set_config_changed()
variables = type(self).variables()
value = getattr(self, variable)
# Get the requested variable from the class' variables tuple
Expand Down Expand Up @@ -562,19 +561,19 @@ def update(self, variable):
# Not an 'entry' variable
varpath = re.sub(regex, getattr(self, matchedvar.variable), varpath)
if value is None:
pandevice.xapi.delete(self.xpath() + "/" + varpath, retry_on_peer=self.HA_SYNC)
pan_device.xapi.delete(self.xpath() + "/" + varpath, retry_on_peer=self.HA_SYNC)
else:
element_tag = varpath.split("/")[-1]
element = ET.Element(element_tag)
if var.vartype == "member":
for member in value:
for member in pandevice.string_or_list(value):
ET.SubElement(element, 'member').text = str(member)
xpath = self.xpath() + "/" + varpath
else:
# Regular text variables
element.text = value
xpath = self.xpath() + "/" + varpath
pandevice.xapi.edit(xpath, ET.tostring(element), retry_on_peer=self.HA_SYNC)
pan_device.xapi.edit(xpath, ET.tostring(element), retry_on_peer=self.HA_SYNC)

def refresh(self, running_config=False, xml=None, refresh_children=True, exceptions=True):
"""Refresh all variables and child objects from the device
Expand Down Expand Up @@ -2442,7 +2441,7 @@ def syncreboot(self, interval=5.0, timeout=600):
# Connection errors (URLError) are ok
# Invalid cred errors are ok because FW auth system takes longer to start up
# Other errors should be raised
if not e.msg.startswith("URLError:") and not e.msg.startswith("Invalid credentials."):
if not str(e).startswith("URLError:") and not str(e).startswith("Invalid credentials."):
# Error not related to connection issue. Raise it.
raise e
else:
Expand Down

0 comments on commit 92ff1e2

Please sign in to comment.