You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ah...@apache.org on 2013/07/23 05:06:19 UTC
[2/3] git commit: updated refs/heads/master to 51377c4
Removed the getByTypeAndId() method and replace it with getById method
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/319d91e1
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/319d91e1
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/319d91e1
Branch: refs/heads/master
Commit: 319d91e1c2c22b27adaed0eb65c7b95e3bbb0503
Parents: 9f15779
Author: Alex Huang <al...@citrix.com>
Authored: Mon Jul 22 17:25:48 2013 -0700
Committer: Alex Huang <al...@citrix.com>
Committed: Mon Jul 22 20:06:04 2013 -0700
----------------------------------------------------------------------
api/src/com/cloud/ha/FenceBuilder.java | 31 +++++++++
api/src/com/cloud/ha/Investigator.java | 33 +++++++++
api/src/com/cloud/vm/VirtualMachine.java | 71 ++++++++++----------
.../src/com/cloud/ovm/hypervisor/OvmFencer.java | 7 +-
.../vmware/src/com/cloud/ha/VmwareFencer.java | 11 ++-
.../src/com/cloud/ha/VmwareInvestigator.java | 10 +--
.../xen/src/com/cloud/ha/XenServerFencer.java | 7 +-
.../com/cloud/ha/CheckOnAgentInvestigator.java | 8 +--
server/src/com/cloud/ha/FenceBuilder.java | 31 ---------
.../cloud/ha/HighAvailabilityManagerImpl.java | 10 +--
server/src/com/cloud/ha/Investigator.java | 33 ---------
server/src/com/cloud/ha/KVMFencer.java | 6 +-
.../ha/ManagementIPSystemVMInvestigator.java | 12 ++--
server/src/com/cloud/ha/RecreatableFencer.java | 8 +--
.../com/cloud/ha/UserVmDomRInvestigator.java | 9 ++-
.../src/com/cloud/ha/XenServerInvestigator.java | 9 +--
.../com/cloud/servlet/ConsoleProxyServlet.java | 28 ++++----
server/src/com/cloud/vm/UserVmManagerImpl.java | 16 ++---
.../src/com/cloud/vm/VirtualMachineManager.java | 4 +-
.../com/cloud/vm/VirtualMachineManagerImpl.java | 5 --
20 files changed, 172 insertions(+), 177 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/319d91e1/api/src/com/cloud/ha/FenceBuilder.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/ha/FenceBuilder.java b/api/src/com/cloud/ha/FenceBuilder.java
new file mode 100644
index 0000000..41bde71
--- /dev/null
+++ b/api/src/com/cloud/ha/FenceBuilder.java
@@ -0,0 +1,31 @@
+// 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.ha;
+
+import com.cloud.host.Host;
+import com.cloud.utils.component.Adapter;
+import com.cloud.vm.VirtualMachine;
+
+public interface FenceBuilder extends Adapter {
+ /**
+ * Fence off the vm.
+ *
+ * @param vm vm
+ * @param host host where the vm was running on.
+ */
+ public Boolean fenceOff(VirtualMachine vm, Host host);
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/319d91e1/api/src/com/cloud/ha/Investigator.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/ha/Investigator.java b/api/src/com/cloud/ha/Investigator.java
new file mode 100644
index 0000000..a5de1ba
--- /dev/null
+++ b/api/src/com/cloud/ha/Investigator.java
@@ -0,0 +1,33 @@
+// 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.ha;
+
+import com.cloud.host.Host;
+import com.cloud.host.Status;
+import com.cloud.utils.component.Adapter;
+import com.cloud.vm.VirtualMachine;
+
+public interface Investigator extends Adapter {
+ /**
+ * Returns if the vm is still alive.
+ *
+ * @param vm to work on.
+ */
+ public Boolean isVmAlive(VirtualMachine vm, Host host);
+
+ public Status isAgentAlive(Host agent);
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/319d91e1/api/src/com/cloud/vm/VirtualMachine.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/vm/VirtualMachine.java b/api/src/com/cloud/vm/VirtualMachine.java
index c172fbf..0a968bc 100755
--- a/api/src/com/cloud/vm/VirtualMachine.java
+++ b/api/src/com/cloud/vm/VirtualMachine.java
@@ -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();
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/319d91e1/plugins/hypervisors/ovm/src/com/cloud/ovm/hypervisor/OvmFencer.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm/src/com/cloud/ovm/hypervisor/OvmFencer.java b/plugins/hypervisors/ovm/src/com/cloud/ovm/hypervisor/OvmFencer.java
index 7aefcaa..71d9d0b 100755
--- a/plugins/hypervisors/ovm/src/com/cloud/ovm/hypervisor/OvmFencer.java
+++ b/plugins/hypervisors/ovm/src/com/cloud/ovm/hypervisor/OvmFencer.java
@@ -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;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/319d91e1/plugins/hypervisors/vmware/src/com/cloud/ha/VmwareFencer.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/ha/VmwareFencer.java b/plugins/hypervisors/vmware/src/com/cloud/ha/VmwareFencer.java
index 2ed5caf..dab5064 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/ha/VmwareFencer.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/ha/VmwareFencer.java
@@ -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;
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/319d91e1/plugins/hypervisors/vmware/src/com/cloud/ha/VmwareInvestigator.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/ha/VmwareInvestigator.java b/plugins/hypervisors/vmware/src/com/cloud/ha/VmwareInvestigator.java
index a7e67e1..e5ef5b7 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/ha/VmwareInvestigator.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/ha/VmwareInvestigator.java
@@ -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;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/319d91e1/plugins/hypervisors/xen/src/com/cloud/ha/XenServerFencer.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/ha/XenServerFencer.java b/plugins/hypervisors/xen/src/com/cloud/ha/XenServerFencer.java
index 737b3b2..4708ff3 100755
--- a/plugins/hypervisors/xen/src/com/cloud/ha/XenServerFencer.java
+++ b/plugins/hypervisors/xen/src/com/cloud/ha/XenServerFencer.java
@@ -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;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/319d91e1/server/src/com/cloud/ha/CheckOnAgentInvestigator.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/ha/CheckOnAgentInvestigator.java b/server/src/com/cloud/ha/CheckOnAgentInvestigator.java
index 2971910..0df324c 100644
--- a/server/src/com/cloud/ha/CheckOnAgentInvestigator.java
+++ b/server/src/com/cloud/ha/CheckOnAgentInvestigator.java
@@ -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);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/319d91e1/server/src/com/cloud/ha/FenceBuilder.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/ha/FenceBuilder.java b/server/src/com/cloud/ha/FenceBuilder.java
deleted file mode 100644
index 6f7413e..0000000
--- a/server/src/com/cloud/ha/FenceBuilder.java
+++ /dev/null
@@ -1,31 +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.ha;
-
-import com.cloud.host.HostVO;
-import com.cloud.utils.component.Adapter;
-import com.cloud.vm.VMInstanceVO;
-
-public interface FenceBuilder extends Adapter {
- /**
- * Fence off the vm.
- *
- * @param vm vm
- * @param host host where the vm was running on.
- */
- public Boolean fenceOff(VMInstanceVO vm, HostVO host);
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/319d91e1/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java b/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
index fcc4792..896c418 100755
--- a/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
+++ b/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
@@ -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);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/319d91e1/server/src/com/cloud/ha/Investigator.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/ha/Investigator.java b/server/src/com/cloud/ha/Investigator.java
deleted file mode 100644
index a414156..0000000
--- a/server/src/com/cloud/ha/Investigator.java
+++ /dev/null
@@ -1,33 +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.ha;
-
-import com.cloud.host.HostVO;
-import com.cloud.host.Status;
-import com.cloud.utils.component.Adapter;
-import com.cloud.vm.VMInstanceVO;
-
-public interface Investigator extends Adapter {
- /**
- * Returns if the vm is still alive.
- *
- * @param vm to work on.
- */
- public Boolean isVmAlive(VMInstanceVO vm, HostVO host);
-
- public Status isAgentAlive(HostVO agent);
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/319d91e1/server/src/com/cloud/ha/KVMFencer.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/ha/KVMFencer.java b/server/src/com/cloud/ha/KVMFencer.java
index 9fcacd7..517209e 100755
--- a/server/src/com/cloud/ha/KVMFencer.java
+++ b/server/src/com/cloud/ha/KVMFencer.java
@@ -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;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/319d91e1/server/src/com/cloud/ha/ManagementIPSystemVMInvestigator.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/ha/ManagementIPSystemVMInvestigator.java b/server/src/com/cloud/ha/ManagementIPSystemVMInvestigator.java
index 17f0355..2b6d261 100644
--- a/server/src/com/cloud/ha/ManagementIPSystemVMInvestigator.java
+++ b/server/src/com/cloud/ha/ManagementIPSystemVMInvestigator.java
@@ -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;
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/319d91e1/server/src/com/cloud/ha/RecreatableFencer.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/ha/RecreatableFencer.java b/server/src/com/cloud/ha/RecreatableFencer.java
index 50aa1b7..398bb03 100644
--- a/server/src/com/cloud/ha/RecreatableFencer.java
+++ b/server/src/com/cloud/ha/RecreatableFencer.java
@@ -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()) {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/319d91e1/server/src/com/cloud/ha/UserVmDomRInvestigator.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/ha/UserVmDomRInvestigator.java b/server/src/com/cloud/ha/UserVmDomRInvestigator.java
index 8b48c09..195deff 100644
--- a/server/src/com/cloud/ha/UserVmDomRInvestigator.java
+++ b/server/src/com/cloud/ha/UserVmDomRInvestigator.java
@@ -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();
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/319d91e1/server/src/com/cloud/ha/XenServerInvestigator.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/ha/XenServerInvestigator.java b/server/src/com/cloud/ha/XenServerInvestigator.java
index 6cbd22f..2b96007 100755
--- a/server/src/com/cloud/ha/XenServerInvestigator.java
+++ b/server/src/com/cloud/ha/XenServerInvestigator.java
@@ -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;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/319d91e1/server/src/com/cloud/servlet/ConsoleProxyServlet.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/servlet/ConsoleProxyServlet.java b/server/src/com/cloud/servlet/ConsoleProxyServlet.java
index 097986b..fe2052e 100644
--- a/server/src/com/cloud/servlet/ConsoleProxyServlet.java
+++ b/server/src/com/cloud/servlet/ConsoleProxyServlet.java
@@ -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;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/319d91e1/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index a4508ee..0805e6c 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -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());
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/319d91e1/server/src/com/cloud/vm/VirtualMachineManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/VirtualMachineManager.java b/server/src/com/cloud/vm/VirtualMachineManager.java
index 4982bcb..6abb91b 100644
--- a/server/src/com/cloud/vm/VirtualMachineManager.java
+++ b/server/src/com/cloud/vm/VirtualMachineManager.java
@@ -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);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/319d91e1/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
index fc55ee5..413bcb0 100755
--- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -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());
}