mirror of https://github.com/apache/cloudstack.git
Decouple hypervisor resource from VM state sync
This commit is contained in:
parent
e31e33ccd3
commit
d0a7ca082f
|
|
@ -29,12 +29,12 @@ import com.cloud.agent.api.Answer;
|
|||
import com.cloud.agent.api.CheckNetworkAnswer;
|
||||
import com.cloud.agent.api.CheckNetworkCommand;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.HostVmStateReportEntry;
|
||||
import com.cloud.agent.api.PingCommand;
|
||||
import com.cloud.agent.api.StartupCommand;
|
||||
import com.cloud.agent.api.StartupRoutingCommand;
|
||||
import com.cloud.agent.api.StartupStorageCommand;
|
||||
import com.cloud.agent.api.StoragePoolInfo;
|
||||
import com.cloud.agent.api.StartupRoutingCommand.VmState;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.Host.Type;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
|
|
@ -162,7 +162,7 @@ public class DummyResource implements ServerResource {
|
|||
|
||||
@Override
|
||||
public StartupCommand[] initialize() {
|
||||
Map<String, VmState> changes = null;
|
||||
Map<String, HostVmStateReportEntry> changes = null;
|
||||
|
||||
final List<Object> info = getHostInfo();
|
||||
|
||||
|
|
|
|||
|
|
@ -16,24 +16,24 @@
|
|||
// under the License.
|
||||
package com.cloud.agent.api;
|
||||
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.VirtualMachine.PowerState;
|
||||
|
||||
public class CheckVirtualMachineAnswer extends Answer {
|
||||
|
||||
Integer vncPort;
|
||||
State state;
|
||||
PowerState state;
|
||||
|
||||
|
||||
protected CheckVirtualMachineAnswer() {
|
||||
}
|
||||
|
||||
public CheckVirtualMachineAnswer(CheckVirtualMachineCommand cmd, State state, Integer vncPort, String detail) {
|
||||
public CheckVirtualMachineAnswer(CheckVirtualMachineCommand cmd, PowerState state, Integer vncPort, String detail) {
|
||||
super(cmd, true, detail);
|
||||
this.state = state;
|
||||
this.vncPort = vncPort;
|
||||
}
|
||||
|
||||
public CheckVirtualMachineAnswer(CheckVirtualMachineCommand cmd, State state, Integer vncPort) {
|
||||
public CheckVirtualMachineAnswer(CheckVirtualMachineCommand cmd, PowerState state, Integer vncPort) {
|
||||
this(cmd, state, vncPort, null);
|
||||
}
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ public class CheckVirtualMachineAnswer extends Answer {
|
|||
return vncPort;
|
||||
}
|
||||
|
||||
public State getState() {
|
||||
public PowerState getState() {
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,11 +19,11 @@ package com.cloud.agent.api;
|
|||
import java.util.HashMap;
|
||||
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.VirtualMachine.PowerState;
|
||||
|
||||
public class ClusterSyncAnswer extends Answer {
|
||||
private long _clusterId;
|
||||
private HashMap<String, Pair<String, State>> _newStates;
|
||||
private HashMap<String, Pair<String, PowerState>> _newStates;
|
||||
private boolean _isExecuted=false;
|
||||
|
||||
// this is here because a cron command answer is being sent twice
|
||||
|
|
@ -38,7 +38,7 @@ public class ClusterSyncAnswer extends Answer {
|
|||
}
|
||||
|
||||
|
||||
public ClusterSyncAnswer(long clusterId, HashMap<String, Pair<String, State>> newStates){
|
||||
public ClusterSyncAnswer(long clusterId, HashMap<String, Pair<String, PowerState>> newStates){
|
||||
_clusterId = clusterId;
|
||||
_newStates = newStates;
|
||||
result = true;
|
||||
|
|
@ -48,7 +48,7 @@ public class ClusterSyncAnswer extends Answer {
|
|||
return _clusterId;
|
||||
}
|
||||
|
||||
public HashMap<String, Pair<String, State>> getNewStates() {
|
||||
public HashMap<String, Pair<String, PowerState>> getNewStates() {
|
||||
return _newStates;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.agent.api;
|
||||
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.PowerState;
|
||||
|
||||
public class HostVmStateReportEntry {
|
||||
VirtualMachine.PowerState state;
|
||||
String host;
|
||||
|
||||
public HostVmStateReportEntry() {
|
||||
}
|
||||
|
||||
public HostVmStateReportEntry(PowerState state, String host) {
|
||||
this.state = state;
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public PowerState getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
}
|
||||
|
|
@ -19,22 +19,22 @@ package com.cloud.agent.api;
|
|||
import java.util.Map;
|
||||
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.VirtualMachine.PowerState;
|
||||
|
||||
public class PingRoutingCommand extends PingCommand {
|
||||
Map<String, State> newStates;
|
||||
Map<String, PowerState> newStates;
|
||||
boolean _gatewayAccessible = true;
|
||||
boolean _vnetAccessible = true;
|
||||
|
||||
protected PingRoutingCommand() {
|
||||
}
|
||||
|
||||
public PingRoutingCommand(Host.Type type, long id, Map<String, State> states) {
|
||||
public PingRoutingCommand(Host.Type type, long id, Map<String, PowerState> states) {
|
||||
super(type, id);
|
||||
this.newStates = states;
|
||||
}
|
||||
|
||||
public Map<String, State> getNewStates() {
|
||||
public Map<String, PowerState> getNewStates() {
|
||||
return newStates;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import java.util.Map;
|
|||
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.VirtualMachine.PowerState;
|
||||
|
||||
|
||||
public class PingRoutingWithNwGroupsCommand extends PingRoutingCommand {
|
||||
|
|
@ -31,7 +31,7 @@ public class PingRoutingWithNwGroupsCommand extends PingRoutingCommand {
|
|||
super();
|
||||
}
|
||||
|
||||
public PingRoutingWithNwGroupsCommand(Host.Type type, long id, Map<String, State> states, HashMap<String, Pair<Long, Long>> nwGrpStates) {
|
||||
public PingRoutingWithNwGroupsCommand(Host.Type type, long id, Map<String, PowerState> states, HashMap<String, Pair<Long, Long>> nwGrpStates) {
|
||||
super(type, id, states);
|
||||
newGroupStates = nwGrpStates;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import java.util.Map;
|
|||
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.VirtualMachine.PowerState;
|
||||
|
||||
public class PingRoutingWithOvsCommand extends PingRoutingCommand {
|
||||
List<Pair<String, Long>> states;
|
||||
|
|
@ -31,7 +31,7 @@ public class PingRoutingWithOvsCommand extends PingRoutingCommand {
|
|||
}
|
||||
|
||||
public PingRoutingWithOvsCommand(Host.Type type, long id,
|
||||
Map<String, State> states, List<Pair<String, Long>> ovsStates) {
|
||||
Map<String, PowerState> states, List<Pair<String, Long>> ovsStates) {
|
||||
super(type, id, states);
|
||||
this.states = ovsStates;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,32 +23,16 @@ import com.cloud.host.Host;
|
|||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.Networks.RouterPrivateIpStrategy;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.VirtualMachine.PowerState;
|
||||
|
||||
public class StartupRoutingCommand extends StartupCommand {
|
||||
public static class VmState {
|
||||
State state;
|
||||
String host;
|
||||
public VmState() {
|
||||
}
|
||||
public VmState(State state, String host) {
|
||||
this.state = state;
|
||||
this.host = host;
|
||||
}
|
||||
public State getState() {
|
||||
return state;
|
||||
}
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
}
|
||||
int cpus;
|
||||
long speed;
|
||||
long memory;
|
||||
long dom0MinMemory;
|
||||
boolean poolSync;
|
||||
Map<String, VmState> vms;
|
||||
HashMap<String, Pair<String, State>> _clusterVMStates;
|
||||
Map<String, HostVmStateReportEntry> vms;
|
||||
HashMap<String, Pair<String, PowerState>> _clusterVMStates;
|
||||
String caps;
|
||||
String pool;
|
||||
HypervisorType hypervisorType;
|
||||
|
|
@ -59,7 +43,6 @@ public class StartupRoutingCommand extends StartupCommand {
|
|||
super(Host.Type.Routing);
|
||||
hostDetails = new HashMap<String, String>();
|
||||
getHostDetails().put(RouterPrivateIpStrategy.class.getCanonicalName(), RouterPrivateIpStrategy.DcGlobal.toString());
|
||||
|
||||
}
|
||||
|
||||
public StartupRoutingCommand(int cpus,
|
||||
|
|
@ -69,8 +52,9 @@ public class StartupRoutingCommand extends StartupCommand {
|
|||
String caps,
|
||||
HypervisorType hypervisorType,
|
||||
RouterPrivateIpStrategy privIpStrategy,
|
||||
Map<String, VmState> vms) {
|
||||
this(cpus, speed, memory, dom0MinMemory, caps, hypervisorType, vms);
|
||||
Map<String, HostVmStateReportEntry> vms) {
|
||||
|
||||
this(cpus, speed, memory, dom0MinMemory, caps, hypervisorType, vms);
|
||||
getHostDetails().put(RouterPrivateIpStrategy.class.getCanonicalName(), privIpStrategy.toString());
|
||||
}
|
||||
|
||||
|
|
@ -81,9 +65,10 @@ public class StartupRoutingCommand extends StartupCommand {
|
|||
String caps,
|
||||
HypervisorType hypervisorType,
|
||||
RouterPrivateIpStrategy privIpStrategy) {
|
||||
this(cpus, speed, memory, dom0MinMemory, caps, hypervisorType, new HashMap<String,String>(), new HashMap<String, VmState>());
|
||||
getHostDetails().put(RouterPrivateIpStrategy.class.getCanonicalName(), privIpStrategy.toString());
|
||||
}
|
||||
|
||||
this(cpus, speed, memory, dom0MinMemory, caps, hypervisorType, new HashMap<String,String>(), new HashMap<String, HostVmStateReportEntry>());
|
||||
getHostDetails().put(RouterPrivateIpStrategy.class.getCanonicalName(), privIpStrategy.toString());
|
||||
}
|
||||
|
||||
public StartupRoutingCommand(int cpus,
|
||||
long speed,
|
||||
|
|
@ -92,7 +77,7 @@ getHostDetails().put(RouterPrivateIpStrategy.class.getCanonicalName(), privIpStr
|
|||
final String caps,
|
||||
final HypervisorType hypervisorType,
|
||||
final Map<String, String> hostDetails,
|
||||
Map<String, VmState> vms) {
|
||||
Map<String, HostVmStateReportEntry> vms) {
|
||||
super(Host.Type.Routing);
|
||||
this.cpus = cpus;
|
||||
this.speed = speed;
|
||||
|
|
@ -107,29 +92,29 @@ getHostDetails().put(RouterPrivateIpStrategy.class.getCanonicalName(), privIpStr
|
|||
|
||||
public StartupRoutingCommand(int cpus2, long speed2, long memory2,
|
||||
long dom0MinMemory2, String caps2, HypervisorType hypervisorType2,
|
||||
Map<String, VmState> vms2) {
|
||||
Map<String, HostVmStateReportEntry> vms2) {
|
||||
this(cpus2, speed2, memory2, dom0MinMemory2, caps2, hypervisorType2, new HashMap<String,String>(), vms2);
|
||||
}
|
||||
|
||||
public StartupRoutingCommand(int cpus, long speed, long memory, long dom0MinMemory, final String caps, final HypervisorType hypervisorType, final Map<String, String> hostDetails, Map<String, VmState> vms, String hypervisorVersion) {
|
||||
public StartupRoutingCommand(int cpus, long speed, long memory, long dom0MinMemory, final String caps, final HypervisorType hypervisorType, final Map<String, String> hostDetails, Map<String, HostVmStateReportEntry> vms, String hypervisorVersion) {
|
||||
this(cpus, speed, memory, dom0MinMemory, caps, hypervisorType, hostDetails, vms);
|
||||
this.hypervisorVersion = hypervisorVersion;
|
||||
}
|
||||
|
||||
public void setChanges(Map<String, VmState> vms) {
|
||||
public void setChanges(Map<String, HostVmStateReportEntry> vms) {
|
||||
this.vms = vms;
|
||||
}
|
||||
|
||||
public void setStateChanges(Map<String, State> vms) {
|
||||
public void setStateChanges(Map<String, PowerState> vms) {
|
||||
for( String vm_name : vms.keySet() ) {
|
||||
if( this.vms == null ) {
|
||||
this.vms = new HashMap<String, VmState>();
|
||||
this.vms = new HashMap<String, HostVmStateReportEntry>();
|
||||
}
|
||||
this.vms.put(vm_name, new VmState(vms.get(vm_name), null));
|
||||
this.vms.put(vm_name, new HostVmStateReportEntry(vms.get(vm_name), null));
|
||||
}
|
||||
}
|
||||
|
||||
public void setClusterVMStateChanges(HashMap<String, Pair<String, State>> allStates){
|
||||
public void setClusterVMStateChanges(HashMap<String, Pair<String, PowerState>> allStates){
|
||||
_clusterVMStates = allStates;
|
||||
}
|
||||
|
||||
|
|
@ -153,11 +138,11 @@ getHostDetails().put(RouterPrivateIpStrategy.class.getCanonicalName(), privIpStr
|
|||
return dom0MinMemory;
|
||||
}
|
||||
|
||||
public Map<String, VmState> getVmStates() {
|
||||
public Map<String, HostVmStateReportEntry> getVmStates() {
|
||||
return vms;
|
||||
}
|
||||
|
||||
public HashMap<String, Pair<String, State>> getClusterVMStateChanges() {
|
||||
public HashMap<String, Pair<String, PowerState>> getClusterVMStateChanges() {
|
||||
return _clusterVMStates;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -109,6 +109,7 @@ import com.cloud.storage.template.TemplateInfo;
|
|||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.vm.DiskProfile;
|
||||
import com.cloud.vm.VirtualMachine.PowerState;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
|
|
@ -900,8 +901,8 @@ public class HypervResource extends ServerResourceBase implements ServerResource
|
|||
return hypervHosts;
|
||||
}
|
||||
|
||||
protected HashMap<String, State> sync() {
|
||||
HashMap<String, State> changes = new HashMap<String, State>();
|
||||
protected HashMap<String, PowerState> sync() {
|
||||
HashMap<String, PowerState> changes = new HashMap<String, PowerState>();
|
||||
|
||||
try {
|
||||
synchronized (_vms) {
|
||||
|
|
@ -916,9 +917,9 @@ public class HypervResource extends ServerResourceBase implements ServerResource
|
|||
|
||||
@Override
|
||||
public PingCommand getCurrentStatus(long id) {
|
||||
HashMap<String, State> newStates = sync();
|
||||
HashMap<String, PowerState> newStates = sync();
|
||||
if (newStates == null) {
|
||||
newStates = new HashMap<String, State>();
|
||||
newStates = new HashMap<String, PowerState>();
|
||||
}
|
||||
PingRoutingCommand cmd = new PingRoutingCommand(com.cloud.host.Host.Type.Routing, id, newStates);
|
||||
return cmd;
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ import com.cloud.utils.script.Script2;
|
|||
import com.cloud.utils.script.Script2.ParamType;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.PowerState;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
|
|
@ -305,13 +306,13 @@ public class BareMetalResourceBase extends ManagerBase implements ServerResource
|
|||
}
|
||||
}
|
||||
|
||||
protected Map<String, State> fullSync() {
|
||||
Map<String, State> states = new HashMap<String, State>();
|
||||
protected Map<String, PowerState> fullSync() {
|
||||
Map<String, PowerState> states = new HashMap<String, PowerState>();
|
||||
if (hostId != null) {
|
||||
vmDao = ComponentContext.getComponent(VMInstanceDao.class);
|
||||
final List<? extends VMInstanceVO> vms = vmDao.listByHostId(hostId);
|
||||
for (VMInstanceVO vm : vms) {
|
||||
states.put(vm.getInstanceName(), vm.getState());
|
||||
states.put(vm.getInstanceName(), vm.getState() == State.Running ? PowerState.PowerOn : PowerState.PowerOff);
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
|
@ -402,7 +403,7 @@ public class BareMetalResourceBase extends ManagerBase implements ServerResource
|
|||
}
|
||||
|
||||
protected CheckVirtualMachineAnswer execute(final CheckVirtualMachineCommand cmd) {
|
||||
return new CheckVirtualMachineAnswer(cmd, State.Stopped, null);
|
||||
return new CheckVirtualMachineAnswer(cmd, PowerState.PowerOff, null);
|
||||
}
|
||||
|
||||
protected Answer execute(IpmiBootorResetCommand cmd) {
|
||||
|
|
@ -554,8 +555,8 @@ public class BareMetalResourceBase extends ManagerBase implements ServerResource
|
|||
}
|
||||
}
|
||||
|
||||
protected HashMap<String, State> deltaSync() {
|
||||
final HashMap<String, State> changes = new HashMap<String, State>();
|
||||
protected HashMap<String, PowerState> deltaSync() {
|
||||
final HashMap<String, PowerState> changes = new HashMap<String, PowerState>();
|
||||
/*
|
||||
* Disable sync until we find a way that only tracks status but not does
|
||||
* action
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ import com.cloud.resource.ServerResource;
|
|||
import com.cloud.utils.component.ManagerBase;
|
||||
import com.cloud.utils.script.Script;
|
||||
import com.cloud.utils.ssh.SSHCmdHelper;
|
||||
import com.cloud.vm.VirtualMachine.PowerState;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.trilead.ssh2.SCPClient;
|
||||
|
||||
|
|
@ -142,7 +143,7 @@ public class BaremetalDhcpResourceBase extends ManagerBase implements ServerReso
|
|||
@Override
|
||||
public PingCommand getCurrentStatus(long id) {
|
||||
//TODO: check server
|
||||
return new PingRoutingCommand(getType(), id, new HashMap<String, State>());
|
||||
return new PingRoutingCommand(getType(), id, new HashMap<String, PowerState>());
|
||||
}
|
||||
|
||||
protected ReadyAnswer execute(ReadyCommand cmd) {
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import com.cloud.agent.api.PingRoutingCommand;
|
|||
import com.cloud.agent.api.routing.DhcpEntryCommand;
|
||||
import com.cloud.utils.script.Script;
|
||||
import com.cloud.utils.ssh.SSHCmdHelper;
|
||||
import com.cloud.vm.VirtualMachine.PowerState;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.trilead.ssh2.SCPClient;
|
||||
|
||||
|
|
@ -105,7 +106,7 @@ public class BaremetalDhcpdResource extends BaremetalDhcpResourceBase {
|
|||
return null;
|
||||
} else {
|
||||
SSHCmdHelper.releaseSshConnection(sshConnection);
|
||||
return new PingRoutingCommand(getType(), id, new HashMap<String, State>());
|
||||
return new PingRoutingCommand(getType(), id, new HashMap<String, PowerState>());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import com.cloud.agent.api.PingRoutingCommand;
|
|||
import com.cloud.agent.api.routing.DhcpEntryCommand;
|
||||
import com.cloud.utils.script.Script;
|
||||
import com.cloud.utils.ssh.SSHCmdHelper;
|
||||
import com.cloud.vm.VirtualMachine.PowerState;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.trilead.ssh2.SCPClient;
|
||||
|
||||
|
|
@ -96,7 +97,7 @@ public class BaremetalDnsmasqResource extends BaremetalDhcpResourceBase {
|
|||
return null;
|
||||
} else {
|
||||
SSHCmdHelper.releaseSshConnection(sshConnection);
|
||||
return new PingRoutingCommand(getType(), id, new HashMap<String, State>());
|
||||
return new PingRoutingCommand(getType(), id, new HashMap<String, PowerState>());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import com.cloud.agent.api.routing.VmDataCommand;
|
|||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.script.Script;
|
||||
import com.cloud.utils.ssh.SSHCmdHelper;
|
||||
import com.cloud.vm.VirtualMachine.PowerState;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.trilead.ssh2.SCPClient;
|
||||
|
||||
|
|
@ -106,7 +107,7 @@ public class BaremetalKickStartPxeResource extends BaremetalPxeResourceBase {
|
|||
return null;
|
||||
} else {
|
||||
SSHCmdHelper.releaseSshConnection(sshConnection);
|
||||
return new PingRoutingCommand(getType(), id, new HashMap<String, State>());
|
||||
return new PingRoutingCommand(getType(), id, new HashMap<String, PowerState>());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ import com.cloud.agent.api.baremetal.prepareCreateTemplateCommand;
|
|||
import com.cloud.agent.api.routing.VmDataCommand;
|
||||
import com.cloud.utils.script.Script;
|
||||
import com.cloud.utils.ssh.SSHCmdHelper;
|
||||
import com.cloud.vm.VirtualMachine.PowerState;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.trilead.ssh2.SCPClient;
|
||||
|
||||
|
|
@ -142,7 +143,7 @@ public class BaremetalPingPxeResource extends BaremetalPxeResourceBase {
|
|||
return null;
|
||||
} else {
|
||||
SSHCmdHelper.releaseSshConnection(sshConnection);
|
||||
return new PingRoutingCommand(getType(), id, new HashMap<String, State>());
|
||||
return new PingRoutingCommand(getType(), id, new HashMap<String, PowerState>());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -227,6 +227,7 @@ import com.cloud.utils.script.OutputInterpreter;
|
|||
import com.cloud.utils.script.Script;
|
||||
import com.cloud.vm.DiskProfile;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.PowerState;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.VirtualMachineName;
|
||||
|
||||
|
|
@ -352,21 +353,21 @@ ServerResource {
|
|||
protected int _timeout;
|
||||
protected int _cmdsTimeout;
|
||||
protected int _stopTimeout;
|
||||
protected static HashMap<DomainInfo.DomainState, State> s_statesTable;
|
||||
protected static HashMap<DomainInfo.DomainState, PowerState> s_statesTable;
|
||||
static {
|
||||
s_statesTable = new HashMap<DomainInfo.DomainState, State>();
|
||||
s_statesTable = new HashMap<DomainInfo.DomainState, PowerState>();
|
||||
s_statesTable.put(DomainInfo.DomainState.VIR_DOMAIN_SHUTOFF,
|
||||
State.Stopped);
|
||||
PowerState.PowerOff);
|
||||
s_statesTable.put(DomainInfo.DomainState.VIR_DOMAIN_PAUSED,
|
||||
State.Running);
|
||||
PowerState.PowerOn);
|
||||
s_statesTable.put(DomainInfo.DomainState.VIR_DOMAIN_RUNNING,
|
||||
State.Running);
|
||||
PowerState.PowerOn);
|
||||
s_statesTable.put(DomainInfo.DomainState.VIR_DOMAIN_BLOCKED,
|
||||
State.Running);
|
||||
PowerState.PowerOn);
|
||||
s_statesTable.put(DomainInfo.DomainState.VIR_DOMAIN_NOSTATE,
|
||||
State.Unknown);
|
||||
PowerState.PowerUnknown);
|
||||
s_statesTable.put(DomainInfo.DomainState.VIR_DOMAIN_SHUTDOWN,
|
||||
State.Stopping);
|
||||
PowerState.PowerOff);
|
||||
}
|
||||
|
||||
protected HashMap<String, State> _vms = new HashMap<String, State>(20);
|
||||
|
|
@ -2533,19 +2534,19 @@ ServerResource {
|
|||
return new ReadyAnswer(cmd);
|
||||
}
|
||||
|
||||
protected State convertToState(DomainInfo.DomainState ps) {
|
||||
final State state = s_statesTable.get(ps);
|
||||
return state == null ? State.Unknown : state;
|
||||
protected PowerState convertToState(DomainInfo.DomainState ps) {
|
||||
final PowerState state = s_statesTable.get(ps);
|
||||
return state == null ? PowerState.PowerUnknown : state;
|
||||
}
|
||||
|
||||
protected State getVmState(Connect conn, final String vmName) {
|
||||
protected PowerState getVmState(Connect conn, final String vmName) {
|
||||
int retry = 3;
|
||||
Domain vms = null;
|
||||
while (retry-- > 0) {
|
||||
try {
|
||||
vms = conn.domainLookupByUUID(UUID.nameUUIDFromBytes(vmName
|
||||
.getBytes()));
|
||||
State s = convertToState(vms.getInfo().state);
|
||||
PowerState s = convertToState(vms.getInfo().state);
|
||||
return s;
|
||||
} catch (final LibvirtException e) {
|
||||
s_logger.warn("Can't get vm state " + vmName + e.getMessage()
|
||||
|
|
@ -2560,15 +2561,15 @@ ServerResource {
|
|||
}
|
||||
}
|
||||
}
|
||||
return State.Stopped;
|
||||
return PowerState.PowerOff;
|
||||
}
|
||||
|
||||
private Answer execute(CheckVirtualMachineCommand cmd) {
|
||||
try {
|
||||
Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName());
|
||||
final State state = getVmState(conn, cmd.getVmName());
|
||||
final PowerState state = getVmState(conn, cmd.getVmName());
|
||||
Integer vncPort = null;
|
||||
if (state == State.Running) {
|
||||
if (state == PowerState.PowerOn) {
|
||||
vncPort = getVncPort(conn, cmd.getVmName());
|
||||
|
||||
synchronized (_vms) {
|
||||
|
|
@ -3584,7 +3585,7 @@ ServerResource {
|
|||
|
||||
@Override
|
||||
public PingCommand getCurrentStatus(long id) {
|
||||
final HashMap<String, State> newStates = sync();
|
||||
final HashMap<String, PowerState> newStates = sync();
|
||||
|
||||
if (!_can_bridge_firewall) {
|
||||
return new PingRoutingCommand(com.cloud.host.Host.Type.Routing, id,
|
||||
|
|
@ -3615,7 +3616,7 @@ ServerResource {
|
|||
|
||||
@Override
|
||||
public StartupCommand[] initialize() {
|
||||
Map<String, State> changes = null;
|
||||
Map<String, PowerState> changes = null;
|
||||
|
||||
synchronized (_vms) {
|
||||
_vms.clear();
|
||||
|
|
@ -3663,7 +3664,16 @@ ServerResource {
|
|||
return new StartupCommand[] { cmd };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected HashMap<String, PowerState> sync() {
|
||||
HashMap<String, PowerState> newStates = getAllVms();
|
||||
if(newStates != null)
|
||||
return newStates;
|
||||
|
||||
return new HashMap<String, PowerState>();
|
||||
}
|
||||
|
||||
/*
|
||||
protected HashMap<String, State> sync() {
|
||||
HashMap<String, State> newStates;
|
||||
HashMap<String, State> oldStates = null;
|
||||
|
|
@ -3775,8 +3785,8 @@ ServerResource {
|
|||
|
||||
return changes;
|
||||
}
|
||||
|
||||
protected State getRealPowerState(String vm) {
|
||||
*/
|
||||
protected PowerState getRealPowerState(String vm) {
|
||||
int i = 0;
|
||||
s_logger.trace("Checking on the HALTED State");
|
||||
Domain dm = null;
|
||||
|
|
@ -3809,7 +3819,7 @@ ServerResource {
|
|||
s_logger.trace("Ignoring InterruptedException.", e);
|
||||
}
|
||||
}
|
||||
return State.Stopped;
|
||||
return PowerState.PowerOff;
|
||||
}
|
||||
|
||||
protected List<String> getAllVmNames(Connect conn) {
|
||||
|
|
@ -3852,8 +3862,8 @@ ServerResource {
|
|||
return la;
|
||||
}
|
||||
|
||||
private HashMap<String, State> getAllVms() {
|
||||
final HashMap<String, State> vmStates = new HashMap<String, State>();
|
||||
private HashMap<String, PowerState> getAllVms() {
|
||||
final HashMap<String, PowerState> vmStates = new HashMap<String, PowerState>();
|
||||
Connect conn = null;
|
||||
|
||||
try {
|
||||
|
|
@ -3873,8 +3883,8 @@ ServerResource {
|
|||
return vmStates;
|
||||
}
|
||||
|
||||
private HashMap<String, State> getAllVms(Connect conn) {
|
||||
final HashMap<String, State> vmStates = new HashMap<String, State>();
|
||||
private HashMap<String, PowerState> getAllVms(Connect conn) {
|
||||
final HashMap<String, PowerState> vmStates = new HashMap<String, PowerState>();
|
||||
|
||||
String[] vms = null;
|
||||
int[] ids = null;
|
||||
|
|
@ -3899,7 +3909,7 @@ ServerResource {
|
|||
|
||||
DomainInfo.DomainState ps = dm.getInfo().state;
|
||||
|
||||
final State state = convertToState(ps);
|
||||
final PowerState state = convertToState(ps);
|
||||
|
||||
s_logger.trace("VM " + dm.getName() + ": powerstate = " + ps
|
||||
+ "; vm state=" + state.toString());
|
||||
|
|
@ -3925,7 +3935,7 @@ ServerResource {
|
|||
.getBytes()));
|
||||
|
||||
DomainInfo.DomainState ps = dm.getInfo().state;
|
||||
final State state = convertToState(ps);
|
||||
final PowerState state = convertToState(ps);
|
||||
String vmName = dm.getName();
|
||||
s_logger.trace("VM " + vmName + ": powerstate = " + ps
|
||||
+ "; vm state=" + state.toString());
|
||||
|
|
|
|||
|
|
@ -123,6 +123,7 @@ import com.cloud.utils.script.Script;
|
|||
import com.cloud.utils.ssh.SSHCmdHelper;
|
||||
import com.cloud.vm.DiskProfile;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.PowerState;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.trilead.ssh2.SCPClient;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
|
@ -147,16 +148,16 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
|
|||
static boolean _isHeartBeat = false;
|
||||
List<String> _bridges = null;
|
||||
protected HashMap<String, State> _vms = new HashMap<String, State>(50);
|
||||
static HashMap<String, State> _stateMaps;
|
||||
static HashMap<String, PowerState> _stateMaps;
|
||||
private final Map<String, Pair<Long, Long>> _vmNetworkStats= new ConcurrentHashMap<String, Pair<Long, Long>>();
|
||||
private static String _ovsAgentPath = "/opt/ovs-agent-latest";
|
||||
|
||||
static {
|
||||
_stateMaps = new HashMap<String, State>();
|
||||
_stateMaps.put("RUNNING", State.Running);
|
||||
_stateMaps.put("DOWN", State.Stopped);
|
||||
_stateMaps.put("ERROR", State.Error);
|
||||
_stateMaps.put("SUSPEND", State.Stopped);
|
||||
_stateMaps = new HashMap<String, PowerState>();
|
||||
_stateMaps.put("RUNNING", PowerState.PowerOn);
|
||||
_stateMaps.put("DOWN", PowerState.PowerOff);
|
||||
_stateMaps.put("ERROR", PowerState.PowerUnknown);
|
||||
_stateMaps.put("SUSPEND", PowerState.PowerOn);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -371,7 +372,7 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
|
|||
try {
|
||||
StartupRoutingCommand cmd = new StartupRoutingCommand();
|
||||
fillHostInfo(cmd);
|
||||
Map<String, State> changes = null;
|
||||
Map<String, PowerState> changes = null;
|
||||
synchronized (_vms) {
|
||||
_vms.clear();
|
||||
changes = sync();
|
||||
|
|
@ -389,7 +390,7 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
|
|||
public PingCommand getCurrentStatus(long id) {
|
||||
try {
|
||||
OvmHost.ping(_conn);
|
||||
HashMap<String, State> newStates = sync();
|
||||
HashMap<String, PowerState> newStates = sync();
|
||||
return new PingRoutingCommand(getType(), id, newStates);
|
||||
} catch (XmlRpcException e) {
|
||||
s_logger.debug("Check agent status failed", e);
|
||||
|
|
@ -760,25 +761,37 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
|
|||
}
|
||||
}
|
||||
|
||||
private State toState(String vmName, String s) {
|
||||
State state = _stateMaps.get(s);
|
||||
private PowerState toState(String vmName, String s) {
|
||||
PowerState state = _stateMaps.get(s);
|
||||
if (state == null) {
|
||||
s_logger.debug("Unkown state " + s + " for " + vmName);
|
||||
state = State.Unknown;
|
||||
state = PowerState.PowerUnknown;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
protected HashMap<String, State> getAllVms() throws XmlRpcException {
|
||||
final HashMap<String, State> vmStates = new HashMap<String, State>();
|
||||
protected HashMap<String, PowerState> getAllVms() throws XmlRpcException {
|
||||
final HashMap<String, PowerState> vmStates = new HashMap<String, PowerState>();
|
||||
Map<String, String> vms = OvmHost.getAllVms(_conn);
|
||||
for (final Map.Entry<String, String> entry : vms.entrySet()) {
|
||||
State state = toState(entry.getKey(), entry.getValue());
|
||||
PowerState state = toState(entry.getKey(), entry.getValue());
|
||||
vmStates.put(entry.getKey(), state);
|
||||
}
|
||||
return vmStates;
|
||||
}
|
||||
|
||||
protected HashMap<String, PowerState> sync() {
|
||||
try {
|
||||
HashMap<String, PowerState> newStates = getAllVms();
|
||||
|
||||
if(newStates != null)
|
||||
return newStates;
|
||||
} catch(Exception e) {
|
||||
}
|
||||
return new HashMap<String, PowerState>();
|
||||
}
|
||||
|
||||
/*
|
||||
protected HashMap<String, State> sync() {
|
||||
HashMap<String, State> newStates;
|
||||
HashMap<String, State> oldStates = null;
|
||||
|
|
@ -806,13 +819,6 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
|
|||
s_logger.trace("VM " + vm + ": ovm has state " + newState + " and we have state " + (oldState != null ? oldState.toString() : "null"));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: what is migrating ??? if
|
||||
* (vm.startsWith("migrating")) {
|
||||
* s_logger.debug("Migrating from xen detected. Skipping");
|
||||
* continue; }
|
||||
*/
|
||||
|
||||
if (oldState == null) {
|
||||
_vms.put(vm, newState);
|
||||
s_logger.debug("Detecting a new state but couldn't find a old state so adding it to the changes: "
|
||||
|
|
@ -879,6 +885,7 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
protected GetStorageStatsAnswer execute(final GetStorageStatsCommand cmd) {
|
||||
try {
|
||||
|
|
@ -1001,14 +1008,14 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
|
|||
try {
|
||||
Map<String, String> res = OvmVm.register(_conn, vmName);
|
||||
Integer vncPort = Integer.parseInt(res.get("vncPort"));
|
||||
HashMap<String, State> states = getAllVms();
|
||||
State vmState = states.get(vmName);
|
||||
HashMap<String, PowerState> states = getAllVms();
|
||||
PowerState vmState = states.get(vmName);
|
||||
if (vmState == null) {
|
||||
s_logger.warn("Check state of " + vmName + " return null in CheckVirtualMachineCommand");
|
||||
vmState = State.Stopped;
|
||||
vmState = PowerState.PowerOff;
|
||||
}
|
||||
|
||||
if (vmState == State.Running) {
|
||||
if (vmState == PowerState.PowerOn) {
|
||||
synchronized (_vms) {
|
||||
_vms.put(vmName, State.Running);
|
||||
}
|
||||
|
|
@ -1017,7 +1024,7 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
|
|||
return new CheckVirtualMachineAnswer(cmd, vmState, vncPort);
|
||||
} catch (Exception e) {
|
||||
s_logger.debug("Check migration for " + vmName + " failed", e);
|
||||
return new CheckVirtualMachineAnswer(cmd, State.Stopped, null);
|
||||
return new CheckVirtualMachineAnswer(cmd, PowerState.PowerOff, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ import com.cloud.utils.Ternary;
|
|||
import com.cloud.utils.component.ManagerBase;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.vm.VirtualMachine.PowerState;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
|
@ -334,7 +335,7 @@ public class MockVmManagerImpl extends ManagerBase implements MockVmManager {
|
|||
}
|
||||
|
||||
txn.commit();
|
||||
return new CheckVirtualMachineAnswer(cmd, vm.getState(), vm.getVncPort());
|
||||
return new CheckVirtualMachineAnswer(cmd, vm.getState() == State.Running ? PowerState.PowerOn : PowerState.PowerOff, vm.getVncPort());
|
||||
} catch (Exception ex) {
|
||||
txn.rollback();
|
||||
throw new CloudRuntimeException("unable to fetch vm state " + cmd.getVmName(), ex);
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ import com.cloud.simulator.MockVMVO;
|
|||
import com.cloud.storage.Storage.StorageResourceType;
|
||||
import com.cloud.storage.template.TemplateInfo;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.vm.VirtualMachine.PowerState;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
|
||||
public class AgentRoutingResource extends AgentStorageResource {
|
||||
|
|
@ -112,17 +113,29 @@ public class AgentRoutingResource extends AgentStorageResource {
|
|||
_vms.putAll(_simMgr.getVmStates(hostGuid));
|
||||
}
|
||||
}
|
||||
final HashMap<String, State> newStates = sync();
|
||||
final HashMap<String, PowerState> newStates = sync();
|
||||
HashMap<String, Pair<Long, Long>> nwGrpStates = _simMgr.syncNetworkGroups(hostGuid);
|
||||
return new PingRoutingWithNwGroupsCommand(getType(), id, newStates, nwGrpStates);
|
||||
}
|
||||
|
||||
private HashMap<String, PowerState> getVmStates() {
|
||||
Map<String, State> rawStates = _simMgr.getVmStates(this.hostGuid);
|
||||
if(rawStates != null) {
|
||||
HashMap<String, PowerState> states = new HashMap<String, PowerState>();
|
||||
for(Map.Entry<String, State> entry : rawStates.entrySet()) {
|
||||
states.put(entry.getKey(), entry.getValue() == State.Running ? PowerState.PowerOn : PowerState.PowerOff);
|
||||
}
|
||||
return states;
|
||||
}
|
||||
return new HashMap<String, PowerState>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public StartupCommand[] initialize() {
|
||||
synchronized (_vms) {
|
||||
_vms.clear();
|
||||
}
|
||||
Map<String, State> changes = _simMgr.getVmStates(this.hostGuid);
|
||||
Map<String, PowerState> changes = getVmStates();
|
||||
Map<String, MockVMVO> vmsMaps = _simMgr.getVms(this.hostGuid);
|
||||
totalCpu = agentHost.getCpuCount() * agentHost.getCpuSpeed();
|
||||
totalMem = agentHost.getMemorySize();
|
||||
|
|
@ -251,8 +264,8 @@ public class AgentRoutingResource extends AgentStorageResource {
|
|||
protected CheckVirtualMachineAnswer execute(final CheckVirtualMachineCommand cmd) {
|
||||
final String vmName = cmd.getVmName();
|
||||
CheckVirtualMachineAnswer result = (CheckVirtualMachineAnswer)_simMgr.simulate(cmd, hostGuid);
|
||||
State state = result.getState();
|
||||
if (state == State.Running) {
|
||||
PowerState state = result.getState();
|
||||
if (state == PowerState.PowerOn) {
|
||||
synchronized (_vms) {
|
||||
_vms.put(vmName, State.Running);
|
||||
}
|
||||
|
|
@ -276,6 +289,11 @@ public class AgentRoutingResource extends AgentStorageResource {
|
|||
return info;
|
||||
}
|
||||
|
||||
protected HashMap<String, PowerState> sync() {
|
||||
return this.getVmStates();
|
||||
}
|
||||
|
||||
/*
|
||||
protected HashMap<String, State> sync() {
|
||||
Map<String, State> newStates;
|
||||
Map<String, State> oldStates = null;
|
||||
|
|
@ -342,7 +360,7 @@ public class AgentRoutingResource extends AgentStorageResource {
|
|||
|
||||
return changes;
|
||||
}
|
||||
|
||||
*/
|
||||
private Answer execute(ShutdownCommand cmd) {
|
||||
this.stopped = true;
|
||||
return new Answer(cmd);
|
||||
|
|
|
|||
|
|
@ -223,6 +223,7 @@ import com.cloud.utils.net.NetUtils;
|
|||
import com.cloud.utils.ssh.SshHelper;
|
||||
import com.cloud.vm.DiskProfile;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.PowerState;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.VirtualMachineName;
|
||||
import com.cloud.vm.VmDetailConstants;
|
||||
|
|
@ -314,12 +315,12 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
|
||||
protected volatile long _cmdSequence = 1;
|
||||
|
||||
protected static HashMap<VirtualMachinePowerState, State> s_statesTable;
|
||||
protected static HashMap<VirtualMachinePowerState, PowerState> s_statesTable;
|
||||
static {
|
||||
s_statesTable = new HashMap<VirtualMachinePowerState, State>();
|
||||
s_statesTable.put(VirtualMachinePowerState.POWERED_ON, State.Running);
|
||||
s_statesTable.put(VirtualMachinePowerState.POWERED_OFF, State.Stopped);
|
||||
s_statesTable.put(VirtualMachinePowerState.SUSPENDED, State.Stopped);
|
||||
s_statesTable = new HashMap<VirtualMachinePowerState, PowerState>();
|
||||
s_statesTable.put(VirtualMachinePowerState.POWERED_ON, PowerState.PowerOn);
|
||||
s_statesTable.put(VirtualMachinePowerState.POWERED_OFF, PowerState.PowerOff);
|
||||
s_statesTable.put(VirtualMachinePowerState.SUSPENDED, PowerState.PowerOn);
|
||||
}
|
||||
|
||||
public VmwareResource() {
|
||||
|
|
@ -2082,7 +2083,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(vmName);
|
||||
if (vmMo != null) {
|
||||
s_logger.info("VM " + vmName + " already exists, tear down devices for reconfiguration");
|
||||
if (getVmState(vmMo) != State.Stopped)
|
||||
if (getVmState(vmMo) != PowerState.PowerOff)
|
||||
vmMo.safePowerOff(_shutdown_waitMs);
|
||||
vmMo.tearDownDevices(new Class<?>[] { VirtualDisk.class, VirtualEthernetCard.class });
|
||||
vmMo.ensureScsiDeviceController();
|
||||
|
|
@ -2098,7 +2099,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
|
||||
takeVmFromOtherHyperHost(hyperHost, vmName);
|
||||
|
||||
if (getVmState(vmMo) != State.Stopped)
|
||||
if (getVmState(vmMo) != PowerState.PowerOff)
|
||||
vmMo.safePowerOff(_shutdown_waitMs);
|
||||
vmMo.tearDownDevices(new Class<?>[] { VirtualDisk.class, VirtualEthernetCard.class });
|
||||
vmMo.ensureScsiDeviceController();
|
||||
|
|
@ -2759,7 +2760,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
HashMap<String, VmStatsEntry> vmStatsMap = null;
|
||||
|
||||
try {
|
||||
HashMap<String, State> newStates = getVmStates();
|
||||
HashMap<String, PowerState> newStates = getVmStates();
|
||||
|
||||
List<String> requestedVmNames = cmd.getVmNames();
|
||||
List<String> vmNames = new ArrayList();
|
||||
|
|
@ -2833,7 +2834,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
try {
|
||||
vmMo.setCustomFieldValue(CustomFieldConstants.CLOUD_NIC_MASK, "0");
|
||||
|
||||
if (getVmState(vmMo) != State.Stopped) {
|
||||
if (getVmState(vmMo) != PowerState.PowerOff) {
|
||||
|
||||
// before we stop VM, remove all possible snapshots on the VM to let
|
||||
// disk chain be collapsed
|
||||
|
|
@ -2948,7 +2949,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
}
|
||||
|
||||
final String vmName = cmd.getVmName();
|
||||
State state = State.Unknown;
|
||||
PowerState state = PowerState.PowerOff;
|
||||
Integer vncPort = null;
|
||||
|
||||
VmwareContext context = getServiceContext();
|
||||
|
|
@ -2958,7 +2959,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(vmName);
|
||||
if (vmMo != null) {
|
||||
state = getVmState(vmMo);
|
||||
if (state == State.Running) {
|
||||
if (state == PowerState.PowerOn) {
|
||||
synchronized (_vms) {
|
||||
_vms.put(vmName, State.Running);
|
||||
}
|
||||
|
|
@ -3719,7 +3720,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
List<NetworkDetails> networks = vmMo.getNetworksWithDetails();
|
||||
|
||||
// tear down all devices first before we destroy the VM to avoid accidently delete disk backing files
|
||||
if (getVmState(vmMo) != State.Stopped)
|
||||
if (getVmState(vmMo) != PowerState.PowerOff)
|
||||
vmMo.safePowerOff(_shutdown_waitMs);
|
||||
vmMo.tearDownDevices(new Class<?>[] { VirtualDisk.class, VirtualEthernetCard.class });
|
||||
vmMo.destroy();
|
||||
|
|
@ -4074,7 +4075,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
|
||||
@Override
|
||||
public PingCommand getCurrentStatus(long id) {
|
||||
HashMap<String, State> newStates = sync();
|
||||
HashMap<String, PowerState> newStates = sync();
|
||||
if (newStates == null) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -4180,7 +4181,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
StartupRoutingCommand cmd = new StartupRoutingCommand();
|
||||
fillHostInfo(cmd);
|
||||
|
||||
Map<String, State> changes = null;
|
||||
Map<String, PowerState> changes = null;
|
||||
synchronized (_vms) {
|
||||
_vms.clear();
|
||||
changes = sync();
|
||||
|
|
@ -4338,7 +4339,16 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
details.put("NativeHA", "true");
|
||||
}
|
||||
}
|
||||
|
||||
protected HashMap<String, PowerState> sync() {
|
||||
try {
|
||||
return this.getVmStates();
|
||||
} catch(Exception e) {
|
||||
return new HashMap<String, PowerState>();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
protected HashMap<String, State> sync() {
|
||||
HashMap<String, State> changes = new HashMap<String, State>();
|
||||
HashMap<String, State> oldStates = null;
|
||||
|
|
@ -4388,10 +4398,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
} else if (oldState != newState) {
|
||||
_vms.put(vm, newState);
|
||||
if (newState == State.Stopped) {
|
||||
/*
|
||||
* if (_vmsKilled.remove(vm)) { s_logger.debug("VM " + vm + " has been killed for storage. ");
|
||||
* newState = State.Error; }
|
||||
*/
|
||||
}
|
||||
changes.put(vm, newState);
|
||||
}
|
||||
|
|
@ -4445,7 +4451,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
}
|
||||
return changes;
|
||||
}
|
||||
|
||||
*/
|
||||
private boolean isVmInCluster(String vmName) throws Exception {
|
||||
VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
|
||||
|
||||
|
|
@ -4610,11 +4616,11 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
}
|
||||
}
|
||||
|
||||
private HashMap<String, State> getVmStates() throws Exception {
|
||||
private HashMap<String, PowerState> getVmStates() throws Exception {
|
||||
VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
|
||||
ObjectContent[] ocs = hyperHost.getVmPropertiesOnHyperHost(new String[] { "name", "runtime.powerState", "config.template" });
|
||||
|
||||
HashMap<String, State> newStates = new HashMap<String, State>();
|
||||
HashMap<String, PowerState> newStates = new HashMap<String, PowerState>();
|
||||
if (ocs != null && ocs.length > 0) {
|
||||
for (ObjectContent oc : ocs) {
|
||||
List<DynamicProperty> objProps = oc.getPropSet();
|
||||
|
|
@ -4853,11 +4859,11 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
return connect(vmname, ipAddress, 3922);
|
||||
}
|
||||
|
||||
private static State convertState(VirtualMachinePowerState powerState) {
|
||||
private static PowerState convertState(VirtualMachinePowerState powerState) {
|
||||
return s_statesTable.get(powerState);
|
||||
}
|
||||
|
||||
private static State getVmState(VirtualMachineMO vmMo) throws Exception {
|
||||
private static PowerState getVmState(VirtualMachineMO vmMo) throws Exception {
|
||||
VirtualMachineRuntimeInfo runtimeInfo = vmMo.getRuntimeInfo();
|
||||
return convertState(runtimeInfo.getPowerState());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -244,6 +244,7 @@ import com.cloud.utils.exception.CloudRuntimeException;
|
|||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.vm.DiskProfile;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.PowerState;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.snapshot.VMSnapshot;
|
||||
import com.trilead.ssh2.SCPClient;
|
||||
|
|
@ -355,14 +356,14 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
}
|
||||
}
|
||||
|
||||
protected static HashMap<Types.VmPowerState, State> s_statesTable;
|
||||
protected static HashMap<Types.VmPowerState, PowerState> s_statesTable;
|
||||
static {
|
||||
s_statesTable = new HashMap<Types.VmPowerState, State>();
|
||||
s_statesTable.put(Types.VmPowerState.HALTED, State.Stopped);
|
||||
s_statesTable.put(Types.VmPowerState.PAUSED, State.Running);
|
||||
s_statesTable.put(Types.VmPowerState.RUNNING, State.Running);
|
||||
s_statesTable.put(Types.VmPowerState.SUSPENDED, State.Running);
|
||||
s_statesTable.put(Types.VmPowerState.UNRECOGNIZED, State.Unknown);
|
||||
s_statesTable = new HashMap<Types.VmPowerState, PowerState>();
|
||||
s_statesTable.put(Types.VmPowerState.HALTED, PowerState.PowerOff);
|
||||
s_statesTable.put(Types.VmPowerState.PAUSED, PowerState.PowerOn);
|
||||
s_statesTable.put(Types.VmPowerState.RUNNING, PowerState.PowerOn);
|
||||
s_statesTable.put(Types.VmPowerState.SUSPENDED, PowerState.PowerOn);
|
||||
s_statesTable.put(Types.VmPowerState.UNRECOGNIZED, PowerState.PowerUnknown);
|
||||
}
|
||||
|
||||
public XsHost getHost() {
|
||||
|
|
@ -2659,13 +2660,13 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
.valueOf(_pollingIntervalInSeconds), "startTime", startTime);
|
||||
}
|
||||
|
||||
protected State convertToState(Types.VmPowerState ps) {
|
||||
final State state = s_statesTable.get(ps);
|
||||
return state == null ? State.Unknown : state;
|
||||
protected PowerState convertToState(Types.VmPowerState ps) {
|
||||
final PowerState state = s_statesTable.get(ps);
|
||||
return state == null ? PowerState.PowerUnknown : state;
|
||||
}
|
||||
|
||||
protected HashMap<String, Pair<String, State>> getAllVms(Connection conn) {
|
||||
final HashMap<String, Pair<String, State>> vmStates = new HashMap<String, Pair<String, State>>();
|
||||
protected HashMap<String, Pair<String, PowerState>> getAllVms(Connection conn) {
|
||||
final HashMap<String, Pair<String, PowerState>> vmStates = new HashMap<String, Pair<String, PowerState>>();
|
||||
Map<VM, VM.Record> vm_map = null;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
try {
|
||||
|
|
@ -2690,7 +2691,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
}
|
||||
|
||||
VmPowerState ps = record.powerState;
|
||||
final State state = convertToState(ps);
|
||||
final PowerState state = convertToState(ps);
|
||||
if (s_logger.isTraceEnabled()) {
|
||||
s_logger.trace("VM " + record.nameLabel + ": powerstate = " + ps + "; vm state=" + state.toString());
|
||||
}
|
||||
|
|
@ -2709,14 +2710,14 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
vmStates.put(record.nameLabel, new Pair<String, State>(host_uuid, state));
|
||||
vmStates.put(record.nameLabel, new Pair<String, PowerState>(host_uuid, state));
|
||||
}
|
||||
}
|
||||
|
||||
return vmStates;
|
||||
}
|
||||
|
||||
protected State getVmState(Connection conn, final String vmName) {
|
||||
protected PowerState getVmState(Connection conn, final String vmName) {
|
||||
int retry = 3;
|
||||
while (retry-- > 0) {
|
||||
try {
|
||||
|
|
@ -2753,15 +2754,15 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
}
|
||||
}
|
||||
|
||||
return State.Stopped;
|
||||
return PowerState.PowerOff;
|
||||
}
|
||||
|
||||
protected CheckVirtualMachineAnswer execute(final CheckVirtualMachineCommand cmd) {
|
||||
Connection conn = getConnection();
|
||||
final String vmName = cmd.getVmName();
|
||||
final State state = getVmState(conn, vmName);
|
||||
final PowerState state = getVmState(conn, vmName);
|
||||
Integer vncPort = null;
|
||||
if (state == State.Running) {
|
||||
if (state == PowerState.PowerOn) {
|
||||
synchronized (_cluster.intern()) {
|
||||
s_vms.put(_cluster, _name, vmName, State.Running);
|
||||
}
|
||||
|
|
@ -3102,7 +3103,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
|
||||
}
|
||||
|
||||
protected State getRealPowerState(Connection conn, String label) {
|
||||
protected PowerState getRealPowerState(Connection conn, String label) {
|
||||
int i = 0;
|
||||
s_logger.trace("Checking on the HALTED State");
|
||||
for (; i < 20; i++) {
|
||||
|
|
@ -3131,7 +3132,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
return State.Stopped;
|
||||
return PowerState.PowerOff;
|
||||
}
|
||||
|
||||
protected Pair<VM, VM.Record> getControlDomain(Connection conn) throws XenAPIException, XmlRpcException {
|
||||
|
|
@ -4708,7 +4709,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
|
||||
Host.Record hostr = poolr.master.getRecord(conn);
|
||||
if (_host.uuid.equals(hostr.uuid)) {
|
||||
HashMap<String, Pair<String, State>> allStates=fullClusterSync(conn);
|
||||
HashMap<String, Pair<String, PowerState>> allStates=fullClusterSync(conn);
|
||||
cmd.setClusterVMStateChanges(allStates);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
|
|
@ -7681,12 +7682,13 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
s_logger.warn("Check for master failed, failing the Cluster sync command");
|
||||
return new Answer(cmd);
|
||||
}
|
||||
HashMap<String, Pair<String, State>> newStates = deltaClusterSync(conn);
|
||||
// HashMap<String, Pair<String, PowerState>> newStates = deltaClusterSync(conn);
|
||||
HashMap<String, Pair<String, PowerState>> newStates = new HashMap<String, Pair<String, PowerState>>();
|
||||
return new ClusterSyncAnswer(cmd.getClusterId(), newStates);
|
||||
}
|
||||
|
||||
|
||||
protected HashMap<String, Pair<String, State>> fullClusterSync(Connection conn) {
|
||||
protected HashMap<String, Pair<String, PowerState>> fullClusterSync(Connection conn) {
|
||||
synchronized (_cluster.intern()) {
|
||||
s_vms.clear(_cluster);
|
||||
}
|
||||
|
|
@ -7698,13 +7700,13 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
}
|
||||
String vm_name = record.nameLabel;
|
||||
VmPowerState ps = record.powerState;
|
||||
final State state = convertToState(ps);
|
||||
final PowerState state = convertToState(ps);
|
||||
Host host = record.residentOn;
|
||||
String host_uuid = null;
|
||||
if( ! isRefNull(host) ) {
|
||||
host_uuid = host.getUuid(conn);
|
||||
synchronized (_cluster.intern()) {
|
||||
s_vms.put(_cluster, host_uuid, vm_name, state);
|
||||
s_vms.put(_cluster, host_uuid, vm_name, state == PowerState.PowerOn ? State.Running : State.Stopped);
|
||||
}
|
||||
}
|
||||
if (s_logger.isTraceEnabled()) {
|
||||
|
|
@ -7716,16 +7718,28 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
s_logger.warn(msg, e);
|
||||
throw new CloudRuntimeException(msg);
|
||||
}
|
||||
return s_vms.getClusterVmState(_cluster);
|
||||
|
||||
HashMap<String, Pair<String, PowerState>> states = new HashMap<String, Pair<String, PowerState>> ();
|
||||
|
||||
HashMap<String, Pair<String, State>> rawStates = s_vms.getClusterVmState(_cluster);
|
||||
if(rawStates != null) {
|
||||
for(Map.Entry<String, Pair<String, State>> entry : rawStates.entrySet()) {
|
||||
states.put(entry.getKey(), new Pair<String, PowerState>(
|
||||
entry.getValue().first(),
|
||||
entry.getValue().second() == State.Running ? PowerState.PowerOn : PowerState.PowerOff));
|
||||
}
|
||||
}
|
||||
|
||||
return states;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
protected HashMap<String, Pair<String, State>> deltaClusterSync(Connection conn) {
|
||||
final HashMap<String, Pair<String, State>> changes = new HashMap<String, Pair<String, State>>();
|
||||
|
||||
|
||||
synchronized (_cluster.intern()) {
|
||||
HashMap<String, Pair<String, State>> newStates = getAllVms(conn);
|
||||
HashMap<String, Pair<String, PowerState>> newStates = getAllVms(conn);
|
||||
if (newStates == null) {
|
||||
s_logger.warn("Unable to get the vm states so no state sync at this point.");
|
||||
return null;
|
||||
|
|
@ -7791,10 +7805,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
s_logger.debug("14. The VM " + vm + " is in " + newState + " state was " + oldState.second());
|
||||
s_vms.put(_cluster, host_uuid, vm, newState);
|
||||
if (newState == State.Stopped) {
|
||||
/*
|
||||
* if (s_vmsKilled.remove(vm)) { s_logger.debug("VM " + vm + " has been killed for storage. ");
|
||||
* newState = State.Error; }
|
||||
*/
|
||||
}
|
||||
changes.put(vm, new Pair<String, State>(host_uuid, newState));
|
||||
}
|
||||
|
|
@ -7828,7 +7838,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
}
|
||||
return changes;
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
* @param cmd
|
||||
* @return
|
||||
|
|
|
|||
|
|
@ -98,6 +98,11 @@
|
|||
<artifactId>cloud-framework-events</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-framework-ipc</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<defaultGoal>install</defaultGoal>
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import com.cloud.host.HostVO;
|
|||
import com.cloud.host.Status;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine.PowerState;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
|
||||
@Local(value=Investigator.class)
|
||||
|
|
@ -57,7 +58,7 @@ public class CheckOnAgentInvestigator extends AdapterBase implements Investigato
|
|||
}
|
||||
|
||||
s_logger.debug("Agent responded with state " + answer.getState().toString());
|
||||
return answer.getState() == State.Running;
|
||||
return answer.getState() == PowerState.PowerOn;
|
||||
} catch (AgentUnavailableException e) {
|
||||
s_logger.debug("Unable to reach the agent for " + vm.toString() + ": " + e.getMessage());
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -23,10 +23,10 @@ import javax.naming.ConfigurationException;
|
|||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.HostVmStateReportEntry;
|
||||
import com.cloud.agent.api.PingCommand;
|
||||
import com.cloud.agent.api.StartupCommand;
|
||||
import com.cloud.agent.api.StartupRoutingCommand;
|
||||
import com.cloud.agent.api.StartupRoutingCommand.VmState;
|
||||
import com.cloud.host.Host.Type;
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.resource.ServerResource;
|
||||
|
|
@ -46,7 +46,7 @@ public class KvmDummyResourceBase extends ServerResourceBase implements ServerRe
|
|||
|
||||
@Override
|
||||
public StartupCommand[] initialize() {
|
||||
StartupRoutingCommand cmd = new StartupRoutingCommand(0, 0, 0, 0, null, Hypervisor.HypervisorType.KVM, new HashMap<String, String>(), new HashMap<String, VmState>());
|
||||
StartupRoutingCommand cmd = new StartupRoutingCommand(0, 0, 0, 0, null, Hypervisor.HypervisorType.KVM, new HashMap<String, String>(), new HashMap<String, HostVmStateReportEntry>());
|
||||
cmd.setDataCenter(_zoneId);
|
||||
cmd.setPod(_podId);
|
||||
cmd.setCluster(_clusterId);
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public class DummyHostServerResource extends ServerResourceBase {
|
|||
|
||||
@Override
|
||||
public PingCommand getCurrentStatus(long id) {
|
||||
HashMap<String, VirtualMachine.State> newStates = new HashMap<String, VirtualMachine.State>();
|
||||
HashMap<String, VirtualMachine.PowerState> newStates = new HashMap<String, VirtualMachine.PowerState>();
|
||||
return new PingRoutingCommand(com.cloud.host.Host.Type.Routing, id, newStates);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
package com.cloud.vm;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -90,6 +91,8 @@ public interface VirtualMachineManager extends Manager {
|
|||
<T extends VMInstanceVO> boolean expunge(T vm, User caller, Account account) throws ResourceUnavailableException;
|
||||
|
||||
<T extends VMInstanceVO> void registerGuru(VirtualMachine.Type type, VirtualMachineGuru<T> guru);
|
||||
|
||||
Collection<VirtualMachineGuru<? extends VMInstanceVO>> getRegisteredGurus();
|
||||
|
||||
boolean stateTransitTo(VMInstanceVO vm, VirtualMachine.Event e, Long hostId) throws NoTransitionException;
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ import org.apache.log4j.Logger;
|
|||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.AgentManager.OnError;
|
||||
import com.cloud.agent.Listener;
|
||||
import com.cloud.agent.api.StartupRoutingCommand.VmState;
|
||||
import com.cloud.agent.api.to.NicTO;
|
||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
import com.cloud.agent.manager.Commands;
|
||||
|
|
@ -132,6 +131,7 @@ import com.cloud.utils.fsm.NoTransitionException;
|
|||
import com.cloud.utils.fsm.StateMachine2;
|
||||
import com.cloud.vm.ItWorkVO.Step;
|
||||
import com.cloud.vm.VirtualMachine.Event;
|
||||
import com.cloud.vm.VirtualMachine.PowerState;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.dao.NicDao;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
|
|
@ -259,6 +259,13 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
_vmGurus.put(type, guru);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<VirtualMachineGuru<? extends VMInstanceVO>> getRegisteredGurus() {
|
||||
synchronized(_vmGurus) {
|
||||
return _vmGurus.values();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
|
|
@ -1199,7 +1206,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
|
||||
protected boolean checkVmOnHost(VirtualMachine vm, long hostId) throws AgentUnavailableException, OperationTimedoutException {
|
||||
CheckVirtualMachineAnswer answer = (CheckVirtualMachineAnswer) _agentMgr.send(hostId, new CheckVirtualMachineCommand(vm.getInstanceName()));
|
||||
if (!answer.getResult() || answer.getState() == State.Stopped) {
|
||||
if (!answer.getResult() || answer.getState() == PowerState.PowerOff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1626,12 +1633,11 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
public Command cleanup(String vmName) {
|
||||
return new StopCommand(vmName);
|
||||
}
|
||||
|
||||
/*
|
||||
public Commands fullHostSync(final long hostId, StartupRoutingCommand startup) {
|
||||
Commands commands = new Commands(OnError.Continue);
|
||||
|
||||
Map<Long, AgentVmInfo> infos = convertToInfos(startup);
|
||||
|
||||
final List<? extends VMInstanceVO> vms = _vmDao.listByHostId(hostId);
|
||||
s_logger.debug("Found " + vms.size() + " VMs for host " + hostId);
|
||||
for (VMInstanceVO vm : vms) {
|
||||
|
|
@ -1718,8 +1724,6 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
return commands;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void deltaSync(Map<String, Pair<String, State>> newStates) {
|
||||
Map<Long, AgentVmInfo> states = convertToInfos(newStates);
|
||||
|
||||
|
|
@ -1754,7 +1758,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
public void fullSync(final long clusterId, Map<String, Pair<String, State>> newStates) {
|
||||
if (newStates==null)return;
|
||||
|
|
@ -1924,15 +1928,16 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
return map;
|
||||
}
|
||||
|
||||
/*
|
||||
protected Map<Long, AgentVmInfo> convertToInfos(StartupRoutingCommand cmd) {
|
||||
final Map<String, VmState> states = cmd.getVmStates();
|
||||
final Map<String, HostVmStateReportEntry> states = cmd.getVmStates();
|
||||
final HashMap<Long, AgentVmInfo> map = new HashMap<Long, AgentVmInfo>();
|
||||
if (states == null) {
|
||||
return map;
|
||||
}
|
||||
Collection<VirtualMachineGuru<? extends VMInstanceVO>> vmGurus = _vmGurus.values();
|
||||
|
||||
for (Map.Entry<String, VmState> entry : states.entrySet()) {
|
||||
for (Map.Entry<String, HostVmStateReportEntry> entry : states.entrySet()) {
|
||||
for (VirtualMachineGuru<? extends VMInstanceVO> vmGuru : vmGurus) {
|
||||
String name = entry.getKey();
|
||||
VMInstanceVO vm = vmGuru.findByName(name);
|
||||
|
|
@ -1950,7 +1955,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
|
||||
return map;
|
||||
}
|
||||
|
||||
*/
|
||||
protected Map<Long, AgentVmInfo> convertDeltaToInfos(final Map<String, State> states) {
|
||||
final HashMap<Long, AgentVmInfo> map = new HashMap<Long, AgentVmInfo>();
|
||||
|
||||
|
|
@ -2233,7 +2238,10 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
if (answer instanceof ClusterSyncAnswer) {
|
||||
ClusterSyncAnswer hs = (ClusterSyncAnswer) answer;
|
||||
if (!hs.isExceuted()){
|
||||
|
||||
/* TODO
|
||||
deltaSync(hs.getNewStates());
|
||||
*/
|
||||
hs.setExecuted();
|
||||
}
|
||||
}
|
||||
|
|
@ -2258,6 +2266,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
if (cmd instanceof PingRoutingCommand) {
|
||||
PingRoutingCommand ping = (PingRoutingCommand) cmd;
|
||||
if (ping.getNewStates() != null && ping.getNewStates().size() > 0) {
|
||||
|
||||
/* TODO
|
||||
Commands commands = deltaHostSync(agentId, ping.getNewStates());
|
||||
if (commands.size() > 0) {
|
||||
try {
|
||||
|
|
@ -2266,6 +2276,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
s_logger.warn("Agent is now unavailable", e);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
processed = true;
|
||||
}
|
||||
|
|
@ -2304,11 +2316,13 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
|
||||
if (agent.getHypervisorType() == HypervisorType.XenServer) { // only for Xen
|
||||
StartupRoutingCommand startup = (StartupRoutingCommand) cmd;
|
||||
|
||||
/* TODO
|
||||
HashMap<String, Pair<String, State>> allStates = startup.getClusterVMStateChanges();
|
||||
if (allStates != null){
|
||||
this.fullSync(clusterId, allStates);
|
||||
}
|
||||
|
||||
*/
|
||||
// initiate the cron job
|
||||
ClusterSyncCommand syncCmd = new ClusterSyncCommand(Integer.parseInt(Config.ClusterDeltaSyncInterval.getDefaultValue()), clusterId);
|
||||
try {
|
||||
|
|
@ -2320,6 +2334,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
}
|
||||
else { // for others KVM and VMWare
|
||||
StartupRoutingCommand startup = (StartupRoutingCommand) cmd;
|
||||
|
||||
/*
|
||||
Commands commands = fullHostSync(agentId, startup);
|
||||
|
||||
if (commands.size() > 0) {
|
||||
|
|
@ -2345,7 +2361,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
throw new ConnectionException(true, "Unable to sync", e);
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.vm;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.agent.api.HostVmStateReportEntry;
|
||||
|
||||
public interface VirtualMachinePowerStateSync {
|
||||
void resetHostSyncState(long hostId);
|
||||
void processHostVmStateReport(long hostId, Map<String, HostVmStateReportEntry> report);
|
||||
}
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.vm;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.framework.messagebus.MessageBus;
|
||||
import org.apache.cloudstack.framework.messagebus.PublishScope;
|
||||
import org.apache.cloudstack.messagebus.SubjectConstants;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.HostVmStateReportEntry;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
public class VirtualMachinePowerStateSyncImpl implements VirtualMachinePowerStateSync {
|
||||
private static final Logger s_logger = Logger.getLogger(VirtualMachinePowerStateSyncImpl.class);
|
||||
|
||||
@Inject MessageBus _messageBus;
|
||||
@Inject VMInstanceDao _instanceDao;
|
||||
@Inject VirtualMachineManager _vmMgr;
|
||||
|
||||
public VirtualMachinePowerStateSyncImpl() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetHostSyncState(long hostId) {
|
||||
s_logger.info("Reset VM power state sync for host: " + hostId);
|
||||
_instanceDao.resetHostPowerStateTracking(hostId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processHostVmStateReport(long hostId, Map<String, HostVmStateReportEntry> report) {
|
||||
s_logger.info("Process host VM state report. host: " + hostId);
|
||||
|
||||
Map<Long, VirtualMachine.PowerState> translatedInfo = convertToInfos(report);
|
||||
for(Map.Entry<Long, VirtualMachine.PowerState> entry : translatedInfo.entrySet()) {
|
||||
if(_instanceDao.updatePowerState(entry.getKey(), hostId, entry.getValue())) {
|
||||
_messageBus.publish(null, SubjectConstants.VM_POWER_STATE, PublishScope.GLOBAL, entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected Map<Long, VirtualMachine.PowerState> convertToInfos(Map<String, HostVmStateReportEntry> states) {
|
||||
final HashMap<Long, VirtualMachine.PowerState> map = new HashMap<Long, VirtualMachine.PowerState>();
|
||||
if (states == null) {
|
||||
return map;
|
||||
}
|
||||
|
||||
Collection<VirtualMachineGuru<? extends VMInstanceVO>> vmGurus = _vmMgr.getRegisteredGurus();
|
||||
|
||||
for (Map.Entry<String, HostVmStateReportEntry> entry : states.entrySet()) {
|
||||
for (VirtualMachineGuru<? extends VMInstanceVO> vmGuru : vmGurus) {
|
||||
String name = entry.getKey();
|
||||
VMInstanceVO vm = vmGuru.findByName(name);
|
||||
if (vm != null) {
|
||||
map.put(vm.getId(), entry.getValue().getState());
|
||||
break;
|
||||
}
|
||||
|
||||
Long id = vmGuru.convertToId(name);
|
||||
if (id != null) {
|
||||
vm = vmGuru.findById(id);
|
||||
if(vm != null) {
|
||||
map.put(id, entry.getValue().getState());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
|
@ -116,7 +116,7 @@ public interface VMInstanceDao extends GenericDao<VMInstanceVO, Long>, StateDao<
|
|||
*/
|
||||
List<String> listDistinctHostNames(long networkId, VirtualMachine.Type... types);
|
||||
|
||||
void updatePowerState(long instanceId, long powerHostId, VirtualMachine.PowerState powerState);
|
||||
boolean updatePowerState(long instanceId, long powerHostId, VirtualMachine.PowerState powerState);
|
||||
void resetVmPowerStateTracking(long instanceId);
|
||||
void resetHostPowerStateTracking(long hostId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import java.util.Map;
|
|||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.Entity;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
|
@ -630,7 +629,8 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
|
|||
}
|
||||
|
||||
@Override @DB
|
||||
public void updatePowerState(long instanceId, long powerHostId, VirtualMachine.PowerState powerState) {
|
||||
public boolean updatePowerState(long instanceId, long powerHostId, VirtualMachine.PowerState powerState) {
|
||||
boolean needToUpdate = false;
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
|
|
@ -642,20 +642,21 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
|
|||
instance.setPowerHostId(powerHostId);
|
||||
instance.setPowerStateUpdateCount(1);
|
||||
instance.setPowerStateUpdateTime(DateUtil.currentGMTTime());
|
||||
|
||||
needToUpdate = true;
|
||||
update(instanceId, instance);
|
||||
} else {
|
||||
// to reduce DB updates, consecutive same state update for more than 3 times
|
||||
if(instance.getPowerStateUpdateCount() < MAX_CONSECUTIVE_SAME_STATE_UPDATE_COUNT) {
|
||||
instance.setPowerStateUpdateCount(instance.getPowerStateUpdateCount() + 1);
|
||||
instance.setPowerStateUpdateTime(DateUtil.currentGMTTime());
|
||||
|
||||
needToUpdate = true;
|
||||
update(instanceId, instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
txn.commit();
|
||||
return needToUpdate;
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.messagebus;
|
||||
|
||||
public interface SubjectConstants {
|
||||
public static final String VM_POWER_STATE = "vm.powerstate";
|
||||
}
|
||||
|
|
@ -1,312 +0,0 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.vm;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.agent.api.to.NicTO;
|
||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.deploy.DeploymentPlan;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InsufficientServerCapacityException;
|
||||
import com.cloud.exception.ManagementServerException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.exception.VirtualMachineMigrationException;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.dao.NetworkVO;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
import com.cloud.storage.StoragePool;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.ManagerBase;
|
||||
import com.cloud.utils.fsm.NoTransitionException;
|
||||
import com.cloud.vm.VirtualMachine.Event;
|
||||
import com.cloud.vm.VirtualMachine.Type;
|
||||
import com.cloud.vm.VirtualMachineProfile.Param;
|
||||
|
||||
@Component
|
||||
@Local(value = VirtualMachineManager.class)
|
||||
public class MockVirtualMachineManagerImpl extends ManagerBase implements VirtualMachineManager {
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean start() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stop() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> boolean stop(T vm, User caller, Account account) throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> boolean expunge(T vm, User caller, Account account) throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> void registerGuru(Type type, VirtualMachineGuru<T> guru) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stateTransitTo(VMInstanceVO vm, Event e, Long hostId) throws NoTransitionException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> boolean advanceStop(T vm, boolean forced, User caller, Account account) throws ResourceUnavailableException, OperationTimedoutException,
|
||||
ConcurrentOperationException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> boolean advanceExpunge(T vm, User caller, Account account) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> boolean remove(T vm, User caller, Account account) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> boolean destroy(T vm, User caller, Account account) throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean migrateAway(Type type, long vmid, long hostId) throws InsufficientServerCapacityException, VirtualMachineMigrationException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> T migrate(T vm, long srcHostId, DeployDestination dest) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException,
|
||||
VirtualMachineMigrationException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VMInstanceVO findByIdAndType(Type type, long vmId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVirtualMachineUpgradable(VirtualMachine vm, ServiceOffering offering) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> T allocate(T vm, VMTemplateVO template, ServiceOfferingVO serviceOffering, Pair<? extends DiskOfferingVO, Long> rootDiskOffering,
|
||||
List<Pair<DiskOfferingVO, Long>> dataDiskOfferings, List<Pair<NetworkVO, NicProfile>> networks, Map<Param, Object> params, DeploymentPlan plan, HypervisorType hyperType, Account owner)
|
||||
throws InsufficientCapacityException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> T allocate(T vm, VMTemplateVO template, ServiceOfferingVO serviceOffering, Long rootSize, Pair<DiskOfferingVO, Long> dataDiskOffering,
|
||||
List<Pair<NetworkVO, NicProfile>> networks, DeploymentPlan plan, HypervisorType hyperType, Account owner) throws InsufficientCapacityException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> T allocate(T vm, VMTemplateVO template, ServiceOfferingVO serviceOffering, List<Pair<NetworkVO, NicProfile>> networkProfiles, DeploymentPlan plan,
|
||||
HypervisorType hyperType, Account owner) throws InsufficientCapacityException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> T start(T vm, Map<Param, Object> params, User caller, Account account) throws InsufficientCapacityException, ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> T start(T vm, Map<Param, Object> params, User caller, Account account, DeploymentPlan planToDeploy) throws InsufficientCapacityException,
|
||||
ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> T advanceStart(T vm, Map<Param, Object> params, User caller, Account account) throws InsufficientCapacityException, ResourceUnavailableException,
|
||||
ConcurrentOperationException, OperationTimedoutException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> T advanceStart(T vm, Map<Param, Object> params, User caller, Account account, DeploymentPlan planToDeploy) throws InsufficientCapacityException,
|
||||
ResourceUnavailableException, ConcurrentOperationException, OperationTimedoutException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> T reboot(T vm, Map<Param, Object> params, User caller, Account account) throws InsufficientCapacityException, ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> T advanceReboot(T vm, Map<Param, Object> params, User caller, Account account) throws InsufficientCapacityException, ResourceUnavailableException,
|
||||
ConcurrentOperationException, OperationTimedoutException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> T storageMigration(T vm,
|
||||
StoragePool storagePoolId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VMInstanceVO findById(long vmId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.vm.VirtualMachineManager#checkIfCanUpgrade(com.cloud.vm.VirtualMachine, long)
|
||||
*/
|
||||
@Override
|
||||
public void checkIfCanUpgrade(VirtualMachine vmInstance, long newServiceOfferingId) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.vm.VirtualMachineManager#upgradeVmDb(long, long)
|
||||
*/
|
||||
@Override
|
||||
public boolean upgradeVmDb(long vmId, long serviceOfferingId) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.vm.VirtualMachineManager#toNicTO(com.cloud.vm.NicProfile, com.cloud.hypervisor.Hypervisor.HypervisorType)
|
||||
*/
|
||||
@Override
|
||||
public NicTO toNicTO(NicProfile nic, HypervisorType hypervisorType) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.vm.VirtualMachineManager#toVmTO(com.cloud.vm.VirtualMachineProfile)
|
||||
*/
|
||||
@Override
|
||||
public VirtualMachineTO toVmTO(VirtualMachineProfile<? extends VMInstanceVO> profile) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VMInstanceVO reConfigureVm(VMInstanceVO vm, ServiceOffering newServiceOffering, boolean sameHost) throws ResourceUnavailableException, ConcurrentOperationException {
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public VMInstanceVO findHostAndMigrate(VirtualMachine.Type vmType, VMInstanceVO vm, Long newSvcOfferingId) throws InsufficientCapacityException,
|
||||
ConcurrentOperationException, ResourceUnavailableException,
|
||||
VirtualMachineMigrationException, ManagementServerException{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> T migrateForScale(T vm, long srcHostId, DeployDestination dest, Long newSvcOfferingId) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException {
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.vm.VirtualMachineManager#addVmToNetwork(com.cloud.vm.VirtualMachine, com.cloud.network.Network, com.cloud.vm.NicProfile)
|
||||
*/
|
||||
@Override
|
||||
public NicProfile addVmToNetwork(VirtualMachine vm, Network network, NicProfile requested) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.vm.VirtualMachineManager#removeVmFromNetwork(com.cloud.vm.VirtualMachine, com.cloud.network.Network, java.net.URI)
|
||||
*/
|
||||
@Override
|
||||
public boolean removeNicFromVm(VirtualMachine vm, NicVO nic) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.vm.VirtualMachineManager#removeVmFromNetwork(com.cloud.vm.VirtualMachine, com.cloud.network.Network, java.net.URI)
|
||||
*/
|
||||
@Override
|
||||
public boolean removeVmFromNetwork(VirtualMachine vm, Network network, URI broadcastUri) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue