saltstack/salt — pull request #314 by wags007 (2011-12-04 17:17:07+00:00)
Title: Change to detect Vmware and Virutal Box

Sorry I am a newbie this is the first thing I have ever uploaded to a project. The version I have downloaded doesn't detect VirtualBox or Vmware. I have been trying to figure out the best way to do that detection. I would rather be collaborative and I don't want to step on anyone's toes if I missed someone else working on this. I could also use some help detecting this on BSD systems since I am not currently using any. What I am proposing might/should also work for Zen and other Virtual Systems as long as the OS has dmidecode.

if osdata['kernel'] == 'Linux' and os.path.isfile('/usr/sbin/dmidecode'):
vbios = subprocess.Popen(
'/usr/sbin/dmidecode --type 1|grep -i "Product Name" ',
shell=True,
stdout=subprocess.PIPE
).communicate()[0].split(':')[1].split(' ')[1]