def compare_bucket_content(context, args): manifest_path, manifest = _get_path_and_manifest(context, args.manifest_path) s3 = context.aws.client('s3') bucketName = _get_content_bucket(context) manifestDict = _create_manifest_bucket_key_map(context, manifest, manifest_path) for thisKey, thisHash in manifestDict.iteritems(): try: headResponse = s3.head_object(Bucket=bucketName, Key=thisKey) except Exception as e: show_manifest.key_not_found(thisKey) continue show_manifest.hash_comparison_bucket( thisKey, thisHash, _get_bucket_item_hash(headResponse))
def list_bucket_content(context, args): manifest_path, manifest = _get_path_and_manifest(context, args.manifest_path) contentsList = _get_bucket_content_list(context) manifestDict = _create_manifest_bucket_key_map(context, manifest, manifest_path) thisBucketItem = {} for thisBucketItem in contentsList: thisKey = thisBucketItem.get('Key') if thisKey in manifestDict: show_manifest.hash_comparison_bucket( thisKey, manifestDict[thisKey], _get_bucket_item_hash(thisBucketItem)) del manifestDict[thisKey] for remainingKey in manifestDict.keys(): show_manifest.new_local_key(remainingKey)
def _get_unmatched_content(context, manifest, manifest_path, deployment_name): s3 = context.aws.client('s3') bucketName = _get_content_bucket_by_name(context, deployment_name) manifestDict = _create_manifest_bucket_key_map(context, manifest, manifest_path) returnDict = {} for thisKey, thisHash in manifestDict.iteritems(): try: headResponse = s3.head_object(Bucket=bucketName, Key=thisKey) except Exception as e: show_manifest.key_not_found(thisKey) returnDict[thisKey] = thisHash continue show_manifest.hash_comparison_bucket( thisKey, thisHash, _get_bucket_item_hash(headResponse)) if _get_bucket_item_hash(headResponse) != thisHash: returnDict[thisKey] = thisHash return returnDict