'The function creates network resources in the given tenant.
The function checks if network_resources class member is empty,
In case it is, it will create a network, a subnet and a router for
the tenant according to the given tenant id parameter.
Otherwise it will create a network resource according
to the values from network_resources dict.
:param tenant_id: The tenant id to create resources for.
:type tenant_id: str
:raises: InvalidConfiguration, Exception
:returns: network resources(network,subnet,router)
:rtype: tuple'

def _create_network_resources(self, tenant_id):

    network = None
    subnet = None
    router = None
    if self.network_resources:
        if self.network_resources['router']:
            if ((not self.network_resources['subnet']) or (not self.network_resources['network'])):
                raise lib_exc.InvalidConfiguration('A    router    requires    a    subnet    and    network')
        elif self.network_resources['subnet']:
            if (not self.network_resources['network']):
                raise lib_exc.InvalidConfiguration('A    subnet    requires    a    network')
        elif self.network_resources['dhcp']:
            raise lib_exc.InvalidConfiguration('DHCP    requires    a    subnet')
    rand_name_root = data_utils.rand_name(self.name, prefix=self.resource_prefix)
    if ((not self.network_resources) or self.network_resources['network']):
        network_name = (rand_name_root + '-network')
        network = self._create_network(network_name, tenant_id)
    try:
        if ((not self.network_resources) or self.network_resources['subnet']):
            subnet_name = (rand_name_root + '-subnet')
            subnet = self._create_subnet(subnet_name, tenant_id, network['id'])
        if ((not self.network_resources) or self.network_resources['router']):
            router_name = (rand_name_root + '-router')
            router = self._create_router(router_name, tenant_id)
            self._add_router_interface(router['id'], subnet['id'])
    except Exception:
        try:
            if router:
                self._clear_isolated_router(router['id'], router['name'])
            if subnet:
                self._clear_isolated_subnet(subnet['id'], subnet['name'])
            if network:
                self._clear_isolated_network(network['id'], network['name'])
        except Exception as cleanup_exception:
            msg = 'There    was    an    exception    trying    to    setup    network    resources    for    tenant    %s,    and    this    error    happened    trying    to    clean    them    up:    %s'
            LOG.warning(msg, tenant_id, cleanup_exception)
        raise
    return (network, subnet, router)
