Commit ce40efb6 authored by Kirk Webb's avatar Kirk Webb

Checkpoint libvnode_blockstore work.

parent 57469ba3
......@@ -29,9 +29,13 @@ use Exporter;
@EXPORT = qw( VNODE_STATUS_RUNNING VNODE_STATUS_STOPPED VNODE_STATUS_BOOTING
VNODE_STATUS_INIT VNODE_STATUS_STOPPING VNODE_STATUS_UNKNOWN
VNODE_STATUS_MOUNTED
VNODE_PATH
findVirtControlNet
);
# Drag in path stuff
BEGIN { require "/etc/emulab/paths.pm"; import emulabpaths; }
sub VNODE_STATUS_RUNNING() { return "running"; }
sub VNODE_STATUS_STOPPED() { return "stopped"; }
sub VNODE_STATUS_MOUNTED() { return "mounted"; }
......@@ -40,6 +44,10 @@ sub VNODE_STATUS_INIT() { return "init"; }
sub VNODE_STATUS_STOPPING(){ return "stopping"; }
sub VNODE_STATUS_UNKNOWN() { return "unknown"; }
# VM path stuff
my $VMPATH = "$VARDIR/vminfo";
sub VNODE_PATH() { return $VMPATH; }
#
# Magic control network config parameters.
#
......
......@@ -3403,16 +3403,17 @@ sub getstorageconfig($;$) {
}
my %fields = (
'CMD' => 'ELEMENT',
'CMD' => '(ELEMENT|EXPORT|SLICE)',
'IDX' => '\d+',
'BSID' => '[-\w]+',
'CLASS' => '(SAN|local)',
'PROTO' => '(iSCSI|local)',
'HOSTID' => '[-\w\.]+',
'PERMS' => '(RO|RW)',
'PROTO' => '(iSCSI|local)',
'UUID' => '[-\w\.:]+',
'UUID_TYPE'=> '(iqn|serial)',
'VOLNAME' => '[-\w]+',
'VOLSIZE' => '\d+',
'PERMS' => '(RO|RW)'
);
my @ops = ();
......
......@@ -28,7 +28,7 @@ package libutil;
use Exporter;
@ISA = "Exporter";
@EXPORT = qw( ipToMac macAddSep fatal mysystem mysystem2
findDNS setState isRoutable findDomain
findDNS setState isRoutable findDomain convertToMebi
);
use libtmcc;
......@@ -122,6 +122,62 @@ sub findDomain()
return $domain;
}
#
# Convert most storage size specs to Mebibytes
#
sub convertToMebi($) {
my $insize = shift;
my $outsize;
if (!defined($insize) || !$insize) {
return -1;
}
CSIZE:
for ($insize) {
/^(\d+)B?$/ && do {
$outsize = $1 / 2**20;
last CSIZE;
};
/^(\d+(\.\d+)?)KB?$/ && do {
$outsize = $1 * 10**3 / 2**20;
last CSIZE;
};
/^(\d+(\.\d+)?)KiB?$/ && do {
$outsize = $1 / 2**10;
last CSIZE;
};
/^(\d+(\.\d+)?)MB?$/ && do {
$outsize = $1 * 10**6 / 2**20;
last CSIZE;
};
/^(\d+(\.\d+)?)MiB?$/ && do {
$outsize = $1;
last CSIZE;
};
/^(\d+(\.\d+)?)GB?$/ && do {
$outsize = $1 * 10**9 / 2**20;
last CSIZE;
};
/^(\d+(\.\d+)?)GiB?$/ && do {
$outsize = $1 * 2**10;
last CSIZE;
};
/^(\d+(\.\d+)?)TB?$/ && do {
$outsize = $1 * 10**12 / 2**20;
last CSIZE;
};
/^(\d+(\.\d+)?)TiB?$/ && do {
$outsize = $1 * 2**20;
last CSIZE;
};
# Default (bad size spec)
$outsize = -1;
}
return $outsize;
}
#
# Print error and exit.
#
......
This diff is collapsed.
#!/usr/bin/perl -wT
BEGIN { require "/etc/emulab/paths.pm"; import emulabpaths; }
use libsetup;
use libtmcc;
use libvnode_blockstore;
use Data::Dumper;
# Test FreeNAS list parsing
my @list = libvnode_blockstore::parseFreeNASListing("ist_extent");
print "Dump of FreeNAS ist_extent:\n" . Dumper(@list);
# List off slice info
my $sliceh = libvnode_blockstore::getSliceList();
print "Dump of FreeNAS slices:\n" . Dumper(%$sliceh);
# List off pools
my $pools = libvnode_blockstore::getPoolList();
print "Dump of FreeNAS pools:\n" . Dumper(%$pools);
# Grab and stash away storageconfig stuff for some vnode.
my @sconf;
my $vnodeid = "dboxvm1-1";
libsetup_setvnodeid($vnodeid);
libtmcc::configtmcc("portnum",7778);
die "getstorageconfig($vnodeid): $!"
if (getstorageconfig(\@sconf));
print "Storageconfig for $vnodeid:\n" . Dumper(@sconf);
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