Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2017 deploy 1box #6

Open
wants to merge 83 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
5af1a2d
Added ./safe-sync-files.sh to copy in day1 or day2 files
triggers May 10, 2016
c56b8b2
Generalized second parameter of notebooks-sync.sh to handle deeper paths
triggers May 10, 2016
3ed3912
Refactored to move build step that was incorrectly put in unrelated g…
triggers May 11, 2016
0e03518
Moved build step to set password to happen after jupyter-1box-vm snap…
triggers May 11, 2016
1388a07
Modified password-setting code to work in its new place
triggers May 11, 2016
db20406
Fixed code typo
triggers May 11, 2016
f2a8365
Changed to append, not replace, /var/log/jupyter.log
triggers May 11, 2016
e3e1677
Fixed flags used to do post-build shutdown/boot
triggers May 11, 2016
0e38d79
Changed default to install *no* notebooks. fullsync=true option adde…
triggers May 11, 2016
02e93f8
Moved notebook synchronization step to be last
triggers May 11, 2016
e08694b
Added build steps to synchronize only day1 or day2 notebooks
triggers May 11, 2016
b33e434
Moved install of customized machine image to occur before making jupy…
triggers May 11, 2016
94cf304
New error message to handle from qemu-kvm-0.12.1.2-2.479.el6_7.4
triggers May 11, 2016
45da44d
Revised some wrong words and fixed 108a 3.7.5 script sample.
k-oyakata May 12, 2016
029991e
Merge pull request #102 from axsh/fix-notebooks-may12
k-oyakata May 12, 2016
87e833a
Modified kvm-boot.sh so it will stop keeping ssh from exiting
triggers May 12, 2016
9600b3d
Changed from symbolic links to copying for kvm control scripts
triggers May 12, 2016
bf86075
More changes to support copying of kvm control scripts
triggers May 12, 2016
b0b9120
Replace forked repository with orignal
toros11 May 13, 2016
0dd804a
Added script for scripts for task to configure script variables
toros11 May 18, 2016
75bf6a8
Added scripts for task to save imagebuild ids to file
toros11 May 18, 2016
2107dbe
Updated the script and template for imagebuild notebook
toros11 May 18, 2016
e6ee84a
Merge pull request #99 from axsh/build-and-install-dev
triggers May 19, 2016
38c67f2
Localized and added some explanations.
k-oyakata May 19, 2016
69a1099
Changed the evaluation-mode from 'provided-script' to 'my-script'.
k-oyakata May 19, 2016
fa0c77c
Added the link to other notbooks.
k-oyakata May 19, 2016
8e3d381
Revised the sample script (method for getting IP address)
k-oyakata May 19, 2016
4a1a874
Merge pull request #108 from axsh/imagebuild-tasks
toros11 May 19, 2016
52a6c3b
Merge pull request #109 from axsh/japalization-for-day2-may13
k-oyakata May 19, 2016
a614c35
Added scripts for gui task to setup parameters
toros11 May 19, 2016
8167604
Added script tasks and a task to setup the parameters required by hand
toros11 May 19, 2016
a655748
Added missing script for loading provided settings
toros11 May 20, 2016
5e2e4d1
Added script for script task to assign the image_id parameters
toros11 May 20, 2016
0de01b4
Added scripts for task install-dependencies
toros11 May 20, 2016
f6b134f
Added scrits for task to run integration test
toros11 May 20, 2016
f0ebb39
removed test file
toros11 May 20, 2016
f83c30c
Fixed typo
toros11 May 20, 2016
079e527
Modified some words.
k-oyakata May 21, 2016
fc3eb03
Localized and added some explanations.
k-oyakata May 21, 2016
c41c4f1
Add mussel to PATH in provided-scripts
toros11 May 23, 2016
77272c4
Fixed template and tasks and cleaned up output
toros11 May 23, 2016
3570070
Merge pull request #111 from axsh/localization-for-day2-may19
k-oyakata May 23, 2016
2ec24a9
Merge pull request #112 from axsh/integration-tasks
toros11 May 23, 2016
9995778
Implement check_message for day two notebook checks
toros11 May 23, 2016
b0fc7c1
Added check message for installing mussel
toros11 May 23, 2016
b48e990
Merge pull request #114 from axsh/fix-check-messages-day2
toros11 May 23, 2016
444436d
Disabled step that removed networks demo{2..8}
triggers May 23, 2016
01c4089
Added missing prev_cmd_failed
triggers May 23, 2016
4eee9b4
Merge pull request #115 from axsh/disable-network-removing-step
triggers May 23, 2016
0d469fb
Fixes a bug where configurations that gets inserted does not get save…
toros11 May 24, 2016
88396f5
Make copy of jenkins configuration before updating current progress
toros11 May 24, 2016
d584e2c
Refactored and cleaned up code
toros11 May 24, 2016
93dd8eb
Localized 202b and fixed some wrong explanations.
k-oyakata May 24, 2016
5abe8b3
Merge pull request #117 from axsh/feature-incremental-xml-logging
toros11 May 24, 2016
720ed6d
Merge pull request #118 from axsh/localization-for-day2-may24
k-oyakata May 24, 2016
13e4fed
Corrected the stepdef and cli command
toros11 May 24, 2016
3b31fbe
Modified some explanations.
k-oyakata May 25, 2016
0043c0b
Modified some explanations.
k-oyakata May 25, 2016
5b251e3
Check if file was copied from the instance and return if missing
toros11 May 25, 2016
4efc812
Change error message and make it a warning
toros11 May 25, 2016
995fd07
Removed duplicate load cell
toros11 May 25, 2016
13bee72
Implement formatted check message
toros11 May 25, 2016
9d234da
Merge pull request #119 from axsh/fix-incorrect-load-cell
toros11 May 25, 2016
624b5f2
Merge pull request #121 from axsh/fix-save-error-message
toros11 May 25, 2016
58c7a2f
Merge pull request #123 from axsh/fix-corrected-git-repo
toros11 May 25, 2016
0e62402
fixed May 25 test result (part1).
k-oyakata May 26, 2016
f10a183
Modified the introduction and revised some wrong words.
k-oyakata May 26, 2016
8bb4a4d
Merge pull request #122 from axsh/fix-imagebuild-missing-check-message
toros11 May 26, 2016
e0f845b
Increase the time before timeout when waiting for image to become ava…
toros11 May 26, 2016
ab9c987
Merge pull request #125 from axsh/fix-increase-retry-timer
toros11 May 26, 2016
bb1ca39
modified some explanations.
k-oyakata May 26, 2016
51dd267
Merge pull request #126 from axsh/localization-for-day2-may25
k-oyakata May 26, 2016
ea48afe
modified explanations.
k-oyakata May 26, 2016
c436108
revised how to use local variable 'image_id'.
k-oyakata May 26, 2016
448b86d
canceled "Task: Use parameters recieved from imagebuild".
k-oyakata May 26, 2016
29e0e55
Merge pull request #127 from axsh/localization-for-day2-may26
k-oyakata May 26, 2016
f2a856c
the last revision of some explanations.
k-oyakata May 27, 2016
5d9041f
revised the check script.
k-oyakata May 27, 2016
3fba699
Merge pull request #128 from axsh/localization-for-day2-may27
k-oyakata May 27, 2016
4e834ac
Fix the incremental logging
toros11 Jul 20, 2016
76e3cf5
Merge pull request #131 from axsh/fix-incremental-log
toros11 Jul 22, 2016
1c70df6
Created scripts for creating standalone 1box environments
toros11 May 17, 2017
335247e
Use socat for redirecting relevant ports from instance
toros11 May 18, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
193 changes: 122 additions & 71 deletions build-nii.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,36 +143,6 @@ EOF
) ; prev_cmd_failed
done

