diff --git a/Reference/Common/common.php b/Reference/Common/common.php index 6cc5e508f..20b24ed4f 100755 --- a/Reference/Common/common.php +++ b/Reference/Common/common.php @@ -149,4 +149,18 @@ function task_warning($message) { exit; } +function task_error_with_email ($from, $email_recipients, $email_subject, $email_content) { + global $context; + logTofile(debug_dump($email_content, "Error message :\n")); + _email_send($from, $email_recipients, $email_subject, $email_content); + $response = prepare_json_response(FAILED, $email_content, $context, true); + echo $response; + exit; +} + + + + + + ?> diff --git a/Reference/Common/curl_performer.php b/Reference/Common/curl_performer.php index ebe2b59a3..f34db4e70 100755 --- a/Reference/Common/curl_performer.php +++ b/Reference/Common/curl_performer.php @@ -14,12 +14,20 @@ function create_msa_operation_request ($operation, $msa_rest_api, $json_body = " $connection_timeout = 60, $max_time = 60) { global $CURL_CMD, $context; - - $HTTP_HOST = "localhost"; // get_vars_value(WEB_NODE_PRIV_IP)""; - $HTTP_PORT = "8480"; // get_vars_value(WEB_NODE_HTTP_PORT); + + if (isset($context['WEB_NODE_PRIV_IP']) && isset($context['NCROOT_PASSWORD_VARIABLE']) && isset($context['WEB_NODE_HTTP_PORT']) ){ + //for remote MSA, needed for migration + $HTTP_HOST = $context['WEB_NODE_PRIV_IP']; + $password = $context['NCROOT_PASSWORD_VARIABLE']; + $HTTP_PORT = $context['WEB_NODE_HTTP_PORT']; + $remote = 1; + }else{ + $HTTP_HOST = "localhost"; // get_vars_value(WEB_NODE_PRIV_IP)""; + $password = "ubiqube"; //shell_exec(ENCP_SCRIPT . ' ' . $NCROOT_PASSWORD); + $HTTP_PORT = "8480"; // get_vars_value(WEB_NODE_HTTP_PORT); + $remote = 0; + } $USERNAME = "ncroot"; - //$NCROOT_PASSWORD = get_vars_value(NCROOT_PASSWORD_VARIABLE); - $password = "ubiqube"; //shell_exec(ENCP_SCRIPT . ' ' . $NCROOT_PASSWORD); $auth_token = $context['TOKEN']; if (strpos($msa_rest_api, "?") !== false) { @@ -46,11 +54,21 @@ function create_msa_operation_request ($operation, $msa_rest_api, $json_body = " if (strpos($json_body, "@") === 0) { $content_type = "*/*"; } - $curl_cmd = "{$CURL_CMD} -isw '\nHTTP_CODE=%{http_code}' -H \"Authorization: Bearer $auth_token\" --connect-timeout $connection_timeout --max-time $max_time -H \"Content-Type: {$content_type}\" -X {$operation} {$url}"; + if ($remote){ + $curl_cmd = "{$CURL_CMD} -isw '\nHTTP_CODE=%{http_code}' -u {$USERNAME}:\$p --connect-timeout $connection_timeout --max-time $max_time -H \"Content-Type: {$content_type}\" -X {$operation} {$url}"; + }else{ + $curl_cmd = "{$CURL_CMD} -isw '\nHTTP_CODE=%{http_code}' -H \"Authorization: Bearer $auth_token\" --connect-timeout $connection_timeout --max-time $max_time -H \"Content-Type: {$content_type}\" -X {$operation} {$url}"; + } if ($json_body !== "") { $curl_cmd .= " -d '" . pretty_print_json($json_body) . "'"; } logToFile("Curl Request : $curl_cmd\n"); + if ($remote){ + $curl_cmd = "p=$(" . ENCP_SCRIPT . " '{$password}');{$curl_cmd}"; + } + logToFile("Curl ecnrypt cmd= ". ENCP_SCRIPT . " '{$password}'"); + logToFile("Curl Request FULL: $curl_cmd\n"); + return $curl_cmd; } diff --git a/Reference/Common/utility.php b/Reference/Common/utility.php index b7d4fff64..490f0dc1d 100755 --- a/Reference/Common/utility.php +++ b/Reference/Common/utility.php @@ -542,6 +542,10 @@ function update_asynchronous_task_details($args, $details) { $TASKID = $args['TASKID']; $EXECNUMBER = $args['EXECNUMBER']; + $details = preg_replace ("/\"/",' ',$details); //remove " to prevent somme error + $details = preg_replace ("/\'/",' ',$details); //remove ' to prevent somme error + $details = preg_replace ("/\(/",' ',$details); //remove ( to prevent somme error + $details = preg_replace ("/\)/",' ',$details); //remove ) to prevent somme error logToFile("UPDATE PROCESS SCRIPT DETAILS : $PROCESSINSTANCEID $TASKID $EXECNUMBER \"{$details}\"\n"); $response = _orchestration_update_process_script_details($PROCESSINSTANCEID, $TASKID, $EXECNUMBER, $details); } diff --git a/Reference/MSActivator/Device/.meta_Task_msa_device_backup.php b/Reference/MSActivator/Device/.meta_Task_msa_device_backup.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/MSActivator/Device/.meta_Task_msa_device_backup.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/MSActivator/Device/Task_msa_device_backup.php b/Reference/MSActivator/Device/Task_msa_device_backup.php new file mode 100644 index 000000000..70c29d314 --- /dev/null +++ b/Reference/MSActivator/Device/Task_msa_device_backup.php @@ -0,0 +1,39 @@ + $PROCESSINSTANCEID, + 'EXECNUMBER' => $EXECNUMBER, + 'TASKID' => $TASKID); + +$device_id = substr($context['device_id'], 3); +$response = _device_do_backup($device_id, $process_params); +$response = json_decode($response, true); +if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + echo $response; + exit; +} + +$response = wait_for_backup_completion($device_id, $process_params); +$response = json_decode($response, true); +if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + echo $response; + exit; +} +$backup_status_message = $response['wo_comment']; + +$response = prepare_json_response(ENDED, "Device $device_id Backup completed successfully.\n" . $backup_status_message, $context, true); +echo $response; + +?> \ No newline at end of file diff --git a/Reference/MSActivator/DeviceConfiguration/.meta_Task_msa_list_files_attached_to_device.php b/Reference/MSActivator/DeviceConfiguration/.meta_Task_msa_list_files_attached_to_device.php new file mode 100644 index 000000000..63d652f4c --- /dev/null +++ b/Reference/MSActivator/DeviceConfiguration/.meta_Task_msa_list_files_attached_to_device.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1543297870623 + + + DATE_CREATION + 1543297850173 + + + TYPE + FILE + + + diff --git a/Reference/MSActivator/DeviceConfiguration/.meta_Task_msa_list_files_config_profile.php b/Reference/MSActivator/DeviceConfiguration/.meta_Task_msa_list_files_config_profile.php new file mode 100644 index 000000000..4200bd58a --- /dev/null +++ b/Reference/MSActivator/DeviceConfiguration/.meta_Task_msa_list_files_config_profile.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1543298047166 + + + DATE_CREATION + 1543297992685 + + + TYPE + FILE + + + diff --git a/Reference/MSActivator/DeviceConfiguration/Task_msa_list_files_attached_to_device.php b/Reference/MSActivator/DeviceConfiguration/Task_msa_list_files_attached_to_device.php new file mode 100644 index 000000000..990664546 --- /dev/null +++ b/Reference/MSActivator/DeviceConfiguration/Task_msa_list_files_attached_to_device.php @@ -0,0 +1,27 @@ + \ No newline at end of file diff --git a/Reference/MSActivator/DeviceConfiguration/Task_msa_list_files_config_profile.php b/Reference/MSActivator/DeviceConfiguration/Task_msa_list_files_config_profile.php new file mode 100644 index 000000000..a476f462a --- /dev/null +++ b/Reference/MSActivator/DeviceConfiguration/Task_msa_list_files_config_profile.php @@ -0,0 +1,52 @@ +(\d+)\<\/configurationProfileId\>/',$result,$match)) +{ + $response = prepare_json_response(FAILED, "Listing Files Attached From Config Profile Failed" , $context, true); + echo $response; + exit; +} + +$config_profile_id = $match[1]; + +if ($config_profile_id == 0){ + $response = prepare_json_response(ENDED, "No Config Profiles Attached to the device", $context, true); + echo $response; + exit; +} + +$cmd = "bash /opt/ubi-jentreprise/bin/api/deviceconfiguration/listFilesByConfigurationProfileId.sh $config_profile_id|grep return"; + +logToFile("COMMAND TO GET PROFILE FILES:" .$cmd."\n"); +$result = shell_exec ("$cmd"); + +if(preg_match_all('/\(.*)\<\/return\>/',$result,$uris) == 0) +{ + $response = prepare_json_response(FAILED, "Listing Files Attached From Config Profile Failed" , $context, true); + echo $response; + exit; +} + +if(!isset($context['device_objects_uri'])) +{ + $context['device_objects_uri'] = array(); +} + +foreach($uris[1] as $uri) +{ + array_push($context['device_objects_uri'], $uri); +} + +$response = prepare_json_response(ENDED, "Files Attached From Config Profile listed Successfully", $context, true); +echo $response; + +?> diff --git a/Reference/MSActivator/Orchestration/.meta_Task_Pause.php b/Reference/MSActivator/Orchestration/.meta_Task_Pause.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/MSActivator/Orchestration/.meta_Task_Pause.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/MSActivator/Orchestration/Task_Pause.php b/Reference/MSActivator/Orchestration/Task_Pause.php new file mode 100644 index 000000000..1f12b82f1 --- /dev/null +++ b/Reference/MSActivator/Orchestration/Task_Pause.php @@ -0,0 +1,9 @@ + \ No newline at end of file