Skip to content

Commit

Permalink
Merge pull request #294 from rustyrobot/use_uuids
Browse files Browse the repository at this point in the history
Use id instead of mac as node indentifier
  • Loading branch information
loles committed Oct 30, 2015
2 parents db0246d + aaa8a90 commit 96c002d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
10 changes: 5 additions & 5 deletions examples/provisioning/provision.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ def __getattr__(self, name):
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)
Expand All @@ -42,11 +42,11 @@ def partitioning(self):
# 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'})

Expand Down
20 changes: 10 additions & 10 deletions templates/not_provisioned_nodes.yaml
Original file line number Diff line number Diff line change
@@ -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 %}

Expand Down

0 comments on commit 96c002d

Please sign in to comment.