mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
fix creating a nic tag on a link with double 0 in the MAC
otherwise we get a message like '12:34:00:56:78:90 is not present on this system.' as dladm prints the '00' as '0' and we fail to correctly identify the existing interface. Fix a linting issue while here
This commit is contained in:
parent
a3cb0e576e
commit
47a66975ff
1 changed files with 5 additions and 3 deletions
|
@ -118,7 +118,7 @@ def exists(*nictag, **kwargs):
|
|||
salt '*' nictagadm.exists admin
|
||||
'''
|
||||
ret = {}
|
||||
if len(nictag) == 0:
|
||||
if not nictag:
|
||||
return {'Error': 'Please provide at least one nictag to check.'}
|
||||
|
||||
cmd = 'nictagadm exists -l {0}'.format(' '.join(nictag))
|
||||
|
@ -159,7 +159,8 @@ def add(name, mac, mtu=1500):
|
|||
if mac != 'etherstub':
|
||||
cmd = 'dladm show-phys -m -p -o address'
|
||||
res = __salt__['cmd.run_all'](cmd)
|
||||
if mac not in res['stdout'].splitlines():
|
||||
# dladm prints '00' as '0', so account for that.
|
||||
if mac.replace('00', '0') not in res['stdout'].splitlines():
|
||||
return {'Error': '{0} is not present on this system.'.format(mac)}
|
||||
|
||||
if mac == 'etherstub':
|
||||
|
@ -207,7 +208,8 @@ def update(name, mac=None, mtu=None):
|
|||
else:
|
||||
cmd = 'dladm show-phys -m -p -o address'
|
||||
res = __salt__['cmd.run_all'](cmd)
|
||||
if mac not in res['stdout'].splitlines():
|
||||
# dladm prints '00' as '0', so account for that.
|
||||
if mac.replace('00', '0') not in res['stdout'].splitlines():
|
||||
return {'Error': '{0} is not present on this system.'.format(mac)}
|
||||
|
||||
if mac and mtu:
|
||||
|
|
Loading…
Add table
Reference in a new issue