'Create clone worker function'

def _create_clone(self, volume, clone, clone_type):

    volume_name = ''
    if (clone_type == 'snapshot'):
        volume_name = volume['volume_name']
    elif (clone_type == 'clone'):
        volume_name = volume['name']
    args = {}
    args['name'] = volume_name
    args['status_string'] = OPERATIONAL_STATUS
    retries = self.configuration.ise_completion_retries
    vol_info = self._wait_for_completion(self._help_wait_for_status, args, retries)
    if (vol_info['value'] == '0'):
        LOG.debug('Source    volume    %s    ready.', volume_name)
    else:
        LOG.error('Source    volume    %s    not    ready!', volume_name)
        RaiseXIODriverException()
    ctxt = context.get_admin_context()
    type_id = volume['volume_type_id']
    extra_specs = self._get_extra_specs(ctxt, type_id)
    LOG.debug('Volume    %(volume_name)s    extra_specs    %(extra_specs)s', {'volume_name': volume['name'], 'extra_specs': extra_specs})
    qos = self._get_qos_specs(ctxt, type_id)
    args['method'] = 'POST'
    args['url'] = vol_info['location']
    args['status'] = 202
    args['arglist'] = {'name': clone['name'], 'type': clone_type, 'affinity': extra_specs['affinity'], 'IOPSmin': qos['minIOPS'], 'IOPSmax': qos['maxIOPS'], 'IOPSburst': qos['burstIOPS']}
    retries = self.configuration.ise_completion_retries
    resp = self._wait_for_completion(self._help_call_method, args, retries)
    if (resp['status'] != 202):
        LOG.error('Prepare    clone    failed    for    %s.', clone['name'])
        RaiseXIODriverException()
    args['name'] = clone['name']
    args['status_string'] = PREPARED_STATUS
    retries = self.configuration.ise_completion_retries
    clone_info = self._wait_for_completion(self._help_wait_for_status, args, retries)
    if (PREPARED_STATUS in clone_info['details']):
        LOG.debug('Clone    %s    prepared.', clone['name'])
    else:
        LOG.error('Clone    %s    not    in    prepared    state!', clone['name'])
        RaiseXIODriverException()
    resp = self._send_cmd('PUT', clone_info['location'], {clone_type: 'true'})
    if (resp['status'] != 201):
        LOG.error('Commit    clone    failed:    %(name)s    (%(status)d)!', {'name': clone['name'], 'status': resp['status']})
        RaiseXIODriverException()
    args['name'] = clone['name']
    args['status_string'] = OPERATIONAL_STATUS
    retries = self.configuration.ise_completion_retries
    clone_info = self._wait_for_completion(self._help_wait_for_status, args, retries)
    if (OPERATIONAL_STATUS in clone_info['string']):
        LOG.info('Clone    %s    created.', clone['name'])
    else:
        LOG.error('Commit    failed    for    %s!', clone['name'])
        RaiseXIODriverException()
    return
