Skip to content

Commit

Permalink
Add an endpoint for UI to retrieve available space for ix-apps
Browse files Browse the repository at this point in the history
This commit adds changes to add an endpoint which UI can consume to retrieve available space in ix-apps dataset so it can show to a user when he wants to install an app that by default X space is available in ix-apps dataset.
  • Loading branch information
sonicaj committed Sep 6, 2024
1 parent 1c7b7b9 commit 8f34ec0
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/middlewared/middlewared/plugins/apps/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,29 @@ async def ip_choices(self):
for ip in await self.middleware.call('interface.ip_in_use', {'static': True, 'any': True})
}

@accepts(roles=['CATALOG_READ'])
@returns(Dict(
'available_space',
additional_attrs=True,
example={
'parsed': 21289574400,
'rawvalue': '21289574400',
'value': '19.8G',
'source': 'NONE',
'source_info': None,
}
))
async def available_space(self):
"""
Returns space available in the configured apps pool which apps can consume
"""
await self.middleware.call('docker.state.validate')
return (await self.middleware.call(
'zfs.dataset.get_instance', (await self.middleware.call('docker.config'))['dataset'], {
'extra': {'retrieve_children': False, 'properties': ['available']},
}
))['properties']['available']

@accepts(roles=['APPS_READ'])
@returns(Dict('gpu_choices', additional_attrs=True))
async def gpu_choices(self):
Expand Down

0 comments on commit 8f34ec0

Please sign in to comment.