(
$starting_step "Set default password for jupyter, plus other easy initial setup"
JCFG="/home/centos/.jupyter/jupyter_notebook_config.py"
[ -x "$DATADIR/vmdir/ssh-to-kvm.sh" ] && {
[ -f "$DATADIR/vmdir/1box-openvz-w-jupyter.raw.tar.gz" ] || \
"$DATADIR/vmdir/ssh-to-kvm.sh" grep sha1 "$JCFG" 2>/dev/null 1>&2
}
$skip_step_if_already_done ; set -e

# http://jupyter-notebook.readthedocs.org/en/latest/public_server.html
"$DATADIR/vmdir/ssh-to-kvm.sh" <<EOF
set -x
[ -f "$JCFG" ] || jupyter notebook --generate-config

# set default password
saltpass="\$(echo $'from notebook.auth import passwd\nprint(passwd("${JUPYTER_PASSWORD:=warmwinter}"))' | python)"
echo "c.NotebookApp.password = '\$saltpass'" >>"$JCFG"
echo "c.NotebookApp.ip = '*'" >>"$JCFG"

# move jupyter's default directory away from \$HOME
mkdir notebooks
echo "c.NotebookApp.notebook_dir = 'notebooks'" >>"$JCFG"

# autostart on boot
echo "(setsid su - centos -c '/home/centos/anaconda3/bin/jupyter notebook' > /var/log/jupyter.log 2>&1) &" | \
sudo bash -c "cat >>/etc/rc.local"
EOF
) ; prev_cmd_failed


