/[smeserver]/cdrom.image/sme9/product/installclasses/server.py
ViewVC logotype

Contents of /cdrom.image/sme9/product/installclasses/server.py

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.12 - (show annotations) (download) (as text)
Thu Apr 17 00:30:37 2014 UTC (10 years, 8 months ago) by wellsi
Branch: MAIN
CVS Tags: HEAD
Changes since 1.11: +1 -1 lines
Content type: text/x-python
Error occurred while calculating annotation data.
Use RAID 1 for boot, correct syntax [SME:7529]

1 #
2 # server.py
3 #
4
5 import os, iutil
6
7 import yuminstall
8
9 from installclass import BaseInstallClass
10 from kickstart import AnacondaKSScript as Script
11
12 from flags import flags
13 from constants import *
14 from pykickstart.constants import *
15 from storage.partspec import *
16
17 import gettext
18 _ = lambda x: gettext.ldgettext("anaconda", x)
19
20 import logging
21 log = logging.getLogger("anaconda")
22
23 class Script:
24 def __repr__(self):
25 str = ("(s: '%s' i: %s c: %d)") % \
26 (self.script, self.interp, self.inChroot)
27 return string.replace(str, "\n", "|")
28
29 def __init__(self, script, interp = '/bin/sh', inChroot = 1, logfile = None):
30 self.script = script
31 self.interp = interp
32 self.inChroot = inChroot
33 self.logfile = logfile
34
35 def run(self, chroot, serial, intf = None):
36 import tempfile
37 import os.path
38
39 if self.inChroot:
40 scriptRoot = chroot
41 else:
42 scriptRoot = "/"
43
44 (fd, path) = tempfile.mkstemp("", "sme-script-", scriptRoot + "/tmp")
45
46 os.write(fd, self.script)
47 os.close(fd)
48 os.chmod(path, 0700)
49
50 if self.logfile:
51 if self.inChroot:
52 messages = "%s/%s" % (scriptRoot, self.logfile)
53 else:
54 messages = self.logfile
55
56 d = os.path.dirname(messages)
57 if not os.path.exists(d):
58 os.makedirs(d)
59 elif serial:
60 messages = "%s.log" % path
61 else:
62 messages = "/dev/tty3"
63
64 if intf:
65 intf.suspend()
66 rc = iutil.execWithRedirect(self.interp, ["/tmp/%s" % os.path.basename(path)],
67 stdin = messages, stdout = messages, stderr = messages,
68 root = scriptRoot)
69 if intf:
70 intf.resume()
71
72 if rc != 0:
73 log.error("ERROR - Error code %s encountered running a sme script", rc)
74
75 os.unlink(path)
76 if serial or self.logfile:
77 os.chmod("%s" % messages, 0600)
78
79 class InstallClass(BaseInstallClass):
80 # make sure the translation data is read from product.img tree
81 if os.path.isdir("/tmp/product/locale"):
82 import gettext
83 gettext.bindtextdomain("comps", localedir="/tmp/product/locale")
84 _ = lambda x: gettext.ldgettext("comps", x)
85 N_ = lambda x: x
86
87 # name has underscore used for mnemonics, strip if you dont need it
88 id = "server"
89 name = N_("SME Server")
90 _description = N_("The default installation of %s is a basic server install. "
91 "You can optionally select a different set of software "
92 "now.")
93 sortPriority = 90000
94 hidden = 0
95
96 bootloaderTimeoutDefault = 5
97 tasks = [(N_("Basic Server"),
98 ["base", "core"]),
99 (N_("Minimal"),
100 ["core"])]
101
102 def _get_description(self):
103 return gettext.ldgettext("comps", self._description) % self._descriptionFields
104 description = property(_get_description)
105
106 def postAction(self, anaconda):
107 if anaconda.id.getUpgrade():
108 w = anaconda.intf.waitWindow(_("Post Upgrade"),
109 _("Performing post-upgrade configuration"))
110 log.info("Running post-upgrade action script")
111 script = Script( "#!/bin/sh\n/sbin/rsyslogd; sleep 2; /sbin/e-smith/signal-event post-upgrade; touch /forcequotacheck\n" )
112 else:
113 w = anaconda.intf.waitWindow(_("Post Installation"),
114 _("Performing post-installation configuration"))
115 log.info("Running post-install action script")
116 script = Script( "#!/bin/sh\n/sbin/rsyslogd; sleep 2; /sbin/e-smith/signal-event post-install; touch /forcequotacheck\n" )
117
118 script.run(anaconda.rootPath, flags.serial, anaconda.intf)
119 if anaconda.intf is not None:
120 w.pop()
121
122 BaseInstallClass.postAction(self, anaconda)
123
124 def setSteps(self, anaconda):
125 BaseInstallClass.setSteps(self, anaconda)
126 anaconda.dispatch.skipStep("welcome")
127 #anaconda.dispatch.skipStep("filtertype")
128 anaconda.dispatch.skipStep("network")
129 anaconda.dispatch.skipStep("accounts")
130 anaconda.dispatch.skipStep("partition")
131 anaconda.dispatch.skipStep("tasksel")
132 anaconda.dispatch.skipStep("firstboot")
133
134 def setDefaultPartitioning(self, storage, platform):
135 autorequests = []
136
137 # If user specifies "nolvm", then asVol = False; otherwise, asVol = True
138 # If asVol = False below, then LVM won't be used
139
140 asVol_flag = not flags.cmdline.has_key("nolvm")
141
142 # If user specifies "noraid", then useRAID = False; otherwise, useRAID = True
143 # If useRAID = False below, then RAID1 won't be used
144
145 if flags.cmdline.has_key("noraid"):
146 raidLevel = "none"
147 else:
148 raidLevel = "1"
149 if flags.cmdline.has_key("raid") and flags.cmdline["raid"] in ["none","0","1","5","6"]:
150 raidLevel = flags.cmdline["raid"]
151
152 fstype = "ext4"
153 if flags.cmdline.has_key("ext3"):
154 fstype = "ext3"
155
156 # /boot
157 # Manually specify fstype = ext3/ext4 and size = 250 MB
158 # (Platform default is fstype ext4 and size = 500 MB)
159
160 autorequests.append(PartSpec(mountpoint="/boot", fstype=fstype, size=250, raidLevel="1",
161 weight=platform.weight(mountpoint="/boot")))
162
163 # /
164 # Manually specify fstype = ext3/ext4 and size = 2048 MB, but growable
165
166 autorequests.append(PartSpec(mountpoint="/", fstype=fstype, size=2048, raidLevel=raidLevel,
167 grow=True, asVol=asVol_flag))
168
169 # swap
170 # Manually specify fstype = swap and minswap < size < maxswap (growable)
171
172 (minswap, maxswap) = iutil.swapSuggestion()
173 autorequests.append(PartSpec(fstype="swap", size=minswap, maxSize=maxswap, raidLevel=raidLevel,
174 grow=True, asVol=asVol_flag))
175
176 storage.autoPartitionRequests = autorequests
177
178 def setInstallData(self, anaconda):
179 BaseInstallClass.setInstallData(self, anaconda)
180 anaconda.id.security.setSELinux(SELINUX_DISABLED)
181 self.setDefaultPartitioning(
182 anaconda.id.storage,
183 anaconda.platform)
184
185 def productMatches(self, oldprod):
186 log.info("oldprod %s productName %s" % (oldprod, productName));
187 if oldprod is None:
188 return False
189
190 if oldprod.startswith(productName):
191 return True
192
193 productUpgrades = {
194 "SME Server": ("Mitel Networks", "SME Server", "e-smith server", ),
195 }
196
197 if productUpgrades.has_key(productName):
198 acceptable = productUpgrades[productName]
199 else:
200 acceptable = ()
201
202 for p in acceptable:
203 if oldprod.startswith(p):
204 return True
205
206 return False
207
208 def versionMatches(self, oldver):
209 log.info("oldver %s productVersion %s" % (oldver, productVersion));
210 return True;
211
212 def getBackend(self):
213 return yuminstall.YumBackend
214
215 def __init__(self):
216 BaseInstallClass.__init__(self)

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed