mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-28 11:18:11 +00:00
If we can found a common subnet we return the host binding for link
creation Fix #773
This commit is contained in:
parent
ca6f014207
commit
57e2fd9943
@ -618,4 +618,8 @@ class Compute:
|
|||||||
other_network = ipaddress.ip_network("{}/{}".format(other_interface["ip_address"], other_interface["netmask"]), strict=False)
|
other_network = ipaddress.ip_network("{}/{}".format(other_interface["ip_address"], other_interface["netmask"]), strict=False)
|
||||||
if this_network.overlaps(other_network):
|
if this_network.overlaps(other_network):
|
||||||
return (this_interface["ip_address"], other_interface["ip_address"])
|
return (this_interface["ip_address"], other_interface["ip_address"])
|
||||||
|
|
||||||
|
# Perhaps the user has correct network gateway
|
||||||
|
if (self.host_ip not in ('0.0.0.0', '127.0.0.1') and other_compute.host_ip not in ('0.0.0.0', '127.0.0.1')):
|
||||||
|
return (self.host_ip, other_compute.host_ip)
|
||||||
raise ValueError("No common subnet for compute {} and {}".format(self.name, other_compute.name))
|
raise ValueError("No common subnet for compute {} and {}".format(self.name, other_compute.name))
|
||||||
|
@ -447,7 +447,6 @@ def test_get_ip_on_same_subnet(controller, async_run):
|
|||||||
assert async_run(compute1.get_ip_on_same_subnet(compute2)) == ("192.168.1.1", "192.168.1.2")
|
assert async_run(compute1.get_ip_on_same_subnet(compute2)) == ("192.168.1.1", "192.168.1.2")
|
||||||
|
|
||||||
#No common interface
|
#No common interface
|
||||||
# Case 2 compute2 host is on a different network but a common interface is available
|
|
||||||
compute2 = Compute("compute2", host="127.0.0.1", controller=controller)
|
compute2 = Compute("compute2", host="127.0.0.1", controller=controller)
|
||||||
compute2._interfaces_cache = [
|
compute2._interfaces_cache = [
|
||||||
{
|
{
|
||||||
@ -481,5 +480,4 @@ def test_get_ip_on_same_subnet(controller, async_run):
|
|||||||
"netmask": "255.255.0.0"
|
"netmask": "255.255.0.0"
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
with pytest.raises(ValueError):
|
assert async_run(compute1.get_ip_on_same_subnet(compute2)) == ('192.168.2.1', '192.168.1.2')
|
||||||
assert async_run(compute1.get_ip_on_same_subnet(compute2))
|
|
||||||
|
Loading…
Reference in New Issue
Block a user