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
Show 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):
...
@@ -264,6 +264,15 @@ class Instance(BaseMachineDescriptor):
self
.
password
=
self
.
generate_password
()
self
.
password
=
self
.
generate_password
()
self
.
save
()
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
):
def
change_name
(
self
,
new_name
):
self
.
name
=
new_name
self
.
name
=
new_name
self
.
save
()
self
.
save
()
...
...
recircle/instance/views.py
View file @
f34faabf
...
@@ -168,15 +168,13 @@ class InstanceViewSet(AuthorizationMixin, ViewSet):
...
@@ -168,15 +168,13 @@ class InstanceViewSet(AuthorizationMixin, ViewSet):
@action
(
detail
=
True
,
methods
=
[
"POST"
])
@action
(
detail
=
True
,
methods
=
[
"POST"
])
def
resize
(
self
,
request
,
pk
):
def
resize
(
self
,
request
,
pk
):
pass
instance
=
self
.
get_object
(
pk
)
# TODO: resize not implemented in model
if
"flavor"
in
request
.
data
:
# instance = self.get_object(pk)
flavor
=
Flavor
.
objects
.
get
(
pk
=
request
.
data
[
"flavor"
])
# if "flavor" in request.data:
instance
.
resize
(
flavor
)
# flavor = Flavor.objects.get(pk=request.data["flavor"])
return
Response
(
status
=
status
.
HTTP_200_OK
)
# instance.resize(flavor)
else
:
# return Response(status=status.HTTP_200_OK)
return
Response
(
data
=
"No new flavor provided"
,
status
=
status
.
HTTP_400_BAD_REQUEST
)
# else:
# return Response(data="No new flavor provided", status=status.HTTP_400_BAD_REQUEST)
@action
(
detail
=
True
,
methods
=
[
"POST"
])
@action
(
detail
=
True
,
methods
=
[
"POST"
])
def
attach_disk
(
self
,
request
,
pk
):
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