request#
这是 SDK 的核心模块, 实现了各种底层方法.
- acore_soap_remote.request.build_cli_arg_for_gm(command: str, username: Optional[str] = None, password: Optional[str] = None, host: Optional[str] = None, port: Optional[int] = None, delay: int = 100, raises: bool = True, output_s3uri: Optional[str] = None, path_agent_cli: str = '/home/ubuntu/git_repos/acore_soap_agent-project/.venv/bin/acoresoapagent') str[source]#
构造最终的命令行参数. 以便之后 pass 给
acoresoapagent gm ...CLI 命令.
- class acore_soap_remote.request.SoapResponseAsyncGetter(command_id: str, ec2_instance_id: str, ssm_client: SSMClient, output_s3uri: Optional[str], s3_client: Optional[S3Client], delays: int, timeout: int, verbose: bool)[source]#
A helper class to get SOAP responses asynchronously.
- acore_soap_remote.request.run_soap_command(gm_commands: List[str], ec2_instance_id: str, ssm_client: SSMClient, username: Optional[str] = None, password: Optional[str] = None, host: Optional[str] = None, port: Optional[int] = None, raises: bool = True, input_s3uri: Optional[str] = None, output_s3uri: Optional[str] = None, s3_client: Optional[S3Client] = None, path_agent_cli: str = '/home/ubuntu/git_repos/acore_soap_agent-project/.venv/bin/acoresoapagent', delays_between_command: int = 100, delays: int = 1, timeout: int = 10, verbose: bool = True) SoapResponseAsyncGetter[source]#
从任何地方, 通过 SSM Run Command, 远程执行 SOAP 命令.
如果显式指定了
s3uri_input, 则将 GM 命令的输入写入 S3.如果显式指定了
s3uri_output, 则将 GM 命令的输出写入 S3.- 如果没有显示指定
s3uri_output, 有两种情况: - requests 的数量不超过 20 条, 则将 GM 命令的输出作为 JSON 在 stdout 中打印,
并在
ssm.send_command()API 返回.
- requests 的数量超过了 20 条, 则强制要求指定
s3uri_output将 GM 命令的输出 写入 S3.
- requests 的数量超过了 20 条, 则强制要求指定
- 如果没有显示指定
Usage Example:
>>> async_getter = response = run_soap_command( ... gm_commands=[".server info"], ... ec2_instance_id="i-1234567890abcdef0", ... ssm_client=ssm_client, ... ) >>> responses = async_getter.get()
- Parameters:
gm_commands – 一组 GM 命令.
ec2_instance_id – EC2 实例 ID.
ssm_client – boto3.client(“ssm”) 对象.
username – 默认的用户名, 只有当 request.username 为 None 的时候才会用到.
password – 默认的密码, 只有当 request.password 为 None 的时候才会用到.
host – 默认的 host, 只有当 request.host 为 None 的时候才会用到.
port – 默认的 port, 只有当 request.port 为 None 的时候才会用到.
raises – 默认为 True. 如果为 True, 则在遇到错误时抛出异常. 反之则将 failed SOAP Response 原封不动地返回.
input_s3uri – 如果指定, 则将输入写入 S3. 常用于 Payload 比较大的情况. 如果你一次性发送的 request 大于 20 条, 则必须使用这个参数.
output_s3uri – 如果不指定, 则默认将输出作为 JSON 打印. 如果指定了 s3uri, 则将输出写入到 S3.
s3_client – boto3.client(“s3”) 对象.
path_agent_cli – EC2 上 acsoap 命令行工具的绝对路径.
delays_between_command – 在运行每个 GM 命令之间的延迟时间, 单位为毫秒.
delays – 等待 run command 完成期间查询状态的间隔, 单位为秒.
timeout – run command 的超时限制.
verbose – 在等待 run command 完成时是否显示进度条.