VRE Backend API and Scheduler
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

82 lines
2.8 KiB

from django.contrib import admin
from django.template.defaultfilters import filesizeformat
from .models import (VirtualMachineOperatingSystem,
VirtualMachineMemory,
VirtualMachineStorage,
VirtualMachineGPU,
VirtualMachineNetwork,
VirtualMachineProfile,
VirtualMachine,
VirtualMachineAccess)
# Register your models here.
@admin.register(VirtualMachine)
class VirtualMachineAdmin(admin.ModelAdmin):
list_display = ('name', 'researcher', 'profile', 'provider', 'total_memory', 'total_storage', 'created_at')
list_filter = ('provider', 'profile')
search_fields = ('name', 'researcher', 'profile', 'provider', )
ordering = ('-created_at', 'name', 'researcher', )
readonly_fields = ('created_at', 'updated_at')
def total_memory(self, obj):
return filesizeformat(obj.total_memory)
def total_storage(self, obj):
return filesizeformat(obj.total_storage)
class VirtualMachinePartAdmin(admin.ModelAdmin):
list_display = ('name', 'provider', 'is_available', 'created_at')
list_filter = ('provider', 'is_available')
search_fields = ('name', 'provider', )
ordering = ('provider', 'name', '-created_at', )
readonly_fields = ('created_at', 'updated_at', )
fields = ('name', 'provider', 'cloud_id', 'is_available', 'created_at', 'updated_at')
@admin.register(VirtualMachineOperatingSystem)
class VirtualMachineOperatingSystemAdmin(VirtualMachinePartAdmin):
pass
@admin.register(VirtualMachineMemory)
class VirtualMachineMemoryAdmin(VirtualMachinePartAdmin):
pass
@admin.register(VirtualMachineNetwork)
class VirtualMachineNetworkAdmin(VirtualMachinePartAdmin):
pass
@admin.register(VirtualMachineStorage)
class VirtualMachineStorageAdmin(VirtualMachinePartAdmin):
pass
@admin.register(VirtualMachineGPU)
class VirtualMachineGPUAdmin(VirtualMachinePartAdmin):
pass
@admin.register(VirtualMachineProfile)
class VirtualMachineProfileAdmin(VirtualMachinePartAdmin):
list_display = ('name', 'provider', 'is_available', 'created_at')
list_filter = ('provider', 'is_available')
search_fields = ('name', 'provider', )
ordering = ('provider', 'name', '-created_at', )
readonly_fields = ('created_at', 'updated_at', )
fields = ('name', 'provider', 'os', 'networks', 'memory_type', 'memory_amount', 'storage_type', 'storage_amount', 'gpu_type', 'gpu_amount', 'is_available', 'created_at', 'updated_at')
@admin.register(VirtualMachineAccess)
class VirtualMachineAccessAdmin(admin.ModelAdmin):
list_display = ('researcher', 'virtual_machine', 'created_at')
search_fields = ('researcher', 'virtual_machine')
ordering = ('-created_at', 'researcher',)
readonly_fields = ('username', 'created_at', 'updated_at')