diff --git a/.meta_Cisco_ZTD_service b/.meta_Cisco_ZTD_service new file mode 100644 index 000000000..b6bb70cd5 --- /dev/null +++ b/.meta_Cisco_ZTD_service @@ -0,0 +1,39 @@ + + + + + MODEL + + + DATE_MODIFICATION + 1488536691430 + + + COMMENT + + + + REPOSITORY + CommandDefinition + + + DATE_CREATION + 1488536691378 + + + MANUFACTURER + + + CONFIGURATION_FILTER + + + + TYPE + DIRECTORY + + + TAG + + + + diff --git a/.meta_MSA_Micro_Service_Tasks_Builder b/.meta_MSA_Micro_Service_Tasks_Builder new file mode 100644 index 000000000..b62763812 --- /dev/null +++ b/.meta_MSA_Micro_Service_Tasks_Builder @@ -0,0 +1,39 @@ + + + + + MODEL + + + DATE_MODIFICATION + 1453798968685 + + + COMMENT + + + + REPOSITORY + CommandDefinition + + + DATE_CREATION + 1453798968671 + + + MANUFACTURER + + + CONFIGURATION_FILTER + + + + TYPE + DIRECTORY + + + TAG + + + + diff --git a/.meta_MSA_Template_Management b/.meta_MSA_Template_Management new file mode 100644 index 000000000..b62763812 --- /dev/null +++ b/.meta_MSA_Template_Management @@ -0,0 +1,39 @@ + + + + + MODEL + + + DATE_MODIFICATION + 1453798968685 + + + COMMENT + + + + REPOSITORY + CommandDefinition + + + DATE_CREATION + 1453798968671 + + + MANUFACTURER + + + CONFIGURATION_FILTER + + + + TYPE + DIRECTORY + + + TAG + + + + diff --git a/.meta_MSA_Template_Workflows b/.meta_MSA_Template_Workflows new file mode 100644 index 000000000..b62763812 --- /dev/null +++ b/.meta_MSA_Template_Workflows @@ -0,0 +1,39 @@ + + + + + MODEL + + + DATE_MODIFICATION + 1453798968685 + + + COMMENT + + + + REPOSITORY + CommandDefinition + + + DATE_CREATION + 1453798968671 + + + MANUFACTURER + + + CONFIGURATION_FILTER + + + + TYPE + DIRECTORY + + + TAG + + + + diff --git a/.meta_Reference b/.meta_Reference index 82a62f1b7..b62763812 100755 --- a/.meta_Reference +++ b/.meta_Reference @@ -6,7 +6,7 @@ DATE_MODIFICATION - 1513269379142 + 1453798968685 COMMENT @@ -18,7 +18,7 @@ DATE_CREATION - 1513269379130 + 1453798968671 MANUFACTURER diff --git a/.meta_Test_SubProcess b/.meta_Test_SubProcess new file mode 100644 index 000000000..76e64ed50 --- /dev/null +++ b/.meta_Test_SubProcess @@ -0,0 +1,39 @@ + + + + + MODEL + + + DATE_MODIFICATION + 1489051934058 + + + COMMENT + + + + REPOSITORY + CommandDefinition + + + DATE_CREATION + 1489051934025 + + + MANUFACTURER + + + CONFIGURATION_FILTER + + + + TYPE + DIRECTORY + + + TAG + Topology_SNMP + + + diff --git a/.meta_Topology b/.meta_Topology new file mode 100644 index 000000000..76e64ed50 --- /dev/null +++ b/.meta_Topology @@ -0,0 +1,39 @@ + + + + + MODEL + + + DATE_MODIFICATION + 1489051934058 + + + COMMENT + + + + REPOSITORY + CommandDefinition + + + DATE_CREATION + 1489051934025 + + + MANUFACTURER + + + CONFIGURATION_FILTER + + + + TYPE + DIRECTORY + + + TAG + Topology_SNMP + + + diff --git a/Cisco_ZTD_service/.meta_Cisco_ZTD_Service.xml b/Cisco_ZTD_service/.meta_Cisco_ZTD_Service.xml new file mode 100644 index 000000000..8bc93f6a4 --- /dev/null +++ b/Cisco_ZTD_service/.meta_Cisco_ZTD_Service.xml @@ -0,0 +1,37 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1489676134088 + + + COMMENT + + + + REPOSITORY + CommandDefinition + + + DATE_CREATION + 1488536718927 + + + CONFIGURATION_FILTER + + + + TYPE + UPLOAD + + + TAG + Upload_1.xml + + + diff --git a/Cisco_ZTD_service/.meta_Process_Create_Device b/Cisco_ZTD_service/.meta_Process_Create_Device new file mode 100644 index 000000000..c26b5e787 --- /dev/null +++ b/Cisco_ZTD_service/.meta_Process_Create_Device @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1489581714438 + + + DATE_CREATION + 1489581714431 + + + TYPE + DIRECTORY + + + diff --git a/Cisco_ZTD_service/.meta_Process_Enable_ZTD b/Cisco_ZTD_service/.meta_Process_Enable_ZTD new file mode 100644 index 000000000..ab2f6d9d7 --- /dev/null +++ b/Cisco_ZTD_service/.meta_Process_Enable_ZTD @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1489658102339 + + + DATE_CREATION + 1489658102331 + + + TYPE + DIRECTORY + + + diff --git a/Cisco_ZTD_service/.meta_Process_Provision b/Cisco_ZTD_service/.meta_Process_Provision new file mode 100644 index 000000000..f932f3220 --- /dev/null +++ b/Cisco_ZTD_service/.meta_Process_Provision @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1489581019666 + + + DATE_CREATION + 1489581019660 + + + TYPE + DIRECTORY + + + diff --git a/Cisco_ZTD_service/.meta_Process_Validate_ZTD b/Cisco_ZTD_service/.meta_Process_Validate_ZTD new file mode 100644 index 000000000..fa8b1dfb2 --- /dev/null +++ b/Cisco_ZTD_service/.meta_Process_Validate_ZTD @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1488539231040 + + + DATE_CREATION + 1488539231032 + + + TYPE + DIRECTORY + + + diff --git a/Cisco_ZTD_service/.meta_Process_ZTD_Request b/Cisco_ZTD_service/.meta_Process_ZTD_Request new file mode 100644 index 000000000..39fcb292f --- /dev/null +++ b/Cisco_ZTD_service/.meta_Process_ZTD_Request @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1488536782381 + + + DATE_CREATION + 1488536782372 + + + TYPE + DIRECTORY + + + diff --git a/Cisco_ZTD_service/.meta_Process_delete b/Cisco_ZTD_service/.meta_Process_delete new file mode 100644 index 000000000..bee82ab64 --- /dev/null +++ b/Cisco_ZTD_service/.meta_Process_delete @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1489577929406 + + + DATE_CREATION + 1489577929397 + + + TYPE + DIRECTORY + + + diff --git a/Cisco_ZTD_service/Cisco_ZTD_Service.xml b/Cisco_ZTD_service/Cisco_ZTD_Service.xml new file mode 100644 index 000000000..3d83e9b22 --- /dev/null +++ b/Cisco_ZTD_service/Cisco_ZTD_Service.xml @@ -0,0 +1,139 @@ + + + + SERVICEINSTANCEREFERENCE + 5 + + /images/eclipseIcons/page_obj.gif + Cisco_ZTD_Service + 10000 + 5 + false + false + false + 5 + + + +
Instantiate
+
+
+ + +
Instantiate
+
+
+ + +
MSA Device
+
+
+ + +
MSA Device
+
+
+ + +
MSA Device
+
+
+ + +
MSA Device
+
+
+ + +
MSA Device
+
+
+ + +
MSA Device
+
+
+ + +
MSA Device
+
+
+ + +
MSA Device
+
+
+
+ + + + 5 + ZTD Request + + false + SET + + /opt/fmc_repository/Process/Cisco_ZTD_service/Process_ZTD_Request/Tasks/ + Instantiate + + + + 5 + Validate ZTD + + false + UPDATE + + + /opt/fmc_repository/Process/Cisco_ZTD_service/Process_Validate_ZTD/Tasks/ + Verify Request + + + + Provision + + + + 5 + delete + + false + DELETE + + /opt/fmc_repository/Process/Cisco_ZTD_service/Process_delete/Tasks/ + Remove lock + + + + 5 + Create Device + + false + UPDATE + + + /opt/fmc_repository/Process/Cisco_ZTD_service/Process_Create_Device/Tasks/ + Create MSA Device + + + + Provision + + + + + 5 + Enable ZTD + + false + UPDATE + + /opt/fmc_repository/Process/Cisco_ZTD_service/Process_Enable_ZTD/Tasks/ + Enable ZTD + + + + Provision + + +
diff --git a/Cisco_ZTD_service/Process_Create_Device/.meta_Tasks b/Cisco_ZTD_service/Process_Create_Device/.meta_Tasks new file mode 100644 index 000000000..1e7952775 --- /dev/null +++ b/Cisco_ZTD_service/Process_Create_Device/.meta_Tasks @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1489656980127 + + + DATE_CREATION + 1489656980119 + + + TYPE + DIRECTORY + + + diff --git a/Cisco_ZTD_service/Process_Create_Device/Tasks/.meta_Task_Create_MSA_Device.php b/Cisco_ZTD_service/Process_Create_Device/Tasks/.meta_Task_Create_MSA_Device.php new file mode 100644 index 000000000..1037db946 --- /dev/null +++ b/Cisco_ZTD_service/Process_Create_Device/Tasks/.meta_Task_Create_MSA_Device.php @@ -0,0 +1,29 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1541078442593 + + + COMMENT + + + + DATE_CREATION + 1489656980143 + + + TAG + + + + TYPE + UPLOAD + + + diff --git a/Cisco_ZTD_service/Process_Create_Device/Tasks/Task_Create_MSA_Device.php b/Cisco_ZTD_service/Process_Create_Device/Tasks/Task_Create_MSA_Device.php new file mode 100644 index 000000000..32ae36833 --- /dev/null +++ b/Cisco_ZTD_service/Process_Create_Device/Tasks/Task_Create_MSA_Device.php @@ -0,0 +1,198 @@ + 0) { + if(strpos($line, 'setHostnameResponse') !== false){ + // Success + $msg = "hostname:$host_name set to the device:$dev_seq_num"; + $ret = prepare_json_response ( ENDED, $msg, $context, true ); + $is_complete = true; + break; + } + } + if($is_complete === false){ + $msg = "Error setting device hostname:$host_name to device:$dev_seq_num"; + $ret = prepare_json_response ( FAILED, $msg, $context, true ); + } + } + return $ret; +} + +function addSerialToDevice($dev_seq_num, $serial_num,$context){ + $output_array = array (); + $cmd_line = "/opt/ubi-jentreprise/bin/api/devicefields/setSerialNumber.sh $dev_seq_num $serial_num"; + + exec ( $cmd_line, $output_array ); + + // cho "ret=$ret\n"; + if (empty ( $output_array )) { + $msg = "Error setting device serial number:$serial_num to device:$dev_seq_num"; + $ret = prepare_json_response ( FAILED, $msg, $context, true ); + } else { + $is_complete = false; + foreach ( $output_array as $line ) { + // if (preg_match ( "setSerialNumberResponse", $line ) > 0) { + if(strpos($line, 'setSerialNumberResponse') !== false){ + // Success + $msg = "Serial no.$serial_num is added to the device:$dev_seq_num"; + $ret = prepare_json_response ( ENDED, $msg, $context, true ); + $is_complete = true; + break; + } + } + if($is_complete === false){ + $msg = "Error setting device serial number:$serial_num to device:$dev_seq_num"; + $ret = prepare_json_response ( FAILED, $msg, $context, true ); + } + } + return $ret; +} + +function addDeviceToWorkorder($dev_seq_num, $work_order_ref,$context){ + $output_array = array(); + $cmd_line="/opt/ubi-ztd/bin/addDeviceToWorkOrder.sh $work_order_ref $dev_seq_num"; + + exec($cmd_line,$output_array); + + #echo "ret=$ret\n"; + if (empty($output_array)){ + $msg="Device:$dev_seq_num added to workorder:$work_order_ref"; + $ret = prepare_json_response(ENDED, $msg, $context, true); + }else{ + /* + * foreach ($output_array as $line) { echo "Line:$line\n"; } + */ + $msg = "Error adding Device:$dev_seq_num to workorder:$work_order_ref"; + $ret = prepare_json_response ( FAILED, 'Error', $context, true ); +} + +return $ret; +} + +$customer_id = $context['UBIQUBEID']; +$customer_id = substr($customer_id,4); +$managed_device_name = $context['hostname']; +$manufacturer_id = 1; +$model_id=113; +$login=$context['login']; +$password=$context['password']; +$password_admin=$context['password_admin']; +$device_ip_address = $context['mgmt_ip']; +$serial_num=$context['serialnum']; + +$response = _device_create($customer_id, $managed_device_name, $manufacturer_id, +$model_id, $login, $password, $password_admin, $device_ip_address); +$response = json_decode($response, true); +if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + echo $response; + exit; +} +$created_device_id = $response['wo_newparams']['entity']['externalReference']; +$context['device_id']= $created_device_id; +$created_seq_num= $response['wo_newparams']['entity']['id']; +$wo_comment = "DeviceID:".$created_device_id; +logToFile($wo_comment); +$response = json_encode($response); +// $response = prepare_json_response(ENDED, "MSA Device created successfully.\n" . $wo_comment, $context, true); +//Device created, now add this device to workorder +$add_wo_response = addDeviceToWorkorder($created_seq_num,WORK_ORDER_REF,$context); +$add_wo_response = json_decode($add_wo_response, true); +if ($add_wo_response['wo_status'] !== ENDED) { + $add_wo_response = json_encode($add_wo_response); + //Do device creation cleanup if necessary, not handled now + echo $add_wo_response; + exit; +} +$wo_comment = "DeviceID:$created_device_id added to workorder"; +logToFile($wo_comment); +//Add serial number ot the device +$add_serial_response = addSerialToDevice($created_seq_num,$serial_num,$context); +$add_serial_response = json_decode($add_serial_response, true); +if ($add_serial_response['wo_status'] !== ENDED) { + $add_serial_response = json_encode($add_serial_response); + //Do device creation cleanup if necessary, not handled now + echo $add_serial_response; + exit; +} +$wo_comment = "Serial number updated"; +logToFile($wo_comment); + +$setHostname_response = setHostnameToDevice($created_seq_num, $managed_device_name, $context); +$setHostname_response = json_decode($setHostname_response, true); +if ($setHostname_response['wo_status'] !== ENDED) { + $setHostname_response = json_encode($setHostname_response); + //Do device creation cleanup if necessary, not handled now + echo $setHostname_response; + exit; +} +$wo_comment = "Hostname updated"; +logToFile($wo_comment); + + +$ztd_flag=$context['enable_ztd']; +$msg="ZTD disabled"; +if($ztd_flag === 'true'){ + $cmd_line="/opt/ubi-ztd/bin/set_ztd_enabled.sh $created_device_id 1"; + shell_exec($cmd_line); + $msg="ZTD enabled"; +} +else{ + $cmd_line="/opt/ubi-ztd/bin/set_ztd_enabled.sh $created_device_id 0"; + shell_exec($cmd_line); +} +logToFile($msg); + +$message = "Device: $created_device_id created for the ZTD request coming from device with serial number:$serial_num"; +$response = prepare_json_response(ENDED, $message, $context, true); +echo $response; + +?> \ No newline at end of file diff --git a/Cisco_ZTD_service/Process_Enable_ZTD/.meta_Tasks b/Cisco_ZTD_service/Process_Enable_ZTD/.meta_Tasks new file mode 100644 index 000000000..ff57dd2c7 --- /dev/null +++ b/Cisco_ZTD_service/Process_Enable_ZTD/.meta_Tasks @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1489658140902 + + + DATE_CREATION + 1489658140895 + + + TYPE + DIRECTORY + + + diff --git a/Cisco_ZTD_service/Process_Enable_ZTD/Tasks/.meta_Task_Enable_ZTD.php b/Cisco_ZTD_service/Process_Enable_ZTD/Tasks/.meta_Task_Enable_ZTD.php new file mode 100644 index 000000000..1e6e22596 --- /dev/null +++ b/Cisco_ZTD_service/Process_Enable_ZTD/Tasks/.meta_Task_Enable_ZTD.php @@ -0,0 +1,29 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1489668296475 + + + COMMENT + + + + DATE_CREATION + 1489658140933 + + + TAG + + + + TYPE + UPLOAD + + + diff --git a/Cisco_ZTD_service/Process_Enable_ZTD/Tasks/Task_Enable_ZTD.php b/Cisco_ZTD_service/Process_Enable_ZTD/Tasks/Task_Enable_ZTD.php new file mode 100644 index 000000000..c32e20f68 --- /dev/null +++ b/Cisco_ZTD_service/Process_Enable_ZTD/Tasks/Task_Enable_ZTD.php @@ -0,0 +1,34 @@ + \ No newline at end of file diff --git a/Cisco_ZTD_service/Process_Provision/.meta_Tasks b/Cisco_ZTD_service/Process_Provision/.meta_Tasks new file mode 100644 index 000000000..767300b00 --- /dev/null +++ b/Cisco_ZTD_service/Process_Provision/.meta_Tasks @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1489656971534 + + + DATE_CREATION + 1489656971528 + + + TYPE + DIRECTORY + + + diff --git a/Cisco_ZTD_service/Process_Provision/Tasks/.meta_Task_Provision.php b/Cisco_ZTD_service/Process_Provision/Tasks/.meta_Task_Provision.php new file mode 100644 index 000000000..b7813fcbd --- /dev/null +++ b/Cisco_ZTD_service/Process_Provision/Tasks/.meta_Task_Provision.php @@ -0,0 +1,29 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1489671397343 + + + COMMENT + + + + DATE_CREATION + 1489656971545 + + + TAG + + + + TYPE + UPLOAD + + + diff --git a/Cisco_ZTD_service/Process_Provision/Tasks/Task_Provision.php b/Cisco_ZTD_service/Process_Provision/Tasks/Task_Provision.php new file mode 100644 index 000000000..b8e71363c --- /dev/null +++ b/Cisco_ZTD_service/Process_Provision/Tasks/Task_Provision.php @@ -0,0 +1,111 @@ +"); + $ret_enc_index=strpos($xml_input,""); + $ret_len=$ret_enc_index-$ret_index-strlen($tag_name)-2; + $ret_str=substr($xml_input,$ret_index+strlen($tag_name)+2,$ret_len); + return $ret_str; +} + +check_mandatory_param('device_id'); +check_mandatory_param('src_ip'); +check_mandatory_param('serialnum'); +check_mandatory_param('enable_ztd'); + +$src_ip=$context['src_ip']; +$serialnum=$context['serialnum']; +$ztd_flag=$context['enable_ztd']; +$isr_login="cisco"; +$isr_passwd="cisco"; +$isr_admin_passwd="cisco"; +$dev_id=$context['device_id']; +$PROCESSINSTANCEID = $context['PROCESSINSTANCEID']; +$EXECNUMBER = $context['EXECNUMBER']; +$TASKID = $context['TASKID']; +$process_params = array('PROCESSINSTANCEID' => $PROCESSINSTANCEID, + 'EXECNUMBER' => $EXECNUMBER, + 'TASKID' => $TASKID); + +$is_ztd_enabled = isZtdEnabled($dev_id); +$is_ztd_enabled = trim($is_ztd_enabled); +logToFile("is_ztd_enabled:$is_ztd_enabled || ztd_flag:$ztd_flag "); +if($ztd_flag !== 'true' || $is_ztd_enabled !== '1'){ + $message = "ZTD not enabled on device:$dev_id"; + $ret = prepare_json_response(FAILED, $message, $context, true); + echo "$ret\n"; + exit; +} + + +$device_id = substr($dev_id, 3); +//Launch unlockprovisioning for the device +$unlock_cmd="/opt/sms/bin/sms -e UNLOCKPROVISIONING -i $device_id"; +$unlock_res=shell_exec($unlock_cmd); +$message = "UNLOCKPROVISIONING:$unlock_res"; +update_asynchronous_task_details($process_params, $message); + +//Launch firmware upgrade for the device +/* $fmwr_cmd="/opt/sms/bin/sms -e JSAUPDATEFIRMWARE -i $dev_id ip=$src_ip,login=$isr_login,pwd=$isr_passwd,admin_passwd=$isr_admin_passwd,NO_REBOOT"; +update_asynchronous_task_details($process_params, $fmwr_cmd); +$fmwr_res=shell_exec($fmwr_cmd); + + +//Check for the firmware upgrade status +$frmwr_status_cmd="/opt/sms/bin/sms -e CHECKUPDATEFIRMWARE -i $dev_id | sed -n '3p'"; +$frmwr_status='W'; +while($frmwr_status === "W"){ + + $frmwr_status=shell_exec($frmwr_status_cmd); + sleep(5); +} +if($frmwr_status !== "E"){ + $message = "Firmware update of the device:$dev_id, failed"; + $ret = prepare_json_response(FAILED, $message, $context, true); + echo "$ret\n"; + exit; +} */ +//Launch initial provisioning using cli +$init_prov_cmd="/opt/sms/bin/sms -e PROVISIONING -i $dev_id -c \"$src_ip $isr_login $isr_passwd $isr_admin_passwd\""; +$status=shell_exec($init_prov_cmd); +if(strpos($status, 'FAIL') !== false){ + $message = "Initial provisioning of the device:$dev_id failed, please check the device status"; + $ret = prepare_json_response(FAILED, $message, $context, true); + shell_exec("rm -f /opt/ubi-ztd/var/lock/$serialnum.lock"); + echo "$ret\n"; + exit; +} +$message = "Provisioning of the device:$dev_id started..."; +update_asynchronous_task_details($process_params, $message); + +//Wait for provisioning to complete +$response = wait_for_provisioning_completion($device_id, $process_params); +$response = json_decode($response, true); +if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + shell_exec("rm -f /opt/ubi-ztd/var/lock/$serialnum.lock"); + echo $response; + exit; +} +$wo_comment = $response['wo_comment']; +$cmd_line="/opt/ubi-ztd/bin/set_ztd_enabled.sh $dev_id 0"; +shell_exec($cmd_line); +$response = prepare_json_response(ENDED, "MSA Device $device_id Provisioned successfully.\n" . $wo_comment, $context, true); +shell_exec("rm -f /opt/ubi-ztd/var/lock/$serialnum.lock"); +echo $response; + +?> \ No newline at end of file diff --git a/Cisco_ZTD_service/Process_Validate_ZTD/.meta_Tasks b/Cisco_ZTD_service/Process_Validate_ZTD/.meta_Tasks new file mode 100644 index 000000000..ba899bd01 --- /dev/null +++ b/Cisco_ZTD_service/Process_Validate_ZTD/.meta_Tasks @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1489580552856 + + + DATE_CREATION + 1489580552848 + + + TYPE + DIRECTORY + + + diff --git a/Cisco_ZTD_service/Process_Validate_ZTD/Tasks/.meta_Task_Verify_Request.php b/Cisco_ZTD_service/Process_Validate_ZTD/Tasks/.meta_Task_Verify_Request.php new file mode 100644 index 000000000..bc4cd5334 --- /dev/null +++ b/Cisco_ZTD_service/Process_Validate_ZTD/Tasks/.meta_Task_Verify_Request.php @@ -0,0 +1,29 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1541076717664 + + + COMMENT + + + + DATE_CREATION + 1489580552870 + + + TAG + + + + TYPE + UPLOAD + + + diff --git a/Cisco_ZTD_service/Process_Validate_ZTD/Tasks/Task_Verify_Request.php b/Cisco_ZTD_service/Process_Validate_ZTD/Tasks/Task_Verify_Request.php new file mode 100644 index 000000000..0ebef2a9c --- /dev/null +++ b/Cisco_ZTD_service/Process_Validate_ZTD/Tasks/Task_Verify_Request.php @@ -0,0 +1,176 @@ + FAIL [Don't proceed] + * Such cases need to be handled as per the Task logic + */ +check_mandatory_param('serialnum'); +check_mandatory_param('src_ip'); + +/** + * $context => Service Context variable per Service Instance + * All the user-inputs of Tasks are automatically stored in $context + * Also, any new variables should be stored in $context which are used across Service Instance + * The variables stored in $context can be used across all the Tasks and Processes of a particular Service + * Update $context array [add/update/delete variables] as per requirement + * + * ENTER YOUR CODE HERE + */ + +$PROCESSINSTANCEID = $context['PROCESSINSTANCEID']; +$EXECNUMBER = $context['EXECNUMBER']; +$TASKID = $context['TASKID']; +$process_params = array('PROCESSINSTANCEID' => $PROCESSINSTANCEID, + 'EXECNUMBER' => $EXECNUMBER, + 'TASKID' => $TASKID); + +// $context['var_name2'] = $context['var_name2'] + 1; +$serial_number=$context['serialnum']; +$device_ip=$context['src_ip']; + + +$device_id=fetch_device_by_serial_num($serial_number); +$device_id=trim($device_id); + +if($device_id === ""){ + $message = "For the request coming from $device_ip, no device found in MSA with Serial number: $serial_number"; + $ret = prepare_json_response(FAILED, $message, $context, true); + echo "$ret\n"; + exit; +} +$message = "Device $device_id found for the request coming from $device_ip, with Serial number: $serial_number"; +update_asynchronous_task_details($process_params, $message); +// $ret = prepare_json_response(ENDED, $message, $context, true); +// echo "$ret\n"; + +$context['device_id']=$device_id; + +$dev_seq_num = substr($device_id,3); + + +$response = _device_read_by_id ($dev_seq_num); +$response = json_decode($response, true); +if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + echo $response; + exit; +} +$context['mgmt_ip']=$response['wo_newparams']['managementAddress']; +$context['login']=$response['wo_newparams']['login']; +$context['password']=$response['wo_newparams']['password']; +$context['password_admin']=$response['wo_newparams']['passwordAdmin']; + +$ztd_status=isZtdEnabled($device_id); +$ztd_status=trim($ztd_status); +logToFile("ztd_status:=>$ztd_status::"); +if($ztd_status === ''){ + logToFile("Device not added to workorder"); + + $context['enable_ztd'] = false; + // Device already created, now add this device to workorder + $add_wo_response = addDeviceToWorkorder ( $dev_seq_num, WORK_ORDER_REF, $context ); + +} elseif ($ztd_status === '0'){ + logToFile("ztd_status=$ztd_status::false"); + $context['enable_ztd'] = false; +}else{ + logToFile("ztd_status=$ztd_status::true"); + $context['enable_ztd'] = true; +} + +logToFile("Device added to workorder"); +$dev_ext_ref=$response['wo_newparams']['externalReference']; + + +/* //Trigger provisioning process of same service instance +$customer_id=$context['UBIQUBEID']; +$external_ref=substr($customer_id,4); +$service_name="Process/Cisco_ZTD_service/Cisco_ZTD_Service"; +$service_ref=$serial_number; +$add_service_array = array(); +$add_service_array['device_id'] = $context['device_id']; +$add_service_array['src_ip'] = $context['src_ip']; +$add_service_array['serialnum'] = $context['serialnum']; +$json_body = json_encode($add_service_array); +$response= _orchestration_execute_service_by_reference($external_ref, $service_ref, $service_name, Process/Cisco_ZTD_service/Process_Provision, $json_body); +$response = json_decode($response, true); +if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + echo $response; + exit; +} */ +$message = "ZTD request verified for device with serial number:$serial_number and identfied the device:$device_id"; +$response = prepare_json_response(ENDED, $message, $context, true); +echo $response; + + + +?> \ No newline at end of file diff --git a/Cisco_ZTD_service/Process_ZTD_Request/.meta_Tasks b/Cisco_ZTD_service/Process_ZTD_Request/.meta_Tasks new file mode 100644 index 000000000..3546d75e9 --- /dev/null +++ b/Cisco_ZTD_service/Process_ZTD_Request/.meta_Tasks @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1488537412603 + + + DATE_CREATION + 1488537412594 + + + TYPE + DIRECTORY + + + diff --git a/Cisco_ZTD_service/Process_ZTD_Request/Tasks/.meta_Task_Instantiate.php b/Cisco_ZTD_service/Process_ZTD_Request/Tasks/.meta_Task_Instantiate.php new file mode 100644 index 000000000..3e2756ee1 --- /dev/null +++ b/Cisco_ZTD_service/Process_ZTD_Request/Tasks/.meta_Task_Instantiate.php @@ -0,0 +1,29 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1541063615010 + + + COMMENT + + + + DATE_CREATION + 1488537412619 + + + TAG + + + + TYPE + UPLOAD + + + diff --git a/Cisco_ZTD_service/Process_ZTD_Request/Tasks/Task_Instantiate.php b/Cisco_ZTD_service/Process_ZTD_Request/Tasks/Task_Instantiate.php new file mode 100644 index 000000000..5293339c9 --- /dev/null +++ b/Cisco_ZTD_service/Process_ZTD_Request/Tasks/Task_Instantiate.php @@ -0,0 +1,44 @@ + $PROCESSINSTANCEID, + 'EXECNUMBER' => $EXECNUMBER, + 'TASKID' => $TASKID); +$response = _orchestration_update_service_instance_reference($context['UBIQUBEID'], $context['SERVICEINSTANCEID'],$context['serialnum']); +$response = json_decode($response, true); +if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + echo $response; + exit; +} + +task_exit(ENDED, "Task OK"); + +?> diff --git a/Cisco_ZTD_service/Process_delete/.meta_Tasks b/Cisco_ZTD_service/Process_delete/.meta_Tasks new file mode 100644 index 000000000..54dbc0e4f --- /dev/null +++ b/Cisco_ZTD_service/Process_delete/.meta_Tasks @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1489668782449 + + + DATE_CREATION + 1489668782440 + + + TYPE + DIRECTORY + + + diff --git a/Cisco_ZTD_service/Process_delete/Tasks/.meta_Task_Remove_lock.php b/Cisco_ZTD_service/Process_delete/Tasks/.meta_Task_Remove_lock.php new file mode 100644 index 000000000..0412198e9 --- /dev/null +++ b/Cisco_ZTD_service/Process_delete/Tasks/.meta_Task_Remove_lock.php @@ -0,0 +1,29 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1489669190318 + + + COMMENT + + + + DATE_CREATION + 1489668782464 + + + TAG + + + + TYPE + UPLOAD + + + diff --git a/Cisco_ZTD_service/Process_delete/Tasks/Task_Remove_lock.php b/Cisco_ZTD_service/Process_delete/Tasks/Task_Remove_lock.php new file mode 100644 index 000000000..5ba4d222b --- /dev/null +++ b/Cisco_ZTD_service/Process_delete/Tasks/Task_Remove_lock.php @@ -0,0 +1,20 @@ + \ No newline at end of file diff --git a/MSA_Micro_Service_Tasks_Builder/.meta_MSA_Micro_Service_Tasks_Builder.xml b/MSA_Micro_Service_Tasks_Builder/.meta_MSA_Micro_Service_Tasks_Builder.xml new file mode 100644 index 000000000..53b17196d --- /dev/null +++ b/MSA_Micro_Service_Tasks_Builder/.meta_MSA_Micro_Service_Tasks_Builder.xml @@ -0,0 +1,37 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1506702647088 + + + COMMENT + + + + REPOSITORY + CommandDefinition + + + DATE_CREATION + 1480524728449 + + + CONFIGURATION_FILTER + + + + TYPE + UPLOAD + + + TAG + MSA Micro Service Management + + + diff --git a/MSA_Micro_Service_Tasks_Builder/.meta_Process_Create_Micro_Service_Tasks b/MSA_Micro_Service_Tasks_Builder/.meta_Process_Create_Micro_Service_Tasks new file mode 100644 index 000000000..5962c17a4 --- /dev/null +++ b/MSA_Micro_Service_Tasks_Builder/.meta_Process_Create_Micro_Service_Tasks @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1480595756717 + + + DATE_CREATION + 1480595756704 + + + TYPE + DIRECTORY + + + diff --git a/MSA_Micro_Service_Tasks_Builder/.meta_Process_Delete_Workflow_Instance b/MSA_Micro_Service_Tasks_Builder/.meta_Process_Delete_Workflow_Instance new file mode 100644 index 000000000..c4dfc456a --- /dev/null +++ b/MSA_Micro_Service_Tasks_Builder/.meta_Process_Delete_Workflow_Instance @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1480596741702 + + + DATE_CREATION + 1480596741690 + + + TYPE + DIRECTORY + + + diff --git a/MSA_Micro_Service_Tasks_Builder/.meta_Process_Refresh_Micro_Service_Tasks b/MSA_Micro_Service_Tasks_Builder/.meta_Process_Refresh_Micro_Service_Tasks new file mode 100644 index 000000000..5962c17a4 --- /dev/null +++ b/MSA_Micro_Service_Tasks_Builder/.meta_Process_Refresh_Micro_Service_Tasks @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1480595756717 + + + DATE_CREATION + 1480595756704 + + + TYPE + DIRECTORY + + + diff --git a/MSA_Micro_Service_Tasks_Builder/MSA_Micro_Service_Tasks_Builder.xml b/MSA_Micro_Service_Tasks_Builder/MSA_Micro_Service_Tasks_Builder.xml new file mode 100644 index 000000000..7f086c3dd --- /dev/null +++ b/MSA_Micro_Service_Tasks_Builder/MSA_Micro_Service_Tasks_Builder.xml @@ -0,0 +1,48 @@ + + + + SERVICEINSTANCEREFERENCE + 5 + MSA Operator + /images/repository/CommandDefinition/icons/web cluster.jpg + MSA Micro service Tasks Buider + 10000 + 5 + true + true + false + 3 + + + +
MSA Micro Service
+
+
+
+ + + 3 + Create MSA Micro service Tasks + CREATE + + + Create MSA Micro service Tasks + + + + + 3 + Refresh MSA Micro service Tasks + UPDATE + + + Refresh MSA Micro service Tasks + + + + + 5 + Move To Trash + DELETE + +
\ No newline at end of file diff --git a/MSA_Micro_Service_Tasks_Builder/Process_Create_Micro_Service_Tasks/.meta_Tasks b/MSA_Micro_Service_Tasks_Builder/Process_Create_Micro_Service_Tasks/.meta_Tasks new file mode 100644 index 000000000..80c8946fe --- /dev/null +++ b/MSA_Micro_Service_Tasks_Builder/Process_Create_Micro_Service_Tasks/.meta_Tasks @@ -0,0 +1,39 @@ + + + + + MODEL + + + DATE_MODIFICATION + 1445429309400 + + + COMMENT + + + + REPOSITORY + Process + + + DATE_CREATION + 1445429309382 + + + MANUFACTURER + + + CONFIGURATION_FILTER + + + + TYPE + DIRECTORY + + + TAG + + + + diff --git a/MSA_Micro_Service_Tasks_Builder/Process_Create_Micro_Service_Tasks/Tasks/.meta_MSA b/MSA_Micro_Service_Tasks_Builder/Process_Create_Micro_Service_Tasks/Tasks/.meta_MSA new file mode 100644 index 000000000..80c8946fe --- /dev/null +++ b/MSA_Micro_Service_Tasks_Builder/Process_Create_Micro_Service_Tasks/Tasks/.meta_MSA @@ -0,0 +1,39 @@ + + + + + MODEL + + + DATE_MODIFICATION + 1445429309400 + + + COMMENT + + + + REPOSITORY + Process + + + DATE_CREATION + 1445429309382 + + + MANUFACTURER + + + CONFIGURATION_FILTER + + + + TYPE + DIRECTORY + + + TAG + + + + diff --git a/MSA_Micro_Service_Tasks_Builder/Process_Create_Micro_Service_Tasks/Tasks/MSA/Task_create_msa_workflow_tasks_for_micro_services.php b/MSA_Micro_Service_Tasks_Builder/Process_Create_Micro_Service_Tasks/Tasks/MSA/Task_create_msa_workflow_tasks_for_micro_services.php new file mode 100644 index 000000000..00af2fbc7 --- /dev/null +++ b/MSA_Micro_Service_Tasks_Builder/Process_Create_Micro_Service_Tasks/Tasks/MSA/Task_create_msa_workflow_tasks_for_micro_services.php @@ -0,0 +1,112 @@ + address +$msa_micro_service_name = substr($msa_micro_service_name_with_xml, 0, strlen($msa_micro_service_name_with_xml) - 4); +$msa_micro_service_dir = substr($msa_micro_service_path, 0, strlen($msa_micro_service_path) - strlen($msa_micro_service_name_with_xml)); + +logToFile("MICRO SERVICE PATH : $msa_micro_service_path"); +logToFile("MICRO SERVICE DIR : $msa_micro_service_dir"); +logToFile("MICRO SERVICE NAME : $msa_micro_service_name"); + +try { + $msa_micro_service_task_variables = array(); + $msa_micro_service_task_variables[0]['name'] = "device_id"; + $msa_micro_service_task_variables[0]['type'] = "Device"; + $msa_micro_service_task_variables[0]['isMandatory'] = "true"; + + $msa_micro_service_task_delete_variables = array(); + $msa_micro_service_task_delete_variables[0] = $msa_micro_service_task_variables[0]; + + $additional_task_string = "\$device_id = substr(\$context['device_id'], 3);"; + $additional_task_string .= "\n\$object_id = \$context['object_id'];"; + $micro_service_vars_string = "\n\$micro_service_vars_array = array();"; + + $msa_micro_service_variables = msa_micro_service_variables_to_workflow_variables($msa_micro_service_path); + $msa_micro_service_task_variables_index = 1; + $object_id_var_index = 1; + foreach ($msa_micro_service_variables as $msa_micro_service_variable) { + if (isset($msa_micro_service_variable['visible']) && $msa_micro_service_variable['visible'] === "false") { + continue; + } + $msa_micro_service_task_variables[$msa_micro_service_task_variables_index] = $msa_micro_service_variable; + $msa_micro_service_variable_name = substr($msa_micro_service_variable['name'], 7); + $msa_micro_service_task_variables[$msa_micro_service_task_variables_index]['displayOrder'] = $msa_micro_service_task_variables_index; + $msa_micro_service_task_variables[$msa_micro_service_task_variables_index]['name'] = $msa_micro_service_variable_name; + if ($msa_micro_service_variable_name === "object_id") { + $object_id_var_index = $msa_micro_service_task_variables_index; + } + if ($msa_micro_service_task_variables[$msa_micro_service_task_variables_index]['type'] === "ObjectRef") { + $msa_micro_service_task_variables[$msa_micro_service_task_variables_index]['type'] = "OBMFRef"; + } + $msa_micro_service_task_variables_index++; + + if (strpos($msa_micro_service_variable_name, ".0.") === false) { + $micro_service_vars_string .= "\n\$micro_service_vars_array['{$msa_micro_service_variable_name}'] = \$context['{$msa_micro_service_variable_name}'];"; + } + else { + $name_array = explode(".0.", $msa_micro_service_variable_name); + $array_variable_name = $name_array[0]; + if (strpos($micro_service_vars_string, "\n\$micro_service_vars_array['{$array_variable_name}'] = \$context['{$array_variable_name}'];") === false) { + $micro_service_vars_string .= "\n\$micro_service_vars_array['{$array_variable_name}'] = \$context['{$array_variable_name}'];"; + } + } + if ($msa_micro_service_variable_name === "object_id") { + $msa_micro_service_task_delete_variables[1] = $msa_micro_service_variable; + $msa_micro_service_task_delete_variables[1]['name'] = $msa_micro_service_variable_name; + $msa_micro_service_task_delete_variables[1]['type'] = "OBMFRef"; + /** + * TODO : Is it needed to change the displayOrder of that variable ?? + */ + } + } + $micro_service_vars_string .= "\n\n\${$msa_micro_service_name} = array('{$msa_micro_service_name}' => array(\$object_id => \$micro_service_vars_array));"; + + $micro_service_create_string = "\n\n\$response = execute_command_and_verify_response(\$device_id, CMD_CREATE, \${$msa_micro_service_name}, \"CREATE $msa_micro_service_name\");"; + $micro_service_create_string .= response_status_verifier_string(); + $success_message = "$msa_micro_service_name \$object_id created successfully on the Device \$device_id."; + create_msa_workflow_task("{$msa_micro_service_dir}/{$msa_micro_service_name}/Tasks", "Task_Create", + array(), $msa_micro_service_task_variables, + "{$additional_task_string}{$micro_service_vars_string}{$micro_service_create_string}", false, + $success_message); + + $micro_service_update_string = "\n\n\$response = execute_command_and_verify_response(\$device_id, CMD_UPDATE, \${$msa_micro_service_name}, \"UPDATE $msa_micro_service_name\");"; + $micro_service_update_string .= response_status_verifier_string(); + $success_message = "$msa_micro_service_name \$object_id updated successfully on the Device \$device_id."; + $msa_micro_service_task_variables[$object_id_var_index]['type'] = "OBMFRef"; + create_msa_workflow_task("{$msa_micro_service_dir}/{$msa_micro_service_name}/Tasks", "Task_Update", + array(), $msa_micro_service_task_variables, + "{$additional_task_string}{$micro_service_vars_string}{$micro_service_update_string}", false, + $success_message); + + $micro_service_vars_string = "\n\${$msa_micro_service_name} = array('{$msa_micro_service_name}' => \$object_id);"; + $micro_service_delete_string = "\n\n\$response = execute_command_and_verify_response(\$device_id, CMD_DELETE, \${$msa_micro_service_name}, \"DELETE $msa_micro_service_name\");"; + $micro_service_delete_string .= response_status_verifier_string(); + $success_message = "$msa_micro_service_name \$object_id deleted successfully on the Device \$device_id."; + create_msa_workflow_task("{$msa_micro_service_dir}/{$msa_micro_service_name}/Tasks", "Task_Delete", + array(), $msa_micro_service_task_delete_variables, + "{$additional_task_string}{$micro_service_vars_string}{$micro_service_delete_string}", false, + $success_message); +} +catch (Exception $e) { + logToFile("Exception : $e"); + $response = prepare_json_response(FAILED, "Exception occured while creating MSA Workflows Tasks for Micro service.\nPlease check logs for more details.", $context, true); + echo $response; + exit; +} + +$response = prepare_json_response(ENDED, "Workflow Tasks created succesfully for Micro Service $msa_micro_service_name", $context, true); +echo $response; + +?> \ No newline at end of file diff --git a/MSA_Template_Management/.meta_MSA_Template_Management.xml b/MSA_Template_Management/.meta_MSA_Template_Management.xml new file mode 100644 index 000000000..8a774c4c0 --- /dev/null +++ b/MSA_Template_Management/.meta_MSA_Template_Management.xml @@ -0,0 +1,37 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1506702647088 + + + COMMENT + + + + REPOSITORY + CommandDefinition + + + DATE_CREATION + 1480524728449 + + + CONFIGURATION_FILTER + + + + TYPE + UPLOAD + + + TAG + MSA Templates Management + + + diff --git a/MSA_Template_Management/.meta_Process_Clean_Workflow b/MSA_Template_Management/.meta_Process_Clean_Workflow new file mode 100644 index 000000000..5962c17a4 --- /dev/null +++ b/MSA_Template_Management/.meta_Process_Clean_Workflow @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1480595756717 + + + DATE_CREATION + 1480595756704 + + + TYPE + DIRECTORY + + + diff --git a/MSA_Template_Management/.meta_Process_Create_Workflow b/MSA_Template_Management/.meta_Process_Create_Workflow new file mode 100644 index 000000000..5962c17a4 --- /dev/null +++ b/MSA_Template_Management/.meta_Process_Create_Workflow @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1480595756717 + + + DATE_CREATION + 1480595756704 + + + TYPE + DIRECTORY + + + diff --git a/MSA_Template_Management/.meta_Process_Delete_Workflow_Instance b/MSA_Template_Management/.meta_Process_Delete_Workflow_Instance new file mode 100644 index 000000000..c4dfc456a --- /dev/null +++ b/MSA_Template_Management/.meta_Process_Delete_Workflow_Instance @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1480596741702 + + + DATE_CREATION + 1480596741690 + + + TYPE + DIRECTORY + + + diff --git a/MSA_Template_Management/.meta_Process_Refresh_Workflow b/MSA_Template_Management/.meta_Process_Refresh_Workflow new file mode 100644 index 000000000..5962c17a4 --- /dev/null +++ b/MSA_Template_Management/.meta_Process_Refresh_Workflow @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1480595756717 + + + DATE_CREATION + 1480595756704 + + + TYPE + DIRECTORY + + + diff --git a/MSA_Template_Management/MSA_Template_Management.xml b/MSA_Template_Management/MSA_Template_Management.xml new file mode 100644 index 000000000..180cc0a6a --- /dev/null +++ b/MSA_Template_Management/MSA_Template_Management.xml @@ -0,0 +1,76 @@ + + + + SERVICEINSTANCEREFERENCE + 5 + MSA Operator + /images/repository/CommandDefinition/icons/web cluster.jpg + MSA Template Management + 10000 + 5 + true + true + false + 3 + + + +
MSA Templates
+
+
+ + +
MSA Templates
+
+
+ + +
MSA Template -> Workflow Customers
+
+
+
+ + + 3 + Create MSA Template Workflow + CREATE + + + Fetch MSA Templates + + + + Create MSA Workflow from MSA Templates + + + + + 3 + Refresh MSA Template Workflow + UPDATE + + + Fetch MSA Templates + + + + Create MSA Workflow from MSA Templates + + + + + 3 + Clean MSA Template Workflow + UPDATE + + + Clean MSA Workflow for MSA Templates + + + + + 5 + Move To Trash + DELETE + +
\ No newline at end of file diff --git a/MSA_Template_Management/Process_Clean_Workflow/.meta_Tasks b/MSA_Template_Management/Process_Clean_Workflow/.meta_Tasks new file mode 100644 index 000000000..80c8946fe --- /dev/null +++ b/MSA_Template_Management/Process_Clean_Workflow/.meta_Tasks @@ -0,0 +1,39 @@ + + + + + MODEL + + + DATE_MODIFICATION + 1445429309400 + + + COMMENT + + + + REPOSITORY + Process + + + DATE_CREATION + 1445429309382 + + + MANUFACTURER + + + CONFIGURATION_FILTER + + + + TYPE + DIRECTORY + + + TAG + + + + diff --git a/MSA_Template_Management/Process_Clean_Workflow/Tasks/.meta_MSA b/MSA_Template_Management/Process_Clean_Workflow/Tasks/.meta_MSA new file mode 100644 index 000000000..80c8946fe --- /dev/null +++ b/MSA_Template_Management/Process_Clean_Workflow/Tasks/.meta_MSA @@ -0,0 +1,39 @@ + + + + + MODEL + + + DATE_MODIFICATION + 1445429309400 + + + COMMENT + + + + REPOSITORY + Process + + + DATE_CREATION + 1445429309382 + + + MANUFACTURER + + + CONFIGURATION_FILTER + + + + TYPE + DIRECTORY + + + TAG + + + + diff --git a/MSA_Template_Management/Process_Clean_Workflow/Tasks/MSA/Task_clean_msa_workflows.php b/MSA_Template_Management/Process_Clean_Workflow/Tasks/MSA/Task_clean_msa_workflows.php new file mode 100644 index 000000000..c7150bd56 --- /dev/null +++ b/MSA_Template_Management/Process_Clean_Workflow/Tasks/MSA/Task_clean_msa_workflows.php @@ -0,0 +1,32 @@ + \ No newline at end of file diff --git a/MSA_Template_Management/Process_Create_Workflow/.meta_Tasks b/MSA_Template_Management/Process_Create_Workflow/.meta_Tasks new file mode 100644 index 000000000..80c8946fe --- /dev/null +++ b/MSA_Template_Management/Process_Create_Workflow/.meta_Tasks @@ -0,0 +1,39 @@ + + + + + MODEL + + + DATE_MODIFICATION + 1445429309400 + + + COMMENT + + + + REPOSITORY + Process + + + DATE_CREATION + 1445429309382 + + + MANUFACTURER + + + CONFIGURATION_FILTER + + + + TYPE + DIRECTORY + + + TAG + + + + diff --git a/MSA_Template_Management/Process_Create_Workflow/Tasks/.meta_MSA b/MSA_Template_Management/Process_Create_Workflow/Tasks/.meta_MSA new file mode 100644 index 000000000..80c8946fe --- /dev/null +++ b/MSA_Template_Management/Process_Create_Workflow/Tasks/.meta_MSA @@ -0,0 +1,39 @@ + + + + + MODEL + + + DATE_MODIFICATION + 1445429309400 + + + COMMENT + + + + REPOSITORY + Process + + + DATE_CREATION + 1445429309382 + + + MANUFACTURER + + + CONFIGURATION_FILTER + + + + TYPE + DIRECTORY + + + TAG + + + + diff --git a/MSA_Template_Management/Process_Create_Workflow/Tasks/MSA/Task_create_msa_workflows_from_msa_templates.php b/MSA_Template_Management/Process_Create_Workflow/Tasks/MSA/Task_create_msa_workflows_from_msa_templates.php new file mode 100644 index 000000000..5919ee4a9 --- /dev/null +++ b/MSA_Template_Management/Process_Create_Workflow/Tasks/MSA/Task_create_msa_workflows_from_msa_templates.php @@ -0,0 +1,166 @@ + 1, 'modId' => 104), array('manId' => 1, 'modId' => 113)); + +$workflow_variable_details[1]['name'] = "position"; +$workflow_variable_details[1]['displayOrder'] = 1; +$workflow_variable_details[1]['type'] = "String"; +$workflow_variable_details[1]['displayName'] = "Position"; +$workflow_variable_details[1]['maxLength'] = 100; +$workflow_variable_details[1]['startIncrement'] = 0; +$workflow_variable_details[1]['isMandatory'] = "true"; +$workflow_variable_details[1]['isUserLocked'] = "false"; +$workflow_variable_details[1]['default'] = "AUTO"; +$workflow_variable_details[1]['editalbe'] = "false"; +$workflow_variable_details[1]['validValues'] = array("AUTO", "PRE_CONFIG", "POST_CONFIG", "PRE_CUE_CONFIG", "POST_CUE_CONFIG"); +$workflow_variable_index = 2; + +$process_index = 0; +$process_details = array(); +$process_details[$process_index]['name'] = "MSA_Template_Workflows/{$workflow_name}/Process_create"; +$process_details[$process_index]['icon'] = ""; +$process_details[$process_index]['visibility'] = 4; +$process_details[$process_index]['displayName'] = "Create"; +$process_details[$process_index]['type'] = CMD_CREATE; +$process_details[$process_index]['tasks'][0]['name'] = WORKFLOWS_HOME_DIR . "MSA_Template_Workflows/{$workflow_name}/Process_create/Tasks/Task_create.php"; +$process_details[$process_index]['tasks'][0]['processPath'] = ""; +$process_details[$process_index++]['tasks'][0]['displayName'] = "Input device"; + +try { + $params = array(); + $params[0]['name'] = "device_id"; + $params[0]['type'] = "Device"; + $params[0]['isMandatory'] = "true"; + $json_string = create_json_string_from_array($context['msa_templates']); + $additional_task_string = "\$context['msa_templates'] = json_decode(\"{$json_string}\", true);"; + create_msa_workflow_task("MSA_Template_Workflows/{$workflow_name}/Process_create/Tasks", "Task_create", array(), $params, $additional_task_string); + + //$template_variable_details = array(); + foreach ($msa_templates as $index => $element) { + + $uri = $element['uri']; + $variable_details = msa_template_variables_to_workflow_variables($uri); + for ($template_var_index = 0; $template_var_index < count($variable_details); $template_var_index++) { + if (recursive_array_search($variable_details[$template_var_index]['name'], $workflow_variable_details) === false) { + $workflow_variable_details[$workflow_variable_index] = $variable_details[$template_var_index]; + $workflow_variable_details[$workflow_variable_index]['displayOrder'] = $workflow_variable_index; + $workflow_variable_index++; + } + } + //$template_variable_details[$index][] = $variable_details; + + $template_paths = explode("/", $uri); + $template_paths_count = count($template_paths); + $template_name = $template_paths[$template_paths_count - 1]; + $template_dir = ""; + //$process_dir_name = ""; + //$process_name = ""; + for ($template_paths_index = 0; $template_paths_index < $template_paths_count - 1; $template_paths_index++) { + $template_dir .= $template_paths[$template_paths_index]; + //$process_dir_name .= $template_paths[$template_paths_index]; + //$process_name .= $template_paths[$template_paths_index]; + if ($template_paths_index !== $template_paths_count - 2) { + $template_dir .= "/"; + //$process_dir_name .= "_"; + //$process_name .= "|"; + } + } + logToFile("TEMPLATE NAME : $template_name"); + logToFile("TEMPLATE DIR : $template_dir"); + + $process_details[$process_index]['name'] = "MSA_Template_Workflows/{$workflow_name}/Process_{$template_name}"; + $process_details[$process_index]['icon'] = ""; + $process_details[$process_index]['visibility'] = 4; + $process_details[$process_index]['displayName'] = $template_name; + $process_details[$process_index]['type'] = CMD_UPDATE; + $process_details[$process_index]['tasks'][0]['name'] = WORKFLOWS_HOME_DIR . "MSA_Template_Workflows/Common/Tasks/MSA/Task_manage_templates_attachment.php"; + $process_details[$process_index]['tasks'][0]['processPath'] = ""; + $process_details[$process_index]['tasks'][0]['displayName'] = "Detach all Templates and Attach Template {$template_name}"; + $process_details[$process_index]['tasks'][1]['name'] = WORKFLOWS_HOME_DIR . "MSA_Template_Workflows/{$workflow_name}/Process_{$template_name}/Tasks/Task_{$template_name}_input_config_vars.php"; + $process_details[$process_index]['tasks'][1]['processPath'] = ""; + $process_details[$process_index]['tasks'][1]['displayName'] = "Input Template Config variables"; + $process_details[$process_index]['tasks'][2]['name'] = WORKFLOWS_HOME_DIR . "MSA_Template_Workflows/Common/Tasks/MSA/Task_update_template_config_vars.php"; + $process_details[$process_index]['tasks'][2]['processPath'] = ""; + $process_details[$process_index]['tasks'][2]['displayName'] = "Update Template Config vars"; + $process_details[$process_index]['tasks'][3]['name'] = WORKFLOWS_HOME_DIR . "MSA_Template_Workflows/Common/Tasks/MSA/Task_msa_device_update_config.php"; + $process_details[$process_index]['tasks'][3]['processPath'] = ""; + $process_details[$process_index]['tasks'][3]['displayName'] = "Update Device Config"; + $process_details[$process_index]['tasks'][4]['name'] = WORKFLOWS_HOME_DIR . "MSA_Template_Workflows/Common/Tasks/MSA/Task_manage_templates_reattachment.php"; + $process_details[$process_index]['tasks'][4]['processPath'] = ""; + $process_details[$process_index]['tasks'][4]['displayName'] = "Attach all detached Templates"; + $process_index++; + + $additional_task_string = "\$context['input_vars_task_name'] = \"Task_{$template_name}_input_config_vars\";"; + create_msa_workflow_task("MSA_Template_Workflows/{$workflow_name}/Process_{$template_name}/Tasks", "Task_{$template_name}_input_config_vars", array(), $variable_details, $additional_task_string); + } + + $process_details[$process_index]['name'] = "MSA_Template_Workflows/{$workflow_name}/Process_Move_To_Trash"; + $process_details[$process_index]['icon'] = ""; + $process_details[$process_index]['visibility'] = 4; + $process_details[$process_index]['displayName'] = "Move To Trash"; + $process_details[$process_index]['type'] = CMD_DELETE; + $process_details[$process_index]['tasks'] = array(); + + // Create MSA Workflow definition file + create_msa_workflow_definition("MSA_Template_Workflows/{$workflow_name}", $workflow_name, $workflow_name, $workflow_variable_details, + $process_details, "MSA Template Workflows", "device_id"); + + $wo_comment = "Workflow {$workflow_name}.xml created successfully.\n\n"; + + foreach ($workflow_customers as $workflow_customer) { + $customer_ubiqube_id = $workflow_customer['ubiqube_id']; + $response = _orchestration_service_attach($customer_ubiqube_id, "Process/MSA_Template_Workflows/{$workflow_name}/{$workflow_name}.xml"); + $response = json_decode($response, true); + if ($response['wo_status'] !== ENDED) { + $wo_comment .= "Workflow attachment to the customer $customer_ubiqube_id : FAIL\n"; + } + else { + $wo_comment .= "Workflow attachment to the customer $customer_ubiqube_id : PASS\n"; + } + } +} +catch (Exception $e) { + logToFile("Exception : $e"); + $response = prepare_json_response(FAILED, "Exception occured while creating MSA Workflows from Templates.\nPlease check logs for more details.", $context, true); + echo $response; + exit; +} + +$response = prepare_json_response(ENDED, $wo_comment, $context, true); +echo $response; + +?> \ No newline at end of file diff --git a/MSA_Template_Management/Process_Create_Workflow/Tasks/MSA/Task_import_msa_templates.php b/MSA_Template_Management/Process_Create_Workflow/Tasks/MSA/Task_import_msa_templates.php new file mode 100644 index 000000000..88e8707d9 --- /dev/null +++ b/MSA_Template_Management/Process_Create_Workflow/Tasks/MSA/Task_import_msa_templates.php @@ -0,0 +1,40 @@ + \ No newline at end of file diff --git a/MSA_Template_Workflows/.meta_Common b/MSA_Template_Workflows/.meta_Common new file mode 100644 index 000000000..db47d8a9b --- /dev/null +++ b/MSA_Template_Workflows/.meta_Common @@ -0,0 +1,39 @@ + + + + + MODEL + + + DATE_MODIFICATION + 1445429309400 + + + COMMENT + + + + REPOSITORY + Process + + + DATE_CREATION + 1445429309382 + + + MANUFACTURER + + + CONFIGURATION_FILTER + + + + TYPE + DIRECTORY + + + TAG + + + + \ No newline at end of file diff --git a/MSA_Template_Workflows/Common/.meta_Tasks b/MSA_Template_Workflows/Common/.meta_Tasks new file mode 100644 index 000000000..80c8946fe --- /dev/null +++ b/MSA_Template_Workflows/Common/.meta_Tasks @@ -0,0 +1,39 @@ + + + + + MODEL + + + DATE_MODIFICATION + 1445429309400 + + + COMMENT + + + + REPOSITORY + Process + + + DATE_CREATION + 1445429309382 + + + MANUFACTURER + + + CONFIGURATION_FILTER + + + + TYPE + DIRECTORY + + + TAG + + + + diff --git a/MSA_Template_Workflows/Common/Tasks/.meta_MSA b/MSA_Template_Workflows/Common/Tasks/.meta_MSA new file mode 100644 index 000000000..80c8946fe --- /dev/null +++ b/MSA_Template_Workflows/Common/Tasks/.meta_MSA @@ -0,0 +1,39 @@ + + + + + MODEL + + + DATE_MODIFICATION + 1445429309400 + + + COMMENT + + + + REPOSITORY + Process + + + DATE_CREATION + 1445429309382 + + + MANUFACTURER + + + CONFIGURATION_FILTER + + + + TYPE + DIRECTORY + + + TAG + + + + diff --git a/MSA_Template_Workflows/Common/Tasks/MSA/Task_manage_templates_attachment.php b/MSA_Template_Workflows/Common/Tasks/MSA/Task_manage_templates_attachment.php new file mode 100644 index 000000000..0bf06f80d --- /dev/null +++ b/MSA_Template_Workflows/Common/Tasks/MSA/Task_manage_templates_attachment.php @@ -0,0 +1,67 @@ + $element) { + $uri = $element['uri']; + if (strpos($uri, $template_name) !== false) { + $current_template_uri = $uri; + break; + } +} + +$device_id = substr($context['device_id'], 3); +$response = _device_configuration_list_files_by_id($device_id); +$response = json_decode($response, true); +if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + echo $response; + exit; +} + +$attached_msa_templates_index = 0; +foreach ($response['wo_newparams'] as $uri) { + if (strpos($uri, "Configuration") === 0) { + $context['attached_msa_templates'][$attached_msa_templates_index++]['uri'] = $uri; + $response = _device_configuration_detach_file_from_device($device_id, $uri); + $response = json_decode($response, true); + if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + echo $response; + exit; + } + } +} + +$response = _device_configuration_attach_file_to_device($device_id, "Configuration/{$current_template_uri}", $context['position']); +$response = json_decode($response, true); +if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + echo $response; + exit; +} + +$response = prepare_json_response(ENDED, "Template $template_name attached successfully to the device", $context, true); +echo $response; + +?> diff --git a/MSA_Template_Workflows/Common/Tasks/MSA/Task_manage_templates_reattachment.php b/MSA_Template_Workflows/Common/Tasks/MSA/Task_manage_templates_reattachment.php new file mode 100644 index 000000000..87f282eaf --- /dev/null +++ b/MSA_Template_Workflows/Common/Tasks/MSA/Task_manage_templates_reattachment.php @@ -0,0 +1,29 @@ + If yes, then change "AUTO" with respective position of each template + */ + $response = _device_configuration_attach_file_to_device($device_id, $attached_msa_template['uri'], "AUTO"); + $response = json_decode($response, true); + if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + echo $response; + exit; + } +} + +$response = prepare_json_response(ENDED, "Original Templates attached successfully to the device", $context, true); +echo $response; + +?> diff --git a/MSA_Template_Workflows/Common/Tasks/MSA/Task_msa_device_update_config.php b/MSA_Template_Workflows/Common/Tasks/MSA/Task_msa_device_update_config.php new file mode 100644 index 000000000..0b8673a86 --- /dev/null +++ b/MSA_Template_Workflows/Common/Tasks/MSA/Task_msa_device_update_config.php @@ -0,0 +1,90 @@ + \ No newline at end of file diff --git a/MSA_Template_Workflows/Common/Tasks/MSA/Task_update_template_config_vars.php b/MSA_Template_Workflows/Common/Tasks/MSA/Task_update_template_config_vars.php new file mode 100644 index 000000000..c39724fcc --- /dev/null +++ b/MSA_Template_Workflows/Common/Tasks/MSA/Task_update_template_config_vars.php @@ -0,0 +1,61 @@ + $template_vars) { + if ($template_vars['type'] === "Array") { + foreach ($template_vars['arrayVars'] as $template_var_index => $template_var) { + + /* + * TODO : Handle arrayOfArray type variables + */ + + // Currently single Array variables are handled + // monitorInterfaces.0.interfaceName + // monitorInterfaces.1.interfaceName + // {"context":{"monitorInterface":[{"interfaceName":"e1", "interfaceStatus":"up"}, + // {"interfaceName":"e2", "interfaceStatus":"down"}]}} + + $template_var_keys = explode(".0.", $template_var['name']); + if (array_key_exists($template_var_keys[0], $context)) { + foreach ($context[$template_var_keys[0]] as $element_index => $element) { + foreach ($element as $key => $value) { + if ($key === $template_var_keys[count($template_var_keys) - 1]) { + $response = _configuration_variable_create($device_id, $template_var_keys[0] . ".{$element_index}.{$key}", $value, $template_var['type']); + $response = json_decode($response, true); + if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + echo $response; + exit; + } + break; + } + } + } + } + } + } + else { + $response = _configuration_variable_create($device_id, $template_vars['name'], $context[$template_vars['name']], $template_vars['type']); + $response = json_decode($response, true); + if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + echo $response; + exit; + } + } + } +} + +$response = prepare_json_response(ENDED, "Template $template_name config vars updated successfully.", $context, true); +echo $response; + +?> \ No newline at end of file diff --git a/Reference/Common/Library/.meta_conf_profile_rest.php b/Reference/Common/Library/.meta_conf_profile_rest.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/Common/Library/.meta_conf_profile_rest.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/Common/Library/.meta_email_rest.php b/Reference/Common/Library/.meta_email_rest.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/Common/Library/.meta_email_rest.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/Common/Library/Topology/Topology_populate.php b/Reference/Common/Library/Topology/Topology_populate.php new file mode 100644 index 000000000..e780106b1 --- /dev/null +++ b/Reference/Common/Library/Topology/Topology_populate.php @@ -0,0 +1,48 @@ + $value) { + if($value["object_id"] == $nodeId) { + return $key; + } + } + return -1; +} + +function createTopology($nodeId, $name, $subtype, $image) { + global $context; + + $place = _topology_exist_object_this_instance($nodeId); + if ($place == -1) { + $context['Nodes'][] = array( + "primary_key" => $nodeId, + "name" => $name, + "object_id" => $nodeId, + "x" => 0, + "y" => 0, + "description" => "", + "subtype" => $subtype, + "image" => $image, + "color" => "#acd7e5", + "hidden" => "false", + "cluster_id" => "" + ); + + $place = _topology_exist_object_this_instance($nodeId); + } else { + unset($context['Nodes'][$place]["link"]); + $context['Nodes'][$place]["name"] = $name; + $context['Nodes'][$place]["image"] = $image; + } + + logTofile(debug_dump($place, "***TOPOLOGY CREATETOPO $nodeId * $name***")); + $context['Nodes_MAJ'][] = array( + "object_id" => $nodeId, + "primary_key" => $nodeId + ); + return $place; +} + +?> \ No newline at end of file diff --git a/Reference/Common/Library/conf_profile_rest.php b/Reference/Common/Library/conf_profile_rest.php new file mode 100644 index 000000000..bd67f7636 --- /dev/null +++ b/Reference/Common/Library/conf_profile_rest.php @@ -0,0 +1,73 @@ + $conf_profile_name, + 'externalReference' => $conf_profile_external_reference, + 'vendor' => array( "id" => $manufacturer_id), + 'model' => array( "id" => $model_id ), + 'comment' => $comment, + 'microserviceUris' => $microserviceUris, + 'templateUris' => $templateUris, + 'attachedManagedEntities' => $attachedManagedEntities + ); + + + $json = json_encode($array); + $msa_rest_api = "conf-profile/v2/{$customer_id}"; + $curl_cmd = create_msa_operation_request(OP_POST, $msa_rest_api, $json); + $response = perform_curl_operation($curl_cmd, "Create configuration profile Deployment setting"); + $response = json_decode($response, true); + if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + return $response; + } + $response = prepare_json_response(ENDED, ENDED_SUCCESSFULLY, $response['wo_newparams']['response_body']); + return $response; +} + + + +/** + * curl -u -XGET http://localhost:80/ubi-api-rest/conf-profile/v2/list/customer/{customerId} + * Find configuration profiles by customer + * + */ +function _conf_profile_read_by_id ($customer_id) { + + $msa_rest_api = "/conf-profile/v2/list/customer/{$customer_id}"; + $curl_cmd = create_msa_operation_request(OP_GET, $msa_rest_api); + $response = perform_curl_operation($curl_cmd, "READ CONF Profile/ deployment Setting by Customer ID"); + $response = json_decode($response, true); + if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + return $response; + } + $response = prepare_json_response(ENDED, ENDED_SUCCESSFULLY, $response['wo_newparams']['response_body']); + return $response; +} + + +/** + *
+ *     curl -u ncroot:ubiqube  -XDELETE http://localhost:10080/ubi-api-rest/conf-profile/id/1671
+ * 
+ * + */ +function _conf_profile_delete ($conf_profile_id) { + + $msa_rest_api = "conf-profile/v2/{$conf_profile_id}"; + $curl_cmd = create_msa_operation_request(OP_DELETE, $msa_rest_api); + $response = perform_curl_operation($curl_cmd, "Delete configuration profile by id"); + return $response; +} diff --git a/Reference/Common/Library/customer_rest.php b/Reference/Common/Library/customer_rest.php index ed1a55a44..20a1c9264 100755 --- a/Reference/Common/Library/customer_rest.php +++ b/Reference/Common/Library/customer_rest.php @@ -189,7 +189,7 @@ function _customer_delete_configuration_variable ($customer_reference, $name) { */ function _customer_attach_profile ($customer_reference, $profile_reference) { - $msa_rest_api = "customer/reference/{$customer_reference}/attach?profile={$profile_reference}"; + $msa_rest_api = "customer/{$customer_reference}/attach?profile={$profile_reference}"; $curl_cmd = create_msa_operation_request(OP_PUT, $msa_rest_api); $response = perform_curl_operation($curl_cmd, "ATTACH A PROFILE TO CUSTOMER"); return $response; @@ -202,7 +202,7 @@ function _customer_attach_profile ($customer_reference, $profile_reference) { */ function _customer_detach_profile ($customer_reference, $profile_reference) { - $msa_rest_api = "customer/reference/{$customer_reference}/detach?profile={$profile_reference}"; + $msa_rest_api = "customer/{$customer_reference}/detach?profile={$profile_reference}"; $curl_cmd = create_msa_operation_request(OP_PUT, $msa_rest_api); $response = perform_curl_operation($curl_cmd, "DETACH A PROFILE FROM CUSTOMER"); return $response; diff --git a/Reference/Common/Library/delegation_rest.php b/Reference/Common/Library/delegation_rest.php index a7af69712..cc2c9b771 100755 --- a/Reference/Common/Library/delegation_rest.php +++ b/Reference/Common/Library/delegation_rest.php @@ -15,6 +15,25 @@ function _delegation_profile_create ($operator_prefix, $name) { return $response; } +/** + * Get the list of delegations for the given operator + * + * //curl -u ncroot:NCROOT_PWD -H 'Accept: application/json' -XGET http://localhost/ubi-api-rest/delegation/v1/operator/prefix/MSA/profile?namePattern=MSAResMgr + * + */ +function _delegation_profile_read_by_name ($operator_prefix, $delegation_profile_name) { + + if (empty($delegation_profile_name)){ + //it will return all delegations profiles for the given operator + $delegation_profile_name = "*"; + } + $msa_rest_api = "delegation/v1/operator/prefix/{$operator_prefix}/profile?namePattern={$delegation_profile_name}"; + $curl_cmd = create_msa_operation_request(OP_GET, $msa_rest_api); + $response = perform_curl_operation($curl_cmd, "GET DELEGATION PROFILE"); + return $response; +} + + /** * Delete Delegation Profile by Id * diff --git a/Reference/Common/Library/device_rest.php b/Reference/Common/Library/device_rest.php index a84bde815..67fb531d0 100755 --- a/Reference/Common/Library/device_rest.php +++ b/Reference/Common/Library/device_rest.php @@ -70,7 +70,7 @@ function _device_create ($customer_id, $device_name, $manufacturer_id, function _device_delete ($device_id) { $msa_rest_api = "device/id/{$device_id}"; - $curl_cmd = create_msa_operation_request(OP_DELETE, $msa_rest_api); + $curl_cmd = create_msa_operation_request(OP_DELETE, $msa_rest_api, "", 300, 300); $response = perform_curl_operation($curl_cmd, "DELETE DEVICE BY ID"); return $response; } @@ -84,7 +84,7 @@ function _device_delete ($device_id) { function _device_delete_by_reference ($device_reference) { $msa_rest_api = "device/reference/{$device_reference}"; - $curl_cmd = create_msa_operation_request(OP_DELETE, $msa_rest_api); + $curl_cmd = create_msa_operation_request(OP_DELETE, $msa_rest_api, "", 300, 300); $response = perform_curl_operation($curl_cmd, "DELETE DEVICE BY REFERENCE"); return $response; } @@ -140,7 +140,9 @@ function _device_read_by_id ($device_id) { } /** - * curl -u ncroot:ubiqube -X GET http://localhost:8080/ubi-api-rest/device/reference/DEVICE_REF1234 +
+ curl -u ncroot:ubiqube  -X GET http://localhost:8080/ubi-api-rest/device/reference/DEVICE_REF1234
+ 
* * @param unknown $device_reference * @return Ambigous @@ -249,6 +251,11 @@ function _device_set_maintenance_mode ($device_id, $enable = "true") { */ function _device_set_maintenance_mode_v15_3 ($device_id, $enable = "true") { + if (isset($enable) && ($enable === true|| $enable ==='true' || $enable == 1 )){ + $enable = 'true'; //we should put a string 'true' or 'false' into request, 1 ou 0 don't work + }else{ + $enable = 'false'; + } $msa_rest_api = "device/maintenance/{$device_id}?enable={$enable}"; $curl_cmd = create_msa_operation_request(OP_POST, $msa_rest_api); $response = perform_curl_operation($curl_cmd, "SET DEVICE MAINTENANCE MODE on MSA v15.3"); diff --git a/Reference/Common/Library/email_rest.php b/Reference/Common/Library/email_rest.php index 99497a75e..b88fe970f 100755 --- a/Reference/Common/Library/email_rest.php +++ b/Reference/Common/Library/email_rest.php @@ -8,10 +8,16 @@ */ function _email_send ($from, $to, $subject = "", $content = "", $cc = "", $bcc = "") { - $msa_rest_api = "email/send?from={$from}&to={$to}&subject={$subject}&cc={$cc}&bcc={$bcc}"; - $curl_cmd = create_msa_operation_request(OP_POST, $msa_rest_api, $content); - $response = perform_curl_operation($curl_cmd, "SEND EMAIL"); - return $response; + $subject = urlencode($subject); + $msa_rest_api = "email/send?from={$from}&to={$to}&subject={$subject}&cc={$cc}&bcc={$bcc}"; + $email_content = ""; + if ($content !== "") { + $email_content = array('content' => $content); + $email_content = json_encode($email_content); + } + $curl_cmd = create_msa_operation_request(OP_POST, $msa_rest_api, $email_content); + $response = perform_curl_operation($curl_cmd, "SEND EMAIL"); + return $response; } ?> diff --git a/Reference/Common/Library/lookup_rest.php b/Reference/Common/Library/lookup_rest.php index 8e6c0691b..fb6e34937 100755 --- a/Reference/Common/Library/lookup_rest.php +++ b/Reference/Common/Library/lookup_rest.php @@ -111,4 +111,30 @@ function _lookup_list_sec_nodes () { return $response; } +/** + * Get SecEngine Node by Device Id + * + * curl -u ncroot:ubiqube -XGET http://localhost:10080/ubi-api-rest/lookup/v1/sec-node-by-device-id/{device_id} + * "ipV6Mask": "64", + * "id": 1, + * "haStatusSecNode": 1, + * "haStatusRepNode": 0, + * "name": "ACS", + * "logAddress": "10.31.1.5", + * "smsAddress": "127.0.0.1", + * "alive": true + */ +function _lookup_get_sec_node_by_device_id ($device_id) { + $msa_rest_api = "lookup/v1/sec-node-by-device-id/{$device_id}"; + $curl_cmd = create_msa_operation_request(OP_GET, $msa_rest_api); + $response = perform_curl_operation($curl_cmd, "GET SEC NODE BY DEVICE ID"); + $response = json_decode($response, true); + if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + return $response; + } + $response = prepare_json_response(ENDED, ENDED_SUCCESSFULLY, $response['wo_newparams']['response_body']); + return $response; +} + ?> \ No newline at end of file diff --git a/Reference/Common/Library/msa_common.php b/Reference/Common/Library/msa_common.php index ec51d546d..af8a8b8f3 100755 --- a/Reference/Common/Library/msa_common.php +++ b/Reference/Common/Library/msa_common.php @@ -20,6 +20,9 @@ require_once LIBRARY_DIR . 'customer_rest.php'; require_once LIBRARY_DIR . 'operator_rest.php'; require_once LIBRARY_DIR . 'widget_portal_rest.php'; +require_once LIBRARY_DIR . 'asset_rest.php'; +require_once LIBRARY_DIR . '../constants.php'; +#require_once LIBRARY_DIR . 'conf_profile_rest.php'; /** * Import objects for a device @@ -82,6 +85,7 @@ function synchronize_objects_and_verify_response ($device_id, $connection_timeou return $response; } $message = ""; + $wo_newparams = array(); foreach ($response['wo_newparams'] as $object) { $object_newparam['wo_newparams'] = $object; $response = verify_response($object_newparam, $device_id, CMD_SYNCHRONIZE); @@ -177,6 +181,7 @@ function verify_response($response, $device_id, $command_name, $comment = '') { } else { if ($command_name === CMD_SYNCHRONIZE) { + $wo_newparams = json_decode($message, true); $obj_name = substr($message, 2); $obj_name = substr($obj_name, 0, strpos($obj_name, "\"")); $message = $obj_name; @@ -526,7 +531,7 @@ function wait_for_provisioning_completion ($device_id, $process_params, $sleep_t * @param unknown $process_params * @return mixed|unknown */ -function wait_for_pushconfig_completion ($device_id, $process_params, $ignore_messages = array(), $timeout = PUSH_CONFIG_TIMEOUT) { +function wait_for_pushconfig_completion ($device_id, $process_params, $ignore_messages = array(), $timeout = PUSH_CONFIG_TIMEOUT, $upd_task_execution = true) { $wo_newparams = array(); $status = ''; @@ -558,7 +563,9 @@ function wait_for_pushconfig_completion ($device_id, $process_params, $ignore_me else { $wo_comment_print = $wo_comment; } - update_asynchronous_task_details($process_params, $check_pushconfig_status_message . $wo_comment_print); + if ($upd_task_execution) { + update_asynchronous_task_details($process_params, $check_pushconfig_status_message . $wo_comment_print); + } if ($status === ENDED) { break; } @@ -722,6 +729,7 @@ function wait_for_ssh_status ($ip_address, $port_no = SSH_DEFAULT_PORT_NO, $proc /** * Execute a shell cmd and wait for a particular output string + * If the $expected_output_string is empty, we are waiting the output of the command is empty (used for stop ping monitoring, the device should be disaspear from sdlist) * * @param unknown $cmd * @param unknown $expected_output_string @@ -747,9 +755,15 @@ function execute_linux_command_and_wait_for_output ($cmd, $expected_output_strin } logToFile("Command : $cmd"); logToFile("Output : $output"); - sleep(LINUX_CMD_OUTPUT_CHECK_SLEEP); + if ($total_sleeptime>0) { + sleep(LINUX_CMD_OUTPUT_CHECK_SLEEP); + }else{ + //the first times, we sleep only 1 seconde to have the time to see the display + sleep(1); + } $total_sleeptime += LINUX_CMD_OUTPUT_CHECK_SLEEP; $wo_comment = "Command : $cmd\nOutput : $output\n"; + $wo_comment = preg_replace('#Forti(\w+)\S+#','Device', $wo_comment); //Replace the Word "Forti*" with Device update_asynchronous_task_details($process_params, $check_cmd_output_message . $wo_comment); if ($total_sleeptime > $timeout) { $wo_comment .= "The expected output string was not available in the command output within $timeout seconds.\nHence, Ending the Process as Failure."; @@ -779,7 +793,6 @@ function wait_for_process_completion ($process_id, $process_params, $sleep_time } $process_task_status = $response['wo_newparams']['status']['processTaskStatus']; $process_task_count = count($process_task_status); - $service_id = $response['wo_newparams']['serviceId']['id']; $service_name = $response['wo_newparams']['serviceId']['name']; $process_id = $response['wo_newparams']['processId']['id']; @@ -798,9 +811,17 @@ function wait_for_process_completion ($process_id, $process_params, $sleep_time //In processTaskStatus we don't see all available tasks before all tasks are finished, there are filled one after one when they are finished individually. //We want write into logs the running task and each task already ended. + if ($process_status!== ENDED){ + update_asynchronous_task_details($process_params, implode('',$update_async_task_details) ); + //wait $sleep_time secondes before to check the status + sleep($sleep_time); + } + while ($process_status === RUNNING) { //status of the whole tasks, it will be ended when all tasks are ended. $response = _orchestration_get_process_instance($process_id); $response = json_decode($response, true); + logToFile(debug_dump($response , "msa_common.php process_id=$process_id, sleep_time=$sleep_time _orchestration_get_process_instance22=\n")); + if ($response['wo_status'] !== ENDED) { $response = json_encode($response); return $response; @@ -833,18 +854,13 @@ function wait_for_process_completion ($process_id, $process_params, $sleep_time $tasks_already_displayed[$order][$order_status]=1; } } - $update_async_task_details_string=''; - foreach ($update_async_task_details as $detail){ - $update_async_task_details_string .= $detail; - } - update_asynchronous_task_details($process_params, $update_async_task_details_string); + update_asynchronous_task_details($process_params, implode('',$update_async_task_details)); if ($process_status!== ENDED){ sleep($sleep_time); } } - //$response = prepare_json_response(ENDED, ENDED_SUCCESSFULLY, $wo_newparams); $response = prepare_json_response(ENDED, ENDED_SUCCESSFULLY, $response['wo_newparams']); return $response; } @@ -989,9 +1005,83 @@ function msa_execute_service_by_reference_and_wait_for_completion ($external_ref } $context['executed_service_id'] = $service_id; $context[$service_name][$service_id]['context'] = $response['wo_newparams']; + //$context[$service_name][0]['context'] = $response; + } +} + +/** + * Poll Device Backup Status and wait for it's completion + * + * @param unknown $device_id + * @param unknown $process_params + * @return mixed|unknown + */ +function wait_for_backup_completion ($device_id, $process_params, $timeout = DEVICE_BACKUP_TIMEOUT) { + + $wo_newparams = array(); + $status = ''; + $wo_comment = ""; + $total_sleeptime = 0; + $check_backup_status_message = "Checking Device $device_id Backup Status (every " . DEVICE_BACKUP_CHECK_SLEEP . " seconds"; + $check_backup_status_message .= ", timeout = $timeout seconds) :\n"; + while ($status !== ENDED) { + + $response = _device_get_backup_status_by_device_id($device_id); + $response = json_decode($response, true); + if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + return $response; + } + $status = $response['wo_newparams']['status']; + $message = $response['wo_newparams']['message']; + $revision_id = $response['wo_newparams']['revisionId']; + logToFile("BACKUP STATUS : $status"); + logToFile("BACKUP MESSAGE : $message"); + logToFile("BACKUP REVISION ID : $revision_id"); + + $wo_comment = "Backup Status : " . $status; + $wo_comment .= "\nBackup Message : $message\n"; + $wo_comment .= "\nBackup Revision Id : $revision_id\n"; + update_asynchronous_task_details($process_params, $check_backup_status_message . $wo_comment); + if ($status === ENDED) { + break; + } + else if ($status === FAILED) { + $response = prepare_json_response(FAILED, $message, $wo_newparams, true); + return $response; + } + sleep(DEVICE_BACKUP_CHECK_SLEEP); + $total_sleeptime += DEVICE_BACKUP_CHECK_SLEEP; + if ($total_sleeptime > $timeout) { + $wo_comment .= "The Device $device_id Backup could not be completed within $timeout seconds.\nHence, Ending the Process as Failure."; + $response = prepare_json_response(FAILED, $wo_comment, $wo_newparams, true); + return $response; + } } + $response = prepare_json_response(ENDED, $wo_comment, $wo_newparams); + return $response; } +function msa_push_config_and_wait_for_completion ($device_id, $configuration, $ignore_messages = array(), $timeout = PUSH_CONFIG_TIMEOUT) { + + global $context; + $response = _device_do_push_configuration_by_id($device_id, $configuration); + $response = json_decode($response, true); + if ($response['wo_status'] !== ENDED) { + task_error($response['wo_comment']); + } + + $response = wait_for_pushconfig_completion($device_id, $context, $ignore_messages, $timeout); + $response = json_decode($response, true); + if ($response['wo_status'] !== ENDED) { + task_error($response['wo_comment']); + } + + // Return pushconfig status message + $pushconfig_status_message = $response['wo_comment']; + $pushconfig_status_message = substr($pushconfig_status_message, strpos($pushconfig_status_message, "Push Config Message : ") + strlen("Push Config Message : ")); + return $pushconfig_status_message; +} ?> \ No newline at end of file diff --git a/Reference/Common/Library/orchestration_rest.php b/Reference/Common/Library/orchestration_rest.php index 8cfbdae94..d708e91dc 100755 --- a/Reference/Common/Library/orchestration_rest.php +++ b/Reference/Common/Library/orchestration_rest.php @@ -19,6 +19,24 @@ function _orchestration_list_service_instances ($ubiqube_id) { return $response; } + +/** list_service_instances for MSA in v15_3 + * curl -u ncroot:ubiqube -XGET http://localhost:10080/ubi-api-rest/orchestration/{ubiqubeId}/service/instance + */ +function _orchestration_list_service_instances_v15_3 ($ubiqube_id) { + // $msa_rest_api = "orchestration/{$ubiqube_id}/service/instance"; + $msa_rest_api = "orchestration/service/instance/{$ubiqube_id}"; + $curl_cmd = create_msa_operation_request(OP_GET, $msa_rest_api); + $response = perform_curl_operation($curl_cmd, "LIST SERVICE INSTANCES"); + $response = json_decode($response, true); + if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + return $response; + } + $response = prepare_json_response(ENDED, ENDED_SUCCESSFULLY, $response['wo_newparams']['response_body']); + return $response; +} + /** * curl -u ncroot:ubiqube -XGET http://localhost:10080/ubi-api-rest/orchestration/{ubiqubeId}/service/instance/{serviceId} */ @@ -98,6 +116,20 @@ function _orchestration_update_service_variable ($service_id, $variable_name, $v return $response; } + +/** + * curl -u ncroot:ubiqube -XDELETE http://localhost:10080/ubi-api-rest/orchestration/v1/services/{$service_id}/service-variables/{$variable_name} + */ +function _orchestration_delete_service_context_variable ($service_id, $variable_name) { + #DELETE GIVEN VARIABLE IN THE CONTEXT FOR GIVENT SERVICE ID. + # Rq one array is store in the context in many variables like tab.niv1.niv2 pour $context['tab']['niv1']['niv2'], so we have to delete all variables names to delete the array. + $msa_rest_api = "orchestration/v1/services/{$service_id}/service-variables/{$variable_name}"; + $curl_cmd = create_msa_operation_request(OP_DELETE, $msa_rest_api); + $response = perform_curl_operation($curl_cmd, "DELETE GIVEN VARIABLE IN CONTEXT FOR GIVENT SERVICE ID"); + return $response; +} + + /** * curl -u ncroot:ubiqube -XDELETE http://localhost:10080/ubi-api-rest/orchestration/{ubiqubeId}/service/instance/{serviceId} */ @@ -109,6 +141,18 @@ function _orchestration_delete_service_instance_by_id ($ubiqube_id, $service_id) return $response; } + +/** Delete instance in V15.3 + * curl -u ncroot:ubiqube -XDELETE http://localhost:10080/ubi-api-rest/orchestration//service/instance/{ubiqubeId}/{serviceId} + */ +function _orchestration_delete_service_instance_by_id_v15_3 ($ubiqube_id, $service_id) { + + $msa_rest_api = "orchestration/service/instance/{$ubiqube_id}/{$service_id}"; + $curl_cmd = create_msa_operation_request(OP_DELETE, $msa_rest_api); + $response = perform_curl_operation($curl_cmd, "DELETE SERVICE INSTANCE BY SERVICE ID"); + return $response; +} + /** * curl -u ncroot:ubiqube -XGET http://localhost:10080/ubi-api-rest/orchestration/{ubiqubeId}/process/instances?serviceName={serviceName}&processName={processName} */ @@ -136,7 +180,7 @@ function _orchestration_list_process_instance ($ubiqube_id, $service_name, $proc */ function _orchestration_execute_service ($ubiqube_id, $service_name, $process_name, $json_body = "{}") { - $msa_rest_api = "orchestration/service/execute/{$ubiqube_id}?serviceName={$service_name}&processName={$process_name}"; + $msa_rest_api = "orchestration/service/execute/{$ubiqube_id}?serviceName={$service_name}&processName={$process_name}&serviceInstance=0"; $curl_cmd = create_msa_operation_request(OP_POST, $msa_rest_api, $json_body); $response = perform_curl_operation($curl_cmd, "EXECUTE SERVICE"); $response = json_decode($response, true); @@ -148,18 +192,26 @@ function _orchestration_execute_service ($ubiqube_id, $service_name, $process_na return $response; } +/** + curl -u ncroot:ubiqube -XPOST http://localhost:10080/ubi-api-rest/orchestration/process/execute/{ubiqubeId}/{serviceId}?processName={processName} -d ' + { + "var1": "val1", + "var2": "val2" + } + ' + */ function _orchestration_launch_process_instance ($ubiqube_id, $service_id, $process_name, $json_body = "") { - $msa_rest_api = "orchestration/process/execute/{$ubiqube_id}/{$service_id}?processName={$process_name}"; - $curl_cmd = create_msa_operation_request(OP_POST, $msa_rest_api, $json_body); - $response = perform_curl_operation($curl_cmd, "LAUNCH PROCESS INSTANCE"); - $response = json_decode($response, true); - if ($response['wo_status'] !== ENDED) { - $response = json_encode($response); - return $response; - } - $response = prepare_json_response(ENDED, ENDED_SUCCESSFULLY, $response['wo_newparams']['response_body']); - return $response; + $msa_rest_api = "orchestration/process/execute/{$ubiqube_id}/{$service_id}?processName={$process_name}"; + $curl_cmd = create_msa_operation_request(OP_POST, $msa_rest_api, $json_body); + $response = perform_curl_operation($curl_cmd, "LAUNCH PROCESS INSTANCE"); + $response = json_decode($response, true); + if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + return $response; + } + $response = prepare_json_response(ENDED, ENDED_SUCCESSFULLY, $response['wo_newparams']['response_body']); + return $response; } @@ -193,7 +245,7 @@ function _orchestration_execute_service_by_instance ($ubiqube_id, $service_insta ' */ function _orchestration_launch_sub_process ($ubiqube_id, $service_instance, $service_name, $process_name, $json_body = "{}") { - $msa_rest_api = "orchestration/subprocess/execute/{$ubiqube_id}?serviceName={$service_name}&processName={$process_name}&serviceInstance={$service_instance}"; + $msa_rest_api = "orchestration/process/execute/{$ubiqube_id}/{$service_instance}?processName={$process_name}"; $curl_cmd = create_msa_operation_request(OP_POST, $msa_rest_api, $json_body); $response = perform_curl_operation($curl_cmd, "EXECUTE SERVICE"); $response = json_decode($response, true); @@ -305,5 +357,30 @@ function _orchestration_service_detach ($ubiqube_id, $service_uri) { $response = perform_curl_operation($curl_cmd, "DETACH SERVICE FROM CUSTOMER"); return $response; } +/** + * curl -u ncroot:ubiqube -X POST http://localhost:10080/ubi-api-rest/orchestration/{ubiqubeId}/service/instance/search -d + * { + * "services_to_search":{ + * "service_name" : "Process/Reference/Sampe/Firewall", + * "service_name" : "Process/UBI/Test_Management/Test_Management" + * }, + * "service_instance_id":"12345", + * "service_external_reference":"MSASID12345", + * "process_instance_id":"1234", + * "service_execution_status":"Running", + * "service_variables":{ + * "ipaddress":"1.2.3.4", + * "mask":"255.255.255.0", + * "deviceId":"MSA123" + * } + * } + */ +function _orchestration_service_search ($ubiqube_id, $json_body = "{}") { + + $msa_rest_api = "orchestration/{$ubiqube_id}/service/instance/search"; + $curl_cmd = create_msa_operation_request(OP_POST, $msa_rest_api, $json_body); + $response = perform_curl_operation($curl_cmd, "RUN WORKFLOW SEARCH"); + return $response; +} ?> diff --git a/Reference/Common/Library/order_command_rest.php b/Reference/Common/Library/order_command_rest.php index 904c94ce3..a5f1881ab 100755 --- a/Reference/Common/Library/order_command_rest.php +++ b/Reference/Common/Library/order_command_rest.php @@ -27,6 +27,31 @@ function _order_command_execute ($device_id, $command_name, $object_parameters, return $response; } +/** + * REST endpoint available in MSA NB + * ex: + curl -u ncroot:ubiqube -XPUT http://localhost:10080/ubi-api-rest/ordercommand/store/configuration/657/UPDATE -d '{ + "deviceId": 657, + "commandName": "UPDATE", + "objectParameters": { + "subnet": "mySubnet" + } + }' + */ +function _order_command_store_configuration ($device_id, $command_name, $object_parameters, $connection_timeout = 60, $max_time = 60) { + + $msa_rest_api = "ordercommand/store/configuration/{$device_id}/{$command_name}"; + $curl_cmd = create_msa_operation_request(OP_PUT, $msa_rest_api, $object_parameters); + $response = perform_curl_operation($curl_cmd, "STORE CONFIGURATION"); + $response = json_decode($response, true); + if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + return $response; + } + $response = prepare_json_response(ENDED, ENDED_SUCCESSFULLY, $response['wo_newparams']['response_body']); + return $response; +} + /**
  curl -u ncroot:ubiqube  -XPOST http://localhost:10080/ubi-api-rest/ordercommand/get/configuration/657/UPDATE -d '{
@@ -62,7 +87,7 @@ function _order_command_generate_configuration ($device_id, $command_name, $obje
  * @param unknown $device_id
  * @return unknown
  */
-function _order_command_synchronize ($device_id, $connection_timeout = 300, $max_time = 300) {
+function _order_command_synchronize ($device_id, $connection_timeout = OBJECTS_SYNCHRONIZATION_CONNECTION_TIMEOUT, $max_time = OBJECTS_SYNCHRONIZATION_MAX_TIME) {
 
 	$msa_rest_api = "ordercommand/synchronize/{$device_id}";
 	$curl_cmd = create_msa_operation_request(OP_POST, $msa_rest_api, "", $connection_timeout, $max_time);
diff --git a/Reference/Common/Library/profile_rest.php b/Reference/Common/Library/profile_rest.php
index ddb92a04b..3d460f8a1 100755
--- a/Reference/Common/Library/profile_rest.php
+++ b/Reference/Common/Library/profile_rest.php
@@ -90,6 +90,51 @@ function _profile_configuration_delete_by_id ($customer_id, $profile_id) {
 	return $response;
 }
 
+
+/**
+ * Create new Monitoring profile
+ * 
+ * /usr/bin/curl -isw 'HTTP_CODE=%{http_code}' -u ncroot:$PWD --connect-timeout 60 --max-time 60 -H "Content-Type: application/json" -X POST 'http://127.0.0.1:80/ubi-api-rest/profile/v1/create' -d '{"actorId": "46", "customerId": "56", "externalReference": "MON",  "name": "MON", "type": "M"}'
+ *
+ * the output :
+ * "id": 0, "prefix": "string", "ubiId": "string", "name": "string", "externalReference": "string",  "operatorId": 0, "displayName": "string", "displayNameForJsps": "string", "type": "string",  "profileType": "string", "customerId": 0
+ */
+
+function _profile_monitoring_create ($manager_id, $customer_id, $monitoring_profile_reference,  $monitoring_profile_reference){
+  
+  $msa_rest_api = "profile/v1/create"; 
+  $param= array ("actorId"           => $manager_id,
+                 "customerId"        => $customer_id,
+                 "externalReference" => $monitoring_profile_reference,
+                 "name"              => $monitoring_profile_reference,
+                 "type"              => 'M'   ); 
+  $json =   json_encode($param);
+  $curl_cmd = create_msa_operation_request(OP_POST, $msa_rest_api, $json);
+  $response = perform_curl_operation($curl_cmd, "Create new Monitory Profil $monitoring_profile_reference to operator ");
+  return $response;
+}
+
+
+
+/**
+ * Attach Monitoring profile to customer by external reference
+ * /usr/bin/curl -isw 'HTTP_CODE=%{http_code}' -u ncroot:$p --connect-timeout 60 --max-time 60 -H "Content-Type: application/json" -X POST 'http://127.0.0.1:80/ubi-api-rest/profile/v1/ecl2_0v2-80/attach/M80'
+ * output {
+    "wo_status": "ENDED",
+    "wo_comment": "The monitoring profile M80 is attached to ecl2_0v2-80.\n",
+    "wo_newparams": {................
+ * 
+ */
+
+function _profile_monitoring_attach_to_customer ($customer_ext_reference,$monitoring_profile_reference){
+  
+  $msa_rest_api = "profile/v1/$customer_ext_reference/attach/$monitoring_profile_reference";
+  $curl_cmd = create_msa_operation_request(OP_POST, $msa_rest_api);
+  $response = perform_curl_operation($curl_cmd, "Attach monitoring profile $monitoring_profile_reference to $customer_ext_reference");
+  return $response;
+}
+
+
 /**
  * Export Monitoring Profile
  * 
diff --git a/Reference/Common/Library/repository_rest.php b/Reference/Common/Library/repository_rest.php
index a5a5473de..770c4a5a7 100755
--- a/Reference/Common/Library/repository_rest.php
+++ b/Reference/Common/Library/repository_rest.php
@@ -72,6 +72,19 @@ function _repository_add_customer ($uri) {
 	return $response;
 }
 
+/**
+ * curl -u ncroot:ubiqube  -XPOST 'http://MSA_IP/ubi-api-rest/repository/comment?uri={file_uri}&comment={comment}'
+ */
+function _repository_file_update_comment ($file_uri, $comment) {
+
+	$encoded_comment = urlencode($comment);
+	$encoded_uri = urlencode($file_uri);
+	$msa_rest_api = "repository/comment?uri={$encoded_uri}&comment={$encoded_comment}";
+	$curl_cmd = create_msa_operation_request(OP_POST, $msa_rest_api);
+	$response = perform_curl_operation($curl_cmd, "UPDATE REPOSITORY FILE COMMENT");
+	return $response;
+}
+
 /**
  * curl -u ncroot:NCROOT_PWD  -XDELETE "http://localhost:10080/ubi-api-rest/repository/customer?uri={uri}"
  */
@@ -210,6 +223,24 @@ function _repository_list_files ($uri) {
 	return $response;
 }
 
+/**
+ * curl -u ncroot:ubiqube  -XGET 'http://MSA_IP/ubi-api-rest/repository/meta_value?uri={file_uri}&meta_key={meta_key}'
+ */
+function _repository_read_meta_value ($file_uri, $meta_key) {
+
+	$msa_rest_api = "repository/meta_value?uri={$file_uri}&meta_key={$meta_key}";
+	$curl_cmd = create_msa_operation_request(OP_GET, $msa_rest_api);
+	$response = perform_curl_operation($curl_cmd, "READ REPOSITORY META FILE KEY VALUE");
+	$response = json_decode($response, true);
+	if ($response['wo_status'] !== ENDED) {
+		$response = json_encode($response);
+		return $response;
+	}
+	$response = prepare_json_response(ENDED, ENDED_SUCCESSFULLY, $response['wo_newparams']['response_body']);
+	return $response;
+}
+
+
 /**
  * curl -u ncroot:NCROOT_PWD  -XGET "http://localhost:10080/ubi-api-rest/repository/v2/resource/workflow?uri={uri}"
  */
diff --git a/Reference/Common/Library/user_rest.php b/Reference/Common/Library/user_rest.php
index 0aaceaf90..6393349f8 100755
--- a/Reference/Common/Library/user_rest.php
+++ b/Reference/Common/Library/user_rest.php
@@ -74,6 +74,24 @@ function _manager_read_by_id ($manager_id) {
 	return $response;
 }
 
+/**
+ * curl -u ncroot:Ub1qub3  -XGET http://localhost:80/ubi-api-rest/lookup/managers
+ *
+ */
+function _get_all_manager () {
+
+	$msa_rest_api = "lookup/managers";
+	$curl_cmd = create_msa_operation_request(OP_GET, $msa_rest_api);
+	$response = perform_curl_operation($curl_cmd, "GET ALL MANAGERS");
+	$response = json_decode($response, true);
+	if ($response['wo_status'] !== ENDED) {
+		$response = json_encode($response);
+		return $response;
+	}
+	$response = prepare_json_response(ENDED, ENDED_SUCCESSFULLY, $response['wo_newparams']['response_body']);
+	return $response;
+}
+
 /**
  
  curl -u ncroot:ubiqube  -X GET http://localhost:8080/ubi-api-rest/user/reference/ADMIN_MAN
@@ -114,16 +132,31 @@ function _manager_read_by_login ($manager_login) {
 
 /**
  * Attach Customers to Manager
- *
+ *    $manager_reference
+ *    $customer_references should be a php array like ["customerReference": "ABC", "customerReference": "XYZ"]
  * curl -u ncroot:ubiqube  -XPUT http://localhost:10080/ubi-api-rest/user/manager/{managerReference}/customers/attach -d '["customerReference": "ABC", "customerReference": "XYZ"]'
  */
 function _manager_attach_customers ($manager_reference, $customer_references) {
-	$msa_rest_api = "user/manager/{$manager_reference}/customers/attach";
-	$curl_cmd = create_msa_operation_request(OP_PUT, $msa_rest_api, $customer_references);
-	$response = perform_curl_operation($curl_cmd, "ATTACH CUSTOMERS TO MANAGER");
-	return $response;
+  $msa_rest_api = "user/manager/{$manager_reference}/customers/attach";
+  $json =  '['.json_encode($customer_references).']';
+  $curl_cmd = create_msa_operation_request(OP_PUT, $msa_rest_api, $json);
+  $response = perform_curl_operation($curl_cmd, "ATTACH CUSTOMERS TO MANAGER");
+  return $response;
+}
+
+
+/**
+ * For the given manager, set the given delegationId to the given customer
+ * curl -u ncroot:ubiqube  -XPUT -XPUT "http://MSA_IP/ubi-api-rest/delegation/{delegationId}/{managerId}/{customerId}" 
+ */
+function _manager_set_delegation_to_customer ($delegationId, $managerId, $customerId) {
+  $msa_rest_api = "delegation/{$delegationId}/{$managerId}/{$customerId}";
+  $curl_cmd = create_msa_operation_request(OP_PUT, $msa_rest_api);
+  $response = perform_curl_operation($curl_cmd, "For MANAGER set the delegation for the given customer");
+  return $response;
 }
 
+
 /**
  * Detach Customers from Manager
  *
@@ -148,4 +181,15 @@ function _manager_update_password ($manager_id, $password) {
 	return $response;
 }
 
+/**
+* Update Manager Delegation Profile
+* 
+* curl -X PUT "https://10.30.18.222/user/v1/updateManagerDelegationProfile?managerId=111&delegationProfile=122&callerLogin=ddd" -H "accept: application/json"
+**/
+function _manager_update_delegation_profile ($manager_id, $delegation_profile_id, $caller_login) {
+        $msa_rest_api = "user/v1/updateManagerDelegationProfile?managerId={$manager_id}&delegationProfile={$delegation_profile_id}&callerLogin={$caller_login}";
+        $curl_cmd = create_msa_operation_request(OP_PUT, $msa_rest_api);
+        $response = perform_curl_operation($curl_cmd, "UPDATE MANAGER DELEGATION PROFILE");
+        return $response;
+}
 ?>
\ No newline at end of file
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/utility.php b/Reference/Common/utility.php
index b7d4fff64..f73c6f89b 100755
--- a/Reference/Common/utility.php
+++ b/Reference/Common/utility.php
@@ -175,6 +175,7 @@ function _get_variable_by_name($name) {
 	return null;
 }
 
+
 /**
  * Execute a shell command
  * @param unknown $cmd
@@ -542,6 +543,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/Common/workflows_common.php b/Reference/Common/workflows_common.php
index 3e78e0f5c..992aaeb6a 100755
--- a/Reference/Common/workflows_common.php
+++ b/Reference/Common/workflows_common.php
@@ -58,8 +58,12 @@ function msa_micro_service_variables_to_workflow_variables ($micro_service_uri)
 	$micro_service_variables = $object_definition->ObjectDefinition->variables;
 	*/
 	
-	$xml = simplexml_load_file(MICRO_SERVICES_HOME_DIR . $micro_service_uri);
-	$micro_service_defition = json_decode(json_encode($xml), true);
+	if (preg_match("/^CommandDefinition/", $micro_service_uri, $match)){
+  		$xml = simplexml_load_file(FMC_REPOSITORY_DIRECTORY . $micro_service_uri);
+	}else{
+  		$xml = simplexml_load_file(MICRO_SERVICES_HOME_DIR . $micro_service_uri);
+	}	
+    $micro_service_defition = json_decode(json_encode($xml), true);
 	$variables = $micro_service_defition['variables']['variable'];
 	
 	$micro_service_variables = array();
@@ -408,7 +412,11 @@ function msa_micro_service_variables_to_workflow_variables_with_mapping ($micro_
 
 function msa_micro_service_information_to_workflow_variables ($micro_service_uri) {
     $micro_service_information = array();
-    $xml = simplexml_load_file(MICRO_SERVICES_HOME_DIR . $micro_service_uri);
+    if (preg_match("/^CommandDefinition/", $micro_service_uri, $match)){
+  		$xml = simplexml_load_file(FMC_REPOSITORY_DIRECTORY . $micro_service_uri);
+	}else{
+  		$xml = simplexml_load_file(MICRO_SERVICES_HOME_DIR . $micro_service_uri);
+	}
     $micro_service_defition = json_decode(json_encode($xml), true);
     $micro_service_information = $micro_service_defition['information'];
 
diff --git a/Reference/Customer/Kibana/.meta_Process_Create_Report_Dashboard b/Reference/Customer/Kibana/.meta_Process_Create_Report_Dashboard
new file mode 100644
index 000000000..6da2a29ab
--- /dev/null
+++ b/Reference/Customer/Kibana/.meta_Process_Create_Report_Dashboard
@@ -0,0 +1,17 @@
+
+
+    
+        
+            DATE_MODIFICATION
+            1473866149892
+        
+        
+            DATE_CREATION
+            1473866147847
+        
+        
+            TYPE
+            DIRECTORY
+        
+    
+
diff --git a/Reference/Customer/Kibana/.meta_Process_Delete_Dashboard b/Reference/Customer/Kibana/.meta_Process_Delete_Dashboard
new file mode 100644
index 000000000..767808ccd
--- /dev/null
+++ b/Reference/Customer/Kibana/.meta_Process_Delete_Dashboard
@@ -0,0 +1,17 @@
+
+
+    
+        
+            DATE_MODIFICATION
+            1473866407171
+        
+        
+            DATE_CREATION
+            1473866407154
+        
+        
+            TYPE
+            DIRECTORY
+        
+    
+
diff --git a/Reference/Customer/Kibana/.meta_Process_Update_Dashboard b/Reference/Customer/Kibana/.meta_Process_Update_Dashboard
new file mode 100644
index 000000000..5647cbe49
--- /dev/null
+++ b/Reference/Customer/Kibana/.meta_Process_Update_Dashboard
@@ -0,0 +1,17 @@
+
+
+    
+        
+            DATE_MODIFICATION
+            1473866516693
+        
+        
+            DATE_CREATION
+            1473866516651
+        
+        
+            TYPE
+            DIRECTORY
+        
+    
+
diff --git a/Reference/Customer/Kibana/.meta_Task_Search_Dashboard_Template_Selected.php b/Reference/Customer/Kibana/.meta_Task_Search_Dashboard_Template_Selected.php
new file mode 100644
index 000000000..fad434804
--- /dev/null
+++ b/Reference/Customer/Kibana/.meta_Task_Search_Dashboard_Template_Selected.php
@@ -0,0 +1,17 @@
+
+
+    
+        
+            DATE_MODIFICATION
+            1484752228416
+        
+        
+            DATE_CREATION
+            1484752141060
+        
+        
+            TYPE
+            FILE
+        
+    
+
diff --git a/Reference/Customer/Kibana/.meta_kibana_dashboard.xml b/Reference/Customer/Kibana/.meta_kibana_dashboard.xml
new file mode 100644
index 000000000..201a16097
--- /dev/null
+++ b/Reference/Customer/Kibana/.meta_kibana_dashboard.xml
@@ -0,0 +1,43 @@
+
+
+    
+        
+            MODEL
+        
+        
+            FILE_TYPE
+            text
+        
+        
+            DATE_MODIFICATION
+            1563215192664
+        
+        
+            COMMENT
+            
+        
+        
+            REPOSITORY
+            CommandDefinition
+        
+        
+            DATE_CREATION
+            1474277616131
+        
+        
+            MANUFACTURER
+        
+        
+            CONFIGURATION_FILTER
+            
+        
+        
+            TYPE
+            UPLOAD
+        
+        
+            TAG
+            kibana_dashboard
+        
+    
+
diff --git a/Reference/Customer/Kibana/Process_Create_Report_Dashboard/.meta_Task_Recovering_and_Filtering.php b/Reference/Customer/Kibana/Process_Create_Report_Dashboard/.meta_Task_Recovering_and_Filtering.php
new file mode 100644
index 000000000..6fb3638ac
--- /dev/null
+++ b/Reference/Customer/Kibana/Process_Create_Report_Dashboard/.meta_Task_Recovering_and_Filtering.php
@@ -0,0 +1,42 @@
+
+
+    
+        
+            MODEL
+        
+        
+            FILE_TYPE
+            text
+        
+        
+            DATE_MODIFICATION
+            1496135294687
+        
+        
+            COMMENT
+            
+        
+        
+            REPOSITORY
+        
+        
+            DATE_CREATION
+            1485796219899
+        
+        
+            MANUFACTURER
+        
+        
+            CONFIGURATION_FILTER
+            
+        
+        
+            TAG
+            
+        
+        
+            TYPE
+            UPLOAD
+        
+    
+
diff --git a/Reference/Customer/Kibana/Process_Create_Report_Dashboard/.meta_Task_Recoving_and_Filtring.php b/Reference/Customer/Kibana/Process_Create_Report_Dashboard/.meta_Task_Recoving_and_Filtring.php
new file mode 100644
index 000000000..604269b37
--- /dev/null
+++ b/Reference/Customer/Kibana/Process_Create_Report_Dashboard/.meta_Task_Recoving_and_Filtring.php
@@ -0,0 +1,29 @@
+
+
+    
+        
+            FILE_TYPE
+            text
+        
+        
+            DATE_MODIFICATION
+            1485769195029
+        
+        
+            COMMENT
+            
+        
+        
+            DATE_CREATION
+            1473866294467
+        
+        
+            TAG
+            
+        
+        
+            TYPE
+            UPLOAD
+        
+    
+
diff --git a/Reference/Customer/Kibana/Process_Create_Report_Dashboard/.meta_Task_Search_Dashboard_Template_Selected.php b/Reference/Customer/Kibana/Process_Create_Report_Dashboard/.meta_Task_Search_Dashboard_Template_Selected.php
new file mode 100644
index 000000000..fbe0a5abb
--- /dev/null
+++ b/Reference/Customer/Kibana/Process_Create_Report_Dashboard/.meta_Task_Search_Dashboard_Template_Selected.php
@@ -0,0 +1,29 @@
+
+
+    
+        
+            FILE_TYPE
+            text
+        
+        
+            DATE_MODIFICATION
+            1563215176346
+        
+        
+            COMMENT
+            
+        
+        
+            DATE_CREATION
+            1473866231318
+        
+        
+            TAG
+            
+        
+        
+            TYPE
+            UPLOAD
+        
+    
+
diff --git a/Reference/Customer/Kibana/Process_Create_Report_Dashboard/.meta_Task_Send_the_new_template_to_ES.php b/Reference/Customer/Kibana/Process_Create_Report_Dashboard/.meta_Task_Send_the_new_template_to_ES.php
new file mode 100644
index 000000000..c192d5640
--- /dev/null
+++ b/Reference/Customer/Kibana/Process_Create_Report_Dashboard/.meta_Task_Send_the_new_template_to_ES.php
@@ -0,0 +1,29 @@
+
+
+    
+        
+            FILE_TYPE
+            text
+        
+        
+            DATE_MODIFICATION
+            1563214805701
+        
+        
+            COMMENT
+            
+        
+        
+            DATE_CREATION
+            1473866345335
+        
+        
+            TAG
+            
+        
+        
+            TYPE
+            UPLOAD
+        
+    
+
diff --git a/Reference/Customer/Kibana/Process_Create_Report_Dashboard/Task_Search_Dashboard_Template_Selected.php b/Reference/Customer/Kibana/Process_Create_Report_Dashboard/Task_Search_Dashboard_Template_Selected.php
new file mode 100644
index 000000000..a26864f40
--- /dev/null
+++ b/Reference/Customer/Kibana/Process_Create_Report_Dashboard/Task_Search_Dashboard_Template_Selected.php
@@ -0,0 +1,223 @@
+\d+)/',$context['device_id'],$device_id_number);
+$context['device_id_number']=$device_id_number[1];
+$context['cmd']="/opt/ubi-jentreprise/bin/api/device/readDeviceById.sh ".$context['device_id_number'];
+$response_cmd= shell_exec($context['cmd']);
+preg_match('#\n
(.*)
\n#',$response_cmd, $out); +$context['device_ip']=$out[1]; + +} + + + + +/* Recover IP Address for Kibana */ + +define('HOST_KIBANA', 'UBI_ES_KIBANA_IP'); +$_KIBANA=get_vars_value(HOST_KIBANA); +preg_match('#(.*):#',$_KIBANA,$_KIBANA); +$context['kibanaIpAddress']=$_KIBANA[1]; + + +/* Recover Port Number for Kibana */ + +$_KIBANA=get_vars_value(HOST_KIBANA); +preg_match('#:(.*)#',$_KIBANA,$_KIBANA); +$context['kibanaPort']=$_KIBANA[1]; + + +/** +curl -XPOST "10.30.18.116:5601/api/saved_objects/_export" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d' +{ + "objects": [ + { + "type": "dashboard", + "id": "template_dashboard" + } + ] +} +' +**/ + +/* *** Recove ES ip address **** */ +define('HOST_ES', 'UBI_ES_WEBPORTAL_ENDPOINT'); +$_H=get_vars_value(HOST_ES); +$context['ipAddress']=$_H; + + + +/* ** recove customer_id) ** */ +preg_match('/(?\d+)/',$context['UBIQUBEID'],$matches); +$context['customer_id']=$matches[1]; + + +/* ***** to hash Url Customer Dashboard ***** */ +$context['Hash']=sha1(uniqid($context['customer_id'] . mt_rand(), true)); + + + +/* ** Url and Method to Find selected Dashboard **** */ +$context['searchingURI']='http://'.$context['ipAddress'].':'.$context['port'].'/api/saved_objects/_export'; + +$body_request=' +{ + "objects": [ + { + "type": "'.$context['type'].'", + "id": "'.$context['template name'].'" + } + ] +} +'; + + + +$context['f']='/tmp/file_kibana_'.$context['Hash'].'.ndjson'; +$fp = fopen($context['f'], "w"); + +$ci = curl_init(); + curl_setopt($ci, CURLOPT_URL,$context['searchingURI']); + curl_setopt($ci, CURLOPT_TIMEOUT, 200); + curl_setopt($ci, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ci, CURLOPT_FORBID_REUSE, 0); + curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'POST'); + curl_setopt($ci, CURLOPT_POSTFIELDS, $body_request); + curl_setopt($ci, CURLOPT_HTTPHEADER, array('kbn-xsrf: true','Content-Type: application/json')); + $result= curl_exec($ci); + fwrite($fp, $result); + +/* Store the result in a variable */ +$context['result']=$result; + + + +/* ** Store Kibana Url ***/ + +$context['kibanaUrl']='http://'.$context['kibanaIpAddress'].':'.$context['kibanaPort'].'/app/kibana#/dashboard/'.$context['Hash'].'/'; + + +$check=json_decode($result,true); +if(!isset($check['statusCode'])){ + + task_exit(ENDED, "Template ID found"); +} + + else{ + + task_exit(WARNING, 'Template ID not found => '.$result.''); +} + +//task_exit(ENDED, $result); + +?> \ No newline at end of file diff --git a/Reference/Customer/Kibana/Process_Create_Report_Dashboard/Task_Send_the_new_template_to_ES.php b/Reference/Customer/Kibana/Process_Create_Report_Dashboard/Task_Send_the_new_template_to_ES.php new file mode 100644 index 000000000..fd8b4deb4 --- /dev/null +++ b/Reference/Customer/Kibana/Process_Create_Report_Dashboard/Task_Send_the_new_template_to_ES.php @@ -0,0 +1,196 @@ + \ No newline at end of file diff --git a/Reference/Customer/Kibana/Process_Delete_Dashboard/.meta_Task_Delete_Dashboard.php b/Reference/Customer/Kibana/Process_Delete_Dashboard/.meta_Task_Delete_Dashboard.php new file mode 100644 index 000000000..06dbf4b22 --- /dev/null +++ b/Reference/Customer/Kibana/Process_Delete_Dashboard/.meta_Task_Delete_Dashboard.php @@ -0,0 +1,29 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1563046638792 + + + COMMENT + + + + DATE_CREATION + 1473866443748 + + + TAG + + + + TYPE + UPLOAD + + + diff --git a/Reference/Customer/Kibana/Process_Delete_Dashboard/Task_Delete_Dashboard.php b/Reference/Customer/Kibana/Process_Delete_Dashboard/Task_Delete_Dashboard.php new file mode 100644 index 000000000..b8e46e811 --- /dev/null +++ b/Reference/Customer/Kibana/Process_Delete_Dashboard/Task_Delete_Dashboard.php @@ -0,0 +1,34 @@ + \ No newline at end of file diff --git a/Reference/Customer/Kibana/Process_Update_Dashboard/.meta_Task_Recove_and_filter_for_Updating.php b/Reference/Customer/Kibana/Process_Update_Dashboard/.meta_Task_Recove_and_filter_for_Updating.php new file mode 100644 index 000000000..2e32a3ad8 --- /dev/null +++ b/Reference/Customer/Kibana/Process_Update_Dashboard/.meta_Task_Recove_and_filter_for_Updating.php @@ -0,0 +1,29 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1485769433722 + + + COMMENT + + + + DATE_CREATION + 1473866610261 + + + TAG + + + + TYPE + UPLOAD + + + diff --git a/Reference/Customer/Kibana/Process_Update_Dashboard/.meta_Task_Recovering_and_filtering_for_Updating.php b/Reference/Customer/Kibana/Process_Update_Dashboard/.meta_Task_Recovering_and_filtering_for_Updating.php new file mode 100644 index 000000000..6e1657455 --- /dev/null +++ b/Reference/Customer/Kibana/Process_Update_Dashboard/.meta_Task_Recovering_and_filtering_for_Updating.php @@ -0,0 +1,42 @@ + + + + + MODEL + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1496136181418 + + + COMMENT + + + + REPOSITORY + + + DATE_CREATION + 1485796244476 + + + MANUFACTURER + + + CONFIGURATION_FILTER + + + + TAG + + + + TYPE + UPLOAD + + + diff --git a/Reference/Customer/Kibana/Process_Update_Dashboard/.meta_Task_Search_Dashboard_Selected_for_Updating.php b/Reference/Customer/Kibana/Process_Update_Dashboard/.meta_Task_Search_Dashboard_Selected_for_Updating.php new file mode 100644 index 000000000..7fc237939 --- /dev/null +++ b/Reference/Customer/Kibana/Process_Update_Dashboard/.meta_Task_Search_Dashboard_Selected_for_Updating.php @@ -0,0 +1,29 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1563215189738 + + + COMMENT + + + + DATE_CREATION + 1473866564176 + + + TAG + + + + TYPE + UPLOAD + + + diff --git a/Reference/Customer/Kibana/Process_Update_Dashboard/.meta_Task_Send_back_template_to_ES_for_Updating.php b/Reference/Customer/Kibana/Process_Update_Dashboard/.meta_Task_Send_back_template_to_ES_for_Updating.php new file mode 100644 index 000000000..73a325870 --- /dev/null +++ b/Reference/Customer/Kibana/Process_Update_Dashboard/.meta_Task_Send_back_template_to_ES_for_Updating.php @@ -0,0 +1,29 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1563215006223 + + + COMMENT + + + + DATE_CREATION + 1473866640234 + + + TAG + + + + TYPE + UPLOAD + + + diff --git a/Reference/Customer/Kibana/Process_Update_Dashboard/Task_Search_Dashboard_Selected_for_Updating.php b/Reference/Customer/Kibana/Process_Update_Dashboard/Task_Search_Dashboard_Selected_for_Updating.php new file mode 100644 index 000000000..20ff11e79 --- /dev/null +++ b/Reference/Customer/Kibana/Process_Update_Dashboard/Task_Search_Dashboard_Selected_for_Updating.php @@ -0,0 +1,201 @@ +\d+)/',$context['device_id'],$device_id_number); +$context['device_id_number']=$device_id_number[1]; +$context['cmd']="/opt/ubi-jentreprise/bin/api/device/readDeviceById.sh ".$context['device_id_number']; +$response_cmd= shell_exec($context['cmd']); +preg_match('#\n
(.*)
\n#',$response_cmd, $out); +$context['device_ip']=$out[1]; + +} + + + + +/* Recover IP Address for Kibana */ + +define('HOST_KIBANA', 'UBI_ES_KIBANA_IP'); +$_KIBANA=get_vars_value(HOST_KIBANA); +preg_match('#(.*):#',$_KIBANA,$_KIBANA); +$context['kibanaIpAddress']=$_KIBANA[1]; + + +/* Recover Port Number for Kibana */ + +$_KIBANA=get_vars_value(HOST_KIBANA); +preg_match('#:(.*)#',$_KIBANA,$_KIBANA); +$context['kibanaPort']=$_KIBANA[1]; + + +/** +curl -XPOST "10.30.18.116:5601/api/saved_objects/_export" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d' +{ + "objects": [ + { + "type": "dashboard", + "id": "template_dashboard" + } + ] +} +' +**/ + +/* *** Recove ES ip address **** */ +define('HOST_ES', 'UBI_ES_WEBPORTAL_ENDPOINT'); +$_H=get_vars_value(HOST_ES); +$context['ipAddress']=$_H; + + + +/* ** recove customer_id) ** */ +preg_match('/(?\d+)/',$context['UBIQUBEID'],$matches); +$context['customer_id']=$matches[1]; + + + + +/* ** Url and Method to Find selected Dashboard **** */ +$context['searchingURI']='http://'.$context['ipAddress'].':'.$context['port'].'/api/saved_objects/_export'; + +$body_request=' +{ + "objects": [ + { + "type": "'.$context['type'].'", + "id": "'.$context['template name'].'" + } + ] +} +'; + + + +$context['f']='/tmp/file_kibana_'.$context['Hash'].'.ndjson'; +$fp = fopen($context['f'], "w"); + +$ci = curl_init(); + curl_setopt($ci, CURLOPT_URL,$context['searchingURI']); + curl_setopt($ci, CURLOPT_TIMEOUT, 200); + curl_setopt($ci, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ci, CURLOPT_FORBID_REUSE, 0); + curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'POST'); + curl_setopt($ci, CURLOPT_POSTFIELDS, $body_request); + curl_setopt($ci, CURLOPT_HTTPHEADER, array('kbn-xsrf: true','Content-Type: application/json')); + $result= curl_exec($ci); + fwrite($fp, $result); + +/* Store the result in a variable */ +$context['result']=$result; + +/* ** Store Kibana Url ***/ + +$context['kibanaUrl']='http://'.$context['kibanaIpAddress'].':'.$context['kibanaPort'].'/app/kibana#/dashboard/'.$context['Hash'].'/'; + +$check=json_decode($result,true); +if(!isset($check['statusCode'])){ + + task_exit(ENDED, "Template ID found"); +} + + else{ + + task_exit(WARNING, 'Template ID not found => '.$result.''); +} + + +//task_exit(ENDED, $result); + +?> \ No newline at end of file diff --git a/Reference/Customer/Kibana/Process_Update_Dashboard/Task_Send_back_template_to_ES_for_Updating.php b/Reference/Customer/Kibana/Process_Update_Dashboard/Task_Send_back_template_to_ES_for_Updating.php new file mode 100644 index 000000000..62a7b67f4 --- /dev/null +++ b/Reference/Customer/Kibana/Process_Update_Dashboard/Task_Send_back_template_to_ES_for_Updating.php @@ -0,0 +1,206 @@ + \ No newline at end of file diff --git a/Reference/Customer/Kibana/kibana_dashboard.xml b/Reference/Customer/Kibana/kibana_dashboard.xml new file mode 100644 index 000000000..de6576d0b --- /dev/null +++ b/Reference/Customer/Kibana/kibana_dashboard.xml @@ -0,0 +1,274 @@ + + + true + + dashboardName + 5 + TRANSACTION + Dashboard + /images/eclipseIcons/page_obj.gif + Deploy Dashboard + 10000 + 0 + 5 + false + false + false + 5 + + + + + + + + + template_default + template_Email_Overview + template_WEB + template_USER + template_URL + template_NF_BYTES_IP_PORT + template_Event_Alarm + template_Event_Alarm_Rule + template_Events_Per_Traffic + template_NF_Counter + + Select available dashboards on Kibana or write the name of your created dashboard (based on the dashboard url) + + + Name of your duplicated dashbaoard from your selected dashboard template + + + + + + + + + + Basic + Advanced + + +
Filtering
+
+ - Advanced : your write all fields and their values with operators ( OR, AND ) in Advanced filter input + +- Basic : you have Basic Fitler table that you can put fields and select your operator. Then you can decide if you want to apply your filter directly or just save it +
+ + +
Filtering
+
+ + + +
Filtering
+
+
+ +
+ Write your filter in according index fields (ex. port:<50 OR protocol:UDP) +
+ + +
Filtering
+
+ + + +
Filtering
+
+
+ +
+
+ + +
Filtering
+
+ + + + +
Filtering
+
+
+
+
+ + +
Filtering
+
+ + + + +
Filtering
+
+
+
+
+ + +
Basic Filter
+
+ + + +
filter
+
+
+ + +
Basic Filter
+
+
+
+
+ + +
Basic Filter
+
+ + + +
filter
+
+
+ + +
Basic Filter
+
+
+
+
+ + +
Basic Filter
+
+ + + +
filter
+
+
+ + + && + || + + +
Basic Filter
+
+
+
+
+ + +
Basic Filter
+
+
+ + +
Basic Filter
+
+ + + +
filter
+
+
+ + +
Basic Filter
+
+
+
+
+ + + service + device + + +
Level View
+
+ In according your selection, the dashboard that your are going to deploy will be display in the appropriated tab +
+ + +
Level View
+
+ + + +
Device View
+
+
+ +
+
+ + +
Level View
+
+ + + +
Device View
+
+
+ +
+
+
+ + + 5 + Create Dashboard + CREATE + + + + + /opt/fmc_repository/Process/Reference/Customer/Kibana/Process_Create_Report_Dashboard/ + Search Dashboard Template Selected + + + /opt/fmc_repository/Process/Reference/Customer/Kibana/Process_Create_Report_Dashboard/ + Send the new template to ES + + + + + + 5 + Delete Dashboard + DELETE + + /opt/fmc_repository/Process/Reference/Customer/Kibana/Process_Delete_Dashboard/ + Delete Dashboard + + + + + + 5 + Update Dashboard + UPDATE + + + + + /opt/fmc_repository/Process/Reference/Customer/Kibana/Process_Update_Dashboard/ + Search Dashboard Selected for Updating + + + /opt/fmc_repository/Process/Reference/Customer/Kibana/Process_Update_Dashboard/ + Send back template to ES for Updating + + + +
diff --git a/Reference/Device_Data_File/.meta_Device_Data_File.xml b/Reference/Device_Data_File/.meta_Device_Data_File.xml new file mode 100644 index 000000000..de45c0c57 --- /dev/null +++ b/Reference/Device_Data_File/.meta_Device_Data_File.xml @@ -0,0 +1,37 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1530270251991 + + + COMMENT + + + + REPOSITORY + CommandDefinition + + + DATE_CREATION + 1530180120538 + + + CONFIGURATION_FILTER + + + + TYPE + UPLOAD + + + TAG + Device_Data_File.xml + + + diff --git a/Reference/Device_Data_File/.meta_Process_Delete_File b/Reference/Device_Data_File/.meta_Process_Delete_File new file mode 100644 index 000000000..c3fb50f75 --- /dev/null +++ b/Reference/Device_Data_File/.meta_Process_Delete_File @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1530180584098 + + + DATE_CREATION + 1530180584052 + + + TYPE + DIRECTORY + + + diff --git a/Reference/Device_Data_File/.meta_Process_Delete_The_Instance b/Reference/Device_Data_File/.meta_Process_Delete_The_Instance new file mode 100644 index 000000000..54021ec71 --- /dev/null +++ b/Reference/Device_Data_File/.meta_Process_Delete_The_Instance @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1530180625464 + + + DATE_CREATION + 1530180625455 + + + TYPE + DIRECTORY + + + diff --git a/Reference/Device_Data_File/.meta_Process_Send_File b/Reference/Device_Data_File/.meta_Process_Send_File new file mode 100644 index 000000000..417e497dc --- /dev/null +++ b/Reference/Device_Data_File/.meta_Process_Send_File @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1530180243748 + + + DATE_CREATION + 1530180243706 + + + TYPE + DIRECTORY + + + diff --git a/Reference/Device_Data_File/.meta_Process_Update b/Reference/Device_Data_File/.meta_Process_Update new file mode 100644 index 000000000..809b470eb --- /dev/null +++ b/Reference/Device_Data_File/.meta_Process_Update @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1530180268786 + + + DATE_CREATION + 1530180268719 + + + TYPE + DIRECTORY + + + diff --git a/Reference/Device_Data_File/Device_Data_File.xml b/Reference/Device_Data_File/Device_Data_File.xml new file mode 100644 index 000000000..8f530847f --- /dev/null +++ b/Reference/Device_Data_File/Device_Data_File.xml @@ -0,0 +1,116 @@ + + + true + + service_id + 5 + + /images/eclipseIcons/page_obj.gif + Device Data File + 10000 + 5 + false + false + false + 5 + + + +
Sending
+
+
+ + +
Sending
+
+
+ + +
Sending
+
+
+ + +
Sending
+
+
+ + +
Deletion
+
+
+ + +
Sending
+
+
+ + +
Sending
+
+
+ + +
Sening
+
+
+
+ + 5 + Send File + + false + CREATE + + + + + /opt/fmc_repository/Process/Reference/Device_Data_File/Process_Send_File/Tasks/ + File Found + + + /opt/fmc_repository/Process/Reference/Device_Data_File/Process_Send_File/Tasks/ + File Sent + + + + 5 + Update + + false + UPDATE + + + + + /opt/fmc_repository/Process/Reference/Device_Data_File/Process_Update/Tasks/ + File Found + + + /opt/fmc_repository/Process/Reference/Device_Data_File/Process_Update/Tasks/ + File Sent + + + + 5 + Delete File + + false + UPDATE + + /opt/fmc_repository/Process/Reference/Device_Data_File/Process_Delete_File/Tasks/ + File Found + + + /opt/fmc_repository/Process/Reference/Device_Data_File/Process_Delete_File/Tasks/ + File Deleted + + + + 5 + Delete The Instance + + false + DELETE + +
diff --git a/Reference/Device_Data_File/Process_Delete_File/.meta_Tasks b/Reference/Device_Data_File/Process_Delete_File/.meta_Tasks new file mode 100644 index 000000000..f69701ec4 --- /dev/null +++ b/Reference/Device_Data_File/Process_Delete_File/.meta_Tasks @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1530181203290 + + + DATE_CREATION + 1530181203281 + + + TYPE + DIRECTORY + + + diff --git a/Reference/Device_Data_File/Process_Delete_File/Tasks/.meta_Task_File_Deleted.php b/Reference/Device_Data_File/Process_Delete_File/Tasks/.meta_Task_File_Deleted.php new file mode 100644 index 000000000..c0ec313d4 --- /dev/null +++ b/Reference/Device_Data_File/Process_Delete_File/Tasks/.meta_Task_File_Deleted.php @@ -0,0 +1,29 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1530268336224 + + + COMMENT + + + + DATE_CREATION + 1530181209746 + + + TAG + + + + TYPE + UPLOAD + + + diff --git a/Reference/Device_Data_File/Process_Delete_File/Tasks/.meta_Task_File_Found.php b/Reference/Device_Data_File/Process_Delete_File/Tasks/.meta_Task_File_Found.php new file mode 100644 index 000000000..e9b725ab1 --- /dev/null +++ b/Reference/Device_Data_File/Process_Delete_File/Tasks/.meta_Task_File_Found.php @@ -0,0 +1,29 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1530270249672 + + + COMMENT + + + + DATE_CREATION + 1530181203307 + + + TAG + + + + TYPE + UPLOAD + + + diff --git a/Reference/Device_Data_File/Process_Delete_File/Tasks/Task_File_Deleted.php b/Reference/Device_Data_File/Process_Delete_File/Tasks/Task_File_Deleted.php new file mode 100644 index 000000000..1c69d9c2f --- /dev/null +++ b/Reference/Device_Data_File/Process_Delete_File/Tasks/Task_File_Deleted.php @@ -0,0 +1,73 @@ + /dev/null"; + + + +$response_cmd= shell_exec($cmd); + +preg_match('#Done\s+(.*)\s+Done#',$response_cmd, $out); + + +if ( ! isset($out[1])) { + $out[1] ='null'; +} + +$file1=$out[1]; + + +if ($file1==$context['file_to_delete']) +{ + +$cmd="sshpass -p ".$context['password']." ssh -o StrictHostKeyChecking=no ".$context['user']."@".$context['device_ip']." shell rm ".$context['file_to_delete']." 2> /dev/null"; + +$response_cmd= shell_exec($cmd); + +preg_match('#Done\s+(.*)\s+Done#',$response_cmd, $out); +$file1=$out[1]; + +if($file1==""){ +task_exit(ENDED, "File Deleted"); + +} + +else +{ +task_exit(WARNING, "Error"); +} + +} + +else +{ +task_exit(WARNING, "Error"); +} + + + + + +?> \ No newline at end of file diff --git a/Reference/Device_Data_File/Process_Delete_File/Tasks/Task_File_Found.php b/Reference/Device_Data_File/Process_Delete_File/Tasks/Task_File_Found.php new file mode 100644 index 000000000..63d338545 --- /dev/null +++ b/Reference/Device_Data_File/Process_Delete_File/Tasks/Task_File_Found.php @@ -0,0 +1,56 @@ + /dev/null"; + + + +$response_cmd= shell_exec($cmd); + +preg_match('#Done\s+(.*)\s+Done#',$response_cmd, $out); + + +if ( ! isset($out[1])) { + $out[1] ='null'; +} + +$file1=$out[1]; + + +if ($file1==$context['file_to_delete']) +{ +task_exit(ENDED, "File Found"); +} + +else +{ +task_exit(WARNING, "Error"); +} + + +?> \ No newline at end of file diff --git a/Reference/Device_Data_File/Process_Send_File/.meta_Tasks b/Reference/Device_Data_File/Process_Send_File/.meta_Tasks new file mode 100644 index 000000000..4e1154810 --- /dev/null +++ b/Reference/Device_Data_File/Process_Send_File/.meta_Tasks @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1530180421134 + + + DATE_CREATION + 1530180421091 + + + TYPE + DIRECTORY + + + diff --git a/Reference/Device_Data_File/Process_Send_File/Tasks/.meta_Task_Destination_Found.php b/Reference/Device_Data_File/Process_Send_File/Tasks/.meta_Task_Destination_Found.php new file mode 100644 index 000000000..24168de1a --- /dev/null +++ b/Reference/Device_Data_File/Process_Send_File/Tasks/.meta_Task_Destination_Found.php @@ -0,0 +1,29 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1530187310818 + + + COMMENT + + + + DATE_CREATION + 1530180466638 + + + TAG + + + + TYPE + UPLOAD + + + diff --git a/Reference/Device_Data_File/Process_Send_File/Tasks/.meta_Task_File_Found.php b/Reference/Device_Data_File/Process_Send_File/Tasks/.meta_Task_File_Found.php new file mode 100644 index 000000000..0379f6c4e --- /dev/null +++ b/Reference/Device_Data_File/Process_Send_File/Tasks/.meta_Task_File_Found.php @@ -0,0 +1,29 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1530269050682 + + + COMMENT + + + + DATE_CREATION + 1530180421156 + + + TAG + + + + TYPE + UPLOAD + + + diff --git a/Reference/Device_Data_File/Process_Send_File/Tasks/.meta_Task_File_Sent.php b/Reference/Device_Data_File/Process_Send_File/Tasks/.meta_Task_File_Sent.php new file mode 100644 index 000000000..e27518ee9 --- /dev/null +++ b/Reference/Device_Data_File/Process_Send_File/Tasks/.meta_Task_File_Sent.php @@ -0,0 +1,29 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1530268602473 + + + COMMENT + + + + DATE_CREATION + 1530180519350 + + + TAG + + + + TYPE + UPLOAD + + + diff --git a/Reference/Device_Data_File/Process_Send_File/Tasks/Task_Destination_Found.php b/Reference/Device_Data_File/Process_Send_File/Tasks/Task_Destination_Found.php new file mode 100644 index 000000000..85bcb34b0 --- /dev/null +++ b/Reference/Device_Data_File/Process_Send_File/Tasks/Task_Destination_Found.php @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/Reference/Device_Data_File/Process_Send_File/Tasks/Task_File_Found.php b/Reference/Device_Data_File/Process_Send_File/Tasks/Task_File_Found.php new file mode 100644 index 000000000..fd28ddee5 --- /dev/null +++ b/Reference/Device_Data_File/Process_Send_File/Tasks/Task_File_Found.php @@ -0,0 +1,55 @@ + \ No newline at end of file diff --git a/Reference/Device_Data_File/Process_Send_File/Tasks/Task_File_Sent.php b/Reference/Device_Data_File/Process_Send_File/Tasks/Task_File_Sent.php new file mode 100644 index 000000000..aff0a8031 --- /dev/null +++ b/Reference/Device_Data_File/Process_Send_File/Tasks/Task_File_Sent.php @@ -0,0 +1,48 @@ +\d+)/',$context['device'],$device_id_number); +$context['device_id_number']=$device_id_number[1]; +$context['cmd']="/opt/ubi-jentreprise/bin/api/device/readDeviceById.sh ".$context['device_id_number']; +$response_cmd= shell_exec($context['cmd']); +preg_match('#\n
(.*)
\n#',$response_cmd, $out); +$context['device_ip']=$out[1]; + + +// $cmd="scp ".$context['src_file']." ".$context['user']."@".$context['device_ip'].":".$context['dst_file']; +$cmd="sshpass -p ".$context['password']." scp -o StrictHostKeyChecking=no ".$context['src_file']." ".$context['user']."@".$context['device_ip'].":".$context['dst_file']." 2> /dev/null"; + +shell_exec($cmd); + +task_exit(ENDED, "OK, Check the first task in the Live Console"); + +?> \ No newline at end of file diff --git a/Reference/Device_Data_File/Process_Update/.meta_Tasks b/Reference/Device_Data_File/Process_Update/.meta_Tasks new file mode 100644 index 000000000..239b1ddc0 --- /dev/null +++ b/Reference/Device_Data_File/Process_Update/.meta_Tasks @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1530181118446 + + + DATE_CREATION + 1530181118410 + + + TYPE + DIRECTORY + + + diff --git a/Reference/Device_Data_File/Process_Update/Tasks/.meta_Task_Destination_Found.php b/Reference/Device_Data_File/Process_Update/Tasks/.meta_Task_Destination_Found.php new file mode 100644 index 000000000..440c2bf5d --- /dev/null +++ b/Reference/Device_Data_File/Process_Update/Tasks/.meta_Task_Destination_Found.php @@ -0,0 +1,29 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1530181151449 + + + COMMENT + + + + DATE_CREATION + 1530181151443 + + + TAG + + + + TYPE + UPLOAD + + + diff --git a/Reference/Device_Data_File/Process_Update/Tasks/.meta_Task_File_Found.php b/Reference/Device_Data_File/Process_Update/Tasks/.meta_Task_File_Found.php new file mode 100644 index 000000000..00533574e --- /dev/null +++ b/Reference/Device_Data_File/Process_Update/Tasks/.meta_Task_File_Found.php @@ -0,0 +1,29 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1530269092894 + + + COMMENT + + + + DATE_CREATION + 1530181118463 + + + TAG + + + + TYPE + UPLOAD + + + diff --git a/Reference/Device_Data_File/Process_Update/Tasks/.meta_Task_File_Sent.php b/Reference/Device_Data_File/Process_Update/Tasks/.meta_Task_File_Sent.php new file mode 100644 index 000000000..10036d60d --- /dev/null +++ b/Reference/Device_Data_File/Process_Update/Tasks/.meta_Task_File_Sent.php @@ -0,0 +1,29 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1530268619201 + + + COMMENT + + + + DATE_CREATION + 1530181166710 + + + TAG + + + + TYPE + UPLOAD + + + diff --git a/Reference/Device_Data_File/Process_Update/Tasks/Task_Destination_Found.php b/Reference/Device_Data_File/Process_Update/Tasks/Task_Destination_Found.php new file mode 100644 index 000000000..eb6d2c29e --- /dev/null +++ b/Reference/Device_Data_File/Process_Update/Tasks/Task_Destination_Found.php @@ -0,0 +1,79 @@ + FAIL [Don't proceed] + * Such cases need to be handled as per the Task logic + */ +check_mandatory_param('var_name'); + +/** + * $context => Service Context variable per Service Instance + * All the user-inputs of Tasks are automatically stored in $context + * Also, any new variables should be stored in $context which are used across Service Instance + * The variables stored in $context can be used across all the Tasks and Processes of a particular Service + * Update $context array [add/update/delete variables] as per requirement + * + * ENTER YOUR CODE HERE + */ +$context['var_name2'] = $context['var_name2'] + 1; + +/** + * Format of the Task response : + * JSON format : {"wo_status":"status","wo_comment":"comment","wo_newparams":{json_body}} + * wo_status : ENDED [Green color] or FAILED [Red color] or WARNING [Orange color] + * -> While the Task is Running [means no response returned yet], task status is RUNNING [Blue color] + * -> When status is returned as FAILED, the Orchestration Engine stops the Process Execution from this Task + * wo_comment : Appropriate Comment to display as per the success/failure of the Task + * wo_newparams : json_body parameters returned from this Task + * + * Function prepare_json_response() takes care of Creating a Json response from inputs + * This function definiton can be found at : /opt/fmc_repository/Process/Reference/Common/utility.php + * NOTE : For 'wo_newparams', always pass "$context" [whether wo_status is ENDED/FAILED/WARNING to preserve it across Service Instance] + * -> Last argument "true" mentions whether the json_response to be Logged in the logfile : /opt/jboss/latest/logs/process.log + * -> If not passed, it's "false" + * + * The response "$ret" should be echoed from the Task "echo $ret" which is read by Orchestration Engine + * In case of FAILURE/WARNING, the Task can be Terminated by calling "exit" as per Logic + */ +if ($context['var_name2'] % 2 === 0) { + $ret = prepare_json_response(FAILED, 'Task Failed', $context, true); + echo "$ret\n"; + exit; +} + +/** + * End of the task do not modify after this point + */ +task_exit(ENDED, "Task OK"); + +?> \ No newline at end of file diff --git a/Reference/Device_Data_File/Process_Update/Tasks/Task_File_Found.php b/Reference/Device_Data_File/Process_Update/Tasks/Task_File_Found.php new file mode 100644 index 000000000..a126e0507 --- /dev/null +++ b/Reference/Device_Data_File/Process_Update/Tasks/Task_File_Found.php @@ -0,0 +1,63 @@ + \ No newline at end of file diff --git a/Reference/Device_Data_File/Process_Update/Tasks/Task_File_Sent.php b/Reference/Device_Data_File/Process_Update/Tasks/Task_File_Sent.php new file mode 100644 index 000000000..b430e23ae --- /dev/null +++ b/Reference/Device_Data_File/Process_Update/Tasks/Task_File_Sent.php @@ -0,0 +1,48 @@ +\d+)/',$context['device'],$device_id_number); +$context['device_id_number']=$device_id_number[1]; +$context['cmd']="/opt/ubi-jentreprise/bin/api/device/readDeviceById.sh ".$context['device_id_number']; +$response_cmd= shell_exec($context['cmd']); +preg_match('#\n
(.*)
\n#',$response_cmd, $out); +$context['device_ip']=$out[1]; + + +// $cmd="scp ".$context['src_file']." ".$context['user']."@".$context['device_ip'].":".$context['dst_file']; +$cmd="sshpass -p ".$context['password']." scp -o StrictHostKeyChecking=no ".$context['src_file']." ".$context['user']."@".$context['device_ip'].":".$context['dst_file']." 2> /dev/null"; + +shell_exec($cmd); + + + +task_exit(ENDED, "OK, Check the first task in the Live Console"); + +?> \ No newline at end of file diff --git a/Reference/Device_Management/.meta_Device_Management_List.xml b/Reference/Device_Management/.meta_Device_Management_List.xml new file mode 100644 index 000000000..83f442afe --- /dev/null +++ b/Reference/Device_Management/.meta_Device_Management_List.xml @@ -0,0 +1,37 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1526045269328 + + + COMMENT + + + + REPOSITORY + CommandDefinition + + + DATE_CREATION + 1525946328081 + + + CONFIGURATION_FILTER + + + + TYPE + UPLOAD + + + TAG + Device_Management_List.xml + + + diff --git a/Reference/Device_Management/.meta_Process_Get_Device_List b/Reference/Device_Management/.meta_Process_Get_Device_List new file mode 100644 index 000000000..fd67db18c --- /dev/null +++ b/Reference/Device_Management/.meta_Process_Get_Device_List @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1525946519084 + + + DATE_CREATION + 1525946519045 + + + TYPE + DIRECTORY + + + diff --git a/Reference/Device_Management/.meta_Process_Get_Device_List_Update b/Reference/Device_Management/.meta_Process_Get_Device_List_Update new file mode 100644 index 000000000..6884ba7be --- /dev/null +++ b/Reference/Device_Management/.meta_Process_Get_Device_List_Update @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1525974445427 + + + DATE_CREATION + 1525974445418 + + + TYPE + DIRECTORY + + + diff --git a/Reference/Device_Management/.meta_Process_Move_to_Trash b/Reference/Device_Management/.meta_Process_Move_to_Trash new file mode 100644 index 000000000..5798192e6 --- /dev/null +++ b/Reference/Device_Management/.meta_Process_Move_to_Trash @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1525958319913 + + + DATE_CREATION + 1525958319905 + + + TYPE + DIRECTORY + + + diff --git a/Reference/Device_Management/.meta_Process_Update_Device_List b/Reference/Device_Management/.meta_Process_Update_Device_List new file mode 100644 index 000000000..e76ed1951 --- /dev/null +++ b/Reference/Device_Management/.meta_Process_Update_Device_List @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1525974496109 + + + DATE_CREATION + 1525974496071 + + + TYPE + DIRECTORY + + + diff --git a/Reference/Device_Management/Device_Management_List.xml b/Reference/Device_Management/Device_Management_List.xml new file mode 100644 index 000000000..5de9fcd57 --- /dev/null +++ b/Reference/Device_Management/Device_Management_List.xml @@ -0,0 +1,62 @@ + + + true + + service_id + 5 + TRANSACTION + + /images/eclipseIcons/page_obj.gif + Device Management List + 10000 + 0 + 5 + false + false + false + 5 + + + +
Get Device List
+
+
+ + +
Get Device List
+
+
+
+ + 5 + Get Device List + + false + CREATE + + /opt/fmc_repository/Process/Reference/Device_Management/Process_Get_Device_List/Tasks/ + Get Device List + + + + + 5 + Move to Trash + + false + DELETE + + + + 5 + Update Device List + + false + UPDATE + + /opt/fmc_repository/Process/Reference/Device_Management/Process_Update_Device_List/Tasks/ + Update Device List + + + +
diff --git a/Reference/Device_Management/Process_Get_Device_List/.meta_Tasks b/Reference/Device_Management/Process_Get_Device_List/.meta_Tasks new file mode 100644 index 000000000..006474f76 --- /dev/null +++ b/Reference/Device_Management/Process_Get_Device_List/.meta_Tasks @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1525946599334 + + + DATE_CREATION + 1525946599292 + + + TYPE + DIRECTORY + + + diff --git a/Reference/Device_Management/Process_Get_Device_List/Tasks/.meta_Task_Get_Device_List.php b/Reference/Device_Management/Process_Get_Device_List/Tasks/.meta_Task_Get_Device_List.php new file mode 100644 index 000000000..eff09175f --- /dev/null +++ b/Reference/Device_Management/Process_Get_Device_List/Tasks/.meta_Task_Get_Device_List.php @@ -0,0 +1,29 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1526045213418 + + + COMMENT + + + + DATE_CREATION + 1525946599353 + + + TAG + + + + TYPE + UPLOAD + + + diff --git a/Reference/Device_Management/Process_Get_Device_List/Tasks/Task_Get_Device_List.php b/Reference/Device_Management/Process_Get_Device_List/Tasks/Task_Get_Device_List.php new file mode 100644 index 000000000..013db9636 --- /dev/null +++ b/Reference/Device_Management/Process_Get_Device_List/Tasks/Task_Get_Device_List.php @@ -0,0 +1,84 @@ + to avoid error display characters (accent..) with excel file import + +fprintf($file, chr(0xEF).chr(0xBB).chr(0xBF)); + +foreach($lines as $line){ + +fputcsv($file, $line,$delimiter); + +} + +fclose($file); + + +$res = prepare_json_response(ENDED, "Devices details fetched successfully.", $context, true); +echo $res; + + +?> \ No newline at end of file diff --git a/Reference/Device_Management/Process_Update_Device_List/.meta_Tasks b/Reference/Device_Management/Process_Update_Device_List/.meta_Tasks new file mode 100644 index 000000000..5821564e4 --- /dev/null +++ b/Reference/Device_Management/Process_Update_Device_List/.meta_Tasks @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1525974530942 + + + DATE_CREATION + 1525974530935 + + + TYPE + DIRECTORY + + + diff --git a/Reference/Device_Management/Process_Update_Device_List/Tasks/.meta_Task_Update_Device_List.php b/Reference/Device_Management/Process_Update_Device_List/Tasks/.meta_Task_Update_Device_List.php new file mode 100644 index 000000000..c0fa75c15 --- /dev/null +++ b/Reference/Device_Management/Process_Update_Device_List/Tasks/.meta_Task_Update_Device_List.php @@ -0,0 +1,29 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1526045243459 + + + COMMENT + + + + DATE_CREATION + 1525974530960 + + + TAG + + + + TYPE + UPLOAD + + + diff --git a/Reference/Device_Management/Process_Update_Device_List/Tasks/Task_Update_Device_List.php b/Reference/Device_Management/Process_Update_Device_List/Tasks/Task_Update_Device_List.php new file mode 100644 index 000000000..fd8aa82be --- /dev/null +++ b/Reference/Device_Management/Process_Update_Device_List/Tasks/Task_Update_Device_List.php @@ -0,0 +1,85 @@ + to avoid error display characters (accent..) with excel file import + +fprintf($file, chr(0xEF).chr(0xBB).chr(0xBF)); + +foreach($lines as $line){ + +fputcsv($file, $line,$delimiter); + +} + +fclose($file); + + +$res = prepare_json_response(ENDED, "Devices details fetched successfully.", $context, true); +echo $res; + + +?> \ No newline at end of file diff --git a/Reference/FORTINET/.meta_Tasks b/Reference/FORTINET/.meta_Tasks new file mode 100644 index 000000000..80c8946fe --- /dev/null +++ b/Reference/FORTINET/.meta_Tasks @@ -0,0 +1,39 @@ + + + + + MODEL + + + DATE_MODIFICATION + 1445429309400 + + + COMMENT + + + + REPOSITORY + Process + + + DATE_CREATION + 1445429309382 + + + MANUFACTURER + + + CONFIGURATION_FILTER + + + + TYPE + DIRECTORY + + + TAG + + + + diff --git a/Reference/FORTINET/Tasks/.meta_Task_fortigate_execute_ping.php b/Reference/FORTINET/Tasks/.meta_Task_fortigate_execute_ping.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/FORTINET/Tasks/.meta_Task_fortigate_execute_ping.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/FORTINET/Tasks/.meta_Task_fortigate_port_ip_update.php b/Reference/FORTINET/Tasks/.meta_Task_fortigate_port_ip_update.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/FORTINET/Tasks/.meta_Task_fortigate_port_ip_update.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/FORTINET/Tasks/.meta_Task_fortigate_reboot.php b/Reference/FORTINET/Tasks/.meta_Task_fortigate_reboot.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/FORTINET/Tasks/.meta_Task_fortigate_reboot.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/FORTINET/Tasks/.meta_Task_fortigate_stop.php b/Reference/FORTINET/Tasks/.meta_Task_fortigate_stop.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/FORTINET/Tasks/.meta_Task_fortigate_stop.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/FORTINET/Tasks/.meta_Task_fortigate_update_execute.php b/Reference/FORTINET/Tasks/.meta_Task_fortigate_update_execute.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/FORTINET/Tasks/.meta_Task_fortigate_update_execute.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/FORTINET/Tasks/Task_fortigate_execute_ping.php b/Reference/FORTINET/Tasks/Task_fortigate_execute_ping.php new file mode 100644 index 000000000..ece5e888f --- /dev/null +++ b/Reference/FORTINET/Tasks/Task_fortigate_execute_ping.php @@ -0,0 +1,56 @@ + $PROCESSINSTANCEID, + 'EXECNUMBER' => $EXECNUMBER, + 'TASKID' => $TASKID); + +$device_id = substr($context['device_id'], 3); +$ip_address = $context['ip_address']; + +$configuration = "execute ping $ip_address"; +$response = _device_do_push_configuration_by_id($device_id, $configuration); +$response = json_decode($response, true); +if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + echo $response; + exit; +} + +$response = wait_for_pushconfig_completion($device_id, $process_params); +$response = json_decode($response, true); +if ($response['wo_status'] !== ENDED) { + $context['ping_response'] = "Not Available"; + $context['ping_status'] = "Not Available"; + $response = prepare_json_response(FAILED, $response['wo_comment'] . "\nPING Status : Not Available", $context, true); + echo $response; + exit; +} +$pushconfig_status_message = $response['wo_comment']; +$context['ping_response'] = substr($pushconfig_status_message, strpos($pushconfig_status_message, "Push Config Message : ") + + strlen("Push Config Message : ")); + +if (strpos($pushconfig_status_message, "100% packet loss") !== false) { + $pushconfig_status_message .= "PING Status : " . FAILED; + $context['ping_status'] = FAILED; +} +else { + $pushconfig_status_message .= "PING Status : " . STATUS_OK; + $context['ping_status'] = STATUS_OK; +} +$response = prepare_json_response(ENDED, $pushconfig_status_message, $context, true); +echo $response; +?> \ No newline at end of file diff --git a/Reference/FORTINET/Tasks/Task_fortigate_port_ip_update.php b/Reference/FORTINET/Tasks/Task_fortigate_port_ip_update.php new file mode 100644 index 000000000..56b06018c --- /dev/null +++ b/Reference/FORTINET/Tasks/Task_fortigate_port_ip_update.php @@ -0,0 +1,59 @@ + $PROCESSINSTANCEID, + 'EXECNUMBER' => $EXECNUMBER, + 'TASKID' => $TASKID); + +$operator_prefix = $context['operator_prefix']; +$device_id = substr($context['device_id'], 3); +$ip_address = $context['ip_address']; +$netmask = $context['netmask']; +$interface = $context['interface']; + +$command1 = "config system interface"; +$command2 = "edit $interface"; +$command3 = "set ip $ip_address $netmask"; +$command4 = "end"; +$configuration = "$command1\n$command2\n$command3\n$command4"; +$response = _device_do_push_configuration_by_id($device_id, $configuration); +$response = json_decode($response, true); +if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + echo $response; + exit; +} + +$timeout_prompt = $operator_prefix . $device_id . " # "; +if ($interface == 'port1'){ + //for port1, we lost the connection when we change the IP, we get 'timeout, buffer received' + $timeout_ignone_messasges = array("timeout, buffer received", "timeout, $timeout_prompt not found", "timeout, # not found"); +}else{ + $timeout_ignone_messasges = array("timeout, $timeout_prompt not found", "timeout, # not found"); +} +$response = wait_for_pushconfig_completion($device_id, $process_params, $timeout_ignone_messasges); +$response = json_decode($response, true); +if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + echo $response; + exit; +} +$pushconfig_status_message = $response['wo_comment']; + +$response = prepare_json_response(ENDED, "IP Address $ip_address-$netmask updated successfully on Interface $interface on the Fortigate Device $device_id.\n$pushconfig_status_message", + $context, true); +echo $response; + +?> \ No newline at end of file diff --git a/Reference/FORTINET/Tasks/Task_fortigate_reboot.php b/Reference/FORTINET/Tasks/Task_fortigate_reboot.php new file mode 100644 index 000000000..56cfe843f --- /dev/null +++ b/Reference/FORTINET/Tasks/Task_fortigate_reboot.php @@ -0,0 +1,43 @@ + $PROCESSINSTANCEID, + 'EXECNUMBER' => $EXECNUMBER, + 'TASKID' => $TASKID); +$device_id = substr($context['device_id'], 3); + +$configuration = "execute reboot"; +$response = _device_do_push_configuration_by_id($device_id, $configuration); +$response = json_decode($response, true); +if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + echo $response; + exit; +} + +$timeout_ignone_messasge = "closed by peer"; +$response = wait_for_pushconfig_completion($device_id, $process_params, $timeout_ignone_messasge); +$response = json_decode($response, true); +if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + echo $response; + exit; +} +$pushconfig_status_message = $response['wo_comment']; + +$response = prepare_json_response(ENDED, "Fortigate Device $device_id Rebooted Successfully.\n$pushconfig_status_message", + $context, true); +echo $response; + +?> \ No newline at end of file diff --git a/Reference/FORTINET/Tasks/Task_fortigate_stop.php b/Reference/FORTINET/Tasks/Task_fortigate_stop.php new file mode 100644 index 000000000..70e95e844 --- /dev/null +++ b/Reference/FORTINET/Tasks/Task_fortigate_stop.php @@ -0,0 +1,43 @@ + $PROCESSINSTANCEID, + 'EXECNUMBER' => $EXECNUMBER, + 'TASKID' => $TASKID); +$device_id = substr($context['device_id'], 3); + +$configuration = "execute shutdown"; +$response = _device_do_push_configuration_by_id($device_id, $configuration); +$response = json_decode($response, true); +if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + echo $response; + exit; +} + +$timeout_ignone_messasge = "closed by peer"; +$response = wait_for_pushconfig_completion($device_id, $process_params, $timeout_ignone_messasge); +$response = json_decode($response, true); +if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + echo $response; + exit; +} +$pushconfig_status_message = $response['wo_comment']; + +$response = prepare_json_response(ENDED, "Fortigate Device $device_id Shutdown Successfully.\n$pushconfig_status_message", + $context, true); +echo $response; + +?> \ No newline at end of file diff --git a/Reference/FORTINET/Tasks/Task_fortigate_update_execute.php b/Reference/FORTINET/Tasks/Task_fortigate_update_execute.php new file mode 100644 index 000000000..7c0e9958f --- /dev/null +++ b/Reference/FORTINET/Tasks/Task_fortigate_update_execute.php @@ -0,0 +1,43 @@ + $PROCESSINSTANCEID, + 'EXECNUMBER' => $EXECNUMBER, + 'TASKID' => $TASKID); +$device_id = substr($context['device_id'], 3); + +$configuration = "execute update-now"; +$response = _device_do_push_configuration_by_id($device_id, $configuration); +$response = json_decode($response, true); +if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + echo $response; + exit; +} + +#$timeout_ignone_messasge = "closed by peer"; +$response = wait_for_pushconfig_completion($device_id, $process_params); +$response = json_decode($response, true); +if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + echo $response; + exit; +} +$pushconfig_status_message = $response['wo_comment']; + +$response = prepare_json_response(ENDED, "Fortigate Device $device_id Updated Successfully.\n$pushconfig_status_message", + $context, true); +echo $response; + +?> \ No newline at end of file diff --git a/Reference/Heat/.meta_Process_Deploy b/Reference/Heat/.meta_Process_Deploy new file mode 100644 index 000000000..d2daaaafe --- /dev/null +++ b/Reference/Heat/.meta_Process_Deploy @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1466000685339 + + + DATE_CREATION + 1466000685047 + + + TYPE + DIRECTORY + + + diff --git a/Reference/Heat/.meta_Process_Undeploy b/Reference/Heat/.meta_Process_Undeploy new file mode 100644 index 000000000..03523023c --- /dev/null +++ b/Reference/Heat/.meta_Process_Undeploy @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1466000839203 + + + DATE_CREATION + 1466000839180 + + + TYPE + DIRECTORY + + + diff --git a/Reference/Heat/.meta_SampleCirrosHeat.xml b/Reference/Heat/.meta_SampleCirrosHeat.xml new file mode 100644 index 000000000..b0031cf04 --- /dev/null +++ b/Reference/Heat/.meta_SampleCirrosHeat.xml @@ -0,0 +1,37 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1466002063463 + + + COMMENT + + + + REPOSITORY + CommandDefinition + + + DATE_CREATION + 1465999894072 + + + CONFIGURATION_FILTER + + + + TAG + SampleCirrosHeat.xml + + + TYPE + UPLOAD + + + diff --git a/Reference/Heat/.meta_TaskLaunchStack.php b/Reference/Heat/.meta_TaskLaunchStack.php new file mode 100644 index 000000000..de7552b4f --- /dev/null +++ b/Reference/Heat/.meta_TaskLaunchStack.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1466001519146 + + + DATE_CREATION + 1466001473937 + + + TYPE + FILE + + + diff --git a/Reference/Heat/.meta_TaskRemoveStack.php b/Reference/Heat/.meta_TaskRemoveStack.php new file mode 100644 index 000000000..307b75f01 --- /dev/null +++ b/Reference/Heat/.meta_TaskRemoveStack.php @@ -0,0 +1,43 @@ + + + + + MODEL + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1466000249083 + + + COMMENT + + + + REPOSITORY + CommandDefinition + + + DATE_CREATION + 1466000231695 + + + MANUFACTURER + + + CONFIGURATION_FILTER + + + + TYPE + UPLOAD + + + TAG + TaskRemoveFortinet.php + + + diff --git a/Reference/Heat/.meta_getFloatingIp.php b/Reference/Heat/.meta_getFloatingIp.php new file mode 100644 index 000000000..26c5bb41b --- /dev/null +++ b/Reference/Heat/.meta_getFloatingIp.php @@ -0,0 +1,43 @@ + + + + + MODEL + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1466000214342 + + + COMMENT + + + + REPOSITORY + CommandDefinition + + + DATE_CREATION + 1466000173549 + + + MANUFACTURER + + + CONFIGURATION_FILTER + + + + TYPE + UPLOAD + + + TAG + getFloatingIp.php + + + diff --git a/Reference/Heat/Process_Deploy/.keep b/Reference/Heat/Process_Deploy/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/Reference/Heat/Process_Undeploy/.keep b/Reference/Heat/Process_Undeploy/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/Reference/Heat/SampleCirrosHeat.xml b/Reference/Heat/SampleCirrosHeat.xml new file mode 100644 index 000000000..180a89754 --- /dev/null +++ b/Reference/Heat/SampleCirrosHeat.xml @@ -0,0 +1,142 @@ + + + + service_id + 5 + Default + /images/repository/CommandDefinition/icons/ServerPool.png + Cirros Heat + 10000 + 1 + 0 + + + +
VIM
+
+
+ + +
VIM
+
+
+ + +
VIM
+
+
+ + +
VIM
+
+
+ + +
VNF
+
+
+ + +
VNF
+
+
+ + +
VNF
+
+
+ + +
VNF
+
+
+ + +
VNF
+
+
+ + +
VNF
+
+
+ + +
VNF
+
+
+ + +
VNF
+
+
+ + +
VNF
+
+
+ + +
VNF
+
+
+ + +
VNF
+
+
+ + +
VNF
+
+
+ + +
VNF
+
+
+ + +
VNF
+
+
+
repository.uploader.Process.default + + + 5 + Deploy + CREATE + + + + Launch Heat Template + + + + Get Floating IP + + + + Create VNF in MSActivator + + + + Provisione VNF + + + + + 5 + Undeploy + DELETE + + + + Remove Stack + + + + Remove VNF + + +
diff --git a/Reference/Heat/TaskLaunchStack.php b/Reference/Heat/TaskLaunchStack.php new file mode 100644 index 000000000..e0134d575 --- /dev/null +++ b/Reference/Heat/TaskLaunchStack.php @@ -0,0 +1,52 @@ + \ No newline at end of file diff --git a/Reference/Heat/TaskRemoveStack.php b/Reference/Heat/TaskRemoveStack.php new file mode 100644 index 000000000..d782514c6 --- /dev/null +++ b/Reference/Heat/TaskRemoveStack.php @@ -0,0 +1,20 @@ + \ No newline at end of file diff --git a/Reference/Heat/getFloatingIp.php b/Reference/Heat/getFloatingIp.php new file mode 100644 index 000000000..9aac23a18 --- /dev/null +++ b/Reference/Heat/getFloatingIp.php @@ -0,0 +1,16 @@ + \ No newline at end of file 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/Device/Task_msa_device_delete.php b/Reference/MSActivator/Device/Task_msa_device_delete.php index d6ec4f43c..3c151f1b6 100755 --- a/Reference/MSActivator/Device/Task_msa_device_delete.php +++ b/Reference/MSActivator/Device/Task_msa_device_delete.php @@ -18,10 +18,16 @@ function list_args() { $response = _device_delete($device_id); $response = json_decode($response, true); if ($response['wo_status'] !== ENDED) { - $response['wo_status'] = WARNING; - $response = json_encode($response); - echo $response; - exit; + if (isset($response['wo_comment']) && preg_match("/not found in database/i",$response['wo_comment'],$match)){ + //Device not found in the MSA Database + $response = prepare_json_response(ENDED, "OK, MSA Device $device_id not found in DB", $context, true); + echo $response; + }else{ + $response['wo_status'] = WARNING; + $response = json_encode($response); + echo $response; + exit; + } } $response = prepare_json_response(ENDED, "MSA Device $device_id deleted successfully.", $context, true); diff --git a/Reference/MSActivator/Device/Task_msa_management_ip_update.php b/Reference/MSActivator/Device/Task_msa_management_ip_update.php index c3e6dee3b..d1a124543 100755 --- a/Reference/MSActivator/Device/Task_msa_management_ip_update.php +++ b/Reference/MSActivator/Device/Task_msa_management_ip_update.php @@ -20,6 +20,27 @@ function list_args() echo $response; exit; } + +//check if ip is update in the sec-engine side +$sec_ip_address = ""; +for($i=0; $i<5; $i++){ + sleep(2); + $output = shell_exec("/opt/dms/bin/oradns --id ".$context['device_id']); + //example output - ECL480 ip 10.30.19.237 ext ip 10.30.19.237 interface type E (port1-port1) ip type S (UP 31 sec old - 6 pings left) + if($output != null){ + $details = explode(" ", $output); + $sec_ip_address = $details[2]; + if($sec_ip_address == $ip_address){ + break; + } + } +} + +if($sec_ip_address != $ip_address){ + $response = prepare_json_response(FAILED, "Update Management IP $ip_address failed on Sec Engine side, check batchupdate", $context, true); + echo $response; + exit; +} $response = prepare_json_response(ENDED, "Management IP $ip_address updated successfully on MSA Device $device_id.", $context, true); echo $response; 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/OPENSTACK/Library/OBMF/nova_obmf.php b/Reference/OPENSTACK/Library/OBMF/nova_obmf.php index f602918b8..75f45013f 100755 --- a/Reference/OPENSTACK/Library/OBMF/nova_obmf.php +++ b/Reference/OPENSTACK/Library/OBMF/nova_obmf.php @@ -16,7 +16,7 @@ function _nova_server_create ($device_id, $server_name, $networks, $server_array['key'] = $key; $server_array['config_drive'] = $config_drive; $server_array['user_data'] = $user_data; - if ($availability_zone !== "") { + if (!empty($availability_zone)) { $array['availability_zone'] = $availability_zone; } if (!empty($security_groups)) { diff --git a/Reference/OPENSTACK/Library/REST/cinder_rest.php b/Reference/OPENSTACK/Library/REST/cinder_rest.php index cf80e7859..cb5ce75e3 100755 --- a/Reference/OPENSTACK/Library/REST/cinder_rest.php +++ b/Reference/OPENSTACK/Library/REST/cinder_rest.php @@ -2,8 +2,8 @@ require_once '/opt/fmc_repository/Process/Reference/OPENSTACK/Library/REST/utility.php'; -#curl -i -k https://10.1.144.119/v2/abcde/volumes -X POST -#-H "X-Auth-Token:42946664fc6e41e392bb7ee51a9160b9" -H "Accept: application/json" +#curl -i -k https://xxxxx/v2/abcde/volumes -X POST +#-H "X-Auth-Token:yyyyy" -H "Accept: application/json" #-H "Content-Type: application/json" -d '{"volume":{"name":"abc","size":40, #"availability_zone":"nova","multiattach":"false","bootable":"fales"}}' function _cinder_volume_create ($cinder_endpoint, $auth_token, $name, $size, @@ -54,7 +54,7 @@ function _cinder_volume_update ($cinder_endpoint, $auth_token, $volume_id, $name $array = array(); $array['name'] = $name; $array['description'] = $description; - $array['metadata'] = $metadata; + //$array['metadata'] = $metadata; //optional, prevent error with openstack juno patch $array['tenant_id'] = $tenant_id; $volume_array = array('volume' => $array); diff --git a/Reference/OPENSTACK/Library/REST/glance_rest.php b/Reference/OPENSTACK/Library/REST/glance_rest.php new file mode 100644 index 000000000..49a80cf4f --- /dev/null +++ b/Reference/OPENSTACK/Library/REST/glance_rest.php @@ -0,0 +1,59 @@ + diff --git a/Reference/OPENSTACK/Library/REST/keystone_rest.php b/Reference/OPENSTACK/Library/REST/keystone_rest.php index eb8a5f131..d41820fe7 100755 --- a/Reference/OPENSTACK/Library/REST/keystone_rest.php +++ b/Reference/OPENSTACK/Library/REST/keystone_rest.php @@ -2,7 +2,7 @@ require_once '/opt/fmc_repository/Process/Reference/OPENSTACK/Library/REST/utility.php'; -#export TEST_TOKEN=`curl -si 'http://ct-int-vip:25357/v3/auth/tokens' -X OP_POST -H 'Accept: application/json' +#export TEST_TOKEN=`curl -si 'http://xxxxxx/v3/auth/tokens' -X OP_POST -H 'Accept: application/json' #-H 'Content-type: application/json' #-d '{'auth': {'identity': {'methods': ['password'], 'password': {'user': {'domain': {'name': 'Default'}, #'name': 'abc', 'password': 'abc'}}}, 'scope': {'project': {'domain': {'name': 'Default'}, @@ -11,13 +11,13 @@ function _keystone_project_scoped_token_get ($keystone_endpoint, $userdomain, $u $scopedomain, $projectname) { $array = array(); - //$array['domain'] = array('id' => $userdomain); - $array['domain'] = array('name' => $userdomain); + $array['domain'] = array('id' => $userdomain); + //$array['domain'] = array('name' => $userdomain); $array['user'] = array('domain' => $array['domain'], 'name' => $username, 'password' => $password); $array['password'] = array('user' => $array['user']); - //$array['domain'] = array('id' => $scopedomain); - $array['domain'] = array('name' => $scopedomain); + $array['domain'] = array('id' => $scopedomain); + //$array['domain'] = array('name' => $scopedomain); $array['project'] = array('domain' => $array['domain'], 'id' => $projectname); $array['scope'] = array('project' => $array['project']); @@ -32,7 +32,7 @@ function _keystone_project_scoped_token_get ($keystone_endpoint, $userdomain, $u return $response; } -#export ADMIN_TOKEN=`curl -si -X OP_POST http://ct-int-vip:25357/v3/auth/tokens -H "Accept: application/json" +#export ADMIN_TOKEN=`curl -si -X OP_POST http://xxxxxxxxxx/v3/auth/tokens -H "Accept: application/json" #-H "Content-type: application/json" -d '{"auth": {"identity": {"methods": ["password"], #"password": {"user": {"domain": {"name": "dmnAdmin"}, "name": "usrDmnAdmin", "password": "xxxxxxxx"}}}, #"scope": {"domain": {"name": "Default"}}}}' | grep X-Subject-Token | awk '{print $2}' | sed 's/\r//'`;echo $ADMIN_TOKEN @@ -57,7 +57,7 @@ function _keystone_domain_scoped_token_get ($keystone_endpoint, $userdomain, $us return $response; } -#curl -si 'http://10.1.144.111:35357/v2.0/tokens' -H "Content-type: application/json" +#curl -si 'http://xxxxxxxxxxxxxxx/v2.0/tokens' -H "Content-type: application/json" #-d '{ "auth": {"tenantId": "1234", "passwordCredentials" : {"username": "admin", "password": "admin123"}}}' function _keystone_v2_token_get ($keystone_endpoint, $username, $password, $tenant_id) { @@ -79,7 +79,7 @@ function _keystone_v2_token_get ($keystone_endpoint, $username, $password, $tena return $response; } -#curl -i -X OP_POST http://ct-int-vip:25357/v3/users -H "X-Auth-Token: ${ADMIN_TOKEN}" -H "Accept: application/json" +#curl -i -X OP_POST http://xxxxxxxxxxx/v3/users -H "X-Auth-Token: ${ADMIN_TOKEN}" -H "Accept: application/json" #-H "Content-type: application/json" -d #'{"user": {"domain_id": "v2AccessDomain", "enabled": true,"name": "abc"}}' function _keystone_user_create ($keystone_endpoint, $auth_token, $domain_id, $name, $enabled = "true") { @@ -104,7 +104,7 @@ function _keystone_user_create ($keystone_endpoint, $auth_token, $domain_id, $na return $response; } -#url -i -X PATCH http://ct-int-vip:25357/v3/users/c02b1913b277410784c6956e24360141 -H "X-Auth-Token: ${ADMIN_TOKEN}" +#url -i -X PATCH http://xxxxxxxx/v3/users/c02b1913b277410784c6956e24360141 -H "X-Auth-Token: ${ADMIN_TOKEN}" #-H "Accept: application/json" -H "Content-type: application/json" -d '{"user": {"password": "abc"}}' function _keystone_user_password_update ($keystone_endpoint, $auth_token, $user_id, $password) { @@ -125,7 +125,7 @@ function _keystone_user_password_update ($keystone_endpoint, $auth_token, $user_ return $response; } -#curl -i -X OP_POST http://ct-int-vip:25357/v3/projects -H "X-Auth-Token: ${ADMIN_TOKEN}" -H "Accept: application/json" +#curl -i -X OP_POST http://xxxxxxxxx/v3/projects -H "X-Auth-Token: ${ADMIN_TOKEN}" -H "Accept: application/json" #-H "Content-type: application/json" -d #'{"project": {"enabled": true, "domain_id": "v2AccessDomain", "description": null,"name": "abc"}}' function _keystone_project_create ($keystone_endpoint, $auth_token, $domain_id, $name, $enabled = "true", $description = "") { @@ -150,7 +150,7 @@ function _keystone_project_create ($keystone_endpoint, $auth_token, $domain_id, return $response; } -#curl -i -X OP_PUT http://ct-int-vip:25357/v3/projects/${PJID}/users/$USERID/roles/$ROLEID -H "X-Auth-Token: ${ADMIN_TOKEN}" +#curl -i -X OP_PUT http://xxxxxxxxxxx/v3/projects/${PJID}/users/$USERID/roles/$ROLEID -H "X-Auth-Token: ${ADMIN_TOKEN}" #-H "Accept: application/json" -H "Content-type: application/json" function _keystone_user_role_add ($keystone_endpoint, $auth_token, $tenant_id, $user_id, $role_id) { diff --git a/Reference/OPENSTACK/Library/REST/neutron_rest.php b/Reference/OPENSTACK/Library/REST/neutron_rest.php index 2ccecda7e..8ed7cbdef 100755 --- a/Reference/OPENSTACK/Library/REST/neutron_rest.php +++ b/Reference/OPENSTACK/Library/REST/neutron_rest.php @@ -2,7 +2,7 @@ require_once '/opt/fmc_repository/Process/Reference/OPENSTACK/Library/REST/utility.php'; -#curl -i http://ot1-contrail-int-vip:9696/v2.0/networks.json -X OP_POST -H "X-Auth-Token: ${TEST_TOKEN}" +#curl -i http://xxxxxxxxx:9696/v2.0/networks.json -X OP_POST -H "X-Auth-Token: ${TEST_TOKEN}" #-H "Accept: application/json" -H "Content-Type: application/json" -d #'{"network": {"name": "abc", "admin_state_up": true}}' function _neutron_network_create ($neutron_endpoint, $auth_token, $name, $admin_state_up = true) { @@ -26,7 +26,96 @@ function _neutron_network_create ($neutron_endpoint, $auth_token, $name, $admin_ return $response; } -#curl -i http://ot1-contrail-int-vip:9696/v2.0/subnets.json -X OP_POST -H "X-Auth-Token: ${TEST_TOKEN}" +/** +* +* Get Networks +* +**/ + +function _neutron_subnets_from_name($neutron_endpoint, $auth_token, $networks) +{ + $openstack_rest_api = "{$neutron_endpoint}/v2.0/networks"; + $curl_cmd = create_openstack_operation_request(OP_GET, $openstack_rest_api, $auth_token); + + $response = perform_curl_operation($curl_cmd, "GET NETWORKS"); + $response = json_decode($response, true); + if ($response['wo_status'] !== ENDED) { + return json_encode($response); + } + + $response = stripslashes($response['wo_newparams']['response_body']); + $subnets = array(); + if (isset($networks) && ! empty($networks)) { + foreach ($networks as &$network) { + $nets = json_decode($response, true); + foreach ($nets['networks'] as &$net) { + if ($net['name'] == $network) { + $subnets[] = $net['subnets']; + } + } + } + } + return prepare_json_response(ENDED, ENDED_SUCCESSFULLY, json_encode($subnets)); +} + +function _neutron_networks_from_name($neutron_endpoint, $auth_token, $networks) +{ + $openstack_rest_api = "{$neutron_endpoint}/v2.0/networks"; + $curl_cmd = create_openstack_operation_request(OP_GET, $openstack_rest_api, $auth_token); + + $response = perform_curl_operation($curl_cmd, "GET NETWORKS"); + $response = json_decode($response, true); + if ($response['wo_status'] !== ENDED) { + return json_encode($response); + } + + $response = stripslashes($response['wo_newparams']['response_body']); + $network_list = array(); + if (isset($networks) && ! empty($networks)) { + foreach ($networks as &$network) { + $nets = json_decode($response, true); + foreach ($nets['networks'] as &$net) { + if ($net['name'] == $network) { + $network_list[] = $net['id']; + } + } + } + } + return prepare_json_response(ENDED, ENDED_SUCCESSFULLY, json_encode($network_list)); +} + +/*** +* GET routers +* +**/ +function _neutron_routers_by_routers_name($neutron_endpoint, $auth_token, $routers) +{ + $openstack_rest_api = "{$neutron_endpoint}/v2.0/routers"; + $curl_cmd = create_openstack_operation_request(OP_GET, $openstack_rest_api, $auth_token); + + $response = perform_curl_operation($curl_cmd, "GET ROUTERS"); + $response = json_decode($response, true); + if ($response['wo_status'] !== ENDED) { + return json_encode($response); + } + + $response = stripslashes($response['wo_newparams']['response_body']); + $router_list = array(); + if (isset($routers) && ! empty($routers)) { + foreach ($routers as &$router) { + $rts = json_decode($response, true); + foreach ($rts['routers'] as &$rt) { + if ($rt['name'] == $router) { + $router_list[] = $rt['id']; + } + } + } + } + return prepare_json_response(ENDED, ENDED_SUCCESSFULLY, json_encode($router_list)); +} + + +#curl -i http://xxxxxxxxx:9696/v2.0/subnets.json -X OP_POST -H "X-Auth-Token: ${TEST_TOKEN}" #-H "Accept: application/json" -H "Content-Type: application/json" #-d '{"subnet": {"network_id": "abc", "ip_version": 4,"cidr": "192.168.100.0/24"}}' function _neutron_subnet_create ($neutron_endpoint, $auth_token, $network_id, $ip_version, $cidr) { @@ -51,7 +140,7 @@ function _neutron_subnet_create ($neutron_endpoint, $auth_token, $network_id, $i return $response; } -#curl -i http://ot1-contrail-int-vip:9696/v2.0/ports.json -X OP_POST -H "X-Auth-Token: ${TEST_TOKEN}" +#curl -i http://xxxxxxxxx:9696/v2.0/ports.json -X OP_POST -H "X-Auth-Token: ${TEST_TOKEN}" #-H "Accept: application/json" -H "Content-Type: application/json" #-d '{"port": {"network_id": "abc", "fixed_ips":[{"subnet_id":"abc", #"ip_address": "1.2.3.4"}], admin_state_up": true}}' @@ -81,7 +170,7 @@ function _neutron_port_create ($neutron_endpoint, $auth_token, $network_id, $por return $response; } -#curl -i -X POST http://10.31.1.123:9696/v2.0/ports.json -H "User-Agent: python-neutronclient" +#curl -i -X POST http://xxxxxxxxx:9696/v2.0/ports.json -H "User-Agent: python-neutronclient" #-H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token: 12445" #-d '{"ports": [{"name": "temp1", "admin_state_up": false, "network_id": "1233"}, #{"name": "temp2", "admin_state_up": false, "network_id": "21345"}]}' @@ -103,7 +192,7 @@ function _neutron_bulk_ports_create ($neutron_endpoint, $auth_token, $ports) { return $response; } -#curl -i -X PUT http://10.31.1.123:9696/v2.0/ports/ec20daad-4d01-464c-bb1c-242bcc150488.json -H "User-Agent: python-neutronclient" +#curl -i -X PUT http://xxxxxxxxx:9696/v2.0/ports/ec20daad-4d01-464c-bb1c-242bcc150488.json -H "User-Agent: python-neutronclient" #-H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token: TOKEN_REDACTED" #-d '{"port": {"allowed_address_pairs": [{"ip_address": "192.168.1.0/24"}]}}' function _neutron_port_update_allowed_ipaddress_pairs ($neutron_endpoint, $auth_token, $port_id, $allowed_address_pairs = array()) { @@ -126,7 +215,7 @@ function _neutron_port_update_allowed_ipaddress_pairs ($neutron_endpoint, $auth_ return $response; } -#curl -i -X PUT http://10.31.1.123:9696/v2.0/ports/ec20daad-4d01-464c-bb1c-242bcc150488.json -H "User-Agent: python-neutronclient" +#curl -i -X PUT http://xxxxxxxxx:9696/v2.0/ports/ec20daad-4d01-464c-bb1c-242bcc150488.json -H "User-Agent: python-neutronclient" #-H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token: a2e24794f42646218e01c1cb042ecde5" #-d '{"port": {"fixed_ips": [{"subnet_id" : "2f30f680-2c26-48c6-b96b-1e429646f949","ip_address":"192.168.1.20"}]}}' function _neutron_port_update_fixed_ips ($neutron_endpoint, $auth_token, $port_id, $fixed_ips) { @@ -149,7 +238,7 @@ function _neutron_port_update_fixed_ips ($neutron_endpoint, $auth_token, $port_i return $response; } -#curl -i -X PUT http://10.31.1.125:9696/v2.0/ports/15f0bd4b-aeef-415a-afaf-1ae8314533f8.json -H "User-Agent: python-neutronclient" +#curl -i -X PUT http://xxxxxxxxx:9696/v2.0/ports/15f0bd4b-aeef-415a-afaf-1ae8314533f8.json -H "User-Agent: python-neutronclient" #-H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token: TOKEN_REDACTED" -d '{"port": {"name": "mgt_port"}}' function _neutron_port_update_name ($neutron_endpoint, $auth_token, $port_id, $port_name) { @@ -171,7 +260,7 @@ function _neutron_port_update_name ($neutron_endpoint, $auth_token, $port_id, $p return $response; } -#curl -i http://10.1.144.111:9696/v2.0/ports/e9783bb4-6d72-47d5-9d4b-4042806d03ae -X DELETE +#curl -i http://xxxxxxxxx:9696/v2.0/ports/e9783bb4-6d72-47d5-9d4b-4042806d03ae -X DELETE #-H "X-Auth-Token:a116a2fdbe7949e189e4207b95285161" -H "Accept: application/json" #-H "Content-Type: application/json" function _neutron_port_delete ($neutron_endpoint, $auth_token, $port_id) { @@ -183,7 +272,7 @@ function _neutron_port_delete ($neutron_endpoint, $auth_token, $port_id) { return $response; } -#curl -g -i -X PUT http://10.31.1.13:9696/v2.0/ports/6c6e9331-0cdf-4fd0-ac48-7fcad356d800.json +#curl -g -i -X PUT http://xxxxxxxxx:9696/v2.0/ports/6c6e9331-0cdf-4fd0-ac48-7fcad356d800.json #-H "User-Agent: python-neutronclient" -H "Content-Type: application/json" -H "Accept: application/json" #-H "X-Auth-Token: {SHA1}b691726e88b30f007c535fe18214f82227480e55" #-d '{"port": {"port_security_enabled": "False", "security_groups": []}}' @@ -207,7 +296,7 @@ function _neutron_disable_port_security ($neutron_endpoint, $auth_token, $port_i return $response; } -#curl -g -i -X POST http://10.31.1.13:9696/v2.0/floatingips.json -H "User-Agent: python-neutronclient" +#curl -g -i -X POST http://xxxxxxxxx:9696/v2.0/floatingips.json -H "User-Agent: python-neutronclient" #-H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token: #{SHA1}1c28f029a9d8e72173b724404c1e04ce1cc5a473" #-d '{"floatingip": {"floating_network_id": "fa700a48-724f-470a-a4e4-eaf84ae93af2", @@ -244,7 +333,7 @@ function _neutron_floatingip_create ($neutron_endpoint, $auth_token, $network_id return $response; } -#curl -i http://ot1-contrail-int-vip:9696/v2.0/security-group-rules -X OP_POST -H "X-Auth-Token: ${TEST_TOKEN}" +#curl -i http://xxxxxxxxx:9696/v2.0/security-group-rules -X OP_POST -H "X-Auth-Token: ${TEST_TOKEN}" #-H "Accept: application/json" -H "Content-Type: application/json" #-d '{"security_group_rule":{"remote_group_id":null,"direction":"ingress", #"security_group_id":"d952ec52-2bb9-4c03-9d6e-6185e2acf0e2","ethertype":"IPv4"}}' @@ -271,7 +360,7 @@ function _neutron_security_group_rule_create ($neutron_endpoint, $auth_token, $s return $response; } -#curl -g -i -X PUT http://10.31.1.13:9696/v2.0/ports/609915ac-1925-414e-98f0-d047a37031dc.json +#curl -g -i -X PUT http://xxxxxxxxx:9696/v2.0/ports/609915ac-1925-414e-98f0-d047a37031dc.json #-H "User-Agent: python-neutronclient" -H "Content-Type: application/json" -H "Accept: application/json" #-H "X-Auth-Token: {SHA1}391fc66fe5043964a2f862e729aafefc9f01b3e7" -d #'{"port": {"security_groups": ["e25e9e23-ac8a-4706-9ee5-d7026b59d7e7"]}}' @@ -293,7 +382,7 @@ function _neutron_attach_security_groups_to_port ($neutron_endpoint, $auth_token return $response; } -#curl -g -i -X PUT http://10.31.1.13:9696/v2.0/floatingips/bec23045-e6d4-4530-bbaf-240a270f66e2.json +#curl -g -i -X PUT http://xxxxxxxxx:9696/v2.0/floatingips/bec23045-e6d4-4530-bbaf-240a270f66e2.json #-H "User-Agent: python-neutronclient" -H "Content-Type: application/json" -H "Accept: application/json" #-H "X-Auth-Token: {SHA1}96e3f409c10e636c1814ec54afdd1ad144cf7abd" #-d '{"floatingip": {"fixed_ip_address": "10.0.0.15", "port_id": "609915ac-1925-414e-98f0-d047a37031dc"}}' @@ -320,7 +409,7 @@ function _neutron_associate_floatingip_to_port ($neutron_endpoint, $auth_token, return $response; } -#curl -i -X PUT http://10.31.1.123:9696/v2.0/floatingips/b1a2147f-364a-41d5-943c-56e38326b796.json -H "User-Agent: python-neutronclient" +#curl -i -X PUT http://xxxxxxxxx:9696/v2.0/floatingips/b1a2147f-364a-41d5-943c-56e38326b796.json -H "User-Agent: python-neutronclient" #-H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token: TOKEN_REDACTED" -d '{"floatingip": {"port_id": null}}' function _neutron_disassociate_floatingip_from_port ($neutron_endpoint, $auth_token, $floatingip_id) { @@ -342,7 +431,7 @@ function _neutron_disassociate_floatingip_from_port ($neutron_endpoint, $auth_to return $response; } -#curl -g -i -X PUT http://10.31.1.13:9696/v2.0/subnets/51328b1e-b2ec-4aa6-a298-fec3d63fc651.json +#curl -g -i -X PUT http://xxxxxxxxx:9696/v2.0/subnets/51328b1e-b2ec-4aa6-a298-fec3d63fc651.json #-H "User-Agent: python-neutronclient" -H "Content-Type: application/json" -H "Accept: application/json" #-H "X-Auth-Token: {SHA1}d66bbaa920a056afe96fea6dd6061804d3b7e2cc" -d '{"subnet": {"gateway_ip": "123.0.0.254"}}' function _neutron_subnet_update_gateway_ip ($neutron_endpoint, $auth_token, $subnet_id, $gateway_ip = "") { @@ -364,7 +453,7 @@ function _neutron_subnet_update_gateway_ip ($neutron_endpoint, $auth_token, $sub return $response; } -#curl -g -i -X PUT http://10.31.1.13:9696/v2.0/routers/fa477dec-b343-4f60-a13d-0fc250d5055e/add_router_interface.json +#curl -g -i -X PUT http://xxxxxxxxx:9696/v2.0/routers/fa477dec-b343-4f60-a13d-0fc250d5055e/add_router_interface.json #-H "User-Agent: python-neutronclient" -H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token: #{SHA1}42b7493353205b58cb99edf705e8b9efc0d1d7dd" -d '{"subnet_id": "51328b1e-b2ec-4aa6-a298-fec3d63fc651"}' function _neutron_router_interface_add ($neutron_endpoint, $auth_token, $router_id, $subnet_id) { @@ -385,7 +474,7 @@ function _neutron_router_interface_add ($neutron_endpoint, $auth_token, $router_ return $response; } -#curl -g -i -X PUT http://10.31.1.13:9696/v2.0/routers/fa477dec-b343-4f60-a13d-0fc250d5055e/remove_router_interface.json +#curl -g -i -X PUT http://xxxxxxxxx:9696/v2.0/routers/fa477dec-b343-4f60-a13d-0fc250d5055e/remove_router_interface.json #-H "User-Agent: python-neutronclient" -H "Content-Type: application/json" -H "Accept: application/json" #-H "X-Auth-Token: {SHA1}2720b29fb37bcd3f1029b641b704c02a16b86abf" -d '{"subnet_id": "51328b1e-b2ec-4aa6-a298-fec3d63fc651"}' function _neutron_router_interface_delete ($neutron_endpoint, $auth_token, $router_id, $subnet_id) { @@ -406,7 +495,7 @@ function _neutron_router_interface_delete ($neutron_endpoint, $auth_token, $rout return $response; } -#curl -g -i -X PUT http://10.31.1.13:9696/v2.0/subnets/51328b1e-b2ec-4aa6-a298-fec3d63fc651.json -H "User-Agent: python-neutronclient" +#curl -g -i -X PUT http://xxxxxxxxx:9696/v2.0/subnets/51328b1e-b2ec-4aa6-a298-fec3d63fc651.json -H "User-Agent: python-neutronclient" #-H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}7c57e21b97ef05a3fb2e7bc1e4ce6001d2bda97c" #-d '{"subnet": {"allocation_pools": [{"start": "123.0.0.10", "end": "123.0.0.20"}, {"start": "123.0.0.21", "end": "123.0.0.25"}]}}' function _neutron_subnet_update_allocation_pools ($neutron_endpoint, $auth_token, $subnet_id, $allocation_pools) { @@ -454,4 +543,4 @@ function _neutron_get_public_networks($neutron_endpoint, $auth_token) { $response = prepare_json_response(ENDED, ENDED_SUCCESSFULLY, $response['wo_newparams']['response_body']); return $response; } -?> + diff --git a/Reference/OPENSTACK/Library/REST/nova_rest.php b/Reference/OPENSTACK/Library/REST/nova_rest.php index d6f460f61..5755a9e42 100755 --- a/Reference/OPENSTACK/Library/REST/nova_rest.php +++ b/Reference/OPENSTACK/Library/REST/nova_rest.php @@ -2,8 +2,8 @@ require_once '/opt/fmc_repository/Process/Reference/OPENSTACK/Library/REST/utility.php'; -#curl -i http://10.1.144.111:8774/v2/ebd239c789994f3a88d6da7083098851/flavors -X POST -#-H "X-Auth-Token:fb7317fa0c3c43949ccbe9de55dfba85" -H "Accept: application/json" -H "Content-type: application/json" +#curl -i http://xxxxx:8774/v2/ebd239c789994f3a88d6da7083098851/flavors -X POST +#-H "X-Auth-Token:yyyyy" -H "Accept: application/json" -H "Content-type: application/json" # -d '{"flavor" :{ "name":"test-flavor2","ram":1024,"vcpus":2,"disk":10,"os-flavor-access:is_public": false}}' function _nova_flavor_create ($nova_endpoint, $auth_token, $tenant_id, $ram, $vcpus, $disk, $name = "", $is_public = false) { @@ -31,13 +31,13 @@ function _nova_flavor_create ($nova_endpoint, $auth_token, $tenant_id, $ram, $vc } -#curl -i http://ct-int-vip:28774/v2/${PJID}/servers -X POST -H "X-Auth-Token: ${TEST_TOKEN}" +#curl -i http://xxxx:28774/v2/${PJID}/servers -X POST -H "X-Auth-Token: ${TEST_TOKEN}" #-H "Accept: application/json" -H "Content-Type: application/json" -d -#'{ "server": { "availability_zone": "ote-lab1","flavorRef": "120","imageRef":"6a0de364-7fef-4e02-9e6e-2b4d3bead6fd", +#'{ "server": { "availability_zone": "ote-lab1","flavorRef": "120","imageRef":"xxx", #"max_count": 1,"min_count": 1,"name": "vyatta_other_tenant_07", -#"networks":[{"uuid":"a4000cdf-835b-4ec0-942d-a456a3b4f495","port_id":"7dceafe1-ef96-4047-b717-dc354eb48ea2"}]}}' +#"networks":[{"uuid":"a4000cdf-835b-4ec0-942d-a456a3b4f495","port_id":"xxxx"}]}}' function _nova_server_create ($nova_endpoint, $auth_token, $name, $flavor, $image, - $networks, $availability_zone = "", $user_data = "", + $networks, $availability_zone = "", $user_data = "", $config_drive = "", $security_groups = array(), $min_count = 1, $max_count = 1) { $array = array(); @@ -45,12 +45,15 @@ function _nova_server_create ($nova_endpoint, $auth_token, $name, $flavor, $imag $array['flavorRef'] = $flavor; $array['imageRef'] = $image; $array['networks'] = $networks; - if ($availability_zone !== "") { + if (!empty($availability_zone)) { $array['availability_zone'] = $availability_zone; } - if ($user_data !== "") { + if (!empty($user_data)) { $array['user_data'] = $user_data; } + if (!empty($config_drive)) { + $array['config_drive'] = $config_drive; + } if (!empty($security_groups)) { $array['security_groups'] = $security_groups; } @@ -73,9 +76,9 @@ function _nova_server_create ($nova_endpoint, $auth_token, $name, $flavor, $imag return $response; } -#curl -g -i -X PUT http://10.31.1.13:8774/v2/5b57e85c3a4e4cc3ae81ea2a503e1d6e/servers/d4e139f8-2cd2-4519-9e3c-32fb6d22fadd +#curl -g -i -X PUT http://xxxx:8774/v2/ c3ae81ea2a503e1d6e/servers/ 2cd2-4519-9e3c-32fb6d22fadd #-H "User-Agent: python-novaclient" -H "Content-Type: application/json" -H "Accept: application/json" -#-H "X-Auth-Token: 1dbf7ef4000d44f98348cf828a5f4448" -d '{"server": {"name": "cirros"}}' +#-H "X-Auth-Token: xxxx" -d '{"server": {"name": "cirros"}}' function _nova_server_update_name ($nova_endpoint, $auth_token, $server_id, $server_name) { $array = array(); @@ -96,8 +99,8 @@ function _nova_server_update_name ($nova_endpoint, $auth_token, $server_id, $ser return $response; } -#curl -g -i -X DELETE http://10.31.1.13:8774/v2/689b343425824ee3a491a05d01f628e3/servers/bc7d8f1e-a479-483b-85a5-a85db9eb60a4 -#-H "User-Agent: python-novaclient" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}30ff76ffd347c2dda6389a46a9206250eeb14422" +#curl -g -i -X DELETE http://xxxx:8774/v2/689b343425824ee3a491a05d01f628e3/servers/xxxxxxxxxx0a4 +#-H "User-Agent: python-novaclient" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}xxx" function _nova_server_delete ($nova_endpoint, $auth_token, $server_id) { $openstack_rest_api = "{$nova_endpoint}/servers/{$server_id}"; @@ -107,7 +110,7 @@ function _nova_server_delete ($nova_endpoint, $auth_token, $server_id) { return $response; } -#curl -i http://ct-int-vip:28774/v2/${PJID}/servers/1234/action -X POST -H "X-Auth-Token: ${TEST_TOKEN}" +#curl -i http://xxxxxx:28774/v2/${PJID}/servers/1234/action -X POST -H "X-Auth-Token: ${TEST_TOKEN}" #-H "Accept: application/json" -H "Content-Type: application/json" -d '{"resize": {"flavorRef": "120"}}' function _nova_server_resize ($nova_endpoint, $auth_token, $server_id, $resize_flavor_id) { @@ -137,10 +140,10 @@ function _nova_server_resize_confirm ($nova_endpoint, $auth_token, $server_id) { return $response; } -#curl -g -i -X POST http://10.31.1.13:8774/v2/689b343425824ee3a491a05d01f628e3/servers/ -#43ef02a3-d596-4969-9139-09d39f1c95e5/action -H "User-Agent: python-novaclient" +#curl -g -i -X POST http://xxxxxxxxx:8774/v2/689b343425824ee3a491a05d01f628e3/servers/ +# -9139-09d39f1c95e5/action -H "User-Agent: python-novaclient" #-H "Content-Type: application/json" -H "Accept: application/json" -#-H "X-Auth-Token: {SHA1}8d1fe213446613da45441bd53596c852e00913ef" -d '{"reboot": {"type": "SOFT"}}' +#-H "X-Auth-Token: {SHA1} 45441bd53596c852e00913ef" -d '{"reboot": {"type": "SOFT"}}' function _nova_server_reboot ($nova_endpoint, $auth_token, $server_id, $type = "SOFT") { $array = array(); @@ -154,9 +157,9 @@ function _nova_server_reboot ($nova_endpoint, $auth_token, $server_id, $type = " return $response; } -#curl -i 'http://10.31.1.123:8774/v2/e470fd6ea0834192ab05c17930bee22c/servers/362b95bf-da62-4c52-b39a-547aa79b78ee/action' +#curl -i 'http://xxxxxxxx:8774/v2/e470fd6ea0834192ab05c17930bee22c/servers/-4c52-b39a-547aa79b78ee/action' # -X POST -H "Accept: application/json" -H "Content-Type: application/json" -H "User-Agent: python-novaclient" -#-H "X-Auth-Project-Id: ntt" -H "X-Auth-Token: {SHA1}eecb49db110434af8a563c44718e6d1a25e1d613" -d '{"os-start": null}' +#-H "X-Auth-Project-Id: " -H "X-Auth-Token: {SHA1}63c44718e6d1a25e1d613" -d '{"os-start": null}' function _nova_server_start ($nova_endpoint, $auth_token, $server_id) { $array = array(); @@ -181,9 +184,9 @@ function _nova_server_stop ($nova_endpoint, $auth_token, $server_id) { return $response; } -#curl -g -i -X POST http://10.31.1.13:8774/v2/fe268fd218aa42868063b7cf34855899/servers/ +#curl -g -i -X POST http://xxxxxx:8774/v2/868063b7cf34855899/servers/ #46b85ef3-caad-4749-8e72-70939fbfd086/action -H "User-Agent: python-novaclient" -H "Content-Type: application/json" -#-H "Accept: application/json" -H "X-Auth-Token: {SHA1}6bfc24a82d845208fcf652dd24622f95b5ca532d" +#-H "Accept: application/json" -H "X-Auth-Token: {SHA1}5208fcf652dd24622f95b5ca532d" #-d '{"addSecurityGroup": {"name": "secgrp_vnf_demo"}}' function _nova_add_security_group ($nova_endpoint, $auth_token, $server_id, $security_group) { @@ -198,9 +201,9 @@ function _nova_add_security_group ($nova_endpoint, $auth_token, $server_id, $sec return $response; } -#curl -g -i -X POST http://10.31.1.13:8774/v2/fe268fd218aa42868063b7cf34855899/servers/ +#curl -g -i -X POST http://xxxxxxx:8774/v2/42868063b7cf34855899/servers/ #46b85ef3-caad-4749-8e72-70939fbfd086/action -H "User-Agent: python-novaclient" -H "Content-Type: application/json" -#-H "Accept: application/json" -H "X-Auth-Token: {SHA1}33a8df4a62d6b9e3537d178e8fa43d789f48cc5a" +#-H "Accept: application/json" -H "X-Auth-Token: {SHA1}9e3537d178e8fa43d789f48cc5a" #-d '{"addFloatingIp": {"fixed_address": "192.168.2.7", "address": "10.30.19.27"}}' function _nova_floating_ip_associate ($nova_endpoint, $auth_token, $server_id, $floatingip_address, $fixed_address = "") { @@ -219,9 +222,9 @@ function _nova_floating_ip_associate ($nova_endpoint, $auth_token, $server_id, $ return $response; } -#curl -g -i -X POST http://10.31.1.13:8774/v2/fe268fd218aa42868063b7cf34855899/servers/ +#curl -g -i -X POST http://xxxxxxxxx:8774/v2/8aa42868063b7cf34855899/servers/ #46b85ef3-caad-4749-8e72-70939fbfd086/action -H "User-Agent: python-novaclient" -H "Content-Type: application/json" -#-H "Accept: application/json" -H "X-Auth-Token: {SHA1}df2bf9bb8cd667d0eee6f4e2cd8addbd79446a7c" +#-H "Accept: application/json" -H "X-Auth-Token: {SHA1}667d0eee6f4e2cd8addbd79446a7c" #-d '{"removeFloatingIp": {"address": "10.30.19.27"}}' function _nova_floating_ip_disassociate ($nova_endpoint, $auth_token, $server_id, $floatingip_address) { @@ -236,11 +239,11 @@ function _nova_floating_ip_disassociate ($nova_endpoint, $auth_token, $server_id return $response; } -#curl -i http://ct-int-vip:28774/v2/${PJID}/servers/${SVID}/os-interface -X POST -H "X-Auth-Token: ${TEST_TOKEN}" +#curl -i http://xxxxxxxxx:28774/v2/${PJID}/servers/${SVID}/os-interface -X POST -H "X-Auth-Token: ${TEST_TOKEN}" #-H "Accept: application/json" -H "Content-Type: application/json" -d '{"interfaceAttachment":{"port_id":"1234"}}' -#curl -i http://ct-int-vip:28774/v2/${PJID}/servers/${SVID}/os-interface -X POST -H "X-Auth-Token: ${TEST_TOKEN}" +#curl -i http://xxxxxxxxx:28774/v2/${PJID}/servers/${SVID}/os-interface -X POST -H "X-Auth-Token: ${TEST_TOKEN}" #-H "Accept: application/json" -H "Content-Type: application/json" -d -#'{"interfaceAttachment":{"net_id":"3b49fd97-caab-40ef-9fa6-4073d1639e7c","fixed_ips":[{"ip_address":"192.168.101.2"}]}}' +#'{"interfaceAttachment":{"net_id":"ef-9fa6-4073d1639e7c","fixed_ips":[{"ip_address":"192.168.101.2"}]}}' function _nova_interface_attach ($nova_endpoint, $auth_token, $server_id, $port_id = "", $network_id = "", $fixed_ips = array()) { @@ -269,7 +272,7 @@ function _nova_interface_attach ($nova_endpoint, $auth_token, $server_id, $port_ return $response; } -#curl -i http://ct-int-vip:28774/v2/${PJID}/servers/${SVID}/os-interface/12345 -X DELETE -H "X-Auth-Token: +#curl -i http://xxxxxxxxx:28774/v2/${PJID}/servers/${SVID}/os-interface/12345 -X DELETE -H "X-Auth-Token: #${TEST_TOKEN}" -H "Accept: application/json" -H "Content-Type: application/json" function _nova_interface_detach ($nova_endpoint, $auth_token, $server_id, $port_id) { @@ -280,9 +283,9 @@ function _nova_interface_detach ($nova_endpoint, $auth_token, $server_id, $port_ return $response; } -#curl -i 'http://10.31.1.125:8774/v2/5fd116d488644b84bd57fca22fb02587/servers/44916e9c-5f3e-4e2b-ae89-48f7b5c2d821/action' -X POST -#-H "Accept: application/json" -H "Content-Type: application/json" -H "User-Agent: python-novaclient" -H "X-Auth-Project-Id: NTTCom" -#-H "X-Auth-Token: {SHA1}d4563d73b930b0e7bd37c17ab078887da0a64dd4" -d '{"os-getVNCConsole": {"type": "novnc"}}' +#curl -i 'http://xxxxxxxxx:8774/v2/6d488644b84bd57fca22fb02587/servers/f3e-4e2b-ae89-48f7b5c2d821/action' -X POST +#-H "Accept: application/json" -H "Content-Type: application/json" -H "User-Agent: python-novaclient" -H "X-Auth-Project-Id: " +#-H "X-Auth-Token: {SHA1}930b0e7bd37c17ab078887da0a64dd4" -d '{"os-getVNCConsole": {"type": "novnc"}}' # Type of vnc console ("novnc" or "xvpvnc"). function _nova_get_vnc_console ($nova_endpoint, $auth_token, $server_id, $console_type) { @@ -303,10 +306,10 @@ function _nova_get_vnc_console ($nova_endpoint, $auth_token, $server_id, $consol return $response; } -#curl -i -k https://10.1.144.116/v2/abcd/servers/abcd/os-volume_attachments -X POST +#curl -i -k https://xxxxxxxxxv2/abcd/servers/abcd/os-volume_attachments -X POST #-H "X-Auth-Token:42946664fc6e41e392bb7ee51a9160b9" -H "Accept: application/json" #-H "Content-Type: application/json" -#-d '{"volumeAttachment":{"volumeId":"b009c52c-97bd-4da4-916c-b2d4c90a85f4"}}' +#-d '{"volumeAttachment":{"volumeId":"d-4da4-916c-b2d4c90a85f4"}}' function _nova_volume_attach ($nova_endpoint, $auth_token, $server_id, $volume_id, $device = null) { $array = array(); @@ -327,7 +330,7 @@ function _nova_volume_attach ($nova_endpoint, $auth_token, $server_id, $volume_i return $response; } -#curl -i -k https://10.1.144.116/v2/abcd/servers/abcd/os-volume_attachments/sdasd -X DELETE +#curl -i -k https://xxxxxxxxxv2/abcd/servers/abcd/os-volume_attachments/sdasd -X DELETE #-H "X-Auth-Token:f16eb9820b4941879379e166e93e27c7" -H "Accept: application/json" #-H "Content-Type: application/json" function _nova_volume_detach ($nova_endpoint, $auth_token, $server_id, $volume_id) { @@ -339,4 +342,122 @@ function _nova_volume_detach ($nova_endpoint, $auth_token, $server_id, $volume_i return $response; } -?> \ No newline at end of file +/** +* VNF Live migration from hostA to hostX of the Openstack VIM. +* +* curl --tlsv1.2 -i -sw 'HTTP_CODE=%{http_code}' --connect-timeout 50 --max-time 50 -X POST -H "X-Auth-Token: gAAAAABdel44SS-FrqBKUdIEthbnsIH-R9cXfO307WcU3bz47fjJw1rxqLdaN4P08uw9U9P1UcB-9Qg-NAk3_FvmXD71tHmyyWYje-m2D1GFxF5WtuGZ3S0n7TsbkeIBLOoJt6bUQ45O0X9qrq9CAJtBWBoDr-SvKMrIup0nAOvlt0e09h_UINo" -H "Content-Type: application/json" -k 'http://xxxxxxxxx:8774/v2.1/df1f081bf2d345099e6bb53f6b9407ff/servers/22b555e1-2fe2-45d6-ace1-e5cad4d34db5/action' -d '{ + "os-migrateLive": { + "host": "openstack2.ubiqube.com", + "block_migration": "false", + "disk_over_commit": false + } +}' +**/ +function _nova_os_migration_live($nova_endpoint, $auth_token, $server_id, $host, $block_migration = "false", $disk_over_commit = "false") +{ + $array = array(); + $array['host'] = $host; + $array['block_migration'] = $block_migration; + $array['disk_over_commit'] = $disk_over_commit; + $os_migrate_live_array = array( + 'os-migrateLive' => $array + ); + $json = json_encode($os_migrate_live_array); + + $openstack_rest_api = "{$nova_endpoint}/servers/{$server_id}/action"; + $curl_cmd = create_openstack_operation_request(OP_POST, $openstack_rest_api, $auth_token, $json); + $response = perform_curl_operation($curl_cmd, "SERVER LIVE MIGRATION"); + $response = json_decode($response, true); + if ($response['wo_status'] !== ENDED) { + return json_encode($response); + } + return prepare_json_response(ENDED, ENDED_SUCCESSFULLY, $response); +} + +/* + * { + * "evacuate": { + * "host": "b419863b7d814906a68fb31703c0dbd6", + * "adminPass": "MySecretPass", + * "onSharedStorage": "False" + * } + * } + */ +function _nova_os_evacuate($nova_endpoint, $auth_token, $server_id, $host) +{ + $array = array(); + $array['onSharedStorage'] = "False"; + $os_evacuate_array = array( + 'evacuate' => $array + ); + $json = json_encode($os_evacuate_array); + + $openstack_rest_api = "{$nova_endpoint}/servers/{$server_id}/action"; + $curl_cmd = create_openstack_operation_request(OP_POST, $openstack_rest_api, $auth_token, $json); + $response = perform_curl_operation($curl_cmd, "SERVER EVACUATE"); + $response = json_decode($response, true); + if ($response['wo_status'] !== ENDED) { + return json_encode($response); + } + + return prepare_json_response(ENDED, ENDED_SUCCESSFULLY, $response); +} + + +/** +* GET VIM hosts list (hypervisors). +* +* curl --tlsv1.2 -i -sw 'HTTP_CODE=%{http_code}' --connect-timeout 50 --max-time 50 -X GET -H "X-Auth-Token: gAAAAABdel44SS-FrqBKUdIEthbnsIH-R9cXfO307WcU3bz47fjJw1rxqLdaN4P08uw9U9P1UcB-9Qg-NAk3_FvmXD71tHmyyWYje-m2D1GFxF5WtuGZ3S0n7TsbkeIBLOoJt6bUQ45O0X9qrq9CAJtBWBoDr-SvKMrIup0nAOvlt0e09h_UINo" -H "Content-Type: application/json" -k 'http://xxxxxxxxx:8774/v2.1/os-hypervisors' +* +**/ +function _nova_os_hypervisors($nova_endpoint, $auth_token) +{ + $openstack_rest_api = "{$nova_endpoint}/os-hypervisors"; + $curl_cmd = create_openstack_operation_request(OP_GET, $openstack_rest_api, $auth_token); + $response = perform_curl_operation($curl_cmd, "GET OS HYPERVISORS"); + $response = json_decode($response, true); + if ($response['wo_status'] !== ENDED) { + return json_encode($response); + } + return prepare_json_response(ENDED, ENDED_SUCCESSFULLY, $response['wo_newparams']['response_body']); +} + + + /** +* GET VIM hosts list (hypervisors). +* +* curl --tlsv1.2 -i -sw 'HTTP_CODE=%{http_code}' --connect-timeout 50 --max-time 50 -X GET -H "X-Auth-Token: gAAAAABdel44SS-FrqBKUdIEthbnsIH-R9cXfO307WcU3bz47fjJw1rxqLdaN4P08uw9U9P1UcB-9Qg-NAk3_FvmXD71tHmyyWYje-m2D1GFxF5WtuGZ3S0n7TsbkeIBLOoJt6bUQ45O0X9qrq9CAJtBWBoDr-SvKMrIup0nAOvlt0e09h_UINo" -H "Content-Type: application/json" -k 'http://xxxxxxxxx:8774/v2.1/os-hypervisors' +* +**/ +function _nova_os_hypervisors_list_detail($nova_endpoint, $auth_token) +{ + $openstack_rest_api = "{$nova_endpoint}/os-hypervisors/detail"; + $curl_cmd = create_openstack_operation_request(OP_GET, $openstack_rest_api, $auth_token); + $response = perform_curl_operation($curl_cmd, "GET OS HYPERVISORS DETAIL"); + $response = json_decode($response, true); + if ($response['wo_status'] !== ENDED) { + return json_encode($response); + } + return prepare_json_response(ENDED, ENDED_SUCCESSFULLY, $response['wo_newparams']['response_body']); +} + + +/** +* GET VIM host details by ID. +* +* curl --tlsv1.2 -i -sw 'HTTP_CODE=%{http_code}' --connect-timeout 50 --max-time 50 -X GET -H "X-Auth-Token: gAAAAABdel44SS-FrqBKUdIEthbnsIH-R9cXfO307WcU3bz47fjJw1rxqLdaN4P08uw9U9P1UcB-9Qg-NAk3_FvmXD71tHmyyWYje-m2D1GFxF5WtuGZ3S0n7TsbkeIBLOoJt6bUQ45O0X9qrq9CAJtBWBoDr-SvKMrIup0nAOvlt0e09h_UINo" -H "Content-Type: application/json" -k 'http://xxxxxxxxx:8774/v2.1/os-hypervisors/8' +* +**/ +function _nova_os_hypervisor_details_by_id($nova_endpoint, $auth_token, $hypervisor_id) +{ + $openstack_rest_api = "{$nova_endpoint}/os-hypervisors/{$hypervisor_id}"; + $curl_cmd = create_openstack_operation_request(OP_GET, $openstack_rest_api, $auth_token); + $response = perform_curl_operation($curl_cmd, "GET OS HYPERVISORS DETAILS"); + $response = json_decode($response, true); + if ($response['wo_status'] !== ENDED) { + return json_encode($response); + } + return prepare_json_response(ENDED, ENDED_SUCCESSFULLY, $response['wo_newparams']); +} + + diff --git a/Reference/OPENSTACK/Library/REST/openstack_common_rest.php b/Reference/OPENSTACK/Library/REST/openstack_common_rest.php index 534b6635e..77c935260 100755 --- a/Reference/OPENSTACK/Library/REST/openstack_common_rest.php +++ b/Reference/OPENSTACK/Library/REST/openstack_common_rest.php @@ -4,8 +4,9 @@ require_once '/opt/fmc_repository/Process/Reference/OPENSTACK/Library/REST/cinder_rest.php'; require_once '/opt/fmc_repository/Process/Reference/OPENSTACK/Library/REST/neutron_rest.php'; require_once '/opt/fmc_repository/Process/Reference/OPENSTACK/Library/REST/keystone_rest.php'; +require_once '/opt/fmc_repository/Process/Reference/OPENSTACK/Library/REST/glance_rest.php'; -#curl -i http://ot1-contrail-int-vip:9696/v2.0/subnets.json -X GET -H "X-Auth-Token: ${TEST_TOKEN}" +#curl -i http://xxxxxxxxx:9696/v2.0/subnets.json -X GET -H "X-Auth-Token: ${TEST_TOKEN}" #-H "Accept: application/json" -H "Content-Type: application/json" function object_get ($object_name, $auth_token, $openstack_rest_api) { @@ -20,7 +21,7 @@ function object_get ($object_name, $auth_token, $openstack_rest_api) { return $response; } -#curl -i http://ot1-contrail-int-vip:9696/v2.0/networks/12345 -X DELETE -H "X-Auth-Token: +#curl -i http://xxxxxxxxx:9696/v2.0/networks/12345 -X DELETE -H "X-Auth-Token: #${TEST_TOKEN}" -H "Accept: application/json" -H "Content-Type: application/json" function object_delete ($object_name, $auth_token, $openstack_rest_api) { @@ -97,10 +98,18 @@ function wait_for_server_status ($nova_endpoint, $auth_token, $server_id, $statu } if ($server_status === ERROR) { logToFile("SERVER CREATION/ACTION FAILED."); - $message = $response['fault']['message']; - $code = $response['fault']['code']; - $details = $response['fault']['details']; - $wo_comment = "Server Status : $server_status\nMessage : $message\nCODE : $code\nDetails: $details"; + if (isset($response['fault']) && is_array($response['fault']) && isset($response['fault']['message']) && isset($response['fault']['code'])){ + $message = $response['fault']['message']; + $code = $response['fault']['code']; + if (isset($response['fault']['details']) && !empty($response['fault']['details'])) { + $details = $response['fault']['details']; + } else { + $details = ''; + } + $wo_comment = "Server Status : $server_status\nMessage : $message\nCODE : $code\nDetails: $details"; + }else{ + $wo_comment = "Server Status : $server_status"; + } $response = prepare_json_response(FAILED, $wo_comment, $wo_newparams, true); return $response; } @@ -489,7 +498,7 @@ function get_server_interface_details ($auth_token, $nova_endpoint, $neutron_end return $response; } -#curl -g -i -X GET http://10.31.1.13:9696/v2.0/ports.json?device_id=fa477dec-b343-4f60-a13d-0fc250d5055e +#curl -g -i -X GET http://xxxxxxxxx:9696/v2.0/ports.json?device_id=fa477dec-b343-4f60-a13d-0fc250d5055e #-H "User-Agent: python-neutronclient" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}74ae9bf825ea9d16061f66518d0b9effa78f0785" function router_interface_list ($neutron_endpoint, $auth_token, $router_id) { @@ -570,6 +579,17 @@ function get_port_id_from_subnet_and_ip_address ($auth_token, $neutron_endpoint, return $response; } +/** +* +* GET subnet ids from network. +* +* +*/ +function get_subnet_ids_from_network($auth_token, $neutron_endpoint, $network) +{ + $response = object_get("networks", $auth_token, "{$neutron_endpoint}/v2.0/networks/{$network}"); + return json_decode($response, true); +} /** * Get Subnet details from network and IP address * @@ -781,11 +801,11 @@ function remove_all_router_interfaces ($auth_token, $neutron_endpoint, $router) $index = 0; foreach ($router_interfaces as $router_interface) { - $device_owner = $router_interfaces['device_owner']; + $device_owner = $router_interface['device_owner']; $device_id = $router_interface['device_id']; if ($device_owner === "network:router_interface" && $device_id === $router) { - $response = _neutron_router_interface_delete($neutron_endpoint, $auth_token, $router, $subnet_id); $subnet_id = $router_interface['fixed_ips'][0]['subnet_id']; + _neutron_router_interface_delete($neutron_endpoint, $auth_token, $router, $subnet_id); $router_interface_subnets[$index]['subnet_id'] = $subnet_id; $ip_address = $router_interface['fixed_ips'][0]['ip_address']; $subnet_gateway_ips[$index++]['ip_address'] = $ip_address; @@ -813,7 +833,7 @@ function _list_stacks_resources ($stacks_endpoint, $auth_token, $stack_name, $st return $response; } -#curl -i http://ct-int-vip:28774/v2/${PJID}/servers/${server_id} -X GET -H "X-Auth-Token: +#curl -i http://xxxxxxxxx:28774/v2/${PJID}/servers/${server_id} -X GET -H "X-Auth-Token: #${TEST_TOKEN}" -H "Accept: application/json" -H "Content-Type: application/json" function _nova_get_server_details ($nova_endpoint, $auth_token, $server_id) { @@ -824,4 +844,27 @@ function _nova_get_server_details ($nova_endpoint, $auth_token, $server_id) { return $response; } +#curl -i http://xxxxxxxxx:28774/v2/${PJID}/flavors/${flavor_id} -X GET -H "X-Auth-Token: +#${TEST_TOKEN}" -H "Accept: application/json" -H "Content-Type: application/json" +function _nova_get_flavor_details ($nova_endpoint, $auth_token, $flavor_id) { + + $openstack_rest_api = "{$nova_endpoint}/flavors/{$flavor_id}"; + $curl_cmd = create_openstack_operation_request(OP_GET, $openstack_rest_api, $auth_token); + + $response = perform_curl_operation($curl_cmd, "FLAVOR GET DETAILS"); + return $response; +} + + +#curl -i http://xxxxxxxxx:28774/v2/${PJID}/flavors/detail -X GET -H "X-Auth-Token: +#${TEST_TOKEN}" -H "Accept: application/json" -H "Content-Type: application/json" +function _nova_get_flavors_with_details ($nova_endpoint, $auth_token) { + + $openstack_rest_api = "{$nova_endpoint}/flavors/detail"; + $curl_cmd = create_openstack_operation_request(OP_GET, $openstack_rest_api, $auth_token); + + $response = perform_curl_operation($curl_cmd, "FLAVORS GET LIST WITH DETAILS"); + return $response; +} + ?> diff --git a/Reference/OPENSTACK/Library/REST/orchestration_rest.php b/Reference/OPENSTACK/Library/REST/orchestration_rest.php index 2c08128f3..9e88d5227 100755 --- a/Reference/OPENSTACK/Library/REST/orchestration_rest.php +++ b/Reference/OPENSTACK/Library/REST/orchestration_rest.php @@ -1,22 +1,19 @@ - + diff --git a/Reference/OPENSTACK/Library/REST/utility.php b/Reference/OPENSTACK/Library/REST/utility.php index d8ee6d568..68b3e39f8 100755 --- a/Reference/OPENSTACK/Library/REST/utility.php +++ b/Reference/OPENSTACK/Library/REST/utility.php @@ -13,19 +13,53 @@ * @return string */ function create_openstack_operation_request ($operation, $openstack_rest_api, $auth_token = "", $json_body = "", - $connection_timeout = 60, $max_time = 60) { + $connection_timeout = OS_CURL_CONNECTION_TIMEOUT, $max_time = OS_CURL_MAX_TIME) { global $CURL_CMD; global $CURL_OPENSTACK; - // curl -i http://ct-int-vip:28774/v2/${PJID}/servers -X POST -H "X-Auth-Token: ${TEST_TOKEN}" -H "Accept: application/json" -H "Content-Type: application/json" -d '{ "server": { "availability_zone": "ote-lab1","flavorRef": "120","imageRef":"0f0ba35a-1445-497f-8630-c8a1d0b97a87","max_count": 1,"min_count": 1,"name": "vyatta_other_tenant_03","networks":[{"uuid":"a4000cdf-835b-4ec0-942d-a456a3b4f495","port_id":"7dceafe1-ef96-4047-b717-dc354eb48ea2"},{"uuid":"3b49fd97-caab-40ef-9fa6-4073d1639e7c","port_id":"7dceafe1-ef96-4047-b717-dc354eb48ea2"}]}}' - $curl_cmd = "{$CURL_CMD} {$CURL_OPENSTACK} -i -sw '\nHTTP_CODE=%{http_code}' --connect-timeout $connection_timeout --max-time $max_time -k '{$openstack_rest_api}' -X {$operation} -H \"Accept: application/json\" -H \"Content-Type: application/json\""; + global $OS_CURL_VERBOSE; + global $OS_CURL_RETRY_COUNT; + global $OS_CURL_RETRY_DELAY; + global $OS_CURL_RETRY_MAX_TIME; + global $context; + + // curl -i http://xxxxxx:28774/v2/${PJID}/servers -X POST -H "X-Auth-Token: ${TEST_TOKEN}" -H "Accept: application/json" -H "Content-Type: application/json" -d '{ "server": { "availability_zone": "ote-lab1","flavorRef": "120","imageRef":"0f0ba35a-1445-497f-8630-c8a1d0b97a87","max_count": 1,"min_count": 1,"name": "vyatta_other_tenant_03","networks":[{"uuid":"a4000cdf-835b-4ec0-942d-a456a3b4f495","port_id":"7dceafe1-ef96-4047-b717-dc354eb48ea2"},{"uuid":"3b49fd97-caab-40ef-9fa6-4073d1639e7c","port_id":"7dceafe1-ef96-4047-b717-dc354eb48ea2"}]}}' +// /usr/bin/curl --tlsv1.2 -i -sw ' + + $curl_cmd = "{$CURL_CMD} {$CURL_OPENSTACK} -i -sw '\nHTTP_CODE=%{http_code}' {$OS_CURL_VERBOSE} --connect-timeout $connection_timeout --max-time $max_time {$OS_CURL_RETRY_COUNT} {$OS_CURL_RETRY_DELAY} {$OS_CURL_RETRY_MAX_TIME} -k '{$openstack_rest_api}' -X {$operation} -H \"Accept: application/json\" -H \"Content-Type: application/json\""; if ($auth_token !== "") { + //We can check if the Auth-Token(token_id) has expired + if (isset($context['token_id']) && isset($context['keystone_admin_endpoint']) && isset($context['user_domain_id']) && isset($context['admin_username']) && isset($context['admin_password']) && isset($context['project_domain_id']) && isset($context['admin_tenant_id']) ){ + if (! isset($context['token_id_expire']) || (isset($context['token_id_expire']) && $context['token_id_expire'] < time()) ) { + //We should get a new token_id + $response = _keystone_project_scoped_token_get($context['keystone_admin_endpoint'], $context['user_domain_id'], $context['admin_username'], + $context['admin_password'], $context['project_domain_id'], $context['admin_tenant_id']); + $response = json_decode($response, true); + if ($response['wo_status'] !== ENDED) { + $response = prepare_json_response(FAILED, $response['wo_comment'], $context, true); + echo $response; + exit; + } + + $response_raw_headers = $response['wo_newparams']['response_raw_headers']; + $response_headers = http_parse_headers($response_raw_headers); + $context['token_id'] = $response_headers[X_SUBJECT_TOKEN]; + $context['token_id_expire'] = time() + OPENSTACK_TOKEN_ID_EXPIRE_SEC; // expire in OPENSTACK_TOKEN_ID_EXPIRE_SEC secondes + $auth_token = $context['token_id']; + logToFile(__FILE__ . ' Get new token successfull, expire in '.OPENSTACK_TOKEN_ID_EXPIRE_SEC.' secondes'); + }else{ + logToFile(__FILE__ . ' Token not expired'); + } + }else{ + logToFile(__FILE__ . ' Can not check token_id expire date because missing datas, exist keystone_admin_endpoint='. isset($context['keystone_admin_endpoint']).', exist user_domain_id='.isset($context['user_domain_id']).', exist admin_username='.isset($context['admin_username']).', exist admin_password='.isset($context['admin_password']).', exist project_domain_id='.isset($context['project_domain_id']).', exist admin_tenant_id='.isset($context['admin_tenant_id'])); + } $curl_cmd .= " -H \"X-Auth-Token: {$auth_token}\""; } if ($json_body !== "") { $curl_cmd .= " -d '" . pretty_print_json($json_body) . "'"; } logToFile("Curl Request : $curl_cmd\n"); + // Curl Request : /usr/bin/curl --tlsv1.2 -i -sw 'HTTP_CODE=%{http_code}' -v --connect-timeout 120 --max-time 120 --retry 3 --retry-delay 10 --retry-max-time 180 -k 'https://xxxxxx/v2.0/ports/84f29670-e90b-43b7-9051-2d595b71efe8' -X DELETE -H "Accept: application/json" -H "Content-Type: application/json" -H "X-Auth-Token: 9cb83397749145c0b1543e0..." return $curl_cmd; } diff --git a/Reference/OPENSTACK/Library/constants.php b/Reference/OPENSTACK/Library/constants.php index 3b9093e16..2464e92fb 100755 --- a/Reference/OPENSTACK/Library/constants.php +++ b/Reference/OPENSTACK/Library/constants.php @@ -1,4 +1,13 @@ + diff --git a/Reference/OPENSTACK/Tasks/OBMF/Neutron/Task_openstack_get_available_floating_ip.php b/Reference/OPENSTACK/Tasks/OBMF/Neutron/Task_openstack_get_available_floating_ip.php index f73951e20..0b1fc853f 100755 --- a/Reference/OPENSTACK/Tasks/OBMF/Neutron/Task_openstack_get_available_floating_ip.php +++ b/Reference/OPENSTACK/Tasks/OBMF/Neutron/Task_openstack_get_available_floating_ip.php @@ -14,8 +14,7 @@ function list_args() check_mandatory_param('floating_ip_network'); check_mandatory_param('tenant'); -$openstack_device_id = $context['openstack_device_id']; -$openstack_device_id = preg_replace('/\D/', '', $openstack_device_id); +$openstack_device_id = substr($context['openstack_device_id'], 3); $floating_ip_network = $context['floating_ip_network']; $floating_ip_tenant = $context['tenant']; diff --git a/Reference/OPENSTACK/Tasks/REST/Keystone/Task_openstack_keystone_v2_token_get.php b/Reference/OPENSTACK/Tasks/REST/Keystone/Task_openstack_keystone_v2_token_get.php index 5bf710601..af460cb3f 100755 --- a/Reference/OPENSTACK/Tasks/REST/Keystone/Task_openstack_keystone_v2_token_get.php +++ b/Reference/OPENSTACK/Tasks/REST/Keystone/Task_openstack_keystone_v2_token_get.php @@ -32,6 +32,7 @@ function list_args() $token_id = $response['wo_newparams']['access']['token']['id']; $endpoints = $response['wo_newparams']['access']['serviceCatalog']; $context['token_id'] = $token_id; +$context['token_id_expire'] = time() + OPENSTACK_TOKEN_ID_EXPIRE_SEC; // expire in 5 minutes $context['endpoints'] = seperate_endpoints_v2($endpoints); $response = prepare_json_response(ENDED, "Token created successfully.\nToken Id : $token_id", $context, true); echo $response; diff --git a/Reference/OPENSTACK/Tasks/REST/Keystone/Task_openstack_project_scoped_token_get.php b/Reference/OPENSTACK/Tasks/REST/Keystone/Task_openstack_project_scoped_token_get.php index 1072acc81..01c00c342 100755 --- a/Reference/OPENSTACK/Tasks/REST/Keystone/Task_openstack_project_scoped_token_get.php +++ b/Reference/OPENSTACK/Tasks/REST/Keystone/Task_openstack_project_scoped_token_get.php @@ -7,15 +7,22 @@ function list_args() { } +check_mandatory_param('user_domain_id'); +check_mandatory_param('admin_username'); +check_mandatory_param('admin_password'); +check_mandatory_param('project_domain_id'); +check_mandatory_param('tenant_id'); +check_mandatory_param('keystone_public_endpoint'); + $user_domain_id = $context['user_domain_id']; -$username = $context['tenant_login']; -$password = $context['tenant_password']; +$admin_username = $context['admin_username']; +$admin_password = $context['admin_password']; $project_domain_id = $context['project_domain_id']; $openstack_tenant_id = $context['tenant_id']; -$keystone_endpoint = $context['keystone_public_endpoint']; +$keystone_public_endpoint = $context['keystone_public_endpoint']; -$response = _keystone_project_scoped_token_get($keystone_endpoint, $user_domain_id, $username, - $password, $project_domain_id, $openstack_tenant_id); +$response = _keystone_project_scoped_token_get($keystone_public_endpoint, $user_domain_id, $admin_username, + $admin_password, $project_domain_id, $openstack_tenant_id); $response = json_decode($response, true); if ($response['wo_status'] !== ENDED) { $response = json_encode($response); @@ -27,10 +34,9 @@ function list_args() $response_headers = http_parse_headers($response_raw_headers); $token_id = $response_headers[X_SUBJECT_TOKEN]; $context['token_id'] = $token_id; +$context['token_id_expire'] = time() + OPENSTACK_TOKEN_ID_EXPIRE_SEC; // expire in 5 minutes -$response_body_json = $response['wo_newparams']['response_body']; -$response_body = json_decode($response_body_json, true); -$endpoints = $response_body['token']['catalog']; +$endpoints = $response['wo_newparams']['response_body']['token']['catalog']; $context['endpoints'] = seperate_endpoints_v3($endpoints); $response = prepare_json_response(ENDED, "Token created successfully.\nToken Id : $token_id", $context, true); echo $response; diff --git a/Reference/OPENSTACK/Tasks/REST/Nova/Task_openstack_server_stop.php b/Reference/OPENSTACK/Tasks/REST/Nova/Task_openstack_server_stop.php index 0d034863f..913c0980e 100755 --- a/Reference/OPENSTACK/Tasks/REST/Nova/Task_openstack_server_stop.php +++ b/Reference/OPENSTACK/Tasks/REST/Nova/Task_openstack_server_stop.php @@ -1,44 +1,45 @@ $PROCESSINSTANCEID, - 'EXECNUMBER' => $EXECNUMBER, - 'TASKID' => $TASKID); +$process_params = array( + 'PROCESSINSTANCEID' => $PROCESSINSTANCEID, + 'EXECNUMBER' => $EXECNUMBER, + 'TASKID' => $TASKID +); $server_id = $context['server_id']; $token_id = $context['token_id']; $endpoints = $context['endpoints']; - + $nova_endpoint = $endpoints[NOVA]['endpoints'][0][ADMIN_URL]; $response = _nova_server_stop($nova_endpoint, $token_id, $server_id); $response = json_decode($response, true); if ($response['wo_status'] !== ENDED) { $response = json_encode($response); echo $response; - exit; + exit(); } - + $response = wait_for_server_status($nova_endpoint, $token_id, $server_id, SHUTOFF, $process_params); $response = json_decode($response, true); if ($response['wo_status'] !== ENDED) { $response = json_encode($response); echo $response; - exit; + exit(); } $server_status_comment = $response['wo_comment']; $response = prepare_json_response(ENDED, "Openstack Server $server_id stopped successfully.\n$server_status_comment", $context, true); echo $response; -?> + diff --git a/Reference/PALOALTO/.meta_Library b/Reference/PALOALTO/.meta_Library new file mode 100644 index 000000000..80c8946fe --- /dev/null +++ b/Reference/PALOALTO/.meta_Library @@ -0,0 +1,39 @@ + + + + + MODEL + + + DATE_MODIFICATION + 1445429309400 + + + COMMENT + + + + REPOSITORY + Process + + + DATE_CREATION + 1445429309382 + + + MANUFACTURER + + + CONFIGURATION_FILTER + + + + TYPE + DIRECTORY + + + TAG + + + + diff --git a/Reference/PALOALTO/.meta_Tasks b/Reference/PALOALTO/.meta_Tasks new file mode 100644 index 000000000..80c8946fe --- /dev/null +++ b/Reference/PALOALTO/.meta_Tasks @@ -0,0 +1,39 @@ + + + + + MODEL + + + DATE_MODIFICATION + 1445429309400 + + + COMMENT + + + + REPOSITORY + Process + + + DATE_CREATION + 1445429309382 + + + MANUFACTURER + + + CONFIGURATION_FILTER + + + + TYPE + DIRECTORY + + + TAG + + + + diff --git a/Reference/PALOALTO/Library/.meta_constants.php b/Reference/PALOALTO/Library/.meta_constants.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/PALOALTO/Library/.meta_constants.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/PALOALTO/Library/.meta_paloalto_generic_common.php b/Reference/PALOALTO/Library/.meta_paloalto_generic_common.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/PALOALTO/Library/.meta_paloalto_generic_common.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/PALOALTO/Library/.meta_paloalto_generic_obmf.php b/Reference/PALOALTO/Library/.meta_paloalto_generic_obmf.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/PALOALTO/Library/.meta_paloalto_generic_obmf.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/PALOALTO/Library/constants.php b/Reference/PALOALTO/Library/constants.php new file mode 100644 index 000000000..21150000b --- /dev/null +++ b/Reference/PALOALTO/Library/constants.php @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/Reference/PALOALTO/Library/paloalto_generic_common.php b/Reference/PALOALTO/Library/paloalto_generic_common.php new file mode 100644 index 000000000..cbcd12579 --- /dev/null +++ b/Reference/PALOALTO/Library/paloalto_generic_common.php @@ -0,0 +1,48 @@ + \ No newline at end of file diff --git a/Reference/PALOALTO/Library/paloalto_generic_obmf.php b/Reference/PALOALTO/Library/paloalto_generic_obmf.php new file mode 100644 index 000000000..6ab773b73 --- /dev/null +++ b/Reference/PALOALTO/Library/paloalto_generic_obmf.php @@ -0,0 +1,315 @@ + + array($profile_name => + array('decoder' => $decoder, + 'packet_capture' => $packet_capture, + 'description' => $description + ) + ) + ); + $response = execute_command_and_verify_response($device_id, $command_name, $array, "CREATE ANTI-VIRUS USER PROFILE", 180, 180); + return $response; +} +function _paloalto_generic_url_filtering_user_profile ($device_id, $command_name, $profile_name, + $license_expired = "", $enable_container_page = "no", + $dynamic_url = "no", $log_container_page_only = "yes", + $alert = array(), $allow = array(), $block = array(), + $continue = array(), $override = array(), + $allow_list = array(), $block_list = array(), + $action = "block", $description = "") { + + $url_filterting_user_profile_array = array(); + $url_filterting_user_profile_array['licence_expired'] = $license_expired; + $url_filterting_user_profile_array['enable_container_page'] = $enable_container_page; + $url_filterting_user_profile_array['log_container_page_only'] = $log_container_page_only; + $url_filterting_user_profile_array['dynamic_url'] = $dynamic_url; + $url_filterting_user_profile_array['action'] = $action; + $url_filterting_user_profile_array['description'] = $description; + if (!empty($alert)) { + $url_filterting_user_profile_array['alert'] = $alert; + } + if (!empty($allow)) { + $url_filterting_user_profile_array['allow'] = $allow; + } + if (!empty($block)) { + $url_filterting_user_profile_array['block'] = $block; + } + if (!empty($continue)) { + $url_filterting_user_profile_array['continue'] = $continue; + } + if (!empty($override)) { + $url_filterting_user_profile_array['override'] = $override; + } + if (!empty($allow_list)) { + $url_filterting_user_profile_array['allow_list'] = $allow_list; + } + if (!empty($block_list)) { + $url_filterting_user_profile_array['block_list'] = $block_list; + } + + $array = array('urlf_user_profile' => + array($profile_name => $url_filterting_user_profile_array + ) + ); + $response = execute_command_and_verify_response($device_id, $command_name, $array, "CREATE URL-FILTERING USER PROFILE", 180, 180); + return $response; +} +function _paloalto_generic_profile_group ($device_id, $command_name, $profile_group_name, $anti_virus, + $anti_spyware, $vulnerability, $wildfire_analysis, + $url_filtering, $file_blocking, $data_filtering) { + + $array = array('profile_group' => + array($profile_group_name => + array('virus' => $anti_virus, + 'spyware' => $anti_spyware, + 'vulnerability' => $vulnerability, + 'wildfire_analysis' => $wildfire_analysis, + 'url_filtering' => $url_filtering, + 'file_blocking' => $file_blocking, + 'data_filtering' => $data_filtering + ) + ) + ); + $response = execute_command_and_verify_response($device_id, $command_name, $array, "CREATE PROFILE GROUP", 180, 180); + return $response; +} +function _paloalto_generic_address_ip_netmask ($device_id, $command_name, $name, + $address, $masklen) { + + $array = array('address_ip_netmask' => + array($name => + array('address' => $address, + 'masklen' => $masklen + ) + ) + ); + $response = execute_command_and_verify_response($device_id, $command_name, $array, "CREATE IP NETMASK", 180, 180); + return $response; +} +function _paloalto_generic_address_ip_range ($device_id, $command_name, $name, + $start_address, $end_address) { + + $array = array('address_ip_range' => + array($name => + array('startaddress' => $start_address, + 'endaddress' => $end_address + ) + ) + ); + $response = execute_command_and_verify_response($device_id, $command_name, $array, "CREATE IP RANGE", 180, 180); + return $response; +} +function _paloalto_generic_address_group ($device_id, $command_name, $address_group_name, $address_group_type, + $filter = "", $addresses = array()) { + + $address_group_array = array(); + $address_group_array['type'] = $address_group_type; + if ($address_group_type === "dynamic") { + $address_group_array['filter'] = $filter; + } + else if ($address_group_type === "static") { + $address_group_array['addresses'] = $addresses; + } + + $array = array('address_group' => + array($address_group_name => $address_group_array + ) + ); + $response = execute_command_and_verify_response($device_id, $command_name, $array, "CREATE ADDRESS GROUP", 180, 180); + return $response; +} +function _paloalto_generic_security_policy ($device_id, $command_name, $name, + $zone_from, $src_address, $zone_to, $dst_address, + $services, $action = "allow", $applications = array(), + $users = array(), $categories = array(), + $hip_profiles = array(), $profile_group = "", + $schedule = "", $log_start = "no", $log_end = "yes") { + + $security_policy_array = array(); + $security_policy_array['zone_from'] = $zone_from; + $security_policy_array['zone_to'] = $zone_to; + $security_policy_array['src_address'] = $src_address; + $security_policy_array['dst_address'] = $dst_address; + $security_policy_array['services'] = $services; + $security_policy_array['action'] = $action; + + if ($profile_group !== "") { + $security_policy_array['profile_group'] = $profile_group; + } + if ($schedule !== "") { + $security_policy_array['schedule'] = $schedule; + } + if ($log_start !== "") { + $security_policy_array['log_start'] = $log_start; + } + if ($log_end !== "") { + $security_policy_array['log_end'] = $log_end; + } + if (!empty($applications)) { + $security_policy_array['application'] = $applications; + } + if (!empty($users)) { + $security_policy_array['users'] = $users; + } + if (!empty($categories)) { + $security_policy_array['categories'] = $categories; + } + if (!empty($hip_profiles)) { + $security_policy_array['hip_profile'] = $hip_profiles; + } + + $array = array('policy_app' => + array($name => $security_policy_array + ) + ); + $response = execute_command_and_verify_response($device_id, $command_name, $array, "CREATE SECURITY POLICY", 180, 180); + return $response; +} +function _paloalto_generic_vpn_phase1 ($device_id, $command_name, $name, $lifetime, + $encryption = array(), $hash = array(), $dhgroup = array(), + $lifetime_unit = "") { + + $array = array('Phase1' => + array($name => + array('encryption' => $encryption, + 'hash' => $hash, + 'dhgroup' => $dhgroup, + 'lifetime' => $lifetime, + 'lifetime_unit' => $lifetime_unit + ) + ) + ); + $response = execute_command_and_verify_response($device_id, $command_name, $array, "CREATE VPN PHASE-1", 180, 180); + return $response; +} +function _paloalto_generic_antivirus_service ($device_id, $command_name, $av_service_name, + $av_profile, $policy) { + + $array = array('antivirus_service' => + array($av_service_name => + array('av_profile' => $av_profile, + 'policy' => $policy + ) + ) + ); + $response = execute_command_and_verify_response($device_id, $command_name, $array, "CREATE ANTI-VIRUS SERVICE", 180, 180); + return $response; +} + +//{"dns_servers":{"":{"primary":"6.6.6.6","secondary":"4.4.4.4"}}} +function _paloalto_generic_dns_servers ($device_id, $command_name, $primary = "", $secondary = "") { + + $dns_servers_array = array(); + if ($primary !== "") { + $dns_servers_array['primary'] = $primary; + } + if ($secondary !== "") { + $dns_servers_array['secondary'] = $secondary; + } + + if ($primary !== "" || $secondary !== "") { + $array = array('dns_servers' => + array("" => $dns_servers_array) + ); + } + else { + $array = array('dns_servers' => ""); + } + $response = execute_command_and_verify_response($device_id, $command_name, $array, "SET DNS SERVERS", 180, 180); + return $response; +} +// {"license":{"":{"auth_code":"xyz"}}} +function _paloalto_generic_license ($device_id, $command_name, $auth_code = "") { + + $license_array = array(); + if ($auth_code !== "") { + $license_array['auth_code'] = $auth_code; + $array = array('license' => + array("" => $license_array) + ); + } + else { + $array = array('license' => ""); + } + $response = execute_command_and_verify_response($device_id, $command_name, $array, "SET LICENSE", 180, 180); + return $response; +} + +function _paloalto_generic_ethernet ($device_id, $command_name, $ethernet_name, $interface_type) { + + $array = array('ethernet' => + array($ethernet_name => + array('interface_type' => $interface_type + ) + ) + ); + $response = execute_command_and_verify_response($device_id, $command_name, $array, "CREATE $interface_type INTERFACE", 180, 180); + return $response; +} +function _paloalto_generic_eth_tag ($device_id, $command_name, $ethernet_name, $subinterfaces) { + + $array = array('eth_tag' => + array($ethernet_name => + array('vwireinterface' => $subinterfaces + ) + ) + ); + $response = execute_command_and_verify_response($device_id, $command_name, $array, "CREATE VIRTUAL-WIRE SUB-INTERFACE", 180, 180); + return $response; +} +function _paloalto_generic_virtual_wire ($device_id, $command_name, $vwire_name, $interface1, $interface2, + $tag_allowed = "", $multicast_firewalling = "", + $link_state_pass_through = "") { + + $array = array('vwire' => + array($vwire_name => + array('interface1' => $interface1, + 'interface2' => $interface2, + 'tag_allowed' => $tag_allowed, + 'multicast_firewalling' => $multicast_firewalling, + 'link_state_pass_through' => $link_state_pass_through + ) + ) + ); + $response = execute_command_and_verify_response($device_id, $command_name, $array, "CREATE VIRTUAL-WIRE", 180, 180); + return $response; +} +function _paloalto_generic_zone ($device_id, $command_name, $zone_name, $zone_type, $zone_members) { + + $array = array('zone' => + array($zone_name => + array('zone_type' => $zone_type, + 'members' => $zone_members + ) + ) + ); + $response = execute_command_and_verify_response($device_id, $command_name, $array, "CREATE ZONE", 180, 180); + return $response; +} + +function _paloalto_generic_dhcp_client ($device_id, $command_name, $send_hostname = "no", + $accept_dhcp_domain = "no", $send_client_id = "no", + $accept_dhcp_hostname = "no") { + + $array = array('dhcp_client' => + array("" => + array('send_hostname' => $send_hostname, + 'accept_dhcp_domain' => $accept_dhcp_domain, + 'send_client_id' => $send_client_id, + 'accept_dhcp_hostname' => $accept_dhcp_hostname + ) + ) + ); + $response = execute_command_and_verify_response($device_id, $command_name, $array, "CREATE DHCP-CLIENT", 180, 180); + return $response; +} + + +?> \ No newline at end of file diff --git a/Reference/PALOALTO/Tasks/.meta_Task_paloalto_auto_license.php b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_auto_license.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_auto_license.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_address_group.php b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_address_group.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_address_group.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_address_ip_netmask.php b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_address_ip_netmask.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_address_ip_netmask.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_address_ip_range.php b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_address_ip_range.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_address_ip_range.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_antivirus_user_profile.php b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_antivirus_user_profile.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_antivirus_user_profile.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_dhcp_client.php b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_dhcp_client.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_dhcp_client.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_dns_server.php b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_dns_server.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_dns_server.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_eth_vwire.php b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_eth_vwire.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_eth_vwire.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_profile_group.php b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_profile_group.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_profile_group.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_security_policy.php b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_security_policy.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_security_policy.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_url_filtering_user_profile.php b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_url_filtering_user_profile.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_url_filtering_user_profile.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_virtual_wire.php b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_virtual_wire.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_virtual_wire.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_vpn_phase1.php b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_vpn_phase1.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_vpn_phase1.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_zone.php b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_zone.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_create_zone.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/PALOALTO/Tasks/.meta_Task_paloalto_license_deactivate.php b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_license_deactivate.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_license_deactivate.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/PALOALTO/Tasks/.meta_Task_paloalto_wait_for_autocom_job_completion.php b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_wait_for_autocom_job_completion.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/PALOALTO/Tasks/.meta_Task_paloalto_wait_for_autocom_job_completion.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/PALOALTO/Tasks/Task_paloalto_auto_license.php b/Reference/PALOALTO/Tasks/Task_paloalto_auto_license.php new file mode 100644 index 000000000..8f784aaef --- /dev/null +++ b/Reference/PALOALTO/Tasks/Task_paloalto_auto_license.php @@ -0,0 +1,30 @@ + diff --git a/Reference/PALOALTO/Tasks/Task_paloalto_create_address_group.php b/Reference/PALOALTO/Tasks/Task_paloalto_create_address_group.php new file mode 100644 index 000000000..33764b728 --- /dev/null +++ b/Reference/PALOALTO/Tasks/Task_paloalto_create_address_group.php @@ -0,0 +1,45 @@ + diff --git a/Reference/PALOALTO/Tasks/Task_paloalto_create_address_ip_netmask.php b/Reference/PALOALTO/Tasks/Task_paloalto_create_address_ip_netmask.php new file mode 100644 index 000000000..537e47d32 --- /dev/null +++ b/Reference/PALOALTO/Tasks/Task_paloalto_create_address_ip_netmask.php @@ -0,0 +1,34 @@ + diff --git a/Reference/PALOALTO/Tasks/Task_paloalto_create_address_ip_range.php b/Reference/PALOALTO/Tasks/Task_paloalto_create_address_ip_range.php new file mode 100644 index 000000000..e28165aaa --- /dev/null +++ b/Reference/PALOALTO/Tasks/Task_paloalto_create_address_ip_range.php @@ -0,0 +1,34 @@ + diff --git a/Reference/PALOALTO/Tasks/Task_paloalto_create_antivirus_user_profile.php b/Reference/PALOALTO/Tasks/Task_paloalto_create_antivirus_user_profile.php new file mode 100644 index 000000000..76276118f --- /dev/null +++ b/Reference/PALOALTO/Tasks/Task_paloalto_create_antivirus_user_profile.php @@ -0,0 +1,44 @@ + diff --git a/Reference/PALOALTO/Tasks/Task_paloalto_create_dhcp_client.php b/Reference/PALOALTO/Tasks/Task_paloalto_create_dhcp_client.php new file mode 100644 index 000000000..dade79fc1 --- /dev/null +++ b/Reference/PALOALTO/Tasks/Task_paloalto_create_dhcp_client.php @@ -0,0 +1,46 @@ + diff --git a/Reference/PALOALTO/Tasks/Task_paloalto_create_dns_server.php b/Reference/PALOALTO/Tasks/Task_paloalto_create_dns_server.php new file mode 100644 index 000000000..765f660c8 --- /dev/null +++ b/Reference/PALOALTO/Tasks/Task_paloalto_create_dns_server.php @@ -0,0 +1,43 @@ + diff --git a/Reference/PALOALTO/Tasks/Task_paloalto_create_eth_vwire.php b/Reference/PALOALTO/Tasks/Task_paloalto_create_eth_vwire.php new file mode 100644 index 000000000..30dd9c2c8 --- /dev/null +++ b/Reference/PALOALTO/Tasks/Task_paloalto_create_eth_vwire.php @@ -0,0 +1,41 @@ + diff --git a/Reference/PALOALTO/Tasks/Task_paloalto_create_profile_group.php b/Reference/PALOALTO/Tasks/Task_paloalto_create_profile_group.php new file mode 100644 index 000000000..f8ade15f1 --- /dev/null +++ b/Reference/PALOALTO/Tasks/Task_paloalto_create_profile_group.php @@ -0,0 +1,74 @@ + diff --git a/Reference/PALOALTO/Tasks/Task_paloalto_create_security_policy.php b/Reference/PALOALTO/Tasks/Task_paloalto_create_security_policy.php new file mode 100644 index 000000000..1f3e58454 --- /dev/null +++ b/Reference/PALOALTO/Tasks/Task_paloalto_create_security_policy.php @@ -0,0 +1,91 @@ + diff --git a/Reference/PALOALTO/Tasks/Task_paloalto_create_url_filtering_user_profile.php b/Reference/PALOALTO/Tasks/Task_paloalto_create_url_filtering_user_profile.php new file mode 100644 index 000000000..b1fc110a1 --- /dev/null +++ b/Reference/PALOALTO/Tasks/Task_paloalto_create_url_filtering_user_profile.php @@ -0,0 +1,91 @@ + diff --git a/Reference/PALOALTO/Tasks/Task_paloalto_create_virtual_wire.php b/Reference/PALOALTO/Tasks/Task_paloalto_create_virtual_wire.php new file mode 100644 index 000000000..ff87345b6 --- /dev/null +++ b/Reference/PALOALTO/Tasks/Task_paloalto_create_virtual_wire.php @@ -0,0 +1,50 @@ + diff --git a/Reference/PALOALTO/Tasks/Task_paloalto_create_vpn_phase1.php b/Reference/PALOALTO/Tasks/Task_paloalto_create_vpn_phase1.php new file mode 100644 index 000000000..c3466dcf3 --- /dev/null +++ b/Reference/PALOALTO/Tasks/Task_paloalto_create_vpn_phase1.php @@ -0,0 +1,41 @@ + diff --git a/Reference/PALOALTO/Tasks/Task_paloalto_create_zone.php b/Reference/PALOALTO/Tasks/Task_paloalto_create_zone.php new file mode 100644 index 000000000..eb8d0077e --- /dev/null +++ b/Reference/PALOALTO/Tasks/Task_paloalto_create_zone.php @@ -0,0 +1,34 @@ + \ No newline at end of file diff --git a/Reference/PALOALTO/Tasks/Task_paloalto_license_deactivate.php b/Reference/PALOALTO/Tasks/Task_paloalto_license_deactivate.php new file mode 100644 index 000000000..e3078707a --- /dev/null +++ b/Reference/PALOALTO/Tasks/Task_paloalto_license_deactivate.php @@ -0,0 +1,25 @@ + diff --git a/Reference/PALOALTO/Tasks/Task_paloalto_wait_for_autocom_job_completion.php b/Reference/PALOALTO/Tasks/Task_paloalto_wait_for_autocom_job_completion.php new file mode 100644 index 000000000..34d02c8c6 --- /dev/null +++ b/Reference/PALOALTO/Tasks/Task_paloalto_wait_for_autocom_job_completion.php @@ -0,0 +1,31 @@ + $PROCESSINSTANCEID, + 'EXECNUMBER' => $EXECNUMBER, + 'TASKID' => $TASKID); + +$device_id = substr($context['device_id'], 3); +$response = wait_for_autocom_job_completion($device_id, $process_params); +$response = json_decode($response, true); +if ($response['wo_status'] !== ENDED) { + $response = json_encode($response); + echo $response; + exit; +} +$autocom_status_message = $response['wo_comment']; +$response = prepare_json_response(ENDED, "AutoCom Job completed successfully on the PA Device $device_id\n$autocom_status_message", $context, true); +echo $response; + +?> diff --git a/Reference/README b/Reference/README new file mode 100644 index 000000000..5dc90e181 --- /dev/null +++ b/Reference/README @@ -0,0 +1,3 @@ +These files are provided by UBIqube as examples and can be freely reused to build new objects, templates or orchestration services. + +UBIqube may change or update these files without any notification therefore it is advised to copy the files to a folder other than reference before doing any modification. diff --git a/Reference/VMWARE/.meta_vRO b/Reference/VMWARE/.meta_vRO new file mode 100644 index 000000000..9002eb411 --- /dev/null +++ b/Reference/VMWARE/.meta_vRO @@ -0,0 +1,39 @@ + + + + + MODEL + + + DATE_MODIFICATION + 1445429309400 + + + COMMENT + + + + REPOSITORY + Process + + + DATE_CREATION + 1445429309382 + + + MANUFACTURER + + + CONFIGURATION_FILTER + + + + TYPE + DIRECTORY + + + TAG + vRO + + + diff --git a/Reference/VMWARE/vRO/.meta_Library b/Reference/VMWARE/vRO/.meta_Library new file mode 100644 index 000000000..80c8946fe --- /dev/null +++ b/Reference/VMWARE/vRO/.meta_Library @@ -0,0 +1,39 @@ + + + + + MODEL + + + DATE_MODIFICATION + 1445429309400 + + + COMMENT + + + + REPOSITORY + Process + + + DATE_CREATION + 1445429309382 + + + MANUFACTURER + + + CONFIGURATION_FILTER + + + + TYPE + DIRECTORY + + + TAG + + + + diff --git a/Reference/VMWARE/vRO/.meta_Tasks b/Reference/VMWARE/vRO/.meta_Tasks new file mode 100644 index 000000000..80c8946fe --- /dev/null +++ b/Reference/VMWARE/vRO/.meta_Tasks @@ -0,0 +1,39 @@ + + + + + MODEL + + + DATE_MODIFICATION + 1445429309400 + + + COMMENT + + + + REPOSITORY + Process + + + DATE_CREATION + 1445429309382 + + + MANUFACTURER + + + CONFIGURATION_FILTER + + + + TYPE + DIRECTORY + + + TAG + + + + diff --git a/Reference/VMWARE/vRO/Library/.meta_REST b/Reference/VMWARE/vRO/Library/.meta_REST new file mode 100644 index 000000000..db47d8a9b --- /dev/null +++ b/Reference/VMWARE/vRO/Library/.meta_REST @@ -0,0 +1,39 @@ + + + + + MODEL + + + DATE_MODIFICATION + 1445429309400 + + + COMMENT + + + + REPOSITORY + Process + + + DATE_CREATION + 1445429309382 + + + MANUFACTURER + + + CONFIGURATION_FILTER + + + + TYPE + DIRECTORY + + + TAG + + + + \ No newline at end of file diff --git a/Reference/VMWARE/vRO/Library/.meta_constants.php b/Reference/VMWARE/vRO/Library/.meta_constants.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/VMWARE/vRO/Library/.meta_constants.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/VMWARE/vRO/Library/REST/.meta_execution_rest.php b/Reference/VMWARE/vRO/Library/REST/.meta_execution_rest.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/VMWARE/vRO/Library/REST/.meta_execution_rest.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/VMWARE/vRO/Library/REST/.meta_interaction_presentation_rest.php b/Reference/VMWARE/vRO/Library/REST/.meta_interaction_presentation_rest.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/VMWARE/vRO/Library/REST/.meta_interaction_presentation_rest.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/VMWARE/vRO/Library/REST/.meta_presentation_rest.php b/Reference/VMWARE/vRO/Library/REST/.meta_presentation_rest.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/VMWARE/vRO/Library/REST/.meta_presentation_rest.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/VMWARE/vRO/Library/REST/.meta_utility.php b/Reference/VMWARE/vRO/Library/REST/.meta_utility.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/VMWARE/vRO/Library/REST/.meta_utility.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/VMWARE/vRO/Library/REST/.meta_vmware_vro_common_rest.php b/Reference/VMWARE/vRO/Library/REST/.meta_vmware_vro_common_rest.php new file mode 100644 index 000000000..b9e5360a9 --- /dev/null +++ b/Reference/VMWARE/vRO/Library/REST/.meta_vmware_vro_common_rest.php @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1453292430598 + + + DATE_CREATION + 1453292418180 + + + TYPE + FILE + + + diff --git a/Reference/VMWARE/vRO/Library/REST/execution_rest.php b/Reference/VMWARE/vRO/Library/REST/execution_rest.php new file mode 100644 index 000000000..fc7f53e11 --- /dev/null +++ b/Reference/VMWARE/vRO/Library/REST/execution_rest.php @@ -0,0 +1,21 @@ + \ No newline at end of file diff --git a/Reference/VMWARE/vRO/Library/REST/interaction_presentation_rest.php b/Reference/VMWARE/vRO/Library/REST/interaction_presentation_rest.php new file mode 100644 index 000000000..191007f84 --- /dev/null +++ b/Reference/VMWARE/vRO/Library/REST/interaction_presentation_rest.php @@ -0,0 +1,21 @@ + \ No newline at end of file diff --git a/Reference/VMWARE/vRO/Library/REST/presentation_rest.php b/Reference/VMWARE/vRO/Library/REST/presentation_rest.php new file mode 100644 index 000000000..a6e5e106e --- /dev/null +++ b/Reference/VMWARE/vRO/Library/REST/presentation_rest.php @@ -0,0 +1,21 @@ + \ No newline at end of file diff --git a/Reference/VMWARE/vRO/Library/REST/utility.php b/Reference/VMWARE/vRO/Library/REST/utility.php new file mode 100644 index 000000000..5d266607f --- /dev/null +++ b/Reference/VMWARE/vRO/Library/REST/utility.php @@ -0,0 +1,87 @@ +hasNext()) { + $encoded_data .= "&"; + } + } + $ait = new ArrayIterator(explode("/", $uri)); + $cit = new CachingIterator($ait); + $uri_encoded = ""; + foreach ($cit as $uri_path) { + $uri_encoded .= rawurlencode($uri_path); + if ($cit->hasNext()) { + $uri_encoded .= "/"; + } + } + $url = "'https://{$VRO_HOST}:{$VRO_PORT}/vco/api/{$uri_encoded}?{$encoded_data}'"; + } + else { + $ait = new ArrayIterator(explode("/", $vro_rest_api)); + $cit = new CachingIterator($ait); + $uri_encoded = ""; + foreach ($cit as $uri_path) { + $uri_encoded .= rawurlencode($uri_path); + if ($cit->hasNext()) { + $uri_encoded .= "/"; + } + } + $url = "'https://{$VRO_HOST}:{$VRO_PORT}/vco/api/{$uri_encoded}'"; + } + + $content_type = "application/json"; + $accept = "application/json"; + if (strpos($json_body, "@") === 0) { + $content_type = "*/*"; + } + else if (strpos($json_body, "file=") === 0) { + $content_type = "application/x-www-form-urlencoded"; + } + $authorization = base64_encode($context['vcenter_username'] . ":" . $context['vcenter_password']); + $curl_cmd = "{$CURL_CMD} -iksw '\nHTTP_CODE=%{http_code}' -H \"Content-Type: {$content_type}\" -H \"Accept: {$accept}\" -H 'Authorization: Basic {$authorization}' --connect-timeout $connection_timeout --max-time $max_time -X {$operation} {$url}"; + if ($json_body !== "") { + $curl_cmd .= " -d '" . pretty_print_json($json_body) . "'"; + } + logToFile("Curl Request : $curl_cmd\n"); + return $curl_cmd; +} + +function vro_add_parameter_in_request (&$parameters, $name, $type, $value, $scope = "local", $description = "") { + + $index = count($parameters); + $parameters[$index]['name'] = $name; + $parameters[$index]['type'] = $type; + $parameters[$index]['value'] = $value; + $parameters[$index]['scope'] = $scope; + $parameters[$index]['description'] = $description; +} + +?> \ No newline at end of file diff --git a/Reference/VMWARE/vRO/Library/REST/vmware_vro_common_rest.php b/Reference/VMWARE/vRO/Library/REST/vmware_vro_common_rest.php new file mode 100644 index 000000000..eca3db1ea --- /dev/null +++ b/Reference/VMWARE/vRO/Library/REST/vmware_vro_common_rest.php @@ -0,0 +1,106 @@ + $timeout) { + $wo_comment .= "Workflow execution could not be completed within $timeout seconds.\nHence, Ending the Process as Failure."; + $response = prepare_json_response(FAILED, $wo_comment, $wo_newparams, true); + return $response; + } + } + $response = prepare_json_response(ENDED, $wo_comment, $wo_newparams); + return $response; +} + +function vro_execute_workflow_and_wait_for_completion ($workflow_id, $parameters_array) { + + global $context; + + $response = _execution_start_workflow($workflow_id, $parameters_array); + $response = json_decode($response, true); + if ($response['wo_status'] !== ENDED) { + $response = prepare_json_response(FAILED, $response['wo_comment'], $context, true); + echo $response; + exit; + } + + $execution_id = vro_get_execution_id($response['wo_newparams']['response_raw_headers']); + $context['execution_id'] = $execution_id; + + $response = vro_wait_for_workflow_completion($workflow_id, $execution_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['output_parameters'] = $response['wo_newparams']; +} + +?> \ No newline at end of file diff --git a/Reference/VMWARE/vRO/Library/constants.php b/Reference/VMWARE/vRO/Library/constants.php new file mode 100644 index 000000000..1ca850527 --- /dev/null +++ b/Reference/VMWARE/vRO/Library/constants.php @@ -0,0 +1,72 @@ + diff --git a/Reference/VMWARE/vRO/Tasks/.meta_REST b/Reference/VMWARE/vRO/Tasks/.meta_REST new file mode 100644 index 000000000..db47d8a9b --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/.meta_REST @@ -0,0 +1,39 @@ + + + + + MODEL + + + DATE_MODIFICATION + 1445429309400 + + + COMMENT + + + + REPOSITORY + Process + + + DATE_CREATION + 1445429309382 + + + MANUFACTURER + + + CONFIGURATION_FILTER + + + + TYPE + DIRECTORY + + + TAG + + + + \ No newline at end of file diff --git a/Reference/VMWARE/vRO/Tasks/REST/.meta_vCenter b/Reference/VMWARE/vRO/Tasks/REST/.meta_vCenter new file mode 100644 index 000000000..80c8946fe --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/.meta_vCenter @@ -0,0 +1,39 @@ + + + + + MODEL + + + DATE_MODIFICATION + 1445429309400 + + + COMMENT + + + + REPOSITORY + Process + + + DATE_CREATION + 1445429309382 + + + MANUFACTURER + + + CONFIGURATION_FILTER + + + + TYPE + DIRECTORY + + + TAG + + + + diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/.meta_VM_Management b/Reference/VMWARE/vRO/Tasks/REST/vCenter/.meta_VM_Management new file mode 100644 index 000000000..80c8946fe --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/.meta_VM_Management @@ -0,0 +1,39 @@ + + + + + MODEL + + + DATE_MODIFICATION + 1445429309400 + + + COMMENT + + + + REPOSITORY + Process + + + DATE_CREATION + 1445429309382 + + + MANUFACTURER + + + CONFIGURATION_FILTER + + + + TYPE + DIRECTORY + + + TAG + + + + diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Add_CD_ROM.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Add_CD_ROM.php new file mode 100644 index 000000000..aecec21c3 --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Add_CD_ROM.php @@ -0,0 +1,21 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1530408716044 + + + DATE_CREATION + 1530408605282 + + + TYPE + FILE + + + diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Add_Disk.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Add_Disk.php new file mode 100644 index 000000000..6fec0ed08 --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Add_Disk.php @@ -0,0 +1,21 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1530408387526 + + + DATE_CREATION + 1530408312219 + + + TYPE + FILE + + + diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Change_RAM.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Change_RAM.php new file mode 100644 index 000000000..aecec21c3 --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Change_RAM.php @@ -0,0 +1,21 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1530408716044 + + + DATE_CREATION + 1530408605282 + + + TYPE + FILE + + + diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Create_Simple_VM.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Create_Simple_VM.php new file mode 100644 index 000000000..5919b34e9 --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Create_Simple_VM.php @@ -0,0 +1,21 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1530407364769 + + + DATE_CREATION + 1530407364765 + + + TYPE + FILE + + + diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Create_Snapshot.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Create_Snapshot.php new file mode 100644 index 000000000..b85f773c3 --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Create_Snapshot.php @@ -0,0 +1,21 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1530478772021 + + + DATE_CREATION + 1530478422959 + + + TYPE + FILE + + + diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Delete_VM.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Delete_VM.php new file mode 100644 index 000000000..aecec21c3 --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Delete_VM.php @@ -0,0 +1,21 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1530408716044 + + + DATE_CREATION + 1530408605282 + + + TYPE + FILE + + + diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Get_VMs_by_Name.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Get_VMs_by_Name.php new file mode 100644 index 000000000..aecec21c3 --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Get_VMs_by_Name.php @@ -0,0 +1,21 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1530408716044 + + + DATE_CREATION + 1530408605282 + + + TYPE + FILE + + + diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Mount_CD_ROM.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Mount_CD_ROM.php new file mode 100644 index 000000000..f6ff5aed5 --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Mount_CD_ROM.php @@ -0,0 +1,21 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1530408821008 + + + DATE_CREATION + 1530408821005 + + + TYPE + FILE + + + diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Power_Off_VM.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Power_Off_VM.php new file mode 100644 index 000000000..aecec21c3 --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Power_Off_VM.php @@ -0,0 +1,21 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1530408716044 + + + DATE_CREATION + 1530408605282 + + + TYPE + FILE + + + diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Reboot_VM.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Reboot_VM.php new file mode 100644 index 000000000..aecec21c3 --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Reboot_VM.php @@ -0,0 +1,21 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1530408716044 + + + DATE_CREATION + 1530408605282 + + + TYPE + FILE + + + diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Register_VM.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Register_VM.php new file mode 100644 index 000000000..2ab6fe17a --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Register_VM.php @@ -0,0 +1,21 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1530407097872 + + + DATE_CREATION + 1530407097870 + + + TYPE + FILE + + + diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Remove_All_Snapshots.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Remove_All_Snapshots.php new file mode 100644 index 000000000..c5c1c10ab --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Remove_All_Snapshots.php @@ -0,0 +1,21 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1530479392235 + + + DATE_CREATION + 1530479392232 + + + TYPE + FILE + + + diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Resume_VM_And_Wait.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Resume_VM_And_Wait.php new file mode 100644 index 000000000..aecec21c3 --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Resume_VM_And_Wait.php @@ -0,0 +1,21 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1530408716044 + + + DATE_CREATION + 1530408605282 + + + TYPE + FILE + + + diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Revert_To_Snapshot_And_Wait.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Revert_To_Snapshot_And_Wait.php new file mode 100644 index 000000000..f6abee5bd --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Revert_To_Snapshot_And_Wait.php @@ -0,0 +1,21 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1530479032924 + + + DATE_CREATION + 1530479032922 + + + TYPE + FILE + + + diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Run_SSH_Command.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Run_SSH_Command.php new file mode 100644 index 000000000..ba00cea3e --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Run_SSH_Command.php @@ -0,0 +1,21 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1530409694385 + + + DATE_CREATION + 1530409441163 + + + TYPE + FILE + + + diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Set_VM_Performance.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Set_VM_Performance.php new file mode 100644 index 000000000..a0fdcac9d --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Set_VM_Performance.php @@ -0,0 +1,21 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1530478139344 + + + DATE_CREATION + 1530476371620 + + + TYPE + FILE + + + diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Start_VM_And_Wait.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Start_VM_And_Wait.php new file mode 100644 index 000000000..aecec21c3 --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Start_VM_And_Wait.php @@ -0,0 +1,21 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1530408716044 + + + DATE_CREATION + 1530408605282 + + + TYPE + FILE + + + diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Suspend_VM_And_Wait.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Suspend_VM_And_Wait.php new file mode 100644 index 000000000..aecec21c3 --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/.meta_Task_vRO_Suspend_VM_And_Wait.php @@ -0,0 +1,21 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1530408716044 + + + DATE_CREATION + 1530408605282 + + + TYPE + FILE + + + diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Add_CD_ROM.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Add_CD_ROM.php new file mode 100644 index 000000000..48edd297e --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Add_CD_ROM.php @@ -0,0 +1,38 @@ + array("type" => VC_VIRTUAL_MACHINE, "id" => $context['vm'])); +vro_add_parameter_in_request($parameters, 'vm', VC_VIRTUAL_MACHINE, $value); + +$value = array("boolean" => array("value" => filter_var($context['connectAtPowerOn'], FILTER_VALIDATE_BOOLEAN))); +vro_add_parameter_in_request($parameters, 'connectAtPowerOn', 'boolean', $value); + +$value = array("string" => array("value" => $context['deviceType'])); +vro_add_parameter_in_request($parameters, 'deviceType', 'string', $value); + +$value = array("string" => array("value" => $context['filePath'])); +vro_add_parameter_in_request($parameters, 'filePath', 'string', $value); + +$parameters_array['parameters'] = $parameters; + +vro_execute_workflow_and_wait_for_completion(VRO_ADD_CD_ROM_V20, $parameters_array); + +$response = prepare_json_response(ENDED, "CD-ROM added succesfully.", $context, true); +echo $response; + +?> diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Add_Disk.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Add_Disk.php new file mode 100644 index 000000000..735794549 --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Add_Disk.php @@ -0,0 +1,56 @@ + array("type" => VC_VIRTUAL_MACHINE, "id" => $context['vm'])); +vro_add_parameter_in_request($parameters, 'vm', VC_VIRTUAL_MACHINE, $value); + +$value = array("sdk-object" => array("type" => VC_DATASTORE, "id" => "{$vcenter_fqdn}/" . $context['datastore'])); +vro_add_parameter_in_request($parameters, 'datastore', VC_DATASTORE, $value); + +$value = array("number" => array("value" => $context['diskIndex'])); +vro_add_parameter_in_request($parameters, 'diskIndex', 'number', $value); + +$value = array("number" => array("value" => $context['diskSize'])); +vro_add_parameter_in_request($parameters, 'diskSize', 'number', $value); + +$value = array("sdk-object" => array("type" => VC_DISK_MODE, "id" => $context['diskMode'])); +vro_add_parameter_in_request($parameters, 'diskMode', VC_DISK_MODE, $value); + +$value = array("number" => array("value" => $context['scsiBusNumber'])); +vro_add_parameter_in_request($parameters, 'scsiBusNumber', 'number', $value); + +$value = array("boolean" => array("value" => filter_var($context['thinProvisioned'], FILTER_VALIDATE_BOOLEAN))); +vro_add_parameter_in_request($parameters, 'thinProvisioned', 'boolean', $value); + +$parameters_array['parameters'] = $parameters; + +vro_execute_workflow_and_wait_for_completion(VRO_ADD_DISK_V20, $parameters_array); + +$response = prepare_json_response(ENDED, "Disk added successfully.", $context, true); +echo $response; + +?> diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Change_RAM.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Change_RAM.php new file mode 100644 index 000000000..02dd7eb9c --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Change_RAM.php @@ -0,0 +1,30 @@ + array("type" => VC_VIRTUAL_MACHINE, "id" => $context['vm'])); +vro_add_parameter_in_request($parameters, 'vm', VC_VIRTUAL_MACHINE, $value); + +$value = array("number" => array("value" => $context['memory'])); +vro_add_parameter_in_request($parameters, 'memory', 'number', $value); + +$parameters_array['parameters'] = $parameters; + +vro_execute_workflow_and_wait_for_completion(VRO_CHANGE_RAM_V20, $parameters_array); + +$response = prepare_json_response(ENDED, "RAM changed successfully.", $context, true); +echo $response; + +?> \ No newline at end of file diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Create_Simple_VM.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Create_Simple_VM.php new file mode 100644 index 000000000..9f830d893 --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Create_Simple_VM.php @@ -0,0 +1,82 @@ + array("value" => $context['vmName'])); +vro_add_parameter_in_request($parameters, 'vmName', 'string', $value); + +$value = array("sdk-object" => array("type" => VC_VM_GUEST_OS, "id" => $context['vmGuestOs'])); +vro_add_parameter_in_request($parameters, 'vmGuestOs', VC_VM_GUEST_OS, $value); + +$value = array("sdk-object" => array("type" => VC_VM_FOLDER, "id" => "{$vcenter_fqdn}/" . $context['vmFolder'])); +vro_add_parameter_in_request($parameters, 'vmFolder', VC_VM_FOLDER, $value); + +$value = array("sdk-object" => array("type" => VC_RESOURCE_POOL, "id" => "{$vcenter_fqdn}/" . $context['vmResourcePool'])); +vro_add_parameter_in_request($parameters, 'vmResourcePool', VC_RESOURCE_POOL, $value); + +$value = array("sdk-object" => array("type" => VC_HOST_SYSTEM, "id" => "{$vcenter_fqdn}/" . $context['vmHost'])); +vro_add_parameter_in_request($parameters, 'vmHost', VC_HOST_SYSTEM, $value); + +$value = array("number" => array("value" => intval($context['vmDiskSize']))); +vro_add_parameter_in_request($parameters, 'vmDiskSize', 'number', $value); + +$value = array("number" => array("value" => intval($context['vmMemorySize']))); +vro_add_parameter_in_request($parameters, 'vmMemorySize', 'number', $value); + +$value = array("number" => array("value" => intval($context['vmNbOfCpus']))); +vro_add_parameter_in_request($parameters, 'vmNbOfCpus', 'number', $value); + +$value = array("sdk-object" => array("type" => VC_NETWORK, "id" => "{$vcenter_fqdn}/" . $context['vmNetwork'])); +vro_add_parameter_in_request($parameters, 'vmNetwork', VC_NETWORK, $value); + +$value = array("sdk-object" => array("type" => VC_DATASTORE, "id" => "{$vcenter_fqdn}/" . $context['vmDatastore'])); +vro_add_parameter_in_request($parameters, 'vmDatastore', VC_DATASTORE, $value); + +$value = array("boolean" => array("value" => filter_var($context['diskThinProvisioned'], FILTER_VALIDATE_BOOLEAN))); +vro_add_parameter_in_request($parameters, 'diskThinProvisioned', 'boolean', $value); + +$parameters_array['parameters'] = $parameters; + +vro_execute_workflow_and_wait_for_completion(VRO_CREATE_SIMPLE_VM_V20, $parameters_array); + +$id_full = $context['output_parameters'][0]['value']['sdk-object']['id']; +$context['vm'] = str_replace(",id:", "/", $id_full); +$vm_id = substr($id_full, strpos($id_full, "id:") + 3); +$context['vm_id'] = $vm_id; + +$response = prepare_json_response(ENDED, "VM created successfully.\nVM Id : $vm_id", $context, true); +echo $response; + +?> \ No newline at end of file diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Create_Snapshot.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Create_Snapshot.php new file mode 100644 index 000000000..fc1e84292 --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Create_Snapshot.php @@ -0,0 +1,53 @@ + array("type" => VC_VIRTUAL_MACHINE, "id" => $context['vm'])); +vro_add_parameter_in_request($parameters, 'vm', VC_VIRTUAL_MACHINE, $value); + +$value = array("string" => array("value" => $context['snapshot_name'])); +vro_add_parameter_in_request($parameters, 'name', 'string', $value); + +$value = array("string" => array("value" => $context['description'])); +vro_add_parameter_in_request($parameters, 'description', 'string', $value); + +$value = array("boolean" => array("value" => filter_var($context['snapshot_memory'], FILTER_VALIDATE_BOOLEAN))); +vro_add_parameter_in_request($parameters, 'memory', 'boolean', $value); + +$value = array("boolean" => array("value" => filter_var($context['quiesce'], FILTER_VALIDATE_BOOLEAN))); +vro_add_parameter_in_request($parameters, 'quiesce', 'boolean', $value); + +$parameters_array['parameters'] = $parameters; + +vro_execute_workflow_and_wait_for_completion(VRO_CREATE_SNAPSHOT_V20, $parameters_array); +/** + * TODO : snapshot response + */ +$id_full = $context['output_parameters'][0]['value']['sdk-object']['id']; +$context['snapshot'] = str_replace(",id:", "/", $id_full); +$snapshot_id = substr($id_full, strpos($id_full, "id:") + 3); +$context['snapshot_id'] = $snapshot_id; + +$response = prepare_json_response(ENDED, "Snapshot created successfully.\nSnapshot id : $snapshot_id", $context, true); +echo $response; + +?> \ No newline at end of file diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Delete_VM.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Delete_VM.php new file mode 100644 index 000000000..1028ddf72 --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Delete_VM.php @@ -0,0 +1,30 @@ + array("type" => VC_VIRTUAL_MACHINE, "id" => $context['vm'])); +vro_add_parameter_in_request($parameters, 'vm', VC_VIRTUAL_MACHINE, $value); + +$parameters_array['parameters'] = $parameters; + +vro_execute_workflow_and_wait_for_completion(VRO_DELETE_VM_V20, $parameters_array); + +$response = prepare_json_response(ENDED, "VM deleted successfully.", $context, true); +echo $response; + +?> diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Get_VMs_by_Name.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Get_VMs_by_Name.php new file mode 100644 index 000000000..2e89ce4f9 --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Get_VMs_by_Name.php @@ -0,0 +1,36 @@ + array("value" => $context['criteria'])); +vro_add_parameter_in_request($parameters, 'criteria', 'string', $value); + +$parameters_array['parameters'] = $parameters; + +vro_execute_workflow_and_wait_for_completion(VRO_GET_VMS_BY_NAME_V102, $parameters_array); + +$context['vm'] = array(); +$index = 0; +foreach ($context['output_parameters'][0]['value']['array']['elements'] as $element) { + $id_full = $element['sdk-object']['id']; + $vm_id = substr($id_full, strpos($id_full, "id:") + 3); + $context['vm'][$index]['id'] = $vm_id; + /** + * TODO : Need more info like VM name etc..? + */ + $index++; +} + +$context['vm_count'] = $index; + +task_exit(ENDED, "VM details fetched successfully."); + +?> \ No newline at end of file diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Mount_CD_ROM.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Mount_CD_ROM.php new file mode 100644 index 000000000..bf6013bb4 --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Mount_CD_ROM.php @@ -0,0 +1,38 @@ + array("type" => VC_VIRTUAL_MACHINE, "id" => $context['vm'])); +vro_add_parameter_in_request($parameters, 'vm', VC_VIRTUAL_MACHINE, $value); + +$value = array("boolean" => array("value" => filter_var($context['connectAtPowerOn'], FILTER_VALIDATE_BOOLEAN))); +vro_add_parameter_in_request($parameters, 'connectAtPowerOn', 'boolean', $value); + +$value = array("string" => array("value" => $context['deviceType'])); +vro_add_parameter_in_request($parameters, 'deviceType', 'string', $value); + +$value = array("string" => array("value" => $context['filePath'])); +vro_add_parameter_in_request($parameters, 'filePath', 'string', $value); + +$parameters_array['parameters'] = $parameters; + +vro_execute_workflow_and_wait_for_completion(VRO_MOUNT_CD_ROM_V32, $parameters_array); + +$response = prepare_json_response(ENDED, "CD-ROM mounted succesfully.", $context, true); +echo $response; + +?> diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Power_Off_VM.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Power_Off_VM.php new file mode 100644 index 000000000..bea26e5c6 --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Power_Off_VM.php @@ -0,0 +1,30 @@ + array("type" => VC_VIRTUAL_MACHINE, "id" => $context['vm'])); +vro_add_parameter_in_request($parameters, 'vm', VC_VIRTUAL_MACHINE, $value); + +$parameters_array['parameters'] = $parameters; + +vro_execute_workflow_and_wait_for_completion(VRO_POWER_OFF_VM_AND_WAIT_V20, $parameters_array); + +$response = prepare_json_response(ENDED, "VM powered off successfully.", $context, true); +echo $response; + +?> \ No newline at end of file diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Reboot_VM.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Reboot_VM.php new file mode 100644 index 000000000..948eac7a5 --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Reboot_VM.php @@ -0,0 +1,30 @@ + array("type" => VC_VIRTUAL_MACHINE, "id" => $context['vm'])); +vro_add_parameter_in_request($parameters, 'vm', VC_VIRTUAL_MACHINE, $value); + +$parameters_array['parameters'] = $parameters; + +vro_execute_workflow_and_wait_for_completion(VRO_REBOOT_GUEST_OS_V20, $parameters_array); + +$response = prepare_json_response(ENDED, "VM rebooted successfully.", $context, true); +echo $response; + +?> \ No newline at end of file diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Register_VM.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Register_VM.php new file mode 100644 index 000000000..c5c29e553 --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Register_VM.php @@ -0,0 +1,55 @@ + array("type" => VC_VM_FOLDER, "id" => "{$vcenter_fqdn}/" . $context['folder'])); +vro_add_parameter_in_request($parameters, 'folder', VC_VM_FOLDER, $value); + +$value = array("string" => array("value" => $context['path'])); +vro_add_parameter_in_request($parameters, 'path', 'string', $value); + +$value = array("string" => array("value" => $context['name'])); +vro_add_parameter_in_request($parameters, 'name', 'string', $value); + +$value = array("boolean" => array("value" => filter_var($context['asTemplate'], FILTER_VALIDATE_BOOLEAN))); +vro_add_parameter_in_request($parameters, 'asTemplate', 'boolean', $value); + +$value = array("sdk-object" => array("type" => VC_RESOURCE_POOL, "id" => "{$vcenter_fqdn}/" . $context['resourcePool'])); +vro_add_parameter_in_request($parameters, 'resourcePool', VC_RESOURCE_POOL, $value); + +$value = array("sdk-object" => array("type" => VC_HOST_SYSTEM, "id" => "{$vcenter_fqdn}/" . $context['host'])); +vro_add_parameter_in_request($parameters, 'host', VC_HOST_SYSTEM, $value); + +$parameters_array['parameters'] = $parameters; + +vro_execute_workflow_and_wait_for_completion(VRO_REGISTER_VM_V14, $parameters_array); + +$id_full = $context['output_parameters'][0]['value']['sdk-object']['id']; +$context['registered_vm'] = str_replace(",id:", "/", $id_full); +$vm_id = substr($id_full, strpos($id_full, "id:") + 3); +$context['registered_vm_id'] = $vm_id; + +$response = prepare_json_response(ENDED, "VM registered successfully.\nVM Id : $vm_id", $context, true); +echo $response; + +?> \ No newline at end of file diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Remove_All_Snapshots.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Remove_All_Snapshots.php new file mode 100644 index 000000000..830fd05fe --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Remove_All_Snapshots.php @@ -0,0 +1,25 @@ + array("type" => VC_VIRTUAL_MACHINE, "id" => $context['vm'])); +vro_add_parameter_in_request($parameters, 'vm', VC_VIRTUAL_MACHINE, $value); + +$parameters_array['parameters'] = $parameters; + +vro_execute_workflow_and_wait_for_completion(VRO_REMOVE_ALL_SNAPSHOTS_V20, $parameters_array); + +$response = prepare_json_response(ENDED, "Snapshots removed successfully.", $context, true); +echo $response; + +?> \ No newline at end of file diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Resume_VM_And_Wait.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Resume_VM_And_Wait.php new file mode 100644 index 000000000..cde9413ae --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Resume_VM_And_Wait.php @@ -0,0 +1,34 @@ + array("type" => VC_VIRTUAL_MACHINE, "id" => $context['vm'])); +vro_add_parameter_in_request($parameters, 'vm', VC_VIRTUAL_MACHINE, $value); + +$value = array("sdk-object" => array("type" => VC_HOST_SYSTEM, "id" => $context['host'])); +vro_add_parameter_in_request($parameters, 'host', VC_HOST_SYSTEM, $value); + +$parameters_array['parameters'] = $parameters; + +vro_execute_workflow_and_wait_for_completion(VRO_RESUME_VM_AND_WAIT_V20, $parameters_array); + +$response = prepare_json_response(ENDED, "VM resumed successfully.", $context, true); +echo $response; + +?> \ No newline at end of file diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Revert_To_Snapshot_And_Wait.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Revert_To_Snapshot_And_Wait.php new file mode 100644 index 000000000..046bd6c09 --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Revert_To_Snapshot_And_Wait.php @@ -0,0 +1,31 @@ + array("type" => VC_VIRTUAL_MACHINE_SNAPSHOT, "id" => $context['snapshot'])); +vro_add_parameter_in_request($parameters, 'snapshot', VC_VIRTUAL_MACHINE_SNAPSHOT, $value); + +$value = array("sdk-object" => array("type" => VC_HOST_SYSTEM, "id" => "{$vcenter_fqdn}/" . $context['snapshot_revert_host'])); +vro_add_parameter_in_request($parameters, 'vmhost', VC_HOST_SYSTEM, $value); + +$parameters_array['parameters'] = $parameters; + +vro_execute_workflow_and_wait_for_completion(VRO_REVERT_TO_SNAPSHOT_AND_WAIT_V20, $parameters_array); + +$response = prepare_json_response(ENDED, "Snapshot reverted successfully to " . $context['snapshot'], $context, true); +echo $response; + +?> \ No newline at end of file diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Run_SSH_Command.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Run_SSH_Command.php new file mode 100644 index 000000000..4868fe198 --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Run_SSH_Command.php @@ -0,0 +1,71 @@ + array("value" => $context['hostNameOrIP'])); +vro_add_parameter_in_request($parameters, 'hostNameOrIP', 'string', $value); + +$value = array("number" => array("value" => $context['port'])); +vro_add_parameter_in_request($parameters, 'port', 'number', $value); + +$value = array("string" => array("value" => $context['username'])); +vro_add_parameter_in_request($parameters, 'username', 'string', $value); + +$value = array("SecureString" => array("value" => $context['password'])); +vro_add_parameter_in_request($parameters, 'password', 'SecureString', $value); + +$value = array("string" => array("value" => $context['cmd'])); +vro_add_parameter_in_request($parameters, 'cmd', 'string', $value); + +$value = array("boolean" => array("value" => filter_var($context['passwordAuthentication'], FILTER_VALIDATE_BOOLEAN))); +vro_add_parameter_in_request($parameters, 'passwordAuthentication', 'boolean', $value); + +$value = array("Path" => array("value" => $context['vco_key_path'])); +vro_add_parameter_in_request($parameters, 'path', 'Path', $value); + +$value = array("SecureString" => array("value" => $context['passphrase'])); +vro_add_parameter_in_request($parameters, 'passphrase', 'SecureString', $value); + +$value = array("string" => array("value" => $context['encoding'])); +vro_add_parameter_in_request($parameters, 'encoding', 'string', $value); + +$parameters_array['parameters'] = $parameters; + +vro_execute_workflow_and_wait_for_completion(VRO_RUN_SSH_COMMAND_V9, $parameters_array); + +$result = $context['output_parameters']['result']; +$context['result'] = $result; +$output_text = $output_parameters['outputText']; +$context['output_text'] = $output_text; +$error_text = $output_parameters['errorText']; +$context['error_text'] = $error_text; + +$wo_comment = "Result : $result\nOutput text : $output_text\nError text : $error_text"; + +$response = prepare_json_response(ENDED, "SSH command executed successfully.\n$wo_comment", $context, true); +echo $response; + +?> \ No newline at end of file diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Set_VM_Performance.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Set_VM_Performance.php new file mode 100644 index 000000000..35f18615b --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Set_VM_Performance.php @@ -0,0 +1,80 @@ + array("type" => VC_VIRTUAL_MACHINE, "id" => $context['vm'])); +vro_add_parameter_in_request($parameters, 'vm', VC_VIRTUAL_MACHINE, $value); + +$value = array("boolean" => array("value" => filter_var($context['setCPU'], FILTER_VALIDATE_BOOLEAN))); +vro_add_parameter_in_request($parameters, 'setCPU', 'boolean', $value); + +$value = array("boolean" => array("value" => filter_var($context['setRAM'], FILTER_VALIDATE_BOOLEAN))); +vro_add_parameter_in_request($parameters, 'setRAM', 'boolean', $value); + +$value = array("boolean" => array("value" => filter_var($context['setDisk'], FILTER_VALIDATE_BOOLEAN))); +vro_add_parameter_in_request($parameters, 'setDisk', 'boolean', $value); + +$value = array("sdk-object" => array("type" => VC_SHARES_LEVEL, "id" => $context['cpuSharesLevel'])); +vro_add_parameter_in_request($parameters, 'cpuSharesLevel', VC_SHARES_LEVEL, $value); + +$value = array("number" => array("value" => $context['cpuShares'])); +vro_add_parameter_in_request($parameters, 'cpuShares', 'number', $value); + +$value = array("number" => array("value" => $context['cpuReservation'])); +vro_add_parameter_in_request($parameters, 'cpuReservation', 'number', $value); + +$value = array("number" => array("value" => $context['cpuLimit'])); +vro_add_parameter_in_request($parameters, 'cpuLimit', 'number', $value); + +$value = array("sdk-object" => array("type" => VC_SHARES_LEVEL, "id" => $context['ramSharesLevel'])); +vro_add_parameter_in_request($parameters, 'ramSharesLevel', VC_SHARES_LEVEL, $value); + +$value = array("number" => array("value" => $context['ramShares'])); +vro_add_parameter_in_request($parameters, 'ramShares', 'number', $value); + +$value = array("number" => array("value" => $context['ramReservation'])); +vro_add_parameter_in_request($parameters, 'ramReservation', 'number', $value); + +$value = array("number" => array("value" => $context['ramLimit'])); +vro_add_parameter_in_request($parameters, 'ramLimit', 'number', $value); + +$value = array("sdk-object" => array("type" => VC_SHARES_LEVEL, "id" => $context['diskSharesLevel'])); +vro_add_parameter_in_request($parameters, 'diskSharesLevel', VC_SHARES_LEVEL, $value); + +$value = array("number" => array("value" => $context['diskShares'])); +vro_add_parameter_in_request($parameters, 'diskShares', 'number', $value); + +$parameters_array['parameters'] = $parameters; + +vro_execute_workflow_and_wait_for_completion(VRO_SET_VM_PERFORMANCE_V30, $parameters_array); + +$response = prepare_json_response(ENDED, "VM Performance set successfully.", $context, true); +echo $response; + +?> \ No newline at end of file diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Start_VM_And_Wait.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Start_VM_And_Wait.php new file mode 100644 index 000000000..0ee75653c --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Start_VM_And_Wait.php @@ -0,0 +1,36 @@ + array("type" => VC_VIRTUAL_MACHINE, "id" => $context['vm'])); +vro_add_parameter_in_request($parameters, 'vm', VC_VIRTUAL_MACHINE, $value); + +$value = array("sdk-object" => array("type" => VC_HOST_SYSTEM, "id" => "{$vcenter_fqdn}/" . $context['host'])); +vro_add_parameter_in_request($parameters, 'host', VC_HOST_SYSTEM, $value); + +$parameters_array['parameters'] = $parameters; + +vro_execute_workflow_and_wait_for_completion(VRO_START_VM_AND_WAIT_V31, $parameters_array); + +$response = prepare_json_response(ENDED, "VM started successfully.", $context, true); +echo $response; + +?> diff --git a/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Suspend_VM_And_Wait.php b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Suspend_VM_And_Wait.php new file mode 100644 index 000000000..c485cf0bb --- /dev/null +++ b/Reference/VMWARE/vRO/Tasks/REST/vCenter/VM_Management/Task_vRO_Suspend_VM_And_Wait.php @@ -0,0 +1,30 @@ + array("type" => VC_VIRTUAL_MACHINE, "id" => $context['vm'])); +vro_add_parameter_in_request($parameters, 'vm', VC_VIRTUAL_MACHINE, $value); + +$parameters_array['parameters'] = $parameters; + +vro_execute_workflow_and_wait_for_completion(VRO_SUSPEND_VM_AND_WAIT_V20, $parameters_array); + +$response = prepare_json_response(ENDED, "VM supended successfully.", $context, true); +echo $response; + +?> \ No newline at end of file diff --git a/Topology/.meta_Process_Call_For_Device b/Topology/.meta_Process_Call_For_Device new file mode 100644 index 000000000..55c3942d6 --- /dev/null +++ b/Topology/.meta_Process_Call_For_Device @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1492682243720 + + + DATE_CREATION + 1492682243688 + + + TYPE + DIRECTORY + + + diff --git a/Topology/.meta_Process_Call_Service b/Topology/.meta_Process_Call_Service new file mode 100644 index 000000000..55c3942d6 --- /dev/null +++ b/Topology/.meta_Process_Call_Service @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1492682243720 + + + DATE_CREATION + 1492682243688 + + + TYPE + DIRECTORY + + + diff --git a/Topology/.meta_Process_Create_View b/Topology/.meta_Process_Create_View new file mode 100644 index 000000000..ea26ef15c --- /dev/null +++ b/Topology/.meta_Process_Create_View @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1490773172307 + + + DATE_CREATION + 1490773172299 + + + TYPE + DIRECTORY + + + diff --git a/Topology/.meta_Process_Delete_View b/Topology/.meta_Process_Delete_View new file mode 100644 index 000000000..1c5bee40f --- /dev/null +++ b/Topology/.meta_Process_Delete_View @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1490773212566 + + + DATE_CREATION + 1490773212558 + + + TYPE + DIRECTORY + + + diff --git a/Topology/.meta_Process_Save b/Topology/.meta_Process_Save new file mode 100644 index 000000000..d5e0cf50d --- /dev/null +++ b/Topology/.meta_Process_Save @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1497951270597 + + + DATE_CREATION + 1497951270561 + + + TYPE + DIRECTORY + + + diff --git a/Topology/.meta_Process_Update_View b/Topology/.meta_Process_Update_View new file mode 100644 index 000000000..a5907e48b --- /dev/null +++ b/Topology/.meta_Process_Update_View @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1490773202083 + + + DATE_CREATION + 1490773202076 + + + TYPE + DIRECTORY + + + diff --git a/Topology/.meta_Topology.xml b/Topology/.meta_Topology.xml new file mode 100644 index 000000000..f278c6cb2 --- /dev/null +++ b/Topology/.meta_Topology.xml @@ -0,0 +1,37 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1504251793276 + + + COMMENT + + + + REPOSITORY + CommandDefinition + + + DATE_CREATION + 1490773029592 + + + CONFIGURATION_FILTER + + + + TAG + Topology.xml + + + TYPE + UPLOAD + + + diff --git a/Topology/.meta_Topology_Types b/Topology/.meta_Topology_Types new file mode 100644 index 000000000..ea26ef15c --- /dev/null +++ b/Topology/.meta_Topology_Types @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1490773172307 + + + DATE_CREATION + 1490773172299 + + + TYPE + DIRECTORY + + + diff --git a/Topology/Process_Call_For_Device/.meta_Tasks b/Topology/Process_Call_For_Device/.meta_Tasks new file mode 100644 index 000000000..8ab4921ff --- /dev/null +++ b/Topology/Process_Call_For_Device/.meta_Tasks @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1490775312844 + + + DATE_CREATION + 1490775312837 + + + TYPE + DIRECTORY + + + diff --git a/Topology/Process_Call_For_Device/Tasks/.meta_Task_Call_For_Devicephp b/Topology/Process_Call_For_Device/Tasks/.meta_Task_Call_For_Devicephp new file mode 100644 index 000000000..4ac484a90 --- /dev/null +++ b/Topology/Process_Call_For_Device/Tasks/.meta_Task_Call_For_Devicephp @@ -0,0 +1,29 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1490775379501 + + + COMMENT + + + + DATE_CREATION + 1490775312860 + + + TAG + + + + TYPE + UPLOAD + + + diff --git a/Topology/Process_Call_For_Device/Tasks/Task_Call_For_Device.php b/Topology/Process_Call_For_Device/Tasks/Task_Call_For_Device.php new file mode 100644 index 000000000..7acb2a12c --- /dev/null +++ b/Topology/Process_Call_For_Device/Tasks/Task_Call_For_Device.php @@ -0,0 +1,44 @@ + \ No newline at end of file diff --git a/Topology/Process_Create_View/.meta_Tasks b/Topology/Process_Create_View/.meta_Tasks new file mode 100644 index 000000000..8ab4921ff --- /dev/null +++ b/Topology/Process_Create_View/.meta_Tasks @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1490775312844 + + + DATE_CREATION + 1490775312837 + + + TYPE + DIRECTORY + + + diff --git a/Topology/Process_Create_View/Tasks/.meta_Task_Create.php b/Topology/Process_Create_View/Tasks/.meta_Task_Create.php new file mode 100644 index 000000000..4ac484a90 --- /dev/null +++ b/Topology/Process_Create_View/Tasks/.meta_Task_Create.php @@ -0,0 +1,29 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1490775379501 + + + COMMENT + + + + DATE_CREATION + 1490775312860 + + + TAG + + + + TYPE + UPLOAD + + + diff --git a/Topology/Process_Create_View/Tasks/Task_Create.php b/Topology/Process_Create_View/Tasks/Task_Create.php new file mode 100644 index 000000000..70a772972 --- /dev/null +++ b/Topology/Process_Create_View/Tasks/Task_Create.php @@ -0,0 +1,25 @@ + \ No newline at end of file diff --git a/Topology/Process_Delete_View/.keep b/Topology/Process_Delete_View/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/Topology/Process_Save_View/.meta_Tasks b/Topology/Process_Save_View/.meta_Tasks new file mode 100644 index 000000000..8ab4921ff --- /dev/null +++ b/Topology/Process_Save_View/.meta_Tasks @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1490775312844 + + + DATE_CREATION + 1490775312837 + + + TYPE + DIRECTORY + + + diff --git a/Topology/Process_Save_View/Tasks/.meta_Task_Save.php b/Topology/Process_Save_View/Tasks/.meta_Task_Save.php new file mode 100644 index 000000000..4ac484a90 --- /dev/null +++ b/Topology/Process_Save_View/Tasks/.meta_Task_Save.php @@ -0,0 +1,29 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1490775379501 + + + COMMENT + + + + DATE_CREATION + 1490775312860 + + + TAG + + + + TYPE + UPLOAD + + + diff --git a/Topology/Process_Save_View/Tasks/Task_Save.php b/Topology/Process_Save_View/Tasks/Task_Save.php new file mode 100644 index 000000000..4e2368073 --- /dev/null +++ b/Topology/Process_Save_View/Tasks/Task_Save.php @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/Topology/Process_Update_View/.meta_Tasks b/Topology/Process_Update_View/.meta_Tasks new file mode 100644 index 000000000..f4c4fcfb3 --- /dev/null +++ b/Topology/Process_Update_View/.meta_Tasks @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1490775426577 + + + DATE_CREATION + 1490775426569 + + + TYPE + DIRECTORY + + + diff --git a/Topology/Process_Update_View/Tasks/.meta_Task_Manage_New.php b/Topology/Process_Update_View/Tasks/.meta_Task_Manage_New.php new file mode 100644 index 000000000..202eec391 --- /dev/null +++ b/Topology/Process_Update_View/Tasks/.meta_Task_Manage_New.php @@ -0,0 +1,29 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1490775426599 + + + COMMENT + + + + DATE_CREATION + 1490775426596 + + + TAG + + + + TYPE + UPLOAD + + + diff --git a/Topology/Process_Update_View/Tasks/.meta_Task_Update.php b/Topology/Process_Update_View/Tasks/.meta_Task_Update.php new file mode 100644 index 000000000..202eec391 --- /dev/null +++ b/Topology/Process_Update_View/Tasks/.meta_Task_Update.php @@ -0,0 +1,29 @@ + + + + + FILE_TYPE + text + + + DATE_MODIFICATION + 1490775426599 + + + COMMENT + + + + DATE_CREATION + 1490775426596 + + + TAG + + + + TYPE + UPLOAD + + + diff --git a/Topology/Process_Update_View/Tasks/Task_Manage_New.php b/Topology/Process_Update_View/Tasks/Task_Manage_New.php new file mode 100644 index 000000000..2672e7762 --- /dev/null +++ b/Topology/Process_Update_View/Tasks/Task_Manage_New.php @@ -0,0 +1,48 @@ + $value) { + $contains = false; + + if($value["subtype"] == "cluster") { + foreach ($context["Nodes_MAJ"] as $value2) { + if($value2["cluster_id"] == $value["object_id"]) { + $contains = true; + break; + } + } + } else { + foreach ($context["Nodes_MAJ"] as $value2) { + if($value2["object_id"] == $value["object_id"]) { + $contains = true; + break; + } + } + } + if(!$contains) { + $TO_DELETE[] = $key; + } +} + +foreach ($TO_DELETE as $value) { + unset($context["Nodes"][$value]); +} + +unset($context["Nodes_MAJ"]); + +echo prepare_json_response(ENDED, "The new devices are managed", $context, false); + +?> diff --git a/Topology/Process_Update_View/Tasks/Task_Update.php b/Topology/Process_Update_View/Tasks/Task_Update.php new file mode 100644 index 000000000..53206b29f --- /dev/null +++ b/Topology/Process_Update_View/Tasks/Task_Update.php @@ -0,0 +1,26 @@ + \ No newline at end of file diff --git a/Topology/Topology.xml b/Topology/Topology.xml new file mode 100644 index 000000000..45983345a --- /dev/null +++ b/Topology/Topology.xml @@ -0,0 +1,112 @@ + + + + + service_id + 5 + TRANSACTION + + /images/eclipseIcons/page_obj.gif + Topology + 10000 + 0 + 5 + true + false + true + 5 + + + + + + + + + + + + + + + + + + + + + 5 + Create + + false + CREATE + + /opt/fmc_repository/Process/Topology/Process_Create_View/Tasks/ + + Create + + + /opt/fmc_repository/Process/Topology/Process_Update_View/Tasks/ + + Manage_New + + + 0 + + + 5 + Update + + false + UPDATE + + /opt/fmc_repository/Process/Topology/Process_Update_View/Tasks/ + + Update + + + /opt/fmc_repository/Process/Topology/Process_Update_View/Tasks/ + + Manage_New + + + 0 + + + 5 + Delete + + false + DELETE + + 0 + + + + 0 + false + Device Polling + UPDATE + + /opt/fmc_repository/Process/Topology/Process_Call_For_Device/Tasks/ + + Call Service + + + 0 + + + + 0 + false + Save + UPDATE + + /opt/fmc_repository/Process/Topology/Process_Save_View/Tasks/ + + Save + + + 0 + + diff --git a/Topology/Topology_Types/.meta_SNMP b/Topology/Topology_Types/.meta_SNMP new file mode 100644 index 000000000..ea26ef15c --- /dev/null +++ b/Topology/Topology_Types/.meta_SNMP @@ -0,0 +1,17 @@ + + + + + DATE_MODIFICATION + 1490773172307 + + + DATE_CREATION + 1490773172299 + + + TYPE + DIRECTORY + + + diff --git a/Topology/Topology_Types/SNMP.php b/Topology/Topology_Types/SNMP.php new file mode 100644 index 000000000..285655e3c --- /dev/null +++ b/Topology/Topology_Types/SNMP.php @@ -0,0 +1,219 @@ +wo_newparams as $value) { + $deviceId = $value->id; + $name = $value->name; + //$error = launchParallelSNMP($deviceId, $name, $context ["view_type"]); + $error = singleSNMP($deviceId, $name, $context ["view_type"]); + + if ($error != "") { + logTofile(debug_dump($error, "***TOPOLOGY CREATE ERROR***")); + } + } + + return prepare_json_response(ENDED, "The topology has fully loaded", $context, false); +} + +function topology_update_view() { + global $context; + + if (!isset($context ["Nodes"])) { + $context ['Nodes'] = array (); + } + + if (!isset($context ["Nodes_MAJ"])) { + $context ['Nodes_MAJ'] = array (); + } + $list = json_decode(_lookup_list_devices_by_customer_reference($context ['UBIQUBEID']), false); + + foreach ($list->wo_newparams as $value) { + $deviceId = $value->id; + $name = $value->name; + //$error = launchParallelSNMP($deviceId, $name, $context ["view_type"]); + $error = singleSNMP($deviceId, $name, $context ["view_type"]); + + if ($error != "") { + logTofile(debug_dump($error, "***TOPOLOGY CREATE ERROR***")); + } + } + + return prepare_json_response(ENDED, "The topology has fully loaded", $context, false); +} + +// **********SERVICE FUNCTIONS********** // +function searchAdress($search, &$matches) { + return preg_match_all('#([0-9]{1,3})(\.[0-9]{1,3}){3}#', $search, $matches); +} + +function readInformationsFromDevice($device_id, &$community, &$address) { + $info = json_decode(_device_read_by_id($device_id), true); + + if ($info ["wo_status"] == "FAIL") { + return $info ["wo_comment"]; + } + + logTofile(debug_dump($info, "***TOPOLOGY READINFO INFODEVICE***")); + + $address = $info ["wo_newparams"] ["managementAddress"]; + $community = $info ["wo_newparams"] ["snmpCommunity"]; + + if ((empty($community) || $community == "") && (empty($address) || $address == "")) { + return "Site with id " . $device_id . " was not found"; + } else if (empty($community) || $community == "") { + return "Community of site with id " . $device_id . " was not found"; + } else if (empty($address) || $address == "") { + return "Address of site with id " . $device_id . " was not found"; + } else { + return ""; + } +} + +function calcMask($maskAdr) { + $maskPart = explode(".", $maskAdr); + $mask = ""; + foreach ($maskPart as $val) { + $mask .= decbin(intval($val)); + } + $pos = strpos($mask, "0"); + if ($pos !== false) { + return $pos; + } else { + return 32; + } +} + +function getNetworkByAddressAndMask($address, $mask) { + $addressParts = explode(".", $address); + $networkAddressBinary = ""; + foreach ($addressParts as $val) { + $morceauBinaire = decbin(intval($val)); + while (strlen($morceauBinaire) < 8) { + $morceauBinaire = "0" . $morceauBinaire; + } + $networkAddressBinary .= $morceauBinaire; + } + + $networkAddressBinary = substr($networkAddressBinary, 0, $mask); + while (strlen($networkAddressBinary) < 32) { + $networkAddressBinary .= "0"; + } + + $addressMasked = ""; + for($i = 0; $i < 32; $i = $i + 8) { + $part = intval(substr($networkAddressBinary, $i, 8), 2); + $addressMasked .= $part . "."; + } + + $addressMasked = substr($addressMasked, 0, strlen($addressMasked) - 1); + return $addressMasked; +} + +function singleSNMP($device_id, $name) { + try { + $status = getStatus($device_id); + if($status == "UP") { + startSNMPForDevice($device_id, $name); + } else { + if($status == "UNREACHABLE") { + createTopology($device_id, $name, "router", "style/topology/img/router_ERROR.svg"); + } else if($status == "NEVERREACHED") { + createTopology($device_id, $name, "router", "style/topology/img/router_NEVERREACHED.svg"); + } else if($status == "CRITICAL") { + createTopology($device_id, $name, "router", "style/topology/img/router_CRITICAL.svg"); + } + } + } catch (Exception $e) { + logTofile(debug_dump($e, "**************TOPOLOGY ERROR **************")); + echo prepare_json_response(FAILED, "FAILED", $context, true); + exit; + } +} + +function launchParallelSNMP($deviceId, $name, $view_type) { + global $context; + global $process_id; + + $ubiqube_id = $context ['UBIQUBEID']; + $service_instance = $context ['SERVICEINSTANCEID']; + + $service_name = "Process/Topology/Topology"; + $process_name = "Process/Topology/Process_Call_For_Device"; + + $add_service_array = $context; + $add_service_array ['device_id'] = $deviceId; + $add_service_array ['name'] = $name; + $json_body = json_encode($add_service_array); + + _orchestration_launch_sub_process($ubiqube_id, $service_instance, $service_name, $process_name, $json_body); + + logTofile("***TOPOLOGY LAUNCH SNMP $deviceId * $name***"); +} + +function startSNMPForDevice($deviceId, $name) { + global $context; + global $DO_NOT_DELETE; + + $nodePlace = createTopology($deviceId, $name, "router", "style/topology/img/router_OK.svg"); + $error = readInformationsFromDevice($deviceId, $community, $address); + + if ($error == "") { + try { + checkSNMPResponds($community, $address); + $cmd = "snmpwalk -v2c -c $community $address IP-MIB::ipAdEntNetMask 2>&1"; + logTofile(debug_dump($cmd, "***TOPOLOGY SNMP COMMAND***")); + exec($cmd, $value, $error); + if (!$error) { + $rep = array (); + foreach ($value as $search) { + if (searchAdress($search, $matches) != false) { + if ($matches [1] [0] != 127) { + $address_link = $matches [0] [0]; + $maskAdr = $matches [0] [1]; + $mask = calcMask($maskAdr); + $address_link_masked = getNetworkByAddressAndMask($address_link, $mask); + $addressAndMask = $address_link_masked . "/" . $mask; + createTopology(str_replace(".", "_", $addressAndMask), $addressAndMask, "network", ""); + $context ['Nodes'] [$nodePlace] ["link"] [] ["id"] = $addressAndMask; + } + } + } + } else { + logTofile(debug_dump($value, "***TOPOLOGY START ERROR_1***")); + } + } catch (Exception $e) { + logTofile(debug_dump($e->getMessage(), "***TOPOLOGY START ERROR_2***")); + } + } else { + logTofile(debug_dump($error, "***TOPOLOGY START ERROR_3***")); + } +} + +function getStatus($device_id) { + $info = json_decode(_device_get_status($device_id), true); + $status = $info ["wo_newparams"]; + + if (empty($status) || $status == "") { + return "Site with id " . $device_id . " was not found"; + } else { + return $status; + } +} + +function checkSNMPResponds($community, $address) { + $cmd_SNMP_RESPOND = "timeout 1 snmpwalk -v2c -c $community $address SNMPv2-MIB::sysName 2>&1"; + exec($cmd_SNMP_RESPOND, $value, $error); + if ($error) { + throw new Exception("SNMP NOT AVAILABLE ON " . $address); + } +} +?> diff --git a/Topology/Topology_Types/Template.php b/Topology/Topology_Types/Template.php new file mode 100644 index 000000000..a4b9f9bc5 --- /dev/null +++ b/Topology/Topology_Types/Template.php @@ -0,0 +1,15 @@ + \ No newline at end of file diff --git a/Topology/Topology_Types/VLAN/VLAN.php b/Topology/Topology_Types/VLAN/VLAN.php new file mode 100644 index 000000000..4d3eac006 --- /dev/null +++ b/Topology/Topology_Types/VLAN/VLAN.php @@ -0,0 +1,146 @@ +wo_newparams as $value) { + $deviceId = $value->id; + $ubiId = $value->ubiId; + $name = $value->name; + logTofile(debug_dump($deviceId, "***TOPOLOGY VLAN DEVICEID***")); + + $status = getStatus($deviceId); + logTofile(debug_dump($status, "***TOPOLOGY VLAN STATUS***")); + $nodePlace = -1; + if ($status == "UP") { + $error = startVLANForDevice($deviceId, $ubiId, $name, $nodePlace); + if ($error) { + logTofile(debug_dump($error, "***TOPOLOGY VLAN ERROR***")); + } + } else { + if ($status == "UNREACHABLE") { + createTopology($deviceId, $name, "router", "style/topology/img/router_ERROR.svg"); + } else if ($status == "NEVERREACHED") { + createTopology($deviceId, $name, "router", "style/topology/img/router_NEVERREACHED.svg"); + } else if ($status == "CRITICAL") { + createTopology($deviceId, $name, "router", "style/topology/img/router_CRITICAL.svg"); + } + } + } + + $context ["Nodes"] = $GLOBALS ["Nodes"]; + $ret = prepare_json_response(ENDED, "The topology has fully loaded", $context, true); + return $ret; +} +function topology_update_view($context) { + logTofile(debug_dump($context, "***TOPOLOGY VLAN CONTEXT***")); + if (isset($context ["Nodes"])) { + $GLOBALS ["Nodes"] = $context ["Nodes"]; + unset($context ["Nodes"]); + } else { + $GLOBALS ["Nodes"] = array (); + } + $GLOBALS ["DO_NOT_DESTROY"] = array (); + + $ubiqube_id = $context ['UBIQUBEID']; + + $list = json_decode(_lookup_list_devices_by_customer_reference($ubiqube_id)); + + foreach ($list->wo_newparams as $value) { + $deviceId = $value->id; + $ubiId = $value->ubiId; + $name = $value->name; + + array_push($GLOBALS ["DO_NOT_DESTROY"], $deviceId); + + logTofile(debug_dump($deviceId, "***TOPOLOGY VLAN DEVICEID***")); + + $nodePlace = -1; + $status = getStatus($deviceId); + logTofile(debug_dump($status, "***TOPOLOGY VLAN STATUS***")); + if ($status == "UP") { + $error = startVLANForDevice($deviceId, $ubiId, $name, $nodePlace); + if ($error != "") { + logTofile(debug_dump($error, "***TOPOLOGY VLAN ERROR***")); + } + } else { + if ($status == "UNREACHABLE") { + $nodePlace = createTopology($deviceId, $name, "router", "style/topology/img/router_ERROR.svg"); + } else if ($status == "NEVERREACHED") { + $nodePlace = createTopology($deviceId, $name, "router", "style/topology/img/router_NEVERREACHED.svg"); + } else if ($status == "CRITICAL") { + $nodePlace = createTopology($deviceId, $name, "router", "style/topology/img/router_CRITICAL.svg"); + } + } + + $cluster_id = $GLOBALS ["Nodes"] [$nodePlace] ["cluster_id"]; + if (!in_array($cluster_id, $GLOBALS ["DO_NOT_DESTROY"])) { + array_push($GLOBALS ["DO_NOT_DESTROY"], $cluster_id); + } + } + + foreach ($GLOBALS ["Nodes"] as $key => $value_verif) { + $destroy = true; + foreach ($GLOBALS ["DO_NOT_DESTROY"] as $value_not_destroy) { + if ($value_verif ["object_id"] == $value_not_destroy) { + $destroy = false; + } + } + if ($destroy) { + unset($GLOBALS ["Nodes"] [$key]); + } + } + + $context ["Nodes"] = $GLOBALS ["Nodes"]; + logTofile(debug_dump($context, "***TOPOLOGY VLAN CONTEXT***")); + return prepare_json_response(ENDED, "The topology has fully loaded", $context, true); +} + +// **********SERVICE FUNCTIONS********** // +// Don't delete $nodeplace : it's use in Update +function startVLANForDevice($deviceId, $ubiId, $name, &$nodePlace) { + $nodePlace = createTopology($deviceId, $name, "router", "style/topology/img/router_OK.svg"); + + $instances_objname = "vlan"; + $array = array ( + $instances_objname + ); + $vlans = json_decode(import_objects($deviceId, $array))->wo_newparams->vlan; + foreach ($vlans as $vlan) { + if (!in_array($vlan->object_id, $GLOBALS ["DO_NOT_DESTROY"])) { + array_push($GLOBALS ["DO_NOT_DESTROY"], $vlan->object_id); + } + + if ($vlan->object_id == 1) { + createTopology($vlan->object_id, $vlan->name, "vlan", "", "#AA3BF2"); + } else { + createTopology($vlan->object_id, $vlan->name, "vlan", ""); + } + $GLOBALS ["Nodes"] [$nodePlace] ["link"] [] ["id"] = $vlan->object_id; + } + + logTofile(debug_dump($GLOBALS ["Nodes"], "***TOPOLOGY GLOBALS***")); + return false; +} + +function getStatus($device_id) { + $cmd = "/opt/ubi-jentreprise/bin/api/device/getDeviceStatus.sh " . $device_id; + $res = shell_exec($cmd); + + preg_match('#[A-Za-z]*#', $res, $matches); + $status = substr($matches [0], 8, -9); + + if (empty($status) || $status == "") { + return "Site with id " . $device_id . " was not found"; + } else { + return $status; + } +} +?> \ No newline at end of file