mirror of
https://github.com/xcat2/confluent.git
synced 2025-02-11 16:24:41 +00:00
Support resource register from plugin
This commit is contained in:
parent
6e7b6188dd
commit
05a683698e
@ -47,6 +47,7 @@ import confluent.messages as msg
|
||||
import confluent.networking.macmap as macmap
|
||||
import confluent.noderange as noderange
|
||||
import confluent.osimage as osimage
|
||||
import confluent.plugin as plugin
|
||||
try:
|
||||
import confluent.shellmodule as shellmodule
|
||||
except ImportError:
|
||||
@ -71,6 +72,7 @@ import sys
|
||||
|
||||
pluginmap = {}
|
||||
dispatch_plugins = (b'ipmi', u'ipmi', b'redfish', u'redfish', b'tsmsol', u'tsmsol')
|
||||
PluginCollection = plugin.PluginCollection
|
||||
|
||||
try:
|
||||
unicode
|
||||
@ -131,10 +133,29 @@ def load_plugins():
|
||||
pluginmap[name] = tmpmod
|
||||
else:
|
||||
pluginmap[plugin] = tmpmod
|
||||
_register_resource(tmpmod)
|
||||
plugins.clear()
|
||||
# restore path to not include the plugindir
|
||||
sys.path.pop(1)
|
||||
|
||||
|
||||
def _register_resource(plugin):
|
||||
global noderesources
|
||||
if 'custom_resources' in plugin.__dict__:
|
||||
_merge_dict(noderesources, plugin.custom_resources)
|
||||
|
||||
|
||||
def _merge_dict(original, custom):
|
||||
for k,v in custom.items():
|
||||
if k in original:
|
||||
if isinstance(original.get(k), dict):
|
||||
_merge_dict(original.get(k), custom.get(k))
|
||||
else:
|
||||
original[k] = custom.get(k)
|
||||
else:
|
||||
original[k] = custom.get(k)
|
||||
|
||||
|
||||
rootcollections = ['deployment/', 'discovery/', 'events/', 'networking/',
|
||||
'noderange/', 'nodes/', 'nodegroups/', 'usergroups/' ,
|
||||
'users/', 'version']
|
||||
@ -145,11 +166,6 @@ class PluginRoute(object):
|
||||
self.routeinfo = routedict
|
||||
|
||||
|
||||
class PluginCollection(object):
|
||||
def __init__(self, routedict, maxdepth=1):
|
||||
self.routeinfo = routedict
|
||||
self.maxdepth = maxdepth
|
||||
|
||||
|
||||
def handle_deployment(configmanager, inputdata, pathcomponents,
|
||||
operation):
|
||||
|
23
confluent_server/confluent/plugin.py
Normal file
23
confluent_server/confluent/plugin.py
Normal file
@ -0,0 +1,23 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright 2014 IBM Corporation
|
||||
# Copyright 2015-2018 Lenovo
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
class PluginCollection(object):
|
||||
def __init__(self, routedict, maxdepth=1):
|
||||
self.routeinfo = routedict
|
||||
self.maxdepth = maxdepth
|
||||
|
Loading…
x
Reference in New Issue
Block a user