Re: [PATCH] virsh: Separate 'create'/'modify' message for secret-define

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



+AD4- On Fri, Apr 18, 2014 at 12:20:26 +-0200, Martin Kletzander wrote:
+AD4- +AD4- On Fri, Apr 18, 2014 at 04:27:10AM -0400, Li Yang wrote:
+AD4- +AD4- +AD4-The current message of secret-define always be:
+AD4- +AD4- +AD4-Secret 09a9736f-eedb-449c-9983-80d0ab67393f created
+AD4- +AD4-
+AD4- +AD4- +AD4-even you just modify the secret, perhaps this may puzzle
+AD4- +AD4- +AD4-uses. Now this patch make the modify action output message
+AD4- +AD4- +AD4-like this:
+AD4- +AD4- +AD4-Secret f2d1bafc-ac58-4a47-93e4-47723686fef5 modified
+AD4- +AD4- +AD4-
+AD4- +AD4- +AD4-Signed-off-by: Li Yang +ADw-liyang.fnst+AEA-cn.fujitsu.com+AD4-
+AD4- +AD4- +AD4----
+AD4- +AD4- +AD4- tools/virsh-secret.c +AHw-   16 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+--
+AD4- +AD4- +AD4- 1 files changed, 15 insertions(+-), 1 deletions(-)
+AD4- +AD4- +AD4-
+AD4- +AD4- +AD4-diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c
+AD4- +AD4- +AD4-index 10d5db3..d1cbe04 100644
+AD4- +AD4- +AD4---- a/tools/virsh-secret.c
+AD4- +AD4- +AD4AKwArACs- b/tools/virsh-secret.c
+AD4- +AD4- +AD4AQABA- -39,6 +-39,7 +AEAAQA-
+AD4- +AD4- +AD4- +ACM-include +ACI-virutil.h+ACI-
+AD4- +AD4- +AD4- +ACM-include +ACI-virxml.h+ACI-
+AD4- +AD4- +AD4- +ACM-include +ACI-conf/secret+AF8-conf.h+ACI-
+AD4- +AD4- +AD4AKwAj-include +ACI-viruuid.h+ACI-
+AD4- +AD4- +AD4-
+AD4- +AD4- +AD4- static virSecretPtr
+AD4- +AD4- +AD4- vshCommandOptSecret(vshControl +ACo-ctl, const vshCmd +ACo-cmd, const char +ACoAKg-name)
+AD4- +AD4- +AD4AQABA- -96,6 +-97,7 +AEAAQA- cmdSecretDefine(vshControl +ACo-ctl, const vshCmd +ACo-cmd)
+AD4- +AD4- +AD4-     char +ACo-buffer+ADs-
+AD4- +AD4- +AD4-     virSecretPtr res+ADs-
+AD4- +AD4- +AD4-     char uuid+AFs-VIR+AF8-UUID+AF8-STRING+AF8-BUFLEN+AF0AOw-
+AD4- +AD4- +AD4AKw-    virSecretDefPtr new+AF8-attrs+ADs-
+AD4- +AD4- +AD4-     bool ret +AD0- false+ADs-
+AD4- +AD4- +AD4-
+AD4- +AD4- +AD4-     if (vshCommandOptStringReq(ctl, cmd, +ACI-file+ACI-, +ACY-from) +ADw- 0)
+AD4- +AD4- +AD4AQABA- -104,6 +-106,12 +AEAAQA- cmdSecretDefine(vshControl +ACo-ctl, const vshCmd +ACo-cmd)
+AD4- +AD4- +AD4-     if (virFileReadAll(from, VSH+AF8-MAX+AF8-XML+AF8-FILE, +ACY-buffer) +ADw- 0)
+AD4- +AD4- +AD4-         return false+ADs-
+AD4- +AD4- +AD4-
+AD4- +AD4- +AD4AKw-    new+AF8-attrs +AD0- virSecretDefParseString(buffer)+ADs-
+AD4- +AD4- +AD4AKw-    if (new+AF8-attrs +AD0APQ- NULL)+AHs-
+AD4- +AD4- +AD4AKw-        VIR+AF8-FREE(buffer)+ADs-
+AD4- +AD4- +AD4AKw-        return false+ADs-
+AD4- +AD4- +AD4AKw-    +AH0-
+AD4- +AD4- +AD4AKw-
+AD4- +AD4- +AD4-     if (+ACE-(res +AD0- virSecretDefineXML(ctl-+AD4-conn, buffer, 0))) +AHs-
+AD4- +AD4- +AD4-         vshError(ctl, +AF8-(+ACI-Failed to set attributes from +ACU-s+ACI-), from)+ADs-
+AD4- +AD4- +AD4-         goto cleanup+ADs-
+AD4- +AD4- +AD4AQABA- -114,10 +-122,16 +AEAAQA- cmdSecretDefine(vshControl +ACo-ctl, const vshCmd +ACo-cmd)
+AD4- +AD4- +AD4-         goto cleanup+ADs-
+AD4- +AD4- +AD4-     +AH0-
+AD4- +AD4- +AD4-
+AD4- +AD4- +AD4--    vshPrint(ctl, +AF8-(+ACI-Secret +ACU-s created+AFw-n+ACI-), uuid)+ADs-
+AD4- +AD4- +AD4AKw-    char uuidstr+AFs-VIR+AF8-UUID+AF8-STRING+AF8-BUFLEN+AF0AOw-
+AD4- +AD4- +AD4AKw-    virUUIDFormat(new+AF8-attrs-+AD4-uuid, uuidstr)+ADs-
+AD4- +AD4- +AD4AKw-    if (memcmp(uuid, uuidstr, VIR+AF8-UUID+AF8-BUFLEN) +AD0APQ- 0)
+AD4- +AD4- +AD4AKw-        vshPrint(ctl, +AF8-(+ACI-Secret +ACU-s modified+AFw-n+ACI-), uuid)+ADs-
+AD4- +AD4- +AD4AKw-    else
+AD4- +AD4- +AD4AKw-        vshPrint(ctl, +AF8-(+ACI-Secret +ACU-s created+AFw-n+ACI-), uuid)+ADs-
+AD4- +AD4- +AD4-     ret +AD0- true+ADs-
+AD4- +AD4- 
+AD4- +AD4- You'll still print 'modified' if the new created secret has an uuid in
+AD4- +AD4- the file already, plus it does more parsing, etc.  Wouldn't it be
+AD4- +AD4- easier to just do s/created/defined/ ?
+AD4-
+AD4- Also you compare just the first VIR+AF8-UUID+AF8-BUFLEN characters in UUID
+AD4- string. I agree with Martin.
+AD4-
+AD4- Jirka

Oh, yes, you are right, I didn't notice that. I will try another way to cover this situation.
If I cannot find an easy way to solve this  problem, I think we'd better leave it at that,
Modify +ACI-created+ACI- to +ACI-defined+ACI- seems not enough useful for uses...
After all, secret-undefine command's output is +ACI-Secret +ACoAKgAq- deleted+ACI-, it's correspond
to secret-define command's output +ACI-Secret +ACoAKgAq- created+ACI-.

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]