mirror of https://github.com/apache/cloudstack.git
more changes
This commit is contained in:
parent
22652e7ace
commit
c0d8422d69
|
|
@ -39,6 +39,13 @@ public class DeployDestination {
|
|||
public Map<Volume, StoragePool> getStorageForDisks() {
|
||||
return _storage;
|
||||
}
|
||||
|
||||
public DeployDestination(DataCenter dc, Pod pod, Cluster cluster, Host host) {
|
||||
_dc = dc;
|
||||
_pod = pod;
|
||||
_cluster = cluster;
|
||||
_host = host;
|
||||
}
|
||||
|
||||
public DeployDestination() {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,6 @@ import java.util.Set;
|
|||
import com.cloud.utils.component.Adapter;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
|
||||
public interface DeploymentDispatcher extends Adapter {
|
||||
public interface DeploymentPlanner extends Adapter {
|
||||
DeployDestination plan(VirtualMachineProfile vm, DeploymentPlan plan, Set<DeployDestination> avoid);
|
||||
}
|
||||
|
|
@ -5,20 +5,33 @@ package com.cloud.network.configuration;
|
|||
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.deploy.DeploymentPlan;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
||||
import com.cloud.network.NetworkConfiguration;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.component.Adapter;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
|
||||
/**
|
||||
* NetworkProfiler takes the list of network offerings requested and figures
|
||||
* out what are the additional network profiles that are needed to add
|
||||
* NetworkGuru takes a network offering requested and figures
|
||||
* out what is the correct network configuration that are needed to add
|
||||
* to the account in order to support this network.
|
||||
*
|
||||
*/
|
||||
public interface NetworkGuru extends Adapter {
|
||||
NetworkConfiguration design(NetworkOffering offering, DeploymentPlan plan, NetworkConfiguration config, Account owner);
|
||||
NetworkConfiguration design(NetworkOffering offering, DeploymentPlan plan, NetworkConfiguration userSpecified, Account owner);
|
||||
|
||||
NetworkConfiguration implement(NetworkConfiguration config, NetworkOffering offering, DeployDestination destination);
|
||||
|
||||
NicProfile allocate(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
|
||||
|
||||
boolean create(NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
|
||||
|
||||
String reserve(NicProfile nic, VirtualMachineProfile vm, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
|
||||
|
||||
boolean release(String uniqueId);
|
||||
|
||||
void destroy(NetworkConfiguration config, NetworkOffering offering);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package com.cloud.vm;
|
||||
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
||||
import com.cloud.network.NetworkConfiguration;
|
||||
import com.cloud.resource.Concierge;
|
||||
|
||||
/**
|
||||
* NetworkConcierge reserves network settings for a VM based
|
||||
* on the NetworkCharacteristics given. A concierge must
|
||||
* return a unique name so we know to call it to release
|
||||
* the reservation.
|
||||
*
|
||||
*/
|
||||
public interface NetworkConcierge extends Concierge<Nic> {
|
||||
String getUniqueName();
|
||||
|
||||
NicProfile allocate(VirtualMachine vm, NetworkConfiguration config, NicProfile nic) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
|
||||
|
||||
boolean create(Nic nic) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
|
||||
|
||||
String reserve(VirtualMachine vm, NicProfile ch, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
|
||||
|
||||
boolean release(String uniqueName, String uniqueId);
|
||||
}
|
||||
|
|
@ -73,6 +73,7 @@ import com.cloud.dc.dao.DataCenterDao;
|
|||
import com.cloud.dc.dao.HostPodDao;
|
||||
import com.cloud.dc.dao.VlanDao;
|
||||
import com.cloud.deploy.DataCenterDeployment;
|
||||
import com.cloud.deploy.DeploymentPlan;
|
||||
import com.cloud.domain.DomainVO;
|
||||
import com.cloud.event.EventState;
|
||||
import com.cloud.event.EventTypes;
|
||||
|
|
@ -511,11 +512,11 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ConsoleProxyVO startProxy(long proxyVmId, long startEventId) {
|
||||
try {
|
||||
return start(proxyVmId, startEventId);
|
||||
return start2(proxyVmId, startEventId);
|
||||
} catch (StorageUnavailableException e) {
|
||||
s_logger.warn("Exception while trying to start console proxy", e);
|
||||
return null;
|
||||
|
|
@ -528,6 +529,12 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||
}
|
||||
}
|
||||
|
||||
public ConsoleProxyVO start2(long proxyVmId, long startEventId) throws StorageUnavailableException, InsufficientCapacityException, ConcurrentOperationException {
|
||||
ConsoleProxyVO proxy = _consoleProxyDao.findById(proxyVmId);
|
||||
DeploymentPlan plan = new DataCenterDeployment(proxy.getDataCenterId(), 1);
|
||||
return _vmMgr.start(proxy, plan);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public ConsoleProxyVO start(long proxyId, long startEventId) throws StorageUnavailableException, InsufficientCapacityException,
|
||||
|
|
@ -859,7 +866,8 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||
return null;
|
||||
}
|
||||
|
||||
ConsoleProxyVO proxy = allocProxyStorage(dataCenterId, proxyVmId);
|
||||
ConsoleProxyVO proxy = _consoleProxyDao.findById(proxyVmId);
|
||||
//allocProxyStorage(dataCenterId, proxyVmId);
|
||||
if (proxy != null) {
|
||||
SubscriptionMgr.getInstance().notifySubscribers(ConsoleProxyManager.ALERT_SUBJECT, this,
|
||||
new ConsoleProxyAlertEventArgs(ConsoleProxyAlertEventArgs.PROXY_CREATED, dataCenterId, proxy.getId(), proxy, null));
|
||||
|
|
@ -898,7 +906,8 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||
return null;
|
||||
}
|
||||
|
||||
ConsoleProxyVO proxy = allocProxyStorage(dataCenterId, proxyVmId);
|
||||
ConsoleProxyVO proxy = _consoleProxyDao.findById(proxyVmId);
|
||||
//allocProxyStorage(dataCenterId, proxyVmId);
|
||||
if (proxy != null) {
|
||||
SubscriptionMgr.getInstance().notifySubscribers(ConsoleProxyManager.ALERT_SUBJECT, this,
|
||||
new ConsoleProxyAlertEventArgs(ConsoleProxyAlertEventArgs.PROXY_CREATED, dataCenterId, proxy.getId(), proxy, null));
|
||||
|
|
@ -1408,7 +1417,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||
try {
|
||||
if (proxyLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
|
||||
try {
|
||||
readyProxy = start(readyProxy.getId(), 0);
|
||||
readyProxy = start2(readyProxy.getId(), 0);
|
||||
} finally {
|
||||
proxyLock.unlock();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ public interface NetworkManager extends Manager {
|
|||
|
||||
List<NetworkOfferingVO> getSystemAccountNetworkOfferings(String... offeringNames);
|
||||
|
||||
<K extends VMInstanceVO> List<NicProfile> allocate(K vm, List<Pair<NetworkConfigurationVO, NicProfile>> networks) throws InsufficientCapacityException;
|
||||
List<NicProfile> allocate(VirtualMachineProfile vm, List<Pair<NetworkConfigurationVO, NicProfile>> networks) throws InsufficientCapacityException;
|
||||
|
||||
List<NicTO> prepare(VirtualMachineProfile profile, DeployDestination dest) throws InsufficientAddressCapacityException, InsufficientVirtualNetworkCapcityException;
|
||||
|
||||
|
|
|
|||
|
|
@ -154,7 +154,6 @@ import com.cloud.utils.net.NetUtils;
|
|||
import com.cloud.vm.DomainRouter;
|
||||
import com.cloud.vm.DomainRouter.Role;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
import com.cloud.vm.NetworkConcierge;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.NicVO;
|
||||
import com.cloud.vm.State;
|
||||
|
|
@ -215,8 +214,6 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||
|
||||
@Inject(adapter=NetworkGuru.class)
|
||||
Adapters<NetworkGuru> _networkGurus;
|
||||
@Inject(adapter=NetworkConcierge.class)
|
||||
Adapters<NetworkConcierge> _networkConcierges;
|
||||
@Inject(adapter=NetworkElement.class)
|
||||
Adapters<NetworkElement> _networkElements;
|
||||
|
||||
|
|
@ -1814,8 +1811,6 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||
_executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("RouterMonitor"));
|
||||
|
||||
final ComponentLocator locator = ComponentLocator.getCurrentLocator();
|
||||
_networkGurus = locator.getAdapters(NetworkGuru.class);
|
||||
_networkConcierges = locator.getAdapters(NetworkConcierge.class);
|
||||
|
||||
final Map<String, String> configs = _configDao.getConfiguration("AgentManager", params);
|
||||
|
||||
|
|
@ -2431,7 +2426,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||
|
||||
|
||||
@Override @DB
|
||||
public <K extends VMInstanceVO> List<NicProfile> allocate(K vm, List<Pair<NetworkConfigurationVO, NicProfile>> networks) throws InsufficientCapacityException {
|
||||
public List<NicProfile> allocate(VirtualMachineProfile vm, List<Pair<NetworkConfigurationVO, NicProfile>> networks) throws InsufficientCapacityException {
|
||||
List<NicProfile> nicProfiles = new ArrayList<NicProfile>(networks.size());
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
|
|
@ -2440,30 +2435,29 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||
int deviceId = 0;
|
||||
|
||||
for (Pair<NetworkConfigurationVO, NicProfile> network : networks) {
|
||||
for (NetworkConcierge concierge : _networkConcierges) {
|
||||
NicProfile profile = concierge.allocate(vm, network.first(), network.second());
|
||||
if (profile == null) {
|
||||
continue;
|
||||
}
|
||||
NicVO vo = new NicVO(concierge.getUniqueName(), vm.getId(), network.first().getId());
|
||||
vo.setDeviceId(deviceId++);
|
||||
vo.setMode(network.first().getMode());
|
||||
if (profile.getIp4Address() != null) {
|
||||
vo.setIp4Address(profile.getIp4Address());
|
||||
vo.setState(NicVO.State.Reserved);
|
||||
}
|
||||
|
||||
if (profile.getMacAddress() != null) {
|
||||
vo.setMacAddress(profile.getMacAddress());
|
||||
}
|
||||
|
||||
if (profile.getMode() != null) {
|
||||
vo.setMode(profile.getMode());
|
||||
}
|
||||
|
||||
vo = _nicDao.persist(vo);
|
||||
nicProfiles.add(new NicProfile(vo, network.first()));
|
||||
NetworkGuru concierge = _networkGurus.get(network.first().getGuruName());
|
||||
NicProfile profile = concierge.allocate(network.first(), network.second(), vm);
|
||||
if (profile == null) {
|
||||
continue;
|
||||
}
|
||||
NicVO vo = new NicVO(concierge.getName(), vm.getId(), network.first().getId());
|
||||
vo.setDeviceId(deviceId++);
|
||||
vo.setMode(network.first().getMode());
|
||||
if (profile.getIp4Address() != null) {
|
||||
vo.setIp4Address(profile.getIp4Address());
|
||||
vo.setState(NicVO.State.Reserved);
|
||||
}
|
||||
|
||||
if (profile.getMacAddress() != null) {
|
||||
vo.setMacAddress(profile.getMacAddress());
|
||||
}
|
||||
|
||||
if (profile.getMode() != null) {
|
||||
vo.setMode(profile.getMode());
|
||||
}
|
||||
|
||||
vo = _nicDao.persist(vo);
|
||||
nicProfiles.add(new NicProfile(vo, network.first()));
|
||||
}
|
||||
txn.commit();
|
||||
|
||||
|
|
@ -2490,18 +2484,18 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||
NetworkConfigurationVO config = _networkProfileDao.findById(nic.getNetworkConfigurationId());
|
||||
|
||||
if (nic.getReservationStrategy() == ReservationStrategy.Start) {
|
||||
NetworkConcierge concierge = _networkConcierges.get(nic.getReserver());
|
||||
NetworkGuru concierge = _networkGurus.get(config.getGuruName());
|
||||
nic.setState(Resource.State.Reserving);
|
||||
_nicDao.update(nic.getId(), nic);
|
||||
NicProfile profile = toNicProfile(nic);
|
||||
String reservationId = concierge.reserve(null, profile, dest);
|
||||
String reservationId = concierge.reserve(profile, vmProfile, dest);
|
||||
nic.setIp4Address(profile.getIp4Address());
|
||||
nic.setIp6Address(profile.getIp6Address());
|
||||
nic.setMacAddress(profile.getMacAddress());
|
||||
nic.setIsolationUri(profile.getIsolationUri());
|
||||
nic.setBroadcastUri(profile.getBroadCastUri());
|
||||
nic.setReservationId(reservationId);
|
||||
nic.setReserver(concierge.getUniqueName());
|
||||
nic.setReserver(concierge.getName());
|
||||
nic.setState(Resource.State.Reserved);
|
||||
_nicDao.update(nic.getId(), nic);
|
||||
for (NetworkElement element : _networkElements) {
|
||||
|
|
@ -2530,8 +2524,8 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||
for (NicVO nic : nics) {
|
||||
nic.setState(Resource.State.Releasing);
|
||||
_nicDao.update(nic.getId(), nic);
|
||||
NetworkConcierge concierge = _networkConcierges.get(nic.getReserver());
|
||||
if (!concierge.release(nic.getReserver(), nic.getReservationId())) {
|
||||
NetworkGuru concierge = _networkGurus.get(nic.getReserver());
|
||||
if (!concierge.release(nic.getReservationId())) {
|
||||
s_logger.warn("Unable to release " + nic + " using " + concierge.getName());
|
||||
}
|
||||
nic.setState(Resource.State.Allocated);
|
||||
|
|
@ -2541,8 +2535,6 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||
|
||||
@Override
|
||||
public <K extends VMInstanceVO> void create(K vm) {
|
||||
for (NetworkConcierge concierge : _networkConcierges) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -28,13 +28,11 @@ 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;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
|
||||
@Local(value={NetworkGuru.class, NetworkConcierge.class})
|
||||
public class ControlNetworkGuru extends AdapterBase implements NetworkGuru, NetworkConcierge {
|
||||
@Local(value={NetworkGuru.class})
|
||||
public class ControlNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
private static final Logger s_logger = Logger.getLogger(ControlNetworkGuru.class);
|
||||
@Inject DataCenterDao _dcDao;
|
||||
String _cidr;
|
||||
|
|
@ -82,12 +80,7 @@ public class ControlNetworkGuru extends AdapterBase implements NetworkGuru, Netw
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueName() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NicProfile allocate(VirtualMachine vm, NetworkConfiguration config, NicProfile nic) throws InsufficientVirtualNetworkCapcityException,
|
||||
public NicProfile allocate(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapcityException,
|
||||
InsufficientAddressCapacityException {
|
||||
if (config.getTrafficType() != TrafficType.Control) {
|
||||
return null;
|
||||
|
|
@ -101,12 +94,12 @@ public class ControlNetworkGuru extends AdapterBase implements NetworkGuru, Netw
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean create(Nic nic) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
|
||||
public boolean create(NicProfile nic, VirtualMachineProfile profile) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String reserve(VirtualMachine vm, NicProfile nic, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException,
|
||||
public String reserve(NicProfile nic, VirtualMachineProfile vm, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException,
|
||||
InsufficientAddressCapacityException {
|
||||
String ip = _dcDao.allocateLinkLocalPrivateIpAddress(dest.getDataCenter().getId(), dest.getPod().getId(), vm.getId());
|
||||
nic.setIp4Address(ip);
|
||||
|
|
@ -116,7 +109,7 @@ public class ControlNetworkGuru extends AdapterBase implements NetworkGuru, Netw
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean release(String uniqueName, String uniqueId) {
|
||||
public boolean release(String uniqueId) {
|
||||
_dcDao.releaseLinkLocalPrivateIpAddress(Long.parseLong(uniqueId));
|
||||
return true;
|
||||
}
|
||||
|
|
@ -125,4 +118,8 @@ public class ControlNetworkGuru extends AdapterBase implements NetworkGuru, Netw
|
|||
public NetworkConfiguration implement(NetworkConfiguration config, NetworkOffering offering, DeployDestination destination) {
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy(NetworkConfiguration config, NetworkOffering offering) {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ import com.cloud.dc.dao.DataCenterDao;
|
|||
import com.cloud.dc.dao.VlanDao;
|
||||
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;
|
||||
|
|
@ -21,6 +23,8 @@ import com.cloud.offering.NetworkOffering.GuestIpType;
|
|||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
|
||||
@Local(value=NetworkGuru.class)
|
||||
public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
|
|
@ -61,4 +65,37 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NicProfile allocate(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm)
|
||||
throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean create(NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapcityException,
|
||||
InsufficientAddressCapacityException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String reserve(NicProfile nic, VirtualMachineProfile vm, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException,
|
||||
InsufficientAddressCapacityException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean release(String uniqueId) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy(NetworkConfiguration config, NetworkOffering offering) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,13 +25,11 @@ import com.cloud.utils.component.AdapterBase;
|
|||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.vm.NetworkConcierge;
|
||||
import com.cloud.vm.Nic;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
|
||||
@Local(value={NetworkGuru.class, NetworkConcierge.class})
|
||||
public class PodBasedNetworkGuru extends AdapterBase implements NetworkGuru, NetworkConcierge {
|
||||
@Local(value={NetworkGuru.class})
|
||||
public class PodBasedNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
private static final Logger s_logger = Logger.getLogger(PodBasedNetworkGuru.class);
|
||||
@Inject DataCenterDao _dcDao;
|
||||
|
||||
|
|
@ -53,12 +51,7 @@ public class PodBasedNetworkGuru extends AdapterBase implements NetworkGuru, Net
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueName() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NicProfile allocate(VirtualMachine vm, NetworkConfiguration config, NicProfile nic) throws InsufficientVirtualNetworkCapcityException,
|
||||
public NicProfile allocate(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapcityException,
|
||||
InsufficientAddressCapacityException {
|
||||
TrafficType trafficType = config.getTrafficType();
|
||||
if (trafficType != TrafficType.Storage && trafficType != TrafficType.Management) {
|
||||
|
|
@ -74,12 +67,12 @@ public class PodBasedNetworkGuru extends AdapterBase implements NetworkGuru, Net
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean create(Nic nic) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
|
||||
public boolean create(NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String reserve(VirtualMachine vm, NicProfile nic, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException,
|
||||
public String reserve(NicProfile nic, VirtualMachineProfile vm, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException,
|
||||
InsufficientAddressCapacityException {
|
||||
DataCenter dc = dest.getDataCenter();
|
||||
Pod pod = dest.getPod();
|
||||
|
|
@ -98,7 +91,7 @@ public class PodBasedNetworkGuru extends AdapterBase implements NetworkGuru, Net
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean release(String uniqueName, String uniqueId) {
|
||||
public boolean release(String uniqueId) {
|
||||
_dcDao.releasePrivateIpAddress(Long.parseLong(uniqueId));
|
||||
return true;
|
||||
}
|
||||
|
|
@ -107,5 +100,8 @@ public class PodBasedNetworkGuru extends AdapterBase implements NetworkGuru, Net
|
|||
public NetworkConfiguration implement(NetworkConfiguration config, NetworkOffering offering, DeployDestination destination) {
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void destroy(NetworkConfiguration config, NetworkOffering offering) {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,13 +29,11 @@ import com.cloud.utils.Pair;
|
|||
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;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
|
||||
@Local(value={NetworkGuru.class, NetworkConcierge.class})
|
||||
public class PublicNetworkGuru extends AdapterBase implements NetworkGuru, NetworkConcierge {
|
||||
@Local(value={NetworkGuru.class})
|
||||
public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
private static final Logger s_logger = Logger.getLogger(PublicNetworkGuru.class);
|
||||
|
||||
@Inject DataCenterDao _dcDao;
|
||||
|
|
@ -55,12 +53,7 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru, Netwo
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueName() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NicProfile allocate(VirtualMachine vm, NetworkConfiguration config, NicProfile nic) throws InsufficientVirtualNetworkCapcityException,
|
||||
public NicProfile allocate(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapcityException,
|
||||
InsufficientAddressCapacityException {
|
||||
if (config.getTrafficType() != TrafficType.Public) {
|
||||
return null;
|
||||
|
|
@ -74,16 +67,15 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru, Netwo
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean create(Nic nic) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
|
||||
public boolean create(NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String reserve(VirtualMachine vm, NicProfile ch, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
|
||||
public String reserve(NicProfile ch, VirtualMachineProfile vm, DeployDestination dest) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
|
||||
long dcId = dest.getDataCenter().getId();
|
||||
long podId = dest.getPod().getId();
|
||||
|
||||
Pair<String, VlanVO> ipAndVlan = _vlanDao.assignIpAddress(dcId, vm.getAccountId(), vm.getDomainId(), VlanType.VirtualNetwork, true);
|
||||
Pair<String, VlanVO> ipAndVlan = _vlanDao.assignIpAddress(dcId, vm.getVm().getAccountId(), vm.getVm().getDomainId(), VlanType.VirtualNetwork, true);
|
||||
if (ipAndVlan == null) {
|
||||
throw new InsufficientVirtualNetworkCapcityException("Unable to get public ip address in " + dcId);
|
||||
}
|
||||
|
|
@ -102,7 +94,7 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru, Netwo
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean release(String uniqueName, String uniqueId) {
|
||||
public boolean release(String uniqueId) {
|
||||
return _vlanDao.release(Long.parseLong(uniqueId));
|
||||
}
|
||||
|
||||
|
|
@ -110,4 +102,8 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru, Netwo
|
|||
public NetworkConfiguration implement(NetworkConfiguration config, NetworkOffering offering, DeployDestination destination) {
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy(NetworkConfiguration config, NetworkOffering offering) {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,12 +33,13 @@ import com.cloud.agent.api.to.VirtualMachineTO;
|
|||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.deploy.DeploymentDispatcher;
|
||||
import com.cloud.deploy.DeploymentPlan;
|
||||
import com.cloud.deploy.DeploymentPlanner;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.network.NetworkConfigurationVO;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
|
|
@ -70,8 +71,8 @@ public class MauriceMoss implements VmManager {
|
|||
@Inject private VMInstanceDao _vmDao;
|
||||
@Inject private ServiceOfferingDao _offeringDao;
|
||||
|
||||
@Inject(adapter=DeploymentDispatcher.class)
|
||||
private Adapters<DeploymentDispatcher> _dispatchers;
|
||||
@Inject(adapter=DeploymentPlanner.class)
|
||||
private Adapters<DeploymentPlanner> _planners;
|
||||
|
||||
private int _retry;
|
||||
|
||||
|
|
@ -95,7 +96,7 @@ public class MauriceMoss implements VmManager {
|
|||
vm.setDataCenterId(plan.getDataCenterId());
|
||||
_vmDao.update(vm.getId(), vm);
|
||||
|
||||
List<NicProfile> nics = _networkMgr.allocate(vm, networks);
|
||||
List<NicProfile> nics = _networkMgr.allocate(vmProfile, networks);
|
||||
vmProfile.setNics(nics);
|
||||
|
||||
if (dataDiskOfferings == null) {
|
||||
|
|
@ -163,7 +164,7 @@ public class MauriceMoss implements VmManager {
|
|||
int retry = _retry;
|
||||
while (_retry-- > 0) {
|
||||
DeployDestination context = null;
|
||||
for (DeploymentDispatcher dispatcher : _dispatchers) {
|
||||
for (DeploymentPlanner dispatcher : _planners) {
|
||||
context = dispatcher.plan(vmProfile, plan, avoids);
|
||||
if (context != null) {
|
||||
journal.record("Deployment found ", vmProfile, context);
|
||||
|
|
@ -217,7 +218,7 @@ public class MauriceMoss implements VmManager {
|
|||
ConfigurationDao configDao = locator.getDao(ConfigurationDao.class);
|
||||
Map<String, String> params = configDao.getConfiguration(xmlParams);
|
||||
|
||||
_dispatchers = locator.getAdapters(DeploymentDispatcher.class);
|
||||
_planners = locator.getAdapters(DeploymentPlanner.class);
|
||||
|
||||
_retry = NumbersUtil.parseInt(params.get(Config.StartRetry.key()), 2);
|
||||
return true;
|
||||
|
|
@ -232,39 +233,41 @@ public class MauriceMoss implements VmManager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> T start(VirtualMachineProfile vmProfile, DeploymentPlan plan) throws InsufficientCapacityException {
|
||||
public <T extends VMInstanceVO> T start(T vm, DeploymentPlan plan) throws InsufficientCapacityException {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Creating actual resources for VM " + vmProfile);
|
||||
s_logger.debug("Creating actual resources for VM " + vm);
|
||||
}
|
||||
|
||||
Journal journal = new Journal.LogJournal("Creating " + vmProfile, s_logger);
|
||||
Journal journal = new Journal.LogJournal("Creating " + vm, s_logger);
|
||||
|
||||
ServiceOffering offering = _offeringDao.findById(vm.getServiceOfferingId());
|
||||
|
||||
VirtualMachineProfile vmProfile = new VirtualMachineProfile(vm, offering);
|
||||
|
||||
Set<DeployDestination> avoids = new HashSet<DeployDestination>();
|
||||
int retry = _retry;
|
||||
while (_retry-- > 0) {
|
||||
DeployDestination context = null;
|
||||
for (DeploymentDispatcher dispatcher : _dispatchers) {
|
||||
context = dispatcher.plan(vmProfile, plan, avoids);
|
||||
if (context != null) {
|
||||
avoids.add(context);
|
||||
journal.record("Deployment found ", vmProfile, context);
|
||||
while (retry-- > 0) {
|
||||
DeployDestination dest = null;
|
||||
for (DeploymentPlanner dispatcher : _planners) {
|
||||
dest = dispatcher.plan(vmProfile, plan, avoids);
|
||||
if (dest != null) {
|
||||
avoids.add(dest);
|
||||
journal.record("Deployment found ", vmProfile, dest);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (context == null) {
|
||||
if (dest == null) {
|
||||
throw new CloudRuntimeException("Unable to create a deployment for " + vmProfile);
|
||||
}
|
||||
|
||||
VMInstanceVO vm = _vmDao.findById(vmProfile.getId());
|
||||
|
||||
vm.setDataCenterId(context.getDataCenter().getId());
|
||||
vm.setPodId(context.getPod().getId());
|
||||
_vmDao.updateIf(vm, Event.StartRequested, context.getHost().getId());
|
||||
vm.setDataCenterId(dest.getDataCenter().getId());
|
||||
vm.setPodId(dest.getPod().getId());
|
||||
_vmDao.updateIf(vm, Event.StartRequested, dest.getHost().getId());
|
||||
|
||||
VirtualMachineTO vmTO = new VirtualMachineTO();
|
||||
// _networkMgr.prepare(vmProfile);
|
||||
// _storageMgr.prepare(vm);
|
||||
_networkMgr.prepare(vmProfile, dest);
|
||||
// _storageMgr.prepare(vm, dest);
|
||||
}
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public interface VmManager extends Manager {
|
|||
DeploymentPlan plan,
|
||||
AccountVO owner) throws InsufficientCapacityException, StorageUnavailableException;
|
||||
|
||||
<T extends VMInstanceVO> T start(VirtualMachineProfile p, DeploymentPlan plan) throws InsufficientCapacityException, StorageUnavailableException, ConcurrentOperationException;
|
||||
<T extends VMInstanceVO> T start(T vm, DeploymentPlan plan) throws InsufficientCapacityException, StorageUnavailableException, ConcurrentOperationException;
|
||||
|
||||
<T extends VMInstanceVO> T stop(T vm) throws AgentUnavailableException, ConcurrentOperationException;
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public class Journal {
|
|||
}
|
||||
|
||||
public void record(Logger logger, Level p, String msg, Object... params) {
|
||||
if (logger.getLevel().isGreaterOrEqual(p)) {
|
||||
if (logger.isEnabledFor(p)) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
toString(buf, msg, params);
|
||||
String entry = buf.toString();
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
package com.cloud.utils.component;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
|
@ -35,7 +36,6 @@ import com.cloud.utils.EnumerationImpl;
|
|||
**/
|
||||
public class Adapters<T extends Adapter> implements Iterable<T> {
|
||||
private Map<String, T> _map;
|
||||
private List<T> _adapters;
|
||||
protected String _name;
|
||||
|
||||
public Adapters(String name, List<T> adapters) {
|
||||
|
|
@ -53,16 +53,16 @@ public class Adapters<T extends Adapter> implements Iterable<T> {
|
|||
}
|
||||
|
||||
public Enumeration<T> enumeration() {
|
||||
return new EnumerationImpl<T>(_adapters.iterator());
|
||||
return new EnumerationImpl<T>(_map.values().iterator());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<T> iterator() {
|
||||
return new EnumerationImpl<T>(_adapters.iterator());
|
||||
return new EnumerationImpl<T>(_map.values().iterator());
|
||||
}
|
||||
|
||||
protected List<T> get() {
|
||||
return _adapters;
|
||||
protected Collection<T> get() {
|
||||
return _map.values();
|
||||
}
|
||||
|
||||
protected void set(List<T> adapters) {
|
||||
|
|
@ -71,7 +71,6 @@ public class Adapters<T extends Adapter> implements Iterable<T> {
|
|||
map.put(adapter.getName(), adapter);
|
||||
}
|
||||
this._map = map;
|
||||
this._adapters = adapters;
|
||||
}
|
||||
|
||||
public T get(String name) {
|
||||
|
|
@ -79,6 +78,6 @@ public class Adapters<T extends Adapter> implements Iterable<T> {
|
|||
}
|
||||
|
||||
public boolean isSet() {
|
||||
return _adapters.size() != 0;
|
||||
return _map.size() != 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -443,7 +443,7 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
|||
Set<Map.Entry<String, List<Info<Adapter>>>> entries = map.entrySet();
|
||||
for (Map.Entry<String, List<Info<Adapter>>> entry : entries) {
|
||||
Adapters<Adapter> adapters = (Adapters<Adapter>)_adapterMap.get(entry.getKey());
|
||||
List<Adapter> lst = adapters.get();
|
||||
List<Adapter> lst = new ArrayList<Adapter>();
|
||||
for (Info<Adapter> info : entry.getValue()) {
|
||||
s_logger.info("Instantiating Adapter: " + info.name);
|
||||
info.instance = (Adapter)createInstance(info.clazz, true);
|
||||
|
|
@ -462,6 +462,7 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
|||
lst.add(info.instance);
|
||||
s_logger.info("Instantiated Adapter: " + info.name);
|
||||
}
|
||||
adapters.set(lst);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue