pycloudlib.ibm_classic.cloud module
IBM Cloud type.
- class pycloudlib.ibm_classic.cloud.IBMClassic(tag: str, timestamp_suffix: bool = True, config_file: Path | StringIO | None = None, *, username: str | None = None, api_key: str | None = None, domain_name: str | None = None)[source]
Bases:
BaseCloudIBM Classic Class.
- __init__(tag: str, timestamp_suffix: bool = True, config_file: Path | StringIO | None = None, *, username: str | None = None, api_key: str | None = None, domain_name: str | None = None)[source]
Initialize base cloud class.
- Parameters:
tag – string used to name and tag resources with
timestamp_suffix – Append a timestamped suffix to the tag string.
config_file – path to pycloudlib configuration file
username – IBM Classic specific username for API
api_key – IBM Classic specific API key
domain_name – Domain name to use for creating instance FQDNs
- clean() List[Exception][source]
Cleanup ALL artifacts associated with this Cloud instance.
Cleanup any cloud artifacts created at any time during this class’s existence. This includes all instances, snapshots, resources, etc.
- Returns:
A list of exceptions that occurred during cleanup.
- create_default_security_groups() Tuple[int, int][source]
Create default security groups.
To make this extensible for all users, security groups and rules are created on the fly. A unique security group is created for each instance so that it can be torn down later without affecting other instances. The security group is named after the instance tag. The public security group allows inbound ssh traffic and all outbound traffic. The private security group allows all inbound and outbound traffic.
- Returns:
A Tuple containing the IDs of the two created security groups in the order (public, private).
- daily_image(release: str, **kwargs)[source]
ID of the latest daily image for a particular release.
- Parameters:
release – The release to look for
- Returns:
A single string with the latest daily image ID for the specified release.
- delete_image(image_id: str, **kwargs)[source]
Delete an image.
- Parameters:
image_id – string, ID (not GID) of the image to delete.
- get_image_id_from_name(name: str) str[source]
Get the id of the first image whose name contains the given name.
The name does not need to be an exact match, just a substring of the image name.
- Parameters:
name – string, name of the image to search for
- Returns:
string, image ID
- get_instance(instance_id, **kwargs) BaseInstance[source]
Get an instance by id.
- Parameters:
instance_id – ID identifying the instance
- 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: str = 'B1_2X4', user_data=None, *, name: str | None = None, disk_size: Literal['25G', '100G'] = '25G', datacenter_region: str = 'dal', datacenter: str | None = None, **kwargs) BaseInstance[source]
Launch an instance.
- Parameters:
name – name of the instance
image_id – image ID to use for the instance. Can accept either an ID or a GID.
instance_type – type of instance to create. This value is
For (combined with the disk_size to create the instance flavor.)
example
"B1_2X4X25". (B1_2X4 with disk_size of 25G would result in)
user_data – cloud-init user data to pass to the instance
datacenter_region – region to launch the instance in. This will automatically select a datacenter in the region if “datacenter” is not provided.
datacenter – datacenter to launch the instance in. If not provided, “datacenter_region” will be used. If both are provided, “datacenter” will be used.
**kwargs – dictionary of other arguments to pass to launch
- Returns:
An instance object to use to manipulate the instance further.
- list_keys()[source]
List ssh key names present on the cloud for accessing instances.
- Returns:
A list of strings of key pair names accessible to the cloud.