'Extend a volume.'

def extend_volume(self, volume, new_size):

    lun_id = self._check_volume_exist_on_array(volume, constants.VOLUME_NOT_EXISTS_RAISE)
    volume_type = self._get_volume_type(volume)
    opts = self._get_volume_params(volume_type)
    if (opts.get('replication_enabled') == 'true'):
        msg = (_("Can't    extend    replication    volume,    volume:    %(id)s") % {'id': volume.id})
        LOG.error(msg)
        raise exception.VolumeBackendAPIException(data=msg)
    lun_info = self.client.get_lun_info(lun_id)
    old_size = int(lun_info.get('CAPACITY'))
    new_size = ((int(new_size) * units.Gi) / 512)
    if (new_size == old_size):
        LOG.info('New    size    is    equal    to    the    real    size    from    backend    storage,    no    need    to    extend.    realsize:    %(oldsize)s,    newsize:    %(newsize)s.', {'oldsize': old_size, 'newsize': new_size})
        return
    if (new_size < old_size):
        msg = (_('New    size    should    be    bigger    than    the    real    size    from    backend    storage.    realsize:    %(oldsize)s,    newsize:    %(newsize)s.'), {'oldsize': old_size, 'newsize': new_size})
        LOG.error(msg)
        raise exception.VolumeBackendAPIException(data=msg)
    LOG.info('Extend    volume:    %(id)s,    oldsize:    %(oldsize)s,    newsize:    %(newsize)s.', {'id': volume.id, 'oldsize': old_size, 'newsize': new_size})
    self.client.extend_lun(lun_id, new_size)
