-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e620a46
commit 652475d
Showing
8 changed files
with
104 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from cudo_compute import cudo_api, Disk, CreateVMBody | ||
from cudo_compute.rest import ApiException | ||
import json | ||
|
||
# Hint: use examples/machine-types.py to find machine_type/data_center_id and gpu_model | ||
# use examples/images.py to get list of OS images for boot_disk_image_id | ||
|
||
try: | ||
disk = Disk(storage_class="STORAGE_CLASS_NETWORK", size_gib=100, | ||
id="my-disk-id") | ||
request = CreateVMBody(vm_id="my-vm-id", machine_type="epyc-rome-rtx-a4000", | ||
data_center_id="no-luster-1", boot_disk_image_id='ubuntu-nvidia-docker', | ||
memory_gib=16, vcpus=4, gpus=1, gpu_model="A4000", boot_disk=disk, | ||
metadata={"group": "a"}) | ||
api = cudo_api.virtual_machines() | ||
vm = api.create_vm(cudo_api.project_id(), request) | ||
|
||
print(json.dumps(vm.to_dict(), indent=2)) | ||
except ApiException as e: | ||
print(e) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from cudo_compute import cudo_api | ||
from cudo_compute.rest import ApiException | ||
import json | ||
|
||
try: | ||
api = cudo_api.virtual_machines() | ||
vm = api.get_vm(cudo_api.project_id(), 'my-vm-id') | ||
print(vm.to_dict()) | ||
except ApiException as e: | ||
print(e) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from cudo_compute import cudo_api | ||
from cudo_compute.rest import ApiException | ||
import json | ||
|
||
try: | ||
api = cudo_api.virtual_machines() | ||
images = api.list_public_vm_images() | ||
print(json.dumps(images.to_dict(), indent=2)) | ||
except ApiException as e: | ||
print(e) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from cudo_compute import cudo_api | ||
from cudo_compute.rest import ApiException | ||
import json | ||
|
||
try: | ||
api = cudo_api.virtual_machines() | ||
vms = api.list_vms(cudo_api.project_id()) | ||
print(json.dumps(vms.to_dict(), indent=2)) | ||
except ApiException as e: | ||
print(e) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from cudo_compute import cudo_api | ||
from cudo_compute.rest import ApiException | ||
import json | ||
|
||
|
||
def machine_types(gpu_model, mem_gib, vcpu_count, gpu_count): | ||
try: | ||
api = cudo_api.virtual_machines() | ||
types = api.list_vm_machine_types(mem_gib, vcpu_count, gpu=gpu_count, gpu_model=gpu_model) | ||
types_dict = types.to_dict() | ||
return types_dict['host_configs'] | ||
except ApiException as e: | ||
raise e | ||
|
||
|
||
def gpu_types(gpu_count): | ||
try: | ||
api = cudo_api.virtual_machines() | ||
types = api.list_vm_machine_types(1, 1, gpu=gpu_count, ) | ||
gpu_list = [] | ||
for gpu in types.to_dict()['gpu_models']: | ||
gpu_list.append(gpu['name']) | ||
return gpu_list | ||
except ApiException as e: | ||
raise e | ||
|
||
|
||
print('Gpu types') | ||
print(json.dumps(gpu_types(1), indent=2)) | ||
|
||
print('Machine types with GPU') | ||
mts = machine_types("", 1, 1, 1) | ||
mt_list = [] | ||
for mt in mts: | ||
mt_list.append( | ||
{'machine_type': mt['machine_type'], 'gpu_model': mt['gpu_model'], 'data_center_id': mt['data_center_id']}) | ||
print(json.dumps(mt_list, indent=2)) | ||
|
||
print('Machine types without GPU') | ||
mts = machine_types("", 1, 1, 0) | ||
mt_list = [] | ||
for mt in mts: | ||
mt_list.append( | ||
{'machine_type': mt['machine_type'], 'data_center_id': mt['data_center_id']}) | ||
print(json.dumps(mt_list, indent=2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from cudo_compute import cudo_api | ||
from cudo_compute.rest import ApiException | ||
|
||
try: | ||
api = cudo_api.virtual_machines() | ||
api.terminate_vm(cudo_api.project_id(), 'my-vm-id') | ||
except ApiException as e: | ||
print(e) |