コード例 #1
0
public static function create_or_update_JSIObject( $inputs, $update = false){

    $computeResource = Utilities::get_compute_resource(  $inputs["crId"]);


    $jsiId = null;
    if( isset( $inputs["jsiId"]))
        $jsiId = $inputs["jsiId"];

    if( $inputs["jobSubmissionProtocol"] == JobSubmissionProtocol::LOCAL)
    {

        //print_r( $jsiObject->resourceJobManager->resourceJobManagerId);
        $resourceManager = new ResourceJobManager(array( 
                                                    "resourceJobManagerType" => $inputs["resourceJobManagerType"],
                                                    "pushMonitoringEndpoint" => $inputs["pushMonitoringEndpoint"],
                                                    "jobManagerBinPath"      => $inputs["jobManagerBinPath"],
                                                    "jobManagerCommands"     => $inputs["jobManagerCommands"]
                                                    ));

        //$rmId = $jsiObject->resourceJobManager->resourceJobManagerId;
        //$rm = $airavataclient->updateResourceJobManager($rmId, $resourceManager);
        //print_r( $rm); exit;
        $localJobSubmission = new LOCALSubmission(  array(
                                                            "resourceJobManager" => $resourceManager
                                                        )
                                                    );

        if( $update) //update Local JSP
        {
            $jsiObject = Airavata::getLocalJobSubmission( $jsiId);
            $localSub = Airavata::updateResourceJobManager(  $jsiObject->resourceJobManager->resourceJobManagerId, $resourceManager);
            //$localSub = $airavataclient->updateLocalSubmissionDetails( $jsiId, $localJobSubmission);
        }
        else        // create Local JSP
        {
            $localSub = Airavata::addLocalSubmissionDetails( $computeResource->computeResourceId, 0, $localJobSubmission);
            return $localSub;
        }
        
    }
    else if( $inputs["jobSubmissionProtocol"] ==  JobSubmissionProtocol::SSH) /* SSH */
    {
        $resourceManager = new ResourceJobManager(array( 
                                                    "resourceJobManagerType" => $inputs["resourceJobManagerType"],
                                                    "pushMonitoringEndpoint" => $inputs["pushMonitoringEndpoint"],
                                                    "jobManagerBinPath"      => $inputs["jobManagerBinPath"],
                                                    "jobManagerCommands"     => $inputs["jobManagerCommands"]
                                                    ));
        $sshJobSubmission = new SSHJobSubmission( array
                                                    (
                                                        "securityProtocol" => intval( $inputs["securityProtocol"]),
                                                        "resourceJobManager" => $resourceManager,
                                                        "alternativeSSHHostName" => $inputs["alternativeSSHHostName"],
                                                        "sshPort" => intval( $inputs["sshPort"] ),
                                                        "monitorMode" => intval( $inputs["monitorMode"] )
                                                    )
                                                );
        //var_dump( $sshJobSubmission); exit;
        if( $update) //update Local JSP
        {
            $jsiObject = Airavata::getSSHJobSubmission( $jsiId);

            //first update resource job manager
            $rmjId = $jsiObject->resourceJobManager->resourceJobManagerId;
            Airavata::updateResourceJobManager(  $rmjId, $resourceManager);
            $jsiObject = Airavata::getSSHJobSubmission( $jsiId);

            $jsiObject->securityProtocol = intval( $inputs["securityProtocol"] );
            $jsiObject->alternativeSSHHostName = $inputs["alternativeSSHHostName"];
            $jsiObject->sshPort = intval( $inputs["sshPort"] );
            $jsiObject->monitorMode = intval( $inputs["monitorMode"] );
            $jsiObject->resourceJobManager = Airavata::getresourceJobManager( $rmjId);
            //var_dump( $jsiObject); exit;
            //add updated resource job manager to ssh job submission object.
            //$sshJobSubmission->resourceJobManager->resourceJobManagerId = $rmjId;
            $localSub = Airavata::updateSSHJobSubmissionDetails( $jsiId, $jsiObject);
        }
        else
        {
            $sshSub = Airavata::addSSHJobSubmissionDetails( $computeResource->computeResourceId, 0, $sshJobSubmission);
        }
        return;        
    }
    else if( $inputs["jobSubmissionProtocol"] == JobSubmissionProtocol::UNICORE)
    {
        $unicoreJobSubmission  = new UnicoreJobSubmission( array
                                                            (
                                                                "securityProtocol" => intval( $inputs["securityProtocol"]),
                                                                "unicoreEndPointURL" => $inputs["unicoreEndPointURL"]
                                                            )
                                                        );
        if( $update)
        {
            $jsiObject = Airavata::getUnicoreJobSubmission( $jsiId);
            $jsiObject->securityProtocol = intval( $inputs["securityProtocol"] );
            $jsiObject->unicoreEndPointURL = $inputs["unicoreEndPointURL"];

            $unicoreSub = Airavata::updateUnicoreJobSubmissionDetails( $jsiId, $jsiObject);
        }
        else
        {
            $unicoreSub = Airavata::addUNICOREJobSubmissionDetails( $computeResource->computeResourceId, 0, $unicoreJobSubmission);
        }
    }
    else /* Globus does not work currently */
    {
        print_r( "Whoops! We haven't coded for this Job Submission Protocol yet. Still working on it. Please click <a href='" . URL::to('/') . "/cr/edit'>here</a> to go back to edit page for compute resource.");
    }
}
コード例 #2
0
 public static function create_or_update_JSIObject($inputs, $update = false)
 {
     $computeResource = CRUtilities::get_compute_resource($inputs["crId"]);
     if (Config::get('pga_config.airavata')['enable-app-catalog-cache']) {
         if (Cache::has('CR-' . $inputs["crId"])) {
             Cache::forget('CR-' . $inputs["crId"]);
         }
     }
     $jsiId = null;
     if (isset($inputs["jsiId"])) {
         $jsiId = $inputs["jsiId"];
     }
     if ($inputs["jobSubmissionProtocol"] == JobSubmissionProtocol::LOCAL) {
         //print_r( $jsiObject->resourceJobManager->resourceJobManagerId);
         $resourceManager = new ResourceJobManager(array("resourceJobManagerType" => $inputs["resourceJobManagerType"], "pushMonitoringEndpoint" => $inputs["pushMonitoringEndpoint"], "jobManagerBinPath" => $inputs["jobManagerBinPath"], "jobManagerCommands" => $inputs["jobManagerCommands"]));
         //$rmId = $jsiObject->resourceJobManager->resourceJobManagerId;
         //$rm = $airavataclient->updateResourceJobManager($rmId, $resourceManager);
         //print_r( $rm); exit;
         $localJobSubmission = new LOCALSubmission(array("resourceJobManager" => $resourceManager));
         if ($update) {
             $jsiObject = Airavata::getLocalJobSubmission(Session::get('authz-token'), $jsiId);
             $localSub = Airavata::updateResourceJobManager(Session::get('authz-token'), $jsiObject->resourceJobManager->resourceJobManagerId, $resourceManager);
             //$localSub = $airavataclient->updateLocalSubmissionDetails( $jsiId, $localJobSubmission);
         } else {
             $localSub = Airavata::addLocalSubmissionDetails(Session::get('authz-token'), $computeResource->computeResourceId, 0, $localJobSubmission);
             return $localSub;
         }
     } else {
         if ($inputs["jobSubmissionProtocol"] == JobSubmissionProtocol::SSH) {
             $resourceManager = new ResourceJobManager(array("resourceJobManagerType" => $inputs["resourceJobManagerType"], "pushMonitoringEndpoint" => $inputs["pushMonitoringEndpoint"], "jobManagerBinPath" => $inputs["jobManagerBinPath"], "jobManagerCommands" => $inputs["jobManagerCommands"]));
             $sshJobSubmission = new SSHJobSubmission(array("securityProtocol" => intval($inputs["securityProtocol"]), "resourceJobManager" => $resourceManager, "alternativeSSHHostName" => $inputs["alternativeSSHHostName"], "sshPort" => intval($inputs["sshPort"]), "monitorMode" => MonitorMode::JOB_EMAIL_NOTIFICATION_MONITOR));
             //var_dump( $sshJobSubmission); exit;
             if ($update) {
                 $jsiObject = Airavata::getSSHJobSubmission(Session::get('authz-token'), $jsiId);
                 //first update resource job manager
                 $rmjId = $jsiObject->resourceJobManager->resourceJobManagerId;
                 Airavata::updateResourceJobManager(Session::get('authz-token'), $rmjId, $resourceManager);
                 $jsiObject = Airavata::getSSHJobSubmission(Session::get('authz-token'), $jsiId);
                 $jsiObject->securityProtocol = intval($inputs["securityProtocol"]);
                 $jsiObject->alternativeSSHHostName = $inputs["alternativeSSHHostName"];
                 $jsiObject->sshPort = intval($inputs["sshPort"]);
                 $jsiObject->monitorMode = intval($inputs["monitorMode"]);
                 $jsiObject->resourceJobManager = Airavata::getresourceJobManager(Session::get('authz-token'), $rmjId);
                 //var_dump( $jsiObject); exit;
                 //add updated resource job manager to ssh job submission object.
                 //$sshJobSubmission->resourceJobManager->resourceJobManagerId = $rmjId;
                 $localSub = Airavata::updateSSHJobSubmissionDetails(Session::get('authz-token'), $jsiId, $jsiObject);
             } else {
                 $sshSub = Airavata::addSSHJobSubmissionDetails(Session::get('authz-token'), $computeResource->computeResourceId, 0, $sshJobSubmission);
             }
             return;
         } else {
             if ($inputs["jobSubmissionProtocol"] == JobSubmissionProtocol::SSH_FORK) {
                 $resourceManager = new ResourceJobManager(array("resourceJobManagerType" => $inputs["resourceJobManagerType"], "pushMonitoringEndpoint" => $inputs["pushMonitoringEndpoint"], "jobManagerBinPath" => $inputs["jobManagerBinPath"], "jobManagerCommands" => $inputs["jobManagerCommands"]));
                 $sshJobSubmission = new SSHJobSubmission(array("securityProtocol" => intval($inputs["securityProtocol"]), "resourceJobManager" => $resourceManager, "alternativeSSHHostName" => $inputs["alternativeSSHHostName"], "sshPort" => intval($inputs["sshPort"]), "monitorMode" => MonitorMode::FORK));
                 //var_dump( $sshJobSubmission); exit;
                 if ($update) {
                     $jsiObject = Airavata::getSSHJobSubmission(Session::get('authz-token'), $jsiId);
                     //first update resource job manager
                     $rmjId = $jsiObject->resourceJobManager->resourceJobManagerId;
                     Airavata::updateResourceJobManager(Session::get('authz-token'), $rmjId, $resourceManager);
                     $jsiObject = Airavata::getSSHJobSubmission(Session::get('authz-token'), $jsiId);
                     $jsiObject->securityProtocol = intval($inputs["securityProtocol"]);
                     $jsiObject->alternativeSSHHostName = $inputs["alternativeSSHHostName"];
                     $jsiObject->sshPort = intval($inputs["sshPort"]);
                     $jsiObject->monitorMode = intval($inputs["monitorMode"]);
                     $jsiObject->resourceJobManager = Airavata::getresourceJobManager(Session::get('authz-token'), $rmjId);
                     //var_dump( $jsiObject); exit;
                     //add updated resource job manager to ssh job submission object.
                     //$sshJobSubmission->resourceJobManager->resourceJobManagerId = $rmjId;
                     $localSub = Airavata::updateSSHJobSubmissionDetails(Session::get('authz-token'), $jsiId, $jsiObject);
                 } else {
                     $sshSub = Airavata::addSSHForkJobSubmissionDetails(Session::get('authz-token'), $computeResource->computeResourceId, 0, $sshJobSubmission);
                 }
                 return;
             } else {
                 if ($inputs["jobSubmissionProtocol"] == JobSubmissionProtocol::UNICORE) {
                     $unicoreJobSubmission = new UnicoreJobSubmission(array("securityProtocol" => intval($inputs["securityProtocol"]), "unicoreEndPointURL" => $inputs["unicoreEndPointURL"]));
                     if ($update) {
                         $jsiObject = Airavata::getUnicoreJobSubmission(Session::get('authz-token'), $jsiId);
                         $jsiObject->securityProtocol = intval($inputs["securityProtocol"]);
                         $jsiObject->unicoreEndPointURL = $inputs["unicoreEndPointURL"];
                         $unicoreSub = Airavata::updateUnicoreJobSubmissionDetails(Session::get('authz-token'), $jsiId, $jsiObject);
                     } else {
                         $unicoreSub = Airavata::addUNICOREJobSubmissionDetails(Session::get('authz-token'), $computeResource->computeResourceId, 0, $unicoreJobSubmission);
                     }
                 } else {
                     print_r("Whoops! We haven't coded for this Job Submission Protocol yet. Still working on it. Please click <a href='" . URL::to('/') . "/cr/edit'>here</a> to go back to edit page for compute resource.");
                 }
             }
         }
     }
 }