예제 #1
0
 public static function create_or_update_appDeployment($inputs, $update = false)
 {
     $appDeploymentValues = $inputs;
     if (isset($appDeploymentValues["moduleLoadCmds"])) {
         $moduleLoadCmds = array_unique(array_filter($appDeploymentValues["moduleLoadCmds"], "trim"));
         $processedModuleLoadCommands = array();
         foreach ($moduleLoadCmds as $index => $loadCmd) {
             $cmdObject = new CommandObject();
             $cmdObject->command = $loadCmd;
             $cmdObject->commandOrder = $index;
             $processedModuleLoadCommands[] = $cmdObject;
         }
         $appDeploymentValues["moduleLoadCmds"] = $processedModuleLoadCommands;
     }
     if (isset($appDeploymentValues["libraryPrependPathName"])) {
         $libPrependPathNames = array_unique(array_filter($appDeploymentValues["libraryPrependPathName"], "trim"));
         foreach ($libPrependPathNames as $index => $prependName) {
             $envPath = new SetEnvPaths(array("name" => $prependName, "value" => $appDeploymentValues["libraryPrependPathValue"][$index]));
             $appDeploymentValues["libPrependPaths"][] = $envPath;
         }
     }
     if (isset($appDeploymentValues["libraryAppendPathName"])) {
         $libAppendPathNames = array_unique(array_filter($appDeploymentValues["libraryAppendPathName"], "trim"));
         foreach ($libAppendPathNames as $index => $appendName) {
             $envPath = new SetEnvPaths(array("name" => $appendName, "value" => $appDeploymentValues["libraryAppendPathValue"][$index]));
             $appDeploymentValues["libAppendPaths"][] = $envPath;
         }
     }
     if (isset($appDeploymentValues["environmentName"])) {
         $environmentNames = array_unique(array_filter($appDeploymentValues["environmentName"], "trim"));
         foreach ($environmentNames as $index => $envName) {
             $envPath = new SetEnvPaths(array("name" => $envName, "value" => $appDeploymentValues["environmentValue"][$index]));
             $envPath->envPathOrder = $index;
             $appDeploymentValues["setEnvironment"][] = $envPath;
         }
     }
     if (isset($appDeploymentValues["preJobCommand"])) {
         $preJobCmds = array_unique(array_filter($appDeploymentValues["preJobCommand"], "trim"));
         foreach ($preJobCmds as $index => $preJobCmd) {
             $cmdObject = new CommandObject();
             $cmdObject->command = $preJobCmd;
             $cmdObject->commandOrder = $index;
             $appDeploymentValues["preJobCommands"][] = $cmdObject;
         }
     }
     if (isset($appDeploymentValues["postJobCommand"])) {
         $postJobCmds = array_unique(array_filter($appDeploymentValues["postJobCommand"], "trim"));
         foreach ($postJobCmds as $index => $postJobCmd) {
             $cmdObject = new CommandObject();
             $cmdObject->command = $postJobCmd;
             $cmdObject->commandOrder = $index;
             $appDeploymentValues["postJobCommands"][] = $cmdObject;
         }
     }
     if (isset($appDeploymentValues["parallelism"])) {
         switch ($appDeploymentValues["parallelism"]) {
             case "MPI":
                 $appDeploymentValues["parallelism"] = \Airavata\Model\AppCatalog\AppDeployment\ApplicationParallelismType::MPI;
                 break;
             case "SERIAL":
                 $appDeploymentValues["parallelism"] = \Airavata\Model\AppCatalog\AppDeployment\ApplicationParallelismType::SERIAL;
                 break;
             case "OPENMP":
                 $appDeploymentValues["parallelism"] = \Airavata\Model\AppCatalog\AppDeployment\ApplicationParallelismType::OPENMP;
                 break;
             case "OPENMP_MPI":
                 $appDeploymentValues["parallelism"] = \Airavata\Model\AppCatalog\AppDeployment\ApplicationParallelismType::OPENMP_MPI;
                 break;
             case "CRAY_MPI":
                 $appDeploymentValues["parallelism"] = \Airavata\Model\AppCatalog\AppDeployment\ApplicationParallelismType::CRAY_MPI;
                 break;
             case "CCM":
                 $appDeploymentValues["parallelism"] = \Airavata\Model\AppCatalog\AppDeployment\ApplicationParallelismType::CCM;
                 break;
         }
     }
     //var_dump( $appDeploymentValues); exit;
     $appDeployment = new ApplicationDeploymentDescription($appDeploymentValues);
     if ($update) {
         Airavata::updateApplicationDeployment(Session::get('authz-token'), $inputs["app-deployment-id"], $appDeployment);
     } else {
         $appDeploymentId = Airavata::registerApplicationDeployment(Session::get('authz-token'), Session::get("gateway_id"), $appDeployment);
     }
     return;
 }
	public static function create_or_update_appDeployment( $inputs, $update = false){

		$appDeploymentValues = $inputs;

		if( isset( $appDeploymentValues["moduleLoadCmds"]))
			$appDeploymentValues["moduleLoadCmds"] = array_unique( array_filter( $appDeploymentValues["moduleLoadCmds"]));

		if( isset( $appDeploymentValues["libraryPrependPathName"] )) 
		{	
			$libPrependPathNames = array_unique( array_filter( $appDeploymentValues["libraryPrependPathName"],"trim" ));
		
			foreach( $libPrependPathNames as $index => $prependName)
			{
				$envPath = new SetEnvPaths(array(
												"name" => $prependName,
												"value" => $appDeploymentValues["libraryPrependPathValue"][ $index]
											));
				$appDeploymentValues["libPrependPaths"][] = $envPath;
			}
		}

		if( isset( $appDeploymentValues["libraryAppendPathName"] )) 
		{
			$libAppendPathNames = array_unique( array_filter( $appDeploymentValues["libraryAppendPathName"],"trim" ));
			foreach( $libAppendPathNames as $index => $appendName)
			{
				$envPath = new SetEnvPaths(array(
												"name" => $appendName,
												"value" => $appDeploymentValues["libraryAppendPathValue"][ $index]
											));
				$appDeploymentValues["libAppendPaths"][] = $envPath;
			}
		}

		if( isset( $appDeploymentValues["environmentName"] )) 
		{
			$environmentNames = array_unique( array_filter( $appDeploymentValues["environmentName"], "trim"));
			foreach( $environmentNames as $index => $envName)
			{
				$envPath = new SetEnvPaths(array(
												"name" => $envName,
												"value" => $appDeploymentValues["environmentValue"][$index]
											));
				$appDeploymentValues["setEnvironment"][] = $envPath;
			}
		}
		
		if( isset( $appDeploymentValues["preJobCommand"] )) 
		{
			$appDeploymentValues["preJobCommands"] = array_unique( array_filter( $appDeploymentValues["preJobCommand"], "trim"));
		}

		if( isset( $appDeploymentValues["postJobCommand"] )) 
		{
			$appDeploymentValues["postJobCommands"] = array_unique( array_filter( $appDeploymentValues["postJobCommand"], "trim"));
		}

		//var_dump( $appDeploymentValues); exit;
		$appDeployment = new ApplicationDeploymentDescription(  $appDeploymentValues);
		if( $update)
            Airavata::updateApplicationDeployment( $inputs["app-deployment-id"], $appDeployment);
		else
			$appDeploymentId = Airavata::registerApplicationDeployment( Session::get("gateway_id"), $appDeployment);

		return;

	}