From cd9990d6654efd5e024c576216f3ebb58548bf72 Mon Sep 17 00:00:00 2001 From: Corey Bryant Date: Mon, 20 Mar 2017 19:30:38 +0000 Subject: [PATCH] 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 --- bindep.txt | 1 + snap/snap-openstack.yaml | 37 ++++++++++++++++-------------- snap/templates/glance-snap.conf.j2 | 6 ++--- snapcraft.yaml | 24 ++++++------------- tox.ini | 4 ++++ 5 files changed, 35 insertions(+), 37 deletions(-) diff --git a/bindep.txt b/bindep.txt index 5816a55..8d8c1a2 100644 --- a/bindep.txt +++ b/bindep.txt @@ -1 +1,2 @@ snapcraft [platform:dpkg] +snapd [platform:dpkg] diff --git a/snap/snap-openstack.yaml b/snap/snap-openstack.yaml index b1e4184..5edabc5 100644 --- a/snap/snap-openstack.yaml +++ b/snap/snap-openstack.yaml @@ -1,33 +1,36 @@ setup: dirs: - - "{snap_common}/etc/glance.conf.d" - - "{snap_common}/etc/glance" - - "{snap_common}/log" - - "{snap_common}/lock" - - "{snap_common}/images" + - "{snap_common}/etc/glance/conf.d" + - "{snap_common}/lib/glance/images" + - "{snap_common}/log/glance" + - "{snap_common}/lock/glance" + 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: - "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: glance-manage: binary: glance-manage config-files: - - "{snap}/etc/glance/glance.conf" - - "{snap_common}/etc/glance/glance.conf" + - "/etc/glance/glance.conf" config-dirs: - - "{snap_common}/etc/glance.conf.d" + - "/etc/glance/conf.d" glance-registry: binary: glance-registry config-files: - - "{snap}/etc/glance/glance-registry.conf" - - "{snap_common}/etc/glance/glance-registry.conf" + - "/etc/glance/glance-registry.conf" config-dirs: - - "{snap_common}/etc/glance.conf.d" - log-file: "{snap_common}/log/glance-registry.log" + - "/etc/glance/conf.d" + log-file: "/var/log/glance/glance-registry.log" glance-api: binary: glance-api config-files: - - "{snap}/etc/glance/glance-api.conf" - - "{snap_common}/etc/glance/glance-api.conf" + - "/etc/glance/glance-api.conf" config-dirs: - - "{snap_common}/etc/glance.conf.d" - log-file: "{snap_common}/log/glance-api.log" + - "/etc/glance/conf.d" + log-file: "/var/log/glance/glance-api.log" diff --git a/snap/templates/glance-snap.conf.j2 b/snap/templates/glance-snap.conf.j2 index 9a797f3..9592294 100644 --- a/snap/templates/glance-snap.conf.j2 +++ b/snap/templates/glance-snap.conf.j2 @@ -1,11 +1,11 @@ [DEFAULT] # Set state path to writable directory -state_path = {{ snap_common }} +state_path = /var/lib/glance [oslo_concurrency] # Oslo Concurrency lock path -lock_path = {{ snap_common }}/lock +lock_path = /var/lock/glance [glance_store] # Set default glance_store path to writable directory -filesystem_store_datadir = {{ snap_common }}/images +filesystem_store_datadir = /var/lib/glance/images diff --git a/snapcraft.yaml b/snapcraft.yaml index d7ea821..fd2844b 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -6,26 +6,21 @@ description: | to store, browse, share, distribute and manage bootable disk images, other data closely associated with initializing compute resources, and metadata definitions. -confinement: strict +confinement: classic grade: devel +environment: + PATH: $PATH:$SNAP/bin/ + apps: api: command: snap-openstack glance-api daemon: simple - plugs: - - network - - network-bind registry: command: snap-openstack glance-registry daemon: simple - plugs: - - network - - network-bind manage: command: snap-openstack glance-manage - plugs: - - network aliases: - glance-manage @@ -46,21 +41,16 @@ parts: - git+https://github.com/openstack/snap.openstack#egg=snap.openstack constraints: https://raw.githubusercontent.com/openstack/requirements/master/upper-constraints.txt build-packages: + - gcc - libffi-dev - libssl-dev - - libxml2-dev - - libxslt1-dev - - pkg-config - - gcc templates: - after: - - glance + after: [glance] plugin: dump source: snap # TODO: replace below with scriplets once implemented in snapcraft config: - after: - - glance + after: [glance] plugin: dump source: http://tarballs.openstack.org/glance/glance-master.tar.gz organize: diff --git a/tox.ini b/tox.ini index 997c257..7360ffc 100644 --- a/tox.ini +++ b/tox.ini @@ -6,9 +6,13 @@ skipsdist = True basepython = python3.5 install_command = pip install {opts} {packages} passenv = HOME TERM +whitelist_externals = + sudo + snapcraft [testenv:snap] deps = -r{toxinidir}/requirements.txt commands = + sudo snap install core snapcraft clean snapcraft snap