Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public class UpdateSecurityGroupCmd extends BaseCustomIdCmd {
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "The new name of the security group.")
private String name;

@Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "The new description of the security group.")
private String description;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
Expand All @@ -60,6 +63,10 @@ public String getName() {
return name;
}

public String getDescription() {
return description;
}

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

@Override
public long getDomainId() {
return domainId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1168,19 +1168,20 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
public SecurityGroup updateSecurityGroup(UpdateSecurityGroupCmd cmd) {
final Long groupId = cmd.getId();
final String newName = cmd.getName();
final String newDescription = cmd.getDescription();
Account caller = CallContext.current().getCallingAccount();

SecurityGroupVO group = _securityGroupDao.findById(groupId);
if (group == null) {
throw new InvalidParameterValueException("Unable to find security group: " + groupId + "; failed to update security group.");
}

if (newName == null) {
logger.debug("security group [{}] name is not changed.", group);
if (newName == null && newDescription == null) {
logger.debug("security group [{}] is not changed.", group);
return group;
}

if (StringUtils.isBlank(newName)) {
if (newName != null && StringUtils.isBlank(newName)) {
throw new InvalidParameterValueException("Security group name cannot be empty");
}

Expand All @@ -1195,18 +1196,22 @@ public SecurityGroupVO doInTransaction(TransactionStatus status) {
throw new InvalidParameterValueException("Unable to find security group by id " + groupId);
}

if (newName.equals(group.getName())) {
if (newName != null && newName.equals(group.getName())) {
logger.debug("security group [{}] name is not changed.", group);
return group;
} else if (newName.equalsIgnoreCase(SecurityGroupManager.DEFAULT_GROUP_NAME)) {
} else if (newName != null && newName.equalsIgnoreCase(SecurityGroupManager.DEFAULT_GROUP_NAME)) {
throw new InvalidParameterValueException("The security group name " + SecurityGroupManager.DEFAULT_GROUP_NAME + " is reserved");
}

if (group.getName().equalsIgnoreCase(SecurityGroupManager.DEFAULT_GROUP_NAME)) {
if (newName != null && group.getName().equalsIgnoreCase(SecurityGroupManager.DEFAULT_GROUP_NAME)) {
throw new InvalidParameterValueException("The default security group cannot be renamed");
}

group.setName(newName);
if (newName != null) {
group.setName(newName);
}
if (newDescription != null) {
group.setDescription(newDescription);
}
_securityGroupDao.update(groupId, group);

logger.debug("Updated security group {}", group);
Expand Down
2 changes: 1 addition & 1 deletion ui/src/config/section/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ export default {
icon: 'edit-outlined',
label: 'label.edit',
dataView: true,
args: ['name'],
args: ['name', 'description'],
show: (record) => { return record.name !== 'default' }
},
{
Expand Down