node-update (centos)
Embarrassingly simple python program to perform final configuration of a cloned vmware node (from a template) to assign the network bits. NOTE: for centos base node only.
====================================================================================================
#!/usr/bin/env python
# vi:set nu ai ap aw smd showmatch tabstop=4 shiftwidth=4:
import time
import pysphere
from pysphere import VIServer
import sys,getopt
if len(sys.argv) != 2:
print "must specify fqdn "
exit(1)
fqdn = str(sys.argv[1])
print "FQDN: ", str(sys.argv[1])
server = VIServer()
server.connect("cloud.qalabs.symantec.com","yyyyyyyy","xxxxxxxxxx")
opened = False
while opened == False:
vm1 = server.get_vm_by_name(fqdn)
if vm1:
opened = True
time.sleep(10)
# wait for vmware tools to start up
print ">>> sleeping to allow vmware tools to start..."
time.sleep(5)
print ">>> remote login to " + fqdn
vm1.login_in_guest("root","xxxxxxxx")
vm1.delete_file("/etc/udev/rules.d/70-persistent-net.rules")
print ">>> remove existing 70-persistent-net.rule"
vm1.send_file("/tmp/" + fqdn + "-network","/etc/sysconfig/network",overwrite=True)
print ">>> install new /etc/sysconfig/network file"
vm1.send_file("/tmp/" + fqdn + "-ifcfg-eth0","/etc/sysconfig/network-scripts/ifcfg-eth0",overwrite=True)
print ">>> install new /etc/sysconfig/ifcfg-eth0 file"
vm1.send_file("/tmp/" + fqdn + "-role","/etc/role",overwrite=True)
print ">>> install new /etc/role file"
vm1.send_file("/tmp/" + fqdn + "-env","/etc/env",overwrite=True)
print ">>> install new /etc/env file"
vm1.send_file("/tmp/" + fqdn + "-puppet.conf", "/etc/puppet/puppet.conf",overwrite=True)
print ">>> install new /etc/puppet/puppet.conf file"
print ">>> now rebooting guest"
vm1.reboot_guest()
exit()