Example #1
0
 def _configure_lua_file(self):
     """
     Configure the packet gen to write the results into the right file
     :return: None
     """
     common.replace_in_file(self.lua_file, 'local out_file = ""',
                            'local out_file = "' + self.results_file + '"')
 def finalize(self):
     common.replace_in_file(self.lua_file, 'local out_file = "' +
                            self.results_file + '"', 'local out_file = ""')
     # destroy neighbor stacks
     for stack_name in self.neighbor_stack_names:
         common.DEPLOYMENT_UNIT.destroy_heat_template(stack_name)
     self.neighbor_stack_names = list()
 def finalize(self):
     common.replace_in_file(self.lua_file,
                            'local out_file = "' + self.results_file + '"',
                            'local out_file = ""')
     # destroy neighbor stacks
     for stack_name in self.neighbor_stack_names:
         common.DEPLOYMENT_UNIT.destroy_heat_template(stack_name)
     self.neighbor_stack_names = list()
Example #4
0
 def _reset_lua_file(self):
     """
     Sets back the configuration of the local file var to the default
     :return:
     """
     common.replace_in_file(self.lua_file,
                            'local out_file = "' + self.results_file + '"',
                            'local out_file = ""')
 def _reset_lua_file(self):
     """
     Sets back the configuration of the local file var to the default
     :return:
     """
     common.replace_in_file(self.lua_file, 'local out_file = "' +
                            self.results_file + '"',
                            'local out_file = ""')
 def _configure_lua_file(self):
     """
     Configure the packet gen to write the results into the right file
     :return: None
     """
     common.replace_in_file(self.lua_file, 'local out_file = ""',
                            'local out_file = "' +
                            self.results_file + '"')
Example #7
0
 def test_replace_in_file_for_success(self):
     filename = 'tests/data/common/file_replacement.txt'
     text_to_search = 'replacement of'
     text_to_replace = '***'
     common.replace_in_file(filename, text_to_search, text_to_replace)
     after = open(filename, 'r').readline()
     self.assertEqual(after, 'Test for the *** strings into a file\n')
     text_to_search = '***'
     text_to_replace = 'replacement of'
     common.replace_in_file(filename, text_to_search, text_to_replace)
Example #8
0
 def test_replace_in_file_for_success(self):
     filename = 'tests/data/common/file_replacement.txt'
     text_to_search = 'replacement of'
     text_to_replace = '***'
     common.replace_in_file(filename, text_to_search, text_to_replace)
     after = open(filename, 'r').readline()
     self.assertEqual(after, 'Test for the *** strings into a file\n')
     text_to_search = '***'
     text_to_replace = 'replacement of'
     common.replace_in_file(filename, text_to_search, text_to_replace)
 def init(self):
     super(InstantiationValidationNoisyNeighborsBenchmark, self).init()
     common.replace_in_file(self.lua_file, 'local out_file = ""',
                            'local out_file = "' + self.results_file + '"')
     heat_param = dict()
     heat_param['cores'] = self.params['number_of_cores']
     heat_param['memory'] = self.params['amount_of_ram']
     for i in range(0, int(self.params['num_of_neighbours'])):
         stack_name = self.stack_name + str(i)
         common.DEPLOYMENT_UNIT.deploy_heat_template(
             self.template_file, stack_name, heat_param)
         self.neighbor_stack_names.append(stack_name)
 def init(self):
     """
     Initialize the benchmark
     return: None
     """
     common.replace_in_file(self.lua_file, 'local out_file = ""', 'local out_file = "' + self.results_file + '"')
     heat_param = dict()
     heat_param['cores'] = self.params['number_of_cores']
     heat_param['memory'] = self.params['amount_of_ram']
     for i in range(0, int(self.params['num_of_neighbours'])):
         stack_name = self.stack_name + str(i)
         common.DEPLOYMENT_UNIT.deploy_heat_template(self.template_file, stack_name, heat_param)
         self.neighbor_stack_names.append(stack_name)
 def init(self):
     super(InstantiationValidationNoisyNeighborsBenchmark, self).init()
     common.replace_in_file(self.lua_file, 'local out_file = ""',
                            'local out_file = "' + self.results_file + '"')
     heat_param = dict()
     heat_param['cores'] = self.params['number_of_cores']
     heat_param['memory'] = self.params['amount_of_ram']
     for i in range(0, int(self.params['num_of_neighbours'])):
         stack_name = self.stack_name + str(i)
         common.DEPLOYMENT_UNIT.deploy_heat_template(self.template_file,
                                                     stack_name,
                                                     heat_param)
         self.neighbor_stack_names.append(stack_name)
Example #12
0
 def init(self):
     """
     Initialize the benchmark
     return: None
     """
     common.replace_in_file(self.lua_file, 'local out_file = ""',
                            'local out_file = "' + self.results_file + '"')
     heat_param = dict()
     heat_param['cores'] = self.params['number_of_cores']
     heat_param['memory'] = self.params['amount_of_ram']
     for i in range(0, int(self.params['num_of_neighbours'])):
         stack_name = self.stack_name + str(i)
         common.DEPLOYMENT_UNIT.deploy_heat_template(
             self.template_file, stack_name, heat_param)
         self.neighbor_stack_names.append(stack_name)
 def _configure_lua_file(self, traffic_rate_percentage, traffic_time):
     """
     Configure the packet gen to write the results into the right file
     :return: None
     """
     common.replace_in_file(self.lua_file, 'local out_file = ""',
                            'local out_file = "' + self.results_file + '"')
     common.replace_in_file(self.lua_file, 'local traffic_rate = 0',
                            'local traffic_rate = ' + traffic_rate_percentage)
     common.replace_in_file(self.lua_file, 'local traffic_delay = 0',
                            'local traffic_delay = ' + traffic_time)
