From 6f787ab5a2c398b9a228bd4c68935bc277c9f093 Mon Sep 17 00:00:00 2001 From: Stan Lagun Date: Tue, 13 Dec 2016 14:58:11 -0800 Subject: [PATCH] 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 --- .../resources/ExistingNeutronNetwork.yaml | 10 ++++++++- .../Classes/resources/NeutronNetwork.yaml | 22 ++----------------- .../Classes/resources/NeutronNetworkBase.yaml | 20 +++++++++++++++-- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/meta/io.murano/Classes/resources/ExistingNeutronNetwork.yaml b/meta/io.murano/Classes/resources/ExistingNeutronNetwork.yaml index c3d4b0fc8..919737b8b 100644 --- a/meta/io.murano/Classes/resources/ExistingNeutronNetwork.yaml +++ b/meta/io.murano/Classes/resources/ExistingNeutronNetwork.yaml @@ -59,6 +59,13 @@ Workflow: $.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( @@ -145,7 +152,8 @@ Workflow: netRef => $._internalNetworkId, subnetRef => $._internalSubnetworkId, floatingIpResourceName => $fipName, - floatingIpNetRef => $floatingIpNetRef + floatingIpNetRef => $floatingIpNetRef, + netName => $._internalNetworkName ) describe: diff --git a/meta/io.murano/Classes/resources/NeutronNetwork.yaml b/meta/io.murano/Classes/resources/NeutronNetwork.yaml index cf6429f44..0b36672ef 100644 --- a/meta/io.murano/Classes/resources/NeutronNetwork.yaml +++ b/meta/io.murano/Classes/resources/NeutronNetwork.yaml @@ -150,7 +150,8 @@ Methods: netRef => $netRef, subnetRef => $subnetRef, floatingIpResourceName => $fipName, - floatingIpNetRef => $extNetId + floatingIpNetRef => $extNetId, + netName => $._getHeatName() ) # (sjmc7) This is a workaround for https://bugs.launchpad.net/heat/+bug/1299259 @@ -163,19 +164,8 @@ Methods: - $._getRouterInterfaceName() - $result.template: $result.template.mergeWith($template) - - $addressOutputName: format('adresses-{0}-in-{1}', $instance.name, $this.name) - - $ipsOutputTemplate: - outputs: - $addressOutputName: - description: format('Addresses for {0} in {1}', $instance.name, $this.name) - value: - get_attr: [$instance.name, 'addresses', $._getHeatName()] - - $result.template: $result.template.mergeWith($ipsOutputTemplate) - - $result.instanceOutputs: $result.instanceOutputs.append($addressOutputName) - - Return: $result - describe: Body: - $.deploy() @@ -209,14 +199,6 @@ Methods: - $region.stack.push() - $.openstackId: null - getInstanceIpList: - Arguments: - - instance: - Contract: $.class(Instance).notNull() - Body: - - Return: $.getRegion().stack.output().get(format('adresses-{0}-in-{1}', $instance.name, $this.name)).select($["addr"]).distinct() - - _getRouterInterfaceName: Body: Return: format('ri-{0}', id($)) diff --git a/meta/io.murano/Classes/resources/NeutronNetworkBase.yaml b/meta/io.murano/Classes/resources/NeutronNetworkBase.yaml index ba50ff930..c3ffd9730 100644 --- a/meta/io.murano/Classes/resources/NeutronNetworkBase.yaml +++ b/meta/io.murano/Classes/resources/NeutronNetworkBase.yaml @@ -49,10 +49,14 @@ Methods: Contract: $.string() - floatingIpNetRef: Contract: $ + - netName: + Contract: $.string().notNull() Body: - $netExplorer: $._getNetExplorer() - $securityGroupsEnabled: $netExplorer.listNeutronExtensions().alias.contains('security-group') - $portName: format('port-{0}-{1}', id($), $instance.name) + + - $addressesOutputName: format('addresses-{0}-{1}', $instance.name, id($this)) - $patchTemplate: resources: $portName: @@ -60,6 +64,11 @@ Methods: properties: network: $netRef replacement_policy: AUTO + outputs: + $addressesOutputName: + description: format('Addresses for {0} in {1}', $instance.name, $netName) + value: + get_attr: [$instance.name, 'addresses', $netName] - If: $subnetRef Then: @@ -82,7 +91,7 @@ Methods: - $patchTemplate: $patchTemplate.mergeWith($template) - $instanceResources: [$portName] - - $instanceOutputs: [] + - $instanceOutputs: [$addressesOutputName] - For: sip In: $sharedIps @@ -123,7 +132,6 @@ Methods: instanceResources: $instanceResources instanceOutputs: $instanceOutputs - generateSecurityGroupManager: Body: - $region: $.getRegion() @@ -135,3 +143,11 @@ Methods: Else: - $._environment.reporter.report($this, "Warning! Security groups are disabled!") - Return: new(sys:DummySecurityGroupManager, $region) + + getInstanceIpList: + Arguments: + - instance: + Contract: $.class(Instance).notNull() + Body: + - Return: $.getRegion().stack.output()[ + format('addresses-{0}-{1}', $instance.name, id($this))].addr.distinct()