Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

Commit

Permalink
Merge pull request #43 from s-t-e-v-e-n-k/backport-trove-random-password
Browse files Browse the repository at this point in the history
Backport trove random password
  • Loading branch information
vuntz committed Sep 14, 2016
2 parents def9604 + 4a778b5 commit 932298f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
2 changes: 2 additions & 0 deletions chef/data_bags/crowbar/bc-template-trove.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"cinder_instance": "none",
"rabbitmq_instance": "none",
"volume_support": false,
"service_user": "trove",
"db": {
"password": "",
"user": "trove",
Expand All @@ -22,6 +23,7 @@
"trove": {
"crowbar-revision": 1,
"crowbar-applied": false,
"schema-revision": 2,
"element_states": {
"trove-server": [ "readying", "ready", "applying" ]
},
Expand Down
3 changes: 3 additions & 0 deletions chef/data_bags/crowbar/bc-template-trove.schema
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"swift_instance": { "type": "str", "required": true },
"rabbitmq_instance": { "type": "str", "required": true },
"volume_support": { "type": "bool", "required": true },
"service_user": { "type": "str", "required": true },
"service_password": { "type": "str" },
"db": {
"type": "map",
"required": true,
Expand Down Expand Up @@ -47,6 +49,7 @@
"crowbar-status": { "type": "str" },
"crowbar-failed": { "type": "str" },
"crowbar-queued": { "type": "bool" },
"schema-revision": { "type": "int" },
"element_states": {
"type": "map",
"mapping": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
def upgrade ta, td, a, d
a['trove']['db'] = {}
a['trove']['db']['password'] = nil
a['trove']['db']['user'] = 'trove'
a['trove']['db']['database'] = 'trove'
unless a.key? "db"
a["db"] = {}
a["db"]["password"] = nil
a["db"]["user"] = "trove"
a["db"]["database"] = "trove"
end
return a, d
end

def downgrade ta, td, a, d
a['trove'].delete 'db'
a.delete 'db'
return a, d
end
16 changes: 16 additions & 0 deletions chef/data_bags/crowbar/migrate/trove/002_add_service_details.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
def upgrade(ta, td, a, d)
# Use a class variable, since migrations are run twice.
unless defined?(@@trove_service_password)
service = ServiceObject.new "fake-logger"
@@trove_service_password = service.random_password
end
a["service_user"] = ta["service_user"]
a["service_password"] = @@trove_service_password
return a, d
end

def downgrade(ta, td, a, d)
a.delete("service_user")
a.delete("service_password")
return a, d
end
1 change: 1 addition & 0 deletions crowbar_framework/app/models/trove_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def create_proposal
base["attributes"][@bc_name]["swift_instance"] = find_dep_proposal("swift", true)
base["attributes"][@bc_name]["rabbitmq_instance"] = find_dep_proposal("rabbitmq")
base["attributes"][@bc_name]["db"]["password"] = random_password
base["attributes"][@bc_name]["service_password"] = random_password

# assign a default node to the trove-server role
nodes = NodeObject.all
Expand Down

0 comments on commit 932298f

Please sign in to comment.