libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <>
Subject [GitHub] [libcloud] yukw777 opened a new pull request #1398: Support for aws ec2 spot instances
Date Sat, 28 Dec 2019 06:17:10 GMT
yukw777 opened a new pull request #1398: Support for aws ec2 spot instances
   ## Support for aws ec2 spot instances
   ### Description
   Support for aws ec2 spot instances. The previous PR (
went stale, so I decided to create a new one. I've added a unit test and ran a manual test
with the following script:
   import os
   import time
   from libcloud.compute.types import Provider
   from libcloud.compute.providers import get_driver
   from libcloud.compute.base import NodeImage
   from libcloud.compute.types import NodeState
   SIZE_ID = 't1.micro'
   AMI_ID = 'ami-04b9e92b5572fa0d1'
   REGION = 'us-east-1'
   KEYPAIR_NAME = 'key'
   SECURITY_GROUP_NAMES = ['default']
   NODE_NAME = 'test-spot-node'
   def create_spot_request(accessid, secretkey):
       cls = get_driver(Provider.EC2)
       driver = cls(accessid, secretkey, region=REGION)
       sizes = driver.list_sizes()
       size = [s for s in sizes if == SIZE_ID][0]
       image = NodeImage(id=AMI_ID, name=None, driver=driver)
       # create the spot instance
       node = driver.create_node(
       print("Spot instance created: '%s" %
       assert node.extra.get('instance_lifecycle') == 'spot'
       print("Destroying node...")
       while node.state != NodeState.TERMINATED:
           print("...waiting to be terminated (State: %s)" % node.state)
           node = driver.list_nodes(ex_node_ids=[])[0]
   def main():
       accessid = os.getenv('ACCESSID')
       secretkey = os.getenv('SECRETKEY')
       if accessid and secretkey:
           create_spot_request(accessid, secretkey)
           print('ACCESSID and SECRETKEY are sourced from the environment')
   if __name__ == "__main__":
   ### Status
   done, ready for review
   ### Checklist (tick everything that applies)
   - [x] [Code linting](
(required, can be done after the PR checks)
   - [x] Documentation
   - [x] [Tests](
   - [x] [ICLA](
(required for bigger changes)

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:

With regards,
Apache Git Services

View raw message