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
8edd7811
authored
Jul 04, 2019
by
Belákovics Ádám
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'extend_volume' into 'DEV'
Extend volume See merge request
!5
parents
f22ec7f1
c551e4f0
Pipeline
#736
passed with stage
in 40 seconds
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
16 deletions
+33
-16
implementation/image/OpenstackImageManager.py
+7
-5
implementation/storage/OpenstackSnapshotManager.py
+7
-5
implementation/storage/OpenstackStorageManager.py
+16
-6
interface/storage/StorageManager.py
+3
-0
No files found.
implementation/image/OpenstackImageManager.py
View file @
8edd7811
from
typing
import
Optional
from
openstack.exceptions
import
ResourceNotFound
from
interface_openstack.interface.image.ImageManager
import
ImageManager
...
...
@@ -12,14 +14,14 @@ class OpenstackImageManager(ImageManager):
self
.
openstack
=
openstack
@staticmethod
def
os_image_to_rc_image
(
os_image
):
def
os_image_to_rc_image
(
os_image
)
->
Image
:
return
Image
(
os_image
.
id
,
os_image
.
name
,
os_image
.
disk_format
)
def
upload_file
(
self
,
name
,
path
,
format
):
def
upload_file
(
self
,
name
,
path
,
format
)
->
Image
:
os_image
=
self
.
openstack
.
image
.
create_image
(
name
=
name
,
filename
=
path
,
...
...
@@ -28,7 +30,7 @@ class OpenstackImageManager(ImageManager):
return
self
.
os_image_to_rc_image
(
os_image
)
def
get
(
self
,
id
):
def
get
(
self
,
id
)
->
Optional
[
Image
]
:
try
:
os_image
=
self
.
openstack
.
image
.
get_image
(
id
)
except
ResourceNotFound
:
...
...
@@ -39,7 +41,7 @@ class OpenstackImageManager(ImageManager):
def
download
(
self
,
id
):
return
self
.
openstack
.
image
.
download_image
(
id
)
def
delete
(
self
,
id
):
def
delete
(
self
,
id
)
->
bool
:
try
:
self
.
openstack
.
image
.
delete_image
(
id
)
except
ResourceNotFound
:
...
...
@@ -47,7 +49,7 @@ class OpenstackImageManager(ImageManager):
return
True
def
list
(
self
):
def
list
(
self
)
->
[]
:
images
=
[]
for
os_image
in
self
.
openstack
.
image
.
images
():
...
...
implementation/storage/OpenstackSnapshotManager.py
View file @
8edd7811
from
typing
import
Optional
from
openstack.exceptions
import
ResourceNotFound
from
interface_openstack.interface.storage.Snapshot
import
Snapshot
...
...
@@ -12,7 +14,7 @@ class OpenstackSnapshotManager(SnapshotManager):
self
.
openstack
=
os
@staticmethod
def
os_snapshot_to_rc_snapshot
(
os_snapshot
):
def
os_snapshot_to_rc_snapshot
(
os_snapshot
)
->
Snapshot
:
return
Snapshot
(
os_snapshot
.
id
,
os_snapshot
.
volume_id
,
...
...
@@ -21,12 +23,12 @@ class OpenstackSnapshotManager(SnapshotManager):
os_snapshot
.
created_at
)
def
create_from_volume
(
self
,
id
):
def
create_from_volume
(
self
,
id
)
->
Snapshot
:
os_snapshot
=
self
.
openstack
.
block_storage
.
create_snapshot
(
volume_id
=
id
)
return
self
.
os_snapshot_to_rc_snapshot
(
os_snapshot
)
def
get
(
self
,
id
):
def
get
(
self
,
id
)
->
Optional
[
Snapshot
]
:
try
:
os_snapshot
=
self
.
openstack
.
block_storage
.
get_snapshot
(
id
)
except
ResourceNotFound
:
...
...
@@ -34,7 +36,7 @@ class OpenstackSnapshotManager(SnapshotManager):
return
self
.
os_snapshot_to_rc_snapshot
(
os_snapshot
)
def
list
(
self
):
def
list
(
self
)
->
[]
:
snapshots
=
[]
for
os_snapshot
in
self
.
openstack
.
block_storage
.
snapshots
():
...
...
@@ -42,7 +44,7 @@ class OpenstackSnapshotManager(SnapshotManager):
return
snapshots
def
delete
(
self
,
id
):
def
delete
(
self
,
id
)
->
bool
:
try
:
self
.
openstack
.
block_storage
.
delete_snapshot
(
id
)
except
ResourceNotFound
:
...
...
implementation/storage/OpenstackStorageManager.py
View file @
8edd7811
from
typing
import
Optional
from
openstack.exceptions
import
ResourceNotFound
from
interface_openstack.interface.storage.StorageManager
import
StorageManager
...
...
@@ -12,7 +14,7 @@ class OpenstackStorageManager(StorageManager):
self
.
openstack
=
openstack
@staticmethod
def
os_volume_to_rc_volume
(
os_volume
):
def
os_volume_to_rc_volume
(
os_volume
)
->
Volume
:
return
Volume
(
os_volume
.
id
,
os_volume
.
image_id
,
...
...
@@ -22,14 +24,14 @@ class OpenstackStorageManager(StorageManager):
os_volume
.
created_at
)
def
create
(
self
,
size
):
def
create
(
self
,
size
)
->
Volume
:
os_volume
=
self
.
openstack
.
block_storage
.
create_volume
(
size
=
size
)
return
self
.
os_volume_to_rc_volume
(
os_volume
)
def
create_from_image
(
self
,
id
,
size
,
bootable
):
def
create_from_image
(
self
,
id
,
size
,
bootable
)
->
Volume
:
os_volume
=
self
.
openstack
.
block_storage
.
create_volume
(
image_id
=
id
,
size
=
size
,
...
...
@@ -38,14 +40,14 @@ class OpenstackStorageManager(StorageManager):
return
self
.
os_volume_to_rc_volume
(
os_volume
)
def
create_from_snapshot
(
self
,
id
):
def
create_from_snapshot
(
self
,
id
)
->
Volume
:
os_volume
=
self
.
openstack
.
block_storage
.
create_volume
(
snapshot_id
=
id
)
return
self
.
os_volume_to_rc_volume
(
os_volume
)
def
get
(
self
,
id
):
def
get
(
self
,
id
)
->
Optional
[
Volume
]
:
try
:
os_volume
=
self
.
openstack
.
block_storage
.
get_volume
(
id
)
except
ResourceNotFound
:
...
...
@@ -61,7 +63,15 @@ class OpenstackStorageManager(StorageManager):
return
True
def
list
(
self
):
def
extend
(
self
,
id
,
size
)
->
bool
:
try
:
self
.
openstack
.
block_storage
.
extend_volume
(
id
,
size
)
except
ResourceNotFound
:
return
False
return
True
def
list
(
self
)
->
[]:
volumes
=
[]
for
os_volume
in
self
.
openstack
.
block_storage
.
volumes
():
...
...
interface/storage/StorageManager.py
View file @
8edd7811
...
...
@@ -17,5 +17,8 @@ class StorageManager:
def
delete
(
self
,
id
):
raise
NotImplementedError
def
extend
(
self
,
id
,
size
):
raise
NotImplementedError
def
list
(
self
):
raise
NotImplementedError
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