Skip to content

Commit

Permalink
removing/updating reference to asgs
Browse files Browse the repository at this point in the history
  • Loading branch information
PhillipsOwen committed Feb 2, 2024
1 parent a132e1e commit f55d423
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
27 changes: 14 additions & 13 deletions src/common/geoserver_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self, _logger=None):
self.logger = LoggingUtil.init_logging("APSVIZ.Archiver.GeoServerUtils", level=log_level, line_format='medium', log_file_path=log_path)

# specify the DBs to gain connectivity to
db_names: tuple = ('asgs', 'apsviz', 'adcirc_obs')
db_names: tuple = ('apsviz', 'adcirc_obs')

# create a DB connection object
self.db_info = PGImplementation(db_names, self.logger)
Expand Down Expand Up @@ -87,12 +87,12 @@ def process_geoserver_rule(self, stats: dict, rule: RuleUtils.Rule) -> (bool, di
The GEOSERVER_REMOVE action removes data file directories as well as DB and GeoServer records.
The base data directory is defined in the EDS secrets GEOSERVER_PROJ_PATH and GEOSERVER_WORKSPACE
and is usually located at "/opt/geoserver/data_dir/data/ADCIRC_2023/<data directories>". The names of the directories are used to as
and is usually located at "/opt/geoserver/data_dir/data/<catalog>>/<data directories>". The names of the directories are used to as
instance ids which can be used to target DB and GeoServer records.
Here is the full set of operations that can be performed on each instance id:
1. remove the obs/mod records from the stations table in the adcirc_obs DB.
2. remove the image.* records from the run properties table in the asgs_dashboard DB.
2. remove the image.* records from the run properties table in the apsviz DB.
3. remove the catalog member records from the apsviz DB.
4. copy, move or remove the geoserver files from the data directory (eg. <base dir>/4362-2023030112-gfsforecast*).
5. copy, move or remove the obs/mod files from the file server (/fileserver/obs_png/4362-2023030112-gfsforecast).
Expand All @@ -117,7 +117,7 @@ def process_geoserver_rule(self, stats: dict, rule: RuleUtils.Rule) -> (bool, di

try:
# create a list of functions to call to perform DB and directory operations
operations: list = [self.perform_obs_mod_db_ops, self.perform_asgs_dashboard_db_ops, self.perform_catalog_db_ops, self.perform_dir_ops]
operations: list = [self.perform_obs_mod_db_ops, self.perform_apsviz_db_ops, self.perform_catalog_db_ops, self.perform_dir_ops]

# for each entity
for instance_id in instance_ids:
Expand Down Expand Up @@ -174,8 +174,7 @@ def process_geoserver_rule(self, stats: dict, rule: RuleUtils.Rule) -> (bool, di

def create_geoserver_store(self, store_type: str, instance_id: str) -> bool:
"""
Adds a GeoServer store for the store type and instance id passed
Adds a GeoServer store for the store type and instance id pas
:param store_type:
:param instance_id:
:return:
Expand All @@ -190,15 +189,17 @@ def create_geoserver_store(self, store_type: str, instance_id: str) -> bool:
# # create the config body
# store_config = json.loads('{"coverageStore": {"name": "' + coverage_store_name + '", "workspace": "' + self.geoserver_workspace + '"}}')
# store_config: dict = {
# 'coverageStore': {'name': instance_id, 'workspace': self.geoserver_workspace, 'url': 'file:data/ADCIRC_2023/test_coverage_store',
# 'coverageStore': {'name': instance_id, 'workspace': self.geoserver_workspace, 'url': 'file:data/{geoserver_workspace}/test_coverage_store',
# 'type': 'imagemosaic'}}

geoserver_workspace: str = os.environ.get('GEOSERVER_WORKSPACE', 'ADCIRC_2024')

# build the URL to the service
url = f'{self.geoserver_url}/rest/workspaces/{self.geoserver_workspace}/{store_type.lower()}'

# create the config request
store_config: dict = {
store_type[:-1]: {'name': instance_id, 'workspace': self.geoserver_workspace, 'url': f'file:data/ADCIRC_2023/{instance_id}',
store_type[:-1]: {'name': instance_id, 'workspace': self.geoserver_workspace, 'url': f'file:data/{geoserver_workspace}/{instance_id}',
'type': 'imagemosaic'}}

# execute the post
Expand Down Expand Up @@ -434,9 +435,9 @@ def perform_dir_ops(self, rule: RuleUtils.Rule, instance_id: str) -> bool:
# return to the caller
return success

def perform_asgs_dashboard_db_ops(self, rule: RuleUtils.Rule, instance_id) -> (bool, object):
def perform_apsviz_db_ops(self, rule: RuleUtils.Rule, instance_id) -> (bool, object):
"""
removes the asgs dashboard DB image.* run prop records associated to the run name
removes the apsviz DB image.* run prop records associated to the run name
:param rule:
:param instance_id:
Expand All @@ -447,17 +448,17 @@ def perform_asgs_dashboard_db_ops(self, rule: RuleUtils.Rule, instance_id) -> (b

# only remove operations are supported
if rule.action_type == ActionType.GEOSERVER_REMOVE:
self.logger.debug('Executing perform_asgs_dashboard_db_ops( %s )', instance_id)
self.logger.debug('Executing perform_apsviz_db_ops( %s )', instance_id)

# execute the call if not in debug mode
if not rule.debug:
# remove the records
success = self.db_info.remove_run_props_db_image_records(instance_id)
else:
self.logger.debug('Debug mode on. Would have executed perform_asgs_dashboard_db_ops( %s )', instance_id)
self.logger.debug('Debug mode on. Would have executed perform_apsviz_db_ops( %s )', instance_id)
else:
# log the error
self.logger.warning('Warning: Only remove operations are supported in perform_asgs_dashboard_db_ops()')
self.logger.warning('Warning: Only remove operations are supported in perform_apsviz_db_ops()')

# set the failure flag
success = False
Expand Down
4 changes: 2 additions & 2 deletions src/common/pg_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def is_tropical_run(self, run_name: str) -> bool:

def remove_run_props_db_image_records(self, run_name: str):
"""
Removes the asgs dashboard image run props that are associated to the instance id from the DB.
Removes the apsviz image run props that are associated to the instance id from the DB.
"""
# init the return value
Expand All @@ -134,7 +134,7 @@ def remove_run_props_db_image_records(self, run_name: str):
sql = f"SELECT remove_image_run_props('{run_name}')"

# execute the sql
sql_ret = self.exec_sql('asgs', sql)
sql_ret = self.exec_sql('apsviz', sql)

# check the result
if sql_ret < 0:
Expand Down
1 change: 0 additions & 1 deletion src/common/rule_enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class SyncSystemType(int, Enum):
"""
APSVIZ_DB = 1
GEOSERVER = 2
ASGS_DB = 3
OBS_MOD_DB = 4
NONE = 99

Expand Down
2 changes: 1 addition & 1 deletion src/test/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_db_connection_creation():
:return:
"""
# specify the DBs to gain connectivity to
db_names: tuple = ('asgs', 'apsviz', 'adcirc_obs')
db_names: tuple = ('apsviz', 'adcirc_obs')

# create a DB connection object
db_info = PGImplementation(db_names)
Expand Down

0 comments on commit f55d423

Please sign in to comment.