Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
62ad3366
authored
Oct 28, 2013
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: extract common base model for instances and templates
parent
02755b55
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
15 deletions
+19
-15
circle/vm/migrations/0008_auto__del_field_namedbaseresourceconfig_boot_menu__del_field_namedbase.py
+0
-0
circle/vm/models.py
+19
-15
No files found.
circle/vm/migrations/0008_auto__del_field_namedbaseresourceconfig_boot_menu__del_field_namedbase.py
0 → 100644
View file @
62ad3366
This diff is collapsed.
Click to expand it.
circle/vm/models.py
View file @
62ad3366
...
@@ -32,8 +32,7 @@ VNC_PORT_RANGE = (2000, 65536) # inclusive start, exclusive end
...
@@ -32,8 +32,7 @@ VNC_PORT_RANGE = (2000, 65536) # inclusive start, exclusive end
class
BaseResourceConfigModel
(
Model
):
class
BaseResourceConfigModel
(
Model
):
"""Abstract base class for models with base resource configuration
"""Abstract base for models with base resource configuration parameters.
parameters.
"""
"""
num_cores
=
IntegerField
(
verbose_name
=
_
(
'number of cores'
),
num_cores
=
IntegerField
(
verbose_name
=
_
(
'number of cores'
),
help_text
=
_
(
'Number of virtual CPU cores '
help_text
=
_
(
'Number of virtual CPU cores '
...
@@ -47,11 +46,6 @@ class BaseResourceConfigModel(Model):
...
@@ -47,11 +46,6 @@ class BaseResourceConfigModel(Model):
choices
=
ARCHITECTURES
)
choices
=
ARCHITECTURES
)
priority
=
IntegerField
(
verbose_name
=
_
(
'priority'
),
priority
=
IntegerField
(
verbose_name
=
_
(
'priority'
),
help_text
=
_
(
'CPU priority.'
))
help_text
=
_
(
'CPU priority.'
))
boot_menu
=
BooleanField
(
verbose_name
=
_
(
'boot menu'
),
default
=
False
,
help_text
=
_
(
'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.'
))
class
Meta
:
class
Meta
:
abstract
=
True
abstract
=
True
...
@@ -69,6 +63,22 @@ class NamedBaseResourceConfig(BaseResourceConfigModel, TimeStampedModel):
...
@@ -69,6 +63,22 @@ class NamedBaseResourceConfig(BaseResourceConfigModel, TimeStampedModel):
return
self
.
name
return
self
.
name
class
VirtualMachineDescModel
(
BaseResourceConfigModel
):
"""Abstract base for virtual machine describing models.
"""
access_method
=
CharField
(
max_length
=
10
,
choices
=
ACCESS_METHODS
,
verbose_name
=
_
(
'access method'
),
help_text
=
_
(
'Primary remote access method.'
))
boot_menu
=
BooleanField
(
verbose_name
=
_
(
'boot menu'
),
default
=
False
,
help_text
=
_
(
'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.'
))
class
Meta
:
abstract
=
True
class
Node
(
TimeStampedModel
):
class
Node
(
TimeStampedModel
):
"""A VM host machine, a hypervisor.
"""A VM host machine, a hypervisor.
...
@@ -170,7 +180,7 @@ class Lease(Model):
...
@@ -170,7 +180,7 @@ class Lease(Model):
return
self
.
name
return
self
.
name
class
InstanceTemplate
(
BaseResourceConfig
Model
,
TimeStampedModel
):
class
InstanceTemplate
(
VirtualMachineDesc
Model
,
TimeStampedModel
):
"""Virtual machine template.
"""Virtual machine template.
...
@@ -201,9 +211,6 @@ class InstanceTemplate(BaseResourceConfigModel, TimeStampedModel):
...
@@ -201,9 +211,6 @@ class InstanceTemplate(BaseResourceConfigModel, TimeStampedModel):
help_text
=
(
_
(
'Name of operating system in '
help_text
=
(
_
(
'Name of operating system in '
'format like "
%
s".'
)
%
'format like "
%
s".'
)
%
'Ubuntu 12.04 LTS Desktop amd64'
))
'Ubuntu 12.04 LTS Desktop amd64'
))
access_method
=
CharField
(
max_length
=
10
,
choices
=
ACCESS_METHODS
,
verbose_name
=
_
(
'access method'
),
help_text
=
_
(
'Primary remote access method.'
))
state
=
CharField
(
max_length
=
10
,
choices
=
STATES
,
default
=
'NEW'
)
state
=
CharField
(
max_length
=
10
,
choices
=
STATES
,
default
=
'NEW'
)
disks
=
ManyToManyField
(
Disk
,
verbose_name
=
_
(
'disks'
),
disks
=
ManyToManyField
(
Disk
,
verbose_name
=
_
(
'disks'
),
related_name
=
'template_set'
,
related_name
=
'template_set'
,
...
@@ -258,7 +265,7 @@ class InterfaceTemplate(Model):
...
@@ -258,7 +265,7 @@ class InterfaceTemplate(Model):
verbose_name_plural
=
_
(
'interface templates'
)
verbose_name_plural
=
_
(
'interface templates'
)
class
Instance
(
BaseResourceConfig
Model
,
TimeStampedModel
):
class
Instance
(
VirtualMachineDesc
Model
,
TimeStampedModel
):
"""Virtual machine instance.
"""Virtual machine instance.
...
@@ -314,9 +321,6 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
...
@@ -314,9 +321,6 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
help_text
=
_
(
"Set of mounted disks."
),
help_text
=
_
(
"Set of mounted disks."
),
verbose_name
=
_
(
'disks'
))
verbose_name
=
_
(
'disks'
))
lease
=
ForeignKey
(
Lease
,
help_text
=
_
(
"Preferred expiration periods."
))
lease
=
ForeignKey
(
Lease
,
help_text
=
_
(
"Preferred expiration periods."
))
access_method
=
CharField
(
max_length
=
10
,
choices
=
ACCESS_METHODS
,
help_text
=
_
(
"Primary remote access method."
),
verbose_name
=
_
(
'access method'
))
vnc_port
=
IntegerField
(
blank
=
True
,
default
=
None
,
null
=
True
,
vnc_port
=
IntegerField
(
blank
=
True
,
default
=
None
,
null
=
True
,
help_text
=
_
(
"TCP port where VNC console listens."
),
help_text
=
_
(
"TCP port where VNC console listens."
),
unique
=
True
,
verbose_name
=
_
(
'vnc_port'
))
unique
=
True
,
verbose_name
=
_
(
'vnc_port'
))
...
...
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