From 9f8690b842a1970ccd783be7434f3b2548711ec0 Mon Sep 17 00:00:00 2001 From: Sebastian Kalinowski Date: Fri, 23 Oct 2015 13:54:57 +0200 Subject: [PATCH 01/10] Get node data from ohai and put it into discovery Node info is gathered by running ohai using ssh transport from solar. Then it's uploaded to discovery system. --- examples/provisioning/provision.py | 53 +++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/examples/provisioning/provision.py b/examples/provisioning/provision.py index 5b58830..6178a00 100755 --- a/examples/provisioning/provision.py +++ b/examples/provisioning/provision.py @@ -1,18 +1,43 @@ #!/usr/bin/env python +import json + 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.transports.ssh import SSHRunTransport -from solar.events.controls import React from solar.events.api import add_event +from solar.events.controls import React +transport_run = SSHRunTransport() + discovery_service = 'http://0.0.0.0:8881' + +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(':', '_') + + +def feed_discovery(mac, ohai_data): + return requests.put( + "{base_url}/nodes/{mac}/".format( + base_url=discovery_service, + mac=mac, + ), + json=ohai_data, + ) + nodes_list = requests.get(discovery_service).json() # Create slave node resources @@ -23,14 +48,20 @@ master_node = filter(lambda n: n.name == 'node_master', node_resources)[0] # Dnsmasq resources for node in nodes_list: - dnsmasq = vr.create('dnsmasq_{0}'.format(node['mac'].replace(':', '_')), 'resources/dnsmasq', {})[0] - node = filter(lambda n: n.name.endswith('node_{0}'.format(node['mac']).replace(':', '_')), node_resources)[0] - master_node.connect(dnsmasq) - node.connect(dnsmasq, {'admin_mac': 'exclude_mac_pxe'}) + node = NodeAdapter(node) + node_resource = filter(lambda n: n.name.endswith('node_{0}'.format(node.safe_mac)), node_resources)[0] - event = React(node.name, 'run', 'success', node.name, 'provision') + run_result = transport_run.run(node_resource, 'ohai') + ohai = json.loads(run_result.stdout) + feed_discovery(node['mac'], ohai) + + 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) - 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) - 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) From 6a8a1dd8c6a807b72bb930f9a1ad79a1ab5a75b5 Mon Sep 17 00:00:00 2001 From: Sebastian Kalinowski Date: Tue, 27 Oct 2015 13:06:42 +0100 Subject: [PATCH 02/10] Use "new" partition format during provisioning --- .../not_provisioned_node/actions/provision.sh | 3 +- .../templates/provisioning_new.json | 289 ++++++++++++++++++ 2 files changed, 291 insertions(+), 1 deletion(-) create mode 100644 resources/not_provisioned_node/templates/provisioning_new.json diff --git a/resources/not_provisioned_node/actions/provision.sh b/resources/not_provisioned_node/actions/provision.sh index ccbdb45..2e1737a 100644 --- a/resources/not_provisioned_node/actions/provision.sh +++ b/resources/not_provisioned_node/actions/provision.sh @@ -6,4 +6,5 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # TODO should be a way to render configs, in order to do this # we should have scripts dir variable passed from above sed -i "s||${DIR}|" "${DIR}"/templates/agent.config -provision --input_data_file "${DIR}"/templates/provisioning.json --config-file "${DIR}"/templates/agent.config +#provision --input_data_file "${DIR}"/templates/provisioning.json --config-file "${DIR}"/templates/agent.config +provision --input_data_file "${DIR}"/templates/provisioning_new.json --config-file "${DIR}"/templates/agent.config --data_driver nailgun_simple diff --git a/resources/not_provisioned_node/templates/provisioning_new.json b/resources/not_provisioned_node/templates/provisioning_new.json new file mode 100644 index 0000000..188513c --- /dev/null +++ b/resources/not_provisioned_node/templates/provisioning_new.json @@ -0,0 +1,289 @@ +{ + "profile": "ubuntu_1404_x86_64", + "name_servers_search": "\"example.com\"", + "uid": "2", + "interfaces": { + "eth1": { + "static": "0", + "mac_address": "08:00:27:6e:6d:b4" + }, + "eth0": { + "ip_address": "10.0.2.15", + "dns_name": "node-8.test.domain.local", + "netmask": "255.255.255.0", + "static": "0", + "mac_address": "08:00:27:ea:35:e7" + } + }, + "interfaces_extra": { + "eth1": { + "onboot": "no", + "peerdns": "no" + }, + "eth0": { + "onboot": "no", + "peerdns": "no" + } + }, + "power_type": "ssh", + "power_user": "root", + "kernel_options": { + "udevrules": "08:00:27:6e:6d:b4_eth1,08:00:27:ea:35:e7_eth0", + "netcfg/choose_interface": "08:00:27:ea:35:e7" + }, + "power_address": "10.20.0.1", + "name_servers": "\"127.0.0.1\"", + "ks_meta": { + "gw": "10.20.0.1", + "mco_enable": 1, + "mco_vhost": "mcollective", + "repo_setup": { + "installer_kernel": { + "local": "/var/www/nailgun/ubuntu/x86_64/images/linux", + "remote_relative": "dists/trusty/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64/linux" + }, + "repos": [ + { + "name": "ubuntu", + "section": "main universe multiverse", + "uri": "http://archive.ubuntu.com/ubuntu/", + "priority": null, + "suite": "trusty", + "type": "deb" + }, + { + "name": "ubuntu-updates", + "section": "main universe multiverse", + "uri": "http://archive.ubuntu.com/ubuntu/", + "priority": null, + "suite": "trusty-updates", + "type": "deb" + }, + { + "name": "ubuntu-security", + "section": "main universe multiverse", + "uri": "http://archive.ubuntu.com/ubuntu/", + "priority": null, + "suite": "trusty-security", + "type": "deb" + }, + { + "name": "mos", + "section": "main restricted", + "uri": "http://127.0.0.1:8080/2015.1.0-7.0/ubuntu/x86_64", + "priority": 1050, + "suite": "mos7.0", + "type": "deb" + }, + { + "name": "mos-updates", + "section": "main restricted", + "uri": "http://mirror.fuel-infra.org/mos/ubuntu/", + "priority": 1050, + "suite": "mos7.0-updates", + "type": "deb" + }, + { + "name": "mos-security", + "section": "main restricted", + "uri": "http://mirror.fuel-infra.org/mos/ubuntu/", + "priority": 1050, + "suite": "mos7.0-security", + "type": "deb" + }, + { + "name": "mos-holdback", + "section": "main restricted", + "uri": "http://mirror.fuel-infra.org/mos/ubuntu/", + "priority": 1100, + "suite": "mos7.0-holdback", + "type": "deb" + }, + { + "name": "Auxiliary", + "section": "main restricted", + "uri": "http://127.0.0.1:8080/2015.1.0-7.0/ubuntu/auxiliary", + "priority": 1150, + "suite": "auxiliary", + "type": "deb" + } + ], + "metadata": { + "always_editable": true, + "weight": 50, + "label": "Repositories" + }, + "installer_initrd": { + "local": "/var/www/nailgun/ubuntu/x86_64/images/initrd.gz", + "remote_relative": "dists/trusty/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64/initrd.gz" + } + }, + "authorized_keys": [], + "mlnx_iser_enabled": false, + "mco_pskey": "Gie6iega9ohngaenahthohngu8aebohxah9seidi", + "mco_user": "guest", + "puppet_enable": 0, + "fuel_version": "6.1", + "install_log_2_syslog": 1, + "image_data": { + "/boot": { + "container": "gzip", + "uri": "http://10.0.0.2:8001/tmp/targetimages/env_3_ubuntu_1404_amd64-boot.img.gz", + "format": "ext2" + }, + "/": { + "container": "gzip", + "uri": "http://10.0.0.2:8001/tmp/targetimages/env_3_ubuntu_1404_amd64.img.gz", + "format": "ext4" + } + }, + "timezone": "Etc/UTC", + "puppet_auto_setup": 1, + "puppet_master": "localhost", + "mco_auto_setup": 1, + "mco_password": "guest", + "auth_key": "\"\"", + "pm_data": { + "kernel_params": "console=ttyS0,9600 console=tty0 net.ifnames=0 biosdevname=0 rootdelay=90 nomodeset", + "ks_spaces": [] + }, + "mlnx_plugin_mode": "disabled", + "master_ip": "127.0.0.1", + "mco_connector": "rabbitmq", + "mlnx_vf_num": "16", + "admin_net": "10.20.0.0/24", + "mco_host": "localhost" + }, + "name": "node-2", + "hostname": "node-2.example.com", + "slave_name": "node-2", + "power_pass": "/root/.ssh/bootstrap.rsa", + "netboot_enabled": "1", + "partitioning": { + "pvs": [ + { + "metadatasize": 28, + "name": "/dev/sda4", + "metadatacopies": 2, + "keep_data": false + } + ], + "lvs": [ + { + "vgname": "os", + "keep_data": false, + "name": "root", + "size": 11744 + }, + { + "vgname": "os", + "keep_data": false, + "name": "swap", + "size": 8192 + } + ], + "fss": [ + { + "keep_data": false, + "mount": "/boot", + "fs_label": "", + "fs_type": "ext2", + "fs_options": "", + "device": "/dev/sda3" + }, + { + "keep_data": false, + "mount": "/", + "fs_label": "", + "fs_type": "ext4", + "fs_options": "", + "device": "/dev/mapper/os-root" + }, + { + "keep_data": false, + "mount": "swap", + "fs_label": "", + "fs_type": "swap", + "fs_options": "", + "device": "/dev/mapper/os-swap" + } + ], + "parteds": [ + { + "install_bootloader": true, + "partitions": [ + { + "count": 1, + "begin": 1, + "end": 25, + "name": "/dev/sda1", + "keep_data": false, + "device": "/dev/sda", + "flags": ["bios_grub"], + "guid": null, + "configdrive": false, + "partition_type": "primary" + }, + { + "count": 2, + "begin": 25, + "end": 225, + "name": "/dev/sda2", + "keep_data": false, + "device": "/dev/sda", + "flags": [], + "guid": null, + "configdrive": false, + "partition_type": "primary" + }, + { + "count": 3, + "begin": 225, + "end": 425, + "name": "/dev/sda3", + "keep_data": false, + "device": "/dev/sda", + "flags": [], + "guid": null, + "configdrive": false, + "partition_type": "primary" + }, + { + "count": 4, + "begin": 425, + "end": 20425, + "name": "/dev/sda4", + "keep_data": false, + "device": "/dev/sda", + "flags": [], + "guid": null, + "configdrive": false, + "partition_type": "primary" + }, + { + "count": 5, + "begin": 20425, + "end": 20445, + "name": "/dev/sda5", + "keep_data": false, + "device": "/dev/sda", + "flags": [], + "guid": null, + "configdrive": true, + "partition_type": "primary" + } + ], + "name": "/dev/sda", + "label": "gpt" + } + ], + "mds": [], + "vgs": [ + { + "keep_data": false, + "name": "os", + "pvnames": ["/dev/sda4"] + } + ] + } +} From f7832feb53f142a95259ae9456b8567600d947b3 Mon Sep 17 00:00:00 2001 From: Evgeniy L Date: Tue, 27 Oct 2015 16:53:40 +0300 Subject: [PATCH 03/10] Remove new provisioning.json template for not_provisioned_node resource --- .../templates/provisioning_new.json | 289 ------------------ 1 file changed, 289 deletions(-) delete mode 100644 resources/not_provisioned_node/templates/provisioning_new.json diff --git a/resources/not_provisioned_node/templates/provisioning_new.json b/resources/not_provisioned_node/templates/provisioning_new.json deleted file mode 100644 index 188513c..0000000 --- a/resources/not_provisioned_node/templates/provisioning_new.json +++ /dev/null @@ -1,289 +0,0 @@ -{ - "profile": "ubuntu_1404_x86_64", - "name_servers_search": "\"example.com\"", - "uid": "2", - "interfaces": { - "eth1": { - "static": "0", - "mac_address": "08:00:27:6e:6d:b4" - }, - "eth0": { - "ip_address": "10.0.2.15", - "dns_name": "node-8.test.domain.local", - "netmask": "255.255.255.0", - "static": "0", - "mac_address": "08:00:27:ea:35:e7" - } - }, - "interfaces_extra": { - "eth1": { - "onboot": "no", - "peerdns": "no" - }, - "eth0": { - "onboot": "no", - "peerdns": "no" - } - }, - "power_type": "ssh", - "power_user": "root", - "kernel_options": { - "udevrules": "08:00:27:6e:6d:b4_eth1,08:00:27:ea:35:e7_eth0", - "netcfg/choose_interface": "08:00:27:ea:35:e7" - }, - "power_address": "10.20.0.1", - "name_servers": "\"127.0.0.1\"", - "ks_meta": { - "gw": "10.20.0.1", - "mco_enable": 1, - "mco_vhost": "mcollective", - "repo_setup": { - "installer_kernel": { - "local": "/var/www/nailgun/ubuntu/x86_64/images/linux", - "remote_relative": "dists/trusty/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64/linux" - }, - "repos": [ - { - "name": "ubuntu", - "section": "main universe multiverse", - "uri": "http://archive.ubuntu.com/ubuntu/", - "priority": null, - "suite": "trusty", - "type": "deb" - }, - { - "name": "ubuntu-updates", - "section": "main universe multiverse", - "uri": "http://archive.ubuntu.com/ubuntu/", - "priority": null, - "suite": "trusty-updates", - "type": "deb" - }, - { - "name": "ubuntu-security", - "section": "main universe multiverse", - "uri": "http://archive.ubuntu.com/ubuntu/", - "priority": null, - "suite": "trusty-security", - "type": "deb" - }, - { - "name": "mos", - "section": "main restricted", - "uri": "http://127.0.0.1:8080/2015.1.0-7.0/ubuntu/x86_64", - "priority": 1050, - "suite": "mos7.0", - "type": "deb" - }, - { - "name": "mos-updates", - "section": "main restricted", - "uri": "http://mirror.fuel-infra.org/mos/ubuntu/", - "priority": 1050, - "suite": "mos7.0-updates", - "type": "deb" - }, - { - "name": "mos-security", - "section": "main restricted", - "uri": "http://mirror.fuel-infra.org/mos/ubuntu/", - "priority": 1050, - "suite": "mos7.0-security", - "type": "deb" - }, - { - "name": "mos-holdback", - "section": "main restricted", - "uri": "http://mirror.fuel-infra.org/mos/ubuntu/", - "priority": 1100, - "suite": "mos7.0-holdback", - "type": "deb" - }, - { - "name": "Auxiliary", - "section": "main restricted", - "uri": "http://127.0.0.1:8080/2015.1.0-7.0/ubuntu/auxiliary", - "priority": 1150, - "suite": "auxiliary", - "type": "deb" - } - ], - "metadata": { - "always_editable": true, - "weight": 50, - "label": "Repositories" - }, - "installer_initrd": { - "local": "/var/www/nailgun/ubuntu/x86_64/images/initrd.gz", - "remote_relative": "dists/trusty/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64/initrd.gz" - } - }, - "authorized_keys": [], - "mlnx_iser_enabled": false, - "mco_pskey": "Gie6iega9ohngaenahthohngu8aebohxah9seidi", - "mco_user": "guest", - "puppet_enable": 0, - "fuel_version": "6.1", - "install_log_2_syslog": 1, - "image_data": { - "/boot": { - "container": "gzip", - "uri": "http://10.0.0.2:8001/tmp/targetimages/env_3_ubuntu_1404_amd64-boot.img.gz", - "format": "ext2" - }, - "/": { - "container": "gzip", - "uri": "http://10.0.0.2:8001/tmp/targetimages/env_3_ubuntu_1404_amd64.img.gz", - "format": "ext4" - } - }, - "timezone": "Etc/UTC", - "puppet_auto_setup": 1, - "puppet_master": "localhost", - "mco_auto_setup": 1, - "mco_password": "guest", - "auth_key": "\"\"", - "pm_data": { - "kernel_params": "console=ttyS0,9600 console=tty0 net.ifnames=0 biosdevname=0 rootdelay=90 nomodeset", - "ks_spaces": [] - }, - "mlnx_plugin_mode": "disabled", - "master_ip": "127.0.0.1", - "mco_connector": "rabbitmq", - "mlnx_vf_num": "16", - "admin_net": "10.20.0.0/24", - "mco_host": "localhost" - }, - "name": "node-2", - "hostname": "node-2.example.com", - "slave_name": "node-2", - "power_pass": "/root/.ssh/bootstrap.rsa", - "netboot_enabled": "1", - "partitioning": { - "pvs": [ - { - "metadatasize": 28, - "name": "/dev/sda4", - "metadatacopies": 2, - "keep_data": false - } - ], - "lvs": [ - { - "vgname": "os", - "keep_data": false, - "name": "root", - "size": 11744 - }, - { - "vgname": "os", - "keep_data": false, - "name": "swap", - "size": 8192 - } - ], - "fss": [ - { - "keep_data": false, - "mount": "/boot", - "fs_label": "", - "fs_type": "ext2", - "fs_options": "", - "device": "/dev/sda3" - }, - { - "keep_data": false, - "mount": "/", - "fs_label": "", - "fs_type": "ext4", - "fs_options": "", - "device": "/dev/mapper/os-root" - }, - { - "keep_data": false, - "mount": "swap", - "fs_label": "", - "fs_type": "swap", - "fs_options": "", - "device": "/dev/mapper/os-swap" - } - ], - "parteds": [ - { - "install_bootloader": true, - "partitions": [ - { - "count": 1, - "begin": 1, - "end": 25, - "name": "/dev/sda1", - "keep_data": false, - "device": "/dev/sda", - "flags": ["bios_grub"], - "guid": null, - "configdrive": false, - "partition_type": "primary" - }, - { - "count": 2, - "begin": 25, - "end": 225, - "name": "/dev/sda2", - "keep_data": false, - "device": "/dev/sda", - "flags": [], - "guid": null, - "configdrive": false, - "partition_type": "primary" - }, - { - "count": 3, - "begin": 225, - "end": 425, - "name": "/dev/sda3", - "keep_data": false, - "device": "/dev/sda", - "flags": [], - "guid": null, - "configdrive": false, - "partition_type": "primary" - }, - { - "count": 4, - "begin": 425, - "end": 20425, - "name": "/dev/sda4", - "keep_data": false, - "device": "/dev/sda", - "flags": [], - "guid": null, - "configdrive": false, - "partition_type": "primary" - }, - { - "count": 5, - "begin": 20425, - "end": 20445, - "name": "/dev/sda5", - "keep_data": false, - "device": "/dev/sda", - "flags": [], - "guid": null, - "configdrive": true, - "partition_type": "primary" - } - ], - "name": "/dev/sda", - "label": "gpt" - } - ], - "mds": [], - "vgs": [ - { - "keep_data": false, - "name": "os", - "pvnames": ["/dev/sda4"] - } - ] - } -} From 2edd7b09def904035fcb6a8e38754ada11199401 Mon Sep 17 00:00:00 2001 From: Evgeniy L Date: Tue, 27 Oct 2015 16:55:08 +0300 Subject: [PATCH 04/10] Remove commented line from provision.sh --- resources/not_provisioned_node/actions/provision.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/not_provisioned_node/actions/provision.sh b/resources/not_provisioned_node/actions/provision.sh index 2e1737a..408d071 100644 --- a/resources/not_provisioned_node/actions/provision.sh +++ b/resources/not_provisioned_node/actions/provision.sh @@ -6,5 +6,5 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # TODO should be a way to render configs, in order to do this # we should have scripts dir variable passed from above sed -i "s||${DIR}|" "${DIR}"/templates/agent.config -#provision --input_data_file "${DIR}"/templates/provisioning.json --config-file "${DIR}"/templates/agent.config -provision --input_data_file "${DIR}"/templates/provisioning_new.json --config-file "${DIR}"/templates/agent.config --data_driver nailgun_simple + +provision --data_driver nailgun_simple --input_data_file "${DIR}"/templates/provisioning.json --config-file "${DIR}"/templates/agent.config From 7e17d08c6e535ccc0d61b11e32ae9500c2617c61 Mon Sep 17 00:00:00 2001 From: Evgeniy L Date: Tue, 27 Oct 2015 17:14:14 +0300 Subject: [PATCH 05/10] Use BatTransport instead of ssh to get discovery info --- examples/provisioning/provision.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/provisioning/provision.py b/examples/provisioning/provision.py index 6178a00..e69aa08 100755 --- a/examples/provisioning/provision.py +++ b/examples/provisioning/provision.py @@ -5,13 +5,13 @@ import json import requests from solar.core.resource import virtual_resource as vr -from solar.core.transports.ssh import SSHRunTransport +from solar.core.transports.bat import BatRunTransport from solar.events.api import add_event from solar.events.controls import React -transport_run = SSHRunTransport() +transport_run = BatRunTransport() discovery_service = 'http://0.0.0.0:8881' @@ -35,7 +35,7 @@ def feed_discovery(mac, ohai_data): base_url=discovery_service, mac=mac, ), - json=ohai_data, + data=json.dumps(ohai_data), ) nodes_list = requests.get(discovery_service).json() From 4096350d6f42e948f5bbd0b3faffbd568d8d2c9c Mon Sep 17 00:00:00 2001 From: Evgeniy L Date: Tue, 27 Oct 2015 17:24:22 +0300 Subject: [PATCH 06/10] Use provisionin.json as template --- .../templates/{provisioning.json => provisioning.json.jinja} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename resources/not_provisioned_node/templates/{provisioning.json => provisioning.json.jinja} (100%) diff --git a/resources/not_provisioned_node/templates/provisioning.json b/resources/not_provisioned_node/templates/provisioning.json.jinja similarity index 100% rename from resources/not_provisioned_node/templates/provisioning.json rename to resources/not_provisioned_node/templates/provisioning.json.jinja From 6585c98c29bc4620969e007f6bf0a518c4746173 Mon Sep 17 00:00:00 2001 From: Evgeniy L Date: Tue, 27 Oct 2015 17:42:47 +0300 Subject: [PATCH 07/10] Get partitioning information from bareon-api --- examples/provisioning/provision.py | 7 +++++++ resources/not_provisioned_node/meta.yaml | 3 +++ .../not_provisioned_node/templates/provisioning.json.jinja | 1 + 3 files changed, 11 insertions(+) diff --git a/examples/provisioning/provision.py b/examples/provisioning/provision.py index e69aa08..e225a9d 100755 --- a/examples/provisioning/provision.py +++ b/examples/provisioning/provision.py @@ -14,6 +14,7 @@ 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' class NodeAdapter(dict): @@ -28,6 +29,10 @@ class NodeAdapter(dict): def safe_mac(self): return self['mac'].replace(':', '_') + @property + def partitioning(self): + return requests.get(bareon_service.format(self['mac'])).json() + def feed_discovery(mac, ohai_data): return requests.put( @@ -55,6 +60,8 @@ for node in nodes_list: 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] master_node.connect(dnsmasq) node_resource.connect(dnsmasq, {'admin_mac': 'exclude_mac_pxe'}) diff --git a/resources/not_provisioned_node/meta.yaml b/resources/not_provisioned_node/meta.yaml index 7d9a668..e541342 100644 --- a/resources/not_provisioned_node/meta.yaml +++ b/resources/not_provisioned_node/meta.yaml @@ -21,5 +21,8 @@ input: schema: str! value: $uuid reverse: True + partitioning: + schema: dict! + value: tags: [resources=node] diff --git a/resources/not_provisioned_node/templates/provisioning.json.jinja b/resources/not_provisioned_node/templates/provisioning.json.jinja index 6b07718..445f39a 100644 --- a/resources/not_provisioned_node/templates/provisioning.json.jinja +++ b/resources/not_provisioned_node/templates/provisioning.json.jinja @@ -1,4 +1,5 @@ { + "partitioning": {{ partitioning | to_pretty_json }}, "profile": "ubuntu_1404_x86_64", "name_servers_search": "\"example.com\"", "uid": "2", From e98bf64b64df560bfffb94848139fb03be6233ef Mon Sep 17 00:00:00 2001 From: Evgeniy L Date: Wed, 28 Oct 2015 16:50:31 +0300 Subject: [PATCH 08/10] Enable logging for fuel-agent --- resources/not_provisioned_node/templates/agent.config | 2 ++ 1 file changed, 2 insertions(+) diff --git a/resources/not_provisioned_node/templates/agent.config b/resources/not_provisioned_node/templates/agent.config index d51d09a..7f80755 100644 --- a/resources/not_provisioned_node/templates/agent.config +++ b/resources/not_provisioned_node/templates/agent.config @@ -1,2 +1,4 @@ [DEFAULT] +debug=true nc_template_path=/templates/cloud-init-templates/ +log_file=/var/log/fuel-agent.log From acf1754a1e4a2386e36175d828a3912c68cebc00 Mon Sep 17 00:00:00 2001 From: Sebastian Kalinowski Date: Wed, 28 Oct 2015 16:20:39 +0100 Subject: [PATCH 09/10] 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. --- examples/provisioning/provision.py | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/examples/provisioning/provision.py b/examples/provisioning/provision.py index e225a9d..61bd3fe 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] From bd21e5d83078998ffbae2d6e7d88a5189001cbda Mon Sep 17 00:00:00 2001 From: Evgeniy L Date: Thu, 29 Oct 2015 16:07:59 +0300 Subject: [PATCH 10/10] Sync data in brareon-api before starting for provisioning --- examples/provisioning/provision.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/provisioning/provision.py b/examples/provisioning/provision.py index 61bd3fe..bd39d31 100755 --- a/examples/provisioning/provision.py +++ b/examples/provisioning/provision.py @@ -8,6 +8,7 @@ from solar.events.controls import React 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): @@ -26,6 +27,10 @@ class NodeAdapter(dict): 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() # Create slave node resources