Skip to content

Commit 9a861ec

Browse files
authored
Merge branch 'master' into CY-2432-Keystone-v3-Validation
2 parents 3e1942f + 03c00d6 commit 9a861ec

File tree

4 files changed

+34
-11
lines changed

4 files changed

+34
-11
lines changed

CHANGELOG.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
3.2.11:
22
- Keystone V3 validation to refer to docs URL in case of missing configuration.
3+
- Add public_ip property when using server_connected_to_floating_ip and if use_public_ip is set True.
34
3.2.10:
45
- Remove ID key from resource object if healing terminated VM.
56
3.2.9

openstack_plugin/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@
152152
CLOUDIFY_STOP_OPERATION,
153153
CLOUDIFY_DELETE_OPERATION,
154154
CLOUDIFY_CREATE_VALIDATION]
155+
SERVER_PUBLIC_IP_PROPERTY = 'public_ip'
156+
SERVER_IP_PROPERTY = 'ip'
155157

156158
KEY_USE_CFY_LOGGER = 'use_cfy_logger'
157159
KEY_GROUPS = 'groups'

openstack_plugin/resources/compute/server.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@
8484
OPENSTACK_PORT_ID,
8585
OPENSTACK_NETWORK_ID,
8686
OPENSTACK_TYPE_PROPERTY,
87-
USE_EXTERNAL_RESOURCE_PROPERTY)
87+
USE_EXTERNAL_RESOURCE_PROPERTY,
88+
SERVER_PUBLIC_IP_PROPERTY,
89+
SERVER_IP_PROPERTY)
8890

8991
from openstack_plugin.utils import \
9092
(handle_userdata,
@@ -209,8 +211,8 @@ def _set_server_ips_runtime_properties(server):
209211

210212
# Only set the first "ip" as runtime property
211213
if ipv4['type'] == 'fixed'\
212-
and 'ip' not in ctx.instance.runtime_properties:
213-
ctx.instance.runtime_properties['ip'] = ip
214+
and SERVER_IP_PROPERTY not in ctx.instance.runtime_properties:
215+
ctx.instance.runtime_properties[SERVER_IP_PROPERTY] = ip
214216

215217
# Only set the first "public_ip_address" as runtime property
216218
elif ipv4['type'] == 'floating'\
@@ -226,8 +228,8 @@ def _set_server_ips_runtime_properties(server):
226228
ctx.instance.runtime_properties['ipv6'] = ip_v6
227229
# If "ip" is not set at this point, then the only address used
228230
# is ipv6
229-
if 'ip' not in ctx.instance.runtime_properties:
230-
ctx.instance.runtime_properties['ip'] = ip_v6
231+
if SERVER_IP_PROPERTY not in ctx.instance.runtime_properties:
232+
ctx.instance.runtime_properties[SERVER_IP_PROPERTY] = ip_v6
231233

232234
# Only set the first "public_ip6_address" as runtime property
233235
elif ipv6['type'] == 'floating'\
@@ -240,11 +242,12 @@ def _set_server_ips_runtime_properties(server):
240242
if ctx.node.properties.get('use_public_ip'):
241243
pip = ctx.instance.runtime_properties.get('public_ip_address')
242244
if pip:
243-
ctx.instance.runtime_properties['ip'] = pip
245+
ctx.instance.runtime_properties[SERVER_IP_PROPERTY] = pip
246+
ctx.instance.runtime_properties[SERVER_PUBLIC_IP_PROPERTY] = pip
244247

245248
elif ctx.node.properties.get('use_ipv6_ip', False) and ipv6_addresses:
246249
ip_v6 = ctx.instance.runtime_properties['ipv6']
247-
ctx.instance.runtime_properties['ip'] = ip_v6
250+
ctx.instance.runtime_properties[SERVER_IP_PROPERTY] = ip_v6
248251

249252
# Get list of all ipv4 associated with server
250253
ipv4_list = map(lambda ipv4_conf: ipv4_conf['addr'], ipv4_addresses)
@@ -2003,6 +2006,14 @@ def connect_floating_ip(openstack_resource, floating_ip, fixed_ip=''):
20032006
fixed_ip = fixed_ip or None
20042007
openstack_resource.add_floating_ip_to_server(floating_ip,
20052008
fixed_ip=fixed_ip)
2009+
# set public ip property inside server runtime_properties
2010+
ctx.source.instance.runtime_properties[SERVER_PUBLIC_IP_PROPERTY] = \
2011+
floating_ip
2012+
if ctx.source.node.properties.get('use_public_ip', False):
2013+
ctx.source.instance.runtime_properties['last_ip'] = \
2014+
ctx.source.instance.runtime_properties.get(SERVER_IP_PROPERTY)
2015+
ctx.source.instance.runtime_properties[SERVER_IP_PROPERTY] = \
2016+
floating_ip
20062017

20072018

20082019
@with_compat_node
@@ -2022,6 +2033,11 @@ def disconnect_floating_ip(openstack_resource, floating_ip):
20222033
''.format(openstack_resource.resource_id))
20232034

