Fixed OrchestratorInfo handlers for LCM

The LCM serializers should be used for all releases
that are LCM ready.
Also the plugin hooks was removed in LCM and
the hooks can not be retrieved. The tasks graph API
can be used to get information about tasks from plugins.

DocImpact
Closes-Bug: 1569778

Change-Id: I037f79c5b4f51dd40bf05d7a00bde9a38c4b4454
(cherry picked from commit 87fe57d055)
This commit is contained in:
Bulat Gaifullin 2016-04-13 13:15:28 +03:00
parent ca4afc6df9
commit 3523ba6092
3 changed files with 67 additions and 10 deletions

View File

@ -153,6 +153,10 @@ class DefaultProvisioningInfo(DefaultOrchestratorInfo):
class DefaultDeploymentInfo(DefaultOrchestratorInfo):
def _serialize(self, cluster, nodes):
if objects.Release.is_lcm_supported(cluster.release):
return deployment_serializers.serialize_for_lcm(
cluster, nodes, ignore_customized=True
)
graph = orchestrator_graph.AstuteGraph(cluster)
return deployment_serializers.serialize(
graph, cluster, nodes, ignore_customized=True)
@ -164,6 +168,10 @@ class DefaultDeploymentInfo(DefaultOrchestratorInfo):
class DefaultPrePluginsHooksInfo(DefaultOrchestratorInfo):
def _serialize(self, cluster, nodes):
if objects.Release.is_lcm_supported(cluster.release):
raise self.http(
405, msg="The plugin hooks are not supported anymore."
)
graph = orchestrator_graph.AstuteGraph(cluster)
return pre_deployment_serialize(graph, cluster, nodes)
@ -174,6 +182,10 @@ class DefaultPrePluginsHooksInfo(DefaultOrchestratorInfo):
class DefaultPostPluginsHooksInfo(DefaultOrchestratorInfo):
def _serialize(self, cluster, nodes):
if objects.Release.is_lcm_supported(cluster.release):
raise self.http(
405, msg="The plugin hooks are not supported anymore."
)
graph = orchestrator_graph.AstuteGraph(cluster)
return post_deployment_serialize(graph, cluster, nodes)

View File

@ -66,14 +66,33 @@ class TestDefaultOrchestratorInfoHandlers(BaseIntegrationTest):
self.assertTrue(self.cluster.is_customized)
self.datadiff(get_info(), facts)
def test_default_deployment_handler(self):
def check_default_deployment_handler(self, release_version):
self.env.create(
nodes_kwargs=[
{'roles': ['controller'], 'pending_addition': True},
{'roles': ['compute'], 'pending_addition': True},
{'roles': ['cinder'], 'pending_addition': True}],
release_kwargs={
'version': release_version,
'operating_system': consts.RELEASE_OS.ubuntu
}
)
cluster = self.env.clusters[-1]
resp = self.app.get(
reverse('DefaultDeploymentInfo',
kwargs={'cluster_id': self.cluster.id}),
kwargs={'cluster_id': cluster.id}),
headers=self.default_headers)
self.assertEqual(resp.status_code, 200)
self.assertEqual(3, len(resp.json_body))
# for lcm the deployment info will contain master node too
# and we check only that nodes are included to result
expected_node_uids = {n.uid for n in cluster.nodes}
actual_node_uids = {n['uid'] for n in resp.json_body}
self.assertTrue(expected_node_uids.issubset(actual_node_uids))
def test_default_deployment_handler(self):
for release_ver in ('newton-10.0', 'mitaka-9.0', 'liberty-8.0'):
self.check_default_deployment_handler(release_ver)
def test_default_provisioning_handler(self):
resp = self.app.get(

View File

@ -18,6 +18,7 @@ import mock
from oslo_serialization import jsonutils
import yaml
from nailgun import consts
from nailgun import objects
from nailgun.plugins import adapters
from nailgun.test import base
@ -91,14 +92,18 @@ class BasePluginTest(base.BaseIntegrationTest):
resp = self.app.get(
base.reverse('DefaultPrePluginsHooksInfo',
{'cluster_id': cluster.id}),
headers=self.default_headers)
headers=self.default_headers,
expect_errors=True
)
return resp
def get_post_hooks(self, cluster):
resp = self.app.get(
base.reverse('DefaultPostPluginsHooksInfo',
{'cluster_id': cluster.id}),
headers=self.default_headers)
headers=self.default_headers,
expect_errors=True
)
return resp
def sync_plugins(self, params=None, expect_errors=False):
@ -360,7 +365,8 @@ class TestPrePostHooks(BasePluginTest):
objects.Plugin.get_by_uid(resp.json['id']))
self.cluster = self.create_cluster([
{'roles': ['controller'], 'pending_addition': True},
{'roles': ['compute'], 'pending_addition': True}])
{'roles': ['compute'], 'pending_addition': True}]
)
objects.Cluster.prepare_for_deployment(self.cluster)
self.enable_plugin(
@ -371,8 +377,10 @@ class TestPrePostHooks(BasePluginTest):
self._requests_mock.stop()
super(TestPrePostHooks, self).tearDown()
def test_generate_pre_hooks(self):
tasks = self.get_pre_hooks(self.cluster).json
def test_generate_pre_hooks_for_legacy_env(self):
resp = self.get_pre_hooks(self.cluster)
self.assertEqual(200, resp.status_code)
tasks = resp.json
plugins_tasks = [t for t in tasks if t.get('diagnostic_name')]
upload_file = [t for t in plugins_tasks if t['type'] == 'upload_file']
rsync = [t for t in plugins_tasks if t['type'] == 'sync']
@ -390,8 +398,10 @@ class TestPrePostHooks(BasePluginTest):
if u'apt-get update' in t['parameters']['cmd']]
self.assertEqual(len(apt_update), 1)
def test_generate_post_hooks(self):
tasks = self.get_post_hooks(self.cluster).json
def test_generate_post_hooks_for_legacy_env(self):
resp = self.get_post_hooks(self.cluster)
self.assertEqual(200, resp.status_code)
tasks = resp.json
self.assertEqual(len(tasks), 1)
task = tasks[0]
controller_id = [n.uid for n in self.cluster.nodes
@ -399,6 +409,22 @@ class TestPrePostHooks(BasePluginTest):
self.assertEqual(controller_id, task['uids'])
self.assertEqual(task['diagnostic_name'], self.plugin.full_name)
def test_generate_hooks_is_not_supported_since_90(self):
self.env.create(
nodes_kwargs=[
{'roles': ['controller'], 'pending_addition': True},
{'roles': ['compute'], 'pending_addition': True},
{'roles': ['cinder'], 'pending_addition': True}],
release_kwargs={
'version': 'mitaka-9.0',
'operating_system': consts.RELEASE_OS.ubuntu
}
)
resp = self.get_pre_hooks(self.env.clusters[-1])
self.assertEqual(405, resp.status_code)
resp = self.get_post_hooks(self.env.clusters[-1])
self.assertEqual(405, resp.status_code)
class TestPluginValidation(BasePluginTest):