31 800 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
#
# Convert to randomly generated mac addresses for container control interface.
#
use strict;
use libinstall;
use installvars;
use emdb;
use emutil;

sub InstallUpdate($$)
{
    my ($version, $phase) = @_;

    if ($phase eq "pre") {
	my $query_result =
	    DBQueryFatal("select i.node_id,iface,mac from interfaces as i ".
			 "left join nodes as n on n.node_id=i.node_id ".
			 "left join node_types as t on t.type=n.type ".
			 "where t.isvirtnode=1 and i.role='ctrl'");

	while (my ($node_id,$iface,$mac) = $query_result->fetchrow_array()) {
	    next
		if ($mac ne "000000000000");

	    my $newmac = GenFakeMac();

	    DBQueryFatal("update interfaces set mac='$newmac' ".
			 "where node_id='$node_id' and iface='$iface'");
	}
    }
    return 0;
}

1;

# Local Variables:
# mode:perl
# End: