#!/usr/bin/awk -f BEGIN { # So that the awk interpreter does not attempt to read the command # line as a list of input files. ARGC = 1; # Debugging output is requested if(ARGV[1] != "") { debug_file = ARGV[1]; } else { # By doing this, we ensure that we only need to test for debugging # output once; if it is not requested, we just write all the debugging # statements to /dev/null debug_file = "/dev/null"; } } # The idea here is to collect the job attributes as they are passed to # us by the VM GAHP. The GAHP then outputs a blank line to indicate # that the entire classad has been sent to us. { gsub(/\"/, "") key = $1 # Matching value should be $3-$NR $1 = "" $2 = "" sub(/^ /, "") attrs[key] = $0 bootloader = "" root = "" initrd = "" kernel = "" kern_params = "" print "Received attribute: " key "=" attrs[key] >>debug_file } END { if(index(attrs["JobVMType"],"xen") != 0) { print ""; os_type = "linux" if(index(attrs["VMPARAM_Xen_Kernel"],"included") != 0) { bootloader = attrs["VMPARAM_Xen_Bootloader"] } else { kernel = attrs["VMPARAM_Xen_Kernel"] root = attrs["VMPARAM_Xen_Root"] initrd = attrs["VMPARAM_Xen_Initrd"] kern_params = attrs["VMPARAM_Xen_Kernel_Params"] } } else if(index(attrs["JobVMType"],"kvm") != 0) { print "" ; os_type = "hvm" } else { print "Unknown VM type: " index(attrs["JobVMType"], "kvm") >>debug_file; exit(-1); } print "" attrs["VMPARAM_VM_NAME"] "" ; if( attrs["JobVMMemory"] != "" && attrs["JobVMMemory"] != "undefined" ) { print "" attrs["JobVMMemory"] * 1024 "" ; } else { print "" attrs["RequestMemory"] * 1024 "" ; } if( attrs["JobVM_VCPUS"] != "" && attrs["JobVM_VCPUS"] != "undefined" ) { print "" attrs["JobVM_VCPUS"] "" ; } else { print "" attrs["RequestCpus"] "" ; } print "" ; print "" os_type "" if(kernel != "") { print "" kernel "" } if(initrd != "") { print "" initrd "" } if(root != "") { print "" root "" } if(kern_params != "") { print "" kern_params "" } print "" ; if(bootloader != "") { print "" bootloader "" } # Make sure guests destroy on power off print "" ; print "destroyrestartrestart" ; print "" ; print "" ; print "" ; # Check VNC settings if(attrs["JobVMVNCConsole"] == "true") { print "" ; } # To see full input ad to script set D_FULLDEBUG if(attrs["JobVMNetworking"] == "true") { if(index(attrs["JobVMNetworkingType"],"nat") != 0) { print "" ; if(attrs["JobVM_MACADDR"] != "") { print"" ; } print "" ; } else { print "" ; if(attrs["JobVM_MACADDR"] != "") { print"" ; } if(attrs["VMPARAM_Bridge_Interface"] != "") { print "" ; } print "" ; } } n=split(attrs["VMPARAM_vm_Disk"], full_disk, " *, *"); for ( i=1; i<=n; i++ ) { # count is used to determine if format is passed. p = split(full_disk[i], disk_string, ":"); if (index( disk_string[1], "iso") ) { print ""; } else { print "" ; } if ( p == 4 ) { # only an issue w/qemu if (attrs["JobVMType"] == "kvm") { print ""; } } if ( index( disk_string[1], "/" ) == 1 ) { print "" ; } else { print "" ; } print "" ; if ( disk_string[3] == "r" ) { print "" } print "" ; } print "" exit(0); }