Merge branch 'feature/fabric'
diff --git a/xos/configurations/cord-pod/cord-vtn-vsg.yaml b/xos/configurations/cord-pod/cord-vtn-vsg.yaml
index 7de536a..e3f73c6 100644
--- a/xos/configurations/cord-pod/cord-vtn-vsg.yaml
+++ b/xos/configurations/cord-pod/cord-vtn-vsg.yaml
@@ -65,6 +65,11 @@
               node: addresses_exampleservice-public
               relationship: tosca.relationships.ProvidesAddresses
 
+    service_fabric:
+      type: tosca.nodes.FabricService
+      properties:
+          view_url: /admin/fabric/fabricservice/$id$/
+
     Private:
       type: tosca.nodes.NetworkTemplate
 
diff --git a/xos/services/fabric/__init__.py b/xos/services/fabric/__init__.py
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/xos/services/fabric/__init__.py
@@ -0,0 +1 @@
+
diff --git a/xos/services/fabric/admin.py b/xos/services/fabric/admin.py
new file mode 100644
index 0000000..5dc5923
--- /dev/null
+++ b/xos/services/fabric/admin.py
@@ -0,0 +1,63 @@
+from django.contrib import admin
+
+from services.fabric.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.models import AddressPool
+from core.admin import ServiceAppAdmin,SliceInline,ServiceAttrAsTabInline, ReadOnlyAwareAdmin, XOSTabularInline, ServicePrivilegeInline, TenantRootTenantInline, TenantRootPrivilegeInline
+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
+
+class FabricServiceForm(forms.ModelForm):
+    def __init__(self,*args,**kwargs):
+        super (FabricServiceForm,self ).__init__(*args,**kwargs)
+
+    def save(self, commit=True):
+        return super(FabricServiceForm, self).save(commit=commit)
+
+    class Meta:
+        model = FabricService
+
+class FabricServiceAdmin(ReadOnlyAwareAdmin):
+    model = FabricService
+    verbose_name = "Fabric Service"
+    verbose_name_plural = "Fabric Services"
+    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]
+    form = FabricServiceForm
+
+    extracontext_registered_admins = True
+
+    user_readonly_fields = ["name", "enabled", "versionNumber", "description"]
+
+    suit_form_tabs =(('general', 'Fabric Service Details'),
+        ('administration', 'Administration'),
+        #('tools', 'Tools'),
+        ('slices','Slices'),
+        ('serviceattrs','Additional Attributes'),
+        ('serviceprivileges','Privileges'),
+    )
+
+    suit_form_includes = (('fabricadmin.html', 'top', 'administration'),
+                           )
+
+    def queryset(self, request):
+        return FabricService.get_service_objects_by_user(request.user)
+
+admin.site.register(FabricService, FabricServiceAdmin)
+
diff --git a/xos/services/fabric/models.py b/xos/services/fabric/models.py
new file mode 100644
index 0000000..0bf6a14
--- /dev/null
+++ b/xos/services/fabric/models.py
@@ -0,0 +1,30 @@
+from django.db import models
+from core.models import Service, PlCoreBase, Slice, Instance, Tenant, TenantWithContainer, Node, Image, User, Flavor, Subscriber, NetworkParameter, NetworkParameterType, Port, AddressPool
+from core.models.plcorebase 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
+import traceback
+from xos.exceptions import *
+from xos.config import Config
+
+class ConfigurationError(Exception):
+    pass
+
+FABRIC_KIND = "fabric"
+
+CORD_USE_VTN = getattr(Config(), "networking_use_vtn", False)
+
+class FabricService(Service):
+    KIND = FABRIC_KIND
+
+    class Meta:
+        app_label = "fabric"
+        verbose_name = "Fabric Service"
+        proxy = True
+
+
diff --git a/xos/tools/xos-manage b/xos/tools/xos-manage
index e955b5d..709882b 100755
--- a/xos/tools/xos-manage
+++ b/xos/tools/xos-manage
@@ -149,6 +149,7 @@
     python ./manage.py makemigrations vtr
     python ./manage.py makemigrations vrouter
     python ./manage.py makemigrations vtn
+    python ./manage.py makemigrations fabric
     #python ./manage.py makemigrations servcomp
 }
 
