mzcli Profiles
If you want to use the mzcli on multiple installations of MediationZone using dedicated installation names, you can use the new --profile option.
The --profile option calls a configuration file called mzcli_configuration.xml, in which the required details for connecting to each installation have been stored. This file will automatically be generated the first time you run any mzcli command, and it will be placed in the .mzcli folder of USER_HOME directory. If the .mzcli folder does not exist in the USER_HOME directory, it will be created.
Note!
Ensure you have write permissions on the USER_HOME directory when running the mzcli command, otherwise, the mzcli_configuration.xml file will fail to be created.
Once created the file will look like this:
Example - Configuration File mzcli_configuration.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<installationlist>
<installation name="mz_dev">
<host>localhost</host>
<port>9000</port>
<username>mzadmin</username>
<schema>http</schema>
</installation>
<installation name="mz_prod">
<host>1.2.3.4</host>
<port>1234</port>
<username>example-user</username>
<schema>https</schema>
</installation>
</installationlist>and you will manually have to update the respective <installation> sections for the different installations you want to be able to run the mzcli command on.
The mzcli_configuration.xml file can contain multiple installation entries, each defined within an <installation> section.
Each <installation> must include the following four parameters:
host
port
username
schema (
httporhttps)
All of these parameters, along with the name attribute, are required. The name attribute cannot be empty or consist only of spaces. This name is used for the --profile option when running mzcli commands.
Caution!
The file is considered invalid if any mandatory parameters are missing. Avoid manually editing other parts of the XML file, as this may also invalidate it. If you add comments, be cautious—missing a closing > could make the file invalid. If the file is invalid, mzcli commands will not execute.
Note!
If the XML file becomes invalid, you can rename it and run an mzcli command. This will generate a new template file, where you can manually re-enter the previous installation details.
Once you have a valid configuration file, you can use the --profile option to state which of the installations you want to run the mzcli command for:
mzcli --profile <installation name> <command>You can also define a default installation to be used when running the mzcli command without the --profile flag.
Default Profile
Setting a Default Profile
To set a default profile run the following command:
java -jar mzcli.jar [mzcli] --set-default-profile <installation name>If the profile was successfully set, you will get a message saying that the Default Profile has been set to the stated installation, and you will see a new attribute in the <installation-list> tag in the configuration file:
<installationlist default-installation="my_installation">The stated installation must be present in the configuration file.
Checking the Default Profile
If you want to check if an installation has been set as default from the command line, you can run the following command:
java -jar mzcli.jar [mzcli] --get-default-profileYou will then get a message stating either that there is no default profile set, or the installation that is currently set along with information about schema, host and port.
Overriding the Default Profile
If a default profile has been set, you can still override it by stating another installation in your mzcli command:
mzcli --profile <installation name> <command>