From 56fa2d3d173a71fc2110cc768ade9b08667e75a9 Mon Sep 17 00:00:00 2001 From: Scott Hussey Date: Thu, 22 Jun 2017 13:19:11 -0500 Subject: [PATCH] Split dockerfile to have an intermediate image w/ all Python deps Fix some issues in bootdata implementation --- Dockerfile | 12 ++++------ Dockerfile.inter | 27 +++++++++++++++++++++++ drydock_provisioner/control/api.py | 3 ++- drydock_provisioner/control/bootdata.py | 2 +- drydock_provisioner/ingester/__init__.py | 10 ++++++++- drydock_provisioner/statemgmt/__init__.py | 2 +- requirements.txt | 15 ++++++++----- 7 files changed, 54 insertions(+), 17 deletions(-) create mode 100644 Dockerfile.inter diff --git a/Dockerfile b/Dockerfile index a2bac38d..141a6abe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,17 +11,13 @@ # 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. -FROM ubuntu:16.04 +FROM drydock_base:0.1 ENV DEBIAN_FRONTEND noninteractive ENV container docker -RUN apt -qq update && \ - apt -y install git netbase python3-minimal python3-setuptools python3-pip python3-dev ca-certificates gcc g++ make libffi-dev libssl-dev --no-install-recommends - -# Need to configure proxies? - -RUN git clone https://github.com/sh8121att/drydock /tmp/drydock +ADD drydock.conf /etc/drydock/drydock.conf +ADD . /tmp/drydock WORKDIR /tmp/drydock @@ -29,4 +25,4 @@ RUN python3 setup.py install EXPOSE 9000 -CMD ["/usr/bin/uwsgi","--http",":9000","-w","drydock_provisioner.drydock","--callable","drydock","--enable-threads","-L"] \ No newline at end of file +CMD ["uwsgi","--http",":9000","-w","drydock_provisioner.drydock","--callable","drydock","--enable-threads","-L","--pyargv","--config-file /etc/drydock/drydock.conf"] diff --git a/Dockerfile.inter b/Dockerfile.inter new file mode 100644 index 00000000..3f1e0dc3 --- /dev/null +++ b/Dockerfile.inter @@ -0,0 +1,27 @@ +# Copyright 2017 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. +FROM ubuntu:16.04 + +ENV DEBIAN_FRONTEND noninteractive +ENV container docker + +RUN apt -qq update && \ + apt -y install git netbase python3-minimal python3-setuptools python3-pip python3-dev ca-certificates gcc g++ make libffi-dev libssl-dev --no-install-recommends + +# Need to configure proxies? +ADD requirements.txt /tmp/drydock/requirements.txt + +WORKDIR /tmp/drydock + +RUN pip3 install -r requirements.txt diff --git a/drydock_provisioner/control/api.py b/drydock_provisioner/control/api.py index 65d68c34..fcf694cd 100644 --- a/drydock_provisioner/control/api.py +++ b/drydock_provisioner/control/api.py @@ -15,6 +15,7 @@ import falcon from .designs import * from .tasks import * +from .bootdata import * from .base import DrydockRequest from .middleware import AuthMiddleware, ContextMiddleware, LoggingMiddleware @@ -45,7 +46,7 @@ def start_api(state_manager=None, ingester=None, orchestrator=None): ('/designs/{design_id}/parts/{kind}/{name}', DesignsPartResource(state_manager=state_manager, orchestrator=orchestrator)), # API for nodes to discover their bootdata during curtin install - ('/bootdata/{hostname}/{data_key}', BootdataResource(state_manager=state_manager)) + ('/bootdata/{hostname}/{data_key}', BootdataResource(state_manager=state_manager, orchestrator=orchestrator)) ] for path, res in v1_0_routes: diff --git a/drydock_provisioner/control/bootdata.py b/drydock_provisioner/control/bootdata.py index 61152b13..eeeb8db8 100644 --- a/drydock_provisioner/control/bootdata.py +++ b/drydock_provisioner/control/bootdata.py @@ -28,7 +28,7 @@ class BootdataResource(StatefulResource): resp.body = BootdataResource.systemd_definition resp.content_type = 'text/plain' return - elif data_key == 'prominit' + elif data_key == 'prominit': resp.boy = BootdataResource.prominit resp.content_type = 'text/plain' return diff --git a/drydock_provisioner/ingester/__init__.py b/drydock_provisioner/ingester/__init__.py index b997545e..1b37087d 100644 --- a/drydock_provisioner/ingester/__init__.py +++ b/drydock_provisioner/ingester/__init__.py @@ -70,7 +70,15 @@ class Ingester(object): def ingest_data(self, plugin_name='', design_state=None, design_id=None, context=None, **kwargs): - + """ + ingest_data - Execute a data ingestion using the named plugin (assuming it is enabled) + + :param plugin_name: - Which plugin should be used for ingestion + :param design_state: - An instance of statemgmt.DesignState + :param design_id: - The ID of the SiteDesign all parsed designed parts should be added + :param context: - Context of the request requesting ingestion + :param kwargs: - Keywork arguments to pass to the ingester plugin + """ if design_state is None: self.logger.error("Ingester:ingest_data called without valid DesignState handler") raise ValueError("Invalid design_state handler") diff --git a/drydock_provisioner/statemgmt/__init__.py b/drydock_provisioner/statemgmt/__init__.py index 744a4394..c0d0b670 100644 --- a/drydock_provisioner/statemgmt/__init__.py +++ b/drydock_provisioner/statemgmt/__init__.py @@ -229,7 +229,7 @@ class DesignState(object): parts = self.promenade.get(target, None) if parts is not None: - return [p.obj_to_primitive() for p in parts] + return [objects.PromenadeConfig.obj_from_primitive(p) for p in parts] else: return None diff --git a/requirements.txt b/requirements.txt index 1a33ec11..dbd23942 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,10 @@ -PyYAML==3.12 -oauth==1.0.1 -requests-oauthlib==0.8.0 -netaddr==0.7.19 -python-libmaas==0.4.1 \ No newline at end of file +PyYAML +pyghmi>=1.0.18 +netaddr +falcon +oslo.versionedobjects>=1.23.0 +requests +oauthlib +uwsgi>1.4 +bson===0.4.7 +oslo.config===4.6.0 \ No newline at end of file