CORD-1849 Split XOS code out of OLT and VTN repos

Change-Id: I307b2a9a54fdcdab14e6bf96d9a9b060ff421a77
diff --git a/xos/admin.py b/xos/admin.py
new file mode 100644
index 0000000..6ab7524
--- /dev/null
+++ b/xos/admin.py
@@ -0,0 +1,171 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# 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.
+
+
+from django.contrib import admin
+
+from services.volt.models import *
+from django import forms
+from django.utils.safestring import mark_safe
+from django.contrib.auth.admin import UserAdmin
+from django.contrib.admin.widgets import FilteredSelectMultiple
+from django.contrib.auth.forms import ReadOnlyPasswordHashField
+from django.contrib.auth.signals import user_logged_in
+from django.utils import timezone
+from django.contrib.contenttypes import generic
+from suit.widgets import LinkedSelect
+from core.admin import ServiceAppAdmin,SliceInline,ServiceAttrAsTabInline, ReadOnlyAwareAdmin, XOSTabularInline, ServicePrivilegeInline, SubscriberLinkInline, ProviderLinkInline, ProviderDependencyInline,SubscriberDependencyInline
+from core.middleware import get_request
+
+from functools import update_wrapper
+from django.contrib.admin.views.main import ChangeList
+from django.core.urlresolvers import reverse
+from django.contrib.admin.utils import quote
+
+#-----------------------------------------------------------------------------
+# vOLT
+#-----------------------------------------------------------------------------
+
+class VOLTServiceAdmin(ReadOnlyAwareAdmin):
+    model = VOLTService
+    verbose_name = "vOLT Service"
+    verbose_name_plural = "vOLT Service"
+    list_display = ("backend_status_icon", "name", "enabled")
+    list_display_links = ('backend_status_icon', 'name', )
+    fieldsets = [(None, {'fields': ['backend_status_text', 'name','enabled','versionNumber', 'description',"view_url","icon_url" ], 'classes':['suit-tab suit-tab-general']})]
+    readonly_fields = ('backend_status_text', )
+    inlines = [SliceInline,ServiceAttrAsTabInline,ServicePrivilegeInline,ProviderDependencyInline,SubscriberDependencyInline]
+
+    extracontext_registered_admins = True
+
+    user_readonly_fields = ["name", "enabled", "versionNumber", "description"]
+
+    suit_form_tabs =(('general', 'vOLT Service Details'),
+        ('administration', 'Administration'),
+        #('tools', 'Tools'),
+        ('slices','Slices'),
+        ('serviceattrs','Additional Attributes'),
+        ('servicetenants', 'Dependencies'),
+        ('serviceprivileges','Privileges'),
+    )
+
+    suit_form_includes = (('voltadmin.html', 'top', 'administration'),
+                           ) #('hpctools.html', 'top', 'tools') )
+
+class VOLTTenantForm(forms.ModelForm):
+    s_tag = forms.CharField()
+    c_tag = forms.CharField()
+    creator = forms.ModelChoiceField(queryset=User.objects.all())
+
+    def __init__(self,*args,**kwargs):
+        super (VOLTTenantForm,self ).__init__(*args,**kwargs)
+        self.fields['owner'].queryset = VOLTService.objects.all()
+        if self.instance:
+            # fields for the attributes
+            self.fields['c_tag'].initial = self.instance.c_tag
+            self.fields['s_tag'].initial = self.instance.s_tag
+            self.fields['creator'].initial = self.instance.creator
+        if (not self.instance) or (not self.instance.pk):
+            # default fields for an 'add' form
+            self.fields['creator'].initial = get_request().user
+            if VOLTService.objects.exists():
+               self.fields["owner"].initial = VOLTService.objects.all()[0]
+
+    def save(self, commit=True):
+        self.instance.s_tag = self.cleaned_data.get("s_tag")
+        self.instance.c_tag = self.cleaned_data.get("c_tag")
+        self.instance.creator = self.cleaned_data.get("creator")
+        return super(VOLTTenantForm, self).save(commit=commit)
+
+    class Meta:
+        model = VOLTTenant
+        fields = '__all__'
+
+
+class VOLTTenantAdmin(ReadOnlyAwareAdmin):
+    list_display = ('backend_status_icon', 'id', 'service_specific_id', 's_tag', 'c_tag', )
+    list_display_links = ('backend_status_icon', 'id')
+    fieldsets = [ (None, {'fields': ['backend_status_text', 'owner', 'service_specific_id', # 'service_specific_attribute',
+                                     's_tag', 'c_tag', 'creator'],
+                          'classes':['suit-tab suit-tab-general']})]
+    readonly_fields = ('backend_status_text', 'service_specific_attribute')
+    inlines = (ProviderLinkInline, SubscriberLinkInline)
+    form = VOLTTenantForm
+
+    suit_form_tabs = (('general','Details'), ('servicelinks','Links'),)
+
+    def get_queryset(self, request):
+        return VOLTTenant.select_by_user(request.user)
+
+class AccessDeviceInline(XOSTabularInline):
+    model = AccessDevice
+    fields = ['volt_device','uplink','vlan']
+    readonly_fields = []
+    extra = 0
+#    max_num = 0
+    suit_classes = 'suit-tab suit-tab-accessdevices'
+
+#    @property
+#    def selflink_reverse_path(self):
+#        return "admin:cord_volttenant_change"
+
+class VOLTDeviceAdmin(ReadOnlyAwareAdmin):
+    list_display = ('backend_status_icon', 'name', 'openflow_id', 'driver' )
+    list_display_links = ('backend_status_icon', 'name', 'openflow_id')
+    fieldsets = [ (None, {'fields': ['backend_status_text','name','volt_service','openflow_id','driver','access_agent'],
+                          'classes':['suit-tab suit-tab-general']})]
+    readonly_fields = ('backend_status_text',)
+    inlines = [AccessDeviceInline]
+
+    suit_form_tabs = (('general','Details'), ('accessdevices','Access Devices'))
+
+class AccessDeviceAdmin(ReadOnlyAwareAdmin):
+    list_display = ('backend_status_icon', 'id', 'volt_device', 'uplink', 'vlan' )
+    list_display_links = ('backend_status_icon', 'id')
+    fieldsets = [ (None, {'fields': ['backend_status_text','volt_device','uplink','vlan'],
+                          'classes':['suit-tab suit-tab-general']})]
+    readonly_fields = ('backend_status_text',)
+
+    suit_form_tabs = (('general','Details'),)
+
+class AgentPortMappingInline(XOSTabularInline):
+    model = AgentPortMapping
+    fields = ['access_agent', 'mac', 'port']
+    readonly_fields = []
+    extra = 0
+#    max_num = 0
+    suit_classes = 'suit-tab suit-tab-accessportmaps'
+
+#    @property
+#    def selflink_reverse_path(self):
+#        return "admin:cord_volttenant_change"
+
+class AccessAgentAdmin(ReadOnlyAwareAdmin):
+    list_display = ('backend_status_icon', 'name', 'mac' )
+    list_display_links = ('backend_status_icon', 'name')
+    fieldsets = [ (None, {'fields': ['backend_status_text','name','volt_service','mac'],
+                          'classes':['suit-tab suit-tab-general']})]
+    readonly_fields = ('backend_status_text',)
+    inlines= [AgentPortMappingInline]
+
+    suit_form_tabs = (('general','Details'), ('accessportmaps', 'Port Mappings'))
+
+admin.site.register(VOLTService, VOLTServiceAdmin)
+admin.site.register(VOLTTenant, VOLTTenantAdmin)
+admin.site.register(VOLTDevice, VOLTDeviceAdmin)
+admin.site.register(AccessDevice, AccessDeviceAdmin)
+admin.site.register(AccessAgent, AccessAgentAdmin)
+
+
diff --git a/xos/attic/accessagent_model.py b/xos/attic/accessagent_model.py
new file mode 100644
index 0000000..b80d979
--- /dev/null
+++ b/xos/attic/accessagent_model.py
@@ -0,0 +1,17 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# 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.
+
+
+def __unicode__(self): return u'%s' % (self.name)
diff --git a/xos/attic/accessdevice_model.py b/xos/attic/accessdevice_model.py
new file mode 100644
index 0000000..507cd58
--- /dev/null
+++ b/xos/attic/accessdevice_model.py
@@ -0,0 +1,17 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# 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.
+
+
+def __unicode__(self): return u'%s-%d:%d' % (self.volt_device.name,self.uplink,self.vlan)
diff --git a/xos/attic/agentportmapping_model.py b/xos/attic/agentportmapping_model.py
new file mode 100644
index 0000000..d80baab
--- /dev/null
+++ b/xos/attic/agentportmapping_model.py
@@ -0,0 +1,17 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# 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.
+
+
+def __unicode__(self): return u'%s-%s-%s' % (self.access_agent.name, self.port, self.mac)
diff --git a/xos/attic/header.py b/xos/attic/header.py
new file mode 100644
index 0000000..0bb8be2
--- /dev/null
+++ b/xos/attic/header.py
@@ -0,0 +1,39 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# 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.
+
+
+from django.db import models
+from django.db.models import *
+from core.models import Service, XOSBase, Slice, Instance, ServiceInstance, ServiceInstanceLink, Node, Image, User, Flavor, NetworkParameter, NetworkParameterType, Port, AddressPool, User
+from core.models.xosbase import StrippedCharField
+import os
+from django.db import models, transaction
+from django.forms.models import model_to_dict
+from django.db.models import Q
+from operator import itemgetter, attrgetter, methodcaller
+from core.models import Tag
+from core.models.service import LeastLoadedNodeScheduler
+from services.vrouter.models import VRouterService, VRouterTenant
+from services.rcord.models import CordSubscriberRoot
+import traceback
+from xos.exceptions import *
+from xosconfig import Config
+
+class ConfigurationError(Exception):
+    pass
+
+VOLT_KIND = "vOLT"
+
+CORD_USE_VTN = getattr(Config(), "networking_use_vtn", False)
diff --git a/xos/attic/voltdevice_model.py b/xos/attic/voltdevice_model.py
new file mode 100644
index 0000000..b80d979
--- /dev/null
+++ b/xos/attic/voltdevice_model.py
@@ -0,0 +1,17 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# 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.
+
+
+def __unicode__(self): return u'%s' % (self.name)
diff --git a/xos/attic/volttenant_model.py b/xos/attic/volttenant_model.py
new file mode 100644
index 0000000..c7a3420
--- /dev/null
+++ b/xos/attic/volttenant_model.py
@@ -0,0 +1,69 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# 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.
+
+
+def __init__(self, *args, **kwargs):
+    volt_services = VOLTService.objects.all()
+    if volt_services:
+        self._meta.get_field("owner").default = volt_services[0].id
+    super(VOLTTenant, self).__init__(*args, **kwargs)
+    self.cached_vcpe = None
+
+@property
+def vcpe(self):
+    # TODO: hardcoded service dependency
+    from services.vsg.models import VSGTenant
+
+    vsg = None
+    for link in self.subscribed_links:
+        # cast from base class to derived class
+        vsgs = VSGTenant.objects.filter(serviceinstance_ptr=link.provider_service_instance)
+        if vsgs:
+            vsg = vsgs[0]
+
+    if not vsg:
+        return None
+
+    # always return the same object when possible
+    if (self.cached_vcpe) and (self.cached_vcpe.id == vsg.id):
+        return self.cached_vcpe
+
+    vsg.caller = self.creator
+    self.cached_vcpe = vsg
+    return vsg
+
+@vcpe.setter
+def vcpe(self, value):
+    raise XOSConfigurationError("vOLT.vCPE cannot be set this way -- create a new vCPE object and set its subscriber_tenant instead")
+
+@property
+def subscriber(self):
+    for link in self.provided_links:
+        # cast from base class to derived class
+        roots = CordSubscriberRoot.objects.filter(serviceinstance_ptr=link.subscriber_service_instance)
+        if roots:
+            return roots[0]
+    return None
+
+def save(self, *args, **kwargs):
+    if not self.creator:
+        if not getattr(self, "caller", None):
+            # caller must be set when creating a vCPE since it creates a slice
+            raise XOSProgrammingError("VOLTTenant's self.caller was not set")
+        self.creator = self.caller
+        if not self.creator:
+            raise XOSProgrammingError("VOLTTenant's self.creator was not set")
+
+    super(VOLTTenant, self).save(*args, **kwargs)
diff --git a/xos/header.py b/xos/header.py
new file mode 100644
index 0000000..0bb8be2
--- /dev/null
+++ b/xos/header.py
@@ -0,0 +1,39 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# 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.
+
+
+from django.db import models
+from django.db.models import *
+from core.models import Service, XOSBase, Slice, Instance, ServiceInstance, ServiceInstanceLink, Node, Image, User, Flavor, NetworkParameter, NetworkParameterType, Port, AddressPool, User
+from core.models.xosbase import StrippedCharField
+import os
+from django.db import models, transaction
+from django.forms.models import model_to_dict
+from django.db.models import Q
+from operator import itemgetter, attrgetter, methodcaller
+from core.models import Tag
+from core.models.service import LeastLoadedNodeScheduler
+from services.vrouter.models import VRouterService, VRouterTenant
+from services.rcord.models import CordSubscriberRoot
+import traceback
+from xos.exceptions import *
+from xosconfig import Config
+
+class ConfigurationError(Exception):
+    pass
+
+VOLT_KIND = "vOLT"
+
+CORD_USE_VTN = getattr(Config(), "networking_use_vtn", False)
diff --git a/xos/synchronizer/Dockerfile.synchronizer b/xos/synchronizer/Dockerfile.synchronizer
new file mode 100644
index 0000000..a9d5e65
--- /dev/null
+++ b/xos/synchronizer/Dockerfile.synchronizer
@@ -0,0 +1,56 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# 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.
+
+
+# xosproject/volt-synchronizer
+
+FROM xosproject/xos-synchronizer-base:candidate
+
+ADD . /opt/xos/synchronizers/volt
+
+ENTRYPOINT []
+
+WORKDIR "/opt/xos/synchronizers/volt"
+
+# Label image
+ARG org_label_schema_schema_version=1.0
+ARG org_label_schema_name=volt-synchronizer
+ARG org_label_schema_version=unknown
+ARG org_label_schema_vcs_url=unknown
+ARG org_label_schema_vcs_ref=unknown
+ARG org_label_schema_build_date=unknown
+ARG org_opencord_vcs_commit_date=unknown
+ARG org_opencord_component_chameleon_version=unknown
+ARG org_opencord_component_chameleon_vcs_url=unknown
+ARG org_opencord_component_chameleon_vcs_ref=unknown
+ARG org_opencord_component_xos_version=unknown
+ARG org_opencord_component_xos_vcs_url=unknown
+ARG org_opencord_component_xos_vcs_ref=unknown
+
+LABEL org.label-schema.schema-version=$org_label_schema_schema_version \
+      org.label-schema.name=$org_label_schema_name \
+      org.label-schema.version=$org_label_schema_version \
+      org.label-schema.vcs-url=$org_label_schema_vcs_url \
+      org.label-schema.vcs-ref=$org_label_schema_vcs_ref \
+      org.label-schema.build-date=$org_label_schema_build_date \
+      org.opencord.vcs-commit-date=$org_opencord_vcs_commit_date \
+      org.opencord.component.chameleon.version=$org_opencord_component_chameleon_version \
+      org.opencord.component.chameleon.vcs-url=$org_opencord_component_chameleon_vcs_url \
+      org.opencord.component.chameleon.vcs-ref=$org_opencord_component_chameleon_vcs_ref \
+      org.opencord.component.xos.version=$org_opencord_component_xos_version \
+      org.opencord.component.xos.vcs-url=$org_opencord_component_xos_vcs_url \
+      org.opencord.component.xos.vcs-ref=$org_opencord_component_xos_vcs_ref
+
+CMD bash -c "cd /opt/xos/synchronizers/volt; ./run.sh"
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/model_policies/model_policy_volttenant.py b/xos/synchronizer/model_policies/model_policy_volttenant.py
new file mode 100644
index 0000000..ef5ba4e
--- /dev/null
+++ b/xos/synchronizer/model_policies/model_policy_volttenant.py
@@ -0,0 +1,94 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# 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.
+
+
+from synchronizers.new_base.modelaccessor import *
+from synchronizers.new_base.policy import Policy
+
+class VOLTTenantPolicy(Policy):
+    model_name = "VOLTTenant"
+
+    def handle_create(self, tenant):
+        return self.handle_update(tenant)
+
+    def handle_update(self, tenant):
+        self.manage_vsg(tenant)
+        self.manage_subscriber(tenant)
+        self.cleanup_orphans(tenant)
+
+    def handle_delete(self, tenant):
+        if tenant.vcpe:
+            tenant.vcpe.delete()
+
+    def manage_vsg(self, tenant):
+        # Each VOLT object owns exactly one VCPE object
+
+        if tenant.deleted:
+            self.logger.info("MODEL_POLICY: volttenant %s deleted, deleting vsg" % tenant)
+            return
+
+        # Check to see if the wrong s-tag is set. This can only happen if the
+        # user changed the s-tag after the VoltTenant object was created.
+        if tenant.vcpe and tenant.vcpe.instance:
+            s_tags = Tag.objects.filter(content_type=tenant.vcpe.instance.self_content_type_id,
+                                        object_id=tenant.vcpe.instance.id, name="s_tag")
+            if s_tags and (s_tags[0].value != str(tenant.s_tag)):
+                self.logger.info("MODEL_POLICY: volttenant %s s_tag changed, deleting vsg" % tenant)
+                tenant.vcpe.delete()
+
+        if tenant.vcpe is None:
+            vsgServices = VSGService.objects.all()
+            if not vsgServices:
+                raise XOSConfigurationError("No VSG Services available")
+
+            self.logger.info("MODEL_POLICY: volttenant %s creating vsg" % tenant)
+
+            vcpe = VSGTenant(owner=vsgServices[0])
+            vcpe.creator = tenant.creator
+            vcpe.save()
+            link = ServiceInstanceLink(provider_service_instance = vcpe, subscriber_service_instance = tenant)
+            link.save()
+
+    def manage_subscriber(self, tenant):
+        # check for existing link to a root
+        links = tenant.provided_links.all()
+        for link in links:
+            roots = CordSubscriberRoot.objects.filter(id = link.subscriber_service_instance.id)
+            if roots:
+                return
+
+        subs = CordSubscriberRoot.objects.filter(service_specific_id = tenant.service_specific_id)
+        if subs:
+            self.logger.info("MODEL_POLICY: volttenant %s using existing subscriber root" % tenant)
+            sub = subs[0]
+        else:
+            self.logger.info("MODEL_POLICY: volttenant %s creating new subscriber root" % tenant)
+            sub = CordSubscriberRoot(service_specific_id = tenant.service_specific_id,
+                                     name = "autogenerated-for-vOLT-%s" % tenant.id)
+            sub.save()
+
+        link = ServiceInstanceLink(provider_service_instance = tenant, subscriber_service_instance = sub)
+        link.save()
+
+    def cleanup_orphans(self, tenant):
+        # ensure vOLT only has one vCPE
+        cur_vcpe = tenant.vcpe
+
+        links = tenant.subscribed_links.all()
+        for link in links:
+            vsgs = VSGTenant.objects.filter(id = link.provider_service_instance.id)
+            for vsg in vsgs:
+                if (not cur_vcpe) or (vsg.id != cur_vcpe.id):
+                    vsg.delete()
diff --git a/xos/synchronizer/run.sh b/xos/synchronizer/run.sh
new file mode 100755
index 0000000..2f90845
--- /dev/null
+++ b/xos/synchronizer/run.sh
@@ -0,0 +1,17 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# 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.
+
+
+python volt-synchronizer.py
diff --git a/xos/synchronizer/volt-synchronizer.py b/xos/synchronizer/volt-synchronizer.py
new file mode 100755
index 0000000..25ab599
--- /dev/null
+++ b/xos/synchronizer/volt-synchronizer.py
@@ -0,0 +1,32 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# 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.
+
+
+#!/usr/bin/env python
+
+# This imports and runs ../../xos-observer.py
+
+import importlib
+import os
+import sys
+from xosconfig import Config
+
+config_file = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + '/volt_config.yaml')
+Config.init(config_file, 'synchronizer-config-schema.yaml')
+
+observer_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),"../../synchronizers/new_base")
+sys.path.append(observer_path)
+mod = importlib.import_module("xos-synchronizer")
+mod.main()
diff --git a/xos/synchronizer/volt_config.yaml b/xos/synchronizer/volt_config.yaml
new file mode 100644
index 0000000..fdcd31f
--- /dev/null
+++ b/xos/synchronizer/volt_config.yaml
@@ -0,0 +1,22 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# 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.
+
+
+name: volt-synchronizer
+accessor:
+  username: xosadmin@opencord.org
+  password: "@/opt/xos/services/volt/credentials/xosadmin@opencord.org"
+dependency_graph: "/opt/xos/synchronizers/volt/model-deps"
+model_policies_dir: "/opt/xos/synchronizers/volt/model_policies"
\ No newline at end of file
diff --git a/xos/templates/voltadmin.html b/xos/templates/voltadmin.html
new file mode 100644
index 0000000..b971d15
--- /dev/null
+++ b/xos/templates/voltadmin.html
@@ -0,0 +1,28 @@
+
+<!--
+Copyright 2017-present Open Networking Foundation
+
+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.
+-->
+
+
+<div class = "row text-center">
+    <div class="col-xs-12">
+        <a href="/admin/volt/volttenant/">vOLT Tenants</a>
+    </div><div class="col-xs-12">
+        <a href="/admin/volt/voltdevice/">vOLT Devices</a>
+    </div><div class="col-xs-12">
+        <a href="/admin/volt/accessagent/">vOLT Access Agents</a>
+    </div>
+</div>
+
diff --git a/xos/tosca/resources/CORDSubscriber.py b/xos/tosca/resources/CORDSubscriber.py
new file mode 100644
index 0000000..69f6652
--- /dev/null
+++ b/xos/tosca/resources/CORDSubscriber.py
@@ -0,0 +1,32 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# 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.
+
+
+#from core.models import User, TenantRootPrivilege, TenantRootRole
+from services.rcord.models import CordSubscriberRoot
+from xosresource import XOSResource
+
+class XOSCORDSubscriber(XOSResource):
+    provides = "tosca.nodes.CORDSubscriber"
+    xos_model = CordSubscriberRoot
+    copyin_props = ["service_specific_id", "firewall_enable", "url_filter_enable", "cdn_enable", "url_filter_level"]
+
+#    def postprocess(self, obj):
+#        rolemap = ( ("tosca.relationships.AdminPrivilege", "admin"), ("tosca.relationships.AccessPrivilege", "access"), )
+#        self.postprocess_privileges(TenantRootRole, TenantRootPrivilege, rolemap, obj, "tenant_root")
+
+    def can_delete(self, obj):
+        return super(XOSCORDSubscriber, self).can_delete(obj)
+
diff --git a/xos/tosca/resources/CORDUser.py b/xos/tosca/resources/CORDUser.py
new file mode 100644
index 0000000..2a061bb
--- /dev/null
+++ b/xos/tosca/resources/CORDUser.py
@@ -0,0 +1,71 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# 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.
+
+
+from core.models import User
+from services.rcord.models import CordSubscriberRoot
+
+from xosresource import XOSResource
+
+class XOSCORDUser(XOSResource):
+    provides = "tosca.nodes.CORDUser"
+
+    def get_model_class_name(self):
+        return "CORDUser"
+
+    def get_subscriber_root(self, throw_exception=True):
+        sub_name = self.get_requirement("tosca.relationships.SubscriberDevice", throw_exception=throw_exception)
+        sub = self.get_xos_object(CordSubscriberRoot, name=sub_name, throw_exception=throw_exception)
+        return sub
+
+    def get_existing_objs(self):
+        result = []
+        sub = self.get_subscriber_root(throw_exception=False)
+        if not sub:
+           return []
+        for user in sub.devices:
+            if user["name"] == self.obj_name:
+                result.append(user)
+        return result
+
+    def get_xos_args(self):
+        args = {"name": self.obj_name,
+                "level": self.get_property("level"),
+                "mac": self.get_property("mac")}
+        return args
+
+
+    def create(self):
+        xos_args = self.get_xos_args()
+        sub = self.get_subscriber_root()
+
+        sub.create_device(**xos_args)
+        sub.save()
+
+        self.info("Created CORDUser %s for Subscriber %s" % (self.obj_name, sub.name))
+
+    def update(self, obj):
+        pass
+
+    def delete(self, obj):
+        if (self.can_delete(obj)):
+            self.info("destroying CORDUser %s" % obj["name"])
+            sub = self.get_subscriber_root()
+            sub.delete_user(obj["id"])
+            sub.save()
+
+    def can_delete(self, obj):
+        return True
+
diff --git a/xos/tosca/resources/VOLTTenant.py b/xos/tosca/resources/VOLTTenant.py
new file mode 100644
index 0000000..856d990
--- /dev/null
+++ b/xos/tosca/resources/VOLTTenant.py
@@ -0,0 +1,61 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# 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.
+
+
+from core.models import User, ServiceInstanceLink
+from services.volt.models import VOLTTenant, VOLTService, VOLT_KIND
+from services.rcord.models import CordSubscriberRoot
+
+from xosresource import XOSResource
+
+class XOSVOLTTenant(XOSResource):
+    provides = "tosca.nodes.VOLTTenant"
+    xos_model = VOLTTenant
+    copyin_props = ["service_specific_id", "s_tag", "c_tag"]
+    name_field = None
+
+    def get_xos_args(self, throw_exception=True):
+        args = super(XOSVOLTTenant, self).get_xos_args()
+
+        provider_name = self.get_requirement("tosca.relationships.MemberOfService", throw_exception=throw_exception)
+        if provider_name:
+            args["owner"] = self.get_xos_object(VOLTService, throw_exception=throw_exception, name=provider_name)
+
+        return args
+
+    def get_existing_objs(self):
+        args = self.get_xos_args(throw_exception=False)
+        provider_service = args.get("owner", None)
+        service_specific_id = args.get("service_specific_id", None)
+        if (provider_service) and (service_specific_id):
+            existing_obj = self.get_xos_object(VOLTTenant, owner=provider_service, service_specific_id=service_specific_id, throw_exception=False)
+            if existing_obj:
+                return [ existing_obj ]
+        return []
+
+    def postprocess(self, obj):
+        subscriber_name = self.get_requirement("tosca.relationships.BelongsToSubscriber")
+        if subscriber_name:
+            subscriber = self.get_xos_object(CordSubscriberRoot, throw_exception=True, name=subscriber_name)
+
+            links = ServiceInstanceLink.objects.filter(provider_service_instance = obj,
+                                                       subscriber_service_instance = subscriber)
+            if not links:
+                link = ServiceInstanceLink(provider_service_instance = obj, subscriber_service_instance = subscriber)
+                link.save()
+
+    def can_delete(self, obj):
+        return super(XOSVOLTTenant, self).can_delete(obj)
+
diff --git a/xos/tosca/resources/accessagent.py b/xos/tosca/resources/accessagent.py
new file mode 100644
index 0000000..fedf959
--- /dev/null
+++ b/xos/tosca/resources/accessagent.py
@@ -0,0 +1,65 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# 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.
+
+
+from services.volt.models import AccessAgent, VOLTDevice, VOLTService, AgentPortMapping
+from xosresource import XOSResource
+
+class XOSAccessAgent(XOSResource):
+    provides = "tosca.nodes.AccessAgent"
+    xos_model = AccessAgent
+    copyin_props = ["mac"]
+
+    def get_xos_args(self, throw_exception=True):
+        args = super(XOSAccessAgent, self).get_xos_args()
+
+        volt_service_name = self.get_requirement("tosca.relationships.MemberOfService", throw_exception=throw_exception)
+        if volt_service_name:
+            args["volt_service"] = self.get_xos_object(VOLTService, throw_exception=throw_exception, name=volt_service_name)
+
+        return args
+
+    def postprocess(self, obj):
+        # For convenient, allow the port mappings to be specified by a Tosca
+        # string with commas between lines.
+        #      <port> <mac>,
+        #      <port> <mac>,
+        #      ...
+        #      <port> <mac>
+
+        port_mappings_str = self.get_property("port_mappings")
+        port_mappings = []
+        if port_mappings_str:
+            lines = [x.strip() for x in port_mappings_str.split(",")]
+            for line in lines:
+                if not (" " in line):
+                    raise "Malformed port mapping `%s`", line
+                (port, mac) = line.split(" ")
+                port=port.strip()
+                mac=mac.strip()
+                port_mappings.append( (port, mac) )
+
+            for apm in list(AgentPortMapping.objects.filter(access_agent=obj)):
+                if (apm.port, apm.mac) not in port_mappings:
+                    print "Deleting AgentPortMapping '%s'" % apm
+                    apm.delete()
+
+            for port_mapping in port_mappings:
+                existing_objs = AgentPortMapping.objects.filter(access_agent=obj, port=port_mapping[0], mac=port_mapping[1])
+                if not existing_objs:
+                    apm = AgentPortMapping(access_agent=obj, port=port_mapping[0], mac=port_mapping[1])
+                    apm.save()
+                    print "Created AgentPortMapping '%s'" % apm
+
diff --git a/xos/tosca/resources/accessdevice.py b/xos/tosca/resources/accessdevice.py
new file mode 100644
index 0000000..a9fd999
--- /dev/null
+++ b/xos/tosca/resources/accessdevice.py
@@ -0,0 +1,49 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# 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.
+
+
+from services.volt.models import AccessDevice, VOLTDevice
+from xosresource import XOSResource
+
+class XOSAccessDevice(XOSResource):
+    provides = "tosca.nodes.AccessDevice"
+    xos_model = AccessDevice
+    copyin_props = ["uplink", "vlan"]
+    name_field = None
+
+    def get_xos_args(self, throw_exception=True):
+        args = super(XOSAccessDevice, self).get_xos_args()
+
+        volt_device_name = self.get_requirement("tosca.relationships.MemberOfDevice", throw_exception=throw_exception)
+        if volt_device_name:
+            args["volt_device"] = self.get_xos_object(VOLTDevice, throw_exception=throw_exception, name=volt_device_name)
+
+        return args
+
+    # AccessDevice has no name field, so we rely on matching the keys. We assume
+    # the for a given VOLTDevice, there is only one AccessDevice per (uplink, vlan)
+    # pair.
+
+    def get_existing_objs(self):
+        args = self.get_xos_args(throw_exception=False)
+        volt_device = args.get("volt_device", None)
+        uplink = args.get("uplink", None)
+        vlan = args.get("vlan", None)
+        if (volt_device is not None) and (uplink is not None) and (vlan is not None):
+            existing_obj = self.get_xos_object(AccessDevice, volt_device=volt_device, uplink=uplink, vlan=vlan, throw_exception=False)
+            if existing_obj:
+                return [ existing_obj ]
+        return []
+
diff --git a/xos/tosca/resources/voltdevice.py b/xos/tosca/resources/voltdevice.py
new file mode 100644
index 0000000..ef3d05e
--- /dev/null
+++ b/xos/tosca/resources/voltdevice.py
@@ -0,0 +1,61 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# 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.
+
+
+from services.volt.models import VOLTDevice, VOLTService, AccessDevice, AccessAgent
+from xosresource import XOSResource
+
+class XOSVOLTDevice(XOSResource):
+    provides = "tosca.nodes.VOLTDevice"
+    xos_model = VOLTDevice
+    copyin_props = ["openflow_id", "driver"]
+
+    def get_xos_args(self, throw_exception=True):
+        args = super(XOSVOLTDevice, self).get_xos_args()
+
+        volt_service_name = self.get_requirement("tosca.relationships.MemberOfService", throw_exception=throw_exception)
+        if volt_service_name:
+            args["volt_service"] = self.get_xos_object(VOLTService, throw_exception=throw_exception, name=volt_service_name)
+
+        agent_name = self.get_requirement("tosca.relationships.UsesAgent", throw_exception=throw_exception)
+        if agent_name:
+            args["access_agent"] = self.get_xos_object(AccessAgent, throw_exception=throw_exception, name=agent_name)
+
+        return args
+
+    def postprocess(self, obj):
+        access_devices_str = self.get_property("access_devices")
+        access_devices = []
+        if access_devices_str:
+            lines = [x.strip() for x in access_devices_str.split(",")]
+            for line in lines:
+                if not (" " in line):
+                    raise "Malformed access device `%s`", line
+                (uplink, vlan) = line.split(" ")
+                uplink=int(uplink.strip())
+                vlan=int(vlan.strip())
+                access_devices.append( (uplink, vlan) )
+
+            for ad in list(AccessDevice.objects.filter(volt_device=obj)):
+                if (ad.uplink, ad.vlan) not in access_devices:
+                    print "Deleting AccessDevice '%s'" % ad
+                    ad.delete()
+
+            for access_device in access_devices:
+                existing_objs = AccessDevice.objects.filter(volt_device=obj, uplink=access_device[0], vlan=access_device[1])
+                if not existing_objs:
+                    ad = AccessDevice(volt_device=obj, uplink=access_device[0], vlan=access_device[1])
+                    ad.save()
+                    print "Created AccessDevice '%s'" % ad
diff --git a/xos/tosca/resources/voltservice.py b/xos/tosca/resources/voltservice.py
new file mode 100644
index 0000000..cc28c35
--- /dev/null
+++ b/xos/tosca/resources/voltservice.py
@@ -0,0 +1,23 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# 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.
+
+
+from services.volt.models import VOLTService
+from service import XOSService
+
+class XOSVOLTService(XOSService):
+    provides = "tosca.nodes.VOLTService"
+    xos_model = VOLTService
+    copyin_props = ["view_url", "icon_url", "kind", "enabled", "published", "public_key", "private_key_fn", "versionNumber"]
diff --git a/xos/volt-onboard.yaml b/xos/volt-onboard.yaml
new file mode 100644
index 0000000..85b9aef
--- /dev/null
+++ b/xos/volt-onboard.yaml
@@ -0,0 +1,39 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# 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.
+
+
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: Onboard the exampleservice
+
+imports:
+   - custom_types/xos.yaml
+
+topology_template:
+  node_templates:
+    servicecontroller#volt:
+      type: tosca.nodes.ServiceController
+      properties:
+          base_url: file:///opt/xos_services/olt/xos/
+          # The following will concatenate with base_url automatically, if
+          # base_url is non-null.
+          xproto: ./
+          admin: admin.py
+          admin_template: templates/voltadmin.html
+          #synchronizer: synchronizer/manifest
+          tosca_resource: tosca/resources/voltdevice.py, tosca/resources/voltservice.py, tosca/resources/CORDSubscriber.py, tosca/resources/CORDUser.py, tosca/resources/VOLTTenant.py, tosca/resources/accessagent.py, tosca/resources/accessdevice.py
+          private_key: file:///opt/xos/key_import/volt_rsa
+          public_key: file:///opt/xos/key_import/volt_rsa.pub
+
diff --git a/xos/volt.xproto b/xos/volt.xproto
new file mode 100644
index 0000000..e1f5ddf
--- /dev/null
+++ b/xos/volt.xproto
@@ -0,0 +1,49 @@
+option name = "volt";
+
+message VOLTService (Service){
+     option verbose_name = "vOLT Service";
+     option kind = "vOLT";
+}
+
+message VOLTTenant (ServiceInstance){
+     option kind = "vOLT";
+     option verbose_name = "vOLT Tenant";
+
+     optional int32 s_tag = 1 [help_text = "s-tag", null = True, db_index = False, blank = True];
+     optional int32 c_tag = 2 [help_text = "c-tag", null = True, db_index = False, blank = True];
+     optional manytoone creator->User:created_volts = 3 [db_index = True, null = True, blank = True];
+}
+
+message AccessAgent (XOSBase){
+     option verbose_name = "Access Agent";
+
+     required string name = 1 [help_text = "name of agent", max_length = 254, null = False, db_index = False, blank = False];
+     required manytoone volt_service->VOLTService:access_agents = 2 [db_index = True, null = False, blank = False];
+     optional string mac = 3 [help_text = "MAC Address or Access Agent", max_length = 32, null = True, db_index = False, blank = True];
+}
+
+message VOLTDevice (XOSBase){
+     option verbose_name = "vOLT Device";
+
+     required string name = 1 [help_text = "name of device", max_length = 254, null = False, db_index = False, blank = False];
+     required manytoone volt_service->VOLTService:volt_devices = 2 [db_index = True, null = False, blank = False];
+     optional string openflow_id = 3 [help_text = "OpenFlow ID", max_length = 254, null = True, db_index = False, blank = True];
+     optional string driver = 4 [help_text = "driver", max_length = 254, null = True, db_index = False, blank = True];
+     optional manytoone access_agent->AccessAgent:volt_devices = 5 [db_index = True, null = True, blank = True];
+}
+
+message AccessDevice (XOSBase){
+     option verbose_name = "Access Device";
+
+     required manytoone volt_device->VOLTDevice:access_devices = 1 [db_index = True, null = False, blank = False];
+     optional int32 uplink = 2 [db_index = False, null = True, blank = True];
+     optional int32 vlan = 3 [db_index = False, null = True, blank = True];
+}
+
+message AgentPortMapping (XOSBase){
+     option verbose_name = "Agent Port Mapping";
+
+     required manytoone access_agent->AccessAgent:port_mappings = 1 [db_index = True, null = False, blank = False];
+     optional string mac = 2 [help_text = "MAC Address", max_length = 32, null = True, db_index = False, blank = True];
+     optional string port = 3 [help_text = "Openflow port ID", max_length = 32, null = True, db_index = False, blank = True];
+}