Commit afc009ba authored by Shayan Hajipour's avatar Shayan Hajipour
Browse files

feat: e2e acl installation added: 1.post, get, delete endpoints of acl added...

feat: e2e acl installation added: 1.post, get, delete endpoints of acl added to nbi 2.ipinfusion netconf proprietary acl recipe added since openconfig recipe does not create acl entries in the router
parent e1958317
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ message AclMatch {
  uint32 dst_port         = 6;
  uint32 start_mpls_label = 7;
  uint32 end_mpls_label   = 8;
  string flags            = 9;
}

message AclAction {
+1 −0
Original line number Diff line number Diff line
@@ -498,6 +498,7 @@ message ConfigRule_Custom {
message ConfigRule_ACL {
  EndPointId endpoint_id = 1;
  acl.AclRuleSet rule_set = 2;
  string interface = 3;
}

message ConfigRule {
+21 −8
Original line number Diff line number Diff line
@@ -27,6 +27,9 @@ from .NetworkInstances import parse as parse_network_instances
from .RoutingPolicy import parse as parse_routing_policy
from .Acl import parse as parse_acl
from .Inventory import parse as parse_inventory
from .acl.acl_adapter import acl_cr_to_dict
from .acl.acl_adapter_ipinfusion_proprietary import acl_cr_to_dict_ipinfusion_proprietary

LOGGER = logging.getLogger(__name__)

ALL_RESOURCE_KEYS = [
@@ -113,16 +116,26 @@ def compose_config( # template generation

    elif (message_renderer == "jinja"):
        templates =[]
        if "acl_ruleset" in resource_key:                                               # MANAGING ACLs
            if True: #vendor == 'ipinfusion': #! ipinfusion proprietary netconf receipe is used temporarily
                acl_entry_path = 'acl/acl-set/acl-entry/edit_config_ipinfusion_proprietary.xml'
                acl_ingress_path = 'acl/interfaces/ingress/edit_config_ipinfusion_proprietary.xml'
                data : Dict[str, Any] = acl_cr_to_dict_ipinfusion_proprietary(resource_value, delete=delete)
            else:
                acl_entry_path = 'acl/acl-set/acl-entry/edit_config.xml'
                acl_ingress_path = 'acl/interfaces/ingress/edit_config.xml'
                data : Dict[str, Any] = acl_cr_to_dict(resource_value, delete=delete)
            if delete: # unpair acl and interface before removing acl
                templates.append(JINJA_ENV.get_template(acl_ingress_path))
                templates.append(JINJA_ENV.get_template(acl_entry_path))
            else:
                templates.append(JINJA_ENV.get_template(acl_entry_path))
                templates.append(JINJA_ENV.get_template(acl_ingress_path))
        else:
            template_name = '{:s}/edit_config.xml'.format(RE_REMOVE_FILTERS.sub('', resource_key))
            templates.append(JINJA_ENV.get_template(template_name))

        if "acl_ruleset" in resource_key:                                               # MANAGING ACLs
            templates =[]
            templates.append(JINJA_ENV.get_template('acl/acl-set/acl-entry/edit_config.xml'))
            templates.append(JINJA_ENV.get_template('acl/interfaces/ingress/edit_config.xml'))
            data : Dict[str, Any] = json.loads(resource_value)
        operation = 'delete' if delete else 'merge'

        return [
            '<config>{:s}</config>'.format(
            template.render(**data, operation=operation, vendor=vendor).strip())
+13 −0
Original line number Diff line number Diff line
# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
 No newline at end of file
+34 −0
Original line number Diff line number Diff line
<acl xmlns="http://www.ipinfusion.com/yang/ocnos/ipi-acl">
  <acl-sets>
    <acl-set {% if operation == 'delete' %}operation="delete"{% endif %}>
      <name>{{name}}</name>
      {% if type is defined %}<type>{{type}}</type>{% endif %}
      <config>
        <name>{{name}}</name>
        {% if type is defined %}<type>{{type}}</type>{% endif %}
      </config>
      {% if operation != 'delete' %}
      <acl-entries>
        <acl-entry>
          <sequence-id>{{sequence_id}}</sequence-id>
          <config>
            <sequence-id>{{sequence_id}}</sequence-id>
          </config>
          <ipv4>
            <config>
              <source-address>{{source_address}}</source-address>
              <destination-address>{{destination_address}}</destination-address>
              <dscp>{{dscp}}</dscp>
              <protocol-tcp />
              <tcp-source-port>{{source_port}}</tcp-source-port>
              <tcp-destination-port>{{destination_port}}</tcp-destination-port>
              <tcp-flags>{{tcp_flags}}</tcp-flags>
              <forwarding-action>{{forwarding_action}}</forwarding-action>
            </config>
          </ipv4>
        </acl-entry>
      </acl-entries>
      {% endif %}
    </acl-set>
  </acl-sets>
</acl>
 No newline at end of file
Loading