mirror of https://github.com/apache/cloudstack.git
Display flag support for publicIpAddress and VPC. Once set to false, the object is not listed to the regular user. Available to be set by Root admin only
This commit is contained in:
parent
4fcd0b1a1f
commit
2f7bfc0c73
|
|
@ -85,4 +85,6 @@ public interface IpAddress extends ControlledEntity, Identity, InternalIdentity
|
|||
|
||||
Long getNetworkId();
|
||||
|
||||
boolean isDisplay();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public interface NetworkService {
|
|||
|
||||
List<? extends Network> getIsolatedNetworksOwnedByAccountInZone(long zoneId, Account owner);
|
||||
|
||||
IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId) throws ResourceAllocationException, InsufficientAddressCapacityException,
|
||||
IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId, Boolean displayIp) throws ResourceAllocationException, InsufficientAddressCapacityException,
|
||||
ConcurrentOperationException;
|
||||
|
||||
boolean releaseIpAddress(long ipAddressId) throws InsufficientAddressCapacityException;
|
||||
|
|
@ -177,5 +177,5 @@ public interface NetworkService {
|
|||
|
||||
Map<Network.Capability, String> getNetworkOfferingServiceCapabilities(NetworkOffering offering, Service service);
|
||||
|
||||
IpAddress updateIP(Long id, String customId);
|
||||
IpAddress updateIP(Long id, String customId, Boolean displayIp);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,4 +72,5 @@ public interface Vpc extends ControlledEntity, Identity, InternalIdentity {
|
|||
*/
|
||||
boolean isRestartRequired();
|
||||
|
||||
boolean isDisplay();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,10 +43,11 @@ public interface VpcService {
|
|||
* @param displayText
|
||||
* @param cidr
|
||||
* @param networkDomain TODO
|
||||
* @param displayVpc TODO
|
||||
* @return
|
||||
* @throws ResourceAllocationException TODO
|
||||
*/
|
||||
public Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName, String displayText, String cidr, String networkDomain)
|
||||
public Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName, String displayText, String cidr, String networkDomain, Boolean displayVpc)
|
||||
throws ResourceAllocationException;
|
||||
|
||||
/**
|
||||
|
|
@ -67,9 +68,10 @@ public interface VpcService {
|
|||
* @param vpcName
|
||||
* @param displayText
|
||||
* @param customId TODO
|
||||
* @param displayVpc TODO
|
||||
* @return
|
||||
*/
|
||||
public Vpc updateVpc(long vpcId, String vpcName, String displayText, String customId);
|
||||
public Vpc updateVpc(long vpcId, String vpcName, String displayText, String customId, Boolean displayVpc);
|
||||
|
||||
/**
|
||||
* Lists VPC(s) based on the parameters passed to the method call
|
||||
|
|
|
|||
|
|
@ -550,7 +550,6 @@ public class ApiConstants {
|
|||
public static final String PASSIVE = "passive";
|
||||
public static final String VERSION = "version";
|
||||
public static final String START = "start";
|
||||
public static final String DISPLAY = "display";
|
||||
|
||||
public enum HostDetails {
|
||||
all, capacity, events, stats, min;
|
||||
|
|
|
|||
|
|
@ -18,8 +18,7 @@ package org.apache.cloudstack.api.command.user.address;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiCommandJobType;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
|
|
@ -37,6 +36,7 @@ import org.apache.cloudstack.api.response.RegionResponse;
|
|||
import org.apache.cloudstack.api.response.VpcResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
|
|
@ -103,6 +103,9 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
|
|||
description = "region ID from where portable ip is to be associated.")
|
||||
private Integer regionId;
|
||||
|
||||
@Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the ip to the end user or not", since = "4.4", authorized = {RoleType.Admin})
|
||||
private Boolean display;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -195,6 +198,10 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
|
|||
}
|
||||
}
|
||||
|
||||
public Boolean getDisplayIp() {
|
||||
return display;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
Account caller = CallContext.current().getCallingAccount();
|
||||
|
|
@ -274,7 +281,7 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
|
|||
IpAddress ip = null;
|
||||
|
||||
if (!isPortable()) {
|
||||
ip = _networkService.allocateIP(_accountService.getAccount(getEntityOwnerId()), getZoneId(), getNetworkId());
|
||||
ip = _networkService.allocateIP(_accountService.getAccount(getEntityOwnerId()), getZoneId(), getNetworkId(), getDisplayIp());
|
||||
} else {
|
||||
ip = _networkService.allocatePortableIP(_accountService.getAccount(getEntityOwnerId()), 1, getZoneId(), getNetworkId(), getVpcId());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.api.command.user.address;
|
||||
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseAsyncCustomIdCmd;
|
||||
|
|
@ -51,6 +52,9 @@ public class UpdateIPAddrCmd extends BaseAsyncCustomIdCmd {
|
|||
@Parameter(name = ApiConstants.ACCOUNT_ID, type = CommandType.UUID, entityType = AccountResponse.class, expose = false)
|
||||
private Long ownerId;
|
||||
|
||||
@Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the ip to the end user or not", since = "4.4", authorized = {RoleType.Admin})
|
||||
private Boolean display;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -63,6 +67,10 @@ public class UpdateIPAddrCmd extends BaseAsyncCustomIdCmd {
|
|||
return id;
|
||||
}
|
||||
|
||||
public Boolean getDisplayIp() {
|
||||
return display;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
|
|
@ -77,6 +85,7 @@ public class UpdateIPAddrCmd extends BaseAsyncCustomIdCmd {
|
|||
return ("Updating ip address with id=" + id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
if (ownerId == null) {
|
||||
|
|
@ -114,7 +123,7 @@ public class UpdateIPAddrCmd extends BaseAsyncCustomIdCmd {
|
|||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException,
|
||||
NetworkRuleConflictException {
|
||||
|
||||
IpAddress result = _networkService.updateIP(getId(), this.getCustomId());
|
||||
IpAddress result = _networkService.updateIP(getId(), this.getCustomId(), getDisplayIp());
|
||||
IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(result);
|
||||
ipResponse.setResponseName(getCommandName());
|
||||
setResponseObject(ipResponse);
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@
|
|||
// 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.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
|
|
@ -33,6 +32,7 @@ import org.apache.cloudstack.api.response.ProjectResponse;
|
|||
import org.apache.cloudstack.api.response.VpcResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
|
|
@ -136,7 +136,7 @@ public class CreateNetworkCmd extends BaseCmd {
|
|||
|
||||
@Parameter(name = ApiConstants.DISPLAY_NETWORK,
|
||||
type = CommandType.BOOLEAN,
|
||||
description = "an optional field, whether to the display the network to the end user or not.")
|
||||
description = "an optional field, whether to the display the network to the end user or not.", authorized = {RoleType.Admin})
|
||||
private Boolean displayNetwork;
|
||||
|
||||
@Parameter(name = ApiConstants.ACL_ID, type = CommandType.UUID, entityType = NetworkACLResponse.class, description = "Network ACL Id associated for the network")
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.api.command.user.network;
|
||||
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
|
|
@ -69,7 +70,7 @@ public class UpdateNetworkCmd extends BaseAsyncCustomIdCmd {
|
|||
|
||||
@Parameter(name = ApiConstants.DISPLAY_NETWORK,
|
||||
type = CommandType.BOOLEAN,
|
||||
description = "an optional field, whether to the display the network to the end user or not.")
|
||||
description = "an optional field, whether to the display the network to the end user or not.", authorized = {RoleType.Admin})
|
||||
private Boolean displayNetwork;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import java.util.LinkedHashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
|
||||
import org.apache.cloudstack.affinity.AffinityGroupResponse;
|
||||
import org.apache.cloudstack.api.ACL;
|
||||
|
|
@ -170,7 +171,7 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd {
|
|||
+ "Mutually exclusive with affinitygroupids parameter")
|
||||
private List<String> affinityGroupNameList;
|
||||
|
||||
@Parameter(name = ApiConstants.DISPLAY_VM, type = CommandType.BOOLEAN, since = "4.2", description = "an optional field, whether to the display the vm to the end user or not.")
|
||||
@Parameter(name = ApiConstants.DISPLAY_VM, type = CommandType.BOOLEAN, since = "4.2", description = "an optional field, whether to the display the vm to the end user or not.", authorized = {RoleType.Admin})
|
||||
private Boolean displayVm;
|
||||
|
||||
@Parameter(name = ApiConstants.DETAILS, type = CommandType.MAP, since = "4.3", description = "used to specify the custom parameters.")
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.api.command.user.vm;
|
||||
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
|
|
@ -67,7 +68,7 @@ public class UpdateVMCmd extends BaseCustomIdCmd {
|
|||
length = 32768)
|
||||
private String userData;
|
||||
|
||||
@Parameter(name = ApiConstants.DISPLAY_VM, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the vm to the end user or not.")
|
||||
@Parameter(name = ApiConstants.DISPLAY_VM, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the vm to the end user or not.", authorized = {RoleType.Admin})
|
||||
private Boolean displayVm;
|
||||
|
||||
@Parameter(name = ApiConstants.IS_DYNAMICALLY_SCALABLE,
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class AddResourceDetailCmd extends BaseAsyncCmd {
|
|||
@Parameter(name = ApiConstants.RESOURCE_ID, type = CommandType.STRING, required = true, collectionType = CommandType.STRING, description = "resource id to create the details for")
|
||||
private String resourceId;
|
||||
|
||||
@Parameter(name = ApiConstants.DISPLAY, type = CommandType.BOOLEAN, description = "pass false if you want this detail to be disabled for the regular user. True by default")
|
||||
@Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "pass false if you want this detail to be disabled for the regular user. True by default", since = "4.4")
|
||||
private Boolean display;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -16,14 +16,13 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.api.command.user.volume;
|
||||
|
||||
import org.apache.cloudstack.api.BaseAsyncCreateCustomIdCmd;
|
||||
import org.apache.cloudstack.api.BaseCmd;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiCommandJobType;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseAsyncCreateCustomIdCmd;
|
||||
import org.apache.cloudstack.api.BaseCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.DiskOfferingResponse;
|
||||
|
|
@ -34,6 +33,7 @@ import org.apache.cloudstack.api.response.UserVmResponse;
|
|||
import org.apache.cloudstack.api.response.VolumeResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
|
|
@ -97,7 +97,7 @@ public class CreateVolumeCmd extends BaseAsyncCreateCustomIdCmd {
|
|||
@Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, description = "the ID of the availability zone")
|
||||
private Long zoneId;
|
||||
|
||||
@Parameter(name = ApiConstants.DISPLAY_VOLUME, type = CommandType.BOOLEAN, description = "an optional field, whether to display the volume to the end user or not.")
|
||||
@Parameter(name = ApiConstants.DISPLAY_VOLUME, type = CommandType.BOOLEAN, description = "an optional field, whether to display the volume to the end user or not.", authorized = {RoleType.Admin})
|
||||
private Boolean displayVolume;
|
||||
|
||||
@Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID,
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.api.command.user.volume;
|
||||
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiCommandJobType;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
|
|
@ -62,7 +63,7 @@ public class UpdateVolumeCmd extends BaseAsyncCustomIdCmd {
|
|||
|
||||
@Parameter(name = ApiConstants.DISPLAY_VOLUME,
|
||||
type = CommandType.BOOLEAN,
|
||||
description = "an optional field, whether to the display the volume to the end user or not.")
|
||||
description = "an optional field, whether to the display the volume to the end user or not.", authorized = {RoleType.Admin})
|
||||
private Boolean displayVolume;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.api.command.user.vpc;
|
||||
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
|
|
@ -87,6 +88,9 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd {
|
|||
"True by default.", since = "4.3")
|
||||
private Boolean start;
|
||||
|
||||
@Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the vpc to the end user or not", since = "4.4", authorized = {RoleType.Admin})
|
||||
private Boolean display;
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
// ///////////////// Accessors ///////////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
|
|
@ -130,9 +134,13 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd {
|
|||
return true;
|
||||
}
|
||||
|
||||
public Boolean getDisplayVpc() {
|
||||
return display;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create() throws ResourceAllocationException {
|
||||
Vpc vpc = _vpcService.createVpc(getZoneId(), getVpcOffering(), getEntityOwnerId(), getVpcName(), getDisplayText(), getCidr(), getNetworkDomain());
|
||||
Vpc vpc = _vpcService.createVpc(getZoneId(), getVpcOffering(), getEntityOwnerId(), getVpcName(), getDisplayText(), getCidr(), getNetworkDomain(), getDisplayVpc());
|
||||
if (vpc != null) {
|
||||
setEntityId(vpc.getId());
|
||||
setEntityUuid(vpc.getUuid());
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.api.command.user.vpc;
|
||||
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
|
|
@ -48,6 +49,9 @@ public class UpdateVPCCmd extends BaseAsyncCustomIdCmd {
|
|||
@Parameter(name = ApiConstants.DISPLAY_TEXT, type = CommandType.STRING, description = "the display text of the VPC")
|
||||
private String displayText;
|
||||
|
||||
@Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the vpc to the end user or not", since = "4.4", authorized = {RoleType.Admin})
|
||||
private Boolean display;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -64,6 +68,10 @@ public class UpdateVPCCmd extends BaseAsyncCustomIdCmd {
|
|||
return id;
|
||||
}
|
||||
|
||||
public Boolean getDisplayVpc() {
|
||||
return display;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -84,7 +92,7 @@ public class UpdateVPCCmd extends BaseAsyncCustomIdCmd {
|
|||
|
||||
@Override
|
||||
public void execute() {
|
||||
Vpc result = _vpcService.updateVpc(getId(), getVpcName(), getDisplayText(), this.getCustomId());
|
||||
Vpc result = _vpcService.updateVpc(getId(), getVpcName(), getDisplayText(), this.getCustomId(), getDisplayVpc());
|
||||
if (result != null) {
|
||||
VpcResponse response = _responseGenerator.createVpcResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
|
|
|
|||
|
|
@ -19,14 +19,13 @@ package org.apache.cloudstack.api.response;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
import org.apache.cloudstack.api.EntityReference;
|
||||
|
||||
import com.cloud.network.IpAddress;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
@EntityReference(value = IpAddress.class)
|
||||
@SuppressWarnings("unused")
|
||||
|
|
@ -146,6 +145,10 @@ public class IPAddressResponse extends BaseResponse implements ControlledEntityR
|
|||
@Param(description = "is public IP portable across the zones")
|
||||
private Boolean isPortable;
|
||||
|
||||
@SerializedName(ApiConstants.FOR_DISPLAY)
|
||||
@Param(description = "is public ip for display to the regular user", since = "4.4")
|
||||
private Boolean forDisplay;
|
||||
|
||||
/*
|
||||
@SerializedName(ApiConstants.JOB_ID) @Param(description="shows the current pending asynchronous job ID. This tag is not returned if no current pending jobs are acting on the volume")
|
||||
private IdentityProxy jobId = new IdentityProxy("async_job");
|
||||
|
|
@ -280,4 +283,8 @@ public class IPAddressResponse extends BaseResponse implements ControlledEntityR
|
|||
public void setPortable(Boolean portable) {
|
||||
this.isPortable = portable;
|
||||
}
|
||||
|
||||
public void setForDisplay(Boolean forDisplay) {
|
||||
this.forDisplay = forDisplay;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,14 +20,13 @@ import java.util.Date;
|
|||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
import org.apache.cloudstack.api.EntityReference;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
@EntityReference(value = Volume.class)
|
||||
@SuppressWarnings("unused")
|
||||
|
|
@ -410,10 +409,6 @@ public class VolumeResponse extends BaseResponse implements ControlledViewEntity
|
|||
this.tags.add(tag);
|
||||
}
|
||||
|
||||
public Boolean getDisplayVolume() {
|
||||
return displayVolume;
|
||||
}
|
||||
|
||||
public void setDisplayVolume(Boolean displayVm) {
|
||||
this.displayVolume = displayVm;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,14 +19,13 @@ package org.apache.cloudstack.api.response;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
import org.apache.cloudstack.api.EntityReference;
|
||||
|
||||
import com.cloud.network.vpc.Vpc;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
@EntityReference(value = Vpc.class)
|
||||
@SuppressWarnings("unused")
|
||||
|
|
@ -107,6 +106,10 @@ public class VpcResponse extends BaseResponse implements ControlledEntityRespons
|
|||
@Param(description = "the list of resource tags associated with the project", responseObject = ResourceTagResponse.class)
|
||||
private List<ResourceTagResponse> tags;
|
||||
|
||||
@SerializedName(ApiConstants.FOR_DISPLAY)
|
||||
@Param(description = "is vpc for display to the regular user", since = "4.4")
|
||||
private Boolean forDisplay;
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
|
@ -191,4 +194,8 @@ public class VpcResponse extends BaseResponse implements ControlledEntityRespons
|
|||
public void setTags(List<ResourceTagResponse> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public void setForDisplay(Boolean forDisplay) {
|
||||
this.forDisplay = forDisplay;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ public interface IpAddressManager {
|
|||
PublicIp assignDedicateIpAddress(Account owner, Long guestNtwkId, Long vpcId, long dcId, boolean isSourceNat) throws ConcurrentOperationException,
|
||||
InsufficientAddressCapacityException;
|
||||
|
||||
IpAddress allocateIp(Account ipOwner, boolean isSystem, Account caller, long callerId, DataCenter zone) throws ConcurrentOperationException,
|
||||
IpAddress allocateIp(Account ipOwner, boolean isSystem, Account caller, long callerId, DataCenter zone, Boolean displayIp) throws ConcurrentOperationException,
|
||||
ResourceAllocationException, InsufficientAddressCapacityException;
|
||||
|
||||
PublicIp assignPublicIpAddressFromVlans(long dcId, Long podId, Account owner, VlanType type, List<Long> vlanDbIds, Long networkId, String requestedIp,
|
||||
|
|
|
|||
|
|
@ -231,4 +231,9 @@ public class PublicIp implements PublicIpAddress {
|
|||
public Long getIpMacAddress() {
|
||||
return _addr.getMacAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisplay() {
|
||||
return _addr.isDisplay();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -165,6 +165,7 @@ public class IPAddressDaoImpl extends GenericDaoBase<IPAddressVO, Long> implemen
|
|||
address.setVpcId(null);
|
||||
address.setSystem(false);
|
||||
address.setVmIp(null);
|
||||
address.setDisplay(true);
|
||||
update(ipAddressId, address);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -114,6 +114,9 @@ public class IPAddressVO implements IpAddress {
|
|||
@Column(name = "is_portable")
|
||||
private boolean portable = false;
|
||||
|
||||
@Column(name = "display", updatable = true, nullable = false)
|
||||
protected boolean display = true;
|
||||
|
||||
protected IPAddressVO() {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
|
@ -334,4 +337,13 @@ public class IPAddressVO implements IpAddress {
|
|||
public Long getNetworkId() {
|
||||
return sourceNetworkId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisplay() {
|
||||
return display;
|
||||
}
|
||||
|
||||
public void setDisplay(boolean display) {
|
||||
this.display = display;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,6 +76,9 @@ public class VpcVO implements Vpc {
|
|||
@Column(name = "restart_required")
|
||||
boolean restartRequired = false;
|
||||
|
||||
@Column(name = "display", updatable = true, nullable = false)
|
||||
protected boolean display = true;
|
||||
|
||||
public VpcVO() {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
|
@ -182,4 +185,13 @@ public class VpcVO implements Vpc {
|
|||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public void setDisplay(boolean display) {
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisplay() {
|
||||
return display;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -356,7 +356,7 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
|
|||
try {
|
||||
Account caller = CallContext.current().getCallingAccount();
|
||||
long callerUserId = CallContext.current().getCallingUserId();
|
||||
outsideIp = _ipAddrMgr.allocateIp(owner, false, caller, callerUserId, zone);
|
||||
outsideIp = _ipAddrMgr.allocateIp(owner, false, caller, callerUserId, zone, displayIp);
|
||||
} catch (ResourceAllocationException e) {
|
||||
s_logger.error("Unable to allocate additional public Ip address. Exception details " + e);
|
||||
throw new CloudRuntimeException("Unable to allocate additional public Ip address. Exception details " + e);
|
||||
|
|
|
|||
|
|
@ -714,6 +714,8 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
}
|
||||
}
|
||||
|
||||
ipResponse.setForDisplay(ipAddr.isDisplay());
|
||||
|
||||
ipResponse.setPortable(ipAddr.isPortable());
|
||||
|
||||
//set tag information
|
||||
|
|
@ -2783,6 +2785,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
response.setCidr(vpc.getCidr());
|
||||
response.setRestartRequired(vpc.isRestartRequired());
|
||||
response.setNetworkDomain(vpc.getNetworkDomain());
|
||||
response.setForDisplay(vpc.isDisplay());
|
||||
|
||||
Map<Service, Set<Provider>> serviceProviderMap = ApiDBUtils.listVpcOffServices(vpc.getVpcOfferingId());
|
||||
List<ServiceResponse> serviceResponses = new ArrayList<ServiceResponse>();
|
||||
|
|
|
|||
|
|
@ -115,7 +115,9 @@ import com.cloud.network.rules.StaticNat;
|
|||
import com.cloud.network.rules.dao.PortForwardingRulesDao;
|
||||
import com.cloud.network.vpc.NetworkACLManager;
|
||||
import com.cloud.network.vpc.VpcManager;
|
||||
import com.cloud.network.vpc.VpcVO;
|
||||
import com.cloud.network.vpc.dao.PrivateIpDao;
|
||||
import com.cloud.network.vpc.dao.VpcDao;
|
||||
import com.cloud.network.vpn.RemoteAccessVpnService;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.Availability;
|
||||
|
|
@ -271,6 +273,8 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
|
|||
Ipv6AddressManager _ipv6Mgr;
|
||||
@Inject
|
||||
PortableIpDao _portableIpDao;
|
||||
@Inject
|
||||
VpcDao _vpcDao;
|
||||
SearchBuilder<IPAddressVO> AssignIpAddressSearch;
|
||||
SearchBuilder<IPAddressVO> AssignIpAddressFromPodVlanSearch;
|
||||
|
||||
|
|
@ -409,7 +413,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
|
|||
|
||||
DataCenter zone = _entityMgr.findById(DataCenter.class, zoneId);
|
||||
|
||||
return allocateIp(ipOwner, isSystem, caller, callerUserId, zone);
|
||||
return allocateIp(ipOwner, isSystem, caller, callerUserId, zone, null);
|
||||
}
|
||||
|
||||
// An IP association is required in below cases
|
||||
|
|
@ -640,18 +644,19 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
|
|||
@Override
|
||||
public PublicIp assignPublicIpAddress(long dcId, Long podId, Account owner, VlanType type, Long networkId, String requestedIp, boolean isSystem)
|
||||
throws InsufficientAddressCapacityException {
|
||||
return fetchNewPublicIp(dcId, podId, null, owner, type, networkId, false, true, requestedIp, isSystem, null);
|
||||
return fetchNewPublicIp(dcId, podId, null, owner, type, networkId, false, true, requestedIp, isSystem, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PublicIp assignPublicIpAddressFromVlans(long dcId, Long podId, Account owner, VlanType type, List<Long> vlanDbIds, Long networkId, String requestedIp, boolean isSystem)
|
||||
throws InsufficientAddressCapacityException {
|
||||
return fetchNewPublicIp(dcId, podId, vlanDbIds, owner, type, networkId, false, true, requestedIp, isSystem, null);
|
||||
return fetchNewPublicIp(dcId, podId, vlanDbIds, owner, type, networkId, false, true, requestedIp, isSystem, null, null);
|
||||
}
|
||||
|
||||
@DB
|
||||
public PublicIp fetchNewPublicIp(final long dcId, final Long podId, final List<Long> vlanDbIds, final Account owner, final VlanType vlanUse, final Long guestNetworkId,
|
||||
final boolean sourceNat, final boolean assign, final String requestedIp, final boolean isSystem, final Long vpcId) throws InsufficientAddressCapacityException {
|
||||
final boolean sourceNat, final boolean assign, final String requestedIp, final boolean isSystem, final Long vpcId, final Boolean displayIp)
|
||||
throws InsufficientAddressCapacityException {
|
||||
IPAddressVO addr = Transaction.execute(new TransactionCallbackWithException<IPAddressVO, InsufficientAddressCapacityException>() {
|
||||
@Override
|
||||
public IPAddressVO doInTransaction(TransactionStatus status) throws InsufficientAddressCapacityException {
|
||||
|
|
@ -764,6 +769,9 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
|
|||
addr.setAllocatedInDomainId(owner.getDomainId());
|
||||
addr.setAllocatedToAccountId(owner.getId());
|
||||
addr.setSystem(isSystem);
|
||||
if (displayIp != null) {
|
||||
addr.setDisplay(displayIp);
|
||||
}
|
||||
|
||||
if (assign) {
|
||||
markPublicIpAsAllocated(addr);
|
||||
|
|
@ -871,8 +879,16 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
|
|||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("lock account " + ownerId + " is acquired");
|
||||
}
|
||||
boolean displayIp = true;
|
||||
if (guestNtwkId != null) {
|
||||
Network ntwk = _networksDao.findById(guestNtwkId);
|
||||
displayIp = ntwk.getDisplayNetwork();
|
||||
} else if (vpcId != null) {
|
||||
VpcVO vpc = _vpcDao.findById(vpcId);
|
||||
displayIp = vpc.isDisplay();
|
||||
}
|
||||
|
||||
PublicIp ip = fetchNewPublicIp(dcId, null, null, owner, VlanType.VirtualNetwork, guestNtwkId, isSourceNat, false, null, false, vpcId);
|
||||
PublicIp ip = fetchNewPublicIp(dcId, null, null, owner, VlanType.VirtualNetwork, guestNtwkId, isSourceNat, false, null, false, vpcId, displayIp);
|
||||
IPAddressVO publicIp = ip.ip();
|
||||
|
||||
markPublicIpAsAllocated(publicIp);
|
||||
|
|
@ -974,7 +990,8 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
|
|||
|
||||
@DB
|
||||
@Override
|
||||
public IpAddress allocateIp(final Account ipOwner, final boolean isSystem, Account caller, long callerUserId, final DataCenter zone) throws ConcurrentOperationException,
|
||||
public IpAddress allocateIp(final Account ipOwner, final boolean isSystem, Account caller, long callerUserId, final DataCenter zone, final Boolean displayIp)
|
||||
throws ConcurrentOperationException,
|
||||
ResourceAllocationException, InsufficientAddressCapacityException {
|
||||
|
||||
final VlanType vlanType = VlanType.VirtualNetwork;
|
||||
|
|
@ -1007,7 +1024,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
|
|||
ip = Transaction.execute(new TransactionCallbackWithException<PublicIp, InsufficientAddressCapacityException>() {
|
||||
@Override
|
||||
public PublicIp doInTransaction(TransactionStatus status) throws InsufficientAddressCapacityException {
|
||||
PublicIp ip = fetchNewPublicIp(zone.getId(), null, null, ipOwner, vlanType, null, false, assign, null, isSystem, null);
|
||||
PublicIp ip = fetchNewPublicIp(zone.getId(), null, null, ipOwner, vlanType, null, false, assign, null, isSystem, null, displayIp);
|
||||
|
||||
if (ip == null) {
|
||||
InsufficientAddressCapacityException ex = new InsufficientAddressCapacityException("Unable to find available public IP addresses", DataCenter.class, zone
|
||||
|
|
@ -1038,7 +1055,8 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
|
|||
|
||||
@Override
|
||||
@DB
|
||||
public IpAddress allocatePortableIp(final Account ipOwner, Account caller, final long dcId, final Long networkId, final Long vpcID) throws ConcurrentOperationException,
|
||||
public IpAddress allocatePortableIp(final Account ipOwner, Account caller, final long dcId, final Long networkId, final Long vpcID)
|
||||
throws ConcurrentOperationException,
|
||||
ResourceAllocationException, InsufficientAddressCapacityException {
|
||||
|
||||
GlobalLock portableIpLock = GlobalLock.getInternLock("PortablePublicIpRange");
|
||||
|
|
|
|||
|
|
@ -513,7 +513,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
|
|||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_NET_IP_ASSIGN, eventDescription = "allocating Ip", create = true)
|
||||
public IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId) throws ResourceAllocationException, InsufficientAddressCapacityException,
|
||||
public IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId, Boolean displayIp) throws ResourceAllocationException, InsufficientAddressCapacityException,
|
||||
ConcurrentOperationException {
|
||||
|
||||
Account caller = CallContext.current().getCallingAccount();
|
||||
|
|
@ -537,7 +537,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
|
|||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Associate IP address called by the user " + callerUserId + " account " + ipOwner.getId());
|
||||
}
|
||||
return _ipAddrMgr.allocateIp(ipOwner, false, caller, callerUserId, zone);
|
||||
return _ipAddrMgr.allocateIp(ipOwner, false, caller, callerUserId, zone, displayIp);
|
||||
} else {
|
||||
throw new InvalidParameterValueException("Associate IP address can only be called on the shared networks in the advanced zone"
|
||||
+ " with Firewall/Source Nat/Static Nat/Port Forwarding/Load balancing services enabled");
|
||||
|
|
@ -548,7 +548,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
|
|||
_accountMgr.checkAccess(caller, null, false, ipOwner);
|
||||
}
|
||||
|
||||
return _ipAddrMgr.allocateIp(ipOwner, false, caller, callerUserId, zone);
|
||||
return _ipAddrMgr.allocateIp(ipOwner, false, caller, callerUserId, zone, displayIp);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -1022,11 +1022,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
|
|||
zoneId = pNtwk.getDataCenterId();
|
||||
}
|
||||
|
||||
if (displayNetwork != null) {
|
||||
if (!_accountMgr.isRootAdmin(caller.getType())) {
|
||||
throw new PermissionDeniedException("Only admin allowed to update displaynetwork parameter");
|
||||
}
|
||||
} else {
|
||||
if (displayNetwork == null) {
|
||||
displayNetwork = true;
|
||||
}
|
||||
|
||||
|
|
@ -1990,10 +1986,6 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
|
|||
|
||||
// display flag is not null and has changed
|
||||
if (displayNetwork != null && displayNetwork != network.getDisplayNetwork()) {
|
||||
if (!_accountMgr.isRootAdmin(callerAccount.getType())) {
|
||||
throw new PermissionDeniedException("Only admin allowed to update displaynetwork parameter");
|
||||
}
|
||||
|
||||
// Update resource count if it needs to be updated
|
||||
NetworkOffering networkOffering = _networkOfferingDao.findById(network.getNetworkOfferingId());
|
||||
if (_networkMgr.resourceCountNeedsUpdate(networkOffering, network.getAclType())) {
|
||||
|
|
@ -4036,7 +4028,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
|
|||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_NET_IP_UPDATE, eventDescription = "updating public ip address", async = true)
|
||||
public IpAddress updateIP(Long id, String customId) {
|
||||
public IpAddress updateIP(Long id, String customId, Boolean displayIp) {
|
||||
Account caller = CallContext.current().getCallingAccount();
|
||||
IPAddressVO ipVO = _ipAddressDao.findById(id);
|
||||
if (ipVO == null) {
|
||||
|
|
@ -4053,6 +4045,11 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
|
|||
if (customId != null) {
|
||||
ipVO.setUuid(customId);
|
||||
}
|
||||
|
||||
if (displayIp != null) {
|
||||
ipVO.setDisplay(displayIp);
|
||||
}
|
||||
|
||||
_ipAddressDao.update(id, ipVO);
|
||||
return _ipAddressDao.findById(id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -584,7 +584,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
|||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_VPC_CREATE, eventDescription = "creating vpc", create = true)
|
||||
public Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName, String displayText, String cidr, String networkDomain)
|
||||
public Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName, String displayText, String cidr, String networkDomain, Boolean displayVpc)
|
||||
throws ResourceAllocationException {
|
||||
Account caller = CallContext.current().getCallingAccount();
|
||||
Account owner = _accountMgr.getAccount(vpcOwnerId);
|
||||
|
|
@ -630,12 +630,12 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
|||
}
|
||||
}
|
||||
|
||||
return createVpc(zoneId, vpcOffId, owner, vpcName, displayText, cidr, networkDomain);
|
||||
return createVpc(zoneId, vpcOffId, owner, vpcName, displayText, cidr, networkDomain, displayVpc);
|
||||
}
|
||||
|
||||
@DB
|
||||
protected Vpc createVpc(final long zoneId, final long vpcOffId, final Account vpcOwner, final String vpcName, final String displayText, final String cidr,
|
||||
final String networkDomain) {
|
||||
final String networkDomain, final Boolean displayVpc) {
|
||||
|
||||
//Validate CIDR
|
||||
if (!NetUtils.isValidCIDR(cidr)) {
|
||||
|
|
@ -658,6 +658,9 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
|||
@Override
|
||||
public VpcVO doInTransaction(TransactionStatus status) {
|
||||
VpcVO vpc = new VpcVO(zoneId, vpcName, displayText, vpcOwner.getId(), vpcOwner.getDomainId(), vpcOffId, cidr, networkDomain);
|
||||
if (displayVpc != null) {
|
||||
vpc.setDisplay(displayVpc);
|
||||
}
|
||||
vpc = _vpcDao.persist(vpc, finalizeServicesAndProvidersForVpc(zoneId, vpcOffId));
|
||||
_resourceLimitMgr.incrementResourceCount(vpcOwner.getId(), ResourceType.vpc);
|
||||
|
||||
|
|
@ -769,7 +772,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
|||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_VPC_UPDATE, eventDescription = "updating vpc")
|
||||
public Vpc updateVpc(long vpcId, String vpcName, String displayText, String customId) {
|
||||
public Vpc updateVpc(long vpcId, String vpcName, String displayText, String customId, Boolean displayVpc) {
|
||||
CallContext.current().setEventDetails(" Id: " + vpcId);
|
||||
Account caller = CallContext.current().getCallingAccount();
|
||||
|
||||
|
|
@ -795,6 +798,10 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
|||
vpc.setUuid(customId);
|
||||
}
|
||||
|
||||
if (displayVpc != null) {
|
||||
vpc.setDisplay(displayVpc);
|
||||
}
|
||||
|
||||
if (_vpcDao.update(vpcId, vpc)) {
|
||||
s_logger.debug("Updated VPC id=" + vpcId);
|
||||
return _vpcDao.findById(vpcId);
|
||||
|
|
@ -2020,6 +2027,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
|||
//update ip address with networkId
|
||||
ip.setVpcId(vpcId);
|
||||
ip.setSourceNat(isSourceNatFinal);
|
||||
|
||||
_ipAddressDao.update(ipId, ip);
|
||||
|
||||
//mark ip as allocated
|
||||
|
|
|
|||
|
|
@ -373,13 +373,13 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
|||
Account caller = CallContext.current().getCallingAccount();
|
||||
|
||||
long ownerId = cmd.getEntityOwnerId();
|
||||
Boolean displayVolumeEnabled = cmd.getDisplayVolume();
|
||||
Boolean displayVolume = cmd.getDisplayVolume();
|
||||
|
||||
// permission check
|
||||
_accountMgr.checkAccess(caller, null, true, _accountMgr.getActiveAccountById(ownerId));
|
||||
|
||||
if (displayVolumeEnabled == null) {
|
||||
displayVolumeEnabled = true;
|
||||
if (displayVolume == null) {
|
||||
displayVolume = true;
|
||||
} else {
|
||||
if (!_accountMgr.isRootAdmin(caller.getType())) {
|
||||
throw new PermissionDeniedException("Cannot update parameter displayvolume, only admin permitted ");
|
||||
|
|
@ -387,7 +387,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
|||
}
|
||||
|
||||
// Check that the resource limit for volumes won't be exceeded
|
||||
_resourceLimitMgr.checkResourceLimit(_accountMgr.getAccount(ownerId), ResourceType.volume, displayVolumeEnabled);
|
||||
_resourceLimitMgr.checkResourceLimit(_accountMgr.getAccount(ownerId), ResourceType.volume, displayVolume);
|
||||
|
||||
Long zoneId = cmd.getZoneId();
|
||||
Long diskOfferingId = null;
|
||||
|
|
@ -528,7 +528,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
|||
}
|
||||
|
||||
// Check that the resource limit for primary storage won't be exceeded
|
||||
_resourceLimitMgr.checkResourceLimit(_accountMgr.getAccount(ownerId), ResourceType.primary_storage, displayVolumeEnabled, new Long(size));
|
||||
_resourceLimitMgr.checkResourceLimit(_accountMgr.getAccount(ownerId), ResourceType.primary_storage, displayVolume, new Long(size));
|
||||
|
||||
// Verify that zone exists
|
||||
DataCenterVO zone = _dcDao.findById(zoneId);
|
||||
|
|
@ -552,13 +552,13 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
|||
userSpecifiedName = getRandomVolumeName();
|
||||
}
|
||||
|
||||
VolumeVO volume = commitVolume(cmd, caller, ownerId, displayVolumeEnabled, zoneId, diskOfferingId, size, minIops, maxIops, parentVolume, userSpecifiedName,
|
||||
VolumeVO volume = commitVolume(cmd, caller, ownerId, displayVolume, zoneId, diskOfferingId, size, minIops, maxIops, parentVolume, userSpecifiedName,
|
||||
_uuidMgr.generateUuid(Volume.class, cmd.getCustomId()));
|
||||
|
||||
return volume;
|
||||
}
|
||||
|
||||
private VolumeVO commitVolume(final CreateVolumeCmd cmd, final Account caller, final long ownerId, final Boolean displayVolumeEnabled, final Long zoneId,
|
||||
private VolumeVO commitVolume(final CreateVolumeCmd cmd, final Account caller, final long ownerId, final Boolean displayVolume, final Long zoneId,
|
||||
final Long diskOfferingId, final Long size, final Long minIops, final Long maxIops, final VolumeVO parentVolume, final String userSpecifiedName, final String uuid) {
|
||||
return Transaction.execute(new TransactionCallback<VolumeVO>() {
|
||||
@Override
|
||||
|
|
@ -577,7 +577,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
|||
volume.setInstanceId(null);
|
||||
volume.setUpdated(new Date());
|
||||
volume.setDomainId((caller == null) ? Domain.ROOT_DOMAIN : caller.getDomainId());
|
||||
volume.setDisplayVolume(displayVolumeEnabled);
|
||||
volume.setDisplayVolume(displayVolume);
|
||||
if (parentVolume != null) {
|
||||
volume.setTemplateId(parentVolume.getTemplateId());
|
||||
volume.setFormat(parentVolume.getFormat());
|
||||
|
|
@ -596,8 +596,8 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
|||
|
||||
// Increment resource count during allocation; if actual creation fails,
|
||||
// decrement it
|
||||
_resourceLimitMgr.incrementResourceCount(volume.getAccountId(), ResourceType.volume, displayVolumeEnabled);
|
||||
_resourceLimitMgr.incrementResourceCount(volume.getAccountId(), ResourceType.primary_storage, displayVolumeEnabled, new Long(volume.getSize()));
|
||||
_resourceLimitMgr.incrementResourceCount(volume.getAccountId(), ResourceType.volume, displayVolume);
|
||||
_resourceLimitMgr.incrementResourceCount(volume.getAccountId(), ResourceType.primary_storage, displayVolume, new Long(volume.getSize()));
|
||||
return volume;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1826,7 +1826,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||
String displayName = cmd.getDisplayName();
|
||||
String group = cmd.getGroup();
|
||||
Boolean ha = cmd.getHaEnable();
|
||||
Boolean isDisplayVmEnabled = cmd.getDisplayVm();
|
||||
Boolean isDisplayVm = cmd.getDisplayVm();
|
||||
Long id = cmd.getId();
|
||||
Long osTypeId = cmd.getOsTypeId();
|
||||
String userData = cmd.getUserData();
|
||||
|
|
@ -1842,17 +1842,14 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||
_accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, true, vmInstance);
|
||||
|
||||
//If the flag is specified and is changed
|
||||
if (isDisplayVmEnabled != null && isDisplayVmEnabled != vmInstance.isDisplayVm()) {
|
||||
if (!_accountMgr.isRootAdmin(caller.getType())) {
|
||||
throw new PermissionDeniedException("Cannot update parameter displayvm, only admin permitted ");
|
||||
}
|
||||
if (isDisplayVm != null && isDisplayVm != vmInstance.isDisplayVm()) {
|
||||
ServiceOffering offering = _serviceOfferingDao.findByIdIncludingRemoved(vmInstance.getServiceOfferingId());
|
||||
_resourceLimitMgr.changeResourceCount(vmInstance.getAccountId(), ResourceType.user_vm, isDisplayVmEnabled);
|
||||
_resourceLimitMgr.changeResourceCount(vmInstance.getAccountId(), ResourceType.cpu, isDisplayVmEnabled, new Long(offering.getCpu()));
|
||||
_resourceLimitMgr.changeResourceCount(vmInstance.getAccountId(), ResourceType.memory, isDisplayVmEnabled, new Long(offering.getRamSize()));
|
||||
_resourceLimitMgr.changeResourceCount(vmInstance.getAccountId(), ResourceType.user_vm, isDisplayVm);
|
||||
_resourceLimitMgr.changeResourceCount(vmInstance.getAccountId(), ResourceType.cpu, isDisplayVm, new Long(offering.getCpu()));
|
||||
_resourceLimitMgr.changeResourceCount(vmInstance.getAccountId(), ResourceType.memory, isDisplayVm, new Long(offering.getRamSize()));
|
||||
}
|
||||
|
||||
return updateVirtualMachine(id, displayName, group, ha, isDisplayVmEnabled, osTypeId, userData, isDynamicallyScalable, cmd.getHttpMethod(), cmd.getCustomId());
|
||||
return updateVirtualMachine(id, displayName, group, ha, isDisplayVm, osTypeId, userData, isDynamicallyScalable, cmd.getHttpMethod(), cmd.getCustomId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -2460,7 +2457,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||
@DB
|
||||
protected UserVm createVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate tmplt, String hostName, String displayName, Account owner,
|
||||
Long diskOfferingId, Long diskSize, List<NetworkVO> networkList, List<Long> securityGroupIdList, String group, HTTPMethod httpmethod, String userData,
|
||||
String sshKeyPair, HypervisorType hypervisor, Account caller, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps, Boolean isDisplayVmEnabled, String keyboard,
|
||||
String sshKeyPair, HypervisorType hypervisor, Account caller, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps, Boolean isDisplayVm, String keyboard,
|
||||
List<Long> affinityGroupIdList, Map<String, String> customParameters, String customId) throws InsufficientCapacityException, ResourceUnavailableException,
|
||||
ConcurrentOperationException, StorageUnavailableException, ResourceAllocationException {
|
||||
|
||||
|
|
@ -2524,7 +2521,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||
}
|
||||
size += _diskOfferingDao.findById(diskOfferingId).getDiskSize();
|
||||
}
|
||||
resourceLimitCheck(owner, isDisplayVmEnabled, new Long(offering.getCpu()), new Long(offering.getRamSize()));
|
||||
resourceLimitCheck(owner, isDisplayVm, new Long(offering.getCpu()), new Long(offering.getRamSize()));
|
||||
|
||||
_resourceLimitMgr.checkResourceLimit(owner, ResourceType.volume, (isIso || diskOfferingId == null ? 1 : 2));
|
||||
_resourceLimitMgr.checkResourceLimit(owner, ResourceType.primary_storage, size);
|
||||
|
|
@ -2765,7 +2762,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||
hypervisorType = template.getHypervisorType();
|
||||
}
|
||||
|
||||
UserVmVO vm = commitUserVm(zone, template, hostName, displayName, owner, diskOfferingId, diskSize, userData, hypervisor, caller, isDisplayVmEnabled, keyboard, accountId,
|
||||
UserVmVO vm = commitUserVm(zone, template, hostName, displayName, owner, diskOfferingId, diskSize, userData, hypervisor, caller, isDisplayVm, keyboard, accountId,
|
||||
offering, isIso, sshPublicKey, networkNicMap, id, instanceName, uuidName, hypervisorType, customParameters);
|
||||
|
||||
// Assign instance to the group
|
||||
|
|
@ -2794,7 +2791,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||
}
|
||||
|
||||
private UserVmVO commitUserVm(final DataCenter zone, final VirtualMachineTemplate template, final String hostName, final String displayName, final Account owner,
|
||||
final Long diskOfferingId, final Long diskSize, final String userData, final HypervisorType hypervisor, final Account caller, final Boolean isDisplayVmEnabled,
|
||||
final Long diskOfferingId, final Long diskSize, final String userData, final HypervisorType hypervisor, final Account caller, final Boolean isDisplayVm,
|
||||
final String keyboard, final long accountId, final ServiceOfferingVO offering, final boolean isIso, final String sshPublicKey,
|
||||
final LinkedHashMap<String, NicProfile> networkNicMap, final long id, final String instanceName, final String uuidName, final HypervisorType hypervisorType,
|
||||
final Map<String, String> customParameters) throws InsufficientCapacityException {
|
||||
|
|
@ -2824,11 +2821,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||
customParameters.remove("rootdisksize");
|
||||
}
|
||||
|
||||
if (isDisplayVmEnabled != null) {
|
||||
if (!_accountMgr.isRootAdmin(caller.getType())) {
|
||||
throw new PermissionDeniedException("Cannot update parameter displayvm, only admin permitted ");
|
||||
}
|
||||
vm.setDisplayVm(isDisplayVmEnabled);
|
||||
if (isDisplayVm != null) {
|
||||
vm.setDisplayVm(isDisplayVm);
|
||||
} else {
|
||||
vm.setDisplayVm(true);
|
||||
}
|
||||
|
|
@ -2906,7 +2900,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||
}
|
||||
|
||||
//Update Resource Count for the given account
|
||||
resourceCountIncrement(accountId, isDisplayVmEnabled, new Long(offering.getCpu()), new Long(offering.getRamSize()));
|
||||
resourceCountIncrement(accountId, isDisplayVm, new Long(offering.getCpu()), new Long(offering.getRamSize()));
|
||||
return vm;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkOrches
|
|||
* @see com.cloud.network.NetworkService#allocateIP(com.cloud.user.Account, long, java.lang.Long)
|
||||
*/
|
||||
@Override
|
||||
public IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId) throws ResourceAllocationException, InsufficientAddressCapacityException,
|
||||
public IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId, Boolean displayIp) throws ResourceAllocationException, InsufficientAddressCapacityException,
|
||||
ConcurrentOperationException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
|
|
@ -858,7 +858,7 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkOrches
|
|||
}
|
||||
|
||||
@Override
|
||||
public IpAddress updateIP(Long id, String customId) {
|
||||
public IpAddress updateIP(Long id, String customId, Boolean displayIp) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -528,3 +528,9 @@ UPDATE `cloud`.`vpc_details` set `display`=1 where id> 0;
|
|||
|
||||
ALTER TABLE `cloud`.`vpc_gateway_details` CHANGE `display` `display` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'True if the detail can be displayed to the end user';
|
||||
UPDATE `cloud`.`vpc_gateway_details` set `display`=1 where id> 0;
|
||||
|
||||
ALTER TABLE `cloud`.`user_ip_address` ADD COLUMN `display` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'True if the ip address can be displayed to the end user';
|
||||
ALTER TABLE `cloud`.`vpc` ADD COLUMN `display` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'True if the vpc can be displayed to the end user';
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue