Skip to content

Commit

Permalink
fixes #289
Browse files Browse the repository at this point in the history
  • Loading branch information
isaac-s committed Nov 30, 2018
1 parent bc7fc2f commit 311a3fa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
2.14.4:
- By default, don't allow using an existing floating IP if it had already been allocated.
2.14.3:
- Fix check subnet cidr for fixed ip.
2.14.2:
Expand Down
8 changes: 7 additions & 1 deletion openstack_plugin_common/floatingip.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# * limitations under the License.

from cloudify import ctx
from cloudify.exceptions import RecoverableError
from openstack_plugin_common import (
delete_resource_and_runtime_properties,
use_external_resource,
Expand All @@ -22,7 +23,6 @@
OPENSTACK_ID_PROPERTY,
OPENSTACK_TYPE_PROPERTY)


FLOATINGIP_OPENSTACK_TYPE = 'floatingip'

# Runtime properties
Expand All @@ -35,6 +35,12 @@ def use_external_floatingip(client, ip_field_name, ext_fip_ip_extractor):
external_fip = use_external_resource(
ctx, client, FLOATINGIP_OPENSTACK_TYPE, ip_field_name)
if external_fip:
if ctx.node.properties['allow_reallocation'] \

This comment has been minimized.

Copy link
@mabuaisha

mabuaisha Dec 4, 2018

@isaac-s based on your defining the allow_reallocation

      allow_reallocation:
        type: boolean
        default: false
        description: >
          (Applicable only when use_external_resource is true)
          If true, then allow using this floating IP even if it has already been allocated to
          another instance. If false, and the floating IP is already allocated (that is, it is
          in 'ACTIVE' state), a recoverable error is raised.

The condition must be if not ctx.node.properties['allow_reallocation'] and external_fip['status'] == 'ACTIVE'

This comment has been minimized.

Copy link
@isaac-s

isaac-s Dec 4, 2018

Author Contributor

You're right!
@EarthmanT please abort the release — I'll submit a fix right away

and external_fip['status'] == 'ACTIVE':
raise RecoverableError(
'Floating IP address {0} is already associated'.format(
external_fip['floating_ip_address'])
)
ctx.instance.runtime_properties[IP_ADDRESS_PROPERTY] = \
ext_fip_ip_extractor(external_fip)
return True
Expand Down
8 changes: 8 additions & 0 deletions plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,14 @@ node_types:
description: >
a boolean for setting whether to create the resource or use an existing one.
See the using existing resources section.
allow_reallocation:
type: boolean
default: false
description: >
(Applicable only when use_external_resource is true)
If true, then allow using this floating IP even if it has already been allocated to
another instance. If false, and the floating IP is already allocated (that is, it is
in 'ACTIVE' state), a recoverable error is raised.
create_if_missing:
type: boolean
default: false
Expand Down

0 comments on commit 311a3fa

Please sign in to comment.