From notifications-return-16634-apmail-libcloud-notifications-archive=libcloud.apache.org@libcloud.apache.org Sat Dec 28 06:17:11 2019 Return-Path: X-Original-To: apmail-libcloud-notifications-archive@www.apache.org Delivered-To: apmail-libcloud-notifications-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by minotaur.apache.org (Postfix) with SMTP id A1B0E19D05 for ; Sat, 28 Dec 2019 06:17:11 +0000 (UTC) Received: (qmail 62395 invoked by uid 500); 28 Dec 2019 06:17:11 -0000 Delivered-To: apmail-libcloud-notifications-archive@libcloud.apache.org Received: (qmail 62372 invoked by uid 500); 28 Dec 2019 06:17:11 -0000 Mailing-List: contact notifications-help@libcloud.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@libcloud.apache.org Delivered-To: mailing list notifications@libcloud.apache.org Received: (qmail 62363 invoked by uid 99); 28 Dec 2019 06:17:10 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 28 Dec 2019 06:17:10 +0000 From: GitBox To: notifications@libcloud.apache.org Subject: [GitHub] [libcloud] yukw777 opened a new pull request #1398: Support for aws ec2 spot instances Message-ID: Date: Sat, 28 Dec 2019 06:17:10 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit yukw777 opened a new pull request #1398: Support for aws ec2 spot instances URL: https://github.com/apache/libcloud/pull/1398 ## Support for aws ec2 spot instances ### Description Support for aws ec2 spot instances. The previous PR (https://github.com/apache/libcloud/pull/1207) 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: ```python 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 s.id == SIZE_ID][0] image = NodeImage(id=AMI_ID, name=None, driver=driver) # create the spot instance node = driver.create_node( name=NODE_NAME, size=size, image=image, ex_spot=True, ex_spot_max_price=0.005, ex_keyname=KEYPAIR_NAME, ex_security_groups=SECURITY_GROUP_NAMES) print("Spot instance created: '%s" % node.id) assert node.extra.get('instance_lifecycle') == 'spot' print("Destroying node...") driver.destroy_node(node) while node.state != NodeState.TERMINATED: print("...waiting to be terminated (State: %s)" % node.state) node = driver.list_nodes(ex_node_ids=[node.id])[0] time.sleep(5) def main(): accessid = os.getenv('ACCESSID') secretkey = os.getenv('SECRETKEY') if accessid and secretkey: create_spot_request(accessid, secretkey) else: print('ACCESSID and SECRETKEY are sourced from the environment') if __name__ == "__main__": main() ``` ### Status done, ready for review ### Checklist (tick everything that applies) - [x] [Code linting](http://libcloud.readthedocs.org/en/latest/development.html#code-style-guide) (required, can be done after the PR checks) - [x] Documentation - [x] [Tests](http://libcloud.readthedocs.org/en/latest/testing.html) - [x] [ICLA](http://libcloud.readthedocs.org/en/latest/development.html#contributing-bigger-changes) (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: users@infra.apache.org With regards, Apache Git Services