1 Preparing to Use the CLI

Before you begin using the CLI, you must install the CLI client and set up a few environment variables as described in this section.

Before You Begin with Oracle Compute Cloud Service

  • Create and configure your account on Oracle Cloud. See Getting an Oracle.com Account in Getting Started with Oracle Cloud.

  • Obtain a trial or paid subscription to Oracle Compute Cloud Service. See How to Begin with Oracle Compute Cloud Service Subscriptions in Using Oracle Compute Cloud Service (IaaS).

  • Understand the features of the service. See About Oracle Compute Cloud Service in Using Oracle Compute Cloud Service (IaaS).

  • Be familiar with the Oracle Compute Cloud Service terminology. See Oracle Compute Cloud Service Terminology in Using Oracle Compute Cloud Service (IaaS).

  • Contact your account administrator and get the required roles assigned to your user name in Oracle Cloud My Services.

    • To create, update, and delete Oracle Compute Cloud Service objects, you must have the Compute_Operations role.

    • To view or retrieve details of objects, you must have the Compute_Monitor or Compute_Operations role.

    For more information, see About Oracle Compute Cloud Service Roles in Using Oracle Compute Cloud Service (IaaS).

    If the required role isn't assigned to you or you're not sure, then ask your system administrator to ensure that the role is assigned to you in Oracle Cloud My Services. See Modifying User Roles in Managing and Monitoring Oracle Cloud.

Installing the CLI

Ensure that the system on which you want to install the CLI has Oracle Linux release 6 (update 3 or later) installed.

To install the CLI:

  1. Download the CLI installation bundle (.zip file) from http://www.oracle.com/technetwork/topics/cloud/downloads/index.html#opccli.

  2. Unzip the CLI installation bundle.

    unzip opc-cli-RELEASE.zip

    RELEASE indicates the release version of the CLI.

    The following files are extracted:

    Archive:  opc-cli-RELEASE.zip
      inflating: README
      inflating: opc-cli-RELEASE.x86_64.rpm
      inflating: linux/opc
    
  3. Go to the directory in which you extracted the ZIP file.

  4. You can install the CLI in one of the following ways.

    • Install the RPM file.

      sudo yum -y install ./opc-cli-RELEASE.x86_64.rpm
      Loaded plugins: aliases, changelog, downloadonly, kabi, presto, refresh-packagekit, security, tmprepo, verify, versionlock
      Loading support for kernel ABI
      
      Setting up Install Process
      Examining ./opc_cli-RELEASE.x86_64.rpm: opc_RELEASE.noarch
      Marking ./opc_cli-RELEASE.x86_64.rpm to be installed
      Resolving Dependencies
      --> Running transaction check
      ---> Package opc_cli.x86_64 0:16.4.6 will be installed
      --> Finished Dependency Resolution
      
      Dependencies Resolved
      =======================================================================================================================
       Package              Arch                 Version                  Repository                              Size
      =======================================================================================================================
      Installing:
       opc_cli             x86_64                RELEASE                  /opc_cli-RELEASE.x86_64              14 M
      
      Transaction Summary
      =====================================================================================================================
      Install       1 Package(s)
      
      Total size: 14 M
      
      Downloading Packages:
      Running rpm_check_debug
      Running Transaction Test
      Transaction Test Succeeded
      Running Transaction
      Installing : opc_cli-RELEASE.x86_64
      Verifying  : opc_cli-RELEASE.x86_64 

      Wait till you see the Complete! message.

      Installed:
        opc_cli-RELEASE.x86_64
      
      Complete!
      

      The CLI is installed.

    • Copy the binary file from /linux/opc to any location of your choice.

  5. Perform the steps described in Quick Start.

Quick Start

Create a profile to store your user name, password, and REST API endpoint URL. The sample commands provided in this section are for the Bash shell. Based on your Linux shell, the commands you should use may vary. For information about other ways to pass the information required to run CLI commands, see Setting Up Environment Variables and Files.

  1. Note down the REST API endpoint URL of your Compute Classic site. To find out the REST API endpoint URL of your site, follow the instructions at Send Requests in REST API for Oracle Compute Cloud Service (IaaS).

  2. Note down your two-part user name (/Compute-identity_domain/user).

    The account creation email from Oracle would contain the identity domain name, user name, and password for your Oracle Compute Cloud Service instance, as shown in the following example:

    Account creation email from Oracle contains the name of the identity domain, user name, and password.

    If you don't have this information, contact your service administrator.

    Note:

    The user name consists of two parts, in the following format:

    /Compute-identity_domain/user

    For example, if your identity domain is acme and the username in your account-creation email is jack.jones@example.com, then the following would be the two-part user name that you must use for running CLI commands:

    /Compute-acme/jack.jones@example.com

  3. Store your password in a plain-text file of your choice (for example, in your /home/user directory).

    Ensure that the file containing the password isn't world-readable, by changing the permission to 600.

    chmod 600 /full/path/to/password/file
    
  4. Create a directory where you want to save your profile file. For example, ~/.opc/profiles.

  5. Create a new file in this folder. In this example, let’s create a profile with the file name profile-jack.

    vi profile-jack
    
    {
      "global": {
        "debug-requests": false
      },
      "compute": {
        "user": "/Compute-identity_domain/user",
        "password-file": "/full/path/to/password/file",
        "endpoint": "api-z999.compute.us0.oraclecloud.com"
      }
    }

    Replace user, password-file, and endpoint with values that are specific to your environment.

  6. Ensure that the profile file isn't world-readable, by changing the permission to 600.
    chmod 600 /full/path/to/profile/file
    
  7. Store the name of the profile file in the OPC_PROFILE_FILE environment variable. The default value of this variable is default which points to the ~/.opc/profile/default profile file.
    export OPC_PROFILE_FILE="name-of-profile-file"
  8. Store the name of the folder in which the profile file is located in the OPC_PROFILE_DIRECTORY environment variable. The default value of this variable is ~/.opc/profiles.

    export OPC_PROFILE_DIRECTORY="/full/path/of/profile-directory"
  9. Understand the syntax of opc compute CLI commands. See General Syntax of opc compute Commands. You can now run the Compute Classic CLI commands.

  10. (Optional.) Create your first storage volume.

    opc compute storage-volumes add /Compute-acme/jack.jones@example.com/MyVolume /oracle/public/storage/default 10G --description 'My first storage volume'
  11. Review the details of your first storage volume.

    opc compute storage-volumes get /Compute-acme/jack.jones@example.com/MyVolume

    After the volume is created, the status field in the response shows online.