add use_external_host
diff --git a/xos/services/onos/admin.py b/xos/services/onos/admin.py
index 4989fb2..d5696b4 100644
--- a/xos/services/onos/admin.py
+++ b/xos/services/onos/admin.py
@@ -18,15 +18,32 @@
from django.core.urlresolvers import reverse
from django.contrib.admin.utils import quote
+class ONOSServiceForm(forms.ModelForm):
+ use_external_host = forms.CharField(required=False)
+
+ def __init__(self,*args,**kwargs):
+ super (ONOSServiceForm,self ).__init__(*args,**kwargs)
+ if self.instance:
+ # fields for the attributes
+ self.fields['use_external_host'].initial = self.instance.use_external_host
+
+ def save(self, commit=True):
+ self.instance.use_external_host = self.cleaned_data.get("use_external_host")
+ return super(ONOSServiceForm, self).save(commit=commit)
+
+ class Meta:
+ model = ONOSService
+
class ONOSServiceAdmin(ReadOnlyAwareAdmin):
model = ONOSService
verbose_name = "ONOS Service"
verbose_name_plural = "ONOS Services"
list_display = ("backend_status_icon", "name", "enabled")
list_display_links = ('backend_status_icon', 'name', )
- fieldsets = [(None, {'fields': ['backend_status_text', 'name','enabled','versionNumber', 'description',"view_url","icon_url" ], 'classes':['suit-tab suit-tab-general']})]
+ fieldsets = [(None, {'fields': ['backend_status_text', 'name','enabled','versionNumber', 'description',"view_url","icon_url", "use_external_host" ], 'classes':['suit-tab suit-tab-general']})]
readonly_fields = ('backend_status_text', )
inlines = [SliceInline,ServiceAttrAsTabInline,ServicePrivilegeInline]
+ form = ONOSServiceForm
extracontext_registered_admins = True
@@ -48,7 +65,7 @@
class ONOSAppForm(forms.ModelForm):
creator = forms.ModelChoiceField(queryset=User.objects.all())
name = forms.CharField()
- dependencies = forms.CharField()
+ dependencies = forms.CharField(required=False)
def __init__(self,*args,**kwargs):
super (ONOSAppForm,self ).__init__(*args,**kwargs)
diff --git a/xos/services/onos/models.py b/xos/services/onos/models.py
index b47dd10..8ed3618 100644
--- a/xos/services/onos/models.py
+++ b/xos/services/onos/models.py
@@ -21,6 +21,16 @@
verbose_name = "ONOS Service"
proxy = True
+ default_attributes = {"use_external_host": ""}
+
+ @property
+ def use_external_host(self):
+ return self.get_attribute("use_external_host", self.default_attributes["use_external_host"])
+
+ @use_external_host.setter
+ def use_external_host(self, value):
+ self.set_attribute("use_external_host", value)
+
class ONOSApp(Tenant): # aka 'ONOSTenant'
class Meta:
proxy = True
@@ -28,7 +38,7 @@
KIND = ONOS_KIND
default_attributes = {"name": "",
- "dependencies": ""}
+ "dependencies": "",}
def __init__(self, *args, **kwargs):
onos_services = ONOSService.get_service_objects().all()
if onos_services: