Oracle by Example brandingGetting Started with Oracle Cloud Stack from the CLI

section 0Before You Begin

This 30-minute tutorial shows you how to create an Oracle Cloud Stack from the command line. You use a standard template that provisions Oracle Java Cloud Service and Oracle Database Cloud Service.

Background

To build and deploy their applications, businesses often require sophisticated environments that consist of multiple, integrated cloud services. Using templates in Oracle Cloud Stack, you can quickly provision a group of cloud resources called a stack. Oracle Cloud Stack can be accessed from a web console, a REST API, or a command line interface (CLI).

What Do You Need?


section 1Download and Install the CLI

You can download the PSM CLI from the web console of any Oracle Platform service. Install the CLI using Python.

  1. Sign in to Oracle Cloud.
  2. If your cloud account includes Oracle Identity Cloud Service, from the Oracle Cloud Infrastructure Console, click the Navigation menu Dashboard Menu Icon at the top left corner of the page, expand Identity, and then select Federation.

    Record the Identity Service Id. For example, idcs-35e8456d2e6544e735e8456d2e6544e7.

  3. From the Oracle Cloud Infrastructure Console, click the Navigation menu Dashboard Menu Icon at the top left corner of the page, expand Platform Services, and then select Java.

    Note: On some older Oracle Cloud accounts, you use the Oracle Cloud Infrastructure Classic Console. Click the Navigation menu Dashboard Menu Icon, and then select Java.

    Tip: You can download the CLI from any Oracle Platform service.

  4. From the Java Cloud Service console, click your user name in the top right corner of the page.
  5. Select Help, and then click Download Center.
    Download center
    Description of the illustration download_center.png
  6. Click the Download icon for the PaaS Service Manager (PSM) Command Line Interface. Save the file psmcli.zip to your computer.
  7. Launch a command shell on your computer.
  8. If your computer accesses the Internet through a proxy server, then set these environment variables:

    On Windows:

    set http_proxy=proxy_server_URL
    set https_proxy=proxy_server_URL

    On Linux:

    export http_proxy=proxy_server_URL
    export https_proxy=proxy_server_URL

  9. Use the pip tool to install the CLI software to your Python library.
    pip3 install -U psmcli.zip

    On Linux, you might need to use the sudo command to run pip with a non-administrator user.


section 2Configure the CLI

  1. Run the setup command.
    psm setup
  2. Enter your Oracle Cloud Username, Password, and Identity domain.

    If your cloud account includes Oracle Identity Cloud Service, enter your Identity Service Id instead of the domain name. For example, idcs-35e8456d2e6544e735e8456d2e6544e7.

  3. Enter your Oracle Cloud Region (us or emea).
  4. Enter your preferred output format. The examples in this tutorial use json.
  5. If the CLI makes a successful connection to your cloud account, it will list the services available to this account, including Oracle Cloud Stack. For example:
    'psm setup' was successful. Available services are:
       o dbcs : Oracle Database Cloud Service
       o jcs : Oracle Java Cloud Service
       o accs : Oracle Application Container Cloud Service
       o stack : Oracle Cloud Stack Manager
  6. List the available Oracle Cloud Stack commands in the CLI
    psm stack help

section 3Select a Stack Template

  1. Run the stack list-templates command.
    psm stack list-templates
  2. In the command output, locate the details for the template named Oracle-JCS-DBCS-Template.
    {
        "templateName":"Oracle-JCS-DBCS-Template",
        "latestVersion":"1.3.8",
        "description":"Provisions a Stack composed of Java Cloud Service and Database Cloud Service instances using Oracle Storage Cloud Service. **WARNING** You will be billed for the Cloud resources created if you create a Cloud Stack from this template",
        "createdOn":"2018-06-16T08:47:36.169+0000",
        "state":"PUBLISHED",
        "type":"SYSTEM_TEMPLATE",
        ...
    }
    
  3. View the definition of the Oracle-JCS-DBCS-Template template.
    psm stack export-template -n Oracle-JCS-DBCS-Template
  4. Locate the available parameters in the template's definition. For example:
    parameters:
      wlVersion:
        label: JCS Version
        description: Select a JCS Version
        ...
      wlComputeShape:
        label: Compute Shape
        description: Select a Compute Shape for this service.
        ...

section 4Create a Stack

  1. Run the stack create command. Create a stack named MyJavaStack that uses the template Oracle-JCS-DBCS-Template.

    Provide values for these template parameters:

    Parameter Name Value
    commonPwd Your_password
    publicKeyText Your_public_key
    dbStorage 15
    psm stack create -n MyJavaStack -t Oracle-JCS-DBCS-Template -p commonPwd:Your_password publicKeyText:"Your_public_key" dbStorage:15

    Tip: Paste the full contents of your public key file. Do not enter the location of the file on your computer.

  2. From the command output, identify the job ID.
    Job ID : 80521

section 5Monitor Stack Creation

  1. Run the stack operation-status command. Specify the job ID.
    psm stack operation-status -j job_id
  2. Locate the job messages in the command output. For example:
    "messages":[
        {
            "activityDate":"2018-06-29T20:31:57.386+0000",
            "message":"[MyJavaStack] : Service creation request accepted."
        },
        {
            "activityDate":"2018-06-29T20:31:57.408+0000",
            "message":"[MyJavaStack] : Initializing MyJavaStack"
        },
        ...
    ]
  3. Run the stack describe command. Specify the name of your stack.
    psm stack describe -n MyJavaStack
  4. From the command output, identify the state of your stack. For example:
    {
        "serviceName":"MyJavaStack",
        "description":"",
        "state":"INITIALIZING",
        "stateDetail":"Creating Service ...",
        ...
    }
  5. Run these same commands periodically until the job is finished and your stack is created.

more informationWant to Learn More?