Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
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
da10884e
authored
Nov 30, 2017
by
Czémán Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network, dashboard: add EditorElement model
parent
c152076c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
0 deletions
+68
-0
circle/network/migrations/0003_editorelement.py
+31
-0
circle/network/models.py
+33
-0
circle/vm/models/instance.py
+4
-0
No files found.
circle/network/migrations/0003_editorelement.py
0 → 100644
View file @
da10884e
# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2017-11-30 01:01
from
__future__
import
unicode_literals
from
django.conf
import
settings
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'contenttypes'
,
'0002_remove_content_type_name'
),
migrations
.
swappable_dependency
(
settings
.
AUTH_USER_MODEL
),
(
'network'
,
'0002_auto_20171110_0041'
),
]
operations
=
[
migrations
.
CreateModel
(
name
=
'EditorElement'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'x'
,
models
.
IntegerField
()),
(
'y'
,
models
.
IntegerField
()),
(
'free_port_num'
,
models
.
IntegerField
()),
(
'object_id'
,
models
.
PositiveIntegerField
()),
(
'content_type'
,
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'contenttypes.ContentType'
)),
(
'owner'
,
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
settings
.
AUTH_USER_MODEL
)),
],
),
]
circle/network/models.py
View file @
da10884e
...
...
@@ -14,17 +14,49 @@
#
# You should have received a copy of the GNU General Public License along
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
from
django.db
import
models
from
django.contrib.auth.models
import
User
from
django.core.validators
import
MinValueValidator
,
MaxValueValidator
from
django.core.urlresolvers
import
reverse
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.contrib.contenttypes.fields
import
(
GenericRelation
,
GenericForeignKey
)
from
django.contrib.contenttypes.models
import
ContentType
from
acl.models
import
AclBase
from
firewall.models
import
Vlan
from
firewall.fields
import
val_alfanum
class
EditorElement
(
models
.
Model
):
x
=
models
.
IntegerField
()
y
=
models
.
IntegerField
()
free_port_num
=
models
.
IntegerField
()
owner
=
models
.
ForeignKey
(
User
)
content_type
=
models
.
ForeignKey
(
ContentType
,
on_delete
=
models
.
CASCADE
)
object_id
=
models
.
PositiveIntegerField
()
content_object
=
GenericForeignKey
()
def
as_data
(
self
):
type
=
'network'
if
isinstance
(
self
.
content_object
,
Vxlan
)
else
'vm'
if
type
==
'network'
:
id
=
"net-
%
s"
%
self
.
content_object
.
vni
else
:
id
=
"vm-
%
s"
%
self
.
content_object
.
pk
return
{
'name'
:
unicode
(
self
.
content_object
),
'id'
:
id
,
'x'
:
self
.
x
,
'y'
:
self
.
y
,
'free_port_num'
:
self
.
free_port_num
,
'type'
:
type
,
'description'
:
self
.
content_object
.
description
,
}
class
Vxlan
(
AclBase
,
models
.
Model
):
"""
...
...
@@ -73,6 +105,7 @@ class Vxlan(AclBase, models.Model):
verbose_name
=
_
(
'owner'
))
modified_at
=
models
.
DateTimeField
(
auto_now
=
True
,
verbose_name
=
_
(
'modified at'
))
editor_elements
=
GenericRelation
(
EditorElement
)
class
Meta
:
app_label
=
'network'
...
...
circle/vm/models/instance.py
View file @
da10884e
...
...
@@ -34,6 +34,7 @@ from django.db import IntegrityError
from
django.dispatch
import
Signal
from
django.utils
import
timezone
from
django.utils.translation
import
ugettext_lazy
as
_
,
ugettext_noop
from
django.contrib.contenttypes.fields
import
GenericRelation
from
model_utils
import
Choices
from
model_utils.managers
import
QueryManager
...
...
@@ -50,6 +51,8 @@ from .activity import (ActivityInProgressError, InstanceActivity)
from
.common
import
BaseResourceConfigModel
,
Lease
from
.network
import
Interface
from
.node
import
Node
,
Trait
from
network.models
import
EditorElement
logger
=
getLogger
(
__name__
)
pre_state_changed
=
Signal
(
providing_args
=
[
"new_state"
])
...
...
@@ -256,6 +259,7 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
destroyed_at
=
DateTimeField
(
blank
=
True
,
null
=
True
,
help_text
=
_
(
"The virtual machine's time of "
"destruction."
))
editor_elements
=
GenericRelation
(
EditorElement
)
objects
=
Manager
()
active
=
QueryManager
(
destroyed_at
=
None
)
...
...
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