aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--deploy/compass_vm.sh4
-rw-r--r--deploy/conf/base.conf2
-rw-r--r--deploy/host_virtual.sh6
-rwxr-xr-xdeploy/network.sh173
-rw-r--r--deploy/template/network/bridge_nic.xml6
-rw-r--r--deploy/template/vm/compass.xml8
-rw-r--r--deploy/template/vm/host.xml8
7 files changed, 51 insertions, 156 deletions
diff --git a/deploy/compass_vm.sh b/deploy/compass_vm.sh
index 944c6cff..9e192281 100644
--- a/deploy/compass_vm.sh
+++ b/deploy/compass_vm.sh
@@ -100,8 +100,8 @@ function launch_compass() {
-e "s#REPLACE_IMAGE#$compass_vm_dir/disk.img#g" \
-e "s#REPLACE_ISO#$compass_vm_dir/centos.iso#g" \
-e "s/REPLACE_NET_MGMT/mgmt/g" \
- -e "s/REPLACE_BRIDGE_INSTALL/br_install/g" \
- -e "s/REPLACE_BRIDGE_EXTERNAL/br_external/g" \
+ -e "s/REPLACE_NET_INSTALL/install/g" \
+ -e "s/REPLACE_NET_EXTERNAL/external/g" \
$COMPASS_DIR/deploy/template/vm/compass.xml \
> $WORK_DIR/vm/compass/libvirt.xml
diff --git a/deploy/conf/base.conf b/deploy/conf/base.conf
index c48aca64..d3d535dc 100644
--- a/deploy/conf/base.conf
+++ b/deploy/conf/base.conf
@@ -9,7 +9,7 @@ export MGMT_MASK=${MAGMT_MASK:-255.255.252.0}
export MGMT_GW=${MAGMT_GW:-192.168.200.1}
export MGMT_IP_START=${MGMT_IP_START:-192.168.200.3}
export MGMT_IP_END=${MGMT_IP_END:-192.168.200.254}
-export EXTERNAL_NIC=${EXTERNAL_NIC:-eth3}
+export EXTERNAL_NIC=${EXTERNAL_NIC:-eth0}
export CLUSTER_NAME="opnfv2"
export DOMAIN="ods.com"
export PARTITIONS="/=70%,/home=5%,/tmp=5%,/var=20%"
diff --git a/deploy/host_virtual.sh b/deploy/host_virtual.sh
index 35ab4352..d769010b 100644
--- a/deploy/host_virtual.sh
+++ b/deploy/host_virtual.sh
@@ -30,10 +30,8 @@ function launch_host_vms() {
-e "s/REPLACE_NAME/$host/g" \
-e "s#REPLACE_IMAGE#$vm_dir/disk.img#g" \
-e "s/REPLACE_BOOT_MAC/${mac_array[i]}/g" \
- -e "s/REPLACE_BRIDGE_MGMT/br_install/g" \
- -e "s/REPLACE_BRIDGE_TENANT/br_external/g" \
- -e "s/REPLACE_BRIDGE_PUBLIC/br_install/g" \
- -e "s/REPLACE_BRIDGE_STORAGE/br_install/g" \
+ -e "s/REPLACE_NET_INSTALL/install/g" \
+ -e "s/REPLACE_NET_TENANT/external/g" \
$COMPASS_DIR/deploy/template/vm/host.xml\
> $vm_dir/libvirt.xml
diff --git a/deploy/network.sh b/deploy/network.sh
index e5133c9e..ac0a73e2 100755
--- a/deploy/network.sh
+++ b/deploy/network.sh
@@ -1,163 +1,54 @@
-function destroy_nat() {
- sudo virsh net-destroy $1 2>&1
- sudo virsh net-undefine $1 2>&1
- rm -rf $COMPASS_DIR/deploy/work/network/$1.xml
-}
-
-function destroy_bridge()
-{
- bridge=$1
- nic=$2
- ip="$3"
-
- brige_info=$(ip addr show $bridge 2>/dev/null)
- if [[ -z $brige_info ]]; then
- return
- fi
-
- if [[ -n $ip ]]; then
- ip addr delete $ip dev $bridge | true
- fi
-
- ips=`echo "$brige_info" | grep 'inet ' | sed "s/inet //g"`
-
- routes=$(ip route show | grep $bridge)
-
- ip link set $bridge down
-
- brctl delbr $bridge
-
- if [[ -n $ips ]]; then
- echo "$ips" | while read line; do
- echo $line | sed "s/$bridge/dev $nic/g" | xargs ip addr add | true
- done
- fi
-
- if [[ -n $routes ]]; then
- echo "$routes" | while read line; do
- echo $line | sed "s/$bridge/$nic/g" | xargs ip route add | true
- done
- fi
-}
-
-function get_broadcast_addr()
-{
- ip=(${1//[!0-9]/ })
- mask=(${2//[!0-9]/ })
-
- for i in {0..3}; do
- num=$((${ip[$i]} | $((${mask[$i]} ^ 255))))
- if [[ -z $broadcast ]]; then
- broadcast="$num"
- else
- broadcast="$broadcast.$num"
- fi
- done
- echo ${broadcast}
-}
-function get_mask_len()
+function setup_bridge_net()
{
- mask=`echo $1 | awk -F'.' '{print ($1*(2^24)+$2*(2^16)+$3*(2^8)+$4)}'`
- mask_len=`echo "obase=2;${mask}"|bc|awk -F'0' '{print length($1)}'`
- echo $mask_len
-}
-
-function create_bridge()
-{
- bridge=$1
+ net_name=$1
nic=$2
- ips=$(ip addr show $nic | grep 'inet ' | sed "s/inet //g")
- routes=$(ip route show | grep $nic)
- ip addr flush $nic
-
- brctl addbr $bridge
- brctl addif $bridge $nic
- ip link set $bridge up
-
- if [[ -n $ips ]]; then
- echo "$ips" | while read line; do
- echo $line | sed -e "s/$nic/dev $bridge/g" | xargs ip addr add
- done
- fi
+ sudo virsh net-destroy $net_name
+ sudo virsh net-undefine $net_name
+ sed -e "s/REPLACE_NAME/$net_name/g" \
+ -e "s/REPLACE_NIC/$nic/g" \
+ $COMPASS_DIR/deploy/template/network/bridge_nic.xml \
+ > $WORK_DIR/network/$net_name.xml
- if [[ -n $routes ]]; then
- echo "$routes" | while read line; do
- echo $line | sed "s/$nic/$bridge/g" | xargs ip route add | true
- done
- fi
+ sudo virsh net-define $WORK_DIR/network/$net_name.xml
+ sudo virsh net-start $net_name
}
-function add_install_ip() {
- mask_len=`get_mask_len $INSTALL_MASK`
- broadcast=`get_broadcast_addr $INSTALL_GW $INSTALL_MASK`
- ip addr add $INSTALL_GW/$mask_len brd $broadcast dev $bridge
-}
+function setup_nat_net() {
+ net_name=$1
+ gw=$2
+ mask=$3
+ ip_start=$4
+ ip_end=$5
-function setup_install_bridge() {
- destroy_bridge br_install $INSTALL_NIC $INSTALL_GW
- create_bridge br_install $INSTALL_NIC
- add_install_ip
-}
-
-function setup_external_net() {
- if [[ -z `brctl show br_external 2>/dev/null` ]]; then
- brctl addbr br_external
- fi
-
- if [[ -z $EXTERNAL_NIC ]]; then
- return
- fi
-
- if [[ $TYPE == baremetal && $EXTERNAL_NIC == $INSTALL_NIC ]]; then
- exit 1
- fi
-
- destroy_bridge br_external $EXTERNAL_NIC ""
- create_bridge br_external $EXTERNAL_NIC
-}
-
-function setup_install_nat() {
- destroy_nat install
+ sudo virsh net-destroy $net_name
+ sudo virsh net-undefine $net_name
# create install network
- sed -e "s/REPLACE_BRIDGE/br_install/g" \
- -e "s/REPLACE_NAME/install/g" \
- -e "s/REPLACE_GATEWAY/$INSTALL_GW/g" \
- -e "s/REPLACE_MASK/$INSTALL_MASK/g" \
- -e "s/REPLACE_START/$INSTALL_IP_START/g" \
- -e "s/REPLACE_END/$INSTALL_IP_END/g" \
+ sed -e "s/REPLACE_BRIDGE/br_$net_name/g" \
+ -e "s/REPLACE_NAME/$net_name/g" \
+ -e "s/REPLACE_GATEWAY/$gw/g" \
+ -e "s/REPLACE_MASK/$mask/g" \
+ -e "s/REPLACE_START/$ip_start/g" \
+ -e "s/REPLACE_END/$ip_end/g" \
$COMPASS_DIR/deploy/template/network/nat.xml \
- > $WORK_DIR/network/install.xml
+ > $WORK_DIR/network/$net_name.xml
- sudo virsh net-define $WORK_DIR/network/install.xml
- sudo virsh net-start install
+ sudo virsh net-define $WORK_DIR/network/$net_name.xml
+ sudo virsh net-start $net_name
}
function create_nets() {
- destroy_nat mgmt
- # create mgmt network
- sed -e "s/REPLACE_BRIDGE/br_mgmt/g" \
- -e "s/REPLACE_NAME/mgmt/g" \
- -e "s/REPLACE_GATEWAY/$MGMT_GW/g" \
- -e "s/REPLACE_MASK/$MGMT_MASK/g" \
- -e "s/REPLACE_START/$MGMT_IP_START/g" \
- -e "s/REPLACE_END/$MGMT_IP_END/g" \
- $COMPASS_DIR/deploy/template/network/nat.xml \
- > $WORK_DIR/network/mgmt.xml
-
- sudo virsh net-define $WORK_DIR/network/mgmt.xml
- sudo virsh net-start mgmt
+ setup_nat_net mgmt $MGMT_GW $MGMT_MASK $MGMT_IP_START $MGMT_IP_END
# create install network
- if [[ ! -z $VIRT_NUMBER ]];then
- setup_install_nat
+ if [[ -n $INSTALL_NIC ]]; then
+ setup_bridge_net install $INSTALL_NIC
else
- setup_install_bridge
+ setup_nat_net install $INSTALL_GW $INSTALL_MASK
fi
# create external network
- setup_external_net
+ setup_bridge_net external $EXTERNAL_NIC
}
-
diff --git a/deploy/template/network/bridge_nic.xml b/deploy/template/network/bridge_nic.xml
new file mode 100644
index 00000000..055845fb
--- /dev/null
+++ b/deploy/template/network/bridge_nic.xml
@@ -0,0 +1,6 @@
+<network>
+<name>REPLACE_NAME</name>
+<forward mode="bridge">
+ <interface dev="REPLACE_NIC"/>
+</forward>
+</network>
diff --git a/deploy/template/vm/compass.xml b/deploy/template/vm/compass.xml
index 453e728d..182232f4 100644
--- a/deploy/template/vm/compass.xml
+++ b/deploy/template/vm/compass.xml
@@ -41,13 +41,13 @@
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</interface>
- <interface type='bridge'>
- <source bridge='REPLACE_BRIDGE_INSTALL'/>
+ <interface type='network'>
+ <source network='REPLACE_NET_INSTALL'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</interface>
- <interface type='bridge'>
- <source bridge='REPLACE_BRIDGE_EXTERNAL'/>
+ <interface type='network'>
+ <source network='REPLACE_NET_EXTERNAL'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
</interface>
diff --git a/deploy/template/vm/host.xml b/deploy/template/vm/host.xml
index 11b29f0c..e6eca551 100644
--- a/deploy/template/vm/host.xml
+++ b/deploy/template/vm/host.xml
@@ -25,14 +25,14 @@
<source file='REPLACE_IMAGE'/>
<target dev='vda' bus='virtio'/>
</disk>
- <interface type='bridge'>
+ <interface type='network'>
<mac address=REPLACE_BOOT_MAC/>
- <source bridge='REPLACE_BRIDGE_MGMT'/>
+ <source network='REPLACE_NET_INSTALL'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</interface>
- <interface type='bridge'>
- <source bridge='REPLACE_BRIDGE_TENANT'/>
+ <interface type='network'>
+ <source network='REPLACE_NET_TENANT'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</interface>