167167 default: present
168168 choices:
169169 - present
170- - absent
170+ - absent
171171 wait:
172172 description:
173173 - Flag to enable internal polling to wait for the Virtual Warehouse to achieve the declared state.
@@ -359,29 +359,30 @@ def process(self):
359359 else :
360360 # Begin Drop
361361 if self .target ['status' ] not in self .cdpy .sdk .REMOVABLE_STATES :
362- self .module .warn (
363- "DW Virtual Warehouse not in valid state for Delete operation: %s" % self .target ['status' ])
362+ self .module .fail_json ( msg = "Virtual Warehouse not in valid state for Delete operation: %s" %
363+ self .target ['status' ])
364364 else :
365365 _ = self .cdpy .dw .delete_vw (cluster_id = self .cluster_id , vw_id = self .target ['id' ])
366366 self .changed = True
367- if self .wait :
368- self .cdpy .sdk .wait_for_state (
369- describe_func = self .cdpy .dw .describe_vw ,
370- params = dict (cluster_id = self .cluster_id , vw_id = self .target ['id' ]),
371- field = None , delay = self .delay , timeout = self .timeout
372- )
373- else :
374- self .cdpy .sdk .sleep (self .delay ) # Wait for consistency sync
375- self .virtual_warehouse = self .cdpy .dw .describe_vw (cluster_id = self .cluster_id , vw_id = self .target ['id' ])
367+ if self .wait :
368+ self .cdpy .sdk .wait_for_state (
369+ describe_func = self .cdpy .dw .describe_vw ,
370+ params = dict (cluster_id = self .cluster_id , vw_id = self .target ['id' ]),
371+ field = None , delay = self .delay , timeout = self .timeout
372+ )
373+ else :
374+ self .cdpy .sdk .sleep (self .delay ) # Wait for consistency sync
375+ self .virtual_warehouse = self .cdpy .dw .describe_vw (cluster_id = self .cluster_id , vw_id = self .target ['id' ])
376376 # End Drop
377377 elif self .state == 'present' :
378378 # Begin Config check
379- self .module .warn ("DW Virtual Warehouse already present and reconciliation is not implemented" )
380- if self .wait :
379+ self .module .warn ("Virtual Warehouse already present and reconciliation is not yet implemented" )
380+ if self .wait and not self . module . check_mode :
381381 self .target = self .cdpy .sdk .wait_for_state (
382382 describe_func = self .cdpy .dw .describe_vw ,
383383 params = dict (cluster_id = self .cluster_id , vw_id = self .target ['id' ]),
384- state = self .cdpy .sdk .STARTED_STATES , delay = self .delay , timeout = self .timeout
384+ state = self .cdpy .sdk .STARTED_STATES + self .cdpy .sdk .STOPPED_STATES , delay = self .delay ,
385+ timeout = self .timeout
385386 )
386387 self .virtual_warehouse = self .target
387388 # End Config check
@@ -391,8 +392,7 @@ def process(self):
391392 else :
392393 # Begin Virtual Warehouse Not Found
393394 if self .state == 'absent' :
394- self .module .warn (
395- "DW Virtual Warehouse %s already absent in Cluster %s" % (self .name , self .cluster_id ))
395+ self .module .warn ("Virtual Warehouse is already absent in Cluster %s" % self .cluster_id )
396396 elif self .state == 'present' :
397397 if not self .module .check_mode :
398398 vw_id = self .cdpy .dw .create_vw (cluster_id = self .cluster_id ,
@@ -441,7 +441,7 @@ def main():
441441 )),
442442 application_configs = dict (type = 'dict' ),
443443 ldap_groups = dict (type = 'list' ),
444- enable_sso = dict (type = 'bool' ),
444+ enable_sso = dict (type = 'bool' , default = False ),
445445 tags = dict (type = 'dict' ),
446446 state = dict (type = 'str' , choices = ['present' , 'absent' ], default = 'present' ),
447447 wait = dict (type = 'bool' , default = True ),
@@ -450,7 +450,7 @@ def main():
450450 ),
451451 required_if = [
452452 ['state' , 'absent' , ['id' ]],
453- ['state' , 'present' , ['dbc_id' , 'type' , 'name' ], True ]
453+ ['state' , 'present' , ['dbc_id' , 'type' , 'name' ]]
454454 ],
455455 supports_check_mode = True
456456 )
0 commit comments