def update_ingress_backend(self, ns_name, service_name, oper):
        ingress_ids = self._find_ingress(self._ingress_label_cache, ns_name,
                                         service_name)
        for ingress_id in ingress_ids or []:
            ingress = IngressKM.get(ingress_id)
            lb = LoadbalancerKM.get(ingress_id)
            if not ingress or not lb:
                continue
            if oper == 'ADD':
                new_backend_list = self._get_new_backend_list(
                    ingress.spec, ns_name)
                for new_backend in new_backend_list[:] or []:
                    if new_backend['member']['serviceName'] == service_name:

                        # Create a firewall rule for ingress to this service.
                        fw_uuid = VncIngress.add_ingress_to_service_rule(
                            ns_name, ingress.name, service_name)
                        lb.add_firewall_rule(fw_uuid)

                        self._create_listener_pool_member(
                            ns_name, lb, new_backend)
            else:
                old_backend_list = self._get_old_backend_list(lb)
                for old_backend in old_backend_list[:] or []:
                    if old_backend['member']['serviceName'] == service_name:
                        self._delete_listener(old_backend['listener_id'])

                        # Delete rules created for this ingress to service.
                        deleted_fw_rule_uuid =\
                            VncIngress.delete_ingress_to_service_rule(ns_name,
                                                                  ingress.name,
                                                                  service_name)
                        lb.remove_firewall_rule(deleted_fw_rule_uuid)
 def update_ingress_backend(self, ns_name, service_name, oper):
     ingress_ids = self._find_ingress(
         self._ingress_label_cache, ns_name, service_name)
     for ingress_id in ingress_ids or []:
         ingress = IngressKM.get(ingress_id)
         lb = LoadbalancerKM.get(ingress_id)
         if not ingress or not lb:
             continue
         if oper == 'ADD':
             new_backend_list = self._get_new_backend_list(ingress.spec, ns_name)
             for new_backend in new_backend_list[:] or []:
                 if new_backend['member']['serviceName'] == service_name:
                     self._create_listener_pool_member(
                         ns_name, lb, new_backend)
         else:
             old_backend_list = self._get_old_backend_list(lb)
             for old_backend in old_backend_list[:] or []:
                 if old_backend['member']['serviceName'] == service_name:
                     self._delete_listener(old_backend['listener_id'])