def create_virtual(hostname, username, password, name, destination,
                   pool=None,
                   address_status=None,
                   auto_lasthop=None,
                   bwc_policy=None,
                   cmp_enabled=None,
                   connection_limit=None,
                   dhcp_relay=None,
                   description=None,
                   fallback_persistence=None,
                   flow_eviction_policy=None,
                   gtm_score=None,
                   ip_forward=None,
                   ip_protocol=None,
                   internal=None,
                   twelve_forward=None,
                   last_hop_pool=None,
                   mask=None,
                   mirror=None,
                   nat64=None,
                   persist=None,
                   profiles=None,
                   policies=None,
                   rate_class=None,
                   rate_limit=None,
                   rate_limit_mode=None,
                   rate_limit_dst=None,
                   rate_limit_src=None,
                   rules=None,
                   related_rules=None,
                   reject=None,
                   source=None,
                   source_address_translation=None,
                   source_port=None,
                   virtual_state=None,
                   traffic_classes=None,
                   translate_address=None,
                   translate_port=None,
                   vlans=None):

    ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''}

    if __opts__['test']:
        return _test_output(ret, 'create', params={
            'hostname': hostname,
            'username': username,
            'password': password,
            'name': name,
            'destination': destination,
            'pool': pool,
            'address_status': address_status,
            'auto_lasthop': auto_lasthop,
            'bwc_policy': bwc_policy,
            'cmp_enabled': cmp_enabled,
            'connection_limit': connection_limit,
            'dhcp_relay': dhcp_relay,
            'description': description,
            'fallback_persistence': fallback_persistence,
            'flow_eviction_policy': flow_eviction_policy,
            'gtm_score': gtm_score,
            'ip_forward': ip_forward,
            'ip_protocol': ip_protocol,
            'internal': internal,
            'twelve_forward': twelve_forward,
            'last_hop_pool': last_hop_pool,
            'mask': mask,
            'mirror': mirror,
            'nat64': nat64,
            'persist': persist,
            'profiles': profiles,
            'policies': policies,
            'rate_class': rate_class,
            'rate_limit': rate_limit,
            'rate_limit_mode': rate_limit_mode,
            'rate_limit_dst': rate_limit_dst,
            'rate_limit_src': rate_limit_src,
            'rules': rules,
            'related_rules': related_rules,
            'reject': reject,
            'source': source,
            'source_address_translation': source_address_translation,
            'source_port': source_port,
            'virtual_state': virtual_state,
            'traffic_classes': traffic_classes,
            'translate_address': translate_address,
            'translate_port': translate_port,
            'vlans': vlans
        }
        )

    existing = __salt__['bigip.list_virtual'](hostname, username, password, name)

    # does this virtual exist?
    if existing['code'] == 200:

        ret['result'] = True
        ret['comment'] = 'A virtual by this name currently exists.  No change made.'

    elif existing['code'] == 404:

        #create it
        virtual = __salt__['bigip.create_virtual'](hostname=hostname,
                                                   username=username,
                                                   password=password,
                                                   name=name,
                                                   destination=destination,
                                                   description=description,
                                                   pool=pool,
                                                   address_status=address_status,
                                                   auto_lasthop=auto_lasthop,
                                                   bwc_policy=bwc_policy,
                                                   cmp_enabled=cmp_enabled,
                                                   connection_limit=connection_limit,
                                                   dhcp_relay=dhcp_relay,
                                                   fallback_persistence=fallback_persistence,
                                                   flow_eviction_policy=flow_eviction_policy,
                                                   gtm_score=gtm_score,
                                                   ip_forward=ip_forward,
                                                   ip_protocol=ip_protocol,
                                                   internal=internal,
                                                   twelve_forward=twelve_forward,
                                                   last_hop_pool=last_hop_pool,
                                                   mask=mask,
                                                   mirror=mirror,
                                                   nat64=nat64,
                                                   persist=persist,
                                                   profiles=profiles,
                                                   policies=policies,
                                                   rate_class=rate_class,
                                                   rate_limit=rate_limit,
                                                   rate_limit_mode=rate_limit_mode,
                                                   rate_limit_dst=rate_limit_dst,
                                                   rate_limit_src=rate_limit_src,
                                                   rules=rules,
                                                   related_rules=related_rules,
                                                   reject=reject,
                                                   source=source,
                                                   source_address_translation=source_address_translation,
                                                   source_port=source_port,
                                                   state=virtual_state,
                                                   traffic_classes=traffic_classes,
                                                   translate_address=translate_address,
                                                   translate_port=translate_port,
                                                   vlans=vlans)
        if virtual['code'] == 200:
            ret['result'] = True
            ret['changes']['old'] = {}
            ret['changes']['new'] = virtual['content']
            ret['comment'] = 'Virtual was successfully created.'
        else:
            ret = _load_result(existing, ret)

    # else something else was returned
    else:
        ret = _load_result(existing, ret)

    return ret
A function to connect to a bigip device and create a virtual server if it does not already exists.
dataset/ETHPy150Open saltstack/salt/salt/states/bigip.py/create_virtual