Avoid overwriting VF data
Ensures that the configuration of a VF is not overwritten in Zookeeper on a node restart. The SRIOVVFInstance handlers were modified to start with None values, so that the DataWatch statements will always trigger updates to the live system interfaces on daemon startup, thus ensuring that the config stored in Zookeeper is applied to the system on startup (mostly relevant after a cold boot or if the API changes them during a daemon restart).
This commit is contained in:
parent
8f1af2a642
commit
5607a6bb62
|
@ -1121,21 +1121,23 @@ if enable_networking:
|
|||
# 'query_rss_en': False
|
||||
# }
|
||||
vfphy = '{}v{}'.format(pf, vf['vf'])
|
||||
zkhandler.write([
|
||||
(('node.sriov.vf', myhostname, 'sriov_vf', vfphy), ''),
|
||||
(('node.sriov.vf', myhostname, 'sriov_vf.pf', vfphy), pf),
|
||||
(('node.sriov.vf', myhostname, 'sriov_vf.mtu', vfphy), mtu),
|
||||
(('node.sriov.vf', myhostname, 'sriov_vf.mac', vfphy), vf['address']),
|
||||
(('node.sriov.vf', myhostname, 'sriov_vf.config', vfphy), ''),
|
||||
(('node.sriov.vf', myhostname, 'sriov_vf.config.vlan_id', vfphy), vf['vlan_list'][0].get('vlan', '')),
|
||||
(('node.sriov.vf', myhostname, 'sriov_vf.config.vlan_qos', vfphy), vf['vlan_list'][0].get('qos', '')),
|
||||
(('node.sriov.vf', myhostname, 'sriov_vf.config.tx_rate_min', vfphy), vf['rate']['min_tx']),
|
||||
(('node.sriov.vf', myhostname, 'sriov_vf.config.tx_rate_max', vfphy), vf['rate']['max_tx']),
|
||||
(('node.sriov.vf', myhostname, 'sriov_vf.config.spoof_check', vfphy), vf['spoofchk']),
|
||||
(('node.sriov.vf', myhostname, 'sriov_vf.config.link_state', vfphy), vf['link_state']),
|
||||
(('node.sriov.vf', myhostname, 'sriov_vf.config.trust', vfphy), vf['trust']),
|
||||
(('node.sriov.vf', myhostname, 'sriov_vf.config.query_rss', vfphy), vf['query_rss_en']),
|
||||
])
|
||||
# Add the VF to Zookeeper if it does not yet exist
|
||||
if not zkhandler.exists(('node.sriov.vf', myhostname, 'sriov_vf', vfphy)):
|
||||
zkhandler.write([
|
||||
(('node.sriov.vf', myhostname, 'sriov_vf', vfphy), ''),
|
||||
(('node.sriov.vf', myhostname, 'sriov_vf.pf', vfphy), pf),
|
||||
(('node.sriov.vf', myhostname, 'sriov_vf.mtu', vfphy), mtu),
|
||||
(('node.sriov.vf', myhostname, 'sriov_vf.mac', vfphy), vf['address']),
|
||||
(('node.sriov.vf', myhostname, 'sriov_vf.config', vfphy), ''),
|
||||
(('node.sriov.vf', myhostname, 'sriov_vf.config.vlan_id', vfphy), vf['vlan_list'][0].get('vlan', '')),
|
||||
(('node.sriov.vf', myhostname, 'sriov_vf.config.vlan_qos', vfphy), vf['vlan_list'][0].get('qos', '')),
|
||||
(('node.sriov.vf', myhostname, 'sriov_vf.config.tx_rate_min', vfphy), vf['rate']['min_tx']),
|
||||
(('node.sriov.vf', myhostname, 'sriov_vf.config.tx_rate_max', vfphy), vf['rate']['max_tx']),
|
||||
(('node.sriov.vf', myhostname, 'sriov_vf.config.spoof_check', vfphy), vf['spoofchk']),
|
||||
(('node.sriov.vf', myhostname, 'sriov_vf.config.link_state', vfphy), vf['link_state']),
|
||||
(('node.sriov.vf', myhostname, 'sriov_vf.config.trust', vfphy), vf['trust']),
|
||||
(('node.sriov.vf', myhostname, 'sriov_vf.config.query_rss', vfphy), vf['query_rss_en']),
|
||||
])
|
||||
# Append the device to the list of VFs
|
||||
sriov_vf_list.append(vfphy)
|
||||
|
||||
|
|
|
@ -43,16 +43,17 @@ class SRIOVVFInstance(object):
|
|||
self.mtu = self.zkhandler.read(('node.sriov.vf', self.myhostname, 'sriov_vf.mtu', self.vf))
|
||||
|
||||
self.vfid = self.vf.replace('{}v'.format(self.pf), '')
|
||||
self.mac = self.zkhandler.read(('node.sriov.vf', self.myhostname, 'sriov_vf.mac', self.vf))
|
||||
|
||||
self.vlan_id = self.zkhandler.read(('node.sriov.vf', self.myhostname, 'sriov_vf.config.vlan_id', self.vf))
|
||||
self.vlan_qos = self.zkhandler.read(('node.sriov.vf', self.myhostname, 'sriov_vf.config.vlan_qos', self.vf))
|
||||
self.tx_rate_min = self.zkhandler.read(('node.sriov.vf', self.myhostname, 'sriov_vf.config.tx_rate_min', self.vf))
|
||||
self.tx_rate_max = self.zkhandler.read(('node.sriov.vf', self.myhostname, 'sriov_vf.config.tx_rate_max', self.vf))
|
||||
self.spoof_check = self.zkhandler.read(('node.sriov.vf', self.myhostname, 'sriov_vf.config.spoof_check', self.vf))
|
||||
self.link_state = self.zkhandler.read(('node.sriov.vf', self.myhostname, 'sriov_vf.config.link_state', self.vf))
|
||||
self.trust = self.zkhandler.read(('node.sriov.vf', self.myhostname, 'sriov_vf.config.trust', self.vf))
|
||||
self.query_rss = self.zkhandler.read(('node.sriov.vf', self.myhostname, 'sriov_vf.config.query_rss', self.vf))
|
||||
# These properties are set via the DataWatch functions, to ensure they are configured on the system
|
||||
self.mac = None
|
||||
self.vlan_id = None
|
||||
self.vlan_qos = None
|
||||
self.tx_rate_min = None
|
||||
self.tx_rate_max = None
|
||||
self.spoof_check = None
|
||||
self.link_state = None
|
||||
self.trust = None
|
||||
self.query_rss = None
|
||||
|
||||
# Zookeeper handlers for changed configs
|
||||
@self.zkhandler.zk_conn.DataWatch(self.zkhandler.schema.path('node.sriov.vf', self.myhostname) + self.zkhandler.schema.path('sriov_vf.mac', self.vf))
|
||||
|
|
Loading…
Reference in New Issue