[node-patches] Change in ovirt-node[master]: pkg: Remove legacy installer and setup
fabiand at fedoraproject.org
fabiand at fedoraproject.org
Fri May 31 10:18:34 UTC 2013
Fabian Deutsch has uploaded a new change for review.
Change subject: pkg: Remove legacy installer and setup
......................................................................
pkg: Remove legacy installer and setup
And the ovirt-config-storage tool.
They are not needed anymore.
Change-Id: I1b959b85f44b1932f1d7fc7ce14484e14722253f
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=969143
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M ovirt-node.spec.in
M scripts/Makefile.am
D scripts/legacy/ovirt-config-installer.py
D scripts/legacy/ovirt-config-setup.py
D scripts/legacy/ovirt-config-storage
M src/ovirt/node/installer/__main__.py
6 files changed, 2 insertions(+), 4,748 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/44/15244/1
diff --git a/ovirt-node.spec.in b/ovirt-node.spec.in
index 59a2ac6..20c4d23 100644
--- a/ovirt-node.spec.in
+++ b/ovirt-node.spec.in
@@ -513,11 +513,8 @@
%{_libexecdir}/ovirt-config-uninstall
%{_libexecdir}/ovirt-functions
%{_libexecdir}/ovirt-rpmquery
-%{_libexecdir}/ovirt-config-installer
-%{_libexecdir}/ovirt-config-setup
%{_libexecdir}/ovirt-admin-shell
%{_libexecdir}/ovirt-init-functions.sh
-%{_libexecdir}/ovirt-config-storage
%{_sbindir}/persist
%{_sbindir}/unpersist
%{_sbindir}/ovirt-node-upgrade
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 59920c0..d904605 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -39,18 +39,13 @@
ovirt-init-functions.sh \
ovirt-auto-install.py \
ovirt-admin-shell \
- ovirt-node-igor-slave \
- legacy/ovirt-config-installer.py \
- legacy/ovirt-config-setup.py \
- legacy/ovirt-config-storage
+ ovirt-node-igor-slave
# default hook for local_boot_trigger
dist_localboottrigger_SCRIPTS = \
local_boot_trigger.sh
install-exec-hook:
- mv $(DESTDIR)$(libexecdir)/ovirt-config-installer.py $(DESTDIR)$(libexecdir)/ovirt-config-installer
- mv $(DESTDIR)$(libexecdir)/ovirt-config-setup.py $(DESTDIR)$(libexecdir)/ovirt-config-setup
mv $(DESTDIR)$(libexecdir)/ovirt-auto-install.py $(DESTDIR)$(libexecdir)/ovirt-auto-install
mv $(DESTDIR)$(sbindir)/ovirt-node-upgrade.py $(DESTDIR)$(sbindir)/ovirt-node-upgrade
diff --git a/scripts/legacy/ovirt-config-installer.py b/scripts/legacy/ovirt-config-installer.py
deleted file mode 100644
index dbf9dc5..0000000
--- a/scripts/legacy/ovirt-config-installer.py
+++ /dev/null
@@ -1,1108 +0,0 @@
-#!/usr/bin/python
-# ovirt-config-installer - Copyright (C) 2010 Red Hat, Inc.
-# Written by Joey Boggs <jboggs at redhat.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# 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 General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-# MA 02110-1301, USA. A copy of the GNU General Public License is
-# also available at http://www.gnu.org/copyleft/gpl.html.
-
-from snack import *
-import ovirtnode.password as password
-from ovirtnode.install import *
-import ovirtnode.storage as storage
-from ovirtnode.ovirtfunctions import *
-import _snack
-import traceback
-import os
-import dbus
-import fcntl
-import gudev
-import PAM
-import rpm
-
-QUIT_BUTTON = "Quit"
-BACK_BUTTON = "Back"
-NEXT_BUTTON = "Next"
-FINISH_BUTTON = "Finish"
-INSTALL_BUTTON = "Install"
-REBOOT_BUTTON = "Reboot"
-POWEROFF_BUTTON = "Power Off"
-CONTINUE_BUTTON = "Continue"
-SHELL_BUTTON = "Drop To Shell"
-
-WELCOME_PAGE = 1
-KEYBOARD_PAGE = 2
-ROOT_STORAGE_PAGE = 3
-OTHER_DEVICE_ROOT_PAGE = 4
-HOSTVG_STORAGE_PAGE = 5
-OTHER_DEVICE_HOSTVG_PAGE = 6
-STORAGE_VOL_PAGE = 7
-PASSWORD_PAGE = 8
-UPGRADE_PAGE = 9
-FAILED_PAGE = 11
-FINISHED_PAGE = 13
-current_password = ""
-
-def pam_conv(auth, query_list):
- global current_password
- resp = []
- for i in range(len(query_list)):
- resp.append((current_password, 0))
- return resp
-
-def tui_check_fakeraid(device, screen):
- if not is_wipe_fakeraid():
- if has_fakeraid(device):
- msg = "The device(s) you have selected contains fakeraid metadata. Installation cannot proceed with this metadata on the disk. Is it OK to remove the metadata?"
- warn = ButtonChoiceWindow(screen, "Fakeraid Metadata Detected", msg, buttons = ['Ok', 'Cancel'])
- if warn == "ok":
- set_wipe_fakeraid(1)
- return True
- else:
- return False
- else:
- return True
- else:
- return True
-
-class NodeInstallScreen:
- def __init__(self, colorset = None):
- self.__current_page = 1
- self.__finished = False
- self.ovirt_defaults_file = "/etc/default/ovirt"
- OVIRT_VARS = parse_defaults()
- _console_colorset = {
- "ROOT" : ("gray", "magenta"),
- "BORDER" : ("magenta", "magenta"),
- "WINDOW" : ("magenta", "magenta"),
- "ACTBUTTON" : ("blue", "white"),
- "BUTTON" : ("blue", "white"),
- "COMPACTBUTTON" : ("black", "magenta"),
- "LISTBOX" : ("green", "red"),
- "ACTLISTBOX" : ("blue", "white"),
- "ACTSELLISTBOX" : ("blue", "white"),
- "TEXTBOX" : ("cyan", "magenta"),
- "ENTRY" : ("cyan", "magenta"),
- "SHADOW" : ("magenta", "magenta"),
- "LABEL" : ("brown", "magenta"),
- "TITLE" : ("white", "blue"),
- "HELPLINE" : ("cyan", "magenta"),
- "EMPTYSCALE" : ("white", "cyan"),
- "FULLSCALE" : ("cyan", "white"),
- "CHECKBOX" : ("black", "red"),
- "ROOTTEXT" : ("white", "blue"),
- }
- _alternate_colorset = {
- "ROOT" : ("white", "white"),
- "HELPLINE" : ("white", "white"),
- "SHADOW" : ("white", "white"),
- "BORDER" : ("white", "white"),
- "ACTBUTTON" : ("white", "blue"),
- "BUTTON" : ("blue", "white"),
- "TITLE" : ("white", "blue"),
- "EMPTYSCALE" : ("white", "cyan"),
- "FULLSCALE" : ("black", "white"),
- "CHECKBOX" : ("black", "gray"),
- "ROOTTEXT" : ("white", "blue"),
- "ACTSELLISTBOX" : ("white", "black"),
- "LABEL" : ("black", "white"),
- }
-
- if is_console():
- self.__colorset = _console_colorset
- else:
- self.__colorset = _alternate_colorset
- self.dev_name = ""
- self.dev_model = ""
- self.dev_bus = ""
- self.dev_serial = ""
- self.dev_size = ""
- self.dev_desc = ""
- self.current_password_fail = 0
- self.failed_block_dev = 0
- self.failed_install = False
- self.live_disk = get_live_disk()
- self.config_vol_msg = None
- self.data_vol_msg = None
- self.swap_vol_msg = None
- self.log_vol_msg = None
- self.swap_vol_failed = False
- self.log_vol_failed = False
- self.data_vol_failed = False
- self.config_vol_failed = False
- if not "/dev/mapper" in self.live_disk:
- self.live_disk = "/dev/" + get_live_disk().rstrip('0123456789')
- logger.info("::::live device::::\n" + self.live_disk)
- def set_console_colors(self):
- self.existing_color_array = None
- tty_file = None
- try:
- tty_file = open("/dev/tty", "rw")
- except:
- pass
- if tty_file == None:
- tty_file = open("/dev/console", "rw")
- try:
- self._set_colors(tty_file)
- except:
- pass
- finally:
- tty_file.close()
-
- def _set_colors(self, tty_file):
- GIO_CMAP = 0x4B70
- PIO_CMAP = 0x4B71
- self.existing_color_array = bytearray(fcntl.ioctl(tty_file.fileno(), GIO_CMAP, b"\x00" * 48))
- color_array = self.existing_color_array
- color_array[3] = 0xde
- color_array[4] = 0xde
- color_array[5] = 0xde
- color_array[6] = 0x30
- color_array[7] = 0x30
- color_array[8] = 0x30
- color_array[9] = 0x52
- color_array[10] = 0x52
- color_array[11] = 0x52
- color_array[12] = 0x00
- color_array[13] = 0xbb
- color_array[14] = 0xff
- color_array[15] = 0xea
- color_array[16] = 0xea
- color_array[17] = 0xea
- color_array[18] = 0x71
- color_array[19] = 0x71
- color_array[20] = 0x71
- color_array[21] = 0xff
- color_array[22] = 0xff
- color_array[23] = 0xff
- fcntl.ioctl(tty_file.fileno(), PIO_CMAP, bytes(color_array))
-
- def restore_console_colors(self):
- if self.existing_color_array == None:
- return
- tty_file = None
- try:
- tty_file = open("/dev/tty", "rw")
- except:
- pass
- if tty_file == None:
- tty_file = open("/dev/console", "rw")
- try:
- self._restore_colors(tty_file)
- except:
- pass
- finally:
- tty_file.close()
-
- def _restore_colors(self, tty_file):
- GIO_CMAP = 0x4B70
- PIO_CMAP = 0x4B71
- fcntl.ioctl(tty_file.fileno(), PIO_CMAP, bytes(self.existing_color_array))
-
- def reset_screen_colors(self):
- for item in self.__colorset.keys():
- colors = self.__colorset.get(item)
- self.screen.setColor(item, colors[0], colors[1])
-
- def get_def_swap_size(self, overcommit):
- if "OVIRT_OVERCOMMIT" in OVIRT_VARS:
- return calculate_swap_size(float(OVIRT_VARS["OVIRT_OVERCOMMIT"]))
- else:
- return calculate_swap_size(overcommit)
-
- def swap_size_callback(self):
- Storage = storage.Storage()
- if not check_int(self.SWAP_SIZE.value()):
- self.swap_vol_failed = True
- self.swap_vol_msg = "Swap Size must be an integer."
- elif int(self.SWAP_SIZE.value()) < int(Storage.MIN_SWAP_SIZE):
- self.swap_vol_failed = True
- self.swap_vol_msg = "Minimum Swap size is %s MB." % Storage.MIN_SWAP_SIZE
- else:
- self.swap_vol_failed = False
- self.swap_vol_msg = None
- self.write_storage_vol_msg()
- return
-
- def config_size_callback(self):
- if not check_int(self.CONFIG_SIZE.value()):
- self.config_vol_failed = True
- self.config_vol_msg = "Config Partition Size must be a positive integer."
- elif int(self.CONFIG_SIZE.value()) < 5:
- self.config_vol_failed = True
- self.config_vol_msg = "Minimum Config size is 5 MB."
- else:
- self.config_vol_failed = False
- self.config_vol_msg = None
- self.write_storage_vol_msg()
- return
-
- def log_size_callback(self):
- Storage = storage.Storage()
- if not check_int(self.LOGGING_SIZE.value()):
- self.log_vol_failed = True
- self.log_vol_msg = "Logging Partition Size must be a positive integer."
- elif int(self.LOGGING_SIZE.value()) < int(Storage.MIN_LOGGING_SIZE):
- self.log_vol_failed = True
- self.log_vol_msg = "Minimum Logging size is %s MB." % Storage.MIN_LOGGING_SIZE
- else:
- self.log_vol_failed = False
- self.log_vol_msg = None
- self.write_storage_vol_msg()
- return
-
- def data_size_callback(self):
- if self.DATA_SIZE.value() == "-1":
- self.data_vol_failed = False
- self.data_vol_msg = None
- elif not check_int(self.DATA_SIZE.value()):
- self.data_vol_failed = True
- self.data_vol_msg = "Data Partition Size must be a positive integer or -1."
- else:
- self.data_vol_failed = False
- self.data_size_msg = None
- self.write_storage_vol_msg()
- return
-
- def write_storage_vol_msg(self):
- self.vol_msg.setText("\n\n\n\n\n")
- self.vol_msg.setText(self.format_storage_vol_msg())
-
- def format_storage_vol_msg(self):
- counter = 4
- msg = ""
- if self.swap_vol_msg is not None:
- msg += "%s\n" % self.swap_vol_msg
- if self.config_vol_msg is not None:
- msg += "%s\n" % self.config_vol_msg
- if self.log_vol_msg is not None:
- msg += "%s\n" % self.log_vol_msg
- if self.data_vol_msg is not None:
- msg += "%s\n" % self.data_vol_msg
- return msg
-
- def password_check_callback(self):
- self.valid_password, msg = password_check(self.root_password_1.value(), self.root_password_2.value())
- if self.current_password_fail == 0:
- self.pw_msg.setText(msg)
- return
-
- def password_check_w_empty_callback(self):
- self.valid_password, msg = password_check(self.root_password_1.value(), self.root_password_2.value(), 0)
- if self.current_password_fail == 0:
- if len(self.root_password_1.value()) is 0 and \
- len(self.root_password_2.value()) is 0:
- msg = "You have not provided a new password, " + \
- "current admin password will be used."
- self.pw_msg.setText(msg)
- return
-
- def current_password_callback(self):
- auth = PAM.pam()
- auth.start("passwd")
- auth.set_item(PAM.PAM_USER, "admin")
- global current_password
- current_password = self.current_password.value()
- auth.set_item(PAM.PAM_CONV, pam_conv)
- try:
- auth.authenticate()
- except PAM.error, (resp, code):
- logger.error(resp)
- self.current_password_fail = 1
- self.pw_msg.setText("Current Password Invalid\n\n\n\n\n\n")
- return False
- except:
- logger.error("Internal error")
- return False
- else:
- self.current_password_fail = 0
- self.pw_msg.setText(" \n\n\n\n\n\n")
- return True
-
- def other_device_root_callback(self):
- ret = system_closefds("test -b " + self.root_device.value())
- if ret != 0:
- self.screen.setColor("BUTTON", "black", "red")
- self.screen.setColor("ACTBUTTON", "blue", "white")
- ButtonChoiceWindow(self.screen, "Storage Check", "Invalid Block Device", buttons = ['Ok'])
- self.reset_screen_colors()
- self.failed_block_dev = 1
- else:
- self.failed_block_dev = 0
- return
-
- def other_device_hostvg_callback(self):
- for dev in self.hostvg_device.value().split(","):
- ret = system_closefds("test -b " + dev)
- if ret != 0:
- self.screen.setColor("BUTTON", "black", "red")
- self.screen.setColor("ACTBUTTON", "blue", "white")
- ButtonChoiceWindow(self.screen, "Storage Check", "Invalid Block Device: " + dev, buttons = ['Ok'])
- self.reset_screen_colors()
- self.failed_block_dev = 1
- else:
- self.failed_block_dev = 0
- return
-
- def menuSpacing(self):
- menu_option = self.menu_list.current()
- if self.menuo < self.menu_list.current():
- if menu_option == 2:
- try:
- self.menu_list.setCurrent(3)
- self.menuo = 3
- except:
- try:
- self.menu_list.setCurrent(5)
- self.menuo = 5
- except:
- self.menu_list.setCurrent(1)
- self.menuo = 1
- if menu_option == 4:
- self.menu_list.setCurrent(5)
- self.menuo = 5
- if menu_option == 6:
- self.menu_list.setCurrent(7)
- self.menuo = 7
- if menu_option == 8:
- self.menu_list.setCurrent(9)
- self.menuo = 9
- if menu_option == 10:
- self.menu_list.setCurrent(11)
- self.menuo = 11
- if menu_option == 10:
- self.menu_list.setCurrent(11)
- self.menuo = 11
- # prevent going further down list
- if menu_option == 12:
- self.menu_list.setCurrent(11)
- self.menuo = 11
- elif self.menuo > self.menu_list.current():
- if menu_option == 10:
- self.menu_list.setCurrent(9)
- self.menuo = 9
- if menu_option == 8:
- self.menu_list.setCurrent(7)
- self.menuo = 7
- if menu_option == 6:
- self.menu_list.setCurrent(5)
- self.menuo = 5
- if menu_option == 4:
- self.menu_list.setCurrent(3)
- self.menuo = 3
- if menu_option == 2:
- self.menu_list.setCurrent(1)
- self.menuo = 1
-
- def get_back_page(self):
- if self.__current_page == KEYBOARD_PAGE:
- self.__current_page = WELCOME_PAGE
- elif self.__current_page == ROOT_STORAGE_PAGE:
- self.__current_page = KEYBOARD_PAGE
- elif self.__current_page == OTHER_DEVICE_ROOT_PAGE:
- self.__current_page = ROOT_STORAGE_PAGE
- elif self.__current_page == OTHER_DEVICE_HOSTVG_PAGE:
- self.__current_page = HOSTVG_STORAGE_PAGE
- elif self.__current_page == HOSTVG_STORAGE_PAGE:
- self.__current_page = ROOT_STORAGE_PAGE
- elif self.__current_page == STORAGE_VOL_PAGE:
- self.__current_page = HOSTVG_STORAGE_PAGE
- elif self.__current_page == PASSWORD_PAGE:
- self.__current_page = STORAGE_VOL_PAGE
- elif self.__current_page == UPGRADE_PAGE:
- self.__current_page = KEYBOARD_PAGE
- return
-
- def install_page(self):
- elements = Grid(2, 5)
- self.menuo = 1
- self.menu_list = Listbox(14, width = 73, returnExit = 1, border = 0, showCursor = 0, scroll = 0)
- try:
- m_version,m_release = get_media_version_number()
- m_full_ver = m_version + "-" + m_release
- finally:
- if os.path.exists("/dev/HostVG"):
- if not os.path.exists("/dev/disk/by-label/ROOT"):
- try:
- e_version, e_release = get_installed_version_number()
- e_full_ver = e_version + "-" + e_release
- compare = rpm.labelCompare(('1', e_version, e_release), ('1', m_version, m_release))
- if compare == -1:
- self.menu_list.append(" Upgrade " + e_full_ver + " to " + m_full_ver, 3)
- elif compare == 1:
- self.menu_list.append(" Downgrade " + e_full_ver + " to " + m_full_ver, 3)
- else:
- self.menu_list.append(" Reinstall " + m_full_ver, 3)
- except:
- self.menu_list.append(" Invalid installation, please reboot from media and choose Reinstall", 0)
- self.failed_install = True
- logger.error("Unable to get version numbers for upgrade, invalid installation or media")
- pass
- else:
- self.menu_list.append("Major version upgrades are unsupported, uninstall existing version first", 0)
- else:
- self.menu_list.append(" Install Hypervisor " + m_full_ver, 1)
- self.menu_list.setCallback(self.menuSpacing)
- elements.setField(self.menu_list, 1,1, anchorLeft = 1, padding = (0,0,0,1))
- hwvirt_msg = get_virt_hw_status()
- self.hwvirt = Textbox(50, 2, hwvirt_msg, wrap = 1)
- elements.setField(self.hwvirt, 1, 2, anchorLeft = 1, padding=(0,0,0,0))
- if is_efi_boot():
- efi_text="INFO: Machine is booted in EFI mode"
- elements.setField(Label(efi_text), 1, 3, anchorLeft = 1, padding=(0,1,0,0))
- return [Label(""), elements]
-
- def finish_install_page(self):
- elements = Grid(2, 5)
- title = "%s Installation Finished Successfully" % PRODUCT_SHORT
- title_start = 39 - len(title) / 2
- elements.setField(Label(title), 0, 0,padding=(title_start,6,0,1))
- elements.setField(Label(" "), 0, 1)
- return [Label(""), elements]
-
- def failed_install_page(self):
- system_closefds("cat " + OVIRT_TMP_LOGFILE + ">> " + OVIRT_LOGFILE)
- elements = Grid(2, 5)
- elements.setField(Label("%s Installation Failed " %
- PRODUCT_SHORT), 0, 0)
- elements.setField(Label(" View Log Files "), 0, 1, anchorLeft = 1, padding = (0,1,0,1))
- self.log_menu_list = Listbox(3, width = 30, returnExit = 1, border = 0, showCursor = 0, scroll = 0)
- if os.path.exists("/var/log/ovirt.log"):
- self.log_menu_list.append(" /var/log/ovirt.log", "/var/log/ovirt.log")
- if os.path.exists("/tmp/ovirt.log"):
- self.log_menu_list.append(" /tmp/ovirt.log", "/tmp/ovirt.log")
- self.log_menu_list.append(" /var/log/messages", "/var/log/messages")
- elements.setField(self.log_menu_list, 0, 2, anchorLeft = 1, padding = (0,0,0,12))
- return [Label(""), elements]
-
- def keyboard_page(self):
- # placeholder for system-config-keyboard-base, will remove move later
- try:
- import system_config_keyboard.keyboard as keyboard
- except:
- return [Label(""), elements]
-
- elements = Grid(2, 9)
- heading = Label("Keyboard Layout Selection")
- if is_console():
- heading.setColors(customColorset(1))
- self.kbd = keyboard.Keyboard()
- self.kbd.read()
- self.kbdDict = self.kbd.modelDict
- self.kbdKeys = [k[0] for k in sorted(self.kbdDict.items(), \
- key=lambda e: e[1][0].lower())]
- self.kb_list = Listbox(10, scroll = 1, returnExit = 1)
- default = ""
- for kbd in self.kbdKeys:
- if kbd == self.kbd.get():
- default = kbd
- plainName = self.kbdDict[kbd][0]
- self.kb_list.append(plainName, kbd)
- try:
- self.kb_list.setCurrent(default)
- except:
- pass
- elements.setField(heading, 0, 0, anchorLeft = 1)
- elements.setField(self.kb_list, 0, 1, anchorLeft = 1, padding=(1,1,0,3))
- return [Label(""), elements]
-
- def process_keyboard_config(self):
- self.kbd.set(self.kb_list.current())
- self.kbd.write()
- self.kbd.activate()
-
- def disk_details_callback(self):
- if self.__current_page == ROOT_STORAGE_PAGE:
- dev = self.root_disk_menu_list.current()
- elif self.__current_page == HOSTVG_STORAGE_PAGE:
- self.hostvg_checkbox.getEntryValue("OtherDevice")[1]
- dev = self.hostvg_checkbox.getCurrent()
- if self.hostvg_checkbox.getEntryValue(dev)[1] == 1 and dev != "OtherDevice":
- self.hostvg_checkbox.setEntryValue("OtherDevice", selected = 0)
- if self.hostvg_checkbox.getEntryValue("OtherDevice")[1] == 1 and dev == "OtherDevice":
- for d in self.dev_names:
- if d != self.live_disk and d in self.disk_dict:
- # only disks from disk_dict and if it's not the live
- # media
- # self.hostvg_checkbox is populated w entries from
- # self.disk_dict
- d = translate_multipath_device(d)
- self.hostvg_checkbox.setEntryValue(d, selected = 0)
- if "Location" in dev or "NoDevices" in dev or "OtherDevice" in dev:
- blank_entry = ",,,,,"
- dev_bus,dev_name,dev_size,dev_desc,dev_serial,dev_model = blank_entry.split(",",5)
- else:
- dev = translate_multipath_device(dev)
- dev_bus,dev_name,dev_size,dev_desc,dev_serial,dev_model = self.disk_dict[dev].split(",",5)
- self.dev_bus_label.setText(dev_bus)
- dev_name = dev_name.replace(" ","")
- self.dev_name_label.setText(dev_name)
- self.dev_size_label.setText(dev_size + "GB")
- self.dev_desc_label.setText(dev_desc)
- self.dev_serial_label.setText(dev_serial)
- self.dev_model_label.setText(dev_model)
- return
- def root_disk_page(self):
- elements = Grid(2, 9)
- self.root_disk_menu_list = Listbox(5, width = 70, returnExit = 1, border = 0, scroll = 1)
- self.root_disk_menu_list.setCallback(self.disk_details_callback)
- Storage = storage.Storage()
- dev_names, self.disk_dict = Storage.get_udev_devices()
- self.displayed_disks = {}
- self.valid_disks = []
- for dev in dev_names:
- dev = translate_multipath_device(dev)
- if not self.displayed_disks.has_key(dev):
- if self.disk_dict.has_key(dev) and dev != self.live_disk:
- dev_bus,dev_name,dev_size,dev_desc,dev_serial,dev_model = self.disk_dict[dev].split(",",5)
- dev_desc = pad_or_trim(32, dev_desc)
- self.valid_disks.append(dev_name)
- dev_name = os.path.basename(dev_name).replace(" ", "")
- dev_name = pad_or_trim(31, dev_name)
- dev_entry = " %6s %11s %5s GB" % (dev_bus,dev_name, dev_size)
- dev_name = translate_multipath_device(dev_name)
- self.root_disk_menu_list.append(dev_entry, dev)
- self.valid_disks.append(dev_name)
- self.displayed_disks[dev] = ""
- if len(self.valid_disks) == 0:
- self.root_disk_menu_list.append(" No Valid Install Devices Detected", "NoDevices")
- self.disk_dict["NoDevices"] = ",,,,,"
- dev_bus,dev_name,dev_size,dev_desc,dev_serial,dev_model = self.disk_dict["NoDevices"].split(",",5)
- else:
- dev_bus,dev_name,dev_size,dev_desc,dev_serial,dev_model = self.disk_dict[self.valid_disks[0]].split(",",5)
- self.root_disk_menu_list.append(" Other Device", "OtherDevice")
- self.disk_dict["OtherDevice"] = ",,,,,"
- elements.setField(Label("Please select the disk to use for booting %s"
- % PRODUCT_SHORT), 0,1, anchorLeft = 1)
- elements.setField(Label(" "), 0,2, anchorLeft = 1)
- elements.setField(Label(" Location Device Name Size"),0,3,anchorLeft =1)
- elements.setField(self.root_disk_menu_list, 0,4)
- disk_grid = Grid(5,8)
- elements.setField(Label("Disk Details"), 0,5, anchorLeft = 1)
- elements.setField(Label(" "), 0,6)
- disk_grid.setField(Label("Device "),0, 0, anchorLeft = 1)
- disk_grid.setField(Label("Model "),0, 1, anchorLeft = 1)
- disk_grid.setField(Label("Bus Type "),0, 2, anchorLeft = 1)
- disk_grid.setField(Label("Serial "),0, 3, anchorLeft = 1)
- disk_grid.setField(Label("Size "),0, 4, anchorLeft = 1)
- disk_grid.setField(Label("Description "),0, 5, anchorLeft = 1)
- dev_name = dev_name.replace(" ", "")
- self.dev_name_label = Label(dev_name)
- self.dev_model_label = Label(dev_model)
- self.dev_bus_label = Label(dev_bus)
- self.dev_serial_label = Label(dev_serial)
- self.dev_size_label = Label(dev_size + "GB")
- self.dev_desc_label = Label(dev_desc)
- disk_grid.setField(self.dev_name_label,1, 0, anchorLeft = 1)
- disk_grid.setField(self.dev_model_label,1, 1, anchorLeft = 1)
- disk_grid.setField(self.dev_bus_label,1, 2, anchorLeft = 1)
- disk_grid.setField(self.dev_serial_label,1, 3, anchorLeft = 1)
- disk_grid.setField(self.dev_size_label,1, 4, anchorLeft = 1)
- disk_grid.setField(self.dev_desc_label,1, 5, anchorLeft = 1)
- elements.setField(disk_grid, 0,7, anchorLeft = 1)
- elements.setField(Label(" "), 0, 8, anchorLeft = 1)
- return [Label(""), elements]
-
- def hostvg_disk_page(self):
- self.hostvg_checkbox = CheckboxTree(6, width = 73, scroll = 1)
- self.hostvg_checkbox.setCallback(self.disk_details_callback)
- self.hostvg_checkbox.append(" Location Device Name Size", selected = 1)
- elements = Grid(2, 9)
- Storage = storage.Storage()
- devs = Storage.get_dev_name()
- dev_names = []
- for dev in devs:
- dev_names.append(dev)
- dev_names.sort()
- self.dev_names = dev_names
- self.displayed_disks = {}
- for dev in dev_names:
- dev = translate_multipath_device(dev)
- if not self.displayed_disks.has_key(dev) and dev != self.live_disk:
- if self.disk_dict.has_key(dev):
- dev_bus,dev_name,dev_size,dev_desc,dev_serial,dev_model = self.disk_dict[dev].split(",",5)
- dev_desc = pad_or_trim(32, dev_desc)
- if dev_name == self.root_disk_menu_list.current():
- select_status = 1
- else:
- select_status = 0
- # strip all "/dev/*/" references and leave just basename
- dev_name = os.path.basename(dev_name).replace(" ", "")
- dev_name = pad_or_trim(31, dev_name)
- dev_entry = " %6s %10s %2s GB" % (dev_bus,dev_name, dev_size)
- self.hostvg_checkbox.addItem(dev_entry, (0, snackArgs['append']), item = dev, selected = select_status)
- self.displayed_disks[dev] = ""
- if self.root_disk_menu_list.current() == "OtherDevice":
- select_status = 1
- else:
- select_status = 0
- self.hostvg_checkbox.addItem(" Other Device", (0, snackArgs['append']), item = "OtherDevice", selected = select_status)
- elements.setField(Label("Please select the disk(s) to use for installation of %s" % PRODUCT_SHORT), 0,1, anchorLeft = 1)
- elements.setField(self.hostvg_checkbox, 0,3)
- elements.setField(Label("Disk Details"), 0,4, anchorLeft = 1, padding = (0,1,0,0))
- elements.setField(Label(" "), 0,5)
- disk_grid = Grid(2,8)
- disk_grid.setField(Label("Device "),0, 0, anchorLeft = 1)
- disk_grid.setField(Label("Model "),0, 1, anchorLeft = 1)
- disk_grid.setField(Label("Bus Type "),0, 2, anchorLeft = 1)
- disk_grid.setField(Label("Serial "),0, 3, anchorLeft = 1)
- disk_grid.setField(Label("Size "),0, 4, anchorLeft = 1)
- disk_grid.setField(Label("Description "),0, 5, anchorLeft = 1)
- # get disk's info to prepopulate
- dev_bus,dev_name,dev_size,dev_desc,dev_serial,dev_model = self.disk_dict[self.root_disk_menu_list.current()].split(",",5)
- self.hostvg_checkbox.setCurrent(self.root_disk_menu_list.current())
- dev_name = dev_name.replace(" ", "")
- self.dev_name_label = Label(dev_name)
- self.dev_model_label = Label(dev_model)
- self.dev_bus_label = Label(dev_bus)
- self.dev_serial_label = Label(dev_serial)
- self.dev_size_label = Label(dev_size + "GB")
- self.dev_desc_label = Label(dev_desc)
- disk_grid.setField(self.dev_name_label,1, 0, anchorLeft = 1)
- disk_grid.setField(self.dev_model_label,1, 1, anchorLeft = 1)
- disk_grid.setField(self.dev_bus_label,1, 2, anchorLeft = 1)
- disk_grid.setField(self.dev_serial_label,1, 3, anchorLeft = 1)
- disk_grid.setField(self.dev_size_label,1, 4, anchorLeft = 1)
- disk_grid.setField(self.dev_desc_label,1, 5, anchorLeft = 1)
- elements.setField(disk_grid, 0,6, anchorLeft = 1, padding = (0,0,0,1))
- return [Label(""), elements]
-
- def other_device_root_page(self):
- elements = Grid(2, 8)
- elements.setField(Label("Please enter the disk to use for booting %s" % PRODUCT_SHORT), 0, 0, anchorLeft = 1)
- self.root_device = Entry(35)
- self.root_device.setCallback(self.other_device_root_callback)
- elements.setField(self.root_device, 0,1, anchorLeft = 1, padding = (0,1,0,14))
- return [Label(""), elements]
-
- def other_device_hostvg_page(self):
- elements = Grid(2, 8)
- elements.setField(Label("Please select the disk(s) to use for installation of %s" % PRODUCT_SHORT), 0, 0, anchorLeft = 1)
- elements.setField(Label("Enter multiple entries separated by commas"), 0, 1, anchorLeft = 1)
- self.hostvg_device = Entry(35)
- self.hostvg_device.setCallback(self.other_device_hostvg_callback)
- elements.setField(self.hostvg_device, 0, 2, anchorLeft = 1, padding = (0,1,0,13))
- return [Label(""), elements]
-
- def storage_vol_page(self):
- elements = Grid(2,8)
- Storage = storage.Storage()
- elements.setField(Label("Please enter the sizes for the following partitions in MB"),0,0,anchorLeft=1)
- vol_elements = Grid(3,8)
- vol_elements.setField(Label("UEFI/Bios: "),0,0,anchorLeft=1)
- self.UEFI_SIZE = Entry(10)
- if "OVIRT_VOL_EFI_SIZE" in OVIRT_VARS:
- self.UEFI_SIZE.set(OVIRT_VARS["OVIRT_VOL_EFI_SIZE"])
- else:
- self.UEFI_SIZE.set(str(Storage.EFI_SIZE))
- self.UEFI_SIZE.setFlags(_snack.FLAG_DISABLED, 0)
- vol_elements.setField(self.UEFI_SIZE,1,0)
- vol_elements.setField(Label("Root & RootBackup: "),0,1,anchorLeft=1)
- self.ROOT_SIZE = Entry(10)
- if "OVIRT_VOL_ROOT_SIZE" in OVIRT_VARS:
- self.ROOT_SIZE.set(OVIRT_VARS["OVIRT_VOL_ROOT_SIZE"])
- else:
- self.ROOT_SIZE.set(str(Storage.ROOT_SIZE))
- self.ROOT_SIZE.setFlags(_snack.FLAG_DISABLED, 0)
- vol_elements.setField(self.ROOT_SIZE,1,1)
- vol_elements.setField(Label(" (2 partitions at 256MB each)"),2,1,anchorLeft=1)
- vol_elements.setField(Label("Swap: "),0,2,anchorLeft=1)
- self.SWAP_SIZE = Entry(10)
- if "OVIRT_VOL_SWAP_SIZE" in OVIRT_VARS:
- self.SWAP_SIZE.set(OVIRT_VARS["OVIRT_VOL_SWAP_SIZE"])
- else:
- self.SWAP_SIZE.set(str(self.get_def_swap_size(Storage.overcommit)))
- self.SWAP_SIZE.setCallback(self.swap_size_callback)
- vol_elements.setField(self.SWAP_SIZE,1,2)
- vol_elements.setField(Label("Config: "),0,3,anchorLeft=1)
- self.CONFIG_SIZE = Entry(10)
- if "OVIRT_VOL_CONFIG_SIZE" in OVIRT_VARS:
- self.CONFIG_SIZE.set(OVIRT_VARS["OVIRT_VOL_CONFIG_SIZE"])
- else:
- self.CONFIG_SIZE.set(str(Storage.CONFIG_SIZE))
- self.CONFIG_SIZE.setCallback(self.config_size_callback)
- vol_elements.setField(self.CONFIG_SIZE,1,3)
- vol_elements.setField(Label("Logging: "),0,4,anchorLeft=1)
- self.LOGGING_SIZE = Entry(10)
- if "OVIRT_VOL_LOGGING_SIZE" in OVIRT_VARS:
- self.LOGGING_SIZE.set(OVIRT_VARS["OVIRT_VOL_LOGGING_SIZE"])
- else:
- self.LOGGING_SIZE.set(str(Storage.LOGGING_SIZE))
- self.LOGGING_SIZE.setCallback(self.log_size_callback)
- vol_elements.setField(self.LOGGING_SIZE,1,4)
- vol_elements.setField(Label("Data: "),0,5,anchorLeft=1)
- self.DATA_SIZE = Entry(10)
- if "OVIRT_VOL_DATA_SIZE" in OVIRT_VARS:
- self.DATA_SIZE.set(OVIRT_VARS["OVIRT_VOL_DATA_SIZE"])
- else:
- self.DATA_SIZE.set(str(Storage.DATA_SIZE))
- self.DATA_SIZE.setCallback(self.data_size_callback)
- vol_elements.setField(self.DATA_SIZE,1,5)
- elements.setField(Label(""),0,1)
- elements.setField(vol_elements,0,2,anchorLeft=1)
- self.vol_msg = Textbox(60,4,"",wrap=1)
- elements.setField(self.vol_msg,0,3,padding=(0,1,0,4))
- return [Label(""), elements]
-
-
- def password_page(self):
- elements = Grid(2, 8)
- pw_elements = Grid (3,3)
- elements.setField(Label("Require a password for local console access?"), 0, 0, anchorLeft = 1)
- elements.setField(Label(" "), 0, 1, anchorLeft = 1)
- elements.setField(Label(" "), 0, 4)
- pw_elements.setField(Label("Password: "), 0, 1, anchorLeft = 1)
- pw_elements.setField(Label("Confirm Password: "), 0, 2, anchorLeft = 1)
- self.root_password_1 = Entry(15,password = 1)
- self.root_password_1.setCallback(self.password_check_callback)
- self.root_password_2 = Entry(15,password = 1)
- self.root_password_2.setCallback(self.password_check_callback)
- pw_elements.setField(self.root_password_1, 1,1)
- pw_elements.setField(self.root_password_2, 1,2)
- elements.setField(pw_elements, 0, 5, anchorLeft = 1)
- self.pw_msg = Textbox(60, 6, "", wrap=1)
- elements.setField(self.pw_msg, 0, 6, padding = (0,1,0,5))
- return [Label(""), elements]
-
- def upgrade_page(self):
- elements = Grid(2, 9)
- pw_elements = Grid (3,8)
- self.current_password = Entry(15,password = 1)
- self.root_password_1 = Entry(15,password = 1)
- self.root_password_2 = Entry(15,password = 1)
-
- if pwd_set_check("admin"):
- elements.setField(Label("Please enter the current admin password. You may also change the"), 0, 1, anchorLeft = 1)
- elements.setField(Label("admin password if required. If new password fields are left blank"), 0, 2, anchorLeft = 1)
- elements.setField(Label("the password will remain the same."), 0, 3, anchorLeft = 1)
-
- pw_elements.setField(Label("Current Password: "), 0, 1, anchorLeft = 1)
- self.current_password.setCallback(self.current_password_callback)
- pw_elements.setField(self.current_password, 1, 1)
- elements.setField(Label("Password for local console access"), 0, 4, anchorLeft = 1)
- elements.setField(Label(" "), 0, 5)
- pw_elements.setField(Label("Password: "), 0, 2, anchorLeft = 1)
- pw_elements.setField(Label("Confirm Password: "), 0, 3, anchorLeft = 1)
- self.root_password_1.setCallback(self.password_check_w_empty_callback)
- self.root_password_2.setCallback(self.password_check_w_empty_callback)
- pw_elements.setField(self.root_password_1, 1,2)
- pw_elements.setField(self.root_password_2, 1,3)
- elements.setField(pw_elements, 0, 6, anchorLeft = 1)
- self.pw_msg = Textbox(60, 6, "", wrap=1)
- elements.setField(self.pw_msg, 0, 7, padding = (0,1,0,1))
- return [Label(""), elements]
-
- def get_elements_for_page(self, screen, page):
- if page == WELCOME_PAGE:
- return self.install_page()
- if page == KEYBOARD_PAGE:
- return self.keyboard_page()
- if page == ROOT_STORAGE_PAGE:
- return self.root_disk_page()
- if page == OTHER_DEVICE_ROOT_PAGE:
- return self.other_device_root_page()
- if page == OTHER_DEVICE_HOSTVG_PAGE:
- return self.other_device_hostvg_page()
- if page == HOSTVG_STORAGE_PAGE:
- return self.hostvg_disk_page()
- if page == STORAGE_VOL_PAGE:
- return self.storage_vol_page()
- if page == PASSWORD_PAGE:
- return self.password_page()
- if page == FAILED_PAGE:
- return self.failed_install_page()
- if page == UPGRADE_PAGE:
- return self.upgrade_page()
- if page == FINISHED_PAGE:
- return self.finish_install_page()
- return []
-
- def install_node(self):
- self.__current_page = FAILED_PAGE
- gridform = GridForm(self.screen, "", 2, 3)
- dev_name = self.storage_init.replace(" ","")
- gridform.add(Label("Partitioning and Creating File Systems On"), 0, 0)
- gridform.add(Label(dev_name), 0, 1)
- progress_bar = Scale(50,100)
- progress_bar.set(25)
- gridform.add(progress_bar, 0, 2)
- gridform.draw()
- self.screen.refresh()
- config_storage = storage.Storage()
- storage_setup = config_storage.perform_partitioning()
- if storage_setup:
- progress_bar.set(50)
- gridform = GridForm(self.screen, "", 2, 2)
- gridform.add(Label("Setting Root Password"), 0, 0)
- gridform.add(progress_bar, 0, 1)
- gridform.draw()
- self.screen.refresh()
- admin_pw_set = password.set_password(self.root_password_1.value(), "admin")
- if admin_pw_set:
- gridform.add(progress_bar, 0, 1)
- gridform.draw()
- self.screen.refresh()
- progress_bar.set(75)
- gridform = GridForm(self.screen, "", 2, 3)
- gridform.add(Label("Installing Bootloader Configuration On "), 0, 0)
- gridform.add(Label(dev_name), 0, 1)
- gridform.add(progress_bar, 0, 2)
- gridform.draw()
- self.screen.refresh()
- install = Install()
- boot_setup = install.ovirt_boot_setup()
- if boot_setup:
- progress_bar.set(100)
- self.__current_page = FINISHED_PAGE
-
- def upgrade_node(self):
- gridform = GridForm(self.screen, "", 2, 2)
- # can also cover downgrading/reinstalling so changed to "updating"
- gridform.add(Label("Updating Hypervisor"), 0, 0, anchorLeft = 1)
- progress_bar = Scale(50,100)
- progress_bar.set(75)
- gridform.add(progress_bar, 0, 1)
- gridform.draw()
- self.screen.refresh()
- admin_pw_set = False
- if len(self.root_password_1.value()) is 0:
- # Use the old password if no password is given.
- admin_pw_set = True
- else:
- admin_pw_set = password.set_password(self.root_password_1.value(), "admin")
- if admin_pw_set:
- install = Install()
- boot_setup = install.ovirt_boot_setup()
- progress_bar.set(100)
- self.__current_page = FINISHED_PAGE
- return
-
- def start(self):
- self.set_console_colors()
- active = True
- while active and (self.__finished == False):
- # reread defaults every refresh
- OVIRT_VARS = parse_defaults()
- self.screen = SnackScreen()
- screen = self.screen
- for item in self.__colorset.keys():
- colors = self.__colorset.get(item)
- screen.setColor(item, colors[0], colors[1])
- screen.pushHelpLine(" ")
- PRODUCT_TITLE = "%s %s-%s" % (PRODUCT_SHORT, PRODUCT_VERSION, PRODUCT_RELEASE)
- screen.drawRootText(1,0, "".ljust(78))
- screen.drawRootText(1,1, " %s" % PRODUCT_TITLE.ljust(75))
- screen.drawRootText(1,2, "".ljust(78))
- elements = self.get_elements_for_page(screen, self.__current_page)
- self.gridform = GridForm(screen, "", 8, 8)
- gridform = self.gridform
- content = Grid(1, len(elements) + 3) # extra = button bar + padding row
- current_element = 1
- for element in elements:
- # set the title of the page
- content.setField(element, 0, current_element, anchorLeft = 1)
- current_element += 1
- (fullwidth, fullheight) = _snack.size()
- current_element += 1
- buttons = []
- if self.__current_page == FINISHED_PAGE:
- buttons.append(["Reboot", REBOOT_BUTTON])
- if self.__current_page != FINISHED_PAGE:
- buttons.append(["Quit", QUIT_BUTTON])
- if self.__current_page != WELCOME_PAGE and self.__current_page != FAILED_PAGE and self.__current_page != FINISHED_PAGE:
- buttons.append(["Back", BACK_BUTTON])
- if self.__current_page == HOSTVG_STORAGE_PAGE or self.__current_page == ROOT_STORAGE_PAGE or self.__current_page == UPGRADE_PAGE or self.__current_page == STORAGE_VOL_PAGE:
- buttons.append(["Continue", CONTINUE_BUTTON])
- if self.__current_page == OTHER_DEVICE_ROOT_PAGE or self.__current_page == OTHER_DEVICE_HOSTVG_PAGE:
- buttons.append(["Continue", CONTINUE_BUTTON])
- if self.__current_page == PASSWORD_PAGE:
- buttons.append(["Install", INSTALL_BUTTON])
- if self.__current_page == FAILED_PAGE:
- buttons.append(["Reboot", REBOOT_BUTTON])
- buttons.append(["Power Off", POWEROFF_BUTTON])
- buttonbar = ButtonBar(screen, buttons, compact = 1)
- buttongrid = Grid(1,1)
- if self.__current_page == FINISHED_PAGE:
- buttongrid.setField(buttonbar, 0, 0, padding = (9,0,0,0))
- buttongrid_anchor = 0
- else:
- buttongrid.setField(buttonbar, 0, 0, anchorLeft = 1)#, growx = 0)
- buttongrid_anchor = 1
-
- current_element += 1
- gridform.add(content, 2, 0, anchorTop = 1)
- if self.__current_page == FINISHED_PAGE:
- gridform.add(buttongrid, 2, 1, anchorLeft = buttongrid_anchor, padding = (6,0,0,0))
- else:
- gridform.add(buttongrid, 2, 1, anchorLeft = buttongrid_anchor)
- gridform.addHotKey("F2")
- gridform.addHotKey("F3")
- try:
- (top, left) = (1, 4)
- result = gridform.runOnce(top, left)
- pressed = buttonbar.buttonPressed(result)
- menu_choice = self.menu_list.current()
- self.screen.setColor("BUTTON", "black", "red")
- self.screen.setColor("ACTBUTTON", "blue", "white")
- if result == "F2" or pressed == SHELL_BUTTON:
- warn = ButtonChoiceWindow(self.screen, "Support Shell", "This is for troubleshooting with support representatives. Do not use this option without guidance from support.")
- if warn == "ok":
- screen.popWindow()
- screen.finish()
- system_closefds("/usr/bin/clear;SHELL=/bin/bash /bin/bash")
- elif pressed == QUIT_BUTTON:
- abort = ButtonChoiceWindow(self.screen, "Abort Installation","The installation of %s is not complete." %
- PRODUCT_SHORT, buttons = ['Back','Reboot','Shutdown'])
- if abort == "reboot":
- system_closefds("/usr/bin/clear;reboot")
- elif abort == "shutdown":
- system_closefds("/usr/bin/clear;halt")
- elif pressed == REBOOT_BUTTON:
- screen.finish()
- system_closefds("/usr/bin/clear;/sbin/reboot")
- elif pressed == POWEROFF_BUTTON:
- system_closefds("/usr/bin/clear;halt")
- elif pressed == BACK_BUTTON:
- self.get_back_page()
- elif not result == "F2":
- if self.__current_page == WELCOME_PAGE and self.failed_install == False:
- self.__current_page = KEYBOARD_PAGE
- elif self.__current_page == KEYBOARD_PAGE:
- self.process_keyboard_config()
- if menu_choice == 1:
- self.__current_page = ROOT_STORAGE_PAGE
- elif menu_choice == 3:
- self.__current_page = UPGRADE_PAGE
- elif self.__current_page == ROOT_STORAGE_PAGE:
- self.storage_init = self.root_disk_menu_list.current()
- if self.storage_init == "OtherDevice":
- self.__current_page = OTHER_DEVICE_ROOT_PAGE
- elif self.storage_init == "NoDevices":
- ButtonChoiceWindow(self.screen, "Root Storage Selection", "You must enter a valid device", buttons = ['Ok'])
- self.__current_page = ROOT_STORAGE_PAGE
- else:
- if not tui_check_fakeraid(self.storage_init, self.screen):
- continue
- augtool("set", "/files/" + OVIRT_DEFAULTS + "/OVIRT_INIT", '"' + self.storage_init + '"')
- augtool("set", "/files/" + OVIRT_DEFAULTS + "/OVIRT_ROOT_INSTALL", '"y"')
- self.__current_page = HOSTVG_STORAGE_PAGE
- elif self.__current_page == OTHER_DEVICE_ROOT_PAGE:
- if not self.root_device.value():
- ButtonChoiceWindow(self.screen, "Root Storage Selection", "You must enter a valid device", buttons = ['Ok'])
- self.__current_page == OTHER_DEVICE_ROOT_PAGE
- else:
- if self.failed_block_dev == 0:
- self.storage_init = translate_multipath_device(self.root_device.value())
- if not tui_check_fakeraid(self.storage_init, self.screen):
- continue
- augtool("set", "/files/" + OVIRT_DEFAULTS + "/OVIRT_INIT", '"' + self.storage_init + '"')
- augtool("set", "/files/" + OVIRT_DEFAULTS + "/OVIRT_ROOT_INSTALL", '"y"')
- self.__current_page = HOSTVG_STORAGE_PAGE
- else:
- self.__current_page = OTHER_DEVICE_ROOT_PAGE
- elif self.__current_page == HOSTVG_STORAGE_PAGE:
- self.hostvg_init = self.hostvg_checkbox.getSelection()
- if not self.hostvg_checkbox.getSelection():
- ButtonChoiceWindow(self.screen, "HostVG Storage Selection", "You must select a HostVG device", buttons = ['Ok'])
- self.__current_page = HOSTVG_STORAGE_PAGE
- else:
- if "OtherDevice" in self.hostvg_init:
- self.__current_page = OTHER_DEVICE_HOSTVG_PAGE
- else:
- hostvg_list = ""
- for dev in self.hostvg_init:
- if not tui_check_fakeraid(dev, self.screen):
- continue
- hostvg_list += dev + ","
- augtool("set", "/files/" + OVIRT_DEFAULTS + "/OVIRT_INIT", '"' + self.storage_init + "," + hostvg_list + '"')
- if check_existing_hostvg(""):
- self.screen.setColor("BUTTON", "black", "red")
- self.screen.setColor("ACTBUTTON", "blue", "white")
- msg = "Existing HostVG Detected on %s, Please reboot from media and choose Reinstall" % check_existing_hostvg("")
- warn = ButtonChoiceWindow(self.screen, "HostVG Check", msg, buttons = ['Reboot'])
- self.reset_screen_colors()
- if warn != "ok":
- self.exit_stop_boot_and_run("reboot")
- else:
- self.__current_page = STORAGE_VOL_PAGE
- elif self.__current_page == OTHER_DEVICE_HOSTVG_PAGE:
- if not self.hostvg_device.value():
- ButtonChoiceWindow(self.screen, "HostVG Storage Selection", "You must enter a valid device", buttons = ['Ok'])
- else:
- if self.failed_block_dev == 0:
- self.hostvg_init = ""
- for device in self.hostvg_device.value().split(","):
- self.hostvg_init += translate_multipath_device(device) + ","
- hostvg_list = ""
- for dev in self.hostvg_init.split(","):
- if not tui_check_fakeraid(dev, self.screen):
- continue
- hostvg_list += dev + ","
- augtool("set", "/files/" + OVIRT_DEFAULTS + "/OVIRT_INIT", '"' + self.storage_init + "," + hostvg_list + '"')
- self.__current_page = STORAGE_VOL_PAGE
- else:
- self.__current_page = OTHER_DEVICE_HOSTVG_PAGE
- elif self.__current_page == STORAGE_VOL_PAGE:
- if ( self.swap_vol_failed or self.log_vol_failed or
- self.config_vol_failed or self.data_vol_failed):
- ButtonChoiceWindow(self.screen, "Error", self.format_storage_vol_msg(), buttons=['OK'])
- self.__current_page=STORAGE_VOL_PAGE
- continue
- else:
- augtool("set", "/files/" + OVIRT_DEFAULTS + "/OVIRT_VOL_ROOT_SIZE", '"' + self.ROOT_SIZE.value() + '"')
- augtool("set", "/files/" + OVIRT_DEFAULTS + "/OVIRT_VOL_EFI_SIZE", '"' + self.UEFI_SIZE.value() + '"')
- augtool("set", "/files/" + OVIRT_DEFAULTS + "/OVIRT_VOL_SWAP_SIZE", '"' + self.SWAP_SIZE.value() + '"')
- augtool("set", "/files/" + OVIRT_DEFAULTS + "/OVIRT_VOL_LOGGING_SIZE", '"' + self.LOGGING_SIZE.value() + '"')
- augtool("set", "/files/" + OVIRT_DEFAULTS + "/OVIRT_VOL_CONFIG_SIZE", '"' + self.CONFIG_SIZE.value() + '"')
- augtool("set", "/files/" + OVIRT_DEFAULTS + "/OVIRT_VOL_DATA_SIZE", '"' + self.DATA_SIZE.value() + '"')
- s = storage.Storage()
- if not s.check_partition_sizes():
- msg = "Not enough space for installation\nPlease select a bigger drive\nor change the partition sizes.\n\nAvailable Space: %sMB\nRequired Space: %sMB\n" % (s.drive_disk_size, s.drive_need_size)
- warn = ButtonChoiceWindow(self.screen, "Disk Space Check", msg, buttons = ['Ok'])
- self.__current_page = STORAGE_VOL_PAGE
- else:
- self.__current_page=PASSWORD_PAGE
- elif self.__current_page == UPGRADE_PAGE:
- if self.current_password_fail is not 1:
- if self.valid_password == 0:
- self.upgrade_node()
- else:
- ButtonChoiceWindow(self.screen, "Password Check", "You must enter a valid password", buttons = ['Ok'])
- self.__current_page = UPGRADE_PAGE
- elif self.__current_page == PASSWORD_PAGE:
- if self.valid_password == 0:
- self.install_node()
- else:
- ButtonChoiceWindow(self.screen, "Password Check", "You must enter a valid password", buttons = ['Ok'])
- self.__current_page = PASSWORD_PAGE
- elif self.__current_page == FAILED_PAGE:
- f = self.log_menu_list.current()
- log = open(f)
- log = log.read()
- ButtonChoiceWindow(screen, "Log Viewer", log, buttons=['Ok'], width=68, x = 1, y = 6)
-
- except Exception, error:
- self.screen.setColor("BUTTON", "black", "red")
- self.screen.setColor("ACTBUTTON", "blue", "white")
- ButtonChoiceWindow(screen,
- "An Exception Has Occurred",
- str(error) + "\n" + traceback.format_exc(),
- buttons = ["OK"])
- screen.popWindow()
- screen.finish()
- self.restore_console_colors()
-
-if __name__ == "__main__":
- screen = NodeInstallScreen()
- screen.start()
diff --git a/scripts/legacy/ovirt-config-setup.py b/scripts/legacy/ovirt-config-setup.py
deleted file mode 100755
index 6a70a95..0000000
--- a/scripts/legacy/ovirt-config-setup.py
+++ /dev/null
@@ -1,2274 +0,0 @@
-#!/usr/bin/env python
-#
-# ovirt-config-setup.py - Copyright (C) 2010 Red Hat, Inc.
-# Written by Joey Boggs <jboggs at redhat.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# 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 General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-# MA 02110-1301, USA. A copy of the GNU General Public License is
-# also available at http://www.gnu.org/copyleft/gpl.html.
-
-from snack import *
-import _snack
-import os
-import traceback
-import fcntl
-import libvirt
-import PAM
-import gudev
-import pkgutil
-import ovirt_config_setup
-import sys
-import time
-from ovirtnode.ovirtfunctions import *
-from ovirtnode.password import *
-from ovirtnode.log import *
-from ovirtnode.network import *
-from ovirtnode.kdump import *
-from ovirtnode.iscsi import *
-
-OK_BUTTON = "OK"
-BACK_BUTTON = "Back"
-RESET_BUTTON = "Reset"
-CANCEL_BUTTON = "Cancel"
-APPLY_BUTTON = "Apply"
-IDENTIFY_BUTTON = "Identify NIC"
-PING_BUTTON = "Ping Test"
-LOCK_BUTTON = "Lock"
-RESTART_BUTTON = "Restart"
-POWER_OFF_BUTTON = "Power Off"
-UNLOCK_BUTTON = "Unlock"
-MENU_BUTTON = "Back to Menu"
-LOG_OFF_BUTTON = "Log Off"
-login_password = ""
-
-STATUS_PAGE = 1
-NETWORK_PAGE = 2
-AUTHENTICATION_PAGE = 3
-KEYBOARD_PAGE = 4
-LOGGING_PAGE = 5
-KDUMP_PAGE = 6
-LAST_OPTION = REMOTE_STORAGE_PAGE = 7
-# max. 3 plugin menu options/pages: 13,15,17
-FIRST_PLUGIN_PAGE = 8
-LAST_PLUGIN_PAGE = 13
-#
-NETWORK_DETAILS_PAGE = 19
-SUPPORT_PAGE = 21
-LOCKED_PAGE = 99
-
-OVIRT_VARS = parse_defaults()
-
-
-def pam_conv(auth, query_list):
- global login_password
- resp = []
- for i in range(len(query_list)):
- resp.append((login_password, 0))
- return resp
-
-
-class NodeConfigScreen():
- """
- User interface for Hypervisor Node Configuration.
- """
-
- def __init__(self):
- _console_colorset = {
- "ROOT": ("gray", "magenta"),
- "BORDER": ("magenta", "magenta"),
- "WINDOW": ("magenta", "magenta"),
- "ACTBUTTON": ("blue", "white"),
- "BUTTON": ("blue", "white"),
- "COMPACTBUTTON": ("black", "magenta"),
- "LISTBOX": ("green", "red"),
- "ACTLISTBOX": ("cyan", "red"),
- "ACTSELLISTBOX": ("blue", "white"),
- "TEXTBOX": ("cyan", "magenta"),
- "ENTRY": ("cyan", "magenta"),
- "DISENTRY": ("white", "cyan"),
- "SHADOW": ("magenta", "magenta"),
- "LABEL": ("brown", "magenta"),
- "TITLE": ("white", "blue"),
- "HELPLINE": ("cyan", "magenta"),
- "EMPTYSCALE": ("white", "cyan"),
- "FULLSCALE": ("cyan", "white"),
- "CHECKBOX": ("black", "red"),
- "ACTCHECKBOX": ("blue", "white")
- }
- _alternate_colorset = {
- "ROOT": ("white", "white"),
- "HELPLINE": ("white", "white"),
- "SHADOW": ("white", "white"),
- "BORDER": ("white", "white"),
- "ACTBUTTON": ("white", "blue"),
- "BUTTON": ("blue", "white"),
- "TITLE": ("white", "blue"),
- "EMPTYSCALE": ("white", "cyan"),
- "FULLSCALE": ("black", "white"),
- "CHECKBOX": ("blue", "white"),
- "ROOTTEXT": ("white", "blue"),
- "ACTSELLISTBOX": ("white", "black"),
- "LABEL": ("black", "white"),
- }
-
- if is_console():
- self.__colorset = _console_colorset
- else:
- self.__colorset = _alternate_colorset
- self.__current_page = 1
- self.__finished = False
- self.__nic_config_failed = 0
- self.net_apply_config = 0
- self._plugins_enabled = False
- self._plugins_pagenum = 0
- self._ping_test = False
- self.INVALID_KDUMP_MSG = ""
-
-
- def _set_title(self):
- PRODUCT_TITLE = "%s %s-%s" % (PRODUCT_SHORT, PRODUCT_VERSION,
- PRODUCT_RELEASE)
- self.screen.drawRootText(1, 0, "".ljust(78))
- self.screen.drawRootText(1, 1, " %s" % PRODUCT_TITLE.ljust(76))
- self.screen.drawRootText(1, 2, " %s" % os.uname()[1].ljust(76))
-
- def _create_blank_screen(self):
- self.screen = SnackScreen()
- self.reset_screen_colors()
- self._gridform = GridForm(self.screen, "", 2, 2)
- self.screen.pushHelpLine(" ")
- if not self._plugins_enabled:
- self._set_title()
- return self._gridform
-
- def _create_warn_screen(self):
- self._create_blank_screen()
- if is_console():
- self.screen.setColor("BUTTON", "black", "red")
- self.screen.setColor("ACTBUTTON", "blue", "white")
-
- def set_console_colors(self):
- self.existing_color_array = None
- tty_file = None
- try:
- tty_file = open("/dev/tty", "rw")
- except:
- pass
- if tty_file == None:
- tty_file = open("/dev/console", "rw")
- try:
- self._set_colors(tty_file)
- except:
- pass
- finally:
- tty_file.close()
-
- def _set_colors(self, tty_file):
- GIO_CMAP = 0x4B70
- PIO_CMAP = 0x4B71
- self.existing_color_array = bytearray(fcntl.ioctl(tty_file.fileno(),
- GIO_CMAP, b"\x00" * 48))
- color_array = self.existing_color_array
- color_array[3] = 0xde
- color_array[4] = 0xde
- color_array[5] = 0xde
- color_array[6] = 0x30
- color_array[7] = 0x30
- color_array[8] = 0x30
- color_array[9] = 0x52
- color_array[10] = 0x52
- color_array[11] = 0x52
- color_array[12] = 0x00
- color_array[13] = 0xbb
- color_array[14] = 0xff
- color_array[15] = 0xea
- color_array[16] = 0xea
- color_array[17] = 0xea
- color_array[18] = 0x71
- color_array[19] = 0x71
- color_array[20] = 0x71
- color_array[21] = 0xff
- color_array[22] = 0xff
- color_array[23] = 0xff
- fcntl.ioctl(tty_file.fileno(), PIO_CMAP, bytes(color_array))
-
- def restore_console_colors(self):
- if is_console():
- if self.existing_color_array == None:
- return
- tty_file = None
- try:
- tty_file = open("/dev/tty", "rw")
- except:
- pass
- if tty_file == None:
- tty_file = open("/dev/console", "rw")
- try:
- self._restore_colors(tty_file)
- except:
- pass
- finally:
- tty_file.close()
-
- def _restore_colors(self, tty_file):
- GIO_CMAP = 0x4B70
- PIO_CMAP = 0x4B71
- fcntl.ioctl(tty_file.fileno(), PIO_CMAP,
- bytes(self.existing_color_array))
-
- def reset_screen_colors(self):
- for item in self.__colorset.keys():
- colors = self.__colorset.get(item)
- self.screen.setColor(item, colors[0], colors[1])
-
- def get_elements_for_page(self, screen, page):
- if page == STATUS_PAGE:
- return self.status_page(screen)
- if page == NETWORK_PAGE:
- return self.network_configuration_page(screen)
- if page == AUTHENTICATION_PAGE:
- return self.authentication_configuration_page(screen)
- if page == KEYBOARD_PAGE:
- return self.keyboard_configuration_page(screen)
- if page == LOGGING_PAGE:
- return self.logging_configuration_page(screen)
- if page == KDUMP_PAGE:
- return self.kdump_configuration_page(screen)
- if page == REMOTE_STORAGE_PAGE:
- return self.remote_storage_configuration_page(screen)
- if page == NETWORK_DETAILS_PAGE:
- return self.network_details_page(screen)
- if page == SUPPORT_PAGE:
- return self.support_page(screen)
- if page == LOCKED_PAGE:
- return self.screen_locked_page(screen)
- # plugin pages
- plugin_page = FIRST_PLUGIN_PAGE
- for p in self.plugins:
- if page == plugin_page:
- return p.form()
- plugin_page += 1
- if plugin_page > LAST_PLUGIN_PAGE:
- # should not happen
- return None
-
- def network_proto_Callback(self):
- return
-
- def nic_lb_callback(self):
- try:
- get_ip_address(self.nic_lb.current())
- self.nic_disabled.setFlags(_snack.FLAG_DISABLED,
- _snack.FLAGS_RESET)
- except:
- self.nic_disabled.setFlags(_snack.FLAG_DISABLED, _snack.FLAGS_SET)
- return
-
- def nic_dhcp_callback(self):
- if self.nic_dhcp.value() == 1:
- flag = _snack.FLAGS_SET
- else:
- flag = _snack.FLAGS_RESET
- for i in self.netdevip, self.netdevmask, self.netdevgateway:
- i.setFlags(_snack.FLAG_DISABLED, flag)
- return
-
- def dns_host1_callback(self):
- warn = 0
- if (not self.dns_host1.value() is None and
- not self.dns_host1.value() == ""):
- if not is_valid_ipv4(self.dns_host1.value()):
- if not is_valid_ipv6(self.dns_host1.value()):
- warn = 1
- if warn == 1:
- self._create_warn_screen()
- ButtonChoiceWindow(self.screen, "Network", "Invalid IP Address",
- buttons=['Ok'])
- self.dns_host1.set("")
- self.reset_screen_colors()
- self.gridform.draw()
- self._set_title()
- return
-
- def dns_host2_callback(self):
- warn = 0
- if (not self.dns_host2.value() is None and
- not self.dns_host2.value() == ""):
- if not is_valid_ipv4(self.dns_host2.value()):
- if not is_valid_ipv6(self.dns_host1.value()):
- warn = 1
- if warn == 1:
- self._create_warn_screen()
- ButtonChoiceWindow(self.screen, "Network", "Invalid IP Address",
- buttons=['Ok'])
- self.dns_host2.set("")
- self.reset_screen_colors()
- self.gridform.draw()
- self._set_title()
- return
-
- def ntp_host1_callback(self):
- warn = 0
- if (not self.ntp_host1.value() is None and
- not self.ntp_host1.value() == ""):
- if not is_valid_ipv4(self.ntp_host1.value()):
- if not is_valid_ipv6(self.ntp_host1.value()):
- if not is_valid_hostname(self.ntp_host1.value()):
- warn = 1
- if warn == 1:
- self._create_warn_screen()
- ButtonChoiceWindow(self.screen, "Network", "Invalid IP Address",
- buttons=['Ok'])
- self.ntp_host1.set("")
- self.reset_screen_colors()
- self.gridform.draw()
- self._set_title()
- return
-
- def ntp_host2_callback(self):
- warn = 0
- if (not self.ntp_host2.value() is None and
- not self.ntp_host2.value() == ""):
- if not is_valid_ipv4(self.ntp_host2.value()):
- if not is_valid_ipv6(self.ntp_host2.value()):
- if not is_valid_hostname(self.ntp_host2.value()):
- warn = 1
- if warn == 1:
- self._create_warn_screen()
- ButtonChoiceWindow(self.screen, "Network", "Invalid IP Address",
- buttons=['Ok'])
- self.ntp_host2.set("")
- self.reset_screen_colors()
- self.gridform.draw()
- self._set_title()
- return
-
- def ipv4_ip_callback(self):
- warn = 0
- if (not self.ipv4_netdevip.value() is None and
- not self.ipv4_netdevip.value() == ""):
- if not is_valid_ipv4(self.ipv4_netdevip.value()):
- warn = 1
- if warn == 1:
- self._create_warn_screen()
- ButtonChoiceWindow(self.screen, "Network", "Invalid IP Address",
- buttons=['Ok'])
- self.ipv4_netdevip.set("")
- self.reset_screen_colors()
- self.gridform.draw()
- self._set_title()
- return
-
- def ipv4_netmask_callback(self):
- warn = 0
- if (not self.ipv4_netdevmask.value() is None and
- not self.ipv4_netdevmask.value() == ""):
- if not is_valid_ipv4(self.ipv4_netdevmask.value()):
- warn = 1
- if warn == 1:
- self._create_warn_screen()
- ButtonChoiceWindow(self.screen, "Network", "Invalid IP Address",
- buttons=['Ok'])
- self.ipv4_netdevmask.set("")
- self.reset_screen_colors()
- self.gridform.draw()
- self._set_title()
- return
-
- def ipv4_gateway_callback(self):
- warn = 0
- if (not self.ipv4_netdevgateway.value() is None and
- not self.ipv4_netdevgateway.value() == ""):
- if not is_valid_ipv4(self.ipv4_netdevgateway.value()):
- warn = 1
- if warn == 1:
- self._create_warn_screen()
- ButtonChoiceWindow(self.screen, "Network", "Invalid IP Address",
- buttons=['Ok'])
- self.ipv4_netdevgateway.set("")
- self.reset_screen_colors()
- self.gridform.draw()
- self._set_title()
- return
-
- def ipv4_disabled_callback(self):
- if self.disabled_ipv4_nic_proto.value() == 1:
- flag = _snack.FLAGS_SET
- for i in (self.ipv4_netdevip, self.ipv4_netdevmask,
- self.ipv4_netdevgateway):
- i.setFlags(_snack.FLAG_DISABLED, flag)
- self.dhcp_ipv4_nic_proto.setValue(" 0")
- self.static_ipv4_nic_proto.setValue(" 0")
- if self.netvlanid:
- self.netvlanid.setFlags(_snack.FLAG_DISABLED, _snack.FLAGS_SET)
-
- def ipv4_dhcp_callback(self):
- if self.dhcp_ipv4_nic_proto.value() == 1:
- flag = _snack.FLAGS_SET
- for i in (self.ipv4_netdevip, self.ipv4_netdevmask,
- self.ipv4_netdevgateway):
- i.setFlags(_snack.FLAG_DISABLED, flag)
- self.disabled_ipv4_nic_proto.setValue(" 0")
- self.static_ipv4_nic_proto.setValue(" 0")
- if self.netvlanid:
- self.netvlanid.setFlags(_snack.FLAG_DISABLED, _snack.FLAGS_RESET)
-
- def ipv4_static_callback(self):
- if self.static_ipv4_nic_proto.value() == 1:
- flag = _snack.FLAGS_RESET
- for i in (self.ipv4_netdevip, self.ipv4_netdevmask,
- self.ipv4_netdevgateway):
- i.setFlags(_snack.FLAG_DISABLED, flag)
- self.disabled_ipv4_nic_proto.setValue(" 0")
- self.dhcp_ipv4_nic_proto.setValue(" 0")
- if self.netvlanid:
- self.netvlanid.setFlags(_snack.FLAG_DISABLED, _snack.FLAGS_RESET)
-
- def ipv6_disabled_callback(self):
- if self.disabled_ipv6_nic_proto.value() == 1:
- flag = _snack.FLAGS_SET
- for i in (self.ipv6_netdevip, self.ipv6_netdevmask,
- self.ipv6_netdevgateway):
- i.setFlags(_snack.FLAG_DISABLED, flag)
- self.dhcp_ipv6_nic_proto.setValue(" 0")
- self.static_ipv6_nic_proto.setValue(" 0")
- self.auto_ipv6_nic_proto.setValue(" 0")
-
- def ipv6_dhcp_callback(self):
- if self.dhcp_ipv6_nic_proto.value() == 1:
- flag = _snack.FLAGS_SET
- for i in (self.ipv6_netdevip, self.ipv6_netdevmask,
- self.ipv6_netdevgateway):
- i.setFlags(_snack.FLAG_DISABLED, flag)
- self.disabled_ipv6_nic_proto.setValue(" 0")
- self.static_ipv6_nic_proto.setValue(" 0")
- self.auto_ipv6_nic_proto.setValue(" 0")
-
- def ipv6_static_callback(self):
- if self.static_ipv6_nic_proto.value() == 1:
- flag = _snack.FLAGS_RESET
- for i in (self.ipv6_netdevip, self.ipv6_netdevmask,
- self.ipv6_netdevgateway):
- i.setFlags(_snack.FLAG_DISABLED, flag)
- self.disabled_ipv6_nic_proto.setValue(" 0")
- self.dhcp_ipv6_nic_proto.setValue(" 0")
- self.auto_ipv6_nic_proto.setValue(" 0")
-
- def ipv6_auto_callback(self):
- if self.auto_ipv6_nic_proto.value() == 1:
- flag = _snack.FLAGS_SET
- for i in (self.ipv6_netdevip, self.ipv6_netdevmask,
- self.ipv6_netdevgateway):
- i.setFlags(_snack.FLAG_DISABLED, flag)
- self.disabled_ipv6_nic_proto.setValue(" 0")
- self.dhcp_ipv6_nic_proto.setValue(" 0")
- self.static_ipv6_nic_proto.setValue(" 0")
-
- def ipv6_ip_callback(self):
- warn = 0
- if (not self.ipv6_netdevip.value() is None and
- not self.ipv6_netdevip.value() == ""):
- if not is_valid_ipv6(self.ipv6_netdevip.value()):
- warn = 1
- if warn == 1:
- self._create_warn_screen()
- ButtonChoiceWindow(self.screen, "Network", "Invalid IP Address",
- buttons=['Ok'])
- self.ipv6_netdevip.set("")
- self.reset_screen_colors()
- self.gridform.draw()
- self._set_title()
- return
-
- def ipv6_netmask_callback(self):
- warn = 0
- if (not self.ipv6_netdevmask.value() is None and
- not self.ipv6_netdevmask.value() == ""):
- try:
- if not int(self.ipv6_netdevmask.value()) in range(1, 128):
- warn = 1
- except:
- warn = 1
- if warn == 1:
- self._create_warn_screen()
- ButtonChoiceWindow(self.screen, "Network", "Invalid IPv6 Netmask",
- buttons=['Ok'])
- self.ipv6_netdevmask.set("")
- self.reset_screen_colors()
- self.gridform.draw()
- self._set_title()
- return
-
- def ipv6_gateway_callback(self):
- warn = 0
- if (not self.ipv6_netdevgateway.value() is None and
- not self.ipv6_netdevgateway.value() == ""):
- if not is_valid_ipv6(self.ipv6_netdevgateway.value()):
- warn = 1
- if warn == 1:
- self._create_warn_screen()
- ButtonChoiceWindow(self.screen, "Network", "Invalid IP Address",
- buttons=['Ok'])
- self.ipv6_netdevgateway.set("")
- self.reset_screen_colors()
- self.gridform.draw()
- self._set_title()
- return
-
- def netvlanid_callback(self):
- warn = 0
- try:
- if not self.netvlanid.value() == "":
- if (not int(self.netvlanid.value()) in range(1, 4095) or
- " " in self.netvlanid.value()):
- warn = 1
- except:
- warn = 1
- finally:
- if warn == 1:
- self._create_warn_screen()
- ButtonChoiceWindow(self.screen, "Configuration Check",
- "Invalid VLAN ID", buttons=['Ok'])
- self.reset_screen_colors()
- self.gridform.draw()
- self._set_title()
- self.netvlanid.set("")
-
- def password_check_callback(self):
- resp, msg = password_check(self.root_password_1.value(),
- self.root_password_2.value())
- self.pw_msg.setText(msg)
- return
-
- def valid_logrotate_max_size_callback(self):
- if not self.logrotate_max_size.value().isdigit():
- self._create_warn_screen()
- ButtonChoiceWindow(self.screen, "Configuration Check",
- "Invalid Log File Size", buttons=['Ok'])
- self.reset_screen_colors()
- self.logrotate_max_size.set("1024")
- self.gridform.draw()
- self._set_title()
-
- def valid_syslog_port_callback(self):
- if not is_valid_port(self.syslog_port.value()):
- self._create_warn_screen()
- ButtonChoiceWindow(self.screen, "Configuration Check",
- "Invalid Port Number", buttons=['Ok'])
- self.reset_screen_colors()
- self.syslog_port.set("514")
- self.gridform.draw()
- self._set_title()
-
- def valid_syslog_server_callback(self):
- if not is_valid_host_or_ip(self.syslog_server.value()):
- self._create_warn_screen()
- ButtonChoiceWindow(self.screen, "Configuration Check",
- "Invalid Hostname or Address", buttons=['Ok'])
- self.reset_screen_colors()
- self.syslog_server.set("")
- self.gridform.draw()
- self._set_title()
-
- def kdump_nfs_callback(self):
- self.kdump_ssh_type.setValue(" 0")
- self.kdump_restore_type.setValue(" 0")
- self.kdump_nfs_config.setFlags(_snack.FLAG_DISABLED,
- _snack.FLAGS_RESET)
- self.kdump_ssh_config.setFlags(_snack.FLAG_DISABLED, _snack.FLAGS_SET)
-
- def kdump_valid_nfs_callback(self):
- if len(self.kdump_nfs_config.value()) > 0:
- if not is_valid_nfs(self.kdump_nfs_config.value()):
- self._create_warn_screen()
- ButtonChoiceWindow(self.screen, "Configuration Check",
- "Invalid NFS Entry", buttons=['Ok'])
- self.reset_screen_colors()
- self.kdump_nfs_config.set("")
- self.gridform.draw()
- self._set_title()
- else:
- self.INVALID_KDUMP_MSG = "KDump NFS location cannot be empty"
-
- def kdump_ssh_callback(self):
- self.kdump_nfs_type.setValue(" 0")
- self.kdump_restore_type.setValue(" 0")
- self.kdump_nfs_config.setFlags(_snack.FLAG_DISABLED, _snack.FLAGS_SET)
- self.kdump_ssh_config.setFlags(_snack.FLAG_DISABLED,
- _snack.FLAGS_RESET)
-
- def kdump_valid_ssh_callback(self):
- if len(self.kdump_nfs_config.value()) > 0:
- if not is_valid_user_host(self.kdump_ssh_config.value()):
- self._create_warn_screen()
- ButtonChoiceWindow(self.screen, "Configuration Check",
- "Invalid SSH Entry", buttons=['Ok'])
- self.reset_screen_colors()
- self.kdump_ssh_config.set("")
- self.gridform.draw()
- self._set_title()
- else:
- self.INVALID_KDUMP_MSG = "KDump SSH location cannot be empty"
-
- def kdump_restore_callback(self):
- self.kdump_ssh_type.setValue(" 0")
- self.kdump_nfs_type.setValue(" 0")
- if self.kdump_restore_type.value() == 1:
- self.kdump_nfs_config.setFlags(_snack.FLAG_DISABLED, _snack.FLAGS_SET)
- self.kdump_ssh_config.setFlags(_snack.FLAG_DISABLED, _snack.FLAGS_SET)
- if self.kdump_ssh_type.value() == 0 and self.kdump_nfs_type.value() == 0:
- self.kdump_restore_type.setValue("*")
-
- def valid_netconsole_server_callback(self):
- if not is_valid_host_or_ip(self.netconsole_server.value()):
- self._create_warn_screen()
- ButtonChoiceWindow(self.screen, "Configuration Check",
- "Invalid NetConsole Hostname or Address",
- buttons=['Ok'])
- self.reset_screen_colors()
- self.netconsole_server.set("")
- self.gridform.draw()
- self._set_title()
-
- def valid_netconsole_server_port_callback(self):
- if not is_valid_port(self.netconsole_server_port.value()):
- self._create_warn_screen()
- ButtonChoiceWindow(self.screen, "Configuration Check",
- "Invalid NetConsole Server Port", buttons=['Ok'])
- self.reset_screen_colors()
- self.netconsole_server_port.set("6666")
- self.gridform.draw()
- self._set_title()
-
- def valid_hostname_callback(self):
- if not self.net_hostname.value() == "" or \
- len(self.net_hostname.value()) > 64:
- self._create_warn_screen()
- if len(self.net_hostname.value()) > 64:
- ButtonChoiceWindow(self.screen, "Configuration Check",
- "Hostname Too Long", buttons=['Ok'])
- self.net_hostname.set(self.net_hostname.value()[:64])
- if not is_valid_hostname(self.net_hostname.value()):
- ButtonChoiceWindow(self.screen, "Configuration Check",
- "Invalid Hostname", buttons=['Ok'])
- self.net_hostname.set("localhost.localdomain")
- self.reset_screen_colors()
- self.gridform.draw()
- self._set_title()
-
- def valid_iqn_callback(self):
- if not self.iscsi_initiator_config.value() == "":
- if not is_valid_iqn(self.iscsi_initiator_config.value()):
- self._create_warn_screen()
- ButtonChoiceWindow(self.screen, "Configuration Check",
- "Invalid IQN Format", buttons=['Ok'])
- self.reset_screen_colors()
- self.gridform.draw()
- self._set_title()
- self.iscsi_initiator_config.set(
- "iqn.1994-05.com.example:1234567890")
-
- def valid_fqdn_or_ipv4(self):
- warn = 0
- if not self.ntp_host1.value() == "":
- if not is_valid_ipv4(self.ntp_host1.value()):
- if not is_valid_hostname(self.ntp_host1.value()):
- if not is_valid_ipv6(self.ntp_host1.value()):
- warn = 1
- if not self.ntp_host2.value() == "":
- if not is_valid_ipv4(self.ntp_host2.value()):
- if not is_valid_hostname(self.ntp_host2.value()):
- if not is_valid_ipv6(self.ntp_host2.value()):
- warn = 1
-
- if not self.dns_host1.value() == "":
- if not is_valid_ipv4(self.dns_host1.value()):
- if not is_valid_ipv6(self.dns_host1.value()):
- warn = 1
- if not self.dns_host2.value() == "":
- if not is_valid_ipv4(self.dns_host2.value()):
- if not is_valid_ipv6(self.dns_host2.value()):
- warn = 1
- if warn == 1:
- self._create_warn_screen()
- ButtonChoiceWindow(self.screen, "Network", "Invalid IP/Hostname",
- buttons=['Ok'])
- self.reset_screen_colors()
- self.gridform.draw()
- self._set_title()
- return
-
- def valid_nfsv4_domain_callback(self):
- if len(self.nfsv4_domain.value()) > 0:
- if not is_valid_hostname(self.nfsv4_domain.value()):
- self.nfsv4_domain.set("")
- self._create_warn_screen()
- ButtonChoiceWindow(self.screen, "Network", "Invalid NFS Domain",
- buttons=['Ok'])
- self.reset_screen_colors()
- self.gridform.draw()
- self._set_title()
-
- def valid_rng_bytes_callback(self):
- rng_bytes = self.rng_bytes.value()
- if len(rng_bytes) > 0 and not rng_bytes.isdigit() \
- or rng_bytes.startswith("0"):
- self.rng_bytes.set("")
- self._create_warn_screen()
- ButtonChoiceWindow(self.screen, "Network", "Invalid RNG Bytes Value",
- buttons=['Ok'])
- self.reset_screen_colors()
- self.gridform.draw()
- self._set_title()
-
- def screen_locked_page(self, screen):
- self.screen_locked = True
- elements = Grid(1, 3)
- pw_elements = Grid(2, 2)
- pad = 34 - len(os.uname()[1]) / 2
- elements.setField(Label("Unlock " + os.uname()[1]), 0, 0,
- padding=(pad - 3, 1, 0, 1))
- self.login_username = os.getlogin()
- self.login_password = Entry(15, "", password=1)
- pw_elements.setField(Label("Username: "), 0, 0, padding=(pad, 1, 0, 1))
- pw_elements.setField(Label(self.login_username), 1, 0)
- pw_elements.setField(Label("Password: "), 0, 1, padding=(pad, 0, 0, 1))
- pw_elements.setField(self.login_password, 1, 1)
- elements.setField(pw_elements, 0, 1)
- return [Label(""), elements]
-
- def status_page(self, screen):
- elements = Grid(2, 10)
- main_grid = Grid(2, 10)
- if network_up():
- self.network_status = {}
- status_text = ""
- client = gudev.Client(['net'])
- # reload augeas tree
- aug.load()
- for nic in client.query_by_subsystem("net"):
- try:
- interface = nic.get_property("INTERFACE")
- logger.debug(interface)
- if not interface == "lo":
- if has_ip_address(interface) or get_ipv6_address(
- interface):
- ipv4_address = get_ip_address(interface)
- try:
- ipv6_address, netmask = get_ipv6_address(
- interface)
- except:
- ipv6_address = ""
- self.network_status[interface] = (ipv4_address,
- ipv6_address)
- except:
- pass
- # remove parent/bridge duplicates
- for key in sorted(self.network_status.iterkeys()):
- if key.startswith("br"):
- parent_dev = key[+2:]
- if parent_dev in self.network_status:
- del self.network_status[parent_dev]
- for key in sorted(self.network_status.iterkeys()):
- ipv4_addr, ipv6_addr = self.network_status[key]
- cmd = ("/files/etc/sysconfig/network-scripts/" +
- "ifcfg-%s/BOOTPROTO") % str(key)
- dev_bootproto = augtool_get(cmd)
- if dev_bootproto is None:
- cmd = ("/files/etc/sysconfig/network-scripts/" +
- "ifcfg-br%s/BOOTPROTO") % str(key)
- dev_bootproto = augtool_get(cmd)
- if dev_bootproto is None:
- dev_bootproto = "Disabled"
- dev_bootproto = dev_bootproto.strip().lower().replace("none", "static")
- if not nic_link_detected(key):
- ipv4_addr = "(Link Inactive)"
- if ipv4_addr.strip() == "" and dev_bootproto == "dhcp":
- if "Inactive" in ipv4_addr:
- ipv4_addr = "(Link Inactive)"
- else:
- ipv4_addr = "(DHCP Failed)"
- if "OVIRT_IPV6" in OVIRT_VARS and ipv6_addr != "":
- status_text += "%1s: %5s %14s \nIPv6: %1s\n\n" % (
- key.strip(), dev_bootproto,
- ipv4_addr.strip(), ipv6_addr.strip())
- else:
- status_text += "%1s: %5s %14s \n" % (key.strip(),
- dev_bootproto, ipv4_addr.strip())
- status_text.strip()
- networking = TextboxReflowed(32, status_text, maxHeight=3)
- networking.setText(status_text)
- logger.debug(status_text)
- logger.debug(self.network_status)
- else:
- networking = Textbox(25, 1, "Not Connected")
- elements.setField(Label("Networking:"), 0, 0, anchorLeft=1,
- anchorTop=1)
- elements.setField(networking, 1, 0, anchorLeft=1, padding=(4, 0, 0, 1))
- elements.setField(Label("Logical Network Device MAC Address"), 1,
- 4, anchorLeft=1)
- networks = logical_to_physical_networks()
- if len(networks) >= 3:
- net_scroll = 1
- else:
- net_scroll = 0
- self.network_list = Textbox(50, 3, "", scroll=net_scroll)
- net_entry = ""
- for key in networks.iterkeys():
- device, mac = networks[key]
- key = pad_or_trim(12, key)
- device = pad_or_trim(8, device)
- net_entry += " %1s %6s %9s\n" % (key, device, mac)
- elements.setField(self.network_list, 1, 5, anchorLeft=1,
- padding=(4, 0, 0, 1))
- self.network_list.setText(net_entry)
- logging_status_text = ""
- if not get_rsyslog_config() is None:
- host, port = get_rsyslog_config()
- logging_status_text += "Rsyslog: %s:%s\n" % (host, port)
- netconsole_server = augtool_get("/files/etc/sysconfig/netconsole/" +
- "SYSLOGADDR")
- netconsole_server_port = augtool_get("/files/etc/sysconfig/" +
- "netconsole/SYSLOGPORT")
- if netconsole_server and netconsole_server_port:
- logging_status_text += "Netconsole: %s:%s" % (netconsole_server,
- netconsole_server_port)
- if len(logging_status_text) == 0:
- logging_status_text = "Local Only"
- logging_status = Textbox(45, 2, logging_status_text)
- elements.setField(Label("Logs:"), 0, 6, anchorLeft=1)
- elements.setField(logging_status, 1, 6, anchorLeft=1,
- padding=(4, 0, 0, 0))
- try:
- conn = libvirt.openReadOnly(None)
- self.dom_count = conn.numOfDomains()
- conn.close()
- except:
- self.dom_count = "Failed to connect"
- self.jobs_status = Textbox(18, 1, str(self.dom_count))
- running_vms_grid = Grid(2, 1)
- running_vms_grid.setField(Label("Running VMs: "), 0, 0, anchorLeft=1)
- running_vms_grid.setField(self.jobs_status, 1, 0, anchorLeft=1)
- main_grid.setField(elements, 0, 1, anchorLeft=1)
- hwvirt_msg = get_virt_hw_status()
- if not hwvirt_msg is "":
- self.hwvirt = Textbox(50, 1, hwvirt_msg)
- main_grid.setField(self.hwvirt, 0, 3, anchorLeft=1,
- padding=(0, 1, 0, 0))
- else:
- main_grid.setField(running_vms_grid, 0, 3, anchorLeft=1,
- padding=(0, 0, 0, 0))
-
- help_text = Textbox(62, 1, "Press F8 For Support Menu")
- main_grid.setField(help_text, 0, 4, anchorLeft=1,
- padding=(0, 0, 0, 0))
- details_grid = Grid(2, 1)
- self.ssh_hostkey_btn = CompactButton("View Host Key")
- details_grid.setField(self.ssh_hostkey_btn, 0, 0, anchorLeft=1,
- padding=(1, 1, 0, 0))
- self.cpu_details_btn = CompactButton("View CPU Details")
- details_grid.setField(self.cpu_details_btn, 1, 0, anchorLeft=1,
- padding=(1, 1, 0, 0))
- main_grid.setField(details_grid, 0, 5, anchorLeft=1,
- padding=(0, 0, 0, 0))
- return [Label(""), main_grid]
-
- def logging_configuration_page(self, screen):
- elements = Grid(2, 8)
- if network_up():
- heading = Label("Logging")
- else:
- heading = Label("Network Down, Logging Configuration Disabled")
- if is_console():
- heading.setColors(customColorset(1))
- elements.setField(heading, 0, 0, anchorLeft=1)
- logrotate_grid = Grid(2, 2)
- logrotate_grid.setField(Label(" Logrotate Max Log Size (KB): "), 0,
- 0, anchorLeft=1)
- self.logrotate_max_size = Entry(5, "", scroll=0)
- self.logrotate_max_size.setCallback(
- self.valid_logrotate_max_size_callback)
- logrotate_grid.setField(self.logrotate_max_size, 1, 0, anchorLeft=1)
- current_logrotate_size = get_logrotate_size()
- self.logrotate_max_size.set(current_logrotate_size)
- elements.setField(logrotate_grid, 0, 1, anchorLeft=1,
- padding=(0, 1, 0, 0))
- elements.setField(Label(" "), 0, 2, anchorLeft=1)
- elements.setField(Textbox(45, 2, "Rsyslog is an enhanced " +
- "multi-threaded syslogd"), 0, 3, anchorLeft=1)
- rsyslog_grid = Grid(2, 2)
- rsyslog_grid.setField(Label(" Server Address:"), 0, 0, anchorLeft=1)
- self.syslog_server = Entry(25, "")
- self.syslog_server.setCallback(self.valid_syslog_server_callback)
- rsyslog_grid.setField(self.syslog_server, 1, 0, anchorLeft=1,
- padding=(2, 0, 0, 1))
- self.syslog_port = Entry(6, "", scroll=0)
- self.syslog_port.setCallback(self.valid_syslog_port_callback)
- rsyslog_grid.setField(Label(" Server Port:"), 0, 1, anchorLeft=1,
- padding=(0, 0, 0, 1))
- rsyslog_grid.setField(self.syslog_port, 1, 1, anchorLeft=1,
- padding=(2, 0, 0, 1))
- rsyslog_config = get_rsyslog_config()
- logger.debug(rsyslog_config)
- if not rsyslog_config is None:
- rsyslog_server, rsyslog_port = rsyslog_config
- self.syslog_server.set(rsyslog_server)
- self.syslog_port.set(rsyslog_port)
- else:
- self.syslog_port.set("514")
- elements.setField(rsyslog_grid, 0, 4, anchorLeft=1)
- elements.setField(Textbox(48, 3, "Netconsole service allows a " +
- "remote syslog daemon\nto record kernel printk() " +
- "messages"), 0, 5, anchorLeft=1,
- padding=(0, 0, 0, 0))
- netconsole_grid = Grid(2, 2)
- netconsole_grid.setField(Label(" Server Address:"), 0, 0,
- anchorLeft=1)
- self.netconsole_server = Entry(25, "")
- self.netconsole_server.setCallback(
- self.valid_netconsole_server_callback)
- netconsole_grid.setField(Label(" Server Port:"), 0, 1, anchorLeft=1)
- self.netconsole_server_port = Entry(5, "", scroll=0)
- self.netconsole_server_port.setCallback(
- self.valid_netconsole_server_port_callback)
- netconsole_grid.setField(self.netconsole_server, 1, 0, anchorLeft=1,
- padding=(2, 0, 0, 1))
- netconsole_grid.setField(self.netconsole_server_port, 1, 1,
- anchorLeft=1, padding=(2, 0, 0, 0))
- elements.setField(netconsole_grid, 0, 6, anchorLeft=1,
- padding=(0, 0, 0, 1))
- netconsole_server = augtool_get("/files/etc/sysconfig/netconsole/" +
- "SYSLOGADDR")
- netconsole_server_port = augtool_get("/files/etc/sysconfig/" +
- "netconsole/SYSLOGPORT")
- if netconsole_server is None:
- self.netconsole_server.set("")
- else:
- self.netconsole_server.set(netconsole_server)
- if netconsole_server_port is None:
- self.netconsole_server_port.set("6666")
- else:
- self.netconsole_server_port.set(netconsole_server_port)
-
- input_fields = [self.syslog_server, self.syslog_port,
- self.netconsole_server, self.netconsole_server_port]
- if not network_up():
- for field in input_fields:
- field.setFlags(FLAG_DISABLED, FLAGS_SET)
- return [Label(""), elements]
-
- def authentication_configuration_page(self, screen):
- elements = Grid(2, 9)
- heading = Label("Remote Access")
- if is_console():
- heading.setColors(customColorset(1))
- elements.setField(heading, 0, 0, anchorLeft=1)
- pw_elements = Grid(3, 3)
- self.current_ssh_pwd_status = augtool_get("/files/etc/ssh/" +
- "sshd_config/PasswordAuthentication")
- if self.current_ssh_pwd_status == "yes":
- self.current_ssh_pwd_status = 1
- else:
- self.current_ssh_pwd_status = 0
- self.ssh_passwd_status = Checkbox("Enable ssh password authentication",
- isOn=self.current_ssh_pwd_status)
- elements.setField(self.ssh_passwd_status, 0, 1, anchorLeft=1)
- rng_heading = Label("Strong Random Number Generator")
- if is_console():
- rng_heading.setColors(customColorset(1))
- elements.setField(rng_heading, 0, 2, anchorLeft=1,
- padding = (0, 1, 0, 0))
-
- self.current_rng_bytes, self.current_aes_ni_status = rng_status()
- rng_elements = Grid(2, 2)
- rng_bit_elements = Grid(2, 1)
- self.disable_aes_ni = Checkbox("Disable AES-NI",
- isOn=self.current_aes_ni_status)
- rng_elements.setField(self.disable_aes_ni, 0, 0, anchorLeft=1)
- rng_bit_elements.setField(Label("Bytes Used: "), 0, 0, anchorLeft=1)
- self.rng_bytes = Entry(5, scroll=0)
- self.rng_bytes.setCallback(self.valid_rng_bytes_callback)
- if self.current_rng_bytes > 0:
- self.rng_bytes.set(self.current_rng_bytes)
- rng_bit_elements.setField(self.rng_bytes, 1, 0, anchorLeft=1)
- rng_elements.setField(rng_bit_elements, 0, 1, anchorLeft=1)
- elements.setField(rng_elements, 0, 3, anchorLeft=1)
- local_heading = Label("Local Access")
- if is_console():
- local_heading.setColors(customColorset(1))
- elements.setField(local_heading, 0, 4, anchorLeft=1,
- padding=(0, 1, 0, 0))
- pw_elements.setField(Label("Password: "), 0, 1, anchorLeft=1)
- pw_elements.setField(Label("Confirm Password: "), 0, 2, anchorLeft=1)
- self.root_password_1 = Entry(15, password=1)
- self.root_password_1.setCallback(self.password_check_callback)
- self.root_password_2 = Entry(15, password=1)
- self.root_password_2.setCallback(self.password_check_callback)
- pw_elements.setField(self.root_password_1, 1, 1)
- pw_elements.setField(self.root_password_2, 1, 2)
- self.pw_msg = Textbox(60, 6, "", wrap=1)
- elements.setField(pw_elements, 0, 7, anchorLeft=1)
- elements.setField(self.pw_msg, 0, 8, padding=(0, 1, 0, 0))
- return [Label(""), elements]
-
- def network_configuration_page(self, screen):
- self.network_config_fields = []
- aug.load()
- grid = Grid(2, 15)
- self.heading = Label("System Identification")
- grid.setField(self.heading, 0, 1, anchorLeft=1)
- hostname_grid = Grid(2, 2)
- hostname_grid.setField(Label("Hostname: "), 0, 1, anchorLeft=1,
- padding=(0, 0, 4, 0))
- self.current_hostname = os.uname()[1]
- hostname = os.uname()[1]
- self.net_hostname = Entry(35, hostname)
- self.network_config_fields += [self.net_hostname]
- self.net_hostname.setCallback(self.valid_hostname_callback)
- self.ntp_dhcp = 0
- hostname_grid.setField(self.net_hostname, 1, 1, anchorLeft=1,
- padding=(0, 0, 0, 0))
- grid.setField(hostname_grid, 0, 3, anchorLeft=1)
- dns_grid = Grid(2, 2)
- self.dns_host1 = Entry(25)
- self.network_config_fields += [self.dns_host1]
- self.dns_host1.setCallback(self.dns_host1_callback)
- self.current_dns_host1 = augtool_get("/files/etc/resolv.conf/" +
- "nameserver[1]")
- if self.current_dns_host1:
- self.dns_host1.set(self.current_dns_host1)
- else:
- self.dns_host1.set("")
- self.dns_host2 = Entry(25)
- self.network_config_fields += [self.dns_host2]
- self.dns_host2.setCallback(self.dns_host2_callback)
- self.current_dns_host2 = augtool_get("/files/etc/resolv.conf" +
- "/nameserver[2]")
- if self.current_dns_host2:
- self.dns_host2.set(self.current_dns_host2)
- else:
- self.dns_host2.set("")
- dns_grid.setField(Label("DNS Server 1: "), 0, 0, anchorLeft=1)
- dns_grid.setField(Label("DNS Server 2: "), 0, 1, anchorLeft=1)
- dns_grid.setField(self.dns_host1, 1, 0, anchorLeft=1)
- dns_grid.setField(self.dns_host2, 1, 1, anchorLeft=1)
- grid.setField(Label(" "), 0, 4)
- grid.setField(dns_grid, 0, 6, anchorLeft=1)
- grid.setField(Label(" "), 0, 7)
- ntp_grid = Grid(2, 2)
- self.ntp_host1 = Entry(25)
- self.network_config_fields += [self.ntp_host1]
- self.ntp_host1.setCallback(self.ntp_host1_callback)
-
- self.ntp_host2 = Entry(25)
- self.network_config_fields += [self.ntp_host2]
- self.ntp_host2.setCallback(self.ntp_host2_callback)
-
- self.current_ntp_host1 = augtool_get("/files/etc/ntp.conf/server[1]")
- if self.current_ntp_host1:
- self.ntp_host1.set(self.current_ntp_host1)
- self.current_ntp_host2 = augtool_get("/files/etc/ntp.conf/server[2]")
- if self.current_ntp_host2:
- self.ntp_host2.set(self.current_ntp_host2)
- ntp_grid.setField(Label("NTP Server 1: "), 0, 0, anchorLeft=1)
- ntp_grid.setField(Label("NTP Server 2: "), 0, 1, anchorLeft=1)
- ntp_grid.setField(self.ntp_host1, 1, 0, anchorLeft=1)
- ntp_grid.setField(self.ntp_host2, 1, 1, anchorLeft=1)
- grid.setField(Label(" "), 0, 10)
- grid.setField(ntp_grid, 0, 9, anchorLeft=1)
- self.nic_dict, self.configured_nics, self.ntp_dhcp = get_system_nics()
- if len(self.nic_dict) > 5:
- self.nic_lb = Listbox(height=5, width=56, returnExit=1, scroll=1)
- else:
- self.nic_lb = Listbox(height=5, width=56, returnExit=1, scroll=0)
- for key in sorted(self.nic_dict.iterkeys()):
- (dev_interface, dev_bootproto, dev_vendor, dev_address,
- dev_driver, dev_conf_status, dev_bridge) = (
- self.nic_dict[key].split(",", 6))
- dev_vendor = pad_or_trim(10, dev_vendor)
- dev_interface = pad_or_trim(6, dev_interface)
- nic_option = '%2s %13s %10s %19s\n' % (dev_interface,
- dev_conf_status, dev_vendor, dev_address)
- self.nic_lb.append(nic_option, dev_interface.strip())
- NIC_LABEL = Label("Device Status Model MAC Address")
- grid.setField(NIC_LABEL, 0, 11, (0, 0, 0, 0), anchorLeft=1)
- grid.setField(self.nic_lb, 0, 12)
- if os.path.exists("/etc/sysconfig/network-scripts/ifcfg-rhevm"):
- for item in (self.dns_host1, self.dns_host2, self.ntp_host1,
- self.ntp_host2):
- item.setFlags(_snack.FLAG_DISABLED, _snack.FLAGS_SET)
- self.heading.setText("Managed by RHEV-M (Read Only)")
- if self.ntp_dhcp == 1:
- for item in self.ntp_host1, self.ntp_host2:
- item.setFlags(_snack.FLAG_DISABLED, _snack.FLAGS_SET)
-
- self.original_system_network_config = (
- self.get_tui_field_network_config())
- if (hasattr(self, "preset_network_config")
- and self.preset_network_config is not None):
- for field, value in zip(self.network_config_fields,
- self.preset_network_config):
- field.set(value)
- self.preset_network_config = None
-
- return [Label(""), grid]
-
- def network_details_page(self, screen):
- grid = Grid(1, 15)
- if nic_link_detected(self.nic_lb.current()):
- link_status = "Active"
- else:
- link_status = "Inactive"
- dev = self.nic_lb.current()
- (interface, bootproto, vendor, address, driver, conf_status,
- dev_bridge) = self.nic_dict[dev].split(",", 6)
- if dev_bridge == "rhevm" or dev_bridge == "ovirtmgmt":
- cmd = ("/files/etc/sysconfig/network-scripts/" + \
- "ifcfg-%s/BOOTPROTO" % dev_bridge)
- bootproto = augtool_get(cmd)
- nic_detail_grid = Grid(6, 10)
- nic_detail_grid.setField(Label("Interface: "), 0, 1, anchorLeft=1,
- padding=(0, 0, 1, 0))
- nic_detail_grid.setField(Label("Protocol: "), 0, 2, anchorLeft=1,
- padding=(0, 0, 1, 0))
- nic_detail_grid.setField(Label("Link Status: "), 0, 3, anchorLeft=1,
- padding=(0, 0, 1, 0))
- nic_detail_grid.setField(Label("Driver: "), 3, 1, anchorLeft=1,
- padding=(0, 0, 1, 0))
- nic_detail_grid.setField(Label("Vendor: "), 3, 2, anchorLeft=1,
- padding=(0, 0, 1, 0))
- nic_detail_grid.setField(Label("MAC Address: "), 3, 3, anchorLeft=1,
- padding=(0, 0, 1, 0))
- nic_detail_grid.setField(Label(interface), 1, 1, anchorLeft=1,
- padding=(0, 0, 5, 0))
- nic_detail_grid.setField(Label(bootproto), 1, 2, anchorLeft=1,
- padding=(0, 0, 5, 0))
- nic_detail_grid.setField(Label(link_status), 1, 3, anchorLeft=1,
- padding=(0, 0, 5, 0))
- nic_detail_grid.setField(Label(driver), 4, 1, anchorLeft=1,
- padding=(0, 0, 0, 0))
- nic_detail_grid.setField(Label(vendor), 4, 2, anchorLeft=1,
- padding=(0, 0, 0, 0))
- nic_detail_grid.setField(Label(address), 4, 3, anchorLeft=1,
- padding=(0, 0, 0, 0))
- grid.setField(nic_detail_grid, 0, 1)
- ipv4_main_grid = Grid(6, 8)
- # Needs to be defined here, b/c callbacks are referencing it
- self.netvlanid = None
- self.disabled_ipv4_nic_proto = Checkbox("Disabled ")
- self.disabled_ipv4_nic_proto.setCallback(self.ipv4_disabled_callback)
- self.dhcp_ipv4_nic_proto = Checkbox("DHCP ")
- self.dhcp_ipv4_nic_proto.setCallback(self.ipv4_dhcp_callback)
- self.static_ipv4_nic_proto = Checkbox("Static ")
- self.static_ipv4_nic_proto.setCallback(self.ipv4_static_callback)
- if bootproto.lower() == "dhcp":
- self.dhcp_ipv4_nic_proto.setValue("*")
- elif bootproto.lower() == "static" or bootproto.lower() == "none":
- self.static_ipv4_nic_proto.setValue("*")
- else:
- self.disabled_ipv4_nic_proto.setValue("*")
- ipv4_proto_grid = Grid(6, 1)
- ipv4_proto_grid.setField(self.disabled_ipv4_nic_proto, 0, 0,
- anchorLeft=1)
- ipv4_proto_grid.setField(self.dhcp_ipv4_nic_proto, 2, 0, anchorLeft=1)
- ipv4_proto_grid.setField(self.static_ipv4_nic_proto, 4, 0,
- anchorLeft=1)
- ipv4_main_grid.setField(Label("IPv4 Settings"), 0, 0, anchorLeft=1)
- ipv4_main_grid.setField(ipv4_proto_grid, 0, 2, anchorLeft=1)
- self.ipv4_netdevip = Entry(16, "", scroll=0)
- self.ipv4_netdevip.setCallback(self.ipv4_ip_callback)
- self.ipv4_netdevmask = Entry(16, "", scroll=0)
- self.ipv4_netdevmask.setCallback(self.ipv4_netmask_callback)
- self.ipv4_netdevgateway = Entry(16, "", scroll=0)
- self.ipv4_netdevgateway.setCallback(self.ipv4_gateway_callback)
- if not dev_bridge is None:
- dev = dev_bridge
- current_ip = get_ip_address(dev)
- if current_ip != "":
- self.ipv4_netdevip.set(current_ip)
- current_netmask = get_netmask(dev)
- if current_netmask != "":
- self.ipv4_netdevmask.set(current_netmask)
- current_gateway = get_gateway(dev)
- if is_valid_ipv4(current_gateway) or is_valid_ipv6(current_gateway):
- self.ipv4_netdevgateway.set(current_gateway)
- ipv4_grid = Grid(5, 3)
- ipv4_grid.setField(Label("IP Address: "), 0, 1, anchorLeft=1)
- ipv4_grid.setField(Label(" Netmask: "), 3, 1, anchorLeft=1)
- ipv4_grid.setField(Label("Gateway:"), 0, 2, anchorLeft=1)
- ipv4_grid.setField(self.ipv4_netdevip, 2, 1)
- ipv4_grid.setField(self.ipv4_netdevmask, 4, 1)
- ipv4_grid.setField(self.ipv4_netdevgateway, 2, 2)
- ipv4_main_grid.setField(ipv4_grid, 0, 3)
- if self.dhcp_ipv4_nic_proto.value() == 1:
- self.ipv4_dhcp_callback()
- elif self.static_ipv4_nic_proto.value() == 1:
- self.ipv4_static_callback()
- else:
- self.ipv4_disabled_callback()
- # prepopulate current values only in case of missing values
- if self.__nic_config_failed == 1:
- try:
- self.ipv4_netdevip.set(self.ipv4_current_netdevip)
- self.ipv4_netdevmask.set(self.ipv4_current_netdevmask)
- self.ipv4_netdevgateway.set(self.ipv4_current_netdevgateway)
- except:
- pass
- self.__nic_config_failed = 0
- # ipv6 grids
- ipv6_main_grid = Grid(6, 8)
- self.disabled_ipv6_nic_proto = Checkbox("Disabled ")
- self.disabled_ipv6_nic_proto.setCallback(self.ipv6_disabled_callback)
- self.dhcp_ipv6_nic_proto = Checkbox("DHCP ")
- self.dhcp_ipv6_nic_proto.setCallback(self.ipv6_dhcp_callback)
- self.static_ipv6_nic_proto = Checkbox("Static ")
- self.static_ipv6_nic_proto.setCallback(self.ipv6_static_callback)
- self.auto_ipv6_nic_proto = Checkbox("Auto")
- self.auto_ipv6_nic_proto.setCallback(self.ipv6_auto_callback)
- ipv6_autoconf_lookup_cmd = ("/files/etc/sysconfig/network-scripts/" +
- "ifcfg-%s/IPV6_AUTOCONF") % self.nic_lb.current()
- ipv6_autoconf = augtool_get(ipv6_autoconf_lookup_cmd)
- if ipv6_autoconf is None:
- ipv6_autoconf_lookup_cmd = ("/files/etc/sysconfig/network-" +
- "scripts/ifcfg-br%s/IPV6_AUTOCONF") % self.nic_lb.current()
- ipv6_autoconf = augtool_get(ipv6_autoconf_lookup_cmd)
- ipv6_dhcp_lookup_cmd = ("/files/etc/sysconfig/network-scripts/" +
- "ifcfg-%s/DHCPV6C") % self.nic_lb.current()
- ipv6_dhcp = augtool_get(ipv6_dhcp_lookup_cmd)
- if ipv6_dhcp is None:
- ipv6_dhcp_lookup_cmd = ("/files/etc/sysconfig/network-scripts/" +
- "ifcfg-br%s/DHCPV6C") % self.nic_lb.current()
- ipv6_dhcp = augtool_get(ipv6_dhcp_lookup_cmd)
- ipv6_bootproto = ""
- if ipv6_autoconf == "yes":
- ipv6_bootproto = "auto"
- if ipv6_dhcp == "yes":
- ipv6_bootproto = "dhcp"
- if ipv6_bootproto == "dhcp":
- self.dhcp_ipv6_nic_proto.setValue("*")
- elif ipv6_bootproto == "auto":
- self.auto_ipv6_nic_proto.setValue("*")
- else:
- self.disabled_ipv6_nic_proto.setValue("*")
- ipv6_proto_grid = Grid(6, 1)
- ipv6_proto_grid.setField(self.disabled_ipv6_nic_proto, 0, 0,
- anchorLeft=1)
- ipv6_proto_grid.setField(self.dhcp_ipv6_nic_proto, 1, 0, anchorLeft=1)
- ipv6_proto_grid.setField(self.static_ipv6_nic_proto, 2, 0,
- anchorLeft=1)
- ipv6_proto_grid.setField(self.auto_ipv6_nic_proto, 3, 0, anchorLeft=1)
- ipv6_main_grid.setField(Label("IPv6 Settings"), 0, 0, anchorLeft=1)
- ipv6_main_grid.setField(ipv6_proto_grid, 0, 2, anchorLeft=1)
- self.ipv6_netdevip = Entry(39, "", scroll=0)
- self.ipv6_netdevip.setCallback(self.ipv6_ip_callback)
- self.ipv6_netdevmask = Entry(39, "", scroll=0)
- self.ipv6_netdevmask.setCallback(self.ipv6_netmask_callback)
- self.ipv6_netdevgateway = Entry(39, "", scroll=0)
- self.ipv6_netdevgateway.setCallback(self.ipv6_gateway_callback)
- if "OVIRT_IPV6_ADDRESS" in OVIRT_VARS:
- self.ipv6_netdevip.set(OVIRT_VARS["OVIRT_IPV6_ADDRESS"])
- else:
- try:
- current_ip, current_netmask = get_ipv6_address(
- self.nic_lb.current())
- except:
- current_ip = ""
- current_netmask = ""
- if current_ip == "":
- try:
- current_ip, current_netmask = get_ipv6_address("br" +
- self.nic_lb.current())
- except:
- pass
- if current_ip != "":
- self.ipv6_netdevip.set(current_ip)
- if "OVIRT_IPV6_NETMASK" in OVIRT_VARS:
- self.ipv6_netdevmask.set(OVIRT_VARS["OVIRT_IPV6_NETMASK"])
- else:
- if current_ip != "":
- self.ipv6_netdevmask.set(current_netmask)
- if "OVIRT_IPV6_GATEWAY" in OVIRT_VARS:
- self.ipv6_netdevgateway.set(OVIRT_VARS["OVIRT_IPV6_GATEWAY"])
- else:
- current_gateway = get_ipv6_gateway(self.nic_lb.current())
- if current_gateway == "":
- current_gateway = get_gateway("br" + self.nic_lb.current())
- ipv6_grid = Grid(5, 4)
- ipv6_grid.setField(Label("IP Address: "), 0, 1, anchorLeft=1)
- ipv6_grid.setField(Label("Netmask: "), 0, 2, anchorLeft=1)
- ipv6_grid.setField(Label("Gateway:"), 0, 3, anchorLeft=1)
- ipv6_grid.setField(self.ipv6_netdevip, 2, 1)
- ipv6_grid.setField(self.ipv6_netdevmask, 2, 2)
- ipv6_grid.setField(self.ipv6_netdevgateway, 2, 3)
- ipv6_main_grid.setField(ipv6_grid, 0, 3)
- if self.dhcp_ipv6_nic_proto.value() == 1:
- self.ipv6_dhcp_callback()
- elif self.static_ipv6_nic_proto.value() == 1:
- self.ipv6_static_callback()
- else:
- self.ipv6_disabled_callback()
- grid.setField(Label(" "), 0, 4, anchorLeft=1)
- grid.setField(ipv4_main_grid, 0, 5, anchorLeft=1)
- grid.setField(Label(" "), 0, 6, anchorLeft=1)
- # only display ipv6 settings if OVIRT_IPV6 key is in defaults file
- if "OVIRT_IPV6" in OVIRT_VARS:
- grid.setField(ipv6_main_grid, 0, 7, anchorLeft=1)
- else:
- grid.setField(Label(" "), 0, 7, anchorLeft=1, padding=(0, 4, 0, 0))
- grid.setField(Label(" "), 0, 8, anchorLeft=1)
- vlan_grid = Grid(2, 2)
- self.netvlanid = Entry(4, "", scroll=0)
- self.netvlanid.setCallback(self.netvlanid_callback)
- for vlan in get_system_vlans():
- # XXX wrong match e.g. eth10.1 with eth1
- if self.nic_lb.current() in vlan:
- vlan_id = vlan.replace(self.nic_lb.current() + ".", "")
- self.netvlanid.set(vlan_id)
- if self.disabled_ipv4_nic_proto.value() == 1:
- self.netvlanid.setFlags(_snack.FLAG_DISABLED, _snack.FLAGS_SET)
- vlan_grid.setField(Label("VLAN ID: "), 0, 0, anchorLeft=1)
- vlan_grid.setField(self.netvlanid, 1, 0)
- grid.setField(vlan_grid, 0, 9, anchorLeft=1)
- # disable all items if registered to rhevm server
- if os.path.exists("/etc/sysconfig/network-scripts/ifcfg-rhevm"):
- for item in (self.disabled_ipv4_nic_proto,
- self.dhcp_ipv4_nic_proto, self.static_ipv4_nic_proto,
- self.ipv4_netdevip, self.ipv4_netdevmask,
- self.ipv4_netdevgateway, self.disabled_ipv6_nic_proto,
- self.dhcp_ipv6_nic_proto, self.static_ipv6_nic_proto,
- self.auto_ipv6_nic_proto, self.ipv6_netdevip,
- self.ipv6_netdevmask, self.ipv6_netdevgateway,
- self.netvlanid):
- item.setFlags(_snack.FLAG_DISABLED, _snack.FLAGS_SET)
- try:
- current_ip = get_ipv6_address("br" +
- self.nic_lb.current()).split("\n")
- if current_ip == "":
- current_ip = get_ipv6_address(
- self.nic_lb.current()).split("\n")
- if current_ip != "":
- if len(current_ip) > 1:
- current_ip = current_ip[0]
- current_ip, netmask = current_ip.split("/")
- else:
- current_ip, netmask = current_ip.split("/")
- self.ipv6_netdevip.set(current_ip)
- self.ipv6_netdevmask.set(netmask)
- except:
- pass
- return [Label(""),
- grid]
-
-
- def keyboard_configuration_page(self, screen):
- # placeholder for system-config-keyboard-base, will remove move later
- try:
- import system_config_keyboard.keyboard as keyboard
- except:
- return [Label(""), elements]
-
- elements = Grid(2, 9)
- heading = Label("Keyboard Layout Selection")
- if is_console():
- heading.setColors(customColorset(1))
- self.kbd = keyboard.Keyboard()
- self.kbd.read()
- self.kbdDict = self.kbd.modelDict
- self.kbdKeys = [k[0] for k in sorted(self.kbdDict.items(), \
- key=lambda e: e[1][0].lower())]
- self.kb_list = Listbox(10, scroll=1, returnExit=0)
- default = ""
- for kbd in self.kbdKeys:
- if kbd == self.kbd.get():
- default = kbd
- plainName = self.kbdDict[kbd][0]
- self.kb_list.append(plainName, kbd)
- try:
- self.kb_list.setCurrent(default)
- except:
- pass
- elements.setField(heading, 0, 0, anchorLeft=1)
- elements.setField(self.kb_list, 0, 1, anchorLeft=1,
- padding=(1, 1, 0, 3))
- return [Label(""), elements]
-
- def kdump_configuration_page(self, screen):
- elements = Grid(2, 12)
- heading = Label("Kernel Dump")
- if not network_up():
- heading = Label("Network Down, SSH/NFS KDump Configuration " +
- "disabled")
- if is_console():
- heading.setColors(customColorset(1))
- elements.setField(heading, 0, 0, anchorLeft=1)
- elements.setField(Label(" "), 0, 1, anchorLeft=1)
- kdump_type_grid = Grid(5, 2)
- self.kdump_nfs_type = Checkbox("NFS ")
- self.kdump_nfs_type.setCallback(self.kdump_nfs_callback)
- self.kdump_ssh_type = Checkbox("SSH ")
- self.kdump_ssh_type.setCallback(self.kdump_ssh_callback)
- self.kdump_restore_type = Checkbox("Restore (Local)")
- self.kdump_restore_type.setCallback(self.kdump_restore_callback)
- kdump_type_grid.setField(self.kdump_nfs_type, 0, 0, anchorLeft=1)
- kdump_type_grid.setField(self.kdump_ssh_type, 1, 0, anchorLeft=1)
- kdump_type_grid.setField(self.kdump_restore_type, 2, 0, anchorLeft=1)
- elements.setField(kdump_type_grid, 0, 2, anchorLeft=1)
- elements.setField(Label(" "), 0, 3, anchorLeft=1)
- elements.setField(Label("NFS Location (example.redhat.com:" +
- "/var/crash):"), 0, 4, anchorLeft=1)
- self.kdump_nfs_config = Entry(30, "")
- self.kdump_nfs_config.setCallback(self.kdump_valid_nfs_callback)
- elements.setField(self.kdump_nfs_config, 0, 5, anchorLeft=1)
- elements.setField(Label(" "), 0, 6, anchorLeft=1)
- elements.setField(Label("SSH Location (root at example.redhat.com):"),
- 0, 7, anchorLeft=1)
- self.kdump_ssh_config = Entry(30, "")
- self.kdump_ssh_config.setCallback(self.kdump_valid_ssh_callback)
- elements.setField(self.kdump_ssh_config, 0, 8, anchorLeft=1,
- padding=(0, 0, 0, 6))
- try:
- kdump_config_file = open("/etc/kdump.conf")
- for line in kdump_config_file:
- if not line.startswith("#"):
- if line.startswith("net"):
- line = line.replace("net ", "")
- if "@" in line:
- self.kdump_ssh_type.setValue("*")
- self.kdump_ssh_config.set(line.strip())
- self.kdump_nfs_config.setFlags(
- _snack.FLAG_DISABLED, _snack.FLAGS_SET)
- elif ":" in line:
- self.kdump_nfs_type.setValue("*")
- self.kdump_nfs_config.set(line.strip())
- self.kdump_ssh_config.setFlags(
- _snack.FLAG_DISABLED, _snack.FLAGS_SET)
- elif "/dev/HostVG/Data" in line:
- self.kdump_restore_type.setValue("*")
- kdump_config_file.close()
- except:
- pass
- disable_fields = []
- if not network_up():
- disable_fields += [self.kdump_nfs_type, self.kdump_ssh_type]
- if not network_up() or (self.kdump_nfs_type.value() == 0 and \
- self.kdump_ssh_type.value() == 0):
- disable_fields += [self.kdump_nfs_config, self.kdump_ssh_config]
- for field in disable_fields:
- field.setFlags(_snack.FLAG_DISABLED, _snack.FLAGS_SET)
-
- return [Label(""), elements]
-
- def support_page(self, screen):
- logger.info("Loading Support Page")
- elements = Grid(2, 8)
- elements.setField(Label(" View Log Files "), 0, 1, anchorLeft=1,
- padding=(0, 1, 0, 1))
- self.log_menu_list = Listbox(5, width=40, returnExit=1, border=0,
- showCursor=0, scroll=0)
- self.log_menu_list.append(" oVirt Log (ovirt.log)",
- "/var/log/ovirt.log")
- self.log_menu_list.append(" System Messages (messages)",
- "/var/log/messages")
- self.log_menu_list.append(" Security Log (secure)", "/var/log/secure")
- if os.path.exists("/var/log/vdsm/vdsm.log"):
- self.log_menu_list.append(" VDSM Log (vdsm.log)",
- "/var/log/vdsm/vdsm.log")
- if os.path.exists("/var/log/vdsm-reg/vdsm-reg.log"):
- self.log_menu_list.append(" VDSM Registration Log (vdsm-reg.log)",
- "/var/log/vdsm-reg/vdsm-reg.log")
- elements.setField(self.log_menu_list, 0, 2, anchorLeft=1,
- padding=(0, 0, 0, 6))
- elements.setField(Label(" After viewing press \"q\" to quit "), 0,
- 3, anchorLeft=1, padding=(0, 1, 0, 0))
-
- return [Label(""), elements]
-
- def remote_storage_configuration_page(self, screen):
- elements = Grid(2, 8)
- heading = Label("Remote Storage")
- if is_console():
- heading.setColors(customColorset(1))
- elements.setField(heading, 0, 0, anchorLeft=1)
- elements.setField(Label(" "), 0, 1, anchorLeft=1)
- elements.setField(Label("iSCSI Initiator Name:"), 0, 2, anchorLeft=1)
- self.iscsi_initiator_config = Entry(50, "")
- self.iscsi_initiator_config.setCallback(self.valid_iqn_callback)
- elements.setField(self.iscsi_initiator_config, 0, 3, anchorLeft=1,
- padding=(0, 0, 0, 1))
- elements.setField(Label("NFSv4 Domain (example.redhat.com):"), 0, 4, anchorLeft=1)
- self.nfsv4_domain = Entry(30, "")
- self.nfsv4_domain.setCallback(self.valid_nfsv4_domain_callback)
- elements.setField(self.nfsv4_domain, 0, 5, anchorLeft=1,
- padding=(0, 0, 0, 8))
- current_iscsi_initiator_name = get_current_iscsi_initiator_name()
- if current_iscsi_initiator_name is not None:
- self.iscsi_initiator_config.set(current_iscsi_initiator_name)
- current_nfsv4_domain = get_current_nfsv4_domain()
- if not current_nfsv4_domain.startswith("#"):
- self.nfsv4_domain.set(current_nfsv4_domain)
- return [Label(""), elements]
-
- def menuSpacing(self):
- # pages that dont use main listbox
- if not self.__current_page == NETWORK_DETAILS_PAGE:
- if self.menu_list.current() != self.__current_page:
- self.__current_page = self.menu_list.current()
- screen.start()
-
- def get_tui_field_network_config(self):
- return [f.value() for f in self.network_config_fields]
-
- def is_same_network_config(self, a, b):
- return all(x == y for x, y in zip(a, b))
-
- def process_network_config(self):
- # First update the central "model" (defaults/ovirt)
- dns_servers = []
- ntp_servers = []
- if not self.dns_host1.value() == "":
- dns_servers.append(self.dns_host1.value())
- if not self.dns_host2.value() == "":
- dns_servers.append(self.dns_host2.value())
- if not self.ntp_host1.value() == "":
- ntp_servers.append(self.ntp_host1.value())
- if not self.ntp_host2.value() == "":
- ntp_servers.append(self.ntp_host2.value())
-
- # Save DNS servers
- dns_servers = ",".join(dns_servers)
- logger.debug("Setting DNS defaults to: %s" % dns_servers)
- augtool("set", "/files/" + OVIRT_DEFAULTS + "/OVIRT_DNS",
- '"' + dns_servers + '"')
-
- # Save NTP servers
- ntp_servers = ",".join(ntp_servers)
- logger.debug("Setting NTP defaults to: %s" % ntp_servers)
- augtool("set", "/files/" + OVIRT_DEFAULTS + "/OVIRT_NTP",
- '"' + ntp_servers + '"')
-
- aug.load()
-
- # Then apply the configuration
- network = Network()
- if self.net_hostname.value() == "":
- network.remove_non_localhost()
- augtool("set", "/files/etc/sysconfig/network/HOSTNAME", "localhost.localdomain")
- system_closefds("hostname localhost.localdomain")
- elif (self.net_hostname.value() != self.current_hostname and
- is_valid_hostname(self.net_hostname.value())):
- network.remove_non_localhost()
- network.add_localhost_alias(self.net_hostname.value())
- augtool("set", "/files/etc/sysconfig/network/HOSTNAME",
- self.net_hostname.value())
- system_closefds("hostname " + self.net_hostname.value())
- ovirt_store_config("/etc/sysconfig/network")
- ovirt_store_config("/etc/hosts")
- logger.debug("Calling DNS and NTP configuration")
- network.configure_dns()
- network.configure_ntp()
- network.save_ntp_configuration()
- self.net_apply_config = 1
- return
-
- def process_nic_config(self):
- self._create_warn_screen()
- message = "Network Configuration may take a few moments, proceed?"
- if self.configured_nics > 0 and \
- "Unconfigured" in self.nic_dict[self.nic_lb.current()]:
- message = ("Network Configuration detected an already " +
- "configured NIC the configuration for that NIC " +
- "is going to be removed and the reconfiguration " +
- "may take a few moments, proceed?")
- warn = ButtonChoiceWindow(self.screen, "Confirm Network Settings",
- message)
- self.reset_screen_colors()
- if warn == "ok":
- self._create_blank_screen()
- gridform = GridForm(self.screen, "", 2, 2)
- gridform.add(Label("Verifying Networking Configuration"), 0, 0)
- progress_bar = Scale(50, 100)
- gridform.add(progress_bar, 0, 1)
- progress_bar.set(25)
- gridform.draw()
- self.screen.refresh()
- msg = ""
-
- if self.static_ipv4_nic_proto.value() == 0 and \
- self.dhcp_ipv4_nic_proto.value() == 0 and \
- self.disabled_ipv4_nic_proto.value() == 0:
- msg += " - IPv4 boot protocol (Disabled, Static, DHCP)"
-
- if self.static_ipv4_nic_proto.value() == 1:
- if self.ipv4_netdevip.value() == "":
- msg += " - IPv4 Address\n"
- if self.ipv4_netdevmask.value() == "":
- msg += " - IPv4 Netmask Address\n"
- if self.ipv4_netdevgateway.value() == "":
- msg += " - IPv4 Gateway Address\n"
-
- if self.static_ipv6_nic_proto.value() == 1:
- if self.ipv6_netdevmask.value() == "":
- msg += " - IPv6 Netmask Address\n"
- if self.ipv6_netdevgateway.value() == "":
- msg += " - IPv6 Gateway Address\n"
- # left out gateway check to prevent multiple ones
- if msg != "":
- msg = "Please Input:\n" + msg
- self._create_warn_screen()
- warn = ButtonChoiceWindow(self.screen, "Network Settings",
- msg, buttons=['Ok'])
- self.__nic_config_failed = 1
- self.ipv4_current_netdevip = self.ipv4_netdevip.value()
- self.ipv4_current_netdevmask = self.ipv4_netdevmask.value()
- self.ipv4_current_netdevgateway = \
- self.ipv4_netdevgateway.value()
- self.reset_screen_colors()
- return
-
- # If we are here: All checks passed, let's clean and set new values
- # clean: if exists remove static keys from dictionary
- if "OVIRT_IP_ADDRESS" in OVIRT_VARS:
- del OVIRT_VARS["OVIRT_IP_ADDRESS"]
- if "OVIRT_IP_NETMASK" in OVIRT_VARS:
- del OVIRT_VARS["OVIRT_IP_NETMASK"]
- if "OVIRT_IP_GATEWAY" in OVIRT_VARS:
- del OVIRT_VARS["OVIRT_IP_GATEWAY"]
- if "OVIRT_IPV6" in OVIRT_VARS:
- del OVIRT_VARS["OVIRT_IPV6"]
- if "OVIRT_ADDRESS" in OVIRT_VARS:
- del OVIRT_VARS["OVIRT_IPV6_ADDRESS"]
- if "OVIRT_IPV6_NETMASK" in OVIRT_VARS:
- del OVIRT_VARS["OVIRT_IPV6_NETMASK"]
- if "OVIRT_IPV6_GATEWAY" in OVIRT_VARS:
- del OVIRT_VARS["OVIRT_IPV6_GATEWAY"]
- if "OVIRT_VLAN" in OVIRT_VARS:
- del OVIRT_VARS["OVIRT_VLAN"]
-
- gridform = GridForm(self.screen, "", 2, 2)
- gridform.add(Label("Configuring Networking"), 0, 0)
- progress_bar = Scale(50, 100)
- gridform.add(progress_bar, 0, 1)
- progress_bar.set(50)
- gridform.draw()
- self.screen.refresh()
-
- augtool("rm", "/files/" + OVIRT_DEFAULTS + "/OVIRT_BOOTIF", "")
- if self.netvlanid.value() == "":
- augtool("rm", "/files/" + OVIRT_DEFAULTS + "/OVIRT_VLAN", "")
- if self.disabled_ipv4_nic_proto.value() == 1:
- augtool("set", "/files/" + OVIRT_DEFAULTS +
- "/OVIRT_BOOTIF", '"' + self.nic_lb.current() + '-DISABLED"')
- else:
- augtool("set", "/files/" + OVIRT_DEFAULTS +
- "/OVIRT_BOOTIF", '"' + self.nic_lb.current() + '"')
- augtool("rm", "/files/" + OVIRT_DEFAULTS + "/OVIRT_IP_ADDRESS", "")
- augtool("rm", "/files/" + OVIRT_DEFAULTS + "/OVIRT_IP_NETMASK", "")
- augtool("rm", "/files/" + OVIRT_DEFAULTS + "/OVIRT_IP_GATEWAY", "")
- augtool("rm", "/files/" + OVIRT_DEFAULTS + "/OVIRT_IPV6", "")
- augtool("rm", "/files/" + OVIRT_DEFAULTS +
- "/OVIRT_IPV6_ADDRESS", "")
- augtool("rm", "/files/" + OVIRT_DEFAULTS +
- "/OVIRT_IPV6_NETMASK", "")
- augtool("rm", "/files/" + OVIRT_DEFAULTS +
- "/OVIRT_IPV6_GATEWAY", "")
-
- # ... set new values:
- if self.static_ipv4_nic_proto.value() == 1:
- augtool("set", "/files/" + OVIRT_DEFAULTS +
- "/OVIRT_IP_ADDRESS", '"' +
- self.ipv4_netdevip.value() + '"')
- augtool("set", "/files/" + OVIRT_DEFAULTS +
- "/OVIRT_IP_NETMASK", '"' +
- self.ipv4_netdevmask.value() + '"')
- augtool("set", "/files/" + OVIRT_DEFAULTS +
- "/OVIRT_IP_GATEWAY", '"' +
- self.ipv4_netdevgateway.value() + '"')
-
- if self.netvlanid.value() != "":
- augtool("set", "/files/" + OVIRT_DEFAULTS + "/OVIRT_VLAN",
- '"' + self.netvlanid.value() + '"')
- if self.dhcp_ipv6_nic_proto.value() == 1:
- augtool("set", "/files/" + OVIRT_DEFAULTS + "/OVIRT_IPV6",
- '"' + "dhcp" + '"')
- if self.auto_ipv6_nic_proto.value() == 1:
- augtool("set", "/files/" + OVIRT_DEFAULTS + "/OVIRT_IPV6",
- '"' + "auto" + '"')
- if self.static_ipv6_nic_proto.value() == 1:
- augtool("set", "/files/" + OVIRT_DEFAULTS + "/OVIRT_IPV6",
- '"' + "static" + '"')
- if self.ipv6_netdevip.value():
- augtool("set", "/files/" + OVIRT_DEFAULTS +
- "/OVIRT_IPV6_ADDRESS", '"' +
- self.ipv6_netdevip.value() + '"')
- if self.ipv6_netdevmask.value():
- augtool("set", "/files/" + OVIRT_DEFAULTS +
- "/OVIRT_IPV6_NETMASK", '"' +
- self.ipv6_netdevmask.value() + '"')
- if self.ipv6_netdevgateway.value():
- augtool("set", "/files/" + OVIRT_DEFAULTS +
- "/OVIRT_IPV6_GATEWAY", '"' +
- self.ipv6_netdevgateway.value() + '"')
-
- network = Network()
- network.configure_interface()
- gridform = GridForm(self.screen, "", 2, 2)
- gridform.add(Label("Enabling Network Configuration"), 0, 0)
- progress_bar = Scale(50, 100)
- gridform.add(progress_bar, 0, 1)
- progress_bar.set(75)
- gridform.draw()
- self.screen.refresh()
- network.save_network_configuration()
- self.screen.popWindow()
- self.net_apply_config = 1
- return
- else:
- self.__nic_config_failed = 1
- return
-
- def process_authentication_config(self):
- self._create_warn_screen()
- ssh_restart = False
- profile_template = ""
- if self.current_rng_bytes != self.rng_bytes.value():
- self.rng_bytes = self.rng_bytes.value()
- if len(self.rng_bytes) > 0 and not self.rng_bytes.isdigit():
- ButtonChoiceWindow(self.screen, "Random Number Generator",
- "Invalid Byte Entry", buttons=['Ok'])
- return False
- unmount_config("/etc/profile")
- system_closefds("sed -i '/SSH_USE_STRONG_RNG/d' /etc/profile")
- if len(self.rng_bytes) > 0:
- profile_template += "export SSH_USE_STRONG_RNG=%s\n" \
- % self.rng_bytes
- if self.current_aes_ni_status != self.disable_aes_ni.value():
- unmount_config("/etc/profile")
- system_closefds("sed -i '/OPENSSL_DISABLE_AES_NI/d' /etc/profile")
- if self.disable_aes_ni.value() == 1:
- profile_template += "export OPENSSL_DISABLE_AES_NI=1\n"
- if len(profile_template) > 0:
- f = open("/etc/profile", "a")
- f.write(profile_template)
- f.close()
- ssh_restart = True
- ovirt_store_config("/etc/profile")
- if (self.root_password_1.value() != "" or
- self.root_password_2.value() != ""):
- if self.root_password_1.value() != self.root_password_2.value():
- ButtonChoiceWindow(self.screen, "Remote Access",
- "Passwords Do Not Match", buttons=['Ok'])
- else:
- set_password(self.root_password_1.value(), "admin")
- ButtonChoiceWindow(self.screen, "Remote Access",
- "Password Successfully Changed",
- buttons=['Ok'])
- logger.info("Admin Password Changed")
- if (self.ssh_passwd_status.value() == 1 and
- self.current_ssh_pwd_status == 0):
- self.current_ssh_pwd_status = augtool("set",
- "/files/etc/ssh/sshd_config/PasswordAuthentication",
- "yes")
- ssh_restart = True
- elif (self.ssh_passwd_status.value() == 0 and
- self.current_ssh_pwd_status == 1):
- self.current_ssh_pwd_status = augtool("set",
- "/files/etc/ssh/sshd_config/PasswordAuthentication",
- "no")
- ssh_restart = True
- if ssh_restart:
- system_closefds("service sshd restart &>/dev/null")
- ButtonChoiceWindow(self.screen, "Remote Access",
- "SSH Restarted", buttons=['Ok'])
- logger.info("SSH service restarted")
- ovirt_store_config("/etc/ssh/sshd_config")
- self.reset_screen_colors()
- return True
-
- def process_logging_config(self):
- ovirt_rsyslog(self.syslog_server.value(),
- self.syslog_port.value(), "udp")
- ovirt_netconsole(self.netconsole_server.value(),
- self.netconsole_server_port.value())
- set_logrotate_size(self.logrotate_max_size.value())
- return True
-
- def process_keyboard_config(self):
- self.kbd.set(self.kb_list.current())
- self.kbd.write()
- self.kbd.activate()
- # store keyboard config
- ovirt_store_config("/etc/sysconfig/keyboard")
- ovirt_store_config("/etc/vconsole.conf")
-
- def process_locked_screen(self):
- auth = PAM.pam()
- auth.start("passwd")
- auth.set_item(PAM.PAM_USER, self.login_username)
- global login_password
- login_password = self.login_password.value()
- auth.set_item(PAM.PAM_CONV, pam_conv)
- try:
- auth.authenticate()
- except PAM.error, (resp, code):
- logger.debug(resp)
- return False
- except:
- logger.debug("Internal error")
- return False
- else:
- self.screen_locked = False
- self.__current_page = STATUS_PAGE
- return True
-
- def process_config(self):
- self._create_blank_screen()
- self._set_title()
- self._gridform.add(Label("Applying Configuration"), 0, 0)
- self._gridform.draw()
- self.screen.refresh()
- if self.__current_page == NETWORK_PAGE:
- ret = self.process_network_config()
- if self.__current_page == AUTHENTICATION_PAGE:
- ret = self.process_authentication_config()
- if self.__current_page == LOGGING_PAGE:
- ret = self.process_logging_config()
- if self.__current_page == NETWORK_DETAILS_PAGE:
- ret = self.process_nic_config()
- if self.__current_page == KEYBOARD_PAGE:
- ret = self.process_keyboard_config()
- if self.__current_page == KDUMP_PAGE:
- ret = self.process_kdump_config()
- if self.__current_page == REMOTE_STORAGE_PAGE:
- ret = self.process_remote_storage_config()
- if self.__current_page == LOCKED_PAGE:
- ret = self.process_locked_screen()
- # plugin pages
- plugin_page = FIRST_PLUGIN_PAGE
- for p in self.plugins:
- if self.__current_page == plugin_page:
- ret = p.action()
- break
- plugin_page += 1
- if plugin_page > LAST_PLUGIN_PAGE:
- # should not happen
- break
- return
-
- def process_kdump_config(self):
- try:
- ret = 0
- if len(self.INVALID_KDUMP_MSG) > 0:
- self._create_warn_screen()
- ButtonChoiceWindow(self.screen, "Configuration Check",
- self.INVALID_KDUMP_MSG, buttons=["Ok"])
- self.INVALID_KDUMP_MSG = ""
- return False
- if os.path.exists("/etc/kdump.conf"):
- system("cp /etc/kdump.conf /etc/kdump.conf.old")
- if self.kdump_nfs_type.value() == 1:
- write_kdump_config(self.kdump_nfs_config.value())
- elif self.kdump_ssh_type.value() == 1:
- write_kdump_config(self.kdump_ssh_config.value())
- self.screen.popWindow()
- self.screen.finish()
- # systemctl change
- if os.path.exists("/usr/bin/kdumpctl"):
- kdump_prop_cmd = "kdumpctl propagate"
- else:
- kdump_prop_cmd = "service kdump propagate"
- try:
- ret = system_closefds("clear; %s" % kdump_prop_cmd)
- if ret == 0:
- ovirt_store_config("/root/.ssh/kdump_id_rsa.pub")
- ovirt_store_config("/root/.ssh/kdump_id_rsa")
- ovirt_store_config("/root/.ssh/known_hosts")
- ovirt_store_config("/root/.ssh/config")
- except KeyboardInterrupt:
- ret = 1
- if os.path.exists("/etc/kdump.conf.old"):
- system("rm -f /etc/kdump.conf.old")
- if os.path.exists("/etc/kdump.conf"):
- remove_config("/etc/kdump.conf")
- system("rm -f /etc/kdump.conf")
- elif self.kdump_restore_type.value() == 1:
- restore_kdump_config()
- else:
- remove_config("/etc/kdump.conf")
- system("service kdump stop")
- open('/etc/kdump.conf', 'w').close()
- return
- if not system("service kdump restart") or ret > 0:
- self._create_warn_screen()
- ButtonChoiceWindow(self.screen, "KDump Status",
- "KDump configuration failed, " +
- "location unreachable", buttons=['Ok'])
- self.reset_screen_colors()
- if os.path.exists("/etc/kdump.conf"):
- os.remove("/etc/kdump.conf")
- system("cat /etc/kdump.conf.old > /etc/kdump.conf")
- system("service kdump restart")
- else:
- ovirt_store_config("/etc/kdump.conf")
- if os.path.exists("/etc/kdump.conf.old"):
- system("rm /etc/kdump.conf.old")
- except KeyboardInterrupt:
- ret = 1
- if os.path.exists("/etc/kdump.conf"):
- remove_config("/etc/kdump.conf")
- system("rm -f /etc/kdump.conf")
- if os.path.exists("/etc/kdump.conf.old"):
- system("rm /etc/kdump.conf.old")
-
- def process_remote_storage_config(self):
- set_iscsi_initiator(self.iscsi_initiator_config.value())
- if len(self.nfsv4_domain.value()) > 0:
- set_nfsv4_domain(self.nfsv4_domain.value())
- def ssh_hostkey_btn_cb(self):
- self._create_warn_screen()
- ssh_hostkey_msg = ("RSA Host Key Fingerprint:\n%s\n\nRSA Host " +
- "Key:\n%s") % get_ssh_hostkey()
- ButtonChoiceWindow(self.screen, "Host Key", ssh_hostkey_msg,
- buttons=['Ok'], width=70)
- self.reset_screen_colors()
- self.gridform.draw()
- self._set_title()
-
- def cpu_details_btn_cb(self):
- self._create_warn_screen()
- ButtonChoiceWindow(self.screen, "CPU Details", cpu_details(),
- buttons=['Ok'], width=40)
- self.reset_screen_colors()
- self.gridform.draw()
- self._set_title()
-
- def quit(self):
- manual_teardown()
- sys.exit(2)
-
- def start(self):
- self.plugins = []
- self.last_option = LAST_OPTION
- for imp, mod, ispkg in pkgutil.iter_modules(
- ovirt_config_setup.__path__, "ovirt_config_setup."):
- module = __import__(mod, fromlist="dummy")
- self.plugins.append(module.get_plugin(self))
- self.last_option += 1
-
- active = True
- # check for screenlock status
- self.screen_locked = False
- while active and (self.__finished == False):
- logger.debug("Current Page: " + str(self.__current_page))
-
- self._create_blank_screen()
- screen = self.screen
-
- # apply any colorsets that were provided.
- if is_console():
- self.set_console_colors()
- screen.setColor(customColorset(1), "black", "magenta")
- screen.pushHelpLine(" ")
-
- if self.__current_page == NETWORK_PAGE:
- # Draw loading msg on background:
- self._set_title()
- screen.drawRootText(15, 10, "Loading page ...")
- screen.refresh()
-
- elements = self.get_elements_for_page(screen, self.__current_page)
-
- self.gridform = GridForm(screen, "", 2, 1)
- self._set_title()
- content = Grid(1, len(elements) + 3)
- self.menuo = 1
- self.menu_list = Listbox(18, width=20, returnExit=0,
- border=0, showCursor=0)
- self.menu_list.append(" Status", 1)
- self.menu_list.append(" Network", 2)
- self.menu_list.append(" Security", 3)
- self.menu_list.append(" Keyboard", 4)
- self.menu_list.append(" Logging", 5)
- self.menu_list.append(" Kernel Dump", 6)
- self.menu_list.append(" Remote Storage", 7)
- # plugin menu options
- plugin_page = FIRST_PLUGIN_PAGE
- for p in self.plugins:
- if p.label() == "Plugins":
- self._plugins_enabled = True
- self._plugins_pagenum = plugin_page
- self.menu_list.append(" " + p.label(), plugin_page)
- plugin_page += 1
- if plugin_page > LAST_PLUGIN_PAGE:
- # should not happen
- raise ("Too many plugins installed: max. %d are " +
- "allowed.") % ((LAST_PLUGIN_PAGE -
- FIRST_PLUGIN_PAGE) / 2 + 1)
- if (self.__current_page != LOCKED_PAGE and
- self.__current_page != NETWORK_DETAILS_PAGE and
- self.__current_page != SUPPORT_PAGE):
- self.menu_list.setCurrent(self.__current_page)
- if not self.screen_locked:
- if (not self.__current_page == NETWORK_DETAILS_PAGE and
- not self.__current_page == SUPPORT_PAGE):
- self.menu_list.setCallback(self.menuSpacing)
- self.gridform.add(self.menu_list, 0, 0,
- anchorTop=1, anchorLeft=1,
- growx=0)
- current_element = 0
- for element in elements:
- content.setField(element, 0, current_element,
- anchorLeft=1)
- current_element += 1
- (fullwidth, fullheight) = _snack.size()
- screen.height = fullheight
- current_element += 1
- buttons = []
- plugin_page = False
- if self.__current_page == NETWORK_PAGE:
- buttons.append(["Ping Test",
- PING_BUTTON])
- if self.__current_page != STATUS_PAGE \
- and self.__current_page < 20 \
- and not (self.__current_page is NETWORK_DETAILS_PAGE and \
- is_engine_configured()):
- if (self._plugins_enabled and self._plugins_pagenum > 0 and \
- self.__current_page == self._plugins_pagenum):
- buttons.append(["View Details", APPLY_BUTTON])
- else:
- buttons.append(["Apply", APPLY_BUTTON])
- if self.__current_page == NETWORK_DETAILS_PAGE:
- buttons.append(["Back", BACK_BUTTON])
- if self.__current_page == STATUS_PAGE:
- if not pwd_lock_check("admin"):
- buttons.append(["Lock", LOCK_BUTTON])
- buttons.append(["Log Off", LOG_OFF_BUTTON])
- buttons.append(["Restart", RESTART_BUTTON])
- buttons.append(["Power Off", POWER_OFF_BUTTON])
- if self.__current_page == LOCKED_PAGE:
- buttons.append(["Unlock", UNLOCK_BUTTON])
- if self.__current_page != STATUS_PAGE \
- and self.__current_page < 20 \
- and not (self.__current_page is NETWORK_DETAILS_PAGE and \
- is_engine_configured()):
- buttons.append(["Reset", RESET_BUTTON])
- if self.__current_page == SUPPORT_PAGE:
- buttons.append(["Back to Menu", MENU_BUTTON])
- if self.__current_page == NETWORK_DETAILS_PAGE:
- buttons.append(["Flash Lights to Identify",
- IDENTIFY_BUTTON])
- buttonbar = ButtonBar(screen, buttons, compact=1)
- if self.__current_page == LOCKED_PAGE:
- pad = 28
- else:
- pad = 0
- content.setField(buttonbar, 0, current_element, anchorLeft=1,
- padding=(pad, 0, 0, 0))
- self.gridform.add(content, 1, 0, anchorTop=1,
- padding=(2, 0, 0, 0))
- self.gridform.addHotKey("F2")
- self.gridform.addHotKey("F8")
- try:
- (top, left) = (1, 4)
- result = self.gridform.runOnce(top, left)
- menu_choice = self.menu_list.current()
- pressed = buttonbar.buttonPressed(result)
- self.menu_list.setCurrent(menu_choice)
- warn_message = ""
- try:
- conn = libvirt.openReadOnly(None)
- self.dom_count = conn.numOfDomains()
- conn.close()
- except:
- self.dom_count = "Failed to connect"
- if str(self.dom_count).isdigit():
- warn_message = ("There are %s Virtual Machines " +
- "running\n\n") % str(self.dom_count)
- else:
- warn_message = "Unable to verify any running vms\n\n"
- self._create_warn_screen()
- if pressed == IDENTIFY_BUTTON:
- system_closefds("ethtool -p " + self.nic_lb.current() +
- " 10")
- elif pressed == PING_BUTTON:
- self._ping_test = True
- ping_window = EntryWindow(self.screen, 'Network Ping Test', 'Enter Host to Ping', ['Host:'])
- res = ping_window[1]
- host = res[0]
- if ping_window[0] == "ok":
- # scrub host variable
- if len(host) > 0 and " " not in host and ";" not in host:
- cmd = "ping -c 3 %s" % host
- gridform = GridForm(self.screen, "", 1, 1)
- gridform.add(Label("Performing Ping Test"), 0, 0)
- gridform.draw()
- self.screen.refresh()
- proc = passthrough(cmd, log_func=logger.debug)
- ButtonChoiceWindow(self.screen, "Ping Test Results",
- proc.stdout, buttons=["OK"], width = 60)
- else:
- ButtonChoiceWindow(self.screen, "Ping Test Results",
- "Invalid Hostname: %s" % host, buttons=["OK"], width = 60)
- elif pressed == APPLY_BUTTON or pressed == UNLOCK_BUTTON:
- errors = []
- self.process_config()
- elif pressed == LOCK_BUTTON:
- self.__current_page = LOCKED_PAGE
- elif pressed == RESTART_BUTTON:
- self._create_warn_screen()
- warn = ButtonChoiceWindow(self.screen,
- "Confirm System Restart", warn_message +
- "This will restart the system, proceed?")
- if warn == "ok":
- screen.popWindow()
- screen.finish()
- system_closefds("reboot")
- elif pressed == POWER_OFF_BUTTON:
- self._create_warn_screen()
- warn = ButtonChoiceWindow(self.screen,
- "Confirm System Shutdown", warn_message +
- "This will shutdown the system, proceed?")
- if warn == "ok":
- screen.popWindow()
- screen.finish()
- system_closefds("/usr/bin/clear;shutdown -h now")
- elif pressed == LOG_OFF_BUTTON:
- # will exit and ovirt-admin-shell cleans up
- # tty lockfile and drops to login
- self.quit()
- elif (result is self.ssh_hostkey_btn):
- self.ssh_hostkey_btn_cb()
- elif (result is self.cpu_details_btn):
- self.cpu_details_btn_cb()
-
- if self.__current_page == LOCKED_PAGE:
- self.screen_locked = True
- elif result == "F8" and self.__current_page != LOCKED_PAGE:
- self.__current_page = SUPPORT_PAGE
- elif result == "F2" and self.__current_page != LOCKED_PAGE:
- self._create_warn_screen()
- title = "Shell Access"
- message = ("This is a non persistent filesystem. " +
- "Any changes will be lost on reboot. RPM " +
- "installations may succeed, but changes " +
- "will be lost when rebooted.")
- warn = ButtonChoiceWindow(self.screen, title, message)
- if warn == "ok":
- screen.popWindow()
- screen.finish()
- system_closefds("/usr/bin/clear;" +
- "SHELL=/bin/bash /bin/bash")
- else:
- if self.__current_page == NETWORK_PAGE:
- if menu_choice == NETWORK_PAGE:
- if pressed == RESET_BUTTON:
- self.__current_page = NETWORK_PAGE
- elif pressed == APPLY_BUTTON:
- self.__current_page == NETWORK_PAGE
- else:
- # We want to enter the NIC details ...
- current_network_config = (
- self.get_tui_field_network_config())
- if self.is_same_network_config(
- self.original_system_network_config,
- current_network_config):
- if self._ping_test:
- self._ping_test = False
- self.__current_page = (NETWORK_PAGE)
- else:
- self.__current_page = (
- NETWORK_DETAILS_PAGE)
- else:
- if pressed == PING_BUTTON:
- self.__current_page = (
- NETWORK_PAGE)
- else:
- warn = None
- self._create_warn_screen()
- title = "Confirm NIC Configuration"
- message = ("Unsaved network changes " +
- "detected, save and continue to " +
- "NIC configuration?")
- warn = ButtonChoiceWindow(self.screen,
- title, message)
- if warn == "ok":
- # apply and continue
- self.process_network_config()
- self.__current_page = (
- NETWORK_DETAILS_PAGE)
- self.preset_network_config = None
- else:
- # Do not apply, return
- self.preset_network_config = (
- current_network_config)
- else:
- self.__current_page = menu_choice
- if self.net_apply_config == 1:
- self.net_apply_config = 0
- elif self.__current_page == NETWORK_DETAILS_PAGE:
- if pressed == BACK_BUTTON:
- self.__current_page = NETWORK_PAGE
- elif pressed == RESET_BUTTON:
- self.__current_page = NETWORK_DETAILS_PAGE
- elif pressed == IDENTIFY_BUTTON:
- self.__current_page = NETWORK_DETAILS_PAGE
- elif self.net_apply_config == 1:
- self.__current_page = NETWORK_PAGE
- elif self.__nic_config_failed == 1:
- self.__current_page = NETWORK_DETAILS_PAGE
- elif is_managed():
- self.__current_page = NETWORK_PAGE
- else:
- self.__current_page = menu_choice
- elif self.__current_page == SUPPORT_PAGE:
- logger.debug("Pressed: " + str(pressed))
- if pressed == MENU_BUTTON:
- self.__current_page = STATUS_PAGE
- else:
- f = self.log_menu_list.current()
- screen.popWindow()
- screen.finish()
- system_closefds("/usr/bin/clear;" +
- "SHELL=/bin/false /usr/bin/less -R " + f)
- else:
- self.__current_page = menu_choice
- except Exception, error:
- self._create_warn_screen()
- os.remove(lockfile)
- ButtonChoiceWindow(screen,
- "An Exception Has Occurred",
- str(error) + "\n" + traceback.format_exc(),
- buttons=["OK"])
- screen.popWindow()
- screen.finish()
- self.restore_console_colors()
-
-if __name__ == "__main__":
- if is_rescue_mode():
- print "Unable to run setup in rescue mode"
- sys.exit(1)
- elif (is_booted_from_local_disk() or is_stateless() or
- "--force" in sys.argv):
- if manual_setup() and "--force" not in sys.argv:
- print ("Unable to run setup manually, Run \"exit\" to return " +
- "to setup")
- else:
- sys.setrecursionlimit(50000)
- tty = get_ttyname()
- lockfile = "/tmp/ovirt-setup.%s" % tty
- f = open(lockfile, "w").close()
- screen = NodeConfigScreen()
- screen.start()
- else:
- print "Setup must be run after installation and reboot"
- sys.exit(1)
diff --git a/scripts/legacy/ovirt-config-storage b/scripts/legacy/ovirt-config-storage
deleted file mode 100755
index 07fe8fd..0000000
--- a/scripts/legacy/ovirt-config-storage
+++ /dev/null
@@ -1,1356 +0,0 @@
-#!/bin/bash
-#
-# To automate the partitioning, set OVIRT_VOL_* in /etc/default/ovirt and call
-# ovirt-config-storage AUTO
-#
-# All sizes are in megabytes
-#
-
-. /usr/libexec/ovirt-functions
-
-ME=$(basename "$0")
-warn() { printf '%s: %s\n' "$ME" "$*" >&2; }
-die() { warn "$*"; exit 1; }
-
-trap '__st=$?; stop_log; exit $__st' 0
-trap 'exit $?' 1 2 13 15
-
-# check that we're not booted from local storage; if so then exit with an error
-if is_booted_from_local_disk; then
- die "You cannot configure storage on a running system. Please boot from CD/USB to configure storage."
-fi
-
-default_overcommit=0.5
-default_boot_size=50
-default_root_size=256
-default_config_size=5
-default_logging_size=2048
-# -1 indicates data partition should use remaining disk
-default_data_size=-1
-default_swap2_size=0
-default_data2_size=0
-boot_min_size=50
-root_min_size=256
-config_min_size=5
-logging_min_size=5
-data_min_size=5
-swap_min_size=5
-default_efi_size=256
-
-# return sd name for given #:# identifier
-get_sd_name() {
- local id="$1"
- local device_sys=$(grep -H "^$id$" /sys/block/*/dev | cut -d: -f1)
-
- if [ -n "$device_sys" ]; then
- echo $(basename $(dirname "$device_sys"))
- return 0
- fi
- return 1
-}
-
-# gets the dependent block devices for multipath devices
-get_multipath_deps() {
- local mpath_device="$(basename "$1")"
- local deplist_var="$2"
- local deplist=""
-
- if [[ ! "$1" =~ '/dev/mapper' ]]; then
- evel $deplist_var=$(basename $1)
- return
- fi
- #get dependencies for multipath device
- local deps=$(dmsetup deps -u "mpath-$mpath_device" \
- | sed -r 's/\(([0-9]+), ([0-9]+)\)/\1:\2/g' \
- | sed 's/ /\n/g' | grep [0-9]:[0-9] )
-
- for dep in $deps
- do
- local device="$(get_sd_name "$dep")"
- if [ -n "$device" ]; then
- if [ -z "$deplist" ]; then
- deplist="$device"
- else
- deplist="$deplist $device"
- fi
- fi
- done
-
- eval $deplist_var='$deplist'
-}
-
-get_drive_size()
-{
- local drive="$1"
- local space_var="$2"
-
- local size=$(sfdisk -s "$drive" 2>/dev/null)
- size=$(echo "scale=0; $size / 1024" | bc -l)
-
- echo "$drive ($size MB)"
- if [ -n "$space_var" ]; then
- eval $space_var="$size"
- fi
-}
-
-check_partition_sizes()
-{
- local disk_size need_size
-
- local min_data_size="$DATA_SIZE"
- if [ "$DATA_SIZE" = -1 ]; then
- min_data_size=5
- fi
- local min_data2_size="$DATA2_SIZE"
- if [ "$DATA2_SIZE" = -1 ]; then
- min_data2_size=5
- fi
-
- printf "\n"
- if [ "$OVIRT_ISCSI_ENABLED" = "y" ]; then
- get_drive_size "$BOOTDRIVE" BOOTDRIVESPACE
- drive_list="BOOT"
- BOOT_NEED_SIZE="$BOOT_SIZE"
- else
- get_drive_size "$ROOTDRIVE" ROOTDRIVESPACE
- oldIFS="$IFS"
- IFS="$SEP"
- for drv in $HOSTVGDRIVE; do
- get_drive_size "$drv" DRIVESPACE
- if [ -n "${HOSTVGDRIVESPACE}" ]; then
- HOSTVGDRIVESPACE=$(echo "scale=0;" \
- "$HOSTVGDRIVESPACE + $DRIVESPACE" | bc -l)
- else
- HOSTVGDRIVESPACE=$DRIVESPACE
- fi
- done
- if [ -n "${APPVGDRIVE}" ]; then
- for drv in $APPVGDRIVE; do
- get_drive_size "$drv" DRIVESPACE
- if [ -n "${APPVGDRIVESPACE}" ]; then
- APPVGDRIVESPACE=$(echo "scale=0;" \
- "$APPVGDRIVESPACE + $DRIVESPACE" | bc -l)
- else
- APPVGDRIVESPACE=$DRIVESPACE
- fi
- done
- APPVG_NEED_SIZE=$(echo "scale=0; $SWAP2_SIZE + $min_data2_size" | bc -l)
- fi
- IFS="$oldIFS"
- ROOT_NEED_SIZE=$(echo "scale=0; $ROOT_SIZE * 2 + $EFI_SIZE"| bc -l)
- HOSTVG_NEED_SIZE=$(echo "scale=0;" \
- "$SWAP_SIZE + $CONFIG_SIZE + $LOGGING_SIZE + $min_data_size" | bc -l)
-
- if [ "$ROOTDRIVE" = "$HOSTVGDRIVE" ]; then
- drive_list="ROOT"
- ROOT_NEED_SIZE=$(echo "scale=0; $ROOT_SIZE * 2 + $HOSTVG_NEED_SIZE"| bc -l)
- else
- drive_list="ROOT HOSTVG"
- oldIFS="$IFS"
- IFS="$SEP"
- for drv in $HOSTVGDRIVE; do
- # XXX first in hostvgdrive list is assumed to be rootdrive
- if [ "$ROOTDRIVE" = "$drv" ]; then
- HOSTVGDRIVESPACE=$(echo "scale=0; $HOSTVGDRIVESPACE - $ROOT_NEED_SIZE"| bc -l)
- fi
- break
- done
- IFS="$oldIFS"
- fi
- if [ -n "${APPVGDRIVE}" ]; then
- drive_list="${drive_list} APPVG"
- fi
- fi
-
- for drive in $drive_list; do
- drive_need_size=$(eval "echo \${$(echo ${drive}_NEED_SIZE)"})
- drive_disk_size=$(eval "echo \${$(echo ${drive}DRIVESPACE)"})
-
- if [ $drive_need_size -gt $drive_disk_size ]; then
- local gap_size=$(echo "scale=0; $drive_need_size-$drive_disk_size;" | bc -l)
- printf "\n"
- printf "=============================================================\n"
- printf "The target storage device is too small for the desired sizes:\n"
- printf " Disk Target: $drive \n"
- printf " Size of target storage device: $drive_disk_size MB\n"
- printf " Total storage size to be used: $drive_need_size MB\n"
- printf "\n"
- printf "You need an additional $gap_size MB of storage.\n"
- printf "\n"
- return 1
- else
- printf "Required Space : $drive_need_size MB\n\n"
- fi
- done
-}
-
-manual_input()
-{
- local manual_device
- local return_var="$1"
- while true; do
- read -rp "Enter disk device path: " manual_device
- if [ -z "$manual_device" ]; then
- return 1
- fi
- manual_device="$(translate_multipath_device "$manual_device")"
- if [ -n "$manual_device" ]; then
- if [ -b "$(readlink -f "$manual_device")" ]; then
- eval $return_var="$manual_device"
- return 0
- fi
- else
- return 1
- fi
- done
-}
-
-# Find a usable/selected storage device.
-# If there are none, give a diagnostic and return nonzero.
-# If there is just one, e.g., /dev/sda, treat it as selected (see below).
-# and return 0. If there are two or more, make the user select one
-# or decline. Upon decline, return nonzero. Otherwise, print the
-# selected name, then return 0.
-# Sample output: /dev/sda
-get_dev_name()
-{
- local devices=""
- # list separator
- for d in $(ls -db /sys/block/[hsv]d*); do
- devices="/dev/$(basename "$d")${LF}${devices}"
- done
-
- local byid_list=$(find /dev/disk/by-id -mindepth 1 -not -name '*-part*' 2>/dev/null)
- for d in $byid_list; do
- local devicename="$(readlink -f "$d")"
- if udevadm info --name="$(basename "$devicename")" --query=property | grep -q ^ID_BUS; then
- devices="${devicename}${LF}${devices}"
- fi
- done
-
- # FIXME: workaround for detecting cciss devices
- for d in $(ls /dev/cciss/ 2>/dev/null); do
- if [[ ! "$d" =~ p[0-9]+\$ ]]; then
- devices="/dev/cciss/$d${LF}${devices}"
- fi
- done
-
- # include multipath devices
- local devs_to_remove=""
- oldIFS="$IFS"
- IFS="$LF"
- for d in $(dmsetup ls --target=multipath | cut -f1)
- do
- devices="/dev/mapper/$d${LF}${devices}"
- local sd_devs=""
- IFS="$oldIFS" get_multipath_deps "/dev/mapper/$d" sd_devs
- local dm_dev=$(multipath -ll "$d" | grep "$d" | sed -r 's/^.*(dm-[0-9]+ ).*$/\1/' )
- devs_to_remove="${devs_to_remove} ${sd_devs} ${dm_dev} "
- # example: ++ devs_to_remove=' sda dm-2 '
- done
- # Remove /dev/sd* devices that are part of a multipath device
- local dev_list=""
- for d in $devices
- do
- if [[ ! "$devs_to_remove" =~ "$(basename "$d") " ]]; then
- dev_list="$d${LF}$dev_list"
- fi
- done
- devices=$(echo "$dev_list" | sort -u | grep -v "^$")
- local num_devices=$(echo "$devices" | wc -l)
-
- # If there's only one device, use it.
- case $num_devices in
- 0) warn "ERROR: found no usable block device"; IFS="$oldIFS"; return 1;;
- 1) echo "$devices"; IFS="$oldIFS"; return 0;;
- *) ;; # found more than one
- esac
-
- # There are two or more; make the user choose.
- # display description for each disk
- for d in $devices; do
- get_drive_size "$d" >&2
- done
- local rc=0
- local choices="$devices${LF}Abort${LF}Manual Selection"
- select device in $choices
- do
- test "$device" = Abort && rc=1
- test "$device" = "Manual Selection" && manual_input device
- test "$device" = "Manual Selection" && rc=1
- test -z "$device" && continue
- test $rc = 0 && echo "$device"
- break
- done
- IFS="$oldIFS"
- return $rc
-}
-
-do_configure()
-{
- local name_and_size
- if [ "$OVIRT_ISCSI_ENABLED" = "y" ]; then
- printf "\n\nPlease select the disk to use for the Boot partition.\n\n"
- BOOTDRIVE="$(get_dev_name)" || return 0
- get_drive_size "$BOOTDRIVE" BOOTDRIVESPACE
- echo "$BOOTDRIVE"
- OVIRT_ISCSI_HOSTVG="y"
- printf "\n\nPlease select the disk to use for the HostVG.\n\n"
- HOSTVGDRIVE=$(get_dev_name) || return 0
- get_drive_size "$HOSTVGDRIVE" HOSTVGDRIVESPACE
- echo "$HOSTVGDRIVE"
- else
- printf "\n\nPlease select the disk to use for the Root.\n\n"
- ROOTDRIVE=$(get_dev_name) || return 0
- get_drive_size "$ROOTDRIVE" ROOTDRIVESPACE
- if ask_yes_or_no "Will Root be shared with other nodes ([Y]es/[N]o)?"; then
- OVIRT_SHARED_ROOT="y"
- if ask_yes_or_no "Partition and install Root?"; then
- OVIRT_ROOT_INSTALL="y"
- else
- OVIRT_ROOT_INSTALL="n"
- fi
- else
- OVIRT_SHARED_ROOT="n"
- OVIRT_ROOT_INSTALL="y"
- fi
-
- augtool <<EOF
- set /files$OVIRT_DEFAULTS/OVIRT_SHARED_ROOT $OVIRT_SHARED_ROOT
- set /files$OVIRT_DEFAULTS/OVIRT_ROOT_INSTALL $OVIRT_ROOT_INSTALL
-EOF
-
- printf "\n\nPlease select the disk to use for the HostVG.\n\n"
- while true; do
- HOSTVGDRIVE=$(get_dev_name) || return 0
- if [ "$OVIRT_SHARED_ROOT" = "y" ]; then
- if [ "$ROOTDRIVE" = "$HOSTVGDRIVE" ]; then
- printf "\n\nRoot Drive and HostVG drive must be different when shared\n\n"
- return 1
- else
- break;
- fi
- fi
- break;
- done
-
- local skipped=false
- if check_existing_hostvg "$HOSTVGDRIVE" devs; then
- oldIFS="$IFS"
- IFS="$SEP"
- for dev in $devs
- do
- printf "Removing HostVG on $dev will erase the drive and cannot be undone\n"
- if ask_yes_or_no "Do you want to remove HostVG from $dev (y/n)?"; then
- start_log
- if ! wipe_lvm_on_disk "$dev"; then
- stop_log
- IFS="$oldIFS"
- return 1
- fi
- stop_log
- else
- skipped=true
- fi
- done
- IFS="$oldIFS"
- fi
- $skipped && printf "Installation cannot proceed with existing HostVG.\n" && return 0
- get_drive_size "$HOSTVGDRIVE" HOSTVGDRIVESPACE
- echo "$HOSTVGDRIVESPACE"
- fi
- printf "\n\nPlease configure storage partitions.\n\n"
- printf "* Enter partition sizes in MB.\n"
- printf "* A value of 0 indicates the partition should be disabled.\n"
- printf "* If the partition is enabled, it will have a minimum valid size.\n"
- printf "* Size remaining value is approximate due to cylinder rounding\n"
- printf " during partitioning.\n"
- printf "* For the Data partition, a size of -1 indicates that the\n"
- printf " partition should use up the remaining space on the disk.\n\n"
-
- if do_review; then
- if ask_yes_or_no "Use these default values ([Y]es/[N]o)?"; then
- return
- fi
- else
- printf "Selected disk is too small for default storage configuration"
- fi
-
- local space_left=$HOSTVGDRIVESPACE
- if [ "$OVIRT_ISCSI_ENABLED" = "y" -a "$OVIRT_ISCSI_HOSTVG" != "y" ]; then
- partlist=""
- local space_left=$BOOTDRIVESPACE
- elif [ "$OVIRT_ISCSI_ENABLED" = "y" -a "$OVIRT_ISCSI_HOSTVG" = "y" ]; then
- partlist="swap config logging data"
- local space_left=$BOOTDRIVESPACE
- elif [ "$OVIRT_ROOT_INSTALL" = "n" ]; then
- partlist="swap config logging data"
- else
- partlist="swap config logging data"
- fi
- for part in $partlist ; do
- part_regexp="^0$"
- if [ "$part" = "data" ]; then
- part_regexp="^\-1|0$"
- fi
- uc=$(echo $part|tr '[[:lower:]]' '[[:upper:]]')
- size_var=${uc}_SIZE
- eval "size=\$$size_var"
- min_size_var=${part}_min_size
- eval "min_size=\$$min_size_var"
-
- while true; do
- printf "\n"
- read -ep "Change $part partition size. (Def. ${size}MB), Min. ${min_size}MB, Max. ~${space_left}MB? or Q to quit "
- mb_input=$REPLY
- test -z "$mb_input" && mb_input=$size
- local size_used=0
- if [ $mb_input = "q" -o $mb_input = "Q" ]; then
- printf "Aborting"
- return
- elif [[ $mb_input =~ ^-*[0-9]+$ ]]; then
- if [[ $mb_input -ge $min_size || $mb_input =~ $part_regexp ]] \
- && [[ $mb_input -le $space_left ]] ; then
- eval "$size_var=$mb_input"
- size_used=$mb_input
- break;
- else
- printf "invalid $part size: $mb_input. "
- printf "Does not fall into specified range.\n"
- fi
- else
- printf "invalid $part size: '$mb_input'.\n"
- fi
- done
- space_left=$(echo "scale=0;$space_left - $size_used" | bc -l)
- done
-
- if ! check_partition_sizes; then
- printf "Please try partitioning again.\n"
- ROOTDRIVE=
- return 1
- fi
-
- # save input variables
- augtool <<EOF
-set /files$OVIRT_DEFAULTS/OVIRT_VOL_BOOT_SIZE $BOOT_SIZE
-set /files$OVIRT_DEFAULTS/OVIRT_VOL_SWAP_SIZE $SWAP_SIZE
-set /files$OVIRT_DEFAULTS/OVIRT_VOL_ROOT_SIZE $ROOT_SIZE
-set /files$OVIRT_DEFAULTS/OVIRT_VOL_CONFIG_SIZE $CONFIG_SIZE
-set /files$OVIRT_DEFAULTS/OVIRT_VOL_LOGGING_SIZE $LOGGING_SIZE
-set /files$OVIRT_DEFAULTS/OVIRT_VOL_DATA_SIZE $DATA_SIZE
-EOF
-
- if [ -n "$BOOTDRIVE" ]; then
- augtool <<EOF
-set /files$OVIRT_DEFAULTS/OVIRT_INIT_BOOT "$BOOTDRIVE"
-EOF
- else
- augtool <<EOF
-set /files$OVIRT_DEFAULTS/OVIRT_INIT "$ROOTDRIVE"
-EOF
- fi
-}
-
-do_review()
-{
- if [[ -z "$ROOTDRIVE" && "$OVIRT_ISCSI_ENABLED" != "y" ]]; then
- printf "\nNo Root storage device selected.\n"
- return 1
- fi
-
- if [[ -z "$HOSTVGDRIVE" ]]; then
- printf "\nNo HostVG storage device selected.\n"
- return 1
- fi
- local is_negative=0
-
- local data_size_display="$DATA_SIZE MB"
- if [ "$DATA_SIZE" = -1 ]; then
-
- if [ "$ROOTDRIVE" = "$HOSTVGDRIVE" ]; then
- local remaining_mb=$(( $ROOTDRIVESPACE - $SWAP_SIZE \
- - $ROOT_SIZE * 2 - $CONFIG_SIZE - $LOGGING_SIZE ))
- test $remaining_mb -lt 0 && is_negative=1
- else
- local remaining_mb=$(( $HOSTVGDRIVESPACE - $SWAP_SIZE - $CONFIG_SIZE - $LOGGING_SIZE ))
- test $remaining_mb -lt 0 && is_negative=1
- fi
- data_size_display="$remaining_mb MB"
- fi
-
- if [ "$OVIRT_ISCSI_ENABLED" != "y" ]; then
- cat <<EOF
-
-The selected disk will be repartitioned as follows:
-================================================
- Root Drive: $(get_drive_size "$ROOTDRIVE")
- HostVG Drive: $(get_drive_size "$HOSTVGDRIVE")
- Swap partition size: $SWAP_SIZE MB
- Installation partition size: $ROOT_SIZE * 2 MB
- Configuration partition size: $CONFIG_SIZE MB
- Logging partition size: $LOGGING_SIZE MB
- Data partition size: $data_size_display
-
-EOF
- else
- cat <<EOF
-
-The selected disk will be repartitioned as follows:
-================================================
- Boot Drive: $(get_drive_size "$BOOTDRIVE")
- Boot partition size: $BOOT_SIZE
-
-EOF
-
- fi
- if [ "$OVIRT_ISCSI_HOSTVG" = "y" ]; then
- cat <<EOF
- HostVG Drive: $(get_drive_size "$HOSTVGDRIVE")
- Swap partition size: $SWAP_SIZE MB
- Installation partition size: $ROOT_SIZE * 2 MB
- Configuration partition size: $CONFIG_SIZE MB
- Logging partition size: $LOGGING_SIZE MB
- Data partition size: $data_size_display
-EOF
- fi
- return ${is_negative-0}
-
-}
-
-#Check for an existing VG on any device on the system.
-# Return 0 if there is a VG found, unless only one found is on $1
-# Return 1 if no VG found or only found on $1
-check_existing_hostvg()
-{
- local install_dev=
- local dev=
- oldIFS="$IFS"
- IFS="$SEP"
- for dev in $1; do
- if [ -n "${install_dev}" ]; then
- install_dev="${install_dev}+|${dev}"
- # XXX +| => wrong match e.g. sdaa vs sda ?
- else
- install_dev="${dev}"
- fi
- done
- IFS="$oldIFS"
- local devices_var=$2
- local vgname=
- if [ -n "$3" ]; then
- vgname="$3"
- else
- vgname="HostVG"
- fi
-
- if [ -z "$install_dev" ]; then
- devices="$(pvs --separator="${TAB}" -o pv_name,vg_name --noheadings | \
- grep "${vgname}" | cut -f1)"
- else
- devices="$(pvs --separator="${TAB}" -o pv_name,vg_name --noheadings | \
- egrep -v "${install_dev}" | grep "${vgname}" | cut -f1)"
- fi
- rc=1
- if [ -n "$devices" ]; then
- printf "\n"
- printf "There appears to already be an installation on another device:\n"
- oldIFS="$IFS"
- IFS="$LF"
- for device in $devices; do
- printf "\t$device\n"
- done
- IFS="$oldIFS"
- printf "The installation cannot proceed until the device is removed\n"
- printf "from the system of the HostVG volume group is removed.\n"
- rc=0
- fi
-
- test -n "$devices_var" && eval "$devices_var"="\"$devices\""
-
- return $rc
-}
-
-# cleanup lvms on selected disk
-# - remove mounted filesystems
-# - remove LVM volumes and groups
-wipe_lvm_on_disk()
-{
- local devs=${1-"$HOSTVGDRIVE"}
- local query1=
- local query2=
- unmount_logging
- unmount_config /etc/default/ovirt
-# local part_delim="p"
-# if [[ "$dev" =~ /dev/[hsv]d ]]; then
-# part_delim=""
-# fi
- oldIFS="$IFS"
- IFS="$SEP"
- for d in $devs; do
- local part_delim="p"
- if [[ "$d" =~ "/dev/sd" ]]; then
- part_delim=""
- fi
- if [ -n "${query1}" ]; then
- query1="${query1} ${d} ${d}${part_delim}[0-9]*"
- else
- query1="${d} ${d}${part_delim}[0-9]*"
- fi
- if [ -n "${query2}" ]; then
- query2="${query2}+|${d}${part_delim}[0-9]+|${d}"
- else
- query2="${d}${part_delim}[0-9]+|${d}"
- fi
- done
- IFS="$oldIFS"
- for vg in $(pvs -o vg_uuid --noheadings "$query1" 2>/dev/null|sort -u); do
-
-# for vg in $(pvs -o vg_uuid --noheadings $dev $dev${part_delim}[0-9]* \
-# --config " devices { filter = [ \"a/.*/\" ] } " \
-# 2>/dev/null|sort -u); do
- if pvs -o pv_name,vg_uuid --noheadings \
- --config " devices { filter = [ \"a/.*/\" ] } " | \
- grep "$vg" | egrep -v -q "${query2} " 2>/dev/null; then
-
-# grep "$vg" | egrep -v -q "${dev}${part_delim}[0-9]+|${dev} " 2>/dev/null; then
- log "The volume group \"$vg\" spans multiple disks."
- log "This operation cannot complete. Please manually"
- log "cleanup the storage using standard linux tools."
- return 1
- fi
- vg_name=$(vgs -o vg_name,vg_uuid --noheadings \
- --config " devices { filter = [ \"a|$dev|\", \"r/.*/\" ] } " \
- 2>/dev/null | grep -w "$vg" | awk '{print $1}')
- wipe_volume_group "${vg_name}" "$dev"
- done
- return 0
-}
-
-reread_partitions()
-{
- local drive="$1"
- udevadm settle 2> /dev/null
-
- if [[ "$drive" =~ "/dev/mapper" ]]; then
- # kpartx -a -p p "$drive"
- # XXX fails with spaces in device names (TBI)
- # ioctl(3, DM_TABLE_LOAD, 0x966980) = -1 EINVAL (Invalid argument)
- # create/reload failed on 0QEMU QEMU HARDDISK drive-scsi0-0-0p1
-
- # flush to sync DM and blockdev, workaround from rhbz#623846#c14
- echo 3 > /proc/sys/vm/drop_caches
- set +e
- until partprobe "$drive"; do
- log "retrying partprobe"
- sleep 1
- done
- set -e
- else
- # ioctl 0x0000125F BLKRRPART void
- set +e
- until blockdev --rereadpt "$drive"; do
- log "retrying blockdev"
- sleep 1
- done
- set -e
- fi
-}
-
-create_hostvg()
-{
- log "Creating LVM partition(s) for HostVG"
- local drv
- local parted_cmd
- oldIFS="$IFS"
- IFS="$SEP"
- local physical_vols=
- for drv in $HOSTVGDRIVE; do
- if [ "$ROOTDRIVE" = "$drv" ]; then
- parted_cmd="mkpart primary ext2 ${RootBackup_end}M -1"
- hostvgpart="4"
- elif [ "$BOOTDRIVE" = "$drv" ]; then
- parted_cmd="mkpart primary ext2 ${boot_size_si} -1"
- hostvgpart="2"
- # FIXME : set for gtpsync/parted compat for now
- ROOTDRIVE=$BOOTDRIVE
- else
- parted_cmd="mkpart primary ext2 2048s -1"
- hostvgpart="1"
- fi
- while true; do
- set +e
- parted -s "$drv" "$parted_cmd"
- parted -s "$drv" "set $hostvgpart lvm on"
- set -e
- reread_partitions "$drv"
- if [ -e "${drv}${hostvgpart}" -o "${drv}p${hostvgpart}" ]; then
- break
- fi
- done
-
- # sync GPT to the legacy MBR partitions
- if [ "${OVIRT_INSTALL_ROOT}" = "y" ]; then
- if [ "gpt" = "$LABEL_TYPE" ]; then
- log "Running gptsync to create legacy mbr"
- gptsync "$ROOTDRIVE"
- fi
- fi
-
- partpv="${drv}${hostvgpart}"
- if [ ! -e "$partpv" ]; then
- # e.g. /dev/cciss/c0d0p2 or /dev/mapper/<wwid>p3
- partpv="${drv}p${hostvgpart}"
- fi
- log "Creating physical volume"
- for count in $(seq 1 10); do
- if [ ! -e "$partpv" ]; then
- sleep 1
- if [[ "$count" == "10" && ! -e "$partpv" ]]; then
- log "$partpv is not available!"
- exit 1
- fi
- fi
- done
- dd if=/dev/zero of="${partpv}" bs=1024k count=1
- pvcreate -ff -y "${partpv}"
- physical_vols="${physical_vols}${SEP}${partpv}"
- done
-
- log "Creating volume group HostVG"
- local is_first=1
- for drv in $physical_vols; do
- if [ -z "$drv" ]; then
- continue
- fi
- if [ "$is_first" ]; then
- vgcreate HostVG "$drv"
- is_first=
- else
- vgextend HostVG "$drv"
- fi
- done
- IFS="$oldIFS"
-
- if [ "$SWAP_SIZE" -gt 0 ]; then
- log "Creating swap partition"
- lvcreate --name Swap --size ${SWAP_SIZE}M /dev/HostVG
- if [ -n "${OVIRT_CRYPT_SWAP}" ]; then
- echo "SWAP /dev/HostVG/Swap /dev/mapper/ovirt-crypt-swap ${OVIRT_CRYPT_SWAP}" >> /etc/ovirt-crypttab
- else
- mkswap -L "SWAP" /dev/HostVG/Swap
- echo "/dev/HostVG/Swap swap swap defaults 0 0" >> /etc/fstab
- fi
- fi
- if [ "$CONFIG_SIZE" -gt 0 ]; then
- log "Creating config partition"
- lvcreate --name Config --size ${CONFIG_SIZE}M /dev/HostVG
- mke2fs -j -t ext4 /dev/HostVG/Config -L "CONFIG"
- tune2fs -c 0 -i 0 /dev/HostVG/Config
- fi
- if [ "$LOGGING_SIZE" -gt 0 ]; then
- log "Creating log partition"
- lvcreate --name Logging --size ${LOGGING_SIZE}M /dev/HostVG
- mke2fs -j -t ext4 /dev/HostVG/Logging -L "LOGGING"
- tune2fs -c 0 -i 0 /dev/HostVG/Logging
- echo "/dev/HostVG/Logging /var/log ext4 defaults,noatime 0 0" >> /etc/fstab
- fi
-
- local use_data=1
- if [ "$DATA_SIZE" -eq -1 ]; then
- log "Creating data partition with remaining free space"
- lvcreate --name Data -l 100%FREE /dev/HostVG
- use_data=0
- elif [ "$DATA_SIZE" -gt 0 ]; then
- log "Creating data partition"
- lvcreate --name Data --size ${DATA_SIZE}M /dev/HostVG
- use_data=0
- fi
-
- if [ "$use_data" = 0 ]; then
- mke2fs -j -t ext4 /dev/HostVG/Data -L "DATA"
- tune2fs -c 0 -i 0 /dev/HostVG/Data
- echo "/dev/HostVG/Data /data ext4 defaults,noatime 0 0" >> /etc/fstab
- echo "/data/images /var/lib/libvirt/images bind bind 0 0" >> /etc/fstab
- echo "/data/core /var/log/core bind bind 0 0" >> /etc/fstab
- fi
-
- # end critical section
- set +x
- set +e
-
- log "Mounting config partition"
- if mount_config; then
- ovirt_store_config /etc/fstab
- fi
-
- mount_logging
- if [ "$use_data" = 0 ]; then
- log "Mounting data partition"
- mount_data
- fi
- log "Completed HostVG!"
-
-}
-
-create_appvg()
-{
- log "Creating LVM partition(s) for AppVG"
- local drv
- local physical_vols=
- oldIFS="$IFS"
- IFS="$SEP"
- for drv in $APPVGDRIVE; do
- wipe_partitions "$drv"
- reread_partitions "$drv"
- log "Labeling Drive: $drv"
- appvgpart="1"
- while true; do
- set +e
- parted -s "$drv" "mklabel ${LABEL_TYPE} mkpart primary ext2 2048s -1 set $appvgpart lvm on print"
- set -e
- reread_partitions "$drv"
- if [ -e "${drv}${appvgpart}" -o "${drv}p${appvgpart}" ]; then
- break
- fi
- done
-
- partpv="${drv}${appvgpart}"
- if [ ! -e "$partpv" ]; then
- # e.g. /dev/cciss/c0d0p2
- partpv="${drv}p${appvgpart}"
- fi
- log "Creating physical volume"
- if [ ! -e "$partpv" ]; then
- log "$partpv is not available!"
- exit 1
- fi
- dd if=/dev/zero of="${partpv}" bs=1024k count=1
- pvcreate -ff -y "${partpv}"
- physical_vols="${physical_vols}${SEP}${partpv}"
- done
-
- log "Creating volume group AppVG"
- local is_first=1
- for drv in $physical_vols; do
- if [ -z "$drv" ]; then
- continue
- fi
- if [ "$is_first" ]; then
- vgcreate AppVG "$drv"
- is_first=
- else
- vgextend AppVG "$drv"
- fi
- done
- IFS="$oldIFS"
-
- if [ "$SWAP2_SIZE" -gt 0 ]; then
- log "Creating swap2 partition"
- lvcreate --name Swap2 --size ${SWAP2_SIZE}M /dev/AppVG
- if [ -n "${OVIRT_CRYPT_SWAP2}" ]; then
- echo "SWAP2 /dev/AppVG/Swap2 /dev/mapper/ovirt-crypt-swap2 ${OVIRT_CRYPT_SWAP2}" >> /etc/ovirt-crypttab
- else
- mkswap -L "SWAP2" /dev/AppVG/Swap2
- echo "/dev/AppVG/Swap2 swap swap defaults 0 0" >> /etc/fstab
- fi
- fi
-
- local use_data=1
- if [ "$DATA2_SIZE" -eq -1 ]; then
- log "Creating data2 partition with remaining free space"
- lvcreate --name Data2 -l 100%FREE /dev/AppVG
- use_data=0
- elif [ "$DATA2_SIZE" -gt 0 ]; then
- log "Creating data2 partition"
- lvcreate --name Data2 --size ${DATA2_SIZE}M /dev/AppVG
- use_data=0
- fi
-
- if [ "$use_data" = 0 ]; then
- mke2fs -j -t ext4 /dev/AppVG/Data2 -L "DATA"
- tune2fs -c 0 -i 0 /dev/AppVG/Data2
- echo "/dev/AppVG/Data2 /data2 ext4 defaults,noatime 0 0" >> /etc/fstab
- fi
-
- if [ "$use_data" = 0 ]; then
- log "Mounting data2 partition"
- mount_data2
- fi
- log "Completed AppVG!"
-
-}
-
-perform_partitioning()
-{
- if [ -z "$HOSTVGDRIVE" -a "$OVIRT_ISCSI_ENABLED" != "y" ]; then
- printf "\nNo storage device selected.\n"
- return
- fi
-
- if [ -z "$BOOTDRIVE" -a "$OVIRT_ISCSI_ENABLED" = "y" ]; then
- printf "\nNo storage device selected.\n"
- return
- fi
- start_log
-
- log "Saving parameters"
- unmount_config /etc/default/ovirt
-
- log "Removing old LVM partitions"
- wipe_volume_group HostVG
- wipe_volume_group AppVG
- wipe_lvm_on_disk "$HOSTVGDRIVE"
- [ -n "${APPVGDRIVE}" ] && wipe_lvm_on_disk "$APPVGDRIVE"
- wipe_lvm_on_disk "$ROOTDRIVE"
-
- # begin critical section
- set -e
- set -x
-
- MEM_SIZE_MB=$(echo "scale=0; $MEM_SIZE_MB / 1024;" | bc -l)
- boot_size_si=$(echo "scale=0; $BOOT_SIZE * (1024 * 1024) / (1000 * 1000)" | bc -l)
-
- if [ "$OVIRT_ISCSI_ENABLED" = "y" ]; then
- log "iSCSI enabled, partitioning boot drive: $BOOTDRIVE"
- wipe_partitions "$BOOTDRIVE"
- reread_partitions "$BOOTDRIVE"
- log "Creating boot partition"
- while true; do
- set +e
- parted -s "$BOOTDRIVE" "mklabel ${LABEL_TYPE} mkpart primary ext2 2048s ${boot_size_si}M"
- set -e
- reread_partitions "$BOOTDRIVE"
- if [ -e "${BOOTDRIVE}1" -o "${BOOTDRIVE}p1" ]; then
- break
- fi
- done
- partboot="${BOOTDRIVE}1"
- if [ ! -e "$partboot" ]; then
- partboot="${BOOTDRIVE}p1"
- fi
- # sleep to ensure filesystems are created before continuing
- sleep 10
- mke2fs "${partboot}" -L Boot
- tune2fs -c 0 -i 0 "${partboot}"
- if [ "$OVIRT_ISCSI_HOSTVG" = "y" ]; then
- # XXX Can iscsi hostvg span multiple drives?
- # for drv in $HOSTVGDRIVE
- log "Partitioning root drive: $HOSTVGDRIVE"
- wipe_partitions "$HOSTVGDRIVE"
- reread_partitions "$HOSTVGDRIVE"
- log "Labeling Drive: $HOSTVGDRIVE"
- set +e
- until parted -s "$HOSTVGDRIVE" "mklabel ${LABEL_TYPE}"; do
- log "retrying iscsi-hostvg:mklabel"
- sleep 1
- done
- set -e
- create_hostvg
- fi
- log "Completed!"
- return
- fi
-
- if [ "$OVIRT_ROOT_INSTALL" = "y" ]; then
- log "Partitioning root drive: $ROOTDRIVE"
- wipe_partitions "$ROOTDRIVE"
- reread_partitions "$ROOTDRIVE"
- log "Creating Root and RootBackup Partitions"
- let RootBackup_end=${ROOT_SIZE}*2+${EFI_SIZE}
- let Root_end=${ROOT_SIZE}+${EFI_SIZE}
- while true; do
- set +e
- parted -s "$ROOTDRIVE" "mklabel ${LABEL_TYPE} mkpart primary fat32 2048s ${EFI_SIZE}M mkpart primary ext2 ${EFI_SIZE} ${Root_end}M mkpart primary ext2 ${Root_end}M ${RootBackup_end}M"
- set -e
- reread_partitions "$ROOTDRIVE"
- if [ -e "${ROOTDRIVE}3" -o -e "${ROOTDRIVE}p3" ]; then
- break
- fi
- done
- partefi="${ROOTDRIVE}1"
- partroot="${ROOTDRIVE}2"
- partrootbackup="${ROOTDRIVE}3"
- if [ ! -e "$partroot" ]; then
- partefi="${ROOTDRIVE}p1"
- partroot="${ROOTDRIVE}p2"
- partrootbackup="${ROOTDRIVE}p3"
- fi
- ln -snf "${partefi}" /dev/disk/by-label/EFI
- mkfs.vfat "${partefi}" -n EFI
- ln -snf "${partroot}" /dev/disk/by-label/Root
- mke2fs -t ext2 "${partroot}" -L Root
- tune2fs -c 0 -i 0 "${partroot}"
- ln -snf "${partrootbackup}" /dev/disk/by-label/RootBackup
- mke2fs -t ext2 "${partrootbackup}" -L RootBackup
- tune2fs -c 0 -i 0 "${partrootbackup}"
- fi
-
- oldIFS="$IFS"
- IFS="$SEP"
- for drv in $HOSTVGDRIVE; do
- if [ "$ROOTDRIVE" != "$drv" ]; then
- wipe_partitions "$drv"
- reread_partitions "$drv"
- log "Labeling Drive: $drv"
- set +e
- until parted -s "$drv" "mklabel ${LABEL_TYPE}"; do
- log "retrying hostvg:mklabel"
- sleep 1
- done
- set -e
- fi
- done
- IFS="$oldIFS"
-
- create_hostvg
- [ -n "${APPVGDRIVE}" ] && create_appvg
- if [ -n "${OVIRT_CRYPT_SWAP2}" -o -n "${OVIRT_CRYPT_SWAP}" ]; then
- ovirt_store_config /etc/ovirt-crypttab
- fi
- stop_log
-}
-
-do_confirm()
-{
-
- if [[ -z "$ROOTDRIVE" && "$OVIRT_ISCSI_ENABLED" != "y" ]]; then
- printf "\nNo Root storage device selected.\n"
- return
- fi
-
- if [[ -z "$HOSTVGDRIVE" ]]; then
- printf "\nNo HostVG storage device selected.\n"
- return
- fi
-
- while true; do
- sp=' '
- w='!!WARNING'
- wb="$w"'!!'
- w8="$w$w$w$w$w$w$w$w"
- printf '%s!!\n' \
- "$w8" \
- "$w8" \
- "$wb$sp$w" \
- "$wb$sp$w" \
- "$wb If you proceed, all data on your selected storage $w" \
- "$wb device will be destroyed and your hard disk $w" \
- "$wb will be irreversably reconfigured $w" \
- "$wb$sp$w" \
- "$wb$sp$w" \
- "$w8" \
- "$w8"
-
- if ask_yes_or_no "Do you wish to proceed ([Y]es/[N]o)?"; then
- if check_partition_sizes; then
- perform_partitioning
- exit 0
- fi
- else
- return
- fi
- # store networking config since it was created before storage was established for iscsi targets
- if [ "$OVIRT_ISCSI_NETWORKING" = "y" ]; then
- ovirt_store_config \
- /etc/sysconfig/network-scripts/ifcfg* \
- /etc/ntp.conf
- fi
- done
-}
-
-do_iscsi_target()
-{
-if ! network_up ; then
- printf "Networking must be configured prior to configuring an iscsi target.\n\n"
- # allow network config without setting up storage first
- augtool <<EOF
-set /files/etc/default/ovirt/OVIRT_ISCSI_NETWORK_CONFIG y
-EOF
- exit 99
-fi
-
-while true; do
- OPTIONS="\"Target IP\" \"Target Port\"" #\"CHAP Username\" \"CHAP Password\""
- printf "\nPress Enter to leave option blank or Q to quit (default Target Port is 3260)\n"
- eval set $OPTIONS
- PS3="Choose an option: "
- for OPTION in "$@"; do
- while true; do
- read -ep "Enter $OPTION: "
- if [ "$REPLY" = "q" -o "$REPLY" = "Q" ]; then
- return
- fi
-
- if [ "$OPTION" = "Target IP" ]; then
- if is_valid_ipv4 $REPLY; then
- OVIRT_ISCSI_TARGET_IP="$REPLY"
- break;
- else
- printf "\nThe address $REPLY is not a valid IPv4 address.\n"
- fi
-
- elif [ "$OPTION" = "Target Port" ]; then
- OVIRT_ISCSI_TARGET_PORT="$REPLY"
- if [ -z "$REPLY" ]; then
- OVIRT_ISCSI_TARGET_PORT="3260"
- break;
- else
- break;
- fi
-
- elif [ "$OPTION" = "CHAP Username" ]; then
- OVIRT_ISCSI_CHAP_USERNAME="$REPLY"
- break
-
- elif [ "$OPTION" = "CHAP Password" ]; then
- OVIRT_ISCSI_CHAP_PASSWORD="$REPLY"
- break;
- fi
- done
- done
-
- cat <<EOF
-
-The iSCSI target be configured as follows:
-================================================
- Target IP: $OVIRT_ISCSI_TARGET_IP
- Target Port: $OVIRT_ISCSI_TARGET_PORT
-
-EOF
-# Username: $OVIRT_ISCSI_CHAP_USERNAME
-# Password: $OVIRT_ISCSI_CHAP_PASSWORD
-#EOF
-
-if ask_yes_or_no "Is this correct ([Y]es/[N]o)?" true true; then
-
- OVIRT_ISCSI_ENABLED="y"
- augtool <<EOF
-set /files/etc/default/ovirt/OVIRT_ISCSI_ENABLED y
-set /files/etc/default/ovirt/OVIRT_ISCSI_TARGET_IP $OVIRT_ISCSI_TARGET_IP
-set /files/etc/default/ovirt/OVIRT_ISCSI_TARGET_PORT $OVIRT_ISCSI_TARGET_PORT
-EOF
-
- if [[ -n "$OVIRT_ISCSI_CHAP_USERNAME" && -n "$OVIRT_ISCSI_CHAP_PASSWORD" ]]; then
- log "setting iscsid.conf username/password"
- augtool <<EOF
-set /files/etc/iscsi/iscsid.conf/node.session.auth.authmethod CHAP
-set /files/etc/iscsi/iscsid.conf/node.session.auth.username $OVIRT_ISCSI_CHAP_USERNAME
-set /files/etc/iscsi/iscsid.conf/node.session.auth.password $OVIRT_ISCSI_CHAP_PASSWORD
-set /files/etc/default/ovirt/OVIRT_ISCSI_CHAP_USERNAME $OVIRT_ISCSI_CHAP_USERNAME
-set /files/etc/default/ovirt/OVIRT_ISCSI_CHAP_PASSWORD $OVIRT_ISCSI_CHAP_PASSWORD
-EOF
- fi
-
- iscsiadm -p "$OVIRT_ISCSI_TARGET_IP:$OVIRT_ISCSI_TARGET_PORT" -m discovery -t sendtargets
- log "Restarting iscsi service"
- service iscsi restart
-
-ISCSI_NODE_NAMES="$(iscsiadm -m discovery -p $OVIRT_ISCSI_TARGET_IP:$OVIRT_ISCSI_TARGET_PORT -t sendtargets|awk {'print $2'})"
-
-printf "\n\n Select iSCSI target node\n\n" >&2
-select OVIRT_ISCSI_NODE_NAME in $ISCSI_NODE_NAMES ; do
-log " Selected Node Name: $OVIRT_ISCSI_NODE_NAME"
-break;
-done
-
-augtool <<EOF
-set /files/etc/default/ovirt/OVIRT_ISCSI_ENABLED y
-set /files/etc/default/ovirt/OVIRT_ISCSI_TARGET_IP $OVIRT_ISCSI_TARGET_IP
-set /files/etc/default/ovirt/OVIRT_ISCSI_TARGET_PORT $OVIRT_ISCSI_TARGET_PORT
-set /files/etc/default/ovirt/OVIRT_ISCSI_NODE_NAME $OVIRT_ISCSI_NODE_NAME
-EOF
-break;
-fi
-done
-
-if mount_iscsi_liveos; then
- if ! [ -d /liveos/lib/modules/$(uname -r) ]; then
- printf "Running kernel version does not match version installed to iscsi root file system, aborting\n\n"
- exit 99
- fi
-fi
-}
-
-cross_check_host_app()
-{
-oldIFS="$IFS"
-IFS="$SEP"
-for hdrv in $HOSTVGDRIVE; do
- for adrv in $APPVGDRIVE; do
- if [ "${hdrv}" = "${adrv}" ]; then
- # Skip disk partitioning, AppVG overlaps with HostVG
- IFS="$oldIFS"
- return 1
- fi
- done
-done
-IFS="$oldIFS"
-return 0
-}
-
-MEM_SIZE_MB=$(awk '/MemTotal:/ { print $2 }' /proc/meminfo)
-case $MEM_SIZE_MB in
- ''|*[^0-9]*) die failed to get system memory size;;
-esac
-MEM_SIZE_MB=$(echo "scale=0; $MEM_SIZE_MB / 1024;" | bc -l)
-
-overcommit=${OVIRT_OVERCOMMIT:-$default_overcommit}
-# we multiply the overcommit coefficient by 10 then divide the
-# product by 10 to avoid decimals in the result
-OVERCOMMIT_SWAP_SIZE=$(echo "scale=0; (${MEM_SIZE_MB} * (${overcommit} * 10))/10;" | bc -l)
-
-# add to the swap the amounts from http://kbase.redhat.com/faq/docs/DOC-15252
-MEM_SIZE_GB=$(echo "scale=0; $MEM_SIZE_MB/1024;" | bc -l)
-if [ $MEM_SIZE_GB -le 4 ]; then
- BASE_SWAP_SIZE=2048
-elif [ $MEM_SIZE_GB -le 16 ]; then
- BASE_SWAP_SIZE=4096
-elif [ $MEM_SIZE_GB -le 64 ]; then
- BASE_SWAP_SIZE=8192
-else
- BASE_SWAP_SIZE=16384
-fi
-
-CALC_SWAP_SIZE=$(echo "scale=0; ${BASE_SWAP_SIZE} + ${OVERCOMMIT_SWAP_SIZE};" | bc -l)
-
-BOOT_SIZE=$default_boot_size
-SWAP_SIZE=${OVIRT_VOL_SWAP_SIZE:-$CALC_SWAP_SIZE}
-ROOT_SIZE=$default_root_size
-CONFIG_SIZE=${OVIRT_VOL_CONFIG_SIZE:-$default_config_size}
-LOGGING_SIZE=${OVIRT_VOL_LOGGING_SIZE:-$default_logging_size}
-DATA_SIZE=${OVIRT_VOL_DATA_SIZE:-$default_data_size}
-SWAP2_SIZE=${OVIRT_VOL_SWAP2_SIZE:-$default_swap2_size}
-DATA2_SIZE=${OVIRT_VOL_DATA2_SIZE:-$default_data2_size}
-EFI_SIZE=${default_efi_size}
-
-if [ -n "$OVIRT_INIT" ]; then
- # if present, use drive(s) selected with 'ovirt_init' boot parameter
- ROOTDRIVE=
- HOSTVGDRIVE=
- oldIFS="$IFS"
- IFS="$SEP"
- for drv in $OVIRT_INIT; do
- DRIVE="$(translate_multipath_device "$drv")"
- if [ -z "$ROOTDRIVE" ]; then
- # XXX assumes first is ROOTDRIVE
- ROOTDRIVE="$DRIVE"
- fi
- if [ -n "$HOSTVGDRIVE" ]; then
- HOSTVGDRIVE="$HOSTVGDRIVE${SEP}$DRIVE"
- else
- HOSTVGDRIVE="$DRIVE"
- fi
- done
- IFS="$oldIFS"
-
- OVIRT_ROOT_INSTALL="y"
- get_drive_size "$ROOTDRIVE" ROOTDRIVESPACE
-fi
-
-if [ -n "$OVIRT_INIT_APP" ]; then
- if [ ${SWAP2_SIZE} -ne 0 -o ${DATA2_SIZE} -ne 0 ]; then
- APPVGDRIVE=
- oldIFS="$IFS"
- IFS="$SEP"
- for drv in $OVIRT_INIT_APP; do
- DRIVE="$(translate_multipath_device "$drv")"
- if [ -n "$APPVGDRIVE" ]; then
- APPVGDRIVE="$APPVGDRIVE${SEP}$DRIVE"
- else
- APPVGDRIVE="$DRIVE"
- fi
- done
- IFS="$oldIFS"
- cross_check_host_app || {
- log "Skip disk partitioning, AppVG overlaps with HostVG"
- exit 1
- }
- fi
-else
- { [ ${SWAP2_SIZE} -ne 0 ] || [ $DATA2_SIZE -ne 0 ]; } && {
- log "Missing device parameter for AppVG: unable to partition any disk"
- exit 2
- }
-fi
-
-# if the node is Fedora then use GPT, otherwise use MBR
-if [ -f /etc/fedora-release ]; then
- LABEL_TYPE="gpt"
-else
- LABEL_TYPE="msdos"
-fi
-
-if [ "$1" = "AUTO" ]; then
- log "Beginning automatic disk partitioning."
- if [ -n "$OVIRT_INIT" ]; then
- # Logic for automatic partitioning
- # If HostVG/AppVG exists on a disk other than $DRIVE, fail
- # If HostVG/AppVG exists on $DRIVE, then partition only if
- # firstboot is specified
- # Else, partition
- if check_existing_hostvg >/dev/null 2>&1 \
- || check_existing_hostvg "" "" AppVG ; then
- if check_existing_hostvg "$HOSTVGDRIVE"; then
- log "HostVG exists on a separate disk"
- log "Manual Intervention required"
- exit 1
- elif [ -n "$APPVGDRIVE" ] \
- && check_existing_hostvg "$APPVGDRIVE"; then
- log "AppVG exists on a separate disk"
- log "Manual Intervention required"
- exit 1
- else
- if is_firstboot; then
- if check_partition_sizes; then
- log "Partitioning hard disk..."
- perform_partitioning
- exit $?
- else
- log "storage_vol parameter can be used to reduce the size of partitions"
- log "e.g. storage_vol=:SWAP_SIZE_IN_MB"
- log "WARNING: you might have issues because you don't have enough swap"
- log "to meet suggested minimum swap size."
- exit 1
- fi
- else
- echo "Disk is already partitioned and firstboot not specified, Skipping partitioning"
- exit 0
- fi
- fi
- else
- if check_partition_sizes; then
- log "Partitioning hard disk..."
- perform_partitioning
- exit $?
- else
- log "storage_vol parameter can be used to reduce the size of partitions"
- log "e.g. storage_vol=:SWAP_SIZE_IN_MB"
- log "WARNING: you might have issues because you don't have enough swap"
- log "to meet suggested minimum swap size."
- fi
- fi
- else
- log "Missing device parameter: unable to partition any disk"
- exit 2
- fi
-else
- OPTIONS="\"Enable iSCSI Target\" \"Configure Storage\" \"Review\" \"Commit Changes And Quit\" \"Return To Menu\""
- eval set $OPTIONS
- PS3="Choose an option: "
-
- while true; do
- printf "\n\n Storage Configuration\n\n" >&2
-
- select OPTION in "$@"
- do
- case "$OPTION" in
- "Enable iSCSI Target") do_iscsi_target; break ;;
- "Configure Storage") do_configure ; break ;;
- "Review") do_review ; break ;;
- "Commit Changes And Quit") do_confirm ; break ;;
- "Return To Menu") printf "\nExiting.\n"; exit ;;
- esac
- done
- done
-fi
diff --git a/src/ovirt/node/installer/__main__.py b/src/ovirt/node/installer/__main__.py
index 49e6d94..b3a95be 100644
--- a/src/ovirt/node/installer/__main__.py
+++ b/src/ovirt/node/installer/__main__.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
-# ovirt-config-installer.py - Copyright (C) 2012 Red Hat, Inc.
+# ovirt-node-installer.py - Copyright (C) 2012 Red Hat, Inc.
# Written by Fabian Deutsch <fabiand at redhat.com>
#
# This program is free software; you can redistribute it and/or modify
--
To view, visit http://gerrit.ovirt.org/15244
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1b959b85f44b1932f1d7fc7ce14484e14722253f
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Fabian Deutsch <fabiand at fedoraproject.org>
More information about the node-patches
mailing list