libvtop.pm.in 3.46 KB
Newer Older
1 2
#!/usr/bin/perl -w
#
3
# Copyright (c) 2005-2018 University of Utah and the Flux Group.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# 
# {{{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/>.
# 
# }}}
23 24 25 26 27 28 29 30
#
package libvtop;

use strict;
use Exporter;
use vars qw(@ISA @EXPORT @EXPORT_OK
	    $VTOP_FLAGS_UPDATE $VTOP_FLAGS_VERBOSE $VTOP_FLAGS_QUIET
	    $VTOP_FLAGS_FIXNODES $VTOP_FLAGS_IMPOTENT $VTOP_FLAGS_ALLOCONLY
31
	    $VTOP_FLAGS_REGRESSION $VTOP_FLAGS_FIXLANNODES
32
	    $VTOP_FLAGS_PREASSIGN $VTOP_FLAGS_COMMITMODE);
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50

@ISA    = "Exporter";
@EXPORT = qw( );

# Configure variables
my $TB		  = "@prefix@";
my $libvtoptest;

use EmulabFeatures;

# Flags.
$VTOP_FLAGS_VERBOSE	= 0x0;
$VTOP_FLAGS_UPDATE	= 0x0;
$VTOP_FLAGS_FIXNODES	= 0x0;
$VTOP_FLAGS_IMPOTENT	= 0x0;
$VTOP_FLAGS_REGRESSION  = 0x0;
$VTOP_FLAGS_QUIET       = 0x0;
$VTOP_FLAGS_ALLOCONLY	= 0x0;
51
$VTOP_FLAGS_FIXLANNODES	= 0x0;
52
$VTOP_FLAGS_PREASSIGN	= 0x0;
53
$VTOP_FLAGS_COMMITMODE	= 0x0;
54 55 56

@EXPORT_OK = qw($VTOP_FLAGS_UPDATE $VTOP_FLAGS_VERBOSE $VTOP_FLAGS_FIXNODES
		$VTOP_FLAGS_IMPOTENT $VTOP_FLAGS_REGRESSION $VTOP_FLAGS_QUIET
57 58
		$VTOP_FLAGS_ALLOCONLY $VTOP_FLAGS_PREASSIGN
		$VTOP_FLAGS_COMMITMODE);
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78

sub Init($$$)
{
    my ($this_user, $group, $experiment) = @_;

    $libvtoptest = EmulabFeatures->FeatureEnabled("LibVtopTest",
						  $this_user,
						  $group, $experiment);

    if ($libvtoptest) {
	print "Using test version of libvtop ...\n";
	require libvtop_test;

	$VTOP_FLAGS_VERBOSE	= $libvtop_test::VTOP_FLAGS_VERBOSE;
	$VTOP_FLAGS_UPDATE	= $libvtop_test::VTOP_FLAGS_UPDATE;
	$VTOP_FLAGS_FIXNODES	= $libvtop_test::VTOP_FLAGS_FIXNODES;
	$VTOP_FLAGS_IMPOTENT	= $libvtop_test::VTOP_FLAGS_IMPOTENT;
	$VTOP_FLAGS_REGRESSION  = $libvtop_test::VTOP_FLAGS_REGRESSION;
	$VTOP_FLAGS_QUIET       = $libvtop_test::VTOP_FLAGS_QUIET;
	$VTOP_FLAGS_ALLOCONLY	= $libvtop_test::VTOP_FLAGS_ALLOCONLY;
79
	$VTOP_FLAGS_FIXLANNODES	= $libvtop_test::VTOP_FLAGS_FIXLANNODES;
80
	$VTOP_FLAGS_PREASSIGN	= $libvtop_test::VTOP_FLAGS_PREASSIGN;
81
	$VTOP_FLAGS_COMMITMODE	= $libvtop_test::VTOP_FLAGS_COMMITMODE;
82 83 84 85 86 87 88 89 90 91 92
    }
    else {
	require libvtop_stable;

	$VTOP_FLAGS_VERBOSE	= $libvtop_stable::VTOP_FLAGS_VERBOSE;
	$VTOP_FLAGS_UPDATE	= $libvtop_stable::VTOP_FLAGS_UPDATE;
	$VTOP_FLAGS_FIXNODES	= $libvtop_stable::VTOP_FLAGS_FIXNODES;
	$VTOP_FLAGS_IMPOTENT	= $libvtop_stable::VTOP_FLAGS_IMPOTENT;
	$VTOP_FLAGS_REGRESSION  = $libvtop_stable::VTOP_FLAGS_REGRESSION;
	$VTOP_FLAGS_QUIET       = $libvtop_stable::VTOP_FLAGS_QUIET;
	$VTOP_FLAGS_ALLOCONLY	= $libvtop_stable::VTOP_FLAGS_ALLOCONLY;
93
	$VTOP_FLAGS_FIXLANNODES	= $libvtop_stable::VTOP_FLAGS_FIXLANNODES;
94
	$VTOP_FLAGS_PREASSIGN	= $libvtop_stable::VTOP_FLAGS_PREASSIGN;
95
	$VTOP_FLAGS_COMMITMODE	= $libvtop_stable::VTOP_FLAGS_COMMITMODE;
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
    }
    return 0;
}

sub Create
{
    return undef
	if (!defined($libvtoptest));
    
    shift();
    return ($libvtoptest ?
	    libvtop_test->Create(@_) : libvtop_stable->Create(@_));
}

1;