Before 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?
- Valid credentials for an Oracle Cloud account
- An active subscription to Oracle Java Cloud Service
- Python version 3.3 or later. See Performing Prerequisite Tasks for the Command Line Interface
- A public SSH key and its associated private key. See Generating a Key Pair with OpenSSH or Generating a Key Pair with PuTTY
Download
and Install the CLI
You can download the PSM CLI from the web console of any Oracle Platform service. Install the CLI using Python.
- Sign in to Oracle Cloud.
- If your cloud account includes Oracle Identity Cloud
Service, from the Oracle Cloud Infrastructure Console, click the Navigation menu
at the top left corner of the page, expand Identity, and then select Federation.
Record the Identity Service Id. For example,
idcs-35e8456d2e6544e735e8456d2e6544e7
. - From the Oracle Cloud Infrastructure Console, click the Navigation menu
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
, and then select Java.
Tip: You can download the CLI from any Oracle Platform service.
- From the Java Cloud Service console, click your user name in the top right corner of the page.
- Select Help, and then click Download
Center.
Description of the illustration download_center.png - Click the Download icon for the PaaS
Service Manager (PSM) Command Line Interface. Save the file
psmcli.zip
to your computer. - Launch a command shell on your computer.
- 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
- 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 runpip
with a non-administrator user.
Configure
the CLI
- Run the
setup
command.psm setup
- 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
. - Enter your Oracle Cloud Region (
us
oremea
). - Enter your preferred output format. The examples in this
tutorial use
json
. - 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
- List the available Oracle Cloud Stack commands in the CLI
psm stack help
Select
a Stack Template
- Run the
stack list-templates
command.psm stack list-templates
- 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", ... }
- View the definition of the
Oracle-JCS-DBCS-Template
template.psm stack export-template -n Oracle-JCS-DBCS-Template
- 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. ...
Create
a Stack
- Run the
stack create
command. Create a stack namedMyJavaStack
that uses the templateOracle-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.
- From the command output, identify the job ID.
Job ID : 80521
Monitor
Stack Creation
- Run the
stack operation-status
command. Specify the job ID.psm stack operation-status -j job_id
- 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" }, ... ]
- Run the
stack describe
command. Specify the name of your stack.psm stack describe -n MyJavaStack
- From the command output, identify the
state
of your stack. For example:{ "serviceName":"MyJavaStack", "description":"", "state":"INITIALIZING", "stateDetail":"Creating Service ...", ... }
- Run these same commands periodically until the job is finished and your stack is created.