'Update/Finalize an attachment.
This call updates a valid attachment record to associate with a volume
and provide the caller with the proper connection info.  Note that
this call requires an `attachment_ref`.  It\'s expected that prior to
this call that the volume and an attachment UUID has been reserved.
param: vref: Volume object to create attachment for
param: connector: Connector object to use for attachment creation
param: attachment_ref: ID of the attachment record to update'

def attachment_update(self, context, vref, connector, attachment_id):

    mode = connector.get('mode', 'rw')
    self._notify_about_volume_usage(context, vref, 'attach.start')
    attachment_ref = objects.VolumeAttachment.get_by_id(context, attachment_id)
    connection_info = self._connection_create(context, vref, attachment_ref, connector)
    volume_metadata = self.db.volume_admin_metadata_update(context.elevated(), attachment_ref.volume_id, {'attached_mode': mode}, False)
    try:
        if ((volume_metadata.get('readonly') == 'True') and (mode != 'ro')):
            raise exception.InvalidVolumeAttachMode(mode=mode, volume_id=vref.id)
        utils.require_driver_initialized(self.driver)
        self.driver.attach_volume(context, vref, attachment_ref.instance_uuid, connector.get('host', ''), connector.get('mountpoint', 'na'))
    except Exception as err:
        self.message_api.create(context, message_field.Action.UPDATE_ATTACHMENT, resource_uuid=vref.id, exception=err)
        with excutils.save_and_reraise_exception():
            self.db.volume_attachment_update(context, attachment_ref.id, {'attach_status': fields.VolumeAttachStatus.ERROR_ATTACHING})
    self.db.volume_attached(context.elevated(), attachment_ref.id, attachment_ref.instance_uuid, connector.get('host', ''), connector.get('mountpoint', 'na'), mode)
    vref.refresh()
    self._notify_about_volume_usage(context, vref, 'attach.end')
    LOG.info('Attach    volume    completed    successfully.', resource=vref)
    attachment_ref = objects.VolumeAttachment.get_by_id(context, attachment_id)
    return connection_info
