diff options
Diffstat (limited to 'conductor')
-rw-r--r-- | conductor/conductor/common/__init__.py | 1 | ||||
-rw-r--r-- | conductor/conductor/common/music/api.py | 23 | ||||
-rw-r--r-- | conductor/conductor/common/music/model/search.py | 13 | ||||
-rwxr-xr-x | conductor/conductor/common/utils/conductor_logging_util.py | 6 |
4 files changed, 38 insertions, 5 deletions
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) |