diff --git a/devstack/lib/ironic b/devstack/lib/ironic index 328a12a837f..dba8e482589 100644 --- a/devstack/lib/ironic +++ b/devstack/lib/ironic @@ -203,6 +203,9 @@ IRONIC_VM_LOG_ROTATE=$(trueorfalse True IRONIC_VM_LOG_ROTATE) # Set resource_classes for nodes to use Nova's placement engine IRONIC_DEFAULT_RESOURCE_CLASS=${IRONIC_DEFAULT_RESOURCE_CLASS:-baremetal} +# Set traits for nodes. Traits should be separated by whitespace. +IRONIC_DEFAULT_TRAITS=${IRONIC_DEFAULT_TRAITS-CUSTOM_GOLD} + # Whether to build the ramdisk or download a prebuilt one. IRONIC_BUILD_DEPLOY_RAMDISK=$(trueorfalse True IRONIC_BUILD_DEPLOY_RAMDISK) @@ -1646,6 +1649,17 @@ function wait_for_nova_resources { | jq ".inventories.CUSTOM_$resource_class as \$cls | (\$cls.total // 0) - (\$cls.reserved // 0)") + # Check whether the resource provider has all expected traits + # registered against it. + rp_traits=$(curl -sH "X-Auth-Token: $token" \ + -H "OpenStack-API-Version: placement 1.6" \ + $endpoint/resource_providers/$p/traits) + for trait in $IRONIC_DEFAULT_TRAITS; do + if [[ $(echo "$rp_traits" | jq ".traits | contains([\"$trait\"])") == false ]]; then + amount=0 + fi + done + if [ $amount -gt 0 ]; then count=$(( count + $amount )) fi @@ -1931,6 +1945,10 @@ function enroll_nodes { die_if_not_set $LINENO node_id "Failed to create node" node_uuids+=" $node_id" + if [[ -n $IRONIC_DEFAULT_TRAITS ]]; then + $IRONIC_CMD node add trait $node_id $IRONIC_DEFAULT_TRAITS + fi + $IRONIC_CMD node manage $node_id --wait $IRONIC_MANAGE_TIMEOUT || \ die $LINENO "Node did not reach manageable state in $IRONIC_MANAGE_TIMEOUT seconds" @@ -2011,6 +2029,10 @@ function enroll_nodes { openstack flavor set baremetal --property "capabilities:boot_mode"="uefi" fi + for trait in $IRONIC_DEFAULT_TRAITS; do + openstack flavor set baremetal --property "trait:$trait"="required" + done + # NOTE(dtantsur): sometimes nova compute fails to start with ironic due # to keystone restarting and not being able to authenticate us. # Restart it just to be sure (and avoid gate problems like bug 1537076) diff --git a/playbooks/legacy/grenade-dsvm-ironic-multinode-multitenant/run.yaml b/playbooks/legacy/grenade-dsvm-ironic-multinode-multitenant/run.yaml index a8b251db58d..771b9a5d540 100644 --- a/playbooks/legacy/grenade-dsvm-ironic-multinode-multitenant/run.yaml +++ b/playbooks/legacy/grenade-dsvm-ironic-multinode-multitenant/run.yaml @@ -135,6 +135,9 @@ cat << 'EOF' >> ironic-extra-vars export DEVSTACK_LOCAL_CONFIG+=$'\n'"IRONIC_VM_SPECS_RAM=384" export DEVSTACK_LOCAL_CONFIG+=$'\n'"IRONIC_RAMDISK_TYPE=tinyipa" + # TODO(mgoddard): Remove this when the queens ironic devstack + # plugin has support for registering traits. + export DEVSTACK_LOCAL_CONFIG+=$'\n'"IRONIC_DEFAULT_TRAITS=\"\"" EOF chdir: '{{ ansible_user_dir }}/workspace' diff --git a/playbooks/legacy/grenade-dsvm-ironic/run.yaml b/playbooks/legacy/grenade-dsvm-ironic/run.yaml index a36fcfd504d..eac5f3526c0 100644 --- a/playbooks/legacy/grenade-dsvm-ironic/run.yaml +++ b/playbooks/legacy/grenade-dsvm-ironic/run.yaml @@ -78,6 +78,9 @@ cat << 'EOF' >> ironic-extra-vars export DEVSTACK_LOCAL_CONFIG+=$'\n'"IRONIC_VM_SPECS_RAM=384" export DEVSTACK_LOCAL_CONFIG+=$'\n'"IRONIC_RAMDISK_TYPE=tinyipa" + # TODO(mgoddard): Remove this when the queens ironic devstack + # plugin has support for registering traits. + export DEVSTACK_LOCAL_CONFIG+=$'\n'"IRONIC_DEFAULT_TRAITS=\"\"" EOF chdir: '{{ ansible_user_dir }}/workspace'