source: add support for autoinstall data
Since we added a search_drivers checkbox that is uncheckd by default, there is no longer a way for users to install third-party drivers in an autoinstall context. We now implement the autoinstall support for source so that users can specify what value they want for search_drivers. Futhermore, to be backward compatible with existing autoinstall configurations, we now make search_drivers default to true in autoinstall contexts. Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
parent
8929197010
commit
caff5f7dd7
|
@ -118,6 +118,17 @@
|
||||||
],
|
],
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
},
|
},
|
||||||
|
"source": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"search_drivers": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"search_drivers"
|
||||||
|
]
|
||||||
|
},
|
||||||
"network": {
|
"network": {
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from typing import Optional
|
from typing import Any, Optional
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from curtin.commands.extract import get_handler_for_source
|
from curtin.commands.extract import get_handler_for_source
|
||||||
|
@ -52,11 +52,41 @@ class SourceController(SubiquityController):
|
||||||
|
|
||||||
endpoint = API.source
|
endpoint = API.source
|
||||||
|
|
||||||
|
autoinstall_key = "source"
|
||||||
|
autoinstall_schema = {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"search_drivers": {
|
||||||
|
"type": "boolean",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["search_drivers"],
|
||||||
|
}
|
||||||
|
# Defaults to true for backward compatibility with existing autoinstall
|
||||||
|
# configurations. Back then, then users were able to install third-party
|
||||||
|
# drivers without this field.
|
||||||
|
autoinstall_default = {"search_drivers": True}
|
||||||
|
|
||||||
def __init__(self, app):
|
def __init__(self, app):
|
||||||
super().__init__(app)
|
super().__init__(app)
|
||||||
self._handler = None
|
self._handler = None
|
||||||
self.source_path: Optional[str] = None
|
self.source_path: Optional[str] = None
|
||||||
|
|
||||||
|
def make_autoinstall(self):
|
||||||
|
return {"search_drivers": self.model.search_drivers}
|
||||||
|
|
||||||
|
def load_autoinstall_data(self, data: Any) -> None:
|
||||||
|
if data is None:
|
||||||
|
# For some reason, the schema validator does not reject
|
||||||
|
# "source: null" despite "type" being "object"
|
||||||
|
data = self.autoinstall_default
|
||||||
|
|
||||||
|
# search_drivers is marked required so the schema validator should
|
||||||
|
# reject any missing data.
|
||||||
|
assert "search_drivers" in data
|
||||||
|
|
||||||
|
self.model.search_drivers = data["search_drivers"]
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
path = '/cdrom/casper/install-sources.yaml'
|
path = '/cdrom/casper/install-sources.yaml'
|
||||||
if self.app.opts.source_catalog is not None:
|
if self.app.opts.source_catalog is not None:
|
||||||
|
|
Loading…
Reference in New Issue