Created
March 14, 2014 22:36
-
-
Save joshgachnang/9558450 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import requests | |
import sys | |
IRONIC_BASE_URL = "http://10.127.75.253:6385/v1/" | |
def upload(row): | |
payload = { | |
"driver_info": { | |
"ipmi_address": row[0], | |
"ipmi_username": "USERID", | |
"ipmi_password": "PASSW0RD" | |
} | |
} | |
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'} | |
response = requests.post(url=IRONIC_BASE_URL + "nodes/", | |
data=json.dumps(payload), | |
headers=headers) | |
print response | |
if __name__ == "__main__": | |
csv_file = sys.argv[1] | |
input_file = open(csv_file, "rb") | |
reader = csv.reader(input_file) | |
for row in reader: | |
upload(row) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment