23 Machine Image

This section describes the Compute Classic CLI commands that you can use to create, delete, and view machine images.

Commands

A machine image is a template of a virtual hard disk of a specific size with an installed operating system. You use machine images to create virtual machine instances in Compute Classic.

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.

machine-image add

Adds a machine image to Compute Classic.

Before performing this task, you must upload your machine image file to Compute Classic. Make a note of the name of the .tar.gz file that you have uploaded. You'll need to provide this name while adding a machine image to Compute Classic. For more information, see Uploading Machine Image Files to Oracle Cloud Infrastructure Object Storage Classic in Using Oracle Cloud Infrastructure Compute Classic.

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 machine-image add name file [--attributes="attributes"] [--description 'description'] [--account /Compute-IdentityDomain/cloud_storage]

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

Example

opc -f json compute machine-image add /Compute-acme/jack.jones@example.com/prodimages oraclelinux-x64.img.tar.gz --attributes="platform=linux"

Sample Output

{
   "account": "/Compute-acme/cloud_storage", 
   "name": "/Compute-acme/jack.jones@example.com/prodimages", 
   "sizes": {
    "uploaded": 2641539583, 
    "total": 2641539583, 
    "decompressed": 22020096000
   },
   "uri": "http://api.compute.us0.oraclecloud.com/machineimage/Compute-acme/jack.jones@example.com/prodimages", 
   "quota": null,
   "platform": "linux", 
   "no_upload": true, 
   "state": "available", 
   "signed_by": null, 
   "file": "http://api.compute.us0.oraclecloud.com:443/machineimage/Compute-acme/jack.jones@example.com/oraclelinux-x64",
   "signature": "", 
   "checksums": {}, 
   "attributes": {"platform": "linux"}, 
   "error_reason": "",
   "image_format": "raw", 
   "audited": null
}

machine-image list

Retrieves details of all the machine images in the specified container.

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 machine-image list container

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

Example

opc -f table -F name,state compute machine-image list /oracle/public

Sample Output

Note that this output is merely an example. The machine images that are displayed when you run this command may be different.

+-------------------------------------------------------------+-----------+
                             NAME                             |   STATE   
+-------------------------------------------------------------+-----------+
 /oracle/public/oel_6.4_20GB                                  | available 
 /oracle/public/oel_6.4_2GB                                   | available 
 /oracle/public/oel_6.4_2GB                                   | available 
 /oracle/public/corente_gateway_images-9.4.141a               | available 
 /oracle/public/OL-6.4-20GB-x11-RD                            | available 
 /oracle/public/OL-6.4-20GB-x11-RD_2                          | available 
+-------------------------------------------------------------+-----------+

machine-image 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 machine-image discover container

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

Example

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

Sample Output

{
 "result": [
/Compute-acme/jack.jones@example.com/oraclelinux-x64 
 ]
}

machine-image get

Retrieves details of the specified machine image.

You can use the get command to verify whether the add operation was completed successfully. Use the -F option (for example, -F state) to filter the output for specific attributes.

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 machine-image get name

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

Example

opc -f json compute machine-image get /Compute-acme/jack.jones@example.com/oraclelinux-x64

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/cloud_storage",
   "name": "/Compute-acme/jack.jones@example.com/oraclelinux-x64",
   "sizes": {
    "uploaded": 2641539583,
    "total": 2641539583,
    "decompressed": 22020096000
   },
   "uri": "https://api-z999.compute.us0.oraclecloud.com/machineimage/Compute-acme/jack.jones@example.com/oraclelinux-x64",
   "quota": null,
   "platform": "linux",
   "no_upload": true,
   "state": "available",
   "signed_by": null,
   "file": "https://api-z999.compute.us0.oraclecloud.com:443/machineimage/Compute-acme/jack.jones@example.com/oraclelinux-x64",
   "signature": "",
   "checksums": {},
   "attributes": {},
   "error_reason": "",
   "image_format": "raw",
   "audited": null
 }

machine-image delete

Deletes a machine image. No response is returned.

When you no longer need a machine image that you’ve registered in Compute Classic, you can delete the image.

You can’t delete system-provided machine images that are available in the /oracle/public container.

Prerequisites

  • Ensure that the machine image you want to delete isn’t used in any orchestration.

    Caution:

    If you delete a machine image that’s used in an orchestration, then when that orchestration is stopped and re-started, the instances won’t be created.

Deleting an image removes the image from your Compute Classic account. However, the image file in your Oracle Cloud Infrastructure Object Storage Classic account is not deleted. You can register this image in your Compute Classic account again later, if required. You'll only need to remember the name of the .tar.gz image file that is available in your Oracle Cloud Infrastructure Object Storage Classic account. For instructions to permanently remove a machine image file from Oracle Cloud Infrastructure Object Storage Classic, see the Deleting Machine Image Files from Oracle Cloud Infrastructure Object Storage Classictutorial.

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 machine-image delete name

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

Example

opc compute machine-image delete /Compute-acme/jack.jones@example.com/oraclelinux-x64