remove ancient model and view code

Old bcache, iscsi and ceph code from 2015. If we want to look at it
again we can just dig it out of git...
This commit is contained in:
Michael Hudson-Doyle 2019-12-17 07:59:30 +13:00
parent 7e7ca080f6
commit f02c86175f
7 changed files with 0 additions and 508 deletions

View File

@ -1,59 +0,0 @@
# Copyright 2015 Canonical, Ltd.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# 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/>.
import logging
log = logging.getLogger('subiquity.models.ceph_disk')
class CephDiskModel(object):
""" Model representing iscsi Ceph storage
"""
signals = [
('Ceph view',
'ceph:show',
'ceph'),
('Ceph finish',
'ceph:finish',
'ceph_handler')
]
menu = [
('Fetch key from USB',
'ceph:fetch-key-usb',
'fetch_key_usb'),
('Fetch key by SSH (scp)',
'ceph:fetch-key-ssh',
'fetch_key_ssh')
]
server_authentication = {
'mon': None,
'username': None,
'key': None
}
def get_signal_by_name(self, selection):
for x, y, z in self.get_signals():
if x == selection:
return y
def get_signals(self):
return self.signals + self.menu
def get_menu(self):
return self.menu

View File

@ -1,44 +0,0 @@
# Copyright 2015 Canonical, Ltd.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# 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/>.
import logging
log = logging.getLogger('subiquity.models.iscsi_disk')
class IscsiDiskModel(object):
""" Model representing iscsi network disk
"""
menu = [
('Discover volumes now', 'iscsi:discover-volumes'),
('Use custom discovery credentials (advanced)',
'iscsi:custom-discovery-credentials'),
('Enter volume details manually', 'iscsi:manual-volume-details')
]
server_authentication = {
'server_host': None,
'anonymous': False,
'username': None,
'password': None,
'server_auth': False,
'server_username': None,
'server_password': None
}
def get_menu(self):
return self.menu

View File

@ -1,44 +0,0 @@
# Copyright 2015 Canonical, Ltd.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# 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/>.
import logging
log = logging.getLogger('subiquity.models.raid')
class RaidModel(object):
""" Model representing software raid
"""
menu = [
('RAID Level', 'raid:set-raid-level'),
('Hot spares', 'raid:set-hot-spares'),
('Chunk size', 'raid:set-chunk-size')
]
raid_levels = ['0', '1', '5', '6', '10', 'linear']
raid_levels_map = {
'linear': {'min_disks': 0},
'0': {'min_disks': 0},
'1': {'min_disks': 0},
'5': {'min_disks': 0},
'6': {'min_disks': 0},
'10': {'min_disks': 0}
}
def get_menu(self):
return self.menu

View File

