Add support vSphere Datastore backend for Glance
Created class for this type of glance backend Change-Id: I88478bf4ec5d9a4c65344fbdc04ac973a31f46ea
This commit is contained in:
parent
f377c0229c
commit
bb8e5301ed
|
@ -0,0 +1,83 @@
|
|||
#
|
||||
# Copyright (C) 2014 Mirantis
|
||||
#
|
||||
# Author: Steapn Rogov <srogov@mirantis.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# == Class: glance::backend::vsphere
|
||||
#
|
||||
# Setup Glance to backend images into VMWare vCenter/ESXi
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*vcenter_api_insecure*]
|
||||
# (optional) Allow to perform insecure SSL requests to vCenter/ESXi.
|
||||
# Should be a valid string boolean value
|
||||
# Defaults to 'False'
|
||||
#
|
||||
# [*vcenter_host*]
|
||||
# (required) vCenter/ESXi Server target system.
|
||||
# Should be a valid an IP address or a DNS name.
|
||||
#
|
||||
# [*vcenter_user*]
|
||||
# (required) Username for authenticating with vCenter/ESXi server.
|
||||
#
|
||||
# [*vcenter_password*]
|
||||
# (required) Password for authenticating with vCenter/ESXi server.
|
||||
#
|
||||
# [*vcenter_datacenter*]
|
||||
# (required) Inventory path to a datacenter.
|
||||
# If you want to use ESXi host as datastore,it should be "ha-datacenter".
|
||||
#
|
||||
# [*vcenter_datastore*]
|
||||
# (required) Datastore associated with the datacenter.
|
||||
#
|
||||
# [*vcenter_image_dir*]
|
||||
# (required) The name of the directory where the glance images will be stored
|
||||
# in the VMware datastore.
|
||||
#
|
||||
# [*vcenter_task_poll_interval*]
|
||||
# (optional) The interval used for polling remote tasks invoked on
|
||||
# vCenter/ESXi server.
|
||||
# Defaults to '5'
|
||||
#
|
||||
# [*vcenter_api_retry_count*]
|
||||
# (optional) Number of times VMware ESX/VC server API must be retried upon
|
||||
# connection related issues.
|
||||
# Defaults to '10'
|
||||
#
|
||||
class glance::backend::vsphere(
|
||||
$vcenter_host,
|
||||
$vcenter_user,
|
||||
$vcenter_password,
|
||||
$vcenter_datacenter,
|
||||
$vcenter_datastore,
|
||||
$vcenter_image_dir,
|
||||
$vcenter_api_insecure = 'False',
|
||||
$vcenter_task_poll_interval = '5',
|
||||
$vcenter_api_retry_count = '10',
|
||||
) {
|
||||
glance_api_config {
|
||||
'DEFAULT/default_store': value => 'vsphere';
|
||||
'DEFAULT/vmware_api_insecure': value => $vcenter_api_insecure;
|
||||
'DEFAULT/vmware_server_host': value => $vcenter_host;
|
||||
'DEFAULT/vmware_server_username': value => $vcenter_user;
|
||||
'DEFAULT/vmware_server_password': value => $vcenter_password;
|
||||
'DEFAULT/vmware_datastore_name': value => $vcenter_datastore;
|
||||
'DEFAULT/vmware_store_image_dir': value => $vcenter_image_dir;
|
||||
'DEFAULT/vmware_task_poll_interval': value => $vcenter_task_poll_interval;
|
||||
'DEFAULT/vmware_api_retry_count': value => $vcenter_api_retry_count;
|
||||
'DEFAULT/vmware_datacenter_path': value => $vcenter_datacenter;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
#
|
||||
# Copyright (C) 2014 Mirantis
|
||||
#
|
||||
# Author: Steapn Rogov <srogov@mirantis.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# Unit tests for glance::backend::vsphere class
|
||||
#
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'glance::backend::vsphere' do
|
||||
|
||||
let :pre_condition do
|
||||
'class { "glance::api": keystone_password => "pass" }'
|
||||
end
|
||||
|
||||
shared_examples_for 'glance with vsphere backend' do
|
||||
|
||||
context 'when default parameters' do
|
||||
let :params do
|
||||
{
|
||||
:vcenter_host => '10.0.0.1',
|
||||
:vcenter_user => 'root',
|
||||
:vcenter_password => '123456',
|
||||
:vcenter_datacenter => 'Datacenter',
|
||||
:vcenter_datastore => 'Datastore',
|
||||
:vcenter_image_dir => '/openstack_glance',
|
||||
}
|
||||
end
|
||||
it 'configures glance-api.conf' do
|
||||
should contain_glance_api_config('DEFAULT/default_store').with_value('vsphere')
|
||||
should contain_glance_api_config('DEFAULT/vmware_api_insecure').with_value('False')
|
||||
should contain_glance_api_config('DEFAULT/vmware_server_host').with_value('10.0.0.1')
|
||||
should contain_glance_api_config('DEFAULT/vmware_server_username').with_value('root')
|
||||
should contain_glance_api_config('DEFAULT/vmware_server_password').with_value('123456')
|
||||
should contain_glance_api_config('DEFAULT/vmware_datastore_name').with_value('Datastore')
|
||||
should contain_glance_api_config('DEFAULT/vmware_store_image_dir').with_value('/openstack_glance')
|
||||
should contain_glance_api_config('DEFAULT/vmware_task_poll_interval').with_value('5')
|
||||
should contain_glance_api_config('DEFAULT/vmware_api_retry_count').with_value('10')
|
||||
should contain_glance_api_config('DEFAULT/vmware_datacenter_path').with_value('Datacenter')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when overriding parameters' do
|
||||
let :params do
|
||||
{
|
||||
:vcenter_host => '10.0.0.1',
|
||||
:vcenter_user => 'root',
|
||||
:vcenter_password => '123456',
|
||||
:vcenter_datacenter => 'Datacenter',
|
||||
:vcenter_datastore => 'Datastore',
|
||||
:vcenter_image_dir => '/openstack_glance',
|
||||
:vcenter_api_insecure => 'True',
|
||||
:vcenter_task_poll_interval => '6',
|
||||
:vcenter_api_retry_count => '11',
|
||||
}
|
||||
end
|
||||
it 'configures glance-api.conf' do
|
||||
should contain_glance_api_config('DEFAULT/vmware_api_insecure').with_value('True')
|
||||
should contain_glance_api_config('DEFAULT/vmware_task_poll_interval').with_value('6')
|
||||
should contain_glance_api_config('DEFAULT/vmware_api_retry_count').with_value('11')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
it_configures 'glance with vsphere backend'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
it_configures 'glance with vsphere backend'
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue