author | Ethan Quach <Ethan.Quach@sun.com> |
Tue, 31 May 2011 14:21:09 -0700 | |
changeset 1160 | 6f7e708c38ec |
parent 1151 | 95413393ef67 |
child 1221 | 31c6d2de5731 |
permissions | -rw-r--r-- |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
1 |
#!/usr/bin/python2.6 |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
2 |
# |
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
3 |
# CDDL HEADER START |
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
4 |
# |
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
5 |
# The contents of this file are subject to the terms of the |
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
6 |
# Common Development and Distribution License (the "License"). |
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
7 |
# You may not use this file except in compliance with the License. |
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
8 |
# |
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
9 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
10 |
# or http://www.opensolaris.org/os/licensing. |
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
11 |
# See the License for the specific language governing permissions |
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
12 |
# and limitations under the License. |
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
13 |
# |
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
14 |
# When distributing Covered Code, include this CDDL HEADER in each |
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
15 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
16 |
# If applicable, add the following below this CDDL HEADER, with the |
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
17 |
# fields enclosed by brackets "[]" replaced with your own identifying |
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
18 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
19 |
# |
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
20 |
# CDDL HEADER END |
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
21 |
# |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
906
diff
changeset
|
22 |
# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
23 |
|
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
24 |
""" |
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
25 |
|
1005
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
26 |
AI publish_manifest |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
27 |
|
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
28 |
""" |
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
29 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
30 |
import errno |
1005
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
31 |
import gettext |
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
32 |
import logging |
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
33 |
import lxml.etree |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
34 |
import os.path |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
35 |
import pwd |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
36 |
import shutil |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
37 |
import StringIO |
1005
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
38 |
import sys |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
39 |
|
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
40 |
from stat import S_IRUSR, S_IWUSR |
625
b9566ecaa511
11933 - AI install issue with nightly build of 10/12 with the fix of 4152.
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
617
diff
changeset
|
41 |
from optparse import OptionParser |
b9566ecaa511
11933 - AI install issue with nightly build of 10/12 with the fix of 4152.
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
617
diff
changeset
|
42 |
|
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
43 |
import osol_install.auto_install.AI_database as AIdb |
625
b9566ecaa511
11933 - AI install issue with nightly build of 10/12 with the fix of 4152.
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
617
diff
changeset
|
44 |
import osol_install.auto_install.verifyXML as verifyXML |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
45 |
|
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
46 |
from osol_install.auto_install.installadm_common import validate_service_name |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
47 |
from osol_install.auto_install.properties import set_default, get_service_info |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
48 |
from solaris_install import _, AI_DATA, KSH93_SHEBANG, PYTHON_SHEBANG |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
49 |
|
523
9abfbbe9b302
4325 Better syntactic treatment of IP and MAC address AI criteria
Jack Schwartz <Jack.A.Schwartz@Sun.COM>
parents:
475
diff
changeset
|
50 |
INFINITY = str(0xFFFFFFFFFFFFFFFF) |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
51 |
IMG_AI_MANIFEST_DTD = "auto_install/ai.dtd" |
1151
95413393ef67
7038120 Update Auto Installer to use CUD
Darren Kenny <Darren.Kenny@Oracle.COM>
parents:
1087
diff
changeset
|
52 |
SYS_AI_MANIFEST_DTD = "/usr/share/install/ai.dtd" |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
53 |
|
677
6d71cbed2556
13518 'installadm add' does not validate against AI schema from the image
Jan Damborsky <jan.damborsky@sun.com>
parents:
670
diff
changeset
|
54 |
IMG_AI_MANIFEST_SCHEMA = "auto_install/ai_manifest.rng" |
523
9abfbbe9b302
4325 Better syntactic treatment of IP and MAC address AI criteria
Jack Schwartz <Jack.A.Schwartz@Sun.COM>
parents:
475
diff
changeset
|
55 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
56 |
# Modes of operation. |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
57 |
DO_ADD = True |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
58 |
DO_UPDATE = False |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
59 |
|
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
60 |
# 0600 for chmod |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
61 |
PERM_OWNER_RW = S_IRUSR + S_IWUSR |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
62 |
|
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
63 |
# Eventually rename functions to convention. |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
64 |
# pylint: disable-msg=C0103 |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
65 |
|
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
66 |
|
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
67 |
def get_add_usage(): |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
68 |
""" |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
69 |
get usage for add-manifest |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
70 |
""" |
1005
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
71 |
return(_( |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
72 |
'add-manifest\t-n|--service <svcname>\n' |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
73 |
'\t\t-f|--file <manifest_file/script file> \n' |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
74 |
'\t\t[-m|--manifest <manifest/script name>]\n' |
1005
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
75 |
'\t\t[-c|--criteria <criteria=value|range> ... | \n' |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
76 |
'\t\t -C|--criteria-file <criteria.xml>] \n' |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
77 |
'\t\t[-d|--default]')) |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
78 |
|
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
906
diff
changeset
|
79 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
80 |
def get_update_usage(): |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
81 |
""" |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
82 |
get usage for update-manifest |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
83 |
""" |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
84 |
return(_( |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
85 |
'update-manifest\t-n|--service <svcname>\n' |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
86 |
'\t\t-f|--file <manifest/script file> \n' |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
87 |
'\t\t-m|--manifest <manifest/script name>')) |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
88 |
|
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
89 |
|
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
90 |
def parse_options(do_add, cmd_options=None): |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
91 |
""" |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
92 |
Parse and validate options |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
93 |
Args: Optional cmd_options, used for unit testing. Otherwise, cmd line |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
94 |
options handled by OptionParser |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
95 |
Returns: the DataFiles object populated and initialized |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
96 |
Raises: The DataFiles initialization of manifest(s) A/I, SC, SMF looks for |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
97 |
many error conditions and, when caught, are flagged to the user |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
98 |
via raising SystemExit exceptions. |
1005
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
99 |
|
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
100 |
""" |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
101 |
if do_add: |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
102 |
usage = '\n' + get_add_usage() |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
103 |
else: |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
104 |
usage = '\n' + get_update_usage() |
1005
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
105 |
parser = OptionParser(usage=usage) |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
106 |
if do_add: |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
107 |
parser.add_option("-c", "--criteria", dest="criteria_c", |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
108 |
action="append", default=[], help=_("Criteria: " |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
109 |
"<-c criteria=value|range> ..."), metavar="CRITERIA") |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
110 |
parser.add_option("-C", "--criteria-file", dest="criteria_file", |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
111 |
default=None, help=_("Path to criteria XML file.")) |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
112 |
parser.add_option("-d", "--default", dest="set_as_default", |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
113 |
default=False, action='store_true', |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
114 |
help=_("Set manifest as default ")) |
1005
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
115 |
parser.add_option("-f", "--file", dest="manifest_path", |
906
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
116 |
default=None, help=_("Path to manifest file ")) |
1005
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
117 |
parser.add_option("-m", "--manifest", dest="manifest_name", |
906
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
118 |
default=None, help=_("Name of manifest")) |
1005
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
119 |
parser.add_option("-n", "--service", dest="service_name", |
906
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
120 |
default=None, help=_("Name of install service.")) |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
121 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
122 |
# Get the parsed options using parse_args(). We know we don't have |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
123 |
# args, so we're just grabbing the first item of the tuple returned. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
124 |
options, args = parser.parse_args(cmd_options) |
1005
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
125 |
|
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
126 |
if len(args): |
1005
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
127 |
parser.error(_("Unexpected argument(s): %s" % args)) |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
128 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
129 |
if not do_add: |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
130 |
options.criteria_file = None |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
131 |
options.criteria_c = None |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
132 |
options.set_as_default = False |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
133 |
|
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
134 |
# options are: |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
135 |
# -c criteria=<value/range> ... (add only) |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
136 |
# -C XML file with criteria specified (add only) |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
137 |
# -d set manifest as default (add only) |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
138 |
# -n service name |
906
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
139 |
# -f path to manifest file |
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
140 |
# -m manifest name |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
141 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
142 |
# check that we got the install service's name and an AI manifest. |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
143 |
if options.manifest_path is None or options.service_name is None: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
144 |
parser.error(_("Missing one or more required options.")) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
145 |
|
1005
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
146 |
logging.debug("options = %s", options) |
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
147 |
|
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
148 |
# validate service name |
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
149 |
try: |
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
150 |
validate_service_name(options.service_name) |
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
151 |
except ValueError as err: |
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
152 |
parser.error(err) |
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
153 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
154 |
criteria_dict = None |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
155 |
if do_add: |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
156 |
# check that we aren't mixing -c and -C |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
157 |
# Note: -c and -C will be accepted for add, not for update. |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
158 |
if options.criteria_c and options.criteria_file: |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
159 |
parser.error(_("Options used are mutually exclusive.")) |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
160 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
161 |
# if we have criteria from cmd line, convert into dictionary |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
162 |
if options.criteria_c: |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
163 |
try: |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
164 |
criteria_dict = criteria_to_dict(options.criteria_c) |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
165 |
except ValueError as err: |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
166 |
parser.error(err) |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
167 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
168 |
elif options.criteria_file: |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
169 |
if not os.path.exists(options.criteria_file): |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
170 |
parser.error(_("Unable to find criteria file: %s") % |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
171 |
options.criteria_file) |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
172 |
|
1075
df96871c232d
16045 SC manifest should not be required to be in an XML comment when using embedded form
William Schumann <william.schumann@sun.com>
parents:
1005
diff
changeset
|
173 |
# get AI service database info |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
174 |
service_dir, dbname, image_path = get_service_info(options.service_name) |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
175 |
try: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
176 |
files = DataFiles(service_dir=service_dir, image_path=image_path, |
1075
df96871c232d
16045 SC manifest should not be required to be in an XML comment when using embedded form
William Schumann <william.schumann@sun.com>
parents:
1005
diff
changeset
|
177 |
database_path=dbname, |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
178 |
manifest_file=options.manifest_path, |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
179 |
manifest_name=options.manifest_name, |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
180 |
criteria_dict=criteria_dict, |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
181 |
criteria_file=options.criteria_file, |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
182 |
service_name=options.service_name, |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
183 |
set_as_default=options.set_as_default) |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
184 |
except (AssertionError, IOError, ValueError) as err: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
185 |
raise SystemExit(err) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
186 |
except (lxml.etree.LxmlError) as err: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
187 |
raise SystemExit(_("Error:\tmanifest error: %s") % err) |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
188 |
|
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
189 |
return(files) |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
190 |
|
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
906
diff
changeset
|
191 |
|
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
192 |
def criteria_to_dict(criteria): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
193 |
""" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
194 |
Convert criteria list into dictionary. This function is intended to be |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
195 |
called by a main function, or the options parser, so it can potentially |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
196 |
raise the SystemExit exception. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
197 |
Args: criteria in list format: [ criteria=value, criteria=value, ... ] |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
198 |
where value can be a: single string value |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
199 |
space-separated string value (list of values) |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
200 |
range (<lower>-<upper>) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
201 |
Returns: dictionary of criteria { criteria: value, criteria: value, ... } |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
202 |
with all keys in lower case, values are case-sensitive. |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
203 |
Raises: ValueError on malformed name=value strings in input list. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
204 |
""" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
205 |
cri_dict = {} |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
206 |
for entry in criteria: |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
207 |
entries = entry.partition("=") |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
208 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
209 |
if entries[1]: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
210 |
if not entries[0]: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
211 |
raise ValueError(_("Missing criteria name in " |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
212 |
"'%s'\n") % entry) |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
213 |
elif entries[0].lower() in cri_dict: |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
214 |
raise ValueError(_("Duplicate criteria: '%s'\n") % |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
215 |
entries[0]) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
216 |
elif not entries[2]: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
217 |
raise ValueError(_("Missing value for criteria " |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
218 |
"'%s'\n") % entries[0]) |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
219 |
cri_dict[entries[0].lower()] = entries[2] |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
220 |
else: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
221 |
raise ValueError(_("Criteria must be of the form " |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
222 |
"<criteria>=<value>\n")) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
223 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
224 |
return cri_dict |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
225 |
|
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
906
diff
changeset
|
226 |
|
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
227 |
def find_colliding_criteria(criteria, db, exclude_manifests=None): |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
228 |
""" |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
229 |
Returns: A dictionary of colliding criteria with keys being manifest name |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
230 |
and instance tuples and values being the DB column names which |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
231 |
collided |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
232 |
Args: criteria - Criteria object holding the criteria that is to be |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
233 |
added/set for a manifest. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
234 |
db - AI_database object for the install service. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
235 |
exclude_manifests -A list of manifest names from DB to ignore. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
236 |
This arg is passed in when we're calling this |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
237 |
function to find criteria collisions for an |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
238 |
already published manifest. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
239 |
Raises: SystemExit if: criteria is not found in database |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
906
diff
changeset
|
240 |
value is not valid for type (integer and |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
906
diff
changeset
|
241 |
hexadecimal checks) |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
242 |
range is improper |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
243 |
""" |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
244 |
class Fields(object): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
245 |
""" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
246 |
Define convenience indexes |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
247 |
""" |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
248 |
# manifest name is row index 0 |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
249 |
MANNAME = 0 |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
250 |
# manifest instance is row index 1 |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
251 |
MANINST = 1 |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
252 |
# criteria is row index 2 (when a single valued criteria) |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
253 |
CRIT = 2 |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
254 |
# minimum criteria is row index 2 (when a range valued criteria) |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
255 |
MINCRIT = 2 |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
256 |
# maximum criteria is row index 3 (when a range valued criteria) |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
257 |
MAXCRIT = 3 |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
258 |
|
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
259 |
# collisions is a dictionary to hold keys of the form (manifest name, |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
260 |
# instance) which will point to a comma-separated string of colliding |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
261 |
# criteria |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
262 |
collisions = dict() |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
263 |
|
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
264 |
# verify each range criteria in the manifest is well formed and collect |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
265 |
# collisions with database entries |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
266 |
for crit in criteria: |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
267 |
# gather this criteria's values from the manifest |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
268 |
man_criterion = criteria[crit] |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
269 |
|
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
270 |
# Determine if this crit is a range criteria or not. |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
271 |
is_range_crit = AIdb.isRangeCriteria(db.getQueue(), crit, |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
272 |
AIdb.MANIFESTS_TABLE) |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
273 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
274 |
# Process "value" criteria here (check if the criteria exists in |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
275 |
# DB, and then find collisions) |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
276 |
if not is_range_crit: |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
277 |
# only check criteria in use in the DB |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
278 |
if crit not in AIdb.getCriteria(db.getQueue(), |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
279 |
onlyUsed=False, strip=False): |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
280 |
raise SystemExit(_("Error:\tCriteria %s is not a " + |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
281 |
"valid criteria!") % crit) |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
282 |
|
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
283 |
# get all values in the database for this criteria (and |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
284 |
# manifest/instance pairs for each value) |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
285 |
db_criteria = AIdb.getSpecificCriteria( |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
906
diff
changeset
|
286 |
db.getQueue(), crit, |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
287 |
provideManNameAndInstance=True, |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
288 |
excludeManifests=exclude_manifests) |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
289 |
|
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
290 |
# will iterate over a list of the form [manName, manInst, crit, |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
291 |
# None] |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
292 |
for row in db_criteria: |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
293 |
# check if a value in the list of values to be added is equal |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
294 |
# to a value in the list of values for this criteria for this |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
295 |
# row |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
296 |
for value in man_criterion: |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
297 |
if AIdb.is_in_list(crit, value, str(row[Fields.CRIT]), |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
298 |
None): |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
299 |
# record manifest name, instance and criteria name |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
300 |
try: |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
301 |
collisions[row[Fields.MANNAME], |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
302 |
row[Fields.MANINST]] += crit + "," |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
303 |
except KeyError: |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
304 |
collisions[row[Fields.MANNAME], |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
305 |
row[Fields.MANINST]] = crit + "," |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
306 |
|
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
307 |
# This is a range criteria. (Check that ranges are valid, that |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
308 |
# "unbounded" gets set to 0/+inf, ensure the criteria exists |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
309 |
# in the DB, then look for collisions.) |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
310 |
else: |
906
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
311 |
# Clean-up NULL's and change "unbounded"s to 0 and |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
312 |
# really large numbers in case this Python does |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
313 |
# not support IEEE754. Note "unbounded"s are already |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
314 |
# converted to lower case during manifest processing. |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
315 |
if man_criterion[0] == "unbounded": |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
316 |
man_criterion[0] = "0" |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
317 |
if man_criterion[1] == "unbounded": |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
318 |
man_criterion[1] = INFINITY |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
319 |
if crit == "mac": |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
320 |
# convert hex mac address (w/o colons) to a number |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
321 |
try: |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
322 |
man_criterion[0] = long(str(man_criterion[0]).upper(), 16) |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
323 |
man_criterion[1] = long(str(man_criterion[1]).upper(), 16) |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
324 |
except ValueError: |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
325 |
raise SystemExit(_("Error:\tCriteria %s " |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
326 |
"is not a valid hexadecimal value") % |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
327 |
crit) |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
328 |
else: |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
329 |
# this is a decimal value |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
330 |
try: |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
331 |
man_criterion = [long(str(man_criterion[0]).upper()), |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
332 |
long(str(man_criterion[1]).upper())] |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
333 |
except ValueError: |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
334 |
raise SystemExit(_("Error:\tCriteria %s " |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
335 |
"is not a valid integer value") % crit) |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
336 |
|
906
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
337 |
# Check for a properly ordered range (with unbounded being 0 or |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
906
diff
changeset
|
338 |
# Inf.) but ensure both are not unbounded. |
906
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
339 |
# Check for: |
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
340 |
# a range of zero to inf -- not a valid range |
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
341 |
# and |
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
342 |
# min > max -- range order reversed |
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
343 |
# |
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
344 |
if (man_criterion[0] == 0 and man_criterion[1] == long(INFINITY)): |
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
345 |
raise SystemExit(_("Error:\tCriteria %s is not a valid range, " |
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
346 |
"MIN and MAX unbounded.") % crit) |
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
347 |
|
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
906
diff
changeset
|
348 |
if ((man_criterion[0] != 0 and |
906
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
349 |
man_criterion[1] != long(INFINITY)) and |
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
350 |
(long(man_criterion[0]) > long(man_criterion[1]))): |
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
351 |
raise SystemExit(_("Error:\tCriteria %s is not a valid range, " |
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
352 |
"MIN > MAX.") % crit) |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
353 |
# check to see that this criteria exists in the database columns |
1075
df96871c232d
16045 SC manifest should not be required to be in an XML comment when using embedded form
William Schumann <william.schumann@sun.com>
parents:
1005
diff
changeset
|
354 |
man_crit = AIdb.getCriteria(db.getQueue(), onlyUsed=False, |
df96871c232d
16045 SC manifest should not be required to be in an XML comment when using embedded form
William Schumann <william.schumann@sun.com>
parents:
1005
diff
changeset
|
355 |
strip=False) |
df96871c232d
16045 SC manifest should not be required to be in an XML comment when using embedded form
William Schumann <william.schumann@sun.com>
parents:
1005
diff
changeset
|
356 |
if 'MIN' + crit not in man_crit and 'MAX' + crit not in man_crit: |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
357 |
raise SystemExit(_("Error:\tCriteria %s is not a " |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
358 |
"valid criteria!") % crit) |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
359 |
db_criteria = AIdb.getSpecificCriteria( |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
360 |
db.getQueue(), 'MIN' + crit, 'MAX' + crit, |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
361 |
provideManNameAndInstance=True, |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
362 |
excludeManifests=exclude_manifests) |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
363 |
|
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
364 |
# will iterate over a list of the form [manName, manInst, mincrit, |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
365 |
# maxcrit] |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
366 |
for row in db_criteria: |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
367 |
# arbitrarily large number in case this Python does |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
368 |
# not support IEEE754 |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
369 |
db_criterion = ["0", INFINITY] |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
370 |
|
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
371 |
# now populate in valid database values (i.e. non-NULL values) |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
372 |
if row[Fields.MINCRIT]: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
373 |
db_criterion[0] = row[Fields.MINCRIT] |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
374 |
if row[Fields.MAXCRIT]: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
375 |
db_criterion[1] = row[Fields.MAXCRIT] |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
376 |
if crit == "mac": |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
377 |
# use a hexadecimal conversion |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
378 |
db_criterion = [long(str(db_criterion[0]), 16), |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
379 |
long(str(db_criterion[1]), 16)] |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
380 |
else: |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
381 |
# these are decimal numbers |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
382 |
db_criterion = [long(str(db_criterion[0])), |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
383 |
long(str(db_criterion[1]))] |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
384 |
|
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
385 |
# these three criteria can determine if there's a range overlap |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
386 |
if((man_criterion[1] >= db_criterion[0] and |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
387 |
db_criterion[1] >= man_criterion[0]) or |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
388 |
man_criterion[0] == db_criterion[1]): |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
389 |
# range overlap so record the collision |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
390 |
try: |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
391 |
collisions[row[Fields.MANNAME], |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
392 |
row[Fields.MANINST]] += "MIN" + crit + "," |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
393 |
collisions[row[Fields.MANNAME], |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
394 |
row[Fields.MANINST]] += "MAX" + crit + "," |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
395 |
except KeyError: |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
396 |
collisions[row[Fields.MANNAME], |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
397 |
row[Fields.MANINST]] = "MIN" + crit + "," |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
398 |
collisions[row[Fields.MANNAME], |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
399 |
row[Fields.MANINST]] += "MAX" + crit + "," |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
400 |
return collisions |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
401 |
|
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
906
diff
changeset
|
402 |
|
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
403 |
def find_colliding_manifests(criteria, db, collisions, append_manifest=None): |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
404 |
""" |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
405 |
For each manifest/instance pair in collisions check that the manifest |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
406 |
criteria diverge (i.e. are not exactly the same) and that the ranges do not |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
407 |
collide for ranges. |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
408 |
Raises if: a range collides, or if the manifest has the same criteria as a |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
409 |
manifest already in the database (SystemExit raised) |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
410 |
Returns: Nothing |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
411 |
Args: criteria - Criteria object holding the criteria that is to be |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
412 |
added/set for a manifest. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
413 |
db - AI_database object for the install service. |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
414 |
collisions - a dictionary with collisions, as produced by |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
415 |
find_colliding_criteria() |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
416 |
append_manifest - name of manifest we're appending criteria to. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
417 |
This arg is passed in when we're calling this |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
418 |
function to find criteria collisions for an |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
419 |
already published manifest that we're appending |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
420 |
criteria to. |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
421 |
""" |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
422 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
423 |
# If we're appending criteria to an already published manifest, get a |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
424 |
# dictionary of the criteria that's already published for that manifest. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
425 |
if append_manifest is not None: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
426 |
published_criteria = AIdb.getManifestCriteria(append_manifest, 0, |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
427 |
db.getQueue(), |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
428 |
humanOutput=True, |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
429 |
onlyUsed=False) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
430 |
|
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
431 |
# check every manifest in collisions to see if manifest collides (either |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
432 |
# identical criteria, or overlaping ranges) |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
433 |
for man_inst in collisions: |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
434 |
# get all criteria from this manifest/instance pair |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
435 |
db_criteria = AIdb.getManifestCriteria(man_inst[0], |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
436 |
man_inst[1], |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
437 |
db.getQueue(), |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
438 |
humanOutput=True, |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
439 |
onlyUsed=False) |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
440 |
|
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
441 |
# iterate over every criteria in the database |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
442 |
for crit in AIdb.getCriteria(db.getQueue(), |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
443 |
onlyUsed=False, strip=False): |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
444 |
|
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
445 |
# Get the criteria name (i.e. no MIN or MAX) |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
446 |
crit_name = crit.replace('MIN', '', 1).replace('MAX', '', 1) |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
447 |
# Set man_criterion to the key of the DB criteria or None |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
448 |
man_criterion = criteria[crit_name] |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
449 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
450 |
if man_criterion and crit.startswith('MIN'): |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
451 |
man_criterion = man_criterion[0] |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
452 |
elif man_criterion and crit.startswith('MAX'): |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
453 |
man_criterion = man_criterion[1] |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
454 |
|
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
455 |
# If man_criterion is still None, and if we're appending criteria |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
456 |
# to an already published manifest, look for criteria in the |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
457 |
# published set of criteria for the manifest we're appending to |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
458 |
# as well, because existing criteria might cause a collision, |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
459 |
# which we need to compare for. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
460 |
if man_criterion is None and append_manifest is not None: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
461 |
man_criterion = published_criteria[str(crit)] |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
462 |
# replace database NULL's with Python None |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
463 |
if man_criterion == '': |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
464 |
man_criterion = None |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
465 |
|
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
466 |
# set the database criteria |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
467 |
if db_criteria[str(crit)] == '': |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
468 |
# replace database NULL's with a Python None |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
469 |
db_criterion = None |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
470 |
else: |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
471 |
db_criterion = db_criteria[str(crit)] |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
472 |
|
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
473 |
# Replace unbounded's in the criteria (i.e. 0/+inf) |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
474 |
# with a Python None. |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
475 |
if isinstance(man_criterion, basestring) and \ |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
476 |
man_criterion == "unbounded": |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
477 |
man_criterion = None |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
478 |
|
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
479 |
# check to determine if this is a range collision by using |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
480 |
# collisions and if not are the manifests divergent |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
481 |
|
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
482 |
if((crit.startswith('MIN') and |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
483 |
collisions[man_inst].find(crit + ",") != -1) or |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
484 |
(crit.startswith('MAX') and |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
485 |
collisions[man_inst].find(crit + ",") != -1) |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
486 |
): |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
487 |
if str(db_criterion).lower() != str(man_criterion).lower(): |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
488 |
raise SystemExit(_("Error:\tManifest has a range " |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
489 |
"collision with manifest:%s/%i" |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
490 |
"\n\tin criteria: %s!") % |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
491 |
(man_inst[0], man_inst[1], |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
492 |
crit.replace('MIN', '', 1). |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
493 |
replace('MAX', '', 1))) |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
494 |
|
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
495 |
# Either the range did not collide or this is not a range |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
496 |
# criteria. (If the value of this criteria in the db does |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
497 |
# not equal the value of this criteria for the set of criteria |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
498 |
# to check, we can break out knowing we diverge for this |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
499 |
# manifest/instance) |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
500 |
elif not db_criterion and not man_criterion: |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
501 |
# Neither the value for this criteria in the db nor |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
502 |
# the value for for this criteria in the given set of |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
503 |
# criteria to check are populated. Loop around to |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
504 |
# check the next criteria. |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
505 |
continue |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
506 |
elif not db_criterion or not man_criterion: |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
507 |
# One of the two are not populated, we can break knowing |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
508 |
# they're different. |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
509 |
break |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
510 |
else: |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
511 |
# Both are populated. If none of values in the list for |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
512 |
# this criteria to be added are equal to any of the values |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
513 |
# in the list for this criteria from the db, there will be |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
514 |
# no collision. We can break out. |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
515 |
if not [value for value in man_criterion if \ |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
516 |
AIdb.is_in_list(crit, value, str(db_criterion), None)]: |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
517 |
break |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
518 |
|
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
519 |
# end of for loop and we never broke out (collision) |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
520 |
else: |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
521 |
raise SystemExit(_("Error:\tManifest has same criteria as " + |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
522 |
"manifest: %s/%i!") % |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
523 |
(man_inst[0], man_inst[1])) |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
524 |
|
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
906
diff
changeset
|
525 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
526 |
def insert_SQL(files): |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
527 |
""" |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
528 |
Ensures all data is properly sanitized and formatted, then inserts it into |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
529 |
the database |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
530 |
Args: None |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
531 |
Returns: None |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
532 |
""" |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
533 |
query = "INSERT INTO manifests VALUES(" |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
534 |
|
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
535 |
# add the manifest name to the query string |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
536 |
query += "'" + AIdb.sanitizeSQL(files.manifest_name) + "'," |
906
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
537 |
# check to see if manifest name is already in database (affects instance |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
538 |
# number) |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
539 |
if AIdb.sanitizeSQL(files.manifest_name) in \ |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
540 |
AIdb.getManNames(files.database.getQueue()): |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
541 |
# database already has this manifest name get the number of |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
542 |
# instances |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
543 |
instance = AIdb.numInstances(AIdb.sanitizeSQL(files.manifest_name), |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
544 |
files.database.getQueue()) |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
545 |
# this a new manifest |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
546 |
else: |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
547 |
instance = 0 |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
548 |
|
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
549 |
# actually add the instance to the query string |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
550 |
query += str(instance) + "," |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
551 |
|
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
552 |
# we need to fill in the criteria or NULLs for each criteria the database |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
553 |
# supports (so iterate over each criteria) |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
554 |
for crit in AIdb.getCriteria(files.database.getQueue(), |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
555 |
onlyUsed=False, strip=False): |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
556 |
# for range values trigger on the MAX criteria (skip the MIN's |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
557 |
# arbitrary as we handle rows in one pass) |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
558 |
if crit.startswith('MIN'): |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
559 |
continue |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
560 |
|
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
561 |
# get the values from the manifest |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
562 |
values = files.criteria[crit.replace('MAX', '', 1)] |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
563 |
|
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
564 |
# If the critera manifest didn't specify this criteria, fill in NULLs |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
565 |
if values is None: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
566 |
# use the criteria name to determine if this is a range |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
567 |
if crit.startswith('MAX'): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
568 |
query += "NULL,NULL," |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
569 |
# this is a single value |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
570 |
else: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
571 |
query += "NULL," |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
572 |
|
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
573 |
# Else if this is a value criteria (not a range), insert the value |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
574 |
# as a space-separated list of values which will account for the case |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
575 |
# where a list of values have been given. |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
576 |
elif not crit.startswith('MAX'): |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
577 |
# Join the values of the list with a space separator. |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
578 |
query += "'" + AIdb.sanitizeSQL(" ".join(values)) + "'," |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
579 |
# else values is a range |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
580 |
else: |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
581 |
for value in values: |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
582 |
# translate "unbounded" to a database NULL |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
583 |
if value == "unbounded": |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
584 |
query += "NULL," |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
585 |
# we need to deal with mac addresses specially being |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
586 |
# hexadecimal |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
587 |
elif crit.endswith("mac"): |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
588 |
# need to insert with hex operand x'<val>' |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
589 |
# use an upper case string for hex values |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
906
diff
changeset
|
590 |
query += "x'" + AIdb.sanitizeSQL(str(value).upper()) + \ |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
906
diff
changeset
|
591 |
"'," |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
592 |
else: |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
593 |
query += AIdb.sanitizeSQL(str(value).upper()) + "," |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
594 |
|
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
595 |
# strip trailing comma and close parentheses |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
596 |
query = query[:-1] + ")" |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
597 |
|
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
598 |
# update the database |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
599 |
query = AIdb.DBrequest(query, commit=True) |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
600 |
files.database.getQueue().put(query) |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
601 |
query.waitAns() |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
602 |
# in case there's an error call the response function (which will print the |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
603 |
# error) |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
604 |
query.getResponse() |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
605 |
|
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
906
diff
changeset
|
606 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
607 |
def _copy_file(source, target): |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
608 |
""" |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
609 |
Copy a file from source to target, and prepare for use by webserver. |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
610 |
""" |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
611 |
# Copy the script. |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
612 |
try: |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
613 |
shutil.copyfile(source, target) |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
614 |
except IOError as err: |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
615 |
raise SystemExit(_("Error:\tUnable to copy script to dest: " |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
616 |
"\n\t%s: %s") % (err.strerror, err.filename)) |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
617 |
|
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
618 |
# change read and write for owner |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
619 |
os.chmod(target, PERM_OWNER_RW) |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
620 |
|
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
621 |
webserver_id = pwd.getpwnam('webservd').pw_uid |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
622 |
# change to user/group webserver/root (uid/gid 0) |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
623 |
os.chown(target, webserver_id, 0) |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
624 |
|
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
906
diff
changeset
|
625 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
626 |
def place_manifest(files): |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
627 |
""" |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
628 |
If manifest does not exist, copies new manifest into place and sets correct |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
629 |
permissions and ownership |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
630 |
Args: files - DataFiles object holding all of the relevant and verified |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
631 |
information for the manifest we're publishing. |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
632 |
Returns: None |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
633 |
Raises : Error, Unable to write destination manifest. |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
634 |
Errors if _copy_file fails. |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
635 |
""" |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
636 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
637 |
if files.manifest_is_script: |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
638 |
root = None |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
639 |
elif files.is_dtd: |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
640 |
root = files.AI_root |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
641 |
else: |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
642 |
root = files.criteria_root |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
643 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
644 |
# Write out the manifest. |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
645 |
if root: |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
646 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
647 |
# Remove all <ai_criteria> elements if they exist. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
648 |
for tag in root.xpath('/ai_criteria_manifest/ai_criteria'): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
649 |
tag.getparent().remove(tag) |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
906
diff
changeset
|
650 |
|
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
651 |
try: |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
652 |
root.write(files.stored_manifest_path, pretty_print=True) |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
653 |
except IOError as err: |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
654 |
raise SystemExit(_("Error:\tUnable to store destination " |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
655 |
"manifest:\n\t%s") % err) |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
656 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
657 |
# change read and write for owner |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
658 |
os.chmod(files.stored_manifest_path, PERM_OWNER_RW) |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
906
diff
changeset
|
659 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
660 |
webserver_id = pwd.getpwnam('webservd').pw_uid |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
661 |
# change to user/group webserver/root (uid/gid 0) |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
662 |
os.chown(files.stored_manifest_path, webserver_id, 0) |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
663 |
|
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
664 |
# "manifest" is a script |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
665 |
else: |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
666 |
_copy_file(files.manifest_path, files.stored_manifest_path) |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
906
diff
changeset
|
667 |
|
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
668 |
|
1075
df96871c232d
16045 SC manifest should not be required to be in an XML comment when using embedded form
William Schumann <william.schumann@sun.com>
parents:
1005
diff
changeset
|
669 |
def verifyCriteria(schema, criteria_path, db, table=AIdb.MANIFESTS_TABLE, |
df96871c232d
16045 SC manifest should not be required to be in an XML comment when using embedded form
William Schumann <william.schumann@sun.com>
parents:
1005
diff
changeset
|
670 |
is_dtd=True): |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
671 |
""" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
672 |
Used for verifying and loading criteria XML from a Criteria manifest, |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
673 |
which can be a combined Criteria manifest (for backwards compatibility |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
674 |
in supporting older install services) or a criteria manifest with just |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
675 |
criteria. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
676 |
Args: schema - path to schema file for criteria manifest. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
677 |
criteria_path - path to criteria XML manifest file to verify. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
678 |
db - database object for install service |
1075
df96871c232d
16045 SC manifest should not be required to be in an XML comment when using embedded form
William Schumann <william.schumann@sun.com>
parents:
1005
diff
changeset
|
679 |
table - database table, distinguishing manifests from profiles |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
680 |
is_dtd - criteria file should contain criteria only, no |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
681 |
AI or SC manifest info |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
682 |
Raises IOError: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
683 |
*if the schema does not open |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
684 |
*if the XML file does not open |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
685 |
Raises ValueError: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
686 |
*if the XML is invalid according to the schema or has a syntax error |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
687 |
Returns: A valid XML DOM of the criteria manifest and all MAC and IPV4 |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
688 |
values are formatted according to |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
689 |
verifyXML.prepValuesAndRanges(). |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
690 |
""" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
691 |
schema = open(schema, 'r') |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
692 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
693 |
# Remove AI and SC elements from within the Criteria manifests if |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
694 |
# they exist. We validate those separately later. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
695 |
try: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
696 |
crit = lxml.etree.parse(criteria_path) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
697 |
except lxml.etree.XMLSyntaxError, err: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
698 |
raise ValueError(_("Error: %s") % err.error_log.last_error) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
699 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
700 |
ai_sc_list = list() |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
701 |
ai_sc_paths = (".//ai_manifest_file", ".//ai_embedded_manifest", |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
702 |
".//sc_manifest_file", ".//sc_embedded_manifest") |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
703 |
for path in ai_sc_paths: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
704 |
elements = crit.iterfind(path) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
705 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
706 |
for elem in elements: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
707 |
if is_dtd: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
708 |
raise ValueError(_("Error:\tCriteria file should not contain " |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
709 |
"AI or SC manifest tags: %s") % |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
710 |
criteria_path) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
711 |
ai_sc_list.append(elem) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
712 |
elem.getparent().remove(elem) |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
713 |
|
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
714 |
# Verify the remaing DOM, which should only contain criteria |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
715 |
root, errors = (verifyXML.verifyRelaxNGManifest(schema, |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
716 |
StringIO.StringIO(lxml.etree.tostring(crit.getroot())))) |
1075
df96871c232d
16045 SC manifest should not be required to be in an XML comment when using embedded form
William Schumann <william.schumann@sun.com>
parents:
1005
diff
changeset
|
717 |
logging.debug('criteria file passed RNG validation') |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
718 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
719 |
if errors: |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
720 |
raise ValueError(_("Error:\tFile %s failed validation:\n" |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
721 |
"\tline %s: %s") % (criteria_path, errors.line, |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
722 |
errors.message)) |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
723 |
try: |
1075
df96871c232d
16045 SC manifest should not be required to be in an XML comment when using embedded form
William Schumann <william.schumann@sun.com>
parents:
1005
diff
changeset
|
724 |
verifyXML.prepValuesAndRanges(root, db, table) |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
725 |
except ValueError, err: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
726 |
raise ValueError(_("Error:\tCriteria manifest error: %s") % err) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
727 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
728 |
# Reinsert AI and SC elements back into the criteria_root DOM. |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
729 |
for ai_sc_element in ai_sc_list: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
730 |
root.getroot().append(ai_sc_element) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
731 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
732 |
return root |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
733 |
|
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
906
diff
changeset
|
734 |
|
1075
df96871c232d
16045 SC manifest should not be required to be in an XML comment when using embedded form
William Schumann <william.schumann@sun.com>
parents:
1005
diff
changeset
|
735 |
def verifyCriteriaDict(schema, criteria_dict, db, table=AIdb.MANIFESTS_TABLE): |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
736 |
""" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
737 |
Used for verifying and loading criteria from a dictionary of criteria. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
738 |
Args: schema - path to schema file for criteria manifest. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
739 |
criteria_dict - dictionary of criteria to verify, in the form |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
740 |
of { criteria: value, criteria: value, ... } |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
741 |
db - database object for install service |
1075
df96871c232d
16045 SC manifest should not be required to be in an XML comment when using embedded form
William Schumann <william.schumann@sun.com>
parents:
1005
diff
changeset
|
742 |
table - database table, distinguishing manifests from profiles |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
743 |
Raises IOError: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
744 |
* if the schema does not open |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
745 |
ValueError: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
746 |
* if the criteria_dict dictionary is empty |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
747 |
* if the XML is invalid according to the schema |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
748 |
AssertionError: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
749 |
* if a value in the dictionary is empty |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
750 |
Returns: A valid XML DOM of the criteria and all MAC and IPV4 values |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
751 |
are formatted according to verifyXML.prepValuesAndRanges(). |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
752 |
""" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
753 |
schema = open(schema, 'r') |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
754 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
755 |
if not criteria_dict: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
756 |
raise ValueError("Error:\tCriteria dictionary empty: %s\n" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
757 |
% criteria_dict) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
758 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
759 |
root = lxml.etree.Element("ai_criteria_manifest") |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
760 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
761 |
for name, value_or_range in criteria_dict.iteritems(): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
762 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
763 |
if value_or_range is None: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
764 |
raise AssertionError(_("Error: Missing value for criteria " |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
765 |
"'%s'") % name) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
766 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
767 |
crit = lxml.etree.SubElement(root, "ai_criteria") |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
768 |
crit.set("name", name) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
769 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
770 |
# If criteria is a range, split on "-" and add to |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
771 |
# XML DOM as a range element. |
1075
df96871c232d
16045 SC manifest should not be required to be in an XML comment when using embedded form
William Schumann <william.schumann@sun.com>
parents:
1005
diff
changeset
|
772 |
if AIdb.isRangeCriteria(db.getQueue(), name, table): |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
773 |
# Split on "-" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
774 |
range_value = value_or_range.split('-', 1) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
775 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
776 |
# If there was only a single value, means user specified |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
777 |
# this range criteria as a single value, add it as a single |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
778 |
# value |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
779 |
if len(range_value) == 1: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
780 |
value_elem = lxml.etree.SubElement(crit, "value") |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
781 |
value_elem.text = value_or_range |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
782 |
else: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
783 |
range_elem = lxml.etree.SubElement(crit, "range") |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
784 |
range_elem.text = " ".join(range_value) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
785 |
else: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
786 |
value_elem = lxml.etree.SubElement(crit, "value") |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
787 |
value_elem.text = value_or_range |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
788 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
789 |
# Verify the generated criteria DOM |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
790 |
root, errors = verifyXML.verifyRelaxNGManifest(schema, |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
791 |
StringIO.StringIO(lxml.etree.tostring(root))) |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
792 |
if errors: |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
793 |
raise ValueError(_("Error: Criteria failed validation:\n\t%s") % |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
794 |
root.message) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
795 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
796 |
try: |
1075
df96871c232d
16045 SC manifest should not be required to be in an XML comment when using embedded form
William Schumann <william.schumann@sun.com>
parents:
1005
diff
changeset
|
797 |
verifyXML.prepValuesAndRanges(root, db, table) |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
798 |
except ValueError, err: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
799 |
raise ValueError(_("Error:\tCriteria error: %s") % err) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
800 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
801 |
return root |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
802 |
|
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
906
diff
changeset
|
803 |
|
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
804 |
# The criteria class is a list object with an overloaded get_item method |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
805 |
# to act like a dictionary, looking up values from an underlying XML DOM. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
806 |
class Criteria(list): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
807 |
""" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
808 |
Wrap list class to provide lookups in the criteria file when requested |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
809 |
""" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
810 |
def __init__(self, criteria_root): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
811 |
# store the criteria manifest DOM root |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
812 |
self._criteria_root = criteria_root |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
813 |
# call the _init_() for the list class with a generator provided by |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
814 |
# find_criteria() to populate this _criteria() instance. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
815 |
super(Criteria, self).__init__(self.find_criteria()) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
816 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
817 |
def find_criteria(self): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
818 |
""" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
819 |
Find criteria from the criteria DOM. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
820 |
Returns: A generator providing all criteria name attributes from |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
821 |
<ai_criteria> tags |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
822 |
""" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
823 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
824 |
if self._criteria_root is None: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
825 |
return |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
826 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
827 |
root = self._criteria_root.findall(".//ai_criteria") |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
828 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
829 |
# actually find criteria |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
830 |
for tag in root: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
831 |
for child in tag.getchildren(): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
832 |
if (child.tag == "range" or child.tag == "value") and \ |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
833 |
child.text is not None: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
834 |
# criteria names are lower case |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
835 |
yield tag.attrib['name'].lower() |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
836 |
else: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
837 |
# should not happen according to schema |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
838 |
raise AssertionError(_("Criteria contains no values")) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
839 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
840 |
def get_criterion(self, criterion): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
841 |
""" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
842 |
Return criterion out of the criteria DOM |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
843 |
Returns: A two-item list for range criterion with a min and max entry |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
844 |
A list of one or more values for value criterion |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
845 |
""" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
846 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
847 |
if self._criteria_root is None: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
848 |
return None |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
849 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
850 |
source = self._criteria_root |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
851 |
for tag in source.getiterator('ai_criteria'): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
852 |
crit = tag.get('name') |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
853 |
# compare criteria name case-insensitive |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
854 |
if crit.lower() == criterion.lower(): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
855 |
for child in tag.getchildren(): |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
856 |
if child.text is not None: |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
857 |
# split on white space for both values and ranges |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
858 |
return child.text.split() |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
859 |
# should not happen according to schema |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
860 |
else: |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
861 |
raise AssertionError(_("Criteria contains no values")) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
862 |
return None |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
863 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
864 |
""" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
865 |
Look up a requested criteria (akin to dictionary access) but for an |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
866 |
uninitialized key will not raise an exception but return None) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
867 |
""" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
868 |
__getitem__ = get_criterion |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
869 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
870 |
# disable trying to update criteria |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
871 |
__setitem__ = None |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
872 |
__delitem__ = None |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
873 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
874 |
|
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
875 |
class DataFiles(object): |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
876 |
""" |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
877 |
Class to contain and work with data files necessary for program |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
878 |
""" |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
879 |
# schema for validating an AI criteria manifest |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
880 |
criteriaSchema = "/usr/share/auto_install/criteria_schema.rng" |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
881 |
# DTD for validating an SMF SC manifest |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
882 |
smfDtd = "/usr/share/lib/xml/dtd/service_bundle.dtd.1" |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
883 |
|
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
884 |
def __init__(self, service_dir=None, image_path=None, |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
885 |
database_path=None, manifest_file=None, |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
886 |
criteria_dict=None, criteria_file=None, manifest_name=None, |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
887 |
service_name=None, set_as_default=False): |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
888 |
|
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
889 |
""" |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
890 |
Initialize DataFiles instance. All parameters optional, however, proper |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
891 |
setup order asurred, if all data provided upon instantiation. |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
892 |
""" |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
893 |
|
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
894 |
# |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
895 |
# State variables |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
896 |
################# |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
897 |
# |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
898 |
|
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
899 |
# Variable to cache criteria class for criteria property |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
900 |
self._criteria_cache = None |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
901 |
|
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
902 |
# Holds path to AI manifest being published (may not be set if an |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
903 |
# embedded manifest) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
904 |
self._manifest = None |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
905 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
906 |
self.criteria_dict = criteria_dict |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
907 |
self.criteria_file = criteria_file |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
908 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
909 |
# Flag to indicate we're operating with the newer AI DTD, |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
910 |
# or with the older AI rng schema |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
911 |
self.is_dtd = True |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
912 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
913 |
# Flag to indicate that the "manifest" is really a script. |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
914 |
# This is to support derived manifests. |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
915 |
self.manifest_is_script = False |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
916 |
|
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
917 |
# Flag to indicate to set the current manifest as the default. |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
918 |
self.set_as_default = set_as_default |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
919 |
|
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
920 |
# Store service name |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
921 |
self.service_name = service_name |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
922 |
|
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
923 |
# |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
924 |
# File system path variables |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
925 |
############################ |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
926 |
# |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
927 |
|
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
928 |
# Check AI Criteria Schema exists |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
929 |
if not os.path.exists(self.criteriaSchema): |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
930 |
raise IOError(_("Error:\tUnable to find criteria_schema: " + |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
931 |
"%s") % self.criteriaSchema) |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
932 |
|
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
933 |
# Check SC manifest SMF DTD exists |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
934 |
if not os.path.exists(self.smfDtd): |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
935 |
raise IOError(_("Error:\tUnable to find SMF system " + |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
936 |
"configuration DTD: %s") % self.smfDtd) |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
937 |
|
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
938 |
# A/I Manifest Schema |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
939 |
self._AIschema = None |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
940 |
|
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
941 |
# Holds path to service directory (i.e. /var/ai/46501) |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
942 |
self._service = None |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
943 |
if service_dir: |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
944 |
self.service = service_dir |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
945 |
|
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
946 |
# Holds path to AI image |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
947 |
self._imagepath = None |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
948 |
if image_path: |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
949 |
self.image_path = image_path |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
950 |
# set the AI schema once image_path is set |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
951 |
self.set_AI_schema() |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
952 |
|
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
953 |
# Holds database object for criteria database |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
954 |
self._db = None |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
955 |
if database_path: |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
956 |
# Set Database Path and Open SQLite3 Object |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
957 |
self.database = database_path |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
958 |
# verify the database's table/column structure (or exit if errors) |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
959 |
self.database.verifyDBStructure() |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
960 |
|
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
961 |
# Holds DOM for criteria manifest |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
962 |
self.criteria_root = None |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
963 |
|
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
964 |
# Determine if we're operating with the newer AI DTD, |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
965 |
# or with the older AI rng schema |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
966 |
try: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
967 |
lxml.etree.DTD(self.AI_schema) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
968 |
self.is_dtd = True |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
969 |
except lxml.etree.DTDParseError: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
970 |
try: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
971 |
lxml.etree.RelaxNG(file=self.AI_schema) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
972 |
self.is_dtd = False |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
973 |
except lxml.etree.RelaxNGParseError: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
974 |
raise ValueError(_("Error: Unable to determine AI manifest " |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
975 |
"validation type.\n")) |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
976 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
977 |
self._manifest_name = manifest_name |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
978 |
self.manifest_is_script = self.manifest_is_a_script(manifest_file) |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
979 |
|
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
980 |
# Bypass XML verification if script passed in instead of a manifest. |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
981 |
if self.manifest_is_script: |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
982 |
self._manifest = manifest_file |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
983 |
|
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
984 |
# Verify the AI manifest to make sure its valid |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
985 |
elif self.is_dtd: |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
986 |
self._manifest = manifest_file |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
987 |
self.verify_AI_manifest() |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
988 |
|
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
989 |
# Holds DOMs for SC manifests |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
990 |
self._smfDict = dict() |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
991 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
992 |
# Look for a SC manifests specified within the manifest file |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
993 |
# sets _smfDict DOMs |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
994 |
self.find_SC_from_manifest(self.AI_root, self.manifest_path) |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
995 |
else: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
996 |
# Holds path for manifest file (if reference to AI manifest URI |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
997 |
# found inside the combined Criteria manifest) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
998 |
self._manifest = None |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
999 |
|
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1000 |
self.criteria_path = manifest_file |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1001 |
self.criteria_root = verifyCriteria(self.criteriaSchema, |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1002 |
self.criteria_path, |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1003 |
self.database, |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1004 |
is_dtd=self.is_dtd) |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1005 |
|
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1006 |
# Holds DOM for AI manifest |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1007 |
self.AI_root = None |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1008 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1009 |
# Since we were provided a combined criteria manifest, look for |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1010 |
# an A/I manifest specified by the criteria manifest |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1011 |
if self.criteria_root: |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1012 |
|
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1013 |
# This will set _manifest to be the AI manifest path (if a |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1014 |
# file), or set AI_root to the correct location in the |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1015 |
# criteria DOM (if embedded), or exit (if unable to find an |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1016 |
# AI manifest) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1017 |
self.find_AI_from_criteria() |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1018 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1019 |
# This will parse _manifest (if it was set from above), load |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1020 |
# it into an XML DOM and set AI_root to it. The AI_root DOM |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1021 |
# will then be verified. The function will exit on error. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1022 |
self.verify_AI_manifest() |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1023 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1024 |
# Holds DOMs for SC manifests |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1025 |
self._smfDict = dict() |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
1026 |
|
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1027 |
# Look for a SC manifests specified within the manifest file |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1028 |
# sets _smfDict DOMs |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1029 |
self.find_SC_from_manifest(self.criteria_root, |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1030 |
self.criteria_path) |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1031 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1032 |
# Process criteria from -c, or -C. This will setup criteria_root |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1033 |
# as a DOM and will overwrite the DOM from criteria found in a |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1034 |
# combined Criteria manifest. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1035 |
if self.criteria_file: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1036 |
self.criteria_path = self.criteria_file |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1037 |
root = verifyCriteria(self.criteriaSchema, self.criteria_path, |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1038 |
self.database, is_dtd=self.is_dtd) |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1039 |
# Set this criteria into criteria_root |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1040 |
self.set_criteria_root(root) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1041 |
elif self.criteria_dict: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1042 |
root = verifyCriteriaDict(self.criteriaSchema, self.criteria_dict, |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1043 |
self.database) |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1044 |
# Set this criteria into criteria_root |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1045 |
self.set_criteria_root(root) |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
1046 |
|
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1047 |
@property |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1048 |
def criteria(self): |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1049 |
""" |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1050 |
Function to provide access to criteria class (and provide caching of |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1051 |
class created) |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1052 |
Returns: A criteria instance |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1053 |
""" |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1054 |
# if we don't have a cached _criteria class, create one and update the |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1055 |
# cache |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1056 |
if not self._criteria_cache: |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1057 |
self._criteria_cache = Criteria(self.criteria_root) |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1058 |
# now return cached _criteria class |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1059 |
return self._criteria_cache |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1060 |
|
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1061 |
def open_database(self, db_file): |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1062 |
""" |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1063 |
Sets self._db (opens database object) and errors if already set or file |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1064 |
does not yet exist |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1065 |
Args: A file path to an SQLite3 database |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1066 |
Raises: SystemExit if path does not exist, |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1067 |
AssertionError if self._db is already set |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1068 |
Returns: Nothing |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1069 |
""" |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1070 |
if not os.path.exists(db_file): |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1071 |
raise SystemExit(_("Error:\tFile %s is not a valid database " |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1072 |
"file") % db_file) |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1073 |
elif self._db is None: |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
1074 |
self._db = AIdb.DB(db_file, commit=True) |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1075 |
else: |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1076 |
raise AssertionError('Opening database when already open!') |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
1077 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
1078 |
def get_database(self): |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1079 |
""" |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1080 |
Returns self._db (database object) and errors if not set |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1081 |
Raises: AssertionError if self._db is not yet set |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1082 |
Returns: SQLite3 database object |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1083 |
""" |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1084 |
if isinstance(self._db, AIdb.DB): |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
906
diff
changeset
|
1085 |
return (self._db) |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1086 |
else: |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1087 |
raise AssertionError('Database not yet open!') |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
1088 |
|
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1089 |
database = property(get_database, open_database, None, |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1090 |
"Holds database object for criteria database") |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1091 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
1092 |
def get_service(self): |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1093 |
""" |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1094 |
Returns self._service and errors if not yet set |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1095 |
Raises: AssertionError if self._service is not yet set |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1096 |
Returns: String object |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1097 |
""" |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1098 |
if self._service is not None: |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1099 |
return(self._service) |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1100 |
else: |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1101 |
raise AssertionError('Service not yet set!') |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
1102 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
1103 |
def set_service(self, serv=None): |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1104 |
""" |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1105 |
Sets self._service and errors if already set |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1106 |
Args: A string path to an AI service directory |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1107 |
Raises: SystemExit if path does not exist, |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1108 |
AssertionError if self._service is already set |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1109 |
Returns: Nothing |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1110 |
""" |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1111 |
if not os.path.isdir(serv): |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1112 |
raise SystemExit(_("Error:\tDirectory %s is not a valid AI " |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1113 |
"directory") % serv) |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1114 |
elif self._service is None: |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1115 |
self._service = os.path.abspath(serv) |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1116 |
else: |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1117 |
raise AssertionError('Setting service when already set!') |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
1118 |
|
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1119 |
service = property(get_service, set_service, None, |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1120 |
"Holds path to service directory (i.e. /var/ai/46501)") |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1121 |
|
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1122 |
def find_SC_from_manifest(self, manifest_root, manifest_path): |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1123 |
""" |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1124 |
Find SC manifests as referenced in the manifest file. We search for |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1125 |
embedded SC manifests first, then do a subsequent search for SC file |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1126 |
references and expand them in-place in the manifest_root DOM, to be |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1127 |
embedded SC manifests. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1128 |
Preconditions: None |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1129 |
Postconditions: self._smfDict will be a dictionary containing all |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1130 |
SC manifest DOMs |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1131 |
Raises: AssertionError: - if manifest_root or manifest_path are not set |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1132 |
- if two SC manifests are named the same |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1133 |
Args: manifest_root - a valid XML DOM of the manifest from which |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1134 |
will find SC manifests. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1135 |
manifest_path - a path to the file from which manifest_root |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1136 |
was created. |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1137 |
Returns: None |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1138 |
""" |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1139 |
root = manifest_root.iterfind(".//sc_embedded_manifest") |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1140 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1141 |
# For each SC manifest embedded: verify it, adding it to the |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1142 |
# dictionary of SMF SC manifests |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1143 |
for SC_man in root: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1144 |
# strip the comments off the SC manifest |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1145 |
xml_data = lxml.etree.tostring(SC_man.getchildren()[0]) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1146 |
xml_data = xml_data.replace("<!-- ", "").replace("-->", "") |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1147 |
xml_data = StringIO.StringIO(xml_data) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1148 |
# parse and read in the SC manifest |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1149 |
self._smfDict[SC_man.attrib['name']] = \ |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1150 |
self.verify_SC_manifest(xml_data, name=SC_man.attrib['name']) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1151 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1152 |
root = manifest_root.iterfind(".//sc_manifest_file") |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1153 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1154 |
# For each SC manifest file: get the URI and verify it, adding it to |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1155 |
# the dictionary of SMF SC manifests (this means we can support a |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1156 |
# manifest file with multiple SC manifests embedded or referenced) |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
1157 |
for SC_man in root: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
1158 |
if SC_man.attrib['name'] in self._smfDict: |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1159 |
raise AssertionError(_("Error:\tTwo SC manifests with name %s") |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1160 |
% SC_man.attrib['name']) |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1161 |
# if this is an absolute path just hand it off |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
1162 |
if os.path.isabs(str(SC_man.attrib['URI'])): |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
1163 |
self._smfDict[SC_man.attrib['name']] = \ |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
1164 |
self.verify_SC_manifest(SC_man.attrib['URI']) |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1165 |
# this is not an absolute path - make it one |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1166 |
else: |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
1167 |
self._smfDict[SC_man.attrib['name']] = \ |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
1168 |
self.verify_SC_manifest(os.path.join(os.path.dirname( |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1169 |
manifest_path), |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
1170 |
SC_man.attrib['URI'])) |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1171 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1172 |
# Replace each SC manifest file element in the manifest root DOM |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1173 |
# with an embedded manifest, using the content from its referenced |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1174 |
# file, which has just been loaded into the _smfDict of SC DOMs. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1175 |
old_sc = self._smfDict[SC_man.attrib['name']] |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1176 |
new_sc = lxml.etree.Element("sc_embedded_manifest") |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1177 |
new_sc.set("name", SC_man.get("name")) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1178 |
new_sc.text = "\n\t" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1179 |
new_sc.tail = "\n" |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
906
diff
changeset
|
1180 |
embedded_sc = lxml.etree.Comment(" <?xml version='%s'?>\n\t" % |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1181 |
old_sc.docinfo.xml_version + |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1182 |
lxml.etree.tostring(old_sc, pretty_print=True, |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1183 |
encoding=unicode, xml_declaration=False)) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1184 |
embedded_sc.tail = "\n" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1185 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1186 |
new_sc.append(embedded_sc) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1187 |
SC_man.getparent().replace(SC_man, new_sc) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1188 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
1189 |
def find_AI_from_criteria(self): |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1190 |
""" |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1191 |
Find AI manifest as referenced or embedded in a criteria manifest. |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1192 |
Preconditions: self.criteria_root is a valid XML DOM |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1193 |
Postconditions: self.manifest_path will be set if using a free-standing |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1194 |
AI manifest otherwise self.AI_root will be set to a |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1195 |
valid XML DOM for the AI manifest |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1196 |
Raises: ValueError for XML processing errors |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1197 |
for no ai_manifest_file specification |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1198 |
AssertionError if criteria_root not set |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1199 |
""" |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1200 |
if self.criteria_root is None: |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1201 |
raise AssertionError(_("Error:\tcriteria_root not set!")) |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1202 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1203 |
# Try to find an embedded AI manifest. |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1204 |
root = self.criteria_root.find(".//ai_embedded_manifest") |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1205 |
if root is not None: |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1206 |
self.AI_root = root.find(".//ai_manifest") |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1207 |
if self.AI_root is not None: |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1208 |
return |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1209 |
else: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1210 |
raise ValueError(_("Error: <ai_embedded_manifest> missing " |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1211 |
"<ai_manifest>")) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1212 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1213 |
# Try to find an AI manifest file reference. |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1214 |
root = self.criteria_root.find(".//ai_manifest_file") |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1215 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1216 |
if root is not None: |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1217 |
try: |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1218 |
if os.path.isabs(root.attrib['URI']): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1219 |
self.manifest_path = root.attrib['URI'] |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1220 |
else: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1221 |
# if we do not have an absolute path try using the criteria |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1222 |
# manifest's location for a base |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1223 |
self.manifest_path = \ |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1224 |
os.path.join(os.path.dirname(self.criteria_path), |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1225 |
root.attrib['URI']) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1226 |
return |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1227 |
except KeyError: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1228 |
raise ValueError(_("Error: <ai_manifest_file> missing URI")) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1229 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1230 |
raise ValueError(_("Error: No <ai_manifest_file> or " |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1231 |
"<ai_embedded_manifest> element in " |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1232 |
"criteria manifest.")) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1233 |
|
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1234 |
@property |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1235 |
def AI_schema(self): |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1236 |
""" |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1237 |
Returns self._AIschema and errors if not yet set |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1238 |
Args: None |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1239 |
Raises: AssertionError if self._AIschema is not yet set |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1240 |
Returns: String object |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1241 |
""" |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1242 |
if self._AIschema is not None: |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1243 |
return (self._AIschema) |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1244 |
else: |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1245 |
raise AssertionError('AIschema not set') |
536
ae182deb9b05
7986 AI should validate manifests against an install image's schema
Ethan Quach <Ethan.Quach@sun.com>
parents:
523
diff
changeset
|
1246 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
1247 |
def set_AI_schema(self): |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1248 |
""" |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1249 |
Sets self._AIschema and errors if imagepath not yet set. |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1250 |
Args: None |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1251 |
Raises: SystemExit if unable to find a valid AI schema |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1252 |
Returns: None |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1253 |
""" |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1254 |
if os.path.exists(os.path.join(self.image_path, |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1255 |
IMG_AI_MANIFEST_DTD)): |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1256 |
self._AIschema = os.path.join(self.image_path, |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1257 |
IMG_AI_MANIFEST_DTD) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1258 |
elif os.path.exists(os.path.join(self.image_path, |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1259 |
IMG_AI_MANIFEST_SCHEMA)): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1260 |
self._AIschema = os.path.join(self.image_path, |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1261 |
IMG_AI_MANIFEST_SCHEMA) |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1262 |
else: |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1263 |
if os.path.exists(SYS_AI_MANIFEST_DTD): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1264 |
self._AIschema = SYS_AI_MANIFEST_DTD |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1265 |
print (_("Warning: Using AI manifest dtd <%s>\n") % |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1266 |
self._AIschema) |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1267 |
else: |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1268 |
raise SystemExit(_("Error:\tUnable to find an AI dtd!")) |
536
ae182deb9b05
7986 AI should validate manifests against an install image's schema
Ethan Quach <Ethan.Quach@sun.com>
parents:
523
diff
changeset
|
1269 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
1270 |
def get_image_path(self): |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1271 |
""" |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1272 |
Returns self._imagepath and errors if not set |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1273 |
Raises: AssertionError if self._imagepath is not yet set |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1274 |
Returns: String object |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1275 |
""" |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1276 |
if self._imagepath is not None: |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1277 |
return (self._imagepath) |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1278 |
else: |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1279 |
raise AssertionError('Imagepath not set') |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1280 |
|
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1281 |
def set_image_path(self, imagepath): |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1282 |
""" |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1283 |
Sets self._imagepath but exits if already set or not a directory |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1284 |
Args: image path to a valid AI image |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1285 |
Raises: SystemExit if image path provided is not a directory |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1286 |
AssertionError if image path is already set |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1287 |
Returns: None |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1288 |
""" |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1289 |
if not os.path.isdir(imagepath): |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1290 |
raise SystemExit(_("Error:\tInvalid imagepath " + |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1291 |
"directory: %s") % imagepath) |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1292 |
if self._imagepath is None: |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1293 |
self._imagepath = os.path.abspath(imagepath) |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1294 |
else: |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1295 |
raise AssertionError('imagepath already set') |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1296 |
|
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1297 |
image_path = property(get_image_path, set_image_path, None, |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1298 |
"Holds path to service's AI image") |
536
ae182deb9b05
7986 AI should validate manifests against an install image's schema
Ethan Quach <Ethan.Quach@sun.com>
parents:
523
diff
changeset
|
1299 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
1300 |
def get_manifest_path(self): |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1301 |
""" |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1302 |
Returns self._manifest and errors if not set |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1303 |
Raises: AssertionError if self._manifest is not yet set |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1304 |
Returns: String object path to AI manifest |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1305 |
""" |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1306 |
if self._manifest is not None: |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1307 |
return(self._manifest) |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1308 |
else: |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1309 |
raise AssertionError('Manifest path not yet set!') |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
1310 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
1311 |
def set_manifest_path(self, mani=None): |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1312 |
""" |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1313 |
Sets self._manifest and errors if already set |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1314 |
Args: path to an AI manifest |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1315 |
Raises: AssertionError if manifest is already set |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1316 |
Returns: None |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1317 |
""" |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1318 |
if self._manifest is None: |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1319 |
self._manifest = os.path.abspath(mani) |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1320 |
else: |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1321 |
raise AssertionError('Setting manifest when already set!') |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
1322 |
|
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1323 |
manifest_path = property(get_manifest_path, set_manifest_path, None, |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1324 |
"Holds path to AI manifest being published") |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
906
diff
changeset
|
1325 |
|
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1326 |
@property |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
1327 |
def manifest_name(self): |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1328 |
""" |
906
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
1329 |
Returns: name if passed on command line, manifest name if defined |
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
1330 |
in the AI manifest, otherwise defaults to name of file |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
906
diff
changeset
|
1331 |
Raises: SystemExit if neither <ai_manifest> or <auto_install> |
906
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
1332 |
can be found or if there is another problem identifying |
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
1333 |
the manifest |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1334 |
""" |
906
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
1335 |
attrib_name = None |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1336 |
if not self.manifest_is_script: |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1337 |
if self.AI_root.getroot().tag == "ai_manifest": |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1338 |
attrib_name = self.AI_root.getroot().attrib['name'] |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1339 |
elif self.AI_root.getroot().tag == "auto_install": |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1340 |
try: |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1341 |
ai_instance = self.AI_root.find(".//ai_instance") |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1342 |
except lxml.etree.LxmlError, err: |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1343 |
raise SystemExit(_("Error:\tAI manifest error: %s") % err) |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1344 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1345 |
if 'name' in ai_instance.attrib: |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1346 |
attrib_name = ai_instance.attrib['name'] |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1347 |
else: |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1348 |
raise SystemExit(_("Error:\tCan not find either <ai_manifest> " |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1349 |
"or <auto_install> tags!")) |
906
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
1350 |
|
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
1351 |
# Use name if passed on command line, else internal name if |
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
1352 |
# defined, otherwise default to name of file |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1353 |
if self._manifest_name: |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1354 |
name = self._manifest_name |
906
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
1355 |
elif attrib_name: |
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
1356 |
name = attrib_name |
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
1357 |
else: |
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
1358 |
name = os.path.basename(self.manifest_path) |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1359 |
return name |
906
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
1360 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1361 |
@property |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1362 |
def stored_manifest_path(self): |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1363 |
""" |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1364 |
Returns the full path of the stored manifest or script. |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1365 |
""" |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1366 |
return os.path.join(self.get_service(), AI_DATA, |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1367 |
self.manifest_name) |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
1368 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
1369 |
def verify_AI_manifest(self): |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1370 |
""" |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1371 |
Used for verifying and loading AI manifest as defined by |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1372 |
DataFiles._AIschema. |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1373 |
Args: None. |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1374 |
Preconditions: Expects its is_dtd variable to be set to determine |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1375 |
how to validate the AI manifest. |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1376 |
Postconditions: Sets AI_root on success to a XML DOM of the AI |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1377 |
manifest. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1378 |
Raises: IOError on file open error. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1379 |
ValueError on validation error. |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1380 |
""" |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1381 |
schema = file(self.AI_schema, 'r') |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1382 |
|
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1383 |
try: |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1384 |
xml_data = file(self.manifest_path, 'r') |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1385 |
except AssertionError: |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1386 |
# manifest path will be unset if we're not using a separate file |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1387 |
# for A/I manifest so we must emulate a file |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1388 |
xml_data = StringIO.StringIO(lxml.etree.tostring(self.AI_root)) |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1389 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1390 |
if self.is_dtd: |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1391 |
self.AI_root, errors = verifyXML.verifyDTDManifest(self.AI_schema, |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1392 |
xml_data) |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1393 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1394 |
if errors: |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1395 |
err = '\n'.join(errors) |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1396 |
raise ValueError(_("Error: AI manifest failed validation:\n%s") |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1397 |
% err) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1398 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1399 |
ai_instance = self.AI_root.find(".//ai_instance") |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1400 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1401 |
else: |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1402 |
self.AI_root, errors = verifyXML.verifyRelaxNGManifest(schema, |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1403 |
xml_data) |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1404 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1405 |
if errors: |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1406 |
# catch if we are not using a manifest we can name with |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1407 |
# manifest_path |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1408 |
try: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1409 |
# manifest_path is a property that may raise an |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1410 |
# AssertionError |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1411 |
man_path = self.manifest_path |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1412 |
raise ValueError(_("Error:\tFile %s failed validation:" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1413 |
"\n\t%s") % |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1414 |
(os.path.basename(man_path), |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1415 |
errors.message)) |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1416 |
# manifest_path will throw an AssertionError if it does not |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1417 |
# have a path use a different error message |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1418 |
except AssertionError: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1419 |
raise ValueError(_("Error: AI manifest failed validation:" |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1420 |
"\n\t%s") % errors.message) |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
1421 |
|
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1422 |
# Replace the <ai_manifest_file> element (if one exists) with an |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1423 |
# <ai_embedded_manifest> element, using content from its referenced |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1424 |
# file which was just loaded into the AI_root XML DOM |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1425 |
ai_manifest_file = self.criteria_root.find(".//ai_manifest_file") |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1426 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1427 |
if ai_manifest_file is not None: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1428 |
new_ai = lxml.etree.Element("ai_embedded_manifest") |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
906
diff
changeset
|
1429 |
# add newlines to separate ai_embedded_manifest |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1430 |
# from children |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1431 |
new_ai.text = "\n\t" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1432 |
new_ai.tail = "\n" |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1433 |
self.AI_root.getroot().tail = "\n" |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1434 |
new_ai.append(self.AI_root.getroot()) |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1435 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1436 |
ai_manifest_file.getparent().replace(ai_manifest_file, new_ai) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1437 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1438 |
ai_instance = self.criteria_root.find(".//ai_manifest") |
906
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
1439 |
|
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
1440 |
# Set/update the name inside the DOM |
1293ecd7e911
4322 installadm list should list name of the manifest that was used for creation
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
1441 |
ai_instance.set("name", self.manifest_name) |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
1442 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
1443 |
def verify_SC_manifest(self, data, name=None): |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1444 |
""" |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1445 |
Used for verifying and loading SC manifest |
670
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1446 |
Args: data - file path, or StringIO object. |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1447 |
name - Optionally, takes a name to provide error output, |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1448 |
as a StringIO object will not have a file path to |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1449 |
provide. |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1450 |
Returns: Provide an XML DOM for the SC manifest |
2565d2cc3a1c
12300 publish-manifest: needs to have correct usage message
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
649
diff
changeset
|
1451 |
Raises: SystemExit on validation or file open error. |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1452 |
""" |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1453 |
if not isinstance(data, StringIO.StringIO): |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1454 |
try: |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1455 |
data = file(data, 'r') |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1456 |
except IOError: |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1457 |
if name is None: |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1458 |
raise SystemExit(_("Error:\tCan not open: %s") % data) |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1459 |
else: |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1460 |
raise SystemExit(_("Error:\tCan not open: %s") % name) |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1461 |
xml_root, errors = verifyXML.verifyDTDManifest(self.smfDtd, data) |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1462 |
if errors: |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1463 |
if not isinstance(data, StringIO.StringIO): |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1464 |
print >> sys.stderr, (_("Error:\tFile %s failed validation:") % |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1465 |
data.name) |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1466 |
else: |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1467 |
print >> sys.stderr, (_("Error:\tSC Manifest %s failed " |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1468 |
"validation:") % name) |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
1469 |
for err in xml_root: |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1470 |
print >> sys.stderr, err |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1471 |
raise SystemExit() |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
1472 |
return(xml_root) |
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
1473 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1474 |
@classmethod |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1475 |
def manifest_is_a_script(cls, manifest_filepath): |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1476 |
""" |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1477 |
Returns True if given manifest is supported by Derived Manifests. |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1478 |
|
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1479 |
Raises a SystemExit exception if an unsupported script type is found. |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1480 |
""" |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1481 |
manifest_fobj = open(manifest_filepath) |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1482 |
first_line = manifest_fobj.readline() |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1483 |
manifest_fobj.close() |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1484 |
if first_line.startswith("#!"): |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1485 |
if (first_line.find(KSH93_SHEBANG) == -1 and |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1486 |
first_line.find(PYTHON_SHEBANG) == -1): |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1487 |
print >> sys.stderr, "Unsupported script format. " \ |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1488 |
"Python and ksh93 scripts are supported." |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1489 |
raise SystemExit(errno.EINVAL) |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1490 |
return True |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1491 |
return False |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1492 |
|
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1493 |
def set_criteria_root(self, root=None): |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1494 |
""" |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1495 |
Used to set criteria_root DOM with the criteria from the passed |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1496 |
in root DOM. If criteria_root already exists, overwrite its |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1497 |
<ai_criteria> elements with the criteria found in root. If |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1498 |
criteria_root doesn't already exist, simply set the root DOM |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1499 |
passed in as criteria_root. |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1500 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1501 |
Args: root - A DOM for a criteria manifest |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1502 |
Postconditions: criteria_root will be set with a criteria manifest |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1503 |
DOM, or have its <ai_criteria> elements replaced with |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1504 |
the criteria from the root DOM passed in. |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1505 |
""" |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1506 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1507 |
# If the criteria_root is not yet set, set it to the root |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1508 |
# DOM passed in. |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1509 |
if self.criteria_root is None: |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1510 |
self.criteria_root = root |
523
9abfbbe9b302
4325 Better syntactic treatment of IP and MAC address AI criteria
Jack Schwartz <Jack.A.Schwartz@Sun.COM>
parents:
475
diff
changeset
|
1511 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1512 |
# Else criteria_root already exists (because this is being |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1513 |
# called with an older install service where the manifest input |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1514 |
# is a combined Criteria manifest), use the criteria specified |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1515 |
# in 'root' to overwrite any criteria in criteria_root. |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1516 |
else: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1517 |
# Remove all <ai_criteria> elements if they exist. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1518 |
removed_criteria = False |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1519 |
path = '/ai_criteria_manifest/ai_criteria' |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1520 |
for tag in self.criteria_root.xpath(path): |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1521 |
removed_criteria = True |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1522 |
tag.getparent().remove(tag) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1523 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1524 |
# If we removed a criteria from criteria_root, this means |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1525 |
# criteria was also specified in a combined Criteria manifest. |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
906
diff
changeset
|
1526 |
# Warn user that those will be ignored, and criteria specified |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1527 |
# on the command line via -c or -C override those. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1528 |
if removed_criteria: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1529 |
print("Warning: criteria specified in multiple places.\n" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1530 |
" Ignoring criteria from combined Criteria manifest " |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1531 |
"file.\n") |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1532 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1533 |
# Append all criteria from the new criteria root. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1534 |
ai_criteria = root.iterfind(".//ai_criteria") |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1535 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1536 |
self.criteria_root.getroot().extend(ai_criteria) |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1537 |
|
287
13cbbc65259c
3440 Need webserver for A/I support
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
diff
changeset
|
1538 |
|
1005
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
1539 |
def do_publish_manifest(cmd_options=None): |
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
1540 |
''' |
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
1541 |
Publish a manifest, associating it with an install service. |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
906
diff
changeset
|
1542 |
|
1005
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
1543 |
''' |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1544 |
# check that we are root |
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1545 |
if os.geteuid() != 0: |
1005
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
1546 |
raise SystemExit(_("Error:\tRoot privileges are required for " |
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
1547 |
"this command.")) |
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
1548 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1549 |
# load in all the options and file data. Validate proper manifests. |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1550 |
data = parse_options(DO_ADD, cmd_options) |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1551 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1552 |
# Disallow multiple manifests or scripts with the same mname. |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1553 |
if os.path.exists(data.stored_manifest_path): |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1554 |
raise SystemExit(_("Error:\tName %s is already registered with " |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1555 |
"this service.") % data.manifest_name) |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1556 |
|
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1557 |
# if criteria are provided, make sure they are a unique set. |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1558 |
if data.criteria: |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1559 |
find_colliding_manifests(data.criteria, data.database, |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
772
diff
changeset
|
1560 |
find_colliding_criteria(data.criteria, data.database)) |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1561 |
|
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1562 |
# Add all manifests to the database, whether default or not, and whether |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1563 |
# they have criteria or not. |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1564 |
insert_SQL(data) |
630
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1565 |
|
354d968d3628
4318 - publish-manifest needs to error about no criteria in non-default manifests
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
625
diff
changeset
|
1566 |
# move the manifest into place |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
630
diff
changeset
|
1567 |
place_manifest(data) |
1005
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
1568 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1569 |
# if we have a default manifest do default manifest handling |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1570 |
if data.set_as_default: |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1571 |
set_default(data.service_name, data.manifest_name) |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1572 |
|
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1573 |
|
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1574 |
def do_update_manifest(cmd_options=None): |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1575 |
''' |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1576 |
Update the contents of an existing manifest. |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1577 |
|
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1578 |
''' |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1579 |
# check that we are root |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1580 |
if os.geteuid() != 0: |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1581 |
raise SystemExit(_("Error:\tRoot privileges are required for " |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1582 |
"this command.")) |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1583 |
|
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1584 |
# load in all the options and file data. Validate proper manifests. |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1585 |
data = parse_options(DO_UPDATE, cmd_options) |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1586 |
|
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1587 |
if not os.path.exists(data.stored_manifest_path): |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1588 |
raise SystemExit(_("Error:\tNo manifest or script with name " |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1589 |
"%s is registered with this service.\n" |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1590 |
"\tPlease use installadm add-manifest instead.") % |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1591 |
data.manifest_name) |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1592 |
|
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1593 |
# move the manifest into place |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1594 |
place_manifest(data) |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1595 |
|
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1596 |
|
1005
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
1597 |
if __name__ == '__main__': |
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
1598 |
gettext.install("ai", "/usr/lib/locale") |
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
1599 |
|
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
1600 |
# If invoked from the shell directly, mostly for testing, |
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
1601 |
# attempt to perform the action. |
4a59a181decd
7015429 Convert installadm.c to python
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
992
diff
changeset
|
1602 |
do_publish_manifest() |