Skip to content

Commit

Permalink
Pass the username/password instead of reading them twice
Browse files Browse the repository at this point in the history
This is a follow up after 3b0176f. Since we have 2 options for the
password (bmc_pass & bmc_pass_file), I am passing the username/password
along instead of reading it again.
  • Loading branch information
Ahmed Abdrabo committed Nov 6, 2020
1 parent 54353d1 commit c4c1139
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions connectors/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func collect(input <-chan string, source *string, db *gorm.DB) {
continue
}

err := collectCmc(bmc)
err := collectCmc(bmc, bmcUser, bmcPass)
if err != nil {
log.WithFields(log.Fields{"operation": "collection", "ip": host}).Error(err)
graphiteKey = "collect.cmc_collection_failed"
Expand Down Expand Up @@ -367,7 +367,7 @@ func collectBmc(bmc devices.Bmc) (err error) {
return nil
}

func collectCmc(bmc devices.Cmc) (err error) {
func collectCmc(bmc devices.Cmc, bmcUser string, bmcPass string) (err error) {
defer bmc.Close()

if !bmc.IsActive() {
Expand Down Expand Up @@ -400,8 +400,8 @@ func collectCmc(bmc devices.Cmc) (err error) {

if conn, err := discover.ScanAndConnect(
blade.BmcAddress,
viper.GetString("bmc_user"),
viper.GetString("bmc_pass"),
bmcUser,
bmcPass,
hintOpts...,
); err == nil {

Expand Down

0 comments on commit c4c1139

Please sign in to comment.