run-oci-cli-command icon indicating copy to clipboard operation
run-oci-cli-command copied to clipboard

Question: db autonomous-database generate-wallet

Open norman-aberin opened this issue 2 years ago • 6 comments

Can we use this GitHub plugin to generate a wallet using the oci-cli. To be exact: db autonomous-database generate-wallet?

norman-aberin avatar Oct 12 '23 01:10 norman-aberin

You should be able to run any command with this Action that you you can using oci manually, though you'll need to work out how to securely retrieve the wallet once it has been created.

Djelibeybi avatar Oct 12 '23 03:10 Djelibeybi

I am currently facing the following issue when downloading the wallet, any pointers as to how to resolve the following?

Run oracle-actions/[email protected]
Installing Oracle Cloud Infrastructure CLI
Executing Oracle Cloud Infrastructure CLI command
/home/runner/.local/bin/oci db autonomous-database generate-wallet --autonomous-database-id ocid1.autonomousdatabase.oc1.phx.<redacted> --password .<redacted> --file ./wallet.zip --debug
DEBUG:oci_cli.cli_metrics: 2023-10-12 01:40:01.712259: Metrics is not enabled
Linux-6.2.0-1012-azure-x86_64-with-glibc2.35
System name: Linux
System release : 6.2.0-1012-azure
System version: #12~22.04.1-Ubuntu SMP Thu Sep  7 14:07:14 UTC 2023

