diff options
author | Sankar Tanguturi <stanguturi@stanguturi-rhel> | 2016-03-11 11:29:15 -0800 |
---|---|---|
committer | Sankar Tanguturi <stanguturi@stanguturi-rhel> | 2016-03-11 11:29:15 -0800 |
commit | a3fd7441f8ea4d25e96b9bc0eca7cbb6164a4691 (patch) | |
tree | 74a6ebbe7c91c30467577eb231fab8c5f188b93c /cloudinit/sources/helpers | |
parent | a6e0922a4d34ede6df000dd8fc4bb3531218d69f (diff) | |
parent | 41470d29f5888baf7ec78e170cc0d6d981dcf63e (diff) | |
download | vyos-cloud-init-a3fd7441f8ea4d25e96b9bc0eca7cbb6164a4691.tar.gz vyos-cloud-init-a3fd7441f8ea4d25e96b9bc0eca7cbb6164a4691.zip |
- Executed 'bzr merge' and resolved all the conflicts.
- Now my branch is identical to trunk.dist
Diffstat (limited to 'cloudinit/sources/helpers')
-rw-r--r-- | cloudinit/sources/helpers/azure.py | 26 | ||||
-rw-r--r-- | cloudinit/sources/helpers/vmware/imc/config_nic.py | 6 |
2 files changed, 18 insertions, 14 deletions
diff --git a/cloudinit/sources/helpers/azure.py b/cloudinit/sources/helpers/azure.py index d90c22fd..018cac6d 100644 --- a/cloudinit/sources/helpers/azure.py +++ b/cloudinit/sources/helpers/azure.py @@ -197,6 +197,21 @@ class WALinuxAgentShim(object): self.openssl_manager.clean_up() @staticmethod + def get_ip_from_lease_value(lease_value): + unescaped_value = lease_value.replace('\\', '') + if len(unescaped_value) > 4: + hex_string = '' + for hex_pair in unescaped_value.split(':'): + if len(hex_pair) == 1: + hex_pair = '0' + hex_pair + hex_string += hex_pair + packed_bytes = struct.pack( + '>L', int(hex_string.replace(':', ''), 16)) + else: + packed_bytes = unescaped_value.encode('utf-8') + return socket.inet_ntoa(packed_bytes) + + @staticmethod def find_endpoint(): LOG.debug('Finding Azure endpoint...') content = util.load_file('/var/lib/dhcp/dhclient.eth0.leases') @@ -206,16 +221,7 @@ class WALinuxAgentShim(object): value = line.strip(' ').split(' ', 2)[-1].strip(';\n"') if value is None: raise Exception('No endpoint found in DHCP config.') - if ':' in value: - hex_string = '' - for hex_pair in value.split(':'): - if len(hex_pair) == 1: - hex_pair = '0' + hex_pair - hex_string += hex_pair - value = struct.pack('>L', int(hex_string.replace(':', ''), 16)) - else: - value = value.encode('utf-8') - endpoint_ip_address = socket.inet_ntoa(value) + endpoint_ip_address = WALinuxAgentShim.get_ip_from_lease_value(value) LOG.debug('Azure endpoint found at %s', endpoint_ip_address) return endpoint_ip_address diff --git a/cloudinit/sources/helpers/vmware/imc/config_nic.py b/cloudinit/sources/helpers/vmware/imc/config_nic.py index 42fbcc7e..77098a05 100644 --- a/cloudinit/sources/helpers/vmware/imc/config_nic.py +++ b/cloudinit/sources/helpers/vmware/imc/config_nic.py @@ -19,7 +19,6 @@ import logging import os -import subprocess import re from cloudinit import util @@ -186,9 +185,8 @@ 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 |