此内容没有您所选择的语言版本。
12.4. Resources and Groups
Web applications (EARs and WARs) are content-backed resources, a cross between a managed resource and a content package.
When running a CLI script, there are some methods available specifically to retrieve or create the content for the resource.
To create a content-backed resource, upload the file with a specified version number.
This script's steps are:
- Search for the resource to upload the content to. This example looks for a JBoss AS 5 server.
- Make sure the server is running. The JBoss server has to be running for content to be deployed successfully.
Example 12.5. Creating a Content-Backed Resource
Updating a package is slightly simpler. It requires sending a new file and version number to the existing EAR resource.
Example 12.6. Updating a Content-Backed Resource
While a content-backed resource is added or updated as if it were a software package (which it is), it is deleted as if it were a resource.
NOTE
Deleting is not the same as uninventorying a resource. Uninventorying removes the resource from the inventory but leaves it intact on the platform. Deleting a resource deletes it from the platform itself.
Example 12.7. Deleting a Content-Backed Resource
12.4.2. Creating a Resource Group and Adding Members 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
When a group is created by a script, it is initially created as a mixed group. All empty groups are treated as mixed groups. Once members are added, if all the members are the same resource type, then the group is automatically tagged as a compatible group.
Compatible groups are great for scripted management tasks, because the same operation or configuration change can be performed on each member iteratively.
The script steps are:
- Search for the resource type.
- Create the group, based on the resource type.
- Find resources of that resource type.
- Iterate through the returned resources and add them to the group.
Example 12.8. Annotated Example
12.4.3. Creating and Editing Dynagroups 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
A dynamic groups specifies a search term to use to search the inventory and identify matching resources to belong to the group. Since the search results change automatically as results are added and removed from the inventory, the group membership is always changing and always current.
Dynamic groups (or dynagroups) have their own classes to create and update groups.
A dynagroup is created by defining a set of expressions which are search filters to use to search the inventory for matching members. The group membership is calculated (using those expressions) by an administrative task.
NOTE
Dynagroups expressions are covered extensively in the Users Guide.
Both for creating an editing a dynagroup, then, it is necessary to recalculate the group membership to capture changes to matching members. It can also be reasonable to recaculate group membership whenever there are changes to the inventory, to update the dynagroups with new members.
Example 12.9. Creating a Dynagroup
This uses simple expressions to identify group members.
It is possible to use more complex expressions such as groupby within the setExpression value.
Example 12.10. Editing a Dynagroup
This adds another expression to the dynagroup, updates the definition, and then recalculates the group membership.
Dynagroup memberships are only updated after a calculation operation. So, if there are changes to the inventory, even if there are not changes to the dynagroup expression itself, the dynagroup must be updated to update the members.
Example 12.11. Recalculating a Group Definition
This updates a single dynagroup, based on the group name.
It is possible to recalculate all dynagroups or a set of dynagroups, by incrementing through the search results and running the
calculatedGroupMembership()
method. This is covered in Section 12.3, “Getting Data for Single and Multiple Resources”.