當前位置: 首頁>>代碼示例>>Golang>>正文


Golang ManagementAPI.AddHostedService方法代碼示例

本文整理匯總了Golang中launchpad/net/gwacl.ManagementAPI.AddHostedService方法的典型用法代碼示例。如果您正苦於以下問題:Golang ManagementAPI.AddHostedService方法的具體用法?Golang ManagementAPI.AddHostedService怎麽用?Golang ManagementAPI.AddHostedService使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在launchpad/net/gwacl.ManagementAPI的用法示例。


在下文中一共展示了ManagementAPI.AddHostedService方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: attemptCreateService

// attemptCreateService tries to create a new hosted service on Azure, with a
// name it chooses (based on the given prefix), but recognizes that the name
// may not be available.  If the name is not available, it does not treat that
// as an error but just returns nil.
func attemptCreateService(azure *gwacl.ManagementAPI, prefix string, affinityGroupName string, location string) (*gwacl.CreateHostedService, error) {
	var err error
	name := gwacl.MakeRandomHostedServiceName(prefix)
	err = azure.CheckHostedServiceNameAvailability(name)
	if err != nil {
		// The calling function should retry.
		return nil, nil
	}
	req := gwacl.NewCreateHostedServiceWithLocation(name, name, location)
	req.AffinityGroup = affinityGroupName
	err = azure.AddHostedService(req)
	if err != nil {
		return nil, err
	}
	return req, nil
}
開發者ID:hivetech,項目名稱:judo.legacy,代碼行數:20,代碼來源:environ.go

示例2: attemptCreateService

// attemptCreateService tries to create a new hosted service on Azure, with a
// name it chooses (based on the given prefix), but recognizes that the name
// may not be available.  If the name is not available, it does not treat that
// as an error but just returns nil.
func attemptCreateService(azure *gwacl.ManagementAPI, prefix string, affinityGroupName string) (*gwacl.CreateHostedService, error) {
	name := gwacl.MakeRandomHostedServiceName(prefix)
	req := gwacl.NewCreateHostedServiceWithLocation(name, name, serviceLocation)
	req.AffinityGroup = affinityGroupName
	err := azure.AddHostedService(req)
	azErr, isAzureError := err.(*gwacl.AzureError)
	if isAzureError && azErr.HTTPStatus == http.StatusConflict {
		// Conflict.  As far as we can see, this only happens if the
		// name was already in use.  It's still dangerous to assume
		// that we know it can't be anything else, but there's nothing
		// else in the error that we can use for closer identifcation.
		return nil, nil
	}
	if err != nil {
		return nil, err
	}
	return req, nil
}
開發者ID:CSRedRat,項目名稱:juju-core,代碼行數:22,代碼來源:environ.go


注:本文中的launchpad/net/gwacl.ManagementAPI.AddHostedService方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。