Skip to content

Commit c476ce4

Browse files
committed
NSOL-5942: fixing dataset manager config when no config file exists
1 parent d391d30 commit c476ce4

1 file changed

Lines changed: 47 additions & 5 deletions

File tree

netapp_dataops_traditional/netapp_dataops/config/dataset_manager.py

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,9 @@ def _setup_existing_root_volume(self, config: DatasetManagerConfig) -> None:
167167
volume_info = self._get_volume_info(root_volume_name)
168168

169169
if volume_info is None:
170-
logger.info(f" Warning: Volume '{root_volume_name}' not found on ONTAP.")
171-
logger.info(" Configuration has been saved. Please verify the volume name and try setup again.")
170+
logger.info(f" Note: Cannot validate volume '{root_volume_name}' on ONTAP at this time.")
171+
logger.info(" Configuration has been saved. Volume validation will occur when you use Dataset Manager.")
172+
# Skip mounting setup since we can't validate the volume
172173
return
173174

174175
# Check junction path
@@ -203,6 +204,19 @@ def _setup_new_root_volume(self, config: DatasetManagerConfig) -> None:
203204

204205
logger.info(f"\n Setting up new Dataset Manager root volume '{root_volume_name}'...")
205206

207+
# Check if we can connect to ONTAP
208+
from ..traditional.core import _retrieve_config
209+
from ..traditional.exceptions import InvalidConfigError
210+
211+
try:
212+
_retrieve_config(print_output=False)
213+
except (InvalidConfigError, FileNotFoundError):
214+
# Base config doesn't exist yet - defer volume creation
215+
logger.info(f" Note: Cannot create root volume on ONTAP - base configuration not yet complete.")
216+
logger.info(f" Configuration has been saved.")
217+
logger.info(f" Please create the root volume '{root_volume_name}' manually or reconfigure after base setup is complete.")
218+
return
219+
206220
while True: # Loop for retrying with different names if needed
207221
try:
208222
# Check if volume already exists
@@ -250,8 +264,23 @@ def _setup_new_root_volume(self, config: DatasetManagerConfig) -> None:
250264
self._handle_root_volume_mounting(root_volume_name, root_mountpoint)
251265

252266
def _get_volume_info(self, volume_name: str) -> Optional[Dict[str, Any]]:
253-
"""Get volume information from ONTAP."""
267+
"""Get volume information from ONTAP.
268+
269+
Returns None if ONTAP connection cannot be established (e.g., during initial config).
270+
"""
254271
try:
272+
# Check if base ONTAP config exists before trying to connect
273+
from ..traditional.core import _retrieve_config
274+
from ..traditional.exceptions import InvalidConfigError
275+
276+
try:
277+
_retrieve_config(print_output=False)
278+
except (InvalidConfigError, FileNotFoundError):
279+
# Base config doesn't exist yet - can't connect to ONTAP
280+
if self.print_output:
281+
logger.info(f" Note: Cannot validate volume on ONTAP - base configuration not yet complete")
282+
return None
283+
255284
# Use list_volumes to find the specific volume
256285
# Always suppress output to avoid displaying volume lists during user input
257286
volumes = volume_operations.list_volumes(print_output=False)
@@ -261,12 +290,25 @@ def _get_volume_info(self, volume_name: str) -> Optional[Dict[str, Any]]:
261290
return None
262291
except Exception as e:
263292
if self.print_output:
264-
logger.info(f"Error retrieving volume information: {e}")
293+
logger.info(f" Error retrieving volume information: {e}")
265294
return None
266295

267296
def _junction_path_exists(self, junction_path: str, exclude_volume: str = None) -> bool:
268-
"""Check if a junction path is already in use by any volume."""
297+
"""Check if a junction path is already in use by any volume.
298+
299+
Returns False if ONTAP connection cannot be established.
300+
"""
269301
try:
302+
# Check if base ONTAP config exists before trying to connect
303+
from ..traditional.core import _retrieve_config
304+
from ..traditional.exceptions import InvalidConfigError
305+
306+
try:
307+
_retrieve_config(print_output=False)
308+
except (InvalidConfigError, FileNotFoundError):
309+
# Base config doesn't exist yet - can't check junction paths
310+
return False
311+
270312
# Always suppress output to avoid displaying volume lists during validation
271313
volumes = volume_operations.list_volumes(print_output=False)
272314
for volume in volumes:

0 commit comments

Comments
 (0)