def __init__(self, *args, **kwargs): BaseContainerAgent.__init__(self, *args, **kwargs) self._is_started = False self._capabilities = [] # set container id and cc_agent name (as they are set in base class call) self.id = get_default_container_id() self.name = "cc_agent_%s" % self.id Container.instance = self from pyon.core import bootstrap bootstrap.container_instance = self log.debug("Container (sysname=%s) initializing ..." % bootstrap.get_sys_name()) # DatastoreManager - controls access to Datastores (both mock and couch backed) self.datastore_manager = DatastoreManager() self.datastore_manager.start() self._capabilities.append("DATASTORE_MANAGER") # Keep track of the overrides from the command-line, so they can trump app/rel file data self.spawn_args = kwargs # Instantiate Directory and self-register # Has the additional side effect of either # bootstrapping the configuration into the # directory or read the configuration based # in the value of the auto_bootstrap setting self.directory = Directory() # Create this Container's specific ExchangeManager instance self.ex_manager = ExchangeManager(self) # Create this Container's specific ProcManager instance self.proc_manager = ProcManager(self) # Create this Container's specific AppManager instance self.app_manager = AppManager(self) # File System - Interface to the OS File System, using correct path names and setups self.file_system = FileSystem(CFG) # Governance Controller - manages the governance related interceptors self.governance_controller = GovernanceController(self) # sFlow manager - controls sFlow stat emission self.sflow_manager = SFlowManager(self) # Coordinates the container start self._status = "INIT" # protection for when the container itself is used as a Process for clients self.container = self log.debug("Container initialized, OK.")
def __init__(self, *args, **kwargs): BaseContainerAgent.__init__(self, *args, **kwargs) self._is_started = False # set id and name (as they are set in base class call) self.id = string.replace('%s_%d' % (os.uname()[1], os.getpid()), ".", "_") self.name = "cc_agent_%s" % self.id Container.instance = self # TODO: Bug: Replacing CFG instance not work because references are already public. Update directly dict_merge(CFG, kwargs, inplace=True) from pyon.core import bootstrap bootstrap.container_instance = self bootstrap.assert_configuration(CFG) log.debug("Container (sysname=%s) initializing ..." % bootstrap.get_sys_name()) # Keep track of the overrides from the command-line, so they can trump app/rel file data self.spawn_args = kwargs # Load object and service registry etc. bootstrap_pyon() # Create this Container's specific ExchangeManager instance self.ex_manager = ExchangeManager(self) # Create this Container's specific ProcManager instance self.proc_manager = ProcManager(self) # Create this Container's specific AppManager instance self.app_manager = AppManager(self) # DatastoreManager - controls access to Datastores (both mock and couch backed) self.datastore_manager = DatastoreManager() # File System - Interface to the OS File System, using correct path names and setups self.file_system = FileSystem(CFG) # Governance Controller - manages the governance related interceptors self.governance_controller = GovernanceController(self) # sFlow manager - controls sFlow stat emission self.sflow_manager = SFlowManager(self) # Coordinates the container start self._is_started = False self._capabilities = [] self._status = "INIT" # protection for when the container itself is used as a Process for clients self.container = self log.debug("Container initialized, OK.")
def setUp(self): self.ex_manager = ExchangeManager(Mock()) self.ex_manager._transport = Mock(BaseTransport) # mock out _client, which is a property, to return a sentinel propmock = Mock() propmock.__get__ = Mock(return_value=sentinel.client) patcher = patch.object(ExchangeManager, '_client', propmock) patcher.start() self.addCleanup(patcher.stop)
def begin(self): self._active_queues = set() self._test_changes = {} self._queues_declared = [] # ordered list of queues declared self._queues = defaultdict(list) # queue name -> list of accesses from pyon.ion.exchange import ExchangeManager from pyon.util.containers import DotDict from pyon.core.bootstrap import CFG from mock import Mock containermock = Mock() containermock.resource_registry.find_resources.return_value = ([], None) self.ex_manager = ExchangeManager( containermock) # needs to be able to setattr self.ex_manager._nodes['priviledged'] = DotDict(client=DotDict( parameters=DotDict( host=CFG.get_safe('server.amqp.host', 'localhost'))))
def setUp(self): self.ex_manager = ExchangeManager(Mock()) self.pt = Mock(spec=BaseTransport) self.ex_manager.get_transport = Mock(return_value=self.pt) # set up some nodes self.ex_manager._nodes = {'primary': Mock(), 'priviledged': Mock()} # patch for setUp and test self.patch_cfg( 'pyon.ion.exchange.CFG', { 'container': { 'exchange': { 'auto_register': False } }, 'messaging': { 'server': {} } }) # start ex manager self.ex_manager.start()
def setUp(self): self.container = Mock() self.ex_manager = ExchangeManager(self.container) self.ex_manager._get_channel = Mock()
def setUp(self): self.ex_manager = ExchangeManager(Mock()) self.ex_manager._transport = Mock(BaseTransport) self.ex_manager._client = Mock()
def setUp(self): self.ex_manager = ExchangeManager(Mock()) self.ex_manager._nodes = MagicMock() self.ex_manager._nodes.get.return_value.client.parameters.host = "testhost" # stringifies so don't use sentinel self.ex_manager._ems_client = Mock()
def setUp(self): self.container = Mock() self.ex_manager = ExchangeManager(self.container) self.ex_manager.get_transport = Mock()
def __init__(self, *args, **kwargs): BaseContainerAgent.__init__(self, *args, **kwargs) self._is_started = False # set container id and cc_agent name (as they are set in base class call) self.id = get_default_container_id() self.name = "cc_agent_%s" % self.id self._capabilities = [] bootstrap.container_instance = self Container.instance = self log.debug("Container (sysname=%s) initializing ..." % bootstrap.get_sys_name()) # Keep track of the overrides from the command-line, so they can trump app/rel file data self.spawn_args = kwargs # DatastoreManager - controls access to Datastores (both mock and couch backed) self.datastore_manager = DatastoreManager() # TODO: Do not start a capability here. Symmetric start/stop self.datastore_manager.start() self._capabilities.append("DATASTORE_MANAGER") # Instantiate Directory self.directory = Directory() # internal router self.local_router = None # Create this Container's specific ExchangeManager instance self.ex_manager = ExchangeManager(self) # Create this Container's specific ProcManager instance self.proc_manager = ProcManager(self) # Create this Container's specific AppManager instance self.app_manager = AppManager(self) # File System - Interface to the OS File System, using correct path names and setups self.file_system = FileSystem(CFG) # Governance Controller - manages the governance related interceptors self.governance_controller = GovernanceController(self) # sFlow manager - controls sFlow stat emission self.sflow_manager = SFlowManager(self) # Coordinates the container start self._status = "INIT" # protection for when the container itself is used as a Process for clients self.container = self # publisher, initialized in start() self.event_pub = None # context-local storage self.context = LocalContextMixin() log.debug("Container initialized, OK.")