From: Ian Campbell Date: Thu, 6 Aug 2009 20:43:21 +0000 (-0700) Subject: xenserver: Factor out XAPI interactions in interface-reconfigure. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d8ba4acf4494d381b3b789251274b9ca77578dd1;p=openvswitch xenserver: Factor out XAPI interactions in interface-reconfigure. Currently interface-reconfigure stores a copy of the XAPI database using python's pickling functionality. Since the XenServer host installer also needs to write this file (so it is present after slave upgrade) we would like to switch to something more explicitly under our control. Begin by factoring out XAPI interactions. --- diff --git a/xenserver/opt_xensource_libexec_interface-reconfigure b/xenserver/opt_xensource_libexec_interface-reconfigure index 2a32fad2..6f2b5bcc 100755 --- a/xenserver/opt_xensource_libexec_interface-reconfigure +++ b/xenserver/opt_xensource_libexec_interface-reconfigure @@ -249,6 +249,18 @@ def interface_exists(i): return os.path.exists("/sys/class/net/" + i) class DatabaseCache(object): + def __get_pif_records_from_xapi(self, session): + self.__pifs = session.xenapi.PIF.get_all_records() + + def __get_vlan_records_from_xapi(self, session): + self.__vlans = session.xenapi.VLAN.get_all_records() + + def __get_bond_records_from_xapi(self, session): + self.__bonds = session.xenapi.Bond.get_all_records() + + def __get_network_records_from_xapi(self, session): + self.__networks = session.xenapi.network.get_all_records() + def __init__(self, session_ref=None, cache_file=None): if session_ref and cache_file: raise Error("can't specify session reference and cache file") @@ -263,10 +275,10 @@ class DatabaseCache(object): session._session = session_ref try: - self.__vlans = session.xenapi.VLAN.get_all_records() - self.__bonds = session.xenapi.Bond.get_all_records() - self.__pifs = session.xenapi.PIF.get_all_records() - self.__networks = session.xenapi.network.get_all_records() + self.__get_pif_records_from_xapi(session) + self.__get_vlan_records_from_xapi(session) + self.__get_bond_records_from_xapi(session) + self.__get_network_records_from_xapi(session) finally: if not session_ref: session.xenapi.session.logout()