[lxc-devel] [lxd/master] lxd init: ask for images.auto_update_cached
brauner on Github
lxc-bot at linuxcontainers.org
Fri Sep 9 13:00:59 UTC 2016
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 492 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160909/7bf33013/attachment.bin>
-------------- next part --------------
From ed240f74cce99649ae6e612d8d8f70906d1a86a2 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at canonical.com>
Date: Fri, 9 Sep 2016 11:04:53 +0200
Subject: [PATCH] lxd init: ask for images.auto_update_cached
On lxd init, ask the user whether he wants lxd to automatically refresh stale
images. Defaults to true.
Signed-off-by: Christian Brauner <christian.brauner at canonical.com>
---
lxd/main.go | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/lxd/main.go b/lxd/main.go
index f15463a..565bf66 100644
--- a/lxd/main.go
+++ b/lxd/main.go
@@ -600,10 +600,12 @@ func cmdInit() error {
var networkAddress string // Address
var networkPort int64 // Port
var trustPassword string // Trust password
+ var imagesAutoUpdate bool // controls whether we set images.auto_update_cached
// Detect userns
defaultPrivileged = -1
runningInUserns = shared.RunningInUserNS()
+ imagesAutoUpdate = false
// Only root should run this
if os.Geteuid() != 0 {
@@ -876,6 +878,10 @@ they otherwise would.
}
}
+ if askBool("Would you like stale cached images to be updated automatically? (yes/no) [default=yes]? ", "yes") {
+ imagesAutoUpdate = true
+ }
+
if !shared.StringInSlice(storageBackend, []string{"dir", "zfs"}) {
return fmt.Errorf("Invalid storage backend: %s", storageBackend)
}
@@ -947,6 +953,18 @@ they otherwise would.
}
}
+ if imagesAutoUpdate {
+ _, err = c.SetServerConfig("images.auto_update_cached", "true")
+ if err != nil {
+ return err
+ }
+ } else {
+ _, err = c.SetServerConfig("images.auto_update_cached", "false")
+ if err != nil {
+ return err
+ }
+ }
+
if networkAddress != "" {
_, err = c.SetServerConfig("core.https_address", fmt.Sprintf("%s:%d", networkAddress, networkPort))
if err != nil {
More information about the lxc-devel
mailing list