'Create a volume from a snapshot.'

def create_volume_from_snapshot(self, volume, snapshot):

    LOG.debug('in    create_volume_from_snapshot')
    LOG.debug('volume:    %s', volume.__dict__)
    LOG.debug('snapshot:    %s', snapshot.__dict__)
    snap_metadata = snapshot['metadata']
    if ('snapshot_id' not in snap_metadata):
        LOG.debug('Metadata    of    the    snapshot    is    invalid')
        msg = _('Metadata    of    the    snapshot    is    invalid')
        raise exception.VolumeDriverException(message=msg)
    LOG.debug('snapshot_id:    %s', snap_metadata['snapshot_id'])
    snapshot_id = snap_metadata['snapshot_id']
    create_lun_name = self._gen_lun_name()
    self.api_executor.clone_snapshot(snapshot_id, create_lun_name)
    max_wait_sec = 600
    try_times = 0
    lun_naa = ''
    while True:
        created_lun = self.api_executor.get_lun_info(LUNName=create_lun_name)
        if (created_lun.find('LUNNAA') is not None):
            lun_naa = created_lun.find('LUNNAA').text
        try_times = (try_times + 3)
        eventlet.sleep(self.TIME_INTERVAL)
        if ((try_times > max_wait_sec) or (lun_naa is not None)):
            break
    if (volume['size'] > snapshot['volume_size']):
        self._extend_lun(volume, lun_naa)
    _metadata = self._get_volume_metadata(volume)
    _metadata['LUNNAA'] = lun_naa
    _metadata['LunName'] = create_lun_name
    return {'metadata': _metadata}