# function is called remotely in the next step below
do_register_keypair()
{
Expand Down Expand Up @@ -312,6 +282,45 @@ EOF
) | "$DATADIR/vmdir/ssh-to-kvm.sh"
)

(
$starting_group "Install customized machine image into OpenVZ 1box image"
imagefile="centos-6.6.x86_64.openvz.md.raw.tar.gz"
imageid="bo-centos1d64"
! [ -f "$DATADIR/$imagefile" ]
$skip_group_if_unnecessary

(
$starting_step "Compute backup object parameters for customized image"
[ -f "$DATADIR/$imagefile.params" ]

$skip_step_if_already_done; set -e
"$DATADIR/vmapp-vdc-1box/gen-image-size-params.sh" \
"$DATADIR/$imagefile" >"$DATADIR/$imagefile.params"
) ; prev_cmd_failed

(
$starting_step "Install customized image"

[ -x "$DATADIR/vmdir/ssh-to-kvm.sh" ] &&
"$DATADIR/vmdir/ssh-to-kvm.sh" '[ -d /var/lib/wakame-vdc/images/hide ]' 2>/dev/null
$skip_step_if_already_done; set -e

( cd "$DATADIR" &&
tar c "$imagefile" | "$DATADIR/vmdir/ssh-to-kvm.sh" tar xv
)
"$DATADIR/vmdir/ssh-to-kvm.sh" <<EOF
set -x
sudo mkdir -p /var/lib/wakame-vdc/images/hide
sudo mv /var/lib/wakame-vdc/images/$imagefile /var/lib/wakame-vdc/images/hide
sudo mv /home/centos/$imagefile /var/lib/wakame-vdc/images

/opt/axsh/wakame-vdc/dcmgr/bin/vdc-manage backupobject modify \
$imageid $(cat "$DATADIR/$imagefile.params")

EOF
) ; prev_cmd_failed
)

# TODO: this guard is awkward.
[ -x "$DATADIR/vmdir/kvm-shutdown-via-ssh.sh" ] && \
"$DATADIR/vmdir/kvm-shutdown-via-ssh.sh"
Expand Down Expand Up @@ -353,14 +362,14 @@ EOF
) ; prev_cmd_failed

(
$starting_step "Synchronize notebooks/ to VM"
$starting_step "Synchronize bin/ and notebooks/.downloads to VM"
[ -x "$DATADIR/vmdir/ssh-to-kvm.sh" ] && {
"$DATADIR/vmdir/ssh-to-kvm.sh" '[ "$(ls notebooks)" != "" ]' 2>/dev/null
"$DATADIR/vmdir/ssh-to-kvm.sh" '[ "$(ls bin)" != "" ]' 2>/dev/null
}
$skip_step_if_already_done; set -e

"$DATADIR/notebooks-sync.sh" tovm bin
"$DATADIR/notebooks-sync.sh" tovm
"$DATADIR/notebooks-sync.sh" tovm notebooks/.downloads
) ; prev_cmd_failed

(
Expand Down Expand Up @@ -406,43 +415,15 @@ EOF
) ; prev_cmd_failed

