Полезные API команды

Список доступных IP адресов с распределением по сетям

openstack ip availability list
+--------------------------------------+----------------------------------------------------+-----------+----------+
| Network ID                           | Network Name                                       | Total IPs | Used IPs |
+--------------------------------------+----------------------------------------------------+-----------+----------+
| 4ab38952-d477-4e1f-8cc8-6332d0794468 | HA network tenant b681c3453ecb4c8bb5f702a9a6d02cae |     16382 |        3 |
| d68873fd-42c1-4688-a209-aa876f73d1b2 | provider                                           |       245 |       40 |
| 718ac738-59f6-4b26-a059-17ad1b6b788e | websites                                           |       245 |        8 |
| f69f5b96-41d2-4d65-b3b2-d18c211f1177 | VPN2                                               |       253 |        3 |
+--------------------------------------+----------------------------------------------------+-----------+----------+

Список подсетей

openstack subnet list
+--------------------------------------+---------------------------------------------------+--------------------------------------+------------------+
| ID                                   | Name                                              | Network                              | Subnet           |
+--------------------------------------+---------------------------------------------------+--------------------------------------+------------------+
| 07f659f6-c9bf-45f0-9575-fc9688794b42 | test zone subnetwork                              | 8092c467-5225-4f56-92cd-37f256e18e3d | 192.168.55.0/24  |
| fa0d4f61-ac99-41bb-a320-2f887e6b0b87 | basic                                             | c917de2c-5ee3-4e71-922f-354a09b7589c | 192.168.31.0/24  |
+--------------------------------------+---------------------------------------------------+--------------------------------------+------------------+

Добавление пользователя

Скрипт добавит пользователя с правами администратора.

#!/bin/bash
new_adm=$1
if [[ -z $1 ]]; then echo "Username not defined" && exit 0; else
  openstack user create --enable --description 'CLI admin' --password-prompt --domain default $new_adm
  openstack role add --project admin --user $new_adm admin
  new_adm_id=$(openstack user show $new_adm -f value -c id)
  curl -s -X PATCH -H "X-Auth-Token: $(openstack token issue -c id -f value)" -H "Content-Type: application/json" -d'{"user": {"is_admin": true}}' "http://api.cloud.local:35357/v3/users/$new_adm_id"
fi