Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 1 | var normativeTypesRootYml = "tosca_definitions_version: tosca_simple_yaml_1_0_0_wd03"+ |
| 2 | |
| 3 | "template_name: tosca-normative-types-root"+ |
| 4 | "template_author: TOSCA TC"+ |
| 5 | "template_version: 1.0.0.wd03-SNAPSHOT"+ |
| 6 | "description: Contains the normative types definition."+ |
| 7 | "node_types:"+ |
| 8 | " tosca.nodes.Root:"+ |
| 9 | " abstract: true"+ |
| 10 | " description: >"+ |
| 11 | " This is the default (root) TOSCA Node Type that all other TOSCA nodes should extends."+ |
| 12 | " This allows all TOSCA nodes to have a consistent set of features for modeling and management"+ |
| 13 | " (e.g, consistent definitions for requirements, capabilities, and lifecycle interfaces)."+ |
| 14 | " tags:"+ |
| 15 | " icon: /images/root.png"+ |
| 16 | " attributes:"+ |
| 17 | " tosca_id:"+ |
| 18 | " type: string"+ |
| 19 | " tosca_name:"+ |
| 20 | " type: string"+ |
| 21 | " requirements:"+ |
| 22 | " dependency:"+ |
| 23 | " type: tosca.capabilities.Root"+ |
| 24 | " lower_bound: 0"+ |
| 25 | " upper_bound: unbounded"+ |
| 26 | " capabilities:"+ |
| 27 | " root:"+ |
| 28 | " type: tosca.capabilities.Root"+ |
| 29 | " interfaces:"+ |
| 30 | " tosca.interfaces.node.lifecycle.Standard:"+ |
| 31 | " description: >"+ |
| 32 | " This lifecycle interface defines the essential, normative operations that TOSCA nodes may support."+ |
| 33 | " create:"+ |
| 34 | " description: Standard lifecycle create operation."+ |
| 35 | " configure:"+ |
| 36 | " description: Standard lifecycle configure operation (pre-start)."+ |
| 37 | " start:"+ |
| 38 | " description: Standard lifecycle start operation."+ |
| 39 | " post_start:"+ |
| 40 | " description: Standard lifecycle post-configure operation (post-start)"+ |
| 41 | " stop:"+ |
| 42 | " description: Standard lifecycle stop operation."+ |
| 43 | " delete:"+ |
| 44 | " description: Standard lifecycle delete operation."+ |
| 45 | "capability_types:"+ |
| 46 | " tosca.capabilities.Root:"+ |
| 47 | " description: This is the default (root) TOSCA Capability Type definition that all other TOSCA Capability Types derive from."+ |
| 48 | "relationship_types:"+ |
| 49 | " tosca.relationships.Root:"+ |
| 50 | " abstract: true"+ |
| 51 | " description: This is the default (root) TOSCA Relationship Type definition that all other TOSCA Relationship Types derive from."+ |
| 52 | " valid_targets: [ tosca.capabilities.Root ]"+ |
| 53 | " attributes:"+ |
| 54 | " tosca_id:"+ |
| 55 | " type: string"+ |
| 56 | " tosca_name:"+ |
| 57 | " type: string"+ |
| 58 | " interfaces:"+ |
| 59 | " tosca.interfaces.relationship.Configure:"+ |
| 60 | " description: >"+ |
| 61 | " The lifecycle interfaces define the essential, normative operations that each TOSCA Relationship Types may support."+ |
| 62 | " pre_configure_source:"+ |
| 63 | " description: Operation to pre-configure the source endpoint."+ |
| 64 | " pre_configure_target:"+ |
| 65 | " description: Operation to pre-configure the target endpoint."+ |
| 66 | " post_configure_source:"+ |
| 67 | " description: Operation to post-configure the source endpoint."+ |
| 68 | " post_configure_target:"+ |
| 69 | " description: Operation to post-configure the target endpoint."+ |
| 70 | " add_target:"+ |
| 71 | " description: Operation to notify the source node of a target node being added via a relationship."+ |
| 72 | " add_source:"+ |
| 73 | " description: Operation to notify the target node of a source node which is now available via a relationship."+ |
| 74 | " remove_target:"+ |
| 75 | " description: Operation to notify the source node of a target node being removed from a relationship."+ |
| 76 | " remove_source:"+ |
| 77 | " description: Operation to notify the target node of a source node being removed from a relationship."+ |
| 78 | " target_changed:"+ |
| 79 | " description: Operation to notify source some property or attribute of the target."+ |
| 80 | " source_changed:"+ |
| 81 | " description: Operation to notify target some property or attribute of the source."+ |
| 82 | "artifact_types:"+ |
| 83 | " tosca.artifacts.Root:"+ |
| 84 | " description: The TOSCA Artifact Type all other TOSCA Artifact Types derive from."; |
| 85 | |
| 86 | |
| 87 | var mysqlTypeYml = |
| 88 | "tosca_definitions_version: tosca_simple_yaml_1_0_0_wd03"+ |
| 89 | "description: MySQL RDBMS installation on a specific mounted volume path."+ |
| 90 | "template_name: mysql-type"+ |
| 91 | "template_version: 2.0.0-SNAPSHOT"+ |
| 92 | "template_author: FastConnect"+ |
| 93 | |
| 94 | "imports:"+ |
| 95 | ' - "tosca-normative-types:1.0.0.wd03-SNAPSHOT"'+ |
| 96 | |
| 97 | "node_types:"+ |
| 98 | " alien.nodes.Mysql:"+ |
| 99 | " derived_from: tosca.nodes.Database"+ |
| 100 | " description: >"+ |
| 101 | " A node to install MySQL v5.5 database with data"+ |
| 102 | " on a specific attached volume."+ |
| 103 | " capabilities:"+ |
| 104 | " host:"+ |
| 105 | " type: alien.capabilities.MysqlDatabase"+ |
| 106 | " properties:"+ |
| 107 | " valid_node_types: [ tosca.nodes.WebApplication ]"+ |
| 108 | " requirements:"+ |
| 109 | " - host: tosca.nodes.Compute"+ |
| 110 | " type: tosca.relationships.HostedOn"+ |
| 111 | " tags:"+ |
| 112 | " icon: /images/mysql.png"+ |
| 113 | " properties:"+ |
| 114 | " db_port:"+ |
| 115 | " type: integer"+ |
| 116 | " default: 3306"+ |
| 117 | " description: The port on which the underlying database service will listen to data."+ |
| 118 | " db_name:"+ |
| 119 | " type: string"+ |
| 120 | " required: true"+ |
| 121 | " default: wordpress"+ |
| 122 | " description: The logical name of the database."+ |
| 123 | " db_user:"+ |
| 124 | " type: string"+ |
| 125 | " default: pass"+ |
| 126 | " description: The special user account used for database administration."+ |
| 127 | " db_password:"+ |
| 128 | " type: string"+ |
| 129 | " default: pass"+ |
| 130 | " description: The password associated with the user account provided in the ‘db_user’ property."+ |
| 131 | " bind_address:"+ |
| 132 | " type: boolean"+ |
| 133 | " default: true"+ |
| 134 | " required: false"+ |
| 135 | " description: If true,the server accepts TCP/IP connections on all server host IPv4 interfaces."+ |
| 136 | " storage_path:"+ |
| 137 | " type: string"+ |
| 138 | " default: /mountedStorage"+ |
| 139 | " constraints:"+ |
| 140 | ' - valid_values: [ "/mountedStorage", "/var/mysql" ]'+ |
| 141 | " interfaces:"+ |
| 142 | " Standard:"+ |
| 143 | " create: scripts/install_mysql.sh"+ |
| 144 | " start:"+ |
| 145 | " inputs:"+ |
| 146 | " VOLUME_HOME: { get_property: [SELF, storage_path] }"+ |
| 147 | " PORT: { get_property: [SELF, db_port] }"+ |
| 148 | " DB_NAME: { get_property: [SELF, db_name] }"+ |
| 149 | " DB_USER: { get_property: [SELF, db_user] }"+ |
| 150 | " DB_PASSWORD: { get_property: [SELF, db_password] }"+ |
| 151 | " BIND_ADRESS: { get_property: [SELF, bind_address] }"+ |
| 152 | " implementation: scripts/start_mysql.sh"+ |
| 153 | " "+ |
| 154 | "capability_types:"+ |
| 155 | " alien.capabilities.MysqlDatabase:"+ |
| 156 | " derived_from: tosca.capabilities.Container"; |
| 157 | |
| 158 | |
| 159 | var installMySqlSH = |
| 160 | '#!/bin/bash'+ |
| 161 | |
| 162 | 'echo "Debian based MYSQL install 5..."'+ |
| 163 | 'LOCK="/tmp/lockaptget"'+ |
| 164 | |
| 165 | 'while true; do'+ |
| 166 | ' if mkdir "${LOCK}" &>/dev/null; then'+ |
| 167 | ' echo "MySQL take the lock"'+ |
| 168 | ' break;'+ |
| 169 | ' fi'+ |
| 170 | ' echo "Waiting the end of one of our recipes..."'+ |
| 171 | ' sleep 0.5'+ |
| 172 | 'done'+ |
| 173 | |
| 174 | 'while sudo fuser /var/lib/dpkg/lock >/dev/null 2>&1 ; do'+ |
| 175 | ' echo "Waiting for other software managers to finish..."'+ |
| 176 | ' sleep 0.5'+ |
| 177 | 'done'+ |
| 178 | 'sudo rm -f /var/lib/dpkg/lock'+ |
| 179 | |
| 180 | 'sudo apt-get update || (sleep 15; sudo apt-get update || exit ${1})'+ |
| 181 | 'sudo DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-server-5.5 pwgen || exit ${1}'+ |
| 182 | 'rm -rf "${LOCK}"'+ |
| 183 | |
| 184 | 'sudo /etc/init.d/mysql stop'+ |
| 185 | 'sudo rm -rf /var/lib/apt/lists/*'+ |
| 186 | 'sudo rm -rf /var/lib/mysql/*'+ |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame^] | 187 | 'echo "MySQL Installation complete."'; |