summaryrefslogtreecommitdiff
path: root/openstackclient/volume/v1/volume.py
diff options
context:
space:
mode:
authorHuanxuan Ao <huanxuan.ao@easystack.cn>2016-10-01 18:38:29 +0800
committerHuanxuan Ao <huanxuan.ao@easystack.cn>2016-10-18 11:48:30 +0800
commitd7c8bb88e4a117d8ab6a53c3a7d14cc7a4105eda (patch)
tree0d57ee569161f51704811caf70b5985ea3a75c8d /openstackclient/volume/v1/volume.py
parent5e3ec1b42faf7dc49722b58829b6c2cf5c15da79 (diff)
downloadpython-openstackclient-d7c8bb88e4a117d8ab6a53c3a7d14cc7a4105eda.tar.gz
Add "volume migrate" command
Add "volume migrate" command in volume v1 and v2 to support migrating volume to a new host Change-Id: Ie4e6037171a31a872006a13f9fd1e15eaa627c26 Implements: bp cinder-command-support
Diffstat (limited to 'openstackclient/volume/v1/volume.py')
-rw-r--r--openstackclient/volume/v1/volume.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/openstackclient/volume/v1/volume.py b/openstackclient/volume/v1/volume.py
index cafe8ce6..63bcfbb8 100644
--- a/openstackclient/volume/v1/volume.py
+++ b/openstackclient/volume/v1/volume.py
@@ -344,6 +344,37 @@ class ListVolume(command.Lister):
) for s in data))
+class MigrateVolume(command.Command):
+ """Migrate volume to a new host"""
+
+ def get_parser(self, prog_name):
+ parser = super(MigrateVolume, self).get_parser(prog_name)
+ parser.add_argument(
+ 'volume',
+ metavar="<volume>",
+ help=_("Volume to migrate (name or ID)")
+ )
+ parser.add_argument(
+ '--host',
+ metavar="<host>",
+ required=True,
+ help=_("Destination host (takes the form: host@backend-name#pool)")
+ )
+ parser.add_argument(
+ '--force-host-copy',
+ action="store_true",
+ help=_("Enable generic host-based force-migration, "
+ "which bypasses driver optimizations")
+ )
+ return parser
+
+ def take_action(self, parsed_args):
+ volume_client = self.app.client_manager.volume
+ volume = utils.find_resource(volume_client.volumes, parsed_args.volume)
+ volume_client.volumes.migrate_volume(volume.id, parsed_args.host,
+ parsed_args.force_host_copy,)
+
+
class SetVolume(command.Command):
"""Set volume properties"""