Comments

jigish.addweb created an issue. See original summary.

jigish.addweb’s picture

Status: Active » Needs review
StatusFileSize
new40.92 KB
yas’s picture

@jigishaddweb

Thank you for adding the feature. Please refer to my comment at #3121323-4.

Also,

+++ b/modules/cloud_service_providers/openstack/config/schema/openstack.settings.schema.yml
@@ -1,5 +1,5 @@
 openstack.settings:
   type: config_object
   mapping:
-    openstack_cloud_config_icon:
+    openstack_config_icon:

This should remain the same as the original one, openstack_cloud_config_icon is correct since the magic format is <MODULE_NAME>_cloud_config_icon.

jigish.addweb’s picture

Status: Needs work » Needs review
StatusFileSize
new60.17 KB
new39.45 KB

@yas

I refactored the code as per your comment.

Please test updated patch.

Thanks

jigish.addweb’s picture

StatusFileSize
new59.87 KB
new1.98 KB

@yas

I deleted OpenStackImageInterface file as that is not empty interface.

Please test new patch.

Thanks

jigish.addweb’s picture

StatusFileSize
new73.45 KB
new34.31 KB

@yas

I refactored the code.

Please test updated patch.

Thanks

yas’s picture

Status: Needs review » Needs work

@jigishaddweb

Thank you for the update. The following is my feedback:

