func machinetoStruct(rawmachine vm.Machine) jsonMachine { var mach jsonMachine mach.Id = rawmachine.Id() mach.Name, _ = rawmachine.Name() status, _ := rawmachine.Status() mach.Status = vm.StatusToString(status) ip, _ := rawmachine.IP() mach.Ip = string(ip) return mach }
func isStopped(machine vms.Machine) bool { status, err := machine.Status() if err != nil { log.Error(err.Error()) return false } if status == vms.StatusDown { return true } else { return false } }
func provExec(p io.Writer, machine vms.Machine, command string) (string, error) { machine.Status() ip, _ := machine.IP() for checkPlaza(ip.String(), utils.Env("PLAZA_PORT", "9090")) != true { machine.Status() ip, _ = machine.IP() time.Sleep(time.Millisecond * 500) } plazaAddress, err := machine.IP() if err != nil { log.Error(err.Error()) return "", err } plazaPort, err := strconv.Atoi(utils.Env("PLAZA_PORT", "9090")) if err != nil { log.Error(err.Error()) return "", err } domain := utils.Env("WINDOWS_DOMAIN", "") if domain == "" { log.Error("domain unknown") return "", errors.New("domain unknown") } username, password, err := machine.Credentials() if err != nil { log.Error(err.Error()) return "", err } res, err := PowershellExec( plazaAddress.String(), plazaPort, username, domain, password, command, ) p.Write([]byte(command)) if err != nil { return "", err } return res.Stdout, nil }