Esempio n. 1
0
func (d *Driver) waitForSSHFunc(client ssh.Client, command string) func() bool {
	return func() bool {
		_, err := client.Output(command)
		if err == nil {
			return true
		}
		return false
	}
}
Esempio n. 2
0
// Fix the routing rules
func (d *Driver) fixRoutingRules(sshClient ssh.Client) {
	output, err := sshClient.Output("route del -net 172.16.0.0/12")
	log.Debugf("%s | Delete route command err, output: %v: %s", d.MachineName, err, output)

	output, err = sshClient.Output("if [ -e /etc/network/interfaces ]; then sed -i '/^up route add -net 172.16.0.0 netmask 255.240.0.0 gw/d' /etc/network/interfaces; fi")
	log.Debugf("%s | Fix route in /etc/network/interfaces command err, output: %v: %s", d.MachineName, err, output)

	output, err = sshClient.Output("if [ -e /etc/sysconfig/network-scripts/route-eth0 ]; then sed -i '/^172.16.0.0\\/12 via /d' /etc/sysconfig/network-scripts/route-eth0; fi")
	log.Debugf("%s | Fix route in /etc/sysconfig/network-scripts/route-eth0 command err, output: %v: %s", d.MachineName, err, output)
}
Esempio n. 3
0
// Install Kernel 3.19
func (d *Driver) upgradeKernel(sshClient ssh.Client, tcpAddr string) {
	log.Debugf("%s | Upgrade kernel version ...", d.MachineName)
	output, err := sshClient.Output("for i in 1 2 3 4 5; do apt-get update -y && break || sleep 5; done")
	log.Infof("%s | apt-get update update err, output: %v: %s", d.MachineName, err, output)
	output, err = sshClient.Output("for i in 1 2 3 4 5; do apt-get install -y linux-generic-lts-vivid && break || sleep 5; done")
	log.Infof("%s | Upgrade kernel err, output: %v: %s", d.MachineName, err, output)
	time.Sleep(5 * time.Second)
	log.Infof("%s | Restart VM instance for kernel update ...", d.MachineName)
	d.Restart()
	time.Sleep(30 * time.Second)
	sshClient.Output("echo 'I am back'")
}
Esempio n. 4
0
// Mount the addtional disk
func (d *Driver) autoFdisk(sshClient ssh.Client) {
	script := fmt.Sprintf("cat > ~/machine_autofdisk.sh <<MACHINE_EOF\n%s\nMACHINE_EOF\n", autoFdiskScript)
	output, err := sshClient.Output(script)
	output, err = sshClient.Output("bash ~/machine_autofdisk.sh")
	log.Debugf("%s | Auto Fdisk command err, output: %v: %s", d.MachineName, err, output)
}