Scoped tokens

This commit is contained in:
Stan Lagun 2013-03-27 21:30:40 +04:00
parent c313c0959a
commit 8c2bf8bfe0
5 changed files with 416 additions and 407 deletions

View File

@ -27,7 +27,7 @@ def task_received(task, message_id):
reporter = reporting.Reporter(rmqclient, message_id, task['id']) reporter = reporting.Reporter(rmqclient, message_id, task['id'])
command_dispatcher = CommandDispatcher( command_dispatcher = CommandDispatcher(
task['id'], rmqclient, task['token']) task['id'], rmqclient, task['token'], task['tenant_id'])
workflows = [] workflows = []
for path in glob.glob("data/workflows/*.xml"): for path in glob.glob("data/workflows/*.xml"):
log.debug('Loading XML {0}'.format(path)) log.debug('Loading XML {0}'.format(path))
@ -79,7 +79,7 @@ class ConductorWorkflowService(service.Service):
with rabbitmq.RmqClient() as rmq: with rabbitmq.RmqClient() as rmq:
rmq.declare('tasks', 'tasks') rmq.declare('tasks', 'tasks')
rmq.declare('task-results') rmq.declare('task-results')
with rmq.open('tasks') as subscription: with rmq.open('tasks2') as subscription:
while True: while True:
msg = subscription.get_message() msg = subscription.get_message()
self.tg.add_thread( self.tg.add_thread(

View File

@ -7,19 +7,26 @@ from command import CommandBase
import conductor.config import conductor.config
from heatclient.client import Client from heatclient.client import Client
import heatclient.exc import heatclient.exc
from keystoneclient.v2_0 import client as ksclient
import types import types
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class HeatExecutor(CommandBase): class HeatExecutor(CommandBase):
def __init__(self, stack, token): def __init__(self, stack, token, tenant_id):
self._update_pending_list = [] self._update_pending_list = []
self._delete_pending_list = [] self._delete_pending_list = []
self._stack = 'e' + stack self._stack = 'e' + stack
settings = conductor.config.CONF.heat settings = conductor.config.CONF.heat
client = ksclient.Client(endpoint=settings.keystone)
scoped_token = client.tokens.authenticate(
tenant_id=tenant_id,
token=token).id
self._heat_client = Client('1', settings.url, self._heat_client = Client('1', settings.url,
token_only=True, token=token) token_only=True, token=scoped_token)
def execute(self, command, callback, **kwargs): def execute(self, command, callback, **kwargs):
log.debug('Got command {0} on stack {1}'.format(command, self._stack)) log.debug('Got command {0} on stack {1}'.format(command, self._stack))

View File

@ -4,9 +4,9 @@ import windows_agent
class CommandDispatcher(command.CommandBase): class CommandDispatcher(command.CommandBase):
def __init__(self, environment_id, rmqclient, token): def __init__(self, environment_id, rmqclient, token, tenant_id):
self._command_map = { self._command_map = {
'cf': cloud_formation.HeatExecutor(environment_id, token), 'cf': cloud_formation.HeatExecutor(environment_id, token, tenant_id),
'agent': windows_agent.WindowsAgentExecutor( 'agent': windows_agent.WindowsAgentExecutor(
environment_id, rmqclient) environment_id, rmqclient)
} }

View File

@ -46,7 +46,8 @@ rabbit_opts = [
] ]
heat_opts = [ heat_opts = [
cfg.StrOpt('url') cfg.StrOpt('url'),
cfg.StrOpt('keystone')
] ]
CONF = cfg.CONF CONF = cfg.CONF

View File

@ -5,6 +5,7 @@ verbose=True
[heat] [heat]
url = http://172.18.124.101:8004/v1/16eb78cbb688459c8308d89678bcef50 url = http://172.18.124.101:8004/v1/16eb78cbb688459c8308d89678bcef50
keystone = http://172.18.124.101:5000/v2.0
[rabbitmq] [rabbitmq]
host = 172.18.124.101 host = 172.18.124.101