updated the agent databag with new role for monasca-agent

updated the split roles as well

add user monasca-agent

had to manually merge data_bags

cleaned up data bag

Change-Id: If5c22a16208d301b363514d9496da6c19252458e
This commit is contained in:
Derrick Johnson 2014-07-30 09:10:02 -07:00
parent 7abe348d9f
commit 11809450b7
4 changed files with 48 additions and 22 deletions

View File

@ -1,31 +1,58 @@
# Sets up a user mini-mon username/password in keystone # Sets up a user mini-mon username/password in keystone
python 'make default keystone user' do python 'make default keystone users' do
action :run action :run
code <<-EOH code <<-EOH
import keystoneclient import keystoneclient
from keystoneclient.v2_0 import client from keystoneclient.v2_0 import client
import sys import sys
def create_user(user_name, password, email,tenant_id):
user_id = None
user_list = key.users.list()
# Create the user if it doesn't exist
for user in user_list:
if user.name == user_name:
user_id = user.id
if user_id is None:
user_id = key.users.create(name=user_name, password=password, email=email, tenant_id=tenant_id, enabled=True)
return user_id
def create_role(user_name, role_name, tenant_id):
role_id = None
for role in key.roles.list():
if role.name == role_name:
role_id = role.id
#create role it doesn't exist
if role_id is None:
role_id = key.roles.create(role_name)
key.roles.add_user_role(user_name, role_id, tenant_id)
def create_tenant(tenant_name):
tenant_id = None
for tenant in key.tenants.list():
if tenant.name == tenant_name:
tenant_id = tenant.id
if tenant_id is None:
tenant_id = key.tenants.create(tenant_name).id
return tenant_id
try: try:
key = client.Client(token='ADMIN', endpoint='http://127.0.0.1:35357/v2.0/') key = client.Client(token='ADMIN', endpoint='http://127.0.0.1:35357/v2.0/')
user_list = key.users.list()
except keystoneclient.exceptions: except keystoneclient.exceptions:
time.sleep(2) # Sometimes chef is too fast and the service is not yet up time.sleep(2) # Sometimes chef is too fast and the service is not yet up
key = client.Client(token='ADMIN', endpoint='http://127.0.0.1:35357/v2.0/') key = client.Client(token='ADMIN', endpoint='http://127.0.0.1:35357/v2.0/')
user_list = key.users.list()
# Create the tenant for mini-mon if it doesn't exist tenant_id = create_tenant('mini-mon')
tenant_id = None create_user('mini-mon', 'password', 'mini@mon.com', tenant_id)
for tenant in key.tenants.list(): monasca_user_id = create_user('monasca-agent', 'password', 'monasca-agent@mon.com', tenant_id)
if tenant.name == 'mini-mon':
tenant_id = tenant.id
if tenant_id is None:
tenant_id = key.tenants.create('mini-mon').id
# Create the user if it doesn't exist create_role(monasca_user_id, 'monasca-agent', tenant_id)
for user in user_list:
if user.name == 'mini-mon':
sys.exit(0)
key.users.create(name='mini-mon', password='password', email='mini@mon.com', tenant_id=tenant_id, enabled=True)
EOH EOH
end end

View File

@ -2,7 +2,6 @@
"id": "mon_credentials", "id": "mon_credentials",
"middleware": { "middleware": {
"serverVip": "192.168.10.5", "serverVip": "192.168.10.5",
"truststore_password": "changeit",
"adminAuthMethod": "password", "adminAuthMethod": "password",
"adminUser": "admin", "adminUser": "admin",
"adminPassword": "password", "adminPassword": "password",

View File

@ -1,7 +1,7 @@
{ {
"id" : "monasca_agent", "id" : "monasca_agent",
"keystone_url": "http://192.168.10.5:35357/v3", "keystone_url": "http://192.168.10.5:35357/v3",
"username": "mini-mon", "username": "monasca-agent",
"password": "password", "password": "password",
"project_name": "mini-mon", "project_name": "mini-mon",
"monasca_api_url" : "http://192.168.10.4:8080/v2.0", "monasca_api_url" : "http://192.168.10.4:8080/v2.0",

View File

@ -1,7 +1,7 @@
{ {
"id" : "monasca_agent", "id" : "monasca_agent",
"keystone_url": "http://192.168.10.5:35357/v3", "keystone_url": "http://192.168.10.5:35357/v3",
"username": "mini-mon", "username": "monasca-agent",
"password": "password", "password": "password",
"project_name": "mini-mon", "project_name": "mini-mon",
"monasca_api_url" : "http://192.168.10.4:8080/v2.0", "monasca_api_url" : "http://192.168.10.4:8080/v2.0",