Use id instead of mac

This commit is contained in:
Evgeniy L 2015-10-30 17:57:02 +03:00
parent db0246d951
commit aaa8a90739
2 changed files with 15 additions and 15 deletions

View File

@ -20,12 +20,12 @@ class NodeAdapter(dict):
raise AttributeError(name)
@property
def safe_mac(self):
return self['mac'].replace(':', '_')
def node_id(self):
return self['id']
@property
def partitioning(self):
return requests.get(bareon_service.format(self['mac'])).json()
return requests.get(bareon_service.format(self['id'])).json()
# Sync hw info about nodes from discovery service into bareon-api
requests.post(bareon_sync)
@ -42,11 +42,11 @@ master_node = filter(lambda n: n.name == 'node_master', node_resources)[0]
# Dnsmasq resources
for node in nodes_list:
node = NodeAdapter(node)
node_resource = filter(lambda n: n.name.endswith('node_{0}'.format(node.safe_mac)), node_resources)[0]
node_resource = filter(lambda n: n.name.endswith('node_{0}'.format(node.node_id)), node_resources)[0]
node_resource.update({'partitioning': node.partitioning})
dnsmasq = vr.create('dnsmasq_{0}'.format(node.safe_mac), 'resources/dnsmasq', {})[0]
dnsmasq = vr.create('dnsmasq_{0}'.format(node.node_id), 'resources/dnsmasq', {})[0]
master_node.connect(dnsmasq)
node_resource.connect(dnsmasq, {'admin_mac': 'exclude_mac_pxe'})

View File

@ -1,25 +1,25 @@
id: not_provisioned_nodes
resources:
{% for node in nodes %}
{% set mac = node.mac | replace(':', '_') %}
- id: ssh_transport{{ mac }}
{% set id = node.id | replace(':', '_') %}
- id: ssh_transport{{ id }}
from: resources/transport_ssh
values:
ssh_user: 'root'
ssh_key: '/vagrant/tmp/keys/ssh_private'
- id: transports{{mac}}
- id: transports{{id}}
from: resources/transports
values:
transports:key: ssh_transport{{mac}}::ssh_key
transports:user: ssh_transport{{mac}}::ssh_user
transports:port: ssh_transport{{mac}}::ssh_port
transports:name: ssh_transport{{mac}}::name
- id: node_{{mac}}
transports:key: ssh_transport{{id}}::ssh_key
transports:user: ssh_transport{{id}}::ssh_user
transports:port: ssh_transport{{id}}::ssh_port
transports:name: ssh_transport{{id}}::name
- id: node_{{id}}
from: resources/not_provisioned_node
values:
ip: {{node.ip}}
transports_id: transports{{mac}}::transports_id
name: node_{{mac}}
transports_id: transports{{id}}::transports_id
name: node_{{id}}
admin_mac: {{node.mac}}
{% endfor %}