本文整理匯總了Python中mininet.net.Containernet.__init__方法的典型用法代碼示例。如果您正苦於以下問題:Python Containernet.__init__方法的具體用法?Python Containernet.__init__怎麽用?Python Containernet.__init__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mininet.net.Containernet
的用法示例。
在下文中一共展示了Containernet.__init__方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from mininet.net import Containernet [as 別名]
# 或者: from mininet.net.Containernet import __init__ [as 別名]
def __init__(self, controller=RemoteController, monitor=False,
enable_learning = True, # in case of RemoteController (Ryu), learning switch behavior can be turned off/on
dc_emulation_max_cpu=1.0, # fraction of overall CPU time for emulation
dc_emulation_max_mem=512, # emulation max mem in MB
**kwargs):
"""
Create an extended version of a Containernet network
:param dc_emulation_max_cpu: max. CPU time used by containers in data centers
:param kwargs: path through for Mininet parameters
:return:
"""
self.dcs = {}
# make sure any remaining Ryu processes are killed
self.killRyu()
# make sure no containers are left over from a previous emulator run.
self.removeLeftoverContainers()
# call original Docker.__init__ and setup default controller
Containernet.__init__(
self, switch=OVSKernelSwitch, controller=controller, **kwargs)
# Ryu management
self.ryu_process = None
if controller == RemoteController:
# start Ryu controller
self.startRyu(learning_switch=enable_learning)
# add the specified controller
self.addController('c0', controller=controller)
# graph of the complete DC network
self.DCNetwork_graph = nx.MultiDiGraph()
# initialize pool of vlan tags to setup the SDN paths
self.vlans = range(4096)[::-1]
# link to Ryu REST_API
ryu_ip = '0.0.0.0'
ryu_port = '8080'
self.ryu_REST_api = 'http://{0}:{1}'.format(ryu_ip, ryu_port)
# monitoring agent
if monitor:
self.monitor_agent = DCNetworkMonitor(self)
else:
self.monitor_agent = None
# initialize resource model registrar
self.rm_registrar = ResourceModelRegistrar(
dc_emulation_max_cpu, dc_emulation_max_mem)
示例2: __init__
# 需要導入模塊: from mininet.net import Containernet [as 別名]
# 或者: from mininet.net.Containernet import __init__ [as 別名]
def __init__(self, controller=RemoteController, monitor=False,
enable_learning=False, # learning switch behavior of the default ovs switches icw Ryu controller can be turned off/on, needed for E-LAN functionality
dc_emulation_max_cpu=1.0, # fraction of overall CPU time for emulation
dc_emulation_max_mem=512, # emulation max mem in MB
**kwargs):
"""
Create an extended version of a Containernet network
:param dc_emulation_max_cpu: max. CPU time used by containers in data centers
:param kwargs: path through for Mininet parameters
:return:
"""
# members
self.dcs = {}
self.ryu_process = None
#list of deployed nsds.E_Lines and E_LANs (uploaded from the dummy gatekeeper)
self.deployed_nsds = []
self.deployed_elines = []
self.deployed_elans = []
self.vlan_dict = {}
# flag to indicate if the topology has been stopped (e.g. by api call)
self.exit = False
# always cleanup environment before we start the emulator
self.killRyu()
cleanup()
# call original Docker.__init__ and setup default controller
Containernet.__init__(
self, switch=OVSKernelSwitch, controller=controller, **kwargs)
# default switch configuration
enable_ryu_learning = False
if enable_learning :
self.failMode = 'standalone'
enable_ryu_learning = True
else:
self.failMode = 'secure'
# Ryu management
if controller == RemoteController:
# start Ryu controller
self.startRyu(learning_switch=enable_ryu_learning)
# add the specified controller
self.addController('c0', controller=controller)
# graph of the complete DC network
self.DCNetwork_graph = nx.MultiDiGraph()
# initialize pool of vlan tags to setup the SDN paths
self.vlans = range(1, 4095)[::-1]
# link to Ryu REST_API
ryu_ip = 'localhost'
ryu_port = '8080'
self.ryu_REST_api = 'http://{0}:{1}'.format(ryu_ip, ryu_port)
self.RyuSession = requests.Session()
# monitoring agent
if monitor:
self.monitor_agent = DCNetworkMonitor(self)
else:
self.monitor_agent = None
# initialize resource model registrar
self.rm_registrar = ResourceModelRegistrar(
dc_emulation_max_cpu, dc_emulation_max_mem)
self.cpu_period = CPU_PERIOD