User Tools

Site Tools


cobbler_api_hook_for_vm_creation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
cobbler_api_hook_for_vm_creation [2011/07/28 20:04]
jt
— (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"​) 
-token = automagick.login("​jthomas","​jay*123"​) 
-default_profile = '​Centos5-Base-KVM-CORP'​ 
- 
-#Get required information from user for vm creation: 
-if len(sys.argv) < 3: 
-  print ("​usage:​ sys.argv[0] hostname"​) 
-  sys.exit(1) 
- 
-## Need to check if it is also a valid hostname with proper fqdn  
-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) 
- 
-def build_system_definition(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>​ 
cobbler_api_hook_for_vm_creation.1311883456.txt.gz ยท Last modified: 2020/08/10 02:28 (external edit)