aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/serializers
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
commitb7c4d286ffa618be0e95b15f3883e2f6920a3fb1 (patch)
tree930e9b9282b8f50e671844b2a1e7f39dc5d6035d /src/api/serializers
parent6a90796de1df8d74c79415c39c867ffe6cd80fd0 (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 'src/api/serializers')
-rw-r--r--src/api/serializers/booking_serializer.py37
1 files changed, 28 insertions, 9 deletions
diff --git a/src/api/serializers/booking_serializer.py b/src/api/serializers/booking_serializer.py
index e891de4..9b5c059 100644
--- a/src/api/serializers/booking_serializer.py
+++ b/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)