(
$starting_group "Install customized machine image into OpenVZ 1box image"
imagefile="centos-6.6.x86_64.openvz.md.raw.tar.gz"
imageid="bo-centos1d64"
! [ -f "$DATADIR/$imagefile" ]
$starting_group "Hide unused steps"

## This step is removed from the build because it caused trouble
## with the load balancer. Instead of removing it, I am blocking
## its execution with a group so that it can still be forced to
## execute (using the bashctrl.sh wrapper script) for some
## anticipated debugging/testing work.
true
$skip_group_if_unnecessary

(
$starting_step "Compute backup object parameters for customized image"
[ -f "$DATADIR/$imagefile.params" ]

$skip_step_if_already_done; set -e
"$DATADIR/vmapp-vdc-1box/gen-image-size-params.sh" \
"$DATADIR/$imagefile" >"$DATADIR/$imagefile.params"
) ; prev_cmd_failed

(
$starting_step "Install customized image"

[ -x "$DATADIR/vmdir/ssh-to-kvm.sh" ] &&
"$DATADIR/vmdir/ssh-to-kvm.sh" '[ -d /var/lib/wakame-vdc/images/hide ]' 2>/dev/null
$skip_step_if_already_done; set -e

( cd "$DATADIR" &&
tar c "$imagefile" | "$DATADIR/vmdir/ssh-to-kvm.sh" tar xv
)
"$DATADIR/vmdir/ssh-to-kvm.sh" <<EOF
set -x
sudo mkdir -p /var/lib/wakame-vdc/images/hide
sudo mv /var/lib/wakame-vdc/images/$imagefile /var/lib/wakame-vdc/images/hide
sudo mv /home/centos/$imagefile /var/lib/wakame-vdc/images

/opt/axsh/wakame-vdc/dcmgr/bin/vdc-manage backupobject modify \
$imageid $(cat "$DATADIR/$imagefile.params")

EOF
) ; prev_cmd_failed

(
$starting_step "Removed demo2 through demo8 and minimum from launch instance"

Expand Down Expand Up @@ -471,4 +452,74 @@ MMM

EOF
) ; prev_cmd_failed
)
) ; prev_cmd_failed

(
$starting_step "Set default password for jupyter, plus other easy initial setup"
JCFG="/home/centos/.jupyter/jupyter_notebook_config.py"
[ -x "$DATADIR/vmdir/ssh-to-kvm.sh" ] && \
"$DATADIR/vmdir/ssh-to-kvm.sh" grep sha1 "$JCFG" 2>/dev/null 1>&2
$skip_step_if_already_done ; set -e

# http://jupyter-notebook.readthedocs.org/en/latest/public_server.html
"$DATADIR/vmdir/ssh-to-kvm.sh" <<EOF
set -x
[ -f "$JCFG" ] || jupyter notebook --generate-config

# set default password
saltpass="\$(echo $'from notebook.auth import passwd\nprint(passwd("${JUPYTER_PASSWORD:=warmwinter}"))' | python)"
echo "c.NotebookApp.password = '\$saltpass'" >>"$JCFG"
echo "c.NotebookApp.ip = '*'" >>"$JCFG"

# move jupyter's default directory away from \$HOME
mkdir notebooks
echo "c.NotebookApp.notebook_dir = 'notebooks'" >>"$JCFG"

# autostart on boot
echo "(setsid su - centos -c '/home/centos/anaconda3/bin/jupyter notebook' >> /var/log/jupyter.log 2>&1) &" | \
sudo bash -c "cat >>/etc/rc.local"

# We could start jupyter directly now, but let's do a shutdown/boot
# cycle to test that is working option in case unexpected problems occur.
# Need to set flag below.
EOF
touch "$DATADIR/reboot1box" # necessary to use a file because inside a subprocess
) ; prev_cmd_failed

if [ "$reboot1box" != "" ] || \
[ -f "$DATADIR/reboot1box" ] ; then # this flag can also be set before calling ./build-nii.sh
rm -f "$DATADIR/reboot1box"
[ -x "$DATADIR/vmdir/kvm-shutdown-via-ssh.sh" ] && \
"$DATADIR/vmdir/kvm-shutdown-via-ssh.sh"
fi

[ -x "$DATADIR/vmdir/kvm-boot.sh" ] && \
"$DATADIR/vmdir/kvm-boot.sh"

(
$starting_step "Synchronize *all* of notebooks/ to VM, if fullsync=true"
[ "$fullsync" != "true" ]
$skip_step_if_already_done; set -e

"$DATADIR/notebooks-sync.sh" tovm
) ; prev_cmd_failed

(
$starting_step "Synchronize day1 notebooks/ to VM, if day1sync=true"
[ "$day1sync" != "true" ]
$skip_step_if_already_done; set -e

cd "$DATADIR"
./notebooks-sync.sh tovm notebooks/stepdefs # always sync all stepdefs
./safe-sync-files.sh notebooks/1*
) ; prev_cmd_failed

