Exemplo n.º 1
0
    def resolve(self, value):
        """
        Reads the topology data.
        """
        topology_dirs = [os.path.join(path, self.app_name, 'topology')
                         for path in self.settings_dirs]

        topology_dict = {}
        for topology_item in value.split(','):
            pattern = re.compile("^[A-Za-z]+:[0-9]+$")
            if pattern.match(topology_item) is None:
                pattern = re.compile("^[0-9]+_[A-Za-z]+$")
                if pattern.match(topology_item) is None:
                    raise exceptions.IRWrongTopologyFormat(value)
                number, node_type = topology_item.split('_')
                LOG.warning("The '{}' topology format is deprecated and will "
                            "be removed in future versions. "
                            "Please see `--help` "
                            "for proper format".format(topology_item))
            else:
                node_type, number = topology_item.split(':')

            # Remove white spaces
            node_type = node_type.strip()

            topology_dict[node_type] = \
                utils.load_yaml(node_type + ".yml", *topology_dirs)
            topology_dict[node_type]['amount'] = int(number)

        return topology_dict
Exemplo n.º 2
0
    def resolve_value(self, arg_name, defaults=None):
        """
        Merges topology files in a single topology dict.

        :param clg_args: Dictionary based on cmd-line args parsed by clg
        :param app_settings_dir: path to the base directory holding the
            application's settings. App can be provisioner\installer\tester
            and the path would be: settings/<app_name>/
        """
        super(TopologyArgument, self).resolve_value(arg_name, defaults)

        # post process topology
        topology_dir = os.path.join(self.get_app_attr("settings_dir"),
                                    'topology')
        topology_dict = {}
        for topology_item in self.value.split(','):
            if '_' in topology_item:
                number, node_type = topology_item.split('_')
            else:
                raise exceptions.IRConfigurationException(
                    "Topology node should be in format  <number>_<node role>. "
                    "Current value: '{}' ".format(topology_item))
            # todo(obaraov): consider moving topology to config on constant.
            topology_dict[node_type] = utils.load_yaml(node_type + ".yaml",
                                                       topology_dir)
            topology_dict[node_type]['amount'] = int(number)

        self.value = topology_dict
Exemplo n.º 3
0
    def resolve(self, value):
        """
        Reads the topology data.
        """
        topology_dirs = [
            os.path.join(path, self.app_name, 'topology')
            for path in self.settings_dirs
        ]

        topology_dict = {}
        for topology_item in value.split(','):
            pattern = re.compile("^[A-Za-z]+:[0-9]+$")
            if pattern.match(topology_item) is None:
                pattern = re.compile("^[0-9]+_[A-Za-z]+$")
                if pattern.match(topology_item) is None:
                    raise exceptions.IRWrongTopologyFormat(value)
                number, node_type = topology_item.split('_')
                LOG.warning("The '{}' topology format is deprecated and will "
                            "be removed in future versions. "
                            "Please see `--help` "
                            "for proper format".format(topology_item))
            else:
                node_type, number = topology_item.split(':')

            # Remove white spaces
            node_type = node_type.strip()

            topology_dict[node_type] = \
                utils.load_yaml(node_type + ".yml", *topology_dirs)
            topology_dict[node_type]['amount'] = int(number)

        return topology_dict
Exemplo n.º 4
0
 def resolve(self, value):
     """
     Transforms yaml file to the dict
     :return:
     """
     search_paths = self.get_file_locations()
     return utils.load_yaml(value, *search_paths)
Exemplo n.º 5
0
    def resolve_value(self, arg_name, defaults=None):
        """
        Merges topology files in a single topology dict.

        :param clg_args: Dictionary based on cmd-line args parsed by clg
        :param app_settings_dir: path to the base directory holding the
            application's settings. App can be provisioner\installer\tester
            and the path would be: settings/<app_name>/
        """
        super(TopologyArgument, self).resolve_value(arg_name, defaults)

        # post process topology
        topology_dir = os.path.join(self.get_app_attr("settings_dir"),
                                    'topology')
        topology_dict = {}
        for topology_item in self.value.split(','):
            if '_' in topology_item:
                number, node_type = topology_item.split('_')
            else:
                raise exceptions.IRConfigurationException(
                    "Topology node should be in format  <number>_<node role>. "
                    "Current value: '{}' ".format(topology_item))
            # todo(obaraov): consider moving topology to config on constant.
            topology_dict[node_type] = utils.load_yaml(node_type + ".yaml",
                                                       topology_dir)
            topology_dict[node_type]['amount'] = int(number)

        self.value = topology_dict
Exemplo n.º 6
0
 def resolve(self, value):
     """
     Transforms yaml file to the dict
     :return:
     """
     search_paths = self.get_file_locations()
     return utils.load_yaml(value, *search_paths)
Exemplo n.º 7
0
    def resolve_value(self, arg_name, defaults=None):
        super(YamlFileArgument, self).resolve_value(arg_name, defaults)

        search_paths = self.get_file_locations(
            self.get_app_attr("settings_dir"),
            self.get_app_attr("subcommand"),
            arg_name)

        if self.value is not None:
            self.value = utils.load_yaml(self.value,
                                         *search_paths)
        else:
            pass
Exemplo n.º 8
0
    def resolve_value(self, arg_name, defaults=None):
        super(YamlFileArgument, self).resolve_value(arg_name, defaults)

        search_first = os.path.join(self.get_app_attr("settings_dir"),
                                    self.get_app_attr("subcommand"),
                                    *arg_name.split("-"))
        search_second = os.path.join(self.get_app_attr("settings_dir"),
                                     *arg_name.split("-"))

        if self.value is not None:
            self.value = utils.load_yaml(self.value, search_first,
                                         search_second)
        else:
            pass
Exemplo n.º 9
0
    def resolve_value(self, arg_name, defaults=None):
        super(YamlFileArgument, self).resolve_value(arg_name, defaults)

        search_first = os.path.join(self.get_app_attr("settings_dir"),
                                    self.get_app_attr("subcommand"),
                                    *arg_name.split("-"))
        search_second = os.path.join(self.get_app_attr("settings_dir"),
                                     *arg_name.split("-"))

        if self.value is not None:
            self.value = utils.load_yaml(self.value,
                                         search_first,
                                         search_second)
        else:
            pass
Exemplo n.º 10
0
    def resolve(self, value):
        search_paths = self.get_file_locations()

        result = {}
        if value is not None:
            # validate value. Check that we have comma separated values
            pattern = re.compile("^[-\w\s\.]+(?:,[-\w\s]*)*$")
            if pattern.match(value) is None:
                raise exceptions.IRWrongYamlListFormat(value)

            for item in value.split(','):
                item_name, item_file = self._construct_name(item)
                item_dict = utils.load_yaml(item_file, *search_paths)
                result[item_name] = item_dict

        return result
Exemplo n.º 11
0
    def resolve(self, value):
        search_paths = self.get_file_locations()

        result = {}
        if value is not None:
            # validate value. Check that we have comma separated values
            pattern = re.compile("^[-\w\s\.]+(?:,[-\w\s]*)*$")
            if pattern.match(value) is None:
                raise exceptions.IRWrongYamlListFormat(value)

            for item in value.split(','):
                item_name, item_file = self._construct_name(item)
                item_dict = utils.load_yaml(item_file, *search_paths)
                result[item_name] = item_dict

        return result