[Kimchi-devel] [PATCH 10/22] refactor model: Create a separated model for interface resource
Aline Manera
alinefm at linux.vnet.ibm.com
Tue Jan 28 20:21:24 UTC 2014
From: Aline Manera <alinefm at br.ibm.com>
The model implementation for config and its sub-resources were added to
model_/interfaces.py
Signed-off-by: Aline Manera <alinefm at br.ibm.com>
---
src/kimchi/model_/interfaces.py | 46 +++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
create mode 100644 src/kimchi/model_/interfaces.py
diff --git a/src/kimchi/model_/interfaces.py b/src/kimchi/model_/interfaces.py
new file mode 100644
index 0000000..b3b6ccd
--- /dev/null
+++ b/src/kimchi/model_/interfaces.py
@@ -0,0 +1,46 @@
+#
+# Project Kimchi
+#
+# Copyright IBM, Corp. 2013
+#
+# Authors:
+# 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 import netinfo
+from kimchi.exception import NotFoundError
+from kimchi.model_.networks import NetworksModel
+
+
+class InterfacesModel(object):
+ def __init__(self, **kargs):
+ self.conn = kargs['conn']
+ self.networks = NetworksModel(**kargs)
+
+ def get_list(self):
+ return list(set(netinfo.all_favored_interfaces()) -
+ set(self.networks.get_all_networks_interfaces()))
+
+
+class InterfaceModel(object):
+ def __init__(self, **kargs):
+ pass
+
+ def lookup(self, name):
+ try:
+ return netinfo.get_interface_info(name)
+ except ValueError, e:
+ raise NotFoundError(e)
--
1.7.10.4
More information about the Kimchi-devel
mailing list