Initial commit. Copy from efd1c0fc52ba1f2ed39b1764b14da4add285059d in cosmo-manager