コード例 #1
0
 def fixture_response_connected(self, response_code):
     handle = MockCurl({pycurl.RESPONSE_CODE: response_code})
     handle.request_obj = Request(RequestTarget(self.host),
                                  RequestData(self.request))
     handle.output_buffer = io.BytesIO()
     handle.output_buffer.write(self.data)
     return Response.connection_successful(handle)
コード例 #2
0
ファイル: mock_node_communicator.py プロジェクト: vvidic/pcs
def _communication_to_response(
    label,
    dest_list,
    action,
    param_list,
    response_code,
    output,
    debug_output,
    was_connected,
    errno,
    error_msg,
    raw_data,
):
    return Response(
        MockCurlSimple(
            info={pycurl.RESPONSE_CODE: response_code},
            output=output,
            debug_output=debug_output,
            request=Request(
                # We do not need to check if token is the right one in tests:
                # 1) Library commands tests do not care about tokens. That
                #    should be covered once in a specialized test, not in every
                #    single library command test.
                # 2) If we need to test teh case when a token is not accepted
                #    by pcsd, we will do so by setting an appropriate response.
                #    The actual token value doesn't matter.
                RequestTarget(label, dest_list=dest_list, token=None),
                RequestData(action, param_list, raw_data),
            ),
        ),
        was_connected=was_connected,
        errno=errno,
        error_msg=error_msg,
    )
コード例 #3
0
 def _prepare_initial_requests(self):
     return [
         Request(
             target,
             RequestData("remote/set_sbd_config", [("config", config)]),
         ) for target, config in self._request_data_list
     ]
コード例 #4
0
ファイル: sbd.py プロジェクト: miz-take/pcs
 def _prepare_initial_requests(self):
     return [
         Request(
             target,
             RequestData("remote/check_sbd",
                         [("watchdog", watchdog),
                          ("device_list", json.dumps(device_list))]))
         for target, watchdog, device_list in self._request_data_list
     ]
コード例 #5
0
ファイル: qdevice_net.py プロジェクト: miz-take/pcs
 def _prepare_initial_requests(self):
     return [
         Request(
             target,
             RequestData("remote/qdevice_net_sign_node_certificate", [
                 ("certificate_request", base64.b64encode(cert)),
                 ("cluster_name", cluster_name),
             ])) for target, cert, cluster_name in self._input_data
     ]
コード例 #6
0
ファイル: scsi.py プロジェクト: mbaldessari/pcs
 def _prepare_initial_requests(self):
     return [
         Request(
             target,
             RequestData(
                 "api/v1/scsi-unfence-node/v1",
                 data=json.dumps({
                     "devices": self._devices,
                     "node": target.label
                 }),
             ),
         ) for target in self._target_list
     ]
コード例 #7
0
ファイル: scsi.py プロジェクト: vvidic/pcs
 def _prepare_initial_requests(self):
     return [
         Request(
             target,
             RequestData(
                 "api/v1/scsi-unfence-node/v2",
                 data=json.dumps(
                     dict(
                         node=target.label,
                         original_devices=self._original_devices,
                         updated_devices=self._updated_devices,
                     )),
             ),
         ) for target in self._target_list
     ]
コード例 #8
0
ファイル: scsi.py プロジェクト: kmalyjur/pcs
 def _prepare_initial_requests(self):
     return [
         Request(
             target,
             RequestData(
                 "api/v1/scsi-unfence-node-mpath/v1",
                 data=json.dumps(
                     dict(
                         key=self._node_key_map[target.label],
                         original_devices=self._original_devices,
                         updated_devices=self._updated_devices,
                     )),
             ),
         ) for target in self._target_list
     ]
コード例 #9
0
ファイル: config_http.py プロジェクト: miz-take/pcs
 def __communication_to_response(self, label, address_list, action,
                                 param_list, port, token, response_code,
                                 output, debug_output, was_connected, errno,
                                 error_msg):
     return Response(
         MockCurlSimple(info={pycurl.RESPONSE_CODE: response_code},
                        output=output.encode("utf-8"),
                        debug_output=debug_output.encode("utf-8"),
                        request=Request(
                            RequestTarget(label, address_list, port, token),
                            RequestData(action, param_list),
                        )),
         was_connected=was_connected,
         errno=6,
         error_msg=error_msg,
     )
コード例 #10
0
def get_request(timeout):
    return Request(global_target, RequestData("delay/{0}".format(timeout)))
コード例 #11
0
def fixture_request():
    return Request(RequestTarget("host"), RequestData("action"))
コード例 #12
0
 def fixture_response_not_connected(self, errno, error_msg):
     handle = MockCurl()
     handle.request_obj = Request(RequestTarget(self.host),
                                  RequestData(self.request))
     return Response.connection_failure(handle, errno, error_msg)
コード例 #13
0
 def _prepare_initial_requests(self):
     return [
         Request(target, self._get_request_data())
         for target in self.__target_list
     ]