Commit 26cc9fd3 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

cyclades: Fix double double creation of IP log

The port creation command called 'associate_port_with_machine' function
in order to associate the port with the machine and create an
IPAddressLog entry. However, this is already done by the connect
function which sends the job in the Ganeti backend. This resulted in
duplicate entries in the IP accounting mechanism.
parent 4b649f24
......@@ -485,9 +485,7 @@ def _create_port(userid, network, machine=None, use_ipaddress=None,
ipaddress.save()
if machine is not None:
# Associate Port(NIC) with VirtualMachine
port = associate_port_with_machine(port, machine)
# Send job to connect port to instance
# Connect port to the instance.
machine = connect(machine, network, port)
jobID = machine.task_job_id
log.info("Created Port %s with IP %s. Ganeti Job: %s",
......@@ -506,6 +504,8 @@ def associate_port_with_machine(port, machine):
IPAddressLog if the port has a public IPv4 address from a public network.
"""
if port.machine is not None:
raise faults.Conflict("Port %s is already in use." % port.id)
if port.network.public:
ipv4_address = port.ipv4_address
if ipv4_address is not 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