본문 바로가기

파이썬 코드

(11)
파이썬 자동화 -7- import paramiko, time, socks, re, os from getpass import getpass import pandas as pd import openpyxl from tqdm import tqdm from concurrent.futures import as_completed from openpyxl.utils.dataframe import dataframe_to_rows from concurrent.futures import ThreadPoolExecutor, as_completed import threading def juniper_parse_fixed(df, up_t): df.loc[0, "uptime"] = up_t[0] return df def parse_fix(df1): ..
파이썬 자동화 -6- import paramiko, time, socks, re, os from getpass import getpass import pandas as pd import openpyxl from openpyxl.utils.dataframe import dataframe_to_rows from concurrent.futures import ThreadPoolExecutor, as_completed import threading def juniper_parse_fixed(df, up_t): df.loc[0, "uptime"] = up_t[0] return df def re_ver(data): ex2200_match = re.search(r"ex2200", data) if ex2200_match: match2 = ..
network automation -5- import paramiko, time from getpass import getpass import re import openpyxl from openpyxl.utils.dataframe import dataframe_to_rows import pandas as pd def juniper_parse_fixed(df): fpc_rows = df[df["item"].astype(str).str.startswith("FPC")].reset_index(drop=True) ps_rows = df[df["item"].astype(str).str.startswith("Power Supply")].reset_index(drop=True) paired_rows = [] ps_idx = 0 for _, fpc_rows ..
Network Automation -4- import time import paramiko, time import socks from getpass import getpass import re import pandas as pd import os import openpyxl from openpyxl.utils.dataframe import dataframe_to_rows from concurrent.futures import ThreadPoolExecutor, as_completed import threading def juniper_parse(ip_a, u_id, u_pas, lock): try: ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy(..
networkautomation -3- import time import paramiko, time from getpass import getpass import re import pandas as pd import os import openpyxl from openpyxl.utils.dataframe import dataframe_to_rows def juniper_parse(ip_a, u_id, u_pas): try: ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(ip_a, username=u_id, password=u_pas) print("Connected Complete") #interactive shell 선..
텍스트 파일에서 주니퍼 장비 정보 파싱하기 import re import pandas as pd host = re.compile(r"Hostname: (\w{1,30})") model = re.compile(r"Model: (\w{1,7}-\w{1,7})") ver = re.compile(r"Junos: (\w{1,2}.\w{1,3})") serial = re.compile(r"FPC \d{1} \w{1,3} \d{1,2} \w{1,3}-\w{1,6} (\w{1,13})") with open("juniper_rawdata.txt") as f: f_line = f.read().splitlines() h=host.findall(str(f_line)) m=model.findall(str(f_line)) s=serial.findall(str(f_line..
Network automation -2- import time import paramiko, time import socks from getpass import getpass def juniper_parse(ip_a, u_id, u_pas,find_words): try: #socks config sock=socks.socksocket() sock.set_proxy( proxy_type=socks.SOCKS5, addr="Socks Server IP", port=Socks Server Port, username="Socks Server ID", password="Socks Server Password") #sock ssh connect sock.connect((ip_a,22)) ssh = paramiko.SSHClient() ssh.set_mis..
Network automation import time import paramiko, time import socks from getpass import getpass def juniper_parse(ip_a, u_id, u_pas, command): #socks config sock=socks.socksocket() sock.set_proxy( proxy_type=socks.SOCKS5, addr="Socks Server IP", port=Socks Server Port, username="Socks Server ID", password="Socks Server Password") #sock ssh connect sock.connect(("SSH 연결 IP",22)) ssh = paramiko.SSHClient() ssh.set_mis..