Merge pull request #64 from OpenCHAMI/update-readme

Update readme
This commit is contained in:
David Allen 2024-10-16 14:23:19 -06:00 committed by GitHub
commit 294f4520f2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 30 additions and 29 deletions

View file

@ -60,6 +60,9 @@ release: ## goreleaser build
$(call print-target) $(call print-target)
$(GOPATH)/bin/goreleaser build --clean --single-target --snapshot $(GOPATH)/bin/goreleaser build --clean --single-target --snapshot
.PHONY: binaries
binaries: build
.PHONY: build .PHONY: build
build: ## go build build: ## go build
go build -v --tags=all -ldflags=$(LDFLAGS) -o $(NAME) main.go go build -v --tags=all -ldflags=$(LDFLAGS) -o $(NAME) main.go

View file

@ -101,7 +101,7 @@ This should return a JSON response with general information. The output below ha
### Running the Tool ### Running the Tool
There are three main commands to use with the tool: `scan`, `list`, and `collect`. To see all of the available commands, run `magellan` with the `help` subcommand: There are three main commands to use with the tool: `scan`, `list`, and `collect`. To see all of the available commands, run `magellan` with the `help` subcommand which will print this output:
```bash ```bash
Redfish-based BMC discovery tool Redfish-based BMC discovery tool
@ -119,16 +119,17 @@ Available Commands:
login Log in with identity provider for access token login Log in with identity provider for access token
scan Scan to discover BMC nodes on a network scan Scan to discover BMC nodes on a network
update Update BMC node firmware update Update BMC node firmware
version Print version info and exit
Flags: Flags:
--access-token string set the access token --access-token string Set the access token
--cache string set the scanning result cache path (default "/tmp/allend/magellan/assets.db") --cache string Set the scanning result cache path (default "/tmp/allend/magellan/assets.db")
--concurrency int set the number of concurrent processes (default -1) --concurrency int Set the number of concurrent processes (default -1)
-c, --config string set the config file path -c, --config string Set the config file path
-d, --debug set to enable/disable debug messages -d, --debug Set to enable/disable debug messages
-h, --help help for magellan -h, --help help for magellan
--timeout int set the timeout (default 5) --timeout int Set the timeout for requests (default 5)
-v, --verbose set to enable/disable verbose output -v, --verbose Set to enable/disable verbose output
Use "magellan [command] --help" for more information about a command. Use "magellan [command] --help" for more information about a command.
``` ```
@ -143,23 +144,19 @@ To start a network scan for BMC nodes, use the `scan` command. If the port is no
--cache data/assets.db \ --cache data/assets.db \
``` ```
This will scan the `172.16.0.0` subnet returning the host and port that return a response and store the results in a local cache with at the `data/assets.db` path. Additional flags can be set such as `--host` to add more hosts to scan not included on the subnet, `--timeout` to set how long to wait for a response from the BMC node, or `--concurrency` to set the number of requests to make concurrently. Setting the `--format=json` will format the output in JSON. Try using `./magellan help scan` for a complete set of options this subcommand. Alternatively, the same scan can be started using CIDR notation and with additional hosts: This will scan the `172.16.0.0` subnet returning the host and port that return a response and store the results in a local cache with at the `data/assets.db` path. Additional flags can be set such as `--host` to add more hosts to scan that are not included on the subnet, `--timeout` to set how long to wait for a response from the BMC node, or `--concurrency` to set the number of requests to make concurrently with goroutines. Try using `./magellan help scan` for a complete set of options this subcommand. Alternatively, the same scan can be started using CIDR notation and with additional hosts:
```bash ```bash
./magellan scan https://10.0.0.100:5000 --subnet 172.16.0.0/24 ./magellan scan https://10.0.0.100:5000 --subnet 172.16.0.0/24
``` ```
Check the help for each subcommand for more examples for specifying arguments. Once the scan is complete, inspect the cache to see a list of found hosts with the `list` command. Make sure to point to the same database used before if you set the `--cache` flag.
To inspect the cache, use the `list` command. Make sure to point to the same database used before:
```bash ```bash
./magellan list --cache data/assets.db --format json ./magellan list --cache data/assets.db
``` ```
This will print a list of node info found and stored from the scan. Like the `scan` subcommand, the output format can be set using the `--format` flag. This will print a list of host information needed for the `collect` step. Set the `ACCESS_TOKEN` if necessary and invoke `magellan` again with the `collect` subcommand to query the node BMCs stored in cache. If the `--host` flag is set, then an additional request will be made to send the output to the specified URL. The `--userame` and `--password` flags must be set if the BMC requires basic authentication.
Finally, set the `ACCESS_TOKEN`run the `collect` command to query the node from cache and send the info to be stored into SMD:
```bash ```bash
./magellan collect \ ./magellan collect \
@ -167,14 +164,14 @@ Finally, set the `ACCESS_TOKEN`run the `collect` command to query the node from
--timeout 5 \ --timeout 5 \
--username $USERNAME \ --username $USERNAME \
--password $PASSWORD \ --password $PASSWORD \
--host https://example.openchami.cluster:27779 \ --host https://example.openchami.cluster:8443 \
--output logs/ --output logs/
--cacert cacert.pem --cacert cacert.pem
``` ```
This uses the info stored in cache to request information about each BMC node if possible. Like with the scan, the time to wait for a response can be set with the `--timeout` flag as well. This command also requires the `--user` and `--pass` flags to be set if access the Redfish service requires basic authentication. Additionally, it may be necessary to set the `--host` and `--port` flags for `magellan` to find the SMD API (not the root API endpoint "/hsm/v2"). The output of the `collect` can be saved by using the `--output` This will initiate a crawler that will find as much inventory data as possible. The data can be viewed from standard output by setting the `--verbose` flag. This output can also be saved by using the `--output` flag and providing a path argument.
Note: If the `cache` flag is not set, `magellan` will use "/tmp/$USER/magellan.db" by default. Note: If the `cache` flag is not set, `magellan` will use `/tmp/$USER/magellan.db` by default.
### Updating Firmware ### Updating Firmware

