Add support for VMDK driver

The patch adds support for VMware vmdk cinder driver. It also
supports configuring the driver for multi-backend scenarios.

implements blueprint support-vmdk-driver

Change-Id: I3f50f9974100ceab2a991f692022dd918f2e4445
This commit is contained in:
Sabari Kumar Murugesan 2013-12-04 12:29:02 -08:00 committed by Gerrit Code Review
parent bb977b42d5
commit 14be689255
6 changed files with 375 additions and 0 deletions

88
manifests/backend/vmdk.pp Normal file
View File

@ -0,0 +1,88 @@
# == define: cinder::backend::vmdk
#
# Configure the VMware VMDK driver for cinder.
#
# === Parameters
#
# [*host_ip*]
# The IP address of the VMware vCenter server.
#
# [*host_username*]
# The username for connection to VMware vCenter server.
#
# [*host_password*]
# The password for connection to VMware vCenter server.
#
# [*volume_backend_name*]
# Used to set the volume_backend_name in multiple backends.
# Defaults to $name as passed in the title.
#
# [*api_retry_count*]
# (optional) The number of times we retry on failures,
# e.g., socket error, etc.
# Defaults to 10.
#
# [*$max_object_retrieval*]
# (optional) The maximum number of ObjectContent data objects that should
# be returned in a single result. A positive value will cause
# the operation to suspend the retrieval when the count of
# objects reaches the specified maximum. The server may still
# limit the count to something less than the configured value.
# Any remaining objects may be retrieved with additional requests.
# Defaults to 100.
#
# [*task_poll_interval*]
# (optional) The interval in seconds used for polling of remote tasks.
# Defaults to 5.
#
# [*image_transfer_timeout_secs*]
# (optional) The timeout in seconds for VMDK volume transfer between Cinder and Glance.
# Defaults to 7200.
#
# [*wsdl_location*]
# (optional) VIM Service WSDL Location e.g
# http://<server>/vimService.wsdl. Optional over-ride to
# default location for bug work-arounds.
# Defaults to None.
#
# [*volume_folder*]
# (optional) The name for the folder in the VC datacenter that will contain cinder volumes.
# Defaults to 'cinder-volumes'.
#
define cinder::backend::vmdk (
$host_ip,
$host_username,
$host_password,
$volume_backend_name = $name,
$volume_folder = 'cinder-volumes',
$api_retry_count = 10,
$max_object_retrieval = 100,
$task_poll_interval = 5,
$image_transfer_timeout_secs = 7200,
$wsdl_location = undef
) {
cinder_config {
"${name}/volume_backend_name": value => $volume_backend_name;
"${name}/volume_driver": value => 'cinder.volume.drivers.vmware.vmdk.VMwareVcVmdkDriver';
"${name}/vmware_host_ip": value => $host_ip;
"${name}/vmware_host_username": value => $host_username;
"${name}/vmware_host_password": value => $host_password;
"${name}/vmware_volume_folder": value => $volume_folder;
"${name}/vmware_api_retry_count": value => $api_retry_count;
"${name}/vmware_max_object_retrieval": value => $max_object_retrieval;
"${name}/vmware_task_poll_interval": value => $task_poll_interval;
"${name}/vmware_image_transfer_timeout_secs": value => $image_transfer_timeout_secs;
}
if $wsdl_location {
cinder_config {
"${name}/vmware_wsdl_location": value => $wsdl_location;
}
}
package { 'suds':
ensure => present,
provider => pip
}
}

53
manifests/vmware.pp Normal file
View File

@ -0,0 +1,53 @@
# ==Define: cinder::vmware
#
# Creates vmdk specific disk file type & clone type.
#
# === Parameters
#
# [*os_password*]
# (required) The keystone tenant:username password.
#
# [*os_tenant_name*]
# (optional) The keystone tenant name. Defaults to 'admin'.
#
# [*os_username*]
# (optional) The keystone user name. Defaults to 'admin.
#
# [*os_auth_url*]
# (optional) The keystone auth url. Defaults to 'http://127.0.0.1:5000/v2.0/'.
#
class cinder::vmware (
$os_password,
$os_tenant_name = 'admin',
$os_username = 'admin',
$os_auth_url = 'http://127.0.0.1:5000/v2.0/'
) {
Cinder::Type {
os_password => $os_password,
os_tenant_name => $os_tenant_name,
os_username => $os_username,
os_auth_url => $os_auth_url
}
cinder::type {'vmware-thin':
set_value => 'thin',
set_key => 'vmware:vmdk_type'
}
cinder::type {'vmware-thick':
set_value => 'thick',
set_key => 'vmware:vmdk_type'
}
cinder::type {'vmware-eagerZeroedThick':
set_value => 'eagerZeroedThick',
set_key => 'vmware:vmdk_type'
}
cinder::type {'vmware-full':
set_value => 'full',
set_key => 'vmware:clone_type'
}
cinder::type {'vmware-linked':
set_value => 'linked',
set_key => 'vmware:clone_type'
}
}

