1 Getting Started with the Oracle Compute CLI

Oracle Public Cloud Machine supports a customized version of the Oracle Compute Cloud Service (Oracle Compute) command-line interface (CLI). The Oracle Compute CLI supports any action that can be performed by the Oracle Compute REST API. Use the CLI to manage the various Oracle Compute objects. This section gives an overview of the Oracle Compute CLI.

About the Oracle Compute CLI for Oracle Public Cloud Machine

Oracle Compute Cloud service supports oracle-compute CLI tool. Use this tool to view and manage Oracle Compute objects such as instances, storage volumes, and orchestrations.

For more information on Oracle Compute Cloud Services and supported objects, see Getting Started with Using Oracle Compute Cloud Services in Using Oracle Compute Cloud Service.

Roles of CLI Users

The following CLI user roles are supported:
  • Tenant administrator (/tenant_name/username): Administrator for a given tenant. Can perform all the administrative functions for a tenant. Can create users in their tenancy with Tenant User role. The default tenant admin user is /tenant_name/administrator.

  • Tenant user (/tenant_name/username): User of a tenant group. Can create and use VMs and resources within the tenant.

For more information on user roles, see Getting Started with Using Oracle Compute Cloud Services in Using Oracle Compute Cloud Service.

Preparing to Use the Oracle Compute CLI

Before installing the Oracle Compute CLI tools, you must get the API URL of the API server used when installing your Oracle Public Cloud Machine. You can get this information from Oracle Cloud Administrator.

Examples in this guide use the following name for the API server:

api.oc.example.com

Setting Up Environment Variables

Set the environment variables in the shell to avoid having to provide the values in the CLI command.

The following table lists the environment variables, describes each variable, and provides the command to set the variable in the host using a bash shell.

Name Description Command

ORACLE_COMPUTE_API

URL of API endpoint

When this variable isn't set, you must specify a API endpoint with the -a option on the command line.

export ORACLE_COMPUTE_API=API URL

Example:

export ORACLE_COMPUTE_API="https://api.oc.example.com"

To make the environment variable persist across login sessions, add this line to your.bash_profile or .bashrc file.

ORACLE_COMPUTE_USER

The Oracle Compute user name.

When this variable isn't set, you must specify a user name with the -u option on the command line.

export ORACLE_COMPUTE_USER=username

Example:

export ORACLE_COMPUTE_USER="mytenant/user"

To make the environment variable persist across login sessions, add this line to your .bash_profile or .bashrc file.

ORACLE_COMPUTE_COOKIE

The value of an authentication token received from the oracle-compute auth command. See Authenticate User.

export ORACLE_COMPUTE_COOKIE=auth_token

If both ORACLE_COMPUTE_USER and ORACLE_COMPUTE_COOKIE are specified, then ORACLE_COMPUTE_USER takes precedence.

Installing the Oracle Compute CLI on a Remote System

The prerequisites for installing the Oracle Compute CLI on the remote client system are as follows:

  • Client system must have Oracle Linux 6.3 or later.

  • Client system must have Python 2.6 or later but not Python 3.x.

  • The script must have root privileges in the client system.

To install the oracle-compute tool:

  1. Install the prerequisite RPMs: python-simplejson, python-dateutil, python-setuptools.
    sudo yum install python-simplejson python-dateutil python-setuptools
    
  2. Get the installation script and make it executable.
    wget http://API_URL/tools/Linux/install-IaaS-CLI.sh
    chmod 555 install-IaaS-CLI.sh
    
  3. Run the installation script.
    ./install-IaaS-CLI.sh
    

    Use ./install-IaaS-CLI.sh http://API_URL if ORACLE_COMPUTE_API variable isn’t configured.

    Note:

    Use the -f option of the script to force run the script, even if the host isn’t running on a known RedHat OS.

After the installation, the following CLI tool is available:
  • /usr/bin/oracle-compute