Merge "Add info about upgrade to deployment_info"
This commit is contained in:
commit
0c040170f9
|
@ -18,7 +18,21 @@ import os
|
|||
|
||||
from nailgun import extensions
|
||||
|
||||
from . import handlers
|
||||
from cluster_upgrade import handlers
|
||||
|
||||
|
||||
class UpgradePipeline(extensions.BasePipeline):
|
||||
@classmethod
|
||||
def process_deployment_for_cluster(cls, cluster, cluster_data):
|
||||
from cluster_upgrade.objects.relations import UpgradeRelationObject
|
||||
|
||||
relation = UpgradeRelationObject.get_cluster_relation(cluster.id)
|
||||
cluster_data['upgrade'] = {
|
||||
'relation_info': {
|
||||
'orig_cluster_id': relation.orig_cluster_id,
|
||||
'seed_cluster_id': relation.seed_cluster_id,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class ClusterUpgradeExtension(extensions.BaseExtension):
|
||||
|
@ -26,6 +40,10 @@ class ClusterUpgradeExtension(extensions.BaseExtension):
|
|||
version = '0.0.1'
|
||||
description = "Cluster Upgrade Extension"
|
||||
|
||||
data_pipelines = [
|
||||
UpgradePipeline,
|
||||
]
|
||||
|
||||
urls = [
|
||||
{'uri': r'/clusters/(?P<cluster_id>\d+)/upgrade/clone/?$',
|
||||
'handler': handlers.ClusterUpgradeCloneHandler},
|
||||
|
|
|
@ -19,6 +19,7 @@ import six
|
|||
|
||||
from nailgun.api.v1.handlers import base
|
||||
from nailgun import errors
|
||||
from nailgun.extensions.manager import update_extensions_for_object
|
||||
from nailgun import objects
|
||||
from nailgun.task import manager
|
||||
|
||||
|
@ -61,6 +62,7 @@ class ClusterUpgradeCloneHandler(base.BaseHandler):
|
|||
raise errors.InvalidData("Network changes during upgrade"
|
||||
" is not supported.")
|
||||
|
||||
update_extensions_for_object(new_cluster.cluster, ['cluster_upgrade'])
|
||||
return new_cluster.to_dict()
|
||||
|
||||
|
||||
|
|
|
@ -15,10 +15,16 @@
|
|||
# under the License.
|
||||
|
||||
import mock
|
||||
from nailgun.test.base import BaseTestCase
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
from .. import extension
|
||||
from ..objects import relations
|
||||
from nailgun import objects
|
||||
from nailgun.orchestrator.deployment_serializers import DeploymentLCMSerializer
|
||||
from nailgun.test.base import BaseTestCase
|
||||
from nailgun.utils import reverse
|
||||
|
||||
from cluster_upgrade import extension
|
||||
from cluster_upgrade.objects import relations
|
||||
from cluster_upgrade.tests import base
|
||||
|
||||
|
||||
class TestExtension(BaseTestCase):
|
||||
|
@ -27,3 +33,34 @@ class TestExtension(BaseTestCase):
|
|||
cluster = mock.Mock(id=42)
|
||||
extension.ClusterUpgradeExtension.on_cluster_delete(cluster)
|
||||
mock_on_cluster_delete.assert_called_once_with(42)
|
||||
|
||||
|
||||
class TestPipeline(base.BaseCloneClusterTest):
|
||||
def setUp(self):
|
||||
super(TestPipeline, self).setUp()
|
||||
|
||||
resp = self.app.post(
|
||||
reverse("ClusterUpgradeCloneHandler",
|
||||
kwargs={"cluster_id": self.src_cluster_db.id}),
|
||||
jsonutils.dumps(self.data),
|
||||
headers=self.default_headers
|
||||
).json_body
|
||||
|
||||
self.dst_cluster_db = objects.Cluster.get_by_uid(resp['id'])
|
||||
|
||||
def test_upgrade_info(self):
|
||||
deployment_info = DeploymentLCMSerializer().serialize(
|
||||
self.dst_cluster_db, []
|
||||
)
|
||||
|
||||
expected = {
|
||||
'relation_info': {
|
||||
'orig_cluster_id': self.src_cluster_db.id,
|
||||
'seed_cluster_id': self.dst_cluster_db.id,
|
||||
}
|
||||
}
|
||||
|
||||
self.assertEqual(
|
||||
deployment_info['common']['upgrade'],
|
||||
expected,
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue