-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclm-tools
executable file
·73 lines (58 loc) · 2.62 KB
/
clm-tools
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/python
import sys, argparse
import ConfigParser
config = ConfigParser.ConfigParser()
config.read('config')
user=config.get("Basic","USERNAME").strip('"')
password=config.get("Basic","PASSWORD").strip('"')
endpoint=config.get("Basic","ENDPOINT").strip('"')
installDir=config.get("Basic","INSTALL_DIR").strip('"')
sys.path.append(str.strip(installDir,'"')+"/lib")
from clm import *
clm = CLM(user,password,endpoint)
clm.login()
if len(sys.argv) > 1 and sys.argv[1] == 'clm-describe-instances':
results=clm.describeInstances()
print "GUID\t\tReconID\t\tName\t\tTenant"
for serviceOffering in results:
print serviceOffering['guid'] + "\t" + serviceOffering['reconciliationID'] + "\t" + serviceOffering['name'] + "\t" + clm.getTenant(serviceOffering['tenant'])['name']
exit
if len(sys.argv) > 1 and sys.argv[1] == 'clm-describe-images':
results=clm.describeImages()
print "GUID\tReconID\tName"
for serviceOffering in results:
print serviceOffering['guid'] + "\t" + serviceOffering['reconciliationID'] + "\t" + serviceOffering['name']
exit
if len(sys.argv) > 1 and sys.argv[1] == 'clm-describe-regions':
results=clm.describeRegions()
print "GUID\tReconID\tName"
for serviceOffering in results:
print serviceOffering['guid'] + "\t" + serviceOffering['reconciliationID'] + "\t" + serviceOffering['name']
exit
if len(sys.argv) > 1 and sys.argv[1] == 'clm-describe-availability-zones':
results=clm.describeAZs()
print "GUID\tReconID\tName"
for serviceOffering in results:
print serviceOffering['guid'] + "\t" + serviceOffering['reconciliationID'] + "\t" + serviceOffering['name']
exit
if len(sys.argv) > 1 and sys.argv[1] == 'clm-describe-vpcs':
results=clm.describeVPCs()
print "GUID\tReconID\tName"
for serviceOffering in results:
print serviceOffering['guid'] + "\t" + serviceOffering['reconciliationID'] + "\t" + serviceOffering['name']
exit
if len(sys.argv) > 1 and sys.argv[1] == 'clm-describe-tenants':
results=clm.describeTenants()
print "GUID\tReconID\tName"
for serviceOffering in results:
print serviceOffering['guid'] + "\t" + serviceOffering['reconciliationID'] + "\t" + serviceOffering['name']
exit
if len(sys.argv) > 1 and sys.argv[1] == 'clm-run-instance':
parser = argparse.ArgumentParser(description='create a new service offering instance')
parser.add_argument('-s',action="store", dest="serviceOffering")
parser.add_argument('-t',action="store", dest="tenant", nargs='+')
parser.add_argument('-q',action="store", dest="quantity", type=int)
options=parser.parse_args(sys.argv[2:])
print " ".join(options.tenant)
clm.runInstance(options.serviceOffering," ".join(options.tenant),options.quantity)
exit