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
edf318bc
authored
Aug 07, 2019
by
Chif Gergő
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add network_id field to template
parent
350011be
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
3 deletions
+27
-3
recircle/instance/models.py
+1
-2
recircle/instance/views.py
+1
-1
recircle/template/migrations/0007_basetemplate_network_id.py
+18
-0
recircle/template/models.py
+7
-0
No files found.
recircle/instance/models.py
View file @
edf318bc
...
@@ -143,12 +143,11 @@ class Instance(models.Model):
...
@@ -143,12 +143,11 @@ class Instance(models.Model):
disks
,
networks
,
flavor
):
disks
,
networks
,
flavor
):
# TODO: attach disks when the remote instance created
# TODO: attach disks when the remote instance created
try
:
try
:
remote_i
nst
=
interface
.
create_vm_from_template
(
params
[
"name"
],
remote_i
d
=
interface
.
create_vm_from_template
(
params
[
"name"
],
template
.
image
.
remote_id
,
template
.
image
.
remote_id
,
flavor
.
remote_id
,
flavor
.
remote_id
,
networks
,
networks
,
)
)
remote_id
=
remote_inst
.
id
new_inst
=
cls
.
create
(
lease
,
owner
,
flavor
,
template
,
new_inst
=
cls
.
create
(
lease
,
owner
,
flavor
,
template
,
remote_id
,
params
)
remote_id
,
params
)
return
new_inst
return
new_inst
...
...
recircle/instance/views.py
View file @
edf318bc
...
@@ -45,7 +45,7 @@ class InstanceViewSet(ViewSet):
...
@@ -45,7 +45,7 @@ class InstanceViewSet(ViewSet):
"system"
:
data
[
"system"
],
"system"
:
data
[
"system"
],
},
},
lease
=
template
.
lease
,
lease
=
template
.
lease
,
networks
=
[{
"uuid"
:
"7485b41f-2524-4399-a20b-4b2c7ee9fd01"
}],
networks
=
[{
"uuid"
:
template
.
network_id
}],
template
=
template
,
template
=
template
,
flavor
=
template
.
flavor
,
flavor
=
template
.
flavor
,
owner
=
request
.
user
,
owner
=
request
.
user
,
...
...
recircle/template/migrations/0007_basetemplate_network_id.py
0 → 100644
View file @
edf318bc
# Generated by Django 2.2.3 on 2019-08-07 12:19
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'template'
,
'0006_auto_20190719_1416'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'basetemplate'
,
name
=
'network_id'
,
field
=
models
.
CharField
(
blank
=
True
,
help_text
=
'The new instance will be in this network.'
,
max_length
=
100
,
null
=
True
,
verbose_name
=
'network_id'
),
),
]
recircle/template/models.py
View file @
edf318bc
...
@@ -44,6 +44,13 @@ class BaseTemplate(models.Model):
...
@@ -44,6 +44,13 @@ class BaseTemplate(models.Model):
related_name
=
'templates'
)
related_name
=
'templates'
)
lease
=
models
.
ForeignKey
(
Lease
,
on_delete
=
"CASCADE"
,
lease
=
models
.
ForeignKey
(
Lease
,
on_delete
=
"CASCADE"
,
related_name
=
'templates'
)
related_name
=
'templates'
)
network_id
=
models
.
CharField
(
max_length
=
100
,
verbose_name
=
"network_id"
,
help_text
=
"The new instance will be in this network."
,
null
=
True
,
blank
=
True
)
class
DiskTemplate
(
BaseTemplate
):
class
DiskTemplate
(
BaseTemplate
):
...
...
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