-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from hubblestack/develop
Merge to master (prep v2017.3.2)
- Loading branch information
Showing
15 changed files
with
314 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
''' | ||
HubbleStack AWS Details | ||
:maintainer: HubbleStack | ||
:platform: All | ||
:requires: SaltStack | ||
''' | ||
|
||
import requests | ||
|
||
def get_aws_details(): | ||
# Gather amazon information if present | ||
aws = {} | ||
aws['aws_ami_id'] = None | ||
aws['aws_instance_id'] = None | ||
aws['aws_account_id'] = None | ||
|
||
try: | ||
aws['aws_account_id'] = requests.get('http://169.254.169.254/latest/dynamic/instance-identity/document', | ||
timeout=1).json().get('accountId', 'unknown') | ||
# AWS account id is always an integer number | ||
# So if it's an aws machine it must be a valid integer number | ||
# Else it will throw an Exception | ||
aws['aws_account_id'] = int(aws['aws_account_id']) | ||
|
||
aws['aws_ami_id'] = requests.get('http://169.254.169.254/latest/meta-data/ami-id', | ||
timeout=1).text | ||
aws['aws_instance_id'] = requests.get('http://169.254.169.254/latest/meta-data/instance-id', | ||
timeout=1).text | ||
except (requests.exceptions.RequestException, ValueError): | ||
# Not on an AWS box | ||
aws['aws_account_id'] = None | ||
pass | ||
return aws |
Oops, something went wrong.