20242035
openstack_resource.remove_floating_ip_from_server(floating_ip)
2036+
# remove public ip property from server runtime_properties
2037+
ctx.source.instance.runtime_properties.pop(SERVER_PUBLIC_IP_PROPERTY, None)
2038+
if ctx.source.node.properties.get('use_public_ip', False):
2039+
ctx.source.instance.runtime_properties[SERVER_IP_PROPERTY] = \
2040+
ctx.source.instance.runtime_properties.pop('last_ip', None)
20252041

20262042

20272043
@with_compat_node

openstack_plugin/tests/compute/test_server.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@
6666
VOLUME_DETACHMENT_TASK,
6767
VOLUME_ATTACHMENT_ID,
6868
SERVER_ACTION_STATUS_DONE,
69-
SERVER_ACTION_STATUS_PENDING)
69+
SERVER_ACTION_STATUS_PENDING,
70+
SERVER_PUBLIC_IP_PROPERTY,
71+
SERVER_IP_PROPERTY)
7072

7173

7274
class CustomMockContext(MockContext):
@@ -656,8 +658,9 @@ def test_create_external_resource(self,
656658
'10.1.0.1',
657659
self._ctx.instance.runtime_properties['access_ipv4'])
658660

659-
self.assertTrue(self._ctx.instance.runtime_properties['ip'],
660-
'10.1.0.1')
661+
self.assertTrue(
662+
self._ctx.instance.runtime_properties[SERVER_IP_PROPERTY],
663+
'10.1.0.1')
661664

662665
self.assertEqual(
663666
3,
@@ -1946,6 +1949,7 @@ def test_disconnect_floating_ip(self, mock_connection):
19461949
RESOURCE_ID: 'a95b5509-c122-4c2f-823e-884bb559afe8',
19471950
OPENSTACK_TYPE_PROPERTY: SERVER_OPENSTACK_TYPE,
19481951
OPENSTACK_NAME_PROPERTY: 'node-server',
1952+
SERVER_PUBLIC_IP_PROPERTY: '10.2.3.4',
19491953
}),
19501954
'node': MockNodeContext(
19511955
id='1',
@@ -2018,6 +2022,7 @@ def test_disconnect_external_floating_ip(self, mock_connection):
20182022
RESOURCE_ID: 'a95b5509-c122-4c2f-823e-884bb559afe8',
20192023
OPENSTACK_TYPE_PROPERTY: SERVER_OPENSTACK_TYPE,
20202024
OPENSTACK_NAME_PROPERTY: 'node-server',
2025+
SERVER_PUBLIC_IP_PROPERTY: '10.2.3.4',
20212026
}),
20222027
'node': MockNodeContext(
20232028
id='1',
@@ -2043,7 +2048,6 @@ def test_disconnect_external_floating_ip(self, mock_connection):
20432048
'availability_zone': 'test_availability_zone',
20442049
'key_name': 'test_key_name',
20452050
'status': 'ACTIVE',
2046-
20472051
})
20482052

20492053
# Mock find server operation

0 commit comments

Comments
 (0)