public function test_request()
 {
     $this->setExpectedExceptionCode(NO_VALID_JSON_RECEIVED);
     $cloudstack = new BaseCloudStackClient("http://google.com/", "slqkdjqslkdjlqskjd", "qlskdjlskqjdlkqsjdlkjq");
     $cloudstack->request("command-name-non-empty", array());
 }
Пример #2
0
define("CONFIG_FILE", dirname(__FILE__) . "/../config.php");
/**************************
  Initial checks
 **************************/
check(defined('STDIN'), "This script is supposed to be run from command line. Exiting.");
check(file_exists(CLOUDSTACKCLIENT_FILE), "Unable to find CloudStackClient file, looked for " . CLOUDSTACKCLIENT_FILE);
check(file_exists(CONFIG_FILE), "Unable to find config file, looked for " . CONFIG_FILE);
check($argc > 1, "Usage: php cloudstack.php command args...");
require CLOUDSTACKCLIENT_FILE;
$config = (require CONFIG_FILE);
$command = $argv[1];
$args = array_slice($argv, 1);
/**************************
  Request
 **************************/
$cloudstack = new BaseCloudStackClient($config['endpoint'], $config['api_key'], $config['secret_key']);
try {
    $result = $cloudstack->request($command, $args);
} catch (Exception $e) {
    err($e->getMessage());
}
var_dump($result);
/**************************
  Helpers
 **************************/
function check($cond, $errorMessage)
{
    if (!$cond) {
        err($errorMessage);
    }
}