add networkPorts
diff --git a/planetstack/core/xoslib/methods/sliceplus.py b/planetstack/core/xoslib/methods/sliceplus.py
index 48102df..0e0a940 100644
--- a/planetstack/core/xoslib/methods/sliceplus.py
+++ b/planetstack/core/xoslib/methods/sliceplus.py
@@ -15,11 +15,19 @@
# rest_framework 2.x
IdField = serializers.Field
+class NetworkPortsField(serializers.WritableField): # note: maybe just Field in rest_framework 3.x instead of WritableField
+ def to_representation(self, obj):
+ return obj
+
+ def to_internal_value(self, data):
+ return data
+
class SlicePlusIdSerializer(serializers.ModelSerializer, PlusSerializerMixin):
id = IdField()
sliceInfo = serializers.SerializerMethodField("getSliceInfo")
humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
+ networkPorts = NetworkPortsField()
def getSliceInfo(self, slice):
return slice.getSliceInfo(user=self.context['request'].user)
@@ -27,12 +35,12 @@
def getHumanReadableName(self, obj):
return str(obj)
- networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
- availableNetworks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
+ networks = serializers.PrimaryKeyRelatedField(many=True, read_only=True)
+# availableNetworks = serializers.PrimaryKeyRelatedField(many=True, read_only=True, view_name='network-detail')
class Meta:
model = SlicePlus
- fields = ('humanReadableName', 'id','created','updated','enacted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','image_preference','service','network','mount_data_sets','serviceClass','creator','networks','availableNetworks','sliceInfo','backendIcon','backendHtml')
+ fields = ('humanReadableName', 'id','created','updated','enacted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','image_preference','service','network','mount_data_sets','serviceClass','creator','networks','sliceInfo','networkPorts','backendIcon','backendHtml')
class SlicePlusList(generics.ListCreateAPIView):
queryset = SlicePlus.objects.select_related().all()
diff --git a/planetstack/core/xoslib/objects/sliceplus.py b/planetstack/core/xoslib/objects/sliceplus.py
index ddec295..f4a5e0a 100644
--- a/planetstack/core/xoslib/objects/sliceplus.py
+++ b/planetstack/core/xoslib/objects/sliceplus.py
@@ -26,6 +26,23 @@
"siteCount": len(used_sites.keys()),
"roles": roles}
+ @property
+ def networkPorts(self):
+ # XXX this assumes there is only one network that can have ports bound
+ # to it for a given slice. This is intended for the tenant view, which
+ # will obey this field.
+ networkPorts = ""
+ for networkSlice in self.networkslices.all():
+ network = networkSlice.network
+ if network.ports:
+ networkPorts = network.ports
+
+ return networkPorts
+
+ @networkPorts.setter
+ def networkPorts(self, value):
+ print "XXX set networkPorts to", value
+
@staticmethod
def select_by_user(user):
if user.is_admin: