[Kimchi-devel] [PATCH] [WoK 03/10] /config/plugins: changes in config model

dhbarboza82 at gmail.com dhbarboza82 at gmail.com
Fri Jan 20 17:32:37 UTC 2017


From: Daniel Henrique Barboza <danielhb at linux.vnet.ibm.com>

Added the Plugins Collection and Plugin Resource classes
in wok/control/config.py.

Plugin is a Resource with two actions called 'enable' and
'disable'.

Signed-off-by: Daniel Henrique Barboza <danielhb at linux.vnet.ibm.com>
---
 src/wok/control/config.py | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/wok/control/config.py b/src/wok/control/config.py
index 338306c..c0679f3 100644
--- a/src/wok/control/config.py
+++ b/src/wok/control/config.py
@@ -1,7 +1,7 @@
 #
 # Project Wok
 #
-# Copyright IBM Corp, 2016
+# Copyright IBM Corp, 2016-2017
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -17,7 +17,7 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
 
-from wok.control.base import Resource
+from wok.control.base import Collection, Resource
 from wok.control.utils import UrlSubNode
 
 
@@ -25,6 +25,26 @@ from wok.control.utils import UrlSubNode
 class Config(Resource):
     def __init__(self, model, id=None):
         super(Config, self).__init__(model, id)
+        self.plugins = Plugins(self.model)
+
+    @property
+    def data(self):
+        return self.info
+
+
+class Plugins(Collection):
+    def __init__(self, model):
+        super(Plugins, self).__init__(model)
+        self.resource = Plugin
+
+
+class Plugin(Resource):
+    def __init__(self, model, ident=None):
+        super(Plugin, self).__init__(model, ident)
+        self.ident = ident
+        self.uri_fmt = "/config/plugins/%s"
+        self.enable = self.generate_action_handler('enable')
+        self.disable = self.generate_action_handler('disable')
 
     @property
     def data(self):
-- 
2.7.4



More information about the Kimchi-devel mailing list