slavkap commented on a change in pull request #5043:
URL: https://github.com/apache/cloudstack/pull/5043#discussion_r649147183



##########
File path: 
server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java
##########
@@ -3332,14 +3312,14 @@ public DiskOffering updateDiskOffering(final 
UpdateDiskOfferingCmd cmd) {
     }
 
     /**
-     * Check the tags parameters to the diskOffering
+     * Check the tags parameters to the disk/service offering
      * <ul>
      *     <li>If tags is null, do nothing and return.</li>
-     *     <li>If tags is not null, set tag to the diskOffering.</li>
-     *     <li>If tags is an blank string, set null on diskOffering tag.</li>
+     *     <li>If tags is not null, set tag to the disk/service offering.</li>
+     *     <li>If tags is an blank string, set null on disk/service offering 
tag.</li>
      * </ul>
      */
-    protected void updateDiskOfferingTagsIfIsNotNull(String tags, 
DiskOfferingVO diskOffering) {
+    protected void updateOfferingTagsIfIsNotNull(String tags, DiskOfferingVO 
diskOffering) {
         if (tags == null) { return; }
         if (StringUtils.isNotBlank(tags)) {
             diskOffering.setTags(tags);

Review comment:
       @SadiJr, both methods are absolutely the same, with one difference that 
this one updates the storage tags and updateServiceOfferingHostTagsIfNotNull 
updates the host tags. And with both, you can add/remove tags
   
        protected void updateOfferingTagsIfIsNotNull(String tags, 
DiskOfferingVO diskOffering) {
           if (tags == null) { return; }
           if (StringUtils.isNotBlank(tags)) {
               diskOffering.setTags(tags);
           } else {
               diskOffering.setTags(null);
           }
       }
   
       /**
        * Check the host tags parameters to the service offering
        * <ul>
        *     <li>If host tags is null, do nothing and return.</li>
        *     <li>If host tags is not null, set host tag to the service 
offering.</li>
        *     <li>If host tags is an blank string, set null on service offering 
tag.</li>
        * </ul>
        */
       protected void updateServiceOfferingHostTagsIfNotNull(String hostTags, 
ServiceOfferingVO offering) {
           if (hostTags == null) {
               return;
           }
           if (StringUtils.isNotBlank(hostTags)) {
               offering.setHostTag(hostTags);
           } else {
               offering.setHostTag(null);
           }
       }
    
    
   set the storage tags:
   
   
http://localhost:5050/client/api/?id=86a7d7bd-42a1-4d78-be8f-51a13f3eef7c&amp;name=Small
 Instance&amp;displaytext=Small Instance&amp;tags=tag1, 
tag2&amp;command=updateServiceOffering&amp;response=json
   
   response:
   
   
   ```
    {
        "updateserviceofferingresponse": {
                "serviceoffering": {
                        "id": "86a7d7bd-42a1-4d78-be8f-51a13f3eef7c",
                        "name": "Small Instance",
                        "displaytext": "Small Instance",
                        "cpunumber": 1,
                        "cpuspeed": 500,
                        "memory": 512,
                        "created": "2021-02-26T07:38:24+0200",
                        "storagetype": "shared",
                        "provisioningtype": "thin",
                        "offerha": false,
                        "limitcpuuse": false,
                        "isvolatile": false,
                        "tags": "tag1, tag2",
                        "hosttags": "",
                        "issystem": false,
                        "defaultuse": false,
                        "iscustomized": false,
                        "rootdisksize": 0
                }
        }
    }
   ```
   
   
   remove the storage tags:
   
   
http://localhost:5050/client/api/?id=86a7d7bd-42a1-4d78-be8f-51a13f3eef7c&name=Small
 Instance&displaytext=Small 
Instance&tags=&command=updateServiceOffering&response=json
   
      and the response:
      
   
   ```
       {
        "updateserviceofferingresponse": {
                "serviceoffering": {
                        "id": "86a7d7bd-42a1-4d78-be8f-51a13f3eef7c",
                        "name": "Small Instance",
                        "displaytext": "Small Instance",
                        "cpunumber": 1,
                        "cpuspeed": 500,
                        "memory": 512,
                        "created": "2021-02-26T07:38:24+0200",
                        "storagetype": "shared",
                        "provisioningtype": "thin",
                        "offerha": false,
                        "limitcpuuse": false,
                        "isvolatile": false,
                        "hosttags": "",
                        "issystem": false,
                        "defaultuse": false,
                        "iscustomized": false,
                        "rootdisksize": 0
                }
        }
    }
   ```
    




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to