Module: check_mk
Branch: master
Commit: 13456368b257de3b240656ba9d81a2502a36e82c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=13456368b257de…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Wed Jan 23 12:23:08 2019 +0100
agent_aws: Separate sections registry from __init__
Change-Id: I6e61b5ab03f91141a22f9a8f5c38701c29732789
---
agents/special/agent_aws | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/agents/special/agent_aws b/agents/special/agent_aws
index 6f157d5..f6bd95e 100755
--- a/agents/special/agent_aws
+++ b/agents/special/agent_aws
@@ -891,6 +891,10 @@ class AWSSectionsTmpl(object):
self._results = {}
self._exceptions = []
+ @abc.abstractmethod
+ def init_sections(self, **kwargs):
+ pass
+
def _init_client(self, client_key):
try:
return self._session.client(client_key)
@@ -1000,9 +1004,7 @@ class AWSSectionsUSEast(AWSSectionsTmpl):
https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/ce-api.html
"""
- def __init__(self, hostname, session, services):
- super(AWSSectionsUSEast, self).__init__(hostname, session, services)
-
+ def init_sections(self, **kwargs):
#---clients---------------------------------------------------------
ce_client = self._init_client('ce')
@@ -1015,9 +1017,7 @@ class AWSSectionsUSEast(AWSSectionsTmpl):
class AWSSections(AWSSectionsTmpl):
- def __init__(self, hostname, session, services):
- super(AWSSections, self).__init__(hostname, session, services)
-
+ def init_sections(self, **kwargs):
#---clients---------------------------------------------------------
ec2_client = self._init_client('ec2')
s3_client = self._init_client('s3')
@@ -1196,6 +1196,7 @@ def main(args=None):
try:
session = create_session(access_key_id, secret_access_key,
"us-east-1")
aws_sections_us_east = AWSSectionsUSEast(hostname, session, services)
+ aws_sections_us_east.init_sections()
aws_sections_us_east.run(use_cache=use_cache)
except Exception as e:
if args.debug:
@@ -1206,6 +1207,7 @@ def main(args=None):
try:
session = create_session(access_key_id, secret_access_key, region)
aws_sections = AWSSections(hostname, session, services)
+ aws_sections.init_sections()
aws_sections.run(use_cache=use_cache)
except Exception as e:
if args.debug: