Added support for invokers, non-docker runtime. Added ETREE and ELAN models, admin GUI, REST API and test domain
Change-Id: Iade143ba72f967390f0782a4e46e5aa289f9ffbb
diff --git a/xos/__init__.py b/xos/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/xos/__init__.py
diff --git a/xos/admin.py b/xos/admin.py
index cffd99d..6aae88b 100644
--- a/xos/admin.py
+++ b/xos/admin.py
@@ -7,10 +7,10 @@
from services.metronetwork.models import *
-class MetroServiceAdmin(ReadOnlyAwareAdmin):
- model = MetroNetworkService
- verbose_name = "MetroNetwork Service"
- verbose_name_plural = "MetroNetwork Services"
+class MetroNetworkSystemAdmin(ReadOnlyAwareAdmin):
+ model = MetroNetworkSystem
+ verbose_name = "MetroNetwork System"
+ verbose_name_plural = "MetroNetwork System"
list_display = ("name", "administrativeState")
list_display_links = ('name',)
fieldsets = [(None, {
@@ -27,61 +27,53 @@
class NetworkDeviceAdmin(XOSBaseAdmin):
-
+ verbose_name = "Network Device"
+ verbose_name_plural = "Network Devices"
form = NetworkDeviceAdminForm
list_display = ('id', 'restCtrlUrl', 'administrativeState', 'username')
list_display_links = ('id', 'restCtrlUrl', 'administrativeState', 'username')
fields = ('id', 'restCtrlUrl', 'administrativeState', 'username', 'password')
-class NetworkPortAdmin(XOSBaseAdmin):
- list_display = ('id', 'element')
- list_display_links = ('id', 'element')
-
- fields = ('id', 'element')
- readonly_fields = ('id', 'element')
-
class NetworkEdgePortAdmin(XOSBaseAdmin):
+ verbose_name = "Network Edge Port"
+ verbose_name_plural = "Network Edge Ports"
list_display = ('id', 'pid', 'element', 'bwpCfgCbs', 'bwpCfgEbs', 'bwpCfgCir', 'bwpCfgEir', 'name', 'location', 'latlng')
list_display_links = ('id', 'pid', 'element', 'bwpCfgCbs', 'bwpCfgEbs', 'bwpCfgCir', 'bwpCfgEir')
fields = ('id', 'pid', 'element', 'bwpCfgCbs', 'bwpCfgEbs', 'bwpCfgCir', 'bwpCfgEir', 'name', 'location', 'latlng')
readonly_fields = ('id', 'pid', 'element', 'bwpCfgCbs', 'bwpCfgEbs', 'bwpCfgCir', 'bwpCfgEir')
-
-class NetworkInterLinkAdmin(XOSBaseAdmin):
- list_display = ('discovery', 'src', 'dest', 'state')
- list_display_links = ('discovery', 'src', 'dest', 'state')
-
- fields = ('discovery', 'src', 'dest', 'state')
- readonly_fields = ('discovery', 'src', 'dest', 'state')
-
-class NetworkPointToPointConnectionAdmin(XOSBaseAdmin):
- list_display = ('id', 'sid', 'type', 'src', 'dest', 'adminstate', 'operstate')
- list_display_links = ('id', 'sid', 'type', 'src', 'dest', 'adminstate', 'operstate')
-
- fields = ('id', 'sid', 'type', 'src', 'dest', 'adminstate', 'operstate')
- readonly_fields = ('id', 'type', 'src', 'dest', 'operstate')
-
-class NetworkEdgePointToEdgePointConnectionAdmin(XOSBaseAdmin):
+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')
fields = ('id', 'sid', 'type', 'uni1', 'uni2', 'adminstate', 'operstate', 'backend_status')
readonly_fields = ('id', 'type', 'uni1', 'uni2', 'operstate', 'backend_status')
-class NetworkMultipointConnectionAdmin(XOSBaseAdmin):
- list_display = ('type', 'state')
- list_display_links = ('type', 'state')
+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')
- fields = ('type', 'eps', 'state')
- readonly_fields = ('type', 'eps', 'state')
+ fields = ('id', 'sid', 'type', 'eps', 'adminstate', 'operstate', 'backend_status')
+ readonly_fields = ('id', 'sid', 'type', 'eps', 'adminstate', 'operstate', 'backend_status')
-admin.site.register(MetroNetworkService, MetroServiceAdmin)
+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')
+
+ fields = ('id', 'sid', 'type', 'root', 'eps', 'adminstate', 'operstate', 'backend_status')
+ readonly_fields = ('id', 'sid', 'type', 'root', 'eps', 'adminstate', 'operstate', 'backend_status')
+
+admin.site.register(MetroNetworkSystem, MetroNetworkSystemAdmin)
admin.site.register(NetworkDevice, NetworkDeviceAdmin)
-admin.site.register(NetworkPort, NetworkPortAdmin)
admin.site.register(NetworkEdgePort, NetworkEdgePortAdmin)
-admin.site.register(NetworkInterLink, NetworkInterLinkAdmin)
-admin.site.register(NetworkPointToPointConnection, NetworkPointToPointConnectionAdmin)
-admin.site.register(NetworkEdgeToEdgePointConnection, NetworkEdgePointToEdgePointConnectionAdmin)
-admin.site.register(NetworkMultipointConnection, NetworkMultipointConnectionAdmin)
+admin.site.register(NetworkEdgeToEdgePointConnection, NetworkEdgeToEdgePointConnectionAdmin)
+admin.site.register(NetworkMultipointToMultipointConnection, NetworkMultipointToMultipointConnectionAdmin)
+admin.site.register(NetworkEdgeToMultipointConnection, NetworkEdgeToMultipointConnectionAdmin)
diff --git a/xos/api/service/metronetworkservice/metronetworkservice.py b/xos/api/service/metronetworkservice/metronetworkservice.py
index 368e52f..8e200ce 100644
--- a/xos/api/service/metronetworkservice/metronetworkservice.py
+++ b/xos/api/service/metronetworkservice/metronetworkservice.py
@@ -1,16 +1,16 @@
from rest_framework.response import Response
from rest_framework import serializers, filters, status
from api.xosapi_helpers import PlusModelSerializer, XOSViewSet, ReadOnlyField
-from services.metronetwork.models import MetroNetworkService, NetworkEdgePort, NetworkEdgeToEdgePointConnection
+from services.metronetwork.models import *
from django.core.exceptions import ObjectDoesNotExist
from django.core import serializers as jsonserializer
-class MetroNetworkServiceSerializer(PlusModelSerializer):
+class MetroNetworkSystemSerializer(PlusModelSerializer):
id = ReadOnlyField()
humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
class Meta:
- model = MetroNetworkService
+ model = MetroNetworkSystem
fields = ('humanReadableName',
'id',
'restUrl',
@@ -20,16 +20,16 @@
def getHumanReadableName(self, obj):
return obj.__unicode__()
-class MetroNetworkServiceViewSet(XOSViewSet):
- base_name = "metronetworkservice"
- method_name = "metronetwork"
+class MetroNetworkSystemViewSet(XOSViewSet):
+ base_name = "metronetworksystem"
+ method_name = "metronetworksystem"
method_kind = "viewset"
- queryset = MetroNetworkService.get_service_objects().all()
- serializer_class = MetroNetworkServiceSerializer
+ queryset = MetroNetworkSystem.objects.all()
+ serializer_class = MetroNetworkSystemSerializer
@classmethod
def get_urlpatterns(self, api_path="^"):
- patterns = super(MetroNetworkServiceViewSet, self).get_urlpatterns(api_path=api_path)
+ patterns = super(MetroNetworkSystemViewSet, self).get_urlpatterns(api_path=api_path)
return patterns
@@ -64,8 +64,8 @@
return obj.id
class NetworkEdgePortViewSet(XOSViewSet):
- base_name = "SCA_ETH_FPP_UNI_N"
- method_name = "SCA_ETH_FPP_UNI_N"
+ base_name = "UNI"
+ method_name = "UNI"
method_kind = "viewset"
queryset = NetworkEdgePort.objects.all()
serializer_class = NetworkEdgePortSerializer
@@ -105,10 +105,10 @@
return obj.id
class NetworkEdgeToEdgePointConnectionViewSet(XOSViewSet):
- base_name = "SCA_ETH_FDFr_EC"
- method_name = "SCA_ETH_FDFr_EC"
+ base_name = "ELINE"
+ method_name = "ELINE"
method_kind = "viewset"
- queryset = NetworkEdgeToEdgePointConnection.objects.all()
+ queryset = NetworkEdgeToEdgePointConnection.get_service_objects().all()
serializer_class = NetworkEdgeToEdgePointConnectionSerializer
@classmethod
@@ -183,4 +183,201 @@
response_data['uni2']['location'] = uni1.location
response_data['uni2']['latlng'] = uni1.latlng
- return Response(response_data)
\ No newline at end of file
+ return Response(response_data)
+
+class NetworkEdgeToMultipointConnectionSerializer(PlusModelSerializer):
+ humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
+ root = NetworkEdgePortSerializer(required=True, read_only=False)
+ eps = NetworkEdgePortSerializer(required=True, read_only=False, many=True)
+
+ class Meta:
+ model = NetworkEdgeToMultipointConnection
+
+ fields = ('humanReadableName',
+ 'sid',
+ 'id',
+ 'type',
+ 'root',
+ 'eps',
+ 'operstate',
+ 'adminstate'
+ )
+
+ def getHumanReadableName(self, obj):
+ return obj.id
+
+class NetworkEdgeToMultipointConnectionViewSet(XOSViewSet):
+ base_name = "ETREE"
+ method_name = "ETREE"
+ method_kind = "viewset"
+ queryset = NetworkEdgeToMultipointConnection.get_service_objects().all()
+ serializer_class = NetworkEdgeToMultipointConnectionSerializer
+
+ @classmethod
+ def get_urlpatterns(self, api_path="^"):
+ patterns = super(NetworkEdgeToMultipointConnectionViewSet, 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):
+ ETreeConnectionToDelete = NetworkEdgeToMultipointConnection.objects.get(pk=pk)
+
+ if (ETreeConnectionToDelete):
+ ETreeConnectionToDelete.adminstate = 'deactivationrequested'
+ ETreeConnectionToDelete.save()
+ else:
+ return Response(status=status.HTTP_400_BAD_REQUEST)
+
+ return Response(status=status.HTTP_200_OK)
+
+ def create(self, validated_data):
+
+ ETreeConnection = NetworkEdgeToMultipointConnection()
+ 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')
+
+ root_id = validated_data.data.get('root')
+ eps_list = validated_data.data.get('eps')
+
+ root = NetworkEdgePort.objects.get(pk=root_id)
+ ETreeConnection.root = root
+ ETreeConnection.save()
+
+ for ep in eps_list:
+ port = NetworkEdgePort.objects.get(pk=ep['id'])
+ ETreeConnection.eps.add(port)
+
+ response_data = {}
+ response_data['sid'] = ETreeConnection.sid
+ response_data['adminstate'] = ETreeConnection.adminstate
+ response_data['operstate'] = ETreeConnection.operstate
+ response_data['type'] = ETreeConnection.type
+
+ response_data['root'] = {}
+ response_data['root']['id'] = root.id
+ response_data['root']['pid'] = root.pid
+ response_data['root']['bwpCfgCbs'] = root.bwpCfgCbs
+ response_data['root']['bwpCfgEbs'] = root.bwpCfgEbs
+ response_data['root']['bwpCfgCir'] = root.bwpCfgCir
+ response_data['root']['bwpCfgEir'] = root.bwpCfgEir
+ response_data['root']['name'] = root.name
+ response_data['root']['location'] = root.location
+ response_data['root']['latlng'] = root.latlng
+
+ eps_data = []
+ for ep in ETreeConnection.eps.all():
+ port = {}
+ port['id'] = ep.id
+ port['pid'] = ep.pid
+ port['bwpCfgCbs'] = ep.bwpCfgCbs
+ port['bwpCfgEbs'] = ep.bwpCfgEbs
+ port['bwpCfgCir'] = ep.bwpCfgCir
+ port['bwpCfgEir'] = ep.bwpCfgEir
+ port['name'] = ep.name
+ port['location'] = ep.location
+ port['latlng'] = ep.latlng
+ eps_data.append(port)
+
+ response_data['eps'] = eps_data
+
+ return Response(response_data)
+
+class NetworkMultipointToMultipointConnectionSerializer(PlusModelSerializer):
+ humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
+ eps = NetworkEdgePortSerializer(required=True, read_only=False, many=True)
+
+ class Meta:
+ model = NetworkMultipointToMultipointConnection
+
+ fields = ('humanReadableName',
+ 'sid',
+ 'id',
+ 'type',
+ 'eps',
+ 'operstate',
+ 'adminstate'
+ )
+
+ def getHumanReadableName(self, obj):
+ return obj.id
+
+class NetworkMultipointToMultipointConnectionViewSet(XOSViewSet):
+ base_name = "ELAN"
+ method_name = "ELAN"
+ method_kind = "viewset"
+ queryset = NetworkMultipointToMultipointConnection.get_service_objects().all()
+ serializer_class = NetworkMultipointToMultipointConnectionSerializer
+
+ @classmethod
+ def get_urlpatterns(self, api_path="^"):
+ patterns = super(NetworkMultipointToMultipointConnectionViewSet, 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):
+ ETreeConnectionToDelete = NetworkMultipointToMultipointConnection.objects.get(pk=pk)
+
+ if (ETreeConnectionToDelete):
+ ETreeConnectionToDelete.adminstate = 'deactivationrequested'
+ ETreeConnectionToDelete.save()
+ else:
+ return Response(status=status.HTTP_400_BAD_REQUEST)
+
+ return Response(status=status.HTTP_200_OK)
+
+ def create(self, validated_data):
+
+ ELanConnection = NetworkMultipointToMultipointConnection()
+ 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')
+
+ eps_list = validated_data.data.get('eps')
+ ELanConnection.save()
+
+ for ep in eps_list:
+ port = NetworkEdgePort.objects.get(pk=ep['id'])
+ ELanConnection.eps.add(port)
+
+ response_data = {}
+ response_data['sid'] = ELanConnection.sid
+ response_data['adminstate'] = ELanConnection.adminstate
+ response_data['operstate'] = ELanConnection.operstate
+ response_data['type'] = ELanConnection.type
+
+ eps_data = []
+ for ep in ELanConnection.eps.all():
+ port = {}
+ port['id'] = ep.id
+ port['pid'] = ep.pid
+ port['bwpCfgCbs'] = ep.bwpCfgCbs
+ port['bwpCfgEbs'] = ep.bwpCfgEbs
+ port['bwpCfgCir'] = ep.bwpCfgCir
+ port['bwpCfgEir'] = ep.bwpCfgEir
+ port['name'] = ep.name
+ port['location'] = ep.location
+ port['latlng'] = ep.latlng
+ eps_data.append(port)
+
+ response_data['eps'] = eps_data
+
+ return Response(response_data)
diff --git a/xos/models.py b/xos/models.py
index 3abb3cb..bb069a5 100644
--- a/xos/models.py
+++ b/xos/models.py
@@ -6,15 +6,15 @@
METRONETWORK_KIND = "metronetwork"
SERVICE_NAME = 'metronetwork'
-SERVICE_NAME_VERBOSE = 'Metro Network Service'
+SERVICE_NAME_ELINE_VERBOSE = 'E-Line Service'
+SERVICE_NAME_ELAN_VERBOSE = 'E-LAN Service'
+SERVICE_NAME_ETREE_VERBOSE = 'E-Tree Service'
-class MetroNetworkService(Service):
-
- KIND = METRONETWORK_KIND
+class MetroNetworkSystem(PlCoreBase):
class Meta:
- app_label = SERVICE_NAME
- verbose_name = SERVICE_NAME_VERBOSE
+ app_label = METRONETWORK_KIND
+ verbose_name = "Metro Network System"
ADMINISTRATIVE_STATE = (
('enabled', 'Enabled'),
@@ -26,6 +26,15 @@
('inactive', 'Inactive')
)
+ name = models.CharField(unique=True,
+ verbose_name="Name",
+ max_length=256,
+ editable=True)
+
+ description = models.CharField(verbose_name="Description",
+ max_length=1024,
+ editable=True)
+
restUrl = models.CharField(verbose_name="Rest URL",
max_length=256,
editable=True)
@@ -42,7 +51,7 @@
editable=True)
def __init__(self, *args, **kwargs):
- super(MetroNetworkService, self).__init__(*args, **kwargs)
+ super(MetroNetworkSystem, self).__init__(*args, **kwargs)
def getAdminstrativeState(self):
return self.administrativeState
@@ -60,7 +69,8 @@
class NetworkDevice(PlCoreBase):
class Meta:
- app_label = SERVICE_NAME
+ app_label = METRONETWORK_KIND
+ verbose_name = "Network Device"
ADMINISTRATIVE_STATE = (
('enabled', 'Enabled'),
@@ -103,22 +113,11 @@
def __init__(self, *args, **kwargs):
super(NetworkDevice, self).__init__(*args, **kwargs)
-class NetworkPort(PlCoreBase):
-
- class Meta:
- app_label = SERVICE_NAME
-
- element = models.ForeignKey(NetworkDevice, on_delete=models.CASCADE)
- id = models.AutoField(verbose_name="id", primary_key=True, editable=False)
- pid = models.CharField(unique=True, verbose_name="Port ID", max_length=256, editable=False)
-
- def __init__(self, *args, **kwargs):
- super(NetworkPort, self).__init__(*args, **kwargs)
-
class NetworkEdgePort(PlCoreBase):
class Meta:
- app_label = SERVICE_NAME
+ app_label = METRONETWORK_KIND
+ verbose_name = "Network Edge Port"
element = models.ForeignKey(NetworkDevice, on_delete=models.CASCADE)
id = models.AutoField(verbose_name="id", primary_key=True, editable=False)
@@ -153,61 +152,12 @@
super(NetworkEdgePort, self).save(*args, **kwargs)
-class NetworkPointToPointConnection(PlCoreBase):
+#E-Line Service
+class NetworkEdgeToEdgePointConnection(Service):
class Meta:
app_label = SERVICE_NAME
-
- TYPE = (
- ('direct', 'Direct'),
- ('indirect', 'Indirect'),
- ('edge', 'Edge'),
- ('tunnel', 'Tunnel'),
- ('optical', 'Optical'),
- ('virtual', 'Virtual'),
- )
-
- OPERATIONALSTATE = (
- ('active', 'Active'),
- ('inactive', 'Inactive')
- )
-
- ADMINISTRATIVESTATE = (
- ('disabled', 'Disabled'),
- ('activationrequested', 'ActivationRequested'),
- ('enabled', 'Enabled'),
- ('invalid', 'Invalid'),
- ('deactivationrequested', 'DeactivationRequested')
- )
-
- id = models.AutoField(verbose_name="PointToPointConnectionId",
- primary_key=True,
- editable=False)
-
-
- 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)
- src = models.ForeignKey(NetworkPort,
- related_name='PointToPointSrc',
- verbose_name="Source",
- editable=False,
- on_delete=models.CASCADE)
- dest = models.ForeignKey(NetworkPort,
- related_name='PointToPointDst',
- verbose_name="Destination",
- editable=False,
- on_delete=models.CASCADE)
- operstate = models.CharField(choices=OPERATIONALSTATE, verbose_name="OperationalState", max_length=256, editable=False)
- adminstate = models.CharField(choices=ADMINISTRATIVESTATE, verbose_name="AdministrativeState", max_length=256, editable=True)
-
-
- def __init__(self, *args, **kwargs):
- super(NetworkPointToPointConnection, self).__init__(*args, **kwargs)
-
-class NetworkEdgeToEdgePointConnection(PlCoreBase):
-
- class Meta:
- app_label = SERVICE_NAME
+ verbose_name = SERVICE_NAME_ELINE_VERBOSE
TYPE = (
('direct', 'Direct'),
@@ -230,9 +180,6 @@
('deactivationrequested', 'DeactivationRequested')
)
- id = models.AutoField(verbose_name="EdgePointToEdgePointConnectivityId",
- primary_key=True,
- editable=False)
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=True)
uni1 = models.ForeignKey(NetworkEdgePort,
@@ -248,15 +195,18 @@
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)
+ #uni1_createbuffer = models.CharField(max_length=256, default="{}", null=True)
+ #uni2_createbuffer = models.CharField(max_length=256, default="{}", null=True)
def __init__(self, *args, **kwargs):
super(NetworkEdgeToEdgePointConnection, self).__init__(*args, **kwargs)
-
-class NetworkMultipointConnection(PlCoreBase):
+#E-Tree Service
+class NetworkEdgeToMultipointConnection(Service):
class Meta:
app_label = SERVICE_NAME
+ verbose_name = SERVICE_NAME_ETREE_VERBOSE
TYPE = (
('vlan', 'VLAN'),
@@ -264,48 +214,82 @@
('ethernet', 'Ethernet'),
)
- STATE = (
+ OPERATIONALSTATE = (
('active', 'Active'),
('inactive', 'Inactive')
)
+ ADMINISTRATIVESTATE = (
+ ('disabled', 'Disabled'),
+ ('activationrequested', 'ActivationRequested'),
+ ('enabled', 'Enabled'),
+ ('invalid', 'Invalid'),
+ ('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)
- eps = models.ManyToManyField(NetworkPort,
- related_name='eps',
+ root = models.ForeignKey(NetworkEdgePort,
+ related_name='EdgeToMultipointRoot',
+ verbose_name="Root",
+ editable=True,
+ on_delete=models.CASCADE)
+ eps = models.ManyToManyField(NetworkEdgePort,
+ related_name='%(class)s_eps',
verbose_name="Endpoints",
editable=False)
- state = models.CharField(choices=STATE, verbose_name="State", max_length=256, editable=False)
+ 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)
+
+ # Scratch Area to help deal with the Many to Many relationship with the eps
+ #eps_createbuffer = models.CharField(max_length=1024, default="{}", null=True)
def __init__(self, *args, **kwargs):
- super(NetworkMultipointConnection, self).__init__(*args, **kwargs)
+ super(NetworkEdgeToMultipointConnection, self).__init__(*args, **kwargs)
-class NetworkInterLink(PlCoreBase):
+#E-LAN Service
+class NetworkMultipointToMultipointConnection(Service):
class Meta:
app_label = SERVICE_NAME
+ verbose_name = SERVICE_NAME_ELAN_VERBOSE
- DISCOVERY = (
- ('auto', 'Automatic Discovery'),
- ('manual', 'Manual Discovery'),
+ TYPE = (
+ ('vlan', 'VLAN'),
+ ('ip', 'IP'),
+ ('ethernet', 'Ethernet'),
)
- STATE = (
+ OPERATIONALSTATE = (
('active', 'Active'),
('inactive', 'Inactive')
)
- src = models.ForeignKey(NetworkPort,
- related_name='InterLinkSrc',
- verbose_name="Source",
- editable=False,
- on_delete=models.CASCADE)
- dest = models.ForeignKey(NetworkPort,
- related_name='InterLinkDst',
- verbose_name="Destination",
- editable=False,
- on_delete=models.CASCADE)
- state = models.CharField(choices=STATE, verbose_name="State", max_length=256, editable=False)
- discovery = models.CharField(choices=STATE, verbose_name="State", max_length=256, editable=False)
+ ADMINISTRATIVESTATE = (
+ ('disabled', 'Disabled'),
+ ('activationrequested', 'ActivationRequested'),
+ ('enabled', 'Enabled'),
+ ('invalid', 'Invalid'),
+ ('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)
+ eps = models.ManyToManyField(NetworkEdgePort,
+ related_name='%(class)s_eps',
+ verbose_name="Endpoints",
+ editable=False)
+
+ 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)
+
+ # Scratch Area to help deal with the Many to Many relationship with the eps
+ #eps_createbuffer = models.CharField(max_length=1024, default="{}", null=True)
def __init__(self, *args, **kwargs):
- super(NetworkInterLink, self).__init__(*args, **kwargs)
\ No newline at end of file
+ super(NetworkMultipointToMultipointConnection, self).__init__(*args, **kwargs)
+
diff --git a/xos/synchronizer/invokers/__init__.py b/xos/synchronizer/invokers/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/xos/synchronizer/invokers/__init__.py
diff --git a/xos/synchronizer/invokers/invoker.py b/xos/synchronizer/invokers/invoker.py
new file mode 100644
index 0000000..e645285
--- /dev/null
+++ b/xos/synchronizer/invokers/invoker.py
@@ -0,0 +1,25 @@
+class Invoker(object):
+
+ 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):
+ return None
+
+
+ # 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 - None - this is a pure invoke() call, return type is None
+ #
+ def postsave(self, obj):
+ return None
\ No newline at end of file
diff --git a/xos/synchronizer/invokers/invokerfactory.py b/xos/synchronizer/invokers/invokerfactory.py
new file mode 100644
index 0000000..786f99d
--- /dev/null
+++ b/xos/synchronizer/invokers/invokerfactory.py
@@ -0,0 +1,20 @@
+from services.metronetwork.models import *
+from synchronizers.metronetwork.invokers.networkmultipointtomultipointinvoker import NetworkMultipointToMultipointInvoker
+from synchronizers.metronetwork.invokers.networkedgetoedgepointinvoker import NetworkEdgeToEdgePointInvoker
+from synchronizers.metronetwork.invokers.networkedgetomultipointinvoker import NetworkEdgeToMultipointInvoker
+
+
+class InvokerFactory(object):
+ @staticmethod
+ def getinvoker(obj):
+ #
+ # Here is where we build various invokers
+ #
+ if isinstance(obj, NetworkMultipointToMultipointConnection):
+ return NetworkMultipointToMultipointInvoker()
+ elif isinstance(obj, NetworkEdgeToEdgePointConnection):
+ return NetworkEdgeToEdgePointInvoker()
+ elif isinstance(obj, NetworkEdgeToMultipointConnection):
+ return NetworkEdgeToMultipointInvoker()
+ else:
+ return None
diff --git a/xos/synchronizer/invokers/networkedgetoedgepointinvoker.py b/xos/synchronizer/invokers/networkedgetoedgepointinvoker.py
new file mode 100644
index 0000000..ebc4d12
--- /dev/null
+++ b/xos/synchronizer/invokers/networkedgetoedgepointinvoker.py
@@ -0,0 +1,33 @@
+import json
+from synchronizers.metronetwork.invokers.invoker import Invoker
+from services.metronetwork.models import NetworkEdgePort
+
+
+class NetworkEdgeToEdgePointInvoker(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
+ 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
+ # 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
diff --git a/xos/synchronizer/invokers/networkedgetomultipointinvoker.py b/xos/synchronizer/invokers/networkedgetomultipointinvoker.py
new file mode 100644
index 0000000..a0b7ffd
--- /dev/null
+++ b/xos/synchronizer/invokers/networkedgetomultipointinvoker.py
@@ -0,0 +1,45 @@
+import json
+from synchronizers.metronetwork.invokers.invoker import Invoker
+from services.metronetwork.models import NetworkEdgeToMultipointConnection, NetworkEdgePort
+
+class NetworkEdgeToMultipointInvoker(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
+ # root field
+ rootEdgePort = NetworkEdgePort.objects.get(pid=obj.root_createbuffer)
+ obj.root = rootEdgePort
+
+
+ # 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
+ #
+ #
+ scratchpad = json.loads(obj.eps_createbuffer)
+ eps = scratchpad['eps']
+
+ 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
new file mode 100644
index 0000000..78b617c
--- /dev/null
+++ b/xos/synchronizer/invokers/networkmultipointtomultipointinvoker.py
@@ -0,0 +1,42 @@
+import json
+from synchronizers.metronetwork.invokers.invoker import Invoker
+from services.metronetwork.models import NetworkMultipointToMultipointConnection, NetworkEdgePort
+
+class NetworkMultipointToMultipointInvoker(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):
+ pass
+
+
+ # 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
+ #
+ #
+ scratchpad = json.loads(obj.eps_createbuffer)
+ eps = scratchpad['eps']
+
+ for ep in eps:
+ port = NetworkEdgePort.objects.get(pid=ep)
+ obj.eps.add(port)
diff --git a/xos/synchronizer/manifest b/xos/synchronizer/manifest
index 3f33fbc..98cb0d9 100644
--- a/xos/synchronizer/manifest
+++ b/xos/synchronizer/manifest
@@ -6,6 +6,12 @@
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
diff --git a/xos/synchronizer/providers/metronetworkprovider.py b/xos/synchronizer/providers/metronetworkprovider.py
index d36a384..c316815 100644
--- a/xos/synchronizer/providers/metronetworkprovider.py
+++ b/xos/synchronizer/providers/metronetworkprovider.py
@@ -26,11 +26,6 @@
# Default method needs to be overriden
logger.debug("get_network_ports for deletion called - default is all ports in the db related to this id")
objs = []
- # ports = NetworkPort.objects.filter(networkdevice=self.networkdevice.id)
- ports = NetworkPort.objects.all()
- for port in ports:
- objs.append(port)
-
return objs
# Method for retrieving all network links from the backend system
diff --git a/xos/synchronizer/providers/metronetworktestprovider.py b/xos/synchronizer/providers/metronetworktestprovider.py
index 48ee215..3c3f179 100644
--- a/xos/synchronizer/providers/metronetworktestprovider.py
+++ b/xos/synchronizer/providers/metronetworktestprovider.py
@@ -1,4 +1,5 @@
import random
+import json
from xos.logger import Logger, logging
from services.metronetwork.models import *
@@ -13,7 +14,41 @@
# Method for retrieving all network ports from the backend system
def get_network_ports(self):
- # Our Test Network Consists of 6 ports - two on each of three internal switches
+ #
+ # Our Test Network Consists of three NetworkDevices (which correspond to ONOS instances):
+ #
+ # ONOS1-CORDPOD1
+ # ONOS2-MetroNetwork
+ # ONOW3-CORDPOD2
+ #
+ #
+ # 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
objs = []
@@ -21,108 +56,111 @@
if self.networkdevice.id != 'TestMetroNet':
return objs
- # Ok - in the test class we cheat and create the adjunct NetworkDevices Devices
+ # Ok - in the test class we cheat and create one NetworkDevice with 8 NetworkEdgePorts
device1 = NetworkDevice()
- device1.id = 'TestCORD1Net'
+ device1.id = 'TestCORDNet'
device1.administrativeState = 'enabled'
device1.restCtrlUrl = 'testCordPod1.onlab.net:8000'
device1.username = 'karaf'
device1.password = 'karaf'
objs.append(device1)
- device2 = NetworkDevice()
- device2.id = 'TestCORD2Net'
- device2.administrativeState = 'enabled'
- device2.restCtrlUrl = 'testCordPod2.onlabl.net:8000'
- device2.username = 'karaf'
- device2.password = 'karaf'
- objs.append(device2)
-
- # Ok - here we go creating ports - its 4 ports for each CORD Pod and 2 for MetroNetwork
-
- # Metro Network Switch
- port1 = NetworkPort()
- port1.element = self.networkdevice
- port1.pid = self.networkdevice.id + "." + "of:000000001/1"
+ port1 = NetworkEdgePort()
+ port1.element = device1
+ port1.pid = device1.id + "." + "of:000000001/1"
+ port1.bwpCfgCbs = 1000000
+ port1.bwpCfgEbs = 1000000
+ port1.bwpCfgEir = 1000000
+ port1.bwpCfgCir = 1000000
+ port1.location = "San Francisco"
+ port1.name = "Central Office 1"
+ port1.latlng = "[-122.419416, 37.774929]"
objs.append(port1)
- port2 = NetworkPort()
- port2.element = self.networkdevice
- port2.pid = self.networkdevice.id + "." + "of:000000001/2"
+ port2 = NetworkEdgePort()
+ port2.element = device1
+ port2.pid = device1.id + "." + "of:000000001/2"
+ port2.bwpCfgCbs = 1000000
+ port2.bwpCfgEbs = 1000000
+ port2.bwpCfgEir = 1000000
+ port2.bwpCfgCir = 1000000
+ port2.location = "San Jose"
+ port2.name = "Central Office 2"
+ port2.latlng = "[-121.886329, 37.338208]"
objs.append(port2)
- # CORD POD1
- cordpod1device = NetworkDevice()
- cordpod1device.id = 'TestCORD1Net'
-
port3 = NetworkEdgePort()
- port3.element = cordpod1device
- port3.pid = cordpod1device.id + "." + "of:000000001/1"
+ port3.element = device1
+ port3.pid = device1.id + "." + "of:000000001/3"
port3.bwpCfgCbs = 1000000
port3.bwpCfgEbs = 1000000
port3.bwpCfgEir = 1000000
port3.bwpCfgCir = 1000000
- port3.bwpCfgCir = 1000000
+ port3.location = "Palo Alto"
+ port3.name = "Central Office 3"
+ port3.latlng = "[-122.143019, 37.441883]"
objs.append(port3)
- port4 = NetworkPort()
- port4.element = cordpod1device
- port4.pid = cordpod1device.id + "." + "of:000000001/2"
+ port4 = NetworkEdgePort()
+ port4.element = device1
+ port4.pid = device1.id + "." + "of:000000001/4"
+ port4.bwpCfgCbs = 1000000
+ port4.bwpCfgEbs = 1000000
+ port4.bwpCfgEir = 1000000
+ port4.bwpCfgCir = 1000000
+ port4.location = "Oakland"
+ port4.name = "Central Office 4"
+ port4.latlng = "[-122.271114, 37.804364]"
objs.append(port4)
- # Internal Switch 3
port5 = NetworkEdgePort()
- port5.element = cordpod1device
- port5.pid = cordpod1device.id + "." + "of:000000001/3"
+ port5.element = device1
+ port5.pid = device1.id + "." + "of:000000001/5"
port5.bwpCfgCbs = 1000000
port5.bwpCfgEbs = 1000000
port5.bwpCfgEir = 1000000
port5.bwpCfgCir = 1000000
- port5.bwpCfgCir = 1000000
+ port5.location = "San Rafael"
+ port5.name = "Central Office 5"
+ port5.latlng = "[-122.531087, 37.973535]"
objs.append(port5)
- port6 = NetworkPort()
- port6.element = cordpod1device
- port6.capacity = 1000000000
- port6.usedCapacity = 1000000000
- port6.pid = cordpod1device.id + "." + "of:000000001/4"
+ port6 = NetworkEdgePort()
+ port6.element = device1
+ port6.pid = device1.id + "." + "of:000000001/6"
+ port6.bwpCfgCbs = 1000000
+ port6.bwpCfgEbs = 1000000
+ port6.bwpCfgEir = 1000000
+ port6.bwpCfgCir = 1000000
+ port6.location = "San Mateo"
+ port6.name = "Central Office 6"
+ port6.latlng = "[-122.325525, 37.562992]"
objs.append(port6)
- # CORD POD2
- cordpod2device = NetworkDevice()
- cordpod2device.id = 'TestCORD2Net'
-
port7 = NetworkEdgePort()
- port7.element = cordpod2device
- port7.pid = cordpod2device.id + "." + "of:000000001/1"
+ port7.element = device1
+ port7.pid = device1.id + "." + "of:000000001/7"
port7.bwpCfgCbs = 1000000
port7.bwpCfgEbs = 1000000
port7.bwpCfgEir = 1000000
port7.bwpCfgCir = 1000000
- port7.bwpCfgCir = 1000000
+ port7.location = "Hayward"
+ port7.name = "Central Office 7"
+ port7.latlng = "[-122.080796, 37.668821]"
objs.append(port7)
- port8 = NetworkPort()
- port8.element = cordpod2device
- port8.pid = cordpod2device.id + "." + "of:000000001/2"
+ port8 = NetworkEdgePort()
+ port8.element = device1
+ port8.pid = device1.id + "." + "of:000000001/8"
+ port8.bwpCfgCbs = 1000000
+ port8.bwpCfgEbs = 1000000
+ port8.bwpCfgEir = 1000000
+ port8.bwpCfgCir = 1000000
+ port8.location = "Fremont"
+ port8.name = "Central Office 8"
+ port8.latlng = "[-121.988572, 37.548270]"
objs.append(port8)
- # Internal Switch 3
- port9 = NetworkEdgePort()
- port9.element = cordpod2device
- port9.pid = cordpod2device.id + "." + "of:000000001/3"
- port9.bwpCfgCbs = 1000000
- port9.bwpCfgEbs = 1000000
- port9.bwpCfgEir = 1000000
- port9.bwpCfgCir = 1000000
- port9.bwpCfgCir = 1000000
- objs.append(port9)
-
- port10 = NetworkPort()
- port10.element = cordpod2device
- port10.pid = cordpod2device.id + "." + "of:000000001/4"
- objs.append(port10)
-
return objs
def get_network_ports_for_deletion(self):
@@ -140,95 +178,68 @@
# Ok - in the test class we cheat and take down the adjunct Fake NetworkDevices Devices
device1 = NetworkDevice()
- device1.id = 'TestCORD1Net'
+ device1.id = 'TestCORDNet'
objs.append(device1)
- device2 = NetworkDevice()
- device2.id = 'TestCORD2Net'
- objs.append(device2)
-
return objs
def get_network_links(self):
objs = []
- # Metro Link Connectivity object - Point to Point
- metronetconnectivity = NetworkPointToPointConnection()
- port1 = NetworkPort()
- port1.pid = self.networkdevice.id + "." + "of:000000001/1"
- port2 = NetworkPort()
- port2.pid = self.networkdevice.id + "." + "of:000000001/2"
- metronetconnectivity.src = port1
- metronetconnectivity.dest = port2
- metronetconnectivity.type = 'direct'
- metronetconnectivity.operstate = 'active'
- metronetconnectivity.adminstate = 'enabled'
- metronetconnectivity.sid = 'MetroNetworkPointToPointConnectivity_1'
- objs.append(metronetconnectivity)
-
- # CORDPOD1 Connectivity object - Point to Point
+ # Connectivity object - Point to Point
cordpod1device = NetworkDevice()
- cordpod1device.id = 'TestCORD1Net'
-
- cordpod1connectivity = NetworkPointToPointConnection()
- port6 = NetworkPort()
- port6.pid = cordpod1device.id + "." + "of:000000001/4"
- port4 = NetworkPort()
- port4.pid = cordpod1device.id + "." + "of:000000001/2"
- cordpod1connectivity.src = port6
- cordpod1connectivity.dest = port4
- cordpod1connectivity.type = 'direct'
- cordpod1connectivity.operstate = 'active'
- cordpod1connectivity.adminstate = 'enabled'
- cordpod1connectivity.sid = 'CordPod1PointToPointConnectivity_1'
- objs.append(cordpod1connectivity)
-
- # CORDPOD2 Connectivity object - Point to Point
- cordpod2device = NetworkDevice()
- cordpod2device.id = 'TestCORD2Net'
-
- cordpod2connectivity = NetworkPointToPointConnection()
- port8 = NetworkPort()
- port8.pid = cordpod2device.id + "." + "of:000000001/2"
- port10 = NetworkPort()
- port10.pid = cordpod2device.id + "." + "of:000000001/4"
- cordpod2connectivity.src = port10
- cordpod2connectivity.dest = port8
- cordpod2connectivity.type = 'direct'
- cordpod2connectivity.operstate = 'active'
- cordpod2connectivity.adminstate = 'enabled'
- cordpod2connectivity.sid = 'CordPod2PointToPointConnectivity_1'
- objs.append(cordpod2connectivity)
-
- # InterLink object between CORDPOD1 and MetroNet
- interlink1 = NetworkInterLink()
- interlink1.src = port1
- interlink1.dest = port6
- interlink1.state = 'active'
- objs.append(interlink1)
-
- # InterLink object between CORDPOD2 and MetroNet
- interlink2 = NetworkInterLink()
- interlink2.src = port2
- interlink2.dest = port10
- interlink2.state = 'active'
- objs.append(interlink2)
+ cordpod1device.id = 'TestCORDNet'
# Edge to Edge Point Connectivity Objects
edgetoedgeconnectivity = NetworkEdgeToEdgePointConnection()
- port3 = NetworkEdgePort()
- port3.pid = cordpod1device.id + "." + "of:000000001/1"
- port7 = NetworkEdgePort()
- port7.pid = cordpod2device.id + "." + "of:000000001/1"
- edgetoedgeconnectivity.uni1 = port3
- edgetoedgeconnectivity.uni2 = port7
+ edgetoedgeconnectivity.uni1_createbuffer = cordpod1device.id + "." + "of:000000001/1"
+ edgetoedgeconnectivity.uni2_createbuffer = cordpod1device.id + "." + "of:000000001/2"
edgetoedgeconnectivity.type = 'direct'
edgetoedgeconnectivity.operstate = 'active'
edgetoedgeconnectivity.adminstate = 'enabled'
- edgetoedgeconnectivity.sid = 'EdgePointToEdgePointConnectivity_1'
+ edgetoedgeconnectivity.sid = 'EdgeToEdgePointConnectivity_1'
objs.append(edgetoedgeconnectivity)
+
+ # Multipoint to Multipoint Connectivity Objects
+ multipoint2multipointconnectivity=NetworkMultipointToMultipointConnection()
+ multipoint2multipointconnectivity.operstate = 'active'
+ multipoint2multipointconnectivity.adminstate = 'enabled'
+ multipoint2multipointconnectivity.type = 'ethernet'
+ multipoint2multipointconnectivity.sid = 'MultipointToMultipointConnectivity_1'
+
+ #
+ # Create JSON array for post-save behaviour
+ #
+ eps = []
+ eps.append(cordpod1device.id + "." + "of:000000001/3")
+ eps.append(cordpod1device.id + "." + "of:000000001/4")
+ eps.append(cordpod1device.id + "." + "of:000000001/5")
+
+ myjsonstr = {'eps': eps, 'foo':0, 'bar':0}
+ multipoint2multipointconnectivity.eps_createbuffer = json.dumps(myjsonstr)
+ objs.append(multipoint2multipointconnectivity)
+
+ # Edge to Multipoint Connectivity Objects
+ edge2multipointconnectivity = NetworkEdgeToMultipointConnection()
+ edge2multipointconnectivity.operstate = 'active'
+ edge2multipointconnectivity.adminstate = 'enabled'
+ edge2multipointconnectivity.type = 'ethernet'
+ edge2multipointconnectivity.sid = 'EdgeToMultipointConnectivity_1'
+ edge2multipointconnectivity.root_createbuffer = cordpod1device.id + "." + "of:000000001/7"
+ #
+ # Create JSON array for post-save behaviour
+ #
+ eps = []
+ eps.append(cordpod1device.id + "." + "of:000000001/6")
+ eps.append(cordpod1device.id + "." + "of:000000001/8")
+
+ myjsonstr = {'eps': eps, 'foo': 0, 'bar': 0}
+ edge2multipointconnectivity.eps_createbuffer = json.dumps(myjsonstr)
+ objs.append(edge2multipointconnectivity)
+
+
return objs
def get_network_links_for_deletion(self):
diff --git a/xos/synchronizer/steps/sync_metronetworkservice.py b/xos/synchronizer/steps/sync_metronetworkservice.py
index 724bb9a..5c3fe70 100644
--- a/xos/synchronizer/steps/sync_metronetworkservice.py
+++ b/xos/synchronizer/steps/sync_metronetworkservice.py
@@ -5,6 +5,7 @@
from services.metronetwork.models import *
from xos.logger import Logger, logging
from synchronizers.metronetwork.providers.providerfactory import ProviderFactory
+from synchronizers.metronetwork.invokers.invokerfactory import InvokerFactory
# metronetwork will be in steps/..
parentdir = os.path.join(os.path.dirname(__file__), "..")
@@ -13,9 +14,9 @@
logger = Logger(level=logging.INFO)
-class SyncMetroNetworkService(SyncStep):
- provides = [MetroNetworkService]
- observes = MetroNetworkService
+class SyncMetroNetworkSystem(SyncStep):
+ provides = [MetroNetworkSystem]
+ observes = MetroNetworkSystem
requested_interval = 0
initialized = False
@@ -35,18 +36,18 @@
objs = []
- # Get the NetworkService object - if it exists it will test us
+ # Get the NetworkSystem object - if it exists it will test us
# whether we should do a full sync or not - it all has our config
# information about the REST interface
- metronetworkservice = self.get_metronetwork_service()
- if not metronetworkservice:
+ metronetworksystem = self.get_metronetwork_system()
+ if not metronetworksystem:
logger.debug("No Service configured")
return objs
- # Check to make sure the Service is enabled
- metronetworkservice = self.get_metronetwork_service()
- if metronetworkservice.administrativeState == 'disabled':
+ # Check to make sure the Metro Network System is enabled
+ metronetworksystem = self.get_metronetwork_system()
+ if metronetworksystem.administrativeState == 'disabled':
# Nothing to do
logger.debug("MetroService configured - state is Disabled")
return objs
@@ -163,19 +164,33 @@
return objs
def sync_record(self, o):
+
+ # First we call and see if there is an invoker for this object - the idea of the invoker
+ # is to wrap the save with a pre/post paradigm to handle special cases
+ # It will only exist for a subset of ojbects
+ invoker = InvokerFactory.getinvoker(o)
+
+ # Call Pre-save on the inovker (if it exists)
+ if invoker is not None:
+ invoker.presave(o)
+
# Simply save the record to the DB - both updates and adds are handled the same way
o.save()
+ # Call Post-save on the inovker (if it exists)
+ if invoker is not None:
+ invoker.postsave(o)
+
def delete_record(self, o):
# Overriden to customize our behaviour - the core sync step for will remove the record directly
# We just log and return
logger.debug("deleting Object %s" % str(o), extra=o.tologdict())
- def get_metronetwork_service(self):
+ def get_metronetwork_system(self):
# We only expect to have one of these objects in the system in the curent design
# So get the first element from the query
- metronetworkservices = MetroNetworkService.get_service_objects().all()
- if not metronetworkservices:
+ metronetworksystem = MetroNetworkSystem.objects.all()
+ if not metronetworksystem:
return None
- return metronetworkservices[0]
+ return metronetworksystem[0]