VMware Cloud Community
jasonrobinson
Enthusiast
Enthusiast
Jump to solution

UpdateViewData Parent

I am trying to use the UpdateViewData method on the parent property from a ESXi host to collect all of the information from the parent cluster. However I am only able to collect the Name from the parent property when using UpdateViewData, is this expected behavior?

$vmhost.UpdateViewData('Parent.*')

$vmhost.LinkedView.Parent


Configuration   :
Recommendation  :

DrsRecommendation   :

MigrationHistory:
ActionHistory   :
DrsFault        :
LinkedView      :
ResourcePool    :
Host            :
Datastore       :
Network         :
Summary         :

EnvironmentBrowser  :

ConfigurationEx :
Parent          : Folder-group-h48
CustomValue     : {}
OverallStatus   : green
ConfigStatus    : green
ConfigIssue     : {}
EffectiveRole   : {-1}
Permission      : {}
Name            :TestCluster
DisabledMethod  : {}
RecentTask      : {}

DeclaredAlarmState  : {alarm-1.domain-c51, alarm-10.domain-c51, alarm-11.domain-c51, alarm-12.domain-c51...}

TriggeredAlarmState : {}

AlarmActionsEnabled : False

Tag             : {}
Value           : {}
AvailableField  : {}
MoRef           : ClusterComputeResource-domain-c51
Client          : VMware.Vim.VimClientImpl
Jason @jrob24
0 Kudos
1 Solution

Accepted Solutions
jasonrobinson
Enthusiast
Enthusiast
Jump to solution

I opened an SR with VMware and it is in fact a bug, they gave me a workaround until it is addressed, which is one additional call to the UpdateViewData method.

$vmhost.UpdateViewData('Parent.*')

# This is the additional call to update view data

$vmhost.LinkedView.Parent.UpdateViewData()

# Check result

$vmhost.LinkedView.Parent

Jason @jrob24

View solution in original post

0 Kudos
8 Replies
LucD
Leadership
Leadership
Jump to solution

Seems to work for me, not sure if the meta-character is allowed in your command.

$vmhost = Get-View -ViewType HostSystem -Property Name -Filter @{'Name'='MyEsx'}

Write-Host 'Before'

$vmhost.Parent

$vmhost.UpdateViewData('Parent')

Write-Host 'After'

$vmhost.Parent


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
jasonrobinson
Enthusiast
Enthusiast
Jump to solution

Hmm, that didnt change anything on my side. I also thought you had to call the LinkedView property after running UpdateViewData to see the properties of the object. For example this works fine:

PowerCLI C:\> $vmhost.UpdateViewData('VM.Summary')

PowerCLI C:\> $vmhost.LinkedView.Vm.Summary

This gives me all of the summary data back from the VMs hosted on $vmhost.

Trying what you suggested didn't give me back any properties on the cluster object.

PowerCLI C:\> $vmhost.UpdateViewData('Parent')

PowerCLI C:\> $vmhost.Parent

Type                                    Value

----                                    -----

ClusterComputeResource                  domain-c51

Ideally I want to collect the summary properties on the parent object (cluster) without having to run Get-View again. Trying it this way throws this error:

PowerCLI C:\> $vmhost.UpdateViewData('Parent.Summary')

Exception calling "UpdateViewData" with "1" argument(s): "The specified path

is not correct. Element 'summary' doesn't exist."

At line:1 char:1

+ $vmhost.UpdateViewData('Parent.Summary')

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : ArgumentException

Then trying it the original way I posted doesn't give me anymore data outside of the name property for the Parent.

Jason @jrob24
0 Kudos
LucD
Leadership
Leadership
Jump to solution

From your output it seems to be returning correctly.

The Parent property contains a MoRef, and that is what is shown.

You do another Get-View, or use the LinkedView, to get the object the MoRef is pointing to.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
jasonrobinson
Enthusiast
Enthusiast
Jump to solution

Ok I must be missing it then. How can I use LinkedView to get all of the properties of the parent object the MoRef is pointing to?

Based on the way I use UpdateViewData for all other objects (outside of Parent) this works fine. However as you can see I only get back the cluster name and nothing else.

PowerCLI C:\> $vmhost.UpdateViewData('Parent.*')

