示例#1
0
 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 == '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 poke(self, context):
     self.log.info('Poking for status : %s\nfor cluster %s',
                   self.target_status, self.cluster_identifier)
     hook = RedshiftHook(aws_conn_id=self.aws_conn_id)
     return hook.cluster_status(
         self.cluster_identifier) == self.target_status
示例#3
0
 def test_cluster_status_returns_cluster_not_found(self):
     self._create_clusters()
     hook = RedshiftHook(aws_conn_id='aws_default')
     status = hook.cluster_status('test_cluster_not_here')
     self.assertEqual(status, 'cluster_not_found')
示例#4
0
 def test_cluster_status_returns_available_cluster(self):
     self._create_clusters()
     hook = RedshiftHook(aws_conn_id='aws_default')
     status = hook.cluster_status('test_cluster')
     self.assertEqual(status, 'available')