class SliverInline(PlStackTabularInline):
model = Sliver
- fields = ['backend_status_icon', 'all_ips_string', 'instance_name', 'slice', 'controllerNetwork', 'flavor', 'image', 'node']
+ fields = ['backend_status_icon', 'all_ips_string', 'instance_name', 'slice', 'deployment', 'flavor', 'image', 'node']
extra = 0
readonly_fields = ['backend_status_icon', 'all_ips_string', 'instance_name']
suit_classes = 'suit-tab suit-tab-slivers'
return Sliver.select_by_user(request.user)
def formfield_for_foreignkey(self, db_field, request=None, **kwargs):
- if db_field.name == 'controllerNetwork':
+ if db_field.name == 'deployment':
kwargs['queryset'] = Deployment.select_by_acl(request.user)
kwargs['widget'] = forms.Select(attrs={'onChange': "sliver_deployment_changed(this);"})
- elif db_field.name == 'flavor':
+ if db_field.name == 'flavor':
kwargs['widget'] = forms.Select(attrs={'onChange': "sliver_flavor_changed(this);"})
field = super(SliverInline, self).formfield_for_foreignkey(db_field, request, **kwargs)
def queryset(self, request):
return DeploymentPrivilege.select_by_user(request.user)
-class ControllerPrivilegeInline(PlStackTabularInline):
- model = ControllerPrivilege
+class ControllerSiteInline(PlStackTabularInline):
+ model = ControllerSite
extra = 0
suit_classes = 'suit-tab suit-tab-admin-only'
- fields = ['backend_status_icon', 'user','role','controller']
- readonly_fields = ('backend_status_icon', )
+ fields = ['controller', 'site', 'tenant_id']
- def queryset(self, request):
- return ControllerPrivilege.select_by_user(request.user)
-
-class ControllerSiteDeploymentsInline(PlStackTabularInline):
- model = ControllerSiteDeployments
- extra = 0
- suit_classes = 'suit-tab suit-tab-admin-only'
- fields = ['controller', 'site_deployment', 'tenant_id']
class SitePrivilegeInline(PlStackTabularInline):
model = SitePrivilege
def queryset(self, request):
return SitePrivilege.select_by_user(request.user)
-class SiteDeploymentsInline(PlStackTabularInline):
- model = SiteDeployments
+class SiteDeploymentInline(PlStackTabularInline):
+ model = SiteDeployment
extra = 0
suit_classes = 'suit-tab suit-tab-deployments'
fields = ['backend_status_icon', 'deployment','site', 'controller']
if db_field.name == 'controller':
kwargs['queryset'] = Controller.select_by_user(request.user)
- return super(SiteDeploymentsInline, self).formfield_for_foreignkey(db_field, request, **kwargs)
+ return super(SiteDeploymentInline, self).formfield_for_foreignkey(db_field, request, **kwargs)
def queryset(self, request):
- return SiteDeployments.select_by_user(request.user)
+ return SiteDeployment.select_by_user(request.user)
class SlicePrivilegeInline(PlStackTabularInline):
self.fields['accessControl'].initial = "allow site " + request.user.site.name
if self.instance and self.instance.pk:
- self.fields['sites'].initial = [x.site for x in self.instance.sitedeployments.all()]
+ self.fields['sites'].initial = [x for x in self.instance.sites.all()]
self.fields['images'].initial = [x.image for x in self.instance.imagedeployments.all()]
self.fields['flavors'].initial = self.instance.flavors.all()
# create/destroy the through models ourselves. There has to be
# a better way...
- self.manipulate_m2m_objs(deployment, self.cleaned_data['sites'], deployment.sitedeployments.all(), SiteDeployments, "deployment", "site")
+ self.manipulate_m2m_objs(deployment, self.cleaned_data['sites'], deployment.sitedeployment.all(), SiteDeployment, "deployment", "site")
self.manipulate_m2m_objs(deployment, self.cleaned_data['images'], deployment.imagedeployments.all(), ImageDeployments, "deployment", "image")
# manipulate_m2m_objs doesn't work for Flavor/Deployment relationship
# so well handle that manually here
for flavor in deployment.flavors.all():
if getattr(flavor, 'name') not in self.cleaned_data['flavors']:
- flavor.delete()
+ deployment.flavors.remove(flavor)
for flavor in self.cleaned_data['flavors']:
if flavor not in deployment.flavors.all():
flavor.deployments.add(deployment)
return AdminFormMetaClass
class ControllerAdminForm(forms.ModelForm):
- site_deployments = forms.ModelMultipleChoiceField(
- queryset=SiteDeployments.objects.all(),
+ sites = forms.ModelMultipleChoiceField(
+ queryset=Site.objects.all(),
required=False,
- help_text="Select which sites deployments are managed by this controller",
+ help_text="Select which sites are managed by this controller",
widget=FilteredSelectMultiple(
- verbose_name=('Site Deployments'), is_stacked=False
+ verbose_name=('Sites'), is_stacked=False
)
)
super(ControllerAdminForm, self).__init__(*args, **kwargs)
if self.instance and self.instance.pk:
- self.fields['site_deployments'].initial = [x.site_deployment for x in self.instance.controllersitedeployments.all()]
+ self.fields['sites'].initial = [x.site_deployment for x in self.instance.controllersite.all()]
def manipulate_m2m_objs(self, this_obj, selected_objs, all_relations, relation_class, local_attrname, foreign_attrname):
""" helper function for handling m2m relations from the MultipleChoiceField
# save_m2m() doesn't seem to work with 'through' relations. So we
# create/destroy the through models ourselves. There has to be
# a better way...
- self.manipulate_m2m_objs(controller, self.cleaned_data['site_deployments'], controller.controllersitedeployments.all(), ControllerSiteDeployments, "controller", "site_deployment")
-
+ self.manipulate_m2m_objs(controller, self.cleaned_data['sites'], controller.controllersite.all(), ControllerSite, "controller", "site")
+ pass
+
self.save_m2m()
return controller
model = Controller
fieldList = ['name', 'version', 'backend_type', 'auth_url', 'admin_user', 'admin_tenant','admin_password']
#fieldsets = [(None, {'fields': fieldList, 'classes':['suit-tab suit-tab-general']})]
- inlines = [ControllerSiteDeploymentsInline] # ,ControllerImagesInline]
+ inlines = [ControllerSiteInline] # ,ControllerImagesInline]
list_display = ['backend_status_icon', 'name', 'version', 'backend_type']
list_display_links = ('backend_status_icon', 'name', )
readonly_fields = ('backend_status_text',)
(None, {'fields': fieldList, 'classes':['suit-tab suit-tab-general']}),
#('Deployment Networks', {'fields': ['deployments'], 'classes':['suit-tab suit-tab-deployments']}),
]
- suit_form_tabs =(('general', 'Site Details'),
- ('users','Users'),
- ('siteprivileges','Privileges'),
- ('deployments','Deployments'),
- ('slices','Slices'),
- #('nodes','Nodes'),
- ('tags','Tags'),
- )
readonly_fields = ['backend_status_text', 'accountLink']
user_readonly_fields = ['name', 'deployments','site_url', 'enabled', 'is_public', 'login_base', 'accountLink']
list_display = ('backend_status_icon', 'name', 'login_base','site_url', 'enabled')
list_display_links = ('backend_status_icon', 'name', )
filter_horizontal = ('deployments',)
- inlines = [SliceInline,UserInline,TagInline, SitePrivilegeInline, SiteDeploymentsInline]
+ inlines = [SliceInline,UserInline,TagInline, SitePrivilegeInline, SiteDeploymentInline]
+ admin_inlines = [ControllerSite]
search_fields = ['name']
+ @property
+ def suit_form_tabs(self):
+ tabs = [('general', 'Site Details'),
+ ('users','Users'),
+ ('siteprivileges','Privileges'),
+ ('deployments','Deployments'),
+ ('slices','Slices'),
+ #('nodes','Nodes'),
+ ('tags','Tags'),
+ ]
+
+ request=getattr(_thread_locals, "request", None)
+ if request and request.user.is_admin:
+ tabs.append( ('admin-only', 'Admin-Only') )
+
+ return tabs
+
def queryset(self, request):
return Site.select_by_user(request.user)
raise forms.ValidationError('slice name must begin with %s' % site.login_base)
return cleaned_data
-class ControllerSlicesInline(PlStackTabularInline):
- model = ControllerSlices
+class ControllerSliceInline(PlStackTabularInline):
+ model = ControllerSlice
extra = 0
verbose_name = "Controller Slices"
verbose_name_plural = "Controller Slices"
suit_classes = 'suit-tab suit-tab-admin-only'
fields = ['backend_status_icon', 'controller', 'tenant_id']
- readonly_fields = ('backend_status_icon', )
+ readonly_fields = ('backend_status_icon', 'controller' )
class SliceAdmin(PlanetStackBaseAdmin):
form = SliceForm
list_display = ('backend_status_icon', 'name', 'site','serviceClass', 'slice_url', 'max_slivers')
list_display_links = ('backend_status_icon', 'name', )
inlines = [SlicePrivilegeInline,SliverInline, TagInline, ReservationInline,SliceNetworkInline]
- admin_inlines = [ControllerSlicesInline]
+ admin_inlines = [ControllerSliceInline]
user_readonly_fields = fieldList
def render_change_form(self, request, context, add=False, change=False, form_url='', obj=None):
deployment_nodes = []
for node in Node.objects.all():
- deployment_nodes.append( (node.deployment.id, node.id, node.name) )
+ deployment_nodes.append( (node.site_deployment.id, node.id, node.name) )
deployment_flavors = []
for flavor in Flavor.objects.all():
deployment_images = []
for image in Image.objects.all():
for deployment_image in image.imagedeployments.all():
- deployment_images.append( (deployment_image.controller.id, image.id, image.name) )
+ deployment_images.append( (deployment_image.deployment.id, image.id, image.name) )
site_login_bases = []
for site in Site.objects.all():
'ip': PlainTextWidget(),
'instance_name': PlainTextWidget(),
'slice': LinkedSelect,
- 'controllerNetwork': LinkedSelect,
+ 'deployment': LinkedSelect,
'node': LinkedSelect,
'image': LinkedSelect
}
class SliverAdmin(PlanetStackBaseAdmin):
form = SliverForm
fieldsets = [
- ('Sliver Details', {'fields': ['backend_status_text', 'slice', 'controllerNetwork', 'node', 'ip', 'instance_name', 'flavor', 'image', ], 'classes': ['suit-tab suit-tab-general'], })
+ ('Sliver Details', {'fields': ['backend_status_text', 'slice', 'deployment', 'node', 'ip', 'instance_name', 'flavor', 'image', ], 'classes': ['suit-tab suit-tab-general'], })
]
readonly_fields = ('backend_status_text', )
- list_display = ['backend_status_icon', 'ip', 'instance_name', 'slice', 'flavor', 'image', 'node', 'controllerNetwork']
+ list_display = ['backend_status_icon', 'ip', 'instance_name', 'slice', 'flavor', 'image', 'node', 'deployment']
list_display_links = ('backend_status_icon', 'ip',)
suit_form_tabs =(('general', 'Sliver Details'),
inlines = [TagInline]
- user_readonly_fields = ['slice', 'controllerNetwork', 'node', 'ip', 'instance_name', 'flavor', 'image']
+ user_readonly_fields = ['slice', 'deployment', 'node', 'ip', 'instance_name', 'flavor', 'image']
def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == 'slice':
suit_classes = 'suit-tab suit-tab-dashboards'
fields = ['user', 'dashboardView', 'order']
+class ControllerUserInline(PlStackTabularInline):
+ model = ControllerUser
+ extra = 0
+ suit_classes = 'suit-tab suit-tab-admin-only'
+ fields = ['controller', 'user', 'kuser_id']
+ readonly_fields=['controller']
+
+
class UserAdmin(PermissionCheckingAdminMixin, UserAdmin):
# Note: Make sure PermissionCheckingAdminMixin is listed before
# admin.ModelAdmin in the class declaration.
# that reference specific fields on auth.User.
list_display = ('email', 'firstname', 'lastname', 'site', 'last_login')
list_filter = ('site',)
- inlines = [SlicePrivilegeInline,SitePrivilegeInline,ControllerPrivilegeInline,UserDashboardViewInline]
-
+ inlines = [SlicePrivilegeInline,SitePrivilegeInline,UserDashboardViewInline]
+ admin_inlines = [ControllerUserInline]
fieldListLoginDetails = ['backend_status_text', 'email','site','password','is_active','is_readonly','is_admin','public_key']
fieldListContactInfo = ['firstname','lastname','phone','timezone']
if getattr(_thread_locals, "obj", None) is None:
return []
else:
- return (('general','Login Details'),
+ tabs = [('general','Login Details'),
('contact','Contact Information'),
('sliceprivileges','Slice Privileges'),
('siteprivileges','Site Privileges'),
- ('controllerprivileges','Controller Privileges'),
- ('dashboards','Dashboard Views'))
+ ('dashboards','Dashboard Views')]
+
+ request=getattr(_thread_locals, "request", None)
+ if request and request.user.is_admin:
+ tabs.append( ('admin-only', 'Admin-Only') )
+
+ return tabs
def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == 'site':
def queryset(self, request):
return User.select_by_user(request.user)
+class ControllerDashboardViewInline(PlStackTabularInline):
+ model = ControllerDashboardView
+ extra = 0
+ fields = ["controller", "url"]
+ suit_classes = 'suit-tab suit-tab-controllers'
+
class DashboardViewAdmin(PlanetStackBaseAdmin):
fieldsets = [('Dashboard View Details',
{'fields': ['backend_status_text', 'name', 'url'],
'classes': ['suit-tab suit-tab-general']})
]
readonly_fields = ('backend_status_text', )
+ inlines = [ControllerDashboardViewInline]
- suit_form_tabs =(('general','Dashboard View Details'),)
+ suit_form_tabs =(('general','Dashboard View Details'),
+ ('controllers', 'Per-controller Dashboard Details'))
class ServiceResourceInline(PlStackTabularInline):
model = ServiceResource
fields = ['backend_status_icon', 'network','slice']
readonly_fields = ('backend_status_icon', )
-class ControllerNetworksInline(PlStackTabularInline):
- model = ControllerNetworks
+class ControllerNetworkInline(PlStackTabularInline):
+ model = ControllerNetwork
extra = 0
verbose_name_plural = "Controller Networks"
verbose_name = "Controller Network"
readonly_fields = ("subnet", )
inlines = [NetworkParameterInline, NetworkSliversInline, NetworkSlicesInline, RouterInline]
- admin_inlines = [ControllerNetworksInline]
+ admin_inlines = [ControllerNetworkInline]
form=NetworkForm
fieldsets = [
- (None, {'fields': ['backend_status_text', 'name','template','ports','labels','owner','guaranteedBandwidth', 'permitAllSlices','permittedSlices','network_id','router_id','subnet_id','subnet'],
+ (None, {'fields': ['backend_status_text', 'name','template','ports','labels','owner','guaranteed_bandwidth', 'permit_all_slices','permitted_slices','network_id','router_id','subnet_id','subnet'],
'classes':['suit-tab suit-tab-general']}),
- (None, {'fields': ['topologyParameters', 'controllerUrl', 'controllerParameters'],
+ (None, {'fields': ['topology_parameters', 'controller_url', 'controller_parameters'],
'classes':['suit-tab suit-tab-sdn']}),
]
readonly_fields = ('backend_status_text', )
- user_readonly_fields = ['name','template','ports','labels','owner','guaranteedBandwidth', 'permitAllSlices','permittedSlices','network_id','router_id','subnet_id','subnet']
+ user_readonly_fields = ['name','template','ports','labels','owner','guaranteed_bandwidth', 'permit_all_slices','permitted_slices','network_id','router_id','subnet_id','subnet']
@property
def suit_form_tabs(self):
class NetworkTemplateAdmin(PlanetStackBaseAdmin):
- list_display = ("backend_status_icon", "name", "guaranteedBandwidth", "visibility")
+ list_display = ("backend_status_icon", "name", "guaranteed_bandwidth", "visibility")
list_display_links = ('backend_status_icon', 'name', )
- user_readonly_fields = ["name", "guaranteedBandwidth", "visibility"]
+ user_readonly_fields = ["name", "guaranteed_bandwidth", "visibility"]
user_readonly_inlines = []
fieldsets = [
- (None, {'fields': ['name', 'description', 'guaranteedBandwidth', 'visibility', 'translation', 'sharedNetworkName', 'sharedNetworkId', 'topologyKind', 'controllerKind'],
+ (None, {'fields': ['name', 'description', 'guaranteed_bandwidth', 'visibility', 'translation', 'shared_network_name', 'shared_network_id', 'topology_kind', 'controller_kind'],
'classes':['suit-tab suit-tab-general']}),]
suit_form_tabs = (('general','Network Template Details'), )