-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvdc_starter.py
More file actions
54 lines (45 loc) · 1.59 KB
/
vdc_starter.py
File metadata and controls
54 lines (45 loc) · 1.59 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#! /usr/bin/env python
# Python script for the Interoute Virtual Data Centre API:
# Name: vdc_starter.py
# Purpose: Starter file for API programming
# Requires: class VDCApiCall in the file vdc_api_call.py
# For download and information:
# http://cloudstore.interoute.com/main/knowledge-centre/library/vdc-api-python-scripts
#
# Copyright (C) Interoute Communications Limited, 2014
from __future__ import print_function
import vdc_api_call as vdc
import getpass
import json
import os
from pprint import pprint
if __name__ == '__main__':
cloudinit_scripts_dir = 'cloudinit-scripts'
config_file = os.path.join(os.path.expanduser('~'), '.vdcapi')
if os.path.isfile(config_file):
with open(config_file) as fh:
data = fh.read()
config = json.loads(data)
api_url = config['api_url']
apiKey = config['api_key']
secret = config['api_secret']
try:
cloudinit_scripts_dir = config['cloudinit_scripts_dir']
except KeyError:
pass
else:
print('API url (e.g. http://10.220.18.115:8080/client/api):', end='')
api_url = raw_input()
print('API key:', end='')
apiKey = raw_input()
secret = getpass.getpass(prompt='API secret:')
# Create the api access object
api = vdc.VDCApiCall(api_url, apiKey, secret)
# Define the request
#request = {}
# Execute the API call
#result = api.listZones(request)
#print the result
#pprint(result)
# FOR ASYNCHRONOUS CALLS ONLY
#pprint(api.wait_for_job(result['jobid']))