Added registration of a service endpoint to keystone
Change-Id: I657bbb74e5476ceee923ee6e3eb5e67af11a5abb
This commit is contained in:
parent
11809450b7
commit
565968438e
@ -4,4 +4,4 @@ maintainer_email "hpcs-mon@hp.com"
|
|||||||
license "All rights reserved"
|
license "All rights reserved"
|
||||||
description "Customizes devstack server for use with mini-mon"
|
description "Customizes devstack server for use with mini-mon"
|
||||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||||
version "0.0.3"
|
version "0.0.4"
|
||||||
|
@ -5,7 +5,24 @@ python 'make default keystone users' do
|
|||||||
code <<-EOH
|
code <<-EOH
|
||||||
import keystoneclient
|
import keystoneclient
|
||||||
from keystoneclient.v2_0 import client
|
from keystoneclient.v2_0 import client
|
||||||
import sys
|
|
||||||
|
def add_service_endpoint(key, service_name, endpoint_host):
|
||||||
|
"""Add the Monasca service to the catalog with the specified endpoint, if it doesn't yet exist."""
|
||||||
|
service_names = { service.name: service.id for service in key.services.list() }
|
||||||
|
if service_name in service_names.keys():
|
||||||
|
service_id = service_names[service_name]
|
||||||
|
else:
|
||||||
|
service=key.services.create(name=service_name, service_type='monitoring', description='Monasca monitoring service')
|
||||||
|
service_id = service.id
|
||||||
|
|
||||||
|
for endpoint in key.endpoints.list():
|
||||||
|
if endpoint.service_id == service_id:
|
||||||
|
return
|
||||||
|
|
||||||
|
key.endpoints.create(region="RegionOne", service_id=service_id,
|
||||||
|
publicurl="http://%s:8080/v2.0/" % endpoint_host,
|
||||||
|
adminurl="http://%s:8080/v2.0/" % endpoint_host,
|
||||||
|
internalurl="http://%s:8080/v2.0/" % endpoint_host)
|
||||||
|
|
||||||
def create_user(user_name, password, email,tenant_id):
|
def create_user(user_name, password, email,tenant_id):
|
||||||
user_id = None
|
user_id = None
|
||||||
@ -54,5 +71,7 @@ create_user('mini-mon', 'password', 'mini@mon.com', tenant_id)
|
|||||||
monasca_user_id = create_user('monasca-agent', 'password', 'monasca-agent@mon.com', tenant_id)
|
monasca_user_id = create_user('monasca-agent', 'password', 'monasca-agent@mon.com', tenant_id)
|
||||||
|
|
||||||
create_role(monasca_user_id, 'monasca-agent', tenant_id)
|
create_role(monasca_user_id, 'monasca-agent', tenant_id)
|
||||||
|
|
||||||
|
add_service_endpoint(key, 'monasca', '192.168.10.4')
|
||||||
EOH
|
EOH
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user