mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Removed the getByTypeAndId() method and replace it with getById method
This commit is contained in:
parent
9f15779f10
commit
319d91e1c2
@ -16,9 +16,9 @@
|
||||
// under the License.
|
||||
package com.cloud.ha;
|
||||
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.utils.component.Adapter;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
public interface FenceBuilder extends Adapter {
|
||||
/**
|
||||
@ -27,5 +27,5 @@ public interface FenceBuilder extends Adapter {
|
||||
* @param vm vm
|
||||
* @param host host where the vm was running on.
|
||||
*/
|
||||
public Boolean fenceOff(VMInstanceVO vm, HostVO host);
|
||||
public Boolean fenceOff(VirtualMachine vm, Host host);
|
||||
}
|
||||
@ -16,10 +16,10 @@
|
||||
// under the License.
|
||||
package com.cloud.ha;
|
||||
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.utils.component.Adapter;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
public interface Investigator extends Adapter {
|
||||
/**
|
||||
@ -27,7 +27,7 @@ public interface Investigator extends Adapter {
|
||||
*
|
||||
* @param vm to work on.
|
||||
*/
|
||||
public Boolean isVmAlive(VMInstanceVO vm, HostVO host);
|
||||
public Boolean isVmAlive(VirtualMachine vm, Host host);
|
||||
|
||||
public Status isAgentAlive(HostVO agent);
|
||||
public Status isAgentAlive(Host agent);
|
||||
}
|
||||
@ -158,7 +158,7 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, I
|
||||
}
|
||||
}
|
||||
|
||||
public static final String IsDynamicScalingEnabled = "enable.dynamic.scaling";
|
||||
static final String IsDynamicScalingEnabled = "enable.dynamic.scaling";
|
||||
|
||||
public enum Event {
|
||||
CreateRequested,
|
||||
@ -182,27 +182,28 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, I
|
||||
};
|
||||
|
||||
public enum Type {
|
||||
User,
|
||||
DomainRouter,
|
||||
ConsoleProxy,
|
||||
SecondaryStorageVm,
|
||||
ElasticIpVm,
|
||||
ElasticLoadBalancerVm,
|
||||
InternalLoadBalancerVm,
|
||||
User(false),
|
||||
DomainRouter(true),
|
||||
ConsoleProxy(true),
|
||||
SecondaryStorageVm(true),
|
||||
ElasticIpVm(true),
|
||||
ElasticLoadBalancerVm(true),
|
||||
InternalLoadBalancerVm(true),
|
||||
|
||||
/*
|
||||
* UserBareMetal is only used for selecting VirtualMachineGuru, there is no
|
||||
* VM with this type. UserBareMetal should treat exactly as User.
|
||||
*/
|
||||
UserBareMetal;
|
||||
UserBareMetal(false);
|
||||
|
||||
public static boolean isSystemVM(VirtualMachine.Type vmtype) {
|
||||
if (DomainRouter.equals(vmtype)
|
||||
|| ConsoleProxy.equals(vmtype)
|
||||
|| SecondaryStorageVm.equals(vmtype) || InternalLoadBalancerVm.equals(vmtype)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
boolean _isUsedBySystem;
|
||||
|
||||
private Type(boolean isUsedBySystem) {
|
||||
_isUsedBySystem = isUsedBySystem;
|
||||
}
|
||||
|
||||
public boolean isUsedBySystem() {
|
||||
return _isUsedBySystem;
|
||||
}
|
||||
}
|
||||
|
||||
@ -211,39 +212,39 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, I
|
||||
* reference this VM. You can build names that starts with this name and it
|
||||
* guarantees uniqueness for things related to the VM.
|
||||
*/
|
||||
public String getInstanceName();
|
||||
String getInstanceName();
|
||||
|
||||
/**
|
||||
* @return the host name of the virtual machine. If the user did not
|
||||
* specify the host name when creating the virtual machine then it is
|
||||
* defaults to the instance name.
|
||||
*/
|
||||
public String getHostName();
|
||||
String getHostName();
|
||||
|
||||
/**
|
||||
* @return the ip address of the virtual machine.
|
||||
*/
|
||||
public String getPrivateIpAddress();
|
||||
String getPrivateIpAddress();
|
||||
|
||||
/**
|
||||
* @return mac address.
|
||||
*/
|
||||
public String getPrivateMacAddress();
|
||||
String getPrivateMacAddress();
|
||||
|
||||
/**
|
||||
* @return password of the host for vnc purposes.
|
||||
*/
|
||||
public String getVncPassword();
|
||||
String getVncPassword();
|
||||
|
||||
/**
|
||||
* @return the state of the virtual machine
|
||||
*/
|
||||
// public State getState();
|
||||
// State getState();
|
||||
|
||||
/**
|
||||
* @return template id.
|
||||
*/
|
||||
public long getTemplateId();
|
||||
long getTemplateId();
|
||||
|
||||
|
||||
|
||||
@ -252,49 +253,51 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, I
|
||||
*
|
||||
* @return guestOSId
|
||||
*/
|
||||
public long getGuestOSId();
|
||||
long getGuestOSId();
|
||||
|
||||
/**
|
||||
* @return pod id.
|
||||
*/
|
||||
public Long getPodIdToDeployIn();
|
||||
Long getPodIdToDeployIn();
|
||||
|
||||
/**
|
||||
* @return data center id.
|
||||
*/
|
||||
public long getDataCenterId();
|
||||
long getDataCenterId();
|
||||
|
||||
/**
|
||||
* @return id of the host it was assigned last time.
|
||||
*/
|
||||
public Long getLastHostId();
|
||||
Long getLastHostId();
|
||||
|
||||
@Override
|
||||
public Long getHostId();
|
||||
Long getHostId();
|
||||
|
||||
/**
|
||||
* @return should HA be enabled for this machine?
|
||||
*/
|
||||
public boolean isHaEnabled();
|
||||
boolean isHaEnabled();
|
||||
|
||||
/**
|
||||
* @return should limit CPU usage to the service offering?
|
||||
*/
|
||||
public boolean limitCpuUse();
|
||||
boolean limitCpuUse();
|
||||
|
||||
/**
|
||||
* @return date when machine was created
|
||||
*/
|
||||
public Date getCreated();
|
||||
Date getCreated();
|
||||
|
||||
public long getServiceOfferingId();
|
||||
long getServiceOfferingId();
|
||||
|
||||
public Long getDiskOfferingId();
|
||||
Long getDiskOfferingId();
|
||||
|
||||
Type getType();
|
||||
|
||||
HypervisorType getHypervisorType();
|
||||
|
||||
public Map<String, String> getDetails();
|
||||
Map<String, String> getDetails();
|
||||
|
||||
long getUpdated();
|
||||
|
||||
}
|
||||
|
||||
@ -31,12 +31,13 @@ import com.cloud.agent.api.FenceCommand;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.ha.FenceBuilder;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
@Local(value=FenceBuilder.class)
|
||||
public class OvmFencer extends AdapterBase implements FenceBuilder {
|
||||
@ -66,7 +67,7 @@ public class OvmFencer extends AdapterBase implements FenceBuilder {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean fenceOff(VMInstanceVO vm, HostVO host) {
|
||||
public Boolean fenceOff(VirtualMachine vm, Host host) {
|
||||
if (host.getHypervisorType() != HypervisorType.Ovm) {
|
||||
s_logger.debug("Don't know how to fence non Ovm hosts " + host.getHypervisorType());
|
||||
return null;
|
||||
|
||||
@ -11,25 +11,22 @@
|
||||
// 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
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.ha;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
@Local(value=FenceBuilder.class)
|
||||
public class VmwareFencer extends AdapterBase implements FenceBuilder {
|
||||
|
||||
@Override
|
||||
public Boolean fenceOff(VMInstanceVO vm, HostVO host) {
|
||||
public Boolean fenceOff(VirtualMachine vm, Host host) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -11,18 +11,18 @@
|
||||
// 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
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.ha;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
@Local(value=Investigator.class)
|
||||
public class VmwareInvestigator extends AdapterBase implements Investigator {
|
||||
@ -30,7 +30,7 @@ public class VmwareInvestigator extends AdapterBase implements Investigator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Status isAgentAlive(HostVO agent) {
|
||||
public Status isAgentAlive(Host agent) {
|
||||
if(agent.getHypervisorType() == HypervisorType.VMware)
|
||||
return Status.Disconnected;
|
||||
|
||||
@ -38,7 +38,7 @@ public class VmwareInvestigator extends AdapterBase implements Investigator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isVmAlive(VMInstanceVO vm, HostVO host) {
|
||||
public Boolean isVmAlive(VirtualMachine vm, Host host) {
|
||||
if(vm.getHypervisorType() == HypervisorType.VMware)
|
||||
return true;
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
// 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
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.ha;
|
||||
@ -31,13 +31,14 @@ import com.cloud.agent.api.FenceAnswer;
|
||||
import com.cloud.agent.api.FenceCommand;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
@Local(value=FenceBuilder.class)
|
||||
public class XenServerFencer extends AdapterBase implements FenceBuilder {
|
||||
@ -49,7 +50,7 @@ public class XenServerFencer extends AdapterBase implements FenceBuilder {
|
||||
@Inject ResourceManager _resourceMgr;
|
||||
|
||||
@Override
|
||||
public Boolean fenceOff(VMInstanceVO vm, HostVO host) {
|
||||
public Boolean fenceOff(VirtualMachine vm, Host host) {
|
||||
if (host.getHypervisorType() != HypervisorType.XenServer) {
|
||||
s_logger.debug("Don't know how to fence non XenServer hosts " + host.getHypervisorType());
|
||||
return null;
|
||||
|
||||
@ -26,10 +26,10 @@ import com.cloud.agent.api.CheckVirtualMachineAnswer;
|
||||
import com.cloud.agent.api.CheckVirtualMachineCommand;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
|
||||
@Local(value=Investigator.class)
|
||||
@ -42,12 +42,12 @@ public class CheckOnAgentInvestigator extends AdapterBase implements Investigato
|
||||
}
|
||||
|
||||
@Override
|
||||
public Status isAgentAlive(HostVO agent) {
|
||||
public Status isAgentAlive(Host agent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isVmAlive(VMInstanceVO vm, HostVO host) {
|
||||
public Boolean isVmAlive(VirtualMachine vm, Host host) {
|
||||
CheckVirtualMachineCommand cmd = new CheckVirtualMachineCommand(vm.getInstanceName());
|
||||
try {
|
||||
CheckVirtualMachineAnswer answer = (CheckVirtualMachineAnswer)_agentMgr.send(vm.getHostId(), cmd);
|
||||
|
||||
@ -388,7 +388,7 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
|
||||
|
||||
long vmId = work.getInstanceId();
|
||||
|
||||
VMInstanceVO vm = _itMgr.findByIdAndType(work.getType(), work.getInstanceId());
|
||||
VirtualMachine vm = _itMgr.findById(work.getInstanceId());
|
||||
if (vm == null) {
|
||||
s_logger.info("Unable to find vm: " + vmId);
|
||||
return null;
|
||||
@ -506,7 +506,7 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
|
||||
}
|
||||
}
|
||||
|
||||
vm = _itMgr.findByIdAndType(vm.getType(), vm.getId());
|
||||
vm = _itMgr.findById(vm.getId());
|
||||
|
||||
if (!_forceHA && !vm.isHaEnabled()) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
@ -560,7 +560,7 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
|
||||
_alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodIdToDeployIn(), "Unable to restart " + vm.getHostName() + " which was running on host " + hostDesc,
|
||||
"The Storage is unavailable for trying to restart VM, name: " + vm.getHostName() + ", id: " + vmId + " which was running on host " + hostDesc);
|
||||
}
|
||||
vm = _itMgr.findByIdAndType(vm.getType(), vm.getId());
|
||||
vm = _itMgr.findById(vm.getId());
|
||||
work.setUpdateTime(vm.getUpdated());
|
||||
work.setPreviousState(vm.getState());
|
||||
return (System.currentTimeMillis() >> 10) + _restartRetryInterval;
|
||||
@ -606,7 +606,7 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
|
||||
}
|
||||
|
||||
protected Long destroyVM(HaWorkVO work) {
|
||||
final VMInstanceVO vm = _itMgr.findByIdAndType(work.getType(), work.getInstanceId());
|
||||
final VirtualMachine vm = _itMgr.findById(work.getInstanceId());
|
||||
s_logger.info("Destroying " + vm.toString());
|
||||
try {
|
||||
if (vm.getState() != State.Destroyed) {
|
||||
@ -639,7 +639,7 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
|
||||
}
|
||||
|
||||
protected Long stopVM(final HaWorkVO work) throws ConcurrentOperationException {
|
||||
VMInstanceVO vm = _itMgr.findByIdAndType(work.getType(), work.getInstanceId());
|
||||
VirtualMachine vm = _itMgr.findById(work.getInstanceId());
|
||||
if (vm == null) {
|
||||
s_logger.info("No longer can find VM " + work.getInstanceId() + ". Throwing away " + work);
|
||||
work.setStep(Step.Done);
|
||||
|
||||
@ -17,7 +17,6 @@
|
||||
package com.cloud.ha;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ejb.Local;
|
||||
@ -31,13 +30,14 @@ import com.cloud.agent.api.FenceAnswer;
|
||||
import com.cloud.agent.api.FenceCommand;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
@Local(value=FenceBuilder.class)
|
||||
public class KVMFencer extends AdapterBase implements FenceBuilder {
|
||||
@ -70,7 +70,7 @@ public class KVMFencer extends AdapterBase implements FenceBuilder {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean fenceOff(VMInstanceVO vm, HostVO host) {
|
||||
public Boolean fenceOff(VirtualMachine vm, Host host) {
|
||||
if (host.getHypervisorType() != HypervisorType.KVM) {
|
||||
s_logger.debug("Don't know how to fence non kvm hosts " + host.getHypervisorType());
|
||||
return null;
|
||||
|
||||
@ -25,13 +25,13 @@ import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.vm.Nic;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
@Local(value={Investigator.class})
|
||||
@ -39,13 +39,13 @@ public class ManagementIPSystemVMInvestigator extends AbstractInvestigatorImpl {
|
||||
private static final Logger s_logger = Logger.getLogger(ManagementIPSystemVMInvestigator.class);
|
||||
|
||||
private String _name = null;
|
||||
@Inject private HostDao _hostDao = null;
|
||||
@Inject private NetworkModel _networkMgr = null;
|
||||
@Inject private final HostDao _hostDao = null;
|
||||
@Inject private final NetworkModel _networkMgr = null;
|
||||
|
||||
|
||||
@Override
|
||||
public Boolean isVmAlive(VMInstanceVO vm, HostVO host) {
|
||||
if (!VirtualMachine.Type.isSystemVM(vm.getType())) {
|
||||
public Boolean isVmAlive(VirtualMachine vm, Host host) {
|
||||
if (!vm.getType().isUsedBySystem()) {
|
||||
s_logger.debug("Not a System Vm, unable to determine state of " + vm + " returning null");
|
||||
}
|
||||
|
||||
@ -110,7 +110,7 @@ public class ManagementIPSystemVMInvestigator extends AbstractInvestigatorImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Status isAgentAlive(HostVO agent) {
|
||||
public Status isAgentAlive(Host agent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -21,15 +21,15 @@ import java.util.List;
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.host.HostVO;
|
||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.storage.dao.VolumeDao;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
@Component
|
||||
@ -44,7 +44,7 @@ public class RecreatableFencer extends AdapterBase implements FenceBuilder {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean fenceOff(VMInstanceVO vm, HostVO host) {
|
||||
public Boolean fenceOff(VirtualMachine vm, Host host) {
|
||||
VirtualMachine.Type type = vm.getType();
|
||||
if (type != VirtualMachine.Type.ConsoleProxy && type != VirtualMachine.Type.DomainRouter && type != VirtualMachine.Type.SecondaryStorageVm) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
|
||||
@ -29,7 +29,7 @@ import org.apache.log4j.Logger;
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.PingTestCommand;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.NetworkModel;
|
||||
@ -38,7 +38,6 @@ import com.cloud.network.router.VirtualRouter;
|
||||
import com.cloud.network.router.VpcVirtualNetworkApplianceManager;
|
||||
import com.cloud.vm.Nic;
|
||||
import com.cloud.vm.UserVmVO;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
|
||||
@ -53,7 +52,7 @@ public class UserVmDomRInvestigator extends AbstractInvestigatorImpl {
|
||||
@Inject private final VpcVirtualNetworkApplianceManager _vnaMgr = null;
|
||||
|
||||
@Override
|
||||
public Boolean isVmAlive(VMInstanceVO vm, HostVO host) {
|
||||
public Boolean isVmAlive(VirtualMachine vm, Host host) {
|
||||
if (vm.getType() != VirtualMachine.Type.User) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Not a User Vm, unable to determine state of " + vm + " returning null");
|
||||
@ -104,7 +103,7 @@ public class UserVmDomRInvestigator extends AbstractInvestigatorImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Status isAgentAlive(HostVO agent) {
|
||||
public Status isAgentAlive(Host agent) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("checking if agent (" + agent.getId() + ") is alive");
|
||||
}
|
||||
@ -166,7 +165,7 @@ public class UserVmDomRInvestigator extends AbstractInvestigatorImpl {
|
||||
return true;
|
||||
}
|
||||
|
||||
private Boolean testUserVM(VMInstanceVO vm, Nic nic, VirtualRouter router) {
|
||||
private Boolean testUserVM(VirtualMachine vm, Nic nic, VirtualRouter router) {
|
||||
String privateIp = nic.getIp4Address();
|
||||
String routerPrivateIp = router.getPrivateIpAddress();
|
||||
|
||||
|
||||
@ -23,17 +23,18 @@ import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.CheckOnHostAnswer;
|
||||
import com.cloud.agent.api.CheckOnHostCommand;
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
@Local(value=Investigator.class)
|
||||
public class XenServerInvestigator extends AdapterBase implements Investigator {
|
||||
@ -46,7 +47,7 @@ public class XenServerInvestigator extends AdapterBase implements Investigator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Status isAgentAlive(HostVO agent) {
|
||||
public Status isAgentAlive(Host agent) {
|
||||
if (agent.getHypervisorType() != HypervisorType.XenServer) {
|
||||
return null;
|
||||
}
|
||||
@ -72,7 +73,7 @@ public class XenServerInvestigator extends AdapterBase implements Investigator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isVmAlive(VMInstanceVO vm, HostVO host) {
|
||||
public Boolean isVmAlive(VirtualMachine vm, Host host) {
|
||||
Status status = isAgentAlive(host);
|
||||
if (status == null) {
|
||||
return null;
|
||||
|
||||
@ -35,12 +35,16 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.cloudstack.api.IdentityService;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import org.apache.cloudstack.api.IdentityService;
|
||||
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.server.ManagementServer;
|
||||
@ -51,12 +55,10 @@ import com.cloud.user.User;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.Ternary;
|
||||
import com.cloud.utils.db.EntityManager;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachineManager;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
/**
|
||||
* Thumbnail access : /console?cmd=thumbnail&vm=xxx&w=xxx&h=xxx
|
||||
@ -74,10 +76,12 @@ public class ConsoleProxyServlet extends HttpServlet {
|
||||
@Inject VirtualMachineManager _vmMgr;
|
||||
@Inject ManagementServer _ms;
|
||||
@Inject IdentityService _identityService;
|
||||
@Inject
|
||||
EntityManager _entityMgr;
|
||||
|
||||
static ManagementServer s_ms;
|
||||
|
||||
private Gson _gson = new GsonBuilder().create();
|
||||
private final Gson _gson = new GsonBuilder().create();
|
||||
|
||||
public ConsoleProxyServlet() {
|
||||
}
|
||||
@ -179,7 +183,7 @@ public class ConsoleProxyServlet extends HttpServlet {
|
||||
}
|
||||
|
||||
private void handleThumbnailRequest(HttpServletRequest req, HttpServletResponse resp, long vmId) {
|
||||
VMInstanceVO vm = _vmMgr.findById(vmId);
|
||||
VirtualMachine vm = _vmMgr.findById(vmId);
|
||||
if(vm == null) {
|
||||
s_logger.warn("VM " + vmId + " does not exist, sending blank response for thumbnail request");
|
||||
sendResponse(resp, "");
|
||||
@ -230,7 +234,7 @@ public class ConsoleProxyServlet extends HttpServlet {
|
||||
}
|
||||
|
||||
private void handleAccessRequest(HttpServletRequest req, HttpServletResponse resp, long vmId) {
|
||||
VMInstanceVO vm = _vmMgr.findById(vmId);
|
||||
VirtualMachine vm = _vmMgr.findById(vmId);
|
||||
if(vm == null) {
|
||||
s_logger.warn("VM " + vmId + " does not exist, sending blank response for console access request");
|
||||
sendResponse(resp, "");
|
||||
@ -258,7 +262,7 @@ public class ConsoleProxyServlet extends HttpServlet {
|
||||
|
||||
String vmName = vm.getHostName();
|
||||
if(vm.getType() == VirtualMachine.Type.User) {
|
||||
UserVm userVm = (UserVm)_vmMgr.findByIdAndType(VirtualMachine.Type.User, vmId);
|
||||
UserVm userVm = _entityMgr.findById(UserVm.class, vmId);
|
||||
String displayName = userVm.getDisplayName();
|
||||
if(displayName != null && !displayName.isEmpty() && !displayName.equals(vmName)) {
|
||||
vmName += "(" + displayName + ")";
|
||||
@ -276,7 +280,7 @@ public class ConsoleProxyServlet extends HttpServlet {
|
||||
|
||||
// TODO authentication channel between console proxy VM and management server needs to be secured,
|
||||
// the data is now being sent through private network, but this is apparently not enough
|
||||
VMInstanceVO vm = _vmMgr.findById(vmId);
|
||||
VirtualMachine vm = _vmMgr.findById(vmId);
|
||||
if(vm == null) {
|
||||
s_logger.warn("VM " + vmId + " does not exist, sending failed response for authentication request from console proxy");
|
||||
sendResponse(resp, "failed");
|
||||
@ -339,7 +343,7 @@ public class ConsoleProxyServlet extends HttpServlet {
|
||||
return _gson.toJson(keyIvPair);
|
||||
}
|
||||
|
||||
private String composeThumbnailUrl(String rootUrl, VMInstanceVO vm, HostVO hostVo, int w, int h) {
|
||||
private String composeThumbnailUrl(String rootUrl, VirtualMachine vm, HostVO hostVo, int w, int h) {
|
||||
StringBuffer sb = new StringBuffer(rootUrl);
|
||||
|
||||
String host = hostVo.getPrivateIpAddress();
|
||||
@ -374,7 +378,7 @@ public class ConsoleProxyServlet extends HttpServlet {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private String composeConsoleAccessUrl(String rootUrl, VMInstanceVO vm, HostVO hostVo) {
|
||||
private String composeConsoleAccessUrl(String rootUrl, VirtualMachine vm, HostVO hostVo) {
|
||||
StringBuffer sb = new StringBuffer(rootUrl);
|
||||
String host = hostVo.getPrivateIpAddress();
|
||||
|
||||
@ -454,7 +458,7 @@ public class ConsoleProxyServlet extends HttpServlet {
|
||||
|
||||
private boolean checkSessionPermision(HttpServletRequest req, long vmId, Account accountObj) {
|
||||
|
||||
VMInstanceVO vm = _vmMgr.findById(vmId);
|
||||
VirtualMachine vm = _vmMgr.findById(vmId);
|
||||
if(vm == null) {
|
||||
s_logger.debug("Console/thumbnail access denied. VM " + vmId + " does not exist in system any more");
|
||||
return false;
|
||||
|
||||
@ -4201,9 +4201,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
|
||||
txn.commit();
|
||||
|
||||
VMInstanceVO vmoi = _itMgr.findByIdAndType(vm.getType(), vm.getId());
|
||||
VirtualMachineProfileImpl vmOldProfile = new VirtualMachineProfileImpl(
|
||||
vmoi);
|
||||
VirtualMachine vmoi = _itMgr.findById(vm.getId());
|
||||
VirtualMachineProfileImpl vmOldProfile = new VirtualMachineProfileImpl(vmoi);
|
||||
|
||||
// OS 3: update the network
|
||||
List<Long> networkIdList = cmd.getNetworkIds();
|
||||
@ -4279,9 +4278,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(networkList.get(0),
|
||||
profile));
|
||||
|
||||
VMInstanceVO vmi = _itMgr.findByIdAndType(vm.getType(), vm.getId());
|
||||
VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(
|
||||
vmi);
|
||||
VirtualMachine vmi = _itMgr.findById(vm.getId());
|
||||
VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(vmi);
|
||||
_networkMgr.allocate(vmProfile, networks);
|
||||
|
||||
_securityGroupMgr.addInstanceToGroups(vm.getId(),
|
||||
@ -4413,10 +4411,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(appNet,
|
||||
defaultNic));
|
||||
}
|
||||
VMInstanceVO vmi = _itMgr.findByIdAndType(vm.getType(),
|
||||
vm.getId());
|
||||
VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(
|
||||
vmi);
|
||||
VirtualMachine vmi = _itMgr.findById(vm.getId());
|
||||
VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(vmi);
|
||||
_networkMgr.allocate(vmProfile, networks);
|
||||
s_logger.debug("AssignVM: Advance virtual, adding networks no "
|
||||
+ networks.size() + " to " + vm.getInstanceName());
|
||||
|
||||
@ -108,8 +108,6 @@ public interface VirtualMachineManager extends Manager {
|
||||
|
||||
<T extends VMInstanceVO> T advanceReboot(T vm, Map<VirtualMachineProfile.Param, Object> params, User caller, Account account) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException, OperationTimedoutException;
|
||||
|
||||
VMInstanceVO findByIdAndType(VirtualMachine.Type type, long vmId);
|
||||
|
||||
/**
|
||||
* Check to see if a virtual machine can be upgraded to the given service offering
|
||||
*
|
||||
@ -119,7 +117,7 @@ public interface VirtualMachineManager extends Manager {
|
||||
*/
|
||||
boolean isVirtualMachineUpgradable(final VirtualMachine vm, final ServiceOffering offering);
|
||||
|
||||
VMInstanceVO findById(long vmId);
|
||||
VirtualMachine findById(long vmId);
|
||||
|
||||
<T extends VMInstanceVO> T storageMigration(T vm, StoragePool storagePoolId);
|
||||
|
||||
|
||||
@ -2017,11 +2017,6 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
return rebootedVm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VMInstanceVO findByIdAndType(VirtualMachine.Type type, long vmId) {
|
||||
return _vmDao.findById(vmId);
|
||||
}
|
||||
|
||||
public Command cleanup(VirtualMachine vm) {
|
||||
return new StopCommand(vm, _mgmtServer.getExecuteInSequence());
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user