-
Notifications
You must be signed in to change notification settings - Fork 31
Update confdb tutorial following feedback from Ocado #377
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,7 +89,7 @@ See [confdb-schema types](https://documentation.ubuntu.com/core/reference/assert | |
|
|
||
| Now let’s create some view rules to access confdb. | ||
|
|
||
| In our example, we'll use one snap to configure the network and another to access it, which means we need two views: `wifi-admin` and `wifi-state`. | ||
| In our example, we'll use one snap as custodian of the two views and allowing changes to the configuration of the network, and another snap to access it. This means we will need two views: `configure-wifi` and `access-wifi`. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The view names here are also the old ones |
||
|
|
||
| * `wifi-admin` exposes parameters and allows them to be set. | ||
| * `wifi-state` allows the snap to list Wi-Fi connections and read SSID and state information (e.g., up, down). | ||
|
|
@@ -108,27 +108,27 @@ views: | |
| summary: Configure Wi-Fi networks | ||
| rules: | ||
| - | ||
| request: "{name}.ssid" | ||
| storage: "v1.wifi.{name}.ssid" | ||
| request: "{name}.ssid" | ||
| storage: "wifi.{name}.ssid" | ||
| - | ||
| request: "{name}.password" | ||
| storage: "v1.wifi.{name}.psk" | ||
| request: "{name}.password" | ||
| storage: "wifi.{name}.psk" | ||
| - | ||
| request: "{name}.state" | ||
| storage: "v1.wifi.{name}.state" | ||
| request: "{name}.state" | ||
| storage: "wifi.{name}.state" | ||
|
Comment on lines
+111
to
+118
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is restoring the pre-SD247 paths |
||
|
|
||
| wifi-state: | ||
| summary: List and read Wi-Fi SSIDs | ||
| rules: | ||
| - | ||
| request: "{name}" | ||
| storage: "v1.wifi.{name}" | ||
| access: read | ||
| content: | ||
| request: "{name}" | ||
| storage: "wifi.{name}" | ||
| access: read | ||
| content: | ||
| - | ||
| storage: ssid | ||
| storage: ssid | ||
| - | ||
| storage: state | ||
| storage: state | ||
|
|
||
| body-length: 552 | ||
| sign-key-sha3-384: 74KHeq1foV… | ||
|
|
@@ -225,7 +225,7 @@ Custodian snaps have a special role when accessing ephemeral data. They're respo | |
|
|
||
| The data that snapd stores for ephemeral configuration is only a cached, non-authoritative version of the external data. At least one custodian snap must be installed in the system for a particular confdb-schema. | ||
|
|
||
| The first snap will configure the Wi-Fi network to be used, so let’s configure it accordingly: | ||
| The first snap will act as the custodian for both views as well as allowing configuration of the Wi-Fi network, so let’s configure it accordingly: | ||
|
|
||
| ```yaml | ||
| plugs: | ||
|
|
@@ -234,6 +234,11 @@ plugs: | |
| account: <account-id> | ||
| view: network/wifi-admin | ||
| role: custodian | ||
| access-wifi: | ||
| interface: confdb | ||
| account: <account-id> | ||
| view: network/access-wifi | ||
| role: custodian | ||
| ``` | ||
|
|
||
| The other component that must be defined in the snap are the {ref}`hooks <reference-development-supported-snap-hooks>`. | ||
|
|
@@ -260,7 +265,7 @@ That’s it for the custodian snap. | |
|
|
||
| ### Reader snap | ||
|
|
||
| Now we’ll create a snap that will read the configuration. Its plug will reference the read-only view and it will omit the `role`: | ||
| Now we’ll create a snap that will only read the configuration. Its plug will reference the read-only view and it will omit the `role`: | ||
|
|
||
| ```yaml | ||
| plugs: | ||
|
|
@@ -288,8 +293,9 @@ Note that when a snap is published by the same account ID as the assertion, the | |
|
|
||
| ```shell | ||
| snap install custodian-snap reader-snap | ||
| snap connect custodian-snap:network-wifi-admin | ||
| snap connect reader-snap:network-wifi-state | ||
| snap connect custodian-snap:configure-wifi | ||
| snap connect custodian-snap:access-wifi | ||
| snap connect reader-snap:access-wifi | ||
|
Comment on lines
+296
to
+298
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same |
||
| ``` | ||
|
|
||
| ## Setting data | ||
|
|
@@ -325,10 +331,10 @@ ID Status Spawn Ready Summary | |
| $ snap change 123 | ||
| Status Spawn Ready Summary | ||
| Done ... ... Clears the ongoing confdb transaction from state (on error) | ||
| Done ... ... Run hook change-view-network-wifi-admin of snap "custodian-snap" | ||
| Done ... ... Run hook observe-view-network-wifi-state of snap "reader-snap" | ||
| Done ... ... Commit changes to confdb (<account-id>/network/wifi-admin) | ||
| Done ... ... Clears the ongoing confdb transaction from state | ||
| Done ... ... Run hook change-view-configure-wifi of snap "custodian-snap" | ||
| Done ... ... Run hook observe-view-access-wifi of snap "test-snap" | ||
| Done ... ... Commit changes to confdb (NI7Jstuu8gffcoXr02i1kYt898p6Co0A/network/wifi-setup) | ||
| Done ... ... Clears the ongoing confdb transaction from state | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same |
||
|
|
||
|
|
||
| $ cat /snap/reader-snap/common/ssid | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, the rebase has undone changes that landed in #378.. llike renaming the views to
wifi-admin&wifi-state. And now the storage paths start withv1