Changeset View
Changeset View
Standalone View
Standalone View
scripts/sql/manage_storage.php
| Show All 25 Lines | $args->parsePartial( | ||||
| array( | array( | ||||
| array( | array( | ||||
| 'name' => 'force', | 'name' => 'force', | ||||
| 'short' => 'f', | 'short' => 'f', | ||||
| 'help' => pht( | 'help' => pht( | ||||
| 'Do not prompt before performing dangerous operations.'), | 'Do not prompt before performing dangerous operations.'), | ||||
| ), | ), | ||||
| array( | array( | ||||
| 'name' => 'host', | |||||
| 'param' => 'hostname', | |||||
| 'help' => pht( | |||||
| 'Connect to __host__ instead of the default host.'), | |||||
| ), | |||||
| array( | |||||
| 'name' => 'user', | 'name' => 'user', | ||||
| 'short' => 'u', | 'short' => 'u', | ||||
| 'param' => 'username', | 'param' => 'username', | ||||
| 'help' => pht( | 'help' => pht( | ||||
| 'Connect with __username__ instead of the configured default.'), | 'Connect with __username__ instead of the configured default.'), | ||||
| ), | ), | ||||
| array( | array( | ||||
| 'name' => 'password', | 'name' => 'password', | ||||
| Show All 28 Lines | |||||
| } catch (PhutilArgumentUsageException $ex) { | } catch (PhutilArgumentUsageException $ex) { | ||||
| $args->printUsageException($ex); | $args->printUsageException($ex); | ||||
| exit(77); | exit(77); | ||||
| } | } | ||||
| // First, test that the Phabricator configuration is set up correctly. After | // First, test that the Phabricator configuration is set up correctly. After | ||||
| // we know this works we'll test any administrative credentials specifically. | // we know this works we'll test any administrative credentials specifically. | ||||
| $host = $args->getArg('host'); | |||||
| if (strlen($host)) { | |||||
| $ref = null; | |||||
| $refs = PhabricatorDatabaseRef::getLiveRefs(); | |||||
| // Include the master in case the user is just specifying a redundant | |||||
| // "--host" flag for no reason and does not actually have a database | |||||
| // cluster configured. | |||||
| $refs[] = PhabricatorDatabaseRef::getMasterDatabaseRef(); | |||||
| foreach ($refs as $possible_ref) { | |||||
| if ($possible_ref->getHost() == $host) { | |||||
| $ref = $possible_ref; | |||||
| break; | |||||
| } | |||||
| } | |||||
| if (!$ref) { | |||||
| throw new PhutilArgumentUsageException( | |||||
| pht( | |||||
| 'There is no configured database on host "%s". This command can '. | |||||
| 'only interact with configured databases.', | |||||
| $host)); | |||||
| } | |||||
| } else { | |||||
| $ref = PhabricatorDatabaseRef::getMasterDatabaseRef(); | $ref = PhabricatorDatabaseRef::getMasterDatabaseRef(); | ||||
| if (!$ref) { | if (!$ref) { | ||||
| throw new Exception( | throw new Exception( | ||||
| pht('No database master is configured.')); | pht('No database master is configured.')); | ||||
| } | } | ||||
| } | |||||
| $default_user = $ref->getUser(); | $default_user = $ref->getUser(); | ||||
| $default_host = $ref->getHost(); | $default_host = $ref->getHost(); | ||||
| $default_port = $ref->getPort(); | $default_port = $ref->getPort(); | ||||
| $test_api = id(new PhabricatorStorageManagementAPI()) | $test_api = id(new PhabricatorStorageManagementAPI()) | ||||
| ->setUser($default_user) | ->setUser($default_user) | ||||
| ->setHost($default_host) | ->setHost($default_host) | ||||
| ▲ Show 20 Lines • Show All 88 Lines • Show Last 20 Lines | |||||