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, glance configs are installed in $SNAP_COMMON/etc/glance
which has a symlink at /etc/glance.

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

Change-Id: Ic763f9c8f34ab3096e8592520db00cdf81b0d9ef
This commit is contained in:
Corey Bryant 2017-03-20 19:30:38 +00:00
parent 23b8f67dd3
commit cd9990d665
5 changed files with 35 additions and 37 deletions

View File

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

View File

@ -1,33 +1,36 @@
setup: setup:
dirs: dirs:
- "{snap_common}/etc/glance.conf.d" - "{snap_common}/etc/glance/conf.d"
- "{snap_common}/etc/glance" - "{snap_common}/lib/glance/images"
- "{snap_common}/log" - "{snap_common}/log/glance"
- "{snap_common}/lock" - "{snap_common}/lock/glance"
- "{snap_common}/images" symlinks:
"{snap_common}/etc/glance": /etc/glance
"{snap_common}/lib/glance": /var/lib/glance
"{snap_common}/log/glance": /var/log/glance
"{snap_common}/lock/glance": /var/lock/glance
templates: templates:
"glance-snap.conf.j2": "{snap_common}/etc/glance.conf.d/glance-snap.conf" glance-snap.conf.j2: "{snap_common}/etc/glance/conf.d/glance-snap.conf"
copyfiles:
"{snap}/etc/glance": "{snap_common}/etc/glance"
entry_points: entry_points:
glance-manage: glance-manage:
binary: glance-manage binary: glance-manage
config-files: config-files:
- "{snap}/etc/glance/glance.conf" - "/etc/glance/glance.conf"
- "{snap_common}/etc/glance/glance.conf"
config-dirs: config-dirs:
- "{snap_common}/etc/glance.conf.d" - "/etc/glance/conf.d"
glance-registry: glance-registry:
binary: glance-registry binary: glance-registry
config-files: config-files:
- "{snap}/etc/glance/glance-registry.conf" - "/etc/glance/glance-registry.conf"
- "{snap_common}/etc/glance/glance-registry.conf"
config-dirs: config-dirs:
- "{snap_common}/etc/glance.conf.d" - "/etc/glance/conf.d"
log-file: "{snap_common}/log/glance-registry.log" log-file: "/var/log/glance/glance-registry.log"
glance-api: glance-api:
binary: glance-api binary: glance-api
config-files: config-files:
- "{snap}/etc/glance/glance-api.conf" - "/etc/glance/glance-api.conf"
- "{snap_common}/etc/glance/glance-api.conf"
config-dirs: config-dirs:
- "{snap_common}/etc/glance.conf.d" - "/etc/glance/conf.d"
log-file: "{snap_common}/log/glance-api.log" log-file: "/var/log/glance/glance-api.log"

View File

@ -1,11 +1,11 @@
[DEFAULT] [DEFAULT]
# Set state path to writable directory # Set state path to writable directory
state_path = {{ snap_common }} state_path = /var/lib/glance
[oslo_concurrency] [oslo_concurrency]
# Oslo Concurrency lock path # Oslo Concurrency lock path
lock_path = {{ snap_common }}/lock lock_path = /var/lock/glance
[glance_store] [glance_store]
# Set default glance_store path to writable directory # Set default glance_store path to writable directory
filesystem_store_datadir = {{ snap_common }}/images filesystem_store_datadir = /var/lib/glance/images

View File

@ -6,26 +6,21 @@ description: |
to store, browse, share, distribute and manage bootable disk images, to store, browse, share, distribute and manage bootable disk images,
other data closely associated with initializing compute resources, other data closely associated with initializing compute resources,
and metadata definitions. and metadata definitions.
confinement: strict confinement: classic
grade: devel grade: devel
environment:
PATH: $PATH:$SNAP/bin/
apps: apps:
api: api:
command: snap-openstack glance-api command: snap-openstack glance-api
daemon: simple daemon: simple
plugs:
- network
- network-bind
registry: registry:
command: snap-openstack glance-registry command: snap-openstack glance-registry
daemon: simple daemon: simple
plugs:
- network
- network-bind
manage: manage:
command: snap-openstack glance-manage command: snap-openstack glance-manage
plugs:
- network
aliases: aliases:
- glance-manage - glance-manage
@ -46,21 +41,16 @@ parts:
- git+https://github.com/openstack/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: [glance]
- glance
plugin: dump plugin: dump
source: snap source: snap
# TODO: replace below with scriplets once implemented in snapcraft # TODO: replace below with scriplets once implemented in snapcraft
config: config:
after: after: [glance]
- glance
plugin: dump plugin: dump
source: http://tarballs.openstack.org/glance/glance-master.tar.gz source: http://tarballs.openstack.org/glance/glance-master.tar.gz
organize: organize:

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