fabfile.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:airflow-local 作者: gavinln 项目源码 文件源码
def request_spot_instances(
        price=0.01, zone='us-west-2a', inst_type=INSTANCE_TYPE,
        inst_id="ami-9abea4fb"):
    ' request spot instances '
    # ami-9abea4fb - ubuntu-trusty-14.04-amd64-server
    launch_specification = '''
        {{
          "ImageId": "{}",
          "KeyName": "ubuntu_trusty",
          "SecurityGroupIds": [ "sg-94a671f3" ],
          "InstanceType": "{}"
        }}
    '''.format(inst_id, inst_type)
    ls_encode = launch_specification.replace('\n', '')
    ls_encode = ls_encode.replace('"', '\\"')
    aws_cmd = 'aws ec2 request-spot-instances --spot-price "{}" --instance-count 1 --type "one-time" --availability-zone-group {} --launch-specification "{}"'
    aws_cmd = aws_cmd.format(price, zone, ls_encode)
    jq_cmd = 'jq -c -C "."'
    with hide("running"):
        local('|'.join([aws_cmd, jq_cmd]))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号