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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

Supported by

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