Example #14
0
 def _configure_lua_file(self, traffic_rate_percentage, traffic_time):
     """
     Configure the packet gen to write the results into the right file
     :return: None
     """
     common.replace_in_file(self.lua_file, 'local out_file = ""',
                            'local out_file = "' + self.results_file + '"')
     common.replace_in_file(
         self.lua_file, 'local traffic_rate = 0',
         'local traffic_rate = ' + traffic_rate_percentage)
     common.replace_in_file(self.lua_file, 'local traffic_delay = 0',
                            'local traffic_delay = ' + traffic_time)
Example #15
0
def generates_templates(base_heat_template, deployment_configuration):
    """
    Generates the heat templates for the experiments
    :return: None
    """
    # Load useful parameters from file
    template_dir = common.get_template_dir()
    template_file_extension = fp.TEMPLATE_FILE_EXTENSION
    template_base_name = base_heat_template

    variables = deployment_configuration

    # Delete the templates eventually generated in previous running of the
    # framework
    common.LOG.info("Removing the heat templates previously generated")
    command = "rm {}{}_*".format(template_dir, template_name)
    os.system(command)

    # Creation of the tree with all the new configurations
    common.LOG.info("Creation of the tree with all the new configurations")
    tree = TreeNode()
    for variable in variables:
        leaves = TreeNode.get_leaves(tree)
        common.LOG.debug("LEAVES: " + str(leaves))
        common.LOG.debug("VALUES: " + str(variables[variable]))

        for value in variables[variable]:
            for leaf in leaves:
                new_node = TreeNode()
                new_node.set_variable_name(variable)
                new_node.set_variable_value(value)
                leaf.add_child(new_node)

    common.LOG.debug("CONFIGURATION TREE: " + str(tree))

    common.LOG.info("Heat Template and metadata file creation")
    leaves = TreeNode.get_leaves(tree)
    counter = 1
    for leaf in leaves:
        heat_template_vars = leaf.get_path()
        if os.path.isabs(template_base_name):
            base_template = template_base_name
        else:
            base_template = template_dir + template_base_name
        new_template = template_dir + template_name
        new_template += "_" + str(counter) + template_file_extension
        shutil.copy(base_template, new_template)

        metadata = {}
        for var in heat_template_vars:
            if var.get_variable_name():
                common.replace_in_file(new_template,
                                       "#" + var.get_variable_name(),
                                       var.get_variable_value())
                metadata[var.get_variable_name()] = var.get_variable_value()

        # Save the metadata on a JSON file
        with open(new_template + ".json", 'w') as outfile:
            # sort keys to maintain persistent order for git
            jsonutils.dump(metadata, outfile, sort_keys=True)

        common.LOG.debug("Heat Templates and Metadata file " + str(counter) +
                         " created")
        counter += 1

    # Creation of the template files
    common.LOG.info(
        str(counter - 1) + " Heat Templates and Metadata files "
        "created")
def generates_templates(base_heat_template, deployment_configuration):
    """
    Generates the heat templates for the experiments
    :return: None
    """
    # Load useful parameters from file
    template_dir = common.get_template_dir()
    template_file_extension = fp.TEMPLATE_FILE_EXTENSION
    template_base_name = base_heat_template

    variables = deployment_configuration

    # Delete the templates eventually generated in previous running of the
    # framework
    common.LOG.info("Removing the heat templates previously generated")
    os.system("rm " + template_dir + template_name + "_*")

    # Creation of the tree with all the new configurations
    common.LOG.info("Creation of the tree with all the new configurations")
    tree = TreeNode()
    for variable in variables:
        leaves = TreeNode.get_leaves(tree)
        common.LOG.debug("LEAVES: " + str(leaves))
        common.LOG.debug("VALUES: " + str(variables[variable]))

        for value in variables[variable]:
            for leaf in leaves:
                new_node = TreeNode()
                new_node.set_variable_name(variable)
                new_node.set_variable_value(value)
                leaf.add_child(new_node)

    common.LOG.debug("CONFIGURATION TREE: " + str(tree))

    common.LOG.info("Heat Template and metadata file creation")
    leaves = TreeNode.get_leaves(tree)
    counter = 1
    for leaf in leaves:
        heat_template_vars = leaf.get_path()
        if os.path.isabs(template_base_name):
            base_template = template_base_name
        else:
            base_template = template_dir + template_base_name
        new_template = template_dir + template_name
        new_template += "_" + str(counter) + template_file_extension
        shutil.copy(base_template, new_template)

        metadata = dict()
        for var in heat_template_vars:
            if var.get_variable_name():
                common.replace_in_file(new_template, "#" +
                                       var.get_variable_name(),
                                       var.get_variable_value())
                metadata[var.get_variable_name()] = var.get_variable_value()

        # Save the metadata on a JSON file
        with open(new_template + ".json", 'w') as outfile:
            json.dump(metadata, outfile)

        common.LOG.debug("Heat Templates and Metadata file " + str(counter) +
                         " created")
        counter += 1

    # Creation of the template files
    common.LOG.info(str(counter - 1) + " Heat Templates and Metadata files "
                                       "created")