Commit 0e2283c9 by Őry Máté

circle2: make things compile and validate

parent 23646e98
...@@ -152,7 +152,7 @@ INSTALLED_APPS = ( ...@@ -152,7 +152,7 @@ INSTALLED_APPS = (
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'django.contrib.admin', 'django.contrib.admin',
'django.contrib.admindocs', 'django.contrib.admindocs',
'one', # 'one',
'school', 'school',
'cloud', 'cloud',
'store', 'store',
......
...@@ -17,7 +17,6 @@ from django.utils.translation import ugettext_lazy as _ ...@@ -17,7 +17,6 @@ from django.utils.translation import ugettext_lazy as _
from firewall.models import Host, Vlan from firewall.models import Host, Vlan
from store.api import StoreApi from store.api import StoreApi
from vm.models import Template
from .util import keygen from .util import keygen
import django.conf import django.conf
......
...@@ -28,19 +28,18 @@ class DataStore(models.Model): ...@@ -28,19 +28,18 @@ class DataStore(models.Model):
return u'%s (%s)' % (self.name, self.path) return u'%s (%s)' % (self.name, self.path)
class Disk(models.Model, TimeStampedModel): class Disk(TimeStampedModel):
"""Virtual disks.""" """Virtual disks."""
FORMATS = [('qcow2', 'qcow2'), ('raw', 'raw'), ('iso', 'iso')] FORMATS = [('qcow2', 'qcow2'), ('raw', 'raw'), ('iso', 'iso')]
TYPES = [('snapshot', 'snapshot'), ('normal', 'normal')] TYPES = [('snapshot', 'snapshot'), ('normal', 'normal')]
name = models.CharField(max_length=100, unique=True, name = models.CharField(max_length=100, unique=True,
verbose_name=_('name')) verbose_name=_('name'))
datastore = models.ForeignKey('DataStore') datastore = models.ForeignKey('DataStore')
format = models.CharField(max_length=10, choices=FORMAT) format = models.CharField(max_length=10, choices=FORMATS)
size = models.IntegerField() size = models.IntegerField()
type = models.CharField(max_length=10, choices=TYPES) type = models.CharField(max_length=10, choices=TYPES)
base = models.ForeignKey('Disk', related_name='snapshots', base = models.ForeignKey('Disk', related_name='snapshots',
null=True, blank=True) null=True, blank=True)
created = models.BooleanField(default=False)
class Meta: class Meta:
ordering = ['name'] ordering = ['name']
......
from django.contrib.auth.models import User
from django.db import models 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 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 """Abstract base class for models with base resource configuration
parameters. parameters.
""" """
...@@ -19,7 +24,7 @@ class BaseResourceConfigModel(): ...@@ -19,7 +24,7 @@ class BaseResourceConfigModel():
abstract = True abstract = True
class NamedBaseResourceConfig(models.Model, BaseResourceConfigModel): class NamedBaseResourceConfig(BaseResourceConfigModel):
"""Pre-created, named base resource configurations. """Pre-created, named base resource configurations.
""" """
name = models.CharField(max_length=50, unique=True, name = models.CharField(max_length=50, unique=True,
...@@ -34,7 +39,7 @@ class Interface(models.Model): ...@@ -34,7 +39,7 @@ class Interface(models.Model):
""" """
vlan = models.ForeignKey(Vlan) vlan = models.ForeignKey(Vlan)
host = models.ForeignKey(Host) host = models.ForeignKey(Host)
instance = models.ForeignKey(Instance) instance = models.ForeignKey('Instance')
class InterfaceTemplate(models.Model): class InterfaceTemplate(models.Model):
...@@ -42,7 +47,7 @@ class InterfaceTemplate(models.Model): ...@@ -42,7 +47,7 @@ class InterfaceTemplate(models.Model):
""" """
vlan = models.ForeignKey(Vlan) vlan = models.ForeignKey(Vlan)
managed = models.BooleanField() managed = models.BooleanField()
template = models.ForeignKey(Template) template = models.ForeignKey('Template')
class Node(models.Model): class Node(models.Model):
...@@ -55,8 +60,7 @@ class Node(models.Model): ...@@ -55,8 +60,7 @@ class Node(models.Model):
online = models.BooleanField(default=False) online = models.BooleanField(default=False)
class InstanceTemplate(models.Model, TimeStampedModel, class InstanceTemplate(TimeStampedModel, BaseResourceConfigModel):
BaseResourceConfigModel):
"""Virtual machine template. """Virtual machine template.
Every template has: Every template has:
...@@ -88,9 +92,9 @@ class InstanceTemplate(models.Model, TimeStampedModel, ...@@ -88,9 +92,9 @@ class InstanceTemplate(models.Model, TimeStampedModel,
'Ubuntu 12.04 LTS Desktop amd64')) 'Ubuntu 12.04 LTS Desktop amd64'))
access_method = models.CharField(max_length=10, choices=ACCESS_METHODS, access_method = models.CharField(max_length=10, choices=ACCESS_METHODS,
verbose_name=_('access method')) verbose_name=_('access method'))
state = models.CharField(max_length=10, choices=TEMPLATE_STATES, state = models.CharField(max_length=10, choices=STATES,
default='NEW') default='NEW')
images = models.ManyToManyField(Image, verbose_name=_('images'), disks = models.ManyToManyField(Disk, verbose_name=_('disks'),
related_name='template_set') related_name='template_set')
# TODO review # TODO review
owner = models.ForeignKey(User, verbose_name=_('owner'), owner = models.ForeignKey(User, verbose_name=_('owner'),
...@@ -119,7 +123,7 @@ class InstanceTemplate(models.Model, TimeStampedModel, ...@@ -119,7 +123,7 @@ class InstanceTemplate(models.Model, TimeStampedModel,
return "linux" return "linux"
class Instance(models.Model, TimeStampedModel, BaseResourceConfigModel): class Instance(TimeStampedModel, BaseResourceConfigModel):
"""Virtual machine instance. """Virtual machine instance.
Every instance has: Every instance has:
...@@ -147,7 +151,7 @@ class Instance(models.Model, TimeStampedModel, BaseResourceConfigModel): ...@@ -147,7 +151,7 @@ class Instance(models.Model, TimeStampedModel, BaseResourceConfigModel):
blank=True) blank=True)
description = models.TextField(verbose_name=_('description'), description = models.TextField(verbose_name=_('description'),
blank=True) blank=True)
template = models.ForeignKey(Template, verbose_name=_('template'), template = models.ForeignKey('Template', verbose_name=_('template'),
related_name='instance_set', related_name='instance_set',
null=True, blank=True) null=True, blank=True)
pw = models.CharField(max_length=20, verbose_name=_('password'), pw = models.CharField(max_length=20, verbose_name=_('password'),
...@@ -170,7 +174,7 @@ class Instance(models.Model, TimeStampedModel, BaseResourceConfigModel): ...@@ -170,7 +174,7 @@ class Instance(models.Model, TimeStampedModel, BaseResourceConfigModel):
related_name='instance_set') related_name='instance_set')
state = models.CharField(max_length=20, choices=STATES, state = models.CharField(max_length=20, choices=STATES,
default='NOSTATE') 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')) verbose_name=_('operation'))
# TODO review fields below # TODO review fields below
owner = models.ForeignKey(User, verbose_name=_('owner'), owner = models.ForeignKey(User, verbose_name=_('owner'),
...@@ -187,7 +191,7 @@ class Instance(models.Model, TimeStampedModel, BaseResourceConfigModel): ...@@ -187,7 +191,7 @@ class Instance(models.Model, TimeStampedModel, BaseResourceConfigModel):
@models.permalink @models.permalink
def get_absolute_url(self): def get_absolute_url(self):
return ('one.views.vm_show', None, {'iid': self.id}) return ('one.views.vm_show', None, {'iid': self.id})
@property @property
def primary_host(self): def primary_host(self):
if not hosts.exists(): if not hosts.exists():
...@@ -227,7 +231,7 @@ class Instance(models.Model, TimeStampedModel, BaseResourceConfigModel): ...@@ -227,7 +231,7 @@ class Instance(models.Model, TimeStampedModel, BaseResourceConfigModel):
def get_age(self): def get_age(self):
"""Deprecated. Use uptime instead. """Deprecated. Use uptime instead.
Get age of VM in seconds. Get age of VM in seconds.
""" """
return self.uptime.seconds return self.uptime.seconds
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment