예제 #1
0
    def _validate(self, s_set: dict):
        """
        validates a give storage_sets to have required properties
        Raises exception if there is any entry missing
        """
        s_set_name = s_set.get('name')
        if s_set_name is None:
            raise CortxProvisionerError(
                errno.EINVAL, 'Missing name for the storage_set entry')

        Log.debug("Validating storage set '%s' properties" % s_set_name)

        required_keys_for_storage_set = ['durability', 'nodes']
        for k in required_keys_for_storage_set:
            if s_set.get(k) is None:
                raise VError(
                    errno.EINVAL,
                    f"'{k}' property is unspecified for storage_set {s_set_name}."
                )
예제 #2
0
    def _check_storage_sets(self):
        """Validate storage_sets present in cortx_conf."""
        solution_config_storage_sets = self._get_config(
            ConfigValidator._key_storage_set_sc)

        storage_set_counter = 0
        while self.cortx_conf.get(
                f'cluster>storage_set[{storage_set_counter}]>name'
        ) is not None:
            storage_set_counter = storage_set_counter + 1
        if len(solution_config_storage_sets) != storage_set_counter:
            Log.debug(
                f'Number of storage_sets define in {self.solution_conf_url} is '
                f'{len(solution_config_storage_sets)} and in {self.cortx_conf_url} '
                f'is {storage_set_counter}')
            raise CortxProvisionerError(
                errno.EINVAL,
                f'Number of storage_sets define in {self.cortx_conf_url} '
                f'and {self.solution_conf_url} is not equal.')
        return 0
예제 #3
0
 def _check_number_of_nodes(self):
     """Validate number of nodes specified in cortx_conf."""
     solution_config_storage_sets = self._get_config(
         ConfigValidator._key_storage_set_sc)
     for storage_set in solution_config_storage_sets:
         storage_set_name = storage_set['name']
         solution_config_nodes = storage_set['nodes']
         # Get number of nodes from confstore which has same storage_set_name.
         conf_store_nodes = self.cortx_conf.search('node', 'storage_set',
                                                   storage_set_name)
         if len(solution_config_nodes) != len(conf_store_nodes):
             Log.debug(
                 f'Number of nodes define in {self.solution_conf_url} is '
                 f'{len(solution_config_nodes)} and {self.cortx_conf_url} is '
                 f'{len(conf_store_nodes)}')
             raise CortxProvisionerError(
                 errno.EINVAL,
                 f'Number of nodes define in {self.cortx_conf_url} and '
                 f'{self.solution_conf_url} is not equal.')
     return 0
예제 #4
0
    def _validate(self, node: dict):
        """
        validates a give node to have required properties
        Raises exception if there is any entry missing
        """

        node_name = node.get('name')
        if node_name is None:
            raise CortxProvisionerError(errno.EINVAL,
                                        'Missing name for the node entry')

        Log.debug("Validating node '%s' properties" % node_name)

        required_keys_for_node = [
            'id', 'components', 'storage_set', 'hostname'
        ]
        for k in required_keys_for_node:
            if node.get(k) is None:
                raise CortxProvisionerError(
                    errno.EINVAL,
                    f"'{k}' property is unspecified for node {node_name}")
예제 #5
0
 def _validate_services(self, service_list, component_name):
     """Verify services defined in cluster.yaml is supported in constant file."""
     for service in service_list:
         # check if service name is define in utils const.py file.
         if service not in Const._value2member_map_:
             raise CortxProvisionerError(errno.EINVAL,
                                         f'{service} is not supported.')
         # Verify service_name is define for the specific component.
         # Get all keys from constant file which has same 'service_name'.
         constant_service_keys = [
             key for key, enum_ele in Const.__members__.items()
             if enum_ele.value.lower() == service.lower()
         ]
         if not any(component_name.upper() in key
                    for key in constant_service_keys):
             Log.debug(
                 f'"{service}" service defined in "{self.solution_conf_url}" for '
                 f'"{component_name}", is not supported.')
             raise CortxProvisionerError(
                 errno.EINVAL,
                 f'Component "{component_name}" does not support service "{service}".'
             )
     return 0