Friday, October 12, 2018

Prepare Config File For Python3 OCI SDK

Refer official doc
  • mkdir ~/.oci/
  • vim config    -----example would be like
[DEFAULT]
user=ocid1.user.oc1..testaaaaaaaa2rwnm5zt2q3kvhjfgrd3w
fingerprint=85:7e:55:e3:cd:63:6a:87:d7:c5:e2:87:40:4e:71:95
key_file=/home/oracle/.oci/oci_api_key.pem
tenancy=ocid1.tenancy.oc1..testestjizbiv4zjm763rbrtd3dfhpjq
compartment_id=ocid1.compartment.oc1..testaaaaatesttest
region=us-phoenix-1
  •  Use below code to load config file for python OCI SDK
>>> from oci.config import from_file
>>> config = from_file()
# Using a different profile from the default location
>>> config = from_file(profile_name="integ-beta")
# Using the default profile from a different file
>>> config = from_file(file_location="~/.oci/config")
#display config setting to see if they are in place
>>> config
{'log_requests': False, 'additional_user_agent': '', 'pass_phrase': None, 'user': 'ocid1.user.oc1..aaaaaaaa2rwntegn3vjf5eg5bp2zuvl7ria', 'fingerprint': '85:7e:03:e3:cd:63:6a:87:d7:66:e2:87:40:4e:71:95', 'key_file': '/home/oracle/.oci/oci_api_key.pem', 'tenancy': 'ocid1.tenancy.oc1..aaaaaatestsetiv4zjm76fhpjq7cmnka', 'compartment_id': 'ocid1.compartment.oc1..aaaaaaaanwshxt3acxczvfsy3ykq', 'region': 'us-phoenix-1'}

No comments: