Skip to content

Commit b39c53b

Browse files
Virtual Hosts guide: sync all 4.x editions; wording
1 parent 34fcdbf commit b39c53b

File tree

3 files changed

+174
-35
lines changed

3 files changed

+174
-35
lines changed

docs/vhosts.md

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -148,20 +148,25 @@ Virtual host metadata can be set at creation time or updated later:
148148
<Tabs groupId="examples">
149149
<TabItem value="bash" label="rabbitmqctl with bash" default>
150150
```bash
151+
# Create a virtual host with metadata
151152
rabbitmqctl add_vhost qa1 --description "QA env 1" --default-queue-type quorum
152153

154+
# Update virtual host metadata
153155
rabbitmqctl update_vhost_metadata qa1 --description "QA environment for issue 1662" --default-queue-type quorum --tags qa,project-a,qa-1662
154156

157+
# List virtual hosts with metadata
155158
rabbitmqctl -q --formatter=pretty_table list_vhosts name description tags default_queue_type
156159
```
157160
</TabItem>
158161

159162
<TabItem value="rabbitmqadmin" label="rabbitmqadmin with bash">
160163
```bash
164+
# Create a virtual host with metadata
161165
rabbitmqadmin vhosts declare --name qa1 \
162166
--description "QA environment 1" \
163167
--default-queue-type quorum
164168

169+
# Create a virtual host with tracing enabled
165170
rabbitmqadmin vhosts declare --name qa-tracing \
166171
--description "QA environment with tracing" \
167172
--default-queue-type quorum \
@@ -173,20 +178,25 @@ rabbitmqadmin vhosts list
173178

174179
<TabItem value="PowerShell" label="rabbitmqctl with PowerShell">
175180
```PowerShell
181+
# Create a virtual host with metadata
176182
rabbitmqctl.bat add_vhost qa1 --description "QA env 1" --default-queue-type quorum
177183
184+
# Update virtual host metadata
178185
rabbitmqctl.bat update_vhost_metadata qa1 --description "QA environment for issue 1662" --default-queue-type quorum --tags qa,project-a,qa-1662
179186
187+
# List virtual hosts with metadata
180188
rabbitmqctl.bat -q --formatter=pretty_table list_vhosts name description tags default_queue_type
181189
```
182190
</TabItem>
183191

184192
<TabItem value="rabbitmqadmin-PowerShell" label="rabbitmqadmin with PowerShell">
185193
```PowerShell
194+
# Create a virtual host with metadata
186195
rabbitmqadmin.exe vhosts declare --name qa1 ^
187196
--description "QA environment 1" ^
188197
--default-queue-type quorum
189198
199+
# Create a virtual host with tracing enabled
190200
rabbitmqadmin.exe vhosts declare --name qa-tracing ^
191201
--description "QA environment with tracing" ^
192202
--default-queue-type quorum ^
@@ -322,16 +332,28 @@ rabbitmqadmin.exe vhosts delete --name qa1
322332
</TabItem>
323333
</Tabs>
324334

335+
### Using HTTP API
336+
337+
A virtual host can be deleted using the `DELETE /api/vhosts/{name}` [HTTP API](./management) endpoint
338+
where `{name}` is the name of the virtual host.
339+
340+
Here's an example that uses [curl](https://curl.haxx.se/) to delete a virtual host `vh1` by contacting
341+
a node at `rabbitmq.local:15672`:
342+
343+
```bash
344+
curl -u userename:pa$sw0rD -X DELETE http://rabbitmq.local:15672/api/vhosts/vh1
345+
```
346+
325347
### Deleting Multiple Virtual Hosts
326348

327349
`rabbitmqadmin` supports deleting multiple virtual hosts at once using a name matching pattern.
328350

329351
:::danger
330352

331-
**THIS IS AN EXTREMELY DESTRUCTIVE OPERATION AND MUST BE USED WITH EXTREME CARE.**
353+
**This is an extremely destructive operation and must be used with great care.**
332354

333-
This command will delete ALL virtual hosts matching the provided regular expression pattern.
334-
ALL data in those virtual hosts will be permanently lost, including:
355+
This command will delete all virtual hosts matching the provided regular expression pattern.
356+
All data in those virtual hosts will be permanently lost, including:
335357

336358
* Queues, streams, and partitioned streams
337359
* Exchanges and bindings
@@ -342,7 +364,7 @@ ALL data in those virtual hosts will be permanently lost, including:
342364
* Policies and operator policies
343365
* Runtime parameters
344366

345-
**ALWAYS use `--dry-run` first to verify what will be deleted before running the actual deletion.**
367+
**Always use `--dry-run` first to verify what will be deleted before running the actual deletion.**
346368

347369
:::
348370

@@ -376,18 +398,6 @@ The default virtual host (`/`) is always preserved and will never be deleted by
376398

377399
:::
378400

379-
### Using HTTP API
380-
381-
A virtual host can be deleted using the `DELETE /api/vhosts/{name}` [HTTP API](./management) endpoint
382-
where `{name}` is the name of the virtual host.
383-
384-
Here's an example that uses [curl](https://curl.haxx.se/) to delete a virtual host `vh1` by contacting
385-
a node at `rabbitmq.local:15672`:
386-
387-
```bash
388-
curl -u userename:pa$sw0rD -X DELETE http://rabbitmq.local:15672/api/vhosts/vh1
389-
```
390-
391401
## Deletion Protection {#deletion-protection}
392402

393403
A virtual host can be protected from deletion. Protected virtual hosts cannot be deleted
@@ -658,7 +668,6 @@ that is set to `true`, will mark the virtual host as protected when it is create
658668
}
659669
```
660670

661-
662671
## Limits {#limits}
663672

664673
In some cases it is desirable to limit the maximum allowed number of queues

versioned_docs/version-4.0/vhosts.md

Lines changed: 144 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,8 @@ Deleting a virtual host will permanently delete all entities (queues, exchanges,
303303

304304
### Using CLI Tools
305305

306-
A virtual host can be deleted using CLI tools:
306+
A virtual host can be deleted using [rabbitmqctl](./cli)'s `delete_vhost` command
307+
which accepts virtual host name as the only mandatory argument.
307308

308309
<Tabs groupId="examples">
309310
<TabItem value="bash" label="rabbitmqctl with bash" default>
@@ -318,9 +319,9 @@ rabbitmqadmin vhosts delete --name qa1
318319
```
319320
</TabItem>
320321

321-
<TabItem value="powershell" label="rabbitmqctl with PowerShell">
322+
<TabItem value="PowerShell" label="rabbitmqctl with PowerShell">
322323
```PowerShell
323-
rabbitmqctl.exe delete_vhost qa1
324+
rabbitmqctl.bat delete_vhost qa1
324325
```
325326
</TabItem>
326327

@@ -334,7 +335,7 @@ rabbitmqadmin.exe vhosts delete --name qa1
334335
### Using HTTP API
335336

336337
A virtual host can be deleted using the `DELETE /api/vhosts/{name}` [HTTP API](./management) endpoint
337-
where `{name}` is the name of the virtual host
338+
where `{name}` is the name of the virtual host.
338339

339340
Here's an example that uses [curl](https://curl.haxx.se/) to delete a virtual host `vh1` by contacting
340341
a node at `rabbitmq.local:15672`:
@@ -349,10 +350,10 @@ curl -u userename:pa$sw0rD -X DELETE http://rabbitmq.local:15672/api/vhosts/vh1
349350

350351
:::danger
351352

352-
**THIS IS AN EXTREMELY DESTRUCTIVE OPERATION AND MUST BE USED WITH EXTREME CARE.**
353+
**This is an extremely destructive operation and must be used with great care.**
353354

354-
This command will delete ALL virtual hosts matching the provided regular expression pattern.
355-
ALL data in those virtual hosts will be permanently lost, including:
355+
This command will delete all virtual hosts matching the provided regular expression pattern.
356+
All data in those virtual hosts will be permanently lost, including:
356357

357358
* Queues, streams, and partitioned streams
358359
* Exchanges and bindings
@@ -363,7 +364,7 @@ ALL data in those virtual hosts will be permanently lost, including:
363364
* Policies and operator policies
364365
* Runtime parameters
365366

366-
**ALWAYS use `--dry-run` first to verify what will be deleted before running the actual deletion.**
367+
**Always use `--dry-run` first to verify what will be deleted before running the actual deletion.**
367368

368369
:::
369370

@@ -404,40 +405,138 @@ until the protection is removed.
404405

405406
### Using CLI Tools
406407

407-
`rabbitmqctl enable_vhost_protection_from_deletion` is the command that marks a virtual host
408-
as protected from deletion:
408+
A virtual host can be protected from deletion using `rabbitmqctl` or `rabbitmqadmin`.
409409

410+
<Tabs groupId="examples">
411+
<TabItem value="bash" label="rabbitmqctl with bash" default>
410412
```bash
411413
rabbitmqctl enable_vhost_protection_from_deletion "vhost-name"
412414
```
415+
</TabItem>
416+
417+
<TabItem value="rabbitmqadmin" label="rabbitmqadmin with bash">
418+
```bash
419+
rabbitmqadmin vhosts enable_deletion_protection --name "vhost-name"
420+
```
421+
</TabItem>
422+
423+
<TabItem value="PowerShell" label="rabbitmqctl with PowerShell">
424+
```PowerShell
425+
rabbitmqctl.bat enable_vhost_protection_from_deletion "vhost-name"
426+
```
427+
</TabItem>
428+
429+
<TabItem value="rabbitmqadmin-PowerShell" label="rabbitmqadmin with PowerShell">
430+
```PowerShell
431+
rabbitmqadmin.exe vhosts enable_deletion_protection --name "vhost-name"
432+
```
433+
</TabItem>
434+
</Tabs>
413435

414436
An attempt to delete the virtual host then will fail with a specific message:
415437

438+
<Tabs groupId="examples">
439+
<TabItem value="bash" label="rabbitmqctl with bash" default>
416440
```bash
417441
rabbitmqctl delete_vhost "vhost-name"
418442
# ...
419443
# => Error:
420444
# => Cannot delete this virtual host: it is protected from deletion. To lift the protection, inspect and update its metadata
421445
```
446+
</TabItem>
447+
448+
<TabItem value="rabbitmqadmin" label="rabbitmqadmin with bash">
449+
```bash
450+
rabbitmqadmin vhosts delete --name "vhost-name"
451+
# => Error: HTTP request failed with status 412: Precondition Failed
452+
# => Refusing to delete virtual host 'vhost-name' because it is protected from deletion
453+
```
454+
</TabItem>
455+
456+
<TabItem value="PowerShell" label="rabbitmqctl with PowerShell">
457+
```PowerShell
458+
rabbitmqctl.bat delete_vhost "vhost-name"
459+
# ...
460+
# => Error:
461+
# => Cannot delete this virtual host: it is protected from deletion. To lift the protection, inspect and update its metadata
462+
```
463+
</TabItem>
422464

423-
To remove the protection, use `rabbitmqctl disable_vhost_protection_from_deletion`:
465+
<TabItem value="rabbitmqadmin-PowerShell" label="rabbitmqadmin with PowerShell">
466+
```PowerShell
467+
rabbitmqadmin.exe vhosts delete --name "vhost-name"
468+
# => Error: HTTP request failed with status 412: Precondition Failed
469+
# => Refusing to delete virtual host 'vhost-name' because it is protected from deletion
470+
```
471+
</TabItem>
472+
</Tabs>
424473

474+
To remove the protection:
475+
476+
<Tabs groupId="examples">
477+
<TabItem value="bash" label="rabbitmqctl with bash" default>
425478
```bash
426-
## removes virtual host deletion protection
427479
rabbitmqctl disable_vhost_protection_from_deletion "vhost-name"
428480
```
481+
</TabItem>
482+
483+
<TabItem value="rabbitmqadmin" label="rabbitmqadmin with bash">
484+
```bash
485+
rabbitmqadmin vhosts disable_deletion_protection --name "vhost-name"
486+
```
487+
</TabItem>
488+
489+
<TabItem value="PowerShell" label="rabbitmqctl with PowerShell">
490+
```PowerShell
491+
rabbitmqctl.bat disable_vhost_protection_from_deletion "vhost-name"
492+
```
493+
</TabItem>
494+
495+
<TabItem value="rabbitmqadmin-PowerShell" label="rabbitmqadmin with PowerShell">
496+
```PowerShell
497+
rabbitmqadmin.exe vhosts disable_deletion_protection --name "vhost-name"
498+
```
499+
</TabItem>
500+
</Tabs>
429501

430502
with the protection removed, the virtual host can be deleted again:
431503

