本文整理汇总了Golang中github.com/rackspace/gophercloud.AuthOptions.DomainName方法的典型用法代码示例。如果您正苦于以下问题:Golang AuthOptions.DomainName方法的具体用法?Golang AuthOptions.DomainName怎么用?Golang AuthOptions.DomainName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/rackspace/gophercloud.AuthOptions
的用法示例。
在下文中一共展示了AuthOptions.DomainName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: New
func New(cfgFile string) CinderDriver {
conf, err := processConfig(cfgFile)
isV3 := strings.Contains(conf.Endpoint, "v3")
if err != nil {
log.Fatal("Error processing cinder driver config file: ", err)
}
_, err = os.Lstat(conf.MountPoint)
if os.IsNotExist(err) {
if err := os.MkdirAll(conf.MountPoint, 0755); err != nil {
log.Fatal("Failed to create Mount directory during driver init: %v", err)
}
}
auth := gophercloud.AuthOptions{
IdentityEndpoint: conf.Endpoint,
Username: conf.Username,
Password: conf.Password,
TenantID: conf.TenantID,
AllowReauth: true,
}
if isV3 == true && conf.DomainName == "" {
log.Warning("V3 endpoint specified, but DomainName not set!")
log.Warning("Setting to \"Default\", maybe it'll work.")
auth.DomainName = "Default"
}
if conf.DomainName != "" && isV3 == true {
log.Info("Authorizing to a V3 Endpoint")
auth.DomainName = conf.DomainName
}
providerClient, err := openstack.AuthenticatedClient(auth)
if err != nil {
log.Fatal("Error initiating gophercloud provider client: ", err)
}
client, err := openstack.NewBlockStorageV2(providerClient,
gophercloud.EndpointOpts{Region: "RegionOne"})
if err != nil {
log.Fatal("Error initiating gophercloud cinder client: ", err)
}
d := CinderDriver{
Conf: &conf,
Mutex: &sync.Mutex{},
Client: client,
}
return d
}