Skip to content
Snippets Groups Projects
Commit 8b01d082 authored by xiaohua guan's avatar xiaohua guan Committed by Yas Naoi
Browse files

Issue #3248632 by Xiaohua Guan, yas: Delete and bulk delete elastic IP from...

Issue #3248632 by Xiaohua Guan, yas: Delete and bulk delete  elastic IP from Cloud Orchestrator master to workers (AWS Cloud)
parent e04f43ef
No related branches found
No related tags found
No related merge requests found
......@@ -29,27 +29,37 @@ class ElasticIpDeleteForm extends AwsDeleteUpdateEntityForm {
$params['AllocationId'] = $allocation_id;
$params['NetworkBorderGroup'] = $entity->getNetworkBorderGroup();
}
if (!empty($entity)
&& !empty($params)
&& !empty($this->ec2Service->releaseAddress($params))) {
// Update instances after the Elastic IP is deleted.
if ($entity->getEntityTypeId() === 'aws_cloud_elastic_ip') {
$this->ec2Service->updateInstances();
}
$form_state->setRedirect("view.{$entity->getEntityTypeId()}.list", ['cloud_context' => $entity->getCloudContext()]);
$entity->delete();
$result = $this->ec2Service->releaseAddress($params);
$this->messenger->addStatus($this->getDeletionMessage());
$this->logDeletionMessage();
$this->clearCacheValues($entity->getCacheTags());
$this->dispatchSubmitEvent($entity);
}
else {
// If $result is NULL, some error should have occurred
// when calling the AWS API.
if ($result === NULL) {
$this->processOperationErrorStatus($entity, 'deleted');
return;
}
$form_state->setRedirect("view.{$entity->getEntityTypeId()}.list", ['cloud_context' => $entity->getCloudContext()]);
if (!empty($result['SendToWorker'])) {
$this->messenger->addStatus($this->t('The @type @label has been deleted remotely.', [
'@type' => $entity->getEntityType()->getSingularLabel(),
'@label' => $entity->getName(),
]));
return;
}
// Update instances after the Elastic IP is deleted.
if ($entity->getEntityTypeId() === 'aws_cloud_elastic_ip') {
$this->ec2Service->updateInstances();
}
$entity->delete();
$this->messenger->addStatus($this->getDeletionMessage());
$this->logDeletionMessage();
$this->clearCacheValues($entity->getCacheTags());
$this->dispatchSubmitEvent($entity);
}
}
......@@ -1042,7 +1042,7 @@ class Ec2Service extends CloudServiceBase implements Ec2ServiceInterface {
* {@inheritdoc}
*/
public function releaseAddress(array $params = []): ?ResultInterface {
return $this->execute('ReleaseAddress', $params);
return $this->execute('ReleaseAddress', $params, [], 'updateElasticIps', []);
}
/**
......
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