Skip to content

Commit

Permalink
added committing of config for the last supported device, paloalto
Browse files Browse the repository at this point in the history
  • Loading branch information
ctomkow committed Jan 24, 2020
1 parent 9edde8f commit 44b06b2
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions device_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,25 +138,33 @@ def send_config_set(self, set_list):
return self.device_connection.send_config_set(set_list, exit_config_mode=True)
elif self.device_type == 'sentry_pdu':
return self.device_connection.send_config_set(set_list, exit_config_mode=False)
elif self.device_type == 'paloalto_panos':
try:
return self.device_connection.send_config_set(set_list, exit_config_mode=False)
except OSError:
return "Did not find expected pattern. Likely nothing to commit!"
else:
pass

def save_config_and_exit(self):

buf = ""
try:
if self.device_type == 'juniper_junos':
buf += self.device_connection.commit(and_quit=True)
elif self.device_type == 'cisco_ios':
buf += self.device_connection.save_config()
elif self.device_type == 'hp_procurve':
buf += self.device_connection.save_config()
elif self.device_type == 'sentry_pdu':

if self.device_type == 'juniper_junos':
buf += self.device_connection.commit(and_quit=True)
elif self.device_type == 'cisco_ios':
buf += self.device_connection.save_config()
elif self.device_type == 'hp_procurve':
buf += self.device_connection.save_config()
elif self.device_type == 'sentry_pdu':
try: # e.g. sentry_pdu uses netmiko's accedian device - it doesn't impl save_config as config is auto-saved
buf += self.device_connection.save_config()
else:
pass
except NotImplementedError: # e.g. sentry_pdu uses netmiko's accedian device and it doesn't impl save_config
return buf
except NotImplementedError:
return buf
elif self.device_type == 'paloalto_panos':
buf += self.device_connection.commit()
else:
pass

buf += self.device_connection.exit_config_mode()
return buf
Expand Down

0 comments on commit 44b06b2

Please sign in to comment.