Rizwan Haider | 51fdb3f | 2016-11-09 18:29:32 -0500 | [diff] [blame] | 1 | # models.py - VNOD Local Service |
| 2 | |
| 3 | from django.db import models |
| 4 | from core.models import Service |
| 5 | from core.models import PlCoreBase |
| 6 | |
| 7 | VNODLOCAL_KIND = "vnodlocal" |
| 8 | SERVICE_NAME = 'vnodlocal' |
| 9 | |
| 10 | class VnodLocalSystem(PlCoreBase): |
| 11 | class Meta: |
| 12 | app_label = VNODLOCAL_KIND |
| 13 | verbose_name = "VNOD Local System" |
| 14 | |
| 15 | ADMINISTRATIVE_STATE = ( |
| 16 | ('enabled', 'Enabled'), |
| 17 | ('disabled', 'Disabled') |
| 18 | ) |
| 19 | |
| 20 | name = models.CharField(unique=True, |
| 21 | verbose_name="Name", |
| 22 | max_length=256, |
| 23 | editable=True) |
| 24 | |
| 25 | description = models.CharField(verbose_name="Description", |
| 26 | max_length=1024, |
| 27 | editable=True) |
| 28 | |
| 29 | restUrl = models.CharField(verbose_name="MetroNetwork Rest URL", |
| 30 | max_length=256, |
| 31 | editable=True) |
| 32 | |
| 33 | username = models.CharField(verbose_name='Username', |
| 34 | max_length=32, |
| 35 | editable=True, |
| 36 | blank=True) |
| 37 | |
| 38 | password = models.CharField(max_length=32, |
| 39 | verbose_name='Password', |
| 40 | editable=True, |
| 41 | blank=True) |
| 42 | |
| 43 | administrativeState = models.CharField(choices=ADMINISTRATIVE_STATE, |
| 44 | default='enabled', |
| 45 | verbose_name="AdministrativeState", |
| 46 | max_length=16, |
| 47 | editable=True) |
| 48 | |
| 49 | pseudowireprovider = models.CharField(unique=False, |
| 50 | verbose_name="Pseudowire Provider", |
| 51 | default='none', |
| 52 | max_length=256, |
| 53 | editable=True) |
| 54 | |
| 55 | networkControllerUrl = models.CharField(verbose_name="Network Controller URL", |
| 56 | blank=True, |
| 57 | max_length=256, |
| 58 | editable=True) |
| 59 | |
| 60 | def __init__(self, *args, **kwargs): |
| 61 | super(VnodLocalSystem, self).__init__(*args, **kwargs) |
| 62 | |
| 63 | |
| 64 | def getAdminstrativeState(self): |
| 65 | return self.administrativeState |
| 66 | |
| 67 | |
| 68 | def setAdminstrativeState(self, value): |
| 69 | self.administrativeState = value |
| 70 | |
| 71 | |
| 72 | def getRestUrl(self): |
| 73 | return self.restUrl |
| 74 | |
| 75 | |
| 76 | class VnodLocalService(Service): |
| 77 | |
| 78 | class Meta: |
| 79 | app_label = VNODLOCAL_KIND |
| 80 | verbose_name = "Virtual Network On Demand Local Service" |
| 81 | |
| 82 | ADMINISTRATIVE_STATE = ( |
| 83 | ('disabled', 'Disabled'), |
| 84 | ('configurationrequested', 'ConfigurationRequested'), |
| 85 | ('configurationfailed', 'ConfigurationFailed'), |
| 86 | ('configured', 'Configured'), |
| 87 | ('activationrequested', 'ActivationRequested'), |
| 88 | ('activationfailed', 'ActivationFailed'), |
| 89 | ('enabled', 'Enabled'), |
| 90 | ('deactivationrequested', 'DeactivationRequested') |
| 91 | ) |
| 92 | |
| 93 | OPERATIONALSTATE = ( |
| 94 | ('active', 'Active'), |
| 95 | ('inactivereported', 'InactiveReported'), |
| 96 | ('inactive', 'Inactive'), |
| 97 | ('activereported', 'ActiveReported') |
| 98 | ) |
| 99 | |
| 100 | portid = models.CharField(verbose_name="PortId", blank=True, max_length=256, editable=True) |
| 101 | vlanid = models.CharField(verbose_name="VlanId", blank=True, max_length=256, editable=True) |
| 102 | servicehandle = models.CharField(verbose_name="Service Handle", max_length=256, editable=True) |
| 103 | autoattached = models.BooleanField(verbose_name="Auto-Attached", default=False, editable=True) |
| 104 | |
| 105 | administrativeState = models.CharField(choices=ADMINISTRATIVE_STATE, |
| 106 | default='disabled', |
| 107 | verbose_name="AdministrativeState", |
| 108 | max_length=64, |
| 109 | editable=True) |
| 110 | |
| 111 | operstate = models.CharField(choices=OPERATIONALSTATE, |
| 112 | default='inactive', |
| 113 | verbose_name="OperationalState", |
| 114 | max_length=64, |
| 115 | editable=True) |
| 116 | |
| 117 | |
| 118 | def __init__(self, *args, **kwargs): |
| 119 | super(VnodLocalService, self).__init__(*args, **kwargs) |
| 120 | |
| 121 | def __unicode__(self): return u'%s:%s' % (self.servicehandle, self.portid) |
| 122 | |
| 123 | |
| 124 | class VnodLocalPseudowireConnectorService(Service): |
| 125 | |
| 126 | class Meta: |
| 127 | app_label = VNODLOCAL_KIND |
| 128 | verbose_name = "Virtual Network On Demand Local Pseudo-wire Connector Service" |
| 129 | |
| 130 | ADMINISTRATIVE_STATE = ( |
| 131 | ('disabled', 'Disabled'), |
| 132 | ('activationrequested', 'ActivationRequested'), |
| 133 | ('enabled', 'Enabled'), |
| 134 | ('deactivationrequested', 'DeactivationRequested') |
| 135 | ) |
| 136 | |
| 137 | OPERATIONALSTATE = ( |
| 138 | ('active', 'Active'), |
| 139 | ('inactive', 'Inactive') |
| 140 | ) |
| 141 | |
| 142 | servicehandle = models.CharField(verbose_name="Service Handle", max_length=256, editable=True) |
| 143 | pseudowirehandle = models.CharField(verbose_name="Pseudowirehandle", blank=True, max_length=256, editable=True) |
| 144 | internalport = models.CharField(verbose_name="Internal Port", max_length=256, editable=True) |
| 145 | |
| 146 | vnodlocal = models.ForeignKey(VnodLocalService, |
| 147 | related_name='VnodLocalService', |
| 148 | verbose_name="VnodLocalService", |
| 149 | null=True, |
| 150 | editable=True, |
| 151 | on_delete=models.CASCADE) |
| 152 | |
| 153 | administrativeState = models.CharField(choices=ADMINISTRATIVE_STATE, |
| 154 | default='disabled', |
| 155 | verbose_name="AdministrativeState", |
| 156 | max_length=64, |
| 157 | editable=True) |
| 158 | |
| 159 | operstate = models.CharField(choices=OPERATIONALSTATE, |
| 160 | default='inactive', |
| 161 | verbose_name="OperationalState", |
| 162 | max_length=64, |
| 163 | editable=True) |
| 164 | |
| 165 | |
| 166 | def __init__(self, *args, **kwargs): |
| 167 | super(VnodLocalPseudowireConnectorService, self).__init__(*args, **kwargs) |