Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
+++ b/modules/cloud_service_providers/aws_cloud/src/Controller/Ec2/ApiController.php
@@ -163,7 +163,13 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
+ if ($updated !== FALSE) {
@@ -342,7 +330,13 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
+ if ($updated !== FALSE) {
@@ -392,7 +374,13 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
+ if ($updated !== FALSE) {
@@ -508,7 +473,13 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
+ if ($updated !== FALSE) {
@@ -558,7 +517,13 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
+ if ($updated !== FALSE) {
@@ -609,7 +562,13 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
+ if ($updated !== FALSE) {
+++ b/modules/cloud_service_providers/aws_cloud/src/Controller/Vpc/ApiController.php
@@ -118,7 +115,13 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
+ if ($updated !== FALSE) {
@@ -169,7 +160,13 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
+ if ($updated !== FALSE) {
@@ -220,7 +205,13 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
+ if ($updated !== FALSE) {
+++ b/modules/cloud_service_providers/aws_cloud/src/Service/Ec2/Ec2Service.php
@@ -3200,4 +3216,96 @@ class Ec2Service extends CloudServiceBase implements Ec2ServiceInterface {
+ if ($updated !== FALSE) {
...
+ if ($updated !== FALSE) {
...
+ if ($updated !== FALSE) {
Is there any reason why you didn't use $updated === TRUE here?
+++ b/modules/cloud_service_providers/aws_cloud/src/Controller/Ec2/ApiController.php
@@ -177,9 +183,13 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
public function updateAllInstanceList() {
@@ -356,29 +350,17 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
public function updateAllSecurityGroupList() {
@@ -406,9 +394,13 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
public function updateAllNetworkInterfaceList() {
@@ -456,44 +448,17 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
public function updateAllElasticIpList() {
@@ -522,29 +493,17 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
public function updateAllKeyPairList() {
@@ -572,29 +537,17 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
public function updateAllVolumeList() {
@@ -623,9 +582,13 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
public function updateAllSnapshotList() {
+++ b/modules/cloud_service_providers/aws_cloud/src/Controller/Vpc/ApiController.php
@@ -132,29 +135,17 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
public function updateAllVpcList() {
@@ -183,29 +180,17 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
public function updateAllVpcPeeringConnectionList() {
@@ -234,9 +225,13 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
public function updateAllSubnetList() {
Can you refactor to aggregate those updateAll*List() methods to e.g. updateAllResourceList()?
+++ b/modules/cloud_service_providers/aws_cloud/src/Service/Ec2/Ec2Service.php
@@ -3200,4 +3216,96 @@ class Ec2Service extends CloudServiceBase implements Ec2ServiceInterface {
+ public function updateEntityMessage($entity_type, $cloud_context, $cloud_config, $updated) {
Can you refactor the logic in the method to even simpler? (Reducing or aggregating if-statement)
+++ b/src/Entity/CloudConfig.php
@@ -340,6 +340,29 @@ class CloudConfig extends CloudContentEntityBase implements CloudConfigInterface
+ public function getResourceLink($plural_label, $entity_type, $cloud_context) {
Do we need the parameter $cloud_context? Because this is CloudConfig entity, so it should hold the $cloud_context inside the instance. (Can we use getCloudContext() in getResourceLink()?)
Since we have to support a custom case for aws_elastic_ips, how about we use a "switch" statement, where the default case is the code inside if ($entity_type_name !== 'aws_cloud_image)?
We can then have switch cases for 'aws_cloud_image' and 'aws_cloud_elastic_ips'..etc...
+++ b/src/Entity/CloudConfig.php
@@ -340,6 +340,27 @@ class CloudConfig extends CloudContentEntityBase implements CloudConfigInterface
+ public function getResourceLink($plural_label, $entity_type) {
If this is a public method, please add a definition in CloudConfigInterface
1. Ec2Service::clearCacheValue(); is used for update*List() not for updateAll*List() method. $this->clearCacheValue(); is used for updateAll*List() so both are using for different methods.
I moved $this->clearCacheValue(); into updateAllResourceList() instead of updateEntityMessage().
2. Moved Elastic Ip logic into updateAllResourceList() with status messages from updateEntityMessage().
3. I initialized $account_id to NULL.
4. We can not declare it as private as it is used in ApiController. I added updateAllResourceList() in Ec2ServiceInterface.
5. Converted the logic into switch case.
6. Added getResourceLink() in CloudConfigInterface.
Comments
Comment #2
jigish.addweb CreditAttribution: jigish.addweb at AddWeb Solution Pvt. Ltd. commentedComment #3
jigish.addweb CreditAttribution: jigish.addweb at AddWeb Solution Pvt. Ltd. commentedComment #4
yasIs there any reason why you didn't use
$updated === TRUE
here?Can you refactor to aggregate those
updateAll*List()
methods to e.g.updateAllResourceList()
?Can you refactor the logic in the method to even simpler? (Reducing or aggregating
if
-statement)Do we need the parameter $cloud_context? Because this is CloudConfig entity, so it should hold the $cloud_context inside the instance. (Can we use
getCloudContext()
ingetResourceLink()
?)Comment #5
jigish.addweb CreditAttribution: jigish.addweb at AddWeb Solution Pvt. Ltd. commentedComment #6
jigish.addweb CreditAttribution: jigish.addweb at AddWeb Solution Pvt. Ltd. commented@yas
Thank you for your review.
1. There was a condition for FALSE (i.e.
$updated !== FALSE
) so that I had followed that code but now, I have changed it to$updated === TRUE
.2. Refactored the code of
updateAll*List()
methods and added common methodupdateAllResourceList()
.3. Reduced if-statements as much as possible.
4. Removed
$cloud_context
parameter and usedgetCloudContext()
instead of$cloud_context
.Please review updated patch.
Thanks
Comment #7
yas@jigishaddweb
Thank you for the update.
Can we refactor as follows?
FROM:
TO:
Comment #8
jigish.addweb CreditAttribution: jigish.addweb at AddWeb Solution Pvt. Ltd. commentedComment #9
jigish.addweb CreditAttribution: jigish.addweb at AddWeb Solution Pvt. Ltd. commented@yas
I have done changes as per your comment. Please review updated patch.
Thanks
Comment #10
jigish.addweb CreditAttribution: jigish.addweb at AddWeb Solution Pvt. Ltd. commented@yas
I have added permission to each AWS entity. Please review this updated patch.
Thanks
Comment #11
yas@jigishaddweb
Thank you for the update.
Let's reduce the if-statement nest and adding
!empty()
:FROM:
TO:
@xiaohua-guan, @baldwinloue
What do you think in the other portion?
Comment #12
jigish.addweb CreditAttribution: jigish.addweb at AddWeb Solution Pvt. Ltd. commentedComment #13
jigish.addweb CreditAttribution: jigish.addweb at AddWeb Solution Pvt. Ltd. commented@yas
I did changes as per your comment. Please review the new patch.
Thanks
Comment #14
baldwinlouie CreditAttribution: baldwinlouie commented@jigishaddweb, Thank you for the updated patch. I have the following comments.
clearCacheValue()
can potentially be called twice per API operation. Once inside theupdate*List()
and once inside theupdateEntityMessage
method.Please choose one place to call the cache clear.
I think it should be in the
APIController
code and not insideupdateEntityMessage
.updateEntityMessage
should only be for setting messages.When an Elastic Ip is updated, there is code that updates the NetworkInterfaces as well. This code needs to be moved to
updateAllResourceList
as well.Please initialize
$account_id
to something. There is a chance $account_id can be returned uninitialized.If this is a public method, please put this in
ApiControllerInterface
. If it is only meant to be a helper method, please make this private.This method should also catch the following exceptions:
Since we have to support a custom case for aws_elastic_ips, how about we use a "switch" statement, where the default case is the code inside
if ($entity_type_name !== 'aws_cloud_image)
?We can then have switch cases for 'aws_cloud_image' and 'aws_cloud_elastic_ips'..etc...
If this is a public method, please add a definition in
CloudConfigInterface
Comment #15
jigish.addweb CreditAttribution: jigish.addweb at AddWeb Solution Pvt. Ltd. commentedComment #16
jigish.addweb CreditAttribution: jigish.addweb at AddWeb Solution Pvt. Ltd. commented@baldwinlouie
Thank you for reviewing the patch.
1.
Ec2Service::clearCacheValue();
is used forupdate*List()
not forupdateAll*List()
method.$this->clearCacheValue();
is used forupdateAll*List()
so both are using for different methods.I moved
$this->clearCacheValue();
intoupdateAllResourceList()
instead ofupdateEntityMessage()
.2. Moved Elastic Ip logic into
updateAllResourceList()
with status messages fromupdateEntityMessage()
.3. I initialized
$account_id
to NULL.4. We can not declare it as private as it is used in
ApiController
. I addedupdateAllResourceList()
inEc2ServiceInterface
.5. Converted the logic into switch case.
6. Added
getResourceLink()
inCloudConfigInterface
.Please review the updated patch.
Thanks
Comment #17
baldwinlouie CreditAttribution: baldwinlouie commented@jigishaddweb, thank you for the updated patch. Please see my comments below.
I think it is better to catch the exceptions in the method and display an error message.
The methods that call
updateallResourceList
do not catch the exceptions. Thus, there is a chance we get a White Screen due to a 500 error.I think you can get rid of
$account = $this->currentUser()
and useSince we are not using
$account
again.Comment #18
jigish.addweb CreditAttribution: jigish.addweb at AddWeb Solution Pvt. Ltd. commentedComment #19
jigish.addweb CreditAttribution: jigish.addweb at AddWeb Solution Pvt. Ltd. commented@baldwinlouie
I did changes as per your comment. Please review the new patch.
Thanks
Comment #20
baldwinlouie CreditAttribution: baldwinlouie commented@jigishaddweb, thank you for the patch. It looks good now!
Comment #21
yas@baldwinlouie
Thank you for your review. I'll merge the patch to
8.x-1.x
,8.x-2.x
and3.x
and close this issue asFixed
.Comment #25
yas