add bbs_server and bbs_slice to vCPE Service model and admin
diff --git a/xos/cord/admin.py b/xos/cord/admin.py
index 93bd8f5..9513893 100644
--- a/xos/cord/admin.py
+++ b/xos/cord/admin.py
@@ -88,18 +88,24 @@
#-----------------------------------------------------------------------------
class VCPEServiceForm(forms.ModelForm):
- bbs_url = forms.CharField()
- client_network_label = forms.CharField()
+ bbs_url = forms.CharField(required=False)
+ bbs_server = forms.CharField(required=False)
+ backend_network_label = forms.CharField(required=False)
+ bbs_slice = forms.ModelChoiceField(queryset=Slice.objects.all(), required=False)
def __init__(self,*args,**kwargs):
super (VCPEServiceForm,self ).__init__(*args,**kwargs)
if self.instance:
self.fields['bbs_url'].initial = self.instance.bbs_url
- self.fields['client_network_label'].initial = self.instance.client_network_label
+ self.fields['bbs_server'].initial = self.instance.bbs_server
+ self.fields['backend_network_label'].initial = self.instance.client_network_label
+ self.fields['bbs_slice'].initial = self.instance.bbs_slice
def save(self, commit=True):
self.instance.bbs_url = self.cleaned_data.get("bbs_url")
- self.instance.client_network_label = self.cleaned_data.get("client_network_label")
+ self.instance.bbs_server = self.cleaned_data.get("bbs_server")
+ self.instance.client_network_label = self.cleaned_data.get("backend_network_label")
+ self.instance.bbs_slice = self.cleaned_data.get("bbs_slice")
return super(VCPEServiceForm, self).save(commit=commit)
class Meta:
@@ -111,8 +117,10 @@
verbose_name_plural = "vCPE Service"
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", "service_specific_attribute",
- "bbs_url", "client_network_label" ], 'classes':['suit-tab suit-tab-general']})]
+ fieldsets = [(None, {'fields': ['backend_status_text', 'name','enabled','versionNumber', 'description', "view_url", "icon_url", "service_specific_attribute",],
+ 'classes':['suit-tab suit-tab-general']}),
+ ("backend config", {'fields': [ "backend_network_label", "bbs_url", "bbs_server", "bbs_slice"],
+ 'classes':['suit-tab suit-tab-backend']}) ]
readonly_fields = ('backend_status_text', "service_specific_attribute")
inlines = [SliceInline,ServiceAttrAsTabInline,ServicePrivilegeInline]
form = VCPEServiceForm
@@ -121,7 +129,8 @@
user_readonly_fields = ["name", "enabled", "versionNumber", "description"]
- suit_form_tabs =(('general', 'vCPE Service Details'),
+ suit_form_tabs =(('general', 'Service Details'),
+ ('backend', 'Backend Config'),
('administration', 'Administration'),
#('tools', 'Tools'),
('slices','Slices'),
diff --git a/xos/cord/models.py b/xos/cord/models.py
index 15287b8..e219509 100644
--- a/xos/cord/models.py
+++ b/xos/cord/models.py
@@ -409,7 +409,8 @@
KIND = VCPE_KIND
simple_attributes = ( ("bbs_url", None),
- ("client_network_label", "hpc_client") )
+ ("bbs_server", None),
+ ("client_network_label", "hpc_client"), )
def __init__(self, *args, **kwargs):
super(VCPEService, self).__init__(*args, **kwargs)
@@ -433,6 +434,22 @@
raise XOSConfigurationError("We've run out of available broadbandshield accounts. Delete some vcpe and try again.")
+ @property
+ def bbs_slice(self):
+ bbs_slice_id=self.get_attribute("bbs_slice_id")
+ if not bbs_slice_id:
+ return None
+ bbs_slices=Slice.objects.filter(id=bbs_slice_id)
+ if not bbs_slices:
+ return None
+ return bbs_slices[0]
+
+ @bbs_slice.setter
+ def bbs_slice(self, value):
+ if value:
+ value = value.id
+ self.set_attribute("bbs_slice_id", value)
+
VCPEService.setup_simple_attributes()