Changeset 203 for trunk


Ignore:
Timestamp:
08/22/12 14:17:15 (12 years ago)
Author:
bas
Message:

added two new configuration options for client program, closes #17

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Changelog

    r200 r203  
     14.1.0:
     2  * Added two new configuration options for pxeconfig.conf file: closes #17
     3     - client_script_hook_add    : The script that must be run when we create
     4                                 a pxeconfig file for a host(s). This option
     5                                 replaces client_script_hook.
     6     - client_script_hook_remove : The script that must be run wehn we remove
     7                                 a pxeconfig file for a host(s)
     8
     9    Both options are useful for firewall setups. To open/close ports.
     10 
     11  Reported by: Ramon Bastiaans (SARA)
     12  Fixed by: Bas van der Vlies
     13
    1144.0.3:
    215  * Removed server_args from pxeconfig.xinetd example. Everything is set via
  • trunk/debian/changelog

    r200 r203  
     1pxeconfig (4.1.0-1) stable; urgency=low
     2
     3  * See Changelog
     4
     5 -- Bas van der Vlies <bas@sara.nl>  Wed, 22 Aug 2012 14:15:57 +0200
     6
    17pxeconfig (4.0.3-1) stable; urgency=low
    28
  • trunk/pxeconfig.conf

    r193 r203  
    22;pxe_config_dir    : ./pxelinux.cfg
    33;debug             : 0
    4 ;client_script_hook : /usr/sara/sbin/pxefirewall-pre-install.sh
    5 ;daemon_script_hook : /usr/sara/sbin/pxefirewall-post-install.sh
     4;client_script_hook_remove : /usr/sara/sbin/pxefirewall-pre-install.sh remove
     5;client_script_hook_add    : /usr/sara/sbin/pxefirewall-pre-install.sh add
     6;daemon_script_hook        : /usr/sara/sbin/pxefirewall-post-install.sh
    67
    78; Only set it when dynamic ip's are enabled
  • trunk/pxeconfig.spec

    r200 r203  
    44
    55Name: pxeconfig
    6 Version: 4.0.3
     6Version: 4.1.0
    77Release: 1%{?dist}
    88License: See LICENSE
  • trunk/src/pxeconfig.py

    r202 r203  
    125125    return files[index-1]
    126126
    127 def manage_links(haddr, options):
     127def manage_links(haddr, ip_addr, options):
    128128    """
    129129    Create the links in the PXE_CONF_DIR,
     
    141141            print 'removing %s/%s' %(PXE_CONF_DIR, haddr)
    142142
     143            if options.SCRIPT_HOOK_REMOVE and ip_addr:
     144                print 'Executing client script hook remove : %s with arg: %s' %(options.SCRIPT_HOOK_REMOVE, ip_addr)
     145
    143146        if os.path.exists(haddr) and not options.DRY_RUN:
    144147            os.unlink(haddr)
    145148
    146149    else:
     150
    147151        if options.DEBUG or options.DRY_RUN or options.VERBOSE:
    148152            print 'linking %s to %s' %(haddr, pxe_filename)
     153
     154            if options.SCRIPT_HOOK_ADD and ip_addr:
     155                print 'Executing client script hook add : %s with arg: %s' %(options.SCRIPT_HOOK_ADD, ip_addr)
    149156
    150157        if not options.DRY_RUN:
     
    152159                os.unlink(haddr)
    153160            os.symlink(pxe_filename, haddr)
     161   
     162            if options.SCRIPT_HOOK_ADD and ip_addr:
     163                cmd = '%s %s' %(options.SCRIPT_HOOK_ADD, ip_addr)
     164                os.system(cmd)
    154165
    155166def net_2_hex(net, options):
     
    194205    cnet = string.joinfields(net[0:3], '.')
    195206
    196     if options.SCRIPT_HOOK:
    197         if options.DEBUG or options.DRY_RUN or options.VERBOSE:
    198             print 'Executing client script hook: %s with arg: %s' %(options.SCRIPT_HOOK, addr)
    199         if not options.DRY_RUN:
    200             cmd = '%s %s' %(options.SCRIPT_HOOK, addr)
    201             os.system(cmd)
    202207
    203208    haddr = '%s%02X' %(net_2_hex(cnet, options), int(net[3]))
    204     manage_links(haddr, options)
     209    manage_links(haddr, addr, options)
    205210
    206211
     
    214219
    215220    haddr = '01-%s' %(mac_addr.replace(':', '-').lower())
    216     manage_links(haddr, options)
     221    manage_links(haddr, None, options)
    217222
    218223def add_options(p):
     
    226231        REMOVE  = False,
    227232        VERSION  = False,
    228         SCRIPT_HOOK = False,
     233        SCRIPT_HOOK_ADD = False,
     234        SCRIPT_HOOK_REMOVE = False,
    229235    )
    230236
     
    302308            options.filename = select_pxe_configfile()
    303309
    304     # ...
    305     try:
    306         options.SCRIPT_HOOK = defaults['client_script_hook']
     310
     311    ## This will be obsoleted by client_script_hook_add
     312    #
     313    try:
     314        options.SCRIPT_HOOK_ADD = defaults['client_script_hook']
     315    except KeyError, detail:
     316        pass
     317
     318    try:
     319        options.SCRIPT_HOOK_ADD = defaults['client_script_hook_add']
     320    except KeyError, detail:
     321        pass
     322
     323    try:
     324        options.SCRIPT_HOOK_REMOVE = defaults['client_script_hook_remove']
    307325    except KeyError, detail:
    308326        pass
Note: See TracChangeset for help on using the changeset viewer.