def take_action(self, parsed_args):
        rows = const.MONITOR_ROWS
        attrs = v2_utils.get_health_monitor_attrs(self.app.client_manager,
                                                  parsed_args)
        body = {"healthmonitor": attrs}
        data = self.app.client_manager.load_balancer.health_monitor_create(
            json=body)

        if parsed_args.wait:
            pool = self.app.client_manager.load_balancer.pool_show(
                data['healthmonitor']['pools'][0]['id'])
            v2_utils.wait_for_active(status_f=(
                self.app.client_manager.load_balancer.load_balancer_show),
                                     res_id=pool['loadbalancers'][0]['id'])
            data = {
                'healthmonitor':
                (self.app.client_manager.load_balancer.health_monitor_show(
                    data['healthmonitor']['id']))
            }

        formatters = {'pools': v2_utils.format_list}

        return (rows, (utils.get_dict_properties(data['healthmonitor'],
                                                 rows,
                                                 formatters=formatters)))
    def take_action(self, parsed_args):
        rows = const.LISTENER_ROWS
        attrs = v2_utils.get_listener_attrs(self.app.client_manager,
                                            parsed_args)

        validate.check_listener_attrs(attrs)

        body = {"listener": attrs}
        data = self.app.client_manager.load_balancer.listener_create(json=body)

        if parsed_args.wait:
            v2_utils.wait_for_active(
                status_f=(
                    self.app.client_manager.load_balancer.load_balancer_show),
                res_id=data['listener']['loadbalancers'][0]['id'])
            data = {
                'listener':
                (self.app.client_manager.load_balancer.listener_show(
                    data['listener']['id']))
            }

        formatters = {
            'loadbalancers': v2_utils.format_list,
            'pools': v2_utils.format_list,
            'l7policies': v2_utils.format_list,
            'insert_headers': v2_utils.format_hash,
            'allowed_cidrs': v2_utils.format_list_flat
        }

        return (rows, (utils.get_dict_properties(data['listener'],
                                                 rows,
                                                 formatters=formatters)))
Example #3
0
    def take_action(self, parsed_args):
        rows = const.POOL_ROWS
        attrs = v2_utils.get_pool_attrs(self.app.client_manager, parsed_args)

        body = {"pool": attrs}
        data = self.app.client_manager.load_balancer.pool_create(json=body)

        if parsed_args.wait:
            v2_utils.wait_for_active(
                status_f=(
                    self.app.client_manager.load_balancer.load_balancer_show),
                res_id=data['pool']['loadbalancers'][0]['id'])
            data = {
                'pool': (self.app.client_manager.load_balancer.pool_show(
                    data['pool']['id']))
            }

        formatters = {
            'loadbalancers': v2_utils.format_list,
            'members': v2_utils.format_list,
            'listeners': v2_utils.format_list,
            'session_persistence': v2_utils.format_hash
        }

        return (rows,
                (utils.get_dict_properties(data['pool'],
                                           rows,
                                           formatters=formatters,
                                           mixed_case_fields=['enable-tls'])))
Example #4
0
    def take_action(self, parsed_args):
        rows = const.LOAD_BALANCER_ROWS
        attrs = v2_utils.get_loadbalancer_attrs(self.app.client_manager,
                                                parsed_args)
        self._check_attrs(attrs)
        body = {'loadbalancer': attrs}

        data = self.app.client_manager.load_balancer.load_balancer_create(
            json=body)

        if parsed_args.wait:
            v2_utils.wait_for_active(status_f=(
                self.app.client_manager.load_balancer.load_balancer_show),
                                     res_id=data['loadbalancer']['id'])
            data = {
                'loadbalancer':
                (self.app.client_manager.load_balancer.load_balancer_show(
                    data['loadbalancer']['id']))
            }

        formatters = {
            'listeners': v2_utils.format_list,
            'pools': v2_utils.format_list,
            'l7policies': v2_utils.format_list
        }

        return (rows, (utils.get_dict_properties(data['loadbalancer'],
                                                 rows,
                                                 formatters=formatters)))
Example #5
0
    def take_action(self, parsed_args):
        rows = const.L7POLICY_ROWS
        attrs = v2_utils.get_l7policy_attrs(self.app.client_manager,
                                            parsed_args)
        validate.check_l7policy_attrs(attrs)
        body = {"l7policy": attrs}

        data = self.app.client_manager.load_balancer.l7policy_create(
            json=body)

        if parsed_args.wait:
            listener = self.app.client_manager.load_balancer.listener_show(
                data['l7policy']['listener_id'])
            v2_utils.wait_for_active(
                status_f=(self.app.client_manager.load_balancer.
                          load_balancer_show),
                res_id=listener['loadbalancers'][0]['id']
            )
            data = {
                'l7policy': (
                    self.app.client_manager.load_balancer.l7policy_show(
                        data['l7policy']['id']))
            }

        formatters = {'rules': v2_utils.format_list}

        return (rows, (utils.get_dict_properties(
            data['l7policy'], rows, formatters=formatters)))
