예제 #1
0
function isInstanceReady($instance)
{
    // Get Status
    $cupid = new Cupid();
    $cupid->init();
    $inst_status = $cupid->getInstanceStatus($instance);
    $cupid->disconnect();
    // If the instance is Ready
    //   -> Go to the Instance domain and begin
    // If the instance is not created
    //   -> Go to Trial
    // If the instance is being set up
    //   -> Continue with welcome
    $ret = '';
    switch ($inst_status) {
        case 'INSTANCE_LIVE':
            // Do the redirect thing
            $ret = json_encode(array('ready' => true));
            break;
        case 'INSTANCE_NEW':
            $ret = json_encode(array('ready' => false, 'status' => 'pending'));
            break;
        case 'INSTANCE_MAINTENANCE':
            $ret = json_encode(array('ready' => false, 'status' => 'down'));
            break;
        case 'NULL':
            // Do the redirect thing
            $ret = json_encode(array('ready' => true));
            break;
    }
    return $ret;
}