From d0f101d1703e3c279300f5bfc79ef1459913842f Mon Sep 17 00:00:00 2001 From: root Date: Wed, 20 Jan 2021 10:01:21 +0000 Subject: [PATCH 1/7] initial commit --- .../.meta_simple_vnf_management_on_aws.xml | 43 +++++++++++++++++++ .../simple_vnf_management_on_aws.xml | 14 ++++++ 2 files changed, 57 insertions(+) create mode 100755 Public_Cloud/AWS/Simple_Instance_Management/.meta_simple_vnf_management_on_aws.xml create mode 100644 Public_Cloud/AWS/Simple_Instance_Management/simple_vnf_management_on_aws.xml diff --git a/Public_Cloud/AWS/Simple_Instance_Management/.meta_simple_vnf_management_on_aws.xml b/Public_Cloud/AWS/Simple_Instance_Management/.meta_simple_vnf_management_on_aws.xml new file mode 100755 index 000000000..808aa9d9b --- /dev/null +++ b/Public_Cloud/AWS/Simple_Instance_Management/.meta_simple_vnf_management_on_aws.xml @@ -0,0 +1,43 @@ + + + + + DISPLAYNAME + simple_vnf_management_on_aws.xml + + + DATE_MODIFICATION + 1611136738886 + + + REPOSITORY + Process + + + DATE_CREATION + 1611136738880 + + + MODEL + 0 + + + TAG + + + FILE_TYPE + text + + + MANUFACTURER + 0 + + + TYPE + FILE + + + COMMENT + + + diff --git a/Public_Cloud/AWS/Simple_Instance_Management/simple_vnf_management_on_aws.xml b/Public_Cloud/AWS/Simple_Instance_Management/simple_vnf_management_on_aws.xml new file mode 100644 index 000000000..43c3c6071 --- /dev/null +++ b/Public_Cloud/AWS/Simple_Instance_Management/simple_vnf_management_on_aws.xml @@ -0,0 +1,14 @@ + + + + + + + service_id + php + 10000 + 5 + Simple VNF Management on AWS + + + From fd8fd906e9c6223cfad6b4d361958f5048ee0c0c Mon Sep 17 00:00:00 2001 From: root Date: Wed, 20 Jan 2021 10:15:36 +0000 Subject: [PATCH 2/7] delete files --- .../.meta_simple_vnf_management_on_aws.xml | 43 ------------------- .../simple_vnf_management_on_aws.xml | 14 ------ 2 files changed, 57 deletions(-) delete mode 100755 Public_Cloud/AWS/Simple_Instance_Management/.meta_simple_vnf_management_on_aws.xml delete mode 100644 Public_Cloud/AWS/Simple_Instance_Management/simple_vnf_management_on_aws.xml diff --git a/Public_Cloud/AWS/Simple_Instance_Management/.meta_simple_vnf_management_on_aws.xml b/Public_Cloud/AWS/Simple_Instance_Management/.meta_simple_vnf_management_on_aws.xml deleted file mode 100755 index 808aa9d9b..000000000 --- a/Public_Cloud/AWS/Simple_Instance_Management/.meta_simple_vnf_management_on_aws.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - DISPLAYNAME - simple_vnf_management_on_aws.xml - - - DATE_MODIFICATION - 1611136738886 - - - REPOSITORY - Process - - - DATE_CREATION - 1611136738880 - - - MODEL - 0 - - - TAG - - - FILE_TYPE - text - - - MANUFACTURER - 0 - - - TYPE - FILE - - - COMMENT - - - diff --git a/Public_Cloud/AWS/Simple_Instance_Management/simple_vnf_management_on_aws.xml b/Public_Cloud/AWS/Simple_Instance_Management/simple_vnf_management_on_aws.xml deleted file mode 100644 index 43c3c6071..000000000 --- a/Public_Cloud/AWS/Simple_Instance_Management/simple_vnf_management_on_aws.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - service_id - php - 10000 - 5 - Simple VNF Management on AWS - - - From cf0915a854f9c8c064a549a54b31d0d368662a7d Mon Sep 17 00:00:00 2001 From: root Date: Wed, 20 Jan 2021 10:15:59 +0000 Subject: [PATCH 3/7] add empty processes/tasks --- .../.meta_Process_delete_service | 31 +++++++++++ .../.meta_Process_onboard_instance | 31 +++++++++++ .../.meta_Process_start_instance | 31 +++++++++++ .../.meta_Process_stop_instance | 31 +++++++++++ .../.meta_simple_instance_management.xml | 43 +++++++++++++++ .../Process_delete_service/.meta_Tasks | 31 +++++++++++ .../Process_onboard_instance/.meta_Tasks | 31 +++++++++++ .../Tasks/.meta_Task_onboard_instance.php | 35 ++++++++++++ .../Tasks/Task_onboard_instance.php | 20 +++++++ .../Process_start_instance/.meta_Tasks | 31 +++++++++++ .../Tasks/.meta_Task_start_instance.php | 35 ++++++++++++ .../Tasks/Task_start_instance.php | 16 ++++++ .../Process_stop_instance/.meta_Tasks | 31 +++++++++++ .../Tasks/.meta_Task_stop_instance.php | 35 ++++++++++++ .../Tasks/Task_stop_instance.php | 16 ++++++ .../simple_instance_management.xml | 53 +++++++++++++++++++ 16 files changed, 501 insertions(+) create mode 100755 Public_Cloud/AWS/Simple_Instance_Management/.meta_Process_delete_service create mode 100755 Public_Cloud/AWS/Simple_Instance_Management/.meta_Process_onboard_instance create mode 100755 Public_Cloud/AWS/Simple_Instance_Management/.meta_Process_start_instance create mode 100755 Public_Cloud/AWS/Simple_Instance_Management/.meta_Process_stop_instance create mode 100755 Public_Cloud/AWS/Simple_Instance_Management/.meta_simple_instance_management.xml create mode 100755 Public_Cloud/AWS/Simple_Instance_Management/Process_delete_service/.meta_Tasks create mode 100755 Public_Cloud/AWS/Simple_Instance_Management/Process_onboard_instance/.meta_Tasks create mode 100755 Public_Cloud/AWS/Simple_Instance_Management/Process_onboard_instance/Tasks/.meta_Task_onboard_instance.php create mode 100755 Public_Cloud/AWS/Simple_Instance_Management/Process_onboard_instance/Tasks/Task_onboard_instance.php create mode 100755 Public_Cloud/AWS/Simple_Instance_Management/Process_start_instance/.meta_Tasks create mode 100755 Public_Cloud/AWS/Simple_Instance_Management/Process_start_instance/Tasks/.meta_Task_start_instance.php create mode 100755 Public_Cloud/AWS/Simple_Instance_Management/Process_start_instance/Tasks/Task_start_instance.php create mode 100755 Public_Cloud/AWS/Simple_Instance_Management/Process_stop_instance/.meta_Tasks create mode 100755 Public_Cloud/AWS/Simple_Instance_Management/Process_stop_instance/Tasks/.meta_Task_stop_instance.php create mode 100755 Public_Cloud/AWS/Simple_Instance_Management/Process_stop_instance/Tasks/Task_stop_instance.php create mode 100644 Public_Cloud/AWS/Simple_Instance_Management/simple_instance_management.xml 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..cdf5d84b3 --- /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 + 1611137706398 + + + REPOSITORY + Process + + + DATE_CREATION + 1611137706391 + + + 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..1e9e4c393 --- /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 + 1611137485898 + + + REPOSITORY + Process + + + DATE_CREATION + 1611137421398 + + + 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..c42123c31 --- /dev/null +++ b/Public_Cloud/AWS/Simple_Instance_Management/Process_onboard_instance/Tasks/Task_onboard_instance.php @@ -0,0 +1,20 @@ + \ 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..9aad8db5d --- /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 + 1611137662989 + + + 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..3fea4f2c3 --- /dev/null +++ b/Public_Cloud/AWS/Simple_Instance_Management/Process_start_instance/Tasks/Task_start_instance.php @@ -0,0 +1,16 @@ + \ No newline at end of file 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..484e48f31 --- /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 + 1611137694276 + + + 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..3fea4f2c3 --- /dev/null +++ b/Public_Cloud/AWS/Simple_Instance_Management/Process_stop_instance/Tasks/Task_stop_instance.php @@ -0,0 +1,16 @@ + \ No newline at end of file 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..17ec626f1 --- /dev/null +++ b/Public_Cloud/AWS/Simple_Instance_Management/simple_instance_management.xml @@ -0,0 +1,53 @@ + + + + + + + + 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 + + + + + + service_id + php + 10000 + 5 + Simple Instance Management on AWS + + + From 92c6d91469b0e10fdb062ed6cabf46cc28292ff9 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 20 Jan 2021 10:35:14 +0000 Subject: [PATCH 4/7] update code --- .../Tasks/.meta_Task_onboard_instance.php | 2 +- .../Tasks/Task_onboard_instance.php | 43 ++++++++++++++++++- .../Tasks/.meta_Task_start_instance.php | 2 +- .../Tasks/Task_start_instance.php | 31 ++++++++++--- .../Tasks/.meta_Task_stop_instance.php | 2 +- .../Tasks/Task_stop_instance.php | 34 ++++++++++++++- .../simple_instance_management.xml | 5 +++ 7 files changed, 106 insertions(+), 13 deletions(-) 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 index 1e9e4c393..1e5755d43 100755 --- 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 @@ -7,7 +7,7 @@ DATE_MODIFICATION - 1611137485898 + 1611138670761 REPOSITORY 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 index c42123c31..7718752cb 100755 --- 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 @@ -10,11 +10,52 @@ */ function list_args() { - + create_var_def('aws_device_id', 'Device'); create_var_def('instance_id', 'String'); } check_mandatory_param('instance_id'); +check_mandatory_param('aws_device_id'); + + +$PROCESSINSTANCEID = $context['PROCESSINSTANCEID']; +$EXECNUMBER = $context['EXECNUMBER']; +$TASKID = $context['TASKID']; +$process_params = array('PROCESSINSTANCEID' => $PROCESSINSTANCEID, + 'EXECNUMBER' => $EXECNUMBER, + 'TASKID' => $TASKID); +$context['service_id'] = $context['SERVICEINSTANCEID']." - ".$context['instance_id'] + +$device_id = substr($context['AwsDeviceId'], 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; + +$region = $context["region"]; +$key=$context["key"]; +$secret = $context["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; task_success($context['instance_id']." onboarded"); ?> \ No newline at end of file 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 index 9aad8db5d..eaedef93e 100755 --- 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 @@ -7,7 +7,7 @@ DATE_MODIFICATION - 1611137662989 + 1611138164970 REPOSITORY 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 index 3fea4f2c3..b63c7f438 100755 --- 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 @@ -4,13 +4,30 @@ * This file is necessary to include to use all the in-built libraries of /opt/fmc_repository/Reference/Common */ require_once '/opt/fmc_repository/Process/Reference/Common/common.php'; +require '/opt/devops/OpenMSA_Adapters/vendor/autoload.php'; -/** - * List all the parameters required by the task - */ -function list_args() -{ +use Aws\Ec2\Ec2Client; + +$ec2Client = Ec2Client::factory(array( + 'key' => $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"]); -task_success('Task OK'); -?> \ No newline at end of file +?> 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 index 484e48f31..7384ae679 100755 --- 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 @@ -7,7 +7,7 @@ DATE_MODIFICATION - 1611137694276 + 1611138170476 REPOSITORY 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 index 3fea4f2c3..d1828ec1b 100755 --- 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 @@ -4,13 +4,43 @@ * This file is necessary to include to use all the in-built libraries of /opt/fmc_repository/Reference/Common */ require_once '/opt/fmc_repository/Process/Reference/Common/common.php'; +require '/opt/devops/OpenMSA_Adapters/vendor/autoload.php'; + +use Aws\Ec2\Ec2Client; /** * List all the parameters required by the task */ function list_args() { + create_var_def("force", "Boolean"); +} + +$ec2Client = Ec2Client::factory(array( + 'key' => $context["key"], + 'secret' => $context["secret"], + 'region' => $context["region"] +)); + +logToFile("ec2 client successful:" . $context["InstanceId"] . " Region: " . $context["region"]); + +$force = true; +if ($context["force"] === "false") { + $force = false; } +$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"]); -task_success('Task OK'); -?> \ No newline at end of file +?> diff --git a/Public_Cloud/AWS/Simple_Instance_Management/simple_instance_management.xml b/Public_Cloud/AWS/Simple_Instance_Management/simple_instance_management.xml index 17ec626f1..12a9264c1 100644 --- a/Public_Cloud/AWS/Simple_Instance_Management/simple_instance_management.xml +++ b/Public_Cloud/AWS/Simple_Instance_Management/simple_instance_management.xml @@ -1,5 +1,10 @@ + + + + + From f7b9f7069733277f369b0c388fd9e6cbedbe0399 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 20 Jan 2021 10:51:32 +0000 Subject: [PATCH 5/7] last fixed after testing --- .../.meta_simple_instance_management.xml | 4 ++-- .../Tasks/.meta_Task_onboard_instance.php | 2 +- .../Tasks/Task_onboard_instance.php | 12 +++++------- .../Tasks/.meta_Task_stop_instance.php | 2 +- .../Tasks/Task_stop_instance.php | 6 +----- 5 files changed, 10 insertions(+), 16 deletions(-) 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 index cdf5d84b3..b0302d9d8 100755 --- a/Public_Cloud/AWS/Simple_Instance_Management/.meta_simple_instance_management.xml +++ b/Public_Cloud/AWS/Simple_Instance_Management/.meta_simple_instance_management.xml @@ -7,7 +7,7 @@ DATE_MODIFICATION - 1611137706398 + 1611139465944 REPOSITORY @@ -15,7 +15,7 @@ DATE_CREATION - 1611137706391 + 1611139465937 MODEL 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 index 1e5755d43..0a16a62ae 100755 --- 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 @@ -7,7 +7,7 @@ DATE_MODIFICATION - 1611138670761 + 1611139221497 REPOSITORY 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 index 7718752cb..83ecc603f 100755 --- 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 @@ -24,9 +24,9 @@ function list_args() $process_params = array('PROCESSINSTANCEID' => $PROCESSINSTANCEID, 'EXECNUMBER' => $EXECNUMBER, 'TASKID' => $TASKID); -$context['service_id'] = $context['SERVICEINSTANCEID']." - ".$context['instance_id'] +$context['service_id'] = $context['SERVICEINSTANCEID']." - ".$context['instance_id']; -$device_id = substr($context['AwsDeviceId'], 3); +$device_id = substr($context['aws_device_id'], 3); $response = synchronize_objects_and_verify_response($device_id); @@ -42,10 +42,6 @@ function list_args() $secret = $response['wo_newparams']['password']; $context["secret"] = $secret; -$region = $context["region"]; -$key=$context["key"]; -$secret = $context["secret"]; - $response = _device_get_hostname_by_id($device_id); $response = json_decode($response, true); @@ -54,8 +50,10 @@ function list_args() echo $response; exit; } + $region = $response['wo_newparams']['hostname']; $context["region"] = $region; -task_success($context['instance_id']." onboarded"); +$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_stop_instance/Tasks/.meta_Task_stop_instance.php b/Public_Cloud/AWS/Simple_Instance_Management/Process_stop_instance/Tasks/.meta_Task_stop_instance.php index 7384ae679..2cf4908c9 100755 --- 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 @@ -7,7 +7,7 @@ DATE_MODIFICATION - 1611138170476 + 1611139464953 REPOSITORY 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 index d1828ec1b..4b9448d1d 100755 --- 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 @@ -13,7 +13,6 @@ */ function list_args() { - create_var_def("force", "Boolean"); } $ec2Client = Ec2Client::factory(array( @@ -22,12 +21,9 @@ function list_args() 'region' => $context["region"] )); -logToFile("ec2 client successful:" . $context["InstanceId"] . " Region: " . $context["region"]); +logToFile("ec2 client successful:" . $context["instance_id"] . " Region: " . $context["region"]); $force = true; -if ($context["force"] === "false") { - $force = false; -} $array = array("Force" => $force, "InstanceIds" => array($context["instance_id"])); $result = $ec2Client->stopInstances($array); From fbee2a1522b0263a2c73ab7882532c6323187f25 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 20 Jan 2021 11:38:56 +0000 Subject: [PATCH 6/7] update display var for service ID --- .../.meta_simple_instance_management.xml | 4 ++-- .../Tasks/.meta_Task_onboard_instance.php | 2 +- .../Process_onboard_instance/Tasks/Task_onboard_instance.php | 3 +-- .../Simple_Instance_Management/simple_instance_management.xml | 4 +++- 4 files changed, 7 insertions(+), 6 deletions(-) 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 index b0302d9d8..d1d874737 100755 --- a/Public_Cloud/AWS/Simple_Instance_Management/.meta_simple_instance_management.xml +++ b/Public_Cloud/AWS/Simple_Instance_Management/.meta_simple_instance_management.xml @@ -7,7 +7,7 @@ DATE_MODIFICATION - 1611139465944 + 1611140481278 REPOSITORY @@ -15,7 +15,7 @@ DATE_CREATION - 1611139465937 + 1611140481273 MODEL 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 index 0a16a62ae..1f024c382 100755 --- 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 @@ -7,7 +7,7 @@ DATE_MODIFICATION - 1611139221497 + 1611140480228 REPOSITORY 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 index 83ecc603f..9dd0854ab 100755 --- 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 @@ -17,14 +17,13 @@ function list_args() check_mandatory_param('instance_id'); check_mandatory_param('aws_device_id'); - $PROCESSINSTANCEID = $context['PROCESSINSTANCEID']; $EXECNUMBER = $context['EXECNUMBER']; $TASKID = $context['TASKID']; $process_params = array('PROCESSINSTANCEID' => $PROCESSINSTANCEID, 'EXECNUMBER' => $EXECNUMBER, 'TASKID' => $TASKID); -$context['service_id'] = $context['SERVICEINSTANCEID']." - ".$context['instance_id']; +$context['id_for_display'] = $context['SERVICEINSTANCEID']." - ".$context['instance_id']; $device_id = substr($context['aws_device_id'], 3); diff --git a/Public_Cloud/AWS/Simple_Instance_Management/simple_instance_management.xml b/Public_Cloud/AWS/Simple_Instance_Management/simple_instance_management.xml index 12a9264c1..ba71479c3 100644 --- a/Public_Cloud/AWS/Simple_Instance_Management/simple_instance_management.xml +++ b/Public_Cloud/AWS/Simple_Instance_Management/simple_instance_management.xml @@ -7,6 +7,8 @@ + + @@ -48,7 +50,7 @@ - service_id + id_for_display php 10000 5 From 73d72b8c31bfbe1a081f21837738a20d21acd807 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 20 Jan 2021 12:54:07 +0000 Subject: [PATCH 7/7] set a category --- .../.meta_simple_instance_management.xml | 4 ++-- .../Tasks/.meta_Task_onboard_instance.php | 4 ++-- .../Simple_Instance_Management/simple_instance_management.xml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) 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 index d1d874737..10d202de7 100755 --- a/Public_Cloud/AWS/Simple_Instance_Management/.meta_simple_instance_management.xml +++ b/Public_Cloud/AWS/Simple_Instance_Management/.meta_simple_instance_management.xml @@ -7,7 +7,7 @@ DATE_MODIFICATION - 1611140481278 + 1611147160570 REPOSITORY @@ -15,7 +15,7 @@ DATE_CREATION - 1611140481273 + 1611147160560 MODEL 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 index 1f024c382..21c22195d 100755 --- 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 @@ -7,7 +7,7 @@ DATE_MODIFICATION - 1611140480228 + 1611147052800 REPOSITORY @@ -15,7 +15,7 @@ DATE_CREATION - 1611137421398 + 1611147052795 TAG diff --git a/Public_Cloud/AWS/Simple_Instance_Management/simple_instance_management.xml b/Public_Cloud/AWS/Simple_Instance_Management/simple_instance_management.xml index ba71479c3..2fea02b8b 100644 --- a/Public_Cloud/AWS/Simple_Instance_Management/simple_instance_management.xml +++ b/Public_Cloud/AWS/Simple_Instance_Management/simple_instance_management.xml @@ -49,12 +49,12 @@ - + Onboards an existing instance and provides start/stop actions id_for_display php 10000 5 Simple Instance Management on AWS - + training|util