def execute(self, listeners, health_mon, vthunder):
        method = None
        url = None
        expect_code = None

        if health_mon.type in a10constants.HTTP_TYPE:
            method = health_mon.http_method
            url = health_mon.url_path
            expect_code = health_mon.expected_codes
        args = utils.meta(health_mon, 'hm', {})

        try:
            self.axapi_client.slb.hm.create(health_mon.id[0:5],
                                            openstack_mappings.hm_type(self.axapi_client,
                                                                       health_mon.type),
                                            health_mon.delay, health_mon.timeout,
                                            health_mon.rise_threshold, method=method,
                                            port=listeners[0].protocol_port, url=url,
                                            expect_code=expect_code, axapi_args=args)
            LOG.debug("Health Monitor created successfully: %s", health_mon.id)
        except Exception as e:
            LOG.exception("Failed to create Health Monitor: %s", str(e))
            raise

        try:
            self.axapi_client.slb.service_group.update(health_mon.pool_id,
                                                       health_monitor=health_mon.id[0:5],
                                                       health_check_disable=0)
            LOG.debug("Health Monitor %s is associated to pool %s successfully.",
                      health_mon.id, health_mon.pool_id)
        except Exception as e:
            LOG.exception("Failed to associate pool to Health Monitor: %s", str(e))
            raise
 def execute(self, listeners, health_mon, vthunder, update_dict):
     """ Execute update health monitor """
     # TODO(hthompson6) Length of name of healthmonitor for older vThunder devices
     health_mon.update(update_dict)
     method = None
     url = None
     expect_code = None
     if health_mon.type in a10constants.HTTP_TYPE:
         method = health_mon.http_method
         url = health_mon.url_path
         expect_code = health_mon.expected_codes
     args = utils.meta(health_mon, 'hm', {})
     try:
         self.axapi_client.slb.hm.update(health_mon.id,
                                         openstack_mappings.hm_type(
                                             self.axapi_client,
                                             health_mon.type),
                                         health_mon.delay,
                                         health_mon.timeout,
                                         health_mon.rise_threshold,
                                         method=method,
                                         url=url,
                                         expect_code=expect_code,
                                         port=listeners[0].protocol_port,
                                         axapi_args=args)
         LOG.debug("Successfully updated health monitor: %s", health_mon.id)
     except (acos_errors.ACOSException, ConnectionError) as e:
         LOG.exception("Failed to update health monitor: %s", health_mon.id)
         raise e
    def execute(self,
                listeners,
                health_mon,
                vthunder,
                update_dict,
                flavor=None):
        """ Execute update health monitor """

        health_mon.update(update_dict)
        method = None
        url = None
        expect_code = None
        if health_mon.type in a10constants.HTTP_TYPE:
            method = health_mon.http_method
            url = health_mon.url_path
            expect_code = health_mon.expected_codes
        args = utils.meta(health_mon, 'hm', {})
        args = utils.dash_to_underscore(args)

        # overwrite options from flavor
        if flavor:
            flavors = flavor.get('health_monitor')
            if flavors:
                name_exprs = flavors.get('name_expressions')
                parsed_exprs = utils.parse_name_expressions(
                    health_mon.name, name_exprs)
                flavors.pop('name_expressions', None)
                flavors.update(parsed_exprs)
                args.update({'monitor': flavors})

        try:
            hm_name = _get_hm_name(self.axapi_client, health_mon)
            post_data = CONF.health_monitor.post_data
            self.axapi_client.slb.hm.update(hm_name,
                                            openstack_mappings.hm_type(
                                                self.axapi_client,
                                                health_mon.type),
                                            health_mon.delay,
                                            health_mon.timeout,
                                            health_mon.rise_threshold,
                                            method=method,
                                            url=url,
                                            expect_code=expect_code,
                                            post_data=post_data,
                                            port=listeners[0].protocol_port,
                                            **args)
            LOG.debug("Successfully updated health monitor: %s", health_mon.id)
        except (acos_errors.ACOSException, ConnectionError) as e:
            LOG.exception("Failed to update health monitor: %s", health_mon.id)
            raise e
