diff --git a/bootstrapvz/base/manifest.py b/bootstrapvz/base/manifest.py index 2e04d42..0daad4f 100644 --- a/bootstrapvz/base/manifest.py +++ b/bootstrapvz/base/manifest.py @@ -27,12 +27,12 @@ class Manifest(object): if path is None and data is None: raise ManifestError('`path\' or `data\' must be provided') self.path = path - self.load(data) - self.initialize() + self.load_data(data) + self.load_modules() self.validate() self.parse() - def load(self, data=None): + def load_data(self, data=None): """Loads the manifest and performs a basic validation. This function reads the manifest and performs some basic validation of the manifest itself to ensure that the properties required for initalization are accessible @@ -47,12 +47,8 @@ class Manifest(object): # Validate the manifest with the base validation function in __init__ validate_manifest(self.data, self.schema_validator, self.validation_error) - def initialize(self): - """Initializes the provider and the plugins. - This function loads the specified provider and plugins. - Once the provider and plugins are loaded, - the initialize() function is called on each of them (if it exists). - The provider must have an initialize function. + def load_modules(self): + """Loads the provider and the plugins. """ # Get the provider name from the manifest and load the corresponding module provider_modname = 'bootstrapvz.providers.' + self.data['provider']['name'] @@ -70,14 +66,6 @@ class Manifest(object): plugin = importlib.import_module(modname) self.modules['plugins'].append(plugin) - # Run the initialize function on the provider and plugins - self.modules['provider'].initialize() - for module in self.modules['plugins']: - # Plugins are not required to have an initialize function - init = getattr(module, 'initialize', None) - if callable(init): - init() - def validate(self): """Validates the manifest using the provider and plugin validation functions. Plugins are not required to have a validate_manifest function @@ -141,7 +129,7 @@ class Manifest(object): def __setstate__(self, state): self.path = state['path'] - self.load(state['data']) - self.initialize() + self.load_data(state['data']) + self.load_modules() self.validate() self.parse() diff --git a/bootstrapvz/providers/azure/__init__.py b/bootstrapvz/providers/azure/__init__.py index a4c2415..a11177b 100644 --- a/bootstrapvz/providers/azure/__init__.py +++ b/bootstrapvz/providers/azure/__init__.py @@ -7,10 +7,6 @@ from bootstrapvz.common.tasks import initd from bootstrapvz.common.tasks import ssh -def initialize(): - pass - - def validate_manifest(data, validator, error): import os.path schema_path = os.path.normpath(os.path.join(os.path.dirname(__file__), 'manifest-schema.yml')) diff --git a/bootstrapvz/providers/ec2/__init__.py b/bootstrapvz/providers/ec2/__init__.py index 23e3c45..b368c8a 100644 --- a/bootstrapvz/providers/ec2/__init__.py +++ b/bootstrapvz/providers/ec2/__init__.py @@ -17,12 +17,6 @@ from bootstrapvz.common.tasks import loopback from bootstrapvz.common.tasks import kernel -def initialize(): - # Regardless of of loglevel, we don't want boto debug stuff, it's very noisy - import logging - logging.getLogger('boto').setLevel(logging.INFO) - - def validate_manifest(data, validator, error): import os.path validator(data, os.path.join(os.path.dirname(__file__), 'manifest-schema.yml')) @@ -64,6 +58,7 @@ def resolve_tasks(taskset, manifest): taskset.update([tasks.host.AddExternalCommands, tasks.packages.DefaultPackages, + tasks.connection.SilenceBotoDebug, tasks.connection.GetCredentials, tasks.ami.AMIName, tasks.connection.Connect, diff --git a/bootstrapvz/providers/ec2/tasks/connection.py b/bootstrapvz/providers/ec2/tasks/connection.py index 5ace8bc..b742ae1 100644 --- a/bootstrapvz/providers/ec2/tasks/connection.py +++ b/bootstrapvz/providers/ec2/tasks/connection.py @@ -3,9 +3,21 @@ from bootstrapvz.common import phases import host +class SilenceBotoDebug(Task): + description = 'Silence boto debug logging' + phase = phases.preparation + + @classmethod + def run(cls, info): + # Regardless of of loglevel, we don't want boto debug stuff, it's very noisy + import logging + logging.getLogger('boto').setLevel(logging.INFO) + + class GetCredentials(Task): description = 'Getting AWS credentials' phase = phases.preparation + successors = [SilenceBotoDebug] @classmethod def run(cls, info): diff --git a/bootstrapvz/providers/gce/__init__.py b/bootstrapvz/providers/gce/__init__.py index cda00e9..cfabcf7 100644 --- a/bootstrapvz/providers/gce/__init__.py +++ b/bootstrapvz/providers/gce/__init__.py @@ -15,10 +15,6 @@ from bootstrapvz.common.tasks import ssh from bootstrapvz.common.tasks import volume -def initialize(): - pass - - def validate_manifest(data, validator, error): import os.path schema_path = os.path.normpath(os.path.join(os.path.dirname(__file__), 'manifest-schema.yml')) diff --git a/bootstrapvz/providers/kvm/__init__.py b/bootstrapvz/providers/kvm/__init__.py index 55879d4..10afcb0 100644 --- a/bootstrapvz/providers/kvm/__init__.py +++ b/bootstrapvz/providers/kvm/__init__.py @@ -5,10 +5,6 @@ from bootstrapvz.common.tasks import initd from bootstrapvz.common.tasks import ssh -def initialize(): - pass - - def validate_manifest(data, validator, error): import os.path schema_path = os.path.normpath(os.path.join(os.path.dirname(__file__), 'manifest-schema.yml')) diff --git a/bootstrapvz/providers/virtualbox/__init__.py b/bootstrapvz/providers/virtualbox/__init__.py index 83411f8..6f62d67 100644 --- a/bootstrapvz/providers/virtualbox/__init__.py +++ b/bootstrapvz/providers/virtualbox/__init__.py @@ -3,10 +3,6 @@ import tasks.packages from bootstrapvz.common.tasks import loopback -def initialize(): - pass - - def validate_manifest(data, validator, error): import os.path schema_path = os.path.normpath(os.path.join(os.path.dirname(__file__), 'manifest-schema.yml'))