From 35d5a6eba105783d4685431757185489d136f106 Mon Sep 17 00:00:00 2001 From: Adrian Png Date: Thu, 5 Sep 2019 19:55:37 -0700 Subject: [PATCH 1/5] Support for OCI --- .devcontainer/Dockerfile | 1 + .devcontainer/devcontainer.json | 3 +++ .gitignore | 3 ++- README.md | 4 ++++ docs/support-for-oci.md | 21 +++++++++++++++++++++ 5 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 docs/support-for-oci.md diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 3ab426e..fac1e53 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -30,6 +30,7 @@ RUN yum install -y \ python3 -m pip install \ pylint \ cx_Oracle \ + oci \ --upgrade USER ${USERNAME} \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 10b92f7..4f14409 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -15,6 +15,9 @@ // Uncomment the next line to use Docker from inside the container. See https://aka.ms/vscode-remote/samples/docker-in-docker for details. // "-v","/var/run/docker.sock:/var/run/docker.sock", + // Uncomment the next line to mount the user's .oci directory that contains the OCI API key and config files. + // "-v", "${env:HOME}${env:USERPROFILE}/.oci:/home/vscode/.oci", + // Uncomment the next line if you will be using a ptrace-based debugger like C++, Go, and Rust. // "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" diff --git a/.gitignore b/.gitignore index 3be041e..cf28cc0 100644 --- a/.gitignore +++ b/.gitignore @@ -211,4 +211,5 @@ $RECYCLE.BIN/ # End of https://www.gitignore.io/api/node,java,linux,macos,maven,windows,visualstudiocode *.ora -.wallets \ No newline at end of file +.wallets +.oci \ No newline at end of file diff --git a/README.md b/README.md index 7a86a77..85a7cbe 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,10 @@ A debug configuration has been created. See [`launch.json`](.vscode/launch.json) Developers are encouraged to store database credentials safely in encrypted Oracle Wallets, as oppose to storing them in plaintext either within the Python script or as environment variables. Follow the [*Oracle Database Connection with Oracle Wallet*](docs/oracle-database-connection-with-oracle-wallet.md) guide. +### Support for Oracle Cloud Infrastructure + +See [support-for-oci.md](docs/support-for-oci.md). + ## Credits The beauty of [Open Source](https://opensource.org/) is that we can learn and build on top of previous knowledge shared by others. I wish to thank the following projects that have guided the creation of this starter kit: diff --git a/docs/support-for-oci.md b/docs/support-for-oci.md new file mode 100644 index 0000000..1393eee --- /dev/null +++ b/docs/support-for-oci.md @@ -0,0 +1,21 @@ +# Support for Oracle Cloud Infrastructure + +The starter kit now comes with the [Oracle Cloud Infrastructure](https://cloud.oracle.com) (OCI) [Python SDK](https://oracle-cloud-infrastructure-python-sdk.readthedocs.io) preinstalled. + +1. Follow the instructions on OCI's [Tools Configuration](https://docs.cloud.oracle.com/iaas/Content/ToolsConfig.htm) page to generate, upload the API key and configure the SDK. +1. Place the API key and `config` file in a subdirectory `.oci`, under the home directory of the user. In Mac and Linux, the home directory is expressed by the environment variable `$HOME`, and in Windows, `%USERPROFILE%`. +1. Uncomment the following line in [devcontainer.json](../.devcontainer/devcontainer.json): + ```json + "-v", "${env:HOME}${env:USERPROFILE}/.oci:/home/vscode/.oci", + ``` + +Running the following Python code should return the user object if the SDK is configured correctly: + +```python +import oci + +config=oci.config.from_file("~/.oci/config", "DEFAULT") +identity = oci.identity.IdentityClient(config) +user = identity.get_user(config["user"]).data +print(user) +``` \ No newline at end of file From dbc73fa7732aec96e295d666cf49b25e80b73a01 Mon Sep 17 00:00:00 2001 From: Adrian Png Date: Thu, 5 Sep 2019 19:57:55 -0700 Subject: [PATCH 2/5] Minor documentation edit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 85a7cbe..45e929b 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ Developers are encouraged to store database credentials safely in encrypted Orac ### Support for Oracle Cloud Infrastructure -See [support-for-oci.md](docs/support-for-oci.md). +See [*Support for Oracle Cloud Infrasturcture Guide*](docs/support-for-oci.md). ## Credits From 80abe032f772b990815888ef8eb2d091c374cedf Mon Sep 17 00:00:00 2001 From: Adrian Png Date: Thu, 5 Sep 2019 21:36:23 -0700 Subject: [PATCH 3/5] Added OCI Python SDK to list of components --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 45e929b..92d48e6 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ The starter kit runs a Docker container with the following components for Python * Oracle SQL*Plus * Python 3.x * [cx_Oracle](https://oracle.github.io/python-cx_Oracle/) +* [Oracle Cloud Infrastructure](https://cloud.oracle.com) (OCI) [Python SDK](https://oracle-cloud-infrastructure-python-sdk.readthedocs.io) * Git * Microsoft's [Python extension for VS Code](https://marketplace.visualstudio.com/items?itemName=ms-python.python) * [pylint](https://www.pylint.org/) From 4612f531b7e8fe8bc8533fabb9abcf18ec7a7a46 Mon Sep 17 00:00:00 2001 From: Adrian Png Date: Sat, 7 Sep 2019 09:54:49 -0700 Subject: [PATCH 4/5] Moved packages cx_Oracle and oci to be installed using requirements.txt --- .devcontainer/Dockerfile | 2 -- .devcontainer/devcontainer.json | 2 +- requirements.txt | 2 ++ 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index fac1e53..194ee5a 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -29,8 +29,6 @@ RUN yum install -y \ chmod 0440 /etc/sudoers.d/$USERNAME && \ python3 -m pip install \ pylint \ - cx_Oracle \ - oci \ --upgrade USER ${USERNAME} \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 4f14409..1d23248 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -43,7 +43,7 @@ }, // Installs any dependencies if "requirements.txt" exists in workspace root. - "postCreateCommand": "if [[ -f requirements.txt ]]; then python3 -m pip install -r requirements.txt; fi;", + "postCreateCommand": "if [[ -f requirements.txt ]]; then sudo python3 -m pip install -r requirements.txt; fi;", // Add the IDs of any extensions you want installed in the array below. "extensions": [ "ms-python.python" ] diff --git a/requirements.txt b/requirements.txt index 343e57d..58f7139 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,3 @@ +cx_oracle +oci # Place any additional Python libraries required that can be found on the [Python Package Index](https://pypi.org/) \ No newline at end of file From b64d9089225090f1ee21f055e35bbaa696ff8b99 Mon Sep 17 00:00:00 2001 From: Adrian Png Date: Sat, 7 Sep 2019 09:56:30 -0700 Subject: [PATCH 5/5] Minor edit --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 58f7139..760e3f0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ cx_oracle oci -# Place any additional Python libraries required that can be found on the [Python Package Index](https://pypi.org/) \ No newline at end of file +# Place any additional Python libraries required that can be found on the [Python Package Index](https://pypi.org/) below this line. \ No newline at end of file