The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/4237

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
This can be used by some image server to return a different set of
images based on the storage backends in use and will also make it easier
for us to know what storage backends to focus efforts on.

Signed-off-by: St├ęphane Graber <stgra...@ubuntu.com>
From e905092c87560f5f6958662f34a7d5d72f16e968 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Fri, 9 Feb 2018 20:37:25 -0500
Subject: [PATCH] shared/version: Include storage backends in agent
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This can be used by some image server to return a different set of
images based on the storage backends in use and will also make it easier
for us to know what storage backends to focus efforts on.

Signed-off-by: St├ęphane Graber <stgra...@ubuntu.com>
---
 lxd/storage.go              |  9 +++++++++
 shared/version/useragent.go | 25 ++++++++++++++++++++-----
 2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/lxd/storage.go b/lxd/storage.go
index 4a651d70e..82d59c9b8 100644
--- a/lxd/storage.go
+++ b/lxd/storage.go
@@ -18,6 +18,7 @@ import (
        "github.com/lxc/lxd/shared/idmap"
        "github.com/lxc/lxd/shared/ioprogress"
        "github.com/lxc/lxd/shared/logger"
+       "github.com/lxc/lxd/shared/version"
 )
 
 // lxdStorageLockMap is a hashmap that allows functions to check whether the
@@ -886,6 +887,14 @@ func storagePoolDriversCacheUpdate(dbNode *db.Node) {
                data[driver] = sCore.GetStorageTypeVersion()
        }
 
+       backends := []string{}
+       for k, v := range data {
+               backends = append(backends, fmt.Sprintf("%s %s", k, v))
+       }
+
+       // Update the agent
+       version.UserAgentStorageBackends(backends)
+
        storagePoolDriversCacheLock.Lock()
        storagePoolDriversCacheVal.Store(data)
        storagePoolDriversCacheLock.Unlock()
diff --git a/shared/version/useragent.go b/shared/version/useragent.go
index 9c371cff5..300f5a645 100644
--- a/shared/version/useragent.go
+++ b/shared/version/useragent.go
@@ -9,19 +9,34 @@ import (
 )
 
 // UserAgent contains a string suitable as a user-agent
-var UserAgent = getUserAgent()
+var UserAgent = getUserAgent(nil)
 
-func getUserAgent() string {
+func getUserAgent(storageTokens []string) string {
        archID, err := osarch.ArchitectureId(runtime.GOARCH)
        if err != nil {
                panic(err)
        }
+
        arch, err := osarch.ArchitectureName(archID)
        if err != nil {
                panic(err)
        }
 
-       tokens := []string{strings.Title(runtime.GOOS), arch}
-       tokens = append(tokens, getPlatformVersionStrings()...)
-       return fmt.Sprintf("LXD %s (%s)", Version, strings.Join(tokens, "; "))
+       osTokens := []string{strings.Title(runtime.GOOS), arch}
+       osTokens = append(osTokens, getPlatformVersionStrings()...)
+
+       agent := fmt.Sprintf("LXD %s", Version)
+       if len(osTokens) > 0 {
+               agent = fmt.Sprintf("%s (%s)", agent, strings.Join(osTokens, "; 
"))
+       }
+
+       if len(storageTokens) > 0 {
+               agent = fmt.Sprintf("%s (%s)", agent, 
strings.Join(storageTokens, "; "))
+       }
+
+       return agent
+}
+
+func UserAgentStorageBackends(backends []string) {
+       UserAgent = getUserAgent(backends)
 }
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to