Nokia: Putting in support for metro network services within XOS for E-CORD

Change-Id: Idbc7e09ca53b0d9705d24bf1730fd9b05347a241
diff --git a/.gitreview b/.gitreview
new file mode 100644
index 0000000..d361107
--- /dev/null
+++ b/.gitreview
@@ -0,0 +1,6 @@
+[gerrit]
+host=gerrit.opencord.org
+port=29418
+project=metronetwork.git
+defaultremote=origin
+defaultbranch=master
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..ded4f63
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright 2016 Open Networking Laboratory
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..b2730be
--- /dev/null
+++ b/README.md
@@ -0,0 +1,8 @@
+## Metronetwork Service
+
+This repository contains components needed for the XOS Metronetwork service
+
+Sub-directories
+
+* xos: A service definition for the Metronetwork. This follows the XOS component design for onboarding.
+
diff --git a/xos/admin.py b/xos/admin.py
new file mode 100644
index 0000000..f1fdddb
--- /dev/null
+++ b/xos/admin.py
@@ -0,0 +1,19 @@
+# admin.py - MetroNetworkService Django Admin
+
+from core.admin import ReadOnlyAwareAdmin
+from django.contrib import admin
+from services.metronetwork.models import *
+
+
+class MetroServiceAdmin(ReadOnlyAwareAdmin):
+    model = MetroNetworkService
+    verbose_name = "MetroNetwork Service"
+    verbose_name_plural = "MetroNetwork Services"
+    list_display = ("name", "administrativeState")
+    list_display_links = ('name',)
+    fieldsets = [(None, {
+        'fields': ['name', 'administrativeState', 'description'],
+        'classes': ['suit-tab suit-tab-general']})]
+
+
+admin.site.register(MetroNetworkService, MetroServiceAdmin)
diff --git a/xos/api/service/metronetworkservice.py b/xos/api/service/metronetworkservice.py
new file mode 100644
index 0000000..0a80034
--- /dev/null
+++ b/xos/api/service/metronetworkservice.py
@@ -0,0 +1,187 @@
+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
+from core.models.netw import NetworkEdgePort, NetworkEdgeToEdgePointConnection
+from django.core.exceptions import ObjectDoesNotExist
+from django.core import serializers as jsonserializer
+
+class MetroNetworkServiceSerializer(PlusModelSerializer):
+        id = ReadOnlyField()
+        humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
+
+        class Meta:
+            model = MetroNetworkService
+            fields = ('humanReadableName',
+                      'id',
+                      'restUrl',
+                      'administrativeState',
+                      'operationalState')
+
+        def getHumanReadableName(self, obj):
+            return obj.__unicode__()
+
+class MetroNetworkServiceViewSet(XOSViewSet):
+    base_name = "metronetworkservice"
+    method_name = "metronetworkservice/metronetwork"
+    method_kind = "viewset"
+    queryset = MetroNetworkService.get_service_objects().all()
+    serializer_class = MetroNetworkServiceSerializer
+
+    @classmethod
+    def get_urlpatterns(self, api_path="^"):
+        patterns = super(MetroNetworkServiceViewSet, 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)
+
+
+class NetworkEdgePortSerializer(PlusModelSerializer):
+    id = ReadOnlyField()
+    humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
+
+    class Meta:
+        model = NetworkEdgePort
+        fields = ('humanReadableName',
+                  'pid',
+                  'id',
+                  'element',
+                  'bwpCfgCbs',
+                  'bwpCfgEbs',
+                  'bwpCfgCir',
+                  'bwpCfgEir',
+                  'name',
+                  'location',
+                  'latlng')
+
+
+    def getHumanReadableName(self, obj):
+        return obj.id
+
+class NetworkEdgePortViewSet(XOSViewSet):
+    base_name = "SCA_ETH_FPP_UNI_N"
+    method_name = "metronetworkservice/SCA_ETH_FPP_UNI_N"
+    method_kind = "viewset"
+    queryset = NetworkEdgePort.objects.all()
+    serializer_class = NetworkEdgePortSerializer
+
+    @classmethod
+    def get_urlpatterns(self, api_path="^"):
+        patterns = super(NetworkEdgePortViewSet, 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)
+
+class NetworkEdgeToEdgePointConnectionSerializer(PlusModelSerializer):
+    humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
+    uni1 = NetworkEdgePortSerializer(required=True, read_only=False)
+    uni2 = NetworkEdgePortSerializer(required=True, read_only=False)
+
+    class Meta:
+        model = NetworkEdgeToEdgePointConnection
+
+        fields = ('humanReadableName',
+                  'sid',
+                  'id',
+                  'type',
+                  'uni1',
+                  'uni2',
+                  'operstate',
+                  'adminstate'
+                  )
+
+    def getHumanReadableName(self, obj):
+        return obj.id
+
+class NetworkEdgeToEdgePointConnectionViewSet(XOSViewSet):
+    base_name = "SCA_ETH_FDFr_EC"
+    method_name = "metronetworkservice/SCA_ETH_FDFr_EC"
+    method_kind = "viewset"
+    queryset = NetworkEdgeToEdgePointConnection.objects.all()
+    serializer_class = NetworkEdgeToEdgePointConnectionSerializer
+
+    @classmethod
+    def get_urlpatterns(self, api_path="^"):
+        patterns = super(NetworkEdgeToEdgePointConnectionViewSet, 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):
+        ELineConnectionToDelete = NetworkEdgeToEdgePointConnection.objects.get(pk=pk)
+
+        if (ELineConnectionToDelete):
+            ELineConnectionToDelete.adminstate = 'deactivationrequested'
+            ELineConnectionToDelete.save()
+        else:
+            return Response(status=status.HTTP_400_BAD_REQUEST)
+
+        return Response(status=status.HTTP_200_OK)
+
+
+    def create(self, validated_data):
+
+        ELineConnection = NetworkEdgeToEdgePointConnection()
+        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')
+
+        uni1 = validated_data.data.get('uni1')
+        uni2 = validated_data.data.get('uni2')
+
+        uni1 = NetworkEdgePort.objects.get(pk=uni1['id'])
+        uni2 = NetworkEdgePort.objects.get(pk=uni2['id'])
+
+        ELineConnection.uni1 = uni1
+        ELineConnection.uni2 = uni2
+        ELineConnection.save()
+
+        response_data = {}
+        response_data['sid'] = ELineConnection.sid
+        response_data['adminstate'] = ELineConnection.adminstate
+        response_data['operstate'] = ELineConnection.operstate
+        response_data['type'] = ELineConnection.type
+
+        response_data['uni1'] = {}
+        response_data['uni1']['id'] = uni1.id
+        response_data['uni1']['pid'] = uni1.pid
+        response_data['uni1']['bwpCfgCbs'] = uni1.bwpCfgCbs
+        response_data['uni1']['bwpCfgEbs'] = uni1.bwpCfgEbs
+        response_data['uni1']['bwpCfgCir'] = uni1.bwpCfgCir
+        response_data['uni1']['bwpCfgEir'] = uni1.bwpCfgEir
+        response_data['uni1']['name'] = uni1.name
+        response_data['uni1']['location'] = uni1.location
+        response_data['uni1']['latlng'] = uni1.latlng
+
+        response_data['uni2'] = {}
+        response_data['uni2']['id'] = uni2.id
+        response_data['uni2']['pid'] = uni2.pid
+        response_data['uni2']['bwpCfgCbs'] = uni2.bwpCfgCbs
+        response_data['uni2']['bwpCfgEbs'] = uni2.bwpCfgEbs
+        response_data['uni2']['bwpCfgCir'] = uni2.bwpCfgCir
+        response_data['uni2']['bwpCfgEir'] = uni2.bwpCfgEir
+        response_data['uni2']['name'] = uni1.name
+        response_data['uni2']['location'] = uni1.location
+        response_data['uni2']['latlng'] = uni1.latlng
+
+        return Response(response_data)
\ No newline at end of file
diff --git a/xos/make_synchronizer_manifest.sh b/xos/make_synchronizer_manifest.sh
new file mode 100755
index 0000000..4058982
--- /dev/null
+++ b/xos/make_synchronizer_manifest.sh
@@ -0,0 +1,2 @@
+#! /bin/bash
+find synchronizer -type f | cut -b 14- > synchronizer/manifest 
diff --git a/xos/metronetworkservice-onboard.yaml b/xos/metronetworkservice-onboard.yaml
new file mode 100644
index 0000000..b8a966d
--- /dev/null
+++ b/xos/metronetworkservice-onboard.yaml
@@ -0,0 +1,20 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: Onboard the metronetwork service
+
+imports:
+   - custom_types/xos.yaml
+
+topology_template:
+  node_templates:
+    metronetwork:
+      type: tosca.nodes.ServiceController
+      properties:
+          base_url: file:///opt/xos_services/metro-net/xos/
+          # The following will concatenate with base_url automatically, if
+          # base_url is non-null.
+          models: models.py
+          admin: admin.py
+          rest_service: api/service/metronetworkservice.py
+          synchronizer: synchronizer/manifest
+          synchronizer_run: metronetworkervice-synchronizer.py
\ No newline at end of file
diff --git a/xos/models.py b/xos/models.py
new file mode 100644
index 0000000..2c68fab
--- /dev/null
+++ b/xos/models.py
@@ -0,0 +1,56 @@
+# models.py -  Metro Network Service
+
+from django.db import models
+from core.models import Service
+
+METRONETWORK_KIND = "metronetwork"
+SERVICE_NAME = 'metronetwork'
+SERVICE_NAME_VERBOSE = 'Metro Network Service'
+
+class MetroNetworkService(Service):
+
+    KIND = METRONETWORK_KIND
+
+    class Meta:
+        app_label = SERVICE_NAME
+        verbose_name = SERVICE_NAME_VERBOSE
+
+    ADMINISTRATIVE_STATE = (
+        ('enabled', 'Enabled'),
+        ('disabled', 'Disabled')
+    )
+
+    OPERATIONALSTATE = (
+        ('active', 'Active'),
+        ('inactive', 'Inactive')
+    )
+
+    restUrl = models.CharField(verbose_name="Rest URL",
+                               max_length=256,
+                               editable=True)
+
+    administrativeState = models.CharField(choices=ADMINISTRATIVE_STATE,
+                                           default='disabled',
+                                           verbose_name="AdministrativeState",
+                                           max_length=16,
+                                           editable=True)
+
+    operationalState = models.CharField(choices=OPERATIONALSTATE,
+                                        verbose_name="OperationalState",
+                                        max_length=256,
+                                        editable=True)
+
+    def __init__(self, *args, **kwargs):
+        super(MetroNetworkService, self).__init__(*args, **kwargs)
+
+    def getAdminstrativeState(self):
+         return self.administrativeState
+
+    def setAdminstrativeState(self, value):
+        self.administrativeState = value
+
+    def getOperationalState(self):
+        return self.operationalState
+
+    def getRestUrl(self):
+        return self.restUrl
\ No newline at end of file
diff --git a/xos/synchronizer/__init__.py b/xos/synchronizer/__init__.py
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/xos/synchronizer/__init__.py
@@ -0,0 +1 @@
+
diff --git a/xos/synchronizer/manifest b/xos/synchronizer/manifest
new file mode 100644
index 0000000..3f33fbc
--- /dev/null
+++ b/xos/synchronizer/manifest
@@ -0,0 +1,14 @@
+metronetwork-synchronizer.py
+__init__.py
+model-deps
+providers/metronetworktestprovider.py
+providers/metronetworkrestprovider.py
+providers/providerfactory.py
+providers/__init__.py
+providers/metronetworkprovider.py
+run_devel.sh
+metronetwork-synchronizer-devel.py
+manifest
+steps/sync_metronetworkservice.py
+run.sh
+metronetwork_synchronizer_config
diff --git a/xos/synchronizer/metronetwork-synchronizer-devel.py b/xos/synchronizer/metronetwork-synchronizer-devel.py
new file mode 100755
index 0000000..df697ec
--- /dev/null
+++ b/xos/synchronizer/metronetwork-synchronizer-devel.py
@@ -0,0 +1,13 @@
+#!/usr/bin/env python
+
+# This imports and runs ../../xos-observer.py
+
+import importlib
+import os
+import sys
+
+#observer_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../synchronizers/base")
+sys.path.append("/opt/xos/synchronizers/base")
+print sys.path
+mod = importlib.import_module("xos-synchronizer")
+mod.main()
diff --git a/xos/synchronizer/metronetwork-synchronizer.py b/xos/synchronizer/metronetwork-synchronizer.py
new file mode 100755
index 0000000..64d0b08
--- /dev/null
+++ b/xos/synchronizer/metronetwork-synchronizer.py
@@ -0,0 +1,12 @@
+#!/usr/bin/env python
+
+# This imports and runs ../../xos-observer.py
+
+import importlib
+import os
+import sys
+
+observer_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../synchronizers/base")
+sys.path.append(observer_path)
+mod = importlib.import_module("xos-synchronizer")
+mod.main()
diff --git a/xos/synchronizer/metronetwork_synchronizer_config b/xos/synchronizer/metronetwork_synchronizer_config
new file mode 100644
index 0000000..86847b9
--- /dev/null
+++ b/xos/synchronizer/metronetwork_synchronizer_config
@@ -0,0 +1,38 @@
+
+[plc]
+name=plc
+deployment=VICCI
+
+[db]
+name=xos
+user=postgres
+password=password
+host=localhost
+port=5432
+
+[api]
+host=128.112.171.237
+port=8000
+ssl_key=None
+ssl_cert=None
+ca_ssl_cert=None
+ratelimit_enabled=0
+omf_enabled=0
+mail_support_address=support@localhost
+nova_enabled=True
+
+[observer]
+name=metronetwork
+dependency_graph=/opt/xos/synchronizers/metronetwork/model-deps
+steps_dir=/opt/xos/synchronizers/metronetwork/steps
+sys_dir=/opt/xos/synchronizers/metronetwork/sys
+deleters_dir=/opt/xos/synchronizers/metronetwork/deleters
+log_file=console
+driver=None
+pretend=False
+backoff_disabled=True
+fofum_disabled=True
+
+[feefie]
+client_id='vicci_dev_central'
+user_id='pl'
diff --git a/xos/synchronizer/model-deps b/xos/synchronizer/model-deps
new file mode 100644
index 0000000..0967ef4
--- /dev/null
+++ b/xos/synchronizer/model-deps
@@ -0,0 +1 @@
+{}
diff --git a/xos/synchronizer/providers/__init__.py b/xos/synchronizer/providers/__init__.py
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/xos/synchronizer/providers/__init__.py
@@ -0,0 +1 @@
+
diff --git a/xos/synchronizer/providers/metronetworkprovider.py b/xos/synchronizer/providers/metronetworkprovider.py
new file mode 100644
index 0000000..db651c3
--- /dev/null
+++ b/xos/synchronizer/providers/metronetworkprovider.py
@@ -0,0 +1,95 @@
+from xos.logger import Logger, logging
+from core.models.netw import *
+
+logger = Logger(level=logging.INFO)
+
+
+class MetroNetworkProvider(object):
+    networkdevice = None
+
+    def __init__(self, networkdevice, **args):
+        self.networkdevice = networkdevice
+        pass
+
+    # Methods to support for Synchronization - effectively list all interfaces
+    #
+    # Method for retrieving all network ports from the backend system
+    # Intended for use when doing a re-sync
+    def get_network_ports(self):
+        # Default method needs to be overriden
+        logger.debug("get_network_ports default called - should be overriden")
+
+    # Method for getting a list of network ports to delete
+    # The default imnplementation just gets a list from the local DB
+    # Intended for use when doing a re-sync
+    def get_network_ports_for_deletion(self):
+        # 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
+    # Includes Connectivity Objects
+    # Intended for use when doing a re-sync
+    def get_network_links(self):
+        # Default method needs to be overriden
+        logger.debug("get_network_links default called - should be overriden")
+        objs = []
+        return objs
+
+    # Method for getting a list of network links to delete
+    # Includes Connectivity Objects
+    # Intended for use when doing a re-sync
+    def get_network_links_for_deletion(self):
+        # Default method needs to be overriden
+        logger.debug("get_network_links for deletion called - should be overidden")
+        objs = []
+        return objs
+
+    # Methods to support Event Management - movement of changes from the Domain to XOS
+    #
+    # Method for Create and Update - Create and Update are together given the base design
+    def get_updated_or_created_objects(self):
+        # Default method needs to be overriden
+        logger.debug("get_updated_or_created_objects default called - should be overriden")
+        objs = []
+        return objs
+
+    # Method for Delete - Create and Update are together given the base design
+    def get_deleted_objects(self):
+        # Default method needs to be overriden
+        logger.debug("get_deleted_objects default called - should be overriden")
+        objs = []
+        return objs
+
+    # Methods to support Movement of changes from XOS into the Domain
+    #
+    # Method for creating point to point connectivity object
+    #
+    # obj     - Connection object - with all configuration variables set
+    # returns - Boolean - indicating whether or not the request succeeded - in either case the Admin/Oper
+    #                     states are assigned - if False the backend_status field
+    #                     should be assigned with the appropriate error code - in the case of True the
+    #                     backend_status will be assigned by the system and should be unassigned
+
+    def create_point_to_point_connectivity(self, obj):
+        # Default method needs to be overriden
+        logger.debug("create_point_to_point_connectivity called - should be overriden")
+        return False
+
+    # Method for deleting point to point connectivity object
+    #
+    # obj     - Connection object
+    # returns - Boolean - indicating whether or not the request succeeded - in either case the Admin/Oper
+    #                     states are assigned - if False the backend_status field
+    #                     should be assigned with the appropriate error code - in the case of True the
+    #                     backend_status will be assigned by the system and should be unassigned
+    def delete_point_to_point_connectivity(self, obj):
+        # Default method needs to be overriden
+        logger.debug("delete_point_to_point_connectivity called - should be overriden")
+        return False
diff --git a/xos/synchronizer/providers/metronetworkrestprovider.py b/xos/synchronizer/providers/metronetworkrestprovider.py
new file mode 100644
index 0000000..fa9ef71
--- /dev/null
+++ b/xos/synchronizer/providers/metronetworkrestprovider.py
@@ -0,0 +1,232 @@
+from xos.logger import Logger, logging

+from core.models.netw import *

+from synchronizers.metronetwork.providers.metronetworkprovider import MetroNetworkProvider

+

+import requests, json

+from requests.auth import HTTPBasicAuth

+

+logger = Logger(level=logging.INFO)

+

+

+class MetroNetworkRestProvider(MetroNetworkProvider):

+    def __init__(self, networkdevice, **args):

+        MetroNetworkProvider.__init__(self, networkdevice, **args)

+

+    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_links(self):

+

+        objs = []

+

+        restCtrlUrl = self.networkdevice.restCtrlUrl

+        username = self.networkdevice.username

+        password = self.networkdevice.password

+

+        resp = requests.get("{}/mef-sca-api/SCA_ETH_FDFr_EC/findByState?state=Active".format(restCtrlUrl),

+                            auth=HTTPBasicAuth(username, password))

+

+        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

+

+        else:

+            raise Exception("OnosApiError: get_network_links()")

+

+    def create_point_to_point_connectivity(self, obj):

+

+        restCtrlUrl = self.networkdevice.restCtrlUrl

+        username = self.networkdevice.username

+        password = self.networkdevice.password

+

+        evcServiceType = obj.type

+        # evcServiceType = "Point_To_Point"

+

+        uni1 = obj.uni1

+        uni1Id = uni1.pid

