removed router stuff from network manager

This commit is contained in:
Alex Huang 2010-12-04 15:12:49 -08:00
parent 3bd089acb5
commit daa9add158
22 changed files with 456 additions and 458 deletions

View File

@ -26,9 +26,8 @@ import com.cloud.network.Networks.TrafficType;
public interface NetworkOffering {
public enum GuestIpType {
Virtualized,
DirectSingle,
DirectDual
Virtual,
Direct,
}
public final String DefaultVirtualizedNetworkOffering = "DefaultVirtualizedNetworkOffering";

View File

@ -244,14 +244,14 @@ public class UserConcentratedAllocator implements PodAllocator {
so = _offeringDao.findById(userVm.getServiceOfferingId());
} else if(vm.getType() == VirtualMachine.Type.ConsoleProxy) {
so = new ServiceOfferingVO("Fake Offering For DomP", 1,
_proxyRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, false, true, null, true);
_proxyRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, false, true, null, true);
} else if(vm.getType() == VirtualMachine.Type.SecondaryStorageVm) {
so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, false, true, null, true);
so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, false, true, null, true);
} else if(vm.getType() == VirtualMachine.Type.DomainRouter) {
so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, false, true, null, true);
so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, false, true, null, true);
} else {
assert(false) : "Unsupported system vm type";
so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, false, true, null, true);
so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, false, true, null, true);
}
if(capacityType == CapacityVO.CAPACITY_TYPE_MEMORY) {

View File

@ -346,7 +346,7 @@ public class ApiResponseHelper implements ResponseGenerator {
offeringResponse.setCreated(offering.getCreated());
offeringResponse.setStorageType(offering.getUseLocalStorage() ? "local" : "shared");
offeringResponse.setOfferHa(offering.getOfferHA());
offeringResponse.setUseVirtualNetwork(offering.getGuestIpType().equals(GuestIpType.Virtualized));
offeringResponse.setUseVirtualNetwork(offering.getGuestIpType().equals(GuestIpType.Virtual));
offeringResponse.setTags(offering.getTags());
if(offering.getDomainId() != null){
offeringResponse.setDomain(ApiDBUtils.findDomainById(offering.getDomainId()).getName());
@ -497,7 +497,7 @@ public class ApiResponseHelper implements ResponseGenerator {
userVmResponse.setCpuNumber(offering.getCpu());
userVmResponse.setCpuSpeed(offering.getSpeed());
userVmResponse.setMemory(offering.getRamSize());
userVmResponse.setForVirtualNetwork(offering.getGuestIpType().equals(GuestIpType.Virtualized));
userVmResponse.setForVirtualNetwork(offering.getGuestIpType().equals(GuestIpType.Virtual));
VolumeVO rootVolume = ApiDBUtils.findRootVolume(userVm.getId());
if (rootVolume != null) {

View File

@ -1162,7 +1162,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
String multicastRateStr = _configDao.getValue("multicast.throttling.rate");
int networkRate = ((networkRateStr == null) ? 200 : Integer.parseInt(networkRateStr));
int multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr));
NetworkOffering.GuestIpType guestIpType = useVirtualNetwork ? NetworkOffering.GuestIpType.Virtualized : NetworkOffering.GuestIpType.DirectSingle;
NetworkOffering.GuestIpType guestIpType = useVirtualNetwork ? NetworkOffering.GuestIpType.Virtual : NetworkOffering.GuestIpType.Direct;
tags = cleanupTags(tags);
ServiceOfferingVO offering = new ServiceOfferingVO(name, cpu, ramSize, speed, networkRate, multicastRate, offerHA, displayText, guestIpType, localStorageRequired, false, tags, false,domainId);
@ -1216,7 +1216,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
}
if (useVirtualNetwork != null) {
NetworkOffering.GuestIpType guestIpType = useVirtualNetwork ? NetworkOffering.GuestIpType.Virtualized : NetworkOffering.GuestIpType.DirectSingle;
NetworkOffering.GuestIpType guestIpType = useVirtualNetwork ? NetworkOffering.GuestIpType.Virtual : NetworkOffering.GuestIpType.Direct;
offering.setGuestIpType(guestIpType);
}
@ -1248,7 +1248,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
if (_serviceOfferingDao.update(id, offering)) {
offering = _serviceOfferingDao.findById(id);
saveConfigurationEvent(userId, null, EventTypes.EVENT_SERVICE_OFFERING_EDIT, "Successfully updated service offering with name: " + offering.getName() + ".", "soId=" + offering.getId(), "name=" + offering.getName(),
"displayText=" + offering.getDisplayText(), "offerHA=" + offering.getOfferHA(), "useVirtualNetwork=" + (offering.getGuestIpType() == NetworkOffering.GuestIpType.Virtualized), "tags=" + offering.getTags(), "domainId=" + offering.getDomainId());
"displayText=" + offering.getDisplayText(), "offerHA=" + offering.getOfferHA(), "useVirtualNetwork=" + (offering.getGuestIpType() == NetworkOffering.GuestIpType.Virtual), "tags=" + offering.getTags(), "domainId=" + offering.getDomainId());
return offering;
} else {
return null;
@ -1395,7 +1395,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
if (_serviceOfferingDao.remove(offeringId)) {
saveConfigurationEvent(userId, null, EventTypes.EVENT_SERVICE_OFFERING_EDIT, "Successfully deleted service offering with name: " + offering.getName(), "soId=" + offeringId, "name=" + offering.getName(),
"displayText=" + offering.getDisplayText(), "offerHA=" + offering.getOfferHA(), "useVirtualNetwork=" + (offering.getGuestIpType() == GuestIpType.Virtualized));
"displayText=" + offering.getDisplayText(), "offerHA=" + offering.getOfferHA(), "useVirtualNetwork=" + (offering.getGuestIpType() == GuestIpType.Virtual));
return true;
} else {
return false;

View File

@ -136,7 +136,6 @@ import com.cloud.user.Account;
import com.cloud.user.AccountService;
import com.cloud.user.AccountVO;
import com.cloud.user.User;
import com.cloud.user.UserVO;
import com.cloud.user.dao.AccountDao;
import com.cloud.utils.DateUtil;
import com.cloud.utils.NumbersUtil;
@ -330,8 +329,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
}
ConsoleProxyVO proxy = result.second();
if (proxy == null)
if (proxy == null) {
return null;
}
return new ConsoleProxyInfo(proxy.isSslEnabled(), proxy.getPublicIpAddress(), _consoleProxyPort, proxy.getPort(), _configDao.getValue("consoleproxy.url.domain"));
}
@ -384,25 +384,29 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
// storage and computing
// resource may be allocated and assigned in another pod
//
if (s_logger.isInfoEnabled())
if (s_logger.isInfoEnabled()) {
s_logger.info("Unable to start console proxy, proxy vm Id : " + proxyVmId + " will recycle it and restart a new one");
}
destroyProxy(proxyVmId, 0);
return null;
} else {
if (s_logger.isTraceEnabled())
if (s_logger.isTraceEnabled()) {
s_logger.trace("Console proxy " + proxy.getHostName() + " is started");
}
// if it is a new assignment or a changed assignment,
// update the
// record
if (vm.getProxyId() == null || vm.getProxyId().longValue() != proxy.getId())
if (vm.getProxyId() == null || vm.getProxyId().longValue() != proxy.getId()) {
_instanceDao.updateProxyId(vmId, proxy.getId(), DateUtil.currentGMTTime());
}
proxy.setSslEnabled(_sslEnabled);
if (_sslEnabled)
if (_sslEnabled) {
proxy.setPort(443);
else
} else {
proxy.setPort(80);
}
return proxy;
}
} finally {
@ -424,8 +428,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
VMInstanceVO vm = this._instanceDao.findById(vmId);
if (vm != null && vm.getState() != State.Running) {
if (s_logger.isInfoEnabled())
if (s_logger.isInfoEnabled()) {
s_logger.info("Detected that vm : " + vmId + " is not currently at running state, we will fail the proxy assignment for it");
}
return null;
}
@ -434,16 +439,19 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
if (proxy != null) {
if (!isInAssignableState(proxy)) {
if (s_logger.isInfoEnabled())
if (s_logger.isInfoEnabled()) {
s_logger.info("A previous assigned proxy is not assignable now, reassign console proxy for user vm : " + vmId);
}
proxy = null;
} else {
if (_consoleProxyDao.getProxyActiveLoad(proxy.getId()) < _capacityPerProxy || hasPreviousSession(proxy, vm)) {
if (s_logger.isTraceEnabled())
if (s_logger.isTraceEnabled()) {
s_logger.trace("Assign previous allocated console proxy for user vm : " + vmId);
}
if (proxy.getActiveSession() >= _capacityPerProxy)
if (proxy.getActiveSession() >= _capacityPerProxy) {
s_logger.warn("Assign overloaded proxy to user VM as previous session exists, user vm : " + vmId);
}
} else {
proxy = null;
}
@ -451,24 +459,28 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
}
}
if (proxy == null)
if (proxy == null) {
proxy = assignProxyFromRunningPool(dataCenterId);
}
if (proxy == null) {
if (s_logger.isInfoEnabled())
if (s_logger.isInfoEnabled()) {
s_logger.info("No running console proxy is available, check to see if we can bring up a stopped one for data center : "
+ dataCenterId);
}
proxy = assignProxyFromStoppedPool(dataCenterId);
if (proxy == null) {
if (s_logger.isInfoEnabled())
if (s_logger.isInfoEnabled()) {
s_logger.info("No stopped console proxy is available, need to allocate a new console proxy for data center : " + dataCenterId);
}
proxy = startNew(dataCenterId);
} else {
if (s_logger.isInfoEnabled())
if (s_logger.isInfoEnabled()) {
s_logger.info("Found a stopped console proxy, bring it up to running pool. proxy vm id : " + proxy.getId() + ", data center : "
+ dataCenterId);
}
proxyFromStoppedPool[0] = new Boolean(true);
}
@ -480,8 +492,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
private static boolean isInAssignableState(ConsoleProxyVO proxy) {
// console proxies that are in states of being able to serve user VM
State state = proxy.getState();
if (state == State.Running || state == State.Starting || state == State.Creating || state == State.Migrating)
if (state == State.Running || state == State.Starting || state == State.Creating || state == State.Migrating) {
return true;
}
return false;
}
@ -511,8 +524,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
s_logger.warn("Unable to parse console proxy connection info passed through tag: " + connections[i].tag, e);
}
}
if (taggedVmId == vm.getId())
if (taggedVmId == vm.getId()) {
return true;
}
}
//
@ -520,8 +534,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
// received load-update yet
// wait until session time
//
if (DateUtil.currentGMTTime().getTime() - vm.getProxyAssignTime().getTime() < _proxySessionTimeoutValue)
if (DateUtil.currentGMTTime().getTime() - vm.getProxyAssignTime().getTime() < _proxySessionTimeoutValue) {
return true;
}
return false;
} else {
@ -568,8 +583,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
if (asyncExecutor != null) {
AsyncJobVO job = asyncExecutor.getJob();
if (s_logger.isInfoEnabled())
if (s_logger.isInfoEnabled()) {
s_logger.info("Start console proxy " + proxyId + ", update async job-" + job.getId());
}
_asyncMgr.updateAsyncJobAttachment(job.getId(), "console_proxy", proxyId);
}
@ -594,14 +610,16 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
State state = proxy.getState();
if (state == State.Starting /* || state == State.Migrating */) {
if (s_logger.isDebugEnabled())
if (s_logger.isDebugEnabled()) {
s_logger.debug("Waiting console proxy to be ready, proxy vm id : " + proxyId + " proxy VM state : " + state.toString());
}
if (proxy.getPrivateIpAddress() == null || connect(proxy.getPrivateIpAddress(), _proxyCmdPort) != null) {
if (proxy.getPrivateIpAddress() == null)
if (proxy.getPrivateIpAddress() == null) {
s_logger.warn("Retruning a proxy that is being started but private IP has not been allocated yet, proxy vm id : " + proxyId);
else
} else {
s_logger.warn("Waiting console proxy to be ready timed out, proxy vm id : " + proxyId);
}
// TODO, it is very tricky here, if the startup process
// takes too long and it timed out here,
@ -612,8 +630,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
}
if (state == State.Running) {
if (s_logger.isTraceEnabled())
if (s_logger.isTraceEnabled()) {
s_logger.trace("Console proxy is already started: " + proxy.getHostName());
}
return proxy;
}
@ -692,15 +711,17 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
StartConsoleProxyCommand cmdStart = new StartConsoleProxyCommand(_networkRate, _multicastRate,
_proxyCmdPort, proxy, proxy.getHostName(), "", vols, Integer.toString(_consoleProxyPort),
Integer.toString(_consoleProxyUrlPort), _mgmt_host, _mgmt_port, _sslEnabled, guestOSDescription);
if (s_logger.isDebugEnabled())
if (s_logger.isDebugEnabled()) {
s_logger.debug("Sending start command for console proxy " + proxy.getHostName() + " to " + routingHost.getName());
}
try {
answer = _agentMgr.send(routingHost.getId(), cmdStart);
s_logger.debug("StartConsoleProxy Answer: " + (answer != null ? answer : "null"));
if (s_logger.isDebugEnabled())
if (s_logger.isDebugEnabled()) {
s_logger.debug("Received answer on starting console proxy " + proxy.getHostName() + " on " + routingHost.getName());
}
if (answer != null && answer.getResult()) {
if (s_logger.isDebugEnabled()) {
@ -842,8 +863,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
public ConsoleProxyVO assignProxyFromRunningPool(long dataCenterId) {
if (s_logger.isTraceEnabled())
if (s_logger.isTraceEnabled()) {
s_logger.trace("Assign console proxy from running pool for request from data center : " + dataCenterId);
}
ConsoleProxyAllocator allocator = getCurrentAllocator();
assert (allocator != null);
@ -851,8 +873,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
if (runningList != null && runningList.size() > 0) {
if (s_logger.isTraceEnabled()) {
s_logger.trace("Running proxy pool size : " + runningList.size());
for (ConsoleProxyVO proxy : runningList)
for (ConsoleProxyVO proxy : runningList) {
s_logger.trace("Running proxy instance : " + proxy.getHostName());
}
}
List<Pair<Long, Integer>> l = _consoleProxyDao.getProxyLoadMatrix();
@ -868,34 +891,39 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
}
return allocator.allocProxy(runningList, loadInfo, dataCenterId);
} else {
if (s_logger.isTraceEnabled())
if (s_logger.isTraceEnabled()) {
s_logger.trace("Empty running proxy pool for now in data center : " + dataCenterId);
}
}
return null;
}
public ConsoleProxyVO assignProxyFromStoppedPool(long dataCenterId) {
List<ConsoleProxyVO> l = _consoleProxyDao.getProxyListInStates(dataCenterId, State.Creating, State.Starting, State.Stopped, State.Migrating);
if (l != null && l.size() > 0)
if (l != null && l.size() > 0) {
return l.get(0);
}
return null;
}
public ConsoleProxyVO startNewConsoleProxy(long dataCenterId) {
if (s_logger.isDebugEnabled())
if (s_logger.isDebugEnabled()) {
s_logger.debug("Assign console proxy from a newly started instance for request from data center : " + dataCenterId);
}
Map<String, Object> context = _useNewNetworking ? createProxyInstance2(dataCenterId) : createProxyInstance(dataCenterId);
long proxyVmId = (Long) context.get("proxyVmId");
if (proxyVmId == 0) {
if (s_logger.isTraceEnabled())
if (s_logger.isTraceEnabled()) {
s_logger.trace("Creating proxy instance failed, data center id : " + dataCenterId);
}
// release critical system resource on failure
if (context.get("publicIpAddress") != null)
if (context.get("publicIpAddress") != null) {
freePublicIpAddress((String) context.get("publicIpAddress"), dataCenterId, 0);
}
return null;
}
@ -907,8 +935,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
new ConsoleProxyAlertEventArgs(ConsoleProxyAlertEventArgs.PROXY_CREATED, dataCenterId, proxy.getId(), proxy, null));
return proxy;
} else {
if (s_logger.isDebugEnabled())
if (s_logger.isDebugEnabled()) {
s_logger.debug("Unable to allocate console proxy storage, remove the console proxy record from DB, proxy id: " + proxyVmId);
}
SubscriptionMgr.getInstance().notifySubscribers(
ConsoleProxyManager.ALERT_SUBJECT,
@ -923,19 +952,22 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
public ConsoleProxyVO startNew(long dataCenterId) {
if (s_logger.isDebugEnabled())
if (s_logger.isDebugEnabled()) {
s_logger.debug("Assign console proxy from a newly started instance for request from data center : " + dataCenterId);
}
Map<String, Object> context = _useNewNetworking ? createProxyInstance2(dataCenterId) : createProxyInstance(dataCenterId);
long proxyVmId = (Long) context.get("proxyVmId");
if (proxyVmId == 0) {
if (s_logger.isTraceEnabled())
if (s_logger.isTraceEnabled()) {
s_logger.trace("Creating proxy instance failed, data center id : " + dataCenterId);
}
// release critical system resource on failure
if (context.get("publicIpAddress") != null)
if (context.get("publicIpAddress") != null) {
freePublicIpAddress((String) context.get("publicIpAddress"), dataCenterId, 0);
}
return null;
}
@ -947,8 +979,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
new ConsoleProxyAlertEventArgs(ConsoleProxyAlertEventArgs.PROXY_CREATED, dataCenterId, proxy.getId(), proxy, null));
return proxy;
} else {
if (s_logger.isDebugEnabled())
if (s_logger.isDebugEnabled()) {
s_logger.debug("Unable to allocate console proxy storage, remove the console proxy record from DB, proxy id: " + proxyVmId);
}
SubscriptionMgr.getInstance().notifySubscribers(
ConsoleProxyManager.ALERT_SUBJECT,
@ -1147,8 +1180,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
if (ipAndVlan == null) {
s_logger.debug("Unable to get public ip address (type=Virtual) for console proxy vm for data center : " + dcId);
ipAndVlan = _vlanDao.assignPodDirectAttachIpAddress(dcId, podId, Account.ACCOUNT_ID_SYSTEM, DomainVO.ROOT_DOMAIN);
if (ipAndVlan == null)
if (ipAndVlan == null) {
s_logger.debug("Unable to get public ip address (type=DirectAttach) for console proxy vm for data center : " + dcId);
}
}
if (ipAndVlan != null) {
VlanVO vlan = ipAndVlan.second();
@ -1185,8 +1219,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
private ConsoleProxyAllocator getCurrentAllocator() {
// for now, only one adapter is supported
Enumeration<ConsoleProxyAllocator> it = _consoleProxyAllocators.enumeration();
if (it.hasMoreElements())
if (it.hasMoreElements()) {
return it.nextElement();
}
return null;
}
@ -1229,8 +1264,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
}
public void onLoadAnswer(ConsoleProxyLoadAnswer answer) {
if (answer.getDetails() == null)
if (answer.getDetails() == null) {
return;
}
ConsoleProxyStatus status = null;
try {
@ -1244,16 +1280,19 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
if (status != null) {
int count = 0;
if (status.getConnections() != null)
if (status.getConnections() != null) {
count = status.getConnections().length;
}
byte[] details = null;
if (answer.getDetails() != null)
if (answer.getDetails() != null) {
details = answer.getDetails().getBytes(Charset.forName("US-ASCII"));
}
_consoleProxyDao.update(answer.getProxyVmId(), count, DateUtil.currentGMTTime(), details);
} else {
if (s_logger.isTraceEnabled())
if (s_logger.isTraceEnabled()) {
s_logger.trace("Unable to get console proxy load info, id : " + answer.getProxyVmId());
}
_consoleProxyDao.update(answer.getProxyVmId(), 0, DateUtil.currentGMTTime(), null);
// TODO : something is wrong with the VM, restart it?
@ -1262,8 +1301,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
@Override
public void onLoadReport(ConsoleProxyLoadReportCommand cmd) {
if (cmd.getLoadInfo() == null)
if (cmd.getLoadInfo() == null) {
return;
}
ConsoleProxyStatus status = null;
try {
@ -1277,16 +1317,19 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
if (status != null) {
int count = 0;
if (status.getConnections() != null)
if (status.getConnections() != null) {
count = status.getConnections().length;
}
byte[] details = null;
if (cmd.getLoadInfo() != null)
if (cmd.getLoadInfo() != null) {
details = cmd.getLoadInfo().getBytes(Charset.forName("US-ASCII"));
}
_consoleProxyDao.update(cmd.getProxyVmId(), count, DateUtil.currentGMTTime(), details);
} else {
if (s_logger.isTraceEnabled())
if (s_logger.isTraceEnabled()) {
s_logger.trace("Unable to get console proxy load info, id : " + cmd.getProxyVmId());
}
_consoleProxyDao.update(cmd.getProxyVmId(), 0, DateUtil.currentGMTTime(), null);
}
@ -1315,8 +1358,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
}
if (cmd.getVmId() != null && cmd.getVmId().isEmpty()) {
if (s_logger.isTraceEnabled())
if (s_logger.isTraceEnabled()) {
s_logger.trace("Invalid vm id sent from proxy(happens when proxy session has terminated)");
}
return new ConsoleAccessAuthenticationAnswer(cmd, false);
}
@ -1376,8 +1420,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
// pinging the console proxy VM command port
//
// for now, just log a message
if (s_logger.isInfoEnabled())
if (s_logger.isInfoEnabled()) {
s_logger.info("Console proxy agent is connected. proxy: " + host.getName());
}
/* update public/private ip address */
if (_IpAllocator != null && _IpAllocator.exteralIpAddressAllocatorEnabled()) {
@ -1408,8 +1453,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
HostVO host = _hostDao.findById(agentId);
if (host.getType() == Type.ConsoleProxy) {
String name = host.getName();
if (s_logger.isInfoEnabled())
if (s_logger.isInfoEnabled()) {
s_logger.info("Console proxy agent disconnected, proxy: " + name);
}
if (name != null && name.startsWith("v-")) {
String[] tokens = name.split("-");
long proxyVmId = 0;
@ -1441,9 +1487,10 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
* ); stopProxy(proxy.getId()); } });
*/
} else {
if (s_logger.isInfoEnabled())
if (s_logger.isInfoEnabled()) {
s_logger.info("Console proxy agent disconnected but corresponding console proxy VM no longer exists in DB, proxy: "
+ name);
}
}
} else {
assert (false) : "Invalid console proxy name: " + name;
@ -1478,16 +1525,18 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
proxyLock.unlock();
}
} else {
if (s_logger.isInfoEnabled())
if (s_logger.isInfoEnabled()) {
s_logger.info("Unable to acquire synchronization lock to start console proxy : " + readyProxy.getHostName());
}
}
} finally {
proxyLock.releaseRef();
}
}
} else {
if (s_logger.isInfoEnabled())
if (s_logger.isInfoEnabled()) {
s_logger.info("Unable to acquire synchronization lock to allocate proxy storage, wait for next turn");
}
}
} catch (StorageUnavailableException e) {
s_logger.warn("Storage unavailable", e);
@ -1520,8 +1569,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
}
private void reallyRun() {
if (s_logger.isTraceEnabled())
if (s_logger.isTraceEnabled()) {
s_logger.trace("Begin console proxy capacity scan");
}
// config var for consoleproxy.restart check
String restart = _configDao.getValue("consoleproxy.restart");
@ -1532,17 +1582,20 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
Map<Long, ZoneHostInfo> zoneHostInfoMap = getZoneHostInfo();
if (isServiceReady(zoneHostInfoMap)) {
if (s_logger.isTraceEnabled())
if (s_logger.isTraceEnabled()) {
s_logger.trace("Service is ready, check to see if we need to allocate standby capacity");
}
if (!_capacityScanLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION)) {
if (s_logger.isTraceEnabled())
if (s_logger.isTraceEnabled()) {
s_logger.trace("Capacity scan lock is used by others, skip and wait for my turn");
}
return;
}
if (s_logger.isTraceEnabled())
if (s_logger.isTraceEnabled()) {
s_logger.trace("*** Begining capacity scan... ***");
}
try {
checkPendingProxyVMs();
@ -1560,9 +1613,11 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
// indexing load info by data-center id
Map<Long, ConsoleProxyLoadInfo> mapVmCounts = new HashMap<Long, ConsoleProxyLoadInfo>();
if (listVmCounts != null)
for (ConsoleProxyLoadInfo info : listVmCounts)
if (listVmCounts != null) {
for (ConsoleProxyLoadInfo info : listVmCounts) {
mapVmCounts.put(info.getId(), info);
}
}
for (ConsoleProxyLoadInfo info : l) {
if (info.getName().equals(_instance)) {
@ -1572,8 +1627,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
if (isZoneReady(zoneHostInfoMap, info.getId())) {
allocCapacity(info.getId());
} else {
if (s_logger.isTraceEnabled())
if (s_logger.isTraceEnabled()) {
s_logger.trace("Zone " + info.getId() + " is not ready to alloc standy console proxy");
}
}
}
@ -1591,47 +1647,54 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
if (isZoneReady(zoneHostInfoMap, info.getId())) {
allocCapacity(info.getId());
} else {
if (s_logger.isTraceEnabled())
if (s_logger.isTraceEnabled()) {
s_logger.trace("Zone " + info.getId() + " is not ready to alloc standy console proxy");
}
}
}
}
}
if (s_logger.isTraceEnabled())
if (s_logger.isTraceEnabled()) {
s_logger.trace("*** Stop capacity scan ***");
}
} finally {
_capacityScanLock.unlock();
}
} else {
if (s_logger.isTraceEnabled())
if (s_logger.isTraceEnabled()) {
s_logger.trace("Service is not ready for capacity preallocation, wait for next time");
}
}
if (s_logger.isTraceEnabled())
if (s_logger.isTraceEnabled()) {
s_logger.trace("End of console proxy capacity scan");
}
}
};
}
private boolean checkCapacity(ConsoleProxyLoadInfo proxyCountInfo, ConsoleProxyLoadInfo vmCountInfo) {
if (proxyCountInfo.getCount() * _capacityPerProxy - vmCountInfo.getCount() <= _standbyCapacity)
if (proxyCountInfo.getCount() * _capacityPerProxy - vmCountInfo.getCount() <= _standbyCapacity) {
return false;
}
return true;
}
private void allocCapacity(long dataCenterId) {
if (s_logger.isTraceEnabled())
if (s_logger.isTraceEnabled()) {
s_logger.trace("Allocate console proxy standby capacity for data center : " + dataCenterId);
}
boolean proxyFromStoppedPool = false;
ConsoleProxyVO proxy = assignProxyFromStoppedPool(dataCenterId);
if (proxy == null) {
if (s_logger.isInfoEnabled())
if (s_logger.isInfoEnabled()) {
s_logger.info("No stopped console proxy is available, need to allocate a new console proxy");
}
if (_allocProxyLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
try {
@ -1640,13 +1703,15 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
_allocProxyLock.unlock();
}
} else {
if (s_logger.isInfoEnabled())
if (s_logger.isInfoEnabled()) {
s_logger.info("Unable to acquire synchronization lock to allocate proxy resource for standby capacity, wait for next scan");
}
return;
}
} else {
if (s_logger.isInfoEnabled())
if (s_logger.isInfoEnabled()) {
s_logger.info("Found a stopped console proxy, bring it up to running pool. proxy vm id : " + proxy.getId());
}
proxyFromStoppedPool = true;
}
@ -1661,8 +1726,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
proxyLock.unlock();
}
} else {
if (s_logger.isInfoEnabled())
if (s_logger.isInfoEnabled()) {
s_logger.info("Unable to acquire synchronization lock to start proxy for standby capacity, proxy vm id : " + proxy.getId());
}
return;
}
} finally {
@ -1670,15 +1736,18 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
}
if (proxy == null) {
if (s_logger.isInfoEnabled())
if (s_logger.isInfoEnabled()) {
s_logger.info("Unable to start console proxy for standby capacity, proxy vm Id : " + proxyVmId
+ ", will recycle it and start a new one");
}
if (proxyFromStoppedPool)
if (proxyFromStoppedPool) {
destroyProxy(proxyVmId, 0);
}
} else {
if (s_logger.isInfoEnabled())
if (s_logger.isInfoEnabled()) {
s_logger.info("Console proxy " + proxy.getHostName() + " is started");
}
}
}
}
@ -1686,8 +1755,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
public boolean isServiceReady(Map<Long, ZoneHostInfo> zoneHostInfoMap) {
for (ZoneHostInfo zoneHostInfo : zoneHostInfoMap.values()) {
if (isZoneHostReady(zoneHostInfo)) {
if (s_logger.isInfoEnabled())
if (s_logger.isInfoEnabled()) {
s_logger.info("Zone " + zoneHostInfo.getDcId() + " is ready to launch");
}
return true;
}
}
@ -1712,12 +1782,14 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
if (l != null && l.size() > 0 && l.get(0).second().intValue() > 0) {
return true;
} else {
if (s_logger.isTraceEnabled())
if (s_logger.isTraceEnabled()) {
s_logger.trace("Primary storage is not ready, wait until it is ready to launch console proxy");
}
}
} else {
if (s_logger.isTraceEnabled())
if (s_logger.isTraceEnabled()) {
s_logger.trace("Zone host is ready, but console proxy template is not ready");
}
}
}
return false;
@ -1725,10 +1797,11 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
private boolean isZoneHostReady(ZoneHostInfo zoneHostInfo) {
int expectedFlags = 0;
if (_use_storage_vm)
if (_use_storage_vm) {
expectedFlags = RunningHostInfoAgregator.ZoneHostInfo.ROUTING_HOST_MASK;
else
} else {
expectedFlags = RunningHostInfoAgregator.ZoneHostInfo.ALL_HOST_MASK;
}
return (zoneHostInfo.getFlags() & expectedFlags) == expectedFlags;
}
@ -1738,9 +1811,11 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
List<RunningHostCountInfo> l = _hostDao.getRunningHostCounts(new Date(cutTime.getTime() - ClusterManager.DEFAULT_HEARTBEAT_THRESHOLD));
RunningHostInfoAgregator aggregator = new RunningHostInfoAgregator();
if (l.size() > 0)
for (RunningHostCountInfo countInfo : l)
if (l.size() > 0) {
for (RunningHostCountInfo countInfo : l) {
aggregator.aggregate(countInfo);
}
}
return aggregator.getZoneHostInfoMap();
}
@ -1752,16 +1827,18 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
@Override
public boolean start() {
if (s_logger.isInfoEnabled())
if (s_logger.isInfoEnabled()) {
s_logger.info("Start console proxy manager");
}
return true;
}
@Override
public boolean stop() {
if (s_logger.isInfoEnabled())
if (s_logger.isInfoEnabled()) {
s_logger.info("Stop console proxy manager");
}
_capacityScanScheduler.shutdownNow();
try {
@ -1846,15 +1923,17 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
if (asyncExecutor != null) {
AsyncJobVO job = asyncExecutor.getJob();
if (s_logger.isInfoEnabled())
if (s_logger.isInfoEnabled()) {
s_logger.info("Stop console proxy " + proxyVmId + ", update async job-" + job.getId());
}
_asyncMgr.updateAsyncJobAttachment(job.getId(), "console_proxy", proxyVmId);
}
ConsoleProxyVO proxy = _consoleProxyDao.findById(proxyVmId);
if (proxy == null) {
if (s_logger.isDebugEnabled())
if (s_logger.isDebugEnabled()) {
s_logger.debug("Stopping console proxy failed: console proxy " + proxyVmId + " no longer exists");
}
return false;
}
/*
@ -1865,8 +1944,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
try {
return stop(proxy, startEventId);
} catch (AgentUnavailableException e) {
if (s_logger.isDebugEnabled())
if (s_logger.isDebugEnabled()) {
s_logger.debug("Stopping console proxy " + proxy.getHostName() + " failed : exception " + e.toString());
}
return false;
}
}
@ -1877,8 +1957,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
if (asyncExecutor != null) {
AsyncJobVO job = asyncExecutor.getJob();
if (s_logger.isInfoEnabled())
if (s_logger.isInfoEnabled()) {
s_logger.info("Reboot console proxy " + proxyVmId + ", update async job-" + job.getId());
}
_asyncMgr.updateAsyncJobAttachment(job.getId(), "console_proxy", proxyVmId);
}
@ -1898,8 +1979,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
final Answer answer = _agentMgr.easySend(proxy.getHostId(), cmd);
if (answer != null) {
if (s_logger.isDebugEnabled())
if (s_logger.isDebugEnabled()) {
s_logger.debug("Successfully reboot console proxy " + proxy.getHostName());
}
SubscriptionMgr.getInstance()
.notifySubscribers(
@ -1918,8 +2000,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
_eventDao.persist(event);
return true;
} else {
if (s_logger.isDebugEnabled())
if (s_logger.isDebugEnabled()) {
s_logger.debug("failed to reboot console proxy : " + proxy.getHostName());
}
final EventVO event = new EventVO();
event.setUserId(User.UID_SYSTEM);
@ -1948,8 +2031,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
if (asyncExecutor != null) {
AsyncJobVO job = asyncExecutor.getJob();
if (s_logger.isInfoEnabled())
if (s_logger.isInfoEnabled()) {
s_logger.info("Destroy console proxy " + vmId + ", update async job-" + job.getId());
}
_asyncMgr.updateAsyncJobAttachment(job.getId(), "console_proxy", vmId);
}
@ -1988,8 +2072,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
txn.start();
// release critical system resources used by the VM before we
// delete them
if (vm.getPublicIpAddress() != null)
if (vm.getPublicIpAddress() != null) {
freePublicIpAddress(vm.getPublicIpAddress(), vm.getDataCenterId(), vm.getPodId());
}
vm.setPublicIpAddress(null);
_consoleProxyDao.remove(vm.getId());
@ -2023,8 +2108,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
ConsoleProxyVO proxy = _consoleProxyDao.findById(vmId);
if (proxy != null) {
if (proxy.getPublicIpAddress() != null)
if (proxy.getPublicIpAddress() != null) {
freePublicIpAddress(proxy.getPublicIpAddress(), proxy.getDataCenterId(), proxy.getPodId());
}
_consoleProxyDao.remove(vmId);
@ -2245,15 +2331,17 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
event.setDescription(description);
event.setStartId(startEventId);
event = _eventDao.persist(event);
if (event != null)
if (event != null) {
return event.getId();
}
return null;
}
@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
if (s_logger.isInfoEnabled())
if (s_logger.isInfoEnabled()) {
s_logger.info("Start configuring console proxy manager : " + name);
}
_name = name;
@ -2274,8 +2362,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
_proxyCmdPort = NumbersUtil.parseInt(value, DEFAULT_PROXY_CMD_PORT);
value = configs.get("consoleproxy.sslEnabled");
if (value != null && value.equalsIgnoreCase("true"))
if (value != null && value.equalsIgnoreCase("true")) {
_sslEnabled = true;
}
value = configs.get("consoleproxy.capacityscan.interval");
_capacityScanInterval = NumbersUtil.parseLong(value, DEFAULT_CAPACITY_SCAN_INTERVAL);
@ -2285,20 +2374,24 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
_proxySessionTimeoutValue = NumbersUtil.parseInt(configs.get("consoleproxy.session.timeout"), DEFAULT_PROXY_SESSION_TIMEOUT);
value = configs.get("consoleproxy.port");
if (value != null)
if (value != null) {
_consoleProxyPort = NumbersUtil.parseInt(value, ConsoleProxyManager.DEFAULT_PROXY_VNC_PORT);
}
value = configs.get("consoleproxy.url.port");
if (value != null)
if (value != null) {
_consoleProxyUrlPort = NumbersUtil.parseInt(value, ConsoleProxyManager.DEFAULT_PROXY_URL_PORT);
}
value = configs.get("system.vm.use.local.storage");
if (value != null && value.equalsIgnoreCase("true"))
if (value != null && value.equalsIgnoreCase("true")) {
_use_lvm = true;
}
value = configs.get("secondary.storage.vm");
if (value != null && value.equalsIgnoreCase("true"))
if (value != null && value.equalsIgnoreCase("true")) {
_use_storage_vm = true;
}
_useNewNetworking = Boolean.parseBoolean(configs.get("use.new.networking"));
@ -2357,7 +2450,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
String multicastRateStr = _configDao.getValue("multicast.throttling.rate");
_networkRate = ((networkRateStr == null) ? 200 : Integer.parseInt(networkRateStr));
_multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr));
_serviceOffering = new ServiceOfferingVO("System Offering For Console Proxy", 1, _proxyRamSize, 256, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized,
_serviceOffering = new ServiceOfferingVO("System Offering For Console Proxy", 1, _proxyRamSize, 256, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual,
useLocalStorage, true, null, true);
_serviceOffering.setUniqueName("Cloud.com-ConsoleProxy");
_serviceOffering = _offeringDao.persistSystemServiceOffering(_serviceOffering);
@ -2368,8 +2461,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
_capacityScanScheduler.scheduleAtFixedRate(getCapacityScanTask(), STARTUP_DELAY, _capacityScanInterval, TimeUnit.MILLISECONDS);
if (s_logger.isInfoEnabled())
if (s_logger.isInfoEnabled()) {
s_logger.info("Console Proxy Manager is configured.");
}
return true;
}

View File

@ -305,7 +305,7 @@ public class Db20to21MigrationUtil {
_configDao.getValue(Config.ConsoleProxyRamSize.key()),
ConsoleProxyManager.DEFAULT_PROXY_VM_RAMSIZE);
ServiceOffering21VO soConsoleProxy = new ServiceOffering21VO("Fake Offering For DomP", 1,
proxyRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized,
proxyRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual,
useLocalStorage, true, null);
soConsoleProxy.setId(seq++);
soConsoleProxy.setUniqueName("Cloud.com-ConsoleProxy");
@ -316,7 +316,7 @@ public class Db20to21MigrationUtil {
_configDao.getValue(Config.SecStorageVmRamSize.key()),
SecondaryStorageVmManager.DEFAULT_SS_VM_RAMSIZE);
ServiceOffering21VO soSecondaryVm = new ServiceOffering21VO("Fake Offering For Secondary Storage VM", 1,
secStorageVmRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, useLocalStorage, true, null);
secStorageVmRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, useLocalStorage, true, null);
soSecondaryVm.setId(seq++);
soSecondaryVm.setUniqueName("Cloud.com-SecondaryStorage");
soSecondaryVm = _serviceOffering21Dao.persist(soSecondaryVm);
@ -324,7 +324,7 @@ public class Db20to21MigrationUtil {
int routerRamSize = NumbersUtil.parseInt(_configDao.getValue("router.ram.size"), 128);
ServiceOffering21VO soDomainRouter = new ServiceOffering21VO("Fake Offering For DomR", 1,
routerRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, useLocalStorage, true, null);
routerRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, useLocalStorage, true, null);
soDomainRouter.setId(seq++);
soDomainRouter.setUniqueName("Cloud.Com-SoftwareRouter");
soDomainRouter = _serviceOffering21Dao.persist(soDomainRouter);

View File

@ -52,7 +52,7 @@ public class ServiceOffering20VO {
@Column(name="guest_ip_type")
@Enumerated(EnumType.STRING)
private NetworkOffering.GuestIpType guestIpType = NetworkOffering.GuestIpType.Virtualized;
private NetworkOffering.GuestIpType guestIpType = NetworkOffering.GuestIpType.Virtual;
@Column(name="use_local_storage")
private boolean useLocalStorage;
@ -67,7 +67,7 @@ public class ServiceOffering20VO {
}
public ServiceOffering20VO(Long id, String name, int cpu, int ramSize, int speed, int rateMbps, int multicastRateMbps, boolean offerHA, String displayText, boolean localStorageRequired) {
this(id, name, cpu, ramSize, speed, rateMbps, multicastRateMbps, offerHA, displayText, NetworkOffering.GuestIpType.Virtualized, localStorageRequired);
this(id, name, cpu, ramSize, speed, rateMbps, multicastRateMbps, offerHA, displayText, NetworkOffering.GuestIpType.Virtual, localStorageRequired);
}
public ServiceOffering20VO(Long id, String name, int cpu, int ramSize, int speed, int rateMbps, int multicastRateMbps, boolean offerHA, String displayText, NetworkOffering.GuestIpType guestIpType, boolean useLocalStorage) {

View File

@ -18,12 +18,9 @@
package com.cloud.network;
import java.util.List;
import java.util.Map;
import com.cloud.dc.DataCenter;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.HostPodVO;
import com.cloud.dc.VlanVO;
import com.cloud.deploy.DeployDestination;
import com.cloud.deploy.DeploymentPlan;
import com.cloud.exception.ConcurrentOperationException;
@ -33,7 +30,6 @@ import com.cloud.exception.InsufficientNetworkCapacityException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.network.router.VirtualRouter;
import com.cloud.network.rules.FirewallRule;
import com.cloud.offerings.NetworkOfferingVO;
import com.cloud.service.ServiceOfferingVO;
@ -45,7 +41,6 @@ import com.cloud.vm.DomainRouterVO;
import com.cloud.vm.Nic;
import com.cloud.vm.NicProfile;
import com.cloud.vm.ReservationContext;
import com.cloud.vm.UserVmVO;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineProfile;
@ -57,70 +52,6 @@ import com.cloud.vm.VirtualMachineProfile;
public interface NetworkManager extends NetworkService {
public static final int DEFAULT_ROUTER_VM_RAMSIZE = 128; // 128M
public static final boolean USE_POD_VLAN = false;
/**
* create the router.
*
* @param accountId account Id the router belongs to.
* @param ipAddress public ip address the router should use to access the internet.
* @param dcId data center id the router should live in.
* @param domain domain name of this network.
* @param offering service offering associated with this request
* @return DomainRouterVO if created. null if not.
*/
DomainRouterVO createRouter(long accountId, String ipAddress, long dcId, String domain, ServiceOfferingVO offering, long startEventId) throws ConcurrentOperationException;
/**
* create a DHCP server/user data server for directly connected VMs
* @param userId the user id of the user creating the router.
* @param accountId the account id of the user creating the router.
* @param dcId data center id the router should live in.
* @param domain domain name of this network.
* @return DomainRouterVO if created. null if not.
*/
DomainRouterVO createDhcpServerForDirectlyAttachedGuests(long userId, long accountId, DataCenterVO dc, HostPodVO pod, Long candidateHost, VlanVO vlan) throws ConcurrentOperationException;
/**
/*
* Send ssh public/private key pair to specified host
* @param hostId
* @param pubKey
* @param prvKey
*/
boolean sendSshKeysToHost(Long hostId, String pubKey, String prvKey);
/**
* save a vm password on the router.
*
* @param routerId the ID of the router to save the password to
* @param vmIpAddress the IP address of the User VM that will use the password
* @param password the password to save to the router
*/
boolean savePasswordToRouter(long routerId, String vmIpAddress, String password);
DomainRouterVO startRouter(long routerId, long eventId);
boolean releaseRouter(long routerId);
boolean destroyRouter(long routerId);
boolean stopRouter(long routerId, long eventId);
boolean getRouterStatistics(long vmId, Map<String, long[]> netStats, Map<String, long[]> diskStats);
boolean rebootRouter(long routerId, long eventId);
/**
* @param hostId get all of the virtual machine routers on a host.
* @return collection of VirtualMachineRouter
*/
List<? extends VirtualRouter> getRouters(long hostId);
/**
* @param routerId id of the router
* @return VirtualMachineRouter
*/
DomainRouterVO getRouter(long routerId);
/**
* Do all of the work of releasing public ip addresses. Note that
* if this method fails, there can be side effects.
@ -173,22 +104,6 @@ public interface NetworkManager extends NetworkService {
*/
public boolean addDhcpEntry(long routerHostId, String routerIp, String vmName, String vmMac, String vmIp);
/**
* Adds a virtual machine into the guest network.
* 1. Starts the domR
* 2. Sets the dhcp Entry on the domR
* 3. Sets the domR
*
* @param vm user vm to add to the guest network
* @param password password for this vm. Can be null
* @return DomainRouterVO if everything is successful. null if not.
*
* @throws ConcurrentOperationException if multiple starts are being attempted.
*/
public DomainRouterVO addVirtualMachineToGuestNetwork(UserVmVO vm, String password, long startEventId) throws ConcurrentOperationException;
String createZoneVlan(DomainRouterVO router);
/**
* Lists IP addresses that belong to VirtualNetwork VLANs
* @param accountId - account that the IP address should belong to

View File

@ -60,7 +60,6 @@ import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.configuration.dao.ResourceLimitDao;
import com.cloud.dc.DataCenter;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.HostPodVO;
import com.cloud.dc.Vlan;
import com.cloud.dc.Vlan.VlanType;
import com.cloud.dc.VlanVO;
@ -103,7 +102,6 @@ import com.cloud.network.dao.VpnUserDao;
import com.cloud.network.element.NetworkElement;
import com.cloud.network.lb.LoadBalancingRulesManager;
import com.cloud.network.router.DomainRouterManager;
import com.cloud.network.router.VirtualRouter;
import com.cloud.network.rules.FirewallRule;
import com.cloud.network.rules.RulesManager;
import com.cloud.offering.NetworkOffering;
@ -149,7 +147,6 @@ import com.cloud.vm.NicProfile;
import com.cloud.vm.NicVO;
import com.cloud.vm.ReservationContext;
import com.cloud.vm.State;
import com.cloud.vm.UserVmVO;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineProfile;
@ -221,14 +218,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
private Map<String, String> _configs;
@Override
public boolean sendSshKeysToHost(Long hostId, String pubKey, String prvKey) {
return _routerMgr.sendSshKeysToHost(hostId, pubKey, prvKey);
}
@Override @DB
public String assignSourceNatIpAddress(Account account, final DataCenterVO dc, final String domain, final ServiceOfferingVO serviceOffering, long startEventId, HypervisorType hyperType) throws ResourceAllocationException {
if (serviceOffering.getGuestIpType() == NetworkOffering.GuestIpType.DirectDual || serviceOffering.getGuestIpType() == NetworkOffering.GuestIpType.DirectSingle) {
if (serviceOffering.getGuestIpType() == NetworkOffering.GuestIpType.Direct) {
return null;
}
final long dcId = dc.getId();
@ -324,7 +316,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
DomainRouterVO router = null;
try {
router = createRouter(account.getId(), sourceNat, dcId, domain, serviceOffering, startEventId);
router = _routerMgr.createRouter(account.getId(), sourceNat, dcId, domain, serviceOffering, startEventId);
} catch (final Exception e) {
s_logger.error("Unable to create router for " + account.getAccountName(), e);
}
@ -469,56 +461,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
}
@Override
@DB
public DomainRouterVO createDhcpServerForDirectlyAttachedGuests(long userId, long accountId, DataCenterVO dc, HostPodVO pod, Long candidateHost, VlanVO guestVlan) throws ConcurrentOperationException{
return _routerMgr.createDhcpServerForDirectlyAttachedGuests(userId, accountId, dc, pod, candidateHost, guestVlan);
}
@Override
public boolean releaseRouter(final long routerId) {
return destroyRouter(routerId);
}
@Override @DB
public DomainRouterVO createRouter(final long accountId, final String publicIpAddress, final long dataCenterId,
String domain, final ServiceOfferingVO offering, long startEventId)
throws ConcurrentOperationException {
return _routerMgr.createRouter(accountId, publicIpAddress, dataCenterId, domain, offering, startEventId);
}
@Override
public boolean destroyRouter(final long routerId) {
return _routerMgr.destroyRouter(routerId);
}
@Override
public boolean savePasswordToRouter(final long routerId, final String vmIpAddress, final String password) {
return _routerMgr.savePasswordToRouter(routerId, vmIpAddress, password);
}
@Override
public DomainRouterVO startRouter(final long routerId, long eventId) {
return _routerMgr.startRouter(routerId, eventId);
}
@Override
public boolean stopRouter(final long routerId, long eventId) {
return _routerMgr.stopRouter(routerId, eventId);
}
@Override
public boolean getRouterStatistics(final long vmId, final Map<String, long[]> netStats, final Map<String, long[]> diskStats) {
return _routerMgr.getRouterStatistics(vmId, netStats, diskStats);
}
@Override
public boolean rebootRouter(final long routerId, long startEventId) {
return _routerMgr.rebootRouter(routerId, startEventId);
}
@Override
public boolean associateIP(final DomainRouterVO router, final List<String> ipAddrList, final boolean add, long vmId) {
Commands cmds = new Commands(OnError.Continue);
@ -927,17 +869,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
// } else {
}
@Override
public DomainRouterVO getRouter(final long routerId) {
return _routerMgr.getRouter(routerId);
}
@Override
public List<? extends VirtualRouter> getRouters(final long hostId) {
return _routerMgr.getRouters(hostId);
}
private Integer getIntegerConfigValue(String configKey, Integer dflt) {
String value = _configs.get(configKey);
if (value != null) {
@ -1002,9 +933,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
storageNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(storageNetworkOffering);
_systemNetworks.put(NetworkOfferingVO.SystemVmStorageNetwork, storageNetworkOffering);
NetworkOfferingVO defaultGuestNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultVirtualizedNetworkOffering, "Virtual Vlan", TrafficType.Guest, GuestIpType.Virtualized, false, false, rateMbps, multicastRateMbps, null, true);
NetworkOfferingVO defaultGuestNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultVirtualizedNetworkOffering, "Virtual Vlan", TrafficType.Guest, GuestIpType.Virtual, false, false, rateMbps, multicastRateMbps, null, true);
defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestNetworkOffering);
NetworkOfferingVO defaultGuestDirectNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultDirectNetworkOffering, "Direct", TrafficType.Guest, GuestIpType.DirectSingle, false, false, rateMbps, multicastRateMbps, null, true);
NetworkOfferingVO defaultGuestDirectNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultDirectNetworkOffering, "Direct", TrafficType.Guest, GuestIpType.Direct, false, false, rateMbps, multicastRateMbps, null, true);
defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestDirectNetworkOffering);
AccountsUsingNetworkConfigurationSearch = _accountDao.createSearchBuilder();
@ -1046,19 +977,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
return (answer != null && answer.getResult());
}
@Override
public DomainRouterVO addVirtualMachineToGuestNetwork(UserVmVO vm, String password, long startEventId) throws ConcurrentOperationException {
return _routerMgr.addVirtualMachineToGuestNetwork(vm, password, startEventId);
}
public void releaseVirtualMachineFromGuestNetwork(UserVmVO vm) {
}
@Override
public String createZoneVlan(DomainRouterVO router) {
return _routerMgr.createZoneVlan(router);
}
@Override
public List<IPAddressVO> listPublicIpAddressesInVirtualNetwork(long accountId, long dcId, Boolean sourceNat) {
SearchBuilder<IPAddressVO> ipAddressSB = _ipAddressDao.createSearchBuilder();
@ -1964,11 +1882,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
//Don't pass owner to create vlan when network offering is of type Direct
if (networkOffering.getGuestIpType() == GuestIpType.DirectSingle) {
if (networkOffering.getGuestIpType() == GuestIpType.Direct) {
owner = null;
}
if (ctxAccount.getType() == Account.ACCOUNT_TYPE_ADMIN && networkOffering.getGuestIpType() != GuestIpType.Virtualized && startIP != null && endIP != null && gateway != null) {
if (ctxAccount.getType() == Account.ACCOUNT_TYPE_ADMIN && networkOffering.getGuestIpType() != GuestIpType.Virtual && startIP != null && endIP != null && gateway != null) {
//Create vlan ip range
Vlan vlan = _configMgr.createVlanAndPublicIpRange(userId, zoneId, podId, startIP, endIP, gateway, vlanNetmask, false, vlanId, owner, networkId);
if (vlan == null) {

View File

@ -77,7 +77,7 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
GuestIpType ipType = offering.getGuestIpType();
BroadcastDomainType broadcastType = null;
Mode mode = null;
if (ipType == GuestIpType.Virtualized) {
if (ipType == GuestIpType.Virtual) {
mode = Mode.Dhcp;
broadcastType = BroadcastDomainType.Vlan;
} else {

View File

@ -64,7 +64,7 @@ public class DomainRouterElement extends AdapterBase implements NetworkElement {
@Override
public boolean implement(Network guestConfig, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException {
if (offering.getGuestIpType() != GuestIpType.Virtualized) {
if (offering.getGuestIpType() != GuestIpType.Virtual) {
s_logger.trace("Not handling guest ip type = " + offering.getGuestIpType());
return false;
}

View File

@ -1517,7 +1517,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
String multicastRateStr = _configDao.getValue("multicast.throttling.rate");
_networkRate = ((networkRateStr == null) ? 200 : Integer.parseInt(networkRateStr));
_multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr));
_offering = new ServiceOfferingVO("System Offering For Software Router", 1, _routerRamSize, 256, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, useLocalStorage, true, null, true);
_offering = new ServiceOfferingVO("System Offering For Software Router", 1, _routerRamSize, 256, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, useLocalStorage, true, null, true);
_offering.setUniqueName("Cloud.Com-SoftwareRouter");
_offering = _serviceOfferingDao.persistSystemServiceOffering(_offering);
_template = _templateDao.findRoutingTemplate();

View File

@ -160,7 +160,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
List<? extends Nic> nics = _networkMgr.getNics(vm);
for (Nic nic : nics) {
Network ntwk = _networkMgr.getNetwork(nic.getNetworkId());
if (ntwk.getGuestType() == GuestIpType.Virtualized) {
if (ntwk.getGuestType() == GuestIpType.Virtual) {
network = ntwk;
dstIp = new Ip(nic.getIp4Address());
break;
@ -257,7 +257,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
List<? extends Nic> nics = _networkMgr.getNics(vm);
for (Nic nic : nics) {
Network ntwk = _networkMgr.getNetwork(nic.getNetworkId());
if (ntwk.getGuestType() == GuestIpType.Virtualized) {
if (ntwk.getGuestType() == GuestIpType.Virtual) {
dstIp = new Ip(nic.getIp4Address());
return new Pair<Network, Ip>(ntwk, dstIp);
}

View File

@ -647,7 +647,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
String multicastRateStr = _configDao.getValue("multicast.throttling.rate");
int networkRate = ((networkRateStr == null) ? 200 : Integer.parseInt(networkRateStr));
int multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr));
NetworkOffering.GuestIpType guestIpType = useVirtualNetwork ? NetworkOffering.GuestIpType.Virtualized : NetworkOffering.GuestIpType.DirectSingle;
NetworkOffering.GuestIpType guestIpType = useVirtualNetwork ? NetworkOffering.GuestIpType.Virtual : NetworkOffering.GuestIpType.Direct;
tags = cleanupTags(tags);
ServiceOfferingVO offering = new ServiceOfferingVO(name, cpu, ramSize, speed, networkRate, multicastRate, offerHA, displayText, guestIpType, localStorageRequired, false, tags, false);

View File

@ -935,7 +935,7 @@ public class ManagementServerImpl implements ManagementServer {
throw rae;
}
} else {
if (offering.getGuestIpType() == NetworkOffering.GuestIpType.Virtualized) {
if (offering.getGuestIpType() == NetworkOffering.GuestIpType.Virtual) {
try {
externalIp = _networkMgr.assignSourceNatIpAddress(account, dc, domain, offering, startEventId, template.getHypervisorType());
} catch (ResourceAllocationException rae) {
@ -1272,12 +1272,12 @@ public class ManagementServerImpl implements ManagementServer {
}
}
if (offering.getGuestIpType() != NetworkOffering.GuestIpType.Virtualized) {
if (offering.getGuestIpType() != NetworkOffering.GuestIpType.Virtual) {
_networkGroupMgr.createDefaultNetworkGroup(accountId);
}
if (networkGroups != null) {
if (offering.getGuestIpType() == NetworkOffering.GuestIpType.Virtualized) {
if (offering.getGuestIpType() == NetworkOffering.GuestIpType.Virtual) {
throw new InvalidParameterValueException("Network groups are not compatible with service offering " + offering.getName());
}
Set<String> nameSet = new HashSet<String>(); //handle duplicate names -- allowed
@ -1289,7 +1289,7 @@ public class ManagementServerImpl implements ManagementServer {
throw new InvalidParameterValueException("Some network group names do not exist");
}
} else { //create a default group if necessary
if (offering.getGuestIpType() != NetworkOffering.GuestIpType.Virtualized && _networkGroupsEnabled) {
if (offering.getGuestIpType() != NetworkOffering.GuestIpType.Virtual && _networkGroupsEnabled) {
networkGroups = new String[]{NetworkGroupManager.DEFAULT_GROUP_NAME};
}
}
@ -2709,7 +2709,7 @@ public class ManagementServerImpl implements ManagementServer {
}
if (useVirtualNetwork != null) {
sc.setJoinParameters("serviceSearch", "guestIpType", NetworkOffering.GuestIpType.Virtualized.toString());
sc.setJoinParameters("serviceSearch", "guestIpType", NetworkOffering.GuestIpType.Virtual.toString());
}
if (keyword != null) {

View File

@ -112,6 +112,7 @@ import com.cloud.host.dao.DetailsDao;
import com.cloud.host.dao.HostDao;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.network.NetworkManager;
import com.cloud.network.router.DomainRouterManager;
import com.cloud.offering.ServiceOffering;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.service.dao.ServiceOfferingDao;
@ -210,6 +211,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
@Inject protected DomainDao _domainDao;
@Inject protected UserDao _userDao;
@Inject protected ClusterDao _clusterDao;
@Inject protected DomainRouterManager _routerMgr;
@Inject(adapter=StoragePoolAllocator.class)
protected Adapters<StoragePoolAllocator> _storagePoolAllocators;
@ -971,8 +973,9 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
VMInstanceVO vmInstance = _vmInstanceDao.findById(vmId);
if (vmInstance != null) {
Long hostId = vmInstance.getHostId();
if (hostId != null && !avoidHosts.contains(vmInstance.getHostId()))
return hostId;
if (hostId != null && !avoidHosts.contains(vmInstance.getHostId())) {
return hostId;
}
}
}
/*Can't find the vm where host resides on(vm is destroyed? or volume is detached from vm), randomly choose a host to send the cmd */
@ -1294,9 +1297,9 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
URI uri = null;
try {
uri = new URI(cmd.getUrl());
if (uri.getScheme() == null)
if (uri.getScheme() == null) {
throw new ServerApiException(BaseCmd.PARAM_ERROR, "scheme is null " + cmd.getUrl() + ", add nfs:// as a prefix");
else if (uri.getScheme().equalsIgnoreCase("nfs")) {
} else if (uri.getScheme().equalsIgnoreCase("nfs")) {
String uriHost = uri.getHost();
String uriPath = uri.getPath();
if (uriHost == null || uriPath == null || uriHost.trim().isEmpty() || uriPath.trim().isEmpty()) {
@ -1525,8 +1528,9 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
StoragePoolVO lock = _storagePoolDao.acquireInLockTable(sPool.getId());
try {
if (lock == null) {
if(s_logger.isDebugEnabled())
s_logger.debug("Failed to acquire lock when deleting StoragePool with ID: " + sPool.getId());
if(s_logger.isDebugEnabled()) {
s_logger.debug("Failed to acquire lock when deleting StoragePool with ID: " + sPool.getId());
}
return false;
}
@ -1752,9 +1756,9 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
throw new InvalidParameterValueException("Invalid size for custom volume creation: " + size+" ,max volume size is:"+_maxVolumeSizeInGb);
}
if(diskOffering.getDiskSize() > 0)
size = (diskOffering.getDiskSize()*1024*1024);//the disk offering size is in MB, which needs to be converted into bytes
else{
if(diskOffering.getDiskSize() > 0) {
size = (diskOffering.getDiskSize()*1024*1024);//the disk offering size is in MB, which needs to be converted into bytes
} else{
if(!validateVolumeSizeRange(size)){
throw new InvalidParameterValueException("Invalid size for custom volume creation: " + size+" ,max volume size is:"+_maxVolumeSizeInGb);
}
@ -2241,8 +2245,9 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
//if they dont, then just stop all vms on this one
List<StoragePoolVO> upPools = _storagePoolDao.listPoolsByStatus(Status.Up);
if(upPools == null || upPools.size() == 0)
restart = false;
if(upPools == null || upPools.size() == 0) {
restart = false;
}
//2. Get a list of all the volumes within this storage pool
List<VolumeVO> allVolumes = _volsDao.findByPoolId(primaryStorageId);
@ -2252,8 +2257,9 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
{
VMInstanceVO vmInstance = _vmInstanceDao.findById(volume.getInstanceId());
if(vmInstance == null)
continue;
if(vmInstance == null) {
continue;
}
//shut down the running vms
if(vmInstance.getState().equals(State.Running) || vmInstance.getState().equals(State.Starting))
@ -2347,7 +2353,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
//create a dummy event
long eventId2 = saveScheduledEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventTypes.EVENT_ROUTER_STOP, "stopping domain router with Id: "+vmInstance.getId());
if(!_networkMgr.stopRouter(vmInstance.getId(), eventId2))
if(!_routerMgr.stopRouter(vmInstance.getId(), eventId2))
{
String errorMsg = "There was an error stopping the domain router id: "+vmInstance.getId()+" ,cannot enable primary storage maintenance";
s_logger.warn(errorMsg);
@ -2359,7 +2365,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
{
//create a dummy event and restart the domr immediately
long eventId = saveScheduledEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventTypes.EVENT_PROXY_START, "starting domr with Id: "+vmInstance.getId());
if(_networkMgr.startRouter(vmInstance.getId(), eventId)==null)
if(_routerMgr.startRouter(vmInstance.getId(), eventId)==null)
{
String errorMsg = "There was an error starting the domain router id: "+vmInstance.getId()+" on another storage pool, cannot enable primary storage maintenance";
s_logger.warn(errorMsg);

View File

@ -147,14 +147,14 @@ public class LocalStoragePoolAllocator extends FirstFitStoragePoolAllocator {
so = _offeringDao.findById(userVm.getServiceOfferingId());
} else if(vm.getType() == VirtualMachine.Type.ConsoleProxy) {
so = new ServiceOfferingVO("Fake Offering For DomP", 1,
_proxyRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, false, true, null, true);
_proxyRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, false, true, null, true);
} else if(vm.getType() == VirtualMachine.Type.SecondaryStorageVm) {
so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, false, true, null, true);
so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, false, true, null, true);
} else if(vm.getType() == VirtualMachine.Type.DomainRouter) {
so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, false, true, null, true);
so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, false, true, null, true);
} else {
assert(false) : "Unsupported system vm type";
so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, false, true, null, false);
so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, false, true, null, false);
}
long usedMemory = calcHostAllocatedCpuMemoryCapacity(vmOnHost, CapacityVO.CAPACITY_TYPE_MEMORY);
@ -244,14 +244,14 @@ public class LocalStoragePoolAllocator extends FirstFitStoragePoolAllocator {
so = _offeringDao.findById(userVm.getServiceOfferingId());
} else if(vm.getType() == VirtualMachine.Type.ConsoleProxy) {
so = new ServiceOfferingVO("Fake Offering For DomP", 1,
_proxyRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, false, true, null, true);
_proxyRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, false, true, null, true);
} else if(vm.getType() == VirtualMachine.Type.SecondaryStorageVm) {
so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, false, true, null, true);
so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, false, true, null, true);
} else if(vm.getType() == VirtualMachine.Type.DomainRouter) {
so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, false, true, null, true);
so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, false, true, null, true);
} else {
assert(false) : "Unsupported system vm type";
so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, false, true, null, false);
so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, false, true, null, false);
}
if(capacityType == CapacityVO.CAPACITY_TYPE_MEMORY) {

View File

@ -294,8 +294,9 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
if (asyncExecutor != null) {
AsyncJobVO job = asyncExecutor.getJob();
if (s_logger.isInfoEnabled())
if (s_logger.isInfoEnabled()) {
s_logger.info("Start secondary storage vm " + secStorageVmId + ", update async job-" + job.getId());
}
_asyncMgr.updateAsyncJobAttachment(job.getId(), "sec_storage_vm", secStorageVmId);
}
@ -315,19 +316,21 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
State state = secStorageVm.getState();
if (state == State.Starting /* || state == State.Migrating */) {
if (s_logger.isDebugEnabled())
s_logger.debug("Waiting secondary storage vm to be ready, secondary storage vm id : "
if (s_logger.isDebugEnabled()) {
s_logger.debug("Waiting secondary storage vm to be ready, secondary storage vm id : "
+ secStorageVmId
+ " secStorageVm VM state : "
+ state.toString());
}
if (secStorageVm.getPrivateIpAddress() == null || connect(secStorageVm.getPrivateIpAddress(), _secStorageVmCmdPort) != null) {
if (secStorageVm.getPrivateIpAddress() == null)
s_logger.warn("Retruning a secondary storage vm that is being started but private IP has not been allocated yet, secondary storage vm id : "
if (secStorageVm.getPrivateIpAddress() == null) {
s_logger.warn("Retruning a secondary storage vm that is being started but private IP has not been allocated yet, secondary storage vm id : "
+ secStorageVmId);
else
s_logger.warn("Waiting secondary storage vm to be ready timed out, secondary storage vm id : "
} else {
s_logger.warn("Waiting secondary storage vm to be ready timed out, secondary storage vm id : "
+ secStorageVmId);
}
// TODO, it is very tricky here, if the startup process
// takes too long and it timed out here,
@ -338,9 +341,10 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
}
if (state == State.Running) {
if (s_logger.isTraceEnabled())
s_logger.trace("Secondary storage vm is already started: "
if (s_logger.isTraceEnabled()) {
s_logger.trace("Secondary storage vm is already started: "
+ secStorageVm.getHostName());
}
saveFailedEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventTypes.EVENT_SSVM_START, "Secondary storage vm is already started", startEventId);
return secStorageVm;
}
@ -424,21 +428,23 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
_multicastRate, _secStorageVmCmdPort, secStorageVm,
secStorageVm.getHostName(), "", vols, _mgmt_host, _mgmt_port, _useSSlCopy, guestOSDescription);
if (s_logger.isDebugEnabled())
s_logger.debug("Sending start command for secondary storage vm "
if (s_logger.isDebugEnabled()) {
s_logger.debug("Sending start command for secondary storage vm "
+ secStorageVm.getHostName()
+ " to "
+ routingHost.getName());
}
try {
answer = _agentMgr.send(routingHost.getId(), cmdStart);
s_logger.debug("StartSecStorageVmCommand Answer: " + (answer != null ? answer : "null"));
if (s_logger.isDebugEnabled())
s_logger.debug("Received answer on starting secondary storage vm "
if (s_logger.isDebugEnabled()) {
s_logger.debug("Received answer on starting secondary storage vm "
+ secStorageVm.getHostName()
+ " on "
+ routingHost.getName());
}
if ( answer != null && answer.getResult() ) {
if (s_logger.isDebugEnabled()) {
@ -622,12 +628,14 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
setupCmd.setCopyUserName(TemplateConstants.DEFAULT_HTTP_AUTH_USER);
Answer answer = _agentMgr.easySend(storageHost.getId(), setupCmd);
if (answer != null) {
if (s_logger.isDebugEnabled())
s_logger.debug("Successfully programmed http auth into " + secStorageVm.getHostName());
if (s_logger.isDebugEnabled()) {
s_logger.debug("Successfully programmed http auth into " + secStorageVm.getHostName());
}
return true;
} else {
if (s_logger.isDebugEnabled())
s_logger.debug("failed to program http auth into secondary storage vm : " + secStorageVm.getHostName());
if (s_logger.isDebugEnabled()) {
s_logger.debug("failed to program http auth into secondary storage vm : " + secStorageVm.getHostName());
}
return false;
}
}
@ -653,8 +661,9 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
SecStorageFirewallCfgCommand cpc = new SecStorageFirewallCfgCommand();
for (SecondaryStorageVmVO ssVm: alreadyRunning) {
if (ssVm.getPublicIpAddress() != null) {
if (ssVm.getId() == secStorageVm.getId())
continue;
if (ssVm.getId() == secStorageVm.getId()) {
continue;
}
cpc.addPortConfig(ssVm.getPublicIpAddress(), copyPort , true, TemplateConstants.DEFAULT_TMPLT_COPY_INTF);
if (_useSSlCopy){
cpc.addPortConfig(ssVm.getPublicIpAddress(), "443" , true, TemplateConstants.DEFAULT_TMPLT_COPY_INTF);
@ -663,12 +672,14 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
}
Answer answer = _agentMgr.easySend(storageHost.getId(), cpc);
if (answer != null) {
if (s_logger.isDebugEnabled())
s_logger.debug("Successfully programmed firewall rules into " + secStorageVm.getHostName());
if (s_logger.isDebugEnabled()) {
s_logger.debug("Successfully programmed firewall rules into " + secStorageVm.getHostName());
}
return true;
} else {
if (s_logger.isDebugEnabled())
s_logger.debug("failed to program firewall rules into secondary storage vm : " + secStorageVm.getHostName());
if (s_logger.isDebugEnabled()) {
s_logger.debug("failed to program firewall rules into secondary storage vm : " + secStorageVm.getHostName());
}
return false;
}
@ -679,19 +690,22 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
public SecondaryStorageVmVO startNew(long dataCenterId) {
if (s_logger.isDebugEnabled())
s_logger.debug("Assign secondary storage vm from a newly started instance for request from data center : " + dataCenterId);
if (s_logger.isDebugEnabled()) {
s_logger.debug("Assign secondary storage vm from a newly started instance for request from data center : " + dataCenterId);
}
Map<String, Object> context = _useNewNetworking ? createSecStorageVmInstance2(dataCenterId) : createSecStorageVmInstance(dataCenterId);
long secStorageVmId = (Long) context.get("secStorageVmId");
if (secStorageVmId == 0) {
if (s_logger.isTraceEnabled())
s_logger.trace("Creating secondary storage vm instance failed, data center id : " + dataCenterId);
if (s_logger.isTraceEnabled()) {
s_logger.trace("Creating secondary storage vm instance failed, data center id : " + dataCenterId);
}
// release critical system resource on failure
if (context.get("publicIpAddress") != null)
freePublicIpAddress((String) context.get("publicIpAddress"), dataCenterId, 0);
if (context.get("publicIpAddress") != null) {
freePublicIpAddress((String) context.get("publicIpAddress"), dataCenterId, 0);
}
return null;
}
@ -706,9 +720,10 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
);
return secStorageVm;
} else {
if (s_logger.isDebugEnabled())
s_logger.debug("Unable to allocate secondary storage vm storage, remove the secondary storage vm record from DB, secondary storage vm id: "
if (s_logger.isDebugEnabled()) {
s_logger.debug("Unable to allocate secondary storage vm storage, remove the secondary storage vm record from DB, secondary storage vm id: "
+ secStorageVmId);
}
SubscriptionMgr.getInstance().notifySubscribers(ALERT_SUBJECT, this,
new SecStorageVmAlertEventArgs(
@ -912,8 +927,9 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
if (ipAndVlan == null) {
s_logger.debug("Unable to get public ip address (type=Virtual) for secondary storage vm for data center : " + dcId);
ipAndVlan = _vlanDao.assignPodDirectAttachIpAddress(dcId, podId, Account.ACCOUNT_ID_SYSTEM, DomainVO.ROOT_DOMAIN);
if (ipAndVlan == null)
s_logger.debug("Unable to get public ip address (type=DirectAttach) for secondary storage vm for data center : " + dcId);
if (ipAndVlan == null) {
s_logger.debug("Unable to get public ip address (type=DirectAttach) for secondary storage vm for data center : " + dcId);
}
}
if (ipAndVlan != null) {
@ -952,8 +968,9 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
// for now, only one adapter is supported
Enumeration<SecondaryStorageVmAllocator> it = _ssVmAllocators.enumeration();
if (it.hasMoreElements())
return it.nextElement();
if (it.hasMoreElements()) {
return it.nextElement();
}
return null;
}
@ -991,16 +1008,18 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
secStorageVmLock.unlock();
}
} else {
if (s_logger.isInfoEnabled())
s_logger.info("Unable to acquire synchronization lock to start secondary storage vm : " + readysecStorageVm.getHostName());
if (s_logger.isInfoEnabled()) {
s_logger.info("Unable to acquire synchronization lock to start secondary storage vm : " + readysecStorageVm.getHostName());
}
}
} finally {
secStorageVmLock.releaseRef();
}
}
} else {
if (s_logger.isInfoEnabled())
s_logger.info("Unable to acquire synchronization lock to allocate secondary storage vm storage, wait for next turn");
if (s_logger.isInfoEnabled()) {
s_logger.info("Unable to acquire synchronization lock to allocate secondary storage vm storage, wait for next turn");
}
}
} catch (StorageUnavailableException e) {
s_logger.warn("Storage unavailable", e);
@ -1032,22 +1051,26 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
}
private void reallyRun() {
if (s_logger.isTraceEnabled())
s_logger.trace("Begin secondary storage vm capacity scan");
if (s_logger.isTraceEnabled()) {
s_logger.trace("Begin secondary storage vm capacity scan");
}
Map<Long, ZoneHostInfo> zoneHostInfoMap = getZoneHostInfo();
if (isServiceReady(zoneHostInfoMap)) {
if (s_logger.isTraceEnabled())
s_logger.trace("Sec Storage VM Service is ready, check to see if we need to allocate standby capacity");
if (s_logger.isTraceEnabled()) {
s_logger.trace("Sec Storage VM Service is ready, check to see if we need to allocate standby capacity");
}
if (!_capacityScanLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION)) {
if (s_logger.isTraceEnabled())
s_logger.trace("Sec Storage VM Capacity scan lock is used by others, skip and wait for my turn");
if (s_logger.isTraceEnabled()) {
s_logger.trace("Sec Storage VM Capacity scan lock is used by others, skip and wait for my turn");
}
return;
}
if (s_logger.isTraceEnabled())
s_logger.trace("*** Begining secondary storage vm capacity scan... ***");
if (s_logger.isTraceEnabled()) {
s_logger.trace("*** Begining secondary storage vm capacity scan... ***");
}
try {
checkPendingSecStorageVMs();
@ -1069,24 +1092,28 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
}
} else {
if(s_logger.isDebugEnabled())
s_logger.debug("Zone " + dc.getId() + " is not ready to alloc secondary storage vm");
if(s_logger.isDebugEnabled()) {
s_logger.debug("Zone " + dc.getId() + " is not ready to alloc secondary storage vm");
}
}
}
if (s_logger.isTraceEnabled())
s_logger.trace("*** Stop secondary storage vm capacity scan ***");
if (s_logger.isTraceEnabled()) {
s_logger.trace("*** Stop secondary storage vm capacity scan ***");
}
} finally {
_capacityScanLock.unlock();
}
} else {
if (s_logger.isTraceEnabled())
s_logger.trace("Secondary storage vm service is not ready for capacity preallocation, wait for next time");
if (s_logger.isTraceEnabled()) {
s_logger.trace("Secondary storage vm service is not ready for capacity preallocation, wait for next time");
}
}
if (s_logger.isTraceEnabled())
s_logger.trace("End of secondary storage vm capacity scan");
if (s_logger.isTraceEnabled()) {
s_logger.trace("End of secondary storage vm capacity scan");
}
}
};
}
@ -1095,8 +1122,9 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
public SecondaryStorageVmVO assignSecStorageVmFromRunningPool(long dataCenterId) {
if (s_logger.isTraceEnabled())
s_logger.trace("Assign secondary storage vm from running pool for request from data center : " + dataCenterId);
if (s_logger.isTraceEnabled()) {
s_logger.trace("Assign secondary storage vm from running pool for request from data center : " + dataCenterId);
}
SecondaryStorageVmAllocator allocator = getCurrentAllocator();
assert (allocator != null);
@ -1104,16 +1132,18 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
if (runningList != null && runningList.size() > 0) {
if (s_logger.isTraceEnabled()) {
s_logger.trace("Running secondary storage vm pool size : " + runningList.size());
for (SecondaryStorageVmVO secStorageVm : runningList)
s_logger.trace("Running secStorageVm instance : " + secStorageVm.getHostName());
for (SecondaryStorageVmVO secStorageVm : runningList) {
s_logger.trace("Running secStorageVm instance : " + secStorageVm.getHostName());
}
}
Map<Long, Integer> loadInfo = new HashMap<Long, Integer>();
return allocator.allocSecondaryStorageVm(runningList, loadInfo, dataCenterId);
} else {
if (s_logger.isTraceEnabled())
s_logger.trace("Empty running secStorageVm pool for now in data center : " + dataCenterId);
if (s_logger.isTraceEnabled()) {
s_logger.trace("Empty running secStorageVm pool for now in data center : " + dataCenterId);
}
}
return null;
}
@ -1122,21 +1152,24 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
List<SecondaryStorageVmVO> l = _secStorageVmDao.getSecStorageVmListInStates(
dataCenterId, State.Creating, State.Starting, State.Stopped,
State.Migrating);
if (l != null && l.size() > 0)
return l.get(0);
if (l != null && l.size() > 0) {
return l.get(0);
}
return null;
}
private void allocCapacity(long dataCenterId) {
if (s_logger.isTraceEnabled())
s_logger.trace("Allocate secondary storage vm standby capacity for data center : " + dataCenterId);
if (s_logger.isTraceEnabled()) {
s_logger.trace("Allocate secondary storage vm standby capacity for data center : " + dataCenterId);
}
boolean secStorageVmFromStoppedPool = false;
SecondaryStorageVmVO secStorageVm = assignSecStorageVmFromStoppedPool(dataCenterId);
if (secStorageVm == null) {
if (s_logger.isInfoEnabled())
s_logger.info("No stopped secondary storage vm is available, need to allocate a new secondary storage vm");
if (s_logger.isInfoEnabled()) {
s_logger.info("No stopped secondary storage vm is available, need to allocate a new secondary storage vm");
}
if (_allocLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
try {
@ -1145,13 +1178,15 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
_allocLock.unlock();
}
} else {
if (s_logger.isInfoEnabled())
s_logger.info("Unable to acquire synchronization lock to allocate secStorageVm resource for standby capacity, wait for next scan");
if (s_logger.isInfoEnabled()) {
s_logger.info("Unable to acquire synchronization lock to allocate secStorageVm resource for standby capacity, wait for next scan");
}
return;
}
} else {
if (s_logger.isInfoEnabled())
s_logger.info("Found a stopped secondary storage vm, bring it up to running pool. secStorageVm vm id : " + secStorageVm.getId());
if (s_logger.isInfoEnabled()) {
s_logger.info("Found a stopped secondary storage vm, bring it up to running pool. secStorageVm vm id : " + secStorageVm.getId());
}
secStorageVmFromStoppedPool = true;
}
@ -1166,9 +1201,10 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
secStorageVmLock.unlock();
}
} else {
if (s_logger.isInfoEnabled())
s_logger.info("Unable to acquire synchronization lock to start secStorageVm for standby capacity, secStorageVm vm id : "
if (s_logger.isInfoEnabled()) {
s_logger.info("Unable to acquire synchronization lock to start secStorageVm for standby capacity, secStorageVm vm id : "
+ secStorageVm.getId());
}
return;
}
} finally {
@ -1176,15 +1212,18 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
}
if (secStorageVm == null) {
if (s_logger.isInfoEnabled())
s_logger.info("Unable to start secondary storage vm for standby capacity, secStorageVm vm Id : "
if (s_logger.isInfoEnabled()) {
s_logger.info("Unable to start secondary storage vm for standby capacity, secStorageVm vm Id : "
+ secStorageVmId + ", will recycle it and start a new one");
}
if (secStorageVmFromStoppedPool)
destroySecStorageVm(secStorageVmId, 0);
if (secStorageVmFromStoppedPool) {
destroySecStorageVm(secStorageVmId, 0);
}
} else {
if (s_logger.isInfoEnabled())
s_logger.info("Secondary storage vm " + secStorageVm.getHostName() + " is started");
if (s_logger.isInfoEnabled()) {
s_logger.info("Secondary storage vm " + secStorageVm.getHostName() + " is started");
}
}
}
}
@ -1192,8 +1231,9 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
public boolean isServiceReady(Map<Long, ZoneHostInfo> zoneHostInfoMap) {
for (ZoneHostInfo zoneHostInfo : zoneHostInfoMap.values()) {
if ((zoneHostInfo.getFlags() & RunningHostInfoAgregator.ZoneHostInfo.ALL_HOST_MASK) != 0){
if (s_logger.isInfoEnabled())
s_logger.info("Zone " + zoneHostInfo.getDcId() + " is ready to launch");
if (s_logger.isInfoEnabled()) {
s_logger.info("Zone " + zoneHostInfo.getDcId() + " is ready to launch");
}
return true;
}
}
@ -1207,8 +1247,9 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
VMTemplateVO template = _templateDao.findConsoleProxyTemplate();
HostVO secHost = _hostDao.findSecondaryStorageHost(dataCenterId);
if (secHost == null) {
if (s_logger.isDebugEnabled())
s_logger.debug("No secondary storage available in zone " + dataCenterId + ", wait until it is ready to launch secondary storage vm");
if (s_logger.isDebugEnabled()) {
s_logger.debug("No secondary storage available in zone " + dataCenterId + ", wait until it is ready to launch secondary storage vm");
}
return false;
}
@ -1225,12 +1266,14 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
return true;
} else {
if (s_logger.isDebugEnabled())
s_logger.debug("Primary storage is not ready, wait until it is ready to launch secondary storage vm");
if (s_logger.isDebugEnabled()) {
s_logger.debug("Primary storage is not ready, wait until it is ready to launch secondary storage vm");
}
}
} else {
if (s_logger.isTraceEnabled())
s_logger.trace("Zone host is ready, but secondary storage vm template is not ready");
if (s_logger.isTraceEnabled()) {
s_logger.trace("Zone host is ready, but secondary storage vm template is not ready");
}
}
}
return false;
@ -1241,9 +1284,11 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
List<RunningHostCountInfo> l = _hostDao.getRunningHostCounts(new Date(cutTime.getTime() - _clusterMgr.getHeartbeatThreshold()));
RunningHostInfoAgregator aggregator = new RunningHostInfoAgregator();
if (l.size() > 0)
for (RunningHostCountInfo countInfo : l)
aggregator.aggregate(countInfo);
if (l.size() > 0) {
for (RunningHostCountInfo countInfo : l) {
aggregator.aggregate(countInfo);
}
}
return aggregator.getZoneHostInfoMap();
}
@ -1255,16 +1300,18 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
@Override
public boolean start() {
if (s_logger.isInfoEnabled())
s_logger.info("Start secondary storage vm manager");
if (s_logger.isInfoEnabled()) {
s_logger.info("Start secondary storage vm manager");
}
return true;
}
@Override
public boolean stop() {
if (s_logger.isInfoEnabled())
s_logger.info("Stop secondary storage vm manager");
if (s_logger.isInfoEnabled()) {
s_logger.info("Stop secondary storage vm manager");
}
_capacityScanScheduler.shutdownNow();
try {
@ -1280,8 +1327,9 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
@Override
public boolean configure(String name, Map<String, Object> params)
throws ConfigurationException {
if (s_logger.isInfoEnabled())
s_logger.info("Start configuring secondary storage vm manager : " + name);
if (s_logger.isInfoEnabled()) {
s_logger.info("Start configuring secondary storage vm manager : " + name);
}
_name = name;
@ -1393,12 +1441,14 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
}
_userVmDao = locator.getDao(UserVmDao.class);
if (_userVmDao == null)
throw new ConfigurationException("Unable to get " + UserVmDao.class.getName());
if (_userVmDao == null) {
throw new ConfigurationException("Unable to get " + UserVmDao.class.getName());
}
_instanceDao = locator.getDao(VMInstanceDao.class);
if (_instanceDao == null)
throw new ConfigurationException("Unable to get " + VMInstanceDao.class.getName());
if (_instanceDao == null) {
throw new ConfigurationException("Unable to get " + VMInstanceDao.class.getName());
}
_capacityDao = locator.getDao(CapacityDao.class);
if (_capacityDao == null) {
@ -1474,7 +1524,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
String multicastRateStr = _configDao.getValue("multicast.throttling.rate");
_networkRate = ((networkRateStr == null) ? 200 : Integer.parseInt(networkRateStr));
_multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr));
_serviceOffering = new ServiceOfferingVO("System Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 256, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, useLocalStorage, true, null, true);
_serviceOffering = new ServiceOfferingVO("System Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 256, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, useLocalStorage, true, null, true);
_serviceOffering.setUniqueName("Cloud.com-SecondaryStorage");
_serviceOffering = _offeringDao.persistSystemServiceOffering(_serviceOffering);
_template = _templateDao.findConsoleProxyTemplate();
@ -1488,8 +1538,9 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
}
String configValue = _configDao.getValue("system.vm.use.local.storage");
_useLocalStorage = Boolean.parseBoolean(configValue);
if (s_logger.isInfoEnabled())
s_logger.info("Secondary storage vm Manager is configured.");
if (s_logger.isInfoEnabled()) {
s_logger.info("Secondary storage vm Manager is configured.");
}
return true;
}
@ -1567,8 +1618,9 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
if (asyncExecutor != null) {
AsyncJobVO job = asyncExecutor.getJob();
if (s_logger.isInfoEnabled())
if (s_logger.isInfoEnabled()) {
s_logger.info("Stop secondary storage vm " + secStorageVmId + ", update async job-" + job.getId());
}
_asyncMgr.updateAsyncJobAttachment(job.getId(), "secStorageVm", secStorageVmId);
}
long eventId = saveStartedEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventTypes.EVENT_SSVM_STOP, "Stopping secondary storage Vm with Id: "+secStorageVmId, startEventId);
@ -1578,16 +1630,18 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
SecondaryStorageVmVO secStorageVm = _secStorageVmDao.findById(secStorageVmId);
if (secStorageVm == null) {
String msg = "Stopping secondary storage vm failed: secondary storage vm " + secStorageVmId + " no longer exists";
if (s_logger.isDebugEnabled())
s_logger.debug(msg);
if (s_logger.isDebugEnabled()) {
s_logger.debug(msg);
}
saveFailedEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventTypes.EVENT_SSVM_STOP, msg, startEventId);
return false;
}
try {
return stop(secStorageVm, startEventId);
} catch (AgentUnavailableException e) {
if (s_logger.isDebugEnabled())
s_logger.debug("Stopping secondary storage vm " + secStorageVm.getHostName() + " faled : exception " + e.toString());
if (s_logger.isDebugEnabled()) {
s_logger.debug("Stopping secondary storage vm " + secStorageVm.getHostName() + " faled : exception " + e.toString());
}
return false;
}
}
@ -1598,8 +1652,9 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
if (asyncExecutor != null) {
AsyncJobVO job = asyncExecutor.getJob();
if (s_logger.isInfoEnabled())
if (s_logger.isInfoEnabled()) {
s_logger.info("Reboot secondary storage vm " + secStorageVmId + ", update async job-" + job.getId());
}
_asyncMgr.updateAsyncJobAttachment(job.getId(), "secstorage_vm", secStorageVmId);
}
@ -1620,8 +1675,9 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
final Answer answer = _agentMgr.easySend(secStorageVm.getHostId(), cmd);
if (answer != null) {
if (s_logger.isDebugEnabled())
s_logger.debug("Successfully reboot secondary storage vm " + secStorageVm.getHostName());
if (s_logger.isDebugEnabled()) {
s_logger.debug("Successfully reboot secondary storage vm " + secStorageVm.getHostName());
}
SubscriptionMgr.getInstance().notifySubscribers(
ALERT_SUBJECT, this,
@ -1642,8 +1698,9 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
} else {
String msg = "Rebooting Secondary Storage VM failed - " + secStorageVm.getHostName();
saveFailedEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventTypes.EVENT_SSVM_REBOOT, msg, startEventId);
if (s_logger.isDebugEnabled())
s_logger.debug(msg);
if (s_logger.isDebugEnabled()) {
s_logger.debug(msg);
}
return false;
}
} else {
@ -1665,8 +1722,9 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
if (asyncExecutor != null) {
AsyncJobVO job = asyncExecutor.getJob();
if (s_logger.isInfoEnabled())
if (s_logger.isInfoEnabled()) {
s_logger.info("Destroy secondary storage vm " + vmId + ", update async job-" + job.getId());
}
_asyncMgr.updateAsyncJobAttachment(job.getId(), "secstorage_vm", vmId);
}
@ -1710,8 +1768,9 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
txn.start();
// release critical system resources used by the VM before we
// delete them
if (vm.getPublicIpAddress() != null)
freePublicIpAddress(vm.getPublicIpAddress(), vm.getDataCenterId(), vm.getPodId());
if (vm.getPublicIpAddress() != null) {
freePublicIpAddress(vm.getPublicIpAddress(), vm.getDataCenterId(), vm.getPodId());
}
vm.setPublicIpAddress(null);
_secStorageVmDao.remove(vm.getId());
@ -1745,8 +1804,9 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
SecondaryStorageVmVO secStorageVm = _secStorageVmDao.findById(vmId);
if (secStorageVm != null) {
if (secStorageVm.getPublicIpAddress() != null)
freePublicIpAddress(secStorageVm.getPublicIpAddress(), secStorageVm.getDataCenterId(), secStorageVm.getPodId());
if (secStorageVm.getPublicIpAddress() != null) {
freePublicIpAddress(secStorageVm.getPublicIpAddress(), secStorageVm.getDataCenterId(), secStorageVm.getPodId());
}
_secStorageVmDao.remove(vmId);
final EventVO event = new EventVO();
@ -1974,8 +2034,9 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
event.setDescription(description);
event.setStartId(startEventId);
event = _eventDao.persist(event);
if(event != null)
return event.getId();
if(event != null) {
return event.getId();
}
return null;
}

View File

@ -752,7 +752,7 @@ public class DatabaseConfig {
String guestIpType = _currentObjectParams.get("guestIpType");
NetworkOffering.GuestIpType type = null;
if (guestIpType == null) {
type = NetworkOffering.GuestIpType.Virtualized;
type = NetworkOffering.GuestIpType.Virtual;
} else {
type = NetworkOffering.GuestIpType.valueOf(guestIpType);
}

View File

@ -64,6 +64,7 @@ import com.cloud.exception.PermissionDeniedException;
import com.cloud.network.IPAddressVO;
import com.cloud.network.NetworkManager;
import com.cloud.network.dao.IPAddressDao;
import com.cloud.network.router.DomainRouterManager;
import com.cloud.network.security.NetworkGroupManager;
import com.cloud.server.Criteria;
import com.cloud.storage.StorageManager;
@ -120,6 +121,7 @@ public class AccountManagerImpl implements AccountManager, AccountService {
@Inject private StorageManager _storageMgr;
@Inject private TemplateManager _tmpltMgr;
@Inject private ConfigurationManager _configMgr;
@Inject private DomainRouterManager _routerMgr;
private final GlobalLock m_resourceCountLock = GlobalLock.getInternLock("resource.count");
@ -856,7 +858,7 @@ public class AccountManagerImpl implements AccountManager, AccountService {
boolean routersCleanedUp = true;
for (DomainRouterVO router : routers) {
if (!_networkMgr.destroyRouter(router.getId())) {
if (!_routerMgr.destroyRouter(router.getId())) {
s_logger.error("Unable to destroy router: " + router.getId());
routersCleanedUp = false;
}
@ -968,7 +970,7 @@ public class AccountManagerImpl implements AccountManager, AccountService {
List<DomainRouterVO> routers = _routerDao.listBy(accountId);
for (DomainRouterVO router : routers) {
success = (success && _networkMgr.stopRouter(router.getId(), 0));
success = (success && _routerMgr.stopRouter(router.getId(), 0));
}
return success;

View File

@ -138,6 +138,7 @@ import com.cloud.network.dao.IPAddressDao;
import com.cloud.network.dao.LoadBalancerDao;
import com.cloud.network.dao.LoadBalancerVMMapDao;
import com.cloud.network.dao.NetworkDao;
import com.cloud.network.router.DomainRouterManager;
import com.cloud.network.router.VirtualRouter.Role;
import com.cloud.network.security.NetworkGroupManager;
import com.cloud.network.security.NetworkGroupVO;
@ -253,6 +254,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
@Inject InstanceGroupVMMapDao _groupVMMapDao;
@Inject VmManager _itMgr;
@Inject NetworkDao _networkDao;
@Inject DomainRouterManager _routerMgr;
private IpAddrAllocator _IpAllocator;
ScheduledExecutorService _executor = null;
@ -329,7 +331,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
/*TODO: add it for external dhcp mode*/
return true;
}
if (_networkMgr.savePasswordToRouter(vmInstance.getDomainRouterId(), vmInstance.getPrivateIpAddress(), password)) {
if (_routerMgr.savePasswordToRouter(vmInstance.getDomainRouterId(), vmInstance.getPrivateIpAddress(), password)) {
// Need to reboot the virtual machine so that the password gets redownloaded from the DomR, and reset on the VM
if (!rebootVirtualMachine(userId, vmId)) {
if (vmInstance.getState() == State.Stopped) {
@ -720,10 +722,11 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
_volsDao.update(volume.getId(), volume);
}
if(!vm.getHostName().equals(vm.getDisplayName()))
event.setDescription("Volume: " +volume.getName()+ " successfully detached from VM: "+vm.getHostName()+"("+vm.getDisplayName()+")");
else
event.setDescription("Volume: " +volume.getName()+ " successfully detached from VM: "+vm.getHostName());
if(!vm.getHostName().equals(vm.getDisplayName())) {
event.setDescription("Volume: " +volume.getName()+ " successfully detached from VM: "+vm.getHostName()+"("+vm.getDisplayName()+")");
} else {
event.setDescription("Volume: " +volume.getName()+ " successfully detached from VM: "+vm.getHostName());
}
event.setLevel(EventVO.LEVEL_INFO);
_eventDao.persist(event);
@ -962,7 +965,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
String vnet = null;
DomainRouterVO router = null;
if (vm.getDomainRouterId() != null) {
router = _networkMgr.addVirtualMachineToGuestNetwork(vm, password, startEventId);
router = _routerMgr.addVirtualMachineToGuestNetwork(vm, password, startEventId);
if (router == null) {
s_logger.error("Unable to add vm " + vm.getId() + " - " + vm.getHostName());
_itMgr.stateTransitTo(vm, VirtualMachine.Event.OperationFailed, null);
@ -985,7 +988,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
//VM is in a different Pod
if(router.getZoneVlan() == null){
//Create Zone Vlan if not created already
vnet = _networkMgr.createZoneVlan(router);
vnet = _routerMgr.createZoneVlan(router);
if (vnet == null) {
s_logger.error("Vlan creation failed. Unable to add vm " + vm.getId() + " - " + vm.getHostName());
return null;
@ -1549,7 +1552,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
public void releaseGuestIpAddress(UserVmVO userVm) {
ServiceOffering offering = _offeringDao.findById(userVm.getServiceOfferingId());
if (offering.getGuestIpType() != NetworkOffering.GuestIpType.Virtualized) {
if (offering.getGuestIpType() != NetworkOffering.GuestIpType.Virtual) {
IPAddressVO guestIP = (userVm.getGuestIpAddress() == null) ? null : _ipAddressDao.findById(userVm.getGuestIpAddress());
if (guestIP != null && guestIP.getAllocated() != null) {
_ipAddressDao.unassignIpAddress(userVm.getGuestIpAddress());
@ -2799,7 +2802,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
router = rtrs.get(0);
routerId = router.getId();
} else if (rtrs.size() == 0) {
router = _networkMgr.createDhcpServerForDirectlyAttachedGuests(userId, accountId, dc, pod.first(), pod.second(), guestVlan);
router = _routerMgr.createDhcpServerForDirectlyAttachedGuests(userId, accountId, dc, pod.first(), pod.second(), guestVlan);
if (router == null) {
avoids.add(pod.first().getId());
if (s_logger.isDebugEnabled()) {

View File

@ -289,7 +289,7 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements Use
SearchCriteria<UserVmVO> sc = AccountDataCenterVirtualSearch.create();
sc.setParameters("account", accountId);
sc.setParameters("dc", dcId);
sc.setJoinParameters("offeringSearch", "guestIpType", NetworkOffering.GuestIpType.Virtualized);
sc.setJoinParameters("offeringSearch", "guestIpType", NetworkOffering.GuestIpType.Virtual);
return listBy(sc);
}