简体   繁体   中英

openstack4j sending request to wrong host

I have a OpenStack running on a Google Cloud Plataform VM. Even tough I create a openstack4j os with external IP, when I call any method I got connect timed out , because openstack4j is using internal IP. Can I set manually my host when calling methods like os.compute().flavors().list() ?

        OSClient.OSClientV3 os = OSFactory.builderV3()
                .endpoint("http://external_ip:5000/v3")
                .credentials("admin", "pass", domain)
                .scopeToProject(project)
                .authenticate();

        os.compute().flavors().list();

Using OSFactory.enableHttpLoggingFilter(true); , I found out that flavors.list is calling http://internal_ip:8774/v2.1/.../flavors/detail .

Other wierd thing is that if I remove .scopeToProject(project) and call the same flavors.list method, calls external ip, but returns none flavor (problably because it should be stick to a project).

Why flavors.list is calling my GCP VM's internal IP? Can I set to external?

As @larsks suggested, I had to tell openstak4j that was needed to use external IP. To solve it, I added a instruction with my public IP: .withConfig(Config.newConfig().withEndpointNATResolution("xxxx")) . New auth code:

OSClient.OSClientV3 os = OSFactory.builderV3()
   .endpoint("http://external_ip:5000/v3")
   .credentials("admin", "pass", domain)
   .scopeToProject(project)
   .authenticate();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM