'Setup - create multiple elements.
Project, initiators, initiatorgroup, target and targetgroup.'

def do_setup(self, context):

    lcfg = self.configuration
    LOG.info('Connecting    to    host:    %s.', lcfg.san_ip)
    self.zfssa = factory_zfssa()
    self.tgt_zfssa = factory_zfssa()
    self.zfssa.set_host(lcfg.san_ip, timeout=lcfg.zfssa_rest_timeout)
    auth_str = ('%s:%s' % (lcfg.san_login, lcfg.san_password))
    auth_str = base64.encode_as_text(auth_str)
    self.zfssa.login(auth_str)
    self.zfssa.create_project(lcfg.zfssa_pool, lcfg.zfssa_project, compression=lcfg.zfssa_lun_compression, logbias=lcfg.zfssa_lun_logbias)
    schemas = [{'property': 'cinder_managed', 'description': 'Managed    by    Cinder', 'type': 'Boolean'}]
    if lcfg.zfssa_enable_local_cache:
        self.zfssa.create_project(lcfg.zfssa_pool, lcfg.zfssa_cache_project, compression=lcfg.zfssa_lun_compression, logbias=lcfg.zfssa_lun_logbias)
        schemas.extend([{'property': 'image_id', 'description': 'OpenStack    image    ID', 'type': 'String'}, {'property': 'updated_at', 'description': 'Most    recent    updated    time    of    image', 'type': 'String'}])
    self.zfssa.create_schemas(schemas)
    if (lcfg.zfssa_initiator_config != ''):
        initiator_config = ast.literal_eval(lcfg.zfssa_initiator_config)
        for initiator_group in initiator_config:
            zfssa_initiator_group = initiator_group
            for zfssa_initiator in initiator_config[zfssa_initiator_group]:
                self.zfssa.create_initiator(zfssa_initiator['iqn'], ((zfssa_initiator_group + '-') + zfssa_initiator['iqn']), chapuser=zfssa_initiator['user'], chapsecret=zfssa_initiator['password'])
                if (zfssa_initiator_group != 'default'):
                    self.zfssa.add_to_initiatorgroup(zfssa_initiator['iqn'], zfssa_initiator_group)
    else:
        LOG.warning('zfssa_initiator_config    not    found.    Using    deprecated    configuration    options.')
        if (not lcfg.zfssa_initiator_group):
            LOG.error('zfssa_initiator_group    cannot    be    empty.    Explicitly    set    the    value    "default"    to    use    the    default    initiator    group.')
            raise exception.InvalidConfigurationValue(value='', option='zfssa_initiator_group')
        if ((not lcfg.zfssa_initiator) and (lcfg.zfssa_initiator_group != 'default')):
            LOG.error('zfssa_initiator    cannot    be    empty    when    creating    a    zfssa_initiator_group.')
            raise exception.InvalidConfigurationValue(value='', option='zfssa_initiator')
        if (lcfg.zfssa_initiator != ''):
            if (lcfg.zfssa_initiator_group == 'default'):
                LOG.warning('zfssa_initiator:    %(ini)s    wont    be    used    on    zfssa_initiator_group=    %(inigrp)s.', {'ini': lcfg.zfssa_initiator, 'inigrp': lcfg.zfssa_initiator_group})
            else:
                for initiator in lcfg.zfssa_initiator.split(','):
                    initiator = initiator.strip()
                    self.zfssa.create_initiator(initiator, ((lcfg.zfssa_initiator_group + '-') + initiator), chapuser=lcfg.zfssa_initiator_user, chapsecret=lcfg.zfssa_initiator_password)
                    self.zfssa.add_to_initiatorgroup(initiator, lcfg.zfssa_initiator_group)
    interfaces = []
    for intrface in lcfg.zfssa_target_interfaces.split(','):
        if (intrface == ''):
            continue
        interfaces.append(intrface)
    iqn = self.zfssa.create_target(self._get_target_alias(), interfaces, tchapuser=lcfg.zfssa_target_user, tchapsecret=lcfg.zfssa_target_password)
    self.zfssa.add_to_targetgroup(iqn, lcfg.zfssa_target_group)
    if (lcfg.zfssa_manage_policy not in ('loose', 'strict')):
        err_msg = (_("zfssa_manage_policy    property    needs    to    be    set    to    'strict'    or    'loose'.    Current    value    is:    %s.") % lcfg.zfssa_manage_policy)
        LOG.error(err_msg)
        raise exception.InvalidInput(reason=err_msg)
    (host, port) = lcfg.zfssa_target_portal.split(':')
    host_ip_addr = utils.resolve_hostname(host)
    self.zfssa_target_portal = ((host_ip_addr + ':') + port)
