Added round robin based placement algorithm to dummy GK to use both PoPs for the...
authorpeusterm <manuel.peuster@uni-paderborn.de>
Wed, 31 Aug 2016 17:00:17 +0000 (19:00 +0200)
committerpeusterm <manuel.peuster@uni-paderborn.de>
Wed, 31 Aug 2016 17:01:35 +0000 (19:01 +0200)
src/emuvim/api/sonata/dummygatekeeper.py

index 766ec73..69e5f3c 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
@@ -502,6 +503,21 @@ 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
 """