Fix: Name SAP's interfaces always: sap0
[osm/vim-emu.git] / src / emuvim / api / sonata / dummygatekeeper.py
index 766ec73..c3d8802 100755 (executable)
@@ -164,7 +164,8 @@ class Service(object):
 
         # 3. compute placement of this service instance (adds DC names to VNFDs)
         if not GK_STANDALONE_MODE:
-            self._calculate_placement(FirstDcPlacement)
+            #self._calculate_placement(FirstDcPlacement)
+            self._calculate_placement(RoundRobinDcPlacement)
         # iterate over all vnfds that we have to start
         for vnfd in self.vnfds.itervalues():
             vnfi = None
@@ -391,6 +392,8 @@ class Service(object):
         for sap in SAPs:
             # endpoints needed in this service
             sap_vnf_id, sap_vnf_interface = sap.split(':')
+            # Fix: lets fix the name of the SAP interface to "sap0"
+            sap_vnf_interface = "sap0"
             # set of the connection_point ids found in the nsd (in the examples this is 'ns')
             self.sap_identifiers.add(sap_vnf_id)
 
@@ -502,6 +505,20 @@ class FirstDcPlacement(object):
             vnfd["dc"] = list(dcs.itervalues())[0]
 
 
+class RoundRobinDcPlacement(object):
+    """
+    Placement: Distribute VNFs across all available DCs in a round robin fashion.
+    """
+    def place(self, nsd, vnfds, dcs):
+        c = 0
+        dcs_list = list(dcs.itervalues()) 
+        for name, vnfd in vnfds.iteritems():
+            vnfd["dc"] = dcs_list[c % len(dcs_list)]
+            c += 1  # inc. c to use next DC
+
+
+
+
 """
 Resource definitions and API endpoints
 """