Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cc-node
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror
cc-node
Commits
cc439720
Commit
cc439720
authored
14 years ago
by
Thibault VINCENT
Browse files
Options
Downloads
Patches
Plain Diff
storage: add wrappers for volume allocation and capacity
parent
3f02e6e3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ccnode/interface.py
+22
-0
22 additions, 0 deletions
ccnode/interface.py
ccnode/libvirtwrapper.py
+37
-0
37 additions, 0 deletions
ccnode/libvirtwrapper.py
with
59 additions
and
0 deletions
ccnode/interface.py
+
22
−
0
View file @
cc439720
...
...
@@ -289,3 +289,25 @@ class HVStorage(object):
:type volume_name: :class:`str`
:return: :class:`str` path to the volume file
'''
def
get_volume_allocation
(
self
,
pool
,
vol_name
):
'''
Returns the pool space used by this volume in bytes
:param pool: the pool containing this volume from
:type pool: :class:`virStoragePool`
:param vol_name: name of the volume to query
:type vol_name: :class:`str`
:return: :class:`int` of allocation in bytes
'''
def
get_volume_capacity
(
self
,
pool
,
vol_name
):
'''
Returns the capacity (usable space) of this volume in bytes
:param pool: the pool containing this volume from
:type pool: :class:`virStoragePool`
:param vol_name: name of the volume to query
:type vol_name: :class:`str`
:return: :class:`int` of capacity in bytes
'''
This diff is collapsed.
Click to expand it.
ccnode/libvirtwrapper.py
+
37
−
0
View file @
cc439720
...
...
@@ -504,6 +504,43 @@ class LibvirtHVStorage(HVStorage):
except
libvirt
.
libvirtError
as
e
:
raise
StorageError
(
"
Volume has no path information (%s)
"
%
e
)
def
get_volume_allocation
(
self
,
pool
,
vol_name
):
'''
Returns the pool space used by this volume in bytes
:param pool: the pool containing this volume from
:type pool: :class:`virStoragePool`
:param vol_name: name of the volume to query
:type vol_name: :class:`str`
:return: :class:`int` of allocation in bytes
'''
try
:
vol
=
pool
.
storageVolLookupByName
(
vol_name
)
except
libvirt
.
libvirtError
as
e
:
raise
StorageError
(
"
Volume not found (%s)
"
%
e
)
try
:
return
vol
.
info
()[
2
]
except
libvirt
.
libvirtError
as
e
:
raise
StorageError
(
"
Volume has no allocation information (%s)
"
%
e
)
def
get_volume_capacity
(
self
,
pool
,
vol_name
):
'''
Returns the capacity (usable space) of this volume in bytes
:param pool: the pool containing this volume from
:type pool: :class:`virStoragePool`
:param vol_name: name of the volume to query
:type vol_name: :class:`str`
:return: :class:`int` of capacity in bytes
'''
try
:
vol
=
pool
.
storageVolLookupByName
(
vol_name
)
except
libvirt
.
libvirtError
as
e
:
raise
StorageError
(
"
Volume not found (%s)
"
%
e
)
try
:
return
vol
.
info
()[
1
]
except
libvirt
.
libvirtError
as
e
:
raise
StorageError
(
"
Volume has no capacity information (%s)
"
%
e
)
#### Helper functions
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment