-
Notifications
You must be signed in to change notification settings - Fork 399
Expand file tree
/
Copy pathCmdConfigInterface.h
More file actions
61 lines (52 loc) · 1.85 KB
/
Copy pathCmdConfigInterface.h
File metadata and controls
61 lines (52 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* 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.
*
*/
#pragma once
#include <string>
#include <vector>
#include "fboss/cli/fboss2/CmdHandler.h"
#include "fboss/cli/fboss2/commands/config/interface/InterfaceAttrArgsBase.h"
namespace facebook::fboss {
/*
* InterfacesConfig captures both port/interface names and optional
* attribute key-value pairs from the CLI.
*
* Usage: config interface <port-list> [<attr> [<value>] ...]
*
* The first tokens (until a known attribute name is encountered) are
* treated as port/interface names. The remaining tokens are parsed
* as attribute-value pairs (see InterfaceAttrArgsBase).
*/
class InterfacesConfig : public InterfaceAttrArgsBase {
public:
// NOLINTNEXTLINE(google-explicit-constructor)
/* implicit */ InterfacesConfig(const std::vector<std::string>& v);
};
struct CmdConfigInterfaceTraits : public WriteCommandTraits {
static void addCliArg(CLI::App& cmd, std::vector<std::string>& args) {
cmd.add_option(
"interface_config",
args,
"<port-list> [<attr> <value> ...] where <attr> is one "
"of: description, mtu, ip-address, ipv6-address, ...");
}
using ObjectArgType = InterfacesConfig;
using RetType = std::string;
};
class CmdConfigInterface
: public CmdHandler<CmdConfigInterface, CmdConfigInterfaceTraits> {
public:
using ObjectArgType = CmdConfigInterfaceTraits::ObjectArgType;
using RetType = CmdConfigInterfaceTraits::RetType;
RetType queryClient(
const HostInfo& hostInfo,
const ObjectArgType& interfaceConfig);
void printOutput(const RetType& logMsg);
};
} // namespace facebook::fboss