summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIkram Ikramullah <ikram@research.att.com>2018-03-23 09:38:24 -0400
committerIkram Ikramullah <ikram@research.att.com>2018-03-23 09:39:31 -0400
commit519b0cac34c403fcc482dba2b41ed614f122ddf2 (patch)
tree0dee2d2e4561a25683a339691f008ac0529c1b11
parent9c7878cd58992d239bc1828d192cbaa8519b3452 (diff)
Accommodate Changes for Music 2.4.x
Issue-ID: OPTFRA-199 Change-Id: Ieadb1ae38621cd406af384458a9fce6ffdd15f0c Signed-off-by: Ikram Ikramullah <ikram@research.att.com>
-rwxr-xr-xconductor.conf25
-rw-r--r--conductor/conductor/common/__init__.py1
-rw-r--r--conductor/conductor/common/music/api.py23
-rw-r--r--conductor/conductor/common/music/model/search.py13
-rwxr-xr-xconductor/conductor/common/utils/conductor_logging_util.py6
5 files changed, 58 insertions, 10 deletions
diff --git a/conductor.conf b/conductor.conf
index d6e85e5..1a2dfac 100755
--- a/conductor.conf
+++ b/conductor.conf
@@ -8,7 +8,7 @@
#api_paste_config = api_paste.ini
# Music keyspace for content (string value)
-keyspace = conductor_rui_test_active
+keyspace = conductor_ikram
#
# From oslo.log
@@ -165,6 +165,15 @@ certificate_authority_bundle_file =/usr/local/bin/bundle.pem
# Minimum value: 1
#default_api_return_limit = 100
+[conductor_api]
+
+# Basic Authentication Username (string value)
+username = admin1
+
+# Basic Authentication Password (string value)
+password = plan.15
+
+basic_auth_secure = True
[controller]
@@ -207,7 +216,7 @@ concurrent = true
#
# Music keyspace for messages (string value)
-#keyspace = conductor_rpc
+keyspace = conductor_ikram_rpc
# Wait interval while checking for a message response. Default value is 1
# second. (integer value)
@@ -236,9 +245,14 @@ timeout = 300
#
# From conductor
#
-
+music_new_version = True
# Base URL for Music REST API without a trailing slash. (string value)
-server_url = http://135.25.84.108:8080/MUSIC/rest
+server_url = http://135.197.226.30:8080/MUSIC/rest/v2
+version = v2
+music_version = "2.4.21"
+aafuser = conductor
+aafpass = c0nduct0r
+aafns = conductor
# DEPRECATED: List of hostnames (round-robin access) (list value)
# This option is deprecated for removal.
@@ -260,7 +274,7 @@ server_url = http://135.25.84.108:8080/MUSIC/rest
# Lock timeout (integer value)
#lock_timeout = 10
-
+replication_factor = 3
# Log debug messages. Default value is False. (boolean value)
#debug = false
@@ -326,3 +340,4 @@ concurrent = true
[reservation]
concurrent = true
+
diff --git a/conductor/conductor/common/__init__.py b/conductor/conductor/common/__init__.py
index 4d222ec..9bcf381 100644
--- a/conductor/conductor/common/__init__.py
+++ b/conductor/conductor/common/__init__.py
@@ -33,6 +33,7 @@ def music_api(configuration):
kwargs = {
'host': configuration.get('host'),
'port': configuration.get('port'),
+ 'version': configuration.get('version'),
'replication_factor': configuration.get('replication_factor'),
}
api_instance = api.API(**kwargs)
diff --git a/conductor/conductor/common/music/api.py b/conductor/conductor/common/music/api.py
index 987e40d..306f016 100644
--- a/conductor/conductor/common/music/api.py
+++ b/conductor/conductor/common/music/api.py
@@ -37,7 +37,7 @@ global MUSIC_API
MUSIC_API_OPTS = [
cfg.StrOpt('server_url',
- default='http://controller:8080/MUSIC/rest',
+ default='http://controller:8080/MUSIC/rest/v2',
help='Base URL for Music REST API without a trailing slash.'),
cfg.ListOpt('hostnames',
deprecated_for_removal=True,
@@ -83,6 +83,16 @@ MUSIC_API_OPTS = [
help='Name of the third data center'),
cfg.IntOpt('third_datacenter_replicas',
help='Number of replicas in third data center'),
+ cfg.BoolOpt('music_new_version',
+ help='new or old version'),
+ cfg.StrOpt('music_version',
+ help='for version'),
+ cfg.StrOpt('aafuser',
+ help='for header value'),
+ cfg.StrOpt('aafpass',
+ help='for header value'),
+ cfg.StrOpt('aafns',
+ help='for header value'),
]
CONF.register_opts(MUSIC_API_OPTS, group='music_api')
@@ -112,7 +122,7 @@ class MusicAPI(object):
port = CONF.music_api.port or 8080
path = CONF.music_api.path or '/MUSIC/rest'
server_url = 'http://{}:{}/{}'.format(
- host, port, path.rstrip('/').lstrip('/'))
+ host, port, version, path.rstrip('/').lstrip('/'))
kwargs = {
'server_url': server_url,
@@ -122,6 +132,15 @@ class MusicAPI(object):
}
self.rest = rest.REST(**kwargs)
+ if(CONF.music_api.music_new_version):
+ MUSIC_version = CONF.music_api.music_version.split(".")
+
+ self.rest.session.headers['content-type'] = 'application/json'
+ self.rest.session.headers['X-patchVersion'] = MUSIC_version[2]
+ self.rest.session.headers['ns'] = CONF.music_api.aafns
+ self.rest.session.headers['userId'] = CONF.music_api.aafuser
+ self.rest.session.headers['password'] = CONF.music_api.aafpass
+
self.lock_ids = {}
# TODO(jdandrea): Allow override at creation time.
diff --git a/conductor/conductor/common/music/model/search.py b/conductor/conductor/common/music/model/search.py
index 7564b75..9680da9 100644
--- a/conductor/conductor/common/music/model/search.py
+++ b/conductor/conductor/common/music/model/search.py
@@ -72,13 +72,22 @@ class Query(object):
kwargs = self.__kwargs()
rows = api.MUSIC_API.row_read(
pk_name=pk_name, pk_value=pk_value, **kwargs)
- return self.__rows_to_objects(rows).first()
+
+ if 'result' in rows:
+ return (self.__rows_to_objects(rows['result']).first())
+ else:
+ return (self.__rows_to_objects(rows).first())
def all(self):
"""Return all objects"""
kwargs = self.__kwargs()
rows = api.MUSIC_API.row_read(**kwargs)
- return self.__rows_to_objects(rows)
+
+ # Accommodate both Music 2.1 and 2.2 responses
+ if 'result' in rows:
+ return self.__rows_to_objects(rows['result'])
+ else:
+ return self.__rows_to_objects(rows)
def get_plan_by_id(self, plan_id):
"""Return the plan with specific id"""
diff --git a/conductor/conductor/common/utils/conductor_logging_util.py b/conductor/conductor/common/utils/conductor_logging_util.py
index 718388e..13da6ff 100755
--- a/conductor/conductor/common/utils/conductor_logging_util.py
+++ b/conductor/conductor/common/utils/conductor_logging_util.py
@@ -13,6 +13,10 @@ class LoggerFilter(logging.Filter):
def getTransactionId(keyspace, plan_id):
""" get transaction id from a pariticular plan in MUSIC """
rows = api.API().row_read(keyspace, "plans", "id", plan_id)
+
+ if 'result' in rows:
+ rows = rows['result']
+
for row_id, row_value in rows.items():
template = row_value['template']
if template:
@@ -41,4 +45,4 @@ def setLoggerFilter(logger, keyspace, plan_id):
handler.setFormatter(error_formatter)
else:
handler.setFormatter(generic_formatter)
- handler.addFilter(logger_filter) \ No newline at end of file
+ handler.addFilter(logger_filter)