summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-03-01 19:06:41 +0100
committerChristian Poessinger <christian@poessinger.com>2020-03-01 19:06:41 +0100
commit8dbd849e47e32ebabb382bc3287376e7df35dc09 (patch)
tree0684e3c5c46340029e7eb90cf54e55321a75f705
parent336f372d218b9af533e5d2c0408d6f13476cf1f5 (diff)
downloadvyos-1x-8dbd849e47e32ebabb382bc3287376e7df35dc09.tar.gz
vyos-1x-8dbd849e47e32ebabb382bc3287376e7df35dc09.zip
vmware: T1028: readd static IP address after resume
-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)