diff --git a/congress/datasources/json_ingester/exec_api.py b/congress/datasources/json_ingester/exec_api.py index 55342a86f..0d71fc9cb 100644 --- a/congress/datasources/json_ingester/exec_api.py +++ b/congress/datasources/json_ingester/exec_api.py @@ -24,10 +24,10 @@ from oslo_concurrency import lockutils from oslo_config import cfg from oslo_log import log as logging import psycopg2 -from psycopg2 import sql import requests from congress.datasources import datasource_utils +from congress.datasources.json_ingester import sql from congress import exception diff --git a/congress/datasources/json_ingester/json_ingester.py b/congress/datasources/json_ingester/json_ingester.py index c8bd3297d..38baf20cd 100644 --- a/congress/datasources/json_ingester/json_ingester.py +++ b/congress/datasources/json_ingester/json_ingester.py @@ -25,12 +25,12 @@ from jsonpath_rw import parser from oslo_config import cfg from oslo_log import log as logging import psycopg2 -from psycopg2 import sql import requests from congress.api import base as api_base from congress.datasources import datasource_driver from congress.datasources import datasource_utils +from congress.datasources.json_ingester import sql from congress.dse2 import data_service from congress import exception diff --git a/congress/datasources/json_ingester/sql.py b/congress/datasources/json_ingester/sql.py new file mode 100644 index 000000000..6ad39a741 --- /dev/null +++ b/congress/datasources/json_ingester/sql.py @@ -0,0 +1,36 @@ +# Copyright (c) 2019 VMware, Inc. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +''' +This module provides a minimal implementation psycopg2.sql features used by +Congress. The purpose is to avoid requiring psycopg2>=2.7 which is not +available in CentOS 7. +''' +from __future__ import print_function +from __future__ import division +from __future__ import absolute_import + +import re + + +def SQL(input_statement): + return input_statement + + +def Identifier(identifier): + '''Validate and return quoted SQL identifier.''' + if re.search('^[a-zA-Z_][a-zA-Z0-9_]*$', identifier): + return '"' + identifier + '"' + else: + raise Exception('Unacceptable SQL identifier: {}'.format(identifier)) diff --git a/lower-constraints.txt b/lower-constraints.txt index 06f710cf0..192329c0c 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -84,7 +84,7 @@ pika-pool==0.1.3 pika==0.10.0 ply==3.11 prettytable==0.7.2 -psycopg2==2.7 +psycopg2==2.5.1 PuLP==1.4.1 pycadf==2.7.0 pycparser==2.18 diff --git a/requirements.txt b/requirements.txt index c10cfe381..21bf087d0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,7 @@ # process, which may cause wedges in the gate later. eventlet!=0.18.3,!=0.20.1,>=0.18.2 # MIT -jsonschema<3.0.0,>=2.6.0 # MIT +jsonschema>=2.6.0 # MIT PuLP>=1.4.1 # MIT keystoneauth1>=3.4.0 # Apache-2.0 keystonemiddleware>=4.17.0 # Apache-2.0 @@ -26,7 +26,7 @@ alembic>=0.8.10 # MIT cryptography>=2.1 # BSD/Apache-2.0 netaddr>=0.7.18 # BSD jsonpath-rw<2.0,>=1.2.0 # Apache-2.0 -psycopg2>=2.7 # LGPL/ZPL +psycopg2>=2.5.1 # LGPL/ZPL python-dateutil>=2.5.3 # BSD python-glanceclient>=2.8.0 # Apache-2.0 requests>=2.14.2,!=2.20.0 # Apache-2.0