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