Added data to deploy cast from backend

This commit is contained in:
Mike Scherbakov 2012-09-19 17:04:51 +04:00 committed by default
parent 5442579274
commit 1c75add9d4
2 changed files with 24 additions and 3 deletions

View File

@ -284,11 +284,18 @@ class ClusterChangesHandler(JSONHandler):
)
nd.power_reboot()
message = {"method": "deploy", "args": {"var1": "Hello from nailgun"}}
rpc.cast('mcollective', message)
netmanager.assign_ips(cluster_id, "management")
nodes = []
for n in cluster.nodes:
nodes.append({'id': n.id, 'status': n.status,
'ip': n.ip, 'mac': n.mac, 'role': n.role,
'network_data': netmanager.get_node_networks(n.id)})
message = {'method': 'deploy',
'respond_to': 'deploy_resp',
'args': {'nodes': nodes}}
rpc.cast('naily', message)
return json.dumps(
self.render(cluster),
indent=4

View File

@ -48,3 +48,17 @@ def assign_ips(cluster_id, network_name):
web.ctx.orm.add(ip_db)
web.ctx.orm.commit()
used_ips.append(free_ip)
def get_node_networks(node_id):
ips = web.ctx.orm.query(IPAddr).filter_by(node=node_id).all()
network_data = []
for i in ips:
net = web.ctx.orm.query(Network).get(i.network)
network_data.append({
'vlan': net.vlan_id,
'ip': i.ip_addr + '/' + str(IPNetwork(net.cidr).prefixlen),
'brd': str(IPNetwork(net.cidr).broadcast),
'gateway': net.gateway,
'dev': 'eth0'}) # We need to figure out interface
return network_data