Commit 30e1928d authored by Spiros Koulouzis's avatar Spiros Koulouzis

get all info of nodes

parent d2898192
...@@ -38,9 +38,10 @@ topology_template: ...@@ -38,9 +38,10 @@ topology_template:
# Just in case we need it later on. # Just in case we need it later on.
MONITORING_PROXY2: { get_property: [SELF, "Monitoring Proxy", "monitoring/proxy/api/endpoint" ] } MONITORING_PROXY2: { get_property: [SELF, "Monitoring Proxy", "monitoring/proxy/api/endpoint" ] }
"Notifier_output": "Notifier_output":
type: "JSON" Side_type: "JSON"
host_port: SET_ITS_VALUE host_port: SET_ITS_VALUE
container_port: SET_ITS_VALUE container_port: SET_ITS_VALUE
protocol: "tcp"
Environment_variables: Environment_variables:
ENV1: ... ENV1: ...
#So this is given for all containers? #So this is given for all containers?
...@@ -52,6 +53,7 @@ topology_template: ...@@ -52,6 +53,7 @@ topology_template:
scaling_mode: single scaling_mode: single
requirements: requirements:
- host: - host:
# Future work...
node: "VM_1" node: "VM_1"
node_filter: node_filter:
capabilities: capabilities:
...@@ -71,12 +73,12 @@ topology_template: ...@@ -71,12 +73,12 @@ topology_template:
mount_type: r/rw mount_type: r/rw
- monitoring_proxy: "Monitoring Proxy" - monitoring_proxy: "Monitoring Proxy"
- sip_notifier: "SIPNotifyer" - sip_notifier: "SIPNotifyer"
# So this(below) should just map to
# volumes:
# graphite_data:
# inside docker compose.
"Volume_ID": "Volume_ID":
# So I do not know what information is needed for this, as it is my first time hearing about it type: "Switch.Volume"
# I suggest we look at docker compose for it and extrapolate from there.
requirements:
- host:
node: "VM_1"
"SIPNotifier": "SIPNotifier":
artifacts: artifacts:
sipnotifier_image: sipnotifier_image:
...@@ -394,7 +396,6 @@ topology_template: ...@@ -394,7 +396,6 @@ topology_template:
type: linux type: linux
distribution: rhel distribution: rhel
version: 6.5 version: 6.5
"VM_5": "VM_5":
# Stub I think this should be generated by DRIP-planer. But we could have a diamond so SIDE can make it. # Stub I think this should be generated by DRIP-planer. But we could have a diamond so SIDE can make it.
type: Switch.node.Compute type: Switch.node.Compute
......
No preview for this file type
This diff is collapsed.
...@@ -24,18 +24,14 @@ import logging ...@@ -24,18 +24,14 @@ import logging
import linecache import linecache
import sys import sys
# create logger logger = logging.getLogger(__name__)
logger = logging.getLogger('docker_swarm') if not getattr(logger, 'handler_set', None):
logger.setLevel(logging.DEBUG) logger.setLevel(logging.INFO)
# create console handler and set level to debug h = logging.StreamHandler()
ch = logging.StreamHandler() formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
ch.setLevel(logging.DEBUG) h.setFormatter(formatter)
# create formatter logger.addHandler(h)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') logger.handler_set = True
# add formatter to ch
ch.setFormatter(formatter)
# add ch to logger
logger.addHandler(ch)
...@@ -80,23 +76,22 @@ def docker_check(vm, compose_name): ...@@ -80,23 +76,22 @@ def docker_check(vm, compose_name):
if i.encode(): if i.encode():
json_str = json.loads(i.encode().strip('\n')) json_str = json.loads(i.encode().strip('\n'))
stack_info.append(json_str) stack_info.append(json_str)
json_response ['stack_info'] = stack_info json_response ['stack_info'] = stack_info
cmd = 'sudo docker node inspect ' cmd = 'sudo docker node inspect '
for hostname in nodes_hostname: for hostname in nodes_hostname:
cmd += hostname cmd += hostname
logger.info(cmd)
stdin, stdout, stderr = ssh.exec_command(cmd) stdin, stdout, stderr = ssh.exec_command(cmd)
inspect_resp = stdout.readlines() inspect_resp = stdout.readlines()
nodes_info = []
#for i in inspect_resp:
#if i.encode():
#json_str = json.loads(i.encode().strip('\n'))
#nodes_info.append(json_str)
#json_response ['nodes_info'] = nodes_info response_str = ""
for i in inspect_resp:
if i.encode():
response_str+=i.encode().strip('\n')
json_str = json.loads(response_str.rstrip("\n\r").strip().encode('string_escape'))
json_response['nodes_info'] = json_str
logger.info("Finished docker info services on: "+vm.ip) logger.info("Finished docker info services on: "+vm.ip)
except Exception as e: except Exception as e:
......
...@@ -21,18 +21,14 @@ import paramiko, os ...@@ -21,18 +21,14 @@ import paramiko, os
from vm_info import VmInfo from vm_info import VmInfo
import logging import logging
# create logger logger = logging.getLogger(__name__)
logger = logging.getLogger('docker_swarm') if not getattr(logger, 'handler_set', None):
logger.setLevel(logging.DEBUG) logger.setLevel(logging.INFO)
# create console handler and set level to debug h = logging.StreamHandler()
ch = logging.StreamHandler() formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
ch.setLevel(logging.DEBUG) h.setFormatter(formatter)
# create formatter logger.addHandler(h)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') logger.handler_set = True
# add formatter to ch
ch.setFormatter(formatter)
# add ch to logger
logger.addHandler(ch)
def deploy_compose(vm, compose_file, compose_name): def deploy_compose(vm, compose_file, compose_name):
......
...@@ -19,9 +19,22 @@ __author__ = 'Yang Hu' ...@@ -19,9 +19,22 @@ __author__ = 'Yang Hu'
import paramiko, os import paramiko, os
import threading import threading
import logging
logger = logging.getLogger(__name__)
if not getattr(logger, 'handler_set', None):
logger.setLevel(logging.INFO)
h = logging.StreamHandler()
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
h.setFormatter(formatter)
logger.addHandler(h)
logger.handler_set = True
def install_engine(vm): def install_engine(vm):
try: try:
print "%s: ====== Start Docker Engine Installing ======" % (vm.ip) logger.info("Starting docker engine installation on: "+(vm.ip))
paramiko.util.log_to_file("deployment.log") paramiko.util.log_to_file("deployment.log")
ssh = paramiko.SSHClient() ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
...@@ -38,9 +51,9 @@ def install_engine(vm): ...@@ -38,9 +51,9 @@ def install_engine(vm):
sftp.put(install_script, "engine_setup.sh") sftp.put(install_script, "engine_setup.sh")
stdin, stdout, stderr = ssh.exec_command("sudo sh /tmp/engine_setup.sh") stdin, stdout, stderr = ssh.exec_command("sudo sh /tmp/engine_setup.sh")
stdout.read() stdout.read()
print "%s: ========= Docker Engine Installed =========" % (vm.ip) logger.info("Finised docker engine installation on: "+(vm.ip))
except Exception as e: except Exception as e:
print '%s: %s' % (vm.ip, e) logger.error(vm.ip + " " + str(e))
return "ERROR:"+vm.ip+" "+str(e) return "ERROR:"+vm.ip+" "+str(e)
ssh.close() ssh.close()
return "SUCCESS" return "SUCCESS"
......
...@@ -21,18 +21,14 @@ import paramiko, os ...@@ -21,18 +21,14 @@ import paramiko, os
from vm_info import VmInfo from vm_info import VmInfo
import logging import logging
# create logger logger = logging.getLogger(__name__)
logger = logging.getLogger('docker_swarm') if not getattr(logger, 'handler_set', None):
logger.setLevel(logging.DEBUG) logger.setLevel(logging.INFO)
# create console handler and set level to debug h = logging.StreamHandler()
ch = logging.StreamHandler() formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
ch.setLevel(logging.DEBUG) h.setFormatter(formatter)
# create formatter logger.addHandler(h)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') logger.handler_set = True
# add formatter to ch
ch.setFormatter(formatter)
# add ch to logger
logger.addHandler(ch)
def scale_service(vm, application_name, service_name, service_num): def scale_service(vm, application_name, service_name, service_num):
......
...@@ -21,18 +21,15 @@ import paramiko, os ...@@ -21,18 +21,15 @@ import paramiko, os
from vm_info import VmInfo from vm_info import VmInfo
import logging import logging
# create logger
logger = logging.getLogger('docker_swarm') logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG) if not getattr(logger, 'handler_set', None):
# create console handler and set level to debug logger.setLevel(logging.INFO)
ch = logging.StreamHandler() h = logging.StreamHandler()
ch.setLevel(logging.DEBUG) formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# create formatter h.setFormatter(formatter)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') logger.addHandler(h)
# add formatter to ch logger.handler_set = True
ch.setFormatter(formatter)
# add ch to logger
logger.addHandler(ch)
def install_manager(vm): def install_manager(vm):
......
...@@ -24,18 +24,14 @@ if len(sys.argv) > 1: ...@@ -24,18 +24,14 @@ if len(sys.argv) > 1:
else: else:
rabbitmq_host = '127.0.0.1' rabbitmq_host = '127.0.0.1'
logger = logging.getLogger('rpc_server') logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG) if not getattr(logger, 'handler_set', None):
ch = logging.StreamHandler() logger.setLevel(logging.INFO)
ch.setLevel(logging.DEBUG) h = logging.StreamHandler()
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
ch.setFormatter(formatter) h.setFormatter(formatter)
logger.addHandler(ch) logger.addHandler(h)
logger.handler_set = True
fh = logging.FileHandler('deployer.log')
fh.setLevel(logging.DEBUG)
fh.setFormatter(formatter)
logger.addHandler(fh)
connection = pika.BlockingConnection(pika.ConnectionParameters(host=rabbitmq_host)) connection = pika.BlockingConnection(pika.ConnectionParameters(host=rabbitmq_host))
...@@ -55,7 +51,7 @@ def handleDelivery(message): ...@@ -55,7 +51,7 @@ def handleDelivery(message):
parsed_json = json.loads(message) parsed_json = json.loads(message)
params = parsed_json["parameters"] params = parsed_json["parameters"]
node_num = 0 node_num = 0
vm_list = [] vm_list = set()
current_milli_time = lambda: int(round(time.time() * 1000)) current_milli_time = lambda: int(round(time.time() * 1000))
try: try:
path = os.path.dirname(os.path.abspath(__file__)) + "/deployer_files/"+str(current_milli_time()) + "/" path = os.path.dirname(os.path.abspath(__file__)) + "/deployer_files/"+str(current_milli_time()) + "/"
...@@ -86,7 +82,7 @@ def handleDelivery(message): ...@@ -86,7 +82,7 @@ def handleDelivery(message):
os.chmod(key, 0o600) os.chmod(key, 0o600)
vm = VmInfo(ip, user, key, role) vm = VmInfo(ip, user, key, role)
vm_list.append(vm) vm_list.add(vm)
elif name == "playbook": elif name == "playbook":
value = param["value"] value = param["value"]
playbook = path + "playbook.yml" playbook = path + "playbook.yml"
......
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