mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 15:36:27 +00:00
Kill the initalize() function. Nobody uses it except ec2
The boto debug messages are now silenced with a task.
This commit is contained in:
parent
2ef9382a55
commit
989f33c226
7 changed files with 20 additions and 41 deletions
|
@ -27,12 +27,12 @@ class Manifest(object):
|
||||||
if path is None and data is None:
|
if path is None and data is None:
|
||||||
raise ManifestError('`path\' or `data\' must be provided')
|
raise ManifestError('`path\' or `data\' must be provided')
|
||||||
self.path = path
|
self.path = path
|
||||||
self.load(data)
|
self.load_data(data)
|
||||||
self.initialize()
|
self.load_modules()
|
||||||
self.validate()
|
self.validate()
|
||||||
self.parse()
|
self.parse()
|
||||||
|
|
||||||
def load(self, data=None):
|
def load_data(self, data=None):
|
||||||
"""Loads the manifest and performs a basic validation.
|
"""Loads the manifest and performs a basic validation.
|
||||||
This function reads the manifest and performs some basic validation of
|
This function reads the manifest and performs some basic validation of
|
||||||
the manifest itself to ensure that the properties required for initalization are accessible
|
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 the manifest with the base validation function in __init__
|
||||||
validate_manifest(self.data, self.schema_validator, self.validation_error)
|
validate_manifest(self.data, self.schema_validator, self.validation_error)
|
||||||
|
|
||||||
def initialize(self):
|
def load_modules(self):
|
||||||
"""Initializes the provider and the plugins.
|
"""Loads 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.
|
|
||||||
"""
|
"""
|
||||||
# Get the provider name from the manifest and load the corresponding module
|
# Get the provider name from the manifest and load the corresponding module
|
||||||
provider_modname = 'bootstrapvz.providers.' + self.data['provider']['name']
|
provider_modname = 'bootstrapvz.providers.' + self.data['provider']['name']
|
||||||
|
@ -70,14 +66,6 @@ class Manifest(object):
|
||||||
plugin = importlib.import_module(modname)
|
plugin = importlib.import_module(modname)
|
||||||
self.modules['plugins'].append(plugin)
|
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):
|
def validate(self):
|
||||||
"""Validates the manifest using the provider and plugin validation functions.
|
"""Validates the manifest using the provider and plugin validation functions.
|
||||||
Plugins are not required to have a validate_manifest function
|
Plugins are not required to have a validate_manifest function
|
||||||
|
@ -141,7 +129,7 @@ class Manifest(object):
|
||||||
|
|
||||||
def __setstate__(self, state):
|
def __setstate__(self, state):
|
||||||
self.path = state['path']
|
self.path = state['path']
|
||||||
self.load(state['data'])
|
self.load_data(state['data'])
|
||||||
self.initialize()
|
self.load_modules()
|
||||||
self.validate()
|
self.validate()
|
||||||
self.parse()
|
self.parse()
|
||||||
|
|
|
@ -7,10 +7,6 @@ from bootstrapvz.common.tasks import initd
|
||||||
from bootstrapvz.common.tasks import ssh
|
from bootstrapvz.common.tasks import ssh
|
||||||
|
|
||||||
|
|
||||||
def initialize():
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def validate_manifest(data, validator, error):
|
def validate_manifest(data, validator, error):
|
||||||
import os.path
|
import os.path
|
||||||
schema_path = os.path.normpath(os.path.join(os.path.dirname(__file__), 'manifest-schema.yml'))
|
schema_path = os.path.normpath(os.path.join(os.path.dirname(__file__), 'manifest-schema.yml'))
|
||||||
|
|
|
@ -17,12 +17,6 @@ from bootstrapvz.common.tasks import loopback
|
||||||
from bootstrapvz.common.tasks import kernel
|
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):
|
def validate_manifest(data, validator, error):
|
||||||
import os.path
|
import os.path
|
||||||
validator(data, os.path.join(os.path.dirname(__file__), 'manifest-schema.yml'))
|
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,
|
taskset.update([tasks.host.AddExternalCommands,
|
||||||
tasks.packages.DefaultPackages,
|
tasks.packages.DefaultPackages,
|
||||||
|
tasks.connection.SilenceBotoDebug,
|
||||||
tasks.connection.GetCredentials,
|
tasks.connection.GetCredentials,
|
||||||
tasks.ami.AMIName,
|
tasks.ami.AMIName,
|
||||||
tasks.connection.Connect,
|
tasks.connection.Connect,
|
||||||
|
|
|
@ -3,9 +3,21 @@ from bootstrapvz.common import phases
|
||||||
import host
|
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):
|
class GetCredentials(Task):
|
||||||
description = 'Getting AWS credentials'
|
description = 'Getting AWS credentials'
|
||||||
phase = phases.preparation
|
phase = phases.preparation
|
||||||
|
successors = [SilenceBotoDebug]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, info):
|
def run(cls, info):
|
||||||
|
|
|
@ -15,10 +15,6 @@ from bootstrapvz.common.tasks import ssh
|
||||||
from bootstrapvz.common.tasks import volume
|
from bootstrapvz.common.tasks import volume
|
||||||
|
|
||||||
|
|
||||||
def initialize():
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def validate_manifest(data, validator, error):
|
def validate_manifest(data, validator, error):
|
||||||
import os.path
|
import os.path
|
||||||
schema_path = os.path.normpath(os.path.join(os.path.dirname(__file__), 'manifest-schema.yml'))
|
schema_path = os.path.normpath(os.path.join(os.path.dirname(__file__), 'manifest-schema.yml'))
|
||||||
|
|
|
@ -5,10 +5,6 @@ from bootstrapvz.common.tasks import initd
|
||||||
from bootstrapvz.common.tasks import ssh
|
from bootstrapvz.common.tasks import ssh
|
||||||
|
|
||||||
|
|
||||||
def initialize():
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def validate_manifest(data, validator, error):
|
def validate_manifest(data, validator, error):
|
||||||
import os.path
|
import os.path
|
||||||
schema_path = os.path.normpath(os.path.join(os.path.dirname(__file__), 'manifest-schema.yml'))
|
schema_path = os.path.normpath(os.path.join(os.path.dirname(__file__), 'manifest-schema.yml'))
|
||||||
|
|
|
@ -3,10 +3,6 @@ import tasks.packages
|
||||||
from bootstrapvz.common.tasks import loopback
|
from bootstrapvz.common.tasks import loopback
|
||||||
|
|
||||||
|
|
||||||
def initialize():
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def validate_manifest(data, validator, error):
|
def validate_manifest(data, validator, error):
|
||||||
import os.path
|
import os.path
|
||||||
schema_path = os.path.normpath(os.path.join(os.path.dirname(__file__), 'manifest-schema.yml'))
|
schema_path = os.path.normpath(os.path.join(os.path.dirname(__file__), 'manifest-schema.yml'))
|
||||||
|
|
Loading…
Add table
Reference in a new issue