diff options
| author | Huanxuan Ao <huanxuan.ao@easystack.cn> | 2016-09-28 09:27:32 +0800 |
|---|---|---|
| committer | Huanxuan Ao <huanxuan.ao@easystack.cn> | 2016-10-18 14:34:05 +0800 |
| commit | daffce3a6a31ac59ee10e3cc8fe421320da1704a (patch) | |
| tree | 7c58f76614d5fda6ea154b41623cdef7e8f19b34 /openstackclient/volume/v2/volume.py | |
| parent | 5e3ec1b42faf7dc49722b58829b6c2cf5c15da79 (diff) | |
| download | python-openstackclient-daffce3a6a31ac59ee10e3cc8fe421320da1704a.tar.gz | |
Add "--read-only" and "--read-write" options in "volume set"
Add "--read-only" and "--read-write" options in "volume set"
command to set volume access mode.
Implements: bp cinder-command-support
Change-Id: I76ba85c7d3ff0eb026a9cbd794368d8b2b0d17fe
Diffstat (limited to 'openstackclient/volume/v2/volume.py')
| -rw-r--r-- | openstackclient/volume/v2/volume.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/openstackclient/volume/v2/volume.py b/openstackclient/volume/v2/volume.py index cb409711..695139bd 100644 --- a/openstackclient/volume/v2/volume.py +++ b/openstackclient/volume/v2/volume.py @@ -473,6 +473,17 @@ class SetVolume(command.Command): action="store_true", help=_("Mark volume as non-bootable") ) + readonly_group = parser.add_mutually_exclusive_group() + readonly_group.add_argument( + "--read-only", + action="store_true", + help=_("Set volume to read-only access mode") + ) + readonly_group.add_argument( + "--read-write", + action="store_true", + help=_("Set volume to read-write access mode") + ) return parser def take_action(self, parsed_args): @@ -523,6 +534,15 @@ class SetVolume(command.Command): except Exception as e: LOG.error(_("Failed to set volume bootable property: %s"), e) result += 1 + if parsed_args.read_only or parsed_args.read_write: + try: + volume_client.volumes.update_readonly_flag( + volume.id, + parsed_args.read_only) + except Exception as e: + LOG.error(_("Failed to set volume read-only access " + "mode flag: %s"), e) + result += 1 kwargs = {} if parsed_args.name: |
