def create_healthmonitor(self, service, bigips):
        # create member
        hm = self.service_adapter.get_healthmonitor(service)
        hm_helper = self._get_monitor_helper(service)
        error = None

        for bigip in bigips:
            try:
                hm_helper.create(bigip, hm)
            except HTTPError as err:
                if err.response.status_code == 409:
                    try:
                        hm_helper.update(bigip, hm)
                    except Exception as err:
                        error = f5_ex.MonitorUpdateException(err.message)
                        LOG.error("Failed to update monitor %s on %s: %s",
                                  hm['name'], bigip, error.message)
                else:
                    error = f5_ex.MonitorCreationException(err.message)
                    LOG.error("Failed to create monitor %s on %s: %s",
                              hm['name'], bigip, error.message)
            except Exception as err:
                error = f5_ex.MonitorCreationException(err.message)
                LOG.error("Failed to create monitor %s on %s: %s", hm['name'],
                          bigip, error.message)

        return error
示例#2
0
    def _assure_monitors(self, service):
        if not (("pools" in service) and ("healthmonitors" in service)):
            return

        monitors = service["healthmonitors"]
        loadbalancer = service["loadbalancer"]
        bigips = self.driver.get_config_bigips()

        for monitor in monitors:
            svc = {
                "loadbalancer": loadbalancer,
                "healthmonitor": monitor,
                "pool": self.get_pool_by_id(service, monitor["pool_id"])
            }
            if monitor['provisioning_status'] == plugin_const.PENDING_DELETE:
                try:
                    self.pool_builder.delete_healthmonitor(svc, bigips)
                except Exception as err:
                    monitor['provisioning_status'] = plugin_const.ERROR
                    raise f5_ex.MonitorDeleteException(err.message)
            else:
                try:
                    self.pool_builder.create_healthmonitor(svc, bigips)
                except HTTPError as err:
                    if err.response.status_code != 409:
                        # pool['provisioning_status'] = plugin_const.ERROR
                        loadbalancer['provisioning_status'] = (
                            plugin_const.ERROR)
                        raise f5_ex.MonitorCreationException(err.message)
                    else:
                        self.pool_builder.update_healthmonitor(svc, bigips)
                except Exception as err:
                    monitor['provisioning_status'] = plugin_const.ERROR
                    raise f5_ex.MonitorCreationException(err.message)
示例#3
0
    def create_healthmonitor(self, service, bigips):
        # create member
        hm = self.service_adapter.get_healthmonitor(service)
        hm_helper = self._get_monitor_helper(service)
        error = None

        for bigip in bigips:
            try:
                if hm_helper.exists(bigip,
                                    name=hm['name'],
                                    partition=hm['partition']):
                    LOG.debug("Health monitor already exists...updating")
                    hm_helper.update(bigip, hm)
                else:
                    LOG.debug("Health monitor does not exist...creating")
                    hm_helper.create(bigip, hm)
            except Exception as err:
                error = f5_ex.MonitorCreationException(err.message)
                LOG.error("Failed to create monitor %s on %s: %s",
                          hm['name'], bigip, error.message)

        return error