Esempio n. 1
0
 def report_item_generator(i):
     if i == 1:
         raise NodeConnectionException("node", "command", "reason")
     elif i == 2:
         raise LibraryError(
             ReportItem.error(
                 report_codes.COMMON_ERROR,
             ),
             ReportItem.info(
                 report_codes.COMMON_INFO,
             )
         )
Esempio n. 2
0
def __validate_role_id_for_create(tree, role_id):
    validate_id(role_id, 'ACL role')
    if tree.find('.//acl_role[@id="{0}"]'.format(role_id)) is not None:
        raise LibraryError(ReportItem.error(
            error_codes.ACL_ROLE_ALREADY_EXISTS,
            'role {id} already exists',
            info={'id': role_id}
        ))
    if does_id_exist(tree, role_id):
        raise LibraryError(ReportItem.error(
            error_codes.ID_ALREADY_EXISTS,
            '{id} already exists',
            info={'id': role_id}
        ))
Esempio n. 3
0
def validate_id(id_candidate, description="id"):
    """
    Validate a pacemaker id, raise LibraryError on invalid id.

    id_candidate id's value
    description id's role description (default "id")
    """
    # see NCName definition
    # http://www.w3.org/TR/REC-xml-names/#NT-NCName
    # http://www.w3.org/TR/REC-xml/#NT-Name
    if len(id_candidate) < 1:
        raise LibraryError(ReportItem.error(
            error_codes.INVALID_ID,
            "{description} cannot be empty",
            info={
                "id": id_candidate,
                "description": description,
                "reason": "empty",
            }
        ))
    first_char_re = re.compile("[a-zA-Z_]")
    if not first_char_re.match(id_candidate[0]):
        raise LibraryError(ReportItem.error(
            error_codes.INVALID_ID,
            "invalid {description} '{id}', '{invalid_character}' is not " +
                "a valid first character for a {description}"
            ,
            info={
                "id": id_candidate,
                "description": description,
                "reason": "invalid first character",
                "invalid_character": id_candidate[0],
            }
        ))
    char_re = re.compile("[a-zA-Z0-9_.-]")
    for char in id_candidate[1:]:
        if not char_re.match(char):
            raise LibraryError(ReportItem.error(
                error_codes.INVALID_ID,
                "invalid {description} '{id}', '{invalid_character}' is not " +
                    "a valid character for a {description}"
                ,
                info={
                    "id": id_candidate,
                    "description": description,
                    "reason": "invalid character",
                    "invalid_character": char,
                }
            ))
Esempio n. 4
0
def sbd_enabling_started():
    """
    enabling SBD service started
    """
    return ReportItem.info(
        report_codes.SBD_ENABLING_STARTED,
    )
Esempio n. 5
0
def booth_config_distribution_started():
    """
    booth configuration is about to be sent to nodes
    """
    return ReportItem.info(
        report_codes.BOOTH_CONFIG_DISTRIBUTION_STARTED,
    )
Esempio n. 6
0
def cluster_restart_required_to_apply_changes():
    """
    warn user a cluster needs to be manually restarted to use new configuration
    """
    return ReportItem.warning(
        report_codes.CLUSTER_RESTART_REQUIRED_TO_APPLY_CHANGES,
    )
Esempio n. 7
0
def wait_for_idle_not_supported():
    """
    crm_resource does not support --wait
    """
    return ReportItem.error(
        report_codes.WAIT_FOR_IDLE_NOT_SUPPORTED,
    )
Esempio n. 8
0
def sbd_disabling_started():
    """
    disabling SBD service started
    """
    return ReportItem.info(
        report_codes.SBD_DISABLING_STARTED,
    )
Esempio n. 9
0
def wait_for_idle_not_live_cluster():
    """
    cannot wait for the cluster if not running with a live cluster
    """
    return ReportItem.error(
        report_codes.WAIT_FOR_IDLE_NOT_LIVE_CLUSTER,
    )
Esempio n. 10
0
def cib_load_error_invalid_format():
    """
    cib does not conform to the schema
    """
    return ReportItem.error(
        report_codes.CIB_LOAD_ERROR_BAD_FORMAT,
    )
Esempio n. 11
0
def cluster_state_invalid_format():
    """
    crm_mon xml output does not conform to the schema
    """
    return ReportItem.error(
        report_codes.BAD_CLUSTER_STATE_FORMAT,
    )
Esempio n. 12
0
def empty_resource_set_list():
    """
    an empty resource set has been specified, which is not allowed by cib schema
    """
    return ReportItem.error(
        report_codes.EMPTY_RESOURCE_SET_LIST,
    )
