Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-devel
Commits
1fb3e726
Commit
1fb3e726
authored
Dec 06, 2013
by
Mike Hibler
Browse files
Add AvailableCapacity method.
parent
a2bccf93
Changes
1
Hide whitespace changes
Inline
Side-by-side
db/Blockstore.pm
View file @
1fb3e726
...
...
@@ -523,6 +523,29 @@ done:
return
-
1
;
}
#
# Return the remaining unallocated space
#
sub
AvailableCapacity
($)
{
my
(
$self
)
=
@_
;
my
$bsidx
=
$self
->
bsidx
();
my
$query_result
=
DBQueryWarn
("
select b.total_size,s.remaining_capacity
"
.
"
from blockstores as b left join blockstore_state as s
"
.
"
on b.bsidx=s.bsidx where b.bsidx='
$bsidx
'
");
return
-
1
if
(
!
$query_result
||
!
$query_result
->
numrows
);
#
# If remaining_capacity is NULL, then the blockstore is unused
# and we just return the total size.
#
my
(
$size
,
$avail
)
=
$query_result
->
fetchrow_array
();
return
(
defined
(
$avail
)
?
$avail
:
$size
);
}
############################################################################
#
# Package to describe a specific reservation of a blockstore.
...
...
Write
Preview
Supports
Markdown
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