hide Deployment column for mysite_vcpe slice
diff --git a/xos/core/admin.py b/xos/core/admin.py
index f48a7f5..c2de0f7 100644
--- a/xos/core/admin.py
+++ b/xos/core/admin.py
@@ -433,6 +433,28 @@
return field
+class CordSliverInline(XOSTabularInline):
+ model = Sliver
+ fields = ['backend_status_icon', 'all_ips_string', 'instance_id', 'instance_name', 'slice', 'flavor', 'image', 'node']
+ extra = 0
+ readonly_fields = ['backend_status_icon', 'all_ips_string', 'instance_id', 'instance_name']
+ suit_classes = 'suit-tab suit-tab-slivers'
+
+ def queryset(self, request):
+ return Sliver.select_by_user(request.user)
+
+ def formfield_for_foreignkey(self, db_field, request=None, **kwargs):
+ if db_field.name == 'deployment':
+
+ kwargs['queryset'] = Deployment.select_by_acl(request.user).filter(sitedeployments__nodes__isnull=False).distinct()
+ kwargs['widget'] = forms.Select(attrs={'onChange': "sliver_deployment_changed(this);"})
+ if db_field.name == 'flavor':
+ kwargs['widget'] = forms.Select(attrs={'onChange': "sliver_flavor_changed(this);"})
+
+ field = super(CordSliverInline, self).formfield_for_foreignkey(db_field, request, **kwargs)
+
+ return field
+
class SiteInline(XOSTabularInline):
model = Site
extra = 0
@@ -975,7 +997,8 @@
readonly_fields = ('backend_status_text', )
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]
+ normal_inlines = [SlicePrivilegeInline, SliverInline, TagInline, ReservationInline, SliceNetworkInline]
+ inlines = normal_inlines
admin_inlines = [ControllerSliceInline]
user_readonly_fields = fieldList
@@ -997,6 +1020,8 @@
return tabs
def add_view(self, request, form_url='', extra_context=None):
+ # Ugly hack for CORD
+ self.inlines = self.normal_inlines
# revert to default read-only fields
self.readonly_fields = ('backend_status_text',)
return super(SliceAdmin, self).add_view(request, form_url, extra_context=extra_context)
@@ -1005,6 +1030,14 @@
# cannot change the site of an existing slice so make the site field read only
if object_id:
self.readonly_fields = ('backend_status_text','site')
+
+ # Ugly hack for CORD
+ self.inlines = self.normal_inlines
+ if object_id:
+ slice = Slice.objects.get(pk=object_id)
+ if slice.name == "mysite_vcpe":
+ self.inlines = [ SlicePrivilegeInline, CordSliverInline, TagInline, ReservationInline,SliceNetworkInline]
+
return super(SliceAdmin, self).change_view(request, object_id, form_url)
def render_change_form(self, request, context, add=False, change=False, form_url='', obj=None):
@@ -1052,6 +1085,23 @@
inline.model.caller = request.user
yield inline.get_formset(request, obj)
+ def UNUSED_get_inline_instances(self, request, obj=None):
+ # HACK for CORD to do something special on vcpe slice page
+ # this was a good idea, but failed miserably, as something still
+ # expects there to be a deployment field.
+ # XXX this approach is better than clobbering self.inlines, so
+ # try to make this work post-demo.
+ if (obj is not None) and (obj.name == "mysite_vcpe"):
+ cord_vcpe_inlines = [ SlicePrivilegeInline, CordSliverInline, TagInline, ReservationInline,SliceNetworkInline]
+
+ inlines=[]
+ for inline_class in cord_vcpe_inlines:
+ inlines.append(inline_class(self.model, self.admin_site))
+ else:
+ inlines = super(SliceAdmin, self).get_inline_instances(request, obj)
+
+ return inlines
+
class SlicePrivilegeAdmin(XOSBaseAdmin):
fieldsets = [
(None, {'fields': ['backend_status_text', 'user', 'slice', 'role']})
@@ -1091,7 +1141,6 @@
obj.os_manager = OpenStackManager(auth=auth, caller=request.user)
obj.delete()
-
class ImageAdmin(XOSBaseAdmin):
fieldsets = [('Image Details',