0

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?

Kilmer Luiz Aleluia
  • 305
  • 1
  • 3
  • 14
  • 1
    I don't know OpenStack4J, but you need to set the "interface" used to locate the endpoint url (to one of `public`, `admin`, or `internal`). There is some suggestion that you can do this via a custom endpoint url resolver in [the faq](http://www.openstack4j.com/learn/getting-started#faq), but there are no examples there. – larsks Apr 19 '19 at 21:48
  • In advance, thanks for helping me (: To solve the problem, I had to do what you suggested, but in another way: https://github.com/ContainX/openstack4j/issues/152. I will answer with my solution. – Kilmer Luiz Aleluia Apr 20 '19 at 05:23

1 Answers1

0

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();
Kilmer Luiz Aleluia
  • 305
  • 1
  • 3
  • 14