from subprocess import Popen
from random import randint
import ipaddress
+import copy
logging.basicConfig()
LOG = logging.getLogger("sonata-dummy-gatekeeper")
for v in vnf_instances:
self._stop_vnfi(v)
+ for sap_name in self.saps_ext:
+ ext_sap = self.saps[sap_name]
+ target_dc = ext_sap.get("dc")
+ target_dc.removeExternalSAP(sap_name, ext_sap['net'])
+ LOG.info("Stopping the SAP instance: %r in DC %r" % (sap_name, target_dc))
+
if not GK_STANDALONE_MODE:
# remove placement?
# self._remove_placement(RoundRobinPlacement)
# create list of all SAPs
# check if we need to deploy management ports
if USE_DOCKER_MGMT:
- LOG.debug("nsd: {0}".format(self.nsd))
SAPs = [p for p in self.nsd["connection_points"] if 'management' not in p.get('type')]
else:
SAPs = [p for p in self.nsd["connection_points"]]
# first stop and delete any other running services
if AUTO_DELETE:
- for service_uuid in GK.services:
- for instance_uuid in GK.services[service_uuid].instances:
+ service_list = copy.copy(GK.services)
+ for service_uuid in service_list:
+ instances_list = copy.copy(GK.services[service_uuid].instances)
+ for instance_uuid in instances_list:
# valid service and instance UUID, stop service
GK.services.get(service_uuid).stop_service(instance_uuid)
LOG.info("service instance with uuid %r stopped." % instance_uuid)
return link
+ def removeLink(self, link=None, node1=None, node2=None):
+ """
+ Remove the link from the Containernet and the networkx graph
+ """
+ Containernet.removeLink(self, link=link, node1=node1, node2=node2)
+ self.DCNetwork_graph.remove_edge(node2.name, node1.name)
+
def addDocker( self, label, **params ):
"""
Wrapper for addDocker method to use custom container class.
def attachExternalSAP(self, sap_name, sap_net, **params):
# create SAP as separate OVS switch with an assigned ip address
sap_ip = str(sap_net[1]) + '/' + str(sap_net.prefixlen)
+ # allow connection to the external internet through the host
+ params = dict(NAT=True, SAPNet=str(sap_net))
sap_switch = self.net.addExtSAP(sap_name, sap_ip, dpid=hex(self._get_next_extSAP_dpid())[2:], **params)
sap_switch.start()
# link SAP to the DC switch
self.net.addLink(sap_switch, self.switch, cls=Link)
- # allow connection to the external internet through the host
- self.net.addSAPNAT(sap_switch, str(sap_net))
+ def removeExternalSAP(self, sap_name, sap_net):
+ sap_switch = self.net.getNodeByName(sap_name)
+ # link SAP to the DC switch
+ self.net.removeLink(link=None, node1=sap_switch, node2=self.switch)
+ self.net.removeExtSAP(sap_name, str(sap_net))
def listCompute(self):
"""