#!/usr/bin/perl -w

# Print the mac addresses of the given machines (or all machines)

use strict;

my @F;
my $name;

open VIFLIST, "xe vm-vif-list|" or die "can't run xe vm-vif-list";

while (<VIFLIST>) {
  @F = split(/:\s/);
  next unless $F[1];
  $name = $F[1] if $F[0] =~ /vm-name-label/;
  chop $F[1];
  print $F[1] . " " . $name if $F[0] =~ /MAC /;

}
