Switch to classic confinement

Classic confinement allows the snap to behave like a traditionally
packaged application with full access to the system, and enables the
use of traditional directories such as /etc and /var/log.

We will continue to store all of the snap's files in $SNAP* directories.
This enables the snap to cleanup after itself if it is removed. However,
traditional directory locations are symlinked to their corresponding
$SNAP* directories.

For example, nova configs are installed in $SNAP_COMMON/etc/nova
which has a symlink at /etc/nova.

The nova apps then use the traditional directories when running
commands and services.

Change-Id: Ie21c66007a37b90ac3bca042505bad332fa76543
This commit is contained in:
Corey Bryant 2017-03-20 19:13:51 +00:00
parent 0ff5b25d59
commit 1388b583b5
5 changed files with 42 additions and 51 deletions

View File

@ -1 +1,2 @@
snapcraft [platform:dpkg] snapcraft [platform:dpkg]
snapd [platform:dpkg]

View File

@ -1,49 +1,51 @@
setup: setup:
dirs: dirs:
- "{snap_common}/etc/nova.conf.d" - "{snap_common}/etc/nova/conf.d"
- "{snap_common}/etc/nova" - "{snap_common}/lib/nova"
- "{snap_common}/log" - "{snap_common}/log/nova"
- "{snap_common}/lock" - "{snap_common}/lock/nova"
- "{snap_common}/run" - "{snap_common}/run/nova"
symlinks:
"{snap_common}/etc/nova": /etc/nova
"{snap_common}/lib/nova": /var/lib/nova
"{snap_common}/log/nova": /var/log/nova
"{snap_common}/lock/nova": /var/lock/nova
templates: templates:
"nova-snap.conf.j2": "{snap_common}/etc/nova.conf.d/nova-snap.conf" nova-snap.conf.j2: "{snap_common}/etc/nova/conf.d/nova-snap.conf"
copyfiles:
"{snap}/etc/nova": "{snap_common}/etc/nova"
entry_points: entry_points:
nova-api-os-compute: nova-api-os-compute:
binary: nova-api-os-compute binary: nova-api-os-compute
config-files: config-files:
- "{snap}/etc/nova/nova.conf" - "/etc/nova/nova.conf"
- "{snap_common}/etc/nova/nova.conf"
config-dirs: config-dirs:
- "{snap_common}/etc/nova.conf.d" - "/etc/nova/conf.d"
log-file: "{snap_common}/log/nova-api-os-compute.log" log-file: "/var/log/nova/nova-api-os-compute.log"
nova-conductor: nova-conductor:
binary: nova-conductor binary: nova-conductor
config-files: config-files:
- "{snap}/etc/nova/nova.conf" - "/etc/nova/nova.conf"
- "{snap_common}/etc/nova/nova.conf"
config-dirs: config-dirs:
- "{snap_common}/etc/nova.conf.d" - "/etc/nova/conf.d"
log-file: "{snap_common}/log/nova-conductor.log" log-file: "/var/log/nova/nova-conductor.log"
nova-scheduler: nova-scheduler:
binary: nova-scheduler binary: nova-scheduler
config-files: config-files:
- "{snap}/etc/nova/nova.conf" - "/etc/nova/nova.conf"
- "{snap_common}/etc/nova/nova.conf"
config-dirs: config-dirs:
- "{snap_common}/etc/nova.conf.d" - "/etc/nova/conf.d"
log-file: "{snap_common}/log/nova-scheduler.log" log-file: "/var/log/nova/nova-scheduler.log"
nova-consoleauth: nova-consoleauth:
binary: nova-consoleauth binary: nova-consoleauth
config-files: config-files:
- "{snap}/etc/nova/nova.conf" - "/etc/nova/nova.conf"
- "{snap_common}/etc/nova/nova.conf"
config-dirs: config-dirs:
- "{snap_common}/etc/nova.conf.d" - "/etc/nova/conf.d"
log-file: "{snap_common}/log/nova-consoleauth.log" log-file: "/var/log/nova/nova-consoleauth.log"
nova-manage: nova-manage:
binary: nova-manage binary: nova-manage
config-files: config-files:
- "{snap}/etc/nova/nova.conf" - "/etc/nova/nova.conf"
- "{snap_common}/etc/nova/nova.conf"
config-dirs: config-dirs:
- "{snap_common}/etc/nova.conf.d" - "/etc/nova/conf.d"

View File

@ -1,7 +1,7 @@
[DEFAULT] [DEFAULT]
# Set state path to writable directory # Set state path to writable directory
state_path = {{ snap_common }} state_path = /var/lib/nova
[oslo_concurrency] [oslo_concurrency]
# Oslo Concurrency lock path # Oslo Concurrency lock path
lock_path = {{ snap_common }}/lock lock_path = /var/lock/nova

View File

@ -14,38 +14,27 @@ description: |
. .
This snap provides the Nova controller component of an OpenStack This snap provides the Nova controller component of an OpenStack
deployment. deployment.
confinement: strict confinement: classic
grade: devel grade: devel
environment:
PATH: $PATH:$SNAP/bin/
apps: apps:
api: api:
command: snap-openstack nova-api-os-compute command: snap-openstack nova-api-os-compute
daemon: simple daemon: simple
plugs:
- network
- network-bind
conductor: conductor:
command: snap-openstack nova-conductor command: snap-openstack nova-conductor
daemon: simple daemon: simple
plugs:
- network
- network-bind
scheduler: scheduler:
command: snap-openstack nova-scheduler command: snap-openstack nova-scheduler
daemon: simple daemon: simple
plugs:
- network
- network-bind
consoleauth: consoleauth:
command: snap-openstack nova-consoleauth command: snap-openstack nova-consoleauth
daemon: simple daemon: simple
plugs:
- network
- network-bind
manage: manage:
command: snap-openstack nova-manage command: snap-openstack nova-manage
plugs:
- network
aliases: aliases:
- nova-manage - nova-manage
parts: parts:
@ -56,23 +45,18 @@ parts:
python-packages: python-packages:
- pymysql - pymysql
- python-memcached - python-memcached
- git+https://github.com/openstack-snaps/snap.openstack#egg=snap.openstack - git+https://github.com/openstack/snap.openstack#egg=snap.openstack
constraints: https://raw.githubusercontent.com/openstack/requirements/master/upper-constraints.txt constraints: https://raw.githubusercontent.com/openstack/requirements/master/upper-constraints.txt
build-packages: build-packages:
- gcc
- libffi-dev - libffi-dev
- libssl-dev - libssl-dev
- libxml2-dev
- libxslt1-dev
- pkg-config
- gcc
templates: templates:
after: after: [nova]
- nova
plugin: dump plugin: dump
source: snap source: snap
config: config:
after: after: [nova]
- nova
plugin: dump plugin: dump
source: http://tarballs.openstack.org/nova/nova-master.tar.gz source: http://tarballs.openstack.org/nova/nova-master.tar.gz
filesets: filesets:

View File

@ -6,9 +6,13 @@ skipsdist = True
basepython = python3.5 basepython = python3.5
install_command = pip install {opts} {packages} install_command = pip install {opts} {packages}
passenv = HOME TERM passenv = HOME TERM
whitelist_externals =
sudo
snapcraft
[testenv:snap] [testenv:snap]
deps = -r{toxinidir}/requirements.txt deps = -r{toxinidir}/requirements.txt
commands = commands =
sudo snap install core
snapcraft clean snapcraft clean
snapcraft snap snapcraft snap