Sure, here it is:
from django.db import models
import datetime
SERVER_STATUS_CHOICES = (
('A', 'Active'),
('I', 'Inactive'),
)
COUNTRY_CHOICES = (
('UK', 'United Kingdom'),
('US', 'United States'),
)
class Country(models.Model):
country_name = models.CharField(maxlength=2)
def __repr__(self):
return self.country_name
class Admin:
pass
class Region(models.Model):
region_name = models.CharField(maxlength=200)
def __repr__(self):
return self.region_name
class Admin:
pass
class Datacenter(models.Model):
datacenter_name = models.CharField(maxlength=200)
location = models.CharField(maxlength=200)
country = models.CharField(maxlength=200, choices=COUNTRY_CHOICES)
def __repr__(self):
return self.datacenter_name
class Admin:
pass
class TowerUsage(models.Model):
usage = models.CharField(maxlength=200)
comment = models.TextField(blank=True, null=True)
def __repr__(self):
return self.usage
class Admin:
pass
class Tower(models.Model):
tower_name = models.CharField(maxlength=200)
country = models.ForeignKey(Country)
region = models.ForeignKey(Region, blank=True, null=True)
datacenter = models.ForeignKey(Datacenter)
usage = models.ForeignKey(TowerUsage, blank=True, null=True)
def __repr__(self):
return self.tower_name
class Admin:
pass
class TowerAlias(models.Model):
tower = models.ForeignKey(Tower)
tower_alias = models.CharField(maxlength=200)
def __repr__(self):
return self.tower_alias
class Admin:
list_display = ('tower', 'tower_alias'),
list_filter = ['tower'],
class Server(models.Model):
tower = models.ForeignKey(Tower)
server_name = models.CharField(maxlength=200)
internal_ip = models.IPAddressField()
external_ip = models.IPAddressField(blank=True, null=True)
status = models.CharField(maxlength=1,
choices=SERVER_STATUS_CHOICES, default='A')
def __repr__(self):
return self.server_name
class Admin:
list_display = ('tower', 'server_name'),
list_filter = ['tower'],
class CommandType(models.Model):
command_type = models.CharField(maxlength=200)
def __repr__(self):
return self.command_type
class Admin:
pass
class Command(models.Model):
command_type = models.ForeignKey(CommandType)
name = models.CharField(maxlength=200)
command = models.TextField()
description = models.TextField(blank=True, null=True)
def __repr__(self):
return self.command
class Admin:
ordering = ['name']
list_display = ('name', 'command', 'command_type'),
list_filter = ['command_type'],
class CommandOptions(models.Model):
command = models.ForeignKey(Command)
option_order = models.IntegerField()
description = models.CharField(maxlength=200)
def __repr__(self):
return self.description
class Admin:
ordering = ['option_order']
list_display = ('command', 'option_order', 'description'),
list_filter = ['command'],
class CommandLog(models.Model):
fullcommand = models.TextField()
command_type = models.ForeignKey(CommandType)
host = models.IPAddressField()
command_time = models.DateTimeField(blank=True, null=True)
command_output = models.TextField(blank=True, null=True)
date_to_run = models.DateTimeField(default=datetime.datetime.now())
priority = models.IntegerField(default=10)
completed = models.BooleanField(default=False)
def __repr__(self):
return self.fullcommand
def show_future(self):
future = objects.filter(completed=False,
date_to_run__gt=datetime.datetime.now())
return future
def show_outstanding(self):
outstanding = objects.filter(completed=False,
date_to_run__lt=datetime.datetime.now())
return outstanding
class Admin:
ordering = ['-command_time']
list_display = ('fullcommand', 'host', 'command_time',
'completed'),
list_filter = ['completed'],
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---