Browse files

Make HA Agent configuration use process_defintion_ids

  • Loading branch information...
1 parent 8e4f949 commit 4a781c3d88c606ca825b3bc0519458f4eb2f89c0 @oldpatricka oldpatricka committed Sep 26, 2012
Showing with 13 additions and 10 deletions.
  1. +3 −2 ion/agents/cei/high_availability_agent.py
  2. +10 −8 ion/agents/cei/test/test_haagent.py
View
5 ion/agents/cei/high_availability_agent.py
@@ -57,11 +57,12 @@ def on_init(self):
cfg = self.CFG.get_safe("highavailability")
pds = self.CFG.get_safe("highavailability.process_dispatchers", [])
- process_spec = self.CFG.get_safe("highavailability.process_spec")
+ process_definition_id = self.CFG.get_safe("highavailability.process_definition_id")
process_configuration = self.CFG.get_safe("highavailability.process_configuration")
# TODO: Allow other core class?
self.core = HighAvailabilityCore(cfg, ProcessDispatcherSimpleAPIClient,
- pds, process_spec, self.policy, parameters=policy_parameters,
+ pds, self.policy, process_definition_id=process_definition_id,
+ parameters=policy_parameters,
process_configuration=process_configuration)
self.policy_thread = looping_call(self.policy_interval, self.core.apply_policy)
View
18 ion/agents/cei/test/test_haagent.py
@@ -5,6 +5,7 @@
from nose.plugins.attrib import attr
from nose.plugins.skip import SkipTest
from mock import Mock
+from uuid import uuid4
from pyon.agent.simple_agent import SimpleResourceAgentClient
from pyon.event.event import EventSubscriber
@@ -17,7 +18,7 @@
from interface.services.icontainer_agent import ContainerAgentClient
from ion.agents.cei.high_availability_agent import HighAvailabilityAgentClient, ProcessDispatcherSimpleAPIClient
from interface.services.cei.iprocess_dispatcher_service import ProcessDispatcherServiceClient
-from interface.objects import ProcessStateEnum
+from interface.objects import ProcessStateEnum, ProcessDefinition
class FakeProcess(LocalContextMixin):
@@ -60,6 +61,13 @@ def setUp(self):
#self.pd_cli = ProcessDispatcherServiceClient(node=self.container.node)
self.pd_cli = ProcessDispatcherServiceClient(to_name="process_dispatcher")
+ self.process_definition_id = uuid4().hex
+ self.process_definition = ProcessDefinition(name='test', executable={
+ 'module': 'ion.agents.cei.test.test_haagent',
+ 'class': 'TestProcess'
+ })
+ self.pd_cli.create_process_definition(self.process_definition, self.process_definition_id)
+
self.resource_id = "haagent_1234"
self._haa_name = "high_availability_agent"
self._haa_config = {
@@ -71,13 +79,7 @@ def setUp(self):
'preserve_n': 0
}
},
- 'process_spec': {
- 'name': 'test',
- 'executable':{
- 'module': 'ion.agents.cei.test.test_haagent',
- 'class': 'TestProcess'
- }
- },
+ 'process_definition_id': self.process_definition_id,
"process_dispatchers": [
'process_dispatcher'
]

0 comments on commit 4a781c3

Please sign in to comment.