xenserver: Print program name on error in dump-vif-details
[openvswitch] / xenserver / vswitch-xen.spec
index a9c3402ac9e61d4bec91d2afbdcbe3a4beafeccc..c79309d22b3b8d937c2fad384ca52636e23a61b2 100644 (file)
@@ -67,6 +67,8 @@ install -m 755 xenserver/etc_xensource_scripts_vif \
              $RPM_BUILD_ROOT%{_prefix}/scripts/vif
 install -m 755 xenserver/root_vswitch_scripts_dump-vif-details \
                $RPM_BUILD_ROOT%{_prefix}/scripts/dump-vif-details
              $RPM_BUILD_ROOT%{_prefix}/scripts/vif
 install -m 755 xenserver/root_vswitch_scripts_dump-vif-details \
                $RPM_BUILD_ROOT%{_prefix}/scripts/dump-vif-details
+install -m 755 xenserver/root_vswitch_scripts_refresh-xs-network-uuids \
+               $RPM_BUILD_ROOT%{_prefix}/scripts/refresh-xs-network-uuids
 install -m 755 xenserver/usr_sbin_xen-bugtool \
              $RPM_BUILD_ROOT%{_prefix}/scripts/xen-bugtool
 install -m 755 xenserver/usr_sbin_brctl \
 install -m 755 xenserver/usr_sbin_xen-bugtool \
              $RPM_BUILD_ROOT%{_prefix}/scripts/xen-bugtool
 install -m 755 xenserver/usr_sbin_brctl \
@@ -101,7 +103,7 @@ rm -rf \
 %clean
 rm -rf $RPM_BUILD_ROOT
 
 %clean
 rm -rf $RPM_BUILD_ROOT
 
-%pre
+%post
 if [ ! -f /etc/xensource-inventory ]; then
     printf "XenSource inventory not present in /etc/xensource-inventory"
     exit 1
 if [ ! -f /etc/xensource-inventory ]; then
     printf "XenSource inventory not present in /etc/xensource-inventory"
     exit 1
@@ -141,7 +143,7 @@ EOF
     fi
 fi
 
     fi
 fi
 
-if test ! -e /etc/ovs-vswitch.dbcache; then
+if test ! -e /var/lib/openvswitch/dbcache; then
     if test "$1" = 1; then
         printf "Creating xapi database cache...  "
     else
     if test "$1" = 1; then
         printf "Creating xapi database cache...  "
     else
@@ -150,34 +152,8 @@ if test ! -e /etc/ovs-vswitch.dbcache; then
         printf "Re-creating xapi database cache...  "
     fi
 
         printf "Re-creating xapi database cache...  "
     fi
 
-    source /etc/xensource-inventory
-    if python - "$INSTALLATION_UUID" <<EOF
-import XenAPI
-import pickle
-import sys
-
-session = XenAPI.xapi_local()
-try:
-    session.xenapi.login_with_password("root", "")
-
-    vlans = session.xenapi.VLAN.get_all_records()
-    bonds = session.xenapi.Bond.get_all_records()
-    pifs = session.xenapi.PIF.get_all_records()
-    networks = session.xenapi.network.get_all_records()
-    host = session.xenapi.host.get_by_uuid(sys.argv[1])
-finally:
-    session.xenapi.session.logout()
-
-dbcache_file = "/etc/ovs-vswitch.dbcache"
-f = open(dbcache_file, 'w')
-pickle.dump({'vlans': vlans,
-             'bonds': bonds,
-             'pifs': pifs,
-             'networks': networks}, f)
-pickle.dump({'host': host}, f)
-f.close()
-EOF
-    then
+    mkdir -p /var/lib/openvswitch
+    if /root/vswitch/scripts/interface-reconfigure rewrite; then
         printf "done.\n"
     else
         printf "FAILED\n"
         printf "done.\n"
     else
         printf "FAILED\n"
@@ -188,7 +164,6 @@ EOF
     fi
 fi
 
     fi
 fi
 
-%post
 if grep -F net.ipv4.conf.all.arp_filter /etc/sysctl.conf >/dev/null 2>&1; then :; else
     cat >>/etc/sysctl.conf <<EOF
 # This works around an issue in xhad, which binds to a particular
 if grep -F net.ipv4.conf.all.arp_filter /etc/sysctl.conf >/dev/null 2>&1; then :; else
     cat >>/etc/sysctl.conf <<EOF
 # This works around an issue in xhad, which binds to a particular
@@ -309,6 +284,7 @@ if [ "$1" = "0" ]; then     # $1 = 1 for upgrade
     rm -f /etc/sysconfig/vswitch
     rm -f /var/log/vswitch*
     rm -f /etc/ovs-vswitchd.cacert
     rm -f /etc/sysconfig/vswitch
     rm -f /var/log/vswitch*
     rm -f /etc/ovs-vswitchd.cacert
+    rm -f /var/lib/openvswitch/dbcache
 
     printf "\nYou MUST reboot the server now to complete the change to\n"
     printf "standard Xen networking.  Attempts to modify networking on the\n"
 
     printf "\nYou MUST reboot the server now to complete the change to\n"
     printf "standard Xen networking.  Attempts to modify networking on the\n"
@@ -328,6 +304,7 @@ fi
 /root/vswitch/kernel_modules/openvswitch_mod.ko
 /root/vswitch/kernel_modules/veth_mod.ko
 /root/vswitch/scripts/dump-vif-details
 /root/vswitch/kernel_modules/openvswitch_mod.ko
 /root/vswitch/kernel_modules/veth_mod.ko
 /root/vswitch/scripts/dump-vif-details
+/root/vswitch/scripts/refresh-xs-network-uuids
 /root/vswitch/scripts/interface-reconfigure
 /root/vswitch/scripts/vif
 /root/vswitch/scripts/xen-bugtool
 /root/vswitch/scripts/interface-reconfigure
 /root/vswitch/scripts/vif
 /root/vswitch/scripts/xen-bugtool