Switch to using CLI for introspection rules

Gate for liberty is using python-ironic-inspector-client 1.2.0.

Unused function curl_ins is not deleted, as it's likely to be used
the next time we introduce a new API.

Change-Id: I019023cb9add125a7c43b94c3a5a5b029f812c51
This commit is contained in:
Dmitry Tantsur 2015-09-20 19:00:49 +02:00
parent 3cdb38109f
commit de2108de98

View File

@ -7,35 +7,33 @@ export IRONIC_API_VERSION=${IRONIC_API_VERSION:-latest}
# Copied from devstack # Copied from devstack
PRIVATE_NETWORK_NAME=${PRIVATE_NETWORK_NAME:-"private"} PRIVATE_NETWORK_NAME=${PRIVATE_NETWORK_NAME:-"private"}
successful_rule=$(mktemp) rules_file=$(mktemp)
cat > "$successful_rule" << EOM cat > "$rules_file" << EOM
{ [
"description": "Successful Rule", {
"conditions": [ "description": "Successful Rule",
{"op": "ge", "field": "memory_mb", "value": 256}, "conditions": [
{"op": "ge", "field": "local_gb", "value": 1} {"op": "ge", "field": "memory_mb", "value": 256},
], {"op": "ge", "field": "local_gb", "value": 1}
"actions": [ ],
{"action": "set-attribute", "path": "/extra/rule_success", "actions": [
"value": "yes"} {"action": "set-attribute", "path": "/extra/rule_success",
] "value": "yes"}
} ]
EOM },
{
failing_rule=$(mktemp) "description": "Failing Rule",
cat > "$failing_rule" << EOM "conditions": [
{ {"op": "lt", "field": "memory_mb", "value": 42},
"description": "Failing Rule", {"op": "eq", "field": "local_gb", "value": 0}
"conditions": [ ],
{"op": "lt", "field": "memory_mb", "value": 42}, "actions": [
{"op": "eq", "field": "local_gb", "value": 0} {"action": "set-attribute", "path": "/extra/rule_success",
], "value": "no"},
"actions": [ {"action": "fail", "message": "This rule should not have run"}
{"action": "set-attribute", "path": "/extra/rule_success", ]
"value": "no"}, }
{"action": "fail", "message": "This rule should not have run"} ]
]
}
EOM EOM
expected_cpus=$(openstack flavor show baremetal -f value -c vcpus) expected_cpus=$(openstack flavor show baremetal -f value -c vcpus)
@ -81,9 +79,8 @@ for uuid in $nodes; do
ironic node-set-provision-state $uuid manage ironic node-set-provision-state $uuid manage
done done
curl_ins DELETE v1/rules openstack baremetal introspection rule purge
curl_ins POST v1/rules "--data-binary @$successful_rule" openstack baremetal introspection rule import "$rules_file"
curl_ins POST v1/rules "--data-binary @$failing_rule"
for uuid in $nodes; do for uuid in $nodes; do
ironic node-set-provision-state $uuid inspect ironic node-set-provision-state $uuid inspect
@ -114,7 +111,7 @@ while true; do
fi fi
done done
curl_ins DELETE v1/rules openstack baremetal introspection rule purge
function test_swift { function test_swift {
# Basic sanity check of the data stored in Swift # Basic sanity check of the data stored in Swift