@@ -415,38 +415,35 @@ def process(self):
415415 if existing ['status' ] in self .cdpy .sdk .FAILED_STATES :
416416 self .module .fail_json (msg = 'Attempting to restart a failed datalake' )
417417
418- # Warn if attempting to start an datalake amidst the creation cycle
419- elif existing ['status' ] in self .cdpy .sdk .CREATION_STATES :
418+ # Check for Datalake actions during create or started
419+ elif existing ['status' ] in self .cdpy .sdk .CREATION_STATES + self . cdpy . sdk . STARTED_STATES :
420420 # Reconcile and error if specifying invalid cloud parameters
421421 if self .environment is not None :
422422 env = self .cdpy .environments .describe_environment (self .environment )
423-
424423 if env ['crn' ] != existing ['environmentCrn' ]:
425424 self .module .fail_json (
426425 msg = "Datalake exists in a different Environment: %s" % existing ['environmentCrn' ])
427-
428- # Check for changes
429- mismatch = self ._reconcile_existing_state (existing )
430- if mismatch :
431- msg = ''
432- for m in mismatch :
433- msg += "Parameter '%s' found to be '%s'\n " % (m [0 ], m [1 ])
434- self .module .fail_json (
435- msg = 'Datalake exists and differs from expected:\n ' + msg , violations = mismatch )
426+ # Check for changes
427+ mismatch = self ._reconcile_existing_state (existing )
428+ if mismatch :
429+ msg = ''
430+ for m in mismatch :
431+ msg += "Parameter '%s' found to be '%s'\n " % (m [0 ], m [1 ])
432+ self .module .fail_json (
433+ msg = 'Datalake exists and differs from expected:\n ' + msg , violations = mismatch )
434+ # Wait
435+ if not self .wait :
436+ self .module .warn ('Datalake already creating or started, changes may not be possible' )
436437 else :
437- if not self .wait :
438- self .module .warn ('Attempting to modify a datalake during its creation cycle' )
439-
440- else :
441- # Wait for creation to complete if previously requested and still running
442- self .datalake = self .cdpy .sdk .wait_for_state (
443- describe_func = self .cdpy .datalake .describe_datalake ,
444- params = dict (name = self .name ),
445- field = 'status' ,
446- state = 'RUNNING' ,
447- delay = self .delay ,
448- timeout = self .timeout
449- )
438+ # Wait for creation to complete if previously requested and still running
439+ self .datalake = self .cdpy .sdk .wait_for_state (
440+ describe_func = self .cdpy .datalake .describe_datalake ,
441+ params = dict (name = self .name ),
442+ field = 'status' ,
443+ state = 'RUNNING' ,
444+ delay = self .delay ,
445+ timeout = self .timeout
446+ )
450447 # Else create the datalake if not exists already
451448 else :
452449 if self .environment is not None :
@@ -550,16 +547,16 @@ def _configure_payload(self):
550547 def _reconcile_existing_state (self , existing ):
551548 mismatched = list ()
552549
553- if existing ['cloudPlatform' ] == 'AWS' :
550+ if 'cloudPlatform' in existing and existing ['cloudPlatform' ] == 'AWS' :
554551 if self .instance_profile is not None and \
555552 self .instance_profile != existing ['awsConfiguration' ]['instanceProfile' ]:
556553 mismatched .append (['instance_profile' , existing ['awsConfiguration' ]['instanceProfile' ]])
557554
558- if self .storage is not None :
559- self .module .warn ("Updating an existing Datalake's 'storage'"
560- "directly is not supported at this time. If "
561- "you need to change the storage, explicitly "
562- "delete and recreate the Datalake." )
555+ if self .storage is not None :
556+ self .module .warn ("Updating an existing Datalake's 'storage' "
557+ "directly is not supported at this time. If "
558+ "you need to change the storage, explicitly "
559+ "delete and recreate the Datalake." )
563560
564561 if self .runtime :
565562 self .module .warn ("Updating an existing Datalake's 'runtime' "
0 commit comments