Managing assets using wsadmin scripting

Use the commands in the BLAManagement command group to manage your asset configuration. Use the examples in this topic to list assets, view asset configuration data, remove assets from the asset repository, update one or more files for assets, and export assets.

Before you begin

There are two ways to complete this task. Complete the tasks in this topic to manage assets with the BLAManagement command group for the AdminTask object. Alternatively, you can use the scripts in the AdminBLA script library to administer your asset configurations.

Procedure

  • List assets.
    1. Start the wsadmin scripting tool.
    2. List the assets registered to the asset repository.
      Use the listAssets command to display the configuration ID, description, and deployment target for each asset within the cell, as the following command demonstrates:
      AdminTask.listAssets()
  • View asset settings.
    1. Start the wsadmin scripting tool.
    2. Display the asset settings.
      Use the viewAsset command to display the configuration information for the asset of interest, which in the following example is myAsset.zip:
      AdminTask.viewAsset('-assetID myAsset.zip')
      The command returns the configured asset options, as the following sample output displays:
      Specify Asset options (AssetOptions)  Specify options for Asset.  *Asset Name (name): 
       [defaultapp.ear] Default Binding Properties (defaultBindingProps): 
       [defaultbinding.ejbjndi.prefix#defaultbinding.datasource.jndi# 
        defaultbinding.datasource.username# defaultbinding.datasource.password# defaultbinding.cf.jndi# 
        defaultbinding.cf.resauth#defaultbinding.virtual.host# defaultbinding.force]
        Asset Description (description): [] Asset Binaries 
        Destination Url (destination): [${USER_INSTALL_ROOT}/installedAssets/defaultapp.ear/BASE/defaultapp.ear]
        Asset Type Aspects(typeAspect): [WebSphere:spec=j2ee_ear] Asset Relationships (relationship):
        []File Permission (filePermission): 
        [.*\\.dll=755#.*\\.so=755#.*\\.a=755#.*\\.sl=755] Validate asset (validate): [false]
  • Remove one or more assets from the product management domain.
    1. Start the wsadmin scripting tool.
    2. Determine if the asset can be deleted.

      You cannot delete an asset from the asset registry if it is associated with composition unit in a business-level application.

      Use the listCompUnits command to display the configuration ID, type, and description for each composition unit in a business-level application, as the following example demonstrates for the myBLA application:
      AdminTask.listCompUnits('-blaID myBLA -includeDescription true')
      The command returns the following sample output:
      Websphere:cuname=cu1 asset "Composition unit for asset.zip"  Websphere:cuname=cu4 bla  "cu4 
       description" WebSphere:cuname=defaultapp __j2ee "defaultapp description"
      The type for the cu1 composition unit is asset, which denotes that the composition unit is associated with an asset.

      Use the deleteCompUnit command to remove the composition unit before deleting the asset from the asset repository, as the following example demonstrates:

      AdminTask.deleteCompUnit('-blaID myBLA -cuID cu1')
    3. Delete the asset.
      Use the deleteAsset command to remove the asset of interest, which in the following example is asset2.zip, from the asset repository:
      AdminTask.deleteAsset('-assetID asset2.zip')
      The command returns the configuration ID of the deleted asset:
      WebSphere:assetname=asset2.zip
  • Update the contents of an asset.
    1. Start the wsadmin scripting tool.
    2. Determine how to update the asset.
      You can invoke several different operations on assets that are registered in the asset repository, as the following table displays:
      Table 1. updateAsset supported operations . Run an updateAsset command with an operation.
      Operation Description
      replace The replace operation replaces the contents of the asset of interest.
      merge The merge operation updates multiple files for the asset, but does not update all files.
      add The add operation adds a new file or module file.
      addupdate The addupdate operation adds or updates one file or module file. If the file does not exist, the system adds the contents. If the file exists, the system updates the file.
      update The update operation updates one file or module file.
      delete The delete operation deletes a file or module file.
    3. Update the asset of interest.

      The updateAsset command modifies one or more files or module files of an asset, which in the following merge example includes asset2.zip:

      [Windows]
      AdminTask.updateAsset('-assetID asset2.zip -operation merge -contents c:/temp/updatedFiles_asset1.zip')
      [Linux][AIX][z/OS][HP-UX][IBM i][Solaris]
      AdminTask.updateAsset('-assetID asset2.zip -operation merge -contents /temp/updatedFiles_asset1.zip')

      The command updates the asset binary file, but does not update the composition unit that the system deploys with the asset as a backing object.

    4. Save your configuration changes.
      Use the following command example to save your configuration changes:
      AdminConfig.save()
  • Export an asset to a target location.
    1. Start the wsadmin scripting tool.
    2. Export the asset of interest.

      Use the exportAsset command to save an asset configuration to a file. The command accepts an incomplete asset configuration ID if the system matches it to a unique ID in your configuration. The following example exports an asset:

      [Windows]
      AdminTask.exportAsset('-assetID asset2.zip -filename c:/temp/a2.zip')
      [Linux][AIX][z/OS][HP-UX][IBM i][Solaris]
      AdminTask.exportAsset('-assetID asset2.zip -filename /temp/a2.zip')