def get_info_for_reshard(stream_details):
 min_hash_key = 0
 max_hash_key = 0
 stream_details['OpenShards'] = []
 for shard in stream_details['Shards']:
  shard_id = shard['ShardId']
  if ('EndingSequenceNumber' in shard['SequenceNumberRange']):
   log.debug('skipping closed shard {0}'.format(shard_id))
   continue
  stream_details['OpenShards'].append(shard)
  shard['HashKeyRange']['StartingHashKey'] = long_int(shard['HashKeyRange']['StartingHashKey'])
  shard['HashKeyRange']['EndingHashKey'] = long_int(shard['HashKeyRange']['EndingHashKey'])
  if (shard['HashKeyRange']['StartingHashKey'] < min_hash_key):
   min_hash_key = shard['HashKeyRange']['StartingHashKey']
  if (shard['HashKeyRange']['EndingHashKey'] > max_hash_key):
   max_hash_key = shard['HashKeyRange']['EndingHashKey']
 stream_details['OpenShards'].sort(key=(lambda shard: long_int(shard['HashKeyRange']['StartingHashKey'])))
 return (min_hash_key, max_hash_key, stream_details)

def get_info_for_reshard ( stream_details ) : min_hash_key = 0 max_hash_key = 0 stream_details [ 'OpenShards' ] = [ ] for shard in stream_details [ 'Shards' ] : shard_id = shard [ 'ShardId' ] if ( 'EndingSequenceNumber' in shard [ 'SequenceNumberRange' ] ) : log . debug ( 'skipping closed shard {0}' . format ( shard_id ) ) continue stream_details [ 'OpenShards' ] . append ( shard ) shard [ 'HashKeyRange' ] [ 'StartingHashKey' ] = long_int ( shard [ 'HashKeyRange' ] [ 'StartingHashKey' ] ) shard [ 'HashKeyRange' ] [ 'EndingHashKey' ] = long_int ( shard [ 'HashKeyRange' ] [ 'EndingHashKey' ] ) if ( shard [ 'HashKeyRange' ] [ 'StartingHashKey' ] < min_hash_key ) : min_hash_key = shard [ 'HashKeyRange' ] [ 'StartingHashKey' ] if ( shard [ 'HashKeyRange' ] [ 'EndingHashKey' ] > max_hash_key ) : max_hash_key = shard [ 'HashKeyRange' ] [ 'EndingHashKey' ] stream_details [ 'OpenShards' ] . sort ( key = ( lambda shard : long_int ( shard [ 'HashKeyRange' ] [ 'StartingHashKey' ] ) ) ) return ( min_hash_key , max_hash_key , stream_details )
collect some data: number of open shards .