~mhall119/awstrial/per-campaign-settings

« back to all changes in this revision

Viewing changes to awstrial/trial/models.py

  • Committer: Michael Hall
  • Date: 2011-09-26 14:02:30 UTC
  • Revision ID: mhall119@ubuntu.com-20110926140230-0v62rfd81i19q2m9
Update trial models to use new django_ec2 app

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
from trial import util
26
26
import yaml
27
27
 
 
28
from django_ec2.models import *
28
29
 
29
30
INSTANCE_STATUS = (
30
31
    ('reserved', _('reserved')),
57
58
      return self.domain
58
59
 
59
60
class Campaign(models.Model):
60
 
    verbose_name = models.CharField(max_length=150, verbose_name=_('Name of the Campaign'))
61
61
    name = models.CharField(max_length=150, verbose_name=_('The slug, to use in the URL'))
62
62
    verbose_name = models.CharField(max_length=150, verbose_name=_('Name of the Campaign'))
63
63
    max_instances = models.IntegerField(verbose_name=_('Number of instances authorised'))
 
64
 
 
65
    cloud = models.ForeignKey(Cloud, verbose_name=_('Target Cloud'))
 
66
    images = models.ManyToManyField(Image, verbose_name=_('Available Images'))
 
67
    groups = models.ManyToManyField(SecurityGroup, verbose_name=_('Security Groups'))
 
68
 
 
69
    life_span = models.IntegerField(verbose_name=_('Time (in seconds) to live'), default=60 * 55)
 
70
    instance_key_name = models.CharField(max_length=150, verbose_name=_('Instance Key Name'), blank=True, null=True)
 
71
    instance_type = models.CharField(max_length=150, verbose_name=_('Instance Type'), default='m1.small')
 
72
 
64
73
    active = models.BooleanField(verbose_name=_('Is this Campaign active?'))
 
74
 
65
75
    def __unicode__(self):
66
76
        return self.verbose_name
 
77
 
67
78
    def remaining(self):
68
79
        instance_count = Instances.objects.filter(campaign__verbose_name=self.verbose_name).count()
69
80
        remaining = self.max_instances-instance_count
85
96
    shutdown_time = models.DateTimeField(help_text=_('First time the instance was found shutting-down or terminated'), verbose_name=_('Shutting-down time'), blank=True, null=True)
86
97
    terminated_time = models.DateTimeField(help_text=_('Time the instance was found terminated'), verbose_name=_('Terminated time'), blank=True, null=True)
87
98
    ph_time = models.DateTimeField(verbose_name=_('Info Callback Time'), help_text=_('Time when instance called back with info (ie "Phoned Home")'), blank=True, null=True)
88
 
    region = models.CharField(verbose_name=_('EC2 Region'), max_length=16, choices=EC2_REGIONS)
89
 
    ami_id = models.SlugField(_("AMI Identifier"), max_length=12, null=False, db_index=False)
 
99
    region = models.ForeignKey(Region)
 
100
    image = models.ForeignKey(Image)
90
101
    console_start = models.TextField(verbose_name=_('Console Output at start'), blank=True, null=True)
91
102
    console_end = models.TextField(verbose_name=_('Console Output after terminated'), blank=True, null=True)
92
103
    hostname = models.CharField(verbose_name=_('EC2 Hostname'), max_length=128, blank=True)