diff --git a/api/src/com/cloud/api/commands/UpdateServiceOfferingCmd.java b/api/src/com/cloud/api/commands/UpdateServiceOfferingCmd.java index 0233bfa1065..80fe6140ff3 100644 --- a/api/src/com/cloud/api/commands/UpdateServiceOfferingCmd.java +++ b/api/src/com/cloud/api/commands/UpdateServiceOfferingCmd.java @@ -39,11 +39,14 @@ public class UpdateServiceOfferingCmd extends BaseCmd { @Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, description="the display text of the service offering to be updated") private String displayText; - @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the service offering to be updated") - private Long id; + @Parameter(name=ApiConstants.IS_PUBLIC, type=CommandType.BOOLEAN, description="if the service offering needs to be made public , we can only go from private to public and not vice versa") + private Boolean isPublic; @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the service offering to be updated") private String serviceOfferingName; + + @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the service offering to be updated") + private Long id; ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// @@ -61,7 +64,9 @@ public class UpdateServiceOfferingCmd extends BaseCmd { return serviceOfferingName; } - + public Boolean getIsPublic() { + return isPublic; + } ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index 56c7121d044..b547073610c 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -1304,7 +1304,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura Long id = cmd.getId(); String name = cmd.getServiceOfferingName(); Long userId = UserContext.current().getCallerUserId(); - + Boolean isPublic = cmd.getIsPublic(); + if (userId == null) { userId = Long.valueOf(User.UID_SYSTEM); } @@ -1316,6 +1317,10 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura } boolean updateNeeded = (name != null || displayText != null); + + if(isPublic != null && isPublic) + updateNeeded = true; + if (!updateNeeded) { return _serviceOfferingDao.findById(id); } @@ -1329,6 +1334,10 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura if (displayText != null) { offering.setDisplayText(displayText); } + + if(isPublic != null && isPublic) { + offering.setDomainId(null); + } //Note: tag editing commented out for now; keeping the code intact, might need to re-enable in next releases // if (tags != null)