mirror of
https://github.com/retspen/webvirtcloud
synced 2024-10-31 19:44:16 +00:00
reorganize host interfaces. remove it from instance methods
This commit is contained in:
parent
59af676f68
commit
2f1b11b3ca
6 changed files with 12 additions and 16 deletions
|
@ -204,10 +204,6 @@ class Instance(models.Model):
|
|||
def formats(self):
|
||||
return self.proxy.get_image_formats()
|
||||
|
||||
@cached_property
|
||||
def interfaces(self):
|
||||
return self.proxy.get_ifaces()
|
||||
|
||||
|
||||
class PermissionSet(models.Model):
|
||||
"""
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
{% for c_net in networks_host %}
|
||||
<option value="net:{{ c_net }}">Network {{ c_net }}</option>
|
||||
{% endfor %}
|
||||
{% for c_iface in instance.interfaces %}
|
||||
{% for c_iface in interfaces_host %}
|
||||
<option value="iface:{{ c_iface }}">Interface {{ c_iface }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
|
|
@ -401,7 +401,7 @@
|
|||
{% for c_net in networks_host %}
|
||||
<option value="net:{{ c_net }}" {% if c_net == network.nic %} selected {% endif %}>{% trans 'Network' %} {{ c_net }}</option>
|
||||
{% endfor %}
|
||||
{% for c_iface in instance.interfaces %}
|
||||
{% for c_iface in interfaces_host %}
|
||||
<option value="iface:{{ c_iface }}" {% if c_iface == network.nic %} selected {% endif %}>{% trans 'Interface' %} {{ c_iface }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
|
|
@ -29,7 +29,8 @@ def interfaces(request, compute_id):
|
|||
netdevs = ["eth0", "eth1"]
|
||||
|
||||
for iface in ifaces:
|
||||
ifaces_all.append(conn.get_iface_info(iface))
|
||||
interf = wvmInterface(compute.hostname, compute.login, compute.password, compute.type, iface)
|
||||
ifaces_all.append(interf.get_details())
|
||||
|
||||
if request.method == "POST":
|
||||
if "create" in request.POST:
|
||||
|
|
|
@ -482,7 +482,7 @@ class wvmConnect(object):
|
|||
|
||||
def get_networks(self):
|
||||
"""
|
||||
:return: list of networks
|
||||
:return: list of host networks
|
||||
"""
|
||||
virtnet = []
|
||||
for net in self.wvm.listNetworks():
|
||||
|
@ -493,7 +493,7 @@ class wvmConnect(object):
|
|||
|
||||
def get_ifaces(self):
|
||||
"""
|
||||
:return: list of network interfaces
|
||||
:return: list of host interfaces
|
||||
"""
|
||||
interface = []
|
||||
for inface in self.wvm.listInterfaces():
|
||||
|
|
|
@ -6,13 +6,6 @@ from vrtManager.connection import wvmConnect
|
|||
|
||||
|
||||
class wvmInterfaces(wvmConnect):
|
||||
def get_iface_info(self, name):
|
||||
iface = self.get_iface(name)
|
||||
xml = iface.XMLDesc(0)
|
||||
mac = iface.MACString()
|
||||
itype = util.get_xml_path(xml, "/interface/@type")
|
||||
state = iface.isActive()
|
||||
return {"name": name, "type": itype, "state": state, "mac": mac}
|
||||
|
||||
def define_iface(self, xml, flag=0):
|
||||
self.wvm.interfaceDefineXML(xml, flag)
|
||||
|
@ -153,6 +146,12 @@ class wvmInterface(wvmConnect):
|
|||
else:
|
||||
return None
|
||||
|
||||
def get_details(self):
|
||||
mac = self.get_mac()
|
||||
itype = self.get_type()
|
||||
state = self.is_active()
|
||||
return {"name": self.iface, "type": itype, "state": state, "mac": mac}
|
||||
|
||||
def stop_iface(self):
|
||||
self.iface.destroy()
|
||||
|
||||
|
|
Loading…
Reference in a new issue