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
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
407f3782
authored
Apr 09, 2019
by
adamtorok
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
upgrades
parent
b84611e4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
8 deletions
+28
-8
implementation/storage/OpenstackStorageManager.py
+28
-8
No files found.
implementation/storage/OpenstackStorageManager.py
View file @
407f3782
import
Volume
import
openstack
import
StorageManager
from
openstack.exceptions
import
ResourceNotFound
from
interface.storage.Volume
import
Volume
class
OpenstackStorageManager
(
StorageManager
.
StorageManager
):
def
__init__
(
self
,
cloud
)
->
None
:
def
__init__
(
self
,
openstack
)
->
None
:
super
()
.
__init__
()
self
.
openstack
=
openstack
.
connect
(
cloud
=
cloud
)
self
.
openstack
=
openstack
@staticmethod
def
os_volume_to_rc_volume
(
os_volume
):
return
Volume
.
Volume
(
return
Volume
(
os_volume
.
id
,
os_volume
.
size
,
os_volume
.
is_bootable
os_volume
.
is_bootable
,
os_volume
.
status
,
os_volume
.
created_at
)
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
)
def
get
(
self
,
id
):
try
:
os_volume
=
self
.
openstack
.
block_storage
.
get_volume
(
id
)
except
ResourceNotFound
:
return
None
return
self
.
os_volume_to_rc_volume
(
os_volume
)
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
):
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