-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Add Cisco IOS-XR Provider and implement interface stubs #85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sven-rosenzweig
wants to merge
6
commits into
main
Choose a base branch
from
feat/iosxrv2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1651a79
fix: Support unencrypted GRPC connections
sven-rosenzweig 4c89d0a
feat: Introduce Client as an interface
sven-rosenzweig b5e8d43
feat: Add Cisco IOS-XR Provider and implement interface stubs
sven-rosenzweig 06a011e
fixup! fix: Support unencrypted GRPC connections
sven-rosenzweig b9b0581
fixup! feat: Introduce Client as an interface
sven-rosenzweig 3969b89
fixup! feat: Add Cisco IOS-XR Provider and implement interface stubs
sven-rosenzweig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| // SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and IronCore contributors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package iosxr | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "regexp" | ||
|
|
||
| "github.com/ironcore-dev/network-operator/internal/provider/cisco/gnmiext/v2" | ||
| ) | ||
|
|
||
| type PhysIf struct { | ||
| Name string `json:"-"` | ||
| Description string `json:"description"` | ||
| Active string `json:"active"` | ||
| Vrf string `json:"Cisco-IOS-XR-infra-rsi-cfg:vrf,omitempty"` | ||
| Statistics Statistics `json:"Cisco-IOS-XR-infra-statsd-cfg:statistics,omitempty"` | ||
| IPv4Network IPv4Network `json:"Cisco-IOS-XR-ipv4-io-cfg:ipv4-network,omitempty"` | ||
| IPv6Network IPv6Network `json:"Cisco-IOS-XR-ipv6-ma-cfg:ipv6-network,omitempty"` | ||
| IPv6Neighbor IPv6Neighbor `json:"Cisco-IOS-XR-ipv6-nd-cfg:ipv6-neighbor,omitempty"` | ||
| MTUs MTUs `json:"mtus,omitempty"` | ||
| Shutdown gnmiext.Empty `json:"shutdown,omitempty"` | ||
| } | ||
|
|
||
| type Statistics struct { | ||
| LoadInterval uint8 `json:"load-interval"` | ||
| } | ||
|
|
||
| type IPv4Network struct { | ||
| Addresses AddressesIPv4 `json:"addresses"` | ||
| Mtu uint16 `json:"mtu"` | ||
| } | ||
|
|
||
| type AddressesIPv4 struct { | ||
| Primary Primary `json:"primary"` | ||
| } | ||
|
|
||
| type Primary struct { | ||
| Address string `json:"address"` | ||
| Netmask string `json:"netmask"` | ||
| } | ||
|
|
||
| type IPv6Network struct { | ||
| Mtu uint16 `json:"mtu"` | ||
| Addresses AddressesIPv6 `json:"addresses"` | ||
| } | ||
|
|
||
| type AddressesIPv6 struct { | ||
| RegularAddresses RegularAddresses `json:"regular-addresses"` | ||
| } | ||
|
|
||
| type RegularAddresses struct { | ||
| RegularAddress []RegularAddress `json:"regular-address"` | ||
| } | ||
|
|
||
| type RegularAddress struct { | ||
| Address string `json:"address"` | ||
| PrefixLength uint8 `json:"prefix-length"` | ||
| Zone string `json:"zone"` | ||
| } | ||
|
|
||
| type IPv6Neighbor struct { | ||
| RASuppress bool `json:"ra-suppress"` | ||
| } | ||
|
|
||
| type MTUs struct { | ||
| MTU []MTU `json:"mtu"` | ||
| } | ||
|
|
||
| type MTU struct { | ||
| MTU int32 `json:"mtu"` | ||
| Owner string `json:"owner"` | ||
| } | ||
|
|
||
| func (i *PhysIf) XPath() string { | ||
| return fmt.Sprintf("Cisco-IOS-XR-ifmgr-cfg:interface-configurations/interface-configuration[active=act][interface-name=%s]", i.Name) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note for later: Is this always set to |
||
| } | ||
|
|
||
| func (i *PhysIf) String() string { | ||
| return fmt.Sprintf("Name: %s, Description=%s, ShutDown=%t", i.Name, i.Description, i.Shutdown) | ||
| } | ||
|
|
||
| type IFaceSpeed string | ||
|
|
||
| const ( | ||
| Speed10G IFaceSpeed = "TenGigE" | ||
| Speed25G IFaceSpeed = "TwentyFiveGigE" | ||
| Speed40G IFaceSpeed = "FortyGigE" | ||
| Speed100G IFaceSpeed = "HundredGigE" | ||
| ) | ||
|
|
||
| func ExractMTUOwnerFromIfaceName(ifaceName string) (IFaceSpeed, error) { | ||
| // Match the port_type in an interface name <port_type>/<rack>/<slot/<module>/<port> | ||
| // E.g. match TwentyFiveGigE of interface with name TwentyFiveGigE0/0/0/1 | ||
| re := regexp.MustCompile(`^\D*`) | ||
|
|
||
| mtuOwner := string(re.Find([]byte(ifaceName))) | ||
|
Comment on lines
+96
to
+98
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we use a |
||
|
|
||
| if mtuOwner == "" { | ||
| return "", fmt.Errorf("failed to extract MTU owner from interface name %s", ifaceName) | ||
| } | ||
|
|
||
| switch mtuOwner { | ||
| case string(Speed10G): | ||
| return Speed10G, nil | ||
| case string(Speed25G): | ||
| return Speed25G, nil | ||
| case string(Speed40G): | ||
| return Speed25G, nil | ||
| case string(Speed100G): | ||
| return Speed100G, nil | ||
| default: | ||
| return "", fmt.Errorf("unsupported interface type %s for MTU owner extraction", mtuOwner) | ||
| } | ||
| } | ||
|
|
||
| type PhysIfStateType string | ||
|
|
||
| const ( | ||
| StateUp PhysIfStateType = "im-state-up" | ||
| StateDown PhysIfStateType = "im-state-down" | ||
| StateNotReady PhysIfStateType = "im-state-not-ready" | ||
| StateAdminDown PhysIfStateType = "im-state-admin-down" | ||
| StateShutDown PhysIfStateType = "im-state-shutdown" | ||
| ) | ||
|
|
||
| type PhysIfState struct { | ||
| State string `json:"state"` | ||
| Name string `json:"-"` | ||
| } | ||
|
|
||
| func (phys *PhysIfState) XPath() string { | ||
| // (fixme): hardcoded route processor for the moment | ||
| return fmt.Sprintf("Cisco-IOS-XR-ifmgr-oper:interface-properties/data-nodes/data-node[data-node-name=0/RP0/CPU0]/system-view/interfaces/interface[interface-name=%s]", phys.Name) | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we could just always use
falsehere as this is only called with theinsecuretransport credentials.