libgenvnode.pm 2.05 KB
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
#!/usr/bin/perl -wT
#
# Copyright (c) 2008-2012 University of Utah and the Flux Group.
# 
# {{{EMULAB-LICENSE
# 
# This file is part of the Emulab network testbed software.
# 
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# 
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
# 
# }}}
#
# OS-independent vnode definitions, helpers, etc.
#
package libgenvnode;
use Exporter;
@ISA    = "Exporter";
@EXPORT = qw( VNODE_STATUS_RUNNING VNODE_STATUS_STOPPED VNODE_STATUS_BOOTING 
              VNODE_STATUS_INIT VNODE_STATUS_STOPPING VNODE_STATUS_UNKNOWN
	      VNODE_STATUS_MOUNTED
32
              VNODE_PATH
33 34 35
              findVirtControlNet
            );

36 37 38
# Drag in path stuff
BEGIN { require "/etc/emulab/paths.pm"; import emulabpaths; }

39 40 41 42 43 44 45 46
sub VNODE_STATUS_RUNNING() { return "running"; }
sub VNODE_STATUS_STOPPED() { return "stopped"; }
sub VNODE_STATUS_MOUNTED() { return "mounted"; }
sub VNODE_STATUS_BOOTING() { return "booting"; }
sub VNODE_STATUS_INIT()    { return "init"; }
sub VNODE_STATUS_STOPPING(){ return "stopping"; }
sub VNODE_STATUS_UNKNOWN() { return "unknown"; }

47 48
# VM path stuff
my $VMPATH     = "$VARDIR/vminfo";
49 50 51 52 53 54 55
sub VNODE_PATH(;$) { 
    my $vnode_id = shift;
    return 
	$VMPATH . 
	(defined($vnode_id) ? "/$vnode_id" : "") . 
	"/";
}
56

57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
#
# Magic control network config parameters.
#
my $VCNET_NET	    = "172.16.0.0";
my $VCNET_MASK      = "255.240.0.0";
my $VCNET_GW	    = "172.16.0.1";

#
# Find virtual control net iface info.  Returns:
# (net,mask,GW)
#
sub findVirtControlNet()
{
    return ($VCNET_NET, $VCNET_MASK, $VCNET_GW);
}