mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 07:26:29 +00:00
Fix (de-)serialization
This commit is contained in:
parent
2b33561b82
commit
3542406b91
5 changed files with 46 additions and 15 deletions
|
@ -90,6 +90,9 @@ class BootstrapInformation(object):
|
||||||
def __delattr__(self, name):
|
def __delattr__(self, name):
|
||||||
del self[name]
|
del self[name]
|
||||||
|
|
||||||
|
def __getstate__(self):
|
||||||
|
return self.__dict__
|
||||||
|
|
||||||
def set_manifest_vars(obj, data):
|
def set_manifest_vars(obj, data):
|
||||||
"""Runs through the manifest and creates DictClasses for every key
|
"""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
|
# They are added last so that they may override previous variables
|
||||||
set_manifest_vars(manifest_vars, additional_vars)
|
set_manifest_vars(manifest_vars, additional_vars)
|
||||||
return manifest_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]
|
||||||
|
|
|
@ -133,5 +133,6 @@ class Manifest(object):
|
||||||
raise ManifestError(message, self.path, data_path)
|
raise ManifestError(message, self.path, data_path)
|
||||||
|
|
||||||
def __getstate__(self):
|
def __getstate__(self):
|
||||||
return {'path': self.path,
|
return {'__class__': 'bootstrapvz.base.manifest.Manifest',
|
||||||
|
'path': self.path,
|
||||||
'data': self.data}
|
'data': self.data}
|
||||||
|
|
|
@ -1,15 +1,7 @@
|
||||||
import Pyro4
|
|
||||||
from threading import Thread
|
|
||||||
"""Remote module containing methods to bootstrap remotely
|
"""Remote module containing methods to bootstrap remotely
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
import logging
|
|
||||||
log = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
stop = False
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Main function for invoking the bootstrap process remotely
|
"""Main function for invoking the bootstrap process remotely
|
||||||
"""
|
"""
|
||||||
|
@ -27,6 +19,10 @@ def main():
|
||||||
from bootstrapvz.base.main import setup_loggers
|
from bootstrapvz.base.main import setup_loggers
|
||||||
setup_loggers(opts)
|
setup_loggers(opts)
|
||||||
|
|
||||||
|
register_deserialization_handlers()
|
||||||
|
|
||||||
|
bootstrap_info = None
|
||||||
|
|
||||||
from ssh_rpc_manager import SSHRPCManager
|
from ssh_rpc_manager import SSHRPCManager
|
||||||
manager = SSHRPCManager(build_servers[opts['SERVER']])
|
manager = SSHRPCManager(build_servers[opts['SERVER']])
|
||||||
try:
|
try:
|
||||||
|
@ -41,14 +37,15 @@ def main():
|
||||||
server.set_log_server(log_server)
|
server.set_log_server(log_server)
|
||||||
|
|
||||||
# Everything has been set up, begin the bootstrapping process
|
# Everything has been set up, begin the bootstrapping process
|
||||||
server.run(manifest,
|
bootstrap_info = server.run(manifest,
|
||||||
debug=opts['--debug'],
|
debug=opts['--debug'],
|
||||||
pause_on_error=False,
|
pause_on_error=False,
|
||||||
dry_run=opts['--dry-run'])
|
dry_run=opts['--dry-run'])
|
||||||
finally:
|
finally:
|
||||||
callback_server.stop()
|
callback_server.stop()
|
||||||
finally:
|
finally:
|
||||||
manager.stop()
|
manager.stop()
|
||||||
|
return bootstrap_info
|
||||||
|
|
||||||
|
|
||||||
def get_opts():
|
def get_opts():
|
||||||
|
@ -69,3 +66,21 @@ Options:
|
||||||
-h, --help show this help
|
-h, --help show this help
|
||||||
"""
|
"""
|
||||||
return docopt(usage)
|
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
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
opts = getopts()
|
opts = getopts()
|
||||||
|
from . import register_deserialization_handlers
|
||||||
|
register_deserialization_handlers()
|
||||||
log_forwarder = setup_logging()
|
log_forwarder = setup_logging()
|
||||||
serve(opts, log_forwarder)
|
serve(opts, log_forwarder)
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,6 @@ class TaskList(object):
|
||||||
:param dict info: The bootstrap information object
|
:param dict info: The bootstrap information object
|
||||||
:param bool dry_run: Whether to actually run the tasks or simply step through them
|
: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
|
# Create a list for us to run
|
||||||
task_list = create_list(self.tasks)
|
task_list = create_list(self.tasks)
|
||||||
# Output the tasklist
|
# Output the tasklist
|
||||||
|
|
Loading…
Add table
Reference in a new issue