API, Conductor, Drivers, Specs
Signed-off-by: Emilien Macchi <emilien.macchi@enovance.com>
This commit is contained in:
parent
21fe9fd4c7
commit
65faf63162
|
@ -1,6 +1,10 @@
|
|||
puppet-ironic (Work in progress)
|
||||
===================================
|
||||
|
||||
ToDo:
|
||||
- init.pp + init unit tests
|
||||
- move to Stackforge
|
||||
|
||||
#### Table of Contents
|
||||
|
||||
1. [Overview - What is the ironic module?](#overview)
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
#
|
||||
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
|
||||
#
|
||||
# Author: Emilien Macchi <emilien.macchi@enovance.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.
|
||||
#
|
||||
# Deploy Ironic on a single node
|
||||
#
|
||||
|
||||
class { 'ironic': }
|
||||
class { 'ironic::api': }
|
||||
class { 'ironic::conductor': }
|
||||
class { 'ironic::drivers::pxe': }
|
||||
class { 'ironic::drivers::ipmi': }
|
|
@ -15,8 +15,13 @@ Puppet::Type.type(:ironic_config).provide(
|
|||
'='
|
||||
end
|
||||
|
||||
def file_path
|
||||
def self.file_path
|
||||
'/etc/ironic/ironic.conf'
|
||||
end
|
||||
|
||||
# added for backwards compatibility with older versions of inifile
|
||||
def file_path
|
||||
self.class.file_path
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ Puppet::Type.newtype(:ironic_config) do
|
|||
ensurable
|
||||
|
||||
newparam(:name, :namevar => true) do
|
||||
desc 'Section/setting name to manage from ironic.conf'
|
||||
desc 'Section/setting name to manage from /etc/ironic/ironic.conf'
|
||||
newvalues(/\S+\/\S+/)
|
||||
end
|
||||
|
||||
|
@ -14,5 +14,29 @@ Puppet::Type.newtype(:ironic_config) do
|
|||
value.capitalize! if value =~ /^(true|false)$/i
|
||||
value
|
||||
end
|
||||
|
||||
def is_to_s( currentvalue )
|
||||
if resource.secret?
|
||||
return '[old secret redacted]'
|
||||
else
|
||||
return currentvalue
|
||||
end
|
||||
end
|
||||
|
||||
def should_to_s( newvalue )
|
||||
if resource.secret?
|
||||
return '[new secret redacted]'
|
||||
else
|
||||
return newvalue
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
newparam(:secret, :boolean => true) do
|
||||
desc 'Whether to hide the value from Puppet logs. Defaults to `false`.'
|
||||
|
||||
newvalues(:true, :false)
|
||||
|
||||
defaultto false
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
#
|
||||
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
|
||||
#
|
||||
# Author: Emilien Macchi <emilien.macchi@enovance.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.
|
||||
|
||||
# Configure the API service in Ironic
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*host_ip*]
|
||||
# (optional) The listen IP for the Ironic API server.
|
||||
# Should be an valid IP address
|
||||
# Defaults to '0.0.0.0'.
|
||||
#
|
||||
# [*port*]
|
||||
# (optional) The port for the Ironic API server.
|
||||
# Should be an valid port
|
||||
# Defaults to '0.0.0.0'.
|
||||
#
|
||||
# [*max_limit*]
|
||||
# (optional) The maximum number of items returned in a single response
|
||||
# from a collection resource.
|
||||
# Should be an valid interger
|
||||
# Defaults to '1000'.
|
||||
#
|
||||
|
||||
class ironic::api (
|
||||
$package_ensure = 'present',
|
||||
$enabled = true,
|
||||
$host_ip = '0.0.0.0',
|
||||
$port = '6385',
|
||||
$max_limit = '1000'
|
||||
) {
|
||||
|
||||
include ironic::params
|
||||
|
||||
Ironic_config<||> ~> Service['ironic-api']
|
||||
|
||||
# Configure ironic.conf
|
||||
ironic_config {
|
||||
'api/host_ip': value => $host_ip;
|
||||
'api/port': value => $port;
|
||||
'api/max_limit': value => $max_limit;
|
||||
}
|
||||
|
||||
# Install package
|
||||
if $::ironic::params::api_package {
|
||||
Package['ironic-api'] -> Service['ironic-api']
|
||||
Package['ironic-api'] -> Ironic_config<||>
|
||||
package { 'ironic-api':
|
||||
ensure => $package_ensure,
|
||||
name => $::ironic::params::api_package,
|
||||
}
|
||||
}
|
||||
|
||||
if $enabled {
|
||||
$ensure = 'running'
|
||||
} else {
|
||||
$ensure = 'stopped'
|
||||
}
|
||||
|
||||
# Manage service
|
||||
service { 'ironic-api':
|
||||
ensure => $ensure,
|
||||
name => $::ironic::params::api_service,
|
||||
enable => $enabled,
|
||||
hasstatus => true,
|
||||
require => Class['api'],
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
#
|
||||
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
|
||||
#
|
||||
# Author: Emilien Macchi <emilien.macchi@enovance.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.
|
||||
|
||||
# Configure the conductor service in Ironic
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*max_time_interval*]
|
||||
# (optional) Maximum time, in seconds, since the last check-in of a conductor.
|
||||
# Should be an interger value
|
||||
# Defaults to '120'.
|
||||
#
|
||||
|
||||
class ironic::conductor (
|
||||
$package_ensure = 'present',
|
||||
$enabled = true,
|
||||
$max_time_interval = '120'
|
||||
) {
|
||||
|
||||
include ironic::params
|
||||
|
||||
Ironic_config<||> ~> Service['ironic-conductor']
|
||||
|
||||
# Configure ironic.conf
|
||||
ironic_config {
|
||||
'conductor/max_time_interval': value => $max_time_interval;
|
||||
}
|
||||
|
||||
# Install package
|
||||
if $::ironic::params::conductor_package {
|
||||
Package['ironic-conductor'] -> Service['ironic-conductor']
|
||||
Package['ironic-conductor'] -> Ironic_config<||>
|
||||
package { 'ironic-conductor':
|
||||
ensure => $package_ensure,
|
||||
name => $::ironic::params::conductor_package,
|
||||
}
|
||||
}
|
||||
|
||||
if $enabled {
|
||||
$ensure = 'running'
|
||||
} else {
|
||||
$ensure = 'stopped'
|
||||
}
|
||||
|
||||
# Manage service
|
||||
service { 'ironic-conductor':
|
||||
ensure => $ensure,
|
||||
name => $::ironic::params::conductor_service,
|
||||
enable => $enabled,
|
||||
hasstatus => true,
|
||||
require => Class['conductor'],
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
#
|
||||
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
|
||||
#
|
||||
# Author: Emilien Macchi <emilien.macchi@enovance.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.
|
||||
|
||||
# Configure the IPMI driver in Ironic
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*retry_timeout*]
|
||||
# (optional) Maximum time in seconds to retry IPMI operations.
|
||||
# Should be an interger value
|
||||
# Defaults to '10'.
|
||||
#
|
||||
|
||||
class ironic::drivers::ipmi (
|
||||
$retry_timeout = '10'
|
||||
) {
|
||||
|
||||
# Configure ironic.conf
|
||||
ironic_config {
|
||||
'ipmi/retry_timeout': value => $retry_timeout;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
#
|
||||
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
|
||||
#
|
||||
# Author: Emilien Macchi <emilien.macchi@enovance.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.
|
||||
|
||||
# Configure the PXE driver in Ironic
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*deploy_kernel*]
|
||||
# (optional) Default kernel image ID used in deployment phase.
|
||||
# Should be an valid id
|
||||
# Defaults to undef.
|
||||
#
|
||||
# [*deploy_ramdisk*]
|
||||
# (optional) Default kernel image ID used in deployment phase.
|
||||
# Should be an valid id
|
||||
# Defaults to undef.
|
||||
#
|
||||
# [*pxe_append_params*]
|
||||
# (optional) Additional append parameters for baremetal PXE boot.
|
||||
# Should be valid pxe parameters
|
||||
# Defaults to 'nofb nomodeset vga=normal'.
|
||||
#
|
||||
# [*pxe_config_template*]
|
||||
# (optional) Template file for PXE configuration.
|
||||
# Should be an valid template file
|
||||
# Defaults to '$pybasedir/drivers/modules/pxe_config.template'.
|
||||
#
|
||||
# [*pxe_deploy_timeout*]
|
||||
# (optional) Timeout for PXE deployments.
|
||||
# Should be an valid integer
|
||||
# Defaults to '0' for unlimited.
|
||||
#
|
||||
# [*pxe_config_template*]
|
||||
# (optional) Template file for PXE configuration.
|
||||
# Should be an valid template file
|
||||
# Defaults to undef.
|
||||
#
|
||||
# [*pxe_config_template*]
|
||||
# (optional) Template file for PXE configuration.
|
||||
# Should be an valid template file
|
||||
# Defaults to undef.
|
||||
#
|
||||
# [*pxe_config_template*]
|
||||
# (optional) Template file for PXE configuration.
|
||||
# Should be an valid template file
|
||||
# Defaults to undef.
|
||||
#
|
||||
# [*tftp_server*]
|
||||
# (optional) IP address of Ironic compute node's tftp server.
|
||||
# Should be an valid IP address
|
||||
# Defaults to '$my_ip'.
|
||||
#
|
||||
# [*tftp_root*]
|
||||
# (optional) Ironic compute node's tftp root path.
|
||||
# Should be an valid path
|
||||
# Defaults to '/tftpboot'.
|
||||
#
|
||||
# [*images_path*]
|
||||
# (optional) Directory where images are stored on disk.
|
||||
# Should be an valid directory
|
||||
# Defaults to '/tftpboot'.
|
||||
#
|
||||
# [*tftp_master_path*]
|
||||
# (optional) Directory where master tftp images are stored on disk.
|
||||
# Should be an valid directory
|
||||
# Defaults to '/tftpboot/master_images'.
|
||||
#
|
||||
# [*instance_master_path*]
|
||||
# (optional) Directory where master tftp images are stored on disk.
|
||||
# Should be an valid directory
|
||||
# Defaults to '/var/lib/ironic/master_images'.
|
||||
#
|
||||
|
||||
class ironic::drivers::pxe (
|
||||
$deploy_kernel = undef,
|
||||
$deploy_ramdisk = undef,
|
||||
$pxe_append_params = 'nofb nomodeset vga=normal',
|
||||
$pxe_config_template = '$pybasedir/drivers/modules/pxe_config.template',
|
||||
$pxe_deploy_timeout = '0',
|
||||
$tftp_server = '$my_ip',
|
||||
$tftp_root = '/tftpboot',
|
||||
$images_path = '/var/lib/ironic/images/',
|
||||
$tftp_master_path = '/tftpboot/master_images',
|
||||
$instance_master_path = '/var/lib/ironic/master_images',
|
||||
) {
|
||||
|
||||
# Configure ironic.conf
|
||||
ironic_config {
|
||||
'pxe/pxe_append_params': value => $pxe_append_params;
|
||||
'pxe/pxe_config_template': value => $pxe_config_template;
|
||||
'pxe/pxe_deploy_timeout': value => $pxe_deploy_timeout;
|
||||
'pxe/tftp_server': value => $tftp_server;
|
||||
'pxe/tftp_root': value => $tftp_root;
|
||||
'pxe/images_path': value => $images_path;
|
||||
'pxe/tftp_master_path': value => $tftp_master_path;
|
||||
'pxe/instance_master_path': value => $instance_master_path;
|
||||
}
|
||||
|
||||
if $deploy_kernel {
|
||||
ironic_config {
|
||||
'pxe/deploy_kernel': value => $deploy_kernel;
|
||||
}
|
||||
}
|
||||
|
||||
if $deploy_ramdisk {
|
||||
ironic_config {
|
||||
'pxe/deploy_ramdisk': value => $deploy_ramdisk;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -14,8 +14,10 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
# Ironic
|
||||
#
|
||||
# ironic
|
||||
# === Parameters
|
||||
#
|
||||
|
||||
class ironic (
|
||||
|
|
|
@ -40,6 +40,6 @@ class ironic::params {
|
|||
default: {
|
||||
fail("Unsupported osfamily ${::osfamily}")
|
||||
}
|
||||
} # Case $::osfamily
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
#
|
||||
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
|
||||
#
|
||||
# Author: Emilien Macchi <emilien.macchi@enovance.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 ironic::api class
|
||||
#
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'ironic::api' do
|
||||
|
||||
let :default_params do
|
||||
{ :package_ensure => 'present',
|
||||
:enabled => true,
|
||||
:port => '6385',
|
||||
:max_limit => '1000',
|
||||
:host_ip => '0.0.0.0' }
|
||||
end
|
||||
|
||||
let :params do
|
||||
{}
|
||||
end
|
||||
|
||||
shared_examples_for 'ironic api' do
|
||||
let :p do
|
||||
default_params.merge(params)
|
||||
end
|
||||
|
||||
it { should include_class('ironic::params') }
|
||||
|
||||
it 'installs ironic api package' do
|
||||
if platform_params.has_key?(:api_package)
|
||||
should contain_package('ironic-api').with(
|
||||
:name => platform_params[:api_package],
|
||||
:ensure => p[:package_ensure]
|
||||
)
|
||||
should contain_package('ironic-api').with_before(/Ironic_config\[.+\]/)
|
||||
should contain_package('ironic-api').with_before(/Service\[ironic-api\]/)
|
||||
end
|
||||
end
|
||||
|
||||
it 'ensure ironic api service is running' do
|
||||
should contain_service('ironic-api').with('hasstatus' => true)
|
||||
end
|
||||
|
||||
it 'configures ironic.conf' do
|
||||
should contain_ironic_config('api/port').with_value(p[:port])
|
||||
should contain_ironic_config('api/host_ip').with_value(p[:host_ip])
|
||||
should contain_ironic_config('api/max_limit').with_value(p[:max_limit])
|
||||
|
||||
end
|
||||
|
||||
context 'when overriding parameters' do
|
||||
before :each do
|
||||
params.merge!(:port => '3430')
|
||||
params.merge!(:host_ip => '127.0.0.1')
|
||||
params.merge!(:max_limit => '10')
|
||||
end
|
||||
it 'should replace default parameter with new value' do
|
||||
should contain_ironic_config('api/port').with_value(p[:port])
|
||||
should contain_ironic_config('api/host_ip').with_value(p[:host_ip])
|
||||
should contain_ironic_config('api/max_limit').with_value(p[:max_limit])
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :api_package => 'ironic-api',
|
||||
:api_service => 'ironic-api' }
|
||||
end
|
||||
|
||||
it_configures 'ironic api'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :api_service => 'ironic-api' }
|
||||
end
|
||||
|
||||
it_configures 'ironic api'
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,98 @@
|
|||
#
|
||||
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
|
||||
#
|
||||
# Author: Emilien Macchi <emilien.macchi@enovance.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 ironic::conductor class
|
||||
#
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'ironic::conductor' do
|
||||
|
||||
let :default_params do
|
||||
{ :package_ensure => 'present',
|
||||
:enabled => true,
|
||||
:max_time_interval => '120' }
|
||||
end
|
||||
|
||||
let :params do
|
||||
{}
|
||||
end
|
||||
|
||||
shared_examples_for 'ironic conductor' do
|
||||
let :p do
|
||||
default_params.merge(params)
|
||||
end
|
||||
|
||||
it { should include_class('ironic::params') }
|
||||
|
||||
it 'installs ironic conductor package' do
|
||||
if platform_params.has_key?(:conductor_package)
|
||||
should contain_package('ironic-conductor').with(
|
||||
:name => platform_params[:conductor_package],
|
||||
:ensure => p[:package_ensure]
|
||||
)
|
||||
should contain_package('ironic-conductor').with_before(/Ironic_config\[.+\]/)
|
||||
should contain_package('ironic-conductor').with_before(/Service\[ironic-conductor\]/)
|
||||
end
|
||||
end
|
||||
|
||||
it 'ensure ironic conductor service is running' do
|
||||
should contain_service('ironic-conductor').with('hasstatus' => true)
|
||||
end
|
||||
|
||||
it 'configures ironic.conf' do
|
||||
should contain_ironic_config('conductor/max_time_interval').with_value(p[:max_time_interval])
|
||||
|
||||
end
|
||||
|
||||
context 'when overriding parameters' do
|
||||
before :each do
|
||||
params.merge!(:max_time_interval => '50')
|
||||
end
|
||||
it 'should replace default parameter with new value' do
|
||||
should contain_ironic_config('conductor/max_time_interval').with_value(p[:max_time_interval])
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :conductor_package => 'ironic-conductor',
|
||||
:conductor_service => 'ironic-conductor' }
|
||||
end
|
||||
|
||||
it_configures 'ironic conductor'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :conductor_service => 'ironic-conductor' }
|
||||
end
|
||||
|
||||
it_configures 'ironic conductor'
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,69 @@
|
|||
#
|
||||
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
|
||||
#
|
||||
# Author: Emilien Macchi <emilien.macchi@enovance.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 ironic::drivers::ipmi class
|
||||
#
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'ironic::drivers::ipmi' do
|
||||
|
||||
let :default_params do
|
||||
{:retry_timeout => '10' }
|
||||
end
|
||||
|
||||
let :params do
|
||||
{}
|
||||
end
|
||||
|
||||
shared_examples_for 'ironic ipmi driver' do
|
||||
let :p do
|
||||
default_params.merge(params)
|
||||
end
|
||||
|
||||
it 'configures ironic.conf' do
|
||||
should contain_ironic_config('ipmi/retry_timeout').with_value(p[:retry_timeout])
|
||||
end
|
||||
|
||||
context 'when overriding parameters' do
|
||||
before :each do
|
||||
params.merge!(:retry_timeout => '50')
|
||||
end
|
||||
it 'should replace default parameter with new value' do
|
||||
should contain_ironic_config('ipmi/retry_timeout').with_value(p[:retry_timeout])
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
it_configures 'ironic ipmi driver'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
it_configures 'ironic ipmi driver'
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,101 @@
|
|||
#
|
||||
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
|
||||
#
|
||||
# Author: Emilien Macchi <emilien.macchi@enovance.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 ironic::drivers::pxe class
|
||||
#
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'ironic::drivers::pxe' do
|
||||
|
||||
let :default_params do
|
||||
{:pxe_append_params => 'nofb nomodeset vga=normal',
|
||||
:pxe_config_template => '$pybasedir/drivers/modules/pxe_config.template',
|
||||
:pxe_deploy_timeout => '0',
|
||||
:tftp_server => '$my_ip',
|
||||
:tftp_root => '/tftpboot',
|
||||
:images_path => '/var/lib/ironic/images/',
|
||||
:tftp_master_path => '/tftpboot/master_images',
|
||||
:instance_master_path => '/var/lib/ironic/master_images'}
|
||||
end
|
||||
|
||||
let :params do
|
||||
{}
|
||||
end
|
||||
|
||||
shared_examples_for 'ironic pxe driver' do
|
||||
let :p do
|
||||
default_params.merge(params)
|
||||
end
|
||||
|
||||
it 'configures ironic.conf' do
|
||||
should contain_ironic_config('pxe/pxe_append_params').with_value(p[:pxe_append_params])
|
||||
should contain_ironic_config('pxe/pxe_config_template').with_value(p[:pxe_config_template])
|
||||
should contain_ironic_config('pxe/pxe_deploy_timeout').with_value(p[:pxe_deploy_timeout])
|
||||
should contain_ironic_config('pxe/tftp_server').with_value(p[:tftp_server])
|
||||
should contain_ironic_config('pxe/tftp_root').with_value(p[:tftp_root])
|
||||
should contain_ironic_config('pxe/images_path').with_value(p[:images_path])
|
||||
should contain_ironic_config('pxe/tftp_master_path').with_value(p[:tftp_master_path])
|
||||
should contain_ironic_config('pxe/instance_master_path').with_value(p[:instance_master_path])
|
||||
end
|
||||
|
||||
context 'when overriding parameters' do
|
||||
before :each do
|
||||
params.merge!(:deploy_kernel => 'foo')
|
||||
params.merge!(:deploy_ramdisk => 'bar')
|
||||
params.merge!(:pxe_append_params => 'foo')
|
||||
params.merge!(:pxe_config_template => 'bar')
|
||||
params.merge!(:pxe_deploy_timeout => '40')
|
||||
params.merge!(:tftp_server => '192.168.0.1')
|
||||
params.merge!(:tftp_root => '/mnt/ftp')
|
||||
params.merge!(:images_path => '/mnt/images')
|
||||
params.merge!(:tftp_master_path => '/mnt/master_images')
|
||||
params.merge!(:instance_master_path => '/mnt/ironic/master_images')
|
||||
end
|
||||
it 'should replace default parameter with new value' do
|
||||
should contain_ironic_config('pxe/deploy_kernel').with_value(p[:deploy_kernel])
|
||||
should contain_ironic_config('pxe/deploy_ramdisk').with_value(p[:deploy_ramdisk])
|
||||
should contain_ironic_config('pxe/pxe_append_params').with_value(p[:pxe_append_params])
|
||||
should contain_ironic_config('pxe/pxe_config_template').with_value(p[:pxe_config_template])
|
||||
should contain_ironic_config('pxe/pxe_deploy_timeout').with_value(p[:pxe_deploy_timeout])
|
||||
should contain_ironic_config('pxe/tftp_server').with_value(p[:tftp_server])
|
||||
should contain_ironic_config('pxe/tftp_root').with_value(p[:tftp_root])
|
||||
should contain_ironic_config('pxe/images_path').with_value(p[:images_path])
|
||||
should contain_ironic_config('pxe/tftp_master_path').with_value(p[:tftp_master_path])
|
||||
should contain_ironic_config('pxe/instance_master_path').with_value(p[:instance_master_path])
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
it_configures 'ironic pxe driver'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
it_configures 'ironic pxe driver'
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue