mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
bug CS-15389: Added prepareStop to Virtualmachine manager and moved network usage collection into prepareStop of VR manager
This commit is contained in:
parent
c894555924
commit
9611a017e9
@ -352,12 +352,12 @@ public class MockVmManagerImpl implements MockVmManager {
|
|||||||
_mockAgentMgr.handleSystemVMStop(vm.getId());
|
_mockAgentMgr.handleSystemVMStop(vm.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
return new StopAnswer(cmd, null, new Integer(0), new Long(100), new Long(200));
|
return new StopAnswer(cmd, null, new Integer(0), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Answer rebootVM(RebootCommand cmd) {
|
public Answer rebootVM(RebootCommand cmd) {
|
||||||
return new RebootAnswer(cmd, "Rebooted "+cmd.getVmName());
|
return new RebootAnswer(cmd, "Rebooted "+cmd.getVmName(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -233,10 +233,10 @@ public class AgentRoutingResource extends AgentStorageResource {
|
|||||||
Answer result = _simMgr.simulate(cmd, hostGuid);
|
Answer result = _simMgr.simulate(cmd, hostGuid);
|
||||||
|
|
||||||
if (!result.getResult()) {
|
if (!result.getResult()) {
|
||||||
return new StopAnswer(cmd, result.getDetails());
|
return new StopAnswer(cmd, result.getDetails(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
answer = new StopAnswer(cmd, null, 0, new Long(100), new Long(200));
|
answer = new StopAnswer(cmd, null, 0, true);
|
||||||
Pair<Long, Long> data = _runningVms.get(vmName);
|
Pair<Long, Long> data = _runningVms.get(vmName);
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
this.usedCpu -= data.first();
|
this.usedCpu -= data.first();
|
||||||
|
|||||||
@ -443,8 +443,6 @@ public class FakeComputingResource extends ServerResourceBase implements
|
|||||||
String vmName = cmd.getVmName();
|
String vmName = cmd.getVmName();
|
||||||
|
|
||||||
Integer port = vmMgr.getVncPort(vmName);
|
Integer port = vmMgr.getVncPort(vmName);
|
||||||
Long bytesReceived = null;
|
|
||||||
Long bytesSent = null;
|
|
||||||
|
|
||||||
State state = null;
|
State state = null;
|
||||||
synchronized (_vms) {
|
synchronized (_vms) {
|
||||||
@ -462,17 +460,16 @@ public class FakeComputingResource extends ServerResourceBase implements
|
|||||||
s_logger.warn("Couldn't stop " + vmName);
|
s_logger.warn("Couldn't stop " + vmName);
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
return new StopAnswer(cmd, result);
|
return new StopAnswer(cmd, result, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
answer = new StopAnswer(cmd, null, port, bytesSent, bytesReceived);
|
answer = new StopAnswer(cmd, null, port, true);
|
||||||
|
|
||||||
String result2 = vmMgr.cleanupVnet(cmd.getVnet());
|
String result2 = vmMgr.cleanupVnet(cmd.getVnet());
|
||||||
if (result2 != null) {
|
if (result2 != null) {
|
||||||
result = result2 + (result != null ? ("\n" + result) : "");
|
result = result2 + (result != null ? ("\n" + result) : "");
|
||||||
answer = new StopAnswer(cmd, result, port, bytesSent,
|
answer = new StopAnswer(cmd, result, port, true);
|
||||||
bytesReceived);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_dhcpSnooper.cleanup(vmName, null);
|
_dhcpSnooper.cleanup(vmName, null);
|
||||||
@ -498,7 +495,7 @@ public class FakeComputingResource extends ServerResourceBase implements
|
|||||||
protected Answer execute(RebootCommand cmd) {
|
protected Answer execute(RebootCommand cmd) {
|
||||||
VmMgr vmMgr = getVmManager();
|
VmMgr vmMgr = getVmManager();
|
||||||
vmMgr.rebootVM(cmd.getVmName());
|
vmMgr.rebootVM(cmd.getVmName());
|
||||||
return new RebootAnswer(cmd, "success", 0L, 0L);
|
return new RebootAnswer(cmd, "success", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Answer execute(PingTestCommand cmd) {
|
private Answer execute(PingTestCommand cmd) {
|
||||||
|
|||||||
@ -2270,8 +2270,6 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Answer execute(RebootCommand cmd) {
|
private Answer execute(RebootCommand cmd) {
|
||||||
Long bytesReceived = null;
|
|
||||||
Long bytesSent = null;
|
|
||||||
|
|
||||||
synchronized (_vms) {
|
synchronized (_vms) {
|
||||||
_vms.put(cmd.getVmName(), State.Starting);
|
_vms.put(cmd.getVmName(), State.Starting);
|
||||||
@ -2288,13 +2286,12 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
|
|
||||||
}
|
}
|
||||||
get_rule_logs_for_vms();
|
get_rule_logs_for_vms();
|
||||||
return new RebootAnswer(cmd, null, bytesSent, bytesReceived,
|
return new RebootAnswer(cmd, null, vncPort);
|
||||||
vncPort);
|
|
||||||
} else {
|
} else {
|
||||||
return new RebootAnswer(cmd, result);
|
return new RebootAnswer(cmd, result, false);
|
||||||
}
|
}
|
||||||
} catch (LibvirtException e) {
|
} catch (LibvirtException e) {
|
||||||
return new RebootAnswer(cmd, e.getMessage());
|
return new RebootAnswer(cmd, e.getMessage(), false);
|
||||||
} finally {
|
} finally {
|
||||||
synchronized (_vms) {
|
synchronized (_vms) {
|
||||||
_vms.put(cmd.getVmName(), State.Running);
|
_vms.put(cmd.getVmName(), State.Running);
|
||||||
@ -2303,16 +2300,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected Answer execute(RebootRouterCommand cmd) {
|
protected Answer execute(RebootRouterCommand cmd) {
|
||||||
Long bytesSent = 0L;
|
|
||||||
Long bytesRcvd = 0L;
|
|
||||||
if (VirtualMachineName.isValidRouterName(cmd.getVmName())) {
|
|
||||||
long[] stats = getNetworkStats(cmd.getPrivateIpAddress());
|
|
||||||
bytesSent = stats[0];
|
|
||||||
bytesRcvd = stats[1];
|
|
||||||
}
|
|
||||||
RebootAnswer answer = (RebootAnswer) execute((RebootCommand) cmd);
|
RebootAnswer answer = (RebootAnswer) execute((RebootCommand) cmd);
|
||||||
answer.setBytesSent(bytesSent);
|
|
||||||
answer.setBytesReceived(bytesRcvd);
|
|
||||||
String result = _virtRouterResource.connect(cmd.getPrivateIpAddress());
|
String result = _virtRouterResource.connect(cmd.getPrivateIpAddress());
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
networkUsage(cmd.getPrivateIpAddress(), "create", null);
|
networkUsage(cmd.getPrivateIpAddress(), "create", null);
|
||||||
@ -2345,9 +2333,6 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
protected Answer execute(StopCommand cmd) {
|
protected Answer execute(StopCommand cmd) {
|
||||||
final String vmName = cmd.getVmName();
|
final String vmName = cmd.getVmName();
|
||||||
|
|
||||||
Long bytesReceived = new Long(0);
|
|
||||||
Long bytesSent = new Long(0);
|
|
||||||
|
|
||||||
State state = null;
|
State state = null;
|
||||||
synchronized (_vms) {
|
synchronized (_vms) {
|
||||||
state = _vms.get(vmName);
|
state = _vms.get(vmName);
|
||||||
@ -2373,9 +2358,9 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||||||
result = result2 + result;
|
result = result2 + result;
|
||||||
}
|
}
|
||||||
state = State.Stopped;
|
state = State.Stopped;
|
||||||
return new StopAnswer(cmd, result, 0, bytesSent, bytesReceived);
|
return new StopAnswer(cmd, result, 0, true);
|
||||||
} catch (LibvirtException e) {
|
} catch (LibvirtException e) {
|
||||||
return new StopAnswer(cmd, e.getMessage());
|
return new StopAnswer(cmd, e.getMessage(), false);
|
||||||
} finally {
|
} finally {
|
||||||
synchronized (_vms) {
|
synchronized (_vms) {
|
||||||
if (state != null) {
|
if (state != null) {
|
||||||
|
|||||||
@ -17,52 +17,25 @@
|
|||||||
package com.cloud.agent.api;
|
package com.cloud.agent.api;
|
||||||
|
|
||||||
public class RebootAnswer extends Answer {
|
public class RebootAnswer extends Answer {
|
||||||
Long bytesSent;
|
|
||||||
Long bytesReceived;
|
|
||||||
Integer vncPort;
|
Integer vncPort;
|
||||||
|
|
||||||
protected RebootAnswer() {
|
protected RebootAnswer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public RebootAnswer(RebootCommand cmd, String details, Long bytesSent, Long bytesReceived, Integer vncport) {
|
public RebootAnswer(RebootCommand cmd, String details, Integer vncport) {
|
||||||
super(cmd, true, details);
|
super(cmd, true, details);
|
||||||
this.bytesReceived = bytesReceived;
|
|
||||||
this.bytesSent = bytesSent;
|
|
||||||
this.vncPort = vncport;
|
this.vncPort = vncport;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RebootAnswer(RebootCommand cmd, String details, Long bytesSent, Long bytesReceived) {
|
public RebootAnswer(RebootCommand cmd, String details, boolean success) {
|
||||||
super(cmd, true, details);
|
super(cmd, success, details);
|
||||||
this.bytesReceived = bytesReceived;
|
|
||||||
this.bytesSent = bytesSent;
|
|
||||||
this.vncPort = null;
|
this.vncPort = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RebootAnswer(RebootCommand cmd, String details) {
|
|
||||||
super(cmd, false, details);
|
|
||||||
bytesSent = null;
|
|
||||||
bytesReceived = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RebootAnswer(RebootCommand cmd, Exception e) {
|
public RebootAnswer(RebootCommand cmd, Exception e) {
|
||||||
super(cmd, e);
|
super(cmd, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBytesReceived(Long bytesReceived) {
|
|
||||||
this.bytesReceived = bytesReceived;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getBytesReceived() {
|
|
||||||
return bytesReceived;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBytesSent(Long bytesSent) {
|
|
||||||
this.bytesSent = bytesSent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getBytesSent() {
|
|
||||||
return bytesSent;
|
|
||||||
}
|
|
||||||
public Integer getVncPort() {
|
public Integer getVncPort() {
|
||||||
return vncPort;
|
return vncPort;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,13 +22,13 @@ public class StopAnswer extends RebootAnswer {
|
|||||||
protected StopAnswer() {
|
protected StopAnswer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public StopAnswer(StopCommand cmd, String details, Integer vncPort, Long bytesSent, Long bytesReceived) {
|
public StopAnswer(StopCommand cmd, String details, Integer vncPort, boolean success) {
|
||||||
super(cmd, details, bytesSent, bytesReceived);
|
super(cmd, details, success);
|
||||||
this.vncPort = vncPort;
|
this.vncPort = vncPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StopAnswer(StopCommand cmd, String details) {
|
public StopAnswer(StopCommand cmd, String details, boolean success) {
|
||||||
super(cmd, details);
|
super(cmd, details, success);
|
||||||
vncPort = null;
|
vncPort = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,6 @@ public class StopCommand extends RebootCommand {
|
|||||||
private boolean isProxy=false;
|
private boolean isProxy=false;
|
||||||
private String urlPort=null;
|
private String urlPort=null;
|
||||||
private String publicConsoleProxyIpAddress=null;
|
private String publicConsoleProxyIpAddress=null;
|
||||||
private String privateRouterIpAddress=null;
|
|
||||||
|
|
||||||
protected StopCommand() {
|
protected StopCommand() {
|
||||||
}
|
}
|
||||||
@ -45,12 +44,6 @@ public class StopCommand extends RebootCommand {
|
|||||||
this.vnet = vnet;
|
this.vnet = vnet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StopCommand(VirtualMachine vm, String vmName, String vnet, String privateRouterIpAddress) {
|
|
||||||
super(vmName);
|
|
||||||
this.vnet = vnet;
|
|
||||||
this.privateRouterIpAddress = privateRouterIpAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
public StopCommand(String vmName) {
|
public StopCommand(String vmName) {
|
||||||
super(vmName);
|
super(vmName);
|
||||||
}
|
}
|
||||||
@ -76,7 +69,4 @@ public class StopCommand extends RebootCommand {
|
|||||||
return this.publicConsoleProxyIpAddress;
|
return this.publicConsoleProxyIpAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPrivateRouterIpAddress() {
|
|
||||||
return privateRouterIpAddress;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -716,7 +716,7 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
|
|||||||
vm = OvmVm.getDetails(_conn, vmName);
|
vm = OvmVm.getDetails(_conn, vmName);
|
||||||
} catch (XmlRpcException e) {
|
} catch (XmlRpcException e) {
|
||||||
s_logger.debug("Unable to get details of vm: " + vmName + ", treating it as stopped", e);
|
s_logger.debug("Unable to get details of vm: " + vmName + ", treating it as stopped", e);
|
||||||
return new StopAnswer(cmd, "success", 0, 0L, 0L);
|
return new StopAnswer(cmd, "success", 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteAllNetworkRulesForVm(vmName);
|
deleteAllNetworkRulesForVm(vmName);
|
||||||
@ -724,10 +724,10 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
|
|||||||
cleanup(vm);
|
cleanup(vm);
|
||||||
|
|
||||||
state = State.Stopped;
|
state = State.Stopped;
|
||||||
return new StopAnswer(cmd, "success", 0, 0L, 0L);
|
return new StopAnswer(cmd, "success", 0, true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
s_logger.debug("Stop " + vmName + "failed", e);
|
s_logger.debug("Stop " + vmName + "failed", e);
|
||||||
return new StopAnswer(cmd, e.getMessage());
|
return new StopAnswer(cmd, e.getMessage(), false);
|
||||||
} finally {
|
} finally {
|
||||||
synchronized(_vms) {
|
synchronized(_vms) {
|
||||||
if (state != null) {
|
if (state != null) {
|
||||||
@ -749,10 +749,10 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
|
|||||||
try {
|
try {
|
||||||
Map<String, String> res = OvmVm.reboot(_conn, vmName);
|
Map<String, String> res = OvmVm.reboot(_conn, vmName);
|
||||||
Integer vncPort = Integer.parseInt(res.get("vncPort"));
|
Integer vncPort = Integer.parseInt(res.get("vncPort"));
|
||||||
return new RebootAnswer(cmd, null, null, null, vncPort);
|
return new RebootAnswer(cmd, null, vncPort);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
s_logger.debug("Reboot " + vmName + " failed", e);
|
s_logger.debug("Reboot " + vmName + " failed", e);
|
||||||
return new RebootAnswer(cmd, e.getMessage());
|
return new RebootAnswer(cmd, e.getMessage(), false);
|
||||||
} finally {
|
} finally {
|
||||||
synchronized(_vms) {
|
synchronized(_vms) {
|
||||||
_vms.put(cmd.getVmName(), State.Running);
|
_vms.put(cmd.getVmName(), State.Running);
|
||||||
|
|||||||
@ -2027,16 +2027,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
vmMo.setCustomFieldValue(CustomFieldConstants.CLOUD_NIC_MASK, "0");
|
vmMo.setCustomFieldValue(CustomFieldConstants.CLOUD_NIC_MASK, "0");
|
||||||
|
|
||||||
if (getVmState(vmMo) != State.Stopped) {
|
if (getVmState(vmMo) != State.Stopped) {
|
||||||
Long bytesSent = 0L;
|
|
||||||
Long bytesRcvd = 0L;
|
|
||||||
|
|
||||||
if (VirtualMachineName.isValidRouterName(cmd.getVmName())) {
|
|
||||||
if (cmd.getPrivateRouterIpAddress() != null) {
|
|
||||||
long[] stats = getNetworkStats(cmd.getPrivateRouterIpAddress());
|
|
||||||
bytesSent = stats[0];
|
|
||||||
bytesRcvd = stats[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// before we stop VM, remove all possible snapshots on the VM to let
|
// before we stop VM, remove all possible snapshots on the VM to let
|
||||||
// disk chain be collapsed
|
// disk chain be collapsed
|
||||||
@ -2044,11 +2034,11 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
vmMo.removeAllSnapshots();
|
vmMo.removeAllSnapshots();
|
||||||
if (vmMo.safePowerOff(_shutdown_waitMs)) {
|
if (vmMo.safePowerOff(_shutdown_waitMs)) {
|
||||||
state = State.Stopped;
|
state = State.Stopped;
|
||||||
return new StopAnswer(cmd, "Stop VM " + cmd.getVmName() + " Succeed", 0, bytesSent, bytesRcvd);
|
return new StopAnswer(cmd, "Stop VM " + cmd.getVmName() + " Succeed", 0, true);
|
||||||
} else {
|
} else {
|
||||||
String msg = "Have problem in powering off VM " + cmd.getVmName() + ", let the process continue";
|
String msg = "Have problem in powering off VM " + cmd.getVmName() + ", let the process continue";
|
||||||
s_logger.warn(msg);
|
s_logger.warn(msg);
|
||||||
return new StopAnswer(cmd, msg, 0, 0L, 0L);
|
return new StopAnswer(cmd, msg, 0, true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
state = State.Stopped;
|
state = State.Stopped;
|
||||||
@ -2056,7 +2046,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
|
|
||||||
String msg = "VM " + cmd.getVmName() + " is already in stopped state";
|
String msg = "VM " + cmd.getVmName() + " is already in stopped state";
|
||||||
s_logger.info(msg);
|
s_logger.info(msg);
|
||||||
return new StopAnswer(cmd, msg, 0, 0L, 0L);
|
return new StopAnswer(cmd, msg, 0, true);
|
||||||
} finally {
|
} finally {
|
||||||
synchronized (_vms) {
|
synchronized (_vms) {
|
||||||
_vms.put(cmd.getVmName(), state);
|
_vms.put(cmd.getVmName(), state);
|
||||||
@ -2069,7 +2059,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
|
|
||||||
String msg = "VM " + cmd.getVmName() + " is no longer in vSphere";
|
String msg = "VM " + cmd.getVmName() + " is no longer in vSphere";
|
||||||
s_logger.info(msg);
|
s_logger.info(msg);
|
||||||
return new StopAnswer(cmd, msg, 0, 0L, 0L);
|
return new StopAnswer(cmd, msg, 0, true);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (e instanceof RemoteException) {
|
if (e instanceof RemoteException) {
|
||||||
@ -2079,7 +2069,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
|
|
||||||
String msg = "StopCommand failed due to " + VmwareHelper.getExceptionMessage(e);
|
String msg = "StopCommand failed due to " + VmwareHelper.getExceptionMessage(e);
|
||||||
s_logger.error(msg);
|
s_logger.error(msg);
|
||||||
return new StopAnswer(cmd, msg);
|
return new StopAnswer(cmd, msg, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2088,17 +2078,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
s_logger.info("Executing resource RebootRouterCommand: " + _gson.toJson(cmd));
|
s_logger.info("Executing resource RebootRouterCommand: " + _gson.toJson(cmd));
|
||||||
}
|
}
|
||||||
|
|
||||||
Long bytesSent = 0L;
|
|
||||||
Long bytesRcvd = 0L;
|
|
||||||
if (VirtualMachineName.isValidRouterName(cmd.getVmName())) {
|
|
||||||
long[] stats = getNetworkStats(cmd.getPrivateIpAddress());
|
|
||||||
bytesSent = stats[0];
|
|
||||||
bytesRcvd = stats[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
RebootAnswer answer = (RebootAnswer) execute((RebootCommand) cmd);
|
RebootAnswer answer = (RebootAnswer) execute((RebootCommand) cmd);
|
||||||
answer.setBytesSent(bytesSent);
|
|
||||||
answer.setBytesReceived(bytesRcvd);
|
|
||||||
|
|
||||||
if (answer.getResult()) {
|
if (answer.getResult()) {
|
||||||
String connectResult = connect(cmd.getVmName(), cmd.getPrivateIpAddress());
|
String connectResult = connect(cmd.getVmName(), cmd.getPrivateIpAddress());
|
||||||
@ -2124,7 +2104,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
if (vmMo != null) {
|
if (vmMo != null) {
|
||||||
try {
|
try {
|
||||||
vmMo.rebootGuest();
|
vmMo.rebootGuest();
|
||||||
return new RebootAnswer(cmd, "reboot succeeded", null, null);
|
return new RebootAnswer(cmd, "reboot succeeded", true);
|
||||||
} catch(ToolsUnavailable e) {
|
} catch(ToolsUnavailable e) {
|
||||||
s_logger.warn("VMware tools is not installed at guest OS, we will perform hard reset for reboot");
|
s_logger.warn("VMware tools is not installed at guest OS, we will perform hard reset for reboot");
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
@ -2133,16 +2113,16 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
|
|
||||||
// continue to try with hard-reset
|
// continue to try with hard-reset
|
||||||
if (vmMo.reset()) {
|
if (vmMo.reset()) {
|
||||||
return new RebootAnswer(cmd, "reboot succeeded", null, null);
|
return new RebootAnswer(cmd, "reboot succeeded", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
String msg = "Reboot failed in vSphere. vm: " + cmd.getVmName();
|
String msg = "Reboot failed in vSphere. vm: " + cmd.getVmName();
|
||||||
s_logger.warn(msg);
|
s_logger.warn(msg);
|
||||||
return new RebootAnswer(cmd, msg);
|
return new RebootAnswer(cmd, msg, false);
|
||||||
} else {
|
} else {
|
||||||
String msg = "Unable to find the VM in vSphere to reboot. vm: " + cmd.getVmName();
|
String msg = "Unable to find the VM in vSphere to reboot. vm: " + cmd.getVmName();
|
||||||
s_logger.warn(msg);
|
s_logger.warn(msg);
|
||||||
return new RebootAnswer(cmd, msg);
|
return new RebootAnswer(cmd, msg, false);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (e instanceof RemoteException) {
|
if (e instanceof RemoteException) {
|
||||||
@ -2152,7 +2132,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
|
|
||||||
String msg = "RebootCommand failed due to " + VmwareHelper.getExceptionMessage(e);
|
String msg = "RebootCommand failed due to " + VmwareHelper.getExceptionMessage(e);
|
||||||
s_logger.error(msg);
|
s_logger.error(msg);
|
||||||
return new RebootAnswer(cmd, msg);
|
return new RebootAnswer(cmd, msg, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -201,7 +201,6 @@ import com.cloud.utils.net.NetUtils;
|
|||||||
import com.cloud.vm.DiskProfile;
|
import com.cloud.vm.DiskProfile;
|
||||||
import com.cloud.vm.VirtualMachine;
|
import com.cloud.vm.VirtualMachine;
|
||||||
import com.cloud.vm.VirtualMachine.State;
|
import com.cloud.vm.VirtualMachine.State;
|
||||||
import com.cloud.vm.VirtualMachineName;
|
|
||||||
import com.trilead.ssh2.SCPClient;
|
import com.trilead.ssh2.SCPClient;
|
||||||
import com.xensource.xenapi.Bond;
|
import com.xensource.xenapi.Bond;
|
||||||
import com.xensource.xenapi.Connection;
|
import com.xensource.xenapi.Connection;
|
||||||
@ -2823,10 +2822,10 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||||||
vms = VM.getByNameLabel(conn, cmd.getVmName());
|
vms = VM.getByNameLabel(conn, cmd.getVmName());
|
||||||
} catch (XenAPIException e0) {
|
} catch (XenAPIException e0) {
|
||||||
s_logger.debug("getByNameLabel failed " + e0.toString());
|
s_logger.debug("getByNameLabel failed " + e0.toString());
|
||||||
return new RebootAnswer(cmd, "getByNameLabel failed " + e0.toString());
|
return new RebootAnswer(cmd, "getByNameLabel failed " + e0.toString(), false);
|
||||||
} catch (Exception e0) {
|
} catch (Exception e0) {
|
||||||
s_logger.debug("getByNameLabel failed " + e0.getMessage());
|
s_logger.debug("getByNameLabel failed " + e0.getMessage());
|
||||||
return new RebootAnswer(cmd, "getByNameLabel failed");
|
return new RebootAnswer(cmd, "getByNameLabel failed", false);
|
||||||
}
|
}
|
||||||
for (VM vm : vms) {
|
for (VM vm : vms) {
|
||||||
try {
|
try {
|
||||||
@ -2834,10 +2833,10 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String msg = e.toString();
|
String msg = e.toString();
|
||||||
s_logger.warn(msg, e);
|
s_logger.warn(msg, e);
|
||||||
return new RebootAnswer(cmd, msg);
|
return new RebootAnswer(cmd, msg, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new RebootAnswer(cmd, "reboot succeeded", null, null);
|
return new RebootAnswer(cmd, "reboot succeeded", true);
|
||||||
} finally {
|
} finally {
|
||||||
synchronized (_cluster.intern()) {
|
synchronized (_cluster.intern()) {
|
||||||
s_vms.put(_cluster, _name, cmd.getVmName(), State.Running);
|
s_vms.put(_cluster, _name, cmd.getVmName(), State.Running);
|
||||||
@ -2848,16 +2847,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||||||
|
|
||||||
protected Answer execute(RebootRouterCommand cmd) {
|
protected Answer execute(RebootRouterCommand cmd) {
|
||||||
Connection conn = getConnection();
|
Connection conn = getConnection();
|
||||||
Long bytesSent = 0L;
|
|
||||||
Long bytesRcvd = 0L;
|
|
||||||
if (VirtualMachineName.isValidRouterName(cmd.getVmName())) {
|
|
||||||
long[] stats = getNetworkStats(conn, cmd.getPrivateIpAddress());
|
|
||||||
bytesSent = stats[0];
|
|
||||||
bytesRcvd = stats[1];
|
|
||||||
}
|
|
||||||
RebootAnswer answer = execute((RebootCommand) cmd);
|
RebootAnswer answer = execute((RebootCommand) cmd);
|
||||||
answer.setBytesSent(bytesSent);
|
|
||||||
answer.setBytesReceived(bytesRcvd);
|
|
||||||
if (answer.getResult()) {
|
if (answer.getResult()) {
|
||||||
String cnct = connect(conn, cmd.getVmName(), cmd.getPrivateIpAddress());
|
String cnct = connect(conn, cmd.getVmName(), cmd.getPrivateIpAddress());
|
||||||
networkUsage(conn, cmd.getPrivateIpAddress(), "create", null);
|
networkUsage(conn, cmd.getPrivateIpAddress(), "create", null);
|
||||||
@ -3320,23 +3310,21 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||||||
s_logger.info("VM does not exist on XenServer" + _host.uuid);
|
s_logger.info("VM does not exist on XenServer" + _host.uuid);
|
||||||
s_vms.remove(_cluster, _name, vmName);
|
s_vms.remove(_cluster, _name, vmName);
|
||||||
}
|
}
|
||||||
return new StopAnswer(cmd, "VM does not exist", 0 , 0L, 0L);
|
return new StopAnswer(cmd, "VM does not exist", 0 , true);
|
||||||
}
|
}
|
||||||
Long bytesSent = 0L;
|
|
||||||
Long bytesRcvd = 0L;
|
|
||||||
for (VM vm : vms) {
|
for (VM vm : vms) {
|
||||||
VM.Record vmr = vm.getRecord(conn);
|
VM.Record vmr = vm.getRecord(conn);
|
||||||
|
|
||||||
if (vmr.isControlDomain) {
|
if (vmr.isControlDomain) {
|
||||||
String msg = "Tring to Shutdown control domain";
|
String msg = "Tring to Shutdown control domain";
|
||||||
s_logger.warn(msg);
|
s_logger.warn(msg);
|
||||||
return new StopAnswer(cmd, msg);
|
return new StopAnswer(cmd, msg, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vmr.powerState == VmPowerState.RUNNING && !isRefNull(vmr.residentOn) && !vmr.residentOn.getUuid(conn).equals(_host.uuid)) {
|
if (vmr.powerState == VmPowerState.RUNNING && !isRefNull(vmr.residentOn) && !vmr.residentOn.getUuid(conn).equals(_host.uuid)) {
|
||||||
String msg = "Stop Vm " + vmName + " failed due to this vm is not running on this host: " + _host.uuid + " but host:" + vmr.residentOn.getUuid(conn);
|
String msg = "Stop Vm " + vmName + " failed due to this vm is not running on this host: " + _host.uuid + " but host:" + vmr.residentOn.getUuid(conn);
|
||||||
s_logger.warn(msg);
|
s_logger.warn(msg);
|
||||||
return new StopAnswer(cmd, msg);
|
return new StopAnswer(cmd, msg, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
State state = s_vms.getState(_cluster, vmName);
|
State state = s_vms.getState(_cluster, vmName);
|
||||||
@ -3350,13 +3338,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||||||
if (vmr.powerState == VmPowerState.RUNNING) {
|
if (vmr.powerState == VmPowerState.RUNNING) {
|
||||||
/* when stop a vm, set affinity to current xenserver */
|
/* when stop a vm, set affinity to current xenserver */
|
||||||
vm.setAffinity(conn, vm.getResidentOn(conn));
|
vm.setAffinity(conn, vm.getResidentOn(conn));
|
||||||
if (VirtualMachineName.isValidRouterName(vmName)) {
|
|
||||||
if (cmd.getPrivateRouterIpAddress() != null) {
|
|
||||||
long[] stats = getNetworkStats(conn, cmd.getPrivateRouterIpAddress());
|
|
||||||
bytesSent = stats[0];
|
|
||||||
bytesRcvd = stats[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (_canBridgeFirewall) {
|
if (_canBridgeFirewall) {
|
||||||
String result = callHostPlugin(conn, "vmops", "destroy_network_rules_for_vm", "vmName", cmd
|
String result = callHostPlugin(conn, "vmops", "destroy_network_rules_for_vm", "vmName", cmd
|
||||||
.getVmName());
|
.getVmName());
|
||||||
@ -3371,7 +3353,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String msg = "Catch exception " + e.getClass().getName() + " when stop VM:" + cmd.getVmName() + " due to " + e.toString();
|
String msg = "Catch exception " + e.getClass().getName() + " when stop VM:" + cmd.getVmName() + " due to " + e.toString();
|
||||||
s_logger.debug(msg);
|
s_logger.debug(msg);
|
||||||
return new StopAnswer(cmd, msg);
|
return new StopAnswer(cmd, msg, false);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -3396,7 +3378,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||||||
disableVlanNetwork(conn, network);
|
disableVlanNetwork(conn, network);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new StopAnswer(cmd, "Stop VM " + vmName + " Succeed", 0, bytesSent, bytesRcvd);
|
return new StopAnswer(cmd, "Stop VM " + vmName + " Succeed", 0, true);
|
||||||
}
|
}
|
||||||
} catch (XenAPIException e) {
|
} catch (XenAPIException e) {
|
||||||
String msg = "VM destroy failed in Stop " + vmName + " Command due to " + e.toString();
|
String msg = "VM destroy failed in Stop " + vmName + " Command due to " + e.toString();
|
||||||
@ -3416,16 +3398,16 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||||||
} catch (XenAPIException e) {
|
} catch (XenAPIException e) {
|
||||||
String msg = "Stop Vm " + vmName + " fail due to " + e.toString();
|
String msg = "Stop Vm " + vmName + " fail due to " + e.toString();
|
||||||
s_logger.warn(msg, e);
|
s_logger.warn(msg, e);
|
||||||
return new StopAnswer(cmd, msg);
|
return new StopAnswer(cmd, msg, false);
|
||||||
} catch (XmlRpcException e) {
|
} catch (XmlRpcException e) {
|
||||||
String msg = "Stop Vm " + vmName + " fail due to " + e.getMessage();
|
String msg = "Stop Vm " + vmName + " fail due to " + e.getMessage();
|
||||||
s_logger.warn(msg, e);
|
s_logger.warn(msg, e);
|
||||||
return new StopAnswer(cmd, msg);
|
return new StopAnswer(cmd, msg, false);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
s_logger.warn("Unable to stop " + vmName + " due to ", e);
|
s_logger.warn("Unable to stop " + vmName + " due to ", e);
|
||||||
return new StopAnswer(cmd, e);
|
return new StopAnswer(cmd, e);
|
||||||
}
|
}
|
||||||
return new StopAnswer(cmd, "Stop VM failed");
|
return new StopAnswer(cmd, "Stop VM failed", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<VDI> getVdis(Connection conn, VM vm) {
|
private List<VDI> getVdis(Connection conn, VM vm) {
|
||||||
|
|||||||
@ -996,4 +996,9 @@ public class ElasticLoadBalancerManagerImpl implements
|
|||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void prepareStop(VirtualMachineProfile<DomainRouterVO> profile) {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -428,10 +428,10 @@ public class BareMetalResourceBase implements ServerResource {
|
|||||||
|
|
||||||
protected RebootAnswer execute(final RebootCommand cmd) {
|
protected RebootAnswer execute(final RebootCommand cmd) {
|
||||||
if (!doScript(_rebootCommand)) {
|
if (!doScript(_rebootCommand)) {
|
||||||
return new RebootAnswer(cmd, "IPMI reboot failed");
|
return new RebootAnswer(cmd, "IPMI reboot failed", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new RebootAnswer(cmd, "reboot succeeded", null, null);
|
return new RebootAnswer(cmd, "reboot succeeded", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected StopAnswer execute(final StopCommand cmd) {
|
protected StopAnswer execute(final StopCommand cmd) {
|
||||||
@ -466,7 +466,7 @@ public class BareMetalResourceBase implements ServerResource {
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return success ? new StopAnswer(cmd, "Success", null, Long.valueOf(0), Long.valueOf(0)) : new StopAnswer(cmd, "IPMI power off failed");
|
return success ? new StopAnswer(cmd, "Success", null, true) : new StopAnswer(cmd, "IPMI power off failed", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected StartAnswer execute(StartCommand cmd) {
|
protected StartAnswer execute(StartCommand cmd) {
|
||||||
|
|||||||
@ -353,4 +353,8 @@ public class AgentBasedConsoleProxyManager implements ConsoleProxyManager, Virtu
|
|||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void prepareStop(VirtualMachineProfile<ConsoleProxyVO> profile) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2014,4 +2014,8 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void prepareStop(VirtualMachineProfile<ConsoleProxyVO> profile) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -506,34 +506,13 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||||||
txn.start();
|
txn.start();
|
||||||
final UserStatisticsVO userStats = _userStatsDao.lock(router.getAccountId(), router.getDataCenterIdToDeployIn(), router.getNetworkId(), null, router.getId(), router.getType().toString());
|
final UserStatisticsVO userStats = _userStatsDao.lock(router.getAccountId(), router.getDataCenterIdToDeployIn(), router.getNetworkId(), null, router.getId(), router.getType().toString());
|
||||||
if (userStats != null) {
|
if (userStats != null) {
|
||||||
final RebootAnswer sa = (RebootAnswer) answer;
|
final long currentBytesRcvd = userStats.getCurrentBytesReceived();
|
||||||
final Long received = sa.getBytesReceived();
|
|
||||||
long netBytes = 0;
|
|
||||||
if (received != null) {
|
|
||||||
if (received.longValue() >= userStats.getCurrentBytesReceived()) {
|
|
||||||
netBytes = received.longValue();
|
|
||||||
} else {
|
|
||||||
netBytes = userStats.getCurrentBytesReceived() + received;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
netBytes = userStats.getCurrentBytesReceived();
|
|
||||||
}
|
|
||||||
userStats.setCurrentBytesReceived(0);
|
userStats.setCurrentBytesReceived(0);
|
||||||
userStats.setNetBytesReceived(userStats.getNetBytesReceived() + netBytes);
|
userStats.setNetBytesReceived(userStats.getNetBytesReceived() + currentBytesRcvd);
|
||||||
|
|
||||||
final Long sent = sa.getBytesSent();
|
final long currentBytesSent = userStats.getCurrentBytesSent();
|
||||||
|
|
||||||
if (sent != null) {
|
|
||||||
if (sent.longValue() >= userStats.getCurrentBytesSent()) {
|
|
||||||
netBytes = sent.longValue();
|
|
||||||
} else {
|
|
||||||
netBytes = userStats.getCurrentBytesSent() + sent;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
netBytes = userStats.getCurrentBytesSent();
|
|
||||||
}
|
|
||||||
userStats.setNetBytesSent(userStats.getNetBytesSent() + netBytes);
|
|
||||||
userStats.setCurrentBytesSent(0);
|
userStats.setCurrentBytesSent(0);
|
||||||
|
userStats.setNetBytesSent(userStats.getNetBytesSent() + currentBytesSent);
|
||||||
_userStatsDao.update(userStats.getId(), userStats);
|
_userStatsDao.update(userStats.getId(), userStats);
|
||||||
s_logger.debug("Successfully updated user statistics as a part of domR " + router + " reboot/stop");
|
s_logger.debug("Successfully updated user statistics as a part of domR " + router + " reboot/stop");
|
||||||
} else {
|
} else {
|
||||||
@ -542,7 +521,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||||||
txn.commit();
|
txn.commit();
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
txn.rollback();
|
txn.rollback();
|
||||||
throw new CloudRuntimeException("Problem getting stats after reboot/stop ", e);
|
throw new CloudRuntimeException("Problem updating stats after reboot/stop ", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2985,4 +2964,99 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void prepareStop(VirtualMachineProfile<DomainRouterVO> profile){
|
||||||
|
//Collect network usage before stopping Vm
|
||||||
|
VMInstanceVO vm = profile.getVirtualMachine();
|
||||||
|
DomainRouterVO router = _routerDao.findById(vm.getId());
|
||||||
|
if(router == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/*String privateIP = router.getPrivateIpAddress();
|
||||||
|
|
||||||
|
if (privateIP != null) {
|
||||||
|
List<Long> routerGuestNtwkIds = _routerDao.getRouterNetworks(router.getId());
|
||||||
|
|
||||||
|
for (Long guestNtwkId : routerGuestNtwkIds) {
|
||||||
|
boolean forVpc = router.getVpcId() != null;
|
||||||
|
Network guestNtwk = _networkMgr.getNetwork(guestNtwkId);
|
||||||
|
Nic guestNic = _nicDao.findByInstanceIdAndNetworkId(guestNtwk.getId(), router.getId());
|
||||||
|
NicProfile guestNicProfile = new NicProfile(guestNic, guestNtwk, guestNic.getBroadcastUri(),
|
||||||
|
guestNic.getIsolationUri(), _networkMgr.getNetworkRate(guestNtwk.getId(), router.getId()),
|
||||||
|
_networkMgr.isSecurityGroupSupportedInNetwork(guestNtwk),
|
||||||
|
_networkMgr.getNetworkTag(router.getHypervisorType(), guestNtwk));
|
||||||
|
final NetworkUsageCommand usageCmd = new NetworkUsageCommand(privateIP, router.getHostName(),
|
||||||
|
forVpc, _itMgr.toNicTO(guestNicProfile, router.getHypervisorType()));
|
||||||
|
UserStatisticsVO previousStats = _statsDao.findBy(router.getAccountId(),
|
||||||
|
router.getDataCenterIdToDeployIn(), guestNtwkId, null, router.getId(), router.getType().toString());
|
||||||
|
NetworkUsageAnswer answer = null;
|
||||||
|
try {
|
||||||
|
answer = (NetworkUsageAnswer) _agentMgr.easySend(router.getHostId(), usageCmd);
|
||||||
|
} catch (Exception e) {
|
||||||
|
s_logger.warn("Error while collecting network stats from router: "+router.getInstanceName()+" from host: "+router.getHostId(), e);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (answer != null) {
|
||||||
|
if (!answer.getResult()) {
|
||||||
|
s_logger.warn("Error while collecting network stats from router: "+router.getInstanceName()+" from host: "+router.getHostId() + "; details: " + answer.getDetails());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Transaction txn = Transaction.open(Transaction.CLOUD_DB);
|
||||||
|
try {
|
||||||
|
if ((answer.getBytesReceived() == 0) && (answer.getBytesSent() == 0)) {
|
||||||
|
s_logger.debug("Recieved and Sent bytes are both 0. Not updating user_statistics");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
txn.start();
|
||||||
|
UserStatisticsVO stats = _statsDao.lock(router.getAccountId(),
|
||||||
|
router.getDataCenterIdToDeployIn(), guestNtwkId, null, router.getId(), router.getType().toString());
|
||||||
|
if (stats == null) {
|
||||||
|
s_logger.warn("unable to find stats for account: " + router.getAccountId());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(previousStats != null
|
||||||
|
&& ((previousStats.getCurrentBytesReceived() != stats.getCurrentBytesReceived())
|
||||||
|
|| (previousStats.getCurrentBytesSent() != stats.getCurrentBytesSent()))){
|
||||||
|
s_logger.debug("Router stats changed from the time NetworkUsageCommand was sent. " +
|
||||||
|
"Ignoring current answer. Router: "+answer.getRouterName()+" Rcvd: " +
|
||||||
|
answer.getBytesReceived()+ "Sent: " +answer.getBytesSent());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stats.getCurrentBytesReceived() > answer.getBytesReceived()) {
|
||||||
|
if (s_logger.isDebugEnabled()) {
|
||||||
|
s_logger.debug("Received # of bytes that's less than the last one. " +
|
||||||
|
"Assuming something went wrong and persisting it. Router: " +
|
||||||
|
answer.getRouterName()+" Reported: " + answer.getBytesReceived()
|
||||||
|
+ " Stored: " + stats.getCurrentBytesReceived());
|
||||||
|
}
|
||||||
|
stats.setNetBytesReceived(stats.getNetBytesReceived() + stats.getCurrentBytesReceived());
|
||||||
|
}
|
||||||
|
stats.setCurrentBytesReceived(answer.getBytesReceived());
|
||||||
|
if (stats.getCurrentBytesSent() > answer.getBytesSent()) {
|
||||||
|
if (s_logger.isDebugEnabled()) {
|
||||||
|
s_logger.debug("Received # of bytes that's less than the last one. " +
|
||||||
|
"Assuming something went wrong and persisting it. Router: " +
|
||||||
|
answer.getRouterName()+" Reported: " + answer.getBytesSent()
|
||||||
|
+ " Stored: " + stats.getCurrentBytesSent());
|
||||||
|
}
|
||||||
|
stats.setNetBytesSent(stats.getNetBytesSent() + stats.getCurrentBytesSent());
|
||||||
|
}
|
||||||
|
stats.setCurrentBytesSent(answer.getBytesSent());
|
||||||
|
_statsDao.update(stats.getId(), stats);
|
||||||
|
txn.commit();
|
||||||
|
} catch (Exception e) {
|
||||||
|
txn.rollback();
|
||||||
|
s_logger.warn("Unable to update user statistics for account: " + router.getAccountId()
|
||||||
|
+ " Rx: " + answer.getBytesReceived() + "; Tx: " + answer.getBytesSent());
|
||||||
|
} finally {
|
||||||
|
txn.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1457,5 +1457,10 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
|||||||
Commands cmds, ReservationContext context) {
|
Commands cmds, ReservationContext context) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void prepareStop(VirtualMachineProfile<SecondaryStorageVmVO> profile) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3630,5 +3630,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||||||
return vm;
|
return vm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void prepareStop(VirtualMachineProfile<UserVmVO> profile) {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -74,4 +74,11 @@ public interface VirtualMachineGuru<T extends VirtualMachine> {
|
|||||||
* @return id if the handler works for this vm and can parse id. null if not.
|
* @return id if the handler works for this vm and can parse id. null if not.
|
||||||
*/
|
*/
|
||||||
Long convertToId(String vmName);
|
Long convertToId(String vmName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare Vm for Stop
|
||||||
|
* @param profile
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
void prepareStop(VirtualMachineProfile<T> profile);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1070,11 +1070,10 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
|
|||||||
if (vm.getState() != State.Stopping) {
|
if (vm.getState() != State.Stopping) {
|
||||||
throw new CloudRuntimeException("We cannot proceed with stop VM " + vm + " since it is not in 'Stopping' state, current state: " + vm.getState());
|
throw new CloudRuntimeException("We cannot proceed with stop VM " + vm + " since it is not in 'Stopping' state, current state: " + vm.getState());
|
||||||
}
|
}
|
||||||
String routerPrivateIp = null;
|
|
||||||
if (vm.getType() == VirtualMachine.Type.DomainRouter) {
|
vmGuru.prepareStop(profile);
|
||||||
routerPrivateIp = vm.getPrivateIpAddress();
|
|
||||||
}
|
StopCommand stop = new StopCommand(vm, vm.getInstanceName(), null);
|
||||||
StopCommand stop = new StopCommand(vm, vm.getInstanceName(), null, routerPrivateIp);
|
|
||||||
boolean stopped = false;
|
boolean stopped = false;
|
||||||
StopAnswer answer = null;
|
StopAnswer answer = null;
|
||||||
try {
|
try {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user