【问题标题】:How to find datastore clusters presented to compute cluster?如何找到呈现给计算集群的数据存储集群?
【发布时间】:2015-03-05 16:43:55
【问题描述】:

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

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

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

【问题讨论】:

    标签: powercli


    【解决方案1】:

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

    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) }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-26
      • 2021-07-05
      • 1970-01-01
      • 1970-01-01
      • 2017-06-01
      • 1970-01-01
      • 2020-11-15
      • 1970-01-01
      相关资源
      最近更新 更多