This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
cobbler_api_hook_for_vm_creation [2011/07/28 19:49] jt created |
— (current) | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | <code python> | ||
- | #!/bin/env python | ||
- | import sys | ||
- | import re | ||
- | import xmlrpclib | ||
- | import cobbler.api as capi | ||
- | automagick = xmlrpclib.Server("http://automagick01vm.ewr1.pokkari.net/cobbler_api") | ||
- | |||
- | #Get required information from user for vm creation: | ||
- | if len(sys.argv) < 3: | ||
- | print ("usage: sys.argv[0] hostname") | ||
- | sys.exit(1) | ||
- | |||
- | def check_hostname (hostname): | ||
- | if len(automagick.find_system({"hostname":hostname})) == 0: | ||
- | return hostname | ||
- | else: | ||
- | print "already exists. please pass switch to reinstall" | ||
- | sys.exit(1) | ||
- | |||
- | vm_hostname = check_hostname(sys.argv[1]) | ||
- | print vm_hostname | ||
- | ~ | ||
- | ~ | ||
- | </code> |