Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content interface for MicroCeph #149

Merged
merged 2 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ source-code: https://github.com/canonical/lxd
website: https://ubuntu.com/lxd
confinement: strict

plugs:
ceph-conf:
interface: content
target: "$SNAP_DATA/microceph"

apps:
# Main commands
activate:
Expand Down
31 changes: 31 additions & 0 deletions snapcraft/hooks/connect-plug-ceph-conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh

# Utility functions
get_bool() {
value=$(echo "${1:-}" | tr '[:upper:]' '[:lower:]')

# See if it's true
for yes in "true" "1" "yes" "on"; do
if [ "${value}" = "${yes}" ]; then
echo "true"
return
fi
done

# See if it's false
for no in "false" "0" "no" "off"; do
if [ "${value}" = "${no}" ]; then
echo "false"
return
fi
done

# Invalid value (or not set)
return
}

ceph_builtin=$(get_bool "$(snapctl get ceph.builtin)")

if ! [ "${ceph_builtin:-"false"}" = "true" ]; then
ln -snf ${SNAP_DATA}/microceph/conf/ /etc/ceph
fi
34 changes: 34 additions & 0 deletions snapcraft/hooks/disconnect-plug-ceph-conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh

# Utility functions
get_bool() {
value=$(echo "${1:-}" | tr '[:upper:]' '[:lower:]')

# See if it's true
for yes in "true" "1" "yes" "on"; do
if [ "${value}" = "${yes}" ]; then
echo "true"
return
fi
done

# See if it's false
for no in "false" "0" "no" "off"; do
if [ "${value}" = "${no}" ]; then
echo "false"
return
fi
done

# Invalid value (or not set)
return
}

ceph_builtin=$(get_bool "$(snapctl get ceph.builtin)")

if [ "${ceph_builtin:-"false"}" = "true" ]; then
mkdir -p "${SNAP_COMMON}/ceph"
ln -snf "${SNAP_COMMON}/ceph" /etc/ceph
else
ln -snf /var/lib/snapd/hostfs/etc/ceph /etc/ceph
fi