本文整理汇总了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