It was a scope issue, the linux prep was being rescoped with my in the elsif block and getting undef in your customization.
Try the attached version. However, from the code looks like it will only work for RHEL5_64Guest, so it would need more modification to support additional linux guest os types.