Allow single list of Zookeeper and cassandra

Change-Id: I69ba8f17007eaad96a933fbd45c397cdc0c498eb
This commit is contained in:
Alex Ruiz Estradera 2016-11-07 18:42:37 +01:00
parent 87ba9d8125
commit bb91c82360
8 changed files with 51 additions and 9 deletions

View File

@ -7,7 +7,8 @@ describe 'midonet::agent class' do
pp = <<-EOS pp = <<-EOS
include ::midonet::repository include ::midonet::repository
class { 'midonet_openstack::role::nsdb': class { 'midonet_openstack::role::nsdb':
client_ip => '127.0.0.1' client_ip => '127.0.0.1',
id => 1
} }
class { 'midonet::agent': class { 'midonet::agent':
zookeeper_hosts => [ { 'ip' => '127.0.0.1', 'port' => '2181' } ], zookeeper_hosts => [ { 'ip' => '127.0.0.1', 'port' => '2181' } ],

View File

@ -6,6 +6,10 @@ describe 'midonet::analytics class' do
it 'should install the midonet analytics without any errors' do it 'should install the midonet analytics without any errors' do
pp = <<-EOS pp = <<-EOS
include ::midonet::repository include ::midonet::repository
class { 'midonet_openstack::role::nsdb':
client_ip => '127.0.0.1',
id => 1
}
class { 'midonet::analytics': class { 'midonet::analytics':
is_mem => false, is_mem => false,
manage_repo => false, manage_repo => false,

View File

@ -7,7 +7,8 @@ describe 'midonet::cluster class' do
pp = <<-EOS pp = <<-EOS
include ::midonet::repository include ::midonet::repository
class { 'midonet_openstack::role::nsdb': class { 'midonet_openstack::role::nsdb':
client_ip => '127.0.0.1' client_ip => '127.0.0.1',
id => 1
} }
class { 'midonet::cluster': class { 'midonet::cluster':
zookeeper_hosts => [{ 'ip' => '127.0.0.1', 'port' => '2181' }], zookeeper_hosts => [{ 'ip' => '127.0.0.1', 'port' => '2181' }],

View File

@ -34,7 +34,13 @@
[zookeeper] [zookeeper]
<%- zkarr = Array.new -%> <%- zkarr = Array.new -%>
<%- @zookeeper_hosts.each do |s| -%> <%- zk_hosts = Array.new -%>
<%- if @zookeeeper_hosts.class == Hash -%>
<%- zk_hosts.push(@zookeeper_hosts) -%>
<%- else -%>
<%- zk_hosts = @zookeeper_hosts -%>
<%- end -%>
<%- zk_hosts.each do |s| -%>
<%- zkarr.push("#{s['ip']}:#{s['port'] ||= 2181 }") -%> <%- zkarr.push("#{s['ip']}:#{s['port'] ||= 2181 }") -%>
<%- end -%> <%- end -%>
zookeeper_hosts = <%= zkarr.join(",") %> zookeeper_hosts = <%= zkarr.join(",") %>

View File

@ -14,7 +14,13 @@
[zookeeper] [zookeeper]
<%- zkarr = Array.new -%> <%- zkarr = Array.new -%>
<%- @zookeeper_hosts.each do |s| -%> <%- zk_hosts = Array.new -%>
<%- if @zookeeeper_hosts.class == Hash -%>
<%- zk_hosts.push(@zookeeper_hosts) -%>
<%- else -%>
<%- zk_hosts = @zookeeper_hosts -%>
<%- end -%>
<%- zk_hosts.each do |s| -%>
<%- zkarr.push("#{s['ip']}:#{s['port'] ||= 2181 }") -%> <%- zkarr.push("#{s['ip']}:#{s['port'] ||= 2181 }") -%>
<%- end -%> <%- end -%>
zookeeper_hosts = <%= zkarr.join(",") %> zookeeper_hosts = <%= zkarr.join(",") %>

View File

@ -14,7 +14,13 @@
[zookeeper] [zookeeper]
<%- zkarr = Array.new -%> <%- zkarr = Array.new -%>
<%- @zookeeper_hosts.each do |s| -%> <%- zk_hosts = Array.new -%>
<%- if @zookeeeper_hosts.class == Hash -%>
<%- zk_hosts.push(@zookeeper_hosts) -%>
<%- else -%>
<%- zk_hosts = @zookeeper_hosts -%>
<%- end -%>
<%- zk_hosts.each do |s| -%>
<%- zkarr.push("#{s['ip']}:#{s['port'] ||= 2181 }") -%> <%- zkarr.push("#{s['ip']}:#{s['port'] ||= 2181 }") -%>
<%- end -%> <%- end -%>
zookeeper_hosts = <%= zkarr.join(",") %> zookeeper_hosts = <%= zkarr.join(",") %>

View File

@ -11,14 +11,26 @@ which mn-conf > /dev/null || {
cat << EOF | mn-conf set -t default cat << EOF | mn-conf set -t default
zookeeper { zookeeper {
<%- zkarr = Array.new -%> <%- zkarr = Array.new -%>
<%- @zookeeper_hosts.each do |s| -%> <%- zk_hosts = Array.new -%>
<%- zkarr.push("#{s['ip']}:#{s['port'] ||= 2181 }") -%> <%- if @zookeeeper_hosts.class == Hash -%>
<%- zk_hosts.push(@zookeeper_hosts) -%>
<%- else -%>
<%- zk_hosts = @zookeeper_hosts -%>
<%- end -%>
<%- zk_hosts.each do |s| -%>
<%- zkarr.push("#{s['ip']}:#{s['port'] ||= 2181 }") -%>
<%- end -%> <%- end -%>
zookeeper_hosts = "<%= zkarr.join(",") %>" zookeeper_hosts = "<%= zkarr.join(",") %>"
} }
cassandra { cassandra {
servers = "<%= @cassandra_servers.join(",") %>" <%- cass_hosts = Array.new -%>
<%- if @cassandra_servers.class == String -%>
<%- cass_hosts.push(@cassandra_servers) -%>
<%- else -%>
<%- cass_hosts = @cassandra_servers -%>
<%- end -%>
servers = "<%= cass_hosts.join(",") %>"
} }
EOF EOF
echo "cassandra.replication_factor : <%= @cassandra_rep_factor %>" | mn-conf set -t default echo "cassandra.replication_factor : <%= @cassandra_rep_factor %>" | mn-conf set -t default

View File

@ -35,7 +35,13 @@ USE_SCREEN="True"
# ZK Hosts (comma delimited) # ZK Hosts (comma delimited)
<%- zkarr = Array.new -%> <%- zkarr = Array.new -%>
<%- @zookeeper_hosts.each do |s| -%> <%- zk_hosts = Array.new -%>
<%- if @zookeeeper_hosts.class == Hash -%>
<%- zk_hosts.push(@zookeeper_hosts) -%>
<%- else -%>
<%- zk_hosts = @zookeeper_hosts -%>
<%- end -%>
<%- zk_hosts.each do |s| -%>
<%- zkarr.push("#{s['ip']}:#{s['port'] ||= 2181 }") -%> <%- zkarr.push("#{s['ip']}:#{s['port'] ||= 2181 }") -%>
<%- end -%> <%- end -%>
ZOOKEEPER_HOSTS=<%= zkarr.join(",") %> ZOOKEEPER_HOSTS=<%= zkarr.join(",") %>