author | Ethan Quach <Ethan.Quach@sun.com> |
Tue, 31 May 2011 14:21:09 -0700 | |
changeset 1160 | 6f7e708c38ec |
parent 1151 | 95413393ef67 |
child 1631 | f8841ae44dc6 |
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:
609
diff
changeset
|
1 |
#!/usr/bin/python2.6 |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
2 |
# |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
3 |
# CDDL HEADER START |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
4 |
# |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
5 |
# The contents of this file are subject to the terms of the |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
6 |
# Common Development and Distribution License (the "License"). |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
7 |
# You may not use this file except in compliance with the License. |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
8 |
# |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
9 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
10 |
# or http://www.opensolaris.org/os/licensing. |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
11 |
# See the License for the specific language governing permissions |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
12 |
# and limitations under the License. |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
13 |
# |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
14 |
# When distributing Covered Code, include this CDDL HEADER in each |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
15 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
16 |
# If applicable, add the following below this CDDL HEADER, with the |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
17 |
# fields enclosed by brackets "[]" replaced with your own identifying |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
18 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
19 |
# |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
20 |
# CDDL HEADER END |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
21 |
# |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
22 |
# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
23 |
# |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
24 |
# ai_get_manifest - AI Service Choosing Engine |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
25 |
# |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
26 |
""" |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
27 |
ai_get_manifest - Obtains AI manifest from AI server |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
28 |
""" |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
29 |
|
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:
994
diff
changeset
|
30 |
from email.parser import Parser |
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:
994
diff
changeset
|
31 |
from errno import EEXIST, ENOENT |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
32 |
import getopt |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
33 |
import gettext |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
34 |
import httplib |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
35 |
import os |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
36 |
import socket |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
37 |
from subprocess import Popen, PIPE |
994
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
38 |
import re |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
39 |
import sys |
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:
994
diff
changeset
|
40 |
import tempfile |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
41 |
import time |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
42 |
import traceback |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
43 |
import urllib |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
44 |
|
1151
95413393ef67
7038120 Update Auto Installer to use CUD
Darren Kenny <Darren.Kenny@Oracle.COM>
parents:
1087
diff
changeset
|
45 |
from solaris_install import _, system_temp_path |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
46 |
|
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
47 |
VERSION_FILE = '/usr/share/auto_install/version' |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
48 |
|
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:
994
diff
changeset
|
49 |
# constants for generating temporary files with unique names for SMF profiles |
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:
994
diff
changeset
|
50 |
SC_PREFIX = 'profile_' |
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:
994
diff
changeset
|
51 |
SC_EXTENSION = '.xml' |
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:
994
diff
changeset
|
52 |
|
1151
95413393ef67
7038120 Update Auto Installer to use CUD
Darren Kenny <Darren.Kenny@Oracle.COM>
parents:
1087
diff
changeset
|
53 |
AI_MANIFEST_ATTACHMENT_NAME = 'manifest.xml' # named as MIME attachment |
95413393ef67
7038120 Update Auto Installer to use CUD
Darren Kenny <Darren.Kenny@Oracle.COM>
parents:
1087
diff
changeset
|
54 |
|
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
55 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
56 |
class AILog: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
57 |
""" |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
58 |
Class AILog: Logging service |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
59 |
Description: Provides logging capabilities for AI service choosing |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
60 |
and AI service discovery engines. |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
61 |
""" |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
62 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
63 |
# list of implemented logging levels |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
64 |
AI_DBGLVL_NONE = 0 |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
65 |
AI_DBGLVL_EMERG = 1 |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
66 |
AI_DBGLVL_ERR = 2 |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
67 |
AI_DBGLVL_WARN = 3 |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
68 |
AI_DBGLVL_INFO = 4 |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
69 |
|
1151
95413393ef67
7038120 Update Auto Installer to use CUD
Darren Kenny <Darren.Kenny@Oracle.COM>
parents:
1087
diff
changeset
|
70 |
def __init__(self, logid="AI", logfile=system_temp_path("ai_sd_log"), |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
71 |
debuglevel=AI_DBGLVL_WARN): |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
72 |
self.log_file = logfile |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
73 |
self.logid = logid |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
74 |
self.dbg_lvl_current = debuglevel |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
75 |
self.fh_log = None |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
76 |
|
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
77 |
# list of prefixes displayed for particular logging levels |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
78 |
self.log_prefix = {AILog.AI_DBGLVL_EMERG: "!", |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
79 |
AILog.AI_DBGLVL_ERR: "E", AILog.AI_DBGLVL_WARN: "W", |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
80 |
AILog.AI_DBGLVL_INFO: "I"} |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
81 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
82 |
# default logging level |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
83 |
self.dbg_lvl_default = AILog.AI_DBGLVL_INFO |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
84 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
85 |
# if provided, open log file in append mode |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
86 |
if self.log_file is not None: |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
87 |
try: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
88 |
self.fh_log = open(self.log_file, "a+") |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
89 |
except IOError: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
90 |
self.fh_log = None |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
91 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
92 |
def set_debug_level(self, level): |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
93 |
""" |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
94 |
Set default logging level |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
95 |
level - new logging level |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
96 |
""" |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
97 |
|
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
98 |
if level in self.log_prefix: |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
99 |
self.dbg_lvl_current = level |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
100 |
|
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:
994
diff
changeset
|
101 |
def get_debug_level(self): |
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:
994
diff
changeset
|
102 |
"""Return current debug level""" |
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:
994
diff
changeset
|
103 |
return self.dbg_lvl_current |
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:
994
diff
changeset
|
104 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
105 |
def post(self, level, msg_format, * msg_args): |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
106 |
""" |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
107 |
Post logging message |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
108 |
level - logging level |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
109 |
msg - message to be logged |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
110 |
msg_args - message parameters |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
111 |
""" |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
112 |
|
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
113 |
if level not in self.log_prefix: |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
114 |
return |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
115 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
116 |
if level > self.dbg_lvl_current: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
117 |
return |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
118 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
119 |
timestamp = time.strftime("%m/%d %H:%M:%S", time.gmtime()) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
120 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
121 |
log_msg = "<%s_%s %s> " % (self.logid, self.log_prefix[level], |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
122 |
timestamp) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
123 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
124 |
if len(msg_args) == 0: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
125 |
log_msg += msg_format |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
126 |
else: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
127 |
log_msg += msg_format % msg_args |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
128 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
129 |
# post message to console |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
130 |
print log_msg |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
131 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
132 |
# post message to file |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
133 |
if self.fh_log is not None: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
134 |
self.fh_log.write(log_msg + '\n') |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
135 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
136 |
return |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
137 |
|
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
138 |
# |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
139 |
# AI service choosing logging service |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
140 |
# |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
141 |
AIGM_LOG = AILog("AISC") |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
142 |
|
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
143 |
|
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
144 |
def ai_exec_cmd(cmd): |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
145 |
""" Description: Executes provided command using subprocess.Popen() |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
146 |
method and captures its stdout & stderr. |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
147 |
stderr is captured for debugging purposes |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
148 |
|
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
149 |
Parameters: |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
150 |
cmd - Command to be executed |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
151 |
|
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
152 |
Returns: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
153 |
captured stdout from 'cmd' |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
154 |
return code - 0..success, -1..failure |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
155 |
""" |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
156 |
|
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
157 |
AIGM_LOG.post(AILog.AI_DBGLVL_INFO, "cmd:" + cmd) |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
158 |
|
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
159 |
try: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
160 |
cmd_popen = Popen(cmd, shell=True, stdout=PIPE) |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
161 |
(cmd_stdout, cmd_stderr) = cmd_popen.communicate() |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
162 |
|
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
163 |
except OSError: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
164 |
AIGM_LOG.post(AILog.AI_DBGLVL_ERR, |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
165 |
"Popen() raised OSError exception") |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
166 |
|
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
167 |
return None, -1 |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
168 |
|
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
169 |
except ValueError: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
170 |
AIGM_LOG.post(AILog.AI_DBGLVL_ERR, |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
171 |
"Popen() raised ValueError exception") |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
172 |
|
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
173 |
return None, -1 |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
174 |
|
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
175 |
# capture output of stderr for debugging purposes |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
176 |
if cmd_stderr is not None: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
177 |
AIGM_LOG.post(AILog.AI_DBGLVL_WARN, |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
178 |
" stderr: %s", cmd_stderr) |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
179 |
|
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
180 |
# check if child process terminated successfully |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
181 |
if cmd_popen.returncode != 0: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
182 |
AIGM_LOG.post(AILog.AI_DBGLVL_ERR, |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
183 |
"Command failed: ret=%d", cmd_popen.returncode) |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
184 |
|
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
185 |
return None, -1 |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
186 |
|
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
187 |
return cmd_stdout, 0 |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
188 |
|
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
189 |
|
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
190 |
class AICriteria: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
191 |
""" Class: AICriteria - base class for holding/manipulating AI criteria |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
192 |
""" |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
193 |
|
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
194 |
def __init__(self, criteria=None): |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
195 |
self.criteria = criteria |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
196 |
|
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
197 |
def get(self): |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
198 |
""" return criteria value |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
199 |
""" |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
200 |
|
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
201 |
return self.criteria |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
202 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
203 |
def is_known(self): |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
204 |
""" check if information requried by criteria is available |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
205 |
""" |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
206 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
207 |
return self.criteria is not None |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
208 |
|
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
209 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
210 |
class AICriteriaHostname(AICriteria): |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
211 |
""" Class: AICriteriaHostname - class for obtaining/manipulating 'hostname' |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
212 |
criteria |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
213 |
""" |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
214 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
215 |
def __init__(self): |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
216 |
AICriteria.__init__(self, socket.gethostname()) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
217 |
|
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
218 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
219 |
class AICriteriaArch(AICriteria): |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
220 |
""" Class: AICriteriaArch class - class for obtaining/manipulating |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
221 |
'architecture' criteria |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
222 |
""" |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
223 |
|
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
224 |
client_arch = None |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
225 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
226 |
def __init__(self): |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
227 |
if AICriteriaArch.client_arch: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
228 |
AICriteria.__init__(self, AICriteriaArch.client_arch) |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
229 |
return |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
230 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
231 |
cmd = "/usr/bin/uname -m" |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
232 |
client_arch, ret = ai_exec_cmd(cmd) |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
233 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
234 |
if ret != 0 or client_arch == "": |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
235 |
AIGM_LOG.post(AILog.AI_DBGLVL_ERR, |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
236 |
"Could not obtain machine architecture") |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
237 |
AICriteriaArch.client_arch = None |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
238 |
else: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
239 |
AICriteriaArch.client_arch = client_arch.strip() |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
240 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
241 |
AICriteria.__init__(self, AICriteriaArch.client_arch) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
242 |
|
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
243 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
244 |
class AICriteriaPlatform(AICriteria): |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
245 |
""" Class: AICriteriaPlatform class - class for obtaining/manipulating |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
246 |
'platform' criteria |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
247 |
""" |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
248 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
249 |
client_platform = None |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
250 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
251 |
def __init__(self): |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
252 |
if AICriteriaPlatform.client_platform: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
253 |
AICriteria.__init__(self, |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
254 |
AICriteriaPlatform.client_platform) |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
255 |
return |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
256 |
|
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
257 |
cmd = "/usr/bin/uname -i" |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
258 |
AICriteriaPlatform.client_platform, ret = ai_exec_cmd(cmd) |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
259 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
260 |
if ret != 0 or AICriteriaPlatform.client_platform == "": |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
261 |
AIGM_LOG.post(AILog.AI_DBGLVL_ERR, |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
262 |
"Could not obtain machine platform") |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
263 |
else: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
264 |
AICriteriaPlatform.client_platform = \ |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
265 |
AICriteriaPlatform.client_platform.strip() |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
266 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
267 |
AICriteria.__init__(self, AICriteriaPlatform.client_platform) |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
268 |
|
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
269 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
270 |
class AICriteriaCPU(AICriteria): |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
271 |
""" Class: AICriteriaCPU - class for obtaining/manipulating |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
272 |
'processor type' criteria |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
273 |
""" |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
274 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
275 |
client_cpu = None |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
276 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
277 |
def __init__(self): |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
278 |
if AICriteriaCPU.client_cpu: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
279 |
AICriteria.__init__(self, AICriteriaCPU.client_cpu) |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
280 |
return |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
281 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
282 |
cmd = "/usr/bin/uname -p" |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
283 |
AICriteriaCPU.client_cpu, ret = ai_exec_cmd(cmd) |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
284 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
285 |
if ret != 0 or AICriteriaCPU.client_cpu == "": |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
286 |
AIGM_LOG.post(AILog.AI_DBGLVL_ERR, |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
287 |
"Could not obtain processor type") |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
288 |
else: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
289 |
AICriteriaCPU.client_cpu = \ |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
290 |
AICriteriaCPU.client_cpu.strip() |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
291 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
292 |
AICriteria.__init__(self, AICriteriaCPU.client_cpu) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
293 |
|
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
294 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
295 |
class AICriteriaMemSize(AICriteria): |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
296 |
""" Class: AICriteriaMemSize class - class for obtaining/manipulating |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
297 |
'physical memory size' criteria, value is in MB |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
298 |
""" |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
299 |
|
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
300 |
client_mem_size = None |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
301 |
client_mem_size_initialized = False |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
302 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
303 |
def __init__(self): |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
304 |
if AICriteriaMemSize.client_mem_size_initialized: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
305 |
AICriteria.__init__(self, |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
306 |
AICriteriaMemSize.client_mem_size) |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
307 |
return |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
308 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
309 |
AICriteriaMemSize.client_mem_size_initialized = True |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
310 |
cmd = "/usr/sbin/prtconf -vp | /usr/bin/grep '^Memory size: '" |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
311 |
client_mem_info, ret = ai_exec_cmd(cmd) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
312 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
313 |
if ret != 0 or client_mem_info == "": |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
314 |
AIGM_LOG.post(AILog.AI_DBGLVL_ERR, |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
315 |
"Could not obtain memory size") |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
316 |
AICriteriaMemSize.client_mem_size = None |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
317 |
AICriteria.__init__(self) |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
318 |
return |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
319 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
320 |
(client_mem_size, client_mem_unit) = client_mem_info.split()[2:] |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
321 |
client_mem_size = long(client_mem_size) |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
322 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
323 |
AIGM_LOG.post(AILog.AI_DBGLVL_INFO, |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
324 |
"prtconf(1M) reported: %ld %s", client_mem_size, |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
325 |
client_mem_unit) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
326 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
327 |
if client_mem_size == 0 or client_mem_unit == "": |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
328 |
AIGM_LOG.post(AILog.AI_DBGLVL_ERR, |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
329 |
"Could not obtain memory size") |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
330 |
AICriteriaMemSize.client_mem_size = None |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
331 |
AICriteria.__init__(self) |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
332 |
return |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
333 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
334 |
if client_mem_unit == "Kilobytes": |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
335 |
client_mem_size /= 1024 |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
336 |
elif client_mem_unit == "Gigabytes": |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
337 |
client_mem_size *= 1024 |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
338 |
elif client_mem_unit == "Terabytes": |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
339 |
client_mem_size *= 1024 * 1024 |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
340 |
elif client_mem_unit != "Megabytes": |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
341 |
AIGM_LOG.post(AILog.AI_DBGLVL_WARN, |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
342 |
"Unknown mem size units %s", client_mem_unit) |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
343 |
client_mem_size = 0 |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
344 |
|
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
345 |
AICriteriaMemSize.client_mem_size = repr(client_mem_size).rstrip('L') |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
346 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
347 |
AICriteria.__init__(self, AICriteriaMemSize.client_mem_size) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
348 |
|
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
349 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
350 |
class AICriteriaNetworkInterface(AICriteria): |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
351 |
""" Class: AICriteriaNetworkInterface class - class for |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
352 |
obtaining/manipulating information about network interface - |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
353 |
this criteria is currently private and not exposed to the server |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
354 |
""" |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
355 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
356 |
network_iface = None |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
357 |
ifconfig_iface_info = None |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
358 |
network_iface_initialized = False |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
359 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
360 |
def __init__(self): |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
361 |
AICriteria.__init__(self) |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
362 |
|
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
363 |
# initialize class variables only once |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
364 |
if AICriteriaNetworkInterface.network_iface_initialized: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
365 |
return |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
366 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
367 |
AICriteriaNetworkInterface.network_iface_initialized = True |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
368 |
# |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
369 |
# Obtain network interface name, which will be queried in next |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
370 |
# step in order to obtain required network parameters |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
371 |
# |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
372 |
# Search for the first interface, which is UP - omit loopback |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
373 |
# interfaces. Then use ifconfig for query the information about |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
374 |
# that interface and store the result. |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
375 |
# |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
376 |
cmd = "/usr/sbin/ifconfig -au | /usr/bin/grep '[0-9]:' " \ |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
377 |
"| /usr/bin/grep -v 'LOOPBACK'" |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
378 |
AICriteriaNetworkInterface.network_iface, ret = ai_exec_cmd(cmd) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
379 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
380 |
if ret != 0: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
381 |
AIGM_LOG.post(AILog.AI_DBGLVL_ERR, |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
382 |
"Could not obtain name of valid network interface") |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
383 |
AICriteriaNetworkInterface.network_iface = None |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
384 |
else: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
385 |
AICriteriaNetworkInterface.network_iface = \ |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
386 |
AICriteriaNetworkInterface.network_iface.split(':')[0] |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
387 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
388 |
AIGM_LOG.post(AILog.AI_DBGLVL_INFO, |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
389 |
"Network interface obtained: %s", |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
390 |
AICriteriaNetworkInterface.network_iface) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
391 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
392 |
# |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
393 |
# Collect all available information about network interface |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
394 |
# |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
395 |
cmd = "/usr/sbin/ifconfig %s" % \ |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
396 |
AICriteriaNetworkInterface.network_iface |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
397 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
398 |
AICriteriaNetworkInterface.ifconfig_iface_info, ret = \ |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
399 |
ai_exec_cmd(cmd) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
400 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
401 |
if ret != 0 or \ |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
402 |
AICriteriaNetworkInterface.ifconfig_iface_info == "": |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
403 |
AIGM_LOG.post(AILog.AI_DBGLVL_ERR, |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
404 |
"Could not obtain information about " |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
405 |
"network interface %s", |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
406 |
AICriteriaNetworkInterface.network_iface) |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
407 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
408 |
AICriteriaNetworkInterface.ifconfig_iface_info = None |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
409 |
|
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
410 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
411 |
class AICriteriaMAC(AICriteriaNetworkInterface): |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
412 |
""" Class: AICriteriaMAC - class for obtaining/manipulating |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
413 |
information about client MAC address |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
414 |
""" |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
415 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
416 |
client_mac = None |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
417 |
client_mac_initialized = False |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
418 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
419 |
def __init__(self): |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
420 |
AICriteriaNetworkInterface.__init__(self) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
421 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
422 |
# initialize class variables only once |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
423 |
if AICriteriaMAC.client_mac_initialized: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
424 |
AICriteria.__init__(self, AICriteriaMAC.client_mac) |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
425 |
return |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
426 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
427 |
AICriteriaMAC.client_mac_initialized = True |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
428 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
429 |
if AICriteriaNetworkInterface.ifconfig_iface_info is None: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
430 |
AIGM_LOG.post(AILog.AI_DBGLVL_ERR, |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
431 |
"Could not obtain MAC address") |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
432 |
else: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
433 |
AICriteriaMAC.client_mac = AICriteriaNetworkInterface. \ |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
434 |
ifconfig_iface_info.split("ether", 1) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
435 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
436 |
if len(AICriteriaMAC.client_mac) < 2: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
437 |
AIGM_LOG.post(AILog.AI_DBGLVL_ERR, |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
438 |
"Could not obtain client MAC address") |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
439 |
AICriteriaMAC.client_mac = None |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
440 |
else: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
441 |
AICriteriaMAC.client_mac = AICriteriaMAC.\ |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
442 |
client_mac[1].strip().split()[0].strip() |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
443 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
444 |
# |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
445 |
# remove ':' and pad with '0's |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
446 |
# |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
447 |
# This step makes sure that the criteria are |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
448 |
# passed to the server in the format which |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
449 |
# server can understand. This is just an interim |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
450 |
# solution. |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
451 |
# |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
452 |
# For longer term, all criteria should be |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
453 |
# passed to the server in native format letting |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
454 |
# the server side control the process of |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
455 |
# conversion. |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
456 |
# |
325
20cd4ea33953
4302 AI SC has to pad MAC addresses
Jan Damborsky <jan.damborsky@sun.com>
parents:
314
diff
changeset
|
457 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
458 |
client_mac_parts = \ |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
459 |
AICriteriaMAC.client_mac.split(":") |
325
20cd4ea33953
4302 AI SC has to pad MAC addresses
Jan Damborsky <jan.damborsky@sun.com>
parents:
314
diff
changeset
|
460 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
461 |
AICriteriaMAC.client_mac = "%s%s%s%s%s%s" % \ |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
462 |
(client_mac_parts[0].zfill(2), |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
463 |
client_mac_parts[1].zfill(2), |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
464 |
client_mac_parts[2].zfill(2), |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
465 |
client_mac_parts[3].zfill(2), |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
466 |
client_mac_parts[4].zfill(2), |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
467 |
client_mac_parts[5].zfill(2)) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
468 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
469 |
AIGM_LOG.post(AILog.AI_DBGLVL_INFO, |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
470 |
"Client MAC address: %s", |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
471 |
AICriteriaMAC.client_mac) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
472 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
473 |
AICriteria.__init__(self, AICriteriaMAC.client_mac) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
474 |
|
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
475 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
476 |
class AICriteriaIP(AICriteriaNetworkInterface): |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
477 |
""" Class: AICriteriaIP class - class for obtaining/manipulating |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
478 |
information about client IP address |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
479 |
""" |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
480 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
481 |
client_ip = None |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
482 |
client_ip_string = None |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
483 |
client_ip_initialized = False |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
484 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
485 |
def __init__(self): |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
486 |
AICriteriaNetworkInterface.__init__(self) |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
487 |
|
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
488 |
# initialize class variables only once |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
489 |
if AICriteriaIP.client_ip_initialized: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
490 |
AICriteria.__init__(self, AICriteriaIP.client_ip_string) |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
491 |
return |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
492 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
493 |
AICriteriaIP.client_ip_initialized = True |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
494 |
if AICriteriaNetworkInterface.ifconfig_iface_info == None: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
495 |
AIGM_LOG.post(AILog.AI_DBGLVL_ERR, |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
496 |
"Could not obtain IP address") |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
497 |
else: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
498 |
AICriteriaIP.client_ip = AICriteriaNetworkInterface. \ |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
499 |
ifconfig_iface_info.split("inet", 1)[1].strip().\ |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
500 |
split()[0].strip() |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
501 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
502 |
# remove '.' |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
503 |
ip_split = AICriteriaIP.client_ip.split('.') |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
504 |
AICriteriaIP.client_ip_string = "%03d%03d%03d%03d" % \ |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
505 |
(int(ip_split[0]), int(ip_split[1]), |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
506 |
int(ip_split[2]), int(ip_split[3])) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
507 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
508 |
AIGM_LOG.post(AILog.AI_DBGLVL_INFO, |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
509 |
"Client IP address: %s", |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
510 |
AICriteriaIP.client_ip_string) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
511 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
512 |
AICriteria.__init__(self, AICriteriaIP.client_ip_string) |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
513 |
|
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
514 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
515 |
class AICriteriaNetwork(AICriteriaIP): |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
516 |
""" Class: AICriteriaNetwork class - class for obtaining/manipulating |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
517 |
information about client network address |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
518 |
""" |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
519 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
520 |
client_net = None |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
521 |
client_net_string = None |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
522 |
client_net_initialized = False |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
523 |
|
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
524 |
def __init__(self): |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
525 |
AICriteriaIP.__init__(self) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
526 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
527 |
# initialize class variables only once |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
528 |
if AICriteriaNetwork.client_net_initialized: |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
529 |
AICriteria.__init__(self, AICriteriaNetwork.client_net_string) |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
530 |
return |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
531 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
532 |
AICriteriaNetwork.client_net_initialized = True |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
533 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
534 |
if AICriteriaNetworkInterface.ifconfig_iface_info == None or \ |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
535 |
AICriteriaIP.client_ip == None: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
536 |
AIGM_LOG.post(AILog.AI_DBGLVL_ERR, |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
537 |
"Could not obtain network address") |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
538 |
else: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
539 |
# extract network mask |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
540 |
client_netmask = \ |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
541 |
long(AICriteriaNetworkInterface.ifconfig_iface_info. |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
542 |
split("netmask", 1)[1].strip().split()[0].strip(), 16) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
543 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
544 |
# Translate IP address in string format to long |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
545 |
ip_part = AICriteriaIP.client_ip.split('.') |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
546 |
ip_long = long(ip_part[0]) << 24 | long(ip_part[1]) << \ |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
547 |
16 | long(ip_part[2]) << 8 | long(ip_part[3]) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
548 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
549 |
client_network_long = ip_long & client_netmask |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
550 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
551 |
AIGM_LOG.post(AILog.AI_DBGLVL_INFO, |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
552 |
"Mask: %08lX, IP: %08lX, Network: %08lX", |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
553 |
client_netmask, ip_long, client_network_long) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
554 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
555 |
AICriteriaNetwork.client_net_string = \ |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
556 |
"%03ld%03ld%03ld%03ld" % \ |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
557 |
(client_network_long >> 24, |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
558 |
client_network_long >> 16 & 0xff, |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
559 |
client_network_long >> 8 & 0xff, |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
560 |
client_network_long & 0xff) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
561 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
562 |
maskbits = 0 |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
563 |
for shift in range(32): |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
564 |
if ((client_netmask >> shift) & 1): |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
565 |
maskbits = 32 - shift |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
566 |
break |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
567 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
568 |
AICriteriaNetwork.client_net = \ |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
569 |
"%ld.%ld.%ld.%ld/%d" % \ |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
570 |
(client_network_long >> 24, |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
571 |
client_network_long >> 16 & 0xff, |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
572 |
client_network_long >> 8 & 0xff, |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
573 |
client_network_long & 0xff, |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
574 |
maskbits) |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
575 |
|
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
576 |
AIGM_LOG.post(AILog.AI_DBGLVL_INFO, "Client net: %s", |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
577 |
AICriteriaNetwork.client_net_string) |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
578 |
|
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
579 |
AICriteria.__init__(self, AICriteriaNetwork.client_net_string) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
580 |
|
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
581 |
# |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
582 |
# dictionary defining list of supported criteria and relationship |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
583 |
# between AI criteria and appropriate class which serves for obtaining |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
584 |
# and manipulating that criteria |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
585 |
# |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
586 |
# It also contains short informative description of the criteria |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
587 |
# |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
588 |
# Use following steps if support for new criteria is required: |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
589 |
# [1] Define name of criteria (like 'MEM'), create new class |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
590 |
# which inherits AICriteria and implements method for |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
591 |
# obtaining the criteria. |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
592 |
# [2] Add name of criteria, class and short description in following |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
593 |
# dictionary |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
594 |
# [3] Test ;-) |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
595 |
# |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
596 |
AI_CRITERIA_SUPPORTED = { |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
597 |
'arch': (AICriteriaArch, "Client machine architecture"), |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
598 |
'cpu': (AICriteriaCPU, "Client processor type"), |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
599 |
'hostname': (AICriteriaHostname, "Client hostname"), |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
600 |
'ipv4': (AICriteriaIP, "Client IP address"), |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
601 |
'mac': (AICriteriaMAC, "Client MAC address"), |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
602 |
'mem': (AICriteriaMemSize, "Physical memory size"), |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
603 |
'network': (AICriteriaNetwork, "Client network address"), |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
604 |
'platform': (AICriteriaPlatform, "Client platform"), |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
605 |
'zonename': (None, "Zonename") |
329
d73380420cb3
4303 - Please use same capitalization for A/I criteria as used elsewhere
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
325
diff
changeset
|
606 |
} |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
607 |
|
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
608 |
|
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
609 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
610 |
def usage(): |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
611 |
""" Print usage message and exit |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
612 |
""" |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
613 |
sys.stderr.write(_("Usage:\n" |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
614 |
" %s -s service_list -o destination" |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
615 |
" -p profile_destination_dir" |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
616 |
" [-c criteria=value ... ]" |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
617 |
" [-d debug_level] [-l] [-h] [-e]\n") % |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
618 |
os.path.basename(sys.argv[0])) |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
619 |
sys.exit(1) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
620 |
|
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
621 |
|
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
622 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
623 |
def get_image_version(fname): |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
624 |
"""Description: Retrieves the IMAGE_VERSION from the on line file. |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
625 |
Parameters: |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
626 |
fname - the filename that contains the version information |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
627 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
628 |
Returns: |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
629 |
'0.5' when no version file exists |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
630 |
'1.0' when no IMAGE_VERSION within the file |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
631 |
the string value of IMAGE_VERSION from the file |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
632 |
""" |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
633 |
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:
994
diff
changeset
|
634 |
with open(fname, 'r') as ifh: |
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:
994
diff
changeset
|
635 |
data = ifh.read() |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
636 |
except IOError: |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
637 |
# No version file, thus prior to the protocol change version was 0.5 |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
638 |
return '0.5' |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
639 |
|
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
640 |
# find the value for the IMAGE_VERSION variable |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
641 |
for line in data.splitlines(): |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
642 |
key, match, value = line.partition("=") |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
643 |
if match and key == "IMAGE_VERSION": |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
644 |
return value |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
645 |
|
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
646 |
AIGM_LOG.post(AILog.AI_DBGLVL_ERR, |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
647 |
"IMAGE_VERSION not found in the version file") |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
648 |
return None |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
649 |
|
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
650 |
|
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
651 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
652 |
def ai_get_http_file(address, service_name, file_path, method, nv_pairs, |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
653 |
no_default=False): |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
654 |
""" Description: Downloads file from url using HTTP protocol |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
655 |
|
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
656 |
Parameters: |
994
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
657 |
address - address of webserver to connect |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
658 |
service_name - requested service name, might be None |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
659 |
file_path - path to file |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
660 |
method - 'POST' or 'GET' |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
661 |
nv_pairs - dictionary containing name-value pairs to be sent |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
662 |
to the server using 'POST' method |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
663 |
no_default - whether or not to request a default manifest if |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
664 |
criteria can't be used to match a manifest. |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
665 |
|
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
666 |
Returns: |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
667 |
file |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
668 |
return code: >= 100 - HTTP Response status code |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
669 |
-1 - Connection to web server failed |
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:
994
diff
changeset
|
670 |
HTTP content type header record |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
671 |
""" |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
672 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
673 |
# try to connect to the provided web server |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
674 |
http_conn = httplib.HTTPConnection(address) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
675 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
676 |
# turn on debug mode in order to track HTTP connection |
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:
994
diff
changeset
|
677 |
if AIGM_LOG.get_debug_level() >= AILog.AI_DBGLVL_INFO: |
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:
994
diff
changeset
|
678 |
http_conn.set_debuglevel(1) |
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:
994
diff
changeset
|
679 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
680 |
try: |
994
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
681 |
if (method == "POST"): |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
682 |
post_data = "" |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
683 |
for key in nv_pairs.keys(): |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
684 |
post_data += "%s=%s;" % (key, nv_pairs[key]) |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
685 |
# remove trailing ';' |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
686 |
post_data = post_data.rstrip(';') |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
687 |
if service_name: |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
688 |
version = get_image_version(VERSION_FILE) |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
689 |
if not version: |
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:
994
diff
changeset
|
690 |
return None, -1, None |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
691 |
|
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:
994
diff
changeset
|
692 |
params = urllib.urlencode({ |
1151
95413393ef67
7038120 Update Auto Installer to use CUD
Darren Kenny <Darren.Kenny@Oracle.COM>
parents:
1087
diff
changeset
|
693 |
'version': version, |
95413393ef67
7038120 Update Auto Installer to use CUD
Darren Kenny <Darren.Kenny@Oracle.COM>
parents:
1087
diff
changeset
|
694 |
'service': service_name, |
95413393ef67
7038120 Update Auto Installer to use CUD
Darren Kenny <Darren.Kenny@Oracle.COM>
parents:
1087
diff
changeset
|
695 |
'logging': AIGM_LOG.get_debug_level(), |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
696 |
'no_default': no_default, |
1151
95413393ef67
7038120 Update Auto Installer to use CUD
Darren Kenny <Darren.Kenny@Oracle.COM>
parents:
1087
diff
changeset
|
697 |
'postData': post_data}) |
994
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
698 |
else: |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
699 |
# compatibility mode only needs to send the data |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
700 |
params = urllib.urlencode({'postData': post_data}) |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
701 |
|
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
702 |
AIGM_LOG.post(AILog.AI_DBGLVL_INFO, "%s", params) |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
703 |
|
1151
95413393ef67
7038120 Update Auto Installer to use CUD
Darren Kenny <Darren.Kenny@Oracle.COM>
parents:
1087
diff
changeset
|
704 |
http_headers = { |
95413393ef67
7038120 Update Auto Installer to use CUD
Darren Kenny <Darren.Kenny@Oracle.COM>
parents:
1087
diff
changeset
|
705 |
"Content-Type": "application/x-www-form-urlencoded", |
95413393ef67
7038120 Update Auto Installer to use CUD
Darren Kenny <Darren.Kenny@Oracle.COM>
parents:
1087
diff
changeset
|
706 |
"Accept": "text/plain,multipart/alternative"} |
994
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
707 |
http_conn.request("POST", file_path, params, http_headers) |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
708 |
else: |
994
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
709 |
http_conn.request("GET", file_path) |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
710 |
|
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
711 |
except httplib.InvalidURL: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
712 |
AIGM_LOG.post(AILog.AI_DBGLVL_ERR, |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
713 |
"%s is not valid URL", address) |
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:
994
diff
changeset
|
714 |
return None, -1, None |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
715 |
except StandardError, err: |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
716 |
msg = "Connection to %s failed (%s)" % (address, err) |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
717 |
AIGM_LOG.post(AILog.AI_DBGLVL_ERR, |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
718 |
"%s", msg) |
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:
994
diff
changeset
|
719 |
return None, -1, None |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
720 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
721 |
http_response = http_conn.getresponse() |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
722 |
url_content = http_response.read() |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
723 |
http_status = http_response.status |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
724 |
http_conn.close() |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
725 |
|
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:
994
diff
changeset
|
726 |
return url_content, http_status, http_response.getheader("Content-Type") |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
727 |
|
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
728 |
|
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
729 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
994
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
730 |
def ai_get_requested_criteria_list(xml_file): |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
731 |
""" Description: |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
732 |
List of requested criteria is extracted from given the XML file |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
733 |
|
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
734 |
If the format of the XML file is validated, then the information |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
735 |
is extracted without using an XML parser. This is just an interim |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
736 |
solution. |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
737 |
|
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
738 |
todo: Switch to DC XML validator - bug 12494 |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
739 |
|
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
740 |
The format of the criteria file before the protocol change is as |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
741 |
follows: |
994
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
742 |
|
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
743 |
<CriteriaList> |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
744 |
<Version Number="0.5"> |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
745 |
<Criteria Name="MEM"> |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
746 |
<Criteria Name="arch"> |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
747 |
... |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
748 |
</CriteriaList> |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
749 |
|
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
750 |
Parameters: |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
751 |
xml_file - XML file with criteria |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
752 |
|
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
753 |
Returns: |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
754 |
list of criteria |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
755 |
""" |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
756 |
|
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
757 |
# '\n' is removed in order to safely use re module |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
758 |
crit_required = xml_file.replace('\n', '').split("<Criteria Name=\"")[1:] |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
759 |
|
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
760 |
# Extract criteria names |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
761 |
for i in range(len(crit_required)): |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
762 |
crit_required[i] = re.sub(r"\"/>.*$", "", crit_required[i]) |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
763 |
AIGM_LOG.post(AILog.AI_DBGLVL_INFO, |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
764 |
"Required criteria %d: %s", i + 1, crit_required[i]) |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
765 |
|
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
766 |
return crit_required |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
767 |
|
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
768 |
|
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
769 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
770 |
def ai_do_compatibility(service_name, known_criteria): |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
771 |
""" Description: retrieve the manifest via compatibility mechanisms |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
772 |
|
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
773 |
Parameters: |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
774 |
service_name - requested service name |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
775 |
known_criteria - the known criteria for the system. |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
776 |
|
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
777 |
Returns: |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
778 |
the retrieved manifest |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
779 |
return code: 0 - Success, -1 - Failure |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
780 |
""" |
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:
994
diff
changeset
|
781 |
xml_criteria, ret, ctype = ai_get_http_file(service_name, None, |
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:
994
diff
changeset
|
782 |
"/manifest.xml", "GET", None) |
994
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
783 |
if ret != httplib.OK: |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
784 |
AIGM_LOG.post(AILog.AI_DBGLVL_ERR, |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
785 |
"Could not obtain criteria list from %s, ret=%d", |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
786 |
service_name, ret) |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
787 |
return None, ret |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
788 |
|
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
789 |
# extract the required criteria list |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
790 |
criteria_required = ai_get_requested_criteria_list(xml_criteria) |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
791 |
|
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
792 |
# Fill in dictionary with criteria name-value pairs |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
793 |
AIGM_LOG.post(AILog.AI_DBGLVL_INFO, "List of criteria to be sent:") |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
794 |
|
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
795 |
ai_crit_response = {} |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
796 |
for criteria in criteria_required: |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
797 |
if known_criteria.get(criteria, None): |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
798 |
ai_crit_response[criteria] = known_criteria[criteria] |
994
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
799 |
AIGM_LOG.post(AILog.AI_DBGLVL_INFO, |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
800 |
" %s=%s", criteria, ai_crit_response[criteria]) |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
801 |
|
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
802 |
# Send back filled in list of criteria to server |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
803 |
AIGM_LOG.post(AILog.AI_DBGLVL_INFO, |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
804 |
"Sending list of criteria, asking for manifest:") |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
805 |
AIGM_LOG.post(AILog.AI_DBGLVL_INFO, |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
806 |
" HTTP POST %s %s", ai_crit_response, service_name) |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
807 |
|
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:
994
diff
changeset
|
808 |
ai_manifest, ret, ctype = ai_get_http_file(service_name, None, |
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:
994
diff
changeset
|
809 |
"/manifest.xml", 'POST', |
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:
994
diff
changeset
|
810 |
ai_crit_response) |
994
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
811 |
|
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
812 |
return ai_manifest, ret |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
813 |
|
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
814 |
|
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
815 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
816 |
def parse_cli(cli_opts_args): |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
817 |
""" main application |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
818 |
""" |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
819 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
820 |
if len(cli_opts_args) == 0: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
821 |
usage() |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
822 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
823 |
opts_args = cli_opts_args[1:] |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
824 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
825 |
try: |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
826 |
opts = getopt.getopt(opts_args, "c:d:ehlo:p:s:")[0] |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
827 |
except getopt.GetoptError: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
828 |
AIGM_LOG.post(AILog.AI_DBGLVL_ERR, |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
829 |
"Invalid options or arguments provided") |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
830 |
usage() |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
831 |
|
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
832 |
criteria_list = list() |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
833 |
service_list = None |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
834 |
manifest_file = None |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
835 |
profile_dir = None |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
836 |
list_criteria_only = False |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
837 |
no_default = False |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
838 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
839 |
for option, argument in opts: |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
840 |
if option == "-c": |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
841 |
criteria_list.append(argument) |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
842 |
elif option == "-s": |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
843 |
service_list = argument |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
844 |
elif option == "-o": |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
845 |
manifest_file = argument |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
846 |
elif option == "-d": |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
847 |
AIGM_LOG.set_debug_level(int(argument)) |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
848 |
elif option == "-l": |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
849 |
list_criteria_only = True |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
850 |
elif option == "-p": |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
851 |
profile_dir = argument |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
852 |
elif option == "-e": |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
853 |
no_default = True |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
854 |
elif option == "-h": |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
855 |
usage() |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
856 |
|
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
857 |
if service_list is None or manifest_file is None or profile_dir is None: |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
858 |
AIGM_LOG.post(AILog.AI_DBGLVL_ERR, |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
859 |
"Invalid options or arguments provided") |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
860 |
usage() |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
861 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
862 |
AIGM_LOG.post(AILog.AI_DBGLVL_INFO, |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
863 |
"Service list: %s", service_list) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
864 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
865 |
AIGM_LOG.post(AILog.AI_DBGLVL_INFO, |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
866 |
"Manifest file: " + manifest_file) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
867 |
|
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
868 |
AIGM_LOG.post(AILog.AI_DBGLVL_INFO, |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
869 |
"Profile directory: " + profile_dir) |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
870 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
871 |
if len(criteria_list) > 0: |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
872 |
AIGM_LOG.post(AILog.AI_DBGLVL_INFO, |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
873 |
"Criteria list: " + str(criteria_list)) |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
874 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
875 |
ai_criteria_known = {} |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
876 |
|
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
877 |
# If criteria specified on the command line, use that as |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
878 |
# our known criteria, otherwise get criteria from system. |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
879 |
if len(criteria_list) > 0: |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
880 |
for entry in criteria_list: |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
881 |
entries = entry.partition("=") |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
882 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
883 |
if entries[1]: |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
884 |
if not entries[0]: |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
885 |
raise ValueError(_("Missing criteria name in '%s'\n") % |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
886 |
entry) |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
887 |
elif entries[0].lower() in ai_criteria_known: |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
888 |
raise ValueError(_("Duplicate criteria: '%s'\n") % |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
889 |
entries[0]) |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
890 |
elif not entries[2]: |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
891 |
raise ValueError(_("Missing value for criteria '%s'\n") % |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
892 |
entries[0]) |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
893 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
894 |
if entries[0] not in AI_CRITERIA_SUPPORTED: |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
895 |
raise ValueError(_("Unsupported criteria: '%s'\n") % |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
896 |
entries[0]) |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
897 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
898 |
ai_criteria_known[entries[0].lower()] = entries[2] |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
899 |
else: |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
900 |
raise ValueError(_("Criteria must be of the form " |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
901 |
"<criteria>=<value>\n")) |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
902 |
else: |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
903 |
# Obtain all available information about client |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
904 |
for key in AI_CRITERIA_SUPPORTED.keys(): |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
905 |
if AI_CRITERIA_SUPPORTED[key][0] 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
|
906 |
ai_crit = AI_CRITERIA_SUPPORTED[key][0]() |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
907 |
if ai_crit.is_known(): |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
908 |
ai_criteria_known[key] = ai_crit.get() |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
909 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
910 |
# List all criteria which client can understand and provide |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
911 |
AIGM_LOG.post(AILog.AI_DBGLVL_INFO, |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
912 |
"Client can supply following criteria") |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
913 |
for key in ai_criteria_known.keys(): |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
914 |
AIGM_LOG.post(AILog.AI_DBGLVL_INFO, |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
915 |
" %s=%s, '%s'", key, ai_criteria_known[key], |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
916 |
AI_CRITERIA_SUPPORTED[key][1]) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
917 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
918 |
# if "-l" option was provided, list known criteria and exit |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
919 |
if list_criteria_only: |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
920 |
print "Client can supply the following criteria" |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
921 |
print "----------------------------------------" |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
922 |
index = 0 |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
923 |
for key in ai_criteria_known.keys(): |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
924 |
index += 1 |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
925 |
print " [%d] %s=%s (%s)" % (index, key, |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
926 |
ai_criteria_known[key], |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
927 |
AI_CRITERIA_SUPPORTED[key][1]) |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
928 |
return 0 |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
929 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
930 |
# |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
931 |
# Go through the list of services. |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
932 |
# Contact each of them and try to obtain valid manifest. |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
933 |
# |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
934 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
935 |
AIGM_LOG.post(AILog.AI_DBGLVL_INFO, |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
936 |
"Starting to contact AI services provided by %s", |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
937 |
service_list) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
938 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
939 |
ai_manifest_obtained = False |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
940 |
try: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
941 |
service_list_fh = open(service_list, 'r') |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
942 |
except IOError: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
943 |
AIGM_LOG.post(AILog.AI_DBGLVL_ERR, |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
944 |
"Could not open %s file", service_list) |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
945 |
return 2 |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
946 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
947 |
for ai_service in service_list_fh.readlines(): |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
948 |
service = ai_service.strip() |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
949 |
(ai_service, ai_port, ai_name) = service.split(':') |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
950 |
ai_service += ':' + str(ai_port) |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
951 |
AIGM_LOG.post(AILog.AI_DBGLVL_INFO, |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
952 |
"AI service: %s", ai_service) |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
953 |
AIGM_LOG.post(AILog.AI_DBGLVL_INFO, |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
954 |
"AI service name: %s", ai_name) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
955 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
956 |
AIGM_LOG.post(AILog.AI_DBGLVL_INFO, |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
957 |
" HTTP POST cgi-bin/cgi_get_manifest.py?service=%s", |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
958 |
ai_service) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
959 |
|
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:
994
diff
changeset
|
960 |
# invoke CGI script to get manifest, profiles |
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:
994
diff
changeset
|
961 |
http_resp, ret, content_type = \ |
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:
994
diff
changeset
|
962 |
ai_get_http_file(ai_service, ai_name, |
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:
994
diff
changeset
|
963 |
"/cgi-bin/cgi_get_manifest.py", |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
964 |
'POST', ai_criteria_known, |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
965 |
no_default=no_default) |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
966 |
# |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
967 |
# If valid manifest was provided, it is not necessary |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
968 |
# to connect next AI service, |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
969 |
# |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
970 |
if ret == httplib.OK: |
1151
95413393ef67
7038120 Update Auto Installer to use CUD
Darren Kenny <Darren.Kenny@Oracle.COM>
parents:
1087
diff
changeset
|
971 |
if content_type == 'text/xml': # old format |
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:
994
diff
changeset
|
972 |
ai_manifest = http_resp |
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:
994
diff
changeset
|
973 |
ai_manifest_obtained = True |
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:
994
diff
changeset
|
974 |
AIGM_LOG.post(AILog.AI_DBGLVL_INFO, |
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:
994
diff
changeset
|
975 |
"%s AI service provided single XML file - " |
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:
994
diff
changeset
|
976 |
"assumed to be AI manifest." % ai_service) |
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:
994
diff
changeset
|
977 |
break |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
978 |
AIGM_LOG.post(AILog.AI_DBGLVL_INFO, |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
979 |
"%s AI service provided valid manifest", |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
980 |
ai_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:
994
diff
changeset
|
981 |
# prepend content type header for MIME boundary |
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:
994
diff
changeset
|
982 |
# Content-Type: multipart/mixed; boundary= ... |
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:
994
diff
changeset
|
983 |
mime_response = "Content-Type: %s\n%s" % (content_type, http_resp) |
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:
994
diff
changeset
|
984 |
# by design, response is MIME-encoded, multipart |
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:
994
diff
changeset
|
985 |
if mime_response is not None: |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
986 |
# delete any profiles from previous runs |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
987 |
cleanup_earlier_run(profile_dir) |
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:
994
diff
changeset
|
988 |
# parse the MIME response |
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:
994
diff
changeset
|
989 |
parse = Parser() |
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:
994
diff
changeset
|
990 |
msg = parse.parsestr(mime_response) |
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:
994
diff
changeset
|
991 |
# handle each self-identifying part |
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:
994
diff
changeset
|
992 |
for imsg in msg.walk(): |
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:
994
diff
changeset
|
993 |
# write out manifest, any profiles, console messages |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
994 |
if handle_mime_payload(imsg, manifest_file, profile_dir): |
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:
994
diff
changeset
|
995 |
ai_manifest_obtained = True |
1151
95413393ef67
7038120 Update Auto Installer to use CUD
Darren Kenny <Darren.Kenny@Oracle.COM>
parents:
1087
diff
changeset
|
996 |
if ai_manifest_obtained: # manifest written by MIME handler |
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:
994
diff
changeset
|
997 |
service_list_fh.close() |
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:
994
diff
changeset
|
998 |
return 0 |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
999 |
else: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
1000 |
AIGM_LOG.post(AILog.AI_DBGLVL_WARN, |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
1001 |
"%s AI service did not provide a valid manifest, " \ |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
1002 |
"ret=%d", ai_service, ret) |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
1003 |
AIGM_LOG.post(AILog.AI_DBGLVL_WARN, |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
1004 |
"Checking compatibility mechanism.") |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
1075
diff
changeset
|
1005 |
ai_manifest, ret = ai_do_compatibility(ai_service, |
994
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
1006 |
ai_criteria_known) |
07af9c520fb7
7016997 new ISO install clients can not get a valid manifest for services on builds 157 & 158
John Fischer <John.Fischer@Sun.COM>
parents:
992
diff
changeset
|
1007 |
|
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
1008 |
if ret == httplib.OK: |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
1009 |
AIGM_LOG.post(AILog.AI_DBGLVL_WARN, |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
1010 |
"Compatibility mechanism provided a valid " \ |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
1011 |
"manifest.") |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
1012 |
ai_manifest_obtained = True |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
1013 |
break |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
1014 |
else: |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
1015 |
AIGM_LOG.post(AILog.AI_DBGLVL_WARN, |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
1016 |
"Compatibility mechanism did not provide valid" \ |
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
1017 |
" manifest, ret=%d", ret) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
1018 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
1019 |
service_list_fh.close() |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
1020 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
1021 |
if not ai_manifest_obtained: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
1022 |
AIGM_LOG.post(AILog.AI_DBGLVL_ERR, |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
1023 |
"None of contacted AI services provided valid manifest") |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
1024 |
if no_default: |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
1025 |
# If a default manifest is not requested, its OK if we didn't |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
1026 |
# obtain a manifest, return 0. |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
1027 |
return 0 |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
1028 |
else: |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
1029 |
return 2 |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
1030 |
|
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
1031 |
# Save the manifest |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
1032 |
AIGM_LOG.post(AILog.AI_DBGLVL_INFO, |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
1033 |
"Saving manifest to %s", manifest_file) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
1034 |
|
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
1035 |
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:
994
diff
changeset
|
1036 |
with open(manifest_file, 'w') as fh_manifest: |
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:
994
diff
changeset
|
1037 |
fh_manifest.write(ai_manifest) |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
1038 |
except IOError: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
1039 |
AIGM_LOG.post(AILog.AI_DBGLVL_ERR, |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
1040 |
"Could not open %s for saving obtained manifest", |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
1041 |
manifest_file) |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
1042 |
return 2 |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
1043 |
|
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:
994
diff
changeset
|
1044 |
return 0 |
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:
994
diff
changeset
|
1045 |
|
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:
994
diff
changeset
|
1046 |
|
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:
994
diff
changeset
|
1047 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
1048 |
def handle_mime_payload(msg, manifest_file, profile_dir): |
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:
994
diff
changeset
|
1049 |
""" Given a MIME part of the manifest locator response, |
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:
994
diff
changeset
|
1050 |
identify it and handle appropriately |
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:
994
diff
changeset
|
1051 |
|
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:
994
diff
changeset
|
1052 |
Args: |
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:
994
diff
changeset
|
1053 |
msg - message object holding contents of one MIME part |
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:
994
diff
changeset
|
1054 |
manifest_file - manifest destination |
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:
994
diff
changeset
|
1055 |
Returns True if an AI manifest was found, False otherwise |
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:
994
diff
changeset
|
1056 |
Effects: write a manifest file, write any profile files, log and display |
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:
994
diff
changeset
|
1057 |
manifest locator CGI script text messages |
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:
994
diff
changeset
|
1058 |
""" |
1151
95413393ef67
7038120 Update Auto Installer to use CUD
Darren Kenny <Darren.Kenny@Oracle.COM>
parents:
1087
diff
changeset
|
1059 |
wrote_manifest = False # when manifest is found, set to True |
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:
994
diff
changeset
|
1060 |
payload = msg.get_payload() |
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:
994
diff
changeset
|
1061 |
|
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:
994
diff
changeset
|
1062 |
# XML received - either manifest or profile |
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:
994
diff
changeset
|
1063 |
if msg.get_content_type() == "text/xml": |
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:
994
diff
changeset
|
1064 |
# identify manifest from unique attachment name |
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:
994
diff
changeset
|
1065 |
if msg.get_filename() == AI_MANIFEST_ATTACHMENT_NAME: |
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:
994
diff
changeset
|
1066 |
try: |
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:
994
diff
changeset
|
1067 |
with open(manifest_file, 'w') as mfp: |
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:
994
diff
changeset
|
1068 |
mfp.write(payload) |
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:
994
diff
changeset
|
1069 |
wrote_manifest = True |
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:
994
diff
changeset
|
1070 |
AIGM_LOG.post(AILog.AI_DBGLVL_INFO, |
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:
994
diff
changeset
|
1071 |
'Wrote manifest: %s.' % manifest_file) |
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:
994
diff
changeset
|
1072 |
except IOError, err: |
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:
994
diff
changeset
|
1073 |
AIGM_LOG.post(AILog.AI_DBGLVL_ERR, |
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:
994
diff
changeset
|
1074 |
'failure writing manifest: ' + str(err)) |
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:
994
diff
changeset
|
1075 |
return wrote_manifest |
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:
994
diff
changeset
|
1076 |
|
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:
994
diff
changeset
|
1077 |
# not manifest, assume the attachment is a profile, and output it |
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:
994
diff
changeset
|
1078 |
pname = write_profile_file(msg.get_filename(), payload, |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
1079 |
profile_dir, SC_EXTENSION, |
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:
994
diff
changeset
|
1080 |
SC_PREFIX) |
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:
994
diff
changeset
|
1081 |
if pname: |
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:
994
diff
changeset
|
1082 |
AIGM_LOG.post(AILog.AI_DBGLVL_INFO, 'Wrote profile %s.' % pname) |
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:
994
diff
changeset
|
1083 |
|
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:
994
diff
changeset
|
1084 |
elif not msg.is_multipart(): |
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:
994
diff
changeset
|
1085 |
# log and display text messages from the locator CGI |
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:
994
diff
changeset
|
1086 |
# assuming any text not within an attachment goes to the console |
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:
994
diff
changeset
|
1087 |
AIGM_LOG.post(AILog.AI_DBGLVL_WARN, |
1151
95413393ef67
7038120 Update Auto Installer to use CUD
Darren Kenny <Darren.Kenny@Oracle.COM>
parents:
1087
diff
changeset
|
1088 |
_("Messages from AI server while locating manifest and profiles:") |
95413393ef67
7038120 Update Auto Installer to use CUD
Darren Kenny <Darren.Kenny@Oracle.COM>
parents:
1087
diff
changeset
|
1089 |
+ "\n" + payload) |
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:
994
diff
changeset
|
1090 |
return wrote_manifest |
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:
994
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:
609
diff
changeset
|
1092 |
|
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:
994
diff
changeset
|
1093 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
1094 |
def cleanup_earlier_run(profile_dir): |
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:
994
diff
changeset
|
1095 |
""" |
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:
994
diff
changeset
|
1096 |
From the designated profile output directory, |
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:
994
diff
changeset
|
1097 |
purge any profiles left over from a previous run. |
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:
994
diff
changeset
|
1098 |
""" |
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:
994
diff
changeset
|
1099 |
try: |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
1100 |
cleanlist = os.listdir(profile_dir) |
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:
994
diff
changeset
|
1101 |
except OSError, err: |
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:
994
diff
changeset
|
1102 |
if err.errno == ENOENT: # exists |
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:
994
diff
changeset
|
1103 |
return |
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:
994
diff
changeset
|
1104 |
raise |
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:
994
diff
changeset
|
1105 |
for fclean in cleanlist: |
1151
95413393ef67
7038120 Update Auto Installer to use CUD
Darren Kenny <Darren.Kenny@Oracle.COM>
parents:
1087
diff
changeset
|
1106 |
if fclean.startswith(SC_PREFIX): # uniquely identify profiles |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1151
diff
changeset
|
1107 |
os.unlink(os.path.join(profile_dir, fclean)) |
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:
994
diff
changeset
|
1108 |
|
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:
994
diff
changeset
|
1109 |
|
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:
994
diff
changeset
|
1110 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
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:
994
diff
changeset
|
1111 |
def write_profile_file(name, profile, outdir, extension, prefix): |
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:
994
diff
changeset
|
1112 |
""" |
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:
994
diff
changeset
|
1113 |
take a profile in a string and output it to a file at a given directory, |
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:
994
diff
changeset
|
1114 |
generating a unique name in the pattern: <prefix><name>NNNNN.<extension> |
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:
994
diff
changeset
|
1115 |
create directory if it doesn't exist |
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:
994
diff
changeset
|
1116 |
Args: |
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:
994
diff
changeset
|
1117 |
name - profile name |
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:
994
diff
changeset
|
1118 |
profile - profile text |
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:
994
diff
changeset
|
1119 |
outdir - directory to write profiles |
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:
994
diff
changeset
|
1120 |
prefix - prepend string to profile path |
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:
994
diff
changeset
|
1121 |
Return generated file name for debugging |
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:
994
diff
changeset
|
1122 |
Effect: one profile written |
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:
994
diff
changeset
|
1123 |
""" |
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:
994
diff
changeset
|
1124 |
try: |
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:
994
diff
changeset
|
1125 |
os.makedirs(outdir) |
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:
994
diff
changeset
|
1126 |
except OSError, err: |
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:
994
diff
changeset
|
1127 |
if err.errno != EEXIST: # exists |
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:
994
diff
changeset
|
1128 |
AIGM_LOG.post(AILog.AI_DBGLVL_ERR, |
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:
994
diff
changeset
|
1129 |
"Problem creating output directory for profiles: %s" % err) |
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:
994
diff
changeset
|
1130 |
return 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:
994
diff
changeset
|
1131 |
try: |
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:
994
diff
changeset
|
1132 |
if name[-len(extension):] == extension: |
1151
95413393ef67
7038120 Update Auto Installer to use CUD
Darren Kenny <Darren.Kenny@Oracle.COM>
parents:
1087
diff
changeset
|
1133 |
name = name[:-len(extension)] # strip ending .xml |
95413393ef67
7038120 Update Auto Installer to use CUD
Darren Kenny <Darren.Kenny@Oracle.COM>
parents:
1087
diff
changeset
|
1134 |
(fd, name) = tempfile.mkstemp(suffix=extension, |
95413393ef67
7038120 Update Auto Installer to use CUD
Darren Kenny <Darren.Kenny@Oracle.COM>
parents:
1087
diff
changeset
|
1135 |
prefix=prefix + name + '.', |
95413393ef67
7038120 Update Auto Installer to use CUD
Darren Kenny <Darren.Kenny@Oracle.COM>
parents:
1087
diff
changeset
|
1136 |
dir=outdir) |
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:
994
diff
changeset
|
1137 |
os.write(fd, profile) |
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:
994
diff
changeset
|
1138 |
os.close(fd) |
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:
994
diff
changeset
|
1139 |
except (OSError, IOError), err: |
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:
994
diff
changeset
|
1140 |
print >> sys.stderr, "ERROR: could not write profile: %s" % err |
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:
994
diff
changeset
|
1141 |
return 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:
994
diff
changeset
|
1142 |
return name |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
1143 |
|
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
1144 |
|
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
1145 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
1146 |
def main(): |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
1147 |
""" main program |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
1148 |
""" |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
1149 |
return(parse_cli(sys.argv)) |
232
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
1150 |
|
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
1151 |
|
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
1152 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
26cab3d8aac1
3477 Automated Installer needs support for obtaining AI and SC manifests
Jan Damborsky <jan.damborsky@sun.com>
parents:
diff
changeset
|
1153 |
if __name__ == "__main__": |
992
b19185e9da83
9538 AI webserver not restarting after server reboot
John Fischer <John.Fischer@Sun.COM>
parents:
649
diff
changeset
|
1154 |
gettext.install("ai", "/usr/lib/locale") |
649
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
1155 |
try: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
1156 |
RET_CODE = main() |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
1157 |
except StandardError: |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
1158 |
traceback.print_exc() |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
1159 |
sys.exit(99) |
ba353c37b287
12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents:
609
diff
changeset
|
1160 |
sys.exit(RET_CODE) |