Skip to content

Commit

Permalink
Removed eth0 hardcoding
Browse files Browse the repository at this point in the history
  • Loading branch information
Sriram S committed Nov 17, 2015
1 parent 2640a68 commit 3bffb05
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
14 changes: 7 additions & 7 deletions util/update-etc-hosts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dir_path=$(dirname $0)
node_type=`bash $(dirname $0)/detect-nodetype.sh`
echo "Local host type is: $node_type"

local_ip_address=`ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
local_ip_address=`ifconfig $1 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
echo "Local host IP is: $local_ip_address"

local_host_name=`hostname`
Expand All @@ -41,25 +41,25 @@ sleep 3

if [ "$node_type" == "controller" ] || [ "$node_type" = "controller_networknode" ]
then
if [ $# -eq 1 ]
if [ $# -eq 2 ]
then
echo "Adding controller node info to /etc/hosts"
change-ip-in-etc-hosts $1 $local_ip_address
change-ip-in-etc-hosts $2 $local_ip_address
else
echo "Correct syntax: $0 <controller-host-name>"
echo "Correct syntax: $0 <mgmt-interface-name> <controller-host-name>"
exit 1;
fi
elif [ "$node_type" == "compute" ] || [ "$node_type" == "networknode" ]
then
if [ $# -eq 2 ]
if [ $# -eq 3 ]
then
echo "Updating local node IP address to /etc/hosts"
change-ip-in-etc-hosts $local_host_name $local_ip_address

echo "Updating controller IP address to /etc/hosts"
change-ip-in-etc-hosts $1 $2
change-ip-in-etc-hosts $2 $3
else
echo "Correct syntax: $0 <controller-host-name> <controller-ip-address>"
echo "Correct syntax: $0 <mgmt-interface-name> <controller-host-name> <controller-ip-address>"
exit 1;
fi
else
Expand Down
28 changes: 14 additions & 14 deletions util/update-ip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,35 @@ node_type=`bash $(dirname $0)/detect-nodetype.sh`
echo "Node Type detected as: $node_type"
sleep 3

if [ $# -lt 1 ]
if [ $# -lt 2 ]
then
echo "Correct Syntax: $0 <controller-host-name> <controller-ip-address>"
echo "Correct Syntax: $0 <mgmt-interface-name> <controller-host-name> <controller-ip-address>"
echo "Second parameter required only for Network and Compute Node"
exit 1;
fi


function update-nova-config-ip() {
mgmg_interface_ip=`ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
mgmg_interface_ip=`ifconfig $1 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
echo "Local Node IP: $mgmg_interface_ip"
sleep 2

crudini --set /etc/nova/nova.conf DEFAULT my_ip $mgmg_interface_ip
crudini --set /etc/nova/nova.conf DEFAULT vncserver_proxyclient_address $mgmg_interface_ip

if [ "$1" == "controller" ]
if [ "$2" == "controller" ]
then
crudini --set /etc/nova/nova.conf DEFAULT vncserver_listen $mgmg_interface_ip
sleep 2
service nova-novncproxy restart
else
if [ -z "$2" ]
if [ -z "$3" ]
then
echo "Correct syntax for Compute Node: $0 <controller-ip-address>"
echo "Correct syntax for Compute Node: $0 <mgmt-interface> compute <controller-ip-address>"
exit 1;
else
crudini --set /etc/nova/nova.conf DEFAULT vncserver_listen 0.0.0.0
crudini --set /etc/nova/nova.conf DEFAULT novncproxy_base_url http://$2:6080/vnc_auto.html
crudini --set /etc/nova/nova.conf DEFAULT novncproxy_base_url http://$3:6080/vnc_auto.html
sleep 2
service nova-compute restart
fi
Expand All @@ -43,22 +43,22 @@ function update-nova-config-ip() {

case $node_type in
controller)
bash $(dirname $0)/update-etc-hosts.sh $1
update-nova-config-ip controller
bash $(dirname $0)/update-etc-hosts.sh $1 $2
update-nova-config-ip $1 controller
bash $(dirname $0)/manage-services.sh all restart
;;
compute)
bash $(dirname $0)/update-etc-hosts.sh $1 $2
update-nova-config-ip compute $2
bash $(dirname $0)/update-etc-hosts.sh $1 $2 $3
update-nova-config-ip $1 compute $3
bash $(dirname $0)/manage-services.sh all restart
;;
networknode)
bash $(dirname $0)/update-etc-hosts.sh $1 $2
bash $(dirname $0)/update-etc-hosts.sh $1 $2 $3
bash $(dirname $0)/manage-services.sh all restart
;;
controller_networknode)
bash $(dirname $0)/update-etc-hosts.sh $1
update-nova-config-ip controller
bash $(dirname $0)/update-etc-hosts.sh $1 $2
update-nova-config-ip $1 controller
bash $(dirname $0)/manage-services.sh all restart
;;
*)
Expand Down

0 comments on commit 3bffb05

Please sign in to comment.