Loading modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/aws_cloud/instance.ts +11 −0 Changes for modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/aws_cloud/instance.ts: 11 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -163,7 +163,18 @@ const AWS_CLOUD_INSTANCE_TEMPLATE: EntityFormTemplate[] = [ ] } ] }, { cloudServiceProvider: 'aws_cloud', entityName: 'instance', actionType: 'reboot', entityRecords: [ { type: 'label', text: 'Are you sure you want to reboot the {{name}} {{entityName}}?', } ], }, ] export default AWS_CLOUD_INSTANCE_TEMPLATE; modules/cloud_service_providers/aws_cloud/aws_cloud.routing.yml +10 −9 Changes for modules/cloud_service_providers/aws_cloud/aws_cloud.routing.yml: 10 added lines, 9 removed lines. Original line number Diff line number Diff line Loading @@ -957,15 +957,6 @@ entity.aws_cloud_instance.stop: requirements: _entity_access: 'aws_cloud_instance.stop' entity.aws_cloud_instance.reboot: path: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_instance/{entity_id}/reboot' defaults: _controller: '\Drupal\aws_cloud\Controller\Ec2\ApiController::operateInstance' command: reboot methods: [POST] requirements: _entity_access: 'aws_cloud_instance.reboot' entity.aws_cloud_instance.delete: path: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_instance/{entity_id}/delete' defaults: Loading Loading @@ -1009,3 +1000,13 @@ entity.aws_cloud_instance.edit: _custom_access: '\Drupal\cloud\Controller\CloudConfigController::access' options: perm: 'edit any aws cloud instance+edit own aws cloud instance' entity.aws_cloud_instance.reboot: path: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_instance/{entity_id}/reboot' defaults: _controller: '\Drupal\aws_cloud\Controller\Ec2\ApiController::operateEntity' entity_type_id: aws_cloud_instance command: reboot methods: [POST] requirements: _entity_access: 'aws_cloud_instance.reboot' modules/cloud_service_providers/aws_cloud/src/Controller/Ec2/ApiController.php +4 −0 Changes for modules/cloud_service_providers/aws_cloud/src/Controller/Ec2/ApiController.php: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -866,6 +866,10 @@ class ApiController extends ControllerBase implements ApiControllerInterface { $method_name = 'editInstance'; break; case 'reboot_aws_cloud_instance': $method_name = 'rebootInstance'; break; } // Execute the process. Loading modules/cloud_service_providers/aws_cloud/src/Form/Ec2/InstanceRebootForm.php +7 −14 Changes for modules/cloud_service_providers/aws_cloud/src/Form/Ec2/InstanceRebootForm.php: 7 added lines, 14 removed lines. Original line number Diff line number Diff line Loading @@ -23,11 +23,11 @@ use Symfony\Component\DependencyInjection\ContainerInterface; class InstanceRebootForm extends AwsDeleteUpdateEntityForm { /** * The AWS Cloud EC2 operation service. * The AWS Cloud Operations service. * * @var \Drupal\aws_cloud\Service\Ec2\Ec2OperationsServiceInterface * @var \Drupal\aws_cloud\Service\AwsCloud\AwsCloudOperationsServiceInterface */ private $ec2OperationsService; protected $awsCloudOperationsService; /** * InstanceRebootForm constructor. Loading Loading @@ -55,7 +55,8 @@ class InstanceRebootForm extends AwsDeleteUpdateEntityForm { * @param \Drupal\cloud\Plugin\cloud\config\CloudConfigPluginManagerInterface $cloud_config_plugin_manager * The cloud service provider plugin manager (CloudConfigPluginManager). */ public function __construct(Ec2ServiceInterface $ec2_service, public function __construct( Ec2ServiceInterface $ec2_service, Ec2OperationsServiceInterface $ec2_operations_service, EntityRepositoryInterface $entity_repository, EntityTypeBundleInfoInterface $entity_type_bundle_info, Loading @@ -79,7 +80,7 @@ class InstanceRebootForm extends AwsDeleteUpdateEntityForm { $cloud_config_plugin_manager ); $this->ec2OperationsService = $ec2_operations_service; $this->awsCloudOperationsService = $ec2_operations_service; } /** Loading Loading @@ -127,15 +128,7 @@ class InstanceRebootForm extends AwsDeleteUpdateEntityForm { * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state): void { $entity = $this->entity; if (!$this->updateEntitySubmitForm($form_state, $entity)) { return; } $this->ec2OperationsService->rebootInstance($entity); $form_state->setRedirect("view.{$this->entity->getEntityTypeId()}.list", ['cloud_context' => $this->entity->getCloudContext()]); $this->awsCloudOperationsService->rebootInstance($this->entity); } } modules/cloud_service_providers/aws_cloud/src/Service/AwsCloud/AwsCloudOperationsService.php +32 −0 Changes for modules/cloud_service_providers/aws_cloud/src/Service/AwsCloud/AwsCloudOperationsService.php: 32 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -557,6 +557,38 @@ class AwsCloudOperationsService implements AwsCloudOperationsServiceInterface { } } /** * {@inheritdoc} */ public function rebootInstance(InstanceInterface $entity, array $form, FormStateInterface $form_state): void { if (!$this->updateEntitySubmitForm($form_state, $entity)) { return; } $this->ec2Service->setCloudContext($entity->getCloudContext()); $result = $this->ec2Service->rebootInstances([ 'InstanceIds' => [ $entity->getInstanceId(), ], ]); if (empty($result)) { $this->processOperationErrorStatus($entity, 'rebooted'); $form_state->setRedirect("view.{$this->entity->getEntityTypeId()}.list", ['cloud_context' => $entity->getCloudContext()]); return; } if (!empty($result['SendToWorker'])) { $this->processOperationStatus($entity, 'rebooted remotely'); $form_state->setRedirect("view.{$this->entity->getEntityTypeId()}.list", ['cloud_context' => $entity->getCloudContext()]); return; } $this->processOperationStatus($entity, 'rebooted'); $this->clearCacheValues($entity->getCacheTags()); $form_state->setRedirect("view.{$this->entity->getEntityTypeId()}.list", ['cloud_context' => $entity->getCloudContext()]); } /** * Helper function to update field tags. * Loading Loading
modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/aws_cloud/instance.ts +11 −0 Changes for modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/aws_cloud/instance.ts: 11 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -163,7 +163,18 @@ const AWS_CLOUD_INSTANCE_TEMPLATE: EntityFormTemplate[] = [ ] } ] }, { cloudServiceProvider: 'aws_cloud', entityName: 'instance', actionType: 'reboot', entityRecords: [ { type: 'label', text: 'Are you sure you want to reboot the {{name}} {{entityName}}?', } ], }, ] export default AWS_CLOUD_INSTANCE_TEMPLATE;
modules/cloud_service_providers/aws_cloud/aws_cloud.routing.yml +10 −9 Changes for modules/cloud_service_providers/aws_cloud/aws_cloud.routing.yml: 10 added lines, 9 removed lines. Original line number Diff line number Diff line Loading @@ -957,15 +957,6 @@ entity.aws_cloud_instance.stop: requirements: _entity_access: 'aws_cloud_instance.stop' entity.aws_cloud_instance.reboot: path: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_instance/{entity_id}/reboot' defaults: _controller: '\Drupal\aws_cloud\Controller\Ec2\ApiController::operateInstance' command: reboot methods: [POST] requirements: _entity_access: 'aws_cloud_instance.reboot' entity.aws_cloud_instance.delete: path: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_instance/{entity_id}/delete' defaults: Loading Loading @@ -1009,3 +1000,13 @@ entity.aws_cloud_instance.edit: _custom_access: '\Drupal\cloud\Controller\CloudConfigController::access' options: perm: 'edit any aws cloud instance+edit own aws cloud instance' entity.aws_cloud_instance.reboot: path: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_instance/{entity_id}/reboot' defaults: _controller: '\Drupal\aws_cloud\Controller\Ec2\ApiController::operateEntity' entity_type_id: aws_cloud_instance command: reboot methods: [POST] requirements: _entity_access: 'aws_cloud_instance.reboot'
modules/cloud_service_providers/aws_cloud/src/Controller/Ec2/ApiController.php +4 −0 Changes for modules/cloud_service_providers/aws_cloud/src/Controller/Ec2/ApiController.php: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -866,6 +866,10 @@ class ApiController extends ControllerBase implements ApiControllerInterface { $method_name = 'editInstance'; break; case 'reboot_aws_cloud_instance': $method_name = 'rebootInstance'; break; } // Execute the process. Loading
modules/cloud_service_providers/aws_cloud/src/Form/Ec2/InstanceRebootForm.php +7 −14 Changes for modules/cloud_service_providers/aws_cloud/src/Form/Ec2/InstanceRebootForm.php: 7 added lines, 14 removed lines. Original line number Diff line number Diff line Loading @@ -23,11 +23,11 @@ use Symfony\Component\DependencyInjection\ContainerInterface; class InstanceRebootForm extends AwsDeleteUpdateEntityForm { /** * The AWS Cloud EC2 operation service. * The AWS Cloud Operations service. * * @var \Drupal\aws_cloud\Service\Ec2\Ec2OperationsServiceInterface * @var \Drupal\aws_cloud\Service\AwsCloud\AwsCloudOperationsServiceInterface */ private $ec2OperationsService; protected $awsCloudOperationsService; /** * InstanceRebootForm constructor. Loading Loading @@ -55,7 +55,8 @@ class InstanceRebootForm extends AwsDeleteUpdateEntityForm { * @param \Drupal\cloud\Plugin\cloud\config\CloudConfigPluginManagerInterface $cloud_config_plugin_manager * The cloud service provider plugin manager (CloudConfigPluginManager). */ public function __construct(Ec2ServiceInterface $ec2_service, public function __construct( Ec2ServiceInterface $ec2_service, Ec2OperationsServiceInterface $ec2_operations_service, EntityRepositoryInterface $entity_repository, EntityTypeBundleInfoInterface $entity_type_bundle_info, Loading @@ -79,7 +80,7 @@ class InstanceRebootForm extends AwsDeleteUpdateEntityForm { $cloud_config_plugin_manager ); $this->ec2OperationsService = $ec2_operations_service; $this->awsCloudOperationsService = $ec2_operations_service; } /** Loading Loading @@ -127,15 +128,7 @@ class InstanceRebootForm extends AwsDeleteUpdateEntityForm { * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state): void { $entity = $this->entity; if (!$this->updateEntitySubmitForm($form_state, $entity)) { return; } $this->ec2OperationsService->rebootInstance($entity); $form_state->setRedirect("view.{$this->entity->getEntityTypeId()}.list", ['cloud_context' => $this->entity->getCloudContext()]); $this->awsCloudOperationsService->rebootInstance($this->entity); } }
modules/cloud_service_providers/aws_cloud/src/Service/AwsCloud/AwsCloudOperationsService.php +32 −0 Changes for modules/cloud_service_providers/aws_cloud/src/Service/AwsCloud/AwsCloudOperationsService.php: 32 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -557,6 +557,38 @@ class AwsCloudOperationsService implements AwsCloudOperationsServiceInterface { } } /** * {@inheritdoc} */ public function rebootInstance(InstanceInterface $entity, array $form, FormStateInterface $form_state): void { if (!$this->updateEntitySubmitForm($form_state, $entity)) { return; } $this->ec2Service->setCloudContext($entity->getCloudContext()); $result = $this->ec2Service->rebootInstances([ 'InstanceIds' => [ $entity->getInstanceId(), ], ]); if (empty($result)) { $this->processOperationErrorStatus($entity, 'rebooted'); $form_state->setRedirect("view.{$this->entity->getEntityTypeId()}.list", ['cloud_context' => $entity->getCloudContext()]); return; } if (!empty($result['SendToWorker'])) { $this->processOperationStatus($entity, 'rebooted remotely'); $form_state->setRedirect("view.{$this->entity->getEntityTypeId()}.list", ['cloud_context' => $entity->getCloudContext()]); return; } $this->processOperationStatus($entity, 'rebooted'); $this->clearCacheValues($entity->getCacheTags()); $form_state->setRedirect("view.{$this->entity->getEntityTypeId()}.list", ['cloud_context' => $entity->getCloudContext()]); } /** * Helper function to update field tags. * Loading