Example #1
0
func (context *ElasticRuntime) getAllCloudControllerVMs() (ccvms []CCJob, err error) {

	lo.G.Debug("Entering getAllCloudControllerVMs() function")
	directorInfo := context.SystemsInfo.SystemDumps[ERDirector]
	connectionURL := fmt.Sprintf(ERVmsURL, directorInfo.Get(SDIP), context.InstallationName)
	lo.G.Debug("getAllCloudControllerVMs() function", log.Data{"connectionURL": connectionURL, "directorInfo": directorInfo})
	gateway := context.HTTPGateway
	if gateway == nil {
		gateway = ghttp.NewHttpGateway()
	}
	lo.G.Debug("Retrieving CC vms")
	if resp, err := gateway.Get(ghttp.HttpRequestEntity{
		Url:         connectionURL,
		Username:    directorInfo.Get(SDUser),
		Password:    directorInfo.Get(SDPass),
		ContentType: "application/json",
	})(); err == nil {
		var jsonObj []VMObject

		lo.G.Debug("Unmarshalling CC vms")
		defer resp.Body.Close()
		body, err := ioutil.ReadAll(resp.Body)
		if err = json.Unmarshal(body, &jsonObj); err == nil {
			ccvms, err = GetCCVMs(jsonObj)
		}
	}
	return
}
Example #2
0
func (context *ElasticRuntime) directorCredentialsValid() (ok bool) {
	var directorInfo SystemDump

	if directorInfo, ok = context.SystemsInfo.SystemDumps[ERDirector]; ok {
		connectionURL := fmt.Sprintf(ERDirectorInfoURL, directorInfo.Get(SDIP))
		gateway := context.HTTPGateway
		if gateway == nil {
			gateway = ghttp.NewHttpGateway()
		}
		_, err := gateway.Get(ghttp.HttpRequestEntity{
			Url:         connectionURL,
			Username:    directorInfo.Get(SDUser),
			Password:    directorInfo.Get(SDPass),
			ContentType: "application/json",
		})()
		ok = (err == nil)
	}
	return
}
Example #3
0
package token

import "encoding/json"
import "fmt"
import "github.com/pivotalservices/gtils/http"

import "github.com/pivotalservices/uaaldapimport/functions"
import "io/ioutil"
import . "net/http"

type Token struct {
	AccessToken string `json:"access_token"`
}

var NewGateway = func() http.HttpGateway {
	return http.NewHttpGateway()
}

var GetToken functions.TokenFunc = func(info *functions.Info) (token string, err error) {
	fmt.Println("Getting token.............")
	entity := http.HttpRequestEntity{
		Url:      fmt.Sprintf("%s/oauth/token?grant_type=client_credentials", info.Uaaurl),
		Username: info.Clientid,
		Password: info.Secret,
	}
	httpGateway := NewGateway()
	request := httpGateway.Post(entity, nil)
	response, err := request()
	if err != nil {
		return
	}
Example #4
0
	LocalExecuter       command.Executer
	SettingsUploader    httpUploader
	AssetsUploader      httpUploader
	SettingsRequestor   httpRequestor
	AssetsRequestor     httpRequestor
	DeploymentDir       string
	OpsmanagerBackupDir string
	Logger              log.Logger
}

// NewOpsManager initializes an OpsManager instance
var NewOpsManager = func(opsManagerHostname string, adminUsername string, adminPassword string, opsManagerUsername string, opsManagerPassword string, target string, logger log.Logger) (context *OpsManager, err error) {
	var remoteExecuter command.Executer

	if remoteExecuter, err = createExecuter(opsManagerHostname, opsManagerUsername, opsManagerPassword, OPSMGR_DEFAULT_SSH_PORT); err == nil {
		settingsHttpRequestor := ghttp.NewHttpGateway()
		settingsMultiHttpRequestor := ghttp.MultiPartUpload
		assetsHttpRequestor := ghttp.NewHttpGateway()
		assetsMultiHttpRequestor := ghttp.MultiPartUpload

		context = &OpsManager{
			SettingsUploader:  settingsMultiHttpRequestor,
			AssetsUploader:    assetsMultiHttpRequestor,
			SettingsRequestor: settingsHttpRequestor,
			AssetsRequestor:   assetsHttpRequestor,
			DeploymentDir:     path.Join(target, OPSMGR_BACKUP_DIR, OPSMGR_DEPLOYMENTS_DIR),
			Hostname:          opsManagerHostname,
			Username:          adminUsername,
			Password:          adminPassword,
			BackupContext: BackupContext{
				TargetDir: target,