def get_plugin(plugin_name, solace_api, *args, **kwargs): """ Returns a new plugin configured for the environment :param plugin_name: name of the plugun :param solace_api: a instance of SolaceAPI :param kwargs: :return: """ plugin = libsolace.plugin_registry(plugin_name, **kwargs) logger.info(args) return plugin(api=solace_api, *args, **kwargs)
def get_plugin(plugin_name, solace_api, *args, **kwargs): """ Returns a new plugin configured for the environment :param plugin_name: name of the plugun :param solace_api: a instance of SolaceAPI :param kwargs: :return: """ plugin = libsolace.plugin_registry(plugin_name, **kwargs) logging.info(args) return plugin(api=solace_api, *args, **kwargs)
def name(*args, **kwargs): """ Passes off work to the plugin as specified by NAMEHOOK in libsolace.yaml. The plugin MUST have a solve() method which accepts args and kwargs. see NamingStandard.py and ZoinksNamingStandard.py :rtype: str """ import libsolace.settingsloader as settings try: return libsolace.plugin_registry(settings.NAMEHOOK)().solve(*args, **kwargs) except Exception, e: logging.error("Unable to solve name of object, reason: %s %s" % (e.__class__, e.message)) raise
def name(*args, **kwargs): """ Passes off work to the plugin as specified by NAMEHOOK in libsolace.yaml. The plugin MUST have a solve() method which accepts args and kwargs. see NamingStandard.py and ZoinksNamingStandard.py :rtype: str """ from libsolace.settingsloader import settings try: return libsolace.plugin_registry(settings["NAMEHOOK"])().solve( *args, **kwargs) except Exception, e: logger.error("Unable to solve name of object, reason: %s %s" % (e.__class__, e.message)) raise
def manage(self, plugin_name, **kwargs): """ Gets a plugin, configures it, then allows direct communication with it. Plugins are passed the kwargs directly if any are specified. Example: >>> api = SolaceAPI("dev") >>> p1 = api.manage("NullPlugin") >>> p1.some_method("foo", bar="baz") (('foo',), {'bar': 'baz'}) >>> p2 = api.manage("NullPlugin", a="a") >>> p2.kwargs['a'] 'a' """ plugin = libsolace.plugin_registry(plugin_name, **kwargs) logger.debug("Setting up the plugin instance with api and kwargs") return plugin(api=self, **kwargs)
def manage(self, plugin_name, **kwargs): """ Gets a plugin, configures it, then allows direct communication with it. Plugins are passed the kwargs directly if any are specified. Example: >>> api = SolaceAPI("dev") >>> p1 = api.manage("NullPlugin") >>> p1.some_method("foo", bar="baz") (('foo',), {'bar': 'baz'}) >>> p2 = api.manage("NullPlugin", a="a") >>> p2.kwargs['a'] 'a' """ plugin = libsolace.plugin_registry(plugin_name, **kwargs) logging.debug("Setting up the plugin instance with api and kwargs") return plugin(api=self, **kwargs)
# now we override the settings with the options if options.xmlurl and not options.xmlfile: settings.CMDB_URL = options.xmlurl xmlfile = None elif options.xmlfile: logging.info('Settings XML file to Local') xmlfile = open(options.xmlfile, 'r') settings.CMDB_URL = None settings.env = options.env.lower() settings.product = options.product logging.info('CMDB_URL: %s' % settings.CMDB_URL) # load the cmdb API client cmdbapi_class = libsolace.plugin_registry(settings.SOLACE_CMDB_PLUGIN, settings=settings) # configure the client ( what init would normally do, but the plugin system # lacks the ability to implement stuff in init ) cmdbapi = cmdbapi_class(settings=settings, environment=options.env) # get the list of vpns to provision vpns = cmdbapi.get_vpns_by_owner(options.product, environment=options.env) logging.info('VPNs: %s' % json.dumps(str(vpns), ensure_ascii=False)) if vpns == []: logging.warn("No VPN found with that owner / componentName") raise Exception logging.info("VPNS %s" % vpns)