Reviewed-by: Rodrigo Trujillo <rodrigo.trujillo(a)linux.vnet.ibm.com>
On 12/26/2013 07:48 PM, Aline Manera wrote:
From: Aline Manera <alinefm(a)br.ibm.com>
Networks(Collection) and Network(Resource) were moved to a new -
control/networks.py
That way we can easily know where network resource is implemented.
Signed-off-by: Aline Manera <alinefm(a)br.ibm.com>
---
src/kimchi/control/networks.py | 48 ++++++++++++++++++++++++++++++++++++++++
src/kimchi/controller.py | 24 --------------------
src/kimchi/root.py | 3 ++-
3 files changed, 50 insertions(+), 25 deletions(-)
create mode 100644 src/kimchi/control/networks.py
diff --git a/src/kimchi/control/networks.py b/src/kimchi/control/networks.py
new file mode 100644
index 0000000..ad95d69
--- /dev/null
+++ b/src/kimchi/control/networks.py
@@ -0,0 +1,48 @@
+#
+# Project Kimchi
+#
+# Copyright IBM, Corp. 2013
+#
+# Authors:
+# Aline Manera <alinefm(a)linux.vnet.ibm.com>
+# ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# 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
+
+from kimchi.control.base import Collection, Resource
+
+
+class Networks(Collection):
+ def __init__(self, model):
+ super(Networks, self).__init__(model)
+ self.resource = Network
+
+
+class Network(Resource):
+ def __init__(self, model, ident):
+ super(Network, self).__init__(model, ident)
+ self.uri_fmt = "/networks/%s"
+ self.activate = self.generate_action_handler('activate')
+ self.deactivate = self.generate_action_handler('deactivate')
+
+ @property
+ def data(self):
+ return {'name': self.ident,
+ 'autostart': self.info['autostart'],
+ 'connection': self.info['connection'],
+ 'interface': self.info['interface'],
+ 'subnet': self.info['subnet'],
+ 'dhcp': self.info['dhcp'],
+ 'state': self.info['state']}
diff --git a/src/kimchi/controller.py b/src/kimchi/controller.py
index 2a888a4..8f21bfd 100644
--- a/src/kimchi/controller.py
+++ b/src/kimchi/controller.py
@@ -35,30 +35,6 @@ from kimchi.exception import NotFoundError, OperationFailed
from kimchi.model import ISO_POOL_NAME
-class Networks(Collection):
- def __init__(self, model):
- super(Networks, self).__init__(model)
- self.resource = Network
-
-
-class Network(Resource):
- def __init__(self, model, ident):
- super(Network, self).__init__(model, ident)
- self.uri_fmt = "/networks/%s"
- self.activate = self.generate_action_handler('activate')
- self.deactivate = self.generate_action_handler('deactivate')
-
- @property
- def data(self):
- return {'name': self.ident,
- 'autostart': self.info['autostart'],
- 'connection': self.info['connection'],
- 'interface': self.info['interface'],
- 'subnet': self.info['subnet'],
- 'dhcp': self.info['dhcp'],
- 'state': self.info['state']}
-
-
class Task(Resource):
def __init__(self, model, id):
super(Task, self).__init__(model, id)
diff --git a/src/kimchi/root.py b/src/kimchi/root.py
index 982c7ea..ebcd062 100644
--- a/src/kimchi/root.py
+++ b/src/kimchi/root.py
@@ -33,6 +33,7 @@ from kimchi.control.utils import parse_request
from kimchi.control.base import Resource
from kimchi.control.debugreports import DebugReports
from kimchi.control.interfaces import Interfaces
+from kimchi.control.networks import Networks
from kimchi.control.storagepools import StoragePools
from kimchi.control.templates import Templates
from kimchi.control.vms import VMs
@@ -57,7 +58,7 @@ class Root(Resource):
self.templates = Templates(model)
self.storagepools = StoragePools(model)
self.interfaces = Interfaces(model)
- self.networks = controller.Networks(model)
+ self.networks = Networks(model)
self.tasks = controller.Tasks(model)
self.config = controller.Config(model)
self.host = controller.Host(model)