From c4c1139887027b1f9d6edbbed36fee5d55f574fb Mon Sep 17 00:00:00 2001 From: Ahmed Abdrabo Date: Fri, 6 Nov 2020 18:28:20 +0100 Subject: [PATCH] Pass the username/password instead of reading them twice 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. --- connectors/collection.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/connectors/collection.go b/connectors/collection.go index 696cf892..6e4191f9 100644 --- a/connectors/collection.go +++ b/connectors/collection.go @@ -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" @@ -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() { @@ -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 {