Hirdetés
- Hivatalos a OnePlus 13 startdátuma
- Milyen hagyományos (nem okos-) telefont vegyek?
- Megtartotta Európában a 7500 mAh-t az Oppo
- OnePlus 15 - van plusz energia
- Bemutatkozott a Poco X7 és X7 Pro
- Samsung Galaxy S25 Ultra - titán keret, acélos teljesítmény
- 7600 mAh-s az aksi az iQOO új mobiljában is
- Így nézhet ki a Huawei Pura 90
- Milyen okostelefont vegyek?
- Okosóra és okoskiegészítő topik
Új hozzászólás Aktív témák
-
jerry311
nagyúr
válasz
sztanozs
#3714
üzenetére
Remelem nem maradt benne jelszo

#!/usr/bin/env python# coding=utf-8"""Python script to get NAT details from routers, and upload to SharePoint.This script feeds into Power AutomateVersion Control- 1.0 Initial Release"""# Modules to loadimport datetimeimport requestsimport crasshimport logging# Static variables 1VPN1 = "1.1.1.1"VPN3 = "2.2.2.2"NAT3 = "3.3.3.3"authfile = "/home/jerry311/credz.txt" # Uid & Passowrd are stored in an external fileurl = "https://removed-site-name.azurewebsites.net/api/upload" # Upload URL of APIquerystring = {"clientID": "removed-client-id", "docPath": "/Shared%20Documents/Daily%20NAT%20File/"} # Client ID for authentication, destination path on SharePointdebug = False # Developer debugging#Logging setuplogging.basicConfig(filename='scripts.log', filemode='a', format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')"""The format for credz.txt isusername: Uidpassword: PW"""def main():"""Main Code BlockLogs onto router, gets the output, and uploads to file on SharePoint."""# Create timestamp to be used in file nametimestamp = datetime.datetime.now().strftime("%y%m%d-%H%M%S")# Get Uid & Password from credz.txtusername, password = crassh.readauthfile(authfile)try:# Connect to router and get outputlogging.warning('CRASSH connection start')hostname = crassh.connect(NAT3, username, password, sysexit=True)output = crassh.send_command("show run | in Current configuration|extendable", hostname)crassh.disconnect()logging.warning('CRASSH finished')# Create file name to be used on SharePointtxtoutputfilename = (hostname + "-" + timestamp + ".txt")logging.warning('File name: ' + txtoutputfilename)# Create HTML payload from outputpayload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"\"; filename=\"" + str(txtoutputfilename) + "\"\r\nContent-Type: text / plain\r\n\r\n" + str(output) + "\r\n\r\n-----011000010111000001101001--\r\n"headers = {"apikey": "removed-api-key","Content-Type": "multipart/form-data; boundary=---011000010111000001101001"}logging.warning('Payload generated')# Upload to APIresponse = requests.request("POST", url, data=payload, headers=headers, params=querystring)logging.warning('API response: ' + response)# Print debug info if debug variable is set to True. Uncomment print(output) if you want to see what we collected from router. Lots of text!!!if debug:logging.debug('Hostname: ' + hostname)logging.debug('Timestamp: ' + timestamp)logging.debug('CRASSH output: ' + output)logging.debug('File name: ' + txtoutputfilename)logging.debug('Payload ' + payload)logging.debug('API response: ' + response)except:logging.warning('Something went wrong')pass # If something fails, move onto next router in the list.# If run from interpreter, run main code function.if __name__ == "__main__":main()
Új hozzászólás Aktív témák
- sziku69: Fűzzük össze a szavakat :)
- AMD Ryzen 9 / 7 / 5 / 3 5***(X) "Zen 3" (AM4)
- NVIDIA GeForce RTX 5080 / 5090 (GB203 / 202)
- Hivatalos a OnePlus 13 startdátuma
- VR topik
- Amit látnod kell 80’ – 90’ évek, egész estét betöltő mozi filmjei.
- Milyen hagyományos (nem okos-) telefont vegyek?
- Megtartotta Európában a 7500 mAh-t az Oppo
- Az elmúlt 30 év legjobb processzorai
- PlayStation 5
- További aktív témák...
- BESZÁMÍTÁS! ASRock X870 R9 7950X3D 32GB DDR5 1TB SSD RTX 4090 24GB Be quiet Pure Base 501 LX white
- Iphone Xs 64GB 100% (3hónap Garancia)
- Telefon felvásárlás!! Samsung Galaxy A14/Samsung Galaxy A34/Samsung Galaxy A54
- Ulefone RugKing
- Dell USB-C, Thunderbolt 3, TB3, TB4 dokkolók (K20A) WD19TB/ WD19TBS/ WD22TB4, (K16A) TB16/ TB18DC
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest



