pjank
Contributor
Contributor

5.1 VclHost calls not backwards compatible

I am testing out our existing VCO workflows in a 5.1 environment in order to verify existing functionality and have run into a few problems.  The first problem was using the 1.5 vCD plugin and attempting to call updateSection() on a vApp to modify firewall configuration.  This gave a compatibility mode error, so I decided to upgrade the vCD plugin to 5.1 and try again.  That is when I found that the VclHost.getEntityById() method has been changed to take a finderType instead of entityType for the first parameter.  Both take a string representation but the string representation of objects are different and thus nmot compatible.

For example, the EntityType string representation of a Blocking Task object is: "vcloud:blockingTask"  but the FinderType string representation of a Blocking Task object is: "BlockingTask"

The worst part is that the VclNotificationHelper class returns objects that can tell you the EntityType, but not the FinderType.  So in 1.5, you could ask the Helper for the id and type and pass those directly to the getEntityById(), like this:

var helper = new VclNotificationHelper();
helper.setMessage(messageBody);

var entityLink = helper.getEntityLink();

var returnObject = host.getEntityById(entityLink.type, entityLink.id);

In 5.1, it looks like I will have to change every instance of getEntityById to be hard-coded to a specific VclFinderType value.  This porting will be tedious, but not difficult.  Does anyone know if there is an association between EntityTypes and FinderTypes that can be leveraged?

0 Kudos
2 Replies
cdecanini_
VMware Employee
VMware Employee

I have written a compatibility guide here : http://communities.vmware.com/docs/DOC-20431

Good question on the entityType to FinderType possible relation I do not have the answer. For this reason I have implemented it the long way:

switch(entityLink.type) {
    case "vcloud:blockingTask" :
        entityBlockingTask = vcdHost.getEntityById(VclFinderType.BLOCKING_TASK, entityLink.id);
        break;

    case "vcloud:catalog" :
        entityCatalog = vcdHost.getEntityById(VclFinderType.CATALOG, entityLink.id);;       
        break;
           
    case "vcloud:catalogitem" :
        entityCatalogItem = vcdHost.getEntityById(VclFinderType.CATALOG_ITEM, entityLink.id);       
        break;
           
    case "vcloud:datastore" :
        entityDatastore = vcdHost.getEntityById(VclFinderType.VMW_DATASTORE, entityLink.id);   
        break;           
           
    case "vcloud:disk" :
        entityDisk = vcdHost.getEntityById(VclFinderType.DISK, entityLink.id);       
        break;
                   
    case "vcloud:gateway" :
        entityGateway = vcdHost.getEntityById(VclFinderType.GATEWAY, entityLink.id);   
        break;   
                               
    case "vcloud:group" :
        entityGroup = vcdHost.getEntityById(VclFinderType.GROUP, entityLink.id);       
        break;
                                                   
    case "vcloud:host" :
        entityHost = vcdHost.getEntityById(VclFinderType.VMW_HOST, entityLink.id);       
        break;

    case "vcloud:media" :
        entityMedia = vcdHost.getEntityById(VclFinderType.MEDIA, entityLink.id);   
        break;
                                       
    case "vcloud:network" :
        entityOrgVdcNetwork = vcdHost.getEntityById(VclFinderType.ORG_VDC_NETWORK, entityLink.id);
        entityVAppNetwork = vcdHost.getEntityById(VclFinderType.VAPP_NETWORK, entityLink.id);
        entityExternalNetwork = vcdHost.getEntityById(VclFinderType.VMW_EXTERNAL_NETWORK, entityLink.id);
        break;
                                       
    case "vcloud:networkPool" :
        entityNetworkPool = vcdHost.getEntityById(VclFinderType.VMW_NETWORK_POOL, entityLink.id);   
        break;
                                                                                                                                                   
    case "vcloud:org" :
        entityOrganization = vcdHost.getEntityById(VclFinderType.ORGANIZATION, entityLink.id);       
        break;
           
    case "vcloud:providervdc" :
        entityProviderVdc = vcdHost.getEntityById(VclFinderType.VMW_PROVIDER_VDC, entityLink.id);
   
        break;

    //case "vcloud:lr.providervdcstorageclass" : //Bug 890059
    case "vcloud:providerVdcStorageProfile":
        entityProviderVdcStorageProfile = vcdHost.getEntityById(VclFinderType.VDC_STORAGE_PROFILE, entityLink.id);       
        break;
                                   
    case "vcloud:right" :
        entityRight = vcdHost.getEntityById(VclFinderType.RIGHT, entityLink.id);   
        break;
                   
    case "vcloud:role" :
        entityRole = vcdHost.getEntityById(VclFinderType.ROLE, entityLink.id);   
        break;
                                                                                                   
    case "vcloud:strandeditem" :
        entityStrandedItem = vcdHost.getEntityById(VclFinderType.STRANDED_ITEM, entityLink.id);       
        break;
                                                                                           
    case "vcloud:task" :
        entityTask = vcdHost.getEntityById(VclFinderType.TASK, entityLink.id);       
        break;

    case "vcloud:user" :
        entityUser = vcdHost.getEntityById(VclFinderType.USER, entityLink.id);       
        break;                                       
                                                                                                                       
    case "vcloud:vapp" :
        entityVApp = vcdHost.getEntityById(VclFinderType.VAPP, entityLink.id);       
        break;
                                       
    case "vcloud:vapptemplate" :
        entityVAppTemplate = vcdHost.getEntityById(VclFinderType.VAPP_TEMPLATE, entityLink.id);       
        break;
                                       
    case "vcloud:vdc" :
        entityVdc = vcdHost.getEntityById(VclFinderType.VDC, entityLink.id);   
        break;
                                                                           
    //case "vcloud:lr.vdcstorageclass" : //Bug 890059
        case "vcloud:vdcStorageProfile" :       
        break;
                                               
    case "vcloud:vimserver" :
        entityVimServer = vcdHost.getEntityById(VclFinderType.VIM_SERVER, entityLink.id);       
        break;
                                       
    case "vcloud:vm" :
        entityVm = vcdHost.getEntityById(VclFinderType.VM, entityLink.id);   
        break;
    default: System.warn("Unidentified entityLink.type : " + entityLink.type);
}           

This is how I implemented the "workflow runner" workflow in the notification package here : http://communities.vmware.com/docs/DOC-20446

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
pjank
Contributor
Contributor

Thanks so much for the compatibility guide and for putting together that switch block.  I have implemented it with a few small adjustments as an action I can call anytime I need to use getEntityById() and it is working great so far.

As for the compatibility guide, one area that was giving me trouble was the Firewall Rules.  Specifically, the library action:

com.vmware.library.vCloud.vApp.Network.Config.Firewall.createFirewallRule

is still configured to use the 1.5 mode of firewall rules, which include "direction" as a parameter.  If you try to use this action with the 5.1 plugin to add a firewall rule to a 5.1 created vApp Network, it fails noting that "direction" is only supported in backwards compatibility mode.

I made a copy of this action and removed the "direction" parameter and that fixed it.  The 1.5 plugin also failed when using this action when talking to a 5.1-created vApp network.  I'm not sure if it would have worked if the vApp network itself was created in 1.5 before the upgrade.

0 Kudos