Engine support to cluster config
This adds engine level support to cluster config. Change-Id: Ic024f77230353f0e76f761d57bc358caff97fd41
This commit is contained in:
parent
3c4c1e16c6
commit
39ee23e820
|
@ -93,14 +93,14 @@ CLUSTER_ATTRS = (
|
|||
CLUSTER_DOMAIN, CLUSTER_PROJECT, CLUSTER_USER,
|
||||
CLUSTER_INIT_AT, CLUSTER_CREATED_AT, CLUSTER_UPDATED_AT,
|
||||
CLUSTER_STATUS, CLUSTER_STATUS_REASON, CLUSTER_TIMEOUT,
|
||||
CLUSTER_METADATA,
|
||||
CLUSTER_METADATA, CLUSTER_CONFIG,
|
||||
) = (
|
||||
'name', 'profile_id', 'desired_capacity',
|
||||
'min_size', 'max_size', 'id',
|
||||
'domain', 'project', 'user',
|
||||
'init_at', 'created_at', 'updated_at',
|
||||
'status', 'status_reason', 'timeout',
|
||||
'metadata',
|
||||
'metadata', 'config',
|
||||
)
|
||||
|
||||
CLUSTER_PARAMS = (
|
||||
|
|
|
@ -73,6 +73,7 @@ class Cluster(object):
|
|||
self.data = kwargs.get('data', {})
|
||||
self.metadata = kwargs.get('metadata') or {}
|
||||
self.dependents = kwargs.get('dependents') or {}
|
||||
self.config = kwargs.get('config') or {}
|
||||
|
||||
# rt is a dict for runtime data
|
||||
self.rt = {
|
||||
|
@ -128,6 +129,7 @@ class Cluster(object):
|
|||
'meta_data': self.metadata,
|
||||
'data': self.data,
|
||||
'dependents': self.dependents,
|
||||
'config': self.config,
|
||||
}
|
||||
|
||||
timestamp = timeutils.utcnow(True)
|
||||
|
@ -167,6 +169,7 @@ class Cluster(object):
|
|||
'data': obj.data,
|
||||
'metadata': obj.metadata,
|
||||
'dependents': obj.dependents,
|
||||
'config': obj.config,
|
||||
}
|
||||
|
||||
return cls(obj.name, obj.desired_capacity, obj.profile_id,
|
||||
|
|
|
@ -767,6 +767,7 @@ class EngineService(service.Service):
|
|||
'data': {},
|
||||
'metadata': req.metadata or {},
|
||||
'dependents': {},
|
||||
'config': req.config or {},
|
||||
'user': ctx.user,
|
||||
'project': ctx.project,
|
||||
'domain': ctx.domain,
|
||||
|
@ -834,6 +835,12 @@ class EngineService(service.Service):
|
|||
req.name != cluster.name):
|
||||
inputs['name'] = req.name
|
||||
|
||||
if (req.obj_attr_is_set(consts.CLUSTER_CONFIG) and
|
||||
req.config != cluster.config):
|
||||
# TODO(anyone): updating cluster config is a multiplexed operation
|
||||
# which have to be handled carefully.
|
||||
inputs['config'] = req.config
|
||||
|
||||
if req.obj_attr_is_set(consts.CLUSTER_PROFILE_ONLY):
|
||||
inputs['profile_only'] = req.profile_only
|
||||
|
||||
|
|
|
@ -145,6 +145,7 @@ class ClusterTest(base.SenlinTestCase):
|
|||
dict(name='C1', desired_capacity=3, profile_id='PROFILE_ID',
|
||||
min_size=0, max_size=-1, timeout=3600, metadata={},
|
||||
dependents={}, data={}, next_index=1, status='INIT',
|
||||
config={},
|
||||
status_reason='Initializing', user=self.ctx.user,
|
||||
project=self.ctx.project, domain=self.ctx.domain))
|
||||
mock_action.assert_called_once_with(
|
||||
|
@ -174,7 +175,8 @@ class ClusterTest(base.SenlinTestCase):
|
|||
mock_check.return_value = None
|
||||
mock_quota.return_value = None
|
||||
req = orco.ClusterCreateRequestBody(name='C1', profile_id='PROFILE',
|
||||
min_size=1, max_size=5)
|
||||
min_size=1, max_size=5,
|
||||
config={'k1': 'v1'})
|
||||
|
||||
# do it
|
||||
result = self.eng.cluster_create(self.ctx, req.obj_to_primitive())
|
||||
|
@ -187,6 +189,7 @@ class ClusterTest(base.SenlinTestCase):
|
|||
dict(name='C1', desired_capacity=1, profile_id='PROFILE_ID',
|
||||
min_size=1, max_size=5, timeout=3600, metadata={},
|
||||
dependents={}, data={}, next_index=1, status='INIT',
|
||||
config={'k1': 'v1'},
|
||||
status_reason='Initializing', user=self.ctx.user,
|
||||
project=self.ctx.project, domain=self.ctx.domain))
|
||||
mock_action.assert_called_once_with(
|
||||
|
@ -309,7 +312,8 @@ class ClusterTest(base.SenlinTestCase):
|
|||
mock_action.return_value = 'ACTION_ID'
|
||||
req = orco.ClusterUpdateRequest(identity='FAKE_ID', name='new_name',
|
||||
profile_id='NEW_PROFILE',
|
||||
metadata={'B': 'A'}, timeout=120)
|
||||
metadata={'B': 'A'}, timeout=120,
|
||||
config={'k1': 'v1'})
|
||||
|
||||
# do it
|
||||
result = self.eng.cluster_update(self.ctx, req.obj_to_primitive())
|
||||
|
@ -332,6 +336,9 @@ class ClusterTest(base.SenlinTestCase):
|
|||
},
|
||||
'timeout': 120,
|
||||
'name': 'new_name',
|
||||
'config': {
|
||||
'k1': 'v1',
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -62,6 +62,8 @@ class TestCluster(base.SenlinTestCase):
|
|||
self.assertEqual('Initializing', cluster.status_reason)
|
||||
self.assertEqual({}, cluster.data)
|
||||
self.assertEqual({}, cluster.metadata)
|
||||
self.assertEqual({}, cluster.dependents)
|
||||
self.assertEqual({}, cluster.config)
|
||||
self.assertEqual({'profile': None, 'nodes': [], 'policies': []},
|
||||
cluster.rt)
|
||||
|
||||
|
|
Loading…
Reference in New Issue