google-cloud-platformopenstackopenstack4j

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?


Solution

  • 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("x.x.x.x")). New auth code:

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