summaryrefslogtreecommitdiffstats
path: root/lib/common-functions.sh
diff options
context:
space:
mode:
authorTim Rozet <trozet@redhat.com>2016-01-27 15:20:07 -0500
committerTim Rozet <trozet@redhat.com>2016-01-27 21:37:20 -0500
commit4a7e1d41a5356f18b900986b06dccd968ab6b6a0 (patch)
tree43e31f987a06de32e5213836e93e8c94647ee4ad /lib/common-functions.sh
parentcc5578d53c28b80a3a1449b036b714c8647c11ae (diff)
Fixes various bugs and adds some improvements
Changes Include: - Disables introspection. We don't currently use introspection for anything other than to just run it. Disabling it to increase deploy speed and reduce pxeboot issues. - Adds timeout to deploy of 90 minutes. Default heat timeout is 3-4 hours. - Fixes OVS bridge attach/detach for users who use PREFIX in their ifcfg instead of NETMASK - Adds nosdn deploy settings file, and allows nosdn deployments - Adds example inventory file to the docs dir Change-Id: Ic13d6c4d5f27bac25365e5951acdd9bd3e641a15 Signed-off-by: Tim Rozet <trozet@redhat.com>
Diffstat (limited to 'lib/common-functions.sh')
-rw-r--r--lib/common-functions.sh28
1 files changed, 24 insertions, 4 deletions
diff --git a/lib/common-functions.sh b/lib/common-functions.sh
index 1e55aa18..7435411e 100644
--- a/lib/common-functions.sh
+++ b/lib/common-functions.sh
@@ -2,6 +2,15 @@
# Common Functions used by OPNFV Apex
# author: Tim Rozet (trozet@redhat.com)
+##converts subnet mask to prefix
+##params: subnet mask
+function prefix2mask {
+ # Number of args to shift, 255..255, first non-255 byte, zeroes
+ set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0
+ [ $1 -gt 1 ] && shift $1 || shift
+ echo ${1-0}.${2-0}.${3-0}.${4-0}
+}
+
##find ip of interface
##params: interface name
function find_ip {
@@ -356,7 +365,7 @@ function generate_floating_ip_range {
##public indicates attaching to a public interface
function attach_interface_to_ovs {
local bridge interface
- local if_ip if_mask if_gw if_file ovs_file
+ local if_ip if_mask if_gw if_file ovs_file if_prefix
if [[ -z "$1" || -z "$2" ]]; then
return 1
@@ -381,8 +390,14 @@ function attach_interface_to_ovs {
return 1
fi
+ if [ -z "$if_mask" ]; then
+ # we can look for PREFIX here, then convert it to NETMASK
+ if_prefix=$(sed -n 's/^PREFIX=\(.*\)$/\1/p' ${if_file})
+ if_mask=$(prefix2mask ${if_prefix})
+ fi
+
if [[ -z "$if_ip" || -z "$if_mask" ]]; then
- echo "ERROR: IPADDR or NETMASK missing for ${interface}"
+ echo "ERROR: IPADDR or NETMASK/PREFIX missing for ${interface}"
return 1
elif [[ -z "$if_gw" && "$3" == "public_network" ]]; then
echo "ERROR: GATEWAY missing for ${interface}, which is public"
@@ -436,7 +451,7 @@ function detach_interface_from_ovs {
local bridge
local port_output ports_no_orig
local net_path
- local if_ip if_mask if_gw
+ local if_ip if_mask if_gw if_prefix
net_path=/etc/sysconfig/network-scripts/
if [[ -z "$1" ]]; then
@@ -462,8 +477,13 @@ function detach_interface_from_ovs {
if_mask=$(sed -n 's/^NETMASK=\(.*\)$/\1/p' ${if_file})
if_gw=$(sed -n 's/^GATEWAY=\(.*\)$/\1/p' ${if_file})
+ if [ -z "$if_mask" ]; then
+ if_prefix=$(sed -n 's/^PREFIX=\(.*\)$/\1/p' ${if_file})
+ if_mask=$(prefix2mask ${if_prefix})
+ fi
+
if [[ -z "$if_ip" || -z "$if_mask" ]]; then
- echo "ERROR: IPADDR or NETMASK missing for ${bridge} and no .orig file for interface ${line}"
+ echo "ERROR: IPADDR or PREFIX/NETMASK missing for ${bridge} and no .orig file for interface ${line}"
return 1
fi