Support shared IP address range

* Add support for range of shared IPs using
  new class SharedIpRange

* Add support for shared IPs on non-external
  networks, floating IP not available in
  this case

Change-Id: I7faa946e99d0070c375408b7f18546a281c668d4
Closes-Bug: #1727349
This commit is contained in:
Gerry Buteau 2017-10-26 11:05:23 -04:00 committed by Felipe Monteiro
parent e6c024f977
commit 823ec20003
5 changed files with 114 additions and 8 deletions

View File

@ -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($))

View File

@ -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

View File

@ -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,

View File

@ -219,7 +219,11 @@ Methods:
_getExternalNetId:
Body:
Return: $._getNetExplorer().getExternalNetworkIdForRouter($.externalRouterId)
- If: $.externalRouterId != null
Then:
Return: $._getNetExplorer().getExternalNetworkIdForRouter($.externalRouterId)
Else:
Return: null
_getHeatName:
Body:

View File

@ -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