Skip to content

Commit

Permalink
Add enterprise license check for virt plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Qubad786 committed Dec 30, 2024
1 parent b87a945 commit 5854d96
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/middlewared/middlewared/plugins/virt/global.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@ async def extend(self, data):
data['state'] = Status.INITIALIZING.value
return data

@private
async def license_active(self):
"""
If this is iX enterprise hardware and has NOT been licensed to run virt plugin
then this will return False, otherwise this will return true.
"""
can_run_virt = True
if await self.middleware.call('system.is_enterprise'):
license_ = await self.middleware.call('system.license')
can_run_virt = license_ is not None and 'JAILS' in license_['features']

return can_run_virt

@private
async def validate(self, new: dict, schema_name: str, verrors: ValidationErrors):

Expand All @@ -88,6 +101,9 @@ async def validate(self, new: dict, schema_name: str, verrors: ValidationErrors)
if pool == POOL_DISABLED:
new['pool'] = None

if pool and not await self.license_active():
verrors.add(f'{schema_name}.pool', 'System is not licensed to run virtualization')

@api_method(VirtGlobalUpdateArgs, VirtGlobalUpdateResult)
@job()
async def do_update(self, job, data):
Expand Down

0 comments on commit 5854d96

Please sign in to comment.