summaryrefslogtreecommitdiff
path: root/cloudinit/cmd
diff options
context:
space:
mode:
authorChad Smith <chad.smith@canonical.com>2018-08-17 20:24:58 +0000
committerServer Team CI Bot <josh.powers+server-team-bot@canonical.com>2018-08-17 20:24:58 +0000
commit47548df9ded4ad4088d3d846f1876b29b16aa7d1 (patch)
tree2518ce7708e80f1df883fc525047e14e42ee7de1 /cloudinit/cmd
parent51f49dc1da0c045d01ddc977874c9bed70cb510f (diff)
downloadvyos-cloud-init-47548df9ded4ad4088d3d846f1876b29b16aa7d1.tar.gz
vyos-cloud-init-47548df9ded4ad4088d3d846f1876b29b16aa7d1.zip
azure: allow azure to generate network configuration from IMDS per boot.
Azure datasource now queries IMDS metadata service for network configuration at link local address http://169.254.169.254/metadata/instance?api-version=2017-12-01. The azure metadata service presents a list of macs and allocated ip addresses associated with this instance. Azure will now also regenerate network configuration on every boot because it subscribes to EventType.BOOT maintenance events as well as the 'first boot' EventType.BOOT_NEW_INSTANCE. For testing add azure-imds --kind to cloud-init devel net_convert tool for debugging IMDS metadata. Also refactor _get_data into 3 discrete methods:   - is_platform_viable: check quickly whether the datasource is     potentially compatible with the platform on which is is running   - crawl_metadata: walk all potential metadata candidates, returning a     structured dict of all metadata and userdata. Raise InvalidMetaData on     error.   - _get_data: call crawl_metadata and process results or error. Cache     instance data on class attributes: metadata, userdata_raw etc.
Diffstat (limited to 'cloudinit/cmd')
-rwxr-xr-xcloudinit/cmd/devel/net_convert.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/cloudinit/cmd/devel/net_convert.py b/cloudinit/cmd/devel/net_convert.py
index 1ec08a3c..271dc5ed 100755
--- a/cloudinit/cmd/devel/net_convert.py
+++ b/cloudinit/cmd/devel/net_convert.py
@@ -8,6 +8,7 @@ import sys
import yaml
from cloudinit.sources.helpers import openstack
+from cloudinit.sources import DataSourceAzure as azure
from cloudinit.net import eni, netplan, network_state, sysconfig
from cloudinit import log
@@ -28,7 +29,8 @@ def get_parser(parser=None):
parser.add_argument("-p", "--network-data", type=open,
metavar="PATH", required=True)
parser.add_argument("-k", "--kind",
- choices=['eni', 'network_data.json', 'yaml'],
+ choices=['eni', 'network_data.json', 'yaml',
+ 'azure-imds'],
required=True)
parser.add_argument("-d", "--directory",
metavar="PATH",
@@ -78,10 +80,13 @@ def handle_args(name, args):
["Input YAML",
yaml.dump(pre_ns, default_flow_style=False, indent=4), ""]))
ns = network_state.parse_net_config_data(pre_ns)
- else:
+ elif args.kind == 'network_data.json':
pre_ns = openstack.convert_net_json(
json.loads(net_data), known_macs=known_macs)
ns = network_state.parse_net_config_data(pre_ns)
+ elif args.kind == 'azure-imds':
+ pre_ns = azure.parse_network_config(json.loads(net_data))
+ ns = network_state.parse_net_config_data(pre_ns)
if not ns:
raise RuntimeError("No valid network_state object created from"