add extra options to deploy dummygatekeeper (placement algorithm, bidirectional chaining)
authorSteven Van Rossem <steven.vanrossem@intec.ugent.be>
Tue, 31 Oct 2017 12:29:54 +0000 (13:29 +0100)
committerSteven Van Rossem <steven.vanrossem@intec.ugent.be>
Tue, 31 Oct 2017 12:29:54 +0000 (13:29 +0100)
src/emuvim/api/sonata/__init__.py
src/emuvim/api/sonata/dummygatekeeper.py

index 879320c..4c30d1a 100755 (executable)
@@ -47,7 +47,7 @@ class SonataDummyGatekeeperEndpoint(object):
     """
 
     def __init__(self, listenip, port, deploy_sap=False, docker_management=False,
-                 auto_deploy=False,  auto_delete=False, sap_vnfd_path=None):
+                 auto_deploy=False,  auto_delete=False, sap_vnfd_path=None, bidirectional=False, placement=None):
         self.dcs = {}
         self.ip = listenip
         self.port = port
@@ -56,6 +56,9 @@ class SonataDummyGatekeeperEndpoint(object):
         dgk.AUTO_DEPLOY = auto_deploy
         dgk.AUTO_DELETE = auto_delete
         dgk.SAP_VNFD = sap_vnfd_path
+        dgk.BIDIRECTIONAL_CHAIN = bidirectional
+        if placement is not None:
+            dgk.PLACEMENT_ALGORITHM = placement
         logging.debug("Created API endpoint %s" % self)
 
     def __repr__(self):
index f20483b..bab5cf2 100755 (executable)
@@ -84,6 +84,10 @@ AUTO_DEPLOY = False
 # and also automatically terminate any other running services
 AUTO_DELETE = False
 
+# default placement algorithm to use for this dummygatekeeper instance
+# we need to use the name of the class as a string
+PLACEMENT_ALGORITHM = 'RoundRobinDcPlacementWithSAPs'
+
 def generate_subnets(prefix, base, subnet_size=50, mask=24):
     # Generate a list of ipaddress in subnets
     r = list()
@@ -197,7 +201,8 @@ class Service(object):
         # 2. compute placement of this service instance (adds DC names to VNFDs)
         if not GK_STANDALONE_MODE:
             #self._calculate_placement(FirstDcPlacement)
-            self._calculate_placement(RoundRobinDcPlacementWithSAPs)
+            #self._calculate_placement(RoundRobinDcPlacementWithSAPs)
+            self._calculate_placement(eval(PLACEMENT_ALGORITHM))
         # 3. start all vnfds that we have in the service (except SAPs)
         for vnf_id in self.vnfds:
             vnfd = self.vnfds[vnf_id]
@@ -566,6 +571,7 @@ class Service(object):
 
     def _start_sap(self, sap, instance_uuid):
         if not DEPLOY_SAP:
+            LOG.debug("Not deploying SAPs")
             return
 
         LOG.info('start SAP: {0} ,type: {1}'.format(sap['name'],sap['type']))
@@ -923,13 +929,22 @@ class RoundRobinDcPlacementWithSAPs(object):
                     dc = dcs_list[randint(0, dc_len-1)]
                     saps[intf_sap_id]['dc'] = dc
 
+class CustomPlacementvCDN(object):
+    """
+    Custom placement (hard-coded) for the vCDN example on a 3 pop topology.
+    """
+    def place(self, nsd, vnfds, saps, dcs):
+        vnfds['squid1']["dc"] = dcs['dc1']
+        vnfds['webserver']["dc"] = dcs['dc3']
+        saps['vCDN-SAP1']["dc"] = dcs['dc1']
+        saps['vCDN-SAP2']["dc"] = dcs['dc2']
+
 
 
 """
 Resource definitions and API endpoints
 """
 
-
 class Packages(fr.Resource):
 
     def post(self):