Updated the instance details so we can set the username, password, and hostname. username and password only come back when you initially create the database. hostname comes back after the database is up. There are many cases where we need to set these on an object.
This commit is contained in:
@@ -41,7 +41,7 @@ class InstanceDetails {
|
||||
|
||||
public function newFromJSON($json) {
|
||||
|
||||
// fwrite(STDOUT, json_encode($json));
|
||||
//fwrite(STDOUT, json_encode($json));
|
||||
|
||||
$o = new InstanceDetails($json['name'], $json['id']);
|
||||
$o->links = $json['links'];
|
||||
@@ -154,6 +154,22 @@ class InstanceDetails {
|
||||
return $this->hostname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the hostname.
|
||||
*
|
||||
* @param string $hostname
|
||||
* The hostname for this server.
|
||||
*
|
||||
* @retval HPCloud::Services::DBaaS::InstanceDetails
|
||||
* @return \HPCloud\Services\DBaaS\InstanceDetails
|
||||
* $this so the method can be used in chaining.
|
||||
*/
|
||||
public function setHostname($hostname) {
|
||||
$this->hostname = $hostname;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The username field, if available.
|
||||
*
|
||||
@@ -166,6 +182,23 @@ class InstanceDetails {
|
||||
public function username() {
|
||||
return $this->username;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the username.
|
||||
*
|
||||
* @param string $username
|
||||
* The username for this server.
|
||||
*
|
||||
* @retval HPCloud::Services::DBaaS::InstanceDetails
|
||||
* @return \HPCloud\Services\DBaaS\InstanceDetails
|
||||
* $this so the method can be used in chaining.
|
||||
*/
|
||||
public function setUsername($username) {
|
||||
$this->username = $username;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The password field, if available.
|
||||
*
|
||||
@@ -180,6 +213,23 @@ class InstanceDetails {
|
||||
public function password() {
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the password.
|
||||
*
|
||||
* @param string $password
|
||||
* The password for this server.
|
||||
*
|
||||
* @retval HPCloud::Services::DBaaS::InstanceDetails
|
||||
* @return \HPCloud\Services\DBaaS\InstanceDetails
|
||||
* $this so the method can be used in chaining.
|
||||
*/
|
||||
public function setPassword($password) {
|
||||
$this->password = $password;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* An array of links about this database.
|
||||
*
|
||||
@@ -239,5 +289,4 @@ class InstanceDetails {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -99,6 +99,8 @@ class DBaaSInstanceTest extends DBaaSTestCase {
|
||||
$details = $this->inst()->describe($db->id());
|
||||
$this->assertInstanceOf('\HPCloud\Services\DBaaS\InstanceDetails', $details);
|
||||
|
||||
$db->setHostname($details->hostname());
|
||||
|
||||
$this->assertEmpty($details->username());
|
||||
$this->assertEmpty($details->password());
|
||||
|
||||
@@ -175,7 +177,7 @@ class DBaaSInstanceTest extends DBaaSTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
$affected = $conn->execute('SELECT 1');
|
||||
$affected = $conn->exec('SELECT 1');
|
||||
|
||||
$this->assertEquals(0, $affected, "Connect and run a SELECT.");
|
||||
|
||||
|
@@ -59,11 +59,14 @@ abstract class DBaaSTestCase extends \HPCloud\Tests\TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public function waitUntilRunning($inst, &$details, $verbose = FALSE, $max = 30, $sleep = 5) {
|
||||
public function waitUntilRunning($inst, &$details, $verbose = FALSE, $max = 120, $sleep = 5) {
|
||||
if ($details->isRunning()) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
$username = $details->username();
|
||||
$password = $details->password();
|
||||
|
||||
for ($i = 0; $i < $max; ++$i) {
|
||||
|
||||
if ($verbose) fwrite(STDOUT, '⌛');
|
||||
@@ -71,6 +74,8 @@ abstract class DBaaSTestCase extends \HPCloud\Tests\TestCase {
|
||||
|
||||
sleep($sleep);
|
||||
$details = $inst->describe($details->id());
|
||||
$details->setPassword($password)
|
||||
->setUsername($username);
|
||||
|
||||
if ($details->isRunning()) {
|
||||
return TRUE;
|
||||
|
Reference in New Issue
Block a user