Extends midonet::agent
Change-Id: Ie23f6fd16d0bfa3cdc6627fc607aab53e7c4957d
This commit is contained in:
@@ -80,7 +80,10 @@ class midonet::agent (
|
||||
$agent_config_path = undef,
|
||||
$package_ensure = undef,
|
||||
$manage_java = undef,
|
||||
$zookeeper_hosts = undef,
|
||||
$zookeeper_hosts,
|
||||
$controller_host,
|
||||
$metadata_port,
|
||||
$shared_secret,
|
||||
) {
|
||||
|
||||
include midonet::repository
|
||||
@@ -98,6 +101,9 @@ class midonet::agent (
|
||||
service_enable => undef,
|
||||
agent_config_path => $agent_config_path,
|
||||
zookeeper_hosts => $zookeeper_hosts,
|
||||
controller_host => $controller_host,
|
||||
metadata_port => $metadata_port,
|
||||
shared_secret => $shared_secret,
|
||||
require => Class['midonet::agent::install'],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,19 +40,31 @@ class midonet::agent::run (
|
||||
$service_ensure = 'running',
|
||||
$service_enable = true,
|
||||
$agent_config_path = '/etc/midolman/midolman.conf',
|
||||
$zookeeper_hosts = [{ 'ip' => '127.0.0.1', 'port' => '2181' }],
|
||||
$zookeeper_hosts,
|
||||
$controller_host,
|
||||
$metadata_port,
|
||||
$shared_secret,
|
||||
) {
|
||||
|
||||
file { 'agent_config':
|
||||
ensure => present,
|
||||
path => $agent_config_path,
|
||||
content => template('midonet/agent/midolman.conf.erb'),
|
||||
require => Package['midolman'],
|
||||
} ~>
|
||||
file { '/tmp/mn-agent_config.sh':
|
||||
ensure => present,
|
||||
content => template('midonet/agent/mn-agent_config.sh.erb'),
|
||||
} ->
|
||||
|
||||
service { 'midolman':
|
||||
ensure => $service_ensure,
|
||||
name => $service_name,
|
||||
enable => $service_enable,
|
||||
}
|
||||
exec { '/bin/bash /tmp/mn-agent_config.sh': }
|
||||
|
||||
file { 'agent_config':
|
||||
ensure => present,
|
||||
path => $agent_config_path,
|
||||
content => template('midonet/agent/midolman.conf.erb'),
|
||||
require => Package['midolman'],
|
||||
notify => Service['midolman'],
|
||||
before => File['/tmp/mn-agent_config.sh'],
|
||||
}
|
||||
|
||||
service { 'midolman':
|
||||
ensure => $service_ensure,
|
||||
name => $service_name,
|
||||
enable => $service_enable,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'midonet::agent class' do
|
||||
context 'default parameters' do
|
||||
context 'with mandatory parameters (default params not overwritten)' do
|
||||
# Using puppet_apply as a helper
|
||||
it 'should install the midonet agent without any errors' do
|
||||
pp = <<-EOS
|
||||
class { 'midonet::agent': manage_java => true }
|
||||
class { 'midonet::agent':
|
||||
zookeeper_hosts => [ { 'ip' => '127.0.0.1', 'port' => '2181' } ],
|
||||
controller_host => '127.0.0.1',
|
||||
metadata_port => '8181',
|
||||
shared_secret => 'SHARED_SECRET',
|
||||
manage_java => true,
|
||||
}
|
||||
EOS
|
||||
|
||||
# Run it twice and test for idempotency
|
||||
|
||||
@@ -9,9 +9,15 @@ describe 'midonet::agent::run' do
|
||||
:lsbdistrelease => '16.04',
|
||||
}
|
||||
end
|
||||
it { is_expected.to contain_file('agent_config').with(
|
||||
'ensure' => 'present',
|
||||
) }
|
||||
let :params do
|
||||
{
|
||||
:zookeeper_hosts => [ { 'ip' => '127.0.0.1' } ],
|
||||
:controller_host => '127.0.0.1',
|
||||
:metadata_port => '8118',
|
||||
:shared_secret => 'SHARED_SECRET',
|
||||
}
|
||||
end
|
||||
it { is_expected.to contain_file('agent_config').with_ensure('present') }
|
||||
it { is_expected.to contain_service('midolman').with_ensure('running') }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,6 +9,14 @@ describe 'midonet::agent' do
|
||||
:lsbdistrelease => '16.04',
|
||||
}
|
||||
end
|
||||
let :params do
|
||||
{
|
||||
:zookeeper_hosts => [ { 'ip' => '127.0.0.1' } ],
|
||||
:controller_host => '127.0.0.1',
|
||||
:metadata_port => '8118',
|
||||
:shared_secret => 'SHARED_SECRET',
|
||||
}
|
||||
end
|
||||
it { is_expected.to contain_class('midonet::repository') }
|
||||
it { is_expected.to contain_class('midonet::agent::install') }
|
||||
it { is_expected.to contain_class('midonet::agent::run') }
|
||||
|
||||
15
templates/agent/mn-agent_config.sh.erb
Normal file
15
templates/agent/mn-agent_config.sh.erb
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
which mn-conf > /dev/null || {
|
||||
echo "'mn-conf' cannot be found in \$PATH" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
## Configure MidoNet Metadata Proxy
|
||||
echo "agent.openstack.metadata.nova_metadata_url : \"http://<%= @controller_host %>:<%= @metadata_port %>\"" | mn-conf set -t default
|
||||
echo "agent.openstack.metadata.shared_secret : <%= @shared_secret %>" | mn-conf set -t default
|
||||
echo "agent.openstack.metadata.enabled : true" | mn-conf set -t default
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user