diff options
author | Chad Smith <chad.smith@canonical.com> | 2018-07-01 16:46:23 -0600 |
---|---|---|
committer | Chad Smith <chad.smith@canonical.com> | 2018-07-01 16:46:23 -0600 |
commit | be9ecc12823607b4709b64408aee137bfdfc7d01 (patch) | |
tree | 808ef44d9de159bf3307f95e1f8e2d6d600c7e91 /cloudinit/event.py | |
parent | 5858136215753cffc2080c85429a3c7a3754741c (diff) | |
download | vyos-cloud-init-be9ecc12823607b4709b64408aee137bfdfc7d01.tar.gz vyos-cloud-init-be9ecc12823607b4709b64408aee137bfdfc7d01.zip |
update_metadata: a datasource can support network re-config every boot
Very basic type definitions are now defined to distinguish 'boot'
events from 'new instance (first boot)'. Event types will now be handed
to a datasource.update_metadata method which can determine whether
to refresh its metadata and re-render configuration based on that
source event.
A datasource can 'subscribe' to an event by setting up the update_events
attribute on the datasource class which describe what config scope is
updated by a list of matching events. By default datasources will have
the following update_events: {'network': [EventType.BOOT_NEW_INSTANCE]}
This setting says the datasource will re-write network configuration only
on first boot of a new instance or when the instance id changes.
New methods are now present on the datasource:
- clear_cached_attrs: Resets cached datasource attributes to values
listed in datasource.cached_attr_defaults. This is performed prior to
processing a fresh metadata process to avoid keeping old/invalid
cached data around.
- update_metadata: accepts source_event_types to determine if the
metadata should be crawled again and processed
Diffstat (limited to 'cloudinit/event.py')
-rw-r--r-- | cloudinit/event.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/cloudinit/event.py b/cloudinit/event.py new file mode 100644 index 00000000..f7b311fb --- /dev/null +++ b/cloudinit/event.py @@ -0,0 +1,17 @@ +# This file is part of cloud-init. See LICENSE file for license information. + +"""Classes and functions related to event handling.""" + + +# Event types which can generate maintenance requests for cloud-init. +class EventType(object): + BOOT = "System boot" + BOOT_NEW_INSTANCE = "New instance first boot" + + # TODO: Cloud-init will grow support for the follow event types: + # UDEV + # METADATA_CHANGE + # USER_REQUEST + + +# vi: ts=4 expandtab |