Support volume attach set ro/rw mode

Registered by YaoZheng_ZTE

Currently, when attach a volume to an instance, cinder api interface has supported to specify attach mode. This mode can be valued by ro or rw. The cinder api like this:
 @wsgi.action('os-attach')
  def _attach(self, req, id, body):
        """Add attachment metadata."""
        ......
        # instance uuid is an option now
        instance_uuid = None
        if 'instance_uuid' in body['os-attach']:
            instance_uuid = body['os-attach']['instance_uuid']
        ......
        mountpoint = body['os-attach']['mountpoint']
        if 'mode' in body['os-attach']:
            mode = body['os-attach']['mode']
        else:
            mode = 'rw'
        ......
        if mode not in ('rw', 'ro'):
            msg = _("Invalid request to attach volume with an invalid mode. "
                    "Attaching mode should be 'rw' or 'ro'")
            raise webob.exc.HTTPBadRequest(explanation=msg)
        try:
            self.volume_api.attach(context, volume,
                                   instance_uuid, host_name, mountpoint, mode)
        except messaging.RemoteError as error:
Out of consideration of data security, users sometimes need a set of VM disk attached as read-only. So the mode is useful for user. But currently nova has no way to set the mode. So, The BP's intention is to allow Nova to volume-attach to support passed the mode parameter.
Currently, The CLI command like this:
[root@stack ~(keystone_admin)]# nova help volume-attach
usage: nova volume-attach <server> <volume> [<device>]

Attach a volume to a server.

Positional arguments:
  <server> Name or ID of server.
  <volume> ID of the volume to attach.
  <device> Name of the device e.g. /dev/vdb. Use "auto" for autoassign (if
                    supported). Libvirt driver will use default device name.
Maybe we can add a positional arguments <mode>, the value is in ro or rw. If the user has no specify the mode parameter, rw is set in default.

Blueprint information

Status:
Not started
Approver:
None
Priority:
Undefined
Drafter:
YaoZheng_ZTE
Direction:
Needs approval
Assignee:
YaoZheng_ZTE
Definition:
New
Series goal:
None
Implementation:
Unknown
Milestone target:
None

Related branches

Sprints

Whiteboard

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.