Use new discovery scan service
Instead of pulling data about nodes into the discovery when provisioning starts, use a separate service that will periodically scan nodes.
This commit is contained in:
parent
e53519e5bb
commit
6d56dcfe16
@ -54,6 +54,7 @@
|
|||||||
# Install discovery service
|
# Install discovery service
|
||||||
- shell: pip install git+https://github.com/rustyrobot/discovery.git
|
- shell: pip install git+https://github.com/rustyrobot/discovery.git
|
||||||
- shell: 'discovery &'
|
- shell: 'discovery &'
|
||||||
|
- shell: 'discovery-scan --ssh_key {{insecure_pub_key_path}} &'
|
||||||
|
|
||||||
# Install bareon-api
|
# Install bareon-api
|
||||||
- shell: pip install git+https://github.com/Mirantis/bareon-api.git
|
- shell: pip install git+https://github.com/Mirantis/bareon-api.git
|
||||||
|
@ -1,18 +1,11 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import json
|
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from solar.core.resource import virtual_resource as vr
|
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.api import add_event
|
||||||
from solar.events.controls import React
|
from solar.events.controls import React
|
||||||
|
|
||||||
|
|
||||||
transport_run = BatRunTransport()
|
|
||||||
|
|
||||||
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_service = 'http://0.0.0.0:9322/v1/nodes/{0}/partitioning'
|
||||||
|
|
||||||
@ -33,16 +26,6 @@ class NodeAdapter(dict):
|
|||||||
def partitioning(self):
|
def partitioning(self):
|
||||||
return requests.get(bareon_service.format(self['mac'])).json()
|
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()
|
nodes_list = requests.get(discovery_service).json()
|
||||||
|
|
||||||
# Create slave node resources
|
# Create slave node resources
|
||||||
@ -56,10 +39,6 @@ for node in nodes_list:
|
|||||||
node = NodeAdapter(node)
|
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.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})
|
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.safe_mac), 'resources/dnsmasq', {})[0]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user