2014-11-18 13:59:21 +00:00
# -*- coding: utf-8 -*-
2015-04-08 14:41:09 +00:00
from __future__ import unicode_literals
2014-11-18 13:59:21 +00:00
from django . db import models , migrations
2021-04-22 12:18:01 +00:00
import django . db . models . deletion
2015-04-05 10:46:24 +00:00
import orchestra . contrib . resources . validators
2014-11-18 13:59:21 +00:00
import orchestra . models . fields
2015-04-29 14:32:38 +00:00
import django . utils . timezone
2015-04-29 13:55:22 +00:00
import orchestra . core . validators
2014-11-18 13:59:21 +00:00
class Migration ( migrations . Migration ) :
dependencies = [
( ' djcelery ' , ' __first__ ' ) ,
2015-04-29 14:32:38 +00:00
( ' contenttypes ' , ' 0002_remove_content_type_name ' ) ,
2014-11-18 13:59:21 +00:00
]
operations = [
migrations . CreateModel (
name = ' MonitorData ' ,
fields = [
2015-04-29 14:32:38 +00:00
( ' id ' , models . AutoField ( primary_key = True , auto_created = True , serialize = False , verbose_name = ' ID ' ) ) ,
( ' monitor ' , models . CharField ( choices = [ ( ' Apache2Traffic ' , ' [M] Apache 2 Traffic ' ) , ( ' DovecotMaildirDisk ' , ' [M] Dovecot Maildir size ' ) , ( ' Exim4Traffic ' , ' [M] Exim4 traffic ' ) , ( ' MailmanSubscribers ' , ' [M] Mailman subscribers ' ) , ( ' MailmanTraffic ' , ' [M] Mailman traffic ' ) , ( ' MysqlDisk ' , ' [M] MySQL disk ' ) , ( ' OpenVZTraffic ' , ' [M] OpenVZTraffic ' ) , ( ' PostfixMailscannerTraffic ' , ' [M] Postfix-Mailscanner traffic ' ) , ( ' UNIXUserDisk ' , ' [M] UNIX user disk ' ) , ( ' VsFTPdTraffic ' , ' [M] VsFTPd traffic ' ) ] , max_length = 256 , verbose_name = ' monitor ' ) ) ,
2014-11-18 13:59:21 +00:00
( ' object_id ' , models . PositiveIntegerField ( verbose_name = ' object id ' ) ) ,
2015-04-29 13:55:22 +00:00
( ' created_at ' , models . DateTimeField ( default = django . utils . timezone . now , verbose_name = ' created ' ) ) ,
2015-04-29 14:32:38 +00:00
( ' value ' , models . DecimalField ( decimal_places = 2 , max_digits = 16 , verbose_name = ' value ' ) ) ,
2021-04-22 12:18:01 +00:00
( ' content_type ' , models . ForeignKey ( on_delete = django . db . models . deletion . CASCADE , verbose_name = ' content type ' , to = ' contenttypes.ContentType ' ) ) ,
2014-11-18 13:59:21 +00:00
] ,
options = {
2015-04-29 13:55:22 +00:00
' get_latest_by ' : ' id ' ,
2015-04-29 14:32:38 +00:00
' verbose_name_plural ' : ' monitor data ' ,
2014-11-18 13:59:21 +00:00
} ,
) ,
migrations . CreateModel (
name = ' Resource ' ,
fields = [
2015-04-29 14:32:38 +00:00
( ' id ' , models . AutoField ( primary_key = True , auto_created = True , serialize = False , verbose_name = ' ID ' ) ) ,
( ' name ' , models . CharField ( validators = [ orchestra . core . validators . validate_name ] , help_text = ' Required. 32 characters or fewer. Lowercase letters, digits and hyphen only. ' , max_length = 32 , verbose_name = ' name ' ) ) ,
2015-04-29 13:55:22 +00:00
( ' verbose_name ' , models . CharField ( max_length = 256 , verbose_name = ' verbose name ' ) ) ,
2015-04-29 14:32:38 +00:00
( ' aggregation ' , models . CharField ( choices = [ ( ' last-10-days-avg ' , ' Last 10 days AVG ' ) , ( ' last ' , ' Last value ' ) , ( ' monthly-avg ' , ' Monthly AVG ' ) , ( ' monthly-sum ' , ' Monthly Sum ' ) ] , help_text = ' Method used for aggregating this resource monitored data. ' , max_length = 16 , default = ' last-10-days-avg ' , verbose_name = ' aggregation ' ) ) ,
2015-04-29 13:55:22 +00:00
( ' on_demand ' , models . BooleanField ( help_text = ' If enabled the resource will not be pre-allocated, but allocated under the application demand ' , default = False , verbose_name = ' on demand ' ) ) ,
( ' default_allocation ' , models . PositiveIntegerField ( help_text = ' Default allocation value used when this is not an on demand resource ' , blank = True , null = True , verbose_name = ' default allocation ' ) ) ,
2015-04-29 14:32:38 +00:00
( ' unit ' , models . CharField ( help_text = ' The unit in which this resource is represented. For example GB, KB or subscribers ' , max_length = 16 , verbose_name = ' unit ' ) ) ,
( ' scale ' , models . CharField ( validators = [ orchestra . contrib . resources . validators . validate_scale ] , help_text = ' Scale in which this resource monitoring resoults should be prorcessed to match with unit. e.g. <tt>10**9</tt> ' , max_length = 32 , verbose_name = ' scale ' ) ) ,
2015-04-29 13:55:22 +00:00
( ' disable_trigger ' , models . BooleanField ( help_text = ' Disables monitors exeeded and recovery triggers ' , default = False , verbose_name = ' disable trigger ' ) ) ,
2015-04-29 14:32:38 +00:00
( ' monitors ' , orchestra . models . fields . MultiSelectField ( choices = [ ( ' Apache2Traffic ' , ' [M] Apache 2 Traffic ' ) , ( ' DovecotMaildirDisk ' , ' [M] Dovecot Maildir size ' ) , ( ' Exim4Traffic ' , ' [M] Exim4 traffic ' ) , ( ' MailmanSubscribers ' , ' [M] Mailman subscribers ' ) , ( ' MailmanTraffic ' , ' [M] Mailman traffic ' ) , ( ' MysqlDisk ' , ' [M] MySQL disk ' ) , ( ' OpenVZTraffic ' , ' [M] OpenVZTraffic ' ) , ( ' P ostfixMailscannerTraffic ' , ' [M] Postfix-Mailscanner traffic ' ) , ( ' UNIXUserDisk ' , ' [M] UNIX user disk ' ) , ( ' VsFTPdTraffic ' , ' [M] VsFTPd traffic ' ) ] , blank = True , help_text = ' Monitor backends used for monitoring this resource. ' , max_length = 256 , verbose_name = ' monitors ' ) ) ,
2015-04-29 13:55:22 +00:00
( ' is_active ' , models . BooleanField ( default = True , verbose_name = ' active ' ) ) ,
2021-04-22 12:18:01 +00:00
( ' content_type ' , models . ForeignKey ( on_delete = django . db . models . deletion . CASCADE , help_text = ' Model where this resource will be hooked. ' , to = ' contenttypes.ContentType ' ) ) ,
( ' crontab ' , models . ForeignKey ( on_delete = django . db . models . deletion . CASCADE , help_text = ' Crontab for periodic execution. Leave it empty to disable periodic monitoring ' , to = ' djcelery.CrontabSchedule ' , verbose_name = ' crontab ' , blank = True , null = True ) ) ,
2014-11-18 13:59:21 +00:00
] ,
) ,
migrations . CreateModel (
name = ' ResourceData ' ,
fields = [
2015-04-29 14:32:38 +00:00
( ' id ' , models . AutoField ( primary_key = True , auto_created = True , serialize = False , verbose_name = ' ID ' ) ) ,
2014-11-18 13:59:21 +00:00
( ' object_id ' , models . PositiveIntegerField ( verbose_name = ' object id ' ) ) ,
2015-04-29 14:32:38 +00:00
( ' used ' , models . DecimalField ( decimal_places = 3 , editable = False , max_digits = 16 , null = True , verbose_name = ' used ' ) ) ,
2015-04-29 13:55:22 +00:00
( ' updated_at ' , models . DateTimeField ( editable = False , null = True , verbose_name = ' updated ' ) ) ,
2015-04-29 14:32:38 +00:00
( ' allocated ' , models . DecimalField ( decimal_places = 2 , max_digits = 8 , blank = True , null = True , verbose_name = ' allocated ' ) ) ,
2021-04-22 12:18:01 +00:00
( ' content_type ' , models . ForeignKey ( on_delete = django . db . models . deletion . CASCADE , verbose_name = ' content type ' , to = ' contenttypes.ContentType ' ) ) ,
( ' resource ' , models . ForeignKey ( on_delete = django . db . models . deletion . CASCADE , related_name = ' dataset ' , to = ' resources.Resource ' , verbose_name = ' resource ' ) ) ,
2014-11-18 13:59:21 +00:00
] ,
options = {
' verbose_name_plural ' : ' resource data ' ,
} ,
) ,
migrations . AlterUniqueTogether (
name = ' resourcedata ' ,
unique_together = set ( [ ( ' resource ' , ' content_type ' , ' object_id ' ) ] ) ,
) ,
migrations . AlterUniqueTogether (
name = ' resource ' ,
2015-04-29 13:55:22 +00:00
unique_together = set ( [ ( ' name ' , ' content_type ' ) , ( ' verbose_name ' , ' content_type ' ) ] ) ,
2014-11-18 13:59:21 +00:00
) ,
]