author | Jesse Butler <jesse.butler@oracle.com> |
Mon, 21 May 2012 13:15:52 -0600 | |
changeset 1682 | c992a85ed3d0 |
parent 1644 | e827d1934114 |
child 1704 | 5f40688bef06 |
permissions | -rw-r--r-- |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
2 |
# |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
3 |
# CDDL HEADER START |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
4 |
# |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
5 |
# The contents of this file are subject to the terms of the |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
6 |
# Common Development and Distribution License (the "License"). |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
7 |
# You may not use this file except in compliance with the License. |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
8 |
# |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
9 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
10 |
# or http://www.opensolaris.org/os/licensing. |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
11 |
# See the License for the specific language governing permissions |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
12 |
# and limitations under the License. |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
13 |
# |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
14 |
# When distributing Covered Code, include this CDDL HEADER in each |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
15 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
16 |
# If applicable, add the following below this CDDL HEADER, with the |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
17 |
# fields enclosed by brackets "[]" replaced with your own identifying |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
18 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
19 |
# |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
20 |
# CDDL HEADER END |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
21 |
# |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
22 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
23 |
# |
1623
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
24 |
# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
25 |
# |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
26 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
27 |
""" discovery.py - target discovery checkpoint. Attempts to find all target |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
28 |
devices on the given system. The Data Object Cache is populated with the |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
29 |
information. |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
30 |
""" |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
31 |
|
1623
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
32 |
import copy |
1407
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
33 |
import optparse |
1355
7e6507b2a970
6260 sparc AI need a way to mechanism to explicitly ask for creating label on Sparc disk
Drew Fisher <drew.fisher@oracle.com>
parents:
1329
diff
changeset
|
34 |
import os |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
35 |
import platform |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
36 |
import re |
1407
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
37 |
import sys |
1623
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
38 |
import tempfile |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
39 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
40 |
import solaris_install.target.vdevs as vdevs |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
41 |
|
1629
a8f3ef646806
7157666 There was the I/O error while ran discovery.py on i86pc arch AI Client
Drew Fisher <drew.fisher@oracle.com>
parents:
1623
diff
changeset
|
42 |
from bootmgmt.pysol import getmntany, mnttab_open, mnttab_close |
1218
ead7c7d814c7
7052696 TI install fails with target discovery in snv_167 if there is floppy drive
Drew Fisher <drew.fisher@oracle.com>
parents:
1213
diff
changeset
|
43 |
|
1323
7e185ea5a224
7068381 AI doesn't retry to list the iscsi target if the OS Device Name is not available
Drew Fisher <drew.fisher@oracle.com>
parents:
1275
diff
changeset
|
44 |
from solaris_install import CalledProcessError, Popen, run |
1197
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
45 |
from solaris_install.data_object.data_dict import DataObjectDict |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
46 |
from solaris_install.engine import InstallEngine |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
47 |
from solaris_install.engine.checkpoint import AbstractCheckpoint as Checkpoint |
1197
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
48 |
from solaris_install.target import CRO_LABEL, Target |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
49 |
from solaris_install.target.libbe import be |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
50 |
from solaris_install.target.libdevinfo import devinfo |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
51 |
from solaris_install.target.libdiskmgt import const, diskmgt |
1623
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
52 |
from solaris_install.target.libefi.efi import efi_free, efi_read |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
53 |
from solaris_install.target.logical import BE, Filesystem, Logical, Zpool, Zvol |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
54 |
from solaris_install.target.physical import Disk, DiskProp, DiskGeometry, \ |
1623
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
55 |
DiskKeyword, Iscsi, GPTPartition, Partition, Slice |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
56 |
from solaris_install.target.size import Size |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
57 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
58 |
|
1197
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
59 |
CROINFO = "/usr/sbin/croinfo" |
1323
7e185ea5a224
7068381 AI doesn't retry to list the iscsi target if the OS Device Name is not available
Drew Fisher <drew.fisher@oracle.com>
parents:
1275
diff
changeset
|
60 |
DEVFSADM = "/usr/sbin/devfsadm" |
7e185ea5a224
7068381 AI doesn't retry to list the iscsi target if the OS Device Name is not available
Drew Fisher <drew.fisher@oracle.com>
parents:
1275
diff
changeset
|
61 |
DHCPINFO = "/sbin/dhcpinfo" |
1644
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
62 |
DLADM = "/usr/sbin/dladm" |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
63 |
EEPROM = "/usr/sbin/eeprom" |
1122
d30415c63b07
7041406 Disk class needs prop_matches() method
Drew Fisher <drew.fisher@oracle.com>
parents:
1118
diff
changeset
|
64 |
FSTYP = "/usr/sbin/fstyp" |
1323
7e185ea5a224
7068381 AI doesn't retry to list the iscsi target if the OS Device Name is not available
Drew Fisher <drew.fisher@oracle.com>
parents:
1275
diff
changeset
|
65 |
ISCSIADM = "/usr/sbin/iscsiadm" |
1623
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
66 |
PCFSMOUNT = "/usr/lib/fs/pcfs/mount" |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
67 |
PRTVTOC = "/usr/sbin/prtvtoc" |
1323
7e185ea5a224
7068381 AI doesn't retry to list the iscsi target if the OS Device Name is not available
Drew Fisher <drew.fisher@oracle.com>
parents:
1275
diff
changeset
|
68 |
SVCS = "/usr/bin/svcs" |
1372
bd82f26440d5
7076301 discovery.py has the wrong path to svcadm
Drew Fisher <drew.fisher@oracle.com>
parents:
1355
diff
changeset
|
69 |
SVCADM = "/usr/sbin/svcadm" |
1623
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
70 |
UMOUNT = "/usr/sbin/umount" |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
71 |
ZFS = "/usr/sbin/zfs" |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
72 |
ZPOOL = "/usr/sbin/zpool" |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
73 |
ZVOL_PATH = "/dev/zvol/dsk" |
1623
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
74 |
ZVOL_RPATH = "/dev/zvol/rdsk" |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
75 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
76 |
DISK_SEARCH_NAME = "disk" |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
77 |
ZPOOL_SEARCH_NAME = "zpool" |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
78 |
|
1644
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
79 |
# regex for matching c#t#d# OR c#d# strings. Use \w rather than \d for the |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
80 |
# "t" to allow matching of WWNs |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
81 |
DISK_RE = "c\d+(?:t\w+)?d\d+" |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
82 |
|
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
83 |
|
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
84 |
def retrieve_drive(name): |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
85 |
""" function to return a drive object based on a specific name |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
86 |
""" |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
87 |
|
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
88 |
try: |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
89 |
# check to see if the search name is either c#t#d# or c#d# |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
90 |
if re.match(DISK_RE, name, re.I): |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
91 |
dmd = diskmgt.descriptor_from_key(const.ALIAS, name) |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
92 |
alias = diskmgt.DMAlias(dmd.value) |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
93 |
drive = alias.drive |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
94 |
else: |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
95 |
dmd = diskmgt.descriptor_from_key(const.DRIVE, name) |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
96 |
drive = diskmgt.DMDrive(dmd.value) |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
97 |
except (KeyError, OSError) as err: |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
98 |
raise RuntimeError("Unable to look up %s - %s" % (name, err)) |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
99 |
|
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
100 |
return drive |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
101 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
102 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
103 |
class TargetDiscovery(Checkpoint): |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
104 |
""" Discover all logical and physical devices on the system. |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
105 |
""" |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
106 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
107 |
def __init__(self, name, search_name=None, search_type=None): |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
108 |
super(TargetDiscovery, self).__init__(name) |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
109 |
|
1355
7e6507b2a970
6260 sparc AI need a way to mechanism to explicitly ask for creating label on Sparc disk
Drew Fisher <drew.fisher@oracle.com>
parents:
1329
diff
changeset
|
110 |
self.dry_run = False |
7e6507b2a970
6260 sparc AI need a way to mechanism to explicitly ask for creating label on Sparc disk
Drew Fisher <drew.fisher@oracle.com>
parents:
1329
diff
changeset
|
111 |
|
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
112 |
self.eng = InstallEngine.get_instance() |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
113 |
self.doc = self.eng.data_object_cache |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
114 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
115 |
# create a root node to insert all discovered objects into |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
116 |
self.root = Target(Target.DISCOVERED) |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
117 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
118 |
# user specified search criteria |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
119 |
self.search_name = search_name |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
120 |
self.search_type = search_type |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
121 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
122 |
# list of discovered swap and dump zvols |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
123 |
self.swap_list = list() |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
124 |
self.dump_list = list() |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
125 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
126 |
# eeprom diag mode and bootdisk value |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
127 |
self.sparc_diag_mode = False |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
128 |
self.bootdisk = None |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
129 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
130 |
# kernel architecture |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
131 |
self.arch = platform.processor() |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
132 |
|
1197
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
133 |
# croinfo dictionary |
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
134 |
self.cro_dict = dict() |
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
135 |
|
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
136 |
def is_bootdisk(self, name): |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
137 |
""" is_bootdisk() -- simple method to compare the name of the disk in |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
138 |
question with what libdevinfo reports as the bootdisk |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
139 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
140 |
name - ctd name of the disk to check |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
141 |
""" |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
142 |
# cache the answer so we don't do multiple lookups to libdevinfo |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
143 |
if self.bootdisk is None: |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
144 |
self.bootdisk = devinfo.get_curr_bootdisk() |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
145 |
return self.bootdisk == name |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
146 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
147 |
def get_progress_estimate(self): |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
148 |
# XXX |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
149 |
return 1 |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
150 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
151 |
def discover_disk(self, drive): |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
152 |
""" discover_disk - method to discover a physical disk's attributes, |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
153 |
partitions and slices |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
154 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
155 |
drive - which physical drive to parse |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
156 |
""" |
1118
c87a271a3921
7043165 Not possible to tell if a Partition was specified in the XML without a start_sector.
Drew Fisher <drew.fisher@oracle.com>
parents:
1117
diff
changeset
|
157 |
# create a DOC object for this drive. Set validate_children to False |
1117
ae9a188dcfcc
7043629 Target shadow list should not adjust boundaries on discovered partitions
Drew Fisher <drew.fisher@oracle.com>
parents:
1110
diff
changeset
|
158 |
# so the shadow code doesn't adjust the start sector or size for any |
ae9a188dcfcc
7043629 Target shadow list should not adjust boundaries on discovered partitions
Drew Fisher <drew.fisher@oracle.com>
parents:
1110
diff
changeset
|
159 |
# children discovered |
1118
c87a271a3921
7043165 Not possible to tell if a Partition was specified in the XML without a start_sector.
Drew Fisher <drew.fisher@oracle.com>
parents:
1117
diff
changeset
|
160 |
new_disk = Disk("disk", validate_children=False) |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
161 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
162 |
# extract drive attributes and media information |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
163 |
drive_attributes = drive.attributes |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
164 |
drive_media = drive.media |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
165 |
|
1558
984cec791838
7118599 Unable to install s11u1_03 from DVD to a x86 system
Drew Fisher <drew.fisher@oracle.com>
parents:
1543
diff
changeset
|
166 |
# if a drive is offline or down return None |
984cec791838
7118599 Unable to install s11u1_03 from DVD to a x86 system
Drew Fisher <drew.fisher@oracle.com>
parents:
1543
diff
changeset
|
167 |
if drive_attributes.status == "DOWN": |
984cec791838
7118599 Unable to install s11u1_03 from DVD to a x86 system
Drew Fisher <drew.fisher@oracle.com>
parents:
1543
diff
changeset
|
168 |
self.logger.debug("disk '%s' is offline" % new_disk.name) |
984cec791838
7118599 Unable to install s11u1_03 from DVD to a x86 system
Drew Fisher <drew.fisher@oracle.com>
parents:
1543
diff
changeset
|
169 |
return None |
984cec791838
7118599 Unable to install s11u1_03 from DVD to a x86 system
Drew Fisher <drew.fisher@oracle.com>
parents:
1543
diff
changeset
|
170 |
|
1682
c992a85ed3d0
7150578 install discovery ignores device path lun numbers
Jesse Butler <jesse.butler@oracle.com>
parents:
1644
diff
changeset
|
171 |
# set the wwn string, including lun if available |
c992a85ed3d0
7150578 install discovery ignores device path lun numbers
Jesse Butler <jesse.butler@oracle.com>
parents:
1644
diff
changeset
|
172 |
wwn = getattr(drive.aliases[0].attributes, "wwn", None) |
c992a85ed3d0
7150578 install discovery ignores device path lun numbers
Jesse Butler <jesse.butler@oracle.com>
parents:
1644
diff
changeset
|
173 |
if wwn is not None: |
c992a85ed3d0
7150578 install discovery ignores device path lun numbers
Jesse Butler <jesse.butler@oracle.com>
parents:
1644
diff
changeset
|
174 |
lun = getattr(drive.aliases[0].attributes, "lun", None) |
c992a85ed3d0
7150578 install discovery ignores device path lun numbers
Jesse Butler <jesse.butler@oracle.com>
parents:
1644
diff
changeset
|
175 |
if lun is not None: |
c992a85ed3d0
7150578 install discovery ignores device path lun numbers
Jesse Butler <jesse.butler@oracle.com>
parents:
1644
diff
changeset
|
176 |
new_disk.wwn = "%s,%d" % (wwn, lun) |
c992a85ed3d0
7150578 install discovery ignores device path lun numbers
Jesse Butler <jesse.butler@oracle.com>
parents:
1644
diff
changeset
|
177 |
else: |
c992a85ed3d0
7150578 install discovery ignores device path lun numbers
Jesse Butler <jesse.butler@oracle.com>
parents:
1644
diff
changeset
|
178 |
new_disk.wwn = wwn |
1536
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
179 |
|
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
180 |
for alias in drive.aliases: |
1543
e23a299d526a
7091282 Installers do not report large-sector-size disks correctly
Drew Fisher <drew.fisher@oracle.com>
parents:
1536
diff
changeset
|
181 |
if drive_media is not None: |
e23a299d526a
7091282 Installers do not report large-sector-size disks correctly
Drew Fisher <drew.fisher@oracle.com>
parents:
1536
diff
changeset
|
182 |
if self.verify_disk_read(alias.name, |
e23a299d526a
7091282 Installers do not report large-sector-size disks correctly
Drew Fisher <drew.fisher@oracle.com>
parents:
1536
diff
changeset
|
183 |
drive_media.attributes.blocksize): |
e23a299d526a
7091282 Installers do not report large-sector-size disks correctly
Drew Fisher <drew.fisher@oracle.com>
parents:
1536
diff
changeset
|
184 |
new_disk.active_ctds.append(alias.name) |
e23a299d526a
7091282 Installers do not report large-sector-size disks correctly
Drew Fisher <drew.fisher@oracle.com>
parents:
1536
diff
changeset
|
185 |
else: |
e23a299d526a
7091282 Installers do not report large-sector-size disks correctly
Drew Fisher <drew.fisher@oracle.com>
parents:
1536
diff
changeset
|
186 |
new_disk.passive_ctds.append(alias.name) |
1536
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
187 |
|
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
188 |
# set the new_disk ctd string |
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
189 |
if new_disk.wwn is None: |
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
190 |
# use the only alias name |
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
191 |
new_disk.ctd = drive.aliases[0].name |
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
192 |
else: |
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
193 |
# use the first active ctd |
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
194 |
new_disk.ctd = new_disk.active_ctds[0] |
1623
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
195 |
|
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
196 |
new_disk.devid = drive.name |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
197 |
new_disk.iscdrom = drive.cdrom |
1134
2f672493c0c0
7043048 TD needs to store/compare disk names with the /pci device notation
Drew Fisher <drew.fisher@oracle.com>
parents:
1133
diff
changeset
|
198 |
new_disk.opath = drive_attributes.opath |
2f672493c0c0
7043048 TD needs to store/compare disk names with the /pci device notation
Drew Fisher <drew.fisher@oracle.com>
parents:
1133
diff
changeset
|
199 |
|
2f672493c0c0
7043048 TD needs to store/compare disk names with the /pci device notation
Drew Fisher <drew.fisher@oracle.com>
parents:
1133
diff
changeset
|
200 |
# set the devpath |
2f672493c0c0
7043048 TD needs to store/compare disk names with the /pci device notation
Drew Fisher <drew.fisher@oracle.com>
parents:
1133
diff
changeset
|
201 |
if os.path.islink(drive_attributes.opath): |
2f672493c0c0
7043048 TD needs to store/compare disk names with the /pci device notation
Drew Fisher <drew.fisher@oracle.com>
parents:
1133
diff
changeset
|
202 |
link = os.readlink(drive_attributes.opath) |
2f672493c0c0
7043048 TD needs to store/compare disk names with the /pci device notation
Drew Fisher <drew.fisher@oracle.com>
parents:
1133
diff
changeset
|
203 |
|
2f672493c0c0
7043048 TD needs to store/compare disk names with the /pci device notation
Drew Fisher <drew.fisher@oracle.com>
parents:
1133
diff
changeset
|
204 |
# clean up the link to get rid of the leading '../../devices/' and |
2f672493c0c0
7043048 TD needs to store/compare disk names with the /pci device notation
Drew Fisher <drew.fisher@oracle.com>
parents:
1133
diff
changeset
|
205 |
# trailing minor name |
2f672493c0c0
7043048 TD needs to store/compare disk names with the /pci device notation
Drew Fisher <drew.fisher@oracle.com>
parents:
1133
diff
changeset
|
206 |
if link.startswith("../../devices") and ":" in link: |
2f672493c0c0
7043048 TD needs to store/compare disk names with the /pci device notation
Drew Fisher <drew.fisher@oracle.com>
parents:
1133
diff
changeset
|
207 |
link = link.partition("../../devices")[2].rpartition(":")[0] |
2f672493c0c0
7043048 TD needs to store/compare disk names with the /pci device notation
Drew Fisher <drew.fisher@oracle.com>
parents:
1133
diff
changeset
|
208 |
new_disk.devpath = link |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
209 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
210 |
# check for SPARC eeprom settings which would interfere with finding |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
211 |
# the boot disk |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
212 |
if self.arch == "sparc": |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
213 |
if not self.sparc_diag_mode: |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
214 |
# check eeprom settings |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
215 |
cmd = [EEPROM, "diag-switch?"] |
1323
7e185ea5a224
7068381 AI doesn't retry to list the iscsi target if the OS Device Name is not available
Drew Fisher <drew.fisher@oracle.com>
parents:
1275
diff
changeset
|
216 |
p = run(cmd) |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
217 |
diag_switch_value = p.stdout.partition("=")[2] |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
218 |
if diag_switch_value.strip().lower() == "true": |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
219 |
# set a variable so we don't check every single disk and |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
220 |
# log a message |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
221 |
self.sparc_diag_mode = True |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
222 |
self.logger.info("Unable to determine bootdisk with " + \ |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
223 |
"diag-switch? eeprom setting set to " + \ |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
224 |
"'true'. Please set diag-switch? " + \ |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
225 |
"to false and reboot the system") |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
226 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
227 |
# check for the bootdisk |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
228 |
if not self.sparc_diag_mode: |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
229 |
if self.is_bootdisk(new_disk.ctd): |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
230 |
new_disk.disk_keyword = DiskKeyword() |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
231 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
232 |
# set vendor information for the drive |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
233 |
new_disk.disk_prop = DiskProp() |
1241
3d4bf09186b2
7060266 snv_167 PV domU install on OVM-222-RC1 fails, "No installation target disks found"
Drew Fisher <drew.fisher@oracle.com>
parents:
1236
diff
changeset
|
234 |
if drive.controllers: |
3d4bf09186b2
7060266 snv_167 PV domU install on OVM-222-RC1 fails, "No installation target disks found"
Drew Fisher <drew.fisher@oracle.com>
parents:
1236
diff
changeset
|
235 |
new_disk.disk_prop.dev_type = drive.controllers[0].attributes.type |
1644
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
236 |
|
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
237 |
# check for any Iscsi object in the DOC. If found, change the |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
238 |
# dev_type from 'scsi' to 'iSCSI' to allow the installers finer |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
239 |
# granularity when choosing these types of LUNs |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
240 |
iscsi_check = self.doc.get_descendants(class_type=Iscsi) |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
241 |
if iscsi_check: |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
242 |
cmd = [ISCSIADM, "list", "target", "-S"] |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
243 |
p = run(cmd) |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
244 |
if new_disk.ctd in p.stdout: |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
245 |
new_disk.disk_prop.dev_type = "iSCSI" |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
246 |
|
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
247 |
new_disk.disk_prop.dev_vendor = drive_attributes.vendor_id |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
248 |
|
1197
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
249 |
# set the alias and receptacle for disks, if possible |
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
250 |
if not new_disk.iscdrom and new_disk.ctd in self.cro_dict: |
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
251 |
new_disk.disk_prop.dev_chassis = self.cro_dict[new_disk.ctd][1] |
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
252 |
new_disk.receptacle = self.cro_dict[new_disk.ctd][2] |
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
253 |
|
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
254 |
# walk the media node to extract partitions and slices |
1218
ead7c7d814c7
7052696 TI install fails with target discovery in snv_167 if there is floppy drive
Drew Fisher <drew.fisher@oracle.com>
parents:
1213
diff
changeset
|
255 |
if drive_media is None: |
ead7c7d814c7
7052696 TI install fails with target discovery in snv_167 if there is floppy drive
Drew Fisher <drew.fisher@oracle.com>
parents:
1213
diff
changeset
|
256 |
# since the drive has no media, we can't determine any attributes |
ead7c7d814c7
7052696 TI install fails with target discovery in snv_167 if there is floppy drive
Drew Fisher <drew.fisher@oracle.com>
parents:
1213
diff
changeset
|
257 |
# about it (geometry, slices, partitions, etc.) so simply return |
ead7c7d814c7
7052696 TI install fails with target discovery in snv_167 if there is floppy drive
Drew Fisher <drew.fisher@oracle.com>
parents:
1213
diff
changeset
|
258 |
# None |
ead7c7d814c7
7052696 TI install fails with target discovery in snv_167 if there is floppy drive
Drew Fisher <drew.fisher@oracle.com>
parents:
1213
diff
changeset
|
259 |
return None |
ead7c7d814c7
7052696 TI install fails with target discovery in snv_167 if there is floppy drive
Drew Fisher <drew.fisher@oracle.com>
parents:
1213
diff
changeset
|
260 |
else: |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
261 |
# store the attributes locally so libdiskmgt doesn't have to keep |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
262 |
# looking them up |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
263 |
drive_media_attributes = drive_media.attributes |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
264 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
265 |
# retrieve the drive's geometry |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
266 |
new_disk = self.set_geometry(drive_media_attributes, new_disk) |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
267 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
268 |
# keep a list of slices already visited so they're not discovered |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
269 |
# again later |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
270 |
visited_slices = [] |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
271 |
|
1623
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
272 |
# if this system is x86 and the drive reports *VTOC* slices but no |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
273 |
# fdisk partitions, don't report any of the slices. This probably |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
274 |
# means there is no label at all on the disk: |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
275 |
# On x86 libdiskmgmt will report slices, but no partitions |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
276 |
# when the disk has no partition table/label at all. |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
277 |
if self.arch == "i386" \ |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
278 |
and drive_media.slices \ |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
279 |
and not drive_media.partitions \ |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
280 |
and new_disk.label != "GPT": |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
281 |
# Unset the erroneous disk label |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
282 |
new_disk._label = None |
1088
d6f83c93a86c
7038486 physical _label_disk() using incorrect logger.
Drew Fisher <drew.fisher@oracle.com>
parents:
1070
diff
changeset
|
283 |
return new_disk |
d6f83c93a86c
7038486 physical _label_disk() using incorrect logger.
Drew Fisher <drew.fisher@oracle.com>
parents:
1070
diff
changeset
|
284 |
|
1623
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
285 |
if new_disk.label == "VTOC": |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
286 |
for partition in drive_media.partitions: |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
287 |
new_partition = self.discover_partition(partition, |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
288 |
drive_media_attributes.blocksize) |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
289 |
|
1623
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
290 |
# add the partition to the disk object |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
291 |
new_disk.insert_children(new_partition) |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
292 |
|
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
293 |
# check for slices associated with this partition |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
294 |
# if found, add them as children |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
295 |
for slc in partition.media.slices: |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
296 |
# discover the slice |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
297 |
new_slice = self.discover_slice(slc, |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
298 |
drive_media_attributes.blocksize) |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
299 |
|
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
300 |
# constrain when a slice is added to the DOC. |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
301 |
# We only want to add a slice when the partition id |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
302 |
# is a Solaris partition (non EFI) |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
303 |
if new_partition.is_solaris: |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
304 |
new_partition.insert_children(new_slice) |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
305 |
|
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
306 |
# keep a record this slice so it's not discovered again |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
307 |
visited_slices.append(slc.name) |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
308 |
|
1623
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
309 |
for slc in drive_media.slices: |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
310 |
# discover the slice if it's not already been found |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
311 |
if slc.name not in visited_slices: |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
312 |
new_slice = self.discover_slice(slc, |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
313 |
drive_media_attributes.blocksize) |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
314 |
new_disk.insert_children(new_slice) |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
315 |
|
1623
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
316 |
# If the disk has a GPT label then the protective MBR |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
317 |
# reported by libdiskmgt should be ignored. The GPT partitions |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
318 |
# are reported by libdiskmgt as "slices", similar to VTOC slices |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
319 |
elif new_disk.label == "GPT": |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
320 |
# EFI/GPT label on disc. Discover GPT partitions. |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
321 |
# libdiskmgt's information about GPT partitions is incomplete |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
322 |
# so use libefi to fill in what is missing. |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
323 |
fh = os.open(new_disk.opath, os.O_RDONLY | os.O_NDELAY) |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
324 |
try: |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
325 |
gptp = efi_read(fh) |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
326 |
try: |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
327 |
for slc in drive_media.slices: |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
328 |
efi_part = gptp.contents.efi_parts[ |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
329 |
slc.attributes.index] |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
330 |
new_gpart = self.discover_gptpartition(slc, |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
331 |
drive_media_attributes.blocksize, |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
332 |
efi_part) |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
333 |
new_disk.insert_children(new_gpart) |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
334 |
finally: |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
335 |
efi_free(gptp) |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
336 |
finally: |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
337 |
os.close(fh) |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
338 |
|
1218
ead7c7d814c7
7052696 TI install fails with target discovery in snv_167 if there is floppy drive
Drew Fisher <drew.fisher@oracle.com>
parents:
1213
diff
changeset
|
339 |
return new_disk |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
340 |
|
1543
e23a299d526a
7091282 Installers do not report large-sector-size disks correctly
Drew Fisher <drew.fisher@oracle.com>
parents:
1536
diff
changeset
|
341 |
def verify_disk_read(self, ctd, blocksize): |
1536
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
342 |
""" |
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
343 |
verify_disk_read() - method to verify a low-level read from the raw ctd |
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
344 |
path. |
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
345 |
""" |
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
346 |
|
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
347 |
raw = "/dev/rdsk/%s" % ctd |
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
348 |
raw2 = raw + "s2" |
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
349 |
# Depending on the label used, we need to check both the raw device and |
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
350 |
# slice 2 to see if the disk can be read. |
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
351 |
for raw_disk in [raw, raw2]: |
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
352 |
fd = None |
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
353 |
try: |
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
354 |
try: |
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
355 |
fd = os.open(raw_disk, os.O_RDONLY | os.O_NDELAY) |
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
356 |
try: |
1543
e23a299d526a
7091282 Installers do not report large-sector-size disks correctly
Drew Fisher <drew.fisher@oracle.com>
parents:
1536
diff
changeset
|
357 |
_none = os.read(fd, blocksize) |
1536
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
358 |
except OSError: |
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
359 |
# the read() call failed |
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
360 |
continue |
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
361 |
else: |
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
362 |
return True |
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
363 |
except OSError: |
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
364 |
# the open() call failed |
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
365 |
continue |
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
366 |
finally: |
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
367 |
if fd is not None: |
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
368 |
os.close(fd) |
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
369 |
return False |
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
370 |
|
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
371 |
def set_geometry(self, dma, new_disk): |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
372 |
""" set_geometry() - method to set the geometry of the Disk DOC object |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
373 |
from the libdiskmgt drive object. |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
374 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
375 |
dma - the drive's media attributes as returned by libdiskmgt |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
376 |
new_disk - Disk DOC object |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
377 |
""" |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
378 |
new_geometry = None |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
379 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
380 |
# If the disk has a GPT label (or no label), ncylinders will be |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
381 |
# None |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
382 |
if dma.ncylinders is None: |
1623
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
383 |
# XXX - libdiskmgt calculation of DM_NACCESSIBLE for GPT disks |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
384 |
# is broken, so we use DM_SIZE since we can access all blocks on |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
385 |
# the disk anyway because we don't need to worry about VTOC |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
386 |
# imposed cylinder alignment on disk size. |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
387 |
# Bugster CR: 7099417 |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
388 |
new_disk.disk_prop.dev_size = Size(str(dma.size) + |
1543
e23a299d526a
7091282 Installers do not report large-sector-size disks correctly
Drew Fisher <drew.fisher@oracle.com>
parents:
1536
diff
changeset
|
389 |
Size.sector_units, |
e23a299d526a
7091282 Installers do not report large-sector-size disks correctly
Drew Fisher <drew.fisher@oracle.com>
parents:
1536
diff
changeset
|
390 |
dma.blocksize) |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
391 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
392 |
# set only the blocksize (not the cylinder size) |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
393 |
new_geometry = DiskGeometry(dma.blocksize, None) |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
394 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
395 |
# set the label of the disk, if possible |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
396 |
if dma.efi: |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
397 |
new_disk.label = "GPT" |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
398 |
new_geometry.efi = True |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
399 |
else: |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
400 |
new_disk.label = "VTOC" |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
401 |
|
1132
d6766742607d
7043031 TD failing to discover volume name(disk.volid), thus AI cannot match disks on volume name
Drew Fisher <drew.fisher@oracle.com>
parents:
1129
diff
changeset
|
402 |
# set the disk's volid |
d6766742607d
7043031 TD failing to discover volume name(disk.volid), thus AI cannot match disks on volume name
Drew Fisher <drew.fisher@oracle.com>
parents:
1129
diff
changeset
|
403 |
new_disk.volid = dma.label |
d6766742607d
7043031 TD failing to discover volume name(disk.volid), thus AI cannot match disks on volume name
Drew Fisher <drew.fisher@oracle.com>
parents:
1129
diff
changeset
|
404 |
|
1146
ff4a15105908
7047609 Geometry settings for x86 VTOC disks is wrong
Drew Fisher <drew.fisher@oracle.com>
parents:
1134
diff
changeset
|
405 |
ncyl = dma.ncylinders |
ff4a15105908
7047609 Geometry settings for x86 VTOC disks is wrong
Drew Fisher <drew.fisher@oracle.com>
parents:
1134
diff
changeset
|
406 |
nhead = dma.nheads |
ff4a15105908
7047609 Geometry settings for x86 VTOC disks is wrong
Drew Fisher <drew.fisher@oracle.com>
parents:
1134
diff
changeset
|
407 |
nsect = dma.nsectors |
1623
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
408 |
new_disk.disk_prop.dev_size = Size(str(dma.naccessible) + |
1543
e23a299d526a
7091282 Installers do not report large-sector-size disks correctly
Drew Fisher <drew.fisher@oracle.com>
parents:
1536
diff
changeset
|
409 |
Size.sector_units, |
e23a299d526a
7091282 Installers do not report large-sector-size disks correctly
Drew Fisher <drew.fisher@oracle.com>
parents:
1536
diff
changeset
|
410 |
dma.blocksize) |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
411 |
new_geometry = DiskGeometry(dma.blocksize, nhead * nsect) |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
412 |
new_geometry.ncyl = ncyl |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
413 |
new_geometry.nheads = nhead |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
414 |
new_geometry.nsectors = nsect |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
415 |
|
1623
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
416 |
new_disk.geometry = new_geometry |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
417 |
return new_disk |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
418 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
419 |
def discover_pseudo(self, controller): |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
420 |
""" discover_psuedo - method to discover pseudo controller information, |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
421 |
usually zvol swap and dump |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
422 |
""" |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
423 |
for drive in controller.drives: |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
424 |
for slc in drive.media.slices: |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
425 |
stats = slc.use_stats |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
426 |
if "used_by" in stats: |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
427 |
if stats["used_name"][0] == "dump": |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
428 |
if slc.name.startswith(ZVOL_PATH): |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
429 |
# remove the /dev/zvol/dsk from the path |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
430 |
self.dump_list.append(slc.name[14:]) |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
431 |
if stats["used_name"][0] == "swap": |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
432 |
if slc.name.startswith(ZVOL_PATH): |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
433 |
# remove the /dev/zvol/dsk from the path |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
434 |
self.swap_list.append(slc.name[14:]) |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
435 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
436 |
def discover_partition(self, partition, blocksize): |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
437 |
""" discover_partition - method to discover a physical disk's |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
438 |
partition layout |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
439 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
440 |
partition - partition object as discovered by ldm |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
441 |
blocksize - blocksize of the disk |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
442 |
""" |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
443 |
# store the attributes locally so libdiskmgt doesn't have to keep |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
444 |
# looking them up |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
445 |
partition_attributes = partition.attributes |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
446 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
447 |
# partition name is ctdp path. Split the string on "p" |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
448 |
root_path, _none, index = partition.name.partition("p") |
1117
ae9a188dcfcc
7043629 Target shadow list should not adjust boundaries on discovered partitions
Drew Fisher <drew.fisher@oracle.com>
parents:
1110
diff
changeset
|
449 |
|
1118
c87a271a3921
7043165 Not possible to tell if a Partition was specified in the XML without a start_sector.
Drew Fisher <drew.fisher@oracle.com>
parents:
1117
diff
changeset
|
450 |
# create a DOC object for this partition. Set validate_children to |
1117
ae9a188dcfcc
7043629 Target shadow list should not adjust boundaries on discovered partitions
Drew Fisher <drew.fisher@oracle.com>
parents:
1110
diff
changeset
|
451 |
# False so the shadow code doesn't adjust the start sector or size for |
ae9a188dcfcc
7043629 Target shadow list should not adjust boundaries on discovered partitions
Drew Fisher <drew.fisher@oracle.com>
parents:
1110
diff
changeset
|
452 |
# any children discovered |
1118
c87a271a3921
7043165 Not possible to tell if a Partition was specified in the XML without a start_sector.
Drew Fisher <drew.fisher@oracle.com>
parents:
1117
diff
changeset
|
453 |
new_partition = Partition(index, validate_children=False) |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
454 |
new_partition.action = "preserve" |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
455 |
new_partition.part_type = partition_attributes.id |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
456 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
457 |
# check the partition's ID to set the partition type correctly |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
458 |
if partition_attributes.id == \ |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
459 |
Partition.name_to_num("Solaris/Linux swap"): |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
460 |
try: |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
461 |
# try to call prtvtoc on slice 2. If it succeeds, this is a |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
462 |
# solaris1 partition. |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
463 |
slice2 = root_path + "s2" |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
464 |
cmd = [PRTVTOC, slice2] |
1323
7e185ea5a224
7068381 AI doesn't retry to list the iscsi target if the OS Device Name is not available
Drew Fisher <drew.fisher@oracle.com>
parents:
1275
diff
changeset
|
465 |
run(cmd, stdout=Popen.DEVNULL) |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
466 |
except CalledProcessError: |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
467 |
# the call to prtvtoc failed which means this partition is |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
468 |
# Linux swap. To be sure, prtvtoc failure might also mean an |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
469 |
# unlabeled Solaris1 partition but we aren't going to worry |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
470 |
# about that for now. Displaying an unlabeled (and therefore |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
471 |
# unused) Solaris1 partition should not have any unforeseen |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
472 |
# consequences in terms of data loss. |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
473 |
new_partition.is_linux_swap = True |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
474 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
475 |
new_partition.size = Size(str(partition_attributes.nsectors) + \ |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
476 |
Size.sector_units, blocksize=blocksize) |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
477 |
new_partition.start_sector = long(partition_attributes.relsect) |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
478 |
new_partition.size_in_sectors = partition_attributes.nsectors |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
479 |
|
1623
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
480 |
# If the partition is an EFI system partition check to see if it |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
481 |
# is PCFS formatted. We only do this on EFI system partitions to save |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
482 |
# time since mounting can be slow. |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
483 |
if new_partition.is_efi_system: |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
484 |
ctdp = partition.name.rsplit('/', 1)[-1] |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
485 |
new_partition._is_pcfs_formatted = self.is_pcfs_formatted(ctdp) |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
486 |
|
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
487 |
return new_partition |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
488 |
|
1623
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
489 |
def discover_gptpartition(self, partition, blocksize, efipart): |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
490 |
""" discover_gptpartition - method to discover a physical disk's GPT |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
491 |
partition layout. |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
492 |
|
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
493 |
# Note that libdiskmgmt terminology treats GPT partitions as slices |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
494 |
# as does the Solaris cXtYdZsN notation |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
495 |
# We shall refer to them as GPT partitions though, like the rest of |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
496 |
# the world does. |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
497 |
partition - object as discovered by ldm |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
498 |
blocksize - blocksize of the disk |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
499 |
efipart - DK_PART EFI cstruct |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
500 |
""" |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
501 |
# store the attributes locally so libdiskmgt doesn't have to keep |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
502 |
# looking them up |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
503 |
gpart_attributes = partition.attributes |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
504 |
|
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
505 |
new_gpart = GPTPartition(str(gpart_attributes.index)) |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
506 |
new_gpart.action = "preserve" |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
507 |
new_gpart.size = Size(str(gpart_attributes.size) + Size.sector_units, |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
508 |
blocksize=blocksize) |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
509 |
new_gpart.start_sector = long(gpart_attributes.start) |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
510 |
new_gpart.size_in_sectors = gpart_attributes.size |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
511 |
|
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
512 |
stats = partition.use_stats |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
513 |
if "used_by" in stats: |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
514 |
new_gpart.in_use = stats |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
515 |
|
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
516 |
# EFI partition type GUID and p_flag not provided by libdiskmgt. Fall |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
517 |
# back on libefi provided DK_PART data. |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
518 |
new_gpart.part_type = '{%s}' % str(efipart.p_guid) |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
519 |
new_gpart.guid = copy.copy(efipart.p_guid) |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
520 |
new_gpart.uguid = copy.copy(efipart.p_uguid) |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
521 |
new_gpart.flag = efipart.p_flag |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
522 |
|
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
523 |
# If the partition is an EFI system partition check to see if it |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
524 |
# is PCFS formatted. We only do this on EFI system partition to save |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
525 |
# time since mounting can be slow. |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
526 |
if new_gpart.is_efi_system: |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
527 |
ctds = partition.name.rsplit('/', 1)[-1] |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
528 |
new_gpart._is_pcfs_formatted = self.is_pcfs_formatted(ctds) |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
529 |
|
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
530 |
return new_gpart |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
531 |
|
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
532 |
def discover_slice(self, slc, blocksize): |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
533 |
""" discover_slices - method to discover a physical disk's slice |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
534 |
layout. |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
535 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
536 |
slc - slice object as discovered by ldm |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
537 |
blocksize - blocksize of the disk |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
538 |
""" |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
539 |
# store the attributes locally so libdiskmgt doesn't have to keep |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
540 |
# looking them up |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
541 |
slc_attributes = slc.attributes |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
542 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
543 |
new_slice = Slice(str(slc_attributes.index)) |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
544 |
new_slice.action = "preserve" |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
545 |
new_slice.tag = slc_attributes.tag |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
546 |
new_slice.flag = slc_attributes.flag |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
547 |
new_slice.size = Size(str(slc_attributes.size) + Size.sector_units, |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
548 |
blocksize=blocksize) |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
549 |
new_slice.start_sector = long(slc_attributes.start) |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
550 |
new_slice.size_in_sectors = slc_attributes.size |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
551 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
552 |
stats = slc.use_stats |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
553 |
if "used_by" in stats: |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
554 |
new_slice.in_use = stats |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
555 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
556 |
return new_slice |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
557 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
558 |
def discover_zpools(self, search_name=""): |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
559 |
""" discover_zpools - method to walk zpool list output to create Zpool |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
560 |
objects. Returns a logical DOC object with all zpools populated. |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
561 |
""" |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
562 |
# create a logical element |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
563 |
logical = Logical("logical") |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
564 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
565 |
# set noswap and nodump to True until a zvol is found otherwise |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
566 |
logical.noswap = True |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
567 |
logical.nodump = True |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
568 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
569 |
# retreive the list of zpools |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
570 |
cmd = [ZPOOL, "list", "-H", "-o", "name"] |
1323
7e185ea5a224
7068381 AI doesn't retry to list the iscsi target if the OS Device Name is not available
Drew Fisher <drew.fisher@oracle.com>
parents:
1275
diff
changeset
|
571 |
p = run(cmd) |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
572 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
573 |
# Get the list of zpools |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
574 |
zpool_list = p.stdout.splitlines() |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
575 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
576 |
# walk the list and populate the DOC |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
577 |
for zpool_name in zpool_list: |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
578 |
# if the user has specified a specific search name, only run |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
579 |
# discovery on that particular pool name |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
580 |
if search_name and zpool_name != search_name: |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
581 |
continue |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
582 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
583 |
self.logger.debug("Populating DOC for zpool: %s", zpool_name) |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
584 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
585 |
# create a new Zpool DOC object and insert it |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
586 |
zpool = Zpool(zpool_name) |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
587 |
zpool.action = "preserve" |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
588 |
logical.insert_children(zpool) |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
589 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
590 |
# check to see if the zpool is the boot pool |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
591 |
cmd = [ZPOOL, "list", "-H", "-o", "bootfs", zpool_name] |
1323
7e185ea5a224
7068381 AI doesn't retry to list the iscsi target if the OS Device Name is not available
Drew Fisher <drew.fisher@oracle.com>
parents:
1275
diff
changeset
|
592 |
p = run(cmd) |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
593 |
if p.stdout.rstrip() != "-": |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
594 |
zpool.is_root = True |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
595 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
596 |
# get the mountpoint of the zpool |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
597 |
cmd = [ZFS, "get", "-H", "-o", "value", "mountpoint", zpool_name] |
1323
7e185ea5a224
7068381 AI doesn't retry to list the iscsi target if the OS Device Name is not available
Drew Fisher <drew.fisher@oracle.com>
parents:
1275
diff
changeset
|
598 |
p = run(cmd) |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
599 |
zpool.mountpoint = p.stdout.strip() |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
600 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
601 |
# set the vdev_mapping on each physical object in the DOC tree for |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
602 |
# this zpool |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
603 |
self.set_vdev_map(zpool) |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
604 |
|
1394
7f92dd7e7416
7077329 Problem with install/textui
Karen Tung <Karen.Tung@oracle.com>
parents:
1372
diff
changeset
|
605 |
# for each zpool, get all of its datasets. Switch to the C locale |
7f92dd7e7416
7077329 Problem with install/textui
Karen Tung <Karen.Tung@oracle.com>
parents:
1372
diff
changeset
|
606 |
# so we don't have issues with LC_NUMERIC settings |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
607 |
cmd = [ZFS, "list", "-r", "-H", "-o", |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
608 |
"name,type,used,mountpoint", zpool_name] |
1394
7f92dd7e7416
7077329 Problem with install/textui
Karen Tung <Karen.Tung@oracle.com>
parents:
1372
diff
changeset
|
609 |
p = run(cmd, env={"LC_ALL": "C"}) |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
610 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
611 |
# walk each dataset and create the appropriate DOC objects for |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
612 |
# each. Skip the first line of list output, as the top level |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
613 |
# dataset (also the dataset with the same name as that of the |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
614 |
# zpool) may have a different mountpoint than the zpool. |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
615 |
for dataset in p.stdout.rstrip().split("\n")[1:]: |
1205
53ccbd18aee3
7049761 cylinder adjustment rounds down and gaps are incorrect
Drew Fisher <drew.fisher@oracle.com>
parents:
1197
diff
changeset
|
616 |
try: |
53ccbd18aee3
7049761 cylinder adjustment rounds down and gaps are incorrect
Drew Fisher <drew.fisher@oracle.com>
parents:
1197
diff
changeset
|
617 |
name, ds_type, ds_size, mountpoint = dataset.split(None, 3) |
53ccbd18aee3
7049761 cylinder adjustment rounds down and gaps are incorrect
Drew Fisher <drew.fisher@oracle.com>
parents:
1197
diff
changeset
|
618 |
except ValueError as err: |
53ccbd18aee3
7049761 cylinder adjustment rounds down and gaps are incorrect
Drew Fisher <drew.fisher@oracle.com>
parents:
1197
diff
changeset
|
619 |
# trap on ValueError so any inconsistencies are captured |
1218
ead7c7d814c7
7052696 TI install fails with target discovery in snv_167 if there is floppy drive
Drew Fisher <drew.fisher@oracle.com>
parents:
1213
diff
changeset
|
620 |
self.logger.debug("Unable to process dataset: %r" % |
1205
53ccbd18aee3
7049761 cylinder adjustment rounds down and gaps are incorrect
Drew Fisher <drew.fisher@oracle.com>
parents:
1197
diff
changeset
|
621 |
dataset) |
53ccbd18aee3
7049761 cylinder adjustment rounds down and gaps are incorrect
Drew Fisher <drew.fisher@oracle.com>
parents:
1197
diff
changeset
|
622 |
self.logger.debug(str(err)) |
53ccbd18aee3
7049761 cylinder adjustment rounds down and gaps are incorrect
Drew Fisher <drew.fisher@oracle.com>
parents:
1197
diff
changeset
|
623 |
continue |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
624 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
625 |
# fix the name field to remove the name of the pool |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
626 |
name = name.partition(zpool_name + "/")[2] |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
627 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
628 |
if ds_type == "filesystem": |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
629 |
obj = Filesystem(name) |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
630 |
obj.mountpoint = mountpoint |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
631 |
elif ds_type == "volume": |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
632 |
obj = Zvol(name) |
1394
7f92dd7e7416
7077329 Problem with install/textui
Karen Tung <Karen.Tung@oracle.com>
parents:
1372
diff
changeset
|
633 |
obj.size = Size(ds_size) |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
634 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
635 |
# check for swap/dump. If there's a match, set the zvol |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
636 |
# 'use' attribute and the noswap/nodump attribute of |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
637 |
# logical. The zpool name needs to be re-attached to the |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
638 |
# zvol name to match what was already parsed |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
639 |
if os.path.join(zpool_name, name) in self.swap_list: |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
640 |
obj.use = "swap" |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
641 |
logical.noswap = False |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
642 |
if os.path.join(zpool_name, name) in self.dump_list: |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
643 |
obj.use = "dump" |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
644 |
logical.nodump = False |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
645 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
646 |
obj.action = "preserve" |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
647 |
zpool.insert_children(obj) |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
648 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
649 |
return logical |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
650 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
651 |
def set_vdev_map(self, zpool): |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
652 |
""" set_vdev_map() - walk the vdev_map to set the zpool's vdev entries |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
653 |
and update existing physical DOC entries with the proper in_zpool and |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
654 |
in_vdev attributes. |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
655 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
656 |
zpool - zpool DOC object |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
657 |
""" |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
658 |
# get the list of Disk DOC objects already inserted |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
659 |
disklist = self.root.get_children(class_type=Disk) |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
660 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
661 |
# get the vdev mappings for this pool |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
662 |
vdev_map = vdevs._get_vdev_mapping(zpool.name) |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
663 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
664 |
for vdev_type, vdev_entries in vdev_map.iteritems(): |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
665 |
in_vdev_label = "%s-%s" % (zpool.name, vdev_type) |
1133
92b5354dba1a
7046012 TD setting redundancy type on discovered Vdev's incorrectly
Drew Fisher <drew.fisher@oracle.com>
parents:
1132
diff
changeset
|
666 |
if vdev_type != "none": |
92b5354dba1a
7046012 TD setting redundancy type on discovered Vdev's incorrectly
Drew Fisher <drew.fisher@oracle.com>
parents:
1132
diff
changeset
|
667 |
redundancy = vdev_type.partition("-")[0] |
92b5354dba1a
7046012 TD setting redundancy type on discovered Vdev's incorrectly
Drew Fisher <drew.fisher@oracle.com>
parents:
1132
diff
changeset
|
668 |
else: |
92b5354dba1a
7046012 TD setting redundancy type on discovered Vdev's incorrectly
Drew Fisher <drew.fisher@oracle.com>
parents:
1132
diff
changeset
|
669 |
redundancy = vdev_type |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
670 |
|
1107
859894cb3839
7041859 TD/TI assumes that a disk with just in_zpool, no in_vdev, belongs in an unspecified vdev
Drew Fisher <drew.fisher@oracle.com>
parents:
1088
diff
changeset
|
671 |
# create a Vdev DOC entry for the vdev_type |
1133
92b5354dba1a
7046012 TD setting redundancy type on discovered Vdev's incorrectly
Drew Fisher <drew.fisher@oracle.com>
parents:
1132
diff
changeset
|
672 |
zpool.add_vdev(in_vdev_label, redundancy) |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
673 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
674 |
for full_entry in vdev_entries: |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
675 |
# remove the device path from the entry |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
676 |
entry = full_entry.rpartition("/dev/dsk/")[2] |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
677 |
|
1623
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
678 |
# try to partition the entry for GPT partitions and |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
679 |
# VTOC slices. |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
680 |
# Both are identified by the letter "s" preceding the index. |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
681 |
(vdev_ctd, vdev_letter, vdev_index) = entry.rpartition("s") |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
682 |
|
1623
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
683 |
# if the entry is not a GPT partition or VTOC slice, |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
684 |
# vdev_letter and index will be empty strings |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
685 |
if not vdev_letter: |
1623
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
686 |
# try to partition the entry for MBR partitions |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
687 |
(vdev_ctd, vdev_letter, vdev_index) = \ |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
688 |
entry.rpartition("p") |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
689 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
690 |
# if the entry is also not a partition skip this entry |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
691 |
if not vdev_letter: |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
692 |
continue |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
693 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
694 |
# walk the disk list looking for a matching ctd |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
695 |
for disk in disklist: |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
696 |
if hasattr(disk, "ctd"): |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
697 |
if disk.ctd == vdev_ctd: |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
698 |
# this disk is a match |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
699 |
if vdev_letter == "s": |
1623
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
700 |
if disk.label == "VTOC": |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
701 |
child_list = disk.get_descendants( |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
702 |
class_type=Slice) |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
703 |
elif disk.label == "GPT": |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
704 |
child_list = disk.get_descendants( |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
705 |
class_type=GPTPartition) |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
706 |
elif vdev_letter == "p": |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
707 |
child_list = disk.get_descendants( |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
708 |
class_type=Partition) |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
709 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
710 |
# walk the child list and look for a matching name |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
711 |
for child in child_list: |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
712 |
if child.name == vdev_index: |
1107
859894cb3839
7041859 TD/TI assumes that a disk with just in_zpool, no in_vdev, belongs in an unspecified vdev
Drew Fisher <drew.fisher@oracle.com>
parents:
1088
diff
changeset
|
713 |
# set the in_zpool and in_vdev attributes |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
714 |
child.in_zpool = zpool.name |
1107
859894cb3839
7041859 TD/TI assumes that a disk with just in_zpool, no in_vdev, belongs in an unspecified vdev
Drew Fisher <drew.fisher@oracle.com>
parents:
1088
diff
changeset
|
715 |
child.in_vdev = in_vdev_label |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
716 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
717 |
# break out of the disklist walk |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
718 |
break |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
719 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
720 |
def discover_BEs(self, zpool_name="", name=None): |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
721 |
""" discover_BEs - method to discover all Boot Environments (BEs) on |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
722 |
the system. |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
723 |
""" |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
724 |
be_list = be.be_list(name) |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
725 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
726 |
# walk each zpool already discovered and add BEs as necessary |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
727 |
for zpool in self.root.get_descendants(class_type=Zpool): |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
728 |
# check to see if we only want a subset of zpools. |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
729 |
if zpool_name and zpool_name != zpool.name: |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
730 |
continue |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
731 |
|
1110
17d2e44bfc3f
7042314 solaris_install.target.be.be_list() should get information about which is the active BE
Drew Fisher <drew.fisher@oracle.com>
parents:
1107
diff
changeset
|
732 |
for be_name, be_pool, root_ds, is_active in be_list: |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
733 |
if be_pool == zpool.name: |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
734 |
zpool.insert_children(BE(be_name)) |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
735 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
736 |
def discover_entire_system(self, add_physical=True): |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
737 |
""" discover_entire_system - populates the root node of the DOC tree |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
738 |
with the entire physical layout of the system. |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
739 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
740 |
add_physical - boolean value to signal if physical targets should be |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
741 |
added to the DOC. |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
742 |
""" |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
743 |
# to find all the drives on the system, first start with the |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
744 |
# controllers |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
745 |
for controller in diskmgt.descriptors_by_type(const.CONTROLLER): |
1629
a8f3ef646806
7157666 There was the I/O error while ran discovery.py on i86pc arch AI Client
Drew Fisher <drew.fisher@oracle.com>
parents:
1623
diff
changeset
|
746 |
# skip USB floppy controllers |
a8f3ef646806
7157666 There was the I/O error while ran discovery.py on i86pc arch AI Client
Drew Fisher <drew.fisher@oracle.com>
parents:
1623
diff
changeset
|
747 |
if controller.floppy_controller: |
a8f3ef646806
7157666 There was the I/O error while ran discovery.py on i86pc arch AI Client
Drew Fisher <drew.fisher@oracle.com>
parents:
1623
diff
changeset
|
748 |
continue |
a8f3ef646806
7157666 There was the I/O error while ran discovery.py on i86pc arch AI Client
Drew Fisher <drew.fisher@oracle.com>
parents:
1623
diff
changeset
|
749 |
|
1642
e27cd6bf7e7b
7162496 auto-install fails in target-discovery on live system with S11u1_14
Drew Fisher <drew.fisher@oracle.com>
parents:
1629
diff
changeset
|
750 |
# trap on the "/pseudo" controller (zvol swap and dump) |
e27cd6bf7e7b
7162496 auto-install fails in target-discovery on live system with S11u1_14
Drew Fisher <drew.fisher@oracle.com>
parents:
1629
diff
changeset
|
751 |
if controller.name == "/pseudo" and add_physical: |
e27cd6bf7e7b
7162496 auto-install fails in target-discovery on live system with S11u1_14
Drew Fisher <drew.fisher@oracle.com>
parents:
1629
diff
changeset
|
752 |
self.discover_pseudo(controller) |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
753 |
else: |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
754 |
# extract every drive on the given controller |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
755 |
for drive in controller.drives: |
1218
ead7c7d814c7
7052696 TI install fails with target discovery in snv_167 if there is floppy drive
Drew Fisher <drew.fisher@oracle.com>
parents:
1213
diff
changeset
|
756 |
# query libdiskmgt for the drive's information |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
757 |
new_disk = self.discover_disk(drive) |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
758 |
|
1241
3d4bf09186b2
7060266 snv_167 PV domU install on OVM-222-RC1 fails, "No installation target disks found"
Drew Fisher <drew.fisher@oracle.com>
parents:
1236
diff
changeset
|
759 |
# skip invalid drives and CDROM drives |
3d4bf09186b2
7060266 snv_167 PV domU install on OVM-222-RC1 fails, "No installation target disks found"
Drew Fisher <drew.fisher@oracle.com>
parents:
1236
diff
changeset
|
760 |
if new_disk is None or new_disk.iscdrom: |
1218
ead7c7d814c7
7052696 TI install fails with target discovery in snv_167 if there is floppy drive
Drew Fisher <drew.fisher@oracle.com>
parents:
1213
diff
changeset
|
761 |
continue |
ead7c7d814c7
7052696 TI install fails with target discovery in snv_167 if there is floppy drive
Drew Fisher <drew.fisher@oracle.com>
parents:
1213
diff
changeset
|
762 |
|
ead7c7d814c7
7052696 TI install fails with target discovery in snv_167 if there is floppy drive
Drew Fisher <drew.fisher@oracle.com>
parents:
1213
diff
changeset
|
763 |
if add_physical: |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
764 |
self.root.insert_children(new_disk) |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
765 |
|
1241
3d4bf09186b2
7060266 snv_167 PV domU install on OVM-222-RC1 fails, "No installation target disks found"
Drew Fisher <drew.fisher@oracle.com>
parents:
1236
diff
changeset
|
766 |
# extract all of the devpaths from all of the drives already inserted |
1273
c4a56398929a
7052475 need to process dataset options from the AI manifest
Darren Kenny <Darren.Kenny@Oracle.COM>
parents:
1241
diff
changeset
|
767 |
devpath_list = [disk.devpath for disk in |
1241
3d4bf09186b2
7060266 snv_167 PV domU install on OVM-222-RC1 fails, "No installation target disks found"
Drew Fisher <drew.fisher@oracle.com>
parents:
1236
diff
changeset
|
768 |
self.root.get_descendants(class_type=Disk)] |
3d4bf09186b2
7060266 snv_167 PV domU install on OVM-222-RC1 fails, "No installation target disks found"
Drew Fisher <drew.fisher@oracle.com>
parents:
1236
diff
changeset
|
769 |
|
3d4bf09186b2
7060266 snv_167 PV domU install on OVM-222-RC1 fails, "No installation target disks found"
Drew Fisher <drew.fisher@oracle.com>
parents:
1236
diff
changeset
|
770 |
# now walk all the drives in the system to make sure we pick up any |
3d4bf09186b2
7060266 snv_167 PV domU install on OVM-222-RC1 fails, "No installation target disks found"
Drew Fisher <drew.fisher@oracle.com>
parents:
1236
diff
changeset
|
771 |
# disks which have no controller (OVM Xen disks) |
1644
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
772 |
self.logger.debug("Adding drives without controllers to the DOC") |
1241
3d4bf09186b2
7060266 snv_167 PV domU install on OVM-222-RC1 fails, "No installation target disks found"
Drew Fisher <drew.fisher@oracle.com>
parents:
1236
diff
changeset
|
773 |
for drive in diskmgt.descriptors_by_type(const.DRIVE): |
1644
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
774 |
# skip drives that have controllers. They would have already been |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
775 |
# discovered above. |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
776 |
if drive.controllers: |
1629
a8f3ef646806
7157666 There was the I/O error while ran discovery.py on i86pc arch AI Client
Drew Fisher <drew.fisher@oracle.com>
parents:
1623
diff
changeset
|
777 |
continue |
1644
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
778 |
|
1629
a8f3ef646806
7157666 There was the I/O error while ran discovery.py on i86pc arch AI Client
Drew Fisher <drew.fisher@oracle.com>
parents:
1623
diff
changeset
|
779 |
# skip any drive whose opath starts with "/dev/zvol/rdsk" |
1623
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
780 |
if drive.attributes.opath.startswith(ZVOL_RPATH): |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
781 |
continue |
1629
a8f3ef646806
7157666 There was the I/O error while ran discovery.py on i86pc arch AI Client
Drew Fisher <drew.fisher@oracle.com>
parents:
1623
diff
changeset
|
782 |
|
1241
3d4bf09186b2
7060266 snv_167 PV domU install on OVM-222-RC1 fails, "No installation target disks found"
Drew Fisher <drew.fisher@oracle.com>
parents:
1236
diff
changeset
|
783 |
new_disk = self.discover_disk(drive) |
3d4bf09186b2
7060266 snv_167 PV domU install on OVM-222-RC1 fails, "No installation target disks found"
Drew Fisher <drew.fisher@oracle.com>
parents:
1236
diff
changeset
|
784 |
|
3d4bf09186b2
7060266 snv_167 PV domU install on OVM-222-RC1 fails, "No installation target disks found"
Drew Fisher <drew.fisher@oracle.com>
parents:
1236
diff
changeset
|
785 |
# skip invalid drives and CDROM drives |
1407
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
786 |
if new_disk is None or new_disk.iscdrom or new_disk.ctd == "dump": |
1241
3d4bf09186b2
7060266 snv_167 PV domU install on OVM-222-RC1 fails, "No installation target disks found"
Drew Fisher <drew.fisher@oracle.com>
parents:
1236
diff
changeset
|
787 |
continue |
3d4bf09186b2
7060266 snv_167 PV domU install on OVM-222-RC1 fails, "No installation target disks found"
Drew Fisher <drew.fisher@oracle.com>
parents:
1236
diff
changeset
|
788 |
|
3d4bf09186b2
7060266 snv_167 PV domU install on OVM-222-RC1 fails, "No installation target disks found"
Drew Fisher <drew.fisher@oracle.com>
parents:
1236
diff
changeset
|
789 |
# skip any disk we've already discovered |
3d4bf09186b2
7060266 snv_167 PV domU install on OVM-222-RC1 fails, "No installation target disks found"
Drew Fisher <drew.fisher@oracle.com>
parents:
1236
diff
changeset
|
790 |
if new_disk.devpath in devpath_list: |
3d4bf09186b2
7060266 snv_167 PV domU install on OVM-222-RC1 fails, "No installation target disks found"
Drew Fisher <drew.fisher@oracle.com>
parents:
1236
diff
changeset
|
791 |
continue |
3d4bf09186b2
7060266 snv_167 PV domU install on OVM-222-RC1 fails, "No installation target disks found"
Drew Fisher <drew.fisher@oracle.com>
parents:
1236
diff
changeset
|
792 |
|
3d4bf09186b2
7060266 snv_167 PV domU install on OVM-222-RC1 fails, "No installation target disks found"
Drew Fisher <drew.fisher@oracle.com>
parents:
1236
diff
changeset
|
793 |
if add_physical: |
3d4bf09186b2
7060266 snv_167 PV domU install on OVM-222-RC1 fails, "No installation target disks found"
Drew Fisher <drew.fisher@oracle.com>
parents:
1236
diff
changeset
|
794 |
self.root.insert_children(new_disk) |
3d4bf09186b2
7060266 snv_167 PV domU install on OVM-222-RC1 fails, "No installation target disks found"
Drew Fisher <drew.fisher@oracle.com>
parents:
1236
diff
changeset
|
795 |
|
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
796 |
def setup_iscsi(self): |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
797 |
""" set up the iSCSI initiator appropriately (if specified) |
1323
7e185ea5a224
7068381 AI doesn't retry to list the iscsi target if the OS Device Name is not available
Drew Fisher <drew.fisher@oracle.com>
parents:
1275
diff
changeset
|
798 |
such that any physical/logical iSCSI devices can be discovered. |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
799 |
""" |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
800 |
|
1355
7e6507b2a970
6260 sparc AI need a way to mechanism to explicitly ask for creating label on Sparc disk
Drew Fisher <drew.fisher@oracle.com>
parents:
1329
diff
changeset
|
801 |
# pull out all of the iscsi entries from the DOC |
7e6507b2a970
6260 sparc AI need a way to mechanism to explicitly ask for creating label on Sparc disk
Drew Fisher <drew.fisher@oracle.com>
parents:
1329
diff
changeset
|
802 |
iscsi_list = self.doc.get_descendants(class_type=Iscsi) |
7e6507b2a970
6260 sparc AI need a way to mechanism to explicitly ask for creating label on Sparc disk
Drew Fisher <drew.fisher@oracle.com>
parents:
1329
diff
changeset
|
803 |
|
7e6507b2a970
6260 sparc AI need a way to mechanism to explicitly ask for creating label on Sparc disk
Drew Fisher <drew.fisher@oracle.com>
parents:
1329
diff
changeset
|
804 |
# if there's nothing to do, simply return |
7e6507b2a970
6260 sparc AI need a way to mechanism to explicitly ask for creating label on Sparc disk
Drew Fisher <drew.fisher@oracle.com>
parents:
1329
diff
changeset
|
805 |
if not iscsi_list: |
7e6507b2a970
6260 sparc AI need a way to mechanism to explicitly ask for creating label on Sparc disk
Drew Fisher <drew.fisher@oracle.com>
parents:
1329
diff
changeset
|
806 |
return |
7e6507b2a970
6260 sparc AI need a way to mechanism to explicitly ask for creating label on Sparc disk
Drew Fisher <drew.fisher@oracle.com>
parents:
1329
diff
changeset
|
807 |
|
1644
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
808 |
# check each entry in the iscsi_list. If any of them do not have a ctd |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
809 |
# value already, set up the mapping to the LUN. |
1355
7e6507b2a970
6260 sparc AI need a way to mechanism to explicitly ask for creating label on Sparc disk
Drew Fisher <drew.fisher@oracle.com>
parents:
1329
diff
changeset
|
810 |
for iscsi in iscsi_list: |
1644
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
811 |
if not iscsi.ctd_list: |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
812 |
# attempt to connect to the target |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
813 |
try: |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
814 |
iscsi.setup_iscsi() |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
815 |
except (CalledProcessError, RuntimeError): |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
816 |
# remove the iSCSI configuration since it's invalid |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
817 |
iscsi.teardown() |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
818 |
raise |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
819 |
|
1644
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
820 |
# map the iSCSI object back to its parent Disk object for AI. |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
821 |
if isinstance(iscsi.parent, Disk): |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
822 |
iscsi.parent.ctd = iscsi.ctd_list[0] |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
823 |
|
1197
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
824 |
def setup_croinfo(self): |
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
825 |
""" set up a DataObjectDict representing the output from |
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
826 |
/usr/sbin/croinfo |
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
827 |
""" |
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
828 |
cmd = [CROINFO, "-h", "-O", "cAR"] |
1323
7e185ea5a224
7068381 AI doesn't retry to list the iscsi target if the OS Device Name is not available
Drew Fisher <drew.fisher@oracle.com>
parents:
1275
diff
changeset
|
829 |
p = run(cmd) |
1197
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
830 |
|
1213
db03aed1d691
7057173 target discovery loops in finding disk with CUD_GUI and TI
Drew Fisher <drew.fisher@oracle.com>
parents:
1205
diff
changeset
|
831 |
# for systems that do not support CRO, nothing will be returned in |
db03aed1d691
7057173 target discovery loops in finding disk with CUD_GUI and TI
Drew Fisher <drew.fisher@oracle.com>
parents:
1205
diff
changeset
|
832 |
# stdout so simply return. |
db03aed1d691
7057173 target discovery loops in finding disk with CUD_GUI and TI
Drew Fisher <drew.fisher@oracle.com>
parents:
1205
diff
changeset
|
833 |
if not p.stdout: |
db03aed1d691
7057173 target discovery loops in finding disk with CUD_GUI and TI
Drew Fisher <drew.fisher@oracle.com>
parents:
1205
diff
changeset
|
834 |
return |
db03aed1d691
7057173 target discovery loops in finding disk with CUD_GUI and TI
Drew Fisher <drew.fisher@oracle.com>
parents:
1205
diff
changeset
|
835 |
|
1197
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
836 |
# keep a positional counter since we can't use OrderedDicts until 2.7 |
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
837 |
i = 1 |
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
838 |
for line in p.stdout.splitlines(): |
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
839 |
(ctd, alias, receptacle) = line.split(":") |
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
840 |
# skip any entries where the ctd is missing. |
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
841 |
if not ctd: |
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
842 |
continue |
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
843 |
|
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
844 |
self.cro_dict[ctd] = (i, alias or None, receptacle) |
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
845 |
i += 1 |
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
846 |
|
1275
a1022e164e5e
7066493 Target Selection failing on system with CRO output, but no CRO disks.
Darren Kenny <Darren.Kenny@Oracle.COM>
parents:
1273
diff
changeset
|
847 |
if self.cro_dict: |
a1022e164e5e
7066493 Target Selection failing on system with CRO output, but no CRO disks.
Darren Kenny <Darren.Kenny@Oracle.COM>
parents:
1273
diff
changeset
|
848 |
# Only insert if there is something in it |
a1022e164e5e
7066493 Target Selection failing on system with CRO output, but no CRO disks.
Darren Kenny <Darren.Kenny@Oracle.COM>
parents:
1273
diff
changeset
|
849 |
self.doc.persistent.insert_children( |
1323
7e185ea5a224
7068381 AI doesn't retry to list the iscsi target if the OS Device Name is not available
Drew Fisher <drew.fisher@oracle.com>
parents:
1275
diff
changeset
|
850 |
DataObjectDict(CRO_LABEL, self.cro_dict, |
1275
a1022e164e5e
7066493 Target Selection failing on system with CRO output, but no CRO disks.
Darren Kenny <Darren.Kenny@Oracle.COM>
parents:
1273
diff
changeset
|
851 |
generate_xml=True)) |
1197
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
852 |
|
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
853 |
def execute(self, dry_run=False): |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
854 |
""" primary execution checkpoint for Target Discovery |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
855 |
""" |
1355
7e6507b2a970
6260 sparc AI need a way to mechanism to explicitly ask for creating label on Sparc disk
Drew Fisher <drew.fisher@oracle.com>
parents:
1329
diff
changeset
|
856 |
self.dry_run = dry_run |
7e6507b2a970
6260 sparc AI need a way to mechanism to explicitly ask for creating label on Sparc disk
Drew Fisher <drew.fisher@oracle.com>
parents:
1329
diff
changeset
|
857 |
|
1644
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
858 |
# look to see if the persistent tree already has a DISCOVERED Target |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
859 |
# node. |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
860 |
discovered = \ |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
861 |
self.doc.persistent.get_descendants(name=Target.DISCOVERED) |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
862 |
|
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
863 |
if discovered: |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
864 |
# target discovery has already run once. Before continuing to run |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
865 |
# it again, force libdiskmgt to rebuild its cache. |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
866 |
self.logger.debug("Found existing Target.DISCOVERED object. " |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
867 |
"Forcing libdiskmgt to refresh its cache.") |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
868 |
diskmgt.cache_update() |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
869 |
|
1197
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
870 |
# setup croinfo mappings |
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
871 |
self.setup_croinfo() |
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
872 |
|
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
873 |
# setup iSCSI so that all iSCSI physical and logical devices can be |
41dc6c86a4c3
7020411 support in TD/TI for interfaces that provide CRO information in libdevinfo
Drew Fisher <drew.fisher@oracle.com>
parents:
1151
diff
changeset
|
874 |
# discovered |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
875 |
self.setup_iscsi() |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
876 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
877 |
# check to see if the user specified a search_type |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
878 |
if self.search_type == DISK_SEARCH_NAME: |
1644
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
879 |
if isinstance(self.search_name, list): |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
880 |
for name in self.search_name: |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
881 |
drive = retrieve_drive(name) |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
882 |
new_disk = self.discover_disk(drive) |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
883 |
if new_disk is not None: |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
884 |
self.root.insert_children(new_disk) |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
885 |
else: |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
886 |
drive = retrieve_drive(self.search_name) |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
887 |
new_disk = self.discover_disk(drive) |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
888 |
if new_disk is not None: |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
889 |
self.root.insert_children(new_disk) |
1070
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
890 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
891 |
elif self.search_type == ZPOOL_SEARCH_NAME: |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
892 |
self.discover_entire_system(add_physical=False) |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
893 |
self.root.insert_children(self.discover_zpools( |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
894 |
self.search_name)) |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
895 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
896 |
# Add all Boot Environments that are contained in this zpool |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
897 |
self.discover_BEs(self.search_name) |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
898 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
899 |
else: |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
900 |
self.discover_entire_system() |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
901 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
902 |
# Add the discovered zpool objects |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
903 |
self.root.insert_children(self.discover_zpools()) |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
904 |
|
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
905 |
# Add all Boot Environments |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
906 |
self.discover_BEs() |
ef77609251f5
7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
907 |
|
1644
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
908 |
# If this is the first run of discovery, simply insert the entire root |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
909 |
if not discovered: |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
910 |
self.doc.persistent.insert_children(self.root) |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
911 |
else: |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
912 |
# take the first (and only) entry in the list and add each new |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
913 |
# child object to the existing discovered tree |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
914 |
discovered = discovered[0] |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
915 |
for child in self.root.children: |
e827d1934114
PSARC/2012/023 Interactive Installation to iSCSI
Drew Fisher <drew.fisher@oracle.com>
parents:
1642
diff
changeset
|
916 |
discovered.insert_children(child) |
1407
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
917 |
|
1623
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
918 |
def is_pcfs_formatted(self, ctdn): |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
919 |
""" is_pcfs_formatted() Return a Boolean value of True if the GPT |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
920 |
partition guid is already formatted with a pcfs filesystem. |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
921 |
|
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
922 |
This test is useful in conjuction with the is_efi_system property to |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
923 |
determine if an existing EFI system partition can be reused to store |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
924 |
the Solaris UEFI boot program. If False, a format using mkfs on the |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
925 |
partition would be required. |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
926 |
""" |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
927 |
|
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
928 |
dev_dsk = "/dev/dsk/%s" % ctdn |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
929 |
if os.path.exists(dev_dsk) is False: |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
930 |
raise RuntimeError("No such block device exists: %s" % dev_dsk) |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
931 |
|
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
932 |
# Check to see if it's mounted first. If it is we can look at the |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
933 |
# fstype it is mounted with. |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
934 |
mntmatch = None |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
935 |
try: |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
936 |
mnttab_open() |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
937 |
mntmatch = getmntany(mnt_special=dev_dsk) |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
938 |
finally: |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
939 |
mnttab_close() |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
940 |
|
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
941 |
# Mounted |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
942 |
if mntmatch is not None: |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
943 |
if mntmatch.get('mnt_fstype') == 'pcfs': |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
944 |
return True |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
945 |
else: |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
946 |
return False |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
947 |
# Not mounted |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
948 |
else: |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
949 |
# Try to mount with pcfs. This is a much more robust and reliable |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
950 |
# check that the ESP is usable than simply checking with |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
951 |
# fstyp(1M) |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
952 |
mount_point = tempfile.mkdtemp(dir="/system/volatile", |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
953 |
prefix="esp_%s_" % (ctdn)) |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
954 |
try: |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
955 |
mount_cmd = [PCFSMOUNT, dev_dsk, mount_point] |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
956 |
run(mount_cmd) |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
957 |
umount_cmd = [UMOUNT, dev_dsk] |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
958 |
run(umount_cmd) |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
959 |
return True |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
960 |
except CalledProcessError: |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
961 |
return False |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
962 |
finally: |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
963 |
os.rmdir(mount_point) |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
964 |
return False |
1407
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
965 |
|
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
966 |
if __name__ == "__main__": |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
967 |
# if discovery.py is run from the command line, rather than imported as a |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
968 |
# checkpoint, run discovery and print the output. |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
969 |
def parse_args(): |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
970 |
""" parse_args() - function to parse the command line arguments |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
971 |
""" |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
972 |
parser = optparse.OptionParser() |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
973 |
parser.add_option("-d", "--disk", dest="disk", action="store_true", |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
974 |
help="print disk information") |
1623
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
975 |
parser.add_option("-g", "--gptpartition", dest="gptpartition", |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
976 |
action="store_true", |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
977 |
help="print GPT partition information") |
1407
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
978 |
parser.add_option("-p", "--partition", dest="partition", |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
979 |
action="store_true", |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
980 |
help="print partition information") |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
981 |
parser.add_option("-s", "--slice", dest="slc", action="store_true", |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
982 |
help="print slice information") |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
983 |
parser.add_option("-z", "--zpool", dest="zpool", action="store_true", |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
984 |
help="print zpool information") |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
985 |
parser.add_option("--libdiskmgt", dest="libdiskmgt", |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
986 |
action="store_true", |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
987 |
help="print all output from libdiskmgt") |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
988 |
parser.add_option("--xml", dest="xml", action="store_true", |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
989 |
help="print DOC xml") |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
990 |
options, args = parser.parse_args() |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
991 |
|
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
992 |
# only run target discovery if the user requests something out of the |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
993 |
# DOC. If only libdiskmgt output is requested, do not run target |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
994 |
# discovery. |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
995 |
if options.disk or options.partition or options.slc or \ |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
996 |
options.zpool or options.xml: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
997 |
options.require_td = True |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
998 |
else: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
999 |
options.require_td = False |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1000 |
|
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1001 |
return options, args |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1002 |
|
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1003 |
def print_disk(doc): |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1004 |
""" prints the output from the -d argument |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1005 |
""" |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1006 |
print "Disk discovery" |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1007 |
# walk the DOC and print only what the user requested |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1008 |
target = doc.persistent.get_children(class_type=Target)[0] |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1009 |
disk_list = target.get_children(class_type=Disk) |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1010 |
header_format = "%15s | %15s | %15s |" |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1011 |
entry_format = "%15s | %15s | %15.3f |" |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1012 |
print "Total number of disks: %d" % len(disk_list) |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1013 |
print '-' * 53 |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1014 |
print header_format % ("name", "boot disk?", "size [GB]") |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1015 |
print '-' * 53 |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1016 |
for disk in disk_list: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1017 |
if disk.disk_keyword is not None and \ |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1018 |
disk.disk_keyword.key == "boot_disk": |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1019 |
boot = "yes" |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1020 |
else: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1021 |
boot = "no" |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1022 |
print entry_format % (disk.ctd, boot, \ |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1023 |
disk.disk_prop.dev_size.get(Size.gb_units)) |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1024 |
print '-' * 53 |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1025 |
|
1623
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1026 |
def print_gptpartition(doc): |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1027 |
""" prints the output from the -g argument |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1028 |
""" |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1029 |
print "GPT partition discovery" |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1030 |
# walk the DOC and print only what the user requested |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1031 |
target = doc.persistent.get_children(class_type=Target)[0] |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1032 |
disk_list = target.get_children(class_type=Disk) |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1033 |
|
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1034 |
header_format = "{0:>15} | {1:>5} | {2:>40} |" |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1035 |
disk_format = "{0:>15} |" + 7 * " " + "|" + 42 * " " + "|" |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1036 |
entry_format = " " * 16 + "| {0:>5} | {1:>40} |" |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1037 |
|
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1038 |
disk_line = '-' * 67 |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1039 |
entry_line = disk_line + "|" |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1040 |
|
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1041 |
print disk_line |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1042 |
print header_format.format(*["disk name", "index", "in use?"]) |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1043 |
print entry_line |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1044 |
for disk in disk_list: |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1045 |
print disk_format.format(disk.ctd) |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1046 |
gpart_list = disk.get_descendants(class_type=GPTPartition) |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1047 |
for gpart in gpart_list: |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1048 |
if gpart.in_use is None: |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1049 |
in_use = "no" |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1050 |
else: |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1051 |
if "used_by" in gpart.in_use: |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1052 |
in_use = "used by: %s" % gpart.in_use["used_by"][0] |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1053 |
if "used_name" in gpart.in_use: |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1054 |
in_use += " (%s)" % gpart.in_use["used_name"][0] |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1055 |
print entry_format.format(*[gpart.name, in_use]) |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1056 |
print entry_line |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1057 |
|
1407
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1058 |
def print_partition(doc): |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1059 |
""" prints the output from the -p argument |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1060 |
""" |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1061 |
print "Partition discovery" |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1062 |
# walk the DOC and print only what the user requested |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1063 |
target = doc.persistent.get_children(class_type=Target)[0] |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1064 |
disk_list = target.get_children(class_type=Disk) |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1065 |
header_format = "{0:>15} | {1:>5} | {2:>7} | {3:>5} | {4:>11} |" |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1066 |
disk_format = "{0:>15} |" + 39 * " " + "|" |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1067 |
line_format = " " * 16 + "| {0:>5} | {1:>7} | {2:>5} | {3:>11} |" |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1068 |
|
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1069 |
entry_line = '-' * 57 |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1070 |
|
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1071 |
print entry_line |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1072 |
print header_format.format(*["disk_name", "index", "active?", "ID", |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1073 |
"Linux Swap?"]) |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1074 |
print entry_line |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1075 |
for disk in disk_list: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1076 |
print disk_format.format(disk.ctd) |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1077 |
partition_list = disk.get_children(class_type=Partition) |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1078 |
for partition in partition_list: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1079 |
if partition.bootid == Partition.ACTIVE: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1080 |
active = "yes" |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1081 |
else: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1082 |
active = "no" |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1083 |
|
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1084 |
if partition.is_linux_swap: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1085 |
linux_swap = "yes" |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1086 |
else: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1087 |
linux_swap = "no" |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1088 |
print line_format.format(*[partition.name.split("/")[-1], |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1089 |
active, partition.part_type, |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1090 |
linux_swap]) |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1091 |
print entry_line |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1092 |
|
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1093 |
def print_slice(doc): |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1094 |
""" prints the output from the -s argument |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1095 |
""" |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1096 |
print "Slice discovery" |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1097 |
# walk the DOC and print only what the user requested |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1098 |
target = doc.persistent.get_children(class_type=Target)[0] |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1099 |
disk_list = target.get_children(class_type=Disk) |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1100 |
|
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1101 |
header_format = "{0:>15} | {1:>5} | {2:>40} |" |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1102 |
disk_format = "{0:>15} |" + 7 * " " + "|" + 42 * " " + "|" |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1103 |
entry_format = " " * 16 + "| {0:>5} | {1:>40} |" |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1104 |
|
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1105 |
disk_line = '-' * 67 |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1106 |
entry_line = disk_line + "|" |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1107 |
|
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1108 |
print disk_line |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1109 |
print header_format.format(*["disk name", "index", "in use?"]) |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1110 |
print entry_line |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1111 |
for disk in disk_list: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1112 |
print disk_format.format(disk.ctd) |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1113 |
slice_list = disk.get_descendants(class_type=Slice) |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1114 |
for slc in slice_list: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1115 |
if slc.in_use is None: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1116 |
in_use = "no" |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1117 |
else: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1118 |
if "used_by" in slc.in_use: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1119 |
in_use = "used by: %s" % slc.in_use["used_by"][0] |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1120 |
if "used_name" in slc.in_use: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1121 |
in_use += " (%s)" % slc.in_use["used_name"][0] |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1122 |
print entry_format.format(*[slc.name, in_use]) |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1123 |
print entry_line |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1124 |
|
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1125 |
def print_zpool(doc): |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1126 |
""" prints the output from the -z argument |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1127 |
""" |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1128 |
print "Zpool discovery" |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1129 |
target = doc.persistent.get_children(class_type=Target)[0] |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1130 |
logical = target.get_children(class_type=Logical)[0] |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1131 |
zpool_list = logical.get_children(class_type=Zpool) |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1132 |
|
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1133 |
print_format = "{0:>10} | {1:>20} | {2:>20} | {3:>7} | {4:>8} |" |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1134 |
|
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1135 |
zpool_line = '-' * 79 |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1136 |
|
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1137 |
print zpool_line |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1138 |
print print_format.format(*["name", "bootfs", "guid", "size", |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1139 |
"capacity"]) |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1140 |
print zpool_line |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1141 |
for zpool in zpool_list: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1142 |
# extract zpool information |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1143 |
cmd = ["/usr/sbin/zpool", "get", "bootfs,guid,size,capacity", |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1144 |
zpool.name] |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1145 |
p = Popen.check_call(cmd, stdout=Popen.STORE, stderr=Popen.STORE) |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1146 |
# strip out just the third column. Exclude the header row and |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1147 |
# trailing newline |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1148 |
(bootfs, guid, size, capacity) = \ |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1149 |
[line.split()[2] for line in p.stdout.split("\n")[1:-1]] |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1150 |
print print_format.format(*[zpool.name, bootfs, guid, size, |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1151 |
capacity]) |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1152 |
print zpool_line |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1153 |
|
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1154 |
def print_libdiskmgt(): |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1155 |
""" prints drive information from the --libdiskmgt argument |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1156 |
""" |
1536
b87779efc2f9
7088826 target discovery needs augmentation to handle aliases, wwn, and active/passive paths
Drew Fisher <drew.fisher@oracle.com>
parents:
1477
diff
changeset
|
1157 |
|
1407
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1158 |
def indent_str(level, string): |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1159 |
""" function to print an indented string |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1160 |
""" |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1161 |
return "\n".join( |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1162 |
[" " * level + line for line in string.splitlines()] |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1163 |
) |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1164 |
|
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1165 |
# start at the bus level |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1166 |
indent = 0 |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1167 |
for bus in diskmgt.descriptors_by_type(const.BUS): |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1168 |
print indent_str(indent, str(bus)) |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1169 |
indent += 1 |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1170 |
for controller in bus.controllers: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1171 |
print indent_str(indent, str(controller)) |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1172 |
indent += 1 |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1173 |
for path in controller.paths: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1174 |
print indent_str(indent, str(path)) |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1175 |
for drive in controller.drives: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1176 |
print indent_str(indent, str(drive)) |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1177 |
indent += 1 |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1178 |
for path in drive.paths: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1179 |
print indent_str(indent, str(path)) |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1180 |
for alias in drive.aliases: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1181 |
print indent_str(indent, str(alias)) |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1182 |
|
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1183 |
media = drive.media |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1184 |
if media is not None: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1185 |
print indent_str(indent, str(media)) |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1186 |
dma = media.attributes |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1187 |
indent += 1 |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1188 |
if dma.efi or dma.fdisk: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1189 |
for part in media.partitions: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1190 |
print indent_str(indent, str(part)) |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1191 |
for slc in media.slices: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1192 |
print indent_str(indent, str(slc)) |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1193 |
indent -= 1 |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1194 |
indent -= 1 |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1195 |
indent -= 1 |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1196 |
indent -= 1 |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1197 |
|
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1198 |
# parse command line arguments |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1199 |
options, args = parse_args() |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1200 |
|
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1201 |
if options.libdiskmgt: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1202 |
print_libdiskmgt() |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1203 |
if not options.require_td: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1204 |
sys.exit() |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1205 |
|
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1206 |
# set up Target Discovery and execute it, finding the entire system |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1207 |
InstallEngine() |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1208 |
TD = TargetDiscovery("Test TD") |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1209 |
|
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1210 |
# set dry_run to True so we don't label any drives on SPARC |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1211 |
TD.execute(dry_run=True) |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1212 |
|
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1213 |
if options.disk: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1214 |
print_disk(TD.doc) |
1623
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1215 |
if options.gptpartition: |
cb56a2fb4925
PSARC 2012/074 UEFI/GRUB2/Large Disk Boot (UGLDB) (Install phase II):
Niall Power <niall.power@oracle.com>
parents:
1558
diff
changeset
|
1216 |
print_gptpartition(TD.doc) |
1407
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1217 |
if options.partition: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1218 |
print_partition(TD.doc) |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1219 |
if options.slc: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1220 |
print_slice(TD.doc) |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1221 |
if options.zpool: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1222 |
print_zpool(TD.doc) |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1223 |
if options.xml: |
233016449e4a
7077874 test_td.py cannot be run in installed environment
Drew Fisher <drew.fisher@oracle.com>
parents:
1396
diff
changeset
|
1224 |
print TD.doc.get_xml_tree_str() |