Most of this example is based on code in the TaggingWorkflow.java sample file, which is located in the following vCloud Suite SDK for Java directory: client/samples/java/com/vmware/vcloud/suite/samples/interop/
import com.vmware.vcloud.suite.samples.vim.helpers.VimUtil; import com.vmware.vapi.std.DynamicID; import com.vmware.cis.TagAssociation; // 1 - Determine the MOID of the ClusterComputeResource from its name. ManagedObjectReference clusterMoRef = VimUtil.getCluster(vimPort, serviceContent, myClusterName); // 2 - Create a dynamic type ID for the cluster. DynamicID clusterDynamicId = DynamicID(clusterMoRef.getType(), clusterMoRef.getValue()); // 3 - Attach the tag to the ClusterComputeResource managed object. TagAssociation tagAssociationStub = myStubFactory.createStub(TagAssociation.class, myStubConfig); tagAssociationStub.attach(tagId, clusterDynamicId);