summaryrefslogtreecommitdiffstats
path: root/dashboard/src/api/serializers/booking_serializer.py
diff options
context:
space:
mode:
authorParker Berberian <pberberian@iol.unh.edu>2018-11-20 11:19:55 -0500
committerParker Berberian <pberberian@iol.unh.edu>2018-11-26 14:07:15 -0500
commitf2bbdbbf7e03be031723a9680aa9deaf80e4a99c (patch)
tree54086b0ae60b65da0905e3b51c922934247b5370 /dashboard/src/api/serializers/booking_serializer.py
parent674812a20f6804c287e1355ec8a1adf907798a94 (diff)
Fix all flake8 errors
The flake8 command in test.sh finds no longer finds any errors. This may form a basis of a jenkins verify job as a sort of 'weak compile-time checks' The flake8 command will not complain about line length, and will not complain about django's manage.py file Change-Id: Ic47cb4fc7ada55e64485661ab6881aef475018ff Signed-off-by: Parker Berberian <pberberian@iol.unh.edu>
Diffstat (limited to 'dashboard/src/api/serializers/booking_serializer.py')
-rw-r--r--dashboard/src/api/serializers/booking_serializer.py37
1 files changed, 28 insertions, 9 deletions
diff --git a/dashboard/src/api/serializers/booking_serializer.py b/dashboard/src/api/serializers/booking_serializer.py
index e891de4..9b5c059 100644
--- a/dashboard/src/api/serializers/booking_serializer.py
+++ b/dashboard/src/api/serializers/booking_serializer.py
@@ -10,7 +10,16 @@
from rest_framework import serializers
-from resource_inventory.models import *
+from resource_inventory.models import (
+ HostConfiguration,
+ CpuProfile,
+ DiskProfile,
+ InterfaceProfile,
+ RamProfile,
+ Image,
+ Interface
+)
+
class BookingField(serializers.Field):
@@ -28,17 +37,17 @@ class BookingField(serializers.Field):
host_configs[host.name] = HostConfiguration.objects.get(host=host.template)
if "jumphost" not in ser and host_configs[host.name].opnfvRole.name.lower() == "jumphost":
ser['jumphost'] = host.name
- #host is a Host model
+ # host is a Host model
for i in range(len(host.interfaces.all())):
interface = host.interfaces.all()[i]
- #interface is an Interface model
+ # interface is an Interface model
for vlan in interface.config.all():
- #vlan is Vlan model
+ # vlan is Vlan model
if vlan.id not in networks:
networks[vlan.id] = []
- net_host = {"hostname": host.name, "tagged": vlan.tagged, "interface":i}
+ net_host = {"hostname": host.name, "tagged": vlan.tagged, "interface": i}
networks[vlan.id].append(net_host)
- #creates networking object of proper form
+ # creates networking object of proper form
networking = []
for vlanid in networks:
network = {}
@@ -47,7 +56,7 @@ class BookingField(serializers.Field):
ser['networking'] = networking
- #creates hosts object of correct form
+ # creates hosts object of correct form
hosts = []
for hostname in host_configs:
host = {"hostname": hostname}
@@ -75,32 +84,37 @@ class BookingField(serializers.Field):
"""
return None
+
class BookingSerializer(serializers.Serializer):
booking = BookingField()
-#Host Type stuff, for inventory
+# Host Type stuff, for inventory
class CPUSerializer(serializers.ModelSerializer):
class Meta:
model = CpuProfile
fields = ('cores', 'architecture', 'cpus')
+
class DiskSerializer(serializers.ModelSerializer):
class Meta:
model = DiskProfile
fields = ('size', 'media_type', 'name')
+
class InterfaceProfileSerializer(serializers.ModelSerializer):
class Meta:
model = InterfaceProfile
fields = ('speed', 'name')
+
class RamSerializer(serializers.ModelSerializer):
class Meta:
model = RamProfile
fields = ('amount', 'channels')
+
class HostTypeSerializer(serializers.Serializer):
name = serializers.CharField(max_length=200)
ram = RamSerializer()
@@ -109,20 +123,24 @@ class HostTypeSerializer(serializers.Serializer):
disks = DiskSerializer()
cpu = CPUSerializer()
-#the rest of the inventory stuff
+
+# the rest of the inventory stuff
class NetworkSerializer(serializers.Serializer):
cidr = serializers.CharField(max_length=200)
gateway = serializers.IPAddressField(max_length=200)
vlan = serializers.IntegerField()
+
class ImageSerializer(serializers.ModelSerializer):
lab_id = serializers.IntegerField()
id = serializers.IntegerField(source="dashboard_id")
name = serializers.CharField(max_length=50)
description = serializers.CharField(max_length=200)
+
class Meta:
model = Image
+
class InterfaceField(serializers.Field):
def to_representation(self, interface):
pass
@@ -143,6 +161,7 @@ class InterfaceField(serializers.Field):
port_name=port_name
)
+
class InventoryHostSerializer(serializers.Serializer):
hostname = serializers.CharField(max_length=100)
host_type = serializers.CharField(max_length=100)