Commit 851b9d92 authored by Daniele Venzano's avatar Daniele Venzano

Fix sonarqube warnings

parent 290fe208
...@@ -86,6 +86,7 @@ def delete_finished(): ...@@ -86,6 +86,7 @@ def delete_finished():
def start_batches(zapp, log): def start_batches(zapp, log):
"""Start zapps in batches."""
zapps_to_start = TOTAL_JOBS - count_jobs() zapps_to_start = TOTAL_JOBS - count_jobs()
print('I need to start {} zapps'.format(zapps_to_start)) print('I need to start {} zapps'.format(zapps_to_start))
while zapps_to_start > 0: while zapps_to_start > 0:
...@@ -105,6 +106,7 @@ def start_batches(zapp, log): ...@@ -105,6 +106,7 @@ def start_batches(zapp, log):
def start_continuous(zapp, log): def start_continuous(zapp, log):
"""Start zapps with a random distribution of interval times."""
zapps_to_start = TOTAL_JOBS - count_jobs() zapps_to_start = TOTAL_JOBS - count_jobs()
print('I need to start {} zapps'.format(zapps_to_start)) print('I need to start {} zapps'.format(zapps_to_start))
while zapps_to_start > 0: while zapps_to_start > 0:
...@@ -118,6 +120,7 @@ def start_continuous(zapp, log): ...@@ -118,6 +120,7 @@ def start_continuous(zapp, log):
def keep_some_running(zapp): def keep_some_running(zapp):
"""Always keep a certain number of zapps running."""
while True: while True:
running_zapps = count_jobs(all=True) running_zapps = count_jobs(all=True)
zapps_to_start = TOTAL_JOBS - running_zapps zapps_to_start = TOTAL_JOBS - running_zapps
......
...@@ -50,6 +50,7 @@ def submit_zapp(zapp): ...@@ -50,6 +50,7 @@ def submit_zapp(zapp):
def get_influx_cpu_data(exec_id): def get_influx_cpu_data(exec_id):
"""Get CPU data."""
query_params = { query_params = {
'db': 'telegraf', 'db': 'telegraf',
'q': 'SELECT LAST(usage_total) FROM docker_container_cpu WHERE "zoe.execution.id" = \'{}\' AND cpu = \'cpu-total\''.format(exec_id) 'q': 'SELECT LAST(usage_total) FROM docker_container_cpu WHERE "zoe.execution.id" = \'{}\' AND cpu = \'cpu-total\''.format(exec_id)
...@@ -64,6 +65,7 @@ def get_influx_cpu_data(exec_id): ...@@ -64,6 +65,7 @@ def get_influx_cpu_data(exec_id):
def get_influx_mem_data(exec_id): def get_influx_mem_data(exec_id):
"""Get memory data."""
query_params = { query_params = {
'db': 'telegraf', 'db': 'telegraf',
'q': 'SELECT MAX(max_usage) FROM docker_container_mem WHERE "zoe.execution.id" = \'{}\''.format(exec_id) 'q': 'SELECT MAX(max_usage) FROM docker_container_mem WHERE "zoe.execution.id" = \'{}\''.format(exec_id)
...@@ -78,6 +80,7 @@ def get_influx_mem_data(exec_id): ...@@ -78,6 +80,7 @@ def get_influx_mem_data(exec_id):
def get_influx_net_rx_data(exec_id): def get_influx_net_rx_data(exec_id):
"""Get network RX data."""
query_params = { query_params = {
'db': 'telegraf', 'db': 'telegraf',
'q': 'SELECT LAST(rx_bytes) FROM docker_container_net WHERE "zoe.execution.id" = \'{}\' AND network = \'eth1\''.format(exec_id) 'q': 'SELECT LAST(rx_bytes) FROM docker_container_net WHERE "zoe.execution.id" = \'{}\' AND network = \'eth1\''.format(exec_id)
...@@ -92,6 +95,7 @@ def get_influx_net_rx_data(exec_id): ...@@ -92,6 +95,7 @@ def get_influx_net_rx_data(exec_id):
def get_influx_net_tx_data(exec_id): def get_influx_net_tx_data(exec_id):
"""Get network TX data."""
query_params = { query_params = {
'db': 'telegraf', 'db': 'telegraf',
'q': 'SELECT LAST(tx_bytes) FROM docker_container_net WHERE "zoe.execution.id" = \'{}\' AND network = \'eth1\''.format(exec_id) 'q': 'SELECT LAST(tx_bytes) FROM docker_container_net WHERE "zoe.execution.id" = \'{}\' AND network = \'eth1\''.format(exec_id)
...@@ -106,6 +110,7 @@ def get_influx_net_tx_data(exec_id): ...@@ -106,6 +110,7 @@ def get_influx_net_tx_data(exec_id):
def get_influx_blkio_data(exec_id): def get_influx_blkio_data(exec_id):
"""Get disk data."""
query_params = { query_params = {
'db': 'telegraf', 'db': 'telegraf',
'q': 'SELECT LAST(io_serviced_recursive_total) FROM docker_container_blkio WHERE "zoe.execution.id" = \'{}\''.format(exec_id) 'q': 'SELECT LAST(io_serviced_recursive_total) FROM docker_container_blkio WHERE "zoe.execution.id" = \'{}\''.format(exec_id)
......
#!/usr/bin/python3 #!/usr/bin/python3
"""
Find the Swarm manager by querying ZooKeeper.
"""
import sys import sys
from kazoo.client import KazooClient from kazoo.client import KazooClient
def zookeeper_swarm(zk_server_list, path='/swarm'): def zookeeper_swarm(zk_server_list, path='/swarm'):
path = path + '/docker/swarm/leader' """Query ZooKeeper."""
path += '/docker/swarm/leader'
zk = KazooClient(hosts=zk_server_list) zk = KazooClient(hosts=zk_server_list)
zk.start() zk.start()
master, stat = zk.get(path) master, stat = zk.get(path)
......
#!/usr/bin/python3 #!/usr/bin/python3
"""
Set the command to execute inside a ZApp.
"""
import json import json
import sys import sys
......
...@@ -77,9 +77,4 @@ class HomeWeb(ZoeRequestHandler): ...@@ -77,9 +77,4 @@ class HomeWeb(ZoeRequestHandler):
else: else:
template_vars['refresh'] = -1 template_vars['refresh'] = -1
template_vars['execution_status'] = execution['status'] template_vars['execution_status'] = execution['status']
# for c_id in execution['services']:
# c = cont_api.get(c_id)
# ip = list(c['ip_address'].values())[0] # FIXME how to decide which network is the right one?
# for p in c['ports']:
# template_vars['execution_urls'].append(('{}'.format(p['name']), '{}://{}:{}{}'.format(p['protocol'], ip, p['port_number'], p['path'])))
return self.render('home_guest.html', **template_vars) return self.render('home_guest.html', **template_vars)
...@@ -52,7 +52,6 @@ class SimulatedNode: ...@@ -52,7 +52,6 @@ class SimulatedNode:
return self.real_free_resources['memory'] - simulated_reservation return self.real_free_resources['memory'] - simulated_reservation
def __repr__(self): def __repr__(self):
# services = ','.join([str(s.id) for s in self.services])
out = 'SN {} | f {}'.format(self.name, self.node_free_memory()) out = 'SN {} | f {}'.format(self.name, self.node_free_memory())
return out return out
......
...@@ -37,10 +37,12 @@ class ZoeFSWorkspace(zoe_master.workspace.base.ZoeWorkspaceBase): ...@@ -37,10 +37,12 @@ class ZoeFSWorkspace(zoe_master.workspace.base.ZoeWorkspaceBase):
"""Get the volume path of the workspace.""" """Get the volume path of the workspace."""
return os.path.join(self.base_path, user_id) return os.path.join(self.base_path, user_id)
def can_be_attached(self): @classmethod
def can_be_attached(cls):
"""Check if this workspace can be mounted as a Docker volume""" """Check if this workspace can be mounted as a Docker volume"""
return True return True
def get_mountpoint(self): @classmethod
def get_mountpoint(cls):
"""Get the volume mount point.""" """Get the volume mount point."""
return '/mnt/workspace' return '/mnt/workspace'
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