diff --git a/libs/skyline-policy-manager/skyline_policy_manager/cmd/manage.py b/libs/skyline-policy-manager/skyline_policy_manager/cmd/manage.py index 3db6997..4a16d08 100644 --- a/libs/skyline-policy-manager/skyline_policy_manager/cmd/manage.py +++ b/libs/skyline-policy-manager/skyline_policy_manager/cmd/manage.py @@ -134,7 +134,10 @@ def generate_conf(dir: str, desc: str) -> None: f.write(f"{'#' * 20}\n# {service}\n{'#' * 20}\n") f.write(f"# {desc}\n\n") for rule in rules: - f.writelines(rule.format_into_yaml()) + rule_yaml = rule.format_into_yaml() + if service in constants.PREFIX_MAPPINGS: + rule_yaml = rule_yaml.replace(constants.PREFIX_MAPPINGS[service], "") + f.writelines(rule_yaml) LOG.info("Generate policy successful") @@ -192,7 +195,7 @@ list_rules = (""" for r in api_rules: print( apirule_format_str.format( - name=json.dumps(r.name), + name=json.dumps(constants.PREFIX_MAPPINGS.get(entry_point, "") + r.name), check_str=json.dumps(r.check_str), description=json.dumps(r.description), scope_types=json.dumps(r.scope_types), diff --git a/libs/skyline-policy-manager/skyline_policy_manager/constants.py b/libs/skyline-policy-manager/skyline_policy_manager/constants.py index 7f64962..ff3f8fb 100644 --- a/libs/skyline-policy-manager/skyline_policy_manager/constants.py +++ b/libs/skyline-policy-manager/skyline_policy_manager/constants.py @@ -26,4 +26,7 @@ SUPPORTED_SERVICE_EPS = { "octavia": ["octavia"], "panko": ["panko"], "placement": ["placement"], + "trove": ["trove"], } + +PREFIX_MAPPINGS = {"trove": "trove:"} diff --git a/libs/skyline-policy-manager/skyline_policy_manager/policies/trove.py b/libs/skyline-policy-manager/skyline_policy_manager/policies/trove.py index ce8751b..57c8562 100644 --- a/libs/skyline-policy-manager/skyline_policy_manager/policies/trove.py +++ b/libs/skyline-policy-manager/skyline_policy_manager/policies/trove.py @@ -8,7 +8,7 @@ list_rules = ( ), base.Rule( name="admin_or_owner", - check_str=("rule:admin or tenant:%(tenant)s"), + check_str=("rule:admin or project_id:%(tenant)s"), description="Must be an administrator or owner of the object.", ), base.Rule( @@ -131,8 +131,7 @@ list_rules = ( operations=[ { "method": "POST", - "path": "/v1.0/{account_id}/instances/{instance_id}/action" - + "(promote_to_replica_source)", + "path": "/v1.0/{account_id}/instances/{instance_id}/action (promote_to_replica_source)", # noqa }, ], ), @@ -328,8 +327,7 @@ list_rules = ( operations=[ { "method": "DELETE", - "path": "/v1.0/{account_id}/instances/{instance_id}/users/{user}" - + "/databases/{database}", + "path": "/v1.0/{account_id}/instances/{instance_id}/users/{user}/databases/{database}", # noqa }, ], ), @@ -549,8 +547,7 @@ list_rules = ( base.APIRule( name="trove:configuration:update", check_str=("rule:admin_or_owner"), - description="Update a configuration group(the configuration group will be replaced" - + "completely).", + description="Update a configuration group(the configuration group will be replaced completely).", # noqa scope_types=["project"], operations=[{"method": "PUT", "path": "/v1.0/{account_id}/configurations/{config}"}], ), @@ -581,16 +578,14 @@ list_rules = ( operations=[ { "method": "GET", - "path": "/v1.0/{account_id}/datastores/{datastore}/versions/{version}/parameters" - + "/{param}", + "path": "/v1.0/{account_id}/datastores/{datastore}/versions/{version}/parameters/{param}", # noqa }, ], ), base.APIRule( name="trove:configuration-parameter:index_by_version", check_str=("rule:admin_or_owner"), - description="List all paramters bind to a datastore version by the id of the" - + "version(datastore is not provided).", + description="List all paramters bind to a datastore version by the id of the version(datastore is not provided).", # noqa scope_types=["project"], operations=[ { @@ -602,8 +597,7 @@ list_rules = ( base.APIRule( name="trove:configuration-parameter:show_by_version", check_str=("rule:admin_or_owner"), - description="Get a paramter of a datastore version by it names and the id of the" - + "version(datastore is not provided).", + description="Get a paramter of a datastore version by it names and the id of the version(datastore is not provided).", # noqa scope_types=["project"], operations=[ { @@ -648,8 +642,7 @@ list_rules = ( base.APIRule( name="trove:datastore:version_show_by_uuid", check_str=(""), - description="Get a version of a datastore by the version" - + "id(without providing the datastore id).", + description="Get a version of a datastore by the version id(without providing the datastore id).", # noqa scope_types=["project"], operations=[ {"method": "GET", "path": "/v1.0/{account_id}/datastores/versions/{version}"}, @@ -684,8 +677,7 @@ list_rules = ( operations=[ { "method": "GET", - "path": "/v1.0/{account_id}/datastores/{datastore}/versions/{version}" - + "/volume-types", + "path": "/v1.0/{account_id}/datastores/{datastore}/versions/{version}/volume-types", # noqa }, ], ),