nrvr.distros.el.clone
index
/usr/lib/python2.7/site-packages/nrvr/distros/el/clone.py

nrvr.distros.el.clone - Manipulate Enterprise Linux machines for cloning
 
Class provided by this module is ElClone.
 
To be improved as needed.
 
Idea and first implementation - Leo Baschy <srguiwiz12 AT nrvr DOT com>
 
Public repository - https://github.com/srguiwiz/nrvr-commander
 
Copyright (c) Nirvana Research 2006-2015.
Simplified BSD License

 
Modules
       
re

 
Classes
       
ElClone

 
class ElClone
    Utilities for manipulating a Enterprise Linux machines for cloning.
 
  Class methods defined here:
commandToChangeHostname(cls, oldHostname, newHostname) from __builtin__.classobj
Build command to change hostname.
 
Must be root to succeed.
 
As implemented works in Enterprise Linux versions 6.x.
 
Clearly, some machines will have more settings that may or may not need changing too.
 
Example use:
 
    vm = VMwareMachine("~/vmware/examples/example68/example68.vmx")
    VMwareHypervisor.local.start(vm.vmxFilePath)
    vm.sleepUntilSshIsAvailable(ticker=True)
    vm.sshCommand([ElClone.commandToChangeStaticIPAddress("10.123.45.67", "10.123.45.68")])
    vm.portsFile.changeIPAddress("10.123.45.67", "10.123.45.68")
    vm.sleepUntilSshIsAvailable(ticker=True)
    vm.acceptKnownHostKey()
    vm.sshCommand([ElClone.commandToChangeHostname("example67", "example68")])
 
Return command to change static hostname.
commandToChangeStaticIPAddress(cls, oldIpAddress, newIpAddress, interface=None) from __builtin__.classobj
Build command to change static IP address.
 
Must be root to succeed.
 
As implemented works in Enterprise Linux versions 6.x.
 
Example use:
 
    vm = VMwareMachine("~/vmware/examples/example68/example68.vmx")
    VMwareHypervisor.local.start(vm.vmxFilePath)
    vm.sleepUntilSshIsAvailable(ticker=True)
    vm.sshCommand([ElClone.commandToChangeStaticIPAddress("10.123.45.67", "10.123.45.68")])
    vm.portsFile.changeIPAddress("10.123.45.67", "10.123.45.68")
    vm.sleepUntilSshIsAvailable(ticker=True)
    vm.acceptKnownHostKey()
    vm.sshCommand([ElClone.commandToChangeHostname("example67", "example68")])
 
interface
    a string, e.g. "eth0".
 
Return command to change static IP address.
commandToRecreateSshHostKeys(cls) from __builtin__.classobj
Build command to recreate ssh host keys.
 
Must be root to succeed.
 
May have to consider timing for subsequent invocation of acceptKnownHostKey().
 
As implemented works in Enterprise Linux versions 6.x.
Recreates SSHv1 RSA key, SSHv2 RSA and DSA key.
 
Some machines may have further settings that may need changing too.
 
Example use:
 
    vm = VMwareMachine("~/vmware/examples/example68/example68.vmx")
    VMwareHypervisor.local.start(vm.vmxFilePath)
    vm.sleepUntilSshIsAvailable(ticker=True)
    vm.sshCommand([ElClone.commandToChangeStaticIPAddress("10.123.45.67", "10.123.45.68")])
    vm.portsFile.changeIPAddress("10.123.45.67", "10.123.45.68")
    vm.sleepUntilSshIsAvailable(ticker=True)
    vm.acceptKnownHostKey()
    vm.sshCommand([ElClone.commandToChangeHostname("example67", "example68")])
    vm.sshCommand([ElClone.commandToRecreateSshHostKeys()])
    time.sleep(10.0)
    vm.acceptKnownHostKey()
 
Return command to recreate ssh host keys.