[lxc-devel] [lxd/master] devices client: only print success message when successful
tych0 on Github
lxc-bot at linuxcontainers.org
Fri Mar 11 22:36:22 UTC 2016
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 361 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160311/71878d1a/attachment.bin>
-------------- next part --------------
From d38553aa7b1afbb53c0a1ecb86986082a2fbb79b Mon Sep 17 00:00:00 2001
From: Tycho Andersen <tycho.andersen at canonical.com>
Date: Fri, 11 Mar 2016 15:35:44 -0700
Subject: [PATCH] devices client: only print success message when successful
Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
lxc/config.go | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/lxc/config.go b/lxc/config.go
index 7bf88f0..0f94945 100644
--- a/lxc/config.go
+++ b/lxc/config.go
@@ -603,11 +603,13 @@ func (c *configCmd) deviceAdd(config *lxd.Config, which string, args []string) e
if err != nil {
return err
}
- fmt.Printf(i18n.G("Device %s added to %s")+"\n", devname, name)
- if which == "profile" {
- return nil
+ if which != "profile" {
+ err = client.WaitForSuccess(resp.Operation)
+ }
+ if err == nil {
+ fmt.Printf(i18n.G("Device %s added to %s")+"\n", devname, name)
}
- return client.WaitForSuccess(resp.Operation)
+ return err
}
func (c *configCmd) deviceRm(config *lxd.Config, which string, args []string) error {
@@ -631,11 +633,13 @@ func (c *configCmd) deviceRm(config *lxd.Config, which string, args []string) er
if err != nil {
return err
}
- fmt.Printf(i18n.G("Device %s removed from %s")+"\n", devname, name)
- if which == "profile" {
- return nil
+ if which != "profile" {
+ err = client.WaitForSuccess(resp.Operation)
+ }
+ if err == nil {
+ fmt.Printf(i18n.G("Device %s removed from %s")+"\n", devname, name)
}
- return client.WaitForSuccess(resp.Operation)
+ return err
}
func (c *configCmd) deviceList(config *lxd.Config, which string, args []string) error {
More information about the lxc-devel
mailing list