13 Instance

This section describes the Compute Classic CLI commands that you can use to view and delete instances.

An Compute Classic instance is a virtual machine running a specific operating system and with CPU and memory resources that you specify. See About Instances in Using Oracle Cloud Infrastructure Compute Classic. For information about creating instances, see launch-plan add.

Before running the CLI commands described in this section, make sure that you've installed the CLI client and set up the required environment variables as described in Preparing to Use the CLI.

instance list

Retrieves names of all the instances in the specified container that match the specified query criteria. You can pass one or more query parameters to filter the search results. If you don't specify any query criteria, then names of all the instances in the container are displayed. To retrieve all the details instances, specify the -f json option.

Required Role

To complete this task, you must have the Compute_Monitor or Compute_Operations role. If this 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 Infrastructure Classic Console. See Modifying User Roles in Managing and Monitoring Oracle Cloud.

Syntax

opc compute instance list container [--tags tags] 

For help with the parameters and options of this command, run the command with the -h option.

Example

This command retrieves the names of the instances in the /Compute-acme/jack.jones@example.com container which are tagged production.

opc -f table compute instance list /Compute-acme/jack.jones@example.com --tags production 

Sample Output

+-----------------------------------------------------------------------------------+
|                                       NAME                                        |
+-----------------------------------------------------------------------------------+
 /Compute-acme/jack.jones@example.com/dev-vm/55a30ad5-ddc2-4991-9c17-f02e97e5c36d  
 /Compute-acme/jack.jones@example.com/prod-vm/ee4b020e-deae-41b2-af72-44a6aa13728b 
+-----------------------------------------------------------------------------------+

instance discover

Required Role

To complete this task, you must have the Compute_Monitor or Compute_Operations role. If this 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 Infrastructure Classic Console. See Modifying User Roles in Managing and Monitoring Oracle Cloud.

Syntax

opc compute instance discover container

For help with the parameters and options of this command, run the command with the -h option.

Example

opc -f json compute instance discover /Compute-acme/jack.jones@example.com  

Sample Output

{
 "result": [
  "/Compute-acme/jack.jones@example.com/app1-vm/",
  "/Compute-acme/jack.jones@example.com/app2-vm/",
  "/Compute-acme/jack.jones@example.com/app3-vm/"
 ]
}

instance get

Retrieves details of the specified instance.

Required Role

To complete this task, you must have the Compute_Monitor or Compute_Operations role. If this 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 Infrastructure Classic Console. See Modifying User Roles in Managing and Monitoring Oracle Cloud.

Syntax

opc compute instance get name

For help with the parameters and options of this command, run the command with the -h option.

Examples

The following command retrieves value of the vcable_id parameter for the specified instance.

opc -f table -F vcable_id compute instance get /Compute-acme/jack.jones@example.com/dev2/6073c806-f7da-47eb-9678-6e618931b29a 

Sample Output

+-----------+------------------------------------------------------------------------+
  vcable_id | /Compute-acme/jack.jones@example.com/f7a0859c-caa9-49e2-bf8a-a1c2798d4fe5
+-----------+------------------------------------------------------------------------+

instance update

Updates the status of the instance, as well as the tags and shape associated with the instance.

You can update values for the following instance parameters:

  • desired_state: You can update the value of this parameter to shut down and restart individual instances which use a persistent bootable storage volume. You cannot update this parameter for ephemeral instances.

    • Specify shutdown as the value for desired_state to shut down an instance which is in the running state.

    • Specify running as the value for desired_state to restart an instance that you had previously shutdown. The instance is restarted without losing any of the instance data or configuration.

  • shape: You can update the value of this parameter to change the shape associated with an instance which is in the shutdown state. You cannot change the shape of a running instance.

  • tags: You can update the array of tags that’s associated with an instance.

Shutting down an instance is useful when you've created multiple instances in a single orchestration. In this case, stopping the instance orchestration would cause all instances to be deleted. If you want to stop one or more instances, while letting other instances in the same orchestration run, you can shut down the required instances individually.

Here's what happens when you shut down an instance:

  • The instance ID is retained and reused when you restart the instance. So the multipart instance name doesn't change. This is useful in case the instance name is referenced by other objects, such as storage attachments.

  • For instances created using orchestrations v1, the instance orchestration shows an error. However, even if the HA policy specified is active, the instance isn't automatically re-created.

  • The resources associated with that instance, such as storage volumes and IP reservations, are freed up and can be used by other instances if required. However, if you attempt to restart an instance, ensure that the required resources are available, otherwise the instance can't restart and will go into an error state.

  • The private IP address on the shared network is released. If you restart the instance later, it is allotted a private IP address afresh. So the private IP address of the instance on the shared network is likely to change.

  • Dynamically allocated IP addresses on IP networks are also released. So if you start the instance later, dynamically allocated IP addresses on IP networks are also likely to change. Static private IP addresses that are allocated to interfaces in the instance orchestration won't change.

  • Any changes that you'd made to the instance in Compute Classic after the instance was created will be lost. For example, if you added the instance to security lists, attached storage volumes to the instance, or detached and attached an IP reservation, you'll need to make those changes again. The instance will be restarted with the resources that are associated with it in the instance orchestration.

