def _determine_new_release(self): ''' Helper function to figure out the latest version and release date from the firewall. ''' api_instance = PanXapi(hostname=self._ip, api_username=self._username, api_password=self._password) # Init status to nothing api_instance.status = None # Keep requesting until we get a successful response while api_instance.status != 'success': logging.info("Trying op command.") api_instance.op('show system info', cmd_xml=True) sleep(1) logging.debug(f"XML is: {api_instance.xml_document}") # Parse version and date out of document soup = BeautifulSoup(api_instance.xml_document, features='html5lib') logging.debug(api_instance.xml_document) version_el = soup.find('av-version') date_el = soup.find('av-release-date') self.latest_version = version_el.text # Reformat date to make sure it's the same as everything else I put in Elastic. dateobj = parser.parse(date_el.text) self.latest_date = format_datetime(dateobj) logging.debug(f"Firewall says the latest version is {self.latest_version}, " f"released {self.latest_date}.")
def __init__(self): self.hostname = raw_input('IP Address:') self.username = raw_input('Username:'******'Password:'******'Do you want to generate an API Key:?') self.port = 22 self.connection_info = PanXapi.keygen(PanXapi(api_username=self.username, api_password=self.password, hostname=self.hostname)) self.filename = open(raw_input('File Path/Name:'), 'w') self.words = self.filename.write(self.connection_info)
def __init__(self): self.hostname = raw_input('IP Address:') self.username = raw_input('Username:'******'Password:'******'Do you want to generate an API Key:?') self.port = 22 self.connection_info = PanXapi.keygen(PanXapi(api_username=self.username, api_password=self.password, hostname=self.hostname)) self.show = PanXapi.show(PanXapi(api_username=self.username, api_password=self.password, hostname=self.hostname) , xpath='/config/devices/entry/network/interface')
def __init__(self): self.hostname = raw_input('IP Address:') self.username = raw_input('Username:'******'Password:'******'Do you want to generate an API Key:?') self.port = 22 self.connection_info = PanXapi.keygen(PanXapi(api_username=self.username, api_password=self.password, hostname=self.hostname)) self.filename = open(raw_input('File Path/Name:'), 'w') self.words = self.filename.write(self.connection_info) self.show = PanXapi.show(PanXapi(api_username=self.username, api_password=self.password, hostname=self.hostname), xpath='/config/devices/entry/network/interface') self.show_file = open(raw_input('What file do you want the show command to?:'), 'w') self.show_write = self.show_file.write(str(self.show))
def api_call(self): if (self.generate_key == 'y') or (self.generate_key == 'Y') or \ (self.generate_key == 'yes') or (self.generate_key == 'YES') or \ (self.generate_key == 'Yes'): PanXapi.keygen(self.connection_info) PanXapi.show(self.show) else: PanXapi.show(self.show)
def api_call(self): if (self.generate_key == 'y') or (self.generate_key == 'Y') or \ (self.generate_key == 'yes') or (self.generate_key == 'YES') or (self.generate_key == 'Yes'): filename = open(raw_input('Filename/Path:'), 'w') filename.write(self.connection_info) show_file = open(raw_input('What file do you want to write the show command to?:'), 'w') show_file.write(self.show) PanXapi.keygen(self.connection_info) PanXapi.show(self.show) if (self.generate_key == 'n') or (self.generate_key == 'N') or (self.generate_key == 'No') or (self.generate_key == 'NO'): show_file = open(raw_input('What file do you want to write the show command to?:'), 'w') show_file.write(self.show) PanXapi.show(self.show)
def main(): module = AnsibleModule( argument_spec=dict( ip_address=dict(required=True), username=dict( required=True, no_log=True ), # Sensitive Parameter so passwords or keys do not end up in logs password=dict( required=True, no_log=True ) # Sensitive Parameter so passwords or keys do not end up in logs ), supports_check_mode=False) username = module.params['username'] password = module.params['password'] ip_address = module.params['ip_address'] panorama = PanXapi(api_username=username, password=password, hostname=ip_address) # Exit the module and return some value module.exit_json(changed=True, info="complete")
def main(): PanXapi.keygen( PanXapi(api_username='******', api_password='******', hostname='172.16.203.251')) PanXapi.port = 22