-
Notifications
You must be signed in to change notification settings - Fork 368
[Nexthop] fboss2 CLI config prototype #668
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
Changes from all commits
d5ed186
20e1ec3
1b3749f
f54da96
afc8c81
9a4f972
9267a64
79865dc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /* | ||
| * Copyright (c) 2004-present, Facebook, Inc. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the BSD-style license found in the | ||
| * LICENSE file in the root directory of this source tree. An additional grant | ||
| * of patent rights can be found in the PATENTS file in the same directory. | ||
| * | ||
| */ | ||
|
|
||
| #include "fboss/cli/fboss2/CmdHandler.cpp" | ||
|
|
||
| #include "fboss/cli/fboss2/commands/config/CmdConfigAppliedInfo.h" | ||
| #include "fboss/cli/fboss2/commands/config/CmdConfigReload.h" | ||
| #include "fboss/cli/fboss2/commands/config/history/CmdConfigHistory.h" | ||
| #include "fboss/cli/fboss2/commands/config/interface/CmdConfigInterface.h" | ||
| #include "fboss/cli/fboss2/commands/config/interface/CmdConfigInterfaceDescription.h" | ||
| #include "fboss/cli/fboss2/commands/config/interface/CmdConfigInterfaceMtu.h" | ||
| #include "fboss/cli/fboss2/commands/config/rollback/CmdConfigRollback.h" | ||
| #include "fboss/cli/fboss2/commands/config/session/CmdConfigSessionCommit.h" | ||
| #include "fboss/cli/fboss2/commands/config/session/CmdConfigSessionDiff.h" | ||
|
|
||
| namespace facebook::fboss { | ||
|
|
||
| template void | ||
| CmdHandler<CmdConfigAppliedInfo, CmdConfigAppliedInfoTraits>::run(); | ||
| template void CmdHandler<CmdConfigReload, CmdConfigReloadTraits>::run(); | ||
| template void CmdHandler<CmdConfigInterface, CmdConfigInterfaceTraits>::run(); | ||
| template void CmdHandler< | ||
| CmdConfigInterfaceDescription, | ||
| CmdConfigInterfaceDescriptionTraits>::run(); | ||
| template void | ||
| CmdHandler<CmdConfigInterfaceMtu, CmdConfigInterfaceMtuTraits>::run(); | ||
| template void CmdHandler<CmdConfigHistory, CmdConfigHistoryTraits>::run(); | ||
| template void CmdHandler<CmdConfigRollback, CmdConfigRollbackTraits>::run(); | ||
| template void | ||
| CmdHandler<CmdConfigSessionCommit, CmdConfigSessionCommitTraits>::run(); | ||
| template void | ||
| CmdHandler<CmdConfigSessionDiff, CmdConfigSessionDiffTraits>::run(); | ||
|
|
||
| } // namespace facebook::fboss |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| /* | ||
| * Copyright (c) 2004-present, Facebook, Inc. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the BSD-style license found in the | ||
| * LICENSE file in the root directory of this source tree. An additional grant | ||
| * of patent rights can be found in the PATENTS file in the same directory. | ||
| * | ||
| */ | ||
|
|
||
| #include "fboss/cli/fboss2/CmdList.h" | ||
|
|
||
| #include "fboss/cli/fboss2/CmdHandler.h" | ||
| #include "fboss/cli/fboss2/commands/config/CmdConfigAppliedInfo.h" | ||
| #include "fboss/cli/fboss2/commands/config/CmdConfigReload.h" | ||
| #include "fboss/cli/fboss2/commands/config/history/CmdConfigHistory.h" | ||
| #include "fboss/cli/fboss2/commands/config/interface/CmdConfigInterface.h" | ||
| #include "fboss/cli/fboss2/commands/config/interface/CmdConfigInterfaceDescription.h" | ||
| #include "fboss/cli/fboss2/commands/config/interface/CmdConfigInterfaceMtu.h" | ||
| #include "fboss/cli/fboss2/commands/config/rollback/CmdConfigRollback.h" | ||
| #include "fboss/cli/fboss2/commands/config/session/CmdConfigSessionCommit.h" | ||
| #include "fboss/cli/fboss2/commands/config/session/CmdConfigSessionDiff.h" | ||
|
|
||
| namespace facebook::fboss { | ||
|
|
||
| const CommandTree& kConfigCommandTree() { | ||
|
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. I can see this function will become massive once we keep adding more and more sub-commands.
Contributor
Author
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. I would suggest refactoring this in a separate change. We already have another change internally that is going to avoid mixing everything together like that. |
||
| static CommandTree root = { | ||
| {"config", | ||
| "applied-info", | ||
| "Show config applied information", | ||
| commandHandler<CmdConfigAppliedInfo>, | ||
| argTypeHandler<CmdConfigAppliedInfoTraits>}, | ||
|
|
||
| {"config", | ||
| "history", | ||
| "Show history of committed config revisions", | ||
| commandHandler<CmdConfigHistory>, | ||
| argTypeHandler<CmdConfigHistoryTraits>}, | ||
|
|
||
| { | ||
| "config", | ||
| "interface", | ||
| "Configure interface settings", | ||
| commandHandler<CmdConfigInterface>, | ||
| argTypeHandler<CmdConfigInterfaceTraits>, | ||
| {{ | ||
| "description", | ||
| "Set interface description", | ||
| commandHandler<CmdConfigInterfaceDescription>, | ||
| argTypeHandler<CmdConfigInterfaceDescriptionTraits>, | ||
| }, | ||
| { | ||
| "mtu", | ||
| "Set interface MTU", | ||
| commandHandler<CmdConfigInterfaceMtu>, | ||
| argTypeHandler<CmdConfigInterfaceMtuTraits>, | ||
| }}, | ||
| }, | ||
|
|
||
| { | ||
| "config", | ||
| "session", | ||
| "Manage config session", | ||
| {{ | ||
| "commit", | ||
| "Commit the current config session", | ||
| commandHandler<CmdConfigSessionCommit>, | ||
| argTypeHandler<CmdConfigSessionCommitTraits>, | ||
| }, | ||
| { | ||
| "diff", | ||
| "Show diff between configs (session vs live, session vs revision, or revision vs revision)", | ||
| commandHandler<CmdConfigSessionDiff>, | ||
| argTypeHandler<CmdConfigSessionDiffTraits>, | ||
| }}, | ||
| }, | ||
|
|
||
| {"config", | ||
| "reload", | ||
| "Reload agent configuration", | ||
| commandHandler<CmdConfigReload>, | ||
| argTypeHandler<CmdConfigReloadTraits>}, | ||
|
|
||
| {"config", | ||
| "rollback", | ||
| "Rollback to a previous config revision", | ||
| commandHandler<CmdConfigRollback>, | ||
| argTypeHandler<CmdConfigRollbackTraits>}, | ||
| }; | ||
| sort(root.begin(), root.end()); | ||
| return root; | ||
| } | ||
|
|
||
| } // namespace facebook::fboss | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,8 @@ const std::map<std::string, std::string>& kSupportedVerbs() { | |
| {"stop", "Stop event"}, | ||
| {"get", "Get object"}, | ||
| {"reload", "Reload object"}, | ||
| // Only implemented in fboss2-dev for now. | ||
| {"config", "Configuration commands"}, | ||
| }; | ||
|
|
||
| return supportedVerbs; | ||
|
|
@@ -217,6 +219,16 @@ CLI::App* CmdSubcommands::addCommand( | |
| case utils::ObjectArgTypeId::OBJECT_ARG_TYPE_FAN_PWM: | ||
| subCmd->add_option("pwm", args, "Fan PWM (0..100) or 'disable'"); | ||
| break; | ||
| case utils::ObjectArgTypeId::OBJECT_ARG_TYPE_MTU: | ||
|
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. Same comment about how to better manage the sub-commands and arg types of the new config.
Contributor
Author
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. I would suggest refactoring this in a separate change. We already have another change that is going to avoid mixing everything together like that. |
||
| subCmd->add_option("mtu", args, "MTU value (68-9216)"); | ||
| break; | ||
| case utils::ObjectArgTypeId::OBJECT_ARG_TYPE_ID_INTERFACE_LIST: | ||
| subCmd->add_option("interfaces", args, "Interface(s)"); | ||
| break; | ||
| case utils::ObjectArgTypeId::OBJECT_ARG_TYPE_ID_REVISION_LIST: | ||
| subCmd->add_option( | ||
| "revisions", args, "Revision(s) in the form 'rN' or 'current'"); | ||
| break; | ||
| case utils::ObjectArgTypeId::OBJECT_ARG_TYPE_ID_UNINITIALIZE: | ||
| case utils::ObjectArgTypeId::OBJECT_ARG_TYPE_ID_NONE: | ||
| break; | ||
|
|
||
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.
We usually don't recommend vendors to touch the BUCK file as they won't be able to verify the changes using buck command.
That's why once we finish landing the PRs, we will adjust the buck file in another diff or the same diff if our on-diff signal complains
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.
I think this is going to save you time 😁