Improve public network detection algorithm
It is possible that there are several public networks exist. ExistingNeutronNetwork used to pick first one of them. Now when internal network name or ID supplied it tries to find such public network that the internal network has a common router with. Change-Id: I252bb5545891903355cf7f8480a2cd76febcfebe Closes-Bug: #1524322
This commit is contained in:
parent
176a58be7f
commit
04bccb55b9
@ -41,6 +41,7 @@ Workflow:
|
||||
- $._netExplorer: new(sys:NetworkExplorer)
|
||||
- $._networks: null
|
||||
- $._subnetworks: null
|
||||
- $._ports: null
|
||||
- $._internalNetworkId: null
|
||||
- $._internalSubnetworkId: null
|
||||
- $._externalNetworkId: null
|
||||
@ -69,6 +70,23 @@ Workflow:
|
||||
$.id = $this.internalSubnetworkName) and
|
||||
$.network_id = $this._internalNetworkId).first().id
|
||||
|
||||
- If: $.externalNetworkName = null and $._internalNetworkId != null
|
||||
Then:
|
||||
- $ports: $._netExplorer.listPorts()
|
||||
- $routerCandidates: $ports.where(
|
||||
$.network_id = $this._internalNetworkId and $.device_owner = 'network:router_interface').
|
||||
select($.device_id)
|
||||
- $networkCandidates: $ports.where(
|
||||
$.device_id in $routerCandidates and $.network_id != $this._internalNetworkId).
|
||||
select($.network_id)
|
||||
- $externalNetwork: $._getNetworks().where(
|
||||
$.get('router:external') = true and $.id in $networkCandidates).
|
||||
firstOrDefault()
|
||||
- If: $externalNetwork != null
|
||||
Then:
|
||||
- $.externalNetworkName: $externalNetwork.name
|
||||
- $._externalNetworkId: $externalNetwork.id
|
||||
|
||||
- If: $.externalNetworkName = null
|
||||
Then:
|
||||
$.externalNetworkName: $._getNetworks().where(
|
||||
@ -123,11 +141,10 @@ Workflow:
|
||||
floatingIpNetRef => $floatingIpNetRef
|
||||
)
|
||||
|
||||
|
||||
describe:
|
||||
Body:
|
||||
- $.deploy()
|
||||
- $subnet: $._netExplorer.listSubnetworks().where(
|
||||
- $subnet: $._getSubnetworks.where(
|
||||
$.network_id = $this._internalNetworkId).first()
|
||||
- Return:
|
||||
provider: Neutron
|
||||
|
@ -175,3 +175,7 @@ class NetworkExplorer(object):
|
||||
def list_subnetworks(self):
|
||||
client = self._clients.get_neutron_client()
|
||||
return client.list_subnets()['subnets']
|
||||
|
||||
def list_ports(self):
|
||||
client = self._clients.get_neutron_client()
|
||||
return client.list_ports()['ports']
|
||||
|
Loading…
Reference in New Issue
Block a user