Skip to content

Commit 9a8aff9

Browse files
committed
Add support for iRODS 5.0.x
1 parent e7bd017 commit 9a8aff9

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
integrity checks, rather than running all of them. This can be useful
1212
on larger environments, where running all checks would be very time-consuming
1313
or even not feasible.
14+
* Add support for iRODS 5.0.x
1415

1516
## [1.0.0] - 2022-11-08
1617

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ This script checks the iRODS ICAT database for unexpected issues, specifically:
1414
- Data objects with too few replicas (the default minimum is one replica)
1515
- Missing indexes
1616

17-
The present version of the script is suitable for Postgresql databases. It is compatible with iRODS 4.2.x and 4.3.x.
17+
The present version of the script is suitable for PostgreSQL databases. It is compatible
18+
with iRODS 4.2.x, 4.3.x. and 5.0.x.
1819

1920
# Requirements
2021

icat_tools/utils.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,22 @@
66
def read_database_config(config_filename):
77
with open(config_filename) as configfile:
88
data = json.load(configfile)
9-
return data['plugin_configuration']['database']['postgres']
9+
if 'postgres' in data['plugin_configuration']['database']:
10+
# This basically translates an iRODS 4.2.x/4.3.x format
11+
# database configuration into iRODS 5.0 format
12+
return {k.replace("db_", "", 1): v for (k, v) in
13+
data['plugin_configuration']['database']['postgres'].items()}
14+
else:
15+
return data['plugin_configuration']['database']
1016

1117

1218
def get_connection_database(config):
1319
try:
14-
connection = psycopg2.connect(user=config['db_username'],
15-
password=config['db_password'],
16-
host=config['db_host'],
17-
port=config['db_port'],
18-
database=config['db_name'])
20+
connection = psycopg2.connect(user=config['username'],
21+
password=config['password'],
22+
host=config['host'],
23+
port=config['port'],
24+
database=config['name'])
1925
except (Exception, psycopg2.Error) as error:
2026
print("Error while connecting to database: ", error)
2127
sys.exit(1)

0 commit comments

Comments
 (0)