PowerCLI C:\> $vmhost.LinkedView.Parent

Configuration   :
Recommendation  :

DrsRecommendation   :

MigrationHistory:
ActionHistory   :
DrsFault        :
LinkedView      :
ResourcePool    :
Host            :
Datastore       :
Network         :
Summary         :

EnvironmentBrowser  :

ConfigurationEx :
Parent          :
CustomValue     :
OverallStatus   : gray
ConfigStatus    : gray
ConfigIssue     :
EffectiveRole   :
Permission      :
Name            : TestCluster
DisabledMethod  :
RecentTask      :

DeclaredAlarmState  :

TriggeredAlarmState :

AlarmActionsEnabled : False

Tag             :
Value           : {}
AvailableField  :
MoRef           : ClusterComputeResource-domain-c51
Client          : VMware.Vim.VimClientImpl

Here I am doing the same thing on VM and it returns ALL of the properties on the VM objects.

PowerCLI C:\> $vmhost.UpdateViewData('VM.*')

PowerCLI C:\> $vmhost.LinkedView.Vm

Capability           : VMware.Vim.VirtualMachineCapability

Config               : VMware.Vim.VirtualMachineConfigInfo

Layout               : VMware.Vim.VirtualMachineFileLayout

LayoutEx             : VMware.Vim.VirtualMachineFileLayoutEx

Storage              : VMware.Vim.VirtualMachineStorageInfo

EnvironmentBrowser   : EnvironmentBrowser-envbrowser-893

ResourcePool         : ResourcePool-resgroup-52

ParentVApp           :

ResourceConfig       : VMware.Vim.ResourceConfigSpec

Runtime              : VMware.Vim.VirtualMachineRuntimeInfo

Guest                : VMware.Vim.GuestInfo

Summary              : VMware.Vim.VirtualMachineSummary

Datastore            : {Datastore-datastore-71}

Network              : {Network-network-183}

Snapshot             : VMware.Vim.VirtualMachineSnapshotInfo

RootSnapshot         : {VirtualMachineSnapshot-snapshot-899}

GuestHeartbeatStatus : gray

LinkedView           :

Parent               : Folder-group-v47

CustomValue          : {}

OverallStatus        : green

ConfigStatus         : green

ConfigIssue          : {}

EffectiveRole        : {-1}

Permission           : {}

Name                 : Jasontest

DisabledMethod       : {MakePrimaryVM_Task, TerminateFaultTolerantVM_Task,

                       ResetVM_Task, UnmountToolsInstaller...}

RecentTask           : {}

DeclaredAlarmState   : {alarm-10.vm-893, alarm-11.vm-893, alarm-2.vm-893,

                       alarm-23.vm-893...}

TriggeredAlarmState  : {}

AlarmActionsEnabled  : True

Tag                  : {}

Value                : {}

AvailableField       : {}

MoRef                : VirtualMachine-vm-893

Client               : VMware.Vim.VimClientImpl

Why would ViewUpdateData('Parent.*') not work exactly the same way?

Jason @jrob24
0 Kudos
jasonrobinson
Enthusiast
Enthusiast
Jump to solution

Does anyone know the difference?

Jason @jrob24
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You didn't say which PowerCLI version you are using.

Imho, and after further tests on my side with PowerCLI 6R1, this looks like a bug in the LinkedView handling of a ClusterComputeResource object.

If I try to get access to the properties that are not displayed (in your example), in this example ConfigurationEx, I get an error

linkedview.png

I would suggest you file an SR for the issue (and yes, PowerCLI is supported).


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
jasonrobinson
Enthusiast
Enthusiast
Jump to solution

I am running PowerCLI 6R1 as well but just tested it in PowerCLI 5.8 R1 and received the same results. I will try and get a case open and see what I can find out.

Jason @jrob24
0 Kudos
jasonrobinson
Enthusiast
Enthusiast
Jump to solution

I opened an SR with VMware and it is in fact a bug, they gave me a workaround until it is addressed, which is one additional call to the UpdateViewData method.

$vmhost.UpdateViewData('Parent.*')

# This is the additional call to update view data

$vmhost.LinkedView.Parent.UpdateViewData()

# Check result

$vmhost.LinkedView.Parent

Jason @jrob24
0 Kudos