diff --git a/fboss/cli/fboss2/commands/show/fabric/CmdShowFabric.h b/fboss/cli/fboss2/commands/show/fabric/CmdShowFabric.h index 94b876e20c777..6a92c707d0b47 100644 --- a/fboss/cli/fboss2/commands/show/fabric/CmdShowFabric.h +++ b/fboss/cli/fboss2/commands/show/fabric/CmdShowFabric.h @@ -39,22 +39,7 @@ class CmdShowFabric : public CmdHandler { using RetType = CmdShowFabricTraits::RetType; RetType queryClient(const HostInfo& hostInfo) { - std::map entries; - if (utils::isFbossFeatureEnabled(hostInfo.getName(), "multi_switch")) { - auto hwAgentQueryFn = - [&entries]( - apache::thrift::Client& client) { - std::map hwagentEntries; - client.sync_getHwFabricConnectivity(hwagentEntries); - entries.merge(hwagentEntries); - }; - utils::runOnAllHwAgents(hostInfo, hwAgentQueryFn); - } else { - auto client = - utils::createClient>(hostInfo); - client->sync_getFabricConnectivity(entries); - } - return createModel(entries); + return createModel(utils::getFabricEndpoints(hostInfo)); } inline void udpateNametoIdString(std::string& name, int64_t value) { diff --git a/fboss/cli/fboss2/utils/CmdUtils.cpp b/fboss/cli/fboss2/utils/CmdUtils.cpp index c74f1e490a231..f68912d3e68d9 100644 --- a/fboss/cli/fboss2/utils/CmdUtils.cpp +++ b/fboss/cli/fboss2/utils/CmdUtils.cpp @@ -376,4 +376,23 @@ cfg::SwitchType getSwitchType( return switchType; } +std::map getFabricEndpoints( + const HostInfo& hostInfo) { + std::map entries; + if (utils::isFbossFeatureEnabled(hostInfo.getName(), "multi_switch")) { + auto hwAgentQueryFn = + [&entries]( + apache::thrift::Client& client) { + std::map hwagentEntries; + client.sync_getHwFabricConnectivity(hwagentEntries); + entries.merge(hwagentEntries); + }; + utils::runOnAllHwAgents(hostInfo, hwAgentQueryFn); + } else { + utils::createClient>(hostInfo) + ->sync_getFabricConnectivity(entries); + } + return entries; +} + } // namespace facebook::fboss::utils diff --git a/fboss/cli/fboss2/utils/CmdUtils.h b/fboss/cli/fboss2/utils/CmdUtils.h index 25366caad3d62..69f6198af4a35 100644 --- a/fboss/cli/fboss2/utils/CmdUtils.h +++ b/fboss/cli/fboss2/utils/CmdUtils.h @@ -472,4 +472,7 @@ Table::StyledCell styledFecTail(int tail); cfg::SwitchType getSwitchType( std::map switchIdToSwitchInfo); +std::map getFabricEndpoints( + const HostInfo& hostInfo); + } // namespace facebook::fboss::utils