Bay of Cluster data store turns into a string?

I am very new to the vCO (or maybe I should call vRO now) and therefor also very new to script and digging through the API, so I apologize if this is a bit of a noob question.

I'm currently running below script to find the data store cluster to a cluster host with more available space.

However, I also want to check for the text in the name of the data store. For this I use indexOf.

If indexOf detects all matches, it should add the DSC (or pod) in a table.

But it seems that this operation turns my array into a string.

Because it is a new environment I have only a DSC connected to the cluster hosts, but I still think that it should be able to be an array with a single value?

Find the Cluster and related variables

var hostarray = System.getModule ("com.vmware.library.vc.cluster") .getAllHostSystemsOfCluster (inCluster);

Host = hostarray [0];

pool = inCluster. ResourcePool;

level of var = 'High';

Find warehouses of data in Cluster

var = host.datastore data warehouses;

Find Clusters of Cluster data store

var storagePods = new Array();

var storagePodNames = new Array();

for (d in data warehouses) {

if (data [d].parent.vimType warehouses is "StoragePod") {

if (storagePodNames.indexOf (datastores [d].parent.name) < = - 1). {

storagePodNames.push (datastores [d].parent.name);

storagePods.push (datastores [d] .parent);

}

}

}

System.log (' storagePods: ' + storagePods [0].) Summary.freeSpace);

Find Clusters corresponding to the layer data store

var podTierArray = new Array();

for each {(var pod in storagePods)

     if (pod.name.indexOf (tier) > = 0) {

podTierArray += pod;

}

}

