Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get projects list not working with openstack4j-3.0.0 #694

Closed
gilbirenberg opened this issue May 30, 2016 · 22 comments
Closed

get projects list not working with openstack4j-3.0.0 #694

gilbirenberg opened this issue May 30, 2016 · 22 comments

Comments

@gilbirenberg
Copy link

Hi All

I am using the name jar and like to get all the projects list, here is the code I am using:
OSClientV3 os2 = OSFactory.builderV3()
.endpoint("http://127.0.0.1:5000/v3")
.credentials("admin", "********", Identifier.byName("default"))
.scopeToProject(Identifier.byName("admin") , Identifier.byName("default"))
.authenticate();
System.out.println(os2.identity().projects().list());

I active the http log:
OSFactory.enableHttpLoggingFilter(true);

the connection is working, then when running the command os2.identity().projects().list() I see that the REST API is trying to run this:
GET http://172.29.159.19:5000/v2.0/projects
You can see that this is not correct, it should be:
GET http://172.29.159.19:5000/v3/projects

Is this known issue?
Thanks
Gil

@auhlig
Copy link
Member

auhlig commented May 30, 2016

Hi @gilbirenberg ,

Strange. Does this happen just with project list?

@gilbirenberg
Copy link
Author

Hi @auhlig

Thanks for getting back to me
no, the same is happening also with
System.out.println(os2.identity().roles().list()) -> http://172.29.159.19:5000/v2.0/roles
System.out.println(os2.identity().users().list()); - > http://172.29.159.19:5000/v2.0/users

I think this is in any function's inside os2.identity()

Thanks
Gil

@auhlig
Copy link
Member

auhlig commented May 31, 2016

Mh. Can you take a look at the Identity Service in the Token's catalog? Is there a Identity V3 one with correct endpoints?

@gilbirenberg
Copy link
Author

should i check this with the openstart4j jar? can you give code example please?

@gilbirenberg
Copy link
Author

Hi

I hope you refering to this, but this is what i did:
Token t = os2.getToken();
List<? extends KeystoneService> ss = (List<? extends KeystoneService>) t.getCatalog();
for (KeystoneService s : ss){
System.out.println("Service:" + s.getName());
List<? extends Endpoint> endpoints = s.getEndpoints();
for (Endpoint endpoint : endpoints){
System.out.println("EndPoint:" + endpoint.getUrl());
}
}

@gilbirenberg
Copy link
Author

where os2 is V3 connection, i can see that the keystone endpoint is only
http://host:5000

@auhlig
Copy link
Member

auhlig commented May 31, 2016

Hi,
The responsebody of the v3-authentication request contains the Token, which contains the service catalog.

So you could enable debug by adding OSFactory's .enableHttpLoggingFilter(true) when building the initial request or use a tool like Charles proxy to be able to see the response.

@gilbirenberg
Copy link
Author

did is what i did, using the OSFactory's .enableHttpLoggingFilter(true). this is how i know that the url of the projects is bad
here is the response hope this ok
May 31, 2016 11:05:17 AM org.glassfish.jersey.filter.LoggingFilter log
INFO: 1 * Client response received on thread main
1 < 201
1 < Connection: Keep-Alive
1 < Content-Length: 4869
1 < Content-Type: application/json
1 < Date: Tue, 31 May 2016 08:05:11 GMT
1 < Keep-Alive: timeout=5, max=100
1 < Server: Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.1e-fips mod_wsgi/3.4 Python/2.7.5
1 < Vary: X-Auth-Token
1 < x-openstack-request-id: req-317f3e0d-723e-4baa-8c58-b60dada209ae
1 < X-Subject-Token: 622fcbd88e9d4b94be85ee76f0c4707d
{"token": {"is_domain": false, "methods": ["password"], "roles": [{"id": "9cbbe35667d5453b9a3070c4a522fc0b", "name": "admin"}], "is_admin_project": true, "project": {"domain": {"id": "default", "name": "Default"}, "id": "f15ab48ed8df45b9805997a5d6a51db4", "name": "admin"}, "catalog": [{"endpoints": [{"region_id": "RegionOne", "url": "http://10.133.65.127:9292", "region": "RegionOne", "interface": "internal", "id": "0df92cb4423743f291eb1824acb0d558"}, {"region_id": "RegionOne", "url": "http://10.133.65.127:9292", "region": "RegionOne", "interface": "public", "id": "1a6cccdbaec54cec848b336ba39e00ad"}, {"region_id": "RegionOne", "url": "http://10.133.65.127:9292", "region": "RegionOne", "interface": "admin", "id": "245adc00b1494580bc0e7977f7932deb"}], "type": "image", "id": "327458b4db904e3dbe943d33a8ccb0bf", "name": "glance"}, {"endpoints": [{"region_id": "RegionOne", "url": "http://10.133.65.127:8776/v1/f15ab48ed8df45b9805997a5d6a51db4", "region": "RegionOne", "interface": "public", "id": "2f69f3fcd98b42339d70b940083fb67f"}, {"region_id": "RegionOne", "url": "http://10.133.65.127:8776/v1/f15ab48ed8df45b9805997a5d6a51db4", "region": "RegionOne", "interface": "internal", "id": "5b803345d9e3415c90be3902e03e55c2"}, {"region_id": "RegionOne", "url": "http://10.133.65.127:8776/v1/f15ab48ed8df45b9805997a5d6a51db4", "region": "RegionOne", "interface": "admin", "id": "cddba5a23cff4cb9a35b272e910bf8f3"}], "type": "volume", "id": "43bcc7bd00804f17867b12ff55209f80", "name": "cinder"}, {"endpoints": [{"region_id": "RegionOne", "url": "http://10.133.65.127:5000", "region": "RegionOne", "interface": "internal", "id": "4ca7c54cb5cf448c9d3c9fa4185536d0"}, {"region_id": "RegionOne", "url": "http://10.133.65.127:35357", "region": "RegionOne", "interface": "admin", "id": "d0919fe5cf7f4064be98506f9f9aaa66"}, {"region_id": "RegionOne", "url": "http://10.133.65.127:5000", "region": "RegionOne", "interface": "public", "id": "fd9182b13bc744ca812f3bd64f8881a5"}], "type": "identity", "id": "872b1566c2ed4390a8ce3c11b8901023", "name": "keystone"}, {"endpoints": [{"region_id": "RegionOne", "url": "http://10.133.65.127:8774/v2/f15ab48ed8df45b9805997a5d6a51db4", "region": "RegionOne", "interface": "admin", "id": "7a4d56517e42446187fb3c11bf4222cd"}, {"region_id": "RegionOne", "url": "http://10.133.65.127:8774/v2/f15ab48ed8df45b9805997a5d6a51db4", "region": "RegionOne", "interface": "public", "id": "bed85ea8cc4d480f8af4e5f7c43a793b"}, {"region_id": "RegionOne", "url": "http://10.133.65.127:8774/v2/f15ab48ed8df45b9805997a5d6a51db4", "region": "RegionOne", "interface": "internal", "id": "e6e024b06b3645f080decbaf7393c920"}], "type": "compute_legacy", "id": "968de258e26d49b2a015a6d922559973", "name": "nova_legacy"}, {"endpoints": [{"region_id": "RegionOne", "url": "http://10.133.65.127:8774/v2.1", "region": "RegionOne", "interface": "admin", "id": "4ed6a1b46e9e48169618eced0395c1d5"}, {"region_id": "RegionOne", "url": "http://10.133.65.127:8774/v2.1", "region": "RegionOne", "interface": "public", "id": "6156ae6a65a44eda8d7533e1a54cdc6b"}, {"region_id": "RegionOne", "url": "http://10.133.65.127:8774/v2.1", "region": "RegionOne", "interface": "internal", "id": "f1b75cfd14d143e28fa89984569cf4c1"}], "type": "compute", "id": "a14200ac54cb4e46abe875598a2d8703", "name": "nova"}, {"endpoints": [{"region_id": "RegionOne", "url": "http://10.133.65.127:8776/v2/f15ab48ed8df45b9805997a5d6a51db4", "region": "RegionOne", "interface": "public", "id": "55788ed3b97b415aa8397e328fd86245"}, {"region_id": "RegionOne", "url": "http://10.133.65.127:8776/v2/f15ab48ed8df45b9805997a5d6a51db4", "region": "RegionOne", "interface": "internal", "id": "5ad9befe7369488ab26a6685710632bc"}, {"region_id": "RegionOne", "url": "http://10.133.65.127:8776/v2/f15ab48ed8df45b9805997a5d6a51db4", "region": "RegionOne", "interface": "admin", "id": "beaf7594a26243469f6e4ed5ed93daad"}], "type": "volumev2", "id": "d113382e968c491f8f566b1a55b68308", "name": "cinderv2"}, {"endpoints": [{"region_id": "RegionOne", "url": "http://10.133.65.127:8776/v3/f15ab48ed8df45b9805997a5d6a51db4", "region": "RegionOne", "interface": "public", "id": "4a35b3cb63db421e8480f40784214185"}, {"region_id": "RegionOne", "url": "http://10.133.65.127:8776/v3/f15ab48ed8df45b9805997a5d6a51db4", "region": "RegionOne", "interface": "internal", "id": "5c0ba2ce450c422babe9cccb7618bded"}, {"region_id": "RegionOne", "url": "http://10.133.65.127:8776/v3/f15ab48ed8df45b9805997a5d6a51db4", "region": "RegionOne", "interface": "admin", "id": "df927602de7c4fe0a006c902b995fb94"}], "type": "volumev3", "id": "f7fa45fd92f045ef82d1bddcf5bec148", "name": "cinderv3"}], "expires_at": "2016-05-31T09:05:18.507946Z", "user": {"domain": {"id": "default", "name": "Default"}, "id": "217e922c3843404b8c246d56776b9a6c", "name": "admin"}, "audit_ids": ["UM89NbMfRWmKNKe6kpS_CA"], "issued_at": "2016-05-31T08:05:18.508098Z"}}

