Loading modules/cloud_service_providers/openstack/src/Service/OpenStackOperationsService.php +32 −0 Original line number Diff line number Diff line Loading @@ -3227,6 +3227,38 @@ class OpenStackOperationsService implements OpenStackOperationsServiceInterface * {@inheritdoc} */ public function deleteOpenStackServerGroup(OpenStackServerGroupInterface $entity, array &$form, FormStateInterface $form_state): bool { $this->entity = $entity; /** @var Drupal\openstack\Service\Rest\OpenStackService $ec2_service */ $ec2_service = $this->openStackServiceFactory->get($entity->getCloudContext()); $this->ec2Service = $ec2_service; $this->awsCloudOperationsService->setEc2Service($this->ec2Service); $form_state->setRedirect("view.{$entity->getEntityTypeId()}.list", ['cloud_context' => $entity->getCloudContext()]); $this->ec2Service->setCloudContext($entity->getCloudContext()); $result = $this->ec2Service->deleteServerGroup([ 'ServerGroupId' => $entity->getServerGroupId(), ]); if ($result === NULL) { $this->processOperationErrorStatus($entity, 'deleted'); return FALSE; } if (!empty($result['SendToWorker'])) { $this->processOperationStatus($entity, 'deleted remotely'); return TRUE; } $entity->delete(); $this->messenger->addStatus($this->getDeletionMessage()); $this->logDeletionMessage(); $this->clearCacheValues($entity->getCacheTags()); $this->dispatchSaveEvent($entity); return TRUE; } Loading modules/cloud_service_providers/openstack/src/Service/Rest/OpenStackService.php +26 −0 Original line number Diff line number Diff line Loading @@ -6027,6 +6027,32 @@ class OpenStackService extends CloudServiceBase implements OpenStackServiceInter return $updated; } /** * Delete server group. * * @param array $params * Parameters to pass to the API. * * @return array|null * Succeeded or failed. */ public function deleteServerGroup(array $params = []): ?array { if ($this->isWorkerResource()) { $this->saveOperation(__FUNCTION__, [$params], 'updateServerGroups'); return ['SendToWorker' => TRUE]; } $credentials = [ 'http_method' => 'delete', 'endpoint' => $this->getEndpoint(OpenStackServiceInterface::COMPUTE_SERVICE, "/os-server-groups/{$params['ServerGroupId']}"), ]; $response = $this->getClient($credentials); return $response['status_code'] === 204 ? ['Success' => TRUE] : NULL; } /** * {@inheritdoc} */ Loading Loading
modules/cloud_service_providers/openstack/src/Service/OpenStackOperationsService.php +32 −0 Original line number Diff line number Diff line Loading @@ -3227,6 +3227,38 @@ class OpenStackOperationsService implements OpenStackOperationsServiceInterface * {@inheritdoc} */ public function deleteOpenStackServerGroup(OpenStackServerGroupInterface $entity, array &$form, FormStateInterface $form_state): bool { $this->entity = $entity; /** @var Drupal\openstack\Service\Rest\OpenStackService $ec2_service */ $ec2_service = $this->openStackServiceFactory->get($entity->getCloudContext()); $this->ec2Service = $ec2_service; $this->awsCloudOperationsService->setEc2Service($this->ec2Service); $form_state->setRedirect("view.{$entity->getEntityTypeId()}.list", ['cloud_context' => $entity->getCloudContext()]); $this->ec2Service->setCloudContext($entity->getCloudContext()); $result = $this->ec2Service->deleteServerGroup([ 'ServerGroupId' => $entity->getServerGroupId(), ]); if ($result === NULL) { $this->processOperationErrorStatus($entity, 'deleted'); return FALSE; } if (!empty($result['SendToWorker'])) { $this->processOperationStatus($entity, 'deleted remotely'); return TRUE; } $entity->delete(); $this->messenger->addStatus($this->getDeletionMessage()); $this->logDeletionMessage(); $this->clearCacheValues($entity->getCacheTags()); $this->dispatchSaveEvent($entity); return TRUE; } Loading
modules/cloud_service_providers/openstack/src/Service/Rest/OpenStackService.php +26 −0 Original line number Diff line number Diff line Loading @@ -6027,6 +6027,32 @@ class OpenStackService extends CloudServiceBase implements OpenStackServiceInter return $updated; } /** * Delete server group. * * @param array $params * Parameters to pass to the API. * * @return array|null * Succeeded or failed. */ public function deleteServerGroup(array $params = []): ?array { if ($this->isWorkerResource()) { $this->saveOperation(__FUNCTION__, [$params], 'updateServerGroups'); return ['SendToWorker' => TRUE]; } $credentials = [ 'http_method' => 'delete', 'endpoint' => $this->getEndpoint(OpenStackServiceInterface::COMPUTE_SERVICE, "/os-server-groups/{$params['ServerGroupId']}"), ]; $response = $this->getClient($credentials); return $response['status_code'] === 204 ? ['Success' => TRUE] : NULL; } /** * {@inheritdoc} */ Loading