diff options
| author | jiahui.qiang <jiahui.qiang@easystack.cn> | 2016-12-04 00:29:03 +0800 |
|---|---|---|
| committer | jiahui.qiang <jiahui.qiang@easystack.cn> | 2016-12-06 00:17:36 +0800 |
| commit | 7e5a98bca91e0734f3440fdbeb12cd59273cd6a4 (patch) | |
| tree | c18ed8bd939d1edf1d1a05ec1c08f35a4f34faa8 /openstackclient/volume/v2 | |
| parent | 29587eaa6661493b7df9357ad818bf058e820730 (diff) | |
| download | python-openstackclient-7e5a98bca91e0734f3440fdbeb12cd59273cd6a4.tar.gz | |
Add some options to "volume create" command
Add "--bootable", "--non-bootable", "--read-only" and "--read-write" options
to "volume create" command for setting some attributes at the time of crration.
Change-Id: I71b4e9fccb4ee0ab1a90e7179d6d2d34dbbae909
Implements: bp cinder-command-support
Diffstat (limited to 'openstackclient/volume/v2')
| -rw-r--r-- | openstackclient/volume/v2/volume.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/openstackclient/volume/v2/volume.py b/openstackclient/volume/v2/volume.py index 80abfb55..301bf5e4 100644 --- a/openstackclient/volume/v2/volume.py +++ b/openstackclient/volume/v2/volume.py @@ -132,6 +132,28 @@ class CreateVolume(command.ShowOne): help=_("Allow volume to be attached more than once " "(default to False)") ) + bootable_group = parser.add_mutually_exclusive_group() + bootable_group.add_argument( + "--bootable", + action="store_true", + help=_("Mark volume as bootable") + ) + bootable_group.add_argument( + "--non-bootable", + action="store_true", + help=_("Mark volume as non-bootable (default)") + ) + 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 (default)") + ) return parser def take_action(self, parsed_args): @@ -199,6 +221,22 @@ class CreateVolume(command.ShowOne): multiattach=parsed_args.multi_attach, scheduler_hints=parsed_args.hint, ) + + if parsed_args.bootable or parsed_args.non_bootable: + try: + volume_client.volumes.set_bootable( + volume.id, parsed_args.bootable) + except Exception as e: + LOG.error(_("Failed to set volume bootable property: %s"), e) + 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) + # Remove key links from being displayed volume._info.update( { |
