Commit fbcd9dc8 authored by Escalante Martinez, Marisa's avatar Escalante Martinez, Marisa
Browse files
parents 7facf9de 3b986164

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.
FROM tiangolo/uwsgi-nginx-flask:python3.6
RUN apt-get update && apt-get install unzip && apt-get install -y vim && wget https://releases.hashicorp.com/terraform/0.10.7/terraform_0.10.7_linux_amd64.zip?_ga=2.121414664.102068769.1507033863-2054770415.1501495729 -O temp.zip && unzip temp.zip -d /usr/local/bin && rm temp.zip && mkdir -p /app/repo && mkdir -p /home/ubuntu/terraform/certs && mkdir -p /home/ubuntu/terraform/scripts && mkdir /home/ubuntu/terraform/keypairs && pip install flask-restplus && pip install -U flask-cors && pip install pymongo==3.7 && pip install jsonschema==3.0.0a3 && wget http://security.debian.org/debian-security/pool/updates/main/o/openssl/libssl1.0.0_1.0.1t-1+deb8u9_amd64.deb && dpkg -i libssl1.0.0_1.0.1t-1+deb8u9_amd64.deb && wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1604-4.0.0.tgz && tar -zxvf mongodb-linux-*-4.0.0.tgz && mkdir -p /data/db && export PATH=mongodb-linux-x86_64-ubuntu1604-4.0.0/bin:$PATH && cp mongodb-linux-x86_64-ubuntu1604-4.0.0/bin/* /usr/local/bin
COPY app/ /app/
COPY tfplugin/terraform-provider-cloudbroker /usr/local/bin
COPY scripts /home/ubuntu/terraform/scripts
COPY mongo.conf /etc/supervisor/conf.d
ENV STATIC_INDEX 1
conn = new Mongo();
print("Getting db 'adapt-do-db'")
db = conn.getDB("adapt-do-db");
print("Removing vm list");
db.vmList.remove({})
print("Removing vm status");
db.vmStatus.remove({})
\ No newline at end of file
#!/bin/bash
rm -r ExampleApp*
rm -r vm*
rm -r operations*
mongo clean-mongodb.js
This diff is collapsed.
variable "adapt_host" {
description = "The endpoint of ADAPT"
}
variable "cloudbroker_endpoint" {
description = "The endpoint of the cloudbroker API"
default = "https://decide-prototype.cloudbroker.com"
}
variable "cloudbroker_username" {
description = "The username for the cloudbroker API"
}
variable "cloudbroker_password" {
description = "The password for the cloudbroker API"
}
variable "vm_software_id" {
default = "21b7ebed-5076-43b6-8351-0e06cf16eedc"
}
variable "vm_resource_id" {
default = "18d07329-07f6-4d59-b1c1-676f64d1663f"
}
variable "vm_region_id" {
default = "4265ddb9-e862-4814-82a4-d6b92f25e8e5"
}
variable "vm_user" {
default = "ubuntu"
}
variable "instance_type_id" {
default = "e3ca8e4c-0f91-4e83-9bd9-4cef88d054a8"
}
variable "key_pair_id" {
default = "fb40a1f3-86b1-4e68-9ab3-049b664139e7"
}
variable "opened_port" {
default = "22,80,8000-9000,9411"
}
variable "consul-join-ip" {
}
variable "docker-private-registry-ip" {
default = ""
}
variable "docker-private-registry-port" {
default = ""
}
variable "node_name" {
}
variable "app_name" {
default = ""
}
provider "cloudbroker" {
username = "${var.cloudbroker_username}"
password = "${var.cloudbroker_password}"
endpoint = "${var.cloudbroker_endpoint}"
timeout = 60
max_retries = 5
}
resource "cloudbroker_instance" "decide-vm" {
software_id = "${var.vm_software_id}"
resource_id = "${var.vm_resource_id}"
region_id = "${var.vm_region_id}"
instance_type_id = "${var.instance_type_id}"
vm_user = "${var.vm_user}"
isolated = "false"
key_pair_id = "${var.key_pair_id}"
disable_autostop = "true"
opened_port = "${var.opened_port}"
name = "${var.node_name}"
provisioner "local-exec" {
command = "echo ${cloudbroker_instance.decide-vm.external_ip_address} > /app/${var.app_name}-${var.node_name}-ip.txt"
}
connection {
host = "${cloudbroker_instance.decide-vm.external_ip_address}"
}
provisioner "file" {
source = "/home/ubuntu/terraform/scripts"
destination = "/tmp"
connection {
type = "ssh"
user = "${var.vm_user}"
private_key = "${file("/home/ubuntu/terraform/keypairs/${var.app_name}/private-key-openssh")}"
}
}
provisioner "remote-exec" {
inline = [
"chmod -R +x /tmp/scripts",
"sleep 5",
"/tmp/scripts/init-vm.sh ${cloudbroker_instance.decide-vm.name} ${cloudbroker_instance.decide-vm.external_ip_address} ${cloudbroker_instance.decide-vm.internal_ip_address} ${var.consul-join-ip} ${var.adapt_host} ${var.docker-private-registry-ip} ${var.docker-private-registry-port}",
]
connection {
type = "ssh"
user = "${var.vm_user}"
private_key = "${file("/home/ubuntu/terraform/keypairs/${var.app_name}/private-key-openssh")}"
}
}
provisioner "local-exec" {
command = <<CMD
mkdir -p /home/ubuntu/terraform/certs/${cloudbroker_instance.decide-vm.external_ip_address} \
&& scp -i /home/ubuntu/terraform/keypairs/${var.app_name}/private-key-openssh -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null -r ${var.vm_user}@${cloudbroker_instance.decide-vm.external_ip_address}:/tmp/scripts/tempkeys/ /home/ubuntu/terraform/certs/${cloudbroker_instance.decide-vm.external_ip_address} \
&& mv /home/ubuntu/terraform/certs/${cloudbroker_instance.decide-vm.external_ip_address}/tempkeys /home/ubuntu/terraform/certs/${cloudbroker_instance.decide-vm.external_ip_address}/keys \
&& chmod -v 0400 /home/ubuntu/terraform/certs/${cloudbroker_instance.decide-vm.external_ip_address}/keys/key.pem \
&& chmod -v 0444 /home/ubuntu/terraform/certs/${cloudbroker_instance.decide-vm.external_ip_address}/keys/cert.pem
CMD
}
}
output "external_ip_address" {
value = "${cloudbroker_instance.decide-vm.external_ip_address}"
}
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "AppDescription",
"description": "DECIDE Application Description",
"type": "object",
"required": [
"id",
"name",
"version",
"highTechnologicalRisk",
"microservices"
],
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"version": {
"type": "string"
},
"highTechnologicalRisk": {
"type": "boolean"
},
"jenkinsEndpoint": {
"type": "string",
"format": "uri"
},
"jenkinsToken": {
"type": "string"
},
"monitoring": {
"$ref": "#/definitions/Monitoring"
},
"recommendedPatterns": {
"type": "array",
"items": {
"$ref": "#/definitions/Pattern"
}
},
"microservices": {
"type": "array",
"minItems": 1,
"items": {
"$ref": "#/definitions/Microservice"
}
},
"mcsla": {
"$ref": "#/definitions/Mcsla"
},
"nfrs": {
"type": "array",
"items": {
"anyOf": [
{
"$ref": "#/definitions/AvailabilityNfr"
},
{
"$ref": "#/definitions/PerformanceNfr"
},
{
"$ref": "#/definitions/ScalabilityNfr"
},
{
"$ref": "#/definitions/LocationNfr"
},
{
"$ref": "#/definitions/CostNfr"
}
]
}
},
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/SchemaElement"
}
},
"virtualMachines": {
"type": "array",
"items": {
"$ref": "#/definitions/VirtualMachine"
}
},
"containers": {
"type": "array",
"items": {
"$ref": "#/definitions/Container"
}
},
"applicationInstanceId": {
"type": "string"
}
},
"definitions": {
"Microservice": {
"type": "object",
"required": [ "id", "endpoints" ],
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"name": {
"type": "string"
},
"tags": {
"type": "array",
"items": {
"type": "string"
},
"uniqueItems": true
},
"sourceRepository": {
"type": "string",
"format": "uri"
},
"deploymentOrder": {
"type": "number"
},
"programmingLanguage": {
"type": "string"
},
"containerId": {
"type": "string"
},
"containerRef": {
"type": "string"
},
"endpoints": {
"type": "array",
"minItems": 1,
"items": {
"type": "string"
}
},
"stateful": {
"type": "boolean",
"default": "false"
},
"classification": {
"type": "string"
},
"dependencies": {
"type": "array",
"items": {
"type": "string"
}
},
"safeMethods": {
"type": "array",
"items": {
"type": "string"
}
},
"publicIP": {
"type": "boolean"
},
"infrastructureRequirements": {
"$ref": "#/definitions/InfrastructureRequirements"
},
"detachableResources": {
"type": "array",
"items": {
"$ref": "#/definitions/DetachableResource"
}
}
}
},
"Mcsla": {
"type": "object",
"required": [ "csSlas" ],
"properties": {
"sla": {
"$ref": "#/definitions/Sla"
},
"csSlas": {
"type": "object",
"description": "Map between cloud services and Slas. Keys are the cloud service ids.",
"additionalProperties": {
"$ref": "#/definitions/Sla"
}
}
}
},
"Nfr": {
"type": "object",
"required": [ "type" ],
"properties": {
"type": {
"enum": [ "Availability", "Performance", "Scalability", "Location", "Cost" ]
},
"tags": {
"type": "array",
"items": {
"type": "string"
},
"uniqueItems": true
}
}
},
"AvailabilityNfr": {
"allOf": [
{
"$ref": "#/definitions/Nfr"
},
{
"type": "object",
"required": [ "abstractValue" ],
"properties": {
"type": {
"const": "Availability"
},
"abstractValue": {
"type": "string",
"enum": [ "Low", "Medium", "High" ]
},
"value": {
"type": "number",
"minimum": 0,
"maximum": 100
},
"unit": {
"type": "string"
}
}
}
]
},
"PerformanceNfr": {
"allOf": [
{
"$ref": "#/definitions/Nfr"
},
{
"type": "object",
"required": [ "abstractValue" ],
"properties": {
"type": {
"const": "Performance"
},
"abstractValue": {
"type": "string",
"enum": [ "Low", "Medium", "High" ]
},
"value": {
"type": "number",
"exclusiveMinimum": 0
},
"unit": {
"type": "string"
}
}
}
]
},
"ScalabilityNfr": {
"allOf": [
{
"$ref": "#/definitions/Nfr"
},
{
"type": "object",
"required": [ "abstractValue" ],
"properties": {
"type": {
"const": "Scalability"
},
"abstractValue": {
"type": "string",
"enum": [ "Low", "Medium", "High" ]
},
"value": {
"type": "number"
},
"unit": {
"type": "string"
}
}
}
]
},
"LocationNfr": {
"allOf": [
{
"$ref": "#/definitions/Nfr"
},
{
"type": "object",
"required": [ "abstractValue" ],
"properties": {
"type": {
"const": "Location"
},
"abstractValue": {
"type": "string",
"enum": [ "Single Location", "Single Country", "Cross Border" ]
},
"value": {
"type": "array",
"items": {
"type": "string"
},
"uniqueItems": true
}
}
}
]
},
"CostNfr": {
"allOf": [
{
"$ref": "#/definitions/Nfr"
},
{
"type": "object",
"required": [ "abstractValue" ],
"properties": {
"type": {
"const": "Cost"
},
"abstractValue": {
"type": "string",
"enum": [ "Low", "Medium", "High" ]
},
"value": {
"type": "number",
"exclusiveMinimum": 0
},
"unit": {
"type": "string"
}
}
}
]
},
"VirtualMachine": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"cspId": {
"type": "string"
},
"cspName": {
"type": "string"
},
"ram": {
"type": "integer",
"minimum": 1
},
"cores": {
"type": "integer",
"minimum": 1
},
"storage": {
"type": "integer",
"minimum": 1
},
"image": {
"type": "string"
},
"openedPorts": {
"type": "array",
"items": {
"type": "integer",
"minimum": 0
}
}
}
},
"Container": {
"type": "object",
"required": [
"imageName",
"imageTag",
"hostname",
"restart",
"dockerHostNodeName"
],
"properties": {
"containerName": {
"type": "string"
},
"imageName": {