--log-to-console will output messages at INFO and above to the
command-line. This is super-useful when running cloud-init from a
terminal, when you don't want to have to dig in a log file.
Change-Id: Ieb3db384b73441c19ef463649c94b04ffaac8026
The current patch proposes the addition of a new data source strategy
for filtering the strategies by a given list of versions.
Each data source exports a new API, called ``version()``, which should
return the underlying version of the said data source. This implies that
each data source module can export multiple versioned data sources and it's
the duty of an external strategy to select the appropiate data source with
regard to a particular set of versions.
Change-Id: I6ef2fdd6520a53fc600232247f23bd22b848461e
The patch brings a couple of new concepts into cloudinit.
We have a general miniframework for defining plugins and discovering them,
with an actual implementation which uses the *pkgutil* builtin module.
Built atop of this framework, we have a new data source loader, found
in cloudinit.bases.DataSourceLoader. The loader operates on three concepts:
- the *module iterator*, which is used to list modules from a specific
location (in our case, from cloudinit.sources.__path__). The data
source loader takes care to use only the modules that exports a
given API.
- the data source discovery API assumes that each data source module exports
a function called `data_sources`, which should return a tuple of data source
classes that the said module exports. The loader filters the modules
that provides this API.
- the data source loader uses a new concept called *search strategy*
for discovering a potential data source. The search strategies
are classes whose purpose is to select one or more data sources
from a data source stream (any iterable).
There are multiple ways to implement a strategy, the search
can be either serial or parallel, there's no additional requirement
as long as they return an iterable.
Also, the strategies can be stacked together, for instance, having
two strategies, one for selecting only the network data sources
and another for selecting the available data sources from a list
of potential data sources.
This patch also adds a new API that uses the DataSourceLoader
with a given module iterator and strategies for selecting one
data source that cloudinit can use.
Change-Id: I30f312191ce40e45445ed9e3fc8a3d4651903280
unregister allows us to unregister things, so that applying
configuration changes will affect the reporting.
Change-Id: I35932c95784060349c60a11b523bf6897fb80090
This adds a new class ReportingEvent Stack for using
report_start_event and report_finish_event easily with a context
handler.
It also modifies FinishReportingEvent (and finish_event) accordingly
to take a status rather than simply a boolean successful. The intent
is that WARN is provided when a non-desireable result occurred but it
is non-fatal.
Change-Id: I978c76e429790036f8740d7eb7279e925a1e74d0
Having a method that raises NotImplementedError is usually not ideal,
since the implementations of the class can't delegate control
through super to the parent or to other classes found in the MRO.
Instead, we mark a priori ReportingHandler as a base class, leaving
the implementation of `publish_event` empty.
Change-Id: Id5c442b6998743b1caffbad627847ee5e88f2982
This will give us a clearer separation between the core reporting code
(which shouldn't change very often) and the handler code (which is
likely to change more often as we add new handlers and new features to
existing handlers).
It is also the first (baby) step on the path of making handlers
pluggable so third-parties can easily drop their own in.
Change-Id: I648df057d2ff719a2a81398afc80aaef9225ff5c
It seems sane to have consistent use of a 'TestCase' class wherever
possible.
I stumbled on need for this in porting some code (the reporter)
back to cloud-init 0.7.
Change-Id: Ia10546484dfe73154a68e817129ac2f950d5fe85
This will allow us to actually have parameters passed in, which we'll
need for handlers with configuration options.
Change-Id: If105b8108d80b49b6da9e16c7520ddcee1f20c8f
We had a test that was sleeping for around a second, this fudges
time.now() to make it look like it doesn't need to sleep.
Change-Id: I7f4b64ef906fcea50d88bfbf4c3f20f848b26274
Previously wait_any_url returned the first url which responded
correctly, but there was no way to actually retrieve its response.
Change-Id: I41aec4fa1f0a5007af70e787a5503ffeb539c783
This module is quite useful for fetching urls in a manner
that can be provided custom headers, retries and ssl_args
so let's ensure we have it available for usage under these
circumstances.
Also adds some basic sanity tests so that it will continue
to work as expected.
Change-Id: I4d5e777cf530e822bbea69c76846ebebb48a7927
This patch adds the routes implementation, general.check_os_version
and network.default_gateway, which are used by the first data source
layout.
Change-Id: If8ede3c41e834d62cfb2d341d88bc1fbaef947b6
- put a brief description of license in LICENSE file
- put full license versions in LICENSE-GPLv3 and LICENSE-Apache2.0
- simplify the per-file header to reference LICENSE
- also, tox.ini: work around httpretty issue
Change-Id: I259ed23767472047da823c1a67085e47afc561d8
This adds a standard Apache 2.0 license header where
previously was a GPLv3 license header.
As Noted in License.txt, code is still available under GPLv3.
Change-Id: I4d4f4678e014c6bfb663519c444c0d94ae96d81f