Merge pull request #120 from open-cloud/feature/folderConfig

Feature/folder config
diff --git a/xos/configurations/cord/cord.yaml b/xos/configurations/cord/cord.yaml
index a35454b..2a61cf9 100644
--- a/xos/configurations/cord/cord.yaml
+++ b/xos/configurations/cord/cord.yaml
@@ -203,6 +203,16 @@
               node: mysite_vbng
               relationship: tosca.relationships.ConnectsToSlice
 
+    Private-Direct:
+      type: tosca.nodes.NetworkTemplate
+      properties:
+          access: direct
+
+    Private-Indirect:
+      type: tosca.nodes.NetworkTemplate
+      properties:
+          access: indirect
+
     subscriber_network:
       type: tosca.nodes.network.Network
       properties:
diff --git a/xos/core/admin.py b/xos/core/admin.py
index be9dcc0..e41ad1d 100644
--- a/xos/core/admin.py
+++ b/xos/core/admin.py
@@ -1848,7 +1848,7 @@
     user_readonly_inlines = []
     inlines = [NetworkParameterInline,]
     fieldsets = [
-        (None, {'fields': ['name', 'description', 'guaranteed_bandwidth', 'visibility', 'translation', 'shared_network_name', 'shared_network_id', 'topology_kind', 'controller_kind'],
+        (None, {'fields': ['name', 'description', 'guaranteed_bandwidth', 'visibility', 'translation', 'access', 'shared_network_name', 'shared_network_id', 'topology_kind', 'controller_kind'],
                 'classes':['suit-tab suit-tab-general']}),]
     suit_form_tabs = (('general','Network Template Details'), ('netparams', 'Parameters') )
 
diff --git a/xos/core/models/network.py b/xos/core/models/network.py
index 6894f9f..a019091 100644
--- a/xos/core/models/network.py
+++ b/xos/core/models/network.py
@@ -100,15 +100,17 @@
     TRANSLATION_CHOICES = (('none', 'none'), ('NAT', 'NAT'))
     TOPOLOGY_CHOICES = (('bigswitch', 'BigSwitch'), ('physical', 'Physical'), ('custom', 'Custom'))
     CONTROLLER_CHOICES = ((None, 'None'), ('onos', 'ONOS'), ('custom', 'Custom'))
+    ACCESS_CHOICES = ((None, 'None'), ('indirect', 'Indirect'), ('direct', 'Direct'))
 
     name = models.CharField(max_length=32)
     description = models.CharField(max_length=1024, blank=True, null=True)
     guaranteed_bandwidth = models.IntegerField(default=0)
     visibility = models.CharField(max_length=30, choices=VISIBILITY_CHOICES, default="private")
     translation = models.CharField(max_length=30, choices=TRANSLATION_CHOICES, default="none")
+    access = models.CharField(max_length=30, null=True, blank=True, choices=ACCESS_CHOICES, help_text="Advertise this network as a means for other slices to contact this slice")
     shared_network_name = models.CharField(max_length=30, blank=True, null=True)
     shared_network_id = models.CharField(null=True, blank=True, max_length=256, help_text="Quantum network")
-    topology_kind = models.CharField(null=False, blank=False, max_length=30, choices=TOPOLOGY_CHOICES, default="BigSwitch")
+    topology_kind = models.CharField(null=False, blank=False, max_length=30, choices=TOPOLOGY_CHOICES, default="bigswitch")
     controller_kind = models.CharField(null=True, blank=True, max_length=30, choices=CONTROLLER_CHOICES, default=None)
 
     def __init__(self, *args, **kwargs):
@@ -126,6 +128,10 @@
             print >> sys.stderr, "XXX warning: topology_kind invalid case"
             self.toplogy_kind="custom"
 
+    def save(self, *args, **kwargs):
+        self.enforce_choices(self.access, self.ACCESS_CHOICES)
+        super(NetworkTemplate, self).save(*args, **kwargs)
+
     def __unicode__(self):  return u'%s' % (self.name)
 
 class Network(PlCoreBase, ParameterMixin):
diff --git a/xos/core/models/plcorebase.py b/xos/core/models/plcorebase.py
index 1a2c37c..360792f 100644
--- a/xos/core/models/plcorebase.py
+++ b/xos/core/models/plcorebase.py
@@ -132,6 +132,16 @@
             else:
                 return ("error", html_escape(self.backend_status, quote=True))
 
+    def enforce_choices(self, field, choices):
+        choices = [x[0] for x in choices]
+        for choice in choices:
+            if field==choice:
+                return
+            if (choice==None) and (field==""):
+                # allow "" and None to be equivalent
+                return
+        raise Exception("Field value %s is not in %s" % (field, str(choices)))
+
 class PlCoreBase(models.Model, PlModelMixIn):
     objects = PlCoreBaseManager()
     deleted_objects = PlCoreBaseDeletionManager()
diff --git a/xos/tosca/custom_types/xos.m4 b/xos/tosca/custom_types/xos.m4
index a806327..907d54c 100644
--- a/xos/tosca/custom_types/xos.m4
+++ b/xos/tosca/custom_types/xos.m4
@@ -350,6 +350,10 @@
                 type: string
                 required: false
                 description: Indicates the type of controller that the network is connected to.
+            access:
+                type: string
+                required: false
+                description: The type of access semantics for this network
 
     tosca.nodes.network.Network.XOS:
           # Due to bug? in implementation, we have to copy everything from
diff --git a/xos/tosca/custom_types/xos.yaml b/xos/tosca/custom_types/xos.yaml
index 3339fdf..60968a5 100644
--- a/xos/tosca/custom_types/xos.yaml
+++ b/xos/tosca/custom_types/xos.yaml
@@ -494,6 +494,10 @@
                 type: string
                 required: false
                 description: Indicates the type of controller that the network is connected to.
+            access:
+                type: string
+                required: false
+                description: The type of access semantics for this network
 
     tosca.nodes.network.Network.XOS:
           # Due to bug? in implementation, we have to copy everything from
diff --git a/xos/tosca/resources/networktemplate.py b/xos/tosca/resources/networktemplate.py
index 557964e..3a5ce59 100644
--- a/xos/tosca/resources/networktemplate.py
+++ b/xos/tosca/resources/networktemplate.py
@@ -12,7 +12,7 @@
 class XOSNetworkTemplate(XOSResource):
     provides = "tosca.nodes.NetworkTemplate"
     xos_model = NetworkTemplate
-    copyin_props = ["visibility", "translation", "shared_network_name", "shared_network_id", "toplogy_kind", "controller_kind"]
+    copyin_props = ["visibility", "translation", "shared_network_name", "shared_network_id", "toplogy_kind", "controller_kind", "access"]
 
     def get_xos_args(self):
         args = super(XOSNetworkTemplate, self).get_xos_args()