mirror of https://github.com/apache/cloudstack.git
NaaS: Add configuration for virtual router elements
This commit is contained in:
parent
fdc354adb5
commit
2ebb719aba
|
|
@ -284,5 +284,6 @@ public class ApiConstants {
|
|||
public static final String DEST_PHYSICAL_NETWORK_ID = "destinationphysicalnetworkid";
|
||||
public static final String ENABLED = "enabled";
|
||||
public static final String SERVICE_NAME = "servicename";
|
||||
|
||||
public static final String DHCP_RANGE = "dhcprange";
|
||||
public static final String UUID = "uuid";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,15 +49,78 @@ public class ConfigureDhcpElementCmd extends BaseAsyncCmd {
|
|||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the dhcp element")
|
||||
private Long id;
|
||||
@Parameter(name=ApiConstants.UUID, type=CommandType.STRING, required=true, description="the UUID of the virtual router element")
|
||||
private String uuid;
|
||||
|
||||
@Parameter(name=ApiConstants.DHCP_SERVICE, type=CommandType.BOOLEAN, required=true, description="true is dhcp service would be enabled")
|
||||
private Boolean dhcpService;
|
||||
|
||||
@Parameter(name=ApiConstants.DNS_SERVICE, type=CommandType.BOOLEAN, required=true, description="true is dns service would be enabled")
|
||||
private Boolean dnsService;
|
||||
|
||||
@Parameter(name=ApiConstants.USERDATA_SERVICE, type=CommandType.BOOLEAN, required=true, description="true is user data service would be enabled")
|
||||
private Boolean userdataService;
|
||||
|
||||
@Parameter(name=ApiConstants.DHCP_RANGE, type=CommandType.STRING, description="the dhcp range for the DHCP service ")
|
||||
private String dhcpRange;
|
||||
|
||||
@Parameter(name=ApiConstants.DNS1, type=CommandType.STRING, description="the first DNS")
|
||||
private String dns1;
|
||||
|
||||
@Parameter(name=ApiConstants.DNS2, type=CommandType.STRING, description="the second DNS")
|
||||
private String dns2;
|
||||
|
||||
@Parameter(name=ApiConstants.INTERNAL_DNS1, type=CommandType.STRING, description="the first internal DNS")
|
||||
private String internalDns1;
|
||||
|
||||
@Parameter(name=ApiConstants.INTERNAL_DNS2, type=CommandType.STRING, description="the second internal DNS")
|
||||
private String internalDns2;
|
||||
|
||||
@Parameter(name=ApiConstants.DOMAIN, type=CommandType.STRING, description="the gateway ip")
|
||||
private String domainName;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
public String getUUID() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public Boolean getDhcpService() {
|
||||
return dhcpService;
|
||||
}
|
||||
|
||||
public Boolean getDnsService() {
|
||||
return dnsService;
|
||||
}
|
||||
|
||||
public Boolean getUserdataService() {
|
||||
return userdataService;
|
||||
}
|
||||
|
||||
public String getDomainName() {
|
||||
return domainName;
|
||||
}
|
||||
|
||||
public String getDhcpRange() {
|
||||
return dhcpRange;
|
||||
}
|
||||
|
||||
public String getDns1() {
|
||||
return dns1;
|
||||
}
|
||||
|
||||
public String getDns2() {
|
||||
return dns2;
|
||||
}
|
||||
|
||||
public String getInternalDns1() {
|
||||
return internalDns1;
|
||||
}
|
||||
|
||||
public String getInternalDns2() {
|
||||
return internalDns2;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -85,7 +148,7 @@ public class ConfigureDhcpElementCmd extends BaseAsyncCmd {
|
|||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "configuring dhcp element: " + getId();
|
||||
return "configuring dhcp element: " + getUUID();
|
||||
}
|
||||
|
||||
public AsyncJob.Type getInstanceType() {
|
||||
|
|
@ -93,13 +156,13 @@ public class ConfigureDhcpElementCmd extends BaseAsyncCmd {
|
|||
}
|
||||
|
||||
public Long getInstanceId() {
|
||||
return getId();
|
||||
return _service.getIdByUUID(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
|
||||
UserContext.current().setEventDetails("Dhcp element Id: " + getId());
|
||||
Boolean result = _service.configure();
|
||||
UserContext.current().setEventDetails("Dhcp element: " + getUUID());
|
||||
Boolean result = _service.configure(this);
|
||||
if (result){
|
||||
SuccessResponse response = new SuccessResponse();
|
||||
response.setResponseName(getCommandName());
|
||||
|
|
|
|||
|
|
@ -49,17 +49,122 @@ public class ConfigureRedundantVirtualRouterElementCmd extends BaseAsyncCmd {
|
|||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the redundant virtual router element")
|
||||
private Long id;
|
||||
@Parameter(name=ApiConstants.UUID, type=CommandType.STRING, required=true, description="the UUID of the virtual router element")
|
||||
private String uuid;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
@Parameter(name=ApiConstants.DHCP_SERVICE, type=CommandType.BOOLEAN, required=true, description="true is dhcp service would be enabled")
|
||||
private Boolean dhcpService;
|
||||
|
||||
@Parameter(name=ApiConstants.DNS_SERVICE, type=CommandType.BOOLEAN, required=true, description="true is dns service would be enabled")
|
||||
private Boolean dnsService;
|
||||
|
||||
@Parameter(name=ApiConstants.GATEWAY_SERVICE, type=CommandType.BOOLEAN, required=true, description="true is gateway service would be enabled")
|
||||
private Boolean gatewayService;
|
||||
|
||||
@Parameter(name=ApiConstants.FIREWALL_SERVICE, type=CommandType.BOOLEAN, required=true, description="true is firewall service would be enabled")
|
||||
private Boolean firewallService;
|
||||
|
||||
@Parameter(name=ApiConstants.LB_SERVICE, type=CommandType.BOOLEAN, required=true, description="true is lb service would be enabled")
|
||||
private Boolean lbService;
|
||||
|
||||
@Parameter(name=ApiConstants.USERDATA_SERVICE, type=CommandType.BOOLEAN, required=true, description="true is user data service would be enabled")
|
||||
private Boolean userdataService;
|
||||
|
||||
@Parameter(name=ApiConstants.SOURCE_NAT_SERVICE, type=CommandType.BOOLEAN, required=true, description="true is source nat service would be enabled")
|
||||
private Boolean sourceNatService;
|
||||
|
||||
@Parameter(name=ApiConstants.VPN_SERVICE, type=CommandType.BOOLEAN, required=true, description="true is vpn service would be enabled")
|
||||
private Boolean vpnService;
|
||||
|
||||
@Parameter(name=ApiConstants.DHCP_RANGE, type=CommandType.STRING, description="the dhcp range for the DHCP service ")
|
||||
private String dhcpRange;
|
||||
|
||||
@Parameter(name=ApiConstants.DNS1, type=CommandType.STRING, description="the first DNS")
|
||||
private String dns1;
|
||||
|
||||
@Parameter(name=ApiConstants.DNS2, type=CommandType.STRING, description="the second DNS")
|
||||
private String dns2;
|
||||
|
||||
@Parameter(name=ApiConstants.INTERNAL_DNS1, type=CommandType.STRING, description="the first internal DNS")
|
||||
private String internalDns1;
|
||||
|
||||
@Parameter(name=ApiConstants.INTERNAL_DNS2, type=CommandType.STRING, description="the second internal DNS")
|
||||
private String internalDns2;
|
||||
|
||||
@Parameter(name=ApiConstants.GATEWAY, type=CommandType.STRING, description="the gateway ip")
|
||||
private String gateway;
|
||||
|
||||
@Parameter(name=ApiConstants.DOMAIN, type=CommandType.STRING, description="the gateway ip")
|
||||
private String domainName;
|
||||
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
public String getUUID() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public Boolean getDhcpService() {
|
||||
return dhcpService;
|
||||
}
|
||||
|
||||
public Boolean getDnsService() {
|
||||
return dnsService;
|
||||
}
|
||||
|
||||
public Boolean getGatewayService() {
|
||||
return gatewayService;
|
||||
}
|
||||
|
||||
public Boolean getFirewallService() {
|
||||
return firewallService;
|
||||
}
|
||||
|
||||
public Boolean getLbService() {
|
||||
return lbService;
|
||||
}
|
||||
|
||||
public Boolean getUserdataService() {
|
||||
return userdataService;
|
||||
}
|
||||
|
||||
public Boolean getSourceNatService() {
|
||||
return sourceNatService;
|
||||
}
|
||||
|
||||
public Boolean getVpnService() {
|
||||
return vpnService;
|
||||
}
|
||||
|
||||
public String getDomainName() {
|
||||
return domainName;
|
||||
}
|
||||
|
||||
public String getDhcpRange() {
|
||||
return dhcpRange;
|
||||
}
|
||||
|
||||
public String getDns1() {
|
||||
return dns1;
|
||||
}
|
||||
|
||||
public String getDns2() {
|
||||
return dns2;
|
||||
}
|
||||
|
||||
public String getInternalDns1() {
|
||||
return internalDns1;
|
||||
}
|
||||
|
||||
public String getInternalDns2() {
|
||||
return internalDns2;
|
||||
}
|
||||
|
||||
public String getGateway() {
|
||||
return gateway;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -85,7 +190,7 @@ public class ConfigureRedundantVirtualRouterElementCmd extends BaseAsyncCmd {
|
|||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "configuring redundant virtual router element: " + getId();
|
||||
return "configuring redundant virtual router element: " + getUUID();
|
||||
}
|
||||
|
||||
public AsyncJob.Type getInstanceType() {
|
||||
|
|
@ -93,13 +198,13 @@ public class ConfigureRedundantVirtualRouterElementCmd extends BaseAsyncCmd {
|
|||
}
|
||||
|
||||
public Long getInstanceId() {
|
||||
return getId();
|
||||
return _service.getIdByUUID(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
|
||||
UserContext.current().setEventDetails("Redundant virtual router element Id: " + getId());
|
||||
Boolean result = _service.configure();
|
||||
UserContext.current().setEventDetails("Redundant virtual router element: " + getUUID());
|
||||
Boolean result = _service.configure(this);
|
||||
if (result){
|
||||
SuccessResponse response = new SuccessResponse();
|
||||
response.setResponseName(getCommandName());
|
||||
|
|
|
|||
|
|
@ -49,15 +49,120 @@ public class ConfigureVirtualRouterElementCmd extends BaseAsyncCmd {
|
|||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the virtual router element")
|
||||
private Long id;
|
||||
@Parameter(name=ApiConstants.UUID, type=CommandType.STRING, required=true, description="the UUID of the virtual router element")
|
||||
private String uuid;
|
||||
|
||||
@Parameter(name=ApiConstants.DHCP_SERVICE, type=CommandType.BOOLEAN, required=true, description="true is dhcp service would be enabled")
|
||||
private Boolean dhcpService;
|
||||
|
||||
@Parameter(name=ApiConstants.DNS_SERVICE, type=CommandType.BOOLEAN, required=true, description="true is dns service would be enabled")
|
||||
private Boolean dnsService;
|
||||
|
||||
@Parameter(name=ApiConstants.GATEWAY_SERVICE, type=CommandType.BOOLEAN, required=true, description="true is gateway service would be enabled")
|
||||
private Boolean gatewayService;
|
||||
|
||||
@Parameter(name=ApiConstants.FIREWALL_SERVICE, type=CommandType.BOOLEAN, required=true, description="true is firewall service would be enabled")
|
||||
private Boolean firewallService;
|
||||
|
||||
@Parameter(name=ApiConstants.LB_SERVICE, type=CommandType.BOOLEAN, required=true, description="true is lb service would be enabled")
|
||||
private Boolean lbService;
|
||||
|
||||
@Parameter(name=ApiConstants.USERDATA_SERVICE, type=CommandType.BOOLEAN, required=true, description="true is user data service would be enabled")
|
||||
private Boolean userdataService;
|
||||
|
||||
@Parameter(name=ApiConstants.SOURCE_NAT_SERVICE, type=CommandType.BOOLEAN, required=true, description="true is source nat service would be enabled")
|
||||
private Boolean sourceNatService;
|
||||
|
||||
@Parameter(name=ApiConstants.VPN_SERVICE, type=CommandType.BOOLEAN, required=true, description="true is vpn service would be enabled")
|
||||
private Boolean vpnService;
|
||||
|
||||
@Parameter(name=ApiConstants.DHCP_RANGE, type=CommandType.STRING, description="the dhcp range for the DHCP service ")
|
||||
private String dhcpRange;
|
||||
|
||||
@Parameter(name=ApiConstants.DNS1, type=CommandType.STRING, description="the first DNS")
|
||||
private String dns1;
|
||||
|
||||
@Parameter(name=ApiConstants.DNS2, type=CommandType.STRING, description="the second DNS")
|
||||
private String dns2;
|
||||
|
||||
@Parameter(name=ApiConstants.INTERNAL_DNS1, type=CommandType.STRING, description="the first internal DNS")
|
||||
private String internalDns1;
|
||||
|
||||
@Parameter(name=ApiConstants.INTERNAL_DNS2, type=CommandType.STRING, description="the second internal DNS")
|
||||
private String internalDns2;
|
||||
|
||||
@Parameter(name=ApiConstants.GATEWAY, type=CommandType.STRING, description="the gateway ip")
|
||||
private String gateway;
|
||||
|
||||
@Parameter(name=ApiConstants.DOMAIN, type=CommandType.STRING, description="the gateway ip")
|
||||
private String domainName;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
public String getUUID() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public Boolean getDhcpService() {
|
||||
return dhcpService;
|
||||
}
|
||||
|
||||
public Boolean getDnsService() {
|
||||
return dnsService;
|
||||
}
|
||||
|
||||
public Boolean getGatewayService() {
|
||||
return gatewayService;
|
||||
}
|
||||
|
||||
public Boolean getFirewallService() {
|
||||
return firewallService;
|
||||
}
|
||||
|
||||
public Boolean getLbService() {
|
||||
return lbService;
|
||||
}
|
||||
|
||||
public Boolean getUserdataService() {
|
||||
return userdataService;
|
||||
}
|
||||
|
||||
public Boolean getSourceNatService() {
|
||||
return sourceNatService;
|
||||
}
|
||||
|
||||
public Boolean getVpnService() {
|
||||
return vpnService;
|
||||
}
|
||||
|
||||
public String getDomainName() {
|
||||
return domainName;
|
||||
}
|
||||
|
||||
public String getDhcpRange() {
|
||||
return dhcpRange;
|
||||
}
|
||||
|
||||
public String getDns1() {
|
||||
return dns1;
|
||||
}
|
||||
|
||||
public String getDns2() {
|
||||
return dns2;
|
||||
}
|
||||
|
||||
public String getInternalDns1() {
|
||||
return internalDns1;
|
||||
}
|
||||
|
||||
public String getInternalDns2() {
|
||||
return internalDns2;
|
||||
}
|
||||
|
||||
public String getGateway() {
|
||||
return gateway;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -85,7 +190,7 @@ public class ConfigureVirtualRouterElementCmd extends BaseAsyncCmd {
|
|||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "configuring virtual router element: " + getId();
|
||||
return "configuring virtual router element: " + getUUID();
|
||||
}
|
||||
|
||||
public AsyncJob.Type getInstanceType() {
|
||||
|
|
@ -93,13 +198,13 @@ public class ConfigureVirtualRouterElementCmd extends BaseAsyncCmd {
|
|||
}
|
||||
|
||||
public Long getInstanceId() {
|
||||
return getId();
|
||||
return _service.getIdByUUID(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
|
||||
UserContext.current().setEventDetails("Virtual router element Id: " + getId());
|
||||
Boolean result = _service.configure();
|
||||
UserContext.current().setEventDetails("Virtual router element: " + getUUID());
|
||||
Boolean result = _service.configure(this);
|
||||
if (result){
|
||||
SuccessResponse response = new SuccessResponse();
|
||||
response.setResponseName(getCommandName());
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
package com.cloud.network.element;
|
||||
|
||||
import com.cloud.api.commands.ConfigureDhcpElementCmd;
|
||||
import com.cloud.utils.component.PluggableService;
|
||||
|
||||
public interface DhcpElementService extends PluggableService{
|
||||
boolean configure();
|
||||
boolean configure(ConfigureDhcpElementCmd cmd);
|
||||
boolean addElement(Long nspId, String uuid);
|
||||
Long getIdByUUID(String uuid);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package com.cloud.network.element;
|
||||
|
||||
import com.cloud.utils.component.PluggableService;
|
||||
import com.cloud.api.commands.ConfigureRedundantVirtualRouterElementCmd;
|
||||
|
||||
public interface RedundantVirtualRouterElementService extends PluggableService{
|
||||
boolean configure();
|
||||
public interface RedundantVirtualRouterElementService extends VirtualRouterElementService {
|
||||
boolean configure(ConfigureRedundantVirtualRouterElementCmd cmd);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package com.cloud.network.element;
|
||||
|
||||
import com.cloud.utils.component.PluggableService;
|
||||
import com.cloud.api.commands.ConfigureVirtualRouterElementCmd;
|
||||
|
||||
public interface VirtualRouterElementService extends PluggableService{
|
||||
boolean configure();
|
||||
public interface VirtualRouterElementService extends DhcpElementService {
|
||||
boolean configure(ConfigureVirtualRouterElementCmd cmd);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
<adapter name="NetscalerExternalLoadBalancer" class="com.cloud.network.element.NetscalerExternalLoadBalancerElement"/>
|
||||
<adapter name="F5ExternalLoadBalancer" class="com.cloud.network.element.F5ExternalLoadBalancerElement"/>
|
||||
<adapter name="DomainRouter" class="com.cloud.network.element.VirtualRouterElement"/>
|
||||
<adapter name="RedundantVirtualRouter" class="com.cloud.network.element.RedundantVirtualRouterElement"/>
|
||||
<adapter name="Dhcp" class="com.cloud.network.element.DhcpElement"/>
|
||||
<adapter name="Ovs" class="com.cloud.network.element.OvsElement"/>
|
||||
<adapter name="ExternalDhcp" class="com.cloud.network.element.ExternalDhcpElement"/>
|
||||
|
|
|
|||
|
|
@ -131,5 +131,6 @@
|
|||
<dao name="AccountDao" class="com.cloud.user.dao.AccountDaoImpl" singleton="false"/>
|
||||
<dao name="UserDao" class="com.cloud.user.dao.UserDaoImpl" singleton="false"/>
|
||||
<dao name="NetworkOfferingServiceDao" class="com.cloud.offerings.dao.NetworkOfferingServiceMapDaoImpl" singleton="false"/>
|
||||
<dao name="VirtualRouterElementsDao" class="com.cloud.network.dao.VirtualRouterElementsDaoImpl" singleton="false"/>
|
||||
</configuration-server>
|
||||
</components.xml>
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ import com.cloud.network.dao.NetworkRuleConfigDaoImpl;
|
|||
import com.cloud.network.dao.PhysicalNetworkDaoImpl;
|
||||
import com.cloud.network.dao.PhysicalNetworkServiceProviderDaoImpl;
|
||||
import com.cloud.network.dao.RemoteAccessVpnDaoImpl;
|
||||
import com.cloud.network.dao.VirtualRouterElementsDaoImpl;
|
||||
import com.cloud.network.dao.VpnUserDaoImpl;
|
||||
import com.cloud.network.element.DhcpElement;
|
||||
import com.cloud.network.element.RedundantVirtualRouterElement;
|
||||
|
|
@ -295,6 +296,7 @@ public class DefaultComponentLibrary extends ComponentLibraryBase implements Com
|
|||
info.addParameter("cache.time.to.live", "600");
|
||||
addDao("PhysicalNetworkDao", PhysicalNetworkDaoImpl.class);
|
||||
addDao("PhysicalNetworkServiceProviderDao", PhysicalNetworkServiceProviderDaoImpl.class);
|
||||
addDao("VirtualRouterElementsDao", VirtualRouterElementsDaoImpl.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import com.cloud.network.element.VirtualRouterElementsVO;
|
|||
import com.cloud.network.element.VirtualRouterElements.VirtualRouterElementsType;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface VirtualRouterElementsDao extends GenericDao<VirtualRouterElementsVO, Long> {
|
||||
public interface VirtualRouterElementsDao extends GenericDao<VirtualRouterElementsVO, Long> {
|
||||
public List<VirtualRouterElementsVO> findByNspIdAndType(long nspId, VirtualRouterElementsType type);
|
||||
public VirtualRouterElementsVO findByUUID(String uuid);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ public class VirtualRouterElementsDaoImpl extends GenericDaoBase<VirtualRouterEl
|
|||
super();
|
||||
AllFieldsSearch = createSearchBuilder();
|
||||
AllFieldsSearch.and("nsp_id", AllFieldsSearch.entity().getNspId(), SearchCriteria.Op.EQ);
|
||||
AllFieldsSearch.and("uuid", AllFieldsSearch.entity().getUUID(), SearchCriteria.Op.EQ);
|
||||
AllFieldsSearch.and("uuid", AllFieldsSearch.entity().getUuid(), SearchCriteria.Op.EQ);
|
||||
AllFieldsSearch.and("type", AllFieldsSearch.entity().getType(), SearchCriteria.Op.EQ);
|
||||
AllFieldsSearch.done();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import javax.ejb.Local;
|
|||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.commands.ConfigureDhcpElementCmd;
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
|
|
@ -43,10 +44,12 @@ import com.cloud.network.Network.Type;
|
|||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.VirtualRouterElementsDao;
|
||||
import com.cloud.network.router.VirtualNetworkApplianceManager;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
import com.cloud.network.router.VirtualRouter.Role;
|
||||
import com.cloud.network.element.DhcpElementService;
|
||||
import com.cloud.network.element.VirtualRouterElements.VirtualRouterElementsType;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.org.Cluster;
|
||||
import com.cloud.user.AccountManager;
|
||||
|
|
@ -80,6 +83,7 @@ public class DhcpElement extends AdapterBase implements DhcpElementService, Pass
|
|||
@Inject HostPodDao _podDao;
|
||||
@Inject AccountManager _accountMgr;
|
||||
@Inject HostDao _hostDao;
|
||||
@Inject VirtualRouterElementsDao _vrElementsDao;
|
||||
|
||||
private boolean canHandle(DeployDestination dest, TrafficType trafficType, Type networkType, long offeringId) {
|
||||
if (_networkMgr.isProviderSupported(offeringId, Service.Gateway, Provider.JuniperSRX) && networkType == Network.Type.Isolated) {
|
||||
|
|
@ -248,15 +252,66 @@ public class DhcpElement extends AdapterBase implements DhcpElementService, Pass
|
|||
return _routerMgr.savePasswordToRouter(network, nic, uservm, routers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configure() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPropertiesFile() {
|
||||
return "virtualrouter_commands.properties";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean configure(ConfigureDhcpElementCmd cmd) {
|
||||
addElement(new Long(3), cmd.getUUID());
|
||||
VirtualRouterElementsVO element = _vrElementsDao.findByUUID(cmd.getUUID());
|
||||
if (element == null) {
|
||||
s_logger.trace("Can't find element with UUID " + cmd.getUUID());
|
||||
return false;
|
||||
}
|
||||
if (cmd.getDhcpService() && cmd.getDhcpRange() == null) {
|
||||
s_logger.trace("DHCP service is provided, but no specific DHCP range!");
|
||||
return false;
|
||||
}
|
||||
if (cmd.getDnsService() && (cmd.getDns1() == null || cmd.getDomainName() == null)) {
|
||||
s_logger.trace("DNS service is provided, but no domain name or dns server!");
|
||||
return false;
|
||||
}
|
||||
element.setIsDhcpProvided(cmd.getDhcpService());
|
||||
element.setDhcpRange(cmd.getDhcpRange());
|
||||
|
||||
element.setIsDnsProvided(cmd.getDnsService());
|
||||
element.setDefaultDomainName(cmd.getDomainName());
|
||||
element.setDns1(cmd.getDns1());
|
||||
element.setDns2(cmd.getDns2());
|
||||
element.setInternalDns1(cmd.getInternalDns1());
|
||||
element.setInternalDns2(cmd.getInternalDns2());
|
||||
|
||||
element.setIsGatewayProvided(false);
|
||||
element.setIsFirewallProvided(false);
|
||||
element.setIsLoadBalanceProvided(false);
|
||||
element.setIsSourceNatProvided(false);
|
||||
element.setIsVpnProvided(false);
|
||||
|
||||
_vrElementsDao.persist(element);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addElement(Long nspId, String uuid) {
|
||||
long serviceOfferingId = _routerMgr.getDefaultVirtualRouterServiceOfferingId();
|
||||
if (serviceOfferingId == 0) {
|
||||
return false;
|
||||
}
|
||||
VirtualRouterElementsVO element = new VirtualRouterElementsVO(nspId, uuid, serviceOfferingId, false, VirtualRouterElementsType.DhcpElement,
|
||||
false, false, false, false, false, false, false);
|
||||
_vrElementsDao.persist(element);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getIdByUUID(String uuid) {
|
||||
VirtualRouterElementsVO element = _vrElementsDao.findByUUID(uuid);
|
||||
if (element == null) {
|
||||
return new Long(0);
|
||||
}
|
||||
return element.getId();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import javax.ejb.Local;
|
|||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.commands.ConfigureRedundantVirtualRouterElementCmd;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
|
|
@ -19,7 +20,9 @@ import com.cloud.network.Network.Service;
|
|||
import com.cloud.network.Network.Type;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
import com.cloud.network.dao.VirtualRouterElementsDao;
|
||||
import com.cloud.network.element.RedundantVirtualRouterElementService;
|
||||
import com.cloud.network.element.VirtualRouterElements.VirtualRouterElementsType;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.component.Inject;
|
||||
|
|
@ -34,6 +37,7 @@ public class RedundantVirtualRouterElement extends VirtualRouterElement implemen
|
|||
private static final Logger s_logger = Logger.getLogger(RedundantVirtualRouterElement.class);
|
||||
|
||||
@Inject NetworkManager _networkMgr;
|
||||
@Inject VirtualRouterElementsDao _vrElementsDao;
|
||||
|
||||
private boolean canHandle(Type networkType, long offeringId) {
|
||||
boolean result = (networkType == Network.Type.Isolated && _networkMgr.isProviderSupported(offeringId, Service.Gateway, Provider.VirtualRouter));
|
||||
|
|
@ -85,8 +89,58 @@ public class RedundantVirtualRouterElement extends VirtualRouterElement implemen
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean configure() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
public boolean configure(ConfigureRedundantVirtualRouterElementCmd cmd) {
|
||||
addElement(new Long(2), cmd.getUUID());
|
||||
VirtualRouterElementsVO element = _vrElementsDao.findByUUID(cmd.getUUID());
|
||||
if (element == null) {
|
||||
s_logger.trace("Can't find element with UUID " + cmd.getUUID());
|
||||
return false;
|
||||
}
|
||||
if (cmd.getDhcpService() && cmd.getDhcpRange() == null) {
|
||||
s_logger.trace("DHCP service is provided, but no specific DHCP range!");
|
||||
return false;
|
||||
}
|
||||
if (cmd.getDnsService() && (cmd.getDns1() == null || cmd.getDomainName() == null)) {
|
||||
s_logger.trace("DNS service is provided, but no domain name or dns server!");
|
||||
return false;
|
||||
}
|
||||
if (cmd.getGatewayService() && cmd.getGateway() == null) {
|
||||
s_logger.trace("Gateway service is provided, but no gateway IP specific!");
|
||||
return false;
|
||||
}
|
||||
element.setIsDhcpProvided(cmd.getDhcpService());
|
||||
element.setDhcpRange(cmd.getDhcpRange());
|
||||
|
||||
element.setIsDnsProvided(cmd.getDnsService());
|
||||
element.setDefaultDomainName(cmd.getDomainName());
|
||||
element.setDns1(cmd.getDns1());
|
||||
element.setDns2(cmd.getDns2());
|
||||
element.setInternalDns1(cmd.getInternalDns1());
|
||||
element.setInternalDns2(cmd.getInternalDns2());
|
||||
|
||||
element.setIsGatewayProvided(cmd.getGatewayService());
|
||||
element.setGatewayIp(cmd.getGateway());
|
||||
|
||||
element.setIsFirewallProvided(cmd.getFirewallService());
|
||||
element.setIsLoadBalanceProvided(cmd.getLbService());
|
||||
element.setIsSourceNatProvided(cmd.getSourceNatService());
|
||||
element.setIsVpnProvided(cmd.getVpnService());
|
||||
|
||||
element.setIsReady(true);
|
||||
_vrElementsDao.persist(element);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addElement(Long nspId, String uuid) {
|
||||
long serviceOfferingId = _routerMgr.getDefaultVirtualRouterServiceOfferingId();
|
||||
if (serviceOfferingId == 0) {
|
||||
return false;
|
||||
}
|
||||
VirtualRouterElementsVO element = new VirtualRouterElementsVO(nspId, uuid, serviceOfferingId, false, VirtualRouterElementsType.RedundantVirtualRouterElement,
|
||||
false, false, false, false, false, false, false);
|
||||
_vrElementsDao.persist(element);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import javax.ejb.Local;
|
|||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.commands.ConfigureVirtualRouterElementCmd;
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dc.DataCenter;
|
||||
|
|
@ -44,6 +45,7 @@ import com.cloud.network.RemoteAccessVpn;
|
|||
import com.cloud.network.VpnUser;
|
||||
import com.cloud.network.dao.LoadBalancerDao;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.VirtualRouterElementsDao;
|
||||
import com.cloud.network.lb.LoadBalancingRulesManager;
|
||||
import com.cloud.network.router.VirtualNetworkApplianceManager;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
|
|
@ -52,6 +54,7 @@ import com.cloud.network.rules.FirewallRule;
|
|||
import com.cloud.network.rules.RulesManager;
|
||||
import com.cloud.network.rules.StaticNat;
|
||||
import com.cloud.network.element.VirtualRouterElementService;
|
||||
import com.cloud.network.element.VirtualRouterElements.VirtualRouterElementsType;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.org.Cluster;
|
||||
|
|
@ -88,6 +91,7 @@ public class VirtualRouterElement extends DhcpElement implements VirtualRouterEl
|
|||
@Inject LoadBalancerDao _lbDao;
|
||||
@Inject HostDao _hostDao;
|
||||
@Inject ConfigurationDao _configDao;
|
||||
@Inject VirtualRouterElementsDao _vrElementsDao;
|
||||
|
||||
private boolean canHandle(Type networkType, long offeringId) {
|
||||
boolean result = (networkType == Network.Type.Isolated && _networkMgr.isProviderSupported(offeringId, Service.Gateway, Provider.VirtualRouter));
|
||||
|
|
@ -381,8 +385,58 @@ public class VirtualRouterElement extends DhcpElement implements VirtualRouterEl
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean configure() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
public boolean configure(ConfigureVirtualRouterElementCmd cmd) {
|
||||
addElement(new Long(1), cmd.getUUID());
|
||||
VirtualRouterElementsVO element = _vrElementsDao.findByUUID(cmd.getUUID());
|
||||
if (element == null) {
|
||||
s_logger.trace("Can't find element with UUID " + cmd.getUUID());
|
||||
return false;
|
||||
}
|
||||
if (cmd.getDhcpService() && cmd.getDhcpRange() == null) {
|
||||
s_logger.trace("DHCP service is provided, but no specific DHCP range!");
|
||||
return false;
|
||||
}
|
||||
if (cmd.getDnsService() && (cmd.getDns1() == null || cmd.getDomainName() == null)) {
|
||||
s_logger.trace("DNS service is provided, but no domain name or dns server!");
|
||||
return false;
|
||||
}
|
||||
if (cmd.getGatewayService() && cmd.getGateway() == null) {
|
||||
s_logger.trace("Gateway service is provided, but no gateway IP specific!");
|
||||
return false;
|
||||
}
|
||||
element.setIsDhcpProvided(cmd.getDhcpService());
|
||||
element.setDhcpRange(cmd.getDhcpRange());
|
||||
|
||||
element.setIsDnsProvided(cmd.getDnsService());
|
||||
element.setDefaultDomainName(cmd.getDomainName());
|
||||
element.setDns1(cmd.getDns1());
|
||||
element.setDns2(cmd.getDns2());
|
||||
element.setInternalDns1(cmd.getInternalDns1());
|
||||
element.setInternalDns2(cmd.getInternalDns2());
|
||||
|
||||
element.setIsGatewayProvided(cmd.getGatewayService());
|
||||
element.setGatewayIp(cmd.getGateway());
|
||||
|
||||
element.setIsFirewallProvided(cmd.getFirewallService());
|
||||
element.setIsLoadBalanceProvided(cmd.getLbService());
|
||||
element.setIsSourceNatProvided(cmd.getSourceNatService());
|
||||
element.setIsVpnProvided(cmd.getVpnService());
|
||||
|
||||
element.setIsReady(true);
|
||||
_vrElementsDao.persist(element);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addElement(Long nspId, String uuid) {
|
||||
long serviceOfferingId = _routerMgr.getDefaultVirtualRouterServiceOfferingId();
|
||||
if (serviceOfferingId == 0) {
|
||||
return false;
|
||||
}
|
||||
VirtualRouterElementsVO element = new VirtualRouterElementsVO(nspId, uuid, serviceOfferingId, false, VirtualRouterElementsType.VirtualRouterElement,
|
||||
false, false, false, false, false, false, false);
|
||||
_vrElementsDao.persist(element);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,9 @@ public class VirtualRouterElementsVO implements VirtualRouterElements {
|
|||
@Column(name="uuid")
|
||||
private String uuid;
|
||||
|
||||
@Column(name="service_offering_id")
|
||||
private long serviceOfferingId;
|
||||
|
||||
@Column(name="dhcp_provided")
|
||||
private boolean isDhcpProvided;
|
||||
|
||||
|
|
@ -96,10 +99,14 @@ public class VirtualRouterElementsVO implements VirtualRouterElements {
|
|||
@Column(name=GenericDao.REMOVED_COLUMN)
|
||||
Date removed;
|
||||
|
||||
public VirtualRouterElementsVO(long nspId, String uuid, boolean isReady, VirtualRouterElementsType type, boolean isDhcpProvided, boolean isDnsProvided,
|
||||
public VirtualRouterElementsVO() {
|
||||
}
|
||||
|
||||
public VirtualRouterElementsVO(long nspId, String uuid, long serviceOfferingId, boolean isReady, VirtualRouterElementsType type, boolean isDhcpProvided, boolean isDnsProvided,
|
||||
boolean isGatewayProvided, boolean isFirewallProvided, boolean isSourceNatProvided, boolean isLoadBalanceProvided, boolean isVpnProvided) {
|
||||
this.nspId = nspId;
|
||||
this.uuid = uuid;
|
||||
this.serviceOfferingId = serviceOfferingId;
|
||||
this.isReady = isReady;
|
||||
this.type = type;
|
||||
this.isDhcpProvided = isDhcpProvided;
|
||||
|
|
@ -110,12 +117,12 @@ public class VirtualRouterElementsVO implements VirtualRouterElements {
|
|||
this.isLoadBalanceProvided = isLoadBalanceProvided;
|
||||
this.isVpnProvided = isVpnProvided;
|
||||
}
|
||||
|
||||
|
||||
public long getNspId() {
|
||||
return nspId;
|
||||
}
|
||||
|
||||
public String getUUID() {
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
|
|
@ -171,34 +178,62 @@ public class VirtualRouterElementsVO implements VirtualRouterElements {
|
|||
this.internalDns2 = internalDns2;
|
||||
}
|
||||
|
||||
public boolean isDhcpProvided() {
|
||||
public boolean getIsDhcpProvided() {
|
||||
return isDhcpProvided;
|
||||
}
|
||||
|
||||
public boolean isDnsProvided() {
|
||||
public boolean getIsDnsProvided() {
|
||||
return isDnsProvided;
|
||||
}
|
||||
|
||||
public boolean isGatewayProvided() {
|
||||
public boolean getIsGatewayProvided() {
|
||||
return isGatewayProvided;
|
||||
}
|
||||
|
||||
public boolean isFirewallProvided() {
|
||||
public boolean getIsFirewallProvided() {
|
||||
return isFirewallProvided;
|
||||
}
|
||||
|
||||
public boolean isSourceNatProvided() {
|
||||
public boolean getIsSourceNatProvided() {
|
||||
return isSourceNatProvided;
|
||||
}
|
||||
|
||||
public boolean isLoadBalanceProvided() {
|
||||
public boolean getIsLoadBalanceProvided() {
|
||||
return isLoadBalanceProvided;
|
||||
}
|
||||
|
||||
public boolean isVpnProvided() {
|
||||
public boolean getIsVpnProvided() {
|
||||
return isVpnProvided;
|
||||
}
|
||||
|
||||
public void setIsDhcpProvided(boolean isDhcpProvided) {
|
||||
this.isDhcpProvided = isDhcpProvided;
|
||||
}
|
||||
|
||||
public void setIsDnsProvided(boolean isDnsProvided) {
|
||||
this.isDnsProvided = isDnsProvided;
|
||||
}
|
||||
|
||||
public void setIsGatewayProvided(boolean isGatewayProvided) {
|
||||
this.isGatewayProvided = isGatewayProvided;
|
||||
}
|
||||
|
||||
public void setIsFirewallProvided(boolean isFirewallProvided) {
|
||||
this.isFirewallProvided = isFirewallProvided;
|
||||
}
|
||||
|
||||
public void setIsSourceNatProvided(boolean isSourceNatProvided) {
|
||||
this.isSourceNatProvided = isSourceNatProvided;
|
||||
}
|
||||
|
||||
public void setIsLoadBalanceProvided(boolean isLoadBalanceProvided) {
|
||||
this.isLoadBalanceProvided = isLoadBalanceProvided;
|
||||
}
|
||||
|
||||
public void setIsVpnProvided(boolean isVpnProvided) {
|
||||
this.isVpnProvided = isVpnProvided;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualRouterElementsType getType() {
|
||||
return this.type;
|
||||
|
|
@ -220,11 +255,35 @@ public class VirtualRouterElementsVO implements VirtualRouterElements {
|
|||
this.removed = removed;
|
||||
}
|
||||
|
||||
public void setReady(boolean isReady) {
|
||||
public void setIsReady(boolean isReady) {
|
||||
this.isReady = isReady;
|
||||
}
|
||||
|
||||
public boolean isReady() {
|
||||
public boolean getIsReady() {
|
||||
return isReady;
|
||||
}
|
||||
|
||||
public void setServiceOfferingId(long serviceOfferingId) {
|
||||
this.serviceOfferingId = serviceOfferingId;
|
||||
}
|
||||
|
||||
public long getServiceOfferingId() {
|
||||
return serviceOfferingId;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setType(VirtualRouterElementsType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setNspId(long nspId) {
|
||||
this.nspId = nspId;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,5 +91,6 @@ public interface VirtualNetworkApplianceManager extends Manager, VirtualNetworkA
|
|||
String getDnsBasicZoneUpdate();
|
||||
|
||||
boolean applyStaticNats(Network network, List<? extends StaticNat> rules, List<? extends VirtualRouter> routers) throws ResourceUnavailableException;
|
||||
|
||||
|
||||
long getDefaultVirtualRouterServiceOfferingId();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2742,4 +2742,12 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
public boolean processTimeout(long agentId, long seq) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDefaultVirtualRouterServiceOfferingId() {
|
||||
if (_offering != null) {
|
||||
return _offering.getId();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ import com.cloud.network.Networks.BroadcastDomainType;
|
|||
import com.cloud.network.Networks.Mode;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.VirtualRouterElementsDao;
|
||||
import com.cloud.network.guru.ControlNetworkGuru;
|
||||
import com.cloud.network.guru.DirectPodBasedNetworkGuru;
|
||||
import com.cloud.network.guru.PodBasedNetworkGuru;
|
||||
|
|
@ -120,6 +121,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||
private final AccountDao _accountDao;
|
||||
private final ResourceCountDao _resourceCountDao;
|
||||
private final NetworkOfferingServiceMapDao _offeringServiceMapDao;
|
||||
private final VirtualRouterElementsDao _virtualRouterElementsDao;
|
||||
|
||||
|
||||
public ConfigurationServerImpl() {
|
||||
|
|
@ -137,7 +139,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||
_accountDao = locator.getDao(AccountDao.class);
|
||||
_resourceCountDao = locator.getDao(ResourceCountDao.class);
|
||||
_offeringServiceMapDao = locator.getDao(NetworkOfferingServiceMapDao.class);
|
||||
|
||||
_virtualRouterElementsDao = locator.getDao(VirtualRouterElementsDao.class);
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
|
|
|
|||
Loading…
Reference in New Issue