- Google Pixel topik
- Samsung Galaxy S25 Ultra - titán keret, acélos teljesítmény
- Samsung Galaxy S25 - végre van kicsi!
- Mobil flották
- Sony WF-1000XM6 – ez évi etalon?
- Samsung Galaxy A56 - megbízható középszerűség
- iPhone topik
- Fotók, videók mobillal
- Megérkezett a Mi Pad 4 és a Redmi 6 Pro
- Elődje legnagyobb hibáját javítja az iPhone 17e
Ú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
- Anime filmek és sorozatok
- NVIDIA GeForce RTX 5070 / 5070 Ti (GB205 / 203)
- Azonnali informatikai kérdések órája
- Programozás topic
- WLAN, WiFi, vezeték nélküli hálózat
- Google Pixel topik
- Melyik tápegységet vegyem?
- Samsung Galaxy S25 Ultra - titán keret, acélos teljesítmény
- Samsung Galaxy Felhasználók OFF topicja
- Le Mans Ultimate
- További aktív témák...
- BESZÁMÍTÁS! MSI B450M R3 4100 8GB DDR4 240GB SSD GTX 1050Ti 4GB Asus Vento AD DeepCool 400W
- BESZÁMÍTÁS! ASRock B450M R5 5600X 16GB DDR4 512GB SSD RTX 4070 12GB DeepCool CC560 CoolerMaster 750W
- BESZÁMÍTÁS! MSI B760 i7 12700K 64GB DDR4 512GB SSD RX 7800XT 16GB Zalman S2 TG GIGABYTE 750W
- BESZÁMÍTÁS! ASUS B365M i5 9600KF 16GB DDR4 512GB SSD RX 5600XT 6GB Zalman S2 TG GAMDIAS 650W
- Apple iPhone 12 mini 64GB - 84% akku
- HIBÁTLAN iPhone SE 2020 64GB Black-1 ÉV GARANCIA - Kártyafüggetlen, MS4001
- HIBÁTLAN iPhone 14 Plus 128GB Yellow -1 ÉV GARANCIA - Kártyafüggetlen, MS4472
- Veszünk: PS5 Fat/Slim/Digital/Pro konzolt, játékokat, Portalt stb. Kérj ajánlatot!
- ÚJ könyv: Gloviczki Zoltán - A holnapután iskolája
- Bomba ár! Lenovo X1 Tab G3 - i5-8350U I 8GB I 256SSD I 13" 2K+ IPS Touch I Cam I W11 I Garancia
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest



