Commit ce84889d authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Merge branch 'feat/tid-openconfig-multivendor' into 'develop'

Improved OpenConfig Driver and Service Handler

See merge request !69
parents dda9a413 db17e18b
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line Diff line number Diff line
@@ -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(
            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(
            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
+3 −1
Original line number Original line Diff line number Diff line
<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 @@
                {% endif %}
                {% endif %}
            </subinterface>
            </subinterface>
        </subinterfaces>
        </subinterfaces>
        {% endif %}
    </interface>
    </interface>
</interfaces>
</interfaces>
+8 −4
Original line number Original line Diff line number Diff line
@@ -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:
@@ -333,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,
@@ -344,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(
+3 −5
Original line number Original line Diff line number Diff line
@@ -105,19 +105,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
+1 −1
Original line number Original line Diff line number Diff line
@@ -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,
        }),
        }),