... versionchanged:: 2017.7.0
    Create a GCE network. Must specify name and cidr.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f create_network gce name=mynet cidr=10.10.10.0/24 mode=legacy description=optional
        salt-cloud -f create_network gce name=mynet description=optional

def create_network(kwargs=None, call=None):
    '''
    ... versionchanged:: 2017.7.0
    Create a GCE network. Must specify name and cidr.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f create_network gce name=mynet cidr=10.10.10.0/24 mode=legacy description=optional
        salt-cloud -f create_network gce name=mynet description=optional
    '''
    if call != 'function':
        raise SaltCloudSystemExit(
            'The create_network function must be called with -f or --function.'
        )

    if not kwargs or 'name' not in kwargs:
        log.error(
            'A name must be specified when creating a network.'
        )
        return False

    mode = kwargs.get('mode', 'legacy')
    cidr = kwargs.get('cidr', None)
    if cidr is None and mode == 'legacy':
        log.error(
            'A network CIDR range must be specified when creating a legacy network.'
        )
        return False

    name = kwargs['name']
    desc = kwargs.get('description', None)
    conn = get_conn()

    __utils__['cloud.fire_event'](
        'event',
        'creating network',
        'salt/cloud/net/creating',
        args={
            'name': name,
            'cidr': cidr,
            'description': desc,
            'mode': mode
        },
        sock_dir=__opts__['sock_dir'],
        transport=__opts__['transport']
    )

    network = conn.ex_create_network(name, cidr, desc, mode)

    __utils__['cloud.fire_event'](
        'event',
        'created network',
        'salt/cloud/net/created',
        args={
            'name': name,
            'cidr': cidr,
            'description': desc,
            'mode': mode
        },
        sock_dir=__opts__['sock_dir'],
        transport=__opts__['transport']
    )
    return _expand_item(network)