1b1f5465c31c4e33eb71ff3a2f651e8f37361171
[mirror/dsa-puppet.git] / 3rdparty / modules / glance / spec / classes / glance_backend_vsphere_spec.rb
1 #
2 # Copyright (C) 2014 Mirantis
3 #
4 # Author: Steapn Rogov <srogov@mirantis.com>
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License"); you may
7 # not use this file except in compliance with the License. You may obtain
8 # a copy of the License at
9 #
10 #      http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15 # License for the specific language governing permissions and limitations
16 # under the License.
17 #
18 # Unit tests for glance::backend::vsphere class
19 #
20
21 require 'spec_helper'
22
23 describe 'glance::backend::vsphere' do
24
25   let :pre_condition do
26     'class { "glance::api": keystone_password => "pass" }'
27   end
28
29   shared_examples_for 'glance with vsphere backend' do
30
31     context 'when default parameters' do
32       let :params do
33         {
34           :vcenter_host       => '10.0.0.1',
35           :vcenter_user       => 'root',
36           :vcenter_password   => '123456',
37           :vcenter_datacenter => 'Datacenter',
38           :vcenter_datastore  => 'Datastore',
39           :vcenter_image_dir  => '/openstack_glance',
40         }
41       end
42       it 'configures glance-api.conf' do
43         should contain_glance_api_config('DEFAULT/default_store').with_value('vsphere')
44         should contain_glance_api_config('DEFAULT/vmware_api_insecure').with_value('False')
45         should contain_glance_api_config('DEFAULT/vmware_server_host').with_value('10.0.0.1')
46         should contain_glance_api_config('DEFAULT/vmware_server_username').with_value('root')
47         should contain_glance_api_config('DEFAULT/vmware_server_password').with_value('123456')
48         should contain_glance_api_config('DEFAULT/vmware_datastore_name').with_value('Datastore')
49         should contain_glance_api_config('DEFAULT/vmware_store_image_dir').with_value('/openstack_glance')
50         should contain_glance_api_config('DEFAULT/vmware_task_poll_interval').with_value('5')
51         should contain_glance_api_config('DEFAULT/vmware_api_retry_count').with_value('10')
52         should contain_glance_api_config('DEFAULT/vmware_datacenter_path').with_value('Datacenter')
53       end
54     end
55
56     context 'when overriding parameters' do
57       let :params do
58         {
59           :vcenter_host               => '10.0.0.1',
60           :vcenter_user               => 'root',
61           :vcenter_password           => '123456',
62           :vcenter_datacenter         => 'Datacenter',
63           :vcenter_datastore          => 'Datastore',
64           :vcenter_image_dir          => '/openstack_glance',
65           :vcenter_api_insecure       => 'True',
66           :vcenter_task_poll_interval => '6',
67           :vcenter_api_retry_count    => '11',
68         }
69       end
70       it 'configures glance-api.conf' do
71         should contain_glance_api_config('DEFAULT/vmware_api_insecure').with_value('True')
72         should contain_glance_api_config('DEFAULT/vmware_task_poll_interval').with_value('6')
73         should contain_glance_api_config('DEFAULT/vmware_api_retry_count').with_value('11')
74       end
75     end
76
77   end
78
79   context 'on Debian platforms' do
80     let :facts do
81       { :osfamily => 'Debian' }
82     end
83
84     it_configures 'glance with vsphere backend'
85   end
86
87   context 'on RedHat platforms' do
88     let :facts do
89       { :osfamily => 'RedHat' }
90     end
91
92     it_configures 'glance with vsphere backend'
93   end
94 end