Commit da96edd1 authored by Yathindra Naik's avatar Yathindra Naik Committed by Yathindra Naik

Added Disk-agent program and its libraries

parent 9548b993
......@@ -3,12 +3,12 @@
# Copyright (c) 2010 University of Utah and the Flux Group.
# All rights reserved.
#
gcc -DELVIN_COMPAT -c ../lib/event.c -o event.o -I../lib/ -I../../lib/libtb/ \
-I../../.. -L../../../pubsub
gcc -DELVIN_COMPAT -c ../lib/util.c -o util.o -I../lib/ -I../../lib/libtb/ \
-I../../.. -L../../../pubsub
gcc -c /proj/utahstud/ydev/emulab-devel/clientside/lib/event/event.c -o event.o -I/proj/utahstud/ydev/emulab-devel/clientside/lib \
-I /proj/utahstud/ydev/emulab-devel/clientside/lib/libtb -I/proj/utahstud/ydev/ -L/proj/utahstud/ydev/pubsub
gcc -c /proj/utahstud/ydev/emulab-devel/clientside/lib/event/util.c -o util.o -I/proj/utahstud/ydev/emulab-devel/clientside/lib \
-I /proj/utahstud/ydev/emulab-devel/clientside/lib/libtb -I/proj/utahstud/ydev/ -L/proj/utahstud/ydev/pubsub
ar crv libevent.a event.o util.o
ranlib libevent.a
g++ -DELVIN_COMPAT -o simple-agent -Wall -I../lib/ -I../../lib/libtb/ \
-I../../.. -L../../../pubsub main.cc libevent.a -lpubsub -lssl
g++ -g -o disk-agent -Wall -I/proj/utahstud/ydev/emulab-devel/clientside/lib -I/proj/utahstud/ydev/emulab-devel/clientside/lib/libtb \
-I/proj/utahstud/ydev/emulab-devel/event/simple-agent -L/proj/utahstud/ydev/emulab-devel/event/simple-agent -L/proj/utahstud/ydev/pubsub disk-agent.cc libevent.a -ldevmapper -lpubsub -lssl
This diff is collapsed.
This diff is collapsed.
/*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _DM_LOGGING_H
#define _DM_LOGGING_H
#include "libdevmapper.h"
extern dm_log_fn dm_log;
extern dm_log_with_errno_fn dm_log_with_errno;
#define LOG_MESG(l, f, ln, e, x...) \
do { \
if (dm_log_is_non_default()) \
dm_log(l, f, ln, ## x); \
else \
dm_log_with_errno(l, f, ln, e, ## x); \
} while (0)
#define LOG_LINE(l, x...) LOG_MESG(l, __FILE__, __LINE__, 0, ## x)
#define LOG_LINE_WITH_ERRNO(l, e, x...) LOG_MESG(l, __FILE__, __LINE__, e, ## x)
#include "log.h"
#endif
This diff is collapsed.
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2005 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
use Getopt::Std;
use Fcntl;
use IO::Handle;
use Socket;
# Drag in path stuff so we can find emulab stuff.
BEGIN { require "/etc/emulab/paths.pm"; import emulabpaths; }
my $DOSTYPE = "$BINDIR/dostype";
sub mysystem($);
sub usage()
{
print("Usage: mkextrafs.pl [-f] [-lM] [-v <vglist>] <mountpoint>\n");
exit(-1);
}
my $optlist = "flv:M";
#
# Yep, hardwired for now. Should be options or queried via TMCC.
#
my $disk = "hda";
my $slice = "4";
my $partition = "";
my $forceit = 0;
my $lvm = 0;
my @vglist = ();
my $lmonster = 0;
my $flag = 0;
#
# Turn off line buffering on output
#
STDOUT->autoflush(1);
STDERR->autoflush(1);
#
# Untaint the environment.
#
$ENV{'PATH'} = "/tmp:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:".
"/usr/local/bin:/usr/site/bin:/usr/site/sbin:/usr/local/etc/emulab";
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
#
# Parse command arguments. Once we return from getopts, all that should be
# left are the required arguments.
#
%options = ();
if (! getopts($optlist, \%options)) {
usage();
}
if (defined($options{"f"})) {
$forceit = 1;
}
if (defined($options{"l"})) {
$lvm = 1;
}
if (defined($options{"v"})) {
@vglist = split(/,/,$options{"v"});
}
if (defined($options{"M"})) {
$lmonster = 1;
if (scalar(@vglist)) {
die("*** $0:\n".
" If you want a single giant LVM-based filesystem, you can" .
" only specify a single volume group name!\n");
}
}
if (scalar(@vglist) == 0) {
@vglist = ('emulab',);
}
my $mountpoint;
if (!$lvm || ($lvm && $lmonster)) {
if (@ARGV != 1) {
usage();
}
$mountpoint = $ARGV[0];
if (! -d $mountpoint) {
die("*** $0:\n".
" $mountpoint does not exist!\n");
}
}
#
# XXX determine the disk based on the root fs
#
my $rootdev = `df | egrep '/\$'`;
if ($rootdev =~ /^\/dev\/([a-z]+)\d+\s+/) {
$disk = $1;
}
my $diskdev = "/dev/${disk}";
my $fsdevice = "${diskdev}${slice}";
#
# An existing fstab entry indicates we have already done this
# XXX override with forceit? Would require unmounting and removing from fstab.
#
if (!system("egrep -q -s '^${fsdevice}' /etc/fstab")) {
$flag=1
# die("*** $0:\n".
# " There is already an entry in /etc/fstab for $fsdevice\n");
}
#
# Likewise, if already mounted somewhere, fail
#
my $mounted = `mount | egrep '^${fsdevice}'`;
if ($mounted =~ /^${fsdevice} on (\S*)/) {
die("*** $0:\n".
" $fsdevice is already mounted on $1\n");
}
my $stype = `sfdisk $diskdev -c $slice`;
if ($stype ne "") {
chomp($stype);
$stype = hex($stype);
}
else {
die("*** $0:\n".
" Could not parse slice $slice fdisk entry!\n");
}
#
# Fail if not forcing and the partition type is non-zero.
#
if (!$forceit) {
if ($stype != 0) {
die("*** $0:\n".
" non-zero partition type ($stype) for ${disk}${slice}, ".
"use -f to override\n");
}
} elsif ($stype && $stype != 131) {
warn("*** $0: WARNING: changing partition type from $stype to 131\n");
}
#
# Before we do anything, do lvm if necessary and do not make any filesystems
# inside the vgs unless they want a single monster fs.
#
if ($lvm) {
my $retval = 0;
my $blockdevs = "$fsdevice";
if ($retval = system("pvcreate $blockdevs")) {
die("*** $0:\n".
" 'pvcreate $blockdevs' failed!\n");
}
foreach my $vg (@vglist) {
if (system("vgcreate $vg $blockdevs")) {
die("*** $0:\n".
" 'vgcreate $vg $blockdevs' failed!\n");
}
}
if ($lmonster) {
if (system("lvcreate -n emulab -l 100\%VG $vglist[0]")) {
die("*** $0:\n".
" 'lvcreate -n emulab -l 100\%VG $vglist[0]' failed!\n");
}
$fsdevice = "/dev/$vglist[0]/emulab";
}
else {
exit(0);
}
}
#
# Set the partition type to Linux if not already set.
#
# XXX sfdisk appears to stomp on partition one's bootblock, at least if it
# is BSD. It zeros bytes in the block 0x200-0x400, I suspect it is attempting
# to invalidate any BSD disklabel. While we could just use a scripted fdisk
# sequence here instead, sfdisk is so much more to-the-point. So, we just
# save off the bootblock, run sfdisk and put the bootblock back.
#
# Would it seek out and destroy other BSD partitions? Don't know.
# I cannot find the source for sfdisk.
#
if (!$lvm && $stype != 131) {
die("*** $0:\n".
" No $DOSTYPE program, cannot set type of DOS partition\n")
if (! -e "$DOSTYPE");
mysystem("$DOSTYPE -f /dev/$disk $slice 131");
}
# eh, quick try for ext3 -- no way we can consistently check the kernel for
# support, off the top of my head
if ( -e "/sbin/mkfs.ext3") {
mysystem("sudo mke2fs -j $fsdevice");
if ( $flag == 0 ) {
mysystem("(echo \"$fsdevice $mountpoint ext3 defaults 0 0\" >> /etc/fstab) 2> /dev/null");
}
}
else {
mysystem("sudo mkfs $fsdevice");
if ( $flag == 0 ) {
mysystem("(echo \"$fsdevice $mountpoint ext2 defaults 0 0\" >> /etc/fstab) 2> /dev/null");
}
}
system("echo $fsdevice");
#mysystem("mount $mountpoint");
#mysystem("mkdir $mountpoint/local");
sub mysystem($)
{
my ($command) = @_;
if (0) {
# print "'$command'\n";
}
else {
# print "'$command'\n";
`$command`;
if ($?) {
die("*** $0:\n".
" Failed: '$command'\n");
}
}
return 0
}
system("../../../pubsub/pubsubd -v -d -p 4001");
system("./simple-agent -E delay-agent/single-node -s localhost -k /var/emulab/boot/eventkey -u foobar -p 4001");
#system("../../../pubsub/pubsubd -v -d -p 4001");
system("./disk-agent -E utahstud/stap3 -s event-server -u disk -p 16505");
#-k /var/emulab/boot/eventkey
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2000-2011 University of Utah and the Flux Group.
* All rights reserved.
*/
/*
* Various constants that are reflected in the DB!
*/
#define TBDB_FLEN_NODEID (32 + 1)
#define TBDB_FLEN_VNAME (32 + 1)
#define TBDB_FLEN_EID (32 + 1)
#define TBDB_FLEN_UID (8 + 1)
#define TBDB_FLEN_PID (48 + 1)
#define TBDB_FLEN_GID (32 + 1)
#define TBDB_FLEN_NODECLASS (10 + 1)
#define TBDB_FLEN_NODETYPE (30 + 1)
#define TBDB_FLEN_IP (16 + 1)
#define TBDB_FLEN_EVOBJTYPE 128
#define TBDB_FLEN_EVOBJNAME 128
#define TBDB_FLEN_EVEVENTTYPE 128
#define TBDB_FLEN_PRIVKEY 64
#define TBDB_FLEN_SFSHOSTID 128
#define TBDB_FLEN_RPMS 4096
#define TBDB_FLEN_TINYTEXT (256 + 1)
/*
* Event system stuff.
*
* If you add to these two lists, make sure you add to the arrays in tbdefs.c
*/
#define TBDB_OBJECTTYPE_TESTBED "TBCONTROL"
#define TBDB_OBJECTTYPE_STATE "TBNODESTATE"
#define TBDB_OBJECTTYPE_OPMODE "TBNODEOPMODE"
#define TBDB_OBJECTTYPE_EXPTSTATE "TBEXPTSTATE"
#define TBDB_OBJECTTYPE_LINK "LINK"
#define TBDB_OBJECTTYPE_TRAFGEN "TRAFGEN"
#define TBDB_OBJECTTYPE_TIME "TIME"
#define TBDB_OBJECTTYPE_PROGRAM "PROGRAM"
#define TBDB_OBJECTTYPE_FRISBEE "FRISBEE"
#define TBDB_OBJECTTYPE_SIMULATOR "SIMULATOR"
#define TBDB_OBJECTTYPE_LINKTEST "LINKTEST"
#define TBDB_OBJECTTYPE_NSE "NSE"
#define TBDB_OBJECTTYPE_CANARYD "CANARYD"
#define TBDB_OBJECTTYPE_NODE "NODE"
#define TBDB_OBJECTTYPE_GROUP "GROUP"
#define TBDB_OBJECTTYPE_TIMELINE "TIMELINE"
#define TBDB_OBJECTTYPE_SEQUENCE "SEQUENCE"
#define TBDB_OBJECTTYPE_CONSOLE "CONSOLE"
#define TBDB_OBJECTTYPE_TOPOGRAPHY "TOPOGRAPHY"
#define TBDB_OBJECTTYPE_LINKTRACE "LINKTRACE"
#define TBDB_OBJECTTYPE_EVPROXY "EVPROXY"
#define TBDB_OBJECTTYPE_BGMON "BGMON"
#define TBDB_OBJECTTYPE_PLABSCHED "PLABSCHED"
#define TBDB_OBJECTTYPE_DISK "DISK"
#define TBDB_EVENTTYPE_START "START"
#define TBDB_EVENTTYPE_STOP "STOP"
#define TBDB_EVENTTYPE_KILL "KILL"
#define TBDB_EVENTTYPE_ISUP "ISUP"
#define TBDB_EVENTTYPE_REBOOT "REBOOT"
#define TBDB_EVENTTYPE_UP "UP"
#define TBDB_EVENTTYPE_DOWN "DOWN"
#define TBDB_EVENTTYPE_UPDATE "UPDATE"
#define TBDB_EVENTTYPE_MODIFY "MODIFY"
#define TBDB_EVENTTYPE_SET "SET"
#define TBDB_EVENTTYPE_RESET "RESET"
#define TBDB_EVENTTYPE_HALT "HALT"
#define TBDB_EVENTTYPE_SWAPOUT "SWAPOUT"
#define TBDB_EVENTTYPE_NSESWAP "NSESWAP"
#define TBDB_EVENTTYPE_NSEEVENT "NSEEVENT"
#define TBDB_EVENTTYPE_REPORT "REPORT"
#define TBDB_EVENTTYPE_ALERT "ALERT"
#define TBDB_EVENTTYPE_SETDEST "SETDEST"
#define TBDB_EVENTTYPE_SNAPSHOT "SNAPSHOT"
#define TBDB_EVENTTYPE_RELOAD "RELOAD"
#define TBDB_EVENTTYPE_COMPLETE "COMPLETE"
#define TBDB_EVENTTYPE_CLEAR "CLEAR"
#define TBDB_EVENTTYPE_DEBUG "DEBUG"
#define TBDB_EVENTTYPE_LOG "LOG"
#define TBDB_EVENTTYPE_MESSAGE "MESSAGE"
#define TBDB_EVENTTYPE_RUN "RUN"
#define TBDB_EVENTTYPE_CREATE "CREATE"
#define TBDB_EVENTTYPE_STOPRUN "STOPRUN"
/*
* Global event passthru sentinal - does _NOT_ go in either event array
*/
#define TBDB_EVENTEXPT_NONE "__none"
#define TBDB_NODESTATE_ISUP "ISUP"
#define TBDB_NODESTATE_REBOOTED "REBOOTED"
#define TBDB_NODESTATE_REBOOTING "REBOOTING"
#define TBDB_NODESTATE_SHUTDOWN "SHUTDOWN"
#define TBDB_NODESTATE_BOOTING "BOOTING"
#define TBDB_NODESTATE_TBSETUP "TBSETUP"
#define TBDB_NODESTATE_RELOADSETUP "RELOADSETUP"
#define TBDB_NODESTATE_RELOADING "RELOADING"
#define TBDB_NODESTATE_RELOADDONE "RELOADDONE"
#define TBDB_NODESTATE_RELOADDONE_V2 "RELOADDONEV2"
#define TBDB_NODESTATE_UNKNOWN "UNKNOWN"
#define TBDB_NODESTATE_PXEWAIT "PXEWAIT"
#define TBDB_NODESTATE_PXEWAKEUP "PXEWAKEUP"
#define TBDB_NODESTATE_PXEBOOTING "PXEBOOTING"
#define TBDB_NODEOPMODE_NORMAL "NORMAL"
#define TBDB_NODEOPMODE_DELAYING "DELAYING"
#define TBDB_NODEOPMODE_UNKNOWNOS "UNKNOWNOS"
#define TBDB_NODEOPMODE_RELOADING "RELOADING"
#define TBDB_NODEOPMODE_NORMALv1 "NORMALv1"
#define TBDB_NODEOPMODE_MINIMAL "MINIMAL"
#define TBDB_NODEOPMODE_RELOAD "RELOAD"
#define TBDB_NODEOPMODE_DELAY "DELAY"
#define TBDB_NODEOPMODE_BOOTWHAT "_BOOTWHAT_"
#define TBDB_NODEOPMODE_UNKNOWN "UNKNOWN"
#define TBDB_TBCONTROL_RESET "RESET"
#define TBDB_TBCONTROL_RELOADDONE "RELOADDONE"
#define TBDB_TBCONTROL_RELOADDONE_V2 "RELOADDONEV2"
#define TBDB_TBCONTROL_TIMEOUT "TIMEOUT"
#define TBDB_IFACEROLE_CONTROL "ctrl"
#define TBDB_IFACEROLE_EXPERIMENT "expt"
#define TBDB_IFACEROLE_JAIL "jail"
#define TBDB_IFACEROLE_FAKE "fake"
#define TBDB_IFACEROLE_GW "gw"
#define TBDB_IFACEROLE_OTHER "other"
/* PLAB_SCHED entry for filtering events */
#define TBDB_PLABSCHED "PLABSCHED"
/*
* Protos.
*/
int tbdb_validobjecttype(char *foo);
int tbdb_valideventtype(char *foo);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment