mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
Support nested host folders in find_cluster()
Search the root and any subfolders for cluster or host resources.
This commit is contained in:
parent
114cb9f398
commit
f6fdfe42d7
3 changed files with 81 additions and 14 deletions
|
|
@ -2887,6 +2887,7 @@ EOT
|
|||
|
||||
describe '#find_cluster' do
|
||||
let(:cluster) {'cluster'}
|
||||
let(:host) { 'host' }
|
||||
let(:missing_cluster) {'missing_cluster'}
|
||||
|
||||
context 'no clusters in the datacenter' do
|
||||
|
|
@ -2909,10 +2910,11 @@ EOT
|
|||
:datacenters => [
|
||||
{ :name => datacenter_name,
|
||||
:hostfolder_tree => {
|
||||
'cluster1' => {:object_type => 'compute_resource'},
|
||||
'cluster2' => {:object_type => 'compute_resource'},
|
||||
cluster => {:object_type => 'compute_resource'},
|
||||
'cluster3' => {:object_type => 'compute_resource'},
|
||||
'cluster1' => {:object_type => 'cluster_compute_resource'},
|
||||
'cluster2' => {:object_type => 'cluster_compute_resource'},
|
||||
cluster => {:object_type => 'cluster_compute_resource'},
|
||||
'cluster3' => {:object_type => 'cluster_compute_resource'},
|
||||
host => {:object_type => 'compute_resource'},
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -2926,6 +2928,13 @@ EOT
|
|||
expect(result.name).to eq(cluster)
|
||||
end
|
||||
|
||||
it 'should return the single host when found' do
|
||||
result = subject.find_cluster(host,connection,datacenter_name)
|
||||
|
||||
expect(result).to_not be_nil
|
||||
expect(result.name).to eq(host)
|
||||
end
|
||||
|
||||
it 'should return nil if the cluster is not found' do
|
||||
expect(subject.find_cluster(missing_cluster,connection,datacenter_name)).to be_nil
|
||||
end
|
||||
|
|
@ -2937,14 +2946,15 @@ EOT
|
|||
:datacenters => [
|
||||
{ :name => 'AnotherDC',
|
||||
:hostfolder_tree => {
|
||||
'cluster1' => {:object_type => 'compute_resource'},
|
||||
'cluster2' => {:object_type => 'compute_resource'},
|
||||
'cluster1' => {:object_type => 'cluster_compute_resource'},
|
||||
'cluster2' => {:object_type => 'cluster_compute_resource'},
|
||||
}
|
||||
},
|
||||
{ :name => datacenter_name,
|
||||
:hostfolder_tree => {
|
||||
cluster => {:object_type => 'compute_resource'},
|
||||
'cluster3' => {:object_type => 'compute_resource'},
|
||||
cluster => {:object_type => 'cluster_compute_resource'},
|
||||
'cluster3' => {:object_type => 'cluster_compute_resource'},
|
||||
host => {:object_type => 'compute_resource'}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -2958,6 +2968,13 @@ EOT
|
|||
expect(result.name).to eq(cluster)
|
||||
end
|
||||
|
||||
it 'should return the single host when found' do
|
||||
result = subject.find_cluster(host,connection,datacenter_name)
|
||||
|
||||
expect(result).to_not be_nil
|
||||
expect(result.name).to eq(host)
|
||||
end
|
||||
|
||||
it 'should return nil if the cluster is not found' do
|
||||
expect(subject.find_cluster(missing_cluster,connection,'AnotherDC')).to be_nil
|
||||
end
|
||||
|
|
@ -2969,13 +2986,18 @@ EOT
|
|||
:datacenters => [
|
||||
{ :name => datacenter_name,
|
||||
:hostfolder_tree => {
|
||||
'cluster1' => {:object_type => 'compute_resource'},
|
||||
'cluster1' => {:object_type => 'cluster_compute_resource'},
|
||||
'folder2' => {
|
||||
:children => {
|
||||
cluster => {:object_type => 'compute_resource'},
|
||||
cluster => {:object_type => 'cluster_compute_resource'},
|
||||
}
|
||||
},
|
||||
'cluster3' => {:object_type => 'compute_resource'},
|
||||
'cluster3' => {:object_type => 'cluster_compute_resource'},
|
||||
'folder4' => {
|
||||
:children => {
|
||||
host => {:object_type => 'compute_resource'},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -2983,13 +3005,19 @@ EOT
|
|||
}}
|
||||
|
||||
it 'should return the cluster when found' do
|
||||
pending('https://github.com/puppetlabs/vmpooler/issues/205')
|
||||
result = subject.find_cluster(cluster,connection,datacenter_name)
|
||||
|
||||
expect(result).to_not be_nil
|
||||
expect(result.name).to eq(cluster)
|
||||
end
|
||||
|
||||
it 'should return the host when found' do
|
||||
result = subject.find_cluster(host,connection,datacenter_name)
|
||||
|
||||
expect(result).to_not be_nil
|
||||
expect(result.name).to eq(host)
|
||||
end
|
||||
|
||||
it 'should return nil if the cluster is not found' do
|
||||
expect(subject.find_cluster(missing_cluster,connection,datacenter_name)).to be_nil
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue