|
| 1 | +""" |
| 2 | +Usage: |
| 3 | +python execute_command_arparse.py <SANDBOX_ID> <TEST_ID> <TEST_DATA> |
| 4 | +
|
| 5 | +Jenkins command step example: |
| 6 | +python execute_command_arparse.py %SANDBOX_ID% "Jenkins Test Name" "Custom Data String" |
| 7 | +""" |
| 8 | +import argparse |
| 9 | +from cloudshell.api.cloudshell_api import CloudShellAPISession, InputNameValue |
| 10 | + |
| 11 | +DEFAULT_REPORTING_SERVICE_ALIAS = "Reporting Service" |
| 12 | + |
| 13 | + |
| 14 | +def set_test_data(cs_api: CloudShellAPISession, sb_id: str, test_id: str, test_data: str): |
| 15 | + """ |
| 16 | + wrapper that calls the set_test_data command on reporting service shell |
| 17 | + See here for command signature reference: |
| 18 | + https://github.com/QualiSystemsLab/CustomJobReporting-Service/blob/88403e9b714cc69101107f0dc22917173ea7b3bd/reporting-service/src/driver.py#L227 |
| 19 | + """ |
| 20 | + inputs = [InputNameValue("test_id", test_id), |
| 21 | + InputNameValue("test_data", test_data)] |
| 22 | + |
| 23 | + cs_api.ExecuteCommand(reservationId=sb_id, |
| 24 | + targetName=DEFAULT_REPORTING_SERVICE_ALIAS, |
| 25 | + targetType="Service", |
| 26 | + commandName="set_test_data", |
| 27 | + commandInputs=inputs, |
| 28 | + printOutput=True) |
| 29 | + |
| 30 | + |
| 31 | +if __name__ == "__main__": |
| 32 | + api = CloudShellAPISession(host="localhost", username="admin", password="admin", domain="Global") |
| 33 | + parser = argparse.ArgumentParser() |
| 34 | + parser.add_argument("sandbox_id") |
| 35 | + parser.add_argument("test_id") |
| 36 | + parser.add_argument("test_data") |
| 37 | + args = parser.parse_args() |
| 38 | + |
| 39 | + set_test_data(api, args.sandbox_id, args.test_id, args.test_data) |
0 commit comments