From 7bd4a86a62520fd85c2d07f04b43021eb1f4df1b Mon Sep 17 00:00:00 2001 From: leu2z Date: Wed, 2 Nov 2016 16:39:19 +0000 Subject: [PATCH] retrieve the Monitor object in the GSLB._build() method The monitor attribute is always None when getting GSLB objects, for example when retrieved with Zone.get_all_gslb(). This patch allows the Monitor object to be instantiated inside the GSLB _build() method, perhaps could be less spaghetti coded. --- dyn/tm/services/gslb.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dyn/tm/services/gslb.py b/dyn/tm/services/gslb.py index d5e5e28..b888d7d 100644 --- a/dyn/tm/services/gslb.py +++ b/dyn/tm/services/gslb.py @@ -811,8 +811,12 @@ def _build(self, data, region=True): region_code = region.pop('region_code', None) self._region.append(GSLBRegion(self._zone, self._fqdn, region_code, **region)) + elif key == 'monitor' and not val: + self._monitor = None elif key == 'monitor': - # We already have the monitor object, no need to rebuild it + self._monitor = Monitor(protocol=val['protocol'], interval=val['interval']) + for attr, v in val.items(): + setattr(self._monitor, '_'+attr, v) pass elif key == "task_id" and not val: self._task_id = None