[Erp5-report] r6445 - /umigumi/trunk/custom/dls_cd/home/dlsadmin/nexedi-dls/autoconf.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Apr 4 09:54:29 CEST 2006
Author: jerome
Date: Tue Apr 4 09:54:28 2006
New Revision: 6445
URL: http://svn.erp5.org?rev=6445&view=rev
Log:
Add room for slaves nodes in dhcpd.conf generation (+5 extra IP address)
Modified:
umigumi/trunk/custom/dls_cd/home/dlsadmin/nexedi-dls/autoconf.py
Modified: umigumi/trunk/custom/dls_cd/home/dlsadmin/nexedi-dls/autoconf.py
URL: http://svn.erp5.org/umigumi/trunk/custom/dls_cd/home/dlsadmin/nexedi-dls/autoconf.py?rev=6445&r1=6444&r2=6445&view=diff
==============================================================================
--- umigumi/trunk/custom/dls_cd/home/dlsadmin/nexedi-dls/autoconf.py (original)
+++ umigumi/trunk/custom/dls_cd/home/dlsadmin/nexedi-dls/autoconf.py Tue Apr 4 09:54:28 2006
@@ -111,10 +111,16 @@
os.chmod(real_path, mode)
os.chown(real_path, 0, 0)
+class TemplateNotFound(Exception):
+ """Raised when a template is not found."""
+
def getTemplate(path):
if path.startswith('/'):
path = path[1:]
- f = open(os.path.join('/home/dlsadmin/nexedi-dls/templates', path))
+ template_path = os.path.join('/home/dlsadmin/nexedi-dls/templates', path)
+ if not os.path.exists(template_path):
+ raise TemplateNotFound, template_path
+ f = open(template_path, 'r')
s = f.read()
f.close()
return s
@@ -516,6 +522,8 @@
template = getTemplate('/etc/dhcpd.conf')
# uses informations from the DNS part (nb0)
+ # XXX this dhcp.conf only supports full class networks
+ # XXX this dhcp.conf only supports cluster if master is X.X.X.1
# calculate subnet
subnet = ""
@@ -551,12 +559,13 @@
big1 = hostcut + str(bigdigit)
small2 = hostcut + str(smalldigit)
- # smallest ip in first range (either 1 or 2)
+ # smallest ip in first range (either 1 or number of nodes)
small1 = hostcut + '1'
if host.ip_address == small1 :
- small1 = hostcut + '2'
+ # XXX always keep 5 ip address, in case ...
+ small1 = "%s.%s" % (hostcut, len(group.host_list)+5)
serverfound1 = 1
-
+
# biggest ip in second range (either 253 or 252)
big2 = hostcut + '253'
if host.ip_address == big2 :
@@ -580,13 +589,22 @@
gate_line = 'option routers %s;' % host.gateway
writeConfigFile('/etc/dhcpd.conf',
- 0644,
- template % (host.netmask,host.broadcast_address,gate_line,host.ip_address,host.domainname,subnet,host.netmask,range1,range2,host.ip_address))
+ 0644,
+ template % ( host.netmask,
+ host.broadcast_address,
+ gate_line,
+ host.ip_address,
+ host.domainname,
+ subnet,
+ host.netmask,
+ range1,
+ range2,
+ host.ip_address ))
os.system('/etc/init.d/dhcpd restart')
## end DHCP
-
+
# /etc/sysconfig/balance
template = getTemplate('/etc/sysconfig/balance')
port_list = []
@@ -606,13 +624,17 @@
# umiboot files
args = {
'ip_address' : host.ip_address,
- 'base_dn' : my_base_dn,
+ 'base_dn' : master_base_dn,
'fqdn' : my_fqdn,
}
for f in ('/etc/exports', '/etc/fstab', '/etc/inittab', '/etc/ldap.conf', \
'/etc/modules.conf', '/etc/ntp.conf', '/etc/raidtab',
'/sbin/depmod',):
- template = getTemplate('/etc/umiboot/common' + f)
+ try:
+ template = getTemplate('/etc/umiboot/common' + f)
+ except TemplateNotFound :
+ print >> sys.stderr, "Template for %s not found" % f
+ continue
if f.startswith('/sbin'):
mode=0755
else:
@@ -628,7 +650,12 @@
'gateway' : h.gateway,
}
if h.dls_type == 'slave':
- template = getTemplate('/etc/umiboot/host' + f)
+ try:
+ template = getTemplate('/etc/umiboot/host' + f)
+ except TemplateNotFound :
+ print >> sys.stderr, "Template for %s not found" % f
+ continue
+
if f.startswith('/sbin'):
mode=0755
else:
@@ -674,4 +701,5 @@
''' % (master.hostname, master.ip_address, host.dls_type, host.host_id, host.ip_address, host.network_device))
finally:
f.close()
-os.chmod("/home/dlsadmin/nexedi-dls/.dlscd", 0600)
+os.chmod("/home/dlsadmin/nexedi-dls/.dlscd", 0600)
+
More information about the Erp5-report
mailing list