Add flag to node e2e test specifying location of ssh privkey

This commit is contained in:
Jeff Grafton 2016-12-20 15:08:49 -08:00
parent 1955ed614f
commit 30a5efa33b
3 changed files with 13 additions and 1 deletions

View File

@ -36,6 +36,7 @@ cluster/photon-controller/templates/salt-minion.sh: hostname_override: $(ip rou
cluster/photon-controller/util.sh: node_ip=$(${PHOTON} vm networks "${node_id}" | grep -i $'\t'"00:0C:29" | grep -E '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -1 | awk -F'\t' '{print $3}')
cluster/photon-controller/util.sh: local cert_dir="/srv/kubernetes"
cluster/photon-controller/util.sh: node_name=${1}
cluster/photon-controller/util.sh: ssh_key=$(ssh-add -L | head -1)
cluster/rackspace/util.sh: local node_ip=$(nova show --minimal ${NODE_NAMES[$i]} \
cluster/saltbase/salt/cluster-autoscaler/cluster-autoscaler.manifest:{% set params = pillar['autoscaler_mig_config'] + " " + cloud_config -%}
cluster/saltbase/salt/etcd/etcd.manifest: "value": "{{ storage_backend }}"

View File

@ -573,6 +573,7 @@ sort-by
source-file
ssh-env
ssh-keyfile
ssh-key
ssh-options
ssh-user
start-services

View File

@ -29,9 +29,11 @@ import (
var sshOptions = flag.String("ssh-options", "", "Commandline options passed to ssh.")
var sshEnv = flag.String("ssh-env", "", "Use predefined ssh options for environment. Options: gce")
var sshKey = flag.String("ssh-key", "", "Path to ssh private key.")
var sshUser = flag.String("ssh-user", "", "Use predefined user for ssh.")
var sshOptionsMap map[string]string
var sshDefaultKeyMap map[string]string
func init() {
usr, err := user.Current()
@ -39,7 +41,10 @@ func init() {
glog.Fatal(err)
}
sshOptionsMap = map[string]string{
"gce": fmt.Sprintf("-i %s/.ssh/google_compute_engine -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o CheckHostIP=no -o StrictHostKeyChecking=no -o ServerAliveInterval=30 -o LogLevel=ERROR", usr.HomeDir),
"gce": "-o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o CheckHostIP=no -o StrictHostKeyChecking=no -o ServerAliveInterval=30 -o LogLevel=ERROR",
}
sshDefaultKeyMap = map[string]string{
"gce": fmt.Sprintf("%s/.ssh/google_compute_engine", usr.HomeDir),
}
}
@ -87,6 +92,11 @@ func SSHNoSudo(host string, cmd ...string) (string, error) {
// runSSHCommand executes the ssh or scp command, adding the flag provided --ssh-options
func runSSHCommand(cmd string, args ...string) (string, error) {
if *sshKey != "" {
args = append([]string{"-i", *sshKey}, args...)
} else if key, found := sshDefaultKeyMap[*sshEnv]; found {
args = append([]string{"-i", key}, args...)
}
if env, found := sshOptionsMap[*sshEnv]; found {
args = append(strings.Split(env, " "), args...)
}