mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
clean up xenserver resource code
This commit is contained in:
parent
b94a982618
commit
15c142326f
@ -148,8 +148,8 @@ public class XenServerGuru extends HypervisorGuruBase implements HypervisorGuru
|
||||
EndPoint ep = endPointSelector.selectHypervisorHost(new ZoneScope(host.getDataCenterId()));
|
||||
host = hostDao.findById(ep.getId());
|
||||
hostDao.loadDetails(host);
|
||||
String snapshotHotFixVersion = host.getDetail(XenserverConfigs.XSHasHotFix62ESP1004);
|
||||
if (snapshotHotFixVersion != null && snapshotHotFixVersion.equalsIgnoreCase("true")) {
|
||||
String snapshotHotFixVersion = host.getDetail(XenserverConfigs.XS620HotFix);
|
||||
if (snapshotHotFixVersion != null && snapshotHotFixVersion.equalsIgnoreCase(XenserverConfigs.XSHotFix62ESP1004)) {
|
||||
return new Pair<Boolean, Long>(Boolean.TRUE, new Long(ep.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -588,7 +588,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
|
||||
} else if (prodBrand.equals("XenServer") && prodVersion.equals("6.1.0")) {
|
||||
resource = XenServer610Resource.class.getName();
|
||||
} else if (prodBrand.equals("XenServer") && prodVersion.equals("6.2.0")) {
|
||||
String hotfix = details.get("XS620HotFix");
|
||||
String hotfix = details.get(XenserverConfigs.XS620HotFix);
|
||||
if (hotfix != null && hotfix.equalsIgnoreCase(XenserverConfigs.XSHotFix62ESP1004)) {
|
||||
resource = Xenserver625Resource.class.getName();
|
||||
} else if (hotfix != null && hotfix.equalsIgnoreCase(XenserverConfigs.XSHotFix62ESP1)){
|
||||
|
||||
@ -16,7 +16,6 @@
|
||||
// under the License.
|
||||
package com.cloud.hypervisor.xen.resource;
|
||||
|
||||
import org.apache.cloudstack.hypervisor.xenserver.XenserverConfigs;
|
||||
import com.cloud.agent.IAgentControl;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.AttachIsoCommand;
|
||||
@ -183,8 +182,6 @@ import com.xensource.xenapi.Console;
|
||||
import com.xensource.xenapi.Host;
|
||||
import com.xensource.xenapi.HostCpu;
|
||||
import com.xensource.xenapi.HostMetrics;
|
||||
import com.xensource.xenapi.HostPatch;
|
||||
import com.xensource.xenapi.PoolPatch;
|
||||
import com.xensource.xenapi.Network;
|
||||
import com.xensource.xenapi.PBD;
|
||||
import com.xensource.xenapi.PIF;
|
||||
@ -5533,24 +5530,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
||||
}
|
||||
|
||||
|
||||
protected boolean hostHasHotFix(Connection conn, String hotFixUuid) {
|
||||
try {
|
||||
Host host = Host.getByUuid(conn, _host.uuid);
|
||||
Host.Record re = host.getRecord(conn);
|
||||
Set<HostPatch> patches = re.patches;
|
||||
PoolPatch poolPatch = PoolPatch.getByUuid(conn, hotFixUuid);
|
||||
for(HostPatch patch : patches) {
|
||||
PoolPatch pp = patch.getPoolPatch(conn);
|
||||
if (pp.equals(poolPatch) && patch.getApplied(conn)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
s_logger.debug("can't get patches information for hotFix: " + hotFixUuid);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void fillHostInfo(Connection conn, StartupRoutingCommand cmd) {
|
||||
final StringBuilder caps = new StringBuilder();
|
||||
try {
|
||||
@ -5569,9 +5548,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
||||
}
|
||||
details.put("product_brand", productBrand);
|
||||
details.put("product_version", _host.productVersion);
|
||||
Boolean hotFix62ESP1004 = hostHasHotFix(conn, XenserverConfigs.XSHotFix62ESP1004);
|
||||
details.put(XenserverConfigs.XSHasHotFix62ESP1004, hotFix62ESP1004.toString());
|
||||
|
||||
if (hr.softwareVersion.get("product_version_text_short") != null) {
|
||||
details.put("product_version_text_short", hr.softwareVersion.get("product_version_text_short"));
|
||||
cmd.setHypervisorVersion(hr.softwareVersion.get("product_version_text_short"));
|
||||
|
||||
@ -15,18 +15,9 @@
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.hypervisor.xen.resource;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.resource.ServerResource;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.script.Script;
|
||||
|
||||
@Local(value = ServerResource.class)
|
||||
public class XenServer602Resource extends XenServer56FP1Resource {
|
||||
@ -41,19 +32,6 @@ public class XenServer602Resource extends XenServer56FP1Resource {
|
||||
return CitrixHelper.getXenServer602GuestOsType(stdType, bootFromCD);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<File> getPatchFiles() {
|
||||
List<File> files = new ArrayList<File>();
|
||||
String patch = "scripts/vm/hypervisor/xenserver/xenserver60/patch";
|
||||
String patchfilePath = Script.findScript("", patch);
|
||||
if (patchfilePath == null) {
|
||||
throw new CloudRuntimeException("Unable to find patch file " + patch);
|
||||
}
|
||||
File file = new File(patchfilePath);
|
||||
files.add(file);
|
||||
return files;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getStaticMax(String os, boolean b, long dynamicMinRam, long dynamicMaxRam) {
|
||||
long recommendedValue = CitrixHelper.getXenServer602StaticMax(os, b);
|
||||
|
||||
@ -16,7 +16,6 @@
|
||||
// under the License.
|
||||
package com.cloud.hypervisor.xen.resource;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -62,7 +61,6 @@ import com.cloud.agent.api.to.VolumeTO;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.resource.ServerResource;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.script.Script;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
|
||||
@Local(value = ServerResource.class)
|
||||
@ -78,19 +76,6 @@ public class XenServer610Resource extends XenServer56FP1Resource {
|
||||
return CitrixHelper.getXenServer610GuestOsType(stdType, bootFromCD);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<File> getPatchFiles() {
|
||||
List<File> files = new ArrayList<File>();
|
||||
String patch = "scripts/vm/hypervisor/xenserver/xenserver60/patch";
|
||||
String patchfilePath = Script.findScript("", patch);
|
||||
if (patchfilePath == null) {
|
||||
throw new CloudRuntimeException("Unable to find patch file " + patch);
|
||||
}
|
||||
File file = new File(patchfilePath);
|
||||
files.add(file);
|
||||
return files;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer executeRequest(Command cmd) {
|
||||
if (cmd instanceof MigrateWithStorageCommand) {
|
||||
|
||||
@ -15,18 +15,20 @@
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.hypervisor.xen.resource;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.xensource.xenapi.Connection;
|
||||
import com.xensource.xenapi.Host;
|
||||
import com.xensource.xenapi.HostPatch;
|
||||
import com.xensource.xenapi.PoolPatch;
|
||||
import org.apache.cloudstack.hypervisor.xenserver.XenserverConfigs;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.StartupRoutingCommand;
|
||||
import com.cloud.resource.ServerResource;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.script.Script;
|
||||
|
||||
@Local(value = ServerResource.class)
|
||||
public class XenServer620Resource extends XenServer610Resource {
|
||||
@ -41,19 +43,6 @@ public class XenServer620Resource extends XenServer610Resource {
|
||||
return CitrixHelper.getXenServer620GuestOsType(stdType, bootFromCD);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<File> getPatchFiles() {
|
||||
List<File> files = new ArrayList<File>();
|
||||
String patch = "scripts/vm/hypervisor/xenserver/xenserver60/patch";
|
||||
String patchfilePath = Script.findScript("", patch);
|
||||
if (patchfilePath == null) {
|
||||
throw new CloudRuntimeException("Unable to find patch file " + patch);
|
||||
}
|
||||
File file = new File(patchfilePath);
|
||||
files.add(file);
|
||||
return files;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getStaticMax(String os, boolean b, long dynamicMinRam, long dynamicMaxRam) {
|
||||
long recommendedValue = CitrixHelper.getXenServer620StaticMax(os, b);
|
||||
@ -83,4 +72,37 @@ public class XenServer620Resource extends XenServer610Resource {
|
||||
}
|
||||
return dynamicMinRam;
|
||||
}
|
||||
|
||||
protected boolean hostHasHotFix(Connection conn, String hotFixUuid) {
|
||||
try {
|
||||
Host host = Host.getByUuid(conn, _host.uuid);
|
||||
Host.Record re = host.getRecord(conn);
|
||||
Set<HostPatch> patches = re.patches;
|
||||
PoolPatch poolPatch = PoolPatch.getByUuid(conn, hotFixUuid);
|
||||
for(HostPatch patch : patches) {
|
||||
PoolPatch pp = patch.getPoolPatch(conn);
|
||||
if (pp.equals(poolPatch) && patch.getApplied(conn)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
s_logger.debug("can't get patches information for hotFix: " + hotFixUuid);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void fillHostInfo(Connection conn, StartupRoutingCommand cmd) {
|
||||
super.fillHostInfo(conn, cmd);
|
||||
Map<String, String> details = cmd.getHostDetails();
|
||||
Boolean hotFix62ESP1004 = hostHasHotFix(conn, XenserverConfigs.XSHotFix62ESP1004);
|
||||
if( hotFix62ESP1004 != null && hotFix62ESP1004 ) {
|
||||
details.put(XenserverConfigs.XS620HotFix , XenserverConfigs.XSHotFix62ESP1004);
|
||||
} else {
|
||||
Boolean hotFix62ESP1 = hostHasHotFix(conn, XenserverConfigs.XSHotFix62ESP1);
|
||||
if( hotFix62ESP1 != null && hotFix62ESP1 ) {
|
||||
details.put(XenserverConfigs.XS620HotFix , XenserverConfigs.XSHotFix62ESP1);
|
||||
}
|
||||
}
|
||||
cmd.setHostDetails(details);
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,17 +18,13 @@
|
||||
*/
|
||||
package com.cloud.hypervisor.xen.resource;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.apache.cloudstack.hypervisor.xenserver.XenserverConfigs;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
@ -40,8 +36,6 @@ import com.cloud.agent.api.StartCommand;
|
||||
import com.cloud.agent.api.StartupRoutingCommand;
|
||||
import com.cloud.agent.api.to.GPUDeviceTO;
|
||||
import com.cloud.resource.ServerResource;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.script.Script;
|
||||
import com.xensource.xenapi.Connection;
|
||||
import com.xensource.xenapi.GPUGroup;
|
||||
import com.xensource.xenapi.Host;
|
||||
@ -84,9 +78,6 @@ public class XenServer620SP1Resource extends XenServer620Resource {
|
||||
@Override
|
||||
protected void fillHostInfo(Connection conn, StartupRoutingCommand cmd) {
|
||||
super.fillHostInfo(conn, cmd);
|
||||
Map<String, String> details = cmd.getHostDetails();
|
||||
details.put("XS620HotFix", XenserverConfigs.XSHotFix62ESP1);
|
||||
cmd.setHostDetails(details);
|
||||
try {
|
||||
HashMap<String, HashMap<String, Long>> groupDetails = getGPUGroupDetails(conn);
|
||||
cmd.setGpuGroupDetails(groupDetails);
|
||||
@ -163,19 +154,6 @@ public class XenServer620SP1Resource extends XenServer620Resource {
|
||||
return CitrixHelper.getXenServer620SP1GuestOsType(stdType, bootFromCD);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<File> getPatchFiles() {
|
||||
List<File> files = new ArrayList<File>();
|
||||
String patch = "scripts/vm/hypervisor/xenserver/xenserver60/patch";
|
||||
String patchfilePath = Script.findScript("", patch);
|
||||
if (patchfilePath == null) {
|
||||
throw new CloudRuntimeException("Unable to find patch file " + patch);
|
||||
}
|
||||
File file = new File(patchfilePath);
|
||||
files.add(file);
|
||||
return files;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getStaticMax(String os, boolean b, long dynamicMinRam, long dynamicMaxRam){
|
||||
long recommendedValue = CitrixHelper.getXenServer620SP1StaticMax(os, b);
|
||||
|
||||
@ -21,7 +21,6 @@ package com.cloud.hypervisor.xen.resource;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
@ -33,9 +32,7 @@ import com.xensource.xenapi.Types;
|
||||
import com.xensource.xenapi.VM;
|
||||
|
||||
import org.apache.cloudstack.hypervisor.xenserver.XenServerResourceNewBase;
|
||||
import org.apache.cloudstack.hypervisor.xenserver.XenserverConfigs;
|
||||
|
||||
import com.cloud.agent.api.StartupRoutingCommand;
|
||||
import com.cloud.resource.ServerResource;
|
||||
import com.cloud.storage.resource.StorageSubsystemCommandHandler;
|
||||
import com.cloud.storage.resource.StorageSubsystemCommandHandlerBase;
|
||||
@ -69,14 +66,6 @@ public class Xenserver625Resource extends XenServerResourceNewBase {
|
||||
return files;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillHostInfo(Connection conn, StartupRoutingCommand cmd) {
|
||||
super.fillHostInfo(conn, cmd);
|
||||
Map<String, String> details = cmd.getHostDetails();
|
||||
details.put("XS620HotFix", XenserverConfigs.XSHotFix62ESP1004);
|
||||
cmd.setHostDetails(details);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getStaticMax(String os, boolean b, long dynamicMinRam, long dynamicMaxRam){
|
||||
long recommendedValue = CitrixHelper.getXenServer625StaticMax(os, b);
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
package org.apache.cloudstack.hypervisor.xenserver;
|
||||
|
||||
public final class XenserverConfigs {
|
||||
public static final String XSHasHotFix62ESP1004 = "xs_has_hot_fix_esp1004";
|
||||
public static final String XS620HotFix = "xs620hotfix";
|
||||
public static final String XSHotFix62ESP1 = "0850b186-4d47-11e3-a720-001b2151a503";
|
||||
public static final String XSHotFix62ESP1004 = "996dd2e7-ad95-49cc-a0be-2c9adc4dfb0b";
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user