(
$starting_step "Synchronize day2 notebooks/ to VM, if day2sync=true"
[ "$day2sync" != "true" ]
$skip_step_if_already_done; set -e

cd "$DATADIR"
./notebooks-sync.sh tovm notebooks/stepdefs # always sync all stepdefs
./safe-sync-files.sh notebooks/2*
) ; prev_cmd_failed
37 changes: 37 additions & 0 deletions deploy/deploy-1box.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash
#
# run this file on some bare metal to deploy setup 1box environments
# the 1box image files needs to be placed in the same folder as this script
#
# usage:
# ./deploy-1box <n>, where <n> is the numbers of 1box environments
#
# ports exposed: <current_dir>/boxes/box_<n>/kvm.ports
# kvm boot cmd: <current_dir>/boxes/box_<n>/kvm.cmdline
# kvm pid: <current_dir>/boxes/box_<n>/box_<n>.pid

BOX_CNT=${1}
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ONEBOX_IMG="${CURRENT_DIR}/1box.tar.gz"
PORT_FORWARD=(
22 0.0.0.0 # ssh on 1box
5222 0.0.0.0 # socat service redirecting to 10.0.2.100:8080 (vdc instance)
9000 0.0.0.0 # wakame gui
9001 0.0.0.0 # wakame api
8080 0.0.0.0 # socat service redirectiong to 10.0.2.100:8080 (vdc jenkins service)
)

# [[ -f "${ONEBOX_IMG}" ]] || { echo "Missing 1box image" ; exit 1 ; }
. ${CURRENT_DIR}/generate-qemu-cmd.sh

for (( i=0; i < ${BOX_CNT} ; i++ )) ; do
echo "Deploying box ${i}"
box_path="${CURRENT_DIR}/boxes/box_${i}"
mkdir -p "${box_path}"
[[ -f "${box_path}/box.img" ]] || tar Sxvf 1box.tar.gz -C "${box_path}"
[[ -f "${box_path}/kvm.cmdline" ]] || build_qemu_cmd "${i}" "${box_path}"
[[ -f "${box_path}/box_${i}.pid" ]] || {
cat "${box_path}/kvm.cmdline"
./preconfigure-cienv.sh $(( 22 + 10000 + ( i * 10 ) )) "${box_path}/1box-key"
}
done
49 changes: 49 additions & 0 deletions deploy/generate-qemu-cmd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash
set -x

build_hostfwd_param()
{
local idx=${1}
local box_path="${2}"
rm -f ${box_path}/kvm.open_ports

for (( i=0 ; i < ${#PORT_FORWARD[@]} ; i+=2 )) ; do
port="${PORT_FORWARD[i]}"
host="${PORT_FORWARD[$(( i + 1 ))]}"
access_port=$(( port + 10000 + ( idx * 10 ) ))
# make sure the access port is not used
until [[ ! "${ret_val}" == *"${access_port}-"* ]] ; do
[[ ! -f ${box_path}/kvm.open_ports ]] && break
access_port=$(( access_port + 1 ))
done
ret_val="${ret_val}hostfwd=tcp::${access_port}-${host}:${port},"
echo "port: ${access_port} -> ${host}:${port}" >> ${box_path}/kvm.ports
done

echo "${ret_val%,*}"
}

build_qemu_cmd()
{
local idx="${1}"
local box_path="${2}"
local vnc_port="${vnc_port:-11050}"
local serial_port="${serial_port:-14060}"
local mac_addr="${mac_addr:-02:00:00:00:00:0${idx}}"

cat <<- EOF > "${box_path}/kvm.cmdline"
qemu-system-x86_64 \
-machine accel=kvm \
-cpu ${cpu_type:-qemu64,+vmx} \
-m ${mem_size:-4096} \
-smp ${cpu_num:-2} \
-vnc ${vnc_addr:-localhost}:$(( vnc_port + idx)) \
-serial telnet:127.0.0.1:$(( serial_port + idx )),server,nowait \
-serial pty \
-drive file=${box_path}/box.img,media=disk,if=virtio,format=${format:-qcow2} \
-net nic,vlan=0,macaddr=${mac_addr},model=virtio,addr=$(( 3 + idx )) \
-net user,vlan=0,$(build_hostfwd_param ${idx} ${box_path}) \
-daemonize \
-pidfile ${box_path}/${vm_name:-box_${idx}}.pid
EOF
}
Loading