[libvirt] [jenkins-ci PATCH 2/3] lcitool: Fix flattening of pip mappings

Andrea Bolognani posted 3 patches 6 years, 1 month ago
[libvirt] [jenkins-ci PATCH 2/3] lcitool: Fix flattening of pip mappings
Posted by Andrea Bolognani 6 years, 1 month ago
Right now we're looping in the wrong place: instead of
unconditionally adding to the flattened list of pip packages and
then calling pip multiple times with that same list, we should
conditionally add items to the flattened list and then call pip
a single time with the result.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
---
 guests/playbooks/update/tasks/packages.yml | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/guests/playbooks/update/tasks/packages.yml b/guests/playbooks/update/tasks/packages.yml
index 116c46d..fc8a3d1 100644
--- a/guests/playbooks/update/tasks/packages.yml
+++ b/guests/playbooks/update/tasks/packages.yml
@@ -121,6 +121,15 @@
   when:
     - pip_mappings[item]["default"] is defined
 
+- name: '{{ project }}: Remove unwanted pip mappings'
+  set_fact:
+    pip_resolved: '{{ pip_resolved|combine({ item: None }) }}'
+  with_items:
+    '{{ packages }}'
+  when:
+    - resolved[item] is defined
+    - resolved[item] != None
+
 - set_fact:
     pip_flattened: []
 
@@ -138,10 +147,3 @@
     name: '{{ pip_flattened|sort }}'
     executable: pip3
     state: '{{ state }}'
-  with_items:
-    '{{ packages }}'
-  when:
-    - resolved[item] is defined
-    - resolved[item] == None
-    - pip_resolved[item] is defined
-    - pip_resolved[item] != None
-- 
2.24.1

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

Re: [libvirt] [jenkins-ci PATCH 2/3] lcitool: Fix flattening of pip mappings
Posted by Daniel P. Berrangé 6 years, 1 month ago
On Tue, Jan 07, 2020 at 04:50:19PM +0100, Andrea Bolognani wrote:
> Right now we're looping in the wrong place: instead of
> unconditionally adding to the flattened list of pip packages and
> then calling pip multiple times with that same list, we should
> conditionally add items to the flattened list and then call pip
> a single time with the result.
> 
> Signed-off-by: Andrea Bolognani <abologna@redhat.com>
> ---
>  guests/playbooks/update/tasks/packages.yml | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

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