def range(instance, version, username, password, network, debug=0): headers = None infoblox_url = 'https://%s/wapi/%s/range?network=%s&_return_fields=network,member,failover_association,options,comment,extattrs,start_addr,end_addr' % ( instance, version, network) status_code, response_headers, cookies, http_response = rest.get_200( infoblox_url, username, password, headers, debug) return (status_code, response_headers, http_response)
def search_by_mac_address(instance, version, username, password, mac, debug=0): headers = None infoblox_url = 'https://%s/wapi/%s/search?mac_address=%s' % (instance, version, mac) status_code, response_headers, cookies, http_response = rest.get_200( infoblox_url, username, password, headers, debug) return (status_code, response_headers, http_response)
def network(instance, version, username, password, network, debug=0): headers = None infoblox_url = 'https://%s/wapi/%s/network?network=%s' % (instance, version, network) status_code, response_headers, cookies, http_response = rest.get_200( infoblox_url, username, password, headers, debug) return (status_code, response_headers, http_response)
def cmdb_from_inc(ticket_sys_id): # Read Incident record servicenow_url = 'https://%s.service-now.com/api/now/table/incident/%s?sysparm_display_value=true' % (servicenow_instance, ticket_sys_id) status_code, response_headers, response_cookies, http_response = rest.get_200(servicenow_url, servicenow_user, servicenow_pass, headers, debug) time.sleep(2) # Read CMDB record using fields retrievd from Incident record cmdb_servicenow_url = http_response['result']['cmdb_ci']['link'] short_description = http_response['result']['short_description'] status_code, response_headers, response_cookies, http_response = rest.get_200(cmdb_servicenow_url, servicenow_user, servicenow_pass, headers, debug) time.sleep(2) cmdb_ci_name = http_response['result']['name'] cmdb_ci_ip_address = http_response['result']['ip_address'] cmdb_ci_sys_id = http_response['result']['sys_id'] print ("Host is: %s - IP is %s" %(cmdb_ci_name, cmdb_ci_ip_address)) return (cmdb_ci_name, cmdb_ci_ip_address, cmdb_ci_sys_id, short_description)
def networkdevice(instance, username, password, data, debug=0): headers = { 'content-type': 'application/json', 'accept': 'application/json', 'X-CSRF-Token': 'fetch' } host_name = data['NetworkDevice']['name'] ise_url = 'https://%s:9060/ers/config/networkdevice?filter=name.CONTAINS.%s' % ( instance, host_name) status_code, response_headers, cookies, http_response = rest.get_200( ise_url, username, password, headers, debug) cookies = None if http_response['SearchResult']['resources']: ise_put_url = http_response['SearchResult']['resources'][0]['link'][ 'href'] status_code, response_headers, cookies, http_response = rest.get_200( ise_put_url, username, password, headers, debug) token = response_headers['X-CSRF-Token'] headers = { 'content-type': 'application/json', 'accept': 'application/json', 'X-CSRF-Token': token } status_code, response_headers, cookies, http_response = rest.put_200( ise_put_url, username, password, headers, data, cookies, debug) else: status_code = 666 response_headers = "NoHeaders" http_response = "NoResponse" return (status_code, response_headers, http_response)