82
manifests/volume/vmdk.pp Normal file
View File

@ -0,0 +1,82 @@
# == define: cinder::volume::vmdk
#
# Configure the VMware VMDK driver for cinder.
#
# === Parameters
#
# [*host_ip*]
# The IP address of the VMware vCenter server.
#
# [*host_username*]
# The username for connection to VMware vCenter server.
#
# [*host_password*]
# The password for connection to VMware vCenter server.
#
# [*api_retry_count*]
# (optional) The number of times we retry on failures,
# e.g., socket error, etc.
# Defaults to 10.
#
# [*max_object_retrieval*]
# (optional) The maximum number of ObjectContent data objects that should
# be returned in a single result. A positive value will cause
# the operation to suspend the retrieval when the count of
# objects reaches the specified maximum. The server may still
# limit the count to something less than the configured value.
# Any remaining objects may be retrieved with additional requests.
# Defaults to 100.
#
# [*task_poll_interval*]
# (optional) The interval in seconds used for polling of remote tasks.
# Defaults to 5.
#
# [*image_transfer_timeout_secs*]
# (optional) The timeout in seconds for VMDK volume transfer between Cinder and Glance.
# Defaults to 7200.
#
# [*wsdl_location*]
# (optional) VIM Service WSDL Location e.g
# http://<server>/vimService.wsdl. Optional over-ride to
# default location for bug work-arounds.
# Defaults to None.
#
# [*volume_folder*]
# (optional) The name for the folder in the VC datacenter that will contain cinder volumes.
# Defaults to 'cinder-volumes'.
#
class cinder::volume::vmdk(
$host_ip,
$host_username,
$host_password,
$volume_folder = 'cinder-volumes',
$api_retry_count = 10,
$max_object_retrieval = 100,
$task_poll_interval = 5,
$image_transfer_timeout_secs = 7200,
$wsdl_location = undef
) {
cinder_config {
'DEFAULT/volume_driver': value => 'cinder.volume.drivers.vmware.vmdk.VMwareVcVmdkDriver';
'DEFAULT/vmware_host_ip': value => $host_ip;
'DEFAULT/vmware_host_username': value => $host_username;
'DEFAULT/vmware_host_password': value => $host_password;
'DEFAULT/vmware_volume_folder': value => $volume_folder;
'DEFAULT/vmware_api_retry_count': value => $api_retry_count;
'DEFAULT/vmware_max_object_retrieval': value => $max_object_retrieval;
'DEFAULT/vmware_task_poll_interval': value => $task_poll_interval;
'DEFAULT/vmware_image_transfer_timeout_secs': value => $image_transfer_timeout_secs;
}
if $wsdl_location {
cinder_config {
'DEFAULT/vmware_wsdl_location': value => $wsdl_location;
}
}
package { 'suds':
ensure => present,
provider => pip
}
}

View File

@ -0,0 +1,35 @@
require 'spec_helper'
describe 'cinder::vmware' do
let :params do
{:os_password => 'asdf',
:os_tenant_name => 'admin',
:os_username => 'admin',
:os_auth_url => 'http://127.127.127.1:5000/v2.0/'}
end
describe 'with defaults' do
it 'should create vmware special types' do
should contain_cinder__type('vmware-thin').with(
:set_key => 'vmware:vmdk_type',
:set_value => 'thin')
should contain_cinder__type('vmware-thick').with(
:set_key => 'vmware:vmdk_type',
:set_value => 'thick')
should contain_cinder__type('vmware-eagerZeroedThick').with(
:set_key => 'vmware:vmdk_type',
:set_value => 'eagerZeroedThick')
should contain_cinder__type('vmware-full').with(
:set_key => 'vmware:clone_type',
:set_value => 'full')
should contain_cinder__type('vmware-linked').with(
:set_key => 'vmware:clone_type',
:set_value => 'linked')
end
end
end

View File

