Integrate octavia
We had octavia spec already, but once code generation been attempted on it series of issues were identified (mostly coming from deeper nesting and weird path naming). Change-Id: I4ecbecb17ce5bfdd0c655644a8b8349060f7c79d
This commit is contained in:
@@ -446,6 +446,7 @@ def get_resource_names_from_url(path: str):
|
|||||||
el[-1] == "s"
|
el[-1] == "s"
|
||||||
and el[-3:] != "dns"
|
and el[-3:] != "dns"
|
||||||
and el[-6:] != "access"
|
and el[-6:] != "access"
|
||||||
|
and el[-6:] != "status"
|
||||||
and el != "qos"
|
and el != "qos"
|
||||||
# quota/details
|
# quota/details
|
||||||
and el != "details"
|
and el != "details"
|
||||||
@@ -456,20 +457,21 @@ def get_resource_names_from_url(path: str):
|
|||||||
if part.startswith("os_"):
|
if part.startswith("os_"):
|
||||||
# We should remove `os_` prefix from resource name
|
# We should remove `os_` prefix from resource name
|
||||||
part = part[3:]
|
part = part[3:]
|
||||||
|
if part == "availabilityzone":
|
||||||
|
part = "availability_zone"
|
||||||
|
elif part == "availabilityzoneprofile":
|
||||||
|
part = "availability_zone_profile"
|
||||||
|
elif part == "flavorprofile":
|
||||||
|
part = "flavor_profile"
|
||||||
path_resource_names.append(part)
|
path_resource_names.append(part)
|
||||||
if len(path_resource_names) > 1 and (
|
if len(path_resource_names) > 1 and (
|
||||||
path_resource_names[-1]
|
path_resource_names[-1]
|
||||||
in [
|
in ["action", "detail", "stat", "status", "failover", "config"]
|
||||||
"action",
|
|
||||||
"detail",
|
|
||||||
]
|
|
||||||
or "add" in path_resource_names[-1]
|
or "add" in path_resource_names[-1]
|
||||||
or "remove" in path_resource_names[-1]
|
or "remove" in path_resource_names[-1]
|
||||||
or "update" in path_resource_names[-1]
|
or "update" in path_resource_names[-1]
|
||||||
):
|
):
|
||||||
path_resource_names.pop()
|
path_resource_names.pop()
|
||||||
if len(path_resource_names) == 0:
|
|
||||||
return ["version"]
|
|
||||||
if path.startswith("/v2/schemas/"):
|
if path.startswith("/v2/schemas/"):
|
||||||
# Image schemas should not be singularized (schema/images,
|
# Image schemas should not be singularized (schema/images,
|
||||||
# schema/image)
|
# schema/image)
|
||||||
@@ -482,6 +484,12 @@ def get_resource_names_from_url(path: str):
|
|||||||
path_resource_names = ["volume_transfer"]
|
path_resource_names = ["volume_transfer"]
|
||||||
if path == "/v2.0/ports/{port_id}/bindings/{id}/activate":
|
if path == "/v2.0/ports/{port_id}/bindings/{id}/activate":
|
||||||
path_resource_names = ["port", "binding"]
|
path_resource_names = ["port", "binding"]
|
||||||
|
if path.startswith("/v2/lbaas"):
|
||||||
|
path_resource_names.remove("lbaa")
|
||||||
|
if path.startswith("/v2/octavia/amphorae"):
|
||||||
|
path_resource_names.remove("octavia")
|
||||||
|
if len(path_resource_names) == 0:
|
||||||
|
return ["version"]
|
||||||
|
|
||||||
return path_resource_names
|
return path_resource_names
|
||||||
|
|
||||||
@@ -522,6 +530,8 @@ def get_rust_service_type_from_str(xtype: str):
|
|||||||
return "Network"
|
return "Network"
|
||||||
case "object-store":
|
case "object-store":
|
||||||
return "ObjectStore"
|
return "ObjectStore"
|
||||||
|
case "load-balancer":
|
||||||
|
return "LoadBalancer"
|
||||||
case _:
|
case _:
|
||||||
return xtype
|
return xtype
|
||||||
|
|
||||||
|
@@ -194,6 +194,13 @@ class MetadataGenerator(BaseGenerator):
|
|||||||
and method == "get"
|
and method == "get"
|
||||||
):
|
):
|
||||||
operation_key = "list"
|
operation_key = "list"
|
||||||
|
elif (
|
||||||
|
args.service_type == "load-balancer"
|
||||||
|
and len(path_elements) > 1
|
||||||
|
and path_elements[-1]
|
||||||
|
in ["stats", "status", "failover", "config"]
|
||||||
|
):
|
||||||
|
operation_key = path_elements[-1]
|
||||||
|
|
||||||
elif response_schema and (
|
elif response_schema and (
|
||||||
method == "get"
|
method == "get"
|
||||||
@@ -550,7 +557,7 @@ class MetadataGenerator(BaseGenerator):
|
|||||||
def get_operation_type_by_key(operation_key):
|
def get_operation_type_by_key(operation_key):
|
||||||
if operation_key in ["list", "list_detailed"]:
|
if operation_key in ["list", "list_detailed"]:
|
||||||
return "list"
|
return "list"
|
||||||
elif operation_key == "get":
|
elif operation_key in ["get", "stats", "status"]:
|
||||||
return "get"
|
return "get"
|
||||||
elif operation_key == "check":
|
elif operation_key == "check":
|
||||||
return "get"
|
return "get"
|
||||||
|
@@ -1209,9 +1209,9 @@ def _convert_wsme_to_jsonschema(body_spec):
|
|||||||
elif wtypes.isdict(body_spec):
|
elif wtypes.isdict(body_spec):
|
||||||
res = {
|
res = {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"additionalProperties": {
|
"additionalProperties": _convert_wsme_to_jsonschema(
|
||||||
"type": _convert_wsme_to_jsonschema(body_spec.value_type)
|
body_spec.value_type
|
||||||
},
|
),
|
||||||
}
|
}
|
||||||
elif wtypes.isusertype(body_spec):
|
elif wtypes.isusertype(body_spec):
|
||||||
basetype = body_spec.basetype
|
basetype = body_spec.basetype
|
||||||
|
@@ -148,7 +148,7 @@ class OctaviaGenerator(OpenStackServerSourceBase):
|
|||||||
proc.start()
|
proc.start()
|
||||||
proc.join()
|
proc.join()
|
||||||
if proc.exitcode != 0:
|
if proc.exitcode != 0:
|
||||||
raise RuntimeError("Error generating Octavia OpenAPI schma")
|
raise RuntimeError("Error generating Octavia OpenAPI schema")
|
||||||
|
|
||||||
def _generate(self, target_dir, args):
|
def _generate(self, target_dir, args):
|
||||||
from octavia.api import root_controller
|
from octavia.api import root_controller
|
||||||
@@ -172,7 +172,7 @@ class OctaviaGenerator(OpenStackServerSourceBase):
|
|||||||
impl_path = Path(
|
impl_path = Path(
|
||||||
work_dir,
|
work_dir,
|
||||||
"openapi_specs",
|
"openapi_specs",
|
||||||
"load-balancing",
|
"load-balancer",
|
||||||
f"v{self.api_version}.yaml",
|
f"v{self.api_version}.yaml",
|
||||||
)
|
)
|
||||||
impl_path.parent.mkdir(parents=True, exist_ok=True)
|
impl_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
@@ -360,13 +360,13 @@ class OctaviaGenerator(OpenStackServerSourceBase):
|
|||||||
action="status",
|
action="status",
|
||||||
conditions={"method": ["GET"]},
|
conditions={"method": ["GET"]},
|
||||||
)
|
)
|
||||||
mapper.connect(
|
# mapper.connect(
|
||||||
None,
|
# None,
|
||||||
"/v2/lbaas/loadbalancers/{loadbalancer_id}/statuses",
|
# "/v2/lbaas/loadbalancers/{loadbalancer_id}/statuses",
|
||||||
controller=load_balancer.StatusController.get,
|
# controller=load_balancer.StatusController.get,
|
||||||
action="status",
|
# action="status",
|
||||||
conditions={"method": ["GET"]},
|
# conditions={"method": ["GET"]},
|
||||||
)
|
# )
|
||||||
mapper.connect(
|
mapper.connect(
|
||||||
None,
|
None,
|
||||||
"/v2/lbaas/loadbalancers/{loadbalancer_id}/failover",
|
"/v2/lbaas/loadbalancers/{loadbalancer_id}/failover",
|
||||||
|
@@ -79,7 +79,7 @@ class OpenApiSchemaGenerator(BaseGenerator):
|
|||||||
self.generate_glance(target_dir, args)
|
self.generate_glance(target_dir, args)
|
||||||
elif args.service_type == "identity":
|
elif args.service_type == "identity":
|
||||||
self.generate_keystone(target_dir, args)
|
self.generate_keystone(target_dir, args)
|
||||||
elif args.service_type == "load-balancing":
|
elif args.service_type == "load-balancer":
|
||||||
self.generate_octavia(target_dir, args)
|
self.generate_octavia(target_dir, args)
|
||||||
elif args.service_type == "network":
|
elif args.service_type == "network":
|
||||||
self.generate_neutron(target_dir, args)
|
self.generate_neutron(target_dir, args)
|
||||||
|
@@ -15,14 +15,16 @@ if [ -z "$1" -o "$1" = "block-storage" ]; then
|
|||||||
openstack-codegenerator --work-dir wrk --target openapi-spec --service-type volume --api-ref-src ${API_REF_BUILD_ROOT}/cinder/api-ref/build/html/v3/index.html
|
openstack-codegenerator --work-dir wrk --target openapi-spec --service-type volume --api-ref-src ${API_REF_BUILD_ROOT}/cinder/api-ref/build/html/v3/index.html
|
||||||
fi
|
fi
|
||||||
if [ -z "$1" -o "$1" = "image" ]; then
|
if [ -z "$1" -o "$1" = "image" ]; then
|
||||||
openstack-codegenerator --work-dir wrk --target openapi-spec --service-type image --api-ref-src ${API_REF_BUILD_ROOT}/glance/api-ref/build/html/v2/index.html
|
openstack-codegenerator --work-dir wrk --target openapi-spec --service-type image --api-ref-src ${API_REF_BUILD_ROOT}/glance/api-ref/build/html/v2/index.html --api-ref-src ${API_REF_BUILD_ROOT}/glance/api-ref/build/html/v2/metadefs-index.html
|
||||||
|
|
||||||
sed -i "s|\[API versions call\](../versions/index.html#versions-call)|API versions call|g" wrk/openapi_specs/image/v2.yaml
|
sed -i "s|\[API versions call\](../versions/index.html#versions-call)|API versions call|g" wrk/openapi_specs/image/v2.yaml
|
||||||
fi
|
fi
|
||||||
if [ -z "$1" -o "$1" = "identity" ]; then
|
if [ -z "$1" -o "$1" = "identity" ]; then
|
||||||
openstack-codegenerator --work-dir wrk --target openapi-spec --service-type identity --api-ref-src ${API_REF_BUILD_ROOT}/keystone/api-ref/build/html/v3/index.html
|
openstack-codegenerator --work-dir wrk --target openapi-spec --service-type identity --api-ref-src ${API_REF_BUILD_ROOT}/keystone/api-ref/build/html/v3/index.html --api-ref-src ${API_REF_BUILD_ROOT}/keystone/api-ref/build/html/v3-ext/index.html
|
||||||
|
|
||||||
fi
|
fi
|
||||||
if [ -z "$1" -o "$1" = "load-balancing" ]; then
|
if [ -z "$1" -o "$1" = "load-balancer" ]; then
|
||||||
openstack-codegenerator --work-dir wrk --target openapi-spec --service-type load-balancing --api-ref-src ${API_REF_BUILD_ROOT}/octavia/api-ref/build/html/v2/index.html
|
openstack-codegenerator --work-dir wrk --target openapi-spec --service-type load-balancer --api-ref-src ${API_REF_BUILD_ROOT}/octavia/api-ref/build/html/v2/index.html --validate
|
||||||
fi
|
fi
|
||||||
if [ -z "$1" -o "$1" = "placement" ]; then
|
if [ -z "$1" -o "$1" = "placement" ]; then
|
||||||
openstack-codegenerator --work-dir wrk --target openapi-spec --service-type placement --api-ref-src ${API_REF_BUILD_ROOT}/placement/api-ref/build/html/index.html
|
openstack-codegenerator --work-dir wrk --target openapi-spec --service-type placement --api-ref-src ${API_REF_BUILD_ROOT}/placement/api-ref/build/html/index.html
|
||||||
|
@@ -5,9 +5,11 @@ openstack-codegenerator --work-dir metadata --target metadata --openapi-yaml-spe
|
|||||||
openstack-codegenerator --work-dir metadata --target metadata --openapi-yaml-spec wrk/openapi_specs/identity/v3.yaml --service-type identity
|
openstack-codegenerator --work-dir metadata --target metadata --openapi-yaml-spec wrk/openapi_specs/identity/v3.yaml --service-type identity
|
||||||
openstack-codegenerator --work-dir metadata --target metadata --openapi-yaml-spec wrk/openapi_specs/image/v2.yaml --service-type image
|
openstack-codegenerator --work-dir metadata --target metadata --openapi-yaml-spec wrk/openapi_specs/image/v2.yaml --service-type image
|
||||||
openstack-codegenerator --work-dir metadata --target metadata --openapi-yaml-spec wrk/openapi_specs/network/v2.yaml --service-type network
|
openstack-codegenerator --work-dir metadata --target metadata --openapi-yaml-spec wrk/openapi_specs/network/v2.yaml --service-type network
|
||||||
|
openstack-codegenerator --work-dir metadata --target metadata --openapi-yaml-spec wrk/openapi_specs/load-balancer/v2.yaml --service-type load-balancer
|
||||||
|
|
||||||
tools/generate_rust_block_storage.sh
|
tools/generate_rust_block_storage.sh
|
||||||
tools/generate_rust_compute.sh
|
tools/generate_rust_compute.sh
|
||||||
tools/generate_rust_identity.sh
|
tools/generate_rust_identity.sh
|
||||||
tools/generate_rust_image.sh
|
tools/generate_rust_image.sh
|
||||||
tools/generate_rust_network.sh
|
tools/generate_rust_network.sh
|
||||||
|
tools/generate_rust_load_balancer.sh
|
||||||
|
32
tools/generate_rust_load_balancer.sh
Executable file
32
tools/generate_rust_load_balancer.sh
Executable file
@@ -0,0 +1,32 @@
|
|||||||
|
#!/usr/bin/bash -e
|
||||||
|
#
|
||||||
|
|
||||||
|
WRK_DIR=wrk
|
||||||
|
METADATA=metadata
|
||||||
|
DST=~/workspace/github/gtema/openstack
|
||||||
|
NET_RESOURCES=(
|
||||||
|
"amphorae"
|
||||||
|
"availability_zone"
|
||||||
|
"availability_zone_profile"
|
||||||
|
"flavor"
|
||||||
|
"flavor_profile"
|
||||||
|
"healthmonitor"
|
||||||
|
"l7policy"
|
||||||
|
"listener"
|
||||||
|
"loadbalancer"
|
||||||
|
"pool"
|
||||||
|
"provider"
|
||||||
|
"quota"
|
||||||
|
"version"
|
||||||
|
)
|
||||||
|
|
||||||
|
openstack-codegenerator --work-dir ${WRK_DIR} --target rust-sdk --metadata ${METADATA}/load-balancer_metadata.yaml --service load-balancer
|
||||||
|
openstack-codegenerator --work-dir ${WRK_DIR} --target rust-cli --metadata ${METADATA}/load-balancer_metadata.yaml --service load-balancer
|
||||||
|
|
||||||
|
|
||||||
|
for resource in "${NET_RESOURCES[@]}"; do
|
||||||
|
cp -av "${WRK_DIR}/rust/openstack_sdk/src/api/load_balancer/v2/${resource}" ${DST}/openstack_sdk/src/api/load_balancer/v2
|
||||||
|
cp -av "${WRK_DIR}/rust/openstack_sdk/src/api/load_balancer/v2/${resource}.rs" ${DST}/openstack_sdk/src/api/load_balancer/v2
|
||||||
|
cp -av "${WRK_DIR}/rust/openstack_cli/src/load_balancer/v2/${resource}" ${DST}/openstack_cli/src/load_balancer/v2
|
||||||
|
cp -av "${WRK_DIR}/rust/openstack_cli/tests/load_balancer/v2/${resource}" ${DST}/openstack_cli/tests/load_balancer/v2
|
||||||
|
done;
|
@@ -15,7 +15,7 @@
|
|||||||
- compute
|
- compute
|
||||||
- identity
|
- identity
|
||||||
- image
|
- image
|
||||||
- load-balancing
|
- load-balancer
|
||||||
- network
|
- network
|
||||||
- placement
|
- placement
|
||||||
required-projects:
|
required-projects:
|
||||||
@@ -158,7 +158,7 @@
|
|||||||
- name: openstack/octavia
|
- name: openstack/octavia
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
openapi_service: load-balancing
|
openapi_service: load-balancer
|
||||||
install_additional_projects:
|
install_additional_projects:
|
||||||
- project: "opendev.org/openstack/octavia"
|
- project: "opendev.org/openstack/octavia"
|
||||||
name: "."
|
name: "."
|
||||||
|
Reference in New Issue
Block a user