def DetectStorage(self): """Detects the storage backend. Only AuFS is currently supported. More info : https://docs.docker.com/engine/userguide/storagedriver/ http://jpetazzo.github.io/assets/2015-06-04-deep-dive-into-docker-storage-drivers.html#60 Returns: Storage: a Storage object. Raises: BadStorageException: If the storage backend couldn't be detected. """ if not os.path.isdir(self.docker_directory): error_msg = ('{0:s} is not a Docker directory\n' 'Please specify the Docker\'s directory path.\n' 'hint: python {1:s} -r /var/lib/docker').format( self.docker_directory, sys.argv[0]) raise BadStorageException(error_msg) if os.path.isfile( os.path.join(self.docker_directory, 'repositories-aufs')): # Handles Docker engine storage versions 1.9 and below. return aufs.AufsStorage(docker_directory=self.docker_directory, docker_version=1) elif os.path.isdir(os.path.join(self.docker_directory, 'aufs')): return aufs.AufsStorage(docker_directory=self.docker_directory) elif os.path.isdir(os.path.join(self.docker_directory, 'overlay')): return overlay.OverlayStorage( docker_directory=self.docker_directory) else: return None
def testPrettyPrintJSON(self): test_storage_object = aufs.AufsStorage() test_dict = {'test': [{'dict1': {'key1': 'val1'}, 'dict2': None}]} test_json = json.dumps(test_dict) expected_string = ( '{\n "test": [\n {\n "dict1": {\n' ' "key1": "val1"\n }, \n' ' "dict2": null\n }\n ]\n}') self.assertEqual(expected_string, test_storage_object._PrettyPrintJSON(test_json))