@gilbirenberg
Copy link
Author

i think i found your problem, you are using this function String resolveV3(URLResolverParams p) to get the keystone public identity, the thing is in one of my system the response is wrong getting
http://172.29.159.19:5000/v2.0 and in one system i am getting http://10.133.65.127:5000,
I don't think that your approach here is right, you only need to get the host and port of the identity and base on the OSclient add the right version V3 or V2.0

any solution for this?
Gil

@gilbirenberg
Copy link
Author

Hi @auhlig

hope you doing well?
looks like your code is depending on the endpoint of the identity,
example:
"region_id": "RegionOne"
"url": "http://172.29.159.19:5000/v2.0"
"region": "RegionOne"
"interface": "public"
"id": "7302ac4c97bb42e58a2e37605f332899"

I don't this is right because i am using v3 connection and when running the command:
os2.identity().projects().list()
it not using the v3 but the v2.0

do you think this will be fix or you will give this option in the next release of you wonderful jar tool :)
Thanks
Gil

@vinodborole
Copy link
Contributor

@auhlig
Copy link
Member

auhlig commented Jun 1, 2016

Hi @gilbirenberg ,
Sorry for the late response.

Shouldn't the Identity V3 Endpoint in the catalog end with /v3?
In your case it's just http://<fqdn>:<port>.

@gilbirenberg
Copy link
Author

Hi @auhlig
No Problem, that is my problem, for some reason on my system i get the url from the endpoint with the version and on a second system i am getting the v2.0 and not the v3
do you know if this behavior can be change in the OpenStack logic? i still think that when calling the identity() function you need to sue the token or access endpoint, the endpoint that we use for the connection and not taking the endpoint from the catalog

Gil

@auhlig
Copy link
Member

auhlig commented Jun 1, 2016

Not sure I understand your last comment. As far as I know the url of the identity service in the catalog should contain the version, which will be used for identity operations.
Shouldn't it be enough to modify the existing/add a new endpoint with an url containing the /v3 to the identity service?

@gilbirenberg
Copy link
Author

Today the endpoint coming from the identity service is returning wrong version
Can i add new endpoint from your openstack4j jar? how can i implement your last sentence?

@auhlig
Copy link
Member

auhlig commented Jun 1, 2016

I guess in your case you need to configure your OpenStack properly, because adding an Endpoint to a service using OS4j is possible but requires that the Identity service works.

@auhlig
Copy link
Member

auhlig commented Jun 30, 2016

@gilbirenberg Is this issue still valid or can it be closed?

@vinodborole
Copy link
Contributor

@gilbirenberg please reopen if this issue is valid still

@kushalagrawal
Copy link
Contributor

kushalagrawal commented May 23, 2017

Hi @vinodborole @auhlig , I have several instance of openstack. All of them support V3 authentication. But in few instances after authentication keystone endpoint it is returning as http://ip_address:port/v2.0, Hence it is creating project url as /v2.0/projects but projects is only supported in /v3.

When I am doing externally /v3/projects it is returning all projects in all instances.

Can you please suggest some way so that I can get projects even if it returns /v2.0 as endpoint url. Otherwise with previous version of openstack it will be difficult to handle and we will be loosing backward compatibility.

@vinodborole
Copy link
Contributor

@kushalagrawal1 What do you mean when by this "When I am doing externally /v3/projects it is returning all projects in all instances." ?

@kushalagrawal
Copy link
Contributor

Hi @vinodborole, Thanks for replying, As I have multiple instances of OpenStack consider 2 at this moment.

/v3/projects returns a proper response in all instances.

the problem is with one of the OpenStack identity URL so get token using /v3/auth/tokens. it returns "/2.0" as identity endpoint and other one returns "/v3".

So in case of /v2.0 get project api starts failing with {"error": {"message": "The resource could not be found.", "code": 404, "title": "Not Found"}}

@vinodborole
Copy link
Contributor

@kushalagrawal1 It has to do something with your openstack configuration itself; please verify it once with your other two instances

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants