X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=src%2Femuvim%2Fdcemulator%2Fnet.py;h=8f627b5b13ed2f01401ac6bf1661471ded8a0997;hb=4fac2afba3182039dae6216d267d13eb3b98a56f;hp=731331b259cb74d80ecb53bc1f1c9a1927e3f1df;hpb=566779d267065c78708112623f9c60afcb01696e;p=osm%2Fvim-emu.git diff --git a/src/emuvim/dcemulator/net.py b/src/emuvim/dcemulator/net.py index 731331b..8f627b5 100755 --- a/src/emuvim/dcemulator/net.py +++ b/src/emuvim/dcemulator/net.py @@ -47,6 +47,9 @@ from emuvim.dcemulator.resourcemodel import ResourceModelRegistrar LOG = logging.getLogger("dcemulator.net") LOG.setLevel(logging.DEBUG) +# default CPU period used for cpu percentage-based cfs values (microseconds) +CPU_PERIOD = 1000000 + class DCNetwork(Containernet): """ Wraps the original Mininet/Containernet class and provides @@ -56,7 +59,7 @@ class DCNetwork(Containernet): """ 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, neede for E-LAN functionality + 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): @@ -121,6 +124,7 @@ class DCNetwork(Containernet): # initialize resource model registrar self.rm_registrar = ResourceModelRegistrar( dc_emulation_max_cpu, dc_emulation_max_mem) + self.cpu_period = CPU_PERIOD def addDatacenter(self, label, metadata={}, resource_log_path=None): """ @@ -338,6 +342,17 @@ class DCNetwork(Containernet): def _addMonitorFlow(self, vnf_src_name, vnf_dst_name, vnf_src_interface=None, vnf_dst_interface=None, tag=None, **kwargs): + """ + Add a monitoring flow entry that adds a special flowentry/counter at the begin or end of a chain. + So this monitoring flowrule exists on top of a previously defined chain rule and uses the same vlan tag/routing. + :param vnf_src_name: + :param vnf_dst_name: + :param vnf_src_interface: + :param vnf_dst_interface: + :param tag: vlan tag to be used for this chain (same tag as existing chain) + :param monitor_placement: 'tx' or 'rx' indicating to place the extra flowentry resp. at the beginning or end of the chain + :return: + """ src_sw = None src_sw_inport_nr = 0 @@ -442,7 +457,7 @@ class DCNetwork(Containernet): kwargs['switch_outport_name'] = dst_sw_outport_name kwargs['skip_vlan_tag'] = True - monitor_placement = kwargs.get('monitor_placement') + monitor_placement = kwargs.get('monitor_placement').strip() # put monitor flow at the dst switch insert_flow = False if monitor_placement == 'tx' and path.index(current_hop) == 0: # first node: @@ -450,7 +465,7 @@ class DCNetwork(Containernet): # put monitoring flow at the src switch elif monitor_placement == 'rx' and path.index(current_hop) == len(path) - 1: # last node: insert_flow = True - else: + elif monitor_placement not in ['rx', 'tx']: LOG.exception('invalid monitor command: {0}'.format(monitor_placement)) @@ -485,6 +500,8 @@ class DCNetwork(Containernet): :param cookie: cookie for the installed flowrules (can be used later as identifier for a set of installed chains) :param match: custom match entry to be added to the flowrules (default: only in_port and vlan tag) :param priority: custom flowrule priority + :param monitor: boolean to indicate whether this chain is a monitoring chain + :param tag: vlan tag to be used for this chain (pre-defined or new one if none is specified) :return: output log string """ @@ -507,7 +524,7 @@ class DCNetwork(Containernet): return ret else: # no chain existing (or E-LAN) -> install normal chain - LOG.warning('*** installing monitoring chain without pre-defined chain from {0}:{1} -> {2}:{3}'. + LOG.warning('*** installing monitoring chain without pre-defined NSD chain from {0}:{1} -> {2}:{3}'. format(vnf_src_name, vnf_src_interface, vnf_dst_name, vnf_dst_interface)) pass