def execute(self, context: 'Context'): redshift_hook = RedshiftHook(aws_conn_id=self.aws_conn_id) cluster_state = redshift_hook.cluster_status( cluster_identifier=self.cluster_identifier) if cluster_state == 'available': self.log.info("Pausing Redshift cluster %s", self.cluster_identifier) redshift_hook.get_conn().pause_cluster( ClusterIdentifier=self.cluster_identifier) else: self.log.warning( "Unable to pause cluster since cluster is currently in status: %s", cluster_state)
def execute(self, context): redshift_hook = RedshiftHook(aws_conn_id=self.aws_conn_id) cluster_state = redshift_hook.cluster_status( cluster_identifier=self.cluster_identifier) if cluster_state == 'paused': self.log.info("Starting Redshift cluster %s", self.cluster_identifier) redshift_hook.get_conn().resume_cluster( ClusterIdentifier=self.cluster_identifier) else: self.log.warning( "Unable to resume cluster since cluster is currently in status: %s", cluster_state)