Merge pull request #3 from prmtl/nodes_ohai_no_discovery_feed

Use new discovery scan service
This commit is contained in:
Evgeniy L 2015-10-29 12:38:01 +03:00
commit 05946dd363
2 changed files with 1 additions and 21 deletions

View File

@ -54,6 +54,7 @@
# Install discovery service
- shell: pip install git+https://github.com/rustyrobot/discovery.git
- shell: 'discovery &'
- shell: 'discovery-scan --ssh_key {{insecure_pub_key_path}} &'
# Install bareon-api
- shell: pip install git+https://github.com/Mirantis/bareon-api.git

View File

@ -1,18 +1,11 @@
#!/usr/bin/env python
import json
import requests
from solar.core.resource import virtual_resource as vr
from solar.core.transports.bat import BatRunTransport
from solar.events.api import add_event
from solar.events.controls import React
transport_run = BatRunTransport()
discovery_service = 'http://0.0.0.0:8881'
bareon_service = 'http://0.0.0.0:9322/v1/nodes/{0}/partitioning'
@ -33,16 +26,6 @@ class NodeAdapter(dict):
def partitioning(self):
return requests.get(bareon_service.format(self['mac'])).json()
def feed_discovery(mac, ohai_data):
return requests.put(
"{base_url}/nodes/{mac}/".format(
base_url=discovery_service,
mac=mac,
),
data=json.dumps(ohai_data),
)
nodes_list = requests.get(discovery_service).json()
# Create slave node resources
@ -56,10 +39,6 @@ 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]
run_result = transport_run.run(node_resource, 'ohai')
ohai = json.loads(run_result.stdout)
feed_discovery(node['mac'], ohai)
node_resource.update({'partitioning': node.partitioning})
dnsmasq = vr.create('dnsmasq_{0}'.format(node.safe_mac), 'resources/dnsmasq', {})[0]