api: add free_only
This commit is contained in:
parent
e32b7f28ac
commit
1b74779aef
|
@ -95,6 +95,14 @@ class API:
|
||||||
class ssh_info:
|
class ssh_info:
|
||||||
def GET() -> Optional[LiveSessionSSHInfo]: ...
|
def GET() -> Optional[LiveSessionSSHInfo]: ...
|
||||||
|
|
||||||
|
class free_only:
|
||||||
|
def GET() -> bool: ...
|
||||||
|
|
||||||
|
def POST(enable: bool) -> None:
|
||||||
|
"""Enable or disable free-only mode. Currently only controlls
|
||||||
|
the list of components. free-only choice must be made prior to
|
||||||
|
confirmation of filesystem changes"""
|
||||||
|
|
||||||
class errors:
|
class errors:
|
||||||
class wait:
|
class wait:
|
||||||
def GET(error_ref: ErrorReportRef) -> ErrorReportRef:
|
def GET(error_ref: ErrorReportRef) -> ErrorReportRef:
|
||||||
|
|
|
@ -86,6 +86,7 @@ class MetaController:
|
||||||
def __init__(self, app):
|
def __init__(self, app):
|
||||||
self.app = app
|
self.app = app
|
||||||
self.context = app.context.child("Meta")
|
self.context = app.context.child("Meta")
|
||||||
|
self.free_only = False
|
||||||
|
|
||||||
async def status_GET(self, cur: Optional[ApplicationState] = None) \
|
async def status_GET(self, cur: Optional[ApplicationState] = None) \
|
||||||
-> ApplicationStatus:
|
-> ApplicationStatus:
|
||||||
|
@ -158,6 +159,18 @@ class MetaController:
|
||||||
ips=ips,
|
ips=ips,
|
||||||
host_key_fingerprints=host_fingerprints)
|
host_key_fingerprints=host_fingerprints)
|
||||||
|
|
||||||
|
async def free_only_GET(self) -> bool:
|
||||||
|
return self.free_only
|
||||||
|
|
||||||
|
async def free_only_POST(self, enable: bool) -> None:
|
||||||
|
self.free_only = enable
|
||||||
|
to_disable = {'restricted', 'multiverse'}
|
||||||
|
if enable:
|
||||||
|
# enabling free only mode means disabling components
|
||||||
|
self.app.base_model.mirror.disable_components |= to_disable
|
||||||
|
else:
|
||||||
|
self.app.base_model.mirror.disable_components -= to_disable
|
||||||
|
|
||||||
|
|
||||||
def get_installer_password_from_cloudinit_log():
|
def get_installer_password_from_cloudinit_log():
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -667,6 +667,25 @@ class TestInfo(TestAPI):
|
||||||
self.assertEqual('/dev/sda', sda['path'])
|
self.assertEqual('/dev/sda', sda['path'])
|
||||||
|
|
||||||
|
|
||||||
|
class TestFree(TestAPI):
|
||||||
|
@timeout(5)
|
||||||
|
async def test_free_only(self):
|
||||||
|
async with start_server('examples/simple.json') as inst:
|
||||||
|
await inst.post('/meta/free_only', enable=True)
|
||||||
|
components = await inst.get('/mirror/disable_components')
|
||||||
|
components.sort()
|
||||||
|
self.assertEqual(['multiverse', 'restricted'], components)
|
||||||
|
|
||||||
|
@timeout(5)
|
||||||
|
async def test_not_free_only(self):
|
||||||
|
async with start_server('examples/simple.json') as inst:
|
||||||
|
comps = ['universe', 'multiverse']
|
||||||
|
await inst.post('/mirror/disable_components', comps)
|
||||||
|
await inst.post('/meta/free_only', enable=False)
|
||||||
|
components = await inst.get('/mirror/disable_components')
|
||||||
|
self.assertEqual(['universe'], components)
|
||||||
|
|
||||||
|
|
||||||
class TestRegression(TestAPI):
|
class TestRegression(TestAPI):
|
||||||
@timeout(5)
|
@timeout(5)
|
||||||
async def test_edit_not_trigger_boot_device(self):
|
async def test_edit_not_trigger_boot_device(self):
|
||||||
|
|
Loading…
Reference in New Issue