Example #1
0
    def check_pacemaker_started(
        self,
        pacemaker_started_node_list=(),
        pacemaker_not_started_node_list=(),
        communication_list=None,
        name="http.host.check_pacemaker_started",
    ):
        """
        Create a call for checking pacemaker status on nodes.

        pacemaker_started_node_list list -- list of node names on which
            pacemaker is fully running
        pacemaker_not_started_node_list list -- listof node names on which
            pacemaker is not fully started yet
        communication_list list -- create custom responses
        name string -- the key of this call
        """
        if bool(
            pacemaker_started_node_list or pacemaker_not_started_node_list
        ) == bool(communication_list):
            raise AssertionError(
                "Exactly one of 'pacemaker_started_node_list and/or "
                "pacemaker_not_started_node_list', 'communication_list' must "
                "be specified"
            )
        if not communication_list:
            communication_list = [
                dict(
                    label=node,
                    output=json.dumps(
                        dict(
                            pending=False,
                            online=True,
                        )
                    ),
                )
                for node in pacemaker_started_node_list
            ] + [
                dict(
                    label=node,
                    output=json.dumps(
                        dict(
                            pending=True,
                            online=False,
                        )
                    ),
                )
                for node in pacemaker_not_started_node_list
            ]

        place_communication(
            self.__calls,
            name,
            communication_list,
            action="remote/pacemaker_node_status",
        )
Example #2
0
 def add_communication(self, name, communication_list, **kwargs):
     """
     Create a generic call for network communication.
     string name -- key of the call
     list of dict communication_list -- see
         pcs_test.tools.command_env.mock_node_communicator.create_communication
     **kwargs -- see
         pcs_test.tools.command_env.mock_node_communicator.create_communication
     """
     place_communication(self.__calls, name, communication_list, **kwargs)
Example #3
0
    def unfence_node_mpath(
        self,
        node_key_map,
        original_devices=(),
        updated_devices=(),
        node_labels=None,
        communication_list=None,
        name="http.scsi.unfence_node",
    ):
        """
        Create a calls for node unfencing

        dict node_key_map -- map of node name to its registration key
        list original_devices -- list of scsi devices before an update
        list updated_devices -- list of scsi devices after an update
        list node_labels -- create success responses from these nodes
        list communication_list -- use these custom responses
        string name -- the key of this call
        """
        if (node_labels is None
                and communication_list is None) or (node_labels
                                                    and communication_list):
            raise AssertionError(
                "Exactly one of 'node_labels', 'communication_list' "
                "must be specified")

        if node_labels:
            communication_list = [
                dict(
                    label=node,
                    raw_data=json.dumps(
                        dict(
                            key=node_key_map[node],
                            original_devices=original_devices,
                            updated_devices=updated_devices,
                        )),
                ) for node in node_labels
            ]
        place_communication(
            self.__calls,
            name,
            communication_list,
            action="api/v1/scsi-unfence-node-mpath/v1",
            output=json.dumps(
                to_dict(
                    communication.dto.InternalCommunicationResultDto(
                        status=communication.const.COM_STATUS_SUCCESS,
                        status_msg=None,
                        report_list=[],
                        data=None,
                    ))),
        )
Example #4
0
    def check_pacemaker_started(
        self, pacemaker_started_node_list=(),
        pacemaker_not_started_node_list=(), communication_list=None,
        name="http.host.check_pacemaker_started",
    ):
        """
        Create a call for checking pacemaker status on nodes.

        pacemaker_started_node_list list -- list of node names on which
            pacemaker is fully running
        pacemaker_not_started_node_list list -- listof node names on which
            pacemaker is not fully started yet
        communication_list list -- create custom responses
        name string -- the key of this call
        """
        if (
            bool(pacemaker_started_node_list or pacemaker_not_started_node_list)
            ==
            bool(communication_list)
        ):
            raise AssertionError(
                "Exactly one of 'pacemaker_started_node_list and/or "
                "pacemaker_not_started_node_list', 'communication_list' must "
                "be specified"
            )
        if not communication_list:
            communication_list = [
                dict(
                    label=node,
                    output=json.dumps(dict(
                        pending=False,
                        online=True,
                    ))
                ) for node in pacemaker_started_node_list
            ] + [
                dict(
                    label=node,
                    output=json.dumps(dict(
                        pending=True,
                        online=False,
                    ))
                ) for node in pacemaker_not_started_node_list
            ]

        place_communication(
            self.__calls,
            name,
            communication_list,
            action="remote/pacemaker_node_status",
        )
Example #5
0
    def unfence_node(
        self,
        devices,
        node_labels=None,
        communication_list=None,
        name="http.scsi.unfence_node",
    ):
        """
        Create a calls for node unfencing

        list devices -- list of scsi devices
        list node_labels -- create success responses from these nodes
        list communication_list -- use these custom responses
        string name -- the key of this call
        """
        if (node_labels is None
                and communication_list is None) or (node_labels
                                                    and communication_list):
            raise AssertionError(
                "Exactly one of 'node_labels', 'communication_list' "
                "must be specified")

        if node_labels:
            communication_list = [
                dict(
                    label=node,
                    raw_data=json.dumps(dict(devices=devices, node=node)),
                ) for node in node_labels
            ]
        place_communication(
            self.__calls,
            name,
            communication_list,
            action="api/v1/scsi-unfence-node/v1",
            output=json.dumps(
                to_dict(
                    communication.dto.InternalCommunicationResultDto(
                        status=communication.const.COM_STATUS_SUCCESS,
                        status_msg=None,
                        report_list=[],
                        data=None,
                    ))),
        )