From de91cbd468c315eabb9af6d1feb4a4a06da2d2de Mon Sep 17 00:00:00 2001 From: JJ Date: Tue, 26 Jun 2018 15:17:09 -0500 Subject: [PATCH 1/2] Adding `get_dsf` to dsf.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adding a function that enables retrieving all config details for a single Traffic Director. Relevant Dyn REST API documentation: Get One Traffic Director (DSF) instance — https://api.dynect.net/REST/DSF// --- dyn/tm/services/dsf.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/dyn/tm/services/dsf.py b/dyn/tm/services/dsf.py index 0022d8a..a5c1518 100644 --- a/dyn/tm/services/dsf.py +++ b/dyn/tm/services/dsf.py @@ -35,6 +35,19 @@ 'TrafficDirector'] +def get_dsf(service): + """ + :param service: a dsf_id string, or :class:`TrafficDirector` + :return: :class:`TrafficDirector` Service + """ + _service_id = _check_type(service) + uri = '/DSF/{}'.format(_service_id) + api_args = {'detail': 'Y'} + response = DynectSession.get_session().execute(uri, 'GET', api_args) + director = TrafficDirector(None, api=False, **response['data']) + return director + + def get_all_dsf_services(): """:return: A ``list`` of :class:`TrafficDirector` Services""" uri = '/DSF/' From 695f171bcf1a4f4a61631d68cf96cc509d1cc30c Mon Sep 17 00:00:00 2001 From: JJ Graham Date: Mon, 9 Jul 2018 14:20:25 -0500 Subject: [PATCH 2/2] Resolving flake8 issues --- dyn/core.py | 2 +- dyn/tm/services/dsf.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dyn/core.py b/dyn/core.py index 0e12036..a9c99d2 100644 --- a/dyn/core.py +++ b/dyn/core.py @@ -264,7 +264,7 @@ def _retry(self, msgs, final=False): # Get the task id task = next(pat.match(i['INFO']).group(1) for i in msgs if pat.match(i.get('INFO', ''))) - except: + except Exception: # Task id could not be recovered wait = 1 else: diff --git a/dyn/tm/services/dsf.py b/dyn/tm/services/dsf.py index a5c1518..c926fe6 100644 --- a/dyn/tm/services/dsf.py +++ b/dyn/tm/services/dsf.py @@ -432,7 +432,7 @@ def _build(self, data): self._rdata_class.lower()): for k, v in rdata_v.items(): setattr(self, '_' + k, v) - except: + except Exception: pass else: setattr(self, '_' + key, val)