cloud-init-dev team mailing list archive
-
cloud-init-dev team
-
Mailing list archive
-
Message #05067
Re: [Merge] ~chad.smith/cloud-init:feature/maintain-network-on-boot into cloud-init:master
Diff comments:
> diff --git a/cloudinit/sources/__init__.py b/cloudinit/sources/__init__.py
> index 90d7457..302cd59 100644
> --- a/cloudinit/sources/__init__.py
> +++ b/cloudinit/sources/__init__.py
> @@ -102,6 +103,22 @@ class DataSource(object):
> url_timeout = 10 # timeout for each metadata url read attempt
> url_retries = 5 # number of times to retry url upon 404
>
> + # The datasource defines a list of supported EventTypes for
> + # which network_configuration is regenerated.
the datasource itself doesnt really have "supported eventtypes for
which network_configuration is regenerated". cloud-init internally
supports network_configuration regeneration, and ultimately needs
to be able to do that on "boot", "boot-new-instance", "udev"...
I think more correctly the datasource is declaring when it
might find new data.
> + # A datasource which supports writing network config on each system boot
> + # would set network_maintenance_events = [EventType.BOOT].
> +
> + # Default: generate network config on new instance id (first boot).
> + network_maintenance_events = [EventType.BOOT_NEW_INSTANCE]
> +
> + # N-tuple listing default values for any metadata-related class
> + # attributes cached on an instance by a get_data runs. These attribute
> + # values are reset via clear_cached_data during any of the supported
> + # network_maintenance_events.
> + cached_attr_defaults = (
> + ('userdata', None), ('metadata', {}), ('userdata_raw', None),
> + ('vendordata', None), ('vendordata_raw', None))
> +
> def __init__(self, sys_cfg, distro, paths, ud_proc=None):
> self.sys_cfg = sys_cfg
> self.distro = distro
> @@ -416,6 +439,34 @@ class DataSource(object):
> def get_package_mirror_info(self):
> return self.distro.get_package_mirror_info(data_source=self)
>
> + def update_metadata(self, source_event_types):
> + """Refresh cached metadata if the datasource supports this event.
> +
> + The datasource has a list of network_maintenance_events which
> + trigger refreshing all cached metadata.
> +
> + @param source_event_types: List of EventTypes which may trigger a
> + metadata update.
> +
> + @return True if the datasource did successfully update cached metadata
> + due to source_event_type.
> + """
> + supported_events = [
> + evt for evt in source_event_types
> + if evt in self.network_maintenance_events]
this is similarly confusing for me.
update_metadata can happen any time really... its just that the source of
that metadata might not have changed.
> + if supported_events:
> + LOG.debug(
> + "Update datasource metadata due to maintenance events: '%s'",
> + ','.join(supported_events))
> + result = self.clear_cached_data()
> + result = self.get_data()
> + if result:
> + return True
> + else:
> + LOG.warning(
> + 'Update metadata encountered invalid datasource type')
> + return False
> +
> def check_instance_id(self, sys_cfg):
> # quickly (local check only) if self.instance_id is still
> return False
--
https://code.launchpad.net/~chad.smith/cloud-init/+git/cloud-init/+merge/348000
Your team cloud-init commiters is requested to review the proposed merge of ~chad.smith/cloud-init:feature/maintain-network-on-boot into cloud-init:master.
References