Skip to content

Commit 1836f90

Browse files
author
earthmant
committed
improvements
1 parent 1927003 commit 1836f90

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

blueprints/server-networks.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ tosca_definitions_version: cloudify_dsl_1_3
22

33
imports:
44
- http://www.getcloudify.org/spec/cloudify/4.3.1/types.yaml
5-
- http://www.getcloudify.org/spec/openstack-plugin/2.8.0/plugin.yaml
5+
- http://www.getcloudify.org/spec/openstack-plugin/2.8.1/plugin.yaml
66

77
inputs:
88

neutron_plugin/floatingip.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,37 +56,35 @@ def create(neutron_client, args, **kwargs):
5656
}
5757
floatingip.update(ctx.node.properties[FLOATINGIP_OPENSTACK_TYPE], **args)
5858

59-
# Do we have a relationship with a network?
60-
6159
network_from_rel = \
6260
get_openstack_id_of_single_connected_node_by_openstack_type(
6361
ctx, NETWORK_OPENSTACK_TYPE, True)
6462

65-
# TODO: Should we check whether this is really an "external" network?
66-
67-
network_name_provided = 'floating_network_name' in floatingip
68-
network_id_provided = 'floating_network_id' in floatingip
69-
provided = [network_name_provided,
70-
network_id_provided,
71-
network_from_rel is not None].count(True)
72-
73-
# At most one is expected.
74-
75-
if provided > 1:
76-
raise NonRecoverableError(FLOATING_NETWORK_ERROR_MSG.format(
77-
network_from_rel, floatingip))
78-
79-
if network_name_provided:
63+
if 'floating_network_id' in floatingip:
64+
ctx.logger.debug(
65+
'Using floating ip network {0}.'.format(
66+
floatingip['floating_network_id']))
67+
elif 'floating_network_name' in floatingip:
8068
floatingip['floating_network_id'] = neutron_client.cosmo_get_named(
8169
'network', floatingip['floating_network_name'])['id']
70+
ctx.logger.debug(
71+
'Using floating ip network {0} from name {1} provided.'.format(
72+
floatingip['floating_network_id'],
73+
floatingip['floating_network_name']))
8274
del floatingip['floating_network_name']
8375
elif network_from_rel:
8476
floatingip['floating_network_id'] = network_from_rel
85-
elif not network_id_provided:
77+
ctx.logger.debug(
78+
'Using floating ip network {0} from relationship.'.format(
79+
floatingip['floating_network_id']))
80+
else:
8681
provider_context = provider(ctx)
8782
ext_network = provider_context.ext_network
8883
if ext_network:
8984
floatingip['floating_network_id'] = ext_network['id']
85+
ctx.logger.debug(
86+
'Using floating ip network {0} from provider context.'.format(
87+
floatingip['floating_network_id']))
9088
else:
9189
raise NonRecoverableError(FLOATING_NETWORK_ERROR_MSG.format(
9290
None, None))

0 commit comments

Comments
 (0)