Example #6
0
    def take_action(self, parsed_args):
        attrs = v2_utils.get_loadbalancer_attrs(self.app.client_manager,
                                                parsed_args)
        lb_id = attrs.pop('loadbalancer_id')
        self.app.client_manager.load_balancer.load_balancer_failover(
            lb_id=lb_id)

        if parsed_args.wait:
            v2_utils.wait_for_active(status_f=(
                self.app.client_manager.load_balancer.load_balancer_show),
                                     res_id=lb_id)
Example #7
0
    def take_action(self, parsed_args):
        attrs = v2_utils.get_pool_attrs(self.app.client_manager, parsed_args)
        pool_id = attrs.pop('pool_id')

        body = {'pool': attrs}

        self.app.client_manager.load_balancer.pool_set(pool_id, json=body)

        if parsed_args.wait:
            v2_utils.wait_for_active(
                status_f=self.app.client_manager.load_balancer.pool_show,
                res_id=pool_id)
Example #8
0
    def take_action(self, parsed_args):
        attrs = v2_utils.get_loadbalancer_attrs(self.app.client_manager,
                                                parsed_args)
        lb_id = attrs.pop('loadbalancer_id')
        body = {'loadbalancer': attrs}

        self.app.client_manager.load_balancer.load_balancer_set(lb_id,
                                                                json=body)

        if parsed_args.wait:
            v2_utils.wait_for_active(status_f=(
                self.app.client_manager.load_balancer.load_balancer_show),
                                     res_id=lb_id)
    def take_action(self, parsed_args):
        attrs = v2_utils.get_health_monitor_attrs(self.app.client_manager,
                                                  parsed_args)

        hm_id = attrs.pop('health_monitor_id')

        body = {'healthmonitor': attrs}

        self.app.client_manager.load_balancer.health_monitor_set(hm_id,
                                                                 json=body)

        if parsed_args.wait:
            v2_utils.wait_for_active(status_f=(
                self.app.client_manager.load_balancer.health_monitor_show),
                                     res_id=hm_id)
Example #10
0
    def take_action(self, parsed_args):
        unset_args = v2_utils.get_unsets(parsed_args)
        if not unset_args:
            return

        pool_id = v2_utils.get_resource_id(
            self.app.client_manager.load_balancer.pool_list, 'pools',
            parsed_args.pool)

        body = {'pool': unset_args}

        self.app.client_manager.load_balancer.pool_set(pool_id, json=body)

        if parsed_args.wait:
            v2_utils.wait_for_active(
                status_f=self.app.client_manager.load_balancer.pool_show,
                res_id=pool_id)
    def take_action(self, parsed_args):
        unset_args = v2_utils.get_unsets(parsed_args)
        if not unset_args:
            return

        listener_id = v2_utils.get_resource_id(
            self.app.client_manager.load_balancer.listener_list, 'listeners',
            parsed_args.listener)

        body = {'listener': unset_args}

        self.app.client_manager.load_balancer.listener_set(listener_id,
                                                           json=body)

        if parsed_args.wait:
            v2_utils.wait_for_active(
                status_f=self.app.client_manager.load_balancer.listener_show,
                res_id=listener_id)
    def take_action(self, parsed_args):
        unset_args = v2_utils.get_unsets(parsed_args)
        if not unset_args:
            return

        hm_id = v2_utils.get_resource_id(
            self.app.client_manager.load_balancer.health_monitor_list,
            'healthmonitors', parsed_args.health_monitor)

        body = {'healthmonitor': unset_args}

        self.app.client_manager.load_balancer.health_monitor_set(hm_id,
                                                                 json=body)

        if parsed_args.wait:
            v2_utils.wait_for_active(status_f=(
                self.app.client_manager.load_balancer.health_monitor_show),
                                     res_id=hm_id)
Example #13
0
    def take_action(self, parsed_args):
        attrs = v2_utils.get_l7policy_attrs(self.app.client_manager,
                                            parsed_args)

        validate.check_l7policy_attrs(attrs)
        l7policy_id = attrs.pop('l7policy_id')

        body = {'l7policy': attrs}

        self.app.client_manager.load_balancer.l7policy_set(
            l7policy_id, json=body)

        if parsed_args.wait:
            v2_utils.wait_for_active(
                status_f=(self.app.client_manager.load_balancer.
                          l7policy_show),
                res_id=l7policy_id
            )
Example #14
0
    def take_action(self, parsed_args):
        unset_args = v2_utils.get_unsets(parsed_args)
        if not unset_args:
            return

        policy_id = v2_utils.get_resource_id(
            self.app.client_manager.load_balancer.l7policy_list,
            'l7policies', parsed_args.l7policy)

        body = {'l7policy': unset_args}

        self.app.client_manager.load_balancer.l7policy_set(
            policy_id, json=body)

        if parsed_args.wait:
            v2_utils.wait_for_active(
                status_f=(self.app.client_manager.load_balancer.
                          l7policy_show),
                res_id=policy_id
            )