libsolace.plugin module

class libsolace.plugin.Plugin(*args, **kwargs)[source]

Bases: object

This is the plugin core object where all plugins should extend from and register too.

Plugin Example:

>>> import pprint
>>> import libsolace
>>> from libsolace.plugin import Plugin
>>> @libsolace.plugin_registry.register
>>> class Bar(Plugin):
>>>     plugin_name = "BarPlugin"
>>>     def __init__(self):
>>>         pass
>>>     # Instance methods work!
>>>     def hello(self, name):
>>>         print("Hello %s from %s" % (name, self))
>>>     # Static methods work too!
>>>     @staticmethod
>>>     def gbye():
>>>         print("Cheers!")
>>> libsolace.plugin_registry('BarPlugin').hello("dude")
>>> libsolace.plugin_registry('BarPlugin').gbye()
>>> pprint.pprint(dir(libsolace.plugin_registry('BarPlugin')))

Plugin Instantiation:

>>> import libsolace.settingsloader as settings
>>> from libsolace.SolaceAPI import SolaceAPI
>>> api = SolaceAPI("dev")
>>> my_plugin = api.manage("NullPlugin")
>>> type(my_plugin)
<class 'libsolace.items.NullPlugin.NullPlugin'>

Direct Instantiation:

>>> import libsolace.settingsloader as settings
>>> import libsolace
>>> my_clazz = libsolace.plugin_registry("NullPlugin", settings=settings)
>>> my_instance = my_clazz(settings=settings)
exists = False
plugin_name = 'Plugin'

the plugin’s name, override this in the derived class!

plugins = [<class 'libsolace.items.NullPlugin.NullPlugin'>, <class 'libsolace.items.SolaceACLProfile.SolaceACLProfile'>, <class 'libsolace.items.SolaceUser.SolaceUser'>, <class 'libsolace.items.SolaceUsers.SolaceUsers'>, <class 'libsolace.items.SolaceVPN.SolaceVPN'>, <class 'libsolace.items.SolaceQueue.SolaceQueue'>, <class 'libsolace.plugins.NamingStandard.NamingStandard'>, <class 'libsolace.plugins.ZoinksNamingStandard.ZoinksNamingStandard'>, <class 'libsolace.items.SolaceClientProfile.SolaceClientProfile'>, <class 'libsolace.plugins.Utilities.Utilities'>, <class 'libsolace.plugins.InfluxDBClient.InfluxDBClient'>, <class 'libsolace.plugins.YAMLClient.YAMLClient'>]
plugins_dict = OrderedDict([('NullPlugin', <class 'libsolace.items.NullPlugin.NullPlugin'>), ('SolaceACLProfile', <class 'libsolace.items.SolaceACLProfile.SolaceACLProfile'>), ('SolaceUser', <class 'libsolace.items.SolaceUser.SolaceUser'>), ('SolaceUsers', <class 'libsolace.items.SolaceUsers.SolaceUsers'>), ('SolaceVPN', <class 'libsolace.items.SolaceVPN.SolaceVPN'>), ('SolaceQueue', <class 'libsolace.items.SolaceQueue.SolaceQueue'>), ('NamingStandard', <class 'libsolace.plugins.NamingStandard.NamingStandard'>), ('ZoinksNamingStandard', <class 'libsolace.plugins.ZoinksNamingStandard.ZoinksNamingStandard'>), ('SolaceClientProfile', <class 'libsolace.items.SolaceClientProfile.SolaceClientProfile'>), ('Utilities', <class 'libsolace.plugins.Utilities.Utilities'>), ('InfluxDBClient', <class 'libsolace.plugins.InfluxDBClient.InfluxDBClient'>), ('YAMLClient', <class 'libsolace.plugins.YAMLClient.YAMLClient'>)])
register(object_class, *args, **kwargs)[source]

Registers a object with the plugin registry, typically used as a decorator.

Parameters:object_class – the class to register as a plugin
Example:
>>> @libsolace.plugin_registry.register
>>> class Foo(Plugin)
>>> ...
set_exists(state)[source]

set_exists is used as caching in order to cut down on SEMP queries to validate existence of items. For example, if you create a new VPN in “batch” mode, After the “create-vpn” XML is generated, set_exists is set to True so subsequent requests decorated with the only_if_exists will function correctly since set_exists states that the object will exist.

Parameters:state (bool) – the existence state of the object
Returns:
class libsolace.plugin.PluginClass[source]

Bases: type

This is a metaclass for construction only, see Plugin rather

class libsolace.plugin.PluginResponse(xml, **kwargs)[source]

Bases: object

Encapsulating class for holding SEMP requests and their accompanying kwargs.

Example:

>>> request = PluginResponse('<rpc semp-version="soltr/7_1_1"><show><memory/></show></rpc>', primaryOnly=True)
>>> request.xml
'<rpc semp-version="soltr/7_1_1"><show><memory/></show></rpc>'
kwargs = None

the kwargs

xml = None

the XML