Support for ELAN, ETREE, and VNoD Global Service
Change-Id: Iea1ee5b5b9224404a16bc9b88bc082719f75d10f
diff --git a/xos/admin.py b/xos/admin.py
index 6aae88b..9f5a2b0 100644
--- a/xos/admin.py
+++ b/xos/admin.py
@@ -47,29 +47,65 @@
class NetworkEdgeToEdgePointConnectionAdmin(XOSBaseAdmin):
verbose_name = "Metro Network E-Line Service"
verbose_name_plural = "Metro Network E-Line Services"
- list_display = ('id', 'sid', 'type', 'uni1', 'uni2', 'adminstate', 'operstate')
- list_display_links = ('id', 'sid', 'type', 'uni1', 'uni2', 'adminstate', 'operstate')
+ list_display = ('id', 'name', 'sid', 'type', 'vlanid', 'uni1', 'uni2', 'adminstate', 'operstate')
+ list_display_links = ('id', 'name', 'sid', 'type', 'vlanid', 'uni1', 'uni2', 'adminstate', 'operstate')
- fields = ('id', 'sid', 'type', 'uni1', 'uni2', 'adminstate', 'operstate', 'backend_status')
- readonly_fields = ('id', 'type', 'uni1', 'uni2', 'operstate', 'backend_status')
+ fields = ('id', 'name', 'sid', 'type', 'vlanid', 'uni1', 'uni2', 'adminstate', 'operstate', 'backend_status')
+ readonly_fields = ('id', 'sid', 'backend_status')
class NetworkMultipointToMultipointConnectionAdmin(XOSBaseAdmin):
verbose_name = "Metro Network E-LAN Service"
verbose_name_plural = "Metro Network E-LAN Services"
- list_display = ('id', 'sid', 'type', 'adminstate', 'operstate')
- list_display_links = ('id', 'sid', 'type', 'adminstate', 'operstate')
+ list_display = ('id', 'name', 'sid', 'type', 'vlanid', 'adminstate', 'operstate')
+ list_display_links = ('id', 'name', 'sid', 'type', 'vlanid', 'adminstate', 'operstate')
- fields = ('id', 'sid', 'type', 'eps', 'adminstate', 'operstate', 'backend_status')
- readonly_fields = ('id', 'sid', 'type', 'eps', 'adminstate', 'operstate', 'backend_status')
+ fields = ('id', 'name', 'sid', 'type', 'vlanid', 'eps', 'adminstate', 'operstate', 'backend_status')
+ readonly_fields = ('id', 'sid', 'backend_status')
class NetworkEdgeToMultipointConnectionAdmin(XOSBaseAdmin):
verbose_name = "Metro Network E-Tree Service"
verbose_name_plural = "Metro Network E-Tree Services"
- list_display = ('id', 'sid', 'type', 'adminstate', 'operstate')
- list_display_links = ('id', 'sid', 'type', 'adminstate', 'operstate')
+ list_display = ('id', 'name', 'sid', 'type', 'vlanid', 'adminstate', 'operstate')
+ list_display_links = ('id', 'name', 'sid', 'type', 'vlanid', 'adminstate', 'operstate')
- fields = ('id', 'sid', 'type', 'root', 'eps', 'adminstate', 'operstate', 'backend_status')
- readonly_fields = ('id', 'sid', 'type', 'root', 'eps', 'adminstate', 'operstate', 'backend_status')
+ fields = ('id', 'name', 'sid', 'type', 'vlanid', 'root', 'eps', 'adminstate', 'operstate', 'backend_status')
+ readonly_fields = ('id', 'sid', 'backend_status')
+
+class RemotePortAdmin(XOSBaseAdmin):
+ verbose_name = "Remote Port"
+ verbose_name_plural = "Remote Ports"
+ list_display = ('name', 'remoteportsite', 'edgeport')
+ list_display_links = ('name', 'remoteportsite', 'edgeport')
+
+ fields = ('name', 'remoteportsite', 'edgeport')
+
+class BandwidthProfileAdmin(XOSBaseAdmin):
+ verbose_name = "Bandwidth Profile"
+ verbose_name_plural = "Bandwidth Profiles"
+ list_display = ('bwpcfgcbs', 'bwpcfgebs', 'bwpcfgcir', 'bwpcfgeir', 'name')
+ list_display_links = ('bwpcfgcbs', 'bwpcfgebs', 'bwpcfgcir', 'bwpcfgeir', 'name')
+
+ fields = ('bwpcfgcbs', 'bwpcfgebs', 'bwpcfgcir', 'bwpcfgeir', 'name')
+
+class ServiceSpokeAdmin(XOSBaseAdmin):
+ verbose_name = "Service Spoke"
+ verbose_name_plural = "Service Spokes"
+ list_display = ('name','vnodlocalsite', 'remotesubscriber', 'adminstate', 'operstate', 'autoattached')
+ list_display_links = ('name','vnodlocalsite', 'remotesubscriber', 'adminstate', 'operstate', 'autoattached')
+
+ fields = ('name', 'id','vnodlocalsite', 'vnodlocalport', 'remotesubscriber', 'adminstate', 'operstate', 'backend_status', 'autoattached')
+ readonly_fields = ('id', 'remotesubscriber', 'adminstate', 'operstate', 'backend_status')
+
+class VnodGlobalServiceAdmin(XOSBaseAdmin):
+ verbose_name = "VNOD Global Service"
+ verbose_name_plural = "VNOD Global Services"
+ list_display = ('servicehandle', 'vlanid', 'type','operstate', 'adminstate')
+ list_display_links = ('servicehandle', 'vlanid', 'type','operstate', 'adminstate')
+
+ fields = (
+ 'id', 'servicehandle', 'vlanid', 'type', 'metronetworkmultipoint', 'metronetworkpointtopoint', 'metronetworkroottomultipoint', 'operstate', 'adminstate', 'spokes', 'bandwidthProfile')
+ readonly_fields = (
+ 'id', 'operstate', 'backend_status', 'metronetworkmultipoint', 'metronetworkpointtopoint', 'metronetworkroottomultipoint')
admin.site.register(MetroNetworkSystem, MetroNetworkSystemAdmin)
admin.site.register(NetworkDevice, NetworkDeviceAdmin)
@@ -77,3 +113,11 @@
admin.site.register(NetworkEdgeToEdgePointConnection, NetworkEdgeToEdgePointConnectionAdmin)
admin.site.register(NetworkMultipointToMultipointConnection, NetworkMultipointToMultipointConnectionAdmin)
admin.site.register(NetworkEdgeToMultipointConnection, NetworkEdgeToMultipointConnectionAdmin)
+admin.site.register(BandwidthProfile, BandwidthProfileAdmin)
+admin.site.register(ServiceSpoke, ServiceSpokeAdmin)
+admin.site.register(VnodGlobalService, VnodGlobalServiceAdmin)
+admin.site.register(RemotePort, RemotePortAdmin)
+
+
+
+
diff --git a/xos/api/service/metronetworkservice/metronetworkservice.py b/xos/api/service/metronetworkservice/metronetworkservice.py
index 8e200ce..764205d 100644
--- a/xos/api/service/metronetworkservice/metronetworkservice.py
+++ b/xos/api/service/metronetworkservice/metronetworkservice.py
@@ -1,7 +1,11 @@
+from django.http import HttpResponseBadRequest
from rest_framework.response import Response
+from rest_framework.views import APIView
from rest_framework import serializers, filters, status
from api.xosapi_helpers import PlusModelSerializer, XOSViewSet, ReadOnlyField
from services.metronetwork.models import *
+from random import randint
+import json
from django.core.exceptions import ObjectDoesNotExist
from django.core import serializers as jsonserializer
@@ -18,7 +22,7 @@
'operationalState')
def getHumanReadableName(self, obj):
- return obj.__unicode__()
+ return obj.name
class MetroNetworkSystemViewSet(XOSViewSet):
base_name = "metronetworksystem"
@@ -143,7 +147,8 @@
ELineConnection.sid = validated_data.data.get('sid')
ELineConnection.adminstate = validated_data.data.get('adminstate')
ELineConnection.operstate = validated_data.data.get('operstate')
- ELineConnection.type = validated_data.data.get('type')
+ ELineConnection.sid = validated_data.data.get('sid')
+ ELineConnection.type = 'Point_To_Point'
uni1 = validated_data.data.get('uni1')
uni2 = validated_data.data.get('uni2')
@@ -244,7 +249,8 @@
ETreeConnection.sid = validated_data.data.get('sid')
ETreeConnection.adminstate = validated_data.data.get('adminstate')
ETreeConnection.operstate = validated_data.data.get('operstate')
- ETreeConnection.type = validated_data.data.get('type')
+ ETreeConnection.sid = validated_data.data.get('sid')
+ ETreeConnection.type = 'Root_Multipoint'
root_id = validated_data.data.get('root')
eps_list = validated_data.data.get('eps')
@@ -349,7 +355,8 @@
ELanConnection.sid = validated_data.data.get('sid')
ELanConnection.adminstate = validated_data.data.get('adminstate')
ELanConnection.operstate = validated_data.data.get('operstate')
- ELanConnection.type = validated_data.data.get('type')
+ ELanConnection.sid = validated_data.data.get('sid')
+ ELanConnection.type = 'Multipoint_To_Multipoint'
eps_list = validated_data.data.get('eps')
ELanConnection.save()
@@ -381,3 +388,455 @@
response_data['eps'] = eps_data
return Response(response_data)
+
+############################
+
+class BandwidthProfileSerializer(PlusModelSerializer):
+ humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
+
+ class Meta:
+ model = BandwidthProfile
+
+ fields = ('humanReadableName',
+ 'id',
+ 'bwpcfgcbs',
+ 'bwpcfgebs',
+ 'bwpcfgcir',
+ 'bwpcfgeir',
+ 'name'
+ )
+
+ def getHumanReadableName(self, obj):
+ return obj.name
+
+class BandwidthProfileViewSet(XOSViewSet):
+ base_name = "BANDWIDTH_PROFILE"
+ method_name = "BANDWIDTH_PROFILE"
+ method_kind = "viewset"
+ queryset = BandwidthProfile.objects.all()
+ serializer_class = BandwidthProfileSerializer
+
+ @classmethod
+ def get_urlpatterns(self, api_path="^"):
+ patterns = super(BandwidthProfileViewSet, self).get_urlpatterns(api_path=api_path)
+
+ return patterns
+
+ def list(self, request):
+
+ object_list = self.filter_queryset(self.get_queryset())
+
+ serializer = self.get_serializer(object_list, many=True)
+
+ return Response(serializer.data)
+
+ def create(self, validated_data):
+
+ bandwidthProfile = BandwidthProfile()
+ bandwidthProfile.name = validated_data.data.get('name')
+ bandwidthProfile.bwpcfgcbs = validated_data.data.get('bwpcfgcbs')
+ bandwidthProfile.bwpcfgebs = validated_data.data.get('bwpcfgebs')
+ bandwidthProfile.bwpcfgcir = validated_data.data.get('bwpcfgcir')
+ bandwidthProfile.bwpcfgeir = validated_data.data.get('bwpcfgeir')
+
+ bandwidthProfile.save()
+
+ response_data = {}
+ response_data['name'] = bandwidthProfile.name
+ response_data['bwpcfgcbs'] = bandwidthProfile.bwpcfgcbs
+ response_data['bwpcfgebs'] = bandwidthProfile.bwpcfgebs
+ response_data['bwpcfgcir'] = bandwidthProfile.bwpcfgeir
+ response_data['bwpcfgcir'] = bandwidthProfile.bwpcfgcir
+ response_data['id'] = bandwidthProfile.id
+
+ return Response(response_data)
+
+class VnodSiteSerializer(PlusModelSerializer):
+ humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
+
+ class Meta:
+ model = Site
+
+ fields = ('humanReadableName',
+ 'site_url',
+ 'enabled',
+ 'longitude',
+ 'latitude',
+ 'name'
+ )
+
+ def getHumanReadableName(self, obj):
+ return obj.name
+
+class RemotePortSerializer(PlusModelSerializer):
+ humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
+ edgeport = NetworkEdgePortSerializer(read_only=True)
+ remoteportsite = VnodSiteSerializer(read_only=True)
+
+ class Meta:
+ model = RemotePort
+
+ fields = ('humanReadableName',
+ 'name',
+ 'edgeport',
+ 'id',
+ 'remoteportsite'
+ )
+
+ def getHumanReadableName(self, obj):
+ return obj.name
+
+class ServiceSpokeSerializer(PlusModelSerializer):
+ humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
+ vnodlocalsite = VnodSiteSerializer(read_only=True)
+ vnodlocalport = RemotePortSerializer(read_only=True)
+
+ class Meta:
+ model = ServiceSpoke
+
+ fields = ('humanReadableName',
+ 'id',
+ 'name',
+ 'remotesubscriber',
+ 'remotevnodid',
+ 'autoattached',
+ 'operstate',
+ 'vnodlocalsite',
+ 'vnodlocalport'
+ )
+
+ def getHumanReadableName(self, obj):
+ return obj.name
+
+class VnodGlobalServiceSerializer(PlusModelSerializer):
+ humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
+ metronetworkroottomultipoint = NetworkEdgeToMultipointConnectionSerializer(read_only=True)
+ metronetworkmultipoint = NetworkMultipointToMultipointConnectionSerializer(read_only=True)
+ metronetworkpointtopoint = NetworkEdgeToEdgePointConnectionSerializer(read_only=True)
+ spokes = ServiceSpokeSerializer(read_only=True, many=True)
+ bandwidthProfile = BandwidthProfileSerializer(read_only=True)
+
+ class Meta:
+ model = VnodGlobalService
+
+ fields = ('humanReadableName',
+ 'servicehandle',
+ 'vlanid',
+ 'id',
+ 'type',
+ 'operstate',
+ 'adminstate',
+ 'metronetworkroottomultipoint',
+ 'metronetworkmultipoint',
+ 'metronetworkpointtopoint',
+ 'spokes',
+ 'bandwidthProfile',
+ 'name'
+ )
+
+ def getHumanReadableName(self, obj):
+ return obj.name
+
+class VnodGlobalServiceViewSet(XOSViewSet):
+ base_name = "VNOD_GLOBAL_SERVICE"
+ method_name = "VNOD_GLOBAL_SERVICE"
+ method_kind = "viewset"
+ queryset = VnodGlobalService.get_service_objects().all()
+ serializer_class = VnodGlobalServiceSerializer
+
+ @classmethod
+ def get_urlpatterns(self, api_path="^"):
+ patterns = super(VnodGlobalServiceViewSet, self).get_urlpatterns(api_path=api_path)
+
+ return patterns
+
+ def list(self, request):
+
+ object_list = self.filter_queryset(self.get_queryset())
+
+ serializer = self.get_serializer(object_list, many=True)
+
+ return Response(serializer.data)
+
+ def destroy(self, request, pk=None):
+ VnodGlobalServiceToDelete = VnodGlobalService.objects.get(pk=pk)
+
+ if (VnodGlobalServiceToDelete):
+ VnodGlobalServiceToDelete.adminstate = 'deactivationrequested'
+ VnodGlobalServiceToDelete.save()
+ else:
+ return Response(status=status.HTTP_400_BAD_REQUEST)
+
+ return Response(status=status.HTTP_200_OK)
+
+ def create(self, validated_data):
+
+ vnodGlobalService = VnodGlobalService()
+
+ vnodGlobalService.name = validated_data.data.get('name')
+
+ if VnodGlobalService.objects.filter(
+ name=vnodGlobalService.name).exists():
+ return HttpResponseBadRequest('Error: VnodGlobalService name \'' + vnodGlobalService.name
+ + '\' already exists.')
+
+ vnodGlobalService.servicehandle = validated_data.data.get('servicehandle')
+ vnodGlobalService.adminstate = 'enabled'
+ vnodGlobalService.operstate = 'inactive'
+ vnodGlobalService.type = validated_data.data.get('type')
+
+ vnodGlobalService.vlanid = self.getUniqueVlandId()
+
+ bandwidth_profile = validated_data.data.get('bandwidthProfile')
+ bandwidthprofile = BandwidthProfile.objects.get(pk=bandwidth_profile['id'])
+ if (bandwidth_profile):
+ vnodGlobalService.bandwidthProfile = bandwidthprofile
+
+ vnodGlobalService.save()
+
+ spokes_list = validated_data.data.get('spokes')
+ if (spokes_list is None):
+ vnodGlobalService.delete()
+ return HttpResponseBadRequest('Error: No spokes found in request.')
+
+ for spoke in spokes_list:
+ vnodlocalsite = Site.objects.get(pk=spoke['vnodlocalsite']['id'])
+ servicespoke = ServiceSpoke()
+ servicespoke.vnodlocalsite = vnodlocalsite
+ servicespoke.vnodlocalport = self.getRandomRemotePort(vnodlocalsite)
+ servicespoke.name = spoke['name']
+ if (spoke.get('autoattached')):
+ servicespoke.autoattached = spoke['autoattached']
+ servicespoke.operstate = 'inactive'
+ servicespoke.adminstate = 'disabled'
+ servicespoke.save()
+ vnodGlobalService.spokes.add(servicespoke)
+
+ serializer = self.get_serializer(vnodGlobalService)
+ return Response(serializer.data)
+
+ def getUniqueVlandId(self):
+ unique = False
+ while not unique:
+ vlanid = randint(1, 4095)
+ vnodglobalservice = VnodGlobalService.get_service_objects().filter(vlanid=vlanid)
+ if (not vnodglobalservice):
+ unique = True
+ return vlanid
+
+ def getRandomRemotePort(self, site):
+ remotePort = RemotePort.objects.get(remoteportsite__name=site.name)
+ if (remotePort):
+ return remotePort
+ return None
+
+ @classmethod
+ def calculateVnodGlobalOperState(self, servicehandle):
+ vnodglobalservice = VnodGlobalService.get_service_objects().filter(servicehandle=servicehandle)
+ if (not vnodglobalservice):
+ HttpResponseBadRequest('Error: Could not find VnodGlobalObject with servicehandle=' + servicehandle)
+
+ vnodglobalservice = vnodglobalservice[0]
+ all_spokes_active_and_enabled = True
+
+ for spoke in vnodglobalservice.spokes.all():
+ if (spoke.operstate != 'active' or spoke.adminstate != 'enabled'):
+ all_spokes_active_and_enabled = False
+ break;
+
+ if (all_spokes_active_and_enabled):
+ vnodglobalservice.operstate = 'active'
+ else:
+ vnodglobalservice.operstate = 'inactive'
+
+ vnodglobalservice.save()
+ return all_spokes_active_and_enabled
+
+ @classmethod
+ def createService(self, servicehandle):
+ vnodglobalservice = VnodGlobalService.get_service_objects().filter(servicehandle=servicehandle)
+ if (not vnodglobalservice):
+ HttpResponseBadRequest('Error: Could not find VnodGlobalObject with servicehandle=' + servicehandle)
+
+ vnodglobalservice = vnodglobalservice[0]
+ if (vnodglobalservice.type == 'eline'):
+
+ spokes = vnodglobalservice.spokes.all()
+ uni1 = spokes[0].vnodlocalport.edgeport
+ uni2 = spokes[1].vnodlocalport.edgeport
+ name = 'ELine-' + str(vnodglobalservice.id)
+ type = 'Point_To_Point'
+ operstate = 'active'
+ adminstate = 'activationrequested'
+
+ eline = NetworkEdgeToEdgePointConnection()
+ eline.name = name
+ eline.type = type
+ eline.operstate = operstate
+ eline.adminstate = adminstate
+ eline.vlanid = vnodglobalservice.vlanid
+ eline.sid = name
+ eline.uni1 = NetworkEdgePort.objects.get(pid=uni1.pid)
+ eline.uni2 = NetworkEdgePort.objects.get(pid=uni2.pid)
+
+ eline.save()
+ vnodglobalservice.metronetworkpointtopoint = eline
+ vnodglobalservice.save()
+
+ elif (vnodglobalservice.type == 'elan'):
+
+ spokes = vnodglobalservice.spokes.all()
+
+ name = 'ELAN-' + str(vnodglobalservice.id)
+ type = 'Multipoint_To_Multipoint'
+ operstate = 'active'
+ adminstate = 'activationrequested'
+
+ elan = NetworkMultipointToMultipointConnection()
+ elan.name = name
+ elan.type = type
+ elan.operstate = 'inactive'
+ elan.adminstate = 'disabled'
+ elan.vlanid = vnodglobalservice.vlanid
+ elan.save()
+
+ for spoke in spokes:
+ uni = NetworkEdgePort.objects.get(pid=spoke.vnodlocalport.edgeport.pid)
+ elan.eps.add(uni)
+
+ elan.operstate = operstate
+ elan.adminstate = adminstate
+ elan.save()
+
+ vnodglobalservice.metronetworkmultipoint = elan
+ vnodglobalservice.save()
+
+ # TODO: elif (vnodglobalservice.type == 'etree'):
+
+class VnodGlobalServiceAutoAttachmentView(APIView):
+ method_kind = "list"
+ method_name = "vnodglobal_api_autoattach"
+
+ def get(self, request, format=None):
+ params = request.query_params
+ sitename = params.get('sitename')
+
+ if ( sitename is None):
+ HttpResponseBadRequest("Error: Request requires] 'sitename' as a query param.")
+
+ vnodglobalservices = VnodGlobalService.get_service_objects().filter(spokes__autoattached=True,
+ spokes__operstate='inactive',
+ spokes__vnodlocalsite__name=sitename)
+
+ if (not vnodglobalservices):
+ HttpResponseBadRequest({"handles" : []})
+
+ handles = []
+ for vnodglobalservice in vnodglobalservices:
+ if (vnodglobalservice.adminstate != 'disabled'):
+ handles.append(vnodglobalservice.servicehandle)
+
+ response_data = {'servicehandles' : handles}
+ return Response(response_data)
+
+class VnodGlobalServiceConfigurationView(APIView):
+ method_kind = "list"
+ method_name = "vnodglobal_api_configuration"
+
+ def get(self, request, format=None):
+ params = request.query_params
+ servicehandle = params.get('servicehandle')
+ sitename = params.get('sitename')
+
+ if (servicehandle is None or sitename is None):
+ HttpResponseBadRequest("Error: Request requires 'servicehandle' and 'sitename' as query params.")
+
+ vnodglobalservice = VnodGlobalService.get_service_objects().filter(servicehandle=servicehandle)
+ if (not vnodglobalservice):
+ HttpResponseBadRequest('Error: Could not find VnodGlobalObject with servicehandle=' + servicehandle)
+
+ vnodglobalservice = vnodglobalservice[0]
+ response_data = {}
+ response_data['vlanid'] = vnodglobalservice.vlanid
+
+ for spoke in vnodglobalservice.spokes.all():
+ if (spoke.vnodlocalsite.name == sitename and spoke.adminstate != 'configured'):
+ response_data['port'] = {}
+ response_data['port']['name'] = spoke.vnodlocalport.name
+ break;
+
+ return Response(response_data)
+
+class VnodGlobalServiceActivationView(APIView):
+ method_kind = "list"
+ method_name = "vnodglobal_api_activation"
+
+ def post(self, request, format=None):
+ body_json = request.body
+ body = json.loads(body_json)
+
+ servicehandle=body['servicehandle']
+ sitename=body['sitename']
+ activate = body['activate']
+ vnodlocalid = body['vnodlocalid']
+ portid = body.get('portid')
+
+ if (activate == 'true' or activate == 'True'):
+ isActivate = True
+ else:
+ isActivate = False
+
+ vnodglobalservice = VnodGlobalService.get_service_objects().filter(servicehandle=servicehandle)
+ if (not vnodglobalservice):
+ HttpResponseBadRequest('Error: Could not find VnodGlobalObject with servicehandle=' + servicehandle)
+
+ vnodglobalservice = vnodglobalservice[0]
+
+ for spoke in vnodglobalservice.spokes.all():
+ if (spoke.vnodlocalsite.name == sitename and spoke.vnodlocalport.name == portid):
+ spoke_id = spoke.id
+ servicespoke = ServiceSpoke.objects.get(id=spoke_id)
+ servicespoke.remotevnodid = vnodlocalid
+ servicespoke.save()
+ break;
+
+ return Response()
+
+class VnodGlobalServiceAdminOperationalStateView(APIView):
+ method_kind = "list"
+ method_name = "vnodglobal_api_status"
+
+ def post(self, request, format=None):
+ body_json = request.body
+ body = json.loads(body_json)
+
+ servicehandle = body['servicehandle']
+ sitename = body['sitename']
+ operstate = body.get('operstate')
+ adminstate = body.get('adminstate')
+ portid = body.get('portid')
+
+ vnodglobalservice = VnodGlobalService.get_service_objects().filter(servicehandle=servicehandle)
+ if (not vnodglobalservice):
+ HttpResponseBadRequest('Error: Could not find VnodGlobalObject with servicehandle=' + servicehandle)
+
+ vnodglobalservice = vnodglobalservice[0]
+
+ for spoke in vnodglobalservice.spokes.all():
+ if (spoke.vnodlocalsite.name == sitename and spoke.vnodlocalport.name == portid):
+ spoke_id = spoke.id
+ servicespoke = ServiceSpoke.objects.get(id=spoke_id)
+ if (operstate):
+ servicespoke.operstate = operstate
+ if (adminstate):
+ servicespoke.adminstate = adminstate
+ servicespoke.save()
+ break;
+
+ isGlobalActive = VnodGlobalServiceViewSet.calculateVnodGlobalOperState(servicehandle=servicehandle)
+
+ if (vnodglobalservice.metronetworkmultipoint is None and vnodglobalservice.metronetworkpointtopoint is None and
+ vnodglobalservice.metronetworkroottomultipoint is None and isGlobalActive):
+ VnodGlobalServiceViewSet.createService(servicehandle=servicehandle)
+
+ return Response()
diff --git a/xos/models.py b/xos/models.py
index bb069a5..4ebda3b 100644
--- a/xos/models.py
+++ b/xos/models.py
@@ -3,6 +3,7 @@
from django.db import models
from core.models import Service
from core.models import PlCoreBase
+from core.models import Site
METRONETWORK_KIND = "metronetwork"
SERVICE_NAME = 'metronetwork'
@@ -133,6 +134,9 @@
def __init__(self, *args, **kwargs):
super(NetworkEdgePort, self).__init__(*args, **kwargs)
+ def __unicode__(self):
+ return u'%s' % (self.pid)
+
def save(self, *args, **kwargs):
if self.latlng:
@@ -180,8 +184,9 @@
('deactivationrequested', 'DeactivationRequested')
)
- sid = models.CharField(unique=True, verbose_name="Service ID", max_length=256, editable=True)
+ sid = models.CharField(verbose_name="Service ID", max_length=256, editable=True, blank=True)
type = models.CharField(choices=TYPE, verbose_name="Type", max_length=256, editable=True)
+ vlanid = models.CharField(verbose_name="Vlanid", max_length=64, editable=True)
uni1 = models.ForeignKey(NetworkEdgePort,
related_name='EdgePointToEdgePointSrc',
verbose_name="UNI 1",
@@ -212,6 +217,7 @@
('vlan', 'VLAN'),
('ip', 'IP'),
('ethernet', 'Ethernet'),
+ ('Root_Multipoint', 'Root Multipoint')
)
OPERATIONALSTATE = (
@@ -227,8 +233,9 @@
('deactivationrequested', 'DeactivationRequested')
)
- sid = models.CharField(unique=True, verbose_name="Service ID", max_length=256, editable=True)
- type = models.CharField(choices=TYPE, verbose_name="Type", max_length=256, editable=False)
+ sid = models.CharField(verbose_name="Service ID", max_length=256, editable=True, blank=True)
+ type = models.CharField(choices=TYPE, verbose_name="Type", max_length=256, editable=True)
+ vlanid = models.CharField(verbose_name="Vlanid", max_length=64, editable=True)
root = models.ForeignKey(NetworkEdgePort,
related_name='EdgeToMultipointRoot',
verbose_name="Root",
@@ -237,7 +244,7 @@
eps = models.ManyToManyField(NetworkEdgePort,
related_name='%(class)s_eps',
verbose_name="Endpoints",
- editable=False)
+ editable=True)
operstate = models.CharField(choices=OPERATIONALSTATE, verbose_name="OperationalState", max_length=256,
editable=True)
adminstate = models.CharField(choices=ADMINISTRATIVESTATE, verbose_name="AdministrativeState", max_length=256,
@@ -260,6 +267,7 @@
('vlan', 'VLAN'),
('ip', 'IP'),
('ethernet', 'Ethernet'),
+ ('Multipoint_To_Multipoint', 'Multipoint To Multipoint')
)
OPERATIONALSTATE = (
@@ -275,12 +283,13 @@
('deactivationrequested', 'DeactivationRequested')
)
- sid = models.CharField(unique=True, verbose_name="Service ID", max_length=256, editable=True)
- type = models.CharField(choices=TYPE, verbose_name="Type", max_length=256, editable=False)
+ sid = models.CharField(verbose_name="Service ID", max_length=256, editable=True, blank=True)
+ type = models.CharField(choices=TYPE, verbose_name="Type", max_length=256, editable=True)
+ vlanid = models.CharField(verbose_name="Vlanid", max_length=64, editable=True)
eps = models.ManyToManyField(NetworkEdgePort,
related_name='%(class)s_eps',
verbose_name="Endpoints",
- editable=False)
+ editable=True)
operstate = models.CharField(choices=OPERATIONALSTATE, verbose_name="OperationalState", max_length=256,
editable=True)
@@ -293,3 +302,162 @@
def __init__(self, *args, **kwargs):
super(NetworkMultipointToMultipointConnection, self).__init__(*args, **kwargs)
+class BandwidthProfile(PlCoreBase):
+
+ class Meta:
+ app_label = METRONETWORK_KIND
+ verbose_name = "Bandwidth Profile"
+
+ id = models.AutoField(verbose_name="id", primary_key=True, editable=False)
+ bwpcfgcbs = models.IntegerField(verbose_name="Committed Burst Size", editable=True)
+ bwpcfgebs = models.IntegerField(verbose_name="Excess Burst Size", editable=True)
+ bwpcfgcir = models.IntegerField(verbose_name="Committed Information Rate", editable=True)
+ bwpcfgeir = models.IntegerField(verbose_name="Excess Information Rate", editable=True)
+ name = models.CharField(unique=True, verbose_name="Name", max_length=256, editable=True)
+
+ def __init__(self, *args, **kwargs):
+ super(BandwidthProfile, self).__init__(*args, **kwargs)
+
+ def __unicode__(self): return u'%s' % (self.name)
+
+# VNoD Global Objects - model is included in metro-net for simplicity
+
+class RemotePort(PlCoreBase):
+ class Meta:
+ app_label = METRONETWORK_KIND
+ verbose_name = "Remote Port"
+
+ remoteportsite = models.ForeignKey(Site,
+ related_name='RemotePortSite',
+ verbose_name="RemotePortSite",
+ editable=True,
+ on_delete=models.CASCADE)
+
+ edgeport = models.ForeignKey(NetworkEdgePort,
+ related_name='RemotePortEdgePort',
+ verbose_name="RemotePortEdgePort",
+ editable=True,
+ on_delete=models.CASCADE)
+
+ id = models.AutoField(verbose_name="id", primary_key=True, editable=False)
+ name = models.CharField(unique=True, verbose_name="Name", max_length=256, editable=True)
+
+ def __init__(self, *args, **kwargs):
+ super(RemotePort, self).__init__(*args, **kwargs)
+
+ def __unicode__(self): return u'%s' % (self.name)
+
+class ServiceSpoke(PlCoreBase):
+
+ class Meta:
+ app_label = METRONETWORK_KIND
+ verbose_name = "Service Spoke"
+
+ OPERATIONALSTATE = (
+ ('active', 'Active'),
+ ('inactive', 'Inactive')
+ )
+
+ ADMINISTRATIVE_STATE = (
+ ('disabled', 'Disabled'),
+ ('configured', 'Configured'),
+ ('impaired', 'Impaired'),
+ ('enabled', 'Enabled')
+ )
+
+ vnodlocalsite = models.ForeignKey(Site,
+ related_name='VnodLocalSite',
+ verbose_name="VnodLocalSite",
+ editable=True,
+ on_delete=models.CASCADE)
+
+ vnodlocalport = models.ForeignKey(RemotePort,
+ related_name='VnodLocalPort',
+ verbose_name="VnodLocalPort",
+ editable=True,
+ on_delete=models.CASCADE)
+
+ id = models.AutoField(verbose_name="id", primary_key=True, editable=False)
+ name = models.CharField(unique=True, verbose_name="Name", max_length=256, editable=True)
+ remotesubscriber = models.CharField(verbose_name="RemoteSubscriber", max_length=256, blank=True, editable=False)
+ remotevnodid = models.CharField(verbose_name="RemoteVnodId", max_length=256, blank=True, editable=False)
+ autoattached = models.BooleanField(verbose_name="Auto-Attached", default=False, editable=True)
+ operstate = models.CharField(choices=OPERATIONALSTATE, verbose_name="OperationalState", max_length=256,
+ editable=True, default='inactive')
+ adminstate = models.CharField(choices=ADMINISTRATIVE_STATE, default='disabled', verbose_name="AdministrativeState",
+ max_length=64, editable=True)
+
+ def __init__(self, *args, **kwargs):
+ super(ServiceSpoke, self).__init__(*args, **kwargs)
+
+ def __unicode__(self): return u'%s' % (self.name)
+
+class VnodGlobalService(Service):
+
+ class Meta:
+ app_label = SERVICE_NAME
+ verbose_name = "Virtual Network On Demand Global Service"
+
+ TYPE = (
+ ('eline', SERVICE_NAME_ELINE_VERBOSE),
+ ('elan', SERVICE_NAME_ELAN_VERBOSE),
+ ('etree', SERVICE_NAME_ETREE_VERBOSE),
+ )
+
+ OPERATIONALSTATE = (
+ ('active', 'Active'),
+ ('inactive', 'Inactive')
+ )
+
+ ADMINISTRATIVESTATE = (
+ ('disabled', 'Disabled'),
+ ('activationrequested', 'ActivationRequested'),
+ ('enabled', 'Enabled'),
+ ('invalid', 'Invalid'),
+ ('deactivationrequested', 'DeactivationRequested')
+ )
+
+ servicehandle = models.CharField(unique=True, verbose_name="Servicehandle", max_length=64, editable=True)
+ vlanid = models.CharField(verbose_name="Vlanid", max_length=64, editable=True)
+ type = models.CharField(choices=TYPE, verbose_name="Type", max_length=256, editable=True)
+
+ metronetworkroottomultipoint = models.ForeignKey(NetworkEdgeToMultipointConnection,
+ related_name='EtreeService',
+ verbose_name="EtreeService",
+ null=True,
+ editable=True,
+ on_delete=models.CASCADE)
+
+ metronetworkmultipoint = models.ForeignKey(NetworkMultipointToMultipointConnection,
+ related_name='ElanService',
+ verbose_name="ElanService",
+ null=True,
+ editable=True,
+ on_delete=models.CASCADE)
+
+ metronetworkpointtopoint = models.ForeignKey(NetworkEdgeToEdgePointConnection,
+ related_name='ElineService',
+ verbose_name="ElineService",
+ null=True,
+ editable=True,
+ on_delete=models.CASCADE)
+
+ operstate = models.CharField(choices=OPERATIONALSTATE, verbose_name="OperationalState", max_length=256,
+ editable=True)
+
+ adminstate = models.CharField(choices=ADMINISTRATIVESTATE, verbose_name="AdministrativeState", max_length=256,
+ editable=True, default='enabled')
+
+ spokes = models.ManyToManyField(ServiceSpoke,
+ related_name='ServiceSpokes',
+ verbose_name="Spokes",
+ editable=True)
+
+ bandwidthProfile = models.ForeignKey(BandwidthProfile,
+ related_name='BandwidthProfile',
+ verbose_name="BandwidthProfile",
+ editable=True,
+ on_delete=models.CASCADE)
+
+ def __init__(self, *args, **kwargs):
+ super(VnodGlobalService, self).__init__(*args, **kwargs)
diff --git a/xos/synchronizer/invokers/invokerfactory.py b/xos/synchronizer/invokers/invokerfactory.py
index 786f99d..b3628fe 100644
--- a/xos/synchronizer/invokers/invokerfactory.py
+++ b/xos/synchronizer/invokers/invokerfactory.py
@@ -2,6 +2,9 @@
from synchronizers.metronetwork.invokers.networkmultipointtomultipointinvoker import NetworkMultipointToMultipointInvoker
from synchronizers.metronetwork.invokers.networkedgetoedgepointinvoker import NetworkEdgeToEdgePointInvoker
from synchronizers.metronetwork.invokers.networkedgetomultipointinvoker import NetworkEdgeToMultipointInvoker
+from synchronizers.metronetwork.invokers.servicespokeinvoker import ServiceSpokeInvoker
+from synchronizers.metronetwork.invokers.vnodglobalserviceinvoker import VnodGlobalServiceInvoker
+from synchronizers.metronetwork.invokers.remoteportinvoker import RemotePortInvoker
class InvokerFactory(object):
@@ -16,5 +19,11 @@
return NetworkEdgeToEdgePointInvoker()
elif isinstance(obj, NetworkEdgeToMultipointConnection):
return NetworkEdgeToMultipointInvoker()
+ elif isinstance(obj, ServiceSpoke):
+ return ServiceSpokeInvoker()
+ elif isinstance(obj, VnodGlobalService):
+ return VnodGlobalServiceInvoker()
+ elif isinstance(obj, RemotePort):
+ return RemotePortInvoker()
else:
return None
diff --git a/xos/synchronizer/invokers/networkedgetoedgepointinvoker.py b/xos/synchronizer/invokers/networkedgetoedgepointinvoker.py
index ebc4d12..2c30d79 100644
--- a/xos/synchronizer/invokers/networkedgetoedgepointinvoker.py
+++ b/xos/synchronizer/invokers/networkedgetoedgepointinvoker.py
@@ -17,10 +17,11 @@
def presave(self, obj):
# Now that the Ports are created - get a proper reference to them and update the
# src and dst fields
- uni1port = NetworkEdgePort.objects.get(pid=obj.uni1_createbuffer)
- uni2port = NetworkEdgePort.objects.get(pid=obj.uni2_createbuffer)
- obj.uni1 = uni1port
- obj.uni2 = uni2port
+ if hasattr(obj, 'uni1_createbuffer'):
+ uni1port = NetworkEdgePort.objects.get(pid=obj.uni1_createbuffer)
+ uni2port = NetworkEdgePort.objects.get(pid=obj.uni2_createbuffer)
+ obj.uni1 = uni1port
+ obj.uni2 = uni2port
# Method for handline post save semantics
# content here would be model specific but could include handling Many-to-Many relationship
diff --git a/xos/synchronizer/invokers/networkedgetomultipointinvoker.py b/xos/synchronizer/invokers/networkedgetomultipointinvoker.py
index a0b7ffd..9b8e88b 100644
--- a/xos/synchronizer/invokers/networkedgetomultipointinvoker.py
+++ b/xos/synchronizer/invokers/networkedgetomultipointinvoker.py
@@ -17,8 +17,9 @@
def presave(self, obj):
# Now that the Ports are created - get a proper reference to them and update the
# root field
- rootEdgePort = NetworkEdgePort.objects.get(pid=obj.root_createbuffer)
- obj.root = rootEdgePort
+ if hasattr(obj, 'root_createbuffer'):
+ rootEdgePort = NetworkEdgePort.objects.get(pid=obj.root_createbuffer)
+ obj.root = rootEdgePort
# Method for handline post save semantics
@@ -37,9 +38,10 @@
# called 'eps' that just containts a reference to a bunch of NetworkEdgePorts
#
#
- scratchpad = json.loads(obj.eps_createbuffer)
- eps = scratchpad['eps']
+ if hasattr(obj, 'eps_createbuffer'):
+ scratchpad = json.loads(obj.eps_createbuffer)
+ eps = scratchpad['eps']
- for ep in eps:
- port = NetworkEdgePort.objects.get(pid=ep)
- obj.eps.add(port)
+ for ep in eps:
+ port = NetworkEdgePort.objects.get(pid=ep)
+ obj.eps.add(port)
diff --git a/xos/synchronizer/invokers/networkmultipointtomultipointinvoker.py b/xos/synchronizer/invokers/networkmultipointtomultipointinvoker.py
index 78b617c..6b2ab42 100644
--- a/xos/synchronizer/invokers/networkmultipointtomultipointinvoker.py
+++ b/xos/synchronizer/invokers/networkmultipointtomultipointinvoker.py
@@ -34,9 +34,10 @@
# called 'eps' that just containts a reference to a bunch of NetworkEdgePorts
#
#
- scratchpad = json.loads(obj.eps_createbuffer)
- eps = scratchpad['eps']
+ if hasattr(obj, 'eps_createbuffer'):
+ scratchpad = json.loads(obj.eps_createbuffer)
+ eps = scratchpad['eps']
- for ep in eps:
- port = NetworkEdgePort.objects.get(pid=ep)
- obj.eps.add(port)
+ for ep in eps:
+ port = NetworkEdgePort.objects.get(pid=ep)
+ obj.eps.add(port)
diff --git a/xos/synchronizer/invokers/remoteportinvoker.py b/xos/synchronizer/invokers/remoteportinvoker.py
new file mode 100644
index 0000000..1061dc4
--- /dev/null
+++ b/xos/synchronizer/invokers/remoteportinvoker.py
@@ -0,0 +1,35 @@
+import json
+from synchronizers.metronetwork.invokers.invoker import Invoker
+from core.models import Site
+from services.metronetwork.models import NetworkEdgePort
+
+class RemotePortInvoker(Invoker):
+ def __init__(self, **args):
+ pass
+
+ # Method for handline pre save semantics
+ # content here would be model specific but could include handling Many-to-Many relationship
+ # creation - which must occur post save
+ #
+ # obj - Whatever obj was just saved
+ # returns - None - this is a pure invoke() call, return type is None
+ #
+ def presave(self, obj):
+ # Now that the Site and EdgePorts are created set the foreign keys
+ if hasattr(obj, 'sitename'):
+ site = Site.objects.get(login_base=obj.sitename)
+ obj.remoteportsite = site
+
+ if hasattr(obj, 'edgeportname'):
+ edgeport = NetworkEdgePort.objects.get(pid=obj.edgeportname)
+ obj.edgeport = edgeport
+
+ # Method for handline post save semantics
+ # content here would be model specific but could include handling Many-to-Many relationship
+ # creation - which must occur post save
+ #
+ # obj - Whatever obj was just saved
+ # returns - N/A - this is a pure invoke() call
+ #
+ def postsave(self, obj):
+ pass
\ No newline at end of file
diff --git a/xos/synchronizer/invokers/servicespokeinvoker.py b/xos/synchronizer/invokers/servicespokeinvoker.py
new file mode 100644
index 0000000..8470cf5
--- /dev/null
+++ b/xos/synchronizer/invokers/servicespokeinvoker.py
@@ -0,0 +1,37 @@
+import json
+from synchronizers.metronetwork.invokers.invoker import Invoker
+from core.models import Site
+from services.metronetwork.models import RemotePort
+
+
+class ServiceSpokeInvoker(Invoker):
+ def __init__(self, **args):
+ pass
+
+ # Method for handline pre save semantics
+ # content here would be model specific but could include handling Many-to-Many relationship
+ # creation - which must occur post save
+ #
+ # obj - Whatever obj was just saved
+ # returns - None - this is a pure invoke() call, return type is None
+ #
+ def presave(self, obj):
+ # Now that the Ports are created - get a proper reference to them and update the
+ # src and dst fields
+ if hasattr(obj, 'sitename'):
+ site = Site.objects.get(login_base=obj.sitename)
+ obj.vnodlocalsite = site
+
+ if hasattr(obj, 'remoteportname'):
+ remoteport = RemotePort.objects.get(name=obj.remoteportname)
+ obj.vnodlocalport = remoteport
+
+ # Method for handline post save semantics
+ # content here would be model specific but could include handling Many-to-Many relationship
+ # creation - which must occur post save
+ #
+ # obj - Whatever obj was just saved
+ # returns - N/A - this is a pure invoke() call
+ #
+ def postsave(self, obj):
+ pass
\ No newline at end of file
diff --git a/xos/synchronizer/invokers/vnodglobalserviceinvoker.py b/xos/synchronizer/invokers/vnodglobalserviceinvoker.py
new file mode 100644
index 0000000..a313171
--- /dev/null
+++ b/xos/synchronizer/invokers/vnodglobalserviceinvoker.py
@@ -0,0 +1,50 @@
+import json
+from synchronizers.metronetwork.invokers.invoker import Invoker
+from services.metronetwork.models import ServiceSpoke
+from services.metronetwork.models import BandwidthProfile
+from services.metronetwork.models import NetworkEdgeToEdgePointConnection
+
+class VnodGlobalServiceInvoker(Invoker):
+
+ def __init__(self, **args):
+ pass
+
+ # Method for handline pre save semantics
+ # content here would be model specific but could include handling Many-to-Many relationship
+ # creation - which must occur post save
+ #
+ # obj - Whatever obj was just saved
+ # returns - None - this is a pure invoke() call, return type is None
+ #
+ def presave(self, obj):
+
+ if hasattr(obj, 'bwpname'):
+ bwprofile = BandwidthProfile.objects.get(name=obj.bwpname)
+ obj.bandwidthProfile = bwprofile
+
+ if hasattr(obj, 'pointtopointsid'):
+ connection = NetworkEdgeToEdgePointConnection.objects.get(sid=obj.pointtopointsid)
+ obj.metronetworkpointtopoint = connection
+
+ # Method for handline post save semantics
+ # content here would be model specific but could include handling Many-to-Many relationship
+ # creation - which must occur post save
+ #
+ # obj - Whatever obj was just saved
+ # returns - N/A - this is a pure invoke() call
+ #
+ def postsave(self, obj):
+ #
+ # Ok - we need to handle the multipoint many-to-many relationships in here
+ #
+ # By design convnetion we will look for them in the 'backend_register' object field
+ # this is a json field that is general purpose - we will expect to find a JSON array
+ # called 'eps' that just containts a reference to a bunch of NetworkEdgePorts
+ #
+ if hasattr(obj, 'spokes_createbuffer'):
+ scratchpad = json.loads(obj.spokes_createbuffer)
+ spokes = scratchpad['spokes']
+
+ for spokeid in spokes:
+ spoke = ServiceSpoke.objects.get(name=spokeid)
+ obj.spokes.add(spoke)
diff --git a/xos/synchronizer/manifest b/xos/synchronizer/manifest
index 98cb0d9..03f1088 100644
--- a/xos/synchronizer/manifest
+++ b/xos/synchronizer/manifest
@@ -6,15 +6,18 @@
providers/providerfactory.py
providers/__init__.py
providers/metronetworkprovider.py
-invokers/invoker.py
-invokers/invokerfactory.py
-invokers/networkedgetoedgepointinvoker.py
-invokers/networkedgetomultipointinvoker.py
-invokers/networkmultipointtomultipointinvoker.py
-invokers/__init__.py
run_devel.sh
metronetwork-synchronizer-devel.py
manifest
steps/sync_metronetworkservice.py
+invokers/servicespokeinvoker.py
+invokers/networkedgetoedgepointinvoker.py
+invokers/vnodglobalserviceinvoker.py
+invokers/networkmultipointtomultipointinvoker.py
+invokers/__init__.py
+invokers/invoker.py
+invokers/networkedgetomultipointinvoker.py
+invokers/invokerfactory.py
+invokers/remoteportinvoker.py
run.sh
metronetwork_synchronizer_config
diff --git a/xos/synchronizer/providers/metronetworkrestprovider.py b/xos/synchronizer/providers/metronetworkrestprovider.py
index 1e00a90..2cb03ab 100644
--- a/xos/synchronizer/providers/metronetworkrestprovider.py
+++ b/xos/synchronizer/providers/metronetworkrestprovider.py
@@ -55,10 +55,171 @@
else:
raise Exception("OnosApiError: get_network_ports()")
+ def get_network_ports(self):
+
+ objs = []
+
+ restCtrlUrl = self.networkdevice.restCtrlUrl
+ username = self.networkdevice.username
+ password = self.networkdevice.password
+
+ resp = requests.get("{}/mef-sca-api/SCA_ETH_FPP_UNI_N".format(restCtrlUrl),
+ auth=HTTPBasicAuth(username, password))
+
+ if resp.status_code == 200:
+ for uni in resp.json():
+ hostname = uni['transportPort']['Hostname']
+ port = uni['transportPort']['Port']
+
+ # Default values
+ bwpCfgCbs = 0
+ bwpCfgEbs = 0
+ bwpCfgCir = 0
+ bwpCfgEir = 0
+
+ if 'interfaceCfgIngressBwp' in uni:
+ bwpCfgCbs = uni['interfaceCfgIngressBwp']['bwpCfgCbs']
+ bwpCfgEbs = uni['interfaceCfgIngressBwp']['bwpCfgEbs']
+ bwpCfgCir = uni['interfaceCfgIngressBwp']['bwpCfgCir']
+ bwpCfgEir = uni['interfaceCfgIngressBwp']['bwpCfgEir']
+
+ uniPort = NetworkEdgePort()
+ uniPort.element = self.networkdevice
+ uniPort.pid = "{}.{}/{}".format(self.networkdevice.id, hostname, port)
+ uniPort.bwpCfgCbs = bwpCfgCbs
+ uniPort.bwpCfgEbs = bwpCfgEbs
+ uniPort.bwpCfgCir = bwpCfgCir
+ uniPort.bwpCfgEir = bwpCfgEir
+
+ objs.append(uniPort)
+
+ return objs
+
+ else:
+ raise Exception("OnosApiError: get_network_ports()")
+
+ def get_network_eline_link(self, networkDevice, evc):
+
+ sid = evc['id']
+ uni1 = evc['SCA_ETH_Flow_Points'][0]
+ hostname = uni1['scaEthFppUniN']['transportPort']['Hostname']
+ port = uni1['scaEthFppUniN']['transportPort']['Port']
+
+ edgePort1 = NetworkEdgePort()
+ edgePort1.element = networkDevice
+ edgePort1.pid = "{}.{}/{}".format(networkDevice.id, hostname, port)
+
+ if 'interfaceCfgIngressBwp' in uni1['scaEthFppUniN']:
+ edgePort1.bwpCfgCbs = uni1['scaEthFppUniN']['interfaceCfgIngressBwp']['bwpCfgCbs']
+ edgePort1.bwpCfgEbs = uni1['scaEthFppUniN']['interfaceCfgIngressBwp']['bwpCfgEbs']
+ edgePort1.bwpCfgCir = uni1['scaEthFppUniN']['interfaceCfgIngressBwp']['bwpCfgCir']
+ edgePort1.bwpCfgEir = uni1['scaEthFppUniN']['interfaceCfgIngressBwp']['bwpCfgEir']
+
+ uni2 = evc['SCA_ETH_Flow_Points'][1]
+ hostname = uni2['scaEthFppUniN']['transportPort']['Hostname']
+ port = uni2['scaEthFppUniN']['transportPort']['Port']
+
+ edgePort2 = NetworkEdgePort()
+ edgePort2.element = networkDevice
+ edgePort2.pid = "{}.{}/{}".format(networkDevice.id, hostname, port)
+
+ if 'interfaceCfgIngressBwp' in uni1['scaEthFppUniN']:
+ edgePort2.bwpCfgCbs = uni2['scaEthFppUniN']['interfaceCfgIngressBwp']['bwpCfgCbs']
+ edgePort2.bwpCfgEbs = uni2['scaEthFppUniN']['interfaceCfgIngressBwp']['bwpCfgEbs']
+ edgePort2.bwpCfgCir = uni2['scaEthFppUniN']['interfaceCfgIngressBwp']['bwpCfgCir']
+ edgePort2.bwpCfgEir = uni2['scaEthFppUniN']['interfaceCfgIngressBwp']['bwpCfgEir']
+
+ edgeToEdgeConnectivity = NetworkEdgeToEdgePointConnection()
+ edgeToEdgeConnectivity.sid = sid
+ edgeToEdgeConnectivity.type = "Point_To_Point"
+ edgeToEdgeConnectivity.uni1 = edgePort1
+ edgeToEdgeConnectivity.uni2 = edgePort2
+ edgeToEdgeConnectivity.operstate = "active"
+ edgeToEdgeConnectivity.adminstate = "enabled"
+
+ return(edgeToEdgeConnectivity)
+
+ def get_network_elan_link(self, networkDevice, evc):
+
+ sid = evc['id']
+ eps = []
+
+ for ep in evc['SCA_ETH_Flow_Points']:
+ hostname = ep['scaEthFppUniN']['transportPort']['Hostname']
+ port = ep['scaEthFppUniN']['transportPort']['Port']
+
+ edgePort = NetworkEdgePort()
+ edgePort.element = networkDevice
+ edgePort.pid = "{}.{}/{}".format(networkDevice.id, hostname, port)
+
+ if 'interfaceCfgIngressBwp' in ep['scaEthFppUniN']:
+ edgePort.bwpCfgCbs = ep['scaEthFppUniN']['interfaceCfgIngressBwp']['bwpCfgCbs']
+ edgePort.bwpCfgEbs = ep['scaEthFppUniN']['interfaceCfgIngressBwp']['bwpCfgEbs']
+ edgePort.bwpCfgCir = ep['scaEthFppUniN']['interfaceCfgIngressBwp']['bwpCfgCir']
+ edgePort.bwpCfgEir = ep['scaEthFppUniN']['interfaceCfgIngressBwp']['bwpCfgEir']
+
+ eps.append(edgePort)
+
+ multipointToMultipointConnectivity = NetworkMultipointToMultipointConnection()
+ multipointToMultipointConnectivity.sid = sid
+ multipointToMultipointConnectivity.type = "Multipoint_To_Multipoint"
+ multipointToMultipointConnectivity.eps = eps
+ multipointToMultipointConnectivity.operstate = "active"
+ multipointToMultipointConnectivity.adminstate = "enabled"
+
+ return(multipointToMultipointConnectivity)
+
+ def get_network_etree_link(self, networkDevice, evc):
+
+ sid = evc['id']
+ eps = []
+
+ root = evc['SCA_ETH_Flow_Points'][0]
+ hostname = root['scaEthFppUniN']['transportPort']['Hostname']
+ port = root['scaEthFppUniN']['transportPort']['Port']
+
+ edgePort = NetworkEdgePort()
+ edgePort.element = networkDevice
+ edgePort.pid = "{}.{}/{}".format(networkDevice.id, hostname, port)
+
+ if 'interfaceCfgIngressBwp' in root['scaEthFppUniN']:
+ edgePort.bwpCfgCbs = root['scaEthFppUniN']['interfaceCfgIngressBwp']['bwpCfgCbs']
+ edgePort.bwpCfgEbs = root['scaEthFppUniN']['interfaceCfgIngressBwp']['bwpCfgEbs']
+ edgePort.bwpCfgCir = root['scaEthFppUniN']['interfaceCfgIngressBwp']['bwpCfgCir']
+ edgePort.bwpCfgEir = root['scaEthFppUniN']['interfaceCfgIngressBwp']['bwpCfgEir']
+
+ edgeToMultipointConnectivity = NetworkEdgeToMultipointConnection()
+ edgeToMultipointConnectivity.sid = sid
+ edgeToMultipointConnectivity.type = "Root_Multipoint"
+ edgeToMultipointConnectivity.root = edgePort
+
+ for ep in evc['SCA_ETH_Flow_Points'][1:]:
+ hostname = ep['scaEthFppUniN']['transportPort']['Hostname']
+ port = ep['scaEthFppUniN']['transportPort']['Port']
+
+ edgePort = NetworkEdgePort()
+ edgePort.element = networkDevice
+ edgePort.pid = "{}.{}/{}".format(networkDevice.id, hostname, port)
+
+ if 'interfaceCfgIngressBwp' in ep['scaEthFppUniN']:
+ edgePort.bwpCfgCbs = ep['scaEthFppUniN']['interfaceCfgIngressBwp']['bwpCfgCbs']
+ edgePort.bwpCfgEbs = ep['scaEthFppUniN']['interfaceCfgIngressBwp']['bwpCfgEbs']
+ edgePort.bwpCfgCir = ep['scaEthFppUniN']['interfaceCfgIngressBwp']['bwpCfgCir']
+ edgePort.bwpCfgEir = ep['scaEthFppUniN']['interfaceCfgIngressBwp']['bwpCfgEir']
+
+ eps.append(edgePort)
+
+ edgeToMultipointConnectivity.eps = eps
+ edgeToMultipointConnectivity.operstate = "active"
+ edgeToMultipointConnectivity.adminstate = "enabled"
+
+ return(edgeToMultipointConnectivity)
+
def get_network_links(self):
objs = []
+ networkDevice = self.networkdevice
restCtrlUrl = self.networkdevice.restCtrlUrl
username = self.networkdevice.username
password = self.networkdevice.password
@@ -68,69 +229,24 @@
if resp.status_code == 200:
for evc in resp.json():
- id = evc['id']
evcServiceType = evc['evcServiceType']
-
if (evcServiceType == "Point_To_Point"):
- uni1 = evc['SCA_ETH_Flow_Points'][0]
- hostname = uni1['scaEthFppUniN']['transportPort']['Hostname']
- port = uni1['scaEthFppUniN']['transportPort']['Port']
-
- if 'interfaceCfgIngressBwp' in uni1['scaEthFppUniN']:
- bwpCfgCbs = uni1['scaEthFppUniN']['interfaceCfgIngressBwp']['bwpCfgCbs']
- bwpCfgEbs = uni1['scaEthFppUniN']['interfaceCfgIngressBwp']['bwpCfgEbs']
- bwpCfgCir = uni1['scaEthFppUniN']['interfaceCfgIngressBwp']['bwpCfgCir']
- bwpCfgEir = uni1['scaEthFppUniN']['interfaceCfgIngressBwp']['bwpCfgEir']
-
- edgePort1 = NetworkEdgePort()
- edgePort1.element = self.networkdevice
- edgePort1.pid = "{}.{}/{}".format(self.networkdevice.id, hostname, port)
- edgePort1.bwpCfgCbs = bwpCfgCbs
- edgePort1.bwpCfgEbs = bwpCfgEbs
- edgePort1.bwpCfgCir = bwpCfgCir
- edgePort1.bwpCfgEir = bwpCfgEir
-
- uni2 = evc['SCA_ETH_Flow_Points'][1]
- hostname = uni2['scaEthFppUniN']['transportPort']['Hostname']
- port = uni2['scaEthFppUniN']['transportPort']['Port']
-
- if 'interfaceCfgIngressBwp' in uni1['scaEthFppUniN']:
- bwpCfgCbs = uni2['scaEthFppUniN']['interfaceCfgIngressBwp']['bwpCfgCbs']
- bwpCfgEbs = uni2['scaEthFppUniN']['interfaceCfgIngressBwp']['bwpCfgEbs']
- bwpCfgCir = uni2['scaEthFppUniN']['interfaceCfgIngressBwp']['bwpCfgCir']
- bwpCfgEir = uni2['scaEthFppUniN']['interfaceCfgIngressBwp']['bwpCfgEir']
-
- edgePort2 = NetworkEdgePort()
- edgePort2.element = self.networkdevice
- edgePort2.pid = "{}.{}/{}".format(self.networkdevice.id, hostname, port)
- edgePort2.bwpCfgCbs = bwpCfgCbs
- edgePort2.bwpCfgEbs = bwpCfgEbs
- edgePort2.bwpCfgCir = bwpCfgCir
- edgePort2.bwpCfgEir = bwpCfgEir
-
- edgeToEdgeConnectivity = NetworkEdgeToEdgePointConnection()
- edgeToEdgeConnectivity.sid = id
- edgeToEdgeConnectivity.type = evcServiceType
- edgeToEdgeConnectivity.uni1 = edgePort1
- edgeToEdgeConnectivity.uni2 = edgePort2
- edgeToEdgeConnectivity.operstate = "active"
- edgeToEdgeConnectivity.adminstate = "enabled"
-
- objs.append(edgeToEdgeConnectivity)
-
- return objs
-
+ objs.append(self.get_network_eline_link(networkDevice, evc))
+ elif (evcServiceType == "Multipoint_To_Multipoint"):
+ objs.append(self.get_network_elan_link(networkDevice, evc))
+ elif (evcServiceType == "Root_Multipoint"):
+ objs.append(self.get_network_etree_link(networkDevice, evc))
+ else:
+ raise Exception("OnosApiError: get_network_links() - unknown link type")
else:
raise Exception("OnosApiError: get_network_links()")
- def create_point_to_point_connectivity(self, obj):
+ return objs
- restCtrlUrl = self.networkdevice.restCtrlUrl
- username = self.networkdevice.username
- password = self.networkdevice.password
+ def create_point_to_point_connectivity_json_data(self, obj):
- evcServiceType = obj.type
- # evcServiceType = "Point_To_Point"
+ p2p_json_data = {}
+ p2p_json_data["evcServiceType"] = "Point_To_Point"
uni1 = obj.uni1
uni1Id = uni1.pid
@@ -142,6 +258,19 @@
uni1BwpCfgCir = uni1.bwpCfgCir
uni1BwpCfgEir = uni1.bwpCfgEir
+ uni1_json_data = {}
+ uni1_json_data['scaEthFppUniN'] = {}
+ uni1_json_data['scaEthFppUniN']['ceVlanId'] = obj.vlanid
+ uni1_json_data['scaEthFppUniN']["transportPort"] = {}
+ uni1_json_data['scaEthFppUniN']["interfaceCfgIngressBwp"] = {}
+
+ uni1_json_data['scaEthFppUniN']["transportPort"]["Hostname"] = uni1Hostname
+ uni1_json_data['scaEthFppUniN']["transportPort"]["Port"] = uni1Port
+ uni1_json_data['scaEthFppUniN']["interfaceCfgIngressBwp"]["bwpCfgCbs"] = uni1BwpCfgCbs
+ uni1_json_data['scaEthFppUniN']["interfaceCfgIngressBwp"]["bwpCfgEbs"] = uni1BwpCfgEbs
+ uni1_json_data['scaEthFppUniN']["interfaceCfgIngressBwp"]["bwpCfgCir"] = uni1BwpCfgCir
+ uni1_json_data['scaEthFppUniN']["interfaceCfgIngressBwp"]["bwpCfgEir"] = uni1BwpCfgEir
+
uni2 = obj.uni2
uni2Id = uni2.pid
uni2IdToken = (uni2Id.split('.', 1))[1].split('/', 1)
@@ -152,27 +281,137 @@
uni2BwpCfgCir = uni2.bwpCfgCir
uni2BwpCfgEir = uni2.bwpCfgEir
- data = {
- "evcServiceType": evcServiceType,
- "SCA_ETH_Flow_Points": [
- {
- "scaEthFppUniN": {"transportPort": {"Hostname": uni1Hostname, "Port": uni1Port},
- "interfaceCfgIngressBwp": {"bwpCfgCbs": uni1BwpCfgCbs,
- "bwpCfgEbs": uni1BwpCfgEbs,
- "bwpCfgCir": uni1BwpCfgCir,
- "bwpCfgEir": uni1BwpCfgEir}}},
- {
- "scaEthFppUniN": {"transportPort": {"Hostname": uni2Hostname, "Port": uni2Port},
- "interfaceCfgIngressBwp": {"bwpCfgCbs": uni2BwpCfgCbs,
- "bwpCfgEbs": uni2BwpCfgEbs,
- "bwpCfgCir": uni2BwpCfgCir,
- "bwpCfgEir": uni2BwpCfgEir}}}]
- }
+ uni2_json_data = {}
+ uni2_json_data['scaEthFppUniN'] = {}
+ uni2_json_data['scaEthFppUniN']['ceVlanId'] = obj.vlanid
+ uni2_json_data['scaEthFppUniN']["transportPort"] = {}
+ uni2_json_data['scaEthFppUniN']["interfaceCfgIngressBwp"] = {}
+
+ uni2_json_data['scaEthFppUniN']["transportPort"]["Hostname"] = uni2Hostname
+ uni2_json_data['scaEthFppUniN']["transportPort"]["Port"] = uni2Port
+ uni2_json_data['scaEthFppUniN']["interfaceCfgIngressBwp"]["bwpCfgCbs"] = uni2BwpCfgCbs
+ uni2_json_data['scaEthFppUniN']["interfaceCfgIngressBwp"]["bwpCfgEbs"] = uni2BwpCfgEbs
+ uni2_json_data['scaEthFppUniN']["interfaceCfgIngressBwp"]["bwpCfgCir"] = uni2BwpCfgCir
+ uni2_json_data['scaEthFppUniN']["interfaceCfgIngressBwp"]["bwpCfgEir"] = uni2BwpCfgEir
+
+ p2p_json_data["SCA_ETH_Flow_Points"] = []
+ p2p_json_data["SCA_ETH_Flow_Points"].append(uni1_json_data)
+ p2p_json_data["SCA_ETH_Flow_Points"].append(uni2_json_data)
+
+ return p2p_json_data
+
+ # nchoi: create elan service json data
+ def create_multipoint_to_multipoint_connectivity_json_data(self, obj):
+
+ mp2mp_json_data = {}
+ mp2mp_json_data["evcServiceType"] = "Multipoint_To_Multipoint"
+ mp2mp_json_data["SCA_ETH_Flow_Points"] = []
+
+ for ep in obj.eps.all():
+ uniId = ep.pid
+ uniIdToken = (uniId.split('.', 1))[1].split('/', 1)
+ uniHostname = uniIdToken[0]
+ uniPort = uniIdToken[1]
+ uniBwpCfgCbs = ep.bwpCfgCbs
+ uniBwpCfgEbs = ep.bwpCfgEbs
+ uniBwpCfgCir = ep.bwpCfgCir
+ uniBwpCfgEir = ep.bwpCfgEir
+
+ uni_json_data = {}
+ uni_json_data['scaEthFppUniN'] = {}
+ uni_json_data['scaEthFppUniN']['ceVlanId'] = obj.vlanid
+ uni_json_data['scaEthFppUniN']["transportPort"] = {}
+ uni_json_data['scaEthFppUniN']["interfaceCfgIngressBwp"] = {}
+
+ uni_json_data['scaEthFppUniN']["transportPort"]["Hostname"] = uniHostname
+ uni_json_data['scaEthFppUniN']["transportPort"]["Port"] = uniPort
+ uni_json_data['scaEthFppUniN']["interfaceCfgIngressBwp"]["bwpCfgCbs"] = uniBwpCfgCbs
+ uni_json_data['scaEthFppUniN']["interfaceCfgIngressBwp"]["bwpCfgEbs"] = uniBwpCfgEbs
+ uni_json_data['scaEthFppUniN']["interfaceCfgIngressBwp"]["bwpCfgCir"] = uniBwpCfgCir
+ uni_json_data['scaEthFppUniN']["interfaceCfgIngressBwp"]["bwpCfgEir"] = uniBwpCfgEir
+
+ mp2mp_json_data["SCA_ETH_Flow_Points"].append(uni_json_data)
+
+ return mp2mp_json_data
+
+ # nchoi: create etree service json data
+ def create_root_multipoint_connectivity_json_data(self, obj):
+
+ r2mp_json_data = {}
+ r2mp_json_data["evcServiceType"] = "Root_Multipoint"
+ r2mp_json_data["SCA_ETH_Flow_Points"] = []
+
+ root = obj.root
+ uniId = root.pid
+ uniIdToken = (uniId.split('.', 1))[1].split('/', 1)
+ uniHostname = uniIdToken[0]
+ uniPort = uniIdToken[1]
+ uniBwpCfgCbs = root.bwpCfgCbs
+ uniBwpCfgEbs = root.bwpCfgEbs
+ uniBwpCfgCir = root.bwpCfgCir
+ uniBwpCfgEir = root.bwpCfgEir
+
+ uni_json_data = {}
+ uni_json_data['scaEthFppUniN'] = {}
+ uni_json_data['scaEthFppUniN']['ceVlanId'] = obj.vlanid
+ uni_json_data['scaEthFppUniN']["transportPort"] = {}
+ uni_json_data['scaEthFppUniN']["interfaceCfgIngressBwp"] = {}
+
+ uni_json_data['scaEthFppUniN']["transportPort"]["Hostname"] = uniHostname
+ uni_json_data['scaEthFppUniN']["transportPort"]["Port"] = uniPort
+ uni_json_data['scaEthFppUniN']["interfaceCfgIngressBwp"]["bwpCfgCbs"] = uniBwpCfgCbs
+ uni_json_data['scaEthFppUniN']["interfaceCfgIngressBwp"]["bwpCfgEbs"] = uniBwpCfgEbs
+ uni_json_data['scaEthFppUniN']["interfaceCfgIngressBwp"]["bwpCfgCir"] = uniBwpCfgCir
+ uni_json_data['scaEthFppUniN']["interfaceCfgIngressBwp"]["bwpCfgEir"] = uniBwpCfgEir
+
+ r2mp_json_data["SCA_ETH_Flow_Points"].append(uni_json_data)
+
+ for ep in obj.eps.all():
+ uniId = ep.pid
+ uniIdToken = (uniId.split('.', 1))[1].split('/', 1)
+ uniHostname = uniIdToken[0]
+ uniPort = uniIdToken[1]
+ uniBwpCfgCbs = ep.bwpCfgCbs
+ uniBwpCfgEbs = ep.bwpCfgEbs
+ uniBwpCfgCir = ep.bwpCfgCir
+ uniBwpCfgEir = ep.bwpCfgEir
+
+ uni_json_data = {}
+ uni_json_data['scaEthFppUniN'] = {}
+ uni_json_data['scaEthFppUniN']['ceVlanId'] = obj.vlanid
+ uni_json_data['scaEthFppUniN']["transportPort"] = {}
+ uni_json_data['scaEthFppUniN']["interfaceCfgIngressBwp"] = {}
+
+ uni_json_data['scaEthFppUniN']["transportPort"]["Hostname"] = uniHostname
+ uni_json_data['scaEthFppUniN']["transportPort"]["Port"] = uniPort
+ uni_json_data['scaEthFppUniN']["interfaceCfgIngressBwp"]["bwpCfgCbs"] = uniBwpCfgCbs
+ uni_json_data['scaEthFppUniN']["interfaceCfgIngressBwp"]["bwpCfgEbs"] = uniBwpCfgEbs
+ uni_json_data['scaEthFppUniN']["interfaceCfgIngressBwp"]["bwpCfgCir"] = uniBwpCfgCir
+ uni_json_data['scaEthFppUniN']["interfaceCfgIngressBwp"]["bwpCfgEir"] = uniBwpCfgEir
+
+ r2mp_json_data["SCA_ETH_Flow_Points"].append(uni_json_data)
+
+ return r2mp_json_data
+
+ def create_network_connectivity(self, obj):
+
+ restCtrlUrl = self.networkdevice.restCtrlUrl
+ username = self.networkdevice.username
+ password = self.networkdevice.password
+
+ evcServiceType = obj.type
+ if (evcServiceType == "Point_To_Point"):
+ network_connectivity_json_data = self.create_point_to_point_connectivity_json_data(obj)
+ elif (evcServiceType == "Multipoint_To_Multipoint"):
+ network_connectivity_json_data = self.create_multipoint_to_multipoint_connectivity_json_data(obj)
+ elif (evcServiceType == "Root_Multipoint"):
+ network_connectivity_json_data = self.create_root_multipoint_connectivity_json_data(obj)
+ else:
+ raise Exception("OnosApiError: get_network_links() - unknown link type")
headers = {'Content-Type': 'application/json'}
-
resp = requests.post('{}/mef-sca-api/SCA_ETH_FDFr_EC'.format(restCtrlUrl),
- data=json.dumps(data), headers=headers, auth=HTTPBasicAuth(username, password))
+ data=json.dumps(network_connectivity_json_data), headers=headers, auth=HTTPBasicAuth(username, password))
if resp.status_code == 201:
result = resp.json()
@@ -192,6 +431,7 @@
obj.adminstate = "invalid" # what's the meaning?
obj.operstate = "inactive"
obj.backend_status = '204 - No network resource'
+
return False
elif resp.status_code == 500:
@@ -201,9 +441,9 @@
return False
else:
- raise Exception("OnosApiError: create_point_to_point_connectivity()")
+ raise Exception("OnosApiError: create_network_connectivity()")
- def delete_point_to_point_connectivity(self, obj):
+ def delete_network_connectivity(self, obj):
restCtrlUrl = self.networkdevice.restCtrlUrl
username = self.networkdevice.username
@@ -229,4 +469,4 @@
return False
else:
- raise Exception("OnosApiError: delete_point_to_point_connectivity()")
+ raise Exception("OnosApiError: delete_network_connectivity()")
diff --git a/xos/synchronizer/providers/metronetworktestprovider.py b/xos/synchronizer/providers/metronetworktestprovider.py
index 3c3f179..3bcbb92 100644
--- a/xos/synchronizer/providers/metronetworktestprovider.py
+++ b/xos/synchronizer/providers/metronetworktestprovider.py
@@ -3,6 +3,7 @@
from xos.logger import Logger, logging
from services.metronetwork.models import *
+from core.models import Site
from synchronizers.metronetwork.providers.metronetworkprovider import MetroNetworkProvider
logger = Logger(level=logging.INFO)
@@ -15,40 +16,18 @@
# Method for retrieving all network ports from the backend system
def get_network_ports(self):
#
- # Our Test Network Consists of three NetworkDevices (which correspond to ONOS instances):
+ # Our Test Network Consists of one NetworkDevice (which correspond to ONOS instance):
#
- # ONOS1-CORDPOD1
- # ONOS2-MetroNetwork
- # ONOW3-CORDPOD2
+ # 8 Ports
+ # 1 Eline (2 ports)
+ # 1 Etree (3 ports)
+ # 1 Elan (3 ports)
#
- #
- # Uni-NetworkEdgePort3--
- # Uni-NetworkEdgePort11-
- # Uni-NetworkEdgePort5--ONOS1-CORDPOD1-NetworkPort6
- # NetworkPort4-- |
- # NetworkPort1-ONOS2-MetroNetwork
- # NetworkPort2-
- # |
- # Uni-NetworkEdgePort7--ONOS3-CORDPOD2-NetworkPort10
- # Uni-NetworkEdgePort9--
- # Uni-NetworkEdgePort12-
- # NetworkPort8--
- #
- # Note: NetworkPorts can be endpoints of Interlinks and NetworkPointToPointConnections
- # they can be seem as a simple port.
- # NetworkEdgePorts are UNIs in the network, so are specicially user facing.
- #
- #
- # InterLinks - Port1 - Port6
- # Port2 - Port10
- #
- # NetworkPointToPointConnections: Port1 - Port2
- # Port4 - Port6
- # Port8 - Port10
- #
- # NetworkEdgeToEdgePointConnections: Port3 - Port7
- #
- # NetworkMultipointConnection: Port11 - Port5 - Port9 - Port12
+ # 2 Sites - Representing Two R-CORD Pods
+ # 2 Ports, One-per-site
+ # 1 Bandwidth Profile
+ # 2 Service Spokes
+ # 1 VnodGlobalService
objs = []
@@ -56,14 +35,9 @@
if self.networkdevice.id != 'TestMetroNet':
return objs
- # Ok - in the test class we cheat and create one NetworkDevice with 8 NetworkEdgePorts
+ # Set the parent device id to just be the Test NetworkDevice
device1 = NetworkDevice()
- device1.id = 'TestCORDNet'
- device1.administrativeState = 'enabled'
- device1.restCtrlUrl = 'testCordPod1.onlab.net:8000'
- device1.username = 'karaf'
- device1.password = 'karaf'
- objs.append(device1)
+ device1.id = self.networkdevice.id
port1 = NetworkEdgePort()
port1.element = device1
@@ -176,11 +150,6 @@
for port in allports:
objs.append(port)
- # Ok - in the test class we cheat and take down the adjunct Fake NetworkDevices Devices
- device1 = NetworkDevice()
- device1.id = 'TestCORDNet'
- objs.append(device1)
-
return objs
def get_network_links(self):
@@ -189,7 +158,7 @@
# Connectivity object - Point to Point
cordpod1device = NetworkDevice()
- cordpod1device.id = 'TestCORDNet'
+ cordpod1device.id = self.networkdevice.id
# Edge to Edge Point Connectivity Objects
edgetoedgeconnectivity = NetworkEdgeToEdgePointConnection()
@@ -239,6 +208,81 @@
edge2multipointconnectivity.eps_createbuffer = json.dumps(myjsonstr)
objs.append(edge2multipointconnectivity)
+ # Create Objects for VnodGlobal Sort of Testing
+
+ # Bandwidth Profile
+
+ bwprofile = BandwidthProfile()
+ bwprofile.bwpcfgcbs = 0
+ bwprofile.bwpcfgcir = 0
+ bwprofile.bwpcfgebs = 0
+ bwprofile.bwpcfgeir = 0
+ bwprofile.name = 'TestBWP'
+ objs.append(bwprofile)
+
+ # Two Sites
+ site1 = Site()
+ site1.name = 'CORDPod1'
+ site1.login_base = 'CordPod1'
+ site1.site_url = 'http://1.2.3.4:8080/VnodLocalApi'
+ objs.append(site1)
+
+ site2 = Site()
+ site2.name = 'CORDPod2'
+ site2.login_base = 'CordPod2'
+ site2.site_url = 'http://10.11.12.13:8080/VnodLocalApi'
+ objs.append(site2)
+
+ # Two Ports - one per Site
+
+ remoteport1 = RemotePort()
+ remoteport1.name = "CORDPOD1:Port1"
+ remoteport1.sitename = 'CordPod1'
+ remoteport1.edgeportname = cordpod1device.id + "." + "of:000000001/1"
+ objs.append(remoteport1)
+
+ remoteport2 = RemotePort()
+ remoteport2.name = "CORDPOD2:Port1"
+ remoteport2.sitename = 'CordPod2'
+ remoteport2.edgeportname = cordpod1device.id + "." + "of:000000001/2"
+ objs.append(remoteport2)
+
+ # One Spoke/Site
+ spoke1 = ServiceSpoke()
+ spoke1.name = 'TestSpoke1'
+ spoke1.remoteportname = "CORDPOD1:Port1"
+ spoke1.remotevnodid = 'CORDPod1:VnodLocal:1'
+ spoke1.operstate = 'inactive'
+ spoke1.adminstate = 'enabled'
+ spoke1.sitename = 'CordPod1'
+ objs.append(spoke1)
+
+ spoke2 = ServiceSpoke()
+ spoke2.name = 'TestSpoke2'
+ spoke2.remoteportname = "CORDPOD2:Port1"
+ spoke2.remotevnodid = 'CORDPod2:VnodLocal:1'
+ spoke2.operstate = 'active'
+ spoke2.adminstate = 'enabled'
+ spoke2.sitename = 'CordPod2'
+ objs.append(spoke2)
+
+ # One VnodGlobal Service
+ vnodglobal = VnodGlobalService()
+ vnodglobal.name = 'VnodGlobalPtToPtTest1'
+ vnodglobal.type = 'eline'
+ vnodglobal.vlanid = '100'
+ vnodglobal.operstate = 'active'
+ vnodglobal.adminstate = 'enabled'
+ vnodglobal.servicehandle = 'testhandle1'
+ vnodglobal.pointtopointsid = 'onos_eline_id'
+ vnodglobal.bwpname = 'TestBWP'
+
+ # Create JSON array for post-save behaviour
+ #
+ spokes = ['TestSpoke1', 'TestSpoke2']
+ myjsonstr = {'spokes': spokes}
+ vnodglobal.spokes_createbuffer = json.dumps(myjsonstr)
+ objs.append(vnodglobal)
return objs
diff --git a/xos/synchronizer/steps/sync_metronetworkservice.py b/xos/synchronizer/steps/sync_metronetworkservice.py
index 5c3fe70..56fd5d5 100644
--- a/xos/synchronizer/steps/sync_metronetworkservice.py
+++ b/xos/synchronizer/steps/sync_metronetworkservice.py
@@ -1,5 +1,5 @@
-import os
-import sys
+import os, sys
+from itertools import chain
from synchronizers.base.syncstep import SyncStep
from services.metronetwork.models import *
@@ -119,12 +119,15 @@
# Handle changes XOS -> ONOS
# Check for ConnectivityObjects that are in acticationequested state - creates to the backend
- activatereqs = NetworkEdgeToEdgePointConnection.objects.filter(adminstate='activationrequested')
+ p2pactivatereqs = NetworkEdgeToEdgePointConnection.objects.filter(adminstate='activationrequested')
+ mp2mpactivatereqs = NetworkMultipointToMultipointConnection.objects.filter(adminstate='activationrequested')
+ r2mpactivatereqs = NetworkEdgeToMultipointConnection.objects.filter(adminstate='activationrequested')
+ activatereqs = list(chain(p2pactivatereqs, mp2mpactivatereqs, r2mpactivatereqs))
for activatereq in activatereqs:
# Call the XOS Interface to create the service
logger.debug("Attempting to create EdgePointToEdgePointConnectivity: %s" % activatereq.id)
- if (provider.create_point_to_point_connectivity(activatereq)):
+ if (provider.create_network_connectivity(activatereq)):
# Everyting is OK, lets let the system handle the persist
objs.append(activatereq)
else:
@@ -133,12 +136,15 @@
activatereq.save()
# Check for ConnectivityObjects that are in deacticationequested state - deletes to the backend
- deactivatereqs = NetworkEdgeToEdgePointConnection.objects.filter(adminstate='deactivationrequested')
+ p2pdeactivatereqs = NetworkEdgeToEdgePointConnection.objects.filter(adminstate='deactivationrequested')
+ mp2mpdeactivatereqs = NetworkMultipointToMultipointConnection.objects.filter(adminstate='deactivationrequested')
+ r2mpdeactivatereqs = NetworkEdgeToMultipointConnection.objects.filter(adminstate='deactivationrequested')
+ deactivatereqs = list(chain(p2pdeactivatereqs, mp2mpdeactivatereqs, r2mpdeactivatereqs))
for deactivatereq in deactivatereqs:
# Call the XOS Interface to delete the service
logger.debug("Attempting to delete EdgePointToEdgePointConnectivity: %s" % deactivatereq.id)
- if provider.delete_point_to_point_connectivity(deactivatereq):
+ if provider.delete_network_connectivity(deactivatereq):
# Everyting is OK, lets let the system handle the persist
objs.append(deactivatereq)
else:
@@ -160,6 +166,57 @@
# Simply put in the queue for update - this will handle both new and changed objects
objs.append(eventobj)
+ # Handle the case where we have deleted Eline Services from our side - if the Service is in
+ # enabled state then we call the provider, otherwise just queue it for deletion
+ elinedeletedobjs = NetworkEdgeToEdgePointConnection.deleted_objects.all()
+ for elinedeletedobj in elinedeletedobjs:
+ if elinedeletedobj.adminstate == 'enabled':
+ provider.delete_network_connectivity(elinedeletedobj)
+ # Either way queue it for deletion
+ objs.append(elinedeletedobj)
+
+ # Handle the case where we have deleted Etree Services from our side - if the Service is in
+ # enabled state then we call the provider, otherwise just queue it for deletion
+ etreedeletedobjs = NetworkEdgeToMultipointConnection.deleted_objects.all()
+ for etreedeletedobj in etreedeletedobjs:
+ # TODO: Handle the case where its connected, we need to disconnect first
+ if etreedeletedobj.adminstate == 'enabled':
+ provider.delete_network_connectivity(etreedeletedobj)
+ # Either way queue it for deletion
+ objs.append(etreedeletedobj)
+
+ # Handle the case where we have deleted Elan Services from our side - if the Service is in
+ # enabled state then we call the provider, otherwise just queue it for deletion
+ elandeletedobjs = NetworkMultipointToMultipointConnection.deleted_objects.all()
+ for elandeletedobj in elandeletedobjs:
+ # TODO: Handle the case where its connected, we need to disconnect first
+ if elandeletedobj.adminstate == 'enabled':
+ provider.delete_network_connectivity(elandeletedobj)
+ # Either way queue it for deletion
+ objs.append(elandeletedobj)
+
+ # Handle the case where we have deleted VnodGlobal Services from our side - if there is
+ # an attached Eline/Etree/Elan we set that to deleted
+ vnodbloaldeletedobjs = VnodGlobalService.deleted_objects.all()
+ for vnodbloaldeletedobj in vnodbloaldeletedobjs:
+ # Check for dependent eline service
+ if vnodbloaldeletedobj.metronetworkpointtopoint is not None:
+ elineobj = vnodbloaldeletedobj.metronetworkpointtopoint
+ elineobj.deleted = True
+ objs.append(elineobj)
+ # Check for dependent elan service
+ if vnodbloaldeletedobj.metronetworkmultipoint is not None:
+ elanobj = vnodbloaldeletedobj.metronetworkmultipoint
+ elanobj.deleted = True
+ objs.append(elanobj)
+ # Check for dependent etree service
+ if vnodbloaldeletedobj.metronetworkroottomultipoint is not None:
+ etreeobj = vnodbloaldeletedobj.metronetworkroottomultipoint
+ etreeobj.deleted = True
+ objs.append(etreeobj)
+
+ objs.append(vnodbloaldeletedobj)
+
# In add cases return the objects we are interested in
return objs