aboutsummaryrefslogtreecommitdiffstats
path: root/deploy
diff options
context:
space:
mode:
Diffstat (limited to 'deploy')
-rwxr-xr-xdeploy/network.sh40
-rwxr-xr-xdeploy/prepare.sh2
-rw-r--r--deploy/template/network/bridge_ovs.xml6
3 files changed, 46 insertions, 2 deletions
diff --git a/deploy/network.sh b/deploy/network.sh
index ac0a73e2..836af0f9 100755
--- a/deploy/network.sh
+++ b/deploy/network.sh
@@ -16,6 +16,44 @@ function setup_bridge_net()
sudo virsh net-start $net_name
}
+function save_network_info()
+{
+ sudo ovs-vsctl list-br |grep br-external
+ br_exist=$?
+ external_nic=`ip route |grep '^default'|awk '{print $NF}'`
+ route_info=`ip route |grep -Eo '^default via [^ ]+'`
+ ip_info=`ip addr show $external_nic|grep -Eo '[^ ]+ brd [^ ]+ '`
+ if [ $br_exist -eq 0 ]; then
+ if [ "$external_nic" != "br-external" ]; then
+ sudo ovs-vsctl --may-exist add-port br-external $external_nic
+ sudo ip addr flush $external_nic
+ sudo ip addr add $ip_info dev br-external
+ sudo ip route add $route_info dev br-external
+ fi
+ else
+ sudo ovs-vsctl add-br br-external
+ sudo ovs-vsctl add-port br-external $external_nic
+ sudo ip addr flush $external_nic
+ sudo ip addr add $ip_info dev br-external
+ sudo ip route add $route_info dev br-external
+ fi
+}
+
+function setup_bridge_external()
+{
+ sudo virsh net-destroy external
+ sudo virsh net-undefine external
+
+ save_network_info
+ sed -e "s/REPLACE_NAME/external/g" \
+ -e "s/REPLACE_OVS/br-external/g" \
+ $COMPASS_DIR/deploy/template/network/bridge_ovs.xml \
+ > $WORK_DIR/network/external.xml
+
+ sudo virsh net-define $WORK_DIR/network/external.xml
+ sudo virsh net-start external
+}
+
function setup_nat_net() {
net_name=$1
gw=$2
@@ -50,5 +88,5 @@ function create_nets() {
fi
# create external network
- setup_bridge_net external $EXTERNAL_NIC
+ setup_bridge_external
}
diff --git a/deploy/prepare.sh b/deploy/prepare.sh
index ce8b7aca..e8b2103e 100755
--- a/deploy/prepare.sh
+++ b/deploy/prepare.sh
@@ -19,7 +19,7 @@ function download_iso()
function prepare_env() {
export PYTHONPATH=/usr/lib/python2.7/dist-packages:/usr/local/lib/python2.7/dist-packages
sudo apt-get update -y
- sudo apt-get install -y --force-yes mkisofs bc curl ipmitool
+ sudo apt-get install -y --force-yes mkisofs bc curl ipmitool openvswitch-switch
sudo apt-get install -y --force-yes git python-pip python-dev
sudo apt-get install -y --force-yes libxslt-dev libxml2-dev libvirt-dev build-essential qemu-utils qemu-kvm libvirt-bin virtinst libmysqld-dev
sudo pip install --upgrade pip
diff --git a/deploy/template/network/bridge_ovs.xml b/deploy/template/network/bridge_ovs.xml
new file mode 100644
index 00000000..cf01a5d9
--- /dev/null
+++ b/deploy/template/network/bridge_ovs.xml
@@ -0,0 +1,6 @@
+ <network ipv6='no'>
+ <name>REPLACE_NAME</name>
+ <bridge name='REPLACE_OVS'/>
+ <forward mode='bridge'/>
+ <virtualport type='openvswitch'/>
+ </network>