def create_l7policy(self, f5_l7policy, bigips): LOG.debug("L7PolicyService: create_l7policy") error = None for bigip in bigips: try: self.policy_helper.create(bigip, f5_l7policy) error = None except HTTPError as err: status_code = err.response.status_code if status_code == 409: LOG.debug("L7 policy already exists...updating") try: self.policy_helper.update(bigip, f5_l7policy) except Exception as err: error = f5_ex.L7PolicyUpdateException(err.message) else: error = f5_ex.L7PolicyCreationException(err.message) except Exception as err: error = f5_ex.L7PolicyCreationException(err.message) if error: LOG.error("L7 policy creation error: %s" % error.message) return error
def create_irule(self, irules, bigips): LOG.debug("L7PolicyService: create_iRule") error = None for bigip in bigips: for rule in irules: try: self.rule_helper.create(bigip, rule) except HTTPError as err: status_code = err.response.status_code if status_code == 409: LOG.debug( "L7 rule (REGEX irule) already exists...updating") try: self.rule_helper.update(bigip, rule) except Exception as err: error = f5_ex.L7PolicyUpdateException(err.message) else: error = f5_ex.L7PolicyCreationException(err.message) except Exception as err: error = f5_ex.L7PolicyCreationException(err.message) if error: LOG.error("L7 rule (REGEX irule) creation error: %s" % error.message) return error
def _assure_l7policies_created(self, service): if 'l7policies' not in service: return bigips = self.driver.get_config_bigips() l7policies = service['l7policies'] for l7policy in l7policies: if l7policy['provisioning_status'] != plugin_const.PENDING_DELETE: try: name = l7policy.get('name', None) if name and self.is_esd(name): listener = self.get_listener_by_id( service, l7policy.get('listener_id', '')) svc = { "loadbalancer": service["loadbalancer"], "listener": listener } esd = self.get_esd(name) self.listener_builder.apply_esd(svc, esd, bigips) else: self.l7service.create_l7policy(l7policy, service, bigips) except Exception as err: l7policy['provisioning_status'] = plugin_const.ERROR service['loadbalancer']['provisioning_status'] = \ plugin_const.ERROR raise f5_ex.L7PolicyCreationException(err.message)
def _assure_l7rules_created(self, service): if 'l7policy_rules' not in service: return force_active = False bigips = self.driver.get_config_bigips() l7rules = service['l7policy_rules'] for l7rule in l7rules: if l7rule['provisioning_status'] != plugin_const.PENDING_DELETE: try: # ignore L7 rule if its policy is really an ESD l7policy = self.get_l7policy_for_rule( service['l7policies'], l7rule) name = l7policy.get('name', None) if name and self.is_esd(name): LOG.error("L7 policy {0} is an ESD. Cannot add " "an L7 rule to and ESD.".format(name)) continue self.l7service.create_l7rule(l7rule, service, bigips) force_active = True except Exception as err: l7rule['provisioning_status'] = plugin_const.ERROR service['loadbalancer']['provisioning_status'] = \ plugin_const.ERROR raise f5_ex.L7PolicyCreationException(err.message) self._set_status_as_active(l7rule, force=force_active)
def _assure_l7rules_created(self, service): if 'l7policy_rules' not in service: return bigips = self.driver.get_config_bigips() l7rules = service['l7policy_rules'] for l7rule in l7rules: if l7rule['provisioning_status'] != plugin_const.PENDING_DELETE: try: self.l7service.create_l7rule(l7rule, service, bigips) except Exception as err: l7rule['provisioning_status'] = plugin_const.ERROR raise f5_ex.L7PolicyCreationException(err.message)