Thursday, October 31, 2019

Frequently Asked Questions About Command Line Interface (CLI) For Oracle Cloud Infrastructure (OCI) (Doc ID 2433795.1)

Click to add to FavoritesTo BottomTo Bottom

In this Document
Purpose
Questions and Answers
 Required Inputs For Configuring Command Line Interface
 1. How to find Tenancy OCID
 2. How to find User OCID
 3. How to get compartment ID
 4. How to find namespace ID using command line
 5. Where to find documentation reference for using commands
 Examples of Using Command Line Interface
 1. How to get list of buckets in OCI console
 2. How to check the objects that can be deleted
 3. How to display database systems in a compartment
 4. How to list backups available for a database instance
 Errors during Installation/Usage of Command Line Interface
 1. Getting error "ZipImportError: can't decompress data" during installation of command line interface
 2. Getting error "ModuleNotFoundError: No module named '_ssl' during installation of command line interface
 3. Executing any oci command shows "The required information to complete authentication was not provided."
 4. Executing any oci command shows "RuntimeError: Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment... This system lists a couple of UTF-8 supporting locales that you can pick from.  The following suitable locales where discovered:"
References


APPLIES TO:

Oracle Cloud Infrastructure - Database Service - Version N/A and later
Information in this document applies to any platform.

PURPOSE

 This document includes frequently asked questions related to usage of command line interface (CLI) for oracle cloud Interface (OCI)

QUESTIONS AND ANSWERS

Required Inputs For Configuring Command Line Interface

1. How to find Tenancy OCID

Login to OCI console. Tenancy OCID can be found at the bottom left side of every page in OCI console.

2. How to find User OCID

Login to OCI console
Expand the username menu in the top-right corner of the Console, and then click User Settings
OCID information is available under "User Information"

3. How to get compartment ID

Login to OCI console
Navigate to Identity --> Compartments
Look OCID under the compartment name
Example of compartment ID: ocid1.compartment.oc1..aaaaaaaax1afaargggggghhhhhhhhhhhhh2bbbbbbbbbbbbbb

4. How to find namespace ID using command line

$ oci os ns get

5. Where to find documentation reference for using commands

Refer the documentation link for usage on oci commands: OCI CLI Command Reference

Examples of Using Command Line Interface

1. How to get list of buckets in OCI console

$ oci os bucket list --compartment-id=<compartment ID>
Sample Output:
$ oci os bucket list --compartment-id=ocid1.compartment.oc1..aaaaaaaax1afaargggggghhhhhhhhhhhhh2bbbbbbbbbbbbbb
{
  "data": [
    {
      "compartment-id": "ocid1.compartment.oc1..aaaaaaaax1afaargggggghhhhhhhhhhhhh2bbbbbbbbbbbbbb",
      "created-by": "ocid1.user.oc1..aaaaaaaajbbbbbbbbbbbbbbbbbbbbjlzdy6xx6ha",
      "defined-tags": null,
      "etag": "84795fbf-1209-40e1-8db0-095403857532",
      "freeform-tags": null,
      "name": "<name>",
      "namespace": "<namespace>",
      "time-created": "2018-08-07T04:06:56.380000+00:00"
    }
  ]
}

2. How to check the objects that can be deleted

$ oci os object bulk-delete -ns <object_storage_namespace> -bn <bucket_name> --dry-run
Sample Output:
=============
$ oci os object bulk-delete -ns <namespace> -bn <bucketname> --dry-run
{
"delete-failures": {},
"deleted-objects": [
"test_delete_bucket.txt"
]
}
=============

3. How to display database systems in a compartment

