Um: let me see if I can work out a suitable answer.
As it stands, step 13 tries to assign unused_floating_ip to a free floating
ip. If there isn't one, it then tries to allocate a floating ip from the
pool, and assigns it to unused_floating_ip
print('Checking for unused Floating IP...')
unused_floating_ip = None
for floating_ip in conn.ex_list_floating_ips():
if not floating_ip.node_id: unused_floating_ip = floating_ip
break
if not unused_floating_ip:
pool = conn.ex_list_floating_ip_pools()[0]
print('Allocating new Floating IP from pool: {}'.format(pool))
unused_floating_ip = pool.create_floating_ip()
So at the end of step 13 unused_floating_ip will be assigned, on those
installations that support floating ip pools. If you are on an installation
that doesn't I'm guessing the adventure stops here because an exception
will have been thrown.
Then in step 14 a test is done to see if the instance has a public ip: and
if it doesn't, attaches the allocated floating ip to the instance.
if len(testing_instance.public_ips) > 0:
print('Instance ' + testing_instance.name + ' already has a public ip.
Skipping attachment.')
else:
conn.ex_attach_floating_ip_to_node(testing_instance, unused_floating_ip)
Finally in step 15 it is reported that the instance can be found at
unused_floating_ip
print('The Fractals app will be deployed to http://%s' %
unused_floating_ip.ip_address)
However, at this point, this ip address might not have been allocated to
the instance, as the instance had a public ip address. So the wrong ip
address is shown...
And on installations where the private ip is in fact the public ip none of
the above would have worked.
On installations where there is a public ip allocated, an attempt is made
to creating a floating ip, which is then reported as the ip address at
which the instance will be found. Which is surely also wrong?
And yes, the documentation says substitute another ip address as
appropriate, but I think that given that this is aimed at developers who
might be new to OpenStack, getting correct code and good documentation in
front of them is worth the effort.
I'm happy to try and improve the libcloud version of the code the matching
documentation if you like: I've already had to work around it for our local
cloud.
Martin
On 2 November 2015 at 22:06, Atsushi SAKAI <email address hidden> wrote:
Um: let me see if I can work out a suitable answer.
As it stands, step 13 tries to assign unused_floating_ip to a free floating
ip. If there isn't one, it then tries to allocate a floating ip from the
pool, and assigns it to unused_floating_ip
print('Checking for unused Floating IP...') list_floating_ ips(): ip.node_ id:
unused_ floating_ ip = floating_ip
unused_floating_ip = None
for floating_ip in conn.ex_
if not floating_
break
if not unused_floating_ip: list_floating_ ip_pools( )[0] 'Allocating new Floating IP from pool: {}'.format(pool)) floating_ ip = pool.create_ floating_ ip()
pool = conn.ex_
print(
unused_
So at the end of step 13 unused_floating_ip will be assigned, on those
installations that support floating ip pools. If you are on an installation
that doesn't I'm guessing the adventure stops here because an exception
will have been thrown.
Then in step 14 a test is done to see if the instance has a public ip: and
if it doesn't, attaches the allocated floating ip to the instance.
if len(testing_ instance. public_ ips) > 0: instance. name + ' already has a public ip. ex_attach_ floating_ ip_to_node( testing_ instance, unused_floating_ip)
print('Instance ' + testing_
Skipping attachment.')
else:
conn.
Finally in step 15 it is reported that the instance can be found at
unused_floating_ip
print('The Fractals app will be deployed to http:// %s' % floating_ ip.ip_address)
unused_
However, at this point, this ip address might not have been allocated to
the instance, as the instance had a public ip address. So the wrong ip
address is shown...
And on installations where the private ip is in fact the public ip none of
the above would have worked.
On installations where there is a public ip allocated, an attempt is made
to creating a floating ip, which is then reported as the ip address at
which the instance will be found. Which is surely also wrong?
And yes, the documentation says substitute another ip address as
appropriate, but I think that given that this is aimed at developers who
might be new to OpenStack, getting correct code and good documentation in
front of them is worth the effort.
I'm happy to try and improve the libcloud version of the code the matching
documentation if you like: I've already had to work around it for our local
cloud.
Martin
On 2 November 2015 at 22:06, Atsushi SAKAI <email address hidden> wrote:
> Would you describe which IP address is problematic? developer. openstack. org/firstapp- libcloud/ getting_ started. html /bugs.launchpad .net/bugs/ 1512215 /bugs.launchpad .net/openstack- api-site/ +bug/1512215/ +subscriptions
>
> Also
> From seeing following URL
> http://
>
> It describes
> Note
> If you do not use floating IPs, substitute another IP address as
> appropriate
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https:/
>
> Title:
> The "Writing your first OpenStack application" book contains code that
> does not work with OpenStack installations that use private IP's as
> public IP's
>
> To manage notifications about this bug go to:
> https:/
>
-- ======= ======= ======= ======= ======= ======= ======= ======= ==
=======
Martin Paulo, BSc.
Software Developer
Tel : +61-3-9434 2508 (Home) www.thepaulofam ily.net
Tel : 04 205 20339 (Mobile)
Site: http://
"Nobody goes there any more. It's too crowded" - Yogi Berra.