Pass all RabbitMQ settings from conductor to Agent
This commit is contained in:
parent
c8887c6b66
commit
1d4538fd9a
@ -14,12 +14,12 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
|
import config
|
||||||
|
import random
|
||||||
|
import string
|
||||||
|
import time
|
||||||
|
|
||||||
import xml_code_engine
|
import xml_code_engine
|
||||||
import config
|
|
||||||
from random import choice
|
|
||||||
import time
|
|
||||||
import string
|
|
||||||
|
|
||||||
|
|
||||||
def update_cf_stack(engine, context, body, template,
|
def update_cf_stack(engine, context, body, template,
|
||||||
@ -53,17 +53,20 @@ def prepare_user_data(context, hostname, service, unit,
|
|||||||
template)) as template_file:
|
template)) as template_file:
|
||||||
init_script = init_script_file.read()
|
init_script = init_script_file.read()
|
||||||
template_data = template_file.read()
|
template_data = template_file.read()
|
||||||
template_data = template_data.replace(
|
|
||||||
'%RABBITMQ_HOST%', settings.host)
|
replacements = {
|
||||||
template_data = template_data.replace(
|
'%RABBITMQ_HOST%': settings.host,
|
||||||
'%RABBITMQ_INPUT_QUEUE%',
|
'%RABBITMQ_INPUT_QUEUE%': '-'.join(
|
||||||
'-'.join([str(context['/dataSource']['name']),
|
[str(context['/dataSource']['name']),
|
||||||
str(service), str(unit)]).lower()
|
str(service), str(unit)]).lower(),
|
||||||
)
|
'%RESULT_QUEUE%': '-execution-results-{0}'.format(
|
||||||
template_data = template_data.replace(
|
str(context['/dataSource']['name'])).lower(),
|
||||||
'%RESULT_QUEUE%',
|
'%RABBITMQ_USER%': settings.login,
|
||||||
'-execution-results-{0}'.format(
|
'%RABBITMQ_PASSWORD%': settings.password,
|
||||||
str(context['/dataSource']['name'])).lower())
|
'%RABBITMQ_VHOST%': settings.virtual_host
|
||||||
|
}
|
||||||
|
|
||||||
|
template_data = set_config_params(template_data, replacements)
|
||||||
|
|
||||||
init_script = init_script.replace(
|
init_script = init_script.replace(
|
||||||
'%WINDOWS_AGENT_CONFIG_BASE64%',
|
'%WINDOWS_AGENT_CONFIG_BASE64%',
|
||||||
@ -73,13 +76,24 @@ def prepare_user_data(context, hostname, service, unit,
|
|||||||
|
|
||||||
return init_script
|
return init_script
|
||||||
|
|
||||||
|
|
||||||
|
def set_config_params(template_data, replacements):
|
||||||
|
for key in replacements:
|
||||||
|
template_data = template_data.replace(key, replacements[key])
|
||||||
|
return template_data
|
||||||
|
|
||||||
|
|
||||||
counter = 0
|
counter = 0
|
||||||
|
|
||||||
|
|
||||||
def int2base(x, base):
|
def int2base(x, base):
|
||||||
digs = string.digits + string.lowercase
|
digs = string.digits + string.lowercase
|
||||||
if x < 0: sign = -1
|
if x < 0:
|
||||||
elif x==0: return '0'
|
sign = -1
|
||||||
else: sign = 1
|
elif x == 0:
|
||||||
|
return '0'
|
||||||
|
else:
|
||||||
|
sign = 1
|
||||||
x *= sign
|
x *= sign
|
||||||
digits = []
|
digits = []
|
||||||
while x:
|
while x:
|
||||||
@ -93,7 +107,7 @@ def int2base(x, base):
|
|||||||
|
|
||||||
def generate_hostname(**kwargs):
|
def generate_hostname(**kwargs):
|
||||||
global counter
|
global counter
|
||||||
prefix = ''.join(choice(string.lowercase) for _ in range(5))
|
prefix = ''.join(random.choice(string.lowercase) for _ in range(5))
|
||||||
timestamp = int2base(int(time.time() * 1000), 36)[:8]
|
timestamp = int2base(int(time.time() * 1000), 36)[:8]
|
||||||
suffix = int2base(counter, 36)
|
suffix = int2base(counter, 36)
|
||||||
counter = (counter + 1) % 1296
|
counter = (counter + 1) % 1296
|
||||||
|
@ -14,11 +14,11 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import jsonpath
|
import jsonpath
|
||||||
import types
|
|
||||||
import re
|
import re
|
||||||
|
import types
|
||||||
|
|
||||||
import xml_code_engine
|
|
||||||
import function_context
|
import function_context
|
||||||
|
import xml_code_engine
|
||||||
|
|
||||||
|
|
||||||
class Workflow(object):
|
class Workflow(object):
|
||||||
|
@ -19,9 +19,9 @@
|
|||||||
</nlog>
|
</nlog>
|
||||||
<appSettings>
|
<appSettings>
|
||||||
<add key="rabbitmq.host" value="%RABBITMQ_HOST%"/>
|
<add key="rabbitmq.host" value="%RABBITMQ_HOST%"/>
|
||||||
<add key="rabbitmq.user" value="keero"/>
|
<add key="rabbitmq.user" value="%RABBITMQ_USER%"/>
|
||||||
<add key="rabbitmq.password" value="keero"/>
|
<add key="rabbitmq.password" value="%RABBITMQ_PASSWORD%"/>
|
||||||
<add key="rabbitmq.vhost" value="keero"/>
|
<add key="rabbitmq.vhost" value="%RABBITMQ_VHOST%"/>
|
||||||
<add key="rabbitmq.inputQueue" value="%RABBITMQ_INPUT_QUEUE%"/>
|
<add key="rabbitmq.inputQueue" value="%RABBITMQ_INPUT_QUEUE%"/>
|
||||||
<add key="rabbitmq.resultExchange" value=""/>
|
<add key="rabbitmq.resultExchange" value=""/>
|
||||||
<add key="rabbitmq.resultRoutingKey" value="%RESULT_QUEUE%"/>
|
<add key="rabbitmq.resultRoutingKey" value="%RESULT_QUEUE%"/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user