Valid options: A string of valid Java options.
-##### `username`
-
-Specifies the username to set for admin role in ODL.
-
-Default: `'admin'`
-
-Valid options: A username string.
-
-##### `password`
-
-Specifies the password to set for admin role in ODL.
-
-Default: `'admin'`
-
-Valid options: A password string.
-
## Limitations
- Tested on CentOS 7 and Ubuntu 16.04.
+++ /dev/null
-Puppet::Type.type(:odl_user).provide(:idm) do
-
- commands :java => 'java'
-
- def odl_path
- '/opt/opendaylight'
- end
-
- def idm_cmd(*args)
- java('-jar', "#{odl_path}/bin/aaa-cli-jar.jar", '--dbd', odl_path, *args)
- end
-
- def create
- idm_cmd('--newUser', @resource[:username], '-p', @resource[:password])
- end
-
- def destroy
- idm_cmd('--deleteUser', @resource[:username])
- end
-
- def exists?
- output = idm_cmd('-l').split("\n")
- output.each do |line|
- if line.eql? @resource[:username]
- return true
- end
- end
- return false
- end
-
- def password
- return false
- end
-
- def password=(password)
- destroy
- idm_cmd('--newUser', @resource[:username], '-p', password)
- end
-
-end
+++ /dev/null
-Puppet::Type.newtype(:odl_user) do
-
- ensurable
-
- newparam(:username, :namevar => true) do
- desc "Username to configure in ODL IDM with admin role"
- newvalues(/^\w+$/)
- end
-
- newproperty(:password) do
- desc "Password for this user"
- validate do |value|
- if !value.is_a?(String)
- raise ArgumentError, "Passwords must be a string"
- end
- end
-
- def change_to_s(current, desire)
- "Password changed"
- end
- end
-
-end
match => '^routing-node=.*$',
}
}
-
- # Configure username/password
- odl_user { $::opendaylight::username:
- password => $::opendaylight::password,
- before => Service['opendaylight'],
- }
}
$vpp_routing_node = $::opendaylight::params::vpp_routing_node,
$java_opts = $::opendaylight::params::java_opts,
$manage_repositories = $::opendaylight::params::manage_repositories,
- $username = $::opendaylight::params::username,
- $password = $::opendaylight::params::password,
) inherits ::opendaylight::params {
# Validate OS family
$vpp_routing_node = ''
$java_opts = '-Djava.net.preferIPv4Stack=true'
$manage_repositories = true
- $username = 'admin'
- $password = 'admin'
}
log_level_validations(log_levels: custom_log_levels)
end
end
-
- describe 'testing odl username/password' do
- context 'using default username/password' do
- context 'using default log levels' do
- # Call specialized helper fn to install OpenDaylight
- install_odl({:extra_features => ['odl-restconf']})
-
- # Call specialized helper fn for username/password validations
- username_password_validations
- end
- end
- end
end
end
end
- # ODL username/password tests
- describe 'ODL username/password tests' do
- # Non-OS-type tests assume CentOS 7
- # See issue #43 for reasoning:
- # https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
- osfamily = 'RedHat'
- operatingsystem = 'CentOS'
- operatingsystemmajrelease = '7'
- context 'using default username/password' do
- let(:facts) {{
- :osfamily => osfamily,
- :operatingsystem => operatingsystem,
- :operatingsystemmajrelease => operatingsystemmajrelease,
- }}
-
- let(:params) {{ }}
-
- # Run shared tests applicable to all supported OSs
- # Note that this function is defined in spec_helper
- generic_tests
-
- # Run test that specialize in checking username/password config
- # Note that this function is defined in spec_helper
- username_password_tests('admin','admin')
- end
-
- context 'specifying non-default username/password' do
- let(:facts) {{
- :osfamily => osfamily,
- :operatingsystem => operatingsystem,
- :operatingsystemmajrelease => operatingsystemmajrelease,
- }}
-
- let(:params) {{
- :username => 'test',
- :password => 'test'
- }}
-
- # Run shared tests applicable to all supported OSs
- # Note that this function is defined in spec_helper
- generic_tests
-
- # Run test that specialize in checking routing-node config
- # Note that this function is defined in spec_helper
- username_password_tests('test', 'test')
- end
- end
-
end
}
end
end
-
-# ODL username/password tests
-def username_password_tests(username, password)
-
- it {
- should contain_odl_user(username).with(
- :password => password
- )
- }
-end
enable_ha = options.fetch(:enable_ha, false)
ha_node_ips = options.fetch(:ha_node_ips, [])
ha_node_index = options.fetch(:ha_node_index, 0)
- username = options.fetch(:username, 'admin')
- password = options.fetch(:password, 'admin')
# Build script for consumption by Puppet apply
it 'should work idempotently with no errors' do
ha_node_ips=> #{ha_node_ips},
ha_node_index=> #{ha_node_index},
log_levels=> #{log_levels},
- username=> #{username},
- password=> #{password},
}
EOS
it { should be_installed }
end
end
-
-# Shared function for validations related to username/password
-def username_password_validations(options = {})
- # NB: This param default should match the one used by the opendaylight
- # class, which is defined in opendaylight::params
- # TODO: Remove this possible source of bugs^^
- odl_username = options.fetch(:username, 'admin')
- odl_password = options.fetch(:password, 'admin')
- odl_check_url = 'http://127.0.0.1:8080/restconf'
-
- describe file('/opt/opendaylight/idmlight.db.mv.db') do
- it { should be_file }
- end
-
- describe command("sleep 60 && curl -o /dev/null --fail --silent --head -u #{odl_username}:#{odl_password} #{odl_check_url}") do
- its(:exit_status) { should eq 0 }
- end
-end
+++ /dev/null
-require 'puppet'
-require 'puppet/provider/odl_user/idm'
-require 'spec_helper'
-
-provider_class = Puppet::Type.type(:odl_user).provider(:idm)
-
-describe 'Puppet::Type.type(:odl_user).provider(:idm)' do
-
- let :odl_attrs do
- {
- :username => 'admin',
- :ensure => 'present',
- }
- end
-
- let :resource do
- Puppet::Type::Odl_user.new(odl_attrs)
- end
-
- let :provider do
- provider_class.new(resource)
- end
-
- describe 'on create' do
- it 'should call idm to create user' do
- provider.expects(:idm_cmd)
- provider.create
- end
- end
-
- describe "when changing password" do
- it 'should change password' do
- provider.expects(:destroy)
- provider.expects(:idm_cmd)
- provider.password = 'admin'
- end
- end
-end
+++ /dev/null
-require 'puppet'
-require 'puppet/type/odl_user'
-require 'spec_helper'
-
-describe 'Puppet::Type.type(:odl_user)' do
-
- it 'should accept username/password' do
- Puppet::Type.type(:odl_user).new(:username => 'admin', :password => 'admin')
- end
-
-end