View file

@ -74,13 +74,13 @@ func Execute() {
func init() { func init() {
currentUser, _ = user.Current() currentUser, _ = user.Current()
cobra.OnInitialize(InitializeConfig) cobra.OnInitialize(InitializeConfig)
rootCmd.PersistentFlags().IntVar(&concurrency, "concurrency", -1, "set the number of concurrent processes") rootCmd.PersistentFlags().IntVar(&concurrency, "concurrency", -1, "Set the number of concurrent processes")
rootCmd.PersistentFlags().IntVar(&timeout, "timeout", 5, "set the timeout") rootCmd.PersistentFlags().IntVar(&timeout, "timeout", 5, "Set the timeout for requests")
rootCmd.PersistentFlags().StringVarP(&configPath, "config", "c", "", "set the config file path") rootCmd.PersistentFlags().StringVarP(&configPath, "config", "c", "", "Set the config file path")
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "set to enable/disable verbose output") rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Set to enable/disable verbose output")
rootCmd.PersistentFlags().BoolVarP(&debug, "debug", "d", false, "set to enable/disable debug messages") rootCmd.PersistentFlags().BoolVarP(&debug, "debug", "d", false, "Set to enable/disable debug messages")
rootCmd.PersistentFlags().StringVar(&accessToken, "access-token", "", "set the access token") rootCmd.PersistentFlags().StringVar(&accessToken, "access-token", "", "Set the access token")
rootCmd.PersistentFlags().StringVar(&cachePath, "cache", fmt.Sprintf("/tmp/%s/magellan/assets.db", currentUser.Username), "set the scanning result cache path") rootCmd.PersistentFlags().StringVar(&cachePath, "cache", fmt.Sprintf("/tmp/%s/magellan/assets.db", currentUser.Username), "Set the scanning result cache path")
// bind viper config flags with cobra // bind viper config flags with cobra
checkBindFlagError(viper.BindPFlag("concurrency", rootCmd.PersistentFlags().Lookup("concurrency"))) checkBindFlagError(viper.BindPFlag("concurrency", rootCmd.PersistentFlags().Lookup("concurrency")))

View file

@ -15,15 +15,16 @@ var (
var versionCmd = &cobra.Command{ var versionCmd = &cobra.Command{
Use: "version", Use: "version",
Short: "Print version info and exit",
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
if cmd.Flag("commit").Value.String() == "true" { if cmd.Flag("commit").Value.String() == "true" {
output = commit output = commit
if date != "" { if date != "" {
output += " built @ " + date output += " built on " + date
} }
fmt.Println(output) fmt.Println(output)
} else { } else {
fmt.Println(version) fmt.Printf("%s-%s\n", version, commit)
} }
}, },
} }