Skip to content
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

6750 Add support for post-install LLDP configuration #7132

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Conversation

Nieuwejaar
Copy link
Contributor

6751 Add support for extracting LLDP neighbor information

6751 Add support for extracting LLDP neighbor information
Copy link
Contributor

@internet-diglett internet-diglett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good just a small comment

Comment on lines 104 to 112
PortId::MacAddress(mac) => format!(
"{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
mac.a[0],
mac.a[1],
mac.a[2],
mac.a[3],
mac.a[4],
mac.a[5]
),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we implement a to_string() method for the mac address type to reduce repetition?

Copy link
Contributor

@ahl ahl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed the whole thing, but the only part where my review might be considered useful was regarding the API where I would suggest a change from returning a vec -> a paginated response.

rqctx: RequestContext<Self::Context>,
path_params: Path<params::SwitchPortPathSelector>,
query_params: Query<params::SwitchPortSelector>,
) -> Result<HttpResponseOk<Vec<LldpNeighbor>>, HttpError> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When returning a collection, we try to use a paginated response.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -0,0 +1,178 @@
use super::DataStore;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copyright and license headers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a license header. I didn't look at every other file in that directory, but none of the ones I did look at had a copyright line. Should they all be updated?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably; but out of scope here I suppose!

//
// For consistency across the lldp operations, all use rack/switch/port rather
// than the uuid.
// XXX: Is this the right call? The other options being: uuid for all
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it? Should we decide before merging this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is, which is why I implemented it this way. The comment was meant to solicit feedback from the reviewers with more API experience - i.e, you. I probably should have made that a github/review comment rather than a rust comment to make that clearer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying. I think it's fine to use rack_id / switch-port rather than the uuid. I do think it's a little odd that the port is often a path param and the rack is a query param. Was there some particular motivation for that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure. Having rack/switch/port in the path seems more natural to me, but this was the pattern Ry used in the original stake-in-the-ground API. I don't know if he had something specific in mind, or if it was the result of a quick decision that was never revisited.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest using both the rack id and port in the path, and there seems to be at least some precedent for that.

use omicron_common::api::external::UpdateResult;
use uuid::Uuid;

// The LLDP configuration has been defined as a leaf of the switch-port-settings
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this whole thing be //!? It seems like kind of a doc comment, but I'm unsure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant it to be useful to somebody reading the code, rather than somebody using the API.

@@ -0,0 +1,132 @@
use crate::app::authz;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copyright / license

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done - again license only.

@@ -196,6 +196,9 @@ networking_bgp_status GET /v1/system/networking/bgp-stat
networking_loopback_address_create POST /v1/system/networking/loopback-address
networking_loopback_address_delete DELETE /v1/system/networking/loopback-address/{rack_id}/{switch_location}/{address}/{subnet_mask}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it does seem like including the rack-id in the path might make more sense based on this precedent. I'm not sure what @internet-diglett has in mind to wrangle the API, but I infer that's still in the works.

Copy link
Contributor

@ahl ahl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. I do think we should make the rack_id part of the path, but ... I leave it to you to figure out the right way to get to a consistent model here.

//
// For consistency across the lldp operations, all use rack/switch/port rather
// than the uuid.
// XXX: Is this the right call? The other options being: uuid for all
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest using both the rack id and port in the path, and there seems to be at least some precedent for that.

"description": "successful operation",
"content": {
"application/json": {
"schema": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants