Red Hat AMQ 6
As of February 2025, Red Hat is no longer supporting Red Hat AMQ 6. If you are using AMQ 6, please upgrade: Migrating to AMQ 7.Este conteúdo não está disponível no idioma selecionado.
6.2. Working with Profiles
Changing the profiles in a container Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
To change the profiles assigned to a Fabric container, invoke the
fabric:container-change-profile command as follows:
fabric:container-change-profile mycontainer myprofile
fabric:container-change-profile mycontainer myprofile
Where the preceding command deploys the
myprofile profile to the mycontainer container. All profiles previously assigned to the container are removed. You can also deploy multiple profiles to the container, with the following command:
fabric:container-change-profile mycontainer myprofile myotherprofile
fabric:container-change-profile mycontainer myprofile myotherprofile
Adding a profile to a container Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
The
fabric:container-add-profile command gives you a simple way to add profiles to a container, without having to list all of the profiles that were already assigned. For example, to add the example-camel profile to the mycontainer container:
fabric:container-add-profile mycontainer example-camel
fabric:container-add-profile mycontainer example-camel
Listing available profiles Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
To see the list of available profiles, invoke the
fabric:profile-list console command:
fabric:profile-list
fabric:profile-list
The command displays all available profiles, showing their parents and the number of containers each profile is deployed into.
Inspecting profiles Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
To see exactly what a profile defines, enter the
fabric:profile-display command. For example, to display what is defined in the feature-camel profile, enter the following command:
fabric:profile-display feature-camel
fabric:profile-display feature-camel
Which outputs something like the following to the console window:
The preceding output does not take into account the definitions inherited from any parent profiles, however. To see the effective definitions for the
feature-camel profile, taking into account all of its ancestors, you must specify the --overlay switch, as follows:
fabric:profile-display --overlay feature-camel
fabric:profile-display --overlay feature-camel
Resource files stored in the profile are listed under the heading Other resources. If you want to display the contents of these resource files as well, add the
--display-resources switch (or -r for short) to the profile-display command, as follows:
fabric:profile-display -r feature-camel
fabric:profile-display -r feature-camel
Creating a new profile Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
To create a new profile for an application, invoke the
fabric:profile-create command, as follows:
fabric:profile-create myprofile
fabric:profile-create myprofile
To specify one ore more parents for the profile when it is being created, add the
--parents option to the command:
fabric:profile-create --parents feature-camel myprofile
fabric:profile-create --parents feature-camel myprofile
After the profile is created, you can start to modify the profile, providing details of what should be deployed in the profile.
Adding or removing features Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
To edit one of the existing profiles, you can use the
fabric:profile-edit command. For example, to add the camel-jclouds feature to the feature-camel profile.
fabric:profile-edit --feature camel-jclouds feature-camel
fabric:profile-edit --feature camel-jclouds feature-camel
Now invoke the
fabric:profile-display command to see what the camel profile looks like now. You should see that the camel-jclouds feature appears in the list of features for the feature-camel profile.
Features :
camel-jclouds
camel-blueprint/2.9.0.fuse-7-061
camel-core/2.9.0.fuse-7-061
fabric-camel/99-master-SNAPSHOT
Features :
camel-jclouds
camel-blueprint/2.9.0.fuse-7-061
camel-core/2.9.0.fuse-7-061
fabric-camel/99-master-SNAPSHOT
If you want to remove a feature from the profile, use the
--delete option. For example, if you need to remove the camel-jclouds feature, you could use the following command:
fabric:profile-edit --delete --feature camel-jclouds feature-camel
fabric:profile-edit --delete --feature camel-jclouds feature-camel
Editing PID properties Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
An OSGi Config Admin Persistent ID (PID) consists essentially of a list of key-value pairs. You can edit PID properties using either of the following approaches:
- Edit the PID using the built-in text editor—the Karaf console has a built-in text editor which you can use to edit profile resources such as PID properties. To start editing a PID using the text editor, enter the following console command:
fabric:profile-edit --pid PID ProfileName
fabric:profile-edit --pid PID ProfileNameCopy to Clipboard Copied! Toggle word wrap Toggle overflow For more details about the built-in text editor, see Appendix A, Editing Profiles with the Built-In Text Editor. - Edit the PID inline, using console commands—alternatively, you can edit PIDs directly from the console, using the appropriate form of the
fabric:profile-editcommand. This approach is particularly useful for scripting. For example, to set a specific key-value pair,Key=Value, in a PID, enter the following console command:fabric:profile-edit --pid PID/Key=Value ProfileName
fabric:profile-edit --pid PID/Key=Value ProfileNameCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Editing a PID inline Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
To edit a PID inline, use the following variants of the
fabric:profile-edit command:
- Assign a value to a PID property, as follows:
fabric:profile-edit --pid PID/Key=Value ProfileName
fabric:profile-edit --pid PID/Key=Value ProfileNameCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Append a value to a delimited list (that is, where the property value is a comma-separated list), as follows:
fabric:profile-edit --append --pid PID/Key=ListItem ProfileName
fabric:profile-edit --append --pid PID/Key=ListItem ProfileNameCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Remove a value from a delimited list, as follows:
fabric:profile-edit --remove --pid PID/Key=ListItem ProfileName
fabric:profile-edit --remove --pid PID/Key=ListItem ProfileNameCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Delete a specific property key, as follows:
fabric:profile-edit --delete --pid PID/Key ProfileName
fabric:profile-edit --delete --pid PID/Key ProfileNameCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Delete a complete PID, as follows:
fabric:profile-edit --delete --pid PID ProfileName
fabric:profile-edit --delete --pid PID ProfileNameCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Example of editing a PID inline Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
In the following example, we modify the
io.fabric8.agent PID, changing the Maven repository list setting. The default profile contains a section like this:
The agent properties section is represented by the
io.fabric8.agent PID. So, by modifying the io.fabric8.agent PID, we effectively change the agent properties. You can modify the list of Maven repositories in the agent properties PID as follows:
fabric:profile-edit --pid io.fabric8.agent/org.ops4j.pax.url.mvn.repositories=http://repositorymanager.mylocalnetwork.net default
fabric:profile-edit --pid io.fabric8.agent/org.ops4j.pax.url.mvn.repositories=http://repositorymanager.mylocalnetwork.net default
Now when you invoke
fabric:profile-display on the default profile, you should see agent properties similar to the following:
Agent Properties :
org.ops4j.pax.url.mvn.repositories = http://repositorymanager.mylocalnetwork.net
Agent Properties :
org.ops4j.pax.url.mvn.repositories = http://repositorymanager.mylocalnetwork.net
Setting encrypted PID property values Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
In some cases, you might prefer to store PID property values in encrypted format instead of plain text. For example, passwords and other sensitive data should usually be stored in encrypted form. To store a property value in encrypted form, perform the following steps:
- Use the
fabric:encrypt-messagecommand to encrypt the property value, as follows:fabric:encrypt-message PropValue
fabric:encrypt-message PropValueCopy to Clipboard Copied! Toggle word wrap Toggle overflow This command returns the encrypted property value,EncryptedValue.NoteThe default encryption algorithm used by Fabric isPBEWithMD5AndDES. - You can now set the property to the encrypted value,
EncryptedValue, using the following syntax:my.sensitive.property = ${crypt:EncryptedValue}my.sensitive.property = ${crypt:EncryptedValue}Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example, using thefabric:profile-editcommand, you can set an encrypted value as follows:fabric:profile-edit --pid com.example.my.pid/my.sensitive.property=${crypt:EncryptedValue} Profilefabric:profile-edit --pid com.example.my.pid/my.sensitive.property=${crypt:EncryptedValue} ProfileCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Warning
These encrypted values are protected by the master password, which is accessible to anyone who can log on to a Fabric container. To keep these encrypted values safe, you must restrict access to the containers in the fabric.
Alternative method for encrypting PID property values Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
The underlying encryption mechanism for PID properties is based on the Jasypt encryption toolkit. Consequently, it is also possible to encrypt PID properties directly, using the Jasypt toolkit, as follows:
- Use the Jasypt
encryptcommand-line tool to encrypt the property value, as follows:./encrypt.sh input="Property value to be encrypted" password=ZooPass verbose=false
./encrypt.sh input="Property value to be encrypted" password=ZooPass verbose=falseCopy to Clipboard Copied! Toggle word wrap Toggle overflow This command returns the encrypted property value,EncryptedValue.NoteThe default encryption algorithm used by Fabric isPBEWithMD5AndDES. You must ensure that theencrypt.shutility is using the same algorithm as Fabric.
Customizing the PID property encryption mechanism Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
You can customize the PID property encryption mechanism, as follows:
- Customize the master password for encryption—using the following console command:
fabric:crypt-password-set MasterPassword
fabric:crypt-password-set MasterPasswordCopy to Clipboard Copied! Toggle word wrap Toggle overflow You can retrieve the current master password by entering thefabric:crypt-password-getcommand. The default value is the ensemble password (as returned byfabric:ensemble-password). - Customize the encryption algorithm—using the following console command:
fabric:crypt-algorithm-set Algorithm
fabric:crypt-algorithm-set AlgorithmCopy to Clipboard Copied! Toggle word wrap Toggle overflow Where the encryption algorithm must be one of the algorithms supported by the underlying Jasypt encryption toolkit. You can retrieve the current encryption algorithm by entering thefabric:crypt-algorithm-getcommand. The default isPBEWithMD5AndDES.
Profile editor Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
If you want to make extensive edits to a profile, it is not very convenient to make changes one setting at a time. There is a more convenient approach for making extensive profile edits, and that is to use the console's built-in profile editor, which is a simple screen-based text editor.
For example, to open the agent properties resource for editing, simply invoke the
fabric:profile-edit command without any options, as follows:
fabric:profile-edit Profile [Version]
fabric:profile-edit Profile [Version]
A simple text editor opens, enabling to edit the configuration settings in the agent properties.
For full details of how to edit profiles using the built-in text editor, see Appendix A, Editing Profiles with the Built-In Text Editor.
Editing resources with the profile editor Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
A practical way to edit a general profile resource (such as an XML configuration resourct) is to use the build-in text editor. For example, to start editing the
broker.xml file in the mq-amq profile, enter the following console command:
fabric:profile-edit --resource broker.xml mq-amq
fabric:profile-edit --resource broker.xml mq-amq