@ -0,0 +1,57 @@
require 'spec_helper'
describe 'cinder::volume::vmdk' do
let :params do
{
:host_ip => '172.16.16.16',
:host_password => 'asdf',
:host_username => 'user'
}
end
let :optional_params do
{
:volume_folder => 'cinder-volume-folder',
:api_retry_count => 5,
:max_object_retrieval => 200,
:task_poll_interval => 10,
:image_transfer_timeout_secs => 3600,
:wsdl_location => 'http://127.0.0.1:8080/vmware/SDK/wsdl/vim25/vimService.wsdl'
}
end
it 'should configure vmdk driver in cinder.conf' do
should contain_cinder_config('DEFAULT/volume_driver').with_value('cinder.volume.drivers.vmware.vmdk.VMwareVcVmdkDriver')
should contain_cinder_config('DEFAULT/vmware_host_ip').with_value(params[:host_ip])
should contain_cinder_config('DEFAULT/vmware_host_username').with_value(params[:host_username])
should contain_cinder_config('DEFAULT/vmware_host_password').with_value(params[:host_password])
should contain_cinder_config('DEFAULT/vmware_volume_folder').with_value('cinder-volumes')
should contain_cinder_config('DEFAULT/vmware_api_retry_count').with_value(10)
should contain_cinder_config('DEFAULT/vmware_max_object_retrieval').with_value(100)
should contain_cinder_config('DEFAULT/vmware_task_poll_interval').with_value(5)
should contain_cinder_config('DEFAULT/vmware_image_transfer_timeout_secs').with_value(7200)
should_not contain_cinder_config('DEFAULT/vmware_wsdl_location')
end
it 'installs vmdk driver with pip' do
should contain_package('suds').with(
:ensure => 'present',
:provider => 'pip')
end
context 'with optional parameters' do
before :each do
params.merge!(optional_params)
end
it 'should configure vmdk driver in cinder.conf' do
should contain_cinder_config('DEFAULT/vmware_volume_folder').with_value(params[:volume_folder])
should contain_cinder_config('DEFAULT/vmware_api_retry_count').with_value(params[:api_retry_count])
should contain_cinder_config('DEFAULT/vmware_max_object_retrieval').with_value(params[:max_object_retrieval])
should contain_cinder_config('DEFAULT/vmware_task_poll_interval').with_value(params[:task_poll_interval])
should contain_cinder_config('DEFAULT/vmware_image_transfer_timeout_secs').with_value(params[:image_transfer_timeout_secs])
should contain_cinder_config('DEFAULT/vmware_wsdl_location').with_value(params[:wsdl_location])
end
end
end

View File

@ -0,0 +1,60 @@
require 'spec_helper'
describe 'cinder::backend::vmdk' do
let (:title) { 'hippo' }
let :params do
{
:host_ip => '172.16.16.16',
:host_password => 'asdf',
:host_username => 'user'
}
end
let :optional_params do
{
:volume_folder => 'cinder-volume-folder',
:api_retry_count => 5,
:max_object_retrieval => 200,
:task_poll_interval => 10,
:image_transfer_timeout_secs => 3600,
:wsdl_location => 'http://127.0.0.1:8080/vmware/SDK/wsdl/vim25/vimService.wsdl'
}
end
it 'should configure vmdk driver in cinder.conf' do
should contain_cinder_config('hippo/volume_backend_name').with_value('hippo')
should contain_cinder_config('hippo/volume_driver').with_value('cinder.volume.drivers.vmware.vmdk.VMwareVcVmdkDriver')
should contain_cinder_config('hippo/vmware_host_ip').with_value(params[:host_ip])
should contain_cinder_config('hippo/vmware_host_username').with_value(params[:host_username])
should contain_cinder_config('hippo/vmware_host_password').with_value(params[:host_password])
should contain_cinder_config('hippo/vmware_volume_folder').with_value('cinder-volumes')
should contain_cinder_config('hippo/vmware_api_retry_count').with_value(10)
should contain_cinder_config('hippo/vmware_max_object_retrieval').with_value(100)
should contain_cinder_config('hippo/vmware_task_poll_interval').with_value(5)
should contain_cinder_config('hippo/vmware_image_transfer_timeout_secs').with_value(7200)
should_not contain_cinder_config('hippo/vmware_wsdl_location')
end
it 'installs vmdk driver with pip' do
should contain_package('suds').with(
:ensure => 'present',
:provider => 'pip')
end
context 'with optional parameters' do
before :each do
params.merge!(optional_params)
end
it 'should configure vmdk driver in cinder.conf' do
should contain_cinder_config('hippo/vmware_volume_folder').with_value(params[:volume_folder])
should contain_cinder_config('hippo/vmware_api_retry_count').with_value(params[:api_retry_count])
should contain_cinder_config('hippo/vmware_max_object_retrieval').with_value(params[:max_object_retrieval])
should contain_cinder_config('hippo/vmware_task_poll_interval').with_value(params[:task_poll_interval])
should contain_cinder_config('hippo/vmware_image_transfer_timeout_secs').with_value(params[:image_transfer_timeout_secs])
should contain_cinder_config('hippo/vmware_wsdl_location').with_value(params[:wsdl_location])
end
end
end