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 |
cobbler_api_hook_for_vm_creation [2011/07/28 20:04] jt |
||
---|---|---|---|
Line 7: | Line 7: | ||
automagick = xmlrpclib.Server("http://automagick01vm.ewr1.pokkari.net/cobbler_api") | automagick = xmlrpclib.Server("http://automagick01vm.ewr1.pokkari.net/cobbler_api") | ||
+ | token = automagick.login("jthomas","*******") | ||
+ | default_profile = 'Centos5-Base-KVM-CORP' | ||
#Get required information from user for vm creation: | #Get required information from user for vm creation: | ||
Line 13: | Line 15: | ||
sys.exit(1) | sys.exit(1) | ||
+ | ## Need to check if it is also a valid hostname with proper fqdn | ||
def check_hostname (hostname): | def check_hostname (hostname): | ||
if len(automagick.find_system({"hostname":hostname})) == 0: | if len(automagick.find_system({"hostname":hostname})) == 0: | ||
Line 20: | Line 23: | ||
sys.exit(1) | sys.exit(1) | ||
- | vm_hostname = check_hostname(sys.argv[1]) | + | def build_system_definition(hostname): |
- | print vm_hostname | + | host_id = automagick.new_system(token) |
- | ~ | + | automagick.modify_system(host_id,'name',hostname,token) |
- | ~ | + | automagick.modify_system(host_id,'profile',default_profile,token) |
+ | automagick.save_system(host_id,token) | ||
+ | |||
+ | |||
+ | hostname = check_hostname(sys.argv[1]) | ||
+ | print hostname | ||
+ | build_system_definition(hostname) | ||
</code> | </code> |