MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / runNodesShow

Function runNodesShow

internal/cli/nodes.go:142–187  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

140}
141
142func runNodesShow(cmd *cobra.Command, args []string) error {
143 session, err := initCLISession(cmd)
144 if err != nil {
145 return printError(err)
146 }
147
148 if session == nil {
149 return nil
150 }
151
152 nodeName := args[0]
153
154 nodes, err := session.getNodes(context.Background())
155 if err != nil {
156 return printError(fmt.Errorf("failed to fetch nodes: %w", err))
157 }
158
159 for _, n := range nodes {
160 if n != nil && n.Name == nodeName {
161 out := nodeToOutput(n)
162
163 if getOutputFormat(cmd) == outputTable {
164 printTable(
165 []string{"FIELD", "VALUE"},
166 [][]string{
167 {"Name", out.Name},
168 {"IP", out.IP},
169 {"Status", onlineStr(out.Online)},
170 {"CPU Usage", fmt.Sprintf("%.1f%%", out.CPUUsage*100)},
171 {"Memory Used", formatBytes(int64(out.MemoryUsed))},
172 {"Memory Total", formatBytes(int64(out.MemoryTotal))},
173 {"Uptime", formatUptime(out.Uptime)},
174 {"Version", out.Version},
175 {"Kernel", out.KernelVersion},
176 },
177 )
178
179 return nil
180 }
181
182 return printJSON(out)
183 }
184 }
185
186 return printError(fmt.Errorf("node %q not found", nodeName))
187}
188
189// ── nodes shell ──────────────────────────────────────────────────────────────
190

Callers

nothing calls this directly

Calls 10

initCLISessionFunction · 0.85
printErrorFunction · 0.85
nodeToOutputFunction · 0.85
getOutputFormatFunction · 0.85
printTableFunction · 0.85
onlineStrFunction · 0.85
formatBytesFunction · 0.85
formatUptimeFunction · 0.85
printJSONFunction · 0.85
getNodesMethod · 0.80

Tested by

no test coverage detected