diff --git a/src/middlewared/middlewared/plugins/virt/global.py b/src/middlewared/middlewared/plugins/virt/global.py index 394e03bdcdbfd..62bc51af0c6aa 100644 --- a/src/middlewared/middlewared/plugins/virt/global.py +++ b/src/middlewared/middlewared/plugins/virt/global.py @@ -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): @@ -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):