def force_synchronize_domainlists(self): edge_api = EdgeAPI(self.get_value('edge_url'), debug=True) meraki_api = MerakiAPI(self.get_value('sdwan_key'), debug=True) if not edge_api.validate_edgeurl() or not meraki_api.validate_api_key(): return False succeed = False if edge_api.login(self.get_value('edge_client_id'), self.get_value('edge_secret')): self._update_domainlist_ids(edge_api) domainlists = {} self._updates_domainlists(edge_api, domainlists) if self._debug: print("Now Synhronizing....") network_id = self._get_network_id(meraki_api) if network_id is not None: rules = meraki_api.get_firewall_rules(network_id) new_rules = self._update_firewall_rules_by_dls(meraki_api, rules, domainlists) meraki_api.update_firewall_rules(network_id, new_rules) timestamp = datetime.datetime.now().strftime("%Y/%m/%d %H:%M:%S.%f UTC") self.set_value('last_execution', timestamp) self.save() succeed = True edge_api.logout() return succeed
def collect_service_points(self): succeed = False try: interval = self.get_value('execution_interval') edge_api = EdgeAPI(self.get_value('edge_url'), debug=True) if not edge_api.validate_edgeurl(): return succeed if edge_api.login(self.get_value('edge_client_id'), self.get_value('edge_secret')): service_points = self._collect_service_points(edge_api) self.set_service_points(service_points) edge_api.logout() except Exception as e: if self._debug: print('DEBUG: Exceptin <%s>' % str(e)) return succeed