504+
<Tabs groupId="examples">
505+
<TabItem value="bash" label="rabbitmqctl with bash" default>
432506
```bash
433507
rabbitmqctl delete_vhost "vhost-name"
434508
# => Deleting vhost "vhost-name" ...
435509
```
510+
</TabItem>
511+
512+
<TabItem value="rabbitmqadmin" label="rabbitmqadmin with bash">
513+
```bash
514+
rabbitmqadmin vhosts delete --name "vhost-name"
515+
# => (No output on success)
516+
```
517+
</TabItem>
518+
519+
<TabItem value="PowerShell" label="rabbitmqctl with PowerShell">
520+
```PowerShell
521+
rabbitmqctl.bat delete_vhost "vhost-name"
522+
# => Deleting vhost "vhost-name" ...
523+
```
524+
</TabItem>
525+
526+
<TabItem value="rabbitmqadmin-PowerShell" label="rabbitmqadmin with PowerShell">
527+
```PowerShell
528+
rabbitmqadmin.exe vhosts delete --name "vhost-name"
529+
# => (No output on success)
530+
```
531+
</TabItem>
532+
</Tabs>
436533

437534
To see whether a virtual host is protected from deletion, use `list_vhosts` command with
438535
an extra column, `protected_from_deletion`:
439536

440-
```shell
537+
<Tabs groupId="examples">
538+
<TabItem value="bash" label="rabbitmqctl with bash" default>
539+
```bash
441540
rabbitmqctl list_vhosts name tags default_queue_type metadata protected_from_deletion --formatter=pretty_table
442541
# => Listing vhosts ...
443542
# => ┌───────────────────────────┬─────────────────────────┐
@@ -450,6 +549,38 @@ rabbitmqctl list_vhosts name tags default_queue_type metadata protected_from_del
450549
# => │ vh2 │ false │
451550
# => └───────────────────────────┴─────────────────────────┘
452551
```
552+
</TabItem>
553+
554+
<TabItem value="rabbitmqadmin" label="rabbitmqadmin with bash">
555+
```bash
556+
rabbitmqadmin vhosts list
557+
# Shows all virtual hosts (protection status not displayed in list view)
558+
```
559+
</TabItem>
560+
561+
<TabItem value="PowerShell" label="rabbitmqctl with PowerShell">
562+
```PowerShell
563+
rabbitmqctl.bat list_vhosts name tags default_queue_type metadata protected_from_deletion --formatter=pretty_table
564+
# => Listing vhosts ...
565+
# => ┌───────────────────────────┬─────────────────────────┐
566+
# => │ name │ protected_from_deletion │
567+
# => ├───────────────────────────┼─────────────────────────┤
568+
# => │ / │ false │
569+
# => ├───────────────────────────┼─────────────────────────┤
570+
# => │ vh1 │ true │
571+
# => ├───────────────────────────┼─────────────────────────┤
572+
# => │ vh2 │ false │
573+
# => └───────────────────────────┴─────────────────────────┘
574+
```
575+
</TabItem>
576+
577+
<TabItem value="rabbitmqadmin-PowerShell" label="rabbitmqadmin with PowerShell">
578+
```PowerShell
579+
rabbitmqadmin.exe vhosts list
580+
# Shows all virtual hosts (protection status not displayed in list view)
581+
```
582+
</TabItem>
583+
</Tabs>
453584

454585
### Using HTTP API
455586

versioned_docs/version-4.1/vhosts.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,10 @@ curl -u userename:pa$sw0rD -X DELETE http://rabbitmq.local:15672/api/vhosts/vh1
350350

351351
:::danger
352352

353-
**THIS IS AN EXTREMELY DESTRUCTIVE OPERATION AND MUST BE USED WITH EXTREME CARE.**
353+
**This is an extremely destructive operation and must be used with great care.**
354354

355-
This command will delete ALL virtual hosts matching the provided regular expression pattern.
356-
ALL data in those virtual hosts will be permanently lost, including:
355+
This command will delete all virtual hosts matching the provided regular expression pattern.
356+
All data in those virtual hosts will be permanently lost, including:
357357

358358
* Queues, streams, and partitioned streams
359359
* Exchanges and bindings
@@ -364,7 +364,7 @@ ALL data in those virtual hosts will be permanently lost, including:
364364
* Policies and operator policies
365365
* Runtime parameters
366366

367-
**ALWAYS use `--dry-run` first to verify what will be deleted before running the actual deletion.**
367+
**Always use `--dry-run` first to verify what will be deleted before running the actual deletion.**
368368

369369
:::
370370

@@ -668,7 +668,6 @@ that is set to `true`, will mark the virtual host as protected when it is create
668668
}
669669
```
670670

671-
672671
## Limits {#limits}
673672

674673
In some cases it is desirable to limit the maximum allowed number of queues

0 commit comments

Comments
 (0)