Skip to content

Commit 1b2455f

Browse files
authored
Merge pull request #256 from cloudify-cosmo/2.9.6-build
fix external volume availability zone issue
2 parents 32af9e0 + 9990082 commit 1b2455f

9 files changed

Lines changed: 55 additions & 25 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,4 @@ docs/_build/
6262

6363
.idea/
6464

65+
.DS_Store

CHANGELOG.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
2.9.6: Correctly set the availability zone runtime property when using an external volume.
12
2.9.5: Creating servers with multiple security groups.
23
2.9.4: Backporting change from 3.0.0 dev branch.
34
2.9.3: Improve Host Aggregate members handling.

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,22 @@ Cloudify OpenStack Plugin
99
## Usage
1010

1111
See [Openstack Plugin](https://docs.cloudify.co/latest/developer/official_plugins/openstack/)
12+
13+
14+
## Known Issues
15+
16+
You may experience such an error when using a local profile:
17+
18+
```shell
19+
ERROR:cloudify.cli.main:(PyYAML 3.10 (/.../python2.7/site-packages), Requirement.parse('PyYAML>=3.12'), set(['oslo.config']))
20+
```
21+
22+
Cloudify CLI requires PyYAML 3.10, whereas Openstack Python SDK Libraries require PyYAML 3.12. For this reason, if you wish to use Cloudify Openstack Plugin in a local profile, you will need to upgrade the PyYAML 3.12 in your virtualenv.
23+
24+
Fix:
25+
26+
```shell
27+
pip install -U pyyaml==3.12
28+
```
29+
30+
At this stage, you should no longer use the flag `--install-plugins` with the `cfy` CLI.

cinder_plugin/tests/test_volume.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
from cloudify.state import current_ctx
2222
from cinder_plugin import volume
2323
from nova_plugin import server
24-
from openstack_plugin_common import (OPENSTACK_ID_PROPERTY,
24+
from openstack_plugin_common import (OPENSTACK_AZ_PROPERTY,
25+
OPENSTACK_ID_PROPERTY,
2526
OPENSTACK_TYPE_PROPERTY,
2627
OPENSTACK_NAME_PROPERTY,
2728
OPENSTACK_RESOURCE_PROPERTY)
@@ -93,6 +94,7 @@ def test_create_use_existing(self):
9394
existing_volume_m = mock.Mock()
9495
existing_volume_m.id = volume_id
9596
existing_volume_m.status = volume.VOLUME_STATUS_AVAILABLE
97+
existing_volume_m.availability_zone = 'az'
9698
cinder_client_m = mock.Mock()
9799
cinder_client_m.volumes = mock.Mock()
98100
cinder_client_m.volumes.create = mock.Mock()
@@ -112,6 +114,9 @@ def test_create_use_existing(self):
112114
self.assertEqual(
113115
volume.VOLUME_OPENSTACK_TYPE,
114116
ctx_m.instance.runtime_properties[OPENSTACK_TYPE_PROPERTY])
117+
self.assertEqual(
118+
ctx_m.instance.runtime_properties[OPENSTACK_AZ_PROPERTY],
119+
'az')
115120
self.assertTrue(
116121
ctx_m.instance.runtime_properties[OPENSTACK_RESOURCE_PROPERTY]
117122
)

cinder_plugin/volume.py

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,28 @@
4747
DEVICE_NAME_PROPERTY = 'device_name'
4848

4949
VOLUME_OPENSTACK_TYPE = 'volume'
50+
VOLUME_OPENSTACK_ID_KEY = 'name'
5051

5152
RUNTIME_PROPERTIES_KEYS = COMMON_RUNTIME_PROPERTIES_KEYS
5253

5354

55+
def _set_volume_runtime_properties(volume):
56+
try:
57+
ctx.instance.runtime_properties[OPENSTACK_AZ_PROPERTY] = \
58+
volume.availability_zone
59+
except AttributeError:
60+
ctx.logger.error('Volume availability_zone not found.')
61+
62+
5463
@operation
5564
@with_cinder_client
5665
def create(cinder_client, status_attempts, status_timeout, args, **kwargs):
5766

58-
if use_external_resource(ctx, cinder_client, VOLUME_OPENSTACK_TYPE,
59-
'name'):
67+
external_volume = use_external_resource(
68+
ctx, cinder_client, VOLUME_OPENSTACK_TYPE, VOLUME_OPENSTACK_ID_KEY)
69+
70+
if external_volume:
71+
_set_volume_runtime_properties(external_volume)
6072
return
6173

6274
volume_dict = create_object_dict(ctx, VOLUME_OPENSTACK_TYPE, args, {})
@@ -68,15 +80,14 @@ def create(cinder_client, status_attempts, status_timeout, args, **kwargs):
6880
ctx.instance.runtime_properties[OPENSTACK_TYPE_PROPERTY] = \
6981
VOLUME_OPENSTACK_TYPE
7082
ctx.instance.runtime_properties[OPENSTACK_NAME_PROPERTY] = \
71-
volume_dict['name']
83+
volume_dict[VOLUME_OPENSTACK_ID_KEY]
7284
wait_until_status(cinder_client=cinder_client,
7385
volume_id=v.id,
7486
status=VOLUME_STATUS_AVAILABLE,
7587
num_tries=status_attempts,
7688
timeout=status_timeout,
7789
)
78-
ctx.instance.runtime_properties[OPENSTACK_AZ_PROPERTY] = \
79-
v.availability_zone
90+
_set_volume_runtime_properties(v)
8091

8192

8293
def _delete_snapshot(cinder_client, search_opts):
@@ -115,8 +126,8 @@ def _delete_backup(cinder_client, search_opts):
115126
return
116127

117128
for backup in backups:
118-
if search_opts.get('name'):
119-
if backup.name != search_opts['name']:
129+
if search_opts.get(VOLUME_OPENSTACK_ID_KEY):
130+
if backup.name != search_opts[VOLUME_OPENSTACK_ID_KEY]:
120131
continue
121132
ctx.logger.debug("Check backup before delete: {}:{} with state {}"
122133
.format(backup.id, backup.name, backup.status))
@@ -131,8 +142,8 @@ def _delete_backup(cinder_client, search_opts):
131142
for backup in backups:
132143
ctx.logger.debug("Check backup after delete: {}:{} with state {}"
133144
.format(backup.id, backup.name, backup.status))
134-
if search_opts.get('name'):
135-
if backup.name == search_opts['name']:
145+
if search_opts.get(VOLUME_OPENSTACK_ID_KEY):
146+
if backup.name == search_opts[VOLUME_OPENSTACK_ID_KEY]:
136147
return ctx.operation.retry(
137148
message='{} is still alive'.format(backup.name),
138149
retry_after=30)
@@ -214,7 +225,7 @@ def snapshot_apply(cinder_client, **kwargs):
214225
ctx.logger.info("Backup apply {} to {}".format(backup_name, volume_id))
215226
search_opts = {
216227
'volume_id': volume_id,
217-
'name': backup_name
228+
VOLUME_OPENSTACK_ID_KEY: backup_name
218229
}
219230

220231
backups = cinder_client.backups.list(
@@ -245,7 +256,7 @@ def snapshot_delete(cinder_client, **kwargs):
245256
# search snaphot for delete
246257
search_opts = {
247258
'volume_id': volume_id,
248-
'name': backup_name
259+
VOLUME_OPENSTACK_ID_KEY: backup_name
249260
}
250261
_delete_backup(cinder_client, search_opts)
251262
else:
@@ -263,7 +274,7 @@ def snapshot_delete(cinder_client, **kwargs):
263274
@with_cinder_client
264275
def creation_validation(cinder_client, **kwargs):
265276
validate_resource(ctx, cinder_client, VOLUME_OPENSTACK_TYPE,
266-
'name')
277+
VOLUME_OPENSTACK_ID_KEY)
267278

268279

269280
@operation

nova_plugin/server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,15 +226,15 @@ def _handle_boot_volume(server, ctx):
226226
if boot_volume:
227227
boot_volume_id = boot_volume.runtime_properties[OPENSTACK_ID_PROPERTY]
228228
ctx.logger.info('boot_volume_id: {0}'.format(boot_volume_id))
229-
az = boot_volume.runtime_properties[OPENSTACK_AZ_PROPERTY]
230229
# If a block device mapping already exists we shouldn't overwrite it
231230
# completely
232231
bdm = server.setdefault('block_device_mapping', {})
233232
bdm['vda'] = '{0}:::0'.format(boot_volume_id)
234233
# Some nova configurations allow cross-az server-volume connections, so
235234
# we can't treat that as an error.
236235
if not server.get('availability_zone'):
237-
server['availability_zone'] = az
236+
server['availability_zone'] = \
237+
boot_volume.runtime_properties[OPENSTACK_AZ_PROPERTY]
238238

239239

240240
@operation

plugin.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
plugins:
66
openstack:
77
executor: central_deployment_agent
8-
source: https://github.com/cloudify-cosmo/cloudify-openstack-plugin/archive/2.9.5.zip
8+
source: https://github.com/cloudify-cosmo/cloudify-openstack-plugin/archive/2.9.6.zip
99
package_name: cloudify-openstack-plugin
10-
package_version: '2.9.5'
10+
package_version: '2.9.6'
1111

1212
data_types:
1313
cloudify.openstack.types.custom_configuration:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
setup(
2020
zip_safe=True,
2121
name='cloudify-openstack-plugin',
22-
version='2.9.5',
22+
version='2.9.6',
2323
author='Cloudify',
2424
author_email='hello@cloudify.co',
2525
packages=[

tox.ini

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@ commands =
2424
--cover-package=openstack_plugin_common openstack_plugin_common/tests \
2525
--with-xunit --xunit-file=nosetests.xml
2626

27-
[testenv:docs]
28-
changedir=docs
29-
deps =
30-
git+https://github.com/cloudify-cosmo/sphinxify.git@initial-work
31-
commands =
32-
sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html
33-
3427
[testenv:flake8]
3528
deps =
3629
flake8

0 commit comments

Comments
 (0)