fi
 fi
 
+if test ! -e /etc/vswitch.dbcache; then
+    if test "$1" = 1; then
+        printf "Creating xapi database cache...  "
+    else
+        printf "warning: Open vSwitch is being re-installed or upgraded,\n"
+        printf "         but the xapi database cache is missing.\n"
+        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/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
+        printf "done.\n"
+    else
+        printf "FAILED\n"
+        printf "Open vSwitch can only be installed on a XenServer that\n"
+        printf "has connectivity to xapi on the pool master.  Please\n"
+        printf "fix connectivity to the pool master, then try again.\n"
+        exit 1
+    fi
+fi
 
 %post
 source /etc/xensource-inventory
     ln -s /root/vswitch/scripts/XSFeatureVSwitch.py /usr/lib/xsconsole/plugins-base/ || printf "Could not link to vSswitch xsconsole plugin.\n"
 fi
 
-# Modify conf files for compatibility with our interface-reconfigure
-for pif in $(xe pif-list host-uuid=$INSTALLATION_UUID params=uuid | awk '{print $5}'); do
-    /opt/xensource/libexec/interface-reconfigure --pif-uuid $pif rewrite
-done
-
 # Ensure all required services are set to run
 for s in vswitch vswitch-xapi-update; do
     if chkconfig --list $s >/dev/null 2>&1; then