Hazenet
Enthusiast
Enthusiast

Trying to Update vCAC Blueprint Entity, gets "java.lang.NullPointerException"

Jump to solution

Hi

I am trying to create a rather complex Workflow in vRealize Orchestrator.

The purpose of this workflow is to Clone an existing/earlier vRealize Automation MultiMachine deployment, and mark the new clones as templates, and then update an "Ad-hoc" Multi-Machine Blueprint in vRA with these new vCenter Templates.

Right now I have figured out how to map the individuel Ad-hoc Single-Machine blueprint prints, to clone from the new vCenter Templates.

This is done in the "VirtualMachineTemplateProperties" part of each Single-Machine blueprint.

Thanks to some borrowed code from Christiaan Roeleveld's createiaasblueprintfortemplate package

But because components of the original MultiMachine deployment might have been scaled up in regards to CPU and Memory, I need to update the Entity for the SingleMachine component blueprints.

I an trying to use the default workflow "Update a vCAC model entity" for this.

The below code is just hardcoded sample code.

I create a set of Properties:

theBlueprintEntityProperties =

{

  CPUCount : "2",

  MemoryGB : "4096",

  DiskSize0GB : "20"

};

I then try to run the "Update a vCAC model entity" workflow (inside my wrapper workflow of cause), with the following inputs:

entity = theBlueprintEntity

inputProperties = theBlueprintEntityProperties

links = null

headers = null

But I just gets "java.lang.NullPointerException" back.

That properly mean that I need to include some links and/or headers.

I have tried with some links, again using code from Christiaan Roeleveld's createiaasblueprintfortemplate package

But even if I include the following links:

var links = {

  "InterfaceType": [ interfaceType ] // The vCAC Entity for the vSphere interface,

  "HostReservationPolicy": [ reservationPolicy ] // The vCAC Entity for my Reservation Policy,

  "ProvisioningGroup": [ provisioningGroup ] // The vCAC Entity for my Procisioning Group / Business Group,

  "WorkflowInfo": [ cloneWorkflow ] // The vCAC Entity for the Clone Workflow,

  "GlobalProfiles": buildProfiles // Array of build profiles, in this case just a array of one build profile,

}

I still just gets "java.lang.NullPointerException" back.

Anyone have some inputs on how to update the vCAC Entity of a Blueprint, in regards to CPU, Memory and/or Disk?

Information about the environment:

vRealize Orchestrator = 6.0.3 Build 3000581

vCAC/vRA Pluging in vRO = 6.2.2

vRealize Automation = 6.2.2 Build 2754020

0 Kudos
1 Solution

Accepted Solutions
Hazenet
Enthusiast
Enthusiast

I found the issue.

The problem is that the Properties in the vRO Inventory, e.g. "VirtualMachineTemplateDescription" has a changed casing, compared to the vRA SQL Database.

In the vRO inventory, it is listed as virtualMachineTemplateDescription (lowercase "v")

But in the vRA SQL Database, it is listed as VirtualMachineTemplateDescription (uppercase "V")

And when the Properties don't match whats in the database, the return answer is:

java.lang.NullPointerException

Below is the corrected code, that updates the VirtualMachineTemplateDescription, CPUCount and MemoryMB of a Blueprint Entity.

var entity = theBlueprint.getEntity();

var properties =

{

  VirtualMachineTemplateDescription : "Testing Description",

  CPUCount : 8,

  MemoryMB : 18432

};

var hostId = entity.hostId;

var modelName = entity.modelName;

var setName = entity.entitySetName;

var keyString = entity.keyString;

vCACEntityManager.updateModelEntityBySerializedKey(hostId, modelName, setName, keyString, properties, null, null);

View solution in original post

0 Kudos
5 Replies
kericmiles
Enthusiast
Enthusiast

Have you tried evoking the action from a scriptable object?

