Vnuml2dot

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.)

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!

#!/usr/bin/perl # # Nota: # networks -> circle # vms -> squares # interfaces -> lines open FILE, $ARGV[0]  || die "Can't open $ARGV[0]\n" ; my @conf= ; close FILE ; print<.*/ ) { $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/.*/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/.*/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>/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" ;