Merge "Update m1.micro flavor creation"

This commit is contained in:
Jenkins 2016-07-21 11:08:42 +00:00 committed by Gerrit Code Review
commit c020c378b8
8 changed files with 276 additions and 122 deletions

View File

@ -6,6 +6,8 @@
condition:
yaql_exp: >
changedAny(('primary-controller' in $.roles), $.quantum)
cross-depends:
- name: /(primary-)?openstack-controller/
parameters:
puppet_manifest: /etc/puppet/modules/openstack_tasks/examples/roles/controller.pp
puppet_modules: /etc/puppet/modules

View File

@ -340,75 +340,6 @@ class openstack_tasks::openstack_controller::openstack_controller {
'DEFAULT/force_raw_images': value => $nova_hash['force_raw_images'];
}
if $primary_controller {
$haproxy_stats_url = "http://${management_vip}:10000/;csv"
$nova_endpoint = hiera('nova_endpoint', $management_vip)
$nova_internal_protocol = get_ssl_property($ssl_hash, {}, 'nova', 'internal', 'protocol', 'http')
$nova_internal_endpoint = get_ssl_property($ssl_hash, {}, 'nova', 'internal', 'hostname', [$nova_endpoint])
$nova_url = "${nova_internal_protocol}://${nova_internal_endpoint}:8774"
$lb_defaults = { 'provider' => 'haproxy', 'url' => $haproxy_stats_url }
if $external_lb {
$lb_backend_provider = 'http'
$lb_url = $nova_url
}
$lb_hash = {
'nova-api' => {
name => 'nova-api',
provider => $lb_backend_provider,
url => $lb_url
}
}
::osnailyfacter::wait_for_backend {'nova-api':
lb_hash => $lb_hash,
lb_defaults => $lb_defaults
}
Openstack::Ha::Haproxy_service <| |> -> Haproxy_backend_status <| |>
Class['::nova::api'] -> ::Osnailyfacter::Wait_for_backend['nova-api']
::Osnailyfacter::Wait_for_backend['nova-api'] -> Exec<| title == 'create-m1.micro-flavor' |>
::Osnailyfacter::Wait_for_backend['nova-api'] -> Nova_floating <| |>
Class['::osnailyfacter::wait_for_keystone_backends'] -> Exec<| title == 'create-m1.micro-flavor' |>
Class['::osnailyfacter::wait_for_keystone_backends'] -> Nova_floating <| |>
class {"::osnailyfacter::wait_for_keystone_backends":}
exec { 'create-m1.micro-flavor' :
path => '/sbin:/usr/sbin:/bin:/usr/bin',
environment => [
"OS_TENANT_NAME=${keystone_tenant}",
"OS_PROJECT_NAME=${keystone_tenant}",
"OS_USERNAME=${keystone_user}",
"OS_PASSWORD=${nova_hash['user_password']}",
"OS_AUTH_URL=${internal_auth_protocol}://${internal_auth_address}:5000/v2.0/",
'OS_ENDPOINT_TYPE=internalURL',
"OS_REGION_NAME=${region}",
"NOVA_ENDPOINT_TYPE=internalURL",
],
command => 'bash -c "nova flavor-create --is-public true m1.micro auto 64 0 1"',
#FIXME(mattymo): Upstream bug PUP-2299 for retries in unless/onlyif
# Retry nova-flavor list until it exits 0, then exit with grep status,
# finally exit 1 if tries exceeded
# lint:ignore:single_quote_string_with_variables
unless => 'bash -c \'for tries in {1..10}; do
nova flavor-list | grep m1.micro;
status=("${PIPESTATUS[@]}");
(( ! status[0] )) && exit "${status[1]}";
sleep 2;
done; exit 1\'',
# lint:endignore
tries => 10,
try_sleep => 2,
require => Class['::nova'],
}
}
nova_config {
'DEFAULT/teardown_unused_network_gateway': value => 'True'
}

View File

@ -10,6 +10,23 @@ class openstack_tasks::roles::controller {
ensure => 'installed',
name => 'cirros-testvm',
}
# create m1.micro flavor for OSTF
include ::osnailyfacter::wait_for_keystone_backends
class { '::osnailyfacter::wait_for_nova_backends':
backends => ['nova-api']
}
nova_flavor { 'm1.micro':
ensure => present,
ram => 64,
disk => 0,
vcpus => 1,
}
Class['::osnailyfacter::wait_for_keystone_backends'] ->
Class['::osnailyfacter::wait_for_nova_backends'] ->
Nova_flavor['m1.micro']
}
Exec { logoutput => true }

View File

@ -10,3 +10,4 @@ fixtures:
openstacklib: "#{source_dir}/../openstacklib"
sysfs: "#{source_dir}/../sysfs"
oslo: "#{source_dir}/../oslo"
haproxy: "#{source_dir}/../haproxy"

View File

@ -0,0 +1,95 @@
# == Class: osnailyfacter::wait_for_nova_backends
#
# This class is created to introduce one entry point to check for nova backends
# By default it will check for *all* nova service backends but can be
# configured to only wait for a particular service.
#
# === Parameters
#
# [*backends*]
# (Optional) List of backend services to wait for
# Defaults to ['nova-api', 'nova-metadata-api', 'nova-novncproxy']
#
# [*management_vip*]
# (Optional) Management vip address
# Defaults to hiera('management_vip')
#
# [*service_endpoint*]
# (Optional) Service endpoint ip address
# Defaults to hiera('service_endpoint')
#
# [*exeternal_lb*]
# (Optional) Flag to indicate if external loadbalancers are used.
# Defaults to hiera('exernal_lb', false)
#
# [*ssl_hash*]
# (Optional) Hash of external ssl information
# Defaults to hiera_hash('use_ssl', {})
#
class osnailyfacter::wait_for_nova_backends (
$backends = ['nova-api', 'nova-metadata-api', 'nova-novncproxy'],
$management_vip = hiera('management_vip'),
$service_endpoint = hiera('service_endpoint'),
$external_lb = hiera('external_lb', false),
$ssl_hash = hiera_hash('use_ssl', {}),
) {
$nova_api_protocol = get_ssl_property($ssl_hash, {}, 'nova', 'internal', 'protocol', 'http')
$nova_api_address = get_ssl_property($ssl_hash, {}, 'nova', 'internal', 'hostname', [$service_endpoint, $management_vip])
$nova_api_url = "${nova_api_protocol}://${nova_api_address}:8774"
$nova_metadata_api_url = "${nova_api_protocol}://${nova_api_address}:8775"
$nova_novncproxy_url = "${nova_api_protocol}://${nova_api_address}:6080"
$haproxy_stats_url = "http://${service_endpoint}:10000/;csv"
$lb_defaults = {
step => 6,
count => 200,
provider => 'haproxy',
url => $haproxy_stats_url
}
if $external_lb {
$lb_nova_api = {
provider => 'http',
url => $nova_api_url
}
$lb_nova_metadata_api = {
provider => 'http',
url => $nova_metadata_api_url,
}
$lb_nova_novncproxy = {
provider => 'http',
url => $nova_novncproxy_url,
}
}
$all_backend_hash = {
'nova-api' => merge(
{ name => 'nova-api' },
$lb_nova_api
),
'nova-metadata-api' => merge(
{ name => 'nova-metadata-api' },
$lb_nova_metadata_api
),
'nova-novncproxy' => merge (
{ name => 'nova-novncproxy' },
$lb_nova_novncproxy
)
}
# use difference from the keys of $all_backend_hash to get the keys we don't
# want to monitor
$keys_to_remove = difference(keys($all_backend_hash), $backends)
$lb_hash = delete($all_backend_hash, $keys_to_remove)
if empty($lb_hash) {
fail('No nova backends to monitor')
}
::osnailyfacter::wait_for_backend { 'nova-api':
lb_hash => $lb_hash,
lb_defaults => $lb_defaults
}
}

View File

@ -0,0 +1,99 @@
require 'spec_helper'
describe 'osnailyfacter::wait_for_nova_backends' do
let :facts do
{
:osfamily => 'Debian',
:operatingsystem => 'Ubuntu',
:operatingsystemrelease => '14.04',
:concat_basedir => '/var/lib/puppet/concat'
}
end
context 'all backends' do
let :params do
{
:management_vip => '127.0.0.1',
:service_endpoint => '127.0.0.2',
}
end
it 'should wait for correct backends' do
is_expected.to contain_osnailyfacter__wait_for_backend('nova-api').with(
:lb_hash => {
'nova-api' => {
'name' => 'nova-api',
'step' => 6,
'count' => 200,
'provider' => 'haproxy',
'url' => 'http://127.0.0.2:10000/;csv'
},
'nova-metadata-api' => {
'name' => 'nova-metadata-api',
'step' => 6,
'count' => 200,
'provider' => 'haproxy',
'url' => 'http://127.0.0.2:10000/;csv'
},
'nova-novncproxy' => {
'name' => 'nova-novncproxy',
'step' => 6,
'count' => 200,
'provider' => 'haproxy',
'url' => 'http://127.0.0.2:10000/;csv'
},
}
)
end
end
context 'only one backend' do
let :params do
{
:backends => ['nova-api'],
:management_vip => '127.0.0.1',
:service_endpoint => '127.0.0.2',
}
end
it 'should wait for correct backends' do
is_expected.to contain_osnailyfacter__wait_for_backend('nova-api').with(
:lb_hash => {
'nova-api' => {
'name' => 'nova-api',
'step' => 6,
'count' => 200,
'provider' => 'haproxy',
'url' => 'http://127.0.0.2:10000/;csv'
}
}
)
end
end
context 'only one backend and external lb' do
let :params do
{
:backends => ['nova-api'],
:management_vip => '127.0.0.1',
:service_endpoint => '127.0.0.2',
:external_lb => true
}
end
it 'should wait for correct backends' do
is_expected.to contain_osnailyfacter__wait_for_backend('nova-api').with(
:lb_hash => {
'nova-api' => {
'name' => 'nova-api',
'step' => 6,
'count' => 200,
'provider' => 'http',
'url' => 'http://127.0.0.2:8774'
},
}
)
end
end
end

View File

@ -75,14 +75,6 @@ describe manifest do
let(:ceilometer_hash) { Noop.hiera_hash 'ceilometer', {} }
storage_hash = Noop.hiera_structure 'storage'
sahara_hash = Noop.hiera_structure 'sahara'
nova_internal_protocol = Noop.puppet_function 'get_ssl_property',
Noop.hiera_hash('use_ssl', {}), {}, 'nova', 'internal', 'protocol',
'http'
nova_endpoint = Noop.hiera('nova_endpoint', Noop.hiera('management_vip'))
nova_internal_endpoint = Noop.puppet_function 'get_ssl_property',
Noop.hiera_hash('use_ssl', {}), {}, 'nova', 'internal', 'hostname',
[nova_endpoint]
let(:auto_assign_floating_ip) { Noop.hiera 'auto_assign_floating_ip', false }
let(:amqp_hosts) { Noop.hiera 'amqp_hosts', '' }
@ -385,20 +377,6 @@ describe manifest do
end
end
#PUP-2299
if primary_controller
it 'should retry unless when creating m1.micro flavor' do
should contain_exec('create-m1.micro-flavor').with(
'command' => 'bash -c "nova flavor-create --is-public true m1.micro auto 64 0 1"',
'unless' => 'bash -c \'for tries in {1..10}; do
nova flavor-list | grep m1.micro;
status=("${PIPESTATUS[@]}");
(( ! status[0] )) && exit "${status[1]}";
sleep 2;
done; exit 1\'',
)
end
end
ironic_enabled = Noop.hiera_structure 'ironic/enabled'
if ironic_enabled
@ -465,37 +443,6 @@ describe manifest do
end
if primary_controller
it 'should have explicit ordering between LB classes and particular actions' do
expect(graph).to ensure_transitive_dependency("Class[nova::api]","Haproxy_backend_status[nova-api]")
expect(graph).to ensure_transitive_dependency("Haproxy_backend_status[nova-api]",
"Exec[create-m1.micro-flavor]")
expect(graph).to ensure_transitive_dependency("Haproxy_backend_status[keystone-public]","Exec[create-m1.micro-flavor]")
expect(graph).to ensure_transitive_dependency("Haproxy_backend_status[keystone-admin]","Exec[create-m1.micro-flavor]")
franges = graph.vertices.find_all {|v| v.type == :nova_floating_range }
if !franges.to_a.empty?
franges.each do
|frange|
expect(graph).to ensure_transitive_dependency("Haproxy_backend_status[nova-api]",frange.ref)
expect(graph).to ensure_transitive_dependency("Haproxy_backend_status[keystone-public]",frange.ref)
expect(graph).to ensure_transitive_dependency("Haproxy_backend_status[keystone-admin]",frange.ref)
end
end
end
if Noop.hiera('external_lb', false)
url = "#{nova_internal_protocol}://#{nova_internal_endpoint}:8774"
provider = 'http'
else
url = 'http://' + Noop.hiera('management_vip').to_s + ':10000/;csv'
provider = Puppet::Type.type(:haproxy_backend_status).defaultprovider.name
end
it {
should contain_haproxy_backend_status('nova-api').with(
:url => url,
:provider => provider
)
}
it 'should declare class nova::api with sync_db and sync_db_api' do
should contain_class('nova::api').with(
'sync_db' => true,

View File

@ -8,6 +8,68 @@ manifest = 'roles/controller.pp'
describe manifest do
shared_examples 'catalog' do
let(:primary_controller) { Noop.hiera 'primary_controller' }
let(:management_vip) { Noop.hiera('management_vip') }
let(:service_endpoint) { Noop.hiera('service_endpoint') }
let(:nova_internal_protocol) { Noop.puppet_function 'get_ssl_property', ssl_hash, {}, 'nova', 'internal', 'protocol', 'http' }
let(:nova_internal_endpoint) { Noop.puppet_function 'get_ssl_property', ssl_hash, {}, 'nova', 'internal', 'hostname', [service_endpoint, management_vip] }
let(:external_lb) { Noop.hiera 'external_lb', false }
let(:status_url) do
if external_lb
"#{nova_internal_protocol}://#{nova_internal_endpoint}:8774"
else
"http://#{management_vip}:10000/;csv"
end
end
let(:status_provider) do
if external_lb
'http'
else
'haproxy'
end
end
it 'should contain backend status calls on primary-controller only' do
if primary_controller
should contain_class('osnailyfacter::wait_for_nova_backends').with(
:backends => ['nova-api'],
)
should contain_haproxy_backend_status('nova-api').with(
:url => status_url,
:provider => status_provider
)
else
should_not contain_class('osnailyfacter::wait_for_nova_backends')
end
end
it 'should configure nova_flavor to manage flavor on primary-controller only' do
if primary_controller
expect(graph).to ensure_transitive_dependency("Haproxy_backend_status[nova-api]", "Nova_flavor[m1.micro]")
expect(graph).to ensure_transitive_dependency("Haproxy_backend_status[keystone-public]","Nova_flavor[m1.micro]")
expect(graph).to ensure_transitive_dependency("Haproxy_backend_status[keystone-admin]","Nova_flavor[m1.micro]")
should contain_nova_flavor('m1.micro').with(
:ensure => 'present',
:ram => 64,
:disk => 0,
:vcpus => 1
)
else
should_not contain_nova_flavor('m1.micro')
end
end
it 'should install cirros image on primary-controler only' do
if primary_controller
should contain_package('cirros-testvm')
else
should_not contain_package('cirros-testvm')
end
end
it 'should set vm.swappiness sysctl to 10' do
should contain_sysctl('vm.swappiness').with(
'val' => '10',