You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2012/12/04 11:02:56 UTC
[29/55] [abbrv] api_refactor: refactor project apis
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5e0501d1/api/src/com/cloud/api/commands/AuthorizeSecurityGroupEgressCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/AuthorizeSecurityGroupEgressCmd.java b/api/src/com/cloud/api/commands/AuthorizeSecurityGroupEgressCmd.java
index 13303a4..3abed2a 100644
--- a/api/src/com/cloud/api/commands/AuthorizeSecurityGroupEgressCmd.java
+++ b/api/src/com/cloud/api/commands/AuthorizeSecurityGroupEgressCmd.java
@@ -69,22 +69,22 @@ public class AuthorizeSecurityGroupEgressCmd extends BaseAsyncCmd {
@Parameter(name = ApiConstants.USER_SECURITY_GROUP_LIST, type = CommandType.MAP, description = "user to security group mapping")
private Map userSecurityGroupList;
-
+
@IdentityMapper(entityTableName="domain")
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="an optional domainId for the security group. If the account parameter is used, domainId must also be used.")
private Long domainId;
-
+
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional account for the security group. Must be used with domainId.")
private String accountName;
-
+
@IdentityMapper(entityTableName="projects")
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="an optional project of the security group")
private Long projectId;
-
+
@IdentityMapper(entityTableName="security_group")
@Parameter(name=ApiConstants.SECURITY_GROUP_ID, type=CommandType.LONG, description="The ID of the security group. Mutually exclusive with securityGroupName parameter")
private Long securityGroupId;
-
+
@Parameter(name=ApiConstants.SECURITY_GROUP_NAME, type=CommandType.STRING, description="The name of the security group. Mutually exclusive with securityGroupName parameter")
private String securityGroupName;
@@ -116,7 +116,7 @@ public class AuthorizeSecurityGroupEgressCmd extends BaseAsyncCmd {
if (securityGroupId != null && securityGroupName != null) {
throw new InvalidParameterValueException("securityGroupId and securityGroupName parameters are mutually exclusive");
}
-
+
if (securityGroupName != null) {
securityGroupId = _responseGenerator.getSecurityGroupId(securityGroupName, getEntityOwnerId());
if (securityGroupId == null) {
@@ -124,11 +124,11 @@ public class AuthorizeSecurityGroupEgressCmd extends BaseAsyncCmd {
}
securityGroupName = null;
}
-
+
if (securityGroupId == null) {
throw new InvalidParameterValueException("Either securityGroupId or securityGroupName is required by authorizeSecurityGroupIngress command");
}
-
+
return securityGroupId;
}
@@ -166,7 +166,7 @@ public class AuthorizeSecurityGroupEgressCmd extends BaseAsyncCmd {
if (accountId == null) {
return UserContext.current().getCaller().getId();
}
-
+
return accountId;
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5e0501d1/api/src/com/cloud/api/commands/AuthorizeSecurityGroupIngressCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/AuthorizeSecurityGroupIngressCmd.java b/api/src/com/cloud/api/commands/AuthorizeSecurityGroupIngressCmd.java
index 21b4eb0..dc8e605 100644
--- a/api/src/com/cloud/api/commands/AuthorizeSecurityGroupIngressCmd.java
+++ b/api/src/com/cloud/api/commands/AuthorizeSecurityGroupIngressCmd.java
@@ -72,22 +72,22 @@ public class AuthorizeSecurityGroupIngressCmd extends BaseAsyncCmd {
@Parameter(name = ApiConstants.USER_SECURITY_GROUP_LIST, type = CommandType.MAP, description = "user to security group mapping")
private Map userSecurityGroupList;
-
+
@IdentityMapper(entityTableName="domain")
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="an optional domainId for the security group. If the account parameter is used, domainId must also be used.")
private Long domainId;
-
+
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional account for the security group. Must be used with domainId.")
private String accountName;
-
+
@IdentityMapper(entityTableName="projects")
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="an optional project of the security group")
private Long projectId;
-
+
@IdentityMapper(entityTableName="security_group")
@Parameter(name=ApiConstants.SECURITY_GROUP_ID, type=CommandType.LONG, description="The ID of the security group. Mutually exclusive with securityGroupName parameter")
private Long securityGroupId;
-
+
@Parameter(name=ApiConstants.SECURITY_GROUP_NAME, type=CommandType.STRING, description="The name of the security group. Mutually exclusive with securityGroupName parameter")
private String securityGroupName;
@@ -119,7 +119,7 @@ public class AuthorizeSecurityGroupIngressCmd extends BaseAsyncCmd {
if (securityGroupId != null && securityGroupName != null) {
throw new InvalidParameterValueException("securityGroupId and securityGroupName parameters are mutually exclusive");
}
-
+
if (securityGroupName != null) {
securityGroupId = _responseGenerator.getSecurityGroupId(securityGroupName, getEntityOwnerId());
if (securityGroupId == null) {
@@ -127,11 +127,11 @@ public class AuthorizeSecurityGroupIngressCmd extends BaseAsyncCmd {
}
securityGroupName = null;
}
-
+
if (securityGroupId == null) {
throw new InvalidParameterValueException("Either securityGroupId or securityGroupName is required by authorizeSecurityGroupIngress command");
}
-
+
return securityGroupId;
}
@@ -169,7 +169,7 @@ public class AuthorizeSecurityGroupIngressCmd extends BaseAsyncCmd {
if (accountId == null) {
return UserContext.current().getCaller().getId();
}
-
+
return accountId;
}
@@ -210,7 +210,7 @@ public class AuthorizeSecurityGroupIngressCmd extends BaseAsyncCmd {
@Override
public void execute() {
if(cidrList != null){
- for(String cidr : cidrList ){
+ for(String cidr : cidrList ){
if (!NetUtils.isValidCIDR(cidr)){
throw new ServerApiException(BaseCmd.PARAM_ERROR, cidr + " is an Invalid CIDR ");
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5e0501d1/api/src/com/cloud/api/commands/CancelMaintenanceCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CancelMaintenanceCmd.java b/api/src/com/cloud/api/commands/CancelMaintenanceCmd.java
index 155a071..dfd7c88 100644
--- a/api/src/com/cloud/api/commands/CancelMaintenanceCmd.java
+++ b/api/src/com/cloud/api/commands/CancelMaintenanceCmd.java
@@ -64,9 +64,9 @@ public class CancelMaintenanceCmd extends BaseAsyncCmd {
public String getCommandName() {
return s_name;
}
-
+
public static String getResultObjectName() {
- return "host";
+ return "host";
}
@Override
@@ -88,17 +88,17 @@ public class CancelMaintenanceCmd extends BaseAsyncCmd {
public String getEventDescription() {
return "canceling maintenance for host: " + getId();
}
-
+
@Override
public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.Host;
+ return AsyncJob.Type.Host;
}
-
+
@Override
public Long getInstanceId() {
- return getId();
+ return getId();
}
-
+
@Override
public void execute(){
Host result = _resourceService.cancelMaintenance(this);
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5e0501d1/api/src/com/cloud/api/commands/CancelPrimaryStorageMaintenanceCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CancelPrimaryStorageMaintenanceCmd.java b/api/src/com/cloud/api/commands/CancelPrimaryStorageMaintenanceCmd.java
index 585490f..400aa9c 100644
--- a/api/src/com/cloud/api/commands/CancelPrimaryStorageMaintenanceCmd.java
+++ b/api/src/com/cloud/api/commands/CancelPrimaryStorageMaintenanceCmd.java
@@ -35,8 +35,8 @@ import com.cloud.user.UserContext;
@Implementation(description="Cancels maintenance for primary storage", responseObject=StoragePoolResponse.class)
public class CancelPrimaryStorageMaintenanceCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(CancelPrimaryStorageMaintenanceCmd.class.getName());
-
+ public static final Logger s_logger = Logger.getLogger(CancelPrimaryStorageMaintenanceCmd.class.getName());
+
private static final String s_name = "cancelprimarystoragemaintenanceresponse";
/////////////////////////////////////////////////////
@@ -65,16 +65,16 @@ public class CancelPrimaryStorageMaintenanceCmd extends BaseAsyncCmd {
public String getCommandName() {
return s_name;
}
-
+
public static String getResultObjectName() {
- return "primarystorage";
+ return "primarystorage";
}
-
+
@Override
public AsyncJob.Type getInstanceType() {
return AsyncJob.Type.StoragePool;
}
-
+
@Override
public Long getInstanceId() {
return getId();
@@ -99,7 +99,7 @@ public class CancelPrimaryStorageMaintenanceCmd extends BaseAsyncCmd {
public String getEventDescription() {
return "canceling maintenance for primary storage pool: " + getId();
}
-
+
@Override
public void execute() throws ResourceUnavailableException{
StoragePool result = _storageService.cancelPrimaryStorageForMaintenance(this);
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5e0501d1/api/src/com/cloud/api/commands/ConfigureVirtualRouterElementCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ConfigureVirtualRouterElementCmd.java b/api/src/com/cloud/api/commands/ConfigureVirtualRouterElementCmd.java
index 923cd1a..c130637 100644
--- a/api/src/com/cloud/api/commands/ConfigureVirtualRouterElementCmd.java
+++ b/api/src/com/cloud/api/commands/ConfigureVirtualRouterElementCmd.java
@@ -39,9 +39,9 @@ import com.cloud.user.UserContext;
@Implementation(responseObject=VirtualRouterProviderResponse.class, description="Configures a virtual router element.")
public class ConfigureVirtualRouterElementCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(ConfigureVirtualRouterElementCmd.class.getName());
+ public static final Logger s_logger = Logger.getLogger(ConfigureVirtualRouterElementCmd.class.getName());
private static final String s_name = "configurevirtualrouterelementresponse";
-
+
@PlugService
private VirtualRouterElementService _service;
@@ -56,7 +56,7 @@ public class ConfigureVirtualRouterElementCmd extends BaseAsyncCmd {
@IdentityMapper(entityTableName = "physical_network_service_providers")
@Parameter(name=ApiConstants.ENABLED, type=CommandType.BOOLEAN, required=true, description="Enabled/Disabled the service provider")
private Boolean enabled;
-
+
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@@ -85,11 +85,11 @@ public class ConfigureVirtualRouterElementCmd extends BaseAsyncCmd {
public String getCommandName() {
return s_name;
}
-
+
public static String getResultObjectName() {
- return "boolean";
+ return "boolean";
}
-
+
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
@@ -104,15 +104,15 @@ public class ConfigureVirtualRouterElementCmd extends BaseAsyncCmd {
public String getEventDescription() {
return "configuring virtual router provider: " + id;
}
-
+
public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.None;
+ return AsyncJob.Type.None;
}
-
+
public Long getInstanceId() {
return id;
}
-
+
@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
UserContext.current().setEventDetails("Virtual router element: " + id);
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5e0501d1/api/src/com/cloud/api/commands/CopyTemplateCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CopyTemplateCmd.java b/api/src/com/cloud/api/commands/CopyTemplateCmd.java
index fc5d09d..6f7bdf6 100755
--- a/api/src/com/cloud/api/commands/CopyTemplateCmd.java
+++ b/api/src/com/cloud/api/commands/CopyTemplateCmd.java
@@ -38,7 +38,7 @@ import com.cloud.user.UserContext;
@Implementation(description="Copies a template from one zone to another.", responseObject=TemplateResponse.class)
public class CopyTemplateCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(CopyTemplateCmd.class.getName());
+ public static final Logger s_logger = Logger.getLogger(CopyTemplateCmd.class.getName());
private static final String s_name = "copytemplateresponse";
/////////////////////////////////////////////////////
@@ -107,29 +107,29 @@ public class CopyTemplateCmd extends BaseAsyncCmd {
public String getEventDescription() {
return "copying template: " + getId() + " from zone: " + getSourceZoneId() + " to zone: " + getDestinationZoneId();
}
-
+
public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.Template;
+ return AsyncJob.Type.Template;
}
-
+
public Long getInstanceId() {
- return getId();
+ return getId();
}
@Override
public void execute() throws ResourceAllocationException{
try {
- UserContext.current().setEventDetails(getEventDescription());
+ UserContext.current().setEventDetails(getEventDescription());
VirtualMachineTemplate template = _templateService.copyTemplate(this);
-
+
if (template != null){
List<TemplateResponse> listResponse = _responseGenerator.createTemplateResponses(template.getId(), getDestinationZoneId(), false);
TemplateResponse response = new TemplateResponse();
if (listResponse != null && !listResponse.isEmpty()) {
response = listResponse.get(0);
}
-
- response.setResponseName(getCommandName());
+
+ response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to copy template");
@@ -137,7 +137,7 @@ public class CopyTemplateCmd extends BaseAsyncCmd {
} catch (StorageUnavailableException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
- }
+ }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5e0501d1/api/src/com/cloud/api/commands/CreateAccountCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CreateAccountCmd.java b/api/src/com/cloud/api/commands/CreateAccountCmd.java
index 57f6149..d1d3996 100755
--- a/api/src/com/cloud/api/commands/CreateAccountCmd.java
+++ b/api/src/com/cloud/api/commands/CreateAccountCmd.java
@@ -70,11 +70,11 @@ public class CreateAccountCmd extends BaseCmd {
@Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, required=true, description="Unique username.")
private String userName;
-
+
@Parameter(name=ApiConstants.NETWORK_DOMAIN, type=CommandType.STRING, description="Network domain for the account's networks")
private String networkDomain;
- @Parameter(name = ApiConstants.ACCOUNT_DETAILS, type = CommandType.MAP, description = "details for account used to store specific parameters")
+ @Parameter(name = ApiConstants.ACCOUNT_DETAILS, type = CommandType.MAP, description = "details for account used to store specific parameters")
private Map<String, String> details;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@@ -115,19 +115,19 @@ public class CreateAccountCmd extends BaseCmd {
public String getUsername() {
return userName;
}
-
+
public String getNetworkDomain() {
return networkDomain;
- }
-
+ }
+
public Map<String, String> getDetails() {
- if (details == null || details.isEmpty()) {
- return null;
- }
-
- Collection<String> paramsCollection = details.values();
- Map<String, String> params = (Map<String, String>) (paramsCollection.toArray())[0];
- return params;
+ if (details == null || details.isEmpty()) {
+ return null;
+ }
+
+ Collection<String> paramsCollection = details.values();
+ Map<String, String> params = (Map<String, String>) (paramsCollection.toArray())[0];
+ return params;
}
/////////////////////////////////////////////////////
@@ -138,12 +138,12 @@ public class CreateAccountCmd extends BaseCmd {
public String getCommandName() {
return s_name;
}
-
+
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
-
+
@Override
public void execute(){
UserContext.current().setEventDetails("Account Name: "+getAccountName()+", Domain Id:"+getDomainId());
@@ -156,4 +156,4 @@ public class CreateAccountCmd extends BaseCmd {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create a user account");
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5e0501d1/api/src/com/cloud/api/commands/CreateDiskOfferingCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CreateDiskOfferingCmd.java b/api/src/com/cloud/api/commands/CreateDiskOfferingCmd.java
index bbe3f17..7478933 100755
--- a/api/src/com/cloud/api/commands/CreateDiskOfferingCmd.java
+++ b/api/src/com/cloud/api/commands/CreateDiskOfferingCmd.java
@@ -53,10 +53,10 @@ public class CreateDiskOfferingCmd extends BaseCmd {
@Parameter(name=ApiConstants.CUSTOMIZED, type=CommandType.BOOLEAN, description="whether disk offering is custom or not")
private Boolean customized;
-
+
@IdentityMapper(entityTableName="domain")
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the ID of the containing domain, null for public offerings")
- private Long domainId;
+ private Long domainId;
@Parameter(name=ApiConstants.STORAGE_TYPE, type=CommandType.STRING, description="the storage type of the disk offering. Values are local and shared.")
private String storageType = ServiceOffering.StorageType.shared.toString();
@@ -82,11 +82,11 @@ public class CreateDiskOfferingCmd extends BaseCmd {
}
public Boolean isCustomized(){
- return customized;
+ return customized;
}
-
+
public Long getDomainId(){
- return domainId;
+ return domainId;
}
public String getStorageType() {
@@ -101,12 +101,12 @@ public class CreateDiskOfferingCmd extends BaseCmd {
public String getCommandName() {
return s_name;
}
-
+
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
-
+
@Override
public void execute(){
DiskOffering offering = _configService.createDiskOffering(this);
@@ -116,6 +116,6 @@ public class CreateDiskOfferingCmd extends BaseCmd {
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create disk offering");
- }
+ }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5e0501d1/api/src/com/cloud/api/commands/CreateDomainCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CreateDomainCmd.java b/api/src/com/cloud/api/commands/CreateDomainCmd.java
index 6e59ae9..62598f2 100644
--- a/api/src/com/cloud/api/commands/CreateDomainCmd.java
+++ b/api/src/com/cloud/api/commands/CreateDomainCmd.java
@@ -63,7 +63,7 @@ public class CreateDomainCmd extends BaseCmd {
public String getNetworkDomain() {
return networkDomain;
- }
+ }
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
@@ -73,12 +73,12 @@ public class CreateDomainCmd extends BaseCmd {
public String getCommandName() {
return s_name;
}
-
+
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
-
+
@Override
public void execute(){
UserContext.current().setEventDetails("Domain Name: "+getDomainName()+((getParentDomainId()!=null)?", Parent DomainId :"+getParentDomainId():""));
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5e0501d1/api/src/com/cloud/api/commands/CreateFirewallRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CreateFirewallRuleCmd.java b/api/src/com/cloud/api/commands/CreateFirewallRuleCmd.java
index d01d92d..877fd7e 100644
--- a/api/src/com/cloud/api/commands/CreateFirewallRuleCmd.java
+++ b/api/src/com/cloud/api/commands/CreateFirewallRuleCmd.java
@@ -63,25 +63,25 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal
@Parameter(name = ApiConstants.END_PORT, type = CommandType.INTEGER, description = "the ending port of firewall rule")
private Integer publicEndPort;
-
+
@Parameter(name = ApiConstants.CIDR_LIST, type = CommandType.LIST, collectionType = CommandType.STRING, description = "the cidr list to forward traffic from")
private List<String> cidrlist;
-
+
@Parameter(name = ApiConstants.ICMP_TYPE, type = CommandType.INTEGER, description = "type of the icmp message being sent")
private Integer icmpType;
@Parameter(name = ApiConstants.ICMP_CODE, type = CommandType.INTEGER, description = "error code for this icmp message")
private Integer icmpCode;
-
+
@Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, description = "type of firewallrule: system/user")
private String type;
-
+
// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
-
+
public String getEntityTable() {
- return "firewall_rules";
+ return "firewall_rules";
}
public Long getIpAddressId() {
@@ -101,7 +101,7 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal
oneCidrList.add(NetUtils.ALL_CIDRS);
return oneCidrList;
}
-
+
}
// ///////////////////////////////////////////////////
@@ -112,7 +112,7 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal
public String getCommandName() {
return s_name;
}
-
+
public void setSourceCidrList(List<String> cidrs){
cidrlist = cidrs;
}
@@ -128,7 +128,7 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal
// State is different after the rule is applied, so get new object here
rule = _entityMgr.findById(FirewallRule.class, getEntityId());
- FirewallResponse fwResponse = new FirewallResponse();
+ FirewallResponse fwResponse = new FirewallResponse();
if (rule != null) {
fwResponse = _responseGenerator.createFirewallResponse(rule);
setResponseObject(fwResponse);
@@ -175,7 +175,7 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal
} else {
return publicEndPort.intValue();
}
-
+
return null;
}
@@ -193,13 +193,13 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal
public long getNetworkId() {
IpAddress ip = _entityMgr.findById(IpAddress.class, getIpAddressId());
Long ntwkId = null;
-
+
if (ip.getAssociatedWithNetworkId() != null) {
ntwkId = ip.getAssociatedWithNetworkId();
}
-
+
if (ntwkId == null) {
- throw new InvalidParameterValueException("Unable to create firewall rule for the ipAddress id=" + ipAddressId +
+ throw new InvalidParameterValueException("Unable to create firewall rule for the ipAddress id=" + ipAddressId +
" as ip is not associated with any network and no networkId is passed in");
}
return ntwkId;
@@ -227,7 +227,7 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal
if (getSourceCidrList() != null) {
for (String cidr: getSourceCidrList()){
if (!NetUtils.isValidCIDR(cidr)){
- throw new ServerApiException(BaseCmd.PARAM_ERROR, "Source cidrs formatting error " + cidr);
+ throw new ServerApiException(BaseCmd.PARAM_ERROR, "Source cidrs formatting error " + cidr);
}
}
}
@@ -276,7 +276,7 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal
}
return ip;
}
-
+
@Override
public Integer getIcmpCode() {
if (icmpCode != null) {
@@ -286,14 +286,14 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal
}
return null;
}
-
+
@Override
public Integer getIcmpType() {
if (icmpType != null) {
return icmpType;
} else if (protocol.equalsIgnoreCase(NetUtils.ICMP_PROTO)) {
return -1;
-
+
}
return null;
}
@@ -303,20 +303,20 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal
return null;
}
- @Override
- public FirewallRuleType getType() {
- if (type != null && type.equalsIgnoreCase("system")) {
- return FirewallRuleType.System;
- } else {
- return FirewallRuleType.User;
- }
- }
-
+ @Override
+ public FirewallRuleType getType() {
+ if (type != null && type.equalsIgnoreCase("system")) {
+ return FirewallRuleType.System;
+ } else {
+ return FirewallRuleType.User;
+ }
+ }
+
@Override
public AsyncJob.Type getInstanceType() {
return AsyncJob.Type.FirewallRule;
}
-
+
@Override
public TrafficType getTrafficType() {
return null;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5e0501d1/api/src/com/cloud/api/commands/CreateIpForwardingRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CreateIpForwardingRuleCmd.java b/api/src/com/cloud/api/commands/CreateIpForwardingRuleCmd.java
index 3df3155..9d79fdb 100644
--- a/api/src/com/cloud/api/commands/CreateIpForwardingRuleCmd.java
+++ b/api/src/com/cloud/api/commands/CreateIpForwardingRuleCmd.java
@@ -54,19 +54,19 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta
@IdentityMapper(entityTableName="user_ip_address")
@Parameter(name=ApiConstants.IP_ADDRESS_ID, type=CommandType.LONG, required=true, description="the public IP address id of the forwarding rule, already associated via associateIp")
private Long ipAddressId;
-
+
@Parameter(name=ApiConstants.START_PORT, type=CommandType.INTEGER, required=true, description="the start port for the rule")
private Integer startPort;
@Parameter(name=ApiConstants.END_PORT, type=CommandType.INTEGER, description="the end port for the rule")
private Integer endPort;
-
+
@Parameter(name=ApiConstants.PROTOCOL, type=CommandType.STRING, required=true, description="the protocol for the rule. Valid values are TCP or UDP.")
private String protocol;
-
+
@Parameter(name = ApiConstants.OPEN_FIREWALL, type = CommandType.BOOLEAN, description = "if true, firewall rule for source/end pubic port is automatically created; if false - firewall rule has to be created explicitely. Has value true by default")
private Boolean openFirewall;
-
+
@Parameter(name = ApiConstants.CIDR_LIST, type = CommandType.LIST, collectionType = CommandType.STRING, description = "the cidr list to forward traffic from")
private List<String> cidrlist;
@@ -74,23 +74,23 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
-
+
public String getEntityTable() {
- return "firewall_rules";
+ return "firewall_rules";
}
-
+
public Long getIpAddressId() {
return ipAddressId;
}
-
+
public int getStartPort() {
return startPort;
}
-
+
public int getEndPort() {
return endPort;
}
-
+
public Boolean getOpenFirewall() {
if (openFirewall != null) {
return openFirewall;
@@ -109,17 +109,17 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta
}
@Override
- public void execute() throws ResourceUnavailableException{
+ public void execute() throws ResourceUnavailableException{
boolean result = true;
FirewallRule rule = null;
try {
UserContext.current().setEventDetails("Rule Id: "+ getEntityId());
-
+
if (getOpenFirewall()) {
result = result && _firewallService.applyFirewallRules(ipAddressId, UserContext.current().getCaller());
}
-
+
result = result && _rulesService.applyStaticNatRules(ipAddressId, UserContext.current().getCaller());
rule = _entityMgr.findById(FirewallRule.class, getEntityId());
StaticNatRule staticNatRule = _rulesService.buildStaticNatRule(rule, false);
@@ -128,26 +128,26 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta
this.setResponseObject(fwResponse);
} finally {
if (!result || rule == null) {
-
+
if (getOpenFirewall()) {
_firewallService.revokeRelatedFirewallRule(getEntityId(), true);
}
-
+
_rulesService.revokeStaticNatRule(getEntityId(), true);
-
+
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Error in creating ip forwarding rule on the domr");
}
}
}
- @Override
- public void create() {
-
- //cidr list parameter is deprecated
+ @Override
+ public void create() {
+
+ //cidr list parameter is deprecated
if (cidrlist != null) {
throw new InvalidParameterValueException("Parameter cidrList is deprecated; if you need to open firewall rule for the specific cidr, please refer to createFirewallRule command");
}
-
+
try {
StaticNatRule rule = _rulesService.createStaticNatRule(this, getOpenFirewall());
this.setEntityId(rule.getId());
@@ -155,7 +155,7 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta
s_logger.info("Unable to create Static Nat Rule due to ", e);
throw new ServerApiException(BaseCmd.NETWORK_RULE_CONFLICT_ERROR, e.getMessage());
}
- }
+ }
@Override
public long getEntityOwnerId() {
@@ -178,16 +178,16 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta
IpAddress ip = _networkService.getIp(ipAddressId);
return ("Applying an ipforwarding 1:1 NAT rule for Ip: "+ip.getAddress()+" with virtual machine:"+ this.getVirtualMachineId());
}
-
+
private long getVirtualMachineId() {
Long vmId = _networkService.getIp(ipAddressId).getAssociatedWithVmId();
-
+
if (vmId == null) {
throw new InvalidParameterValueException("Ip address is not associated with any network, unable to create static nat rule");
}
return vmId;
}
-
+
@Override
public String getDestIpAddress(){
return null;
@@ -248,13 +248,13 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta
IpAddress ip = _networkService.getIp(ipAddressId);
return ip.getAccountId();
}
-
+
@Override
public String getXid() {
// FIXME: We should allow for end user to specify Xid.
return null;
}
-
+
@Override
public String getSyncObjType() {
return BaseAsyncCmd.networkSyncObject;
@@ -272,12 +272,12 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta
}
return ip;
}
-
+
@Override
public Integer getIcmpCode() {
return null;
}
-
+
@Override
public Integer getIcmpType() {
return null;
@@ -287,22 +287,22 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta
public List<String> getSourceCidrList() {
return null;
}
-
+
@Override
public Long getRelated() {
return null;
}
- @Override
- public FirewallRuleType getType() {
- return FirewallRuleType.User;
- }
-
- @Override
+ @Override
+ public FirewallRuleType getType() {
+ return FirewallRuleType.User;
+ }
+
+ @Override
public AsyncJob.Type getInstanceType() {
return AsyncJob.Type.FirewallRule;
}
-
+
@Override
public TrafficType getTrafficType() {
return null;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5e0501d1/api/src/com/cloud/api/commands/CreateLBStickinessPolicyCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CreateLBStickinessPolicyCmd.java b/api/src/com/cloud/api/commands/CreateLBStickinessPolicyCmd.java
index c98dc66..2ea726e 100644
--- a/api/src/com/cloud/api/commands/CreateLBStickinessPolicyCmd.java
+++ b/api/src/com/cloud/api/commands/CreateLBStickinessPolicyCmd.java
@@ -50,7 +50,7 @@ public class CreateLBStickinessPolicyCmd extends BaseAsyncCreateCmd {
// ///////////////////////////////////////////////////
// ////////////// API parameters /////////////////////
// ///////////////////////////////////////////////////
-
+
@IdentityMapper(entityTableName="firewall_rules")
@Parameter(name = ApiConstants.LBID, type = CommandType.LONG, required = true, description = "the ID of the load balancer rule")
private Long lbRuleId;
@@ -117,7 +117,7 @@ public class CreateLBStickinessPolicyCmd extends BaseAsyncCreateCmd {
public void execute() throws ResourceAllocationException, ResourceUnavailableException {
StickinessPolicy policy = null;
boolean success = false;
-
+
try {
UserContext.current().setEventDetails("Rule Id: " + getEntityId());
success = _lbService.applyLBStickinessPolicy(this);
@@ -131,9 +131,9 @@ public class CreateLBStickinessPolicyCmd extends BaseAsyncCreateCmd {
}
} finally {
if (!success || (policy == null)) {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create stickiness policy ");
+ throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create stickiness policy ");
}
- }
+ }
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5e0501d1/api/src/com/cloud/api/commands/CreateLoadBalancerRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CreateLoadBalancerRuleCmd.java b/api/src/com/cloud/api/commands/CreateLoadBalancerRuleCmd.java
index 0088ca6..0402709 100644
--- a/api/src/com/cloud/api/commands/CreateLoadBalancerRuleCmd.java
+++ b/api/src/com/cloud/api/commands/CreateLoadBalancerRuleCmd.java
@@ -69,7 +69,7 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements
@IdentityMapper(entityTableName="user_ip_address")
@Parameter(name=ApiConstants.PUBLIC_IP_ID, type=CommandType.LONG, description="public ip address id from where the network traffic will be load balanced from")
private Long publicIpId;
-
+
@IdentityMapper(entityTableName="data_center")
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=false, description="zone where the load balancer is going to be created. This parameter is required when LB service provider is ElasticLoadBalancerVm")
private Long zoneId;
@@ -78,7 +78,7 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements
private Integer publicPort;
@Parameter(name = ApiConstants.OPEN_FIREWALL, type = CommandType.BOOLEAN, description = "if true, firewall rule for" +
- " source/end pubic port is automatically created; if false - firewall rule has to be created explicitely. If not specified 1) defaulted to false when LB" +
+ " source/end pubic port is automatically created; if false - firewall rule has to be created explicitely. If not specified 1) defaulted to false when LB" +
" rule is being created for VPC guest network 2) in all other cases defaulted to true")
private Boolean openFirewall;
@@ -88,15 +88,15 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements
@IdentityMapper(entityTableName="domain")
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the domain ID associated with the load balancer")
private Long domainId;
-
+
@Parameter(name = ApiConstants.CIDR_LIST, type = CommandType.LIST, collectionType = CommandType.STRING, description = "the cidr list to forward traffic from")
private List<String> cidrlist;
-
+
@IdentityMapper(entityTableName="networks")
@Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.LONG, description="The guest network this " +
- "rule will be created for. Required when public Ip address is not associated with any Guest network yet (VPC case)")
+ "rule will be created for. Required when public Ip address is not associated with any Guest network yet (VPC case)")
private Long networkId;
-
+
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@@ -118,23 +118,23 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements
}
public String getEntityTable() {
- return "firewall_rules";
+ return "firewall_rules";
}
-
+
public Long getSourceIpAddressId() {
- if (publicIpId != null) {
- IpAddress ipAddr = _networkService.getIp(publicIpId);
- if (ipAddr == null || !ipAddr.readyToUse()) {
- throw new InvalidParameterValueException("Unable to create load balancer rule, invalid IP address id " + ipAddr.getId());
- }
- } else if (getEntityId() != null) {
- LoadBalancer rule = _entityMgr.findById(LoadBalancer.class, getEntityId());
- return rule.getSourceIpAddressId();
- }
-
- return publicIpId;
+ if (publicIpId != null) {
+ IpAddress ipAddr = _networkService.getIp(publicIpId);
+ if (ipAddr == null || !ipAddr.readyToUse()) {
+ throw new InvalidParameterValueException("Unable to create load balancer rule, invalid IP address id " + ipAddr.getId());
+ }
+ } else if (getEntityId() != null) {
+ LoadBalancer rule = _entityMgr.findById(LoadBalancer.class, getEntityId());
+ return rule.getSourceIpAddressId();
+ }
+
+ return publicIpId;
}
-
+
private Long getVpcId() {
if (publicIpId != null) {
IpAddress ipAddr = _networkService.getIp(publicIpId);
@@ -146,36 +146,36 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements
}
return null;
}
-
-
+
+
public Long getNetworkId() {
if (networkId != null) {
return networkId;
- }
+ }
Long zoneId = getZoneId();
-
+
if (zoneId == null) {
- Long ipId = getSourceIpAddressId();
- if (ipId == null) {
- throw new InvalidParameterValueException("Either networkId or zoneId or publicIpId has to be specified");
- }
+ Long ipId = getSourceIpAddressId();
+ if (ipId == null) {
+ throw new InvalidParameterValueException("Either networkId or zoneId or publicIpId has to be specified");
+ }
}
-
+
if (zoneId != null) {
- DataCenter zone = _configService.getZone(zoneId);
- if (zone.getNetworkType() == NetworkType.Advanced) {
+ DataCenter zone = _configService.getZone(zoneId);
+ if (zone.getNetworkType() == NetworkType.Advanced) {
List<? extends Network> networks = _networkService.getIsolatedNetworksOwnedByAccountInZone(getZoneId(), _accountService.getAccount(getEntityOwnerId()));
if (networks.size() == 0) {
String domain = _domainService.getDomain(getDomainId()).getName();
throw new InvalidParameterValueException("Account name=" + getAccountName() + " domain=" + domain + " doesn't have virtual networks in zone=" + zone.getName());
}
-
+
if (networks.size() < 1) {
- throw new InvalidParameterValueException("Account doesn't have any Isolated networks in the zone");
+ throw new InvalidParameterValueException("Account doesn't have any Isolated networks in the zone");
} else if (networks.size() > 1) {
- throw new InvalidParameterValueException("Account has more than one Isolated network in the zone");
+ throw new InvalidParameterValueException("Account has more than one Isolated network in the zone");
}
-
+
return networks.get(0).getId();
} else {
Network defaultGuestNetwork = _networkService.getExclusiveGuestNetwork(zoneId);
@@ -186,23 +186,23 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements
}
}
} else {
- IpAddress ipAddr = _networkService.getIp(publicIpId);
- if (ipAddr.getAssociatedWithNetworkId() != null) {
+ IpAddress ipAddr = _networkService.getIp(publicIpId);
+ if (ipAddr.getAssociatedWithNetworkId() != null) {
return ipAddr.getAssociatedWithNetworkId();
- } else {
- throw new InvalidParameterValueException("Ip address id=" + publicIpId + " is not associated with any network");
- }
+ } else {
+ throw new InvalidParameterValueException("Ip address id=" + publicIpId + " is not associated with any network");
+ }
}
}
public Integer getPublicPort() {
return publicPort;
}
-
+
public String getName() {
return loadBalancerRuleName;
}
-
+
public Boolean getOpenFirewall() {
boolean isVpc = getVpcId() == null ? false : true;
if (openFirewall != null) {
@@ -217,7 +217,7 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements
return true;
}
}
-
+
public List<String> getSourceCidrList() {
if (cidrlist != null) {
throw new InvalidParameterValueException("Parameter cidrList is deprecated; if you need to open firewall rule for the specific cidr, please refer to createFirewallRule command");
@@ -233,33 +233,33 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements
public String getCommandName() {
return s_name;
}
-
+
@Override
- public void execute() throws ResourceAllocationException, ResourceUnavailableException {
-
+ public void execute() throws ResourceAllocationException, ResourceUnavailableException {
+
UserContext callerContext = UserContext.current();
boolean success = true;
LoadBalancer rule = null;
try {
UserContext.current().setEventDetails("Rule Id: " + getEntityId());
-
+
if (getOpenFirewall()) {
success = success && _firewallService.applyFirewallRules(getSourceIpAddressId(), callerContext.getCaller());
}
// State might be different after the rule is applied, so get new object here
rule = _entityMgr.findById(LoadBalancer.class, getEntityId());
- LoadBalancerResponse lbResponse = new LoadBalancerResponse();
+ LoadBalancerResponse lbResponse = new LoadBalancerResponse();
if (rule != null) {
lbResponse = _responseGenerator.createLoadBalancerResponse(rule);
setResponseObject(lbResponse);
}
lbResponse.setResponseName(getCommandName());
} catch (Exception ex) {
- s_logger.warn("Failed to create LB rule due to exception ", ex);
+ s_logger.warn("Failed to create LB rule due to exception ", ex);
}finally {
if (!success || rule == null) {
-
+
if (getOpenFirewall()) {
_firewallService.revokeRelatedFirewallRule(getEntityId(), true);
}
@@ -270,7 +270,7 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements
}
}
}
-
+
@Override
public void create() {
//cidr list parameter is deprecated
@@ -300,11 +300,11 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements
public String getProtocol() {
return NetUtils.TCP_PROTO;
}
-
- public long getAccountId() {
+
+ public long getAccountId() {
if (publicIpId != null)
return _networkService.getIp(getSourceIpAddressId()).getAccountId();
-
+
Account account = null;
if ((domainId != null) && (accountName != null)) {
account = _responseGenerator.findAccountByNameDomain(accountName, domainId);
@@ -334,16 +334,16 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements
public int getDefaultPortEnd() {
return privatePort.intValue();
}
-
+
@Override
public long getEntityOwnerId() {
return getAccountId();
}
-
+
public String getAccountName() {
return accountName;
}
-
+
public Long getZoneId() {
return zoneId;
}
@@ -371,7 +371,7 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements
public void setSourceIpAddressId(Long ipId) {
this.publicIpId = ipId;
}
-
+
@Override
public AsyncJob.Type getInstanceType() {
return AsyncJob.Type.FirewallRule;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5e0501d1/api/src/com/cloud/api/commands/CreateNetworkACLCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CreateNetworkACLCmd.java b/api/src/com/cloud/api/commands/CreateNetworkACLCmd.java
index da1229c..09e2922 100644
--- a/api/src/com/cloud/api/commands/CreateNetworkACLCmd.java
+++ b/api/src/com/cloud/api/commands/CreateNetworkACLCmd.java
@@ -42,7 +42,7 @@ import com.cloud.user.Account;
import com.cloud.user.UserContext;
import com.cloud.utils.net.NetUtils;
-@Implementation(description = "Creates a ACL rule the given network (the network has to belong to VPC)",
+@Implementation(description = "Creates a ACL rule the given network (the network has to belong to VPC)",
responseObject = NetworkACLResponse.class)
public class CreateNetworkACLCmd extends BaseAsyncCreateCmd implements FirewallRule {
public static final Logger s_logger = Logger.getLogger(CreateNetworkACLCmd.class.getName());
@@ -53,7 +53,7 @@ public class CreateNetworkACLCmd extends BaseAsyncCreateCmd implements FirewallR
// ////////////// API parameters /////////////////////
// ///////////////////////////////////////////////////
- @Parameter(name = ApiConstants.PROTOCOL, type = CommandType.STRING, required = true, description =
+ @Parameter(name = ApiConstants.PROTOCOL, type = CommandType.STRING, required = true, description =
"the protocol for the ACL rule. Valid values are TCP/UDP/ICMP.")
private String protocol;
@@ -62,30 +62,30 @@ public class CreateNetworkACLCmd extends BaseAsyncCreateCmd implements FirewallR
@Parameter(name = ApiConstants.END_PORT, type = CommandType.INTEGER, description = "the ending port of ACL")
private Integer publicEndPort;
-
- @Parameter(name = ApiConstants.CIDR_LIST, type = CommandType.LIST, collectionType = CommandType.STRING,
+
+ @Parameter(name = ApiConstants.CIDR_LIST, type = CommandType.LIST, collectionType = CommandType.STRING,
description = "the cidr list to allow traffic from/to")
private List<String> cidrlist;
-
+
@Parameter(name = ApiConstants.ICMP_TYPE, type = CommandType.INTEGER, description = "type of the icmp message being sent")
private Integer icmpType;
@Parameter(name = ApiConstants.ICMP_CODE, type = CommandType.INTEGER, description = "error code for this icmp message")
private Integer icmpCode;
-
+
@IdentityMapper(entityTableName="networks")
@Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.LONG, required=true,
description="The network of the vm the ACL will be created for")
private Long networkId;
-
+
@Parameter(name=ApiConstants.TRAFFIC_TYPE, type=CommandType.STRING, description="the traffic type for the ACL," +
- "can be Ingress or Egress, defaulted to Ingress if not specified")
+ "can be Ingress or Egress, defaulted to Ingress if not specified")
private String trafficType;
-
+
// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
-
+
public String getEntityTable() {
return "firewall_rules";
}
@@ -108,21 +108,21 @@ public class CreateNetworkACLCmd extends BaseAsyncCreateCmd implements FirewallR
return oneCidrList;
}
}
-
+
public long getVpcId() {
Network network = _networkService.getNetwork(getNetworkId());
if (network == null) {
throw new InvalidParameterValueException("Invalid networkId is given");
}
-
+
Long vpcId = network.getVpcId();
if (vpcId == null) {
throw new InvalidParameterValueException("Can create network ACL only for the network belonging to the VPC");
}
-
+
return vpcId;
}
-
+
@Override
public FirewallRule.TrafficType getTrafficType() {
if (trafficType == null) {
@@ -144,7 +144,7 @@ public class CreateNetworkACLCmd extends BaseAsyncCreateCmd implements FirewallR
public String getCommandName() {
return s_name;
}
-
+
public void setSourceCidrList(List<String> cidrs){
cidrlist = cidrs;
}
@@ -159,7 +159,7 @@ public class CreateNetworkACLCmd extends BaseAsyncCreateCmd implements FirewallR
success = _networkACLService.applyNetworkACLs(rule.getNetworkId(), callerContext.getCaller());
// State is different after the rule is applied, so get new object here
- NetworkACLResponse aclResponse = new NetworkACLResponse();
+ NetworkACLResponse aclResponse = new NetworkACLResponse();
if (rule != null) {
aclResponse = _responseGenerator.createNetworkACLResponse(rule);
setResponseObject(aclResponse);
@@ -206,7 +206,7 @@ public class CreateNetworkACLCmd extends BaseAsyncCreateCmd implements FirewallR
} else {
return publicEndPort.intValue();
}
-
+
return null;
}
@@ -247,7 +247,7 @@ public class CreateNetworkACLCmd extends BaseAsyncCreateCmd implements FirewallR
if (getSourceCidrList() != null) {
for (String cidr: getSourceCidrList()){
if (!NetUtils.isValidCIDR(cidr)){
- throw new ServerApiException(BaseCmd.PARAM_ERROR, "Source cidrs formatting error " + cidr);
+ throw new ServerApiException(BaseCmd.PARAM_ERROR, "Source cidrs formatting error " + cidr);
}
}
}
@@ -288,7 +288,7 @@ public class CreateNetworkACLCmd extends BaseAsyncCreateCmd implements FirewallR
public Long getSyncObjId() {
return getNetworkId();
}
-
+
@Override
public Integer getIcmpCode() {
if (icmpCode != null) {
@@ -298,14 +298,14 @@ public class CreateNetworkACLCmd extends BaseAsyncCreateCmd implements FirewallR
}
return null;
}
-
+
@Override
public Integer getIcmpType() {
if (icmpType != null) {
return icmpType;
} else if (protocol.equalsIgnoreCase(NetUtils.ICMP_PROTO)) {
return -1;
-
+
}
return null;
}
@@ -319,7 +319,7 @@ public class CreateNetworkACLCmd extends BaseAsyncCreateCmd implements FirewallR
public FirewallRuleType getType() {
return FirewallRuleType.User;
}
-
+
@Override
public AsyncJob.Type getInstanceType() {
return AsyncJob.Type.FirewallRule;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5e0501d1/api/src/com/cloud/api/commands/CreateNetworkCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CreateNetworkCmd.java b/api/src/com/cloud/api/commands/CreateNetworkCmd.java
index 3a3c029..53b19bb 100644
--- a/api/src/com/cloud/api/commands/CreateNetworkCmd.java
+++ b/api/src/com/cloud/api/commands/CreateNetworkCmd.java
@@ -43,54 +43,54 @@ public class CreateNetworkCmd extends BaseCmd {
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
-
+
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name of the network")
private String name;
-
+
@Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, required=true, description="the display text of the network")
private String displayText;
-
+
@IdentityMapper(entityTableName="network_offerings")
@Parameter(name=ApiConstants.NETWORK_OFFERING_ID, type=CommandType.LONG, required=true, description="the network offering id")
private Long networkOfferingId;
-
+
@IdentityMapper(entityTableName="data_center")
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=true, description="the Zone ID for the network")
private Long zoneId;
-
+
@IdentityMapper(entityTableName="physical_network")
@Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.LONG, description="the Physical Network ID the network belongs to")
private Long physicalNetworkId;
@Parameter(name=ApiConstants.GATEWAY, type=CommandType.STRING, description="the gateway of the network. Required " +
- "for Shared networks and Isolated networks when it belongs to VPC")
+ "for Shared networks and Isolated networks when it belongs to VPC")
private String gateway;
-
+
@Parameter(name=ApiConstants.NETMASK, type=CommandType.STRING, description="the netmask of the network. Required " +
"for Shared networks and Isolated networks when it belongs to VPC")
private String netmask;
-
+
@Parameter(name=ApiConstants.START_IP, type=CommandType.STRING, description="the beginning IP address in the network IP range")
private String startIp;
-
+
@Parameter(name=ApiConstants.END_IP, type=CommandType.STRING, description="the ending IP address in the network IP" +
- " range. If not specified, will be defaulted to startIP")
+ " range. If not specified, will be defaulted to startIP")
private String endIp;
@Parameter(name=ApiConstants.VLAN, type=CommandType.STRING, description="the ID or VID of the network")
private String vlan;
-
+
@Parameter(name=ApiConstants.NETWORK_DOMAIN, type=CommandType.STRING, description="network domain")
private String networkDomain;
-
+
@Parameter(name=ApiConstants.ACL_TYPE, type=CommandType.STRING, description="Access control type; supported values" +
- " are account and domain. In 3.0 all shared networks should have aclType=Domain, and all Isolated networks" +
- " - Account. Account means that only the account owner can use the network, domain - all accouns in the domain can use the network")
+ " are account and domain. In 3.0 all shared networks should have aclType=Domain, and all Isolated networks" +
+ " - Account. Account means that only the account owner can use the network, domain - all accouns in the domain can use the network")
private String aclType;
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="account who will own the network")
private String accountName;
-
+
@IdentityMapper(entityTableName="projects")
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="an optional project for the ssh key")
private Long projectId;
@@ -98,11 +98,11 @@ public class CreateNetworkCmd extends BaseCmd {
@IdentityMapper(entityTableName="domain")
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="domain ID of the account owning a network")
private Long domainId;
-
+
@Parameter(name=ApiConstants.SUBDOMAIN_ACCESS, type=CommandType.BOOLEAN, description="Defines whether to allow" +
- " subdomains to use networks dedicated to their parent domain(s). Should be used with aclType=Domain, defaulted to allow.subdomain.network.access global config if not specified")
+ " subdomains to use networks dedicated to their parent domain(s). Should be used with aclType=Domain, defaulted to allow.subdomain.network.access global config if not specified")
private Boolean subdomainAccess;
-
+
@IdentityMapper(entityTableName="vpc")
@Parameter(name=ApiConstants.VPC_ID, type=CommandType.LONG, description="the VPC network belongs to")
private Long vpcId;
@@ -130,7 +130,7 @@ public class CreateNetworkCmd extends BaseCmd {
public Long getDomainId() {
return domainId;
}
-
+
public String getNetmask() {
return netmask;
}
@@ -142,11 +142,11 @@ public class CreateNetworkCmd extends BaseCmd {
public String getEndIp() {
return endIp;
}
-
+
public String getNetworkName() {
return name;
}
-
+
public String getDisplayText() {
return displayText;
}
@@ -154,39 +154,39 @@ public class CreateNetworkCmd extends BaseCmd {
public String getNetworkDomain() {
return networkDomain;
}
-
+
public Long getProjectId() {
return projectId;
}
public String getAclType() {
- return aclType;
- }
+ return aclType;
+ }
- public Boolean getSubdomainAccess() {
- return subdomainAccess;
- }
+ public Boolean getSubdomainAccess() {
+ return subdomainAccess;
+ }
- public Long getVpcId() {
+ public Long getVpcId() {
return vpcId;
}
public Long getZoneId() {
Long physicalNetworkId = getPhysicalNetworkId();
-
+
if (physicalNetworkId == null && zoneId == null) {
throw new InvalidParameterValueException("Zone id is required");
}
-
+
return zoneId;
}
-
+
public Long getPhysicalNetworkId() {
NetworkOffering offering = _configService.getNetworkOffering(networkOfferingId);
if (offering == null) {
throw new InvalidParameterValueException("Unable to find network offering by id " + networkOfferingId);
}
-
+
if (physicalNetworkId != null) {
if (offering.getGuestType() == GuestType.Shared) {
return physicalNetworkId;
@@ -208,19 +208,19 @@ public class CreateNetworkCmd extends BaseCmd {
public String getCommandName() {
return s_name;
}
-
+
@Override
public long getEntityOwnerId() {
Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
if (accountId == null) {
return UserContext.current().getCaller().getId();
}
-
+
return accountId;
}
-
+
@Override
- // an exception thrown by createNetwork() will be caught by the dispatcher.
+ // an exception thrown by createNetwork() will be caught by the dispatcher.
public void execute() throws InsufficientCapacityException, ConcurrentOperationException, ResourceAllocationException{
Network result = _networkService.createGuestNetwork(this);
if (result != null) {
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5e0501d1/api/src/com/cloud/api/commands/CreateNetworkOfferingCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CreateNetworkOfferingCmd.java b/api/src/com/cloud/api/commands/CreateNetworkOfferingCmd.java
index f62cf8f..447a5fb 100644
--- a/api/src/com/cloud/api/commands/CreateNetworkOfferingCmd.java
+++ b/api/src/com/cloud/api/commands/CreateNetworkOfferingCmd.java
@@ -50,55 +50,55 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name of the network offering")
private String networkOfferingName;
-
+
@Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, required=true, description="the display text of the network offering")
private String displayText;
-
+
@Parameter(name=ApiConstants.TRAFFIC_TYPE, type=CommandType.STRING, required=true, description="the traffic type for the network offering. Supported type in current release is GUEST only")
private String traffictype;
-
+
@Parameter(name=ApiConstants.TAGS, type=CommandType.STRING, description="the tags for the network offering.", length=4096)
- private String tags;
-
+ private String tags;
+
@Parameter(name=ApiConstants.SPECIFY_VLAN, type=CommandType.BOOLEAN, description="true if network offering supports vlans")
- private Boolean specifyVlan;
-
+ private Boolean specifyVlan;
+
@Parameter(name=ApiConstants.AVAILABILITY, type=CommandType.STRING, description="the availability of network offering. Default value is Optional")
- private String availability;
-
+ private String availability;
+
@Parameter(name=ApiConstants.NETWORKRATE, type=CommandType.INTEGER, description="data transfer rate in megabits per second allowed")
private Integer networkRate;
-
+
@Parameter(name=ApiConstants.CONSERVE_MODE, type=CommandType.BOOLEAN, description="true if the network offering is IP conserve mode enabled")
private Boolean conserveMode;
-
+
@IdentityMapper(entityTableName="disk_offering")
@Parameter(name=ApiConstants.SERVICE_OFFERING_ID, type=CommandType.LONG, description="the service offering ID used by virtual router provider")
private Long serviceOfferingId;
-
+
@Parameter(name=ApiConstants.GUEST_IP_TYPE, type=CommandType.STRING, required=true, description="guest type of the network offering: Shared or Isolated")
private String guestIptype;
-
+
@Parameter(name=ApiConstants.SUPPORTED_SERVICES, type=CommandType.LIST, required=true, collectionType=CommandType.STRING, description="services supported by the network offering")
private List<String> supportedServices;
-
+
@Parameter(name = ApiConstants.SERVICE_PROVIDER_LIST, type = CommandType.MAP, description = "provider to service mapping. If not specified, the provider for the service will be mapped to the default provider on the physical network")
private Map serviceProviderList;
@Parameter(name = ApiConstants.SERVICE_CAPABILITY_LIST, type = CommandType.MAP, description = "desired service capabilities as part of network offering")
private Map serviceCapabilitystList;
-
+
@Parameter(name=ApiConstants.SPECIFY_IP_RANGES, type=CommandType.BOOLEAN, description="true if network offering supports specifying ip ranges; defaulted to false if not specified")
private Boolean specifyIpRanges;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
-
+
public String getNetworkOfferingName() {
return networkOfferingName;
}
-
+
public String getDisplayText() {
return displayText;
}
@@ -110,7 +110,7 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
public String getTraffictype() {
return traffictype;
}
-
+
public Boolean getSpecifyVlan() {
return specifyVlan == null ? false : specifyVlan;
}
@@ -118,7 +118,7 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
public String getAvailability() {
return availability == null ? Availability.Optional.toString() : availability;
}
-
+
public Integer getNetworkRate() {
return networkRate;
}
@@ -130,18 +130,18 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
public Long getServiceOfferingId() {
return serviceOfferingId;
}
-
+
public List<String> getSupportedServices() {
- return supportedServices;
- }
+ return supportedServices;
+ }
- public String getGuestIpType() {
+ public String getGuestIpType() {
return guestIptype;
}
-
- public Boolean getSpecifyIpRanges() {
- return specifyIpRanges == null ? false : specifyIpRanges;
- }
+
+ public Boolean getSpecifyIpRanges() {
+ return specifyIpRanges == null ? false : specifyIpRanges;
+ }
public Boolean getConserveMode() {
if (conserveMode == null) {
@@ -170,7 +170,7 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
serviceProviderMap.put(service, providerList);
}
}
-
+
return serviceProviderMap;
}
@@ -199,7 +199,7 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
if (svc.equalsIgnoreCase(service.getName())) {
capabilityMap.put(capability, capabilityValue);
} else {
- //throw new InvalidParameterValueException("Service is not equal ")
+ //throw new InvalidParameterValueException("Service is not equal ")
}
}
}
@@ -214,7 +214,7 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
public String getCommandName() {
return _name;
}
-
+
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5e0501d1/api/src/com/cloud/api/commands/CreatePhysicalNetworkCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CreatePhysicalNetworkCmd.java b/api/src/com/cloud/api/commands/CreatePhysicalNetworkCmd.java
index bf6f738..39829b2 100644
--- a/api/src/com/cloud/api/commands/CreatePhysicalNetworkCmd.java
+++ b/api/src/com/cloud/api/commands/CreatePhysicalNetworkCmd.java
@@ -44,7 +44,7 @@ public class CreatePhysicalNetworkCmd extends BaseAsyncCreateCmd {
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
-
+
@IdentityMapper(entityTableName="data_center")
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=true, description="the Zone ID for the physical network")
private Long zoneId;
@@ -58,22 +58,22 @@ public class CreatePhysicalNetworkCmd extends BaseAsyncCreateCmd {
@IdentityMapper(entityTableName="domain")
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="domain ID of the account owning a physical network")
private Long domainId;
-
+
@Parameter(name=ApiConstants.BROADCAST_DOMAIN_RANGE, type=CommandType.STRING, description="the broadcast domain range for the physical network[Pod or Zone]. In Acton release it can be Zone only in Advance zone, and Pod in Basic")
private String broadcastDomainRange;
-
+
@Parameter(name=ApiConstants.TAGS, type=CommandType.LIST, collectionType=CommandType.STRING, description="Tag the physical network")
private List<String> tags;
-
+
@Parameter(name=ApiConstants.ISOLATION_METHODS, type=CommandType.LIST, collectionType=CommandType.STRING, description="the isolation method for the physical network[VLAN/L3/GRE]")
private List<String> isolationMethods;
-
+
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name of the physical network")
private String networkName;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
-
+
public List<String> getTags() {
return tags;
}
@@ -102,25 +102,25 @@ public class CreatePhysicalNetworkCmd extends BaseAsyncCreateCmd {
public List<String> getIsolationMethods() {
return isolationMethods;
}
-
+
public String getNetworkSpeed() {
return speed;
}
-
+
public String getNetworkName() {
- return networkName;
- }
-
- @Override
+ return networkName;
+ }
+
+ @Override
public String getCommandName() {
return s_name;
}
-
+
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
-
+
@Override
public String getEventType() {
return EventTypes.EVENT_PHYSICAL_NETWORK_CREATE;
@@ -140,7 +140,7 @@ public class CreatePhysicalNetworkCmd extends BaseAsyncCreateCmd {
public String getEventDescription() {
return "creating Physical Network. Id: "+getEntityId();
}
-
+
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@@ -167,7 +167,7 @@ public class CreatePhysicalNetworkCmd extends BaseAsyncCreateCmd {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create physical network entity");
}
}
-
+
@Override
public AsyncJob.Type getInstanceType() {
return AsyncJob.Type.PhysicalNetwork;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5e0501d1/api/src/com/cloud/api/commands/CreatePodCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CreatePodCmd.java b/api/src/com/cloud/api/commands/CreatePodCmd.java
index 55dcfae..5c36b9f 100755
--- a/api/src/com/cloud/api/commands/CreatePodCmd.java
+++ b/api/src/com/cloud/api/commands/CreatePodCmd.java
@@ -39,23 +39,23 @@ public class CreatePodCmd extends BaseCmd {
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name of the Pod")
private String podName;
-
+
@IdentityMapper(entityTableName="data_center")
- @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=true, description="the Zone ID in which the Pod will be created ")
+ @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=true, description="the Zone ID in which the Pod will be created ")
private Long zoneId;
@Parameter(name=ApiConstants.START_IP, type=CommandType.STRING, required=true, description="the starting IP address for the Pod")
private String startIp;
-
+
@Parameter(name=ApiConstants.END_IP, type=CommandType.STRING, description="the ending IP address for the Pod")
private String endIp;
-
+
@Parameter(name=ApiConstants.NETMASK, type=CommandType.STRING, required=true, description="the netmask for the Pod")
private String netmask;
@Parameter(name=ApiConstants.GATEWAY, type=CommandType.STRING, required=true, description="the gateway for the Pod")
private String gateway;
-
+
@Parameter(name=ApiConstants.ALLOCATION_STATE, type=CommandType.STRING, description="Allocation state of this Pod for allocation of new resources")
private String allocationState;
@@ -88,9 +88,9 @@ public class CreatePodCmd extends BaseCmd {
}
public String getAllocationState() {
- return allocationState;
+ return allocationState;
}
-
+
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@@ -99,7 +99,7 @@ public class CreatePodCmd extends BaseCmd {
public String getCommandName() {
return s_name;
}
-
+
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5e0501d1/api/src/com/cloud/api/commands/CreatePortForwardingRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CreatePortForwardingRuleCmd.java b/api/src/com/cloud/api/commands/CreatePortForwardingRuleCmd.java
index 472ccfe..3579da2 100644
--- a/api/src/com/cloud/api/commands/CreatePortForwardingRuleCmd.java
+++ b/api/src/com/cloud/api/commands/CreatePortForwardingRuleCmd.java
@@ -51,30 +51,30 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
// ///////////////////////////////////////////////////
@IdentityMapper(entityTableName = "user_ip_address")
- @Parameter(name = ApiConstants.IP_ADDRESS_ID, type = CommandType.LONG, required = true,
+ @Parameter(name = ApiConstants.IP_ADDRESS_ID, type = CommandType.LONG, required = true,
description = "the IP address id of the port forwarding rule")
private Long ipAddressId;
- @Parameter(name = ApiConstants.PRIVATE_START_PORT, type = CommandType.INTEGER, required = true,
+ @Parameter(name = ApiConstants.PRIVATE_START_PORT, type = CommandType.INTEGER, required = true,
description = "the starting port of port forwarding rule's private port range")
private Integer privateStartPort;
- @Parameter(name = ApiConstants.PROTOCOL, type = CommandType.STRING, required = true,
+ @Parameter(name = ApiConstants.PROTOCOL, type = CommandType.STRING, required = true,
description = "the protocol for the port fowarding rule. Valid values are TCP or UDP.")
private String protocol;
@Parameter(name = ApiConstants.PRIVATE_END_PORT, type = CommandType.INTEGER, required = false, description = "the ending port of port forwarding rule's private port range")
private Integer privateEndPort;
- @Parameter(name = ApiConstants.PUBLIC_START_PORT, type = CommandType.INTEGER, required = true,
+ @Parameter(name = ApiConstants.PUBLIC_START_PORT, type = CommandType.INTEGER, required = true,
description = "the starting port of port forwarding rule's public port range")
private Integer publicStartPort;
-
+
@Parameter(name = ApiConstants.PUBLIC_END_PORT, type = CommandType.INTEGER, required = false, description = "the ending port of port forwarding rule's private port range")
private Integer publicEndPort;
@IdentityMapper(entityTableName = "vm_instance")
- @Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, type = CommandType.LONG, required = true,
+ @Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, type = CommandType.LONG, required = true,
description = "the ID of the virtual machine for the port forwarding rule")
private Long virtualMachineId;
@@ -82,16 +82,16 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
description = "the cidr list to forward traffic from")
private List<String> cidrlist;
- @Parameter(name = ApiConstants.OPEN_FIREWALL, type = CommandType.BOOLEAN,
+ @Parameter(name = ApiConstants.OPEN_FIREWALL, type = CommandType.BOOLEAN,
description = "if true, firewall rule for source/end pubic port is automatically created; " +
- "if false - firewall rule has to be created explicitely. If not specified 1) defaulted to false when PF" +
- " rule is being created for VPC guest network 2) in all other cases defaulted to true")
+ "if false - firewall rule has to be created explicitely. If not specified 1) defaulted to false when PF" +
+ " rule is being created for VPC guest network 2) in all other cases defaulted to true")
private Boolean openFirewall;
-
+
@IdentityMapper(entityTableName="networks")
- @Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.LONG,
+ @Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.LONG,
description="The network of the vm the Port Forwarding rule will be created for. " +
- "Required when public Ip address is not associated with any Guest network yet (VPC case)")
+ "Required when public Ip address is not associated with any Guest network yet (VPC case)")
private Long networkId;
// ///////////////////////////////////////////////////
@@ -99,7 +99,7 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
// ///////////////////////////////////////////////////
public String getEntityTable() {
- return "firewall_rules";
+ return "firewall_rules";
}
public Long getIpAddressId() {
@@ -119,11 +119,11 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
public List<String> getSourceCidrList() {
if (cidrlist != null) {
throw new InvalidParameterValueException("Parameter cidrList is deprecated; if you need to open firewall " +
- "rule for the specific cidr, please refer to createFirewallRule command");
+ "rule for the specific cidr, please refer to createFirewallRule command");
}
return null;
}
-
+
public Boolean getOpenFirewall() {
boolean isVpc = getVpcId() == null ? false : true;
if (openFirewall != null) {
@@ -138,7 +138,7 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
return true;
}
}
-
+
private Long getVpcId() {
if (ipAddressId != null) {
IpAddress ipAddr = _networkService.getIp(ipAddressId);
@@ -168,16 +168,16 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
PortForwardingRule rule = null;
try {
UserContext.current().setEventDetails("Rule Id: " + getEntityId());
-
+
if (getOpenFirewall()) {
success = success && _firewallService.applyFirewallRules(ipAddressId, callerContext.getCaller());
}
-
+
success = success && _rulesService.applyPortForwardingRules(ipAddressId, callerContext.getCaller());
// State is different after the rule is applied, so get new object here
rule = _entityMgr.findById(PortForwardingRule.class, getEntityId());
- FirewallRuleResponse fwResponse = new FirewallRuleResponse();
+ FirewallRuleResponse fwResponse = new FirewallRuleResponse();
if (rule != null) {
fwResponse = _responseGenerator.createPortForwardingRuleResponse(rule);
setResponseObject(fwResponse);
@@ -185,13 +185,13 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
fwResponse.setResponseName(getCommandName());
} finally {
if (!success || rule == null) {
-
+
if (getOpenFirewall()) {
_firewallService.revokeRelatedFirewallRule(getEntityId(), true);
}
-
+
_rulesService.revokePortForwardingRule(getEntityId(), true);
-
+
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to apply port forwarding rule");
}
}
@@ -220,7 +220,7 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
@Override
public Integer getSourcePortEnd() {
- return (publicEndPort == null)? publicStartPort.intValue() : publicEndPort.intValue();
+ return (publicEndPort == null)? publicStartPort.intValue() : publicEndPort.intValue();
}
@Override
@@ -237,14 +237,14 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
public long getNetworkId() {
IpAddress ip = _entityMgr.findById(IpAddress.class, getIpAddressId());
Long ntwkId = null;
-
+
if (ip.getAssociatedWithNetworkId() != null) {
ntwkId = ip.getAssociatedWithNetworkId();
} else {
ntwkId = networkId;
}
if (ntwkId == null) {
- throw new InvalidParameterValueException("Unable to create port forwarding rule for the ipAddress id=" + ipAddressId +
+ throw new InvalidParameterValueException("Unable to create port forwarding rule for the ipAddress id=" + ipAddressId +
" as ip is not associated with any network and no networkId is passed in");
}
return ntwkId;
@@ -272,10 +272,10 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
public Ip getDestinationIpAddress() {
return null;
}
-
+
@Override
public void setDestinationIpAddress(Ip destinationIpAddress) {
- return;
+ return;
}
@Override
@@ -294,7 +294,7 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
if (cidrlist != null) {
throw new InvalidParameterValueException("Parameter cidrList is deprecated; if you need to open firewall rule for the specific cidr, please refer to createFirewallRule command");
}
-
+
try {
PortForwardingRule result = _rulesService.createPortForwardingRule(this, virtualMachineId, getOpenFirewall());
setEntityId(result.getId());
@@ -339,26 +339,26 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
}
return ip;
}
-
+
@Override
public Integer getIcmpCode() {
return null;
}
-
+
@Override
public Integer getIcmpType() {
return null;
}
-
+
@Override
public Long getRelated() {
return null;
}
- @Override
- public FirewallRuleType getType() {
- return FirewallRuleType.User;
- }
+ @Override
+ public FirewallRuleType getType() {
+ return FirewallRuleType.User;
+ }
@Override
public AsyncJob.Type getInstanceType() {