add missing files

This commit is contained in:
Alex Huang 2010-09-15 16:49:22 -07:00
parent 327924a9ad
commit 84179cd561
11 changed files with 505 additions and 0 deletions

View File

@ -0,0 +1,56 @@
/**
*
*/
package com.cloud.deploy;
import java.util.Map;
import com.cloud.dc.DataCenter;
import com.cloud.dc.Pod;
import com.cloud.host.Host;
import com.cloud.org.Cluster;
import com.cloud.storage.StoragePool;
import com.cloud.storage.Volume;
import com.cloud.utils.NumbersUtil;
public class DeployDestination {
DataCenter _dc;
Pod _pod;
Cluster _cluster;
Host _host;
Map<Volume, StoragePool> _storage;
public DataCenter getDataCenter() {
return _dc;
}
public Pod getPod() {
return _pod;
}
public Cluster getCluster() {
return _cluster;
}
public Host getHost() {
return _host;
}
public Map<Volume, StoragePool> getStorageForDisks() {
return _storage;
}
public DeployDestination() {
}
@Override
public int hashCode() {
return NumbersUtil.hash(_host.getId());
}
@Override
public boolean equals(Object obj) {
assert false : "Not implemented correctly yet.";
return false;
}
}

View File

@ -0,0 +1,13 @@
/**
*
*/
package com.cloud.deploy;
import java.util.Set;
import com.cloud.utils.component.Adapter;
import com.cloud.vm.VirtualMachineProfile;
public interface DeploymentDispatcher extends Adapter {
DeployDestination plan(VirtualMachineProfile vm, DeploymentPlan plan, Set<DeployDestination> avoid);
}

View File

@ -0,0 +1,11 @@
/**
*
*/
package com.cloud.org;
public interface RunningIn {
long getDataCenterId();
long getPodId();
Long getClusterId();
Long getHostId();
}

View File

@ -0,0 +1,10 @@
/**
*
*/
package com.cloud.resource;
import com.cloud.utils.component.Adapter;
public interface Concierge<T extends Resource> extends Adapter {
}

View File

@ -0,0 +1,59 @@
/**
*
*/
package com.cloud.resource;
import java.util.Date;
/**
* Indicates a resource in CloudStack.
* Any resource that requires an reservation and release system
* must implement this interface.
*
*/
public interface Resource {
enum State {
Allocated, // The resource is allocated but not re
Reserving,
Reserved,
Releasing,
}
/**
* @return id in the CloudStack database
*/
long getId();
/**
* @return reservation id returned by the allocation source. This can be the
* String version of the database id if the allocation source does not need it's
* own implementation of the reservation id. This is passed back to the
* allocation source to release the resource.
*/
String getReservationId();
/**
* @return unique name for the allocation source.
*/
String getReserver();
/**
* @return the time a reservation request was made to the allocation source.
*/
Date getUpdateTime();
/**
* @return the expected reservation interval. -1 indicates
*/
int getExpectedReservationInterval();
/**
* @return the expected release interval.
*/
int getExpectedReleaseInterval();
/**
* @return the reservation state of the resource.
*/
State getState();
}

View File

@ -0,0 +1,123 @@
/**
*
*/
package com.cloud.network.profiler;
import java.util.Map;
import javax.ejb.Local;
import javax.naming.ConfigurationException;
import org.apache.log4j.Logger;
import com.cloud.configuration.Config;
import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.deploy.DeployDestination;
import com.cloud.deploy.DeploymentPlan;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
import com.cloud.network.Network.BroadcastDomainType;
import com.cloud.network.Network.Mode;
import com.cloud.network.Network.TrafficType;
import com.cloud.network.NetworkConfiguration;
import com.cloud.network.NetworkConfigurationVO;
import com.cloud.network.NetworkProfiler;
import com.cloud.offering.NetworkOffering;
import com.cloud.user.Account;
import com.cloud.utils.component.AdapterBase;
import com.cloud.utils.component.ComponentLocator;
import com.cloud.utils.component.Inject;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.vm.NetworkConcierge;
import com.cloud.vm.Nic;
import com.cloud.vm.NicProfile;
import com.cloud.vm.VirtualMachine;
@Local(value=NetworkProfiler.class)
public class ControlNetworkProfiler extends AdapterBase implements NetworkProfiler, NetworkConcierge {
private static final Logger s_logger = Logger.getLogger(ControlNetworkProfiler.class);
@Inject DataCenterDao _dcDao;
String _cidr;
String _gateway;
@Override
public NetworkConfiguration convert(NetworkOffering offering, DeploymentPlan plan, Map<String, String> params, Account owner) {
if (offering.getTrafficType() != TrafficType.Control) {
return null;
}
NetworkConfigurationVO config = new NetworkConfigurationVO(offering.getTrafficType(), Mode.Static, BroadcastDomainType.LinkLocal, offering.getId(), plan.getDataCenterId());
config.setCidr(_cidr);
config.setGateway(_gateway);
return config;
}
protected ControlNetworkProfiler() {
super();
}
@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
super.configure(name, params);
ComponentLocator locator = ComponentLocator.getCurrentLocator();
ConfigurationDao configDao = locator.getDao(ConfigurationDao.class);
Map<String, String> dbParams = configDao.getConfiguration(params);
_cidr = dbParams.get(Config.ControlCidr);
if (_cidr == null) {
_cidr = "169.254.0.0/16";
}
_gateway = dbParams.get(Config.ControlGateway);
if (_gateway == null) {
_gateway = "169.254.0.1";
}
s_logger.info("Control network setup: cidr=" + _cidr + "; gateway = " + _gateway);
return true;
}
@Override
public String getUniqueName() {
return getName();
}
@Override
public NicProfile allocate(VirtualMachine vm, NetworkConfiguration config, NicProfile nic) throws InsufficientVirtualNetworkCapcityException,
InsufficientAddressCapacityException {
if (config.getTrafficType() != TrafficType.Control) {
return null;
}
if (nic != null) {
throw new CloudRuntimeException("Does not support nic specification at this time: " + nic);
}
return new NicProfile(null, null, null);
}
@Override
public boolean create(Nic nic) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
return true;
}
@Override
public String reserve(long vmId, NicProfile nic, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException,
InsufficientAddressCapacityException {
String ip = _dcDao.allocateLinkLocalPrivateIpAddress(dest.getDataCenter().getId(), dest.getPod().getId(), vmId);
nic.setIp4Address(ip);
nic.setMacAddress("FE:FF:FF:FF:FF:FF");
return Long.toString(nic.getId());
}
@Override
public boolean release(String uniqueName, String uniqueId) {
_dcDao.releaseLinkLocalPrivateIpAddress(Long.parseLong(uniqueId));
return true;
}
}

View File

@ -0,0 +1,99 @@
/**
*
*/
package com.cloud.network.profiler;
import java.util.Map;
import javax.ejb.Local;
import org.apache.log4j.Logger;
import com.cloud.dc.Pod;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.deploy.DeployDestination;
import com.cloud.deploy.DeploymentPlan;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
import com.cloud.network.Network.BroadcastDomainType;
import com.cloud.network.Network.Mode;
import com.cloud.network.Network.TrafficType;
import com.cloud.network.NetworkConfiguration;
import com.cloud.network.NetworkConfigurationVO;
import com.cloud.network.NetworkProfiler;
import com.cloud.offering.NetworkOffering;
import com.cloud.user.Account;
import com.cloud.utils.component.AdapterBase;
import com.cloud.utils.component.Inject;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.vm.NetworkConcierge;
import com.cloud.vm.Nic;
import com.cloud.vm.NicProfile;
import com.cloud.vm.VirtualMachine;
@Local(value=NetworkProfiler.class)
public class PodBasedNetworkProfiler extends AdapterBase implements NetworkProfiler, NetworkConcierge {
private static final Logger s_logger = Logger.getLogger(PodBasedNetworkProfiler.class);
@Inject DataCenterDao _dcDao;
@Override
public NetworkConfiguration convert(NetworkOffering offering, DeploymentPlan plan, Map<String, String> params, Account owner) {
TrafficType type = offering.getTrafficType();
if (type != TrafficType.Management && type != TrafficType.Storage) {
return null;
}
NetworkConfigurationVO config = new NetworkConfigurationVO(type, Mode.Static, BroadcastDomainType.Native, offering.getId(), plan.getDataCenterId());
return config;
}
protected PodBasedNetworkProfiler() {
super();
}
@Override
public String getUniqueName() {
return getName();
}
@Override
public NicProfile allocate(VirtualMachine vm, NetworkConfiguration config, NicProfile nic) throws InsufficientVirtualNetworkCapcityException,
InsufficientAddressCapacityException {
TrafficType trafficType = config.getTrafficType();
if (trafficType != TrafficType.Storage && trafficType != TrafficType.Management) {
return null;
}
if (nic != null) {
throw new CloudRuntimeException("Does not support nic configuration");
}
NicProfile profile = new NicProfile(null, null, null);
return profile;
}
@Override
public boolean create(Nic nic) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
return true;
}
@Override
public String reserve(long vmId, NicProfile nic, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException,
InsufficientAddressCapacityException {
Pod pod = dest.getPod();
String ip = _dcDao.allocatePrivateIpAddress(dest.getDataCenter().getId(), dest.getPod().getId(), nic.getId());
nic.setIp4Address(ip);
nic.setCidr(pod.getCidrAddress() + "/" + pod.getCidrSize());
return Long.toString(nic.getId());
}
@Override
public boolean release(String uniqueName, String uniqueId) {
_dcDao.releasePrivateIpAddress(Long.parseLong(uniqueId));
return true;
}
}

