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

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) ===

From d738dafc2d754eac19f50bc7cdd562fa9719659c Mon Sep 17 00:00:00 2001
From: Alberto Donato <[email protected]>
Date: Mon, 31 Jul 2017 17:15:45 +0200
Subject: [PATCH] client: fix image copy

Signed-off-by: Alberto Donato <[email protected]>
---
 lxc/image.go          | 37 +++++++++++++++++++------------------
 test/suites/remote.sh |  5 ++---
 2 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/lxc/image.go b/lxc/image.go
index 8b214375b..21fbb3561 100644
--- a/lxc/image.go
+++ b/lxc/image.go
@@ -359,7 +359,7 @@ func (c *imageCmd) run(conf *config.Config, args []string) 
error {
                return c.doImageAlias(conf, args)
 
        case "copy":
-               /* copy [<remote>:]<image> [<rmeote>:]<image> */
+               /* copy [<remote>:]<image> [<remote>:]<image> */
                if len(args) != 3 {
                        return errArgs
                }
@@ -388,26 +388,27 @@ func (c *imageCmd) run(conf *config.Config, args 
[]string) error {
                        return err
                }
 
+               // Check if an alias
+               fingerprint := c.dereferenceAlias(d, inName)
+
                // Attempt to resolve an image alias
                var imgInfo *api.Image
-               image := inName
-               if c.copyAliases {
-                       alias, _, err := d.GetImageAlias(image)
-                       if err == nil {
-                               image = alias.Target
-                       }
-
-                       // Get the image info
-                       imgInfo, _, err = d.GetImage(image)
-                       if err != nil {
-                               return err
-                       }
-               } else {
-                       // Don't fetch full image info if we don't need aliases 
(since it's
-                       // an expensive operation)
+               if conf.Remotes[remote].Protocol == "simplestreams" {
                        imgInfo = &api.Image{}
-                       imgInfo.Fingerprint = image
+                       imgInfo.Fingerprint = fingerprint
                        imgInfo.Public = true
+               } else {
+                       if c.copyAliases {
+                               // Get the image info
+                               imgInfo, _, err = d.GetImage(fingerprint)
+                               if err != nil {
+                                       return err
+                               }
+
+                       } else {
+                               imgInfo = &api.Image{}
+                               imgInfo.Fingerprint = fingerprint
+                       }
                }
 
                if imgInfo.Public && imgInfo.Fingerprint != inName && 
!strings.HasPrefix(imgInfo.Fingerprint, inName) {
@@ -454,7 +455,7 @@ func (c *imageCmd) run(conf *config.Config, args []string) 
error {
                                aliases = append(aliases, alias)
                        }
                }
-               err = ensureImageAliases(dest, aliases, image)
+               err = ensureImageAliases(dest, aliases, fingerprint)
                return err
 
        case "delete":
diff --git a/test/suites/remote.sh b/test/suites/remote.sh
index 79a168a52..301de89a5 100644
--- a/test/suites/remote.sh
+++ b/test/suites/remote.sh
@@ -147,9 +147,8 @@ test_remote_usage() {
   mv "${LXD_CONF}/client.crt" "${LXD_CONF}/client.crt.bak"
   mv "${LXD_CONF}/client.key" "${LXD_CONF}/client.key.bak"
 
-  # testimage should still exist on the local server.  Count the number of
-  # matches so the output isn't polluted with the results.
-  lxc_remote image list local: | grep -c testimage
+  # testimage should still exist on the local server.
+  lxc_remote image list local: | grep -q testimage
 
   # Skip the truly remote servers in offline mode.  There should always be
   # Ubuntu images in the results for the remote servers.
_______________________________________________
lxc-devel mailing list
[email protected]
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to