0f39a55942
Adding the baclient code to Drydock requires a refactor of the build automation to support multiple languages and multiple artifacts included in a single Docker image NOTE: the go source here is a placeholder 'hello world' sample Change-Id: I1b4883f018b33b3d4fcd7cbcb6cba660fcdc93de
132 lines
4.9 KiB
Python
132 lines
4.9 KiB
Python
# Copyright 2018 AT&T Intellectual Property. All other rights reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
import falcon
|
|
|
|
from .designs import DesignsResource
|
|
from .designs import DesignResource
|
|
from .designs import DesignsPartsResource
|
|
from .designs import DesignsPartsKindsResource
|
|
from .designs import DesignsPartResource
|
|
from .tasks import TasksResource
|
|
from .tasks import TaskResource
|
|
from .tasks import TaskBuilddataResource
|
|
from .nodes import NodesResource
|
|
from .nodes import NodeBuildDataResource
|
|
from .nodes import NodeFilterResource
|
|
from .health import HealthResource
|
|
from .health import HealthExtendedResource
|
|
from .bootaction import BootactionUnitsResource
|
|
from .bootaction import BootactionFilesResource
|
|
from .bootaction import BootactionResource
|
|
from .validation import ValidationResource
|
|
|
|
from .base import DrydockRequest, BaseResource
|
|
from .middleware import AuthMiddleware, ContextMiddleware, LoggingMiddleware
|
|
|
|
|
|
def start_api(state_manager=None, ingester=None, orchestrator=None):
|
|
"""
|
|
Start the Drydock API service
|
|
|
|
:param state_manager: Instance of drydock_provisioner.statemgmt.manager.DesignState for accessing
|
|
state persistence
|
|
:param ingester: Instance of drydock_provisioner.ingester.ingester.Ingester for handling design
|
|
part input
|
|
:param orchestrator: Instance of drydock_provisioner.orchestrator.Orchestrator for managing tasks
|
|
"""
|
|
control_api = falcon.API(
|
|
request_type=DrydockRequest,
|
|
middleware=[
|
|
AuthMiddleware(),
|
|
ContextMiddleware(),
|
|
LoggingMiddleware()
|
|
])
|
|
|
|
control_api.add_route('/versions', VersionsResource())
|
|
|
|
# v1.0 of Drydock API
|
|
v1_0_routes = [
|
|
# API for managing orchestrator tasks
|
|
('/health',
|
|
HealthResource(
|
|
state_manager=state_manager, orchestrator=orchestrator)),
|
|
('/health/extended',
|
|
HealthExtendedResource(
|
|
state_manager=state_manager, orchestrator=orchestrator)),
|
|
('/tasks',
|
|
TasksResource(state_manager=state_manager,
|
|
orchestrator=orchestrator)),
|
|
('/tasks/{task_id}', TaskResource(state_manager=state_manager)),
|
|
('/tasks/{task_id}/builddata',
|
|
TaskBuilddataResource(state_manager=state_manager)),
|
|
|
|
# API for managing site design data
|
|
('/designs', DesignsResource(state_manager=state_manager)),
|
|
('/designs/{design_id}',
|
|
DesignResource(
|
|
state_manager=state_manager, orchestrator=orchestrator)),
|
|
('/designs/{design_id}/parts',
|
|
DesignsPartsResource(state_manager=state_manager, ingester=ingester)),
|
|
('/designs/{design_id}/parts/{kind}',
|
|
DesignsPartsKindsResource(state_manager=state_manager)),
|
|
('/designs/{design_id}/parts/{kind}/{name}',
|
|
DesignsPartResource(
|
|
state_manager=state_manager, orchestrator=orchestrator)),
|
|
|
|
# API to list current MaaS nodes
|
|
('/nodes', NodesResource()),
|
|
# API to get build data for a node
|
|
('/nodes/{hostname}/builddata',
|
|
NodeBuildDataResource(state_manager=state_manager)),
|
|
# API to list current node names based
|
|
('/nodefilter',
|
|
NodeFilterResource(
|
|
state_manager=state_manager, orchestrator=orchestrator)),
|
|
# API for nodes to discover their boot actions during curtin install
|
|
('/bootactions/nodes/{hostname}/units',
|
|
BootactionUnitsResource(
|
|
state_manager=state_manager, orchestrator=orchestrator)),
|
|
('/bootactions/nodes/{hostname}/files',
|
|
BootactionFilesResource(
|
|
state_manager=state_manager, orchestrator=orchestrator)),
|
|
('/bootactions/{action_id}',
|
|
BootactionResource(
|
|
state_manager=state_manager, orchestrator=orchestrator)),
|
|
|
|
# API to validate schemas
|
|
('/validatedesign',
|
|
ValidationResource(
|
|
state_manager=state_manager, orchestrator=orchestrator)),
|
|
]
|
|
|
|
for path, res in v1_0_routes:
|
|
control_api.add_route('/api/v1.0' + path, res)
|
|
|
|
return control_api
|
|
|
|
|
|
class VersionsResource(BaseResource):
|
|
"""
|
|
Lists the versions supported by this API
|
|
"""
|
|
|
|
def on_get(self, req, resp):
|
|
resp.body = self.to_json({
|
|
'v1.0': {
|
|
'path': '/api/v1.0',
|
|
'status': 'stable'
|
|
}
|
|
})
|
|
resp.status = falcon.HTTP_200
|