Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Cmd = &command.Command{ Name: cmdName, Cobra: &cobra.Command{ Use: cmdName, Short: "get VMNIC information", SilenceUsage: true, Args: cobra.NoArgs, PreRunE: func(cmd *cobra.Command, args []string) error { return nil }, RunE: func(cmd *cobra.Command, args []string) error { cons := conswriter.GetTerminal() table := tablewriter.NewWriter(cons) table.SetHeaderAlignment(tablewriter.ALIGN_LEFT) table.SetHeaderLine(false) table.SetAutoFormatHeaders(true) table.SetColumnAlignment([]int{tablewriter.ALIGN_LEFT, tablewriter.ALIGN_RIGHT, tablewriter.ALIGN_RIGHT}) table.SetBorders(tablewriter.Border{Left: true, Top: false, Right: true, Bottom: false}) table.SetCenterSeparator("") table.SetColumnSeparator("") table.SetRowSeparator("") table.SetHeader([]string{"id", "key", "value"}) id, err := flag.GetID(viper.GetViper(), keyVMNICID) if err != nil { return errors.Wrap(err, "unable to get VM NIC ID") } vmnicCfg := vmnic.Config{ ID: id, } vmn, err := vmnic.Open(vmnicCfg) if err != nil { return errors.Wrap(err, "unable to open VM NIC") } defer vmn.Close() if viper.GetBool(keyGetNQueues) { numQueues, err := vmn.NQueuesGet() if err != nil { return errors.Wrapf(err, "unable to get the number of hardware queues") } table.Append([]string{ id.String(), "num-queues", strconv.FormatInt(int64(numQueues), 10), }) } table.Render() return nil }, }, Setup: func(self *command.Command) error { { const ( key = keyGetNQueues longName = "num-queues" shortName = "n" defaultValue = true description = "get the number of hardware queues for a given VM NIC" ) flags := self.Cobra.Flags() flags.BoolP(longName, shortName, defaultValue, description) viper.BindPFlag(key, flags.Lookup(longName)) viper.SetDefault(key, defaultValue) } if err := flag.AddVMNICID(self, keyVMNICID, true); err != nil { return errors.Wrap(err, "unable to register VMNIC ID flag on VM NIC get") } return nil }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.