質問

Trying and trying to do something very simple in fog 1.9 with the vsphere provider. The examples in the little documentation there is not working for me.

I want to list all VMs in a folder. 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. Grr.

I've tried lots of variations on the folder variable e.g.

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top