简体   繁体   English

vSphere和雾

[英]VSphere and Fog

Trying and trying to do something very simple in fog 1.9 with the vsphere provider. 尝试使用vsphere provider在fog 1.9中做一些非常简单的事情。 The examples in the little documentation there is not working for me. 小文档中的示例对我不起作用。

I want to list all VMs in a folder. 我要列出文件夹中的所有VM。 Simple eh? 简单吗?

Tried... 试过...

credentials = {
    :provider => "vsphere",
    :vsphere_username => user,
    :vsphere_password=> pass,
    :vsphere_server => "vc_name",
    :vsphere_ssl    => true,
    :vsphere_expected_pubkey_hash => "1466f20c1b3f990a2a018dc2ca22a79fc2d0284ab4aac534c47blah"
}

compute = Fog::Compute.new(credentials)
vms = compute.servers.all('folder' => '/Datacenters/Ewl/Self-Service')

pp vms

This connects and churns away and RETURNS ALL VMs IN THE DATACENTER and not just the folder. 这将连接并搅动并返回数据中心中的所有VM,而不仅仅是文件夹。 Grr. 格儿。

I've tried lots of variations on the folder variable eg 我已经尝试了很多文件夹变量的变化,例如

vms = compute.servers.all('folder' => '/Hosts & Clusters/Ewl1_vm/Self-Service')
vms = compute.servers.all('folder' => 'Self-Service')
vms = compute.servers.all('folder' => 'Self-Service','datacenter' => 'Ewl')

But all do the same thing. 但是所有人都做同样的事情。

I've worked through the code and it's not helped me really. 我已经遍历了代码,但并没有真正帮助到我。

Help! 救命!

If I'm understanding what your datacenter and folder name are, then the simple way to do this is: 如果我了解您的数据中心和文件夹名称是什么,那么执行此操作的简单方法是:

vms = compute.list_virtual_machines(datacenter: 'Ewl', folder: 'Self-Service')

'folder' in the .servers.all filter hypothetically should work, but you are bound to find surprises with hidden paths, more than 1 datacenter, etc. 假设.servers.all过滤器中的“文件夹”应该可以工作,但是您一定会发现隐藏路径,多个数据中心等带来的惊喜。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM