- Timestamp:
- 12/13/04 16:02:35 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/pxeconfig/pxeconfig
r45 r47 32 32 [-V|--version] 33 33 [-n|--net <C-net> -s|--start <number> -e|--end <number> -f|--file <filename>] 34 [hostname(s)] 34 35 35 36 With this program you can configure which PXE configuration file a node … … 60 61 import glob 61 62 import getopt 63 import socket 62 64 63 65 # DEBUG … … 72 74 START='start' 73 75 END='end' 74 VERSION='0. 4.4'76 VERSION='0.5' 75 77 76 78 SHORTOPT_LIST='hVd:n:s:e:f:' … … 142 144 143 145 144 def c heck_network(net, prefix=''):146 def convert_network(net, prefix=''): 145 147 """ 146 148 This function checks if the give network is a Class C-network and will … … 201 203 202 204 network = raw_input('Give network address (xxx.xxx.xxx): ') 203 naddr = c heck_network(network)205 naddr = convert_network(network) 204 206 205 207 start = raw_input('Starting number: ') … … 233 235 def check_args(argv, binfo): 234 236 """ 235 This function parses the command line options: 236 argv : a list of command line options. 237 binfo: returning a dict with the netinfo. if used non-interactively 237 This function parses the command line options and returns the rest as 238 an list of hostnames: 239 argv : a list of command line options. 240 binfo : returning a dict with the netinfo. if used non-interactively 241 hostnames: the rest of the command lines options that are not-parseble. 238 242 """ 239 243 global PXE_CONF_DIR … … 258 262 elif opt in ['-n', '--net']: 259 263 network = value 260 binfo[NETWORK] = c heck_network(value, opt)264 binfo[NETWORK] = convert_network(value, opt) 261 265 262 266 elif opt in ['-s', '--start']: … … 277 281 sys.exit(0) 278 282 283 if args: 284 return args 285 286 def hosts_links(hosts, binfo): 287 for host in hosts: 288 try: 289 addr = socket.gethostbyname(host) 290 except socket.error,detail: 291 print '%s not an valid hostname: %s' %(host,detail) 292 sys.exit(1) 293 294 net = string.splitfields(addr, '.') 295 cnet = string.joinfields(net[0:3], '.') 296 297 binfo[NETWORK] = convert_network(cnet) 298 binfo[START] = int(net[3]) 299 binfo[END] = int(net[3]) 300 create_links(binfo) 301 279 302 280 303 def main(): … … 282 305 # 283 306 bootinfo = {} 284 check_args(sys.argv, bootinfo) 285 286 if bootinfo: 287 check_cmd_line(bootinfo) 307 308 hostnames = check_args(sys.argv, bootinfo) 309 310 311 # If we supplied args then make links for the supplied hosts 312 # else make links for class C-networks 313 # 314 if hostnames: 315 if not bootinfo.has_key(FILENAME): 316 bootinfo[FILENAME] = select_pxe_configfile() 317 hosts_links(hostnames,bootinfo) 288 318 else: 289 interactive(bootinfo) 290 291 create_links(bootinfo) 319 if bootinfo: 320 check_cmd_line(bootinfo) 321 else: 322 interactive(bootinfo) 323 create_links(bootinfo) 292 324 293 325 if __name__ == '__main__':
Note: See TracChangeset
for help on using the changeset viewer.