Esempio n. 13
0
def cman_unsupported_command():
    """
    requested library command is not available as local cluster is CMAN based
    """
    return ReportItem.error(
        report_codes.CMAN_UNSUPPORTED_COMMAND,
    )
Esempio n. 14
0
def qdevice_certificate_distribution_started():
    """
    Qdevice certificates are about to be set up on nodes
    """
    return ReportItem.info(
        report_codes.QDEVICE_CERTIFICATE_DISTRIBUTION_STARTED,
    )
Esempio n. 15
0
def qdevice_certificate_removal_started():
    """
    Qdevice certificates are about to be removed from nodes
    """
    return ReportItem.info(
        report_codes.QDEVICE_CERTIFICATE_REMOVAL_STARTED,
    )
Esempio n. 16
0
def qdevice_remove_or_cluster_stop_needed():
    """
    operation cannot be executed, qdevice removal or cluster stop is needed
    """
    return ReportItem.error(
        report_codes.QDEVICE_REMOVE_OR_CLUSTER_STOP_NEEDED,
    )
Esempio n. 17
0
def qdevice_client_reload_started():
    """
    qdevice client configuration is about to be reloaded on nodes
    """
    return ReportItem.info(
        report_codes.QDEVICE_CLIENT_RELOAD_STARTED,
    )
Esempio n. 18
0
def qdevice_already_defined():
    """
    qdevice is already set up in a cluster, when it was expected not to be
    """
    return ReportItem.error(
        report_codes.QDEVICE_ALREADY_DEFINED,
    )
Esempio n. 19
0
def qdevice_not_defined():
    """
    qdevice is not set up in a cluster, when it was expected to be
    """
    return ReportItem.error(
        report_codes.QDEVICE_NOT_DEFINED,
    )
Esempio n. 20
0
def corosync_config_parser_missing_closing_brace():
    """
    corosync config cannot be parsed due to missing closing brace
    """
    return ReportItem.error(
        report_codes.PARSE_ERROR_COROSYNC_CONF_MISSING_CLOSING_BRACE,
    )
Esempio n. 21
0
def corosync_config_parser_unexpected_closing_brace():
    """
    corosync config cannot be parsed due to unexpected closing brace
    """
    return ReportItem.error(
        report_codes.PARSE_ERROR_COROSYNC_CONF_UNEXPECTED_CLOSING_BRACE,
    )
Esempio n. 22
0
def corosync_not_running_check_started():
    """
    we are about to make sure corosync is not running on nodes
    """
    return ReportItem.info(
        report_codes.COROSYNC_NOT_RUNNING_CHECK_STARTED,
    )
Esempio n. 23
0
def unable_to_determine_group_gid(group):
    return ReportItem.error(
        report_codes.UNABLE_TO_DETERMINE_GROUP_GID,
        info={
            "group": group
        }
    )
Esempio n. 24
0
def live_environment_required(forbidden_options):
    return ReportItem.error(
        report_codes.LIVE_ENVIRONMENT_REQUIRED,
        info={
            "forbidden_options": forbidden_options,
        }
    )
Esempio n. 25
0
def cib_upgrade_successful():
    """
    Upgrade of CIB schema was successful.
    """
    return ReportItem.info(
        report_codes.CIB_UPGRADE_SUCCESSFUL,
    )
Esempio n. 26
0
def unable_to_determine_user_uid(user):
    return ReportItem.error(
        report_codes.UNABLE_TO_DETERMINE_USER_UID,
        info={
            "user": user
        }
    )
Esempio n. 27
0
def sbd_config_distribution_started():
    """
    distribution of SBD configuration started
    """
    return ReportItem.info(
        report_codes.SBD_CONFIG_DISTRIBUTION_STARTED,
    )
Esempio n. 28
0
def corosync_config_distribution_started():
    """
    corosync configuration is about to be sent to nodes
    """
    return ReportItem.info(
        report_codes.COROSYNC_CONFIG_DISTRIBUTION_STARTED,
    )
Esempio n. 29
0
def sbd_requires_atb():
    """
    Warning that ATB will be enabled in order to make SBD fencing effective.
    """
    return ReportItem.warning(
        report_codes.SBD_REQUIRES_ATB,
    )
Esempio n. 30
0
def corosync_config_reloaded():
    """
    corosync configuration has been reloaded
    """
    return ReportItem.info(
        report_codes.COROSYNC_CONFIG_RELOADED,
    )
