Skip to content

Commit 1310aba

Browse files
authored
verdi setup: improve validation and help string of broker virtual host (#4408)
The help string of the `--broker-virtual-host` option of `verdi setup` incorrectly said that forward slashes have to be escaped but this is not true. The code will escape any characters necessary when constructing the URL to connect to RabbitMQ. On top of that, slashes would fail the validation outright, even though these are common in virtual hosts. For example the virtual host always starts with a leading forward slash, but our validation would reject it. Also the leading slash will be added by the code and so does not have to be used in the setup phase. The help string and the documentation now reflect this. The exacti naming rules for virtual hosts, imposed by RabbitMQ or other implemenatations of the AMQP protocol, are not fully clear. But instead of putting an explicit validation on AiiDA's side and running the risk that we incorrectly reject valid virtual host names, we simply accept all strings. In any case, any non-default virtual host will have to be created through RabbitMQ's control interface, which will perform the validation itself.
1 parent ff30ebd commit 1310aba

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

aiida/cmdline/params/options/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,10 @@ def decorator(command):
315315

316316
BROKER_VIRTUAL_HOST = OverridableOption(
317317
'--broker-virtual-host',
318-
type=types.HostnameType(),
318+
type=click.types.StringParamType(),
319319
default=BROKER_DEFAULTS.virtual_host,
320320
show_default=True,
321-
help='Name of the virtual host for the message broker. Forward slashes need to be encoded'
321+
help='Name of the virtual host for the message broker without leading forward slash.'
322322
)
323323

324324
REPOSITORY_PATH = OverridableOption(

docs/source/intro/installation.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ The following parameters can be configured:
687687
+--------------+---------------------------+---------------+-------------------------------------------------------------------------------------------------------------------------+
688688
| Port | ``--broker-port`` | ``5672`` | The port to which the server listens. |
689689
+--------------+---------------------------+---------------+-------------------------------------------------------------------------------------------------------------------------+
690-
| Virtual host | ``--broker-virtual-host`` | ``''`` | Optional virtual host. If defined, needs to start with a forward slash. |
690+
| Virtual host | ``--broker-virtual-host`` | ``''`` | Optional virtual host. Should not contain the leading forward slash, this will be added automatically by AiiDA. |
691691
+--------------+---------------------------+---------------+-------------------------------------------------------------------------------------------------------------------------+
692692

693693

docs/source/reference/command_line.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,8 @@ Below is a list with all available subcommands.
500500
501501
--broker-host HOSTNAME Hostname for the message broker. [default: 127.0.0.1]
502502
--broker-port INTEGER Port for the message broker. [default: 5672]
503-
--broker-virtual-host HOSTNAME Name of the virtual host for the message broker. Forward
504-
slashes need to be encoded [default: ]
503+
--broker-virtual-host TEXT Name of the virtual host for the message broker without
504+
leading forward slash. [default: ]
505505
506506
--repository DIRECTORY Absolute path to the file repository.
507507
--config FILEORURL Load option values from configuration file in yaml
@@ -638,8 +638,8 @@ Below is a list with all available subcommands.
638638
required]
639639
640640
--broker-port INTEGER Port for the message broker. [default: 5672; required]
641-
--broker-virtual-host HOSTNAME Name of the virtual host for the message broker. Forward
642-
slashes need to be encoded [default: ; required]
641+
--broker-virtual-host TEXT Name of the virtual host for the message broker without
642+
leading forward slash. [default: ; required]
643643
644644
--repository DIRECTORY Absolute path to the file repository.
645645
--config FILEORURL Load option values from configuration file in yaml

0 commit comments

Comments
 (0)