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

feat(middlewared/pool): add topology to pool.query #1185

Merged
merged 1 commit into from May 8, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/middlewared/middlewared/plugins/pool.py
Expand Up @@ -32,6 +32,19 @@ def _null(x):
return x


def _upper(x, attribute):
if isinstance(x, dict):
for key in x:
if key == attribute and isinstance(x[key], str):
x[key] = x[key].upper()
else:
x[key] = _upper(x[key], attribute)
elif isinstance(x, list):
for i, entry in enumerate(x):
x[i] = _upper(x[i], attribute)
return x


async def is_mounted(middleware, path):
mounted = await middleware.run_in_thread(bsd.getmntinfo)
return any(fs.dest == path for fs in mounted)
Expand Down Expand Up @@ -223,7 +236,6 @@ async def filesystem_choices(self):

@private
async def pool_extend(self, pool):
pool.pop('fstype', None)

"""
If pool is encrypted we need to check if the pool is imported
Expand All @@ -237,10 +249,12 @@ async def pool_extend(self, pool):
if zpool:
pool['status'] = zpool['status']
pool['scan'] = zpool['scan']
pool['topology'] = _upper(zpool['groups'], 'type')
else:
pool.update({
'status': 'OFFLINE',
'scan': None,
'topology': None,
})

if pool['encrypt'] > 0:
Expand Down