Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
RECIRCLE
/
interface-openstack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
2
Merge Requests
4
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
407f3782
authored
Apr 09, 2019
by
adamtorok
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
upgrades
parent
b84611e4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
9 deletions
+29
-9
implementation/storage/OpenstackStorageManager.py
+29
-9
No files found.
implementation/storage/OpenstackStorageManager.py
View file @
407f3782
import
Volume
import
openstack
import
StorageManager
import
StorageManager
from
openstack.exceptions
import
ResourceNotFound
from
interface.storage.Volume
import
Volume
class
OpenstackStorageManager
(
StorageManager
.
StorageManager
):
class
OpenstackStorageManager
(
StorageManager
.
StorageManager
):
def
__init__
(
self
,
cloud
)
->
None
:
def
__init__
(
self
,
openstack
)
->
None
:
super
()
.
__init__
()
super
()
.
__init__
()
self
.
openstack
=
openstack
.
connect
(
cloud
=
cloud
)
self
.
openstack
=
openstack
@staticmethod
@staticmethod
def
os_volume_to_rc_volume
(
os_volume
):
def
os_volume_to_rc_volume
(
os_volume
):
return
Volume
.
Volume
(
return
Volume
(
os_volume
.
id
,
os_volume
.
id
,
os_volume
.
size
,
os_volume
.
size
,
os_volume
.
is_bootable
os_volume
.
is_bootable
,
os_volume
.
status
,
os_volume
.
created_at
)
)
def
create
(
self
,
size
,
bootable
):
def
create
(
self
,
size
,
bootable
):
os_volume
=
self
.
openstack
.
block_storage
.
create_volume
(
size
=
size
,
bootable
=
bootable
)
os_volume
=
self
.
openstack
.
block_storage
.
create_volume
(
size
=
size
,
bootable
=
bootable
)
return
self
.
os_volume_to_rc_volume
(
os_volume
)
def
create_from_snapshot
(
self
,
id
):
os_volume
=
self
.
openstack
.
block_storage
.
create_volume
(
snapshot_id
=
id
)
return
self
.
os_volume_to_rc_volume
(
os_volume
)
return
self
.
os_volume_to_rc_volume
(
os_volume
)
def
get
(
self
,
id
):
def
get
(
self
,
id
):
os_volume
=
self
.
openstack
.
block_storage
.
get_volume
(
id
)
try
:
os_volume
=
self
.
openstack
.
block_storage
.
get_volume
(
id
)
except
ResourceNotFound
:
return
None
return
self
.
os_volume_to_rc_volume
(
os_volume
)
return
self
.
os_volume_to_rc_volume
(
os_volume
)
def
delete
(
self
,
id
):
def
delete
(
self
,
id
):
print
(
self
.
openstack
.
block_storage
.
delete_volume
(
id
))
try
:
self
.
openstack
.
block_storage
.
delete_volume
(
id
)
except
ResourceNotFound
:
return
False
return
True
def
list
(
self
):
def
list
(
self
):
volumes
=
[]
volumes
=
[]
...
...
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