Пример #1
0
def boot_image(host, id, pw, image_path) :
    cli("configure terminal ; interface ethernet 1/24 ; description python auto_provisioning")
    cli("configure terminal ; interface ethernet 1/24 ; switchport ; switchport mode trunk ; \
    switchport trunk allowed vlan 500")

    print "Auto_provision을 위한 준비를 하고 있습니다."
    tm = 0
    while tm < 30:
	sys.stdout.write(".")
	sys.stdout.flush()        
	time.sleep(1)
	tm +=1
    cli("ping %s count 1"%host) 
    print "\n"

    file_index = image_path.rfind("/") + 1
    image_file_name = image_path[file_index: len(image_path)]
    ftp_image_dir = image_path[0: file_index]
    local_dir = "/bootflash/"
    ftp.download(host, id, pw, ftp_image_dir, local_dir, image_file_name )

    cli("configure terminal ; no event manager applet Auto-Provisioning")
    cli("configure terminal ; interface ethernet 1/24 ; no description ; no switchport")
    cli("configure terminal ; boot nxos bootflash:///%s" % image_file_name)
    print "다음에 부팅될 nxos 버전 :", cli("show running-config | include nxos")
Пример #2
0
def client(address):
    print('connecting ', address)
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.connect(address)
    urls = get_urls()

    # let vps download the contents you want
    for url in urls:
        sock.sendall(
            pickle.dumps((url, constants.OPTION_DOWNLOAD_FILE)) +
            constants.END_SYMBOL)
        print('Server succeeds to download url:{0}, filename:{1}'.format(
            url, receive(sock, constants.END_SYMBOL)))

    # using ftp to download contents from vps
    for filename in file_list:
        print('Downloading file:%s  ...' % filename)
        ftp.download(filename)

    # when downloaded, delete them all, since the limited disk space of vps
    sock.sendall(
        pickle.dumps((file_list, constants.OPTION_DELETE_FILES)) +
        constants.END_SYMBOL)
    sock.close()
Пример #3
0
if web_data == {} :
	print(ftp.col.minus, 'searching web')
	ftp.explore(web_data, web, ftps)

ftp.explore(local_data, loc)

print("\nChanges:")
if argumetns[1] == "pull" :
	changes, log = ftp.compare(web, loc, web_data, local_data)
	if changes == 0 :
		print(ftp.col.arrow, "no changes to be done\n")
	else :
		print(log)
		agree = input("do you wish to apply changes? ")
		if agree in ['y', 'Y', 'yes', "Yes", 'agree', 'a', 'A'] :
			ftp.download(web, loc, web_data, local_data, ftps)
elif argumetns[1] == "push" :
	changes, log = ftp.compare(loc, web, local_data, web_data)
	if changes == 0 :
		print(ftp.col.arrow, "no changes to be done\n")
	else :
		print(log)
		agree = input("do you wish to apply changes? ")
		if agree in ['y', 'Y', 'yes', "Yes", 'agree', 'a', 'A'] :
			ftp.upload(loc, web, local_data, web_data, ftps)



ftps.close()

Пример #4
0
    else:
        return emptystr


regions = ['25', '27']
for reg in regions:
    name_region = ftp.regions(reg)
    today = datetime.today()
    #today = datetime.strptime('2020-02-27', '%Y-%m-%d')
    #print(today)
    FTP = ftp.connect()

    url_mail = 'https://pm.zakupki.r2000.ru/scripts/mail.php'
    list_notifications = ftp.cwd(
        FTP, '/fcs_regions/' + name_region + '/notifications/currMonth/')
    files_zip = ftp.download(FTP, list_notifications,
                             today.strftime("%Y%m%d") + '\d\d_\d\d\d\.xml')
    for file_zip in files_zip:
        print(file_zip)
        z = zipfile.ZipFile(file_zip['path'], 'r')
        for xml_name in z.namelist():
            if (xml_name[-3:] != 'xml'): continue
            try:
                data = {}
                xmlstring = z.read(xml_name)
                xmlstring = re.sub(' xmlns="[^"]+"', '',
                                   xmlstring.decode('utf-8'))
                xml_tree = ET.fromstring(xmlstring)
                data['nacrezim'] = ''
                for nacrezim in xml_tree.findall('*//requirement/content'):
                    data['nacrezim'] += nacrezim.text
                data['preimuschestva_ogranich'] = ''