Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

feat: add vpnaas under the neutron openapi spec #1

Merged
merged 2 commits into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:

# Deployment job
deploy:
if: github.ref == "refs/heads/main"
permissions:
contents: read
pages: write
Expand Down
47 changes: 28 additions & 19 deletions codegenerator/openapi/cinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,50 @@
# License for the specific language governing permissions and limitations
# under the License.
#

from multiprocessing import Process
from pathlib import Path

from cinder import objects, rpc
from cinder.api.openstack import api_version_request
from cinder.common import config
from cinder.tests.unit.test import Database as db_fixture
from ruamel.yaml.scalarstring import LiteralScalarString

from codegenerator.common.schema import SpecSchema
from codegenerator.common.schema import TypeSchema
from codegenerator.openapi.base import OpenStackServerSourceBase
from codegenerator.openapi.utils import merge_api_ref_doc
from ruamel.yaml.scalarstring import LiteralScalarString

CONF = config.CONF


class CinderV3Generator(OpenStackServerSourceBase):
URL_TAG_MAP = {
"/versions": "version",
}

def __init__(self):
def _api_ver_major(self, ver):
return ver._ver_major

def _api_ver_minor(self, ver):
return ver._ver_minor

def _api_ver(self, ver):
return (ver._ver_major, ver._ver_minor)

def generate(self, target_dir, args):
proc = Process(target=self._generate, args=[target_dir, args])
proc.start()
proc.join()
if proc.exitcode != 0:
raise RuntimeError("Error generating Cinder OpenAPI schma")
return Path(target_dir, "openapi_specs", "block-storage", "v3.yaml")

def _generate(self, target_dir, args, *pargs, **kwargs):
from cinder import objects, rpc
from cinder.api.openstack import api_version_request
from cinder.common import config
from cinder.tests.unit.test import Database as db_fixture

# Register all Cinder objects
objects.register_all()

CONF = config.CONF

self.api_version = api_version_request._MAX_API_VERSION
self.min_api_version = api_version_request._MIN_API_VERSION

Expand All @@ -49,16 +68,6 @@ def __init__(self):

self.router = router.APIRouter()

def _api_ver_major(self, ver):
return ver._ver_major

def _api_ver_minor(self, ver):
return ver._ver_minor

def _api_ver(self, ver):
return (ver._ver_major, ver._ver_minor)

def generate(self, target_dir, args, *pargs, **kwargs):
work_dir = Path(target_dir)
work_dir.mkdir(parents=True, exist_ok=True)

Expand Down
52 changes: 32 additions & 20 deletions codegenerator/openapi/glance.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,16 @@
# under the License.
#
import copy
from multiprocessing import Process
from pathlib import Path

from jsonref import replace_refs
import routes
from ruamel.yaml.scalarstring import LiteralScalarString

from codegenerator.common.schema import SpecSchema, TypeSchema
from codegenerator.openapi.base import OpenStackServerSourceBase
from codegenerator.openapi.utils import merge_api_ref_doc
from glance.api.v2 import image_members
from glance.api.v2 import images
from glance.api.v2 import metadef_namespaces
from glance.api.v2 import metadef_objects
from glance.api.v2 import metadef_properties
from glance.api.v2 import metadef_resource_types
from glance.api.v2 import metadef_tags
from glance.api.v2 import router
from glance.api.v2 import tasks
from glance.common import config
from glance import schema as glance_schema
from jsonref import replace_refs
from oslo_config import fixture as cfg_fixture
from ruamel.yaml.scalarstring import LiteralScalarString


class GlanceGenerator(OpenStackServerSourceBase):
Expand All @@ -42,12 +32,6 @@ def __init__(self):
self.api_version = "2.16"
self.min_api_version = None

self._config_fixture = self.useFixture(cfg_fixture.Config())

config.parse_args(args=[])

self.router = router.API(routes.Mapper())

def _api_ver_major(self, ver):
return ver.ver_major

Expand All @@ -58,6 +42,24 @@ def _api_ver(self, ver):
return (ver.ver_major, ver.ver_minor)

def generate(self, target_dir, args):
proc = Process(target=self._generate, args=[target_dir, args])
proc.start()
proc.join()
if proc.exitcode != 0:
raise RuntimeError("Error generating Glance OpenAPI schma")
return Path(target_dir, "openapi_specs", "image", "v2.yaml")

def _generate(self, target_dir, args):
from glance.api.v2 import router
from glance.common import config
from oslo_config import fixture as cfg_fixture

self._config_fixture = self.useFixture(cfg_fixture.Config())

config.parse_args(args=[])

self.router = router.API(routes.Mapper())

work_dir = Path(target_dir)
work_dir.mkdir(parents=True, exist_ok=True)

Expand Down Expand Up @@ -109,6 +111,16 @@ def _get_schema_ref(
schema_def=None,
action_name=None,
):
from glance.api.v2 import image_members
from glance.api.v2 import images
from glance.api.v2 import metadef_namespaces
from glance.api.v2 import metadef_objects
from glance.api.v2 import metadef_properties
from glance.api.v2 import metadef_resource_types
from glance.api.v2 import metadef_tags
from glance.api.v2 import tasks
from glance import schema as glance_schema

if name == "TasksListResponse":
openapi_spec.components.schemas.setdefault(
name,
Expand Down
33 changes: 23 additions & 10 deletions codegenerator/openapi/keystone.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,24 @@
# under the License.
#
import inspect
from multiprocessing import Process
import logging
from pathlib import Path

from ruamel.yaml.scalarstring import LiteralScalarString

from keystone.assignment import schema as assignment_schema
from keystone.auth import schema as auth_schema
from keystone.identity import schema as identity_schema
from keystone.resource import schema as ks_schema

from codegenerator.common.schema import ParameterSchema
from codegenerator.common.schema import PathSchema
from codegenerator.common.schema import SpecSchema
from codegenerator.common.schema import TypeSchema
from codegenerator.openapi.base import OpenStackServerSourceBase
from codegenerator.openapi.utils import merge_api_ref_doc
from keystone.assignment import schema as assignment_schema
from keystone.auth import schema as auth_schema
from keystone.identity import schema as identity_schema
from keystone.resource import schema as ks_schema
from keystone.server.flask import application
from ruamel.yaml.scalarstring import LiteralScalarString


PROJECT_SCHEMA = TypeSchema(
type="object",
Expand Down Expand Up @@ -221,9 +224,6 @@ def __init__(self):
self.api_version = "3.0"
self.min_api_version = "3.14"

self.app = application.application_factory()
self.router = self.app.url_map

def _api_ver_major(self, ver):
return ver._ver_major

Expand All @@ -233,7 +233,20 @@ def _api_ver_minor(self, ver):
def _api_ver(self, ver):
return (ver._ver_major, ver._ver_minor)

def generate(self, target_dir, args, *pargs, **kwargs):
def generate(self, target_dir, args):
proc = Process(target=self._generate, args=[target_dir, args])
proc.start()
proc.join()
if proc.exitcode != 0:
raise RuntimeError("Error generating Keystone OpenAPI schma")
return Path(target_dir, "openapi_specs", "identity", "v3.yaml")

def _generate(self, target_dir, args, *pargs, **kwargs):
from keystone.server.flask import application

self.app = application.application_factory()
self.router = self.app.url_map

work_dir = Path(target_dir)
work_dir.mkdir(parents=True, exist_ok=True)

Expand Down
Loading