new register-nodes does not accept ints for numeric input

Bug #1382275 reported by James Polley on 2014-10-17
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ghe Rivero

Bug Description

Consider the following node definition:

        "arch": "amd64",
        "cpu": 24,
        "disk": 800,
        "mac": [
        "memory": 49152,
        "pm_addr": "",
        "pm_password": "password",
        "pm_type": "pxe_ipmitool",
        "pm_user": "admin"

The previous incarnation of register-nodes would pipe this through jq, something like this:

    stack@bastion:/home/shared$ jq -r '"properties/cpus=" + (.cpu|tostring) + " properties/memory_mb=" + (.memory|tostring) + " properties/local_gb=" + (.disk|tostring) + " properties/cpu_arch=" + .arch' $NODE_JSON
    properties/cpus=24 properties/memory_mb=49152 properties/local_gb=800 properties/cpu_arch=amd64

Because jq explicitly converts the values to strings, the memory, cpu count, and disk figures could all be specified as integers or as strings.

The new register-nodes barfs on the same input:

        2014-10-17 01:28:35 - root - ERROR - Unexpected error during command execution
        Traceback (most recent call last):
          File "/home/shared/tripleo-incubator/openstack-tools/local/lib/python2.7/site-packages/os_cloud_config/cmd/", line 74, in main
          File "/home/shared/tripleo-incubator/openstack-tools/local/lib/python2.7/site-packages/os_cloud_config/", line 249, in register_all_nodes
          File "/home/shared/tripleo-incubator/openstack-tools/local/lib/python2.7/site-packages/os_cloud_config/", line 203, in _update_or_register_ironic_node
            client.node.update(ironic_node.uuid, node_patch)
          File "/home/shared/tripleo-incubator/openstack-tools/local/lib/python2.7/site-packages/ironicclient/v1/", line 166, in update
            return self._update(self._path(node_id), patch)
          File "/home/shared/tripleo-incubator/openstack-tools/local/lib/python2.7/site-packages/ironicclient/common/", line 130, in _update
            resp, body = self.api.json_request(method, url, body=body)
          File "/home/shared/tripleo-incubator/openstack-tools/local/lib/python2.7/site-packages/ironicclient/common/", line 195, in json_request
            resp, body_iter = self._http_request(url, method, **kwargs)
          File "/home/shared/tripleo-incubator/openstack-tools/local/lib/python2.7/site-packages/ironicclient/common/", line 178, in _http_request
            error_json.get('debuginfo'), method, url)
        BadRequest: Invalid input for field/attribute value. Value: '49152'. Wrong type. Expected '<type 'unicode'>', got '<type 'int'>' (HTTP 400)

This is a backwards-compatibility issue, as peope who have existing nodes definitions that previously worked may find they do not work with the new register-nodes.

James Polley (tchaypo) on 2014-10-17
Changed in os-cloud-config:
status: New → Triaged
importance: Undecided → Critical
Ghe Rivero (ghe.rivero) on 2014-10-21
Changed in os-cloud-config:
assignee: nobody → Ghe Rivero (ghe.rivero)

Fix proposed to branch: master

Changed in os-cloud-config:
status: Triaged → In Progress

Submitter: Jenkins
Branch: master

commit b3e1d87b13948b25792ec882e7be142d867ac243
Author: Ghe Rivero <email address hidden>
Date: Tue Oct 21 17:27:52 2014 +0200

    Allow register-node to accept int for input

    register-node used to pipe the nodes definition file through jq, which
    explicitly converts all int values to strings, but the new
    implementation doesn't do so, which is backward incompatible.

    Change-Id: Id5c5b56ccd73bdabe02eb24575e5b8c4dbcdb04b
    Closes-Bug: #1382275

Changed in os-cloud-config:
status: In Progress → Fix Committed
Changed in os-cloud-config:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers