[jump] Enable jumbo frames for vnet devices
[fuel.git] / mcp / scripts / lib.sh
index ce5db25..c566cc9 100644 (file)
@@ -243,7 +243,8 @@ function cleanup_vms {
   for node in $(virsh list --name --all | grep -P '\w{3}\d{2}'); do
     virsh domblklist "${node}" | awk '/^.da/ {print $2}' | \
       xargs --no-run-if-empty -I{} sudo rm -f {}
-    virsh undefine "${node}" --remove-all-storage --nvram
+    virsh undefine "${node}" --remove-all-storage --nvram || \
+      virsh undefine "${node}" --remove-all-storage
   done
 }
 
@@ -406,6 +407,7 @@ function create_vms {
 
   # create vms with specified options
   for serialized_vnode_data in "${vnodes[@]}"; do
+    if [ -z "${serialized_vnode_data}" ]; then continue; fi
     IFS=',' read -r -a vnode_data <<< "${serialized_vnode_data}"
 
     # prepare network args
@@ -451,6 +453,23 @@ function update_mcpcontrol_network {
     "<host mac='${amac}' name='mas01' ip='${MAAS_IP}'/>" --live --config
 }
 
+function reset_vms {
+  local vnodes=("$@")
+  local cmd_str="ssh ${SSH_OPTS} ${SSH_SALT}"
+
+  # reset non-infrastructure vms, wait for them to come back online
+  for node in "${vnodes[@]}"; do
+    if [[ ! "${node}" =~ (cfg01|mas01) ]]; then
+      virsh reset "${node}"
+    fi
+  done
+  for node in "${vnodes[@]}"; do
+    if [[ ! "${node}" =~ (cfg01|mas01) ]]; then
+      wait_for 20.0 "${cmd_str} sudo salt -C '${node}*' saltutil.sync_all"
+    fi
+  done
+}
+
 function start_vms {
   local vnodes=("$@")
 
@@ -527,6 +546,13 @@ function wait_for {
   )
 }
 
+function do_udev_cfg {
+  local _conf='/etc/udev/rules.d/99-opnfv-fuel-vnet-mtu.rules'
+  # http://linuxaleph.blogspot.com/2013/01/how-to-network-jumbo-frames-to-kvm-guest.html
+  echo 'SUBSYSTEM=="net", ACTION=="add", KERNEL=="vnet*", RUN+="/sbin/ip link set mtu 9000 dev '"'"%k"'"'"' |& sudo tee "${_conf}"
+  sudo udevadm control --reload || true
+}
+
 function do_sysctl_cfg {
   local _conf='/etc/sysctl.d/99-opnfv-fuel-bridge.conf'
   # https://wiki.libvirt.org/page/Net.bridge.bridge-nf-call_and_sysctl.conf