如何查找呈现给计算群集的数据存储群集?

时间:2015-03-05 16:43:55

标签: powercli

我在休息服务中使用PowerCLI脚本调用。其余服务正在传递大量有关新VM构建请求的数据。对于部署,我得到的唯一数据(与此问题相关)是vcenter服务器和计算群集名称。我需要找出一种方法来确定使用计算群集名称部署VM的数据存储群集。如果我做一个get-cluster $ clustername | fl *我没有看到计算机集群和数据存储集群之间存在任何关联。

如果我在群集中获取有关VM主机(get-vmhost $ vmhost)的信息,我会看到datastoreIDlist作为VMhost对象的属性,并且可以看到呈现给它的数据存储(而不是数据存储群集)。这不是理想的,但可能是可行的。

我知道在vcenter中呈现给他们的计算群集和存储之间存在关系。为什么我不能在powercli中找到它?

1 个答案:

答案 0 :(得分:0)

这是查看这些关系的一种方式

get-view -viewtype clustercomputeresource | % {$_.name + " `n " + $_.datastore + "`n"}

不太好,但这会列出每个计算群集可用的数据存储群集:

 $ccr = get-view -viewtype ClusterComputeResource
 $pods = get-view -viewType StoragePod
 $pods | % {set-variable -name $_.name.replace("-","") -value $_.childentity.value} #my storage cluster names happen to contain hyphens, which do not play nice with get/set-variable, hence the .replace
 foreach ($c in $ccr) {
   $list = @()
   foreach ($vol in $c.datastore.value) { $match = $null
    $match = $pods | where {$_.childentity.value -contains $vol} | select -expand name
    if ($match) {$list += $match}
   } #close foreach vol
   set-variable -name $c.name -value $list
 } #close foreach c
$ccr.name | % {$_ + ": " + ((get-variable $_).value | select -unique) }