Skip to content
This repository was archived by the owner on Mar 4, 2026. It is now read-only.

Commit cf41966

Browse files
Riku Voipiommlb
authored andcommitted
add spot instance support
1 parent 6c65d64 commit cf41966

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

packet/Device.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ def __init__(self, data, manager):
1818
self.locked = data['locked']
1919
self.operating_system = OperatingSystem(data['operating_system'])
2020
self.plan = data['plan']
21+
self.spot_instance = data.get('spot_instance')
22+
self.spot_price_max = data.get('spot_price_max')
2123
self.state = data['state']
2224
self.tags = data['tags']
2325
self.updated_at = data['updated_at']

packet/Manager.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ def create_device(self,
8383
ipxe_script_url='',
8484
locked=False,
8585
public_ipv4_subnet_size=31,
86+
spot_instance=False,
87+
spot_price_max=-1,
8688
tags={},
8789
userdata=''):
8890

@@ -104,6 +106,9 @@ def create_device(self,
104106
params['always_pxe'] = always_pxe
105107
params['ipxe_script_url'] = ipxe_script_url
106108
params['operating_system'] = 'custom_ipxe'
109+
if spot_instance:
110+
params['spot_instance'] = spot_instance
111+
params['spot_price_max'] = spot_price_max
107112
data = self.call_api('projects/%s/devices' % project_id, type='POST', params=params)
108113
return Device(data, self)
109114

@@ -173,3 +178,7 @@ def validate_capacity(self, servers):
173178
return False
174179
else:
175180
raise e
181+
182+
def get_spot_market_prices(self, params={}):
183+
data = self.call_api('/market/spot/prices', params=params)
184+
return data["spot_market_prices"]

0 commit comments

Comments
 (0)