Skip to content
Snippets Groups Projects
Commit 5b07d6e1 authored by Carlos Natalino Da Silva's avatar Carlos Natalino Da Silva
Browse files

Merge branch 'fix/load-generator-device-index' into 'develop'

Fix issue of `load-generator` when device names include the "-EMU" suffix

See merge request !88
parents d167ccc7 5ea9daf2
No related branches found
No related tags found
2 merge requests!142Release TeraFlowSDN 2.1,!88Fix issue of `load-generator` when device names include the "-EMU" suffix
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import logging, json, random, threading import logging, json, random, re, threading
from typing import Dict, Optional, Set, Tuple from typing import Dict, Optional, Set, Tuple
from common.proto.context_pb2 import Empty, IsolationLevelEnum, TopologyId from common.proto.context_pb2 import Empty, IsolationLevelEnum, TopologyId
from common.tools.grpc.Tools import grpc_message_to_json from common.tools.grpc.Tools import grpc_message_to_json
...@@ -261,12 +261,12 @@ class RequestGenerator: ...@@ -261,12 +261,12 @@ class RequestGenerator:
src_device_name = self._device_data[src_device_uuid]['name'] src_device_name = self._device_data[src_device_uuid]['name']
src_endpoint_name = self._device_endpoint_data[src_device_uuid][src_endpoint_uuid]['name'] src_endpoint_name = self._device_endpoint_data[src_device_uuid][src_endpoint_uuid]['name']
src_router_id = ROUTER_ID.get(src_device_name) src_router_id = ROUTER_ID.get(src_device_name)
src_router_num = int(src_device_name.replace('R', '')) src_router_num = int(re.findall(r'^\D*(\d+)', src_device_name)[0])
if src_router_id is None: src_router_id = '10.0.0.{:d}'.format(src_router_num) if src_router_id is None: src_router_id = '10.0.0.{:d}'.format(src_router_num)
dst_device_name = self._device_data[dst_device_uuid]['name'] dst_device_name = self._device_data[dst_device_uuid]['name']
dst_endpoint_name = self._device_endpoint_data[dst_device_uuid][dst_endpoint_uuid]['name'] dst_endpoint_name = self._device_endpoint_data[dst_device_uuid][dst_endpoint_uuid]['name']
dst_router_num = int(dst_device_name.replace('R', '')) dst_router_num = int(re.findall(r'^\D*(\d+)', dst_device_name)[0])
dst_router_id = ROUTER_ID.get(dst_device_name) dst_router_id = ROUTER_ID.get(dst_device_name)
if dst_router_id is None: dst_router_id = '10.0.0.{:d}'.format(dst_router_num) if dst_router_id is None: dst_router_id = '10.0.0.{:d}'.format(dst_router_num)
...@@ -314,13 +314,13 @@ class RequestGenerator: ...@@ -314,13 +314,13 @@ class RequestGenerator:
src_device_name = self._device_data[src_device_uuid]['name'] src_device_name = self._device_data[src_device_uuid]['name']
src_endpoint_name = self._device_endpoint_data[src_device_uuid][src_endpoint_uuid]['name'] src_endpoint_name = self._device_endpoint_data[src_device_uuid][src_endpoint_uuid]['name']
src_router_id = ROUTER_ID.get(src_device_name) src_router_id = ROUTER_ID.get(src_device_name)
src_router_num = int(src_device_name.replace('R', '')) src_router_num = int(re.findall(r'^\D*(\d+)', src_device_name)[0])
if src_router_id is None: src_router_id = '10.0.0.{:d}'.format(src_router_num) if src_router_id is None: src_router_id = '10.0.0.{:d}'.format(src_router_num)
src_address_ip = '10.{:d}.{:d}.{:d}'.format(x, y, src_router_num) src_address_ip = '10.{:d}.{:d}.{:d}'.format(x, y, src_router_num)
dst_device_name = self._device_data[dst_device_uuid]['name'] dst_device_name = self._device_data[dst_device_uuid]['name']
dst_endpoint_name = self._device_endpoint_data[dst_device_uuid][dst_endpoint_uuid]['name'] dst_endpoint_name = self._device_endpoint_data[dst_device_uuid][dst_endpoint_uuid]['name']
dst_router_num = int(dst_device_name.replace('R', '')) dst_router_num = int(re.findall(r'^\D*(\d+)', dst_device_name)[0])
dst_router_id = ROUTER_ID.get(dst_device_name) dst_router_id = ROUTER_ID.get(dst_device_name)
if dst_router_id is None: dst_router_id = '10.0.0.{:d}'.format(dst_router_num) if dst_router_id is None: dst_router_id = '10.0.0.{:d}'.format(dst_router_num)
dst_address_ip = '10.{:d}.{:d}.{:d}'.format(y, x, dst_router_num) dst_address_ip = '10.{:d}.{:d}.{:d}'.format(y, x, dst_router_num)
...@@ -425,10 +425,10 @@ class RequestGenerator: ...@@ -425,10 +425,10 @@ class RequestGenerator:
circuit_id = '{:03d}'.format(vlan_id) circuit_id = '{:03d}'.format(vlan_id)
src_device_name = self._device_data[src_device_uuid]['name'] src_device_name = self._device_data[src_device_uuid]['name']
src_router_id = '10.0.0.{:d}'.format(int(src_device_name.replace('R', ''))) src_router_id = '10.0.0.{:d}'.format(int(re.findall(r'^\D*(\d+)', src_device_name)[0]))
dst_device_name = self._device_data[dst_device_uuid]['name'] dst_device_name = self._device_data[dst_device_uuid]['name']
dst_router_id = '10.0.0.{:d}'.format(int(dst_device_name.replace('R', ''))) dst_router_id = '10.0.0.{:d}'.format(int(re.findall(r'^\D*(\d+)', dst_device_name)[0]))
config_rules = [ config_rules = [
json_config_rule_set('/settings', { json_config_rule_set('/settings', {
...@@ -460,13 +460,13 @@ class RequestGenerator: ...@@ -460,13 +460,13 @@ class RequestGenerator:
src_device_name = self._device_data[src_device_uuid]['name'] src_device_name = self._device_data[src_device_uuid]['name']
src_endpoint_name = self._device_endpoint_data[src_device_uuid][src_endpoint_uuid]['name'] src_endpoint_name = self._device_endpoint_data[src_device_uuid][src_endpoint_uuid]['name']
src_router_id = '10.0.0.{:d}'.format(int(src_device_name.replace('R', ''))) src_router_id = '10.0.0.{:d}'.format(int(re.findall(r'^\D*(\d+)', src_device_name)[0]))
src_address_ip = '.'.join([src_device_name.replace('R', ''), '0'] + src_endpoint_name.split('/')) src_address_ip = '.'.join([re.findall(r'^\D*(\d+)', src_device_name)[0], '0'] + src_endpoint_name.split('/'))
dst_device_name = self._device_data[dst_device_uuid]['name'] dst_device_name = self._device_data[dst_device_uuid]['name']
dst_endpoint_name = self._device_endpoint_data[dst_device_uuid][dst_endpoint_uuid]['name'] dst_endpoint_name = self._device_endpoint_data[dst_device_uuid][dst_endpoint_uuid]['name']
dst_router_id = '10.0.0.{:d}'.format(int(dst_device_name.replace('R', ''))) dst_router_id = '10.0.0.{:d}'.format(int(re.findall(r'^\D*(\d+)', dst_device_name)[0]))
dst_address_ip = '.'.join([dst_device_name.replace('R', ''), '0'] + dst_endpoint_name.split('/')) dst_address_ip = '.'.join([re.findall(r'^\D*(\d+)', dst_device_name)[0], '0'] + dst_endpoint_name.split('/'))
config_rules = [ config_rules = [
json_config_rule_set('/settings', { json_config_rule_set('/settings', {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment