<commit_before>import logging
from time import sleep
from ipaddr import IPNetwork

import os
from fuel_test.ci.ci_base import CiBase
from fuel_test.helpers import add_nmap
from fuel_test.node_roles import NodeRoles
from fuel_test.settings import CONTROLLERS, COMPUTES, \
    STORAGES, PROXIES, \
    EMPTY_SNAPSHOT, POOLS, INTERFACE_ORDER, ROUTED_INTERFACE, ISO


class CiVM(CiBase):
    def define(self):
        self._environment.define()

    def __init__(self):
        super(CiVM, self).__init__()

    def node_roles(self):
        return NodeRoles(
            master_names=['master'],
            controller_names=['fuel-controller-%02d' % x for x in
                              range(1, 1 + CONTROLLERS)],
            compute_names=['fuel-compute-%02d' % x for x in range(
                1, 1 + COMPUTES)],
            storage_names=['fuel-swift-%02d' % x for x in range(
                1, 1 + STORAGES)],
            proxy_names=['fuel-swiftproxy-%02d' % x for x in range(
                1, 1 + PROXIES)],
            quantum_names=['fuel-quantum'],
        )

    def env_name(self):
        return os.environ.get('ENV_NAME', 'cobbler')

    def describe_environment(self):
        """
        :rtype : Environment
        """
        environment = self.manager.environment_create(self.env_name())
        networks = []
        for name in INTERFACE_ORDER:
            ip_networks = [ IPNetwork(x) for x in POOLS.get(name)[0].split(',')]
            new_prefix = int(POOLS.get(name)[1])
            pool = self.manager.create_network_pool(
                networks=ip_networks, prefix=int(new_prefix))
            networks.append(self.manager.network_create(
                name=name, environment=environment, pool=pool,
                forward='route' if name==ROUTED_INTERFACE else 'nat'))
        for name in self.node_roles().master_names:
            self.describe_master_node(name, networks)
        for name in self.node_roles().compute_names:
            self.describe_empty_node(name, networks, memory=2048)
        for name in self.node_roles().controller_names + self.node_roles().storage_names + self.node_roles().quantum_names + self.node_roles().proxy_names:
            self.describe_empty_node(name, networks)
        return environment

    def get_startup_nodes(self):
        return self.nodes().masters

    def client_nodes(self):
        return self.nodes().controllers + self.nodes().computes + self.nodes().storages + self.nodes().proxies + self.nodes().quantums

    def setup_environment(self):
        master_node = self.nodes().masters[0]
        logging.info("Starting test nodes ...")
        start_nodes = self.get_startup_nodes()
        self.environment().start(start_nodes)
        for node in start_nodes:
            node.await('public', timeout=300)

        master_remote = master_node.remote('public', login='root',
                                            password='<PASSWORD>')
        add_nmap(master_remote)
        self.environment().snapshot(EMPTY_SNAPSHOT)<commit_msg>Increase timeout<commit_after>import logging
from time import sleep
from ipaddr import IPNetwork

import os
from fuel_test.ci.ci_base import CiBase
from fuel_test.helpers import add_nmap
from fuel_test.node_roles import NodeRoles
from fuel_test.settings import CONTROLLERS, COMPUTES, \
    STORAGES, PROXIES, \
    EMPTY_SNAPSHOT, POOLS, INTERFACE_ORDER, ROUTED_INTERFACE, ISO


class CiVM(CiBase):
    def define(self):
        self._environment.define()

    def __init__(self):
        super(CiVM, self).__init__()

    def node_roles(self):
        return NodeRoles(
            master_names=['master'],
            controller_names=['fuel-controller-%02d' % x for x in
                              range(1, 1 + CONTROLLERS)],
            compute_names=['fuel-compute-%02d' % x for x in range(
                1, 1 + COMPUTES)],
            storage_names=['fuel-swift-%02d' % x for x in range(
                1, 1 + STORAGES)],
            proxy_names=['fuel-swiftproxy-%02d' % x for x in range(
                1, 1 + PROXIES)],
            quantum_names=['fuel-quantum'],
        )

    def env_name(self):
        return os.environ.get('ENV_NAME', 'cobbler')

    def describe_environment(self):
        """
        :rtype : Environment
        """
        environment = self.manager.environment_create(self.env_name())
        networks = []
        for name in INTERFACE_ORDER:
            ip_networks = [ IPNetwork(x) for x in POOLS.get(name)[0].split(',')]
            new_prefix = int(POOLS.get(name)[1])
            pool = self.manager.create_network_pool(
                networks=ip_networks, prefix=int(new_prefix))
            networks.append(self.manager.network_create(
                name=name, environment=environment, pool=pool,
                forward='route' if name==ROUTED_INTERFACE else 'nat'))
        for name in self.node_roles().master_names:
            self.describe_master_node(name, networks)
        for name in self.node_roles().compute_names:
            self.describe_empty_node(name, networks, memory=2048)
        for name in self.node_roles().controller_names + self.node_roles().storage_names + self.node_roles().quantum_names + self.node_roles().proxy_names:
            self.describe_empty_node(name, networks)
        return environment

    def get_startup_nodes(self):
        return self.nodes().masters

    def client_nodes(self):
        return self.nodes().controllers + self.nodes().computes + self.nodes().storages + self.nodes().proxies + self.nodes().quantums

    def setup_environment(self):
        master_node = self.nodes().masters[0]
        logging.info("Starting test nodes ...")
        start_nodes = self.get_startup_nodes()
        self.environment().start(start_nodes)
        for node in start_nodes:
            node.await('public', timeout=600)

        master_remote = master_node.remote('public', login='root',
                                            password='<PASSWORD>')
        add_nmap(master_remote)
        self.environment().snapshot(EMPTY_SNAPSHOT)
{'fraction_non_alphanumeric': 0.11134903640256959, 'fraction_numerical': 0.008565310492505354, 'mean_word_length': 2.473684210526316, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7518534', 'n_tokens_mistral': 1864, 'n_tokens_neox': 1779, 'n_words': 362}