Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LVMCache: update LVs structure to nest them to a VG #212

Open
aesteve-rh opened this issue May 26, 2022 · 0 comments
Open

LVMCache: update LVs structure to nest them to a VG #212

aesteve-rh opened this issue May 26, 2022 · 0 comments
Labels
cleanup Code change keeping current behavior storage

Comments

@aesteve-rh
Copy link
Member

aesteve-rh commented May 26, 2022

Problem

Current cache structure have all LVs flattened in a dictionary and accesible with the vg_name and the lv_name in a tuple. So if we want to retrieve the LVs of a VG (relatively common operation), we have to loop through all the LVs and filter them by vg_name.

It would be better to fix the cache structure so that retrieving the list of LVs is not complicated and expensive as it is now.

Proposal

If we had something like this:

 cache = {
     "vgs": [
         "vg-name-1": {
             "lvs": {
                 "lv-name-1": ...
                 ...
             }
         ...             
         }
          ...
     ]
     "pvs": {
         "path": ...,
         ...
     }

Then we could retrieve all LVs by just doing:

cache["vg-name-1"]["lvs"]

Or maybe something like this:

class VGInfo:
   def __init__(self, vg, lvs):
       self.vg = vg
       self.lvs = lvs

And store instances of this instead of VG namedtuples and LV named tuples raw. This is also a good candidate to be a dataclass.

@aesteve-rh aesteve-rh added the good first issue Good issue for a new contributor label May 26, 2022
@nirs nirs added cleanup Code change keeping current behavior and removed good first issue Good issue for a new contributor labels May 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Code change keeping current behavior storage
Projects
None yet
Development

No branches or pull requests

2 participants