项目作者: giladsh1

项目描述 :
interact with spotinst API using cli
高级语言: Python
项目地址: git://github.com/giladsh1/spotinst-cli.git
创建时间: 2017-04-09T09:54:42Z
项目社区:https://github.com/giladsh1/spotinst-cli

开源协议:

下载


spotinst-cli

spotinst-cli is is an interactive command line tool which allows you to to control your spotinst groups and instances.

Usage

spotinst-cli has the following flags -

  1. -h, --help show this help message and exit
  2. -a ACCOUNT, --account=ACCOUNT spotinst account id defined as environment variable
  3. -g GREP, --grep=GREP text to filter groups by
  4. -u UNGREP, --ungrep=UNGREP text to exclude groups
  5. -l, --list show group list and exit
  6. -j, --json output pure json -- useful for piping into json parsers like jq
  7. -d, --get-data get groups data from spotinst
  8. -s, --get-status get groups status
  9. --get-health get groups health per instance
  10. --min=MIN update group minimum capacity, must supply with max and target
  11. --target=TARGET update group target capacity, must supply with min and max
  12. --max=MAX update group maximum capacity, must supply with min and target
  13. --scale-up=SCALE_UP scale up group by X number of instances
  14. --scale-down=SCALE_DOWN scale down group by X number of instances
  15. --suspend suspend group activities
  16. --unsuspend unsuspend group activities
  17. --suspension-status get groups suspension status
  18. --roll roll a group, must supply batch-size, and grace-period
  19. --batch-size=BATCH roll batch size - must supply with the roll flag
  20. --grace-period=GRACE roll grace period - must supply with the roll flag
  21. --replace-ami=AMI replace AMI for group
  22. --replace-health=HEALTH replace the health check type - can be HCS, EC2, ELB
  23. --set-user-data=USER_DATA updated user data - supply a file path which contains the user data script (cloud init)
  24. --get-user-data fetch the user data script (cloud init)
  25. --roll-status check the status of deployments
  26. -y, --skip-validation skip prompt validation for non-interactive mode

Multiple Accounts

spotinst-cli can use environment variables to reference multiple provider accounts.
Set variables like:

  1. export spotinst_account_prod="act-asdfasdf"
  2. export spotinst_account_qa="act-hjklhjkl"
  3. export spotinst_account_dev="act-zxcvzxcv"
  4. $> spotinst-cli --account prod
  5. ====================================================
  6. Getting groups from Spotisnt, please wait...
  7. ====================================================
  8. ===================================
  9. Found the following groups:
  10. ===================================
  11. +---+-------------------------------+--------------+-----+--------+-----+
  12. | # | Group name | ID | Min | Target | Max |
  13. +---+-------------------------------+--------------+-----+--------+-----+
  14. | 1 | Group-A | sig-adsfadfd | 0 | 0 | 200 |
  15. | 2 | Group-B | sig-fddgdfgd | 0 | 0 | 200 |
  16. | 3 | Group-C | sig-hdfhsfdg | 0 | 52 | 200 |
  17. | 4 | Web Servers | sig-hfhdgdhg | 0 | 0 | 4 |
  18. | 5 | ECS | sig-dfghdfgh | 1 | 8 | 12 |
  19. +---+-------------------------------+--------------+-----+--------+-----+

SpotInst account ids can be found in the web console under settings/account for each of your accounts.
There is currently no way to pull account ids from the SpotInst API.

Installation

  1. pip install spotinst-cli

OR

  1. git clone git@github.com:giladsh1/spotinst-cli.git
  2. ln -s /usr/local/bin/spotinst-cli $(pwd)/spotinst-cli/spotinst-cli