Commit ea3cfc1e authored by Spiros Koulouzis's avatar Spiros Koulouzis

increment i and j to get the next vm and vm topology

parent c4891ab0
tosca_definitions_version: "tosca_simple_yaml_1_0"
topology_template:
node_templates:
compute:
properties:
disk_size: "50000 MB"
mem_size: "6000 MB"
num_cores: 2.0
os: "Ubuntu 18.04"
user_name: "vm_user"
interfaces:
Standard:
create: "dumy.yaml"
type: "tosca.nodes.ARTICONF.VM.Compute"
attributes:
user_key_pair:
protocol: "ssh"
keys:
public_key: "c3NoLXJzYSBBQUFBQjNOemFDMXljMkVBQUFBREFRQUJBQUFBZ1FDVnlpOVNZWitKTnp0ZG9maUM5WXI4RkhHZWJDdHdPUGl0bTFXVmNTL1pPM05tQXhXbXg1RGRDMUI4MU5GZEVWZEt2Nng2N0diSjI2SEplREhIMU9pMmt3aExDQzM5R0dZNmxPSjh4U0hKMjFJVXVydTRCaGk5STNGSlZ0Q1o0ckhIUGsvcjhkaQ1BrNjc1SllkSERFN0ZUbWpUN0lnOGptdzk0dThYZFpRPT0gYXV0byBnZW5lcmF0ZWQgdXNlciBhY2NlZXMga2V5cwo="
private_key: "LS0tLS1CRUdJTiBSU0EgUFJJVkUkzRkpWdENaNHJISFBrL3I4ZGlJQkNQazY3NUpZZEhERTdGVG1qVDdJZzhqbXc5NHU4WGRaUUlEQVFBQgpBb0dBYXVhazV6SnMzVXpodlcwL0lwZUMzV3pwdVpxUlZjSVRHRE5uM1FPdWxtWnJjVDU2VVZEVC9pMTQvOTRTCm5VMG04MTNnQnNwNGdVK1NJMnI0ZkJsakN2RjNEYU9KN1VCUTR5OGpEbW5aUGdrK2ljTUQ2dC9SYnNLZzNPRjgKZ0pFeVN3NFF6UGtTZEJ3Z0JIUnZ3bnA4Z1BtUGxmYWRRCBSU0EgUFJJVkFURSBLRVktLS0tLQo="
public_ip: "XXX.XXX.XXX.XXX"
role: "master"
node_type: "XOLarge"
root_key_pair:
protocol: "ssh"
keys:
public_key: "c3NoLXJzYSBBQUFBQjNOemFDMXljMkVBQUFBREFRQUJDWmRRN2JvQ05VNkhWTndRPT0ga2V5UGFpci1iNWUxYTRjMC01ZjA5LTQyMGMtODQ1Yi04YTIyYmJjOWUxMGIK"
private_key: "LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlDWEFJQkFBS0JnUUNDV04vM3ZVaDVreHhDNnBJZnhuUWE3V3VmWUplbmswbkxKYjFGQU1pN0gzOE1VYnBKCkE3UERwck9SbGhiTEU5ZVVsY1MwakE3Qmp1NXdsVkxlWi8rSjIzK2Z2UHdvb2FIQ0kvVXNiZ3ZFc05sZVhwdmwQ5ODF3dTNlTFB1WnBpWjNKCk93am1TR0pMQWtFQXFQWFJUMzVlU2kzQXBQRFlWQllYZnQ0NlByYWVHOGNSdkpTMFhYSS9vZWhuYmxZRngwZGsKWVQrUjcwajBSQk1TQ0YrVVdSaUlKdlVRR1lXSTBTa29vd0pCQUo0Slo1aXRwNGRtNzUxZlF5K2JsUEp6MjZzUQTlljZkN3R2NubGIrNnVWdQplY2R6dHRianBrbjBzTXdmdGwvL3kyNXl2L3JSdlpmWHRCMzUvNW9ZNUdrPQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo="
host_name: "vm1"
compute_1:
properties:
disk_size: "50000 MB"
mem_size: "6000 MB"
num_cores: 2
os: "Ubuntu 18.04"
user_name: "vm_user"
interfaces:
Standard:
create: "dumy.yaml"
type: "tosca.nodes.ARTICONF.VM.Compute"
kubernetes:
properties:
min_masters_num: 1
min_workers_num: 1
requirements:
- host:
capability: "tosca.capabilities.ARTICONF.VM.topology"
node: "topology"
relationship: "tosca.relationships.HostedOn"
interfaces:
Standard:
create:
inputs:
inventory-file: "k8s_hosts"
playbook: "https://raw.githubusercontent.com/skoulouzis/CONF/DRIP_3.0/ansible_playbooks/install_k8s.yml"
type: "tosca.nodes.ARTICONF.Orchestrator.Kubernetes"
logspout:
properties:
environment:
publish: "127.0.0.1:8000:80"
ports:
- "8000:80"
volumes:
- "/etc/hostname:/etc/host_hostname:ro"
- "/var/run/docker.sock:/var/run/docker.sock"
requirements:
- host:
capability: "tosca.capabilities.ARTICONF.Orchestrator"
node: "kubernetes"
relationship: "tosca.relationships.HostedOn"
type: "tosca.nodes.ARTICONF.Container.Application.Docker"
artifacts:
image:
file: "gliderlabs/logspout:latest"
repository: "docker_hub"
type: "tosca.artifacts.Deployment.Image.Container.Docker"
mysql:
properties:
environment:
MYSQL_DATABASE: "wordpress"
MYSQL_PASSWORD: "wordpress"
MYSQL_ROOT_PASSWORD: "somewordpress"
MYSQL_USER: "wordpress"
ports:
- "3306:3306"
volumes:
- "db_data:/var/lib/mysql"
requirements:
- host:
capability: "tosca.capabilities.ARTICONF.Orchestrator"
node: "kubernetes"
relationship: "tosca.relationships.HostedOn"
type: "tosca.nodes.ARTICONF.Container.Application.Docker"
artifacts:
image:
file: "mysql:5.7"
repository: "docker_hub"
type: "tosca.artifacts.Deployment.Image.Container.Docker"
topology:
properties:
domain: "UvA (Amsterdam, The Netherlands) XO Rack"
provider: "ExoGENI"
requirements:
- vm:
capability: "tosca.capabilities.ARTICONF.VM"
node: "compute"
relationship: "tosca.relationships.DependsOn"
- vm:
capability: "tosca.capabilities.ARTICONF.VM"
node: "compute_1"
relationship: "tosca.relationships.DependsOn"
interfaces:
CloudsStorm:
provision:
inputs:
code_type: "SEQ"
object_type: "SubTopology"
type: "tosca.nodes.ARTICONF.VM.topology"
attributes:
credential:
cloud_provider_name: "ExoGENI"
keys:
keystore: "/u3+7QAAAAIAAAABAAAAAQAEZ2VuaQAAAWt5eo+WAAAFAzCCBP8wDgYKKwYBBAEqAhEBAQUABIIE6+QI4jVyvo+477on8OaF0nwbPvG5QFgYpQDTzX0RDKG5egGch+rxMOHpWerYCmsS5XlHMnUBvqE6lr/H8VieuqwSH97mMwEcwvIdj52nQIuroQsTZampoxYu01"
token: "password"
token_type: "password"
user: "user"
status: "running"
wordpress:
properties:
environment:
WORDPRESS_DB_HOST: "mysql:3306"
WORDPRESS_DB_NAME: "wordpress"
WORDPRESS_DB_PASSWORD: "wordpress"
WORDPRESS_DB_USER: "wordpress"
ports:
- "8000:80"
requirements:
- service:
node: "mysql"
relationship:
type: "tosca.relationships.DependsOn"
- host:
capability: "tosca.capabilities.ARTICONF.Orchestrator"
node: "kubernetes"
relationship: "tosca.relationships.HostedOn"
type: "tosca.nodes.ARTICONF.Container.Application.Docker"
artifacts:
image:
file: "wordpress:latest"
repository: "docker_hub"
type: "tosca.artifacts.Deployment.Image.Container.Docker"
policies:
- scalability:
properties:
constraint_name: "cpu_load"
max_value: 90
targets:
- "wordpress"
type: "tosca.policies.ARTICONF.Performance.CPU"
- faultTolerance:
properties:
level: 1
targets:
- "mysql"
type: "tosca.policies.ARTICONF.FaultTolerance"
description: "TOSCA example"
imports:
- nodes: "https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/nodes.yaml"
- data: "https://raw.githubusercontent.com/skoulouzis/CONF/DRIP_3.0/TOSCA/types/data.yml"
- capabilities: "https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/capabilities.yaml"
- policies: "https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/policies.yaml"
- interfaces: "https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/interfaces.yml"
......@@ -12,7 +12,7 @@ import yaml
import sys
from service import tosca
from service import ansible_service
logger = logging.getLogger(__name__)
......@@ -74,7 +74,7 @@ def handle_delivery(message):
interfaces = tosca.get_interfaces(tosca_template_json)
template_dict = {}
logger.info("template ----: \n" + yaml.dump(template_dict))
response = {'toscaTemplate': template_dict}
......@@ -88,8 +88,24 @@ def handle_delivery(message):
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
logger.info("Input args: " + sys.argv[0] + ' ' + sys.argv[1] + ' ' + sys.argv[2])
channel = init_chanel(sys.argv)
global queue_name
queue_name = sys.argv[2]
start(channel)
if sys.argv[1] == "test_local":
tosca_path = "../TOSCA/"
input_tosca_file_path = tosca_path + '/application_example_provisioned.yaml'
with open(input_tosca_file_path) as f:
# use safe_load instead load
tosca_template_json = yaml.safe_load(f)
interfaces = tosca.get_interfaces(tosca_template_json)
vms = tosca.get_vms(tosca_template_json)
ansible_service.run(interfaces,vms)
else:
logger.info("Input args: " + sys.argv[0] + ' ' + sys.argv[1] + ' ' + sys.argv[2])
channel = init_chanel(sys.argv)
global queue_name
queue_name = sys.argv[2]
start(channel)
def write_invenory_file(vms):
try:
tosca_folder_path = os.path.join(tempfile.gettempdir(), "ansible_files", str(input_current_milli_time()))
except NameError:
import sys
millis = int(round(time.time() * 1000))
tosca_folder_path = os.path.dirname(os.path.abspath(sys.argv[0])) + os.path.join(tempfile.gettempdir(),
"planner_files",
str(millis))
pass
def run(interfaces,vms):
write_invenory_file(vms)
return None
\ No newline at end of file
def get_interfaces(tosca_template_json):
node_templates = tosca_template_json['topology_template']['node_templates']
for node_name in node_templates:
if node_templates[node_name]['type'] == 'tosca.nodes.ARTICONF.Orchestrator.Kubernetes':
return node_templates[node_name]['interfaces']
return None
\ No newline at end of file
def get_vms(tosca_template_json):
node_templates = tosca_template_json['topology_template']['node_templates']
vms = {}
for node_name in node_templates:
if node_templates[node_name]['type'] == 'tosca.nodes.ARTICONF.VM.Compute':
vms[node_name] = node_templates[node_name]
return vms
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="e478ccae-5352-4e8e-9efb-3f5cda44e877" name="Default Changelist" comment="" />
<list default="true" id="e478ccae-5352-4e8e-9efb-3f5cda44e877" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/../drip-deployer/__main__.py" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-deployer/__main__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-deployer/service/ansible_service.py" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-deployer/service/ansible_service.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-deployer/service/tosca.py" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-deployer/service/tosca.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/__main__.py" beforeDir="false" afterPath="$PROJECT_DIR$/__main__.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
......@@ -307,10 +313,10 @@
<screen x="67" y="34" width="2493" height="1406" />
</state>
<state x="679" y="283" key="SettingsEditor/67.34.2493.1406@67.34.2493.1406" timestamp="1575885393075" />
<state x="681" y="400" key="com.intellij.ide.util.TipDialog" timestamp="1578326162404">
<state x="681" y="400" key="com.intellij.ide.util.TipDialog" timestamp="1579003208514">
<screen x="67" y="34" width="1853" height="1046" />
</state>
<state x="681" y="400" key="com.intellij.ide.util.TipDialog/67.34.1853.1046@67.34.1853.1046" timestamp="1578326162404" />
<state x="681" y="400" key="com.intellij.ide.util.TipDialog/67.34.1853.1046@67.34.1853.1046" timestamp="1579003208514" />
<state x="893" y="526" key="com.intellij.ide.util.TipDialog/67.34.2493.1406@67.34.2493.1406" timestamp="1577206106759" />
<state x="882" y="239" width="862" height="993" key="find.popup" timestamp="1576090708880">
<screen x="67" y="34" width="2493" height="1406" />
......
......@@ -95,7 +95,7 @@ def handle_delivery(message):
conf = {'url': "http://host"}
spec_service = SpecService(conf)
test_planner = Planner(tosca_path=input_tosca_file_path,spec_service=spec_service)
test_planner = Planner(tosca_path=input_tosca_file_path, spec_service=spec_service)
tosca_template = test_planner.resolve_requirements()
tosca_template = test_planner.set_infrastructure_specifications()
template_dict = tosca_helper.get_tosca_template_2_topology_template_dictionary(tosca_template)
......
......@@ -285,7 +285,8 @@ class CloudStormService {
private ToscaTemplate runCloudStorm(String tempInputDirPath) throws IOException, ApiException {
String[] args = new String[]{"run", tempInputDirPath};
standalone.MainAsTool.main(args);
// standalone.MainAsTool.main(args);
tempInputDirPath = "/tmp/Input-174407085024744";
CloudsStormTopTopology _top = objectMapper.readValue(new File(tempInputDirPath + TOPOLOGY_RELATIVE_PATH
+ TOP_TOPOLOGY_FILE_NAME),
......@@ -345,9 +346,10 @@ class CloudStormService {
vmAttributes.put("user_key_pair", userKeyPairCredential);
vmTemplateMap.getNodeTemplate().setAttributes(vmAttributes);
toscaTemplate = helper.setNodeInToscaTemplate(toscaTemplate, vmTemplateMap);
j++;
}
toscaTemplate = helper.setNodeInToscaTemplate(toscaTemplate, vmTopologyMap);
i++;
}
return toscaTemplate;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment