@@ -3,10 +3,6 @@ os-capacity
3
3
4
4
This is a prototype tool to extract capacity information.
5
5
6
- .. note ::
7
-
8
- This is currently quite specific to Ironic powered OpenStack Nova clouds.
9
-
10
6
Install
11
7
-------
12
8
@@ -21,139 +17,28 @@ Now lets get that installed inside a virtual environment:
21
17
22
18
.. code ::
23
19
24
- virtualenv .venv-test
25
- source .venv-test /bin/activate
20
+ python3 -m virtualenv .venv
21
+ source .venv/bin/activate
26
22
pip install -U .
27
23
28
24
Prometheus Exporter
29
25
-------------------
30
26
31
- Assuming you have clouds.yaml in the right place and OS_CLOUD set:
32
-
33
- .. code ::
34
-
35
- ./os_capacity/prometheus.py
36
- openstack_total_capacity_per_flavor{flavor="small"} 1
37
- openstack_capacity_by_hostname{hypervisor="aio",flavor="small"} 1
38
-
39
-
40
- TODOs we need support for:
41
-
42
- * add request filter support for require_tenant_aggregate,
43
- map_az_to_placement_aggregate and compute_status_filter
44
-
45
- Configuration
46
- -------------
47
-
48
- The easiest way to configure this is to populate a typical OpenStack RC file:
49
-
50
- .. code ::
51
-
52
- cat > .openrc <<EOF
53
- export OS_AUTH_URL=http://keystone.example.com:5000/v3
54
- export OS_PROJECT_ID=
55
- export OS_PROJECT_NAME=
56
- export OS_USER_DOMAIN_NAME=
57
- export OS_PROJECT_DOMAIN_NAME=
58
- export OS_USERNAME=
59
- export OS_REGION_NAME=
60
- export OS_INTERFACE=
61
- export OS_IDENTITY_API_VERSION=3
62
- export OS_AUTH_PLUGIN=v3password
63
- echo "Please enter your OpenStack Password for project $OS_PROJECT_NAME as user $OS_USERNAME: "
64
- read -sr OS_PASSWORD_INPUT
65
- export OS_PASSWORD=$OS_PASSWORD_INPUT
66
- EOF
67
-
68
- source .openrc
69
-
70
- Some openrc files don't contain the OS_AUTH_PLUGIN and OS_PROJECT_DOMAIN_NAME
71
- variables, but os-capacity requires that those are set.
72
-
73
- Usage
74
- -----
75
-
76
- When opening a new terminal, first activate the venv and the configuration:
77
-
78
- .. code ::
79
-
80
- source .venv-test/bin/activate
81
- source .openrc
82
-
83
-
84
- You can do things like list all flavors:
85
-
86
- .. code ::
87
-
88
- (.venv-test) $ os-capacity flavor list
89
- +--------------------------------------+-------------+-------+--------+---------+
90
- | UUID | Name | VCPUs | RAM MB | DISK GB |
91
- +--------------------------------------+-------------+-------+--------+---------+
92
- | 2622d978-7072-484d-8c7a-144a308c2709 | my-flavor-1 | 1 | 512 | 20 |
93
- | 45de641c-950e-434b-9c2e-6f76b120f85c | my-flavor-2 | 2 | 1024 | 40 |
94
- +--------------------------------------+-------------+-------+--------+---------+
95
-
96
- If you want to see all the REST API calls made, use the verbose flag, and you
97
- can also get the output in json format by adding the format flag:
98
-
99
- .. code ::
100
-
101
- (.venv-test) $ os-capacity -v flavor list -f json
102
-
103
- You can look at all the different types of resources and amount used:
104
-
105
- .. code ::
106
-
107
- (.venv-test) $ os-capacity resources group
108
- +----------------------------------+-------+------+------+-------------+
109
- | Resource Class Groups | Total | Used | Free | Flavors |
110
- +----------------------------------+-------+------+------+-------------+
111
- | VCPU:1,MEMORY_MB:512,DISK_GB:20 | 5 | 1 | 4 | my-flavor-1 |
112
- | VCPU:2,MEMORY_MB:1024,DISK_GB:40 | 2 | 0 | 2 | my-flavor-2 |
113
- +----------------------------------+-------+------+------+-------------+
114
-
115
-
116
- You can also look at the usage grouped by project or user or total usage:
117
-
118
- .. code ::
119
-
120
- (.venv-test) $ os-capacity usages group user --max-width 70
121
- +----------------------+----------------------+----------------------+
122
- | User | Current Usage | Usage Days |
123
- +----------------------+----------------------+----------------------+
124
- | 1e6abb726dd04d4eb4b8 | Count:4, | Count:410, |
125
- | 94e19c397d5e | DISK_GB:1484, | DISK_GB:152110, |
126
- | | MEMORY_MB:524288, | MEMORY_MB:53739520, |
127
- | | VCPU:256 | VCPU:26240 |
128
- | 4661c3e5f2804696ba26 | Count:1, | Count:3, |
129
- | 56b50dbd0f3d | DISK_GB:371, | DISK_GB:1113, |
130
- | | MEMORY_MB:131072, | MEMORY_MB:393216, |
131
- | | VCPU:64 | VCPU:192 |
132
- +----------------------+----------------------+----------------------+
133
-
134
- See the online help for more details:
27
+ Assuming you have clouds.yaml in the right place,
28
+ you can run the exporter doing something like this:
135
29
136
30
.. code ::
137
31
138
- os-capacity help
139
- usage: os-capacity [--version] [-v | -q] [--log-file LOG_FILE] [-h] [--debug]
32
+ export OS_CLIENT_CONFIG_FILE=myappcred.yaml
33
+ export OS_CLOUD=openstack
140
34
141
- OS-Capacity (StackHPC) Command Line Interface (CLI)
35
+ ./os_capacity/prometheus.py &
36
+ curl localhost:9000 > mytestrun
37
+ cat mytestrun
142
38
143
- optional arguments:
144
- --version show program's version number and exit
145
- -v, --verbose Increase verbosity of output. Can be repeated.
146
- -q, --quiet Suppress output except warnings and errors.
147
- --log-file LOG_FILE Specify a file to log output. Disabled by default.
148
- -h, --help Show help message and exit.
149
- --debug Show tracebacks on errors.
39
+ Or just run via docker or similar:::
150
40
151
- Commands:
152
- complete print bash completion command
153
- flavor list List all the flavors.
154
- help print detailed help for another command
155
- prometheus To be run as node exporter textfile collector
156
- resources all List all resource providers, with their resources and servers.
157
- resources group Lists counts of resource providers with similar inventories.
158
- usages all List all current resource usages.
159
- usages group Group usage by specified key (by user or project).
41
+ docker run -d --name os_capacity \
42
+ --mount type=bind,source=/etc/openstack/,target=/etc/openstack/ \
43
+ --env OS_CLOUD=openstack --env OS_CLIENT_CONFIG_FILE=/etc/openstack/mycloud.yaml \
44
+ -p 9000:9000 ghcr.io/stackhpc/os-capacity:master
0 commit comments