Add octavia::client class

This patch adds new class octavia::client to manage client,
note that it only supports Debian and Ubuntu, b/c there is
no available rpm package in CentOS currently.

Change-Id: I8f44676a3923702cfdaffa3a0aee3f84074321d1
This commit is contained in:
Xingchao Yu 2017-11-02 09:03:43 +08:00
parent aec818f1ea
commit fc7dbda80c
4 changed files with 79 additions and 0 deletions

26
manifests/client.pp Normal file
View File

@ -0,0 +1,26 @@
# == Class: octavia::client
#
# Installs the octavia python library.
#
# === Parameters
#
# [*ensure*]
# (Optional) Ensure state for package.
#
class octavia::client (
$ensure = 'present'
) {
include ::octavia::deps
include ::octavia::params
if $::octavia::params::client_package_name {
package { 'python-octaviaclient':
ensure => $ensure,
name => $::octavia::params::client_package_name,
tag => 'openstack',
}
} else {
fail("There is no avaiable client package in osfamily: ${::osfamily}.")
}
}

View File

@ -14,6 +14,7 @@ class octavia::params {
$worker_package_name = 'openstack-octavia-worker'
$health_manager_package_name = 'openstack-octavia-health-manager'
$housekeeping_package_name = 'openstack-octavia-housekeeping'
$client_package_name = undef
}
'Debian': {
$common_package_name = 'octavia-common'
@ -21,6 +22,7 @@ class octavia::params {
$worker_package_name = 'octavia-worker'
$health_manager_package_name = 'octavia-health-manager'
$housekeeping_package_name = 'octavia-housekeeping'
$client_package_name = 'python-octaviaclient'
}
default: {
fail("Unsupported osfamily: ${::osfamily} operatingsystem")

View File

@ -0,0 +1,3 @@
---
features:
- Add support of configuring octavia client.

View File

@ -0,0 +1,48 @@
require 'spec_helper'
describe 'octavia::client' do
let :params do
{}
end
let :default_params do
{ :package_ensure => 'present' }
end
shared_examples_for 'octavia client' do
let :p do
default_params.merge(params)
end
it { is_expected.to contain_class('octavia::params') }
it 'installs octavia client package' do
is_expected.to contain_package('python-octaviaclient').with(
:name => 'python-octaviaclient',
:ensure => p[:package_ensure],
:tag => 'openstack'
)
end
end
on_supported_os({
:supported_os =>
[
{ 'operatingsystem' => 'Ubuntu',
'operatingsystemrelease' => [ '16.04' ] },
{ 'operatingsystem' => 'Debian',
'operatingsystemrelease' => [ '8' ] }
]
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'octavia client'
end
end
end