[MySql] Use simple software configuration
Change-Id: I6a0f061a56f6bb96b106ed95d8f0ce8288176cdb Partially-Implements: bp refactor-apps-scripts
This commit is contained in:
parent
3b51222b09
commit
7df4b8b0ee
|
@ -15,6 +15,7 @@ Namespaces:
|
|||
std: io.murano
|
||||
res: io.murano.resources
|
||||
sys: io.murano.system
|
||||
conf: io.murano.configuration
|
||||
|
||||
Name: MySql
|
||||
|
||||
|
@ -48,11 +49,10 @@ Methods:
|
|||
External: true
|
||||
- $._environment.securityGroupManager.addGroupIngress($securityGroupIngress)
|
||||
- $.instance.deploy()
|
||||
- $resources: new(sys:Resources)
|
||||
# Deploy MySql
|
||||
- $._environment.reporter.report($this, 'Instance is created. Deploying MySql')
|
||||
- $template: $resources.yaml('DeployMySql.template')
|
||||
- $.instance.agent.call($template, $resources)
|
||||
- $file: sys:Resources.string('deployMySql.sh')
|
||||
- conf:Linux.runCommand($.instance.agent, $file)
|
||||
- $._environment.reporter.report($this, 'MySql application is installed.')
|
||||
- $.setAttr(deployed, true)
|
||||
- $._environment.reporter.report($this, 'Creating database and user.')
|
||||
|
@ -71,7 +71,7 @@ Methods:
|
|||
Then:
|
||||
- $host: $.instance.floatingIpAddress
|
||||
Else:
|
||||
- $host: $.instance.ipAddresses[0]
|
||||
- $host: $.instance.ipAddresses.first()
|
||||
- $._environment.reporter.report($this, format('MySQL is available at {0}', $host))
|
||||
|
||||
createDatabase:
|
||||
|
@ -81,12 +81,13 @@ Methods:
|
|||
Body:
|
||||
- $.deploy()
|
||||
- $._environment.reporter.report($this, format('Creating {0} database.', $database))
|
||||
|
||||
# Creating Database on MySQL
|
||||
- $resources: new(sys:Resources)
|
||||
- $template: $resources.yaml('CreateMySqlDatabase.template').bind(dict(
|
||||
database => $database
|
||||
))
|
||||
- $.instance.agent.call($template, $resources)
|
||||
- $replacement:
|
||||
"%DATABASE%": $database
|
||||
- $file: sys:Resources.string('createMySqlDatabase.sh').replace($replacement)
|
||||
- conf:Linux.runCommand($.instance.agent, $file)
|
||||
|
||||
- $._environment.reporter.report($this, format('Database {0} created.', $database))
|
||||
|
||||
createUser:
|
||||
|
@ -98,13 +99,14 @@ Methods:
|
|||
Body:
|
||||
- $.deploy()
|
||||
- $._environment.reporter.report($this, format('Creating {0} user.', $username))
|
||||
|
||||
# Creating user on MySQL
|
||||
- $resources: new(sys:Resources)
|
||||
- $template: $resources.yaml('CreateMySqlUser.template').bind(dict(
|
||||
username => $username,
|
||||
password => $password
|
||||
))
|
||||
- $.instance.agent.call($template, $resources)
|
||||
- $replacements:
|
||||
"%USER_NAME%": $username
|
||||
"%PASSWORD%": $password
|
||||
- $file: sys:Resources.string('createMySqlUser.sh').replace($replacements)
|
||||
- conf:Linux.runCommand($.instance.agent, $file)
|
||||
|
||||
- $._environment.reporter.report($this, format('User {0} created', $username))
|
||||
|
||||
assignUser:
|
||||
|
@ -116,13 +118,14 @@ Methods:
|
|||
Body:
|
||||
- $.deploy()
|
||||
- $._environment.reporter.report($this, format('Assigning user {0} to database {1}.', $username, $database))
|
||||
|
||||
# Assigning user to MySQL database
|
||||
- $resources: new(sys:Resources)
|
||||
- $template: $resources.yaml('AssignUserMySql.template').bind(dict(
|
||||
username => $username,
|
||||
database => $database
|
||||
))
|
||||
- $.instance.agent.call($template, $resources)
|
||||
- $replacements:
|
||||
"%USER_NAME%": $username
|
||||
"%DB_NAME%": $database
|
||||
- $file: sys:Resources.string('assignMySqlUser.sh').replace($replacements)
|
||||
- conf:Linux.runCommand($.instance.agent, $file)
|
||||
|
||||
- $._environment.reporter.report($this, format('User {0} assigned to database {1}.', $username, $database))
|
||||
|
||||
getConnectionString:
|
||||
|
@ -136,5 +139,5 @@ Methods:
|
|||
Then:
|
||||
- $host: $.instance.floatingIpAddress
|
||||
Else:
|
||||
- $host: $.instance.ipAddresses[0]
|
||||
- $host: $.instance.ipAddresses.first()
|
||||
- Return: format('mysql://{0}@{1}:{2}', $username, $password, $host)
|
||||
|
|
|
@ -1,32 +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.
|
||||
|
||||
FormatVersion: 2.0.0
|
||||
Version: 1.0.0
|
||||
Name: Assign user to MySql database
|
||||
|
||||
Parameters:
|
||||
database: $database
|
||||
username: $username
|
||||
|
||||
Body: |
|
||||
return assignUser('{0} {1}'.format(args.database, args.username)).stdout
|
||||
|
||||
Scripts:
|
||||
assignUser:
|
||||
Type: Application
|
||||
Version: 1.0.0
|
||||
EntryPoint: assignMySqlUser.sh
|
||||
Files: []
|
||||
Options:
|
||||
captureStdout: true
|
||||
captureStderr: true
|
|
@ -1,31 +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.
|
||||
|
||||
FormatVersion: 2.0.0
|
||||
Version: 1.0.0
|
||||
Name: Create MySql database
|
||||
|
||||
Parameters:
|
||||
database: $database
|
||||
|
||||
Body: |
|
||||
return createDatabase(args.database).stdout
|
||||
|
||||
Scripts:
|
||||
createDatabase:
|
||||
Type: Application
|
||||
Version: 1.0.0
|
||||
EntryPoint: createMySqlDatabase.sh
|
||||
Files: []
|
||||
Options:
|
||||
captureStdout: true
|
||||
captureStderr: true
|
|
@ -1,32 +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.
|
||||
|
||||
FormatVersion: 2.0.0
|
||||
Version: 1.0.0
|
||||
Name: Create MySql user
|
||||
|
||||
Parameters:
|
||||
username: $username
|
||||
password: $password
|
||||
|
||||
Body: |
|
||||
return createUser('{0} {1}'.format(args.username, args.password)).stdout
|
||||
|
||||
Scripts:
|
||||
createUser:
|
||||
Type: Application
|
||||
Version: 1.0.0
|
||||
EntryPoint: createMySqlUser.sh
|
||||
Files: []
|
||||
Options:
|
||||
captureStdout: true
|
||||
captureStderr: true
|
|
@ -1,31 +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.
|
||||
|
||||
FormatVersion: 2.0.0
|
||||
Version: 1.0.0
|
||||
Name: Deploy MySql
|
||||
|
||||
Parameters:
|
||||
appName: $appName
|
||||
|
||||
Body: |
|
||||
return deploy(args.appName).stdout
|
||||
|
||||
Scripts:
|
||||
deploy:
|
||||
Type: Application
|
||||
Version: 1.0.0
|
||||
EntryPoint: deployMySql.sh
|
||||
Files: []
|
||||
Options:
|
||||
captureStdout: true
|
||||
captureStderr: true
|
|
@ -11,6 +11,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
mysql --user=root --password=root -e "GRANT ALL PRIVILEGES ON $1.* TO '$2'@'localhost' WITH GRANT OPTION"
|
||||
mysql --user=root --password=root -e "GRANT ALL PRIVILEGES ON $1.* TO '$2'@'%' WITH GRANT OPTION"
|
||||
mysql --user=root --password=root -e "GRANT ALL PRIVILEGES ON %DB_NAME%.* TO '%USER_NAME%'@'localhost' WITH GRANT OPTION"
|
||||
mysql --user=root --password=root -e "GRANT ALL PRIVILEGES ON %DB_NAME%.* TO '%USER_NAME%'@'%' WITH GRANT OPTION"
|
||||
mysql --user=root --password=root -e "FLUSH PRIVILEGES"
|
|
@ -11,4 +11,4 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
mysql --user=root --password=root -e "CREATE DATABASE \`$1\`"
|
||||
mysql --user=root --password=root -e "CREATE DATABASE \`%DATABASE%\`"
|
|
@ -11,5 +11,5 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
mysql --user=root --password=root -e "CREATE USER '$1'@'localhost' IDENTIFIED BY '$2'"
|
||||
mysql --user=root --password=root -e "CREATE USER '$1'@'%' IDENTIFIED BY '$2'"
|
||||
mysql --user=root --password=root -e "CREATE USER '%USER_NAME%'@'localhost' IDENTIFIED BY '%PASSWORD%'"
|
||||
mysql --user=root --password=root -e "CREATE USER '%USER_NAME%'@'%' IDENTIFIED BY '%PASSWORD%'"
|
|
@ -10,6 +10,7 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
set -e
|
||||
|
||||
sudo apt-get update
|
||||
|
Loading…
Reference in New Issue