Ejemplo n.º 1
0
function register()
{
    $gatewayId = $GLOBALS['AIRAVATA_GATEWAY'];
    $transport = new TSocket($GLOBALS['AIRAVATA_SERVER'], $GLOBALS['AIRAVATA_PORT']);
    $transport->setSendTimeout($GLOBALS['AIRAVATA_TIMEOUT']);
    $transport->setRecvTimeout($GLOBALS['AIRAVATA_TIMEOUT']);
    $protocol = new TBinaryProtocol($transport);
    try {
        $transport->open();
        $airavataclient = new AiravataClient($protocol);
        if (!$airavataclient->isGatewayExist($gatewayId)) {
            $gateway = new Gateway();
            $gateway->gatewayId = $gatewayId;
            $gateway->gatewayName = "GeanApp_GateWaay";
            $gateway->domain = $GLOBALS['AIRAVATA_SERVER'];
            $gateway->emailAddress = $GLOBALS['AIRAVATA_EMAIL'];
            $airavataclient->addGateway($gateway);
            registerComputeResourceHost($airavataclient, $GLOBALS['COMPUTE_RESOURCE']);
        } else {
            if (isGatewayRegistered($airavataclient, $gatewayId)) {
                $cmrf = $airavataclient->getGatewayResourceProfile($gatewayId)->computeResourcePreferences;
                registerComputeResourceHost($airavataclient, getUnRegisteredHost($airavataclient, $cmrf));
            } else {
                registerComputeResourceHost($airavataclient, $GLOBALS['COMPUTE_RESOURCE']);
            }
        }
        $hostIds = getHostIds($airavataclient, $gatewayId);
        $registeredModules = getRegisteredModules($airavataclient, $gatewayId);
        $modulesHost = getUnregisteredModules($airavataclient, $registeredModules);
        foreach ($modulesHost as $hostName => $modules) {
            if (!empty($modules)) {
                $moduleids = registerApplicationModule($gatewayId, $airavataclient, $modules);
                registerApplicationDeployments($gatewayId, $airavataclient, $moduleids, $modules, $hostIds[$hostName]);
                registerApplicationInterfaces($gatewayId, $airavataclient, $moduleids, $modules, $hostName);
            }
        }
        $transport->close();
    } catch (InvalidRequestException $ire) {
        echo 'InvalidRequestException: ' . $ire->getMessage();
    } catch (AiravataClientException $ace) {
        echo 'Airavata System Exception: ' . $ace->getMessage();
    } catch (AiravataSystemException $ase) {
        echo 'Airavata System Exception: ' . $ase->getMessage();
    } catch (TException $tx) {
        echo 'There is some connection problem, please check if airavata is runnig properly and try again later';
    } catch (\Exception $e) {
        echo 'Exception: ' . $e->getMessage();
    }
}
Ejemplo n.º 2
0
function launchExperiment($expId)
{
    $token = $GLOBALS['AIRAVATA_CREDENTIAL_STORE_TOKEN'];
    $transport = new TSocket($GLOBALS['AIRAVATA_SERVER'], $GLOBALS['AIRAVATA_PORT']);
    $transport->setSendTimeout($GLOBALS['AIRAVATA_TIMEOUT']);
    $transport->setRecvTimeout($GLOBALS['AIRAVATA_TIMEOUT']);
    $protocol = new TBinaryProtocol($transport);
    try {
        $transport->open();
        $airavataclient = new AiravataClient($protocol);
        $airavataclient->launchExperiment($expId, $token);
        $transport->close();
        $outputData = array();
        $outputData["isExperimentLaunched"] = true;
    } catch (InvalidRequestException $ire) {
        $outputData["error"] = 'InvalidRequestException: ' . $ire->getMessage();
    } catch (AiravataClientException $ace) {
        $outputData["error"] = 'Airavata System Exception: ' . $ace->getMessage();
    } catch (AiravataSystemException $ase) {
        $outputData["error"] = 'Airavata System Exception: ' . $ase->getMessage();
    } catch (TException $tx) {
        $outputData["error"] = 'Exception: ' . $tx->getMessage();
    } catch (\Exception $e) {
        $outputData["error"] = 'Exception: ' . $e->getMessage();
    }
    return json_encode($outputData);
}