Install CLI client
https://docs.openstack.org/releasenotes/osc-placement/
pip install openstack-placement echo 3.5.6 > .python-version
resource provider allocation
RESOURCE_PROVIDER_ID=$(openstack resource provider list --name ${NODE_NAME}.$(hostname -d) -c uuid -f value) openstack resource provider show --allocations ${RESOURCE_PROVIDER_ID} -c allocations -f json # list hypervisor openstack resource provider list --sort-column name # show openstack resource provider allocation show ${SERVER_ID} NODE_NAME=com1-prod.example.com RESOURCE_PROVIDER_UUID=$(openstack resource provider list --name ${NODE_NAME} -c uuid -f value) openstack resource provider inventory list ${RESOURCE_PROVIDER_UUID} openstack resource provider usage show ${RESOURCE_PROVIDER_UUID} openstack allocation candidate list --resource VCPU=32 --resource DISK_GB=120 --resource MEMORY_MB=4096 --member-of 3f0d0e40-6cf4-422d-a245-ceaffb0ac037
Add resource provider to aggregate
#Add compute node to AZ openstack aggregate add host az1-aggregate comX-prod # get resource provider ID RESOURCE_PROVIDER_ID=$(openstack --os-placement-api-version=1.2 resource provider show XXXXXX-XXXX-XXXX-XXXX-XXXXXX -c uuid -f value) echo ${RESOURCE_PROVIDER_ID} # get aggregate ID AGGREGATE_ID=$(openstack --os-compute-api-version=2.53 aggregate show XXX -c uuid -f value) echo ${AGGREGATE_ID} # Add resource provider to that aggregate openstack --os-placement-api-version=1.2 resource provider aggregate set --aggregate ${AGGREGATE_ID} ${RESOURCE_PROVIDER_ID}
Check multiple / broken resource provider allocation
for SERVER_ID in $(openstack server list --all -c ID -f value); do HYPERVISOR_HOSTNAME=$(openstack server show ${SERVER_ID} -c OS-EXT-SRV-ATTR:hypervisor_hostname -f value) RESOURCE_PROVIDER=$(openstack resource provider allocation show ${SERVER_ID} -c resource_provider -f value) # openstack resource provider list -c uuid -c name -f value case ${RESOURCE_PROVIDER} in bcf1cfcc-0b97-43e1-bb09-1bfd64ebc4fa) RESOURCE_PROVIDER_NAME=com1-stage.example.com;; 231bd9d5-be18-4466-9865-923f463cd378) RESOURCE_PROVIDER_NAME=com2-stage.example.com;; b9e37e4a-28cf-4f63-bcdd-6463a7828b04) RESOURCE_PROVIDER_NAME=com3-stage.example.com;; esac if [ "${HYPERVISOR_HOSTNAME}" != "${RESOURCE_PROVIDER_NAME}" ]; then echo "SERVER_ID: ${SERVER_ID}" echo "HYPERVISOR_HOSTNAME: ${HYPERVISOR_HOSTNAME}" echo "RESOURCE_PROVIDER_NAME: ${RESOURCE_PROVIDER_NAME}" echo fi done
Remove double allocation
# get RESOURCE_PROVIDER_ID openstack resource provider allocation show ${SERVER_ID} -c resource_provider # delete specific allocation openstack resource provider allocation unset --os-placement-api-version 1.28 --provider ${RESOURCE_PROVIDER_ID} ${SERVER_ID} # delete all allocations openstack resource provider allocation delete ${SERVER_ID}
Delete
openstack catalog list | grep placement PLACEMENT_ENDPOINT=placement-endpoint-returned-by-previous-command TOKEN=$(openstack token issue -f value -c id) curl ${PLACEMENT_ENDPOINT}/resource_providers -H "x-auth-token: $TOKEN" | python -m json.tool # show allocations openstack resource provider list RESOURCE_PROVIDER_UUID=f4984285-2562-4210-99d2-2ee5f72d968f curl -s -H "X-Auth-Token: ${TOKEN}" "${PLACEMENT_ENDPOINT}/resource_providers/${RESOURCE_PROVIDER_UUID}/allocations" | python -m json.tool openstack resource provider allocation delete 4044e24b-099b-444a-863a-f14c0287d85b # remove resource provider UUID=uuid-of-resource-provider-named-openstack curl ${PLACEMENT_ENDPOINT}/resource_providers/$UUID -H "x-auth-token: $TOKEN" -X DELETE
Links
https://docs.openstack.org/osc-placement/latest/cli/index.html