summaryrefslogtreecommitdiffstats
path: root/setup.py
blob: 05e0ab924c5979c4d0d472f1144210c7b5ce2309 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
#!/usr/bin/python

import sys
import os.path
from distutils.core import setup, Extension
import string
import cobbler.yaml as yaml
import Cheetah.Template as Template

VERSION = "1.3.2"
SHORT_DESC = "Network Boot and Update Server"
LONG_DESC = """
Cobbler is a network boot and update server.  Cobbler supports PXE, provisioning virtualized images, and reinstalling existing Linux machines.  The last two modes require a helper tool called 'koan' that integrates with cobbler.  Cobbler's advanced features include importing distributions from DVDs and rsync mirrors, kickstart templating, integrated yum mirroring, and built-in DHCP/DNS Management.  Cobbler also has a Python and XMLRPC API for integration with other applications.
"""
TEMPLATES_DIR = "installer_templates"
DEFAULTS = os.path.join(TEMPLATES_DIR, "defaults")
MODULES_TEMPLATE = os.path.join(TEMPLATES_DIR, "modules.conf.template")
SETTINGS_TEMPLATE = os.path.join(TEMPLATES_DIR, "settings.template")
OUTPUT_DIR = "config"

# =========================================================        
def templatify(template, answers, output):
    t = Template.Template(file=template, searchList=answers)
    open(output,"w").write(t.respond())

def gen_config():
    defaults = {}
    data = yaml.loadFile(DEFAULTS).next()
    defaults.update(data)
    templatify(MODULES_TEMPLATE, defaults, os.path.join(OUTPUT_DIR, "modules.conf"))
    templatify(SETTINGS_TEMPLATE, defaults, os.path.join(OUTPUT_DIR, "settings"))

