Changeset 135


Ignore:
Timestamp:
04/14/09 16:18:00 (15 years ago)
Author:
bas
Message:

pxeconfig.in:

  • some more improvements and code deletion
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pxeconfig.in

    r133 r135  
    157157        return files[index-1]
    158158
    159 def manage_links(dict, options):
     159def manage_links(haddr, options):
    160160        """
    161161        Create the links in the PXE_CONF_DIR,
     
    164164        """
    165165        if options.VERBOSE:
    166                 print 'manage_links()'
     166                print 'manage_links(%s)' %(haddr)
    167167       
    168168        os.chdir(PXE_CONF_DIR)
    169         naddr = dict[NETWORK]
    170169        pxe_filename = options.filename
    171170       
    172         for i in range(dict[START], dict[END]+1):
    173                 haddr = '%s%02X' %(naddr, i)
    174        
    175                 if options.REMOVE:
    176                         if options.DEBUG or options.DRY_RUN:
    177                                 print 'removing %s/%s' %(PXE_CONF_DIR, haddr)
    178 
    179                         if os.path.exists(haddr) and not options.DRY_RUN:
    180                                 os.unlink(haddr)
    181 
    182                 else:
    183                         if options.DEBUG or options.DRY_RUN:
    184                                 print 'linking %s to %s' %(haddr, pxe_filename)
    185 
    186                         if not options.DRY_RUN:
    187                                 if os.path.exists(haddr):
    188                                         os.unlink(haddr)
    189                                 os.symlink(pxe_filename, haddr)
     171        if options.REMOVE:
     172                if options.DEBUG or options.DRY_RUN:
     173                        print 'removing %s/%s' %(PXE_CONF_DIR, haddr)
     174
     175                if os.path.exists(haddr) and not options.DRY_RUN:
     176                        os.unlink(haddr)
     177
     178        else:
     179                if options.DEBUG or options.DRY_RUN:
     180                        print 'linking %s to %s' %(haddr, pxe_filename)
     181
     182                if not options.DRY_RUN:
     183                        if os.path.exists(haddr):
     184                                os.unlink(haddr)
     185                        os.symlink(pxe_filename, haddr)
    190186
    191187def net_2_hex(net, options):
     
    263259
    264260        options, args = parser.parse_args()
     261
     262        if not args:
     263                print __doc__
     264                sys.exit(0)
    265265       
    266266        if options.VERSION:
     
    300300                cnet = string.joinfields(net[0:3], '.')
    301301
    302                 binfo = dict()
    303                 binfo[NETWORK] = net_2_hex(cnet, options)
    304                 binfo[START] = int(net[3])
    305                 binfo[END] =  int(net[3])
    306                 manage_links(binfo, options)
     302                haddr = '%s%02X' %(net_2_hex(cnet, options), int(net[3]))
     303
     304                manage_links(haddr, options)
    307305               
    308306
Note: See TracChangeset for help on using the changeset viewer.