Esempio n. 31
0
def qdevice_already_initialized(model):
    """
    cannot create qdevice on local host, it has been already created
    string model qdevice model
    """
    return ReportItem.error(report_codes.QDEVICE_ALREADY_INITIALIZED,
                            info={
                                "model": model,
                            })
Esempio n. 32
0
def booth_unsupported_file_location(file):
    """
    location of booth configuration file (config, authfile) file is not
    supported (not in /etc/booth/)

    file -- file path
    """
    return ReportItem.warning(report_codes.BOOTH_UNSUPORTED_FILE_LOCATION,
                              info={"file": file})
Esempio n. 33
0
def agent_name_guess_found_none(agent):
    """
    Specified agent doesn't exist
    string agent name of the agent which doesn't exist
    """
    return ReportItem.error(
        report_codes.AGENT_NAME_GUESS_FOUND_NONE,
        info={"agent": agent}
    )
Esempio n. 34
0
def common_error(text):
    # TODO replace by more specific reports
    """
    unspecified error with text message, do not use unless absolutely necessary
    """
    return ReportItem.error(
        report_codes.COMMON_ERROR,
        info={"text": text}
    )
Esempio n. 35
0
def cman_ignored_option(option):
    """
    specified option is ignored as CMAN clusters do not support it
    options string option name
    """
    return ReportItem.warning(
        report_codes.IGNORED_CMAN_UNSUPPORTED_OPTION,
        info={'option_name': option}
    )
Esempio n. 36
0
def pacemaker_local_node_name_not_found(reason):
    """
    we are unable to figure out pacemaker's local node's name
    reason string error message
    """
    return ReportItem.error(
        report_codes.PACEMAKER_LOCAL_NODE_NAME_NOT_FOUND,
        info={"reason": reason}
    )
Esempio n. 37
0
def booth_address_duplication(duplicate_addresses):
    """
    Address of each peer must unique. But address duplication appeared.
    set duplicate_addresses contains addreses entered multiple times
    """
    return ReportItem.error(report_codes.BOOTH_ADDRESS_DUPLICATION,
                            info={
                                "addresses": duplicate_addresses,
                            })
Esempio n. 38
0
def invalid_timeout(timeout):
    """
    specified timeout is not valid (number or other format e.g. 2min)
    timeout string specified invalid timeout
    """
    return ReportItem.error(
        report_codes.INVALID_TIMEOUT_VALUE,
        info={"timeout": timeout}
    )
Esempio n. 39
0
def booth_not_exists_in_cib(name):
    """
    Remove booth instance from cib required. But no such instance found in cib.
    string name is booth instance name
    """
    return ReportItem.error(report_codes.BOOTH_NOT_EXISTS_IN_CIB,
                            info={
                                "name": name,
                            })
Esempio n. 40
0
def invalid_score(score):
    """
    specified score value is not valid
    score specified score value
    """
    return ReportItem.error(report_codes.INVALID_SCORE,
                            info={
                                "score": score,
                            })
Esempio n. 41
0
def booth_even_peers_num(number):
    """
    Booth requires odd number of peers. But even number of peers was entered.
    integer number determines how many peers was entered
    """
    return ReportItem.error(report_codes.BOOTH_EVEN_PEERS_NUM,
                            info={
                                "number": number,
                            })
Esempio n. 42
0
def resource_wait_error(reason):
    """
    waiting for resources (crm_resource --wait) failed
    string reason error description
    """
    return ReportItem.error(report_codes.RESOURCE_WAIT_ERROR,
                            info={
                                "reason": reason,
                            })
Esempio n. 43
0
def booth_lack_of_sites(site_list):
    """
    Less than 2 booth sites entered. But it does not make sense.
    list site_list contains currently entered sites
    """
    return ReportItem.error(report_codes.BOOTH_LACK_OF_SITES,
                            info={
                                "sites": site_list,
                            })
Esempio n. 44
0
def cluster_state_cannot_load(reason):
    """
    cannot load cluster status from crm_mon, crm_mon exited with non-zero code
    string reason error description
    """
    return ReportItem.error(report_codes.CRM_MON_ERROR,
                            info={
                                "reason": reason,
                            })
Esempio n. 45
0
def rrp_active_not_supported(warning=False):
    """
    active RRP mode is not supported, require user confirmation
    warning set to True if user confirmed he/she wants to proceed
    """
    return ReportItem(
        report_codes.RRP_ACTIVE_NOT_SUPPORTED,
        ReportItemSeverity.WARNING if warning else ReportItemSeverity.ERROR,
        forceable=(None if warning else report_codes.FORCE_ACTIVE_RRP))