+++ b/modules/cloud_service_providers/aws_cloud/src/Form/Ec2/AwsCloudContentForm.php
@@ -2,7 +2,6 @@
+  public function __construct($ec2_service,

Need to modify PHPDoc


+++ b/modules/cloud_service_providers/aws_cloud/src/Form/Ec2/ImageCreateForm.php

      $this->setTagsInAws($entity->getImageId(), [
        Image::TAG_CREATED_BY_UID => $entity->getOwner()->id(),
        'Name' => $entity->getName(),
      ]);

Need to add the entity type name in front of Image::TAG_CREATED_BY_UID as a prefix like ImageEditForm ("{$entity->getEntityTypeId()}_{Image::TAG_CREATED_BY_UID}").


FROM:

+++ b/modules/cloud_service_providers/aws_cloud/src/Form/Ec2/ImageDeleteForm.php
+    if ($entity->getEntityTypeId() === 'aws_cloud_image' && ($entity->getAccountId() !== $account_id) ||
+      $this->ec2Service->deregisterImage([

TO:

    if ($entity->getEntityTypeId() === 'aws_cloud_image' && ($entity->getAccountId() !== $account_id)
    || $this->ec2Service->deregisterImage([

+++ b/modules/cloud_service_providers/aws_cloud/src/Form/Ec2/ImageDeleteMultipleForm.php
@@ -15,7 +15,8 @@ class ImageDeleteMultipleForm extends AwsCloudDeleteMultipleForm {

-    if ($entity->getAccountId() !== $account_id) {
+
+    if ($entity->getEntityTypeId() === 'aws_cloud_image' && $entity->getAccountId() !== $account_id) {

Please put the comment for the reason why you changed this condition.


+++ b/modules/cloud_service_providers/openstack/openstack.links.action.yml

+######################
+# OpenStack Cloud Instance.
+######################

...

+##################
+# OpenStack Cloud Image.
+##################

...

+  title: 'Add OpenStack Cloud Image'

OpenStack Cloud → OpenStack


+++ b/modules/cloud_service_providers/openstack/openstack.links.task.yml
@@ -66,12 +66,18 @@ entity.openstack_instance.delete_form:

+  title: 'Add Openstack Image'

openstack → OpenStack


FROM:

+++ b/modules/cloud_service_providers/openstack/openstack.permissions.yml

+  description: 'Allow users to list Amazon machine image (AMI)'

TO:

  description: 'Allow users to list OpenStack images'

+++ b/modules/cloud_service_providers/openstack/openstack.routing.yml
@@ -147,3 +147,25 @@ openstack.settings.options:
+# OpenStack Cloud Images Routes.

OpenStack Cloud → OpenStack


+++ b/modules/cloud_service_providers/openstack/src/Entity/OpenStackImage.php
@@ -0,0 +1,55 @@

+  public const TAG_CREATED_BY_UID = 'created_by_uid';

This change should happen in Drupal\aws_cloud\Entity\Ec2\ImageInterface


+++ b/modules/cloud_service_providers/openstack/src/Entity/OpenStackImageViewsData.php
@@ -15,6 +15,20 @@ class ImageViewsData extends AwsCloudViewsData {

+      'title' => $this->t('OpenStack Cloud Image'),
+      'help'  => $this->t('The OpenStack Cloud Image entity ID.'),

OpenStack Cloud → OpenStack

jigish.addweb’s picture

Status: Needs work » Needs review
StatusFileSize
new75.25 KB
new9.04 KB

@yas

Thank you for reviewing the patch.

I changed the code as per your above comment.

Please test updated patch.

Thanks

yas’s picture

Status: Needs review » Needs work

As per we discussed on online meeting, let us change the status to Needs work.

jigish.addweb’s picture

Status: Needs work » Needs review
StatusFileSize
new77.31 KB
new9.33 KB

@yas

I have done all changes as per our discussion of online meeting.

Please review the new patch.

Thanks

jigish.addweb’s picture

StatusFileSize
new79.7 KB
new8.6 KB

@yas

I have done some changes in code.

Please test new patch.

Thanks

baldwinlouie’s picture

@jigish, I have the following comments.

  1. +++ b/modules/cloud_service_providers/openstack/src/Controller/ApiController.php
    @@ -248,6 +250,33 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
    +   */
    

    Can you add a @thow \Exception comment to the comment?

  2. I'm attaching a screenshot of a permission error I am encountering. I configured it so that "Authenticated users" can only view their own Images. In the screenshot, the browser is logged in as an "Authenticated user", but can still see the entire list of images.

    The issue happens because Views does not perform permission checking on each entity returned in a query result.

    To fix, please review aws_cloud_query_aws_cloud_image_views_access_alter() , and ImageViewsData class . You will need to add a query tag in the views definition. For example in ImageViewsData: $data['aws_cloud_image']['table']['base']['access query tag'] = 'aws_cloud_image_views_access';

    Then in openstack.module, you will need to implement something similar to aws_cloud_query_aws_cloud_image_views_access_alter(AlterableInterface $query) to check if an openstack_cloud_image uid = $account->id()

jigish.addweb’s picture

Status: Needs work » Needs review
StatusFileSize
new81.32 KB
new4.38 KB

@baldwinlouie

I fixed the permission issue and done changes as per your above comment.

Please review new patch.

Thanks

baldwinlouie’s picture

@jigish,

Thank you for the changes. I tested it locally, and it looks good to me.

yas’s picture

@baldwinlouie

Thank you for your review.

@jigishaddweb

Thank you for the update. The patch looks beautiful now, so I'll merge the patch to 8.x-1.x and 8.x-2.x and close this issue as Fixed.

  • yas committed 524d95a on 8.x-1.x authored by jigish.addweb
    Issue #3121489 by jigish.addweb, baldwinlouie, yas: Manage OpenStack...

  • yas committed bd56a57 on 8.x-2.x authored by jigish.addweb
    Issue #3121489 by jigish.addweb, baldwinlouie, yas: Manage OpenStack...
yas’s picture

Status: Reviewed & tested by the community » Fixed
yas’s picture

Status: Fixed » Needs work

@jigishaddweb

I'm re-opening this issue:

  1. I found the following warnings by phpcs. We don't need to implement __construct since the parent constructor now accepts $ec2_service as an object? Could you please check it?
    $ phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md /var/www/html/web/modules/contrib/cloud
    
    FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/openstack/src/Controller/ApiController.php
    ------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------
     270 | ERROR | Throws comment indentation must be 3 spaces, found 2 spaces
    ------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/openstack/src/Form/OpenStackImageDeleteForm.php
    -----------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------
     43 | WARNING | Possible useless method overriding detected
    -----------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/openstack/src/Form/OpenStackImageEditForm.php
    ---------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------------------
     55 | WARNING | Possible useless method overriding detected
    ---------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/openstack/src/Form/OpenStackImageCreateForm.php
    -----------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------
     56 | WARNING | Possible useless method overriding detected
    -----------------------------------------------------------------------------------------------------------------------------
  2. Also, can we remove the following code?

    https://git.drupalcode.org/project/cloud/-/blob/8.x-2.x/modules/cloud_se...

    $this->tempStore = $temp_store_factory->get('entity_delete_multiple_confirm');

    Could you please check it?

jigish.addweb’s picture

Status: Needs work » Needs review
StatusFileSize
new22.06 KB

@yas

I fixed the coding standard violations and removed the code as per your previous comment.

Please test the new patch.

Thanks

yas’s picture

Status: Needs review » Reviewed & tested by the community

@jigishaddweb

Thank you for the refactoring. It looks good to me now. I'll merge the patch to 8.x-1.x and 8.x-2.x and close this issue as Fixed.

  • yas committed 6dd0721 on 8.x-1.x authored by jigish.addweb
    Issue #3121489 by jigish.addweb, baldwinlouie, yas: Hotfix - Manage...

  • yas committed ac757aa on 8.x-2.x authored by jigish.addweb
    Issue #3121489 by jigish.addweb, baldwinlouie, yas: Hotfix - Manage...
yas’s picture

Status: Reviewed & tested by the community » Fixed
yas’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.