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 #696 from mcastelino/single_vm_tls_fix
Browse files Browse the repository at this point in the history
Single VM: Eliminate the need to modify /etc/hosts or use host IP
  • Loading branch information
rbradford authored Oct 18, 2016
2 parents d5405e5 + bc77fbe commit 74c1e8d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 41 deletions.
12 changes: 3 additions & 9 deletions testutil/singlevm/cleanup.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
#!/bin/bash

if [ ! -z $1 ]; then
hosts_file_backup=$1
else
. ~/local/demo.sh
hosts_file_backup=$HOSTS_FILE_BACKUP
fi
. ~/local/demo.sh

ciao_gobin="$GOPATH"/bin
sudo killall ciao-scheduler
Expand All @@ -14,9 +9,8 @@ sudo killall ciao-image
sudo killall ciao-launcher
sleep 2
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 ip link del ciao_eth
sudo pkill -F /tmp/dnsmasq.ciaovlan.pid
sudo docker rm -v -f ceph-demo
sudo rm /etc/ceph/*
sudo rm /etc/pki/ciao/controller_key.pem /etc/pki/ciao/ciao-image-key.pem
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Only listen to routers' LAN NIC. Doing so opens up tcp/udp port 53 to
# localhost and udp port 67 to world:
interface=macvlan0
interface=ciaovlan

listen-address=198.51.100.1

Expand All @@ -22,4 +22,4 @@ log-queries

log-dhcp

#dhcp-host=aa:bb:cc:dd:ee:ff,198.51.100.50
#dhcp-host=aa:bb:cc:dd:ee:ff,198.51.100.50
56 changes: 26 additions & 30 deletions testutil/singlevm/setup.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/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_interface=ciao_eth
ciao_ip=198.51.100.1
ciao_subnet=198.51.100.1/24
ciao_brdcast=198.51.100.255
ciao_bin="$HOME/local"
ciao_cert="$ciao_bin""/cert-Scheduler-""$ciao_host"".pem"
export no_proxy=$no_proxy,$ciao_host
export no_proxy=$no_proxy,$ciao_ip,$ciao_host

ciao_email="[email protected]"
ciao_org="Intel"
Expand All @@ -18,7 +20,8 @@ ciao_cnci_url="https://download.clearlinux.org/demos/ciao"
fedora_cloud_image="Fedora-Cloud-Base-24-1.2.x86_64.qcow2"
fedora_cloud_url="https://download.fedoraproject.org/pub/fedora/linux/releases/24/CloudImages/x86_64/images/Fedora-Cloud-Base-24-1.2.x86_64.qcow2"
download=0
hosts_file_backup="/etc/hosts.orig.$RANDOM"

echo "Subnet =" $ciao_subnet

#Create a directory where all the certificates, binaries and other
#dependencies are placed
Expand All @@ -36,7 +39,7 @@ cp "$ciao_scripts"/cleanup.sh "$ciao_bin"
cleanup()
{
echo "Performing cleanup"
"$ciao_bin"/cleanup.sh $hosts_file_backup
"$ciao_bin"/cleanup.sh
}

# Ctrl-C Trapper
Expand Down Expand Up @@ -105,10 +108,6 @@ sudo killall ciao-controller
sudo killall ciao-launcher
sudo killall ciao-image
sudo killall qemu-system-x86_64
echo "Original /etc/hosts is temporarily move to $hosts_file_backup"
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

cd "$ciao_bin"
Expand Down Expand Up @@ -143,13 +142,13 @@ then
fi

#Generate Certificates
"$GOPATH"/bin/ciao-cert -server -role scheduler -email="$ciao_email" -organization="$ciao_org" -host="$ciao_host" -verify
"$GOPATH"/bin/ciao-cert -server -role scheduler -email="$ciao_email" -organization="$ciao_org" -host="$ciao_host" -ip="$ciao_ip" -verify

"$GOPATH"/bin/ciao-cert -role cnciagent -server-cert "$ciao_cert" -email="$ciao_email" -organization="$ciao_org" -host="$ciao_host" -verify
"$GOPATH"/bin/ciao-cert -role cnciagent -server-cert "$ciao_cert" -email="$ciao_email" -organization="$ciao_org" -host="$ciao_host" -ip="$ciao_ip" -verify

"$GOPATH"/bin/ciao-cert -role controller -server-cert "$ciao_cert" -email="$ciao_email" -organization="$ciao_org" -host="$ciao_host" -verify
"$GOPATH"/bin/ciao-cert -role controller -server-cert "$ciao_cert" -email="$ciao_email" -organization="$ciao_org" -host="$ciao_host" -ip="$ciao_ip" -verify

"$GOPATH"/bin/ciao-cert -role agent,netagent -server-cert "$ciao_cert" -email="$ciao_email" -organization="$ciao_org" -host="$ciao_host" -verify
"$GOPATH"/bin/ciao-cert -role agent,netagent -server-cert "$ciao_cert" -email="$ciao_email" -organization="$ciao_org" -host="$ciao_host" -ip="$ciao_ip" -verify

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout controller_key.pem -out controller_cert.pem -subj "/C=US/ST=CA/L=Santa Clara/O=ciao/CN=$ciao_host"

Expand Down Expand Up @@ -252,42 +251,39 @@ then
exit 1
fi

# 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
sudo ip link del eth10
sudo ip link add name eth10 type bridge
sudo ip link add link eth10 name macvlan0 type macvlan mode bridge
sudo ip addr add 198.51.100.1/24 brd 198.51.100.255 dev macvlan0
sudo ip link set dev macvlan0 up
sudo ip -d link show macvlan0
sudo ip link set dev eth10 up
sudo ip -d link show eth10
sudo ip link del "$ciao_interface"
sudo ip link add name "$ciao_interface" type bridge
sudo ip link add link "$ciao_interface" name ciaovlan type macvlan mode bridge
sudo ip addr add "$ciao_subnet" brd "$ciao_brdcast" dev ciaovlan
sudo ip link set dev ciaovlan up
sudo ip -d link show ciaovlan
sudo ip link set dev "$ciao_interface" up
sudo ip -d link show "$ciao_interface"
else
echo 'ip command is not supported'
fi

# Set DHCP server with dnsmasq
sudo mkdir -p /var/lib/misc
if [ -x "$(command -v ip)" ]; then
sudo dnsmasq -C $ciao_scripts/dnsmasq.conf.macvlan0 \
--pid-file=/tmp/dnsmasq.macvlan0.pid
sudo dnsmasq -C $ciao_scripts/dnsmasq.conf.ciaovlan \
--pid-file=/tmp/dnsmasq.ciaovlan.pid
else
echo 'dnsmasq command is not supported'
fi

# 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'

#Kick off the agents
cd "$ciao_bin"
"$ciao_bin"/run_scheduler.sh &> /dev/null
"$ciao_bin"/run_launcher.sh &> /dev/null
"$ciao_bin"/run_controller.sh &> /dev/null

echo "export HOSTS_FILE_BACKUP=""$hosts_file_backup" > "$ciao_env"
echo "export CIAO_CONTROLLER=""$ciao_host" >> "$ciao_env"
echo "export CIAO_USERNAME=admin" >> "$ciao_env"
echo "export CIAO_PASSWORD=giveciaoatry" >> "$ciao_env"
Expand Down

0 comments on commit 74c1e8d

Please sign in to comment.