1 # Python/Linux Distribution Notes
3 *Updated: 10 Nov 2017 23:30 GMT*
5 This document exists to help bridge the gap between the Conductor python package and any downstream distribution. The steps outlined herein may be taken into consideration when creating an AT&T SWM package, Ubuntu/Debian package, Chef cookbook, or Ansible playbook.
9 Conductor consists of five services that work together:
11 * **``conductor-api``**: An HTTP REST API
12 * **``conductor-controller``**: Validation, translation, and status/results
13 * **``conductor-data``**: Inventory provider and service controller gateway
14 * **``conductor-solver``**: Processing and solution calculation
15 * **``conductor-reservation``**: Reserves the suggested solution solved by Solver component.
19 * Deployment **plans** are created, viewed, and deleted via ``conductor-api`` and its [REST API](doc/api/README.md).
20 * Included within each ``conductor-api`` plan request is a [Homing Template](doc/template/README.md).
21 * Homing Templates describe a set of inventory demands and constraints to be solved against.
22 * ``conductor-api`` hands off all API requests to ``conductor-controller`` for handling.
23 * All deployment plans are assigned a unique identifier (UUID-4), which can be used to check for solution status asynchronously. (Conductor does not support callbacks at this time.)
24 * ``conductor-controller`` ensures templates are well-formed and valid. Errors and remediation are made visible through ``conductor-api``. When running in debug mode, the API will also include a python traceback in the response body, if available.
25 * ``conductor-controller`` uses ``conductor-data`` to resolve demands against a particular **inventory provider** (e.g., A&AI).
26 * ``conductor-controller`` translates the template into a format suitable for solving.
27 * As each template is translated, ``conductor-solver`` begins working on it.
28 * ``conductor-solver`` uses ``conductor-data`` to resolve constraints against a particular **service controller** (e.g., SDN-C).
29 * ``conductor-solver`` determines the most suitable inventory to recommend.
30 * ``conductor-reservation`` attempts to reserve the solved solution in SDN-GC
32 **NOTE**: There is no Command Line Interface or Python API Library at this time.
34 ## Pre-Flight and Pre-Installation Considerations
36 ### AT&T Application Identifiers and Roles
38 * App/Tool Name: ECOMP Conductor
39 * MOTS Application ID: 26213
41 * ECOMP Feature ID: F13704
43 * UAM Role Name: Conductor Production Support
44 * UAM Role id: 0000025248
48 Be aware that some commands may require ``sudo``, depending on the account being used to perform the installation.
52 If line-of-sight to internet-facing repositories is permitted and available, set the following shell environment variables if AT&T proxy services are required:
55 $ export http_proxy="http://one.proxy.att.com:8080/"
56 $ export https_proxy="http://one.proxy.att.com:8080/"
61 Conductor is officially supported on [Ubuntu 14.04 LTS (Trusty Tahr)](http://releases.ubuntu.com/14.04/), though it should also work on newer releases.
63 Ensure the following Ubuntu packages are present, as they may not be included by default:
65 * [libffi-dev](http://packages.ubuntu.com/trusty/libffi-dev)
66 * [postgresql-server-dev-9.3](http://packages.ubuntu.com/trusty/postgresql-server-dev-9.3)
67 * [python2.7](http://packages.ubuntu.com/trusty/python2.7)
69 ``conductor-api`` may be run as-is for development and test purposes. When used in a production environment, it is recommended that ``conductor-api`` run under a multithreaded httpd service supporting [WSGI](https://www.wikipedia.org/wiki/Web_Server_Gateway_Interface), tuned as appropriate.
71 Configuration instructions for **apache2 httpd** and **nginx** are included herein. Respective package requirements are:
73 * [apache2](http://packages.ubuntu.com/trusty/apache2) and [libapache2-mod-wsgi](http://packages.ubuntu.com/trusty/libapache2-mod-wsgi)
74 * [nginx](http://packages.ubuntu.com/trusty/nginx) and [uwsgi](http://packages.ubuntu.com/trusty/uwsgi)
76 All Conductor services use AT&T [Music](https://github.com/att/music) for data storage/persistence and/or as a RPC transport mechanism. Consult the [Music Local Installation Guide](https://github.com/att/music/blob/master/README.md) for installation/configuration steps.
80 All conductor services require line-of-sight access to all Music servers/ports.
82 The ``conductor-api`` service uses TCP port 8091.
86 ``conductor-api`` is accessed via HTTP. SSL/TLS certificates and AuthN/AuthZ (e.g., AAF) are not supported at this time.
88 Conductor makes use of plugins that act as gateways to *inventory providers* and *service controllers*. At present, two plugins are supported out-of-the-box: **A&AI** and **SDN-C**, respectively.
90 A&AI requires two-way SSL/TLS. Certificates must be registered and whitelisted with A&AI. SDN-C uses HTTP Basic Authentication. Consult with each respective service for official information on how to obtain access.
94 For a cloud environment in particular, it may be desirable to use a separate block storage device (e.g., an OpenStack Cinder volume) for logs, configuration, and other data persistence. In this way, it becomes a trivial matter to replace the entire VM if necessary, followed by reinstallation of the app and any supplemental configuration. Take this into consideration when setting various Conductor config options.
96 ### Python Virtual Environments
98 At present, Conductor installation is only supported at the (upstream) python package level and not the (downstream) Ubuntu distribution or SWM package levels.
100 To mitigate/eliminate the risk of introducing conflicts with other python applications or Ubuntu/SWM package dependencies, consider installing Conductor in a [python virtual environment](http://docs.python-guide.org/en/latest/dev/virtualenvs/) (or *venv* for short).
102 Example venv-aware WSGI app configurations, sysvinit scripts, and upstart scripts can be found in the Conductor repository under [examples](/examples/).
104 ### Python Package Dependencies
106 Conductor is installed using the python ``pip`` command. ``pip`` uses a python project's [requirements manifest](/requirements.txt) to install all python module dependencies.
108 **NOTE**: When line-of-sight access to a PyPI-compatible package index is not available, advance installation of Conductor's python package dependencies is required *before* installation.
110 ### Other Production Environment Considerations
114 Over time, considerations may include services such as:
123 ## Installation and Configuration
125 **IMPORTANT**: Perform the steps in this section after *optionally* configuring and activating a python virtual environment.
127 ### Installing From a PyPI Repository
129 In ONAP, the ``conductor`` package can be found on ````.
131 Installation is via the ``pip`` command. Here is an example ``pip.conf`` file that uses both the internet and intranet-facing PyPI repositories:
135 index = https://pypi.python.org/pypi
136 index-url = https://pypi.python.org/simple
141 Once the configuration is in place, installation is simple:
144 $ pip install ecomp-conductor
147 To upgrade or downgrade, simply re-run ``pip install`` using the appropriate ``pip`` command line options.
149 **NOTE**: Be sure proxy settings are in place if they're required to access ``pypi.python.org``.
151 ### Installing From Source
153 Conductor source in ONAP is maintained in https://gerrit.onap.org/r/optf/has.
155 Clone the git repository, and then install from within the ``conductor`` directory:
158 $ git clone https://gerrit.onap.org/r/optf/has
159 Cloning into 'conductor'...
160 remote: Counting objects: 2291, done.
161 remote: Compressing objects: 88% (1918/2179)
162 remote: Compressing objects: 100% (2179/2179), done.
163 remote: Total 2291 (delta 1422), reused 0 (delta 0)
164 Receiving objects: 100% (2291/2291), 477.59 KiB | 0 bytes/s, done.
165 Resolving deltas: 100% (1422/1422), done.
170 The latest source can be pulled from ONAP at any time and reinstalled:
177 ### Verifying Installation
179 Each of the five Conductor services may be invoked with the ``--help`` option:
182 $ conductor-api -- --help
183 $ conductor-controller --help
184 $ conductor-data --help
185 $ conductor-solver --help
186 $ conductor-reservation --help
189 **NOTE**: The ``conductor-api`` command is deliberate. ``--`` is used as as separator between the arguments used to start the WSGI server and the arguments passed to the WSGI application.
191 ## Post-Flight and Post-Installation Considerations
195 It's good practice to create an unprivileged account (e.g., a user/group named ``conductor``) and run all Conductor services as that user:
198 $ sudo addgroup --system conductor
199 $ sudo adduser --system --home /var/lib/conductor --ingroup conductor --no-create-home --shell /bin/false conductor
202 ### SSL/TLS Certificates
204 The A&AI Inventory Provider Plugin requiries two-way SSL/TLS. After provisioning a certificate per A&AI guidelines, it will be necessary to securely install the certificate, key, and certificate authority bundle.
206 When running conductor services as ``conductor:conductor`` (recommended), consider co-locating all of these files under the configuration directory. For example, when using ``/etc/conductor``:
209 $ # Certificate files (crt extension, 644 permissions)
210 $ sudo mkdir /etc/conductor/ssl/certs
211 $ # Private Certificate Key files (key extension, 640 permissions)
212 $ sudo mkdir /etc/conductor/ssl/private
213 $ # Certificate Authority (CA) Bundles (crt extension, 644 permissions)
214 $ sudo mkdir /etc/conductor/ssl/ca-certificates
215 $ # Add files to newly created directories, then set ownership
216 $ sudo chmod -R conductor:conductor /etc/conductor/ssl
219 For a hypothetical domain name ``imacculate.client.research.att.com``, example filenames could be as follows:
222 $ find ssl -type f -printf '%M %u:%g %f\n'
223 -rw-r----- conductor:conductor imacculate.client.research.att.com.key
224 -rw-r--r-- conductor:conductor Symantec_Class_3_Secure_Server_CA.crt
225 -rw-r--r-- conductor:conductor imacculate.client.research.att.com.crt
228 When running conductor services as ``root``, consider these existing Ubuntu filesystem locations for SSL/TLS files:
230 **Certificate** files (``crt`` extension) are typically stored in ``/etc/ssl/certs`` with ``root:root`` ownership and 644 permissions.
232 **Private Certificate Key** files (``key`` extension) are typically stored in ``/etc/ssl/private`` with ``root:root`` ownership and 640 permissions.
234 **Certificate Authority (CA) Bundles** (``crt`` extension) are typically stored in ``/usr/share/ca-certificates/conductor`` with ``root:root`` ownership, and 644 permissions. These Bundle files are then symlinked within ``/etc/ssl/certs`` using equivalent filenames, a ``pem`` extension, and ``root:root`` ownership.
236 **NOTE**: LUKS (Linux Unified Key Setup) is not supported by Conductor at this time.
240 Configuration files are located in ``etc/conductor`` relative to the python environment Conductor is installed in.
242 To generate a sample configuration file, change to the directory just above where ``etc/conductor`` is located (e.g., `/` for the default environment, or the virtual environment root directory). Then:
245 $ oslo-config-generator --config-file=etc/conductor/conductor-config-generator.conf
248 This will generate ``etc/conductor/conductor.conf.sample``.
250 Because the configuration directory and files will include credentials, consider removing world permissions:
253 $ find etc/conductor -type f -exec chmod 640 {} +
254 $ find etc/conductor -type d -exec chmod 750 {} +
257 The sample config may then be copied and edited. Be sure to backup any previous ``conductor.conf`` if necessary.
261 $ cp -p conductor.conf.sample conductor.conf
264 ``conductor.conf`` is fully annotated with descriptions of all options. Defaults are included, with all options commented out. Conductor will use defaults even if an option is not present in the file. To change an option, simply uncomment it and edit its value.
266 With the exception of the ``DEFAULT`` section, it's best to restart the Conductor services after making any config changes. In some cases, only one particular service actually needs to be restarted. When in doubt, however, it's best to restart all of them.
268 A few options in particular warrant special attention:
273 # If set to true, the logging level will be set to DEBUG instead of the default
274 # INFO level. (boolean value)
275 # Note: This option can be changed without restarting.
279 For more verbose logging across all Conductor services, set ``debug`` to true.
284 # Base URL for A&AI, up to and not including the version, and without a
285 # trailing slash. (string value)
286 #server_url = https://controller:8443/aai
288 # SSL/TLS certificate file in pem format. This certificate must be registered
289 # with the A&AI endpoint. (string value)
290 #certificate_file = certificate.pem
292 # Private Certificate Key file in pem format. (string value)
293 #certificate_key_file = certificate_key.pem
295 # Certificate Authority Bundle file in pem format. Must contain the appropriate
296 # trust chain for the Certificate file. (string value)
297 #certificate_authority_bundle_file = certificate_authority_bundle.pem
300 Set ``server_url`` to the A&AI server URL, to but not including the version, omitting any trailing slash. Conductor supports A&AI API v9 at a minimum.
302 Set the ``certificate`` prefixed keys to the appropriate SSL/TLS-related files.
304 **IMPORTANT**: The A&AI server may have a mismatched host/domain name and SSL/TLS certificate. In such cases, certificate verification will fail. To mitigate this, ``certificate_authority_bundle_file`` may be set to an empty value. While Conductor normally requires a CA Bundle (otherwise why bother using SSL/TLS), this requirement has been temporarily relaxed so that development and testing may continue.
309 # Log debug messages. Default value is False. (boolean value)
313 When the ``DEFAULT`` section's ``debug`` option is ``true``, set this section's ``debug`` option to ``true`` to enable detailed Conductor-side RPC-over-Music debug messages.
315 Be aware, it is voluminous. "You have been warned." ``:)``
320 # List of hostnames (round-robin access) (list value)
321 #hostnames = localhost
323 # Log debug messages. Default value is False. (boolean value)
327 Set ``hostnames`` to match wherever the Music REST API is being hosted (wherever Apache Tomcat and ``MUSIC.war`` are located).
329 When the ``DEFAULT`` section's ``debug`` option is ``true``, set this section's ``debug`` option to ``true`` to enable detailed Conductor-side MUSIC API debug messages.
331 The previous comment around the volume of log lines applies even more so here. (Srsly. We're not kidding.)
333 **IMPORTANT**: Conductor does not presently use Music's atomic consistency features due to concern around lock creation/acquisition. Instead, Conductor uses eventual consistency. For this reason, consistency issues may occur when using Music in a multi-server, High Availability configuration.
338 # Base URL for SDN-C. (string value)
339 #server_url = https://controller:8443/restconf
341 # Basic Authentication Username (string value)
344 # Basic Authentication Password (string value)
349 Set ``server_url`` to the SDN-C server URL, omitting any trailing slash.
351 Set ``username`` and ``password`` to the appropriate values as directed by SDN-C.
353 ### Running for the First Time
355 Each Conductor component may be run interactively. In this case, the user does not necessarily matter.
357 When running interactively, it is suggested to run each command in a separate terminal session and in the following order:
360 conductor-data --config-file=/etc/conductor/conductor.conf
361 conductor-controller --config-file=/etc/conductor/conductor.conf
362 conductor-solver --config-file=/etc/conductor/conductor.conf
363 conductor-reservation --config-file=/etc/conductor/conductor.conf
364 conductor-api --port=8091 -- --config-file=/etc/conductor/conductor.conf
367 Optionally, use an application like [screen](http://packages.ubuntu.com/trusty/screen) to nest all five terminal sessions within one detachable session. (This is also the same package used by [DevStack](https://docs.openstack.org/developer/devstack/).)
369 To verify that ``conductor-api`` can be reached, browse to ``http://HOST:8091/``, where HOST is the hostname ``conductor-api`` is running on. No AuthN/AuthZ is required at this time. Depending on network considerations, it may be necessary to use a command like ``wget`` instead of a desktop browser.
371 The response should look similar to:
378 "status": "development",
379 "updated": "2016-11-01T00:00:00Z",
382 "base": "application/json",
383 "type": "application/vnd.ecomp.homing-v1+json"
389 "href": "http://127.0.0.1:8091/v1",
393 "href": "http://conductor.research.att.com/",
404 ### Sample API Calls and Homing Templates
406 A [Postman](http://getpostman.com/) collection illustrating sample requests is available upon request. The collection will also be added in a future revision.
408 [Sample homing templates](/doc/examples/README.md) are also available.
410 ### Ubuntu Service Scripts
412 Ubuntu sysvinit (init.d) and upstart (init) scripts are typically installed at the Ubuntu package level. Since there is no such packaging at this time, example scripts have been provided in the repository.
414 To install, place all Conductor [sysvinit scripts](/examples/distribution/ubuntu/init.d) in ``/etc/init.d``, and all [upstart scripts](/examples/distribution/ubuntu/init) in ``/etc/init``.
416 Set file permissions:
419 $ sudo chmod 644 /etc/init/conductor*
420 $ sudo chmod 755 /etc/init.d/conductor*
423 If a python virtual environment is being used, edit each ``/etc/init/conductor*`` and ``/etc/init.d/conductor*`` prefixed file so that ``PYTHON_HOME`` is set to the python virtual environment root directory.
425 Next, enable the scripts:
428 $ sudo update-rc.d conductor-api defaults
429 $ sudo update-rc.d conductor-controller defaults
430 $ sudo update-rc.d conductor-data defaults
431 $ sudo update-rc.d conductor-solver defaults
432 $ sudo update-rc.d conductor-reservation defaults
433 $ sudo initctl reload-configuration
436 Conductor components may now be started/stopped like any other Ubuntu service, for example:
439 $ sudo service conductor-api start
440 $ sudo service conductor-api status
441 $ sudo service conductor-api restart
442 $ sudo service conductor-api stop
445 Conductor service scripts automatically create directories for ``log``, ``lock``, ``run``, ``lib``, and ``log`` files, e.g., ``/var/log/conductor`` and so on.
447 ### Log File Rotation
449 Sample ``logrotate.d`` configuration files have been provided in the repository.
451 To install, place all Conductor [logrotate files](/examples/distribution/ubuntu/logrotate.d) in ``/etc/logrotate.d``.
453 Set file ownership and permissions:
456 $ sudo chown root:root /etc/logrotate.d/conductor*
457 $ sudo chmod 644 /etc/logrotate.d/conductor*
460 ``logrotate.d`` automatically recognizes new files at the next log rotation opportunity and does not require restarting.
462 ## Running conductor-api Under apache2 httpd and mod_wsgi
464 Sample configuration files have been provided in the repository.
466 These instructions presume a ``conductor`` user exists. See the **Service Scripts** section for details.
468 First, set up a few directories:
471 $ sudo mkdir -p /var/www/conductor
472 $ sudo mkdir /var/log/apache2/conductor
475 To install, place the Conductor [WSGI application file](/conductor/api/app.wsgi) in ``/var/www/conductor``.
477 Set the owner/group of both directories/files to ``conductor``:
480 $ sudo chown -R conductor:conductor /var/log/apache2/conductor /var/www/conductor
483 Next, place the Conductor [apache2 httpd site config file](/examples/apache2/conductor.conf) in ``/etc/apache2/sites-available``.
485 Set the owner/group to ``root``:
488 $ sudo chown -R root:root /etc/apache2/sites-available/conductor.conf
491 If Conductor was installed in a python virtual environment, append ``python-home=VENV`` to ``WSGIDaemonProcess``, where ``VENV`` is the python virtual environment root directory.
493 **IMPORTANT**: Before proceeding, disable the ``conductor-api`` sysvinit and upstart services, as the REST API will now be handled by apache2 httpd. Otherwise there will be a port conflict, and you will be sad.
495 Enable the Conductor site, ensure the configuration syntax is valid, and gracefully restart apache2 httpd.
498 $ sudo a2ensite conductor
501 $ sudo apachectl graceful
504 To disable the Conductor site, run ``sudo a2dissite conductor``, then gracefully restart once again. Optionally, re-enable the ``conductor-api`` sysvinit and upstart services.
506 ## Running conductor-api Under nginx and uWSGI
508 Sample configuration files have been provided in the repository.
510 These instructions presume a ``conductor`` user exists. See the **Service Scripts** section for details.
512 To install, place the Conductor [nginx config files](/examples/nginx/) and [WSGI application file](/conductor/api/app.wsgi) in ``/etc/nginx`` (taking care to backup any prior configuration files). It may be desirable to incorporate Conductor's ``nginx.conf`` into the existing config.
514 Rename ``app.wsgi`` to ``conductor.wsgi``:
518 $ sudo mv app.wsgi conductor.wsgi
521 In ``nginx.conf``, set ``CONDUCTOR_API_FQDN`` to the server name.
523 **IMPORTANT**: Before proceeding, disable the ``conductor-api`` sysvinit and upstart services, as the REST API will now be handled by nginx. Otherwise there will be a port conflict, and you will be sad.
528 $ sudo service nginx restart
531 Then, run ``conductor-api`` under nginx using uWSGI:
534 $ sudo uwsgi -s /tmp/uwsgi.sock --chmod-socket=777 --wsgi-file /etc/nginx/conductor.wsgi --callable application --set port=8091
537 To use a python virtual environment, add ``--venv VENV`` to the ``uwsgi`` command, where ``VENV`` is the python virtual environment root directory.
541 Activate a virtual environment (venv) first, if necessary, then uninstall with:
544 $ pip uninstall ecomp-conductor
547 Remove any previously made configuration file changes, user accounts, Ubuntu/SWM packages, and other settings as needed.
549 ## Bug Reporting and Feedback
551 ... is encouraged. Please raise an issue at: https://jira.onap.org/projects/OPTFRA/summary