Skip to content

Commit a4188c3

Browse files
committed
NSOL-5942: saving base config before configuring dataset manager
1 parent 1384c14 commit a4188c3

2 files changed

Lines changed: 40 additions & 1 deletion

File tree

netapp_dataops_traditional/netapp_dataops/config/dataset_manager.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,39 @@ def _setup_existing_root_volume(self, config: DatasetManagerConfig) -> None:
198198
self._handle_root_volume_mounting(root_volume_name, root_mountpoint)
199199

200200
def _setup_new_root_volume(self, config: DatasetManagerConfig) -> None:
201-
"""Perform operations for new root volume after config is saved."""
201+
"""Perform operations for new root volume after config is saved.
202+
203+
Note: This method assumes the base ONTAP configuration has already been
204+
saved to disk before being called, as it needs to access ONTAP APIs.
205+
"""
202206
root_volume_name = config.root_volume_name
203207
root_mountpoint = config.root_mountpoint
204208

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

211+
# Verify we can connect to ONTAP before proceeding
212+
try:
213+
from ..traditional.core import _retrieve_config
214+
from ..traditional.exceptions import InvalidConfigError
215+
216+
# Try to retrieve config to verify it exists and is valid
217+
try:
218+
ontap_config = _retrieve_config(print_output=False)
219+
# Verify we have the minimum required fields
220+
if not all(k in ontap_config for k in ['hostname', 'svm', 'dataLif']):
221+
raise InvalidConfigError("Missing required ONTAP configuration fields")
222+
except (InvalidConfigError, FileNotFoundError, KeyError) as e:
223+
logger.info(f" Note: Cannot create root volume - ONTAP configuration not available yet.")
224+
logger.info(f" Dataset Manager configuration has been saved.")
225+
logger.info(f" The root volume will be created when you first use Dataset Manager,")
226+
logger.info(f" or you can create it manually: netapp_dataops_cli.py create volume -n {root_volume_name} -s 1GB")
227+
return
228+
except Exception as e:
229+
logger.info(f" Note: Cannot validate ONTAP connection: {e}")
230+
logger.info(f" Dataset Manager configuration has been saved.")
231+
logger.info(f" Please create the root volume manually or reconfigure later.")
232+
return
233+
207234
while True: # Loop for retrying with different names if needed
208235
try:
209236
# Check if volume already exists

netapp_dataops_traditional/netapp_dataops/config/manager.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,18 @@ def create_interactive_config(self) -> NetAppDataOpsConfig:
126126
dataset_manager_config = None
127127
if PromptUtils.prompt_yes_no("Do you intend to use the toolkit's Dataset Manager functionality?"):
128128
logger.info("\nDataset Manager Configuration:")
129+
130+
# IMPORTANT: Save base ONTAP config to disk BEFORE Dataset Manager setup
131+
# This allows Dataset Manager to connect to ONTAP and create volumes
132+
base_config = NetAppDataOpsConfig(
133+
ontap=ontap_config,
134+
s3=s3_config,
135+
cloud_sync=cloud_sync_config,
136+
dataset_manager=None # Will be added after setup
137+
)
138+
self.save_config(base_config)
139+
140+
# Now Dataset Manager can connect to ONTAP using the saved config
129141
dataset_manager_configurator = DatasetManagerConfigurator()
130142
dataset_manager_config = dataset_manager_configurator.configure_dataset_manager()
131143

0 commit comments

Comments
 (0)