author | Ethan Quach <Ethan.Quach@sun.com> |
Tue, 31 May 2011 14:21:09 -0700 | |
changeset 1160 | 6f7e708c38ec |
child 1227 | 4ecf733307ad |
permissions | -rw-r--r-- |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
2 |
# |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
3 |
# CDDL HEADER START |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
4 |
# |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
5 |
# The contents of this file are subject to the terms of the |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
6 |
# Common Development and Distribution License (the "License"). |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
7 |
# You may not use this file except in compliance with the License. |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
8 |
# |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
9 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
10 |
# or http://www.opensolaris.org/os/licensing. |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
11 |
# See the License for the specific language governing permissions |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
12 |
# and limitations under the License. |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
13 |
# |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
14 |
# When distributing Covered Code, include this CDDL HEADER in each |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
15 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
16 |
# If applicable, add the following below this CDDL HEADER, with the |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
17 |
# fields enclosed by brackets "[]" replaced with your own identifying |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
18 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
19 |
# |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
20 |
# CDDL HEADER END |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
21 |
# |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
22 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
23 |
# |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
24 |
# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
25 |
# |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
26 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
27 |
""" target_selection_zone.py - Select Install Target(s) |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
28 |
""" |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
29 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
30 |
import copy |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
31 |
import platform |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
32 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
33 |
from solaris_install import ApplicationData |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
34 |
from solaris_install.engine import InstallEngine |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
35 |
from solaris_install.target import Target |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
36 |
from solaris_install.target.controller import DEFAULT_LOGICAL_NAME |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
37 |
from solaris_install.target.instantiation_zone import ALT_POOL_DATASET |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
38 |
from solaris_install.target.logical import Logical, BE, Filesystem |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
39 |
from solaris_install.auto_install.checkpoints.target_selection import \ |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
40 |
TargetSelection, SelectionError |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
41 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
42 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
43 |
class TargetSelectionZone(TargetSelection): |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
44 |
""" TargetSelectionZone - Checkpoint to select install target. |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
45 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
46 |
This checkpoint selects the install target(s) for a zone based on |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
47 |
the information provided as the zone's alternate pool dataset and the |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
48 |
target information provided in the AI Manifest. |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
49 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
50 |
If it's not possible to determine a selection, then a SelectionError |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
51 |
exception will be raised, causing the installation to fail. |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
52 |
""" |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
53 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
54 |
def __init__(self, name, be_mountpoint="/a"): |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
55 |
super(TargetSelection, self).__init__(name) |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
56 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
57 |
# instance attributes |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
58 |
self.be_mountpoint = be_mountpoint |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
59 |
self.doc = InstallEngine.get_instance().data_object_cache |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
60 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
61 |
# set the zone's alternate pool dataset |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
62 |
self.selected_dataset = None |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
63 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
64 |
# set the platform |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
65 |
self.arch = platform.processor() |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
66 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
67 |
def select_targets(self, from_manifest): |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
68 |
'''Logic to select the targets for a zone. |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
69 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
70 |
Given the alternate pool dataset, and the targets from the |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
71 |
manifest, make the selections. |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
72 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
73 |
If no suitable selection can be made, then the SelectionError |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
74 |
exception will be raised. This should only be the cause if the |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
75 |
selected alternate pool dataset does not exist. |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
76 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
77 |
Returns a new set of Targets that can be insterted into the |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
78 |
Data Object Cache for TargetInstantiationZone to use. |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
79 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
80 |
''' |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
81 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
82 |
# The selected alternate pool dataset must be set |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
83 |
if self.selected_dataset is None: |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
84 |
raise SelectionError("No dataset selected as alternate pool " |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
85 |
"dataset.") |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
86 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
87 |
# Verify selected dataset exists |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
88 |
fs = Filesystem(self.selected_dataset) |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
89 |
if not fs.exists: |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
90 |
raise SelectionError("Dataset (%s) does not exist." % \ |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
91 |
self.selected_dataset) |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
92 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
93 |
if from_manifest: |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
94 |
self.logger.debug("from_manifest =\n%s\n" % \ |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
95 |
(str(from_manifest[0]))) |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
96 |
else: |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
97 |
self.logger.debug("from_manifest is empty\n") |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
98 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
99 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
100 |
# Instantiate desired target, logical, and zpool objects. |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
101 |
target = Target(Target.DESIRED) |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
102 |
logical = Logical(DEFAULT_LOGICAL_NAME) |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
103 |
logical.noswap = True |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
104 |
logical.nodump = True |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
105 |
zpool = logical.add_zpool(self.selected_dataset) |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
106 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
107 |
for manifest_target in from_manifest: |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
108 |
# Copy filesystem children into desired zpool |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
109 |
for fs in manifest_target.get_descendants(class_type=Filesystem): |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
110 |
zpool.insert_children(copy.deepcopy(fs)) |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
111 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
112 |
# Copy BE children into desired zpool |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
113 |
for be in manifest_target.get_descendants(class_type=BE): |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
114 |
zpool.insert_children(copy.deepcopy(be)) |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
115 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
116 |
# Check if we have a BE object under zpool. |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
117 |
# If not, create one. |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
118 |
be_list = zpool.get_children(class_type=BE) |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
119 |
if not be_list: |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
120 |
# Instantiate new BE object and insert it into zpool. |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
121 |
be = BE() |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
122 |
zpool.insert_children(be) |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
123 |
else: |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
124 |
# Zpool will have only one BE object. |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
125 |
be = be_list[0] |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
126 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
127 |
# Set BE's mountpoint to the mountpoint we need |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
128 |
# to mount it at to do the installation. |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
129 |
be.mountpoint = self.be_mountpoint |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
130 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
131 |
# Insert desired logical object into the desired target object. |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
132 |
target.insert_children(logical) |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
133 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
134 |
# Insert desired target object into the DOC. |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
135 |
self.doc.persistent.insert_children(target) |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
136 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
137 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
138 |
def parse_doc(self): |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
139 |
""" Method for locating objects in the data object cache (DOC) for |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
140 |
use by the checkpoint. |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
141 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
142 |
Will return a Data Object reference for the Targets from the |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
143 |
manifest. |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
144 |
""" |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
145 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
146 |
from_manifest = self.doc.find_path( |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
147 |
"//[@solaris_install.auto_install.ai_instance.AIInstance?2]" |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
148 |
"//[@solaris_install.target.Target?2]") |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
149 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
150 |
app_data = self.doc.persistent.get_first_child( \ |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
151 |
class_type=ApplicationData) |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
152 |
if app_data: |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
153 |
self.selected_dataset = app_data.data_dict.get(ALT_POOL_DATASET) |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
154 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
155 |
return from_manifest |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
156 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
157 |
# Implement AbstractCheckpoint methods. |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
158 |
def get_progress_estimate(self): |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
159 |
"""Returns an estimate of the time this checkpoint will take |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
160 |
""" |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
161 |
return 3 |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
162 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
163 |
def execute(self, dry_run=False): |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
164 |
""" Primary execution method used by the Checkpoint parent class |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
165 |
to select the targets during an install. |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
166 |
""" |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
167 |
self.logger.debug("=== Executing Target Selection Zone Checkpoint ==") |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
168 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
169 |
from_manifest = self.parse_doc() |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
170 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
diff
changeset
|
171 |
self.select_targets(from_manifest) |