+        uni1IdToken = (uni1Id.split('.', 1))[1].split('/', 1)

+        uni1Hostname = uni1IdToken[0]

+        uni1Port = uni1IdToken[1]

+        uni1BwpCfgCbs = uni1.bwpCfgCbs

+        uni1BwpCfgEbs = uni1.bwpCfgEbs

+        uni1BwpCfgCir = uni1.bwpCfgCir

+        uni1BwpCfgEir = uni1.bwpCfgEir

+

+        uni2 = obj.uni2

+        uni2Id = uni2.pid

+        uni2IdToken = (uni2Id.split('.', 1))[1].split('/', 1)

+        uni2Hostname = uni2IdToken[0]

+        uni2Port = uni2IdToken[1]

+        uni2BwpCfgCbs = uni2.bwpCfgCbs

+        uni2BwpCfgEbs = uni2.bwpCfgEbs

+        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}}}]

+        }

+

+        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))

+

+        if resp.status_code == 201:

+            result = resp.json()

+            message = result['message']

+

+            msg_token = message.split()

+            for i, token in enumerate(msg_token):

+                if token == 'id':

+                    service_id = msg_token[i + 1]

+                    obj.sid = service_id

+                    obj.adminstate = "enabled"

+                    obj.operstate = "active"

+

+                    return True