View File

@ -0,0 +1,9 @@
/**
*
*/
package com.cloud.network.profiler;
public final class ProfilerUtils {
}

View File

@ -0,0 +1,80 @@
/**
*
*/
package com.cloud.network.profiler;
import java.util.Map;
import javax.ejb.Local;
import com.cloud.deploy.DeployDestination;
import com.cloud.deploy.DeploymentPlan;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
import com.cloud.network.Network.BroadcastDomainType;
import com.cloud.network.Network.Mode;
import com.cloud.network.Network.TrafficType;
import com.cloud.network.NetworkConfiguration;
import com.cloud.network.NetworkConfigurationVO;
import com.cloud.network.NetworkProfiler;
import com.cloud.offering.NetworkOffering;
import com.cloud.user.Account;
import com.cloud.utils.component.AdapterBase;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.vm.NetworkConcierge;
import com.cloud.vm.Nic;
import com.cloud.vm.NicProfile;
import com.cloud.vm.VirtualMachine;
@Local(value=NetworkProfiler.class)
public class PublicNetworkProfiler extends AdapterBase implements NetworkProfiler, NetworkConcierge {
@Override
public NetworkConfiguration convert(NetworkOffering offering, DeploymentPlan plan, Map<String, String> params, Account owner) {
if (offering.getTrafficType() != TrafficType.Public) {
return null;
}
return new NetworkConfigurationVO(offering.getTrafficType(), Mode.Static, BroadcastDomainType.Vlan, offering.getId(), plan.getDataCenterId());
}
protected PublicNetworkProfiler() {
super();
}
@Override
public String getUniqueName() {
return getName();
}
@Override
public NicProfile allocate(VirtualMachine vm, NetworkConfiguration config, NicProfile nic) throws InsufficientVirtualNetworkCapcityException,
InsufficientAddressCapacityException {
if (config.getTrafficType() != TrafficType.Public) {
return null;
}
if (nic != null) {
throw new CloudRuntimeException("Unsupported nic settings");
}
return new NicProfile(null, null, null);
}
@Override
public boolean create(Nic nic) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
return true;
}
@Override
public String reserve(long vmId, NicProfile ch, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException,
InsufficientAddressCapacityException {
return null;
}
@Override
public boolean release(String uniqueName, String uniqueId) {
return false;
}
}

View File

@ -0,0 +1,10 @@
/**
*
*/
package com.cloud.network.router;
import com.cloud.utils.component.Manager;
public interface DomainRouterManager extends Manager {
}

View File

@ -0,0 +1,35 @@
/**
*
*/
package com.cloud.network.router;
import java.util.Map;
import javax.ejb.Local;
import javax.naming.ConfigurationException;
@Local(value=DomainRouterManager.class)
public class DomainRouterManagerImpl implements DomainRouterManager {
String _name;
@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
_name = name;
return true;
}
@Override
public boolean start() {
return true;
}
@Override
public boolean stop() {
return true;
}
@Override
public String getName() {
return _name;
}
}