Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/transformer/models_list
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ openconfig-if-ethernet.yang
openconfig-interfaces.yang
openconfig-interfaces-annot.yang
openconfig-if-ip.yang
openconfig-if-aggregate.yang
openconfig-interfaces-annot.yang
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73r
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200301022130-244492dfa37a h1:GuSPYbZzB5/dcLNCwLQLsg3obCJtX9IJhpXkvY7kzk0=
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI=
Expand Down Expand Up @@ -174,5 +175,6 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
inet.af v0.0.0-20181218191229-53da77bc832c h1:U3RoiyEF5b3Y1SVL6NNvpkgqUz2qS3a0OJh9kpSCN04=
inet.af/netaddr v0.0.0-20230525184311-b8eac61e914a h1:1XCVEdxrvL6c0TGOhecLuB7U9zYNdxZEjvOqJreKZiM=
inet.af/netaddr v0.0.0-20230525184311-b8eac61e914a/go.mod h1:e83i32mAQOW1LAqEIweALsuK2Uw4mhQadA5r7b0Wobo=
20 changes: 20 additions & 0 deletions models/yang/annotations/openconfig-interfaces-annot.yang
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ module openconfig-interfaces-annot {
}
}

deviation /oc-intf:interfaces/oc-intf:interface/oc-eth:ethernet/oc-eth:state/oc-lag:aggregate-id {
deviate add {
sonic-ext:field-transformer "intf_eth_aggr_id_xfmr";
}
}

