Skip to content
This repository has been archived by the owner on Sep 11, 2018. It is now read-only.

Commit

Permalink
Adding some more stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
jsabo committed May 26, 2011
1 parent ecc6856 commit fa030c2
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 1 deletion.
6 changes: 6 additions & 0 deletions createvm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
export VMWARE_USERNAME='root'
export VMWARE_PASSWORD='supsup'
. /etc/profile.d/vijava.sh
/usr/local/bin/vmware_cli.py -s $1 -Vc --name $2 --master $3 --prune
/usr/local/bin/vmware_cli.py -s $1 -mP --on --name $2
Empty file modified genVmwareMac.py
100755 → 100644
Empty file.
48 changes: 48 additions & 0 deletions install_firstboot_createvms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""
Create VMware images on firstboot based on data in Cobbler
"""

import distutils.sysconfig
import utils
import sys

plib = distutils.sysconfig.get_python_lib()
mod_path="%s/cobbler" % plib
sys.path.insert(0, mod_path)

def register():
# this pure python trigger acts as if it were a legacy shell-trigger, but is much faster.
# the return of this method indicates the trigger type
return "/var/lib/cobbler/triggers/install/firstboot/*"

def run(api,args,logger):
# FIXME: make everything use the logger, no prints, use util.subprocess_call, etc

objtype = args[0] # "system" or "profile"
name = args[1] # name of system or profile
ip = args[2] # ip or "?"

if objtype == "system":
target = api.find_system(name)
else:
target = api.find_profile(name)

# collapse the object down to a rendered datastructure
target = utils.blender(api, False, target)

if target == {}:
logger.info("unable to locate %s " % name)
raise CX("failure looking up target")

if target['ks_meta']['vms']:
for vm in target['ks_meta']['vms'].split(','):
try:
arglist = ["/usr/local/bin/createvm",target['ip_address_vmnic1'],vm,target['server']]
logger.info("creating virtual guest %s" % vm)
rc = utils.subprocess_call(logger, arglist, shell=False)
except Exception, reason:
logger.error("unable to create %s: %s" % (name,reason))
if rc != 0:
raise CX("cobbler trigger failed: %(file)s returns ")

return 0
2 changes: 2 additions & 0 deletions vijava.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export CLASSPATH="$CLASSPATH:/opt/vijava/dom4j-1.6.1.jar:/opt/vijava/vijava2120100824.jar"
export PATH="$PATH:/opt/jython/bin"
2 changes: 1 addition & 1 deletion vmware_cli.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ def getCommandLineOpts():
parser.add_option('--notes', dest='annotation', action='store', help='Virtual Machine annotations (default: blank)')
parser.add_option('--disk', dest='disk', action='append', help='Virtual disk size in Kb.', metavar="<size>", nargs=1)
parser.add_option('--nic', dest='nic', action='append', help='MAC address (manually assigned or blank for esx generated)', metavar="<port group>,<mac address>")
parser.add_option('--datastore', dest='datastore', action='store', help='Datastore name (default: Storage1)')
parser.add_option('--datastore', dest='datastore', action='store', help='Datastore name (default: datastore1)')

options, args = parser.parse_args()

Expand Down
Empty file modified vmware_monitor.py
100755 → 100644
Empty file.

0 comments on commit fa030c2

Please sign in to comment.