def _get_server_count(self, cluster_name, cluster_values):
        """
        Determine the number of servers associated with a cluster.
        :param cluster_name: the name of the cluster
        :param cluster_values: a map of values for the cluster
        :return: the number of servers
        """
        if DYNAMIC_SERVERS in cluster_values:
            # for dynamic clusters, return the value of DynamicClusterSize
            dynamic_servers_dict = cluster_values[DYNAMIC_SERVERS]
            cluster_size_value = dictionary_utils.get_element(
                dynamic_servers_dict, DYNAMIC_CLUSTER_SIZE)
            if cluster_size_value is not None:
                return alias_utils.convert_to_type('integer',
                                                   cluster_size_value)
        else:
            # for other clusters, return the number of servers assigned to this cluster
            count = 0
            servers = dictionary_utils.get_dictionary_element(
                self._model.get_model_topology(), SERVER)
            for server_name, server_value in servers.items():
                server_cluster = dictionary_utils.get_element(
                    server_value, CLUSTER)
                if str(server_cluster) == cluster_name:
                    count = count + 1
            return count

        return 0
def _get_target_value(model_value, type_name):
    """
    Return the value for the specified attribute value, to be used in the domain resource file.
    :param model_value: the value to be checked
    :param type_name: the schema type name of the value
    :return: the formatted value
    """
    if type_name == 'boolean':
        # the model values can be true, false, 1, 0, etc.
        # target boolean values must be 'true' or 'false'
        return alias_utils.convert_to_type('boolean', model_value)

    if type_name == 'array':
        # the model values can be 'abc,123'.
        # target values must be a list object.
        return alias_utils.convert_to_type('list', model_value, delimiter=MODEL_LIST_DELIMITER)

    return model_value
Beispiel #3
0
 def is_use_atp(self):
     """
     Determine if the RCU DB info uses the ATP database.
     The model should allow all the values allowed by boolean alias model elements.
     The default when not specified is False.
     :return: True if the model value is present and indicates true, False otherwise
     """
     if USE_ATP in self.rcu_properties_map:
         model_value = self.rcu_properties_map[USE_ATP]
         value = alias_utils.convert_to_type('boolean', model_value)
         return value == 'true'
     return False
Beispiel #4
0
def _get_target_value(model_value, type_name):
    """
    Return the value for the specified attribute value, to be used in the domain resource file.
    :param model_value: the value to be checked
    :param type_name: the alias type name of the value
    :return: the formatted value
    """
    if type_name == BOOLEAN:
        # the model values can be true, false, 1, 0, etc.
        # target boolean values must be 'true' or 'false'
        return alias_utils.convert_to_type('boolean', model_value)

    return model_value
Beispiel #5
0
    def _update_config(self, config_name, config_dictionary, parent_location):
        _method_name = '_update_config'

        config_location = LocationContext(parent_location).append_location(ODL_CONFIGURATION)
        token = self.alias_helper.get_name_token(config_location)
        config_location.add_name_token(token, config_name)

        servers = dictionary_utils.get_element(config_dictionary, _SERVERS)
        if servers is not None:
            servers_list = alias_utils.convert_to_type('list', servers, delimiter=MODEL_LIST_DELIMITER)
            for server in servers_list:
                self.logger.info('WLSDPLY-19708', ODL_CONFIGURATION, config_name, server,
                                 class_name=self.__class_name, method_name=_method_name)
                self._update_server(server, config_dictionary, config_location)
def get_server_count(cluster_name, cluster_values, model_dictionary, aliases):
    """
    Determine the number of servers associated with a cluster.
    :param cluster_name: the name of the cluster
    :param cluster_values: the value map for the cluster
    :param model_dictionary: the model dictionary
    :param aliases: aliases instance for validation
    :return: the number of servers
    """
    if DYNAMIC_SERVERS in cluster_values:
        # for dynamic clusters, return the value of DynamicClusterSize
        dynamic_servers_dict = cluster_values[DYNAMIC_SERVERS]
        location = LocationContext()
        location.append_location(CLUSTER)
        location.add_name_token(aliases.get_name_token(location), 'cluster')
        location.append_location(DYNAMIC_SERVERS)
        location.add_name_token(aliases.get_name_token(location), 'server')
        present, __ = aliases.is_valid_model_attribute_name(
            location, DYNAMIC_CLUSTER_SIZE)
        if present == ValidationCodes.VALID:
            cluster_size_value = dictionary_utils.get_element(
                dynamic_servers_dict, DYNAMIC_CLUSTER_SIZE)
        else:
            cluster_size_value = dictionary_utils.get_element(
                dynamic_servers_dict, MAX_DYNAMIC_SERVER_COUNT)
        if cluster_size_value is not None:
            return alias_utils.convert_to_type('integer', cluster_size_value)
    else:
        # for other clusters, return the number of servers assigned to this cluster
        count = 0
        topology = dictionary_utils.get_dictionary_element(
            model_dictionary, TOPOLOGY)
        servers = dictionary_utils.get_dictionary_element(topology, SERVER)
        for server_name, server_value in servers.items():
            server_cluster = dictionary_utils.get_element(
                server_value, CLUSTER)
            if str(server_cluster) == cluster_name:
                count = count + 1
        return count

    return 0
        use_parent_handlers = dictionary_utils.get_element(
            logger, _USE_PARENT_HANDLERS)
        if use_parent_handlers is not None:
            value = alias_utils.convert_boolean(use_parent_handlers)
            try:
                document.setLoggerUseParentHandlers(logger_name, value)
            except IllegalArgumentException, iae:
                self._log_invalid_set(_USE_PARENT_HANDLERS, value, iae,
                                      _method_name, logger_path)

        assigned_handlers = document.getLoggerHandlers(logger_name)

        logger_handlers = dictionary_utils.get_element(logger, _HANDLERS)
        if logger_handlers is not None:
            handlers_list = alias_utils.convert_to_type(
                'list', logger_handlers, delimiter=MODEL_LIST_DELIMITER)
            for logger_handler in handlers_list:
                if logger_handler not in assigned_handlers:
                    try:
                        document.addHandlerToLogger(logger_name,
                                                    logger_handler)
                    except IllegalArgumentException, iae:
                        self.logger.severe('WLSDPLY-19705',
                                           logger_handler,
                                           logger_name,
                                           logger_path,
                                           iae.getLocalizedMessage(),
                                           class_name=self.__class_name,
                                           method_name=_method_name)

    def _log_invalid_set(self, key, value, exception, method_name, model_path):