supporto ups no auth
This commit is contained in:
parent
77bdc609b1
commit
ee7d2697ee
@ -29,28 +29,29 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func UpsConnect() {
|
func UpsConnect() {
|
||||||
var username, password string
|
var port int
|
||||||
|
var host, username, password string
|
||||||
var connectErr, authenticationError error
|
var connectErr, authenticationError error
|
||||||
var u nut.UPS
|
var u nut.UPS
|
||||||
|
|
||||||
upsClient, connectErr = nut.Connect(config.GetString("Ups.Host"), config.GetInt("Ups.Port"))
|
host = config.GetString("Ups.Host")
|
||||||
|
port = config.GetInt("Ups.Port")
|
||||||
|
upsClient, connectErr = nut.Connect(host, port)
|
||||||
if connectErr != nil {
|
if connectErr != nil {
|
||||||
syslog.Err(connectErr.Error())
|
syslog.Err(connectErr.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if username = config.GetString("Ups.Username"); username == "" {
|
username = config.GetString("Ups.Username")
|
||||||
return
|
password = config.GetString("Ups.Password")
|
||||||
}
|
|
||||||
if password = config.GetString("Ups.Password"); password == "" {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if username != "" && password != "" {
|
||||||
_, authenticationError = upsClient.Authenticate(username, password)
|
_, authenticationError = upsClient.Authenticate(username, password)
|
||||||
if authenticationError != nil {
|
if authenticationError != nil {
|
||||||
syslog.Err(authenticationError.Error())
|
syslog.Err(authenticationError.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
upsList, listErr := upsClient.GetUPSList()
|
upsList, listErr := upsClient.GetUPSList()
|
||||||
if listErr != nil {
|
if listErr != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user