if __name__ == "__main__":
        gen_config()
        # docspath="share/doc/koan-%s/" % VERSION
        bashpath = "/etc/bash_completion.d/"
        manpath  = "share/man/man1/"
        cobpath  = "/var/lib/cobbler/"
        backpath = "/var/lib/cobbler/backup/"
        trigpath = "/var/lib/cobbler/triggers/"
        etcpath  = "/etc/cobbler/"
        if os.path.exists("/etc/SuSE-release"):
            wwwconf  = "/etc/apache2/conf.d/"
        else:
            wwwconf  = "/etc/httpd/conf.d/"
        wwwpath  = "/var/www/cobbler/"
        wwwcon   = "/var/www/cobbler/webui/"
        initpath = "/etc/init.d/"
        logpath  = "/var/log/cobbler/"
        logpath2 = "/var/log/cobbler/kicklog"
        logpath3 = "/var/log/cobbler/syslog"
        logpath4 = "/var/log/httpd/cobbler"
        snippets = "/var/lib/cobbler/snippets"
        vl_kick  = "/var/lib/cobbler/kickstarts"
        wwwtmpl  = "/usr/share/cobbler/webui_templates/"
        vw_localmirror = "/var/www/cobbler/localmirror"
        vw_kickstarts  = "/var/www/cobbler/kickstarts"
        vw_kickstarts_sys  = "/var/www/cobbler/kickstarts_sys"
        vw_repomirror = "/var/www/cobbler/repo_mirror"
        vw_ksmirror   = "/var/www/cobbler/ks_mirror"
        vw_ksmirrorc  = "/var/www/cobbler/ks_mirror/config"
        vw_images     = "/var/www/cobbler/images"
        vw_distros    = "/var/www/cobbler/distros"
        vw_systems    = "/var/www/cobbler/systems"
        vw_profiles   = "/var/www/cobbler/profiles"
        vw_links      = "/var/www/cobbler/links"
        zone_templates = "/etc/cobbler/zone_templates"
        itemplates    = "/usr/share/cobbler/installer_templates"
        tftp_cfg      = "/tftpboot/pxelinux.cfg"
        tftp_images   = "/tftpboot/images"
        rotpath       = "/etc/logrotate.d"
        # cgipath       = "/var/www/cgi-bin/cobbler"
        modpython     = "/var/www/cobbler/web"
        modpythonsvc  = "/var/www/cobbler/svc"

        # hack to bundle jquery until we have packaging guidelines to avoid JS bundling
        # bundling is evil, but temporary.

        def file_slurper(arg, dirname, fnames):
           # FIXME: shell glob would be simpler
           for fn in fnames:
               fn2 = os.path.join(dirname,fn)
               if os.path.isfile(fn2):
                   if not fn2 in arg:
                       arg.append(fn2)
               else:
                   # don't recurse
                   fnames.remove(fn)
 
        jui_files = []
        jui_files2 = []
        jui_files3 = []
        jui_files4 = []
        jui_files5 = []
        os.path.walk("./webui_content/jquery.ui/ui", file_slurper, jui_files)
        os.path.walk("./webui_content/jquery.ui/ui/i18n", file_slurper, jui_files2)
        os.path.walk("./webui_content/jquery.ui/themes", file_slurper, jui_files3)
        os.path.walk("./webui_content/jquery.ui/themes/flora", file_slurper, jui_files4)
        os.path.walk("./webui_content/jquery.ui/themes/flora/i", file_slurper, jui_files5)
        
        setup(
                name="cobbler",
                version = VERSION,
                author = "Michael DeHaan",
                author_email = "mdehaan@redhat.com",
                url = "http://cobbler.et.redhat.com/",
                license = "GPL",
                packages = [
                    "cobbler",
                    "cobbler/yaml",
                    "cobbler/modules", 
                    "cobbler/server", 
                    "cobbler/webui",
                ],
                scripts = [
                    "scripts/cobbler", 
                    "scripts/cobblerd", 
                    "scripts/cobbler-ext-nodes", 
                    "scripts/cobbler-completion",
                    "scripts/cobbler-setup",
                ],
                data_files = [ 
                                (modpython, ['scripts/index.py']),
                                (modpythonsvc, ['scripts/services.py']),
 
                                # miscellaneous config files
                                (rotpath,  ['config/cobblerd_rotate']),
                                (wwwconf,  ['config/cobbler.conf']),
                                (wwwconf,  ['config/cobbler_svc.conf']),
                                (cobpath,  ['config/completions']),
                                (cobpath,  ['config/cobbler_hosts']),
                                (etcpath,  ['config/modules.conf']),
                                (etcpath,  ['config/users.digest']),
                                (etcpath,  ['config/rsync.exclude']),
                                (etcpath,  ['config/users.conf']),
                                (etcpath,  ['config/acls.conf']),
                                (etcpath,  ['config/cheetah_macros']),
                                (initpath, ['config/cobblerd']),
                                (etcpath,  ['config/settings']),
                                # (bashpath, ['config/cobbler_bash']), 

                                # backups for upgrades
                                (backpath, []),

                                # bootloaders and syslinux support files
                                (cobpath,  ['loaders/elilo-3.8-ia64.efi']),
                                (cobpath,  ['loaders/menu.c32']),
                                (cobpath,  ['loaders/yaboot-1.3.14']),
                                ("/var/lib/cobbler/config/distros.d",  []),
                                ("/var/lib/cobbler/config/profiles.d", []),
                                ("/var/lib/cobbler/config/systems.d",  []),
                                ("/var/lib/cobbler/config/repos.d",    []),
                                ("/var/lib/cobbler/config/images.d",   []),

                                # sample kickstart files
                                (etcpath,  ['kickstarts/legacy.ks']),
                                (etcpath,  ['kickstarts/sample.ks']),
                                (etcpath,  ['kickstarts/sample_end.ks']),
                                (etcpath,  ['kickstarts/default.ks']),
                                (etcpath,  ['kickstarts/pxerescue.ks']),
                                
                                # seed files for debian
                                (etcpath,  ['kickstarts/sample.seed']),
 
                                # templates for DHCP, DNS, and syslinux configs
				(etcpath,  ['templates/dhcp.template']),
				(etcpath,  ['templates/dnsmasq.template']),
                                (etcpath,  ['templates/named.template']),
				(etcpath,  ['templates/pxedefault.template']),
				(etcpath,  ['templates/pxesystem.template']),
				(etcpath,  ['templates/pxesystem_s390x.template']),
				(etcpath,  ['templates/pxesystem_ia64.template']),
				(etcpath,  ['templates/pxesystem_ppc.template']),
				(etcpath,  ['templates/pxeprofile.template']),
				(etcpath,  ['templates/pxelocal.template']),
                                (etcpath,  ['templates/zone.template']),

                                # templates for power management
                                (etcpath, ['templates/power_apc_snmp.template']), 
                                (etcpath, ['templates/power_ipmilan.template']),
                                (etcpath, ['templates/power_bullpap.template']),     
                                (etcpath, ['templates/power_ipmitool.template']),
                                (etcpath, ['templates/power_drac.template']),        
                                (etcpath, ['templates/power_rsa.template']),
                                (etcpath, ['templates/power_ether_wake.template']),  
                                (etcpath, ['templates/power_wti.template']),
                                (etcpath, ['templates/power_ilo.template']),

                                # templates for /usr/bin/cobbler-setup
                                (itemplates, ['installer_templates/modules.conf.template']),
                                (itemplates, ['installer_templates/settings.template']),
                                (itemplates, ['installer_templates/defaults']),

                                # kickstart dir
                                (vl_kick,  []),

                                # useful kickstart snippets that we ship
                                (snippets, ['snippets/partition_select']),
                                (snippets, ['snippets/pre_partition_select']),
                                (snippets, ['snippets/main_partition_select']),
                                (snippets, ['snippets/post_install_kernel_options']),
                                (snippets, ['snippets/network_config']),
                                (snippets, ['snippets/pre_install_network_config']),
                                (snippets, ['snippets/post_install_network_config']),
                                (snippets, ['snippets/func_install_if_enabled']),
                                (snippets, ['snippets/func_register_if_enabled']),
                                (snippets, ['snippets/download_config_files']),

                                # documentation
                                (manpath,  ['docs/cobbler.1.gz']),

                                # logfiles
                                (logpath,  []),
                                (logpath2, []),
                                (logpath3, []),
				(logpath4, []),

                                # web page directories that we own
                                (vw_localmirror,    []),
                                (vw_kickstarts,     []),
                                (vw_kickstarts_sys, []),
                                (vw_repomirror,     []),
                                (vw_ksmirror,       []),
                                (vw_ksmirrorc,      []),
                                (vw_distros,        []),
                                (vw_images,         []),
                                (vw_systems,        []),
                                (vw_profiles,       []),
                                (vw_links,          []),

                                # zone-specific templates directory
                                (zone_templates,    []),

                                # tftp directories that we own
                                (tftp_cfg,          []),
                                (tftp_images,       []),

                                # Web UI templates for object viewing & modification
                                # FIXME: other templates to add as they are created.
                                # slurp in whole directory?

                                (wwwtmpl,           ['webui_templates/empty.tmpl']),
                                (wwwtmpl,           ['webui_templates/blank.tmpl']),
                                (wwwtmpl,           ['webui_templates/enoaccess.tmpl']),
                                (wwwtmpl,           ['webui_templates/distro_list.tmpl']),
                                (wwwtmpl,           ['webui_templates/distro_edit.tmpl']),
                                (wwwtmpl,           ['webui_templates/profile_list.tmpl']),
                                (wwwtmpl,           ['webui_templates/profile_edit.tmpl']),
                                (wwwtmpl,           ['webui_templates/system_list.tmpl']),
                                (wwwtmpl,           ['webui_templates/system_edit.tmpl']),
                                (wwwtmpl,           ['webui_templates/repo_list.tmpl']),
                                (wwwtmpl,           ['webui_templates/repo_edit.tmpl']),
                                (wwwtmpl,           ['webui_templates/image_list.tmpl']),
                                (wwwtmpl,           ['webui_templates/image_edit.tmpl']),

                                # Web UI common templates 
                                (wwwtmpl,           ['webui_templates/paginate.tmpl']),
                                (wwwtmpl,           ['webui_templates/message.tmpl']),
                                (wwwtmpl,           ['webui_templates/error_page.tmpl']),
                                (wwwtmpl,           ['webui_templates/master.tmpl']),
                                (wwwtmpl,           ['webui_templates/item.tmpl']),
                                (wwwtmpl,           ['webui_templates/index.tmpl']),

                                # Web UI kickstart file editing
                                (wwwtmpl,           ['webui_templates/ksfile_edit.tmpl']),
                                (wwwtmpl,           ['webui_templates/ksfile_new.tmpl']),
                                (wwwtmpl,           ['webui_templates/ksfile_list.tmpl']),

                                # Web UI support files
				(wwwcon,            ['docs/wui.html']),
                                (wwwcon,            ['docs/cobbler.html']),

                                #(wwwcon,           ['webui_content/icon_16_sync.png']),
                                #(wwwcon,           ['webui_content/list-expand.png']),
                                #(wwwcon,           ['webui_content/list-collapse.png']),
                                #(wwwcon,           ['webui_content/list-parent.png']),

                                (wwwcon,            ['webui_content/cobbler.js']),
                                (wwwcon,            ['webui_content/style.css']),
                                (wwwcon,            ['webui_content/logo-cobbler.png']),
                                (wwwcon,            ['webui_content/cobblerweb.css']),

                                # Directories to hold cobbler triggers
                                ("%sadd/distro/pre" % trigpath,      []),
                                ("%sadd/distro/post" % trigpath,     []),
                                ("%sadd/profile/pre" % trigpath,     []),
                                ("%sadd/profile/post" % trigpath,    []),
                                ("%sadd/system/pre" % trigpath,      []),
                                ("%sadd/system/post" % trigpath,     []),
                                ("%sadd/repo/pre" % trigpath,        []),
                                ("%sadd/repo/post" % trigpath,       []),
                                ("%sdelete/distro/pre" % trigpath,   []),
                                ("%sdelete/distro/post" % trigpath,  []),
                                ("%sdelete/profile/pre" % trigpath,  []),
                                ("%sdelete/profile/post" % trigpath, []),
                                ("%sdelete/system/pre" % trigpath,   []),
                                ("%sdelete/system/post" % trigpath,  []),
                                ("%sdelete/repo/pre" % trigpath,     []),
                                ("%sdelete/repo/post" % trigpath,    []),
                                ("%sdelete/repo/post" % trigpath,    []),
                                ("%sinstall/pre" % trigpath,         [ "triggers/status_pre.trigger"]),
                                ("%sinstall/post" % trigpath,        [ "triggers/status_post.trigger"]),
                                ("%ssync/pre" % trigpath,            []),
                                ("%ssync/post" % trigpath,           [ "triggers/restart-services.trigger" ])
                             ],
                description = SHORT_DESC,
                long_description = LONG_DESC
        )