Skip to content
Merged
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
16 changes: 15 additions & 1 deletion api/src/main/java/com/cloud/network/Network.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,21 @@
public interface Network extends ControlledEntity, StateObject<Network.State>, InternalIdentity, Identity, Serializable, Displayable {

enum GuestType {
Shared, Isolated, L2
Shared, Isolated, L2;

public static GuestType fromValue(String type) {
if (StringUtils.isBlank(type)) {
return null;
} else if (type.equalsIgnoreCase("Shared")) {
return Shared;
} else if (type.equalsIgnoreCase("Isolated")) {
return Isolated;
} else if (type.equalsIgnoreCase("L2")) {
return L2;
} else {
throw new InvalidParameterValueException("Unexpected Guest type : " + type);
}
}
}

enum PVlanType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import com.cloud.network.Network;
import com.cloud.utils.Pair;
import com.google.common.base.Strings;

@APICommand(name = "listNetworks", description = "Lists all available networks.", responseObject = NetworkResponse.class, responseView = ResponseView.Restricted, entityType = {Network.class},
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
Expand All @@ -52,7 +53,7 @@ public class ListNetworksCmd extends BaseListTaggedResourcesCmd implements UserC
@Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, description = "the zone ID of the network")
private Long zoneId;

@Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, description = "the type of the network. Supported values are: isolated and shared")
@Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, description = "the type of the network. Supported values are: isolated, l2, shared and all")
private String guestIpType;

@Parameter(name = ApiConstants.IS_SYSTEM, type = CommandType.BOOLEAN, description = "true if network is system, false otherwise")
Expand Down Expand Up @@ -101,7 +102,13 @@ public Long getZoneId() {
}

public String getGuestIpType() {
return guestIpType;
if (!Strings.isNullOrEmpty(guestIpType)) {
if (guestIpType.equalsIgnoreCase("all")) {
return null;
}
return Network.GuestType.fromValue(guestIpType).toString();
}
return null;
Comment on lines +105 to +111
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so in the end empty and "all" are treated the same?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's right!

}

public Boolean getIsSystem() {
Expand Down