Client renaming of GBP resources
The following resources are being renamed: Endpoints -> Policy Targets Endpoints Groups -> Policy Target Groups Contracts -> Policy Rule Sets The changes to the spec are outlined in: https://review.openstack.org/#/c/134747 Change-Id: I71d7a22a2c16982273625b7e1c63024deccdc7cd Partially-implements: blueprint group-based-policy-abstraction
This commit is contained in:
parent
f269444ccc
commit
1fafa0014b
17
gbp_test.sh
17
gbp_test.sh
@ -12,7 +12,7 @@ ptg_name=myptg1
|
||||
## TODO Sumit: Test for other resources as well after renaming
|
||||
function cleanup() {
|
||||
echo Removing test ptg...
|
||||
gbp endpointgroup-delete ptg_name
|
||||
gbp policy-target-group-delete ptg_name
|
||||
}
|
||||
|
||||
noauth_tenant_id=me
|
||||
@ -29,8 +29,8 @@ FORMAT=" --request-format xml"
|
||||
|
||||
# test the CRUD of network
|
||||
ptg=$ptg_name
|
||||
gbp endpointgroup-create $FORMAT $NOAUTH $ptg || die "fail to create ptg $ptg"
|
||||
temp=`gbp endpointgroup-list $FORMAT -- --name $ptg --fields id | wc -l`
|
||||
gbp policy-target-group-create $FORMAT $NOAUTH $ptg || die "fail to create ptg $ptg"
|
||||
temp=`gbp policy-target-group-list $FORMAT -- --name $ptg --fields id | wc -l`
|
||||
echo $temp
|
||||
if [ $temp -ne 5 ]; then
|
||||
die "PTGs with name $ptg is not unique or found"
|
||||
@ -38,14 +38,13 @@ fi
|
||||
ptg_id=`gbp gbp-list -- --name $ptg --fields id | tail -n 2 | head -n 1 | cut -d' ' -f 2`
|
||||
echo "ID of PTG with name $ptg is $ptg_id"
|
||||
|
||||
gbp endpointgroup-show $FORMAT $ptg || die "fail to show PTG $ptg"
|
||||
gbp endpointgroup-show $FORMAT $ptg_id || die "fail to show PTG $ptg_id"
|
||||
gbp policy-target-group-show $FORMAT $ptg || die "fail to show PTG $ptg"
|
||||
gbp policy-target-group-show $FORMAT $ptg_id || die "fail to show PTG $ptg_id"
|
||||
|
||||
gbp endpointgroup-update $FORMAT $ptg --description "desc" || die "fail to update PTG $ptg"
|
||||
gbp endpointgroup-update $FORMAT $ptg_id --description "new" || die "fail to update PTG $ptg_id"
|
||||
gbp policy-target-group-update $FORMAT $ptg --description "desc" || die "fail to update PTG $ptg"
|
||||
gbp policy-target-group-update $FORMAT $ptg_id --description "new" || die "fail to update PTG $ptg_id"
|
||||
|
||||
gbp endpointgroup-list $FORMAT -c id -- --id fakeid || die "fail to list PTGs with column selection on empty list"
|
||||
gbp policy-target-group-list $FORMAT -c id -- --id fakeid || die "fail to list PTGs with column selection on empty list"
|
||||
|
||||
cleanup
|
||||
echo "Success! :)"
|
||||
|
||||
|
@ -28,56 +28,56 @@ def _format_network_service_params(net_svc_policy):
|
||||
return ''
|
||||
|
||||
|
||||
class ListEndpoint(neutronV20.ListCommand):
|
||||
class ListPolicyTarget(neutronV20.ListCommand):
|
||||
"""List policy_targets that belong to a given tenant."""
|
||||
|
||||
resource = 'endpoint'
|
||||
log = logging.getLogger(__name__ + '.ListEndpoint')
|
||||
resource = 'policy_target'
|
||||
log = logging.getLogger(__name__ + '.ListPolicyTarget')
|
||||
_formatters = {}
|
||||
list_columns = ['id', 'name', 'description', 'endpoint_group_id']
|
||||
list_columns = ['id', 'name', 'description', 'policy_target_group_id']
|
||||
pagination_support = True
|
||||
sorting_support = True
|
||||
|
||||
|
||||
class ShowEndpoint(neutronV20.ShowCommand):
|
||||
class ShowPolicyTarget(neutronV20.ShowCommand):
|
||||
"""Show information of a given policy_target."""
|
||||
|
||||
resource = 'endpoint'
|
||||
log = logging.getLogger(__name__ + '.ShowEndpoint')
|
||||
resource = 'policy_target'
|
||||
log = logging.getLogger(__name__ + '.ShowPolicyTarget')
|
||||
|
||||
|
||||
class CreateEndpoint(neutronV20.CreateCommand):
|
||||
class CreatePolicyTarget(neutronV20.CreateCommand):
|
||||
"""Create a policy_target for a given tenant."""
|
||||
|
||||
resource = 'endpoint'
|
||||
log = logging.getLogger(__name__ + '.CreateEndpoint')
|
||||
resource = 'policy_target'
|
||||
log = logging.getLogger(__name__ + '.CreatePolicyTarget')
|
||||
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--description',
|
||||
help=_('Description of the policy_target'))
|
||||
help=_('Description of the Policy Target'))
|
||||
parser.add_argument(
|
||||
'--endpoint-group', metavar='EPG',
|
||||
'--policy-target-group', metavar='PTG',
|
||||
default='',
|
||||
help=_('group uuid'))
|
||||
help=_('Policy Target Group uuid'))
|
||||
parser.add_argument(
|
||||
'--port',
|
||||
default='',
|
||||
help=_('Neutron Port'))
|
||||
parser.add_argument(
|
||||
'name', metavar='NAME',
|
||||
help=_('Name of policy_target to create'))
|
||||
help=_('Name of policy target to create'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {self.resource: {}, }
|
||||
|
||||
neutronV20.update_dict(parsed_args, body[self.resource],
|
||||
['name', 'tenant_id', 'description'])
|
||||
if parsed_args.endpoint_group:
|
||||
body[self.resource]['endpoint_group_id'] = \
|
||||
if parsed_args.policy_target_group:
|
||||
body[self.resource]['policy_target_group_id'] = \
|
||||
neutronV20.find_resourceid_by_name_or_id(
|
||||
self.get_client(), 'endpoint_group',
|
||||
parsed_args.endpoint_group)
|
||||
self.get_client(), 'policy_target_group',
|
||||
parsed_args.policy_target_group)
|
||||
if parsed_args.port:
|
||||
body[self.resource]['port_id'] = \
|
||||
neutronV20.find_resourceid_by_name_or_id(
|
||||
@ -86,69 +86,69 @@ class CreateEndpoint(neutronV20.CreateCommand):
|
||||
return body
|
||||
|
||||
|
||||
class DeleteEndpoint(neutronV20.DeleteCommand):
|
||||
"""Delete a given policy_target."""
|
||||
class DeletePolicyTarget(neutronV20.DeleteCommand):
|
||||
"""Delete a given Policy Target."""
|
||||
|
||||
resource = 'endpoint'
|
||||
log = logging.getLogger(__name__ + '.DeleteEndpoint')
|
||||
resource = 'policy_target'
|
||||
log = logging.getLogger(__name__ + '.DeletePolicyTarget')
|
||||
|
||||
|
||||
class UpdateEndpoint(neutronV20.UpdateCommand):
|
||||
"""Update policy_target's information."""
|
||||
class UpdatePolicyTarget(neutronV20.UpdateCommand):
|
||||
"""Update Policy Target's information."""
|
||||
|
||||
resource = 'endpoint'
|
||||
log = logging.getLogger(__name__ + '.UpdateEndpoint')
|
||||
resource = 'policy_target'
|
||||
log = logging.getLogger(__name__ + '.UpdatePolicyTarget')
|
||||
|
||||
|
||||
class ListEndpointGroup(neutronV20.ListCommand):
|
||||
"""List groups that belong to a given tenant."""
|
||||
class ListPolicyTargetGroup(neutronV20.ListCommand):
|
||||
"""List Policy Target Groups that belong to a given tenant."""
|
||||
|
||||
resource = 'endpoint_group'
|
||||
log = logging.getLogger(__name__ + '.ListEndpointGroup')
|
||||
resource = 'policy_target_group'
|
||||
log = logging.getLogger(__name__ + '.ListPolicyTargetGroup')
|
||||
list_columns = ['id', 'name', 'description']
|
||||
pagination_support = True
|
||||
sorting_support = True
|
||||
|
||||
|
||||
class ShowEndpointGroup(neutronV20.ShowCommand):
|
||||
"""Show information of a given group."""
|
||||
class ShowPolicyTargetGroup(neutronV20.ShowCommand):
|
||||
"""Show information of a given Policy Target Group."""
|
||||
|
||||
resource = 'endpoint_group'
|
||||
log = logging.getLogger(__name__ + '.ShowEndpointGroup')
|
||||
resource = 'policy_target_group'
|
||||
log = logging.getLogger(__name__ + '.ShowPolicyTargetGroup')
|
||||
|
||||
|
||||
class CreateEndpointGroup(neutronV20.CreateCommand):
|
||||
"""Create a group for a given tenant."""
|
||||
class CreatePolicyTargetGroup(neutronV20.CreateCommand):
|
||||
"""Create a Policy Target Group for a given tenant."""
|
||||
|
||||
resource = 'endpoint_group'
|
||||
log = logging.getLogger(__name__ + '.CreateEndpointGroup')
|
||||
resource = 'policy_target_group'
|
||||
log = logging.getLogger(__name__ + '.CreatePolicyTargetGroup')
|
||||
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--description',
|
||||
help=_('Description of the group'))
|
||||
help=_('Description of the Policy Target Group'))
|
||||
parser.add_argument(
|
||||
'name', metavar='NAME',
|
||||
help=_('Name of group to create'))
|
||||
help=_('Name of Policy Target Group to create'))
|
||||
parser.add_argument(
|
||||
'--l2-policy', metavar='L2_POLICY',
|
||||
default='',
|
||||
help=_('L2 policy uuid'))
|
||||
parser.add_argument(
|
||||
'--provided-contracts', type=utils.str2dict,
|
||||
'--provided-policy-rule-sets', type=utils.str2dict,
|
||||
default={},
|
||||
help=_('Dictionary of provided contract uuids'))
|
||||
help=_('Dictionary of provided policy rule set uuids'))
|
||||
parser.add_argument(
|
||||
'--consumed-contracts', type=utils.str2dict,
|
||||
'--consumed-policy-rule-sets', type=utils.str2dict,
|
||||
default={},
|
||||
help=_('Dictionary of consumed contract uuids'))
|
||||
help=_('Dictionary of consumed policy rule set uuids'))
|
||||
parser.add_argument(
|
||||
'--network-service-policy', metavar='NETWORK_SERVICE_POLICY',
|
||||
default='',
|
||||
help=_('Network service policy uuid'))
|
||||
parser.add_argument(
|
||||
'--subnets', type=string.split,
|
||||
help=_('Subnet to map the group'))
|
||||
help=_('List of neutron subnet uuids'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {self.resource: {}, }
|
||||
@ -165,21 +165,21 @@ class CreateEndpointGroup(neutronV20.CreateCommand):
|
||||
self.get_client(), 'network_service_policy',
|
||||
parsed_args.network_service_policy)
|
||||
|
||||
if parsed_args.provided_contracts:
|
||||
for key in parsed_args.provided_contracts.keys():
|
||||
if parsed_args.provided_policy_rule_sets:
|
||||
for key in parsed_args.provided_policy_rule_sets.keys():
|
||||
id_key = neutronV20.find_resourceid_by_name_or_id(
|
||||
self.get_client(), 'contract',
|
||||
self.get_client(), 'policy_rule_set',
|
||||
key)
|
||||
parsed_args.provided_contracts[id_key] = \
|
||||
parsed_args.provided_contracts.pop(key)
|
||||
parsed_args.provided_policy_rule_sets[id_key] = \
|
||||
parsed_args.provided_policy_rule_sets.pop(key)
|
||||
|
||||
if parsed_args.consumed_contracts:
|
||||
for key in parsed_args.consumed_contracts.keys():
|
||||
if parsed_args.consumed_policy_rule_sets:
|
||||
for key in parsed_args.consumed_policy_rule_sets.keys():
|
||||
id_key = neutronV20.find_resourceid_by_name_or_id(
|
||||
self.get_client(), 'contract',
|
||||
self.get_client(), 'policy_rule_set',
|
||||
key)
|
||||
parsed_args.consumed_contracts[id_key] = \
|
||||
parsed_args.consumed_contracts.pop(key)
|
||||
parsed_args.consumed_policy_rule_sets[id_key] = \
|
||||
parsed_args.consumed_policy_rule_sets.pop(key)
|
||||
|
||||
if parsed_args.subnets:
|
||||
for subnet in parsed_args.subnets:
|
||||
@ -190,29 +190,29 @@ class CreateEndpointGroup(neutronV20.CreateCommand):
|
||||
parsed_args.subnets.append(subnet_id)
|
||||
neutronV20.update_dict(parsed_args, body[self.resource],
|
||||
['name', 'tenant_id', 'description',
|
||||
'provided_contracts', 'subnets',
|
||||
'consumed_contracts'])
|
||||
'provided_policy_rule_sets', 'subnets',
|
||||
'consumed_policy_rule_sets'])
|
||||
|
||||
return body
|
||||
|
||||
|
||||
class DeleteEndpointGroup(neutronV20.DeleteCommand):
|
||||
"""Delete a given group."""
|
||||
class DeletePolicyTargetGroup(neutronV20.DeleteCommand):
|
||||
"""Delete a given Policy Target Group."""
|
||||
|
||||
resource = 'endpoint_group'
|
||||
log = logging.getLogger(__name__ + '.DeleteEndpointGroup')
|
||||
resource = 'policy_target_group'
|
||||
log = logging.getLogger(__name__ + '.DeletePolicyTargetGroup')
|
||||
|
||||
|
||||
class UpdateEndpointGroup(neutronV20.UpdateCommand):
|
||||
"""Update group's information."""
|
||||
class UpdatePolicyTargetGroup(neutronV20.UpdateCommand):
|
||||
"""Update Policy Target Group's information."""
|
||||
|
||||
resource = 'endpoint_group'
|
||||
log = logging.getLogger(__name__ + '.UpdateEndpointGroup')
|
||||
resource = 'policy_target_group'
|
||||
log = logging.getLogger(__name__ + '.UpdatePolicyTargetGroup')
|
||||
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--description',
|
||||
help=_('Description of the group'))
|
||||
help=_('Description of the Policy Target Group'))
|
||||
parser.add_argument(
|
||||
'--l2-policy', metavar='L2_POLICY',
|
||||
help=_('L2 policy uuid'))
|
||||
@ -220,14 +220,14 @@ class UpdateEndpointGroup(neutronV20.UpdateCommand):
|
||||
'--network-service-policy', metavar='NETWORK_SERVICE_POLICY',
|
||||
help=_('Network Service Policy uuid'))
|
||||
parser.add_argument(
|
||||
'--provided-contracts', type=utils.str2dict,
|
||||
help=_('Dictionary of provided contract uuids'))
|
||||
'--provided-policy-rule-sets', type=utils.str2dict,
|
||||
help=_('Dictionary of provided policy rule set uuids'))
|
||||
parser.add_argument(
|
||||
'--consumed-contracts', type=utils.str2dict,
|
||||
help=_('Dictionary of consumed contract uuids'))
|
||||
'--consumed-policy-rule-sets', type=utils.str2dict,
|
||||
help=_('Dictionary of consumed policy rule set uuids'))
|
||||
parser.add_argument(
|
||||
'--subnets', type=string.split,
|
||||
help=_('Subnet to map the group'))
|
||||
help=_('Subnet for the Policy Target Group'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {self.resource: {}, }
|
||||
@ -244,21 +244,21 @@ class UpdateEndpointGroup(neutronV20.UpdateCommand):
|
||||
self.get_client(), 'network_service_policy',
|
||||
parsed_args.l2_policy)
|
||||
|
||||
if parsed_args.provided_contracts:
|
||||
for key in parsed_args.provided_contracts.keys():
|
||||
if parsed_args.provided_policy_rule_sets:
|
||||
for key in parsed_args.provided_policy_rule_sets.keys():
|
||||
id_key = neutronV20.find_resourceid_by_name_or_id(
|
||||
self.get_client(), 'contract',
|
||||
self.get_client(), 'policy_rule_set',
|
||||
key)
|
||||
parsed_args.provided_contracts[id_key] = \
|
||||
parsed_args.provided_contracts.pop(key)
|
||||
parsed_args.provided_policy_rule_sets[id_key] = \
|
||||
parsed_args.provided_policy_rule_sets.pop(key)
|
||||
|
||||
if parsed_args.consumed_contracts:
|
||||
for key in parsed_args.consumed_contracts.keys():
|
||||
if parsed_args.consumed_policy_rule_sets:
|
||||
for key in parsed_args.consumed_policy_rule_sets.keys():
|
||||
id_key = neutronV20.find_resourceid_by_name_or_id(
|
||||
self.get_client(), 'contract',
|
||||
self.get_client(), 'policy_rule_set',
|
||||
key)
|
||||
parsed_args.consumed_contracts[id_key] = \
|
||||
parsed_args.consumed_contracts.pop(key)
|
||||
parsed_args.consumed_policy_rule_sets[id_key] = \
|
||||
parsed_args.consumed_policy_rule_sets.pop(key)
|
||||
|
||||
if parsed_args.subnets:
|
||||
for subnet in parsed_args.subnets:
|
||||
@ -270,8 +270,8 @@ class UpdateEndpointGroup(neutronV20.UpdateCommand):
|
||||
|
||||
neutronV20.update_dict(parsed_args, body[self.resource],
|
||||
['name', 'tenant_id', 'description',
|
||||
'provided_contracts', 'subnets',
|
||||
'consumed_contracts'])
|
||||
'provided_policy_rule_sets', 'subnets',
|
||||
'consumed_policy_rule_sets'])
|
||||
|
||||
return body
|
||||
|
||||
@ -288,14 +288,14 @@ class ListL2Policy(neutronV20.ListCommand):
|
||||
|
||||
|
||||
class ShowL2Policy(neutronV20.ShowCommand):
|
||||
"""Show information of a given l2_policy."""
|
||||
"""Show information of a given L2 Policy."""
|
||||
|
||||
resource = 'l2_policy'
|
||||
log = logging.getLogger(__name__ + '.ShowL2Policy')
|
||||
|
||||
|
||||
class CreateL2Policy(neutronV20.CreateCommand):
|
||||
"""Create a bridge_domain for a given tenant."""
|
||||
"""Create a L2 Policy for a given tenant."""
|
||||
|
||||
resource = 'l2_policy'
|
||||
log = logging.getLogger(__name__ + '.CreateL2Policy')
|
||||
@ -303,17 +303,17 @@ class CreateL2Policy(neutronV20.CreateCommand):
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--description',
|
||||
help=_('Description of the l2_policy'))
|
||||
help=_('Description of the L2 Policy'))
|
||||
parser.add_argument(
|
||||
'--network',
|
||||
help=_('Network to map the l2_policy'))
|
||||
help=_('Network to map the L2 Policy'))
|
||||
parser.add_argument(
|
||||
'--l3-policy',
|
||||
default='',
|
||||
help=_('l3_policy uuid'))
|
||||
help=_('L3 Policy uuid'))
|
||||
parser.add_argument(
|
||||
'name', metavar='NAME',
|
||||
help=_('Name of l2_policy to create'))
|
||||
help=_('Name of L2 Policy to create'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {self.resource: {}, }
|
||||
@ -334,14 +334,14 @@ class CreateL2Policy(neutronV20.CreateCommand):
|
||||
|
||||
|
||||
class DeleteL2Policy(neutronV20.DeleteCommand):
|
||||
"""Delete a given l2_policy."""
|
||||
"""Delete a given L2 Policy."""
|
||||
|
||||
resource = 'l2_policy'
|
||||
log = logging.getLogger(__name__ + '.DeleteL2Policy')
|
||||
|
||||
|
||||
class UpdateL2Policy(neutronV20.UpdateCommand):
|
||||
"""Update l2_policy's information."""
|
||||
"""Update L2 Policy's information."""
|
||||
|
||||
resource = 'l2_policy'
|
||||
log = logging.getLogger(__name__ + '.UpdateL2Policy')
|
||||
@ -360,14 +360,14 @@ class ListL3Policy(neutronV20.ListCommand):
|
||||
|
||||
|
||||
class ShowL3Policy(neutronV20.ShowCommand):
|
||||
"""Show information of a given l3_policy."""
|
||||
"""Show information of a given L3 Policy."""
|
||||
|
||||
resource = 'l3_policy'
|
||||
log = logging.getLogger(__name__ + '.ShowL3Policy')
|
||||
|
||||
|
||||
class CreateL3Policy(neutronV20.CreateCommand):
|
||||
"""Create a l3_policy for a given tenant."""
|
||||
"""Create a L3 Policy for a given tenant."""
|
||||
|
||||
resource = 'l3_policy'
|
||||
log = logging.getLogger(__name__ + '.CreateL3Policy')
|
||||
@ -375,7 +375,7 @@ class CreateL3Policy(neutronV20.CreateCommand):
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--description',
|
||||
help=_('Description of the l3_policy'))
|
||||
help=_('Description of the L3 Policy'))
|
||||
parser.add_argument(
|
||||
'--ip-version',
|
||||
type=int,
|
||||
@ -391,7 +391,7 @@ class CreateL3Policy(neutronV20.CreateCommand):
|
||||
help=_('Subnet prefix length, default is 24'))
|
||||
parser.add_argument(
|
||||
'name', metavar='NAME',
|
||||
help=_('Name of l3_policy to create'))
|
||||
help=_('Name of L3 policy to create'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {self.resource: {}, }
|
||||
@ -405,14 +405,14 @@ class CreateL3Policy(neutronV20.CreateCommand):
|
||||
|
||||
|
||||
class DeleteL3Policy(neutronV20.DeleteCommand):
|
||||
"""Delete a given l3_policy."""
|
||||
"""Delete a given L3 Policy."""
|
||||
|
||||
resource = 'l3_policy'
|
||||
log = logging.getLogger(__name__ + '.DeleteL3Policy')
|
||||
|
||||
|
||||
class UpdateL3Policy(neutronV20.UpdateCommand):
|
||||
"""Update l3_policy's information."""
|
||||
"""Update L3 Policy's information."""
|
||||
|
||||
resource = 'l3_policy'
|
||||
log = logging.getLogger(__name__ + '.UpdateL3Policy')
|
||||
@ -757,43 +757,43 @@ class UpdatePolicyRule(neutronV20.UpdateCommand):
|
||||
return body
|
||||
|
||||
|
||||
class ListContract(neutronV20.ListCommand):
|
||||
"""List contracts that belong to a given tenant."""
|
||||
class ListPolicyRuleSet(neutronV20.ListCommand):
|
||||
"""List policy_rule_sets that belong to a given tenant."""
|
||||
|
||||
resource = 'contract'
|
||||
log = logging.getLogger(__name__ + '.ListContract')
|
||||
resource = 'policy_rule_set'
|
||||
log = logging.getLogger(__name__ + '.ListPolicyRuleSet')
|
||||
_formatters = {}
|
||||
list_columns = ['id', 'name', 'ploicy_rules']
|
||||
pagination_support = True
|
||||
sorting_support = True
|
||||
|
||||
|
||||
class ShowContract(neutronV20.ShowCommand):
|
||||
"""Show information of a given contract."""
|
||||
class ShowPolicyRuleSet(neutronV20.ShowCommand):
|
||||
"""Show information of a given policy_rule_set."""
|
||||
|
||||
resource = 'contract'
|
||||
log = logging.getLogger(__name__ + '.ShowContract')
|
||||
resource = 'policy_rule_set'
|
||||
log = logging.getLogger(__name__ + '.ShowPolicyRuleSet')
|
||||
|
||||
|
||||
class CreateContract(neutronV20.CreateCommand):
|
||||
"""Create a contract for a given tenant."""
|
||||
class CreatePolicyRuleSet(neutronV20.CreateCommand):
|
||||
"""Create a policy rule set for a given tenant."""
|
||||
|
||||
resource = 'contract'
|
||||
log = logging.getLogger(__name__ + '.CreateContract')
|
||||
resource = 'policy_rule_set'
|
||||
log = logging.getLogger(__name__ + '.CreatePolicyRuleSet')
|
||||
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--description',
|
||||
help=_('Description of the contract'))
|
||||
help=_('Description of the policy rule set'))
|
||||
parser.add_argument(
|
||||
'--policy-rules', type=string.split,
|
||||
help=_('List of policy rules'))
|
||||
parser.add_argument(
|
||||
'--child-contracts', type=string.split,
|
||||
help=_('List of child contracts'))
|
||||
'--child-policy-rule-sets', type=string.split,
|
||||
help=_('List of child policy rule sets'))
|
||||
parser.add_argument(
|
||||
'name', metavar='NAME',
|
||||
help=_('Name of contract to create'))
|
||||
help=_('Name of policy rule set to create'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {self.resource: {}, }
|
||||
@ -805,38 +805,38 @@ class CreateContract(neutronV20.CreateCommand):
|
||||
'policy_rule',
|
||||
elem) for elem in parsed_args.policy_rules]
|
||||
|
||||
if parsed_args.child_contracts:
|
||||
body[self.resource]['child_contracts'] = [
|
||||
if parsed_args.child_policy_rule_sets:
|
||||
body[self.resource]['child_policy_rule_sets'] = [
|
||||
neutronV20.find_resourceid_by_name_or_id(
|
||||
self.get_client(),
|
||||
'contract',
|
||||
elem) for elem in parsed_args.child_contracts]
|
||||
'policy_rule_set',
|
||||
elem) for elem in parsed_args.child_policy_rule_sets]
|
||||
|
||||
neutronV20.update_dict(parsed_args, body[self.resource],
|
||||
['name', 'tenant_id', 'description'])
|
||||
return body
|
||||
|
||||
|
||||
class DeleteContract(neutronV20.DeleteCommand):
|
||||
"""Delete a given contract."""
|
||||
class DeletePolicyRuleSet(neutronV20.DeleteCommand):
|
||||
"""Delete a given policy rule set."""
|
||||
|
||||
resource = 'contract'
|
||||
log = logging.getLogger(__name__ + '.DeleteContract')
|
||||
resource = 'policy_rule_set'
|
||||
log = logging.getLogger(__name__ + '.DeletePolicyRuleSet')
|
||||
|
||||
|
||||
class UpdateContract(neutronV20.UpdateCommand):
|
||||
"""Update contract's information."""
|
||||
class UpdatePolicyRuleSet(neutronV20.UpdateCommand):
|
||||
"""Update policy rule set's information."""
|
||||
|
||||
resource = 'contract'
|
||||
log = logging.getLogger(__name__ + '.UpdateContract')
|
||||
resource = 'policy_rule_set'
|
||||
log = logging.getLogger(__name__ + '.UpdatePolicyRuleSet')
|
||||
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--policy-rules', type=string.split,
|
||||
help=_('List of policy rules'))
|
||||
parser.add_argument(
|
||||
'--child-contracts', type=string.split,
|
||||
help=_('List of child contracts'))
|
||||
'--child-policy-rule-sets', type=string.split,
|
||||
help=_('List of child policy rule sets'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {self.resource: {}, }
|
||||
@ -848,14 +848,15 @@ class UpdateContract(neutronV20.UpdateCommand):
|
||||
elem) for elem in parsed_args.policy_rules]
|
||||
parsed_args.policy_rules = body[self.resource]['policy_rules']
|
||||
|
||||
if parsed_args.child_contracts:
|
||||
body[self.resource]['child_contracts'] = [
|
||||
if parsed_args.child_policy_rule_sets:
|
||||
body[self.resource]['child_policy_rule_sets'] = [
|
||||
neutronV20.find_resourceid_by_name_or_id(
|
||||
self.get_client(),
|
||||
'contract',
|
||||
elem) for elem in parsed_args.child_contracts]
|
||||
parsed_args.child_contracts = parsed_args.child_contracts
|
||||
'policy_rule_set',
|
||||
elem) for elem in parsed_args.child_policy_rule_sets]
|
||||
parsed_args.child_policy_rule_sets = (
|
||||
parsed_args.child_policy_rule_sets)
|
||||
neutronV20.update_dict(parsed_args, body[self.resource],
|
||||
['name', 'description', 'policy_rules',
|
||||
'child_contracts'])
|
||||
'child_policy_rule_sets'])
|
||||
return body
|
||||
|
@ -60,10 +60,10 @@ class CreateServiceChainInstance(neutronV20.CreateCommand):
|
||||
'--service-chain-spec', dest='servicechain_spec',
|
||||
help=_('Service Chain Spec ID or the Service Chain Spec name'))
|
||||
parser.add_argument(
|
||||
'--provider-epg', dest='provider_epg',
|
||||
'--provider-ptg', dest='provider_ptg',
|
||||
help=_('Destination Policy Target Group ID of the Provider.'))
|
||||
parser.add_argument(
|
||||
'--consumer-epg', dest='consumer_epg',
|
||||
'--consumer-ptg', dest='consumer_ptg',
|
||||
help=_('Source Policy Target Group ID of the Consumer.'))
|
||||
parser.add_argument(
|
||||
'--param-values', dest='param_values',
|
||||
@ -77,20 +77,20 @@ class CreateServiceChainInstance(neutronV20.CreateCommand):
|
||||
neutronV20.find_resourceid_by_name_or_id(
|
||||
self.get_client(), 'servicechain_spec',
|
||||
parsed_args.servicechain_spec)
|
||||
if parsed_args.provider_epg:
|
||||
body[self.resource]['provider_epg'] = \
|
||||
if parsed_args.provider_ptg:
|
||||
body[self.resource]['provider_ptg'] = \
|
||||
neutronV20.find_resourceid_by_name_or_id(
|
||||
self.get_client(), 'endpoint_group',
|
||||
parsed_args.provider_epg)
|
||||
if parsed_args.consumer_epg:
|
||||
body[self.resource]['consumer_epg'] = \
|
||||
self.get_client(), 'policy_target_group',
|
||||
parsed_args.provider_ptg)
|
||||
if parsed_args.consumer_ptg:
|
||||
body[self.resource]['consumer_ptg'] = \
|
||||
neutronV20.find_resourceid_by_name_or_id(
|
||||
self.get_client(), 'endpoint_group',
|
||||
parsed_args.consumer_epg)
|
||||
self.get_client(), 'policy_target_group',
|
||||
parsed_args.consumer_ptg)
|
||||
neutronV20.update_dict(parsed_args, body[self.resource],
|
||||
['name', 'tenant_id', 'description',
|
||||
'servicechain_spec', 'provider_epg',
|
||||
'consumer_epg', 'param_values'])
|
||||
'servicechain_spec', 'provider_ptg',
|
||||
'consumer_ptg', 'param_values'])
|
||||
return body
|
||||
|
||||
|
||||
@ -105,10 +105,10 @@ class UpdateServiceChainInstance(neutronV20.UpdateCommand):
|
||||
'--service-chain-spec', dest='servicechain_spec',
|
||||
help=_('Service Chain Spec ID or the Service Chain Spec name'))
|
||||
parser.add_argument(
|
||||
'--provider-epg', dest='provider_epg',
|
||||
'--provider-ptg', dest='provider_ptg',
|
||||
help=_('Destination Policy Target Group ID of the Provider.'))
|
||||
parser.add_argument(
|
||||
'--consumer-epg', dest='consumer_epg',
|
||||
'--consumer-ptg', dest='consumer_ptg',
|
||||
help=_('Source Policy Target Group ID of the Consumer.'))
|
||||
parser.add_argument(
|
||||
'--param-values', dest='param_values',
|
||||
@ -122,20 +122,20 @@ class UpdateServiceChainInstance(neutronV20.UpdateCommand):
|
||||
neutronV20.find_resourceid_by_name_or_id(
|
||||
self.get_client(), 'servicechain_spec',
|
||||
parsed_args.servicechain_spec)
|
||||
if parsed_args.provider_epg:
|
||||
body[self.resource]['provider_epg'] = \
|
||||
if parsed_args.provider_ptg:
|
||||
body[self.resource]['provider_ptg'] = \
|
||||
neutronV20.find_resourceid_by_name_or_id(
|
||||
self.get_client(), 'endpoint_group',
|
||||
parsed_args.provider_epg)
|
||||
if parsed_args.consumer_epg:
|
||||
body[self.resource]['consumer_epg'] = \
|
||||
self.get_client(), 'policy_target_group',
|
||||
parsed_args.provider_ptg)
|
||||
if parsed_args.consumer_ptg:
|
||||
body[self.resource]['consumer_ptg'] = \
|
||||
neutronV20.find_resourceid_by_name_or_id(
|
||||
self.get_client(), 'endpoint_group',
|
||||
parsed_args.consumer_epg)
|
||||
self.get_client(), 'policy_target_group',
|
||||
parsed_args.consumer_ptg)
|
||||
neutronV20.update_dict(parsed_args, body[self.resource],
|
||||
['name', 'description',
|
||||
'servicechain_spec', 'provider_epg',
|
||||
'consumer_epg', 'param_values'])
|
||||
'servicechain_spec', 'provider_ptg',
|
||||
'consumer_ptg', 'param_values'])
|
||||
return body
|
||||
|
||||
|
||||
|
@ -87,16 +87,21 @@ def check_non_negative_int(value):
|
||||
|
||||
|
||||
COMMAND_V2 = {
|
||||
'policy-target-create': gbp.CreateEndpoint,
|
||||
'policy-target-delete': gbp.DeleteEndpoint,
|
||||
'policy-target-update': gbp.UpdateEndpoint,
|
||||
'policy-target-list': gbp.ListEndpoint,
|
||||
'policy-target-show': gbp.ShowEndpoint,
|
||||
'group-create': gbp.CreateEndpointGroup,
|
||||
'group-delete': gbp.DeleteEndpointGroup,
|
||||
'group-update': gbp.UpdateEndpointGroup,
|
||||
'group-list': gbp.ListEndpointGroup,
|
||||
'group-show': gbp.ShowEndpointGroup,
|
||||
'policy-target-create': gbp.CreatePolicyTarget,
|
||||
'policy-target-delete': gbp.DeletePolicyTarget,
|
||||
'policy-target-update': gbp.UpdatePolicyTarget,
|
||||
'policy-target-list': gbp.ListPolicyTarget,
|
||||
'policy-target-show': gbp.ShowPolicyTarget,
|
||||
'policy-target-group-create': gbp.CreatePolicyTargetGroup,
|
||||
'policy-target-group-delete': gbp.DeletePolicyTargetGroup,
|
||||
'policy-target-group-update': gbp.UpdatePolicyTargetGroup,
|
||||
'policy-target-group-list': gbp.ListPolicyTargetGroup,
|
||||
'policy-target-group-show': gbp.ShowPolicyTargetGroup,
|
||||
'group-create': gbp.CreatePolicyTargetGroup,
|
||||
'group-delete': gbp.DeletePolicyTargetGroup,
|
||||
'group-update': gbp.UpdatePolicyTargetGroup,
|
||||
'group-list': gbp.ListPolicyTargetGroup,
|
||||
'group-show': gbp.ShowPolicyTargetGroup,
|
||||
'l2policy-create': gbp.CreateL2Policy,
|
||||
'l2policy-delete': gbp.DeleteL2Policy,
|
||||
'l2policy-update': gbp.UpdateL2Policy,
|
||||
@ -127,11 +132,11 @@ COMMAND_V2 = {
|
||||
'policy-rule-update': gbp.UpdatePolicyRule,
|
||||
'policy-rule-list': gbp.ListPolicyRule,
|
||||
'policy-rule-show': gbp.ShowPolicyRule,
|
||||
'policy-rule-set-create': gbp.CreateContract,
|
||||
'policy-rule-set-delete': gbp.DeleteContract,
|
||||
'policy-rule-set-update': gbp.UpdateContract,
|
||||
'policy-rule-set-list': gbp.ListContract,
|
||||
'policy-rule-set-show': gbp.ShowContract,
|
||||
'policy-rule-set-create': gbp.CreatePolicyRuleSet,
|
||||
'policy-rule-set-delete': gbp.DeletePolicyRuleSet,
|
||||
'policy-rule-set-update': gbp.UpdatePolicyRuleSet,
|
||||
'policy-rule-set-list': gbp.ListPolicyRuleSet,
|
||||
'policy-rule-set-show': gbp.ShowPolicyRuleSet,
|
||||
'servicechain-node-list': servicechain.ListServiceChainNode,
|
||||
'servicechain-node-show': servicechain.ShowServiceChainNode,
|
||||
'servicechain-node-create': servicechain.CreateServiceChainNode,
|
||||
|
@ -147,10 +147,10 @@ class Client(object):
|
||||
|
||||
"""
|
||||
|
||||
endpoints_path = "/grouppolicy/endpoints"
|
||||
endpoint_path = "/grouppolicy/endpoints/%s"
|
||||
endpoint_groups_path = "/grouppolicy/endpoint_groups"
|
||||
endpoint_group_path = "/grouppolicy/endpoint_groups/%s"
|
||||
policy_targets_path = "/grouppolicy/policy_targets"
|
||||
policy_target_path = "/grouppolicy/policy_targets/%s"
|
||||
policy_target_groups_path = "/grouppolicy/policy_target_groups"
|
||||
policy_target_group_path = "/grouppolicy/policy_target_groups/%s"
|
||||
l2_policies_path = "/grouppolicy/l2_policies"
|
||||
l2_policy_path = "/grouppolicy/l2_policies/%s"
|
||||
l3_policies_path = "/grouppolicy/l3_policies"
|
||||
@ -163,8 +163,8 @@ class Client(object):
|
||||
policy_action_path = "/grouppolicy/policy_actions/%s"
|
||||
policy_rules_path = "/grouppolicy/policy_rules"
|
||||
policy_rule_path = "/grouppolicy/policy_rules/%s"
|
||||
contracts_path = "/grouppolicy/contracts"
|
||||
contract_path = "/grouppolicy/contracts/%s"
|
||||
policy_rule_sets_path = "/grouppolicy/policy_rule_sets"
|
||||
policy_rule_set_path = "/grouppolicy/policy_rule_sets/%s"
|
||||
servicechain_nodes_path = "/servicechain/servicechain_nodes"
|
||||
servicechain_node_path = "/servicechain/servicechain_nodes/%s"
|
||||
servicechain_specs_path = "/servicechain/servicechain_specs"
|
||||
@ -173,15 +173,15 @@ class Client(object):
|
||||
servicechain_instance_path = "/servicechain/servicechain_instances/%s"
|
||||
|
||||
# API has no way to report plurals, so we have to hard code them
|
||||
EXTED_PLURALS = {'endpoints': 'endpoint',
|
||||
'endpoint_groups': 'endpoint_group',
|
||||
EXTED_PLURALS = {'policy_targets': 'policy_target',
|
||||
'policy_target_groups': 'policy_target_group',
|
||||
'l2_policies': 'l2_policy',
|
||||
'l3_policies': 'l3_policy',
|
||||
'network_service_policies': 'network_service_policy',
|
||||
'policy_classifiers': 'policy_classifier',
|
||||
'policy_actions': 'policy_action',
|
||||
'policy_rules': 'policy_rule',
|
||||
'contracts': 'contract',
|
||||
'policy_rule_sets': 'policy_rule_set',
|
||||
}
|
||||
# 8192 Is the default max URI len for eventlet.wsgi.server
|
||||
MAX_URI_LEN = 8192
|
||||
@ -210,60 +210,63 @@ class Client(object):
|
||||
return self.get(self.extension_path % ext_alias, params=_params)
|
||||
|
||||
@APIParamsCall
|
||||
def list_endpoints(self, retrieve_all=True, **_params):
|
||||
"""Fetches a list of all endpoints for a tenant."""
|
||||
def list_policy_targets(self, retrieve_all=True, **_params):
|
||||
"""Fetches a list of all policy targets for a tenant."""
|
||||
# Pass filters in "params" argument to do_request
|
||||
return self.list('endpoints', self.endpoints_path, retrieve_all,
|
||||
**_params)
|
||||
|
||||
@APIParamsCall
|
||||
def show_endpoint(self, endpoint, **_params):
|
||||
"""Fetches information of a certain endpoint."""
|
||||
return self.get(self.endpoint_path % (endpoint), params=_params)
|
||||
|
||||
@APIParamsCall
|
||||
def create_endpoint(self, body=None):
|
||||
"""Creates a new endpoint."""
|
||||
return self.post(self.endpoints_path, body=body)
|
||||
|
||||
@APIParamsCall
|
||||
def update_endpoint(self, endpoint, body=None):
|
||||
"""Updates a endpoint."""
|
||||
return self.put(self.endpoint_path % (endpoint), body=body)
|
||||
|
||||
@APIParamsCall
|
||||
def delete_endpoint(self, endpoint):
|
||||
"""Deletes the specified endpoint."""
|
||||
return self.delete(self.endpoint_path % (endpoint))
|
||||
|
||||
@APIParamsCall
|
||||
def list_endpoint_groups(self, retrieve_all=True, **_params):
|
||||
"""Fetches a list of all endpoint_groups for a tenant."""
|
||||
# Pass filters in "params" argument to do_request
|
||||
return self.list('endpoint_groups', self.endpoint_groups_path,
|
||||
return self.list('policy_targets', self.policy_targets_path,
|
||||
retrieve_all, **_params)
|
||||
|
||||
@APIParamsCall
|
||||
def show_endpoint_group(self, endpoint_group, **_params):
|
||||
"""Fetches information of a certain endpoint_group."""
|
||||
return self.get(self.endpoint_group_path % (endpoint_group),
|
||||
def show_policy_target(self, policy_target, **_params):
|
||||
"""Fetches information of a certain policy target."""
|
||||
return self.get(self.policy_target_path % (policy_target),
|
||||
params=_params)
|
||||
|
||||
@APIParamsCall
|
||||
def create_endpoint_group(self, body=None):
|
||||
"""Creates a new endpoint_group."""
|
||||
return self.post(self.endpoint_groups_path, body=body)
|
||||
def create_policy_target(self, body=None):
|
||||
"""Creates a new policy target."""
|
||||
return self.post(self.policy_targets_path, body=body)
|
||||
|
||||
@APIParamsCall
|
||||
def update_endpoint_group(self, endpoint_group, body=None):
|
||||
"""Updates a endpoint_group."""
|
||||
return self.put(self.endpoint_group_path % (endpoint_group),
|
||||
def update_policy_target(self, policy_target, body=None):
|
||||
"""Updates a policy target."""
|
||||
return self.put(self.policy_target_path % (policy_target), body=body)
|
||||
|
||||
@APIParamsCall
|
||||
def delete_policy_target(self, policy_target):
|
||||
"""Deletes the specified policy target."""
|
||||
return self.delete(self.policy_target_path % (policy_target))
|
||||
|
||||
@APIParamsCall
|
||||
def list_policy_target_groups(self, retrieve_all=True, **_params):
|
||||
"""Fetches a list of all policy target_groups for a tenant."""
|
||||
# Pass filters in "params" argument to do_request
|
||||
return self.list('policy_target_groups',
|
||||
self.policy_target_groups_path, retrieve_all,
|
||||
**_params)
|
||||
|
||||
@APIParamsCall
|
||||
def show_policy_target_group(self, policy_target_group, **_params):
|
||||
"""Fetches information of a certain policy target_group."""
|
||||
return self.get(self.policy_target_group_path % (policy_target_group),
|
||||
params=_params)
|
||||
|
||||
@APIParamsCall
|
||||
def create_policy_target_group(self, body=None):
|
||||
"""Creates a new policy target_group."""
|
||||
return self.post(self.policy_target_groups_path, body=body)
|
||||
|
||||
@APIParamsCall
|
||||
def update_policy_target_group(self, policy_target_group, body=None):
|
||||
"""Updates a policy target_group."""
|
||||
return self.put(self.policy_target_group_path % (policy_target_group),
|
||||
body=body)
|
||||
|
||||
@APIParamsCall
|
||||
def delete_endpoint_group(self, endpoint_group):
|
||||
"""Deletes the specified endpoint_group."""
|
||||
return self.delete(self.endpoint_group_path % (endpoint_group))
|
||||
def delete_policy_target_group(self, policy_target_group):
|
||||
"""Deletes the specified policy target_group."""
|
||||
return self.delete(
|
||||
self.policy_target_group_path % (policy_target_group))
|
||||
|
||||
@APIParamsCall
|
||||
def list_l2_policies(self, retrieve_all=True, **_params):
|
||||
@ -440,31 +443,33 @@ class Client(object):
|
||||
return self.delete(self.policy_rule_path % (policy_rule))
|
||||
|
||||
@APIParamsCall
|
||||
def list_contracts(self, retrieve_all=True, **_params):
|
||||
"""Fetches a list of all contracts for a tenant."""
|
||||
def list_policy_rule_sets(self, retrieve_all=True, **_params):
|
||||
"""Fetches a list of all Policy Rule Sets for a tenant."""
|
||||
# Pass filters in "params" argument to do_request
|
||||
return self.list('contracts', self.contracts_path, retrieve_all,
|
||||
**_params)
|
||||
return self.list('policy_rule_sets', self.policy_rule_sets_path,
|
||||
retrieve_all, **_params)
|
||||
|
||||
@APIParamsCall
|
||||
def show_contract(self, contract, **_params):
|
||||
"""Fetches information of a certain contract."""
|
||||
return self.get(self.contract_path % (contract), params=_params)
|
||||
def show_policy_rule_set(self, policy_rule_set, **_params):
|
||||
"""Fetches information of a certain Policy Rule Set."""
|
||||
return self.get(self.policy_rule_set_path % (policy_rule_set),
|
||||
params=_params)
|
||||
|
||||
@APIParamsCall
|
||||
def create_contract(self, body=None):
|
||||
"""Creates a new contract."""
|
||||
return self.post(self.contracts_path, body=body)
|
||||
def create_policy_rule_set(self, body=None):
|
||||
"""Creates a new Policy Rule Set."""
|
||||
return self.post(self.policy_rule_sets_path, body=body)
|
||||
|
||||
@APIParamsCall
|
||||
def update_contract(self, contract, body=None):
|
||||
"""Updates a contract."""
|
||||
return self.put(self.contract_path % (contract), body=body)
|
||||
def update_policy_rule_set(self, policy_rule_set, body=None):
|
||||
"""Updates a Policy Rule Set."""
|
||||
return self.put(self.policy_rule_set_path % (policy_rule_set),
|
||||
body=body)
|
||||
|
||||
@APIParamsCall
|
||||
def delete_contract(self, contract):
|
||||
"""Deletes the specified contract."""
|
||||
return self.delete(self.contract_path % (contract))
|
||||
def delete_policy_rule_set(self, policy_rule_set):
|
||||
"""Deletes the specified Policy Rule Set."""
|
||||
return self.delete(self.policy_rule_set_path % (policy_rule_set))
|
||||
|
||||
def list_servicechain_nodes(self, retrieve_all=True, **_params):
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user