-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlisttemplates2.py
More file actions
executable file
·31 lines (23 loc) · 892 Bytes
/
listtemplates2.py
File metadata and controls
executable file
·31 lines (23 loc) · 892 Bytes
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
#!/usr/bin/python
import sys
import CloudStack
import time
from termcolor import colored
from urllib2 import urlopen, HTTPError
import cloudconstants as k
cloudstack = CloudStack.Client(API_URI, YOUR_API_KEY, YOUR_API_SECRET)
if len(sys.argv) < 2:
tmpltype = 'community'
else:
tmpltype = sys.argv[1]
if tmpltype.lower() not in ['community', 'featured', 'self', 'executable']:
sys.exit("Invalid option. Valid options are 'community', 'featured', 'self', 'executable'")
args = {'templatefilter': tmpltype.lower()}
tmpls = cloudstack.listTemplates(args)
print "\nAvailable Templates for Template Type:",
sys.stdout.flush()
print '%s' % colored(tmpltype.upper(), attrs=['bold'])
print "================================================="
print colored("id \t\t\t\t\tname\n", attrs=['bold', 'underline'])
for tmpl in tmpls:
print "%s\t%s\n" % ( tmpl['id'], tmpl['ostypename'])