Add list resource providers API for placement service#1815
Add list resource providers API for placement service#1815jtopjian merged 4 commits intogophercloud:masterfrom
Conversation
| ParentProviderUuid string `json:"parent_provider_uuid"` | ||
| RootProviderUuid string `json:"root_provider_uuid"` |
There was a problem hiding this comment.
UUID capitalization for variable names.
| ParentProviderUuid: "542df8ed-9be2-49b9-b4db-6d3183ff8ec8", | ||
| RootProviderUuid: "542df8ed-9be2-49b9-b4db-6d3183ff8ec8", |
There was a problem hiding this comment.
UUID capitalization for variable names.
| ParentProviderUuid: "", | ||
| RootProviderUuid: "d0b381e9-8761-42de-8e6c-bba99a96d5f5", |
There was a problem hiding this comment.
UUID capitalization for variable names.
|
Build succeeded.
|
|
@jtopjian This is ready for review. Thanks. |
|
Build succeeded.
|
jtopjian
left a comment
There was a problem hiding this comment.
@dkt26111 Thank you for working on this 🙂
This all looks good. I've left a few minor comments. In addition, the files need slightly reorganized:
acceptance/openstack/placement/v1openstack/placement/v1/resourceproviders
Please let me know if you have any questions.
acceptance/clients/clients.go
Outdated
| // NewPlacementClient returns a *ServiceClient for making calls | ||
| // to the OpenStack Placement API. An error will be returned | ||
| // if authentication or client creation was not possible. | ||
| func NewPlacementClient() (*gophercloud.ServiceClient, error) { |
openstack/client.go
Outdated
| } | ||
|
|
||
| // NewPlacement creates a ServiceClient that may be used with the placement package. | ||
| func NewPlacement(client *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) (*gophercloud.ServiceClient, error) { |
|
|
||
| for _, r := range allResourceProviders { | ||
| fmt.Printf("%+v\n", r) | ||
| } |
There was a problem hiding this comment.
nit: the formatting of the above example code looks a little off. godoc depends on correct formatting or else it wouldn't be a big deal.
There was a problem hiding this comment.
You are right. I'll fix that.
| UUID string `q:"uuid"` | ||
|
|
||
| // Member_of is a string representing aggregate uuids to filter or exclude from the list | ||
| Member_of string `q:"member_of"` |
|
|
||
| // In_tree is a string that represents a resource provider UUID. The returned resource | ||
| // providers will be in the same provider tree as the specified provider. | ||
| In_tree string `q:"in_tree"` |
| Links []ResourceProviderLinks `json:"links"` | ||
| Name string `json:"name"` | ||
| ParentProviderUUID string `json:"parent_provider_uuid"` | ||
| RootProviderUUID string `json:"root_provider_uuid"` |
There was a problem hiding this comment.
It looks like the above two fields are part of a microversion?
https://github.com/openstack/placement/blob/master/placement/handlers/resource_provider.py#L56-L58
According to our microversion rules, these should have their own Extract methods. However, Placement is still a relatively new service and I think 1.14 should be an early enough release that we can consider that part of "base".
It might be worthwhile to add a comment about this, though:
// ParentProviderUUID contains the UUID of the parent provider.
// Requires microversion 1.14 or above.
ParentProviderUUID string `json:"parent_provider_uuid"`
// RootProviderUUID contains the UUID of the root provider.
// Requires microversion 1.14 or above.
ParentProviderUUID string `json:"parent_provider_uuid"`There was a problem hiding this comment.
Sure, I'll add the comments.
|
Build failed.
|
|
@jtopjian Ready for review again. |
jtopjian
left a comment
There was a problem hiding this comment.
LGTM - thank you!
Please see the comment about the acceptance test, just as a heads up.
| th "github.com/gophercloud/gophercloud/testhelper" | ||
| ) | ||
|
|
||
| func TestResourceProviderList(t *testing.T) { |
There was a problem hiding this comment.
I'm getting a 403 error when I try to run this test as a normal user -- I think this requires admin access?
If so, then we need to add:
clients.RequireAdmin(t)at the very beginning of this test function.
I'll make this change right after I merge this PR.
There was a problem hiding this comment.
Good catch. In fact all placement APIs appear to be restricted to admin by default:
https://docs.openstack.org/placement/latest/configuration/policy.html
I usually use admin user when running the acceptance tests so I didn't notice it.
For #526
Links to the line numbers/files in the OpenStack source code that support the
code in this PR:
API doc:
https://docs.openstack.org/api-ref/placement/?expanded=#list-resource-providers
API code:
https://github.com/openstack/placement/blob/master/placement/handlers/resource_provider.py#L197