NetworkModel does not have the method _get_network. So, the method
get_network form NetworksModel become a static method and now are
available to be use in src/kimchi/model/networks.py.
Signed-off-by: Ramon Medeiros <ramonn(a)linux.vnet.ibm.com>
---
src/kimchi/model/networks.py | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/kimchi/model/networks.py b/src/kimchi/model/networks.py
index 88b5ece..9f381e3 100644
--- a/src/kimchi/model/networks.py
+++ b/src/kimchi/model/networks.py
@@ -76,7 +76,7 @@ class NetworksModel(object):
# lookup a free network address for nat and isolated automatically
if not netaddr:
for net_name in self.get_list():
- network = self._get_network(net_name)
+ network = NetworksModel.get_network(self.conn.get(), net_name)
xml = network.XMLDesc(0)
subnet = NetworkModel.get_network_from_xml(xml)['subnet']
subnet and net_addrs.append(ipaddr.IPNetwork(subnet))
@@ -158,7 +158,7 @@ class NetworkModel(object):
self.conn = kargs['conn']
def lookup(self, name):
- network = self._get_network(name)
+ network = self.get_network(self.conn.get(), name)
xml = network.XMLDesc(0)
net_dict = self.get_network_from_xml(xml)
subnet = net_dict['subnet']
@@ -209,17 +209,17 @@ class NetworkModel(object):
return xmlutils.xpath_get_text(xml, xpath)
def activate(self, name):
- network = self._get_network(name)
+ network = self.get_network(self.conn.get(), name)
network.create()
def deactivate(self, name):
- network = self._get_network(name)
+ network = self.get_network(self.conn.get(), name)
if self._get_vms_attach_to_a_network(name, "running"):
raise InvalidOperation("KCHNET0018E", {'name': name})
network.destroy()
def delete(self, name):
- network = self._get_network(name)
+ network = self.get_network(self.conn.get(), name)
if network.isActive():
raise InvalidOperation("KCHNET0005E", {'name': name})
if self._get_vms_attach_to_a_network(name):
@@ -228,8 +228,8 @@ class NetworkModel(object):
self._remove_vlan_tagged_bridge(network)
network.undefine()
- def _get_network(self, name):
- conn = self.conn.get()
+ @staticmethod
+ def get_network(conn, name):
try:
return conn.networkLookupByName(name)
except libvirt.libvirtError:
--
1.8.3.1