Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
RECIRCLE
/
portal
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
11
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
261dd9e0
authored
May 13, 2019
by
Gazdag Péter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add image view
parent
eeb4dcd3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
3 deletions
+21
-3
recircle/image/urls.py
+7
-3
recircle/image/views.py
+14
-0
No files found.
recircle/image/urls.py
View file @
261dd9e0
from
django.urls
import
include
,
path
from
rest_framework.urlpatterns
import
format_suffix_patterns
from
image
import
views
urlpatterns
=
[
path
(
'image/'
,
include
(
'image.urls'
)),
]
\ No newline at end of file
path
(
''
,
views
.
DiskList
.
as_view
()),
]
urlpatterns
=
format_suffix_patterns
(
urlpatterns
)
\ No newline at end of file
recircle/image/views.py
View file @
261dd9e0
from
image.models
import
Disk
from
image.serializers
import
DiskSerializer
from
django.shortcuts
import
render
from
rest_framework.views
import
APIView
from
rest_framework.response
import
Response
from
implementation.image.OpenstackImageManager
import
OpenstackImageManager
import
openstack
conn
=
openstack
.
connect
(
cloud
=
'openstack'
)
class
DiskList
(
APIView
):
def
get
(
self
,
request
,
format
=
None
):
#OpenStack
interface
=
OpenstackImageManager
(
conn
)
return
Response
([
disk
.
toJSON
()
for
disk
in
interface
.
list
()])
#Create response
disks
=
Disk
.
object
.
all
()
serializer
=
DiskSerializer
(
disks
,
many
=
True
)
return
Response
(
serializer
.
data
)
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