diff --git a/xos/tosca/custom_types/xos.m4 b/xos/tosca/custom_types/xos.m4
index 32eefa4..e6d77f1 100644
--- a/xos/tosca/custom_types/xos.m4
+++ b/xos/tosca/custom_types/xos.m4
@@ -252,6 +252,16 @@
             xos_base_props
             xos_base_service_props
 
+    tosca.nodes.FabricService:
+        derived_from: tosca.nodes.Root
+        description: >
+            CORD: The Fabric Service.
+        capabilities:
+            xos_base_service_caps
+        properties:
+            xos_base_props
+            xos_base_service_props
+
     tosca.nodes.VTNService:
         derived_from: tosca.nodes.Root
         description: >
diff --git a/xos/tosca/custom_types/xos.yaml b/xos/tosca/custom_types/xos.yaml
index 8102d1c..2bca51e 100644
--- a/xos/tosca/custom_types/xos.yaml
+++ b/xos/tosca/custom_types/xos.yaml
@@ -442,6 +442,60 @@
                 required: false
                 description: Version number of Service.
 
+    tosca.nodes.FabricService:
+        derived_from: tosca.nodes.Root
+        description: >
+            CORD: The Fabric Service.
+        capabilities:
+            scalable:
+                type: tosca.capabilities.Scalable
+            service:
+                type: tosca.capabilities.xos.Service
+        properties:
+            no-delete:
+                type: boolean
+                default: false
+                description: Do not allow Tosca to delete this object
+            no-create:
+                type: boolean
+                default: false
+                description: Do not allow Tosca to create this object
+            no-update:
+                type: boolean
+                default: false
+                description: Do not allow Tosca to update this object
+            kind:
+                type: string
+                default: generic
+                description: Type of service.
+            view_url:
+                type: string
+                required: false
+                description: URL to follow when icon is clicked in the Service Directory.
+            icon_url:
+                type: string
+                required: false
+                description: ICON to display in the Service Directory.
+            enabled:
+                type: boolean
+                default: true
+            published:
+                type: boolean
+                default: true
+                description: If True then display this Service in the Service Directory.
+            public_key:
+                type: string
+                required: false
+                description: Public key to install into Instances to allows Services to SSH into them.
+            private_key_fn:
+                type: string
+                required: false
+                description: Location of private key file
+            versionNumber:
+                type: string
+                required: false
+                description: Version number of Service.
+
     tosca.nodes.VTNService:
         derived_from: tosca.nodes.Root
         description: >
@@ -526,6 +580,7 @@
                 type: string
                 required: false
 
+
     tosca.nodes.CDNService:
         derived_from: tosca.nodes.Root
         description: >
diff --git a/xos/tosca/resources/fabricservice.py b/xos/tosca/resources/fabricservice.py
new file mode 100644
index 0000000..0c9cfb4
--- /dev/null
+++ b/xos/tosca/resources/fabricservice.py
@@ -0,0 +1,16 @@
+import os
+import pdb
+import sys
+import tempfile
+sys.path.append("/opt/tosca")
+from translator.toscalib.tosca_template import ToscaTemplate
+
+from services.fabric.models import FabricService
+
+from service import XOSService
+
+class FabricService(XOSService):
+    provides = "tosca.nodes.FabricService"
+    xos_model = FabricService
+    copyin_props = ["view_url", "icon_url", "enabled", "published", "public_key", "versionNumber"]
+
diff --git a/xos/tosca/resources/xosresource.py b/xos/tosca/resources/xosresource.py
index e70cfa9..82514c9 100644
--- a/xos/tosca/resources/xosresource.py
+++ b/xos/tosca/resources/xosresource.py
@@ -78,6 +78,11 @@
         return default
 
     def get_xos_object(self, cls, throw_exception=True, **kwargs):
+        # do the same parsing that we do for objname
+        for (k,v) in kwargs.items():
+            if (k=="name") and ("#" in v):
+                kwargs[k] = v.split("#",1)[1]
+
         objs = cls.objects.filter(**kwargs)
         if not objs:
             if throw_exception:
diff --git a/xos/xos/settings.py b/xos/xos/settings.py
index 61f4ac2..0343adc 100644
--- a/xos/xos/settings.py
+++ b/xos/xos/settings.py
@@ -183,6 +183,7 @@
     'services.vtr',
     'services.vrouter',
     'services.vtn',
+    'services.fabric',
     'geoposition',
     'rest_framework_swagger',
 )