diff --git a/agent/pom.xml b/agent/pom.xml
index 0f44c1aa297..c2b1502728f 100644
--- a/agent/pom.xml
+++ b/agent/pom.xml
@@ -36,6 +36,11 @@
cloud-utils
${project.version}
+
+ commons-daemon
+ commons-daemon
+ ${cs.daemon.version}
+
install
diff --git a/agent/src/com/cloud/agent/AgentShell.java b/agent/src/com/cloud/agent/AgentShell.java
index 73b3950e7e4..cf454b8c89c 100644
--- a/agent/src/com/cloud/agent/AgentShell.java
+++ b/agent/src/com/cloud/agent/AgentShell.java
@@ -24,7 +24,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.net.HttpURLConnection;
import java.util.ArrayList;
import java.util.Collections;
@@ -38,6 +37,9 @@ import java.util.UUID;
import javax.naming.ConfigurationException;
+import org.apache.commons.daemon.Daemon;
+import org.apache.commons.daemon.DaemonContext;
+import org.apache.commons.daemon.DaemonInitException;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.methods.GetMethod;
@@ -47,7 +49,6 @@ import org.apache.log4j.xml.DOMConfigurator;
import com.cloud.agent.Agent.ExitStatus;
import com.cloud.agent.dao.StorageComponent;
import com.cloud.agent.dao.impl.PropertiesStorage;
-import com.cloud.host.Host;
import com.cloud.resource.ServerResource;
import com.cloud.utils.LogUtils;
import com.cloud.utils.NumbersUtil;
@@ -58,7 +59,7 @@ import com.cloud.utils.backoff.impl.ConstantTimeBackoff;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.script.Script;
-public class AgentShell implements IAgentShell {
+public class AgentShell implements IAgentShell, Daemon {
private static final Logger s_logger = Logger.getLogger(AgentShell.class
.getName());
private static final MultiThreadedHttpConnectionManager s_httpClientManager = new MultiThreadedHttpConnectionManager();
@@ -79,7 +80,6 @@ public class AgentShell implements IAgentShell {
private int _nextAgentId = 1;
private volatile boolean _exit = false;
private int _pingRetries;
- private Thread _consoleProxyMain = null;
private final List _agents = new ArrayList();
public AgentShell() {
@@ -376,7 +376,17 @@ public class AgentShell implements IAgentShell {
return true;
}
-
+
+ @Override
+ public void init(DaemonContext dc) throws DaemonInitException {
+ s_logger.debug("Initializing AgentShell from JSVC");
+ try {
+ init(dc.getArguments());
+ } catch (ConfigurationException ex) {
+ throw new DaemonInitException("Initialization failed", ex);
+ }
+ }
+
public void init(String[] args) throws ConfigurationException {
// PropertiesUtil is used both in management server and agent packages,
@@ -402,11 +412,13 @@ public class AgentShell implements IAgentShell {
loadProperties();
parseCommand(args);
- List properties = Collections.list((Enumeration)_properties.propertyNames());
- for (String property:properties){
- s_logger.debug("Found property: " + property);
+ if (s_logger.isDebugEnabled()) {
+ List properties = Collections.list((Enumeration)_properties.propertyNames());
+ for (String property:properties){
+ s_logger.debug("Found property: " + property);
+ }
}
-
+
s_logger.info("Defaulting to using properties file for storage");
_storage = new PropertiesStorage();
_storage.configure("Storage", new HashMap());
@@ -434,71 +446,6 @@ public class AgentShell implements IAgentShell {
launchAgentFromTypeInfo();
}
- private boolean needConsoleProxy() {
- for (Agent agent : _agents) {
- if (agent.getResource().getType().equals(Host.Type.ConsoleProxy)
- || agent.getResource().getType().equals(Host.Type.Routing))
- return true;
- }
- return false;
- }
-
- private int getConsoleProxyPort() {
- int port = NumbersUtil.parseInt(
- getProperty(null, "consoleproxy.httpListenPort"), 443);
- return port;
- }
-
- private void openPortWithIptables(int port) {
- // TODO
- }
-
- private void launchConsoleProxy() throws ConfigurationException {
- if (!needConsoleProxy()) {
- if (s_logger.isInfoEnabled())
- s_logger.info("Storage only agent, no need to start console proxy on it");
- return;
- }
-
- int port = getConsoleProxyPort();
- openPortWithIptables(port);
-
- _consoleProxyMain = new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- Class> consoleProxyClazz = Class.forName("com.cloud.consoleproxy.ConsoleProxy");
-
- try {
- Method method = consoleProxyClazz.getMethod("start",
- Properties.class);
- method.invoke(null, _properties);
- } catch (SecurityException e) {
- s_logger.error("Unable to launch console proxy due to SecurityException");
- System.exit(ExitStatus.Error.value());
- } catch (NoSuchMethodException e) {
- s_logger.error("Unable to launch console proxy due to NoSuchMethodException");
- System.exit(ExitStatus.Error.value());
- } catch (IllegalArgumentException e) {
- s_logger.error("Unable to launch console proxy due to IllegalArgumentException");
- System.exit(ExitStatus.Error.value());
- } catch (IllegalAccessException e) {
- s_logger.error("Unable to launch console proxy due to IllegalAccessException");
- System.exit(ExitStatus.Error.value());
- } catch (InvocationTargetException e) {
- s_logger.error("Unable to launch console proxy due to InvocationTargetException");
- System.exit(ExitStatus.Error.value());
- }
- } catch (final ClassNotFoundException e) {
- s_logger.error("Unable to launch console proxy due to ClassNotFoundException");
- System.exit(ExitStatus.Error.value());
- }
- }
- }, "Console-Proxy-Main");
- _consoleProxyMain.setDaemon(true);
- _consoleProxyMain.start();
- }
-
private void launchAgentFromClassInfo(String resourceClassNames)
throws ConfigurationException {
String[] names = resourceClassNames.split("\\|");
@@ -591,14 +538,6 @@ public class AgentShell implements IAgentShell {
launchAgent();
- //
- // For both KVM & Xen-Server hypervisor, we have switched to
- // VM-based console proxy solution, disable launching
- // of console proxy here
- //
- // launchConsoleProxy();
- //
-
try {
while (!_exit)
Thread.sleep(1000);
@@ -618,9 +557,6 @@ public class AgentShell implements IAgentShell {
public void stop() {
_exit = true;
- if (_consoleProxyMain != null) {
- _consoleProxyMain.interrupt();
- }
}
public void destroy() {
@@ -629,6 +565,7 @@ public class AgentShell implements IAgentShell {
public static void main(String[] args) {
try {
+ s_logger.debug("Initializing AgentShell from main");
AgentShell shell = new AgentShell();
shell.init(args);
shell.start();
@@ -636,4 +573,5 @@ public class AgentShell implements IAgentShell {
System.out.println(e.getMessage());
}
}
+
}
diff --git a/api/src/com/cloud/agent/api/to/DnsmasqTO.java b/api/src/com/cloud/agent/api/to/DnsmasqTO.java
new file mode 100644
index 00000000000..f99878c2fed
--- /dev/null
+++ b/api/src/com/cloud/agent/api/to/DnsmasqTO.java
@@ -0,0 +1,53 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.agent.api.to;
+
+public class DnsmasqTO {
+ String routerIp;
+ String gateway;
+ String netmask;
+
+ public DnsmasqTO(String routerIp, String gateway, String netmask) {
+ this.routerIp = routerIp;
+ this.gateway = gateway;
+ this.netmask =netmask;
+ }
+
+ public void setRouterIp(String routerIp){
+ this.routerIp = routerIp;
+ }
+
+ public void setGateway(String gateway) {
+ this.gateway = gateway;
+ }
+
+ public void setNetmask(String netmask) {
+ this.netmask = netmask ;
+ }
+
+ public String getRouterIp() {
+ return routerIp;
+ }
+
+ public String getGateway() {
+ return gateway;
+ }
+
+ public String getNetmask() {
+ return netmask;
+ }
+}
diff --git a/api/src/com/cloud/agent/api/to/NetworkACLTO.java b/api/src/com/cloud/agent/api/to/NetworkACLTO.java
index 8818e13de4a..398591b120d 100644
--- a/api/src/com/cloud/agent/api/to/NetworkACLTO.java
+++ b/api/src/com/cloud/agent/api/to/NetworkACLTO.java
@@ -20,10 +20,10 @@ package com.cloud.agent.api.to;
import java.util.ArrayList;
import java.util.List;
+import com.cloud.network.vpc.NetworkACLItem;
+import com.cloud.network.vpc.NetworkACLItem.TrafficType;
import org.apache.cloudstack.api.InternalIdentity;
-import com.cloud.network.rules.FirewallRule;
-import com.cloud.network.rules.FirewallRule.TrafficType;
import com.cloud.utils.net.NetUtils;
@@ -37,15 +37,16 @@ public class NetworkACLTO implements InternalIdentity {
private List cidrList;
private Integer icmpType;
private Integer icmpCode;
- private FirewallRule.TrafficType trafficType;
-
+ private TrafficType trafficType;
+ String action;
+ int number;
protected NetworkACLTO() {
}
public NetworkACLTO(long id,String vlanTag, String protocol, Integer portStart, Integer portEnd, boolean revoked,
- boolean alreadyAdded, List cidrList, Integer icmpType,Integer icmpCode,TrafficType trafficType) {
+ boolean alreadyAdded, List cidrList, Integer icmpType,Integer icmpCode,TrafficType trafficType, boolean allow, int number) {
this.vlanTag = vlanTag;
this.protocol = protocol;
@@ -70,12 +71,20 @@ public class NetworkACLTO implements InternalIdentity {
this.icmpType = icmpType;
this.icmpCode = icmpCode;
this.trafficType = trafficType;
+
+ if(!allow){
+ this.action = "DROP";
+ } else {
+ this.action = "ACCEPT";
+ }
+
+ this.number = number;
}
- public NetworkACLTO(FirewallRule rule, String vlanTag, FirewallRule.TrafficType trafficType ) {
+ public NetworkACLTO(NetworkACLItem rule, String vlanTag, NetworkACLItem.TrafficType trafficType ) {
this(rule.getId(), vlanTag, rule.getProtocol(), rule.getSourcePortStart(), rule.getSourcePortEnd(),
- rule.getState() == FirewallRule.State.Revoke, rule.getState() == FirewallRule.State.Active,
- rule.getSourceCidrList() ,rule.getIcmpType(), rule.getIcmpCode(),trafficType);
+ rule.getState() == NetworkACLItem.State.Revoke, rule.getState() == NetworkACLItem.State.Active,
+ rule.getSourceCidrList() ,rule.getIcmpType(), rule.getIcmpCode(),trafficType, rule.getAction() == NetworkACLItem.Action.Allow, rule.getNumber());
}
public long getId() {
@@ -83,7 +92,7 @@ public class NetworkACLTO implements InternalIdentity {
}
public String getSrcVlanTag() {
- return vlanTag;
+ return vlanTag;
}
public String getProtocol() {
@@ -95,18 +104,18 @@ public class NetworkACLTO implements InternalIdentity {
}
public Integer getIcmpType(){
- return icmpType;
+ return icmpType;
}
public Integer getIcmpCode(){
- return icmpCode;
+ return icmpCode;
}
public String getStringPortRange() {
- if (portRange == null || portRange.length < 2)
- return "0:0";
- else
- return NetUtils.portRangeToString(portRange);
+ if (portRange == null || portRange.length < 2)
+ return "0:0";
+ else
+ return NetUtils.portRangeToString(portRange);
}
public boolean revoked() {
@@ -121,7 +130,15 @@ public class NetworkACLTO implements InternalIdentity {
return alreadyAdded;
}
- public FirewallRule.TrafficType getTrafficType() {
+ public TrafficType getTrafficType() {
return trafficType;
}
+
+ public String getAction() {
+ return action;
+ }
+
+ public int getNumber(){
+ return number;
+ }
}
diff --git a/api/src/com/cloud/async/AsyncJob.java b/api/src/com/cloud/async/AsyncJob.java
index d384a7ad920..ccdc40620b7 100644
--- a/api/src/com/cloud/async/AsyncJob.java
+++ b/api/src/com/cloud/async/AsyncJob.java
@@ -50,7 +50,9 @@ public interface AsyncJob extends Identity, InternalIdentity {
AutoScaleVmProfile,
AutoScaleVmGroup,
GlobalLoadBalancerRule,
+ LoadBalancerRule,
AffinityGroup,
+ InternalLbVm,
DedicatedGuestVlanRange
}
diff --git a/api/src/com/cloud/event/EventTypes.java b/api/src/com/cloud/event/EventTypes.java
index 26c40abb4fb..d272c99bc02 100755
--- a/api/src/com/cloud/event/EventTypes.java
+++ b/api/src/com/cloud/event/EventTypes.java
@@ -16,6 +16,9 @@
// under the License.
package com.cloud.event;
+import java.util.HashMap;
+import java.util.Map;
+
import com.cloud.configuration.Configuration;
import com.cloud.dc.DataCenter;
import com.cloud.dc.Pod;
@@ -23,8 +26,18 @@ import com.cloud.dc.StorageNetworkIpRange;
import com.cloud.dc.Vlan;
import com.cloud.domain.Domain;
import com.cloud.host.Host;
-import com.cloud.network.*;
-import com.cloud.network.as.*;
+import com.cloud.network.GuestVlan;
+import com.cloud.network.Network;
+import com.cloud.network.PhysicalNetwork;
+import com.cloud.network.PhysicalNetworkServiceProvider;
+import com.cloud.network.PhysicalNetworkTrafficType;
+import com.cloud.network.PublicIpAddress;
+import com.cloud.network.RemoteAccessVpn;
+import com.cloud.network.as.AutoScaleCounter;
+import com.cloud.network.as.AutoScalePolicy;
+import com.cloud.network.as.AutoScaleVmGroup;
+import com.cloud.network.as.AutoScaleVmProfile;
+import com.cloud.network.as.Condition;
import com.cloud.network.router.VirtualRouter;
import com.cloud.network.rules.LoadBalancer;
import com.cloud.network.rules.StaticNat;
@@ -43,9 +56,6 @@ import com.cloud.user.Account;
import com.cloud.user.User;
import com.cloud.vm.VirtualMachine;
-import java.util.HashMap;
-import java.util.Map;
-
public class EventTypes {
//map of Event and corresponding entity for which Event is applicable
@@ -103,6 +113,10 @@ public class EventTypes {
public static final String EVENT_NIC_CREATE = "NIC.CREATE";
public static final String EVENT_NIC_DELETE = "NIC.DELETE";
public static final String EVENT_NIC_UPDATE = "NIC.UPDATE";
+ public static final String EVENT_NIC_DETAIL_ADD = "NIC.DETAIL.ADD";
+ public static final String EVENT_NIC_DETAIL_UPDATE = "NIC.DETAIL.UPDATE";
+ public static final String EVENT_NIC_DETAIL_REMOVE = "NIC.DETAIL.REMOVE";
+
// Load Balancers
public static final String EVENT_ASSIGN_TO_LOAD_BALANCER_RULE = "LB.ASSIGN.TO.RULE";
@@ -166,6 +180,9 @@ public class EventTypes {
public static final String EVENT_VOLUME_UPLOAD = "VOLUME.UPLOAD";
public static final String EVENT_VOLUME_MIGRATE = "VOLUME.MIGRATE";
public static final String EVENT_VOLUME_RESIZE = "VOLUME.RESIZE";
+ public static final String EVENT_VOLUME_DETAIL_UPDATE = "VOLUME.DETAIL.UPDATE";
+ public static final String EVENT_VOLUME_DETAIL_ADD = "VOLUME.DETAIL.ADD";
+ public static final String EVENT_VOLUME_DETAIL_REMOVE = "VOLUME.DETAIL.REMOVE";
// Domains
public static final String EVENT_DOMAIN_CREATE = "DOMAIN.CREATE";
@@ -334,6 +351,14 @@ public class EventTypes {
public static final String EVENT_VPC_DELETE = "VPC.DELETE";
public static final String EVENT_VPC_RESTART = "VPC.RESTART";
+ // Network ACL
+ public static final String EVENT_NETWORK_ACL_CREATE = "NETWORK.ACL.CREATE";
+ public static final String EVENT_NETWORK_ACL_DELETE = "NETWORK.ACL.DELETE";
+ public static final String EVENT_NETWORK_ACL_REPLACE = "NETWORK.ACL.REPLACE";
+ public static final String EVENT_NETWORK_ACL_ITEM_CREATE = "NETWORK.ACL.ITEM.CREATE";
+ public static final String EVENT_NETWORK_ACL_ITEM_UPDATE = "NETWORK.ACL.ITEM.UPDATE";
+ public static final String EVENT_NETWORK_ACL_ITEM_DELETE = "NETWORK.ACL.ITEM.DELETE";
+
// VPC offerings
public static final String EVENT_VPC_OFFERING_CREATE = "VPC.OFFERING.CREATE";
public static final String EVENT_VPC_OFFERING_UPDATE = "VPC.OFFERING.UPDATE";
@@ -351,6 +376,10 @@ public class EventTypes {
public static final String EVENT_TAGS_CREATE = "CREATE_TAGS";
public static final String EVENT_TAGS_DELETE = "DELETE_TAGS";
+ // meta data related events
+ public static final String EVENT_RESOURCE_DETAILS_CREATE = "CREATE_RESOURCE_DETAILS";
+ public static final String EVENT_RESOURCE_DETAILS_DELETE = "DELETE_RESOURCE_DETAILS";
+
// vm snapshot events
public static final String EVENT_VM_SNAPSHOT_CREATE = "VMSNAPSHOT.CREATE";
public static final String EVENT_VM_SNAPSHOT_DELETE = "VMSNAPSHOT.DELETE";
@@ -389,11 +418,15 @@ public class EventTypes {
public static final String EVENT_AFFINITY_GROUP_ASSIGN = "AG.ASSIGN";
public static final String EVENT_AFFINITY_GROUP_REMOVE = "AG.REMOVE";
public static final String EVENT_VM_AFFINITY_GROUP_UPDATE = "VM.AG.UPDATE";
+
+ public static final String EVENT_INTERNAL_LB_VM_START = "INTERNALLBVM.START";
+ public static final String EVENT_INTERNAL_LB_VM_STOP = "INTERNALLBVM.STOP";
// Dedicated guest vlan range
public static final String EVENT_GUEST_VLAN_RANGE_DEDICATE = "GUESTVLANRANGE.DEDICATE";
public static final String EVENT_DEDICATED_GUEST_VLAN_RANGE_RELEASE = "GUESTVLANRANGE.RELEASE";
+
static {
// TODO: need a way to force author adding event types to declare the entity details as well, with out braking
diff --git a/api/src/com/cloud/exception/MissingParameterValueException.java b/api/src/com/cloud/exception/MissingParameterValueException.java
new file mode 100644
index 00000000000..231541dcdb3
--- /dev/null
+++ b/api/src/com/cloud/exception/MissingParameterValueException.java
@@ -0,0 +1,25 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.exception;
+
+import com.cloud.utils.exception.CloudRuntimeException;
+public class MissingParameterValueException extends CloudRuntimeException {
+
+ public MissingParameterValueException(String message) {
+ super(message);
+ }
+}
\ No newline at end of file
diff --git a/api/src/com/cloud/network/IpAddress.java b/api/src/com/cloud/network/IpAddress.java
index 71c9b4e0bf3..c48e8b97ca8 100644
--- a/api/src/com/cloud/network/IpAddress.java
+++ b/api/src/com/cloud/network/IpAddress.java
@@ -81,4 +81,7 @@ public interface IpAddress extends ControlledEntity, Identity, InternalIdentity
Long getVpcId();
String getVmIp();
+
+ Long getNetworkId();
+
}
diff --git a/api/src/com/cloud/network/Network.java b/api/src/com/cloud/network/Network.java
index 4472dbacc53..a06208b2565 100644
--- a/api/src/com/cloud/network/Network.java
+++ b/api/src/com/cloud/network/Network.java
@@ -16,18 +16,19 @@
// under the License.
package com.cloud.network;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.cloudstack.acl.ControlledEntity;
+import org.apache.cloudstack.api.Identity;
+import org.apache.cloudstack.api.InternalIdentity;
+
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.Mode;
import com.cloud.network.Networks.TrafficType;
import com.cloud.utils.fsm.StateMachine2;
import com.cloud.utils.fsm.StateObject;
-import org.apache.cloudstack.acl.ControlledEntity;
-import org.apache.cloudstack.api.Identity;
-import org.apache.cloudstack.api.InternalIdentity;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
/**
* owned by an account.
@@ -50,7 +51,7 @@ public interface Network extends ControlledEntity, StateObject, I
Capability.MultipleIps, Capability.TrafficStatistics, Capability.SupportedTrafficDirection, Capability.SupportedEgressProtocols);
public static final Service Lb = new Service("Lb", Capability.SupportedLBAlgorithms, Capability.SupportedLBIsolation,
Capability.SupportedProtocols, Capability.TrafficStatistics, Capability.LoadBalancingSupportedIps,
- Capability.SupportedStickinessMethods, Capability.ElasticLb);
+ Capability.SupportedStickinessMethods, Capability.ElasticLb, Capability.LbSchemes);
public static final Service UserData = new Service("UserData");
public static final Service SourceNat = new Service("SourceNat", Capability.SupportedSourceNatTypes, Capability.RedundantRouter);
public static final Service StaticNat = new Service("StaticNat", Capability.ElasticIp);
@@ -124,6 +125,7 @@ public interface Network extends ControlledEntity, StateObject, I
public static final Provider None = new Provider("None", false);
// NiciraNvp is not an "External" provider, otherwise we get in trouble with NetworkServiceImpl.providersConfiguredForExternalNetworking
public static final Provider NiciraNvp = new Provider("NiciraNvp", false);
+ public static final Provider InternalLbVm = new Provider("InternalLbVm", false);
public static final Provider CiscoVnmc = new Provider("CiscoVnmc", true);
private String name;
@@ -177,6 +179,7 @@ public interface Network extends ControlledEntity, StateObject, I
public static final Capability SupportedTrafficDirection = new Capability("SupportedTrafficDirection");
public static final Capability SupportedEgressProtocols = new Capability("SupportedEgressProtocols");
public static final Capability HealthCheckPolicy = new Capability("HealthCheckPolicy");
+ public static final Capability LbSchemes = new Capability("LbSchemes");
private String name;
@@ -319,9 +322,14 @@ public interface Network extends ControlledEntity, StateObject, I
boolean getSpecifyIpRanges();
+ boolean getDisplayNetwork();
+
/**
* @return
*/
Long getVpcId();
+ Long getNetworkACLId();
+
+ void setNetworkACLId(Long networkACLId);
}
diff --git a/api/src/com/cloud/network/NetworkModel.java b/api/src/com/cloud/network/NetworkModel.java
index 555a09fc53e..f84a8b0c76a 100644
--- a/api/src/com/cloud/network/NetworkModel.java
+++ b/api/src/com/cloud/network/NetworkModel.java
@@ -33,6 +33,7 @@ import com.cloud.network.Networks.TrafficType;
import com.cloud.network.element.NetworkElement;
import com.cloud.network.element.UserDataServiceProvider;
import com.cloud.offering.NetworkOffering;
+import com.cloud.offering.NetworkOffering.Detail;
import com.cloud.user.Account;
import com.cloud.vm.Nic;
import com.cloud.vm.NicProfile;
@@ -264,5 +265,11 @@ public interface NetworkModel {
Nic getPlaceholderNicForRouter(Network network, Long podId);
+ IpAddress getPublicIpAddress(String ipAddress, long zoneId);
+
+ List getUsedIpsInNetwork(Network network);
+
+ Map getNtwkOffDetails(long offId);
+
Networks.IsolationType[] listNetworkIsolationMethods();
}
\ No newline at end of file
diff --git a/api/src/com/cloud/network/NetworkProfile.java b/api/src/com/cloud/network/NetworkProfile.java
index 2f56645139c..fa63ea286aa 100644
--- a/api/src/com/cloud/network/NetworkProfile.java
+++ b/api/src/com/cloud/network/NetworkProfile.java
@@ -52,6 +52,8 @@ public class NetworkProfile implements Network {
private boolean restartRequired;
private boolean specifyIpRanges;
private Long vpcId;
+ private boolean displayNetwork;
+ private Long networkAclId;
public NetworkProfile(Network network) {
this.id = network.getId();
@@ -81,6 +83,8 @@ public class NetworkProfile implements Network {
this.restartRequired = network.isRestartRequired();
this.specifyIpRanges = network.getSpecifyIpRanges();
this.vpcId = network.getVpcId();
+ this.displayNetwork = network.getDisplayNetwork();
+ this.networkAclId = network.getNetworkACLId();
}
public String getDns1() {
@@ -231,11 +235,26 @@ public class NetworkProfile implements Network {
return false;
}
+ @Override
+ public boolean getDisplayNetwork() {
+ return displayNetwork;
+ }
+
@Override
public Long getVpcId() {
return vpcId;
}
+ @Override
+ public Long getNetworkACLId() {
+ return networkAclId;
+ }
+
+ @Override
+ public void setNetworkACLId(Long networkACLId) {
+ this.networkAclId = networkACLId;
+ }
+
@Override
public void setTrafficType(TrafficType type) {
this.trafficType = type;
diff --git a/api/src/com/cloud/network/NetworkService.java b/api/src/com/cloud/network/NetworkService.java
index 5d4fd67d326..2e50c53d8bb 100755
--- a/api/src/com/cloud/network/NetworkService.java
+++ b/api/src/com/cloud/network/NetworkService.java
@@ -21,9 +21,7 @@ import java.util.List;
import org.apache.cloudstack.api.command.admin.network.DedicateGuestVlanRangeCmd;
import org.apache.cloudstack.api.command.admin.network.ListDedicatedGuestVlanRangesCmd;
import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementorsCmd;
-import org.apache.cloudstack.api.command.user.network.RestartNetworkCmd;
-import org.apache.cloudstack.api.command.user.network.CreateNetworkCmd;
-import org.apache.cloudstack.api.command.user.network.ListNetworksCmd;
+import org.apache.cloudstack.api.command.user.network.*;
import org.apache.cloudstack.api.command.user.vm.ListNicsCmd;
import com.cloud.exception.ConcurrentOperationException;
@@ -73,7 +71,7 @@ public interface NetworkService {
IpAddress getIp(long id);
Network updateGuestNetwork(long networkId, String name, String displayText, Account callerAccount, User callerUser,
- String domainSuffix, Long networkOfferingId, Boolean changeCidr, String guestVmCidr);
+ String domainSuffix, Long networkOfferingId, Boolean changeCidr, String guestVmCidr, Boolean displayNetwork);
PhysicalNetwork createPhysicalNetwork(Long zoneId, String vnetRange, String networkSpeed,
List isolationMethods, String broadcastDomainRange, Long domainId, List tags, String name);
@@ -165,7 +163,7 @@ public interface NetworkService {
* @throws ResourceAllocationException
*/
Network createPrivateNetwork(String networkName, String displayText, long physicalNetworkId, String vlan,
- String startIp, String endIP, String gateway, String netmask, long networkOwnerId, Long vpcId, Boolean sourceNat)
+ String startIp, String endIP, String gateway, String netmask, long networkOwnerId, Long vpcId, Boolean sourceNat)
throws ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException;
/* Requests an IP address for the guest nic */
@@ -176,4 +174,5 @@ public interface NetworkService {
/* lists the nic informaton */
List extends Nic> listNics(ListNicsCmd listNicsCmd);
+
}
diff --git a/api/src/com/cloud/network/VirtualNetworkApplianceService.java b/api/src/com/cloud/network/VirtualNetworkApplianceService.java
index 250ecb24e91..58eead2af07 100644
--- a/api/src/com/cloud/network/VirtualNetworkApplianceService.java
+++ b/api/src/com/cloud/network/VirtualNetworkApplianceService.java
@@ -63,5 +63,7 @@ public interface VirtualNetworkApplianceService {
VirtualRouter startRouter(long id) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException;
VirtualRouter destroyRouter(long routerId, Account caller, Long callerUserId) throws ResourceUnavailableException, ConcurrentOperationException;
+
+ VirtualRouter findRouter(long routerId);
}
diff --git a/api/src/com/cloud/network/VirtualRouterProvider.java b/api/src/com/cloud/network/VirtualRouterProvider.java
index ed6a2741ba0..f67686e6b08 100644
--- a/api/src/com/cloud/network/VirtualRouterProvider.java
+++ b/api/src/com/cloud/network/VirtualRouterProvider.java
@@ -23,7 +23,8 @@ public interface VirtualRouterProvider extends InternalIdentity, Identity {
public enum VirtualRouterProviderType {
VirtualRouter,
ElasticLoadBalancerVm,
- VPCVirtualRouter
+ VPCVirtualRouter,
+ InternalLbVm
}
public VirtualRouterProviderType getType();
diff --git a/api/src/com/cloud/network/element/DhcpServiceProvider.java b/api/src/com/cloud/network/element/DhcpServiceProvider.java
index f73590c53e3..83008ca801f 100644
--- a/api/src/com/cloud/network/element/DhcpServiceProvider.java
+++ b/api/src/com/cloud/network/element/DhcpServiceProvider.java
@@ -28,4 +28,6 @@ import com.cloud.vm.VirtualMachineProfile;
public interface DhcpServiceProvider extends NetworkElement {
boolean addDhcpEntry(Network network, NicProfile nic, VirtualMachineProfile extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException;
+ boolean configDhcpSupportForSubnet(Network network, NicProfile nic, VirtualMachineProfile extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException;
+ boolean removeDhcpSupportForSubnet(Network network);
}
diff --git a/api/src/com/cloud/network/element/NetworkACLServiceProvider.java b/api/src/com/cloud/network/element/NetworkACLServiceProvider.java
index 4073b07ba1b..dac0a25c668 100644
--- a/api/src/com/cloud/network/element/NetworkACLServiceProvider.java
+++ b/api/src/com/cloud/network/element/NetworkACLServiceProvider.java
@@ -21,6 +21,7 @@ import java.util.List;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.Network;
import com.cloud.network.rules.FirewallRule;
+import com.cloud.network.vpc.NetworkACLItem;
public interface NetworkACLServiceProvider extends NetworkElement{
@@ -30,6 +31,6 @@ public interface NetworkACLServiceProvider extends NetworkElement{
* @return
* @throws ResourceUnavailableException
*/
- boolean applyNetworkACLs(Network config, List extends FirewallRule> rules) throws ResourceUnavailableException;
+ boolean applyNetworkACLs(Network config, List extends NetworkACLItem> rules) throws ResourceUnavailableException;
}
diff --git a/api/src/com/cloud/network/element/VpcProvider.java b/api/src/com/cloud/network/element/VpcProvider.java
index 81b1cf321db..acdd05d063c 100644
--- a/api/src/com/cloud/network/element/VpcProvider.java
+++ b/api/src/com/cloud/network/element/VpcProvider.java
@@ -52,4 +52,6 @@ public interface VpcProvider extends NetworkElement{
boolean deletePrivateGateway(PrivateGateway privateGateway) throws ConcurrentOperationException, ResourceUnavailableException;
boolean applyStaticRoutes(Vpc vpc, List routes) throws ResourceUnavailableException;
+
+ boolean applyACLItemsToPrivateGw(PrivateGateway gateway) throws ResourceUnavailableException;
}
diff --git a/api/src/com/cloud/network/lb/LoadBalancingRule.java b/api/src/com/cloud/network/lb/LoadBalancingRule.java
index 3e11e8c7c2c..4b37782a8c7 100644
--- a/api/src/com/cloud/network/lb/LoadBalancingRule.java
+++ b/api/src/com/cloud/network/lb/LoadBalancingRule.java
@@ -25,111 +25,83 @@ import com.cloud.network.as.Condition;
import com.cloud.network.as.Counter;
import com.cloud.network.rules.FirewallRule;
import com.cloud.network.rules.LoadBalancer;
+import com.cloud.network.rules.LoadBalancerContainer.Scheme;
import com.cloud.utils.Pair;
+import com.cloud.utils.net.Ip;
-public class LoadBalancingRule implements FirewallRule, LoadBalancer {
+public class LoadBalancingRule {
private LoadBalancer lb;
+ private Ip sourceIp;
private List destinations;
private List stickinessPolicies;
private LbAutoScaleVmGroup autoScaleVmGroup;
private List healthCheckPolicies;
public LoadBalancingRule(LoadBalancer lb, List destinations,
- List stickinessPolicies, List healthCheckPolicies) {
+ List stickinessPolicies, List healthCheckPolicies, Ip sourceIp) {
this.lb = lb;
this.destinations = destinations;
this.stickinessPolicies = stickinessPolicies;
this.healthCheckPolicies = healthCheckPolicies;
+ this.sourceIp = sourceIp;
}
- @Override
public long getId() {
return lb.getId();
}
- @Override
- public long getAccountId() {
- return lb.getAccountId();
- }
-
- @Override
- public long getDomainId() {
- return lb.getDomainId();
- }
-
- @Override
public String getName() {
return lb.getName();
}
- @Override
public String getDescription() {
return lb.getDescription();
}
- @Override
public int getDefaultPortStart() {
return lb.getDefaultPortStart();
}
- @Override
public int getDefaultPortEnd() {
return lb.getDefaultPortEnd();
}
- @Override
public String getAlgorithm() {
return lb.getAlgorithm();
}
- @Override
public String getUuid() {
return lb.getUuid();
}
- @Override
public String getXid() {
return lb.getXid();
}
- @Override
- public Long getSourceIpAddressId() {
- return lb.getSourceIpAddressId();
- }
-
- @Override
public Integer getSourcePortStart() {
return lb.getSourcePortStart();
}
- @Override
public Integer getSourcePortEnd() {
return lb.getSourcePortEnd();
}
- @Override
public String getProtocol() {
return lb.getProtocol();
}
- @Override
- public Purpose getPurpose() {
- return Purpose.LoadBalancing;
+ public FirewallRule.Purpose getPurpose() {
+ return FirewallRule.Purpose.LoadBalancing;
}
- @Override
- public State getState() {
+ public FirewallRule.State getState() {
return lb.getState();
}
- @Override
public long getNetworkId() {
return lb.getNetworkId();
}
- public LoadBalancer getLb() {
- return lb;
- }
public void setDestinations(List destinations) {
this.destinations = destinations;
@@ -287,36 +259,6 @@ public class LoadBalancingRule implements FirewallRule, LoadBalancer {
}
}
- @Override
- public Integer getIcmpCode() {
- return null;
- }
-
- @Override
- public Integer getIcmpType() {
- return null;
- }
-
- @Override
- public List getSourceCidrList() {
- return null;
- }
-
- @Override
- public Long getRelated() {
- return null;
- }
-
- @Override
- public TrafficType getTrafficType() {
- return null;
- }
-
- @Override
- public FirewallRuleType getType() {
- return FirewallRuleType.User;
- }
-
public LbAutoScaleVmGroup getAutoScaleVmGroup() {
return autoScaleVmGroup;
}
@@ -473,4 +415,11 @@ public class LoadBalancingRule implements FirewallRule, LoadBalancer {
}
}
+ public Ip getSourceIp() {
+ return sourceIp;
+ }
+
+ public Scheme getScheme() {
+ return lb.getScheme();
+ }
}
diff --git a/api/src/com/cloud/network/lb/LoadBalancingRulesService.java b/api/src/com/cloud/network/lb/LoadBalancingRulesService.java
index ed39bedaa6f..5fc41e34c34 100644
--- a/api/src/com/cloud/network/lb/LoadBalancingRulesService.java
+++ b/api/src/com/cloud/network/lb/LoadBalancingRulesService.java
@@ -17,10 +17,10 @@
package com.cloud.network.lb;
import java.util.List;
+import java.util.Map;
import org.apache.cloudstack.api.command.user.loadbalancer.CreateLBHealthCheckPolicyCmd;
import org.apache.cloudstack.api.command.user.loadbalancer.CreateLBStickinessPolicyCmd;
-import org.apache.cloudstack.api.command.user.loadbalancer.CreateLoadBalancerRuleCmd;
import org.apache.cloudstack.api.command.user.loadbalancer.ListLBHealthCheckPoliciesCmd;
import org.apache.cloudstack.api.command.user.loadbalancer.ListLBStickinessPoliciesCmd;
import org.apache.cloudstack.api.command.user.loadbalancer.ListLoadBalancerRuleInstancesCmd;
@@ -30,12 +30,13 @@ import org.apache.cloudstack.api.command.user.loadbalancer.UpdateLoadBalancerRul
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.lb.LoadBalancingRule.LbStickinessPolicy;
import com.cloud.network.rules.HealthCheckPolicy;
import com.cloud.network.rules.LoadBalancer;
+import com.cloud.network.rules.LoadBalancerContainer.Scheme;
import com.cloud.network.rules.StickinessPolicy;
import com.cloud.uservm.UserVm;
import com.cloud.utils.Pair;
+import com.cloud.utils.net.Ip;
public interface LoadBalancingRulesService {
@@ -49,7 +50,9 @@ public interface LoadBalancingRulesService {
* @return the newly created LoadBalancerVO if successful, null otherwise
* @throws InsufficientAddressCapacityException
*/
- LoadBalancer createLoadBalancerRule(CreateLoadBalancerRuleCmd lb, boolean openFirewall) throws NetworkRuleConflictException, InsufficientAddressCapacityException;
+ LoadBalancer createPublicLoadBalancerRule(String xId, String name, String description,
+ int srcPortStart, int srcPortEnd, int defPortStart, int defPortEnd, Long ipAddrId, String protocol, String algorithm,
+ long networkId, long lbOwnerId, boolean openFirewall) throws NetworkRuleConflictException, InsufficientAddressCapacityException;
LoadBalancer updateLoadBalancerRule(UpdateLoadBalancerRuleCmd cmd);
@@ -134,8 +137,9 @@ public interface LoadBalancingRulesService {
List extends HealthCheckPolicy> searchForLBHealthCheckPolicies(ListLBHealthCheckPoliciesCmd cmd);
- List listByNetworkId(long networkId);
-
LoadBalancer findById(long LoadBalancer);
- public void updateLBHealthChecks() throws ResourceUnavailableException;
+
+ public void updateLBHealthChecks(Scheme scheme) throws ResourceUnavailableException;
+
+ Map getLbInstances(long lbId);
}
diff --git a/api/src/com/cloud/network/router/VirtualRouter.java b/api/src/com/cloud/network/router/VirtualRouter.java
index d7239dd3452..2311f489918 100755
--- a/api/src/com/cloud/network/router/VirtualRouter.java
+++ b/api/src/com/cloud/network/router/VirtualRouter.java
@@ -23,7 +23,7 @@ import com.cloud.vm.VirtualMachine;
*/
public interface VirtualRouter extends VirtualMachine {
public enum Role {
- VIRTUAL_ROUTER, LB
+ VIRTUAL_ROUTER, LB, INTERNAL_LB_VM
}
Role getRole();
boolean getIsRedundantRouter();
diff --git a/api/src/com/cloud/network/rules/LoadBalancer.java b/api/src/com/cloud/network/rules/LoadBalancer.java
index ab6085aceb7..e6dadcaee97 100644
--- a/api/src/com/cloud/network/rules/LoadBalancer.java
+++ b/api/src/com/cloud/network/rules/LoadBalancer.java
@@ -19,16 +19,10 @@ package com.cloud.network.rules;
/**
* Definition for a LoadBalancer
*/
-public interface LoadBalancer extends FirewallRule {
-
- String getName();
-
- String getDescription();
-
+public interface LoadBalancer extends FirewallRule, LoadBalancerContainer {
+
int getDefaultPortStart();
int getDefaultPortEnd();
- String getAlgorithm();
-
}
diff --git a/api/src/com/cloud/network/rules/LoadBalancerContainer.java b/api/src/com/cloud/network/rules/LoadBalancerContainer.java
new file mode 100644
index 00000000000..9d5ea595c9d
--- /dev/null
+++ b/api/src/com/cloud/network/rules/LoadBalancerContainer.java
@@ -0,0 +1,33 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.network.rules;
+
+public interface LoadBalancerContainer {
+
+ public enum Scheme {
+ Public, Internal;
+ }
+
+ String getName();
+
+ String getDescription();
+
+ String getAlgorithm();
+
+ Scheme getScheme();
+
+}
diff --git a/api/src/com/cloud/network/vpc/NetworkACL.java b/api/src/com/cloud/network/vpc/NetworkACL.java
new file mode 100644
index 00000000000..8bde7c2142f
--- /dev/null
+++ b/api/src/com/cloud/network/vpc/NetworkACL.java
@@ -0,0 +1,36 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package com.cloud.network.vpc;
+
+import org.apache.cloudstack.acl.ControlledEntity;
+import org.apache.cloudstack.api.InternalIdentity;
+
+public interface NetworkACL extends InternalIdentity{
+ public static final long DEFAULT_DENY = 1;
+ public static final long DEFAULT_ALLOW = 2;
+
+ String getDescription();
+
+ String getUuid();
+
+ Long getVpcId();
+
+ long getId();
+
+ String getName();
+}
diff --git a/api/src/com/cloud/network/vpc/NetworkACLItem.java b/api/src/com/cloud/network/vpc/NetworkACLItem.java
new file mode 100644
index 00000000000..312fa7390b2
--- /dev/null
+++ b/api/src/com/cloud/network/vpc/NetworkACLItem.java
@@ -0,0 +1,80 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.network.vpc;
+
+import org.apache.cloudstack.acl.ControlledEntity;
+import org.apache.cloudstack.api.Identity;
+import org.apache.cloudstack.api.InternalIdentity;
+
+import java.util.List;
+
+public interface NetworkACLItem extends InternalIdentity {
+
+ String getUuid();
+
+ Action getAction();
+
+ int getNumber();
+
+ enum State {
+ Staged, // Rule been created but has never got through network rule conflict detection. Rules in this state can not be sent to network elements.
+ Add, // Add means the rule has been created and has gone through network rule conflict detection.
+ Active, // Rule has been sent to the network elements and reported to be active.
+ Revoke // Revoke means this rule has been revoked. If this rule has been sent to the network elements, the rule will be deleted from database.
+ }
+
+ enum TrafficType {
+ Ingress,
+ Egress
+ }
+
+ enum Action {
+ Allow,
+ Deny
+ }
+
+ /**
+ * @return first port of the source port range.
+ */
+ Integer getSourcePortStart();
+
+ /**
+ * @return last port of the source prot range. If this is null, that means only one port is mapped.
+ */
+ Integer getSourcePortEnd();
+
+ /**
+ * @return protocol to open these ports for.
+ */
+ String getProtocol();
+
+ State getState();
+
+ long getAclId();
+
+ Integer getIcmpCode();
+
+ Integer getIcmpType();
+
+ List getSourceCidrList();
+
+ /**
+ * @return
+ */
+ TrafficType getTrafficType();
+
+}
diff --git a/api/src/com/cloud/network/vpc/NetworkACLService.java b/api/src/com/cloud/network/vpc/NetworkACLService.java
new file mode 100644
index 00000000000..ec53c26a4ce
--- /dev/null
+++ b/api/src/com/cloud/network/vpc/NetworkACLService.java
@@ -0,0 +1,135 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.network.vpc;
+
+
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.utils.Pair;
+import org.apache.cloudstack.api.command.user.network.CreateNetworkACLCmd;
+import org.apache.cloudstack.api.command.user.network.ListNetworkACLsCmd;
+
+import java.util.List;
+
+public interface NetworkACLService {
+ /**
+ * Creates Network ACL for the specified VPC
+ * @param name
+ * @param description
+ * @param vpcId
+ * @return
+ */
+ NetworkACL createNetworkACL(String name, String description, long vpcId);
+
+ /**
+ * Get Network ACL with specified Id
+ * @param id
+ * @return
+ */
+ NetworkACL getNetworkACL(long id);
+
+ /**
+ * List NetworkACLs by Id/Name/Network or Vpc it belongs to
+ * @param id
+ * @param name
+ * @param networkId
+ * @param vpcId
+ * @return
+ */
+ Pair,Integer> listNetworkACLs(Long id, String name, Long networkId, Long vpcId);
+
+ /**
+ * Delete specified network ACL. Deletion fails if the list is not empty
+ * @param id
+ * @return
+ */
+ boolean deleteNetworkACL(long id);
+
+ /**
+ * Associates ACL with specified Network
+ * @param aclId
+ * @param networkId
+ * @return
+ * @throws ResourceUnavailableException
+ */
+ boolean replaceNetworkACL(long aclId, long networkId) throws ResourceUnavailableException;
+
+ /**
+ * Applied ACL to associated networks
+ * @param aclId
+ * @return
+ * @throws ResourceUnavailableException
+ */
+ boolean applyNetworkACL(long aclId) throws ResourceUnavailableException;
+
+ /**
+ * Creates a Network ACL Item within an ACL and applies the ACL to associated networks
+ * @param createNetworkACLCmd
+ * @return
+ */
+ NetworkACLItem createNetworkACLItem(CreateNetworkACLCmd aclItemCmd);
+
+ /**
+ * Return ACL item with specified Id
+ * @param ruleId
+ * @return
+ */
+ NetworkACLItem getNetworkACLItem(long ruleId);
+
+ /**
+ * Lists Network ACL Items by Id, Network, ACLId, Traffic Type, protocol
+ * @param listNetworkACLsCmd
+ * @return
+ */
+ Pair, Integer> listNetworkACLItems(ListNetworkACLsCmd cmd);
+
+ /**
+ * Revoked ACL Item with specified Id
+ * @param ruleId
+ * @param apply
+ * @return
+ */
+ boolean revokeNetworkACLItem(long ruleId);
+
+ /**
+ * Updates existing aclItem applies to associated networks
+ * @param id
+ * @param protocol
+ * @param sourceCidrList
+ * @param trafficType
+ * @param action
+ * @param number
+ * @param sourcePortStart
+ * @param sourcePortEnd
+ * @param icmpCode
+ * @param icmpType
+ * @return
+ * @throws ResourceUnavailableException
+ */
+ NetworkACLItem updateNetworkACLItem(Long id, String protocol, List sourceCidrList, NetworkACLItem.TrafficType trafficType,
+ String action, Integer number, Integer sourcePortStart, Integer sourcePortEnd,
+ Integer icmpCode, Integer icmpType) throws ResourceUnavailableException;
+
+ /**
+ * Associates ACL with specified Network
+ * @param aclId
+ * @param privateGatewayId
+ * @return
+ * @throws ResourceUnavailableException
+ */
+ boolean replaceNetworkACLonPrivateGw(long aclId, long privateGatewayId) throws ResourceUnavailableException;
+
+}
diff --git a/api/src/com/cloud/network/vpc/VpcGateway.java b/api/src/com/cloud/network/vpc/VpcGateway.java
index e3530d08561..5d278e952ed 100644
--- a/api/src/com/cloud/network/vpc/VpcGateway.java
+++ b/api/src/com/cloud/network/vpc/VpcGateway.java
@@ -81,4 +81,9 @@ public interface VpcGateway extends Identity, ControlledEntity, InternalIdentity
* @return
*/
boolean getSourceNat();
+
+ /**
+ * @return
+ */
+ long getNetworkACLId();
}
diff --git a/api/src/com/cloud/network/vpc/VpcOffering.java b/api/src/com/cloud/network/vpc/VpcOffering.java
index 3961d0aaba7..3ec81e693af 100644
--- a/api/src/com/cloud/network/vpc/VpcOffering.java
+++ b/api/src/com/cloud/network/vpc/VpcOffering.java
@@ -26,6 +26,7 @@ public interface VpcOffering extends InternalIdentity, Identity {
}
public static final String defaultVPCOfferingName = "Default VPC offering";
+ public static final String defaultVPCNSOfferingName = "Default VPC offering with Netscaler";
/**
*
diff --git a/api/src/com/cloud/network/vpc/VpcService.java b/api/src/com/cloud/network/vpc/VpcService.java
index 23e276489c2..7a444c07b85 100644
--- a/api/src/com/cloud/network/vpc/VpcService.java
+++ b/api/src/com/cloud/network/vpc/VpcService.java
@@ -172,13 +172,14 @@ public interface VpcService {
* @param netmask
* @param gatewayOwnerId
* @param isSourceNat
+ * @param aclId
* @return
* @throws InsufficientCapacityException
* @throws ConcurrentOperationException
* @throws ResourceAllocationException
*/
public PrivateGateway createVpcPrivateGateway(long vpcId, Long physicalNetworkId, String vlan, String ipAddress,
- String gateway, String netmask, long gatewayOwnerId, Boolean isSourceNat) throws ResourceAllocationException,
+ String gateway, String netmask, long gatewayOwnerId, Boolean isSoruceNat, Long aclId) throws ResourceAllocationException,
ConcurrentOperationException, InsufficientCapacityException;
/**
diff --git a/api/src/com/cloud/offering/NetworkOffering.java b/api/src/com/cloud/offering/NetworkOffering.java
index 6f0b9937854..72e2a2bbbab 100644
--- a/api/src/com/cloud/offering/NetworkOffering.java
+++ b/api/src/com/cloud/offering/NetworkOffering.java
@@ -16,6 +16,8 @@
// under the License.
package com.cloud.offering;
+import java.util.Map;
+
import org.apache.cloudstack.acl.InfrastructureEntity;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
@@ -38,6 +40,11 @@ public interface NetworkOffering extends InfrastructureEntity, InternalIdentity,
Disabled,
Enabled
}
+
+ public enum Detail {
+ InternalLbProvider,
+ PublicLbProvider
+ }
public final static String SystemPublicNetwork = "System-Public-Network";
public final static String SystemControlNetwork = "System-Control-Network";
@@ -116,5 +123,9 @@ public interface NetworkOffering extends InfrastructureEntity, InternalIdentity,
boolean isInline();
boolean getIsPersistent();
+
+ boolean getInternalLb();
+
+ boolean getPublicLb();
}
diff --git a/api/src/com/cloud/offering/ServiceOffering.java b/api/src/com/cloud/offering/ServiceOffering.java
index d6c215f42f0..165369c5e9b 100755
--- a/api/src/com/cloud/offering/ServiceOffering.java
+++ b/api/src/com/cloud/offering/ServiceOffering.java
@@ -30,6 +30,7 @@ public interface ServiceOffering extends InfrastructureEntity, InternalIdentity,
public static final String ssvmDefaultOffUniqueName = "Cloud.com-SecondaryStorage";
public static final String routerDefaultOffUniqueName = "Cloud.Com-SoftwareRouter";
public static final String elbVmDefaultOffUniqueName = "Cloud.Com-ElasticLBVm";
+ public static final String internalLbVmDefaultOffUniqueName = "Cloud.Com-InternalLBVm";
public enum StorageType {
local,
diff --git a/api/src/com/cloud/server/ResourceMetaDataService.java b/api/src/com/cloud/server/ResourceMetaDataService.java
new file mode 100644
index 00000000000..556f97453a1
--- /dev/null
+++ b/api/src/com/cloud/server/ResourceMetaDataService.java
@@ -0,0 +1,47 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.package com.cloud.server;
+
+package com.cloud.server;
+import java.util.List;
+import java.util.Map;
+
+import com.cloud.server.ResourceTag.TaggedResourceType;
+
+public interface ResourceMetaDataService {
+
+ TaggedResourceType getResourceType (String resourceTypeStr);
+
+ /**
+ * @param resourceId TODO
+ * @param resourceType
+ * @param details
+ * @return
+ */
+ boolean addResourceMetaData(String resourceId, TaggedResourceType resourceType, Map details);
+
+
+ /**
+ *
+ * @param resourceId
+ * @param resourceType
+ * @param key
+ * @return
+ */
+ public boolean deleteResourceMetaData(String resourceId, TaggedResourceType resourceType, String key);
+
+
+ }
diff --git a/api/src/com/cloud/server/ResourceTag.java b/api/src/com/cloud/server/ResourceTag.java
index 9006e305d81..f1d31e4e0d0 100644
--- a/api/src/com/cloud/server/ResourceTag.java
+++ b/api/src/com/cloud/server/ResourceTag.java
@@ -29,6 +29,7 @@ public interface ResourceTag extends ControlledEntity, Identity, InternalIdentit
Volume,
Snapshot,
Network,
+ Nic,
LoadBalancer,
PortForwardingRule,
FirewallRule,
diff --git a/api/src/com/cloud/server/TaggedResourceService.java b/api/src/com/cloud/server/TaggedResourceService.java
index 92a4300db0a..46b185480bb 100644
--- a/api/src/com/cloud/server/TaggedResourceService.java
+++ b/api/src/com/cloud/server/TaggedResourceService.java
@@ -51,4 +51,7 @@ public interface TaggedResourceService {
boolean deleteTags(List resourceIds, TaggedResourceType resourceType, Map tags);
List extends ResourceTag> listByResourceTypeAndId(TaggedResourceType type, long resourceId);
-}
+
+ public Long getResourceId(String resourceId, TaggedResourceType resourceType);
+
+ }
diff --git a/api/src/com/cloud/storage/VolumeApiService.java b/api/src/com/cloud/storage/VolumeApiService.java
index 462ff6433d1..aa52cf74652 100644
--- a/api/src/com/cloud/storage/VolumeApiService.java
+++ b/api/src/com/cloud/storage/VolumeApiService.java
@@ -18,12 +18,7 @@
*/
package com.cloud.storage;
-import org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd;
-import org.apache.cloudstack.api.command.user.volume.CreateVolumeCmd;
-import org.apache.cloudstack.api.command.user.volume.DetachVolumeCmd;
-import org.apache.cloudstack.api.command.user.volume.MigrateVolumeCmd;
-import org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd;
-import org.apache.cloudstack.api.command.user.volume.UploadVolumeCmd;
+import org.apache.cloudstack.api.command.user.volume.*;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.PermissionDeniedException;
@@ -85,4 +80,5 @@ public interface VolumeApiService {
Snapshot allocSnapshot(Long volumeId, Long policyId)
throws ResourceAllocationException;
+ Volume updateVolume(UpdateVolumeCmd updateVolumeCmd);
}
diff --git a/api/src/com/cloud/vm/NicIpAlias.java b/api/src/com/cloud/vm/NicIpAlias.java
new file mode 100644
index 00000000000..11e127ca856
--- /dev/null
+++ b/api/src/com/cloud/vm/NicIpAlias.java
@@ -0,0 +1,45 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.vm;
+
+import org.apache.cloudstack.acl.ControlledEntity;
+import org.apache.cloudstack.api.Identity;
+import org.apache.cloudstack.api.InternalIdentity;
+
+/** Each entry represents the alis ip of a perticular nic.
+ *
+ */
+public interface NicIpAlias extends ControlledEntity, Identity, InternalIdentity{
+ /**
+ * @return id in the CloudStack database
+ */
+ enum state {
+ active,
+ revoked,
+ }
+ long getId();
+ long getNicId();
+ String getIp4Address();
+ String getIp6Address();
+ long getNetworkId();
+ long getVmId();
+ Long getAliasCount();
+ String getNetmask();
+ String getGateway();
+
+
+}
diff --git a/api/src/com/cloud/vm/UserVmService.java b/api/src/com/cloud/vm/UserVmService.java
index fa89521af0a..0a0660ad493 100755
--- a/api/src/com/cloud/vm/UserVmService.java
+++ b/api/src/com/cloud/vm/UserVmService.java
@@ -177,7 +177,10 @@ public interface UserVmService {
* TODO
* @param defaultIp
* TODO
+ * @param displayVm
+ * - Boolean flag whether to the display the vm to the end user or not
* @param affinityGroupIdList
+ *
* @param accountName
* - an optional account for the virtual machine. Must be used
* with domainId
@@ -197,9 +200,9 @@ public interface UserVmService {
* @throws InsufficientResourcesException
*/
UserVm createBasicSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List securityGroupIdList, Account owner, String hostName,
- String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor,
+ String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor,
HTTPMethod httpmethod, String userData, String sshKeyPair, Map requestedIps,
- IpAddresses defaultIp, String keyboard, List affinityGroupIdList)
+ IpAddresses defaultIp, Boolean displayVm, String keyboard, List affinityGroupIdList)
throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
/**
@@ -250,7 +253,10 @@ public interface UserVmService {
* TODO
* @param defaultIps
* TODO
+ * @param displayVm
+ * - Boolean flag whether to the display the vm to the end user or not
* @param affinityGroupIdList
+ *
* @param accountName
* - an optional account for the virtual machine. Must be used
* with domainId
@@ -270,8 +276,8 @@ public interface UserVmService {
* @throws InsufficientResourcesException
*/
UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List networkIdList, List securityGroupIdList,
- Account owner, String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, HTTPMethod httpmethod, String userData, String sshKeyPair,
- Map requestedIps, IpAddresses defaultIps, String keyboard, List affinityGroupIdList)
+ Account owner, String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, HTTPMethod httpmethod, String userData, String sshKeyPair,
+ Map requestedIps, IpAddresses defaultIps, Boolean displayVm, String keyboard, List affinityGroupIdList)
throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
/**
@@ -319,7 +325,10 @@ public interface UserVmService {
* TODO
* @param defaultIps
* TODO
+ * @param displayVm
+ * - Boolean flag whether to the display the vm to the end user or not
* @param affinityGroupIdList
+ *
* @param accountName
* - an optional account for the virtual machine. Must be used
* with domainId
@@ -340,8 +349,9 @@ public interface UserVmService {
*/
UserVm createAdvancedVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List networkIdList, Account owner, String hostName,
String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor,
- HTTPMethod httpmethod, String userData, String sshKeyPair, Map requestedIps,
- IpAddresses defaultIps, String keyboard, List affinityGroupIdList)
+ HTTPMethod httpmethod, String userData, String sshKeyPair, Map requestedIps,
+ IpAddresses defaultIps, Boolean displayVm, String keyboard, List affinityGroupIdList)
+
throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
/**
diff --git a/api/src/com/cloud/vm/VirtualMachine.java b/api/src/com/cloud/vm/VirtualMachine.java
index 8f807d450c7..ce9add62469 100755
--- a/api/src/com/cloud/vm/VirtualMachine.java
+++ b/api/src/com/cloud/vm/VirtualMachine.java
@@ -186,6 +186,7 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, I
SecondaryStorageVm,
ElasticIpVm,
ElasticLoadBalancerVm,
+ InternalLoadBalancerVm,
/*
* UserBareMetal is only used for selecting VirtualMachineGuru, there is no
@@ -196,7 +197,7 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, I
public static boolean isSystemVM(VirtualMachine.Type vmtype) {
if (DomainRouter.equals(vmtype)
|| ConsoleProxy.equals(vmtype)
- || SecondaryStorageVm.equals(vmtype)) {
+ || SecondaryStorageVm.equals(vmtype) || InternalLoadBalancerVm.equals(vmtype)) {
return true;
}
return false;
diff --git a/api/src/org/apache/cloudstack/api/ApiConstants.java b/api/src/org/apache/cloudstack/api/ApiConstants.java
index d57fe058d93..1b745cf892d 100755
--- a/api/src/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/org/apache/cloudstack/api/ApiConstants.java
@@ -56,7 +56,12 @@ public class ApiConstants {
public static final String DISK_OFFERING_ID = "diskofferingid";
public static final String DISK_SIZE = "disksize";
public static final String DISPLAY_NAME = "displayname";
+ public static final String DISPLAY_NETWORK = "displaynetwork";
+ public static final String DISPLAY_NIC = "displaynic";
public static final String DISPLAY_TEXT = "displaytext";
+ public static final String DISPLAY_VM = "displayvm";
+ public static final String DISPLAY_OFFERING = "displayoffering";
+ public static final String DISPLAY_VOLUME = "displayvolume";
public static final String DNS1 = "dns1";
public static final String DNS2 = "dns2";
public static final String IP6_DNS1 = "ip6dns1";
@@ -480,10 +485,18 @@ public class ApiConstants {
public static final String HEALTHCHECK_HEALTHY_THRESHOLD = "healthythreshold";
public static final String HEALTHCHECK_UNHEALTHY_THRESHOLD = "unhealthythreshold";
public static final String HEALTHCHECK_PINGPATH = "pingpath";
+ public static final String SOURCE_PORT = "sourceport";
+ public static final String INSTANCE_PORT = "instanceport";
+ public static final String SOURCE_IP = "sourceipaddress";
+ public static final String SOURCE_IP_NETWORK_ID = "sourceipaddressnetworkid";
+ public static final String SCHEME = "scheme";
+ public static final String PROVIDER_TYPE = "providertype";
public static final String AFFINITY_GROUP_IDS = "affinitygroupids";
public static final String AFFINITY_GROUP_NAMES = "affinitygroupnames";
public static final String ASA_INSIDE_PORT_PROFILE = "insideportprofile";
public static final String AFFINITY_GROUP_ID = "affinitygroupid";
+ public static final String ACL_ID = "aclid";
+ public static final String NUMBER = "number";
public enum HostDetails {
all, capacity, events, stats, min;
diff --git a/api/src/org/apache/cloudstack/api/BaseCmd.java b/api/src/org/apache/cloudstack/api/BaseCmd.java
index fc31cecf392..5b3b264e4a1 100644
--- a/api/src/org/apache/cloudstack/api/BaseCmd.java
+++ b/api/src/org/apache/cloudstack/api/BaseCmd.java
@@ -28,6 +28,10 @@ import java.util.regex.Pattern;
import javax.inject.Inject;
import org.apache.cloudstack.affinity.AffinityGroupService;
+import com.cloud.server.ResourceMetaDataService;
+import org.apache.cloudstack.network.element.InternalLoadBalancerElementService;
+import org.apache.cloudstack.network.lb.ApplicationLoadBalancerService;
+import org.apache.cloudstack.network.lb.InternalLoadBalancerVMService;
import org.apache.cloudstack.query.QueryService;
import org.apache.cloudstack.usage.UsageService;
import org.apache.log4j.Logger;
@@ -49,7 +53,7 @@ import com.cloud.network.StorageNetworkService;
import com.cloud.network.VpcVirtualNetworkApplianceService;
import com.cloud.network.as.AutoScaleService;
import com.cloud.network.firewall.FirewallService;
-import com.cloud.network.firewall.NetworkACLService;
+import com.cloud.network.vpc.NetworkACLService;
import com.cloud.network.lb.LoadBalancingRulesService;
import com.cloud.network.rules.RulesService;
import com.cloud.network.security.SecurityGroupService;
@@ -129,6 +133,7 @@ public abstract class BaseCmd {
@Inject public IdentityService _identityService;
@Inject public StorageNetworkService _storageNetworkService;
@Inject public TaggedResourceService _taggedResourceService;
+ @Inject public ResourceMetaDataService _resourceMetaDataService;
@Inject public VpcService _vpcService;
@Inject public NetworkACLService _networkACLService;
@Inject public Site2SiteVpnService _s2sVpnService;
@@ -139,7 +144,11 @@ public abstract class BaseCmd {
@Inject public VMSnapshotService _vmSnapshotService;
@Inject public DataStoreProviderApiService dataStoreProviderApiService;
@Inject public VpcProvisioningService _vpcProvSvc;
+ @Inject public ApplicationLoadBalancerService _newLbSvc;
+ @Inject public ApplicationLoadBalancerService _appLbService;
@Inject public AffinityGroupService _affinityGroupService;
+ @Inject public InternalLoadBalancerElementService _internalLbElementSvc;
+ @Inject public InternalLoadBalancerVMService _internalLbSvc;
@Inject public NetworkModel _ntwkModel;
public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException;
diff --git a/api/src/org/apache/cloudstack/api/ResponseGenerator.java b/api/src/org/apache/cloudstack/api/ResponseGenerator.java
index 25466180a4d..dd2bd58a6d2 100644
--- a/api/src/org/apache/cloudstack/api/ResponseGenerator.java
+++ b/api/src/org/apache/cloudstack/api/ResponseGenerator.java
@@ -19,90 +19,22 @@ package org.apache.cloudstack.api;
import java.text.DecimalFormat;
import java.util.EnumSet;
import java.util.List;
+import java.util.Map;
import com.cloud.vm.NicSecondaryIp;
import org.apache.cloudstack.affinity.AffinityGroup;
import org.apache.cloudstack.affinity.AffinityGroupResponse;
+import com.cloud.network.vpc.NetworkACL;
+import com.cloud.network.vpc.NetworkACLItem;
+import com.cloud.network.vpc.PrivateGateway;
+import com.cloud.network.vpc.StaticRoute;
+import com.cloud.network.vpc.Vpc;
+import com.cloud.network.vpc.VpcOffering;
import org.apache.cloudstack.api.ApiConstants.HostDetails;
import org.apache.cloudstack.api.ApiConstants.VMDetails;
import org.apache.cloudstack.api.command.user.job.QueryAsyncJobResultCmd;
-import org.apache.cloudstack.api.response.AccountResponse;
-import org.apache.cloudstack.api.response.AsyncJobResponse;
-import org.apache.cloudstack.api.response.AutoScalePolicyResponse;
-import org.apache.cloudstack.api.response.AutoScaleVmGroupResponse;
-import org.apache.cloudstack.api.response.AutoScaleVmProfileResponse;
-import org.apache.cloudstack.api.response.CapacityResponse;
-import org.apache.cloudstack.api.response.ClusterResponse;
-import org.apache.cloudstack.api.response.ConditionResponse;
-import org.apache.cloudstack.api.response.ConfigurationResponse;
-import org.apache.cloudstack.api.response.CounterResponse;
-import org.apache.cloudstack.api.response.CreateCmdResponse;
-import org.apache.cloudstack.api.response.DiskOfferingResponse;
-import org.apache.cloudstack.api.response.DomainResponse;
-import org.apache.cloudstack.api.response.DomainRouterResponse;
-import org.apache.cloudstack.api.response.EventResponse;
-import org.apache.cloudstack.api.response.ExtractResponse;
-import org.apache.cloudstack.api.response.FirewallResponse;
-import org.apache.cloudstack.api.response.FirewallRuleResponse;
-import org.apache.cloudstack.api.response.GuestOSResponse;
-import org.apache.cloudstack.api.response.HostResponse;
-import org.apache.cloudstack.api.response.HypervisorCapabilitiesResponse;
-import org.apache.cloudstack.api.response.IPAddressResponse;
-import org.apache.cloudstack.api.response.InstanceGroupResponse;
-import org.apache.cloudstack.api.response.IpForwardingRuleResponse;
-import org.apache.cloudstack.api.response.IsolationMethodResponse;
-import org.apache.cloudstack.api.response.LBHealthCheckResponse;
-import org.apache.cloudstack.api.response.LBStickinessResponse;
-import org.apache.cloudstack.api.response.LDAPConfigResponse;
-import org.apache.cloudstack.api.response.LoadBalancerResponse;
-import org.apache.cloudstack.api.response.NetworkACLResponse;
-import org.apache.cloudstack.api.response.NetworkOfferingResponse;
-import org.apache.cloudstack.api.response.NetworkResponse;
-import org.apache.cloudstack.api.response.NicResponse;
-import org.apache.cloudstack.api.response.NicSecondaryIpResponse;
-import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
-import org.apache.cloudstack.api.response.PodResponse;
-import org.apache.cloudstack.api.response.PrivateGatewayResponse;
-import org.apache.cloudstack.api.response.ProjectAccountResponse;
-import org.apache.cloudstack.api.response.ProjectInvitationResponse;
-import org.apache.cloudstack.api.response.ProjectResponse;
-import org.apache.cloudstack.api.response.ProviderResponse;
-import org.apache.cloudstack.api.response.RegionResponse;
-import org.apache.cloudstack.api.response.RemoteAccessVpnResponse;
-import org.apache.cloudstack.api.response.ResourceCountResponse;
-import org.apache.cloudstack.api.response.ResourceLimitResponse;
-import org.apache.cloudstack.api.response.ResourceTagResponse;
-import org.apache.cloudstack.api.response.S3Response;
-import org.apache.cloudstack.api.response.SecurityGroupResponse;
-import org.apache.cloudstack.api.response.ServiceOfferingResponse;
-import org.apache.cloudstack.api.response.ServiceResponse;
-import org.apache.cloudstack.api.response.Site2SiteCustomerGatewayResponse;
-import org.apache.cloudstack.api.response.Site2SiteVpnConnectionResponse;
-import org.apache.cloudstack.api.response.Site2SiteVpnGatewayResponse;
-import org.apache.cloudstack.api.response.SnapshotPolicyResponse;
-import org.apache.cloudstack.api.response.SnapshotResponse;
-import org.apache.cloudstack.api.response.SnapshotScheduleResponse;
-import org.apache.cloudstack.api.response.StaticRouteResponse;
-import org.apache.cloudstack.api.response.StorageNetworkIpRangeResponse;
-import org.apache.cloudstack.api.response.StoragePoolResponse;
-import org.apache.cloudstack.api.response.SwiftResponse;
-import org.apache.cloudstack.api.response.SystemVmInstanceResponse;
-import org.apache.cloudstack.api.response.SystemVmResponse;
-import org.apache.cloudstack.api.response.TemplatePermissionsResponse;
-import org.apache.cloudstack.api.response.TemplateResponse;
-import org.apache.cloudstack.api.response.TrafficMonitorResponse;
-import org.apache.cloudstack.api.response.TrafficTypeResponse;
-import org.apache.cloudstack.api.response.UsageRecordResponse;
-import org.apache.cloudstack.api.response.UserResponse;
-import org.apache.cloudstack.api.response.UserVmResponse;
-import org.apache.cloudstack.api.response.VMSnapshotResponse;
-import org.apache.cloudstack.api.response.VirtualRouterProviderResponse;
-import org.apache.cloudstack.api.response.VlanIpRangeResponse;
-import org.apache.cloudstack.api.response.VolumeResponse;
-import org.apache.cloudstack.api.response.VpcOfferingResponse;
-import org.apache.cloudstack.api.response.VpcResponse;
-import org.apache.cloudstack.api.response.VpnUsersResponse;
-import org.apache.cloudstack.api.response.ZoneResponse;
+import org.apache.cloudstack.api.response.*;
+import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
import org.apache.cloudstack.region.Region;
import org.apache.cloudstack.usage.Usage;
@@ -119,10 +51,25 @@ import com.cloud.domain.Domain;
import com.cloud.event.Event;
import com.cloud.host.Host;
import com.cloud.hypervisor.HypervisorCapabilities;
-import com.cloud.network.*;
+import com.cloud.network.GuestVlan;
+import com.cloud.network.IpAddress;
+import com.cloud.network.Network;
import com.cloud.network.Network.Service;
import com.cloud.network.Networks.IsolationType;
-import com.cloud.network.as.*;
+import com.cloud.network.PhysicalNetwork;
+import com.cloud.network.PhysicalNetworkServiceProvider;
+import com.cloud.network.PhysicalNetworkTrafficType;
+import com.cloud.network.RemoteAccessVpn;
+import com.cloud.network.Site2SiteCustomerGateway;
+import com.cloud.network.Site2SiteVpnConnection;
+import com.cloud.network.Site2SiteVpnGateway;
+import com.cloud.network.VirtualRouterProvider;
+import com.cloud.network.VpnUser;
+import com.cloud.network.as.AutoScalePolicy;
+import com.cloud.network.as.AutoScaleVmGroup;
+import com.cloud.network.as.AutoScaleVmProfile;
+import com.cloud.network.as.Condition;
+import com.cloud.network.as.Counter;
import com.cloud.network.router.VirtualRouter;
import com.cloud.network.rules.FirewallRule;
import com.cloud.network.rules.HealthCheckPolicy;
@@ -132,10 +79,6 @@ import com.cloud.network.rules.StaticNatRule;
import com.cloud.network.rules.StickinessPolicy;
import com.cloud.network.security.SecurityGroup;
import com.cloud.network.security.SecurityRule;
-import com.cloud.network.vpc.PrivateGateway;
-import com.cloud.network.vpc.StaticRoute;
-import com.cloud.network.vpc.Vpc;
-import com.cloud.network.vpc.VpcOffering;
import com.cloud.offering.DiskOffering;
import com.cloud.offering.NetworkOffering;
import com.cloud.offering.ServiceOffering;
@@ -145,7 +88,13 @@ import com.cloud.projects.ProjectAccount;
import com.cloud.projects.ProjectInvitation;
import com.cloud.region.ha.GlobalLoadBalancerRule;
import com.cloud.server.ResourceTag;
-import com.cloud.storage.*;
+import com.cloud.storage.GuestOS;
+import com.cloud.storage.ImageStore;
+import com.cloud.storage.S3;
+import com.cloud.storage.Snapshot;
+import com.cloud.storage.StoragePool;
+import com.cloud.storage.Swift;
+import com.cloud.storage.Volume;
import com.cloud.storage.snapshot.SnapshotPolicy;
import com.cloud.storage.snapshot.SnapshotSchedule;
import com.cloud.template.VirtualMachineTemplate;
@@ -153,11 +102,12 @@ import com.cloud.user.Account;
import com.cloud.user.User;
import com.cloud.user.UserAccount;
import com.cloud.uservm.UserVm;
+import com.cloud.utils.net.Ip;
import com.cloud.vm.InstanceGroup;
import com.cloud.vm.Nic;
-import com.cloud.vm.snapshot.VMSnapshot;
+import com.cloud.vm.NicSecondaryIp;
import com.cloud.vm.VirtualMachine;
-import org.apache.cloudstack.api.response.*;
+import com.cloud.vm.snapshot.VMSnapshot;
public interface ResponseGenerator {
UserResponse createUserResponse(UserAccount user);
@@ -357,11 +307,17 @@ public interface ResponseGenerator {
*/
VpcResponse createVpcResponse(Vpc vpc);
+ /**
+ * @param networkACLItem
+ * @return
+ */
+ NetworkACLItemResponse createNetworkACLItemResponse(NetworkACLItem networkACLItem);
+
/**
* @param networkACL
* @return
*/
- NetworkACLResponse createNetworkACLResponse(FirewallRule networkACL);
+ NetworkACLResponse createNetworkACLResponse(NetworkACL networkACL);
/**
* @param result
@@ -401,9 +357,13 @@ public interface ResponseGenerator {
NicSecondaryIpResponse createSecondaryIPToNicResponse(NicSecondaryIp result);
public NicResponse createNicResponse(Nic result);
+ ApplicationLoadBalancerResponse createLoadBalancerContainerReponse(ApplicationLoadBalancerRule lb, Map lbInstances);
+
AffinityGroupResponse createAffinityGroupResponse(AffinityGroup group);
Long getAffinityGroupId(String name, long entityOwnerId);
+ InternalLoadBalancerElementResponse createInternalLbElementResponse(VirtualRouterProvider result);
+
IsolationMethodResponse createIsolationMethodResponse(IsolationType method);
}
diff --git a/api/src/org/apache/cloudstack/api/command/admin/internallb/ConfigureInternalLoadBalancerElementCmd.java b/api/src/org/apache/cloudstack/api/command/admin/internallb/ConfigureInternalLoadBalancerElementCmd.java
new file mode 100644
index 00000000000..7c3d1e95e57
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/internallb/ConfigureInternalLoadBalancerElementCmd.java
@@ -0,0 +1,114 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.cloudstack.api.command.admin.internallb;
+
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse;
+import org.apache.cloudstack.network.element.InternalLoadBalancerElementService;
+import org.apache.log4j.Logger;
+
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.VirtualRouterProvider;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+@APICommand(name = "configureInternalLoadBalancerElement", responseObject=InternalLoadBalancerElementResponse.class,
+ description="Configures an Internal Load Balancer element.", since="4.2.0")
+public class ConfigureInternalLoadBalancerElementCmd extends BaseAsyncCmd {
+ public static final Logger s_logger = Logger.getLogger(ConfigureInternalLoadBalancerElementCmd.class.getName());
+ private static final String s_name = "configureinternalloadbalancerelementresponse";
+
+ @Inject
+ private List _service;
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = InternalLoadBalancerElementResponse.class,
+ required=true, description="the ID of the internal lb provider")
+ private Long id;
+
+ @Parameter(name=ApiConstants.ENABLED, type=CommandType.BOOLEAN, required=true, description="Enables/Disables the Internal Load Balancer element")
+ private Boolean enabled;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+
+ public Long getId() {
+ return id;
+ }
+
+ public Boolean getEnabled() {
+ return enabled;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+
+ @Override
+ public String getEventType() {
+ return EventTypes.EVENT_NETWORK_ELEMENT_CONFIGURE;
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "configuring internal load balancer element: " + id;
+ }
+
+ @Override
+ public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
+ s_logger.debug("hello alena");
+ UserContext.current().setEventDetails("Internal load balancer element: " + id);
+ s_logger.debug("hello alena");
+ VirtualRouterProvider result = _service.get(0).configureInternalLoadBalancerElement(getId(), getEnabled());
+ s_logger.debug("hello alena");
+ if (result != null){
+ InternalLoadBalancerElementResponse routerResponse = _responseGenerator.createInternalLbElementResponse(result);
+ routerResponse.setResponseName(getCommandName());
+ this.setResponseObject(routerResponse);
+ } else {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to configure the internal load balancer element");
+ }
+ }
+}
diff --git a/api/src/org/apache/cloudstack/api/command/admin/internallb/CreateInternalLoadBalancerElementCmd.java b/api/src/org/apache/cloudstack/api/command/admin/internallb/CreateInternalLoadBalancerElementCmd.java
new file mode 100644
index 00000000000..2902f7ae18a
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/internallb/CreateInternalLoadBalancerElementCmd.java
@@ -0,0 +1,116 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.internallb;
+
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCreateCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse;
+import org.apache.cloudstack.api.response.ProviderResponse;
+import org.apache.cloudstack.network.element.InternalLoadBalancerElementService;
+import org.apache.log4j.Logger;
+
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.network.VirtualRouterProvider;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+@APICommand(name = "createInternalLoadBalancerElement", responseObject=InternalLoadBalancerElementResponse.class, description="Create an Internal Load Balancer element.",since="4.2.0")
+public class CreateInternalLoadBalancerElementCmd extends BaseAsyncCreateCmd {
+ public static final Logger s_logger = Logger.getLogger(CreateInternalLoadBalancerElementCmd.class.getName());
+ private static final String s_name = "createinternalloadbalancerelementresponse";
+
+ @Inject
+ private List _service;
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.NETWORK_SERVICE_PROVIDER_ID, type=CommandType.UUID, entityType = ProviderResponse.class, required=true, description="the network service provider ID of the internal load balancer element")
+ private Long nspId;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public void setNspId(Long nspId) {
+ this.nspId = nspId;
+ }
+
+ public Long getNspId() {
+ return nspId;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+
+ @Override
+ public void execute(){
+ UserContext.current().setEventDetails("Virtual router element Id: "+getEntityId());
+ VirtualRouterProvider result = _service.get(0).getInternalLoadBalancerElement(getEntityId());
+ if (result != null) {
+ InternalLoadBalancerElementResponse response = _responseGenerator.createInternalLbElementResponse(result);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ }else {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Virtual Router entity to physical network");
+ }
+ }
+
+ @Override
+ public void create() throws ResourceAllocationException {
+ VirtualRouterProvider result = _service.get(0).addInternalLoadBalancerElement(getNspId());
+ if (result != null) {
+ setEntityId(result.getId());
+ setEntityUuid(result.getUuid());
+ } else {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Internal Load Balancer entity to physical network");
+ }
+ }
+
+ @Override
+ public String getEventType() {
+ return EventTypes.EVENT_SERVICE_PROVIDER_CREATE;
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "Adding physical network element Internal Load Balancer: " + getEntityId();
+ }
+}
diff --git a/api/src/org/apache/cloudstack/api/command/admin/internallb/ListInternalLBVMsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/internallb/ListInternalLBVMsCmd.java
new file mode 100644
index 00000000000..e314b3245c7
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/internallb/ListInternalLBVMsCmd.java
@@ -0,0 +1,151 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.internallb;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.response.DomainRouterResponse;
+import org.apache.cloudstack.api.response.HostResponse;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.NetworkResponse;
+import org.apache.cloudstack.api.response.PodResponse;
+import org.apache.cloudstack.api.response.UserVmResponse;
+import org.apache.cloudstack.api.response.VpcResponse;
+import org.apache.cloudstack.api.response.ZoneResponse;
+import org.apache.log4j.Logger;
+
+import com.cloud.async.AsyncJob;
+import com.cloud.network.router.VirtualRouter.Role;
+
+@APICommand(name = "listInternalLoadBalancerVMs", description="List internal LB VMs.", responseObject=DomainRouterResponse.class)
+public class ListInternalLBVMsCmd extends BaseListProjectAndAccountResourcesCmd {
+ public static final Logger s_logger = Logger.getLogger(ListInternalLBVMsCmd.class.getName());
+
+ private static final String s_name = "listinternallbvmssresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.HOST_ID, type=CommandType.UUID, entityType=HostResponse.class,
+ description="the host ID of the Internal LB VM")
+ private Long hostId;
+
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=UserVmResponse.class,
+ description="the ID of the Internal LB VM")
+ private Long id;
+
+ @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the Internal LB VM")
+ private String routerName;
+
+ @Parameter(name=ApiConstants.POD_ID, type=CommandType.UUID, entityType=PodResponse.class,
+ description="the Pod ID of the Internal LB VM")
+ private Long podId;
+
+ @Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="the state of the Internal LB VM")
+ private String state;
+
+ @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType=ZoneResponse.class,
+ description="the Zone ID of the Internal LB VM")
+ private Long zoneId;
+
+ @Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.UUID, entityType=NetworkResponse.class,
+ description="list by network id")
+ private Long networkId;
+
+ @Parameter(name=ApiConstants.VPC_ID, type=CommandType.UUID, entityType=VpcResponse.class,
+ description="List Internal LB VMs by VPC")
+ private Long vpcId;
+
+ @Parameter(name=ApiConstants.FOR_VPC, type=CommandType.BOOLEAN, description="if true is passed for this parameter, list only VPC Internal LB VMs")
+ private Boolean forVpc;
+
+ @Parameter(name=ApiConstants.ZONE_TYPE, type=CommandType.STRING, description="the network type of the zone that the virtual machine belongs to")
+ private String zoneType;
+
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getHostId() {
+ return hostId;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public String getRouterName() {
+ return routerName;
+ }
+
+ public Long getPodId() {
+ return podId;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public Long getZoneId() {
+ return zoneId;
+ }
+
+ public Long getNetworkId() {
+ return networkId;
+ }
+
+ public Long getVpcId() {
+ return vpcId;
+ }
+
+ public Boolean getForVpc() {
+ return forVpc;
+ }
+
+ public String getRole() {
+ return Role.INTERNAL_LB_VM.toString();
+ }
+
+ public String getZoneType() {
+ return zoneType;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public AsyncJob.Type getInstanceType() {
+ return AsyncJob.Type.DomainRouter;
+ }
+
+ @Override
+ public void execute(){
+ ListResponse response = _queryService.searchForInternalLbVms(this);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ }
+}
diff --git a/api/src/org/apache/cloudstack/api/command/admin/internallb/ListInternalLoadBalancerElementsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/internallb/ListInternalLoadBalancerElementsCmd.java
new file mode 100644
index 00000000000..18536191995
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/internallb/ListInternalLoadBalancerElementsCmd.java
@@ -0,0 +1,99 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.internallb;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseListCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.ProviderResponse;
+import org.apache.cloudstack.network.element.InternalLoadBalancerElementService;
+import org.apache.log4j.Logger;
+
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.VirtualRouterProvider;
+
+@APICommand(name = "listInternalLoadBalancerElements", description="Lists all available Internal Load Balancer elements.",
+ responseObject=InternalLoadBalancerElementResponse.class, since="4.2.0")
+public class ListInternalLoadBalancerElementsCmd extends BaseListCmd {
+ public static final Logger s_logger = Logger.getLogger(ListInternalLoadBalancerElementsCmd.class.getName());
+ private static final String _name = "listinternalloadbalancerelementsresponse";
+
+ @Inject
+ private InternalLoadBalancerElementService _service;
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = InternalLoadBalancerElementResponse.class,
+ description="list internal load balancer elements by id")
+ private Long id;
+
+ @Parameter(name=ApiConstants.NSP_ID, type=CommandType.UUID, entityType = ProviderResponse.class,
+ description="list internal load balancer elements by network service provider id")
+ private Long nspId;
+
+ @Parameter(name=ApiConstants.ENABLED, type=CommandType.BOOLEAN, description="list internal load balancer elements by enabled state")
+ private Boolean enabled;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getId() {
+ return id;
+ }
+
+ public Long getNspId() {
+ return nspId;
+ }
+
+ public Boolean getEnabled() {
+ return enabled;
+ }
+
+ @Override
+ public String getCommandName() {
+ return _name;
+ }
+
+ @Override
+ public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
+ List extends VirtualRouterProvider> providers = _service.searchForInternalLoadBalancerElements(getId(), getNspId(), getEnabled());
+ ListResponse response = new ListResponse();
+ List providerResponses = new ArrayList();
+ for (VirtualRouterProvider provider : providers) {
+ InternalLoadBalancerElementResponse providerResponse = _responseGenerator.createInternalLbElementResponse(provider);
+ providerResponses.add(providerResponse);
+ }
+ response.setResponses(providerResponses);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+
+ }
+}
diff --git a/api/src/org/apache/cloudstack/api/command/admin/internallb/StartInternalLBVMCmd.java b/api/src/org/apache/cloudstack/api/command/admin/internallb/StartInternalLBVMCmd.java
new file mode 100644
index 00000000000..31d132b5c9c
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/internallb/StartInternalLBVMCmd.java
@@ -0,0 +1,120 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.internallb;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.DomainRouterResponse;
+import org.apache.log4j.Logger;
+
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.router.VirtualRouter;
+import com.cloud.network.router.VirtualRouter.Role;
+import com.cloud.user.UserContext;
+
+@APICommand(name = "startInternalLoadBalancerVM", responseObject=DomainRouterResponse.class, description="Starts an existing internal lb vm.")
+public class StartInternalLBVMCmd extends BaseAsyncCmd {
+ public static final Logger s_logger = Logger.getLogger(StartInternalLBVMCmd.class.getName());
+ private static final String s_name = "startinternallbvmresponse";
+
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=DomainRouterResponse.class,
+ required=true, description="the ID of the internal lb vm")
+ private Long id;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getId() {
+ return id;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ public static String getResultObjectName() {
+ return "router";
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ VirtualRouter router = _entityMgr.findById(VirtualRouter.class, getId());
+ if (router != null && router.getRole() == Role.INTERNAL_LB_VM) {
+ return router.getAccountId();
+ } else {
+ throw new InvalidParameterValueException("Unable to find internal lb vm by id");
+ }
+ }
+
+ @Override
+ public String getEventType() {
+ return EventTypes.EVENT_INTERNAL_LB_VM_START;
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "starting internal lb vm: " + getId();
+ }
+
+ public AsyncJob.Type getInstanceType() {
+ return AsyncJob.Type.InternalLbVm;
+ }
+
+ public Long getInstanceId() {
+ return getId();
+ }
+
+ @Override
+ public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
+ UserContext.current().setEventDetails("Internal Lb Vm Id: "+getId());
+ VirtualRouter result = null;
+ VirtualRouter router = _routerService.findRouter(getId());
+ if (router == null || router.getRole() != Role.INTERNAL_LB_VM) {
+ throw new InvalidParameterValueException("Can't find internal lb vm by id");
+ } else {
+ result = _internalLbSvc.startInternalLbVm(getId(), UserContext.current().getCaller(), UserContext.current().getCallerUserId());
+ }
+
+ if (result != null){
+ DomainRouterResponse routerResponse = _responseGenerator.createDomainRouterResponse(result);
+ routerResponse.setResponseName(getCommandName());
+ this.setResponseObject(routerResponse);
+ } else {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to start internal lb vm");
+ }
+ }
+}
diff --git a/api/src/org/apache/cloudstack/api/command/admin/internallb/StopInternalLBVMCmd.java b/api/src/org/apache/cloudstack/api/command/admin/internallb/StopInternalLBVMCmd.java
new file mode 100644
index 00000000000..f40db49b417
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/internallb/StopInternalLBVMCmd.java
@@ -0,0 +1,123 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.internallb;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.DomainRouterResponse;
+import org.apache.log4j.Logger;
+
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.router.VirtualRouter;
+import com.cloud.network.router.VirtualRouter.Role;
+import com.cloud.user.UserContext;
+
+@APICommand(name = "stopInternalLoadBalancerVM", description = "Stops an Internal LB vm.", responseObject = DomainRouterResponse.class)
+public class StopInternalLBVMCmd extends BaseAsyncCmd {
+ public static final Logger s_logger = Logger.getLogger(StopInternalLBVMCmd.class.getName());
+ private static final String s_name = "stopinternallbvmresponse";
+
+ // ///////////////////////////////////////////////////
+ // ////////////// API parameters /////////////////////
+ // ///////////////////////////////////////////////////
+
+ @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = DomainRouterResponse.class,
+ required = true, description = "the ID of the internal lb vm")
+ private Long id;
+
+ @Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, required = false, description = "Force stop the VM. The caller knows the VM is stopped.")
+ private Boolean forced;
+
+ // ///////////////////////////////////////////////////
+ // ///////////////// Accessors ///////////////////////
+ // ///////////////////////////////////////////////////
+
+ public Long getId() {
+ return id;
+ }
+
+ // ///////////////////////////////////////////////////
+ // ///////////// API Implementation///////////////////
+ // ///////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ VirtualRouter vm = _entityMgr.findById(VirtualRouter.class, getId());
+ if (vm != null && vm.getRole() == Role.INTERNAL_LB_VM) {
+ return vm.getAccountId();
+ } else {
+ throw new InvalidParameterValueException("Unable to find internal lb vm by id");
+ }
+ }
+
+ @Override
+ public String getEventType() {
+ return EventTypes.EVENT_INTERNAL_LB_VM_STOP;
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "stopping internal lb vm: " + getId();
+ }
+
+ @Override
+ public AsyncJob.Type getInstanceType() {
+ return AsyncJob.Type.InternalLbVm;
+ }
+
+ @Override
+ public Long getInstanceId() {
+ return getId();
+ }
+
+ public boolean isForced() {
+ return (forced != null) ? forced : false;
+ }
+
+ @Override
+ public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
+ UserContext.current().setEventDetails("Internal lb vm Id: "+getId());
+ VirtualRouter result = null;
+ VirtualRouter vm = _routerService.findRouter(getId());
+ if (vm == null || vm.getRole() != Role.INTERNAL_LB_VM) {
+ throw new InvalidParameterValueException("Can't find internal lb vm by id");
+ } else {
+ result = _internalLbSvc.stopInternalLbVm(getId(), isForced(), UserContext.current().getCaller(), UserContext.current().getCallerUserId());
+ }
+
+ if (result != null) {
+ DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to stop internal lb vm");
+ }
+ }
+}
diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/CreateNetworkOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/CreateNetworkOfferingCmd.java
index b48bf9e763e..6410715727c 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/network/CreateNetworkOfferingCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/network/CreateNetworkOfferingCmd.java
@@ -31,7 +31,6 @@ import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.NetworkOfferingResponse;
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
-
import org.apache.log4j.Logger;
import com.cloud.exception.InvalidParameterValueException;
@@ -95,6 +94,10 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
@Parameter(name=ApiConstants.IS_PERSISTENT, type=CommandType.BOOLEAN, description="true if network offering supports persistent networks; defaulted to false if not specified")
private Boolean isPersistent;
+
+ @Parameter(name=ApiConstants.DETAILS, type=CommandType.MAP, since="4.2.0", description="Template details in key/value pairs." +
+ " Supported keys are internallbprovider/publiclbprovider with service provider as a value")
+ protected Map details;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@@ -215,6 +218,16 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
return capabilityMap;
}
+
+ public Map getDetails() {
+ if (details == null || details.isEmpty()) {
+ return null;
+ }
+
+ Collection paramsCollection = details.values();
+ Map params = (Map) (paramsCollection.toArray())[0];
+ return params;
+ }
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
diff --git a/api/src/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java
index 68d5dd466a3..aa11599a69e 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java
@@ -62,7 +62,10 @@ public class CreateDiskOfferingCmd extends BaseCmd {
@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();
- /////////////////////////////////////////////////////
+ @Parameter(name=ApiConstants.DISPLAY_OFFERING, type=CommandType.BOOLEAN, description="an optional field, whether to display the offering to the end user or not.")
+ private Boolean displayOffering;
+
+/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@@ -94,6 +97,10 @@ public class CreateDiskOfferingCmd extends BaseCmd {
return storageType;
}
+ public Boolean getDisplayOffering() {
+ return displayOffering;
+ }
+
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/CreateVirtualRouterElementCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/CreateVirtualRouterElementCmd.java
index 39fac136233..b3fca5addf1 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/router/CreateVirtualRouterElementCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/router/CreateVirtualRouterElementCmd.java
@@ -31,6 +31,7 @@ import org.apache.cloudstack.api.response.VirtualRouterProviderResponse;
import org.apache.log4j.Logger;
import com.cloud.event.EventTypes;
+import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.network.VirtualRouterProvider;
import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
@@ -52,6 +53,9 @@ public class CreateVirtualRouterElementCmd extends BaseAsyncCreateCmd {
@Parameter(name=ApiConstants.NETWORK_SERVICE_PROVIDER_ID, type=CommandType.UUID, entityType = ProviderResponse.class, required=true, description="the network service provider ID of the virtual router element")
private Long nspId;
+
+ @Parameter(name=ApiConstants.PROVIDER_TYPE, type=CommandType.UUID, entityType = ProviderResponse.class, description="The provider type. Supported types are VirtualRouter (default) and VPCVirtualRouter")
+ private String providerType;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@@ -61,16 +65,27 @@ public class CreateVirtualRouterElementCmd extends BaseAsyncCreateCmd {
this.nspId = nspId;
}
-
-
public Long getNspId() {
return nspId;
}
+
+ public VirtualRouterProviderType getProviderType() {
+ if (providerType != null) {
+ if (providerType.equalsIgnoreCase(VirtualRouterProviderType.VirtualRouter.toString())) {
+ return VirtualRouterProviderType.VirtualRouter;
+ } else if (providerType.equalsIgnoreCase(VirtualRouterProviderType.VPCVirtualRouter.toString())) {
+ return VirtualRouterProviderType.VPCVirtualRouter;
+ } else throw new InvalidParameterValueException("Invalid providerType specified");
+ }
+ return VirtualRouterProviderType.VirtualRouter;
+ }
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
+
+
@Override
public String getCommandName() {
return s_name;
@@ -96,7 +111,7 @@ public class CreateVirtualRouterElementCmd extends BaseAsyncCreateCmd {
@Override
public void create() throws ResourceAllocationException {
- VirtualRouterProvider result = _service.get(0).addElement(getNspId(), VirtualRouterProviderType.VirtualRouter);
+ VirtualRouterProvider result = _service.get(0).addElement(getNspId(), getProviderType());
if (result != null) {
setEntityId(result.getId());
setEntityUuid(result.getUuid());
diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/ListRoutersCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/ListRoutersCmd.java
index 9fbc9401532..78c3554ae73 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/router/ListRoutersCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/router/ListRoutersCmd.java
@@ -31,6 +31,7 @@ import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.log4j.Logger;
import com.cloud.async.AsyncJob;
+import com.cloud.network.router.VirtualRouter.Role;
@APICommand(name = "listRouters", description="List routers.", responseObject=DomainRouterResponse.class)
public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd {
@@ -77,7 +78,7 @@ public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd {
@Parameter(name=ApiConstants.FOR_VPC, type=CommandType.BOOLEAN, description="if true is passed for this parameter, list only VPC routers")
private Boolean forVpc;
-
+
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@@ -121,6 +122,10 @@ public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd {
public Boolean getForVpc() {
return forVpc;
}
+
+ public String getRole() {
+ return Role.VIRTUAL_ROUTER.toString();
+ }
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/StartRouterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/StartRouterCmd.java
index 1d3930b6b63..ad0461e0eb7 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/router/StartRouterCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/router/StartRouterCmd.java
@@ -29,8 +29,10 @@ import com.cloud.async.AsyncJob;
import com.cloud.event.EventTypes;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.router.VirtualRouter;
+import com.cloud.network.router.VirtualRouter.Role;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
@@ -100,7 +102,13 @@ public class StartRouterCmd extends BaseAsyncCmd {
@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
UserContext.current().setEventDetails("Router Id: "+getId());
- VirtualRouter result = _routerService.startRouter(id);
+ VirtualRouter result = null;
+ VirtualRouter router = _routerService.findRouter(getId());
+ if (router == null || router.getRole() != Role.VIRTUAL_ROUTER) {
+ throw new InvalidParameterValueException("Can't find router by id");
+ } else {
+ result = _routerService.startRouter(getId());
+ }
if (result != null){
DomainRouterResponse routerResponse = _responseGenerator.createDomainRouterResponse(result);
routerResponse.setResponseName(getCommandName());
diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/StopRouterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/StopRouterCmd.java
index 60dd9386c75..94473cf9ffc 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/router/StopRouterCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/router/StopRouterCmd.java
@@ -28,8 +28,10 @@ import org.apache.log4j.Logger;
import com.cloud.async.AsyncJob;
import com.cloud.event.EventTypes;
import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.router.VirtualRouter;
+import com.cloud.network.router.VirtualRouter.Role;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
@@ -103,7 +105,14 @@ public class StopRouterCmd extends BaseAsyncCmd {
@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
UserContext.current().setEventDetails("Router Id: "+getId());
- VirtualRouter result = _routerService.stopRouter(getId(), isForced());
+ VirtualRouter result = null;
+ VirtualRouter router = _routerService.findRouter(getId());
+ if (router == null || router.getRole() != Role.VIRTUAL_ROUTER) {
+ throw new InvalidParameterValueException("Can't find router by id");
+ } else {
+ result = _routerService.stopRouter(getId(), isForced());
+ }
+
if (result != null) {
DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);
response.setResponseName(getCommandName());
diff --git a/api/src/org/apache/cloudstack/api/command/admin/vpc/CreatePrivateGatewayCmd.java b/api/src/org/apache/cloudstack/api/command/admin/vpc/CreatePrivateGatewayCmd.java
index 20556957ff2..22dfb9e2acc 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/vpc/CreatePrivateGatewayCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/vpc/CreatePrivateGatewayCmd.java
@@ -23,6 +23,7 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.NetworkACLResponse;
import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
import org.apache.cloudstack.api.response.PrivateGatewayResponse;
import org.apache.cloudstack.api.response.VpcResponse;
@@ -74,6 +75,11 @@ public class CreatePrivateGatewayCmd extends BaseAsyncCreateCmd {
" 'false': sourcenat is not supported")
private Boolean isSourceNat;
+ @Parameter(name=ApiConstants.ACL_ID, type=CommandType.UUID, entityType = NetworkACLResponse.class,
+ required=false, description="the ID of the network ACL")
+ private Long aclId;
+
+
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@@ -106,9 +112,14 @@ public class CreatePrivateGatewayCmd extends BaseAsyncCreateCmd {
if (isSourceNat == null) {
return false;
}
- return true;
+ return isSourceNat;
}
+ public Long getAclId() {
+ return aclId;
+ }
+
+
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@@ -123,7 +134,7 @@ public class CreatePrivateGatewayCmd extends BaseAsyncCreateCmd {
PrivateGateway result = null;
try {
result = _vpcService.createVpcPrivateGateway(getVpcId(), getPhysicalNetworkId(),
- getVlan(), getStartIp(), getGateway(), getNetmask(), getEntityOwnerId(), getIsSourceNat());
+ getVlan(), getStartIp(), getGateway(), getNetmask(), getEntityOwnerId(), getIsSourceNat(), getAclId());
} catch (InsufficientCapacityException ex){
s_logger.info(ex);
s_logger.trace(ex);
diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateApplicationLoadBalancerCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateApplicationLoadBalancerCmd.java
new file mode 100644
index 00000000000..17ae959aa6e
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateApplicationLoadBalancerCmd.java
@@ -0,0 +1,218 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.loadbalancer;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCreateCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.ApplicationLoadBalancerResponse;
+import org.apache.cloudstack.api.response.NetworkResponse;
+import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
+import org.apache.log4j.Logger;
+
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.InsufficientAddressCapacityException;
+import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.Network;
+import com.cloud.network.rules.LoadBalancerContainer.Scheme;
+import com.cloud.user.UserContext;
+import com.cloud.utils.net.NetUtils;
+
+@APICommand(name = "createLoadBalancer", description="Creates a Load Balancer", responseObject=ApplicationLoadBalancerResponse.class, since="4.2.0")
+public class CreateApplicationLoadBalancerCmd extends BaseAsyncCreateCmd {
+ public static final Logger s_logger = Logger.getLogger(CreateApplicationLoadBalancerCmd.class.getName());
+
+ private static final String s_name = "createloadbalancerresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+ @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="name of the Load Balancer")
+ private String loadBalancerName;
+
+ @Parameter(name=ApiConstants.DESCRIPTION, type=CommandType.STRING, description="the description of the Load Balancer", length=4096)
+ private String description;
+
+ @Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.UUID, required=true, entityType = NetworkResponse.class,
+ description="The guest network the Load Balancer will be created for")
+ private Long networkId;
+
+ @Parameter(name=ApiConstants.SOURCE_PORT, type=CommandType.INTEGER, required=true, description="the source port the network traffic will be load balanced from")
+ private Integer sourcePort;
+
+ @Parameter(name=ApiConstants.ALGORITHM, type=CommandType.STRING, required=true, description="load balancer algorithm (source, roundrobin, leastconn)")
+ private String algorithm;
+
+ @Parameter(name=ApiConstants.INSTANCE_PORT, type=CommandType.INTEGER, required=true, description="the TCP port of the virtual machine where the network traffic will be load balanced to")
+ private Integer instancePort;
+
+ @Parameter(name=ApiConstants.SOURCE_IP, type=CommandType.STRING, description="the source ip address the network traffic will be load balanced from")
+ private String sourceIp;
+
+ @Parameter(name=ApiConstants.SOURCE_IP_NETWORK_ID, type=CommandType.UUID, entityType = NetworkResponse.class, required=true,
+ description="the network id of the source ip address")
+ private Long sourceIpNetworkId;
+
+ @Parameter(name=ApiConstants.SCHEME, type=CommandType.STRING, required=true, description="the load balancer scheme. Supported value in this release is Internal")
+ private String scheme;
+
+
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public String getAlgorithm() {
+ return algorithm;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getLoadBalancerName() {
+ return loadBalancerName;
+ }
+
+ public Integer getPrivatePort() {
+ return instancePort;
+ }
+
+ public long getNetworkId() {
+ return networkId;
+ }
+
+ public String getName() {
+ return loadBalancerName;
+ }
+
+ public Integer getSourcePort() {
+ return sourcePort.intValue();
+ }
+
+ public String getProtocol() {
+ return NetUtils.TCP_PROTO;
+ }
+
+ public long getAccountId() {
+ //get account info from the network object
+ Network ntwk = _networkService.getNetwork(networkId);
+ if (ntwk == null) {
+ throw new InvalidParameterValueException("Invalid network id specified");
+ }
+
+ return ntwk.getAccountId();
+
+ }
+
+ public int getInstancePort() {
+ return instancePort.intValue();
+ }
+
+ @Override
+ public String getEventType() {
+ return EventTypes.EVENT_LOAD_BALANCER_CREATE;
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "creating load balancer: " + getName() + " account: " + getAccountId();
+
+ }
+
+ @Override
+ public AsyncJob.Type getInstanceType() {
+ return AsyncJob.Type.LoadBalancerRule;
+ }
+
+ public String getSourceIp() {
+ return sourceIp;
+ }
+
+ public long getSourceIpNetworkId() {
+ return sourceIpNetworkId;
+ }
+
+ public Scheme getScheme() {
+ if (scheme.equalsIgnoreCase(Scheme.Internal.toString())) {
+ return Scheme.Internal;
+ } else {
+ throw new InvalidParameterValueException("Invalid value for scheme. Supported value is Internal");
+ }
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return getAccountId();
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public void execute() throws ResourceAllocationException, ResourceUnavailableException {
+ ApplicationLoadBalancerRule rule = null;
+ try {
+ UserContext.current().setEventDetails("Load Balancer Id: " + getEntityId());
+ // State might be different after the rule is applied, so get new object here
+ rule = _entityMgr.findById(ApplicationLoadBalancerRule.class, getEntityId());
+ ApplicationLoadBalancerResponse lbResponse = _responseGenerator.createLoadBalancerContainerReponse(rule, _lbService.getLbInstances(getEntityId()));
+ setResponseObject(lbResponse);
+ lbResponse.setResponseName(getCommandName());
+ } catch (Exception ex) {
+ s_logger.warn("Failed to create Load Balancer due to exception ", ex);
+ } finally {
+ if (rule == null) {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create Load Balancer");
+ }
+ }
+ }
+
+ @Override
+ public void create() {
+ try {
+
+ ApplicationLoadBalancerRule result = _appLbService.createApplicationLoadBalancer(getName(), getDescription(), getScheme(),
+ getSourceIpNetworkId(), getSourceIp(), getSourcePort(), getInstancePort(), getAlgorithm(), getNetworkId(), getEntityOwnerId());
+ this.setEntityId(result.getId());
+ this.setEntityUuid(result.getUuid());
+ }catch (NetworkRuleConflictException e) {
+ s_logger.warn("Exception: ", e);
+ throw new ServerApiException(ApiErrorCode.NETWORK_RULE_CONFLICT_ERROR, e.getMessage());
+ } catch (InsufficientAddressCapacityException e) {
+ s_logger.warn("Exception: ", e);
+ throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, e.getMessage());
+ } catch (InsufficientVirtualNetworkCapcityException e) {
+ s_logger.warn("Exception: ", e);
+ throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, e.getMessage());
+ }
+ }
+}
+
diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java
index 5f1d97b2803..f6cc1f130bd 100644
--- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java
@@ -148,7 +148,7 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements
}
- public Long getNetworkId() {
+ public long getNetworkId() {
if (networkId != null) {
return networkId;
}
@@ -278,7 +278,9 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements
throw new InvalidParameterValueException("Parameter cidrList is deprecated; if you need to open firewall rule for the specific cidr, please refer to createFirewallRule command");
}
try {
- LoadBalancer result = _lbService.createLoadBalancerRule(this, getOpenFirewall());
+ LoadBalancer result = _lbService.createPublicLoadBalancerRule(getXid(), getName(), getDescription(),
+ getSourcePortStart(), getSourcePortEnd(), getDefaultPortStart(), getDefaultPortEnd(), getSourceIpAddressId(), getProtocol(), getAlgorithm(),
+ getNetworkId(), getEntityOwnerId(), getOpenFirewall());
this.setEntityId(result.getId());
this.setEntityUuid(result.getUuid());
} catch (NetworkRuleConflictException e) {
diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteApplicationLoadBalancerCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteApplicationLoadBalancerCmd.java
new file mode 100644
index 00000000000..bc6cd09526c
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteApplicationLoadBalancerCmd.java
@@ -0,0 +1,116 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.loadbalancer;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.FirewallRuleResponse;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
+import org.apache.log4j.Logger;
+
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.user.UserContext;
+
+@APICommand(name = "deleteLoadBalancer", description="Deletes a load balancer", responseObject=SuccessResponse.class, since="4.2.0")
+public class DeleteApplicationLoadBalancerCmd extends BaseAsyncCmd {
+ public static final Logger s_logger = Logger.getLogger(DeleteApplicationLoadBalancerCmd.class.getName());
+ private static final String s_name = "deleteloadbalancerresponse";
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = FirewallRuleResponse.class,
+ required=true, description="the ID of the Load Balancer")
+ private Long id;
+
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getId() {
+ return id;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ ApplicationLoadBalancerRule lb = _entityMgr.findById(ApplicationLoadBalancerRule.class, getId());
+ if (lb != null) {
+ return lb.getAccountId();
+ } else {
+ throw new InvalidParameterValueException("Can't find load balancer by id specified");
+ }
+ }
+
+ @Override
+ public String getEventType() {
+ return EventTypes.EVENT_LOAD_BALANCER_DELETE;
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "deleting load balancer: " + getId();
+ }
+
+ @Override
+ public void execute(){
+ UserContext.current().setEventDetails("Load balancer Id: " + getId());
+ boolean result = _appLbService.deleteApplicationLoadBalancer(getId());
+
+ if (result) {
+ SuccessResponse response = new SuccessResponse(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete load balancer");
+ }
+ }
+
+ @Override
+ public String getSyncObjType() {
+ return BaseAsyncCmd.networkSyncObject;
+ }
+
+ @Override
+ public Long getSyncObjId() {
+ ApplicationLoadBalancerRule lb = _appLbService.getApplicationLoadBalancer(id);
+ if(lb == null){
+ throw new InvalidParameterValueException("Unable to find load balancer by id ");
+ }
+ return lb.getNetworkId();
+ }
+
+ @Override
+ public AsyncJob.Type getInstanceType() {
+ return AsyncJob.Type.FirewallRule;
+ }
+}
diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListApplicationLoadBalancersCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListApplicationLoadBalancersCmd.java
new file mode 100644
index 00000000000..8e5df31ed29
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListApplicationLoadBalancersCmd.java
@@ -0,0 +1,131 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.loadbalancer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseListTaggedResourcesCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.response.ApplicationLoadBalancerResponse;
+import org.apache.cloudstack.api.response.FirewallRuleResponse;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.NetworkResponse;
+import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
+import org.apache.log4j.Logger;
+
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.network.rules.LoadBalancerContainer.Scheme;
+import com.cloud.utils.Pair;
+
+@APICommand(name = "listLoadBalancers", description = "Lists Load Balancers", responseObject = ApplicationLoadBalancerResponse.class, since="4.2.0")
+public class ListApplicationLoadBalancersCmd extends BaseListTaggedResourcesCmd {
+ public static final Logger s_logger = Logger.getLogger(ListApplicationLoadBalancersCmd.class.getName());
+
+ private static final String s_name = "listloadbalancerssresponse";
+
+ // ///////////////////////////////////////////////////
+ // ////////////// API parameters /////////////////////
+ // ///////////////////////////////////////////////////
+
+ @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = FirewallRuleResponse.class,
+ description = "the ID of the Load Balancer")
+ private Long id;
+
+ @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "the name of the Load Balancer")
+ private String loadBalancerName;
+
+ @Parameter(name = ApiConstants.SOURCE_IP, type = CommandType.STRING, description = "the source ip address of the Load Balancer")
+ private String sourceIp;
+
+ @Parameter(name=ApiConstants.SOURCE_IP_NETWORK_ID, type=CommandType.UUID, entityType = NetworkResponse.class,
+ description="the network id of the source ip address")
+ private Long sourceIpNetworkId;
+
+ @Parameter(name = ApiConstants.SCHEME, type = CommandType.STRING, description = "the scheme of the Load Balancer. Supported value is Internal in the current release")
+ private String scheme;
+
+ @Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.UUID, entityType = NetworkResponse.class,
+ description="the network id of the Load Balancer")
+ private Long networkId;
+
+
+ // ///////////////////////////////////////////////////
+ // ///////////////// Accessors ///////////////////////
+ // ///////////////////////////////////////////////////
+
+ public Long getId() {
+ return id;
+ }
+
+ public String getLoadBalancerRuleName() {
+ return loadBalancerName;
+ }
+
+ public String getLoadBalancerName() {
+ return loadBalancerName;
+ }
+
+ public String getSourceIp() {
+ return sourceIp;
+ }
+
+ public Long getSourceIpNetworkId() {
+ return sourceIpNetworkId;
+ }
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ public Scheme getScheme() {
+ if (scheme != null) {
+ if (scheme.equalsIgnoreCase(Scheme.Internal.toString())) {
+ return Scheme.Internal;
+ } else {
+ throw new InvalidParameterValueException("Invalid value for scheme. Supported value is Internal");
+ }
+ }
+ return null;
+ }
+
+ public Long getNetworkId() {
+ return networkId;
+ }
+ // ///////////////////////////////////////////////////
+ // ///////////// API Implementation///////////////////
+ // ///////////////////////////////////////////////////
+
+ @Override
+ public void execute() {
+ Pair, Integer> loadBalancers = _appLbService.listApplicationLoadBalancers(this);
+ ListResponse response = new ListResponse();
+ List lbResponses = new ArrayList();
+ for (ApplicationLoadBalancerRule loadBalancer : loadBalancers.first()) {
+ ApplicationLoadBalancerResponse lbResponse = _responseGenerator.createLoadBalancerContainerReponse(loadBalancer, _lbService.getLbInstances(loadBalancer.getId()));
+ lbResponse.setObjectName("loadbalancer");
+ lbResponses.add(lbResponse);
+ }
+ response.setResponses(lbResponses, loadBalancers.second());
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ }
+
+}
diff --git a/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLCmd.java
index 2e307018eed..275fa1866b6 100644
--- a/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLCmd.java
@@ -19,6 +19,8 @@ package org.apache.cloudstack.api.command.user.network;
import java.util.ArrayList;
import java.util.List;
+import com.cloud.network.vpc.NetworkACL;
+import com.cloud.network.vpc.NetworkACLItem;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
@@ -26,6 +28,7 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.NetworkACLItemResponse;
import org.apache.cloudstack.api.response.NetworkACLResponse;
import org.apache.cloudstack.api.response.NetworkResponse;
import org.apache.log4j.Logger;
@@ -36,15 +39,14 @@ import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.Network;
-import com.cloud.network.rules.FirewallRule;
import com.cloud.network.vpc.Vpc;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
import com.cloud.utils.net.NetUtils;
-@APICommand(name = "createNetworkACL", 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 {
+@APICommand(name = "createNetworkACL", description = "Creates a ACL rule in the given network (the network has to belong to VPC)",
+responseObject = NetworkACLItemResponse.class)
+public class CreateNetworkACLCmd extends BaseAsyncCreateCmd {
public static final Logger s_logger = Logger.getLogger(CreateNetworkACLCmd.class.getName());
private static final String s_name = "createnetworkaclresponse";
@@ -54,7 +56,7 @@ public class CreateNetworkACLCmd extends BaseAsyncCreateCmd implements FirewallR
// ///////////////////////////////////////////////////
@Parameter(name = ApiConstants.PROTOCOL, type = CommandType.STRING, required = true, description =
- "the protocol for the ACL rule. Valid values are TCP/UDP/ICMP.")
+ "the protocol for the ACL rule. Valid values are TCP/UDP/ICMP/ALL or valid protocol number")
private String protocol;
@Parameter(name = ApiConstants.START_PORT, type = CommandType.INTEGER, description = "the starting port of ACL")
@@ -74,23 +76,27 @@ public class CreateNetworkACLCmd extends BaseAsyncCreateCmd implements FirewallR
private Integer icmpCode;
@Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.UUID, entityType = NetworkResponse.class,
- required=true,
description="The network of the vm the ACL will be created for")
private Long networkId;
+ @Parameter(name=ApiConstants.ACL_ID, type=CommandType.UUID, entityType = NetworkACLResponse.class,
+ description="The network of the vm the ACL will be created for")
+ private Long aclId;
+
@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")
private String trafficType;
+ @Parameter(name=ApiConstants.NUMBER, type=CommandType.INTEGER, description="The network of the vm the ACL will be created for")
+ private Integer number;
+
+ @Parameter(name=ApiConstants.ACTION, type=CommandType.STRING, description="scl entry action, allow or deny")
+ private String action;
+
// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
- public Long getIpAddressId() {
- return null;
- }
-
- @Override
public String getProtocol() {
return protocol.trim();
}
@@ -105,26 +111,11 @@ public class CreateNetworkACLCmd extends BaseAsyncCreateCmd implements FirewallR
}
}
- 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() {
+ public NetworkACLItem.TrafficType getTrafficType() {
if (trafficType == null) {
- return FirewallRule.TrafficType.Ingress;
+ return NetworkACLItem.TrafficType.Ingress;
}
- for (FirewallRule.TrafficType type : FirewallRule.TrafficType.values()) {
+ for (NetworkACLItem.TrafficType type : NetworkACLItem.TrafficType.values()) {
if (type.toString().equalsIgnoreCase(trafficType)) {
return type;
}
@@ -141,192 +132,103 @@ public class CreateNetworkACLCmd extends BaseAsyncCreateCmd implements FirewallR
return s_name;
}
- public void setSourceCidrList(List cidrs){
- cidrlist = cidrs;
+ public String getAction() {
+ return action;
}
- @Override
- public void execute() throws ResourceUnavailableException {
- UserContext callerContext = UserContext.current();
- boolean success = false;
- FirewallRule rule = _networkACLService.getNetworkACL(getEntityId());
- try {
- UserContext.current().setEventDetails("Rule Id: " + getEntityId());
- success = _networkACLService.applyNetworkACLs(rule.getNetworkId(), callerContext.getCaller());
-
- // State is different after the rule is applied, so get new object here
- NetworkACLResponse aclResponse = new NetworkACLResponse();
- if (rule != null) {
- aclResponse = _responseGenerator.createNetworkACLResponse(rule);
- setResponseObject(aclResponse);
- }
- aclResponse.setResponseName(getCommandName());
- } finally {
- if (!success || rule == null) {
- _networkACLService.revokeNetworkACL(getEntityId(), true);
- throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create network ACL");
- }
- }
+ public Integer getNumber() {
+ return number;
}
- @Override
- public long getId() {
- throw new UnsupportedOperationException("database id can only provided by VO objects");
- }
-
- @Override
- public String getXid() {
- // FIXME: We should allow for end user to specify Xid.
- return null;
- }
-
-
- @Override
- public String getUuid() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Long getSourceIpAddressId() {
- return null;
- }
-
- @Override
public Integer getSourcePortStart() {
- if (publicStartPort != null) {
- return publicStartPort.intValue();
- }
- return null;
+ return publicStartPort;
}
- @Override
public Integer getSourcePortEnd() {
if (publicEndPort == null) {
if (publicStartPort != null) {
- return publicStartPort.intValue();
+ return publicStartPort;
}
} else {
- return publicEndPort.intValue();
+ return publicEndPort;
}
return null;
}
- @Override
- public Purpose getPurpose() {
- return Purpose.Firewall;
- }
-
- @Override
- public State getState() {
- throw new UnsupportedOperationException("Should never call me to find the state");
- }
-
- @Override
- public long getNetworkId() {
+ public Long getNetworkId() {
return networkId;
}
@Override
public long getEntityOwnerId() {
- Vpc vpc = _vpcService.getVpc(getVpcId());
- if (vpc == null) {
- throw new InvalidParameterValueException("Invalid vpcId is given");
- }
-
- Account account = _accountService.getAccount(vpc.getAccountId());
- return account.getId();
- }
-
- @Override
- public long getDomainId() {
- Vpc vpc = _vpcService.getVpc(getVpcId());
- return vpc.getDomainId();
- }
-
- @Override
- public void create() {
- if (getSourceCidrList() != null) {
- for (String cidr: getSourceCidrList()){
- if (!NetUtils.isValidCIDR(cidr)){
- throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Source cidrs formatting error " + cidr);
- }
- }
- }
-
- try {
- FirewallRule result = _networkACLService.createNetworkACL(this);
- setEntityId(result.getId());
- setEntityUuid(result.getUuid());
- } catch (NetworkRuleConflictException ex) {
- s_logger.info("Network rule conflict: " + ex.getMessage());
- s_logger.trace("Network Rule Conflict: ", ex);
- throw new ServerApiException(ApiErrorCode.NETWORK_RULE_CONFLICT_ERROR, ex.getMessage());
- }
+ Account caller = UserContext.current().getCaller();
+ return caller.getAccountId();
}
@Override
public String getEventType() {
- return EventTypes.EVENT_FIREWALL_OPEN;
+ return EventTypes.EVENT_NETWORK_ACL_ITEM_CREATE;
}
@Override
public String getEventDescription() {
- Network network = _networkService.getNetwork(networkId);
- return ("Createing Network ACL for Netowrk: " + network + " for protocol:" + this.getProtocol());
+ return "Creating Network ACL Item";
}
- @Override
- public long getAccountId() {
- Vpc vpc = _vpcService.getVpc(getVpcId());
- return vpc.getAccountId();
- }
-
- @Override
- public String getSyncObjType() {
- return BaseAsyncCmd.networkSyncObject;
- }
-
- @Override
- public Long getSyncObjId() {
- return getNetworkId();
- }
-
- @Override
public Integer getIcmpCode() {
if (icmpCode != null) {
return icmpCode;
- } else if (protocol.equalsIgnoreCase(NetUtils.ICMP_PROTO)) {
+ } else if (getProtocol().equalsIgnoreCase(NetUtils.ICMP_PROTO)) {
return -1;
}
return null;
}
- @Override
public Integer getIcmpType() {
if (icmpType != null) {
return icmpType;
- } else if (protocol.equalsIgnoreCase(NetUtils.ICMP_PROTO)) {
+ } else if (getProtocol().equalsIgnoreCase(NetUtils.ICMP_PROTO)) {
return -1;
}
return null;
}
- @Override
- public Long getRelated() {
- return null;
+ public Long getACLId() {
+ return aclId;
}
@Override
- public FirewallRuleType getType() {
- return FirewallRuleType.User;
+ public void create() {
+ NetworkACLItem result = _networkACLService.createNetworkACLItem(this);
+ setEntityId(result.getId());
+ setEntityUuid(result.getUuid());
}
@Override
- public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.FirewallRule;
+ public void execute() throws ResourceUnavailableException {
+ boolean success = false;
+ NetworkACLItem rule = _networkACLService.getNetworkACLItem(getEntityId());
+ try {
+ UserContext.current().setEventDetails("Rule Id: " + getEntityId());
+ success = _networkACLService.applyNetworkACL(rule.getAclId());
+
+ // State is different after the rule is applied, so get new object here
+ rule = _networkACLService.getNetworkACLItem(getEntityId());
+ NetworkACLItemResponse aclResponse = new NetworkACLItemResponse();
+ if (rule != null) {
+ aclResponse = _responseGenerator.createNetworkACLItemResponse(rule);
+ setResponseObject(aclResponse);
+ }
+ aclResponse.setResponseName(getCommandName());
+ } finally {
+ if (!success || rule == null) {
+ _networkACLService.revokeNetworkACLItem(getEntityId());
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create network ACL Item");
+ }
+ }
}
}
+
diff --git a/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLListCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLListCmd.java
new file mode 100644
index 00000000000..591a3541a53
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLListCmd.java
@@ -0,0 +1,120 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.network;
+
+import com.cloud.event.EventTypes;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.vpc.NetworkACL;
+import com.cloud.network.vpc.Vpc;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCreateCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.NetworkACLResponse;
+import org.apache.cloudstack.api.response.VpcResponse;
+import org.apache.log4j.Logger;
+
+@APICommand(name = "createNetworkACLList", description = "Creates a Network ACL for the given VPC",
+responseObject = NetworkACLResponse.class)
+public class CreateNetworkACLListCmd extends BaseAsyncCreateCmd {
+ public static final Logger s_logger = Logger.getLogger(CreateNetworkACLListCmd.class.getName());
+
+ private static final String s_name = "createnetworkacllistresponse";
+
+ // ///////////////////////////////////////////////////
+ // ////////////// API parameters /////////////////////
+ // ///////////////////////////////////////////////////
+
+ @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "Name of the network ACL List")
+ private String name;
+
+ @Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "Description of the network ACL List")
+ private String description;
+
+ @Parameter(name = ApiConstants.VPC_ID, type = CommandType.UUID, required = true, entityType = VpcResponse.class, description = "Id of the VPC associated with this network ACL List")
+ private Long vpcId;
+
+ // ///////////////////////////////////////////////////
+ // ///////////////// Accessors ///////////////////////
+ // ///////////////////////////////////////////////////
+
+ public String getName() {
+ return name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public Long getVpcId() {
+ return vpcId;
+ }
+
+ // ///////////////////////////////////////////////////
+ // ///////////// API Implementation///////////////////
+ // ///////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public void create() {
+ NetworkACL result = _networkACLService.createNetworkACL(getName(), getDescription(), getVpcId());
+ setEntityId(result.getId());
+ setEntityUuid(result.getUuid());
+ }
+
+ @Override
+ public void execute() throws ResourceUnavailableException {
+ NetworkACL acl = _networkACLService.getNetworkACL(getEntityId());
+ if(acl != null){
+ NetworkACLResponse aclResponse = _responseGenerator.createNetworkACLResponse(acl);
+ setResponseObject(aclResponse);
+ aclResponse.setResponseName(getCommandName());
+ } else {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create network ACL");
+ }
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ Vpc vpc = _vpcService.getVpc(getVpcId());
+ if (vpc == null) {
+ throw new InvalidParameterValueException("Invalid vpcId is given");
+ }
+
+ Account account = _accountService.getAccount(vpc.getAccountId());
+ return account.getId();
+ }
+
+ @Override
+ public String getEventType() {
+ return EventTypes.EVENT_NETWORK_ACL_CREATE;
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "Creating Network ACL with id: "+getEntityUuid();
+ }
+}
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 fc7bd9fdd3f..667c4c89966 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
@@ -22,13 +22,7 @@ import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
-import org.apache.cloudstack.api.response.DomainResponse;
-import org.apache.cloudstack.api.response.NetworkOfferingResponse;
-import org.apache.cloudstack.api.response.NetworkResponse;
-import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
-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.api.response.*;
import org.apache.log4j.Logger;
import com.cloud.exception.ConcurrentOperationException;
@@ -126,6 +120,12 @@ public class CreateNetworkCmd extends BaseCmd {
@Parameter(name=ApiConstants.IP6_CIDR, type=CommandType.STRING, description="the CIDR of IPv6 network, must be at least /64")
private String ip6Cidr;
+ @Parameter(name=ApiConstants.DISPLAY_NETWORK, type=CommandType.BOOLEAN, description="an optional field, whether to the display the network to the end user or not.")
+ private Boolean displayNetwork;
+
+ @Parameter(name=ApiConstants.ACL_ID, type=CommandType.UUID, entityType = NetworkACLResponse.class,
+ description="Network ACL Id associated for the network")
+ private Long aclId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@@ -189,6 +189,10 @@ public class CreateNetworkCmd extends BaseCmd {
return vpcId;
}
+ public Boolean getDisplayNetwork() {
+ return displayNetwork;
+ }
+
public Long getZoneId() {
Long physicalNetworkId = getPhysicalNetworkId();
@@ -247,6 +251,10 @@ public class CreateNetworkCmd extends BaseCmd {
return ip6Cidr.toLowerCase();
}
+ public Long getAclId() {
+ return aclId;
+ }
+
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
diff --git a/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLCmd.java
index 2a2444b3e1b..d35b22c532a 100644
--- a/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLCmd.java
@@ -16,6 +16,8 @@
// under the License.
package org.apache.cloudstack.api.command.user.network;
+import com.cloud.network.vpc.NetworkACLItem;
+import com.cloud.user.Account;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
@@ -24,6 +26,7 @@ import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.AccountResponse;
import org.apache.cloudstack.api.response.FirewallRuleResponse;
+import org.apache.cloudstack.api.response.NetworkACLItemResponse;
import org.apache.cloudstack.api.response.SuccessResponse;
import org.apache.log4j.Logger;
@@ -43,14 +46,10 @@ public class DeleteNetworkACLCmd extends BaseAsyncCmd {
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
- @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = FirewallRuleResponse.class,
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = NetworkACLItemResponse.class,
required=true, description="the ID of the network ACL")
private Long id;
- // unexposed parameter needed for events logging
- @Parameter(name=ApiConstants.ACCOUNT_ID, type=CommandType.UUID, entityType = AccountResponse.class,
- expose=false)
- private Long ownerId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@@ -69,7 +68,7 @@ public class DeleteNetworkACLCmd extends BaseAsyncCmd {
@Override
public String getEventType() {
- return EventTypes.EVENT_FIREWALL_CLOSE;
+ return EventTypes.EVENT_NETWORK_ACL_ITEM_DELETE;
}
@Override
@@ -79,44 +78,22 @@ public class DeleteNetworkACLCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
- if (ownerId == null) {
- FirewallRule rule = _networkACLService.getNetworkACL(id);
- if (rule == null) {
- throw new InvalidParameterValueException("Unable to find network ACL by id=" + id);
- } else {
- ownerId = rule.getAccountId();
- }
- }
- return ownerId;
+ Account caller = UserContext.current().getCaller();
+ return caller.getAccountId();
}
@Override
public void execute() throws ResourceUnavailableException {
- UserContext.current().setEventDetails("Network ACL Id: " + id);
- boolean result = _networkACLService.revokeNetworkACL(id, true);
+ UserContext.current().setEventDetails("Network ACL Item Id: " + id);
+ boolean result = _networkACLService.revokeNetworkACLItem(id);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
- throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete network ACL");
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete network ACL Item");
}
}
-
- @Override
- public String getSyncObjType() {
- return BaseAsyncCmd.networkSyncObject;
- }
-
- @Override
- public Long getSyncObjId() {
- return _firewallService.getFirewallRule(id).getNetworkId();
- }
-
- @Override
- public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.FirewallRule;
- }
}
diff --git a/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLListCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLListCmd.java
new file mode 100644
index 00000000000..379b44a0d50
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLListCmd.java
@@ -0,0 +1,93 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.network;
+
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.rules.FirewallRule;
+import com.cloud.network.vpc.NetworkACL;
+import com.cloud.network.vpc.Vpc;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+import org.apache.cloudstack.api.*;
+import org.apache.cloudstack.api.response.AccountResponse;
+import org.apache.cloudstack.api.response.FirewallRuleResponse;
+import org.apache.cloudstack.api.response.NetworkACLResponse;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.log4j.Logger;
+
+@APICommand(name = "deleteNetworkACLList", description="Deletes a Network ACL", responseObject=SuccessResponse.class)
+public class DeleteNetworkACLListCmd extends BaseAsyncCmd {
+ public static final Logger s_logger = Logger.getLogger(DeleteNetworkACLListCmd.class.getName());
+ private static final String s_name = "deletenetworkacllistresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = NetworkACLResponse.class,
+ required=true, description="the ID of the network ACL")
+ private Long id;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public long getId() {
+ return id;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public String getEventType() {
+ return EventTypes.EVENT_NETWORK_ACL_DELETE;
+ }
+
+ @Override
+ public String getEventDescription() {
+ return ("Deleting Network ACL id=" + id);
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ Account caller = UserContext.current().getCaller();
+ return caller.getAccountId();
+ }
+
+ @Override
+ public void execute() throws ResourceUnavailableException {
+ UserContext.current().setEventDetails("Network ACL Id: " + id);
+ boolean result = _networkACLService.deleteNetworkACL(id);
+
+ if (result) {
+ SuccessResponse response = new SuccessResponse(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete network ACL");
+ }
+ }
+}
+
diff --git a/api/src/org/apache/cloudstack/api/command/user/network/ListNetworkACLListsCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/ListNetworkACLListsCmd.java
new file mode 100644
index 00000000000..bb825d9f9f9
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/network/ListNetworkACLListsCmd.java
@@ -0,0 +1,102 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.network;
+
+import com.cloud.network.vpc.NetworkACL;
+import com.cloud.utils.Pair;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseListCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.NetworkACLResponse;
+import org.apache.cloudstack.api.response.NetworkResponse;
+import org.apache.cloudstack.api.response.VpcResponse;
+import org.apache.log4j.Logger;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@APICommand(name = "listNetworkACLLists", description="Lists all network ACLs", responseObject=NetworkACLResponse.class)
+public class ListNetworkACLListsCmd extends BaseListCmd {
+ public static final Logger s_logger = Logger.getLogger(ListNetworkACLListsCmd.class.getName());
+
+ private static final String s_name = "listnetworkacllistsresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = NetworkACLResponse.class,
+ description="Lists network ACL with the specified ID.")
+ private Long id;
+
+ @Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.UUID, entityType = NetworkResponse.class,
+ description="list network ACLs by network Id")
+ private Long networkId;
+
+ @Parameter(name=ApiConstants.VPC_ID, type=CommandType.UUID, entityType = VpcResponse.class,
+ description="list network ACLs by Vpc Id")
+ private Long vpcId;
+
+ @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="list network ACLs by specified name")
+ private String name;
+
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getNetworkId() {
+ return networkId;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public Long getVpcId() {
+ return vpcId;
+ }
+
+ public String getName(){
+ return name;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public void execute(){
+ Pair,Integer> result = _networkACLService.listNetworkACLs(getId(), getName(), getNetworkId(), getVpcId());
+ ListResponse response = new ListResponse();
+ List aclResponses = new ArrayList();
+
+ for (NetworkACL acl : result.first()) {
+ NetworkACLResponse aclResponse = _responseGenerator.createNetworkACLResponse(acl);
+ aclResponses.add(aclResponse);
+ }
+ response.setResponses(aclResponses, result.second());
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ }
+}
diff --git a/api/src/org/apache/cloudstack/api/command/user/network/ListNetworkACLsCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/ListNetworkACLsCmd.java
index d166974e7d1..df21a722408 100644
--- a/api/src/org/apache/cloudstack/api/command/user/network/ListNetworkACLsCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/network/ListNetworkACLsCmd.java
@@ -19,20 +19,18 @@ package org.apache.cloudstack.api.command.user.network;
import java.util.ArrayList;
import java.util.List;
+import com.cloud.network.vpc.NetworkACLItem;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseListTaggedResourcesCmd;
import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.response.FirewallRuleResponse;
-import org.apache.cloudstack.api.response.ListResponse;
-import org.apache.cloudstack.api.response.NetworkACLResponse;
-import org.apache.cloudstack.api.response.NetworkResponse;
+import org.apache.cloudstack.api.response.*;
import org.apache.log4j.Logger;
import com.cloud.network.rules.FirewallRule;
import com.cloud.utils.Pair;
-@APICommand(name = "listNetworkACLs", description="Lists all network ACLs", responseObject=NetworkACLResponse.class)
+@APICommand(name = "listNetworkACLs", description="Lists all network ACL items", responseObject=NetworkACLItemResponse.class)
public class ListNetworkACLsCmd extends BaseListTaggedResourcesCmd {
public static final Logger s_logger = Logger.getLogger(ListNetworkACLsCmd.class.getName());
@@ -42,16 +40,26 @@ public class ListNetworkACLsCmd extends BaseListTaggedResourcesCmd {
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = FirewallRuleResponse.class,
- description="Lists network ACL with the specified ID.")
+ description="Lists network ACL Item with the specified ID")
private Long id;
@Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.UUID, entityType = NetworkResponse.class,
- description="list network ACLs by network Id")
+ description="list network ACL Items by network Id")
private Long networkId;
- @Parameter(name=ApiConstants.TRAFFIC_TYPE, type=CommandType.STRING, description="list network ACLs by traffic type - Ingress or Egress")
+ @Parameter(name=ApiConstants.TRAFFIC_TYPE, type=CommandType.STRING, description="list network ACL Items by traffic type - Ingress or Egress")
private String trafficType;
+ @Parameter(name=ApiConstants.ACL_ID, type=CommandType.UUID, entityType = NetworkACLResponse.class,
+ description="list network ACL Items by ACL Id")
+ private Long aclId;
+
+ @Parameter(name=ApiConstants.PROTOCOL, type=CommandType.STRING, description="list network ACL Items by Protocol")
+ private String protocol;
+
+ @Parameter(name=ApiConstants.ACTION, type=CommandType.STRING, description="list network ACL Items by Action")
+ private String action;
+
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@@ -68,6 +76,18 @@ public class ListNetworkACLsCmd extends BaseListTaggedResourcesCmd {
return trafficType;
}
+ public Long getAclId(){
+ return aclId;
+ }
+
+ public String getProtocol() {
+ return protocol;
+ }
+
+ public String getAction() {
+ return action;
+ }
+
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@@ -79,12 +99,12 @@ public class ListNetworkACLsCmd extends BaseListTaggedResourcesCmd {
@Override
public void execute(){
- Pair,Integer> result = _networkACLService.listNetworkACLs(this);
- ListResponse response = new ListResponse();
- List aclResponses = new ArrayList();
+ Pair,Integer> result = _networkACLService.listNetworkACLItems(this);
+ ListResponse response = new ListResponse();
+ List aclResponses = new ArrayList();
- for (FirewallRule acl : result.first()) {
- NetworkACLResponse ruleData = _responseGenerator.createNetworkACLResponse(acl);
+ for (NetworkACLItem acl : result.first()) {
+ NetworkACLItemResponse ruleData = _responseGenerator.createNetworkACLItemResponse(acl);
aclResponses.add(ruleData);
}
response.setResponses(aclResponses, result.second());
diff --git a/api/src/org/apache/cloudstack/api/command/user/network/ReplaceNetworkACLListCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/ReplaceNetworkACLListCmd.java
new file mode 100644
index 00000000000..67f40d1a942
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/network/ReplaceNetworkACLListCmd.java
@@ -0,0 +1,120 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.network;
+
+import com.cloud.event.EventTypes;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.vpc.NetworkACL;
+import com.cloud.network.vpc.Vpc;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+import org.apache.cloudstack.api.*;
+import org.apache.cloudstack.api.response.NetworkACLResponse;
+import org.apache.cloudstack.api.response.NetworkResponse;
+import org.apache.cloudstack.api.response.PrivateGatewayResponse;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.log4j.Logger;
+
+@APICommand(name = "replaceNetworkACLList", description="Replaces ACL associated with a Network or private gateway", responseObject=SuccessResponse.class)
+public class ReplaceNetworkACLListCmd extends BaseAsyncCmd {
+ public static final Logger s_logger = Logger.getLogger(ReplaceNetworkACLListCmd.class.getName());
+ private static final String s_name = "replacenetworkacllistresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.ACL_ID, type=CommandType.UUID, entityType = NetworkACLResponse.class,
+ required=true, description="the ID of the network ACL")
+ private long aclId;
+
+ @Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.UUID, entityType = NetworkResponse.class,
+ description="the ID of the network")
+ private Long networkId;
+
+ @Parameter(name=ApiConstants.GATEWAY_ID, type=CommandType.UUID, entityType = PrivateGatewayResponse.class,
+ description="the ID of the private gateway")
+ private Long privateGatewayId;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public long getAclId() {
+ return aclId;
+ }
+
+ public Long getNetworkId(){
+ return networkId;
+ }
+
+ public Long getPrivateGatewayId() {
+ return privateGatewayId;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public String getEventType() {
+ return EventTypes.EVENT_NETWORK_ACL_REPLACE;
+ }
+
+ @Override
+ public String getEventDescription() {
+ return ("Associating Network ACL id=" + aclId+ " with Network id="+ networkId);
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ Account caller = UserContext.current().getCaller();
+ return caller.getAccountId();
+ }
+
+ @Override
+ public void execute() throws ResourceUnavailableException {
+ if (getNetworkId() == null && getPrivateGatewayId() == null) {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Network id and private gateway can't be null at the same time");
+ }
+
+ if (getNetworkId() != null && getPrivateGatewayId() != null) {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Network id and private gateway can't be passed at the same time");
+ }
+
+ UserContext.current().setEventDetails("Network ACL Id: " + aclId);
+ boolean result = false;
+ if (getPrivateGatewayId() != null) {
+ result = _networkACLService.replaceNetworkACLonPrivateGw(aclId, privateGatewayId);
+ } else {
+ result = _networkACLService.replaceNetworkACL(aclId, networkId);
+ }
+
+ if (result) {
+ SuccessResponse response = new SuccessResponse(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to replace network ACL");
+ }
+ }
+}
+
diff --git a/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLItemCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLItemCmd.java
new file mode 100644
index 00000000000..1ea815ab1fb
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLItemCmd.java
@@ -0,0 +1,173 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.network;
+
+import com.cloud.event.EventTypes;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.vpc.NetworkACLItem;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+import com.cloud.utils.net.NetUtils;
+import org.apache.cloudstack.api.*;
+import org.apache.cloudstack.api.response.NetworkACLItemResponse;
+import org.apache.cloudstack.api.response.NetworkACLResponse;
+import org.apache.cloudstack.api.response.NetworkResponse;
+import org.apache.log4j.Logger;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@APICommand(name = "updateNetworkACLItem", description = "Updates ACL Item with specified Id",
+responseObject = NetworkACLItemResponse.class)
+public class UpdateNetworkACLItemCmd extends BaseAsyncCmd {
+ public static final Logger s_logger = Logger.getLogger(UpdateNetworkACLItemCmd.class.getName());
+
+ private static final String s_name = "createnetworkaclresponse";
+
+ // ///////////////////////////////////////////////////
+ // ////////////// API parameters /////////////////////
+ // ///////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = NetworkACLItemResponse.class,
+ required=true, description="the ID of the network ACL Item")
+ private Long id;
+
+ @Parameter(name = ApiConstants.PROTOCOL, type = CommandType.STRING, description =
+ "the protocol for the ACL rule. Valid values are TCP/UDP/ICMP/ALL or valid protocol number")
+ private String protocol;
+
+ @Parameter(name = ApiConstants.START_PORT, type = CommandType.INTEGER, description = "the starting port of ACL")
+ private Integer publicStartPort;
+
+ @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,
+ description = "the cidr list to allow traffic from/to")
+ private List 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.TRAFFIC_TYPE, type=CommandType.STRING, description="the traffic type for the ACL," +
+ "can be Ingress or Egress, defaulted to Ingress if not specified")
+ private String trafficType;
+
+ @Parameter(name=ApiConstants.NUMBER, type=CommandType.INTEGER, description="The network of the vm the ACL will be created for")
+ private Integer number;
+
+ @Parameter(name=ApiConstants.ACTION, type=CommandType.STRING, description="scl entry action, allow or deny")
+ private String action;
+
+ // ///////////////////////////////////////////////////
+ // ///////////////// Accessors ///////////////////////
+ // ///////////////////////////////////////////////////
+
+ public Long getId() {
+ return id;
+ }
+
+ public String getProtocol() {
+ if(protocol != null){
+ return protocol.trim();
+ } else
+ return null;
+ }
+
+ public List getSourceCidrList() {
+ return cidrlist;
+ }
+
+ public NetworkACLItem.TrafficType getTrafficType() {
+ if (trafficType != null) {
+ for (NetworkACLItem.TrafficType type : NetworkACLItem.TrafficType.values()) {
+ if (type.toString().equalsIgnoreCase(trafficType)) {
+ return type;
+ }
+ }
+ }
+ return null;
+ }
+
+ // ///////////////////////////////////////////////////
+ // ///////////// API Implementation///////////////////
+ // ///////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ public String getAction() {
+ return action;
+ }
+
+ public Integer getNumber() {
+ return number;
+ }
+
+ public Integer getSourcePortStart() {
+ return publicStartPort;
+ }
+
+ public Integer getSourcePortEnd() {
+ return publicEndPort;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ Account caller = UserContext.current().getCaller();
+ return caller.getAccountId();
+ }
+
+ @Override
+ public String getEventType() {
+ return EventTypes.EVENT_NETWORK_ACL_ITEM_UPDATE;
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "Updating Network ACL Item";
+ }
+
+ public Integer getIcmpCode() {
+ return icmpCode;
+ }
+
+ public Integer getIcmpType() {
+ return icmpType;
+ }
+
+ @Override
+ public void execute() throws ResourceUnavailableException {
+ UserContext.current().setEventDetails("Rule Id: " + getId());
+ NetworkACLItem aclItem = _networkACLService.updateNetworkACLItem(getId(), getProtocol(), getSourceCidrList(), getTrafficType(),
+ getAction(), getNumber(), getSourcePortStart(), getSourcePortEnd(), getIcmpCode(), getIcmpType());
+ if (aclItem == null) {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update network ACL Item");
+ }
+ NetworkACLItemResponse aclResponse = _responseGenerator.createNetworkACLItemResponse(aclItem);
+ setResponseObject(aclResponse);
+ aclResponse.setResponseName(getCommandName());
+ }
+
+}
+
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 a61474e69d0..fe381246b28 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
@@ -67,6 +67,9 @@ public class UpdateNetworkCmd extends BaseAsyncCmd {
@Parameter(name=ApiConstants.GUEST_VM_CIDR, type=CommandType.STRING, description="CIDR for Guest VMs,Cloudstack allocates IPs to Guest VMs only from this CIDR")
private String guestVmCidr;
+ @Parameter(name=ApiConstants.DISPLAY_NETWORK, type=CommandType.BOOLEAN, description="an optional field, whether to the display the network to the end user or not.")
+ private Boolean displayNetwork;
+
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@@ -101,6 +104,10 @@ public class UpdateNetworkCmd extends BaseAsyncCmd {
private String getGuestVmCidr() {
return guestVmCidr;
}
+
+ public Boolean getDisplayNetwork() {
+ return displayNetwork;
+ }
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@@ -130,7 +137,7 @@ public class UpdateNetworkCmd extends BaseAsyncCmd {
}
Network result = _networkService.updateGuestNetwork(getId(), getNetworkName(), getDisplayText(), callerAccount,
- callerUser, getNetworkDomain(), getNetworkOfferingId(), getChangeCidr(), getGuestVmCidr());
+ callerUser, getNetworkDomain(), getNetworkOfferingId(), getChangeCidr(), getGuestVmCidr(), getDisplayNetwork());
if (result != null) {
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 3ed08d26be0..b5cf9f9c054 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
@@ -183,6 +183,8 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
+ "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.")
+ private Boolean displayVm;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@@ -219,6 +221,10 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
return HypervisorType.getType(hypervisor);
}
+ public Boolean getDisplayVm() {
+ return displayVm;
+ }
+
public List getSecurityGroupIdList() {
if (securityGroupNameList != null && securityGroupIdList != null) {
throw new InvalidParameterValueException("securitygroupids parameter is mutually exclusive with securitygroupnames parameter");
@@ -481,18 +487,20 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
throw new InvalidParameterValueException("Can't specify network Ids in Basic zone");
} else {
vm = _userVmService.createBasicSecurityGroupVirtualMachine(zone, serviceOffering, template, getSecurityGroupIdList(), owner, name,
- displayName, diskOfferingId, size, group, getHypervisor(), this.getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, keyboard, getAffinityGroupIdList());
+ displayName, diskOfferingId, size, group, getHypervisor(), this.getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, displayVm, keyboard, getAffinityGroupIdList());
}
} else {
if (zone.isSecurityGroupEnabled()) {
vm = _userVmService.createAdvancedSecurityGroupVirtualMachine(zone, serviceOffering, template, getNetworkIds(), getSecurityGroupIdList(),
- owner, name, displayName, diskOfferingId, size, group, getHypervisor(), this.getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, keyboard, getAffinityGroupIdList());
+ owner, name, displayName, diskOfferingId, size, group, getHypervisor(), this.getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, displayVm, keyboard, getAffinityGroupIdList());
+
} else {
if (getSecurityGroupIdList() != null && !getSecurityGroupIdList().isEmpty()) {
throw new InvalidParameterValueException("Can't create vm with security groups; security group feature is not enabled per zone");
}
vm = _userVmService.createAdvancedVirtualMachine(zone, serviceOffering, template, getNetworkIds(), owner, name, displayName,
- diskOfferingId, size, group, getHypervisor(), this.getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, keyboard, getAffinityGroupIdList());
+ diskOfferingId, size, group, getHypervisor(), this.getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, displayVm, keyboard, getAffinityGroupIdList());
+
}
}
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 bbf9b259201..28602830e02 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
@@ -64,6 +64,8 @@ public class UpdateVMCmd extends BaseCmd{
@Parameter(name=ApiConstants.USER_DATA, type=CommandType.STRING, description="an optional binary data that can be sent to the virtual machine upon a successful deployment. This binary data must be base64 encoded before adding it to the request. Using HTTP GET (via querystring), you can send up to 2KB of data after base64 encoding. Using HTTP POST(via POST body), you can send up to 32K of data after base64 encoding.", 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.")
+ private Boolean displayVm;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@@ -89,6 +91,10 @@ public class UpdateVMCmd extends BaseCmd{
return userData;
}
+ public Boolean getDisplayVm() {
+ return displayVm;
+ }
+
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@@ -107,6 +113,7 @@ public class UpdateVMCmd extends BaseCmd{
}
@Override
+
public long getEntityOwnerId() {
UserVm userVm = _entityMgr.findById(UserVm.class, getId());
if (userVm != null) {
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
new file mode 100644
index 00000000000..de5832dc8e6
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/AddResourceDetailCmd.java
@@ -0,0 +1,116 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.volume;
+
+import com.cloud.server.ResourceTag;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.api.response.UserVmResponse;
+import org.apache.cloudstack.api.response.VolumeResponse;
+import org.apache.log4j.Logger;
+
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.storage.Volume;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+import java.util.*;
+
+@APICommand(name = "addResourceDetail", description="Adds detail for the Resource.", responseObject=SuccessResponse.class)
+public class AddResourceDetailCmd extends BaseAsyncCmd {
+ public static final Logger s_logger = Logger.getLogger(AddResourceDetailCmd.class.getName());
+ private static final String s_name = "addResourceDetailresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name = ApiConstants.DETAILS, type = CommandType.MAP, required=true, description = "Map of (key/value pairs)")
+ private Map details;
+
+ @Parameter(name=ApiConstants.RESOURCE_TYPE, type=CommandType.STRING, required=true, description="type of the resource")
+ private String resourceType;
+
+ @Parameter(name=ApiConstants.RESOURCE_ID, type=CommandType.STRING, required=true,
+ collectionType=CommandType.STRING, description="resource id to create the details for")
+ private String resourceId;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Map getDetails() {
+ Map detailsMap = null;
+ if (!details.isEmpty()) {
+ detailsMap = new HashMap();
+ Collection> servicesCollection = details.values();
+ Iterator> iter = servicesCollection.iterator();
+ while (iter.hasNext()) {
+ HashMap services = (HashMap) iter.next();
+ String key = services.get("key");
+ String value = services.get("value");
+ detailsMap.put(key, value);
+ }
+ }
+ return detailsMap;
+ }
+
+ public ResourceTag.TaggedResourceType getResourceType() {
+ return _taggedResourceService.getResourceType(resourceType);
+ }
+
+ public String getResourceId() {
+ return resourceId;
+ }
+/////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+
+ @Override
+ public long getEntityOwnerId() {
+ //FIXME - validate the owner here
+ return 1;
+ }
+
+ @Override
+ public String getEventType() {
+ return EventTypes.EVENT_RESOURCE_DETAILS_CREATE;
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "adding details to the resource ";
+ }
+
+ @Override
+ public void execute(){
+ _resourceMetaDataService.addResourceMetaData(getResourceId(), getResourceType(), getDetails());
+ this.setResponseObject(new SuccessResponse(getCommandName()));
+ }
+}
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 5db06bcd47f..86a494b8848 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
@@ -76,8 +76,10 @@ public class CreateVolumeCmd extends BaseAsyncCreateCmd {
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.")
+ private Boolean displayVolume;
- /////////////////////////////////////////////////////
+/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@@ -114,6 +116,10 @@ public class CreateVolumeCmd extends BaseAsyncCreateCmd {
return projectId;
}
+ public Boolean getDisplayVolume() {
+ return displayVolume;
+ }
+
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/ListResourceDetailsCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/ListResourceDetailsCmd.java
new file mode 100644
index 00000000000..c02d4b4c6ef
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/ListResourceDetailsCmd.java
@@ -0,0 +1,75 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.cloudstack.api.command.user.volume;
+
+import com.cloud.server.ResourceTag;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.ResourceDetailResponse;
+import org.apache.cloudstack.api.response.ResourceTagResponse;
+
+import java.util.List;
+
+@APICommand(name = "listResourceDetails", description = "List resource detail(s)", responseObject = ResourceTagResponse.class, since = "4.2")
+public class ListResourceDetailsCmd extends BaseListProjectAndAccountResourcesCmd{
+ private static final String s_name = "listresourcedetailsresponse";
+
+ @Parameter(name=ApiConstants.RESOURCE_TYPE, type=CommandType.STRING, description="list by resource type")
+ private String resourceType;
+
+ @Parameter(name=ApiConstants.RESOURCE_ID, type=CommandType.STRING, description="list by resource id")
+ private String resourceId;
+
+ @Parameter(name=ApiConstants.KEY, type=CommandType.STRING, description="list by key")
+ private String key;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public void execute() {
+
+ ListResponse response = new ListResponse();
+ List resourceDetailResponse = _queryService.listResource(this);
+ response.setResponses(resourceDetailResponse);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ }
+
+ public ResourceTag.TaggedResourceType getResourceType() {
+ return _taggedResourceService.getResourceType(resourceType);
+ }
+
+ public String getResourceId() {
+ return resourceId;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+}
diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/RemoveResourceDetailCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/RemoveResourceDetailCmd.java
new file mode 100644
index 00000000000..3474996a52c
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/RemoveResourceDetailCmd.java
@@ -0,0 +1,110 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for Removeitional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.volume;
+
+import com.cloud.server.ResourceTag;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.api.response.UserVmResponse;
+import org.apache.cloudstack.api.response.VolumeResponse;
+import org.apache.log4j.Logger;
+
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.storage.Volume;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+import java.util.*;
+
+@APICommand(name = "removeResourceDetail", description="Removes detail for the Resource.", responseObject=SuccessResponse.class)
+public class RemoveResourceDetailCmd extends BaseAsyncCmd {
+ public static final Logger s_logger = Logger.getLogger(RemoveResourceDetailCmd.class.getName());
+ private static final String s_name = "RemoveResourceDetailresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name = ApiConstants.KEY, type = CommandType.STRING, description = "Delete details matching key/value pairs")
+ private String key;
+
+ @Parameter(name=ApiConstants.RESOURCE_TYPE, type=CommandType.STRING, required=true, description="Delete detail by resource type")
+ private String resourceType;
+
+ @Parameter(name=ApiConstants.RESOURCE_ID, type=CommandType.STRING, required=true,
+ collectionType=CommandType.STRING, description="Delete details for resource id")
+ private String resourceId;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+
+ public ResourceTag.TaggedResourceType getResourceType(){
+ return _taggedResourceService.getResourceType(resourceType);
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public String getResourceId() {
+ return resourceId;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ public AsyncJob.Type getInstanceType() {
+ return AsyncJob.Type.Volume;
+ }
+
+
+ @Override
+ public long getEntityOwnerId() {
+ //FIXME - validate the owner here
+ return 1;
+ }
+
+ @Override
+ public String getEventType() {
+ return EventTypes.EVENT_RESOURCE_DETAILS_DELETE;
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "Removing detail to the volume ";
+ }
+
+ @Override
+ public void execute(){
+ _resourceMetaDataService.deleteResourceMetaData(getResourceId(), getResourceType(), getKey());
+ this.setResponseObject(new SuccessResponse(getCommandName()));
+ }
+}
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
new file mode 100644
index 00000000000..3453eef9187
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/UpdateVolumeCmd.java
@@ -0,0 +1,112 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.volume;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.UserVmResponse;
+import org.apache.cloudstack.api.response.VolumeResponse;
+import org.apache.log4j.Logger;
+
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.storage.Volume;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+@APICommand(name = "updateVolume", description="Updates the volume.", responseObject=VolumeResponse.class)
+public class UpdateVolumeCmd extends BaseAsyncCmd {
+ public static final Logger s_logger = Logger.getLogger(UpdateVolumeCmd.class.getName());
+ private static final String s_name = "addVolumeresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=VolumeResponse.class,
+ required=true, description="the ID of the disk volume")
+ private Long id;
+
+ @Parameter(name=ApiConstants.PATH, type=CommandType.STRING,
+ required=true, description="the path of the volume")
+ private String path;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public String getPath() {
+ return path;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ public AsyncJob.Type getInstanceType() {
+ return AsyncJob.Type.Volume;
+ }
+
+ public Long getInstanceId() {
+ return getId();
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ Volume volume = _responseGenerator.findVolumeById(getId());
+ if (volume == null) {
+ return Account.ACCOUNT_ID_SYSTEM; // bad id given, parent this command to SYSTEM so ERROR events are tracked
+ }
+ return volume.getAccountId();
+ }
+
+ @Override
+ public String getEventType() {
+ return EventTypes.EVENT_VOLUME_ATTACH;
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "adding detail to the volume: " + getId();
+ }
+
+ @Override
+ public void execute(){
+ UserContext.current().setEventDetails("Volume Id: "+getId());
+ Volume result = _volumeService.updateVolume(this);
+ if (result != null) {
+ VolumeResponse response = _responseGenerator.createVolumeResponse(result);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update volume");
+ }
+ }
+}
diff --git a/api/src/org/apache/cloudstack/api/response/ApplicationLoadBalancerInstanceResponse.java b/api/src/org/apache/cloudstack/api/response/ApplicationLoadBalancerInstanceResponse.java
new file mode 100644
index 00000000000..2d6614d217b
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/response/ApplicationLoadBalancerInstanceResponse.java
@@ -0,0 +1,63 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.response;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseResponse;
+
+import com.cloud.serializer.Param;
+import com.google.gson.annotations.SerializedName;
+
+/**
+ *
+ * Load Balancer instance is the User Vm instance participating in the Load Balancer
+ *
+ */
+
+@SuppressWarnings("unused")
+public class ApplicationLoadBalancerInstanceResponse extends BaseResponse{
+
+ @SerializedName(ApiConstants.ID) @Param(description = "the instance ID")
+ private String id;
+
+ @SerializedName(ApiConstants.NAME) @Param(description = "the name of the instance")
+ private String name;
+
+ @SerializedName(ApiConstants.STATE) @Param(description="the state of the instance")
+ private String state;
+
+ @SerializedName(ApiConstants.IP_ADDRESS)
+ @Param(description="the ip address of the instance")
+ private String ipAddress;
+
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
+ public void setIpAddress(String ipAddress) {
+ this.ipAddress = ipAddress;
+ }
+}
diff --git a/api/src/org/apache/cloudstack/api/response/ApplicationLoadBalancerResponse.java b/api/src/org/apache/cloudstack/api/response/ApplicationLoadBalancerResponse.java
new file mode 100644
index 00000000000..de9bce6c658
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/response/ApplicationLoadBalancerResponse.java
@@ -0,0 +1,142 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.cloudstack.api.response;
+
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseResponse;
+
+import com.cloud.serializer.Param;
+import com.google.gson.annotations.SerializedName;
+
+@SuppressWarnings("unused")
+public class ApplicationLoadBalancerResponse extends BaseResponse implements ControlledEntityResponse{
+ @SerializedName(ApiConstants.ID) @Param(description = "the Load Balancer ID")
+ private String id;
+
+ @SerializedName(ApiConstants.NAME) @Param(description = "the name of the Load Balancer")
+ private String name;
+
+ @SerializedName(ApiConstants.DESCRIPTION) @Param(description = "the description of the Load Balancer")
+ private String description;
+
+ @SerializedName(ApiConstants.ALGORITHM) @Param(description = "the load balancer algorithm (source, roundrobin, leastconn)")
+ private String algorithm;
+
+ @SerializedName(ApiConstants.NETWORK_ID) @Param(description="Load Balancer network id")
+ private String networkId;
+
+ @SerializedName(ApiConstants.SOURCE_IP) @Param(description="Load Balancer source ip")
+ private String sourceIp;
+
+ @SerializedName(ApiConstants.SOURCE_IP_NETWORK_ID) @Param(description="Load Balancer source ip network id")
+ private String sourceIpNetworkId;
+
+ @SerializedName(ApiConstants.ACCOUNT)
+ @Param(description = "the account of the Load Balancer")
+ private String accountName;
+
+ @SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id of the Load Balancer")
+ private String projectId;
+
+ @SerializedName(ApiConstants.PROJECT) @Param(description="the project name of the Load Balancer")
+ private String projectName;
+
+ @SerializedName(ApiConstants.DOMAIN_ID)
+ @Param(description = "the domain ID of the Load Balancer")
+ private String domainId;
+
+ @SerializedName(ApiConstants.DOMAIN)
+ @Param(description = "the domain of the Load Balancer")
+ private String domainName;
+
+ @SerializedName("loadbalancerrule") @Param(description="the list of rules associated with the Load Balancer", responseObject = ApplicationLoadBalancerRuleResponse.class)
+ private List lbRules;
+
+ @SerializedName("loadbalancerinstance") @Param(description="the list of instances associated with the Load Balancer", responseObject = ApplicationLoadBalancerInstanceResponse.class)
+ private List lbInstances;
+
+ @SerializedName(ApiConstants.TAGS) @Param(description="the list of resource tags associated with the Load Balancer", responseObject = ResourceTagResponse.class)
+ private List tags;
+
+ public void setAccountName(String accountName) {
+ this.accountName = accountName;
+ }
+
+ @Override
+ public void setDomainId(String domainId) {
+ this.domainId = domainId;
+ }
+
+ public void setDomainName(String domainName) {
+ this.domainName = domainName;
+ }
+
+ @Override
+ public void setProjectId(String projectId) {
+ this.projectId = projectId;
+ }
+
+ @Override
+ public void setProjectName(String projectName) {
+ this.projectName = projectName;
+ }
+
+ public void setTags(List tags) {
+ this.tags = tags;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public void setAlgorithm(String algorithm) {
+ this.algorithm = algorithm;
+ }
+
+ public void setNetworkId(String networkId) {
+ this.networkId = networkId;
+ }
+
+ public void setSourceIp(String sourceIp) {
+ this.sourceIp = sourceIp;
+ }
+
+ public void setSourceIpNetworkId(String sourceIpNetworkId) {
+ this.sourceIpNetworkId = sourceIpNetworkId;
+ }
+
+ public void setLbRules(List lbRules) {
+ this.lbRules = lbRules;
+ }
+
+ public void setLbInstances(List lbInstances) {
+ this.lbInstances = lbInstances;
+ }
+}
diff --git a/api/src/org/apache/cloudstack/api/response/ApplicationLoadBalancerRuleResponse.java b/api/src/org/apache/cloudstack/api/response/ApplicationLoadBalancerRuleResponse.java
new file mode 100644
index 00000000000..ffc64d5ca46
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/response/ApplicationLoadBalancerRuleResponse.java
@@ -0,0 +1,51 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.cloudstack.api.response;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseResponse;
+
+import com.cloud.serializer.Param;
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * Subobject of the load balancer container response
+ */
+@SuppressWarnings("unused")
+public class ApplicationLoadBalancerRuleResponse extends BaseResponse{
+ @SerializedName(ApiConstants.SOURCE_PORT) @Param(description = "source port of the load balancer rule")
+ private Integer sourcePort;
+
+ @SerializedName(ApiConstants.INSTANCE_PORT) @Param(description = "instance port of the load balancer rule")
+ private Integer instancePort;
+
+ @SerializedName(ApiConstants.STATE) @Param(description = "the state of the load balancer rule")
+ private String state;
+
+ public void setSourcePort(Integer sourcePort) {
+ this.sourcePort = sourcePort;
+ }
+
+ public void setInstancePort(Integer instancePort) {
+ this.instancePort = instancePort;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+}
diff --git a/api/src/org/apache/cloudstack/api/response/DiskOfferingResponse.java b/api/src/org/apache/cloudstack/api/response/DiskOfferingResponse.java
index 04c318f8a2f..377e66ec2b1 100644
--- a/api/src/org/apache/cloudstack/api/response/DiskOfferingResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/DiskOfferingResponse.java
@@ -58,8 +58,20 @@ public class DiskOfferingResponse extends BaseResponse {
@SerializedName("storagetype") @Param(description="the storage type for this disk offering")
private String storageType;
+ @SerializedName("displayoffering") @Param(description="whether to display the offering to the end user or not.")
+ private Boolean displayOffering;
+
+ public Boolean getDisplayOffering() {
+ return displayOffering;
+ }
+
+ public void setDisplayOffering(Boolean displayOffering) {
+ this.displayOffering = displayOffering;
+ }
+
public String getId() {
return id;
+
}
public void setId(String id) {
diff --git a/api/src/org/apache/cloudstack/api/response/DomainRouterResponse.java b/api/src/org/apache/cloudstack/api/response/DomainRouterResponse.java
index 79c8596a8d1..852d98815a3 100644
--- a/api/src/org/apache/cloudstack/api/response/DomainRouterResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/DomainRouterResponse.java
@@ -153,8 +153,11 @@ public class DomainRouterResponse extends BaseResponse implements ControlledView
@SerializedName("scriptsversion") @Param(description="the version of scripts")
private String scriptsVersion;
- @SerializedName(ApiConstants.VPC_ID) @Param(description="VPC the network belongs to")
+ @SerializedName(ApiConstants.VPC_ID) @Param(description="VPC the router belongs to")
private String vpcId;
+
+ @SerializedName(ApiConstants.ROLE) @Param(description="role of the domain router")
+ private String role;
@SerializedName("nic") @Param(description="the list of nics associated with the router",
responseObject = NicResponse.class, since="4.0")
@@ -164,15 +167,11 @@ public class DomainRouterResponse extends BaseResponse implements ControlledView
nics = new LinkedHashSet();
}
-
-
@Override
public String getObjectId() {
return this.getId();
}
-
-
public String getId() {
return id;
}
@@ -372,4 +371,8 @@ public class DomainRouterResponse extends BaseResponse implements ControlledView
public void setIp6Dns2(String ip6Dns2) {
this.ip6Dns2 = ip6Dns2;
}
+
+ public void setRole(String role) {
+ this.role = role;
+ }
}
diff --git a/api/src/org/apache/cloudstack/api/response/InternalLoadBalancerElementResponse.java b/api/src/org/apache/cloudstack/api/response/InternalLoadBalancerElementResponse.java
new file mode 100644
index 00000000000..b7e8634ee8f
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/response/InternalLoadBalancerElementResponse.java
@@ -0,0 +1,51 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.response;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseResponse;
+import org.apache.cloudstack.api.EntityReference;
+
+import com.cloud.network.VirtualRouterProvider;
+import com.cloud.serializer.Param;
+import com.google.gson.annotations.SerializedName;
+
+@EntityReference(value=VirtualRouterProvider.class)
+@SuppressWarnings("unused")
+public class InternalLoadBalancerElementResponse extends BaseResponse {
+ @SerializedName(ApiConstants.ID) @Param(description="the id of the internal load balancer element")
+ private String id;
+
+ @SerializedName(ApiConstants.NSP_ID) @Param(description="the physical network service provider id of the element")
+ private String nspId;
+
+ @SerializedName(ApiConstants.ENABLED) @Param(description="Enabled/Disabled the element")
+ private Boolean enabled;
+
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public void setNspId(String nspId) {
+ this.nspId = nspId;
+ }
+
+ public void setEnabled(Boolean enabled) {
+ this.enabled = enabled;
+ }
+}
diff --git a/api/src/org/apache/cloudstack/api/response/NetworkACLItemResponse.java b/api/src/org/apache/cloudstack/api/response/NetworkACLItemResponse.java
new file mode 100644
index 00000000000..400a4db7631
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/response/NetworkACLItemResponse.java
@@ -0,0 +1,122 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.response;
+
+import java.util.List;
+
+import com.cloud.network.vpc.NetworkACLItem;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseResponse;
+
+import com.cloud.serializer.Param;
+import com.google.gson.annotations.SerializedName;
+import org.apache.cloudstack.api.EntityReference;
+
+@EntityReference(value = NetworkACLItem.class)
+public class NetworkACLItemResponse extends BaseResponse {
+ @SerializedName(ApiConstants.ID) @Param(description="the ID of the ACL Item")
+ private String id;
+
+ @SerializedName(ApiConstants.PROTOCOL) @Param(description="the protocol of the ACL")
+ private String protocol;
+
+ @SerializedName(ApiConstants.START_PORT) @Param(description="the starting port of ACL's port range")
+ private String startPort;
+
+ @SerializedName(ApiConstants.END_PORT) @Param(description = "the ending port of ACL's port range")
+ private String endPort;
+
+ @SerializedName(ApiConstants.TRAFFIC_TYPE) @Param(description="the traffic type for the ACL")
+ private String trafficType;
+
+ @SerializedName(ApiConstants.STATE) @Param(description="the state of the rule")
+ private String state;
+
+ @SerializedName(ApiConstants.CIDR_LIST) @Param(description="the cidr list to forward traffic from")
+ private String cidrList;
+
+ @SerializedName(ApiConstants.ICMP_TYPE) @Param(description= "type of the icmp message being sent")
+ private Integer icmpType;
+
+ @SerializedName(ApiConstants.ICMP_CODE) @Param(description = "error code for this icmp message")
+ private Integer icmpCode;
+
+ @SerializedName(ApiConstants.TAGS) @Param(description="the list of resource tags associated with the network ACLs",
+ responseObject = ResourceTagResponse.class)
+ private List tags;
+
+ @SerializedName(ApiConstants.ACL_ID) @Param(description="the ID of the ACL this item belongs to")
+ private String aclId;
+
+ @SerializedName(ApiConstants.NUMBER) @Param(description= "Number of the ACL Item")
+ private Integer number;
+
+ @SerializedName(ApiConstants.ACTION) @Param(description="Action of ACL Item. Allow/Deny")
+ private String action;
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public void setProtocol(String protocol) {
+ this.protocol = protocol;
+ }
+
+ public void setStartPort(String startPort) {
+ this.startPort = startPort;
+ }
+
+ public void setEndPort(String endPort) {
+ this.endPort = endPort;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
+ public void setCidrList(String cidrList) {
+ this.cidrList = cidrList;
+ }
+
+ public void setIcmpType(Integer icmpType) {
+ this.icmpType = icmpType;
+ }
+
+ public void setIcmpCode(Integer icmpCode) {
+ this.icmpCode = icmpCode;
+ }
+
+ public void setTrafficType(String trafficType) {
+ this.trafficType = trafficType;
+ }
+
+ public void setTags(List tags) {
+ this.tags = tags;
+ }
+
+ public void setAclId(String aclId) {
+ this.aclId = aclId;
+ }
+
+ public void setNumber(Integer number) {
+ this.number = number;
+ }
+
+ public void setAction(String action) {
+ this.action = action;
+ }
+}
diff --git a/api/src/org/apache/cloudstack/api/response/NetworkACLResponse.java b/api/src/org/apache/cloudstack/api/response/NetworkACLResponse.java
index b45b43cf6ec..12ca38b222a 100644
--- a/api/src/org/apache/cloudstack/api/response/NetworkACLResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/NetworkACLResponse.java
@@ -16,84 +16,42 @@
// under the License.
package org.apache.cloudstack.api.response;
-import java.util.List;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseResponse;
-
+import com.cloud.network.vpc.NetworkACL;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseResponse;
+import org.apache.cloudstack.api.EntityReference;
-@SuppressWarnings("unused")
+import java.util.List;
+
+@EntityReference(value = NetworkACL.class)
public class NetworkACLResponse extends BaseResponse {
@SerializedName(ApiConstants.ID) @Param(description="the ID of the ACL")
private String id;
- @SerializedName(ApiConstants.PROTOCOL) @Param(description="the protocol of the ACL")
- private String protocol;
+ @SerializedName(ApiConstants.NAME) @Param(description="the Name of the ACL")
+ private String name;
- @SerializedName(ApiConstants.START_PORT) @Param(description="the starting port of ACL's port range")
- private String startPort;
+ @SerializedName(ApiConstants.DESCRIPTION) @Param(description="Description of the ACL")
+ private String description;
- @SerializedName(ApiConstants.END_PORT) @Param(description = "the ending port of ACL's port range")
- private String endPort;
-
- @SerializedName(ApiConstants.TRAFFIC_TYPE) @Param(description="the traffic type for the ACL")
- private String trafficType;
-
- @SerializedName(ApiConstants.STATE) @Param(description="the state of the rule")
- private String state;
-
- @SerializedName(ApiConstants.CIDR_LIST) @Param(description="the cidr list to forward traffic from")
- private String cidrList;
-
- @SerializedName(ApiConstants.ICMP_TYPE) @Param(description= "type of the icmp message being sent")
- private Integer icmpType;
-
- @SerializedName(ApiConstants.ICMP_CODE) @Param(description = "error code for this icmp message")
- private Integer icmpCode;
-
- @SerializedName(ApiConstants.TAGS) @Param(description="the list of resource tags associated with the network ACLs",
- responseObject = ResourceTagResponse.class)
- private List tags;
+ @SerializedName(ApiConstants.VPC_ID) @Param(description="Id of the VPC this ACL is associated with")
+ private String vpcId;
public void setId(String id) {
this.id = id;
}
- public void setProtocol(String protocol) {
- this.protocol = protocol;
+ public void setName(String name) {
+ this.name = name;
}
- public void setStartPort(String startPort) {
- this.startPort = startPort;
+ public void setDescription(String description) {
+ this.description = description;
}
- public void setEndPort(String endPort) {
- this.endPort = endPort;
- }
-
- public void setState(String state) {
- this.state = state;
- }
-
- public void setCidrList(String cidrList) {
- this.cidrList = cidrList;
- }
-
- public void setIcmpType(Integer icmpType) {
- this.icmpType = icmpType;
- }
-
- public void setIcmpCode(Integer icmpCode) {
- this.icmpCode = icmpCode;
- }
-
- public void setTrafficType(String trafficType) {
- this.trafficType = trafficType;
- }
-
- public void setTags(List tags) {
- this.tags = tags;
+ public void setVpcId(String vpcId) {
+ this.vpcId = vpcId;
}
}
diff --git a/api/src/org/apache/cloudstack/api/response/NetworkOfferingResponse.java b/api/src/org/apache/cloudstack/api/response/NetworkOfferingResponse.java
index b1dcd423117..7a7e371e180 100644
--- a/api/src/org/apache/cloudstack/api/response/NetworkOfferingResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/NetworkOfferingResponse.java
@@ -18,6 +18,7 @@ package org.apache.cloudstack.api.response;
import java.util.Date;
import java.util.List;
+import java.util.Map;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
@@ -83,6 +84,10 @@ public class NetworkOfferingResponse extends BaseResponse {
@SerializedName(ApiConstants.IS_PERSISTENT) @Param(description="true if network offering supports persistent networks, false otherwise")
private Boolean isPersistent;
+
+ @SerializedName(ApiConstants.DETAILS) @Param(description="additional key/value details tied with network offering", since="4.2.0")
+ private Map details;
+
public void setId(String id) {
this.id = id;
@@ -156,5 +161,9 @@ public class NetworkOfferingResponse extends BaseResponse {
public void setIsPersistent(Boolean isPersistent) {
this.isPersistent = isPersistent;
}
+
+ public void setDetails(Map details) {
+ this.details = details;
+ }
}
diff --git a/api/src/org/apache/cloudstack/api/response/NetworkResponse.java b/api/src/org/apache/cloudstack/api/response/NetworkResponse.java
index 3f366e2e576..d6847d55846 100644
--- a/api/src/org/apache/cloudstack/api/response/NetworkResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/NetworkResponse.java
@@ -162,7 +162,18 @@ public class NetworkResponse extends BaseResponse implements ControlledEntityRes
@SerializedName(ApiConstants.IP6_CIDR) @Param(description="the cidr of IPv6 network")
private String ip6Cidr;
-
+
+ @SerializedName(ApiConstants.DISPLAY_NETWORK) @Param(description="an optional field, whether to the display the network to the end user or not.")
+ private Boolean displayNetwork;
+
+ public Boolean getDisplayNetwork() {
+ return displayNetwork;
+ }
+
+ public void setDisplayNetwork(Boolean displayNetwork) {
+ this.displayNetwork = displayNetwork;
+ }
+
public void setId(String id) {
this.id = id;
}
diff --git a/api/src/org/apache/cloudstack/api/response/NicDetailResponse.java b/api/src/org/apache/cloudstack/api/response/NicDetailResponse.java
new file mode 100644
index 00000000000..f8ddf1c8250
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/response/NicDetailResponse.java
@@ -0,0 +1,81 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.response;
+
+import java.util.Date;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+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.google.gson.annotations.SerializedName;
+
+@SuppressWarnings("unused")
+public class NicDetailResponse extends BaseResponse{
+ @SerializedName(ApiConstants.ID)
+ @Param(description = "ID of the nic")
+ private String id;
+
+ @SerializedName(ApiConstants.NAME)
+ @Param(description = "name of the nic detail")
+ private String name;
+
+
+ @SerializedName(ApiConstants.VALUE)
+ @Param(description = "value of the nic detail")
+ private String value;
+
+ @SerializedName(ApiConstants.DISPLAY_NIC) @Param(description="an optional field whether to the display the nic to the end user or not.")
+ private Boolean displayNic;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public String getName() {
+
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Boolean getDisplayNic() {
+ return displayNic;
+ }
+
+ public void setDisplayNic(Boolean displayNic) {
+ this.displayNic = displayNic;
+ }
+}
diff --git a/api/src/org/apache/cloudstack/api/response/PrivateGatewayResponse.java b/api/src/org/apache/cloudstack/api/response/PrivateGatewayResponse.java
index ca760626324..c5c7df59464 100644
--- a/api/src/org/apache/cloudstack/api/response/PrivateGatewayResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/PrivateGatewayResponse.java
@@ -80,6 +80,10 @@ public class PrivateGatewayResponse extends BaseResponse implements ControlledEn
private Boolean sourceNat;
+ @SerializedName(ApiConstants.ACL_ID) @Param(description = "ACL Id set for private gateway")
+ private String aclId;
+
+
@Override
public String getObjectId() {
return this.id;
@@ -154,6 +158,11 @@ public class PrivateGatewayResponse extends BaseResponse implements ControlledEn
this.sourceNat = sourceNat;
}
+ public void setAclId(String aclId) {
+ this.aclId = aclId;
+ }
+
+
}
diff --git a/api/src/org/apache/cloudstack/api/response/ResourceDetailResponse.java b/api/src/org/apache/cloudstack/api/response/ResourceDetailResponse.java
new file mode 100644
index 00000000000..0e917d71904
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/response/ResourceDetailResponse.java
@@ -0,0 +1,81 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.response;
+
+import java.util.Date;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+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.google.gson.annotations.SerializedName;
+
+@SuppressWarnings("unused")
+public class ResourceDetailResponse extends BaseResponse{
+ @SerializedName(ApiConstants.RESOURCE_ID)
+ @Param(description = "ID of the resource")
+ private String resourceId;
+
+ @SerializedName(ApiConstants.RESOURCE_TYPE)
+ @Param(description = "ID of the resource")
+ private String resourceType;
+
+ @SerializedName(ApiConstants.KEY)
+ @Param(description = "key of the resource detail")
+ private String name;
+
+
+ @SerializedName(ApiConstants.VALUE)
+ @Param(description = "value of the resource detail")
+ private String value;
+
+ public String getResourceId() {
+ return resourceId;
+ }
+
+ public void setResourceId(String resourceId) {
+ this.resourceId = resourceId;
+ }
+
+ public String getResourceType() {
+ return resourceType;
+ }
+
+ public void setResourceType(String resourceType) {
+ this.resourceType = resourceType;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+}
diff --git a/api/src/org/apache/cloudstack/api/response/UserVmResponse.java b/api/src/org/apache/cloudstack/api/response/UserVmResponse.java
index da08c94074c..c3bbf8db382 100644
--- a/api/src/org/apache/cloudstack/api/response/UserVmResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/UserVmResponse.java
@@ -177,6 +177,9 @@ public class UserVmResponse extends BaseResponse implements ControlledEntityResp
@Param(description = "list of affinity groups associated with the virtual machine", responseObject = AffinityGroupResponse.class)
private Set affinityGroupList;
+ @SerializedName(ApiConstants.DISPLAY_VM) @Param(description="an optional field whether to the display the vm to the end user or not.")
+ private Boolean displayVm;
+
public UserVmResponse(){
securityGroupList = new LinkedHashSet();
nics = new LinkedHashSet();
@@ -196,7 +199,13 @@ public class UserVmResponse extends BaseResponse implements ControlledEntityResp
return this.id;
}
+ public Boolean getDisplayVm() {
+ return displayVm;
+ }
+ public void setDisplayVm(Boolean displayVm) {
+ this.displayVm = displayVm;
+ }
@Override
public String getObjectId() {
diff --git a/api/src/org/apache/cloudstack/api/response/VirtualRouterProviderResponse.java b/api/src/org/apache/cloudstack/api/response/VirtualRouterProviderResponse.java
index 92d9a1d0cc1..de355bd0c25 100644
--- a/api/src/org/apache/cloudstack/api/response/VirtualRouterProviderResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/VirtualRouterProviderResponse.java
@@ -25,6 +25,7 @@ import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
@EntityReference(value=VirtualRouterProvider.class)
+@SuppressWarnings("unused")
public class VirtualRouterProviderResponse extends BaseResponse implements ControlledEntityResponse {
@SerializedName(ApiConstants.ID) @Param(description="the id of the router")
private String id;
diff --git a/api/src/org/apache/cloudstack/api/response/VolumeDetailResponse.java b/api/src/org/apache/cloudstack/api/response/VolumeDetailResponse.java
new file mode 100644
index 00000000000..04d280d0d9f
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/response/VolumeDetailResponse.java
@@ -0,0 +1,82 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.response;
+
+import java.util.Date;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+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;
+
+@SuppressWarnings("unused")
+public class VolumeDetailResponse extends BaseResponse{
+ @SerializedName(ApiConstants.ID)
+ @Param(description = "ID of the volume")
+ private String id;
+
+ @SerializedName(ApiConstants.NAME)
+ @Param(description = "name of the volume detail")
+ private String name;
+
+
+ @SerializedName(ApiConstants.VALUE)
+ @Param(description = "value of the volume detail")
+ private String value;
+
+ @SerializedName(ApiConstants.DISPLAY_VOLUME) @Param(description="an optional field whether to the display the volume to the end user or not.")
+ private Boolean displayVm;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public String getName() {
+
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Boolean getDisplayVm() {
+ return displayVm;
+ }
+
+ public void setDisplayVm(Boolean displayVm) {
+ this.displayVm = displayVm;
+ }
+}
diff --git a/api/src/org/apache/cloudstack/api/response/VolumeResponse.java b/api/src/org/apache/cloudstack/api/response/VolumeResponse.java
index b928fcd90d0..21d7d1a449f 100644
--- a/api/src/org/apache/cloudstack/api/response/VolumeResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/VolumeResponse.java
@@ -165,6 +165,9 @@ public class VolumeResponse extends BaseResponse implements ControlledViewEntity
@SerializedName(ApiConstants.TAGS) @Param(description="the list of resource tags associated with volume", responseObject = ResourceTagResponse.class)
private Set tags;
+ @SerializedName(ApiConstants.DISPLAY_VOLUME) @Param(description="an optional field whether to the display the volume to the end user or not.")
+ private Boolean displayVm;
+
public VolumeResponse(){
tags = new LinkedHashSet();
}
@@ -324,4 +327,13 @@ public class VolumeResponse extends BaseResponse implements ControlledViewEntity
public void addTag(ResourceTagResponse tag){
this.tags.add(tag);
}
+
+ public Boolean getDisplayVm() {
+ return displayVm;
+ }
+
+ public void setDisplayVm(Boolean displayVm) {
+ this.displayVm = displayVm;
+ }
+
}
diff --git a/api/src/org/apache/cloudstack/network/element/InternalLoadBalancerElementService.java b/api/src/org/apache/cloudstack/network/element/InternalLoadBalancerElementService.java
new file mode 100644
index 00000000000..33a0c64058e
--- /dev/null
+++ b/api/src/org/apache/cloudstack/network/element/InternalLoadBalancerElementService.java
@@ -0,0 +1,56 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.network.element;
+
+import java.util.List;
+
+
+import com.cloud.network.VirtualRouterProvider;
+import com.cloud.utils.component.PluggableService;
+
+public interface InternalLoadBalancerElementService extends PluggableService{
+ /**
+ * Configures existing Internal Load Balancer Element (enables or disables it)
+ * @param id
+ * @param enable
+ * @return
+ */
+ VirtualRouterProvider configureInternalLoadBalancerElement(long id, boolean enable);
+
+ /**
+ * Adds Internal Load Balancer element to the Network Service Provider
+ * @param ntwkSvcProviderId
+ * @return
+ */
+ VirtualRouterProvider addInternalLoadBalancerElement(long ntwkSvcProviderId);
+
+ /**
+ * Retrieves existing Internal Load Balancer element
+ * @param id
+ * @return
+ */
+ VirtualRouterProvider getInternalLoadBalancerElement(long id);
+
+ /**
+ * Searches for existing Internal Load Balancer elements based on parameters passed to the call
+ * @param id
+ * @param ntwkSvsProviderId
+ * @param enabled
+ * @return
+ */
+ List extends VirtualRouterProvider> searchForInternalLoadBalancerElements(Long id, Long ntwkSvsProviderId, Boolean enabled);
+}
diff --git a/api/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerContainer.java b/api/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerContainer.java
new file mode 100644
index 00000000000..df94d3d4338
--- /dev/null
+++ b/api/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerContainer.java
@@ -0,0 +1,28 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.network.lb;
+
+import com.cloud.network.rules.LoadBalancerContainer;
+import com.cloud.utils.net.Ip;
+
+public interface ApplicationLoadBalancerContainer extends LoadBalancerContainer{
+
+ public Long getSourceIpNetworkId();
+
+ public Ip getSourceIp();
+
+}
diff --git a/api/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerRule.java b/api/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerRule.java
new file mode 100644
index 00000000000..f4acb734c8b
--- /dev/null
+++ b/api/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerRule.java
@@ -0,0 +1,24 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.cloudstack.network.lb;
+
+import com.cloud.network.rules.LoadBalancer;
+
+public interface ApplicationLoadBalancerRule extends ApplicationLoadBalancerContainer, LoadBalancer{
+ int getInstancePort();
+}
diff --git a/api/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerService.java b/api/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerService.java
new file mode 100644
index 00000000000..b2ac358555b
--- /dev/null
+++ b/api/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerService.java
@@ -0,0 +1,42 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.cloudstack.network.lb;
+
+import java.util.List;
+
+import org.apache.cloudstack.api.command.user.loadbalancer.ListApplicationLoadBalancersCmd;
+
+import com.cloud.exception.InsufficientAddressCapacityException;
+import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.network.rules.LoadBalancerContainer.Scheme;
+import com.cloud.utils.Pair;
+
+public interface ApplicationLoadBalancerService {
+
+ ApplicationLoadBalancerRule createApplicationLoadBalancer(String name, String description, Scheme scheme, long sourceIpNetworkId, String sourceIp,
+ int sourcePort, int instancePort, String algorithm, long networkId, long lbOwnerId) throws InsufficientAddressCapacityException,
+ NetworkRuleConflictException, InsufficientVirtualNetworkCapcityException;
+
+ boolean deleteApplicationLoadBalancer(long id);
+
+ Pair, Integer> listApplicationLoadBalancers(ListApplicationLoadBalancersCmd cmd);
+
+ ApplicationLoadBalancerRule getApplicationLoadBalancer(long ruleId);
+
+}
diff --git a/api/src/com/cloud/network/firewall/NetworkACLService.java b/api/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMService.java
similarity index 50%
rename from api/src/com/cloud/network/firewall/NetworkACLService.java
rename to api/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMService.java
index 97de496f64f..91cd88d91c1 100644
--- a/api/src/com/cloud/network/firewall/NetworkACLService.java
+++ b/api/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMService.java
@@ -5,7 +5,7 @@
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
-//
+//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
@@ -14,38 +14,21 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-package com.cloud.network.firewall;
+package org.apache.cloudstack.network.lb;
-
-import java.util.List;
-
-import org.apache.cloudstack.api.command.user.network.ListNetworkACLsCmd;
-
-import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.rules.FirewallRule;
+import com.cloud.exception.StorageUnavailableException;
+import com.cloud.network.router.VirtualRouter;
import com.cloud.user.Account;
-import com.cloud.utils.Pair;
-public interface NetworkACLService {
- FirewallRule getNetworkACL(long ruleId);
- boolean applyNetworkACLs(long networkId, Account caller) throws ResourceUnavailableException;
+public interface InternalLoadBalancerVMService {
- /**
- * @param createNetworkACLCmd
- * @return
- */
- FirewallRule createNetworkACL(FirewallRule acl) throws NetworkRuleConflictException;
- /**
- * @param ruleId
- * @param apply
- * @return
- */
- boolean revokeNetworkACL(long ruleId, boolean apply);
- /**
- * @param listNetworkACLsCmd
- * @return
- */
- Pair, Integer> listNetworkACLs(ListNetworkACLsCmd cmd);
+ VirtualRouter startInternalLbVm(long internalLbVmId, Account caller, long callerUserId)
+ throws StorageUnavailableException, InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException;
+
+ VirtualRouter stopInternalLbVm(long vmId, boolean forced, Account caller, long callerUserId)
+ throws ConcurrentOperationException, ResourceUnavailableException;
}
diff --git a/api/src/org/apache/cloudstack/query/QueryService.java b/api/src/org/apache/cloudstack/query/QueryService.java
index 6bb24b52175..1a9e36eade6 100644
--- a/api/src/org/apache/cloudstack/query/QueryService.java
+++ b/api/src/org/apache/cloudstack/query/QueryService.java
@@ -18,6 +18,7 @@ package org.apache.cloudstack.query;
import org.apache.cloudstack.affinity.AffinityGroupResponse;
import org.apache.cloudstack.api.command.admin.host.ListHostsCmd;
+import org.apache.cloudstack.api.command.admin.internallb.ListInternalLBVMsCmd;
import org.apache.cloudstack.api.command.admin.router.ListRoutersCmd;
import org.apache.cloudstack.api.command.admin.storage.ListImageStoresCmd;
import org.apache.cloudstack.api.command.admin.storage.ListStoragePoolsCmd;
@@ -36,6 +37,7 @@ import org.apache.cloudstack.api.command.user.tag.ListTagsCmd;
import org.apache.cloudstack.api.command.user.template.ListTemplatesCmd;
import org.apache.cloudstack.api.command.user.vm.ListVMsCmd;
import org.apache.cloudstack.api.command.user.vmgroup.ListVMGroupsCmd;
+import org.apache.cloudstack.api.command.user.volume.ListResourceDetailsCmd;
import org.apache.cloudstack.api.command.user.volume.ListVolumesCmd;
import org.apache.cloudstack.api.command.user.zone.ListZonesByCmd;
import org.apache.cloudstack.api.response.AccountResponse;
@@ -59,9 +61,12 @@ import org.apache.cloudstack.api.response.UserResponse;
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.api.response.*;
import com.cloud.exception.PermissionDeniedException;
+import java.util.List;
+
/**
* Service used for list api query.
*
@@ -111,4 +116,9 @@ public interface QueryService {
public ListResponse listIsos(ListIsosCmd cmd);
public ListResponse listAffinityGroups(Long affinityGroupId, String affinityGroupName,
String affinityGroupType, Long vmId, Long startIndex, Long pageSize);
+
+ public List listResource(ListResourceDetailsCmd cmd);
+
+ ListResponse searchForInternalLbVms(ListInternalLBVMsCmd cmd);
+
}
diff --git a/client/pom.xml b/client/pom.xml
index 44cdbca14d7..8ffba2be871 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -85,6 +85,11 @@
cloud-plugin-network-midonet
${project.version}
+
+ org.apache.cloudstack
+ cloud-plugin-network-internallb
+ ${project.version}
+
org.apache.cloudstack
cloud-plugin-hypervisor-xen
diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in
index bb46b239327..2ec6b59e96b 100644
--- a/client/tomcatconf/applicationContext.xml.in
+++ b/client/tomcatconf/applicationContext.xml.in
@@ -251,6 +251,8 @@
+
+
@@ -261,7 +263,9 @@
+
+
@@ -359,6 +363,7 @@
+
@@ -368,6 +373,9 @@
+
+
+
diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in
index 0ea800bf657..0520f4a2062 100644
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -67,7 +67,7 @@ getVMPassword=15
restoreVirtualMachine=15
changeServiceForVirtualMachine=15
scaleVirtualMachine=15
-assignVirtualMachine=1
+assignVirtualMachine=7
migrateVirtualMachine=1
migrateVirtualMachineWithVolume=1
recoverVirtualMachine=7
@@ -278,6 +278,11 @@ listVolumes=15
extractVolume=15
migrateVolume=15
resizeVolume=15
+updateVolume=1
+addVolumeDetail=1
+updateVolumeDetail=1
+removeVolumeDetail=1
+listVolumeDetails=1
#### registration command: FIXME -- this really should be something in management server that
#### generates a new key for the user and they just have to
@@ -348,6 +353,10 @@ updateNetwork=15
addNicToVirtualMachine=15
removeNicFromVirtualMachine=15
updateDefaultNicForVirtualMachine=15
+addNicDetail=1
+updateNicDetail=1
+removeNicDetail=1
+listNicDetails=1
####
addIpToNic=15
@@ -439,8 +448,14 @@ deletePrivateGateway=1
#### Network ACL commands
createNetworkACL=15
+updateNetworkACLItem=15
deleteNetworkACL=15
listNetworkACLs=15
+createNetworkACLList=15
+deleteNetworkACLList=15
+replaceNetworkACLList=15
+listNetworkACLLists=15
+
#### Static route commands
createStaticRoute=15
@@ -452,6 +467,11 @@ createTags=15
deleteTags=15
listTags=15
+#### Meta Data commands
+addResourceDetail=1
+removeResourceDetail=1
+listResourceDetails=1
+
### Site-to-site VPN commands
createVpnCustomerGateway=15
createVpnGateway=15
@@ -583,6 +603,17 @@ revertToVMSnapshot=15
#### Baremetal commands
addBaremetalHost=1
+#### New Load Balancer commands
+createLoadBalancer=15
+listLoadBalancers=15
+deleteLoadBalancer=15
+
+#Internal Load Balancer Element commands
+configureInternalLoadBalancerElement=7
+createInternalLoadBalancerElement=7
+listInternalLoadBalancerElements=7
+
+
#### Affinity group commands
createAffinityGroup=15
deleteAffinityGroup=15
@@ -600,5 +631,10 @@ addCiscoAsa1000vResource=1
deleteCiscoAsa1000vResource=1
listCiscoAsa1000vResources=1
+#### Internal LB VM commands
+stopInternalLoadBalancerVM=1
+startInternalLoadBalancerVM=1
+listInternalLoadBalancerVMs=1
+
### Network Isolation methods listing
listNetworkIsolationMethods=1
diff --git a/client/tomcatconf/componentContext.xml.in b/client/tomcatconf/componentContext.xml.in
index 7a469816f82..8a45e5fea85 100644
--- a/client/tomcatconf/componentContext.xml.in
+++ b/client/tomcatconf/componentContext.xml.in
@@ -198,6 +198,7 @@
+
@@ -241,6 +242,7 @@
+
+
+ Storage Setup
+ &PRODUCT; is designed to work with a wide variety of commodity and enterprise-grade storage. Local disk may be used as well, if supported by the selected hypervisor. Storage type support for guest virtual disks differs based on hypervisor selection.
+
+
+
+
+
+ XenServer
+ vSphere
+ KVM
+
+
+
+
+ NFS
+ Supported
+ Supported
+ Supported
+
+
+ iSCSI
+ Supported
+ Supported via VMFS
+ Supported via Clustered Filesystems
+
+
+ Fiber Channel
+ Supported via Pre-existing SR
+ Supported
+ Supported via Clustered Filesystems
+
+
+ Local Disk
+ Supported
+ Supported
+ Supported
+
+
+
+
+ The use of the Cluster Logical Volume Manager (CLVM) for KVM is not officially supported with &PRODUCT;.
+
+ Small-Scale Setup
+ In a small-scale setup, a single NFS server can function as both primary and secondary storage. The NFS server just needs to export two separate shares, one for primary storage and the other for secondary storage.
+
+
+ Secondary Storage
+ &PRODUCT; is designed to work with any scalable secondary storage system. The only requirement is the secondary storage system supports the NFS protocol.
+
+ The storage server should be a machine with a large number of disks. The disks should ideally be managed by a hardware RAID controller. Modern hardware RAID controllers support hot plug functionality independent of the operating system so you can replace faulty disks without impacting the running operating system.
+
+
+
+ Example Configurations
+ In this section we go through a few examples of how to set up storage to work properly on a few types of NFS and iSCSI storage systems.
+
+ Linux NFS on Local Disks and DAS
+ This section describes how to configure an NFS export on a standard Linux installation. The exact commands might vary depending on the operating system version.
+
+ Install the RHEL/CentOS distribution on the storage server.
+ If the root volume is more than 2 TB in size, create a smaller boot volume to install RHEL/CentOS. A root volume of 20 GB should be sufficient.
+ After the system is installed, create a directory called /export. This can each be a directory in the root partition itself or a mount point for a large disk volume.
+ If you have more than 16TB of storage on one host, create multiple EXT3 file systems and multiple NFS exports. Individual EXT3 file systems cannot exceed 16TB.
+
+ After /export directory is created, run the following command to configure it as an NFS export.
+ # echo "/export <CIDR>(rw,async,no_root_squash)" >> /etc/exports
+ Adjust the above command to suit your deployment needs.
+
+
+ Limiting NFS export. It is highly recommended that you limit the NFS export to a particular subnet by specifying a subnet mask (e.g.,”192.168.1.0/24”). By allowing access from only within the expected cluster, you avoid having non-pool member mount the storage. The limit you place must include the management network(s) and the storage network(s). If the two are the same network then one CIDR is sufficient. If you have a separate storage network you must provide separate CIDR’s for both or one CIDR that is broad enough to span both.
+ The following is an example with separate CIDRs:
+ /export 192.168.1.0/24(rw,async,no_root_squash) 10.50.1.0/24(rw,async,no_root_squash)
+
+
+ Removing the async flag. The async flag improves performance by allowing the NFS server to respond before writes are committed to the disk. Remove the async flag in your mission critical production deployment.
+
+
+
+
+ Run the following command to enable NFS service.
+ # chkconfig nfs on
+
+
+ Edit the /etc/sysconfig/nfs file and uncomment the following lines.
+ LOCKD_TCPPORT=32803
+LOCKD_UDPPORT=32769
+MOUNTD_PORT=892
+RQUOTAD_PORT=875
+STATD_PORT=662
+STATD_OUTGOING_PORT=2020
+
+
+ Edit the /etc/sysconfig/iptables file and add the following lines at the beginning of the INPUT chain.
+
+-A INPUT -m state --state NEW -p udp --dport 111 -j ACCEPT
+-A INPUT -m state --state NEW -p tcp --dport 111 -j ACCEPT
+-A INPUT -m state --state NEW -p tcp --dport 2049 -j ACCEPT
+-A INPUT -m state --state NEW -p tcp --dport 32803 -j ACCEPT
+-A INPUT -m state --state NEW -p udp --dport 32769 -j ACCEPT
+-A INPUT -m state --state NEW -p tcp --dport 892 -j ACCEPT
+-A INPUT -m state --state NEW -p udp --dport 892 -j ACCEPT
+-A INPUT -m state --state NEW -p tcp --dport 875 -j ACCEPT
+-A INPUT -m state --state NEW -p udp --dport 875 -j ACCEPT
+-A INPUT -m state --state NEW -p tcp --dport 662 -j ACCEPT
+-A INPUT -m state --state NEW -p udp --dport 662 -j ACCEPT
+
+
+
+ Reboot the server.
+ An NFS share called /export is now set up.
+
+
+ When copying and pasting a command, be sure the command has pasted as a single line before executing. Some document viewers may introduce unwanted line breaks in copied text.
+
+
+ Linux NFS on iSCSI
+ Use the following steps to set up a Linux NFS server export on an iSCSI volume. These steps apply to RHEL/CentOS 5 distributions.
+
+
+ Install iscsiadm.
+
+# yum install iscsi-initiator-utils
+# service iscsi start
+# chkconfig --add iscsi
+# chkconfig iscsi on
+
+
+
+ Discover the iSCSI target.
+ # iscsiadm -m discovery -t st -p <iSCSI Server IP address>:3260
+ For example:
+ # iscsiadm -m discovery -t st -p 172.23.10.240:3260
+ 172.23.10.240:3260,1 iqn.2001-05.com.equallogic:0-8a0906-83bcb3401-16e0002fd0a46f3d-rhel5-test
+
+
+ Log in.
+ # iscsiadm -m node -T <Complete Target Name> -l -p <Group IP>:3260
+ For example:
+ # iscsiadm -m node -l -T iqn.2001-05.com.equallogic:83bcb3401-16e0002fd0a46f3d-rhel5-test -p 172.23.10.240:3260
+
+
+ Discover the SCSI disk. For example:
+
+# iscsiadm -m session -P3 | grep Attached
+Attached scsi disk sdb State: running
+
+
+
+ Format the disk as ext3 and mount the volume.
+ # mkfs.ext3 /dev/sdb
+# mkdir -p /export
+# mount /dev/sdb /export
+
+
+
+ Add the disk to /etc/fstab to make sure it gets mounted on boot.
+ /dev/sdb /export ext3 _netdev 0 0
+
+
+ Now you can set up /export as an NFS share.
+
+
+ Limiting NFS export. In order to avoid data loss, it is highly recommended that you limit the NFS export to a particular subnet by specifying a subnet mask (e.g.,”192.168.1.0/24”). By allowing access from only within the expected cluster, you avoid having non-pool member mount the storage and inadvertently delete all its data. The limit you place must include the management network(s) and the storage network(s). If the two are the same network then one CIDR is sufficient. If you have a separate storage network you must provide separate CIDRs for both or one CIDR that is broad enough to span both.
+ The following is an example with separate CIDRs:
+ /export 192.168.1.0/24(rw,async,no_root_squash) 10.50.1.0/24(rw,async,no_root_squash)
+
+ Removing the async flag. The async flag improves performance by allowing the NFS server to respond before writes are committed to the disk. Remove the async flag in your mission critical production deployment.
+
+
+
+
diff --git a/docs/en-US/sys-offering-sysvm.xml b/docs/en-US/sys-offering-sysvm.xml
index cccf3e04796..563dd6f5ebf 100644
--- a/docs/en-US/sys-offering-sysvm.xml
+++ b/docs/en-US/sys-offering-sysvm.xml
@@ -65,7 +65,7 @@
Restart &PRODUCT; Management Server. Restarting is required because the default
offerings are loaded into the memory at startup.
- service cloud-management restart
+ service cloudstack-management restart
Destroy the existing CPVM or SSVM offerings and wait for them to be recreated. The new
diff --git a/docs/en-US/zone-add.xml b/docs/en-US/zone-add.xml
index 4f6606fce03..3ca5789cd99 100644
--- a/docs/en-US/zone-add.xml
+++ b/docs/en-US/zone-add.xml
@@ -42,7 +42,7 @@
Restart the Management Server.
- # service cloud-management restart
+ # service cloudstack-management restart
Refresh the &PRODUCT; UI browser tab and log back in.
diff --git a/engine/schema/src/com/cloud/dc/dao/VlanDao.java b/engine/schema/src/com/cloud/dc/dao/VlanDao.java
index cc82632e9e3..605fb2020df 100755
--- a/engine/schema/src/com/cloud/dc/dao/VlanDao.java
+++ b/engine/schema/src/com/cloud/dc/dao/VlanDao.java
@@ -16,13 +16,13 @@
// under the License.
package com.cloud.dc.dao;
-import java.util.List;
-
import com.cloud.dc.Vlan;
import com.cloud.dc.Vlan.VlanType;
import com.cloud.dc.VlanVO;
import com.cloud.utils.db.GenericDao;
+import java.util.List;
+
public interface VlanDao extends GenericDao {
VlanVO findByZoneAndVlanId(long zoneId, String vlanId);
@@ -52,4 +52,6 @@ public interface VlanDao extends GenericDao {
List listVlansByPhysicalNetworkId(long physicalNetworkId);
List listZoneWideNonDedicatedVlans(long zoneId);
+
+ List listVlansByNetworkIdAndGateway(long networkid, String gateway);
}
diff --git a/engine/schema/src/com/cloud/dc/dao/VlanDaoImpl.java b/engine/schema/src/com/cloud/dc/dao/VlanDaoImpl.java
index 100295b4b5f..e8c68b18a6b 100755
--- a/engine/schema/src/com/cloud/dc/dao/VlanDaoImpl.java
+++ b/engine/schema/src/com/cloud/dc/dao/VlanDaoImpl.java
@@ -16,19 +16,6 @@
// under the License.
package com.cloud.dc.dao;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-import javax.naming.ConfigurationException;
-
-import org.springframework.stereotype.Component;
-
import com.cloud.dc.AccountVlanMapVO;
import com.cloud.dc.PodVlanMapVO;
import com.cloud.dc.Vlan;
@@ -43,6 +30,17 @@ import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.exception.CloudRuntimeException;
+import org.springframework.stereotype.Component;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
@Component
@Local(value={VlanDao.class})
@@ -59,6 +57,7 @@ public class VlanDaoImpl extends GenericDaoBase implements VlanDao
protected SearchBuilder NetworkVlanSearch;
protected SearchBuilder PhysicalNetworkVlanSearch;
protected SearchBuilder ZoneWideNonDedicatedVlanSearch;
+ protected SearchBuilder VlanGatewaysearch;
protected SearchBuilder AccountVlanMapSearch;
@@ -103,6 +102,11 @@ public class VlanDaoImpl extends GenericDaoBase implements VlanDao
PhysicalNetworkVlanSearch = createSearchBuilder();
PhysicalNetworkVlanSearch.and("physicalNetworkId", PhysicalNetworkVlanSearch.entity().getPhysicalNetworkId(), SearchCriteria.Op.EQ);
PhysicalNetworkVlanSearch.done();
+
+ VlanGatewaysearch = createSearchBuilder();
+ VlanGatewaysearch.and("gateway", VlanGatewaysearch.entity().getVlanGateway(), SearchCriteria.Op.EQ);
+ VlanGatewaysearch.and("networkid", VlanGatewaysearch.entity().getNetworkId(), SearchCriteria.Op.EQ);
+ VlanGatewaysearch.done();
}
@Override
@@ -317,6 +321,14 @@ public class VlanDaoImpl extends GenericDaoBase implements VlanDao
return listBy(sc);
}
+ @Override
+ public List listVlansByNetworkIdAndGateway(long networkid, String gateway){
+ SearchCriteria sc = VlanGatewaysearch.create();
+ sc.setParameters("networkid", networkid);
+ sc.setParameters("gateway", gateway);
+ return listBy(sc);
+ }
+
@Override
public List listVlansByPhysicalNetworkId(long physicalNetworkId) {
SearchCriteria sc = PhysicalNetworkVlanSearch.create();
diff --git a/engine/schema/src/com/cloud/network/dao/FirewallRulesDao.java b/engine/schema/src/com/cloud/network/dao/FirewallRulesDao.java
index 0bbaa93363d..6b9b3bb83e5 100644
--- a/engine/schema/src/com/cloud/network/dao/FirewallRulesDao.java
+++ b/engine/schema/src/com/cloud/network/dao/FirewallRulesDao.java
@@ -18,7 +18,6 @@ package com.cloud.network.dao;
import java.util.List;
-import com.cloud.host.HostVO;
import com.cloud.network.rules.FirewallRule;
import com.cloud.network.rules.FirewallRuleVO;
import com.cloud.utils.db.GenericDao;
diff --git a/engine/schema/src/com/cloud/network/dao/IPAddressDao.java b/engine/schema/src/com/cloud/network/dao/IPAddressDao.java
index 3d588fa9307..fecd44a32b1 100755
--- a/engine/schema/src/com/cloud/network/dao/IPAddressDao.java
+++ b/engine/schema/src/com/cloud/network/dao/IPAddressDao.java
@@ -16,12 +16,12 @@
// under the License.
package com.cloud.network.dao;
-import java.util.List;
-
import com.cloud.dc.Vlan.VlanType;
import com.cloud.utils.db.GenericDao;
import com.cloud.utils.net.Ip;
+import java.util.List;
+
public interface IPAddressDao extends GenericDao {
IPAddressVO markAsUnavailable(long ipAddressId);
@@ -68,4 +68,8 @@ public interface IPAddressDao extends GenericDao {
IPAddressVO findByAssociatedVmIdAndVmIp(long vmId, String vmIp);
IPAddressVO findByIpAndNetworkId(long networkId, String ipAddress);
+
+ IPAddressVO findByIpAndVlanId(String ipAddress, long vlanid);
+
+ long countFreeIpsInVlan(long vlanDbId);
}
diff --git a/engine/schema/src/com/cloud/network/dao/IPAddressDaoImpl.java b/engine/schema/src/com/cloud/network/dao/IPAddressDaoImpl.java
index 73f310fd628..1839ca45476 100755
--- a/engine/schema/src/com/cloud/network/dao/IPAddressDaoImpl.java
+++ b/engine/schema/src/com/cloud/network/dao/IPAddressDaoImpl.java
@@ -16,26 +16,12 @@
// under the License.
package com.cloud.network.dao;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.util.Date;
-import java.util.List;
-
-import javax.annotation.PostConstruct;
-import javax.ejb.Local;
-import javax.inject.Inject;
-
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
import com.cloud.dc.Vlan.VlanType;
import com.cloud.dc.VlanVO;
import com.cloud.dc.dao.VlanDao;
-import com.cloud.dc.dao.VlanDaoImpl;
import com.cloud.network.IpAddress.State;
import com.cloud.server.ResourceTag.TaggedResourceType;
import com.cloud.tags.dao.ResourceTagDao;
-import com.cloud.tags.dao.ResourceTagsDaoImpl;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.GenericSearchBuilder;
@@ -46,6 +32,16 @@ import com.cloud.utils.db.SearchCriteria.Func;
import com.cloud.utils.db.SearchCriteria.Op;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.net.Ip;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+import javax.ejb.Local;
+import javax.inject.Inject;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.Date;
+import java.util.List;
@Component
@Local(value = { IPAddressDao.class })
@@ -192,6 +188,14 @@ public class IPAddressDaoImpl extends GenericDaoBase implemen
return findOneBy(sc);
}
+ @Override
+ public IPAddressVO findByIpAndVlanId(String ipAddress, long vlanid) {
+ SearchCriteria sc = AllFieldsSearch.create();
+ sc.setParameters("ipAddress", ipAddress);
+ sc.setParameters("vlan", vlanid);
+ return findOneBy(sc);
+ }
+
@Override
public IPAddressVO findByIpAndDcId(long dcId, String ipAddress) {
SearchCriteria sc = AllFieldsSearch.create();
@@ -332,6 +336,13 @@ public class IPAddressDaoImpl extends GenericDaoBase implemen
return customSearch(sc, null).get(0);
}
+ @Override
+ public long countFreeIpsInVlan(long vlanDbId) {
+ SearchCriteria sc = VlanDbIdSearchUnallocated.create();
+ sc.setParameters("vlanDbId", vlanDbId);
+ return listBy(sc).size();
+ }
+
@Override
public List listByAssociatedVpc(long vpcId, Boolean isSourceNat) {
SearchCriteria sc = AllFieldsSearch.create();
diff --git a/engine/schema/src/com/cloud/network/dao/IPAddressVO.java b/engine/schema/src/com/cloud/network/dao/IPAddressVO.java
index c5c78e557ae..ae27e95ce4b 100644
--- a/engine/schema/src/com/cloud/network/dao/IPAddressVO.java
+++ b/engine/schema/src/com/cloud/network/dao/IPAddressVO.java
@@ -31,12 +31,8 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
-import org.apache.cloudstack.api.Identity;
-
import com.cloud.network.IpAddress;
-import com.cloud.network.IpAddress.State;
import com.cloud.utils.net.Ip;
-import org.apache.cloudstack.api.InternalIdentity;
/**
* A bean representing a public IP Address
@@ -304,4 +300,9 @@ public class IPAddressVO implements IpAddress {
public void setVmIp(String vmIp) {
this.vmIp = vmIp;
}
+
+ @Override
+ public Long getNetworkId() {
+ return sourceNetworkId;
+ }
}
diff --git a/engine/schema/src/com/cloud/network/dao/LoadBalancerDao.java b/engine/schema/src/com/cloud/network/dao/LoadBalancerDao.java
index 611282e5693..331f7555d81 100644
--- a/engine/schema/src/com/cloud/network/dao/LoadBalancerDao.java
+++ b/engine/schema/src/com/cloud/network/dao/LoadBalancerDao.java
@@ -18,19 +18,15 @@ package com.cloud.network.dao;
import java.util.List;
+import com.cloud.network.rules.LoadBalancerContainer.Scheme;
import com.cloud.utils.db.GenericDao;
public interface LoadBalancerDao extends GenericDao {
- List listInstancesByLoadBalancer(long loadBalancerId);
List listByIpAddress(long ipAddressId);
- LoadBalancerVO findByIpAddressAndPublicPort(long ipAddressId, String publicPort);
+ List listByNetworkIdAndScheme(long networkId, Scheme scheme);
- LoadBalancerVO findByAccountAndName(Long accountId, String name);
-
- List listByNetworkId(long networkId);
-
- List listInTransitionStateByNetworkId(long networkId);
+ List listInTransitionStateByNetworkIdAndScheme(long networkId, Scheme scheme);
}
diff --git a/engine/schema/src/com/cloud/network/dao/LoadBalancerDaoImpl.java b/engine/schema/src/com/cloud/network/dao/LoadBalancerDaoImpl.java
index f211a7f1a79..c20d8b23d6a 100644
--- a/engine/schema/src/com/cloud/network/dao/LoadBalancerDaoImpl.java
+++ b/engine/schema/src/com/cloud/network/dao/LoadBalancerDaoImpl.java
@@ -16,39 +16,24 @@
// under the License.
package com.cloud.network.dao;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.util.ArrayList;
import java.util.List;
import javax.ejb.Local;
import javax.inject.Inject;
-import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import com.cloud.network.rules.FirewallRule.State;
+import com.cloud.network.rules.LoadBalancerContainer.Scheme;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
import com.cloud.utils.db.SearchCriteria.Op;
-import com.cloud.utils.db.Transaction;
@Component
@Local(value = { LoadBalancerDao.class })
public class LoadBalancerDaoImpl extends GenericDaoBase implements LoadBalancerDao {
- private static final Logger s_logger = Logger.getLogger(LoadBalancerDaoImpl.class);
- private static final String LIST_INSTANCES_BY_LOAD_BALANCER = "SELECT vm.id " +
- " FROM vm_instance vm, load_balancer lb, ip_forwarding fwd, user_ip_address ip " +
- " WHERE lb.id = ? AND " +
- " fwd.group_id = lb.id AND " +
- " fwd.forwarding = 0 AND " +
- " fwd.private_ip_address = vm.private_ip_address AND " +
- " lb.ip_address = ip.public_ip_address AND " +
- " ip.data_center_id = vm.data_center_id ";
private final SearchBuilder ListByIp;
- private final SearchBuilder IpAndPublicPortSearch;
- private final SearchBuilder AccountAndNameSearch;
protected final SearchBuilder TransitionStateSearch;
@Inject protected FirewallRulesCidrsDao _portForwardingRulesCidrsDao;
@@ -57,45 +42,16 @@ public class LoadBalancerDaoImpl extends GenericDaoBase im
ListByIp = createSearchBuilder();
ListByIp.and("ipAddressId", ListByIp.entity().getSourceIpAddressId(), SearchCriteria.Op.EQ);
ListByIp.and("networkId", ListByIp.entity().getNetworkId(), SearchCriteria.Op.EQ);
+ ListByIp.and("scheme", ListByIp.entity().getScheme(), SearchCriteria.Op.EQ);
ListByIp.done();
- IpAndPublicPortSearch = createSearchBuilder();
- IpAndPublicPortSearch.and("ipAddressId", IpAndPublicPortSearch.entity().getSourceIpAddressId(), SearchCriteria.Op.EQ);
- IpAndPublicPortSearch.and("publicPort", IpAndPublicPortSearch.entity().getSourcePortStart(), SearchCriteria.Op.EQ);
- IpAndPublicPortSearch.done();
-
- AccountAndNameSearch = createSearchBuilder();
- AccountAndNameSearch.and("accountId", AccountAndNameSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
- AccountAndNameSearch.and("name", AccountAndNameSearch.entity().getName(), SearchCriteria.Op.EQ);
- AccountAndNameSearch.done();
-
TransitionStateSearch = createSearchBuilder();
TransitionStateSearch.and("networkId", TransitionStateSearch.entity().getNetworkId(), Op.EQ);
TransitionStateSearch.and("state", TransitionStateSearch.entity().getState(), Op.IN);
+ TransitionStateSearch.and("scheme", TransitionStateSearch.entity().getScheme(), Op.EQ);
TransitionStateSearch.done();
}
-
- @Override
- public List listInstancesByLoadBalancer(long loadBalancerId) {
- Transaction txn = Transaction.currentTxn();
- String sql = LIST_INSTANCES_BY_LOAD_BALANCER;
- PreparedStatement pstmt = null;
- List instanceList = new ArrayList();
- try {
- pstmt = txn.prepareAutoCloseStatement(sql);
- pstmt.setLong(1, loadBalancerId);
-
- ResultSet rs = pstmt.executeQuery();
- while (rs.next()) {
- Long vmId = rs.getLong(1);
- instanceList.add(vmId);
- }
- } catch (Exception ex) {
- s_logger.error("error getting recent usage network stats", ex);
- }
- return instanceList;
- }
-
+
@Override
public List listByIpAddress(long ipAddressId) {
SearchCriteria sc = ListByIp.create();
@@ -104,33 +60,19 @@ public class LoadBalancerDaoImpl extends GenericDaoBase im
}
@Override
- public List listByNetworkId(long networkId) {
+ public List listByNetworkIdAndScheme(long networkId, Scheme scheme) {
SearchCriteria sc = ListByIp.create();
sc.setParameters("networkId", networkId);
+ sc.setParameters("scheme", scheme);
return listBy(sc);
}
@Override
- public LoadBalancerVO findByIpAddressAndPublicPort(long ipAddressId, String publicPort) {
- SearchCriteria sc = IpAndPublicPortSearch.create();
- sc.setParameters("ipAddressId", ipAddressId);
- sc.setParameters("publicPort", publicPort);
- return findOneBy(sc);
- }
-
- @Override
- public LoadBalancerVO findByAccountAndName(Long accountId, String name) {
- SearchCriteria sc = AccountAndNameSearch.create();
- sc.setParameters("accountId", accountId);
- sc.setParameters("name", name);
- return findOneBy(sc);
- }
-
- @Override
- public List listInTransitionStateByNetworkId(long networkId) {
+ public List listInTransitionStateByNetworkIdAndScheme(long networkId, Scheme scheme) {
SearchCriteria sc = TransitionStateSearch.create();
sc.setParameters("networkId", networkId);
sc.setParameters("state", State.Add.toString(), State.Revoke.toString());
+ sc.setParameters("scheme", scheme);
return listBy(sc);
}
diff --git a/engine/schema/src/com/cloud/network/dao/LoadBalancerVO.java b/engine/schema/src/com/cloud/network/dao/LoadBalancerVO.java
index 5422f41774b..fee88cf7b0a 100644
--- a/engine/schema/src/com/cloud/network/dao/LoadBalancerVO.java
+++ b/engine/schema/src/com/cloud/network/dao/LoadBalancerVO.java
@@ -19,6 +19,8 @@ package com.cloud.network.dao;
import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
@@ -26,6 +28,12 @@ import com.cloud.network.rules.FirewallRuleVO;
import com.cloud.network.rules.LoadBalancer;
import com.cloud.utils.net.NetUtils;
+/**
+ * This VO represent Public Load Balancer
+ * It references source ip address by its Id.
+ * To get the VO for Internal Load Balancer rule, please refer to LoadBalancerRuleVO
+ *
+ */
@Entity
@Table(name=("load_balancing_rules"))
@DiscriminatorValue(value="LoadBalancing")
@@ -46,6 +54,10 @@ public class LoadBalancerVO extends FirewallRuleVO implements LoadBalancer {
@Column(name="default_port_end")
private int defaultPortEnd;
+
+ @Enumerated(value=EnumType.STRING)
+ @Column(name="scheme")
+ Scheme scheme = Scheme.Public;
public LoadBalancerVO() {
}
@@ -57,6 +69,7 @@ public class LoadBalancerVO extends FirewallRuleVO implements LoadBalancer {
this.algorithm = algorithm;
this.defaultPortStart = dstPort;
this.defaultPortEnd = dstPort;
+ this.scheme = Scheme.Public;
}
@Override
@@ -94,5 +107,10 @@ public class LoadBalancerVO extends FirewallRuleVO implements LoadBalancer {
public void setDescription(String description) {
this.description = description;
+ }
+
+ @Override
+ public Scheme getScheme() {
+ return scheme;
}
}
diff --git a/engine/schema/src/com/cloud/network/dao/NetworkDao.java b/engine/schema/src/com/cloud/network/dao/NetworkDao.java
index 1d3f0b84aa6..43cabe751f6 100644
--- a/engine/schema/src/com/cloud/network/dao/NetworkDao.java
+++ b/engine/schema/src/com/cloud/network/dao/NetworkDao.java
@@ -111,4 +111,6 @@ public interface NetworkDao extends GenericDao , StateDao listNetworksByAccount(long accountId, long zoneId, Network.GuestType type, boolean isSystem);
List listRedundantNetworks();
+
+ List listByAclId(long aclId);
}
diff --git a/engine/schema/src/com/cloud/network/dao/NetworkDaoImpl.java b/engine/schema/src/com/cloud/network/dao/NetworkDaoImpl.java
index 1bc8973bc50..5b3b526b640 100644
--- a/engine/schema/src/com/cloud/network/dao/NetworkDaoImpl.java
+++ b/engine/schema/src/com/cloud/network/dao/NetworkDaoImpl.java
@@ -104,6 +104,7 @@ public class NetworkDaoImpl extends GenericDaoBase implements N
AllFieldsSearch.and("physicalNetwork", AllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
AllFieldsSearch.and("broadcastUri", AllFieldsSearch.entity().getBroadcastUri(), Op.EQ);
AllFieldsSearch.and("vpcId", AllFieldsSearch.entity().getVpcId(), Op.EQ);
+ AllFieldsSearch.and("aclId", AllFieldsSearch.entity().getNetworkACLId(), Op.EQ);
SearchBuilder join1 = _ntwkOffDao.createSearchBuilder();
join1.and("isSystem", join1.entity().isSystemOnly(), Op.EQ);
join1.and("isRedundant", join1.entity().getRedundantRouter(), Op.EQ);
@@ -618,4 +619,12 @@ public class NetworkDaoImpl extends GenericDaoBase implements N
sc.setJoinParameters("offerings", "isRedundant", true);
return listBy(sc, null);
}
+
+ @Override
+ public List listByAclId(long aclId) {
+ SearchCriteria sc = AllFieldsSearch.create();
+ sc.setParameters("aclId", aclId);
+
+ return listBy(sc, null);
+ }
}
diff --git a/engine/schema/src/com/cloud/network/dao/NetworkServiceMapDao.java b/engine/schema/src/com/cloud/network/dao/NetworkServiceMapDao.java
index 79b97bec0f1..6d401c40d8b 100644
--- a/engine/schema/src/com/cloud/network/dao/NetworkServiceMapDao.java
+++ b/engine/schema/src/com/cloud/network/dao/NetworkServiceMapDao.java
@@ -35,4 +35,5 @@ public interface NetworkServiceMapDao extends GenericDao getDistinctProviders(long networkId);
String isProviderForNetwork(long networkId, Provider provider);
+ List getProvidersForServiceInNetwork(long networkId, Service service);
}
diff --git a/engine/schema/src/com/cloud/network/dao/NetworkServiceMapDaoImpl.java b/engine/schema/src/com/cloud/network/dao/NetworkServiceMapDaoImpl.java
index 13fbfbc401f..3cdd73885c8 100644
--- a/engine/schema/src/com/cloud/network/dao/NetworkServiceMapDaoImpl.java
+++ b/engine/schema/src/com/cloud/network/dao/NetworkServiceMapDaoImpl.java
@@ -56,6 +56,7 @@ public class NetworkServiceMapDaoImpl extends GenericDaoBase getProvidersForServiceInNetwork(long networkId, Service service) {
+ SearchCriteria sc = DistinctProvidersSearch.create();
+ sc.setParameters("networkId", networkId);
+ sc.setParameters("service", service.getName());
+ return customSearch(sc, null);
+ }
}
diff --git a/engine/schema/src/com/cloud/network/dao/NetworkVO.java b/engine/schema/src/com/cloud/network/dao/NetworkVO.java
index 77b40c8a5c9..6580ea054f9 100644
--- a/engine/schema/src/com/cloud/network/dao/NetworkVO.java
+++ b/engine/schema/src/com/cloud/network/dao/NetworkVO.java
@@ -32,9 +32,6 @@ import javax.persistence.Transient;
import org.apache.cloudstack.acl.ControlledEntity;
import com.cloud.network.Network;
-import com.cloud.network.Networks;
-import com.cloud.network.Network.GuestType;
-import com.cloud.network.Network.State;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.Mode;
import com.cloud.network.Networks.TrafficType;
@@ -163,6 +160,12 @@ public class NetworkVO implements Network {
@Column(name="ip6_cidr")
String ip6Cidr;
+ @Column(name="display_network", updatable=true, nullable=false)
+ protected boolean displayNetwork = true;
+
+ @Column(name="network_acl_id")
+ Long networkACLId;
+
public NetworkVO() {
this.uuid = UUID.randomUUID().toString();
}
@@ -540,4 +543,23 @@ public class NetworkVO implements Network {
public void setIp6Gateway(String ip6Gateway) {
this.ip6Gateway = ip6Gateway;
}
+
+ @Override()
+ public boolean getDisplayNetwork() {
+ return displayNetwork;
+ }
+
+ public void setDisplayNetwork(boolean displayNetwork) {
+ this.displayNetwork = displayNetwork;
+ }
+
+ @Override
+ public void setNetworkACLId(Long networkACLId) {
+ this.networkACLId = networkACLId;
+ }
+
+ @Override
+ public Long getNetworkACLId() {
+ return networkACLId;
+ }
}
diff --git a/engine/schema/src/com/cloud/network/rules/FirewallRuleVO.java b/engine/schema/src/com/cloud/network/rules/FirewallRuleVO.java
index a761520ccfe..9f73029349f 100644
--- a/engine/schema/src/com/cloud/network/rules/FirewallRuleVO.java
+++ b/engine/schema/src/com/cloud/network/rules/FirewallRuleVO.java
@@ -20,7 +20,6 @@ import java.util.Date;
import java.util.List;
import java.util.UUID;
-import javax.inject.Inject;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
@@ -35,7 +34,6 @@ import javax.persistence.InheritanceType;
import javax.persistence.Table;
import javax.persistence.Transient;
-import com.cloud.network.dao.FirewallRulesCidrsDao;
import com.cloud.utils.db.GenericDao;
import com.cloud.utils.net.NetUtils;
diff --git a/engine/schema/src/com/cloud/network/vpc/VpcGatewayVO.java b/engine/schema/src/com/cloud/network/vpc/VpcGatewayVO.java
index e8dcb46b211..7df2dfd236e 100644
--- a/engine/schema/src/com/cloud/network/vpc/VpcGatewayVO.java
+++ b/engine/schema/src/com/cloud/network/vpc/VpcGatewayVO.java
@@ -87,6 +87,11 @@ public class VpcGatewayVO implements VpcGateway {
@Column(name="source_nat")
boolean sourceNat;
+ @Column(name="network_acl_id")
+ long networkACLId;
+
+
+
protected VpcGatewayVO(){
this.uuid = UUID.randomUUID().toString();
}
@@ -106,7 +111,7 @@ public class VpcGatewayVO implements VpcGateway {
* @param sourceNat
*/
public VpcGatewayVO(String ip4Address, Type type, Long vpcId, long zoneId, Long networkId, String vlanTag,
- String gateway, String netmask, long accountId, long domainId, boolean sourceNat) {
+ String gateway, String netmask, long accountId, long domainId, boolean sourceNat, long networkACLId) {
this.ip4Address = ip4Address;
this.type = type;
this.vpcId = vpcId;
@@ -120,6 +125,8 @@ public class VpcGatewayVO implements VpcGateway {
this.domainId = domainId;
this.state = State.Creating;
this.sourceNat = sourceNat;
+ this.networkACLId = networkACLId;
+
}
@Override
@@ -203,4 +210,12 @@ public class VpcGatewayVO implements VpcGateway {
return this.sourceNat;
}
+ public void setNetworkACLId(long networkACLId) {
+ this.networkACLId = networkACLId;
+ }
+
+ @Override
+ public long getNetworkACLId() {
+ return networkACLId;
+ }
}
diff --git a/engine/schema/src/com/cloud/network/vpc/dao/VpcGatewayDao.java b/engine/schema/src/com/cloud/network/vpc/dao/VpcGatewayDao.java
index 600d67f6684..24d9deb511c 100644
--- a/engine/schema/src/com/cloud/network/vpc/dao/VpcGatewayDao.java
+++ b/engine/schema/src/com/cloud/network/vpc/dao/VpcGatewayDao.java
@@ -16,11 +16,18 @@
// under the License.
package com.cloud.network.vpc.dao;
+import com.cloud.network.vpc.VpcGateway;
import com.cloud.network.vpc.VpcGatewayVO;
import com.cloud.utils.db.GenericDao;
+import java.util.List;
+
public interface VpcGatewayDao extends GenericDao{
VpcGatewayVO getPrivateGatewayForVpc(long vpcId);
VpcGatewayVO getVpnGatewayForVpc(long vpcId);
+
+ Long getNetworkAclIdForPrivateIp(long vpcId, long networkId, String ipaddr);
+
+ List listByVpcIdAndType(long vpcId, VpcGateway.Type type);
}
diff --git a/engine/schema/src/com/cloud/network/vpc/dao/VpcGatewayDaoImpl.java b/engine/schema/src/com/cloud/network/vpc/dao/VpcGatewayDaoImpl.java
index a1cd9340402..6a2f8bd4459 100644
--- a/engine/schema/src/com/cloud/network/vpc/dao/VpcGatewayDaoImpl.java
+++ b/engine/schema/src/com/cloud/network/vpc/dao/VpcGatewayDaoImpl.java
@@ -27,6 +27,8 @@ import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
+import java.util.List;
+
@Component
@Local(value = VpcGatewayDao.class)
@DB(txn = false)
@@ -37,6 +39,8 @@ public class VpcGatewayDaoImpl extends GenericDaoBase implem
AllFieldsSearch = createSearchBuilder();
AllFieldsSearch.and("vpcId", AllFieldsSearch.entity().getVpcId(), SearchCriteria.Op.EQ);
AllFieldsSearch.and("type", AllFieldsSearch.entity().getType(), SearchCriteria.Op.EQ);
+ AllFieldsSearch.and("networkid", AllFieldsSearch.entity().getNetworkId(), SearchCriteria.Op.EQ);
+ AllFieldsSearch.and("ipaddress", AllFieldsSearch.entity().getIp4Address(), SearchCriteria.Op.EQ);
AllFieldsSearch.done();
}
@@ -59,4 +63,27 @@ public class VpcGatewayDaoImpl extends GenericDaoBase implem
return findOneBy(sc);
}
+ @Override
+ public Long getNetworkAclIdForPrivateIp (long vpcId, long networkId, String ipaddr) {
+ SearchCriteria sc = AllFieldsSearch.create();
+ sc.setParameters("vpcId", vpcId);
+ sc.setParameters("networkid", networkId);
+ sc.setParameters("ipaddress", ipaddr);
+
+ VpcGateway vpcGateway = findOneBy(sc);
+ if (vpcGateway != null) {
+ return vpcGateway.getNetworkACLId();
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public List listByVpcIdAndType(long vpcId, VpcGateway.Type type) {
+ SearchCriteria sc = AllFieldsSearch.create();
+ sc.setParameters("vpcId", vpcId);
+ sc.setParameters("type", type);
+ return listBy(sc);
+ }
+
}
diff --git a/engine/schema/src/com/cloud/offerings/NetworkOfferingDetailsVO.java b/engine/schema/src/com/cloud/offerings/NetworkOfferingDetailsVO.java
new file mode 100644
index 00000000000..6cd5abc4223
--- /dev/null
+++ b/engine/schema/src/com/cloud/offerings/NetworkOfferingDetailsVO.java
@@ -0,0 +1,90 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.offerings;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.apache.cloudstack.api.InternalIdentity;
+
+import com.cloud.offering.NetworkOffering;
+import com.cloud.offering.NetworkOffering.Detail;
+
+@Entity
+@Table(name="network_offering_details")
+public class NetworkOfferingDetailsVO implements InternalIdentity {
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="id")
+ private long id;
+
+ @Column(name="network_offering_id")
+ private long offeringId;
+
+ @Enumerated(value=EnumType.STRING)
+ @Column(name="name")
+ private NetworkOffering.Detail name;
+
+ @Column(name="value", length=1024)
+ private String value;
+
+ public NetworkOfferingDetailsVO() {}
+
+ public NetworkOfferingDetailsVO(long offeringId, Detail detailName, String value) {
+ this.offeringId = offeringId;
+ this.name = detailName;
+ this.value = value;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public long getOfferingId() {
+ return offeringId;
+ }
+
+ public NetworkOffering.Detail getName() {
+ return name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public void setOfferingId(long offeringId) {
+ this.offeringId = offeringId;
+ }
+
+ public void setName(NetworkOffering.Detail name) {
+ this.name = name;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+}
diff --git a/engine/schema/src/com/cloud/offerings/NetworkOfferingVO.java b/engine/schema/src/com/cloud/offerings/NetworkOfferingVO.java
index c015989c5c5..3ae0bf38b0b 100755
--- a/engine/schema/src/com/cloud/offerings/NetworkOfferingVO.java
+++ b/engine/schema/src/com/cloud/offerings/NetworkOfferingVO.java
@@ -16,15 +16,23 @@
// under the License.
package com.cloud.offerings;
+import java.util.Date;
+import java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
import com.cloud.network.Network;
import com.cloud.network.Networks.TrafficType;
import com.cloud.offering.NetworkOffering;
import com.cloud.utils.db.GenericDao;
-import javax.persistence.*;
-import java.util.Date;
-import java.util.UUID;
-
@Entity
@Table(name = "network_offerings")
public class NetworkOfferingVO implements NetworkOffering {
@@ -126,6 +134,12 @@ public class NetworkOfferingVO implements NetworkOffering {
public String getDisplayText() {
return displayText;
}
+
+ @Column(name = "internal_lb")
+ boolean internalLb;
+
+ @Column(name = "public_lb")
+ boolean publicLb;
@Override
public long getId() {
@@ -262,7 +276,7 @@ public class NetworkOfferingVO implements NetworkOffering {
}
public NetworkOfferingVO(String name, String displayText, TrafficType trafficType, boolean systemOnly, boolean specifyVlan, Integer rateMbps, Integer multicastRateMbps, boolean isDefault,
- Availability availability, String tags, Network.GuestType guestType, boolean conserveMode, boolean specifyIpRanges, boolean isPersistent) {
+ Availability availability, String tags, Network.GuestType guestType, boolean conserveMode, boolean specifyIpRanges, boolean isPersistent, boolean internalLb, boolean publicLb) {
this.name = name;
this.displayText = displayText;
this.rateMbps = rateMbps;
@@ -286,12 +300,14 @@ public class NetworkOfferingVO implements NetworkOffering {
this.inline = false;
this.specifyIpRanges = specifyIpRanges;
this.isPersistent=isPersistent;
+ this.publicLb = publicLb;
+ this.internalLb = internalLb;
}
public NetworkOfferingVO(String name, String displayText, TrafficType trafficType, boolean systemOnly, boolean specifyVlan, Integer rateMbps, Integer multicastRateMbps, boolean isDefault,
Availability availability, String tags, Network.GuestType guestType, boolean conserveMode, boolean dedicatedLb, boolean sharedSourceNat, boolean redundantRouter, boolean elasticIp, boolean elasticLb,
- boolean specifyIpRanges, boolean inline, boolean isPersistent, boolean associatePublicIP) {
- this(name, displayText, trafficType, systemOnly, specifyVlan, rateMbps, multicastRateMbps, isDefault, availability, tags, guestType, conserveMode, specifyIpRanges, isPersistent);
+ boolean specifyIpRanges, boolean inline, boolean isPersistent, boolean associatePublicIP, boolean publicLb, boolean internalLb) {
+ this(name, displayText, trafficType, systemOnly, specifyVlan, rateMbps, multicastRateMbps, isDefault, availability, tags, guestType, conserveMode, specifyIpRanges, isPersistent, internalLb, publicLb);
this.dedicatedLB = dedicatedLb;
this.sharedSourceNat = sharedSourceNat;
this.redundantRouter = redundantRouter;
@@ -313,13 +329,13 @@ public class NetworkOfferingVO implements NetworkOffering {
* TODO
*/
public NetworkOfferingVO(String name, TrafficType trafficType, boolean specifyIpRanges) {
- this(name, "System Offering for " + name, trafficType, true, false, 0, 0, true, Availability.Required, null, null, true, specifyIpRanges, false);
+ this(name, "System Offering for " + name, trafficType, true, false, 0, 0, true, Availability.Required, null, null, true, specifyIpRanges, false, false, false);
this.state = State.Enabled;
}
public NetworkOfferingVO(String name, Network.GuestType guestType) {
this(name, "System Offering for " + name, TrafficType.Guest, true, true, 0, 0, true, Availability.Optional,
- null, Network.GuestType.Isolated, true, false, false);
+ null, Network.GuestType.Isolated, true, false, false, false, false);
this.state = State.Enabled;
}
@@ -388,4 +404,14 @@ public class NetworkOfferingVO implements NetworkOffering {
return isPersistent;
}
+ @Override
+ public boolean getInternalLb() {
+ return internalLb;
+ }
+
+ @Override
+ public boolean getPublicLb() {
+ return publicLb;
+ }
+
}
diff --git a/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDao.java b/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDao.java
index 405d348ffe2..5bb79ced69f 100644
--- a/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDao.java
+++ b/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDao.java
@@ -17,11 +17,13 @@
package com.cloud.offerings.dao;
import java.util.List;
+import java.util.Map;
import com.cloud.network.Network;
import com.cloud.network.Networks.TrafficType;
import com.cloud.offering.NetworkOffering;
import com.cloud.offering.NetworkOffering.Availability;
+import com.cloud.offering.NetworkOffering.Detail;
import com.cloud.offerings.NetworkOfferingVO;
import com.cloud.utils.db.GenericDao;
@@ -57,4 +59,6 @@ public interface NetworkOfferingDao extends GenericDao
List listByTrafficTypeGuestTypeAndState(NetworkOffering.State state, TrafficType trafficType, Network.GuestType type);
+ NetworkOfferingVO persist(NetworkOfferingVO off, Map details);
+
}
diff --git a/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDaoImpl.java b/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDaoImpl.java
index d1e44242d2a..ef8237a48f5 100644
--- a/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDaoImpl.java
+++ b/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDaoImpl.java
@@ -17,8 +17,10 @@
package com.cloud.offerings.dao;
import java.util.List;
+import java.util.Map;
import javax.ejb.Local;
+import javax.inject.Inject;
import javax.persistence.EntityExistsException;
import org.springframework.stereotype.Component;
@@ -27,6 +29,8 @@ import com.cloud.network.Network;
import com.cloud.network.Networks.TrafficType;
import com.cloud.offering.NetworkOffering;
import com.cloud.offering.NetworkOffering.Availability;
+import com.cloud.offering.NetworkOffering.Detail;
+import com.cloud.offerings.NetworkOfferingDetailsVO;
import com.cloud.offerings.NetworkOfferingVO;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.GenericDaoBase;
@@ -45,6 +49,7 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase AvailabilitySearch;
final SearchBuilder AllFieldsSearch;
private final GenericSearchBuilder UpgradeSearch;
+ @Inject NetworkOfferingDetailsDao _detailsDao;
protected NetworkOfferingDaoImpl() {
super();
@@ -165,5 +170,24 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase details) {
+ Transaction txn = Transaction.currentTxn();
+ txn.start();
+ //1) persist the offering
+ NetworkOfferingVO vo = super.persist(off);
+
+ //2) persist the details
+ if (details != null && !details.isEmpty()) {
+ for (NetworkOffering.Detail detail : details.keySet()) {
+ _detailsDao.persist(new NetworkOfferingDetailsVO(off.getId(), detail, details.get(detail)));
+ }
+ }
+
+ txn.commit();
+ return vo;
+ }
}
diff --git a/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDetailsDao.java b/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDetailsDao.java
new file mode 100644
index 00000000000..ce209e04694
--- /dev/null
+++ b/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDetailsDao.java
@@ -0,0 +1,31 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.offerings.dao;
+
+
+import java.util.Map;
+
+import com.cloud.offering.NetworkOffering;
+import com.cloud.offering.NetworkOffering.Detail;
+import com.cloud.offerings.NetworkOfferingDetailsVO;
+import com.cloud.utils.db.GenericDao;
+
+public interface NetworkOfferingDetailsDao extends GenericDao{
+
+ Map getNtwkOffDetails(long offeringId);
+ String getDetail(long offeringId, Detail detailName);
+}
diff --git a/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDetailsDaoImpl.java b/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDetailsDaoImpl.java
new file mode 100644
index 00000000000..068f3908b8d
--- /dev/null
+++ b/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDetailsDaoImpl.java
@@ -0,0 +1,79 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.offerings.dao;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.cloud.offering.NetworkOffering;
+import com.cloud.offering.NetworkOffering.Detail;
+import com.cloud.offerings.NetworkOfferingDetailsVO;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.GenericSearchBuilder;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.SearchCriteria.Func;
+import com.cloud.utils.db.SearchCriteria.Op;
+
+public class NetworkOfferingDetailsDaoImpl extends GenericDaoBase implements NetworkOfferingDetailsDao{
+ protected final SearchBuilder DetailSearch;
+ private final GenericSearchBuilder ValueSearch;
+
+
+ public NetworkOfferingDetailsDaoImpl() {
+
+ DetailSearch = createSearchBuilder();
+ DetailSearch.and("offeringId", DetailSearch.entity().getOfferingId(), SearchCriteria.Op.EQ);
+ DetailSearch.and("name", DetailSearch.entity().getName(), SearchCriteria.Op.EQ);
+ DetailSearch.done();
+
+ ValueSearch = createSearchBuilder(String.class);
+ ValueSearch.select(null, Func.DISTINCT, ValueSearch.entity().getValue());
+ ValueSearch.and("offeringId", ValueSearch.entity().getOfferingId(), SearchCriteria.Op.EQ);
+ ValueSearch.and("name", ValueSearch.entity().getName(), Op.EQ);
+ ValueSearch.done();
+ }
+
+ @Override
+ public Map getNtwkOffDetails(long offeringId) {
+ SearchCriteria sc = DetailSearch.create();
+ sc.setParameters("offeringId", offeringId);
+
+ List results = search(sc, null);
+ Map details = new HashMap(results.size());
+ for (NetworkOfferingDetailsVO result : results) {
+ details.put(result.getName(), result.getValue());
+ }
+
+ return details;
+ }
+
+ @Override
+ public String getDetail(long offeringId, Detail detailName) {
+ SearchCriteria sc = ValueSearch.create();
+ sc.setParameters("name", detailName);
+ sc.setParameters("offeringId", offeringId);
+ List results = customSearch(sc, null);
+ if (results.isEmpty()) {
+ return null;
+ } else {
+ return results.get(0);
+ }
+ }
+
+}
diff --git a/engine/schema/src/com/cloud/storage/DiskOfferingVO.java b/engine/schema/src/com/cloud/storage/DiskOfferingVO.java
index e4fc21c7c13..909d7fe6325 100755
--- a/engine/schema/src/com/cloud/storage/DiskOfferingVO.java
+++ b/engine/schema/src/com/cloud/storage/DiskOfferingVO.java
@@ -100,6 +100,9 @@ public class DiskOfferingVO implements DiskOffering {
@Column(name="sort_key")
int sortKey;
+ @Column(name="display_offering")
+ boolean displayOffering;
+
public DiskOfferingVO() {
this.uuid = UUID.randomUUID().toString();
}
@@ -315,4 +318,13 @@ public class DiskOfferingVO implements DiskOffering {
public void setRecreatable(boolean recreatable) {
this.recreatable = recreatable;
}
+
+
+ public boolean getDisplayOffering() {
+ return displayOffering;
+ }
+
+ public void setDisplayOffering(boolean displayOffering) {
+ this.displayOffering = displayOffering;
+ }
}
diff --git a/engine/schema/src/com/cloud/storage/VolumeVO.java b/engine/schema/src/com/cloud/storage/VolumeVO.java
index a287c26348b..1699afd320f 100755
--- a/engine/schema/src/com/cloud/storage/VolumeVO.java
+++ b/engine/schema/src/com/cloud/storage/VolumeVO.java
@@ -130,7 +130,10 @@ public class VolumeVO implements Volume {
@Column(name = "uuid")
String uuid;
-
+
+ @Column(name="display_volume", updatable=true, nullable=false)
+ protected boolean displayVolume;
+
@Transient
// @Column(name="reservation")
String reservationId;
@@ -451,4 +454,13 @@ public class VolumeVO implements Volume {
public void setUuid(String uuid) {
this.uuid = uuid;
}
+
+
+ public boolean isDisplayVolume() {
+ return displayVolume;
+ }
+
+ public void setDisplayVolume(boolean displayVolume) {
+ this.displayVolume = displayVolume;
+ }
}
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade302to40.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade302to40.java
index 753f64ec682..ecda872dfa4 100644
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade302to40.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade302to40.java
@@ -63,6 +63,7 @@ public class Upgrade302to40 extends Upgrade30xBase implements DbUpgrade {
@Override
public void performDataMigration(Connection conn) {
+ updateVmWareSystemVms(conn);
correctVRProviders(conn);
correctMultiplePhysicaNetworkSetups(conn);
addHostDetailsUniqueKey(conn);
@@ -82,7 +83,55 @@ public class Upgrade302to40 extends Upgrade30xBase implements DbUpgrade {
return new File[] { new File(script) };
}
-
+
+ private void updateVmWareSystemVms(Connection conn){
+ PreparedStatement pstmt = null;
+ ResultSet rs = null;
+ boolean VMware = false;
+ try {
+ pstmt = conn.prepareStatement("select distinct(hypervisor_type) from `cloud`.`cluster` where removed is null");
+ rs = pstmt.executeQuery();
+ while(rs.next()){
+ if("VMware".equals(rs.getString(1))){
+ VMware = true;
+ }
+ }
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Error while iterating through list of hypervisors in use", e);
+ }
+ // Just update the VMware system template. Other hypervisor templates are unchanged from previous 3.0.x versions.
+ s_logger.debug("Updating VMware System Vms");
+ try {
+ //Get 4.0 VMware system Vm template Id
+ pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name = 'systemvm-vmware-4.0' and removed is null");
+ rs = pstmt.executeQuery();
+ if(rs.next()){
+ long templateId = rs.getLong(1);
+ rs.close();
+ pstmt.close();
+ // change template type to SYSTEM
+ pstmt = conn.prepareStatement("update `cloud`.`vm_template` set type='SYSTEM' where id = ?");
+ pstmt.setLong(1, templateId);
+ pstmt.executeUpdate();
+ pstmt.close();
+ // update templete ID of system Vms
+ pstmt = conn.prepareStatement("update `cloud`.`vm_instance` set vm_template_id = ? where type <> 'User' and hypervisor_type = 'VMware'");
+ pstmt.setLong(1, templateId);
+ pstmt.executeUpdate();
+ pstmt.close();
+ } else {
+ if (VMware){
+ throw new CloudRuntimeException("4.0 VMware SystemVm template not found. Cannot upgrade system Vms");
+ } else {
+ s_logger.warn("4.0 VMware SystemVm template not found. VMware hypervisor is not used, so not failing upgrade");
+ }
+ }
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Error while updating VMware systemVm template", e);
+ }
+ s_logger.debug("Updating System Vm Template IDs Complete");
+ }
+
private void correctVRProviders(Connection conn) {
PreparedStatement pstmtVR = null;
ResultSet rsVR = null;
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
index 46c2c78455a..f14a3edc1f6 100644
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
@@ -17,17 +17,21 @@
package com.cloud.upgrade.dao;
-import com.cloud.utils.exception.CloudRuntimeException;
-import com.cloud.utils.script.Script;
-import org.apache.log4j.Logger;
-
import java.io.File;
import java.sql.Connection;
+import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Types;
import java.util.UUID;
+import com.cloud.network.vpc.NetworkACL;
+import org.apache.log4j.Logger;
+
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.utils.script.Script;
+
public class Upgrade410to420 implements DbUpgrade {
final static Logger s_logger = Logger.getLogger(Upgrade410to420.class);
@@ -66,6 +70,9 @@ public class Upgrade410to420 implements DbUpgrade {
updatePrimaryStore(conn);
addEgressFwRulesForSRXGuestNw(conn);
upgradeEIPNetworkOfferings(conn);
+ upgradeDefaultVpcOffering(conn);
+ upgradePhysicalNtwksWithInternalLbProvider(conn);
+ updateNetworkACLs(conn);
}
private void updateSystemVmTemplates(Connection conn) {
@@ -308,6 +315,7 @@ public class Upgrade410to420 implements DbUpgrade {
}
}
}
+
private void addEgressFwRulesForSRXGuestNw(Connection conn) {
PreparedStatement pstmt = null;
ResultSet rs = null;
@@ -389,6 +397,193 @@ public class Upgrade410to420 implements DbUpgrade {
}
} catch (SQLException e) {
throw new CloudRuntimeException("Unable to set elastic_ip_service for network offerings with EIP service enabled.", e);
+ }
+ }
+
+ private void updateNetworkACLs(Connection conn) {
+ //Fetch all VPC Tiers
+ //For each tier create a network ACL and move all the acl_items to network_acl_item table
+ // If there are no acl_items for a tier, associate it with default ACL
+
+ s_logger.debug("Updating network ACLs");
+
+ PreparedStatement pstmt = null;
+ PreparedStatement pstmtDelete = null;
+ ResultSet rs = null;
+ ResultSet rsAcls = null;
+ ResultSet rsCidr = null;
+
+ //1,2 are default acl Ids, start acl Ids from 3
+ long nextAclId = 3;
+
+ try {
+ //Get all VPC tiers
+ pstmt = conn.prepareStatement("SELECT id, vpc_id, uuid FROM `cloud`.`networks` where vpc_id is not null and removed is null");
+ rs = pstmt.executeQuery();
+ while (rs.next()) {
+ Long networkId = rs.getLong(1);
+ s_logger.debug("Updating network ACLs for network: "+networkId);
+ Long vpcId = rs.getLong(2);
+ String tierUuid = rs.getString(3);
+ pstmt = conn.prepareStatement("SELECT id, uuid, start_port, end_port, state, protocol, icmp_code, icmp_type, created, traffic_type FROM `cloud`.`firewall_rules` where network_id = ? and purpose = 'NetworkACL'");
+ pstmt.setLong(1, networkId);
+ rsAcls = pstmt.executeQuery();
+ boolean hasAcls = false;
+ Long aclId = null;
+ int number = 1;
+ while(rsAcls.next()){
+ if(!hasAcls){
+ hasAcls = true;
+ aclId = nextAclId++;
+ //create ACL for the tier
+ s_logger.debug("Creating network ACL for tier: "+tierUuid);
+ pstmt = conn.prepareStatement("INSERT INTO `cloud`.`network_acl` (id, uuid, vpc_id, description, name) values (?, UUID(), ? , ?, ?)");
+ pstmt.setLong(1, aclId);
+ pstmt.setLong(2, vpcId);
+ pstmt.setString(3, "ACL for tier " + tierUuid);
+ pstmt.setString(4, "tier_" + tierUuid);
+ pstmt.executeUpdate();
+ }
+
+ Long fwRuleId = rsAcls.getLong(1);
+ String cidr = null;
+ //get cidr from firewall_rules_cidrs
+ pstmt = conn.prepareStatement("SELECT id, source_cidr FROM `cloud`.`firewall_rules_cidrs` where firewall_rule_id = ?");
+ pstmt.setLong(1, fwRuleId);
+ rsCidr = pstmt.executeQuery();
+ while(rsCidr.next()){
+ Long cidrId = rsCidr.getLong(1);
+ String sourceCidr = rsCidr.getString(2);
+ if(cidr == null){
+ cidr = sourceCidr;
+ } else {
+ cidr += ","+sourceCidr;
+ }
+ //Delete cidr entry
+ pstmtDelete = conn.prepareStatement("DELETE FROM `cloud`.`firewall_rules_cidrs` where id = ?");
+ pstmtDelete.setLong(1, cidrId);
+ pstmtDelete.executeUpdate();
+ }
+
+
+ String aclItemUuid = rsAcls.getString(2);
+ //Move acl to network_acl_item table
+ s_logger.debug("Moving firewall rule: "+aclItemUuid);
+ pstmt = conn.prepareStatement("INSERT INTO `cloud`.`network_acl_item` (uuid, acl_id, start_port, end_port, state, protocol, icmp_code, icmp_type, created, traffic_type, cidr, number, action) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )");
+ //uuid
+ pstmt.setString(1, aclItemUuid);
+ //aclId
+ pstmt.setLong(2, aclId);
+ //Start port
+ Integer startPort = rsAcls.getInt(3);
+ if(rsAcls.wasNull()){
+ pstmt.setNull(3, Types.INTEGER);
+ } else {
+ pstmt.setLong(3, startPort);
+ }
+ //End port
+ Integer endPort = rsAcls.getInt(4);
+ if(rsAcls.wasNull()){
+ pstmt.setNull(4, Types.INTEGER);
+ } else {
+ pstmt.setLong(4, endPort);
+ }
+ //State
+ String state = rsAcls.getString(5);
+ pstmt.setString(5, state);
+ //protocol
+ String protocol = rsAcls.getString(6);
+ pstmt.setString(6, protocol);
+ //icmp_code
+ Integer icmpCode = rsAcls.getInt(7);
+ if(rsAcls.wasNull()){
+ pstmt.setNull(7, Types.INTEGER);
+ } else {
+ pstmt.setLong(7, icmpCode);
+ }
+
+ //icmp_type
+ Integer icmpType = rsAcls.getInt(8);
+ if(rsAcls.wasNull()){
+ pstmt.setNull(8, Types.INTEGER);
+ } else {
+ pstmt.setLong(8, icmpType);
+ }
+
+ //created
+ Date created = rsAcls.getDate(9);
+ pstmt.setDate(9, created);
+ //traffic type
+ String trafficType = rsAcls.getString(10);
+ pstmt.setString(10, trafficType);
+
+ //cidr
+ pstmt.setString(11, cidr);
+ //number
+ pstmt.setInt(12, number++);
+ //action
+ pstmt.setString(13, "Allow");
+ pstmt.executeUpdate();
+
+ //Delete firewall rule
+ pstmtDelete = conn.prepareStatement("DELETE FROM `cloud`.`firewall_rules` where id = ?");
+ pstmtDelete.setLong(1, fwRuleId);
+ pstmtDelete.executeUpdate();
+ }
+ if(!hasAcls){
+ //no network ACls for this network.
+ // Assign default Deny ACL
+ aclId = NetworkACL.DEFAULT_DENY;
+ }
+ //Assign acl to network
+ pstmt = conn.prepareStatement("UPDATE `cloud`.`networks` set network_acl_id=? where id=?");
+ pstmt.setLong(1, aclId);
+ pstmt.setLong(2, networkId);
+ pstmt.executeUpdate();
+ }
+ s_logger.debug("Done updating network ACLs ");
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Unable to move network acls from firewall rules table to network_acl_item table", e);
+ } finally {
+ try {
+ if (rs != null) {
+ rs.close();
+ }
+ if (rsAcls != null) {
+ rsAcls.close();
+ }
+ if (rsCidr != null) {
+ rsCidr.close();
+ }
+ if (pstmt != null) {
+ pstmt.close();
+ }
+ } catch (SQLException e) {
+ }
+ }
+ }
+
+
+ private void upgradeDefaultVpcOffering(Connection conn) {
+
+ PreparedStatement pstmt = null;
+ ResultSet rs = null;
+
+ try {
+ pstmt = conn.prepareStatement("select distinct map.vpc_offering_id from `cloud`.`vpc_offering_service_map` map, `cloud`.`vpc_offerings` off where off.id=map.vpc_offering_id AND service='Lb'");
+ rs = pstmt.executeQuery();
+ while (rs.next()) {
+ long id = rs.getLong(1);
+ //Add internal LB vm as a supported provider for the load balancer service
+ pstmt = conn.prepareStatement("INSERT INTO `cloud`.`vpc_offering_service_map` (vpc_offering_id, service, provider) VALUES (?,?,?)");
+ pstmt.setLong(1, id);
+ pstmt.setString(2, "Lb");
+ pstmt.setString(3, "InternalLbVm");
+ pstmt.executeUpdate();
+ }
+
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Unable update the default VPC offering with the internal lb service", e);
} finally {
try {
if (rs != null) {
@@ -401,4 +596,55 @@ public class Upgrade410to420 implements DbUpgrade {
}
}
}
+
+
+
+ private void upgradePhysicalNtwksWithInternalLbProvider(Connection conn) {
+
+ PreparedStatement pstmt = null;
+ ResultSet rs = null;
+
+ try {
+ pstmt = conn.prepareStatement("SELECT id FROM `cloud`.`physical_network` where removed is null");
+ rs = pstmt.executeQuery();
+ while (rs.next()) {
+ long pNtwkId = rs.getLong(1);
+ String uuid = UUID.randomUUID().toString();
+ //Add internal LB VM to the list of physical network service providers
+ pstmt = conn.prepareStatement("INSERT INTO `cloud`.`physical_network_service_providers` " +
+ "(uuid, physical_network_id, provider_name, state, load_balance_service_provided, destination_physical_network_id)" +
+ " VALUES (?, ?, 'InternalLbVm', 'Enabled', 1, 0)");
+ pstmt.setString(1, uuid);
+ pstmt.setLong(2, pNtwkId);
+ pstmt.executeUpdate();
+
+ //Add internal lb vm to the list of physical network elements
+ PreparedStatement pstmt1 = conn.prepareStatement("SELECT id FROM `cloud`.`physical_network_service_providers`" +
+ " WHERE physical_network_id=? AND provider_name='InternalLbVm'");
+ ResultSet rs1 = pstmt1.executeQuery();
+ while (rs1.next()) {
+ long providerId = rs1.getLong(1);
+ uuid = UUID.randomUUID().toString();
+ pstmt1 = conn.prepareStatement("INSERT INTO `cloud`.`virtual_router_providers` (nsp_id, uuid, type, enabled) VALUES (?, ?, 'InternalLbVm', 1)");
+ pstmt1.setLong(1, providerId);
+ pstmt1.setString(2, uuid);
+ pstmt1.executeUpdate();
+ }
+ }
+
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Unable existing physical networks with internal lb provider", e);
+ } finally {
+ try {
+ if (rs != null) {
+ rs.close();
+ }
+ if (pstmt != null) {
+ pstmt.close();
+ }
+ } catch (SQLException e) {
+ }
+ }
+
+ }
}
diff --git a/engine/schema/src/com/cloud/vm/VMInstanceVO.java b/engine/schema/src/com/cloud/vm/VMInstanceVO.java
index 5ec2712d3d8..fbe03dca8a2 100644
--- a/engine/schema/src/com/cloud/vm/VMInstanceVO.java
+++ b/engine/schema/src/com/cloud/vm/VMInstanceVO.java
@@ -111,6 +111,9 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject {
List listByVmId(long instanceId);
@@ -30,7 +30,7 @@ public interface NicDao extends GenericDao {
List listByNetworkId(long networkId);
- NicVO findByInstanceIdAndNetworkId(long networkId, long instanceId);
+ NicVO findByNtwkIdAndInstanceId(long networkId, long instanceId);
NicVO findByInstanceIdAndNetworkIdIncludingRemoved(long networkId, long instanceId);
@@ -66,4 +66,6 @@ public interface NicDao extends GenericDao {
List listPlaceholderNicsByNetworkId(long networkId);
List listPlaceholderNicsByNetworkIdAndVmType(long networkId, VirtualMachine.Type vmType);
+
+ NicVO findByInstanceIdAndIpAddressAndVmtype(long instanceId, String ipaddress, VirtualMachine.Type type);
}
diff --git a/engine/schema/src/com/cloud/vm/dao/NicDaoImpl.java b/engine/schema/src/com/cloud/vm/dao/NicDaoImpl.java
index c70d19432ef..420643f7363 100644
--- a/engine/schema/src/com/cloud/vm/dao/NicDaoImpl.java
+++ b/engine/schema/src/com/cloud/vm/dao/NicDaoImpl.java
@@ -16,12 +16,6 @@
// under the License.
package com.cloud.vm.dao;
-import java.util.List;
-
-import javax.ejb.Local;
-
-import org.springframework.stereotype.Component;
-
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.GenericSearchBuilder;
import com.cloud.utils.db.SearchBuilder;
@@ -32,6 +26,10 @@ import com.cloud.vm.Nic;
import com.cloud.vm.Nic.State;
import com.cloud.vm.NicVO;
import com.cloud.vm.VirtualMachine;
+import org.springframework.stereotype.Component;
+
+import javax.ejb.Local;
+import java.util.List;
@Component
@Local(value=NicDao.class)
@@ -113,12 +111,21 @@ public class NicDaoImpl extends GenericDaoBase implements NicDao {
}
@Override
- public NicVO findByInstanceIdAndNetworkId(long networkId, long instanceId) {
+ public NicVO findByNtwkIdAndInstanceId(long networkId, long instanceId) {
SearchCriteria sc = AllFieldsSearch.create();
sc.setParameters("network", networkId);
sc.setParameters("instance", instanceId);
return findOneBy(sc);
}
+
+ @Override
+ public NicVO findByInstanceIdAndIpAddressAndVmtype(long instanceId, String ipaddress, VirtualMachine.Type type) {
+ SearchCriteria sc = AllFieldsSearch.create();
+ sc.setParameters("instance", instanceId);
+ sc.setParameters("address", ipaddress);
+ sc.setParameters("vmType", type);
+ return findOneBy(sc);
+ }
@Override
public NicVO findByInstanceIdAndNetworkIdIncludingRemoved(long networkId, long instanceId) {
diff --git a/engine/schema/src/com/cloud/vm/dao/UserVmDao.java b/engine/schema/src/com/cloud/vm/dao/UserVmDao.java
index 81d13cda2ed..e7cd61bddfe 100755
--- a/engine/schema/src/com/cloud/vm/dao/UserVmDao.java
+++ b/engine/schema/src/com/cloud/vm/dao/UserVmDao.java
@@ -38,8 +38,9 @@ public interface UserVmDao extends GenericDao {
* @param id vm id.
* @param displan name and enable for ha
* @param userData updates the userData of the vm
+ * @param displayVm updates the displayvm attribute signifying whether it has to be displayed to the end user or not.
*/
- void updateVM(long id, String displayName, boolean enable, Long osTypeId, String userData);
+ void updateVM(long id, String displayName, boolean enable, Long osTypeId, String userData, boolean displayVm);
List findDestroyedVms(Date date);
diff --git a/engine/schema/src/com/cloud/vm/dao/UserVmDaoImpl.java b/engine/schema/src/com/cloud/vm/dao/UserVmDaoImpl.java
index c2fd6481875..5e8be1054a9 100755
--- a/engine/schema/src/com/cloud/vm/dao/UserVmDaoImpl.java
+++ b/engine/schema/src/com/cloud/vm/dao/UserVmDaoImpl.java
@@ -224,12 +224,13 @@ public class UserVmDaoImpl extends GenericDaoBase implements Use
}
@Override
- public void updateVM(long id, String displayName, boolean enable, Long osTypeId, String userData) {
+ public void updateVM(long id, String displayName, boolean enable, Long osTypeId, String userData, boolean displayVm) {
UserVmVO vo = createForUpdate();
vo.setDisplayName(displayName);
vo.setHaEnabled(enable);
vo.setGuestOSId(osTypeId);
vo.setUserData(userData);
+ vo.setDisplayVm(displayVm);
update(id, vo);
}
diff --git a/engine/schema/src/org/apache/cloudstack/lb/ApplicationLoadBalancerRuleVO.java b/engine/schema/src/org/apache/cloudstack/lb/ApplicationLoadBalancerRuleVO.java
new file mode 100644
index 00000000000..37a747e4272
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/lb/ApplicationLoadBalancerRuleVO.java
@@ -0,0 +1,133 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.cloudstack.lb;
+
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.PrimaryKeyJoinColumn;
+import javax.persistence.Table;
+
+import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
+
+import com.cloud.network.rules.FirewallRuleVO;
+import com.cloud.utils.net.Ip;
+import com.cloud.utils.net.NetUtils;
+
+/**
+ * This VO represent Internal Load Balancer rule.
+ * Instead of pointing to the public ip address id directly as External Load Balancer rule does, it refers to the ip address by its value/sourceNetworkid
+ *
+ */
+@Entity
+@Table(name=("load_balancing_rules"))
+@DiscriminatorValue(value="LoadBalancing")
+@PrimaryKeyJoinColumn(name="id")
+public class ApplicationLoadBalancerRuleVO extends FirewallRuleVO implements ApplicationLoadBalancerRule{
+ @Column(name="name")
+ private String name;
+
+ @Column(name="description", length=4096)
+ private String description;
+
+ @Column(name="algorithm")
+ private String algorithm;
+
+ @Column(name="default_port_start")
+ private int defaultPortStart;
+
+ @Column(name="default_port_end")
+ private int defaultPortEnd;
+
+ @Column(name="source_ip_address_network_id")
+ Long sourceIpNetworkId;
+
+ @Column(name="source_ip_address")
+ @Enumerated(value=EnumType.STRING)
+ private Ip sourceIp = null;
+
+ @Enumerated(value=EnumType.STRING)
+ @Column(name="scheme")
+ Scheme scheme;
+
+
+ public ApplicationLoadBalancerRuleVO() {
+ }
+
+ public ApplicationLoadBalancerRuleVO(String name, String description, int srcPort, int instancePort, String algorithm,
+ long networkId, long accountId, long domainId, Ip sourceIp, long sourceIpNtwkId, Scheme scheme) {
+ super(null, null, srcPort, srcPort, NetUtils.TCP_PROTO, networkId, accountId, domainId, Purpose.LoadBalancing, null, null,null, null, null);
+
+ this.name = name;
+ this.description = description;
+ this.algorithm = algorithm;
+ this.defaultPortStart = instancePort;
+ this.defaultPortEnd = instancePort;
+ this.sourceIp = sourceIp;
+ this.sourceIpNetworkId = sourceIpNtwkId;
+ this.scheme = scheme;
+ }
+
+
+ @Override
+ public Long getSourceIpNetworkId() {
+ return sourceIpNetworkId;
+ }
+
+ @Override
+ public Ip getSourceIp() {
+ return sourceIp;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public String getAlgorithm() {
+ return algorithm;
+ }
+
+ @Override
+ public int getDefaultPortStart() {
+ return defaultPortStart;
+ }
+
+ @Override
+ public int getDefaultPortEnd() {
+ return defaultPortEnd;
+ }
+
+ @Override
+ public Scheme getScheme() {
+ return scheme;
+ }
+
+ @Override
+ public int getInstancePort() {
+ return defaultPortStart;
+ }
+}
diff --git a/engine/schema/src/org/apache/cloudstack/lb/dao/ApplicationLoadBalancerRuleDao.java b/engine/schema/src/org/apache/cloudstack/lb/dao/ApplicationLoadBalancerRuleDao.java
new file mode 100644
index 00000000000..c385e62f6ab
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/lb/dao/ApplicationLoadBalancerRuleDao.java
@@ -0,0 +1,35 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.cloudstack.lb.dao;
+
+import java.util.List;
+
+import org.apache.cloudstack.lb.ApplicationLoadBalancerRuleVO;
+
+import com.cloud.network.rules.LoadBalancerContainer.Scheme;
+import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.net.Ip;
+
+public interface ApplicationLoadBalancerRuleDao extends GenericDao{
+ List listBySrcIpSrcNtwkId(Ip sourceIp, long sourceNetworkId);
+ List listLbIpsBySourceIpNetworkId(long sourceIpNetworkId);
+ long countBySourceIp(Ip sourceIp, long sourceIpNetworkId);
+ List listBySourceIpAndNotRevoked(Ip sourceIp, long sourceNetworkId);
+ List listLbIpsBySourceIpNetworkIdAndScheme(long sourceIpNetworkId, Scheme scheme);
+
+}
diff --git a/engine/schema/src/org/apache/cloudstack/lb/dao/ApplicationLoadBalancerRuleDaoImpl.java b/engine/schema/src/org/apache/cloudstack/lb/dao/ApplicationLoadBalancerRuleDaoImpl.java
new file mode 100644
index 00000000000..880c67e732c
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/lb/dao/ApplicationLoadBalancerRuleDaoImpl.java
@@ -0,0 +1,115 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.cloudstack.lb.dao;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.apache.cloudstack.lb.ApplicationLoadBalancerRuleVO;
+import org.springframework.stereotype.Component;
+
+import com.cloud.network.rules.FirewallRule;
+import com.cloud.network.rules.LoadBalancerContainer.Scheme;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.GenericSearchBuilder;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.SearchCriteria.Func;
+import com.cloud.utils.db.SearchCriteria.Op;
+import com.cloud.utils.net.Ip;
+
+@Component
+@Local(value = { ApplicationLoadBalancerRuleDao.class })
+public class ApplicationLoadBalancerRuleDaoImpl extends GenericDaoBase implements ApplicationLoadBalancerRuleDao{
+ protected final SearchBuilder AllFieldsSearch;
+ final GenericSearchBuilder listIps;
+ final GenericSearchBuilder CountBy;
+ protected final SearchBuilder NotRevokedSearch;
+
+
+
+ protected ApplicationLoadBalancerRuleDaoImpl() {
+ AllFieldsSearch = createSearchBuilder();
+ AllFieldsSearch.and("sourceIp", AllFieldsSearch.entity().getSourceIp(), SearchCriteria.Op.EQ);
+ AllFieldsSearch.and("sourceIpNetworkId", AllFieldsSearch.entity().getSourceIpNetworkId(), SearchCriteria.Op.EQ);
+ AllFieldsSearch.and("networkId", AllFieldsSearch.entity().getNetworkId(), SearchCriteria.Op.EQ);
+ AllFieldsSearch.and("scheme", AllFieldsSearch.entity().getScheme(), SearchCriteria.Op.EQ);
+ AllFieldsSearch.done();
+
+ listIps = createSearchBuilder(String.class);
+ listIps.select(null, Func.DISTINCT, listIps.entity().getSourceIp());
+ listIps.and("sourceIpNetworkId", listIps.entity().getSourceIpNetworkId(), Op.EQ);
+ listIps.and("scheme", listIps.entity().getScheme(), Op.EQ);
+ listIps.done();
+
+ CountBy = createSearchBuilder(Long.class);
+ CountBy.select(null, Func.COUNT, CountBy.entity().getId());
+ CountBy.and("sourceIp", CountBy.entity().getSourceIp(), Op.EQ);
+ CountBy.and("sourceIpNetworkId", CountBy.entity().getSourceIpNetworkId(), Op.EQ);
+ CountBy.done();
+
+ NotRevokedSearch = createSearchBuilder();
+ NotRevokedSearch.and("sourceIp", NotRevokedSearch.entity().getSourceIp(), SearchCriteria.Op.EQ);
+ NotRevokedSearch.and("sourceIpNetworkId", NotRevokedSearch.entity().getSourceIpNetworkId(), SearchCriteria.Op.EQ);
+ NotRevokedSearch.and("state", NotRevokedSearch.entity().getState(), SearchCriteria.Op.NEQ);
+ NotRevokedSearch.done();
+ }
+
+ @Override
+ public List listBySrcIpSrcNtwkId(Ip sourceIp, long sourceNetworkId) {
+ SearchCriteria sc = AllFieldsSearch.create();
+ sc.setParameters("sourceIp", sourceIp);
+ sc.setParameters("sourceIpNetworkId", sourceNetworkId);
+ return listBy(sc);
+ }
+
+ @Override
+ public List listLbIpsBySourceIpNetworkId(long sourceIpNetworkId) {
+ SearchCriteria sc = listIps.create();
+ sc.setParameters("sourceIpNetworkId", sourceIpNetworkId);
+ return customSearch(sc, null);
+ }
+
+ @Override
+ public long countBySourceIp(Ip sourceIp, long sourceIpNetworkId) {
+ SearchCriteria sc = CountBy.create();
+ sc.setParameters("sourceIp", sourceIp);
+ sc.setParameters("sourceIpNetworkId", sourceIpNetworkId);
+ List results = customSearch(sc, null);
+ return results.get(0);
+ }
+
+ @Override
+ public List listBySourceIpAndNotRevoked(Ip sourceIp, long sourceNetworkId) {
+ SearchCriteria sc = NotRevokedSearch.create();
+ sc.setParameters("sourceIp", sourceIp);
+ sc.setParameters("sourceIpNetworkId", sourceNetworkId);
+ sc.setParameters("state", FirewallRule.State.Revoke);
+ return listBy(sc);
+ }
+
+ @Override
+ public List listLbIpsBySourceIpNetworkIdAndScheme(long sourceIpNetworkId, Scheme scheme) {
+ SearchCriteria sc = listIps.create();
+ sc.setParameters("sourceIpNetworkId", sourceIpNetworkId);
+ sc.setParameters("scheme", scheme);
+ return customSearch(sc, null);
+ }
+
+}
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java
index 9bd7cb7b4a6..3f9e3a1e40d 100644
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java
@@ -349,6 +349,11 @@ public class TemplateServiceImpl implements TemplateService {
tmpltStore.setPhysicalSize(tmpltInfo.getPhysicalSize());
tmpltStore.setDataStoreRole(store.getRole());
_vmTemplateStoreDao.persist(tmpltStore);
+
+ // update size in vm_template table
+ VMTemplateVO tmlpt = _templateDao.findById(tmplt.getId());
+ tmlpt.setSize(tmpltInfo.getSize());
+ _templateDao.update(tmplt.getId(), tmlpt);
associateTemplateToZone(tmplt.getId(), zoneId);
}
diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeVO.java b/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeVO.java
index da8234e35f3..831022455c9 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeVO.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeVO.java
@@ -156,6 +156,7 @@ public class VolumeVO implements Identity, StateObject {
this(that.getSize(), that.getVolumeType(), that.getName(), that.getTemplateId());
this.recreatable = that.isRecreatable();
this.state = that.getState();
+
this.size = that.getSize();
this.diskOfferingId = that.getDiskOfferingId();
this.poolId = that.getPoolId();
@@ -413,4 +414,5 @@ public class VolumeVO implements Identity, StateObject {
public void setDiskType(DiskFormat type) {
diskType = type;
}
+
}
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java
index fcb5c323183..2c3ab9969a0 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java
@@ -56,7 +56,7 @@ public class DefaultHostListener implements HypervisorHostListener {
}
if (!answer.getResult()) {
- String msg = "Add host failed due to ModifyStoragePoolCommand failed" + answer.getDetails();
+ String msg = "Unable to attach storage pool" + poolId + " to the host" + hostId;
alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, pool.getDataCenterId(), pool.getPodId(), msg, msg);
throw new CloudRuntimeException("Unable establish connection from storage head to storage pool " + pool.getId() + " due to " + answer.getDetails() + pool.getId());
}
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
index bd6df5798c6..2b7f4ed98c0 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
@@ -862,9 +862,8 @@ public class VolumeServiceImpl implements VolumeService {
return future;
}
CreateVolumeContext context = new CreateVolumeContext(null, volume, future);
- AsyncCallbackDispatcher caller = AsyncCallbackDispatcher.create(this);
- caller.setCallback(caller.getTarget().registerVolumeCallback(null, null))
- .setContext(context);
+ AsyncCallbackDispatcher caller = AsyncCallbackDispatcher.create(this);
+ caller.setCallback(caller.getTarget().resizeVolumeCallback(caller, context)).setContext(context);
volume.getDataStore().getDriver().resize(volume, caller);
return future;
}
diff --git a/packaging/centos63/cloud.spec b/packaging/centos63/cloud.spec
index a7cc20e8ab8..1cde336e7b1 100644
--- a/packaging/centos63/cloud.spec
+++ b/packaging/centos63/cloud.spec
@@ -205,6 +205,7 @@ mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/setup
mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}/management
mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}/awsapi
mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/management
+mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}-management
# Specific for tomcat
mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/management/Catalina/localhost/client
@@ -259,6 +260,7 @@ chmod 770 ${RPM_BUILD_ROOT}%{_localstatedir}/cache/%{name}/management/work
chmod 770 ${RPM_BUILD_ROOT}%{_localstatedir}/cache/%{name}/management/temp
chmod 770 ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}/management
chmod 770 ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}/agent
+chmod 770 ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}-management
# KVM Agent
mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/agent
@@ -397,6 +399,8 @@ if [ -L $oldserverxml ] ; then
if [ -L $serverxml ]; then rm -f $serverxml; fi
ln -s %{_sysconfdir}/%{name}/management/server-ssl.xml $serverxml
fi
+else
+ echo "Unable to determine ssl settings for server.xml, please run cloudstack-setup-management manually"
fi
tomcatconf=%{_sysconfdir}/%{name}/management/tomcat6.conf
@@ -409,6 +413,8 @@ if [ -L $oldtomcatconf ] ; then
if [ -L $tomcatconf ]; then rm -f $tomcatconf; fi
ln -s %{_sysconfdir}/%{name}/management/tomcat6-ssl.conf $tomcatconf
fi
+else
+ echo "Unable to determine ssl settings for tomcat.conf, please run cloudstack-setup-management manually"
fi
%preun agent
@@ -510,6 +516,7 @@ fi
%attr(0755,root,root) %{_bindir}/%{name}-external-ipallocator.py
%attr(0755,root,root) %{_initrddir}/%{name}-ipallocator
%dir %attr(0770,root,root) %{_localstatedir}/log/%{name}/ipallocator
+%dir %attr(0770,root,root) %{_localstatedir}/log/%{name}-management
%{_defaultdocdir}/%{name}-management-%{version}/LICENSE
%{_defaultdocdir}/%{name}-management-%{version}/NOTICE
diff --git a/patches/systemvm/debian/config/etc/init.d/cloud-early-config b/patches/systemvm/debian/config/etc/init.d/cloud-early-config
index ed3894f61cb..a457f228653 100755
--- a/patches/systemvm/debian/config/etc/init.d/cloud-early-config
+++ b/patches/systemvm/debian/config/etc/init.d/cloud-early-config
@@ -901,6 +901,28 @@ setup_elbvm() {
chkconfig portmap off
}
+setup_ilbvm() {
+ log_it "Setting up Internal Load Balancer system vm"
+ local hyp=$1
+ setup_common eth0 eth1
+ #eth0 = guest network, eth1=control network
+
+ sed -i /$NAME/d /etc/hosts
+ echo "$ETH0_IP $NAME" >> /etc/hosts
+
+ cp /etc/iptables/iptables-ilbvm /etc/iptables/rules.v4
+ cp /etc/iptables/iptables-ilbvm /etc/iptables/rules
+ setup_sshd $ETH1_IP "eth1"
+
+ enable_fwding 0
+ enable_svc haproxy 1
+ enable_svc dnsmasq 0
+ enable_svc cloud-passwd-srvr 0
+ enable_svc cloud 0
+ chkconfig nfs-common off
+ chkconfig portmap off
+}
+
setup_default() {
cat > /etc/network/interfaces << EOF
auto lo
@@ -951,6 +973,10 @@ start() {
[ "$NAME" == "" ] && NAME=elb
setup_elbvm
;;
+ ilbvm)
+ [ "$NAME" == "" ] && NAME=ilb
+ setup_ilbvm
+ ;;
unknown)
[ "$NAME" == "" ] && NAME=systemvm
setup_default;
diff --git a/patches/systemvm/debian/config/etc/iptables/iptables-ilbvm b/patches/systemvm/debian/config/etc/iptables/iptables-ilbvm
new file mode 100755
index 00000000000..8d5ca651c75
--- /dev/null
+++ b/patches/systemvm/debian/config/etc/iptables/iptables-ilbvm
@@ -0,0 +1,33 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+*nat
+:PREROUTING ACCEPT [0:0]
+:POSTROUTING ACCEPT [0:0]
+:OUTPUT ACCEPT [0:0]
+COMMIT
+*filter
+:INPUT DROP [0:0]
+:FORWARD DROP [0:0]
+:OUTPUT ACCEPT [0:0]
+-A INPUT -i eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
+-A INPUT -i eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
+-A INPUT -p icmp -j ACCEPT
+-A INPUT -i lo -j ACCEPT
+-A INPUT -i eth1 -p tcp -m state --state NEW --dport 3922 -j ACCEPT
+COMMIT
+
diff --git a/patches/systemvm/debian/config/opt/cloud/bin/ilb.sh b/patches/systemvm/debian/config/opt/cloud/bin/ilb.sh
new file mode 100755
index 00000000000..2a298925be3
--- /dev/null
+++ b/patches/systemvm/debian/config/opt/cloud/bin/ilb.sh
@@ -0,0 +1,211 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+source /root/func.sh
+
+lock="biglock"
+locked=$(getLockFile $lock)
+if [ "$locked" != "1" ]
+then
+ exit 1
+fi
+
+usage() {
+ printf "Usage: %s: -a -d -f -s \n" $(basename $0) >&2
+}
+
+#set -x
+
+fw_remove_backup() {
+ logger -t cloud "$(basename $0): Entering fw_remove_backup"
+ local lb_vif_list=eth0
+ for vif in $lb_vif_list; do
+ sudo iptables -F back_load_balancer_$vif 2> /dev/null
+ sudo iptables -D INPUT -i $vif -p tcp -j back_load_balancer_$vif 2> /dev/null
+ sudo iptables -X back_load_balancer_$vif 2> /dev/null
+ done
+ sudo iptables -F back_lb_stats 2> /dev/null
+ sudo iptables -D INPUT -p tcp -j back_lb_stats 2> /dev/null
+ sudo iptables -X back_lb_stats 2> /dev/null
+}
+
+fw_restore() {
+ logger -t cloud "$(basename $0): Entering fw_restore"
+ local lb_vif_list="eth0"
+ for vif in $lb_vif_list; do
+ sudo iptables -F load_balancer_$vif 2> /dev/null
+ sudo iptables -D INPUT -i $vif -p tcp -j load_balancer_$vif 2> /dev/null
+ sudo iptables -X load_balancer_$vif 2> /dev/null
+ sudo iptables -E back_load_balancer_$vif load_balancer_$vif 2> /dev/null
+ done
+ sudo iptables -F lb_stats 2> /dev/null
+ sudo iptables -D INPUT -p tcp -j lb_stats 2> /dev/null
+ sudo iptables -X lb_stats 2> /dev/null
+ sudo iptables -E back_lb_stats lb_stats 2> /dev/null
+}
+
+# firewall entry to ensure that haproxy can receive on specified port
+fw_entry() {
+ logger -t cloud "$(basename $0): Entering fw_entry"
+ local added=$1
+ local removed=$2
+ local stats=$3
+
+ if [ "$added" == "none" ]
+ then
+ added=""
+ fi
+
+ if [ "$removed" == "none" ]
+ then
+ removed=""
+ fi
+
+ local a=$(echo $added | cut -d, -f1- --output-delimiter=" ")
+ local r=$(echo $removed | cut -d, -f1- --output-delimiter=" ")
+
+# back up the iptable rules by renaming before creating new.
+ local lb_vif_list=eth0
+ for vif in $lb_vif_list; do
+ sudo iptables -E load_balancer_$vif back_load_balancer_$vif 2> /dev/null
+ sudo iptables -N load_balancer_$vif 2> /dev/null
+ sudo iptables -A INPUT -i $vif -p tcp -j load_balancer_$vif
+ done
+ sudo iptables -E lb_stats back_lb_stats 2> /dev/null
+ sudo iptables -N lb_stats 2> /dev/null
+ sudo iptables -A INPUT -p tcp -j lb_stats
+
+ for i in $a
+ do
+ local pubIp=$(echo $i | cut -d: -f1)
+ local dport=$(echo $i | cut -d: -f2)
+ local lb_vif_list="eth0"
+ for vif in $lb_vif_list; do
+ sudo iptables -A load_balancer_$vif -p tcp -d $pubIp --dport $dport -j ACCEPT
+ if [ $? -gt 0 ]
+ then
+ return 1
+ fi
+ done
+ done
+ local pubIp=$(echo $stats | cut -d: -f1)
+ local dport=$(echo $stats | cut -d: -f2)
+ local cidrs=$(echo $stats | cut -d: -f3 | sed 's/-/,/')
+ sudo iptables -A lb_stats -s $cidrs -p tcp -m state --state NEW -d $pubIp --dport $dport -j ACCEPT
+
+ return 0
+}
+
+#Hot reconfigure HA Proxy in the routing domain
+reconfig_lb() {
+ /root/reconfigLB.sh
+ return $?
+}
+
+# Restore the HA Proxy to its previous state, and revert iptables rules on loadbalancer
+restore_lb() {
+ logger -t cloud "Restoring HA Proxy to previous state"
+ # Copy the old version of haproxy.cfg into the file that reconfigLB.sh uses
+ cp /etc/haproxy/haproxy.cfg.old /etc/haproxy/haproxy.cfg.new
+
+ if [ $? -eq 0 ]
+ then
+ # Run reconfigLB.sh again
+ /root/reconfigLB.sh
+ fi
+}
+
+
+logger -t cloud "$(basename $0): Entering $(dirname $0)/$(basename $0)"
+
+iflag=
+aflag=
+dflag=
+sflag=
+
+while getopts 'i:a:d:s:' OPTION
+do
+ case $OPTION in
+ i) iflag=1
+ domRIp="$OPTARG" #unused but passed in
+ ;;
+ a) aflag=1
+ addedIps="$OPTARG"
+ ;;
+ d) dflag=1
+ removedIps="$OPTARG"
+ ;;
+
+ s) sflag=1
+ statsIp="$OPTARG"
+ ;;
+ ?) usage
+ unlock_exit 2 $lock $locked
+ ;;
+ esac
+done
+
+if [[ "$aflag$dflag" != "1" && "$aflag$dflag" != "11" ]]
+then
+ usage
+ unlock_exit 2 $lock $locked
+fi
+
+if [ "$addedIps" == "" ]
+then
+ addedIps="none"
+fi
+
+
+if [ "$removedIps" == "" ]
+then
+ removedIps="none"
+fi
+
+
+# hot reconfigure haproxy
+reconfig_lb $cfgfile
+
+if [ $? -gt 0 ]
+then
+ logger -t cloud "Reconfiguring ilb failed"
+ unlock_exit 1 $lock $locked
+fi
+
+logger -t cloud "HAProxy reconfigured successfully, configuring firewall"
+
+# iptables entry to ensure that haproxy receives traffic
+fw_entry $addedIps $removedIps $statsIp
+
+if [ $? -gt 0 ]
+then
+ logger -t cloud "Failed to apply firewall rules for internal load balancing, reverting HA Proxy config"
+ # Restore the LB
+ restore_lb
+
+ logger -t cloud "Reverting firewall config"
+ fw_restore
+
+ unlock_exit 1 $lock $locked
+else
+ # Remove backedup iptable rules
+ logger -t cloud "Firewall configured successfully, deleting backup firewall config"
+ fw_remove_backup
+fi
+
+unlock_exit 0 $lock $locked
diff --git a/patches/systemvm/debian/config/opt/cloud/bin/patchsystemvm.sh b/patches/systemvm/debian/config/opt/cloud/bin/patchsystemvm.sh
index 8816ad7c068..9cb02502ef1 100755
--- a/patches/systemvm/debian/config/opt/cloud/bin/patchsystemvm.sh
+++ b/patches/systemvm/debian/config/opt/cloud/bin/patchsystemvm.sh
@@ -135,6 +135,19 @@ elbvm_svcs() {
echo "cloud dnsmasq cloud-passwd-srvr apache2 nfs-common portmap" > /var/cache/cloud/disabled_svcs
}
+
+ilbvm_svcs() {
+ chkconfig cloud off
+ chkconfig haproxy on ;
+ chkconfig ssh on
+ chkconfig nfs-common off
+ chkconfig portmap off
+ chkconfig keepalived off
+ chkconfig conntrackd off
+ echo "ssh haproxy" > /var/cache/cloud/enabled_svcs
+ echo "cloud dnsmasq cloud-passwd-srvr apache2 nfs-common portmap" > /var/cache/cloud/disabled_svcs
+}
+
enable_pcihotplug() {
sed -i -e "/acpiphp/d" /etc/modules
sed -i -e "/pci_hotplug/d" /etc/modules
@@ -253,4 +266,14 @@ then
fi
fi
+if [ "$TYPE" == "ilbvm" ]
+then
+ ilbvm_svcs
+ if [ $? -gt 0 ]
+ then
+ printf "Failed to execute ilbvm svcs\n" >$logfile
+ exit 9
+ fi
+fi
+
exit $?
diff --git a/patches/systemvm/debian/config/opt/cloud/bin/vpc_acl.sh b/patches/systemvm/debian/config/opt/cloud/bin/vpc_acl.sh
index 8a207e880be..903d6d6127a 100755
--- a/patches/systemvm/debian/config/opt/cloud/bin/vpc_acl.sh
+++ b/patches/systemvm/debian/config/opt/cloud/bin/vpc_acl.sh
@@ -102,6 +102,7 @@ acl_entry_for_guest_network() {
local sport=$(echo $rule | cut -d: -f3)
local eport=$(echo $rule | cut -d: -f4)
local cidrs=$(echo $rule | cut -d: -f5 | sed 's/-/ /g')
+ local action=$(echo $rule | cut -d: -f6)
if [ "$sport" == "0" -a "$eport" == "0" ]
then
DPORT=""
@@ -123,21 +124,21 @@ acl_entry_for_guest_network() {
if [ "$ttype" == "Ingress" ]
then
sudo iptables -I ACL_INBOUND_$dev -p $prot -s $lcidr \
- --icmp-type $typecode -j ACCEPT
+ --icmp-type $typecode -j $action
else
let egress++
sudo iptables -t mangle -I ACL_OUTBOUND_$dev -p $prot -d $lcidr \
- --icmp-type $typecode -j ACCEPT
+ --icmp-type $typecode -j $action
fi
else
if [ "$ttype" == "Ingress" ]
then
sudo iptables -I ACL_INBOUND_$dev -p $prot -s $lcidr \
- $DPORT -j ACCEPT
+ $DPORT -j $action
else
let egress++
sudo iptables -t mangle -I ACL_OUTBOUND_$dev -p $prot -d $lcidr \
- $DPORT -j ACCEPT
+ $DPORT -j $action
fi
fi
result=$?
@@ -195,7 +196,7 @@ fi
# protocal:sport:eport:cidr
#-a tcp:80:80:0.0.0.0/0::tcp:220:220:0.0.0.0/0:,172.16.92.44:tcp:222:222:192.168.10.0/24-75.57.23.0/22-88.100.33.1/32
# if any entry is reverted , entry will be in the format :reverted:0:0:0
-# example : 172.16.92.44:tcp:80:80:0.0.0.0/0:,172.16.92.44:tcp:220:220:0.0.0.0/0:,200.1.1.2:reverted:0:0:0
+# example : 172.16.92.44:tcp:80:80:0.0.0.0/0:ACCEPT:,172.16.92.44:tcp:220:220:0.0.0.0/0:DROP,200.1.1.2:reverted:0:0:0
success=0
diff --git a/patches/systemvm/debian/config/opt/cloud/bin/vpc_loadbalancer.sh b/patches/systemvm/debian/config/opt/cloud/bin/vpc_loadbalancer.sh
index 334c6177392..36a2347a297 100755
--- a/patches/systemvm/debian/config/opt/cloud/bin/vpc_loadbalancer.sh
+++ b/patches/systemvm/debian/config/opt/cloud/bin/vpc_loadbalancer.sh
@@ -18,6 +18,29 @@
# @VERSION@
+do_ilb_if_ilb () {
+ local typ=""
+ local pattern="type=(.*)"
+
+ for keyval in $(cat /var/cache/cloud/cmdline)
+ do
+ if [[ $keyval =~ $pattern ]]; then
+ typ=${BASH_REMATCH[1]};
+ fi
+ done
+ if [ "$typ" == "ilbvm" ]
+ then
+ logger -t cloud "$(basename $0): Detected that we are running in an internal load balancer vm"
+ $(dirname $0)/ilb.sh "$@"
+ exit $?
+ fi
+
+}
+
+logger -t cloud "$(basename $0): Entering $(dirname $0)/$(basename $0)"
+
+do_ilb_if_ilb "$@"
+
source /root/func.sh
source /opt/cloud/bin/vpc_func.sh
diff --git a/patches/systemvm/debian/config/opt/cloud/bin/vpc_privategw_acl.sh b/patches/systemvm/debian/config/opt/cloud/bin/vpc_privategw_acl.sh
new file mode 100755
index 00000000000..d4e3eba14a5
--- /dev/null
+++ b/patches/systemvm/debian/config/opt/cloud/bin/vpc_privategw_acl.sh
@@ -0,0 +1,224 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# vpc_privategw_acl.sh_rule.sh -- allow/block some ports / protocols to vm instances
+# @VERSION@
+
+source /root/func.sh
+
+lock="biglock"
+locked=$(getLockFile $lock)
+if [ "$locked" != "1" ]
+then
+ exit 1
+fi
+
+usage() {
+ printf "Usage: %s: -a \n" $(basename $0) >&2
+ printf "sourcecidrs format: cidr1-cidr2-cidr3-...\n"
+}
+#set -x
+#FIXME: eating up the error code during execution of iptables
+
+acl_switch_to_new() {
+ sudo iptables -D FORWARD -o $dev -j _ACL_INBOUND_$dev 2>/dev/null
+ sudo iptables-save | grep "\-j _ACL_INBOUND_$dev" | grep "\-A" | while read rule;
+ do
+ rule1=$(echo $rule | sed 's/\_ACL_INBOUND/ACL_INBOUND/')
+ sudo iptables $rule1
+ rule2=$(echo $rule | sed 's/\-A/\-D/')
+ sudo iptables $rule2
+ done
+ sudo iptables -F _ACL_INBOUND_$dev 2>/dev/null
+ sudo iptables -X _ACL_INBOUND_$dev 2>/dev/null
+ sudo iptables -t mangle -F _ACL_OUTBOUND_$dev 2>/dev/null
+ sudo iptables -t mangle -D PREROUTING -m state --state NEW -i $dev -j _ACL_OUTBOUND_$dev 2>/dev/null
+ sudo iptables -t mangle -X _ACL_OUTBOUND_$dev 2>/dev/null
+}
+
+acl_remove_backup() {
+ sudo iptables -F _ACL_INBOUND_$dev 2>/dev/null
+ sudo iptables -D FORWARD -o $dev -j _ACL_INBOUND_$dev 2>/dev/null
+ sudo iptables -X _ACL_INBOUND_$dev 2>/dev/null
+ sudo iptables -t mangle -F _ACL_OUTBOUND_$dev 2>/dev/null
+ sudo iptables -t mangle -D PREROUTING -m state --state NEW -i $dev -j _ACL_OUTBOUND_$dev 2>/dev/null
+ sudo iptables -t mangle -X _ACL_OUTBOUND_$dev 2>/dev/null
+}
+
+acl_remove() {
+ sudo iptables -F ACL_INBOUND_$dev 2>/dev/null
+ sudo iptables -D FORWARD -o $dev -j ACL_INBOUND_$dev 2>/dev/null
+ sudo iptables -X ACL_INBOUND_$dev 2>/dev/null
+ sudo iptables -t mangle -F ACL_OUTBOUND_$dev 2>/dev/null
+ sudo iptables -t mangle -D PREROUTING -m state --state NEW -i $dev -j ACL_OUTBOUND_$dev 2>/dev/null
+ sudo iptables -t mangle -X ACL_OUTBOUND_$dev 2>/dev/null
+}
+
+acl_restore() {
+ acl_remove
+ sudo iptables -E _ACL_INBOUND_$dev ACL_INBOUND_$dev 2>/dev/null
+ sudo iptables -t mangle -E _ACL_OUTBOUND_$dev ACL_OUTBOUND_$dev 2>/dev/null
+}
+
+acl_save() {
+ acl_remove_backup
+ sudo iptables -E ACL_INBOUND_$dev _ACL_INBOUND_$dev 2>/dev/null
+ sudo iptables -t mangle -E ACL_OUTBOUND_$dev _ACL_OUTBOUND_$dev 2>/dev/null
+}
+
+acl_chain_for_guest_network () {
+ acl_save
+ # inbound
+ sudo iptables -N ACL_INBOUND_$dev 2>/dev/null
+ # drop if no rules match (this will be the last rule in the chain)
+ sudo iptables -A ACL_INBOUND_$dev -j DROP 2>/dev/null
+ sudo iptables -A FORWARD -o $dev -j ACL_INBOUND_$dev 2>/dev/null
+ # outbound
+ sudo iptables -t mangle -N ACL_OUTBOUND_$dev 2>/dev/null
+ sudo iptables -t mangle -A PREROUTING -m state --state NEW -i $dev -j ACL_OUTBOUND_$dev 2>/dev/null
+}
+
+
+
+acl_entry_for_guest_network() {
+ local rule=$1
+
+ local ttype=$(echo $rule | cut -d: -f1)
+ local prot=$(echo $rule | cut -d: -f2)
+ local sport=$(echo $rule | cut -d: -f3)
+ local eport=$(echo $rule | cut -d: -f4)
+ local cidrs=$(echo $rule | cut -d: -f5 | sed 's/-/ /g')
+ local action=$(echo $rule | cut -d: -f6)
+ if [ "$sport" == "0" -a "$eport" == "0" ]
+ then
+ DPORT=""
+ else
+ DPORT="--dport $sport:$eport"
+ fi
+ logger -t cloud "$(basename $0): enter apply acl rules on private gateway interface : $dev, inbound:$inbound:$prot:$sport:$eport:$cidrs"
+
+ # note that rules are inserted after the RELATED,ESTABLISHED rule
+ # but before the DROP rule
+ for lcidr in $cidrs
+ do
+ [ "$prot" == "reverted" ] && continue;
+ if [ "$prot" == "icmp" ]
+ then
+ typecode="$sport/$eport"
+ [ "$eport" == "-1" ] && typecode="$sport"
+ [ "$sport" == "-1" ] && typecode="any"
+ if [ "$ttype" == "Ingress" ]
+ then
+ sudo iptables -I ACL_INBOUND_$dev -p $prot -s $lcidr \
+ --icmp-type $typecode -j $action
+ else
+ let egress++
+ sudo iptables -t mangle -I ACL_OUTBOUND_$dev -p $prot -d $lcidr \
+ --icmp-type $typecode -j $action
+ fi
+ else
+ if [ "$ttype" == "Ingress" ]
+ then
+ sudo iptables -I ACL_INBOUND_$dev -p $prot -s $lcidr \
+ $DPORT -j $action
+ else
+ let egress++
+ sudo iptables -t mangle -I ACL_OUTBOUND_$dev -p $prot -d $lcidr \
+ $DPORT -j $action
+ fi
+ fi
+ result=$?
+ [ $result -gt 0 ] &&
+ logger -t cloud "Error adding iptables entry for private gateway interface : $dev,inbound:$inbound:$prot:$sport:$eport:$cidrs" &&
+ break
+ done
+
+ logger -t cloud "$(basename $0): exit apply acl rules for private gw interface : $dev"
+ return $result
+}
+
+
+dflag=0
+gflag=0
+aflag=0
+rules=""
+rules_list=""
+dev=""
+while getopts 'd:a:' OPTION
+do
+ case $OPTION in
+ d) dflag=1
+ dev="$OPTARG"
+ ;;
+ a) aflag=1
+ rules="$OPTARG"
+ ;;
+ ?) usage
+ unlock_exit 2 $lock $locked
+ ;;
+ esac
+done
+
+if [ "$dflag$aflag" != "11" ]
+then
+ usage
+ unlock_exit 2 $lock $locked
+fi
+
+if [ -n "$rules" ]
+then
+ rules_list=$(echo $rules | cut -d, -f1- --output-delimiter=" ")
+fi
+
+# rule format
+# protocal:sport:eport:cidr
+#-a tcp:80:80:0.0.0.0/0::tcp:220:220:0.0.0.0/0:,172.16.92.44:tcp:222:222:192.168.10.0/24-75.57.23.0/22-88.100.33.1/32
+# if any entry is reverted , entry will be in the format :reverted:0:0:0
+# example : 172.16.92.44:tcp:80:80:0.0.0.0/0:ACCEPT:,172.16.92.44:tcp:220:220:0.0.0.0/0:DROP,200.1.1.2:reverted:0:0:0
+
+success=0
+
+acl_chain_for_guest_network
+egress=0
+for r in $rules_list
+do
+ acl_entry_for_guest_network $r
+ success=$?
+ if [ $success -gt 0 ]
+ then
+ logger -t cloud "$(basename $0): failure to apply acl rules on private gateway interface : $dev"
+ break
+ else
+ logger -t cloud "$(basename $0): successful in applying acl rules on private gateway interface : $dev"
+ fi
+done
+
+if [ $success -gt 0 ]
+then
+ logger -t cloud "$(basename $0): restoring from backup on private gateway interface : $dev"
+ acl_restore
+else
+ logger -t cloud "$(basename $0): deleting backup on private gateway interface : $dev"
+ if [ $egress -eq 0 ]
+ then
+ sudo iptables -t mangle -A ACL_OUTBOUND_$dev -j ACCEPT 2>/dev/null
+ else
+ sudo iptables -t mangle -A ACL_OUTBOUND_$dev -j DROP 2>/dev/null
+ fi
+ acl_switch_to_new
+fi
+unlock_exit $success $lock $locked
diff --git a/patches/systemvm/debian/config/root/createIpAlias.sh b/patches/systemvm/debian/config/root/createIpAlias.sh
new file mode 100755
index 00000000000..2c798131fd4
--- /dev/null
+++ b/patches/systemvm/debian/config/root/createIpAlias.sh
@@ -0,0 +1,35 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+usage() {
+ printf " %s \n" $(basename $0) >&2
+}
+
+set -x
+var="$1"
+cert="/root/.ssh/id_rsa.cloud"
+
+while [ -n "$var" ]
+do
+ var1=$(echo $var | cut -f1 -d "-")
+ alias_count=$( echo $var1 | cut -f1 -d ":" )
+ routerip=$(echo $var1 | cut -f2 -d ":")
+ netmask=$(echo $var1 | cut -f3 -d ":")
+ ifconfig eth0:$alias_count $routerip netmask $netmask up
+ var=$( echo $var | sed "s/${var1}-//" )
+done
\ No newline at end of file
diff --git a/patches/systemvm/debian/config/root/deleteIpAlias.sh b/patches/systemvm/debian/config/root/deleteIpAlias.sh
new file mode 100755
index 00000000000..865ff3b4769
--- /dev/null
+++ b/patches/systemvm/debian/config/root/deleteIpAlias.sh
@@ -0,0 +1,43 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+usage() {
+ printf " %s \n" $(basename $0) >&2
+}
+
+set -x
+var="$1"
+cert="/root/.ssh/id_rsa.cloud"
+
+while [ -n "$var" ]
+do
+ var1=$(echo $var | cut -f1 -d "-")
+ alias_count=$( echo $var1 | cut -f1 -d ":" )
+ ifconfig eth0:$alias_count down
+ var=$( echo $var | sed "s/${var1}-//" )
+done
+
+#recreating the active ip aliases
+sh /root/createIpAlias.sh $2
+result=$?
+if [ "$result" -ne "0" ]
+then
+ exit $result
+fi
+
+exit 0
diff --git a/patches/systemvm/debian/config/root/dnsmasq.sh b/patches/systemvm/debian/config/root/dnsmasq.sh
new file mode 100755
index 00000000000..656fd3c320f
--- /dev/null
+++ b/patches/systemvm/debian/config/root/dnsmasq.sh
@@ -0,0 +1,43 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+usage() {
+ printf "Usage: %s: