From VNUML-WIKI
How to generate a graph of the scenario topology
Thanks to Francisco Jesus Monserrat Coll (RedIRIS), we provide here a small script in Perl that can be used to get a graphical representation of VNUML scenario.
To use it (let's assume that the script is named vnuml2dot.pl)
vnuml2dot scenario.xml > scenario.dot neato -Tpng -oscenario.png scenario.dot
And now you can see scenario.png with any graphic program (Gimp, etc.). The neato command comes with the graphviz package (in Debian, just 'apt-get install libgraphviz-perl').
Note that, in the words of its own author, the script is not perfect and there is room for improvement. If you develop improved versions, please tell us about it!
vnuml2dot.pl script
#!/usr/bin/perl
#
# Nota:
# networks -> circle
# vms -> squares
# interfaces -> lines
open FILE, $ARGV[0] || die "Can't open $ARGV[0]\n" ;
my @conf=<FILE> ;
close FILE ;
print<<FIN;
// Graph of VNUML configuration from $ARGV[0]
graph G {
overlap=scale
splines=true
sep=.1
FIN
# OK magic starts!
print "// Networks\n" ;
my ($net,$type) ;
for (my $i=0 ; $i!=@conf ; $i ++ ) {
#print "Linea = $conf[$i]\n" ;
if ($conf[$i] =~ /.*<net.*name=\"(.*)".*mode=\"(.*)\".*\/>.*/ ) {
$net= $1 ;
$type=$2 ;
print "$net [label=\"Red $net, $type\"] ;\n" ;
print "$net [shape=\"circle\"] ;\n" ;
}
}
# OK now vms
print "\n\n// Machines \n" ;
my $linea = join "", @conf ;
$linea =~ m/<vm (.*)<\/vm>.*/msi ;
my @maquinas= split /<\/vm>/ , $1 ;
for (my $i=0 ; $i!=@maquinas ; $i++ ) {
if ( $maquinas[$i] =~ /name.*=.*\"(.*)\"/ ) {
my $maquina=$1 ;
print "$1 [label=\"$1\"] ;\n" ;
print "$1 [shape=\"box\"] ;\n" ;
# Interface magic
my $if= $maquinas[$i] ;
# Koder
my @t = split /\n/, $if ;
my $if= join "" , @t ;
#
$if=~ m/<if(.*)<\/if>.*/msi ;
#print "Lo que sale es $1\n" ;
my @ifs= split /<\/if>/, $1 ;
for (my $k=0 ; $k!=@ifs ; $k++ ){
# print "$ifs[$k]\n" ;
my $t = $ifs[$k] ;
# print "if=$t\n" ;
$t =~ /.*id.*=.*\"(.*)\".*net.*=.*\"(.*)\".*<ipv4.*>(.*)<\/ipv4>/s ;
# print "if= $1 , net=$2 \n" ;
print "// Network connections of $maquina\n" ;
print "// Network interface $1 IP address $3 network $3\n" ;
print "$maquina -- $2 [ label = \"$3\" ];\n " ;
}
print "\n" ;
}
}
print "\n}\n" ;

