Browse Source

Merge pull request #3 from howardabrams/master

Specify the default tenant during user create
Jan Klare 2 years ago
parent
commit
44a257fd4b
2 changed files with 4 additions and 0 deletions
  1. 2
    0
      libraries/openstack_user.rb
  2. 2
    0
      spec/user_spec.rb

+ 2
- 0
libraries/openstack_user.rb View File

@@ -31,12 +31,14 @@ module OpenstackclientCookbook
31 31
 
32 32
     action :create do
33 33
       user = connection.users.find { |u| u.name == user_name }
34
+      project = connection.projects.find { |p| p.name == project_name }
34 35
       if user
35 36
         log "User with name: \"#{user_name}\" already exists"
36 37
       else
37 38
         connection.users.create(
38 39
           name: user_name,
39 40
           email: email,
41
+          default_project_id: project ? project.id : nil,
40 42
           password: password
41 43
         )
42 44
       end

+ 2
- 0
spec/user_spec.rb View File

@@ -65,6 +65,7 @@ describe 'openstackclient_test::user' do
65 65
 
66 66
   let(:found_project) do
67 67
     double :find,
68
+           id: 42,
68 69
            grant_role_to_user: true,
69 70
            revoke_role_from_user: true
70 71
   end
@@ -133,6 +134,7 @@ describe 'openstackclient_test::user' do
133 134
         .with(
134 135
           name: 'myuser',
135 136
           email: 'myemail',
137
+          default_project_id: 42,
136 138
           password: 'mypassword'
137 139
         )
138 140
       chef_run

Loading…
Cancel
Save