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)
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, )
def _prepare_initial_requests(self): return [ Request( target, RequestData("remote/set_sbd_config", [("config", config)]), ) for target, config in self._request_data_list ]
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 ]
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 ]
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 ]
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 ]
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 ]
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, )
def get_request(timeout): return Request(global_target, RequestData("delay/{0}".format(timeout)))
def fixture_request(): return Request(RequestTarget("host"), RequestData("action"))
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)
def _prepare_initial_requests(self): return [ Request(target, self._get_request_data()) for target in self.__target_list ]