Skip to content
Snippets Groups Projects
Commit 7079e9fc authored by delacal's avatar delacal
Browse files

Merge branch 'develop' into feat/l3-components

parents 70e61a71 80a8951e
No related branches found
No related tags found
2 merge requests!142Release TeraFlowSDN 2.1,!93Updated L3 components + scalability
Showing
with 252 additions and 83 deletions
......@@ -61,11 +61,13 @@ class NetconfSessionHandler:
self.__port = int(port)
self.__username = settings.get('username')
self.__password = settings.get('password')
self.__vendor = settings.get('vendor')
self.__key_filename = settings.get('key_filename')
self.__hostkey_verify = settings.get('hostkey_verify', True)
self.__look_for_keys = settings.get('look_for_keys', True)
self.__allow_agent = settings.get('allow_agent', True)
self.__force_running = settings.get('force_running', False)
self.__commit_per_delete = settings.get('delete_rule', False)
self.__device_params = settings.get('device_params', {})
self.__manager_params = settings.get('manager_params', {})
self.__nc_params = settings.get('nc_params', {})
......@@ -90,6 +92,12 @@ class NetconfSessionHandler:
@property
def use_candidate(self): return self.__candidate_supported and not self.__force_running
@property
def commit_per_rule(self): return self.__commit_per_delete
@property
def vendor(self): return self.__vendor
@RETRY_DECORATOR
def get(self, filter=None, with_defaults=None): # pylint: disable=redefined-builtin
with self.__lock:
......@@ -181,8 +189,9 @@ def do_sampling(samples_cache : SamplesCache, resource_key : str, out_samples :
LOGGER.exception('Error retrieving samples')
def edit_config(
netconf_handler : NetconfSessionHandler, resources : List[Tuple[str, Any]], delete=False, target='running',
default_operation='merge', test_option=None, error_option=None, format='xml' # pylint: disable=redefined-builtin
netconf_handler : NetconfSessionHandler, resources : List[Tuple[str, Any]], delete=False, commit_per_rule= False,
target='running', default_operation='merge', test_option=None, error_option=None,
format='xml' # pylint: disable=redefined-builtin
):
str_method = 'DeleteConfig' if delete else 'SetConfig'
LOGGER.info('[{:s}] resources = {:s}'.format(str_method, str(resources)))
......@@ -195,13 +204,16 @@ def edit_config(
chk_length(str_resource_name, resource, min_length=2, max_length=2)
resource_key,resource_value = resource
chk_string(str_resource_name + '.key', resource_key, allow_empty=False)
str_config_message = compose_config(resource_key, resource_value, delete=delete)
str_config_message = compose_config(
resource_key, resource_value, delete=delete, vendor=netconf_handler.vendor)
if str_config_message is None: raise UnsupportedResourceKeyException(resource_key)
LOGGER.info('[{:s}] str_config_message[{:d}] = {:s}'.format(
str_method, len(str_config_message), str(str_config_message)))
netconf_handler.edit_config(
config=str_config_message, target=target, default_operation=default_operation,
test_option=test_option, error_option=error_option, format=format)
if commit_per_rule:
netconf_handler.commit()
results[i] = True
except Exception as e: # pylint: disable=broad-except
str_operation = 'preparing' if target == 'candidate' else ('deleting' if delete else 'setting')
......@@ -278,12 +290,15 @@ class OpenConfigDriver(_Driver):
with self.__lock:
if self.__netconf_handler.use_candidate:
with self.__netconf_handler.locked(target='candidate'):
results = edit_config(self.__netconf_handler, resources, target='candidate')
try:
self.__netconf_handler.commit()
except Exception as e: # pylint: disable=broad-except
LOGGER.exception('[SetConfig] Exception commiting resources: {:s}'.format(str(resources)))
results = [e for _ in resources] # if commit fails, set exception in each resource
if self.__netconf_handler.commit_per_rule:
results = edit_config(self.__netconf_handler, resources, target='candidate', commit_per_rule= True)
else:
results = edit_config(self.__netconf_handler, resources, target='candidate')
try:
self.__netconf_handler.commit()
except Exception as e: # pylint: disable=broad-except
LOGGER.exception('[SetConfig] Exception commiting resources: {:s}'.format(str(resources)))
results = [e for _ in resources] # if commit fails, set exception in each resource
else:
results = edit_config(self.__netconf_handler, resources)
return results
......@@ -294,12 +309,15 @@ class OpenConfigDriver(_Driver):
with self.__lock:
if self.__netconf_handler.use_candidate:
with self.__netconf_handler.locked(target='candidate'):
results = edit_config(self.__netconf_handler, resources, target='candidate', delete=True)
try:
self.__netconf_handler.commit()
except Exception as e: # pylint: disable=broad-except
LOGGER.exception('[DeleteConfig] Exception commiting resources: {:s}'.format(str(resources)))
results = [e for _ in resources] # if commit fails, set exception in each resource
if self.__netconf_handler.commit_per_rule:
results = edit_config(self.__netconf_handler, resources, target='candidate', delete=True, commit_per_rule= True)
else:
results = edit_config(self.__netconf_handler, resources, target='candidate', delete=True)
try:
self.__netconf_handler.commit()
except Exception as e: # pylint: disable=broad-except
LOGGER.exception('[DeleteConfig] Exception commiting resources: {:s}'.format(str(resources)))
results = [e for _ in resources] # if commit fails, set exception in each resource
else:
results = edit_config(self.__netconf_handler, resources, delete=True)
return results
......
......@@ -37,6 +37,10 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]:
#interface_type = xml_interface.find('oci:config/oci:type', namespaces=NAMESPACES)
#add_value_from_tag(interface, 'type', interface_type)
interface_type = xml_interface.find('oci:config/oci:type', namespaces=NAMESPACES)
interface_type.text = interface_type.text.replace('ianaift:','')
add_value_from_tag(interface, 'type', interface_type)
interface_mtu = xml_interface.find('oci:config/oci:mtu', namespaces=NAMESPACES)
add_value_from_tag(interface, 'mtu', interface_mtu, cast=int)
......@@ -49,12 +53,15 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]:
subinterface = {}
add_value_from_tag(subinterface, 'name', interface_name)
add_value_from_tag(subinterface, 'mtu', interface_mtu)
add_value_from_tag(subinterface, 'type', interface_type)
subinterface_index = xml_subinterface.find('oci:index', namespaces=NAMESPACES)
if subinterface_index is None or subinterface_index.text is None: continue
add_value_from_tag(subinterface, 'index', subinterface_index, cast=int)
vlan_id = xml_subinterface.find('ocv:vlan/ocv:config/ocv:vlan-id', namespaces=NAMESPACES)
vlan_id = xml_subinterface.find('ocv:vlan/ocv:match/ocv:single-tagged/ocv:config/ocv:vlan-id', namespaces=NAMESPACES)
add_value_from_tag(subinterface, 'vlan_id', vlan_id, cast=int)
# TODO: implement support for multiple IP addresses per subinterface
......
......@@ -27,6 +27,9 @@ XPATH_NI_IIP_AP = ".//ocni:inter-instance-policies/ocni:apply-policy"
XPATH_NI_IIP_AP_IMPORT = ".//ocni:config/ocni:import-policy"
XPATH_NI_IIP_AP_EXPORT = ".//ocni:config/ocni:export-policy"
XPATH_NI_CPOINTS = ".//ocni:connection-points/ocni:connection-point"
XPATH_NI_CPOINTS_ENDPOINT = ".//ocni:endpoints/ocni:endpoint/ocni:remote/ocni:config"
def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]:
response = []
for xml_network_instance in xml_data.xpath(XPATH_NETWORK_INSTANCES, namespaces=NAMESPACES):
......@@ -39,10 +42,11 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]:
add_value_from_tag(network_instance, 'name', ni_name)
ni_type = xml_network_instance.find('ocni:config/ocni:type', namespaces=NAMESPACES)
ni_type.text = ni_type.text.replace('oc-ni-types:','')
add_value_from_tag(network_instance, 'type', ni_type)
#ni_router_id = xml_network_instance.find('ocni:config/ocni:router-id', namespaces=NAMESPACES)
#add_value_from_tag(network_instance, 'router_id', ni_router_id)
ni_router_id = xml_network_instance.find('ocni:config/ocni:router-id', namespaces=NAMESPACES)
add_value_from_tag(network_instance, 'router_id', ni_router_id)
ni_route_dist = xml_network_instance.find('ocni:config/ocni:route-distinguisher', namespaces=NAMESPACES)
add_value_from_tag(network_instance, 'route_distinguisher', ni_route_dist)
......@@ -53,6 +57,20 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]:
if len(network_instance) == 0: continue
response.append(('/network_instance[{:s}]'.format(network_instance['name']), network_instance))
for xml_cpoints in xml_network_instance.xpath(XPATH_NI_PROTOCOLS, namespaces=NAMESPACES):
cpoint = {}
add_value_from_tag(cpoint, 'name', ni_name)
connection_point = xml_cpoints.find('ocni:connection-point-id', namespaces=NAMESPACES)
add_value_from_tag(cpoint, 'connection_point', connection_point)
for xml_endpoint in xml_cpoints.xpath(XPATH_NI_CPOINTS_ENDPOINT, namespaces=NAMESPACES):
remote_system = xml_endpoint.find('ocni:remote-system', namespaces=NAMESPACES)
add_value_from_tag(cpoint, 'remote_system', remote_system)
VC_ID = xml_endpoint.find('ocni:virtual-circuit-identifier', namespaces=NAMESPACES)
add_value_from_tag(cpoint, 'VC_ID', VC_ID)
for xml_protocol in xml_network_instance.xpath(XPATH_NI_PROTOCOLS, namespaces=NAMESPACES):
#LOGGER.info('xml_protocol = {:s}'.format(str(ET.tostring(xml_protocol))))
......@@ -71,6 +89,8 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]:
if protocol['identifier'] == 'BGP':
bgp_as = xml_protocol.find('ocni:bgp/ocni:global/ocni:config/ocni:as', namespaces=NAMESPACES)
add_value_from_tag(protocol, 'as', bgp_as, cast=int)
bgp_id = xml_protocol.find('ocni:bgp/ocni:global/ocni:config/ocni:router-id', namespaces=NAMESPACES)
add_value_from_tag(protocol, 'router_id', bgp_id)
resource_key = '/network_instance[{:s}]/protocols[{:s}]'.format(
network_instance['name'], protocol['identifier'])
......@@ -94,7 +114,7 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]:
add_value_from_tag(table_connection, 'address_family', address_family,
cast=lambda s: s.replace('oc-types:', ''))
default_import_policy = xml_table_connection.find('ocni:default-import-policy', namespaces=NAMESPACES)
default_import_policy = xml_table_connection.find('ocni:config/ocni:default-import-policy', namespaces=NAMESPACES)
add_value_from_tag(table_connection, 'default_import_policy', default_import_policy)
resource_key = '/network_instance[{:s}]/table_connections[{:s}][{:s}][{:s}]'.format(
......@@ -125,4 +145,7 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]:
iip_ap['name'], iip_ap['export_policy'])
response.append((resource_key, iip_ap))
return response
......@@ -74,7 +74,7 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]:
resource_key = '/routing_policy/bgp_defined_set[{:s}]'.format(bgp_ext_community_set['ext_community_set_name'])
response.append((resource_key, copy.deepcopy(bgp_ext_community_set)))
ext_community_member = xml_bgp_ext_community_set.find('ocbp:ext-community-member', namespaces=NAMESPACES)
ext_community_member = xml_bgp_ext_community_set.find('ocbp:config/ocbp:ext-community-member', namespaces=NAMESPACES)
if ext_community_member is not None and ext_community_member.text is not None:
add_value_from_tag(bgp_ext_community_set, 'ext_community_member', ext_community_member)
......
......@@ -13,7 +13,7 @@
# limitations under the License.
import json, logging, lxml.etree as ET, re
from typing import Any, Dict
from typing import Any, Dict, Optional
from jinja2 import Environment, PackageLoader, select_autoescape
from device.service.driver_api._Driver import (
RESOURCE_ENDPOINTS, RESOURCE_INTERFACES, RESOURCE_NETWORK_INSTANCES, RESOURCE_ROUTING_POLICIES, RESOURCE_ACL)
......@@ -77,9 +77,11 @@ def parse(resource_key : str, xml_data : ET.Element):
if parser is None: return [(resource_key, xml_data)]
return parser(xml_data)
def compose_config(resource_key : str, resource_value : str, delete : bool = False) -> str:
def compose_config(
resource_key : str, resource_value : str, delete : bool = False, vendor : Optional[str] = None
) -> str:
template_name = '{:s}/edit_config.xml'.format(RE_REMOVE_FILTERS.sub('', resource_key))
template = JINJA_ENV.get_template(template_name)
data : Dict[str, Any] = json.loads(resource_value)
operation = 'delete' if delete else 'merge'
return '<config>{:s}</config>'.format(template.render(**data, operation=operation).strip())
return '<config>{:s}</config>'.format(template.render(**data, operation=operation, vendor=vendor).strip())
......@@ -13,6 +13,16 @@
<config>
<sequence-id>{{sequence_id}}</sequence-id>
</config>
{% if operation is not defined or operation != 'delete' %}
{% if type=='ACL_L2' %}
<l2>
<config>
{% if source_address is defined %}<source-mac>{{source_address}}</source-mac>{% endif%}
{% if destination_address is defined %}<destination-mac>{{destination_address}}</destination-mac>{% endif%}
</config>
</l2>
{% endif%}
{% if type=='ACL_IPV4' %}
<ipv4>
<config>
{% if source_address is defined %}<source-address>{{source_address}}</source-address>{% endif%}
......@@ -29,12 +39,26 @@
{% if tcp_flags is defined %}<tcp-flags>{{tcp_flags}}</tcp-flags>{% endif%}
</config>
</transport>
{% endif%}
{% if type=='ACL_IPV6' %}
<ipv6>
<config>
{% if source_address is defined %}<source-address>{{source_address}}</source-address>{% endif%}
{% if destination_address is defined %}<destination-address>{{destination_address}}</destination-address>{% endif%}
{% if protocol is defined %}<protocol>{{protocol}}</protocol>{% endif%}
{% if dscp is defined %}<dscp>{{dscp}}</dscp>{% endif%}
{% if hop_limit is defined %}<hop-limit>{{hop_limit}}</hop-limit>{% endif%}
</config>
</ipv6>
{% endif%}
<actions>
<config>
{% if forwarding_action is defined %}<forwarding-action>{{forwarding_action}}</forwarding-action>{% endif%}
{% if log_action is defined %}<log-action>{{log_action}}</log-action>{% endif%}
</config>
</actions>
{% endif%}
</acl-entry>
</acl-entries>
</acl-set>
......
<acl xmlns="http://openconfig.net/yang/acl">
<interfaces>
<interface{% if operation is defined %} xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="{{operation}}"{% endif %}>
<interface {% if operation is defined %}{% if all is defined %} xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="{{operation}}"{% endif %} {% endif %}>
<id>{{id}}</id>
<config>
<id>{{id}}</id>
</config>
{% if interface is defined %}
<interface-ref>
<config>
<interface>{{interface}}</interface>
{% if subinterface is defined %}<subinterface>{{subinterface}}</subinterface>{% endif%}
</config>
</interface-ref>
{% endif%}
{% if set_name_egress is defined %}
<egress-acl-sets>
<egress-acl-set>
<egress-acl-set {% if operation is defined %}{% if egress is defined %} xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="{{operation}}"{% endif %} {% endif %}>>
<set-name>{{set_name_egress}}</set-name>
<type>{{type_egress}}</type>
<config>
......@@ -21,6 +24,7 @@
</config>
</egress-acl-set>
</egress-acl-sets>
{% endif%}
</interface>
</interfaces>
</acl>
<acl xmlns="http://openconfig.net/yang/acl">
<interfaces>
<interface{% if operation is defined %} xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="{{operation}}"{% endif %}>
<interface {% if operation is defined %}{% if all is defined %} xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="{{operation}}"{% endif %} {% endif %}>
<id>{{id}}</id>
<config>
<id>{{id}}</id>
</config>
{% if interface is defined %}
<interface-ref>
<config>
<interface>{{interface}}</interface>
{% if subinterface is defined %}<subinterface>{{subinterface}}</subinterface>{% endif%}
</config>
</interface-ref>
{% endif%}
{% if set_name_ingress is defined %}
<ingress-acl-sets>
<ingress-acl-set>
<ingress-acl-set {% if operation is defined %}{% if ingress is defined %} xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="{{operation}}"{% endif %} {% endif %}>
<set-name>{{set_name_ingress}}</set-name>
<type>{{type_ingress}}</type>
<config>
......@@ -21,6 +24,7 @@
</config>
</ingress-acl-set>
</ingress-acl-sets>
{% endif%}
</interface>
</interfaces>
</acl>
<interfaces xmlns="http://openconfig.net/yang/interfaces">
<interface{% if operation is defined and operation != 'delete' %} xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="{{operation}}"{% endif %}>
<interface{% if operation is defined %} xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="{{operation}}"{% endif %}>
<name>{{name}}</name>
{% if operation is defined and operation != 'delete' %}
<config>
<name>{{name}}</name>
{% if operation is defined and operation == 'delete' %}
<description></description>
{% else %}
<description>{{description}}</description>
<mtu>{{mtu}}</mtu>
{% endif %}
</config>
{% endif %}
</interface>
</interfaces>
<interfaces xmlns="http://openconfig.net/yang/interfaces">
<interface>
<name>{{name}}</name>
{% if operation is not defined or operation != 'delete' %}
<interfaces xmlns="http://openconfig.net/yang/interfaces"
xmlns:oc-ip="http://openconfig.net/yang/interfaces/ip" >
<interface>
<name>{{name}}</name>
<config>
<name>{{name}}</name>
<type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:{{type}}</type>
{% if mtu is defined %}<mtu>{{mtu}}</mtu>{% endif%}
<enabled>true</enabled>
</config>
<subinterfaces>
<subinterface>
<index>{{index}}</index>
<config>
<name>{{name}}</name>
<index>{{index}}</index>
<description>{{description}}</description>
{% if vendor=="ADVA" and vlan_id is not defined %}
<untagged-allowed xmlns="http://www.advaoptical.com/cim/adva-dnos-oc-interfaces">true</untagged-allowed>
{% endif%}
</config>
{% endif %}
<subinterfaces>
<subinterface{% if operation is defined %} xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="{{operation}}"{% endif %}>
<index>{{index}}</index>
{% if operation is not defined or operation != 'delete' %}
<config>
<index>{{index}}</index>
<enabled>true</enabled>
</config>
<vlan xmlns="http://openconfig.net/yang/vlan">
<config>
<vlan-id>{{vlan_id}}</vlan-id>
</config>
</vlan>
<ipv4 xmlns="http://openconfig.net/yang/interfaces/ip">
<addresses>
<address>
<ip>{{address_ip}}</ip>
<config>
<ip>{{address_ip}}</ip>
<prefix-length>{{address_prefix}}</prefix-length>
</config>
</address>
</addresses>
</ipv4>
{% endif %}
</subinterface>
</subinterfaces>
</interface>
{% if vlan_id is defined %}
<vlan xmlns="http://openconfig.net/yang/vlan">
<match>
<single-tagged>
<config>
<vlan-id>{{vlan_id}}</vlan-id>
</config>
</single-tagged>
</match>
</vlan>
{% endif%}
{% if address_ip is defined %}
<oc-ip:ipv4>
<oc-ip:addresses>
<oc-ip:address>
<oc-ip:ip>{{address_ip}}</oc-ip:ip>
<oc-ip:config>
<oc-ip:ip>{{address_ip}}</oc-ip:ip>
<oc-ip:prefix-length>{{address_prefix}}</oc-ip:prefix-length>
</oc-ip:config>
</oc-ip:address>
</oc-ip:addresses>
</oc-ip:ipv4>
{% endif%}
</subinterface>
</subinterfaces>
</interface>
</interfaces>
<network-instances xmlns="http://openconfig.net/yang/network-instance">
<network-instance>
<name>{{name}}</name>
<connection-points>
<connection-point>
<connection-point-id>{{connection_point}}</connection-point-id>
<config>
<connection-point-id>{{connection_point}}</connection-point-id>
</config>
<endpoints>
<endpoint>
<endpoint-id>{{connection_point}}</endpoint-id>
<config>
<endpoint-id>{{connection_point}}</endpoint-id>
<precedence>1</precedence>
<type xmlns:oc-ni-types="http://openconfig.net/yang/network-instance-types">oc-ni-types:REMOTE</type>
</config>
<remote>
<config>
<virtual-circuit-identifier>{{VC_ID}}</virtual-circuit-identifier>
<remote-system>{{remote_system}}</remote-system>
</config>
</remote>
</endpoint>
</endpoints>
</connection-point>
</connection-points>
</network-instance>
</network-instances>
\ No newline at end of file
......@@ -5,7 +5,8 @@
<config>
<name>{{name}}</name>
<type xmlns:oc-ni-types="http://openconfig.net/yang/network-instance-types">oc-ni-types:{{type}}</type>
<description>{{description}}</description>
{% if type=='L3VRF' %}
{% if description is defined %}<description>{{description}}</description>{% endif %}
{% if router_id is defined %}<router-id>{{router_id}}</router-id>{% endif %}
<route-distinguisher>{{route_distinguisher}}</route-distinguisher>
<enabled>true</enabled>
......@@ -13,8 +14,29 @@
<encapsulation>
<config>
<encapsulation-type xmlns:oc-ni-types="http://openconfig.net/yang/network-instance-types">oc-ni-types:MPLS</encapsulation-type>
<label-allocation-mode xmlns:oc-ni-types="http://openconfig.net/yang/network-instance-types">oc-ni-types:INSTANCE_LABEL</label-allocation-mode>
</config>
</encapsulation>
{% endif %}
{% if type=='L2VSI' %}
{% if description is defined %}<description>{{description}}</description>{% endif %}
<enabled>true</enabled>
<mtu>1500</mtu>
</config>
<encapsulation>
<config>
<encapsulation-type xmlns:oc-ni-types="http://openconfig.net/yang/network-instance-types">oc-ni-types:MPLS</encapsulation-type>
</config>
</encapsulation>
<fdb>
<config>
<mac-learning>true</mac-learning>
<maximum-entries>1000</maximum-entries>
<mac-aging-time>300</mac-aging-time>
</config>
</fdb>
{% endif %}
{% endif %}
</network-instance>
</network-instances>
......@@ -2,15 +2,13 @@
<network-instance>
<name>{{name}}</name>
<interfaces>
<interface{% if operation is defined %} xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="{{operation}}"{% endif %}>
<interface>
<id>{{id}}</id>
{% if operation is not defined or operation != 'delete' %}
<config>
<id>{{id}}</id>
<interface>{{interface}}</interface>
<subinterface>{{subinterface}}</subinterface>
</config>
{% endif %}
</interface>
</interfaces>
</network-instance>
......
......@@ -3,19 +3,19 @@
<name>{{name}}</name>
<protocols>
<protocol{% if operation is defined %} xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="{{operation}}"{% endif %}>
<identifier>{{identifier}}</identifier>
<identifier xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:{{identifier}}</identifier>
<name>{{protocol_name}}</name>
{% if operation is not defined or operation != 'delete' %}
<config>
<identifier>{{identifier}}</identifier>
<identifier xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:{{identifier}}</identifier>
<name>{{protocol_name}}</name>
<enabled>true</enabled>
</config>
{% if identifier=='BGP' %}
<bgp>
<global>
<config>
<as>{{as}}</as>
<router-id>{{router_id}}</router-id>
</config>
</global>
</bgp>
......@@ -23,5 +23,18 @@
{% endif %}
</protocol>
</protocols>
{% if operation is not defined or operation != 'delete' %}
<tables>
<table>
<protocol xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:{{identifier}}</protocol>
<address-family xmlns:oc-types="http://openconfig.net/yang/openconfig-types">oc-types:IPV4</address-family>
<config>
<protocol xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:{{identifier}}</protocol>
<address-family xmlns:oc-types="http://openconfig.net/yang/openconfig-types">oc-types:IPV4</address-family>
</config>
</table>
</tables>
{% endif %}
</network-instance>
</network-instances>
......@@ -5,7 +5,10 @@
<ext-community-set{% if operation is defined %} xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="{{operation}}"{% endif %}>
<ext-community-set-name>{{ext_community_set_name}}</ext-community-set-name>
{% if operation is not defined or operation != 'delete' %}
{% if ext_community_member is defined %} <ext-community-member>{{ext_community_member}}</ext-community-member>{% endif %}
<config>
<ext-community-set-name>{{ext_community_set_name}}</ext-community-set-name>
<ext-community-member>{{ext_community_member}}</ext-community-member>
</config>
{% endif %}
</ext-community-set>
</ext-community-sets>
......
{% if operation is not defined or operation != 'delete' %}
<routing-policy xmlns="http://openconfig.net/yang/routing-policy">
<policy-definitions>
<policy-definition>
<policy-definition {% if operation is defined %} xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="{{operation}}"{% endif %}>
<name>{{policy_name}}</name>
{% if operation is not defined or operation != 'delete' %}
<config>
<name>{{policy_name}}</name>
</config>
<statements>
<statement>
<name>{{statement_name}}</name>
......@@ -10,11 +13,13 @@
<name>{{statement_name}}</name>
</config>
<conditions>
<config>
<install-protocol-eq xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:DIRECTLY_CONNECTED</install-protocol-eq>
</config>
<bgp-conditions xmlns="http://openconfig.net/yang/bgp-policy">
<match-ext-community-set>
<config>
<ext-community-set>{{ext_community_set_name}}</ext-community-set>
<match-set-options>{{match_set_options}}</match-set-options>
</match-ext-community-set>
</config>
</bgp-conditions>
</conditions>
<actions>
......@@ -24,7 +29,7 @@
</actions>
</statement>
</statements>
{% endif %}
</policy-definition>
</policy-definitions>
</routing-policy>
{% endif %}
......@@ -32,9 +32,11 @@ DEVICE_OC_CONNECT_RULES = json_device_connect_rules(DEVICE_OC_ADDRESS, DEVICE_OC
'hostkey_verify' : True,
'look_for_keys' : True,
'allow_agent' : True,
'delete_rule' : False,
'device_params' : {'name': 'default'},
'manager_params' : {'timeout' : DEVICE_OC_TIMEOUT},
})
DEVICE_OC_CONFIG_RULES = [] # populate your configuration rules to test
DEVICE_OC_DECONFIG_RULES = [] # populate your deconfiguration rules to test
......@@ -29,8 +29,12 @@ from .PrepareTestScenario import ( # pylint: disable=unused-import
mock_service, device_service, context_client, device_client, monitoring_client, test_prepare_environment)
try:
from .Device_OpenConfig_Infinera1 import(
#from .Device_OpenConfig_Infinera1 import(
#from .Device_OpenConfig_Infinera2 import(
#from .Device_OpenConfig_Adva import(
#from .Device_OpenConfig_Adva_149 import(
from .Device_OpenConfig_Adva_155 import(
#from .Device_OpenConfig_Cisco import(
DEVICE_OC, DEVICE_OC_CONFIG_RULES, DEVICE_OC_DECONFIG_RULES, DEVICE_OC_CONNECT_RULES, DEVICE_OC_ID,
DEVICE_OC_UUID)
ENABLE_OPENCONFIG = True
......@@ -38,10 +42,9 @@ except ImportError:
ENABLE_OPENCONFIG = False
ENABLE_OPENCONFIG_CONFIGURE = True
ENABLE_OPENCONFIG_MONITOR = True
ENABLE_OPENCONFIG_MONITOR = False
ENABLE_OPENCONFIG_DECONFIGURE = True
logging.getLogger('apscheduler.executors.default').setLevel(logging.WARNING)
logging.getLogger('apscheduler.scheduler').setLevel(logging.WARNING)
logging.getLogger('monitoring-client').setLevel(logging.WARNING)
......
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