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)))
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)
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) formatters = {'rules': v2_utils.format_list} return (rows, (utils.get_dict_properties(data['l7policy'], rows, formatters=formatters)))
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 )
def test_check_l7policy_attrs(self): attrs_dict = { "action": "redirect_to_pool".upper(), "redirect_pool_id": "id", } try: validate.check_l7policy_attrs(attrs_dict) except exceptions.CommandError as e: self.fail("%s raised unexpectedly" % e) attrs_dict.pop("redirect_pool_id") self.assertRaises(exceptions.CommandError, validate.check_l7policy_attrs, attrs_dict) attrs_dict = { "action": "redirect_to_url".upper(), "redirect_url": "url", } try: validate.check_l7policy_attrs(attrs_dict) except exceptions.CommandError as e: self.fail("%s raised unexpectedly" % e) attrs_dict.pop("redirect_url") self.assertRaises(exceptions.CommandError, validate.check_l7policy_attrs, attrs_dict)