author | Niall Power <niall.power@oracle.com> |
Thu, 28 Jul 2011 12:41:10 +0800 | |
changeset 1338 | 092bf136b771 |
parent 1287 | 8a3a06be1d48 |
child 1340 | b7e21281214f |
permissions | -rw-r--r-- |
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1 |
#!/usr/bin/python |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
2 |
# |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
3 |
# CDDL HEADER START |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
4 |
# |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
5 |
# The contents of this file are subject to the terms of the |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
6 |
# Common Development and Distribution License (the "License"). |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
7 |
# You may not use this file except in compliance with the License. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
8 |
# |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
9 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
10 |
# or http://www.opensolaris.org/os/licensing. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
11 |
# See the License for the specific language governing permissions |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
12 |
# and limitations under the License. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
13 |
# |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
14 |
# When distributing Covered Code, include this CDDL HEADER in each |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
15 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
16 |
# If applicable, add the following below this CDDL HEADER, with the |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
17 |
# fields enclosed by brackets "[]" replaced with your own identifying |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
18 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
19 |
# |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
20 |
# CDDL HEADER END |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
21 |
# |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
22 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
23 |
# |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
24 |
# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
25 |
# |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
26 |
""" boot.py -- Installs and configures boot loader and boot menu |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
27 |
onto physical systems and installation images. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
28 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
29 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
30 |
import abc |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
31 |
import array |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
32 |
import fcntl |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
33 |
import linecache |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
34 |
import os |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
35 |
import platform |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
36 |
import stat |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
37 |
import struct |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
38 |
import tempfile |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
39 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
40 |
from grp import getgrnam |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
41 |
from pwd import getpwnam |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
42 |
from shutil import move, copyfile, rmtree |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
43 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
44 |
from bootmgmt import bootconfig, BootmgmtUnsupportedPropertyError |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
45 |
from bootmgmt.bootconfig import BootConfig, DiskBootConfig, ODDBootConfig, \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
46 |
SolarisDiskBootInstance, SolarisODDBootInstance, ChainDiskBootInstance |
1212
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
47 |
from bootmgmt.bootloader import BootLoader |
1338
092bf136b771
7063508 Solaris 11 installers wipes out existing boot-device entries in eeprom
Niall Power <niall.power@oracle.com>
parents:
1287
diff
changeset
|
48 |
from solaris_install import DC_LABEL, DC_PERS_LABEL, \ |
092bf136b771
7063508 Solaris 11 installers wipes out existing boot-device entries in eeprom
Niall Power <niall.power@oracle.com>
parents:
1287
diff
changeset
|
49 |
CalledProcessError, Popen, run |
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
50 |
from solaris_install.boot.boot_spec import BootMods, BootEntry |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
51 |
from solaris_install.data_object import ObjectNotFoundError |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
52 |
from solaris_install.data_object.data_dict import DataObjectDict |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
53 |
from solaris_install.engine import InstallEngine |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
54 |
from solaris_install.engine.checkpoint import AbstractCheckpoint as Checkpoint |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
55 |
from solaris_install.logger import INSTALL_LOGGER_NAME as ILN |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
56 |
from solaris_install.target import Target |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
57 |
from solaris_install.target.logical import be_list, BE, Zpool |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
58 |
from solaris_install.target.physical import Disk, Slice |
1255
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
59 |
from solaris_install.transfer.media_transfer import get_image_grub_title |
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
60 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
61 |
BOOT_ENV = "boot-env" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
62 |
# Character boot device paths eg. c0t0d0s0 |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
63 |
DEVS = "devs" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
64 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
65 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
66 |
class BootMenu(Checkpoint): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
67 |
""" Abstract class for BootMenu checkpoint |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
68 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
69 |
__metaclass__ = abc.ABCMeta |
1256
e8a8a4e2bb96
7044356 x86 boot menu timeout regression after pybootmgt putback
Niall Power <niall.power@oracle.com>
parents:
1255
diff
changeset
|
70 |
DEFAULT_TIMEOUT = 30 |
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
71 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
72 |
def __init__(self, name): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
73 |
""" Constructor for class |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
74 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
75 |
super(BootMenu, self).__init__(name) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
76 |
self.arch = platform.processor() |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
77 |
self.boot_entry_list = list() |
1256
e8a8a4e2bb96
7044356 x86 boot menu timeout regression after pybootmgt putback
Niall Power <niall.power@oracle.com>
parents:
1255
diff
changeset
|
78 |
self.boot_timeout = BootMenu.DEFAULT_TIMEOUT |
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
79 |
self.boot_mods = None |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
80 |
self.boot_title = None |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
81 |
# Used for string token substitution of pybootgmmt return data |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
82 |
self.boot_tokens = dict() |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
83 |
self.config = None |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
84 |
self.doc = InstallEngine.get_instance().data_object_cache |
1255
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
85 |
self.img_info_path = None |
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
86 |
self.rel_file_title = None |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
87 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
88 |
def get_progress_estimate(self): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
89 |
""" Returns an estimate of the time this checkpoint will |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
90 |
take to complete. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
91 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
92 |
return 5 |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
93 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
94 |
@abc.abstractmethod |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
95 |
def build_default_entries(self): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
96 |
""" This method is required to be implemented by all subclasses. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
97 |
Standard, pre-defined boot menu entries get created by |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
98 |
subclass implementors of this method. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
99 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
100 |
raise NotImplementedError |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
101 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
102 |
@abc.abstractmethod |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
103 |
def build_custom_entries(self): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
104 |
""" This method is required to be implemented by all subclasses. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
105 |
Custom entries specified in the boot_mods section of the |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
106 |
XML manifest get created by subclass implementors of this method. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
107 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
108 |
raise NotImplementedError |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
109 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
110 |
@abc.abstractmethod |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
111 |
def _get_rel_file_path(self): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
112 |
""" This method is required to be implemented by all subclasses. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
113 |
Returns file system path to the release file. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
114 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
115 |
raise NotImplementedError |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
116 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
117 |
def parse_doc(self, dry_run=False): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
118 |
""" Parse data object cache for values required by the checkpoint |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
119 |
execution. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
120 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
121 |
# Break doc parsing down into 2 specific parts as the target |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
122 |
# configuration in the doc differs between DC (for ISO images) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
123 |
# and and live system installation. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
124 |
self._parse_doc_target(dry_run) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
125 |
self._parse_doc_boot_mods() |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
126 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
127 |
def _parse_doc_boot_mods(self): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
128 |
""" Parses data object cache (DOC) BootMods tree for configuration of |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
129 |
the checkpoint. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
130 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
131 |
try: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
132 |
# Check and retrieve the optional manifest |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
133 |
# specific boot configurations. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
134 |
boot_mods = self.doc.get_descendants(class_type=BootMods) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
135 |
if len(boot_mods) < 1: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
136 |
return |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
137 |
self.boot_mods = boot_mods[0] |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
138 |
except ObjectNotFoundError as err: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
139 |
raise RuntimeError("Error retrieving BootMods from the DOC: " + \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
140 |
str(err)) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
141 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
142 |
if self.boot_mods.title and len(self.boot_mods.title) > 0: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
143 |
self.logger.info("Setting boot title prefix from manifest value: \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
144 |
'%s'" % self.boot_mods.title) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
145 |
self.boot_title = self.boot_mods.title |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
146 |
|
1256
e8a8a4e2bb96
7044356 x86 boot menu timeout regression after pybootmgt putback
Niall Power <niall.power@oracle.com>
parents:
1255
diff
changeset
|
147 |
if self.boot_mods.timeout is not None: |
e8a8a4e2bb96
7044356 x86 boot menu timeout regression after pybootmgt putback
Niall Power <niall.power@oracle.com>
parents:
1255
diff
changeset
|
148 |
self.logger.info("Setting boot timeout from manifest value: %d" \ |
e8a8a4e2bb96
7044356 x86 boot menu timeout regression after pybootmgt putback
Niall Power <niall.power@oracle.com>
parents:
1255
diff
changeset
|
149 |
% self.boot_mods.timeout) |
e8a8a4e2bb96
7044356 x86 boot menu timeout regression after pybootmgt putback
Niall Power <niall.power@oracle.com>
parents:
1255
diff
changeset
|
150 |
self.boot_timeout = self.boot_mods.timeout |
e8a8a4e2bb96
7044356 x86 boot menu timeout regression after pybootmgt putback
Niall Power <niall.power@oracle.com>
parents:
1255
diff
changeset
|
151 |
|
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
152 |
try: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
153 |
self.boot_entry_list = self.boot_mods.get_children( |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
154 |
class_type=BootEntry) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
155 |
except ObjectNotFoundError: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
156 |
# the manifest does not contain any custom boot entries |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
157 |
self.logger.debug("No custom boot entries found in the DOC") |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
158 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
159 |
@abc.abstractmethod |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
160 |
def _parse_doc_target(self, dry_run=False): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
161 |
""" This method is required to be implemented by all subclasses. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
162 |
Additional class specific parsing to determine the boot |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
163 |
configuration's target paths or devices get performed by |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
164 |
subclass implementors this method. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
165 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
166 |
Input: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
167 |
None |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
168 |
Output: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
169 |
None |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
170 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
171 |
raise NotImplementedError |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
172 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
173 |
@abc.abstractmethod |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
174 |
def init_boot_config(self, autogen=True): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
175 |
""" This method is required to be implemented by all subclasses. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
176 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
177 |
Input: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
178 |
None |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
179 |
Output: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
180 |
None |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
181 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
182 |
raise NotImplementedError |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
183 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
184 |
@abc.abstractmethod |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
185 |
def install_boot_loader(self, dry_run=False): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
186 |
""" This method is required to be implemented by all subclasses. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
187 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
188 |
Input: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
189 |
dry_run |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
190 |
- If True, the set of files that constitute the boot |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
191 |
configuration is written to a temporary directory (and not to |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
192 |
the official location(s)) When files are written to a |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
193 |
temporary directory, the list and format of the files written |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
194 |
is returned (see Output) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
195 |
Output: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
196 |
None |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
197 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
198 |
raise NotImplementedError |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
199 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
200 |
def _handle_boot_config_list(self, boot_config_list, dry_run): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
201 |
""" Method that checks returned tuple list from commit_boot_config() |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
202 |
and copies over content as appropriate to their targets. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
203 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
204 |
for boot_config in boot_config_list: |
1212
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
205 |
# boot-config elements can be either tuples or lists of tuples. |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
206 |
# Cast tuples into a list for consistent iteration loop below. |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
207 |
if not isinstance(boot_config, list): |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
208 |
boot_config = [boot_config] |
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
209 |
for config_set in boot_config: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
210 |
ftype = config_set[0] |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
211 |
if ftype == BootConfig.OUTPUT_TYPE_FILE: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
212 |
self._handle_file_type(config_set, dry_run) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
213 |
elif ftype in [BootConfig.OUTPUT_TYPE_BIOS_ELTORITO]: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
214 |
# UEFI - add handlers for the following when supported: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
215 |
# BootConfig.OUTPUT_TYPE_UEFI_ELTORITO |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
216 |
# BootConfig.OUTPUT_TYPE_HSFS_BOOTBLK |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
217 |
self._handle_iso_boot_image_type(config_set, dry_run) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
218 |
else: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
219 |
raise RuntimeError("Unrecognized boot loader " \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
220 |
"file type: %s" % ftype) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
221 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
222 |
def _handle_file_type(self, config, dry_run): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
223 |
""" Method that copies generic file types to their appropriate targets. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
224 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
225 |
ftype, src, objref, dest, uid, gid, mode = config |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
226 |
# Copy from 'src' to 'dest' and set uid:gid + mode |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
227 |
if src is None: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
228 |
raise RuntimeError("No source path defined for boot" \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
229 |
"file") |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
230 |
if dest is None: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
231 |
raise RuntimeError("No destination path defined for boot" \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
232 |
"file") |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
233 |
# XXX The 'dest' field, I believe, should be prepended with the |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
234 |
# string token '%(systemroot)s' but it currently appears not to |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
235 |
# be the case sometimes, and instead specifies an absolute path |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
236 |
# such as '/boot/grub/menu.lst' |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
237 |
# Check for a leading slash and prepend if necessary |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
238 |
if os.path.isabs(dest): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
239 |
dest = '%(' + BootConfig.TOKEN_SYSTEMROOT + ')s' + dest |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
240 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
241 |
real_dest = dest % (self.boot_tokens) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
242 |
par_dir = os.path.abspath(os.path.join(real_dest, os.path.pardir)) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
243 |
if dry_run is True: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
244 |
os.unlink(src) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
245 |
return |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
246 |
try: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
247 |
if not os.path.exists(par_dir): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
248 |
self.logger.debug("Creating boot configuration folder: %s" \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
249 |
% par_dir) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
250 |
os.makedirs(par_dir) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
251 |
self.logger.debug("Moving boot configuration file: \n" \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
252 |
"%s -> %s" % (src, real_dest)) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
253 |
move(src, real_dest) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
254 |
if uid is None: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
255 |
uid = -1 |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
256 |
if gid is None: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
257 |
gid = -1 |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
258 |
self.logger.debug("Setting ownership of %s to: %s:%s" \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
259 |
% (real_dest, uid, gid)) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
260 |
os.chown(real_dest, |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
261 |
getpwnam(uid).pw_uid, |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
262 |
getgrnam(gid).gr_gid) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
263 |
if mode: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
264 |
self.logger.debug("Setting permissions of %s to: %d" \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
265 |
% (real_dest, mode)) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
266 |
os.chmod(real_dest, mode) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
267 |
except OSError as err: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
268 |
raise RuntimeError("Error copying boot configuration files to " \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
269 |
"target: %s" % str(err)) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
270 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
271 |
def execute(self, dry_run=False): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
272 |
""" Primary execution method used by the Checkpoint parent class |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
273 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
274 |
self.parse_doc(dry_run) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
275 |
self.init_boot_config() |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
276 |
self.build_default_entries() |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
277 |
self.build_custom_entries() |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
278 |
self.install_boot_loader(dry_run) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
279 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
280 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
281 |
class SystemBootMenu(BootMenu): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
282 |
""" Class for SystemBootMenu checkpoint. Suitable for automatic boot loader |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
283 |
and boot menu configuration for install applications that install onto |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
284 |
a physical system device such as gui-install, text install and AI |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
285 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
286 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
287 |
def __init__(self, name): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
288 |
""" Constructor for class |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
289 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
290 |
super(SystemBootMenu, self).__init__(name) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
291 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
292 |
# Dictionary for quick lookup of paramaters needed to configure and |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
293 |
# install the boot loader. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
294 |
self.boot_target = dict() |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
295 |
self.boot_target[BOOT_ENV] = None |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
296 |
self.boot_target[DEVS] = list() |
1255
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
297 |
self.img_info_title = None |
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
298 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
299 |
# Filesystem name of the target boot environment eg. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
300 |
# rpool/ROOT/solaris-11-XYZ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
301 |
self.target_bootfs = None |
1212
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
302 |
# Convenience reference to the SolarisDiskBootInstance for boot target |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
303 |
self.target_boot_instance = None |
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
304 |
# Mountpoint of pool toplevel dataset |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
305 |
self.pool_tld_mount = None |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
306 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
307 |
def init_boot_config(self, autogen=True): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
308 |
""" Instantiates the appropriate bootmgmt.bootConfig subclass object |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
309 |
for this class |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
310 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
311 |
bc_flags = [bootconfig.BootConfig.BCF_CREATE] |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
312 |
if autogen: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
313 |
bc_flags.append(bootconfig.BootConfig.BCF_AUTOGEN) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
314 |
bc_flags = tuple(bc_flags) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
315 |
target_be = self.boot_target[BOOT_ENV] |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
316 |
# If the BE is unmounted for some reason we need to go and mount it. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
317 |
if target_be.mountpoint == None: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
318 |
tmp_be_mp = tempfile.mkdtemp(dir="/system/volatile", |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
319 |
prefix="be_mount_%s_" \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
320 |
% (target_be.name)) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
321 |
self.logger.debug("Mounting BE %s at: %s" % \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
322 |
(target_be.name, tmp_be_mp)) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
323 |
target_be.mount(tmp_be_mp, dry_run=False) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
324 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
325 |
# Note that 'platform' tuple is not supplied here since we want to |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
326 |
# go with the running system arch/firmware, which bootmgmt defaults to. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
327 |
self.config = DiskBootConfig(bc_flags, |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
328 |
rpname=target_be.parent.name, |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
329 |
tldpath=self.pool_tld_mount, |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
330 |
zfspath=target_be.mountpoint) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
331 |
|
1256
e8a8a4e2bb96
7044356 x86 boot menu timeout regression after pybootmgt putback
Niall Power <niall.power@oracle.com>
parents:
1255
diff
changeset
|
332 |
# Apply boot timeout property to boot loader. |
e8a8a4e2bb96
7044356 x86 boot menu timeout regression after pybootmgt putback
Niall Power <niall.power@oracle.com>
parents:
1255
diff
changeset
|
333 |
try: |
e8a8a4e2bb96
7044356 x86 boot menu timeout regression after pybootmgt putback
Niall Power <niall.power@oracle.com>
parents:
1255
diff
changeset
|
334 |
self.config.boot_loader.setprop('timeout', |
e8a8a4e2bb96
7044356 x86 boot menu timeout regression after pybootmgt putback
Niall Power <niall.power@oracle.com>
parents:
1255
diff
changeset
|
335 |
self.boot_timeout) |
e8a8a4e2bb96
7044356 x86 boot menu timeout regression after pybootmgt putback
Niall Power <niall.power@oracle.com>
parents:
1255
diff
changeset
|
336 |
except BootmgmtUnsupportedPropertyError: |
e8a8a4e2bb96
7044356 x86 boot menu timeout regression after pybootmgt putback
Niall Power <niall.power@oracle.com>
parents:
1255
diff
changeset
|
337 |
self.logger.warning("Boot loader type %s does not support the \ |
e8a8a4e2bb96
7044356 x86 boot menu timeout regression after pybootmgt putback
Niall Power <niall.power@oracle.com>
parents:
1255
diff
changeset
|
338 |
'timeout' property. Ignoring." \ |
e8a8a4e2bb96
7044356 x86 boot menu timeout regression after pybootmgt putback
Niall Power <niall.power@oracle.com>
parents:
1255
diff
changeset
|
339 |
% self.config.boot_loader.name) |
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
340 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
341 |
def execute(self, dry_run=False): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
342 |
""" Primary execution method used by the Checkpoint parent class |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
343 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
344 |
# UEFI The divergent code paths for sparc and X86 is a temporary |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
345 |
# workaround for the lack of sparc support in the bootmgmt module. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
346 |
# When this is addressed, I expect to revert to just calling the |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
347 |
# parent class method. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
348 |
if self.arch == 'sparc': |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
349 |
# For sparc, generate a manual menu.lst and copy the bootlst |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
350 |
# binary into the boot dataset. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
351 |
self.parse_doc(dry_run) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
352 |
# Check to make sure that a non-dry run attempt is not |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
353 |
# executed on a live system |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
354 |
if self.boot_target[BOOT_ENV].mountpoint == '/' and \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
355 |
not dry_run: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
356 |
raise RuntimeError("Boot checkpoint can not be executed on" \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
357 |
"live systems except with dry run mode") |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
358 |
self._set_bootfs_pool_prop(dry_run) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
359 |
self._install_sparc_bootblk(dry_run) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
360 |
self._set_sparc_prom_boot_device(dry_run) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
361 |
self._create_sparc_boot_menu(dry_run) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
362 |
self._copy_sparc_bootlst(dry_run) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
363 |
else: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
364 |
super(SystemBootMenu, self).execute(dry_run) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
365 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
366 |
def _set_bootfs_pool_prop(self, dry_run): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
367 |
""" Set the bootfs property on the boot pool, activating the BE. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
368 |
XXX: This should really be ultimately handled by pybootmgmt |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
369 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
370 |
pool = self.boot_target[BOOT_ENV].parent |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
371 |
self.logger.debug("Setting bootfs zpool property on %s to %s" \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
372 |
% (pool.name, self.target_bootfs)) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
373 |
pool.set("bootfs", self.target_bootfs, dry_run) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
374 |
|
1212
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
375 |
def _get_x86_console(self): |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
376 |
""" |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
377 |
Determine X86 console device. Adapted from libict_pymod |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
378 |
Returns console device found in bootenv.rc, from devprop command, |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
379 |
or default 'text'. |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
380 |
""" |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
381 |
osconsole = None |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
382 |
bootvars = self.target_boot_instance.boot_vars |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
383 |
osconsole = bootvars.getprop('output-device') |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
384 |
if osconsole is not None: |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
385 |
return osconsole |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
386 |
|
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
387 |
# get console setting from devprop via. 'console' |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
388 |
osconsole = self._get_dev_property(propname='console') |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
389 |
|
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
390 |
if osconsole is None: |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
391 |
# get console setting from devprop via. 'output-device' |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
392 |
osconsole = self._get_dev_property( |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
393 |
propname='output-device') |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
394 |
if osconsole == 'screen': |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
395 |
osconsole = 'text' |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
396 |
# Set default console value to text |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
397 |
if osconsole is None or osconsole == '': |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
398 |
osconsole = 'text' |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
399 |
return osconsole |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
400 |
|
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
401 |
def _get_dev_property(self, propname): |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
402 |
""" |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
403 |
Internal helper method. |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
404 |
Retrieves the value of propname reported by devprop(1M) |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
405 |
|
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
406 |
Returns: A string value associated with propname or None |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
407 |
""" |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
408 |
propname_val = None |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
409 |
cmd = ["/usr/sbin/devprop", "-s", propname] |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
410 |
p = Popen.check_call(cmd, |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
411 |
stdout=Popen.STORE, |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
412 |
stderr=Popen.STORE, |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
413 |
logger=ILN) |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
414 |
if p.returncode != 0: |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
415 |
raise RuntimeError('Error getting device property: %s' \ |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
416 |
'Exit status=%s' % (cmd, p.stderr)) |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
417 |
|
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
418 |
result = p.stdout.strip() |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
419 |
if len(result) > 0: |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
420 |
propname_val = result |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
421 |
self.logger.debug("Found device property value for " \ |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
422 |
"%s: '%s'" % (propname, propname_val)) |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
423 |
else: |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
424 |
self.logger.debug("No device property value found for %s" \ |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
425 |
% propname) |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
426 |
return propname_val |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
427 |
|
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
428 |
def _create_sparc_boot_menu(self, dry_run): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
429 |
""" Create a boot menu.lst file on a SPARC system. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
430 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
431 |
# Attempt to create the path to where the menu.lst file will reside |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
432 |
boot_menu_path = os.path.join(self.pool_tld_mount, 'boot') |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
433 |
if dry_run: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
434 |
# Override boot_menu_path to temporary storage |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
435 |
temp_dir = tempfile.mkdtemp(dir="/tmp", prefix="sparc_boot_menu_") |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
436 |
boot_menu_path = os.path.join(temp_dir, |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
437 |
boot_menu_path.strip(os.path.sep)) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
438 |
boot_menu = os.path.join(boot_menu_path, 'menu.lst') |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
439 |
sparc_title_line = 'title %s\n' % self.boot_title |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
440 |
bootfs_line = 'bootfs ' + self.target_bootfs + '\n' |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
441 |
self.logger.debug("Creating SPARC boot menu file: %s" \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
442 |
% boot_menu) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
443 |
if not os.path.isdir(boot_menu_path): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
444 |
os.makedirs(boot_menu_path, 0755) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
445 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
446 |
try: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
447 |
with open(boot_menu, 'w') as menu_lst: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
448 |
menu_lst.write(sparc_title_line) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
449 |
menu_lst.write(bootfs_line) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
450 |
os.chmod(boot_menu, |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
451 |
stat.S_IREAD | stat.S_IWRITE | \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
452 |
stat.S_IRGRP | stat.S_IROTH) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
453 |
# Requires root privilige so bypass on dry_run |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
454 |
if not dry_run: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
455 |
os.chown(boot_menu, 0, 3) # chown root:sys |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
456 |
except IOError, msg: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
457 |
raise RuntimeError(msg) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
458 |
if dry_run: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
459 |
rmtree(temp_dir) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
460 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
461 |
def _copy_sparc_bootlst(self, dry_run): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
462 |
""" Copy the bootlst file on a SPARC system. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
463 |
On SPARC systems a bootlst file is maintained at: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
464 |
/platform/`uname -m`/bootlst |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
465 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
466 |
It needs to be copied to: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
467 |
<rootpool>/platform/`uname -m`/bootlst |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
468 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
469 |
bootlst_src = os.path.join(self.boot_target[BOOT_ENV].mountpoint, |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
470 |
'platform', platform.machine(), |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
471 |
'bootlst') |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
472 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
473 |
# Copy file bootlst from basedir to the rootpool |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
474 |
bootlst_dir = os.path.join(self.pool_tld_mount, |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
475 |
'platform', platform.machine()) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
476 |
if dry_run: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
477 |
# Override bootlst_dir to temporary storage |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
478 |
temp_dir = tempfile.mkdtemp(dir="/tmp", prefix="sparc_bootlst_") |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
479 |
bootlst_dir = os.path.join(temp_dir, |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
480 |
bootlst_dir.strip(os.path.sep)) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
481 |
bootlst_dst = os.path.join(bootlst_dir, 'bootlst') |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
482 |
self.logger.debug("Copying SPARC bootlst file: %s" \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
483 |
% bootlst_src) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
484 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
485 |
# Create the destination directory if it does not already exist. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
486 |
if not os.path.isdir(bootlst_dir): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
487 |
os.makedirs(bootlst_dir, 0755) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
488 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
489 |
# Copy the bootlst |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
490 |
copyfile(bootlst_src, bootlst_dst) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
491 |
os.chmod(bootlst_dst, |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
492 |
stat.S_IREAD | stat.S_IWRITE | \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
493 |
stat.S_IRGRP | stat.S_IROTH) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
494 |
# Requires root privilige so bypass on dry_run |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
495 |
if dry_run: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
496 |
rmtree(bootlst_dir) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
497 |
else: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
498 |
os.chown(bootlst_dst, 0, 3) # chown root:sys |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
499 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
500 |
def _install_sparc_bootblk(self, dry_run): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
501 |
""" Runs installboot(1M) command on SPARC architectures to |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
502 |
install the zfs bootblock program. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
503 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
504 |
# This method is only supported on SPARC platforms. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
505 |
if self.arch != 'sparc': |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
506 |
raise RuntimeError("Can not install SPARC bootblk on a non-" \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
507 |
"SPARC architecture system") |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
508 |
boot_devs = list() |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
509 |
boot_devs = [os.path.join('/dev/rdsk', dev) \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
510 |
for dev in self.boot_target[DEVS]] |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
511 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
512 |
if len(boot_devs) < 1: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
513 |
raise RuntimeError("No devices to install SPARC bootblk onto!") |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
514 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
515 |
self.logger.info("Installing SPARC bootblk to root pool devices: %s" \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
516 |
% str(boot_devs)) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
517 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
518 |
bootblk_src = os.path.join(self.boot_target[BOOT_ENV].mountpoint, |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
519 |
'platform', platform.machine(), |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
520 |
'lib', 'fs', 'zfs', 'bootblk') |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
521 |
sub_cmd = ["/usr/sbin/installboot", "-F", "zfs", bootblk_src] |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
522 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
523 |
for dev in boot_devs: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
524 |
cmd = sub_cmd[:] |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
525 |
cmd.append(dev) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
526 |
self.logger.debug("Executing: %s" % cmd) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
527 |
if not dry_run: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
528 |
Popen.check_call(cmd, stdout=Popen.STORE, stderr=Popen.STORE, |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
529 |
logger=ILN) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
530 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
531 |
def _set_sparc_prom_boot_device(self, dry_run): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
532 |
""" Set the SPARC boot-device parameter using eeprom. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
533 |
If the root pool is mirrored, sets the boot-device |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
534 |
parameter as a sequence of the devices forming the |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
535 |
root pool. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
536 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
537 |
self.logger.info("Setting openprom boot-device") |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
538 |
prom_device = "/dev/openprom" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
539 |
#ioctl codes and OPROMMAXPARAM taken from /usr/include/sys/openpromio.h |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
540 |
oioc = ord('O') << 8 |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
541 |
opromdev2promname = oioc | 15 # Convert devfs path to prom path |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
542 |
oprommaxparam = 32768 |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
543 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
544 |
boot_devs = list() |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
545 |
boot_devs = [os.path.join('/dev/dsk', dev) \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
546 |
for dev in self.boot_target[DEVS]] |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
547 |
if len(boot_devs) < 1: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
548 |
raise RuntimeError("No boot devices identified!") |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
549 |
|
1338
092bf136b771
7063508 Solaris 11 installers wipes out existing boot-device entries in eeprom
Niall Power <niall.power@oracle.com>
parents:
1287
diff
changeset
|
550 |
cur_prom_boot_devs = list() |
092bf136b771
7063508 Solaris 11 installers wipes out existing boot-device entries in eeprom
Niall Power <niall.power@oracle.com>
parents:
1287
diff
changeset
|
551 |
new_prom_boot_devs = list() |
092bf136b771
7063508 Solaris 11 installers wipes out existing boot-device entries in eeprom
Niall Power <niall.power@oracle.com>
parents:
1287
diff
changeset
|
552 |
prom_arg_str = None |
092bf136b771
7063508 Solaris 11 installers wipes out existing boot-device entries in eeprom
Niall Power <niall.power@oracle.com>
parents:
1287
diff
changeset
|
553 |
|
092bf136b771
7063508 Solaris 11 installers wipes out existing boot-device entries in eeprom
Niall Power <niall.power@oracle.com>
parents:
1287
diff
changeset
|
554 |
# Get the current boot device(s) using eeprom |
092bf136b771
7063508 Solaris 11 installers wipes out existing boot-device entries in eeprom
Niall Power <niall.power@oracle.com>
parents:
1287
diff
changeset
|
555 |
try: |
092bf136b771
7063508 Solaris 11 installers wipes out existing boot-device entries in eeprom
Niall Power <niall.power@oracle.com>
parents:
1287
diff
changeset
|
556 |
cmd = ["/usr/sbin/eeprom", "boot-device"] |
092bf136b771
7063508 Solaris 11 installers wipes out existing boot-device entries in eeprom
Niall Power <niall.power@oracle.com>
parents:
1287
diff
changeset
|
557 |
p = run(cmd) |
092bf136b771
7063508 Solaris 11 installers wipes out existing boot-device entries in eeprom
Niall Power <niall.power@oracle.com>
parents:
1287
diff
changeset
|
558 |
result = p.stdout.replace('boot-device=', '', 1) |
092bf136b771
7063508 Solaris 11 installers wipes out existing boot-device entries in eeprom
Niall Power <niall.power@oracle.com>
parents:
1287
diff
changeset
|
559 |
cur_prom_boot_devs = result.split() |
092bf136b771
7063508 Solaris 11 installers wipes out existing boot-device entries in eeprom
Niall Power <niall.power@oracle.com>
parents:
1287
diff
changeset
|
560 |
except CalledProcessError as cpe: |
092bf136b771
7063508 Solaris 11 installers wipes out existing boot-device entries in eeprom
Niall Power <niall.power@oracle.com>
parents:
1287
diff
changeset
|
561 |
# Treat this as non-fatal. We can still attempt to set the |
092bf136b771
7063508 Solaris 11 installers wipes out existing boot-device entries in eeprom
Niall Power <niall.power@oracle.com>
parents:
1287
diff
changeset
|
562 |
# boot-device property. |
092bf136b771
7063508 Solaris 11 installers wipes out existing boot-device entries in eeprom
Niall Power <niall.power@oracle.com>
parents:
1287
diff
changeset
|
563 |
self.logger.warning("Error querying openprom boot-device:") |
092bf136b771
7063508 Solaris 11 installers wipes out existing boot-device entries in eeprom
Niall Power <niall.power@oracle.com>
parents:
1287
diff
changeset
|
564 |
self.logger.warning(str(cpe)) |
092bf136b771
7063508 Solaris 11 installers wipes out existing boot-device entries in eeprom
Niall Power <niall.power@oracle.com>
parents:
1287
diff
changeset
|
565 |
|
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
566 |
self.logger.debug("Opening prom device: %s" % prom_device) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
567 |
try: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
568 |
with open(prom_device, "r") as prom: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
569 |
# Set boot-device as a sequence for mirrored root pools since |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
570 |
# the OBP will try to boot each successive device specifier |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
571 |
# in the list until something opens successfully. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
572 |
for i, boot_dev in enumerate(boot_devs): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
573 |
self.logger.debug("Boot device %d: %s" % (i, boot_dev)) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
574 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
575 |
# Set up a mutable array for ioctl to read from and write |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
576 |
# to. Standard Python objects are not usable here. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
577 |
# fcntl.ioctl requires a mutable buffer pre-packed with the |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
578 |
# correct values (as determined by the device-driver). |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
579 |
# In this case,openprom(7D) describes the following C |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
580 |
# stucture as defined in <sys.openpromio.h> |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
581 |
# struct openpromio { |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
582 |
# uint_t oprom_size; /* real size of following data */ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
583 |
# union { |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
584 |
# char b[1]; /* NB: Adjacent, Null terminated */ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
585 |
# int i; |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
586 |
# } opio_u; |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
587 |
# }; |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
588 |
dev = (boot_dev + "\0").ljust(oprommaxparam) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
589 |
buf = array.array('c', struct.pack('I%ds' % oprommaxparam, |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
590 |
oprommaxparam, dev)) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
591 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
592 |
# use ioctl to query the prom device. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
593 |
fcntl.ioctl(prom, opromdev2promname, buf, True) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
594 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
595 |
# Unpack the mutable array, buf, which |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
596 |
# ioctl just wrote into. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
597 |
new_oprom_size, new_dev = struct.unpack( |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
598 |
'I%ds' % oprommaxparam, |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
599 |
buf) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
600 |
|
1338
092bf136b771
7063508 Solaris 11 installers wipes out existing boot-device entries in eeprom
Niall Power <niall.power@oracle.com>
parents:
1287
diff
changeset
|
601 |
# Device names are a list of null-terminated tokens, with |
092bf136b771
7063508 Solaris 11 installers wipes out existing boot-device entries in eeprom
Niall Power <niall.power@oracle.com>
parents:
1287
diff
changeset
|
602 |
# a double null on the final token. |
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
603 |
# We use only the first token. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
604 |
prom_name = new_dev.split('\0')[0] |
1338
092bf136b771
7063508 Solaris 11 installers wipes out existing boot-device entries in eeprom
Niall Power <niall.power@oracle.com>
parents:
1287
diff
changeset
|
605 |
new_prom_boot_devs.append(prom_name) |
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
606 |
self.logger.debug("%s prom device name: %s" \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
607 |
% (boot_dev, prom_name)) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
608 |
except StandardError as std: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
609 |
# Treat this as non-fatal. It can be manually fixed later |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
610 |
# on reboot. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
611 |
self.logger.warning("Failed to set openprom boot-device " \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
612 |
"parameter:\n%s" % str(std)) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
613 |
return |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
614 |
|
1338
092bf136b771
7063508 Solaris 11 installers wipes out existing boot-device entries in eeprom
Niall Power <niall.power@oracle.com>
parents:
1287
diff
changeset
|
615 |
# Append old boot-device list onto new list, filtering out any |
092bf136b771
7063508 Solaris 11 installers wipes out existing boot-device entries in eeprom
Niall Power <niall.power@oracle.com>
parents:
1287
diff
changeset
|
616 |
# duplicate device names already in the new list. |
092bf136b771
7063508 Solaris 11 installers wipes out existing boot-device entries in eeprom
Niall Power <niall.power@oracle.com>
parents:
1287
diff
changeset
|
617 |
new_prom_boot_devs.extend([d for d in cur_prom_boot_devs if \ |
092bf136b771
7063508 Solaris 11 installers wipes out existing boot-device entries in eeprom
Niall Power <niall.power@oracle.com>
parents:
1287
diff
changeset
|
618 |
d not in new_prom_boot_devs]) |
092bf136b771
7063508 Solaris 11 installers wipes out existing boot-device entries in eeprom
Niall Power <niall.power@oracle.com>
parents:
1287
diff
changeset
|
619 |
prom_arg_str = " ".join(new_prom_boot_devs) |
092bf136b771
7063508 Solaris 11 installers wipes out existing boot-device entries in eeprom
Niall Power <niall.power@oracle.com>
parents:
1287
diff
changeset
|
620 |
|
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
621 |
# Set the boot device using eeprom |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
622 |
cmd = ["/usr/sbin/eeprom", "boot-device=%s" % prom_arg_str] |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
623 |
self.logger.debug("Executing: %s" % cmd) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
624 |
if not dry_run: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
625 |
try: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
626 |
Popen.check_call(cmd, |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
627 |
stdout=Popen.STORE, |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
628 |
stderr=Popen.STORE, |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
629 |
logger=ILN) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
630 |
except CalledProcessError as cpe: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
631 |
# Treat this as non-fatal. It can be manually fixed later |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
632 |
# on reboot. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
633 |
self.logger.warning("Failed to set openprom boot-device:") |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
634 |
self.logger.warning(str(cpe)) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
635 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
636 |
def _is_target_instance(self, instance): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
637 |
""" Returns True if instance is the boot instance we just installed. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
638 |
Otherwise returns False |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
639 |
Inputs: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
640 |
- instance: A BootInstance object |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
641 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
642 |
# If not a SolarisDiskBootInstance it's not what we just installed |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
643 |
if not isinstance(instance, bootconfig.SolarisDiskBootInstance): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
644 |
return False |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
645 |
# If the fstype of the instance is not zfs |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
646 |
if instance.fstype is not "zfs": |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
647 |
return False |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
648 |
# Check the bootfs property to see if it's a match |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
649 |
if instance.bootfs == self.target_bootfs: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
650 |
return True |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
651 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
652 |
return False |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
653 |
|
1212
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
654 |
def _ref_target_instance(self, instance): |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
655 |
""" Trivial internal convenience method that stores a |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
656 |
reference to the target SolarisDiskBootInstance. |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
657 |
""" |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
658 |
self.target_boot_instance = instance |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
659 |
|
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
660 |
def _set_as_default_instance(self, instance): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
661 |
""" Sets instance as the default boot instance in a boot configuration |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
662 |
Inputs: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
663 |
- instance: A BootInstance object |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
664 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
665 |
self.logger.debug("Marking '%s' as the default boot instance" \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
666 |
% instance.title) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
667 |
instance.default = True |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
668 |
|
1212
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
669 |
def _set_instance_bootenv(self, instance, mountpoint): |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
670 |
""" |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
671 |
Updates instance's bootenv.rc 'console' property. |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
672 |
'console' property determined from bootenv.rc and |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
673 |
devprop(1M) values for 'output-device' and 'console' |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
674 |
""" |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
675 |
# First, bootmgmt needs to read from the bootenv.rc of the BE |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
676 |
instance.init_from_rootpath(mountpoint) |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
677 |
|
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
678 |
curosconsole = instance.boot_vars.getprop('output-device') |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
679 |
osconsole = self._get_x86_console() |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
680 |
|
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
681 |
# Put it in bootenv.rc |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
682 |
if osconsole is not None and curosconsole != osconsole: |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
683 |
self.logger.info('Setting console boot device property to %s' \ |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
684 |
% osconsole) |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
685 |
instance.boot_vars.setprop('console', osconsole) |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
686 |
# If the console device is not the framebuffer, eg. set to serial |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
687 |
# tty, disable graphical splash images in the boot loader. |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
688 |
if osconsole != 'text' and osconsole != 'graphics': |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
689 |
# Disable splash image from the bootloader which is indicated |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
690 |
# by PROP_CONSOLE_GFX and set by default by pybootmgmt. |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
691 |
# Note 'text' above indicates a framebuffer based console so |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
692 |
# don't confuse it with the meaning of PROP_CONSOLE_TEXT below. |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
693 |
self.logger.info("Disabling graphical console in boot loader") |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
694 |
self.config.boot_loader.setprop( |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
695 |
BootLoader.PROP_CONSOLE, |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
696 |
BootLoader.PROP_CONSOLE_TEXT) |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
697 |
|
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
698 |
def _set_instance_title(self, instance): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
699 |
""" Sets the title of instance to match self.boot_title |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
700 |
Inputs: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
701 |
- instance: A BootInstance object |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
702 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
703 |
self.logger.debug("Setting title of boot instance '%s' to '%s'" \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
704 |
% (instance.title, self.boot_title)) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
705 |
instance.title = self.boot_title |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
706 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
707 |
def _get_rel_file_path(self): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
708 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
709 |
Returns file system path to the release file. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
710 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
711 |
return os.path.join(self.boot_target[BOOT_ENV].mountpoint, |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
712 |
"etc/release") |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
713 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
714 |
def _parse_doc_target(self, dry_run=False): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
715 |
""" Parses the target objects in the DOC to determine the |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
716 |
installation target device for boot loader installation |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
717 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
718 |
try: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
719 |
target = self.doc.get_descendants(Target.DESIRED, Target, |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
720 |
max_count=1, max_depth=2, not_found_is_err=True)[0] |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
721 |
except ObjectNotFoundError: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
722 |
raise RuntimeError("No desired target element specified") |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
723 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
724 |
# Find the root pool(s). |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
725 |
root_pools = list() |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
726 |
for pool in target.get_descendants(class_type=Zpool): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
727 |
if pool.is_root: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
728 |
root_pools.append(pool) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
729 |
if len(root_pools) < 1: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
730 |
raise RuntimeError("No desired target Zpool specified") |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
731 |
root_pool = root_pools[0] |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
732 |
boot_env = root_pool.get_first_child(class_type=BE) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
733 |
if boot_env is None: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
734 |
raise RuntimeError("No BE specified in Target.Desired tree") |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
735 |
self.boot_target[BOOT_ENV] = boot_env |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
736 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
737 |
# If dry_run is True, the target BE might not exist so only bail out |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
738 |
# if not a dry run. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
739 |
result = be_list(boot_env.name) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
740 |
if len(result) != 1: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
741 |
if dry_run == False: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
742 |
raise RuntimeError("Target BE \'%s\' does not exist" \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
743 |
% (boot_env.name)) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
744 |
else: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
745 |
self.target_bootfs = result[0][2] |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
746 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
747 |
# Get root pool's top level filesystem mountpoint |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
748 |
pool = boot_env.parent |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
749 |
if pool.mountpoint: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
750 |
self.pool_tld_mount = pool.mountpoint |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
751 |
# If mountpoint not defined by the zpool, look at its datasets |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
752 |
# for one with the same name as the zpool. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
753 |
if self.pool_tld_mount is None: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
754 |
for filesystem in pool.filesystems: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
755 |
if filesystem.name == pool.name: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
756 |
self.pool_tld_mount = filesystem.get("mountpoint") |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
757 |
break |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
758 |
# If no top level dataset definition exists then assume default zfs |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
759 |
# behaviour for pool top level dataset mount point as '/<pool.name>' |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
760 |
if self.pool_tld_mount is None: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
761 |
self.pool_tld_mount = os.path.join('/', pool.name) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
762 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
763 |
if not os.path.exists(self.pool_tld_mount): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
764 |
raise RuntimeError("Expected mountpoint \'%\' of top level" \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
765 |
"fileystem \'%s\' does not exist!" \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
766 |
% (pool.name, self.pool_tld_mount)) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
767 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
768 |
# Figure out the boot device names in ctd notation |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
769 |
# XXX Will need to check for UEFI/GPT partitions here in future |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
770 |
for disk in target.get_children(class_type=Disk): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
771 |
# Look for slices that are in the boot/root pool and store |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
772 |
# their ctd device names. "slice" is a python reserved word |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
773 |
# so use "slc" to represent slice instead. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
774 |
slices = disk.get_descendants(class_type=Slice, max_depth=2) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
775 |
boot_slices = [slc for slc in slices if \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
776 |
slc.in_zpool == root_pool.name] |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
777 |
bdevs = ['%ss%s' % (disk.ctd, slc.name) for slc in boot_slices] |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
778 |
self.boot_target[DEVS].extend(bdevs) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
779 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
780 |
title_line = linecache.getline(self._get_rel_file_path(), 1) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
781 |
self.rel_file_title = title_line.strip() |
1255
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
782 |
# Set an initial boot_title value. It can be overwritten later by the |
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
783 |
# .image_info file GRUB_TITLE value or the BootMods tree of the DOC. |
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
784 |
self.boot_title = self.rel_file_title |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
785 |
|
1255
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
786 |
# On X86 systems, set boot title according to "GRUB_TITLE" keyword |
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
787 |
# of the .image_info file, if defined. |
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
788 |
if self.arch == 'sparc': |
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
789 |
return |
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
790 |
try: |
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
791 |
self.img_info_title = get_image_grub_title( |
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
792 |
self.logger, |
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
793 |
image_info_file=self.img_info_path) |
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
794 |
# get_image_grub_title() will raise CalledProcessError if not |
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
795 |
# booted from installation media so suppress it if dry_run == True |
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
796 |
except CalledProcessError as cpe: |
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
797 |
if dry_run == False: |
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
798 |
raise cpe |
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
799 |
|
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
800 |
if self.img_info_title is not None: |
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
801 |
self.logger.debug("Setting boot title to image info value: %s" \ |
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
802 |
% self.img_info_title) |
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
803 |
self.boot_title = self.img_info_title |
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
804 |
|
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
805 |
def build_default_entries(self): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
806 |
""" Method for constructing the default entries list. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
807 |
When installing onto physical target systems, the list of entries |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
808 |
is autogenerated based on discovery routines within bootmgmt. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
809 |
The discovered entries should already be present from the |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
810 |
invocation of init_boot_config() so the only remaining tasks here |
1212
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
811 |
are to set the new boot environment as the default boot instance |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
812 |
and the console properties on X86. |
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
813 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
814 |
# Find the boot environment (BE) we just installed and |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
815 |
# make it the default boot instance |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
816 |
self.config.modify_boot_instance(self._is_target_instance, |
1212
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
817 |
self._ref_target_instance) |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
818 |
self._set_as_default_instance(self.target_boot_instance) |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
819 |
# Set its boot title |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
820 |
self._set_instance_title(self.target_boot_instance) |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
821 |
# Set up bootenv.rc console properties on the target instance |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
822 |
if self.arch == 'i386': |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
823 |
self._set_instance_bootenv( |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
824 |
instance=self.target_boot_instance, |
28f35d85a2b5
7051340 x86 machines unable to boot after textinstall and auto_install if
Niall Power <niall.power@oracle.com>
parents:
1185
diff
changeset
|
825 |
mountpoint=self.boot_target[BOOT_ENV].mountpoint) |
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
826 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
827 |
def build_custom_entries(self): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
828 |
""" Currently only consumed by AI installer app. GUI & Text do not |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
829 |
consume a manifest XML file. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
830 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
831 |
for entry in self.boot_entry_list: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
832 |
instance = \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
833 |
SolarisDiskBootInstance(self.boot_target[BOOT_ENV].mountpoint, |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
834 |
fstype='zfs', |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
835 |
bootfs=self.target_bootfs) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
836 |
instance.title = self.boot_title + \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
837 |
" " + entry.title_suffix |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
838 |
if entry.default_entry: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
839 |
instance.default = True |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
840 |
else: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
841 |
instance.default = False |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
842 |
instance.kargs = entry.kernel_args |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
843 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
844 |
if entry.insert_at == "start": |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
845 |
where = 0 |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
846 |
else: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
847 |
where = -1 |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
848 |
self.logger.info("Adding custom boot entry: \'%s\'" \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
849 |
% instance.title) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
850 |
self.config.add_boot_instance(instance, where) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
851 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
852 |
def install_boot_loader(self, dry_run=False): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
853 |
""" Install the boot loader and associated boot |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
854 |
configuration files |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
855 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
856 |
boot_rdevs = [os.path.join('/dev/rdsk', dev) \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
857 |
for dev in self.boot_target[DEVS]] |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
858 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
859 |
if dry_run == True: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
860 |
# Write boot config to a temporary directory instead of to |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
861 |
# a physical target |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
862 |
temp_dir = \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
863 |
tempfile.mkdtemp(dir="/tmp", prefix="boot_config_") |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
864 |
# Add dictionary mappings for tokens that commit_boot_config() |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
865 |
# might return. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
866 |
self.boot_tokens[DiskBootConfig.TOKEN_ZFS_RPOOL_TOP_DATASET] = \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
867 |
self.pool_tld_mount |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
868 |
self.boot_tokens[BootConfig.TOKEN_SYSTEMROOT] = \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
869 |
self.boot_target[BOOT_ENV].mountpoint |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
870 |
self.logger.info("Installing boot loader configuration files to: \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
871 |
%s" % (temp_dir)) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
872 |
boot_config_list = \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
873 |
self.config.commit_boot_config(temp_dir, None) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
874 |
self._handle_boot_config_list(boot_config_list, dry_run) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
875 |
else: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
876 |
# Check to make sure that an installation attempt is not |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
877 |
# executed on a live system |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
878 |
if self.boot_target[BOOT_ENV].mountpoint == '/': |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
879 |
raise RuntimeError("Boot checkpoint can not be executed on " \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
880 |
"a live system except with dry run mode") |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
881 |
# XXX Pybootmgmt ought to be creating this directory tree when |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
882 |
# doing a physical boot loader installation onto the disk. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
883 |
# While it's being fixed, create the directories ourselves to |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
884 |
# make legacy Grub installation work. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
885 |
if not dry_run and self.config.boot_loader.name == "Legacy GRUB": |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
886 |
grub_dir = os.path.join(self.pool_tld_mount, "boot", "grub") |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
887 |
if not os.path.exists(grub_dir): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
888 |
self.logger.info("Creating Legacy GRUB config directory:" \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
889 |
"\n\t%s" % (grub_dir)) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
890 |
os.makedirs(grub_dir, 755) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
891 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
892 |
# Danger Will Robinson!! |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
893 |
self.logger.info("Installing boot loader to devices: %s" \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
894 |
% str(boot_rdevs)) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
895 |
self.config.commit_boot_config( |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
896 |
boot_devices=boot_rdevs) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
897 |
# XXX Pybootmgmt ought to do this but doesn't currently so |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
898 |
# set up the bootfs property on the boot pool. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
899 |
self._set_bootfs_pool_prop(dry_run) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
900 |
if dry_run: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
901 |
rmtree(temp_dir) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
902 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
903 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
904 |
class ISOImageBootMenu(BootMenu): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
905 |
""" Abstract base class for ISOImageBootMenu checkpoint |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
906 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
907 |
__metaclass__ = abc.ABCMeta |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
908 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
909 |
def __init__(self, name): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
910 |
""" Constructor for class |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
911 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
912 |
super(ISOImageBootMenu, self).__init__(name) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
913 |
self.dc_dict = dict() |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
914 |
self.dc_pers_dict = dict() |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
915 |
self.pkg_img_path = None |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
916 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
917 |
def init_boot_config(self, autogen=True): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
918 |
""" Instantiates the appropriate bootmgmt.bootConfig subclass object |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
919 |
for this class |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
920 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
921 |
bc_flags = (bootconfig.BootConfig.BCF_CREATE, |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
922 |
bootconfig.BootConfig.BCF_ONESHOT) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
923 |
self.config = ODDBootConfig(bc_flags, |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
924 |
oddimage_root=self.pkg_img_path) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
925 |
# UEFI Note that we will have to specify additional firmware |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
926 |
# targets (uefi64 & SPARC OBP) when pybootmgmt supports them. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
927 |
self.config.boot_loader.setprop('boot-targets', 'bios') |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
928 |
|
1256
e8a8a4e2bb96
7044356 x86 boot menu timeout regression after pybootmgt putback
Niall Power <niall.power@oracle.com>
parents:
1255
diff
changeset
|
929 |
# Apply boot timeout property to boot loader. |
e8a8a4e2bb96
7044356 x86 boot menu timeout regression after pybootmgt putback
Niall Power <niall.power@oracle.com>
parents:
1255
diff
changeset
|
930 |
try: |
e8a8a4e2bb96
7044356 x86 boot menu timeout regression after pybootmgt putback
Niall Power <niall.power@oracle.com>
parents:
1255
diff
changeset
|
931 |
self.config.boot_loader.setprop('timeout', |
e8a8a4e2bb96
7044356 x86 boot menu timeout regression after pybootmgt putback
Niall Power <niall.power@oracle.com>
parents:
1255
diff
changeset
|
932 |
self.boot_timeout) |
e8a8a4e2bb96
7044356 x86 boot menu timeout regression after pybootmgt putback
Niall Power <niall.power@oracle.com>
parents:
1255
diff
changeset
|
933 |
except BootmgmtUnsupportedPropertyError: |
e8a8a4e2bb96
7044356 x86 boot menu timeout regression after pybootmgt putback
Niall Power <niall.power@oracle.com>
parents:
1255
diff
changeset
|
934 |
self.logger.warning("Boot loader type %s does not support the \ |
e8a8a4e2bb96
7044356 x86 boot menu timeout regression after pybootmgt putback
Niall Power <niall.power@oracle.com>
parents:
1255
diff
changeset
|
935 |
'timeout' property. Ignoring." \ |
e8a8a4e2bb96
7044356 x86 boot menu timeout regression after pybootmgt putback
Niall Power <niall.power@oracle.com>
parents:
1255
diff
changeset
|
936 |
% self.config.boot_loader.name) |
e8a8a4e2bb96
7044356 x86 boot menu timeout regression after pybootmgt putback
Niall Power <niall.power@oracle.com>
parents:
1255
diff
changeset
|
937 |
|
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
938 |
def _get_rel_file_path(self): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
939 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
940 |
Returns file system path to the release file. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
941 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
942 |
return os.path.join(self.pkg_img_path, "etc/release") |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
943 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
944 |
def _add_chainloader_entry(self): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
945 |
""" Adds a chainloader entry to the boot configuration. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
946 |
""" |
1232
b3867d19f3eb
7050300 Boot from Hard Disk grub entry on X86 ISO media has wrong parameters
Niall Power <niall.power@oracle.com>
parents:
1212
diff
changeset
|
947 |
instance = ChainDiskBootInstance(chaininfo=tuple([0])) |
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
948 |
instance.title = "Boot from Hard Disk" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
949 |
self.config.add_boot_instance(instance) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
950 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
951 |
def build_custom_entries(self): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
952 |
""" Add custom defined boot entries from the manifest XML |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
953 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
954 |
for entry in self.boot_entry_list: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
955 |
instance = SolarisODDBootInstance(self.pkg_img_path) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
956 |
instance.title = self.boot_title + " " + entry.title_suffix |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
957 |
# The last boot entry in the list tagged as the default boot entry |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
958 |
# overrides the previous default if more than one is tagged as |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
959 |
# the default. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
960 |
if entry.default_entry: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
961 |
instance.default = True |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
962 |
else: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
963 |
instance.default = False |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
964 |
instance.kargs = entry.kernel_args |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
965 |
if entry.insert_at == "start": |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
966 |
where = 0 |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
967 |
else: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
968 |
where = -1 |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
969 |
self.config.add_boot_instance(instance, where) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
970 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
971 |
def _parse_doc_target(self, dry_run=False): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
972 |
""" Class method for parsing data object cache (DOC) objects for use by |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
973 |
the checkpoint. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
974 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
975 |
try: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
976 |
self.dc_pers_dict = self.doc.persistent.get_children( |
1173
eb652dc71752
7046485 install_boot/boot.py imports a DC python module, causing undesired dependencies in snv_166
Mary Ding <mary.ding@oracle.com>
parents:
1111
diff
changeset
|
977 |
name=DC_PERS_LABEL, |
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
978 |
class_type=DataObjectDict, |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
979 |
not_found_is_err=True)[0].data_dict |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
980 |
except ObjectNotFoundError: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
981 |
pass |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
982 |
|
1173
eb652dc71752
7046485 install_boot/boot.py imports a DC python module, causing undesired dependencies in snv_166
Mary Ding <mary.ding@oracle.com>
parents:
1111
diff
changeset
|
983 |
self.dc_dict = self.doc.volatile.get_children(name=DC_LABEL, |
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
984 |
class_type=DataObjectDict, |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
985 |
not_found_is_err=True)[0].data_dict |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
986 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
987 |
try: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
988 |
self.pkg_img_path = self.dc_dict["pkg_img_path"] |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
989 |
except KeyError, msg: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
990 |
raise RuntimeError("Error retrieving a value from the DOC: " + \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
991 |
str(msg)) |
1255
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
992 |
self.img_info_path = os.path.join(self.pkg_img_path, ".image_info") |
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
993 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
994 |
title_line = linecache.getline(self._get_rel_file_path(), 1) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
995 |
self.rel_file_title = title_line.strip() |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
996 |
# Set an initial boot_title value. It can be overwritten later when |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
997 |
# parsing the BootMods tree of the DOC |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
998 |
self.boot_title = self.rel_file_title |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
999 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1000 |
def execute(self, dry_run=False): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1001 |
""" Primary execution method used by the Checkpoint parent class |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1002 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1003 |
self.logger.info("=== Executing Boot Loader Setup Checkpoint ===") |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1004 |
super(ISOImageBootMenu, self).execute(dry_run) |
1255
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
1005 |
self.update_img_info_path() |
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1006 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1007 |
def install_boot_loader(self, dry_run=False): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1008 |
""" Install the boot loader and associated boot configuration files. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1009 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1010 |
if dry_run == True: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1011 |
temp_dir = \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1012 |
tempfile.mkdtemp(dir="/tmp", prefix="iso_boot_config_") |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1013 |
else: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1014 |
temp_dir = self.pkg_img_path |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1015 |
# Add dictionary mappings for tokens that commit_boot_config() might |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1016 |
# return. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1017 |
self.boot_tokens[BootConfig.TOKEN_SYSTEMROOT] = self.pkg_img_path |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1018 |
self.logger.debug("Writing boot configuration to %s" % (temp_dir)) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1019 |
boot_config_list = self.config.commit_boot_config(temp_dir, None) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1020 |
self._handle_boot_config_list(boot_config_list, dry_run) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1021 |
if dry_run: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1022 |
rmtree(temp_dir) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1023 |
|
1255
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
1024 |
def update_img_info_path(self): |
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
1025 |
""" Method to write out the .img_info_path file. |
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
1026 |
""" |
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
1027 |
self.logger.info("Updating %s" % self.img_info_path) |
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
1028 |
|
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
1029 |
# Write out the GRUB_TITLE line |
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
1030 |
with open(self.img_info_path, "a+") as iip: |
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
1031 |
try: |
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
1032 |
iip.write("GRUB_TITLE=" + self.boot_title) |
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
1033 |
except IOError, msg: |
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
1034 |
raise RuntimeError(msg) |
d2d810d1c345
7047882 Incorrect grub menu entry during reboot after text installation
Niall Power <niall.power@oracle.com>
parents:
1232
diff
changeset
|
1035 |
|
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1036 |
def _handle_iso_boot_image_type(self, config, dry_run): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1037 |
""" Method that copies ISO El Torito and HSFS bootblockimage file types |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1038 |
to their appropriate targets. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1039 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1040 |
# Store the ISO boot image path in DC's dictionary for later use |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1041 |
# when constructing the ISO image |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1042 |
img_type = config[0] |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1043 |
src = config[1] |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1044 |
if not os.path.exists(src): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1045 |
raise RuntimeError("Expected boot image type \'%s\' does not " \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1046 |
"exist at path: %s" % (img_type, src)) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1047 |
if dry_run is True: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1048 |
self.logger.debug("Deleting El Torito image: %s" % src) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1049 |
os.unlink(src) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1050 |
return |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1051 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1052 |
if not os.path.abspath(src).startswith(self.pkg_img_path): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1053 |
raise RuntimeError("El Torito boot image \'%s\' mislocated " |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1054 |
"outside of image root: %s" \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1055 |
% (src, self.pkg_img_path)) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1056 |
if img_type == BootConfig.OUTPUT_TYPE_BIOS_ELTORITO: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1057 |
# bios-eltorito-img needs to live in the persistent section |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1058 |
# of the DOC to ensure pause/resume works correctly. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1059 |
# |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1060 |
# Update the DC_PERS_LABEL DOC object with an entry for |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1061 |
# bios-eltorito-img |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1062 |
if self.dc_pers_dict: |
1173
eb652dc71752
7046485 install_boot/boot.py imports a DC python module, causing undesired dependencies in snv_166
Mary Ding <mary.ding@oracle.com>
parents:
1111
diff
changeset
|
1063 |
self.doc.persistent.delete_children(name=DC_PERS_LABEL) |
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1064 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1065 |
# Strip out the pkg_img_path prefix from src. Otherwise |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1066 |
# mkisofs will choke because it requires a relative rather |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1067 |
# than an absolute path for the eltorito image argument |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1068 |
self.dc_pers_dict["bios-eltorito-img"] = \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1069 |
src.split(self.pkg_img_path + os.sep)[1] |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1070 |
self.doc.persistent.insert_children( |
1173
eb652dc71752
7046485 install_boot/boot.py imports a DC python module, causing undesired dependencies in snv_166
Mary Ding <mary.ding@oracle.com>
parents:
1111
diff
changeset
|
1071 |
DataObjectDict(DC_PERS_LABEL, |
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1072 |
self.dc_pers_dict, generate_xml=True)) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1073 |
self.logger.debug("BIOS El Torito boot image: %s" \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1074 |
% self.dc_pers_dict["bios-eltorito-img"]) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1075 |
# UEFI / Pybootmgmt. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1076 |
# Add in blocks to handle UEFI ELTORIO and SPARC HSFS BOOTBLK |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1077 |
# types here when pybootmgmt supports these firmware types. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1078 |
# For now just it just does BIOS ELTORITO above. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1079 |
else: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1080 |
raise RuntimeError("Unrecognised ISO boot loader image type: %s" \ |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1081 |
% img_type) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1082 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1083 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1084 |
class AIISOImageBootMenu(ISOImageBootMenu): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1085 |
""" Class for AIISOImageBootMenu checkpoint. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1086 |
Used by Distro Constructor for creation of Automated Install ISO image. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1087 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1088 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1089 |
def __init__(self, name, arg=None): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1090 |
""" Constructor for class |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1091 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1092 |
super(AIISOImageBootMenu, self).__init__(name) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1093 |
self.installadm_entry = None |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1094 |
if arg: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1095 |
self.__setup(**arg) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1096 |
else: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1097 |
self.__setup() |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1098 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1099 |
def __setup(self, installadm_entry="boot image"): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1100 |
""" Setup checkpoint with any kwargs in manifest XML |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1101 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1102 |
self.installadm_entry = installadm_entry |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1103 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1104 |
def build_default_entries(self): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1105 |
""" Constructs the default boot entries and inserts them into the |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1106 |
bootConfig object's boot_instances list |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1107 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1108 |
ai_titles = [self.boot_title + " Automated Install custom", |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1109 |
self.boot_title + " Automated Install", |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1110 |
self.boot_title + " Automated Install custom ttya", |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1111 |
self.boot_title + " Automated Install custom ttyb", |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1112 |
self.boot_title + " Automated Install ttya", |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1113 |
self.boot_title + " Automated Install ttyb"] |
1185
cb1813d9af41
7047816 The auto-installer is disabled when booting from physical media, CDs,
Niall Power <niall.power@oracle.com>
parents:
1173
diff
changeset
|
1114 |
ai_kargs = ["-B install=true,aimanifest=prompt", |
cb1813d9af41
7047816 The auto-installer is disabled when booting from physical media, CDs,
Niall Power <niall.power@oracle.com>
parents:
1173
diff
changeset
|
1115 |
"-B install=true", |
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1116 |
"-B install=true,aimanifest=prompt,console=ttya", |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1117 |
"-B install=true,aimanifest=prompt,console=ttyb", |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1118 |
"-B install=true,console=ttya", |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1119 |
"-B install=true,console=ttyb"] |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1120 |
for i, title in enumerate(ai_titles): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1121 |
instance = SolarisODDBootInstance(self.pkg_img_path) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1122 |
instance.title = title |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1123 |
# Make the first entry the default |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1124 |
if i == 0: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1125 |
instance.default = True |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1126 |
instance.kargs = ai_kargs[i] |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1127 |
self.config.add_boot_instance(instance) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1128 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1129 |
# Create a chainloader boot from HD entry |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1130 |
self._add_chainloader_entry() |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1131 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1132 |
def update_img_info_path(self): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1133 |
""" Method to write out the .img_info_path file. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1134 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1135 |
self.logger.info("Updating %s" % self.img_info_path) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1136 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1137 |
# write out the GRUB_TITLE line |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1138 |
with open(self.img_info_path, "a+") as iip: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1139 |
try: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1140 |
iip.write("GRUB_TITLE=" + self.boot_title + "\n") |
1287
8a3a06be1d48
7067272 GRUB_MIN_MEM64 regression in snv_166 and onward and x86 with less than 1 GB memory cannot boot AI (reintroduce GRUB_MIN_MEM64 line)
Drew Fisher <drew.fisher@oracle.com>
parents:
1284
diff
changeset
|
1141 |
iip.write("GRUB_MIN_MEM64=0\n") |
1111
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1142 |
iip.write("GRUB_DO_SAFE_DEFAULT=true\n") |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1143 |
iip.write("NO_INSTALL_GRUB_TITLE=%s\n" % self.installadm_entry) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1144 |
except IOError, msg: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1145 |
raise RuntimeError(msg) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1146 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1147 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1148 |
class LiveCDISOImageBootMenu(ISOImageBootMenu): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1149 |
""" Class for LiveCDISOImageBootMenu checkpoint. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1150 |
Used by Distro Constructor for creation of LiveCD |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1151 |
ISO image. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1152 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1153 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1154 |
def __init__(self, name): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1155 |
""" Constructor for class |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1156 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1157 |
super(LiveCDISOImageBootMenu, self).__init__(name) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1158 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1159 |
def build_default_entries(self): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1160 |
""" Constructs the default boot entries and inserts them into the |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1161 |
bootConfig object's boot_instances list |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1162 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1163 |
# create lists of boot titles and kernel args to use |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1164 |
lcd_titles = [self.boot_title, |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1165 |
self.boot_title + " VESA driver", |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1166 |
self.boot_title + " text console"] |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1167 |
lcd_kargs = [None, |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1168 |
"-B livemode=vesa", |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1169 |
"-B livemode=text"] |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1170 |
for i, title in enumerate(lcd_titles): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1171 |
instance = SolarisODDBootInstance(self.pkg_img_path) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1172 |
instance.title = title |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1173 |
# Make the first entry the default |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1174 |
if i == 0: |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1175 |
instance.default = True |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1176 |
instance.kargs = lcd_kargs[i] |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1177 |
self.config.add_boot_instance(instance) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1178 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1179 |
# Create a chainloader boot from HD entry |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1180 |
self._add_chainloader_entry() |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1181 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1182 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1183 |
class TextISOImageBootMenu(ISOImageBootMenu): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1184 |
""" Class for TextISOImageBootMenu checkpoint. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1185 |
Used by Distro Constructor for creation of Text installer ISO image. |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1186 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1187 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1188 |
def __init__(self, name): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1189 |
""" Constructor for class |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1190 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1191 |
super(TextISOImageBootMenu, self).__init__(name) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1192 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1193 |
def build_default_entries(self): |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1194 |
""" Constructs the default boot entries and inserts them into the |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1195 |
bootConfig object's boot_instances list |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1196 |
""" |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1197 |
instance = SolarisODDBootInstance(self.pkg_img_path) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1198 |
instance.title = self.boot_title |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1199 |
# Make this entry the default |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1200 |
instance.default = True |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1201 |
self.config.add_boot_instance(instance) |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1202 |
|
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1203 |
# Create a chainloader boot from HD entry |
0c6c862af34f
7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents:
diff
changeset
|
1204 |
self._add_chainloader_entry() |