Open kgrvamsi opened 8 years ago
@jrperritt @jamiehannaford Ping
What are you trying to do with the list of tenants and the token? What is the problem you're running into?
I'm more concerned on the tenant list not on the tokens (the code for token above is just to check the function) and my problem here is that when I'm hitting the identity api and trying to retrieve the list of tenants available in that dc I only see one tenant which I'm part of the tenant space but not all the tenants available in that specific dc.
Thanks @jrperritt @jamiehannaford i just have checked the code there and i tried tweaking a bit creating the token and making a request accordingly and here is the snippet not sure if the request flow to fetch the data that i'm doing is correct or not
opts := gophercloud.AuthOptions{
IdentityEndpoint: config.Get(v + ".identityurl").(string),
Username: config.Get(v + ".username").(string),
Password: config.Get(v + ".password").(string),
TenantID: config.Get(v + ".tenantid").(string),
AllowReauth: true,
}
provider, err := openstack.AuthenticatedClient(opts)
client := openstack.NewIdentityV2(provider)
fmt.Println(client)
if err != nil {
fmt.Println("we are here in the error block")
fmt.Println(err)
}
var opts = tokens.AuthOptions{
opts,
}
result := tokens.Create(client, opts)
fmt.Println(result)
token, err := result.ExtractToken()
fmt.Println(token.ID,token.Name)
getResult := tokens.Get(client, token.ID)
user, err := getResult.ExtractUser()
if err != nil {
fmt.Println("We are here in the err block")
fmt.Println(err)
}
fmt.Println(user)
count := 0
err := tenants.List(client, &tenant_opts).EachPage(func(page pagination.Page) (bool, error) {
tenantList, err := tenants.ExtractTenants(page)
for _, t := range tenantList {
// "t" will be a tenants.Tenant
fmt.Println(t)
}
count++
return true,nil
})
}
Output
I get the client object with all the endpoint urls and the roles for the specified user and the user have member and the admin user and the same user in python can get all the tenants and users with respective their roles but here i see single tenant user as show in my first comment screenshot
I hit the wrong Function to grab all the tenants list and the correct function is NewIdentityAdminV2 and the documentation looks wrong with the example there
@kgrvamsi thanks for the hint, I also met with the issue.
I'm not sure if i'm using the library properly but confused with the end result of the code
config.yaml
fetcher.go
Output
Note:
1)Every Dc have around 100+ Tenants 2)Sorry if my standard of programming looks messy anywhere.Recommendations are welcome.