diff options
author | zsdc <taras@vyos.io> | 2020-09-09 20:46:10 +0300 |
---|---|---|
committer | zsdc <taras@vyos.io> | 2020-09-09 20:46:10 +0300 |
commit | 9f83567de8cb818398578fdf061e1f7d7940879a (patch) | |
tree | aa0703bfbceeda8c913d8ed735423e6fe2c69e43 | |
parent | d4004ac6ea1c7c03a35d9410f7c70ab423c926bb (diff) | |
download | vyos-cloud-init-9f83567de8cb818398578fdf061e1f7d7940879a.tar.gz vyos-cloud-init-9f83567de8cb818398578fdf061e1f7d7940879a.zip |
cc_vyos: T2117: The source for v1 metadata changed to instance-data.json
Since the `instance-data.json` file is the only way offered by Cloud-Init to get formatted metadata, using it instead of `_get_standardized_metadata()` function is safer and must be compatible with all versions.
-rw-r--r-- | cloudinit/config/cc_vyos.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/cloudinit/config/cc_vyos.py b/cloudinit/config/cc_vyos.py index 2c40fb8d..a6e06e34 100644 --- a/cloudinit/config/cc_vyos.py +++ b/cloudinit/config/cc_vyos.py @@ -28,6 +28,8 @@ from cloudinit import log as logging from cloudinit.ssh_util import AuthKeyLineParser from cloudinit.distros import ug_util from cloudinit.settings import PER_INSTANCE +from cloudinit.sources import INSTANCE_JSON_FILE +from cloudinit.util import load_file, load_json from vyos.configtree import ConfigTree # configure logging @@ -417,7 +419,8 @@ def handle(name, cfg, cloud, log, _args): metadata_ds = cloud.datasource.metadata logger.debug("Meta-Data ds: {}".format(metadata_ds)) # Metadata in stable v1 format (the same structure for all datasources) - metadata_v1 = cloud.datasource._get_standardized_metadata().get('v1') + instance_data_json = load_json(load_file("{}/{}".format(cloud.datasource.paths.run_dir, INSTANCE_JSON_FILE))) + metadata_v1 = instance_data_json.get('v1') logger.debug("Meta-Data v1: {}".format(metadata_v1)) # User-Data userdata = cloud.datasource.userdata |