Implement initialize() fn for providers and plugins ,silence boto debug

This commit is contained in:
Anders Ingemann 2013-07-01 20:56:38 +02:00
parent 3726d72c68
commit d3ab01f88f
2 changed files with 16 additions and 2 deletions

View file

@ -5,7 +5,12 @@ log = logging.getLogger(__name__)
def load_manifest(path):
data = load_json(path)
provider = __import__('providers.{module}'.format(module=data['provider']), fromlist=['providers'])
provider_name = data['provider']
provider = __import__('providers.{module}'.format(module=provider_name), fromlist=['providers'])
init = getattr(provider, 'initialize', None)
if callable(init):
init()
log.debug('Loaded provider `%s\'', provider_name)
manifest = provider.Manifest(path)
manifest.validate(data)
@ -56,7 +61,10 @@ class Manifest(object):
if plugin_data['enabled']:
modname = 'plugins.{plugin_name}'.format(plugin_name=plugin_name)
plugin = __import__(modname, fromlist=['plugins'])
log.debug('Loaded plugin %s', plugin_name)
init = getattr(plugin, 'initialize', None)
if callable(init):
init()
log.debug('Loaded plugin `%s\'', plugin_name)
self.loaded_plugins.append(plugin)
validate = getattr(plugin, 'validate_manifest', None)
if callable(validate):

View file

@ -1,4 +1,5 @@
from manifest import Manifest
import logging
from tasks import packages
from tasks import connection
from tasks import host
@ -7,6 +8,11 @@ from tasks import filesystem
from tasks import bootstrap
def initialize():
# Regardless of of loglevel, we don't want boto debug stuff, it's very noisy
logging.getLogger('boto').setLevel(logging.INFO)
def tasks(tasklist, manifest):
tasklist.add(packages.HostPackages(), packages.ImagePackages(), host.CheckPackages(),
connection.GetCredentials(), host.GetInfo(), connection.Connect())