Defined Models and REST APIs
TOSCA specs
Synchronizer
Change-Id: Icd9dde1b456711ca7e5f0c69ae547072ff5b3120
diff --git a/xos/admin.py b/xos/admin.py
index 4901939..a6ce270 100644
--- a/xos/admin.py
+++ b/xos/admin.py
@@ -11,7 +11,7 @@
from django.contrib.contenttypes import generic
from suit.widgets import LinkedSelect
from core.models import AddressPool
-from core.admin import ServiceAppAdmin,SliceInline,ServiceAttrAsTabInline, ReadOnlyAwareAdmin, XOSTabularInline, ServicePrivilegeInline, AddressPoolInline
+from core.admin import ServiceAppAdmin, SliceInline, ServiceAttrAsTabInline, ReadOnlyAwareAdmin, XOSTabularInline, ServicePrivilegeInline, AddressPoolInline
from core.middleware import get_request
from functools import update_wrapper
@@ -19,9 +19,31 @@
from django.core.urlresolvers import reverse
from django.contrib.admin.utils import quote
+
+class VRouterPortInline(XOSTabularInline):
+ model = VRouterPort
+ fields = ['openflow_id']
+ suit_classes = 'suit-tab suit-tab-vrouter_ports'
+ extra = 0
+
+
+class VRouterInterfaceInline(XOSTabularInline):
+ model = VRouterInterface
+ fields = ['name', 'mac', 'vlan']
+ suit_classes = 'suit-tab suit-tab-vrouter_interfaces'
+ extra = 0
+
+
+class VRouterIpInline(XOSTabularInline):
+ model = VRouterIp
+ fields = ['ip']
+ suit_classes = 'suit-tab suit-tab-vrouter_ips'
+ extra = 0
+
+
class VRouterServiceForm(forms.ModelForm):
- def __init__(self,*args,**kwargs):
- super (VRouterServiceForm,self ).__init__(*args,**kwargs)
+ def __init__(self, *args, **kwargs):
+ super(VRouterServiceForm, self).__init__(*args, **kwargs)
def save(self, commit=True):
return super(VRouterServiceForm, self).save(commit=commit)
@@ -30,37 +52,60 @@
model = VRouterService
fields = '__all__'
+
class VRouterServiceAdmin(ReadOnlyAwareAdmin):
model = VRouterService
verbose_name = "vRouter Service"
verbose_name_plural = "vRouter 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", ],
- 'classes':['suit-tab suit-tab-general']})]
- readonly_fields = ('backend_status_text', )
- inlines = [SliceInline,ServiceAttrAsTabInline,ServicePrivilegeInline,AddressPoolInline]
+ fieldsets = [(None, {
+ 'fields': [
+ 'backend_status_text',
+ 'name',
+ 'enabled',
+ 'versionNumber',
+ 'description',
+ 'view_url',
+ 'icon_url',
+ 'rest_hostname',
+ 'rest_port',
+ 'rest_user',
+ 'rest_pass',
+ ],
+ 'classes':['suit-tab suit-tab-general']})]
+
+ # NOTE make rest_* params editable
+ readonly_fields = (
+ 'backend_status_text',
+ 'rest_hostname',
+ 'rest_port',
+ 'rest_user',
+ 'rest_pass'
+ )
+ inlines = [SliceInline, ServiceAttrAsTabInline, ServicePrivilegeInline, AddressPoolInline]
form = VRouterServiceForm
extracontext_registered_admins = True
user_readonly_fields = ["name", "enabled", "versionNumber", "description"]
- suit_form_tabs =(('general', 'vRouter Service Details'),
+ suit_form_tabs = (
+ ('general', 'vRouter Service Details'),
('administration', 'Administration'),
('addresspools', 'Addresses'),
- #('tools', 'Tools'),
- ('slices','Slices'),
- ('serviceattrs','Additional Attributes'),
- ('serviceprivileges','Privileges'),
+ # ('tools', 'Tools'),
+ ('slices', 'Slices'),
+ ('serviceattrs', 'Additional Attributes'),
+ ('serviceprivileges', 'Privileges'),
)
- suit_form_includes = (('vrouteradmin.html', 'top', 'administration'),
- ) #('hpctools.html', 'top', 'tools') )
+ suit_form_includes = ('vrouteradmin.html', 'top', 'administration') # ('hpctools.html', 'top', 'tools') )
def get_queryset(self, request):
return VRouterService.get_service_objects_by_user(request.user)
+
class VRouterTenantForm(forms.ModelForm):
public_ip = forms.CharField(required=True)
public_mac = forms.CharField(required=True)
@@ -97,20 +142,82 @@
model = VRouterTenant
fields = '__all__'
+
class VRouterTenantAdmin(ReadOnlyAwareAdmin):
- list_display = ('backend_status_icon', 'id', 'subscriber_tenant', 'public_ip' )
+ list_display = ('backend_status_icon', 'id', 'subscriber_tenant', 'public_ip')
list_display_links = ('backend_status_icon', 'id')
- fieldsets = [ (None, {'fields': ['backend_status_text', 'kind', 'provider_service', 'subscriber_tenant', 'subscriber_service',
- 'address_pool', 'public_ip', 'public_mac', 'gateway_ip', 'gateway_mac', 'cidr'],
- 'classes':['suit-tab suit-tab-general']})]
+ fieldsets = [(None, {
+ 'fields': [
+ 'backend_status_text', 'kind', 'provider_service', 'subscriber_tenant', 'subscriber_service',
+ 'address_pool', 'public_ip', 'public_mac', 'gateway_ip', 'gateway_mac', 'cidr'],
+ 'classes':['suit-tab suit-tab-general']
+ })]
readonly_fields = ('backend_status_text', 'service_specific_attribute', 'gateway_ip', 'gateway_mac', 'cidr')
form = VRouterTenantForm
- suit_form_tabs = (('general','Details'),)
+ suit_form_tabs = (('general', 'Details'),)
def get_queryset(self, request):
return VRouterTenant.get_tenant_objects_by_user(request.user)
+
+class VRouterDeviceAdmin(ReadOnlyAwareAdmin):
+ list_display = ('name', 'openflow_id', 'config_key', 'driver')
+ fieldsets = [(None, {
+ 'fields': ['name', 'openflow_id', 'vrouter_service', 'config_key', 'driver'],
+ 'classes':['suit-tab suit-tab-general']
+ })]
+ inlines = [VRouterPortInline]
+
+ suit_form_tabs = (
+ ('general', 'Device Details'),
+ ('vrouter_ports', 'Ports'),
+ )
+
+
+class VRouterPortAdmin(ReadOnlyAwareAdmin):
+ list_display = ('name', 'openflow_id', 'vrouter_device')
+ fieldsets = [(None, {
+ 'fields': ['name', 'openflow_id', 'vrouter_service', 'vrouter_device'],
+ 'classes':['suit-tab suit-tab-general']
+ })]
+ inlines = [VRouterInterfaceInline]
+
+ suit_form_tabs = (
+ ('general', 'Ports Details'),
+ ('vrouter_interfaces', 'Interfaces'),
+ )
+
+
+class VRouterInterfaceAdmin(ReadOnlyAwareAdmin):
+ list_display = ('name', 'mac', 'vlan')
+ fieldsets = [(None, {
+ 'fields': ['name', 'vrouter_port', 'mac', 'vlan'],
+ 'classes':['suit-tab suit-tab-general']
+ })]
+ inlines = [VRouterIpInline]
+
+ suit_form_tabs = (
+ ('general', 'Interfaces Details'),
+ ('vrouter_ips', 'Ips'),
+ )
+
+
+class VRouterIpAdmin(ReadOnlyAwareAdmin):
+ list_display = ('name', 'ip', 'vrouter_interface')
+ fieldsets = [(None, {'fields': ['name', 'ip', 'vrouter_interface']})]
+
+
+class VRouterAppAdmin(ReadOnlyAwareAdmin):
+ list_display = ('name', 'control_plane_connect_point', 'ospf_enabled')
+ fieldsets = [(None, {'fields': ['name', 'vrouter_service', 'control_plane_connect_point', 'ospf_enabled']})]
+
+
admin.site.register(VRouterService, VRouterServiceAdmin)
admin.site.register(VRouterTenant, VRouterTenantAdmin)
+admin.site.register(VRouterDevice, VRouterDeviceAdmin)
+admin.site.register(VRouterPort, VRouterPortAdmin)
+admin.site.register(VRouterInterface, VRouterInterfaceAdmin)
+admin.site.register(VRouterIp, VRouterIpAdmin)
+admin.site.register(VRouterApp, VRouterAppAdmin)