Commit 940f9eaa authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

cyclades: Fix helpdesk code and tests for new nets

parent 43e14023
......@@ -47,7 +47,7 @@
<td>{{ nic.updated }}</td>
<td>{{ nic.index }}</td>
<td>{{ nic.mac }}</td>
<td>{{ nic.ipv4 }}</td>
<td>{{ nic.ipv4_address }}</td>
<td>{{ nic.ipv6 }}</td>
<td>{{ nic.get_firewall_profile_display }} ({{nic.firewall_profile}})</td>
</tr>
......
......@@ -83,8 +83,8 @@
<td>{{ nic.updated }}</td>
<td>{{ nic.index }}</td>
<td>{{ nic.mac }}</td>
<td>{{ nic.ipv4 }}</td>
<td>{{ nic.ipv6 }}</td>
<td>{{ nic.ipv4_address }}</td>
<td>{{ nic.ipv6_address }}</td>
<td>{{ nic.get_firewall_profile_display }} ({{nic.firewall_profile}})</td>
</tr>
{% empty %}
......
......@@ -10,7 +10,7 @@ def vm_public_ip(vm):
address
"""
try:
return vm.nics.filter(network__public=True)[0].ipv4
return vm.nics.filter(network__public=True)[0].ipv4_address
except IndexError:
return "No public ip"
......
......@@ -111,12 +111,15 @@ class HelpdeskTests(TestCase):
vm2u2 = mfactory.VirtualMachineFactory(userid=USER2, name="user2 vm2",
pk=1003)
netpub = mfactory.NetworkFactory(public=True)
net1u1 = mfactory.NetworkFactory(public=False, userid=USER1)
nic1 = mfactory.NetworkInterfaceFactory(machine=vm1u2, network=net1u1)
nic2 = mfactory.NetworkInterfaceFactory(machine=vm1u1, network=netpub,
ipv4="195.251.222.211")
nic1 = mfactory.NetworkInterfaceFactory(machine=vm1u2,
userid=vm1u2.userid,
network__public=False,
network__userid=USER1)
ip2 = mfactory.IPv4AddressFactory(nic__machine=vm1u1,
userid=vm1u1.userid,
network__public=True,
network__userid=None,
address="195.251.222.211")
def test_enabled_setting(self):
settings.HELPDESK_ENABLED = False
......
......@@ -46,7 +46,7 @@ from urllib import unquote
import astakosclient
from snf_django.lib import astakos
from synnefo.db.models import VirtualMachine, NetworkInterface, Network
from synnefo.db.models import VirtualMachine, IPAddress, Network
# server actions specific imports
from synnefo.api import util
......@@ -185,11 +185,11 @@ def account(request, search_query):
if is_ip:
try:
nic = NetworkInterface.objects.filter(ipv4=search_query).exclude(
machine__deleted=True).get()
search_query = nic.machine.userid
ip = IPAddress.objects.filter(address=search_query, deleted=False)\
.get()
search_query = ip.userid
is_uuid = True
except NetworkInterface.DoesNotExist:
except IPAddress.DoesNotExist:
account_exists = False
account = None
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment