Advertisement
Guest User

Untitled

a guest
Sep 18th, 2014
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.96 KB | None | 0 0
  1. import requests
  2. from md5 import md5
  3.  
  4. template = """{"status":"discover","manufacturer":"VirtualBox","os_platform":"centos","mac":"%s","is_agent":true,"agent_checksum":"%s","platform_name":null,"meta":{"disks":[{"model":"VBOX HARDDISK","disk":"sdc","removable":"0","size":68718428160,"extra":["disk/by-id/scsi-SATA_VBOX_HARDDISK_VB321f1fd2-2230ea33","disk/by-id/ata-VBOX_HARDDISK_VB321f1fd2-2230ea33"],"name":"sdc"},{"model":"VBOX HARDDISK","disk":"disk/by-path/pci-0000:00:0d.0-scsi-0:0:0:0","removable":"0","size":68718428160,"extra":["disk/by-id/scsi-SATA_VBOX_HARDDISK_VB3a07f2b6-af768607","disk/by-id/ata-VBOX_HARDDISK_VB3a07f2b6-af768607"],"name":"sdb"},{"model":"VBOX HARDDISK","disk":"sda","removable":"0","size":68718428160,"extra":["disk/by-id/scsi-SATA_VBOX_HARDDISK_VBe731733f-4a5dab7b","disk/by-id/ata-VBOX_HARDDISK_VBe731733f-4a5dab7b"],"name":"sda"}],"memory":{"total":2104541184},"cpu":{"total":1,"real":0,"spec":[{"model":"Intel(R) Core(TM) i7-3740QM CPU @ 2.70GHz","frequency":2680}]},"system":{"manufacturer":"VirtualBox","serial":"0","version":"1.2","fqdn":"bootstrap","family":"Virtual Machine"},"interfaces":[{"mac":"%s","state":"unknown","current_speed":100,"name":"eth2","max_speed":100},{"mac":"%s","state":"unknown","current_speed":100,"name":"eth1","max_speed":100},{"mac":"%s","netmask":"255.255.255.0","state":"unknown","current_speed":100,"name":"eth0","max_speed":100,"ip":"%s"}]},"ip":"%s"}
  5. """
  6.  
  7. for i in range(16, 116):                                                                                                                                             mac="08:00:27:84:CC:{0}".format(str(hex(i))[2:].upper())
  8.     md5sum=md5(`i`).hexdigest()
  9.     mac1="08:00:27:81:CC:{0}".format(str(hex(i))[2:].upper())
  10.     mac2="08:20:27:81:CC:{0}".format(str(hex(i))[2:].upper())
  11.     admin_ip = "10.20.0.{0}".format(100+i)
  12.     data=template % (mac, md5sum, mac, mac1, mac2, admin_ip, admin_ip)
  13.     print requests.post("http://10.20.0.2:8000/api/nodes", data).content
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement