Merge "Bulletproof novncproxy setting"
This commit is contained in:
commit
0865e058fb
@ -698,7 +698,8 @@ def discover(config, messages):
|
||||
# be used for that too).
|
||||
details = {}
|
||||
release_regexp = re.compile(r'^(?P<OS>.*) release (?P<release>[\d\.]*)')
|
||||
for host in filtered_hosts(config):
|
||||
config['HOST_LIST'] = list(filtered_hosts(config))
|
||||
for host in config['HOST_LIST']:
|
||||
details.setdefault(host, {})
|
||||
server = utils.ScriptRunner(host)
|
||||
# discover OS and release
|
||||
|
14
packstack/puppet/modules/packstack/Gemfile
Normal file
14
packstack/puppet/modules/packstack/Gemfile
Normal file
@ -0,0 +1,14 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
group :development, :test do
|
||||
gem 'puppetlabs_spec_helper', :require => false
|
||||
gem 'puppet-lint', '~> 0.3.2'
|
||||
gem 'rake', '10.1.1'
|
||||
gem 'rspec', '< 2.99'
|
||||
end
|
||||
|
||||
if puppetversion = ENV['PUPPET_GEM_VERSION']
|
||||
gem 'puppet', puppetversion, :require => false
|
||||
else
|
||||
gem 'puppet', :require => false
|
||||
end
|
6
packstack/puppet/modules/packstack/Rakefile
Normal file
6
packstack/puppet/modules/packstack/Rakefile
Normal file
@ -0,0 +1,6 @@
|
||||
require 'puppetlabs_spec_helper/rake_tasks'
|
||||
require 'puppet-lint/tasks/puppet-lint'
|
||||
|
||||
PuppetLint.configuration.fail_on_warnings = true
|
||||
PuppetLint.configuration.send('disable_80chars')
|
||||
PuppetLint.configuration.send('disable_class_parameter_defaults')
|
@ -0,0 +1,30 @@
|
||||
|
||||
# Function returns host's IP selected from list of IPs
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:choose_my_ip, :type => :rvalue) do |args|
|
||||
|
||||
if args.size < 1
|
||||
raise(
|
||||
Puppet::ParseError,
|
||||
"choose_my_ip(): Wrong number of arguments given (#{args.size} for 1)"
|
||||
)
|
||||
end
|
||||
|
||||
host_list = args[0]
|
||||
if not host_list.kind_of?(Array)
|
||||
host_list = [host_list]
|
||||
end
|
||||
my_ips = lookupvar('interfaces').split(',').map do |interface|
|
||||
interface.strip!
|
||||
lookupvar("ipaddress_#{interface}")
|
||||
end
|
||||
|
||||
result = nil
|
||||
host_list.each do |ip|
|
||||
if my_ips.include? ip
|
||||
result = ip
|
||||
end
|
||||
end
|
||||
result
|
||||
end
|
||||
end
|
10
packstack/puppet/modules/packstack/spec/spec_helper.rb
Normal file
10
packstack/puppet/modules/packstack/spec/spec_helper.rb
Normal file
@ -0,0 +1,10 @@
|
||||
require 'puppetlabs_spec_helper/module_spec_helper'
|
||||
|
||||
fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures'))
|
||||
|
||||
RSpec.configure do |c|
|
||||
c.alias_it_should_behave_like_to :it_configures, 'configures'
|
||||
c.alias_it_should_behave_like_to :it_raises, 'raises'
|
||||
c.module_path = File.join(fixture_path, 'modules')
|
||||
c.manifest_dir = File.join(fixture_path, 'manifests')
|
||||
end
|
@ -0,0 +1,36 @@
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe "choose_my_ip function" do
|
||||
|
||||
let :scope do
|
||||
PuppetlabsSpec::PuppetInternals.scope
|
||||
end
|
||||
|
||||
let :subject do
|
||||
function_name = Puppet::Parser::Functions.function(:choose_my_ip)
|
||||
scope.method(function_name)
|
||||
end
|
||||
|
||||
context "basic unit tests" do
|
||||
before :each do
|
||||
scope.stubs(:lookupvar).with('interfaces').returns('eth0,eth1,lo')
|
||||
scope.stubs(:lookupvar).with('ipaddress_eth1').returns('1.2.3.4')
|
||||
scope.stubs(:lookupvar).with('ipaddress_eth0').returns('2.3.4.5')
|
||||
scope.stubs(:lookupvar).with('ipaddress_lo').returns('127.0.0.1')
|
||||
end
|
||||
|
||||
it 'should select correct ip' do
|
||||
result = subject.call([['1.1.1.1', '2.3.4.5', '3.3.3.3']])
|
||||
result.should(eq('2.3.4.5'))
|
||||
end
|
||||
|
||||
it "should raise a ParseError if there is less than 1 arguments" do
|
||||
lambda { scope.function_choose_my_ip([]) }.should(
|
||||
raise_error(Puppet::ParseError)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
@ -35,12 +35,11 @@ $vncproxy_proto = $config_horizon_ssl ? {
|
||||
default => 'http',
|
||||
}
|
||||
|
||||
if ($::fqdn != '' and $::fqdn != 'localhost') {
|
||||
$vncproxy_server = $::fqdn
|
||||
if ($::fqdn == '' or $::fqdn =~ /localhost/) {
|
||||
# For cases where FQDNs have not been correctly set
|
||||
$vncproxy_server = choose_my_ip(hiera('HOST_LIST'))
|
||||
} else {
|
||||
# Multihost does not work without proper FQDN setup, so we use controller IP,
|
||||
# because this case can come up only in usecase, which is all-in-one
|
||||
$vncproxy_server = hiera('CONFIG_CONTROLLER_HOST')
|
||||
$vncproxy_server = $::fqdn
|
||||
}
|
||||
|
||||
class { 'nova::compute':
|
||||
|
Loading…
x
Reference in New Issue
Block a user