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
d5924475
authored
Nov 15, 2013
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: add traits
parent
d58e62b1
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
2 deletions
+22
-2
circle/vm/admin.py
+2
-1
circle/vm/migrations/0010_auto__add_trait.py
+0
-0
circle/vm/models.py
+20
-1
No files found.
circle/vm/admin.py
View file @
d5924475
...
...
@@ -2,7 +2,7 @@ from django.contrib import admin
from
.models
import
(
Instance
,
InstanceActivity
,
InstanceTemplate
,
Interface
,
InterfaceTemplate
,
Lease
,
NamedBaseResourceConfig
,
Node
,
NodeActivity
)
NodeActivity
,
Trait
)
admin
.
site
.
register
(
Instance
)
...
...
@@ -14,3 +14,4 @@ admin.site.register(Lease)
admin
.
site
.
register
(
NamedBaseResourceConfig
)
admin
.
site
.
register
(
Node
)
admin
.
site
.
register
(
NodeActivity
)
admin
.
site
.
register
(
Trait
)
circle/vm/migrations/0010_auto__add_trait.py
0 → 100644
View file @
d5924475
This diff is collapsed.
Click to expand it.
circle/vm/models.py
View file @
d5924475
...
...
@@ -66,6 +66,13 @@ class NamedBaseResourceConfig(BaseResourceConfigModel, TimeStampedModel):
return
self
.
name
class
Trait
(
Model
):
name
=
CharField
(
max_length
=
50
,
verbose_name
=
_
(
'name'
))
def
__unicode__
(
self
):
return
self
.
name
class
VirtualMachineDescModel
(
BaseResourceConfigModel
):
"""Abstract base for virtual machine describing models.
"""
...
...
@@ -77,6 +84,11 @@ class VirtualMachineDescModel(BaseResourceConfigModel):
'Show boot device selection menu on boot.'
))
raw_data
=
TextField
(
verbose_name
=
_
(
'raw_data'
),
blank
=
True
,
help_text
=
_
(
'Additional libvirt domain parameters in XML format.'
))
req_traits
=
ManyToManyField
(
Trait
,
blank
=
True
,
help_text
=
_
(
"A set of traits required for a "
"node to declare to be suitable "
"for hosting the VM."
),
verbose_name
=
_
(
"required traits"
))
tags
=
TaggableManager
(
blank
=
True
,
verbose_name
=
_
(
"tags"
))
class
Meta
:
...
...
@@ -102,6 +114,9 @@ class Node(TimeStampedModel):
enabled
=
BooleanField
(
verbose_name
=
_
(
'enabled'
),
default
=
False
,
help_text
=
_
(
'Indicates whether the node can '
'be used for hosting.'
))
traits
=
ManyToManyField
(
Trait
,
blank
=
True
,
help_text
=
_
(
"Declared traits."
),
verbose_name
=
_
(
'traits'
))
tags
=
TaggableManager
(
blank
=
True
,
verbose_name
=
_
(
"tags"
))
class
Meta
:
...
...
@@ -350,7 +365,7 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
@classmethod
def
create_from_template
(
cls
,
template
,
owner
,
disks
=
None
,
networks
=
None
,
tags
=
None
,
**
kwargs
):
req_traits
=
None
,
tags
=
None
,
**
kwargs
):
"""Create a new instance based on an InstanceTemplate.
Can also specify parameters as keyword arguments which should override
...
...
@@ -361,6 +376,9 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
networks
=
(
template
.
interface_set
.
all
()
if
networks
is
None
else
networks
)
req_traits
=
(
template
.
req_traits
.
all
()
if
req_traits
is
None
else
req_traits
)
tags
=
template
.
tags
.
all
()
if
tags
is
None
else
tags
# prepare parameters
...
...
@@ -390,6 +408,7 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
# TODO fix this port fw
i
.
host
.
add_port
(
proto
,
private
=
port
)
inst
.
req_traits
.
add
(
*
req_traits
)
inst
.
tags
.
add
(
*
tags
)
return
inst
...
...
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