Esempio n. 46
0
def cib_load_error(reason):
    """
    cannot load cib from cibadmin, cibadmin exited with non-zero code
    string reason error description
    """
    return ReportItem.error(report_codes.CIB_LOAD_ERROR,
                            info={
                                "reason": reason,
                            })
Esempio n. 47
0
def resource_wait_timed_out(reason):
    """
    waiting for resources (crm_resource --wait) failed, timeout expired
    string reason error description
    """
    return ReportItem.error(report_codes.RESOURCE_WAIT_TIMED_OUT,
                            info={
                                "reason": reason,
                            })
Esempio n. 48
0
def qdevice_not_running(model):
    """
    qdevice is expected to be running but is not running
    string model qdevice model
    """
    return ReportItem.error(report_codes.QDEVICE_NOT_RUNNING,
                            info={
                                "model": model,
                            })
Esempio n. 49
0
def cib_missing_mandatory_section(section_name):
    """
    CIB is missing a section which is required to be present
    section_name string name of the missing section (element name or path)
    """
    return ReportItem.error(report_codes.CIB_CANNOT_FIND_MANDATORY_SECTION,
                            info={
                                "section": section_name,
                            })
Esempio n. 50
0
def qdevice_certificate_sign_error(reason):
    """
    an error occured when signing qdevice certificate
    string reason an error message
    """
    return ReportItem.error(report_codes.QDEVICE_CERTIFICATE_SIGN_ERROR,
                            info={
                                "reason": reason,
                            })
Esempio n. 51
0
def resource_does_not_exist(resource_id):
    """
    specified resource does not exist (e.g. when creating in constraints)
    resource_id string specified resource id
    """
    return ReportItem.error(report_codes.RESOURCE_DOES_NOT_EXIST,
                            info={
                                "resource_id": resource_id,
                            })
Esempio n. 52
0
def qdevice_initialization_success(model):
    """
    qdevice was successfully initialized on local host
    string model qdevice model
    """
    return ReportItem.info(report_codes.QDEVICE_INITIALIZATION_SUCCESS,
                           info={
                               "model": model,
                           })
Esempio n. 53
0
def qdevice_destroy_success(model):
    """
    qdevice configuration successfully removed from local host
    string model qdevice model
    """
    return ReportItem.info(report_codes.QDEVICE_DESTROY_SUCCESS,
                           info={
                               "model": model,
                           })
Esempio n. 54
0
def quorum_cannot_disable_atb_due_to_sbd(severity=ReportItemSeverity.ERROR,
                                         forceable=None):
    """
    Quorum option auto_tie_breaker cannot be disbled due to SBD.
    """
    return ReportItem(
        report_codes.COROSYNC_QUORUM_CANNOT_DISABLE_ATB_DUE_TO_SBD,
        severity,
        forceable=forceable)
Esempio n. 55
0
def qdevice_certificate_import_error(reason):
    """
    an error occured when importing qdevice certificate to a node
    string reason an error message
    """
    return ReportItem.error(report_codes.QDEVICE_CERTIFICATE_IMPORT_ERROR,
                            info={
                                "reason": reason,
                            })
Esempio n. 56
0
def invalid_response_format(node):
    """
    error message that response in invalid format has been received from
    specified node

    node -- node name
    """
    return ReportItem.error(report_codes.INVALID_RESPONSE_FORMAT,
                            info={"node": node})
Esempio n. 57
0
def qdevice_not_initialized(model):
    """
    cannot work with qdevice on local host, it has not been created yet
    string model qdevice model
    """
    return ReportItem.error(report_codes.QDEVICE_NOT_INITIALIZED,
                            info={
                                "model": model,
                            })
Esempio n. 58
0
def service_kill_success(services):
    """
    system services were killed successfully
    iterable services services name or description
    """
    return ReportItem.info(report_codes.SERVICE_KILL_SUCCESS,
                           info={
                               "services": services,
                           })
Esempio n. 59
0
def corosync_quorum_get_status_error(reason):
    """
    unable to get runtime status of quorum on local node
    string reason an error message
    """
    return ReportItem.error(report_codes.COROSYNC_QUORUM_GET_STATUS_ERROR,
                            info={
                                "reason": reason,
                            })
Esempio n. 60
0
def booth_already_in_cib(name):
    """
    Each booth instance should be in a cib once maximally. Existence of booth
        instance in cib detected during creating new one.
    string name is booth instance name
    """
    return ReportItem.error(report_codes.BOOTH_ALREADY_IN_CIB,
                            info={
                                "name": name,
                            })