fix: allow minimal json(ip, id parameters are mandatory)
This commit is contained in:
parent
2b8d2bf4f3
commit
56b83a3ddd
@ -16,7 +16,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
project_name = 'timmy'
|
project_name = 'timmy'
|
||||||
version = '1.17.4'
|
version = '1.17.5'
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import sys
|
import sys
|
||||||
|
@ -70,10 +70,11 @@ class Node(object):
|
|||||||
conf_match_prefix = 'by_'
|
conf_match_prefix = 'by_'
|
||||||
conf_default_key = '__default'
|
conf_default_key = '__default'
|
||||||
header = ['node-id', 'env', 'ip', 'mac', 'os',
|
header = ['node-id', 'env', 'ip', 'mac', 'os',
|
||||||
'roles', 'online', 'status', 'name', 'fqdn']
|
'roles', 'online', 'status', 'name', 'release', 'fqdn']
|
||||||
|
|
||||||
def __init__(self, id, name, fqdn, mac, cluster, roles, os_platform,
|
def __init__(self, id, ip, conf, name=None, fqdn=None, mac=None,
|
||||||
online, status, ip, conf, logger=None):
|
cluster=None, roles=None, os_platform=None,
|
||||||
|
online=True, status="ready", logger=None):
|
||||||
self.id = id
|
self.id = id
|
||||||
self.mac = mac
|
self.mac = mac
|
||||||
self.cluster = cluster
|
self.cluster = cluster
|
||||||
@ -113,7 +114,7 @@ class Node(object):
|
|||||||
return [str(my_id), str(self.cluster), str(self.ip), str(self.mac),
|
return [str(my_id), str(self.cluster), str(self.ip), str(self.mac),
|
||||||
self.os_platform, ','.join(self.roles),
|
self.os_platform, ','.join(self.roles),
|
||||||
str(self.online), str(self.status),
|
str(self.online), str(self.status),
|
||||||
str(self.name), str(self.fqdn)]
|
str(self.name), str(self.release), str(self.fqdn)]
|
||||||
|
|
||||||
def apply_conf(self, conf, clean=True):
|
def apply_conf(self, conf, clean=True):
|
||||||
|
|
||||||
@ -521,7 +522,7 @@ class NodeManager(object):
|
|||||||
a = [row[i] for row in matrix]
|
a = [row[i] for row in matrix]
|
||||||
mc = 0
|
mc = 0
|
||||||
for word in a:
|
for word in a:
|
||||||
lw = len(word)
|
lw = len(str(word))
|
||||||
mc = lw if (lw > mc) else mc
|
mc = lw if (lw > mc) else mc
|
||||||
return mc + 2
|
return mc + 2
|
||||||
header = Node.header
|
header = Node.header
|
||||||
@ -790,8 +791,12 @@ class NodeManager(object):
|
|||||||
run_items.append(tools.RunItem(target=node.get_release,
|
run_items.append(tools.RunItem(target=node.get_release,
|
||||||
key=key))
|
key=key))
|
||||||
result = tools.run_batch(run_items, 100, dict_result=True)
|
result = tools.run_batch(run_items, 100, dict_result=True)
|
||||||
|
if result:
|
||||||
for key in result:
|
for key in result:
|
||||||
self.nodes[key].release = result[key]
|
self.nodes[key].release = result[key]
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
def nodes_init(self):
|
def nodes_init(self):
|
||||||
for node_data in self.nodes_json:
|
for node_data in self.nodes_json:
|
||||||
@ -803,7 +808,7 @@ class NodeManager(object):
|
|||||||
else:
|
else:
|
||||||
roles = str(node_roles).split(', ')
|
roles = str(node_roles).split(', ')
|
||||||
keys = "fqdn name mac os_platform status online ip".split()
|
keys = "fqdn name mac os_platform status online ip".split()
|
||||||
cl = int(node_data['cluster']) if node_data['cluster'] else None
|
cl = int(node_data['cluster']) if 'cluster' in node_data else None
|
||||||
params = {'id': int(node_data['id']),
|
params = {'id': int(node_data['id']),
|
||||||
# please do NOT convert cluster id to int type
|
# please do NOT convert cluster id to int type
|
||||||
# because None can be valid
|
# because None can be valid
|
||||||
@ -811,6 +816,7 @@ class NodeManager(object):
|
|||||||
'roles': roles,
|
'roles': roles,
|
||||||
'conf': self.conf}
|
'conf': self.conf}
|
||||||
for key in keys:
|
for key in keys:
|
||||||
|
if key in node_data:
|
||||||
params[key] = node_data[key]
|
params[key] = node_data[key]
|
||||||
node = Node(**params)
|
node = Node(**params)
|
||||||
if self.filter(node, self.conf['hard_filter']):
|
if self.filter(node, self.conf['hard_filter']):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user