-
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
base: main
Are you sure you want to change the base?
Conversation
120c4a7 to
ff39cee
Compare
|
Waiting for #30 to be merged. |
ff39cee to
b1a8ff0
Compare
32662d3 to
35d7a78
Compare
Some network devices do not have TLS configured on their side, requiring the use of insecure credentials. To support these cases, this change disables transport security enforcement when insecure credentials are used. Note: This option is intended for development and testing purposes only.
Refactor the Provider to depend on a Client interface instead of a concrete implementation. This simplifies testing and mocking by allowing the Client itself to be mocked, rather than individual gRPC calls.
f3ee185 to
0895369
Compare
0895369 to
9c61755
Compare
Merging this branch changes the coverage (1 decrease, 1 increase)
Coverage by fileChanged files (no unit tests)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. Changed unit test files
|
| } | ||
|
|
||
| func (a *auth) RequireTransportSecurity() bool { return true } | ||
| func (a *auth) RequireTransportSecurity() bool { |
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 false here as this is only called with the insecure transport credentials.
| // Client is a gNMI client offering convenience methods for device configuration | ||
| // using gNMI. | ||
| type Client struct { | ||
| type ClientObj struct { |
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.
| // Client is a gNMI client offering convenience methods for device configuration | |
| // using gNMI. | |
| type Client struct { | |
| type ClientObj struct { | |
| type client struct { |
Would move the comment to the Client interface definition and make the client implementation lowercase (unexported).
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: seems like this file is inconsistency indented. Maybe re-indent.
| ) | ||
|
|
||
| // YANG has an empty type that is represented as a JSON array with a single null value. Whenever the key is present in YANG, it should evaluate to true. | ||
| type Empty bool |
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.
This type is already contained in the gnmiext package and can be used from there.
| return nil, nil | ||
| } | ||
|
|
||
| type PhisIf struct { |
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.
| type PhisIf struct { | |
| type PhysIf struct { |
| // (fixme): for the moment it is enought to keep this static | ||
| // option1: extend existing interface spec | ||
| // option2: create a custom iosxr config | ||
| physif.Shutdown = Empty(false) |
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.
| physif.Shutdown = Empty(false) | |
| physif.Shutdown = Empty(false) | |
| if req.Interface.Spec.AdminState == v1alpha1.InterfaceAdminStateDown { | |
| physif.Shutdown = Empty(true) | |
| } |
| return p.conn.Close() | ||
| } | ||
|
|
||
| func (p *Provider) EnsureInterface(ctx context.Context, req *provider.InterfaceRequest) error { |
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.
Currently only Physical Interfaces are supported. Maybe we should return an error of the Type doesn't match.
| if err != nil { | ||
| return fmt.Errorf("failed to create interface %s: %w", req.Interface.Spec.Name, err) | ||
| } | ||
| fmt.Printf("Interface %s created successfully\n", req.Interface.Spec.Name) |
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.
| fmt.Printf("Interface %s created successfully\n", req.Interface.Spec.Name) |
| return nil | ||
| } | ||
|
|
||
| err = p.client.Patch(ctx, physif) |
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.
| err = p.client.Patch(ctx, physif) | |
| return p.client.Update(ctx, physif) |
I think I would just always use a Update, then you also don't need the check above.
| providerStatus := provider.InterfaceStatus{ | ||
| OperStatus: true, | ||
| } | ||
|
|
||
| if stateMapping[state.State] != StateUp { | ||
| providerStatus.OperStatus = false | ||
| } | ||
|
|
||
| return providerStatus, nil |
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.
| providerStatus := provider.InterfaceStatus{ | |
| OperStatus: true, | |
| } | |
| if stateMapping[state.State] != StateUp { | |
| providerStatus.OperStatus = false | |
| } | |
| return providerStatus, nil | |
| return provider.InterfaceStatus{ | |
| OperStatus: state.State == StateUp, | |
| }, nil |
No description provided.