Note:

Changes made to the instance by logging in to the instance won't be lost, however, as these are preserved on the persistent storage volumes attached to the instance. Data on storage volumes isn't affected by shutting down an instance.

Required Role

To complete this task, you must have the Compute_Operations role. If this 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 Infrastructure Classic Console. See Modifying User Roles in Managing and Monitoring Oracle Cloud.

Syntax

opc compute instance update name [--desired-state running | shutdown] [--tags tags] [--shape shape] 

Many other options may appear in the syntax, but you cannot change the value of these options.

For help with the parameters and options of this command, run the command with the -h option.

Example

This command shuts down the /Compute-acme/jack.jones@example.com/production/dd959b49-60d1-4659-85d3-647722877628 instance which is in the running state and modifies the associated tags.

opc compute instance update /Compute-acme/jack.jones@example.com/production/dd959b49-60d1-4659-85d3-647722877628 --desired-state shutdown --tags 'shutdown instance'

It takes some time for the state of the instance to change. To track the change in the status, run the instance get command.

Sample Output

Some lines have been truncated with ellipses (...) for readability. When you run the command in your environment, you'll see the full output.

account /Compute-acme/default
attributes/dns/domain   compute-acme.oraclecloud.internal.
attributes/dns/hostname b9479d.compute-acme.oraclecloud.internal.
attributes/dns/nimbula_vcable-eth0      b9479d.compute-acme.oraclecloud.internal.
attributes/network/nimbula_vcable-eth0/address  ["c6:b...","10.3..."]
attributes/network/nimbula_vcable-eth0/dhcp_options
attributes/network/nimbula_vcable-eth0/id       /Compute-acme/jack.jones@example.com/58de1c89-a006-494d-88a6-6d5113664c58
attributes/network/nimbula_vcable-eth0/model
attributes/network/nimbula_vcable-eth0/vethernet        /oracle/public/default
attributes/network/nimbula_vcable-eth0/vethernet_id     0
attributes/network/nimbula_vcable-eth0/vethernet_type   vlan
attributes/nimbula_orchestration        /Compute-acme/jack.jones@example.com/production_instance
attributes/sshkeys
availability_domain     /ad1
boot_order      [1]
desired_state   shutdown
disk_attach
domain  compute-acme.oraclecloud.internal.
entry
error_reason
fingerprint
hostname        b9479d.compute-acme.oraclecloud.internal.
hypervisor/mode hvm
image_format    raw
imagelist
ip      0.0.0.0
label   production
name    /Compute-acme/jack.jones@example.com/production/dd959b49-60d1-4659-85d3-647722877628
networking/eth0/dns     ["b9479d.compute-acme.oraclecloud.internal."]
networking/eth0/model
networking/eth0/nat     ippool:/oracle/public/ippool
networking/eth0/seclists        ["/Compute-acme/default/default"]
networking/eth0/vethernet       /oracle/public/default
placement_requirements  ["/system/compute/placement/default","/system/compute/allow_instances"]
platform        linux
priority        /oracle/public/default
quota   /Compute-acme
quota_reservation
relationships
resolvers
reverse_dns     true
shape   oc3
site
sshkeys
start_time      2017-06-30T11:01:24Z
state   shutdown
storage_attachments/0/index     1
storage_attachments/0/volume    /Compute-acme/jack.jones@example.com/production-volume
tags    ["shutdown instance"]
uri     https://api-z999.compute.us0.oraclecloud.com/instance/Compute-acme/jack.jones@example.com
/production/dd959b49-60d1-4659-85d3-647722877628
vcable_id
virtio
vnc

instance delete

Shuts down an instance and removes it permanently from the system. No response is returned.

You can delete instances that is managed by an orchestration. However, if the HA policy for the instance is active, then the instance is re-created as soon as you delete it. To delete an instance which has an active HA policy, you must stop the corresponding orchestration. If you have created an instance by defining a launch plan, then it is not managed by an orchestration and you can delete such an instance by using this command.

Required Role

To complete this task, you must have the Compute_Operations role. If this 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 Infrastructure Classic Console. See Modifying User Roles in Managing and Monitoring Oracle Cloud.

Syntax

opc compute instance delete name

For help with the parameters and options of this command, run the command with the -h option.

Example

opc compute instance delete /Compute-acme/jack.jones@example.com/dev1/6073c806-f7da-47eb-9678-6e618931b29a