From e0b1278fb0ba91f34fd2c2b2869641aca21ccfa6 Mon Sep 17 00:00:00 2001 From: Jeremy Kimber Date: Mon, 22 Nov 2021 13:40:44 -0600 Subject: [PATCH 1/2] enable static network configuration via vmware guestinfo --- .../metadata/services/vmwareguestinfoservice.py | 14 ++++++++++++++ doc/source/services.rst | 16 ++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/cloudbaseinit/metadata/services/vmwareguestinfoservice.py b/cloudbaseinit/metadata/services/vmwareguestinfoservice.py index e469c1afd..8f60e6c83 100644 --- a/cloudbaseinit/metadata/services/vmwareguestinfoservice.py +++ b/cloudbaseinit/metadata/services/vmwareguestinfoservice.py @@ -25,6 +25,7 @@ from cloudbaseinit.metadata.services import base from cloudbaseinit.osutils import factory as osutils_factory from cloudbaseinit.utils import serialization +from cloudbaseinit.metadata.services.nocloudservice import NoCloudNetworkConfigV1Parser CONF = cloudbaseinit_conf.CONF LOG = oslo_logging.getLogger(__name__) @@ -151,3 +152,16 @@ def get_admin_username(self): def get_admin_password(self): return self._meta_data.get('admin-password') + + def get_network_details_v2(self): + network_data = self._meta_data.get('network') + if not network_data: + LOG.info("No network configuration found in metadata") + return + network_data_version = network_data.get("version") + if network_data_version != 1: + LOG.error("Network data version '%s' is not supported", + network_data_version) + return + network_config_parser = NoCloudNetworkConfigV1Parser() + return network_config_parser.parse(network_data.get("config")) diff --git a/doc/source/services.rst b/doc/source/services.rst index a38b64385..66427790f 100644 --- a/doc/source/services.rst +++ b/doc/source/services.rst @@ -518,6 +518,19 @@ Example metadata in yaml format: public-keys-data: | ssh-key 1 ssh-key 2 + network: + version: 1 + config: + - type: physical + name: interface0 + mac_address: "52:54:00:12:34:00" + subnets: + - type: static + address: 192.168.1.10 + netmask: 255.255.255.0 + dns_nameservers: + - 192.168.1.11 + This metadata content needs to be set as string in the guestinfo dictionary, thus needs to be converted to base64 (it is recommended to @@ -551,6 +564,9 @@ Capabilities: * admin user name * admin user password * user data + * static network configuration (`network config v1 + `_ + format) Config options for `vmwareguestinfo` section: From b8b78f445236444977f3880630b91ba656ca5f66 Mon Sep 17 00:00:00 2001 From: Jeremy Kimber Date: Thu, 17 Feb 2022 12:30:24 -0600 Subject: [PATCH 2/2] fix import --- cloudbaseinit/metadata/services/vmwareguestinfoservice.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cloudbaseinit/metadata/services/vmwareguestinfoservice.py b/cloudbaseinit/metadata/services/vmwareguestinfoservice.py index 8f60e6c83..7c0665c30 100644 --- a/cloudbaseinit/metadata/services/vmwareguestinfoservice.py +++ b/cloudbaseinit/metadata/services/vmwareguestinfoservice.py @@ -25,7 +25,7 @@ from cloudbaseinit.metadata.services import base from cloudbaseinit.osutils import factory as osutils_factory from cloudbaseinit.utils import serialization -from cloudbaseinit.metadata.services.nocloudservice import NoCloudNetworkConfigV1Parser +from cloudbaseinit.metadata.services import nocloudservice CONF = cloudbaseinit_conf.CONF LOG = oslo_logging.getLogger(__name__) @@ -163,5 +163,5 @@ def get_network_details_v2(self): LOG.error("Network data version '%s' is not supported", network_data_version) return - network_config_parser = NoCloudNetworkConfigV1Parser() + network_config_parser = nocloudservice.NoCloudNetworkConfigV1Parser() return network_config_parser.parse(network_data.get("config"))