From: Steven Van Rossem Date: Tue, 31 Oct 2017 12:29:54 +0000 (+0100) Subject: add extra options to deploy dummygatekeeper (placement algorithm, bidirectional chaining) X-Git-Tag: v3.1~1^2~4 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=7549925a27f629f42c4f93c227989b51b4c842cd;p=osm%2Fvim-emu.git add extra options to deploy dummygatekeeper (placement algorithm, bidirectional chaining) --- diff --git a/src/emuvim/api/sonata/__init__.py b/src/emuvim/api/sonata/__init__.py index 879320c..4c30d1a 100755 --- a/src/emuvim/api/sonata/__init__.py +++ b/src/emuvim/api/sonata/__init__.py @@ -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): diff --git a/src/emuvim/api/sonata/dummygatekeeper.py b/src/emuvim/api/sonata/dummygatekeeper.py index f20483b..bab5cf2 100755 --- a/src/emuvim/api/sonata/dummygatekeeper.py +++ b/src/emuvim/api/sonata/dummygatekeeper.py @@ -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):