Skip to content

Commit a3b36d3

Browse files
committed
function wait_vhost0_up => common/functions.sh
Signed-off-by: Gleb Galkin <[email protected]> Change-Id: Ieb09abae8ef0d310b8ba0fff8da0b9d69744d1c7
1 parent d30c161 commit a3b36d3

File tree

6 files changed

+24
-42
lines changed

6 files changed

+24
-42
lines changed

ansible/run.sh

+1-10
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,6 @@ function openstack() {
141141
fi
142142
}
143143

144-
function wait_vhost0_up() {
145-
local node
146-
for node in ${AGENT_NODES} ; do
147-
scp $SSH_OPTIONS ${fmy_dir}/functions.sh ${node}:/tmp/functions.sh
148-
if ! ssh $SSH_OPTIONS ${node} "export PATH=\$PATH:/usr/sbin ; source /tmp/functions.sh ; wait_nic_up vhost0" ; then
149-
return 1
150-
fi
151-
done
152-
}
153144

154145
function tf() {
155146
current_container_tag=$(cat $tf_deployer_dir/instances.yaml | python3 -c "import yaml, sys ; data = yaml.safe_load(sys.stdin.read()); print(data['contrail_configuration']['CONTRAIL_CONTAINER_TAG'])")
@@ -175,7 +166,7 @@ function tf() {
175166
-e config_file=$tf_deployer_dir/instances.yaml \
176167
$tf_deployer_dir/playbooks/install_contrail.yml
177168

178-
if ! wait_cmd_success wait_vhost0_up 5 24
169+
if ! wait_cmd_success "wait_vhost0_up ${AGENT_NODES}" 5 24
179170
then
180171
echo "vhost0 interface(s) cannot obtain an IP address"
181172
return 1

common/functions.sh

+13
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,19 @@ function wait_nic_up() {
100100
echo "INFO: $nic is up"
101101
}
102102

103+
function wait_vhost0_up() {
104+
local node
105+
local node_list=$@
106+
for node in $(echo $node_list | tr ',' ' ') ; do
107+
scp $SSH_OPTIONS ${fmy_dir}/functions.sh ${node}:/tmp/functions.sh
108+
echo "INFO: Waiting for vhost0 is up on $node"
109+
if ! ssh $SSH_OPTIONS ${node} "export PATH=\$PATH:/usr/sbin ; source /tmp/functions.sh ; wait_nic_up vhost0" ; then
110+
return 1
111+
fi
112+
done
113+
}
114+
115+
103116
function nic_has_ip() {
104117
local nic=$1
105118
if nic_ip=$(ip addr show $nic | grep -o "inet [0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" | grep -o "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*"); then

helm/deploy_tf_helm.sh

+9-12
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,6 @@ function kill_helm_serve() {
4545
fi
4646
}
4747

48-
function wait_vhost0_up() {
49-
local a=$1
50-
local d="$(basename $(dirname $my_dir))"
51-
if ! ip a | grep -q "${a}"; then
52-
ssh $SSH_OPTIONS ${a} "export PATH=\$PATH:/usr/sbin ; source /tmp/${d}/common/functions.sh ; wait_nic_up vhost0"
53-
else
54-
wait_nic_up vhost0
55-
fi
56-
}
57-
5848
trap 'catch_errors' ERR
5949
function catch_errors() {
6050
local exit_code=$?
@@ -115,10 +105,15 @@ fi
115105

116106
kubectl create ns tungsten-fabric || :
117107
helm upgrade --install --namespace tungsten-fabric tungsten-fabric $WORKSPACE/tf-helm-deployer/$TF_CHART -f $WORKSPACE/tf-devstack-values.yaml $host_var
108+
REMOTE_AGENT_NODES=''
118109
if [[ $ORCHESTRATOR == "openstack" ]] ; then
119110
for machine in $AGENT_NODES ; do
120-
wait_vhost0_up $machine
111+
if ! ip a | grep -q "${machine}"; then
112+
REMOTE_AGENT_NODES+="${machine} "
113+
fi
121114
done
115+
wait_nic_up vhost0
116+
wait_vhost0_up $REMOTE_AGENT_NODES
122117

123118
# upgrade of neutron and nova containers with tf ones
124119
helm upgrade neutron $WORKSPACE/openstack-helm/neutron --namespace=openstack --force --reuse-values \
@@ -128,11 +123,13 @@ if [[ $ORCHESTRATOR == "openstack" ]] ; then
128123
fi
129124

130125
# multinodes "wait_nic_up vhost0"
126+
REMOTE_CONTROLLER_NODES=''
131127
for machine in $CONTROLLER_NODES ; do
132128
if echo $AGENT_NODES | grep -q $machine ; then
133-
wait_vhost0_up $machine
129+
REMOTE_CONTROLLER_NODES+="$machine "
134130
fi
135131
done
132+
wait_vhost0_up $REMOTE_CONTROLLER_NODES
136133

137134
label_nodes_by_ip opencontrail.org/controller=enabled $CONTROLLER_NODES
138135

openshift/functions.sh

-9
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,4 @@ function monitor_csr() {
154154
done
155155
}
156156

157-
function wait_vhost0_up() {
158-
local node
159-
for node in $(echo ${CONTROLLER_NODES} ${AGENT_NODES} | tr ',' ' ') ; do
160-
scp $SSH_OPTIONS ${fmy_dir}/functions.sh ${node}:/tmp/functions.sh
161-
if ! ssh $SSH_OPTIONS ${node} "export PATH=\$PATH:/usr/sbin ; source /tmp/functions.sh ; wait_nic_up vhost0" ; then
162-
return 1
163-
fi
164-
done
165-
}
166157

operator/functions.sh

-10
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,6 @@ EOF
127127
}
128128

129129

130-
function wait_vhost0_up() {
131-
local node
132-
for node in $(echo ${CONTROLLER_NODES} ${AGENT_NODES} | tr ',' ' ') ; do
133-
scp $SSH_OPTIONS ${fmy_dir}/functions.sh ${node}:/tmp/functions.sh
134-
if ! ssh $SSH_OPTIONS ${node} "export PATH=\$PATH:/usr/sbin ; source /tmp/functions.sh ; wait_nic_up vhost0" ; then
135-
return 1
136-
fi
137-
done
138-
}
139-
140130
function rhel_setup_all_the_nodes()
141131
{
142132
local jobs=""

operator/run.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ function tf() {
142142
# apply contrail cluster
143143
kubectl apply -k $OPERATOR_REPO/deploy/kustomize/contrail/templates/
144144

145-
if ! wait_cmd_success wait_vhost0_up 5 24; then
145+
if ! wait_cmd_success "wait_vhost0_up ${CONTROLLER_NODES}, ${AGENT_NODES}" 5 24; then
146146
echo "vhost0 interface(s) cannot obtain an IP address"
147147
return 1
148148
fi

0 commit comments

Comments
 (0)