<commit_before># Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.


import netaddr
import netaddr.core as netexc
from oslo.config import cfg
import six
import webob
from webob import exc

from nova.api.openstack import extensions
from nova import context as nova_context
from nova import exception
from nova.i18n import _
from nova.i18n import _LE
from nova.i18n import _LI
import nova.network
from nova.openstack.common import log as logging
from nova import quota


CONF = cfg.CONF

try:
    os_network_opts = [
        cfg.BoolOpt("enable_network_quota",
                    default=False,
                    help=('Enables or disables quota checking for tenant '
                          'networks')),
        cfg.StrOpt('use_neutron_default_nets',
                         default="False",
                         help=('Control for checking for default networks')),
        cfg.StrOpt('neutron_default_tenant_id',
                         default="default",
                         help=('Default tenant id when creating neutron '
                               'networks'))
    ]
    CONF.register_opts(os_network_opts)
except cfg.DuplicateOptError:
    # NOTE(jkoelker) These options are verbatim elsewhere this is here
    #                to make sure they are registered for our use.
    pass

if CONF.enable_network_quota:
    opts = [
        cfg.IntOpt('quota_networks',
                   default=3,
                   help='Number of private networks allowed per project'),
        ]
    CONF.register_opts(opts)

QUOTAS = quota.QUOTAS
LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer('compute', 'os-tenant-networks')


def network_dict(network):
    return {"id": network.get("uuid") or network.get("id"),
                        "cidr": str(network.get("cidr")),
                        "label": network.get("label")}


class NetworkController(object):
    def __init__(self, network_api=None):
        self.network_api = nova.network.API()
        self._default_networks = []

    def _refresh_default_networks(self):
        self._default_networks = []
        if CONF.use_neutron_default_nets == "True":
            try:<commit_msg>Cleanup tenant networks plugin config creation<commit_after># Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.


import netaddr
import netaddr.core as netexc
from oslo.config import cfg
import six
import webob
from webob import exc

from nova.api.openstack import extensions
from nova import context as nova_context
from nova import exception
from nova.i18n import _
from nova.i18n import _LE
from nova.i18n import _LI
import nova.network
from nova.openstack.common import log as logging
from nova import quota


CONF = cfg.CONF

os_network_opts = [
    cfg.BoolOpt("enable_network_quota",
                default=False,
                help=('Enables or disables quota checking for tenant '
                      'networks')),
    cfg.StrOpt('use_neutron_default_nets',
                     default="False",
                     help=('Control for checking for default networks')),
    cfg.StrOpt('neutron_default_tenant_id',
                     default="default",
                     help=('Default tenant id when creating neutron '
                           'networks')),
    cfg.IntOpt('quota_networks',
               default=3,
               help='Number of private networks allowed per project'),
]
CONF.register_opts(os_network_opts)

QUOTAS = quota.QUOTAS
LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer('compute', 'os-tenant-networks')


def network_dict(network):
    return {"id": network.get("uuid") or network.get("id"),
                        "cidr": str(network.get("cidr")),
                        "label": network.get("label")}


class NetworkController(object):
    def __init__(self, network_api=None):
        self.network_api = nova.network.API()
        self._default_networks = []

    def _refresh_default_networks(self):
        self._default_networks = []
        if CONF.use_neutron_default_nets == "True":
            try:
{'fraction_non_alphanumeric': 0.08261782102652165, 'fraction_numerical': 0.005724098454493417, 'mean_word_length': 2.632709632709633, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7555168', 'n_tokens_mistral': 1452, 'n_tokens_neox': 1404, 'n_words': 458}