CORD-876 eliminate proxy models in VTN service
Change-Id: Ie417b6e6b52c38adf513a77d62d57112cb1827d3
diff --git a/xos/admin.py b/xos/admin.py
index ff3400e..9973bc9 100644
--- a/xos/admin.py
+++ b/xos/admin.py
@@ -19,58 +19,8 @@
from django.core.urlresolvers import reverse
from django.contrib.admin.utils import quote
-class VTNServiceForm(forms.ModelForm):
- privateGatewayMac = forms.CharField(required=False)
- localManagementIp = forms.CharField(required=False)
- ovsdbPort = forms.CharField(required=False)
- sshPort = forms.CharField(required=False)
- sshUser = forms.CharField(required=False)
- sshKeyFile = forms.CharField(required=False)
- mgmtSubnetBits = forms.CharField(required=False)
- xosEndpoint = forms.CharField(required=False)
- xosUser = forms.CharField(required=False)
- xosPassword = forms.CharField(required=False)
- vtnAPIVersion = forms.IntegerField(required=False)
- controllerPort = forms.CharField(required=False)
-
- def __init__(self,*args,**kwargs):
- super (VTNServiceForm,self ).__init__(*args,**kwargs)
- if self.instance:
- self.fields['privateGatewayMac'].initial = self.instance.privateGatewayMac
- self.fields['localManagementIp'].initial = self.instance.localManagementIp
- self.fields['ovsdbPort'].initial = self.instance.ovsdbPort
- self.fields['sshPort'].initial = self.instance.sshPort
- self.fields['sshUser'].initial = self.instance.sshUser
- self.fields['sshKeyFile'].initial = self.instance.sshKeyFile
- self.fields['mgmtSubnetBits'].initial = self.instance.mgmtSubnetBits
- self.fields['xosEndpoint'].initial = self.instance.xosEndpoint
- self.fields['xosUser'].initial = self.instance.xosUser
- self.fields['xosPassword'].initial = self.instance.xosPassword
- self.fields['vtnAPIVersion'].initial = self.instance.vtnAPIVersion
- self.fields['controllerPort'].initial = self.instance.controllerPort
-
- def save(self, commit=True):
- self.instance.privateGatewayMac = self.cleaned_data.get("privateGatewayMac")
- self.instance.localManagementIp = self.cleaned_data.get("localManagementIp")
- self.instance.ovsdbPort = self.cleaned_data.get("ovsdbPort")
- self.instance.sshPort = self.cleaned_data.get("sshPort")
- self.instance.sshUser = self.cleaned_data.get("sshUser")
- self.instance.sshKeyFile = self.cleaned_data.get("sshKeyFile")
- self.instance.mgmtSubnetBits = self.cleaned_data.get("mgmtSubnetBits")
- self.instance.xosEndpoint = self.cleaned_data.get("xosEndpoint")
- self.instance.xosUser = self.cleaned_data.get("xosUser")
- self.instance.xosPassword = self.cleaned_data.get("xosPassword")
- self.instance.vtnAPIVersion = self.cleaned_data.get("vtnAPIVersion")
- self.instance.controllerPort = self.cleaned_data.get("controllerPort")
- return super(VTNServiceForm, self).save(commit=commit)
-
- class Meta:
- model = VTNService
- fields = '__all__'
-
class VTNServiceAdmin(ReadOnlyAwareAdmin):
model = VTNService
- form = VTNServiceForm
verbose_name = "VTN Service"
verbose_name_plural = "VTN Service"
list_display = ("backend_status_icon", "name", "enabled")
diff --git a/xos/models.py b/xos/models.py
index 1c6f7bf..ec2162a 100644
--- a/xos/models.py
+++ b/xos/models.py
@@ -1,13 +1,9 @@
from django.db import models
-from core.models import Service, PlCoreBase, Slice, Instance, Tenant, TenantWithContainer, Node, Image, User, Flavor, Subscriber, NetworkParameter, NetworkParameterType, Port, AddressPool
+from core.models import Service
from core.models.plcorebase import StrippedCharField
import os
from django.db import models, transaction
from django.forms.models import model_to_dict
-from django.db.models import Q
-from operator import itemgetter, attrgetter, methodcaller
-from core.models import Tag
-from core.models.service import LeastLoadedNodeScheduler
import traceback
from xos.exceptions import *
from xos.config import Config
@@ -27,21 +23,17 @@
class Meta:
app_label = "vtn"
verbose_name = "VTN Service"
- proxy = True
- simple_attributes = ( ("privateGatewayMac", "00:00:00:00:00:01"),
- ("localManagementIp", "172.27.0.1/24"),
- ("ovsdbPort", "6641"),
- ("sshPort", "22"),
- ("sshUser", "root"),
- ("sshKeyFile", "/root/node_key") ,
- ("mgmtSubnetBits", "24"),
- ("xosEndpoint", "http://xos/"),
- ("xosUser", "padmin@vicci.org"),
- ("xosPassword", "letmein"),
- ("vtnAPIVersion", 1),
- ("controllerPort", "onos-cord:6653"),
+ privateGatewayMac = StrippedCharField(max_length=30, default="00:00:00:00:00:01")
+ localManagementIp = StrippedCharField(max_length=30, default="172.27.0.1/24")
+ ovsdbPort = models.IntegerField(default=6641)
+ sshPort = models.IntegerField(default=22)
+ sshUser = StrippedCharField(max_length=30, default="root")
+ sshKeyFile = StrippedCharField(max_length=1024, default="/root/node_key")
+ mgmtSubnetBits = models.IntegerField(default=24)
+ xosEndpoint = StrippedCharField(max_length=1024, default="http://xos/")
+ xosUser = StrippedCharField(max_length=255, default="padmin@vicci.org")
+ xosPassword = StrippedCharField(max_length=255, default="letmein")
+ vtnAPIVersion = models.IntegerField(default=1)
+ controllerPort = StrippedCharField(max_length=255, default="onos-cord:6653")
- )
-
-VTNService.setup_simple_attributes()