diff --git a/meta/io.murano/Classes/SharedIp.yaml b/meta/io.murano/Classes/SharedIp.yaml index e47f61e44..05384d6a4 100644 --- a/meta/io.murano/Classes/SharedIp.yaml +++ b/meta/io.murano/Classes/SharedIp.yaml @@ -12,6 +12,7 @@ Namespaces: =: io.murano + res: io.murano.resources Name: SharedIp Extends: CloudResource @@ -26,6 +27,10 @@ Properties: floatingIpAddress: Contract: $.string() Usage: Out + network: + Contract: $.class(res:Network) + Usage: InOut + Methods: initialize: @@ -34,15 +39,25 @@ Methods: - $.instances: [] + deployNetwork: + Body: + - If: $.network = null + Then: + $.network: $.getRegion().defaultNetworks.environment + + - $.network.deploy() + + deploy: Body: - If: not $.getAttr(deployed, false) Then: - $region: $.getRegion() - - $network: $region.defaultNetworks.environment - $reporter: $._environment.reporter - - $network.deploy() - - $networkData: $network.describe() + + - $.deployNetwork() + - $networkData: $.network.describe() + - $aapPortName: format('AllowedAddressPairsPort-{0}', id($)) - $template: resources: @@ -66,7 +81,7 @@ Methods: - subnet_id: $networkData.subnetId - $template: $template.mergeWith($t) - $region.stack.updateTemplate($template) - - If: $.assignFloatingIp + - If: $.assignFloatingIp and $networkData.floatingIpNetId Then: - $extNetId: $networkData.floatingIpNetId - $fipName: format('Shared-Floating-ip-{0}', id($)) diff --git a/meta/io.murano/Classes/SharedIpRange.yaml b/meta/io.murano/Classes/SharedIpRange.yaml new file mode 100644 index 000000000..4d10851b2 --- /dev/null +++ b/meta/io.murano/Classes/SharedIpRange.yaml @@ -0,0 +1,81 @@ +# 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 + +Name: SharedIpRange +Extends: SharedIp + +Properties: + cidr: + Contract: $.string().notNull() + Usage: InOut + + +Methods: + initialize: + Body: + - $._environment: $.find(Environment).require() + + + deploy: + Body: + - If: not $.getAttr(deployed, false) + Then: + - $region: $.getRegion() + - $reporter: $._environment.reporter + + - $.deployNetwork() + - $networkData: $.network.describe() + + - $aapSubnetName: format('AllowedAddressPairsSubnet-{0}', id($)) + - $template: + resources: + $aapSubnetName: + type: 'OS::Neutron::Subnet' + properties: + enable_dhcp: false + network: $networkData.netId + cidr: $.cidr + outputs: + $aapSubnetName+'-cidr': + value: + get_attr: [$aapSubnetName, cidr] + description: format('Shared IP Range of group {0}', id($)) + + - $region.stack.updateTemplate($template) + + - $region.stack.push() + - $outputs: $region.stack.output() + - $.cidr: $outputs.get(format('AllowedAddressPairsSubnet-{0}-cidr', id($))) + - $.virtualIp: $outputs.get(format('AllowedAddressPairsSubnet-{0}-cidr', id($))) + - $reporter.report($this, format('Shared IP Range allocated at {0}', $.cidr)) + - $.setAttr(deployed, true) + + + getSharedIpRef: + Body: + - $aapSubnetName: format('AllowedAddressPairsSubnet-{0}', id($)) + - Return: + get_attr: [$aapSubnetName, cidr] + + + releaseResources: + Body: + - $region: $.getRegion() + - $template: $region.stack.current() + - $template.resources: $template.resources.delete(format('AllowedAddressPairsSubnet-{0}', id($))) + - $template.outputs: $template.outputs.delete(format('AllowedAddressPairsSubnet-{0}-cidr', id($))) + - $region.stack.setTemplate($template) + - $region.stack.push() + - $.cidr: null \ No newline at end of file diff --git a/meta/io.murano/Classes/resources/Instance.yaml b/meta/io.murano/Classes/resources/Instance.yaml index d099e373f..c8d396f39 100644 --- a/meta/io.murano/Classes/resources/Instance.yaml +++ b/meta/io.murano/Classes/resources/Instance.yaml @@ -259,10 +259,15 @@ Methods: Body: - $primary: $net = $._primaryNetwork - $assignFip: $primary and $.assignFloatingIp and not $.getAttr(fipAssigned, false) + - $sharedIps: [] - - If: $primary - Then: - $sharedIps: $.sharedIps + - For: sharedIp + In: $.sharedIps + Do: + - If: $sharedIp.network = $net + Then: + - $sharedIps: $sharedIps.append($sharedIp) + - $joinResult: $net.joinInstance( instance => $this, securityGroupName => $securityGroupName, diff --git a/meta/io.murano/Classes/resources/NeutronNetwork.yaml b/meta/io.murano/Classes/resources/NeutronNetwork.yaml index 5b6f2baac..c3bd2ac9d 100644 --- a/meta/io.murano/Classes/resources/NeutronNetwork.yaml +++ b/meta/io.murano/Classes/resources/NeutronNetwork.yaml @@ -219,7 +219,11 @@ Methods: _getExternalNetId: Body: - Return: $._getNetExplorer().getExternalNetworkIdForRouter($.externalRouterId) + - If: $.externalRouterId != null + Then: + Return: $._getNetExplorer().getExternalNetworkIdForRouter($.externalRouterId) + Else: + Return: null _getHeatName: Body: diff --git a/meta/io.murano/manifest.yaml b/meta/io.murano/manifest.yaml index 216f9f6a7..42f6e2187 100644 --- a/meta/io.murano/manifest.yaml +++ b/meta/io.murano/manifest.yaml @@ -34,6 +34,7 @@ Classes: io.murano.Exception: Exception.yaml io.murano.StackTrace: StackTrace.yaml io.murano.SharedIp: SharedIp.yaml + io.murano.SharedIpRange: SharedIpRange.yaml io.murano.File: File.yaml io.murano.User: User.yaml io.murano.Project: Project.yaml