DEBUG:oci_cli.cli_util:user: Environment Variable
DEBUG:oci_cli.cli_util:fingerprint: Environment Variable
DEBUG:oci_cli.cli_util:key_content: Environment Variable
DEBUG:oci_cli.cli_util:tenancy: Environment Variable
DEBUG:oci_cli.cli_util:region: Environment Variable or Parameter
DEBUG:oci.base_client.140040220140224:Endpoint: https://database.***.oraclecloud.com/20160918
INFO:oci.base_client.140040220140224: 2023-10-12 01:40:02.500547: Request: POST https://database.***.oraclecloud.com/20160918/autonomousDatabases/ocid1.autonomousdatabase.oc1.phx.<redacted>/actions/generateWallet
DEBUG:oci.base_client.140040220140224: 2023-10-12 01:40:05.086241: time elapsed for request 3E46A7BD8C634192A681BF53C09F7635: 2.585572424999981
DEBUG:oci.base_client.140040220140224: 2023-10-12 01:40:05.086378: time elapsed in response: 0:00:02.582429
DEBUG:oci.base_client.140040220140224: 2023-10-12 01:40:05.086421: Response status: 200
DEBUG:oci.base_client.140040220140224: 2023-10-12 01:40:05.086463: Response returned
DEBUG:oci.base_client.140040220140224:time elapsed for request: 2.58596[13](https://github.com/naberin/dboperator-github-actions/actions/runs/6490172282/job/17625567208#step:3:14)310000213
env OCI_CLI_USER is set
env OCI_CLI_TENANCY is set
env OCI_CLI_FINGERPRINT is set
env OCI_CLI_KEY_CONTENT is set
env OCI_CLI_REGION is set
env OCI_PYTHON_SDK_NO_SERVICE_IMPORTS is set
Not using Expect header...
send: b'POST /20160918/autonomousDatabases/ocid1.autonomousdatabase.oc1.phx.<redacted>/actions/generateWallet HTTP/1.1\r\nuser-agent: Oracle-PythonSDK/2.112.4 (python 3.10.12; x86_64-Linux) Oracle-PythonCLI/3.33.4\r\naccept-encoding: gzip, deflate\r\naccept: application/octet-stream\r\nconnection: keep-alive\r\ncontent-type: application/json\r\nopc-request-id: 3E46A7BD8C634192A681BF53C09F7635\r\nopc-retry-token: hsWWAcNd6ImJWeLei25N1Llpv8CeHJ\r\nopc-client-retries: true\r\nopc-client-info: Oracle-PythonSDK/2.112.4\r\nContent-Length: 28\r\ndate: Thu, 12 Oct 2023 01:40:02 GMT\r\nhost: database.***.oraclecloud.com\r\nx-content-sha256: QKhXfdlDJyS6Uj5wFX12MrryNi0Q9kspEHqGBbN9UBs=\r\nauthorization: Signature algorithm="rsa-sha256",headers="date (request-target) host content-length content-type x-content-sha256",keyId="***/***/***",signature="foj1DwOXTsXfHdPqYhiEYJkWIICn7AA23AS+eB82hxjwLpGE/9QLk4BWA1b4CeFOl51UR+s3Z8y9tR6rMn7PMLEqHdC2HjNSb+t2IycFlIuv1E7ixRjUAtfVRlwq4Dju7Mz45GmeHU7FNOrOxBGx5iT2jy80kOIhyubf+iQjHXdqcSzZ2nQV4raziYXpt4ESxO3OwYSeO1hSwm0OhSp0crrSUhgK+YMk1ZdVejQ2/H7aXihtki/iHR08eZF1YuLc1dGJw2+IF8czfeQmHzsUd95zBMYzVpJo28D+UGTRoh6ODUKBXtA2KLWMuB10eK8I9CeLLkJJt9YZkCVPQWTa7w==",version="1"\r\n\r\n{"password": "Welcome54321"}'
reply: 'HTTP/1.1 200 OK\r\n'
header: Date: Thu, 12 Oct 2023 01:40:03 GMT
header: opc-request-id: 3E46A7BD8C634192A681BF53C09F7635/F5E92730185F091E9F9A5AA50D39B528/11E6DF64D191BC7CABDBA2B28B750A5F
header: ETag: ADF19741FE19BD17244B29EA3B5764677262DA41250EB3B2FFFBEB1C[66](https://github.com/naberin/dboperator-github-actions/actions/runs/6490172282/job/17625567208#step:3:68)7E3F60
header: created-on: 2023-10-12 01:40:04.8[75](https://github.com/naberin/dboperator-github-actions/actions/runs/6490172282/job/17625567208#step:3:77)
header: Content-Disposition: attachment; filename = dbdebug01
header: Content-Type: application/octet-stream
header: X-Content-Type-Options: nosniff
header: Strict-Transport-Security: max-age=31536000; includeSubDomains;
header: Content-Length: 21[99](https://github.com/naberin/dboperator-github-actions/actions/runs/6490172282/job/17625567208#step:3:101)9
Downloading file
Error: Unexpected token L in JSON at position 0

norman-aberin avatar Oct 12 '23 15:10 norman-aberin

Ah, I think I knokw what's happening. The action expects a JSON response and not a binary file so it's failing to parse the response from the API. So, my previous comment was only half-right: the command works, it's just that the action doesn't handle the response correctly.

In the meantime, you can probably work around this by using the action to install the CLI but then run it manualliy in the next step so that it doesn't munge the response. Something like this:

- name: Install OCI CLI
  uses: oracle-actions/[email protected]
  id: install-oci-cli
  with:
    command: 'os ns get'

- name: Generate Autonomous Database Wallet
  id: generate-adb-wallet
  run: |
    oci db autonomous-database generate-wallet --autonomous-database-id ${{ secrets.ADB_OCID }} --password ${{ secrets.ADB_WALLET_PWD }} --file ./wallet.zip

You'll need to do something with wallet.zip after this.

Djelibeybi avatar Oct 12 '23 21:10 Djelibeybi

I haven't tested this, so there may be typos so this should just be used as a conceptual guide to how a workaround might be possible. Let me know how it goes.

Djelibeybi avatar Oct 12 '23 21:10 Djelibeybi

Would it be fixed/patched?

norman-aberin avatar Oct 17 '23 17:10 norman-aberin

There are no plans to add this functionality to the action at this time, no.

Djelibeybi avatar Oct 18 '23 00:10 Djelibeybi