On Thu, Jul 10, 2014 at 6:09 PM, Dimitris Aragiorgis <[email protected]> wrote:
> Currently, this remains unused, until we add support for > explicitly snapshotting instance disks. > > Signed-off-by: Dimitris Aragiorgis <[email protected]> > --- > lib/backend.py | 12 ++++++++---- > lib/masterd/instance.py | 4 +++- > lib/rpc_defs.py | 2 ++ > lib/server/noded.py | 7 ++++--- > 4 files changed, 17 insertions(+), 8 deletions(-) > > diff --git a/lib/backend.py b/lib/backend.py > index cbd900f..3430e71 100644 > --- a/lib/backend.py > +++ b/lib/backend.py > @@ -3392,7 +3392,7 @@ def BlockdevGrow(disk, amount, dryrun, backingstore, > excl_stor): > _Fail("Failed to grow block device: %s", err, exc=True) > > > -def BlockdevSnapshot(disk): > +def BlockdevSnapshot(disk, snap_name, snap_size): > """Create a snapshot copy of a block device. > > This function is called recursively, and the snapshot is actually > created > @@ -3400,6 +3400,10 @@ def BlockdevSnapshot(disk): > > @type disk: L{objects.Disk} > @param disk: the disk to be snapshotted > + @type snap_name: string > + @param snap_name: the name of the snapshot > + @type snap_size: int > + @param snap_size: the size of the snapshot > @rtype: string > @return: snapshot disk ID as (vg, lv) > > @@ -3415,11 +3419,11 @@ def BlockdevSnapshot(disk): > if not disk.children: > _Fail("DRBD device '%s' without backing storage cannot be > snapshotted", > disk.unique_id) > - return BlockdevSnapshot(disk.children[0]) > + return BlockdevSnapshot(disk.children[0], snap_name, snap_size) > elif disk.dev_type == constants.DT_PLAIN: > - return _DiskSnapshot(disk) > + return _DiskSnapshot(disk, snap_name, snap_size) > elif disk.dev_type == constants.DT_EXT: > - return _DiskSnapshot(disk) > + return _DiskSnapshot(disk, snap_name, snap_size) > else: > _Fail("Cannot snapshot block device '%s' of type '%s'", > disk.unique_id, disk.dev_type) > diff --git a/lib/masterd/instance.py b/lib/masterd/instance.py > index 5a2dcf1..c1639e3 100644 > --- a/lib/masterd/instance.py > +++ b/lib/masterd/instance.py > @@ -1173,7 +1173,9 @@ class ExportInstanceHelper(object): > > # result.payload will be a snapshot of an lvm leaf of the one we > # passed > - result = self._lu.rpc.call_blockdev_snapshot(src_node, (disk, > instance)) > + result = self._lu.rpc.call_blockdev_snapshot(src_node, > + (disk, instance), > + None, None) > new_dev = False > msg = result.fail_msg > if msg: > diff --git a/lib/rpc_defs.py b/lib/rpc_defs.py > index 5d2b35f..c56776a 100644 > --- a/lib/rpc_defs.py > +++ b/lib/rpc_defs.py > @@ -438,6 +438,8 @@ _BLOCKDEV_CALLS = [ > " given amount"), > ("blockdev_snapshot", SINGLE, None, constants.RPC_TMO_NORMAL, [ > ("cf_bdev", ED_SINGLE_DISK_DICT_DP, None), > + ("snap_name", None, None), > + ("snap_size", None, None), > ], None, None, "Export a given disk to another node"), > ("blockdev_rename", SINGLE, None, constants.RPC_TMO_NORMAL, [ > ("devlist", ED_BLOCKDEV_RENAME, None), > diff --git a/lib/server/noded.py b/lib/server/noded.py > index 23f79f4..bca7252 100644 > --- a/lib/server/noded.py > +++ b/lib/server/noded.py > @@ -369,13 +369,14 @@ class > NodeRequestHandler(http.server.HttpServerHandler): > def perspective_blockdev_snapshot(params): > """Create a snapshot device. > > - Note that this is only valid for LVM disks, if we get passed > + Note that this is only valid for LVM and ExtStorage disks, if we get > passed > something else we raise an exception. The snapshot device can be > remove by calling the generic block device remove call. > > """ > - cfbd = objects.Disk.FromDict(params[0]) > - return backend.BlockdevSnapshot(cfbd) > + (disk, snap_name, snap_size) = params > + cfbd = objects.Disk.FromDict(disk) > + return backend.BlockdevSnapshot(cfbd, snap_name, snap_size) > @staticmethod > def perspective_blockdev_grow(params): > -- > 1.7.10.4 > > LGTM, thanks
