Skip to content
Snippets Groups Projects
Commit ed9f2726 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Merge branch 'develop' of https://labs.etsi.org/rep/tfs/controller into feat/device-ietf-l2vpn

parents a7acb1bc ce84889d
No related branches found
No related tags found
2 merge requests!142Release TeraFlowSDN 2.1,!71OFC'23 + IETF L2VPN Device Driver + Device Controllers + Multiple small improvements
...@@ -201,7 +201,7 @@ def edit_config( ...@@ -201,7 +201,7 @@ def edit_config(
for i,resource in enumerate(resources): for i,resource in enumerate(resources):
str_resource_name = 'resources[#{:d}]'.format(i) str_resource_name = 'resources[#{:d}]'.format(i)
try: try:
#logger.debug('[{:s}] resource = {:s}'.format(str_method, str(resource))) logger.debug('[{:s}] resource = {:s}'.format(str_method, str(resource)))
chk_type(str_resource_name, resource, (list, tuple)) chk_type(str_resource_name, resource, (list, tuple))
chk_length(str_resource_name, resource, min_length=2, max_length=2) chk_length(str_resource_name, resource, min_length=2, max_length=2)
resource_key,resource_value = resource resource_key,resource_value = resource
...@@ -209,8 +209,8 @@ def edit_config( ...@@ -209,8 +209,8 @@ def edit_config(
str_config_message = compose_config( str_config_message = compose_config(
resource_key, resource_value, delete=delete, vendor=netconf_handler.vendor) resource_key, resource_value, delete=delete, vendor=netconf_handler.vendor)
if str_config_message is None: raise UnsupportedResourceKeyException(resource_key) if str_config_message is None: raise UnsupportedResourceKeyException(resource_key)
#logger.debug('[{:s}] str_config_message[{:d}] = {:s}'.format( logger.debug('[{:s}] str_config_message[{:d}] = {:s}'.format(
# str_method, len(str_config_message), str(str_config_message))) str_method, len(str_config_message), str(str_config_message)))
netconf_handler.edit_config( netconf_handler.edit_config(
config=str_config_message, target=target, default_operation=default_operation, config=str_config_message, target=target, default_operation=default_operation,
test_option=test_option, error_option=error_option, format=format) test_option=test_option, error_option=error_option, format=format)
...@@ -228,6 +228,7 @@ def edit_config( ...@@ -228,6 +228,7 @@ def edit_config(
netconf_handler.commit() netconf_handler.commit()
except Exception as e: # pylint: disable=broad-except except Exception as e: # pylint: disable=broad-except
msg = '[{:s}] Exception committing: {:s}' msg = '[{:s}] Exception committing: {:s}'
str_operation = 'preparing' if target == 'candidate' else ('deleting' if delete else 'setting')
logger.exception(msg.format(str_method, str_operation, str(resources))) logger.exception(msg.format(str_method, str_operation, str(resources)))
results = [e for _ in resources] # if commit fails, set exception in each resource results = [e for _ in resources] # if commit fails, set exception in each resource
return results return results
......
<interfaces xmlns="http://openconfig.net/yang/interfaces" <interfaces xmlns="http://openconfig.net/yang/interfaces"
xmlns:oc-ip="http://openconfig.net/yang/interfaces/ip" > xmlns:oc-ip="http://openconfig.net/yang/interfaces/ip" >
<interface> <interface{% if operation is defined %} xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="{{operation}}"{% endif %}>
<name>{{name}}</name> <name>{{name}}</name>
{% if operation is defined and operation != 'delete' %}
<config> <config>
<name>{{name}}</name> <name>{{name}}</name>
<type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:{{type}}</type> <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:{{type}}</type>
...@@ -44,5 +45,6 @@ ...@@ -44,5 +45,6 @@
{% endif %} {% endif %}
</subinterface> </subinterface>
</subinterfaces> </subinterfaces>
{% endif %}
</interface> </interface>
</interfaces> </interfaces>
...@@ -37,11 +37,15 @@ LOGGER = logging.getLogger(__name__) ...@@ -37,11 +37,15 @@ LOGGER = logging.getLogger(__name__)
ROUTER_ID = { ROUTER_ID = {
'R149': '5.5.5.5', 'R149': '5.5.5.5',
'R155': '5.5.5.1', 'R155': '5.5.5.1',
'R199': '5.5.5.6',
} }
VIRTUAL_CIRCUIT = { VIRTUAL_CIRCUIT = {
'R149': '5.5.5.5', 'R149': '5.5.5.5',
'R155': '5.5.5.1', 'R155': '5.5.5.1',
'R199': '5.5.5.6',
} }
class RequestGenerator: class RequestGenerator:
...@@ -255,10 +259,16 @@ class RequestGenerator: ...@@ -255,10 +259,16 @@ class RequestGenerator:
circuit_id = '{:03d}'.format(vlan_id + 100) circuit_id = '{:03d}'.format(vlan_id + 100)
src_device_name = self._device_data[src_device_uuid]['name'] src_device_name = self._device_data[src_device_uuid]['name']
src_router_id = ROUTER_ID.get(src_device_name, '10.0.0.{:d}'.format(int(src_device_name.replace('R', '')))) 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_num = int(src_device_name.replace('R', ''))
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_router_id = ROUTER_ID.get(dst_device_name, '10.0.0.{:d}'.format(int(dst_device_name.replace('R', '')))) 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_id = ROUTER_ID.get(dst_device_name)
if dst_router_id is None: dst_router_id = '10.0.0.{:d}'.format(dst_router_num)
config_rules = [ config_rules = [
json_config_rule_set('/settings', { json_config_rule_set('/settings', {
...@@ -327,7 +337,7 @@ class RequestGenerator: ...@@ -327,7 +337,7 @@ class RequestGenerator:
'/device[{:s}]/endpoint[{:s}]/settings'.format(src_device_name, src_endpoint_name), { '/device[{:s}]/endpoint[{:s}]/settings'.format(src_device_name, src_endpoint_name), {
'router_id' : src_router_id, 'router_id' : src_router_id,
'route_distinguisher': route_distinguisher, 'route_distinguisher': route_distinguisher,
'sub_interface_index': vlan_id, 'sub_interface_index': 0,
'vlan_id' : vlan_id, 'vlan_id' : vlan_id,
'address_ip' : src_address_ip, 'address_ip' : src_address_ip,
'address_prefix' : 16, 'address_prefix' : 16,
...@@ -338,12 +348,12 @@ class RequestGenerator: ...@@ -338,12 +348,12 @@ class RequestGenerator:
'/device[{:s}]/endpoint[{:s}]/settings'.format(dst_device_name, dst_endpoint_name), { '/device[{:s}]/endpoint[{:s}]/settings'.format(dst_device_name, dst_endpoint_name), {
'router_id' : dst_router_id, 'router_id' : dst_router_id,
'route_distinguisher': route_distinguisher, 'route_distinguisher': route_distinguisher,
'sub_interface_index': vlan_id, 'sub_interface_index': 0,
'vlan_id' : vlan_id, 'vlan_id' : vlan_id,
'address_ip' : dst_address_ip, 'address_ip' : dst_address_ip,
'address_prefix' : 16, 'address_prefix' : 16,
'policy_AZ' : policy_AZ, 'policy_ZA' : policy_AZ,
'policy_ZA' : policy_ZA, 'policy_AZ' : policy_ZA,
}), }),
] ]
return json_service_l3nm_planned( return json_service_l3nm_planned(
......
...@@ -104,19 +104,17 @@ def teardown_config_rules( ...@@ -104,19 +104,17 @@ def teardown_config_rules(
if_cirid_name = '{:s}.{:s}'.format(endpoint_name, str(circuit_id)) if_cirid_name = '{:s}.{:s}'.format(endpoint_name, str(circuit_id))
network_instance_name = 'ELAN-AC:{:s}'.format(str(circuit_id)) network_instance_name = 'ELAN-AC:{:s}'.format(str(circuit_id))
connection_point_id = 'VC-1' #connection_point_id = 'VC-1'
json_config_rules = [ json_config_rules = [
json_config_rule_delete( json_config_rule_delete(
'/network_instance[{:s}]'.format(network_instance_name), '/network_instance[{:s}]'.format(network_instance_name),
{'name': network_instance_name}), {'name': network_instance_name}),
json_config_rule_delete( json_config_rule_delete(
'/interface[{:s}]'.format(if_cirid_name), { '/interface[{:s}]/subinterface[0]'.format(if_cirid_name),{
'name': if_cirid_name, 'name': if_cirid_name,
}), }),
] ]
return json_config_rules return json_config_rules
...@@ -252,7 +252,7 @@ def teardown_config_rules( ...@@ -252,7 +252,7 @@ def teardown_config_rules(
#Delete interface; automatically deletes: #Delete interface; automatically deletes:
# - /interface[]/subinterface[] # - /interface[]/subinterface[]
json_config_rule_delete('/interface[{:s}]'.format(if_subif_name), json_config_rule_delete('/interface[{:s}]/subinterface[0]'.format(if_subif_name),
{ {
'name': if_subif_name, 'name': if_subif_name,
}), }),
......
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