Adds missing args2body and add_known_arguments
This is the first commit of 2 towards closing GBP client bug #1403417. It adds args2body and add_known_arguments methods to the resources whose update operations were lacking them: * l2policy * policy-action * policy-classifier * policy-target (although not used as shared) This is a necessary initial step to then show the --shared option in all create/update operations that support that attribute. Change-Id: I1cefcb538c16165a3cd87aa261ea215861aa3b71 Partial-Bug: #1403417
This commit is contained in:
parent
7cd0fddac6
commit
acc8155076
@ -107,6 +107,31 @@ class UpdatePolicyTarget(neutronV20.UpdateCommand):
|
||||
resource = 'policy_target'
|
||||
log = logging.getLogger(__name__ + '.UpdatePolicyTarget')
|
||||
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--description',
|
||||
help=_('Description of the Policy Target'))
|
||||
parser.add_argument(
|
||||
'--policy-target-group', metavar='PTG',
|
||||
default='',
|
||||
help=_('Policy Target Group uuid'))
|
||||
parser.add_argument(
|
||||
'--name',
|
||||
help=_('New name of the Policy Target'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {self.resource: {}, }
|
||||
|
||||
neutronV20.update_dict(parsed_args, body[self.resource],
|
||||
['name', 'tenant_id', 'description'])
|
||||
if parsed_args.policy_target_group:
|
||||
body[self.resource]['policy_target_group_id'] = \
|
||||
neutronV20.find_resourceid_by_name_or_id(
|
||||
self.get_client(), 'policy_target_group',
|
||||
parsed_args.policy_target_group)
|
||||
|
||||
return body
|
||||
|
||||
|
||||
class ListPolicyTargetGroup(neutronV20.ListCommand):
|
||||
"""List Policy Target Groups that belong to a given tenant."""
|
||||
@ -338,6 +363,31 @@ class UpdateL2Policy(neutronV20.UpdateCommand):
|
||||
resource = 'l2_policy'
|
||||
log = logging.getLogger(__name__ + '.UpdateL2Policy')
|
||||
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--description',
|
||||
help=_('Description of the L2 Policy'))
|
||||
parser.add_argument(
|
||||
'--l3-policy',
|
||||
default='',
|
||||
help=_('L3 Policy uuid'))
|
||||
parser.add_argument(
|
||||
'--name', metavar='NAME',
|
||||
help=_('New name of the L2 Policy'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {self.resource: {}, }
|
||||
|
||||
neutronV20.update_dict(parsed_args, body[self.resource],
|
||||
['name', 'tenant_id', 'description'])
|
||||
if parsed_args.l3_policy:
|
||||
body[self.resource]['l3_policy_id'] = \
|
||||
neutronV20.find_resourceid_by_name_or_id(
|
||||
self.get_client(), 'l3_policy',
|
||||
parsed_args.l3_policy)
|
||||
|
||||
return body
|
||||
|
||||
|
||||
class ListL3Policy(neutronV20.ListCommand):
|
||||
"""List l3_policies that belong to a given tenant."""
|
||||
@ -447,7 +497,7 @@ class UpdateL3Policy(neutronV20.UpdateCommand):
|
||||
'(this option can be repeated)'))
|
||||
parser.add_argument(
|
||||
'--name', metavar='NAME',
|
||||
help=_('Name of L3 policy to create'))
|
||||
help=_('New name of the L3 Policy'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {self.resource: {}, }
|
||||
@ -624,6 +674,34 @@ class UpdatePolicyClassifier(neutronV20.UpdateCommand):
|
||||
resource = 'policy_classifier'
|
||||
log = logging.getLogger(__name__ + '.UpdatePolicyClassifier')
|
||||
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--description',
|
||||
help=_('Description of the policy classifier'))
|
||||
parser.add_argument(
|
||||
'--protocol',
|
||||
choices=['tcp', 'udp', 'icmp'],
|
||||
help=_('Protocol'))
|
||||
parser.add_argument(
|
||||
'--port-range',
|
||||
help=_('Port range'))
|
||||
parser.add_argument(
|
||||
'--direction',
|
||||
choices=['in', 'out', 'bi', ''],
|
||||
help=_('Direction'))
|
||||
parser.add_argument(
|
||||
'--name',
|
||||
help=_('New name of the classifier'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {self.resource: {}, }
|
||||
|
||||
neutronV20.update_dict(parsed_args, body[self.resource],
|
||||
['name', 'tenant_id', 'description',
|
||||
'protocol', 'port_range', 'direction'])
|
||||
|
||||
return body
|
||||
|
||||
|
||||
class ListPolicyAction(neutronV20.ListCommand):
|
||||
"""List actions that belong to a given tenant."""
|
||||
@ -692,6 +770,31 @@ class UpdatePolicyAction(neutronV20.UpdateCommand):
|
||||
resource = 'policy_action'
|
||||
log = logging.getLogger(__name__ + '.UpdatePolicyAction')
|
||||
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--description',
|
||||
help=_('Description of the policy action'))
|
||||
parser.add_argument(
|
||||
'--action-value',
|
||||
help=_('Name/UUID of servicechain spec for redirect action'))
|
||||
parser.add_argument(
|
||||
'--name',
|
||||
help=_('New name of the action'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {self.resource: {}, }
|
||||
|
||||
if parsed_args.action_value:
|
||||
body[self.resource]['action_value'] = (
|
||||
neutronV20.find_resourceid_by_name_or_id(
|
||||
self.get_client(), 'servicechain_spec',
|
||||
parsed_args.action_value))
|
||||
|
||||
neutronV20.update_dict(parsed_args, body[self.resource],
|
||||
['name', 'tenant_id', 'description'])
|
||||
|
||||
return body
|
||||
|
||||
|
||||
class ListPolicyRule(neutronV20.ListCommand):
|
||||
"""List policy_rules that belong to a given tenant."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user