Browse Source

Merge "Refactor ns_vrouter ocf"

Jenkins 2 years ago
parent
commit
46f01bc4ee
1 changed files with 18 additions and 9 deletions
  1. 18
    9
      files/fuel-ha-utils/ocf/ns_vrouter

+ 18
- 9
files/fuel-ha-utils/ocf/ns_vrouter View File

@@ -182,6 +182,10 @@ END
182 182
 exit $OCF_SUCCESS
183 183
 }
184 184
 
185
+nsip() {
186
+  ip netns exec "${OCF_RESKEY_ns}" ip ${@}
187
+}
188
+
185 189
 check_ns() {
186 190
   local LH="${LL} check_ns():"
187 191
   local ns=$(ip netns list | awk "/${OCF_RESKEY_ns}/ {print \$1}")
@@ -206,11 +210,7 @@ get_ns() {
206 210
   return $rc
207 211
 }
208 212
 
209
-set_ns_routing() {
210
-  nsip() {
211
-    ip netns exec "${OCF_RESKEY_ns}" ip ${@}
212
-  }
213
-
213
+set_ns_interfaces() {
214 214
   # create host-ns veth pair unless it's present
215 215
   ip link | grep -q '^[[:digit:]]\+:[[:space:]]\+'"${OCF_RESKEY_host_interface}"'[@:]'
216 216
   if [ $? -gt 0 ]; then
@@ -248,11 +248,9 @@ set_ns_routing() {
248 248
     ocf_log debug "Setting namespace interface: ${OCF_RESKEY_namespace_interface} IP to: ${OCF_RESKEY_namespace_ip}/${OCF_RESKEY_network_mask}"
249 249
     ocf_run nsip addr add "${OCF_RESKEY_namespace_ip}/${OCF_RESKEY_network_mask}" dev "${OCF_RESKEY_namespace_interface}"
250 250
   fi
251
-  ocf_log debug "Flushing global scope routes"
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
251
+}
255 252
 
253
+set_ns_routing() {
256 254
   # set default gateway inside ns
257 255
   nsip route list | grep -q "default via ${OCF_RESKEY_host_ip}"
258 256
   if [ $? -gt 0 ]; then
@@ -281,13 +279,24 @@ set_ns_routing() {
281 279
   fi
282 280
 }
283 281
 
282
+set_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
+
284 289
 vrouter_status() {
285 290
   get_ns || return $OCF_NOT_RUNNING
291
+  set_ns_interfaces
292
+  set_ns_routing
286 293
 }
287 294
 
288 295
 vrouter_start()
289 296
 {
290 297
   get_ns
298
+  set_ns_interfaces
299
+  set_ns_flushing
291 300
   set_ns_routing
292 301
         return $OCF_SUCCESS
293 302
 }

Loading…
Cancel
Save