mirror of https://github.com/apache/cloudstack.git
Added support code for external firewalls and loadbalancers. Added new host types and startup commands, and enabled NicVO to reserve IPs for external network resources.
This commit is contained in:
parent
8d87271dad
commit
198cab4dee
|
|
@ -31,7 +31,9 @@ public interface Host {
|
|||
Storage(false),
|
||||
Routing(false),
|
||||
SecondaryStorage(false),
|
||||
ConsoleProxy(true);
|
||||
ConsoleProxy(true),
|
||||
ExternalFirewall(false),
|
||||
ExternalLoadBalancer(false);
|
||||
|
||||
boolean _virtual;
|
||||
private Type(boolean virtual) {
|
||||
|
|
|
|||
|
|
@ -19,4 +19,6 @@ package com.cloud.network.service;
|
|||
|
||||
public class Providers {
|
||||
public final static String VirtualRouter = "VirtualRouter";
|
||||
public final static String ExternalFirewall = "ExternalFirewall";
|
||||
public final static String ExternalLoadBalancer = "ExternalLoadBalancer";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,8 @@ public interface Resource {
|
|||
enum ReservationStrategy {
|
||||
UserSpecified,
|
||||
Create,
|
||||
Start
|
||||
Start,
|
||||
PlaceHolder;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
package com.cloud.agent.api;
|
||||
|
||||
public class StartupExternalFirewallCommand extends StartupCommand {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package com.cloud.agent.api;
|
||||
|
||||
public class StartupExternalLoadBalancerCommand extends StartupCommand {
|
||||
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -18,6 +18,7 @@
|
|||
package com.cloud.agent;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
|
|
@ -34,8 +35,10 @@ import com.cloud.host.Host;
|
|||
import com.cloud.host.HostStats;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.host.Host.Type;
|
||||
import com.cloud.host.Status.Event;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.resource.ServerResource;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.storage.StoragePoolVO;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
|
|
@ -159,6 +162,16 @@ public interface AgentManager extends Manager {
|
|||
List<PodCluster> listByDataCenter(long dcId);
|
||||
List<PodCluster> listByPod(long podId);
|
||||
|
||||
/**
|
||||
* Adds a new host
|
||||
* @param zoneId
|
||||
* @param resource
|
||||
* @param hostType
|
||||
* @param hostDetails
|
||||
* @return new Host
|
||||
*/
|
||||
public Host addHost(long zoneId, ServerResource resource, Type hostType, Map<String, String> hostDetails);
|
||||
|
||||
/**
|
||||
* Deletes a host
|
||||
*
|
||||
|
|
|
|||
|
|
@ -60,6 +60,8 @@ import com.cloud.agent.api.ReadyCommand;
|
|||
import com.cloud.agent.api.ShutdownCommand;
|
||||
import com.cloud.agent.api.StartupAnswer;
|
||||
import com.cloud.agent.api.StartupCommand;
|
||||
import com.cloud.agent.api.StartupExternalFirewallCommand;
|
||||
import com.cloud.agent.api.StartupExternalLoadBalancerCommand;
|
||||
import com.cloud.agent.api.StartupProxyCommand;
|
||||
import com.cloud.agent.api.StartupRoutingCommand;
|
||||
import com.cloud.agent.api.StartupStorageCommand;
|
||||
|
|
@ -1616,15 +1618,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
|
|||
for (final VMInstanceVO vm : vms) {
|
||||
_haMgr.scheduleMigration(vm);
|
||||
}
|
||||
} else {
|
||||
final List<Long> ids = _volDao.findVmsStoredOnHost(hostId);
|
||||
for (final Long id : ids) {
|
||||
final VMInstanceVO instance = _vmDao.findById(id);
|
||||
if (instance != null && (instance.getState() == State.Running || instance.getState() == State.Starting)) {
|
||||
_haMgr.scheduleStop(instance, host.getId(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1755,6 +1749,25 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Host addHost(long zoneId, ServerResource resource, Type hostType, Map<String, String> hostDetails) {
|
||||
// Check if the zone exists in the system
|
||||
if (_dcDao.findById(zoneId) == null ){
|
||||
throw new InvalidParameterValueException("Can't find zone with id " + zoneId);
|
||||
}
|
||||
|
||||
Map<String, String> details = hostDetails;
|
||||
String guid = (String) details.get("guid");
|
||||
List<HostVO> currentHosts = _hostDao.listBy(hostType, zoneId);
|
||||
for (HostVO currentHost : currentHosts) {
|
||||
if (currentHost.getGuid().equals(guid)) {
|
||||
return currentHost;
|
||||
}
|
||||
}
|
||||
|
||||
AgentAttache attache = simulateStart(resource, hostDetails, true);
|
||||
return _hostDao.findById(attache.getId());
|
||||
}
|
||||
|
||||
public HostVO createHost(final StartupCommand startup, ServerResource resource, Map<String, String> details, boolean directFirst) throws IllegalArgumentException {
|
||||
Host.Type type = null;
|
||||
|
|
@ -1793,6 +1806,10 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
|
|||
type = Host.Type.ConsoleProxy;
|
||||
} else if (startup instanceof StartupRoutingCommand) {
|
||||
type = Host.Type.Routing;
|
||||
} else if (startup instanceof StartupExternalFirewallCommand) {
|
||||
type = Host.Type.ExternalFirewall;
|
||||
} else if (startup instanceof StartupExternalLoadBalancerCommand) {
|
||||
type = Host.Type.ExternalLoadBalancer;
|
||||
} else {
|
||||
assert false : "Did someone add a new Startup command?";
|
||||
}
|
||||
|
|
@ -1842,17 +1859,12 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
|
|||
* startup.getStorageIpAddress()); } }
|
||||
*/
|
||||
|
||||
if (startup instanceof StartupStorageCommand) {
|
||||
server = _hostDao.persist(server);
|
||||
id = server.getId();
|
||||
} else if (startup instanceof StartupProxyCommand) {
|
||||
if (startup instanceof StartupProxyCommand) {
|
||||
server.setProxyPort(((StartupProxyCommand) startup).getProxyPort());
|
||||
server = _hostDao.persist(server);
|
||||
id = server.getId();
|
||||
} else if (startup instanceof StartupRoutingCommand) {
|
||||
server = _hostDao.persist(server);
|
||||
id = server.getId();
|
||||
}
|
||||
}
|
||||
|
||||
server = _hostDao.persist(server);
|
||||
id = server.getId();
|
||||
|
||||
s_logger.info("New " + server.getType().toString() + " host connected w/ guid " + startup.getGuid() + " and id is " + id);
|
||||
} else {
|
||||
|
|
@ -2020,7 +2032,9 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
|
|||
}
|
||||
Long podId = null;
|
||||
if (p == null) {
|
||||
if (type != Host.Type.SecondaryStorage) {
|
||||
if (type != Host.Type.SecondaryStorage &&
|
||||
type != Host.Type.ExternalFirewall &&
|
||||
type != Host.Type.ExternalLoadBalancer) {
|
||||
|
||||
/*
|
||||
* s_logger.info("Unable to find the pod so we are creating one."
|
||||
|
|
|
|||
|
|
@ -108,6 +108,11 @@ public class AgentMonitor extends Thread implements Listener {
|
|||
}
|
||||
|
||||
for (HostVO host : hosts) {
|
||||
if (host.getType().equals(Host.Type.ExternalFirewall) ||
|
||||
host.getType().equals(Host.Type.ExternalLoadBalancer)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (host.getManagementServerId() == null || host.getManagementServerId() == _msId) {
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("Asking agent mgr to investgate why host " + host.getId() + " is behind on ping. last ping time: " + host.getLastPinged());
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public class NicVO implements Nic {
|
|||
long id;
|
||||
|
||||
@Column(name="instance_id")
|
||||
long instanceId;
|
||||
Long instanceId;
|
||||
|
||||
@Column(name="ip4_address")
|
||||
String ip4Address;
|
||||
|
|
@ -107,7 +107,7 @@ public class NicVO implements Nic {
|
|||
@Column(name=GenericDao.CREATED_COLUMN)
|
||||
Date created;
|
||||
|
||||
public NicVO(String reserver, long instanceId, long configurationId) {
|
||||
public NicVO(String reserver, Long instanceId, long configurationId) {
|
||||
this.reserver = reserver;
|
||||
this.instanceId = instanceId;
|
||||
this.networkId = configurationId;
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ INSERT INTO `cloud`.`certificate` (id,certificate,updated) VALUES ('1',null,'N')
|
|||
|
||||
CREATE TABLE `cloud`.`nics` (
|
||||
`id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT COMMENT 'id',
|
||||
`instance_id` bigint unsigned NOT NULL COMMENT 'vm instance id',
|
||||
`instance_id` bigint unsigned COMMENT 'vm instance id',
|
||||
`mac_address` varchar(17) COMMENT 'mac address',
|
||||
`ip4_address` varchar(15) COMMENT 'ip4 address',
|
||||
`netmask` varchar(15) COMMENT 'netmask for ip4 address',
|
||||
|
|
|
|||
Loading…
Reference in New Issue