Esempio n. 1
0
func TryDeploy(contents []byte, instance Instance) (id metadata.ID, err error) {

	login := new(metadata.BasicAuth)
	login.SessionId = instance.UserInfo.SessionID

	options := new(metadata.DeployOptions)
	options.SinglePackage = true

	deploy := new(metadata.Deploy)
	deploy.DeployOptions = options

	b64 := base64.StdEncoding.EncodeToString(contents)

	deploy.ZipFile = b64

	port := metadata.NewMetadataPortType(instance.MetadataURL, false, login)

	response, err := port.Deploy(deploy)

	if err != nil {
		return
	}

	id = *response.Result.Id

	fmt.Println(*response.Result.State)
	fmt.Println(response.Result.Message)

	return
}
Esempio n. 2
0
func TryDeploy(contents []byte, url, sessionId string) (success bool, err error) {

	login := new(metadata.BasicAuth)
	login.SessionId = sessionId

	options := new(metadata.DeployOptions)
	options.SinglePackage = true

	deploy := new(metadata.Deploy)
	deploy.DeployOptions = options

	b64 := base64.StdEncoding.EncodeToString(contents)

	port := metadata.NewMetadataPortType(url, false, login)

	response, err := port.Deploy(deploy)

	if err != nil {
		return
	}

	for true {
		time.Sleep(20)

		status := new(metadata.CheckDeployStatus)
		status.IncludeDetails = true
		status.AsyncProcessId = response.Result.Id
		statusResponse, err := port.CheckDeployStatus(status)

		if err != nil {
			success = false
			return
		}

		if statusResponse.Result.Done {
			fmt.Println(statusResponse.Result.Status)
			fmt.Println(statusResponse.Result.Details)

			success = true
			return
		}
	}
}