Changing architecture of LBaaS packages
* LBaaS library is separate package now, it includes: - deploy method (implements all needed deployment workflow for LBaaS) - install LBaaS method - configure LBaaS method (for optional configuration) - start LBaaS method - get credentials method (for service broker) * Now it is possible to create package extending LBaaS library by overriding just 3 methods: - installLoadBalancer - installLBaaS - getOptionalConfig (for detailed configuration) * Minor changes for liberty compatibility: - "Require" key in manifest - using ".init" method instead of "initialize" TODO: - include LBaaS API python package in murano LBaaS package Change-Id: I6fe3e98c6876d3e57c5cca7f826ef0f8932f77bb
This commit is contained in:
parent
32bf60add2
commit
c668552045
145
murano-apps/LBaaS-interface/Classes/LoadBalancer.yaml
Normal file
145
murano-apps/LBaaS-interface/Classes/LoadBalancer.yaml
Normal file
@ -0,0 +1,145 @@
|
||||
# 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.apps.lbaas
|
||||
std: io.murano
|
||||
res: io.murano.resources
|
||||
sys: io.murano.system
|
||||
|
||||
|
||||
Name: LBaaS
|
||||
|
||||
Extends: std:Application
|
||||
|
||||
Properties:
|
||||
|
||||
name:
|
||||
Contract: $.string().notNull()
|
||||
|
||||
instance:
|
||||
Contract: $.class(res:Instance).notNull()
|
||||
|
||||
implementation:
|
||||
Contract: $.string()
|
||||
Default: null
|
||||
|
||||
environment:
|
||||
Contract: $.class(std:Environment)
|
||||
Usage: Runtime
|
||||
|
||||
url:
|
||||
Contract: $.string()
|
||||
Usage: Out
|
||||
|
||||
Methods:
|
||||
.init:
|
||||
Body:
|
||||
- $.environment: $.find(std:Environment).require()
|
||||
|
||||
deploy:
|
||||
Body:
|
||||
- If: $.getAttr(deployed, false)
|
||||
Then:
|
||||
Return: 0
|
||||
|
||||
- $.environment.reporter.report($this, 'Creating security groups...')
|
||||
- $securityGroupIngress:
|
||||
- ToPort: 65535
|
||||
FromPort: 1
|
||||
IpProtocol: tcp
|
||||
External: true
|
||||
- $.environment.securityGroupManager.addGroupIngress($securityGroupIngress)
|
||||
- $.environment.reporter.report($this, 'Creating instance for LBaaS...')
|
||||
- $.instance.deploy()
|
||||
- $.environment.reporter.report($this, 'Instance is created.')
|
||||
- $resources: new(sys:Resources)
|
||||
- $.installLoadBalancer()
|
||||
- $lbaas: $.installLBaaS($.implementation)
|
||||
- $.configureLBaaS()
|
||||
- $.startLBaaS()
|
||||
- If: $.instance.assignFloatingIp
|
||||
Then:
|
||||
- $host: $.instance.floatingIpAddress
|
||||
Else:
|
||||
- $host: $.instance.ipAddresses[0]
|
||||
- $.url: format("http://{0}:{1}{2}", $host, $lbaas.port, $lbaas.path)
|
||||
- $.environment.reporter.report($this, format("LBaaS is available at {0}", $.url))
|
||||
- $.setAttr(deployed, true)
|
||||
|
||||
getCredentials:
|
||||
Usage: Action
|
||||
Body:
|
||||
- Return:
|
||||
credentials:
|
||||
uri: $.url
|
||||
|
||||
getOptionalConfig:
|
||||
# Returns a list of dicts containing 'section', 'key' and 'value' keys.
|
||||
Body:
|
||||
- Return: []
|
||||
|
||||
setConfigValue:
|
||||
Arguments:
|
||||
- section:
|
||||
Contract: $.string().notNull()
|
||||
- key:
|
||||
Contract: $.string().notNull()
|
||||
- value:
|
||||
Contract: $.string().notNull()
|
||||
Body:
|
||||
- $.environment.reporter.report(
|
||||
$this,
|
||||
'Setting value [{0}] {1} = {2}'.format($section, $key, $value)
|
||||
)
|
||||
- $resources: new(sys:Resources)
|
||||
- $template: $resources.yaml('SetConfigValue.template').bind(dict(
|
||||
section => $section,
|
||||
key => $key,
|
||||
value => $value))
|
||||
- $.instance.agent.call($template, $resources)
|
||||
|
||||
installLoadBalancer:
|
||||
# Installs Load Balancer related stuff (e.g. system packages).
|
||||
|
||||
installLBaaS:
|
||||
# Installs LBaaS itself and its drivers on an instance.
|
||||
Arguments:
|
||||
- implementation:
|
||||
Contract: $.string().notNull()
|
||||
Body:
|
||||
- $resources: new(sys:Resources)
|
||||
- $template: $resources.yaml('DeployLBaaS.template').bind(dict(
|
||||
impl => $.implementation
|
||||
))
|
||||
- $.environment.reporter.report($this, 'Installing LBaaS...')
|
||||
- $.instance.agent.call($template, $resources)
|
||||
- $.setConfigValue('lbaas', 'impl', $.implementation)
|
||||
- $.environment.reporter.report($this, 'LBaaS is installed.')
|
||||
- Return:
|
||||
port: 8993
|
||||
path: /v1
|
||||
|
||||
configureLBaaS:
|
||||
Body:
|
||||
- $.environment.reporter.report($this, 'Configuring LBaaS...')
|
||||
# Call setConfigValue for each item in OptionalConfig.
|
||||
- $.getOptionalConfig().select($this.setConfigValue($.section, $.key, $.value))
|
||||
- $.environment.reporter.report($this, 'Configured.')
|
||||
|
||||
startLBaaS:
|
||||
Body:
|
||||
- $resources: new(sys:Resources)
|
||||
- $template: $resources.yaml('StartLBaaS.template')
|
||||
- $.environment.reporter.report($this, 'Starting LBaaS...')
|
||||
- $.instance.agent.call($template, $resources)
|
||||
- $.environment.reporter.report($this, 'LBaaS is started.')
|
@ -0,0 +1,27 @@
|
||||
FormatVersion: 2.0.0
|
||||
Version: 1.0.0
|
||||
Name: Set Config Value
|
||||
|
||||
Parameters:
|
||||
section: $section
|
||||
key: $key
|
||||
value: $value
|
||||
|
||||
Body: |
|
||||
return SetConfigValue(
|
||||
'{0} {1} {2}'.format(
|
||||
args.section,
|
||||
args.key,
|
||||
args.value
|
||||
)
|
||||
).stdout
|
||||
|
||||
Scripts:
|
||||
SetConfigValue:
|
||||
Type: Application
|
||||
Version: 1.0.0
|
||||
EntryPoint: setConfigValue.sh
|
||||
Files: []
|
||||
Options:
|
||||
captureStdout: true
|
||||
captureStderr: true
|
16
murano-apps/LBaaS-interface/Resources/StartLBaaS.template
Normal file
16
murano-apps/LBaaS-interface/Resources/StartLBaaS.template
Normal file
@ -0,0 +1,16 @@
|
||||
FormatVersion: 2.0.0
|
||||
Version: 1.0.0
|
||||
Name: Start LBaaS
|
||||
|
||||
Body: |
|
||||
return LBaasStart().stdout
|
||||
|
||||
Scripts:
|
||||
LBaasStart:
|
||||
Type: Application
|
||||
Version: 1.0.0
|
||||
EntryPoint: startLBaaS.sh
|
||||
Files: []
|
||||
Options:
|
||||
captureStdout: true
|
||||
captureStderr: true
|
@ -29,9 +29,6 @@ sed -i 's/#verbose = false/verbose = true/g' etc/lbaas.conf
|
||||
sed -i 's/#default_log_levels/default_log_levels/g' etc/lbaas.conf
|
||||
sed -i 's/#log_file = <None>/log_file = \/var\/log\/lbaas.log/g' etc/lbaas.conf
|
||||
|
||||
# Configure lbaas impl.
|
||||
sed -i "s/#impl = haproxy/impl = $impl/g" etc/lbaas.conf
|
||||
|
||||
# Configure database connection.
|
||||
mysql --user=root --password=root -e "CREATE DATABASE lbaas;"
|
||||
mysql --user=root --password=root -e "GRANT ALL ON lbaas.* TO 'root'@'localhost';"
|
||||
@ -49,8 +46,3 @@ sudo chown -R $USER:$USER /etc/lbaas
|
||||
sudo chown /var/log/lbaas.log
|
||||
|
||||
mv etc/lbaas.conf /etc/lbaas/lbaas.conf
|
||||
|
||||
cd ~
|
||||
|
||||
# Start lbaas.
|
||||
lbaas-server --config-file /etc/lbaas/lbaas.conf >> lbaas.log 2>&1 &
|
@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
section=$1
|
||||
key=$2
|
||||
value=$3
|
||||
|
||||
# Set value in lbaas config file.
|
||||
sudo sed -i "/^\[$section\]$/,/^\[/ s/^#*$key.*=.*/$key = $value/" /etc/lbaas/lbaas.conf
|
@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd ~
|
||||
|
||||
# Start lbaas.
|
||||
lbaas-server --config-file /etc/lbaas/lbaas.conf >> lbaas.log 2>&1 &
|
22
murano-apps/LBaaS-interface/manifest.yaml
Normal file
22
murano-apps/LBaaS-interface/manifest.yaml
Normal file
@ -0,0 +1,22 @@
|
||||
# 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.
|
||||
|
||||
Format: 1.0
|
||||
Type: Library
|
||||
FullName: io.murano.apps.lbaas.LBaaS
|
||||
Name: LBaaS library
|
||||
Description: |
|
||||
Load Balancing as a Service library.
|
||||
Author: 'Mirantis, Inc'
|
||||
Tags: [HTTP, TCP, Load Balancing as a Service, HAProxy]
|
||||
Classes:
|
||||
io.murano.apps.lbaas.LBaaS: LoadBalancer.yaml
|
@ -18,36 +18,17 @@ Namespaces:
|
||||
|
||||
Name: HAProxy
|
||||
|
||||
Extends: LoadBalancer
|
||||
|
||||
Properties:
|
||||
|
||||
name:
|
||||
Contract: $.string().notNull()
|
||||
|
||||
implementation:
|
||||
Contract: $.string()
|
||||
Default: haproxy
|
||||
Extends: LBaaS
|
||||
|
||||
Methods:
|
||||
.init:
|
||||
Body:
|
||||
- $.implementation: haproxy
|
||||
|
||||
installLoadBalancer:
|
||||
Body:
|
||||
- $resources: new(sys:Resources)
|
||||
- $template: $resources.yaml('DeployHAProxy.template')
|
||||
- $.environment.reporter.report($this, 'Installing HAProxy')
|
||||
- $.environment.reporter.report($this, 'Installing HAProxy...')
|
||||
- $.instance.agent.call($template, $resources)
|
||||
- $.environment.reporter.report($this, 'HAProxy is installed.')
|
||||
|
||||
installLBaaS:
|
||||
Body:
|
||||
- $resources: new(sys:Resources)
|
||||
- $template: $resources.yaml('DeployLBaaS.template').bind(dict(
|
||||
impl => $.implementation
|
||||
))
|
||||
- $.environment.reporter.report($this, 'Installing LBaaS...')
|
||||
- $.instance.agent.call($template, $resources)
|
||||
- $.environment.reporter.report($this, 'LBaaS is installed and started.')
|
||||
- Return:
|
||||
port: 8993
|
||||
path: /v1
|
||||
|
||||
|
@ -1,87 +0,0 @@
|
||||
# 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.apps.lbaas
|
||||
std: io.murano
|
||||
res: io.murano.resources
|
||||
sys: io.murano.system
|
||||
|
||||
|
||||
Name: LoadBalancer
|
||||
|
||||
Extends: std:Application
|
||||
|
||||
Properties:
|
||||
|
||||
name:
|
||||
Contract: $.string().notNull()
|
||||
|
||||
instance:
|
||||
Contract: $.class(res:Instance).notNull()
|
||||
|
||||
implementation:
|
||||
Contract: $.string()
|
||||
Default: null
|
||||
Usage: Runtime
|
||||
|
||||
environment:
|
||||
Contract: $.class(std:Environment)
|
||||
Usage: Runtime
|
||||
|
||||
url:
|
||||
Contract: $.string()
|
||||
Usage: Out
|
||||
|
||||
Methods:
|
||||
initialize:
|
||||
Body:
|
||||
- $.environment: $.find(std:Environment).require()
|
||||
|
||||
deploy:
|
||||
Body:
|
||||
- If: $.getAttr(deployed, false)
|
||||
Then:
|
||||
Return: 0
|
||||
|
||||
- $.environment.reporter.report($this, 'Creating security groups...')
|
||||
- $securityGroupIngress:
|
||||
- ToPort: 65535
|
||||
FromPort: 1
|
||||
IpProtocol: tcp
|
||||
External: true
|
||||
- $.environment.securityGroupManager.addGroupIngress($securityGroupIngress)
|
||||
- $.environment.reporter.report($this, 'Creating instance for load balancer...')
|
||||
- $.instance.deploy()
|
||||
- $.environment.reporter.report($this, 'Instance is created.')
|
||||
- $resources: new(sys:Resources)
|
||||
- $.installLoadBalancer()
|
||||
- $lbaas: $.installLBaaS()
|
||||
- If: $.instance.assignFloatingIp
|
||||
Then:
|
||||
- $host: $.instance.floatingIpAddress
|
||||
Else:
|
||||
- $host: $.instance.ipAddresses[0]
|
||||
- $.url: format('http://{0}:{1}{2}', $host, $lbaas.port, $lbaas.path)
|
||||
- $.environment.reporter.report($this, format('LBaaS is available at {0}', $.url))
|
||||
- $.setAttr(deployed, true)
|
||||
|
||||
getCredentials:
|
||||
Usage: Action
|
||||
Body:
|
||||
- Return:
|
||||
credentials:
|
||||
uri: $.url
|
||||
|
||||
installLoadBalancer:
|
||||
|
||||
installLBaaS:
|
@ -4,7 +4,6 @@ Application:
|
||||
?:
|
||||
type: io.murano.apps.lbaas.HAProxy
|
||||
name: $.appConfiguration.name
|
||||
implementation: $.appConfiguration.LBaasImpl
|
||||
instance:
|
||||
?:
|
||||
type: io.murano.resources.LinuxMuranoInstance
|
||||
@ -25,22 +24,12 @@ Forms:
|
||||
description: >-
|
||||
Enter a desired name for the application. Just A-Z, a-z, 0-9, dash and
|
||||
underline are allowed
|
||||
- name: LBaasImpl
|
||||
label: Load Balancer implementation.
|
||||
type: string
|
||||
description: >-
|
||||
Specify Load balancer implementation for this current LBaaS. Only 'haproxy' is available now.
|
||||
initial: haproxy
|
||||
regexpValidator: '^haproxy$'
|
||||
errorMessages:
|
||||
invalid: Only 'haproxy' is available now.
|
||||
required: true
|
||||
- name: assignFloatingIP
|
||||
type: boolean
|
||||
label: Assign Floating IP
|
||||
description: >-
|
||||
Select to true to assign floating IP automatically
|
||||
initial: false
|
||||
initial: true
|
||||
required: false
|
||||
widgetMedia:
|
||||
css: {all: ['muranodashboard/css/checkbox.css']}
|
||||
|
@ -21,5 +21,6 @@ Description: |
|
||||
Author: 'Mirantis, Inc'
|
||||
Tags: [HTTP, TCP, Load Balancing as a Service, HAProxy]
|
||||
Classes:
|
||||
io.murano.apps.lbaas.HAProxy: HAProxy.yaml
|
||||
io.murano.apps.lbaas.LoadBalancer: LoadBalancer.yaml
|
||||
io.murano.apps.lbaas.HAProxy: HAProxy.yaml
|
||||
Require:
|
||||
io.murano.apps.lbaas.LBaaS:
|
||||
|
Loading…
x
Reference in New Issue
Block a user