def main(args=None): # configure core services CoreServices.setup('infrared.cfg') # Init Managers plugin_manager = CoreServices.plugins_manager() specs_manager = api.SpecManager() specs_manager.register_spec( WorkspaceManagerSpec('workspace', description="Workspace manager. " "Allows to create and use an " "isolated environment for plugins " "execution.")) specs_manager.register_spec( PluginManagerSpec('plugin', plugin_manager=plugin_manager, description="Plugin management")) specs_manager.register_spec( SSHSpec( 'ssh', description="Interactive ssh session to node from inventory.")) # register all plugins for plugin in plugin_manager.PLUGINS_DICT.values(): specs_manager.register_spec(api.InfraredPluginsSpec(plugin)) return specs_manager.run_specs(args) or 0
def main(args=None): CoreServices.setup() # inject ansible config file CoreServices.ansible_config_manager().inject_config() specs_manager = api.SpecManager() # Init Managers specs_manager.register_spec( WorkspaceManagerSpec('workspace', description="Workspace manager. " "Allows to create and use an " "isolated environment for plugins " "execution.")) specs_manager.register_spec( PluginManagerSpec('plugin', description="Plugin management")) specs_manager.register_spec( SSHSpec('ssh', description="Interactive ssh session to node from inventory.")) # register all plugins for plugin in CoreServices.plugins_manager().PLUGINS_DICT.values(): specs_manager.register_spec(api.InfraredPluginsSpec(plugin)) argcomplete.autocomplete(specs_manager.parser) return specs_manager.run_specs(args) or 0
def main(args=None): CoreServices.setup() # inject existing libraries. # because of that all the ansible modules should be imported after that CoreServices.dependency_manager().inject_libraries() specs_manager = api.SpecManager() # Init Managers specs_manager.register_spec( WorkspaceManagerSpec('workspace', description="Workspace manager. " "Allows to create and use an " "isolated environment for plugins " "execution.")) specs_manager.register_spec( PluginManagerSpec('plugin', description="Plugin management")) specs_manager.register_spec( SSHSpec('ssh', description="Interactive ssh session to node from inventory.")) # register all plugins for plugin in CoreServices.plugins_manager().PLUGINS_DICT.values(): specs_manager.register_spec(api.InfraredPluginsSpec(plugin)) argcomplete.autocomplete(specs_manager.parser) return specs_manager.run_specs(args) or 0
def main(args=None): # configure core services CoreServices.setup('infrared.cfg') # Init Managers plugin_manager = CoreServices.plugins_manager() specs_manager = api.SpecManager() specs_manager.register_spec( WorkspaceManagerSpec('workspace', description="Workspace manager. " "Allows to create and use an " "isolated environment for plugins " "execution.")) specs_manager.register_spec( PluginManagerSpec('plugin', plugin_manager=plugin_manager, description="Plugin management")) specs_manager.register_spec( SSHSpec('ssh', description="Interactive ssh session to node from inventory.")) # register all plugins for plugin in plugin_manager.PLUGINS_DICT.values(): specs_manager.register_spec(api.InfraredPluginsSpec(plugin)) return specs_manager.run_specs(args) or 0
def plugin_manager_helper(plugins_conf_dict=None): if plugins_conf_dict is None: plugins_conf_dict = {} plugins_conf_dict.update(SUPPORTED_TYPES_DICT) with lp_file.open(mode='w') as fp: config = ConfigParser.ConfigParser() for section, section_data in plugins_conf_dict.items(): config.add_section(section) for option, value in section_data.items(): config.set(section, option, value) config.write(fp) # replace core service with or test service # dependency manager will live in the temp folder # so we can keep it unmocked. CoreServices.register_service( ServiceName.DEPENDENCY_MANAGER, PluginDependencyManager(os.path.join(lp_file.dirname, ".library"))) CoreServices.register_service( ServiceName.PLUGINS_MANAGER, InfraredPluginManager(lp_file.strpath, CoreServices.dependency_manager(), os.path.join(lp_file.dirname, "plugins"))) return CoreServices.plugins_manager()
def main(args=None): CoreServices.setup() # inject existing libraries. # because of that all the ansible modules should be imported after that CoreServices.dependency_manager().inject_libraries() specs_manager = api.SpecManager() # Init Managers specs_manager.register_spec( WorkspaceManagerSpec('workspace', description="Workspace manager. " "Allows to create and use an " "isolated environment for plugins " "execution.")) specs_manager.register_spec( PluginManagerSpec('plugin', description="Plugin management")) specs_manager.register_spec( SSHSpec( 'ssh', description="Interactive ssh session to node from inventory.")) # register all plugins for plugin in CoreServices.plugins_manager().PLUGINS_DICT.values(): specs_manager.register_spec(api.InfraredPluginsSpec(plugin)) argcomplete.autocomplete(specs_manager.parser) return specs_manager.run_specs(args) or 0
def plugin_manager_helper(plugins_conf_dict=None): if plugins_conf_dict is None: plugins_conf_dict = {} plugins_conf_dict.update(SUPPORTED_TYPES_DICT) with lp_file.open(mode='w') as fp: config = ConfigParser.ConfigParser() for section, section_data in plugins_conf_dict.items(): config.add_section(section) for option, value in section_data.items(): config.set(section, option, value) config.write(fp) # replace core service with or test service # dependency manager will live in the temp folder # so we can keep it unmocked. CoreServices.register_service( ServiceName.DEPENDENCY_MANAGER, PluginDependencyManager( os.path.join(lp_file.dirname, ".library"))) CoreServices.register_service( ServiceName.PLUGINS_MANAGER, InfraredPluginManager( lp_file.strpath, CoreServices.dependency_manager(), os.path.join(lp_file.dirname, "plugins"))) return CoreServices.plugins_manager()
def test_infrared_home_dir(infrared_home): test_settings = CoreSettings() test_settings.install_plugin_at_start = False CoreServices.setup(test_settings) assert os.path.isdir(infrared_home) assert os.path.isdir(os.path.join(infrared_home, '.workspaces')) assert os.path.isdir(os.path.join(infrared_home, '.library')) assert os.path.isfile(os.path.join(infrared_home, '.plugins.ini')) assert os.path.isdir(os.path.join(infrared_home, 'plugins')) assert CoreServices.workspace_manager().workspace_dir == os.path.join( infrared_home, '.workspaces') assert CoreServices.plugins_manager().config_file == os.path.join( infrared_home, '.plugins.ini') assert CoreServices.plugins_manager().plugins_dir == os.path.join( infrared_home, 'plugins')
def plugin_list(**kwargs): """Return plugins names list""" plugin_manager = CoreServices.plugins_manager() installed_plugins = plugin_manager.get_installed_plugins() completions = [] for ptype, plugin in installed_plugins.iteritems(): completions.extend(plugin.keys()) return completions
def plugin_list(**kwargs): """Return plugins names list""" plugin_manager = CoreServices.plugins_manager() installed_plugins = plugin_manager.get_installed_plugins() completions = [] for ptype, plugin in installed_plugins.items(): completions.extend(plugin.keys()) return completions
def test_infrared_home_dir(infrared_home): os.environ['ANSIBLE_CONFIG'] = os.path.join(infrared_home, 'ansible.cfg') test_settings = CoreSettings() test_settings.install_plugin_at_start = False CoreServices.setup(test_settings) assert os.path.isdir(infrared_home) assert os.path.isdir(os.path.join(infrared_home, '.workspaces')) assert os.path.isfile(os.path.join(infrared_home, '.plugins.ini')) assert os.path.isdir(os.path.join(infrared_home, 'plugins')) assert os.path.isfile(os.path.join(infrared_home, 'ansible.cfg')) assert CoreServices.workspace_manager().workspace_dir == os.path.join( infrared_home, '.workspaces') assert CoreServices.plugins_manager().config_file == os.path.join( infrared_home, '.plugins.ini') assert CoreServices.plugins_manager().plugins_dir == os.path.join( infrared_home, 'plugins') assert CoreServices.ansible_config_manager( ).ansible_config_path == os.path.join(infrared_home, 'ansible.cfg')
def test_infrared_home_dir(infrared_home): os.environ['ANSIBLE_CONFIG'] = os.path.join(infrared_home, 'ansible.cfg') test_settings = CoreSettings() test_settings.install_plugin_at_start = False CoreServices.setup(test_settings) assert os.path.isdir(infrared_home) assert os.path.isdir(os.path.join(infrared_home, '.workspaces')) assert os.path.isfile(os.path.join(infrared_home, '.plugins.ini')) assert os.path.isdir(os.path.join(infrared_home, 'plugins')) assert os.path.isfile(os.path.join(infrared_home, 'ansible.cfg')) assert CoreServices.workspace_manager().workspace_dir == os.path.join( infrared_home, '.workspaces') assert CoreServices.plugins_manager().config_file == os.path.join( infrared_home, '.plugins.ini') assert CoreServices.plugins_manager().plugins_dir == os.path.join( infrared_home, 'plugins') assert CoreServices.ansible_config_manager().ansible_config_path == os.path.join( infrared_home, 'ansible.cfg')
def plugin_manager_helper(plugins_conf_dict=None): if plugins_conf_dict is None: plugins_conf_dict = {} plugins_conf_dict.update(SUPPORTED_TYPES_DICT) with lp_file.open(mode='w') as fp: config = ConfigParser.ConfigParser() for section, section_data in plugins_conf_dict.items(): config.add_section(section) for option, value in section_data.items(): config.set(section, option, value) config.write(fp) # replace core service with or test service CoreServices.register_service(ServiceName.PLUGINS_MANAGER, InfraredPluginManager(lp_file.strpath)) return CoreServices.plugins_manager()
def __init__(self, name, *args, **kwargs): super(PluginManagerSpec, self).__init__(name, *args, **kwargs) self.plugin_manager = CoreServices.plugins_manager()