summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-03-14 12:15:15 +0000
committerGerrit Code Review <review@openstack.org>2017-03-14 12:15:15 +0000
commit46f01bc4ee08ce5e244fa16a30c127505df88195 (patch)
treed0f5c2883641771648e60c18e37f61681fdd4fa8
parent8abe8a95c76b8ba66099fbb67f712e6b22b0f422 (diff)
parent89659ee6cbfbefbf76eed8ceab4e3d4cf165b487 (diff)
Merge "Refactor ns_vrouter ocf"
-rw-r--r--files/fuel-ha-utils/ocf/ns_vrouter27
1 files changed, 18 insertions, 9 deletions
diff --git a/files/fuel-ha-utils/ocf/ns_vrouter b/files/fuel-ha-utils/ocf/ns_vrouter
index d0bf19c..03a4578 100644
--- a/files/fuel-ha-utils/ocf/ns_vrouter
+++ b/files/fuel-ha-utils/ocf/ns_vrouter
@@ -182,6 +182,10 @@ END
182exit $OCF_SUCCESS 182exit $OCF_SUCCESS
183} 183}
184 184
185nsip() {
186 ip netns exec "${OCF_RESKEY_ns}" ip ${@}
187}
188
185check_ns() { 189check_ns() {
186 local LH="${LL} check_ns():" 190 local LH="${LL} check_ns():"
187 local ns=$(ip netns list | awk "/${OCF_RESKEY_ns}/ {print \$1}") 191 local ns=$(ip netns list | awk "/${OCF_RESKEY_ns}/ {print \$1}")
@@ -206,11 +210,7 @@ get_ns() {
206 return $rc 210 return $rc
207} 211}
208 212
209set_ns_routing() { 213set_ns_interfaces() {
210 nsip() {
211 ip netns exec "${OCF_RESKEY_ns}" ip ${@}
212 }
213
214 # create host-ns veth pair unless it's present 214 # create host-ns veth pair unless it's present
215 ip link | grep -q '^[[:digit:]]\+:[[:space:]]\+'"${OCF_RESKEY_host_interface}"'[@:]' 215 ip link | grep -q '^[[:digit:]]\+:[[:space:]]\+'"${OCF_RESKEY_host_interface}"'[@:]'
216 if [ $? -gt 0 ]; then 216 if [ $? -gt 0 ]; then
@@ -248,11 +248,9 @@ set_ns_routing() {
248 ocf_log debug "Setting namespace interface: ${OCF_RESKEY_namespace_interface} IP to: ${OCF_RESKEY_namespace_ip}/${OCF_RESKEY_network_mask}" 248 ocf_log debug "Setting namespace interface: ${OCF_RESKEY_namespace_interface} IP to: ${OCF_RESKEY_namespace_ip}/${OCF_RESKEY_network_mask}"
249 ocf_run nsip addr add "${OCF_RESKEY_namespace_ip}/${OCF_RESKEY_network_mask}" dev "${OCF_RESKEY_namespace_interface}" 249 ocf_run nsip addr add "${OCF_RESKEY_namespace_ip}/${OCF_RESKEY_network_mask}" dev "${OCF_RESKEY_namespace_interface}"
250 fi 250 fi
251 ocf_log debug "Flushing global scope routes" 251}
252 nsip route save '0.0.0.0/0' > ${HA_RSCTMP}/default.routes
253 nsip route flush scope global
254 nsip route restore < ${HA_RSCTMP}/default.routes
255 252
253set_ns_routing() {
256 # set default gateway inside ns 254 # set default gateway inside ns
257 nsip route list | grep -q "default via ${OCF_RESKEY_host_ip}" 255 nsip route list | grep -q "default via ${OCF_RESKEY_host_ip}"
258 if [ $? -gt 0 ]; then 256 if [ $? -gt 0 ]; then
@@ -281,13 +279,24 @@ set_ns_routing() {
281 fi 279 fi
282} 280}
283 281
282set_ns_flushing() {
283 ocf_log debug "Flushing global scope routes"
284 nsip route save '0.0.0.0/0' > ${HA_RSCTMP}/default.routes
285 nsip route flush scope global
286 nsip route restore < ${HA_RSCTMP}/default.routes
287}
288
284vrouter_status() { 289vrouter_status() {
285 get_ns || return $OCF_NOT_RUNNING 290 get_ns || return $OCF_NOT_RUNNING
291 set_ns_interfaces
292 set_ns_routing
286} 293}
287 294
288vrouter_start() 295vrouter_start()
289{ 296{
290 get_ns 297 get_ns
298 set_ns_interfaces
299 set_ns_flushing
291 set_ns_routing 300 set_ns_routing
292 return $OCF_SUCCESS 301 return $OCF_SUCCESS
293} 302}