- Timestamp:
- 08/22/12 14:17:15 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/pxeconfig.py
r202 r203 125 125 return files[index-1] 126 126 127 def manage_links(haddr, options):127 def manage_links(haddr, ip_addr, options): 128 128 """ 129 129 Create the links in the PXE_CONF_DIR, … … 141 141 print 'removing %s/%s' %(PXE_CONF_DIR, haddr) 142 142 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 143 146 if os.path.exists(haddr) and not options.DRY_RUN: 144 147 os.unlink(haddr) 145 148 146 149 else: 150 147 151 if options.DEBUG or options.DRY_RUN or options.VERBOSE: 148 152 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) 149 156 150 157 if not options.DRY_RUN: … … 152 159 os.unlink(haddr) 153 160 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) 154 165 155 166 def net_2_hex(net, options): … … 194 205 cnet = string.joinfields(net[0:3], '.') 195 206 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)202 207 203 208 haddr = '%s%02X' %(net_2_hex(cnet, options), int(net[3])) 204 manage_links(haddr, options)209 manage_links(haddr, addr, options) 205 210 206 211 … … 214 219 215 220 haddr = '01-%s' %(mac_addr.replace(':', '-').lower()) 216 manage_links(haddr, options)221 manage_links(haddr, None, options) 217 222 218 223 def add_options(p): … … 226 231 REMOVE = False, 227 232 VERSION = False, 228 SCRIPT_HOOK = False, 233 SCRIPT_HOOK_ADD = False, 234 SCRIPT_HOOK_REMOVE = False, 229 235 ) 230 236 … … 302 308 options.filename = select_pxe_configfile() 303 309 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'] 307 325 except KeyError, detail: 308 326 pass
Note: See TracChangeset
for help on using the changeset viewer.