RAID support for filesystem answers
This commit is contained in:
parent
9e4a66b628
commit
3ca23e82a9
|
@ -0,0 +1,57 @@
|
||||||
|
Welcome:
|
||||||
|
lang: en_US
|
||||||
|
Keyboard:
|
||||||
|
layout: us
|
||||||
|
Installpath:
|
||||||
|
path: ubuntu
|
||||||
|
Network:
|
||||||
|
accept-default: yes
|
||||||
|
Proxy:
|
||||||
|
proxy: ""
|
||||||
|
Mirror:
|
||||||
|
mirror: "http://us.archive.ubuntu.com"
|
||||||
|
Filesystem:
|
||||||
|
manual:
|
||||||
|
- obj: [disk index 0]
|
||||||
|
action: MAKE_BOOT
|
||||||
|
- obj: [disk index 0]
|
||||||
|
action: PARTITION
|
||||||
|
data:
|
||||||
|
size: 1G
|
||||||
|
fstype: null
|
||||||
|
- obj: [disk index 0]
|
||||||
|
action: PARTITION
|
||||||
|
data:
|
||||||
|
size: 1G
|
||||||
|
mount: null
|
||||||
|
- obj: [disk index 0]
|
||||||
|
action: PARTITION
|
||||||
|
data:
|
||||||
|
size: 1G
|
||||||
|
mount: null
|
||||||
|
- action: create-raid
|
||||||
|
data:
|
||||||
|
name: md11
|
||||||
|
level: 1
|
||||||
|
devices:
|
||||||
|
- [disk index 0, part 1]
|
||||||
|
- active
|
||||||
|
- [disk index 0, part 2]
|
||||||
|
- active
|
||||||
|
- [disk index 0, part 3]
|
||||||
|
- spare
|
||||||
|
- action: done
|
||||||
|
Identity:
|
||||||
|
realname: Ubuntu
|
||||||
|
username: ubuntu
|
||||||
|
hostname: ubuntu-server
|
||||||
|
# ubuntu
|
||||||
|
password: '$6$wdAcoXrU039hKYPd$508Qvbe7ObUnxoj15DRCkzC3qO7edjH0VV7BPNRDYK4QR8ofJaEEF2heacn0QgD.f8pO8SNp83XNdWG6tocBM1'
|
||||||
|
ssh-import-id: lp:mwhudson
|
||||||
|
SnapList:
|
||||||
|
snaps:
|
||||||
|
hello:
|
||||||
|
channel: stable
|
||||||
|
is_classic: false
|
||||||
|
InstallProgress:
|
||||||
|
reboot: yes
|
|
@ -22,6 +22,7 @@ from subiquity.models.filesystem import (
|
||||||
align_up,
|
align_up,
|
||||||
DeviceAction,
|
DeviceAction,
|
||||||
Partition,
|
Partition,
|
||||||
|
raidlevels_by_value,
|
||||||
)
|
)
|
||||||
from subiquity.ui.views import (
|
from subiquity.ui.views import (
|
||||||
FilesystemView,
|
FilesystemView,
|
||||||
|
@ -60,6 +61,12 @@ class FilesystemController(BaseController):
|
||||||
if dev_spec[0] == "disk":
|
if dev_spec[0] == "disk":
|
||||||
if dev_spec[1] == "index":
|
if dev_spec[1] == "index":
|
||||||
dev = self.model.all_disks()[int(dev_spec[2])]
|
dev = self.model.all_disks()[int(dev_spec[2])]
|
||||||
|
elif dev_spec[0] == "raid":
|
||||||
|
if dev_spec[1] == "name":
|
||||||
|
for r in self.model.all_raids():
|
||||||
|
if r.name == dev_spec[2]:
|
||||||
|
dev = r
|
||||||
|
break
|
||||||
if dev is None:
|
if dev is None:
|
||||||
raise Exception("could not resolve {}".format(id))
|
raise Exception("could not resolve {}".format(id))
|
||||||
if len(id) > 1:
|
if len(id) > 1:
|
||||||
|
@ -73,6 +80,15 @@ class FilesystemController(BaseController):
|
||||||
def _action_clean_fstype(self, fstype):
|
def _action_clean_fstype(self, fstype):
|
||||||
return self.model.fs_by_name[fstype]
|
return self.model.fs_by_name[fstype]
|
||||||
|
|
||||||
|
def _action_clean_devices(self, devices):
|
||||||
|
return {
|
||||||
|
self._action_get(d): v
|
||||||
|
for d, v in zip(devices[::2], devices[1::2])
|
||||||
|
}
|
||||||
|
|
||||||
|
def _action_clean_level(self, level):
|
||||||
|
return raidlevels_by_value[level]
|
||||||
|
|
||||||
def _enter_form_data(self, form, data, submit):
|
def _enter_form_data(self, form, data, submit):
|
||||||
for k, v in data.items():
|
for k, v in data.items():
|
||||||
c = getattr(self, '_action_clean_{}'.format(k), lambda x: x)
|
c = getattr(self, '_action_clean_{}'.format(k), lambda x: x)
|
||||||
|
@ -108,6 +124,14 @@ class FilesystemController(BaseController):
|
||||||
body.stretchy.form,
|
body.stretchy.form,
|
||||||
action['data'],
|
action['data'],
|
||||||
action.get("submit", True))
|
action.get("submit", True))
|
||||||
|
elif action['action'] == 'create-raid':
|
||||||
|
self.ui.frame.body.create_raid()
|
||||||
|
yield
|
||||||
|
body = self.ui.frame.body._w
|
||||||
|
yield from self._enter_form_data(
|
||||||
|
body.stretchy.form,
|
||||||
|
action['data'],
|
||||||
|
action.get("submit", True))
|
||||||
elif action['action'] == 'done':
|
elif action['action'] == 'done':
|
||||||
if not self.ui.frame.body.done.enabled:
|
if not self.ui.frame.body.done.enabled:
|
||||||
raise Exception("answers did not provide complete fs config")
|
raise Exception("answers did not provide complete fs config")
|
||||||
|
@ -119,14 +143,14 @@ class FilesystemController(BaseController):
|
||||||
for action in actions:
|
for action in actions:
|
||||||
yield from self._answers_action(action)
|
yield from self._answers_action(action)
|
||||||
|
|
||||||
def _run_iterator(self, it):
|
def _run_iterator(self, it, delay=0.2):
|
||||||
try:
|
try:
|
||||||
next(it)
|
next(it)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
return
|
return
|
||||||
self.loop.set_alarm_in(
|
self.loop.set_alarm_in(
|
||||||
0.2,
|
delay,
|
||||||
lambda *args: self._run_iterator(it))
|
lambda *args: self._run_iterator(it, delay/1.1))
|
||||||
|
|
||||||
def manual(self):
|
def manual(self):
|
||||||
self.ui.set_body(FilesystemView(self.model, self))
|
self.ui.set_body(FilesystemView(self.model, self))
|
||||||
|
|
Loading…
Reference in New Issue