Common: Fix aws_instance.py formatting

This commit is contained in:
vakarisz 2022-04-28 11:48:06 +03:00
parent 946c394c74
commit f63bc77df0
1 changed files with 14 additions and 16 deletions

View File

@ -2,7 +2,7 @@ import json
import logging
import re
from dataclasses import dataclass
from typing import Tuple, Optional
from typing import Optional, Tuple
import requests
@ -29,6 +29,7 @@ class AwsInstance(CloudInstance):
"""
Class which gives useful information about the current instance you're on.
"""
__metaclass__ = Singleton
def __init__(self):
@ -55,8 +56,7 @@ class AwsInstance(CloudInstance):
info.instance_id = response.text if response else False
info.region = AwsInstance._parse_region(
requests.get(
AWS_LATEST_METADATA_URI_PREFIX +
"meta-data/placement/availability-zone",
AWS_LATEST_METADATA_URI_PREFIX + "meta-data/placement/availability-zone",
timeout=AWS_TIMEOUT,
).text
)
@ -67,15 +67,13 @@ class AwsInstance(CloudInstance):
try:
info.account_id = AwsInstance._extract_account_id(
requests.get(
AWS_LATEST_METADATA_URI_PREFIX +
"dynamic/instance-identity/document",
AWS_LATEST_METADATA_URI_PREFIX + "dynamic/instance-identity/document",
timeout=AWS_TIMEOUT,
).text
)
except (requests.RequestException, json.decoder.JSONDecodeError, IOError) as e:
logger.debug(
"Failed init of AwsInstance while getting dynamic instance data: {}".format(
e)
"Failed init of AwsInstance while getting dynamic instance data: {}".format(e)
)
return False, AwsInstanceInfo()