Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Reference/Common/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}






?>
30 changes: 24 additions & 6 deletions Reference/Common/curl_performer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}

Expand Down
4 changes: 4 additions & 0 deletions Reference/Common/utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
17 changes: 17 additions & 0 deletions Reference/MSActivator/Device/.meta_Task_msa_device_backup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<metadata>
<map>
<entry>
<key>DATE_MODIFICATION</key>
<value>1453292430598</value>
</entry>
<entry>
<key>DATE_CREATION</key>
<value>1453292418180</value>
</entry>
<entry>
<key>TYPE</key>
<value>FILE</value>
</entry>
</map>
</metadata>
39 changes: 39 additions & 0 deletions Reference/MSActivator/Device/Task_msa_device_backup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

require_once '/opt/fmc_repository/Process/Reference/Common/common.php';

function list_args() {
create_var_def('device_id', 'Device');
}

check_mandatory_param('device_id');

$PROCESSINSTANCEID = $context['PROCESSINSTANCEID'];
$EXECNUMBER = $context['EXECNUMBER'];
$TASKID = $context['TASKID'];
$process_params = array('PROCESSINSTANCEID' => $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;

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<metadata>
<map>
<entry>
<key>DATE_MODIFICATION</key>
<value>1543297870623</value>
</entry>
<entry>
<key>DATE_CREATION</key>
<value>1543297850173</value>
</entry>
<entry>
<key>TYPE</key>
<value>FILE</value>
</entry>
</map>
</metadata>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<metadata>
<map>
<entry>
<key>DATE_MODIFICATION</key>
<value>1543298047166</value>
</entry>
<entry>
<key>DATE_CREATION</key>
<value>1543297992685</value>
</entry>
<entry>
<key>TYPE</key>
<value>FILE</value>
</entry>
</map>
</metadata>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

require_once '/opt/fmc_repository/Process/Reference/Common/common.php';

function list_args()
{
create_var_def('DeviceId', 'Device');
}

check_mandatory_param('DeviceId');

$device_id = substr($context['DeviceId'], 3);

$response = _device_configuration_list_files_by_id ($device_id);
$response = json_decode($response, true);
if ($response['wo_status'] !== ENDED) {
$response = prepare_json_response(FAILED, $response['wo_comment'], $context, true);
echo $response;
exit;
}
$context['device_objects_uri'] = $response['wo_newparams'];
$context['device_id'] = $device_id;

$response = prepare_json_response(ENDED, "Files Attached to Device listed Successfully", $context, true);
echo $response;

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

require_once '/opt/fmc_repository/Process/Reference/Common/common.php';

$device_id = $context['device_id'];

$cmd = "bash /opt/ubi-jentreprise/bin/api/device/readDeviceById.sh $device_id |grep configurationProfileId";

logToFile("COMMAND TO GET PROFILE ID:" .$cmd."\n");
$result = shell_exec ("$cmd");

if(!preg_match('/\<configurationProfileId\>(\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\>(.*)\<\/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;

?>
17 changes: 17 additions & 0 deletions Reference/MSActivator/Orchestration/.meta_Task_Pause.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<metadata>
<map>
<entry>
<key>DATE_MODIFICATION</key>
<value>1453292430598</value>
</entry>
<entry>
<key>DATE_CREATION</key>
<value>1453292418180</value>
</entry>
<entry>
<key>TYPE</key>
<value>FILE</value>
</entry>
</map>
</metadata>
9 changes: 9 additions & 0 deletions Reference/MSActivator/Orchestration/Task_Pause.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
require_once '/opt/fmc_repository/Process/Reference/Common/common.php';

function list_args()
{}

$ret = prepare_json_response(PAUSED, 'Paused : Waiting for user action', $context);
echo "$ret\n";
?>