summaryrefslogtreecommitdiff
path: root/src/etc
diff options
context:
space:
mode:
Diffstat (limited to 'src/etc')
-rwxr-xr-xsrc/etc/vmware-tools/scripts/resume-vm-default.d/ether-resume.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/etc/vmware-tools/scripts/resume-vm-default.d/ether-resume.py b/src/etc/vmware-tools/scripts/resume-vm-default.d/ether-resume.py
index 72da317f5..f8f790bf1 100755
--- a/src/etc/vmware-tools/scripts/resume-vm-default.d/ether-resume.py
+++ b/src/etc/vmware-tools/scripts/resume-vm-default.d/ether-resume.py
@@ -19,7 +19,8 @@ import subprocess
import syslog as sl
from vyos.config import Config
-from vyos.util import vyos
+from vyos import ConfigError
+
def get_config():
c = Config()
@@ -28,7 +29,7 @@ def get_config():
# skip interfaces that are disabled or is configured for dhcp
check_disable = "interfaces ethernet {} disable".format(intf)
check_dhcp = "interfaces ethernet {} address dhcp".format(intf)
- if c.exists_effective(check_disable) or c.exists_effective(check_dhcp):
+ if c.exists_effective(check_disable):
continue
# get addresses configured on the interface
@@ -38,6 +39,7 @@ def get_config():
interfaces[intf] = [addr.strip("'") for addr in intf_addresses]
return interfaces
+
def apply(config):
for intf, addresses in config.items():
# bring the interface up
@@ -47,14 +49,18 @@ def apply(config):
# add configured addresses to interface
for addr in addresses:
- cmd = ["ip", "address", "add", addr, "dev", intf]
+ if addr == "dhcp":
+ cmd = ["dhclient", intf]
+ else:
+ cmd = ["ip", "address", "add", addr, "dev", intf]
sl.syslog(sl.LOG_NOTICE, " ".join(cmd))
subprocess.call(cmd)
+
if __name__ == '__main__':
try:
config = get_config()
apply(config)
- except vyos.ConfigError as e:
+ except ConfigError as e:
print(e)
sys.exit(1)