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: I5132fd085d6ed617055e41c0502d43f00f3a9af4 Closes-Bug: #1524322
This commit is contained in:
parent
27e120a7a8
commit
442bf4d49e
|
@ -29,6 +29,7 @@ Workflow:
|
|||
- $._netExplorer: new(sys:NetworkExplorer)
|
||||
- $._networks: null
|
||||
- $._subnetworks: null
|
||||
- $._ports: null
|
||||
- $._internalNetworkId: null
|
||||
- $._internalSubnetworkId: null
|
||||
- $._externalNetworkId: null
|
||||
|
@ -57,6 +58,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(
|
||||
|
@ -120,5 +138,3 @@ Workflow:
|
|||
netRef: $._internalNetworkId
|
||||
subnetRef: $._internalSubnetworkId
|
||||
floatingIpNeRef: $._externalNetworkId
|
||||
|
||||
|
||||
|
|
|
@ -187,3 +187,8 @@ class NetworkExplorer(murano_object.MuranoObject):
|
|||
def listSubnetworks(self, _context):
|
||||
client = self._clients.get_neutron_client(_context)
|
||||
return client.list_subnets()['subnets']
|
||||
|
||||
# noinspection PyPep8Naming
|
||||
def listPorts(self, _context):
|
||||
client = self._clients.get_neutron_client(_context)
|
||||
return client.list_ports()['ports']
|
||||
|
|
Loading…
Reference in New Issue