Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable static network configuration via vmware guestinfo #2 #107

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions cloudbaseinit/metadata/services/vmwareguestinfoservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from cloudbaseinit import conf as cloudbaseinit_conf
from cloudbaseinit import exception
from cloudbaseinit.metadata.services import base
from cloudbaseinit.metadata.services import nocloudservice
from cloudbaseinit.osutils import factory as osutils_factory
from cloudbaseinit.utils import serialization

Expand Down Expand Up @@ -151,3 +152,22 @@ 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
if 'version' not in network_data:
LOG.error("No network version information 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
if 'config' not in network_data:
LOG.error("Network configuration does not exist")
return
network_config_parser = nocloudservice.NoCloudNetworkConfigV1Parser()
return network_config_parser.parse(network_data.get("config"))
16 changes: 16 additions & 0 deletions doc/source/services.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -551,6 +564,9 @@ Capabilities:
* admin user name
* admin user password
* user data
* static network configuration (`network config v1
<https://cloudinit.readthedocs.io/en/latest/topics/network-config-format-v1.html>`_
format)

Config options for `vmwareguestinfo` section:

Expand Down