Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 43 lines (34 sloc) 1.093 kB
f77e728 Initial import of hg.uk.xensource.com/carbon/trunk/api.hg c/s 9691:9a…
Xen hg user authored
1 #!/usr/bin/python
2 # Print out custom template UUIDs in CLI comma-separated minimal format
3 # (c) Anil Madhavapeddy, Citrix Systems Inc, 2008
4
5 import atexit
6 import XenAPI
7 import os, sys, time
8
9 def logout():
10 try:
11 session.xenapi.session.logout()
12 except:
13 pass
14 atexit.register(logout)
15
16 def main(argv):
17 try:
18 session = XenAPI.xapi_local()
19 session.xenapi.login_with_password("", "")
20
21 templates = session.xenapi.VM.get_all_records_where('field "is_a_template" = "true"' )
22 except:
23 print >> sys.stderr, "Error retrieving template list"
24 sys.exit(1)
25
26 output=[]
27 for tmplref in templates.keys():
28 tmplrec = templates[tmplref]
29 try:
30 if not tmplrec['other_config'].has_key('default_template'):
31 output.append(tmplrec['uuid'])
32 elif tmplrec['other_config']['default_template'] != true:
33 output.append(tmplrec['uuid'])
34 except:
35 pass
36 print(str.join(',', output))
37 session.xenapi.logout()
38
39 if __name__ == "__main__":
40 main(sys.argv[1:])
41
42
Something went wrong with that request. Please try again.