3 final class AlmanacKeys
extends Phobject
{
5 public static function getKeyPath($key_name) {
6 $root = dirname(phutil_get_library_root('phabricator'));
7 $keys = $root.'/conf/keys/';
9 return $keys.ltrim($key_name, '/');
12 public static function getDeviceID() {
13 // While running unit tests, ignore any configured device identity.
15 PhabricatorTestCase
::assertExecutingUnitTests();
17 } catch (Exception
$ex) {
21 $device_id_path = self
::getKeyPath('device.id');
23 if (Filesystem
::pathExists($device_id_path)) {
24 return trim(Filesystem
::readFile($device_id_path));
30 public static function getLiveDevice() {
31 $device_id = self
::getDeviceID();
36 $cache = PhabricatorCaches
::getRequestCache();
37 $cache_key = 'almanac.device.self';
39 $device = $cache->getKey($cache_key);
41 $viewer = PhabricatorUser
::getOmnipotentUser();
42 $device = id(new AlmanacDeviceQuery())
44 ->withNames(array($device_id))
49 'This host has device ID "%s", but there is no corresponding '.
50 'device record in Almanac.',
53 $cache->setKey($cache_key, $device);
59 public static function getClusterSSHUser() {
60 $username = PhabricatorEnv
::getEnvConfig('diffusion.ssh-user');
61 if (strlen($username)) {