X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=xenserver%2Fopt_xensource_libexec_InterfaceReconfigure.py;h=22af3c2249f2459a7c125f2c4a66cf90ac2af2ba;hb=2d8bdd8f220848611722bce97b3258600530e95e;hp=e99ae5834a62f2e1922a8d1ce71fff08407836f2;hpb=2dd26837037ee6b9ff3d8fbdb1eb64b203ad7b02;p=sliver-openvswitch.git diff --git a/xenserver/opt_xensource_libexec_InterfaceReconfigure.py b/xenserver/opt_xensource_libexec_InterfaceReconfigure.py index e99ae5834..22af3c224 100644 --- a/xenserver/opt_xensource_libexec_InterfaceReconfigure.py +++ b/xenserver/opt_xensource_libexec_InterfaceReconfigure.py @@ -279,10 +279,12 @@ _BOND_XML_TAG = "bond" _NETWORK_XML_TAG = "network" _POOL_XML_TAG = "pool" -_ETHTOOL_OTHERCONFIG_ATTRS = ['ethtool-%s' % x for x in 'autoneg', 'speed', 'duplex', 'rx', 'tx', 'sg', 'tso', 'ufo', 'gso' ] +_ETHTOOL_OTHERCONFIG_ATTRS = ['ethtool-%s' % x for x in 'autoneg', 'speed', 'duplex', 'rx', 'tx', 'sg', 'tso', 'ufo', 'gso', 'gro', 'lro' ] _PIF_OTHERCONFIG_ATTRS = [ 'domain', 'peerdns', 'defaultroute', 'mtu', 'static-routes' ] + \ - [ 'bond-%s' % x for x in 'mode', 'miimon', 'downdelay', 'updelay', 'use_carrier' ] + \ + [ 'bond-%s' % x for x in 'mode', 'miimon', 'downdelay', + 'updelay', 'use_carrier', 'hashing-algorithm' ] + \ + [ 'vlan-bug-workaround' ] + \ _ETHTOOL_OTHERCONFIG_ATTRS _PIF_ATTRS = { 'uuid': (_str_to_xml,_str_from_xml), @@ -331,7 +333,11 @@ _BOND_ATTRS = { 'uuid': (_str_to_xml,_str_from_xml), lambda n: _strlist_from_xml(n, 'slaves', 'slave')), } -_NETWORK_OTHERCONFIG_ATTRS = [ 'mtu', 'static-routes', 'vswitch-controller-fail-mode' ] + _ETHTOOL_OTHERCONFIG_ATTRS +_NETWORK_OTHERCONFIG_ATTRS = [ 'mtu', + 'static-routes', + 'vswitch-controller-fail-mode', + 'vswitch-disable-in-band' ] \ + + _ETHTOOL_OTHERCONFIG_ATTRS _NETWORK_ATTRS = { 'uuid': (_str_to_xml,_str_from_xml), 'bridge': (_str_to_xml,_str_from_xml), @@ -390,12 +396,7 @@ class DatabaseCache(object): continue self.__pifs[p] = {} for f in _PIF_ATTRS: - if f in [ "tunnel_access_PIF_of", "tunnel_transport_PIF_of" ] and f not in rec: - # XenServer 5.5 network records did not have - # these fields, so allow them to be missing. - pass - else: - self.__pifs[p][f] = rec[f] + self.__pifs[p][f] = rec[f] self.__pifs[p]['other_config'] = {} for f in _PIF_OTHERCONFIG_ATTRS: if not rec['other_config'].has_key(f): continue @@ -403,8 +404,7 @@ class DatabaseCache(object): def __get_vlan_records_from_xapi(self, session): self.__vlans = {} - for v in session.xenapi.VLAN.get_all(): - rec = session.xenapi.VLAN.get_record(v) + for (v,rec) in session.xenapi.VLAN.get_all_records().items(): if not self.__pif_on_host(rec['untagged_PIF']): continue self.__vlans[v] = {} @@ -423,8 +423,7 @@ class DatabaseCache(object): def __get_bond_records_from_xapi(self, session): self.__bonds = {} - for b in session.xenapi.Bond.get_all(): - rec = session.xenapi.Bond.get_record(b) + for (b,rec) in session.xenapi.Bond.get_all_records().items(): if not self.__pif_on_host(rec['master']): continue self.__bonds[b] = {} @@ -433,8 +432,7 @@ class DatabaseCache(object): def __get_network_records_from_xapi(self, session): self.__networks = {} - for n in session.xenapi.network.get_all(): - rec = session.xenapi.network.get_record(n) + for (n,rec) in session.xenapi.network.get_all_records().items(): self.__networks[n] = {} for f in _NETWORK_ATTRS: if f == "PIFs": @@ -510,15 +508,8 @@ class DatabaseCache(object): host = session.xenapi.host.get_by_uuid(inventory['INSTALLATION_UUID']) self.__get_pif_records_from_xapi(session, host) - - try: - self.__get_tunnel_records_from_xapi(session) - except XenAPI.Failure, e: - error,details = e.details - if error == "MESSAGE_METHOD_UNKNOWN" and details == "tunnel.get_all": - pass - self.__get_pool_records_from_xapi(session) + self.__get_tunnel_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) @@ -584,9 +575,11 @@ class DatabaseCache(object): for (ref,rec) in self.__pools.items(): self.__to_xml(xml, xml.documentElement, _POOL_XML_TAG, ref, rec, _POOL_ATTRS) - f = open(cache_file, 'w') + temp_file = cache_file + ".%d" % os.getpid() + f = open(temp_file, 'w') f.write(xml.toprettyxml()) f.close() + os.rename(temp_file, cache_file) def get_pif_by_uuid(self, uuid): pifs = map(lambda (ref,rec): ref, @@ -676,8 +669,9 @@ class DatabaseCache(object): # # # +PIF_OTHERCONFIG_DEFAULTS = {'gro': 'off', 'lro': 'off'} -def ethtool_settings(oc): +def ethtool_settings(oc, defaults = {}): settings = [] if oc.has_key('ethtool-speed'): val = oc['ethtool-speed'] @@ -687,8 +681,8 @@ def ethtool_settings(oc): log("Invalid value for ethtool-speed = %s. Must be 10|100|1000." % val) if oc.has_key('ethtool-duplex'): val = oc['ethtool-duplex'] - if val in ["10", "100", "1000"]: - settings += ['duplex', 'val'] + if val in ["half", "full"]: + settings += ['duplex', val] else: log("Invalid value for ethtool-duplex = %s. Must be half|full." % val) if oc.has_key('ethtool-autoneg'): @@ -700,7 +694,7 @@ def ethtool_settings(oc): else: log("Invalid value for ethtool-autoneg = %s. Must be on|true|off|false." % val) offload = [] - for opt in ("rx", "tx", "sg", "tso", "ufo", "gso"): + for opt in ("rx", "tx", "sg", "tso", "ufo", "gso", "gro", "lro"): if oc.has_key("ethtool-" + opt): val = oc["ethtool-" + opt] if val in ["true", "on"]: @@ -709,6 +703,8 @@ def ethtool_settings(oc): offload += [opt, 'off'] else: log("Invalid value for ethtool-%s = %s. Must be on|true|off|false." % (opt, val)) + elif opt in defaults: + offload += [opt, defaults[opt]] return settings,offload # By default the MTU is taken from the Network.MTU setting for VIF, @@ -881,8 +877,7 @@ def pif_get_vlan_masters(pif): # Tunnel PIFs # def pif_is_tunnel(pif): - rec = db().get_pif_record(pif) - return rec.has_key('tunnel_access_PIF_of') and len(rec['tunnel_access_PIF_of']) > 0 + return len(db().get_pif_record(pif)['tunnel_access_PIF_of']) > 0 # # Datapath base class