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
7 changes: 4 additions & 3 deletions api/src/main/java/com/cloud/network/Network.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@
*/
public interface Network extends ControlledEntity, StateObject<Network.State>, InternalIdentity, Identity, Serializable, Displayable {

public enum GuestType {
enum GuestType {
Shared, Isolated, L2
}

public String updatingInSequence ="updatingInSequence";
String updatingInSequence = "updatingInSequence";
String hideIpAddressUsage = "hideIpAddressUsage";

public static class Service {
class Service {
private static List<Service> supportedServices = new ArrayList<Service>();

public static final Service Vpn = new Service("Vpn", Capability.SupportedVpnProtocols, Capability.VpnTypes);
Expand Down
4 changes: 2 additions & 2 deletions api/src/main/java/com/cloud/network/NetworkService.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.cloudstack.api.command.user.network.CreateNetworkCmd;
import org.apache.cloudstack.api.command.user.network.ListNetworksCmd;
import org.apache.cloudstack.api.command.user.network.RestartNetworkCmd;
import org.apache.cloudstack.api.command.user.network.UpdateNetworkCmd;
import org.apache.cloudstack.api.command.user.vm.ListNicsCmd;
import org.apache.cloudstack.api.response.AcquirePodIpCmdResponse;

Expand Down Expand Up @@ -81,8 +82,7 @@ IpAddress allocatePortableIP(Account ipOwner, int regionId, Long zoneId, Long ne

IpAddress getIp(long id);

Network updateGuestNetwork(long networkId, String name, String displayText, Account callerAccount, User callerUser, String domainSuffix, Long networkOfferingId,
Boolean changeCidr, String guestVmCidr, Boolean displayNetwork, String newUUID, boolean updateInSequence, boolean forced);
Network updateGuestNetwork(final UpdateNetworkCmd cmd);

/**
* Migrate a network from one physical network to another physical network
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ public class ApiConstants {
public static final String HA_PROVIDER = "haprovider";
public static final String HA_STATE = "hastate";
public static final String HEALTH = "health";
public static final String HIDE_IP_ADDRESS_USAGE = "hideipaddressusage";
public static final String HOST_ID = "hostid";
public static final String HOST_NAME = "hostname";
public static final String HYPERVISOR = "hypervisor";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public class CreateNetworkCmdByAdmin extends CreateNetworkCmd {
@Parameter(name=ApiConstants.BYPASS_VLAN_OVERLAP_CHECK, type=CommandType.BOOLEAN, description="when true bypasses VLAN id/range overlap check during network creation for shared and L2 networks")
private Boolean bypassVlanOverlapCheck;

@Parameter(name=ApiConstants.HIDE_IP_ADDRESS_USAGE, type=CommandType.BOOLEAN, description="when true ip address usage for the network will not be exported by the listUsageRecords API")
private Boolean hideIpAddressUsage;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
Expand All @@ -58,6 +61,13 @@ public Boolean getBypassVlanOverlapCheck() {
return false;
}

public Boolean getHideIpAddressUsage() {
if (hideIpAddressUsage != null) {
return hideIpAddressUsage;
}
return false;
}

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,44 @@
// under the License.
package org.apache.cloudstack.api.command.admin.network;

import org.apache.log4j.Logger;

import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject.ResponseView;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.command.user.network.UpdateNetworkCmd;
import org.apache.cloudstack.api.response.NetworkResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.log4j.Logger;

import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.network.Network;
import com.cloud.user.Account;
import com.cloud.user.User;

@APICommand(name = "updateNetwork", description = "Updates a network", responseObject = NetworkResponse.class, responseView = ResponseView.Full, entityType = {Network.class},
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class UpdateNetworkCmdByAdmin extends UpdateNetworkCmd {
public static final Logger s_logger = Logger.getLogger(UpdateNetworkCmdByAdmin.class.getName());

@Parameter(name= ApiConstants.HIDE_IP_ADDRESS_USAGE, type=CommandType.BOOLEAN, description="when true ip address usage for the network will not be exported by the listUsageRecords API")
private Boolean hideIpAddressUsage;

public Boolean getHideIpAddressUsage() {
if (hideIpAddressUsage == null) {
return false;
}
return hideIpAddressUsage;
}

@Override
public void execute() throws InsufficientCapacityException, ConcurrentOperationException{
User callerUser = _accountService.getActiveUser(CallContext.current().getCallingUserId());
Account callerAccount = _accountService.getActiveAccountById(callerUser.getAccountId());
Network network = _networkService.getNetwork(id);
if (network == null) {
throw new InvalidParameterValueException("Couldn't find network by id");
}

Network result = _networkService.updateGuestNetwork(getId(), getNetworkName(), getDisplayText(), callerAccount,
callerUser, getNetworkDomain(), getNetworkOfferingId(), getChangeCidr(), getGuestVmCidr(), getDisplayNetwork(), getCustomId(), getUpdateInSequence(),getForced());


Network result = _networkService.updateGuestNetwork(this);
if (result != null) {
NetworkResponse response = _responseGenerator.createNetworkResponse(ResponseView.Full, result);
response.setResponseName(getCommandName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.util.Map;
import java.util.Set;

import com.cloud.utils.Pair;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseCmd;
Expand All @@ -36,6 +35,8 @@
import org.apache.cloudstack.api.response.UsageRecordResponse;
import org.apache.cloudstack.usage.Usage;

import com.cloud.utils.Pair;

@APICommand(name = ListUsageRecordsCmd.APINAME,
description = "Lists usage records for accounts",
responseObject = UsageRecordResponse.class,
Expand Down Expand Up @@ -168,11 +169,13 @@ public void execute() {
}
for (Usage usageRecord : usageRecords.first()) {
UsageRecordResponse usageResponse = _responseGenerator.createUsageResponse(usageRecord, resourceTagResponseMap);
usageResponse.setObjectName("usagerecord");
usageResponses.add(usageResponse);
if (usageResponse != null) {
usageResponse.setObjectName("usagerecord");
usageResponses.add(usageResponse);
}
}

response.setResponses(usageResponses, usageRecords.second());
response.setResponses(usageResponses, usageResponses.size());
}

response.setResponseName(getCommandName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
// under the License.
package org.apache.cloudstack.api.command.user.network;

import org.apache.log4j.Logger;

import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
import org.apache.cloudstack.api.ACL;
Expand All @@ -31,16 +29,14 @@
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.NetworkOfferingResponse;
import org.apache.cloudstack.api.response.NetworkResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.log4j.Logger;

import com.cloud.event.EventTypes;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.network.Network;
import com.cloud.offering.NetworkOffering;
import com.cloud.user.Account;
import com.cloud.user.User;

@APICommand(name = "updateNetwork", description = "Updates a network", responseObject = NetworkResponse.class, responseView = ResponseView.Restricted, entityType = {Network.class},
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
Expand Down Expand Up @@ -159,17 +155,12 @@ public long getEntityOwnerId() {

@Override
public void execute() throws InsufficientCapacityException, ConcurrentOperationException {
User callerUser = _accountService.getActiveUser(CallContext.current().getCallingUserId());
Account callerAccount = _accountService.getActiveAccountById(callerUser.getAccountId());
Network network = _networkService.getNetwork(id);
if (network == null) {
throw new InvalidParameterValueException("Couldn't find network by ID");
}

Network result =
_networkService.updateGuestNetwork(getId(), getNetworkName(), getDisplayText(), callerAccount, callerUser, getNetworkDomain(), getNetworkOfferingId(),
getChangeCidr(), getGuestVmCidr(), getDisplayNetwork(), getCustomId(), getUpdateInSequence(), getForced());

Network result = _networkService.updateGuestNetwork(this);
if (result != null) {
NetworkResponse response = _responseGenerator.createNetworkResponse(ResponseView.Restricted, result);
response.setResponseName(getCommandName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
package org.apache.cloudstack.api.response;

import java.util.List;

import java.util.Map;
import java.util.Set;

import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
Expand Down Expand Up @@ -201,6 +202,10 @@ public class NetworkResponse extends BaseResponse implements ControlledEntityRes
@Param(description = "the list of resource tags associated with network", responseObject = ResourceTagResponse.class)
private List<ResourceTagResponse> tags;

@SerializedName(ApiConstants.DETAILS)
@Param(description = "the details of the network")
private Map<String, String> details;

@SerializedName(ApiConstants.IP6_GATEWAY)
@Param(description = "the gateway of IPv6 network")
private String ip6Gateway;
Expand Down Expand Up @@ -414,6 +419,10 @@ public void setTags(List<ResourceTagResponse> tags) {
this.tags = tags;
}

public void setDetails(Map<String, String> details) {
this.details = details;
}

public void setIp6Gateway(String ip6Gateway) {
this.ip6Gateway = ip6Gateway;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,12 @@ public long getResourceId() {
public boolean isDisplay() {
return display;
}

public void setValue(String value) {
this.value = value;
}

public void setDisplay(boolean display) {
this.display = display;
}
}
Loading