VMware Cloud Community
Flipper35
Contributor
Contributor
Jump to solution

Cannot find function reconfigVM_Task in object

So, I get the error message above and in full here:

 

TypeError: Cannot find function reconfigVM_Task in object DynamicWrapper (Instance) : [VcVirtualMachine]-[class com.vmware.o11n.plugin.vsphere_gen.VirtualMachine_Wrapper] -- VALUE : Stub: moRef = (ManagedObjectReference: type = VirtualMachine, value = vm-xxxxxx, serverGuid = null), binding = https://vcenterserverhere:443/sdk. (Workflow:Send Backup Requirement Notification / Send Email to lists (item0)#34)

 

The code here and the last line is what throws the error:

 

var customProperties = new Properties();
var message = new EmailMessage();
var serverName = inputProperties.resourceNames[0];
var description = inputProperties.customProperties.notes;
var notes = inputProperties.customProperties.notes;
var backup = inputProperties.customProperties.backup;
var owner = inputProperties.customProperties.ownername;
sdkConnections = VcPlugin.allSdkConnections
message.toAddress = toAddress;

requestInputs = inputProperties.get("requestInputs");

query = "xpath:name='" + serverName + "'"
      //vm=VcPlugin.findAllForType("VC:VirtualMachine", query); 
      vm=VcPlugin.getAllVirtualMachines(null, query);
      vmObject=vm[0];

System.log("Notes: "+notes);
System.log("VC:VirtualMachine: " + vm);
System.log("VC:VirtualMachine: " + vmObject);


//var oldNotes = vm.summary.config.annotation;  --  This does not work either, I assume related to the error, 
//if (oldNotes == null){oldNotes = "";}  --  but i only need to add notes to a new machine so no need to append old notes
//System.log("Current VM Notes: "+oldNotes);
// Now set the new Notes:
// Start by creating a ConfigSpec
var configSpec = new VcVirtualMachineConfigSpec();
// Update the annotation property with new value
configSpec.annotation = notes;
// launch task to reconfig the vm with the new configspec
// NOTE: This is safe to apply with powered on VM
var task = vm.reconfigVM_Task(configSpec);  --  I have tried this with and without the "var task = "
0 Kudos
1 Solution

Accepted Solutions
eoinbyrne
Expert
Expert
Jump to solution

Hi

The problem is here in this code

 

query = "xpath:name='" + serverName + "'"; 
//vm=VcPlugin.findAllForType("VC:VirtualMachine", query); 

// this returns an VcVirtualMachine[]  (i.e., an array of VMs!)
vm = VcPlugin.getAllVirtualMachines(null, query);

// this is the *real* VcVirtualMachine
vmObject=vm[0];

// NOTE: This is safe to apply with powered on VM
//var task = vm.reconfigVM_Task(configSpec);  --  I have tried this with and without the "var task = "
// change this call to this & you should be sorted
var task = vmObject.reconfigVM_Task(configSpec);

The change on the last line there should fix the problem

 

-HTH

 

View solution in original post

4 Replies
mayank_goyal
Enthusiast
Enthusiast
Jump to solution

I can validate that function reconfigVM_Task() exist for type VC:VirtualMachine if this was your original question as I was able to reconfigure my VM using the below code where I increased the single HDD size to 95GBs.

 

 

var spec = new VcVirtualMachineConfigSpec();
var deviceChange = new Array();
deviceChange[0] = new VcVirtualDeviceConfigSpec();
deviceChange[0].device = new VcVirtualDisk();
deviceChange[0].device.shares = new VcSharesInfo();
deviceChange[0].device.shares.shares = 1000;
deviceChange[0].device.shares.level = VcSharesLevel.normal;
deviceChange[0].device.capacityInBytes = 102005473280;
deviceChange[0].device.storageIOAllocation = new VcStorageIOAllocationInfo();
deviceChange[0].device.storageIOAllocation.shares = new VcSharesInfo();
deviceChange[0].device.storageIOAllocation.shares.shares = 1000;
deviceChange[0].device.storageIOAllocation.shares.level = VcSharesLevel.normal;
deviceChange[0].device.storageIOAllocation.limit = -1;
deviceChange[0].device.storageIOAllocation.reservation = 0;
deviceChange[0].device.backing = new VcVirtualDiskFlatVer2BackingInfo();
deviceChange[0].device.backing.backingObjectId = '';
deviceChange[0].device.backing.fileName = '[SVM_DATA_T2_03_TEST_DEV] testvm1-jINq/testvm1-jINq.vmdk';
deviceChange[0].device.backing.split = false;
deviceChange[0].device.backing.writeThrough = false;
deviceChange[0].device.backing.datastore = Server.findForType("VC:Datastore", myVcVirtualMachine.vimHost.id + "/datastore-24994");
deviceChange[0].device.backing.eagerlyScrub = false;
deviceChange[0].device.backing.contentId = '4757381237af512bda5d92adfffffffe';
deviceChange[0].device.backing.thinProvisioned = true;
deviceChange[0].device.backing.diskMode = 'persistent';
deviceChange[0].device.backing.digestEnabled = false;
deviceChange[0].device.backing.sharing = 'sharingNone';
deviceChange[0].device.backing.uuid = '6000C296-fa2c-fdbe-c383-ce5727d9d089';
deviceChange[0].device.controllerKey = 1000;
deviceChange[0].device.unitNumber = 0;
deviceChange[0].device.nativeUnmanagedLinkedClone = false;
deviceChange[0].device.capacityInKB = 99614720;
deviceChange[0].device.deviceInfo = new VcDescription();
deviceChange[0].device.deviceInfo.summary = '94,371,840 KB';
deviceChange[0].device.deviceInfo.label = 'Hard disk 1';
deviceChange[0].device.diskObjectId = '21-2000';
deviceChange[0].device.key = 2000;
deviceChange[0].operation = VcVirtualDeviceConfigSpecOperation.edit;
spec.deviceChange = deviceChange;
var cpuFeatureMask = new Array();
spec.cpuFeatureMask = cpuFeatureMask;
myVcVirtualMachine.reconfigVM_Task(spec);

 

 

  



-
For more interesting content on Aria Automation, check my blog:
https://cloudblogger.co.in
0 Kudos
Flipper35
Contributor
Contributor
Jump to solution

I know the function exists, I am not sure why it throws the error when I try to use it in that specific code.  It works in the native workflows, just not here.

0 Kudos
eoinbyrne
Expert
Expert
Jump to solution

Hi

The problem is here in this code

 

query = "xpath:name='" + serverName + "'"; 
//vm=VcPlugin.findAllForType("VC:VirtualMachine", query); 

// this returns an VcVirtualMachine[]  (i.e., an array of VMs!)
vm = VcPlugin.getAllVirtualMachines(null, query);

// this is the *real* VcVirtualMachine
vmObject=vm[0];

// NOTE: This is safe to apply with powered on VM
//var task = vm.reconfigVM_Task(configSpec);  --  I have tried this with and without the "var task = "
// change this call to this & you should be sorted
var task = vmObject.reconfigVM_Task(configSpec);

The change on the last line there should fix the problem

 

-HTH

 

Flipper35
Contributor
Contributor
Jump to solution

Thank you for that!

0 Kudos