def test_start_and_stop_with_no_gears(self): ariane_connector = ArianeConnector(self.config) injector_ui_procos_entity_id = ariane_connector.injector_ui_procos_entity.id self.assertIsNotNone(InjectorUITreeService.find_ui_tree_entity(injector_ui_procos_entity_id)) ariane_connector.stop() test_injector_service = InjectorService(self.rbmq_args) self.assertIsNone(InjectorUITreeService.find_ui_tree_entity(injector_ui_procos_entity_id)) test_injector_service.stop()
def test_start_and_stop_with_one_gear(self): ariane_connector = ArianeConnector(self.config) injector_ui_procos_entity_id = ariane_connector.injector_ui_procos_entity.id self.assertIsNotNone(InjectorUITreeService.find_ui_tree_entity(injector_ui_procos_entity_id)) gear = InjectorGearSkeleton.start(gear_id='ariane.community.plugin.procos.gears.cache.localhost', gear_name='procos@localhost', gear_description='Ariane remote injector for localhost', gear_admin_queue='ariane.community.plugin.procos.gears.cache.localhost', running=False).proxy() self.assertTrue(gear.cache(running=True).get()) ariane_connector.stop() test_injector_service = InjectorService(self.rbmq_args) self.assertIsNotNone(InjectorUITreeService.find_ui_tree_entity(injector_ui_procos_entity_id)) test_injector_service.stop()
def __init__(self, docker_config): self.ready = False rest_args = { 'type': 'REST', 'base_url': docker_config.rest_base_url, 'user': docker_config.rest_user, 'password': docker_config.rest_password } client_properties = { 'product': 'Ariane', 'information': 'Ariane Plugin Docker - Map your Docker containers interaction and more ...', 'ariane.pgurl': 'ssh://' + socket.gethostname() + "/$[/usr/local/bin/adocker {start|stop}]", 'ariane.osi': socket.gethostname(), 'ariane.otm': 'AROps', 'ariane.app': 'Ariane Plugin Docker', 'ariane.cmp': 'echinopsii', 'ariane.pid': os.getpid() } nats_args = { 'type': DriverFactory.DRIVER_NATS, 'user': docker_config.nats_user, 'password': docker_config.nats_password, 'host': docker_config.nats_host, 'port': docker_config.nats_port, 'client_properties': client_properties } rbmq_args = { 'type': 'RBMQ', 'user': docker_config.rbmq_user, 'password': docker_config.rbmq_password, 'host': docker_config.rbmq_host, 'port': docker_config.rbmq_port, 'vhost': docker_config.rbmq_vhost, 'client_properties': client_properties } self.gears_registry_cache_id = 'ariane.community.plugin.docker.gears.cache' docker_gears_registry_conf = { 'registry.name': 'Ariane Docker plugin gears registry', 'registry.cache.id': self.gears_registry_cache_id, 'registry.cache.name': 'Ariane Docker plugin gears cache', 'cache.mgr.name': 'ARIANE_PLUGIN_DOCKER_GEARS_CACHE_MGR' } self.components_registry_cache_id = 'ariane.community.plugin.docker.components.cache' docker_components_registry_conf = { 'registry.name': 'Ariane Docker plugin components registry', 'registry.cache.id': self.components_registry_cache_id, 'registry.cache.name': 'Ariane Docker plugin components cache', 'cache.mgr.name': 'ARIANE_PLUGIN_DOCKER_COMPONENTS_CACHE_MGR' } no_error = True DirectoryService(rest_args) # Test Directory Service try: LocationService.get_locations() except Exception as e: LOGGER.error("Problem while initializing Ariane directory service.") LOGGER.error(e.__str__()) no_error = False if no_error: if docker_config.mapping_driver_type == DriverFactory.DRIVER_RBMQ: LOGGER.info("Starting Mapping Service through RabbitMQ") MappingService(rbmq_args) elif docker_config.mapping_driver_type == DriverFactory.DRIVER_NATS: LOGGER.info("Starting Mapping Service through NATS") MappingService(nats_args) else: LOGGER.info("Starting Mapping Service through REST") MappingService(rest_args) # Open session and Test Mapping Service try: SessionService.open_session("ArianeDocker_test" + socket.gethostname()) SessionService.close_session() except Exception as e: LOGGER.error("Problem while initializing Ariane mapping service.") LOGGER.error(e.__str__()) no_error = False if no_error: try: if docker_config.injector_driver_type == DriverFactory.DRIVER_RBMQ: LOGGER.info("Starting Injector Service through RabbitMQ") self.injector_service = InjectorService( driver_args=rbmq_args, gears_registry_args=docker_gears_registry_conf, components_registry_args=docker_components_registry_conf ) elif docker_config.injector_driver_type == DriverFactory.DRIVER_NATS: LOGGER.info("Starting Injector Service through NATS") self.injector_service = InjectorService( driver_args=nats_args, gears_registry_args=docker_gears_registry_conf, components_registry_args=docker_components_registry_conf ) except Exception as e: LOGGER.error("Problem while initializing Ariane injector service.") LOGGER.error(e.__str__()) no_error = False if no_error: # Register UI entity if needed (and so test) self.injector_ui_mapping_entity = InjectorUITreeService.find_ui_tree_entity('mappingDir') if self.injector_ui_mapping_entity is None: self.injector_ui_mapping_entity = InjectorUITreeEntity(uitid="mappingDir", value="Mapping", uitype=InjectorUITreeEntity.entity_dir_type) self.injector_ui_mapping_entity.save() self.injector_ui_system_entity = InjectorUITreeEntity(uitid="systemDir", value="System", uitype=InjectorUITreeEntity.entity_dir_type, context_address="", description="", parent_id=self.injector_ui_mapping_entity.id, display_roles=["sysreviewer"], display_permissions=["injMapSysDocker:display"]) self.injector_ui_system_entity.save() self.injector_ui_procos_entity = InjectorUITreeEntity(uitid="docker", value="Docker", uitype=InjectorUITreeEntity.entity_leaf_type, context_address= "/ariane/views/injectors/external.jsf?id=docker", description="Docker injector", icon="icon-docker-injector", parent_id=self.injector_ui_system_entity.id, display_roles=["sysadmin", "sysreviewer"], display_permissions=["injMapSysDocker:display"], other_actions_roles={"action": ["sysadmin"]}, other_actions_perms={"action": ["injMapSysDocker:action"]}, remote_injector_tree_entity_gears_cache_id= self.gears_registry_cache_id, remote_injector_tree_entity_components_cache_id= self.components_registry_cache_id) self.injector_ui_procos_entity.save() self.ready = True