Merge pull request #289 from prmtl/nodes_ohai
[PoC] get info from ohai and use "new" paritioning
This commit is contained in:
commit
35580bd3f4
@ -1,18 +1,36 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from solar.core import resource
|
|
||||||
from solar.core import signals
|
|
||||||
from solar.core import validation
|
|
||||||
from solar.core.resource import virtual_resource as vr
|
from solar.core.resource import virtual_resource as vr
|
||||||
|
|
||||||
from solar.events.controls import React
|
|
||||||
from solar.events.api import add_event
|
from solar.events.api import add_event
|
||||||
|
from solar.events.controls import React
|
||||||
|
|
||||||
|
|
||||||
discovery_service = 'http://0.0.0.0:8881'
|
discovery_service = 'http://0.0.0.0:8881'
|
||||||
|
bareon_service = 'http://0.0.0.0:9322/v1/nodes/{0}/partitioning'
|
||||||
|
bareon_sync = 'http://0.0.0.0:9322/v1/actions/sync_all'
|
||||||
|
|
||||||
|
|
||||||
|
class NodeAdapter(dict):
|
||||||
|
|
||||||
|
def __getattr__(self, name):
|
||||||
|
try:
|
||||||
|
return self[name]
|
||||||
|
except KeyError:
|
||||||
|
raise AttributeError(name)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def safe_mac(self):
|
||||||
|
return self['mac'].replace(':', '_')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def partitioning(self):
|
||||||
|
return requests.get(bareon_service.format(self['mac'])).json()
|
||||||
|
|
||||||
|
# Sync hw info about nodes from discovery service into bareon-api
|
||||||
|
requests.post(bareon_sync)
|
||||||
|
|
||||||
|
# Get list of nodes from discovery service
|
||||||
nodes_list = requests.get(discovery_service).json()
|
nodes_list = requests.get(discovery_service).json()
|
||||||
|
|
||||||
# Create slave node resources
|
# Create slave node resources
|
||||||
@ -23,14 +41,18 @@ master_node = filter(lambda n: n.name == 'node_master', node_resources)[0]
|
|||||||
|
|
||||||
# Dnsmasq resources
|
# Dnsmasq resources
|
||||||
for node in nodes_list:
|
for node in nodes_list:
|
||||||
dnsmasq = vr.create('dnsmasq_{0}'.format(node['mac'].replace(':', '_')), 'resources/dnsmasq', {})[0]
|
node = NodeAdapter(node)
|
||||||
node = filter(lambda n: n.name.endswith('node_{0}'.format(node['mac']).replace(':', '_')), node_resources)[0]
|
node_resource = filter(lambda n: n.name.endswith('node_{0}'.format(node.safe_mac)), node_resources)[0]
|
||||||
master_node.connect(dnsmasq)
|
|
||||||
node.connect(dnsmasq, {'admin_mac': 'exclude_mac_pxe'})
|
|
||||||
|
|
||||||
event = React(node.name, 'run', 'success', node.name, 'provision')
|
node_resource.update({'partitioning': node.partitioning})
|
||||||
|
|
||||||
|
dnsmasq = vr.create('dnsmasq_{0}'.format(node.safe_mac), 'resources/dnsmasq', {})[0]
|
||||||
|
master_node.connect(dnsmasq)
|
||||||
|
node_resource.connect(dnsmasq, {'admin_mac': 'exclude_mac_pxe'})
|
||||||
|
|
||||||
|
event = React(node_resource.name, 'run', 'success', node_resource.name, 'provision')
|
||||||
add_event(event)
|
add_event(event)
|
||||||
event = React(node.name, 'provision', 'success', dnsmasq.name, 'exclude_mac_pxe')
|
event = React(node_resource.name, 'provision', 'success', dnsmasq.name, 'exclude_mac_pxe')
|
||||||
add_event(event)
|
add_event(event)
|
||||||
event = React(dnsmasq.name, 'exclude_mac_pxe', 'success', node.name, 'reboot')
|
event = React(dnsmasq.name, 'exclude_mac_pxe', 'success', node_resource.name, 'reboot')
|
||||||
add_event(event)
|
add_event(event)
|
||||||
|
@ -6,4 +6,5 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|||||||
# TODO should be a way to render configs, in order to do this
|
# TODO should be a way to render configs, in order to do this
|
||||||
# we should have scripts dir variable passed from above
|
# we should have scripts dir variable passed from above
|
||||||
sed -i "s|<ROOT>|${DIR}|" "${DIR}"/templates/agent.config
|
sed -i "s|<ROOT>|${DIR}|" "${DIR}"/templates/agent.config
|
||||||
provision --input_data_file "${DIR}"/templates/provisioning.json --config-file "${DIR}"/templates/agent.config
|
|
||||||
|
provision --data_driver nailgun_simple --input_data_file "${DIR}"/templates/provisioning.json --config-file "${DIR}"/templates/agent.config
|
||||||
|
@ -21,5 +21,8 @@ input:
|
|||||||
schema: str!
|
schema: str!
|
||||||
value: $uuid
|
value: $uuid
|
||||||
reverse: True
|
reverse: True
|
||||||
|
partitioning:
|
||||||
|
schema: dict!
|
||||||
|
value:
|
||||||
|
|
||||||
tags: [resources=node]
|
tags: [resources=node]
|
||||||
|
@ -1,2 +1,4 @@
|
|||||||
[DEFAULT]
|
[DEFAULT]
|
||||||
|
debug=true
|
||||||
nc_template_path=<ROOT>/templates/cloud-init-templates/
|
nc_template_path=<ROOT>/templates/cloud-init-templates/
|
||||||
|
log_file=/var/log/fuel-agent.log
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"partitioning": {{ partitioning | to_pretty_json }},
|
||||||
"profile": "ubuntu_1404_x86_64",
|
"profile": "ubuntu_1404_x86_64",
|
||||||
"name_servers_search": "\"example.com\"",
|
"name_servers_search": "\"example.com\"",
|
||||||
"uid": "2",
|
"uid": "2",
|
Loading…
x
Reference in New Issue
Block a user