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
f34faabf
authored
Apr 16, 2020
by
Chif Gergő
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Call remote resize in model
parent
720ab1e4
Pipeline
#1070
passed with stage
in 1 minute 32 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
9 deletions
+16
-9
recircle/instance/models.py
+9
-0
recircle/instance/views.py
+7
-9
No files found.
recircle/instance/models.py
View file @
f34faabf
...
...
@@ -264,6 +264,15 @@ class Instance(BaseMachineDescriptor):
self
.
password
=
self
.
generate_password
()
self
.
save
()
def
resize
(
self
,
flavor
):
try
:
interface
.
resize_vm
(
self
.
remote_id
,
flavor
)
self
.
flavor
=
flavor
self
.
save
()
except
Exception
as
e
:
if
e
.
OpenStackError
:
logger
.
error
(
"Can not resize the instance in remote cloud"
)
def
change_name
(
self
,
new_name
):
self
.
name
=
new_name
self
.
save
()
...
...
recircle/instance/views.py
View file @
f34faabf
...
...
@@ -168,15 +168,13 @@ class InstanceViewSet(AuthorizationMixin, ViewSet):
@action
(
detail
=
True
,
methods
=
[
"POST"
])
def
resize
(
self
,
request
,
pk
):
pass
# TODO: resize not implemented in model
# instance = self.get_object(pk)
# if "flavor" in request.data:
# flavor = Flavor.objects.get(pk=request.data["flavor"])
# instance.resize(flavor)
# return Response(status=status.HTTP_200_OK)
# else:
# return Response(data="No new flavor provided", status=status.HTTP_400_BAD_REQUEST)
instance
=
self
.
get_object
(
pk
)
if
"flavor"
in
request
.
data
:
flavor
=
Flavor
.
objects
.
get
(
pk
=
request
.
data
[
"flavor"
])
instance
.
resize
(
flavor
)
return
Response
(
status
=
status
.
HTTP_200_OK
)
else
:
return
Response
(
data
=
"No new flavor provided"
,
status
=
status
.
HTTP_400_BAD_REQUEST
)
@action
(
detail
=
True
,
methods
=
[
"POST"
])
def
attach_disk
(
self
,
request
,
pk
):
...
...
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