Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emulab
emulab-devel
Commits
76117dbb
Commit
76117dbb
authored
Jan 27, 2014
by
Mike Hibler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support creation of a filesystem when creating a block store.
Can do ext[234] or ufs.
parent
7e4a26d6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
8 deletions
+45
-8
clientside/tmcc/freenas8/bscontrol.proxy.pl
clientside/tmcc/freenas8/bscontrol.proxy.pl
+19
-6
clientside/tmcc/freenas8/libfreenas.pm
clientside/tmcc/freenas8/libfreenas.pm
+26
-2
No files found.
clientside/tmcc/freenas8/bscontrol.proxy.pl
View file @
76117dbb
#!/usr/bin/perl -wT
#
# Copyright (c) 2013 University of Utah and the Flux Group.
# Copyright (c) 2013
-2014
University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
...
...
@@ -37,8 +37,8 @@ sub usage()
print
STDERR
"
commands:
\n
";
print
STDERR
"
pools Print size info about pools
\n
";
print
STDERR
"
volumes Print info about volumes
\n
";
print
STDERR
"
create <pool> <vol> <size>
\n
";
print
STDERR
"
Create <vol> in <pool> with <size> in MiB
\n
";
print
STDERR
"
create <pool> <vol> <size>
[ <fstype> ]
\n
";
print
STDERR
"
Create <vol> in <pool> with <size> in MiB
; optionally create a filesystem of type <fstype> on it
\n
";
print
STDERR
"
destroy <pool> <vol>
\n
";
print
STDERR
"
Destroy <vol> in <pool>
\n
";
exit
(
-
1
);
...
...
@@ -132,9 +132,9 @@ sub volumes()
return
0
;
}
sub
create
($$$)
sub
create
($$$
;
$
)
{
my
(
$pool
,
$vol
,
$size
)
=
@_
;
my
(
$pool
,
$vol
,
$size
,
$fstype
)
=
@_
;
if
(
defined
(
$pool
)
&&
$pool
=~
/^([-\w]+)$/
)
{
$pool
=
$
1
;
...
...
@@ -154,8 +154,21 @@ sub create($$$)
print
STDERR
"
bscontrol_proxy: bogus size arg
\n
";
return
1
;
}
if
(
!
defined
(
$fstype
))
{
$fstype
=
"
none
";
}
elsif
(
$fstype
=~
/^(ext2|ext3|ext4|ufs)$/
)
{
$fstype
=
$
1
;
}
else
{
print
STDERR
"
bscontrol_proxy: bogus fstype arg
\n
";
return
1
;
}
my
$rv
=
freenasVolumeCreate
(
$pool
,
$vol
,
$size
);
if
(
$rv
==
0
&&
$fstype
ne
"
none
")
{
$rv
=
freenasFSCreate
(
$pool
,
$vol
,
$fstype
);
}
return
freenasVolumeCreate
(
$pool
,
$vol
,
$size
)
;
return
$rv
;
}
sub
destroy
($$$)
...
...
clientside/tmcc/freenas8/libfreenas.pm
View file @
76117dbb
#!/usr/bin/perl -wT
#
# Copyright (c) 2013 University of Utah and the Flux Group.
# Copyright (c) 2013
-2014
University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
...
...
@@ -31,7 +31,7 @@ use Exporter;
@EXPORT
=
qw(
freenasPoolList freenasVolumeList
freenasVolumeCreate freenasVolumeDestroy
freenasVolumeCreate freenasVolumeDestroy
freenasFSCreate
freenasRunCmd freenasParseListing
$FREENAS_CLI_VERB_IFACE $FREENAS_CLI_VERB_IST_EXTENT
$FREENAS_CLI_VERB_IST_AUTHI $FREENAS_CLI_VERB_IST_TARGET
...
...
@@ -84,6 +84,8 @@ my $VOLUME_BUSY_WAIT = 10;
my
$VOLUME_GONE_WAIT
=
5
;
my
$IFCONFIG
=
"
/sbin/ifconfig
";
my
$ALIASMASK
=
"
255.255.255.255
";
my
$LINUX_MKFS
=
"
/usr/local/sbin/mke2fs
";
my
$FBSD_MKFS
=
"
/sbin/newfs
";
# storageconfig constants
# XXX: should go somewhere more general
...
...
@@ -114,6 +116,7 @@ sub freenasPoolList();
sub
freenasVolumeList
($);
sub
freenasVolumeCreate
($$$);
sub
freenasVolumeDestroy
($$);
sub
freenasFSCreate
($$$);
sub
freenasRunCmd
($$);
sub
freenasParseListing
($);
...
...
@@ -367,6 +370,27 @@ sub freenasParseListing($) {
return
@retlist
;
}
sub
freenasFSCreate
($$$)
{
my
(
$pool
,
$vol
,
$fstype
)
=
@_
;
my
$cmd
;
if
(
$fstype
=~
/^ext[234]$/
)
{
$cmd
=
"
$LINUX_MKFS
-t
$fstype
-o Linux
";
}
elsif
(
$fstype
eq
"
ufs
")
{
$cmd
=
"
$FBSD_MKFS
";
}
else
{
warn
("
*** WARNING: freenasFSCreate: unknown fs type '
$fstype
'
");
return
-
1
;
}
my
$redir
=
"
>/dev/null 2>&1
";
if
(
system
("
$cmd
/dev/zvol/
$pool
/
$vol
$redir
")
!=
0
)
{
warn
("
*** WARNING: freenasFSCreate: '
$cmd
/dev/zvol/
$pool
/
$vol
' failed
");
return
-
1
;
}
return
0
;
}
#######################################################################
# package-local functions
#
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment