summaryrefslogtreecommitdiff
path: root/openstackclient/volume
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
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')
-rw-r--r--openstackclient/volume/v1/volume.py31
-rw-r--r--openstackclient/volume/v2/volume.py47
2 files changed, 78 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"""
diff --git a/openstackclient/volume/v2/volume.py b/openstackclient/volume/v2/volume.py
index cb409711..0e4071fb 100644
--- a/openstackclient/volume/v2/volume.py
+++ b/openstackclient/volume/v2/volume.py
@@ -409,6 +409,53 @@ 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")
+ )
+ lock_group = parser.add_mutually_exclusive_group()
+ lock_group.add_argument(
+ '--lock-volume',
+ action="store_true",
+ help=_("If specified, the volume state will be locked "
+ "and will not allow a migration to be aborted "
+ "(possibly by another operation)")
+ )
+ lock_group.add_argument(
+ '--unlock-volume',
+ action="store_true",
+ help=_("If specified, the volume state will not be "
+ "locked and the a migration can be aborted "
+ "(default) (possibly by another operation)")
+ )
+ 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,
+ parsed_args.lock_volume,)
+
+
class SetVolume(command.Command):
"""Set volume properties"""