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
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
befe5fa1
authored
Sep 03, 2019
by
Belákovics Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modify update response
parent
52626ae9
Pipeline
#861
passed with stage
in 1 minute 21 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
recircle/instance/views.py
+4
-3
No files found.
recircle/instance/views.py
View file @
befe5fa1
...
@@ -16,6 +16,7 @@ authorization = {
...
@@ -16,6 +16,7 @@ authorization = {
"list"
:
{
"filter"
:
[
"use_instance"
]},
"list"
:
{
"filter"
:
[
"use_instance"
]},
"create"
:
{
"model"
:
[
"instance.create_instance"
]},
"create"
:
{
"model"
:
[
"instance.create_instance"
]},
"retrieve"
:
{
"object"
:
[
"use_instance"
]},
"retrieve"
:
{
"object"
:
[
"use_instance"
]},
"update"
:
{
"object"
:
[
"use_instance"
]},
"destroy"
:
{
"object"
:
[
"administer_instance"
]},
"destroy"
:
{
"object"
:
[
"administer_instance"
]},
"template"
:
{
"model"
:
[
"create_template_from_instance"
],
"template"
:
{
"model"
:
[
"create_template_from_instance"
],
"object"
:
[
"use_instance"
]},
"object"
:
[
"use_instance"
]},
...
@@ -105,7 +106,7 @@ class InstanceViewSet(AuthorizationMixin, ViewSet):
...
@@ -105,7 +106,7 @@ class InstanceViewSet(AuthorizationMixin, ViewSet):
def
update
(
self
,
request
,
pk
,
format
=
None
):
def
update
(
self
,
request
,
pk
,
format
=
None
):
if
request
.
data
[
"action"
]
in
update_actions
:
if
request
.
data
[
"action"
]
in
update_actions
:
instance
=
self
.
get_object
(
pk
)
instance
=
self
.
get_object
(
pk
)
if
not
self
.
has_perms_for_object
(
request
.
user
,
'
retriev
e'
,
instance
):
if
not
self
.
has_perms_for_object
(
request
.
user
,
'
updat
e'
,
instance
):
return
Response
({
"error"
:
"No permission to access the Virtual Machine."
},
return
Response
({
"error"
:
"No permission to access the Virtual Machine."
},
status
=
status
.
HTTP_401_UNAUTHORIZED
)
status
=
status
.
HTTP_401_UNAUTHORIZED
)
action
=
request
.
data
[
"action"
]
action
=
request
.
data
[
"action"
]
...
@@ -116,7 +117,7 @@ class InstanceViewSet(AuthorizationMixin, ViewSet):
...
@@ -116,7 +117,7 @@ class InstanceViewSet(AuthorizationMixin, ViewSet):
elif
action
==
"renew"
:
elif
action
==
"renew"
:
instance
.
renew
()
instance
.
renew
()
elif
action
==
"change_lease"
:
elif
action
==
"change_lease"
:
lease
=
Lease
.
objects
.
get
(
id
=
request
.
data
[
"lease"
])
lease
=
Lease
.
objects
.
get
(
pk
=
request
.
data
[
"lease"
])
instance
.
renew
(
lease
)
instance
.
renew
(
lease
)
elif
action
==
"change_flavor"
:
elif
action
==
"change_flavor"
:
pass
pass
...
@@ -142,7 +143,7 @@ class InstanceViewSet(AuthorizationMixin, ViewSet):
...
@@ -142,7 +143,7 @@ class InstanceViewSet(AuthorizationMixin, ViewSet):
instanceDict
=
InstanceSerializer
(
instance
)
.
data
instanceDict
=
InstanceSerializer
(
instance
)
.
data
remoteInstance
=
instance
.
get_remote_instance
()
remoteInstance
=
instance
.
get_remote_instance
()
remoteInstanceDict
=
remoteInstance
.
__dict__
remoteInstanceDict
=
remoteInstance
.
__dict__
merged_dict
=
{
**
instanceDict
,
**
remoteInstanceDict
}
merged_dict
=
{
"db"
:
instanceDict
,
"openstack"
:
remoteInstanceDict
}
return
Response
(
merged_dict
)
return
Response
(
merged_dict
)
else
:
else
:
return
Response
({
"error"
:
"Unknown update action."
},
status
=
status
.
HTTP_400_BAD_REQUEST
)
return
Response
({
"error"
:
"Unknown update action."
},
status
=
status
.
HTTP_400_BAD_REQUEST
)
...
...
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