Minor changes and fixes

This commit is contained in:
David J. Allen 2023-08-30 14:43:13 -06:00
parent 488e6f8131
commit 118c12fa14
9 changed files with 40 additions and 38 deletions

View file

@ -27,7 +27,7 @@ var collectCmd = &cobra.Command{
// use the found results to query bmc information
inventories := [][]byte{}
// users := [][]byte{}
users := [][]byte{}
for _, ps := range probeStates {
if !ps.State {
continue
@ -65,17 +65,17 @@ var collectCmd = &cobra.Command{
inventories = append(inventories, inventory)
// users
// user, err := magellan.QueryUsers(client, &logger, &q)
// if err != nil {
// l.Errorf("could not query users: %v\n", err)
// }
user, err := magellan.QueryUsers(client, &logger, &q)
if err != nil {
l.Errorf("could not query users: %v\n", err)
}
users = append(users, user)
// // bios
// _, err = magellan.QueryBios(client, &logger, &q)
// if err != nil {
// l.Errorf("could not query bios: %v\n", err)
// }
// users = append(users, user)
_, err = magellan.QueryBios(client, &logger, &q)
if err != nil {
l.Errorf("could not query bios: %v\n", err)
}
}
// add all endpoints to smd

View file

@ -17,7 +17,9 @@ var listCmd = &cobra.Command{
if err != nil {
logrus.Errorf("could not get probe results: %v\n", err)
}
fmt.Printf("%v\n", probeResults)
for _, r := range probeResults {
fmt.Printf("%s:%d (%s)\n", r.Host, r.Port, r.Protocol)
}
},
}

View file

@ -17,8 +17,9 @@ var (
certPoolFile string
user string
pass string
dbpath string
dbpath string
drivers []string
ipmitoolPath string
)
// TODO: discover bmc's on network (dora)
@ -26,9 +27,9 @@ var (
// TODO: send bmc component information to smd
var rootCmd = &cobra.Command{
Use: "magellan",
Use: "magellan",
Short: "Tool for BMC discovery",
Long: "",
Long: "",
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
cmd.Help()
@ -37,14 +38,14 @@ var rootCmd = &cobra.Command{
},
}
func Execute(){
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
func init(){
func init() {
rootCmd.PersistentFlags().StringVar(&user, "user", "", "set the BMC user")
rootCmd.PersistentFlags().StringVar(&pass, "pass", "", "set the BMC pass")
rootCmd.PersistentFlags().StringSliceVar(&hosts, "host", []string{}, "set additional hosts")
@ -54,6 +55,7 @@ func init(){
rootCmd.PersistentFlags().IntSliceVar(&ports, "port", []int{}, "set the ports to scan")
rootCmd.PersistentFlags().StringSliceVar(&drivers, "driver", []string{"redfish"}, "set the BMC driver to use")
rootCmd.PersistentFlags().StringVar(&dbpath, "dbpath", ":memory:", "set the probe storage path")
rootCmd.PersistentFlags().StringVar(&ipmitoolPath, "ipmitool", "/usr/bin/ipmitool", "set the path for ipmitool")
rootCmd.PersistentFlags().BoolVar(&withSecureTLS, "secure-tls", false, "enable secure TLS")
rootCmd.PersistentFlags().StringVar(&certPoolFile, "cert-pool", "", "path to an file containing x509 CAs. An empty string uses the system CAs. Only takes effect when --secure-tls=true")
}
}

View file

@ -16,7 +16,7 @@ var (
var scanCmd = &cobra.Command{
Use: "scan",
Short: "Scan for BMCs",
Short: "Scan for BMC nodes on a network",
Run: func(cmd *cobra.Command, args []string) {
// set hosts to use for scanning
hostsToScan := []string{}
@ -49,7 +49,7 @@ var scanCmd = &cobra.Command{
func init() {
scanCmd.Flags().Uint8Var(&begin, "begin", 0, "set the starting point for range of IP addresses")
scanCmd.Flags().Uint8Var(&end, "end", 255, "set the ending point for range of IP addresses")
scanCmd.Flags().StringSliceVar(&subnets, "subnet", []string{"127.0.0.0"}, "set additional subnets")
scanCmd.Flags().StringSliceVar(&subnets, "subnet", []string{}, "set additional subnets")
rootCmd.AddCommand(scanCmd)
}