Files
deb-murano/meta/io.murano/Classes/resources/NeutronNetworkBase.yaml
Stan Lagun bb2d0e5a84 Support for multi-regional apps was added
Now all OpenStack resource classes inherit CloudResource
that provides getRegion method and regionName property.
This allows to assign resources to different regions.
getRegion() returns CloudRegion instance that resource or it
parent belong to. CloudRegion has the similar interface to
Environment class and is the correct way to get HeatStack
instance associated with the regoin, default network
configuration, security group manager and agent listener
instances. Environment acts as the default region so backward
compatibility is not broken. However new applications
should not use environment to set security group rules but
rather a region(s) of their instance(s) in order to work correctly
when their instances were configured to use region other then
the default.

Change-Id: I4dbf40c65042e9a354f3bfadfcd63a63e6e3e418
2016-08-12 07:09:58 -07:00

120 lines
3.9 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: NeutronNetworkBase
Extends: Network
Methods:
.init:
Body:
- $._environment: $.find(std:Environment)
- $._region: $.getRegion()
- $._netExplorer: new(sys:NetworkExplorer, $this)
- $._securityGroupsEnabled: $._netExplorer.listNeutronExtensions().alias.contains('security-group')
joinInstanceToNetwork:
Arguments:
- instance:
Contract: $.class(Instance).notNull()
- securityGroupName:
Contract: $.string()
- sharedIps:
Contract:
- $.class(std:SharedIp)
- netRef:
Contract: $
- subnetRef:
Contract: $
- floatingIpResourceName:
Contract: $.string()
- floatingIpNetRef:
Contract: $
Body:
- $portName: format('port-{0}-{1}', id($), $instance.name)
- $patchTemplate:
resources:
$portName:
type: 'OS::Neutron::Port'
properties:
network: $netRef
fixed_ips:
- subnet: $subnetRef
replacement_policy: AUTO
- If: bool($securityGroupName) and $this._securityGroupsEnabled
Then:
- $template:
resources:
$portName:
properties:
security_groups:
- get_resource: $securityGroupName
- $patchTemplate: $patchTemplate.mergeWith($template)
- $instanceResources: [$portName]
- $instanceOutputs: []
- For: sip
In: $sharedIps
Do:
- $template:
resources:
$portName:
properties:
allowed_address_pairs:
- ip_address: $sip.getSharedIpRef()
- $patchTemplate: $patchTemplate.mergeWith($template)
- $instanceFipOutput: null
- If: $floatingIpResourceName != null and $floatingIpNetRef != null
Then:
- $instanceFipOutput: $instance.name + '-floatingIPaddress'
- $template:
resources:
$floatingIpResourceName:
type: 'OS::Neutron::FloatingIP'
properties:
floating_network: $floatingIpNetRef
port_id:
get_resource: $portName
outputs:
$instanceFipOutput:
value:
get_attr: [$floatingIpResourceName, floating_ip_address]
description: format('Floating IP of {0}', $instance.name)
- $instanceResources: $instanceResources.append($floatingIpResourceName)
- $instanceOutputs: $instanceOutputs.append($instanceFipOutput)
- $patchTemplate: $patchTemplate.mergeWith($template)
- Return:
template: $patchTemplate
portRef:
get_resource: $portName
instanceFipOutput: $instanceFipOutput
instanceResources: $instanceResources
instanceOutputs: $instanceOutputs
generateSecurityGroupManager:
Body:
- If: $this._securityGroupsEnabled
Then:
- Return: new(sys:NeutronSecurityGroupManager, $._region)
Else:
- $._environment.reporter.report($this, "Warning! Security groups are disabled!")
- Return: new(sys:DummySecurityGroupManager, $._region)