Who is fastest VcPlugin:getAllVirtualMachines() or VcSDKConnection:getAllVirtualMachines()

Can someone tell which is faster on VcPlugin:getAllVirtualMachines() or VcSDKConnection:getAllVirtualMachines()?

VcPlugin get all servers configured in parallel - vCenter virtual machines slower remote call will be both for its execution. VcSDKConnection only of a unique vCenter.

Tags: VMware

Similar Questions

  • VcPlugin.getAllVirtualMachines crapping and/or wide range handling blowing up to post 5.5 upgrade

    I just updated our environment 5.1 to 5.5.  We have 9 vCenters and 19000 virtual machines, updated in the vCO.  I fell of the segment size of java to the initial value 4096 and 6144 max values.  I am using the VcPlugin.getAllVirtualMachines () method.  This allows to work with the plugin 5.1.  Now he just going off into the weeds.  I tried to work around him, instead using getAllVirtualMachines() on each sdkConnection and concating it all in a single table that I can go to try to locate a virtual machine by name.  Now when I start to cross the table it out craps after hundreds of items.  I see these errors in the wrapper.log file:

    Filter of destruction [VimSession] 'session[5222d81f-7b94-08c5-3eb1-7a8b6763f4b4]525fc1be-62ec-dc63-e7ce-575610553e7b' of domain\user @ 1e2a5111 # https://someserver.domain.com:443/sdk/hand damaged useis or: true

    [FiltersManager] destroyPropertyFilter() [user\domain @1e2a5111 # https://server.domain.com:443/sdk/hand damaged useis or: true, Nb used filters 1]-> filter "< session[5222d81f-7b94-08c5-3eb1-7a8b6763f4b4]525fc1be-62ec-dc63-e7ce-575610553e7b > PropertyFilter" destroyed

    [VimSession [domain\user @1e2a5111 # https://server.domain.com:443/sdk/hand damaged useis or: true]-UpdateThreadIs] INFO {[email protected]: QCcpuCoreThreadCountCsv:11d8be17-f693-457e-92e8-16ff832afd4c:8ab5cc694451e707014451ee6a230005} createFilter() [VimSession]-> create filter for '3557' VimManagedObjects

    2014-02-20 16:56:55.082 - 0800 [VimSession [domain\user @1e2a5111 # https://server.domain.com:443/sdk/hand damaged useis or: true]-UpdateThreadIs] INFO {[email protected]: QCcpuCoreThreadCountCsv:11d8be17-f693-457e-92e8-16ff832afd4c:8ab5cc694451e707014451ee6a230005} [VimSession] created the 'session[5222d81f-7b94-08c5-3eb1-7a8b6763f4b4]522e386e-7793-9533-1002-dbc23f12d07e' filter the domain\user @ 1e2a5111 # https://Server.domain.com:443/sdk/hand damaged useis or: true

    2014-02-20 16:56:55.082 - 0800 [VimSession [domain\user @1e2a5111 # https://server.domain.com:443/sdk/hand damaged useis or: true]-UpdateThreadIs] INFO {[email protected]: QCcpuCoreThreadCountCsv:11d8be17-f693-457e-92e8-16ff832afd4c:8ab5cc694451e707014451ee6a230005} [PluginCacheManager] disassembly cache element ' vm-1148' (1658147079) of the 'true useIS_ of domain_user.service_https___server.domain.com_443_sdk_Main_1e2a5111' / 1814380472 '.

    2014-02-20 16:56:55.082 - 0800 [VimSession [domain\user @1e2a5111 # https://server.domain.com:443/sdk/hand damaged useis or: true]-UpdateThreadIs] INFO {[email protected]: QCcpuCoreThreadCountCsv:11d8be17-f693-457e-92e8-16ff832afd4c:8ab5cc694451e707014451ee6a230005} [PluginCacheManager] cache item removal "vm-1148' (1658147079) of the"true domain_user.service_https___server.domain.com_443_sdk_Main_1e2a5111 useIS_" ".

    2014-02-20 16:56:55.082 - 0800 [VimSession [domain\user @1e2a5111 # https://server.domain.com:443/sdk/hand damaged useis or: true]-UpdateThreadIs] INFO {[email protected]: QCcpuCoreThreadCountCsv:11d8be17-f693-457e-92e8-16ff832afd4c:8ab5cc694451e707014451ee6a230005} [PluginCacheManager] Ghost cache element ' vm-1148' (1658147079) in 'domain_user.service_https___server.domain.com_443_sdk_Main_1e2a5111 useIS_ true' / 1814380472 '.

    2014-02-20 16:56:55.300 - 0800 [VimSession [domain\user @1e2a5111 # https://server.domain.com:443/sdk/hand damaged useis or: true]-UpdateThreadPc] WARN {[email protected]: QCcpuCoreThreadCountCsv:11d8be17-f693-457e-92e8-16ff832afd4c:8ab5cc694451e707014451ee6a230005}-> cannot find [UpdateThreadPc] processUpdateSet() ' vm-1148' in the cache .

    Someone saw something similar to this.  Is there something that I need to tweak in the cache?  Something in the configuration of java?  Have I exceeded certain maximum and the need to split this out in several vCO (which sucks)? It worked fine in 5.1.

    Paul

    So it seems that my problem was related to the configuration of the jvm.  I don't know if these changes would be appropriate on the device that I have that the deployed version of windows.  In the wrapper.conf file, I got this set value in wrapper.java.maxmemory = 6144 since I was as sure enough I hit the previous maximum of 4096.  I start having problems with the vCO if I did that together, do not use more than 4096 and it's all the time.  We have added another line in the file wrapper.conf as follows:

    Wrapper.java.Additional.23 = "-Xmx6144m".

    where the '. '. 23"was the next available number in the range of switches being passed to the initialization of the Java virtual machine.  I don't know if it's one thing to java or something that will be fixed in an update to better manage the option. MaxMemory in the file but it does not make things better for me.  Now, I see the ball of memory up to approximately 5.5 GB and workflows end as they did before.

  • Who is fastest on the index select or insert?

    Who is fastest on the index select or insert?

    SELECT and insert are totally different operation. And I don't understand what you're trying to ask.

    What do you mean by fast on index?

    Insert becomes generally slow if you have indexes. This is because the db has to do more work, write the data and index.

    Select can be much faster if good indicator are in place. which can lead to an analysis of index and avoide a full table scan.

    Is that what you are looking for?

  • Question about permissions on vCo 4.2.1

    Hello

    I'm having a problem where the user can see more information and vCo should be possible on his account.

    I have a user named "Test" with a vm folder named 'Test' read-only permissions and execute permissions on the workflow 'Research vm'.

    When I run this workflow I would expect to find only vm in this folder.

    The workflow includes following the code to search for the virtual machine:

    XPath = "xpath:name [begin with(.,'"+ pattern +"')]; var

    machines virtual var = new Array();

    VM = VcPlugin.getAllVirtualMachines (null, xpath);

    This workflow returns however each vm you are looking for on the vCenter server when run with the test account, as he is an admin account.

    For example it returns the virtual computer object with vm-1177 as id and can see all the information and even to launch new tasks.

    When I navigate to https://vCenter/mob/?moid=vm-1177 with the test account all fields are disabled.

    My guess is that the only controls vCo if the user has the Execute permission but running the workflow with the admin account.

    Or I do something wrong? And it is even possible to check if an account is authorized to obtain certain information?

    I found this article in the Ko, but he has not answered my question: VMware KB: introduction to security Orchestrator

    Thanks in advance

    Thibaut Noben

    The results received by this workflow will depend on how you have configured vCenter plug-in... If a session shared, then the results of the workflow (regardless of who is connected to vCO) will be based on the credentials used for the session shared to vCenter... If each user is configured, then results are supposed to based on the credentials of the logged-on user because those are those sent to vCenter.

  • List of instant vm via a txt or csv file

    Hello

    I want to create a workflow to create a snapshot of the vm list, this list of virtual machine must be a txt or csv file.

    the file will be asking when I run the workfow (browse file) or a UNC path is already configured in the workflow.

    someone has an idea?

    An example of code here is in a workflow, I wrote for vCloud Director 1 imported users from a csv file that has been uploaded to the server of the vCO. The variable "csvfile" is my MimeAttachment entry, the server has been configured to allow read/write in the folder c:\orchestrator...

    var csvContent = csvFile.content;
    var csvFileName = "c:\\Orchestrator\\csvFile.csv";
    csvFile.write("c:\\Orchestrator\\","csvFile.csv");
    System.log("csvFileName: "+csvFileName);
    var host = organization.parent;
    // Now use file to create FileReader object:
    var fileReader = new FileReader(csvFileName);
    if (fileReader.exists){
        fileReader.open();
        var line=fileReader.readLine();
        System.log("Headers: \n"+line);
        line = fileReader.readLine();
        while (line != null){
            var lineValues = line.split(",");
            var username = lineValues[0];
    var username = lineValues[0];
            var password = lineValues[1];
            var enabled = lineValues[2];
            var role = lineValues[3];
            var fullname = lineValues[4];
            var email = lineValues[5];
            var phone = lineValues[6];
            var im = lineValues[7];
            var storedvmquota = lineValues[8];
            var runningvmquota = lineValues[9];
            var vcdRole = System.getModule("com.vmware.pso.vcd.roles").getRoleByName(host,role);
            System.log("Role name found: "+vcdRole.name);
            System.log("Attempting to create User Params");
            var userParams = System.getModule("com.vmware.library.vCloud.Admin.User").createUserParams(
                        username, fullname, enabled, false,
                        email, phone, null, password, vcdRole,
                        false, runningvmquota,
                        false, storedvmquota
                     );
            var userOut = System.getModule("com.vmware.library.vCloud.Admin.User").createUser(organization, userParams);
            userOut.im = im;
            userOut.update();
            System.log(userOut.name + " imported...");
            line = fileReader.readLine();
        }
        fileReader.close();
        // now cleanup by deleting the uploaded file from the server
        var file = new File(csvFileName);
        System.log("Filename: "+file.name);
        deleteFile(csvFileName);
    }else{
        System.log("Error! File not found! "+csvFileName);
    }
    
    function deleteFile(fileName) {
        var file = new File(fileName);
           if (file.exists) {
                   file.deleteFile();
              }
    }
    

    And who gets a VC:VirtualMachine object in vm name where "vmName" is the string entry containing the name to search and "vCenterVM" is the purpose of VC:VirtualMachine resulting code example:

    var vms = VcPlugin.getAllVirtualMachines(null, "xpath:name='"+vmName+"'");
    var vCenterVM = null;
    if (vms != null){
        if (vms.length == 1){
            System.log("Match found for vm named: "+vmName);
            vCenterVM = vms[0];
        }else{
            System.log("More than one VM found with that name! "+vmName);
            for each (vm in vms){
                System.log("VM ID: "+vm.id);
            }
        }
    }
    
  • Get all the virtual disk to a virtual machine in the workflow

    Hello

    because on the VRO/VRA 7.0.1 reconfigure VM doesn't have the broker of life cycle events, I need to retrieve information about the virtual machine to synchronize the new State in the database.

    I can't find the method to get the name of the disk and their id SCSI virtual

    I need something like this:

    Server-1

    "Hard Disk 1' ' SCSI (0:0).

    «Disk 2 "hard" SCSI (0:1) "»

    «Disc 3 "hard" SCSI (0:2) "»

    Server-2

    "Hard Disk 1' ' SCSI (0:0).

    «Disk 2 "hard" SCSI (0:1) "»

    [...]


    Now, I use this simple test script VRO Javascript Workflow:


    machines virtual var = VcPlugin.getAllVirtualMachines ();

    for {(i SMV)

    var vm = vms [i];

    vmInfo (vm);

    var features = vm.config.hardware.device;

    If (features! = null) {}

    for (device in devices) {}

    var label_name =. deviceInfo.label devices [device]

    System.log ("name:" + label_name);

    var summary_name = [peripheral] deviceInfo.summaryl of devices.

    System.log ("summary name:" + summary_name);

    If ([peripheral] devices instanceof VcVirtualBusLogicController | instanceof devices [device] VcVirtualLsiLogicController)

    || device [device] instanceof VcParaVirtualSCSIController | instanceof VcVirtualLsiLogicSASController devices [device]) {}

    scsiControllerKey = devices [peripheral] .key;

    bus devices = [device];

    busNumber devices [device] = .busNumber;

    System.log ("SCSI controller found. (Key: "+ scsiControllerKey +" ' ") ») ;

    System.log ("Bus number:" + busNumber);

    break;

    }

    }

    }

    but print an output like this:

    [...]

    2016-06-06 16:25:48.707] [I] the name tag: Video card

    [2016-06-06 16:25:48.709] [I] name summary: undefined

    [2016-06-06 16:25:48.711] [I] label name: VMCI device

    [2016-06-06 16:25:48.714] [I] name summary: undefined

    [2016-06-06 16:25:48.716] [I] label name controller: SCSI 0

    [2016-06-06 16:25:48.718] [I] name summary: undefined

    [2016-06-06 16:25:48.720] [I] SCSI controller found. (Key: 1000)

    [2016-06-06 16:25:48.722] [I] Bus number: 0

    [...]

    can someone help me?

    Thank you very much

    Sergio

    Hi Sergio,

    Here is an example of code (the input parameter is type virtual machine vm ):

    var devices = vm.config.hardware.device;
    for each (controller in devices) {
      var is_scsi = controller instanceof VcVirtualBusLogicController || controller instanceof VcVirtualLsiLogicController
           || controller instanceof VcParaVirtualSCSIController || controller instanceof VcVirtualLsiLogicSASController;
      if (!is_scsi) {
        continue;
      }
      var controller_label = controller.deviceInfo.label;
      System.log("SCSI controller found: " + controller_label);
      for each (device in devices) {
        if (device.controllerKey == controller.key) {
          var scsi_id = controller.busNumber + ":" + device.unitNumber;
          System.log("    device found:  '" + device.deviceInfo.label + "'  'SCSI (" + scsi_id + ")'");
        }
      }
    }
    

    SCSI ID is a combination of the number of buses of the controller and unit of the device number.

  • How search whiel seeking records VM or VMs in a vCenters off vCenters several?

    Hi guys,.

    I have multiple vCenters vRO inventory and it is expected that vCenters plus one may not be accessible at times (Disaster Recovery scenario) and when to use the vCenter API that collects everything based on the type of object the script fails as virtual machines or VM or not accessible files on the down/not available vcenter.

    VM = VcPlugin.getAllVirtualMachines ();

    So, how can I restrict this search for a virtual computers specific vcenter or the VM files?

    VcPlugin.allSdkConnections returns an array of objects that represent connections to each vCenter.

    So instead of

    vms = VcPlugin.getAllVirtualMachines();
    

    You can use something like

    for each (var conn in VcPlugin.allSdkConnections) {
        var useThisVC = ...; // somehow determine if this vCenter is accessible/you want to use it
        if (useThisVC) {
            var vmsOnThisVC = conn.getAllVirtualMachines(); // get only VMs on this particular vCenter
        }
    
    }
    

    In addition, you can wrap the code that works with a particular vCenter in a try... catch... Finally block to ensure that errors occurred during an invoke operation will not affect other operations with other vCenters.

  • The list of predefined items regex

    Hello

    right now I'm working on a stream of work that provides a virtual machine, either from scratch or model.

    I want to make a selection of all the models (virtual machines) that contains "_Template".

    I created an input parameter as a list of predefined using the action items ' GetAllVM'sMatchingRegexp '.

    So here's what it looks like at the moment:

    GetAction("com.vmware.library.vc.vm","getAllVMsMatchingRegexp").call ("(.)") (*_modèle/ig) ')

    But no results are displayed. Perhaps some can help me with that?

    Thank you and best regards,

    Weda

    Hello

    I suggest to replicate the existing action of getAllVMsMatchingRegexp to, say, getAllVMsMatchingRegexp2and make a small change to its script code to resemble the following

    // Get all Virtual Machines for all vCenter connections defined for this plugin
    var allVms = VcPlugin.getAllVirtualMachines();
    var vms = new Array();
    // Check if the VM match the regexp
    for (var i in allVms) {
      if (allVms[i].name.match(new RegExp(regexp, "gi"))) {  // here is the only difference from the old action
        vms.push(allVms[i]);
      }
    }
    return vms;
    

    Then, change the list of predefined items to use

    GetAction("com.vmware.library.vc.vm","getAllVMsMatchingRegexp2").call( "Template$" )   // will match the names ending with 'Template'
    
  • Need help in obtaining snapshot and decision after... Help please!

    I would like to know if a virtual machine has a snapshot... If so, I need the workflow to terminate and send by e-mail. If it does not have a snapshot, then she can continue with the workflow. I have everything works except the part of the decision, in this case, it will say there is a snapshot when it does not actually exist and complete the workflow... workflow and the script is described below. Any help is very appreciated!

    Get the snapshot Script:

    Snapshot = new Array();

    machines virtual var = VcPlugin.getAllVirtualMachines ();

    for {(i SMV)

    var vm = vms [i];

    If (vm.runtime.connectionState.value == "connected" & &! vm.config.template) {}

    var vmLayout = vm.layoutEx;

    {if(vmLayout!=null)}

    var layoutFiles = vmLayout.file;

    var layoutSnapshots = vmLayout.snapshot;

    for {(l layoutSnapshots)

    var layoutSnapshot = layoutSnapshots [l];

    dataKey var = layoutSnapshot.dataKey;

    for {(layoutFiles m)

    {if (layoutFiles [m]. Key is dataKey)}

    If (layoutFiles [m] .size/1024/1024 > snapshotSize) {}

    capture instant var = VcPlugin.convertToVimManagedObject (vm, layoutSnapshot.key);

    Snapshot.push (snapshot);

    System.log ("Name:" + layoutFiles [m] .name + "-size:" + layoutFiles [m] .size);

    }

    }

    }

    }

    }

    }

    }

    Decision of snapshot:

    If (snapshot. Length > 0) {}

    Returns false;

    } else {}

    Returns true;

    }

    Yes, it is possible.

    Perhaps the easiest way is to define an attribute (of type VC:Datastore) workflow, select its value using the selector and then use it in your work flow the same way you used the input parameter.

    Another option would be to "Default Value" production designer in the presentation for the input parameter data store and bind it to a script action that returns the value of desired data store object.

  • New Workflows

    Hi, is there a resource to get new workflows across?  I'm short vCO 5.5 and the workflow I want is to list all active Snapshots in our environment.  I am not enough yet to create my own uncomfortable.

    Thank you very much

    Here you go:

    snapshots = new Array();
    var vms = VcPlugin.getAllVirtualMachines();
    for(i in vms){
        var vm = vms[i];
        if(vm.runtime.connectionState.value=="connected" && !vm.config.template){
            var vmLayout = vm.layoutEx;
            if(vmLayout!=null){
                var layoutFiles = vmLayout.file;
                var layoutSnapshots = vmLayout.snapshot;
                for(l in layoutSnapshots){
                    var layoutSnapshot = layoutSnapshots[l];
                    var dataKey = layoutSnapshot.dataKey;
                    for(m in layoutFiles){
                        if(layoutFiles[m].key==dataKey){
                                var snapshot = VcPlugin.convertToVimManagedObject(vm,layoutSnapshot.key);
                                snapshots.push(snapshot);
                        }
                    }
                }
            }
        }
    }
    System.log("Total number of Snapshots found: "+snapshots.length);
    
  • Find a VM by RegEx name - how to ignore case

    Hello

    In vCO, there is a standard Action that looks like this:

    ----------

    Get all Virtual Machines for all vCenter connections defined for this plugin

    var allVms = VcPlugin.getAllVirtualMachines ();

    machines virtual var = new Array();

    Make sure the virtual machine matches the regular expression

    for (var i in allVms) {}

    If (allVms [i].name.match (regexp)) {}

    VMS.push (allVms [i]);

    }

    }

    VMList = MV;

    ----------

    How can I do this actions ignore the case. I searched this in Java script and found that I have to add "/ I" in the regular expression, but I can't make it work.

    If (allVms[i].name.match(regexp/i)) {}

    Anyone know how to get this working?

    / Brian

    This should work with a variable:

    var allDcs = VcPlugin.allDatacenters;
    var nameToMatch = "B00019V";
    for (var i in allDcs) {
      if (allDcs[i].name.match(new RegExp(nameToMatch, "i"))) {
        System.log("found match -> " + allDcs[i].name);
      }
    }
    
  • selective deletion of snapshot of a cluster.

    Hi all

    Task:-remove the snapshot of all virtual machines in a selective cluster (I have 4 clusters, I want to choose a cluster).

    Question:-I am able to select the cluster and inform you of all virtual machines, but at the time of the removal of the snapshot, he said that no snapshot are avalible.  I have attached the workflow. could you help me to fix the workflow (lack of logic). Thank you inadvance for assistance.

    Hello

    I recommend to reproduce the action of getPropertiesForAllSnapshotTask and change the first line he of

    machines virtual var = VcPlugin.getAllVirtualMachines ();

    TO

    machines virtual var = System.getModule("com.vmware.library.vc.cluster").getAllVMsOfCluster (cluster);

    Don't forget to add a parameter named 'cluster' of type clustercomputeResource to action.

    You can do almost the original library workflow, the only thing to change it is to call your action rather than the original action and link the cluster parameter.

    See you soon,.

    Joerg

  • How to delete a virtual machine in a script


    Hello

    I want to delete a virtual machine with a VCO script, I wouldn't use the action item named destroyVM. I explain why I wouldn't use, because in my script, I do this action:

    1. I list all VM in a specific folder name is different date servername-today ' today and powered OFF.

    2. I would destroy each VM in the list.

    But when I would simply test the following command:

    System.getModule("com.vmware.library.vc.vm").destroyVm ("VMName");

    I get the following error message:

    TypeError: Cannot read property "runtime" undefined (name of the dynamic Script Module: destroyVm #52993)

    I search on google and VMware blog, I can't find anything to help me!

    If someone has an idea, you are welcomed to answer me.

    Thank you in advance

    Good day

    Best regards

    Christophe

    Hello

    If you have access to vm.name or vm.runtime, you can access the vmobject.

    Therefore, you don't have to search again. I'm confused...

    (1.) what is folderObject?

    2.) check your if condition. It is not '&' what you want, but «&»

    (3.) getAllVMsMatchingRegexp() returns an array of vmobjects, not a single vmobject. VM names are NOT unique.

    Maybe a small example can help:

    var vmArray = VcPlugin.getAllVirtualMachines();
    for (var vmIndex in vmArray)
    {
        if ((vmArray[vmIndex].runtime.powerState == VcVirtualMachinePowerState.poweredOff) && (vmArray[vmIndex].name == "SCT-Test-01_12_2013"))
        {
            System.getModule("com.vmware.library.vc.vm").destroyVm(vmArray[vmIndex]);
        }
    }
    
  • VM.name attribute copy to another attribute vm_new.name

    Hi people,

    I'm now trying to generate a new attribute on an old.

    I want the vm.name of the attribute that is "Test_Archive" in a new attribute vm_new.name "Clone_Test_Archive". I tried the following code:

    new_vm_name. Name = Clone_ "+ vm.name" ""

    I get an error: type: cannot set the property 'name' to 'Clone_Test_Archive' null

    Where is my mistake?

    Thank you very much.

    Chris

    To see if the virtual machine already exists, you must verify each existing VM if the name is the name you are looking for. Here's a sample:

    var vmExists = false;
    
    if ( new_vm_name == "" ) throw "no VM name to search for";
    
    var myVirtualMachines = VcPlugin.getAllVirtualMachines();
    for each (var myVirtualMachine in myVirtualMachines)
    {
      if ( new_vm_name == myVirtualMachine.name )
      vmExists = true;
    }
    
    if ( vmExists == true )
    {
      System.log( "VM with name " + new_vm_name + " exists." );
    }
    

    Kind regards

    Chris

  • Search case-insensitive for VM by name

    I found examples of code in communities, but it seems that the searches are case-sensitive.  We need help in modifying the script to make it case insensitive.

    var vms = VcPlugin.getAllVirtualMachines(null, "xpath:name='"+vmName+"'"); 
    var vmObject = null;  
    if (vms != null && vms.length >0){  
      System.log("VMs Found: " + vms.length);
        if (vms.length == 1){  
            System.log("Match found for vm named: "+vmName);  
            vmObject = vms[0];  
        }else{  
            System.log("More than one VM found with that name! "+vmName);  
            for each (vm in vms){  
                System.log("VM ID: "+vm.id);  
            }  
        }  
    }else{
      System.log("No VMs Found");
    }
    

    .

    Hi, I was about to send another question on this same method.  Here is what I use to perform a case-insensitive search:

    machines virtual var = VcPlugin.getAllVirtualMachines (null, "xpath:name [translate(.,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ') =" "+ arg_nameToMatch.toUpperCase () +"'"]");

Maybe you are looking for