Beispiel #4
0
    def execute(self, vthunder):
        method = None
        url = None
        expect_code = None
        name = a10constants.OCTAVIA_HEALTH_MANAGER_CONTROLLER
        health_check = a10constants.OCTAVIA_HEALTH_MONITOR
        interval = CONF.a10_health_manager.heartbeat_interval
        timeout = CONF.a10_health_manager.health_check_timeout
        max_retries = CONF.a10_health_manager.health_check_max_retries
        port = CONF.a10_health_manager.bind_port
        ipv4 = CONF.a10_health_manager.bind_ip
        if interval < timeout:
            LOG.warning(
                "Interval should be greater than or equal to timeout. Reverting to default values. "
                "Setting interval to 10 seconds and timeout to 3 seconds.")
            interval = 10
            timeout = 3

        result = None
        try:
            result = self.axapi_client.slb.hm.create(
                health_check,
                openstack_mappings.hm_type(self.axapi_client, 'UDP'), interval,
                timeout, max_retries, method, url, expect_code, port, ipv4)
            LOG.debug("Successfully created health monitor for vThunder %s",
                      vthunder.id)
        except (acos_errors.ACOSException,
                req_exceptions.ConnectionError) as e:
            LOG.exception("Failed to create health monitor: %s", str(e))
            raise e

        if result:
            ip_address = CONF.a10_health_manager.udp_server_ip_address
            health_check = a10constants.OCTAVIA_HEALTH_MONITOR
            try:
                self.axapi_client.slb.server.create(name,
                                                    ip_address,
                                                    health_check=health_check)
                LOG.debug(
                    "Server created successfully. Enabled health check for health monitor."
                )
            except (acos_errors.ACOSException,
                    req_exceptions.ConnectionError) as e:
                LOG.exception("Failed to create health monitor server: %s",
                              str(e))
                raise e
    def execute(self, listeners, health_mon, vthunder):
        method = None
        url = None
        expect_code = None

        if health_mon.type in a10constants.HTTP_TYPE:
            method = health_mon.http_method
            url = health_mon.url_path
            expect_code = health_mon.expected_codes
        args = utils.meta(health_mon, 'hm', {})

        try:
            self.axapi_client.slb.hm.create(health_mon.id,
                                            openstack_mappings.hm_type(
                                                self.axapi_client,
                                                health_mon.type),
                                            health_mon.delay,
                                            health_mon.timeout,
                                            health_mon.rise_threshold,
                                            method=method,
                                            port=listeners[0].protocol_port,
                                            url=url,
                                            expect_code=expect_code,
                                            axapi_args=args)
            LOG.debug("Successfully created health monitor: %s", health_mon.id)

        except (acos_errors.ACOSException, ConnectionError) as e:
            LOG.exception("Failed to create health monitor: %s", health_mon.id)
            raise e

        try:
            self.axapi_client.slb.service_group.update(health_mon.pool_id,
                                                       hm_name=health_mon.id,
                                                       health_check_disable=0)
            LOG.debug("Successfully associated health monitor %s to pool %s",
                      health_mon.id, health_mon.pool_id)
        except (acos_errors.ACOSException, ConnectionError) as e:
            LOG.exception("Failed to associate health monitor %s to pool %s",
                          health_mon.id, health_mon.pool_id)
            raise e
    def execute(self, health_mon, vthunder):
        """ Execute create health monitor for amphora """

        # TODO : Length of name of healthmonitor for older vThunder devices
        try:
            method = None
            url = None
            expect_code = None
            port = None
            if health_mon.type in ['HTTP', 'HTTPS']:
                method = health_mon.http_method
                url = health_mon.url_path
                expect_code = health_mon.expected_codes
            args = self.meta(health_mon, 'hm', {})
            c = self.client_factory(vthunder)
            out = c.slb.hm.create(health_mon.id[0:5],
                                  openstack_mappings.hm_type(
                                      c, health_mon.type),
                                  health_mon.delay,
                                  health_mon.timeout,
                                  health_mon.rise_threshold,
                                  method=method,
                                  url=url,
                                  expect_code=expect_code,
                                  port=port,
                                  axapi_args=args)
            LOG.info("Health Monitor created successfully.")
        except Exception as e:
            print(str(e))

        try:
            c = self.client_factory(vthunder)
            out = c.slb.service_group.update(health_mon.pool_id,
                                             health_monitor=health_mon.id[0:5],
                                             health_check_disable=0)
            LOG.info("Health Monitor associated to pool successfully.")
        except Exception as e:
            print(str(e))
            LOG.info("Error occurred")
    def execute(self, listeners, health_mon, vthunder, flavor=None):
        method = None
        url = None
        expect_code = None

        if health_mon.type in a10constants.HTTP_TYPE:
            method = health_mon.http_method
            url = health_mon.url_path
            expect_code = health_mon.expected_codes
        args = utils.meta(health_mon, 'hm', {})
        args = utils.dash_to_underscore(args)

        # overwrite options from flavor
        if flavor:
            flavors = flavor.get('health_monitor')
            if flavors:
                name_exprs = flavors.get('name_expressions')
                parsed_exprs = utils.parse_name_expressions(
                    health_mon.name, name_exprs)
                flavors.pop('name_expressions', None)
                flavors.update(parsed_exprs)
                args.update({'monitor': flavors})

        try:
            health_mon.type = openstack_mappings.hm_type(
                self.axapi_client, health_mon.type)
        except Exception:
            raise exceptions.ProviderUnsupportedOptionError(
                prov="A10",
                user_msg=("Failed to create health monitor {}, "
                          "A health monitor of type {} is not supported "
                          "by A10 provider").format(health_mon.id,
                                                    health_mon.type))

        try:
            post_data = CONF.health_monitor.post_data
            self.axapi_client.slb.hm.create(health_mon.id,
                                            health_mon.type,
                                            health_mon.delay,
                                            health_mon.timeout,
                                            health_mon.rise_threshold,
                                            method=method,
                                            port=listeners[0].protocol_port,
                                            url=url,
                                            expect_code=expect_code,
                                            post_data=post_data,
                                            **args)
            LOG.debug("Successfully created health monitor: %s", health_mon.id)

        except (acos_errors.ACOSException, ConnectionError) as e:
            LOG.exception("Failed to create health monitor: %s", health_mon.id)
            raise e

        try:
            self.axapi_client.slb.service_group.update(health_mon.pool_id,
                                                       hm_name=health_mon.id,
                                                       health_check_disable=0)
            LOG.debug("Successfully associated health monitor %s to pool %s",
                      health_mon.id, health_mon.pool_id)
        except (acos_errors.ACOSException, ConnectionError) as e:
            LOG.exception("Failed to associate health monitor %s to pool %s",
                          health_mon.id, health_mon.pool_id)
            raise e