Skip to content

Commit

Permalink
Merge pull request #217 from Cloudify-PS/external_resource_in_runtime…
Browse files Browse the repository at this point in the history
…_properties

Mode use_external_resource sets resource data in runtime_properties
  • Loading branch information
EarthmanT authored Apr 1, 2018
2 parents 12d9fbd + 0016d6a commit 85629d4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ node_templates:
use_external_resource: true
resource_id: 'openstack_plugin_test_user'
openstack_config: *openstack_config

test_project:
type: cloudify.openstack.nodes.Project
properties:
use_external_resource: true
resource_id: 'openstack_plugin_test_project'
relationships:
openstack_config: *openstack_config
- type: cloudify.relationships.depends_on
target: test_user
Expand Down
6 changes: 5 additions & 1 deletion cinder_plugin/tests/test_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
from nova_plugin import server
from openstack_plugin_common import (OPENSTACK_ID_PROPERTY,
OPENSTACK_TYPE_PROPERTY,
OPENSTACK_NAME_PROPERTY)
OPENSTACK_NAME_PROPERTY,
OPENSTACK_RESOURCE_PROPERTY)


class TestCinderVolume(unittest.TestCase):
Expand Down Expand Up @@ -111,6 +112,9 @@ def test_create_use_existing(self):
self.assertEqual(
volume.VOLUME_OPENSTACK_TYPE,
ctx_m.instance.runtime_properties[OPENSTACK_TYPE_PROPERTY])
self.assertTrue(
ctx_m.instance.runtime_properties[OPENSTACK_RESOURCE_PROPERTY]
)

def test_delete(self):
volume_id = '00000000-0000-0000-0000-000000000000'
Expand Down
8 changes: 6 additions & 2 deletions nova_plugin/tests/test_host_aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
from openstack_plugin_common import (
OPENSTACK_ID_PROPERTY,
OPENSTACK_NAME_PROPERTY,
OPENSTACK_TYPE_PROPERTY
)
OPENSTACK_TYPE_PROPERTY,
OPENSTACK_RESOURCE_PROPERTY
)
from nova_plugin.host_aggregate import (
HOST_AGGREGATE_OPENSTACK_TYPE,
HOSTS_PROPERTY
Expand Down Expand Up @@ -229,6 +230,9 @@ def test_create_and_delete_external_resource(self, *_):
HOST_AGGREGATE_OPENSTACK_TYPE,
ctx.instance.runtime_properties[OPENSTACK_TYPE_PROPERTY]
)
self.assertTrue(
ctx.instance.runtime_properties[OPENSTACK_RESOURCE_PROPERTY]
)
nova_client.aggregates.create.assert_not_called()
nova_client.aggregates.add_host.assert_not_called()
nova_client.aggregates.set_metadata.assert_not_called()
Expand Down
4 changes: 4 additions & 0 deletions openstack_plugin_common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
OPENSTACK_ID_PROPERTY = 'external_id' # resource's openstack id
OPENSTACK_TYPE_PROPERTY = 'external_type' # resource's openstack type
OPENSTACK_NAME_PROPERTY = 'external_name' # resource's openstack name
OPENSTACK_RESOURCE_PROPERTY = 'external_resource' # resource's parameters
CONDITIONALLY_CREATED = 'conditionally_created' # resource was
# conditionally created
CONFIG_RUNTIME_PROPERTY = CONFIG_PROPERTY # openstack configuration
Expand All @@ -60,6 +61,7 @@
COMMON_RUNTIME_PROPERTIES_KEYS = [OPENSTACK_ID_PROPERTY,
OPENSTACK_TYPE_PROPERTY,
OPENSTACK_NAME_PROPERTY,
OPENSTACK_RESOURCE_PROPERTY,
CONDITIONALLY_CREATED]

MISSING_RESOURCE_MESSAGE = "Couldn't find a resource of " \
Expand Down Expand Up @@ -372,6 +374,8 @@ def use_external_resource(ctx, sugared_client, openstack_type,
ctx.instance.runtime_properties[OPENSTACK_ID_PROPERTY] = \
sugared_client.get_id_from_resource(resource)
ctx.instance.runtime_properties[OPENSTACK_TYPE_PROPERTY] = openstack_type
ctx.instance.runtime_properties[OPENSTACK_RESOURCE_PROPERTY] = \
resource if isinstance(resource, dict) else resource.to_dict()

from neutron_plugin.floatingip import FLOATINGIP_OPENSTACK_TYPE
# store openstack name runtime property, unless it's a floating IP type,
Expand Down

0 comments on commit 85629d4

Please sign in to comment.