pycloudlib.oci.cloud module

OCI Cloud type.

class pycloudlib.oci.cloud.OCI(tag, timestamp_suffix=True, config_file: Union[pathlib.Path, _io.StringIO] = None, *, availability_domain=None, compartment_id=None, config_path=None)[source]

Bases: pycloudlib.cloud.BaseCloud

OCI (Oracle) cloud class.

__init__(tag, timestamp_suffix=True, config_file: Union[pathlib.Path, _io.StringIO] = None, *, availability_domain=None, compartment_id=None, config_path=None)[source]

Initialize the connection to OCI.

OCI must be initialized on the CLI first: https://github.com/cloud-init/qa-scripts/blob/master/doc/launching-oracle.md

Parameters:
  • tag – Name of instance
  • timestamp_suffix – bool set True to append a timestamp suffix to the tag
  • config_file – path to pycloudlib configuration file
  • compartment_id – A compartment found at https://console.us-phoenix-1.oraclecloud.com/a/identity/compartments
  • availability_domain – One of the availability domains from: ‘oci iam availability-domain list’
  • config_path – Path of OCI config file
create_key_pair()

Create and set a ssh key pair for a cloud instance.

Returns:A tuple containing the public and private key created
daily_image(release, operating_system='Canonical Ubuntu')[source]

Get the daily image.

OCI just has periodic builds, so “released” and “daily” don’t really make sense here. Just call the same code for both.

Should be equivalent to the cli call: oci compute image list –operating-system=”Canonical Ubuntu” –operating-system-version=”<xx.xx>” –sort-by=’TIMECREATED’ –sort-order=’DESC’

Parameters:
  • release – string, Ubuntu release to look for
  • operating_system – string, Operating system to use
Returns:

string, id of latest image

delete_image(image_id)[source]

Delete an image.

Parameters:image_id – string, id of the image to delete
get_instance(instance_id)[source]

Get an instance by id.

Parameters:instance_id
Returns:An instance object to use to manipulate the instance further.
image_serial(image_id)[source]

Find the image serial of the latest daily image for a particular release.

Parameters:image_id – string, Ubuntu image id
Returns:string, serial of latest image
launch(image_id, instance_type='VM.Standard2.1', user_data=None, wait=True, **kwargs)[source]

Launch an instance.

Parameters:
Returns:

An instance object to use to manipulate the instance further.

list_keys()

List ssh key names present on the cloud for accessing instances.

Returns:A list of strings of key pair names accessible to the cloud.
released_image(release, operating_system='Canonical Ubuntu')[source]

Get the released image.

OCI just has periodic builds, so “released” and “daily” don’t really make sense here. Just call the same code for both

Parameters:
  • release – string, Ubuntu release to look for
  • operating_system – string, operating system to use
Returns:

string, id of latest image

snapshot(instance, clean=True, name=None)[source]

Snapshot an instance and generate an image from it.

Parameters:
  • instance – Instance to snapshot
  • clean – run instance clean method before taking snapshot
  • name – (Optional) Name of created image
Returns:

An image object

use_key(public_key_path, private_key_path=None, name=None)

Use an existing key.

Parameters:
  • public_key_path – path to the public key to upload
  • private_key_path – path to the private key
  • name – name to reference key by