func (s *SupermicroX) Status() (health string, err error) {
	ipmi, err := s.query("op=SYS_HEALTH.XML&r=(1,ff)")
	if err != nil {
		return health, err
	}
	if ipmi.HealthInfo != nil && ipmi.HealthInfo.Health == "1" {
		return "OK", err
	}
	return "Unhealthy", err
}
Status returns health string status from the bmc
package supermicrox11
import (
	"bytes"
	"context"
	"encoding/xml"
	"fmt"
	"io/ioutil"
	"net/http"
	"net/http/httputil"
	"net/url"
	"strconv"
	"strings"
	"github.com/bmc-toolbox/bmclib/devices"
	"github.com/bmc-toolbox/bmclib/errors"
	"github.com/bmc-toolbox/bmclib/internal/httpclient"
	"github.com/go-logr/logr"
	"github.com/bmc-toolbox/bmclib/providers/supermicro"
)
const (
	BmcType = "supermicrox"
	X11 = "x11"
)
type SupermicroX struct {
	ip         string
	username   string
	password   string
	sid        *http.Cookie
	httpClient *http.Client
	ctx        context.Context
	log        logr.Logger
}
func New(ctx context.Context, ip string, username string, password string, log logr.Logger) (sm *SupermicroX, err error) {
	return &SupermicroX{
		ip:       ip,
		username: username,
		password: password,
		ctx:      ctx,
		log:      log}, err
}
func (s *SupermicroX) CheckCredentials() (err error) {
	err = s.httpLogin()
	if err != nil {
		return err
	}
	return err
}
func (s *SupermicroX) get(endpoint string) (payload []byte, err error) {
	bmcURL := fmt.Sprintf("https://%s/%s", s.ip, endpoint)
	req, err := http.NewRequest("GET", bmcURL, nil)
	if err != nil {
		return payload, err
	}
	req.AddCookie(s.sid)
	reqDump, _ := httputil.DumpRequestOut(req, true)
	s.log.V(2).Info("trace", "url", bmcURL, "requestDump", string(reqDump))
	resp, err := s.httpClient.Do(req)
	if err != nil {
		return payload, err
	}
	defer resp.Body.Close()
	respDump, _ := httputil.DumpResponse(resp, true)
	s.log.V(2).Info("", "responseDump", string(respDump))
	payload, err = ioutil.ReadAll(resp.Body)
	if err != nil {
		return payload, err
	}
	if resp.StatusCode == 404 {
		return payload, errors.ErrPageNotFound
	}
	return payload, err
}
func (s *SupermicroX) post(endpoint string, urlValues *url.Values, form []byte, formDataContentType string) (response string, statusCode int, err error) {
	err = s.httpLogin()
	if err != nil {
		return response, statusCode, err
	}
	bmcURL := fmt.Sprintf("https://%s/cgi/%s", s.ip, endpoint)
	u, err := url.Parse(bmcURL)
	if err != nil {
		return response, statusCode, err
	}
	var req *http.Request
	if formDataContentType == "" {
		req, err = http.NewRequest("POST", u.String(), strings.NewReader(urlValues.Encode()))
		if err != nil {
			return response, statusCode, err
		}
		req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
	} else {
		req, err = http.NewRequest("POST", u.String(), bytes.NewReader(form))
		if err != nil {
			return response, statusCode, err
		}
		req.Header.Set("Content-Type", formDataContentType)
	}
	req.AddCookie(s.sid)
	reqDump, _ := httputil.DumpRequestOut(req, true)
	s.log.V(2).Info("trace", "url", bmcURL, "requestDump", string(reqDump))
	resp, err := s.httpClient.Do(req)
	if err != nil {
		return response, statusCode, err
	}
	defer resp.Body.Close()
	respDump, _ := httputil.DumpResponse(resp, true)
	s.log.V(2).Info("", "responseDump", string(respDump))
	statusCode = resp.StatusCode
	respPayload, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return response, statusCode, err
	}
	return string(respPayload), statusCode, err
}
func (s *SupermicroX) query(requestType string) (ipmi *supermicro.IPMI, err error) {
	err = s.httpLogin()
	if err != nil {
		return ipmi, err
	}
	bmcURL := fmt.Sprintf("https://%s/cgi/ipmi.cgi", s.ip)
	s.log.V(1).Info("retrieving data from bmc", "step", "bmc connection", "vendor", supermicro.VendorID, "ip", s.ip)
	req, err := http.NewRequest("POST", bmcURL, bytes.NewBufferString(requestType))
	if err != nil {
		return ipmi, err
	}
	req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
	u, err := url.Parse(bmcURL)
	if err != nil {
		return ipmi, err
	}
	for _, cookie := range s.httpClient.Jar.Cookies(u) {
		if cookie.Name == "SID" && cookie.Value != "" {
			req.AddCookie(cookie)
		}
	}
	reqDump, _ := httputil.DumpRequestOut(req, true)
	s.log.V(2).Info("trace", "url", bmcURL, "requestDump", string(reqDump))
	resp, err := s.httpClient.Do(req)
	if err != nil {
		return ipmi, err
	}
	defer resp.Body.Close()
	payload, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return ipmi, err
	}
	respDump, _ := httputil.DumpResponse(resp, true)
	s.log.V(2).Info("", "responseDump", string(respDump))
	ipmi = &supermicro.IPMI{}
	err = xml.Unmarshal(payload, ipmi)
	if err != nil {
		return ipmi, err
	}
	return ipmi, err
}
func (s *SupermicroX) Serial() (serial string, err error) {
	ipmi, err := s.query("op=FRU_INFO.XML&r=(0,0)")
	if err != nil {
		return serial, err
	}
	if ipmi.FruInfo == nil || ipmi.FruInfo.Board == nil {
		return serial, errors.ErrInvalidSerial
	}
	return strings.ToLower(ipmi.FruInfo.Board.SerialNum), err
}
func (s *SupermicroX) ChassisSerial() (serial string, err error) {
	ipmi, err := s.query("op=FRU_INFO.XML&r=(0,0)")
	if err != nil {
		return serial, err
	}
	if ipmi.FruInfo == nil || ipmi.FruInfo.Chassis == nil {
		return serial, errors.ErrInvalidSerial
	}
	return strings.ToLower(strings.TrimSpace(ipmi.FruInfo.Chassis.SerialNum)), err
}
func (s *SupermicroX) HardwareType() (model string) {
	m, err := s.Model()
	if err != nil {
		return model
	}
	return m
}
func (s *SupermicroX) Model() (model string, err error) {
	ipmi, err := s.query("op=FRU_INFO.XML&r=(0,0)")
	if err != nil {
		return model, err
	}
	if ipmi.FruInfo != nil && ipmi.FruInfo.Board != nil {
		return ipmi.FruInfo.Board.PartNum, err
	}
	return model, err
}
func (s *SupermicroX) Version() (bmcVersion string, err error) {
	ipmi, err := s.query("op=GENERIC_INFO.XML&r=(0,0)")
	if err != nil {
		return bmcVersion, err
	}
	if ipmi.GenericInfo != nil {
		if ipmi.GenericInfo.IpmiFwVersion != "" {
			return ipmi.GenericInfo.IpmiFwVersion, err
		} else if ipmi.GenericInfo.Generic != nil {
			return ipmi.GenericInfo.Generic.IpmiFwVersion, err
		}
	}
	return bmcVersion, err
}
func (s *SupermicroX) Name() (name string, err error) {
	ipmi, err := s.query("op=CONFIG_INFO.XML&r=(0,0)")
	if err != nil {
		return name, err
	}
	if ipmi.ConfigInfo != nil && ipmi.ConfigInfo.Hostname != nil {
		return ipmi.ConfigInfo.Hostname.Name, err
	}
	return name, err
}