Commit 8c12d5d8 authored by Spiros Koulouzis's avatar Spiros Koulouzis

set correct permissions

parent b91005ed
......@@ -18,7 +18,7 @@ topology_template:
keys:
public_key: "c3NoLXJzYSBBQUFBQjNOemFDMXljMkVBQUFBREFRQUJBQUFBZ1FDVnlpOVNZWitKTnp0ZG9maUM5WXI4RkhHZWJDdHdPUGl0bTFXVmNTL1pPM05tQXhXbXg1RGRDMUI4MU5GZEVWZEt2Nng2N0diSjI2SEplREhIMU9pMmt3aExDQzM5R0dZNmxPSjh4U0hKMjFJVXVydTRCaGk5STNGSlZ0Q1o0ckhIUGsvcjhkaUlCQ1BrNjc1SllkSERFN0ZUbWpUN0lnOGptdzk0dThYZFpRPT0gYXV0byBnZW5lcmF0ZWQgdXNlciBhY2NlZXMga2V5cwo="
private_key: "LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlDV3dJQkFBS0JnUUNWeWk5U1laK0pOenRkb2ZpQzlZcjhGSEdlYkN0d09QaXRtMVdWY1MvWk8zTm1BeFdtCng1RGRDMUI4MU5GZEVWZEt2Nng2N0diSjI2SEplREhIMU9pMmt3aExDQzM5R0dZNmxPSjh4U0hKMjFJVXVydTQKQmhpOUkzRkpWdENaNHJISFBrL3I4ZGlJQkNQazY3NUpZZEhERTdGVG1qVDdJZzhqbXc5NHU4WGRaUUlEQVFBQgpBb0dBYXVhazV6SnMzVXpodlcwL0lwZUMzV3pwdVpxUlZjSVRHRE5uM1FPdWxtWnJjVDU2VVZEVC9pMTQvOTRTCm5VMG04MTNnQnNwNGdVK1NJMnI0ZkJsakN2RjNEYU9KN1VCUTR5OGpEbW5aUGdrK2ljTUQ2dC9SYnNLZzNPRjgKZ0pFeVN3NFF6UGtTZEJ3Z0JIUnZ3bnA4Z1BtUGxmYWRlTHBNdGY0ZEc1d2VabkVDUVFEVUMzTXpmTVRyMWZmYwozMWlNa3JDQ3pSVE5BZ2lxc010MmJsUE5LVEM3U1ZTYURVcUpVOGwrVFJUR1NEOEJqZGxwelFOMVNTNEpYWnJ1CnAzQTlYOWxyQWtFQXROY1BWcUhZalpyOXU0REI3N01TRUVTZDFtWk43c1RqdFIwNzQrOVhZNWxzREx5UGNnWC8KSTF5WnlFMm5MN3VzUGNIUHhWdjhtMElTb1dZZWQ5SElid0pBQzBRWWVOSFdQSmwvczlLQ0IrWDdUdGZLbFNIWQppQWtncGtneVY2SXFucWpFdi9LWTFUY0lhNWQ0MVJnZGtOMlNnWmFNNm54YTM5Q0RYTTYwbmU0cnhRSkFFVTg0CmY2RlVPaEdvMGNhOFNYWkpkMWNxQ0hpWVl3OWpnRldCQXd0SXdSYlJXZEsrcERwZ3RvREprM3VqVWhWVG9rR24KNG9zd2ZhZndZcFNFdkJGUGJ3SkFYeGlVcWpqbFA3eDVKMjhLeDZ6VmdDNk9mcStiQk5PYjVGYzkxbFZ6b3VHbwpFQW8wMkRHZ1l6UlZpT3MxUXN2czNSMUFiRHliNUY0WndNb0hFTWpwZmc9PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo="
public_ip: "192.168.5.5"
public_ip: "172.17.0.2"
role: "master"
node_type: "XOLarge"
root_key_pair:
......@@ -44,7 +44,7 @@ topology_template:
keys:
public_key: "c3NoLXJzYSBBQUFBQjNOemFDMXljMkVBQUFBREFRQUJBQUFBZ1FDVnlpOVNZWitKTnp0ZG9maUM5WXI4RkhHZWJDdHdPUGl0bTFXVmNTL1pPM05tQXhXbXg1RGRDMUI4MU5GZEVWZEt2Nng2N0diSjI2SEplREhIMU9pMmt3aExDQzM5R0dZNmxPSjh4U0hKMjFJVXVydTRCaGk5STNGSlZ0Q1o0ckhIUGsvcjhkaUlCQ1BrNjc1SllkSERFN0ZUbWpUN0lnOGptdzk0dThYZFpRPT0gYXV0byBnZW5lcmF0ZWQgdXNlciBhY2NlZXMga2V5cwo="
private_key: "LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlDV3dJQkFBS0JnUUNWeWk5U1laK0pO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UY0WndNb0hFTWpwZmc9PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo="
public_ip: "192.168.5.10"
public_ip: "172.17.0.3"
role: "worker"
node_type: "XOLarge"
root_key_pair:
......
......@@ -15,8 +15,6 @@
*/
package nl.uva.sne.drip.commons.utils;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
......
......@@ -11,10 +11,9 @@ import pika
import yaml
import sys
from service import tosca
from service import tosca, k8s_service
from service import ansible_service
logger = logging.getLogger(__name__)
......@@ -31,7 +30,7 @@ def init_chanel(args):
global rabbitmq_host
if len(args) > 1:
rabbitmq_host = args[1]
queue_name = args[2] # deployer_qeue
queue_name = args[2] # deployer
else:
rabbitmq_host = '127.0.0.1'
......@@ -70,9 +69,11 @@ def handle_delivery(message):
tosca_file_name = 'tosca_template'
tosca_template_json = parsed_json_message['toscaTemplate']
input_current_milli_time = lambda: int(round(time.time() * 1000))
interfaces = tosca.get_interfaces(tosca_template_json)
vms = tosca.get_vms(tosca_template_json)
ansible_service.run(interfaces, vms)
k8s_service.run(tosca_template_json)
template_dict = {}
logger.info("template ----: \n" + yaml.dump(template_dict))
......@@ -98,8 +99,8 @@ if __name__ == "__main__":
interfaces = tosca.get_interfaces(tosca_template_json)
vms = tosca.get_vms(tosca_template_json)
ansible_service.run(interfaces,vms)
ansible_service.run(interfaces, vms)
k8s_service.run(tosca_template_json)
......
......@@ -4,6 +4,10 @@ import tempfile
import shutil
from stat import S_IREAD
import requests
from subprocess import Popen, PIPE
from numpy.distutils.system_info import openblas64__info
def write_ansible_files(vms, interfaces, tmp_path):
workers = []
......@@ -37,8 +41,8 @@ def write_ansible_files(vms, interfaces, tmp_path):
for worker in workers:
print(worker, file=k8s_hosts_file)
print('\n', file=k8s_hosts_file)
print('[cluster: children]', file=k8s_hosts_file)
print('k8 - master', file=k8s_hosts_file)
print('[cluster:children]', file=k8s_hosts_file)
print('k8-master', file=k8s_hosts_file)
print('worker', file=k8s_hosts_file)
print('\n', file=k8s_hosts_file)
print('[cluster:vars]', file=k8s_hosts_file)
......@@ -56,4 +60,11 @@ def write_ansible_files(vms, interfaces, tmp_path):
def run(interfaces, vms):
tmp_path = tempfile.mkdtemp()
write_ansible_files(vms, interfaces, tmp_path)
p = Popen(["ansible-playbook", "-i", tmp_path+"/k8s_hosts", tmp_path+"/playbook.yml"], stdin=PIPE, stdout=PIPE, stderr=PIPE)
output, err = p.communicate()
print(output)
print(err)
rc = p.returncode
return tmp_path
def get_dockers(tosca_template_json):
pass
def write_k8s_files(dockers):
pass
def run(tosca_template_json):
dockers = get_dockers(tosca_template_json)
tmp_dir = write_k8s_files(dockers)
return None
\ No newline at end of file
......@@ -17,12 +17,17 @@ import com.jcraft.jsch.KeyPair;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.attribute.PosixFilePermission;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import nl.uva.sne.drip.commons.utils.Converter;
......@@ -148,6 +153,11 @@ class CloudStormService {
kpair.writePrivateKey(tempInputDirPath + File.separator + userPrivateName);
kpair.writePublicKey(tempInputDirPath + File.separator + userPublicKeyName, "auto generated user accees keys");
kpair.dispose();
Set<PosixFilePermission> perms = new HashSet<>();
perms.add(PosixFilePermission.OWNER_READ);
Files.setPosixFilePermissions(Paths.get(tempInputDirPath + File.separator + userPrivateName), perms);
return publicKeyPath;
}
......@@ -285,8 +295,8 @@ class CloudStormService {
private ToscaTemplate runCloudStorm(String tempInputDirPath) throws IOException, ApiException {
String[] args = new String[]{"run", tempInputDirPath};
// standalone.MainAsTool.main(args);
tempInputDirPath = "/tmp/Input-174407085024744";
standalone.MainAsTool.main(args);
// tempInputDirPath = "/tmp/Input-174407085024744";
CloudsStormTopTopology _top = objectMapper.readValue(new File(tempInputDirPath + TOPOLOGY_RELATIVE_PATH
+ TOP_TOPOLOGY_FILE_NAME),
......@@ -342,7 +352,7 @@ class CloudStormService {
}
vmAttributes.put("node_type", vm.getNodeType());
vmAttributes.put("host_name", vm.getName());
vmAttributes.put("root_key_pair", rootKeyPairCredential);
vmAttributes.put("user_key_pair", userKeyPairCredential);
vmTemplateMap.getNodeTemplate().setAttributes(vmAttributes);
......
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