Skip to content
This repository has been archived by the owner on Jul 16, 2020. It is now read-only.

Commit

Permalink
Merge pull request #630 from markdryan/master
Browse files Browse the repository at this point in the history
Single VM: Enable Ceph and script refactor
  • Loading branch information
mcastelino authored Oct 5, 2016
2 parents b938a42 + c90af7b commit 9e17e73
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 133 deletions.
18 changes: 10 additions & 8 deletions testutil/singlevm/cleanup.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
#!/bin/bash

if [ -z "$HOSTS_FILE_BACKUP" ]; then
echo "HOSTS_FILE_BACKUP" is not set.
echo "Please run"
echo ""
echo ". ~/local/demo.sh"
exit 1
if [ ! -z $1 ]; then
hosts_file_backup=$1
else
. ~/local/demo.sh
hosts_file_backup=$HOSTS_FILE_BACKUP
fi

ciao_gobin="$GOPATH"/bin
sudo killall ciao-scheduler
sudo killall ciao-controller
sudo killall ciao-launcher
sleep 2
sudo "$ciao_gobin"/ciao-launcher --hard-reset
sudo "$ciao_gobin"/ciao-launcher --alsologtostderr -v 3 --hard-reset
sudo ip link del eth10
sudo pkill -F /tmp/dnsmasq.macvlan0.pid
sudo mv $HOSTS_FILE_BACKUP /etc/hosts
sudo mv $hosts_file_backup /etc/hosts
sudo docker rm -f ceph-demo
sudo rm /etc/ceph/*
2 changes: 2 additions & 0 deletions testutil/singlevm/configuration.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
configure:
scheduler:
storage_uri: /etc/ciao/configuration.yaml
storage:
ceph_id: ciao
controller:
compute_ca: /etc/pki/ciao/controller_cert.pem
compute_cert: /etc/pki/ciao/controller_key.pem
Expand Down
4 changes: 1 addition & 3 deletions testutil/singlevm/run_launcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ default_if=$(ip route list | awk '/^default/ {print $5}')
default_subnet=$(ip -o -f inet addr show $default_if | awk '{print $4}')

#Cleanup artifacts
sudo "$GOPATH"/bin/ciao-launcher --cacert=./CAcert-"$ciao_host".pem --cert=./cert-CNAgent-NetworkingAgent-"$ciao_host".pem --alsologtostderr -v 3 --hard-reset
sudo "$GOPATH"/bin/ciao-launcher --alsologtostderr -v 3 --hard-reset

#Cleanup any prior docker instances and networks
sudo docker rm $(sudo docker ps -qa)
sudo docker network rm $(sudo docker network ls -q -f "type=custom")
sudo rm -f /var/lib/ciao/networking/docker_plugin.db

#Run launcher
Expand Down
145 changes: 23 additions & 122 deletions testutil/singlevm/setup.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
ciao_host=$(hostname)
ciao_ip=$(ip route get 8.8.8.8 | head -1 | cut -d' ' -f8)
ciao_subnet=$(echo $ciao_ip | sed -e 's/\([0-9]\+\).\([0-9]\+\).\([0-9]\+\).\([0-9]\+\)/\1.\2\.\3.0\/24/')
ciao_bin="$HOME/local"
ciao_cert="$ciao_bin""/cert-Scheduler-""$ciao_host"".pem"
export no_proxy=$no_proxy,$ciao_host
Expand All @@ -18,15 +19,13 @@ fedora_cloud_url="https://download.fedoraproject.org/pub/fedora/linux/releases/2
download=0
hosts_file_backup="/etc/hosts.orig.$RANDOM"

# Copy the cleanup scripts
cp "$ciao_scripts"/cleanup.sh "$ciao_bin"

cleanup()
{
echo "Performing cleanup"
"$ciao_gobin"/ciao-cli instance delete --all
#Also kill the CNCI (as there is no other way to delete it today)
sudo killall qemu-system-x86_64
sudo ip link del eth10
sudo pkill -F /tmp/dnsmasq.macvlan0.pid
sudo mv $hosts_file_backup /etc/hosts
echo "Performing cleanup"
"$ciao_bin"/cleanup.sh $hosts_file_backup
}

# Ctrl-C Trapper
Expand Down Expand Up @@ -91,8 +90,6 @@ sudo mv /etc/hosts $hosts_file_backup
echo "$ciao_ip $ciao_host" > hosts
sudo mv hosts /etc/hosts
sudo rm -rf /var/lib/ciao/instances
echo "Deleting docker containers. This may take time"
sudo docker rm -f $(sudo docker ps -a -q)

#Create a directory where all the certificates, binaries and other
#dependencies are placed
Expand Down Expand Up @@ -165,6 +162,7 @@ cp -f "$ciao_scripts"/tables/* "$ciao_bin"/tables
cp "$ciao_scripts"/run_scheduler.sh "$ciao_bin"
cp "$ciao_scripts"/run_controller.sh "$ciao_bin"
cp "$ciao_scripts"/run_launcher.sh "$ciao_bin"
cp "$ciao_scripts"/verify.sh "$ciao_bin"

#Download the firmware
cd "$ciao_bin"
Expand Down Expand Up @@ -252,6 +250,11 @@ sudo cp -f $fedora_cloud_image /var/lib/ciao/images
cd /var/lib/ciao/images
sudo ln -sf $fedora_cloud_image 73a86d7e-93c0-480e-9c41-ab42f69b7799

# Install ceph

sudo docker run --name ceph-demo -d --net=host -v /etc/ceph:/etc/ceph -e MON_IP=$ciao_ip -e CEPH_PUBLIC_NETWORK=$ciao_subnet ceph/demo
sudo ceph auth get-or-create client.ciao -o /etc/ceph/ceph.client.ciao.keyring mon 'allow *' osd 'allow *' mds 'allow'


# Set macvlan interface
if [ -x "$(command -v ip)" ]; then
Expand Down Expand Up @@ -290,126 +293,24 @@ echo "export CIAO_ADMIN_USERNAME=admin" >> "$ciao_env"
echo "export CIAO_ADMIN_PASSWORD=giveciaoatry" >> "$ciao_env"
echo "export CIAO_CA_CERT_FILE=/etc/pki/ciao/controller_cert.pem" >> "$ciao_env"
sleep 5
cat "$ciao_ctl_log"
identity=$(grep CIAO_IDENTITY $ciao_ctl_log | sed 's/^.*export/export/')
echo "$identity" >> "$ciao_env"
export CIAO_CONTROLLER="$ciao_host"
export CIAO_USERNAME=admin
export CIAO_PASSWORD=giveciaoatry

export CIAO_CA_CERT_FILE=/etc/pki/ciao/controller_cert.pem

eval "$identity"
"$ciao_gobin"/ciao-cli workload list

if [ $? -ne 0 ]
then
echo "FATAL ERROR: Unable to list workloads"
cleanup
exit 1
fi

"$ciao_gobin"/ciao-cli instance add --workload=e35ed972-c46c-4aad-a1e7-ef103ae079a2 --instances=2

if [ $? -ne 0 ]
then
echo "FATAL ERROR: Unable to launch VMs"
cleanup
exit 1
fi

"$ciao_gobin"/ciao-cli instance list

if [ $? -ne 0 ]
then
echo "FATAL ERROR: Unable to list instances"
cleanup
exit 1
fi

"$ciao_gobin"/ciao-cli instance add --workload=ab68111c-03a6-11e6-87de-001320fb6e31 --instances=2

if [ $? -ne 0 ]
then
echo "FATAL ERROR: Unable to launch containers"
cleanup
exit 1
fi

sleep 5

"$ciao_gobin"/ciao-cli instance list
if [ $? -ne 0 ]
then
echo "FATAL ERROR: Unable to list instances"
cleanup
exit 1
fi


#Check SSH connectivity
"$ciao_gobin"/ciao-cli instance list

#The VM takes time to boot as you are running on two
#layers of virtualization. Hence wait a bit
retry=0
until [ $retry -ge 6 ]
do
ssh_ip=$("$ciao_gobin"/ciao-cli instance list --workload=e35ed972-c46c-4aad-a1e7-ef103ae079a2 --detail | grep "SSH IP:" | sed 's/^.*SSH IP: //' | head -1)

if [ "$ssh_ip" == "" ]
then
echo "Waiting for instance to boot"
let retry=retry+1
sleep 30
continue
fi

ssh_check=$(head -1 < /dev/tcp/"$ssh_ip"/33002)
echo "$ssh_check"

echo "Attempting to ssh to: $ssh_ip"

if [[ "$ssh_check" == *SSH-2.0-OpenSSH* ]]
then
echo "SSH connectivity verified"
break
else
let retry=retry+1
echo "Retrying ssh connection $retry"
fi
sleep 30
done

if [ $retry -ge 6 ]
then
echo "Unable check ssh connectivity into VM"
cleanup
fi

#Check docker networking
echo "Checking Docker Networking"
sleep 30
docker_id=$(sudo docker ps -q | head -1)
sudo docker logs "$docker_id"


#Now delete all instances
"$ciao_gobin"/ciao-cli instance delete --all

if [ $? -ne 0 ]
then
echo "FATAL ERROR: Unable to delete instances"
exit 1
fi

"$ciao_gobin"/ciao-cli instance list
"$ciao_gobin"/ciao-cli instance delete --all
echo "---------------------------------------------------------------------------------------"
echo ""
echo "Your ciao development environment has been initialised."
echo "To get started run:"
echo ""
echo ". ~/local/demo.sh"
echo ""
echo "Verify the cluster is working correctly by running"
echo ""
echo "~/local/verify.sh"
echo ""
echo "Use ciao-cli to manipulate and inspect the cluster, e.g., "
echo ""
echo "ciao-cli instance add --workload=ab68111c-03a6-11e6-87de-001320fb6e31 --instances=1"
echo ""
echo "When you're finished run the following command to cleanup"
echo ""
echo "./cleanup.sh"
echo "~/local/cleanup.sh"
114 changes: 114 additions & 0 deletions testutil/singlevm/verify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#!/bin/bash

ciao_bin="$HOME/local"
ciao_gobin="$GOPATH"/bin

# Read cluster env variables

. $ciao_bin/demo.sh

"$ciao_gobin"/ciao-cli workload list

if [ $? -ne 0 ]
then
echo "FATAL ERROR: Unable to list workloads"
cleanup
exit 1
fi

"$ciao_gobin"/ciao-cli instance add --workload=e35ed972-c46c-4aad-a1e7-ef103ae079a2 --instances=2

if [ $? -ne 0 ]
then
echo "FATAL ERROR: Unable to launch VMs"
cleanup
exit 1
fi

"$ciao_gobin"/ciao-cli instance list

if [ $? -ne 0 ]
then
echo "FATAL ERROR: Unable to list instances"
cleanup
exit 1
fi

"$ciao_gobin"/ciao-cli instance add --workload=ab68111c-03a6-11e6-87de-001320fb6e31 --instances=2

if [ $? -ne 0 ]
then
echo "FATAL ERROR: Unable to launch containers"
cleanup
exit 1
fi

sleep 5

"$ciao_gobin"/ciao-cli instance list
if [ $? -ne 0 ]
then
echo "FATAL ERROR: Unable to list instances"
cleanup
exit 1
fi


#Check SSH connectivity
"$ciao_gobin"/ciao-cli instance list

#The VM takes time to boot as you are running on two
#layers of virtualization. Hence wait a bit
retry=0
until [ $retry -ge 6 ]
do
ssh_ip=$("$ciao_gobin"/ciao-cli instance list --workload=e35ed972-c46c-4aad-a1e7-ef103ae079a2 --detail | grep "SSH IP:" | sed 's/^.*SSH IP: //' | head -1)

if [ "$ssh_ip" == "" ]
then
echo "Waiting for instance to boot"
let retry=retry+1
sleep 30
continue
fi

ssh_check=$(head -1 < /dev/tcp/"$ssh_ip"/33002)
echo "$ssh_check"

echo "Attempting to ssh to: $ssh_ip"

if [[ "$ssh_check" == *SSH-2.0-OpenSSH* ]]
then
echo "SSH connectivity verified"
break
else
let retry=retry+1
echo "Retrying ssh connection $retry"
fi
sleep 30
done

if [ $retry -ge 6 ]
then
echo "Unable check ssh connectivity into VM"
cleanup
fi

#Check docker networking
echo "Checking Docker Networking"
sleep 30
docker_id=$(sudo docker ps -q | head -1)
sudo docker logs "$docker_id"


#Now delete all instances
"$ciao_gobin"/ciao-cli instance delete --all

if [ $? -ne 0 ]
then
echo "FATAL ERROR: Unable to delete instances"
exit 1
fi

"$ciao_gobin"/ciao-cli instance list
"$ciao_gobin"/ciao-cli instance delete --all

0 comments on commit 9e17e73

Please sign in to comment.