Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
0e2283c9
authored
Aug 21, 2013
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
circle2: make things compile and validate
parent
23646e98
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
18 deletions
+20
-18
cloud/settings/base.py
+1
-1
one/models.py
+0
-1
storage/models.py
+2
-3
vm/models.py
+17
-13
No files found.
cloud/settings/base.py
View file @
0e2283c9
...
...
@@ -152,7 +152,7 @@ INSTALLED_APPS = (
'django.contrib.staticfiles'
,
'django.contrib.admin'
,
'django.contrib.admindocs'
,
'one'
,
#
'one',
'school'
,
'cloud'
,
'store'
,
...
...
one/models.py
View file @
0e2283c9
...
...
@@ -17,7 +17,6 @@ from django.utils.translation import ugettext_lazy as _
from
firewall.models
import
Host
,
Vlan
from
store.api
import
StoreApi
from
vm.models
import
Template
from
.util
import
keygen
import
django.conf
...
...
storage/models.py
View file @
0e2283c9
...
...
@@ -28,19 +28,18 @@ class DataStore(models.Model):
return
u'
%
s (
%
s)'
%
(
self
.
name
,
self
.
path
)
class
Disk
(
models
.
Model
,
TimeStampedModel
):
class
Disk
(
TimeStampedModel
):
"""Virtual disks."""
FORMATS
=
[(
'qcow2'
,
'qcow2'
),
(
'raw'
,
'raw'
),
(
'iso'
,
'iso'
)]
TYPES
=
[(
'snapshot'
,
'snapshot'
),
(
'normal'
,
'normal'
)]
name
=
models
.
CharField
(
max_length
=
100
,
unique
=
True
,
verbose_name
=
_
(
'name'
))
datastore
=
models
.
ForeignKey
(
'DataStore'
)
format
=
models
.
CharField
(
max_length
=
10
,
choices
=
FORMAT
)
format
=
models
.
CharField
(
max_length
=
10
,
choices
=
FORMAT
S
)
size
=
models
.
IntegerField
()
type
=
models
.
CharField
(
max_length
=
10
,
choices
=
TYPES
)
base
=
models
.
ForeignKey
(
'Disk'
,
related_name
=
'snapshots'
,
null
=
True
,
blank
=
True
)
created
=
models
.
BooleanField
(
default
=
False
)
class
Meta
:
ordering
=
[
'name'
]
...
...
vm/models.py
View file @
0e2283c9
from
django.contrib.auth.models
import
User
from
django.db
import
models
from
django.db.models.signals
import
pre_delete
from
django.utils.translation
import
ugettext_lazy
as
_
from
model_utils.models
import
TimeStampedModel
from
firewall.models
import
Vlan
from
storage.models
import
Disk
,
Image
from
firewall.models
import
Vlan
,
Host
from
storage.models
import
Disk
class
BaseResourceConfigModel
():
class
BaseResourceConfigModel
(
models
.
Model
):
"""Abstract base class for models with base resource configuration
parameters.
"""
...
...
@@ -19,7 +24,7 @@ class BaseResourceConfigModel():
abstract
=
True
class
NamedBaseResourceConfig
(
models
.
Model
,
BaseResourceConfigModel
):
class
NamedBaseResourceConfig
(
BaseResourceConfigModel
):
"""Pre-created, named base resource configurations.
"""
name
=
models
.
CharField
(
max_length
=
50
,
unique
=
True
,
...
...
@@ -34,7 +39,7 @@ class Interface(models.Model):
"""
vlan
=
models
.
ForeignKey
(
Vlan
)
host
=
models
.
ForeignKey
(
Host
)
instance
=
models
.
ForeignKey
(
Instance
)
instance
=
models
.
ForeignKey
(
'Instance'
)
class
InterfaceTemplate
(
models
.
Model
):
...
...
@@ -42,7 +47,7 @@ class InterfaceTemplate(models.Model):
"""
vlan
=
models
.
ForeignKey
(
Vlan
)
managed
=
models
.
BooleanField
()
template
=
models
.
ForeignKey
(
Template
)
template
=
models
.
ForeignKey
(
'Template'
)
class
Node
(
models
.
Model
):
...
...
@@ -55,8 +60,7 @@ class Node(models.Model):
online
=
models
.
BooleanField
(
default
=
False
)
class
InstanceTemplate
(
models
.
Model
,
TimeStampedModel
,
BaseResourceConfigModel
):
class
InstanceTemplate
(
TimeStampedModel
,
BaseResourceConfigModel
):
"""Virtual machine template.
Every template has:
...
...
@@ -88,9 +92,9 @@ class InstanceTemplate(models.Model, TimeStampedModel,
'Ubuntu 12.04 LTS Desktop amd64'
))
access_method
=
models
.
CharField
(
max_length
=
10
,
choices
=
ACCESS_METHODS
,
verbose_name
=
_
(
'access method'
))
state
=
models
.
CharField
(
max_length
=
10
,
choices
=
TEMPLATE_
STATES
,
state
=
models
.
CharField
(
max_length
=
10
,
choices
=
STATES
,
default
=
'NEW'
)
images
=
models
.
ManyToManyField
(
Image
,
verbose_name
=
_
(
'image
s'
),
disks
=
models
.
ManyToManyField
(
Disk
,
verbose_name
=
_
(
'disk
s'
),
related_name
=
'template_set'
)
# TODO review
owner
=
models
.
ForeignKey
(
User
,
verbose_name
=
_
(
'owner'
),
...
...
@@ -119,7 +123,7 @@ class InstanceTemplate(models.Model, TimeStampedModel,
return
"linux"
class
Instance
(
models
.
Model
,
TimeStampedModel
,
BaseResourceConfigModel
):
class
Instance
(
TimeStampedModel
,
BaseResourceConfigModel
):
"""Virtual machine instance.
Every instance has:
...
...
@@ -147,7 +151,7 @@ class Instance(models.Model, TimeStampedModel, BaseResourceConfigModel):
blank
=
True
)
description
=
models
.
TextField
(
verbose_name
=
_
(
'description'
),
blank
=
True
)
template
=
models
.
ForeignKey
(
Template
,
verbose_name
=
_
(
'template'
),
template
=
models
.
ForeignKey
(
'Template'
,
verbose_name
=
_
(
'template'
),
related_name
=
'instance_set'
,
null
=
True
,
blank
=
True
)
pw
=
models
.
CharField
(
max_length
=
20
,
verbose_name
=
_
(
'password'
),
...
...
@@ -170,7 +174,7 @@ class Instance(models.Model, TimeStampedModel, BaseResourceConfigModel):
related_name
=
'instance_set'
)
state
=
models
.
CharField
(
max_length
=
20
,
choices
=
STATES
,
default
=
'NOSTATE'
)
operation
=
models
.
CharField
(
max_length
=
100
,
null
=
True
,
blank
=
True
operation
=
models
.
CharField
(
max_length
=
100
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'operation'
))
# TODO review fields below
owner
=
models
.
ForeignKey
(
User
,
verbose_name
=
_
(
'owner'
),
...
...
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