diff --git a/bootstrapvz/base/bootstrapinfo.py b/bootstrapvz/base/bootstrapinfo.py index 0313e3b..70dfa4d 100644 --- a/bootstrapvz/base/bootstrapinfo.py +++ b/bootstrapvz/base/bootstrapinfo.py @@ -90,6 +90,9 @@ class BootstrapInformation(object): def __delattr__(self, name): del self[name] + def __getstate__(self): + return self.__dict__ + def set_manifest_vars(obj, data): """Runs through the manifest and creates DictClasses for every key @@ -124,3 +127,15 @@ class BootstrapInformation(object): # They are added last so that they may override previous variables set_manifest_vars(manifest_vars, additional_vars) return manifest_vars + + def __getstate__(self): + state = self.__dict__.copy() + exclude_keys = ['volume', 'source_lists', 'preference_lists', 'packages'] + for key in exclude_keys: + del state[key] + state['__class__'] = 'bootstrapvz.base.bootstrapinfo.BootstrapInformation' + return state + + def __setstate__(self, state): + for key in state: + self.__dict__[key] = state[key] diff --git a/bootstrapvz/base/manifest.py b/bootstrapvz/base/manifest.py index 576e31f..2854068 100644 --- a/bootstrapvz/base/manifest.py +++ b/bootstrapvz/base/manifest.py @@ -133,5 +133,6 @@ class Manifest(object): raise ManifestError(message, self.path, data_path) def __getstate__(self): - return {'path': self.path, + return {'__class__': 'bootstrapvz.base.manifest.Manifest', + 'path': self.path, 'data': self.data} diff --git a/bootstrapvz/base/remote/__init__.py b/bootstrapvz/base/remote/__init__.py index b7ba576..52e01c5 100644 --- a/bootstrapvz/base/remote/__init__.py +++ b/bootstrapvz/base/remote/__init__.py @@ -1,15 +1,7 @@ -import Pyro4 -from threading import Thread """Remote module containing methods to bootstrap remotely """ -import logging -log = logging.getLogger(__name__) - -stop = False - - def main(): """Main function for invoking the bootstrap process remotely """ @@ -27,6 +19,10 @@ def main(): from bootstrapvz.base.main import setup_loggers setup_loggers(opts) + register_deserialization_handlers() + + bootstrap_info = None + from ssh_rpc_manager import SSHRPCManager manager = SSHRPCManager(build_servers[opts['SERVER']]) try: @@ -41,14 +37,15 @@ def main(): server.set_log_server(log_server) # Everything has been set up, begin the bootstrapping process - server.run(manifest, - debug=opts['--debug'], - pause_on_error=False, - dry_run=opts['--dry-run']) + bootstrap_info = server.run(manifest, + debug=opts['--debug'], + pause_on_error=False, + dry_run=opts['--dry-run']) finally: callback_server.stop() finally: manager.stop() + return bootstrap_info def get_opts(): @@ -69,3 +66,21 @@ Options: -h, --help show this help """ return docopt(usage) + + +def register_deserialization_handlers(): + from Pyro4.util import SerializerBase + SerializerBase.register_dict_to_class('bootstrapvz.base.manifest.Manifest', deserialize_manifest) + SerializerBase.register_dict_to_class('bootstrapvz.base.bootstrapinfo.BootstrapInformation', deserialize_bootstrapinfo) + + +def deserialize_manifest(classname, state): + from bootstrapvz.base.manifest import Manifest + return Manifest(path=state['path'], data=state['data']) + + +def deserialize_bootstrapinfo(classname, state): + from bootstrapvz.base.bootstrapinfo import BootstrapInformation + bootstrap_info = BootstrapInformation.__new__(BootstrapInformation) + bootstrap_info.__setstate__(state) + return bootstrap_info diff --git a/bootstrapvz/base/remote/server.py b/bootstrapvz/base/remote/server.py index 28b9d38..e9325a8 100644 --- a/bootstrapvz/base/remote/server.py +++ b/bootstrapvz/base/remote/server.py @@ -2,6 +2,8 @@ def main(): opts = getopts() + from . import register_deserialization_handlers + register_deserialization_handlers() log_forwarder = setup_logging() serve(opts, log_forwarder) diff --git a/bootstrapvz/base/tasklist.py b/bootstrapvz/base/tasklist.py index 15cfd5d..8e5dbb1 100644 --- a/bootstrapvz/base/tasklist.py +++ b/bootstrapvz/base/tasklist.py @@ -21,8 +21,6 @@ class TaskList(object): :param dict info: The bootstrap information object :param bool dry_run: Whether to actually run the tasks or simply step through them """ - logging.getLogger(__name__).debug('test') - return # Create a list for us to run task_list = create_list(self.tasks) # Output the tasklist