@ -18,24 +18,17 @@ from .filesystem import (
GuidedDiskSelectionView,
GuidedFilesystemView,
)
from .bcache import BcacheView
from .ceph import CephDiskView
from .iscsi import IscsiDiskView
from .identity import IdentityView
from .installprogress import ProgressView
from .keyboard import KeyboardView
from .welcome import WelcomeView
from .zdev import ZdevView
__all__ = [
'BcacheView',
'CephDiskView',
'FilesystemView',
'GuidedDiskSelectionView',
'GuidedFilesystemView',
'IdentityView',
'IscsiDiskView',
'KeyboardView',
'MAASView',
'ProgressView',
'WelcomeView',
'ZdevView',

View File

@ -1,145 +0,0 @@
# Copyright 2015 Canonical, Ltd.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# 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/>.
import logging
from urwid import Text
from subiquitycore.view import BaseView
from subiquitycore.ui.buttons import cancel_btn, done_btn
from subiquitycore.ui.container import ListBox, Pile
from subiquitycore.ui.interactive import Selector
from subiquitycore.ui.utils import Color, Padding
from subiquity.models.filesystem import humanize_size
log = logging.getLogger('subiquity.ui.bcache')
class BcacheView(BaseView):
def __init__(self, model, signal):
self.model = model
self.signal = signal
self.selected_disks = {
'CACHE': None,
'BACKING': None,
}
body = [
Padding.center_50(self._build_disk_selection(section='CACHE')),
Padding.line_break(""),
Padding.center_50(self._build_disk_selection(section='BACKING')),
Padding.line_break(""),
Padding.fixed_10(self._build_buttons())
]
super().__init__(ListBox(body))
@property
def cache_disk(self):
selector = self.selected_disks['CACHE']
if selector:
return selector.value
return selector
@property
def backing_disk(self):
selector = self.selected_disks['BACKING']
if selector:
return selector.value
return selector
def _build_disk_selection(self, section):
log.debug('bcache: _build_disk_selection, section:' + section)
items = [
Text(section + " DISK SELECTION")
]
avail_devs = self._get_available_devs(section)
if len(avail_devs) == 0:
return items.append(
[Color.info_minor(Text("No available disks."))])
selector = Selector(avail_devs)
self.selected_disks[section] = selector
items.append(Color.string_input(selector))
return Pile(items)
def _get_available_devs(self, section):
devs = []
# bcache can use empty whole disks, or empty partitions
avail_disks = self.model.get_empty_disk_names()
avail_parts = self.model.get_empty_partition_names()
input_disks = avail_disks + avail_parts
if section == 'CACHE':
input_disks += self.model.get_bcache_cachedevs()
# filter out:
# currently selected cache or backing disk
# any bcache devices
bcache_names = list(self.model.bcache_devices.keys())
selected_disks = [self.backing_disk, self.cache_disk]
filter_disks = bcache_names + selected_disks
avail_devs = sorted([dev for dev in input_disks
if dev not in filter_disks])
for dname in avail_devs:
device = self.model.get_disk(dname)
if device.path != dname:
# we've got a partition
bcachedev = device.get_partition(dname)
else:
bcachedev = device
disk_sz = humanize_size(bcachedev.size)
disk_string = "{} {}, {}".format(dname,
disk_sz,
device.model)
log.debug('bcache: disk_string={}'.format(disk_string))
devs.append(disk_string)
return devs
def _build_buttons(self):
log.debug('bcache: _build_buttons')
buttons = [
done_btn(on_press=self.done),
cancel_btn(on_press=self.cancel),
]
return Pile(buttons)
def done(self, result):
result = {
'backing_device': self.backing_disk,
'cache_device': self.cache_disk,
}
if not result['backing_device']:
log.debug('Must select a backing device to create a bcache dev')
return
if not result['cache_device']:
log.debug('Must select a caching device to create a bcache dev')
return
if result['backing_device'] == result['cache_device']:
log.debug('Cannot select the same device for backing and cache')
return
log.debug('bcache_done: result = {}'.format(result))
self.model.add_bcache_device(result)
self.signal.prev_signal()
def cancel(self, button):
log.debug('bcache: button_cancel')
self.signal.prev_signal()

View File

@ -1,81 +0,0 @@
# Copyright 2015 Canonical, Ltd.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# 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/>.
import logging
from urwid import Text
from subiquitycore.view import BaseView
from subiquitycore.ui.buttons import cancel_btn, done_btn
from subiquitycore.ui.container import Columns, ListBox, Pile
from subiquitycore.ui.interactive import StringEditor
from subiquitycore.ui.utils import Color, Padding
log = logging.getLogger('subiquity.ceph')
class CephDiskView(BaseView):
def __init__(self, model, signal):
self.model = model
self.signal = signal
self.ceph_mon = StringEditor()
self.username = StringEditor()
self.ceph_key = StringEditor()
self.pool = []
body = [
Padding.center_50(self._build_model_inputs()),
Padding.line_break(""),
Padding.fixed_10(self._build_buttons())
]
super().__init__(ListBox(body))
def _build_model_inputs(self):
items = [
Columns(
[
("weight", 0.2, Text("Ceph MON", align="right")),
("weight", 0.3, Color.string_input(self.ceph_mon))
],
dividechars=4
),
Columns(
[
("weight", 0.2, Text("Username",
align="right")),
("weight", 0.3, Color.string_input(self.username))
],
dividechars=4
),
Columns(
[
("weight", 0.2, Text("Key", align="right")),
("weight", 0.3, Color.string_input(self.ceph_key))
],
dividechars=4
)
]
return Pile(items)
def _build_buttons(self):
buttons = [
done_btn(on_press=self.done),
cancel_btn(on_press=self.cancel),
]
return Pile(buttons)
def done(self, result):
self.signal.emit_signal('ceph:finish')
def cancel(self, button):
self.signal.emit_signal(self.model.get_previous_signal)

View File

@ -1,128 +0,0 @@
# Copyright 2015 Canonical, Ltd.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# 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/>.
import logging
from urwid import Text
from subiquitycore.view import BaseView
from subiquitycore.ui.buttons import menu_btn
from subiquitycore.ui.container import Columns, ListBox, Pile
from subiquitycore.ui.interactive import (StringEditor, YesNo,
PasswordEditor)
from subiquitycore.ui.utils import Color, Padding
log = logging.getLogger('subiquity.iscsi')
class IscsiDiskView(BaseView):
def __init__(self, model, signal):
self.model = model
self.signal = signal
self.iscsi_host = StringEditor()
self.connect_anon = YesNo()
self.connect_username = StringEditor()
self.connect_password = PasswordEditor()
self.server_auth = YesNo()
self.server_username = StringEditor()
self.server_password = PasswordEditor()
body = [
Padding.center_50(self._build_model_inputs()),
Padding.line_break(""),
Padding.center_50(self._build_menu()),
Padding.line_break(""),
Padding.center_75(self._build_volume_mount_selector())
]
super().__init__(ListBox(body))
def _build_model_inputs(self):
items = [
Columns(
[
("weight", 0.2, Text("iSCSI Server Host", align="right")),
("weight", 0.3, Color.string_input(self.iscsi_host))
],
dividechars=4
),
Columns(
[
("weight", 0.2,
Text("Connect anonymously", align="right")),
("weight", 0.3,
Color.string_input(Pile(self.connect_anon.group)))
],
dividechars=4
),
Columns(
[
("weight", 0.2, Text("Connect as user", align="right")),
("weight", 0.3, Color.string_input(self.connect_username))
],
dividechars=4
),
Columns(
[
("weight", 0.2, Text("Password", align="right")),
("weight", 0.3, Color.string_input(self.connect_password))
],
dividechars=4
),
Columns(
[
("weight", 0.2,
Text("Require server auth", align="right")),
("weight", 0.3,
Color.string_input(Pile(self.server_auth.group)))
],
dividechars=4
),
Columns(
[
("weight", 0.2, Text("Server identity", align="right")),
("weight", 0.3, Color.string_input(self.server_username))
],
dividechars=4
),
Columns(
[
("weight", 0.2, Text("Server password", align="right")),
("weight", 0.3, Color.string_input(self.server_password))
],
dividechars=4
)
]
return Pile(items)
def _build_menu(self):
items = []
for label, sig in self.model.get_menu():
items.append(
Columns(
[
("weight", 0.2, Text("")),
("weight", 0.3,
Color.menu_button(
menu_btn(label=label,
on_press=self.confirm,
user_data=sig)))
]))
return Pile(items)
def _build_volume_mount_selector(self):
items = [Text("SELECT VOLUME TO MOUNT")]
# TODO: List found volumes
return Pile(items)
def confirm(self, result, sig):
self.signal.emit_signal(sig)