podTierArray becomes a string instead of table after above operation :(((

System.log (' podTierArray: ' + podTierArray [0]);

System .log (' podTierArray: ' + podTierArray);

Here is the result of the above script:

[12:24:27.307 2015-02-27] [I] storagePods: 4497773428736

[12:24:27.308 2015-02-27] [I] podTierArray: D

[12:24:27.310 2015-02-27] [I] podTierArray: DynamicWrapper (Instance): [VcDatastore]-[class com.vmware.vmo.plugin.vi4.model.VimDatastore] - VALUE: < datastore-386 > Datastore 'high Datastore01 '.


I'm guessing that "D" is the first character in the string (which should be an array), which is also attested by the third row of the output when I print the entire string.

Because this time is a string I can't use it as an object, for example "podTierArray. Summary.freeSpace' give me an error that it is a property not set.

In addition, as you can see earlier when I use the variable ""storagePods "this is a picture I have run the podTierArray. "


Why would he suddenly become a string instead of an array of objects?

Hi Oskar,

It happens because of this line in your code

podTierArray += pod;

This is not the right way to add the element in a table. You need to take it

podTierArray.push(pod);

Tags: VMware

Similar Questions

  • remove the Cluster data store data store

    I have an infrastructure with vCenter and ESXi 4 5.5 I have a data cluster store in SAN with 8 Mon, I need to remove 3 Lun (to be used for other purposes) what is the appropriate procedure

    to remove the Lun (end then to destroy)? Thank you

    Do you want the LUN to use for purpose of non-vSphere? If so, you can just storage vMotion virtual machines since associated LUN data warehouses that you want to decommission (or simply putting the data store in maintenance mode, in this way, that the virtual machines will automatically be migrated). Cleaning after the data store, move the data store from the cluster data store, and then delete the VMware environment data store as described here: best practices: how to properly remove a unit number logic of a host ESX - VMware vSphere Blog - VMware Blogs

  • Question about the creation of cluster data store

    I'm running vSphere 5.1 and want to enable storage Drs before as I have create the cluster data store, I was reading through VMware vSphere 5.1, but don't see any confirmation when I add data to the cluster storage, the virtual machines using these storage of data is not affected.

    Can anyone confirm that the addition of a data to a data cluster store store has no impact on virtual machines running?

    Thank you.

    Can anyone confirm that the addition of a data to a data cluster store store has no impact on virtual machines running?

    You can add and remove data warehouses in a cluster of data with VMS running store.

  • Cluster data store

    Currently we have a number of data warehouses VMStore_Live1 at 8, recently we had a data store to fill and this due to a problem with some of the virtual machines running in our direct environment.

    I had a thought on the use of cluster data store so storage DRS would be used between data warehouses, we are currently using NetApp, would be one of your recommend using cluster data store? or is there some catch with this?

    We have a host with DRS and HA cluster, but at the moment we have just warehouses of separate data which manually migrate us vm.

    Yes,

    We have two modes:

    1 manual load balancing

    2. automatic load balancing

    We do not have partially automated our way to BLAH DRS cluster.

    Note that: automated initial investment is excluded in both modes: DTS generates a recommendation of initial investment which still requires a manual confirmation.

  • How can I get the list of data stores in a cluster data store?

    How can I get the list of data stores in a cluster data store? I mean the command line option.

    Hello

    by command line, you mean PowerCLI?

    If so, you can display data with this warehouses:

    Get-DatastoreCluster-name DSClustername | Get-Datastore

    Tim

    Edit: Moved the thread to the PowerCLI community

  • Add the host Cluster in the Cluster data store

    How can I add host/HostCluster in the Cluster data store after the cluster data store is created. I know that we can add at this time, when you create the cluster data store, but how can we add it as soon as it is created?

    I think that as long as the new host has access to all the LUNS that comprise data warehouses in the cluster data store, then no further action is necessary.

    Make sure just that if using CF then zoning is configured correctly and the LUNS are not hidden from the new host.

    Also, make sure you restart the analysis for new data warehouses on your new host so that it can detect data warehouses

  • Select several files and store in table: folder object type turns into a string?

    Hello

    I'm trying to implement the following:

    The user selects a folder (which contains subfolders) in a dialog box:

    Set Dateiauswahl = CreateObject. BrowseForFolder (0, "Verzeichnis Park", 512, mess_path)

    Folder value = CreateObject ("Scripting.FileSystemObject"). GetFolder (Dateiauswahl.Self.Path)

    All subfolders of the selected folders are listed in two variables with the overall picture:

    Call GlobalDim ("FolderList (" & Ordner.SubFolders.Count - 1 & "" ")" ")

    Call GlobalDim ("FolderPaths (" & Ordner.SubFolders.Count - 1 & "" ")" ")

    f = 0
    for each Unterordner in Ordner.SubFolders
    FolderList (f) = Unterordner.Name
    FolderPaths (f) = Unterordner
    f = f + 1

    next

    Only later the files of some of the subfolders should be stored in another file list table:

    f = 0
    for q = 0 to UBound (selection)
    Unterordner = FolderPaths (selection (q))
    Call MsgBox (Unterordner)
    For each file in Unterordner.Files
    If instr (1, File.Name, "Speed") = 0 then
    FileList (f) = File.Path
    f = f + 1
    end if
    Next

    next

    Now I seem to have a problem with the type data stored in the FolderPaths table. While Unterordner is a Folder object and must be a Folder object for each file in Unterordner.Files to work, store in the array it transformed into a string variable.

    I don't really understand why and am looking for a solution so that I can extract single table FolderPaths subfolders and then extract the files.

    Hi maliya,.

    To assign an object to an array element (or any other variable), you must use the Set syntax, like this:

    Set FolderPaths (f) = Unterordner

    Then later you can retrieve it with the same syntax:

    Set Unterordner = FolderPaths (selection (q))

    Brad Turpin

    Tiara Product Support Engineer

    National Instruments

  • Clone a virtual machine to a Cluster data store

    Hello

    Really simple (hopefully), but I'm trying to write a workflow that includes the provision of a virtual computer to a cluster of data store. I'm a link to the workflow 'Clone the virtual machine, no customizations' that only accepts a store of input data.

    I hope that I am a bit stupid here and there is a simple answer?

    Thank you.

    There is no simple answer.  DRS clusters are actually a set of rules and not a real thing, you can deploy a VMDK.  I suggest to use Onyx to deploy a virtual computer to a DRS cluster and see what it generates.  If I remember correctly, it executes DRS rules to get a recommendation for where to put a VMDK fundamentally and then uses the exit in order to actually deploy the model.

    I opted to write just a simple workflow that finds the data store with the most of freespace that corresponds to a string - for example, if I have a DRS cluster named DSCluster_ugabuga, I have a lot of data stores named something like "ugabuga... ».  So you ask these storages of data and find the one which most freespace.

  • Issue of Cluster data store

    Hello

    Is it possible to have 4 ESXi clusters, each with their own set of SAN data warehouses, all joined to a Cluster of unique data store? I have not found exactly this configuration described anywhere. I understand there are limitations such as 32 data etc. stores and paths to data warehouses will be available from certain hosts.

    Has anyone tried this before? I'm trying to simplify investment VM for Cloud management platform.

    Thank you

    Mike

    This is a supported configuration, and I have a few clients that are running this configuration without problem. Have a look here for details: linking DRS multiple clusters in a single Storage DRS datastore cluster. - frankdenneman.nl

  • Creating a new Cluster data store

    Hello

    Can we move a data store in a Cluster of data while its machines store still virtual hosting?  I was not able to find information on this. What I find the Clusters data store talking about new environments.  I'm working on an existing vSphere 5.5 but the storage of data are not grouped.  I want to place data warehouses in a Cluster of quick data without vMotioning store VMS off.

    Thank you

    Boston Tech Guy

    You can move the datastore in the store Cluster data without any downtime, and while VMS are running on it. (This is as same as you put cluster host, while VMS are running).

  • Put the data store in the Cluster data store (StoragePod)

    Hello

    Try to a data store in a data cluster store, but the attribute VcDatastore.parent is ready, what is the best way to do this?

    Thanks in advance.

    Try stoargeCluster.moveIntoFolder_Task (arrayOfDatastoresToAdd);

  • Cluster data store information

    Hi - I was wondering if someone has a script that can detail the following information .in one table...

    Name of the cluster - & gt; Name of the store data - & gt; Total size - & gt; Free space - & gt; % used space

    I have 2 groups where the data store names are the same in each cluster. I would like a way to be able to see who have warehouses of data 15% or less of free space and the data store cluster that belongs to.

    If anyone can help with that would be great

    concerning

    Chris

    We cannot use the cmdlet WHer-Object here since we don't test in a pipe.

    But a simple if statement with the StartsWith method should do the trick.

    Something like this:

    $report = @()
    
    Get-Cluster $clusterName | Get-View | % {
         foreach($dsMoRef in $cluster.Datastore){
              $ds = Get-View -Id $dsMoRef
              if(-not $ds.Info.Name.StartsWith("LOCAL")){
                   $row = "" | Select Cluster, Datastore, Size, Free, UsedPercentage
                   $row.Cluster = $cluster.Name
                   $row.Datastore = $ds.Info.Name
                   $row.Size = $ds.Info.Vmfs.Capacity
                   $row.Free = $ds.Info.FreeSpace
                   $row.UsedPercentage = "{0:N2}" -f (($row.Size - $row.Free)/$row.Size * 100)
                   $report += $row
              }
         }
    }
    $report
    
  • Script to create virtual machines fails when you try to add the disk to the cluster data store

    Hello

    Attached is the script that I used to create virtual machines and it works very well when virtual machines are created to warehouses of unique data, but do not have clustered data warehouses. I think that the reason is that it creates the virtual machine through the esx host (who does not know the cluter) and not via vCenter (who knows about it). Unfortunately I do not know how to fix.

    Thank you

    Astra

    Looks like he needs a store of data for this parameter object. So we need to do a get Datastore cluster I can try to test tomorrow, but try this:

    If ($datastore1 - only 'none') {}

    $drscluster = get-DatastoreCluster $datastore1

    $vmadddsk = new-disk-hard - VM $gstname CapacityKB - $datastore1size - data $drscluster store

    }

  • Available by cluster data store capacity

    Hi guys

    I was wondering anyone can help me? Looking for a script that counts datastore space free (only VMFS non-local) and how many virtual machines can be supplied by cluster take the average size of a virtual computer as 50 GB.

    Found various scripts, but nothing indicating the total amount of that virtual machines can be configured according to the available free space.

    Thanks in advance

    Hello

    could test you. This should make you request based on

    Total = 1000 GB

    free = 500GB

    10% = 100 GB

    500 GB (100 GB) / 50 = 8

    SE connect-VIServer-server 'server name' - credential (get-credential)

    $report = @)

    $clusterDSReport = @)

    {foreach ($cluster Get-cluster)

    $dsClusterFree = 0

    $dsClusterCapacity = 0

    Get-Datastore - RelatedObject $cluster | where {$_ game-match "VMFS" - and $_.} Name - notmatch ' local | snap"} | %{

    $info = "" | Select the center of data, Cluster, available capacity

    $info. Datacenter = $_. Data Center

    $info. Cluster = $cluster. Name

    $info. Name = $_. Name

    $info. Capacity = [math]: Round($_.capacityGB,2)

    $info. Available = [math]: tour ($_.) FreeSpaceGB, 2)

    $report += $info

    $dsClusterCapacity += $info. Capacity

    $dsClusterFree += $info. Available

    }

    $clusterInfo = "" | Select the Cluster, 'Places available.

    #$clusterInfo = 'Clusters', 'locations '.

    $clusterInfo.Cluster = $cluster. Name

    $clusterInfo. 'Locations' = [math]: Round ($dsClusterFree - ($dsClusterCapacity * 0.1)) / 50

    $clusterDSReport += $clusterInfo

    }

    $report | Export-Csv "C:\vmware\scripts\datastore\cluster-ds.csv" - NoTypeInformation - UseCulture

    $clusterDSReport | Export-Csv "C:\vmware\scripts\datastore\cluster-free-VM-slots.csv" - NoTypeInformation - UseCulture

  • Error in adding the Cluster data store

    "It was not correct to specified parameters. datastore.info.Type ".

    It is a connected iSCSI Synology. I'm sure this is a setting that I missed, can anyone point me in the right direction?

    With vSphere Client 5.5.0, vCenter Server 5.5.0. All hosts running 5.5 as well.

    Thank you!

    Nevermind, I found it. Different types. NAS vs. VMFS. Sigh.

Maybe you are looking for