deviation /oc-intf:interfaces/oc-intf:interface/oc-intf:state {
deviate add {
sonic-ext:db-name "APPL_DB";
Expand Down Expand Up @@ -70,6 +76,20 @@ module openconfig-interfaces-annot {
}
}

deviation /oc-intf:interfaces/oc-intf:interface/oc-lag:aggregation/oc-lag:config/oc-lag:min-links {
deviate add {
sonic-ext:field-transformer "lag_min_links_xfmr";
sonic-ext:field-name "min_links";
}
}

deviation /oc-intf:interfaces/oc-intf:interface/oc-lag:aggregation/oc-lag:state {
deviate add {
sonic-ext:subtree-transformer "intf_lag_state_xfmr";
sonic-ext:path-transformer "intf_lag_state_path_xfmr";
}
}

deviation /oc-intf:interfaces/oc-intf:interface/oc-intf:state/oc-intf:enabled {
deviate add {
sonic-ext:field-transformer "intf_enabled_xfmr";
Expand Down
40 changes: 24 additions & 16 deletions models/yang/extensions/openconfig-interfaces-deviation.yang
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,6 @@ module openconfig-interfaces-deviation {
deviate not-supported;
}

deviation /oc-intf:interfaces/oc-intf:interface/oc-eth:ethernet/oc-eth:config/oc-lag:aggregate-id {
deviate not-supported;
}

deviation /oc-intf:interfaces/oc-intf:interface/oc-eth:ethernet/oc-eth:state/oc-eth:mac-address {
deviate not-supported;
}
Expand All @@ -239,10 +235,6 @@ module openconfig-interfaces-deviation {
deviate not-supported;
}

deviation /oc-intf:interfaces/oc-intf:interface/oc-eth:ethernet/oc-eth:state/oc-lag:aggregate-id {
deviate not-supported;
}

deviation /oc-intf:interfaces/oc-intf:interface/oc-eth:ethernet/oc-eth:state/oc-eth:hw-mac-address {
deviate not-supported;
}
Expand All @@ -255,6 +247,30 @@ module openconfig-interfaces-deviation {
deviate not-supported;
}

deviation /oc-intf:interfaces/oc-intf:interface/oc-eth:ethernet/oc-vlan:switched-vlan {
deviate not-supported;
}

deviation /oc-intf:interfaces/oc-intf:interface/oc-lag:aggregation/oc-vlan:switched-vlan {
deviate not-supported;
}

deviation /oc-intf:interfaces/oc-intf:interface/oc-lag:aggregation/oc-lag:config/oc-lag:lag-type {
deviate not-supported;
}

deviation /oc-intf:interfaces/oc-intf:interface/oc-lag:aggregation/oc-lag:state/oc-lag:lag-type {
deviate not-supported;
}

deviation /oc-intf:interfaces/oc-intf:interface/oc-lag:aggregation/oc-lag:state/oc-lag:lag-speed {
deviate not-supported;
}

deviation /oc-intf:interfaces/oc-intf:interface/oc-lag:aggregation/oc-lag:state/oc-lag:member {
deviate not-supported;
}

deviation /oc-intf:interfaces/oc-intf:interface/oc-eth:ethernet/oc-eth:state/oc-eth:counters/oc-eth:in-mac-control-frames {
deviate not-supported;
}
Expand Down Expand Up @@ -287,18 +303,10 @@ module openconfig-interfaces-deviation {
deviate not-supported;
}

deviation /oc-intf:interfaces/oc-intf:interface/oc-eth:ethernet/oc-vlan:switched-vlan {
deviate not-supported;
}

deviation /oc-intf:interfaces/oc-intf:interface/oc-tun:tunnel {
deviate not-supported;
}

deviation /oc-intf:interfaces/oc-intf:interface/oc-lag:aggregation {
deviate not-supported;
}

deviation /oc-intf:interfaces/oc-intf:interface/oc-vlan:routed-vlan {
deviate not-supported;
}
Expand Down
3 changes: 2 additions & 1 deletion models/yang/sonic/import.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
#
SONICYANG_IMPORTS += sonic-sflow.yang
SONICYANG_IMPORTS += sonic-interface.yang
SONICYANG_IMPORTS += sonic-port.yang
SONICYANG_IMPORTS += sonic-port.yang
SONICYANG_IMPORTS += sonic-portchannel.yang
111 changes: 111 additions & 0 deletions translib/transformer/portchannel_openconfig_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
////////////////////////////////////////////////////////////////////////////////
// //
// Copyright 2024 Dell, Inc. //
// //
// 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. //
// //
////////////////////////////////////////////////////////////////////////////////

//go:build testapp
// +build testapp

package transformer_test

import (
"github.com/Azure/sonic-mgmt-common/translib/tlerr"
"testing"
"time"
)

func Test_openconfig_portchannel(t *testing.T) {
var url, url_input_body_json string

t.Log("\n\n+++++++++++++ CONFIGURING PORTCHANNEL ++++++++++++")

t.Log("\n\n--- PUT to Create PortChannel 111 ---")
url = "/openconfig-interfaces:interfaces/interface[name=PortChannel111]"
url_input_body_json = "{\"openconfig-interfaces:interface\": [{\"name\":\"PortChannel111\", \"config\": {\"name\": \"PortChannel111\", \"mtu\": 9100, \"description\": \"put_pc\", \"enabled\": true}}]}"
t.Run("Test Create PortChannel111", processSetRequest(url, url_input_body_json, "PUT", false, nil))
time.Sleep(1 * time.Second)

t.Log("\n\n--- Verify PortChannel Creation ---")
url = "/openconfig-interfaces:interfaces/interface[name=PortChannel111]/config"
expected_get_json := "{\"openconfig-interfaces:config\": {\"description\": \"put_pc\", \"enabled\": true, \"mtu\": 9100, \"name\": \"PortChannel111\"}}"
t.Run("Test GET PortChannel interface creation config ", processGetRequest(url, nil, expected_get_json, false))
time.Sleep(1 * time.Second)

t.Log("\n\n--- Initialize PortChannel Member ---")
t.Log("\n\n--- DELETE interface IP Addr ---")
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/subinterfaces/subinterface[index=0]/openconfig-if-ip:ipv4/addresses"
t.Run("DELETE on interface IP Addr", processDeleteRequest(url, true))
time.Sleep(1 * time.Second)

t.Log("\n\n--- PATCH to Add PortChannel Member ---")
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/openconfig-if-ethernet:ethernet/config/openconfig-if-aggregate:aggregate-id"
url_input_body_json = "{\"openconfig-if-aggregate:aggregate-id\":\"PortChannel111\"}"
t.Run("Test PATCH on Ethernet aggregate-id", processSetRequest(url, url_input_body_json, "PATCH", false, nil))
time.Sleep(1 * time.Second)

t.Log("\n\n--- Verify the added PortChannel Member ---")
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/openconfig-if-ethernet:ethernet/config/openconfig-if-aggregate:aggregate-id"
expected_get_json = "{\"openconfig-if-aggregate:aggregate-id\": \"PortChannel111\"}"
t.Run("Test GET on portchannel agg-id", processGetRequest(url, nil, expected_get_json, false))
time.Sleep(1 * time.Second)

t.Log("\n\n--- PATCH PortChannel min-links ---")
url = "/openconfig-interfaces:interfaces/interface[name=PortChannel111]/openconfig-if-aggregate:aggregation/config/min-links"
url_input_body_json = "{\"openconfig-if-aggregate:min-links\":3}"
t.Run("Test PATCH min-links on portchannel", processSetRequest(url, url_input_body_json, "PATCH", false, nil))
time.Sleep(1 * time.Second)

t.Log("\n\n--- Verify PATCH PortChannel config ---")
url = "/openconfig-interfaces:interfaces/interface[name=PortChannel111]/openconfig-if-aggregate:aggregation/config"
expected_get_json = "{\"openconfig-if-aggregate:config\": {\"min-links\": 3}}"
t.Run("Test GET on portchannel config", processGetRequest(url, nil, expected_get_json, false))
time.Sleep(1 * time.Second)

t.Log("\n\n--- DELETE PortChannel min-links ---")
url = "/openconfig-interfaces:interfaces/interface[name=PortChannel111]/openconfig-if-aggregate:aggregation/config/min-links"
t.Run("Verify DELETE on PortChannel min-links", processDeleteRequest(url, true))
time.Sleep(1 * time.Second)

t.Log("\n\n--- Verify DELETE PortChannel min-links ---")
url = "/openconfig-interfaces:interfaces/interface[name=PortChannel111]/openconfig-if-aggregate:aggregation/config"
expected_get_json = "{\"openconfig-if-aggregate:config\": {\"min-links\": 3}}"
t.Run("Test GET on portchannel min-links after DELETE", processGetRequest(url, nil, expected_get_json, false))
time.Sleep(1 * time.Second)

t.Log("\n\n--- PATCH PortChannel interface Config ---")
url = "/openconfig-interfaces:interfaces/interface[name=PortChannel111]/config"
url_input_body_json = "{\"openconfig-interfaces:config\": { \"mtu\": 8900, \"description\": \"agg_intf_conf\", \"enabled\": false}}"
t.Run("Test PATCH PortChannel interface Config", processSetRequest(url, url_input_body_json, "PATCH", false, nil))
time.Sleep(1 * time.Second)

t.Log("\n\n--- Verify PATCH interfaces config ---")
url = "/openconfig-interfaces:interfaces/interface[name=PortChannel111]/config"
expected_get_json = "{\"openconfig-interfaces:config\": {\"description\": \"agg_intf_conf\", \"enabled\": false, \"mtu\": 8900, \"name\": \"PortChannel111\"}}"
t.Run("Test GET PortChannel interface Config", processGetRequest(url, nil, expected_get_json, false))
time.Sleep(1 * time.Second)

t.Log("\n\n--- DELETE PortChannel interface ---")
url = "/openconfig-interfaces:interfaces/interface[name=PortChannel111]"
t.Run("Test DELETE on PortChannel", processDeleteRequest(url, true))
time.Sleep(1 * time.Second)

t.Log("\n\n--- Verify DELETE at PortChannel Interface ---")
url = "/openconfig-interfaces:interfaces/interface[name=PortChannel111]"
err_str := "Resource not found"
expected_err_invalid := tlerr.NotFoundError{Format: err_str}
t.Run("Test GET on deleted PortChannel", processGetRequest(url, nil, "", true, expected_err_invalid))
time.Sleep(1 * time.Second)
}
Loading