<commit_before>import logging
import os.path
import ConfigParser
import monsetup.detection
import monsetup.agent_config

log = logging.getLogger(__name__)

# Location of nova.conf to read sql_connect string
nova_conf = "/etc/nova/nova.conf"
# Directory to use for instance and metric caches (preferred tmpfs "/dev/shm")
cache_dir = "/dev/shm"
# Maximum age of instance cache before automatic refresh (in seconds)
nova_refresh = 60 * 60 * 4  # Four hours
# Probation period before metrics are gathered for a VM (in seconds)
vm_probation = 60 * 5  # Five minutes


class Libvirt(monsetup.detection.Plugin):
    """Configures VM monitoring through Nova"""

    def _detect(self):
        """Run detection, set self.available True if the service is detected.
        """
        if (monsetup.detection.find_process_name('nova-api') is not None and
           os.path.isfile(nova_conf)):
            self.available = True

    def build_config(self):
        """Build the config as a Plugins object and return back.
        """
        config = monsetup.agent_config.Plugins()

        if self.dependencies_installed():
            nova_cfg = ConfigParser.SafeConfigParser()
            nova_cfg.read(nova_conf)
            sql_conn = nova_cfg.get('DEFAULT', 'sql_connection')
            # Which configuration options are needed for the plugin YAML?
            cfg_needed = ['admin_user', 'admin_password',
                          'admin_tenant_name', 'identity_uri']
            cfg_section = 'keystone_authtoken'

            # Start with plugin-specific configuration parameters
            init_config = {'cache_dir': cache_dir,
                           'nova_refresh': nova_refresh,
                           'vm_probation': vm_probation}

            for option in cfg_needed:
                init_config[option] = nova_cfg.get(cfg_section, option)

            # Add version to identity_uri
            init_config['identity_uri'] += '/v2.0'

            config['libvirt'] = {'init_config': init_config,<commit_msg>Remove obsolete config options in libvirt plugin<commit_after>import logging
import os.path
import ConfigParser
import monsetup.detection
import monsetup.agent_config

log = logging.getLogger(__name__)

# Location of nova.conf from which to read credentials
nova_conf = "/etc/nova/nova.conf"
# Directory to use for instance and metric caches (preferred tmpfs "/dev/shm")
cache_dir = "/dev/shm"
# Maximum age of instance cache before automatic refresh (in seconds)
nova_refresh = 60 * 60 * 4  # Four hours
# Probation period before metrics are gathered for a VM (in seconds)
vm_probation = 60 * 5  # Five minutes


class Libvirt(monsetup.detection.Plugin):
    """Configures VM monitoring through Nova"""

    def _detect(self):
        """Run detection, set self.available True if the service is detected.
        """
        if (monsetup.detection.find_process_name('nova-api') is not None and
           os.path.isfile(nova_conf)):
            self.available = True

    def build_config(self):
        """Build the config as a Plugins object and return back.
        """
        config = monsetup.agent_config.Plugins()

        if self.dependencies_installed():
            nova_cfg = ConfigParser.SafeConfigParser()
            nova_cfg.read(nova_conf)
            # Which configuration options are needed for the plugin YAML?
            cfg_needed = ['admin_user', 'admin_password',
                          'admin_tenant_name']
            cfg_section = 'keystone_authtoken'

            # Start with plugin-specific configuration parameters
            init_config = {'cache_dir': cache_dir,
                           'nova_refresh': nova_refresh,
                           'vm_probation': vm_probation}

            for option in cfg_needed:
                init_config[option] = nova_cfg.get(cfg_section, option)

            # Create an identity server URI
            init_config['identity_uri'] = "{}://{}:{}/v3".format(nova_cfg.get(cfg_section, 'auth_protocol'),
                                                                 nova_cfg.get(cfg_section, 'auth_host'),
                                                                 nova_cfg.get(cfg_section, 'auth_port'))

            config['libvirt'] = {'init_config': init_config,
{'fraction_non_alphanumeric': 0.08956969130028064, 'fraction_numerical': 0.004443405051449953, 'mean_word_length': 2.386381631037213, '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': '4905703', 'n_tokens_mistral': 1189, 'n_tokens_neox': 1141, 'n_words': 328}