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
d3e11cc8
authored
5 years ago
by
adamtorok
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
upgrades
parent
34480589
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
11 deletions
+25
-11
implementation/image/OpenstackImageManager.py
+25
-11
No files found.
implementation/image/OpenstackImageManager.py
View file @
d3e11cc8
import
openstack
import
Image
import
ImageManager
from
openstack.exceptions
import
ResourceNotFound
from
interface.image.ImageManager
import
ImageManager
from
interface.image.Image
import
Image
class
OpenstackImageManager
(
ImageManager
.
ImageManager
):
def
__init__
(
self
,
cloud
)
->
None
:
class
OpenstackImageManager
(
ImageManager
):
def
__init__
(
self
,
openstack
)
->
None
:
super
()
.
__init__
()
self
.
openstack
=
openstack
.
connect
(
cloud
=
cloud
)
self
.
openstack
=
openstack
@staticmethod
def
os_image_to_rc_image
(
os_image
):
return
Image
.
Image
(
return
Image
(
os_image
.
id
,
os_image
.
name
,
os_image
.
disk_format
)
def
upload_file
(
self
,
path
):
os_image
=
self
.
openstack
.
image
.
create_image
(
name
=
path
,
filename
=
path
,
disk_format
=
'iso'
)
def
upload_file
(
self
,
name
,
path
,
format
):
os_image
=
self
.
openstack
.
image
.
create_image
(
name
=
name
,
filename
=
path
,
disk_format
=
format
)
return
self
.
os_image_to_rc_image
(
os_image
)
def
get
(
self
,
id
):
os_image
=
self
.
openstack
.
image
.
get_image
(
id
)
try
:
os_image
=
self
.
openstack
.
image
.
get_image
(
id
)
except
ResourceNotFound
:
return
None
return
self
.
os_image_to_rc_image
(
os_image
)
def
delete
(
self
,
id
):
self
.
openstack
.
image
.
delete_image
(
id
)
try
:
self
.
openstack
.
image
.
delete_image
(
id
)
except
ResourceNotFound
:
return
False
return
True
def
list
(
self
):
images
=
[]
...
...
This diff is collapsed.
Click to expand it.
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