[Kimchi-devel] [PATCH 11/16] Move all resources related to networks to control/networks.py

Aline Manera alinefm at linux.vnet.ibm.com
Mon Dec 23 18:41:26 UTC 2013


From: Aline Manera <alinefm at 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 at br.ibm.com>
---
 Makefile.am                    |    1 +
 src/kimchi/control/networks.py |   48 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+)
 create mode 100644 src/kimchi/control/networks.py

diff --git a/Makefile.am b/Makefile.am
index 76953ea..988702e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -48,6 +48,7 @@ PEP8_WHITELIST = \
 	src/kimchi/control/base.py \
 	src/kimchi/control/debugreports.py \
 	src/kimchi/control/interfaces.py \
+	src/kimchi/control/networks.py \
 	src/kimchi/control/storagepools.py \
 	src/kimchi/control/storagevolumes.py \
 	src/kimchi/control/templates.py \
diff --git a/src/kimchi/control/networks.py b/src/kimchi/control/networks.py
new file mode 100644
index 0000000..f7df5bd
--- /dev/null
+++ b/src/kimchi/control/networks.py
@@ -0,0 +1,48 @@
+#
+# Project Kimchi
+#
+# Copyright IBM, Corp. 2013
+#
+# Authors:
+#  Adam Litke <agl at linux.vnet.ibm.com>
+#  Aline Manera <alinefm at 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(self, 'activate')
+        self.deactivate = self.generate_action_handler(self, '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']}
-- 
1.7.10.4




More information about the Kimchi-devel mailing list