mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Merge pull request #1049 from DaanHoogland/CLOUDSTACK-9047
CLOUDSTACK-9047 rename enumsmake enums adhere to best practice naming conventions * pr/1049: CLOUDSTACK-9046 rename enums to adhere to naming conventions CLOUDSTACK-9046 renamed enums in kvm plugin CLOUDSTACK-9047 use 'State's only with context there are more types called 'State' (or to be called so but now 'state') So remove imports and prepend their enclosing class/context to them. Signed-off-by: Daan Hoogland <daan@onecht.net>
This commit is contained in:
commit
638f1cf091
@ -24,7 +24,7 @@ public class GPU {
|
||||
vgpuType
|
||||
}
|
||||
|
||||
public enum vGPUType {
|
||||
public enum GPUType {
|
||||
GRID_K100("GRID K100"),
|
||||
GRID_K120Q("GRID K120Q"),
|
||||
GRID_K140Q("GRID K140Q"),
|
||||
@ -36,7 +36,7 @@ public class GPU {
|
||||
|
||||
private String type;
|
||||
|
||||
vGPUType(String type) {
|
||||
GPUType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ public interface NicIpAlias extends ControlledEntity, Identity, InternalIdentity
|
||||
/**
|
||||
* @return id in the CloudStack database
|
||||
*/
|
||||
enum state {
|
||||
enum State {
|
||||
active, revoked,
|
||||
}
|
||||
|
||||
|
||||
@ -96,7 +96,6 @@ import com.cloud.host.Status;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.IpAddress;
|
||||
import com.cloud.network.IpAddress.State;
|
||||
import com.cloud.network.IpAddressManager;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Capability;
|
||||
@ -1755,9 +1754,9 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
|
||||
Network network = _networksDao.findById(nic.getNetworkId());
|
||||
DhcpServiceProvider dhcpServiceProvider = getDhcpServiceProvider(network);
|
||||
try {
|
||||
final NicIpAliasVO ipAlias = _nicIpAliasDao.findByGatewayAndNetworkIdAndState(nic.getIPv4Gateway(), network.getId(), NicIpAlias.state.active);
|
||||
final NicIpAliasVO ipAlias = _nicIpAliasDao.findByGatewayAndNetworkIdAndState(nic.getIPv4Gateway(), network.getId(), NicIpAlias.State.active);
|
||||
if (ipAlias != null) {
|
||||
ipAlias.setState(NicIpAlias.state.revoked);
|
||||
ipAlias.setState(NicIpAlias.State.revoked);
|
||||
Transaction.execute(new TransactionCallbackNoReturn() {
|
||||
@Override
|
||||
public void doInTransactionWithoutResult(TransactionStatus status) {
|
||||
@ -2919,7 +2918,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
|
||||
List<PublicIp> publicIpsToRelease = new ArrayList<PublicIp>();
|
||||
if (userIps != null && !userIps.isEmpty()) {
|
||||
for (IPAddressVO userIp : userIps) {
|
||||
userIp.setState(State.Releasing);
|
||||
userIp.setState(IpAddress.State.Releasing);
|
||||
PublicIp publicIp = PublicIp.createFromAddrAndVlan(userIp, _vlanDao.findById(userIp.getVlanId()));
|
||||
publicIpsToRelease.add(publicIp);
|
||||
}
|
||||
|
||||
@ -54,8 +54,8 @@ public interface NicIpAliasDao extends GenericDao<NicIpAliasVO, Long> {
|
||||
|
||||
public NicIpAliasVO findByIp4AddressAndVmId(String ip4Address, long vmId);
|
||||
|
||||
NicIpAliasVO findByGatewayAndNetworkIdAndState(String gateway, long networkId, NicIpAlias.state state);
|
||||
NicIpAliasVO findByGatewayAndNetworkIdAndState(String gateway, long networkId, NicIpAlias.State state);
|
||||
|
||||
List<NicIpAliasVO> listByNetworkIdAndState(long networkId, NicIpAlias.state state);
|
||||
List<NicIpAliasVO> listByNetworkIdAndState(long networkId, NicIpAlias.State state);
|
||||
|
||||
}
|
||||
@ -82,7 +82,7 @@ public class NicIpAliasDaoImpl extends GenericDaoBase<NicIpAliasVO, Long> implem
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NicIpAliasVO> listByNetworkIdAndState(long networkId, NicIpAlias.state state) {
|
||||
public List<NicIpAliasVO> listByNetworkIdAndState(long networkId, NicIpAlias.State state) {
|
||||
SearchCriteria<NicIpAliasVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("network", networkId);
|
||||
sc.setParameters("state", state);
|
||||
@ -101,7 +101,7 @@ public class NicIpAliasDaoImpl extends GenericDaoBase<NicIpAliasVO, Long> implem
|
||||
public List<NicIpAliasVO> getAliasIpForVm(long vmId) {
|
||||
SearchCriteria<NicIpAliasVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("instanceId", vmId);
|
||||
sc.setParameters("state", NicIpAlias.state.active);
|
||||
sc.setParameters("state", NicIpAlias.State.active);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ public class NicIpAliasDaoImpl extends GenericDaoBase<NicIpAliasVO, Long> implem
|
||||
SearchCriteria<NicIpAliasVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("network", networkId);
|
||||
sc.setParameters("instanceId", instanceId);
|
||||
sc.setParameters("state", NicIpAlias.state.active);
|
||||
sc.setParameters("state", NicIpAlias.State.active);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@ -132,7 +132,7 @@ public class NicIpAliasDaoImpl extends GenericDaoBase<NicIpAliasVO, Long> implem
|
||||
}
|
||||
|
||||
@Override
|
||||
public NicIpAliasVO findByGatewayAndNetworkIdAndState(String gateway, long networkId, NicIpAlias.state state) {
|
||||
public NicIpAliasVO findByGatewayAndNetworkIdAndState(String gateway, long networkId, NicIpAlias.State state) {
|
||||
SearchCriteria<NicIpAliasVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("gateway", gateway);
|
||||
sc.setParameters("network", networkId);
|
||||
|
||||
@ -45,7 +45,7 @@ public class NicIpAliasVO implements NicIpAlias {
|
||||
this.networkId = networkId;
|
||||
this.netmask = netmask;
|
||||
this.gateway = gateway;
|
||||
state = NicIpAlias.state.active;
|
||||
state = NicIpAlias.State.active;
|
||||
String cidr = NetUtils.getCidrFromGatewayAndNetmask(gateway, netmask);
|
||||
String[] cidrPair = cidr.split("\\/");
|
||||
String cidrAddress = cidrPair[0];
|
||||
@ -99,7 +99,7 @@ public class NicIpAliasVO implements NicIpAlias {
|
||||
|
||||
@Column(name = "state")
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
NicIpAlias.state state;
|
||||
NicIpAlias.State state;
|
||||
|
||||
@Column(name = "start_ip_of_subnet")
|
||||
String startIpOfSubnet;
|
||||
@ -220,11 +220,11 @@ public class NicIpAliasVO implements NicIpAlias {
|
||||
this.gateway = gateway;
|
||||
}
|
||||
|
||||
public NicIpAlias.state getState() {
|
||||
public NicIpAlias.State getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(NicIpAlias.state state) {
|
||||
public void setState(NicIpAlias.State state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
|
||||
@ -20,13 +20,13 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LibvirtNetworkDef {
|
||||
enum netType {
|
||||
enum NetworkType {
|
||||
BRIDGE, NAT, LOCAL
|
||||
}
|
||||
|
||||
private final String _networkName;
|
||||
private final String _uuid;
|
||||
private netType _networkType;
|
||||
private NetworkType _networkType;
|
||||
private String _brName;
|
||||
private boolean _stp;
|
||||
private int _delay;
|
||||
@ -66,7 +66,7 @@ public class LibvirtNetworkDef {
|
||||
}
|
||||
|
||||
public void defNATNetwork(String brName, boolean stp, int delay, String fwNic, String ipAddr, String netMask) {
|
||||
_networkType = netType.NAT;
|
||||
_networkType = NetworkType.NAT;
|
||||
_brName = brName;
|
||||
_stp = stp;
|
||||
_delay = delay;
|
||||
@ -76,7 +76,7 @@ public class LibvirtNetworkDef {
|
||||
}
|
||||
|
||||
public void defBrNetwork(String brName, boolean stp, int delay, String fwNic, String ipAddr, String netMask) {
|
||||
_networkType = netType.BRIDGE;
|
||||
_networkType = NetworkType.BRIDGE;
|
||||
_brName = brName;
|
||||
_stp = stp;
|
||||
_delay = delay;
|
||||
@ -86,7 +86,7 @@ public class LibvirtNetworkDef {
|
||||
}
|
||||
|
||||
public void defLocalNetwork(String brName, boolean stp, int delay, String ipAddr, String netMask) {
|
||||
_networkType = netType.LOCAL;
|
||||
_networkType = NetworkType.LOCAL;
|
||||
_brName = brName;
|
||||
_stp = stp;
|
||||
_delay = delay;
|
||||
@ -126,13 +126,13 @@ public class LibvirtNetworkDef {
|
||||
if (_domainName != null) {
|
||||
netBuilder.append("<domain name='" + _domainName + "'/>\n");
|
||||
}
|
||||
if (_networkType == netType.BRIDGE) {
|
||||
if (_networkType == NetworkType.BRIDGE) {
|
||||
netBuilder.append("<forward mode='route'");
|
||||
if (_fwDev != null) {
|
||||
netBuilder.append(" dev='" + _fwDev + "'");
|
||||
}
|
||||
netBuilder.append("/>\n");
|
||||
} else if (_networkType == netType.NAT) {
|
||||
} else if (_networkType == NetworkType.NAT) {
|
||||
netBuilder.append("<forward mode='nat'");
|
||||
if (_fwDev != null) {
|
||||
netBuilder.append(" dev='" + _fwDev + "'");
|
||||
|
||||
@ -18,11 +18,11 @@ package com.cloud.hypervisor.kvm.resource;
|
||||
|
||||
public class LibvirtSecretDef {
|
||||
|
||||
public enum usage {
|
||||
public enum Usage {
|
||||
VOLUME("volume"), CEPH("ceph");
|
||||
String _usage;
|
||||
|
||||
usage(String usage) {
|
||||
Usage(String usage) {
|
||||
_usage = usage;
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ public class LibvirtSecretDef {
|
||||
}
|
||||
}
|
||||
|
||||
private usage _usage;
|
||||
private Usage _usage;
|
||||
private boolean _ephemeral;
|
||||
private boolean _private;
|
||||
private String _uuid;
|
||||
@ -40,12 +40,12 @@ public class LibvirtSecretDef {
|
||||
private String _cephName;
|
||||
private String _volumeVolume;
|
||||
|
||||
public LibvirtSecretDef(usage usage, String uuid) {
|
||||
public LibvirtSecretDef(Usage usage, String uuid) {
|
||||
_usage = usage;
|
||||
_uuid = uuid;
|
||||
}
|
||||
|
||||
public LibvirtSecretDef(usage usage, String uuid, String description) {
|
||||
public LibvirtSecretDef(Usage usage, String uuid, String description) {
|
||||
_usage = usage;
|
||||
_uuid = uuid;
|
||||
_description = description;
|
||||
@ -92,10 +92,10 @@ public class LibvirtSecretDef {
|
||||
secretBuilder.append("<description>" + _description + "</description>\n");
|
||||
}
|
||||
secretBuilder.append("<usage type='" + _usage + "'>\n");
|
||||
if (_usage == usage.VOLUME) {
|
||||
if (_usage == Usage.VOLUME) {
|
||||
secretBuilder.append("<volume>" + _volumeVolume + "</volume>\n");
|
||||
}
|
||||
if (_usage == usage.CEPH) {
|
||||
if (_usage == Usage.CEPH) {
|
||||
secretBuilder.append("<name>" + _cephName + "</name>\n");
|
||||
}
|
||||
secretBuilder.append("</usage>\n");
|
||||
|
||||
@ -17,11 +17,11 @@
|
||||
package com.cloud.hypervisor.kvm.resource;
|
||||
|
||||
public class LibvirtStoragePoolDef {
|
||||
public enum poolType {
|
||||
public enum PoolType {
|
||||
ISCSI("iscsi"), NETFS("netfs"), LOGICAL("logical"), DIR("dir"), RBD("rbd"), GLUSTERFS("glusterfs");
|
||||
String _poolType;
|
||||
|
||||
poolType(String poolType) {
|
||||
PoolType(String poolType) {
|
||||
_poolType = poolType;
|
||||
}
|
||||
|
||||
@ -31,11 +31,11 @@ public class LibvirtStoragePoolDef {
|
||||
}
|
||||
}
|
||||
|
||||
public enum authType {
|
||||
public enum AuthenticationType {
|
||||
CHAP("chap"), CEPH("ceph");
|
||||
String _authType;
|
||||
|
||||
authType(String authType) {
|
||||
AuthenticationType(String authType) {
|
||||
_authType = authType;
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ public class LibvirtStoragePoolDef {
|
||||
}
|
||||
}
|
||||
|
||||
private poolType _poolType;
|
||||
private PoolType _poolType;
|
||||
private String _poolName;
|
||||
private String _uuid;
|
||||
private String _sourceHost;
|
||||
@ -53,10 +53,10 @@ public class LibvirtStoragePoolDef {
|
||||
private String _sourceDir;
|
||||
private String _targetPath;
|
||||
private String _authUsername;
|
||||
private authType _authType;
|
||||
private AuthenticationType _authType;
|
||||
private String _secretUuid;
|
||||
|
||||
public LibvirtStoragePoolDef(poolType type, String poolName, String uuid, String host, int port, String dir, String targetPath) {
|
||||
public LibvirtStoragePoolDef(PoolType type, String poolName, String uuid, String host, int port, String dir, String targetPath) {
|
||||
_poolType = type;
|
||||
_poolName = poolName;
|
||||
_uuid = uuid;
|
||||
@ -66,7 +66,7 @@ public class LibvirtStoragePoolDef {
|
||||
_targetPath = targetPath;
|
||||
}
|
||||
|
||||
public LibvirtStoragePoolDef(poolType type, String poolName, String uuid, String host, String dir, String targetPath) {
|
||||
public LibvirtStoragePoolDef(PoolType type, String poolName, String uuid, String host, String dir, String targetPath) {
|
||||
_poolType = type;
|
||||
_poolName = poolName;
|
||||
_uuid = uuid;
|
||||
@ -75,7 +75,7 @@ public class LibvirtStoragePoolDef {
|
||||
_targetPath = targetPath;
|
||||
}
|
||||
|
||||
public LibvirtStoragePoolDef(poolType type, String poolName, String uuid, String sourceHost, int sourcePort, String dir, String authUsername, authType authType,
|
||||
public LibvirtStoragePoolDef(PoolType type, String poolName, String uuid, String sourceHost, int sourcePort, String dir, String authUsername, AuthenticationType authType,
|
||||
String secretUuid) {
|
||||
_poolType = type;
|
||||
_poolName = poolName;
|
||||
@ -92,7 +92,7 @@ public class LibvirtStoragePoolDef {
|
||||
return _poolName;
|
||||
}
|
||||
|
||||
public poolType getPoolType() {
|
||||
public PoolType getPoolType() {
|
||||
return _poolType;
|
||||
}
|
||||
|
||||
@ -120,14 +120,14 @@ public class LibvirtStoragePoolDef {
|
||||
return _secretUuid;
|
||||
}
|
||||
|
||||
public authType getAuthType() {
|
||||
public AuthenticationType getAuthType() {
|
||||
return _authType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder storagePoolBuilder = new StringBuilder();
|
||||
if (_poolType == poolType.GLUSTERFS) {
|
||||
if (_poolType == PoolType.GLUSTERFS) {
|
||||
/* libvirt mounts a Gluster volume, similar to NFS */
|
||||
storagePoolBuilder.append("<pool type='netfs'>\n");
|
||||
} else {
|
||||
@ -139,13 +139,13 @@ public class LibvirtStoragePoolDef {
|
||||
storagePoolBuilder.append("<name>" + _poolName + "</name>\n");
|
||||
if (_uuid != null)
|
||||
storagePoolBuilder.append("<uuid>" + _uuid + "</uuid>\n");
|
||||
if (_poolType == poolType.NETFS) {
|
||||
if (_poolType == PoolType.NETFS) {
|
||||
storagePoolBuilder.append("<source>\n");
|
||||
storagePoolBuilder.append("<host name='" + _sourceHost + "'/>\n");
|
||||
storagePoolBuilder.append("<dir path='" + _sourceDir + "'/>\n");
|
||||
storagePoolBuilder.append("</source>\n");
|
||||
}
|
||||
if (_poolType == poolType.RBD) {
|
||||
if (_poolType == PoolType.RBD) {
|
||||
storagePoolBuilder.append("<source>\n");
|
||||
storagePoolBuilder.append("<host name='" + _sourceHost + "' port='" + _sourcePort + "'/>\n");
|
||||
storagePoolBuilder.append("<name>" + _sourceDir + "</name>\n");
|
||||
@ -156,7 +156,7 @@ public class LibvirtStoragePoolDef {
|
||||
}
|
||||
storagePoolBuilder.append("</source>\n");
|
||||
}
|
||||
if (_poolType == poolType.GLUSTERFS) {
|
||||
if (_poolType == PoolType.GLUSTERFS) {
|
||||
storagePoolBuilder.append("<source>\n");
|
||||
storagePoolBuilder.append("<host name='");
|
||||
storagePoolBuilder.append(_sourceHost);
|
||||
@ -173,7 +173,7 @@ public class LibvirtStoragePoolDef {
|
||||
storagePoolBuilder.append("'/>\n");
|
||||
storagePoolBuilder.append("</source>\n");
|
||||
}
|
||||
if (_poolType != poolType.RBD) {
|
||||
if (_poolType != PoolType.RBD) {
|
||||
storagePoolBuilder.append("<target>\n");
|
||||
storagePoolBuilder.append("<path>" + _targetPath + "</path>\n");
|
||||
storagePoolBuilder.append("</target>\n");
|
||||
|
||||
@ -63,10 +63,10 @@ public class LibvirtStoragePoolXMLParser {
|
||||
if (auth != null) {
|
||||
String authUsername = auth.getAttribute("username");
|
||||
String authType = auth.getAttribute("type");
|
||||
return new LibvirtStoragePoolDef(LibvirtStoragePoolDef.poolType.valueOf(type.toUpperCase()), poolName, uuid, host, port, pool, authUsername,
|
||||
LibvirtStoragePoolDef.authType.valueOf(authType.toUpperCase()), uuid);
|
||||
return new LibvirtStoragePoolDef(LibvirtStoragePoolDef.PoolType.valueOf(type.toUpperCase()), poolName, uuid, host, port, pool, authUsername,
|
||||
LibvirtStoragePoolDef.AuthenticationType.valueOf(authType.toUpperCase()), uuid);
|
||||
} else {
|
||||
return new LibvirtStoragePoolDef(LibvirtStoragePoolDef.poolType.valueOf(type.toUpperCase()), poolName, uuid, host, port, pool, "");
|
||||
return new LibvirtStoragePoolDef(LibvirtStoragePoolDef.PoolType.valueOf(type.toUpperCase()), poolName, uuid, host, port, pool, "");
|
||||
}
|
||||
/* Gluster is a sub-type of LibvirtStoragePoolDef.poolType.NETFS, need to check format */
|
||||
} else if (format != null && format.equalsIgnoreCase("glusterfs")) {
|
||||
@ -83,7 +83,7 @@ public class LibvirtStoragePoolXMLParser {
|
||||
if (portValue != null && !portValue.isEmpty())
|
||||
port = Integer.parseInt(portValue);
|
||||
|
||||
return new LibvirtStoragePoolDef(LibvirtStoragePoolDef.poolType.valueOf(format.toUpperCase()),
|
||||
return new LibvirtStoragePoolDef(LibvirtStoragePoolDef.PoolType.valueOf(format.toUpperCase()),
|
||||
poolName, uuid, host, port, path, targetPath);
|
||||
} else {
|
||||
String path = getAttrValue("dir", "path", source);
|
||||
@ -91,7 +91,7 @@ public class LibvirtStoragePoolXMLParser {
|
||||
Element target = (Element)rootElement.getElementsByTagName("target").item(0);
|
||||
String targetPath = getTagValue("path", target);
|
||||
|
||||
return new LibvirtStoragePoolDef(LibvirtStoragePoolDef.poolType.valueOf(type.toUpperCase()), poolName, uuid, host, path, targetPath);
|
||||
return new LibvirtStoragePoolDef(LibvirtStoragePoolDef.PoolType.valueOf(type.toUpperCase()), poolName, uuid, host, path, targetPath);
|
||||
}
|
||||
} catch (ParserConfigurationException e) {
|
||||
s_logger.debug(e.toString());
|
||||
|
||||
@ -20,11 +20,11 @@ import org.apache.cloudstack.utils.qemu.QemuImg;
|
||||
import org.apache.commons.lang.NotImplementedException;
|
||||
|
||||
public class LibvirtStorageVolumeDef {
|
||||
public enum volFormat {
|
||||
public enum VolumeFormat {
|
||||
RAW("raw"), QCOW2("qcow2"), DIR("dir"), TAR("tar");
|
||||
private String _format;
|
||||
|
||||
volFormat(String format) {
|
||||
VolumeFormat(String format) {
|
||||
_format = format;
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ public class LibvirtStorageVolumeDef {
|
||||
return _format;
|
||||
}
|
||||
|
||||
public static volFormat getFormat(String format) {
|
||||
public static VolumeFormat getFormat(String format) {
|
||||
if (format == null) {
|
||||
return null;
|
||||
}
|
||||
@ -49,7 +49,7 @@ public class LibvirtStorageVolumeDef {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static volFormat getFormat(QemuImg.PhysicalDiskFormat format){
|
||||
public static VolumeFormat getFormat(QemuImg.PhysicalDiskFormat format){
|
||||
switch (format){
|
||||
case RAW:
|
||||
return RAW;
|
||||
@ -67,11 +67,11 @@ public class LibvirtStorageVolumeDef {
|
||||
|
||||
private String _volName;
|
||||
private Long _volSize;
|
||||
private volFormat _volFormat;
|
||||
private VolumeFormat _volFormat;
|
||||
private String _backingPath;
|
||||
private volFormat _backingFormat;
|
||||
private VolumeFormat _backingFormat;
|
||||
|
||||
public LibvirtStorageVolumeDef(String volName, Long size, volFormat format, String tmplPath, volFormat tmplFormat) {
|
||||
public LibvirtStorageVolumeDef(String volName, Long size, VolumeFormat format, String tmplPath, VolumeFormat tmplFormat) {
|
||||
_volName = volName;
|
||||
_volSize = size;
|
||||
_volFormat = format;
|
||||
@ -79,7 +79,7 @@ public class LibvirtStorageVolumeDef {
|
||||
_backingFormat = tmplFormat;
|
||||
}
|
||||
|
||||
public volFormat getFormat() {
|
||||
public VolumeFormat getFormat() {
|
||||
return this._volFormat;
|
||||
}
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@ public class LibvirtStorageVolumeXMLParser {
|
||||
Element target = (Element)rootElement.getElementsByTagName("target").item(0);
|
||||
String format = getAttrValue("type", "format", target);
|
||||
Long capacity = Long.parseLong(getTagValue("capacity", rootElement));
|
||||
return new LibvirtStorageVolumeDef(VolName, capacity, LibvirtStorageVolumeDef.volFormat.getFormat(format), null, null);
|
||||
return new LibvirtStorageVolumeDef(VolName, capacity, LibvirtStorageVolumeDef.VolumeFormat.getFormat(format), null, null);
|
||||
} catch (ParserConfigurationException e) {
|
||||
s_logger.debug(e.toString());
|
||||
} catch (SAXException e) {
|
||||
|
||||
@ -50,13 +50,13 @@ import org.apache.cloudstack.utils.qemu.QemuImgFile;
|
||||
import com.cloud.exception.InternalErrorException;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtConnection;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtSecretDef;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtSecretDef.usage;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtSecretDef.Usage;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtStoragePoolDef;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtStoragePoolDef.authType;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtStoragePoolDef.poolType;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtStoragePoolDef.AuthenticationType;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtStoragePoolDef.PoolType;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtStoragePoolXMLParser;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtStorageVolumeDef;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtStorageVolumeDef.volFormat;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtStorageVolumeDef.VolumeFormat;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtStorageVolumeXMLParser;
|
||||
import com.cloud.storage.Storage;
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
@ -122,7 +122,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
||||
return vol;
|
||||
}
|
||||
|
||||
public StorageVol createVolume(Connect conn, StoragePool pool, String uuid, long size, volFormat format) throws LibvirtException {
|
||||
public StorageVol createVolume(Connect conn, StoragePool pool, String uuid, long size, VolumeFormat format) throws LibvirtException {
|
||||
LibvirtStorageVolumeDef volDef = new LibvirtStorageVolumeDef(UUID.randomUUID().toString(), size, format, null, null);
|
||||
s_logger.debug(volDef.toString());
|
||||
|
||||
@ -139,7 +139,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
||||
}
|
||||
}
|
||||
|
||||
private StoragePool createNetfsStoragePool(poolType fsType, Connect conn, String uuid, String host, String path) throws LibvirtException {
|
||||
private StoragePool createNetfsStoragePool(PoolType fsType, Connect conn, String uuid, String host, String path) throws LibvirtException {
|
||||
String targetPath = _mountPoint + File.separator + uuid;
|
||||
LibvirtStoragePoolDef spd = new LibvirtStoragePoolDef(fsType, uuid, uuid, host, path, targetPath);
|
||||
_storageLayer.mkdir(targetPath);
|
||||
@ -193,7 +193,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
||||
s_logger.error(mountPoint + " does not exists. Check local.storage.path in agent.properties.");
|
||||
return null;
|
||||
}
|
||||
LibvirtStoragePoolDef spd = new LibvirtStoragePoolDef(poolType.DIR, uuid, uuid, host, path, path);
|
||||
LibvirtStoragePoolDef spd = new LibvirtStoragePoolDef(PoolType.DIR, uuid, uuid, host, path, path);
|
||||
StoragePool sp = null;
|
||||
try {
|
||||
s_logger.debug(spd.toString());
|
||||
@ -224,7 +224,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
||||
String volgroupName = path;
|
||||
volgroupName = volgroupName.replaceFirst("/", "");
|
||||
|
||||
LibvirtStoragePoolDef spd = new LibvirtStoragePoolDef(poolType.LOGICAL, volgroupName, uuid, host, volgroupPath, volgroupPath);
|
||||
LibvirtStoragePoolDef spd = new LibvirtStoragePoolDef(PoolType.LOGICAL, volgroupName, uuid, host, volgroupPath, volgroupPath);
|
||||
StoragePool sp = null;
|
||||
try {
|
||||
s_logger.debug(spd.toString());
|
||||
@ -258,7 +258,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
||||
|
||||
String[] userInfoTemp = userInfo.split(":");
|
||||
if (userInfoTemp.length == 2) {
|
||||
LibvirtSecretDef sd = new LibvirtSecretDef(usage.CEPH, uuid);
|
||||
LibvirtSecretDef sd = new LibvirtSecretDef(Usage.CEPH, uuid);
|
||||
|
||||
sd.setCephName(userInfoTemp[0] + "@" + host + ":" + port + "/" + path);
|
||||
|
||||
@ -278,9 +278,9 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
spd = new LibvirtStoragePoolDef(poolType.RBD, uuid, uuid, host, port, path, userInfoTemp[0], authType.CEPH, uuid);
|
||||
spd = new LibvirtStoragePoolDef(PoolType.RBD, uuid, uuid, host, port, path, userInfoTemp[0], AuthenticationType.CEPH, uuid);
|
||||
} else {
|
||||
spd = new LibvirtStoragePoolDef(poolType.RBD, uuid, uuid, host, port, path, "");
|
||||
spd = new LibvirtStoragePoolDef(PoolType.RBD, uuid, uuid, host, port, path, "");
|
||||
}
|
||||
|
||||
try {
|
||||
@ -368,15 +368,15 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
||||
throw new CloudRuntimeException("Unable to parse the storage pool definition for storage pool " + uuid);
|
||||
}
|
||||
StoragePoolType type = null;
|
||||
if (spd.getPoolType() == LibvirtStoragePoolDef.poolType.NETFS) {
|
||||
if (spd.getPoolType() == LibvirtStoragePoolDef.PoolType.NETFS) {
|
||||
type = StoragePoolType.NetworkFilesystem;
|
||||
} else if (spd.getPoolType() == LibvirtStoragePoolDef.poolType.DIR) {
|
||||
} else if (spd.getPoolType() == LibvirtStoragePoolDef.PoolType.DIR) {
|
||||
type = StoragePoolType.Filesystem;
|
||||
} else if (spd.getPoolType() == LibvirtStoragePoolDef.poolType.RBD) {
|
||||
} else if (spd.getPoolType() == LibvirtStoragePoolDef.PoolType.RBD) {
|
||||
type = StoragePoolType.RBD;
|
||||
} else if (spd.getPoolType() == LibvirtStoragePoolDef.poolType.LOGICAL) {
|
||||
} else if (spd.getPoolType() == LibvirtStoragePoolDef.PoolType.LOGICAL) {
|
||||
type = StoragePoolType.CLVM;
|
||||
} else if (spd.getPoolType() == LibvirtStoragePoolDef.poolType.GLUSTERFS) {
|
||||
} else if (spd.getPoolType() == LibvirtStoragePoolDef.PoolType.GLUSTERFS) {
|
||||
type = StoragePoolType.Gluster;
|
||||
}
|
||||
|
||||
@ -462,9 +462,9 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
||||
} else {
|
||||
disk.setFormat(pool.getDefaultFormat());
|
||||
}
|
||||
} else if (voldef.getFormat() == LibvirtStorageVolumeDef.volFormat.QCOW2) {
|
||||
} else if (voldef.getFormat() == LibvirtStorageVolumeDef.VolumeFormat.QCOW2) {
|
||||
disk.setFormat(PhysicalDiskFormat.QCOW2);
|
||||
} else if (voldef.getFormat() == LibvirtStorageVolumeDef.volFormat.RAW) {
|
||||
} else if (voldef.getFormat() == LibvirtStorageVolumeDef.VolumeFormat.RAW) {
|
||||
disk.setFormat(PhysicalDiskFormat.RAW);
|
||||
}
|
||||
return disk;
|
||||
@ -542,7 +542,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
||||
|
||||
if (type == StoragePoolType.NetworkFilesystem) {
|
||||
try {
|
||||
sp = createNetfsStoragePool(poolType.NETFS, conn, name, host, path);
|
||||
sp = createNetfsStoragePool(PoolType.NETFS, conn, name, host, path);
|
||||
} catch (LibvirtException e) {
|
||||
s_logger.error("Failed to create netfs mount: " + host + ":" + path , e);
|
||||
s_logger.error(e.getStackTrace());
|
||||
@ -550,7 +550,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
||||
}
|
||||
} else if (type == StoragePoolType.Gluster) {
|
||||
try {
|
||||
sp = createNetfsStoragePool(poolType.GLUSTERFS, conn, name, host, path);
|
||||
sp = createNetfsStoragePool(PoolType.GLUSTERFS, conn, name, host, path);
|
||||
} catch (LibvirtException e) {
|
||||
s_logger.error("Failed to create glusterfs mount: " + host + ":" + path , e);
|
||||
s_logger.error(e.getStackTrace());
|
||||
@ -684,7 +684,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
||||
PhysicalDiskFormat format, Storage.ProvisioningType provisioningType, long size) {
|
||||
LibvirtStoragePool libvirtPool = (LibvirtStoragePool) pool;
|
||||
StoragePool virtPool = libvirtPool.getPool();
|
||||
LibvirtStorageVolumeDef.volFormat libvirtformat = LibvirtStorageVolumeDef.volFormat.getFormat(format);
|
||||
LibvirtStorageVolumeDef.VolumeFormat libvirtformat = LibvirtStorageVolumeDef.VolumeFormat.getFormat(format);
|
||||
|
||||
String volPath = null;
|
||||
String volName = null;
|
||||
|
||||
@ -32,7 +32,7 @@ import org.libvirt.StorageVol;
|
||||
import com.cloud.agent.api.to.DiskTO;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtConnection;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtStoragePoolDef;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtStoragePoolDef.poolType;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtStoragePoolDef.PoolType;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtStorageVolumeDef;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtStorageVolumeXMLParser;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
@ -105,7 +105,7 @@ public class ManagedNfsStorageAdaptor implements StorageAdaptor {
|
||||
}
|
||||
|
||||
targetPath = "/mnt" + volumeUuid;
|
||||
spd = new LibvirtStoragePoolDef(poolType.NETFS, volumeUuid, details.get(DiskTO.UUID), pool.getSourceHost(), details.get(DiskTO.MOUNT_POINT), targetPath);
|
||||
spd = new LibvirtStoragePoolDef(PoolType.NETFS, volumeUuid, details.get(DiskTO.UUID), pool.getSourceHost(), details.get(DiskTO.MOUNT_POINT), targetPath);
|
||||
_storageLayer.mkdir(targetPath);
|
||||
|
||||
s_logger.debug(spd.toString());
|
||||
@ -178,14 +178,14 @@ public class ManagedNfsStorageAdaptor implements StorageAdaptor {
|
||||
throw new CloudRuntimeException(e1.toString());
|
||||
}
|
||||
|
||||
LibvirtStorageVolumeDef.volFormat libvirtformat = null;
|
||||
LibvirtStorageVolumeDef.VolumeFormat libvirtformat = null;
|
||||
long volCapacity = 0;
|
||||
// check whether the volume is present on the given pool
|
||||
StorageVol vol = getVolume(virtPool, volumeUuid);
|
||||
try {
|
||||
if (vol == null) {
|
||||
|
||||
libvirtformat = LibvirtStorageVolumeDef.volFormat.QCOW2;
|
||||
libvirtformat = LibvirtStorageVolumeDef.VolumeFormat.QCOW2;
|
||||
|
||||
StoragePoolInfo poolinfo = virtPool.getInfo();
|
||||
volCapacity = poolinfo.available;
|
||||
|
||||
@ -20,14 +20,14 @@
|
||||
package com.cloud.hypervisor.kvm.resource;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtSecretDef.usage;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtSecretDef.Usage;
|
||||
|
||||
public class LibvirtSecretDefTest extends TestCase {
|
||||
|
||||
public void testVolumeSecretDef() {
|
||||
String uuid = "db66f42b-a79e-4666-9910-9dfc8a024427";
|
||||
String name = "myEncryptedQCOW2";
|
||||
usage use = usage.VOLUME;
|
||||
Usage use = Usage.VOLUME;
|
||||
|
||||
LibvirtSecretDef def = new LibvirtSecretDef(use, uuid);
|
||||
def.setVolumeVolume(name);
|
||||
@ -41,7 +41,7 @@ public class LibvirtSecretDefTest extends TestCase {
|
||||
public void testCephSecretDef() {
|
||||
String uuid = "a9febe83-ac5c-467a-bf19-eb75325ec23c";
|
||||
String name = "admin";
|
||||
usage use = usage.CEPH;
|
||||
Usage use = Usage.CEPH;
|
||||
|
||||
LibvirtSecretDef def = new LibvirtSecretDef(use, uuid);
|
||||
def.setCephName(name);
|
||||
|
||||
@ -20,13 +20,13 @@
|
||||
package com.cloud.hypervisor.kvm.resource;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtStoragePoolDef.poolType;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtStoragePoolDef.authType;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtStoragePoolDef.PoolType;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtStoragePoolDef.AuthenticationType;
|
||||
|
||||
public class LibvirtStoragePoolDefTest extends TestCase {
|
||||
|
||||
public void testSetGetStoragePool() {
|
||||
poolType type = poolType.NETFS;
|
||||
PoolType type = PoolType.NETFS;
|
||||
String name = "myNFSPool";
|
||||
String uuid = "d7846cb0-f610-4a5b-8d38-ee6e8d63f37b";
|
||||
String host = "127.0.0.1";
|
||||
@ -45,7 +45,7 @@ public class LibvirtStoragePoolDefTest extends TestCase {
|
||||
}
|
||||
|
||||
public void testNfsStoragePool() {
|
||||
poolType type = poolType.NETFS;
|
||||
PoolType type = PoolType.NETFS;
|
||||
String name = "myNFSPool";
|
||||
String uuid = "89a605bc-d470-4637-b3df-27388be452f5";
|
||||
String host = "127.0.0.1";
|
||||
@ -62,14 +62,14 @@ public class LibvirtStoragePoolDefTest extends TestCase {
|
||||
}
|
||||
|
||||
public void testRbdStoragePool() {
|
||||
poolType type = poolType.RBD;
|
||||
PoolType type = PoolType.RBD;
|
||||
String name = "myRBDPool";
|
||||
String uuid = "921ef8b2-955a-4c18-a697-66bb9adf6131";
|
||||
String host = "127.0.0.1";
|
||||
String dir = "cloudstackrbdpool";
|
||||
String authUsername = "admin";
|
||||
String secretUuid = "08c2fa02-50d0-4a78-8903-b742d3f34934";
|
||||
authType auth = authType.CEPH;
|
||||
AuthenticationType auth = AuthenticationType.CEPH;
|
||||
int port = 6789;
|
||||
|
||||
LibvirtStoragePoolDef pool = new LibvirtStoragePoolDef(type, name, uuid, host, port, dir, authUsername, auth, secretUuid);
|
||||
|
||||
@ -1591,7 +1591,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
if (vgpuVMs.containsKey(capacity.getGroupName().concat(capacity.getModelName()))) {
|
||||
capacityUsed += (float)vgpuVMs.get(capacity.getGroupName().concat(capacity.getModelName())) / capacity.getMaxVpuPerGpu();
|
||||
}
|
||||
if (capacity.getModelName().equals(GPU.vGPUType.passthrough.toString())) {
|
||||
if (capacity.getModelName().equals(GPU.GPUType.passthrough.toString())) {
|
||||
capacityMax += capacity.getMaxCapacity();
|
||||
}
|
||||
}
|
||||
|
||||
@ -3296,7 +3296,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
}
|
||||
}
|
||||
} else { // !isAccountSpecific
|
||||
final NicIpAliasVO ipAlias = _nicIpAliasDao.findByGatewayAndNetworkIdAndState(vlanRange.getVlanGateway(), vlanRange.getNetworkId(), NicIpAlias.state.active);
|
||||
final NicIpAliasVO ipAlias = _nicIpAliasDao.findByGatewayAndNetworkIdAndState(vlanRange.getVlanGateway(), vlanRange.getNetworkId(), NicIpAlias.State.active);
|
||||
//check if the ipalias belongs to the vlan range being deleted.
|
||||
if (ipAlias != null && vlanDbId == _publicIpAddressDao.findByIpAndSourceNetworkId(vlanRange.getNetworkId(), ipAlias.getIp4Address()).getVlanId()) {
|
||||
throw new InvalidParameterValueException("Cannot delete vlan range " + vlanDbId + " as " + ipAlias.getIp4Address()
|
||||
|
||||
@ -122,7 +122,6 @@ import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.NicVO;
|
||||
import com.cloud.vm.UserVmVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.VirtualMachineManager;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
@ -264,7 +263,7 @@ public class CommandSetupHelper {
|
||||
|
||||
public void configDnsMasq(final VirtualRouter router, final Network network, final Commands cmds) {
|
||||
final DataCenterVO dcVo = _dcDao.findById(router.getDataCenterId());
|
||||
final List<NicIpAliasVO> ipAliasVOList = _nicIpAliasDao.listByNetworkIdAndState(network.getId(), NicIpAlias.state.active);
|
||||
final List<NicIpAliasVO> ipAliasVOList = _nicIpAliasDao.listByNetworkIdAndState(network.getId(), NicIpAlias.State.active);
|
||||
final List<DhcpTO> ipList = new ArrayList<DhcpTO>();
|
||||
|
||||
final NicVO router_guest_nic = _nicDao.findByNtwkIdAndInstanceId(network.getId(), router.getId());
|
||||
@ -598,7 +597,7 @@ public class CommandSetupHelper {
|
||||
}
|
||||
|
||||
public void createVmDataCommandForVMs(final DomainRouterVO router, final Commands cmds, final long guestNetworkId) {
|
||||
final List<UserVmVO> vms = _userVmDao.listByNetworkIdAndStates(guestNetworkId, State.Running, State.Migrating, State.Stopping);
|
||||
final List<UserVmVO> vms = _userVmDao.listByNetworkIdAndStates(guestNetworkId, VirtualMachine.State.Running, VirtualMachine.State.Migrating, VirtualMachine.State.Stopping);
|
||||
final DataCenterVO dc = _dcDao.findById(router.getDataCenterId());
|
||||
for (final UserVmVO vm : vms) {
|
||||
boolean createVmData = true;
|
||||
@ -617,7 +616,7 @@ public class CommandSetupHelper {
|
||||
}
|
||||
|
||||
public void createDhcpEntryCommandsForVMs(final DomainRouterVO router, final Commands cmds, final long guestNetworkId) {
|
||||
final List<UserVmVO> vms = _userVmDao.listByNetworkIdAndStates(guestNetworkId, State.Running, State.Migrating, State.Stopping);
|
||||
final List<UserVmVO> vms = _userVmDao.listByNetworkIdAndStates(guestNetworkId, VirtualMachine.State.Running, VirtualMachine.State.Migrating, VirtualMachine.State.Stopping);
|
||||
final DataCenterVO dc = _dcDao.findById(router.getDataCenterId());
|
||||
for (final UserVmVO vm : vms) {
|
||||
boolean createDhcp = true;
|
||||
|
||||
@ -231,7 +231,6 @@ import com.cloud.vm.NicVO;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.ReservationContextImpl;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.VirtualMachineGuru;
|
||||
import com.cloud.vm.VirtualMachineManager;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
@ -249,7 +248,7 @@ import com.cloud.vm.dao.VMInstanceDao;
|
||||
* network appliances available in the Cloud Stack.
|
||||
*/
|
||||
public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements VirtualNetworkApplianceManager, VirtualNetworkApplianceService, VirtualMachineGuru, Listener,
|
||||
Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
||||
Configurable, StateListener<VirtualMachine.State, VirtualMachine.Event, VirtualMachine> {
|
||||
private static final Logger s_logger = Logger.getLogger(VirtualNetworkApplianceManagerImpl.class);
|
||||
|
||||
@Inject
|
||||
@ -442,7 +441,7 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
||||
}
|
||||
|
||||
// Check that the router is stopped
|
||||
if (!router.getState().equals(State.Stopped)) {
|
||||
if (!router.getState().equals(VirtualMachine.State.Stopped)) {
|
||||
s_logger.warn("Unable to upgrade router " + router.toString() + " in state " + router.getState());
|
||||
throw new InvalidParameterValueException("Unable to upgrade router " + router.toString() + " in state " + router.getState()
|
||||
+ "; make sure the router is stopped and not in an error state before upgrading.");
|
||||
@ -542,7 +541,7 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
||||
_accountMgr.checkAccess(caller, null, true, router);
|
||||
|
||||
// Can reboot domain router only in Running state
|
||||
if (router == null || router.getState() != State.Running) {
|
||||
if (router == null || router.getState() != VirtualMachine.State.Running) {
|
||||
s_logger.warn("Unable to reboot, virtual router is not in the right state " + router.getState());
|
||||
throw new ResourceUnavailableException("Unable to reboot domR, it is not in right state " + router.getState(), DataCenter.class, router.getDataCenterId());
|
||||
}
|
||||
@ -744,7 +743,7 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
||||
@Override
|
||||
protected void runInContext() {
|
||||
try {
|
||||
final List<DomainRouterVO> routers = _routerDao.listByStateAndNetworkType(State.Running, GuestType.Isolated, mgmtSrvrId);
|
||||
final List<DomainRouterVO> routers = _routerDao.listByStateAndNetworkType(VirtualMachine.State.Running, GuestType.Isolated, mgmtSrvrId);
|
||||
s_logger.debug("Found " + routers.size() + " running routers. ");
|
||||
|
||||
for (final DomainRouterVO router : routers) {
|
||||
@ -908,7 +907,7 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
||||
if (conns == null || conns.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
if (router.getState() != State.Running) {
|
||||
if (router.getState() != VirtualMachine.State.Running) {
|
||||
for (final Site2SiteVpnConnectionVO conn : conns) {
|
||||
if (conn.getState() != Site2SiteVpnConnection.State.Error) {
|
||||
conn.setState(Site2SiteVpnConnection.State.Disconnected);
|
||||
@ -989,7 +988,7 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
||||
continue;
|
||||
}
|
||||
final RedundantState prevState = router.getRedundantState();
|
||||
if (router.getState() != State.Running) {
|
||||
if (router.getState() != VirtualMachine.State.Running) {
|
||||
router.setRedundantState(RedundantState.UNKNOWN);
|
||||
updated = true;
|
||||
} else {
|
||||
@ -1041,7 +1040,7 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
||||
// Ensure router status is update to date before execute this function. The
|
||||
// function would try best to recover all routers except MASTER
|
||||
protected void recoverRedundantNetwork(final DomainRouterVO masterRouter, final DomainRouterVO backupRouter) {
|
||||
if (masterRouter.getState() == State.Running && backupRouter.getState() == State.Running) {
|
||||
if (masterRouter.getState() == VirtualMachine.State.Running && backupRouter.getState() == VirtualMachine.State.Running) {
|
||||
final HostVO masterHost = _hostDao.findById(masterRouter.getHostId());
|
||||
final HostVO backupHost = _hostDao.findById(backupRouter.getHostId());
|
||||
if (masterHost.getState() == Status.Up && backupHost.getState() == Status.Up) {
|
||||
@ -1174,7 +1173,7 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
||||
final DomainRouterVO router0 = routers.get(0);
|
||||
final DomainRouterVO router1 = routers.get(1);
|
||||
|
||||
if (router0.getState() != State.Running || router1.getState() != State.Running) {
|
||||
if (router0.getState() != VirtualMachine.State.Running || router1.getState() != VirtualMachine.State.Running) {
|
||||
updateRoutersRedundantState(routers);
|
||||
// Wilder Rodrigues (wrodrigues@schubergphilis.com) - One of the routers is not running,
|
||||
// so we don't have to continue here since the host will be null any way. Also, there is no need
|
||||
@ -1188,8 +1187,8 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
||||
} else {
|
||||
router = router1;
|
||||
}
|
||||
// && router.getState() == State.Stopped
|
||||
if (router.getHostId() == null && router.getState() == State.Running) {
|
||||
// && router.getState() == VirtualMachine.State.Stopped
|
||||
if (router.getHostId() == null && router.getState() == VirtualMachine.State.Running) {
|
||||
s_logger.debug("Skip router pair (" + router0.getInstanceName() + "," + router1.getInstanceName() + ") due to can't find host");
|
||||
continue;
|
||||
}
|
||||
@ -1259,7 +1258,7 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
||||
|
||||
protected void getRouterAlerts() {
|
||||
try {
|
||||
final List<DomainRouterVO> routers = _routerDao.listByStateAndManagementServer(State.Running, mgmtSrvrId);
|
||||
final List<DomainRouterVO> routers = _routerDao.listByStateAndManagementServer(VirtualMachine.State.Running, mgmtSrvrId);
|
||||
|
||||
s_logger.debug("Found " + routers.size() + " running routers. ");
|
||||
|
||||
@ -1952,11 +1951,11 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
||||
_networkOfferingDao.findById(_networkDao.findById(guestNetworkId).getNetworkOfferingId()), Service.Dhcp);
|
||||
final String supportsMultipleSubnets = dhcpCapabilities.get(Network.Capability.DhcpAccrossMultipleSubnets);
|
||||
if (supportsMultipleSubnets != null && Boolean.valueOf(supportsMultipleSubnets)) {
|
||||
final List<NicIpAliasVO> revokedIpAliasVOs = _nicIpAliasDao.listByNetworkIdAndState(guestNetworkId, NicIpAlias.state.revoked);
|
||||
final List<NicIpAliasVO> revokedIpAliasVOs = _nicIpAliasDao.listByNetworkIdAndState(guestNetworkId, NicIpAlias.State.revoked);
|
||||
s_logger.debug("Found" + revokedIpAliasVOs.size() + "ip Aliases to revoke on the router as a part of dhcp configuration");
|
||||
removeRevokedIpAliasFromDb(revokedIpAliasVOs);
|
||||
|
||||
final List<NicIpAliasVO> aliasVOs = _nicIpAliasDao.listByNetworkIdAndState(guestNetworkId, NicIpAlias.state.active);
|
||||
final List<NicIpAliasVO> aliasVOs = _nicIpAliasDao.listByNetworkIdAndState(guestNetworkId, NicIpAlias.State.active);
|
||||
s_logger.debug("Found" + aliasVOs.size() + "ip Aliases to apply on the router as a part of dhcp configuration");
|
||||
final List<IpAliasTO> activeIpAliasTOs = new ArrayList<IpAliasTO>();
|
||||
for (final NicIpAliasVO aliasVO : aliasVOs) {
|
||||
@ -2148,7 +2147,7 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
||||
}
|
||||
|
||||
for (final VirtualRouter router : routers) {
|
||||
if (router.getState() != State.Running) {
|
||||
if (router.getState() != VirtualMachine.State.Running) {
|
||||
s_logger.warn("Failed to start remote access VPN: router not in right state " + router.getState());
|
||||
throw new ResourceUnavailableException("Failed to start remote access VPN: router not in right state " + router.getState(), DataCenter.class,
|
||||
network.getDataCenterId());
|
||||
@ -2189,11 +2188,11 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
||||
|
||||
boolean result = true;
|
||||
for (final VirtualRouter router : routers) {
|
||||
if (router.getState() == State.Running) {
|
||||
if (router.getState() == VirtualMachine.State.Running) {
|
||||
final Commands cmds = new Commands(Command.OnError.Continue);
|
||||
_commandSetupHelper.createApplyVpnCommands(false, vpn, router, cmds);
|
||||
result = result && _nwHelper.sendCommandsToRouter(router, cmds);
|
||||
} else if (router.getState() == State.Stopped) {
|
||||
} else if (router.getState() == VirtualMachine.State.Stopped) {
|
||||
s_logger.debug("Router " + router + " is in Stopped state, not sending deleteRemoteAccessVpn command to it");
|
||||
continue;
|
||||
} else {
|
||||
@ -2226,20 +2225,20 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
||||
}
|
||||
|
||||
for (final DomainRouterVO router : routers) {
|
||||
if (router.getState() != State.Running) {
|
||||
if (router.getState() != VirtualMachine.State.Running) {
|
||||
s_logger.warn("Failed to add/remove VPN users: router not in running state");
|
||||
throw new ResourceUnavailableException("Unable to assign ip addresses, domR is not in right state " + router.getState(), DataCenter.class,
|
||||
network.getDataCenterId());
|
||||
}
|
||||
|
||||
final Commands cmds = new Commands(Command.OnError.Continue);
|
||||
final List<NicIpAliasVO> revokedIpAliasVOs = _nicIpAliasDao.listByNetworkIdAndState(network.getId(), NicIpAlias.state.revoked);
|
||||
final List<NicIpAliasVO> revokedIpAliasVOs = _nicIpAliasDao.listByNetworkIdAndState(network.getId(), NicIpAlias.State.revoked);
|
||||
s_logger.debug("Found" + revokedIpAliasVOs.size() + "ip Aliases to revoke on the router as a part of dhcp configuration");
|
||||
final List<IpAliasTO> revokedIpAliasTOs = new ArrayList<IpAliasTO>();
|
||||
for (final NicIpAliasVO revokedAliasVO : revokedIpAliasVOs) {
|
||||
revokedIpAliasTOs.add(new IpAliasTO(revokedAliasVO.getIp4Address(), revokedAliasVO.getNetmask(), revokedAliasVO.getAliasCount().toString()));
|
||||
}
|
||||
final List<NicIpAliasVO> aliasVOs = _nicIpAliasDao.listByNetworkIdAndState(network.getId(), NicIpAlias.state.active);
|
||||
final List<NicIpAliasVO> aliasVOs = _nicIpAliasDao.listByNetworkIdAndState(network.getId(), NicIpAlias.State.active);
|
||||
s_logger.debug("Found" + aliasVOs.size() + "ip Aliases to apply on the router as a part of dhcp configuration");
|
||||
final List<IpAliasTO> activeIpAliasTOs = new ArrayList<IpAliasTO>();
|
||||
for (final NicIpAliasVO aliasVO : aliasVOs) {
|
||||
@ -2306,7 +2305,7 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
||||
|
||||
// After start network, check if it's already running
|
||||
router = _routerDao.findById(routerId);
|
||||
if (router.getState() == State.Running) {
|
||||
if (router.getState() == VirtualMachine.State.Running) {
|
||||
return router;
|
||||
}
|
||||
|
||||
@ -2365,8 +2364,8 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
||||
for (DomainRouterVO router : routers) {
|
||||
if (router.isStopPending()) {
|
||||
s_logger.info("Stopping router " + router.getInstanceName() + " due to stop pending flag found!");
|
||||
final State state = router.getState();
|
||||
if (state != State.Stopped && state != State.Destroyed) {
|
||||
final VirtualMachine.State state = router.getState();
|
||||
if (state != VirtualMachine.State.Stopped && state != VirtualMachine.State.Destroyed) {
|
||||
try {
|
||||
stopRouter(router.getId(), false);
|
||||
} catch (final ResourceUnavailableException e) {
|
||||
@ -2598,18 +2597,18 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preStateTransitionEvent(final State oldState, final VirtualMachine.Event event, final State newState, final VirtualMachine vo, final boolean status,
|
||||
public boolean preStateTransitionEvent(final VirtualMachine.State oldState, final VirtualMachine.Event event, final VirtualMachine.State newState, final VirtualMachine vo, final boolean status,
|
||||
final Object opaque) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean postStateTransitionEvent(final StateMachine2.Transition<State, VirtualMachine.Event> transition, final VirtualMachine vo, final boolean status, final Object opaque) {
|
||||
final State newState = transition.getToState();
|
||||
public boolean postStateTransitionEvent(final StateMachine2.Transition<VirtualMachine.State, VirtualMachine.Event> transition, final VirtualMachine vo, final boolean status, final Object opaque) {
|
||||
final VirtualMachine.State newState = transition.getToState();
|
||||
final VirtualMachine.Event event = transition.getEvent();
|
||||
if (vo.getType() == VirtualMachine.Type.DomainRouter &&
|
||||
event == VirtualMachine.Event.FollowAgentPowerOnReport &&
|
||||
newState == State.Running &&
|
||||
newState == VirtualMachine.State.Running &&
|
||||
isOutOfBandMigrated(opaque)) {
|
||||
s_logger.debug("Virtual router " + vo.getInstanceName() + " is powered-on out-of-band");
|
||||
}
|
||||
|
||||
@ -94,7 +94,7 @@ public class DhcpSubNetRules extends RuleApplier {
|
||||
// networks.
|
||||
if (!NetUtils.sameSubnet(domrGuestNic.getIPv4Address(), _nic.getIPv4Address(), _nic.getIPv4Netmask())) {
|
||||
final NicIpAliasDao nicIpAliasDao = visitor.getVirtualNetworkApplianceFactory().getNicIpAliasDao();
|
||||
final List<NicIpAliasVO> aliasIps = nicIpAliasDao.listByNetworkIdAndState(domrGuestNic.getNetworkId(), NicIpAlias.state.active);
|
||||
final List<NicIpAliasVO> aliasIps = nicIpAliasDao.listByNetworkIdAndState(domrGuestNic.getNetworkId(), NicIpAlias.State.active);
|
||||
boolean ipInVmsubnet = false;
|
||||
for (final NicIpAliasVO alias : aliasIps) {
|
||||
// check if any of the alias ips belongs to the Vm's subnet.
|
||||
|
||||
@ -125,11 +125,11 @@ import com.cloud.vm.dao.VMInstanceDao;
|
||||
@Component
|
||||
public class StatsCollector extends ManagerBase implements ComponentMethodInterceptable {
|
||||
|
||||
public static enum externalStatsProtocol {
|
||||
public static enum ExternalStatsProtocol {
|
||||
NONE("none"), GRAPHITE("graphite");
|
||||
String _type;
|
||||
|
||||
externalStatsProtocol(String type) {
|
||||
ExternalStatsProtocol(String type) {
|
||||
_type = type;
|
||||
}
|
||||
|
||||
@ -218,7 +218,7 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
|
||||
String externalStatsHost = null;
|
||||
int externalStatsPort = -1;
|
||||
boolean externalStatsEnabled = false;
|
||||
externalStatsProtocol externalStatsType = externalStatsProtocol.NONE;
|
||||
ExternalStatsProtocol externalStatsType = ExternalStatsProtocol.NONE;
|
||||
|
||||
private ScheduledExecutorService _diskStatsUpdateExecutor;
|
||||
private int _usageAggregationRange = 1440;
|
||||
@ -266,7 +266,7 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
|
||||
String scheme = uri.getScheme();
|
||||
|
||||
try {
|
||||
externalStatsType = externalStatsProtocol.valueOf(scheme.toUpperCase());
|
||||
externalStatsType = ExternalStatsProtocol.valueOf(scheme.toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
s_logger.info(scheme + " is not a valid protocol for external statistics. No statistics will be send.");
|
||||
}
|
||||
@ -492,7 +492,7 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
|
||||
* Currently only Graphite is supported
|
||||
*/
|
||||
if (!metrics.isEmpty()) {
|
||||
if (externalStatsType != null && externalStatsType == externalStatsProtocol.GRAPHITE) {
|
||||
if (externalStatsType != null && externalStatsType == ExternalStatsProtocol.GRAPHITE) {
|
||||
|
||||
if (externalStatsPort == -1) {
|
||||
externalStatsPort = 2003;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user