'Create a network. In November 2015, Google introduced Subnetworks and
suggests using networks with \'auto\' generated subnetworks. See, the
`subnet docs <https://cloud.google.com/compute/docs/subnetworks>`_ for
more details. Note that libcloud follows the usability pattern from
the Cloud SDK (e.g. \'gcloud compute\' command-line utility) and uses
\'mode\' to specify \'auto\', \'custom\', or \'legacy\'.
:param  name: Name of network to be created
:type   name: ``str``
:param  cidr: Address range of network in CIDR format.
:type   cidr: ``str`` or ``None``
:param  description: Custom description for the network.
:type   description: ``str`` or ``None``
:param  mode: Create a \'auto\', \'custom\', or \'legacy\' network.
:type   mode: ``str``
:return:  Network object
:rtype:   :class:`GCENetwork`'

def ex_create_network(self, name, cidr, description=None, mode='legacy'):

    network_data = {}
    network_data['name'] = name
    network_data['description'] = description
    if (mode.lower() not in ['auto', 'custom', 'legacy']):
        raise ValueError(("Invalid    network    mode:    '%s'.    Must    be    'auto',    'custom',    or    'legacy'." % mode))
    if (cidr and (mode in ['auto', 'custom'])):
        raise ValueError("Can    only    specify    IPv4Range    with    'legacy'    mode.")
    request = '/global/networks'
    if (mode == 'legacy'):
        if (not cidr):
            raise ValueError("Must    specify    IPv4Range    with    'legacy'    mode.")
        network_data['IPv4Range'] = cidr
    else:
        network_data['autoCreateSubnetworks'] = (mode.lower() == 'auto')
    self.connection.async_request(request, method='POST', data=network_data)
    return self.ex_get_network(name)
