Skip to content

Instantly share code, notes, and snippets.

@joshgachnang
Created March 14, 2014 22:36
Show Gist options
  • Save joshgachnang/9558450 to your computer and use it in GitHub Desktop.
Save joshgachnang/9558450 to your computer and use it in GitHub Desktop.
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