From 6d56dcfe1646a6f67d25354ba3bdba1fdec592c1 Mon Sep 17 00:00:00 2001 From: Sebastian Kalinowski Date: Wed, 28 Oct 2015 16:20:39 +0100 Subject: [PATCH] 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. --- bootstrap/playbooks/pxe.yaml | 1 + examples/provisioning/provision.py | 21 --------------------- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/bootstrap/playbooks/pxe.yaml b/bootstrap/playbooks/pxe.yaml index 2808c1a3..001a0270 100644 --- a/bootstrap/playbooks/pxe.yaml +++ b/bootstrap/playbooks/pxe.yaml @@ -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 diff --git a/examples/provisioning/provision.py b/examples/provisioning/provision.py index e225a9d2..61bd3fe8 100755 --- a/examples/provisioning/provision.py +++ b/examples/provisioning/provision.py @@ -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]