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
fcb0150a
authored
Apr 09, 2019
by
adamtorok
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fix
parent
bbe885fe
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
19 deletions
+61
-19
implementation/storage/OpenstackSnapshotManager.py
+39
-0
implementation/storage/OpenstackStorageManager.py
+22
-19
No files found.
implementation/storage/OpenstackSnapshotManager.py
0 → 100644
View file @
fcb0150a
import
Snapshot
import
SnapshotManager
import
openstack
class
OpenstackSnapshotManager
(
SnapshotManager
.
SnapshotManager
):
def
__init__
(
self
,
cloud
)
->
None
:
super
()
.
__init__
()
self
.
openstack
=
openstack
.
connect
(
cloud
=
cloud
)
@staticmethod
def
os_snapshot_to_rc_snapshot
(
os_snapshot
):
return
Snapshot
.
Snapshot
(
os_snapshot
.
id
,
os_snapshot
.
size
)
def
create_from_volume
(
self
,
id
):
os_snapshot
=
self
.
openstack
.
block_storage
.
create_snapshot
(
volume_id
=
id
)
return
self
.
os_snapshot_to_rc_snapshot
(
os_snapshot
)
def
get
(
self
,
id
):
os_snapshot
=
self
.
openstack
.
block_storage
.
get_snapshot
(
id
)
return
self
.
os_snapshot_to_rc_snapshot
(
os_snapshot
)
def
list
(
self
):
snapshots
=
[]
for
os_snapshot
in
self
.
openstack
.
block_storage
.
snapshots
():
snapshots
.
append
(
self
.
os_snapshot_to_rc_snapshot
(
os_snapshot
))
return
snapshots
def
delete
(
self
,
id
):
print
(
self
.
openstack
.
block_storage
.
delete_snapshot
(
id
))
implementation/storage/OpenstackStorageManager.py
View file @
fcb0150a
import
Snapshot
import
SnapshotManager
import
Volume
import
openstack
import
StorageManager
class
OpenstackS
napshotManager
(
SnapshotManager
.
Snapshot
Manager
):
class
OpenstackS
torageManager
(
StorageManager
.
Storage
Manager
):
def
__init__
(
self
,
cloud
)
->
None
:
super
()
.
__init__
()
self
.
openstack
=
openstack
.
connect
(
cloud
=
cloud
)
@staticmethod
def
os_snapshot_to_rc_snapshot
(
os_snapshot
):
return
Snapshot
.
Snapshot
(
os_snapshot
.
id
,
os_snapshot
.
size
def
os_volume_to_rc_volume
(
os_volume
):
return
Volume
.
Volume
(
os_volume
.
id
,
os_volume
.
size
,
os_volume
.
is_bootable
)
def
create
_from_volume
(
self
,
id
):
os_
snapshot
=
self
.
openstack
.
block_storage
.
create_snapshot
(
volume_id
=
id
)
def
create
(
self
,
size
,
bootable
):
os_
volume
=
self
.
openstack
.
block_storage
.
create_volume
(
size
=
size
,
bootable
=
bootable
)
return
self
.
os_
snapshot_to_rc_snapshot
(
os_snapshot
)
return
self
.
os_
volume_to_rc_volume
(
os_volume
)
def
get
(
self
,
id
):
os_snapshot
=
self
.
openstack
.
block_storage
.
get_snapshot
(
id
)
os_volume
=
self
.
openstack
.
block_storage
.
get_volume
(
id
)
return
self
.
os_volume_to_rc_volume
(
os_volume
)
return
self
.
os_snapshot_to_rc_snapshot
(
os_snapshot
)
def
delete
(
self
,
id
):
print
(
self
.
openstack
.
block_storage
.
delete_volume
(
id
))
def
list
(
self
):
snapshot
s
=
[]
volume
s
=
[]
for
os_
snapshot
in
self
.
openstack
.
block_storage
.
snapshot
s
():
snapshots
.
append
(
self
.
os_snapshot_to_rc_snapshot
(
os_snapshot
))
for
os_
volume
in
self
.
openstack
.
block_storage
.
volume
s
():
volumes
.
append
(
self
.
os_volume_to_rc_volume
(
os_volume
))
return
snapshot
s
return
volume
s
def
delet
e
(
self
,
id
):
p
rint
(
self
.
openstack
.
block_storage
.
delete_snapshot
(
id
))
def
resiz
e
(
self
,
id
):
p
ass
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