예제 #1
0
파일: main.go 프로젝트: dell-esg/idracula
func waitForJob(client *wsman.Client, jobinfo *dom.Element) bool {
	jobID := string(search.First(search.Attr("Name", "*", "InstanceID"), jobinfo.All()).Content)
	log.Printf("%s: Waiting for job %s to finish\n", client.Endpoint(), jobID)
	var code string
	ret := false
	for {
		time.Sleep(10 * time.Second)
		msg := client.Get("http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_LifecycleJob")
		msg.Selectors("InstanceID", jobID)
		res, err := msg.Send()
		if err != nil {
			log.Printf("Error monitoring job: %v\n", err)
			if res != nil {
				log.Printf("Response: %s\n", res.String())
			}
			goto out
		}
		code = strings.TrimSpace(
			string(search.First(
				search.Tag("JobStatus", "*"),
				res.AllBodyElements()).Content))
		switch code {
		case "Completed":
			ret = true
			goto out
		case "Completed with Errors":
			goto out
		case "Failed":
			goto out
		}
	}
out:
	log.Printf("Job %s finished with %s\n", jobID, code)
	return ret
}
예제 #2
0
파일: main.go 프로젝트: dell-esg/idracula
func hasIdrac(client *wsman.Client) bool {
	res, err := client.Identify()
	if err != nil {
		log.Printf("No WSMAN endpoint at %s\n", client.Endpoint())
		return false
	}
	n := search.First(search.Tag("ProductName", "*"), res.AllBodyElements())
	if n != nil && string(n.Content) == "iDRAC" {
		log.Printf("Found iDRAC at %s\n", client.Endpoint())
		return true
	}
	log.Printf("No iDRAC at WSMAN endpoint %s\n", client.Endpoint())
	return false
}