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
cf264fe7
Commit
cf264fe7
authored
14 years ago
by
Thibault VINCENT
Browse files
Options
Downloads
Patches
Plain Diff
storage api cleanup, added storage usage methods
parent
b581e5fb
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
+33
-30
33 additions, 30 deletions
ccnode/interface.py
ccnode/libvirtwrapper.py
+51
-24
51 additions, 24 deletions
ccnode/libvirtwrapper.py
with
84 additions
and
54 deletions
ccnode/interface.py
+
33
−
30
View file @
cf264fe7
...
...
@@ -172,25 +172,13 @@ class HVStorage(object):
:param hypervisor: in instance of :class:`Hypervisor`
'''
def
get_backend_type
(
self
):
'''
Returns the type of backend used for storage
'''
pass
def
get_storage_pools
(
self
):
def
get_pools
(
self
):
'''
Returns a dict of storage pools bound to the host
'''
pass
def
get_space_statistics
(
self
):
'''
Returns informations about space available in the storage object
'''
pass
def
get_storage_volumes
(
self
,
pool
=
None
):
def
get_volumes
(
self
,
pool
=
None
):
'''
Returns volumes stored in pool or all pools
'''
...
...
@@ -218,7 +206,7 @@ class HVStorage(object):
Adds a volume to the specified pool
:param pool: the pool in which to create the volume
:type pool: :class:`
str
`
:type pool: :class:`
virStoragePool
`
:param name: name of the new volume
:type name: :class:`str`
:param space: size of the new volume in gigabytes
...
...
@@ -231,7 +219,7 @@ class HVStorage(object):
Deletes a volume in the specified pool
:param pool: the pool in which delete the volume
:type pool: :class:`
str
`
:type pool: :class:`
virStoragePool
`
:param name: the name of the volume
:type name: :class:`str`
'''
...
...
@@ -247,22 +235,37 @@ class HVStorage(object):
pool is suitable
'''
def
get_pool_
info
(
self
,
pool
):
def
get_pool_
state
(
self
,
pool
):
'''
Returns informations about the pool
Returns the running state of the pool
:param pool: the storage pool name
:type pool: libvirt.`virStoragePool`
'''
pass
def
get_
v
ol_
info
(
self
,
v
ol
):
def
get_
po
ol_
total_space
(
self
,
po
ol
):
'''
Returns informations about the volume
Returns the storage capacity of this pool in gigabytes
:param pool: the pool to get information from
:type pool: :class:`virStoragePool`
:return: :class:`int` of capacity in gigabytes
'''
def
get_pool_available_space
(
self
,
pool
):
'''
Returns available space of this storage pool in gigabytes
:param pool: the pool to get information from
:type pool: :class:`virStoragePool`
:return: :class:`int` of available free space in gigabytes
'''
def
get_pool_used_space
(
self
,
pool
):
'''
Returns current storage pool usage in gigabytes
:param pool: the pool to get information from
:type pool: :class:`virStoragePool`
:return: :class:`int` of used space in gigabytes
'''
This diff is collapsed.
Click to expand it.
ccnode/libvirtwrapper.py
+
51
−
24
View file @
cf264fe7
...
...
@@ -333,35 +333,23 @@ class LibvirtHVStorage(HVStorage):
self
.
_pools
=
dict
([(
p
,
pool_obj
(
self
.
hv_handle
.
_con_handle
,
p
))
\
for
p
in
pools
])
def
get_storage_pools
(
self
):
return
self
.
_pools
def
get_pool_info
(
self
,
pool
):
pool_info
=
{}
pool_info
[
POOL_NAME
]
=
pool
.
name
()
pool_info
[
POOL_STATUS
]
=
self
.
get_pool_state
(
pool
)
pool_info
[
POOL_TOTAL_SIZE
]
=
self
.
get_pool_size
(
pool
)
/
GIGABYTE_DIV
return
pool_info
def
get_pool_size
(
self
,
pool
):
def
get_pools
(
self
):
'''
Returns total logical size of the pool
:param pool: the storage pool
:type pool: :class:`libvirt.virStoragePool`
Returns a dict of storage pools bound to the host
'''
return
pool
.
info
()[
1
]
return
self
.
_pools
def
get_
pool_state
(
self
,
pool
):
def
get_
volumes
(
self
,
pool
=
None
):
'''
Returns the running state of the pool
:param pool: the storage pool name
:type pool: libvirt.`virStoragePool`
Returns volumes stored in pool or all pools
'''
return
POOL_STATE
[
pool
.
info
()[
0
]]
volumes
=
[]
if
pool
is
None
:
for
pool
in
self
.
_pools
.
iteritems
():
volumes
.
extend
(
pool
[
1
].
listVolumes
())
else
:
volumes
=
pool
.
listVolumes
()
return
volumes
def
add_volume
(
self
,
pool
,
name
,
space
):
'''
...
...
@@ -423,6 +411,45 @@ class LibvirtHVStorage(HVStorage):
raise
StorageError
(
"
Can
'
t query pool informations (%s)
"
%
e
)
return
False
def
get_pool_state
(
self
,
pool
):
'''
Returns the running state of the pool
:param pool: the storage pool name
:type pool: libvirt.`virStoragePool`
'''
return
POOL_STATE
[
pool
.
info
()[
0
]]
def
get_pool_total_space
(
self
,
pool
):
'''
Returns the storage capacity of this pool in gigabytes
:param pool: the pool to get information from
:type pool: :class:`virStoragePool`
:return: :class:`int` of capacity in gigabytes
'''
return
pool
.
info
()[
1
];
def
get_pool_available_space
(
self
,
pool
):
'''
Returns available space of this storage pool in gigabytes
:param pool: the pool to get information from
:type pool: :class:`virStoragePool`
:return: :class:`int` of available free space in gigabytes
'''
return
pool
.
info
()[
2
];
def
get_pool_used_space
(
self
,
pool
):
'''
Returns current storage pool usage in gigabytes
:param pool: the pool to get information from
:type pool: :class:`virStoragePool`
:return: :class:`int` of used space in gigabytes
'''
return
pool
.
info
()[
3
];
#### 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