-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
84 lines (73 loc) · 4.31 KB
/
main.go
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
* Copyright 2020, 2021, 2022 Hewlett Packard Enterprise Development LP
* Other additional copyright holders may be indicated within.
*
* The entirety of this work is licensed under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
*
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package main
import (
"github.com/alecthomas/kong"
ctx "github.com/NearNodeFlash/nnf-ec/internal/switchtec/cmd"
cfg "github.com/NearNodeFlash/nnf-ec/internal/switchtec/cmd/config"
cmd "github.com/NearNodeFlash/nnf-ec/internal/switchtec/cmd/fabric"
nvme "github.com/NearNodeFlash/nnf-ec/internal/switchtec/cmd/nvme"
)
var cli struct {
Debug bool `kong:"optional,help='Enable debug'"`
Verbose int `kong:"optional,hidden,type='counter',help='Debug verbosity level.'"`
Echo cmd.EchoCmd `kong:"cmd,help='Send an echo command to the device.'"`
Identify cmd.IdentifyCmd `kong:"cmd,help='Identify the PAX device.'"`
LinkStat cmd.LinkStatCmd `kong:"cmd,help='Report link status for a device.'"`
Bind cmd.BindCmd `kong:"cmd,help='Bind an endpoint to a port within a host virtualization domain.'"`
Unbind cmd.UnbindCmd `kong:"cmd,help='Unbind an endpoint on a port within a host virtualization domain.'"`
Dump cmd.DumpCmd `kong:"cmd,help='Dump various types of GFMS information.'"`
Gas cmd.GasCmd `kong:"cmd,help='Global Address Space (GAS) access commands.'"`
Csr cmd.CsrCmd `kong:"cmd,help='Configuration Status Register (CSR) access commands.'"`
Mfg cmd.MfgCmd `kong:"cmd,help='Manufacturing commands.'"`
Event cmd.EventCmd `kong:"cmd,help='Event commands.'"`
Bw cmd.BandwidthCmd `kong:"cmd,help='Measure the traffic bandwidth through each port.'"`
VfReset cmd.VfResetCmd `kong:"cmd,help='Perform a Function Level Reset (FLR) on a Virtual Function'"`
IdCtrl nvme.IdCtrlCmd `kong:"cmd,help='Identify Controller.'"`
IdPrimaryCtlrCaps nvme.PrimaryCtrlCapsCmd `kong:"cmd,help='Identify Primary Controller Capabilities.'"`
IdNs nvme.IdNsCmd `kong:"cmd,help='IdentifyNamespace.'"`
ListNs nvme.ListNsCmd `kong:"cmd,help='List Namespace.'"`
IdNsCtrls nvme.IdNamespaceCtrls `kong:"cmd,help='Identify Controller attached to Namespace.'"`
CreateNs nvme.CreateNsCmd `kong:"cmd,help='Create namespace.'"`
DeleteNs nvme.DeleteNsCmd `kong:"cmd,help='Delete namespace.'"`
FormatNs nvme.FormatNsCmd `kong:"cmd,help='Format namespace.'"`
AttachNs nvme.AttachNsCmd `kong:"cmd,help='attaches a namespace to the given controller or comma-sep list of controllers.'"`
DetachNs nvme.DetachNsCmd `kong:"cmd,help='detaches a namespace from the given controller or comma-sep list of controllers.'"`
ListSecondary nvme.ListSecondaryCmd `kong:"cmd,help='Show secondary controller list associated with the primary controller of the given device.'"`
VirtMgmt nvme.VirtualMgmtCmd `kong:"cmd,help='Virtualization command supported by primary NVMe controlers.'"`
GetFeature nvme.GetFeatureCmd `kong:"cmd,help='Get feature.'"`
SetFeature nvme.SetFeatureCmd `kong:"cmd,help='Set feature.'"`
GetSmartLog nvme.GetSmartLogCmd `kong:"cmd,help='Retrieve SMART log for the given device.'"`
BuildMiFeature nvme.BuildMiFeatureCmd `kong:"cmd,help='Build MI Metadata feature file with interactive terminal'"`
Discover nvme.DiscoverCmd `kong:"cmd,help='Discover NVMe devices by Serial Number, Model Number, or NQN.'"`
Config cfg.ConfigCmd `kong:"cmd,help='Configure device.'"`
}
func main() {
c := kong.Parse(&cli)
debugLevel := cli.Verbose
if debugLevel == ctx.Disabled && cli.Debug {
debugLevel = ctx.Debug
}
ctx.ApplyContext(ctx.Context{
DebugLevel: ctx.DebugLevel(debugLevel),
LogLevel: ctx.LogLevel(ctx.Disabled),
})
err := c.Run()
c.FatalIfErrorf(err)
}