Commit 3956e4d2 authored by Matthieu Dorier's avatar Matthieu Dorier

added support for migrate

parent 45f06aa9
......@@ -253,3 +253,24 @@ class BakeProviderHandle():
"""
ret = _pybakeclient.remove(self._ph, rid._rid)
return (ret == 0)
def migrate(self, source_rid, dest_addr, dest_provider_id, dest_target, remove_source=True):
"""
Migrates a give region from its source to a destination designated by
an address, a provider id, and a target id. This function will also remove
the original region if remove_source is set to True.
Args:
source_rid (BakeRegionID): region to remove.
dest_addr (str): destination address.
dest_provider_id (int): destination provider id.
dest_target (BakeTargetID): destinatin target id.
remove_source (bool): whether to remove the source region.
Returns:
The resulting BakeRegionID if successful, None otherwise.
"""
ret = _pybakeclient.migrate(self._ph, source_rid._rid, remove_source,
str(dest_addr), int(dest_provider_id), dest_target._tid)
if(ret == None):
return ret
return BakeRegionID(ret)
......@@ -183,6 +183,21 @@ static bpl::object pybake_read(
return bpl::object(result);
}
static bpl::object pybake_migrate(
bake_provider_handle_t source_ph,
const bake_region_id_t& source_rid,
bool remove_source,
const std::string& dest_addr,
uint16_t dest_provider_id,
bake_target_id_t dest_target_id) {
bake_region_id_t dest_rid;
int ret = bake_migrate(source_ph, source_rid,
remove_source, dest_addr.c_str(), dest_provider_id,
dest_target_id, &dest_rid);
if(ret != BAKE_SUCCESS) return bpl::object();
return bpl::object(dest_rid);
}
#if HAS_NUMPY
static bpl::object pybake_read_numpy(
bake_provider_handle_t ph,
......@@ -227,6 +242,7 @@ BOOST_PYTHON_MODULE(_pybakeclient)
bpl::def("get_size", &pybake_get_size);
bpl::def("read", &pybake_read);
bpl::def("remove", &bake_remove);
bpl::def("migrate", &pybake_migrate);
bpl::def("shutdown_service", &bake_shutdown_service);
#if HAS_NUMPY
bpl::def("write_numpy", &pybake_write_numpy);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment