Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Juno #280

Closed
wants to merge 7 commits into from
Closed

Juno #280

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Puppetfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ mod 'aviator',
:git => 'https://github.com/aimonb/puppet_aviator.git'

mod 'ceilometer',
:commit => '01f0a3057d3bdad97637a8c19b24f010a8c070e8',
:commit => 'ee5e035df0bfea5ed69b9f39a345caba5b7fd626',
:git => 'https://github.com/stackforge/puppet-ceilometer.git'

mod 'certmonger',
:commit => '3f86b9973fc30c14a066b0f215023d5f1398b874',
:git => 'https://github.com/rcritten/puppet-certmonger.git'

mod 'cinder',
:commit => '00efa65680314e9364d6aaa559ebada7015dfb7f',
:commit => 'bde992600a63a3debba4b06a27d7cde9119f23ed',
:git => 'https://github.com/stackforge/puppet-cinder.git'

mod 'common',
Expand All @@ -35,7 +35,7 @@ mod 'galera',
:git => 'https://github.com/rohara/puppet-galera.git'

mod 'glance',
:commit => 'f71bab5b7ddac3e1fde4823e67ad4cb21512e0d5',
:commit => '533a3bbb91f11b82cd68b02a22531efd3e3f4119',
:git => 'https://github.com/stackforge/puppet-glance.git'

mod 'gluster',
Expand All @@ -47,7 +47,7 @@ mod 'haproxy',
:git => 'https://github.com/puppetlabs/puppetlabs-haproxy.git'

mod 'heat',
:commit => '46b45265cc2cc3da6d45a89097357a976f045948',
:commit => 'f07c80174f9f8b3f467b0171627e4b2586c55e29',
:git => 'https://github.com/stackforge/puppet-heat.git'

mod 'horizon',
Expand All @@ -67,7 +67,7 @@ mod 'ironic',
:git => 'https://github.com/stackforge/puppet-ironic.git'

mod 'keystone',
:commit => '3bb6ec1281d831b743e3c18587d75227fb96dc19',
:commit => '6d1d79ebd5b69a97dfc6e7cf7d5309643ef73492',
:git => 'https://github.com/stackforge/puppet-keystone.git'

mod 'memcached',
Expand Down Expand Up @@ -95,11 +95,11 @@ mod 'nagios',
:git => 'https://github.com/gildub/puppet-nagios-openstack.git'

mod 'neutron',
:commit => '1e5e1b902964013f7c5c2e7107dcd81ed26db1e5',
:commit => 'cd92789a58d09bbf3d863f46c90871c920cedc75',
:git => 'https://github.com/stackforge/puppet-neutron.git'

mod 'nova',
:commit => '482ca09469f97de8cfbb3fd4f4e08505dfdc8911',
:commit => 'a2d7b4dd4a13803f8612b17e214e3856e283b614',
:git => 'https://github.com/stackforge/puppet-nova.git'

mod 'nssdb',
Expand Down
8 changes: 6 additions & 2 deletions ceilometer/.fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ fixtures:
'apache': 'git://github.com/puppetlabs/puppetlabs-apache.git'
'concat': 'git://github.com/puppetlabs/puppetlabs-concat.git'
'inifile': 'git://github.com/puppetlabs/puppetlabs-inifile'
'keystone': 'git://github.com/stackforge/puppet-keystone.git'
'keystone':
repo: 'git://github.com/stackforge/puppet-keystone.git'
ref: 'origin/stable/juno'
'mysql':
repo: 'git://github.com/puppetlabs/puppetlabs-mysql.git'
ref: 'origin/2.2.x'
'nova': 'git://github.com/stackforge/puppet-nova.git'
'nova':
repo: 'git://github.com/stackforge/puppet-nova.git'
ref: 'origin/stable/juno'
'openstacklib': 'git://github.com/stackforge/puppet-openstacklib.git'
'stdlib': 'git://github.com/puppetlabs/puppetlabs-stdlib.git'
symlinks:
Expand Down
4 changes: 3 additions & 1 deletion cinder/.fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ fixtures:
repositories:
'apt': 'git://github.com/puppetlabs/puppetlabs-apt.git'
'inifile': 'git://github.com/puppetlabs/puppetlabs-inifile'
'keystone': 'git://github.com/stackforge/puppet-keystone.git'
'keystone':
repo: 'git://github.com/stackforge/puppet-keystone.git'
ref: 'origin/stable/juno'
'mysql':
repo: 'git://github.com/puppetlabs/puppetlabs-mysql.git'
ref: 'origin/2.2.x'
Expand Down
2 changes: 1 addition & 1 deletion cinder/manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
}
}
default: {
$iscsi_helper = 'tgtadm'
$iscsi_helper = 'lioadm'
}
}

Expand Down
1 change: 1 addition & 0 deletions cinder/manifests/type_set.pp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
exec {"cinder type-key ${type} set ${key}=${name}":
path => ['/usr/bin', '/bin'],
command => "cinder type-key ${type} set ${key}=${name}",
unless => "cinder extra-specs-list | grep -Eq '\\b${type}\\b.*\\b${key}\\b.*\\b${name}\\b'",
environment => concat($cinder_env, $region_env),
require => Package['python-cinderclient']
}
Expand Down
4 changes: 3 additions & 1 deletion cinder/spec/classes/cinder_volume_iscsi_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@
end

let :facts do
{:osfamily => 'RedHat'}
{:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemmajrelease => '6'}
end

it { should contain_file_line('cinder include').with(
Expand Down
1 change: 1 addition & 0 deletions cinder/spec/defines/cinder_type_set_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
it 'should have its execs' do
should contain_exec('cinder type-key sith set monchichi=hippo').with(
:command => 'cinder type-key sith set monchichi=hippo',
:unless => "cinder extra-specs-list | grep -Eq '\\bsith\\b.*\\bmonchichi\\b.*\\bhippo\\b'",
:environment => [
'OS_TENANT_NAME=admin',
'OS_USERNAME=admin',
Expand Down
4 changes: 3 additions & 1 deletion glance/.fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
fixtures:
repositories:
"apt": "git://github.com/puppetlabs/puppetlabs-apt.git"
"keystone": "git://github.com/stackforge/puppet-keystone.git"
"keystone":
repo: "git://github.com/stackforge/puppet-keystone.git"
ref: "origin/stable/juno"
"mysql":
repo: "git://github.com/puppetlabs/puppetlabs-mysql.git"
ref: 'origin/2.2.x'
Expand Down
8 changes: 6 additions & 2 deletions heat/.fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ fixtures:
repositories:
"inifile": "git://github.com/puppetlabs/puppetlabs-inifile"
'concat': 'git://github.com/puppetlabs/puppetlabs-concat.git'
"keystone": "git://github.com/stackforge/puppet-keystone.git"
"keystone":
repo: "git://github.com/stackforge/puppet-keystone.git"
ref: "origin/stable/juno"
"mysql":
repo: 'git://github.com/puppetlabs/puppetlabs-mysql.git'
ref: 'origin/2.2.x'
"nova": "git://github.com/stackforge/puppet-nova.git"
"nova":
repo: "git://github.com/stackforge/puppet-nova.git"
ref: "origin/stable/juno"
'openstacklib': 'git://github.com/stackforge/puppet-openstacklib.git'
'postgresql': 'git://github.com/puppetlabs/puppet-postgresql.git'
"stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib.git"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def create
properties << '--adminurl'
properties << resource[:admin_url]
end
request('endpoint', 'create', name, resource[:auth], properties)
@instance = request('endpoint', 'create', name, resource[:auth], properties)
end

def exists?
Expand Down
2 changes: 1 addition & 1 deletion keystone/lib/puppet/provider/keystone_role/openstack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

def create
properties = []
request('role', 'create', resource[:name], resource[:auth], properties)
@instance = request('role', 'create', resource[:name], resource[:auth], properties)
end

def exists?
Expand Down
2 changes: 1 addition & 1 deletion keystone/lib/puppet/provider/keystone_service/openstack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def create
properties << '--type'
properties << resource[:type]
end
request('service', 'create', resource[:name], resource[:auth], properties)
@instance = request('service', 'create', resource[:name], resource[:auth], properties)
end

def exists?
Expand Down
2 changes: 1 addition & 1 deletion keystone/lib/puppet/provider/keystone_tenant/openstack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def create
properties << '--description'
properties << resource[:description]
end
request('project', 'create', resource[:name], resource[:auth], properties)
@instance = request('project', 'create', resource[:name], resource[:auth], properties)
end

def exists?
Expand Down
2 changes: 1 addition & 1 deletion keystone/lib/puppet/provider/keystone_user/openstack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def create
properties << '--email'
properties << resource[:email]
end
request('user', 'create', resource[:name], resource[:auth], properties)
@instance = request('user', 'create', resource[:name], resource[:auth], properties)
end

def exists?
Expand Down
74 changes: 39 additions & 35 deletions keystone/lib/puppet/provider/keystone_user_role/openstack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@

desc "Provider to manage keystone role assignments to users."

def initialize(value={})
super(value)
@property_flush = {}
end

def create
properties = []
properties << '--project' << get_project
Expand All @@ -24,23 +19,46 @@ def create
end

def exists?
! instance(resource[:name]).empty?
# If we just ran self.instances, no need to make the request again
# instance() will find it cached in @user_role_hash
if self.class.user_role_hash
return ! instance(resource[:name]).empty?
# If we don't have the hash ready, we don't need to rebuild the
# whole thing just to check on one particular user/role
else
roles = request('user role', 'list', nil, resource[:auth], ['--project', get_project, get_user])
# Since requesting every combination of users, roles, and
# projects is so expensive, construct the property hash here
# instead of in self.instances so it can be used in the role
# and destroy methods
@property_hash[:name] = resource[:name]
if roles.empty?
@property_hash[:ensure] = :absent
else
@property_hash[:ensure] = :present
@property_hash[:roles] = roles.collect do |role|
role[:name]
end
end
return @property_hash[:ensure] == :present
end
end

def destroy
properties = []
properties << '--project' << get_project
properties << '--user' << get_user
if resource[:roles]
resource[:roles].each do |role|
if @property_hash[:roles]
@property_hash[:roles].each do |role|
request('role', 'remove', role, resource[:auth], properties)
end
end
@property_hash[:ensure] = :absent
end


def roles
instance(resource[:name])[:roles]
@property_hash[:roles]
end

def roles=(value)
Expand Down Expand Up @@ -70,18 +88,8 @@ def self.instances
end
end

def instances
instances = build_user_role_hash
instances.collect do |title, roles|
{
:name => title,
:roles => roles
}
end
end

def instance(name)
@instances ||= instances.select { |instance| instance[:name] == name }.first || {}
self.class.user_role_hash.select { |role_name, roles| role_name == name } || {}
end

private
Expand Down Expand Up @@ -120,24 +128,19 @@ def self.get_users(project)
end
end

def build_user_role_hash
hash = {}
projects = get_projects
projects.each do |project|
users = get_users(project)
users.each do |user|
user_roles = request('user role', 'list', nil, resource[:auth], ['--project', project, user])
user_roles.each do |role|
hash["#{user}@#{project}"] ||= []
hash["#{user}@#{project}"] << role[:name]
end
end
end
hash
# Class methods for caching user_role_hash so both class and instance
# methods can access the value
def self.set_user_role_hash(user_role_hash)
@user_role_hash = user_role_hash
end

def self.user_role_hash
@user_role_hash
end

def self.build_user_role_hash
hash = {}
hash = user_role_hash || {}
return hash unless hash.empty?
projects = get_projects
projects.each do |project|
users = get_users(project)
Expand All @@ -149,6 +152,7 @@ def self.build_user_role_hash
end
end
end
set_user_role_hash(hash)
hash
end

Expand Down
12 changes: 10 additions & 2 deletions keystone/lib/puppet/provider/openstack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def self.authenticate_request(service, action, *args)
begin
if(action == 'list')
response = openstack(service, action, '--quiet', '--format', 'csv', args)
response = CSV.parse(response.to_s)
response = parse_csv(response)
keys = response.delete_at(0) # ID,Name,Description,Enabled
rv = response.collect do |line|
hash = {}
Expand All @@ -62,12 +62,13 @@ def self.authenticate_request(service, action, *args)
end
hash
end
elsif(action == 'show')
elsif(action == 'show' || action == 'create')
rv = {}
# shell output is name="value"\nid="value2"\ndescription="value3" etc.
openstack(service, action, '--format', 'shell', args).split("\n").each do |line|
# key is everything before the first "="
key, val = line.split("=", 2)
next unless val # Ignore warnings
# value is everything after the first "=", with leading and trailing double quotes stripped
val = val.gsub(/\A"|"\Z/, '')
rv[key.downcase.to_sym] = val
Expand Down Expand Up @@ -177,4 +178,11 @@ def get_credentials_from_env
self.class.get_credentials_from_env
end

def self.parse_csv(text)
# Ignore warnings - assume legitimate output starts with a double quoted
# string. Errors will be caught and raised prior to this
text = text.split("\n").drop_while { |line| line !~ /^\".*\"/ }.join("\n")
return CSV.parse(text + "\n")
end

end
2 changes: 2 additions & 0 deletions keystone/manifests/ldap.pp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
$user_enabled_attribute = undef,
$user_enabled_mask = undef,
$user_enabled_default = undef,
$user_enabled_invert = undef,
$user_attribute_ignore = undef,
$user_default_project_id_attribute = undef,
$user_allow_create = undef,
Expand Down Expand Up @@ -133,6 +134,7 @@
'ldap/user_enabled_attribute': value => $user_enabled_attribute;
'ldap/user_enabled_mask': value => $user_enabled_mask;
'ldap/user_enabled_default': value => $user_enabled_default;
'ldap/user_enabled_invert': value => $user_enabled_invert;
'ldap/user_attribute_ignore': value => $user_attribute_ignore;
'ldap/user_default_project_id_attribute': value => $user_default_project_id_attribute;
'ldap/user_allow_create': value => $user_allow_create;
Expand Down
Loading