Change in vdsm[master]: storage: introducing vdsm-dump-chains script (part of vdsm-t...
nsoffer at redhat.com
nsoffer at redhat.com
Thu Apr 2 17:34:19 UTC 2015
Nir Soffer has posted comments on this change.
Change subject: storage: introducing vdsm-dump-chains script (part of vdsm-tool)
......................................................................
Patch Set 14:
(3 comments)
Looks great, I would consider limiting the use of default dict only for the volume info, and only during printing.
https://gerrit.ovirt.org/#/c/38281/14/lib/vdsm/tool/dump_volume_chains.py
File lib/vdsm/tool/dump_volume_chains.py:
Line 122:
Line 123: def _get_volume_info(server, vol_uuid, img_uuid, sd_uuid, sp_uuid):
Line 124: res = _call_server(server.getVolumeInfo, sd_uuid, sp_uuid, img_uuid,
Line 125: vol_uuid)
Line 126: return defaultdict(_missing_volume_key, res['info'])
Not sure about wrapping in this level. This is great for printing, but may cause other code to be confused - for example, if volume["parent"] is missing, we will get
"(missing)" instead of KeyError, and it will break code that does "key in dict".
I would this only for printing, because it makes the printing code simpler.
Line 127:
Line 128:
Line 129: def _get_volumes_chains(server, sd_uuid):
Line 130: sp_uuid = _get_sp_uuid(server)
Line 131: images_uuids = _get_all_images(server, sd_uuid)
Line 132:
Line 133: image_chains = {} # {image_uuid -> vol_chain}
Line 134: # {vol_uuid-> vol_info}
Line 135: volumes_info = defaultdict(lambda: defaultdict(_missing_volume_key))
I'm not sure this is good idea, better to handle missing volume into with special text, instead of showing all values as (missing).
Line 136:
Line 137: for img_uuid in images_uuids:
Line 138: volumes = _get_volumes_for_image(server, img_uuid, sd_uuid, sp_uuid)
Line 139:
Line 216: _print_line('Volumes and children:')
Line 217: print('')
Line 218: for parent, child in chain_err.volumes_children:
Line 219: _print_line('- %s <- %s' % (parent, child))
Line 220: _print_vol_info(volumes_info[child])
If we use default dict only in the volume info, we can do:
try:
_print_vol_info(volumes_info[child]))
except KeyError:
_print_line("no volume info")
In this case the defaultdict only make it harder.
Line 221: print('')
Line 222: else:
Line 223: for vol in vol_chain:
Line 224: _print_line('- ' + vol)
--
To view, visit https://gerrit.ovirt.org/38281
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I428c443bb7d6b2a504a6f77efcd4838f7ae6c404
Gerrit-PatchSet: 14
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ido Barkan <ibarkan at redhat.com>
Gerrit-Reviewer: Adam Litke <alitke at redhat.com>
Gerrit-Reviewer: Allon Mureinik <amureini at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Darshan N <dnarayan at redhat.com>
Gerrit-Reviewer: Federico Simoncelli <fsimonce at redhat.com>
Gerrit-Reviewer: Ido Barkan <ibarkan at redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: Vladik Romanovsky <vladik.romanovsky at gmail.com>
Gerrit-Reviewer: Yaniv Bronhaim <ybronhei at redhat.com>
Gerrit-Reviewer: Yaniv Dary <ydary at redhat.com>
Gerrit-Reviewer: automation at ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
More information about the vdsm-patches
mailing list