Merge pull request #1153 from ogayot/ua-with-autoinstall
Add support for ubuntu-advantage with autoinstall
This commit is contained in:
commit
3d10a71d3c
|
@ -260,6 +260,18 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"ubuntu-advantage": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"token": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 24,
|
||||||
|
"maxLength": 30,
|
||||||
|
"pattern": "^C[1-9A-HJ-NP-Za-km-z]+$",
|
||||||
|
"description": "A valid token starts with a C and is followed by 23 to 29 Base58 characters.\nSee https://pkg.go.dev/github.com/btcsuite/btcutil/base58#CheckEncode"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"proxy": {
|
"proxy": {
|
||||||
"type": [
|
"type": [
|
||||||
"string",
|
"string",
|
||||||
|
|
|
@ -42,6 +42,9 @@ snaps:
|
||||||
channel: 3.2/stable
|
channel: 3.2/stable
|
||||||
updates: all
|
updates: all
|
||||||
timezone: Pacific/Guam
|
timezone: Pacific/Guam
|
||||||
|
ubuntu-advantage:
|
||||||
|
# Token that passes the basic format checking but is invalid (i.e. contains more than 16 bytes of random data)
|
||||||
|
token: C1NWcZTHLteJXGVMM6YhvHDpGrhyy7
|
||||||
storage:
|
storage:
|
||||||
config:
|
config:
|
||||||
- {type: disk, ptable: gpt, path: /dev/vdb, wipe: superblock, preserve: false, grub_device: true, id: disk-1}
|
- {type: disk, ptable: gpt, path: /dev/vdb, wipe: superblock, preserve: false, grub_device: true, id: disk-1}
|
||||||
|
|
|
@ -173,6 +173,7 @@ python3 scripts/check-yaml-fields.py .subiquity/var/log/installer/subiquity-curt
|
||||||
python3 scripts/check-yaml-fields.py <(python3 scripts/check-yaml-fields.py .subiquity/etc/cloud/cloud.cfg.d/99-installer.cfg datasource.None.userdata_raw) \
|
python3 scripts/check-yaml-fields.py <(python3 scripts/check-yaml-fields.py .subiquity/etc/cloud/cloud.cfg.d/99-installer.cfg datasource.None.userdata_raw) \
|
||||||
locale='"en_GB.UTF-8"' \
|
locale='"en_GB.UTF-8"' \
|
||||||
timezone='"Pacific/Guam"' \
|
timezone='"Pacific/Guam"' \
|
||||||
|
ubuntu_advantage.token='"C1NWcZTHLteJXGVMM6YhvHDpGrhyy7"' \
|
||||||
'snap.commands=[snap install --channel=3.2/stable etcd]'
|
'snap.commands=[snap install --channel=3.2/stable etcd]'
|
||||||
grep -q 'finish: subiquity/Install/install/postinstall/install_package1: SUCCESS: installing package1' \
|
grep -q 'finish: subiquity/Install/install/postinstall/install_package1: SUCCESS: installing package1' \
|
||||||
.subiquity/subiquity-server-debug.log
|
.subiquity/subiquity-server-debug.log
|
||||||
|
|
|
@ -22,6 +22,10 @@ from subiquity.server.controller import SubiquityController
|
||||||
|
|
||||||
log = logging.getLogger("subiquity.server.controllers.ubuntu_advantage")
|
log = logging.getLogger("subiquity.server.controllers.ubuntu_advantage")
|
||||||
|
|
||||||
|
TOKEN_DESC = """\
|
||||||
|
A valid token starts with a C and is followed by 23 to 29 Base58 characters.
|
||||||
|
See https://pkg.go.dev/github.com/btcsuite/btcutil/base58#CheckEncode"""
|
||||||
|
|
||||||
|
|
||||||
class UbuntuAdvantageController(SubiquityController):
|
class UbuntuAdvantageController(SubiquityController):
|
||||||
""" Represent the server-side Ubuntu Advantage controller. """
|
""" Represent the server-side Ubuntu Advantage controller. """
|
||||||
|
@ -29,6 +33,33 @@ class UbuntuAdvantageController(SubiquityController):
|
||||||
endpoint = API.ubuntu_advantage
|
endpoint = API.ubuntu_advantage
|
||||||
|
|
||||||
model_name = "ubuntu_advantage"
|
model_name = "ubuntu_advantage"
|
||||||
|
autoinstall_key = "ubuntu-advantage"
|
||||||
|
autoinstall_schema = {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"token": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 24,
|
||||||
|
"maxLength": 30,
|
||||||
|
"pattern": "^C[1-9A-HJ-NP-Za-km-z]+$",
|
||||||
|
"description": TOKEN_DESC,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
def load_autoinstall_data(self, data: dict) -> None:
|
||||||
|
""" Load autoinstall data and update the model. """
|
||||||
|
if data is None:
|
||||||
|
return
|
||||||
|
self.model.token = data.get("token", "")
|
||||||
|
|
||||||
|
def make_autoinstall(self) -> dict:
|
||||||
|
""" Return a dictionary that can be used as an autoinstall snippet for
|
||||||
|
Ubuntu Advantage.
|
||||||
|
"""
|
||||||
|
return {
|
||||||
|
"token": self.model.token
|
||||||
|
}
|
||||||
|
|
||||||
def serialize(self) -> str:
|
def serialize(self) -> str:
|
||||||
""" Save the current state of the model so it can be loaded later.
|
""" Save the current state of the model so it can be loaded later.
|
||||||
|
|
Loading…
Reference in New Issue