Skip to content
This repository was archived by the owner on Oct 11, 2025. It is now read-only.

Commit 722967e

Browse files
author
Micah Young
committed
Migrate cpi wrapper logic into installer
- Allow CPI to be installed over SSH. Requires non-restrict authorized key entry to allow scp - Only useful for windows or remote hypervisors
1 parent 29e07ae commit 722967e

File tree

329 files changed

+107634
-16964
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

329 files changed

+107634
-16964
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env.ps1
2+
env.sh
13
bin/
24
.DS_Store
35
dev_releases/

ci/state/bosh-deployment-env.sh.template_fusion

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export CI_vm_store_path=<directory for vm and disk state>
1111
export CI_stemcell_store_path=<directory containing full stemcells>
1212
export CI_stemcell_url=file://<path to local stemcell - can be light if using stemcell store path (below)>
1313
export CI_stemcell_sha1=<stemcell sha1>
14+
export CI_trusty_stemcell_url=file://<path to local trusty light stemcell - used for zookeeper>
15+
export CI_trusty_stemcell_sha1=<stemcell sha1>
1416
export CI_ssh_tunnel_host=172.16.125.1
1517
export CI_ssh_tunnel_username="$(whoami)"
1618
export CI_ssh_tunnel_platform="darwin"

ci/state/bosh-deployment-env.sh.template_workstation

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export CI_vm_store_path=<directory for vm and disk state>
1111
export CI_stemcell_store_path=<directory containing full stemcells>
1212
export CI_stemcell_url=file://<path to local stemcell - can be light if using stemcell store path (below)>
1313
export CI_stemcell_sha1=<stemcell sha1>
14+
export CI_trusty_stemcell_url=file://<path to local trusty light stemcell - used for zookeeper>
15+
export CI_trusty_stemcell_sha1=<stemcell sha1>
1416
export CI_ssh_tunnel_host=192.168.133.1
1517
export CI_ssh_tunnel_username="$(whoami)"
1618
export CI_ssh_tunnel_platform=<linux or windows>

ci/vmrun-cpi-opsfile.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,9 @@
5252
stemcell_store_path: "((stemcell_store_path))"
5353
ssh_tunnel:
5454
host: "((ssh_tunnel_host))"
55-
port: 22
5655
username: "((ssh_tunnel_username))"
5756
private_key: "((ssh_tunnel_private_key))"
58-
platform: "linux"
57+
platform: "((ssh_tunnel_platform))"
5958

6059
# Cloud provider
6160
- type: replace
@@ -75,7 +74,6 @@
7574
stemcell_store_path: "((stemcell_store_path))"
7675
ssh_tunnel:
7776
host: localhost
78-
port: 22
7977
username: "((ssh_tunnel_username))"
8078
private_key: "((ssh_tunnel_private_key))"
8179
platform: "((ssh_tunnel_platform))"

ci/zookeeper.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ if ! [ -d $STATE_DIR/zookeeper-release ]; then
3030
popd
3131
fi
3232

33-
$bosh_bin -e ci upload-stemcell $CI_stemcell_url \
34-
--sha1 $CI_stemcell_sha1 \
33+
$bosh_bin -e ci upload-stemcell $CI_trusty_stemcell_url \
34+
--sha1 $CI_trusty_stemcell_sha1 \
3535
;
3636

3737
$bosh_bin -e ci deploy $STATE_DIR/zookeeper-release/manifests/zookeeper.yml \

env.ps1

Lines changed: 0 additions & 1 deletion
This file was deleted.

jobs/vmrun_cpi/spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ properties:
3030
description: Hypervisor hostname or IP with SSH server where CPI will be executed
3131
vmrun.ssh_tunnel.port:
3232
description: Hypervisor SSH server port
33-
default: 22
33+
default: "22"
3434
vmrun.ssh_tunnel.username:
3535
description: Hypervisor SSH username. Must have priviledges to run `vmrun`
3636
vmrun.ssh_tunnel.private_key:

jobs/vmrun_cpi/templates/cpi.erb

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ if [ -d /var/vcap/sys/log/vmrun_cpi/ ]; then
1111
err_log=/var/vcap/sys/log/vmrun_cpi/cpi.stderr.log
1212
fi
1313

14+
trap "echo -e \"CPI error: Recent messages from $err_log:\n\"; tail -10 $err_log" EXIT
15+
1416
<% if_p('vmrun.ssh_tunnel.host') do %>
1517
<% if_p('vmrun.stemcell_store_path') {}.else do %>
1618
echo "Invalid properties: vmrun.stemcell_store_path must be set for vmrun.ssh_tunnel. Tunnelled VMs rely on the stemcell store local to the hypervisor."
@@ -32,44 +34,15 @@ fi
3234
echo "CPI: using ssh-tunnel env: {host: $host, username: $username, port: $port, private_key_file: $private_key_file} " >> $err_log
3335

3436
if [ -w $BOSH_JOBS_DIR/vmrun_cpi/config ]; then
37+
echo "CPI: set permissions on key file" >> $err_log
3538
chmod 0600 $private_key_file
3639
fi
3740

38-
echo "CPI: set permissions on key file" >> $err_log
39-
40-
# Lookup path for hypervisor CPI (installs if vm-store dir to find it later)
41-
hypervisor_cpi_path=$("$package_installer_path" -platform $hypervisor_platform -configBase64JSON $encoded_config 2>>$err_log)
42-
installer_version=$("$package_installer_path" -version 2>>$err_log)
43-
44-
if [ -f $hypervisor_cpi_path -a ! -x $hypervisor_cpi_path ]; then
45-
chmod +x $hypervisor_cpi_path
46-
fi
47-
48-
echo "CPI: hypervisor: $installer_version $hypervisor_cpi_path" >> $err_log
49-
50-
# Check ssh connectivity and cpi version
51-
cpi_version=$(echo | ssh -q -i $private_key_file -p $port -o StrictHostKeyChecking=no -o PreferredAuthentications=publickey $username@$host "$hypervisor_cpi_path -version" 2>/dev/null || true)
41+
#TODO migrate command line arguments to CPI config
42+
hypervisor_cpi_path=$("$package_installer_path" -configBase64JSON $encoded_config 2>>$err_log)
5243

53-
echo "CPI: cpi: $cpi_version" >> $err_log
54-
55-
if [ -z "$cpi_version" ]; then
56-
# CPI cpi args are passed the last args of SSH_ORIGINAL_COMMAND
57-
public_key=$(echo | ssh-keygen -y -f $private_key_file)
58-
auth_key_entry="restrict,command=\"$hypervisor_cpi_path \${SSH_ORIGINAL_COMMAND#* }\" $public_key $username@localhost"
59-
echo "CPI: ssh connection failed. Command not set correctly in authorized_key:\n---\n$auth_key_entry\n---" >> $err_log
60-
echo
61-
echo --------------------------
62-
echo "add to your ~/.ssh/authorized_keys:"
63-
echo "$auth_key_entry"
64-
echo --------------------------
65-
echo
66-
exit 1
67-
elif ! [ "$installer_version" = "$cpi_version" ]; then
68-
echo "CPI: cpi is out of date" >> $err_log
69-
echo
70-
echo manually copy your local version to your hypervisor:
71-
echo - from local path: ${BOSH_PACKAGES_DIR}/vmrun_cpi/bin/cpi-${hypervisor_platform}
72-
echo - to hypervisor path: ${hypervisor_cpi_path}
44+
if [ -z $hypervisor_cpi_path ]; then
45+
echo "CPI: installer returned no hypervisor path" >> $err_log
7346
echo
7447
exit 1
7548
fi

0 commit comments

Comments
 (0)