Subject: pollhelpers: Use correct dictionary keys for old pool/net polling (bz 1099827) From: Cole Robinson crobinso@redhat.com Mon Jun 2 12:17:21 2014 -0400 Date: Mon Jun 2 12:18:59 2014 -0400: Git: d3e9af832899088a17aeb44441e8316177f563ae We were inadvertently using the object name rather than UUID when libvirt didn't support new style polling APIs. Index: virt-manager-1.0.1/virtinst/pollhelpers.py =================================================================== --- virt-manager-1.0.1.orig/virtinst/pollhelpers.py +++ virt-manager-1.0.1/virtinst/pollhelpers.py @@ -52,7 +52,8 @@ def _new_poll_helper(origmap, typename, def _old_poll_helper(origmap, typename, active_list, inactive_list, - lookup_func, build_func): + lookup_func, build_func, + key_is_uuid=False): """ Helper routine for old style split API libvirt polling. @origmap: Pre-existing mapping of objects, with key->obj mapping. @@ -64,6 +65,8 @@ def _old_poll_helper(origmap, typename, @lookup_func: Function to get an object handle for the passed name @build_func: Function that builds a new object class. It is passed args of (raw libvirt object, key (usually UUID)) + @key_is_uuid: If True, we use the object UUID as the returned dictionary + keys """ current = {} new = {} @@ -79,8 +82,10 @@ def _old_poll_helper(origmap, typename, except Exception, e: logging.debug("Unable to list inactive %ss: %s", typename, e) - def check_obj(key): - if key not in origmap: + def check_obj(name): + obj = None + key = name + if key not in origmap or key_is_uuid: try: obj = lookup_func(key) except Exception, e: @@ -88,6 +93,10 @@ def _old_poll_helper(origmap, typename, typename, key, e) return + if key_is_uuid: + key = obj.UUIDString() + + if key not in origmap: # Object is brand new this period current[key] = build_func(obj, key) new[key] = current[key] @@ -120,7 +129,8 @@ def fetch_nets(backend, origmap, build_f return _old_poll_helper(origmap, name, active_list, inactive_list, - lookup_func, build_func) + lookup_func, build_func, + key_is_uuid=True) def fetch_pools(backend, origmap, build_func): @@ -138,7 +148,8 @@ def fetch_pools(backend, origmap, build_ return _old_poll_helper(origmap, name, active_list, inactive_list, - lookup_func, build_func) + lookup_func, build_func, + key_is_uuid=True) def fetch_volumes(backend, pool, origmap, build_func):