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 Compute Classic

  • 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 Compute Classic. See How to Begin with Compute Classic Subscriptions in Using Oracle Cloud Infrastructure Compute Classic.

  • Understand the features of the service. See About Compute Classic in Using Oracle Cloud Infrastructure Compute Classic.

  • Be familiar with the Compute Classic terminology. See Compute Classic Terminology in Using Oracle Cloud Infrastructure Compute Classic.

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

    • To create, update, and delete Compute Classic 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 Compute Classic Roles in Using Oracle Cloud Infrastructure Compute Classic.

    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.

System Requirements and Supported Platforms

Ensure that the system on which you’re going to install the CLI is on a supported platform and meets the specified requirements.

Supported Platforms

  • Oracle Linux 6.6, 6.7, and 7.1

  • OSX 10.12.6

  • RedHat Enteprise Linux 6.7 and 7.1

  • Ubuntu 16 and 17

  • CentOS 7

  • Windows Server 2008 R2 and 2012 R2

System Requirements for Linux Systems

  • Python 2 (2.6.6 or later) must be pre-installed.

  • The python-dateutil module is required and it is installed automatically when you use yum.

Installing the CLI

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: opc-cli-RELEASE.x86_64.rpm
      inflating: README
      inflating: linux/
      inflating: linux/opc
      inflating: darwin/
      inflating: darwin/opc
      inflating: windows/
      inflating: windows/opc.exe
    
  3. You can install the CLI in one of the following ways.

    • By copying the binary file to an appropriate location.

      • On Oracle Linux, RedHat Enteprise Linux, Ubuntu, CentOS systems:

        sudo cp ./linux/opc /usr/bin
      • On Mac OSX systems:

        sudo cp ./darwin/opc /usr/bin
      • On Windows systems, update the value of the existing PATH environment variable to point to the location where the windows/opc.exe file is available on your system. For information about updating environment variables on a Windows system, refer to your Windows documentation.

    • By installing the RPM file on Oracle Linux, RedHat Enteprise Linux, and CentOS systems.

      1. Run the following command.

        sudo yum install ./opc-cli-RELEASE.rpm
        
      2. When prompted, enter y.

        Wait till you see the Complete! message.

        Installed:
          opc_cli-RELEASE.x86_64
        
        Complete!
  4. 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. Identify the type of cloud account that you are using: Traditional Cloud Accounts (also known as Cloud Service Accounts) or Cloud Accounts with Identity Cloud Service (IDCS). See Types of Oracle Cloud Accounts in Getting Started with Oracle Cloud.

    Note:

    Oracle Cloud Machine only supports Cloud Accounts with Identity Cloud Service (IDCS).

  2. Note down the account credentials for your Compute Classic instance.

    • On Oracle Cloud Machine: The account creation email from Oracle would contain the user name and password for your Compute Classic instance.

    • On Oracle Cloud: The account creation email from Oracle would contain the identity domain name, user name, and password for your Compute Classic 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.

  3. 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 Cloud Infrastructure Compute Classic.

  4. While running CLI commands, you have to pass a two-part user name. Specify the two-part user name in one of the following ways:

    • On Oracle Cloud: If you are using a traditional cloud account or if your account creation email contains information about the identity domain, then you must use the following format for the two-part user name:

      /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

    • On Oracle Cloud Machine: If you are using a cloud account with Identity Cloud Service (IDCS) or if your account creation email does not contain information about the identity domain, then you must use the following format for the two-part user name:

      /Compute-serviceInstanceID/username

      To get the service instance ID for your Compute Classic instance:

      1. Sign in to the Oracle Cloud My Services application. See Signing in to Your Cloud Account in Getting Started with Oracle Cloud.

        The Oracle Cloud My Services Dashboard page is displayed. It lists the services that are assigned to your account.

      2. In the Compute service tile, click Compute. The Service Details page for Compute Classic is displayed.

      3. Under Additional Information, note down the Service Instance ID.

        For example, if your service instance ID is 575260584 and the username in your account-creation email is jack.jones@example.com, then use the following two-part user name for REST API calls:

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

    Note:

    All examples in this document use /Compute-acme/jack.jones@example.com as the two-part user name. If you are using a Cloud Account with IDCS, replace acme in the two-part user name with your service instance ID.

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

    • On Windows system, ensure the file containing the password is a read-only file.

    • On other systems, ensure that the file containing the password isn't world-readable, by changing the permission to 600.

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

  7. 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,
        "http-proxy":"http://www-proxy.example.com:80",
        "https-proxy":"https://www-proxy.example.com:80"
      },
      "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.

  8. Ensure that the profile file isn't world-readable, by changing the permission to 600.
    chmod 600 /full/path/to/profile/file
    
  9. 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"
  10. 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"
  11. Understand the syntax of opc compute CLI commands. See General Syntax of opc compute Commands. You can now run the Compute Classic CLI commands.

  12. (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'
  13. 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.