diff --git a/api/src/com/cloud/network/IpAddress.java b/api/src/com/cloud/network/IpAddress.java index a3816cb3ded..5aae7842798 100644 --- a/api/src/com/cloud/network/IpAddress.java +++ b/api/src/com/cloud/network/IpAddress.java @@ -85,4 +85,6 @@ public interface IpAddress extends ControlledEntity, Identity, InternalIdentity Long getNetworkId(); + boolean isDisplay(); + } diff --git a/api/src/com/cloud/network/NetworkService.java b/api/src/com/cloud/network/NetworkService.java index 072a27d1003..1e126f52aee 100755 --- a/api/src/com/cloud/network/NetworkService.java +++ b/api/src/com/cloud/network/NetworkService.java @@ -50,7 +50,7 @@ public interface NetworkService { List 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 getNetworkOfferingServiceCapabilities(NetworkOffering offering, Service service); - IpAddress updateIP(Long id, String customId); + IpAddress updateIP(Long id, String customId, Boolean displayIp); } diff --git a/api/src/com/cloud/network/vpc/Vpc.java b/api/src/com/cloud/network/vpc/Vpc.java index fb5f2cc8991..eb7e39134c3 100644 --- a/api/src/com/cloud/network/vpc/Vpc.java +++ b/api/src/com/cloud/network/vpc/Vpc.java @@ -72,4 +72,5 @@ public interface Vpc extends ControlledEntity, Identity, InternalIdentity { */ boolean isRestartRequired(); + boolean isDisplay(); } diff --git a/api/src/com/cloud/network/vpc/VpcService.java b/api/src/com/cloud/network/vpc/VpcService.java index 218e6755c94..3b1c005b1ec 100644 --- a/api/src/com/cloud/network/vpc/VpcService.java +++ b/api/src/com/cloud/network/vpc/VpcService.java @@ -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 diff --git a/api/src/org/apache/cloudstack/api/ApiConstants.java b/api/src/org/apache/cloudstack/api/ApiConstants.java index 3699102af37..7b7f9ca6012 100755 --- a/api/src/org/apache/cloudstack/api/ApiConstants.java +++ b/api/src/org/apache/cloudstack/api/ApiConstants.java @@ -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; diff --git a/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java b/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java index 4df658bcbb4..ed01c60f14c 100644 --- a/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java @@ -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()); } diff --git a/api/src/org/apache/cloudstack/api/command/user/address/UpdateIPAddrCmd.java b/api/src/org/apache/cloudstack/api/command/user/address/UpdateIPAddrCmd.java index b45bf94312b..16dcc4e65c1 100644 --- a/api/src/org/apache/cloudstack/api/command/user/address/UpdateIPAddrCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/address/UpdateIPAddrCmd.java @@ -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); diff --git a/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java index c1e56ebd638..018f16e42cf 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java @@ -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") diff --git a/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java index 85bea5f6c1b..e327de1d71c 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java @@ -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; ///////////////////////////////////////////////////// diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java index eb19db43866..055832efc7f 100755 --- a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java @@ -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 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.") diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/UpdateVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/UpdateVMCmd.java index 0639477c3f7..1b5613c279c 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vm/UpdateVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vm/UpdateVMCmd.java @@ -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, diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/AddResourceDetailCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/AddResourceDetailCmd.java index a36f1b59c76..8c6713de68f 100644 --- a/api/src/org/apache/cloudstack/api/command/user/volume/AddResourceDetailCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/volume/AddResourceDetailCmd.java @@ -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; ///////////////////////////////////////////////////// diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java index c6457c60eb3..ebade6661c5 100644 --- a/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java @@ -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, diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/UpdateVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/UpdateVolumeCmd.java index 78d402b31d5..9f501bfda2a 100644 --- a/api/src/org/apache/cloudstack/api/command/user/volume/UpdateVolumeCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/volume/UpdateVolumeCmd.java @@ -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; ///////////////////////////////////////////////////// diff --git a/api/src/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmd.java index d4c52b8e42a..dfec95c0feb 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmd.java @@ -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()); diff --git a/api/src/org/apache/cloudstack/api/command/user/vpc/UpdateVPCCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpc/UpdateVPCCmd.java index 3f24a2f13ee..1900def5021 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpc/UpdateVPCCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpc/UpdateVPCCmd.java @@ -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()); diff --git a/api/src/org/apache/cloudstack/api/response/IPAddressResponse.java b/api/src/org/apache/cloudstack/api/response/IPAddressResponse.java index 4889a5638c3..1f51d5a4dbb 100644 --- a/api/src/org/apache/cloudstack/api/response/IPAddressResponse.java +++ b/api/src/org/apache/cloudstack/api/response/IPAddressResponse.java @@ -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; + } } diff --git a/api/src/org/apache/cloudstack/api/response/VolumeResponse.java b/api/src/org/apache/cloudstack/api/response/VolumeResponse.java index 4cba2a1408e..319a7340255 100644 --- a/api/src/org/apache/cloudstack/api/response/VolumeResponse.java +++ b/api/src/org/apache/cloudstack/api/response/VolumeResponse.java @@ -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; } diff --git a/api/src/org/apache/cloudstack/api/response/VpcResponse.java b/api/src/org/apache/cloudstack/api/response/VpcResponse.java index fd9b710bc27..928d1b24f85 100644 --- a/api/src/org/apache/cloudstack/api/response/VpcResponse.java +++ b/api/src/org/apache/cloudstack/api/response/VpcResponse.java @@ -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 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 tags) { this.tags = tags; } + + public void setForDisplay(Boolean forDisplay) { + this.forDisplay = forDisplay; + } } diff --git a/engine/components-api/src/com/cloud/network/IpAddressManager.java b/engine/components-api/src/com/cloud/network/IpAddressManager.java index 9ccc9466f70..98ff55cad73 100644 --- a/engine/components-api/src/com/cloud/network/IpAddressManager.java +++ b/engine/components-api/src/com/cloud/network/IpAddressManager.java @@ -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 vlanDbIds, Long networkId, String requestedIp, diff --git a/engine/components-api/src/com/cloud/network/addr/PublicIp.java b/engine/components-api/src/com/cloud/network/addr/PublicIp.java index 27c247854e7..9a1b66324f0 100644 --- a/engine/components-api/src/com/cloud/network/addr/PublicIp.java +++ b/engine/components-api/src/com/cloud/network/addr/PublicIp.java @@ -231,4 +231,9 @@ public class PublicIp implements PublicIpAddress { public Long getIpMacAddress() { return _addr.getMacAddress(); } + + @Override + public boolean isDisplay() { + return _addr.isDisplay(); + } } diff --git a/engine/schema/src/com/cloud/network/dao/IPAddressDaoImpl.java b/engine/schema/src/com/cloud/network/dao/IPAddressDaoImpl.java index 97c4de142b1..b569718965f 100755 --- a/engine/schema/src/com/cloud/network/dao/IPAddressDaoImpl.java +++ b/engine/schema/src/com/cloud/network/dao/IPAddressDaoImpl.java @@ -165,6 +165,7 @@ public class IPAddressDaoImpl extends GenericDaoBase implemen address.setVpcId(null); address.setSystem(false); address.setVmIp(null); + address.setDisplay(true); update(ipAddressId, address); } diff --git a/engine/schema/src/com/cloud/network/dao/IPAddressVO.java b/engine/schema/src/com/cloud/network/dao/IPAddressVO.java index d71a90fc4fc..9abecbef05b 100644 --- a/engine/schema/src/com/cloud/network/dao/IPAddressVO.java +++ b/engine/schema/src/com/cloud/network/dao/IPAddressVO.java @@ -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; + } } diff --git a/engine/schema/src/com/cloud/network/vpc/VpcVO.java b/engine/schema/src/com/cloud/network/vpc/VpcVO.java index 5f3528d97b9..7d1933a6727 100644 --- a/engine/schema/src/com/cloud/network/vpc/VpcVO.java +++ b/engine/schema/src/com/cloud/network/vpc/VpcVO.java @@ -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; + } } diff --git a/plugins/network-elements/cisco-vnmc/src/com/cloud/network/element/CiscoVnmcElement.java b/plugins/network-elements/cisco-vnmc/src/com/cloud/network/element/CiscoVnmcElement.java index 03fac266700..5ad64a0e148 100644 --- a/plugins/network-elements/cisco-vnmc/src/com/cloud/network/element/CiscoVnmcElement.java +++ b/plugins/network-elements/cisco-vnmc/src/com/cloud/network/element/CiscoVnmcElement.java @@ -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); diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index 4d9c2ddfb9e..c566a5d5a88 100755 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -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> serviceProviderMap = ApiDBUtils.listVpcOffServices(vpc.getVpcOfferingId()); List serviceResponses = new ArrayList(); diff --git a/server/src/com/cloud/network/IpAddressManagerImpl.java b/server/src/com/cloud/network/IpAddressManagerImpl.java index d88755d27a1..8903d1d1137 100644 --- a/server/src/com/cloud/network/IpAddressManagerImpl.java +++ b/server/src/com/cloud/network/IpAddressManagerImpl.java @@ -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 AssignIpAddressSearch; SearchBuilder 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 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 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() { @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() { @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"); diff --git a/server/src/com/cloud/network/NetworkServiceImpl.java b/server/src/com/cloud/network/NetworkServiceImpl.java index bcadd69fef7..2c673d2e569 100755 --- a/server/src/com/cloud/network/NetworkServiceImpl.java +++ b/server/src/com/cloud/network/NetworkServiceImpl.java @@ -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); } diff --git a/server/src/com/cloud/network/vpc/VpcManagerImpl.java b/server/src/com/cloud/network/vpc/VpcManagerImpl.java index b95f689ffea..2157eacf986 100644 --- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java +++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java @@ -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 diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java index 614834ea299..c95d3161355 100644 --- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java @@ -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() { @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; } }); diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index c53b95f9d83..97e3ae78182 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -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 networkList, List securityGroupIdList, String group, HTTPMethod httpmethod, String userData, - String sshKeyPair, HypervisorType hypervisor, Account caller, Map requestedIps, IpAddresses defaultIps, Boolean isDisplayVmEnabled, String keyboard, + String sshKeyPair, HypervisorType hypervisor, Account caller, Map requestedIps, IpAddresses defaultIps, Boolean isDisplayVm, String keyboard, List affinityGroupIdList, Map 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 networkNicMap, final long id, final String instanceName, final String uuidName, final HypervisorType hypervisorType, final Map 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; } }); diff --git a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java index 68390f87c71..b06ddf14914 100644 --- a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java +++ b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java @@ -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; } diff --git a/setup/db/db/schema-430to440.sql b/setup/db/db/schema-430to440.sql index a98df26ff04..c11f446ad3f 100644 --- a/setup/db/db/schema-430to440.sql +++ b/setup/db/db/schema-430to440.sql @@ -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'; + + +