summaryrefslogtreecommitdiff
path: root/packages/python-google-compute-engine/google_compute_engine/distro_lib/helpers.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/python-google-compute-engine/google_compute_engine/distro_lib/helpers.py')
-rw-r--r--packages/python-google-compute-engine/google_compute_engine/distro_lib/helpers.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/packages/python-google-compute-engine/google_compute_engine/distro_lib/helpers.py b/packages/python-google-compute-engine/google_compute_engine/distro_lib/helpers.py
index a0be6a0..c20b241 100644
--- a/packages/python-google-compute-engine/google_compute_engine/distro_lib/helpers.py
+++ b/packages/python-google-compute-engine/google_compute_engine/distro_lib/helpers.py
@@ -17,6 +17,7 @@
import os
import subprocess
+import time
def CallDhclient(
@@ -68,6 +69,23 @@ def CallDhclientIpv6(interfaces, logger, dhclient_script=None,
interfaces)
return
+ # Check for a 'tentative' IPv6 address which would prevent `dhclient -6` from
+ # succeeding below. This should only take 1 second, but we try for up to 5.
+ command = ['ip', '-6', '-o', 'a', 's', 'dev', interfaces[0], 'scope',
+ 'link', 'tentative']
+ for i in range(5):
+ output = ''
+ try:
+ output = subprocess.check_output(command)
+ except subprocess.CalledProcessError as e:
+ logger.warning('Could not confirm tentative IPv6 address: %s.', e.output)
+ if output:
+ logger.info('Found tentative ipv6 link address %s, sleeping 1 second.',
+ output.strip())
+ time.sleep(1)
+ else:
+ break
+
if dhclient_script and os.path.exists(dhclient_script):
dhclient_command += ['-sf', dhclient_script]