diff --git a/MongoDB/package/Classes/MongoDB.yaml b/MongoDB/package/Classes/MongoDB.yaml index c86fcfd3..4968326b 100644 --- a/MongoDB/package/Classes/MongoDB.yaml +++ b/MongoDB/package/Classes/MongoDB.yaml @@ -15,6 +15,7 @@ Namespaces: std: io.murano res: io.murano.resources sys: io.murano.system + conf: io.murano.configuration Name: MongoDB @@ -53,49 +54,49 @@ Methods: External: true - $._environment.securityGroupManager.addGroupIngress($securityGroupIngress) - $.instance.deploy() - - $resources: new(sys:Resources) # Deploy MongoDB - - $template: $resources.yaml('DeployMongoDB.template') - $._environment.reporter.report($this, 'Deploying MongoDB.') - - $.instance.agent.call($template, $resources) + - conf:Linux.runCommand($.instance.agent, "sudo apt-get update && sudo apt-get -y install mongodb") # Configure MongoDB - - $template: $resources.yaml('ConfigureMongoDB.template') - $._environment.reporter.report($this, 'Configuring MongoDB.') - - $.instance.agent.call($template, $resources) + - $file: sys:Resources.string('configureMongoDB.sh') + - conf:Linux.runCommand($.instance.agent, $file) # Add firewall rules - - $template: $resources.yaml('AddFirewallRules.template') - $._environment.reporter.report($this, 'Adding firewall rules for MongoDB.') - - $.instance.agent.call($template, $resources) + - $file: sys:Resources.string('addFirewallRules.sh') + - conf:Linux.runCommand($.instance.agent, $file) # Create database on MongoDB - If: $.database != '' and $.database != null Then: - - $template: $resources.yaml('CreateMongoDBDatabase.template').bind(dict( - database => $.database - )) - $._environment.reporter.report($this, 'Creating database on MongoDB.') - - $.instance.agent.call($template, $resources) + - $replacement: + "%DATABASE%": $.database + - $file: sys:Resources.string('createMongoDBDatabase.sh').replace($replacement) + - conf:Linux.runCommand($.instance.agent, $file) # Create user for database - If: $.username != '' and $.username != null Then: - - $template: $resources.yaml('CreateUserForMongoDBDatabase.template').bind(dict( - database => $.database, - username => $.username, - password => $.password - )) - $._environment.reporter.report($this, 'Creating user for database on MongoDB.') - - $.instance.agent.call($template, $resources) + - $replacements: + "%DATABASE%": $.database + "%USERNAME%": $.username + "%PASSWORD%": $.password + - $file: sys:Resources.string('createUserForMongoDBDatabase.sh').replace($replacements) + - conf:Linux.runCommand($.instance.agent, $file) + + - conf:Linux.runCommand($.instance.agent, 'sudo rm -rf /tmp/murano') # Report MongoDB information - If: $.instance.assignFloatingIp Then: - $host: $.instance.floatingIpAddress Else: - - $host: $.instance.ipAddresses[0] + - $host: $.instance.ipAddresses.first() - $._environment.reporter.report($this, format('MongoDB is available at {0}:{1}.', $host, 27017)) - $._environment.reporter.report($this, format('MongoDB web admin endpoint is available at http://{0}:{1}.', $host, 28017)) - $.setAttr(deployed, true) diff --git a/MongoDB/package/Resources/AddFirewallRules.template b/MongoDB/package/Resources/AddFirewallRules.template deleted file mode 100644 index 9f59c771..00000000 --- a/MongoDB/package/Resources/AddFirewallRules.template +++ /dev/null @@ -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: Add Firewall Rules - -Parameters: - appName: $appName - -Body: | - return addFirewallRules(args.appName).stdout - -Scripts: - addFirewallRules: - Type: Application - Version: 1.0.0 - EntryPoint: addFirewallRules.sh - Files: [] - Options: - captureStdout: true - captureStderr: true diff --git a/MongoDB/package/Resources/ConfigureMongoDB.template b/MongoDB/package/Resources/ConfigureMongoDB.template deleted file mode 100644 index 659a3830..00000000 --- a/MongoDB/package/Resources/ConfigureMongoDB.template +++ /dev/null @@ -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: Configure MongoDB - -Parameters: - appName: $appName - -Body: | - return configureMongoDB(args.appName).stdout - -Scripts: - configureMongoDB: - Type: Application - Version: 1.0.0 - EntryPoint: configureMongoDB.sh - Files: [] - Options: - captureStdout: true - captureStderr: true diff --git a/MongoDB/package/Resources/CreateMongoDBDatabase.template b/MongoDB/package/Resources/CreateMongoDBDatabase.template deleted file mode 100644 index dbc50cc3..00000000 --- a/MongoDB/package/Resources/CreateMongoDBDatabase.template +++ /dev/null @@ -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 MongoDB database - -Parameters: - database: $database - -Body: | - return createMongoDBDatabase(args.database).stdout - -Scripts: - createMongoDBDatabase: - Type: Application - Version: 1.0.0 - EntryPoint: createMongoDBDatabase.sh - Files: [] - Options: - captureStdout: true - captureStderr: true diff --git a/MongoDB/package/Resources/CreateUserForMongoDBDatabase.template b/MongoDB/package/Resources/CreateUserForMongoDBDatabase.template deleted file mode 100644 index 93440878..00000000 --- a/MongoDB/package/Resources/CreateUserForMongoDBDatabase.template +++ /dev/null @@ -1,33 +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 user for MongoDB database - -Parameters: - database: $database - username: $username - password: $password - -Body: | - return createUserForMongoDBDatabase('{0} {1} {2}'.format(args.database, args.username, args.password)).stdout - -Scripts: - createUserForMongoDBDatabase: - Type: Application - Version: 1.0.0 - EntryPoint: createUserForMongoDBDatabase.sh - Files: [] - Options: - captureStdout: true - captureStderr: true diff --git a/MongoDB/package/Resources/DeployMongoDB.template b/MongoDB/package/Resources/DeployMongoDB.template deleted file mode 100644 index d638b35b..00000000 --- a/MongoDB/package/Resources/DeployMongoDB.template +++ /dev/null @@ -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 MongoDB - -Parameters: - appName: $appName - -Body: | - return deployMongoDB(args.appName).stdout - -Scripts: - deployMongoDB: - Type: Application - Version: 1.0.0 - EntryPoint: deployMongoDB.sh - Files: [] - Options: - captureStdout: true - captureStderr: true diff --git a/MongoDB/package/Resources/scripts/addFirewallRules.sh b/MongoDB/package/Resources/addFirewallRules.sh similarity index 100% rename from MongoDB/package/Resources/scripts/addFirewallRules.sh rename to MongoDB/package/Resources/addFirewallRules.sh diff --git a/MongoDB/package/Resources/scripts/configureMongoDB.sh b/MongoDB/package/Resources/configureMongoDB.sh similarity index 100% rename from MongoDB/package/Resources/scripts/configureMongoDB.sh rename to MongoDB/package/Resources/configureMongoDB.sh diff --git a/MongoDB/package/Resources/scripts/createMongoDBDatabase.sh b/MongoDB/package/Resources/createMongoDBDatabase.sh similarity index 97% rename from MongoDB/package/Resources/scripts/createMongoDBDatabase.sh rename to MongoDB/package/Resources/createMongoDBDatabase.sh index a44af906..bd6629a2 100644 --- a/MongoDB/package/Resources/scripts/createMongoDBDatabase.sh +++ b/MongoDB/package/Resources/createMongoDBDatabase.sh @@ -15,6 +15,6 @@ # the MongoDB database will be not really created, # so the default collection named system.users needs to be created. sudo mongo <