Skip to main content

Control Orka clusters and the macOS VMs they run.

Project description

orka-python-sdk

An SDK for interacting with Orka clusters and the macOS VMs they run.

Contents

Installation

pip install orka_sdk

Authentication

Get token

from orka_sdk.orka_sdk import OrkaSDK

orka = OrkaSDK()
orka.login(user='user@email.com', password='password',license_key='license-key')

Revoke token

orka.revoke_token()

VM Management

Define and create a VM

# Define a VM
vm_data = {
	'vm_name': 'fake-name',
	'orka_base_image': 'my-image.img',
	'core_count': '3',
	'vcpu_count': '3'
	}

# Create a VM
r = orka.create_vm(vm_data)  
vm = r.data

Get VM by id

r = orka.get_vm_by_id('<vm_id>')
vm = r.data

Get VM by name

r = orka.get_vm_by_name('<vm_name>')
vm = r.data

Iterate over all VMs in system and execute a remote command on each

r = orka.list_system_vms()
for vm in r.data:
	r = vm.exec('printenv')

Commit current state of deployed VM to base image and clean up

orka.commit_vm_state_to_base_image(vm)
orka.purge_vm(vm)

Save a deployed VM's state as an Image

r = orka.save_vm_as_image('new-image.img', vm)

Commit VM state to base image

r = orka.commit_vm_state_to_base_image()

Purge VM

r = orka.purge_vm(vm)

Delete VM

r = orka.delete_vm(vm)

Start VM

r = orka.start_vm(vm)

Stop VM

r = orka.stop_vm(vm)

Suspend VM

r = orka.suspend_vm(vm)

Resume VM

r = orka.resume_vm(vm)

Revert VM

r = orka.revert_vm(vm)

Get VM status

r = orka.get_vm_status(vm)

VM Instances

VM Properties

Name Description
ip The ip address of the deployed VM
name The VM's name
ssh_port The VM's ssh port
id The VM's unique id
ram Available RAM
vcpu Virtual CPU count
cpu CPU count
io_boost I/O boost enabled
use_saved_state Used saved VM state at boot
gpu_passthrough GPU passthrough to host Node GPU enabled
screen_share_port The VM's screen share port
vnc_port The VM's vnc port
ssh_client Paramiko ssh client associated with the VM
sftp_client Paramiko ssh client associated with the VM
ssh_user The SSH user associated with the VM
ssh_pass The SSH password associated with the VM

VM Methods

upload()

Upload a file to a deployed VM

local_path = '/local/file/path'
dest_path = '/remote/file/path'

# Upload file
r = vm.upload(local_path, dest_path)

# Confirm success
r = vm.exec(f'cat {dest_path}')
print(r.data['stdout'])

download()

Download a file from a deployed VM

remote_path = '/remote/file/path'
local_path = '/local/file/path'
r = vm.download(remote_path, local_path)

exec()

Execute a remote command on a deployed VM

r = vm.exec('printenv')
print(r.data['stdout'])

write_persistent_env_var()

Write an env var export statement to a deployed VM's .zshenv or elsewhere

data = {'FOO': 'bar'}
r = vm.write_persistent_env_var(data)

Alternatively, you can also pass a destination filepath, like so:

dest = '/Users/admin/.bash_profile'
data = {'foo': 'bar'}
r = vm.write_persistent_env_var(data=data, dest=dest)

enable_auto_login()

Enable auto-login on a deployed VM

r = vm.enable_auto_login()

create_launch_daemon()

Create a launch daemon that calls an executable at machine startup

data = {'name':'my_launch_daemon', 'path_to_executable': '/path/to/executable'}
r = vm.create_launch_daemon(data)

install_brew_packages()

Install Homebrew packages listed in a Brewfile.

NOTE: Homebrew must be installed on the VM

file_path = '/path/to/Brewfile'
r = vm.install_brew_packages(file_path)

K8s Management

Deploy a k8s service

orka.k8s.create_service('<path/to/yaml/definition>')

Delete a k8s service

orka.k8s.delete_service('<service_name>')

Create a k8s deployment

orka.k8s.create_deployment('<path/to/yaml/definition>')

Delete a k8s deployment

orka.k8s.delete_deployment('<deployment_name>')

Image Management

List images

r = orka.images.list()

Get image by name

r = orka.images.get('<image_name>')

Delete image

r = orka.images.delete('<image_name>')

Node Management

List nodes

r = orka.nodes.list()

Get node status

r = orka.nodes.get_status('<node_name>')

CI/CD Integrations

GitHub Actions Controller

from orka_sdk.gha_controller import GHAController

controller = GHAController()

controller.spin_up()
controller.check_runner_status()
controller.tear_down()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

orka-sdk-1.0.3.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

orka_sdk-1.0.3-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file orka-sdk-1.0.3.tar.gz.

File metadata

  • Download URL: orka-sdk-1.0.3.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.63.0 importlib-metadata/4.8.2 keyring/17.1.1 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.3

File hashes

Hashes for orka-sdk-1.0.3.tar.gz
Algorithm Hash digest
SHA256 d5c928458d3349b8f0e9918a2b92e5e40d1cb12467842d95cbfe8983ed87f821
MD5 b868be07f0db1ebaedbf210665736e08
BLAKE2b-256 4bbdcff6bd06c33fb36fb8c3200f64d061babe49f40fba00a8e6cf78939fbb1c

See more details on using hashes here.

File details

Details for the file orka_sdk-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: orka_sdk-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.63.0 importlib-metadata/4.8.2 keyring/17.1.1 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.3

File hashes

Hashes for orka_sdk-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 49ff46a9e5b0d70c6bf134643cc9e0adf98fe3c9ebed73a28531bd42a63a3273
MD5 07b39621ac2d42facd61f893580c323c
BLAKE2b-256 3fc1c9422dca786af9ce18aebfc60b23ad7ab7892c9c0e2f894c9010e71e6780

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page