mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
fix python lint/pep8 things
This commit is contained in:
parent
8da69b14d5
commit
9973c0fc20
1 changed files with 6 additions and 3 deletions
|
@ -15,14 +15,16 @@ metadata server set `metadata_server_grains: True` in the minion config.
|
|||
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
import salt.utils.http as http
|
||||
import salt.utils.json
|
||||
import logging
|
||||
|
||||
HOST = "http://169.254.169.254"
|
||||
URL = f"{HOST}/computeMetadata/v1/?alt=json&recursive=true"
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
# Check if metadata_server_grains minion option is enabled
|
||||
if __opts__.get("metadata_server_grains", False) is False:
|
||||
|
@ -35,9 +37,10 @@ def __virtual__():
|
|||
return False
|
||||
return True
|
||||
|
||||
|
||||
def metadata():
|
||||
log.debug("All checks true - loading gce metadata")
|
||||
result = http.query(URL, headers=True, header_list=['Metadata-Flavor: Google'])
|
||||
metadata = salt.utils.json.loads(result.get('body',{}))
|
||||
result = http.query(URL, headers=True, header_list=["Metadata-Flavor: Google"])
|
||||
metadata = salt.utils.json.loads(result.get("body", {}))
|
||||
|
||||
return metadata
|
||||
|
|
Loading…
Add table
Reference in a new issue