当前位置: 首页>>代码示例>>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;未经允许,请勿转载。