Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 30 lines (23 sloc) 0.681 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#!/usr/bin/env python

import os
import sys

import json
import requests

user_id = os.environ['USER_ID']
token = os.environ['TOKEN']
api_url = os.environ.get('PHANTOM_URL', "https://phantom.nimbusproject.org/api/dev")

if len(sys.argv) < 4:
    sys.exit("usage: %s name lc_name vm_count" % sys.argv[0])

name = sys.argv[1]
lc_name = sys.argv[2]
vm_count = int(sys.argv[3])
de_name = "multicloud"

new_domain = {
    'name': name,
    'de_name': de_name,
    'lc_name': lc_name,
    'vm_count': vm_count
}

r = requests.post("%s/domains" % api_url, data=json.dumps(new_domain), auth=(user_id, token))
if r.status_code != 201:
    sys.exit("Error %d: %s" % (r.status_code, r.text))
Something went wrong with that request. Please try again.