diff --git a/Public_Cloud/AWS/Simple_Instance_Management/.meta_Process_delete_service b/Public_Cloud/AWS/Simple_Instance_Management/.meta_Process_delete_service new file mode 100755 index 000000000..bf979b1a2 --- /dev/null +++ b/Public_Cloud/AWS/Simple_Instance_Management/.meta_Process_delete_service @@ -0,0 +1,31 @@ + + + + + DISPLAYNAME + Process_delete_service + + + DATE_MODIFICATION + 1611137625684 + + + REPOSITORY + Process + + + DATE_CREATION + 1611137625679 + + + TAG + + + TYPE + DIRECTORY + + + COMMENT + + + diff --git a/Public_Cloud/AWS/Simple_Instance_Management/.meta_Process_onboard_instance b/Public_Cloud/AWS/Simple_Instance_Management/.meta_Process_onboard_instance new file mode 100755 index 000000000..2df7b67b4 --- /dev/null +++ b/Public_Cloud/AWS/Simple_Instance_Management/.meta_Process_onboard_instance @@ -0,0 +1,31 @@ + + + + + DISPLAYNAME + Process_onboard_instance + + + DATE_MODIFICATION + 1611137408554 + + + REPOSITORY + Process + + + DATE_CREATION + 1611137408549 + + + TAG + + + TYPE + DIRECTORY + + + COMMENT + + + diff --git a/Public_Cloud/AWS/Simple_Instance_Management/.meta_Process_start_instance b/Public_Cloud/AWS/Simple_Instance_Management/.meta_Process_start_instance new file mode 100755 index 000000000..f3b709724 --- /dev/null +++ b/Public_Cloud/AWS/Simple_Instance_Management/.meta_Process_start_instance @@ -0,0 +1,31 @@ + + + + + DISPLAYNAME + Process_start_instance + + + DATE_MODIFICATION + 1611137603614 + + + REPOSITORY + Process + + + DATE_CREATION + 1611137603607 + + + TAG + + + TYPE + DIRECTORY + + + COMMENT + + + diff --git a/Public_Cloud/AWS/Simple_Instance_Management/.meta_Process_stop_instance b/Public_Cloud/AWS/Simple_Instance_Management/.meta_Process_stop_instance new file mode 100755 index 000000000..d1b809cf0 --- /dev/null +++ b/Public_Cloud/AWS/Simple_Instance_Management/.meta_Process_stop_instance @@ -0,0 +1,31 @@ + + + + + DISPLAYNAME + Process_stop_instance + + + DATE_MODIFICATION + 1611137612427 + + + REPOSITORY + Process + + + DATE_CREATION + 1611137612422 + + + TAG + + + TYPE + DIRECTORY + + + COMMENT + + + diff --git a/Public_Cloud/AWS/Simple_Instance_Management/.meta_simple_instance_management.xml b/Public_Cloud/AWS/Simple_Instance_Management/.meta_simple_instance_management.xml new file mode 100755 index 000000000..10d202de7 --- /dev/null +++ b/Public_Cloud/AWS/Simple_Instance_Management/.meta_simple_instance_management.xml @@ -0,0 +1,43 @@ + + + + + DISPLAYNAME + simple_instance_management.xml + + + DATE_MODIFICATION + 1611147160570 + + + REPOSITORY + Process + + + DATE_CREATION + 1611147160560 + + + MODEL + 0 + + + TAG + + + FILE_TYPE + text + + + MANUFACTURER + 0 + + + TYPE + FILE + + + COMMENT + + + diff --git a/Public_Cloud/AWS/Simple_Instance_Management/Process_delete_service/.meta_Tasks b/Public_Cloud/AWS/Simple_Instance_Management/Process_delete_service/.meta_Tasks new file mode 100755 index 000000000..abff53a66 --- /dev/null +++ b/Public_Cloud/AWS/Simple_Instance_Management/Process_delete_service/.meta_Tasks @@ -0,0 +1,31 @@ + + + + + DISPLAYNAME + Tasks + + + DATE_MODIFICATION + 1611137625718 + + + REPOSITORY + Process + + + DATE_CREATION + 1611137625713 + + + TAG + + + TYPE + DIRECTORY + + + COMMENT + + + diff --git a/Public_Cloud/AWS/Simple_Instance_Management/Process_onboard_instance/.meta_Tasks b/Public_Cloud/AWS/Simple_Instance_Management/Process_onboard_instance/.meta_Tasks new file mode 100755 index 000000000..bd60592b1 --- /dev/null +++ b/Public_Cloud/AWS/Simple_Instance_Management/Process_onboard_instance/.meta_Tasks @@ -0,0 +1,31 @@ + + + + + DISPLAYNAME + Tasks + + + DATE_MODIFICATION + 1611137408620 + + + REPOSITORY + Process + + + DATE_CREATION + 1611137408615 + + + TAG + + + TYPE + DIRECTORY + + + COMMENT + + + diff --git a/Public_Cloud/AWS/Simple_Instance_Management/Process_onboard_instance/Tasks/.meta_Task_onboard_instance.php b/Public_Cloud/AWS/Simple_Instance_Management/Process_onboard_instance/Tasks/.meta_Task_onboard_instance.php new file mode 100755 index 000000000..21c22195d --- /dev/null +++ b/Public_Cloud/AWS/Simple_Instance_Management/Process_onboard_instance/Tasks/.meta_Task_onboard_instance.php @@ -0,0 +1,35 @@ + + + + + DISPLAYNAME + Task_onboard_instance.php + + + DATE_MODIFICATION + 1611147052800 + + + REPOSITORY + Process + + + DATE_CREATION + 1611147052795 + + + TAG + + + FILE_TYPE + text + + + TYPE + UPLOAD + + + COMMENT + + + diff --git a/Public_Cloud/AWS/Simple_Instance_Management/Process_onboard_instance/Tasks/Task_onboard_instance.php b/Public_Cloud/AWS/Simple_Instance_Management/Process_onboard_instance/Tasks/Task_onboard_instance.php new file mode 100755 index 000000000..9dd0854ab --- /dev/null +++ b/Public_Cloud/AWS/Simple_Instance_Management/Process_onboard_instance/Tasks/Task_onboard_instance.php @@ -0,0 +1,58 @@ + $PROCESSINSTANCEID, + 'EXECNUMBER' => $EXECNUMBER, + 'TASKID' => $TASKID); +$context['id_for_display'] = $context['SERVICEINSTANCEID']." - ".$context['instance_id']; + +$device_id = substr($context['aws_device_id'], 3); + +$response = synchronize_objects_and_verify_response($device_id); + +$response = _device_read_by_id($device_id); +$response = json_decode($response, true); +if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + echo $response; + exit; +} +$key = $response['wo_newparams']['login']; +$context["key"] = $key; +$secret = $response['wo_newparams']['password']; +$context["secret"] = $secret; + + +$response = _device_get_hostname_by_id($device_id); +$response = json_decode($response, true); +if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + echo $response; + exit; +} + +$region = $response['wo_newparams']['hostname']; +$context["region"] = $region; + +$instance_id = $context['instance_id']; +task_success("$instance_id onboarded"); +?> \ No newline at end of file diff --git a/Public_Cloud/AWS/Simple_Instance_Management/Process_start_instance/.meta_Tasks b/Public_Cloud/AWS/Simple_Instance_Management/Process_start_instance/.meta_Tasks new file mode 100755 index 000000000..6423e7a03 --- /dev/null +++ b/Public_Cloud/AWS/Simple_Instance_Management/Process_start_instance/.meta_Tasks @@ -0,0 +1,31 @@ + + + + + DISPLAYNAME + Tasks + + + DATE_MODIFICATION + 1611137603642 + + + REPOSITORY + Process + + + DATE_CREATION + 1611137603637 + + + TAG + + + TYPE + DIRECTORY + + + COMMENT + + + diff --git a/Public_Cloud/AWS/Simple_Instance_Management/Process_start_instance/Tasks/.meta_Task_start_instance.php b/Public_Cloud/AWS/Simple_Instance_Management/Process_start_instance/Tasks/.meta_Task_start_instance.php new file mode 100755 index 000000000..eaedef93e --- /dev/null +++ b/Public_Cloud/AWS/Simple_Instance_Management/Process_start_instance/Tasks/.meta_Task_start_instance.php @@ -0,0 +1,35 @@ + + + + + DISPLAYNAME + Task_start_instance.php + + + DATE_MODIFICATION + 1611138164970 + + + REPOSITORY + Process + + + DATE_CREATION + 1611137646127 + + + TAG + + + FILE_TYPE + text + + + TYPE + UPLOAD + + + COMMENT + + + diff --git a/Public_Cloud/AWS/Simple_Instance_Management/Process_start_instance/Tasks/Task_start_instance.php b/Public_Cloud/AWS/Simple_Instance_Management/Process_start_instance/Tasks/Task_start_instance.php new file mode 100755 index 000000000..b63c7f438 --- /dev/null +++ b/Public_Cloud/AWS/Simple_Instance_Management/Process_start_instance/Tasks/Task_start_instance.php @@ -0,0 +1,33 @@ + $context["key"], + 'secret' => $context["secret"], + 'region' => $context["region"] +)); + +logToFile("ec2 client successful"); + +$array = array("InstanceIds" => array($context["instance_id"])); +$result = $ec2Client->startInstances($array); + +try { + $res = $result->toArray(); + logToFile(debug_dump($res, "AWS response\n")); + +} +catch (Exception $e) { + task_exit(FAILED, "Error : $e"); +} + +task_exit(ENDED, "VM successfully started. Id : " . $context["instance_id"]); + +?> diff --git a/Public_Cloud/AWS/Simple_Instance_Management/Process_stop_instance/.meta_Tasks b/Public_Cloud/AWS/Simple_Instance_Management/Process_stop_instance/.meta_Tasks new file mode 100755 index 000000000..c91b76b78 --- /dev/null +++ b/Public_Cloud/AWS/Simple_Instance_Management/Process_stop_instance/.meta_Tasks @@ -0,0 +1,31 @@ + + + + + DISPLAYNAME + Tasks + + + DATE_MODIFICATION + 1611137612457 + + + REPOSITORY + Process + + + DATE_CREATION + 1611137612451 + + + TAG + + + TYPE + DIRECTORY + + + COMMENT + + + diff --git a/Public_Cloud/AWS/Simple_Instance_Management/Process_stop_instance/Tasks/.meta_Task_stop_instance.php b/Public_Cloud/AWS/Simple_Instance_Management/Process_stop_instance/Tasks/.meta_Task_stop_instance.php new file mode 100755 index 000000000..2cf4908c9 --- /dev/null +++ b/Public_Cloud/AWS/Simple_Instance_Management/Process_stop_instance/Tasks/.meta_Task_stop_instance.php @@ -0,0 +1,35 @@ + + + + + DISPLAYNAME + Task_stop_instance.php + + + DATE_MODIFICATION + 1611139464953 + + + REPOSITORY + Process + + + DATE_CREATION + 1611137676563 + + + TAG + + + FILE_TYPE + text + + + TYPE + UPLOAD + + + COMMENT + + + diff --git a/Public_Cloud/AWS/Simple_Instance_Management/Process_stop_instance/Tasks/Task_stop_instance.php b/Public_Cloud/AWS/Simple_Instance_Management/Process_stop_instance/Tasks/Task_stop_instance.php new file mode 100755 index 000000000..4b9448d1d --- /dev/null +++ b/Public_Cloud/AWS/Simple_Instance_Management/Process_stop_instance/Tasks/Task_stop_instance.php @@ -0,0 +1,42 @@ + $context["key"], + 'secret' => $context["secret"], + 'region' => $context["region"] +)); + +logToFile("ec2 client successful:" . $context["instance_id"] . " Region: " . $context["region"]); + +$force = true; +$array = array("Force" => $force, "InstanceIds" => array($context["instance_id"])); + +$result = $ec2Client->stopInstances($array); + +try { + $res = $result->toArray(); + logToFile(debug_dump($res, "AWS response\n")); + +} +catch (Exception $e) { + task_exit(FAILED, "Error : $e"); +} + +task_exit(ENDED, "VM successfully stopped. Id : " . $context["instance_id"]); + +?> diff --git a/Public_Cloud/AWS/Simple_Instance_Management/simple_instance_management.xml b/Public_Cloud/AWS/Simple_Instance_Management/simple_instance_management.xml new file mode 100644 index 000000000..2fea02b8b --- /dev/null +++ b/Public_Cloud/AWS/Simple_Instance_Management/simple_instance_management.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + Onboard Instance + CREATE + 5 + + + /opt/fmc_repository/Process/Public_Cloud/AWS/Simple_Instance_Management/Process_onboard_instance/Tasks + onboard_instance + + + + Start Instance + UPDATE + 5 + + + /opt/fmc_repository/Process/Public_Cloud/AWS/Simple_Instance_Management/Process_start_instance/Tasks + start_instance + + + + Stop Instance + UPDATE + 5 + + + /opt/fmc_repository/Process/Public_Cloud/AWS/Simple_Instance_Management/Process_stop_instance/Tasks + stop_instance + + + + Delete Service + DELETE + 5 + + + + + Onboards an existing instance and provides start/stop actions + id_for_display + php + 10000 + 5 + Simple Instance Management on AWS + training|util + +