<commit_before>from charmhelpers.core.hookenv import config, unit_get, log

from charmhelpers.core.host import mkdir, write_file

from charmhelpers.contrib.openstack import context

from charmhelpers.contrib.hahelpers.cluster import (
    determine_apache_port,
    determine_api_port,
    is_clustered
)

from charmhelpers.contrib.hahelpers.apache import install_ca_cert

from charmhelpers.contrib.network.ip import (
    get_address_in_network, is_address_in_network)

import os

CA_CERT_PATH = '/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt'


class ApacheSSLContext(context.ApacheSSLContext):

    interfaces = ['https']
    external_ports = []
    service_namespace = 'keystone'

    def __call__(self):
        # late import to work around circular dependency
        from keystone_utils import determine_ports
        self.external_ports = determine_ports()
        return super(ApacheSSLContext, self).__call__()

    def configure_cert(self, cn):
        from keystone_utils import SSH_USER, get_ca
        ssl_dir = os.path.join('/etc/apache2/ssl/', self.service_namespace)
        mkdir(path=ssl_dir)
        ca = get_ca(user=SSH_USER)
        cert, key = ca.get_cert_and_key(common_name=cn)
        write_file(path=os.path.join(ssl_dir, 'cert_{}'.format(cn)),
                   content=cert)
        write_file(path=os.path.join(ssl_dir, 'key_{}'.format(cn)),
                   content=key)

    def configure_ca(self):
        from keystone_utils import SSH_USER, get_ca
        ca = get_ca(user=SSH_USER)
        install_ca_cert(ca.get_ca_bundle())

    def canonical_names(self):
        print "canonical"
        addresses = []
        vips = []
        if config('vip'):
            vips = config('vip').split()
        for network_type in ['os-internal-network',
                             'os-admin-network',
                             'os-public-network']:
            address = get_address_in_network(config(network_type),
                                             unit_get('private-address'))
            print "lenvip:%s" % len(vips)
            print is_clustered()
            if len(vips) > 1 and is_clustered():
                if not config(network_type):
                    log("Multinet is used, but network_type (%s) is None."
                        % network_type, level='WARNING')
                    continue<commit_msg>Remove debug info.<commit_after>from charmhelpers.core.hookenv import config, unit_get, log

from charmhelpers.core.host import mkdir, write_file

from charmhelpers.contrib.openstack import context

from charmhelpers.contrib.hahelpers.cluster import (
    determine_apache_port,
    determine_api_port,
    is_clustered
)

from charmhelpers.contrib.hahelpers.apache import install_ca_cert

from charmhelpers.contrib.network.ip import (
    get_address_in_network,
    is_address_in_network)

import os

CA_CERT_PATH = '/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt'


class ApacheSSLContext(context.ApacheSSLContext):

    interfaces = ['https']
    external_ports = []
    service_namespace = 'keystone'

    def __call__(self):
        # late import to work around circular dependency
        from keystone_utils import determine_ports
        self.external_ports = determine_ports()
        return super(ApacheSSLContext, self).__call__()

    def configure_cert(self, cn):
        from keystone_utils import SSH_USER, get_ca
        ssl_dir = os.path.join('/etc/apache2/ssl/', self.service_namespace)
        mkdir(path=ssl_dir)
        ca = get_ca(user=SSH_USER)
        cert, key = ca.get_cert_and_key(common_name=cn)
        write_file(path=os.path.join(ssl_dir, 'cert_{}'.format(cn)),
                   content=cert)
        write_file(path=os.path.join(ssl_dir, 'key_{}'.format(cn)),
                   content=key)

    def configure_ca(self):
        from keystone_utils import SSH_USER, get_ca
        ca = get_ca(user=SSH_USER)
        install_ca_cert(ca.get_ca_bundle())

    def canonical_names(self):
        addresses = []
        vips = []
        if config('vip'):
            vips = config('vip').split()
        for network_type in ['os-internal-network',
                             'os-admin-network',
                             'os-public-network']:
            address = get_address_in_network(config(network_type),
                                             unit_get('private-address'))
            if len(vips) > 1 and is_clustered():
                if not config(network_type):
                    log("Multinet is used, but network_type (%s) is None."
                        % network_type, level='WARNING')
                    continue
{'fraction_non_alphanumeric': 0.09605488850771869, 'fraction_numerical': 0.0008576329331046312, 'mean_word_length': 2.4251101321585904, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2727680', 'n_tokens_mistral': 1397, 'n_tokens_neox': 1371, 'n_words': 264}