$ oci db system list --compartment-id <compartment id>
[root@anandu ~]# oci db system list --compartment-id ocid1.compartment.oc1..aaaaaaaax1afaargggggghhhhhhhhhhhhh2bbbbbbbbbbbbbb
{
  "data": [
    {
      "availability-domain": "LBYW:US-ASHBURN-AD-1",
      "backup-subnet-id": null,
      "cluster-name": null,
      "compartment-id": "ocid1.compartment.oc1..aaaaaaaax1afaargggggghhhhhhhhhhhhh2bbbbbbbbbbbbbb",
      "cpu-core-count": 1,
      "data-storage-percentage": 80,
      "data-storage-size-in-gbs": 256,
      "database-edition": "ENTERPRISE_EDITION",
      "defined-tags": {},
      "disk-redundancy": "HIGH",
      "display-name": "<DBSystem>",
      "domain": "sub12191026110.vcndemonetwork.oraclevcn.com",
      "freeform-tags": {},
      "hostname": "<host>",
      "id": "ocid1.dbsystem.oc1.iad.aaaaaaaaaaaaaaaaaaxxxxxxxxxxxwx2y67oewa",
      "last-patch-history-entry-id": null,
      "license-model": "LICENSE_INCLUDED",
      "lifecycle-details": null,
      "lifecycle-state": "AVAILABLE",
      "listener-port": 1521,
      "node-count": 1,
      "reco-storage-size-in-gb": 256,
      "scan-dns-record-id": "ocid1.vcndnsrecord.oc1.iad.aaaaaaaaaaaaaaaaaaaaaxxxxxxxxxxxxxxxxrqiwqlggq",
      "scan-ip-ids": null,
      "shape": "VM.Standard1.1",
      "ssh-public-keys": [
        "<key>"
      ],
      "subnet-id": "ocid1.subnet.oc1.iad.aaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbb12222222222223taivq",
      "time-created": "2018-08-01T06:32:17.477000+00:00",
      "version": "12.2.0.1.180417",
      "vip-ids": null
    }
.
.
   ]
}

4. How to list backups available for a database instance

$ oci db backup list --database-id <database id>
[root@anandu ~]# oci db backup list --database-id ocid1.database.oc1.iad.abuwcljrhciytqvuqijiu2i3xnv2lxufcjh67zk4jkus2hbxxvj3bj67zloa
{
  "data": [
    {
      "availability-domain": "LBYW:US-ASHBURN-AD-1",
      "compartment-id": "ocid1.compartment.oc1..aaaaaaaax1afaargggggghhhhhhhhhhhhh2bbbbbbbbbbbbbb",
      "database-edition": "ENTERPRISE_EDITION",
      "database-id": "ocid1.database.oc1.iad.awewfewfqqqqqqqqqqqaaaaaaaaaaacjh67zk4jkus2hbxxvj3bj67zloa",
      "db-data-size-in-mbs": null,
      "display-name": "Automatic Backup",
      "id": "ocid1.dbbackup.oc1.iad.aadssafadvsdfgwervaaaaaaaaaaaaaapy4tm3d2lijuqofjq",
      "lifecycle-details": null,
      "lifecycle-state": "ACTIVE",
      "time-ended": "2018-08-28T06:11:08.086000+00:00",
      "time-started": "2018-08-28T06:05:59.637000+00:00",
      "type": "INCREMENTAL"
    }
.
.
  ]
}

Errors during Installation/Usage of Command Line Interface

1. Getting error "ZipImportError: can't decompress data" during installation of command line interface

File "/root/Python-3.6.0/Lib/ensurepip/__init__.py", line 27, in _run_pip
    import pip
zipimport.ZipImportError: can't decompress data; zlib not available
make: *** [install] Error 1
 Zlib-devel package is missing. Ensure required rpm packages are installed on the machine.
Note 2444552.1 - How to configure yum Repository in OCI  Instance

2. Getting error "ModuleNotFoundError: No module named '_ssl' during installation of command line interface

Running install script.
Traceback (most recent call last):
  File "/tmp/oci_cli_install_tmp_sXFq", line 21, in <module>
    import ssl
  File "/usr/local/lib/python3.6/ssl.py", line 101, in <module>
    import _ssl             # if we can't import it, let the error propagate
ModuleNotFoundError: No module named '_ssl'
openssl-devel package is missing. Ensure required rpm packages are installed on the machine.
Note 2444552.1 - How to configure yum Repository in OCI  Instance

3. Executing any oci command shows "The required information to complete authentication was not provided."

Refer the following note for issue with executing oci command:
Note 2444284.1 - Executing Any OCI Commands Using Command Line Interface (CLI) Fails With "The required information to complete authentication was not provided"

4. Executing any oci command shows "RuntimeError: Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment... This system lists a couple of UTF-8 supporting locales that you can pick from.  The following suitable locales where discovered:"

Set the following parameters and run the oci command:
$ export LANG=en_US.utf8
$ export LC_ALL=en_US.utf8
$ ./oci --version

REFERENCES

NOTE:2432759.1 - [OCI]: How to Install and Configure Command Line Interface For Oracle Cloud Infrastructure In Linux
NOTE:2444552.1 - OCI : How to Configure yum Repository in OCI Instance

No comments:

Post a Comment

Database Options/Management Packs Usage Reporting for Oracle Databases 11.2 and later (Doc ID 1317265.1)

  Database Options/Management Packs Usage Report You can determine whether an option is currently in use in a database by running options_pa...