diff --git a/deployment/puppet/swift/lib/puppet/type/ring_account_device.rb b/deployment/puppet/swift/lib/puppet/type/ring_account_device.rb index a0645c2e2f..f69d208409 100644 --- a/deployment/puppet/swift/lib/puppet/type/ring_account_device.rb +++ b/deployment/puppet/swift/lib/puppet/type/ring_account_device.rb @@ -7,7 +7,7 @@ Puppet::Type.newtype(:ring_account_device) do validate do |value| # Commit 103b68b changed the acceptable name from address:port/device to simply address:port. address = value.split(':') - raise(Puppet::Error, "invalid name #{value}") unless address.size == 2 + raise(Puppet::Error, "invalid name #{value}: should contain address:port") unless address.size == 2 IPAddr.new(address[0]) end end diff --git a/deployment/puppet/swift/lib/puppet/type/ring_container_device.rb b/deployment/puppet/swift/lib/puppet/type/ring_container_device.rb index a7120de115..fe9aa3ec3d 100644 --- a/deployment/puppet/swift/lib/puppet/type/ring_container_device.rb +++ b/deployment/puppet/swift/lib/puppet/type/ring_container_device.rb @@ -7,7 +7,7 @@ Puppet::Type.newtype(:ring_container_device) do validate do |value| # Commit 103b68b changed the acceptable format from address:port/device to just address:port. address = value.split(':') - raise(Puppet::Error, "invalid name #{value}") unless address.size == 2 + raise(Puppet::Error, "invalid name #{value}: should contain address:port") unless address.size == 2 IPAddr.new(address[0]) end end diff --git a/deployment/puppet/swift/lib/puppet/type/ring_object_device.rb b/deployment/puppet/swift/lib/puppet/type/ring_object_device.rb index e318627496..c539efda89 100644 --- a/deployment/puppet/swift/lib/puppet/type/ring_object_device.rb +++ b/deployment/puppet/swift/lib/puppet/type/ring_object_device.rb @@ -7,7 +7,7 @@ Puppet::Type.newtype(:ring_object_device) do validate do |value| # Commit 103b68b changed acceptable format from address:port/device to just address:port. address = value.split(':') - raise(Puppet::Error, "invalid name #{value}e") unless address.size == 2 + raise(Puppet::Error, "invalid name #{value}: should contain address:port") unless address.size == 2 IPAddr.new(address[0]) end end diff --git a/deployment/puppet/swift/manifests/keystone/auth.pp b/deployment/puppet/swift/manifests/keystone/auth.pp index b41ddbe781..d201fd51fa 100644 --- a/deployment/puppet/swift/manifests/keystone/auth.pp +++ b/deployment/puppet/swift/manifests/keystone/auth.pp @@ -1,11 +1,29 @@ class swift::keystone::auth( $auth_name = 'swift', $password = 'swift_password', - $internal_address = '127.0.0.1', - $admin_address = '127.0.0.1', - $public_address = '127.0.0.1', + $address = '127.0.0.1', + $internal_address = undef, + $admin_address = undef, + $public_address = undef, $port = '8080' ) { + if ($internal_address == undef) { + $internal_address_real = $address + } else { + $internal_address_real = $internal_address + } + + if ($admin_address == undef) { + $admin_address_real = $address + } else { + $admin_address_real = $admin_address + } + + if ($public_address == undef) { + $public_address_real = $address + } else { + $public_address_real = $public_address + } keystone_user { $auth_name: ensure => present, @@ -25,9 +43,9 @@ class swift::keystone::auth( keystone_endpoint { $auth_name: ensure => present, region => 'RegionOne', - public_url => "http://${public_address}:${port}/v1/AUTH_%(tenant_id)s", - admin_url => "http://${admin_address}:${port}/", - internal_url => "http://${internal_address}:${port}/v1/AUTH_%(tenant_id)s", + public_url => "http://${public_address_real}:${port}/v1/AUTH_%(tenant_id)s", + admin_url => "http://${admin_address_real}:${port}/", + internal_url => "http://${internal_address_real}:${port}/v1/AUTH_%(tenant_id)s", } keystone_service { "${auth_name}_s3": @@ -38,9 +56,9 @@ class swift::keystone::auth( keystone_endpoint { "${auth_name}_s3": ensure => present, region => 'RegionOne', - public_url => "http://${public_address}:${port}", - admin_url => "http://${admin_address}:${port}", - internal_url => "http://${internal_address}:${port}", + public_url => "http://${public_address_real}:${port}", + admin_url => "http://${admin_address_real}:${port}", + internal_url => "http://${internal_address_real}:${port}", } } diff --git a/deployment/puppet/swift/manifests/storage/node.pp b/deployment/puppet/swift/manifests/storage/node.pp index 0a5d57b798..6a6014eec6 100644 --- a/deployment/puppet/swift/manifests/storage/node.pp +++ b/deployment/puppet/swift/manifests/storage/node.pp @@ -7,7 +7,6 @@ define swift::storage::node( $mnt_base_dir, $zone, - $weight = 1, $owner = 'swift', $group = 'swift', $max_connections = 25, @@ -16,6 +15,7 @@ define swift::storage::node( ) { Swift::Storage::Server { + swift_zone => $zone, storage_local_net_ip => $storage_local_net_ip, devices => $mnt_base_dir, max_connections => $max_connections, @@ -26,25 +26,22 @@ define swift::storage::node( swift::storage::server { "60${name}0": type => 'object', } - ring_object_device { "${storage_local_net_ip}:60${name}0/$name": + ring_object_device { "${storage_local_net_ip}:60${name}0": zone => $zone, - weight => $weight, } swift::storage::server { "60${name}1": type => 'container', } - ring_container_device { "${storage_local_net_ip}:60${name}1/$name": + ring_container_device { "${storage_local_net_ip}:60${name}1": zone => $zone, - weight => $weight, } swift::storage::server { "60${name}2": type => 'account', } - ring_account_device { "${storage_local_net_ip}:60${name}2/$name": + ring_account_device { "${storage_local_net_ip}:60${name}2": zone => $zone, - weight => $weight, } } diff --git a/deployment/puppet/swift/manifests/storage/server.pp b/deployment/puppet/swift/manifests/storage/server.pp index fc536ce08f..16c6eb28cc 100644 --- a/deployment/puppet/swift/manifests/storage/server.pp +++ b/deployment/puppet/swift/manifests/storage/server.pp @@ -22,12 +22,13 @@ define swift::storage::server( # this parameters needs to be specified after type and name $config_file_path = "${type}-server/${name}.conf" ) { - + if (is_array($pipeline)) { + $pipeline_real = $pipeline + } else { + $pipeline_real = [$pipeline] + } # TODO if array does not include type-server, warn - if( - (is_array($pipeline) and ! member($pipeline, "${type}-server")) or - $pipeline != "${type}-server" - ) { + if(! member($pipeline_real, "${type}-server")) { warning("swift storage server ${type} must specify ${type}-server") } @@ -36,7 +37,6 @@ define swift::storage::server( validate_re($name, '^\d+$') validate_re($type, '^object|container|account$') - validate_array($pipeline) # TODO - validate that name is an integer $bind_port = $name @@ -60,7 +60,7 @@ define swift::storage::server( $required_middlewares = split( inline_template( "<%= - (pipeline - ['${type}-server']).collect do |x| + (pipeline_real - ['${type}-server']).collect do |x| 'Swift::Storage::Filter::' + x + '[${type}]' end.join(',') %>"), ',') diff --git a/deployment/puppet/swift/spec/classes/swift_proxy_cache_spec.rb b/deployment/puppet/swift/spec/classes/swift_proxy_cache_spec.rb index 416445581c..c306bc418b 100644 --- a/deployment/puppet/swift/spec/classes/swift_proxy_cache_spec.rb +++ b/deployment/puppet/swift/spec/classes/swift_proxy_cache_spec.rb @@ -33,7 +33,7 @@ describe 'swift::proxy::cache' do describe 'with overridden memcache server' do let :params do - {:memcache_servers => '10.0.0.1:1'} + {:memcache_servers => ['10.0.0.1:1']} end it { should contain_file(fragment_file).with_content(/memcache_servers = 10\.0\.0\.1:1/) } diff --git a/deployment/puppet/swift/spec/classes/swift_ringbuilder_spec.rb b/deployment/puppet/swift/spec/classes/swift_ringbuilder_spec.rb index 68650ebda0..d72e01fce0 100644 --- a/deployment/puppet/swift/spec/classes/swift_ringbuilder_spec.rb +++ b/deployment/puppet/swift/spec/classes/swift_ringbuilder_spec.rb @@ -61,39 +61,36 @@ describe 'swift::ringbuilder' do 'class { memcached: max_memory => 1} class { swift: swift_hash_suffix => string } class { "ssh::server::install": } - ring_object_device { "127.0.0.1:6000/1": + ring_object_device { "127.0.0.1:6000": zone => 1, - weight => 1, } - ring_container_device { "127.0.0.1:6001/1": + ring_container_device { "127.0.0.1:6001": zone => 2, - weight => 1, } - ring_account_device { "127.0.0.1:6002/1": + ring_account_device { "127.0.0.1:6002": zone => 3, - weight => 1, }' end it 'should set up all of the correct dependencies' do should contain_swift__ringbuilder__create('object').with( - {:before => 'Ring_object_device[127.0.0.1:6000/1]'} + {:before => 'Ring_object_device[127.0.0.1:6000]'} ) should contain_swift__ringbuilder__create('container').with( - {:before => 'Ring_container_device[127.0.0.1:6001/1]'} + {:before => 'Ring_container_device[127.0.0.1:6001]'} ) should contain_swift__ringbuilder__create('account').with( - {:before => 'Ring_account_device[127.0.0.1:6002/1]'} + {:before => 'Ring_account_device[127.0.0.1:6002]'} ) - should contain_ring_object_device('127.0.0.1:6000/1').with( + should contain_ring_object_device('127.0.0.1:6000').with( {:notify => 'Swift::Ringbuilder::Rebalance[object]'} ) - should contain_ring_container_device('127.0.0.1:6001/1').with( + should contain_ring_container_device('127.0.0.1:6001').with( {:notify => 'Swift::Ringbuilder::Rebalance[container]'} ) - should contain_ring_account_device('127.0.0.1:6002/1').with( + should contain_ring_account_device('127.0.0.1:6002').with( {:notify => 'Swift::Ringbuilder::Rebalance[account]'} ) end diff --git a/deployment/puppet/swift/spec/classes/swift_storage_all_spec.rb b/deployment/puppet/swift/spec/classes/swift_storage_all_spec.rb index dc752f7957..a1d96e204f 100644 --- a/deployment/puppet/swift/spec/classes/swift_storage_all_spec.rb +++ b/deployment/puppet/swift/spec/classes/swift_storage_all_spec.rb @@ -27,14 +27,9 @@ describe 'swift::storage::all' do } end - describe 'when an internal network ip is not specified' do - it 'should fail' do - expect { subject }.to raise_error(Puppet::Error, /Must pass storage_local_net_ip/) - end - end - - [{ :storage_local_net_ip => '127.0.0.1' }, + [{ :swift_zone => '1', :storage_local_net_ip => '127.0.0.1' }, { + :swift_zone => '1', :devices => '/tmp/node', :storage_local_net_ip => '10.0.0.1', :object_port => '7000', @@ -98,14 +93,6 @@ describe 'swift::storage::all' do :config_file_path => 'container-server.conf', :pipeline => param_hash[:container_pipeline] || 'container-server' }.merge(storage_server_defaults) )} - - it { should contain_class('rsync::server').with( - {:use_xinetd => true, - :address => param_hash[:storage_local_net_ip], - :use_chroot => 'no' - } - )} - end end @@ -118,8 +105,9 @@ describe 'swift::storage::all' do } end - [{ :storage_local_net_ip => '127.0.0.1' }, + [{ :swift_zone => '1', :storage_local_net_ip => '127.0.0.1' }, { + :swift_zone => '1', :devices => '/tmp/node', :storage_local_net_ip => '10.0.0.1', :object_port => '7000', diff --git a/deployment/puppet/swift/spec/classes/swift_storage_spec.rb b/deployment/puppet/swift/spec/classes/swift_storage_spec.rb index 656b8ebc4c..3a2a2ceaea 100644 --- a/deployment/puppet/swift/spec/classes/swift_storage_spec.rb +++ b/deployment/puppet/swift/spec/classes/swift_storage_spec.rb @@ -23,13 +23,6 @@ describe 'swift::storage' do :storage_local_net_ip => '127.0.0.1', } end - - it { should contain_class('rsync::server').with( - {:use_xinetd => true, - :address => params[:storage_local_net_ip], - :use_chroot => 'no' - } - )} end describe 'when local net ip is not specified' do it 'should fail' do diff --git a/deployment/puppet/swift/spec/defines/swift_storage_node_spec.rb b/deployment/puppet/swift/spec/defines/swift_storage_node_spec.rb index a888b19436..6863156e67 100644 --- a/deployment/puppet/swift/spec/defines/swift_storage_node_spec.rb +++ b/deployment/puppet/swift/spec/defines/swift_storage_node_spec.rb @@ -27,8 +27,8 @@ describe 'swift::storage::node' do end it { - should contain_ring_object_device("127.0.0.1:6010/1") - should contain_ring_container_device("127.0.0.1:6011/1") - should contain_ring_account_device("127.0.0.1:6012/1") + should contain_ring_object_device("127.0.0.1:6010") + should contain_ring_container_device("127.0.0.1:6011") + should contain_ring_account_device("127.0.0.1:6012") } end diff --git a/deployment/puppet/swift/spec/defines/swift_storage_server_spec.rb b/deployment/puppet/swift/spec/defines/swift_storage_server_spec.rb index d00b0fedb9..c7101f68ad 100644 --- a/deployment/puppet/swift/spec/defines/swift_storage_server_spec.rb +++ b/deployment/puppet/swift/spec/defines/swift_storage_server_spec.rb @@ -25,8 +25,9 @@ describe 'swift::storage::server' do describe 'with an invalid title' do let :params do - {:storage_local_net_ip => '127.0.0.1', - :type => 'object'} + {:swift_zone => '1', + :storage_local_net_ip => '127.0.0.1', + :type => 'object'} end let :title do 'foo' @@ -45,7 +46,7 @@ describe 'swift::storage::server' do end let :req_params do - {:storage_local_net_ip => '10.0.0.1', :type => t} + {:swift_zone => '1', :storage_local_net_ip => '10.0.0.1', :type => t} end let :params do req_params @@ -67,7 +68,7 @@ describe 'swift::storage::server' do :user => 'dan', :mount_check => true, :workers => 7, - :pipeline => ['foo'] + :pipeline => 'foo' }.each do |k,v| describe "when #{k} is set" do let :params do req_params.merge({k => v}) end @@ -83,12 +84,6 @@ describe 'swift::storage::server' do :before => ["Swift::Storage::Filter::1[#{t}]", "Swift::Storage::Filter::2[#{t}]", "Swift::Storage::Filter::3[#{t}]"] })} end - describe "when pipeline is not passed an array" do - let :params do req_params.merge({:pipeline => 'not an array'}) end - it "should fail" do - expect { subject }.to raise_error(Puppet::Error, /is not an Array/) - end - end describe "when replicator_concurrency is set" do let :params do req_params.merge({:replicator_concurrency => 42}) end it { should contain_file(fragment_file) \ diff --git a/deployment/puppet/swift/spec/fixtures/manifests/site.pp b/deployment/puppet/swift/spec/fixtures/manifests/site.pp deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/deployment/puppet/swift/spec/unit/puppet/provider/swift_ring_builder_spec.rb b/deployment/puppet/swift/spec/unit/puppet/provider/swift_ring_builder_spec.rb index 5f66f3ad3e..6529338f01 100644 --- a/deployment/puppet/swift/spec/unit/puppet/provider/swift_ring_builder_spec.rb +++ b/deployment/puppet/swift/spec/unit/puppet/provider/swift_ring_builder_spec.rb @@ -26,8 +26,8 @@ Devices: id zone ip address port name weight partitions balance m ' ) resources = provider_class.lookup_ring.inspect - resources['192.168.101.15:6002/1'].should_not be_nil - resources['192.168.101.13:6002/1'].should_not be_nil - resources['192.168.101.14:6002/1'].should_not be_nil + resources['192.168.101.15:6002'].should_not be_nil + resources['192.168.101.13:6002'].should_not be_nil + resources['192.168.101.14:6002'].should_not be_nil end end diff --git a/deployment/puppet/swift/spec/unit/puppet/type/ring_account_device_spec.rb b/deployment/puppet/swift/spec/unit/puppet/type/ring_account_device_spec.rb index 98b3f0a496..cbfbc33927 100644 --- a/deployment/puppet/swift/spec/unit/puppet/type/ring_account_device_spec.rb +++ b/deployment/puppet/swift/spec/unit/puppet/type/ring_account_device_spec.rb @@ -4,12 +4,6 @@ describe Puppet::Type.type(:ring_account_device) do it 'should fail if the name has no ":"' do expect { Puppet::Type.type(:ring_account_device).new(:name => 'foo/bar') - }.to raise_error(Puppet::Error, /should contain address:port\/device/) - end - - it 'should fail if the name does not contain a "/"' do - expect { - Puppet::Type.type(:ring_account_device).new(:name => 'foo:80') - }.to raise_error(Puppet::Error, /should contain a device/) + }.to raise_error(Puppet::Error, /should contain address:port/) end end diff --git a/deployment/puppet/swift/spec/unit/puppet/type/ring_container_device_spec.rb b/deployment/puppet/swift/spec/unit/puppet/type/ring_container_device_spec.rb index 80b436ab2c..bd8e7d9ef9 100644 --- a/deployment/puppet/swift/spec/unit/puppet/type/ring_container_device_spec.rb +++ b/deployment/puppet/swift/spec/unit/puppet/type/ring_container_device_spec.rb @@ -5,12 +5,6 @@ describe Puppet::Type.type(:ring_container_device) do it 'should fail if the name has no ":"' do expect { Puppet::Type.type(:ring_account_device).new(:name => 'foo/bar') - }.to raise_error(Puppet::Error, /should contain address:port\/device/) - end - - it 'should fail if the name does not contain a "/"' do - expect { - Puppet::Type.type(:ring_account_device).new(:name => 'foo:80') - }.to raise_error(Puppet::Error, /should contain a device/) + }.to raise_error(Puppet::Error, /should contain address:port/) end end diff --git a/deployment/puppet/swift/spec/unit/puppet/type/ring_object_device_spec.rb b/deployment/puppet/swift/spec/unit/puppet/type/ring_object_device_spec.rb index 05861bb17a..e0666120f8 100644 --- a/deployment/puppet/swift/spec/unit/puppet/type/ring_object_device_spec.rb +++ b/deployment/puppet/swift/spec/unit/puppet/type/ring_object_device_spec.rb @@ -4,12 +4,6 @@ describe Puppet::Type.type(:ring_object_device) do it 'should fail if the name has no ":"' do expect { Puppet::Type.type(:ring_account_device).new(:name => 'foo/bar') - }.to raise_error(Puppet::Error, /should contain address:port\/device/) - end - - it 'should fail if the name does not contain a "/"' do - expect { - Puppet::Type.type(:ring_account_device).new(:name => 'foo:80') - }.to raise_error(Puppet::Error, /should contain a device/) + }.to raise_error(Puppet::Error, /should contain address:port/) end end diff --git a/deployment/puppet/swift/templates/account-server.conf.erb b/deployment/puppet/swift/templates/account-server.conf.erb index ff1640d65d..b38449a91e 100644 --- a/deployment/puppet/swift/templates/account-server.conf.erb +++ b/deployment/puppet/swift/templates/account-server.conf.erb @@ -8,7 +8,7 @@ log_facility = LOG_LOCAL2 workers = <%= workers %> [pipeline:main] -pipeline = <%= pipeline.to_a.join(' ') %> +pipeline = <%= pipeline_real.join(' ') %> [app:account-server] use = egg:swift#account diff --git a/deployment/puppet/swift/templates/container-server.conf.erb b/deployment/puppet/swift/templates/container-server.conf.erb index 895cee46af..ad2c1cdfad 100644 --- a/deployment/puppet/swift/templates/container-server.conf.erb +++ b/deployment/puppet/swift/templates/container-server.conf.erb @@ -8,7 +8,7 @@ log_facility = LOG_LOCAL2 workers = <%= workers %> [pipeline:main] -pipeline = <%= pipeline.to_a.join(' ') %> +pipeline = <%= pipeline_real.join(' ') %> [app:container-server] use = egg:swift#container diff --git a/deployment/puppet/swift/templates/object-server.conf.erb b/deployment/puppet/swift/templates/object-server.conf.erb index f188ef88c8..003b13ff22 100644 --- a/deployment/puppet/swift/templates/object-server.conf.erb +++ b/deployment/puppet/swift/templates/object-server.conf.erb @@ -8,7 +8,7 @@ log_facility = LOG_LOCAL2 workers = <%= workers %> [pipeline:main] -pipeline = <%= pipeline.to_a.join(' ') %> +pipeline = <%= pipeline_real.join(' ') %> [app:object-server] use = egg:swift#object