mirror of
https://github.com/xcat2/confluent.git
synced 2026-09-02 15:36:05 +00:00
Stop loop variables from shadowing what they iterate (B020)
Each of these loops rebinds the name that holds the iterable. They work
today because the iterable is evaluated once before the loop starts, but
the name is then gone, so any later use reads a loop item instead of the
collection.
- nodeinventory: `for arg in args` / `for arg in arg.split(',')`.
- confignet (common and debian copies): iname holds the comma separated
interface list and is then reused for each interface in it.
- xcc _get_agentless_firmware: adata holds the adapter query response and
is then reused for each adapter.
No behaviour change, just distinct names for distinct things.
This commit is contained in:
@@ -121,8 +121,8 @@ if len(args) > 1:
|
||||
os.execlp('nodefirmware', 'nodefirmware', noderange)
|
||||
else:
|
||||
url = '/noderange/{0}/inventory/hardware/all/system'
|
||||
for arg in args:
|
||||
for arg in arg.split(','):
|
||||
for rawarg in args:
|
||||
for arg in rawarg.split(','):
|
||||
if arg == 'serial':
|
||||
filters.append(re.compile('serial number'))
|
||||
elif arg == 'model':
|
||||
|
||||
@@ -625,18 +625,18 @@ if __name__ == '__main__':
|
||||
time.sleep(1)
|
||||
continue
|
||||
dc = json.loads(dc)
|
||||
iname = get_interface_name(idxmap[curridx], nc.get('default', {}))
|
||||
if iname:
|
||||
for iname in iname.split(','):
|
||||
inames = get_interface_name(idxmap[curridx], nc.get('default', {}))
|
||||
if inames:
|
||||
for iname in inames.split(','):
|
||||
if 'default' in netname_to_interfaces:
|
||||
netname_to_interfaces['default']['interfaces'].add(iname)
|
||||
else:
|
||||
netname_to_interfaces['default'] = {'interfaces': set([iname]), 'settings': nc['default']}
|
||||
for netname in nc.get('extranets', {}):
|
||||
uname = '_' + netname
|
||||
iname = get_interface_name(idxmap[curridx], nc['extranets'][netname])
|
||||
if iname:
|
||||
for iname in iname.split(','):
|
||||
inames = get_interface_name(idxmap[curridx], nc['extranets'][netname])
|
||||
if inames:
|
||||
for iname in inames.split(','):
|
||||
if uname in netname_to_interfaces:
|
||||
netname_to_interfaces[uname]['interfaces'].add(iname)
|
||||
else:
|
||||
|
||||
@@ -545,18 +545,18 @@ if __name__ == '__main__':
|
||||
time.sleep(1)
|
||||
continue
|
||||
dc = json.loads(dc)
|
||||
iname = get_interface_name(idxmap[curridx], nc.get('default', {}))
|
||||
if iname:
|
||||
for iname in iname.split(','):
|
||||
inames = get_interface_name(idxmap[curridx], nc.get('default', {}))
|
||||
if inames:
|
||||
for iname in inames.split(','):
|
||||
if 'default' in netname_to_interfaces:
|
||||
netname_to_interfaces['default']['interfaces'].add(iname)
|
||||
else:
|
||||
netname_to_interfaces['default'] = {'interfaces': set([iname]), 'settings': nc['default']}
|
||||
for netname in nc.get('extranets', {}):
|
||||
uname = '_' + netname
|
||||
iname = get_interface_name(idxmap[curridx], nc['extranets'][netname])
|
||||
if iname:
|
||||
for iname in iname.split(','):
|
||||
inames = get_interface_name(idxmap[curridx], nc['extranets'][netname])
|
||||
if inames:
|
||||
for iname in inames.split(','):
|
||||
if uname in netname_to_interfaces:
|
||||
netname_to_interfaces[uname]['interfaces'].add(iname)
|
||||
else:
|
||||
|
||||
@@ -623,12 +623,12 @@ class OEMHandler(generic.OEMHandler):
|
||||
async def _get_agentless_firmware(self, components):
|
||||
skipkeys = set([])
|
||||
wc = await self.wc()
|
||||
adata = await wc.grab_json_response(
|
||||
adapterdata = await wc.grab_json_response(
|
||||
'/api/dataset/imm_adapters?params=pci_GetAdapters')
|
||||
fdata = await wc.grab_json_response(
|
||||
'/api/function/adapter_update?params=pci_GetAdapterListAndFW')
|
||||
anames = set()
|
||||
for adata in adata.get('items', []):
|
||||
for adata in adapterdata.get('items', []):
|
||||
baseaname = adata['adapterName']
|
||||
aname = baseaname
|
||||
idx = 1
|
||||
|
||||
Reference in New Issue
Block a user