mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Hypervisor as class (#8798)
* HypervisorType as a class * Fixup * fixup * Add missing annotation * Resolve comments * Handle parallels typo * Add missing @Convert annotation
This commit is contained in:
parent
a0b642cdb8
commit
93f31828f5
@ -17,55 +17,45 @@
|
||||
package com.cloud.hypervisor;
|
||||
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Hypervisor {
|
||||
public static class HypervisorType {
|
||||
private static final Map<String, HypervisorType> hypervisorTypeMap = new LinkedHashMap<>();
|
||||
public static final HypervisorType None = new HypervisorType("None"); //for storage hosts
|
||||
public static final HypervisorType XenServer = new HypervisorType("XenServer", ImageFormat.VHD);
|
||||
public static final HypervisorType KVM = new HypervisorType("KVM", ImageFormat.QCOW2);
|
||||
public static final HypervisorType VMware = new HypervisorType("VMware", ImageFormat.OVA);
|
||||
public static final HypervisorType Hyperv = new HypervisorType("Hyperv");
|
||||
public static final HypervisorType VirtualBox = new HypervisorType("VirtualBox");
|
||||
public static final HypervisorType Parralels = new HypervisorType("Parralels");
|
||||
public static final HypervisorType BareMetal = new HypervisorType("BareMetal");
|
||||
public static final HypervisorType Simulator = new HypervisorType("Simulator");
|
||||
public static final HypervisorType Ovm = new HypervisorType("Ovm", ImageFormat.RAW);
|
||||
public static final HypervisorType Ovm3 = new HypervisorType("Ovm3", ImageFormat.RAW);
|
||||
public static final HypervisorType LXC = new HypervisorType("LXC");
|
||||
public static final HypervisorType Custom = new HypervisorType("Custom");
|
||||
public static final HypervisorType Any = new HypervisorType("Any"); /*If you don't care about the hypervisor type*/
|
||||
private final String name;
|
||||
private final ImageFormat imageFormat;
|
||||
|
||||
static Map<String, HypervisorType> hypervisorTypeMap;
|
||||
static Map<HypervisorType, ImageFormat> supportedImageFormatMap;
|
||||
public HypervisorType(String name) {
|
||||
this(name, null);
|
||||
}
|
||||
|
||||
public enum HypervisorType {
|
||||
None, //for storage hosts
|
||||
XenServer,
|
||||
KVM,
|
||||
VMware,
|
||||
Hyperv,
|
||||
VirtualBox,
|
||||
Parralels,
|
||||
BareMetal,
|
||||
Simulator,
|
||||
Ovm,
|
||||
Ovm3,
|
||||
LXC,
|
||||
Custom,
|
||||
|
||||
Any; /*If you don't care about the hypervisor type*/
|
||||
|
||||
static {
|
||||
hypervisorTypeMap = new HashMap<>();
|
||||
hypervisorTypeMap.put("xenserver", HypervisorType.XenServer);
|
||||
hypervisorTypeMap.put("kvm", HypervisorType.KVM);
|
||||
hypervisorTypeMap.put("vmware", HypervisorType.VMware);
|
||||
hypervisorTypeMap.put("hyperv", HypervisorType.Hyperv);
|
||||
hypervisorTypeMap.put("virtualbox", HypervisorType.VirtualBox);
|
||||
hypervisorTypeMap.put("parallels", HypervisorType.Parralels);
|
||||
hypervisorTypeMap.put("baremetal", HypervisorType.BareMetal);
|
||||
hypervisorTypeMap.put("simulator", HypervisorType.Simulator);
|
||||
hypervisorTypeMap.put("ovm", HypervisorType.Ovm);
|
||||
hypervisorTypeMap.put("lxc", HypervisorType.LXC);
|
||||
hypervisorTypeMap.put("any", HypervisorType.Any);
|
||||
hypervisorTypeMap.put("ovm3", HypervisorType.Ovm3);
|
||||
hypervisorTypeMap.put("custom", HypervisorType.Custom);
|
||||
|
||||
supportedImageFormatMap = new HashMap<>();
|
||||
supportedImageFormatMap.put(HypervisorType.XenServer, ImageFormat.VHD);
|
||||
supportedImageFormatMap.put(HypervisorType.KVM, ImageFormat.QCOW2);
|
||||
supportedImageFormatMap.put(HypervisorType.VMware, ImageFormat.OVA);
|
||||
supportedImageFormatMap.put(HypervisorType.Ovm, ImageFormat.RAW);
|
||||
supportedImageFormatMap.put(HypervisorType.Ovm3, ImageFormat.RAW);
|
||||
public HypervisorType(String name, ImageFormat imageFormat) {
|
||||
this.name = name;
|
||||
this.imageFormat = imageFormat;
|
||||
if (name.equals("Parralels")){ // typo in the original code
|
||||
hypervisorTypeMap.put("parallels", this);
|
||||
} else {
|
||||
hypervisorTypeMap.putIfAbsent(name.toLowerCase(Locale.ROOT), this);
|
||||
}
|
||||
}
|
||||
|
||||
public static HypervisorType getType(String hypervisor) {
|
||||
@ -75,24 +65,62 @@ public class Hypervisor {
|
||||
hypervisorTypeMap.getOrDefault(hypervisor.toLowerCase(Locale.ROOT), HypervisorType.None));
|
||||
}
|
||||
|
||||
public static HypervisorType[] values() {
|
||||
return hypervisorTypeMap.values().toArray(HypervisorType[]::new).clone();
|
||||
}
|
||||
|
||||
public static HypervisorType valueOf(String name) {
|
||||
if (StringUtils.isBlank(name)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
HypervisorType hypervisorType = hypervisorTypeMap.get(name.toLowerCase(Locale.ROOT));
|
||||
if (hypervisorType == null) {
|
||||
throw new IllegalArgumentException("HypervisorType '" + name + "' not found");
|
||||
}
|
||||
return hypervisorType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display name of a hypervisor type in case the custom hypervisor is used,
|
||||
* using the 'hypervisor.custom.display.name' setting. Otherwise, returns hypervisor name
|
||||
*/
|
||||
public String getHypervisorDisplayName() {
|
||||
return !Hypervisor.HypervisorType.Custom.equals(this) ?
|
||||
this.toString() :
|
||||
HypervisorGuru.HypervisorCustomDisplayName.value();
|
||||
return HypervisorType.Custom.equals(this) ? HypervisorGuru.HypervisorCustomDisplayName.value() : name;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method really needs to be part of the properties of the hypervisor type itself.
|
||||
*
|
||||
* @param hyperType
|
||||
* @return
|
||||
*/
|
||||
public static ImageFormat getSupportedImageFormat(HypervisorType hyperType) {
|
||||
return supportedImageFormatMap.getOrDefault(hyperType, null);
|
||||
public ImageFormat getSupportedImageFormat() {
|
||||
return imageFormat;
|
||||
}
|
||||
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
} else if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
HypervisorType that = (HypervisorType) o;
|
||||
return Objects.equals(name, that.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -21,6 +21,8 @@ package com.cloud.serializer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import org.apache.cloudstack.transport.HypervisorTypeAdaptor;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
@ -75,6 +77,7 @@ public class GsonHelper {
|
||||
builder.registerTypeAdapter(new TypeToken<Pair<Long, Long>>() {
|
||||
}.getType(), new NwGroupsCommandTypeAdaptor());
|
||||
builder.registerTypeAdapter(Storage.StoragePoolType.class, new StoragePoolTypeAdaptor());
|
||||
builder.registerTypeAdapter(Hypervisor.HypervisorType.class, new HypervisorTypeAdaptor());
|
||||
Gson gson = builder.create();
|
||||
dsAdaptor.initGson(gson);
|
||||
dtAdaptor.initGson(gson);
|
||||
|
||||
@ -0,0 +1,53 @@
|
||||
// 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.transport;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonNull;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
/**
|
||||
* {@link HypervisorType} acts as extendable set of singleton objects and should return same result when used "=="
|
||||
* or {@link Object#equals(Object)}.
|
||||
* To support that, need to return existing object for a given name instead of creating new.
|
||||
*/
|
||||
public class HypervisorTypeAdaptor implements JsonDeserializer<HypervisorType>, JsonSerializer<HypervisorType> {
|
||||
@Override
|
||||
public HypervisorType deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
if (json instanceof JsonPrimitive && ((JsonPrimitive) json).isString()) {
|
||||
return HypervisorType.valueOf(json.getAsString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(HypervisorType src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
String name = src.name();
|
||||
if (name == null) {
|
||||
return new JsonNull();
|
||||
}
|
||||
return new JsonPrimitive(name);
|
||||
}
|
||||
}
|
||||
@ -1735,17 +1735,12 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
return ExecuteInSequence.value();
|
||||
}
|
||||
|
||||
switch (hypervisorType) {
|
||||
case KVM:
|
||||
case XenServer:
|
||||
case Hyperv:
|
||||
case LXC:
|
||||
return false;
|
||||
case VMware:
|
||||
return StorageManager.shouldExecuteInSequenceOnVmware();
|
||||
default:
|
||||
return ExecuteInSequence.value();
|
||||
if (Set.of(HypervisorType.KVM, HypervisorType.XenServer, HypervisorType.Hyperv, HypervisorType.LXC).contains(hypervisorType)) {
|
||||
return false;
|
||||
} else if (hypervisorType.equals(HypervisorType.VMware)) {
|
||||
return StorageManager.shouldExecuteInSequenceOnVmware();
|
||||
}
|
||||
return ExecuteInSequence.value();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -26,8 +26,10 @@ import com.cloud.utils.db.StateMachine;
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State;
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
|
||||
import org.apache.cloudstack.util.HypervisorTypeConverter;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Convert;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
@ -62,6 +64,7 @@ public class EngineClusterVO implements EngineCluster, Identity {
|
||||
long podId;
|
||||
|
||||
@Column(name = "hypervisor_type")
|
||||
@Convert(converter = HypervisorTypeConverter.class)
|
||||
String hypervisorType;
|
||||
|
||||
@Column(name = "cluster_type")
|
||||
|
||||
@ -50,6 +50,7 @@ import com.cloud.util.StoragePoolTypeConverter;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.utils.db.StateMachine;
|
||||
import org.apache.cloudstack.util.HypervisorTypeConverter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "host")
|
||||
@ -118,7 +119,7 @@ public class EngineHostVO implements EngineHost, Identity {
|
||||
private String storageMacAddressDeux;
|
||||
|
||||
@Column(name = "hypervisor_type", updatable = true, nullable = false)
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
@Convert(converter = HypervisorTypeConverter.class)
|
||||
private HypervisorType hypervisorType;
|
||||
|
||||
@Column(name = "proxy_port")
|
||||
|
||||
@ -22,8 +22,10 @@ import com.cloud.org.Grouping;
|
||||
import com.cloud.org.Managed.ManagedState;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import org.apache.cloudstack.util.HypervisorTypeConverter;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Convert;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
@ -56,6 +58,7 @@ public class ClusterVO implements Cluster {
|
||||
long podId;
|
||||
|
||||
@Column(name = "hypervisor_type")
|
||||
@Convert(converter = HypervisorTypeConverter.class)
|
||||
String hypervisorType;
|
||||
|
||||
@Column(name = "cluster_type")
|
||||
|
||||
@ -42,6 +42,7 @@ import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.apache.cloudstack.util.HypervisorTypeConverter;
|
||||
import org.apache.cloudstack.utils.jsinterpreter.TagAsRuleHelper;
|
||||
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;
|
||||
import org.apache.commons.lang.BooleanUtils;
|
||||
@ -125,7 +126,7 @@ public class HostVO implements Host {
|
||||
private String storageMacAddressDeux;
|
||||
|
||||
@Column(name = "hypervisor_type", updatable = true, nullable = false)
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
@Convert(converter = HypervisorTypeConverter.class)
|
||||
private HypervisorType hypervisorType;
|
||||
|
||||
@Column(name = "proxy_port")
|
||||
|
||||
@ -19,9 +19,8 @@ package com.cloud.hypervisor;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Convert;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
@ -29,6 +28,7 @@ import javax.persistence.Table;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import org.apache.cloudstack.util.HypervisorTypeConverter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "hypervisor_capabilities")
|
||||
@ -39,7 +39,7 @@ public class HypervisorCapabilitiesVO implements HypervisorCapabilities {
|
||||
private long id;
|
||||
|
||||
@Column(name = "hypervisor_type")
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
@Convert(converter = HypervisorTypeConverter.class)
|
||||
private HypervisorType hypervisorType;
|
||||
|
||||
@Column(name = "hypervisor_version")
|
||||
|
||||
@ -20,6 +20,7 @@ import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Convert;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
@ -28,6 +29,7 @@ import javax.persistence.Table;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import org.apache.cloudstack.util.HypervisorTypeConverter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "guest_os_hypervisor")
|
||||
@ -44,6 +46,7 @@ public class GuestOSHypervisorVO implements GuestOSHypervisor {
|
||||
String guestOsName;
|
||||
|
||||
@Column(name = "hypervisor_type")
|
||||
@Convert(converter = HypervisorTypeConverter.class)
|
||||
String hypervisorType;
|
||||
|
||||
@Column(name = "hypervisor_version")
|
||||
|
||||
@ -20,6 +20,7 @@ import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Convert;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
@ -28,6 +29,7 @@ import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.apache.cloudstack.util.HypervisorTypeConverter;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
@ -89,7 +91,7 @@ public class SnapshotVO implements Snapshot {
|
||||
Date removed;
|
||||
|
||||
@Column(name = "hypervisor_type")
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
@Convert(converter = HypervisorTypeConverter.class)
|
||||
HypervisorType hypervisorType;
|
||||
|
||||
@Expose
|
||||
|
||||
@ -21,6 +21,7 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Convert;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
@ -32,6 +33,7 @@ import javax.persistence.TemporalType;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import com.cloud.user.UserData;
|
||||
import org.apache.cloudstack.util.HypervisorTypeConverter;
|
||||
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
@ -108,7 +110,7 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
||||
private boolean crossZones = false;
|
||||
|
||||
@Column(name = "hypervisor_type")
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
@Convert(converter = HypervisorTypeConverter.class)
|
||||
private HypervisorType hypervisorType;
|
||||
|
||||
@Column(name = "extractable")
|
||||
|
||||
@ -446,7 +446,7 @@ public class SystemVmTemplateRegistration {
|
||||
private List<String> fetchAllHypervisors(Long zoneId) {
|
||||
List<String> hypervisorList = new ArrayList<>();
|
||||
List<Hypervisor.HypervisorType> hypervisorTypes = clusterDao.getAvailableHypervisorInZone(zoneId);
|
||||
hypervisorList = hypervisorTypes.stream().distinct().map(Enum::name).collect(Collectors.toList());
|
||||
hypervisorList = hypervisorTypes.stream().distinct().map(Hypervisor.HypervisorType::name).collect(Collectors.toList());
|
||||
return hypervisorList;
|
||||
}
|
||||
|
||||
@ -719,8 +719,8 @@ public class SystemVmTemplateRegistration {
|
||||
}
|
||||
|
||||
private void validateTemplates(Set<Hypervisor.HypervisorType> hypervisorsInUse) {
|
||||
Set<String> hypervisors = hypervisorsInUse.stream().map(Enum::name).
|
||||
map(name -> name.toLowerCase(Locale.ROOT)).map(this::getHypervisorName).collect(Collectors.toSet());
|
||||
Set<String> hypervisors = hypervisorsInUse.stream().
|
||||
map(Hypervisor.HypervisorType::name).map(name -> name.toLowerCase(Locale.ROOT)).map(this::getHypervisorName).collect(Collectors.toSet());
|
||||
List<String> templates = new ArrayList<>();
|
||||
for (Hypervisor.HypervisorType hypervisorType : hypervisorsInUse) {
|
||||
templates.add(FileNames.get(hypervisorType));
|
||||
|
||||
@ -31,6 +31,13 @@ import java.util.Set;
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
import static com.cloud.hypervisor.Hypervisor.HypervisorType.Hyperv;
|
||||
import static com.cloud.hypervisor.Hypervisor.HypervisorType.KVM;
|
||||
import static com.cloud.hypervisor.Hypervisor.HypervisorType.LXC;
|
||||
import static com.cloud.hypervisor.Hypervisor.HypervisorType.Ovm3;
|
||||
import static com.cloud.hypervisor.Hypervisor.HypervisorType.VMware;
|
||||
import static com.cloud.hypervisor.Hypervisor.HypervisorType.XenServer;
|
||||
|
||||
public class Upgrade41500to41510 extends DbUpgradeAbstractImpl implements DbUpgradeSystemVmTemplate {
|
||||
|
||||
@Override
|
||||
@ -71,27 +78,19 @@ public class Upgrade41500to41510 extends DbUpgradeAbstractImpl implements DbUpgr
|
||||
final Set<Hypervisor.HypervisorType> hypervisorsListInUse = new HashSet<Hypervisor.HypervisorType>();
|
||||
try (PreparedStatement pstmt = conn.prepareStatement("select distinct(hypervisor_type) from `cloud`.`cluster` where removed is null"); ResultSet rs = pstmt.executeQuery()) {
|
||||
while (rs.next()) {
|
||||
switch (Hypervisor.HypervisorType.getType(rs.getString(1))) {
|
||||
case XenServer:
|
||||
hypervisorsListInUse.add(Hypervisor.HypervisorType.XenServer);
|
||||
break;
|
||||
case KVM:
|
||||
hypervisorsListInUse.add(Hypervisor.HypervisorType.KVM);
|
||||
break;
|
||||
case VMware:
|
||||
hypervisorsListInUse.add(Hypervisor.HypervisorType.VMware);
|
||||
break;
|
||||
case Hyperv:
|
||||
hypervisorsListInUse.add(Hypervisor.HypervisorType.Hyperv);
|
||||
break;
|
||||
case LXC:
|
||||
hypervisorsListInUse.add(Hypervisor.HypervisorType.LXC);
|
||||
break;
|
||||
case Ovm3:
|
||||
hypervisorsListInUse.add(Hypervisor.HypervisorType.Ovm3);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
Hypervisor.HypervisorType type = Hypervisor.HypervisorType.getType(rs.getString(1));
|
||||
if (type.equals(XenServer)) {
|
||||
hypervisorsListInUse.add(XenServer);
|
||||
} else if (type.equals(KVM)) {
|
||||
hypervisorsListInUse.add(KVM);
|
||||
} else if (type.equals(VMware)) {
|
||||
hypervisorsListInUse.add(VMware);
|
||||
} else if (type.equals(Hyperv)) {
|
||||
hypervisorsListInUse.add(Hyperv);
|
||||
} else if (type.equals(LXC)) {
|
||||
hypervisorsListInUse.add(LXC);
|
||||
} else if (type.equals(Ovm3)) {
|
||||
hypervisorsListInUse.add(Ovm3);
|
||||
}
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
@ -101,45 +100,45 @@ public class Upgrade41500to41510 extends DbUpgradeAbstractImpl implements DbUpgr
|
||||
|
||||
final Map<Hypervisor.HypervisorType, String> NewTemplateNameList = new HashMap<Hypervisor.HypervisorType, String>() {
|
||||
{
|
||||
put(Hypervisor.HypervisorType.KVM, "systemvm-kvm-4.15.1");
|
||||
put(Hypervisor.HypervisorType.VMware, "systemvm-vmware-4.15.1");
|
||||
put(Hypervisor.HypervisorType.XenServer, "systemvm-xenserver-4.15.1");
|
||||
put(Hypervisor.HypervisorType.Hyperv, "systemvm-hyperv-4.15.1");
|
||||
put(Hypervisor.HypervisorType.LXC, "systemvm-lxc-4.15.1");
|
||||
put(Hypervisor.HypervisorType.Ovm3, "systemvm-ovm3-4.15.1");
|
||||
put(KVM, "systemvm-kvm-4.15.1");
|
||||
put(VMware, "systemvm-vmware-4.15.1");
|
||||
put(XenServer, "systemvm-xenserver-4.15.1");
|
||||
put(Hyperv, "systemvm-hyperv-4.15.1");
|
||||
put(LXC, "systemvm-lxc-4.15.1");
|
||||
put(Ovm3, "systemvm-ovm3-4.15.1");
|
||||
}
|
||||
};
|
||||
|
||||
final Map<Hypervisor.HypervisorType, String> routerTemplateConfigurationNames = new HashMap<Hypervisor.HypervisorType, String>() {
|
||||
{
|
||||
put(Hypervisor.HypervisorType.KVM, "router.template.kvm");
|
||||
put(Hypervisor.HypervisorType.VMware, "router.template.vmware");
|
||||
put(Hypervisor.HypervisorType.XenServer, "router.template.xenserver");
|
||||
put(Hypervisor.HypervisorType.Hyperv, "router.template.hyperv");
|
||||
put(Hypervisor.HypervisorType.LXC, "router.template.lxc");
|
||||
put(Hypervisor.HypervisorType.Ovm3, "router.template.ovm3");
|
||||
put(KVM, "router.template.kvm");
|
||||
put(VMware, "router.template.vmware");
|
||||
put(XenServer, "router.template.xenserver");
|
||||
put(Hyperv, "router.template.hyperv");
|
||||
put(LXC, "router.template.lxc");
|
||||
put(Ovm3, "router.template.ovm3");
|
||||
}
|
||||
};
|
||||
|
||||
final Map<Hypervisor.HypervisorType, String> newTemplateUrl = new HashMap<Hypervisor.HypervisorType, String>() {
|
||||
{
|
||||
put(Hypervisor.HypervisorType.KVM, "https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-kvm.qcow2.bz2");
|
||||
put(Hypervisor.HypervisorType.VMware, "https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-vmware.ova");
|
||||
put(Hypervisor.HypervisorType.XenServer, "https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-xen.vhd.bz2");
|
||||
put(Hypervisor.HypervisorType.Hyperv, "https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-hyperv.vhd.zip");
|
||||
put(Hypervisor.HypervisorType.LXC, "https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-kvm.qcow2.bz2");
|
||||
put(Hypervisor.HypervisorType.Ovm3, "https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-ovm.raw.bz2");
|
||||
put(KVM, "https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-kvm.qcow2.bz2");
|
||||
put(VMware, "https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-vmware.ova");
|
||||
put(XenServer, "https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-xen.vhd.bz2");
|
||||
put(Hyperv, "https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-hyperv.vhd.zip");
|
||||
put(LXC, "https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-kvm.qcow2.bz2");
|
||||
put(Ovm3, "https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-ovm.raw.bz2");
|
||||
}
|
||||
};
|
||||
|
||||
final Map<Hypervisor.HypervisorType, String> newTemplateChecksum = new HashMap<Hypervisor.HypervisorType, String>() {
|
||||
{
|
||||
put(Hypervisor.HypervisorType.KVM, "0e9f9a7d0957c3e0a2088e41b2da2cec");
|
||||
put(Hypervisor.HypervisorType.XenServer, "86373992740b1eca8aff8b08ebf3aea5");
|
||||
put(Hypervisor.HypervisorType.VMware, "4006982765846d373eb3719b2fe4d720");
|
||||
put(Hypervisor.HypervisorType.Hyperv, "0b9514e4b6cba1f636fea2125f0f7a5f");
|
||||
put(Hypervisor.HypervisorType.LXC, "0e9f9a7d0957c3e0a2088e41b2da2cec");
|
||||
put(Hypervisor.HypervisorType.Ovm3, "ae3977e696b3e6c81bdcbb792d514d29");
|
||||
put(KVM, "0e9f9a7d0957c3e0a2088e41b2da2cec");
|
||||
put(XenServer, "86373992740b1eca8aff8b08ebf3aea5");
|
||||
put(VMware, "4006982765846d373eb3719b2fe4d720");
|
||||
put(Hyperv, "0b9514e4b6cba1f636fea2125f0f7a5f");
|
||||
put(LXC, "0e9f9a7d0957c3e0a2088e41b2da2cec");
|
||||
put(Ovm3, "ae3977e696b3e6c81bdcbb792d514d29");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -26,6 +26,7 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Convert;
|
||||
import javax.persistence.DiscriminatorColumn;
|
||||
import javax.persistence.DiscriminatorType;
|
||||
import javax.persistence.Entity;
|
||||
@ -41,6 +42,7 @@ import javax.persistence.TemporalType;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.apache.cloudstack.backup.Backup;
|
||||
import org.apache.cloudstack.util.HypervisorTypeConverter;
|
||||
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@ -159,7 +161,7 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
|
||||
protected String reservationId;
|
||||
|
||||
@Column(name = "hypervisor_type")
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
@Convert(converter = HypervisorTypeConverter.class)
|
||||
protected HypervisorType hypervisorType;
|
||||
|
||||
@Column(name = "dynamically_scalable")
|
||||
|
||||
@ -17,8 +17,10 @@
|
||||
package org.apache.cloudstack.direct.download;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import org.apache.cloudstack.util.HypervisorTypeConverter;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Convert;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
@ -45,6 +47,7 @@ public class DirectDownloadCertificateVO implements DirectDownloadCertificate {
|
||||
private String certificate;
|
||||
|
||||
@Column(name = "hypervisor_type")
|
||||
@Convert(converter = HypervisorTypeConverter.class)
|
||||
private Hypervisor.HypervisorType hypervisorType;
|
||||
|
||||
@Column(name = "zone_id")
|
||||
|
||||
@ -24,6 +24,7 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Convert;
|
||||
import javax.persistence.DiscriminatorColumn;
|
||||
import javax.persistence.DiscriminatorType;
|
||||
import javax.persistence.Entity;
|
||||
@ -48,6 +49,7 @@ import com.cloud.utils.fsm.FiniteStateObject;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.google.gson.Gson;
|
||||
import org.apache.cloudstack.util.HypervisorTypeConverter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "vm_instance")
|
||||
@ -146,7 +148,7 @@ public class VMEntityVO implements VirtualMachine, FiniteStateObject<State, Virt
|
||||
protected String reservationId;
|
||||
|
||||
@Column(name = "hypervisor_type")
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
@Convert(converter = HypervisorTypeConverter.class)
|
||||
protected HypervisorType hypervisorType;
|
||||
|
||||
@Transient
|
||||
|
||||
@ -25,6 +25,7 @@ import com.cloud.util.StoragePoolTypeConverter;
|
||||
import com.cloud.utils.UriUtils;
|
||||
import com.cloud.utils.db.Encrypt;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import org.apache.cloudstack.util.HypervisorTypeConverter;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Convert;
|
||||
@ -118,7 +119,7 @@ public class StoragePoolVO implements StoragePool {
|
||||
private Long capacityIops;
|
||||
|
||||
@Column(name = "hypervisor")
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
@Convert(converter = HypervisorTypeConverter.class)
|
||||
private HypervisorType hypervisor;
|
||||
|
||||
@Column(name = "parent")
|
||||
|
||||
@ -0,0 +1,38 @@
|
||||
// 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
|
||||
// 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.util;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
|
||||
import javax.persistence.AttributeConverter;
|
||||
import javax.persistence.Converter;
|
||||
|
||||
/**
|
||||
* Converts {@link com.cloud.hypervisor.Hypervisor.HypervisorType} to and from {@link String} using {@link com.cloud.hypervisor.Hypervisor.HypervisorType#name()}.
|
||||
*/
|
||||
@Converter
|
||||
public class HypervisorTypeConverter implements AttributeConverter<Hypervisor.HypervisorType, String> {
|
||||
@Override
|
||||
public String convertToDatabaseColumn(Hypervisor.HypervisorType attribute) {
|
||||
return attribute != null ? attribute.name() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Hypervisor.HypervisorType convertToEntityAttribute(String dbData) {
|
||||
return dbData != null ? Hypervisor.HypervisorType.valueOf(dbData) : null;
|
||||
}
|
||||
}
|
||||
@ -1636,8 +1636,12 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
|
||||
} else if (attr.getValue() != null && attr.getValue() instanceof Long) {
|
||||
pstmt.setLong(j, (Long)attr.getValue());
|
||||
} else if(attr.field.getDeclaredAnnotation(Convert.class) != null) {
|
||||
Object val = _conversionSupport.convertToDatabaseColumn(attr.field, value);
|
||||
pstmt.setObject(j, val);
|
||||
if (value instanceof String) {
|
||||
pstmt.setString(j, (String)value);
|
||||
} else {
|
||||
Object val = _conversionSupport.convertToDatabaseColumn(attr.field, value);
|
||||
pstmt.setObject(j, val);
|
||||
}
|
||||
} else if (attr.field.getType() == String.class) {
|
||||
final String str;
|
||||
try {
|
||||
|
||||
@ -118,6 +118,12 @@ import com.cloud.vm.VirtualMachineProfile.Param;
|
||||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
import com.cloud.vm.dao.NicDao;
|
||||
|
||||
import static com.cloud.hypervisor.Hypervisor.HypervisorType.Hyperv;
|
||||
import static com.cloud.hypervisor.Hypervisor.HypervisorType.KVM;
|
||||
import static com.cloud.hypervisor.Hypervisor.HypervisorType.LXC;
|
||||
import static com.cloud.hypervisor.Hypervisor.HypervisorType.VMware;
|
||||
import static com.cloud.hypervisor.Hypervisor.HypervisorType.XenServer;
|
||||
|
||||
public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements InternalLoadBalancerVMManager, InternalLoadBalancerVMService, VirtualMachineGuru {
|
||||
static final private String InternalLbVmNamePrefix = "b";
|
||||
|
||||
@ -202,7 +208,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements In
|
||||
} else if (nic.getTrafficType() == TrafficType.Control) {
|
||||
controlNic = nic;
|
||||
// Internal LB control command is sent over management server in VMware
|
||||
if (dest.getHost().getHypervisorType() == HypervisorType.VMware) {
|
||||
if (dest.getHost().getHypervisorType() == VMware) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Check if we need to add management server explicit route to Internal LB. pod cidr: " + dest.getPod().getCidrAddress() + "/" +
|
||||
dest.getPod().getCidrSize() + ", pod gateway: " + dest.getPod().getGateway() + ", management host: " + _mgmtHost);
|
||||
@ -748,24 +754,16 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements In
|
||||
logger.debug("Creating the internal lb vm " + id + " in datacenter " + dest.getDataCenter() + " with hypervisor type " + hType);
|
||||
}
|
||||
String templateName = null;
|
||||
switch (hType) {
|
||||
case XenServer:
|
||||
if (hType.equals(XenServer)) {
|
||||
templateName = VirtualNetworkApplianceManager.RouterTemplateXen.valueIn(dest.getDataCenter().getId());
|
||||
break;
|
||||
case KVM:
|
||||
} else if (hType.equals(KVM)) {
|
||||
templateName = VirtualNetworkApplianceManager.RouterTemplateKvm.valueIn(dest.getDataCenter().getId());
|
||||
break;
|
||||
case VMware:
|
||||
} else if (hType.equals(VMware)) {
|
||||
templateName = VirtualNetworkApplianceManager.RouterTemplateVmware.valueIn(dest.getDataCenter().getId());
|
||||
break;
|
||||
case Hyperv:
|
||||
} else if (hType.equals(Hyperv)) {
|
||||
templateName = VirtualNetworkApplianceManager.RouterTemplateHyperV.valueIn(dest.getDataCenter().getId());
|
||||
break;
|
||||
case LXC:
|
||||
} else if (hType.equals(LXC)) {
|
||||
templateName = VirtualNetworkApplianceManager.RouterTemplateLxc.valueIn(dest.getDataCenter().getId());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
final VMTemplateVO template = _templateDao.findRoutingTemplate(hType, templateName);
|
||||
|
||||
|
||||
@ -29,6 +29,7 @@ import javax.persistence.EntityExistsException;
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
import org.apache.cloudstack.framework.messagebus.MessageBus;
|
||||
import org.apache.cloudstack.framework.messagebus.MessageSubscriber;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
@ -240,23 +241,18 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
|
||||
HypervisorType hvType = host.getHypervisorType();
|
||||
|
||||
String label = null;
|
||||
switch (hvType) {
|
||||
case XenServer:
|
||||
if (hvType.equals(HypervisorType.XenServer)) {
|
||||
label = physNetTT.getXenNetworkLabel();
|
||||
if ((label != null) && (!label.equals(""))) {
|
||||
if (StringUtils.isNotBlank(label)) {
|
||||
physNetLabel = label;
|
||||
}
|
||||
break;
|
||||
case KVM:
|
||||
} else if (hvType.equals(HypervisorType.KVM)) {
|
||||
label = physNetTT.getKvmNetworkLabel();
|
||||
if ((label != null) && (!label.equals(""))) {
|
||||
if (StringUtils.isNotBlank(label)) {
|
||||
physNetLabel = label;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new CloudRuntimeException("Hypervisor " +
|
||||
hvType.toString() +
|
||||
" unsupported by OVS Tunnel Manager");
|
||||
} else {
|
||||
throw new CloudRuntimeException(String.format("Hypervisor %s unsupported by OVS Tunnel Manager", hvType));
|
||||
}
|
||||
|
||||
// Try to fetch GRE endpoint IP address for cloud db
|
||||
|
||||
@ -20,6 +20,7 @@ import java.net.URI;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Convert;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
@ -37,6 +38,7 @@ import com.cloud.user.Account;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import org.apache.cloudstack.util.HypervisorTypeConverter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "domain_router_view")
|
||||
@ -138,7 +140,7 @@ public class DomainRouterJoinVO extends BaseViewVO implements ControlledViewEnti
|
||||
private ResourceState hostResourceState;
|
||||
|
||||
@Column(name="hypervisor_type")
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
@Convert(converter = HypervisorTypeConverter.class)
|
||||
private Hypervisor.HypervisorType hypervisorType;
|
||||
|
||||
@Column(name = "template_id", updatable = true, nullable = true, length = 17)
|
||||
|
||||
@ -20,6 +20,7 @@ import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Convert;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
@ -38,6 +39,7 @@ import org.apache.cloudstack.api.Identity;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
import org.apache.cloudstack.ha.HAConfig;
|
||||
import org.apache.cloudstack.outofbandmanagement.OutOfBandManagement;
|
||||
import org.apache.cloudstack.util.HypervisorTypeConverter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
@ -76,7 +78,7 @@ public class HostJoinVO extends BaseViewVO implements InternalIdentity, Identity
|
||||
private String version;
|
||||
|
||||
@Column(name = "hypervisor_type")
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
@Convert(converter = HypervisorTypeConverter.class)
|
||||
private HypervisorType hypervisorType;
|
||||
|
||||
@Column(name = "hypervisor_version")
|
||||
|
||||
@ -20,6 +20,7 @@ package com.cloud.api.query.vo;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Convert;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
@ -34,6 +35,7 @@ import com.cloud.storage.VMTemplateStorageResourceAssoc;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import org.apache.cloudstack.util.HypervisorTypeConverter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "snapshot_view")
|
||||
@ -71,7 +73,7 @@ public class SnapshotJoinVO extends BaseViewWithTagInformationVO implements Cont
|
||||
private Snapshot.LocationType locationType;
|
||||
|
||||
@Column(name = "hypervisor_type")
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
@Convert(converter = HypervisorTypeConverter.class)
|
||||
Hypervisor.HypervisorType hypervisorType;
|
||||
|
||||
@Column(name = "account_id")
|
||||
|
||||
@ -36,6 +36,7 @@ import com.cloud.storage.ScopeType;
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
import com.cloud.storage.StoragePoolStatus;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import org.apache.cloudstack.util.HypervisorTypeConverter;
|
||||
|
||||
/**
|
||||
* Storage Pool DB view.
|
||||
@ -138,7 +139,7 @@ public class StoragePoolJoinVO extends BaseViewVO implements InternalIdentity, I
|
||||
private Long capacityIops;
|
||||
|
||||
@Column(name = "hypervisor")
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
@Convert(converter = HypervisorTypeConverter.class)
|
||||
private HypervisorType hypervisor;
|
||||
|
||||
@Column(name = "storage_provider_name")
|
||||
|
||||
@ -19,6 +19,7 @@ package com.cloud.api.query.vo;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Convert;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
@ -36,6 +37,7 @@ import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||
import com.cloud.template.VirtualMachineTemplate;
|
||||
import com.cloud.template.VirtualMachineTemplate.State;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import org.apache.cloudstack.util.HypervisorTypeConverter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "template_view")
|
||||
@ -114,7 +116,7 @@ public class TemplateJoinVO extends BaseViewWithTagInformationVO implements Cont
|
||||
private boolean crossZones = false;
|
||||
|
||||
@Column(name = "hypervisor_type")
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
@Convert(converter = HypervisorTypeConverter.class)
|
||||
private HypervisorType hypervisorType;
|
||||
|
||||
@Column(name = "extractable")
|
||||
|
||||
@ -43,6 +43,7 @@ import com.cloud.util.StoragePoolTypeConverter;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import org.apache.cloudstack.util.HypervisorTypeConverter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "user_vm_view")
|
||||
@ -128,7 +129,7 @@ public class UserVmJoinVO extends BaseViewWithTagInformationVO implements Contro
|
||||
private String guestOsUuid;
|
||||
|
||||
@Column(name = "hypervisor_type")
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
@Convert(converter = HypervisorTypeConverter.class)
|
||||
private HypervisorType hypervisorType;
|
||||
|
||||
@Column(name = "ha_enabled", updatable = true, nullable = true)
|
||||
|
||||
@ -19,6 +19,7 @@ package com.cloud.api.query.vo;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Convert;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
@ -33,6 +34,7 @@ import com.cloud.storage.Volume;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import org.apache.cloudstack.util.HypervisorTypeConverter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "volume_view")
|
||||
@ -179,7 +181,7 @@ public class VolumeJoinVO extends BaseViewWithTagInformationVO implements Contro
|
||||
private String errorString;
|
||||
|
||||
@Column(name = "hypervisor_type")
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
@Convert(converter = HypervisorTypeConverter.class)
|
||||
private HypervisorType hypervisorType;
|
||||
|
||||
@Column(name = "disk_offering_id")
|
||||
|
||||
@ -1300,22 +1300,16 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel, Confi
|
||||
PhysicalNetworkTrafficTypeVO mgmtTraffic = _pNTrafficTypeDao.findBy(mgmtPhyNetwork.getId(), TrafficType.Management);
|
||||
if (mgmtTraffic != null) {
|
||||
String label = null;
|
||||
switch (hypervisorType) {
|
||||
case XenServer:
|
||||
label = mgmtTraffic.getXenNetworkLabel();
|
||||
break;
|
||||
case KVM:
|
||||
label = mgmtTraffic.getKvmNetworkLabel();
|
||||
break;
|
||||
case VMware:
|
||||
label = mgmtTraffic.getVmwareNetworkLabel();
|
||||
break;
|
||||
case Hyperv:
|
||||
label = mgmtTraffic.getHypervNetworkLabel();
|
||||
break;
|
||||
case Ovm3:
|
||||
label = mgmtTraffic.getOvm3NetworkLabel();
|
||||
break;
|
||||
if (hypervisorType.equals(HypervisorType.XenServer)) {
|
||||
label = mgmtTraffic.getXenNetworkLabel();
|
||||
} else if (hypervisorType.equals(HypervisorType.KVM)) {
|
||||
label = mgmtTraffic.getKvmNetworkLabel();
|
||||
} else if (hypervisorType.equals(HypervisorType.VMware)) {
|
||||
label = mgmtTraffic.getVmwareNetworkLabel();
|
||||
} else if (hypervisorType.equals(HypervisorType.Hyperv)) {
|
||||
label = mgmtTraffic.getHypervNetworkLabel();
|
||||
} else if (hypervisorType.equals(HypervisorType.Ovm3)) {
|
||||
label = mgmtTraffic.getOvm3NetworkLabel();
|
||||
}
|
||||
return label;
|
||||
}
|
||||
@ -1335,22 +1329,16 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel, Confi
|
||||
PhysicalNetworkTrafficTypeVO storageTraffic = _pNTrafficTypeDao.findBy(storagePhyNetwork.getId(), TrafficType.Storage);
|
||||
if (storageTraffic != null) {
|
||||
String label = null;
|
||||
switch (hypervisorType) {
|
||||
case XenServer:
|
||||
label = storageTraffic.getXenNetworkLabel();
|
||||
break;
|
||||
case KVM:
|
||||
label = storageTraffic.getKvmNetworkLabel();
|
||||
break;
|
||||
case VMware:
|
||||
label = storageTraffic.getVmwareNetworkLabel();
|
||||
break;
|
||||
case Hyperv:
|
||||
label = storageTraffic.getHypervNetworkLabel();
|
||||
break;
|
||||
case Ovm3:
|
||||
label = storageTraffic.getOvm3NetworkLabel();
|
||||
break;
|
||||
if (hypervisorType.equals(HypervisorType.XenServer)) {
|
||||
label = storageTraffic.getXenNetworkLabel();
|
||||
} else if (hypervisorType.equals(HypervisorType.KVM)) {
|
||||
label = storageTraffic.getKvmNetworkLabel();
|
||||
} else if (hypervisorType.equals(HypervisorType.VMware)) {
|
||||
label = storageTraffic.getVmwareNetworkLabel();
|
||||
} else if (hypervisorType.equals(HypervisorType.Hyperv)) {
|
||||
label = storageTraffic.getHypervNetworkLabel();
|
||||
} else if (hypervisorType.equals(HypervisorType.Ovm3)) {
|
||||
label = storageTraffic.getOvm3NetworkLabel();
|
||||
}
|
||||
return label;
|
||||
}
|
||||
@ -1860,22 +1848,16 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel, Confi
|
||||
PhysicalNetworkTrafficTypeVO publicTraffic = _pNTrafficTypeDao.findBy(publicPhyNetwork.getId(), TrafficType.Public);
|
||||
if (publicTraffic != null) {
|
||||
String label = null;
|
||||
switch (hypervisorType) {
|
||||
case XenServer:
|
||||
label = publicTraffic.getXenNetworkLabel();
|
||||
break;
|
||||
case KVM:
|
||||
label = publicTraffic.getKvmNetworkLabel();
|
||||
break;
|
||||
case VMware:
|
||||
label = publicTraffic.getVmwareNetworkLabel();
|
||||
break;
|
||||
case Hyperv:
|
||||
label = publicTraffic.getHypervNetworkLabel();
|
||||
break;
|
||||
case Ovm3:
|
||||
label = publicTraffic.getOvm3NetworkLabel();
|
||||
break;
|
||||
if (hypervisorType.equals(HypervisorType.XenServer)) {
|
||||
label = publicTraffic.getXenNetworkLabel();
|
||||
} else if (hypervisorType.equals(HypervisorType.KVM)) {
|
||||
label = publicTraffic.getKvmNetworkLabel();
|
||||
} else if (hypervisorType.equals(HypervisorType.VMware)) {
|
||||
label = publicTraffic.getVmwareNetworkLabel();
|
||||
} else if (hypervisorType.equals(HypervisorType.Hyperv)) {
|
||||
label = publicTraffic.getHypervNetworkLabel();
|
||||
} else if (hypervisorType.equals(HypervisorType.Ovm3)) {
|
||||
label = publicTraffic.getOvm3NetworkLabel();
|
||||
}
|
||||
return label;
|
||||
}
|
||||
@ -1895,22 +1877,16 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel, Confi
|
||||
PhysicalNetworkTrafficTypeVO guestTraffic = _pNTrafficTypeDao.findBy(guestPhyNetwork.getId(), TrafficType.Guest);
|
||||
if (guestTraffic != null) {
|
||||
String label = null;
|
||||
switch (hypervisorType) {
|
||||
case XenServer:
|
||||
label = guestTraffic.getXenNetworkLabel();
|
||||
break;
|
||||
case KVM:
|
||||
label = guestTraffic.getKvmNetworkLabel();
|
||||
break;
|
||||
case VMware:
|
||||
label = guestTraffic.getVmwareNetworkLabel();
|
||||
break;
|
||||
case Hyperv:
|
||||
label = guestTraffic.getHypervNetworkLabel();
|
||||
break;
|
||||
case Ovm3:
|
||||
label = guestTraffic.getOvm3NetworkLabel();
|
||||
break;
|
||||
if (hypervisorType.equals(HypervisorType.XenServer)) {
|
||||
label = guestTraffic.getXenNetworkLabel();
|
||||
} else if (hypervisorType.equals(HypervisorType.KVM)) {
|
||||
label = guestTraffic.getKvmNetworkLabel();
|
||||
} else if (hypervisorType.equals(HypervisorType.VMware)) {
|
||||
label = guestTraffic.getVmwareNetworkLabel();
|
||||
} else if (hypervisorType.equals(HypervisorType.Hyperv)) {
|
||||
label = guestTraffic.getHypervNetworkLabel();
|
||||
} else if (hypervisorType.equals(HypervisorType.Ovm3)) {
|
||||
label = guestTraffic.getOvm3NetworkLabel();
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
@ -3094,24 +3094,16 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
||||
|
||||
private String getValidTemplateName(Long zoneId, HypervisorType hType) {
|
||||
String templateName = null;
|
||||
switch (hType) {
|
||||
case XenServer:
|
||||
templateName = VirtualNetworkApplianceManager.RouterTemplateXen.valueIn(zoneId);
|
||||
break;
|
||||
case KVM:
|
||||
templateName = VirtualNetworkApplianceManager.RouterTemplateKvm.valueIn(zoneId);
|
||||
break;
|
||||
case VMware:
|
||||
templateName = VirtualNetworkApplianceManager.RouterTemplateVmware.valueIn(zoneId);
|
||||
break;
|
||||
case Hyperv:
|
||||
templateName = VirtualNetworkApplianceManager.RouterTemplateHyperV.valueIn(zoneId);
|
||||
break;
|
||||
case LXC:
|
||||
templateName = VirtualNetworkApplianceManager.RouterTemplateLxc.valueIn(zoneId);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
if (hType.equals(HypervisorType.XenServer)) {
|
||||
templateName = VirtualNetworkApplianceManager.RouterTemplateXen.valueIn(zoneId);
|
||||
} else if (hType.equals(HypervisorType.KVM)) {
|
||||
templateName = VirtualNetworkApplianceManager.RouterTemplateKvm.valueIn(zoneId);
|
||||
} else if (hType.equals(HypervisorType.VMware)) {
|
||||
templateName = VirtualNetworkApplianceManager.RouterTemplateVmware.valueIn(zoneId);
|
||||
} else if (hType.equals(HypervisorType.Hyperv)) {
|
||||
templateName = VirtualNetworkApplianceManager.RouterTemplateHyperV.valueIn(zoneId);
|
||||
} else if (hType.equals(HypervisorType.LXC)) {
|
||||
templateName = VirtualNetworkApplianceManager.RouterTemplateLxc.valueIn(zoneId);
|
||||
}
|
||||
return templateName;
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
package com.cloud.template;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -81,6 +82,7 @@ import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.vm.UserVmVO;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public abstract class TemplateAdapterBase extends AdapterBase implements TemplateAdapter {
|
||||
protected @Inject
|
||||
@ -285,8 +287,10 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat
|
||||
|
||||
HypervisorType hypervisorType = HypervisorType.getType(cmd.getHypervisor());
|
||||
if(hypervisorType == HypervisorType.None) {
|
||||
throw new InvalidParameterValueException("Hypervisor Type: " + cmd.getHypervisor() + " is invalid. Supported Hypervisor types are "
|
||||
+ EnumUtils.listValues(HypervisorType.values()).replace("None, ", ""));
|
||||
throw new InvalidParameterValueException(String.format(
|
||||
"Hypervisor Type: %s is invalid. Supported Hypervisor types are: %s",
|
||||
cmd.getHypervisor(),
|
||||
StringUtils.join(Arrays.stream(HypervisorType.values()).filter(h -> h != HypervisorType.None).map(HypervisorType::name).toArray(), ", ")));
|
||||
}
|
||||
|
||||
Map details = cmd.getDetails();
|
||||
@ -327,8 +331,10 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat
|
||||
}
|
||||
|
||||
if(!params.isIso() && params.getHypervisorType() == HypervisorType.None) {
|
||||
throw new InvalidParameterValueException("Hypervisor Type: " + params.getHypervisorType() + " is invalid. Supported Hypervisor types are "
|
||||
+ EnumUtils.listValues(HypervisorType.values()).replace("None, ", ""));
|
||||
throw new InvalidParameterValueException(String.format(
|
||||
"Hypervisor Type: %s is invalid. Supported Hypervisor types are: %s",
|
||||
params.getHypervisorType(),
|
||||
StringUtils.join(Arrays.stream(HypervisorType.values()).filter(h -> h != HypervisorType.None).map(HypervisorType::name).toArray(), ", ")));
|
||||
}
|
||||
|
||||
return prepare(params.isIso(), params.getUserId(), params.getName(), params.getDisplayText(), params.getBits(),
|
||||
|
||||
@ -6359,19 +6359,15 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
String decodedUrl = decodeExtraConfig(extraConfig);
|
||||
HypervisorType hypervisorType = vm.getHypervisorType();
|
||||
|
||||
switch (hypervisorType) {
|
||||
case XenServer:
|
||||
persistExtraConfigXenServer(decodedUrl, vm);
|
||||
break;
|
||||
case KVM:
|
||||
persistExtraConfigKvm(decodedUrl, vm);
|
||||
break;
|
||||
case VMware:
|
||||
persistExtraConfigVmware(decodedUrl, vm);
|
||||
break;
|
||||
default:
|
||||
String msg = String.format("This hypervisor %s is not supported for use with this feature", hypervisorType.toString());
|
||||
throw new CloudRuntimeException(msg);
|
||||
if (hypervisorType.equals(HypervisorType.XenServer)) {
|
||||
persistExtraConfigXenServer(decodedUrl, vm);
|
||||
} else if (hypervisorType.equals(HypervisorType.KVM)) {
|
||||
persistExtraConfigKvm(decodedUrl, vm);
|
||||
} else if (hypervisorType.equals(HypervisorType.VMware)) {
|
||||
persistExtraConfigVmware(decodedUrl, vm);
|
||||
} else {
|
||||
String msg = String.format("This hypervisor %s is not supported for use with this feature", hypervisorType.toString());
|
||||
throw new CloudRuntimeException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user