Skip to content
Snippets Groups Projects
Commit 564da5b5 authored by baldwinlouie's avatar baldwinlouie Committed by Yas Naoi
Browse files

Issue #3175291 by baldwinlouie, yas: Display a warning message before...

Issue #3175291 by baldwinlouie, yas: Display a warning message before terminate (delete) Cloud Orchestrator itself
parent 994d15e5
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,16 @@ use Drupal\Core\Form\FormStateInterface;
*/
class InstanceDeleteForm extends AwsDeleteUpdateEntityForm {
/**
* {@inheritdoc}
*/
public function getQuestion() {
if ($this->ec2Service->isInstanceCloudOrchestrator($this->entity->getInstanceId()) === TRUE) {
$this->messenger()->addWarning($this->t('Attempting to delete Cloud Orchestrator instance. Cloud Orchestrator will stop responding and all data will not be recovered.'));
}
return parent::getQuestion();
}
/**
* {@inheritdoc}
*/
......
......@@ -2,6 +2,7 @@
namespace Drupal\aws_cloud\Form\Ec2;
use Drupal\aws_cloud\Entity\Ec2\Instance;
use Drupal\cloud\Entity\CloudContentEntityBase;
/**
......@@ -9,6 +10,30 @@ use Drupal\cloud\Entity\CloudContentEntityBase;
*/
class InstanceDeleteMultipleForm extends AwsCloudDeleteMultipleForm {
/**
* {@inheritdoc}
*/
public function getQuestion() {
$this->checkCloudOrchestratorIp();
return parent::getQuestion();
}
/**
* Check if Cloud Orchestrator is being terminated.
*
* Notify the user with a warning message if Cloud Orchestrator's IP
* is one of the selected IPs.
*/
private function checkCloudOrchestratorIp(): void {
foreach ($this->selection as $id => $selection) {
$instance = Instance::load($id);
if (!empty($instance) && $this->ec2Service->isInstanceCloudOrchestrator($instance->getInstanceId()) === TRUE) {
$this->messenger()->addWarning($this->t('Attempting to delete Cloud Orchestrator instance. Cloud Orchestrator will stop responding and all data will not be recovered.'));
break;
}
}
}
/**
* {@inheritdoc}
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment