murano/meta/io.murano/Classes/resources/ExistingNeutronNetwork.yaml
Stan Lagun 19b4eb074f ExistingNeutronNetwork didn't return IPs for the instance
When deploying an Instance joined to ExistingNeutronNetwork its
ipAddresses property returned an empty list, which was causing most of
the applications to fail. This happened because the responsibility of
managing HOT outputs for the instance IP was moved to the Network
classes and was implemented for the NeutronNetwork but not the
ExistingNeutronNetwork.

This commit moves the logic to the base class for all Neutron networks
and refactors it so that it could be used for them all

Change-Id: I552098683e0faeb66f7c622ea8c1d073a82d6338
Closes-Bug: #1649715
2016-12-14 14:41:55 +03:00

165 lines
5.3 KiB
YAML

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
Namespaces:
=: io.murano.resources
std: io.murano
sys: io.murano.system
Name: ExistingNeutronNetwork
Extends: NeutronNetworkBase
Properties:
internalNetworkName:
Contract: $.string()
Default: null
Usage: InOut
internalSubnetworkName:
Contract: $.string()
Default: null
Usage: InOut
externalNetworkName:
Contract: $.string()
Default: null
Usage: InOut
Workflow:
initialize:
Body:
- $._networks: null
- $._subnetworks: null
- $._ports: null
- $._internalNetworkId: null
- $._internalSubnetworkId: null
- $._externalNetworkId: null
deploy:
Body:
- $netExplorer: $._getNetExplorer()
- If: $.internalNetworkName = null
Then:
$.internalNetworkName: $._getNetworks().where(
$.get('router:external') = false).first().name
- If: $._internalNetworkId = null
Then:
$._internalNetworkId: $._getNetworks().where(
$.name = $this.internalNetworkName or
$.id = $this.internalNetworkName).first().id
- If: $._internalNetworkId = $.internalNetworkName
Then:
$._internalNetworkName: $._getNetworks().where(
$.id = $this._internalNetworkId).first().name
Else:
$._internalNetworkName: $.internalNetworkName
- If: $.internalSubnetworkName = null
Then:
$.internalSubnetworkName: $._getSubnetworks().where(
$.network_id = $this._internalNetworkId).first().name
- If: $._internalSubnetworkId = null
Then:
$._internalSubnetworkId: $._getSubnetworks().where(
($.name = $this.internalSubnetworkName or
$.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).first(null)
- If: $externalNetwork != null
Then:
- $.externalNetworkName: $externalNetwork.name
- $._externalNetworkId: $externalNetwork.id
- If: $.externalNetworkName = null
Then:
$.externalNetworkName: $._getNetworks().where(
$.get('router:external') = true).select($.name).first(null)
- If: $._externalNetworkId = null and $.externalNetworkName != null
Then:
$._externalNetworkId: $._getNetworks().where(
$.name = $this.externalNetworkName or
$.id = $this.externalNetworkName).first().id
_getNetworks:
Body:
- If: not $._networks
Then:
$._networks: $._getNetExplorer().listNetworks()
- Return: $._networks
_getSubnetworks:
Body:
- If: $._subnetworks = null
Then:
$._subnetworks : $._getNetExplorer().listSubnetworks()
- Return: $._subnetworks
joinInstance:
Arguments:
- instance:
Contract: $.class(Instance).notNull()
- securityGroupName:
Contract: $.string()
- assignFloatingIp:
Contract: $.bool().notNull()
- sharedIps:
Contract:
- $.class(std:SharedIp)
Body:
- $.deploy()
- $fipName: null
- $floatingIpNetRef: null
- If: $assignFloatingIp
Then:
- $floatingIpNetRef: $._externalNetworkId
- $fipName: format('fip-{0}-{1}', id($), $instance.name)
- Return: $.joinInstanceToNetwork(
instance => $instance,
securityGroupName => $securityGroupName,
sharedIps => $sharedIps,
netRef => $._internalNetworkId,
subnetRef => $._internalSubnetworkId,
floatingIpResourceName => $fipName,
floatingIpNetRef => $floatingIpNetRef,
netName => $._internalNetworkName
)
describe:
Body:
- $.deploy()
- $subnet: $._getSubnetworks().where(
$.network_id = $this._internalNetworkId).first()
- Return:
provider: Neutron
netId: $._internalNetworkId
netName: $.internalNetworkName
subnetId: $._internalSubnetworkId
cidr: $subnet.cidr
dns: $subnet.dns_nameservers
gateway: $subnet.gateway_ip
floatingIpNetId: $._externalNetworkId