<commit_before>#
# Copyright (c) 2014 Juniper Networks, Inc. All rights reserved.
#
from loadbalancer_db import LoadBalancerPluginDb

try:
    from neutron.extensions import loadbalancer
except ImportError:
    from neutron_lbaas.extensions import loadbalancer
from neutron.db import servicetype_db as sdb
from neutron.plugins.common import constants
from neutron.services import provider_configuration as pconf


class LoadBalancerPlugin(LoadBalancerPluginDb):
    supported_extension_aliases = ["lbaas", "extra_lbaas_opts"]

    if hasattr(loadbalancer, 'LOADBALANCER_PREFIX'):
        path_prefix = loadbalancer.LOADBALANCER_PREFIX

    def __init__(self):
        super(LoadBalancerPlugin, self).__init__()
        self._get_default_provider()

    def _get_default_provider(self):
        service_type_manager = sdb.ServiceTypeManager.get_instance()
        try:
            provider = (service_type_manager.
                        get_default_service_provider(None,
                                                     constants.LOADBALANCER))
        except pconf.DefaultServiceProviderNotFound:
            self.default_provider = "opencontrail"
        else:
            self._pool_manager.check_provider_exists(provider['name'])
            self.default_provider = provider['name']

    def get_plugin_description(self):
        return "OpenContrail LoadBalancer Service Plugin"

    def _pool_update_provider(self, context, pool):
        if 'provider' not in pool or not pool['provider'] or pool['provider'].__class__ is object:
            pool['provider'] = self.default_provider

    def create_pool(self, context, pool):
        self._pool_update_provider(context, pool['pool'])
        return super(LoadBalancerPlugin, self).create_pool(context, pool)<commit_msg>exception is not handled in the check_provider_exists()<commit_after>#
# Copyright (c) 2014 Juniper Networks, Inc. All rights reserved.
#
from loadbalancer_db import LoadBalancerPluginDb

try:
    from neutron.extensions import loadbalancer
except ImportError:
    from neutron_lbaas.extensions import loadbalancer
from neutron.db import servicetype_db as sdb
from neutron.plugins.common import constants
from neutron.services import provider_configuration as pconf


class LoadBalancerPlugin(LoadBalancerPluginDb):
    supported_extension_aliases = ["lbaas", "extra_lbaas_opts"]

    if hasattr(loadbalancer, 'LOADBALANCER_PREFIX'):
        path_prefix = loadbalancer.LOADBALANCER_PREFIX

    def __init__(self):
        super(LoadBalancerPlugin, self).__init__()
        self._get_default_provider()

    def _get_default_provider(self):
        self.default_provider = "opencontrail"
        try:
            service_type_manager = sdb.ServiceTypeManager.get_instance()
            provider = (service_type_manager.
                        get_default_service_provider(None,
                                                     constants.LOADBALANCER))
            self._pool_manager.check_provider_exists(provider['name'])
            self.default_provider = provider['name']
        except:
            pass

    def get_plugin_description(self):
        return "OpenContrail LoadBalancer Service Plugin"

    def _pool_update_provider(self, context, pool):
        if 'provider' not in pool or not pool['provider'] or pool['provider'].__class__ is object:
            pool['provider'] = self.default_provider

    def create_pool(self, context, pool):
        self._pool_update_provider(context, pool['pool'])
        return super(LoadBalancerPlugin, self).create_pool(context, pool)
{'fraction_non_alphanumeric': 0.0761904761904762, 'fraction_numerical': 0.002240896358543417, 'mean_word_length': 3.307599517490953, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2561552', 'n_tokens_mistral': 986, 'n_tokens_neox': 928, 'n_words': 220}