diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..1a6c0731 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,119 @@ +# Byte-compiled / optimized / DLL files +**/__pycache__/ +*.py[cod] +*$py.class + +# Unit tests +src/bin/*/tests/unit/ + +# C extensions +*.so + +# Distribution / packaging +.Python +**/env/ +**/build/ +**/develop-eggs/ +**/dist/ +**/downloads/ +**/eggs/ +**/.eggs/ +lib/ +**/lib64/ +parts/ +**/sdist/ +var/ +wheels/ +**/*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +**/htmlcov/ +cov/* +**/.tox/ +**/.coverage +**/.coverage.* +**/.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ +docs/*/_static/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# dotenv +.env + +# virtualenv +.venv +venv/ +ENV/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mypy +.mypy_cache/ + +# Generated bogus docs +ChangeLog +AUTHORS + +# build/lint artifacts +*.tgz +**/*.tgz +/charts/shipyard/charts +/charts/shipyard/requirements.lock +.DS_Store + +# vscode +.vscode/ + +!src/lib/ diff --git a/.gitignore b/.gitignore index 869214f7..a78643fa 100644 --- a/.gitignore +++ b/.gitignore @@ -64,7 +64,6 @@ instance/ # Sphinx documentation docs/_build/ -docs/*/_static/ # PyBuilder target/ diff --git a/Makefile b/Makefile index 21761f67..50103758 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +BUILD_CTX ?= src/bin DOCKER_REGISTRY ?= quay.io IMAGE_PREFIX ?= attcomdev IMAGE_TAG ?= latest @@ -39,6 +40,7 @@ $(IMAGE_NAME): # Create tgz of the chart .PHONY: charts charts: clean + tools/helm_tk.sh $(HELM) $(HELM) dep up charts/shipyard $(HELM) package charts/shipyard @@ -55,6 +57,12 @@ dry-run: clean .PHONY: docs docs: clean build_docs + +.PHONY: tests +tests: + cd $(BUILD_CTX)/shipyard_airflow; tox + cd $(BUILD_CTX)/shipyard_client; tox + # Make targets intended for use by the primary targets above. .PHONY: run @@ -67,15 +75,17 @@ build_airflow: .PHONY: build_shipyard build_shipyard: - docker build -t $(IMAGE) --label $(LABEL) -f $(IMAGE_DIR)/Dockerfile . + docker build -t $(IMAGE) --label $(LABEL) -f $(IMAGE_DIR)/Dockerfile --build-arg ctx_base=$(BUILD_CTX) . .PHONY: clean clean: - rm -rf build + cd $(BUILD_CTX)/shipyard_airflow; rm -rf build + cd $(BUILD_CTX)/shipyard_client; rm -rf build .PHONY: pep8 pep8: - tox -e pep8 + cd $(BUILD_CTX)/shipyard_airflow; tox -e pep8 + cd $(BUILD_CTX)/shipyard_client; tox -e pep8 .PHONY: helm_lint helm_lint: clean diff --git a/charts/shipyard/values.yaml b/charts/shipyard/values.yaml index fa7bf4cd..c67f0da5 100644 --- a/charts/shipyard/values.yaml +++ b/charts/shipyard/values.yaml @@ -346,7 +346,7 @@ conf: workflow_orchestrator:get_renderedconfigdocs: rule:admin_required paste: app:shipyard-api: - paste.app_factory: shipyard_airflow.shipyard:paste_start_shipyard + paste.app_factory: shipyard_airflow.shipyard_api:paste_start_shipyard pipeline:main: pipeline: authtoken shipyard-api filter:authtoken: diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 00000000..1f5d803d --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,5 @@ +# +# Requirements for creating documentation only. +# +sphinx>=1.6.2 +sphinx_rtd_theme==0.2.4 diff --git a/etc/shipyard/shipyard.conf.sample b/docs/source/_static/shipyard.conf.sample similarity index 86% rename from etc/shipyard/shipyard.conf.sample rename to docs/source/_static/shipyard.conf.sample index 319808c0..616d0a94 100644 --- a/etc/shipyard/shipyard.conf.sample +++ b/docs/source/_static/shipyard.conf.sample @@ -4,11 +4,11 @@ [airflow] # -# From shipyard_airflow +# From shipyard_api # # Airflow worker url scheme (string value) -#worker_endpoint_scheme = 'http' +#worker_endpoint_scheme = http # Airflow worker port (integer value) #worker_port = 8793 @@ -17,7 +17,7 @@ [armada] # -# From shipyard_airflow +# From shipyard_api # # The service type for the service playing the role of Armada. The specified @@ -29,7 +29,7 @@ [base] # -# From shipyard_airflow +# From shipyard_api # # The web server for Airflow (string value) @@ -54,7 +54,7 @@ [deckhand] # -# From shipyard_airflow +# From shipyard_api # # The service type for the service playing the role of Deckhand. The specified @@ -66,7 +66,7 @@ [drydock] # -# From shipyard_airflow +# From shipyard_api # # The service type for the service playing the role of Drydock. The specified @@ -75,6 +75,16 @@ #service_type = physicalprovisioner +[k8s_logs] + +# +# From shipyard_api +# + +# Namespace of UCP Pods (string value) +#ucp_namespace = ucp + + [keystone_authtoken] # @@ -89,6 +99,22 @@ # *not* be the same endpoint the service user utilizes for validating tokens, # because normal end users may not be able to reach that endpoint. (string # value) +# Deprecated group/name - [keystone_authtoken]/auth_uri +#www_authenticate_uri = + +# DEPRECATED: Complete "public" Identity API endpoint. This endpoint should not +# be an "admin" endpoint, as it should be accessible by all end users. +# Unauthenticated clients are redirected to this endpoint to authenticate. +# Although this endpoint should ideally be unversioned, client support in the +# wild varies. If you're using a versioned v2 endpoint here, then this should +# *not* be the same endpoint the service user utilizes for validating tokens, +# because normal end users may not be able to reach that endpoint. This option +# is deprecated in favor of www_authenticate_uri and will be removed in the S +# release. (string value) +# This option is deprecated for removal since Queens. +# Its value may be silently ignored in the future. +# Reason: The auth_uri option is deprecated in favor of www_authenticate_uri +# and will be removed in the S release. #auth_uri = # API version of the admin Identity API endpoint. (string value) @@ -161,7 +187,10 @@ # in the cache. If ENCRYPT, token data is encrypted and authenticated in the # cache. If the value is not one of these options or empty, auth_token will # raise an exception on initialization. (string value) -# Allowed values: None, MAC, ENCRYPT +# Possible values: +# None - +# MAC - +# ENCRYPT - #memcache_security_strategy = None # (Optional, mandatory if memcache_security_strategy is defined) This string is @@ -249,31 +278,26 @@ #auth_section = -[k8s_logs] - -# -# From shipyard_airflow -# - -# The namespace of the UCP Pods (string value) -#ucp_namespace = ucp - - [logging] # -# From shipyard_airflow +# From shipyard_api # # The default logging level for the root logger. ERROR=40, WARNING=30, INFO=20, # DEBUG=10 (integer value) #log_level = 10 +# The logging levels for named loggers. Use standard representations for +# logging levels: ERROR. WARN, INFO, DEBUG. Configuration file format: +# named_log_levels = keystoneauth:INFO,othlgr:WARN (dict value) +#named_log_levels = keystoneauth:20,keystonemiddleware:20 + [requests_config] # -# From shipyard_airflow +# From shipyard_api # # Airflow logs retrieval connect timeout (in seconds) (integer value) @@ -299,7 +323,7 @@ [shipyard] # -# From shipyard_airflow +# From shipyard_api # # The service type for the service playing the role of Shipyard. The specified diff --git a/docs/source/_static/shipyard.policy.yaml.sample b/docs/source/_static/shipyard.policy.yaml.sample new file mode 100644 index 00000000..a03094df --- /dev/null +++ b/docs/source/_static/shipyard.policy.yaml.sample @@ -0,0 +1,61 @@ +# Actions requiring admin authority +#"admin_required": "role:admin" + +# List workflow actions invoked by users +# GET /api/v1.0/actions +#"workflow_orchestrator:list_actions": "rule:admin_required" + +# Create a workflow action +# POST /api/v1.0/actions +#"workflow_orchestrator:create_action": "rule:admin_required" + +# Retrieve an action by its id +# GET /api/v1.0/actions/{action_id} +#"workflow_orchestrator:get_action": "rule:admin_required" + +# Retrieve an action step by its id +# GET /api/v1.0/actions/{action_id}/steps/{step_id} +#"workflow_orchestrator:get_action_step": "rule:admin_required" + +# Retrieve logs of an action step by its id +# GET /api/v1.0/actions/{action_id}/steps/{step_id}/logs +#"workflow_orchestrator:get_action_step_logs": "rule:admin_required" + +# Retrieve an action validation by its id +# GET /api/v1.0/actions/{action_id}/validations/{validation_id} +#"workflow_orchestrator:get_action_validation": "rule:admin_required" + +# Send a control to an action +# POST /api/v1.0/actions/{action_id}/control/{control_verb} +#"workflow_orchestrator:invoke_action_control": "rule:admin_required" + +# Retrieve the status of the configdocs +# GET /api/v1.0/configdocs +#"workflow_orchestrator:get_configdocs_status": "rule:admin_required" + +# Ingest configuration documents for the site design +# POST /api/v1.0/configdocs/{collection_id} +#"workflow_orchestrator:create_configdocs": "rule:admin_required" + +# Retrieve a collection of configuration documents +# GET /api/v1.0/configdocs/{collection_id} +#"workflow_orchestrator:get_configdocs": "rule:admin_required" + +# Move documents from the Shipyard buffer to the committed documents +# POST /api/v1.0/commitconfigdocs +#"workflow_orchestrator:commit_configdocs": "rule:admin_required" + +# Retrieve the configuration documents rendered by Deckhand into a +# complete design +# GET /api/v1.0/renderedconfigdocs +#"workflow_orchestrator:get_renderedconfigdocs": "rule:admin_required" + +# Retrieve the list of workflows (DAGs) that have been invoked in +# Airflow, whether via Shipyard or scheduled +# GET /api/v1.0/workflows +#"workflow_orchestrator:list_workflows": "rule:admin_required" + +# Retrieve the detailed information for a workflow (DAG) from Airflow +# GET /api/v1.0/workflows/{id} +#"workflow_orchestrator:get_workflow": "rule:admin_required" + diff --git a/docs/source/conf.py b/docs/source/conf.py index 0c4e290a..b9bab7d8 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -34,19 +34,9 @@ import sphinx_rtd_theme extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.todo', - 'sphinx.ext.viewcode', - 'oslo_config.sphinxconfiggen', - 'oslo_policy.sphinxpolicygen' + 'sphinx.ext.viewcode' ] -# oslo_config.sphinxconfiggen options -config_generator_config_file = '../../generator/config-generator.conf' -sample_config_basename = '_static/shipyard' - -# oslo_policy.sphinxpolicygen options -policy_generator_config_file = '../../generator/policy-generator.conf' -sample_policy_basename = '_static/shipyard' - # Add any paths that contain templates here, relative to this directory. # templates_path = [] diff --git a/etc/shipyard/api-paste.ini b/etc/shipyard/api-paste.ini index bd607ad5..9996986c 100644 --- a/etc/shipyard/api-paste.ini +++ b/etc/shipyard/api-paste.ini @@ -16,7 +16,7 @@ #Used to configure uWSGI middleware pipeline [app:shipyard-api] -paste.app_factory = shipyard_airflow.shipyard:paste_start_shipyard +paste.app_factory = shipyard_airflow.shipyard_api:paste_start_shipyard [pipeline:main] pipeline = authtoken shipyard-api diff --git a/images/airflow/requirements.txt b/images/airflow/requirements.txt index 5c1f0090..e461e5b7 100644 --- a/images/airflow/requirements.txt +++ b/images/airflow/requirements.txt @@ -20,8 +20,6 @@ psycopg2==2.7.3.1 docker-py==1.6.0 apache-airflow[crypto,celery,postgres,hive,hdfs,jdbc]==1.9.0 python-openstackclient==3.11.0 -sphinx>=1.6.2 -sphinx_rtd_theme==0.2.4 # Dependencies for other UCP components git+https://github.com/att-comdev/deckhand.git@3cdf3d2d896d43c6e3bc26170522c3eee0d7158f#egg=deckhand diff --git a/images/shipyard/Dockerfile b/images/shipyard/Dockerfile index 2d61de32..cc2fd85e 100644 --- a/images/shipyard/Dockerfile +++ b/images/shipyard/Dockerfile @@ -20,6 +20,7 @@ ENV LC_ALL C.UTF-8 ENV LANG C.UTF-8 ARG DEBIAN_FRONTEND=noninteractive +ARG ctx_base=src/bin # Expose port 9000 for application EXPOSE $PORT @@ -29,21 +30,30 @@ ENTRYPOINT ["/home/shipyard/entrypoint.sh"] CMD ["server"] # Create shipyard user -RUN useradd -ms /bin/bash shipyard +RUN useradd -ms /bin/bash shipyard \ + && mkdir -p /home/shipyard/shipyard \ + && mkdir -p /home/shipyard/shipyard_client # Copy entrypoint.sh to /home/shipyard -COPY entrypoint.sh /home/shipyard/entrypoint.sh -# Change permissions +COPY ${ctx_base}/shipyard_airflow/entrypoint.sh /home/shipyard/entrypoint.sh +# Change permissions and set up directories RUN chown -R shipyard: /home/shipyard \ && chmod +x /home/shipyard/entrypoint.sh -# Set work directory and install dependencies -WORKDIR /home/shipyard/shipyard -COPY requirements.txt /home/shipyard/shipyard -RUN pip3 install -r requirements.txt +# Requirements +COPY ${ctx_base}/shipyard_airflow/requirements.txt /home/shipyard/api_requirements.txt +RUN pip3 install -r /home/shipyard/api_requirements.txt -COPY . /home/shipyard/shipyard -RUN python3 setup.py install +COPY ${ctx_base}/shipyard_client/requirements.txt /home/shipyard/client_requirements.txt +RUN pip3 install -r /home/shipyard/client_requirements.txt + +# Shipyard source and installation +COPY ${ctx_base}/shipyard_client /home/shipyard/shipyard_client/ +RUN cd /home/shipyard/shipyard_client \ + && python3 setup.py install +COPY ${ctx_base}/shipyard_airflow /home/shipyard/shipyard/ +RUN cd /home/shipyard/shipyard \ + && python3 setup.py install # Set user to shipyard USER shipyard diff --git a/requirements.readthedocs.txt b/requirements.readthedocs.txt new file mode 100644 index 00000000..e0a7d3c7 --- /dev/null +++ b/requirements.readthedocs.txt @@ -0,0 +1 @@ +src/bin/shipyard_airflow/ diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 8ad69feb..00000000 --- a/setup.cfg +++ /dev/null @@ -1,38 +0,0 @@ -[metadata] -name = shipyard -summary = Directed acyclic graph controller for Kubernetes and OpenStack control plane life cycle management -description-file = README.md - -author = undercloud team -home-page = https://github.com/att-comdev/shipyard -classifier = - Intended Audience :: Information Technology - Intended Audience :: System Administrators - License :: OSI Approved :: Apache Software License - Operating System :: POSIX :: Linux - Programming Language :: Python - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.5 - -[files] -packages = - shipyard_airflow - shipyard_client - -[entry_points] -oslo.config.opts = - shipyard_airflow = shipyard_airflow.conf.opts:list_opts -oslo.policy.policies = - shipyard_airflow = shipyard_airflow.policy:list_policies -console_scripts = - shipyard = shipyard_client.cli.commands:shipyard - upgrade_db = shipyard_airflow.shipyard_upgrade_db:upgrade_db - -[build_sphinx] -source-dir = docs/source -build-dir = docs/build -all_files = 1 -warning-is-error = 1 - -[upload_sphinx] -upload-dir = docs/build/html diff --git a/.coveragerc b/src/bin/shipyard_airflow/.coveragerc similarity index 78% rename from .coveragerc rename to src/bin/shipyard_airflow/.coveragerc index 40aa900c..b9455419 100644 --- a/.coveragerc +++ b/src/bin/shipyard_airflow/.coveragerc @@ -2,4 +2,3 @@ # omit third party code and unit tests omit = shipyard_airflow/plugins/rest_api_plugin.py - shipyard_client/tests/* diff --git a/README.md b/src/bin/shipyard_airflow/README.md similarity index 100% rename from README.md rename to src/bin/shipyard_airflow/README.md diff --git a/alembic.ini b/src/bin/shipyard_airflow/alembic.ini similarity index 100% rename from alembic.ini rename to src/bin/shipyard_airflow/alembic.ini diff --git a/alembic/README b/src/bin/shipyard_airflow/alembic/README similarity index 100% rename from alembic/README rename to src/bin/shipyard_airflow/alembic/README diff --git a/alembic/env.py b/src/bin/shipyard_airflow/alembic/env.py similarity index 100% rename from alembic/env.py rename to src/bin/shipyard_airflow/alembic/env.py diff --git a/alembic/script.py.mako b/src/bin/shipyard_airflow/alembic/script.py.mako similarity index 100% rename from alembic/script.py.mako rename to src/bin/shipyard_airflow/alembic/script.py.mako diff --git a/alembic/versions/51b92375e5c4_initial_shipyard_base.py b/src/bin/shipyard_airflow/alembic/versions/51b92375e5c4_initial_shipyard_base.py similarity index 100% rename from alembic/versions/51b92375e5c4_initial_shipyard_base.py rename to src/bin/shipyard_airflow/alembic/versions/51b92375e5c4_initial_shipyard_base.py diff --git a/entrypoint.sh b/src/bin/shipyard_airflow/entrypoint.sh similarity index 79% rename from entrypoint.sh rename to src/bin/shipyard_airflow/entrypoint.sh index e73ee79a..cd9faf89 100644 --- a/entrypoint.sh +++ b/src/bin/shipyard_airflow/entrypoint.sh @@ -14,17 +14,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -set -ex - -CMD="shipyard" -PORT=${PORT:-9000} -HTTP_TIMEOUT=${HTTP_TIMEOUT:-600} -# Number of uWSGI workers to handle API request -SHIPYARD_API_WORKERS=${SHIPYARD_API_WORKERS:-"4"} -#Threads per worker -SHIPYARD_API_THREADS=${SHIPYARD_API_THREADS:-"1"} - +set -e if [ "$1" = 'server' ]; then + set -x + PORT=${PORT:-9000} + HTTP_TIMEOUT=${HTTP_TIMEOUT:-600} + # Number of uWSGI workers to handle API request + SHIPYARD_API_WORKERS=${SHIPYARD_API_WORKERS:-"4"} + #Threads per worker + SHIPYARD_API_THREADS=${SHIPYARD_API_THREADS:-"1"} # Start shipyard application exec uwsgi \ --http :${PORT} \ @@ -36,6 +34,7 @@ if [ "$1" = 'server' ]; then --workers $SHIPYARD_API_WORKERS \ --http-timeout ${HTTP_TIMEOUT} else + CMD="shipyard" # Execute shipyard command exec ${CMD} $@ fi diff --git a/etc/shipyard/policy.yaml.sample b/src/bin/shipyard_airflow/etc/shipyard/policy.yaml.sample similarity index 87% rename from etc/shipyard/policy.yaml.sample rename to src/bin/shipyard_airflow/etc/shipyard/policy.yaml.sample index 3de17a82..a03094df 100644 --- a/etc/shipyard/policy.yaml.sample +++ b/src/bin/shipyard_airflow/etc/shipyard/policy.yaml.sample @@ -9,19 +9,19 @@ # POST /api/v1.0/actions #"workflow_orchestrator:create_action": "rule:admin_required" -# Retreive an action by its id +# Retrieve an action by its id # GET /api/v1.0/actions/{action_id} #"workflow_orchestrator:get_action": "rule:admin_required" -# Retreive an action step by its id +# Retrieve an action step by its id # GET /api/v1.0/actions/{action_id}/steps/{step_id} #"workflow_orchestrator:get_action_step": "rule:admin_required" -# Retreive the logs of an action step by its id +# Retrieve logs of an action step by its id # GET /api/v1.0/actions/{action_id}/steps/{step_id}/logs #"workflow_orchestrator:get_action_step_logs": "rule:admin_required" -# Retreive an action validation by its id +# Retrieve an action validation by its id # GET /api/v1.0/actions/{action_id}/validations/{validation_id} #"workflow_orchestrator:get_action_validation": "rule:admin_required" @@ -29,6 +29,10 @@ # POST /api/v1.0/actions/{action_id}/control/{control_verb} #"workflow_orchestrator:invoke_action_control": "rule:admin_required" +# Retrieve the status of the configdocs +# GET /api/v1.0/configdocs +#"workflow_orchestrator:get_configdocs_status": "rule:admin_required" + # Ingest configuration documents for the site design # POST /api/v1.0/configdocs/{collection_id} #"workflow_orchestrator:create_configdocs": "rule:admin_required" diff --git a/src/bin/shipyard_airflow/etc/shipyard/shipyard.conf.sample b/src/bin/shipyard_airflow/etc/shipyard/shipyard.conf.sample new file mode 100644 index 00000000..616d0a94 --- /dev/null +++ b/src/bin/shipyard_airflow/etc/shipyard/shipyard.conf.sample @@ -0,0 +1,332 @@ +[DEFAULT] + + +[airflow] + +# +# From shipyard_api +# + +# Airflow worker url scheme (string value) +#worker_endpoint_scheme = http + +# Airflow worker port (integer value) +#worker_port = 8793 + + +[armada] + +# +# From shipyard_api +# + +# The service type for the service playing the role of Armada. The specified +# type is used to perform the service lookup in the Keystone service catalog. +# (string value) +#service_type = armada + + +[base] + +# +# From shipyard_api +# + +# The web server for Airflow (string value) +#web_server = http://localhost:32080/ + +# Seconds to wait to connect to the airflow api (integer value) +#airflow_api_connect_timeout = 5 + +# Seconds to wait for a response from the airflow api (integer value) +#airflow_api_read_timeout = 60 + +# The database for shipyard (string value) +#postgresql_db = postgresql+psycopg2://shipyard:changeme@postgresql.ucp:5432/shipyard + +# The database for airflow (string value) +#postgresql_airflow_db = postgresql+psycopg2://shipyard:changeme@postgresql.ucp:5432/airflow + +# The direcotry containing the alembic.ini file (string value) +#alembic_ini_path = /home/shipyard/shipyard + + +[deckhand] + +# +# From shipyard_api +# + +# The service type for the service playing the role of Deckhand. The specified +# type is used to perform the service lookup in the Keystone service catalog. +# (string value) +#service_type = deckhand + + +[drydock] + +# +# From shipyard_api +# + +# The service type for the service playing the role of Drydock. The specified +# type is used to perform the service lookup in the Keystone service catalog. +# (string value) +#service_type = physicalprovisioner + + +[k8s_logs] + +# +# From shipyard_api +# + +# Namespace of UCP Pods (string value) +#ucp_namespace = ucp + + +[keystone_authtoken] + +# +# From keystonemiddleware.auth_token +# + +# Complete "public" Identity API endpoint. This endpoint should not be an +# "admin" endpoint, as it should be accessible by all end users. +# Unauthenticated clients are redirected to this endpoint to authenticate. +# Although this endpoint should ideally be unversioned, client support in the +# wild varies. If you're using a versioned v2 endpoint here, then this should +# *not* be the same endpoint the service user utilizes for validating tokens, +# because normal end users may not be able to reach that endpoint. (string +# value) +# Deprecated group/name - [keystone_authtoken]/auth_uri +#www_authenticate_uri = + +# DEPRECATED: Complete "public" Identity API endpoint. This endpoint should not +# be an "admin" endpoint, as it should be accessible by all end users. +# Unauthenticated clients are redirected to this endpoint to authenticate. +# Although this endpoint should ideally be unversioned, client support in the +# wild varies. If you're using a versioned v2 endpoint here, then this should +# *not* be the same endpoint the service user utilizes for validating tokens, +# because normal end users may not be able to reach that endpoint. This option +# is deprecated in favor of www_authenticate_uri and will be removed in the S +# release. (string value) +# This option is deprecated for removal since Queens. +# Its value may be silently ignored in the future. +# Reason: The auth_uri option is deprecated in favor of www_authenticate_uri +# and will be removed in the S release. +#auth_uri = + +# API version of the admin Identity API endpoint. (string value) +#auth_version = + +# Do not handle authorization requests within the middleware, but delegate the +# authorization decision to downstream WSGI components. (boolean value) +#delay_auth_decision = false + +# Request timeout value for communicating with Identity API server. (integer +# value) +#http_connect_timeout = + +# How many times are we trying to reconnect when communicating with Identity +# API Server. (integer value) +#http_request_max_retries = 3 + +# Request environment key where the Swift cache object is stored. When +# auth_token middleware is deployed with a Swift cache, use this option to have +# the middleware share a caching backend with swift. Otherwise, use the +# ``memcached_servers`` option instead. (string value) +#cache = + +# Required if identity server requires client certificate (string value) +#certfile = + +# Required if identity server requires client certificate (string value) +#keyfile = + +# A PEM encoded Certificate Authority to use when verifying HTTPs connections. +# Defaults to system CAs. (string value) +#cafile = + +# Verify HTTPS connections. (boolean value) +#insecure = false + +# The region in which the identity server can be found. (string value) +#region_name = + +# DEPRECATED: Directory used to cache files related to PKI tokens. This option +# has been deprecated in the Ocata release and will be removed in the P +# release. (string value) +# This option is deprecated for removal since Ocata. +# Its value may be silently ignored in the future. +# Reason: PKI token format is no longer supported. +#signing_dir = + +# Optionally specify a list of memcached server(s) to use for caching. If left +# undefined, tokens will instead be cached in-process. (list value) +# Deprecated group/name - [keystone_authtoken]/memcache_servers +#memcached_servers = + +# In order to prevent excessive effort spent validating tokens, the middleware +# caches previously-seen tokens for a configurable duration (in seconds). Set +# to -1 to disable caching completely. (integer value) +#token_cache_time = 300 + +# DEPRECATED: Determines the frequency at which the list of revoked tokens is +# retrieved from the Identity service (in seconds). A high number of revocation +# events combined with a low cache duration may significantly reduce +# performance. Only valid for PKI tokens. This option has been deprecated in +# the Ocata release and will be removed in the P release. (integer value) +# This option is deprecated for removal since Ocata. +# Its value may be silently ignored in the future. +# Reason: PKI token format is no longer supported. +#revocation_cache_time = 10 + +# (Optional) If defined, indicate whether token data should be authenticated or +# authenticated and encrypted. If MAC, token data is authenticated (with HMAC) +# in the cache. If ENCRYPT, token data is encrypted and authenticated in the +# cache. If the value is not one of these options or empty, auth_token will +# raise an exception on initialization. (string value) +# Possible values: +# None - +# MAC - +# ENCRYPT - +#memcache_security_strategy = None + +# (Optional, mandatory if memcache_security_strategy is defined) This string is +# used for key derivation. (string value) +#memcache_secret_key = + +# (Optional) Number of seconds memcached server is considered dead before it is +# tried again. (integer value) +#memcache_pool_dead_retry = 300 + +# (Optional) Maximum total number of open connections to every memcached +# server. (integer value) +#memcache_pool_maxsize = 10 + +# (Optional) Socket timeout in seconds for communicating with a memcached +# server. (integer value) +#memcache_pool_socket_timeout = 3 + +# (Optional) Number of seconds a connection to memcached is held unused in the +# pool before it is closed. (integer value) +#memcache_pool_unused_timeout = 60 + +# (Optional) Number of seconds that an operation will wait to get a memcached +# client connection from the pool. (integer value) +#memcache_pool_conn_get_timeout = 10 + +# (Optional) Use the advanced (eventlet safe) memcached client pool. The +# advanced pool will only work under python 2.x. (boolean value) +#memcache_use_advanced_pool = false + +# (Optional) Indicate whether to set the X-Service-Catalog header. If False, +# middleware will not ask for service catalog on token validation and will not +# set the X-Service-Catalog header. (boolean value) +#include_service_catalog = true + +# Used to control the use and type of token binding. Can be set to: "disabled" +# to not check token binding. "permissive" (default) to validate binding +# information if the bind type is of a form known to the server and ignore it +# if not. "strict" like "permissive" but if the bind type is unknown the token +# will be rejected. "required" any form of token binding is needed to be +# allowed. Finally the name of a binding method that must be present in tokens. +# (string value) +#enforce_token_bind = permissive + +# DEPRECATED: If true, the revocation list will be checked for cached tokens. +# This requires that PKI tokens are configured on the identity server. (boolean +# value) +# This option is deprecated for removal since Ocata. +# Its value may be silently ignored in the future. +# Reason: PKI token format is no longer supported. +#check_revocations_for_cached = false + +# DEPRECATED: Hash algorithms to use for hashing PKI tokens. This may be a +# single algorithm or multiple. The algorithms are those supported by Python +# standard hashlib.new(). The hashes will be tried in the order given, so put +# the preferred one first for performance. The result of the first hash will be +# stored in the cache. This will typically be set to multiple values only while +# migrating from a less secure algorithm to a more secure one. Once all the old +# tokens are expired this option should be set to a single value for better +# performance. (list value) +# This option is deprecated for removal since Ocata. +# Its value may be silently ignored in the future. +# Reason: PKI token format is no longer supported. +#hash_algorithms = md5 + +# A choice of roles that must be present in a service token. Service tokens are +# allowed to request that an expired token can be used and so this check should +# tightly control that only actual services should be sending this token. Roles +# here are applied as an ANY check so any role in this list must be present. +# For backwards compatibility reasons this currently only affects the +# allow_expired check. (list value) +#service_token_roles = service + +# For backwards compatibility reasons we must let valid service tokens pass +# that don't pass the service_token_roles check as valid. Setting this true +# will become the default in a future release and should be enabled if +# possible. (boolean value) +#service_token_roles_required = false + +# Authentication type to load (string value) +# Deprecated group/name - [keystone_authtoken]/auth_plugin +#auth_type = + +# Config Section from which to load plugin specific options (string value) +#auth_section = + + +[logging] + +# +# From shipyard_api +# + +# The default logging level for the root logger. ERROR=40, WARNING=30, INFO=20, +# DEBUG=10 (integer value) +#log_level = 10 + +# The logging levels for named loggers. Use standard representations for +# logging levels: ERROR. WARN, INFO, DEBUG. Configuration file format: +# named_log_levels = keystoneauth:INFO,othlgr:WARN (dict value) +#named_log_levels = keystoneauth:20,keystonemiddleware:20 + + +[requests_config] + +# +# From shipyard_api +# + +# Airflow logs retrieval connect timeout (in seconds) (integer value) +#airflow_log_connect_timeout = 5 + +# Airflow logs retrieval timeout (in seconds) (integer value) +#airflow_log_read_timeout = 300 + +# Deckhand client connect timeout (in seconds) (integer value) +#deckhand_client_connect_timeout = 5 + +# Deckhand client timeout (in seconds) for GET, PUT, POST and DELETE request +# (integer value) +#deckhand_client_read_timeout = 300 + +# UCP component validation connect timeout (in seconds) (integer value) +#validation_connect_timeout = 5 + +# UCP component validation timeout (in seconds) (integer value) +#validation_read_timeout = 300 + + +[shipyard] + +# +# From shipyard_api +# + +# The service type for the service playing the role of Shipyard. The specified +# type is used to perform the service lookup in the Keystone service catalog. +# (string value) +#service_type = shipyard diff --git a/generator/config-generator.conf b/src/bin/shipyard_airflow/generator/config-generator.conf similarity index 50% rename from generator/config-generator.conf rename to src/bin/shipyard_airflow/generator/config-generator.conf index 690017db..1298c8c8 100644 --- a/generator/config-generator.conf +++ b/src/bin/shipyard_airflow/generator/config-generator.conf @@ -1,5 +1,5 @@ [DEFAULT] output_file = etc/shipyard/shipyard.conf.sample wrap_width=79 -namespace = shipyard_airflow -namespace = keystonemiddleware.auth_token \ No newline at end of file +namespace = shipyard_api +namespace = keystonemiddleware.auth_token diff --git a/generator/policy-generator.conf b/src/bin/shipyard_airflow/generator/policy-generator.conf similarity index 66% rename from generator/policy-generator.conf rename to src/bin/shipyard_airflow/generator/policy-generator.conf index 9af53045..1ecca82e 100644 --- a/generator/policy-generator.conf +++ b/src/bin/shipyard_airflow/generator/policy-generator.conf @@ -1,3 +1,3 @@ [DEFAULT] output_file = etc/shipyard/policy.yaml.sample -namespace = shipyard_airflow \ No newline at end of file +namespace = shipyard_api diff --git a/requirements.txt b/src/bin/shipyard_airflow/requirements.txt similarity index 74% rename from requirements.txt rename to src/bin/shipyard_airflow/requirements.txt index 7783a70d..5ccbef29 100644 --- a/requirements.txt +++ b/src/bin/shipyard_airflow/requirements.txt @@ -12,27 +12,23 @@ # See the License for the specific language governing permissions and # limitations under the License. +# API requirements + alembic==0.9.5 -arrow==0.10.0 # API and Client +arrow==0.10.0 configparser==3.5.0 falcon==1.2.0 jsonschema==2.6.0 -keystoneauth1==2.13.0 # API and Client -keystonemiddleware==4.17.0 -oslo.config==4.11.0 -oslo.policy==1.25.1 +keystoneauth1==3.4.0 +keystonemiddleware==4.21.0 +oslo.config==5.2.0 +oslo.policy==1.33.1 PasteDeploy==1.5.2 -pbr!=2.1.0,>=2.0.0 # Apache-2.0 psycopg2==2.7.3.1 python-dateutil==2.6.1 python-memcached==1.58 -requests==2.18.4 # API and Client +requests==2.18.4 +setuptools==39.0.1 SQLAlchemy==1.1.13 ulid==1.1 uwsgi==2.0.15 - -# Client -click==6.7 -click-default-group==1.2 -PTable==0.9.2 -pyyaml==3.12 diff --git a/src/bin/shipyard_airflow/setup.py b/src/bin/shipyard_airflow/setup.py new file mode 100644 index 00000000..a756917d --- /dev/null +++ b/src/bin/shipyard_airflow/setup.py @@ -0,0 +1,42 @@ +# 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. +import setuptools + +setuptools.setup( + name='shipyard_api', + version='0.1a1', + description=('Directed acyclic graph controller for Kubernetes and ' + 'OpenStack control plane life cycle management'), + url='https://github.com/att-comdev/shipyard', + author='AT&T - AIC UCP Developers', + license='Apache 2.0', + packages=setuptools.find_packages(), + entry_points={ + 'oslo.config.opts': + 'shipyard_api = shipyard_airflow.conf.opts:list_opts', + 'oslo.policy.policies': + 'shipyard_api = shipyard_airflow.policy:list_policies', + 'console_scripts': + 'upgrade_db = shipyard_airflow.shipyard_upgrade_db:upgrade_db', + }, + classifiers=[ + 'Intended Audience :: Information Technology', + 'Intended Audience :: System Administrators', + 'License :: OSI Approved :: Apache Software License', + 'Operating System :: POSIX :: Linux', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.5', + ], +) diff --git a/shipyard_airflow/__init__.py b/src/bin/shipyard_airflow/shipyard_airflow/__init__.py similarity index 100% rename from shipyard_airflow/__init__.py rename to src/bin/shipyard_airflow/shipyard_airflow/__init__.py diff --git a/shipyard_airflow/conf/__init__.py b/src/bin/shipyard_airflow/shipyard_airflow/conf/__init__.py similarity index 100% rename from shipyard_airflow/conf/__init__.py rename to src/bin/shipyard_airflow/shipyard_airflow/conf/__init__.py diff --git a/shipyard_airflow/conf/config.py b/src/bin/shipyard_airflow/shipyard_airflow/conf/config.py similarity index 100% rename from shipyard_airflow/conf/config.py rename to src/bin/shipyard_airflow/shipyard_airflow/conf/config.py diff --git a/shipyard_airflow/conf/opts.py b/src/bin/shipyard_airflow/shipyard_airflow/conf/opts.py similarity index 100% rename from shipyard_airflow/conf/opts.py rename to src/bin/shipyard_airflow/shipyard_airflow/conf/opts.py diff --git a/shipyard_airflow/control/__init__.py b/src/bin/shipyard_airflow/shipyard_airflow/control/__init__.py similarity index 100% rename from shipyard_airflow/control/__init__.py rename to src/bin/shipyard_airflow/shipyard_airflow/control/__init__.py diff --git a/shipyard_airflow/control/action/__init__.py b/src/bin/shipyard_airflow/shipyard_airflow/control/action/__init__.py similarity index 100% rename from shipyard_airflow/control/action/__init__.py rename to src/bin/shipyard_airflow/shipyard_airflow/control/action/__init__.py diff --git a/shipyard_airflow/control/action/action_helper.py b/src/bin/shipyard_airflow/shipyard_airflow/control/action/action_helper.py similarity index 100% rename from shipyard_airflow/control/action/action_helper.py rename to src/bin/shipyard_airflow/shipyard_airflow/control/action/action_helper.py diff --git a/shipyard_airflow/control/action/actions_api.py b/src/bin/shipyard_airflow/shipyard_airflow/control/action/actions_api.py similarity index 100% rename from shipyard_airflow/control/action/actions_api.py rename to src/bin/shipyard_airflow/shipyard_airflow/control/action/actions_api.py diff --git a/shipyard_airflow/control/action/actions_control_api.py b/src/bin/shipyard_airflow/shipyard_airflow/control/action/actions_control_api.py similarity index 100% rename from shipyard_airflow/control/action/actions_control_api.py rename to src/bin/shipyard_airflow/shipyard_airflow/control/action/actions_control_api.py diff --git a/shipyard_airflow/control/action/actions_id_api.py b/src/bin/shipyard_airflow/shipyard_airflow/control/action/actions_id_api.py similarity index 100% rename from shipyard_airflow/control/action/actions_id_api.py rename to src/bin/shipyard_airflow/shipyard_airflow/control/action/actions_id_api.py diff --git a/shipyard_airflow/control/action/actions_steps_id_api.py b/src/bin/shipyard_airflow/shipyard_airflow/control/action/actions_steps_id_api.py similarity index 100% rename from shipyard_airflow/control/action/actions_steps_id_api.py rename to src/bin/shipyard_airflow/shipyard_airflow/control/action/actions_steps_id_api.py diff --git a/shipyard_airflow/control/action/actions_steps_id_logs_api.py b/src/bin/shipyard_airflow/shipyard_airflow/control/action/actions_steps_id_logs_api.py similarity index 100% rename from shipyard_airflow/control/action/actions_steps_id_logs_api.py rename to src/bin/shipyard_airflow/shipyard_airflow/control/action/actions_steps_id_logs_api.py diff --git a/shipyard_airflow/control/action/actions_validations_id_api.py b/src/bin/shipyard_airflow/shipyard_airflow/control/action/actions_validations_id_api.py similarity index 100% rename from shipyard_airflow/control/action/actions_validations_id_api.py rename to src/bin/shipyard_airflow/shipyard_airflow/control/action/actions_validations_id_api.py diff --git a/shipyard_airflow/control/af_monitoring/__init__.py b/src/bin/shipyard_airflow/shipyard_airflow/control/af_monitoring/__init__.py similarity index 100% rename from shipyard_airflow/control/af_monitoring/__init__.py rename to src/bin/shipyard_airflow/shipyard_airflow/control/af_monitoring/__init__.py diff --git a/shipyard_airflow/control/af_monitoring/workflow_helper.py b/src/bin/shipyard_airflow/shipyard_airflow/control/af_monitoring/workflow_helper.py similarity index 100% rename from shipyard_airflow/control/af_monitoring/workflow_helper.py rename to src/bin/shipyard_airflow/shipyard_airflow/control/af_monitoring/workflow_helper.py diff --git a/shipyard_airflow/control/af_monitoring/workflows_api.py b/src/bin/shipyard_airflow/shipyard_airflow/control/af_monitoring/workflows_api.py similarity index 100% rename from shipyard_airflow/control/af_monitoring/workflows_api.py rename to src/bin/shipyard_airflow/shipyard_airflow/control/af_monitoring/workflows_api.py diff --git a/shipyard_airflow/control/api.py b/src/bin/shipyard_airflow/shipyard_airflow/control/api.py similarity index 100% rename from shipyard_airflow/control/api.py rename to src/bin/shipyard_airflow/shipyard_airflow/control/api.py diff --git a/shipyard_airflow/control/api_lock.py b/src/bin/shipyard_airflow/shipyard_airflow/control/api_lock.py similarity index 100% rename from shipyard_airflow/control/api_lock.py rename to src/bin/shipyard_airflow/shipyard_airflow/control/api_lock.py diff --git a/shipyard_airflow/control/base.py b/src/bin/shipyard_airflow/shipyard_airflow/control/base.py similarity index 100% rename from shipyard_airflow/control/base.py rename to src/bin/shipyard_airflow/shipyard_airflow/control/base.py diff --git a/shipyard_airflow/control/configdocs/__init__.py b/src/bin/shipyard_airflow/shipyard_airflow/control/configdocs/__init__.py similarity index 100% rename from shipyard_airflow/control/configdocs/__init__.py rename to src/bin/shipyard_airflow/shipyard_airflow/control/configdocs/__init__.py diff --git a/shipyard_airflow/control/configdocs/configdocs_api.py b/src/bin/shipyard_airflow/shipyard_airflow/control/configdocs/configdocs_api.py similarity index 100% rename from shipyard_airflow/control/configdocs/configdocs_api.py rename to src/bin/shipyard_airflow/shipyard_airflow/control/configdocs/configdocs_api.py diff --git a/shipyard_airflow/control/configdocs/configdocs_helper.py b/src/bin/shipyard_airflow/shipyard_airflow/control/configdocs/configdocs_helper.py similarity index 100% rename from shipyard_airflow/control/configdocs/configdocs_helper.py rename to src/bin/shipyard_airflow/shipyard_airflow/control/configdocs/configdocs_helper.py diff --git a/shipyard_airflow/control/configdocs/deckhand_client.py b/src/bin/shipyard_airflow/shipyard_airflow/control/configdocs/deckhand_client.py similarity index 100% rename from shipyard_airflow/control/configdocs/deckhand_client.py rename to src/bin/shipyard_airflow/shipyard_airflow/control/configdocs/deckhand_client.py diff --git a/shipyard_airflow/control/configdocs/rendered_configdocs_api.py b/src/bin/shipyard_airflow/shipyard_airflow/control/configdocs/rendered_configdocs_api.py similarity index 100% rename from shipyard_airflow/control/configdocs/rendered_configdocs_api.py rename to src/bin/shipyard_airflow/shipyard_airflow/control/configdocs/rendered_configdocs_api.py diff --git a/shipyard_airflow/control/health.py b/src/bin/shipyard_airflow/shipyard_airflow/control/health.py similarity index 100% rename from shipyard_airflow/control/health.py rename to src/bin/shipyard_airflow/shipyard_airflow/control/health.py diff --git a/shipyard_airflow/control/json_schemas.py b/src/bin/shipyard_airflow/shipyard_airflow/control/json_schemas.py similarity index 100% rename from shipyard_airflow/control/json_schemas.py rename to src/bin/shipyard_airflow/shipyard_airflow/control/json_schemas.py diff --git a/shipyard_airflow/control/middleware/__init__.py b/src/bin/shipyard_airflow/shipyard_airflow/control/middleware/__init__.py similarity index 100% rename from shipyard_airflow/control/middleware/__init__.py rename to src/bin/shipyard_airflow/shipyard_airflow/control/middleware/__init__.py diff --git a/shipyard_airflow/control/middleware/auth.py b/src/bin/shipyard_airflow/shipyard_airflow/control/middleware/auth.py similarity index 100% rename from shipyard_airflow/control/middleware/auth.py rename to src/bin/shipyard_airflow/shipyard_airflow/control/middleware/auth.py diff --git a/shipyard_airflow/control/middleware/context.py b/src/bin/shipyard_airflow/shipyard_airflow/control/middleware/context.py similarity index 100% rename from shipyard_airflow/control/middleware/context.py rename to src/bin/shipyard_airflow/shipyard_airflow/control/middleware/context.py diff --git a/shipyard_airflow/control/middleware/logging_mw.py b/src/bin/shipyard_airflow/shipyard_airflow/control/middleware/logging_mw.py similarity index 100% rename from shipyard_airflow/control/middleware/logging_mw.py rename to src/bin/shipyard_airflow/shipyard_airflow/control/middleware/logging_mw.py diff --git a/shipyard_airflow/control/service_endpoints.py b/src/bin/shipyard_airflow/shipyard_airflow/control/service_endpoints.py similarity index 100% rename from shipyard_airflow/control/service_endpoints.py rename to src/bin/shipyard_airflow/shipyard_airflow/control/service_endpoints.py diff --git a/shipyard_airflow/control/start_shipyard.py b/src/bin/shipyard_airflow/shipyard_airflow/control/start_shipyard.py similarity index 100% rename from shipyard_airflow/control/start_shipyard.py rename to src/bin/shipyard_airflow/shipyard_airflow/control/start_shipyard.py diff --git a/shipyard_airflow/control/ucp_logging.py b/src/bin/shipyard_airflow/shipyard_airflow/control/ucp_logging.py similarity index 100% rename from shipyard_airflow/control/ucp_logging.py rename to src/bin/shipyard_airflow/shipyard_airflow/control/ucp_logging.py diff --git a/shipyard_airflow/dags/__init__.py b/src/bin/shipyard_airflow/shipyard_airflow/dags/__init__.py similarity index 100% rename from shipyard_airflow/dags/__init__.py rename to src/bin/shipyard_airflow/shipyard_airflow/dags/__init__.py diff --git a/shipyard_airflow/dags/armada_deploy_site.py b/src/bin/shipyard_airflow/shipyard_airflow/dags/armada_deploy_site.py similarity index 100% rename from shipyard_airflow/dags/armada_deploy_site.py rename to src/bin/shipyard_airflow/shipyard_airflow/dags/armada_deploy_site.py diff --git a/shipyard_airflow/dags/common_step_factory.py b/src/bin/shipyard_airflow/shipyard_airflow/dags/common_step_factory.py similarity index 100% rename from shipyard_airflow/dags/common_step_factory.py rename to src/bin/shipyard_airflow/shipyard_airflow/dags/common_step_factory.py diff --git a/shipyard_airflow/dags/config_path.py b/src/bin/shipyard_airflow/shipyard_airflow/dags/config_path.py similarity index 100% rename from shipyard_airflow/dags/config_path.py rename to src/bin/shipyard_airflow/shipyard_airflow/dags/config_path.py diff --git a/shipyard_airflow/dags/dag_concurrency_check.py b/src/bin/shipyard_airflow/shipyard_airflow/dags/dag_concurrency_check.py similarity index 100% rename from shipyard_airflow/dags/dag_concurrency_check.py rename to src/bin/shipyard_airflow/shipyard_airflow/dags/dag_concurrency_check.py diff --git a/shipyard_airflow/dags/dag_deployment_configuration.py b/src/bin/shipyard_airflow/shipyard_airflow/dags/dag_deployment_configuration.py similarity index 100% rename from shipyard_airflow/dags/dag_deployment_configuration.py rename to src/bin/shipyard_airflow/shipyard_airflow/dags/dag_deployment_configuration.py diff --git a/shipyard_airflow/dags/dag_names.py b/src/bin/shipyard_airflow/shipyard_airflow/dags/dag_names.py similarity index 100% rename from shipyard_airflow/dags/dag_names.py rename to src/bin/shipyard_airflow/shipyard_airflow/dags/dag_names.py diff --git a/shipyard_airflow/dags/deckhand_get_design.py b/src/bin/shipyard_airflow/shipyard_airflow/dags/deckhand_get_design.py similarity index 100% rename from shipyard_airflow/dags/deckhand_get_design.py rename to src/bin/shipyard_airflow/shipyard_airflow/dags/deckhand_get_design.py diff --git a/shipyard_airflow/dags/deploy_site.py b/src/bin/shipyard_airflow/shipyard_airflow/dags/deploy_site.py similarity index 100% rename from shipyard_airflow/dags/deploy_site.py rename to src/bin/shipyard_airflow/shipyard_airflow/dags/deploy_site.py diff --git a/shipyard_airflow/dags/destroy_node.py b/src/bin/shipyard_airflow/shipyard_airflow/dags/destroy_node.py similarity index 100% rename from shipyard_airflow/dags/destroy_node.py rename to src/bin/shipyard_airflow/shipyard_airflow/dags/destroy_node.py diff --git a/shipyard_airflow/dags/drydock_deploy_site.py b/src/bin/shipyard_airflow/shipyard_airflow/dags/drydock_deploy_site.py similarity index 100% rename from shipyard_airflow/dags/drydock_deploy_site.py rename to src/bin/shipyard_airflow/shipyard_airflow/dags/drydock_deploy_site.py diff --git a/shipyard_airflow/dags/failure_handlers.py b/src/bin/shipyard_airflow/shipyard_airflow/dags/failure_handlers.py similarity index 100% rename from shipyard_airflow/dags/failure_handlers.py rename to src/bin/shipyard_airflow/shipyard_airflow/dags/failure_handlers.py diff --git a/shipyard_airflow/dags/preflight_checks.py b/src/bin/shipyard_airflow/shipyard_airflow/dags/preflight_checks.py similarity index 100% rename from shipyard_airflow/dags/preflight_checks.py rename to src/bin/shipyard_airflow/shipyard_airflow/dags/preflight_checks.py diff --git a/shipyard_airflow/dags/redeploy_server.py b/src/bin/shipyard_airflow/shipyard_airflow/dags/redeploy_server.py similarity index 100% rename from shipyard_airflow/dags/redeploy_server.py rename to src/bin/shipyard_airflow/shipyard_airflow/dags/redeploy_server.py diff --git a/shipyard_airflow/dags/samples/airflow_task_state_operators.py b/src/bin/shipyard_airflow/shipyard_airflow/dags/samples/airflow_task_state_operators.py similarity index 100% rename from shipyard_airflow/dags/samples/airflow_task_state_operators.py rename to src/bin/shipyard_airflow/shipyard_airflow/dags/samples/airflow_task_state_operators.py diff --git a/shipyard_airflow/dags/samples/openstack_api_call.py b/src/bin/shipyard_airflow/shipyard_airflow/dags/samples/openstack_api_call.py similarity index 100% rename from shipyard_airflow/dags/samples/openstack_api_call.py rename to src/bin/shipyard_airflow/shipyard_airflow/dags/samples/openstack_api_call.py diff --git a/shipyard_airflow/dags/update_site.py b/src/bin/shipyard_airflow/shipyard_airflow/dags/update_site.py similarity index 100% rename from shipyard_airflow/dags/update_site.py rename to src/bin/shipyard_airflow/shipyard_airflow/dags/update_site.py diff --git a/shipyard_airflow/dags/validate_site_design.py b/src/bin/shipyard_airflow/shipyard_airflow/dags/validate_site_design.py similarity index 100% rename from shipyard_airflow/dags/validate_site_design.py rename to src/bin/shipyard_airflow/shipyard_airflow/dags/validate_site_design.py diff --git a/shipyard_airflow/db/__init__.py b/src/bin/shipyard_airflow/shipyard_airflow/db/__init__.py similarity index 100% rename from shipyard_airflow/db/__init__.py rename to src/bin/shipyard_airflow/shipyard_airflow/db/__init__.py diff --git a/shipyard_airflow/db/airflow_db.py b/src/bin/shipyard_airflow/shipyard_airflow/db/airflow_db.py similarity index 100% rename from shipyard_airflow/db/airflow_db.py rename to src/bin/shipyard_airflow/shipyard_airflow/db/airflow_db.py diff --git a/shipyard_airflow/db/common_db.py b/src/bin/shipyard_airflow/shipyard_airflow/db/common_db.py similarity index 100% rename from shipyard_airflow/db/common_db.py rename to src/bin/shipyard_airflow/shipyard_airflow/db/common_db.py diff --git a/shipyard_airflow/db/db.py b/src/bin/shipyard_airflow/shipyard_airflow/db/db.py similarity index 100% rename from shipyard_airflow/db/db.py rename to src/bin/shipyard_airflow/shipyard_airflow/db/db.py diff --git a/shipyard_airflow/db/errors.py b/src/bin/shipyard_airflow/shipyard_airflow/db/errors.py similarity index 100% rename from shipyard_airflow/db/errors.py rename to src/bin/shipyard_airflow/shipyard_airflow/db/errors.py diff --git a/shipyard_airflow/db/shipyard_db.py b/src/bin/shipyard_airflow/shipyard_airflow/db/shipyard_db.py similarity index 100% rename from shipyard_airflow/db/shipyard_db.py rename to src/bin/shipyard_airflow/shipyard_airflow/db/shipyard_db.py diff --git a/shipyard_airflow/errors.py b/src/bin/shipyard_airflow/shipyard_airflow/errors.py similarity index 100% rename from shipyard_airflow/errors.py rename to src/bin/shipyard_airflow/shipyard_airflow/errors.py diff --git a/shipyard_airflow/plugins/__init__.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/__init__.py similarity index 100% rename from shipyard_airflow/plugins/__init__.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/__init__.py diff --git a/shipyard_airflow/plugins/airflow_task_state_operators.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/airflow_task_state_operators.py similarity index 100% rename from shipyard_airflow/plugins/airflow_task_state_operators.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/airflow_task_state_operators.py diff --git a/shipyard_airflow/plugins/armada_base_operator.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/armada_base_operator.py similarity index 100% rename from shipyard_airflow/plugins/armada_base_operator.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/armada_base_operator.py diff --git a/shipyard_airflow/plugins/armada_get_releases.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/armada_get_releases.py similarity index 100% rename from shipyard_airflow/plugins/armada_get_releases.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/armada_get_releases.py diff --git a/shipyard_airflow/plugins/armada_get_status.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/armada_get_status.py similarity index 100% rename from shipyard_airflow/plugins/armada_get_status.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/armada_get_status.py diff --git a/shipyard_airflow/plugins/armada_post_apply.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/armada_post_apply.py similarity index 100% rename from shipyard_airflow/plugins/armada_post_apply.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/armada_post_apply.py diff --git a/shipyard_airflow/plugins/armada_validate_design.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/armada_validate_design.py similarity index 100% rename from shipyard_airflow/plugins/armada_validate_design.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/armada_validate_design.py diff --git a/shipyard_airflow/plugins/check_k8s_node_status.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/check_k8s_node_status.py similarity index 100% rename from shipyard_airflow/plugins/check_k8s_node_status.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/check_k8s_node_status.py diff --git a/shipyard_airflow/plugins/check_k8s_pod_status.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/check_k8s_pod_status.py similarity index 100% rename from shipyard_airflow/plugins/check_k8s_pod_status.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/check_k8s_pod_status.py diff --git a/shipyard_airflow/plugins/concurrency_check_operator.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/concurrency_check_operator.py similarity index 100% rename from shipyard_airflow/plugins/concurrency_check_operator.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/concurrency_check_operator.py diff --git a/shipyard_airflow/plugins/deckhand_base_operator.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/deckhand_base_operator.py similarity index 100% rename from shipyard_airflow/plugins/deckhand_base_operator.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/deckhand_base_operator.py diff --git a/shipyard_airflow/plugins/deckhand_client_factory.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/deckhand_client_factory.py similarity index 100% rename from shipyard_airflow/plugins/deckhand_client_factory.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/deckhand_client_factory.py diff --git a/shipyard_airflow/plugins/deckhand_get_design.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/deckhand_get_design.py similarity index 100% rename from shipyard_airflow/plugins/deckhand_get_design.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/deckhand_get_design.py diff --git a/shipyard_airflow/plugins/deckhand_retrieve_rendered_doc.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/deckhand_retrieve_rendered_doc.py similarity index 100% rename from shipyard_airflow/plugins/deckhand_retrieve_rendered_doc.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/deckhand_retrieve_rendered_doc.py diff --git a/shipyard_airflow/plugins/deckhand_validate_site.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/deckhand_validate_site.py similarity index 100% rename from shipyard_airflow/plugins/deckhand_validate_site.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/deckhand_validate_site.py diff --git a/shipyard_airflow/plugins/deployment_configuration_operator.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/deployment_configuration_operator.py similarity index 100% rename from shipyard_airflow/plugins/deployment_configuration_operator.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/deployment_configuration_operator.py diff --git a/shipyard_airflow/plugins/drydock_base_operator.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/drydock_base_operator.py similarity index 100% rename from shipyard_airflow/plugins/drydock_base_operator.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/drydock_base_operator.py diff --git a/shipyard_airflow/plugins/drydock_deploy_nodes.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/drydock_deploy_nodes.py similarity index 100% rename from shipyard_airflow/plugins/drydock_deploy_nodes.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/drydock_deploy_nodes.py diff --git a/shipyard_airflow/plugins/drydock_destroy_nodes.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/drydock_destroy_nodes.py similarity index 100% rename from shipyard_airflow/plugins/drydock_destroy_nodes.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/drydock_destroy_nodes.py diff --git a/shipyard_airflow/plugins/drydock_prepare_nodes.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/drydock_prepare_nodes.py similarity index 100% rename from shipyard_airflow/plugins/drydock_prepare_nodes.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/drydock_prepare_nodes.py diff --git a/shipyard_airflow/plugins/drydock_prepare_site.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/drydock_prepare_site.py similarity index 100% rename from shipyard_airflow/plugins/drydock_prepare_site.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/drydock_prepare_site.py diff --git a/shipyard_airflow/plugins/drydock_validate_design.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/drydock_validate_design.py similarity index 100% rename from shipyard_airflow/plugins/drydock_validate_design.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/drydock_validate_design.py diff --git a/shipyard_airflow/plugins/drydock_verify_site.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/drydock_verify_site.py similarity index 100% rename from shipyard_airflow/plugins/drydock_verify_site.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/drydock_verify_site.py diff --git a/shipyard_airflow/plugins/get_k8s_logs.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/get_k8s_logs.py similarity index 100% rename from shipyard_airflow/plugins/get_k8s_logs.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/get_k8s_logs.py diff --git a/shipyard_airflow/plugins/get_k8s_pod_port_ip.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/get_k8s_pod_port_ip.py similarity index 100% rename from shipyard_airflow/plugins/get_k8s_pod_port_ip.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/get_k8s_pod_port_ip.py diff --git a/shipyard_airflow/plugins/k8s_preflight_checks_operator.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/k8s_preflight_checks_operator.py similarity index 100% rename from shipyard_airflow/plugins/k8s_preflight_checks_operator.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/k8s_preflight_checks_operator.py diff --git a/shipyard_airflow/plugins/openstack_operators.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/openstack_operators.py similarity index 100% rename from shipyard_airflow/plugins/openstack_operators.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/openstack_operators.py diff --git a/shipyard_airflow/plugins/placeholder_operator.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/placeholder_operator.py similarity index 100% rename from shipyard_airflow/plugins/placeholder_operator.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/placeholder_operator.py diff --git a/shipyard_airflow/plugins/promenade_base_operator.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/promenade_base_operator.py similarity index 100% rename from shipyard_airflow/plugins/promenade_base_operator.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/promenade_base_operator.py diff --git a/shipyard_airflow/plugins/promenade_check_etcd.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/promenade_check_etcd.py similarity index 100% rename from shipyard_airflow/plugins/promenade_check_etcd.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/promenade_check_etcd.py diff --git a/shipyard_airflow/plugins/promenade_clear_labels.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/promenade_clear_labels.py similarity index 100% rename from shipyard_airflow/plugins/promenade_clear_labels.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/promenade_clear_labels.py diff --git a/shipyard_airflow/plugins/promenade_decommission_node.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/promenade_decommission_node.py similarity index 100% rename from shipyard_airflow/plugins/promenade_decommission_node.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/promenade_decommission_node.py diff --git a/shipyard_airflow/plugins/promenade_drain_node.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/promenade_drain_node.py similarity index 100% rename from shipyard_airflow/plugins/promenade_drain_node.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/promenade_drain_node.py diff --git a/shipyard_airflow/plugins/promenade_shutdown_kubelet.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/promenade_shutdown_kubelet.py similarity index 100% rename from shipyard_airflow/plugins/promenade_shutdown_kubelet.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/promenade_shutdown_kubelet.py diff --git a/shipyard_airflow/plugins/rest_api_plugin.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/rest_api_plugin.py similarity index 100% rename from shipyard_airflow/plugins/rest_api_plugin.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/rest_api_plugin.py diff --git a/shipyard_airflow/plugins/service_endpoint.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/service_endpoint.py similarity index 100% rename from shipyard_airflow/plugins/service_endpoint.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/service_endpoint.py diff --git a/shipyard_airflow/plugins/service_session.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/service_session.py similarity index 100% rename from shipyard_airflow/plugins/service_session.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/service_session.py diff --git a/shipyard_airflow/plugins/service_token.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/service_token.py similarity index 100% rename from shipyard_airflow/plugins/service_token.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/service_token.py diff --git a/shipyard_airflow/plugins/ucp_base_operator.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/ucp_base_operator.py similarity index 100% rename from shipyard_airflow/plugins/ucp_base_operator.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/ucp_base_operator.py diff --git a/shipyard_airflow/plugins/ucp_preflight_check_operator.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/ucp_preflight_check_operator.py similarity index 100% rename from shipyard_airflow/plugins/ucp_preflight_check_operator.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/ucp_preflight_check_operator.py diff --git a/shipyard_airflow/plugins/xcom_puller.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/xcom_puller.py similarity index 100% rename from shipyard_airflow/plugins/xcom_puller.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/xcom_puller.py diff --git a/shipyard_airflow/plugins/xcom_pusher.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/xcom_pusher.py similarity index 100% rename from shipyard_airflow/plugins/xcom_pusher.py rename to src/bin/shipyard_airflow/shipyard_airflow/plugins/xcom_pusher.py diff --git a/shipyard_airflow/policy.py b/src/bin/shipyard_airflow/shipyard_airflow/policy.py similarity index 100% rename from shipyard_airflow/policy.py rename to src/bin/shipyard_airflow/shipyard_airflow/policy.py diff --git a/shipyard_airflow/schemas/deploymentConfiguration.yaml b/src/bin/shipyard_airflow/shipyard_airflow/schemas/deploymentConfiguration.yaml similarity index 100% rename from shipyard_airflow/schemas/deploymentConfiguration.yaml rename to src/bin/shipyard_airflow/shipyard_airflow/schemas/deploymentConfiguration.yaml diff --git a/src/bin/shipyard_airflow/shipyard_airflow/schemas/deploymentStrategy.yaml b/src/bin/shipyard_airflow/shipyard_airflow/schemas/deploymentStrategy.yaml new file mode 100644 index 00000000..51bda9f0 --- /dev/null +++ b/src/bin/shipyard_airflow/shipyard_airflow/schemas/deploymentStrategy.yaml @@ -0,0 +1,74 @@ +--- +schema: 'deckhand/DataSchema/v1' +metadata: + schema: metadata/Control/v1 + name: shipyard/DeploymentStrategy/v1 + labels: + application: shipyard +data: + $schema: 'http://json-schema.org/schema#' + id: 'https://github.com/att-comdev/shipyard/deploymentStrategy.yaml' + type: 'object' + required: + - groups + properties: + groups: + type: 'array' + minItems: 0 + items: + type: 'object' + required: + - name + - critical + - depends_on + - selectors + properties: + name: + type: 'string' + minLength: 1 + critical: + type: 'boolean' + depends_on: + type: 'array' + minItems: 0 + items: + type: 'string' + selectors: + type: 'array' + minItems: 0 + items: + type: 'object' + minProperties: 1 + properties: + node_names: + type: 'array' + items: + type: 'string' + node_labels: + type: 'array' + items: + type: 'string' + node_tags: + type: 'array' + items: + type: 'string' + rack_names: + type: 'array' + items: + type: 'string' + additionalProperties: false + success_criteria: + type: 'object' + minProperties: 1 + properties: + percent_successful_nodes: + type: 'integer' + minimum: 0 + maximum: 100 + minimum_successful_nodes: + type: 'integer' + minimum: 0 + maximum_failed_nodes: + type: 'integer' + minimum: 0 + additionalProperties: false diff --git a/shipyard_airflow/shipyard.py b/src/bin/shipyard_airflow/shipyard_airflow/shipyard_api.py similarity index 100% rename from shipyard_airflow/shipyard.py rename to src/bin/shipyard_airflow/shipyard_airflow/shipyard_api.py diff --git a/shipyard_airflow/shipyard_upgrade_db.py b/src/bin/shipyard_airflow/shipyard_airflow/shipyard_upgrade_db.py similarity index 100% rename from shipyard_airflow/shipyard_upgrade_db.py rename to src/bin/shipyard_airflow/shipyard_airflow/shipyard_upgrade_db.py diff --git a/test-requirements.txt b/src/bin/shipyard_airflow/test-requirements.txt similarity index 76% rename from test-requirements.txt rename to src/bin/shipyard_airflow/test-requirements.txt index 7097167a..af653244 100644 --- a/test-requirements.txt +++ b/src/bin/shipyard_airflow/test-requirements.txt @@ -20,14 +20,3 @@ flake8==3.3.0 # Security scanning bandit>=1.1.0 # Apache-2.0 - -# Documentation -sphinx>=1.6.2 -sphinx_rtd_theme==0.2.4 - -# Documentation, repeated from requirements.txt to support readthedocs build. -oslo.config==4.11.0 -oslo.policy==1.25.1 -keystoneauth1==2.13.0 -keystonemiddleware==4.17.0 -falcon==1.2.0 diff --git a/shipyard_client/__init__.py b/src/bin/shipyard_airflow/tests/__init__.py similarity index 100% rename from shipyard_client/__init__.py rename to src/bin/shipyard_airflow/tests/__init__.py diff --git a/shipyard_client/api_client/__init__.py b/src/bin/shipyard_airflow/tests/unit/__init__.py similarity index 100% rename from shipyard_client/api_client/__init__.py rename to src/bin/shipyard_airflow/tests/unit/__init__.py diff --git a/tests/unit/control/__init__.py b/src/bin/shipyard_airflow/tests/unit/control/__init__.py similarity index 100% rename from tests/unit/control/__init__.py rename to src/bin/shipyard_airflow/tests/unit/control/__init__.py diff --git a/shipyard_client/cli/__init__.py b/src/bin/shipyard_airflow/tests/unit/control/af_monitoring/__init__.py similarity index 100% rename from shipyard_client/cli/__init__.py rename to src/bin/shipyard_airflow/tests/unit/control/af_monitoring/__init__.py diff --git a/tests/unit/control/af_monitoring/test_workflow_api.py b/src/bin/shipyard_airflow/tests/unit/control/af_monitoring/test_workflow_api.py similarity index 100% rename from tests/unit/control/af_monitoring/test_workflow_api.py rename to src/bin/shipyard_airflow/tests/unit/control/af_monitoring/test_workflow_api.py diff --git a/tests/unit/control/af_monitoring/test_workflow_helper.py b/src/bin/shipyard_airflow/tests/unit/control/af_monitoring/test_workflow_helper.py similarity index 100% rename from tests/unit/control/af_monitoring/test_workflow_helper.py rename to src/bin/shipyard_airflow/tests/unit/control/af_monitoring/test_workflow_helper.py diff --git a/tests/unit/control/common.py b/src/bin/shipyard_airflow/tests/unit/control/common.py similarity index 100% rename from tests/unit/control/common.py rename to src/bin/shipyard_airflow/tests/unit/control/common.py diff --git a/tests/unit/control/conftest.py b/src/bin/shipyard_airflow/tests/unit/control/conftest.py similarity index 100% rename from tests/unit/control/conftest.py rename to src/bin/shipyard_airflow/tests/unit/control/conftest.py diff --git a/tests/unit/control/fake_response.py b/src/bin/shipyard_airflow/tests/unit/control/fake_response.py similarity index 100% rename from tests/unit/control/fake_response.py rename to src/bin/shipyard_airflow/tests/unit/control/fake_response.py diff --git a/tests/unit/control/middleware/test_logging_mw.py b/src/bin/shipyard_airflow/tests/unit/control/middleware/test_logging_mw.py similarity index 100% rename from tests/unit/control/middleware/test_logging_mw.py rename to src/bin/shipyard_airflow/tests/unit/control/middleware/test_logging_mw.py diff --git a/tests/unit/control/test.conf b/src/bin/shipyard_airflow/tests/unit/control/test.conf similarity index 100% rename from tests/unit/control/test.conf rename to src/bin/shipyard_airflow/tests/unit/control/test.conf diff --git a/tests/unit/control/test_action_helper.py b/src/bin/shipyard_airflow/tests/unit/control/test_action_helper.py similarity index 100% rename from tests/unit/control/test_action_helper.py rename to src/bin/shipyard_airflow/tests/unit/control/test_action_helper.py diff --git a/tests/unit/control/test_actions_api.py b/src/bin/shipyard_airflow/tests/unit/control/test_actions_api.py similarity index 100% rename from tests/unit/control/test_actions_api.py rename to src/bin/shipyard_airflow/tests/unit/control/test_actions_api.py diff --git a/tests/unit/control/test_actions_control_api.py b/src/bin/shipyard_airflow/tests/unit/control/test_actions_control_api.py similarity index 100% rename from tests/unit/control/test_actions_control_api.py rename to src/bin/shipyard_airflow/tests/unit/control/test_actions_control_api.py diff --git a/tests/unit/control/test_actions_id_api.py b/src/bin/shipyard_airflow/tests/unit/control/test_actions_id_api.py similarity index 100% rename from tests/unit/control/test_actions_id_api.py rename to src/bin/shipyard_airflow/tests/unit/control/test_actions_id_api.py diff --git a/tests/unit/control/test_actions_steps_id_api.py b/src/bin/shipyard_airflow/tests/unit/control/test_actions_steps_id_api.py similarity index 100% rename from tests/unit/control/test_actions_steps_id_api.py rename to src/bin/shipyard_airflow/tests/unit/control/test_actions_steps_id_api.py diff --git a/tests/unit/control/test_actions_steps_id_logs_api.py b/src/bin/shipyard_airflow/tests/unit/control/test_actions_steps_id_logs_api.py similarity index 100% rename from tests/unit/control/test_actions_steps_id_logs_api.py rename to src/bin/shipyard_airflow/tests/unit/control/test_actions_steps_id_logs_api.py diff --git a/tests/unit/control/test_actions_validations_id_api.py b/src/bin/shipyard_airflow/tests/unit/control/test_actions_validations_id_api.py similarity index 100% rename from tests/unit/control/test_actions_validations_id_api.py rename to src/bin/shipyard_airflow/tests/unit/control/test_actions_validations_id_api.py diff --git a/tests/unit/control/test_api.py b/src/bin/shipyard_airflow/tests/unit/control/test_api.py similarity index 100% rename from tests/unit/control/test_api.py rename to src/bin/shipyard_airflow/tests/unit/control/test_api.py diff --git a/tests/unit/control/test_base_resource.py b/src/bin/shipyard_airflow/tests/unit/control/test_base_resource.py similarity index 100% rename from tests/unit/control/test_base_resource.py rename to src/bin/shipyard_airflow/tests/unit/control/test_base_resource.py diff --git a/tests/unit/control/test_configdocs_api.py b/src/bin/shipyard_airflow/tests/unit/control/test_configdocs_api.py similarity index 100% rename from tests/unit/control/test_configdocs_api.py rename to src/bin/shipyard_airflow/tests/unit/control/test_configdocs_api.py diff --git a/tests/unit/control/test_configdocs_helper.py b/src/bin/shipyard_airflow/tests/unit/control/test_configdocs_helper.py similarity index 100% rename from tests/unit/control/test_configdocs_helper.py rename to src/bin/shipyard_airflow/tests/unit/control/test_configdocs_helper.py diff --git a/tests/unit/control/test_rendered_configdocs_api.py b/src/bin/shipyard_airflow/tests/unit/control/test_rendered_configdocs_api.py similarity index 100% rename from tests/unit/control/test_rendered_configdocs_api.py rename to src/bin/shipyard_airflow/tests/unit/control/test_rendered_configdocs_api.py diff --git a/tests/unit/control/test_shipyard_request_context.py b/src/bin/shipyard_airflow/tests/unit/control/test_shipyard_request_context.py similarity index 100% rename from tests/unit/control/test_shipyard_request_context.py rename to src/bin/shipyard_airflow/tests/unit/control/test_shipyard_request_context.py diff --git a/tests/unit/control/test_start_shipyard.py b/src/bin/shipyard_airflow/tests/unit/control/test_start_shipyard.py similarity index 100% rename from tests/unit/control/test_start_shipyard.py rename to src/bin/shipyard_airflow/tests/unit/control/test_start_shipyard.py diff --git a/shipyard_client/cli/commit/__init__.py b/src/bin/shipyard_airflow/tests/unit/dags/__init__.py similarity index 100% rename from shipyard_client/cli/commit/__init__.py rename to src/bin/shipyard_airflow/tests/unit/dags/__init__.py diff --git a/tests/unit/dags/test_failure_handlers.py b/src/bin/shipyard_airflow/tests/unit/dags/test_failure_handlers.py similarity index 100% rename from tests/unit/dags/test_failure_handlers.py rename to src/bin/shipyard_airflow/tests/unit/dags/test_failure_handlers.py diff --git a/shipyard_client/cli/control/__init__.py b/src/bin/shipyard_airflow/tests/unit/plugins/__init__.py similarity index 100% rename from shipyard_client/cli/control/__init__.py rename to src/bin/shipyard_airflow/tests/unit/plugins/__init__.py diff --git a/tests/unit/plugins/test.conf b/src/bin/shipyard_airflow/tests/unit/plugins/test.conf similarity index 100% rename from tests/unit/plugins/test.conf rename to src/bin/shipyard_airflow/tests/unit/plugins/test.conf diff --git a/tests/unit/plugins/test_concurrency_check_operator.py b/src/bin/shipyard_airflow/tests/unit/plugins/test_concurrency_check_operator.py similarity index 100% rename from tests/unit/plugins/test_concurrency_check_operator.py rename to src/bin/shipyard_airflow/tests/unit/plugins/test_concurrency_check_operator.py diff --git a/tests/unit/plugins/test_deckhand_client_factory.py b/src/bin/shipyard_airflow/tests/unit/plugins/test_deckhand_client_factory.py similarity index 100% rename from tests/unit/plugins/test_deckhand_client_factory.py rename to src/bin/shipyard_airflow/tests/unit/plugins/test_deckhand_client_factory.py diff --git a/tests/unit/plugins/test_deployment_configuration_operator.py b/src/bin/shipyard_airflow/tests/unit/plugins/test_deployment_configuration_operator.py similarity index 100% rename from tests/unit/plugins/test_deployment_configuration_operator.py rename to src/bin/shipyard_airflow/tests/unit/plugins/test_deployment_configuration_operator.py diff --git a/shipyard_client/cli/create/__init__.py b/src/bin/shipyard_airflow/tests/unit/schemas/__init__.py similarity index 100% rename from shipyard_client/cli/create/__init__.py rename to src/bin/shipyard_airflow/tests/unit/schemas/__init__.py diff --git a/src/bin/shipyard_airflow/tests/unit/schemas/base_schema_validation.py b/src/bin/shipyard_airflow/tests/unit/schemas/base_schema_validation.py new file mode 100644 index 00000000..13685769 --- /dev/null +++ b/src/bin/shipyard_airflow/tests/unit/schemas/base_schema_validation.py @@ -0,0 +1,51 @@ +# 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 logging +import os +import yaml + +import jsonschema +import pkg_resources +import pytest + +from jsonschema.exceptions import ValidationError + +LOG = logging.getLogger(__name__) + + +class BaseSchemaValidationTest(object): + def _test_validate(self, schema, expect_failure, input_files, input): + """validates input yaml against schema. + :param schema: schema yaml file + :param expect_failure: should the validation pass or fail. + :param input_files: pytest fixture used to access the test input files + :param input: test input yaml doc filename""" + schema_dir = pkg_resources.resource_filename('shipyard_airflow', + 'schemas') + schema_filename = os.path.join(schema_dir, schema) + schema_file = open(schema_filename, 'r') + schema = yaml.safe_load(schema_file) + + input_file = input_files.join(input) + instance_file = open(str(input_file), 'r') + instance = yaml.safe_load(instance_file) + + LOG.info('Input: %s, Schema: %s', input_file, schema_filename) + + if expect_failure: + # TypeError is raised when he input document is not well formed. + with pytest.raises((ValidationError, TypeError)): + jsonschema.validate(instance['data'], schema['data']) + else: + jsonschema.validate(instance['data'], schema['data']) diff --git a/src/bin/shipyard_airflow/tests/unit/schemas/conftest.py b/src/bin/shipyard_airflow/tests/unit/schemas/conftest.py new file mode 100644 index 00000000..4e79dc98 --- /dev/null +++ b/src/bin/shipyard_airflow/tests/unit/schemas/conftest.py @@ -0,0 +1,31 @@ +# 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. +import os + +import pytest +import shutil + + +@pytest.fixture(scope='module') +def input_files(tmpdir_factory, request): + tmpdir = tmpdir_factory.mktemp('data') + samples_dir = os.path.dirname(str( + request.fspath)) + "/" + "../yaml_samples" + samples = os.listdir(samples_dir) + + for f in samples: + src_file = samples_dir + "/" + f + dst_file = str(tmpdir) + "/" + f + shutil.copyfile(src_file, dst_file) + return tmpdir diff --git a/tests/unit/schemas/test_deployment_configuration.py b/src/bin/shipyard_airflow/tests/unit/schemas/test_deployment_configuration.py similarity index 100% rename from tests/unit/schemas/test_deployment_configuration.py rename to src/bin/shipyard_airflow/tests/unit/schemas/test_deployment_configuration.py diff --git a/src/bin/shipyard_airflow/tests/unit/schemas/test_deployment_strategy.py b/src/bin/shipyard_airflow/tests/unit/schemas/test_deployment_strategy.py new file mode 100644 index 00000000..c610dc9e --- /dev/null +++ b/src/bin/shipyard_airflow/tests/unit/schemas/test_deployment_strategy.py @@ -0,0 +1,38 @@ +# 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 .base_schema_validation import BaseSchemaValidationTest + + +class TestValidation(BaseSchemaValidationTest): + def test_validate_deploy_config_full_valid(self, input_files): + self._test_validate('deploymentStrategy.yaml', False, input_files, + 'deploymentStrategy_full_valid.yaml') + + self._test_validate('deploymentStrategy.yaml', False, input_files, + 'deploymentStrategy_minimal.yaml') + + self._test_validate('deploymentStrategy.yaml', False, input_files, + 'deploymentStrategy_min_with_content.yaml') + + for testnum in range(1, 5): + self._test_validate( + 'deploymentStrategy.yaml', True, input_files, + 'deploymentStrategy_bad_values_{}.yaml'.format(testnum) + ) + + self._test_validate('deploymentStrategy.yaml', True, input_files, + 'total_garbage.yaml') + + self._test_validate('deploymentStrategy.yaml', True, input_files, + 'empty.yaml') diff --git a/tests/unit/test_errors.py b/src/bin/shipyard_airflow/tests/unit/test_errors.py similarity index 100% rename from tests/unit/test_errors.py rename to src/bin/shipyard_airflow/tests/unit/test_errors.py diff --git a/tests/unit/yaml_samples/deploymentConfiguration_bad_manifest.yaml b/src/bin/shipyard_airflow/tests/unit/yaml_samples/deploymentConfiguration_bad_manifest.yaml similarity index 100% rename from tests/unit/yaml_samples/deploymentConfiguration_bad_manifest.yaml rename to src/bin/shipyard_airflow/tests/unit/yaml_samples/deploymentConfiguration_bad_manifest.yaml diff --git a/tests/unit/yaml_samples/deploymentConfiguration_full_valid.yaml b/src/bin/shipyard_airflow/tests/unit/yaml_samples/deploymentConfiguration_full_valid.yaml similarity index 100% rename from tests/unit/yaml_samples/deploymentConfiguration_full_valid.yaml rename to src/bin/shipyard_airflow/tests/unit/yaml_samples/deploymentConfiguration_full_valid.yaml diff --git a/tests/unit/yaml_samples/deploymentConfiguration_minimal_valid.yaml b/src/bin/shipyard_airflow/tests/unit/yaml_samples/deploymentConfiguration_minimal_valid.yaml similarity index 100% rename from tests/unit/yaml_samples/deploymentConfiguration_minimal_valid.yaml rename to src/bin/shipyard_airflow/tests/unit/yaml_samples/deploymentConfiguration_minimal_valid.yaml diff --git a/src/bin/shipyard_airflow/tests/unit/yaml_samples/deploymentStrategy_bad_values_1.yaml b/src/bin/shipyard_airflow/tests/unit/yaml_samples/deploymentStrategy_bad_values_1.yaml new file mode 100644 index 00000000..dc7711f4 --- /dev/null +++ b/src/bin/shipyard_airflow/tests/unit/yaml_samples/deploymentStrategy_bad_values_1.yaml @@ -0,0 +1,16 @@ +--- +schema: shipyard/DeploymentStrategy/v1 +metadata: + schema: metadata/Document/v1 + name: deployment-strategy + layeringDefinition: + abstract: false + layer: global + storagePolicy: cleartext +data: + groups: +# name is a min length of 1 + - name: "" + critical: false + depends_on: [] + selectors: [] diff --git a/src/bin/shipyard_airflow/tests/unit/yaml_samples/deploymentStrategy_bad_values_2.yaml b/src/bin/shipyard_airflow/tests/unit/yaml_samples/deploymentStrategy_bad_values_2.yaml new file mode 100644 index 00000000..6903c12a --- /dev/null +++ b/src/bin/shipyard_airflow/tests/unit/yaml_samples/deploymentStrategy_bad_values_2.yaml @@ -0,0 +1,16 @@ +--- +schema: shipyard/DeploymentStrategy/v1 +metadata: + schema: metadata/Document/v1 + name: deployment-strategy + layeringDefinition: + abstract: false + layer: global + storagePolicy: cleartext +data: + groups: + - name: a_group +# critical is boolean + critical: cheese sandwich + depends_on: [] + selectors: [] diff --git a/src/bin/shipyard_airflow/tests/unit/yaml_samples/deploymentStrategy_bad_values_3.yaml b/src/bin/shipyard_airflow/tests/unit/yaml_samples/deploymentStrategy_bad_values_3.yaml new file mode 100644 index 00000000..f2c6f375 --- /dev/null +++ b/src/bin/shipyard_airflow/tests/unit/yaml_samples/deploymentStrategy_bad_values_3.yaml @@ -0,0 +1,15 @@ +--- +schema: shipyard/DeploymentStrategy/v1 +metadata: + schema: metadata/Document/v1 + name: deployment-strategy + layeringDefinition: + abstract: false + layer: global + storagePolicy: cleartext +data: + groups: + - name: some_group + critical: true +# depends_on missing + selectors: [] diff --git a/src/bin/shipyard_airflow/tests/unit/yaml_samples/deploymentStrategy_bad_values_4.yaml b/src/bin/shipyard_airflow/tests/unit/yaml_samples/deploymentStrategy_bad_values_4.yaml new file mode 100644 index 00000000..154b5ce9 --- /dev/null +++ b/src/bin/shipyard_airflow/tests/unit/yaml_samples/deploymentStrategy_bad_values_4.yaml @@ -0,0 +1,18 @@ +--- +schema: shipyard/DeploymentStrategy/v1 +metadata: + schema: metadata/Document/v1 + name: deployment-strategy + layeringDefinition: + abstract: false + layer: global + storagePolicy: cleartext +data: + groups: + - name: my_name_is + critical: false + depends_on: [] + selectors: +# node_names are strings + - node_names: [false, true, false] + node_labels: [] diff --git a/src/bin/shipyard_airflow/tests/unit/yaml_samples/deploymentStrategy_bad_values_5.yaml b/src/bin/shipyard_airflow/tests/unit/yaml_samples/deploymentStrategy_bad_values_5.yaml new file mode 100644 index 00000000..d363f3f8 --- /dev/null +++ b/src/bin/shipyard_airflow/tests/unit/yaml_samples/deploymentStrategy_bad_values_5.yaml @@ -0,0 +1,20 @@ +--- +schema: shipyard/DeploymentStrategy/v1 +metadata: + schema: metadata/Document/v1 + name: deployment-strategy + layeringDefinition: + abstract: false + layer: global + storagePolicy: cleartext +data: + groups: + - name: my_group + critical: false + depends_on: [] + selectors: + - node_names: [] + node_labels: [] + success_criteria: +# should be 100 or less + percent_successful_nodes: 190 diff --git a/src/bin/shipyard_airflow/tests/unit/yaml_samples/deploymentStrategy_full_valid.yaml b/src/bin/shipyard_airflow/tests/unit/yaml_samples/deploymentStrategy_full_valid.yaml new file mode 100644 index 00000000..d218bd8d --- /dev/null +++ b/src/bin/shipyard_airflow/tests/unit/yaml_samples/deploymentStrategy_full_valid.yaml @@ -0,0 +1,75 @@ +--- +schema: shipyard/DeploymentStrategy/v1 +metadata: + schema: metadata/Document/v1 + name: deployment-strategy + layeringDefinition: + abstract: false + layer: global + storagePolicy: cleartext +data: + groups: + - name: control-nodes + critical: true + depends_on: + - ntp-node + selectors: + - node_names: [] + node_labels: [] + node_tags: + - control + rack_names: + - rack03 + success_criteria: + percent_successful_nodes: 90 + minimum_successful_nodes: 3 + maximum_failed_nodes: 1 + - name: compute-nodes-1 + critical: false + depends_on: + - control-nodes + selectors: + - node_names: [] + node_labels: [] + rack_names: + - rack01 + node_tags: + - compute + success_criteria: + percent_successful_nodes: 50 + - name: compute-nodes-2 + critical: false + depends_on: + - control-nodes + selectors: + - node_names: [] + node_labels: [] + rack_names: + - rack02 + node_tags: + - compute + success_criteria: + percent_successful_nodes: 50 + - name: monitoring-nodes + critical: false + depends_on: [] + selectors: + - node_names: [] + node_labels: [] + node_tags: + - monitoring + rack_names: + - rack03 + - rack02 + - rack01 + - name: ntp-node + critical: true + depends_on: [] + selectors: + - node_names: + - ntp01 + node_labels: [] + node_tags: [] + rack_names: [] + success_criteria: + minimum_successful_nodes: 1 diff --git a/src/bin/shipyard_airflow/tests/unit/yaml_samples/deploymentStrategy_min_with_content.yaml b/src/bin/shipyard_airflow/tests/unit/yaml_samples/deploymentStrategy_min_with_content.yaml new file mode 100644 index 00000000..65e1930c --- /dev/null +++ b/src/bin/shipyard_airflow/tests/unit/yaml_samples/deploymentStrategy_min_with_content.yaml @@ -0,0 +1,15 @@ +--- +schema: shipyard/DeploymentStrategy/v1 +metadata: + schema: metadata/Document/v1 + name: deployment-strategy + layeringDefinition: + abstract: false + layer: global + storagePolicy: cleartext +data: + groups: + - name: some-nodes + critical: false + depends_on: [] + selectors: [] diff --git a/src/bin/shipyard_airflow/tests/unit/yaml_samples/deploymentStrategy_minimal.yaml b/src/bin/shipyard_airflow/tests/unit/yaml_samples/deploymentStrategy_minimal.yaml new file mode 100644 index 00000000..3f36a115 --- /dev/null +++ b/src/bin/shipyard_airflow/tests/unit/yaml_samples/deploymentStrategy_minimal.yaml @@ -0,0 +1,11 @@ +--- +schema: shipyard/DeploymentStrategy/v1 +metadata: + schema: metadata/Document/v1 + name: deployment-strategy + layeringDefinition: + abstract: false + layer: global + storagePolicy: cleartext +data: + groups: [] diff --git a/shipyard_client/cli/describe/__init__.py b/src/bin/shipyard_airflow/tests/unit/yaml_samples/empty.yaml similarity index 100% rename from shipyard_client/cli/describe/__init__.py rename to src/bin/shipyard_airflow/tests/unit/yaml_samples/empty.yaml diff --git a/src/bin/shipyard_airflow/tests/unit/yaml_samples/total_garbage.yaml b/src/bin/shipyard_airflow/tests/unit/yaml_samples/total_garbage.yaml new file mode 100644 index 00000000..15bab1c2 --- /dev/null +++ b/src/bin/shipyard_airflow/tests/unit/yaml_samples/total_garbage.yaml @@ -0,0 +1,44 @@ +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras euismod +sed urna nec posuere. Phasellus vel arcu vestibulum, mattis ligula eu, +pulvinar magna. Cras mollis velit quis maximus gravida. Morbi nec ligula +neque. Cras vitae cursus tellus, ut ornare enim. Nulla vel suscipit +arcu, in auctor ipsum. Ut a maximus magna. Integer massa risus, +tristique sit amet urna sit amet, facilisis bibendum lectus. Vivamus +vehicula urna in purus lacinia, sit amet tincidunt diam consequat. +Quisque ut metus vitae mauris condimentum sollicitudin. Pellentesque +urna nibh, mollis eu dui ac, molestie malesuada quam. Aliquam fringilla +faucibus orci, a tincidunt dui sollicitudin ac. Nullam enim velit, +imperdiet ut nulla quis, efficitur tincidunt eros. Curabitur nisi justo, +tristique non ornare vitae, mollis eu tortor. In non congue libero. +Mauris et tincidunt sem. Quisque sed congue diam, non ultrices turpis. +Pellentesque lobortis quam justo, facilisis sollicitudin mi imperdiet +sed. Ut nec leo placerat, gravida odio id, hendrerit erat. Praesent +placerat diam mi, et blandit mi sollicitudin et. Proin ligula sapien, +faucibus eget arcu vel, rhoncus vestibulum ipsum. Morbi tristique +pharetra diam non faucibus. Nam scelerisque, leo ut tempus fermentum, +dolor odio tempus nisl, et volutpat ante est id enim. Integer venenatis +scelerisque augue, quis porta lorem dapibus non. Sed arcu purus, iaculis +vitae sem sit amet, ultrices pretium leo. Nulla ultricies eleifend +tempus. Aenean elementum ipsum id auctor faucibus. Cras quis ipsum +vehicula, auctor velit et, dignissim sem. Duis sed nunc sagittis, +interdum dui consequat, iaculis purus. Curabitur quam ex, pellentesque +nec sapien ut, sodales lacinia enim. Etiam hendrerit sem eu turpis +euismod, quis luctus tortor iaculis. Vivamus a rutrum orci. Class aptent +taciti sociosqu ad litora torquent per conubia nostra, per inceptos +himenaeos. Pellentesque habitant morbi tristique senectus et netus et +malesuada fames ac turpis egestas. Aenean non neque ultrices, consequat +erat vitae, porta lorem. Phasellus fringilla fringilla imperdiet. +Quisque in nulla at elit sodales vestibulum ac eget mauris. Ut vel purus +nec metus ultrices aliquet in sed leo. Mauris vel congue velit. Donec +quam turpis, venenatis tristique sem nec, condimentum fringilla orci. +Sed eu feugiat dui. Proin vulputate lacus id blandit tempor. Vivamus +sollicitudin tincidunt ultrices. Aenean sit amet orci efficitur, +condimentum mi vel, condimentum nisi. Cras pellentesque, felis vel +maximus volutpat, turpis arcu dapibus metus, vitae fringilla massa lorem +et elit. Interdum et malesuada fames ac ante ipsum primis in faucibus. +Duis lorem velit, laoreet tincidunt fringilla at, vestibulum eget risus. +Pellentesque ullamcorper venenatis lectus, a mattis lectus feugiat vel. +Suspendisse potenti. Duis suscipit malesuada risus nec egestas. Vivamus +maximus, neque quis egestas rhoncus, mauris purus fringilla nisl, ut +fringilla odio nunc sit amet justo. Phasellus at dui quis magna +elementum sagittis. Nullam sed luctus felis, ac tincidunt erat. diff --git a/src/bin/shipyard_airflow/tox.ini b/src/bin/shipyard_airflow/tox.ini new file mode 100644 index 00000000..b9b467c1 --- /dev/null +++ b/src/bin/shipyard_airflow/tox.ini @@ -0,0 +1,58 @@ +[tox] +envlist = unit, pep8, bandit + +[testenv] +setenv= + PYTHONWARNING=all +basepython=python3.5 +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + +[testenv:unit] +skipsdist=True +commands = + pytest \ + {posargs} \ + --cov-branch \ + --cov-report=term-missing:skip-covered \ + --cov-config=.coveragerc \ + --cov=shipyard_airflow \ + --cov-report=html + +[testenv:pep8] +commands = flake8 {posargs} + +[testenv:bandit] +skipsdist=True +# NOTE(Bryan Strassner) ignoring airflow plugin which uses a subexec +commands = + bandit \ + -r shipyard_airflow \ + -x plugins/rest_api_plugin.py \ + -n 5 + +[testenv:genconfig] +commands = oslo-config-generator --config-file=generator/config-generator.conf + +[testenv:genpolicy] +commands = oslopolicy-sample-generator --config-file=generator/policy-generator.conf + +[testenv:gen_all] +# Combined to make these run together instead of setting up separately +commands = + oslo-config-generator --config-file=generator/config-generator.conf + oslopolicy-sample-generator --config-file=generator/policy-generator.conf + +[flake8] +filename = *.py +# NOTE(Bryan Strassner) ignoring F841 because of the airflow example pattern +# of naming variables even if they aren't used for DAGs and Operators. +# Doing so adds readability and context in this case. +# TODO(Bryan Strassner) The hacking rules defined as ignored below in many +# cases need to be un-ignored and fixed up. These are ignored because of +# the method in which test requirements bring in the hacking rules from +# other projects. +ignore = F841, H101, H201, H210, H238, H301, H304, H306, H401, H403, H404, H405 +# NOTE(Bryan Strassner) excluding 3rd party and generated code that is brought into the +# codebase. +exclude = .venv,.git,.tox,build,dist,*plugins/rest_api_plugin.py,*lib/python*,*egg,alembic/env.py,docs diff --git a/src/bin/shipyard_client/README.md b/src/bin/shipyard_client/README.md new file mode 100644 index 00000000..7b5fce2a --- /dev/null +++ b/src/bin/shipyard_client/README.md @@ -0,0 +1,17 @@ +# Shipyard Client +A CLI for using a deployed Shipyard API. + +Find more documentation for Shipyard on +[Read the Docs](http://shipyard.readthedocs.io/en/latest/) + + +## Getting Started: + +[Shipyard @ Gerrithub](https://review.gerrithub.io/#/q/project:att-comdev/shipyard) +\ +[Helm chart](https://github.com/att-comdev/aic-helm/tree/master/shipyard) + + +## See also: + +[Undercloud Platform (UCP)](https://github.com/att-comdev/ucp-integration) diff --git a/setup.py b/src/bin/shipyard_client/requirements.txt similarity index 79% rename from setup.py rename to src/bin/shipyard_client/requirements.txt index 0cbf35b6..1f6ac18d 100644 --- a/setup.py +++ b/src/bin/shipyard_client/requirements.txt @@ -11,9 +11,14 @@ # 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 setuptools -setuptools.setup( - setup_requires=['pbr>=2.0.0'], - pbr=True -) +# CLI/Client requirements + +arrow==0.10.0 +click==6.7 +click-default-group==1.2 +keystoneauth1==3.4.0 +requests==2.18.4 +setuptools==39.0.1 +PTable==0.9.2 +pyyaml==3.12 diff --git a/src/bin/shipyard_client/setup.py b/src/bin/shipyard_client/setup.py new file mode 100644 index 00000000..83954001 --- /dev/null +++ b/src/bin/shipyard_client/setup.py @@ -0,0 +1,37 @@ +# 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. +import setuptools + +setuptools.setup( + name='shipyard_client', + version='0.1a1', + description='CLI for Shipyard', + url='https://github.com/att-comdev/shipyard', + author='AT&T - AIC UCP Developers', + license='Apache 2.0', + packages=setuptools.find_packages(), + entry_points={ + 'console_scripts': + 'shipyard = shipyard_client.cli.commands:shipyard' + }, + classifiers=[ + 'Intended Audience :: Information Technology', + 'Intended Audience :: System Administrators', + 'License :: OSI Approved :: Apache Software License', + 'Operating System :: POSIX :: Linux', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.5', + ], +) diff --git a/shipyard_client/cli/get/__init__.py b/src/bin/shipyard_client/shipyard_client/__init__.py similarity index 100% rename from shipyard_client/cli/get/__init__.py rename to src/bin/shipyard_client/shipyard_client/__init__.py diff --git a/shipyard_client/cli/help/__init__.py b/src/bin/shipyard_client/shipyard_client/api_client/__init__.py similarity index 100% rename from shipyard_client/cli/help/__init__.py rename to src/bin/shipyard_client/shipyard_client/api_client/__init__.py diff --git a/shipyard_client/api_client/base_client.py b/src/bin/shipyard_client/shipyard_client/api_client/base_client.py similarity index 100% rename from shipyard_client/api_client/base_client.py rename to src/bin/shipyard_client/shipyard_client/api_client/base_client.py diff --git a/shipyard_client/api_client/client_error.py b/src/bin/shipyard_client/shipyard_client/api_client/client_error.py similarity index 100% rename from shipyard_client/api_client/client_error.py rename to src/bin/shipyard_client/shipyard_client/api_client/client_error.py diff --git a/shipyard_client/api_client/shipyard_api_client.py b/src/bin/shipyard_client/shipyard_client/api_client/shipyard_api_client.py similarity index 100% rename from shipyard_client/api_client/shipyard_api_client.py rename to src/bin/shipyard_client/shipyard_client/api_client/shipyard_api_client.py diff --git a/shipyard_client/api_client/shipyardclient_context.py b/src/bin/shipyard_client/shipyard_client/api_client/shipyardclient_context.py similarity index 100% rename from shipyard_client/api_client/shipyardclient_context.py rename to src/bin/shipyard_client/shipyard_client/api_client/shipyardclient_context.py diff --git a/shipyard_client/cli/logs/__init__.py b/src/bin/shipyard_client/shipyard_client/cli/__init__.py similarity index 100% rename from shipyard_client/cli/logs/__init__.py rename to src/bin/shipyard_client/shipyard_client/cli/__init__.py diff --git a/shipyard_client/cli/action.py b/src/bin/shipyard_client/shipyard_client/cli/action.py similarity index 100% rename from shipyard_client/cli/action.py rename to src/bin/shipyard_client/shipyard_client/cli/action.py diff --git a/shipyard_client/cli/cli_format_common.py b/src/bin/shipyard_client/shipyard_client/cli/cli_format_common.py similarity index 100% rename from shipyard_client/cli/cli_format_common.py rename to src/bin/shipyard_client/shipyard_client/cli/cli_format_common.py diff --git a/shipyard_client/cli/commands.py b/src/bin/shipyard_client/shipyard_client/cli/commands.py similarity index 100% rename from shipyard_client/cli/commands.py rename to src/bin/shipyard_client/shipyard_client/cli/commands.py diff --git a/shipyard_client/tests/__init__.py b/src/bin/shipyard_client/shipyard_client/cli/commit/__init__.py similarity index 100% rename from shipyard_client/tests/__init__.py rename to src/bin/shipyard_client/shipyard_client/cli/commit/__init__.py diff --git a/shipyard_client/cli/commit/actions.py b/src/bin/shipyard_client/shipyard_client/cli/commit/actions.py similarity index 100% rename from shipyard_client/cli/commit/actions.py rename to src/bin/shipyard_client/shipyard_client/cli/commit/actions.py diff --git a/shipyard_client/cli/commit/commands.py b/src/bin/shipyard_client/shipyard_client/cli/commit/commands.py similarity index 100% rename from shipyard_client/cli/commit/commands.py rename to src/bin/shipyard_client/shipyard_client/cli/commit/commands.py diff --git a/shipyard_client/tests/unit/__init__.py b/src/bin/shipyard_client/shipyard_client/cli/control/__init__.py similarity index 100% rename from shipyard_client/tests/unit/__init__.py rename to src/bin/shipyard_client/shipyard_client/cli/control/__init__.py diff --git a/shipyard_client/cli/control/actions.py b/src/bin/shipyard_client/shipyard_client/cli/control/actions.py similarity index 100% rename from shipyard_client/cli/control/actions.py rename to src/bin/shipyard_client/shipyard_client/cli/control/actions.py diff --git a/shipyard_client/cli/control/commands.py b/src/bin/shipyard_client/shipyard_client/cli/control/commands.py similarity index 100% rename from shipyard_client/cli/control/commands.py rename to src/bin/shipyard_client/shipyard_client/cli/control/commands.py diff --git a/shipyard_client/tests/unit/apiclient_test/__init__.py b/src/bin/shipyard_client/shipyard_client/cli/create/__init__.py similarity index 100% rename from shipyard_client/tests/unit/apiclient_test/__init__.py rename to src/bin/shipyard_client/shipyard_client/cli/create/__init__.py diff --git a/shipyard_client/cli/create/actions.py b/src/bin/shipyard_client/shipyard_client/cli/create/actions.py similarity index 100% rename from shipyard_client/cli/create/actions.py rename to src/bin/shipyard_client/shipyard_client/cli/create/actions.py diff --git a/shipyard_client/cli/create/commands.py b/src/bin/shipyard_client/shipyard_client/cli/create/commands.py similarity index 100% rename from shipyard_client/cli/create/commands.py rename to src/bin/shipyard_client/shipyard_client/cli/create/commands.py diff --git a/shipyard_client/tests/unit/cli/__init__.py b/src/bin/shipyard_client/shipyard_client/cli/describe/__init__.py similarity index 100% rename from shipyard_client/tests/unit/cli/__init__.py rename to src/bin/shipyard_client/shipyard_client/cli/describe/__init__.py diff --git a/shipyard_client/cli/describe/actions.py b/src/bin/shipyard_client/shipyard_client/cli/describe/actions.py similarity index 100% rename from shipyard_client/cli/describe/actions.py rename to src/bin/shipyard_client/shipyard_client/cli/describe/actions.py diff --git a/shipyard_client/cli/describe/commands.py b/src/bin/shipyard_client/shipyard_client/cli/describe/commands.py similarity index 100% rename from shipyard_client/cli/describe/commands.py rename to src/bin/shipyard_client/shipyard_client/cli/describe/commands.py diff --git a/shipyard_client/cli/format_utils.py b/src/bin/shipyard_client/shipyard_client/cli/format_utils.py similarity index 100% rename from shipyard_client/cli/format_utils.py rename to src/bin/shipyard_client/shipyard_client/cli/format_utils.py diff --git a/shipyard_client/tests/unit/cli/help/__init__.py b/src/bin/shipyard_client/shipyard_client/cli/get/__init__.py similarity index 100% rename from shipyard_client/tests/unit/cli/help/__init__.py rename to src/bin/shipyard_client/shipyard_client/cli/get/__init__.py diff --git a/shipyard_client/cli/get/actions.py b/src/bin/shipyard_client/shipyard_client/cli/get/actions.py similarity index 100% rename from shipyard_client/cli/get/actions.py rename to src/bin/shipyard_client/shipyard_client/cli/get/actions.py diff --git a/shipyard_client/cli/get/commands.py b/src/bin/shipyard_client/shipyard_client/cli/get/commands.py similarity index 100% rename from shipyard_client/cli/get/commands.py rename to src/bin/shipyard_client/shipyard_client/cli/get/commands.py diff --git a/tests/__init__.py b/src/bin/shipyard_client/shipyard_client/cli/help/__init__.py similarity index 100% rename from tests/__init__.py rename to src/bin/shipyard_client/shipyard_client/cli/help/__init__.py diff --git a/shipyard_client/cli/help/commands.py b/src/bin/shipyard_client/shipyard_client/cli/help/commands.py similarity index 100% rename from shipyard_client/cli/help/commands.py rename to src/bin/shipyard_client/shipyard_client/cli/help/commands.py diff --git a/shipyard_client/cli/help/output.py b/src/bin/shipyard_client/shipyard_client/cli/help/output.py similarity index 100% rename from shipyard_client/cli/help/output.py rename to src/bin/shipyard_client/shipyard_client/cli/help/output.py diff --git a/shipyard_client/cli/input_checks.py b/src/bin/shipyard_client/shipyard_client/cli/input_checks.py similarity index 100% rename from shipyard_client/cli/input_checks.py rename to src/bin/shipyard_client/shipyard_client/cli/input_checks.py diff --git a/tests/unit/__init__.py b/src/bin/shipyard_client/shipyard_client/cli/logs/__init__.py similarity index 100% rename from tests/unit/__init__.py rename to src/bin/shipyard_client/shipyard_client/cli/logs/__init__.py diff --git a/shipyard_client/cli/logs/actions.py b/src/bin/shipyard_client/shipyard_client/cli/logs/actions.py similarity index 100% rename from shipyard_client/cli/logs/actions.py rename to src/bin/shipyard_client/shipyard_client/cli/logs/actions.py diff --git a/shipyard_client/cli/logs/commands.py b/src/bin/shipyard_client/shipyard_client/cli/logs/commands.py similarity index 100% rename from shipyard_client/cli/logs/commands.py rename to src/bin/shipyard_client/shipyard_client/cli/logs/commands.py diff --git a/src/bin/shipyard_client/test-requirements.txt b/src/bin/shipyard_client/test-requirements.txt new file mode 100644 index 00000000..6d2b3412 --- /dev/null +++ b/src/bin/shipyard_client/test-requirements.txt @@ -0,0 +1,13 @@ +# Testing +pytest==3.2.1 +pytest-cov==2.5.1 +mock==2.0.0 +responses==0.8.1 +testfixtures==5.1.1 + +# Linting +flake8==3.3.0 + +# Security scanning +bandit>=1.1.0 # Apache-2.0 + diff --git a/tests/unit/control/af_monitoring/__init__.py b/src/bin/shipyard_client/tests/__init__.py similarity index 100% rename from tests/unit/control/af_monitoring/__init__.py rename to src/bin/shipyard_client/tests/__init__.py diff --git a/tests/unit/dags/__init__.py b/src/bin/shipyard_client/tests/unit/__init__.py similarity index 100% rename from tests/unit/dags/__init__.py rename to src/bin/shipyard_client/tests/unit/__init__.py diff --git a/tests/unit/plugins/__init__.py b/src/bin/shipyard_client/tests/unit/apiclient_test/__init__.py similarity index 100% rename from tests/unit/plugins/__init__.py rename to src/bin/shipyard_client/tests/unit/apiclient_test/__init__.py diff --git a/shipyard_client/tests/unit/apiclient_test/test_shipyard_api_client.py b/src/bin/shipyard_client/tests/unit/apiclient_test/test_shipyard_api_client.py similarity index 100% rename from shipyard_client/tests/unit/apiclient_test/test_shipyard_api_client.py rename to src/bin/shipyard_client/tests/unit/apiclient_test/test_shipyard_api_client.py diff --git a/tests/unit/schemas/__init__.py b/src/bin/shipyard_client/tests/unit/cli/__init__.py similarity index 100% rename from tests/unit/schemas/__init__.py rename to src/bin/shipyard_client/tests/unit/cli/__init__.py diff --git a/shipyard_client/tests/unit/cli/commit/test_commit_actions.py b/src/bin/shipyard_client/tests/unit/cli/commit/test_commit_actions.py similarity index 98% rename from shipyard_client/tests/unit/cli/commit/test_commit_actions.py rename to src/bin/shipyard_client/tests/unit/cli/commit/test_commit_actions.py index c11488da..f959a3c3 100644 --- a/shipyard_client/tests/unit/cli/commit/test_commit_actions.py +++ b/src/bin/shipyard_client/tests/unit/cli/commit/test_commit_actions.py @@ -17,7 +17,7 @@ import responses from shipyard_client.api_client.base_client import BaseClient from shipyard_client.cli.commit.actions import CommitConfigdocs -from shipyard_client.tests.unit.cli import stubs +from tests.unit.cli import stubs @responses.activate diff --git a/shipyard_client/tests/unit/cli/commit/test_commit_commands.py b/src/bin/shipyard_client/tests/unit/cli/commit/test_commit_commands.py similarity index 100% rename from shipyard_client/tests/unit/cli/commit/test_commit_commands.py rename to src/bin/shipyard_client/tests/unit/cli/commit/test_commit_commands.py diff --git a/shipyard_client/tests/unit/cli/control/test_control_actions.py b/src/bin/shipyard_client/tests/unit/cli/control/test_control_actions.py similarity index 98% rename from shipyard_client/tests/unit/cli/control/test_control_actions.py rename to src/bin/shipyard_client/tests/unit/cli/control/test_control_actions.py index e11d41da..63014c0c 100644 --- a/shipyard_client/tests/unit/cli/control/test_control_actions.py +++ b/src/bin/shipyard_client/tests/unit/cli/control/test_control_actions.py @@ -17,7 +17,7 @@ import responses from shipyard_client.api_client.base_client import BaseClient from shipyard_client.cli.control.actions import Control -from shipyard_client.tests.unit.cli import stubs +from tests.unit.cli import stubs @responses.activate diff --git a/shipyard_client/tests/unit/cli/control/test_control_commands.py b/src/bin/shipyard_client/tests/unit/cli/control/test_control_commands.py similarity index 100% rename from shipyard_client/tests/unit/cli/control/test_control_commands.py rename to src/bin/shipyard_client/tests/unit/cli/control/test_control_commands.py diff --git a/shipyard_client/tests/unit/cli/create/no_yaml_dir/placeholder.txt b/src/bin/shipyard_client/tests/unit/cli/create/no_yaml_dir/placeholder.txt similarity index 100% rename from shipyard_client/tests/unit/cli/create/no_yaml_dir/placeholder.txt rename to src/bin/shipyard_client/tests/unit/cli/create/no_yaml_dir/placeholder.txt diff --git a/shipyard_client/tests/unit/cli/create/sample_yaml/level1/level2/sample.yaml b/src/bin/shipyard_client/tests/unit/cli/create/sample_yaml/level1/level2/sample.yaml similarity index 100% rename from shipyard_client/tests/unit/cli/create/sample_yaml/level1/level2/sample.yaml rename to src/bin/shipyard_client/tests/unit/cli/create/sample_yaml/level1/level2/sample.yaml diff --git a/shipyard_client/tests/unit/cli/create/sample_yaml/level1/level2/sample2.yaml b/src/bin/shipyard_client/tests/unit/cli/create/sample_yaml/level1/level2/sample2.yaml similarity index 100% rename from shipyard_client/tests/unit/cli/create/sample_yaml/level1/level2/sample2.yaml rename to src/bin/shipyard_client/tests/unit/cli/create/sample_yaml/level1/level2/sample2.yaml diff --git a/shipyard_client/tests/unit/cli/create/sample_yaml/level1/sample.yaml b/src/bin/shipyard_client/tests/unit/cli/create/sample_yaml/level1/sample.yaml similarity index 100% rename from shipyard_client/tests/unit/cli/create/sample_yaml/level1/sample.yaml rename to src/bin/shipyard_client/tests/unit/cli/create/sample_yaml/level1/sample.yaml diff --git a/shipyard_client/tests/unit/cli/create/sample_yaml/level1/sample2.yaml b/src/bin/shipyard_client/tests/unit/cli/create/sample_yaml/level1/sample2.yaml similarity index 100% rename from shipyard_client/tests/unit/cli/create/sample_yaml/level1/sample2.yaml rename to src/bin/shipyard_client/tests/unit/cli/create/sample_yaml/level1/sample2.yaml diff --git a/shipyard_client/tests/unit/cli/create/sample_yaml/level_one/sample.yaml b/src/bin/shipyard_client/tests/unit/cli/create/sample_yaml/level_one/sample.yaml similarity index 100% rename from shipyard_client/tests/unit/cli/create/sample_yaml/level_one/sample.yaml rename to src/bin/shipyard_client/tests/unit/cli/create/sample_yaml/level_one/sample.yaml diff --git a/shipyard_client/tests/unit/cli/create/sample_yaml/level_one/sample2.yaml b/src/bin/shipyard_client/tests/unit/cli/create/sample_yaml/level_one/sample2.yaml similarity index 100% rename from shipyard_client/tests/unit/cli/create/sample_yaml/level_one/sample2.yaml rename to src/bin/shipyard_client/tests/unit/cli/create/sample_yaml/level_one/sample2.yaml diff --git a/shipyard_client/tests/unit/cli/create/sample_yaml/sample.yaml b/src/bin/shipyard_client/tests/unit/cli/create/sample_yaml/sample.yaml similarity index 100% rename from shipyard_client/tests/unit/cli/create/sample_yaml/sample.yaml rename to src/bin/shipyard_client/tests/unit/cli/create/sample_yaml/sample.yaml diff --git a/shipyard_client/tests/unit/cli/create/sample_yaml/sample2.yaml b/src/bin/shipyard_client/tests/unit/cli/create/sample_yaml/sample2.yaml similarity index 100% rename from shipyard_client/tests/unit/cli/create/sample_yaml/sample2.yaml rename to src/bin/shipyard_client/tests/unit/cli/create/sample_yaml/sample2.yaml diff --git a/shipyard_client/tests/unit/cli/create/sample_yaml0/sample.yaml b/src/bin/shipyard_client/tests/unit/cli/create/sample_yaml0/sample.yaml similarity index 100% rename from shipyard_client/tests/unit/cli/create/sample_yaml0/sample.yaml rename to src/bin/shipyard_client/tests/unit/cli/create/sample_yaml0/sample.yaml diff --git a/shipyard_client/tests/unit/cli/create/sample_yaml0/sample2.yaml b/src/bin/shipyard_client/tests/unit/cli/create/sample_yaml0/sample2.yaml similarity index 100% rename from shipyard_client/tests/unit/cli/create/sample_yaml0/sample2.yaml rename to src/bin/shipyard_client/tests/unit/cli/create/sample_yaml0/sample2.yaml diff --git a/shipyard_client/tests/unit/cli/create/test_create_actions.py b/src/bin/shipyard_client/tests/unit/cli/create/test_create_actions.py similarity index 95% rename from shipyard_client/tests/unit/cli/create/test_create_actions.py rename to src/bin/shipyard_client/tests/unit/cli/create/test_create_actions.py index 8685c29b..666d68dc 100644 --- a/shipyard_client/tests/unit/cli/create/test_create_actions.py +++ b/src/bin/shipyard_client/tests/unit/cli/create/test_create_actions.py @@ -20,7 +20,7 @@ import responses from shipyard_client.api_client.base_client import BaseClient from shipyard_client.cli.create.actions import CreateAction from shipyard_client.cli.create.actions import CreateConfigdocs -from shipyard_client.tests.unit.cli import stubs +from tests.unit.cli import stubs resp_body = """ { @@ -103,7 +103,7 @@ def test_create_configdocs(*args): body=succ_resp, status=201) - filename = 'shipyard_client/tests/unit/cli/create/sample_yaml/sample.yaml' + filename = 'tests/unit/cli/create/sample_yaml/sample.yaml' document_data = yaml.dump_all(filename) file_list = (filename,) @@ -132,7 +132,7 @@ def test_create_configdocs_201_with_val_fails(*args): body=succ_resp, status=201) - filename = 'shipyard_client/tests/unit/cli/create/sample_yaml/sample.yaml' + filename = 'tests/unit/cli/create/sample_yaml/sample.yaml' document_data = yaml.dump_all(filename) file_list = (filename,) @@ -162,7 +162,7 @@ def test_create_configdocs_409(*args): body=err_resp, status=409) - filename = 'shipyard_client/tests/unit/cli/create/sample_yaml/sample.yaml' + filename = 'tests/unit/cli/create/sample_yaml/sample.yaml' document_data = yaml.dump_all(filename) file_list = (filename,) diff --git a/shipyard_client/tests/unit/cli/create/test_create_commands.py b/src/bin/shipyard_client/tests/unit/cli/create/test_create_commands.py similarity index 91% rename from shipyard_client/tests/unit/cli/create/test_create_commands.py rename to src/bin/shipyard_client/tests/unit/cli/create/test_create_commands.py index c6fd8636..b8e50828 100644 --- a/shipyard_client/tests/unit/cli/create/test_create_commands.py +++ b/src/bin/shipyard_client/tests/unit/cli/create/test_create_commands.py @@ -56,7 +56,7 @@ def test_create_configdocs(): """test create configdocs with filename""" collection = 'design' - filename = 'shipyard_client/tests/unit/cli/create/sample_yaml/sample.yaml' + filename = 'tests/unit/cli/create/sample_yaml/sample.yaml' append = 'append' file_list = (filename,) runner = CliRunner() @@ -73,7 +73,7 @@ def test_create_configdocs_directory(): """test create configdocs with directory""" collection = 'design' - directory = 'shipyard_client/tests/unit/cli/create/sample_yaml' + directory = 'tests/unit/cli/create/sample_yaml' append = 'append' runner = CliRunner() with patch.object(CreateConfigdocs, '__init__') as mock_method: @@ -88,7 +88,7 @@ def test_create_configdocs_directory_empty(): """test create configdocs with empty directory""" collection = 'design' - dir1 = 'shipyard_client/tests/unit/cli/create/no_yaml_dir/' + dir1 = 'tests/unit/cli/create/no_yaml_dir/' runner = CliRunner() with patch.object(CreateConfigdocs, 'invoke_and_return_resp') as _method: @@ -104,8 +104,8 @@ def test_create_configdocs_multi_directory(): """test create configdocs with multiple directories""" collection = 'design' - dir1 = 'shipyard_client/tests/unit/cli/create/sample_yaml/' - dir2 = 'shipyard_client/tests/unit/cli/create/sample_yaml0/' + dir1 = 'tests/unit/cli/create/sample_yaml/' + dir2 = 'tests/unit/cli/create/sample_yaml0/' append = 'append' runner = CliRunner() with patch.object(CreateConfigdocs, '__init__') as mock_method: @@ -120,8 +120,8 @@ def test_create_configdocs_multi_directory_recurse(): """test create configdocs with multiple directories""" collection = 'design' - dir1 = 'shipyard_client/tests/unit/cli/create/sample_yaml/' - dir2 = 'shipyard_client/tests/unit/cli/create/sample_yaml0/' + dir1 = 'tests/unit/cli/create/sample_yaml/' + dir2 = 'tests/unit/cli/create/sample_yaml0/' append = 'append' runner = CliRunner() with patch.object(CreateConfigdocs, '__init__') as mock_method: diff --git a/shipyard_client/tests/unit/cli/describe/test_describe_actions.py b/src/bin/shipyard_client/tests/unit/cli/describe/test_describe_actions.py similarity index 99% rename from shipyard_client/tests/unit/cli/describe/test_describe_actions.py rename to src/bin/shipyard_client/tests/unit/cli/describe/test_describe_actions.py index cf9d7800..c9b414dc 100644 --- a/shipyard_client/tests/unit/cli/describe/test_describe_actions.py +++ b/src/bin/shipyard_client/tests/unit/cli/describe/test_describe_actions.py @@ -20,7 +20,7 @@ from shipyard_client.cli.describe.actions import DescribeAction from shipyard_client.cli.describe.actions import DescribeStep from shipyard_client.cli.describe.actions import DescribeValidation from shipyard_client.cli.describe.actions import DescribeWorkflow -from shipyard_client.tests.unit.cli import stubs +from tests.unit.cli import stubs GET_ACTION_API_RESP = """ diff --git a/shipyard_client/tests/unit/cli/describe/test_describe_commands.py b/src/bin/shipyard_client/tests/unit/cli/describe/test_describe_commands.py similarity index 100% rename from shipyard_client/tests/unit/cli/describe/test_describe_commands.py rename to src/bin/shipyard_client/tests/unit/cli/describe/test_describe_commands.py diff --git a/shipyard_client/tests/unit/cli/get/test_get_actions.py b/src/bin/shipyard_client/tests/unit/cli/get/test_get_actions.py similarity index 99% rename from shipyard_client/tests/unit/cli/get/test_get_actions.py rename to src/bin/shipyard_client/tests/unit/cli/get/test_get_actions.py index a07be396..d3b278e1 100644 --- a/shipyard_client/tests/unit/cli/get/test_get_actions.py +++ b/src/bin/shipyard_client/tests/unit/cli/get/test_get_actions.py @@ -24,7 +24,7 @@ from shipyard_client.cli.get.actions import GetConfigdocs from shipyard_client.cli.get.actions import GetConfigdocsStatus from shipyard_client.cli.get.actions import GetRenderedConfigdocs from shipyard_client.cli.get.actions import GetWorkflows -from shipyard_client.tests.unit.cli import stubs +from tests.unit.cli import stubs GET_ACTIONS_API_RESP = """ [ diff --git a/shipyard_client/tests/unit/cli/get/test_get_commands.py b/src/bin/shipyard_client/tests/unit/cli/get/test_get_commands.py similarity index 100% rename from shipyard_client/tests/unit/cli/get/test_get_commands.py rename to src/bin/shipyard_client/tests/unit/cli/get/test_get_commands.py diff --git a/src/bin/shipyard_client/tests/unit/cli/help/__init__.py b/src/bin/shipyard_client/tests/unit/cli/help/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/shipyard_client/tests/unit/cli/help/test_help_commands.py b/src/bin/shipyard_client/tests/unit/cli/help/test_help_commands.py similarity index 100% rename from shipyard_client/tests/unit/cli/help/test_help_commands.py rename to src/bin/shipyard_client/tests/unit/cli/help/test_help_commands.py diff --git a/shipyard_client/tests/unit/cli/replace_api_client.py b/src/bin/shipyard_client/tests/unit/cli/replace_api_client.py similarity index 100% rename from shipyard_client/tests/unit/cli/replace_api_client.py rename to src/bin/shipyard_client/tests/unit/cli/replace_api_client.py diff --git a/shipyard_client/tests/unit/cli/stubs.py b/src/bin/shipyard_client/tests/unit/cli/stubs.py similarity index 100% rename from shipyard_client/tests/unit/cli/stubs.py rename to src/bin/shipyard_client/tests/unit/cli/stubs.py diff --git a/shipyard_client/tests/unit/cli/test_auth_validations.py b/src/bin/shipyard_client/tests/unit/cli/test_auth_validations.py similarity index 97% rename from shipyard_client/tests/unit/cli/test_auth_validations.py rename to src/bin/shipyard_client/tests/unit/cli/test_auth_validations.py index ab8ab147..728700eb 100644 --- a/shipyard_client/tests/unit/cli/test_auth_validations.py +++ b/src/bin/shipyard_client/tests/unit/cli/test_auth_validations.py @@ -14,7 +14,7 @@ import pytest from shipyard_client.cli.action import AuthValuesError -from shipyard_client.tests.unit.cli import stubs +from tests.unit.cli import stubs def test_validate_auth_vars_valid(): diff --git a/shipyard_client/tests/unit/cli/test_format_utils.py b/src/bin/shipyard_client/tests/unit/cli/test_format_utils.py similarity index 100% rename from shipyard_client/tests/unit/cli/test_format_utils.py rename to src/bin/shipyard_client/tests/unit/cli/test_format_utils.py diff --git a/shipyard_client/tests/unit/cli/test_input_checks.py b/src/bin/shipyard_client/tests/unit/cli/test_input_checks.py similarity index 100% rename from shipyard_client/tests/unit/cli/test_input_checks.py rename to src/bin/shipyard_client/tests/unit/cli/test_input_checks.py diff --git a/shipyard_client/tests/unit/cli/test_shipyard_commands.py b/src/bin/shipyard_client/tests/unit/cli/test_shipyard_commands.py similarity index 100% rename from shipyard_client/tests/unit/cli/test_shipyard_commands.py rename to src/bin/shipyard_client/tests/unit/cli/test_shipyard_commands.py diff --git a/shipyard_client/tests/unit/cli/utils.py b/src/bin/shipyard_client/tests/unit/cli/utils.py similarity index 100% rename from shipyard_client/tests/unit/cli/utils.py rename to src/bin/shipyard_client/tests/unit/cli/utils.py diff --git a/src/bin/shipyard_client/tox.ini b/src/bin/shipyard_client/tox.ini new file mode 100644 index 00000000..03cf1ff8 --- /dev/null +++ b/src/bin/shipyard_client/tox.ini @@ -0,0 +1,34 @@ +[tox] +skipsdist=True +envlist = unit, pep8, bandit + +[testenv] +setenv= + PYTHONWARNING=all +basepython=python3.5 +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + +[testenv:unit] +commands = + pytest \ + {posargs} \ + --cov-branch \ + --cov-report=term-missing:skip-covered \ + --cov-config=.coveragerc \ + --cov=shipyard_client \ + --cov-report=html + +[testenv:pep8] +commands = flake8 {posargs} + +[testenv:bandit] +commands = + bandit \ + -r shipyard_client \ + -n 5 + +[flake8] +filename = *.py +ignore = F841 +exclude = .venv,.git,.tox,build,dist,*lib/python*,*egg,docs diff --git a/tools/shipyard_image_run.sh b/tools/shipyard_image_run.sh index b27f8bb2..d04e6f8c 100755 --- a/tools/shipyard_image_run.sh +++ b/tools/shipyard_image_run.sh @@ -31,12 +31,14 @@ sleep 5 RESULT="$(curl -i 'http://127.0.0.1:9000/versions' | tr '\r' '\n' | head -1)" +CLI_RESULT="$(docker run -t --rm --net=host ${IMAGE} help | tr '\r' '\n' | head -1)" + docker stop shipyard_test docker rm shipyard_test rm -r build/.tmprun - GOOD="HTTP/1.1 200 OK" -if [[ ${RESULT} == ${GOOD} ]]; then +CLI_GOOD="THE SHIPYARD COMMAND" +if [[ ${RESULT} == ${GOOD} && ${CLI_RESULT} == ${CLI_GOOD} ]]; then exit 0 else exit 1 diff --git a/tox.ini b/tox.ini index f57ef260..152815f2 100644 --- a/tox.ini +++ b/tox.ini @@ -1,62 +1,31 @@ [tox] -envlist = unit, pep8, coverage, bandit, docs +skipsdist=True +envlist = all_jobs, docs [testenv] setenv= PYTHONWARNING=all basepython=python3.5 -deps = -r{toxinidir}/requirements.txt - -r{toxinidir}/test-requirements.txt - -[testenv:unit] -commands = - pytest \ - {posargs} - -[testenv:pep8] -commands = flake8 {posargs} - -[testenv:bandit] -# NOTE(Bryan Strassner) ignoring airflow plugin which uses a subexec -commands = - bandit \ - -r shipyard_airflow shipyard_client \ - -x plugins/rest_api_plugin.py,shipyard_client/tests \ - -n 5 - -[testenv:genconfig] -commands = oslo-config-generator --config-file=generator/config-generator.conf - -[testenv:genpolicy] -commands = oslopolicy-sample-generator --config-file=generator/policy-generator.conf - -[flake8] -filename = *.py -# NOTE(Bryan Strassner) ignoring F841 because of the airflow example pattern -# of naming variables even if they aren't used for DAGs and Operators. -# Doing so adds readability and context in this case. -# TODO(Bryan Strassner) The hacking rules defined as ignored below in many -# cases need to be un-ignored and fixed up. These are ignored because of -# the method in which test requirements bring in the hacking rules from -# other projects. -ignore = F841, H101, H201, H210, H238, H301, H304, H306, H401, H403, H404, H405 -# NOTE(Bryan Strassner) excluding 3rd party and generated code that is brought into the -# codebase. -exclude = .venv,.git,.tox,build,dist,*plugins/rest_api_plugin.py,*lib/python*,*egg,alembic/env.py,docs +# Please use `make docs` instead [testenv:docs] -whitelist_externals=rm -commands = - rm -rf docs/build - python setup.py build_sphinx {posargs} +whitelist_externals= + rm + cp + tox +commands= + tox -c {toxinidir}/src/bin/shipyard_airflow/tox.ini -e gen_all + cp {toxinidir}/src/bin/shipyard_airflow/etc/shipyard/policy.yaml.sample {toxinidir}/docs/source/_static/shipyard.policy.yaml.sample + cp {toxinidir}/src/bin/shipyard_airflow/etc/shipyard/shipyard.conf.sample {toxinidir}/docs/source/_static/shipyard.conf.sample + rm -rf {toxinidir}/docs/build + sphinx-build -b html {toxinidir}/docs/source {toxinidir}/docs/build +deps= -r{toxinidir}/docs/requirements.txt -[testenv:coverage] -commands = - pytest \ - {posargs} \ - --cov-branch \ - --cov-report=term-missing:skip-covered \ - --cov-config=.coveragerc \ - --cov=shipyard_airflow \ - --cov=shipyard_client \ - --cov-report=html +# `all_jobs` is here to support invocation as simply `tox`, as is done in +# current pipeline. +[testenv:all_jobs] +whitelist_externals= + tox +commands= + tox -c {toxinidir}/src/bin/shipyard_airflow/tox.ini + tox -c {toxinidir}/src/bin/shipyard_client/tox.ini