diff options
author | Sankar Tanguturi <stanguturi@stanguturi-rhel> | 2016-03-08 12:41:08 -0800 |
---|---|---|
committer | Sankar Tanguturi <stanguturi@stanguturi-rhel> | 2016-03-08 12:41:08 -0800 |
commit | ef7368ef61c47fbb0bc03e6e7a5bc4571d492baf (patch) | |
tree | 93c08f9eeca19645ef4316b612f7fed1aecf9c06 /cloudinit/sources/helpers/vmware/imc/config_nic.py | |
parent | bbf105baafbe788f7babbda188b513180424e256 (diff) | |
download | vyos-cloud-init-ef7368ef61c47fbb0bc03e6e7a5bc4571d492baf.tar.gz vyos-cloud-init-ef7368ef61c47fbb0bc03e6e7a5bc4571d492baf.zip |
- Ignored return code 1 for 'pkill' command in config_nic.py
- Added few utility functions to report events to the underlying
VMware Virtualization platform
- Re-factored code little bit.
- Executed ./tools/run-pep8 and no pep8 errors were reported.
Diffstat (limited to 'cloudinit/sources/helpers/vmware/imc/config_nic.py')
-rw-r--r-- | cloudinit/sources/helpers/vmware/imc/config_nic.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/cloudinit/sources/helpers/vmware/imc/config_nic.py b/cloudinit/sources/helpers/vmware/imc/config_nic.py index 172a1649..42fbcc7e 100644 --- a/cloudinit/sources/helpers/vmware/imc/config_nic.py +++ b/cloudinit/sources/helpers/vmware/imc/config_nic.py @@ -47,12 +47,12 @@ class NicConfigurator: """ primary_nics = [nic for nic in self.nics if nic.primary] if not primary_nics: - return None + return None elif len(primary_nics) > 1: - raise Exception('There can only be one primary nic', + raise Exception('There can only be one primary nic', [nic.mac for nic in primary_nics]) else: - return primary_nics[0] + return primary_nics[0] def find_devices(self): """ @@ -186,8 +186,9 @@ class NicConfigurator: lines = [] for addr in addrs: - lines.append(' up route -A inet6 add default gw %s metric 10000' % - addr.gateway) + lines.append( + ' up route -A inet6 add default gw %s metric 10000' % + addr.gateway) return lines @@ -206,7 +207,8 @@ class NicConfigurator: def clear_dhcp(self): logger.info('Clearing DHCP leases') - util.subp(["pkill", "dhclient"]) + # Ignore the return code 1. + util.subp(["pkill", "dhclient"], rcs=[0, 1]) util.subp(["rm", "-f", "/var/lib/dhcp/*"]) def if_down_up(self): |