From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
we can difine a /host as follow:
@urlSubNode("host", True)
class Host(Resource):
def __init__(self, model, id=None):
super(Host, self).__init__(model, id)
@urlSubNode("host", True) means:
the URL "/host" is root.Host, and it need authentication
Signed-off-by: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
---
src/kimchi/control/__init__.py | 8 ++++++++
src/kimchi/control/config.py | 2 ++
src/kimchi/control/debugreports.py | 2 ++
src/kimchi/control/host.py | 2 ++
src/kimchi/control/interfaces.py | 2 ++
src/kimchi/control/networks.py | 2 ++
src/kimchi/control/plugins.py | 2 ++
src/kimchi/control/storagepools.py | 2 ++
src/kimchi/control/tasks.py | 2 ++
src/kimchi/control/templates.py | 2 ++
src/kimchi/control/vms.py | 2 ++
11 files changed, 28 insertions(+)
diff --git a/src/kimchi/control/__init__.py b/src/kimchi/control/__init__.py
index 8a37cc4..3d64099 100644
--- a/src/kimchi/control/__init__.py
+++ b/src/kimchi/control/__init__.py
@@ -19,3 +19,11 @@
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+import os
+
+
+from kimchi.utils import load_url_sub_node
+
+
+sub_nodes = load_url_sub_node(os.path.dirname(__file__))
diff --git a/src/kimchi/control/config.py b/src/kimchi/control/config.py
index 603f51d..9813b8d 100644
--- a/src/kimchi/control/config.py
+++ b/src/kimchi/control/config.py
@@ -27,8 +27,10 @@ import cherrypy
from kimchi.config import config
from kimchi.control.base import Collection, Resource
+from kimchi.utils import urlSubNode
+@urlSubNode("config")
class Config(Resource):
def __init__(self, model, id=None):
super(Config, self).__init__(model, id)
diff --git a/src/kimchi/control/debugreports.py b/src/kimchi/control/debugreports.py
index a55ba38..7c594ae 100644
--- a/src/kimchi/control/debugreports.py
+++ b/src/kimchi/control/debugreports.py
@@ -23,8 +23,10 @@
from kimchi.control.base import AsyncCollection, Resource
from kimchi.control.utils import internal_redirect
+from kimchi.utils import urlSubNode
+@urlSubNode("debugreports", True)
class DebugReports(AsyncCollection):
def __init__(self, model):
super(DebugReports, self).__init__(model)
diff --git a/src/kimchi/control/host.py b/src/kimchi/control/host.py
index 9b19577..2fc64be 100644
--- a/src/kimchi/control/host.py
+++ b/src/kimchi/control/host.py
@@ -24,8 +24,10 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
from kimchi.control.base import Collection, Resource
+from kimchi.utils import urlSubNode
+@urlSubNode("host", True)
class Host(Resource):
def __init__(self, model, id=None):
super(Host, self).__init__(model, id)
diff --git a/src/kimchi/control/interfaces.py b/src/kimchi/control/interfaces.py
index 28be26e..e6a1e77 100644
--- a/src/kimchi/control/interfaces.py
+++ b/src/kimchi/control/interfaces.py
@@ -23,8 +23,10 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
from kimchi.control.base import Collection, Resource
+from kimchi.utils import urlSubNode
+@urlSubNode("interfaces")
class Interfaces(Collection):
def __init__(self, model):
super(Interfaces, self).__init__(model)
diff --git a/src/kimchi/control/networks.py b/src/kimchi/control/networks.py
index f3f0b41..ac1aaed 100644
--- a/src/kimchi/control/networks.py
+++ b/src/kimchi/control/networks.py
@@ -22,8 +22,10 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
from kimchi.control.base import Collection, Resource
+from kimchi.utils import urlSubNode
+@urlSubNode("networks", True)
class Networks(Collection):
def __init__(self, model):
super(Networks, self).__init__(model)
diff --git a/src/kimchi/control/plugins.py b/src/kimchi/control/plugins.py
index af32709..ff448bd 100644
--- a/src/kimchi/control/plugins.py
+++ b/src/kimchi/control/plugins.py
@@ -25,8 +25,10 @@
import kimchi.template
from kimchi.control.base import Collection, Resource
from kimchi.control.utils import get_class_name, model_fn
+from kimchi.utils import urlSubNode
+@urlSubNode("plugins")
class Plugins(Collection):
def __init__(self, model):
super(Plugins, self).__init__(model)
diff --git a/src/kimchi/control/storagepools.py b/src/kimchi/control/storagepools.py
index 782f5a6..88d2aa3 100644
--- a/src/kimchi/control/storagepools.py
+++ b/src/kimchi/control/storagepools.py
@@ -31,8 +31,10 @@ from kimchi.control.storagevolumes import IsoVolumes, StorageVolumes
from kimchi.control.utils import get_class_name, model_fn, parse_request
from kimchi.control.utils import validate_params
from kimchi.model import ISO_POOL_NAME
+from kimchi.utils import urlSubNode
+@urlSubNode("storagepools", True)
class StoragePools(Collection):
def __init__(self, model):
super(StoragePools, self).__init__(model)
diff --git a/src/kimchi/control/tasks.py b/src/kimchi/control/tasks.py
index b799422..869cecf 100644
--- a/src/kimchi/control/tasks.py
+++ b/src/kimchi/control/tasks.py
@@ -22,8 +22,10 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
from kimchi.control.base import Collection, Resource
+from kimchi.utils import urlSubNode
+@urlSubNode("tasks", True)
class Tasks(Collection):
def __init__(self, model):
super(Tasks, self).__init__(model)
diff --git a/src/kimchi/control/templates.py b/src/kimchi/control/templates.py
index a77936e..8f59152 100644
--- a/src/kimchi/control/templates.py
+++ b/src/kimchi/control/templates.py
@@ -22,8 +22,10 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
from kimchi.control.base import Collection, Resource
+from kimchi.utils import urlSubNode
+@urlSubNode("templates", True)
class Templates(Collection):
def __init__(self, model):
super(Templates, self).__init__(model)
diff --git a/src/kimchi/control/vms.py b/src/kimchi/control/vms.py
index 7843be7..25474fc 100644
--- a/src/kimchi/control/vms.py
+++ b/src/kimchi/control/vms.py
@@ -24,8 +24,10 @@
from kimchi.control.base import Collection, Resource
from kimchi.control.utils import internal_redirect
+from kimchi.utils import urlSubNode
+@urlSubNode("vms", True)
class VMs(Collection):
def __init__(self, model):
super(VMs, self).__init__(model)
--
1.8.4.2