System.getModule("com.vmware.library.vcac").updateVCACEntity(host.id,theBlueprintEntity.modelName,theBlueprintEntity.entitySetName,theBlueprintEntity.keyString,theBlueprintEntityProperties,theBlueprintEntity.getLinks(host))

0 Kudos
Hazenet
Enthusiast
Enthusiast

Still gets the "java.lang.NullPointerException" error.

I have now tested this in two different environments/installations.

Will try to get the Blueprint Entity in a different way than the official way, which would seem to be:

theBlueprintEntity = System.getModule("com.vmware.library.vcac").getBluePrintEntity(vcacHost,theBlueprint)

Just in case that the above line, does not return the right entity or in the right format. (Long shot)

The only other thing that might be missing is the headers of "updateVCACEntity" action. But I can figure out what it should contain.

0 Kudos
rszymczak
Hot Shot
Hot Shot

Can you tell us what line and script element the NullPoint Exception is thrown in the Update entity workflow? that would help since we can't know what params you're submitting and if they're correct.

Can you try if this works?

var properties = new Properties();

var links = new Properties();

vCACEntityManager.updateModelEntityBySerializedKey(theBlueprintEntity.hostId, theBlueprintEntity.modelName, theBlueprintEntity.entitySetName, theBlueprintEntity.keyString, properties, links, null);

P.S.: headers may be null, no worries. That's not the issue.

BTW: theBlueprintEntity.getEntity() should work just fine to get the vCAC:Entity object if you already have the vCAC:Blueprint object. After using that method you should always test if it's not null. What I usually do is something like this:

var entity = myBlueprint.getEntity();

if(entity)

{

     //do what you like with your entity object

}

else

{

     throw("Error: unable to find entity object!");

}

Cheers,

Robert

0 Kudos
Hazenet
Enthusiast
Enthusiast

I have now simplified the setup.

I have a workflow with only one Scriptable Task.

The Scriptable Task takes two inputs:

vcacHost, Type = vCAC:VCACHost (I only have one vCAC:VCACHost, so can't have selected the wrong one)

theBlueprint, Type = vCAC:Blueprint

The script of the Scriptable Task is:

var entity = System.getModule("com.vmware.library.vcac").getBluePrintEntity(vcacHost,theBlueprint);

var links = entity.getLinks(vcacHost);

var properties =

{

  virtualMachineTemplateDescription : "Testing Description"

}; 

var headers =

{

}; 

var hostId = entity.hostId; 

var modelName = entity.modelName; 

var setName = entity.entitySetName; 

var keyString = entity.keyString; 

vCACEntityManager.updateModelEntityBySerializedKey(hostId, modelName, setName, keyString, properties, links, headers); 

When I run this workflow, it fails with the following exception:

java.lang.NullPointerException (Workflow:Update a vCAC Blueprint Entity / Scriptable task (item1)#19)

0 Kudos
Hazenet
Enthusiast
Enthusiast

I found the issue.

The problem is that the Properties in the vRO Inventory, e.g. "VirtualMachineTemplateDescription" has a changed casing, compared to the vRA SQL Database.

In the vRO inventory, it is listed as virtualMachineTemplateDescription (lowercase "v")

But in the vRA SQL Database, it is listed as VirtualMachineTemplateDescription (uppercase "V")

And when the Properties don't match whats in the database, the return answer is:

java.lang.NullPointerException

Below is the corrected code, that updates the VirtualMachineTemplateDescription, CPUCount and MemoryMB of a Blueprint Entity.

var entity = theBlueprint.getEntity();

var properties =

{

  VirtualMachineTemplateDescription : "Testing Description",

  CPUCount : 8,

  MemoryMB : 18432

};

var hostId = entity.hostId;

var modelName = entity.modelName;

var setName = entity.entitySetName;

var keyString = entity.keyString;

vCACEntityManager.updateModelEntityBySerializedKey(hostId, modelName, setName, keyString, properties, null, null);

View solution in original post

0 Kudos