bootstrap-vz/bootstrapvz/remote/__init__.py

46 lines
2.1 KiB
Python
Raw Normal View History

"""Remote module containing methods to bootstrap remotely
"""
2014-11-30 19:16:27 +01:00
import bootstrapvz.common.exceptions
2014-11-24 23:43:17 +01:00
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)
2014-11-30 19:16:27 +01:00
SerializerBase.register_dict_to_class('bootstrapvz.common.exceptions.ManifestError', deserialize_exception)
SerializerBase.register_dict_to_class('bootstrapvz.common.exceptions.TaskListError', deserialize_exception)
SerializerBase.register_dict_to_class('bootstrapvz.common.exceptions.TaskError', deserialize_exception)
2014-11-24 23:43:17 +01:00
2014-11-25 21:12:37 +01:00
def unregister_deserialization_handlers():
from Pyro4.util import SerializerBase
SerializerBase.unregister_dict_to_class('bootstrapvz.base.manifest.Manifest')
SerializerBase.unregister_dict_to_class('bootstrapvz.base.bootstrapinfo.BootstrapInformation')
2014-11-30 19:16:27 +01:00
SerializerBase.unregister_dict_to_class('bootstrapvz.common.exceptions.ManifestError')
SerializerBase.unregister_dict_to_class('bootstrapvz.common.exceptions.TaskListError')
SerializerBase.unregister_dict_to_class('bootstrapvz.common.exceptions.TaskError')
2014-11-25 21:12:37 +01:00
2014-11-24 23:43:17 +01:00
def deserialize_manifest(classname, state):
from bootstrapvz.base.manifest import Manifest
2014-11-30 19:16:27 +01:00
manifest = Manifest.__new__(Manifest)
manifest.__setstate__(state)
return manifest
2014-11-24 23:43:17 +01:00
def deserialize_bootstrapinfo(classname, state):
from bootstrapvz.base.bootstrapinfo import BootstrapInformation
bootstrap_info = BootstrapInformation.__new__(BootstrapInformation)
bootstrap_info.__setstate__(state)
return bootstrap_info
2014-11-30 19:16:27 +01:00
deserialize_map = {'bootstrapvz.common.exceptions.ManifestError': bootstrapvz.common.exceptions.ManifestError,
'bootstrapvz.common.exceptions.TaskListError': bootstrapvz.common.exceptions.TaskListError,
'bootstrapvz.common.exceptions.TaskError': bootstrapvz.common.exceptions.TaskError,
}
def deserialize_exception(classname, data):
from Pyro4.util import SerializerBase
return SerializerBase.make_exception(deserialize_map[classname], data)