Compute Abstractions
cloudspells.core.abstractions.compute
Cloud-neutral compute abstractions for CloudSpells multi-cloud support.
Defines the disk descriptor, subnet-tier constants, and the compute interface that all provider implementations must satisfy.
Exports
DiskSpec: Cloud-neutral block-disk descriptor. SubnetTier: Type alias for subnet placement tier literals. SUBNET_PUBLIC, SUBNET_PRIVATE, SUBNET_SECURE, SUBNET_MANAGEMENT: Tier constants shared by all providers. AbstractCompute: Interface for a single VM with attached disks.
DiskSpec
dataclass
Cloud-neutral block-disk descriptor.
Maps to OCI VolumeSpec (vpus_per_gb),
AWS EbsBlockDevice (volume_type + IOPS), or GCP
AttachedDiskInitializeParams (disk_type).
Performance tiers map as follows:
| Tier | OCI | AWS | GCP |
|---|---|---|---|
"low" |
0 VPUs/GB | gp3 3 000 IOPS | pd-standard |
"balanced" |
10 VPUs/GB | gp3 3 000 IOPS | pd-balanced |
"high" |
20 VPUs/GB | io2 32 000 IOPS | pd-ssd |
"ultra" |
120 VPUs/GB | io2 64 000 IOPS | pd-extreme |
Attributes:
| Name | Type | Description |
|---|---|---|
size_in_gbs |
int
|
Disk capacity in GiB. |
label |
str
|
Logical slug used to derive the resource name suffix and to
address the disk via |
performance_tier |
str
|
Workload-tier hint. Accepted values: |
is_read_only |
bool
|
Mount the disk read-only. Defaults to |
Example
from cloudspells.core.abstractions.compute import DiskSpec
data_disk = DiskSpec(size_in_gbs=200, label="data",
performance_tier="high")
log_disk = DiskSpec(size_in_gbs=50, label="logs")
Source code in packages/cloudspells-core/src/cloudspells/core/abstractions/compute.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
AbstractCompute
Bases: ABC
Interface for a single cloud VM with attached block disks.
All provider compute implementations (OCI ComputeInstance, AWS AwsInstance,
GCP GcpInstance) satisfy this interface, allowing cross-cloud
helpers and typed function signatures.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
Output[str]
|
Provider resource ID of the instance. |
ssh_public_key |
str
|
OpenSSH public key installed in
|
ssh_private_key |
str | None
|
Corresponding PEM private key, or |
auto_generated_keys |
bool
|
|
Example
def show_ips(vm: AbstractCompute, label: str) -> None:
pulumi.export(f"{label}_private_ip", vm.get_private_ip())
pulumi.export(f"{label}_id", vm.get_instance_id())
show_ips(oci_vm, "oci_app")
show_ips(aws_vm, "aws_app")
Source code in packages/cloudspells-core/src/cloudspells/core/abstractions/compute.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
get_private_ip() -> pulumi.Output[str]
abstractmethod
Return the private IP address of the instance.
Returns:
| Type | Description |
|---|---|
Output[str]
|
|
Source code in packages/cloudspells-core/src/cloudspells/core/abstractions/compute.py
125 126 127 128 129 130 131 | |
get_instance_id() -> pulumi.Output[str]
abstractmethod
Return the provider resource ID of the instance.
Returns:
| Type | Description |
|---|---|
Output[str]
|
|
Source code in packages/cloudspells-core/src/cloudspells/core/abstractions/compute.py
133 134 135 136 137 138 139 | |
get_disk_id(label: str) -> pulumi.Output[str]
abstractmethod
Return the provider resource ID of the disk with the given label.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The |
required |
Returns:
| Type | Description |
|---|---|
Output[str]
|
|
Raises:
| Type | Description |
|---|---|
KeyError
|
If no disk with the given label exists. |
Source code in packages/cloudspells-core/src/cloudspells/core/abstractions/compute.py
141 142 143 144 145 146 147 148 149 150 151 152 153 | |
get_ssh_public_key() -> str
abstractmethod
Return the SSH public key installed on the instance.
Returns:
| Type | Description |
|---|---|
str
|
OpenSSH public key string (auto-generated or caller-supplied). |
Source code in packages/cloudspells-core/src/cloudspells/core/abstractions/compute.py
155 156 157 158 159 160 161 | |
get_ssh_private_key() -> str | None
abstractmethod
Return the auto-generated SSH private key, or None.
Returns:
| Type | Description |
|---|---|
str | None
|
PEM-encoded private key when auto-generated, |
str | None
|
when the caller supplied their own public key. |
Source code in packages/cloudspells-core/src/cloudspells/core/abstractions/compute.py
163 164 165 166 167 168 169 170 | |
export() -> None
abstractmethod
Publish standard compute stack outputs.
Source code in packages/cloudspells-core/src/cloudspells/core/abstractions/compute.py
172 173 174 | |