+

+        elif resp.status_code == 204:

+            obj.adminstate = "invalid"  # what's the meaning?

+            obj.operstate = "inactive"

+            obj.backend_status = '204 - No network resource'

+            return False

+

+        elif resp.status_code == 500:

+            obj.adminstate = "enabled"

+            obj.operstate = "inactive"

+            obj.backend_status = '500 - Internal Server Error'

+            return False

+

+        else:

+            raise Exception("OnosApiError: create_point_to_point_connectivity()")

+

+    def delete_point_to_point_connectivity(self, obj):

+

+        restCtrlUrl = self.networkdevice.restCtrlUrl

+        username = self.networkdevice.username

+        password = self.networkdevice.password

+        evcId = obj.sid

+

+        resp = requests.delete("{}/mef-sca-api/SCA_ETH_FDFr_EC/{}".format(restCtrlUrl, evcId),

+                               auth=HTTPBasicAuth(username, password))

+

+        if resp.status_code == 200:

+            obj.adminstate = 'disabled'

+            obj.operstate = 'inactive'

+            return True

+

+        elif resp.status_code == 204:

+            obj.adminstate = "invalid"  # what's the meaning?

+            obj.backend_status = '204 - No such network resource: {}'.format(evcId)

+            return False

+

+        elif resp.status_code == 500:

+            obj.adminstate = "disabled"

+            obj.backend_status = '500 - Internal Server Error'

+            return False

+

+        else:

+            raise Exception("OnosApiError: delete_point_to_point_connectivity()")

diff --git a/xos/synchronizer/providers/metronetworktestprovider.py b/xos/synchronizer/providers/metronetworktestprovider.py
new file mode 100644
index 0000000..b88427d
--- /dev/null
+++ b/xos/synchronizer/providers/metronetworktestprovider.py
@@ -0,0 +1,284 @@
+import random
+
+from xos.logger import Logger, logging
+from core.models.netw import *
+from synchronizers.metronetwork.providers.metronetworkprovider import MetroNetworkProvider
+
+logger = Logger(level=logging.INFO)
+
+
+class MetroNetworkTestProvider(MetroNetworkProvider):
+    def __init__(self, networkdevice, **args):
+        MetroNetworkProvider.__init__(self, networkdevice, **args)
+
+    # 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
+
+        objs = []
+
+        # For The Test Provider we don't handle re-sync for anything but the Metro Test Network
+        if self.networkdevice.id != 'TestMetroNet':
+            return objs
+
+        # Ok - in the test class we cheat and create the adjunct NetworkDevices Devices
+        device1 = NetworkDevice()
+        device1.id = 'TestCORD1Net'
+        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"
+        objs.append(port1)
+
+        port2 = NetworkPort()
+        port2.element = self.networkdevice
+        port2.pid = self.networkdevice.id + "." + "of:000000001/2"
+        objs.append(port2)
+
+        # CORD POD1
+        cordpod1device = NetworkDevice()
+        cordpod1device.id = 'TestCORD1Net'
+
+        port3 = NetworkEdgePort()
+        port3.element = cordpod1device
+        port3.pid = cordpod1device.id + "." + "of:000000001/1"
+        port3.bwpCfgCbs = 1000000
+        port3.bwpCfgEbs = 1000000
+        port3.bwpCfgEir = 1000000
+        port3.bwpCfgCir = 1000000
+        port3.bwpCfgCir = 1000000
+        objs.append(port3)
+
+        port4 = NetworkPort()
+        port4.element = cordpod1device
+        port4.pid = cordpod1device.id + "." + "of:000000001/2"
+        objs.append(port4)
+
+        # Internal Switch 3
+        port5 = NetworkEdgePort()
+        port5.element = cordpod1device
+        port5.pid = cordpod1device.id + "." + "of:000000001/3"
+        port5.bwpCfgCbs = 1000000
+        port5.bwpCfgEbs = 1000000
+        port5.bwpCfgEir = 1000000
+        port5.bwpCfgCir = 1000000
+        port5.bwpCfgCir = 1000000
+        objs.append(port5)
+
+        port6 = NetworkPort()
+        port6.element = cordpod1device
+        port6.capacity = 1000000000
+        port6.usedCapacity = 1000000000
+        port6.pid = cordpod1device.id + "." + "of:000000001/4"
+        objs.append(port6)
+
+        # CORD POD2
+        cordpod2device = NetworkDevice()
+        cordpod2device.id = 'TestCORD2Net'
+
+        port7 = NetworkEdgePort()
+        port7.element = cordpod2device
+        port7.pid = cordpod2device.id + "." + "of:000000001/1"
+        port7.bwpCfgCbs = 1000000
+        port7.bwpCfgEbs = 1000000
+        port7.bwpCfgEir = 1000000
+        port7.bwpCfgCir = 1000000
+        port7.bwpCfgCir = 1000000
+        objs.append(port7)
+
+        port8 = NetworkPort()
+        port8.element = cordpod2device
+        port8.pid = cordpod2device.id + "." + "of:000000001/2"
+        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):
+
+        objs = []
+
+        # For The Test Provider we don't handle re-sync for anything but the Metro Test Network
+        if self.networkdevice.id != 'TestMetroNet':
+            return objs
+
+        allports = MetroNetworkProvider.get_network_ports_for_deletion(self)
+
+        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 = 'TestCORD1Net'
+        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
+        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)
+
+        # 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.type = 'direct'
+        edgetoedgeconnectivity.operstate = 'active'
+        edgetoedgeconnectivity.adminstate = 'enabled'
+        edgetoedgeconnectivity.sid = 'EdgePointToEdgePointConnectivity_1'
+        objs.append(edgetoedgeconnectivity)
+
+        return objs
+
+    def get_network_links_for_deletion(self):
+
+        # For now we'll rely on cascade deletes in the port area - so from the test provider nothing to do
+        objs = []
+        return objs
+
+    def create_point_to_point_connectivity(self, obj):
+
+        # Ok - here is what we'll do to simulate the 'real world' - get a random number between 1 and 10
+        # 1-7 is considered 'successful' 8 is considered a transient error - 9 is a configuration problem
+        # 10 is a - resource exhausted problem - there you go!!
+        scenario = random.randint(1, 10)
+
+        if (scenario >= 1 and scenario <= 7):
+            obj.adminstate = 'enabled'
+            obj.operstate = 'active'
+            return True
+        elif (scenario == 8):
+            obj.adminstate = 'enabled'
+            obj.operstate = 'inactive'
+            obj.backend_status = '8 - Transient Server Error'
+            return False
+        elif (scenario == 9):
+            obj.adminstate = 'invalid'
+            obj.operstate = 'inactive'
+            obj.backend_status = '9 - Configuration Error'
+            return False
+        else:
+            obj.adminstate = 'enabled'
+            obj.operstate = 'inactive'
+            obj.backend_status = '10 - Resource Exhaustion'
+            return False
+
+    def delete_point_to_point_connectivity(self, obj):
+
+        # Ok - here is what we'll do to simulate the 'real world' - get a random number between 1 and 10
+        # 1-8 is considered 'successful' 8 is considered a transient error - 9 is a configuration problem
+        scenario = random.randint(1, 10)
+
+        if (scenario >= 1 and scenario <= 8):
+            obj.adminstate = 'disabled'
+            obj.operstate = 'inactive'
+            return True
+        elif (scenario == 9):
+            obj.adminstate = 'disabled'
+            obj.backend_status = '8 - Transient Server Error'
+            return False
+        else:
+            obj.adminstate = 'invalid'
+            obj.backend_status = '9 - Configuration Error'
+            return False
diff --git a/xos/synchronizer/providers/providerfactory.py b/xos/synchronizer/providers/providerfactory.py
new file mode 100644
index 0000000..9ef6cb8
--- /dev/null
+++ b/xos/synchronizer/providers/providerfactory.py
@@ -0,0 +1,21 @@
+import sys
+
+from synchronizers.metronetwork.providers.metronetworktestprovider import MetroNetworkTestProvider
+from synchronizers.metronetwork.providers.metronetworkrestprovider import MetroNetworkRestProvider
+
+
+class ProviderFactory(object):
+    @staticmethod
+    def getprovider(networkdevice):
+
+        undertest = False
+
+        # We either return Test or Rest
+        # By convention a NetworkDevice with name TestDomain will use test objects
+        if networkdevice.id == 'TestMetroNet' or networkdevice.id == 'TestCORD1Net' or networkdevice.id == 'TestCORD2Net':
+            undertest = True
+
+        if undertest:
+            return MetroNetworkTestProvider(networkdevice)
+        else:
+            return MetroNetworkRestProvider(networkdevice)
diff --git a/xos/synchronizer/run.sh b/xos/synchronizer/run.sh
new file mode 100755
index 0000000..87b6b7d
--- /dev/null
+++ b/xos/synchronizer/run.sh
@@ -0,0 +1,2 @@
+export XOS_DIR=/opt/xos
+python metronetwork-synchronizer.py  -C $XOS_DIR/synchronizers/metronetwork/metronetwork_synchronizer_config
diff --git a/xos/synchronizer/run_devel.sh b/xos/synchronizer/run_devel.sh
new file mode 100755
index 0000000..1fc515d
--- /dev/null
+++ b/xos/synchronizer/run_devel.sh
@@ -0,0 +1,2 @@
+export XOS_DIR=/opt/xos
+python metronetwork-synchronizer-devel.py  -C $XOS_DIR/synchronizers/metronetwork/metronetwork_synchronizer_config
diff --git a/xos/synchronizer/steps/sync_metronetworkservice.py b/xos/synchronizer/steps/sync_metronetworkservice.py
new file mode 100644
index 0000000..3b5bf27
--- /dev/null
+++ b/xos/synchronizer/steps/sync_metronetworkservice.py
@@ -0,0 +1,182 @@
+import os
+import sys
+
+from synchronizers.base.syncstep import SyncStep
+from core.models.netw import *
+from services.metronetwork.models import MetroNetworkService
+from xos.logger import Logger, logging
+from synchronizers.metronetwork.providers.providerfactory import ProviderFactory
+
+# metronetwork will be in steps/..
+parentdir = os.path.join(os.path.dirname(__file__), "..")
+sys.path.insert(0, parentdir)
+
+logger = Logger(level=logging.INFO)
+
+
+class SyncMetroNetworkService(SyncStep):
+    provides = [MetroNetworkService]
+    observes = MetroNetworkService
+    requested_interval = 0
+    initialized = False
+
+    def __init__(self, **args):
+        SyncStep.__init__(self, **args)
+
+    def fetch_pending(self, deletion=False):
+
+        # The general idea:
+        # We do one of two things in here:
+        #    1. Full Synchronization of the DBS (XOS <-> MetroONOS)
+        #    2. Look for updates between the two stores
+        # The first thing is potentially a much bigger
+        # operation and should not happen as often
+        #
+        # The Sync operation must take into account the 'deletion' flag
+
+        objs = []
+
+        # Get the NetworkService 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:
+            logger.debug("No Service configured")
+            return objs
+
+        # Check to make sure the Service is enabled
+        metronetworkservice = self.get_metronetwork_service()
+        if metronetworkservice.administrativeState == 'disabled':
+            # Nothing to do
+            logger.debug("MetroService configured - state is Disabled")
+            return objs
+
+        # The Main Loop - retrieve all the NetworkDevice objects - for each of these
+        # Apply synchronization aspects
+        networkdevices = NetworkDevice.objects.all()
+
+        for dev in networkdevices:
+
+            # Set up the provider
+            provider = ProviderFactory.getprovider(dev)
+
+            # First check is for the AdminState of Disabled - do nothing
+            if dev.administrativeState == 'disabled':
+                # Nothing to do with this device
+                logger.debug("NetworkDevice %s: administrativeState set to Disabled - continuing" % dev.id)
+
+            # Now to the main options - are we syncing - deletion portion
+            elif dev.administrativeState == 'syncrequested' and deletion is True:
+
+                logger.info("NetworkDevice %s: administrativeState set to SyncRequested" % dev.id)
+
+                # Kill Links
+                networklinks = provider.get_network_links_for_deletion()
+                for link in networklinks:
+                    objs.append(link)
+
+                # Kill Ports
+                allports = provider.get_network_ports_for_deletion()
+                for port in allports:
+                    objs.append(port)
+
+                logger.info("NetworkDevice %s: Deletion part of Sync completed" % dev.id)
+                dev.administrativeState = 'syncinprogress'
+                dev.save(update_fields=['administrativeState'])
+
+            # Now to the main options - are we syncing - creation portion
+            elif dev.administrativeState == 'syncinprogress' and deletion is False:
+
+                logger.info("NetworkDevice %s: administrativeState set to SyncRequested" % dev.id)
+                # Reload objects in the reverse order of deletion
+
+                # Add Ports
+                networkports = provider.get_network_ports()
+                for port in networkports:
+                    objs.append(port)
+
+                # Add Links
+                networklinks = provider.get_network_links()
+                for link in networklinks:
+                    objs.append(link)
+
+                logger.info("NetworkDevice %s: Creation part of Sync completed" % dev.id)
+                dev.administrativeState = 'enabled'
+                dev.save(update_fields=['administrativeState'])
+
+            # If we are enabled - then check for events - in either direction and sync
+            elif dev.administrativeState == 'enabled' and deletion is False:
+                logger.debug("NetworkDevice: administrativeState set to Enabled - non deletion phase")
+
+                # This should be the 'normal running state' when we are not deleting - a few things to do in here
+
+                # Get the changed objects from the provider - deletions are handled separately
+                eventobjs = provider.get_updated_or_created_objects()
+                for eventobj in eventobjs:
+                    # Simply put in the queue for update - this will handle both new and changed objects
+                    objs.append(eventobj)
+
+                # Handle changes XOS -> ONOS
+                # Check for ConnectivityObjects that are in acticationequested state - creates to the backend
+                activatereqs = NetworkEdgeToEdgePointConnection.objects.filter(adminstate='activationrequested')
+                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)):
+                        # Everyting is OK, lets let the system handle the persist
+                        objs.append(activatereq)
+                    else:
+                        # In the case of an error we persist the state of the object directly to preserve
+                        # the error code - and because that is how the base synchronizer is designed
+                        activatereq.save()
+
+                # Check for ConnectivityObjects that are in deacticationequested state - deletes to the backend
+                deactivatereqs = NetworkEdgeToEdgePointConnection.objects.filter(adminstate='deactivationrequested')
+                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):
+                        # Everyting is OK, lets let the system handle the persist
+                        objs.append(deactivatereq)
+                    else:
+                        # In the case of an error we persist the state of the object directly to preserve
+                        # the error code - and because that is how the base synchronizer is designed
+                        deactivatereq.save()
+
+            # If we are enabled - and in our deletion pass then look for objects waiting for deletion
+            elif dev.administrativeState == 'enabled' and deletion is True:
+                logger.debug("NetworkDevice: administrativeState set to Enabled - deletion phase")
+
+                # Any object that is simply deleted in the model gets removed automatically - the synchronizer
+                # doesn't get involved - we just need to check for deleted objects in the domain and reflect that
+                # in the model
+                #
+                # Get the deleted objects from the provider
+                eventobjs = provider.get_deleted_objects()
+                for eventobj in eventobjs:
+                    # Simply put in the queue for update - this will handle both new and changed objects
+                    objs.append(eventobj)
+
+        # In add cases return the objects we are interested in
+        return objs
+
+    def sync_record(self, o):
+        # Simply save the record to the DB - both updates and adds are handled the same way
+        o.save()
+
+    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):
+        # 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:
+            return None
+
+        return metronetworkservices[0]