Fix DNS urls and make easy zone tasks actions
Change-Id: Iab8d69085280aebee5d96991bd5a31ba1089a1e0
This commit is contained in:
@@ -524,6 +524,12 @@ def get_resource_names_from_url(path: str):
|
||||
path_resource_names = ["domain", "config", "group"]
|
||||
elif path == "/v3/domains/config/{group}/{option}/default":
|
||||
path_resource_names = ["domain", "config", "group", "option"]
|
||||
elif path in [
|
||||
"/v2/zones/{zone_id}/tasks/xfr",
|
||||
"/v2/zones/{zone_id}/tasks/abandon",
|
||||
"/v2/zones/{zone_id}/tasks/pool_move",
|
||||
]:
|
||||
path_resource_names = ["zone", "task"]
|
||||
|
||||
if path == "/v2.0/ports/{port_id}/bindings/{id}/activate":
|
||||
path_resource_names = ["port", "binding"]
|
||||
|
||||
@@ -405,6 +405,14 @@ class MetadataGenerator(BaseGenerator):
|
||||
"post": "update",
|
||||
}
|
||||
operation_key = mapping_account[method]
|
||||
if args.service_type == "dns":
|
||||
if resource_name == "zone/task":
|
||||
if path == "/v2/zones/{zone_id}/tasks/xfr":
|
||||
operation_key = "xfr"
|
||||
if path == "/v2/zones/{zone_id}/tasks/abandon":
|
||||
operation_key = "abandon"
|
||||
if path == "/v2/zones/{zone_id}/tasks/pool_move":
|
||||
operation_key = "pool_move"
|
||||
|
||||
if operation_key in resource_model:
|
||||
raise RuntimeError("Operation name conflict")
|
||||
@@ -767,6 +775,10 @@ def post_process_operation(
|
||||
operation = post_process_compute_operation(
|
||||
resource_name, operation_name, operation
|
||||
)
|
||||
elif service_type == "dns":
|
||||
operation = post_process_dns_operation(
|
||||
resource_name, operation_name, operation
|
||||
)
|
||||
elif service_type == "identity":
|
||||
operation = post_process_identity_operation(
|
||||
resource_name, operation_name, operation
|
||||
@@ -1167,3 +1179,16 @@ def post_process_object_store_operation(
|
||||
operation.operation_type = "upload"
|
||||
|
||||
return operation
|
||||
|
||||
|
||||
def post_process_dns_operation(
|
||||
resource_name: str, operation_name: str, operation
|
||||
):
|
||||
# if resource_name == "zone/xfr":
|
||||
# if operation_name == "create":
|
||||
# operation.targets["rust-cli"].cli_full_command = "xfr"
|
||||
# if resource_name == "zone/xfr":
|
||||
# if operation_name == "create":
|
||||
# operation.targets["rust-cli"].cli_full_command = "xfr"
|
||||
|
||||
return operation
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
# under the License.
|
||||
#
|
||||
import inspect
|
||||
import logging
|
||||
from multiprocessing import Process
|
||||
from pathlib import Path
|
||||
from unittest import mock
|
||||
@@ -30,6 +31,7 @@ class DesignateGenerator(OpenStackServerSourceBase):
|
||||
URL_TAG_MAP = {
|
||||
"/zones/tasks/transfer_accepts": "zone-ownership-transfers-accepts",
|
||||
"/zones/tasks/transfer_requests": "zone-ownership-transfers-requests",
|
||||
"/zones/{zone_id}/tasks/transfer_requests": "zone-ownership-transfers-requests",
|
||||
"/zones/tasks/imports": "zone-imports",
|
||||
"/zones/tasks/exports": "zone-exports",
|
||||
"/zones/{zone_id}/tasks/export": "zone-exports",
|
||||
@@ -56,14 +58,9 @@ class DesignateGenerator(OpenStackServerSourceBase):
|
||||
return (ver.ver_major, ver.ver_minor)
|
||||
|
||||
def _build_routes(
|
||||
self,
|
||||
mapper,
|
||||
node,
|
||||
path="",
|
||||
sub_map: dict[str, str] = {},
|
||||
subcontroller_name: str | None = None,
|
||||
self, mapper, node, path: str = "", param_url_map: dict[str, str] = {}
|
||||
):
|
||||
# path = f"{path}/{subcontroller_name}"
|
||||
logging.debug(f"Processing controller {node} with {param_url_map}")
|
||||
for part in [x for x in dir(node) if callable(getattr(node, x))]:
|
||||
# Iterate over functions to find what is exposed on the current
|
||||
# level
|
||||
@@ -82,7 +79,7 @@ class DesignateGenerator(OpenStackServerSourceBase):
|
||||
# Only whatever is pecan exposed is of interest
|
||||
conditions = {}
|
||||
action = None
|
||||
url = path
|
||||
url: str = path
|
||||
resource = None
|
||||
# Check whether for mandatory params there is path defined
|
||||
# If there is entry with all parameters we are most likely on
|
||||
@@ -90,16 +87,11 @@ class DesignateGenerator(OpenStackServerSourceBase):
|
||||
# might be parent_id and id for which we do not have
|
||||
# combination yet, thus take parent_id as base url
|
||||
# for "zone_id" => /zones/{zone_id}/
|
||||
# for "zone_id zone_transfer_request_id" => /zones/{zone_id}
|
||||
# while in transfer_request controller
|
||||
if " ".join(args) in sub_map:
|
||||
url = sub_map[" ".join(args)]
|
||||
if subcontroller_name and subcontroller_name not in url:
|
||||
url += f"/{subcontroller_name}"
|
||||
elif " ".join(args[0:-1]) in sub_map:
|
||||
url = sub_map[" ".join(args[0:-1])]
|
||||
if subcontroller_name and subcontroller_name not in url:
|
||||
url += f"/{subcontroller_name}"
|
||||
# for "zone_id zone_transfer_request_id" => /zones/{zone_id}/tasks/transfer_requests/{transfer_request_id}
|
||||
if " ".join(args) in param_url_map:
|
||||
url = param_url_map[" ".join(args)]
|
||||
elif " ".join(args[0:-1]) in param_url_map:
|
||||
url = param_url_map[" ".join(args[0:-1])]
|
||||
url += f"/{{{args[-1]}}}"
|
||||
elif len(args) > 0:
|
||||
url += f"/{{{args[-1]}}}"
|
||||
@@ -109,8 +101,8 @@ class DesignateGenerator(OpenStackServerSourceBase):
|
||||
if part == "get_one":
|
||||
conditions["method"] = ["GET"]
|
||||
action = "show"
|
||||
if " ".join(args) not in sub_map:
|
||||
sub_map[" ".join(args)] = url
|
||||
# if " ".join(args) not in param_url_map:
|
||||
param_url_map[" ".join(args)] = url
|
||||
elif part == "get_all":
|
||||
conditions["method"] = ["GET"]
|
||||
action = "list"
|
||||
@@ -153,7 +145,10 @@ class DesignateGenerator(OpenStackServerSourceBase):
|
||||
# Not underested in those
|
||||
continue
|
||||
subpath = f"{path}/{subcontroller}"
|
||||
self._build_routes(mapper, v, subpath, sub_map, subcontroller)
|
||||
next_param_url_map: dict = {
|
||||
k: f"{v}/{subcontroller}" for k, v in param_url_map.items()
|
||||
}
|
||||
self._build_routes(mapper, v, subpath, next_param_url_map)
|
||||
|
||||
return
|
||||
|
||||
@@ -174,8 +169,6 @@ class DesignateGenerator(OpenStackServerSourceBase):
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
# import oslo_messaging as messaging
|
||||
# from oslo_messaging import conffixture as messaging_conffixture
|
||||
from pecan import make_app as pecan_make_app
|
||||
from routes import Mapper
|
||||
|
||||
@@ -238,6 +231,12 @@ class DesignateGenerator(OpenStackServerSourceBase):
|
||||
|
||||
self._build_routes(mapper, root.RootController, "/v2")
|
||||
for route in mapper.matchlist:
|
||||
if (
|
||||
route.routepath == "/v2/zones/{zone_id}/tasks/abandon"
|
||||
and route.conditions.get("method", "GET")[0] == "GET"
|
||||
):
|
||||
# returns 405 in Designate anyway
|
||||
continue
|
||||
self._process_route(route, openapi_spec, framework="pecan")
|
||||
|
||||
if args.api_ref_src:
|
||||
|
||||
@@ -302,12 +302,8 @@ resources:
|
||||
module_name: list
|
||||
sdk_mod_name: list
|
||||
cli_full_command: zone task transfer-request list
|
||||
dns.zone/transfer_request:
|
||||
spec_file: wrk/openapi_specs/dns/v2.1.yaml
|
||||
api_version: v2
|
||||
operations:
|
||||
create:
|
||||
operation_id: zones/zone_id/transfer_requests:post
|
||||
operation_id: zones/zone_id/tasks/transfer_requests:post
|
||||
operation_type: create
|
||||
targets:
|
||||
rust-sdk:
|
||||
@@ -315,59 +311,41 @@ resources:
|
||||
rust-cli:
|
||||
module_name: create
|
||||
sdk_mod_name: create
|
||||
cli_full_command: zone transfer-request create
|
||||
dns.zone/abandon:
|
||||
cli_full_command: zone task transfer-request create
|
||||
dns.zone/task:
|
||||
spec_file: wrk/openapi_specs/dns/v2.1.yaml
|
||||
api_version: v2
|
||||
operations:
|
||||
get:
|
||||
operation_id: zones/zone_id/abandon:get
|
||||
operation_type: get
|
||||
abandon:
|
||||
operation_id: zones/zone_id/tasks/abandon:post
|
||||
operation_type: action
|
||||
targets:
|
||||
rust-sdk:
|
||||
module_name: get
|
||||
module_name: abandon
|
||||
rust-cli:
|
||||
module_name: get
|
||||
sdk_mod_name: get
|
||||
cli_full_command: zone abandon get
|
||||
create:
|
||||
operation_id: zones/zone_id/abandon:post
|
||||
operation_type: create
|
||||
module_name: abandon
|
||||
sdk_mod_name: abandon
|
||||
cli_full_command: zone task abandon
|
||||
xfr:
|
||||
operation_id: zones/zone_id/tasks/xfr:post
|
||||
operation_type: action
|
||||
targets:
|
||||
rust-sdk:
|
||||
module_name: create
|
||||
module_name: xfr
|
||||
rust-cli:
|
||||
module_name: create
|
||||
sdk_mod_name: create
|
||||
cli_full_command: zone abandon create
|
||||
dns.zone/xfr:
|
||||
spec_file: wrk/openapi_specs/dns/v2.1.yaml
|
||||
api_version: v2
|
||||
operations:
|
||||
create:
|
||||
operation_id: zones/zone_id/xfr:post
|
||||
operation_type: create
|
||||
module_name: xfr
|
||||
sdk_mod_name: xfr
|
||||
cli_full_command: zone task xfr
|
||||
pool_move:
|
||||
operation_id: zones/zone_id/tasks/pool_move:post
|
||||
operation_type: action
|
||||
targets:
|
||||
rust-sdk:
|
||||
module_name: create
|
||||
module_name: pool_move
|
||||
rust-cli:
|
||||
module_name: create
|
||||
sdk_mod_name: create
|
||||
cli_full_command: zone xfr create
|
||||
dns.zone/pool_move:
|
||||
spec_file: wrk/openapi_specs/dns/v2.1.yaml
|
||||
api_version: v2
|
||||
operations:
|
||||
create:
|
||||
operation_id: zones/zone_id/pool_move:post
|
||||
operation_type: create
|
||||
targets:
|
||||
rust-sdk:
|
||||
module_name: create
|
||||
rust-cli:
|
||||
module_name: create
|
||||
sdk_mod_name: create
|
||||
cli_full_command: zone pool-move create
|
||||
module_name: pool_move
|
||||
sdk_mod_name: pool_move
|
||||
cli_full_command: zone task pool-move
|
||||
dns.zone/task/import:
|
||||
spec_file: wrk/openapi_specs/dns/v2.1.yaml
|
||||
api_version: v2
|
||||
@@ -446,12 +424,8 @@ resources:
|
||||
module_name: show
|
||||
sdk_mod_name: get
|
||||
cli_full_command: zone task export show
|
||||
dns.zone/export:
|
||||
spec_file: wrk/openapi_specs/dns/v2.1.yaml
|
||||
api_version: v2
|
||||
operations:
|
||||
create:
|
||||
operation_id: zones/zone_id/export:post
|
||||
operation_id: zones/zone_id/tasks/export:post
|
||||
operation_type: create
|
||||
targets:
|
||||
rust-sdk:
|
||||
@@ -459,7 +433,21 @@ resources:
|
||||
rust-cli:
|
||||
module_name: create
|
||||
sdk_mod_name: create
|
||||
cli_full_command: zone export create
|
||||
cli_full_command: zone task export create
|
||||
dns.zone/task/export/export:
|
||||
spec_file: wrk/openapi_specs/dns/v2.1.yaml
|
||||
api_version: v2
|
||||
operations:
|
||||
get:
|
||||
operation_id: zones/tasks/exports/export_id/export:get
|
||||
operation_type: get
|
||||
targets:
|
||||
rust-sdk:
|
||||
module_name: get
|
||||
rust-cli:
|
||||
module_name: get
|
||||
sdk_mod_name: get
|
||||
cli_full_command: zone task export export get
|
||||
dns.zone/nameserver:
|
||||
spec_file: wrk/openapi_specs/dns/v2.1.yaml
|
||||
api_version: v2
|
||||
@@ -654,16 +642,26 @@ resources:
|
||||
spec_file: wrk/openapi_specs/dns/v2.1.yaml
|
||||
api_version: v2
|
||||
operations:
|
||||
get:
|
||||
list:
|
||||
operation_id: service_status:get
|
||||
operation_type: get
|
||||
operation_type: list
|
||||
targets:
|
||||
rust-sdk:
|
||||
module_name: list
|
||||
rust-cli:
|
||||
module_name: list
|
||||
sdk_mod_name: list
|
||||
cli_full_command: service-status list
|
||||
show:
|
||||
operation_id: service_status/service_id:get
|
||||
operation_type: show
|
||||
targets:
|
||||
rust-sdk:
|
||||
module_name: get
|
||||
rust-cli:
|
||||
module_name: get
|
||||
module_name: show
|
||||
sdk_mod_name: get
|
||||
cli_full_command: service-status get
|
||||
cli_full_command: service-status show
|
||||
dns.tsigkey:
|
||||
spec_file: wrk/openapi_specs/dns/v2.1.yaml
|
||||
api_version: v2
|
||||
|
||||
Reference in New Issue
Block a user