mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
removing the tags support in the update commands for disk and service offerings
This commit is contained in:
parent
0876136dc4
commit
e5e128545d
@ -47,8 +47,8 @@ public class UpdateDiskOfferingCmd extends BaseCmd{
|
|||||||
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="updates name of the disk offering with this value")
|
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="updates name of the disk offering with this value")
|
||||||
private String diskOfferingName;
|
private String diskOfferingName;
|
||||||
|
|
||||||
@Parameter(name=ApiConstants.TAGS, type=CommandType.STRING, description="update tags of the disk offering with this value")
|
// @Parameter(name=ApiConstants.TAGS, type=CommandType.STRING, description="update tags of the disk offering with this value")
|
||||||
private String tags;
|
// private String tags;
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
/////////////////// Accessors ///////////////////////
|
/////////////////// Accessors ///////////////////////
|
||||||
@ -66,9 +66,9 @@ public class UpdateDiskOfferingCmd extends BaseCmd{
|
|||||||
return diskOfferingName;
|
return diskOfferingName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTags() {
|
// public String getTags() {
|
||||||
return tags;
|
// return tags;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
/////////////// API Implementation///////////////////
|
/////////////// API Implementation///////////////////
|
||||||
|
|||||||
@ -50,8 +50,8 @@ public class UpdateServiceOfferingCmd extends BaseCmd {
|
|||||||
@Parameter(name=ApiConstants.OFFER_HA, type=CommandType.BOOLEAN, description="the HA of the service offering to be updated")
|
@Parameter(name=ApiConstants.OFFER_HA, type=CommandType.BOOLEAN, description="the HA of the service offering to be updated")
|
||||||
private Boolean offerHa;
|
private Boolean offerHa;
|
||||||
|
|
||||||
@Parameter(name=ApiConstants.TAGS, type=CommandType.STRING, description="the tags for this service offering.")
|
// @Parameter(name=ApiConstants.TAGS, type=CommandType.STRING, description="the tags for this service offering.")
|
||||||
private String tags;
|
// private String tags;
|
||||||
|
|
||||||
@Parameter(name=ApiConstants.USE_VIRTUAL_NETWORK, type=CommandType.BOOLEAN, description="if true, the VM created from the offering will use default virtual networking. If false, the VM created will use a direct attached networking model. The default value is true.")
|
@Parameter(name=ApiConstants.USE_VIRTUAL_NETWORK, type=CommandType.BOOLEAN, description="if true, the VM created from the offering will use default virtual networking. If false, the VM created will use a direct attached networking model. The default value is true.")
|
||||||
private Boolean useVirtualNetwork;
|
private Boolean useVirtualNetwork;
|
||||||
@ -76,9 +76,9 @@ public class UpdateServiceOfferingCmd extends BaseCmd {
|
|||||||
return offerHa;
|
return offerHa;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTags() {
|
// public String getTags() {
|
||||||
return tags;
|
// return tags;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public Boolean getUseVirtualNetwork() {
|
public Boolean getUseVirtualNetwork() {
|
||||||
return useVirtualNetwork;
|
return useVirtualNetwork;
|
||||||
|
|||||||
@ -1145,7 +1145,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||||||
Long id = cmd.getId();
|
Long id = cmd.getId();
|
||||||
String name = cmd.getServiceOfferingName();
|
String name = cmd.getServiceOfferingName();
|
||||||
Boolean ha = cmd.getOfferHa();
|
Boolean ha = cmd.getOfferHa();
|
||||||
String tags = cmd.getTags();
|
// String tags = cmd.getTags();
|
||||||
Boolean useVirtualNetwork = cmd.getUseVirtualNetwork();
|
Boolean useVirtualNetwork = cmd.getUseVirtualNetwork();
|
||||||
Long userId = UserContext.current().getUserId();
|
Long userId = UserContext.current().getUserId();
|
||||||
|
|
||||||
@ -1159,7 +1159,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "unable to find service offering " + id);
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "unable to find service offering " + id);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean updateNeeded = (name != null || displayText != null || ha != null || useVirtualNetwork != null || tags != null);
|
boolean updateNeeded = (name != null || displayText != null || ha != null || useVirtualNetwork != null);
|
||||||
if (!updateNeeded) {
|
if (!updateNeeded) {
|
||||||
return _serviceOfferingDao.findById(id);
|
return _serviceOfferingDao.findById(id);
|
||||||
}
|
}
|
||||||
@ -1182,28 +1182,28 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||||||
NetworkOffering.GuestIpType guestIpType = useVirtualNetwork ? NetworkOffering.GuestIpType.Virtualized : NetworkOffering.GuestIpType.DirectSingle;
|
NetworkOffering.GuestIpType guestIpType = useVirtualNetwork ? NetworkOffering.GuestIpType.Virtualized : NetworkOffering.GuestIpType.DirectSingle;
|
||||||
offering.setGuestIpType(guestIpType);
|
offering.setGuestIpType(guestIpType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tags != null)
|
// if (tags != null)
|
||||||
{
|
// {
|
||||||
if (tags.trim().isEmpty() && offeringHandle.getTags() == null)
|
// if (tags.trim().isEmpty() && offeringHandle.getTags() == null)
|
||||||
{
|
// {
|
||||||
//no new tags; no existing tags
|
// //no new tags; no existing tags
|
||||||
offering.setTagsArray(csvTagsToList(null));
|
// offering.setTagsArray(csvTagsToList(null));
|
||||||
}
|
// }
|
||||||
else if (!tags.trim().isEmpty() && offeringHandle.getTags() != null)
|
// else if (!tags.trim().isEmpty() && offeringHandle.getTags() != null)
|
||||||
{
|
// {
|
||||||
//new tags + existing tags
|
// //new tags + existing tags
|
||||||
List<String> oldTags = csvTagsToList(offeringHandle.getTags());
|
// List<String> oldTags = csvTagsToList(offeringHandle.getTags());
|
||||||
List<String> newTags = csvTagsToList(tags);
|
// List<String> newTags = csvTagsToList(tags);
|
||||||
oldTags.addAll(newTags);
|
// oldTags.addAll(newTags);
|
||||||
offering.setTagsArray(oldTags);
|
// offering.setTagsArray(oldTags);
|
||||||
}
|
// }
|
||||||
else if(!tags.trim().isEmpty())
|
// else if(!tags.trim().isEmpty())
|
||||||
{
|
// {
|
||||||
//new tags; NO existing tags
|
// //new tags; NO existing tags
|
||||||
offering.setTagsArray(csvTagsToList(tags));
|
// offering.setTagsArray(csvTagsToList(tags));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (_serviceOfferingDao.update(id, offering)) {
|
if (_serviceOfferingDao.update(id, offering)) {
|
||||||
offering = _serviceOfferingDao.findById(id);
|
offering = _serviceOfferingDao.findById(id);
|
||||||
@ -1258,7 +1258,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||||||
Long diskOfferingId = cmd.getId();
|
Long diskOfferingId = cmd.getId();
|
||||||
String name = cmd.getDiskOfferingName();
|
String name = cmd.getDiskOfferingName();
|
||||||
String displayText = cmd.getDisplayText();
|
String displayText = cmd.getDisplayText();
|
||||||
String tags = cmd.getTags();
|
// String tags = cmd.getTags();
|
||||||
|
|
||||||
//Check if diskOffering exists
|
//Check if diskOffering exists
|
||||||
DiskOfferingVO diskOfferingHandle = _diskOfferingDao.findById(diskOfferingId);
|
DiskOfferingVO diskOfferingHandle = _diskOfferingDao.findById(diskOfferingId);
|
||||||
@ -1267,7 +1267,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||||||
throw new InvalidParameterValueException("Unable to find disk offering by id " + diskOfferingId);
|
throw new InvalidParameterValueException("Unable to find disk offering by id " + diskOfferingId);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean updateNeeded = (name != null || displayText != null || tags != null);
|
boolean updateNeeded = (name != null || displayText != null);
|
||||||
if (!updateNeeded) {
|
if (!updateNeeded) {
|
||||||
return _diskOfferingDao.findById(diskOfferingId);
|
return _diskOfferingDao.findById(diskOfferingId);
|
||||||
}
|
}
|
||||||
@ -1282,27 +1282,27 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||||||
diskOffering.setDisplayText(displayText);
|
diskOffering.setDisplayText(displayText);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tags != null)
|
// if (tags != null)
|
||||||
{
|
// {
|
||||||
if (tags.trim().isEmpty() && diskOfferingHandle.getTags() == null)
|
// if (tags.trim().isEmpty() && diskOfferingHandle.getTags() == null)
|
||||||
{
|
// {
|
||||||
//no new tags; no existing tags
|
// //no new tags; no existing tags
|
||||||
diskOffering.setTagsArray(csvTagsToList(null));
|
// diskOffering.setTagsArray(csvTagsToList(null));
|
||||||
}
|
// }
|
||||||
else if (!tags.trim().isEmpty() && diskOfferingHandle.getTags() != null)
|
// else if (!tags.trim().isEmpty() && diskOfferingHandle.getTags() != null)
|
||||||
{
|
// {
|
||||||
//new tags + existing tags
|
// //new tags + existing tags
|
||||||
List<String> oldTags = csvTagsToList(diskOfferingHandle.getTags());
|
// List<String> oldTags = csvTagsToList(diskOfferingHandle.getTags());
|
||||||
List<String> newTags = csvTagsToList(tags);
|
// List<String> newTags = csvTagsToList(tags);
|
||||||
oldTags.addAll(newTags);
|
// oldTags.addAll(newTags);
|
||||||
diskOffering.setTagsArray(oldTags);
|
// diskOffering.setTagsArray(oldTags);
|
||||||
}
|
// }
|
||||||
else if(!tags.trim().isEmpty())
|
// else if(!tags.trim().isEmpty())
|
||||||
{
|
// {
|
||||||
//new tags; NO existing tags
|
// //new tags; NO existing tags
|
||||||
diskOffering.setTagsArray(csvTagsToList(tags));
|
// diskOffering.setTagsArray(csvTagsToList(tags));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (_diskOfferingDao.update(diskOfferingId, diskOffering)) {
|
if (_diskOfferingDao.update(diskOfferingId, diskOffering)) {
|
||||||
saveConfigurationEvent(UserContext.current().getUserId(), null, EventTypes.EVENT_DISK_OFFERING_EDIT, "Successfully updated disk offering with name: " + diskOffering.getName() + ".", "doId=" + diskOffering.getId(), "name=" + diskOffering.getName(),
|
saveConfigurationEvent(UserContext.current().getUserId(), null, EventTypes.EVENT_DISK_OFFERING_EDIT, "Successfully updated disk offering with name: " + diskOffering.getName() + ".", "doId=" + diskOffering.getId(), "name=" + diskOffering.getName(),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user