1212def get_cloud_details ():
1313 # Gather all cloud details and return them, along with the fieldnames
1414
15- grains = {'cloud_host' : False }
15+ grains = {}
1616
1717 aws = _get_aws_details ()
1818 azure = _get_azure_details ()
1919
2020 if aws ['cloud_details' ]:
21- grains ['cloud_host' ] = True
2221 grains .update (aws )
2322 if azure ['cloud_details' ]:
24- grains ['cloud_host' ] = True
2523 grains .update (azure )
2624
2725 return grains
@@ -37,14 +35,14 @@ def _get_aws_details():
3735
3836 try :
3937 aws ['cloud_account_id' ] = requests .get ('http://169.254.169.254/latest/dynamic/instance-identity/document' ,
40- timeout = 1 ).json ().get ('accountId' , 'unknown' )
38+ timeout = 3 ).json ().get ('accountId' , 'unknown' )
4139 # AWS account id is always an integer number
4240 # So if it's an aws machine it must be a valid integer number
4341 # Else it will throw an Exception
4442 aws ['cloud_account_id' ] = int (aws ['cloud_account_id' ])
4543
4644 aws ['cloud_instance_id' ] = requests .get ('http://169.254.169.254/latest/meta-data/instance-id' ,
47- timeout = 1 ).text
45+ timeout = 3 ).text
4846 except (requests .exceptions .RequestException , ValueError ):
4947 # Not on an AWS box
5048 aws = None
@@ -63,7 +61,7 @@ def _get_azure_details():
6361 azureHeader = {'Metadata' : 'true' }
6462 try :
6563 id = requests .get ('http://169.254.169.254/metadata/instance/compute?api-version=2017-08-01' ,
66- headers = azureHeader , timeout = 1 ).json ()
64+ headers = azureHeader , timeout = 3 ).json ()
6765 azure ['cloud_instance_id' ] = id ['vmId' ]
6866 azure ['cloud_account_id' ] = id ['subscriptionId' ]
6967
0 commit comments