From 508f10527fc199a45900e456899893fb776e50da Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Wed, 22 Apr 2015 11:35:57 +0200 Subject: [PATCH 001/175] Refactoring the LibvirtComputingResource - Adding LibvirtStopCommandWrapper - LibvirtRequestWrapper - 1 unit tests Refactored the RequestWrapper to make it better. - Changes also applied to the CitrixRequestWrapper --- .../com/cloud/resource/RequestWrapper.java | 79 + .../resource/LibvirtComputingResource.java | 1762 +++++++++-------- .../wrapper/LibvirtRequestWrapper.java | 72 + .../wrapper/LibvirtStopCommandWrapper.java | 86 + .../LibvirtComputingResourceTest.java | 197 +- .../wrapper/CitrixRequestWrapper.java | 74 - .../wrapper/CitrixRequestWrapperTest.java | 4 +- 7 files changed, 1242 insertions(+), 1032 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStopCommandWrapper.java diff --git a/core/src/com/cloud/resource/RequestWrapper.java b/core/src/com/cloud/resource/RequestWrapper.java index 6fd1c6688559..0311e2543ce1 100644 --- a/core/src/com/cloud/resource/RequestWrapper.java +++ b/core/src/com/cloud/resource/RequestWrapper.java @@ -19,14 +19,93 @@ package com.cloud.resource; +import java.util.Hashtable; + import com.cloud.agent.api.Answer; import com.cloud.agent.api.Command; public abstract class RequestWrapper { + @SuppressWarnings("rawtypes") + protected Hashtable, Hashtable, CommandWrapper>> resources = new Hashtable, Hashtable, CommandWrapper>>(); + /** * @param command to be executed. * @return an Answer for the executed command. */ public abstract Answer execute(Command command, ServerResource serverResource); + + @SuppressWarnings({ "rawtypes", "unchecked" }) + protected Hashtable, CommandWrapper> retrieveResource(final Command command, final Class resourceClass) { + Class keepResourceClass = resourceClass; + Hashtable, CommandWrapper> resource = resources.get(keepResourceClass); + while (resource == null) { + try { + final Class keepResourceClass2 = (Class) keepResourceClass.getSuperclass(); + resource = resources.get(keepResourceClass2); + + keepResourceClass = keepResourceClass2; + } catch (final ClassCastException e) { + throw new NullPointerException("No key found for '" + command.getClass() + "' in the Map!"); + } + } + return resource; + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + protected CommandWrapper retrieveCommands(final Class commandClass, + final Hashtable, CommandWrapper> resourceCommands) { + + Class keepCommandClass = commandClass; + CommandWrapper commandWrapper = resourceCommands.get(keepCommandClass); + while (commandWrapper == null) { + try { + final Class commandClass2 = (Class) keepCommandClass.getSuperclass(); + + if (commandClass2 == null) { + throw new NullPointerException("All the COMMAND hierarchy tree has been visited but no compliant key has been found for '" + commandClass + "'."); + } + + commandWrapper = resourceCommands.get(commandClass2); + + keepCommandClass = commandClass2; + } catch (final NullPointerException e) { + // Will now traverse all the resource hierarchy. Returning null + // is not a problem. + // It is all being nicely checked and in case we do not have a + // resource, an Unsupported answer will be thrown by the base + // class. + return null; + } + } + return commandWrapper; + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + protected CommandWrapper retryWhenAllFails(final Command command, final Class resourceClass, + final Hashtable, CommandWrapper> resourceCommands) { + + Class keepResourceClass = resourceClass; + CommandWrapper commandWrapper = resourceCommands.get(command.getClass()); + while (commandWrapper == null) { + // Could not find the command in the given resource, will traverse + // the family tree. + try { + final Class resourceClass2 = (Class) keepResourceClass.getSuperclass(); + + if (resourceClass2 == null) { + throw new NullPointerException("All the SERVER-RESOURCE hierarchy tree has been visited but no compliant key has been found for '" + command.getClass() + "'."); + } + + final Hashtable, CommandWrapper> resourceCommands2 = retrieveResource(command, + (Class) keepResourceClass.getSuperclass()); + keepResourceClass = resourceClass2; + + commandWrapper = retrieveCommands(command.getClass(), resourceCommands2); + } catch (final NullPointerException e) { + throw e; + } + } + return commandWrapper; + } } \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 2bd584e6f9b3..892e9063688f 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -61,6 +61,13 @@ import javax.ejb.Local; import javax.naming.ConfigurationException; +import org.apache.cloudstack.storage.command.StorageSubSystemCommand; +import org.apache.cloudstack.storage.to.PrimaryDataStoreTO; +import org.apache.cloudstack.storage.to.VolumeObjectTO; +import org.apache.cloudstack.utils.qemu.QemuImg; +import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat; +import org.apache.cloudstack.utils.qemu.QemuImgException; +import org.apache.cloudstack.utils.qemu.QemuImgFile; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.log4j.Logger; @@ -81,15 +88,6 @@ import com.ceph.rbd.Rbd; import com.ceph.rbd.RbdException; import com.ceph.rbd.RbdImage; - -import org.apache.cloudstack.storage.command.StorageSubSystemCommand; -import org.apache.cloudstack.storage.to.PrimaryDataStoreTO; -import org.apache.cloudstack.storage.to.VolumeObjectTO; -import org.apache.cloudstack.utils.qemu.QemuImg; -import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat; -import org.apache.cloudstack.utils.qemu.QemuImgException; -import org.apache.cloudstack.utils.qemu.QemuImgFile; - import com.cloud.agent.api.Answer; import com.cloud.agent.api.AttachIsoCommand; import com.cloud.agent.api.AttachVolumeAnswer; @@ -232,6 +230,7 @@ import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.TermPolicy; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.VideoDef; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.VirtioSerialDef; +import com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper; import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk; import com.cloud.hypervisor.kvm.storage.KVMStoragePool; import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; @@ -334,12 +333,12 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv protected static final String DEFAULT_BRIDGE_VIF_DRIVER_CLASS_NAME = "com.cloud.hypervisor.kvm.resource.BridgeVifDriver"; @Override - public ExecutionResult executeInVR(String routerIp, String script, String args) { + public ExecutionResult executeInVR(final String routerIp, final String script, final String args) { return executeInVR(routerIp, script, args, _timeout / 1000); } @Override - public ExecutionResult executeInVR(String routerIp, String script, String args, int timeout) { + public ExecutionResult executeInVR(final String routerIp, final String script, final String args, final int timeout) { final Script command = new Script(_routerProxyPath, timeout * 1000, s_logger); final AllLinesParser parser = new AllLinesParser(); command.add(script); @@ -355,13 +354,13 @@ public ExecutionResult executeInVR(String routerIp, String script, String args, } @Override - public ExecutionResult createFileInVR(String routerIp, String path, String filename, String content) { - File permKey = new File("/root/.ssh/id_rsa.cloud"); + public ExecutionResult createFileInVR(final String routerIp, final String path, final String filename, final String content) { + final File permKey = new File("/root/.ssh/id_rsa.cloud"); String error = null; try { SshHelper.scpTo(routerIp, 3922, "root", permKey, null, path, content.getBytes(), filename, null); - } catch (Exception e) { + } catch (final Exception e) { s_logger.warn("Fail to create file " + path + filename + " in VR " + routerIp, e); error = e.getMessage(); } @@ -369,7 +368,7 @@ public ExecutionResult createFileInVR(String routerIp, String path, String filen } @Override - public ExecutionResult prepareCommand(NetworkElementCommand cmd) { + public ExecutionResult prepareCommand(final NetworkElementCommand cmd) { //Update IP used to access router cmd.setRouterAccessIp(cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP)); assert cmd.getRouterAccessIp() != null; @@ -387,7 +386,7 @@ public ExecutionResult prepareCommand(NetworkElementCommand cmd) { } @Override - public ExecutionResult cleanupCommand(NetworkElementCommand cmd) { + public ExecutionResult cleanupCommand(final NetworkElementCommand cmd) { if (cmd instanceof IpAssocCommand && !(cmd instanceof IpAssocVpcCommand)) { return cleanupNetworkElementCommand((IpAssocCommand)cmd); } @@ -398,11 +397,11 @@ private static final class KeyValueInterpreter extends OutputInterpreter { private final Map map = new HashMap(); @Override - public String interpret(BufferedReader reader) throws IOException { + public String interpret(final BufferedReader reader) throws IOException { String line = null; int numLines = 0; while ((line = reader.readLine()) != null) { - String[] toks = line.trim().split("="); + final String[] toks = line.trim().split("="); if (toks.length < 2) { s_logger.warn("Failed to parse Script output: " + line); } else { @@ -491,13 +490,13 @@ protected enum BridgeType { protected StorageSubsystemCommandHandler storageHandler; - private String getEndIpFromStartIp(String startIp, int numIps) { - String[] tokens = startIp.split("[.]"); - assert (tokens.length == 4); + private String getEndIpFromStartIp(final String startIp, final int numIps) { + final String[] tokens = startIp.split("[.]"); + assert tokens.length == 4; int lastbyte = Integer.parseInt(tokens[3]); lastbyte = lastbyte + numIps; tokens[3] = Integer.toString(lastbyte); - StringBuilder end = new StringBuilder(15); + final StringBuilder end = new StringBuilder(15); end.append(tokens[0]).append(".").append(tokens[1]).append(".").append(tokens[2]).append(".").append(tokens[3]); return end.toString(); } @@ -511,14 +510,14 @@ private Map getDeveloperProperties() throws ConfigurationExcepti s_logger.info("developer.properties found at " + file.getAbsolutePath()); try { - Properties properties = PropertiesUtil.loadFromFile(file); + final Properties properties = PropertiesUtil.loadFromFile(file); - String startMac = (String)properties.get("private.macaddr.start"); + final String startMac = (String)properties.get("private.macaddr.start"); if (startMac == null) { throw new ConfigurationException("Developers must specify start mac for private ip range"); } - String startIp = (String)properties.get("private.ipaddr.start"); + final String startIp = (String)properties.get("private.ipaddr.start"); if (startIp == null) { throw new ConfigurationException("Developers must specify start ip for private ip range"); } @@ -562,7 +561,7 @@ protected String getNetworkDirectDevice() { } @Override - public boolean configure(String name, Map params) throws ConfigurationException { + public boolean configure(final String name, final Map params) throws ConfigurationException { boolean success = super.configure(name, params); if (!success) { return false; @@ -591,7 +590,7 @@ public boolean configure(String name, Map params) throws Configu storageScriptsDir = getDefaultStorageScriptsDir(); } - String bridgeType = (String)params.get("network.bridge.type"); + final String bridgeType = (String)params.get("network.bridge.type"); if (bridgeType == null) { _bridgeType = BridgeType.NATIVE; } else { @@ -690,7 +689,7 @@ public boolean configure(String name, Map params) throws Configu } String value = (String)params.get("developer"); - boolean isDeveloper = Boolean.parseBoolean(value); + final boolean isDeveloper = Boolean.parseBoolean(value); if (isDeveloper) { params.putAll(getDeveloperProperties()); @@ -701,7 +700,7 @@ public boolean configure(String name, Map params) throws Configu _pool = "/root"; } - String instance = (String)params.get("instance"); + final String instance = (String)params.get("instance"); _hypervisorType = HypervisorType.getType((String)params.get("hypervisor.type")); if (_hypervisorType == HypervisorType.None) { @@ -780,7 +779,7 @@ public boolean configure(String name, Map params) throws Configu _localStoragePath = "/var/lib/libvirt/images/"; } - File storagePath = new File(_localStoragePath); + final File storagePath = new File(_localStoragePath); _localStoragePath = storagePath.getAbsolutePath(); _localStorageUUID = (String)params.get("local.storage.uuid"); @@ -812,7 +811,7 @@ public boolean configure(String name, Map params) throws Configu value = (String) params.get("kvmclock.disable"); if (Boolean.parseBoolean(value)) { _noKvmClock = true; - } else if(HypervisorType.LXC.equals(_hypervisorType) && (value == null)){ + } else if(HypervisorType.LXC.equals(_hypervisorType) && value == null){ //Disable kvmclock by default for LXC _noKvmClock = true; } @@ -823,11 +822,11 @@ public boolean configure(String name, Map params) throws Configu conn = LibvirtConnection.getConnection(); if (_bridgeType == BridgeType.OPENVSWITCH) { - if (conn.getLibVirVersion() < (10 * 1000 + 0)) { + if (conn.getLibVirVersion() < 10 * 1000 + 0) { throw new ConfigurationException("LibVirt version 0.10.0 required for openvswitch support, but version " + conn.getLibVirVersion() + " detected"); } } - } catch (LibvirtException e) { + } catch (final LibvirtException e) { throw new CloudRuntimeException(e.getMessage()); } @@ -842,10 +841,10 @@ public boolean configure(String name, Map params) throws Configu _hypervisorPath = getHypervisorPath(conn); try { _hvVersion = conn.getVersion(); - _hvVersion = (_hvVersion % 1000000) / 1000; + _hvVersion = _hvVersion % 1000000 / 1000; _hypervisorLibvirtVersion = conn.getLibVirVersion(); _hypervisorQemuVersion = conn.getVersion(); - } catch (LibvirtException e) { + } catch (final LibvirtException e) { s_logger.trace("Ignoring libvirt error.", e); } @@ -853,7 +852,7 @@ public boolean configure(String name, Map params) throws Configu if (_guestCpuMode != null) { _guestCpuModel = (String)params.get("guest.cpu.model"); - if (_hypervisorLibvirtVersion < (9 * 1000 + 10)) { + if (_hypervisorLibvirtVersion < 9 * 1000 + 10) { s_logger.warn("LibVirt version 0.9.10 required for guest cpu mode, but version " + prettyVersion(_hypervisorLibvirtVersion) + " detected, so it will be disabled"); _guestCpuMode = ""; @@ -863,28 +862,28 @@ public boolean configure(String name, Map params) throws Configu params.put("guest.cpu.model", _guestCpuModel); } - String cpuFeatures = (String)params.get("guest.cpu.features"); + final String cpuFeatures = (String)params.get("guest.cpu.features"); if (cpuFeatures != null) { _cpuFeatures = new ArrayList(); - for (String feature: cpuFeatures.split(" ")) { + for (final String feature: cpuFeatures.split(" ")) { if (!feature.isEmpty()) { _cpuFeatures.add(feature); } } } - String[] info = NetUtils.getNetworkParams(_privateNic); + final String[] info = NetUtils.getNetworkParams(_privateNic); _monitor = new KVMHAMonitor(null, info[0], _heartBeatPath); - Thread ha = new Thread(_monitor); + final Thread ha = new Thread(_monitor); ha.start(); _storagePoolMgr = new KVMStoragePoolManager(_storage, _monitor); _sysvmISOPath = (String)params.get("systemvm.iso.path"); if (_sysvmISOPath == null) { - String[] isoPaths = {"/usr/share/cloudstack-common/vms/systemvm.iso"}; - for (String isoPath : isoPaths) { + final String[] isoPaths = {"/usr/share/cloudstack-common/vms/systemvm.iso"}; + for (final String isoPath : isoPaths) { if (_storage.exists(isoPath)) { _sysvmISOPath = isoPath; break; @@ -939,13 +938,13 @@ public boolean configure(String name, Map params) throws Configu if (_migrateSpeed == -1) { //get guest network device speed _migrateSpeed = 0; - String speed = Script.runSimpleBashScript("ethtool " + _pifs.get("public") + " |grep Speed | cut -d \\ -f 2"); + final String speed = Script.runSimpleBashScript("ethtool " + _pifs.get("public") + " |grep Speed | cut -d \\ -f 2"); if (speed != null) { - String[] tokens = speed.split("M"); + final String[] tokens = speed.split("M"); if (tokens.length == 2) { try { _migrateSpeed = Integer.parseInt(tokens[0]); - } catch (NumberFormatException e) { + } catch (final NumberFormatException e) { s_logger.trace("Ignoring migrateSpeed extraction error.", e); } s_logger.debug("device " + _pifs.get("public") + " has speed: " + String.valueOf(_migrateSpeed)); @@ -954,7 +953,7 @@ public boolean configure(String name, Map params) throws Configu params.put("vm.migrate.speed", String.valueOf(_migrateSpeed)); } - Map bridges = new HashMap(); + final Map bridges = new HashMap(); bridges.put("linklocal", _linkLocalBridgeName); bridges.put("public", _publicBridgeName); bridges.put("private", _privBridgeName); @@ -968,12 +967,12 @@ public boolean configure(String name, Map params) throws Configu configureVifDrivers(params); - KVMStorageProcessor storageProcessor = new KVMStorageProcessor(_storagePoolMgr, this); + final KVMStorageProcessor storageProcessor = new KVMStorageProcessor(_storagePoolMgr, this); storageProcessor.configure(name, params); storageHandler = new StorageSubsystemCommandHandlerBase(storageProcessor); - String unameKernelVersion = Script.runSimpleBashScript("uname -r"); - String[] kernelVersions = unameKernelVersion.split("[\\.\\-]"); + final String unameKernelVersion = Script.runSimpleBashScript("uname -r"); + final String[] kernelVersions = unameKernelVersion.split("[\\.\\-]"); _kernelVersion = Integer.parseInt(kernelVersions[0]) * 1000 * 1000 + (long)Integer.parseInt(kernelVersions[1]) * 1000 + Integer.parseInt(kernelVersions[2]); /* Disable this, the code using this is pretty bad and non portable @@ -982,7 +981,7 @@ public boolean configure(String name, Map params) throws Configu return true; } - protected void configureVifDrivers(Map params) throws ConfigurationException { + protected void configureVifDrivers(final Map params) throws ConfigurationException { final String LIBVIRT_VIF_DRIVER = "libvirt.vif.driver"; _trafficTypeVifDrivers = new HashMap(); @@ -1001,19 +1000,19 @@ protected void configureVifDrivers(Map params) throws Configurat _defaultVifDriver = getVifDriverClass(defaultVifDriverName, params); // Load any per-traffic-type vif drivers - for (Map.Entry entry : params.entrySet()) { - String k = entry.getKey(); - String vifDriverPrefix = LIBVIRT_VIF_DRIVER + "."; + for (final Map.Entry entry : params.entrySet()) { + final String k = entry.getKey(); + final String vifDriverPrefix = LIBVIRT_VIF_DRIVER + "."; if (k.startsWith(vifDriverPrefix)) { // Get trafficType - String trafficTypeSuffix = k.substring(vifDriverPrefix.length()); + final String trafficTypeSuffix = k.substring(vifDriverPrefix.length()); // Does this suffix match a real traffic type? - TrafficType trafficType = TrafficType.getTrafficType(trafficTypeSuffix); + final TrafficType trafficType = TrafficType.getTrafficType(trafficTypeSuffix); if (!trafficType.equals(TrafficType.None)) { // Get vif driver class name - String vifDriverClassName = (String)entry.getValue(); + final String vifDriverClassName = (String)entry.getValue(); // if value is null, ignore if (vifDriverClassName != null) { // add traffic type to vif driver mapping to Map @@ -1024,24 +1023,24 @@ protected void configureVifDrivers(Map params) throws Configurat } } - protected VifDriver getVifDriverClass(String vifDriverClassName, Map params) throws ConfigurationException { + protected VifDriver getVifDriverClass(final String vifDriverClassName, final Map params) throws ConfigurationException { VifDriver vifDriver; try { - Class clazz = Class.forName(vifDriverClassName); + final Class clazz = Class.forName(vifDriverClassName); vifDriver = (VifDriver)clazz.newInstance(); vifDriver.configure(params); - } catch (ClassNotFoundException e) { + } catch (final ClassNotFoundException e) { throw new ConfigurationException("Unable to find class for libvirt.vif.driver " + e); - } catch (InstantiationException e) { + } catch (final InstantiationException e) { throw new ConfigurationException("Unable to instantiate class for libvirt.vif.driver " + e); - } catch (IllegalAccessException e) { + } catch (final IllegalAccessException e) { throw new ConfigurationException("Unable to instantiate class for libvirt.vif.driver " + e); } return vifDriver; } - protected VifDriver getVifDriver(TrafficType trafficType) { + protected VifDriver getVifDriver(final TrafficType trafficType) { VifDriver vifDriver = _trafficTypeVifDrivers.get(trafficType); if (vifDriver == null) { @@ -1051,24 +1050,24 @@ protected VifDriver getVifDriver(TrafficType trafficType) { return vifDriver; } - protected List getAllVifDrivers() { - Set vifDrivers = new HashSet(); + public List getAllVifDrivers() { + final Set vifDrivers = new HashSet(); vifDrivers.add(_defaultVifDriver); vifDrivers.addAll(_trafficTypeVifDrivers.values()); - ArrayList vifDriverList = new ArrayList(vifDrivers); + final ArrayList vifDriverList = new ArrayList(vifDrivers); return vifDriverList; } private void getPifs() { - File dir = new File("/sys/devices/virtual/net"); - File[] netdevs = dir.listFiles(); - List bridges = new ArrayList(); + final File dir = new File("/sys/devices/virtual/net"); + final File[] netdevs = dir.listFiles(); + final List bridges = new ArrayList(); for (int i = 0; i < netdevs.length; i++) { - File isbridge = new File(netdevs[i].getAbsolutePath() + "/bridge"); - String netdevName = netdevs[i].getName(); + final File isbridge = new File(netdevs[i].getAbsolutePath() + "/bridge"); + final String netdevName = netdevs[i].getName(); s_logger.debug("looking in file " + netdevs[i].getAbsolutePath() + "/bridge"); if (isbridge.exists()) { s_logger.debug("Found bridge " + netdevName); @@ -1076,9 +1075,9 @@ private void getPifs() { } } - for (String bridge : bridges) { + for (final String bridge : bridges) { s_logger.debug("looking for pif for bridge " + bridge); - String pif = getPif(bridge); + final String pif = getPif(bridge); if (_publicBridgeName != null && bridge.equals(_publicBridgeName)) { _pifs.put("public", pif); } @@ -1092,7 +1091,7 @@ private void getPifs() { // This addresses the unnecessary requirement of someone to create an unused bridge just for traffic label if (_pifs.get("private") == null) { s_logger.debug("guest(private) traffic label '" + _guestBridgeName + "' not found as bridge, looking for physical interface"); - File dev = new File("/sys/class/net/" + _guestBridgeName); + final File dev = new File("/sys/class/net/" + _guestBridgeName); if (dev.exists()) { s_logger.debug("guest(private) traffic label '" + _guestBridgeName + "' found as a physical device"); _pifs.put("private", _guestBridgeName); @@ -1103,7 +1102,7 @@ private void getPifs() { // This addresses the unnecessary requirement of someone to create an unused bridge just for traffic label if (_pifs.get("public") == null) { s_logger.debug("public traffic label '" + _publicBridgeName+ "' not found as bridge, looking for physical interface"); - File dev = new File("/sys/class/net/" + _publicBridgeName); + final File dev = new File("/sys/class/net/" + _publicBridgeName); if (dev.exists()) { s_logger.debug("public traffic label '" + _publicBridgeName + "' found as a physical device"); _pifs.put("public", _publicBridgeName); @@ -1114,15 +1113,15 @@ private void getPifs() { } private void getOvsPifs() { - String cmdout = Script.runSimpleBashScript("ovs-vsctl list-br | sed '{:q;N;s/\\n/%/g;t q}'"); + final String cmdout = Script.runSimpleBashScript("ovs-vsctl list-br | sed '{:q;N;s/\\n/%/g;t q}'"); s_logger.debug("cmdout was " + cmdout); - List bridges = Arrays.asList(cmdout.split("%")); - for (String bridge : bridges) { + final List bridges = Arrays.asList(cmdout.split("%")); + for (final String bridge : bridges) { s_logger.debug("looking for pif for bridge " + bridge); // String pif = getOvsPif(bridge); // Not really interested in the pif name at this point for ovs // bridges - String pif = bridge; + final String pif = bridge; if (_publicBridgeName != null && bridge.equals(_publicBridgeName)) { _pifs.put("public", pif); } @@ -1134,9 +1133,9 @@ private void getOvsPifs() { s_logger.debug("done looking for pifs, no more bridges"); } - private String getPif(String bridge) { + private String getPif(final String bridge) { String pif = matchPifFileInDirectory(bridge); - File vlanfile = new File("/proc/net/vlan/" + pif); + final File vlanfile = new File("/proc/net/vlan/" + pif); if (vlanfile.isFile()) { pif = Script.runSimpleBashScript("grep ^Device\\: /proc/net/vlan/" + pif + " | awk {'print $2'}"); @@ -1145,11 +1144,11 @@ private String getPif(String bridge) { return pif; } - private String matchPifFileInDirectory(String bridgeName) { - File brif = new File("/sys/devices/virtual/net/" + bridgeName + "/brif"); + private String matchPifFileInDirectory(final String bridgeName) { + final File brif = new File("/sys/devices/virtual/net/" + bridgeName + "/brif"); if (!brif.isDirectory()) { - File pif = new File("/sys/class/net/" + bridgeName); + final File pif = new File("/sys/class/net/" + bridgeName); if (pif.isDirectory()) { // if bridgeName already refers to a pif, return it as-is return bridgeName; @@ -1158,10 +1157,10 @@ private String matchPifFileInDirectory(String bridgeName) { return ""; } - File[] interfaces = brif.listFiles(); + final File[] interfaces = brif.listFiles(); for (int i = 0; i < interfaces.length; i++) { - String fname = interfaces[i].getName(); + final String fname = interfaces[i].getName(); s_logger.debug("matchPifFileInDirectory: file name '" + fname + "'"); if (fname.startsWith("eth") || fname.startsWith("bond") || fname.startsWith("vlan") || fname.startsWith("vx") || fname.startsWith("em") || fname.matches("^p\\d+p\\d+.*")) { @@ -1173,7 +1172,7 @@ private String matchPifFileInDirectory(String bridgeName) { return ""; } - private boolean checkNetwork(String networkName) { + private boolean checkNetwork(final String networkName) { if (networkName == null) { return true; } @@ -1185,12 +1184,12 @@ private boolean checkNetwork(String networkName) { } } - private boolean checkBridgeNetwork(String networkName) { + private boolean checkBridgeNetwork(final String networkName) { if (networkName == null) { return true; } - String name = matchPifFileInDirectory(networkName); + final String name = matchPifFileInDirectory(networkName); if (name == null || name.isEmpty()) { return false; @@ -1199,19 +1198,19 @@ private boolean checkBridgeNetwork(String networkName) { } } - private boolean checkOvsNetwork(String networkName) { + private boolean checkOvsNetwork(final String networkName) { s_logger.debug("Checking if network " + networkName + " exists as openvswitch bridge"); if (networkName == null) { return true; } - Script command = new Script("/bin/sh", _timeout); + final Script command = new Script("/bin/sh", _timeout); command.add("-c"); command.add("ovs-vsctl br-exists " + networkName); return "0".equals(command.execute(null)); } - private boolean passCmdLine(String vmName, String cmdLine) throws InternalErrorException { + private boolean passCmdLine(final String vmName, final String cmdLine) throws InternalErrorException { final Script command = new Script(_patchViaSocketPath, 5 * 1000, s_logger); String result; command.add("-n", vmName); @@ -1224,20 +1223,20 @@ private boolean passCmdLine(String vmName, String cmdLine) throws InternalErrorE return true; } - boolean isDirectAttachedNetwork(String type) { + boolean isDirectAttachedNetwork(final String type) { if ("untagged".equalsIgnoreCase(type)) { return true; } else { try { Long.valueOf(type); - } catch (NumberFormatException e) { + } catch (final NumberFormatException e) { return true; } return false; } } - protected String startVM(Connect conn, String vmName, String domainXML) throws LibvirtException, InternalErrorException { + protected String startVM(final Connect conn, final String vmName, final String domainXML) throws LibvirtException, InternalErrorException { try { /* We create a transient domain here. When this method gets @@ -1257,7 +1256,7 @@ protected String startVM(Connect conn, String vmName, String domainXML) throws L // this is safe because it doesn't stop running VMs dm.undefine(); } - } catch (LibvirtException e) { + } catch (final LibvirtException e) { // this is what we want, no domain found } finally { if (dm != null) { @@ -1275,9 +1274,9 @@ protected String startVM(Connect conn, String vmName, String domainXML) throws L @Override public boolean stop() { try { - Connect conn = LibvirtConnection.getConnection(); + final Connect conn = LibvirtConnection.getConnection(); conn.close(); - } catch (LibvirtException e) { + } catch (final LibvirtException e) { s_logger.trace("Ignoring libvirt error.", e); } @@ -1285,12 +1284,18 @@ public boolean stop() { } @Override - public Answer executeRequest(Command cmd) { + public Answer executeRequest(final Command cmd) { + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); try { - if (cmd instanceof StopCommand) { - return execute((StopCommand)cmd); - } else if (cmd instanceof GetVmStatsCommand) { + return wrapper.execute(cmd, this); + } catch (final Exception e) { + //[TODO] ignore for now, we still need to finish the other commands. + //return Answer.createUnsupportedCommandAnswer(cmd); + } + + try { + if (cmd instanceof GetVmStatsCommand) { return execute((GetVmStatsCommand)cmd); } else if (cmd instanceof GetVmDiskStatsCommand) { return execute((GetVmDiskStatsCommand)cmd); @@ -1411,17 +1416,17 @@ public Answer executeRequest(Command cmd) { } } - private OvsFetchInterfaceAnswer execute(OvsFetchInterfaceCommand cmd) { - String label = cmd.getLabel(); + private OvsFetchInterfaceAnswer execute(final OvsFetchInterfaceCommand cmd) { + final String label = cmd.getLabel(); s_logger.debug("Will look for network with name-label:" + label); try { - String ipadd = Script.runSimpleBashScript("ifconfig " + label + " | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'"); - String mask = Script.runSimpleBashScript("ifconfig " + label + " | grep 'inet addr:' | cut -d: -f4"); - String mac = Script.runSimpleBashScript("ifconfig " + label + " | grep HWaddr | awk -F \" \" '{print $5}'"); + final String ipadd = Script.runSimpleBashScript("ifconfig " + label + " | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'"); + final String mask = Script.runSimpleBashScript("ifconfig " + label + " | grep 'inet addr:' | cut -d: -f4"); + final String mac = Script.runSimpleBashScript("ifconfig " + label + " | grep HWaddr | awk -F \" \" '{print $5}'"); return new OvsFetchInterfaceAnswer(cmd, true, "Interface " + label + " retrieved successfully", ipadd, mask, mac); - } catch (Exception e) { + } catch (final Exception e) { s_logger.warn("Caught execption when fetching interface", e); return new OvsFetchInterfaceAnswer(cmd, false, "EXCEPTION:" + e.getMessage()); @@ -1429,7 +1434,7 @@ private OvsFetchInterfaceAnswer execute(OvsFetchInterfaceCommand cmd) { } - private Answer execute(OvsSetupBridgeCommand cmd) { + private Answer execute(final OvsSetupBridgeCommand cmd) { findOrCreateTunnelNetwork(cmd.getBridgeName()); configureTunnelNetwork(cmd.getNetworkId(), cmd.getHostId(), cmd.getBridgeName()); @@ -1437,60 +1442,60 @@ private Answer execute(OvsSetupBridgeCommand cmd) { return new Answer(cmd, true, null); } - private Answer execute(OvsDestroyBridgeCommand cmd) { + private Answer execute(final OvsDestroyBridgeCommand cmd) { destroyTunnelNetwork(cmd.getBridgeName()); s_logger.debug("OVS Bridge destroyed"); return new Answer(cmd, true, null); } - public Answer execute(OvsVpcPhysicalTopologyConfigCommand cmd) { + public Answer execute(final OvsVpcPhysicalTopologyConfigCommand cmd) { - String bridge = cmd.getBridgeName(); + final String bridge = cmd.getBridgeName(); try { - Script command = new Script(_ovsTunnelPath, _timeout, s_logger); + final Script command = new Script(_ovsTunnelPath, _timeout, s_logger); command.add("configure_ovs_bridge_for_network_topology"); command.add("--bridge", bridge); command.add("--config", cmd.getVpcConfigInJson()); - String result = command.execute(); + final String result = command.execute(); if (result.equalsIgnoreCase("SUCCESS")) { return new Answer(cmd, true, result); } else { return new Answer(cmd, false, result); } - } catch (Exception e) { + } catch (final Exception e) { s_logger.warn("caught exception while updating host with latest routing polcies", e); return new Answer(cmd, false, e.getMessage()); } } - public Answer execute(OvsVpcRoutingPolicyConfigCommand cmd) { + public Answer execute(final OvsVpcRoutingPolicyConfigCommand cmd) { try { - Script command = new Script(_ovsTunnelPath, _timeout, s_logger); + final Script command = new Script(_ovsTunnelPath, _timeout, s_logger); command.add("configure_ovs_bridge_for_routing_policies"); command.add("--bridge", cmd.getBridgeName()); command.add("--config", cmd.getVpcConfigInJson()); - String result = command.execute(); + final String result = command.execute(); if (result.equalsIgnoreCase("SUCCESS")) { return new Answer(cmd, true, result); } else { return new Answer(cmd, false, result); } - } catch (Exception e) { + } catch (final Exception e) { s_logger.warn("caught exception while updating host with latest VPC topology", e); return new Answer(cmd, false, e.getMessage()); } } - private synchronized void destroyTunnelNetwork(String bridge) { + private synchronized void destroyTunnelNetwork(final String bridge) { try { findOrCreateTunnelNetwork(bridge); - Script cmd = new Script(_ovsTunnelPath, _timeout, s_logger); + final Script cmd = new Script(_ovsTunnelPath, _timeout, s_logger); cmd.add("destroy_ovs_bridge"); cmd.add("--bridge", bridge); - String result = cmd.execute(); + final String result = cmd.execute(); if (result != null) { // TODO: Should make this error not fatal? // Can Concurrent VM shutdown/migration/reboot events can cause @@ -1499,41 +1504,41 @@ private synchronized void destroyTunnelNetwork(String bridge) { throw new CloudRuntimeException("Unable to remove OVS bridge " + bridge); } return; - } catch (Exception e) { + } catch (final Exception e) { s_logger.warn("destroyTunnelNetwork failed:", e); return; } } - private synchronized boolean findOrCreateTunnelNetwork(String nwName) { + private synchronized boolean findOrCreateTunnelNetwork(final String nwName) { try { if (checkNetwork(nwName)) { return true; } // if not found, create a new one - Map otherConfig = new HashMap(); + final Map otherConfig = new HashMap(); otherConfig.put("ovs-host-setup", ""); Script.runSimpleBashScript("ovs-vsctl -- --may-exist add-br " + nwName + " -- set bridge " + nwName + " other_config:ovs-host-setup='-1'"); s_logger.debug("### KVM network for tunnels created:" + nwName); - } catch (Exception e) { + } catch (final Exception e) { s_logger.warn("createTunnelNetwork failed", e); } return true; } - private synchronized boolean configureTunnelNetwork(long networkId, - long hostId, String nwName) { + private synchronized boolean configureTunnelNetwork(final long networkId, + final long hostId, final String nwName) { try { findOrCreateTunnelNetwork(nwName); - String configuredHosts = Script + final String configuredHosts = Script .runSimpleBashScript("ovs-vsctl get bridge " + nwName + " other_config:ovs-host-setup"); boolean configured = false; if (configuredHosts != null) { - String hostIdsStr[] = configuredHosts.split(","); - for (String hostIdStr : hostIdsStr) { + final String hostIdsStr[] = configuredHosts.split(","); + for (final String hostIdStr : hostIdsStr) { if (hostIdStr.equals(((Long)hostId).toString())) { configured = true; break; @@ -1541,27 +1546,27 @@ private synchronized boolean configureTunnelNetwork(long networkId, } } if (!configured) { - Script cmd = new Script(_ovsTunnelPath, _timeout, s_logger); + final Script cmd = new Script(_ovsTunnelPath, _timeout, s_logger); cmd.add("setup_ovs_bridge"); cmd.add("--key", nwName); cmd.add("--cs_host_id", ((Long)hostId).toString()); cmd.add("--bridge", nwName); - String result = cmd.execute(); + final String result = cmd.execute(); if (result != null) { throw new CloudRuntimeException( "Unable to pre-configure OVS bridge " + nwName + " for network ID:" + networkId); } } - } catch (Exception e) { + } catch (final Exception e) { s_logger.warn("createandConfigureTunnelNetwork failed", e); return false; } return true; } - private OvsCreateTunnelAnswer execute(OvsCreateTunnelCommand cmd) { - String bridge = cmd.getNetworkName(); + private OvsCreateTunnelAnswer execute(final OvsCreateTunnelCommand cmd) { + final String bridge = cmd.getNetworkName(); try { if (!findOrCreateTunnelNetwork(bridge)) { s_logger.debug("Error during bridge setup"); @@ -1571,7 +1576,7 @@ private OvsCreateTunnelAnswer execute(OvsCreateTunnelCommand cmd) { configureTunnelNetwork(cmd.getNetworkId(), cmd.getFrom(), cmd.getNetworkName()); - Script command = new Script(_ovsTunnelPath, _timeout, s_logger); + final Script command = new Script(_ovsTunnelPath, _timeout, s_logger); command.add("create_tunnel"); command.add("--bridge", bridge); command.add("--remote_ip", cmd.getRemoteIp()); @@ -1579,21 +1584,21 @@ private OvsCreateTunnelAnswer execute(OvsCreateTunnelCommand cmd) { command.add("--src_host", cmd.getFrom().toString()); command.add("--dst_host", cmd.getTo().toString()); - String result = command.execute(); + final String result = command.execute(); if (result != null) { return new OvsCreateTunnelAnswer(cmd, true, result, null, bridge); } else { return new OvsCreateTunnelAnswer(cmd, false, result, bridge); } - } catch (Exception e) { + } catch (final Exception e) { s_logger.debug("Error during tunnel setup"); s_logger.warn("Caught execption when creating ovs tunnel", e); return new OvsCreateTunnelAnswer(cmd, false, e.getMessage(), bridge); } } - private Answer execute(OvsDestroyTunnelCommand cmd) { + private Answer execute(final OvsDestroyTunnelCommand cmd) { try { if (!findOrCreateTunnelNetwork(cmd.getBridgeName())) { s_logger.warn("Unable to find tunnel network for GRE key:" @@ -1601,26 +1606,26 @@ private Answer execute(OvsDestroyTunnelCommand cmd) { return new Answer(cmd, false, "No network found"); } - Script command = new Script(_ovsTunnelPath, _timeout, s_logger); + final Script command = new Script(_ovsTunnelPath, _timeout, s_logger); command.add("destroy_tunnel"); command.add("--bridge", cmd.getBridgeName()); command.add("--iface_name", cmd.getInPortName()); - String result = command.execute(); + final String result = command.execute(); if (result == null) { return new Answer(cmd, true, result); } else { return new Answer(cmd, false, result); } - } catch (Exception e) { + } catch (final Exception e) { s_logger.warn("caught execption when destroy ovs tunnel", e); return new Answer(cmd, false, e.getMessage()); } } - private CheckNetworkAnswer execute(CheckNetworkCommand cmd) { - List phyNics = cmd.getPhysicalNetworkInfoList(); + private CheckNetworkAnswer execute(final CheckNetworkCommand cmd) { + final List phyNics = cmd.getPhysicalNetworkInfoList(); String errMsg = null; - for (PhysicalNetworkSetupInfo nic : phyNics) { + for (final PhysicalNetworkSetupInfo nic : phyNics) { if (!checkNetwork(nic.getGuestNetworkName())) { errMsg = "Can not find network: " + nic.getGuestNetworkName(); break; @@ -1640,7 +1645,7 @@ private CheckNetworkAnswer execute(CheckNetworkCommand cmd) { } } - private CopyVolumeAnswer execute(CopyVolumeCommand cmd) { + private CopyVolumeAnswer execute(final CopyVolumeCommand cmd) { /** This method is only used for copying files from Primary Storage TO Secondary Storage @@ -1648,16 +1653,16 @@ private CopyVolumeAnswer execute(CopyVolumeCommand cmd) { that it always sets copyToSecondary to true */ - boolean copyToSecondary = cmd.toSecondaryStorage(); + final boolean copyToSecondary = cmd.toSecondaryStorage(); String volumePath = cmd.getVolumePath(); - StorageFilerTO pool = cmd.getPool(); - String secondaryStorageUrl = cmd.getSecondaryStorageURL(); + final StorageFilerTO pool = cmd.getPool(); + final String secondaryStorageUrl = cmd.getSecondaryStorageURL(); KVMStoragePool secondaryStoragePool = null; KVMStoragePool primaryPool = null; try { try { primaryPool = _storagePoolMgr.getStoragePool(pool.getType(), pool.getUuid()); - } catch (CloudRuntimeException e) { + } catch (final CloudRuntimeException e) { if (e.getMessage().contains("not found")) { primaryPool = _storagePoolMgr.createStoragePool(cmd.getPool().getUuid(), cmd.getPool().getHost(), cmd.getPool().getPort(), cmd.getPool().getPath(), @@ -1667,12 +1672,12 @@ private CopyVolumeAnswer execute(CopyVolumeCommand cmd) { } } - String volumeName = UUID.randomUUID().toString(); + final String volumeName = UUID.randomUUID().toString(); if (copyToSecondary) { - String destVolumeName = volumeName + ".qcow2"; - KVMPhysicalDisk volume = primaryPool.getPhysicalDisk(cmd.getVolumePath()); - String volumeDestPath = "/volumes/" + cmd.getVolumeId() + File.separator; + final String destVolumeName = volumeName + ".qcow2"; + final KVMPhysicalDisk volume = primaryPool.getPhysicalDisk(cmd.getVolumePath()); + final String volumeDestPath = "/volumes/" + cmd.getVolumeId() + File.separator; secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(secondaryStorageUrl); secondaryStoragePool.createFolder(volumeDestPath); _storagePoolMgr.deleteStoragePool(secondaryStoragePool.getType(), secondaryStoragePool.getUuid()); @@ -1682,11 +1687,11 @@ private CopyVolumeAnswer execute(CopyVolumeCommand cmd) { } else { volumePath = "/volumes/" + cmd.getVolumeId() + File.separator; secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(secondaryStorageUrl + volumePath); - KVMPhysicalDisk volume = secondaryStoragePool.getPhysicalDisk(cmd.getVolumePath() + ".qcow2"); + final KVMPhysicalDisk volume = secondaryStoragePool.getPhysicalDisk(cmd.getVolumePath() + ".qcow2"); _storagePoolMgr.copyPhysicalDisk(volume, volumeName, primaryPool, 0); return new CopyVolumeAnswer(cmd, true, null, null, volumeName); } - } catch (CloudRuntimeException e) { + } catch (final CloudRuntimeException e) { return new CopyVolumeAnswer(cmd, false, e.toString(), null, null); } finally { if (secondaryStoragePool != null) { @@ -1695,52 +1700,52 @@ private CopyVolumeAnswer execute(CopyVolumeCommand cmd) { } } - protected Answer execute(DeleteStoragePoolCommand cmd) { + protected Answer execute(final DeleteStoragePoolCommand cmd) { try { _storagePoolMgr.deleteStoragePool(cmd.getPool().getType(), cmd.getPool().getUuid()); return new Answer(cmd); - } catch (CloudRuntimeException e) { + } catch (final CloudRuntimeException e) { return new Answer(cmd, false, e.toString()); } } - protected FenceAnswer execute(FenceCommand cmd) { - ExecutorService executors = Executors.newSingleThreadExecutor(); - List pools = _monitor.getStoragePools(); - KVMHAChecker ha = new KVMHAChecker(pools, cmd.getHostIp()); - Future future = executors.submit(ha); + protected FenceAnswer execute(final FenceCommand cmd) { + final ExecutorService executors = Executors.newSingleThreadExecutor(); + final List pools = _monitor.getStoragePools(); + final KVMHAChecker ha = new KVMHAChecker(pools, cmd.getHostIp()); + final Future future = executors.submit(ha); try { - Boolean result = future.get(); + final Boolean result = future.get(); if (result) { return new FenceAnswer(cmd, false, "Heart is still beating..."); } else { return new FenceAnswer(cmd); } - } catch (InterruptedException e) { + } catch (final InterruptedException e) { s_logger.warn("Unable to fence", e); return new FenceAnswer(cmd, false, e.getMessage()); - } catch (ExecutionException e) { + } catch (final ExecutionException e) { s_logger.warn("Unable to fence", e); return new FenceAnswer(cmd, false, e.getMessage()); } } - protected Answer execute(CheckOnHostCommand cmd) { - ExecutorService executors = Executors.newSingleThreadExecutor(); - List pools = _monitor.getStoragePools(); - KVMHAChecker ha = new KVMHAChecker(pools, cmd.getHost().getPrivateNetwork().getIp()); - Future future = executors.submit(ha); + protected Answer execute(final CheckOnHostCommand cmd) { + final ExecutorService executors = Executors.newSingleThreadExecutor(); + final List pools = _monitor.getStoragePools(); + final KVMHAChecker ha = new KVMHAChecker(pools, cmd.getHost().getPrivateNetwork().getIp()); + final Future future = executors.submit(ha); try { - Boolean result = future.get(); + final Boolean result = future.get(); if (result) { return new Answer(cmd, false, "Heart is still beating..."); } else { return new Answer(cmd); } - } catch (InterruptedException e) { + } catch (final InterruptedException e) { return new Answer(cmd, false, "can't get status of host:"); - } catch (ExecutionException e) { + } catch (final ExecutionException e) { return new Answer(cmd, false, "can't get status of host:"); } @@ -1750,9 +1755,9 @@ protected Storage.StorageResourceType getStorageResourceType() { return Storage.StorageResourceType.STORAGE_POOL; } - protected Answer execute(CreateCommand cmd) { - StorageFilerTO pool = cmd.getPool(); - DiskProfile dskch = cmd.getDiskCharacteristics(); + protected Answer execute(final CreateCommand cmd) { + final StorageFilerTO pool = cmd.getPool(); + final DiskProfile dskch = cmd.getDiskCharacteristics(); KVMPhysicalDisk BaseVol = null; KVMStoragePool primaryPool = null; KVMPhysicalDisk vol = null; @@ -1775,7 +1780,7 @@ protected Answer execute(CreateCommand cmd) { } else { vol = primaryPool.createPhysicalDisk(dskch.getPath(), dskch.getProvisioningType(), dskch.getSize()); } - VolumeTO volume = + final VolumeTO volume = new VolumeTO(cmd.getVolumeId(), dskch.getType(), pool.getType(), pool.getUuid(), pool.getPath(), vol.getName(), vol.getName(), disksize, null); volume.setBytesReadRate(dskch.getBytesReadRate()); volume.setBytesWriteRate(dskch.getBytesWriteRate()); @@ -1783,16 +1788,16 @@ protected Answer execute(CreateCommand cmd) { volume.setIopsWriteRate(dskch.getIopsWriteRate()); volume.setCacheMode(dskch.getCacheMode()); return new CreateAnswer(cmd, volume); - } catch (CloudRuntimeException e) { + } catch (final CloudRuntimeException e) { s_logger.debug("Failed to create volume: " + e.toString()); return new CreateAnswer(cmd, e); } } // this is much like PrimaryStorageDownloadCommand, but keeping it separate - protected KVMPhysicalDisk templateToPrimaryDownload(String templateUrl, KVMStoragePool primaryPool, String volUuid) { - int index = templateUrl.lastIndexOf("/"); - String mountpoint = templateUrl.substring(0, index); + protected KVMPhysicalDisk templateToPrimaryDownload(final String templateUrl, final KVMStoragePool primaryPool, final String volUuid) { + final int index = templateUrl.lastIndexOf("/"); + final String mountpoint = templateUrl.substring(0, index); String templateName = null; if (index < templateUrl.length() - 1) { templateName = templateUrl.substring(index + 1); @@ -1805,12 +1810,12 @@ protected KVMPhysicalDisk templateToPrimaryDownload(String templateUrl, KVMStora /* Get template vol */ if (templateName == null) { secondaryPool.refresh(); - List disks = secondaryPool.listPhysicalDisks(); + final List disks = secondaryPool.listPhysicalDisks(); if (disks == null || disks.isEmpty()) { s_logger.error("Failed to get volumes from pool: " + secondaryPool.getUuid()); return null; } - for (KVMPhysicalDisk disk : disks) { + for (final KVMPhysicalDisk disk : disks) { if (disk.getName().endsWith("qcow2")) { templateVol = disk; break; @@ -1826,9 +1831,9 @@ protected KVMPhysicalDisk templateToPrimaryDownload(String templateUrl, KVMStora /* Copy volume to primary storage */ - KVMPhysicalDisk primaryVol = _storagePoolMgr.copyPhysicalDisk(templateVol, volUuid, primaryPool, 0); + final KVMPhysicalDisk primaryVol = _storagePoolMgr.copyPhysicalDisk(templateVol, volUuid, primaryPool, 0); return primaryVol; - } catch (CloudRuntimeException e) { + } catch (final CloudRuntimeException e) { s_logger.error("Failed to download template to primary storage", e); return null; } finally { @@ -1838,9 +1843,9 @@ protected KVMPhysicalDisk templateToPrimaryDownload(String templateUrl, KVMStora } } - private String getResizeScriptType(KVMStoragePool pool, KVMPhysicalDisk vol) { - StoragePoolType poolType = pool.getType(); - PhysicalDiskFormat volFormat = vol.getFormat(); + private String getResizeScriptType(final KVMStoragePool pool, final KVMPhysicalDisk vol) { + final StoragePoolType poolType = pool.getType(); + final PhysicalDiskFormat volFormat = vol.getFormat(); if (pool.getType() == StoragePoolType.CLVM && volFormat == PhysicalDiskFormat.RAW) { return "CLVM"; @@ -1856,13 +1861,13 @@ private String getResizeScriptType(KVMStoragePool pool, KVMPhysicalDisk vol) { /* uses a local script now, eventually support for virStorageVolResize() will maybe work on qcow2 and lvm and we can do this in libvirt calls */ - public Answer execute(ResizeVolumeCommand cmd) { - String volid = cmd.getPath(); - long newSize = cmd.getNewSize(); - long currentSize = cmd.getCurrentSize(); - String vmInstanceName = cmd.getInstanceName(); - boolean shrinkOk = cmd.getShrinkOk(); - StorageFilerTO spool = cmd.getPool(); + public Answer execute(final ResizeVolumeCommand cmd) { + final String volid = cmd.getPath(); + final long newSize = cmd.getNewSize(); + final long currentSize = cmd.getCurrentSize(); + final String vmInstanceName = cmd.getInstanceName(); + final boolean shrinkOk = cmd.getShrinkOk(); + final StorageFilerTO spool = cmd.getPool(); final String notifyOnlyType = "NOTIFYONLY"; if ( currentSize == newSize) { @@ -1873,8 +1878,8 @@ public Answer execute(ResizeVolumeCommand cmd) { try { KVMStoragePool pool = _storagePoolMgr.getStoragePool(spool.getType(), spool.getUuid()); - KVMPhysicalDisk vol = pool.getPhysicalDisk(volid); - String path = vol.getPath(); + final KVMPhysicalDisk vol = pool.getPhysicalDisk(volid); + final String path = vol.getPath(); String type = getResizeScriptType(pool, vol); if (pool.getType() != StoragePoolType.RBD) { @@ -1891,8 +1896,8 @@ public Answer execute(ResizeVolumeCommand cmd) { if (pool.getType() != StoragePoolType.CLVM && vol.getFormat() != PhysicalDiskFormat.QCOW2) { s_logger.debug("Volume " + path + " can be resized by libvirt. Asking libvirt to resize the volume."); try { - Connect conn = LibvirtConnection.getConnection(); - StorageVol v = conn.storageVolLookupByPath(path); + final Connect conn = LibvirtConnection.getConnection(); + final StorageVol v = conn.storageVolLookupByPath(path); int flags = 0; if (conn.getLibVirVersion() > 1001000 && vol.getFormat() == PhysicalDiskFormat.RAW && pool.getType() != StoragePoolType.RBD) { @@ -1904,7 +1909,7 @@ public Answer execute(ResizeVolumeCommand cmd) { v.resize(newSize, flags); type = notifyOnlyType; - } catch (LibvirtException e) { + } catch (final LibvirtException e) { return new ResizeVolumeAnswer(cmd, false, e.toString()); } } @@ -1916,7 +1921,7 @@ public Answer execute(ResizeVolumeCommand cmd) { resizecmd.add("-t", type); resizecmd.add("-r", String.valueOf(shrinkOk)); resizecmd.add("-v", vmInstanceName); - String result = resizecmd.execute(); + final String result = resizecmd.execute(); if (result != null) { if(type.equals(notifyOnlyType)) { @@ -1929,33 +1934,33 @@ public Answer execute(ResizeVolumeCommand cmd) { /* fetch new size as seen from libvirt, don't want to assume anything */ pool = _storagePoolMgr.getStoragePool(spool.getType(), spool.getUuid()); pool.refresh(); - long finalSize = pool.getPhysicalDisk(volid).getVirtualSize(); + final long finalSize = pool.getPhysicalDisk(volid).getVirtualSize(); s_logger.debug("after resize, size reports as " + finalSize + ", requested " + newSize); return new ResizeVolumeAnswer(cmd, true, "success", finalSize); - } catch (CloudRuntimeException e) { - String error = "Failed to resize volume: " + e.getMessage(); + } catch (final CloudRuntimeException e) { + final String error = "Failed to resize volume: " + e.getMessage(); s_logger.debug(error); return new ResizeVolumeAnswer(cmd, false, error); } } - public Answer execute(DestroyCommand cmd) { - VolumeTO vol = cmd.getVolume(); + public Answer execute(final DestroyCommand cmd) { + final VolumeTO vol = cmd.getVolume(); try { - KVMStoragePool pool = _storagePoolMgr.getStoragePool(vol.getPoolType(), vol.getPoolUuid()); + final KVMStoragePool pool = _storagePoolMgr.getStoragePool(vol.getPoolType(), vol.getPoolUuid()); pool.deletePhysicalDisk(vol.getPath(), null); return new Answer(cmd, true, "Success"); - } catch (CloudRuntimeException e) { + } catch (final CloudRuntimeException e) { s_logger.debug("Failed to delete volume: " + e.toString()); return new Answer(cmd, false, e.toString()); } } - private String getBroadcastUriFromBridge(String brName) { - String pif = matchPifFileInDirectory(brName); - Pattern pattern = Pattern.compile("(\\D+)(\\d+)(\\D*)(\\d*)"); - Matcher matcher = pattern.matcher(pif); + private String getBroadcastUriFromBridge(final String brName) { + final String pif = matchPifFileInDirectory(brName); + final Pattern pattern = Pattern.compile("(\\D+)(\\d+)(\\D*)(\\d*)"); + final Matcher matcher = pattern.matcher(pif); s_logger.debug("getting broadcast uri for pif " + pif + " and bridge " + brName); if(matcher.find()) { if (brName.startsWith("brvx")){ @@ -1977,14 +1982,14 @@ private String getBroadcastUriFromBridge(String brName) { } } - private Answer execute(PvlanSetupCommand cmd) { - String primaryPvlan = cmd.getPrimary(); - String isolatedPvlan = cmd.getIsolated(); - String op = cmd.getOp(); - String dhcpName = cmd.getDhcpName(); - String dhcpMac = cmd.getDhcpMac(); - String dhcpIp = cmd.getDhcpIp(); - String vmMac = cmd.getVmMac(); + private Answer execute(final PvlanSetupCommand cmd) { + final String primaryPvlan = cmd.getPrimary(); + final String isolatedPvlan = cmd.getIsolated(); + final String op = cmd.getOp(); + final String dhcpName = cmd.getDhcpName(); + final String dhcpMac = cmd.getDhcpMac(); + final String dhcpIp = cmd.getDhcpIp(); + final String vmMac = cmd.getVmMac(); boolean add = true; String opr = "-A"; @@ -1997,11 +2002,11 @@ private Answer execute(PvlanSetupCommand cmd) { Connect conn; try { if (cmd.getType() == PvlanSetupCommand.Type.DHCP) { - Script script = new Script(_ovsPvlanDhcpHostPath, _timeout, s_logger); + final Script script = new Script(_ovsPvlanDhcpHostPath, _timeout, s_logger); if (add) { conn = LibvirtConnection.getConnectionByVmName(dhcpName); - List ifaces = getInterfaces(conn, dhcpName); - InterfaceDef guestNic = ifaces.get(0); + final List ifaces = getInterfaces(conn, dhcpName); + final InterfaceDef guestNic = ifaces.get(0); script.add(opr, "-b", _guestBridgeName, "-p", primaryPvlan, "-i", isolatedPvlan, "-n", dhcpName, "-d", dhcpIp, "-m", dhcpMac, "-I", guestNic.getDevName()); } else { @@ -2015,7 +2020,7 @@ private Answer execute(PvlanSetupCommand cmd) { s_logger.info("Programmed pvlan for dhcp server with mac " + dhcpMac); } } else if (cmd.getType() == PvlanSetupCommand.Type.VM) { - Script script = new Script(_ovsPvlanVmPath, _timeout, s_logger); + final Script script = new Script(_ovsPvlanVmPath, _timeout, s_logger); script.add(opr, "-b", _guestBridgeName, "-p", primaryPvlan, "-i", isolatedPvlan, "-v", vmMac); result = script.execute(); if (result != null) { @@ -2025,57 +2030,57 @@ private Answer execute(PvlanSetupCommand cmd) { s_logger.info("Programmed pvlan for vm with mac " + vmMac); } } - } catch (LibvirtException e) { + } catch (final LibvirtException e) { // TODO Auto-generated catch block e.printStackTrace(); } return new Answer(cmd, true, result); } - private void VifHotPlug(Connect conn, String vmName, String broadcastUri, String macAddr) throws InternalErrorException, LibvirtException { - NicTO nicTO = new NicTO(); + private void VifHotPlug(final Connect conn, final String vmName, final String broadcastUri, final String macAddr) throws InternalErrorException, LibvirtException { + final NicTO nicTO = new NicTO(); nicTO.setMac(macAddr); nicTO.setType(TrafficType.Public); if (broadcastUri == null) { nicTO.setBroadcastType(BroadcastDomainType.Native); } else { - URI uri = BroadcastDomainType.fromString(broadcastUri); + final URI uri = BroadcastDomainType.fromString(broadcastUri); nicTO.setBroadcastType(BroadcastDomainType.getSchemeValue(uri)); nicTO.setBroadcastUri(uri); } - Domain vm = getDomain(conn, vmName); + final Domain vm = getDomain(conn, vmName); vm.attachDevice(getVifDriver(nicTO.getType()).plug(nicTO, "Other PV", "").toString()); } - private void vifHotUnPlug (Connect conn, String vmName, String macAddr) throws InternalErrorException, LibvirtException { + private void vifHotUnPlug (final Connect conn, final String vmName, final String macAddr) throws InternalErrorException, LibvirtException { Domain vm = null; vm = getDomain(conn, vmName); - List pluggedNics = getInterfaces(conn, vmName); - for (InterfaceDef pluggedNic : pluggedNics) { + final List pluggedNics = getInterfaces(conn, vmName); + for (final InterfaceDef pluggedNic : pluggedNics) { if (pluggedNic.getMacAddress().equalsIgnoreCase(macAddr)) { vm.detachDevice(pluggedNic.toString()); // We don't know which "traffic type" is associated with // each interface at this point, so inform all vif drivers - for (VifDriver vifDriver : getAllVifDrivers()) { + for (final VifDriver vifDriver : getAllVifDrivers()) { vifDriver.unplug(pluggedNic); } } } } - private PlugNicAnswer execute(PlugNicCommand cmd) { - NicTO nic = cmd.getNic(); - String vmName = cmd.getVmName(); + private PlugNicAnswer execute(final PlugNicCommand cmd) { + final NicTO nic = cmd.getNic(); + final String vmName = cmd.getVmName(); Domain vm = null; try { - Connect conn = LibvirtConnection.getConnectionByVmName(vmName); + final Connect conn = LibvirtConnection.getConnectionByVmName(vmName); vm = getDomain(conn, vmName); - List pluggedNics = getInterfaces(conn, vmName); + final List pluggedNics = getInterfaces(conn, vmName); Integer nicnum = 0; - for (InterfaceDef pluggedNic : pluggedNics) { + for (final InterfaceDef pluggedNic : pluggedNics) { if (pluggedNic.getMacAddress().equalsIgnoreCase(nic.getMac())) { s_logger.debug("found existing nic for mac " + pluggedNic.getMacAddress() + " at index " + nicnum); return new PlugNicAnswer(cmd, true, "success"); @@ -2084,72 +2089,72 @@ private PlugNicAnswer execute(PlugNicCommand cmd) { } vm.attachDevice(getVifDriver(nic.getType()).plug(nic, "Other PV", "").toString()); return new PlugNicAnswer(cmd, true, "success"); - } catch (LibvirtException e) { - String msg = " Plug Nic failed due to " + e.toString(); + } catch (final LibvirtException e) { + final String msg = " Plug Nic failed due to " + e.toString(); s_logger.warn(msg, e); return new PlugNicAnswer(cmd, false, msg); - } catch (InternalErrorException e) { - String msg = " Plug Nic failed due to " + e.toString(); + } catch (final InternalErrorException e) { + final String msg = " Plug Nic failed due to " + e.toString(); s_logger.warn(msg, e); return new PlugNicAnswer(cmd, false, msg); } finally { if (vm != null) { try { vm.free(); - } catch (LibvirtException l) { + } catch (final LibvirtException l) { s_logger.trace("Ignoring libvirt error.", l); } } } } - private UnPlugNicAnswer execute(UnPlugNicCommand cmd) { + private UnPlugNicAnswer execute(final UnPlugNicCommand cmd) { Connect conn; - NicTO nic = cmd.getNic(); - String vmName = cmd.getVmName(); + final NicTO nic = cmd.getNic(); + final String vmName = cmd.getVmName(); Domain vm = null; try { conn = LibvirtConnection.getConnectionByVmName(vmName); vm = getDomain(conn, vmName); - List pluggedNics = getInterfaces(conn, vmName); - for (InterfaceDef pluggedNic : pluggedNics) { + final List pluggedNics = getInterfaces(conn, vmName); + for (final InterfaceDef pluggedNic : pluggedNics) { if (pluggedNic.getMacAddress().equalsIgnoreCase(nic.getMac())) { vm.detachDevice(pluggedNic.toString()); // We don't know which "traffic type" is associated with // each interface at this point, so inform all vif drivers - for (VifDriver vifDriver : getAllVifDrivers()) { + for (final VifDriver vifDriver : getAllVifDrivers()) { vifDriver.unplug(pluggedNic); } return new UnPlugNicAnswer(cmd, true, "success"); } } return new UnPlugNicAnswer(cmd, true, "success"); - } catch (LibvirtException e) { - String msg = " Unplug Nic failed due to " + e.toString(); + } catch (final LibvirtException e) { + final String msg = " Unplug Nic failed due to " + e.toString(); s_logger.warn(msg, e); return new UnPlugNicAnswer(cmd, false, msg); } finally { if (vm != null) { try { vm.free(); - } catch (LibvirtException l) { + } catch (final LibvirtException l) { s_logger.trace("Ignoring libvirt error.", l); } } } } - private ExecutionResult prepareNetworkElementCommand(SetupGuestNetworkCommand cmd) { + private ExecutionResult prepareNetworkElementCommand(final SetupGuestNetworkCommand cmd) { Connect conn; - NicTO nic = cmd.getNic(); - String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME); + final NicTO nic = cmd.getNic(); + final String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME); try { conn = LibvirtConnection.getConnectionByVmName(routerName); - List pluggedNics = getInterfaces(conn, routerName); + final List pluggedNics = getInterfaces(conn, routerName); InterfaceDef routerNic = null; - for (InterfaceDef pluggedNic : pluggedNics) { + for (final InterfaceDef pluggedNic : pluggedNics) { if (pluggedNic.getMacAddress().equalsIgnoreCase(nic.getMac())) { routerNic = pluggedNic; break; @@ -2161,28 +2166,28 @@ private ExecutionResult prepareNetworkElementCommand(SetupGuestNetworkCommand cm } return new ExecutionResult(true, null); - } catch (LibvirtException e) { - String msg = "Creating guest network failed due to " + e.toString(); + } catch (final LibvirtException e) { + final String msg = "Creating guest network failed due to " + e.toString(); s_logger.warn(msg, e); return new ExecutionResult(false, msg); } } - protected ExecutionResult prepareNetworkElementCommand(SetSourceNatCommand cmd) { + protected ExecutionResult prepareNetworkElementCommand(final SetSourceNatCommand cmd) { Connect conn; - String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME); + final String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME); cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); - IpAddressTO pubIP = cmd.getIpAddress(); + final IpAddressTO pubIP = cmd.getIpAddress(); try { conn = LibvirtConnection.getConnectionByVmName(routerName); Integer devNum = 0; - String pubVlan = pubIP.getBroadcastUri(); - List pluggedNics = getInterfaces(conn, routerName); + final String pubVlan = pubIP.getBroadcastUri(); + final List pluggedNics = getInterfaces(conn, routerName); - for (InterfaceDef pluggedNic : pluggedNics) { - String pluggedVlanBr = pluggedNic.getBrName(); - String pluggedVlanId = getBroadcastUriFromBridge(pluggedVlanBr); + for (final InterfaceDef pluggedNic : pluggedNics) { + final String pluggedVlanBr = pluggedNic.getBrName(); + final String pluggedVlanId = getBroadcastUriFromBridge(pluggedVlanBr); if (pubVlan.equalsIgnoreCase(Vlan.UNTAGGED) && pluggedVlanBr.equalsIgnoreCase(_publicBridgeName)) { break; } else if (pluggedVlanBr.equalsIgnoreCase(_linkLocalBridgeName)) { @@ -2200,26 +2205,26 @@ protected ExecutionResult prepareNetworkElementCommand(SetSourceNatCommand cmd) pubIP.setNicDevId(devNum); return new ExecutionResult(true, "success"); - } catch (LibvirtException e) { - String msg = "Ip SNAT failure due to " + e.toString(); + } catch (final LibvirtException e) { + final String msg = "Ip SNAT failure due to " + e.toString(); s_logger.error(msg, e); return new ExecutionResult(false, msg); } } - protected ExecutionResult prepareNetworkElementCommand(IpAssocVpcCommand cmd) { + protected ExecutionResult prepareNetworkElementCommand(final IpAssocVpcCommand cmd) { Connect conn; - String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME); + final String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME); try { conn = LibvirtConnection.getConnectionByVmName(routerName); - IpAddressTO[] ips = cmd.getIpAddresses(); + final IpAddressTO[] ips = cmd.getIpAddresses(); Integer devNum = 0; - Map broadcastUriToNicNum = new HashMap(); - List pluggedNics = getInterfaces(conn, routerName); + final Map broadcastUriToNicNum = new HashMap(); + final List pluggedNics = getInterfaces(conn, routerName); - for (InterfaceDef pluggedNic : pluggedNics) { - String pluggedVlan = pluggedNic.getBrName(); + for (final InterfaceDef pluggedNic : pluggedNics) { + final String pluggedVlan = pluggedNic.getBrName(); if (pluggedVlan.equalsIgnoreCase(_linkLocalBridgeName)) { broadcastUriToNicNum.put("LinkLocal", devNum); } else if (pluggedVlan.equalsIgnoreCase(_publicBridgeName) || pluggedVlan.equalsIgnoreCase(_privBridgeName) || @@ -2231,27 +2236,27 @@ protected ExecutionResult prepareNetworkElementCommand(IpAssocVpcCommand cmd) { devNum++; } - for (IpAddressTO ip : ips) { + for (final IpAddressTO ip : ips) { ip.setNicDevId(broadcastUriToNicNum.get(ip.getBroadcastUri())); } return new ExecutionResult(true, null); - } catch (LibvirtException e) { + } catch (final LibvirtException e) { s_logger.error("Ip Assoc failure on applying one ip due to exception: ", e); return new ExecutionResult(false, e.getMessage()); } } - public ExecutionResult prepareNetworkElementCommand(IpAssocCommand cmd) { - String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME); - String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); + public ExecutionResult prepareNetworkElementCommand(final IpAssocCommand cmd) { + final String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME); + final String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); Connect conn; try { conn = LibvirtConnection.getConnectionByVmName(routerName); - List nics = getInterfaces(conn, routerName); - Map broadcastUriAllocatedToVM = new HashMap(); + final List nics = getInterfaces(conn, routerName); + final Map broadcastUriAllocatedToVM = new HashMap(); Integer nicPos = 0; - for (InterfaceDef nic : nics) { + for (final InterfaceDef nic : nics) { if (nic.getBrName().equalsIgnoreCase(_linkLocalBridgeName)) { broadcastUriAllocatedToVM.put("LinkLocal", nicPos); } else { @@ -2259,15 +2264,15 @@ public ExecutionResult prepareNetworkElementCommand(IpAssocCommand cmd) { nic.getBrName().equalsIgnoreCase(_guestBridgeName)) { broadcastUriAllocatedToVM.put(BroadcastDomainType.Vlan.toUri(Vlan.UNTAGGED).toString(), nicPos); } else { - String broadcastUri = getBroadcastUriFromBridge(nic.getBrName()); + final String broadcastUri = getBroadcastUriFromBridge(nic.getBrName()); broadcastUriAllocatedToVM.put(broadcastUri, nicPos); } } nicPos++; } - IpAddressTO[] ips = cmd.getIpAddresses(); + final IpAddressTO[] ips = cmd.getIpAddresses(); int nicNum = 0; - for (IpAddressTO ip : ips) { + for (final IpAddressTO ip : ips) { boolean newNic = false; if (!broadcastUriAllocatedToVM.containsKey(ip.getBroadcastUri())) { /* plug a vif into router */ @@ -2282,29 +2287,29 @@ public ExecutionResult prepareNetworkElementCommand(IpAssocCommand cmd) { ip.setNewNic(newNic); } return new ExecutionResult(true, null); - } catch (LibvirtException e) { + } catch (final LibvirtException e) { s_logger.error("ipassoccmd failed", e); return new ExecutionResult(false, e.getMessage()); - } catch (InternalErrorException e) { + } catch (final InternalErrorException e) { s_logger.error("ipassoccmd failed", e); return new ExecutionResult(false, e.getMessage()); } } - protected ExecutionResult cleanupNetworkElementCommand(IpAssocCommand cmd) { + protected ExecutionResult cleanupNetworkElementCommand(final IpAssocCommand cmd) { - String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME); - String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); + final String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME); + final String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); Connect conn; try{ conn = LibvirtConnection.getConnectionByVmName(routerName); - List nics = getInterfaces(conn, routerName); - Map broadcastUriAllocatedToVM = new HashMap(); + final List nics = getInterfaces(conn, routerName); + final Map broadcastUriAllocatedToVM = new HashMap(); Integer nicPos = 0; - for (InterfaceDef nic : nics) { + for (final InterfaceDef nic : nics) { if (nic.getBrName().equalsIgnoreCase(_linkLocalBridgeName)) { broadcastUriAllocatedToVM.put("LinkLocal", nicPos); } else { @@ -2312,17 +2317,17 @@ protected ExecutionResult cleanupNetworkElementCommand(IpAssocCommand cmd) { nic.getBrName().equalsIgnoreCase(_guestBridgeName)) { broadcastUriAllocatedToVM.put(BroadcastDomainType.Vlan.toUri(Vlan.UNTAGGED).toString(), nicPos); } else { - String broadcastUri = getBroadcastUriFromBridge(nic.getBrName()); + final String broadcastUri = getBroadcastUriFromBridge(nic.getBrName()); broadcastUriAllocatedToVM.put(broadcastUri, nicPos); } } nicPos++; } - IpAddressTO[] ips = cmd.getIpAddresses(); - int numOfIps = ips.length; + final IpAddressTO[] ips = cmd.getIpAddresses(); + final int numOfIps = ips.length; int nicNum = 0; - for (IpAddressTO ip : ips) { + for (final IpAddressTO ip : ips) { if (!broadcastUriAllocatedToVM.containsKey(ip.getBroadcastUri())) { /* plug a vif into router */ @@ -2337,10 +2342,10 @@ protected ExecutionResult cleanupNetworkElementCommand(IpAssocCommand cmd) { } } - } catch (LibvirtException e) { + } catch (final LibvirtException e) { s_logger.error("ipassoccmd failed", e); return new ExecutionResult(false, e.getMessage()); - } catch (InternalErrorException e) { + } catch (final InternalErrorException e) { s_logger.error("ipassoccmd failed", e); return new ExecutionResult(false, e.getMessage()); } @@ -2349,34 +2354,34 @@ protected ExecutionResult cleanupNetworkElementCommand(IpAssocCommand cmd) { } protected ManageSnapshotAnswer execute(final ManageSnapshotCommand cmd) { - String snapshotName = cmd.getSnapshotName(); - String snapshotPath = cmd.getSnapshotPath(); - String vmName = cmd.getVmName(); + final String snapshotName = cmd.getSnapshotName(); + final String snapshotPath = cmd.getSnapshotPath(); + final String vmName = cmd.getVmName(); try { - Connect conn = LibvirtConnection.getConnectionByVmName(vmName); + final Connect conn = LibvirtConnection.getConnectionByVmName(vmName); DomainState state = null; Domain vm = null; if (vmName != null) { try { vm = getDomain(conn, cmd.getVmName()); state = vm.getInfo().state; - } catch (LibvirtException e) { + } catch (final LibvirtException e) { s_logger.trace("Ignoring libvirt error.", e); } } - KVMStoragePool primaryPool = _storagePoolMgr.getStoragePool(cmd.getPool().getType(), cmd.getPool().getUuid()); + final KVMStoragePool primaryPool = _storagePoolMgr.getStoragePool(cmd.getPool().getType(), cmd.getPool().getUuid()); - KVMPhysicalDisk disk = primaryPool.getPhysicalDisk(cmd.getVolumePath()); + final KVMPhysicalDisk disk = primaryPool.getPhysicalDisk(cmd.getVolumePath()); if (state == DomainState.VIR_DOMAIN_RUNNING && !primaryPool.isExternalSnapshot()) { - String vmUuid = vm.getUUIDString(); - Object[] args = new Object[] {snapshotName, vmUuid}; - String snapshot = SnapshotXML.format(args); + final String vmUuid = vm.getUUIDString(); + final Object[] args = new Object[] {snapshotName, vmUuid}; + final String snapshot = SnapshotXML.format(args); s_logger.debug(snapshot); if (cmd.getCommandSwitch().equalsIgnoreCase(ManageSnapshotCommand.CREATE_SNAPSHOT)) { vm.snapshotCreateXML(snapshot); } else { - DomainSnapshot snap = vm.snapshotLookupByName(snapshotName); + final DomainSnapshot snap = vm.snapshotLookupByName(snapshotName); snap.delete(0); } @@ -2405,16 +2410,16 @@ protected ManageSnapshotAnswer execute(final ManageSnapshotCommand cmd) { */ if (primaryPool.getType() == StoragePoolType.RBD) { try { - Rados r = new Rados(primaryPool.getAuthUserName()); + final Rados r = new Rados(primaryPool.getAuthUserName()); r.confSet("mon_host", primaryPool.getSourceHost() + ":" + primaryPool.getSourcePort()); r.confSet("key", primaryPool.getAuthSecret()); r.confSet("client_mount_timeout", "30"); r.connect(); s_logger.debug("Succesfully connected to Ceph cluster at " + r.confGet("mon_host")); - IoCTX io = r.ioCtxCreate(primaryPool.getSourceDir()); - Rbd rbd = new Rbd(io); - RbdImage image = rbd.open(disk.getName()); + final IoCTX io = r.ioCtxCreate(primaryPool.getSourceDir()); + final Rbd rbd = new Rbd(io); + final RbdImage image = rbd.open(disk.getName()); if (cmd.getCommandSwitch().equalsIgnoreCase(ManageSnapshotCommand.CREATE_SNAPSHOT)) { s_logger.debug("Attempting to create RBD snapshot " + disk.getName() + "@" + snapshotName); @@ -2426,7 +2431,7 @@ protected ManageSnapshotAnswer execute(final ManageSnapshotCommand cmd) { rbd.close(image); r.ioCtxDestroy(io); - } catch (Exception e) { + } catch (final Exception e) { s_logger.error("A RBD snapshot operation on " + disk.getName() + " failed. The error was: " + e.getMessage()); } } else { @@ -2439,7 +2444,7 @@ protected ManageSnapshotAnswer execute(final ManageSnapshotCommand cmd) { } command.add("-n", snapshotName); - String result = command.execute(); + final String result = command.execute(); if (result != null) { s_logger.debug("Failed to manage snapshot: " + result); return new ManageSnapshotAnswer(cmd, false, "Failed to manage snapshot: " + result); @@ -2447,7 +2452,7 @@ protected ManageSnapshotAnswer execute(final ManageSnapshotCommand cmd) { } } return new ManageSnapshotAnswer(cmd, cmd.getSnapshotId(), disk.getPath() + File.separator + snapshotName, true, null); - } catch (LibvirtException e) { + } catch (final LibvirtException e) { s_logger.debug("Failed to manage snapshot: " + e.toString()); return new ManageSnapshotAnswer(cmd, false, "Failed to manage snapshot: " + e.toString()); } @@ -2455,26 +2460,26 @@ protected ManageSnapshotAnswer execute(final ManageSnapshotCommand cmd) { } protected BackupSnapshotAnswer execute(final BackupSnapshotCommand cmd) { - Long dcId = cmd.getDataCenterId(); - Long accountId = cmd.getAccountId(); - Long volumeId = cmd.getVolumeId(); - String secondaryStoragePoolUrl = cmd.getSecondaryStorageUrl(); - String snapshotName = cmd.getSnapshotName(); + final Long dcId = cmd.getDataCenterId(); + final Long accountId = cmd.getAccountId(); + final Long volumeId = cmd.getVolumeId(); + final String secondaryStoragePoolUrl = cmd.getSecondaryStorageUrl(); + final String snapshotName = cmd.getSnapshotName(); String snapshotDestPath = null; String snapshotRelPath = null; - String vmName = cmd.getVmName(); + final String vmName = cmd.getVmName(); KVMStoragePool secondaryStoragePool = null; try { - Connect conn = LibvirtConnection.getConnectionByVmName(vmName); + final Connect conn = LibvirtConnection.getConnectionByVmName(vmName); secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(secondaryStoragePoolUrl); - String ssPmountPath = secondaryStoragePool.getLocalPath(); + final String ssPmountPath = secondaryStoragePool.getLocalPath(); snapshotRelPath = File.separator + "snapshots" + File.separator + dcId + File.separator + accountId + File.separator + volumeId; snapshotDestPath = ssPmountPath + File.separator + "snapshots" + File.separator + dcId + File.separator + accountId + File.separator + volumeId; - KVMStoragePool primaryPool = _storagePoolMgr.getStoragePool(cmd.getPool().getType(), cmd.getPrimaryStoragePoolNameLabel()); - KVMPhysicalDisk snapshotDisk = primaryPool.getPhysicalDisk(cmd.getVolumePath()); + final KVMStoragePool primaryPool = _storagePoolMgr.getStoragePool(cmd.getPool().getType(), cmd.getPrimaryStoragePoolNameLabel()); + final KVMPhysicalDisk snapshotDisk = primaryPool.getPhysicalDisk(cmd.getVolumePath()); /** * RBD snapshots can't be copied using qemu-img, so we have to use @@ -2488,24 +2493,24 @@ protected BackupSnapshotAnswer execute(final BackupSnapshotCommand cmd) { */ if (primaryPool.getType() == StoragePoolType.RBD) { try { - Rados r = new Rados(primaryPool.getAuthUserName()); + final Rados r = new Rados(primaryPool.getAuthUserName()); r.confSet("mon_host", primaryPool.getSourceHost() + ":" + primaryPool.getSourcePort()); r.confSet("key", primaryPool.getAuthSecret()); r.confSet("client_mount_timeout", "30"); r.connect(); s_logger.debug("Succesfully connected to Ceph cluster at " + r.confGet("mon_host")); - IoCTX io = r.ioCtxCreate(primaryPool.getSourceDir()); - Rbd rbd = new Rbd(io); - RbdImage image = rbd.open(snapshotDisk.getName(), snapshotName); - File fh = new File(snapshotDestPath); + final IoCTX io = r.ioCtxCreate(primaryPool.getSourceDir()); + final Rbd rbd = new Rbd(io); + final RbdImage image = rbd.open(snapshotDisk.getName(), snapshotName); + final File fh = new File(snapshotDestPath); try(BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(fh));) { - int chunkSize = 4194304; + final int chunkSize = 4194304; long offset = 0; s_logger.debug("Backuping up RBD snapshot " + snapshotName + " to " + snapshotDestPath); while (true) { - byte[] buf = new byte[chunkSize]; - int bytes = image.read(offset, buf, chunkSize); + final byte[] buf = new byte[chunkSize]; + final int bytes = image.read(offset, buf, chunkSize); if (bytes <= 0) { break; } @@ -2513,25 +2518,25 @@ protected BackupSnapshotAnswer execute(final BackupSnapshotCommand cmd) { offset += bytes; } s_logger.debug("Completed backing up RBD snapshot " + snapshotName + " to " + snapshotDestPath + ". Bytes written: " + offset); - }catch(IOException ex) + }catch(final IOException ex) { s_logger.error("BackupSnapshotAnswer:Exception:"+ ex.getMessage()); } r.ioCtxDestroy(io); - } catch (RadosException e) { + } catch (final RadosException e) { s_logger.error("A RADOS operation failed. The error was: " + e.getMessage()); return new BackupSnapshotAnswer(cmd, false, e.toString(), null, true); - } catch (RbdException e) { + } catch (final RbdException e) { s_logger.error("A RBD operation on " + snapshotDisk.getName() + " failed. The error was: " + e.getMessage()); return new BackupSnapshotAnswer(cmd, false, e.toString(), null, true); } } else { - Script command = new Script(_manageSnapshotPath, _cmdsTimeout, s_logger); + final Script command = new Script(_manageSnapshotPath, _cmdsTimeout, s_logger); command.add("-b", snapshotDisk.getPath()); command.add("-n", snapshotName); command.add("-p", snapshotDestPath); command.add("-t", snapshotName); - String result = command.execute(); + final String result = command.execute(); if (result != null) { s_logger.debug("Failed to backup snaptshot: " + result); return new BackupSnapshotAnswer(cmd, false, result, null, true); @@ -2545,18 +2550,18 @@ protected BackupSnapshotAnswer execute(final BackupSnapshotCommand cmd) { try { vm = getDomain(conn, cmd.getVmName()); state = vm.getInfo().state; - } catch (LibvirtException e) { + } catch (final LibvirtException e) { s_logger.trace("Ignoring libvirt error.", e); } } - KVMStoragePool primaryStorage = _storagePoolMgr.getStoragePool(cmd.getPool().getType(), cmd.getPool().getUuid()); + final KVMStoragePool primaryStorage = _storagePoolMgr.getStoragePool(cmd.getPool().getType(), cmd.getPool().getUuid()); if (state == DomainState.VIR_DOMAIN_RUNNING && !primaryStorage.isExternalSnapshot()) { - String vmUuid = vm.getUUIDString(); - Object[] args = new Object[] {snapshotName, vmUuid}; - String snapshot = SnapshotXML.format(args); + final String vmUuid = vm.getUUIDString(); + final Object[] args = new Object[] {snapshotName, vmUuid}; + final String snapshot = SnapshotXML.format(args); s_logger.debug(snapshot); - DomainSnapshot snap = vm.snapshotLookupByName(snapshotName); + final DomainSnapshot snap = vm.snapshotLookupByName(snapshotName); snap.delete(0); /* @@ -2569,18 +2574,18 @@ protected BackupSnapshotAnswer execute(final BackupSnapshotCommand cmd) { vm.resume(); } } else { - Script command = new Script(_manageSnapshotPath, _cmdsTimeout, s_logger); + final Script command = new Script(_manageSnapshotPath, _cmdsTimeout, s_logger); command.add("-d", snapshotDisk.getPath()); command.add("-n", snapshotName); - String result = command.execute(); + final String result = command.execute(); if (result != null) { s_logger.debug("Failed to backup snapshot: " + result); return new BackupSnapshotAnswer(cmd, false, "Failed to backup snapshot: " + result, null, true); } } - } catch (LibvirtException e) { + } catch (final LibvirtException e) { return new BackupSnapshotAnswer(cmd, false, e.toString(), null, true); - } catch (CloudRuntimeException e) { + } catch (final CloudRuntimeException e) { return new BackupSnapshotAnswer(cmd, false, e.toString(), null, true); } finally { if (secondaryStoragePool != null) { @@ -2594,17 +2599,17 @@ protected CreateVolumeFromSnapshotAnswer execute(final CreateVolumeFromSnapshotC try { String snapshotPath = cmd.getSnapshotUuid(); - int index = snapshotPath.lastIndexOf("/"); + final int index = snapshotPath.lastIndexOf("/"); snapshotPath = snapshotPath.substring(0, index); - KVMStoragePool secondaryPool = _storagePoolMgr.getStoragePoolByURI(cmd.getSecondaryStorageUrl() + snapshotPath); - KVMPhysicalDisk snapshot = secondaryPool.getPhysicalDisk(cmd.getSnapshotName()); + final KVMStoragePool secondaryPool = _storagePoolMgr.getStoragePoolByURI(cmd.getSecondaryStorageUrl() + snapshotPath); + final KVMPhysicalDisk snapshot = secondaryPool.getPhysicalDisk(cmd.getSnapshotName()); - String primaryUuid = cmd.getPrimaryStoragePoolNameLabel(); - KVMStoragePool primaryPool = _storagePoolMgr.getStoragePool(cmd.getPool().getType(), primaryUuid); - String volUuid = UUID.randomUUID().toString(); - KVMPhysicalDisk disk = _storagePoolMgr.copyPhysicalDisk(snapshot, volUuid, primaryPool, 0); + final String primaryUuid = cmd.getPrimaryStoragePoolNameLabel(); + final KVMStoragePool primaryPool = _storagePoolMgr.getStoragePool(cmd.getPool().getType(), primaryUuid); + final String volUuid = UUID.randomUUID().toString(); + final KVMPhysicalDisk disk = _storagePoolMgr.copyPhysicalDisk(snapshot, volUuid, primaryPool, 0); return new CreateVolumeFromSnapshotAnswer(cmd, true, "", disk.getName()); - } catch (CloudRuntimeException e) { + } catch (final CloudRuntimeException e) { return new CreateVolumeFromSnapshotAnswer(cmd, false, e.toString(), null); } } @@ -2615,51 +2620,51 @@ protected Answer execute(final UpgradeSnapshotCommand cmd) { } protected CreatePrivateTemplateAnswer execute(final CreatePrivateTemplateFromSnapshotCommand cmd) { - String templateFolder = cmd.getAccountId() + File.separator + cmd.getNewTemplateId(); - String templateInstallFolder = "template/tmpl/" + templateFolder; - String tmplName = UUID.randomUUID().toString(); - String tmplFileName = tmplName + ".qcow2"; + final String templateFolder = cmd.getAccountId() + File.separator + cmd.getNewTemplateId(); + final String templateInstallFolder = "template/tmpl/" + templateFolder; + final String tmplName = UUID.randomUUID().toString(); + final String tmplFileName = tmplName + ".qcow2"; KVMStoragePool secondaryPool = null; KVMStoragePool snapshotPool = null; try { String snapshotPath = cmd.getSnapshotUuid(); - int index = snapshotPath.lastIndexOf("/"); + final int index = snapshotPath.lastIndexOf("/"); snapshotPath = snapshotPath.substring(0, index); snapshotPool = _storagePoolMgr.getStoragePoolByURI(cmd.getSecondaryStorageUrl() + snapshotPath); - KVMPhysicalDisk snapshot = snapshotPool.getPhysicalDisk(cmd.getSnapshotName()); + final KVMPhysicalDisk snapshot = snapshotPool.getPhysicalDisk(cmd.getSnapshotName()); secondaryPool = _storagePoolMgr.getStoragePoolByURI(cmd.getSecondaryStorageUrl()); - String templatePath = secondaryPool.getLocalPath() + File.separator + templateInstallFolder; + final String templatePath = secondaryPool.getLocalPath() + File.separator + templateInstallFolder; _storage.mkdirs(templatePath); - String tmplPath = templateInstallFolder + File.separator + tmplFileName; - Script command = new Script(_createTmplPath, _cmdsTimeout, s_logger); + final String tmplPath = templateInstallFolder + File.separator + tmplFileName; + final Script command = new Script(_createTmplPath, _cmdsTimeout, s_logger); command.add("-t", templatePath); command.add("-n", tmplFileName); command.add("-f", snapshot.getPath()); command.execute(); - Map params = new HashMap(); + final Map params = new HashMap(); params.put(StorageLayer.InstanceConfigKey, _storage); - Processor qcow2Processor = new QCOW2Processor(); + final Processor qcow2Processor = new QCOW2Processor(); qcow2Processor.configure("QCOW2 Processor", params); - FormatInfo info = qcow2Processor.process(templatePath, null, tmplName); + final FormatInfo info = qcow2Processor.process(templatePath, null, tmplName); - TemplateLocation loc = new TemplateLocation(_storage, templatePath); + final TemplateLocation loc = new TemplateLocation(_storage, templatePath); loc.create(1, true, tmplName); loc.addFormat(info); loc.save(); return new CreatePrivateTemplateAnswer(cmd, true, "", tmplPath, info.virtualSize, info.size, tmplName, info.format); - } catch (ConfigurationException e) { + } catch (final ConfigurationException e) { return new CreatePrivateTemplateAnswer(cmd, false, e.getMessage()); - } catch (InternalErrorException e) { + } catch (final InternalErrorException e) { return new CreatePrivateTemplateAnswer(cmd, false, e.getMessage()); - } catch (IOException e) { + } catch (final IOException e) { return new CreatePrivateTemplateAnswer(cmd, false, e.getMessage()); - } catch (CloudRuntimeException e) { + } catch (final CloudRuntimeException e) { return new CreatePrivateTemplateAnswer(cmd, false, e.getMessage()); } finally { if (secondaryPool != null) { @@ -2673,27 +2678,27 @@ protected CreatePrivateTemplateAnswer execute(final CreatePrivateTemplateFromSna protected GetStorageStatsAnswer execute(final GetStorageStatsCommand cmd) { try { - KVMStoragePool sp = _storagePoolMgr.getStoragePool(cmd.getPooltype(), cmd.getStorageId(), true); + final KVMStoragePool sp = _storagePoolMgr.getStoragePool(cmd.getPooltype(), cmd.getStorageId(), true); return new GetStorageStatsAnswer(cmd, sp.getCapacity(), sp.getUsed()); - } catch (CloudRuntimeException e) { + } catch (final CloudRuntimeException e) { return new GetStorageStatsAnswer(cmd, e.toString()); } } - protected CreatePrivateTemplateAnswer execute(CreatePrivateTemplateFromVolumeCommand cmd) { - String secondaryStorageURL = cmd.getSecondaryStorageUrl(); + protected CreatePrivateTemplateAnswer execute(final CreatePrivateTemplateFromVolumeCommand cmd) { + final String secondaryStorageURL = cmd.getSecondaryStorageUrl(); KVMStoragePool secondaryStorage = null; KVMStoragePool primary = null; try { - String templateFolder = cmd.getAccountId() + File.separator + cmd.getTemplateId() + File.separator; - String templateInstallFolder = "/template/tmpl/" + templateFolder; + final String templateFolder = cmd.getAccountId() + File.separator + cmd.getTemplateId() + File.separator; + final String templateInstallFolder = "/template/tmpl/" + templateFolder; secondaryStorage = _storagePoolMgr.getStoragePoolByURI(secondaryStorageURL); try { primary = _storagePoolMgr.getStoragePool(cmd.getPool().getType(), cmd.getPrimaryStoragePoolNameLabel()); - } catch (CloudRuntimeException e) { + } catch (final CloudRuntimeException e) { if (e.getMessage().contains("not found")) { primary = _storagePoolMgr.createStoragePool(cmd.getPool().getUuid(), cmd.getPool().getHost(), cmd.getPool().getPort(), cmd.getPool().getPath(), @@ -2703,17 +2708,17 @@ protected CreatePrivateTemplateAnswer execute(CreatePrivateTemplateFromVolumeCom } } - KVMPhysicalDisk disk = primary.getPhysicalDisk(cmd.getVolumePath()); - String tmpltPath = secondaryStorage.getLocalPath() + File.separator + templateInstallFolder; + final KVMPhysicalDisk disk = primary.getPhysicalDisk(cmd.getVolumePath()); + final String tmpltPath = secondaryStorage.getLocalPath() + File.separator + templateInstallFolder; _storage.mkdirs(tmpltPath); if (primary.getType() != StoragePoolType.RBD) { - Script command = new Script(_createTmplPath, _cmdsTimeout, s_logger); + final Script command = new Script(_createTmplPath, _cmdsTimeout, s_logger); command.add("-f", disk.getPath()); command.add("-t", tmpltPath); command.add("-n", cmd.getUniqueName() + ".qcow2"); - String result = command.execute(); + final String result = command.execute(); if (result != null) { s_logger.debug("failed to create template: " + result); @@ -2722,65 +2727,65 @@ protected CreatePrivateTemplateAnswer execute(CreatePrivateTemplateFromVolumeCom } else { s_logger.debug("Converting RBD disk " + disk.getPath() + " into template " + cmd.getUniqueName()); - QemuImgFile srcFile = + final QemuImgFile srcFile = new QemuImgFile(KVMPhysicalDisk.RBDStringBuilder(primary.getSourceHost(), primary.getSourcePort(), primary.getAuthUserName(), primary.getAuthSecret(), disk.getPath())); srcFile.setFormat(PhysicalDiskFormat.RAW); - QemuImgFile destFile = new QemuImgFile(tmpltPath + "/" + cmd.getUniqueName() + ".qcow2"); + final QemuImgFile destFile = new QemuImgFile(tmpltPath + "/" + cmd.getUniqueName() + ".qcow2"); destFile.setFormat(PhysicalDiskFormat.QCOW2); - QemuImg q = new QemuImg(0); + final QemuImg q = new QemuImg(0); try { q.convert(srcFile, destFile); - } catch (QemuImgException e) { + } catch (final QemuImgException e) { s_logger.error("Failed to create new template while converting " + srcFile.getFileName() + " to " + destFile.getFileName() + " the error was: " + e.getMessage()); } - File templateProp = new File(tmpltPath + "/template.properties"); + final File templateProp = new File(tmpltPath + "/template.properties"); if (!templateProp.exists()) { templateProp.createNewFile(); } String templateContent = "filename=" + cmd.getUniqueName() + ".qcow2" + System.getProperty("line.separator"); - DateFormat dateFormat = new SimpleDateFormat("MM_dd_yyyy"); - Date date = new Date(); + final DateFormat dateFormat = new SimpleDateFormat("MM_dd_yyyy"); + final Date date = new Date(); templateContent += "snapshot.name=" + dateFormat.format(date) + System.getProperty("line.separator"); try(FileOutputStream templFo = new FileOutputStream(templateProp);) { templFo.write(templateContent.getBytes()); templFo.flush(); - }catch(IOException ex) + }catch(final IOException ex) { s_logger.error("CreatePrivateTemplateAnswer:Exception:"+ex.getMessage()); } } - Map params = new HashMap(); + final Map params = new HashMap(); params.put(StorageLayer.InstanceConfigKey, _storage); - Processor qcow2Processor = new QCOW2Processor(); + final Processor qcow2Processor = new QCOW2Processor(); qcow2Processor.configure("QCOW2 Processor", params); - FormatInfo info = qcow2Processor.process(tmpltPath, null, cmd.getUniqueName()); + final FormatInfo info = qcow2Processor.process(tmpltPath, null, cmd.getUniqueName()); - TemplateLocation loc = new TemplateLocation(_storage, tmpltPath); + final TemplateLocation loc = new TemplateLocation(_storage, tmpltPath); loc.create(1, true, cmd.getUniqueName()); loc.addFormat(info); loc.save(); return new CreatePrivateTemplateAnswer(cmd, true, null, templateInstallFolder + cmd.getUniqueName() + ".qcow2", info.virtualSize, info.size, cmd.getUniqueName(), ImageFormat.QCOW2); - } catch (InternalErrorException e) { + } catch (final InternalErrorException e) { return new CreatePrivateTemplateAnswer(cmd, false, e.toString()); - } catch (IOException e) { + } catch (final IOException e) { return new CreatePrivateTemplateAnswer(cmd, false, e.toString()); - } catch (ConfigurationException e) { + } catch (final ConfigurationException e) { return new CreatePrivateTemplateAnswer(cmd, false, e.toString()); - } catch (CloudRuntimeException e) { + } catch (final CloudRuntimeException e) { return new CreatePrivateTemplateAnswer(cmd, false, e.toString()); } finally { if (secondaryStorage != null) { @@ -2790,9 +2795,9 @@ protected CreatePrivateTemplateAnswer execute(CreatePrivateTemplateFromVolumeCom } protected PrimaryStorageDownloadAnswer execute(final PrimaryStorageDownloadCommand cmd) { - String tmplturl = cmd.getUrl(); - int index = tmplturl.lastIndexOf("/"); - String mountpoint = tmplturl.substring(0, index); + final String tmplturl = cmd.getUrl(); + final int index = tmplturl.lastIndexOf("/"); + final String mountpoint = tmplturl.substring(0, index); String tmpltname = null; if (index < tmplturl.length() - 1) { tmpltname = tmplturl.substring(index + 1); @@ -2806,11 +2811,11 @@ protected PrimaryStorageDownloadAnswer execute(final PrimaryStorageDownloadComma /* Get template vol */ if (tmpltname == null) { secondaryPool.refresh(); - List disks = secondaryPool.listPhysicalDisks(); + final List disks = secondaryPool.listPhysicalDisks(); if (disks == null || disks.isEmpty()) { return new PrimaryStorageDownloadAnswer("Failed to get volumes from pool: " + secondaryPool.getUuid()); } - for (KVMPhysicalDisk disk : disks) { + for (final KVMPhysicalDisk disk : disks) { if (disk.getName().endsWith("qcow2")) { tmplVol = disk; break; @@ -2824,12 +2829,12 @@ protected PrimaryStorageDownloadAnswer execute(final PrimaryStorageDownloadComma } /* Copy volume to primary storage */ - KVMStoragePool primaryPool = _storagePoolMgr.getStoragePool(cmd.getPool().getType(), cmd.getPoolUuid()); + final KVMStoragePool primaryPool = _storagePoolMgr.getStoragePool(cmd.getPool().getType(), cmd.getPoolUuid()); - KVMPhysicalDisk primaryVol = _storagePoolMgr.copyPhysicalDisk(tmplVol, UUID.randomUUID().toString(), primaryPool, 0); + final KVMPhysicalDisk primaryVol = _storagePoolMgr.copyPhysicalDisk(tmplVol, UUID.randomUUID().toString(), primaryPool, 0); return new PrimaryStorageDownloadAnswer(primaryVol.getName(), primaryVol.getSize()); - } catch (CloudRuntimeException e) { + } catch (final CloudRuntimeException e) { return new PrimaryStorageDownloadAnswer(e.toString()); } finally { if (secondaryPool != null) { @@ -2838,37 +2843,37 @@ protected PrimaryStorageDownloadAnswer execute(final PrimaryStorageDownloadComma } } - protected Answer execute(CreateStoragePoolCommand cmd) { + protected Answer execute(final CreateStoragePoolCommand cmd) { return new Answer(cmd, true, "success"); } - protected Answer execute(ModifyStoragePoolCommand cmd) { - KVMStoragePool storagepool = + protected Answer execute(final ModifyStoragePoolCommand cmd) { + final KVMStoragePool storagepool = _storagePoolMgr.createStoragePool(cmd.getPool().getUuid(), cmd.getPool().getHost(), cmd.getPool().getPort(), cmd.getPool().getPath(), cmd.getPool() .getUserInfo(), cmd.getPool().getType()); if (storagepool == null) { return new Answer(cmd, false, " Failed to create storage pool"); } - Map tInfo = new HashMap(); - ModifyStoragePoolAnswer answer = new ModifyStoragePoolAnswer(cmd, storagepool.getCapacity(), storagepool.getAvailable(), tInfo); + final Map tInfo = new HashMap(); + final ModifyStoragePoolAnswer answer = new ModifyStoragePoolAnswer(cmd, storagepool.getCapacity(), storagepool.getAvailable(), tInfo); return answer; } - private Answer execute(SecurityGroupRulesCmd cmd) { + private Answer execute(final SecurityGroupRulesCmd cmd) { String vif = null; String brname = null; try { - Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); - List nics = getInterfaces(conn, cmd.getVmName()); + final Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); + final List nics = getInterfaces(conn, cmd.getVmName()); vif = nics.get(0).getDevName(); brname = nics.get(0).getBrName(); - } catch (LibvirtException e) { + } catch (final LibvirtException e) { return new SecurityGroupRuleAnswer(cmd, false, e.toString()); } - boolean result = + final boolean result = add_network_rules(cmd.getVmName(), Long.toString(cmd.getVmId()), cmd.getGuestIp(), cmd.getSignature(), Long.toString(cmd.getSeqNum()), cmd.getGuestMac(), cmd.stringifyRules(), vif, brname, cmd.getSecIpsString()); @@ -2882,17 +2887,17 @@ private Answer execute(SecurityGroupRulesCmd cmd) { } } - private Answer execute(CleanupNetworkRulesCmd cmd) { - boolean result = cleanup_rules(); + private Answer execute(final CleanupNetworkRulesCmd cmd) { + final boolean result = cleanup_rules(); return new Answer(cmd, result, ""); } - protected GetVncPortAnswer execute(GetVncPortCommand cmd) { + protected GetVncPortAnswer execute(final GetVncPortCommand cmd) { try { - Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getName()); - Integer vncPort = getVncPort(conn, cmd.getName()); + final Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getName()); + final Integer vncPort = getVncPort(conn, cmd.getName()); return new GetVncPortAnswer(cmd, _privateIp, 5900 + vncPort); - } catch (LibvirtException e) { + } catch (final LibvirtException e) { return new GetVncPortAnswer(cmd, e.toString()); } } @@ -2905,7 +2910,7 @@ protected Answer execute(final WatchConsoleProxyLoadCommand cmd) { return executeProxyLoadScan(cmd, cmd.getProxyVmId(), cmd.getProxyVmName(), cmd.getProxyManagementIp(), cmd.getProxyCmdPort()); } - protected MaintainAnswer execute(MaintainCommand cmd) { + protected MaintainAnswer execute(final MaintainCommand cmd) { return new MaintainAnswer(cmd); } @@ -2947,54 +2952,54 @@ private Answer executeProxyLoadScan(final Command cmd, final long proxyVmId, fin return new ConsoleProxyLoadAnswer(cmd, proxyVmId, proxyVmName, success, result); } - private Answer execute(AttachIsoCommand cmd) { + private Answer execute(final AttachIsoCommand cmd) { try { - Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); + final Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); attachOrDetachISO(conn, cmd.getVmName(), cmd.getIsoPath(), cmd.isAttach()); - } catch (LibvirtException e) { + } catch (final LibvirtException e) { return new Answer(cmd, false, e.toString()); - } catch (URISyntaxException e) { + } catch (final URISyntaxException e) { return new Answer(cmd, false, e.toString()); - } catch (InternalErrorException e) { + } catch (final InternalErrorException e) { return new Answer(cmd, false, e.toString()); } return new Answer(cmd); } - private AttachVolumeAnswer execute(AttachVolumeCommand cmd) { + private AttachVolumeAnswer execute(final AttachVolumeCommand cmd) { try { - Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); - KVMStoragePool primary = _storagePoolMgr.getStoragePool(cmd.getPooltype(), cmd.getPoolUuid()); - KVMPhysicalDisk disk = primary.getPhysicalDisk(cmd.getVolumePath()); + final Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); + final KVMStoragePool primary = _storagePoolMgr.getStoragePool(cmd.getPooltype(), cmd.getPoolUuid()); + final KVMPhysicalDisk disk = primary.getPhysicalDisk(cmd.getVolumePath()); attachOrDetachDisk(conn, cmd.getAttach(), cmd.getVmName(), disk, cmd.getDeviceId().intValue(), cmd.getBytesReadRate(), cmd.getBytesWriteRate(), cmd.getIopsReadRate(), cmd.getIopsWriteRate(), cmd.getCacheMode()); - } catch (LibvirtException e) { + } catch (final LibvirtException e) { return new AttachVolumeAnswer(cmd, e.toString()); - } catch (InternalErrorException e) { + } catch (final InternalErrorException e) { return new AttachVolumeAnswer(cmd, e.toString()); } return new AttachVolumeAnswer(cmd, cmd.getDeviceId(), cmd.getVolumePath()); } - private Answer execute(ReadyCommand cmd) { + private Answer execute(final ReadyCommand cmd) { return new ReadyAnswer(cmd); } - protected PowerState convertToPowerState(DomainState ps) { + protected PowerState convertToPowerState(final DomainState ps) { final PowerState state = s_powerStatesTable.get(ps); return state == null ? PowerState.PowerUnknown : state; } - protected PowerState getVmState(Connect conn, final String vmName) { + protected PowerState getVmState(final Connect conn, final String vmName) { int retry = 3; Domain vms = null; while (retry-- > 0) { try { vms = conn.domainLookupByName(vmName); - PowerState s = convertToPowerState(vms.getInfo().state); + final PowerState s = convertToPowerState(vms.getInfo().state); return s; } catch (final LibvirtException e) { s_logger.warn("Can't get vm state " + vmName + e.getMessage() + "retry:" + retry); @@ -3011,9 +3016,9 @@ protected PowerState getVmState(Connect conn, final String vmName) { return PowerState.PowerOff; } - private Answer execute(CheckVirtualMachineCommand cmd) { + private Answer execute(final CheckVirtualMachineCommand cmd) { try { - Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); + final Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); final PowerState state = getVmState(conn, cmd.getVmName()); Integer vncPort = null; if (state == PowerState.PowerOn) { @@ -3021,12 +3026,12 @@ private Answer execute(CheckVirtualMachineCommand cmd) { } return new CheckVirtualMachineAnswer(cmd, state, vncPort); - } catch (LibvirtException e) { + } catch (final LibvirtException e) { return new CheckVirtualMachineAnswer(cmd, e.getMessage()); } } - private Answer execute(PingTestCommand cmd) { + private Answer execute(final PingTestCommand cmd) { String result = null; final String computingHostIp = cmd.getComputingHostIp(); // TODO, split // the @@ -3061,8 +3066,8 @@ private String doPingTest(final String domRIp, final String vmIp) { return command.execute(); } - private Answer execute(MigrateCommand cmd) { - String vmName = cmd.getVmName(); + private Answer execute(final MigrateCommand cmd) { + final String vmName = cmd.getVmName(); String result = null; @@ -3098,9 +3103,9 @@ private Answer execute(MigrateCommand cmd) { //run migration in thread so we can monitor it s_logger.info("Live migration of instance " + vmName + " initiated"); - ExecutorService executor = Executors.newFixedThreadPool(1); - Callable worker = new MigrateKVMAsync(dm, dconn, xmlDesc, vmName, cmd.getDestinationIp()); - Future migrateThread = executor.submit(worker); + final ExecutorService executor = Executors.newFixedThreadPool(1); + final Callable worker = new MigrateKVMAsync(dm, dconn, xmlDesc, vmName, cmd.getDestinationIp()); + final Future migrateThread = executor.submit(worker); executor.shutdown(); long sleeptime = 0; while (!executor.isTerminated()) { @@ -3109,16 +3114,16 @@ private Answer execute(MigrateCommand cmd) { if (sleeptime == 1000) { // wait 1s before attempting to set downtime on migration, since I don't know of a VIR_DOMAIN_MIGRATING state if (_migrateDowntime > 0 ) { try { - int setDowntime = dm.migrateSetMaxDowntime(_migrateDowntime); + final int setDowntime = dm.migrateSetMaxDowntime(_migrateDowntime); if (setDowntime == 0 ) { s_logger.debug("Set max downtime for migration of " + vmName + " to " + String.valueOf(_migrateDowntime) + "ms"); } - } catch (LibvirtException e) { + } catch (final LibvirtException e) { s_logger.debug("Failed to set max downtime for migration, perhaps migration completed? Error: " + e.getMessage()); } } } - if ((sleeptime % 1000) == 0) { + if (sleeptime % 1000 == 0) { s_logger.info("Waiting for migration of " + vmName + " to complete, waited " + sleeptime + "ms"); } @@ -3127,7 +3132,7 @@ private Answer execute(MigrateCommand cmd) { s_logger.info("Pausing VM " + vmName + " due to property vm.migrate.pauseafter setting to " + _migratePauseAfter+ "ms to complete migration"); try { dm.suspend(); - } catch (LibvirtException e) { + } catch (final LibvirtException e) { // pause could be racy if it attempts to pause right when vm is finished, simply warn s_logger.info("Failed to pause vm " + vmName + " : " + e.getMessage()); } @@ -3138,20 +3143,20 @@ private Answer execute(MigrateCommand cmd) { destDomain = migrateThread.get(10, TimeUnit.SECONDS); if (destDomain != null) { - for (DiskDef disk : disks) { + for (final DiskDef disk : disks) { cleanupDisk(disk); } } - } catch (LibvirtException e) { + } catch (final LibvirtException e) { s_logger.debug("Can't migrate domain: " + e.getMessage()); result = e.getMessage(); - } catch (InterruptedException e) { + } catch (final InterruptedException e) { s_logger.debug("Interrupted while migrating domain: " + e.getMessage()); result = e.getMessage(); - } catch (ExecutionException e) { + } catch (final ExecutionException e) { s_logger.debug("Failed to execute while migrating domain: " + e.getMessage()); result = e.getMessage(); - } catch (TimeoutException e) { + } catch (final TimeoutException e) { s_logger.debug("Timed out while migrating domain: " + e.getMessage()); result = e.getMessage(); } finally { @@ -3175,11 +3180,11 @@ private Answer execute(MigrateCommand cmd) { if (result != null) { } else { - destroy_network_rules_for_vm(conn, vmName); - for (InterfaceDef iface : ifaces) { + destroyNetworkRulesForVM(conn, vmName); + for (final InterfaceDef iface : ifaces) { // We don't know which "traffic type" is associated with // each interface at this point, so inform all vif drivers - for (VifDriver vifDriver : getAllVifDrivers()) { + for (final VifDriver vifDriver : getAllVifDrivers()) { vifDriver.unplug(iface); } } @@ -3195,7 +3200,7 @@ private class MigrateKVMAsync implements Callable { String vmName = ""; String destIp = ""; - MigrateKVMAsync(Domain dm, Connect dconn, String dxml, String vmName, String destIp) { + MigrateKVMAsync(final Domain dm, final Connect dconn, final String dxml, final String vmName, final String destIp) { this.dm = dm; this.dconn = dconn; this.dxml = dxml; @@ -3207,33 +3212,33 @@ private class MigrateKVMAsync implements Callable { public Domain call() throws LibvirtException { // set compression flag for migration if libvirt version supports it if (dconn.getLibVirVersion() < 1003000) { - return dm.migrate(dconn, (1 << 0), dxml, vmName, "tcp:" + destIp, _migrateSpeed); + return dm.migrate(dconn, 1 << 0, dxml, vmName, "tcp:" + destIp, _migrateSpeed); } else { - return dm.migrate(dconn, (1 << 0)|(1 << 11), dxml, vmName, "tcp:" + destIp, _migrateSpeed); + return dm.migrate(dconn, 1 << 0|1 << 11, dxml, vmName, "tcp:" + destIp, _migrateSpeed); } } } - private synchronized Answer execute(PrepareForMigrationCommand cmd) { + private synchronized Answer execute(final PrepareForMigrationCommand cmd) { - VirtualMachineTO vm = cmd.getVirtualMachine(); + final VirtualMachineTO vm = cmd.getVirtualMachine(); if (s_logger.isDebugEnabled()) { s_logger.debug("Preparing host for migrating " + vm); } - NicTO[] nics = vm.getNics(); + final NicTO[] nics = vm.getNics(); boolean skipDisconnect = false; try { - Connect conn = LibvirtConnection.getConnectionByVmName(vm.getName()); - for (NicTO nic : nics) { + final Connect conn = LibvirtConnection.getConnectionByVmName(vm.getName()); + for (final NicTO nic : nics) { getVifDriver(nic.getType()).plug(nic, null, ""); } /* setup disks, e.g for iso */ - DiskTO[] volumes = vm.getDisks(); - for (DiskTO volume : volumes) { + final DiskTO[] volumes = vm.getDisks(); + for (final DiskTO volume : volumes) { if (volume.getType() == Volume.Type.ISO) { getVolumePath(conn, volume); } @@ -3247,11 +3252,11 @@ private synchronized Answer execute(PrepareForMigrationCommand cmd) { skipDisconnect = true; return new PrepareForMigrationAnswer(cmd); - } catch (LibvirtException e) { + } catch (final LibvirtException e) { return new PrepareForMigrationAnswer(cmd, e.toString()); - } catch (InternalErrorException e) { + } catch (final InternalErrorException e) { return new PrepareForMigrationAnswer(cmd, e.toString()); - } catch (URISyntaxException e) { + } catch (final URISyntaxException e) { return new PrepareForMigrationAnswer(cmd, e.toString()); } finally { if (!skipDisconnect) { @@ -3260,11 +3265,11 @@ private synchronized Answer execute(PrepareForMigrationCommand cmd) { } } - private Answer execute(CheckHealthCommand cmd) { + private Answer execute(final CheckHealthCommand cmd) { return new CheckHealthAnswer(cmd, true); } - private Answer execute(GetHostStatsCommand cmd) { + private Answer execute(final GetHostStatsCommand cmd) { final Script cpuScript = new Script("/bin/bash", s_logger); cpuScript.add("-c"); cpuScript.add("idle=$(top -b -n 1| awk -F, '/^[%]*[Cc]pu/{$0=$4; gsub(/[^0-9.,]+/,\"\"); print }'); echo $idle"); @@ -3275,7 +3280,7 @@ private Answer execute(GetHostStatsCommand cmd) { s_logger.debug("Unable to get the host CPU state: " + result); return new Answer(cmd, false, result); } - double cpuUtil = (100.0D - Double.parseDouble(parser.getLine())); + final double cpuUtil = 100.0D - Double.parseDouble(parser.getLine()); long freeMem = 0; final Script memScript = new Script("/bin/bash", s_logger); @@ -3289,7 +3294,7 @@ private Answer execute(GetHostStatsCommand cmd) { } freeMem = Long.parseLong(Memparser.getLine()); - Script totalMem = new Script("/bin/bash", s_logger); + final Script totalMem = new Script("/bin/bash", s_logger); totalMem.add("-c"); totalMem.add("free|grep Mem:|awk '{print $2}'"); final OutputInterpreter.OneLineParser totMemparser = new OutputInterpreter.OneLineParser(); @@ -3298,16 +3303,16 @@ private Answer execute(GetHostStatsCommand cmd) { s_logger.debug("Unable to get the host Mem state: " + result); return new Answer(cmd, false, result); } - long totMem = Long.parseLong(totMemparser.getLine()); + final long totMem = Long.parseLong(totMemparser.getLine()); - Pair nicStats = getNicStats(_publicBridgeName); + final Pair nicStats = getNicStats(_publicBridgeName); - HostStatsEntry hostStats = new HostStatsEntry(cmd.getHostId(), cpuUtil, nicStats.first() / 1024, nicStats.second() / 1024, "host", totMem, freeMem, 0, 0); + final HostStatsEntry hostStats = new HostStatsEntry(cmd.getHostId(), cpuUtil, nicStats.first() / 1024, nicStats.second() / 1024, "host", totMem, freeMem, 0, 0); return new GetHostStatsAnswer(cmd, hostStats); } protected String networkUsage(final String privateIpAddress, final String option, final String vif) { - Script getUsage = new Script(_routerProxyPath, s_logger); + final Script getUsage = new Script(_routerProxyPath, s_logger); getUsage.add("netusage.sh"); getUsage.add(privateIpAddress); if (option.equals("get")) { @@ -3323,7 +3328,7 @@ protected String networkUsage(final String privateIpAddress, final String option } final OutputInterpreter.OneLineParser usageParser = new OutputInterpreter.OneLineParser(); - String result = getUsage.execute(usageParser); + final String result = getUsage.execute(usageParser); if (result != null) { s_logger.debug("Failed to execute networkUsage:" + result); return null; @@ -3331,11 +3336,11 @@ protected String networkUsage(final String privateIpAddress, final String option return usageParser.getLine(); } - protected long[] getNetworkStats(String privateIP) { - String result = networkUsage(privateIP, "get", null); - long[] stats = new long[2]; + protected long[] getNetworkStats(final String privateIP) { + final String result = networkUsage(privateIP, "get", null); + final long[] stats = new long[2]; if (result != null) { - String[] splitResult = result.split(":"); + final String[] splitResult = result.split(":"); int i = 0; while (i < splitResult.length - 1) { stats[0] += Long.parseLong(splitResult[i++]); @@ -3346,7 +3351,7 @@ protected long[] getNetworkStats(String privateIP) { } protected String VPCNetworkUsage(final String privateIpAddress, final String publicIp, final String option, final String vpcCIDR) { - Script getUsage = new Script(_routerProxyPath, s_logger); + final Script getUsage = new Script(_routerProxyPath, s_logger); getUsage.add("vpc_netusage.sh"); getUsage.add(privateIpAddress); getUsage.add("-l", publicIp); @@ -3365,7 +3370,7 @@ protected String VPCNetworkUsage(final String privateIpAddress, final String pub } final OutputInterpreter.OneLineParser usageParser = new OutputInterpreter.OneLineParser(); - String result = getUsage.execute(usageParser); + final String result = getUsage.execute(usageParser); if (result != null) { s_logger.debug("Failed to execute VPCNetworkUsage:" + result); return null; @@ -3373,11 +3378,11 @@ protected String VPCNetworkUsage(final String privateIpAddress, final String pub return usageParser.getLine(); } - protected long[] getVPCNetworkStats(String privateIP, String publicIp, String option) { - String result = VPCNetworkUsage(privateIP, publicIp, option, null); - long[] stats = new long[2]; + protected long[] getVPCNetworkStats(final String privateIP, final String publicIp, final String option) { + final String result = VPCNetworkUsage(privateIP, publicIp, option, null); + final long[] stats = new long[2]; if (result != null) { - String[] splitResult = result.split(":"); + final String[] splitResult = result.split(":"); int i = 0; while (i < splitResult.length - 1) { stats[0] += Long.parseLong(splitResult[i++]); @@ -3387,43 +3392,43 @@ protected long[] getVPCNetworkStats(String privateIP, String publicIp, String op return stats; } - private Answer execute(NetworkUsageCommand cmd) { + private Answer execute(final NetworkUsageCommand cmd) { if (cmd.isForVpc()) { if (cmd.getOption() != null && cmd.getOption().equals("create")) { - String result = VPCNetworkUsage(cmd.getPrivateIP(), cmd.getGatewayIP(), "create", cmd.getVpcCIDR()); - NetworkUsageAnswer answer = new NetworkUsageAnswer(cmd, result, 0L, 0L); + final String result = VPCNetworkUsage(cmd.getPrivateIP(), cmd.getGatewayIP(), "create", cmd.getVpcCIDR()); + final NetworkUsageAnswer answer = new NetworkUsageAnswer(cmd, result, 0L, 0L); return answer; } else if (cmd.getOption() != null && (cmd.getOption().equals("get") || cmd.getOption().equals("vpn"))) { - long[] stats = getVPCNetworkStats(cmd.getPrivateIP(), cmd.getGatewayIP(), cmd.getOption()); - NetworkUsageAnswer answer = new NetworkUsageAnswer(cmd, "", stats[0], stats[1]); + final long[] stats = getVPCNetworkStats(cmd.getPrivateIP(), cmd.getGatewayIP(), cmd.getOption()); + final NetworkUsageAnswer answer = new NetworkUsageAnswer(cmd, "", stats[0], stats[1]); return answer; } else { - String result = VPCNetworkUsage(cmd.getPrivateIP(), cmd.getGatewayIP(), cmd.getOption(), cmd.getVpcCIDR()); - NetworkUsageAnswer answer = new NetworkUsageAnswer(cmd, result, 0L, 0L); + final String result = VPCNetworkUsage(cmd.getPrivateIP(), cmd.getGatewayIP(), cmd.getOption(), cmd.getVpcCIDR()); + final NetworkUsageAnswer answer = new NetworkUsageAnswer(cmd, result, 0L, 0L); return answer; } } else { if (cmd.getOption() != null && cmd.getOption().equals("create")) { - String result = networkUsage(cmd.getPrivateIP(), "create", null); - NetworkUsageAnswer answer = new NetworkUsageAnswer(cmd, result, 0L, 0L); + final String result = networkUsage(cmd.getPrivateIP(), "create", null); + final NetworkUsageAnswer answer = new NetworkUsageAnswer(cmd, result, 0L, 0L); return answer; } - long[] stats = getNetworkStats(cmd.getPrivateIP()); - NetworkUsageAnswer answer = new NetworkUsageAnswer(cmd, "", stats[0], stats[1]); + final long[] stats = getNetworkStats(cmd.getPrivateIP()); + final NetworkUsageAnswer answer = new NetworkUsageAnswer(cmd, "", stats[0], stats[1]); return answer; } } - private Answer execute(RebootCommand cmd) { + private Answer execute(final RebootCommand cmd) { try { - Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); + final Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); final String result = rebootVM(conn, cmd.getVmName()); if (result == null) { Integer vncPort = null; try { vncPort = getVncPort(conn, cmd.getVmName()); - } catch (LibvirtException e) { + } catch (final LibvirtException e) { s_logger.trace("Ignoring libvirt error.", e); } get_rule_logs_for_vms(); @@ -3431,13 +3436,13 @@ private Answer execute(RebootCommand cmd) { } else { return new RebootAnswer(cmd, result, false); } - } catch (LibvirtException e) { + } catch (final LibvirtException e) { return new RebootAnswer(cmd, e.getMessage(), false); } } - protected Answer execute(RebootRouterCommand cmd) { - RebootAnswer answer = (RebootAnswer)execute((RebootCommand)cmd); + protected Answer execute(final RebootRouterCommand cmd) { + final RebootAnswer answer = (RebootAnswer)execute((RebootCommand)cmd); if (_virtRouterResource.connect(cmd.getPrivateIpAddress())) { networkUsage(cmd.getPrivateIpAddress(), "create", null); return answer; @@ -3446,13 +3451,13 @@ protected Answer execute(RebootRouterCommand cmd) { } } - protected GetVmDiskStatsAnswer execute(GetVmDiskStatsCommand cmd) { - List vmNames = cmd.getVmNames(); + protected GetVmDiskStatsAnswer execute(final GetVmDiskStatsCommand cmd) { + final List vmNames = cmd.getVmNames(); try { - HashMap> vmDiskStatsNameMap = new HashMap>(); - Connect conn = LibvirtConnection.getConnection(); - for (String vmName : vmNames) { - List statEntry = getVmDiskStat(conn, vmName); + final HashMap> vmDiskStatsNameMap = new HashMap>(); + final Connect conn = LibvirtConnection.getConnection(); + for (final String vmName : vmNames) { + final List statEntry = getVmDiskStat(conn, vmName); if (statEntry == null) { continue; } @@ -3460,19 +3465,19 @@ protected GetVmDiskStatsAnswer execute(GetVmDiskStatsCommand cmd) { vmDiskStatsNameMap.put(vmName, statEntry); } return new GetVmDiskStatsAnswer(cmd, "", cmd.getHostName(), vmDiskStatsNameMap); - } catch (LibvirtException e) { + } catch (final LibvirtException e) { s_logger.debug("Can't get vm disk stats: " + e.toString()); return new GetVmDiskStatsAnswer(cmd, null, null, null); } } - protected GetVmStatsAnswer execute(GetVmStatsCommand cmd) { - List vmNames = cmd.getVmNames(); + protected GetVmStatsAnswer execute(final GetVmStatsCommand cmd) { + final List vmNames = cmd.getVmNames(); try { - HashMap vmStatsNameMap = new HashMap(); - for (String vmName : vmNames) { - Connect conn = LibvirtConnection.getConnectionByVmName(vmName); - VmStatsEntry statEntry = getVmStat(conn, vmName); + final HashMap vmStatsNameMap = new HashMap(); + for (final String vmName : vmNames) { + final Connect conn = LibvirtConnection.getConnectionByVmName(vmName); + final VmStatsEntry statEntry = getVmStat(conn, vmName); if (statEntry == null) { continue; } @@ -3480,60 +3485,60 @@ protected GetVmStatsAnswer execute(GetVmStatsCommand cmd) { vmStatsNameMap.put(vmName, statEntry); } return new GetVmStatsAnswer(cmd, vmStatsNameMap); - } catch (LibvirtException e) { + } catch (final LibvirtException e) { s_logger.debug("Can't get vm stats: " + e.toString()); return new GetVmStatsAnswer(cmd, null); } } - protected Answer execute(StopCommand cmd) { + protected Answer execute(final StopCommand cmd) { final String vmName = cmd.getVmName(); if (cmd.checkBeforeCleanup()) { try { - Connect conn = LibvirtConnection.getConnectionByVmName(vmName); - Domain vm = conn.domainLookupByName(cmd.getVmName()); + final Connect conn = LibvirtConnection.getConnectionByVmName(vmName); + final Domain vm = conn.domainLookupByName(cmd.getVmName()); if (vm != null && vm.getInfo().state == DomainState.VIR_DOMAIN_RUNNING) { return new StopAnswer(cmd, "vm is still running on host", false); } - } catch (Exception e) { + } catch (final Exception e) { s_logger.debug("Failed to get vm status in case of checkboforecleanup is true", e); } } try { - Connect conn = LibvirtConnection.getConnectionByVmName(vmName); + final Connect conn = LibvirtConnection.getConnectionByVmName(vmName); - List disks = getDisks(conn, vmName); - List ifaces = getInterfaces(conn, vmName); + final List disks = getDisks(conn, vmName); + final List ifaces = getInterfaces(conn, vmName); - destroy_network_rules_for_vm(conn, vmName); - String result = stopVM(conn, vmName); + destroyNetworkRulesForVM(conn, vmName); + final String result = stopVM(conn, vmName); if (result == null) { - for (DiskDef disk : disks) { + for (final DiskDef disk : disks) { cleanupDisk(disk); } - for (InterfaceDef iface : ifaces) { + for (final InterfaceDef iface : ifaces) { // We don't know which "traffic type" is associated with // each interface at this point, so inform all vif drivers - for (VifDriver vifDriver : getAllVifDrivers()) { + for (final VifDriver vifDriver : getAllVifDrivers()) { vifDriver.unplug(iface); } } } return new StopAnswer(cmd, result, true); - } catch (LibvirtException e) { + } catch (final LibvirtException e) { return new StopAnswer(cmd, e.getMessage(), false); } } - protected Answer execute(ModifySshKeysCommand cmd) { - File sshKeysDir = new File(SSHKEYSPATH); + protected Answer execute(final ModifySshKeysCommand cmd) { + final File sshKeysDir = new File(SSHKEYSPATH); String result = null; if (!sshKeysDir.exists()) { // Change permissions for the 700 - Script script = new Script("mkdir", _timeout, s_logger); + final Script script = new Script("mkdir", _timeout, s_logger); script.add("-m", "700"); script.add(SSHKEYSPATH); script.execute(); @@ -3543,11 +3548,11 @@ protected Answer execute(ModifySshKeysCommand cmd) { } } - File pubKeyFile = new File(SSHPUBKEYPATH); + final File pubKeyFile = new File(SSHPUBKEYPATH); if (!pubKeyFile.exists()) { try { pubKeyFile.createNewFile(); - } catch (IOException e) { + } catch (final IOException e) { result = "Failed to create file: " + e.toString(); s_logger.debug(result); } @@ -3556,40 +3561,40 @@ protected Answer execute(ModifySshKeysCommand cmd) { if (pubKeyFile.exists()) { try (FileOutputStream pubkStream = new FileOutputStream(pubKeyFile)) { pubkStream.write(cmd.getPubKey().getBytes()); - } catch (FileNotFoundException e) { + } catch (final FileNotFoundException e) { result = "File" + SSHPUBKEYPATH + "is not found:" + e.toString(); s_logger.debug(result); - } catch (IOException e) { + } catch (final IOException e) { result = "Write file " + SSHPUBKEYPATH + ":" + e.toString(); s_logger.debug(result); } } - File prvKeyFile = new File(SSHPRVKEYPATH); + final File prvKeyFile = new File(SSHPRVKEYPATH); if (!prvKeyFile.exists()) { try { prvKeyFile.createNewFile(); - } catch (IOException e) { + } catch (final IOException e) { result = "Failed to create file: " + e.toString(); s_logger.debug(result); } } if (prvKeyFile.exists()) { - String prvKey = cmd.getPrvKey(); + final String prvKey = cmd.getPrvKey(); try (FileOutputStream prvKStream = new FileOutputStream(prvKeyFile);){ if ( prvKStream != null) { prvKStream.write(prvKey.getBytes()); } - } catch (FileNotFoundException e) { + } catch (final FileNotFoundException e) { result = "File" + SSHPRVKEYPATH + "is not found:" + e.toString(); s_logger.debug(result); - } catch (IOException e) { + } catch (final IOException e) { result = "Write file " + SSHPRVKEYPATH + ":" + e.toString(); s_logger.debug(result); } - Script script = new Script("chmod", _timeout, s_logger); + final Script script = new Script("chmod", _timeout, s_logger); script.add("600", SSHPRVKEYPATH); script.execute(); } @@ -3601,7 +3606,7 @@ protected Answer execute(ModifySshKeysCommand cmd) { } } - protected void handleVmStartFailure(Connect conn, String vmName, LibvirtVMDef vm) { + protected void handleVmStartFailure(final Connect conn, final String vmName, final LibvirtVMDef vm) { if (vm != null && vm.getDevices() != null) { cleanupVMNetworks(conn, vm.getDevices().getInterfaces()); } @@ -3612,12 +3617,12 @@ protected String getUuid(String uuid) { uuid = UUID.randomUUID().toString(); } else { try { - UUID uuid2 = UUID.fromString(uuid); - String uuid3 = uuid2.toString(); + final UUID uuid2 = UUID.fromString(uuid); + final String uuid3 = uuid2.toString(); if (!uuid3.equals(uuid)) { uuid = UUID.randomUUID().toString(); } - } catch (IllegalArgumentException e) { + } catch (final IllegalArgumentException e) { uuid = UUID.randomUUID().toString(); } } @@ -3625,25 +3630,25 @@ protected String getUuid(String uuid) { } private void getOsVersion() { - String version = Script.runSimpleBashScript("cat /etc/redhat-release | awk '{print $7}'"); + final String version = Script.runSimpleBashScript("cat /etc/redhat-release | awk '{print $7}'"); if (version != null) { - String[] versions = version.split("\\."); + final String[] versions = version.split("\\."); if (versions.length == 2) { - String major = versions[0]; - String minor = versions[1]; + final String major = versions[0]; + final String minor = versions[1]; try { - Integer m = Integer.parseInt(major); - Integer min = Integer.parseInt(minor); + final Integer m = Integer.parseInt(major); + final Integer min = Integer.parseInt(minor); hostOsVersion = new Pair<>(m, min); - } catch(NumberFormatException e) { + } catch(final NumberFormatException e) { } } } } - protected LibvirtVMDef createVMFromSpec(VirtualMachineTO vmTO) { - LibvirtVMDef vm = new LibvirtVMDef(); + protected LibvirtVMDef createVMFromSpec(final VirtualMachineTO vmTO) { + final LibvirtVMDef vm = new LibvirtVMDef(); vm.setDomainName(vmTO.getName()); String uuid = vmTO.getUuid(); uuid = getUuid(uuid); @@ -3651,7 +3656,7 @@ protected LibvirtVMDef createVMFromSpec(VirtualMachineTO vmTO) { vm.setDomDescription(vmTO.getOs()); vm.setPlatformEmulator(vmTO.getPlatformEmulator()); - GuestDef guest = new GuestDef(); + final GuestDef guest = new GuestDef(); if (HypervisorType.LXC == _hypervisorType && VirtualMachine.Type.User == vmTO.getType()) { // LXC domain is only valid for user VMs. Use KVM for system VMs. @@ -3670,7 +3675,7 @@ protected LibvirtVMDef createVMFromSpec(VirtualMachineTO vmTO) { vm.addComp(guest); - GuestResourceDef grd = new GuestResourceDef(); + final GuestResourceDef grd = new GuestResourceDef(); if (vmTO.getMinRam() != vmTO.getMaxRam() && !_noMemBalloon) { grd.setMemBalloning(true); @@ -3679,11 +3684,11 @@ protected LibvirtVMDef createVMFromSpec(VirtualMachineTO vmTO) { } else { grd.setMemorySize(vmTO.getMaxRam() / 1024); } - int vcpus = vmTO.getCpus(); + final int vcpus = vmTO.getCpus(); grd.setVcpuNum(vcpus); vm.addComp(grd); - CpuModeDef cmd = new CpuModeDef(); + final CpuModeDef cmd = new CpuModeDef(); cmd.setMode(_guestCpuMode); cmd.setModel(_guestCpuModel); if (vmTO.getType() == VirtualMachine.Type.User) { @@ -3691,16 +3696,16 @@ protected LibvirtVMDef createVMFromSpec(VirtualMachineTO vmTO) { } // multi cores per socket, for larger core configs if (vcpus % 6 == 0) { - int sockets = vcpus / 6; + final int sockets = vcpus / 6; cmd.setTopology(6, sockets); } else if (vcpus % 4 == 0) { - int sockets = vcpus / 4; + final int sockets = vcpus / 4; cmd.setTopology(4, sockets); } vm.addComp(cmd); if (_hypervisorLibvirtVersion >= 9000) { - CpuTuneDef ctd = new CpuTuneDef(); + final CpuTuneDef ctd = new CpuTuneDef(); /** A 4.0.X/4.1.X management server doesn't send the correct JSON command for getMinSpeed, it only sends a 'speed' field. @@ -3719,7 +3724,7 @@ So if getMinSpeed() returns null we fall back to getSpeed(). vm.addComp(ctd); } - FeaturesDef features = new FeaturesDef(); + final FeaturesDef features = new FeaturesDef(); features.addFeatures("pae"); features.addFeatures("apic"); features.addFeatures("acpi"); @@ -3733,48 +3738,48 @@ So if getMinSpeed() returns null we fall back to getSpeed(). */ vm.addComp(features); - TermPolicy term = new TermPolicy(); + final TermPolicy term = new TermPolicy(); term.setCrashPolicy("destroy"); term.setPowerOffPolicy("destroy"); term.setRebootPolicy("restart"); vm.addComp(term); - ClockDef clock = new ClockDef(); + final ClockDef clock = new ClockDef(); if (vmTO.getOs().startsWith("Windows")) { clock.setClockOffset(ClockDef.ClockOffset.LOCALTIME); clock.setTimer("rtc", "catchup", null); } else if (vmTO.getType() != VirtualMachine.Type.User || isGuestPVEnabled(vmTO.getOs())) { - if (_hypervisorLibvirtVersion >= (9 * 1000 + 10)) { + if (_hypervisorLibvirtVersion >= 9 * 1000 + 10) { clock.setTimer("kvmclock", null, null, _noKvmClock); } } vm.addComp(clock); - DevicesDef devices = new DevicesDef(); + final DevicesDef devices = new DevicesDef(); devices.setEmulatorPath(_hypervisorPath); devices.setGuestType(guest.getGuestType()); - SerialDef serial = new SerialDef("pty", null, (short)0); + final SerialDef serial = new SerialDef("pty", null, (short)0); devices.addDevice(serial); if (vmTO.getType() != VirtualMachine.Type.User) { - VirtioSerialDef vserial = new VirtioSerialDef(vmTO.getName(), null); + final VirtioSerialDef vserial = new VirtioSerialDef(vmTO.getName(), null); devices.addDevice(vserial); } - VideoDef videoCard = new VideoDef(_videoHw, _videoRam); + final VideoDef videoCard = new VideoDef(_videoHw, _videoRam); devices.addDevice(videoCard); - ConsoleDef console = new ConsoleDef("pty", null, null, (short)0); + final ConsoleDef console = new ConsoleDef("pty", null, null, (short)0); devices.addDevice(console); //add the VNC port passwd here, get the passwd from the vmInstance. - String passwd = vmTO.getVncPassword(); - GraphicDef grap = new GraphicDef("vnc", (short)0, true, vmTO.getVncAddr(), passwd, null); + final String passwd = vmTO.getVncPassword(); + final GraphicDef grap = new GraphicDef("vnc", (short)0, true, vmTO.getVncAddr(), passwd, null); devices.addDevice(grap); - InputDef input = new InputDef("tablet", "usb"); + final InputDef input = new InputDef("tablet", "usb"); devices.addDevice(input); vm.addComp(devices); @@ -3782,15 +3787,15 @@ So if getMinSpeed() returns null we fall back to getSpeed(). return vm; } - protected void createVifs(VirtualMachineTO vmSpec, LibvirtVMDef vm) throws InternalErrorException, LibvirtException { - NicTO[] nics = vmSpec.getNics(); - Map params = vmSpec.getDetails(); + protected void createVifs(final VirtualMachineTO vmSpec, final LibvirtVMDef vm) throws InternalErrorException, LibvirtException { + final NicTO[] nics = vmSpec.getNics(); + final Map params = vmSpec.getDetails(); String nicAdapter = ""; if (params != null && params.get("nicAdapter") != null && !params.get("nicAdapter").isEmpty()) { nicAdapter = params.get("nicAdapter"); } for (int i = 0; i < nics.length; i++) { - for (NicTO nic : vmSpec.getNics()) { + for (final NicTO nic : vmSpec.getNics()) { if (nic.getDeviceId() == i) { createVif(vm, nic, nicAdapter); } @@ -3798,18 +3803,18 @@ protected void createVifs(VirtualMachineTO vmSpec, LibvirtVMDef vm) throws Inter } } - protected StartAnswer execute(StartCommand cmd) { - VirtualMachineTO vmSpec = cmd.getVirtualMachine(); + protected StartAnswer execute(final StartCommand cmd) { + final VirtualMachineTO vmSpec = cmd.getVirtualMachine(); vmSpec.setVncAddr(cmd.getHostIp()); - String vmName = vmSpec.getName(); + final String vmName = vmSpec.getName(); LibvirtVMDef vm = null; DomainState state = DomainState.VIR_DOMAIN_SHUTOFF; Connect conn = null; try { - NicTO[] nics = vmSpec.getNics(); + final NicTO[] nics = vmSpec.getNics(); - for (NicTO nic : nics) { + for (final NicTO nic : nics) { if (vmSpec.getType() != VirtualMachine.Type.User) { nic.setPxeDisable(true); } @@ -3830,17 +3835,17 @@ protected StartAnswer execute(StartCommand cmd) { s_logger.debug("starting " + vmName + ": " + vm.toString()); startVM(conn, vmName, vm.toString()); - for (NicTO nic : nics) { - if (nic.isSecurityGroupEnabled() || (nic.getIsolationUri() != null && nic.getIsolationUri().getScheme().equalsIgnoreCase(IsolationType.Ec2.toString()))) { + for (final NicTO nic : nics) { + if (nic.isSecurityGroupEnabled() || nic.getIsolationUri() != null && nic.getIsolationUri().getScheme().equalsIgnoreCase(IsolationType.Ec2.toString())) { if (vmSpec.getType() != VirtualMachine.Type.User) { default_network_rules_for_systemvm(conn, vmName); break; } else { - List nicSecIps = nic.getNicSecIps(); + final List nicSecIps = nic.getNicSecIps(); String secIpsStr; - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); if (nicSecIps != null) { - for (String ip : nicSecIps) { + for (final String ip : nicSecIps) { sb.append(ip).append(":"); } secIpsStr = sb.toString(); @@ -3856,7 +3861,7 @@ protected StartAnswer execute(StartCommand cmd) { if (vmSpec.getType() != VirtualMachine.Type.User) { //wait and try passCmdLine for 5 minutes at most for CLOUDSTACK-2823 String controlIp = null; - for (NicTO nic : nics) { + for (final NicTO nic : nics) { if (nic.getType() == TrafficType.Control) { controlIp = nic.getIp(); break; @@ -3865,7 +3870,7 @@ protected StartAnswer execute(StartCommand cmd) { for (int count = 0; count < 30; count++) { passCmdLine(vmName, vmSpec.getBootArgs()); //check router is up? - boolean result = _virtRouterResource.connect(controlIp, 1, 5000); + final boolean result = _virtRouterResource.connect(controlIp, 1, 5000); if (result) { break; } @@ -3874,19 +3879,19 @@ protected StartAnswer execute(StartCommand cmd) { state = DomainState.VIR_DOMAIN_RUNNING; return new StartAnswer(cmd); - } catch (LibvirtException e) { + } catch (final LibvirtException e) { s_logger.warn("LibvirtException ", e); if (conn != null) { handleVmStartFailure(conn, vmName, vm); } return new StartAnswer(cmd, e.getMessage()); - } catch (InternalErrorException e) { + } catch (final InternalErrorException e) { s_logger.warn("InternalErrorException ", e); if (conn != null) { handleVmStartFailure(conn, vmName, vm); } return new StartAnswer(cmd, e.getMessage()); - } catch (URISyntaxException e) { + } catch (final URISyntaxException e) { s_logger.warn("URISyntaxException ", e); if (conn != null) { handleVmStartFailure(conn, vmName, vm); @@ -3899,47 +3904,47 @@ protected StartAnswer execute(StartCommand cmd) { } } - private String getVolumePath(Connect conn, DiskTO volume) throws LibvirtException, URISyntaxException { - DataTO data = volume.getData(); - DataStoreTO store = data.getDataStore(); + private String getVolumePath(final Connect conn, final DiskTO volume) throws LibvirtException, URISyntaxException { + final DataTO data = volume.getData(); + final DataStoreTO store = data.getDataStore(); if (volume.getType() == Volume.Type.ISO && data.getPath() != null) { - NfsTO nfsStore = (NfsTO)store; - String isoPath = nfsStore.getUrl() + File.separator + data.getPath(); - int index = isoPath.lastIndexOf("/"); - String path = isoPath.substring(0, index); - String name = isoPath.substring(index + 1); - KVMStoragePool secondaryPool = _storagePoolMgr.getStoragePoolByURI(path); - KVMPhysicalDisk isoVol = secondaryPool.getPhysicalDisk(name); + final NfsTO nfsStore = (NfsTO)store; + final String isoPath = nfsStore.getUrl() + File.separator + data.getPath(); + final int index = isoPath.lastIndexOf("/"); + final String path = isoPath.substring(0, index); + final String name = isoPath.substring(index + 1); + final KVMStoragePool secondaryPool = _storagePoolMgr.getStoragePoolByURI(path); + final KVMPhysicalDisk isoVol = secondaryPool.getPhysicalDisk(name); return isoVol.getPath(); } else { return data.getPath(); } } - protected void createVbd(Connect conn, VirtualMachineTO vmSpec, String vmName, LibvirtVMDef vm) throws InternalErrorException, LibvirtException, URISyntaxException { - List disks = Arrays.asList(vmSpec.getDisks()); + protected void createVbd(final Connect conn, final VirtualMachineTO vmSpec, final String vmName, final LibvirtVMDef vm) throws InternalErrorException, LibvirtException, URISyntaxException { + final List disks = Arrays.asList(vmSpec.getDisks()); Collections.sort(disks, new Comparator() { @Override - public int compare(DiskTO arg0, DiskTO arg1) { + public int compare(final DiskTO arg0, final DiskTO arg1) { return arg0.getDiskSeq() > arg1.getDiskSeq() ? 1 : -1; } }); - for (DiskTO volume : disks) { + for (final DiskTO volume : disks) { KVMPhysicalDisk physicalDisk = null; KVMStoragePool pool = null; - DataTO data = volume.getData(); + final DataTO data = volume.getData(); if (volume.getType() == Volume.Type.ISO && data.getPath() != null) { - NfsTO nfsStore = (NfsTO)data.getDataStore(); - String volPath = nfsStore.getUrl() + File.separator + data.getPath(); - int index = volPath.lastIndexOf("/"); - String volDir = volPath.substring(0, index); - String volName = volPath.substring(index + 1); - KVMStoragePool secondaryStorage = _storagePoolMgr.getStoragePoolByURI(volDir); + final NfsTO nfsStore = (NfsTO)data.getDataStore(); + final String volPath = nfsStore.getUrl() + File.separator + data.getPath(); + final int index = volPath.lastIndexOf("/"); + final String volDir = volPath.substring(0, index); + final String volName = volPath.substring(index + 1); + final KVMStoragePool secondaryStorage = _storagePoolMgr.getStoragePoolByURI(volDir); physicalDisk = secondaryStorage.getPhysicalDisk(volName); } else if (volume.getType() != Volume.Type.ISO) { - PrimaryDataStoreTO store = (PrimaryDataStoreTO)data.getDataStore(); + final PrimaryDataStoreTO store = (PrimaryDataStoreTO)data.getDataStore(); physicalDisk = _storagePoolMgr.getPhysicalDisk(store.getPoolType(), store.getUuid(), data.getPath()); pool = physicalDisk.getPool(); } @@ -3951,11 +3956,11 @@ public int compare(DiskTO arg0, DiskTO arg1) { // if params contains a rootDiskController key, use its value (this is what other HVs are doing) DiskDef.diskBus diskBusType = null; - Map params = vmSpec.getDetails(); + final Map params = vmSpec.getDetails(); if (params != null && params.get("rootDiskController") != null && !params.get("rootDiskController").isEmpty()) { - String rootDiskController = params.get("rootDiskController"); + final String rootDiskController = params.get("rootDiskController"); s_logger.debug("Passed custom disk bus " + rootDiskController); - for (DiskDef.diskBus bus : DiskDef.diskBus.values()) { + for (final DiskDef.diskBus bus : DiskDef.diskBus.values()) { if (bus.toString().equalsIgnoreCase(rootDiskController)) { s_logger.debug("Found matching enum for disk bus " + rootDiskController); diskBusType = bus; @@ -3967,7 +3972,7 @@ public int compare(DiskTO arg0, DiskTO arg1) { if (diskBusType == null) { diskBusType = getGuestDiskModel(vmSpec.getPlatformEmulator()); } - DiskDef disk = new DiskDef(); + final DiskDef disk = new DiskDef(); if (volume.getType() == Volume.Type.ISO) { if (volPath == null) { /* Add iso as placeholder */ @@ -3976,7 +3981,7 @@ public int compare(DiskTO arg0, DiskTO arg1) { disk.defISODisk(volPath); } } else { - int devId = volume.getDiskSeq().intValue(); + final int devId = volume.getDiskSeq().intValue(); if (pool.getType() == StoragePoolType.RBD) { /* @@ -3987,9 +3992,9 @@ public int compare(DiskTO arg0, DiskTO arg1) { disk.defNetworkBasedDisk(physicalDisk.getPath().replace("rbd:", ""), pool.getSourceHost(), pool.getSourcePort(), pool.getAuthUserName(), pool.getUuid(), devId, diskBusType, diskProtocol.RBD, DiskDef.diskFmtType.RAW); } else if (pool.getType() == StoragePoolType.Gluster) { - String mountpoint = pool.getLocalPath(); - String path = physicalDisk.getPath(); - String glusterVolume = pool.getSourceDir().replace("/", ""); + final String mountpoint = pool.getLocalPath(); + final String path = physicalDisk.getPath(); + final String glusterVolume = pool.getSourceDir().replace("/", ""); disk.defNetworkBasedDisk(glusterVolume + path.replace(mountpoint, ""), pool.getSourceHost(), pool.getSourcePort(), null, null, devId, diskBusType, diskProtocol.GLUSTER, DiskDef.diskFmtType.QCOW2); } else if (pool.getType() == StoragePoolType.CLVM || physicalDisk.getFormat() == PhysicalDiskFormat.RAW) { @@ -4006,24 +4011,29 @@ public int compare(DiskTO arg0, DiskTO arg1) { } if (data instanceof VolumeObjectTO) { - VolumeObjectTO volumeObjectTO = (VolumeObjectTO)data; - if ((volumeObjectTO.getBytesReadRate() != null) && (volumeObjectTO.getBytesReadRate() > 0)) + final VolumeObjectTO volumeObjectTO = (VolumeObjectTO)data; + if (volumeObjectTO.getBytesReadRate() != null && volumeObjectTO.getBytesReadRate() > 0) { disk.setBytesReadRate(volumeObjectTO.getBytesReadRate()); - if ((volumeObjectTO.getBytesWriteRate() != null) && (volumeObjectTO.getBytesWriteRate() > 0)) + } + if (volumeObjectTO.getBytesWriteRate() != null && volumeObjectTO.getBytesWriteRate() > 0) { disk.setBytesWriteRate(volumeObjectTO.getBytesWriteRate()); - if ((volumeObjectTO.getIopsReadRate() != null) && (volumeObjectTO.getIopsReadRate() > 0)) + } + if (volumeObjectTO.getIopsReadRate() != null && volumeObjectTO.getIopsReadRate() > 0) { disk.setIopsReadRate(volumeObjectTO.getIopsReadRate()); - if ((volumeObjectTO.getIopsWriteRate() != null) && (volumeObjectTO.getIopsWriteRate() > 0)) + } + if (volumeObjectTO.getIopsWriteRate() != null && volumeObjectTO.getIopsWriteRate() > 0) { disk.setIopsWriteRate(volumeObjectTO.getIopsWriteRate()); - if (volumeObjectTO.getCacheMode() != null) + } + if (volumeObjectTO.getCacheMode() != null) { disk.setCacheMode(DiskDef.diskCacheMode.valueOf(volumeObjectTO.getCacheMode().toString().toUpperCase())); + } } vm.getDevices().addDevice(disk); } if (vmSpec.getType() != VirtualMachine.Type.User) { if (_sysvmISOPath != null) { - DiskDef iso = new DiskDef(); + final DiskDef iso = new DiskDef(); iso.defISODisk(_sysvmISOPath); vm.getDevices().addDevice(iso); } @@ -4031,22 +4041,22 @@ public int compare(DiskTO arg0, DiskTO arg1) { // For LXC, find and add the root filesystem, rbd data disks if (HypervisorType.LXC.toString().toLowerCase().equals(vm.getHvsType())) { - for (DiskTO volume : disks) { - DataTO data = volume.getData(); - PrimaryDataStoreTO store = (PrimaryDataStoreTO)data.getDataStore(); + for (final DiskTO volume : disks) { + final DataTO data = volume.getData(); + final PrimaryDataStoreTO store = (PrimaryDataStoreTO)data.getDataStore(); if (volume.getType() == Volume.Type.ROOT) { - KVMPhysicalDisk physicalDisk = _storagePoolMgr.getPhysicalDisk(store.getPoolType(), store.getUuid(), data.getPath()); - FilesystemDef rootFs = new FilesystemDef(physicalDisk.getPath(), "/"); + final KVMPhysicalDisk physicalDisk = _storagePoolMgr.getPhysicalDisk(store.getPoolType(), store.getUuid(), data.getPath()); + final FilesystemDef rootFs = new FilesystemDef(physicalDisk.getPath(), "/"); vm.getDevices().addDevice(rootFs); } else if (volume.getType() == Volume.Type.DATADISK) { - KVMPhysicalDisk physicalDisk = _storagePoolMgr.getPhysicalDisk(store.getPoolType(), store.getUuid(), data.getPath()); - KVMStoragePool pool = physicalDisk.getPool(); + final KVMPhysicalDisk physicalDisk = _storagePoolMgr.getPhysicalDisk(store.getPoolType(), store.getUuid(), data.getPath()); + final KVMStoragePool pool = physicalDisk.getPool(); if(StoragePoolType.RBD.equals(pool.getType())) { - int devId = volume.getDiskSeq().intValue(); - String device = mapRbdDevice(physicalDisk); + final int devId = volume.getDiskSeq().intValue(); + final String device = mapRbdDevice(physicalDisk); if (device != null) { s_logger.debug("RBD device on host is: " + device); - DiskDef diskdef = new DiskDef(); + final DiskDef diskdef = new DiskDef(); diskdef.defBlockBasedDisk(device, devId, DiskDef.diskBus.VIRTIO); diskdef.setQemuDriver(false); vm.getDevices().addDevice(diskdef); @@ -4060,14 +4070,14 @@ public int compare(DiskTO arg0, DiskTO arg1) { } - private void createVif(LibvirtVMDef vm, NicTO nic, String nicAdapter) throws InternalErrorException, LibvirtException { + private void createVif(final LibvirtVMDef vm, final NicTO nic, final String nicAdapter) throws InternalErrorException, LibvirtException { vm.getDevices().addDevice(getVifDriver(nic.getType()).plug(nic, vm.getPlatformEmulator().toString(), nicAdapter).toString()); } - protected CheckSshAnswer execute(CheckSshCommand cmd) { - String vmName = cmd.getName(); - String privateIp = cmd.getIp(); - int cmdPort = cmd.getPort(); + protected CheckSshAnswer execute(final CheckSshCommand cmd) { + final String vmName = cmd.getName(); + final String privateIp = cmd.getIp(); + final int cmdPort = cmd.getPort(); if (s_logger.isDebugEnabled()) { s_logger.debug("Ping command port, " + privateIp + ":" + cmdPort); @@ -4084,8 +4094,8 @@ protected CheckSshAnswer execute(CheckSshCommand cmd) { return new CheckSshAnswer(cmd); } - public boolean cleanupDisk(DiskDef disk) { - String path = disk.getDiskPath(); + public boolean cleanupDisk(final DiskDef disk) { + final String path = disk.getDiskPath(); if (path == null) { s_logger.debug("Unable to clean up disk with null path (perhaps empty cdrom drive):" + disk); @@ -4104,30 +4114,30 @@ protected KVMStoragePoolManager getPoolManager() { return _storagePoolMgr; } - protected synchronized String attachOrDetachISO(Connect conn, String vmName, String isoPath, boolean isAttach) throws LibvirtException, URISyntaxException, + protected synchronized String attachOrDetachISO(final Connect conn, final String vmName, String isoPath, final boolean isAttach) throws LibvirtException, URISyntaxException, InternalErrorException { String isoXml = null; if (isoPath != null && isAttach) { - int index = isoPath.lastIndexOf("/"); - String path = isoPath.substring(0, index); - String name = isoPath.substring(index + 1); - KVMStoragePool secondaryPool = _storagePoolMgr.getStoragePoolByURI(path); - KVMPhysicalDisk isoVol = secondaryPool.getPhysicalDisk(name); + final int index = isoPath.lastIndexOf("/"); + final String path = isoPath.substring(0, index); + final String name = isoPath.substring(index + 1); + final KVMStoragePool secondaryPool = _storagePoolMgr.getStoragePoolByURI(path); + final KVMPhysicalDisk isoVol = secondaryPool.getPhysicalDisk(name); isoPath = isoVol.getPath(); - DiskDef iso = new DiskDef(); + final DiskDef iso = new DiskDef(); iso.defISODisk(isoPath); isoXml = iso.toString(); } else { - DiskDef iso = new DiskDef(); + final DiskDef iso = new DiskDef(); iso.defISODisk(null); isoXml = iso.toString(); } - List disks = getDisks(conn, vmName); - String result = attachOrDetachDevice(conn, true, vmName, isoXml); + final List disks = getDisks(conn, vmName); + final String result = attachOrDetachDevice(conn, true, vmName, isoXml); if (result == null && !isAttach) { - for (DiskDef disk : disks) { + for (final DiskDef disk : disks) { if (disk.getDeviceType() == DiskDef.deviceType.CDROM) { cleanupDisk(disk); } @@ -4137,23 +4147,23 @@ protected synchronized String attachOrDetachISO(Connect conn, String vmName, Str return result; } - protected synchronized String attachOrDetachDisk(Connect conn, - boolean attach, String vmName, KVMPhysicalDisk attachingDisk, - int devId, Long bytesReadRate, Long bytesWriteRate, Long iopsReadRate, Long iopsWriteRate, String cacheMode) throws LibvirtException, InternalErrorException { + protected synchronized String attachOrDetachDisk(final Connect conn, + final boolean attach, final String vmName, final KVMPhysicalDisk attachingDisk, + final int devId, final Long bytesReadRate, final Long bytesWriteRate, final Long iopsReadRate, final Long iopsWriteRate, final String cacheMode) throws LibvirtException, InternalErrorException { List disks = null; Domain dm = null; DiskDef diskdef = null; - KVMStoragePool attachingPool = attachingDisk.getPool(); + final KVMStoragePool attachingPool = attachingDisk.getPool(); try { if (!attach) { dm = conn.domainLookupByName(vmName); - LibvirtDomainXMLParser parser = new LibvirtDomainXMLParser(); - String xml = dm.getXMLDesc(0); + final LibvirtDomainXMLParser parser = new LibvirtDomainXMLParser(); + final String xml = dm.getXMLDesc(0); parser.parseDomainXML(xml); disks = parser.getDisks(); - for (DiskDef disk : disks) { - String file = disk.getDiskPath(); + for (final DiskDef disk : disks) { + final String file = disk.getDiskPath(); if (file != null && file.equalsIgnoreCase(attachingDisk.getPath())) { diskdef = disk; break; @@ -4175,21 +4185,25 @@ protected synchronized String attachOrDetachDisk(Connect conn, } else if (attachingDisk.getFormat() == PhysicalDiskFormat.RAW) { diskdef.defBlockBasedDisk(attachingDisk.getPath(), devId, DiskDef.diskBus.VIRTIO); } - if ((bytesReadRate != null) && (bytesReadRate > 0)) + if (bytesReadRate != null && bytesReadRate > 0) { diskdef.setBytesReadRate(bytesReadRate); - if ((bytesWriteRate != null) && (bytesWriteRate > 0)) + } + if (bytesWriteRate != null && bytesWriteRate > 0) { diskdef.setBytesWriteRate(bytesWriteRate); - if ((iopsReadRate != null) && (iopsReadRate > 0)) + } + if (iopsReadRate != null && iopsReadRate > 0) { diskdef.setIopsReadRate(iopsReadRate); - if ((iopsWriteRate != null) && (iopsWriteRate > 0)) + } + if (iopsWriteRate != null && iopsWriteRate > 0) { diskdef.setIopsWriteRate(iopsWriteRate); + } if (cacheMode != null) { diskdef.setCacheMode(DiskDef.diskCacheMode.valueOf(cacheMode.toUpperCase())); } } - String xml = diskdef.toString(); + final String xml = diskdef.toString(); return attachOrDetachDevice(conn, attach, vmName, xml); } finally { if (dm != null) { @@ -4198,7 +4212,7 @@ protected synchronized String attachOrDetachDisk(Connect conn, } } - protected synchronized String attachOrDetachDevice(Connect conn, boolean attach, String vmName, String xml) throws LibvirtException, InternalErrorException { + protected synchronized String attachOrDetachDevice(final Connect conn, final boolean attach, final String vmName, final String xml) throws LibvirtException, InternalErrorException { Domain dm = null; try { dm = conn.domainLookupByName(vmName); @@ -4209,7 +4223,7 @@ protected synchronized String attachOrDetachDevice(Connect conn, boolean attach, s_logger.debug("Detaching device: " + xml); dm.detachDevice(xml); } - } catch (LibvirtException e) { + } catch (final LibvirtException e) { if (attach) { s_logger.warn("Failed to attach device to " + vmName + ": " + e.getMessage()); } else { @@ -4220,7 +4234,7 @@ protected synchronized String attachOrDetachDevice(Connect conn, boolean attach, if (dm != null) { try { dm.free(); - } catch (LibvirtException l) { + } catch (final LibvirtException l) { s_logger.trace("Ignoring libvirt error.", l); } } @@ -4230,12 +4244,12 @@ protected synchronized String attachOrDetachDevice(Connect conn, boolean attach, } @Override - public PingCommand getCurrentStatus(long id) { + public PingCommand getCurrentStatus(final long id) { if (!_canBridgeFirewall) { return new PingRoutingCommand(com.cloud.host.Host.Type.Routing, id, this.getHostVmStateReport()); } else { - HashMap> nwGrpStates = syncNetworkGroups(id); + final HashMap> nwGrpStates = syncNetworkGroups(id); return new PingRoutingWithNwGroupsCommand(getType(), id, this.getHostVmStateReport(), nwGrpStates); } } @@ -4247,8 +4261,8 @@ public Type getType() { private Map getVersionStrings() { final Script command = new Script(_versionstringpath, _timeout, s_logger); - KeyValueInterpreter kvi = new KeyValueInterpreter(); - String result = command.execute(kvi); + final KeyValueInterpreter kvi = new KeyValueInterpreter(); + final String result = command.execute(kvi); if (result == null) { return kvi.getKeyValues(); } else { @@ -4276,8 +4290,8 @@ public StartupCommand[] initialize() { StartupStorageCommand sscmd = null; try { - KVMStoragePool localStoragePool = _storagePoolMgr.createStoragePool(_localStorageUUID, "localhost", -1, _localStoragePath, "", StoragePoolType.Filesystem); - com.cloud.agent.api.StoragePoolInfo pi = + final KVMStoragePool localStoragePool = _storagePoolMgr.createStoragePool(_localStorageUUID, "localhost", -1, _localStoragePath, "", StoragePoolType.Filesystem); + final com.cloud.agent.api.StoragePoolInfo pi = new com.cloud.agent.api.StoragePoolInfo(localStoragePool.getUuid(), cmd.getPrivateIpAddress(), _localStoragePath, _localStoragePath, StoragePoolType.Filesystem, localStoragePool.getCapacity(), localStoragePool.getAvailable()); @@ -4286,7 +4300,7 @@ public StartupCommand[] initialize() { sscmd.setGuid(pi.getUuid()); sscmd.setDataCenter(_dcId); sscmd.setResourceType(Storage.StorageResourceType.STORAGE_POOL); - } catch (CloudRuntimeException e) { + } catch (final CloudRuntimeException e) { s_logger.debug("Unable to initialize local storage pool: " + e); } @@ -4301,30 +4315,30 @@ private String getIqn() { try { final String textToFind = "InitiatorName="; - Script iScsiAdmCmd = new Script(true, "grep", 0, s_logger); + final Script iScsiAdmCmd = new Script(true, "grep", 0, s_logger); iScsiAdmCmd.add(textToFind); iScsiAdmCmd.add("/etc/iscsi/initiatorname.iscsi"); - OutputInterpreter.OneLineParser parser = new OutputInterpreter.OneLineParser(); + final OutputInterpreter.OneLineParser parser = new OutputInterpreter.OneLineParser(); - String result = iScsiAdmCmd.execute(parser); + final String result = iScsiAdmCmd.execute(parser); if (result != null) { return null; } - String textFound = parser.getLine().trim(); + final String textFound = parser.getLine().trim(); return textFound.substring(textToFind.length()); } - catch (Exception ex) { + catch (final Exception ex) { return null; } } - protected List getAllVmNames(Connect conn) { - ArrayList la = new ArrayList(); + protected List getAllVmNames(final Connect conn) { + final ArrayList la = new ArrayList(); try { final String names[] = conn.listDefinedDomains(); for (int i = 0; i < names.length; i++) { @@ -4373,7 +4387,7 @@ private HashMap getHostVmStateReport() { vmStates.putAll(getHostVmStateReport(conn)); conn = LibvirtConnection.getConnectionByType(HypervisorType.KVM.toString()); vmStates.putAll(getHostVmStateReport(conn)); - } catch (LibvirtException e) { + } catch (final LibvirtException e) { s_logger.debug("Failed to get connection: " + e.getMessage()); } } @@ -4382,7 +4396,7 @@ private HashMap getHostVmStateReport() { try { conn = LibvirtConnection.getConnectionByType(HypervisorType.KVM.toString()); vmStates.putAll(getHostVmStateReport(conn)); - } catch (LibvirtException e) { + } catch (final LibvirtException e) { s_logger.debug("Failed to get connection: " + e.getMessage()); } } @@ -4390,7 +4404,7 @@ private HashMap getHostVmStateReport() { return vmStates; } - private HashMap getHostVmStateReport(Connect conn) { + private HashMap getHostVmStateReport(final Connect conn) { final HashMap vmStates = new HashMap(); String[] vms = null; @@ -4414,19 +4428,20 @@ private HashMap getHostVmStateReport(Connect con try { dm = conn.domainLookupByID(ids[i]); - DomainState ps = dm.getInfo().state; + final DomainState ps = dm.getInfo().state; final PowerState state = convertToPowerState(ps); s_logger.trace("VM " + dm.getName() + ": powerstate = " + ps + "; vm state=" + state.toString()); - String vmName = dm.getName(); + final String vmName = dm.getName(); // TODO : for XS/KVM (host-based resource), we require to remove // VM completely from host, for some reason, KVM seems to still keep // Stopped VM around, to work-around that, reporting only powered-on VM // - if (state == PowerState.PowerOn) + if (state == PowerState.PowerOn) { vmStates.put(vmName, new HostVmStateReportEntry(state, conn.getHostName())); + } } catch (final LibvirtException e) { s_logger.warn("Unable to get vms", e); } finally { @@ -4434,7 +4449,7 @@ private HashMap getHostVmStateReport(Connect con if (dm != null) { dm.free(); } - } catch (LibvirtException e) { + } catch (final LibvirtException e) { s_logger.trace("Ignoring libvirt error.", e); } } @@ -4445,17 +4460,18 @@ private HashMap getHostVmStateReport(Connect con dm = conn.domainLookupByName(vms[i]); - DomainState ps = dm.getInfo().state; + final DomainState ps = dm.getInfo().state; final PowerState state = convertToPowerState(ps); - String vmName = dm.getName(); + final String vmName = dm.getName(); s_logger.trace("VM " + vmName + ": powerstate = " + ps + "; vm state=" + state.toString()); // TODO : for XS/KVM (host-based resource), we require to remove // VM completely from host, for some reason, KVM seems to still keep // Stopped VM around, to work-around that, reporting only powered-on VM // - if (state == PowerState.PowerOn) + if (state == PowerState.PowerOn) { vmStates.put(vmName, new HostVmStateReportEntry(state, conn.getHostName())); + } } catch (final LibvirtException e) { s_logger.warn("Unable to get vms", e); } finally { @@ -4463,7 +4479,7 @@ private HashMap getHostVmStateReport(Connect con if (dm != null) { dm.free(); } - } catch (LibvirtException e) { + } catch (final LibvirtException e) { s_logger.trace("Ignoring libvirt error.", e); } } @@ -4487,10 +4503,10 @@ protected List getHostInfo() { cpuSockets = hosts.sockets; cpus = hosts.cpus; ram = hosts.memory * 1024L; - LibvirtCapXMLParser parser = new LibvirtCapXMLParser(); + final LibvirtCapXMLParser parser = new LibvirtCapXMLParser(); parser.parseCapabilitiesXML(conn.getCapabilities()); - ArrayList oss = parser.getGuestOsType(); - for (String s : oss) { + final ArrayList oss = parser.getGuestOsType(); + for (final String s : oss) { /* * Even host supports guest os type more than hvm, we only * report hvm to management server @@ -4499,7 +4515,7 @@ protected List getHostInfo() { cap = "hvm"; } } - } catch (LibvirtException e) { + } catch (final LibvirtException e) { s_logger.trace("Ignoring libvirt error.", e); } @@ -4533,23 +4549,23 @@ protected static long getCpuSpeed(final NodeInfo nodeInfo) { } } - protected String rebootVM(Connect conn, String vmName) { + protected String rebootVM(final Connect conn, final String vmName) { Domain dm = null; String msg = null; try { dm = conn.domainLookupByName(vmName); String vmDef = dm.getXMLDesc(0); - LibvirtDomainXMLParser parser = new LibvirtDomainXMLParser(); + final LibvirtDomainXMLParser parser = new LibvirtDomainXMLParser(); parser.parseDomainXML(vmDef); - for (InterfaceDef nic : parser.getInterfaces()) { - if ((nic.getNetType() == guestNetType.BRIDGE) && (nic.getBrName().startsWith("cloudVirBr"))) { + for (final InterfaceDef nic : parser.getInterfaces()) { + if (nic.getNetType() == guestNetType.BRIDGE && nic.getBrName().startsWith("cloudVirBr")) { try { - int vnetId = Integer.parseInt(nic.getBrName().replaceFirst("cloudVirBr", "")); - String pifName = getPif(_guestBridgeName); - String newBrName = "br" + pifName + "-" + vnetId; + final int vnetId = Integer.parseInt(nic.getBrName().replaceFirst("cloudVirBr", "")); + final String pifName = getPif(_guestBridgeName); + final String newBrName = "br" + pifName + "-" + vnetId; vmDef = vmDef.replaceAll("'" + nic.getBrName() + "'", "'" + newBrName + "'"); s_logger.debug("VM bridge name is changed from " + nic.getBrName() + " to " + newBrName); - } catch (NumberFormatException e) { + } catch (final NumberFormatException e) { continue; } } @@ -4558,10 +4574,10 @@ protected String rebootVM(Connect conn, String vmName) { msg = stopVM(conn, vmName); msg = startVM(conn, vmName, vmDef); return null; - } catch (LibvirtException e) { + } catch (final LibvirtException e) { s_logger.warn("Failed to create vm", e); msg = e.getMessage(); - } catch (InternalErrorException e) { + } catch (final InternalErrorException e) { s_logger.warn("Failed to create vm", e); msg = e.getMessage(); } finally { @@ -4569,7 +4585,7 @@ protected String rebootVM(Connect conn, String vmName) { if (dm != null) { dm.free(); } - } catch (LibvirtException e) { + } catch (final LibvirtException e) { s_logger.trace("Ignoring libvirt error.", e); } } @@ -4577,7 +4593,7 @@ protected String rebootVM(Connect conn, String vmName) { return msg; } - protected String stopVM(Connect conn, String vmName) { + public String stopVM(final Connect conn, final String vmName) { DomainState state = null; Domain dm = null; @@ -4597,14 +4613,14 @@ protected String stopVM(Connect conn, String vmName) { dm = conn.domainLookupByName(vmName); state = dm.getInfo().state; break; - } catch (LibvirtException e) { + } catch (final LibvirtException e) { s_logger.debug("Failed to get vm status:" + e.getMessage()); } finally { try { if (dm != null) { dm.free(); } - } catch (LibvirtException l) { + } catch (final LibvirtException l) { s_logger.trace("Ignoring libvirt error.", l); } } @@ -4627,11 +4643,11 @@ protected String stopVM(Connect conn, String vmName) { return null; } - protected String stopVM(Connect conn, String vmName, boolean force) { + protected String stopVM(final Connect conn, final String vmName, final boolean force) { Domain dm = null; try { dm = conn.domainLookupByName(vmName); - int persist = dm.isPersistent(); + final int persist = dm.isPersistent(); if (force) { if (dm.isActive() == 1) { dm.destroy(); @@ -4648,12 +4664,12 @@ protected String stopVM(Connect conn, String vmName, boolean force) { /* Wait for the domain gets into shutoff state. When it does the dm object will no longer work, so we need to catch it. */ try { - while (dm.isActive() == 1 && (retry >= 0)) { + while (dm.isActive() == 1 && retry >= 0) { Thread.sleep(2000); retry--; } - } catch (LibvirtException e) { - String error = e.toString(); + } catch (final LibvirtException e) { + final String error = e.toString(); if (error.contains("Domain not found")) { s_logger.debug("successfully shut down vm " + vmName); } else { @@ -4669,14 +4685,14 @@ protected String stopVM(Connect conn, String vmName, boolean force) { } } } - } catch (LibvirtException e) { + } catch (final LibvirtException e) { if (e.getMessage().contains("Domain not found")) { s_logger.debug("VM " + vmName + " doesn't exist, no need to stop it"); return null; } s_logger.debug("Failed to stop VM :" + vmName + " :", e); return e.getMessage(); - } catch (InterruptedException ie) { + } catch (final InterruptedException ie) { s_logger.debug("Interrupted sleep"); return ie.getMessage(); } finally { @@ -4684,7 +4700,7 @@ protected String stopVM(Connect conn, String vmName, boolean force) { if (dm != null) { dm.free(); } - } catch (LibvirtException e) { + } catch (final LibvirtException e) { s_logger.trace("Ignoring libvirt error.", e); } } @@ -4692,12 +4708,12 @@ protected String stopVM(Connect conn, String vmName, boolean force) { return null; } - protected Integer getVncPort(Connect conn, String vmName) throws LibvirtException { - LibvirtDomainXMLParser parser = new LibvirtDomainXMLParser(); + protected Integer getVncPort(final Connect conn, final String vmName) throws LibvirtException { + final LibvirtDomainXMLParser parser = new LibvirtDomainXMLParser(); Domain dm = null; try { dm = conn.domainLookupByName(vmName); - String xmlDesc = dm.getXMLDesc(0); + final String xmlDesc = dm.getXMLDesc(0); parser.parseDomainXML(xmlDesc); return parser.getVncPort(); } finally { @@ -4705,47 +4721,47 @@ protected Integer getVncPort(Connect conn, String vmName) throws LibvirtExceptio if (dm != null) { dm.free(); } - } catch (LibvirtException l) { + } catch (final LibvirtException l) { s_logger.trace("Ignoring libvirt error.", l); } } } - private boolean IsHVMEnabled(Connect conn) { - LibvirtCapXMLParser parser = new LibvirtCapXMLParser(); + private boolean IsHVMEnabled(final Connect conn) { + final LibvirtCapXMLParser parser = new LibvirtCapXMLParser(); try { parser.parseCapabilitiesXML(conn.getCapabilities()); - ArrayList osTypes = parser.getGuestOsType(); - for (String o : osTypes) { + final ArrayList osTypes = parser.getGuestOsType(); + for (final String o : osTypes) { if (o.equalsIgnoreCase("hvm")) { return true; } } - } catch (LibvirtException e) { + } catch (final LibvirtException e) { s_logger.trace("Ignoring libvirt error.", e); } return false; } - private String getHypervisorPath(Connect conn) { - LibvirtCapXMLParser parser = new LibvirtCapXMLParser(); + private String getHypervisorPath(final Connect conn) { + final LibvirtCapXMLParser parser = new LibvirtCapXMLParser(); try { parser.parseCapabilitiesXML(conn.getCapabilities()); - } catch (LibvirtException e) { + } catch (final LibvirtException e) { s_logger.debug(e.getMessage()); } return parser.getEmulator(); } - private String getGuestType(Connect conn, String vmName) { - LibvirtDomainXMLParser parser = new LibvirtDomainXMLParser(); + private String getGuestType(final Connect conn, final String vmName) { + final LibvirtDomainXMLParser parser = new LibvirtDomainXMLParser(); Domain dm = null; try { dm = conn.domainLookupByName(vmName); - String xmlDesc = dm.getXMLDesc(0); + final String xmlDesc = dm.getXMLDesc(0); parser.parseDomainXML(xmlDesc); return parser.getDescription(); - } catch (LibvirtException e) { + } catch (final LibvirtException e) { s_logger.trace("Ignoring libvirt error.", e); return null; } finally { @@ -4753,13 +4769,13 @@ private String getGuestType(Connect conn, String vmName) { if (dm != null) { dm.free(); } - } catch (LibvirtException l) { + } catch (final LibvirtException l) { s_logger.trace("Ignoring libvirt error.", l); } } } - boolean isGuestPVEnabled(String guestOSName) { + boolean isGuestPVEnabled(final String guestOSName) { if (guestOSName == null) { return false; } @@ -4783,7 +4799,7 @@ public boolean isCentosHost() { } } - private DiskDef.diskBus getGuestDiskModel(String platformEmulator) { + private DiskDef.diskBus getGuestDiskModel(final String platformEmulator) { if (isGuestPVEnabled(platformEmulator)) { return DiskDef.diskBus.VIRTIO; } else { @@ -4791,29 +4807,29 @@ private DiskDef.diskBus getGuestDiskModel(String platformEmulator) { } } - private void cleanupVMNetworks(Connect conn, List nics) { + private void cleanupVMNetworks(final Connect conn, final List nics) { if (nics != null) { - for (InterfaceDef nic : nics) { - for (VifDriver vifDriver : getAllVifDrivers()) { + for (final InterfaceDef nic : nics) { + for (final VifDriver vifDriver : getAllVifDrivers()) { vifDriver.unplug(nic); } } } } - public Domain getDomain(Connect conn, String vmName) throws LibvirtException { + public Domain getDomain(final Connect conn, final String vmName) throws LibvirtException { return conn.domainLookupByName(vmName); } - protected List getInterfaces(Connect conn, String vmName) { - LibvirtDomainXMLParser parser = new LibvirtDomainXMLParser(); + public List getInterfaces(final Connect conn, final String vmName) { + final LibvirtDomainXMLParser parser = new LibvirtDomainXMLParser(); Domain dm = null; try { dm = conn.domainLookupByName(vmName); parser.parseDomainXML(dm.getXMLDesc(0)); return parser.getInterfaces(); - } catch (LibvirtException e) { + } catch (final LibvirtException e) { s_logger.debug("Failed to get dom xml: " + e.toString()); return new ArrayList(); } finally { @@ -4821,21 +4837,21 @@ protected List getInterfaces(Connect conn, String vmName) { if (dm != null) { dm.free(); } - } catch (LibvirtException e) { + } catch (final LibvirtException e) { s_logger.trace("Ignoring libvirt error.", e); } } } - public List getDisks(Connect conn, String vmName) { - LibvirtDomainXMLParser parser = new LibvirtDomainXMLParser(); + public List getDisks(final Connect conn, final String vmName) { + final LibvirtDomainXMLParser parser = new LibvirtDomainXMLParser(); Domain dm = null; try { dm = conn.domainLookupByName(vmName); parser.parseDomainXML(dm.getXMLDesc(0)); return parser.getDisks(); - } catch (LibvirtException e) { + } catch (final LibvirtException e) { s_logger.debug("Failed to get dom xml: " + e.toString()); return new ArrayList(); } finally { @@ -4843,39 +4859,40 @@ public List getDisks(Connect conn, String vmName) { if (dm != null) { dm.free(); } - } catch (LibvirtException e) { + } catch (final LibvirtException e) { s_logger.trace("Ignoring libvirt error.", e); } } } - private String executeBashScript(String script) { - Script command = new Script("/bin/bash", _timeout, s_logger); + private String executeBashScript(final String script) { + final Script command = new Script("/bin/bash", _timeout, s_logger); command.add("-c"); command.add(script); return command.execute(); } - private List getVmDiskStat(Connect conn, String vmName) throws LibvirtException { + private List getVmDiskStat(final Connect conn, final String vmName) throws LibvirtException { Domain dm = null; try { dm = getDomain(conn, vmName); - List stats = new ArrayList(); + final List stats = new ArrayList(); - List disks = getDisks(conn, vmName); + final List disks = getDisks(conn, vmName); - for (DiskDef disk : disks) { - if (disk.getDeviceType() != deviceType.DISK) + for (final DiskDef disk : disks) { + if (disk.getDeviceType() != deviceType.DISK) { break; - DomainBlockStats blockStats = dm.blockStats(disk.getDiskLabel()); - String path = disk.getDiskPath(); // for example, path = /mnt/pool_uuid/disk_path/ + } + final DomainBlockStats blockStats = dm.blockStats(disk.getDiskLabel()); + final String path = disk.getDiskPath(); // for example, path = /mnt/pool_uuid/disk_path/ String diskPath = null; if (path != null) { - String[] token = path.split("/"); + final String[] token = path.split("/"); if (token.length > 3) { diskPath = token[3]; - VmDiskStatsEntry stat = new VmDiskStatsEntry(vmName, diskPath, blockStats.wr_req, blockStats.rd_req, blockStats.wr_bytes, blockStats.rd_bytes); + final VmDiskStatsEntry stat = new VmDiskStatsEntry(vmName, diskPath, blockStats.wr_req, blockStats.rd_req, blockStats.wr_bytes, blockStats.rd_bytes); stats.add(stat); } } @@ -4900,20 +4917,20 @@ private class VmStats { Calendar _timestamp; } - VmStatsEntry getVmStat(Connect conn, String vmName) throws LibvirtException { + VmStatsEntry getVmStat(final Connect conn, final String vmName) throws LibvirtException { Domain dm = null; try { dm = getDomain(conn, vmName); - DomainInfo info = dm.getInfo(); + final DomainInfo info = dm.getInfo(); - VmStatsEntry stats = new VmStatsEntry(); + final VmStatsEntry stats = new VmStatsEntry(); stats.setNumCPUs(info.nrVirtCpu); stats.setEntityType("vm"); /* get cpu utilization */ VmStats oldStats = null; - Calendar now = Calendar.getInstance(); + final Calendar now = Calendar.getInstance(); oldStats = _vmStats.get(vmName); @@ -4922,7 +4939,7 @@ VmStatsEntry getVmStat(Connect conn, String vmName) throws LibvirtException { elapsedTime = now.getTimeInMillis() - oldStats._timestamp.getTimeInMillis(); double utilization = (info.cpuTime - oldStats._usedTime) / ((double)elapsedTime * 1000000); - NodeInfo node = conn.nodeInfo(); + final NodeInfo node = conn.nodeInfo(); utilization = utilization / node.cpus; if (utilization > 0) { stats.setCPUUtilization(utilization * 100); @@ -4931,32 +4948,34 @@ VmStatsEntry getVmStat(Connect conn, String vmName) throws LibvirtException { /* get network stats */ - List vifs = getInterfaces(conn, vmName); + final List vifs = getInterfaces(conn, vmName); long rx = 0; long tx = 0; - for (InterfaceDef vif : vifs) { - DomainInterfaceStats ifStats = dm.interfaceStats(vif.getDevName()); + for (final InterfaceDef vif : vifs) { + final DomainInterfaceStats ifStats = dm.interfaceStats(vif.getDevName()); rx += ifStats.rx_bytes; tx += ifStats.tx_bytes; } if (oldStats != null) { - double deltarx = rx - oldStats._rx; - if (deltarx > 0) + final double deltarx = rx - oldStats._rx; + if (deltarx > 0) { stats.setNetworkReadKBs(deltarx / 1024); - double deltatx = tx - oldStats._tx; - if (deltatx > 0) + } + final double deltatx = tx - oldStats._tx; + if (deltatx > 0) { stats.setNetworkWriteKBs(deltatx / 1024); + } } /* get disk stats */ - List disks = getDisks(conn, vmName); + final List disks = getDisks(conn, vmName); long io_rd = 0; long io_wr = 0; long bytes_rd = 0; long bytes_wr = 0; - for (DiskDef disk : disks) { - DomainBlockStats blockStats = dm.blockStats(disk.getDiskLabel()); + for (final DiskDef disk : disks) { + final DomainBlockStats blockStats = dm.blockStats(disk.getDiskLabel()); io_rd += blockStats.rd_req; io_wr += blockStats.wr_req; bytes_rd += blockStats.rd_bytes; @@ -4964,22 +4983,26 @@ VmStatsEntry getVmStat(Connect conn, String vmName) throws LibvirtException { } if (oldStats != null) { - long deltaiord = io_rd - oldStats._ioRead; - if (deltaiord > 0) + final long deltaiord = io_rd - oldStats._ioRead; + if (deltaiord > 0) { stats.setDiskReadIOs(deltaiord); - long deltaiowr = io_wr - oldStats._ioWrote; - if (deltaiowr > 0) + } + final long deltaiowr = io_wr - oldStats._ioWrote; + if (deltaiowr > 0) { stats.setDiskWriteIOs(deltaiowr); - double deltabytesrd = bytes_rd - oldStats._bytesRead; - if (deltabytesrd > 0) + } + final double deltabytesrd = bytes_rd - oldStats._bytesRead; + if (deltabytesrd > 0) { stats.setDiskReadKBs(deltabytesrd / 1024); - double deltabyteswr = bytes_wr - oldStats._bytesWrote; - if (deltabyteswr > 0) + } + final double deltabyteswr = bytes_wr - oldStats._bytesWrote; + if (deltabyteswr > 0) { stats.setDiskWriteKBs(deltabyteswr / 1024); + } } /* save to Hashmap */ - VmStats newStat = new VmStats(); + final VmStats newStat = new VmStats(); newStat._usedTime = info.cpuTime; newStat._rx = rx; newStat._tx = tx; @@ -4997,55 +5020,55 @@ VmStatsEntry getVmStat(Connect conn, String vmName) throws LibvirtException { } } - private boolean can_bridge_firewall(String prvNic) { - Script cmd = new Script(_securityGroupPath, _timeout, s_logger); + private boolean can_bridge_firewall(final String prvNic) { + final Script cmd = new Script(_securityGroupPath, _timeout, s_logger); cmd.add("can_bridge_firewall"); cmd.add(prvNic); - String result = cmd.execute(); + final String result = cmd.execute(); if (result != null) { return false; } return true; } - protected boolean destroy_network_rules_for_vm(Connect conn, String vmName) { + public boolean destroyNetworkRulesForVM(final Connect conn, final String vmName) { if (!_canBridgeFirewall) { return false; } String vif = null; - List intfs = getInterfaces(conn, vmName); + final List intfs = getInterfaces(conn, vmName); if (intfs.size() > 0) { - InterfaceDef intf = intfs.get(0); + final InterfaceDef intf = intfs.get(0); vif = intf.getDevName(); } - Script cmd = new Script(_securityGroupPath, _timeout, s_logger); + final Script cmd = new Script(_securityGroupPath, _timeout, s_logger); cmd.add("destroy_network_rules_for_vm"); cmd.add("--vmname", vmName); if (vif != null) { cmd.add("--vif", vif); } - String result = cmd.execute(); + final String result = cmd.execute(); if (result != null) { return false; } return true; } - protected boolean default_network_rules(Connect conn, String vmName, NicTO nic, Long vmId, String secIpStr) { + protected boolean default_network_rules(final Connect conn, final String vmName, final NicTO nic, final Long vmId, final String secIpStr) { if (!_canBridgeFirewall) { return false; } - List intfs = getInterfaces(conn, vmName); + final List intfs = getInterfaces(conn, vmName); if (intfs.size() == 0 || intfs.size() < nic.getDeviceId()) { return false; } - InterfaceDef intf = intfs.get(nic.getDeviceId()); - String brname = intf.getBrName(); - String vif = intf.getDevName(); + final InterfaceDef intf = intfs.get(nic.getDeviceId()); + final String brname = intf.getBrName(); + final String vif = intf.getDevName(); - Script cmd = new Script(_securityGroupPath, _timeout, s_logger); + final Script cmd = new Script(_securityGroupPath, _timeout, s_logger); cmd.add("default_network_rules"); cmd.add("--vmname", vmName); cmd.add("--vmid", vmId.toString()); @@ -5056,28 +5079,28 @@ protected boolean default_network_rules(Connect conn, String vmName, NicTO nic, cmd.add("--vif", vif); cmd.add("--brname", brname); cmd.add("--nicsecips", secIpStr); - String result = cmd.execute(); + final String result = cmd.execute(); if (result != null) { return false; } return true; } - protected boolean post_default_network_rules(Connect conn, String vmName, NicTO nic, Long vmId, InetAddress dhcpServerIp, String hostIp, String hostMacAddr) { + protected boolean post_default_network_rules(final Connect conn, final String vmName, final NicTO nic, final Long vmId, final InetAddress dhcpServerIp, final String hostIp, final String hostMacAddr) { if (!_canBridgeFirewall) { return false; } - List intfs = getInterfaces(conn, vmName); + final List intfs = getInterfaces(conn, vmName); if (intfs.size() < nic.getDeviceId()) { return false; } - InterfaceDef intf = intfs.get(nic.getDeviceId()); - String brname = intf.getBrName(); - String vif = intf.getDevName(); + final InterfaceDef intf = intfs.get(nic.getDeviceId()); + final String brname = intf.getBrName(); + final String vif = intf.getDevName(); - Script cmd = new Script(_securityGroupPath, _timeout, s_logger); + final Script cmd = new Script(_securityGroupPath, _timeout, s_logger); cmd.add("post_default_network_rules"); cmd.add("--vmname", vmName); cmd.add("--vmid", vmId.toString()); @@ -5085,42 +5108,43 @@ protected boolean post_default_network_rules(Connect conn, String vmName, NicTO cmd.add("--vmmac", nic.getMac()); cmd.add("--vif", vif); cmd.add("--brname", brname); - if (dhcpServerIp != null) + if (dhcpServerIp != null) { cmd.add("--dhcpSvr", dhcpServerIp.getHostAddress()); + } cmd.add("--hostIp", hostIp); cmd.add("--hostMacAddr", hostMacAddr); - String result = cmd.execute(); + final String result = cmd.execute(); if (result != null) { return false; } return true; } - protected boolean default_network_rules_for_systemvm(Connect conn, String vmName) { + protected boolean default_network_rules_for_systemvm(final Connect conn, final String vmName) { if (!_canBridgeFirewall) { return false; } - Script cmd = new Script(_securityGroupPath, _timeout, s_logger); + final Script cmd = new Script(_securityGroupPath, _timeout, s_logger); cmd.add("default_network_rules_systemvm"); cmd.add("--vmname", vmName); cmd.add("--localbrname", _linkLocalBridgeName); - String result = cmd.execute(); + final String result = cmd.execute(); if (result != null) { return false; } return true; } - private boolean add_network_rules(String vmName, String vmId, String guestIP, String sig, String seq, String mac, String rules, String vif, String brname, - String secIps) { + private boolean add_network_rules(final String vmName, final String vmId, final String guestIP, final String sig, final String seq, final String mac, final String rules, final String vif, final String brname, + final String secIps) { if (!_canBridgeFirewall) { return false; } - String newRules = rules.replace(" ", ";"); - Script cmd = new Script(_securityGroupPath, _timeout, s_logger); + final String newRules = rules.replace(" ", ";"); + final Script cmd = new Script(_securityGroupPath, _timeout, s_logger); cmd.add("add_network_rules"); cmd.add("--vmname", vmName); cmd.add("--vmid", vmId); @@ -5134,26 +5158,26 @@ private boolean add_network_rules(String vmName, String vmId, String guestIP, St if (newRules != null && !newRules.isEmpty()) { cmd.add("--rules", newRules); } - String result = cmd.execute(); + final String result = cmd.execute(); if (result != null) { return false; } return true; } - private boolean network_rules_vmSecondaryIp(Connect conn, String vmName, String secIp, String action) { + private boolean network_rules_vmSecondaryIp(final Connect conn, final String vmName, final String secIp, final String action) { if (!_canBridgeFirewall) { return false; } - Script cmd = new Script(_securityGroupPath, _timeout, s_logger); + final Script cmd = new Script(_securityGroupPath, _timeout, s_logger); cmd.add("network_rules_vmSecondaryIp"); cmd.add("--vmname", vmName); cmd.add("--nicsecips", secIp); cmd.add("--action", action); - String result = cmd.execute(); + final String result = cmd.execute(); if (result != null) { return false; } @@ -5164,9 +5188,9 @@ private boolean cleanup_rules() { if (!_canBridgeFirewall) { return false; } - Script cmd = new Script(_securityGroupPath, _timeout, s_logger); + final Script cmd = new Script(_securityGroupPath, _timeout, s_logger); cmd.add("cleanup_rules"); - String result = cmd.execute(); + final String result = cmd.execute(); if (result != null) { return false; } @@ -5174,30 +5198,30 @@ private boolean cleanup_rules() { } private String get_rule_logs_for_vms() { - Script cmd = new Script(_securityGroupPath, _timeout, s_logger); + final Script cmd = new Script(_securityGroupPath, _timeout, s_logger); cmd.add("get_rule_logs_for_vms"); - OutputInterpreter.OneLineParser parser = new OutputInterpreter.OneLineParser(); - String result = cmd.execute(parser); + final OutputInterpreter.OneLineParser parser = new OutputInterpreter.OneLineParser(); + final String result = cmd.execute(parser); if (result == null) { return parser.getLine(); } return null; } - private HashMap> syncNetworkGroups(long id) { - HashMap> states = new HashMap>(); + private HashMap> syncNetworkGroups(final long id) { + final HashMap> states = new HashMap>(); - String result = get_rule_logs_for_vms(); + final String result = get_rule_logs_for_vms(); s_logger.trace("syncNetworkGroups: id=" + id + " got: " + result); - String[] rulelogs = result != null ? result.split(";") : new String[0]; - for (String rulesforvm : rulelogs) { - String[] log = rulesforvm.split(","); + final String[] rulelogs = result != null ? result.split(";") : new String[0]; + for (final String rulesforvm : rulelogs) { + final String[] log = rulesforvm.split(","); if (log.length != 6) { continue; } try { states.put(log[0], new Pair(Long.parseLong(log[1]), Long.parseLong(log[5]))); - } catch (NumberFormatException nfe) { + } catch (final NumberFormatException nfe) { states.put(log[0], new Pair(-1L, -1L)); } } @@ -5206,7 +5230,7 @@ private HashMap> syncNetworkGroups(long id) { /* online snapshot supported by enhanced qemu-kvm */ private boolean isSnapshotSupported() { - String result = executeBashScript("qemu-img --help|grep convert"); + final String result = executeBashScript("qemu-img --help|grep convert"); if (result != null) { return false; } else { @@ -5214,40 +5238,40 @@ private boolean isSnapshotSupported() { } } - static Pair getNicStats(String nicName) { + static Pair getNicStats(final String nicName) { return new Pair(readDouble(nicName, "rx_bytes"), readDouble(nicName, "tx_bytes")); } - static double readDouble(String nicName, String fileName) { + static double readDouble(final String nicName, final String fileName) { final String path = "/sys/class/net/" + nicName + "/statistics/" + fileName; try { return Double.parseDouble(FileUtils.readFileToString(new File(path))); - } catch (IOException ioe) { + } catch (final IOException ioe) { s_logger.warn("Failed to read the " + fileName + " for " + nicName + " from " + path, ioe); return 0.0; } } - private Answer execute(NetworkRulesSystemVmCommand cmd) { + private Answer execute(final NetworkRulesSystemVmCommand cmd) { boolean success = false; Connect conn; try { conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); success = default_network_rules_for_systemvm(conn, cmd.getVmName()); - } catch (LibvirtException e) { + } catch (final LibvirtException e) { s_logger.trace("Ignoring libvirt error.", e); } return new Answer(cmd, success, ""); } - private Answer execute(NetworkRulesVmSecondaryIpCommand cmd) { + private Answer execute(final NetworkRulesVmSecondaryIpCommand cmd) { boolean success = false; Connect conn; try { conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); success = network_rules_vmSecondaryIp(conn, cmd.getVmName(), cmd.getVmSecIp(), cmd.getAction()); - } catch (LibvirtException e) { + } catch (final LibvirtException e) { // TODO Auto-generated catch block e.printStackTrace(); } @@ -5255,21 +5279,21 @@ private Answer execute(NetworkRulesVmSecondaryIpCommand cmd) { return new Answer(cmd, success, ""); } - private String prettyVersion(long version) { - long major = version / 1000000; - long minor = version % 1000000 / 1000; - long release = version % 1000000 % 1000; + private String prettyVersion(final long version) { + final long major = version / 1000000; + final long minor = version % 1000000 / 1000; + final long release = version % 1000000 % 1000; return major + "." + minor + "." + release; } @Override - public void setName(String name) { + public void setName(final String name) { // TODO Auto-generated method stub } @Override - public void setConfigParams(Map params) { + public void setConfigParams(final Map params) { // TODO Auto-generated method stub } @@ -5287,7 +5311,7 @@ public int getRunLevel() { } @Override - public void setRunLevel(int level) { + public void setRunLevel(final int level) { // TODO Auto-generated method stub } @@ -5307,10 +5331,10 @@ private boolean checkCgroups(){ return true; } - public String mapRbdDevice(KVMPhysicalDisk disk){ - KVMStoragePool pool = disk.getPool(); + public String mapRbdDevice(final KVMPhysicalDisk disk){ + final KVMStoragePool pool = disk.getPool(); //Check if rbd image is already mapped - String[] splitPoolImage = disk.getPath().split("/"); + final String[] splitPoolImage = disk.getPath().split("/"); String device = Script.runSimpleBashScript("rbd showmapped | grep \""+splitPoolImage[0]+"[ ]*"+splitPoolImage[1]+"\" | grep -o \"[^ ]*[ ]*$\""); if(device == null) { //If not mapped, map and return mapped device diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java new file mode 100644 index 000000000000..fc039b8d1639 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java @@ -0,0 +1,72 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +package com.cloud.hypervisor.kvm.resource.wrapper; + +import java.util.Hashtable; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.Command; +import com.cloud.agent.api.StopCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; +import com.cloud.resource.RequestWrapper; +import com.cloud.resource.ServerResource; + +public class LibvirtRequestWrapper extends RequestWrapper { + + private static LibvirtRequestWrapper instance; + + static { + instance = new LibvirtRequestWrapper(); + } + + private LibvirtRequestWrapper() { + init(); + } + + @SuppressWarnings("rawtypes") + private void init() { + // LibvirtComputingResource commands + final Hashtable, CommandWrapper> linbvirtCommands = new Hashtable, CommandWrapper>(); + + linbvirtCommands.put(StopCommand.class, new LibvirtStopCommandWrapper()); + resources.put(LibvirtComputingResource.class, linbvirtCommands); + } + + public static LibvirtRequestWrapper getInstance() { + return instance; + } + + @SuppressWarnings({"rawtypes" }) + @Override + public Answer execute(final Command command, final ServerResource serverResource) { + final Class resourceClass = serverResource.getClass(); + + final Hashtable, CommandWrapper> resourceCommands = retrieveResource(command, resourceClass); + + CommandWrapper commandWrapper = retrieveCommands(command.getClass(), resourceCommands); + + while (commandWrapper == null) { + //Could not find the command in the given resource, will traverse the family tree. + commandWrapper = retryWhenAllFails(command, resourceClass, resourceCommands); + } + + return commandWrapper.execute(command, serverResource); + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStopCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStopCommandWrapper.java new file mode 100644 index 000000000000..3e6c6b4adfa8 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStopCommandWrapper.java @@ -0,0 +1,86 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import java.util.List; + +import org.apache.log4j.Logger; +import org.libvirt.Connect; +import org.libvirt.Domain; +import org.libvirt.DomainInfo.DomainState; +import org.libvirt.LibvirtException; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.StopAnswer; +import com.cloud.agent.api.StopCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.hypervisor.kvm.resource.LibvirtConnection; +import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef; +import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef; +import com.cloud.hypervisor.kvm.resource.VifDriver; +import com.cloud.resource.CommandWrapper; + +public final class LibvirtStopCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtStopCommandWrapper.class); + + @Override + public Answer execute(final StopCommand command, final LibvirtComputingResource citrixResourceBase) { + final String vmName = command.getVmName(); + + if (command.checkBeforeCleanup()) { + try { + final Connect conn = LibvirtConnection.getConnectionByVmName(vmName); + final Domain vm = conn.domainLookupByName(command.getVmName()); + if (vm != null && vm.getInfo().state == DomainState.VIR_DOMAIN_RUNNING) { + return new StopAnswer(command, "vm is still running on host", false); + } + } catch (final Exception e) { + s_logger.debug("Failed to get vm status in case of checkboforecleanup is true", e); + } + } + + try { + final Connect conn = LibvirtConnection.getConnectionByVmName(vmName); + + final List disks = citrixResourceBase.getDisks(conn, vmName); + final List ifaces = citrixResourceBase.getInterfaces(conn, vmName); + + citrixResourceBase.destroyNetworkRulesForVM(conn, vmName); + final String result = citrixResourceBase.stopVM(conn, vmName); + if (result == null) { + for (final DiskDef disk : disks) { + citrixResourceBase.cleanupDisk(disk); + } + for (final InterfaceDef iface : ifaces) { + // We don't know which "traffic type" is associated with + // each interface at this point, so inform all vif drivers + for (final VifDriver vifDriver : citrixResourceBase.getAllVifDrivers()) { + vifDriver.unplug(iface); + } + } + } + + return new StopAnswer(command, result, true); + } catch (final LibvirtException e) { + return new StopAnswer(command, e.getMessage(), false); + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index b82796fa6160..881ebc522b11 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -38,6 +38,7 @@ import org.junit.Assert; import org.junit.Assume; import org.junit.Test; +import org.junit.runner.RunWith; import org.libvirt.Connect; import org.libvirt.Domain; import org.libvirt.DomainBlockStats; @@ -46,22 +47,29 @@ import org.libvirt.LibvirtException; import org.libvirt.NodeInfo; import org.mockito.Matchers; +import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; +import org.powermock.modules.junit4.PowerMockRunner; import org.w3c.dom.Document; import org.xml.sax.SAXException; +import com.cloud.agent.api.StopCommand; import com.cloud.agent.api.VmStatsEntry; import com.cloud.agent.api.to.VirtualMachineTO; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef; +import com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper; import com.cloud.template.VirtualMachineTemplate.BootloaderType; import com.cloud.utils.Pair; import com.cloud.vm.VirtualMachine; +@RunWith(PowerMockRunner.class) public class LibvirtComputingResourceTest { + @Mock + private LibvirtComputingResource libvirtComputingResource; + String _hyperVisorType = "kvm"; Random _random = new Random(); @@ -71,28 +79,28 @@ public class LibvirtComputingResourceTest { The overcommit feature has not been merged in there and thus only 'speed' is set. - */ + */ @Test public void testCreateVMFromSpecLegacy() { - int id = _random.nextInt(65534); - String name = "test-instance-1"; + final int id = _random.nextInt(65534); + final String name = "test-instance-1"; - int cpus = _random.nextInt(2) + 1; - int speed = 1024; - int minRam = 256 * 1024; - int maxRam = 512 * 1024; + final int cpus = _random.nextInt(2) + 1; + final int speed = 1024; + final int minRam = 256 * 1024; + final int maxRam = 512 * 1024; - String os = "Ubuntu"; + final String os = "Ubuntu"; - String vncAddr = ""; - String vncPassword = "mySuperSecretPassword"; + final String vncAddr = ""; + final String vncPassword = "mySuperSecretPassword"; - LibvirtComputingResource lcr = new LibvirtComputingResource(); - VirtualMachineTO to = new VirtualMachineTO(id, name, VirtualMachine.Type.User, cpus, speed, minRam, maxRam, BootloaderType.HVM, os, false, false, vncPassword); + final LibvirtComputingResource lcr = new LibvirtComputingResource(); + final VirtualMachineTO to = new VirtualMachineTO(id, name, VirtualMachine.Type.User, cpus, speed, minRam, maxRam, BootloaderType.HVM, os, false, false, vncPassword); to.setVncAddr(vncAddr); to.setUuid("b0f0a72d-7efb-3cad-a8ff-70ebf30b3af9"); - LibvirtVMDef vm = lcr.createVMFromSpec(to); + final LibvirtVMDef vm = lcr.createVMFromSpec(to); vm.setHvsType(_hyperVisorType); verifyVm(to, vm); @@ -100,29 +108,29 @@ public void testCreateVMFromSpecLegacy() { /** This test verifies that CPU topology is properly set for hex-core - */ + */ @Test public void testCreateVMFromSpecWithTopology6() { - int id = _random.nextInt(65534); - String name = "test-instance-1"; + final int id = _random.nextInt(65534); + final String name = "test-instance-1"; - int cpus = 12; - int minSpeed = 1024; - int maxSpeed = 2048; - int minRam = 256 * 1024; - int maxRam = 512 * 1024; + final int cpus = 12; + final int minSpeed = 1024; + final int maxSpeed = 2048; + final int minRam = 256 * 1024; + final int maxRam = 512 * 1024; - String os = "Ubuntu"; + final String os = "Ubuntu"; - String vncAddr = ""; - String vncPassword = "mySuperSecretPassword"; + final String vncAddr = ""; + final String vncPassword = "mySuperSecretPassword"; - LibvirtComputingResource lcr = new LibvirtComputingResource(); - VirtualMachineTO to = new VirtualMachineTO(id, name, VirtualMachine.Type.User, cpus, minSpeed, maxSpeed, minRam, maxRam, BootloaderType.HVM, os, false, false, vncPassword); + final LibvirtComputingResource lcr = new LibvirtComputingResource(); + final VirtualMachineTO to = new VirtualMachineTO(id, name, VirtualMachine.Type.User, cpus, minSpeed, maxSpeed, minRam, maxRam, BootloaderType.HVM, os, false, false, vncPassword); to.setVncAddr(vncAddr); to.setUuid("b0f0a72d-7efb-3cad-a8ff-70ebf30b3af9"); - LibvirtVMDef vm = lcr.createVMFromSpec(to); + final LibvirtVMDef vm = lcr.createVMFromSpec(to); vm.setHvsType(_hyperVisorType); verifyVm(to, vm); @@ -130,29 +138,29 @@ public void testCreateVMFromSpecWithTopology6() { /** This test verifies that CPU topology is properly set for quad-core - */ + */ @Test public void testCreateVMFromSpecWithTopology4() { - int id = _random.nextInt(65534); - String name = "test-instance-1"; + final int id = _random.nextInt(65534); + final String name = "test-instance-1"; - int cpus = 8; - int minSpeed = 1024; - int maxSpeed = 2048; - int minRam = 256 * 1024; - int maxRam = 512 * 1024; + final int cpus = 8; + final int minSpeed = 1024; + final int maxSpeed = 2048; + final int minRam = 256 * 1024; + final int maxRam = 512 * 1024; - String os = "Ubuntu"; + final String os = "Ubuntu"; - String vncAddr = ""; - String vncPassword = "mySuperSecretPassword"; + final String vncAddr = ""; + final String vncPassword = "mySuperSecretPassword"; - LibvirtComputingResource lcr = new LibvirtComputingResource(); - VirtualMachineTO to = new VirtualMachineTO(id, name, VirtualMachine.Type.User, cpus, minSpeed, maxSpeed, minRam, maxRam, BootloaderType.HVM, os, false, false, vncPassword); + final LibvirtComputingResource lcr = new LibvirtComputingResource(); + final VirtualMachineTO to = new VirtualMachineTO(id, name, VirtualMachine.Type.User, cpus, minSpeed, maxSpeed, minRam, maxRam, BootloaderType.HVM, os, false, false, vncPassword); to.setVncAddr(vncAddr); to.setUuid("b0f0a72d-7efb-3cad-a8ff-70ebf30b3af9"); - LibvirtVMDef vm = lcr.createVMFromSpec(to); + final LibvirtVMDef vm = lcr.createVMFromSpec(to); vm.setHvsType(_hyperVisorType); verifyVm(to, vm); @@ -164,37 +172,37 @@ public void testCreateVMFromSpecWithTopology4() { It tests if the Agent can handle a vmSpec with overcommit data like minSpeed and maxSpeed in there - */ + */ @Test public void testCreateVMFromSpec() { - int id = _random.nextInt(65534); - String name = "test-instance-1"; + final int id = _random.nextInt(65534); + final String name = "test-instance-1"; - int cpus = _random.nextInt(2) + 1; - int minSpeed = 1024; - int maxSpeed = 2048; - int minRam = 256 * 1024; - int maxRam = 512 * 1024; + final int cpus = _random.nextInt(2) + 1; + final int minSpeed = 1024; + final int maxSpeed = 2048; + final int minRam = 256 * 1024; + final int maxRam = 512 * 1024; - String os = "Ubuntu"; + final String os = "Ubuntu"; - String vncAddr = ""; - String vncPassword = "mySuperSecretPassword"; + final String vncAddr = ""; + final String vncPassword = "mySuperSecretPassword"; - LibvirtComputingResource lcr = new LibvirtComputingResource(); - VirtualMachineTO to = - new VirtualMachineTO(id, name, VirtualMachine.Type.User, cpus, minSpeed, maxSpeed, minRam, maxRam, BootloaderType.HVM, os, false, false, vncPassword); + final LibvirtComputingResource lcr = new LibvirtComputingResource(); + final VirtualMachineTO to = + new VirtualMachineTO(id, name, VirtualMachine.Type.User, cpus, minSpeed, maxSpeed, minRam, maxRam, BootloaderType.HVM, os, false, false, vncPassword); to.setVncAddr(vncAddr); to.setUuid("b0f0a72d-7efb-3cad-a8ff-70ebf30b3af9"); - LibvirtVMDef vm = lcr.createVMFromSpec(to); + final LibvirtVMDef vm = lcr.createVMFromSpec(to); vm.setHvsType(_hyperVisorType); verifyVm(to, vm); } - private void verifyVm(VirtualMachineTO to, LibvirtVMDef vm) { - Document domainDoc = parse(vm.toString()); + private void verifyVm(final VirtualMachineTO to, final LibvirtVMDef vm) { + final Document domainDoc = parse(vm.toString()); assertXpath(domainDoc, "/domain/@type", vm.getHvsType()); assertXpath(domainDoc, "/domain/name/text()", to.getName()); assertXpath(domainDoc, "/domain/uuid/text()", to.getUuid()); @@ -246,7 +254,7 @@ static void assertNodeExists(final Document doc, final String xPathExpr) { try { Assert.assertNotNull(XPathFactory.newInstance().newXPath() .evaluate(xPathExpr, doc, XPathConstants.NODE)); - } catch (XPathExpressionException e) { + } catch (final XPathExpressionException e) { Assert.fail(e.getMessage()); } } @@ -256,7 +264,7 @@ static void assertXpath(final Document doc, final String xPathExpr, try { Assert.assertEquals(expected, XPathFactory.newInstance().newXPath() .evaluate(xPathExpr, doc)); - } catch (XPathExpressionException e) { + } catch (final XPathExpressionException e) { Assert.fail("Could not evaluate xpath" + xPathExpr + ":" + e.getMessage()); } @@ -267,18 +275,18 @@ public void testGetNicStats() { //this test is only working on linux because of the loopback interface name //also the tested code seems to work only on linux Assume.assumeTrue(SystemUtils.IS_OS_LINUX); - Pair stats = LibvirtComputingResource.getNicStats("lo"); + final Pair stats = LibvirtComputingResource.getNicStats("lo"); assertNotNull(stats); } @Test public void testUUID() { String uuid = "1"; - LibvirtComputingResource lcr = new LibvirtComputingResource(); + final LibvirtComputingResource lcr = new LibvirtComputingResource(); uuid = lcr.getUuid(uuid); Assert.assertTrue(!uuid.equals("1")); - String oldUuid = UUID.randomUUID().toString(); + final String oldUuid = UUID.randomUUID().toString(); uuid = oldUuid; uuid = lcr.getUuid(uuid); Assert.assertTrue(uuid.equals(oldUuid)); @@ -288,12 +296,12 @@ public void testUUID() { @Test public void testGetVmStat() throws LibvirtException { - Connect connect = Mockito.mock(Connect.class); - Domain domain = Mockito.mock(Domain.class); - DomainInfo domainInfo = new DomainInfo(); + final Connect connect = Mockito.mock(Connect.class); + final Domain domain = Mockito.mock(Domain.class); + final DomainInfo domainInfo = new DomainInfo(); Mockito.when(domain.getInfo()).thenReturn(domainInfo); Mockito.when(connect.domainLookupByName(VMNAME)).thenReturn(domain); - NodeInfo nodeInfo = new NodeInfo(); + final NodeInfo nodeInfo = new NodeInfo(); nodeInfo.cpus = 8; nodeInfo.memory = 8 * 1024 * 1024; nodeInfo.sockets = 2; @@ -301,24 +309,24 @@ public void testGetVmStat() throws LibvirtException { nodeInfo.model = "Foo processor"; Mockito.when(connect.nodeInfo()).thenReturn(nodeInfo); // this is testing the interface stats, returns an increasing number of sent and received bytes - Mockito.when(domain.interfaceStats(Matchers.anyString())).thenAnswer(new Answer() { + Mockito.when(domain.interfaceStats(Matchers.anyString())).thenAnswer(new org.mockito.stubbing.Answer() { // increment with less than a KB, so this should be less than 1 KB final static int increment = 1000; int rxBytes = 1000; int txBytes = 1000; @Override - public DomainInterfaceStats answer(InvocationOnMock invocation) throws Throwable { - DomainInterfaceStats domainInterfaceStats = new DomainInterfaceStats(); - domainInterfaceStats.rx_bytes = (rxBytes += increment); - domainInterfaceStats.tx_bytes = (txBytes += increment); + public DomainInterfaceStats answer(final InvocationOnMock invocation) throws Throwable { + final DomainInterfaceStats domainInterfaceStats = new DomainInterfaceStats(); + domainInterfaceStats.rx_bytes = rxBytes += increment; + domainInterfaceStats.tx_bytes = txBytes += increment; return domainInterfaceStats; } }); - Mockito.when(domain.blockStats(Matchers.anyString())).thenAnswer(new Answer() { + Mockito.when(domain.blockStats(Matchers.anyString())).thenAnswer(new org.mockito.stubbing.Answer() { // a little less than a KB final static int increment = 1000; @@ -326,32 +334,32 @@ public DomainInterfaceStats answer(InvocationOnMock invocation) throws Throwable int wrBytes = 1024; @Override - public DomainBlockStats answer(InvocationOnMock invocation) throws Throwable { - DomainBlockStats domainBlockStats = new DomainBlockStats(); + public DomainBlockStats answer(final InvocationOnMock invocation) throws Throwable { + final DomainBlockStats domainBlockStats = new DomainBlockStats(); - domainBlockStats.rd_bytes = (rdBytes += increment); - domainBlockStats.wr_bytes = (wrBytes += increment); + domainBlockStats.rd_bytes = rdBytes += increment; + domainBlockStats.wr_bytes = wrBytes += increment; return domainBlockStats; } }); - LibvirtComputingResource libvirtComputingResource = new LibvirtComputingResource() { + final LibvirtComputingResource libvirtComputingResource = new LibvirtComputingResource() { @Override - protected List getInterfaces(Connect conn, String vmName) { - InterfaceDef interfaceDef = new InterfaceDef(); + public List getInterfaces(final Connect conn, final String vmName) { + final InterfaceDef interfaceDef = new InterfaceDef(); return Arrays.asList(interfaceDef); } @Override - public List getDisks(Connect conn, String vmName) { - DiskDef diskDef = new DiskDef(); + public List getDisks(final Connect conn, final String vmName) { + final DiskDef diskDef = new DiskDef(); return Arrays.asList(diskDef); } }; libvirtComputingResource.getVmStat(connect, VMNAME); - VmStatsEntry vmStat = libvirtComputingResource.getVmStat(connect, VMNAME); + final VmStatsEntry vmStat = libvirtComputingResource.getVmStat(connect, VMNAME); // network traffic as generated by the logic above, must be greater than zero Assert.assertTrue(vmStat.getNetworkReadKBs() > 0); Assert.assertTrue(vmStat.getNetworkWriteKBs() > 0); @@ -363,7 +371,24 @@ public List getDisks(Connect conn, String vmName) { @Test public void getCpuSpeed() { Assume.assumeTrue(SystemUtils.IS_OS_LINUX); - NodeInfo nodeInfo = Mockito.mock(NodeInfo.class); + final NodeInfo nodeInfo = Mockito.mock(NodeInfo.class); LibvirtComputingResource.getCpuSpeed(nodeInfo); } -} + + /* + * New Tests + */ + + @Test(expected = UnsatisfiedLinkError.class) + public void testStopCommand() { + // We cannot do much here due to the Native libraries and Static methods used by the LibvirtConnection we need + // a better way to mock stuff! + final String vmName = "Test"; + final StopCommand stopCommand = new StopCommand(vmName, false, false); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + wrapper.execute(stopCommand, libvirtComputingResource); + } +} \ No newline at end of file diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapper.java index 4537b2a4cfe4..02f377428a29 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapper.java @@ -107,12 +107,7 @@ public class CitrixRequestWrapper extends RequestWrapper { instance = new CitrixRequestWrapper(); } - @SuppressWarnings("rawtypes") - private final Hashtable, Hashtable, CommandWrapper>> resources; - - @SuppressWarnings("rawtypes") private CitrixRequestWrapper() { - resources = new Hashtable, Hashtable, CommandWrapper>>(); init(); } @@ -232,73 +227,4 @@ public Answer execute(final Command command, final ServerResource serverResource return commandWrapper.execute(command, serverResource); } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - protected Hashtable, CommandWrapper> retrieveResource(final Command command, final Class resourceClass) { - Class keepResourceClass = resourceClass; - Hashtable, CommandWrapper> resource = resources.get(keepResourceClass); - while (resource == null) { - try { - final Class keepResourceClass2 = (Class) keepResourceClass.getSuperclass(); - resource = resources.get(keepResourceClass2); - - keepResourceClass = keepResourceClass2; - } catch (final ClassCastException e) { - throw new NullPointerException("No key found for '" + command.getClass() + "' in the Map!"); - } - } - return resource; - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - protected CommandWrapper retrieveCommands(final Class commandClass, - final Hashtable, CommandWrapper> resourceCommands) { - - Class keepCommandClass = commandClass; - CommandWrapper commandWrapper = resourceCommands.get(keepCommandClass); - while (commandWrapper == null) { - try { - final Class commandClass2 = (Class) keepCommandClass.getSuperclass(); - - if (commandClass2 == null) { - throw new NullPointerException("All the COMMAND hierarchy tree has been visited but no compliant key has been found for '" + commandClass +"'."); - } - - commandWrapper = resourceCommands.get(commandClass2); - - keepCommandClass = commandClass2; - } catch (final NullPointerException e) { - // Will now traverse all the resource hierarchy. Returning null is not a problem. - // It is all being nicely checked and in case we do not have a resource, an Unsupported answer will be thrown by the base class. - return null; - } - } - return commandWrapper; - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - protected CommandWrapper retryWhenAllFails(final Command command, final Class resourceClass, - final Hashtable, CommandWrapper> resourceCommands) { - - Class keepResourceClass = resourceClass; - CommandWrapper commandWrapper = resourceCommands.get(command.getClass()); - while (commandWrapper == null) { - //Could not find the command in the given resource, will traverse the family tree. - try { - final Class resourceClass2 = (Class) keepResourceClass.getSuperclass(); - - if (resourceClass2 == null) { - throw new NullPointerException("All the SERVER-RESOURCE hierarchy tree has been visited but no compliant key has been found for '" + command.getClass() +"'."); - } - - final Hashtable, CommandWrapper> resourceCommands2 = retrieveResource(command, (Class) keepResourceClass.getSuperclass()); - keepResourceClass = resourceClass2; - - commandWrapper = retrieveCommands(command.getClass(), resourceCommands2); - } catch (final NullPointerException e) { - throw e; - } - } - return commandWrapper; - } } \ No newline at end of file diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapperTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapperTest.java index 060d3b5d13fb..28fc3708d614 100644 --- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapperTest.java +++ b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapperTest.java @@ -42,7 +42,6 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; import com.cloud.agent.api.Answer; @@ -136,7 +135,6 @@ import com.xensource.xenapi.Types.XenAPIException; @RunWith(PowerMockRunner.class) -@PrepareForTest({ Connection.class, Host.Record.class }) public class CitrixRequestWrapperTest { @Mock @@ -279,7 +277,7 @@ public void testCheckHealthCommand() { } @Test - public void testStopCommandCommand() { + public void testStopCommand() { final StopCommand stopCommand = new StopCommand("Test", false, false); final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance(); From 7086d64387fd0fb6381e4dbb63d46361d619b948 Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Wed, 22 Apr 2015 14:53:28 +0200 Subject: [PATCH 002/175] Refactoring the LibvirtComputingResource - Adding LibvirtGetVmStatsCommandWrapper - 3 unit tests Refactored the LibvirtConnectiobn by surrounding it with an wrapper. - Make it easier to cover the static/native calls - Added better coverage to StopCommand tests --- .../spring-kvm-compute-context.xml | 3 + .../resource/LibvirtComputingResource.java | 15 ++- .../wrapper/LibvirtConnectionWrapper.java | 33 ++++++ .../LibvirtGetVmStatsCommandWrapper.java | 63 +++++++++++ .../wrapper/LibvirtRequestWrapper.java | 2 + .../wrapper/LibvirtStopCommandWrapper.java | 21 ++-- .../LibvirtComputingResourceTest.java | 106 +++++++++++++++++- 7 files changed, 227 insertions(+), 16 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConnectionWrapper.java create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmStatsCommandWrapper.java diff --git a/plugins/hypervisors/kvm/resources/META-INF/cloudstack/kvm-compute/spring-kvm-compute-context.xml b/plugins/hypervisors/kvm/resources/META-INF/cloudstack/kvm-compute/spring-kvm-compute-context.xml index ce596f22bbf1..de6853e3b9d8 100644 --- a/plugins/hypervisors/kvm/resources/META-INF/cloudstack/kvm-compute/spring-kvm-compute-context.xml +++ b/plugins/hypervisors/kvm/resources/META-INF/cloudstack/kvm-compute/spring-kvm-compute-context.xml @@ -31,4 +31,7 @@ + + diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 892e9063688f..5969df355735 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -59,6 +59,7 @@ import java.util.regex.Pattern; import javax.ejb.Local; +import javax.inject.Inject; import javax.naming.ConfigurationException; import org.apache.cloudstack.storage.command.StorageSubSystemCommand; @@ -230,6 +231,7 @@ import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.TermPolicy; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.VideoDef; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.VirtioSerialDef; +import com.cloud.hypervisor.kvm.resource.wrapper.LibvirtConnectionWrapper; import com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper; import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk; import com.cloud.hypervisor.kvm.storage.KVMStoragePool; @@ -332,6 +334,9 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv protected static final String DEFAULT_OVS_VIF_DRIVER_CLASS_NAME = "com.cloud.hypervisor.kvm.resource.OvsVifDriver"; protected static final String DEFAULT_BRIDGE_VIF_DRIVER_CLASS_NAME = "com.cloud.hypervisor.kvm.resource.BridgeVifDriver"; + @Inject + private LibvirtConnectionWrapper libvirtConnectionWrapper; + @Override public ExecutionResult executeInVR(final String routerIp, final String script, final String args) { return executeInVR(routerIp, script, args, _timeout / 1000); @@ -393,6 +398,10 @@ public ExecutionResult cleanupCommand(final NetworkElementCommand cmd) { return new ExecutionResult(true, null); } + public LibvirtConnectionWrapper getLibvirtConnectionWrapper() { + return libvirtConnectionWrapper; + } + private static final class KeyValueInterpreter extends OutputInterpreter { private final Map map = new HashMap(); @@ -915,7 +924,7 @@ public boolean configure(final String name, final Map params) th } s_logger.debug("Found pif: " + _pifs.get("private") + " on " + _privBridgeName + ", pif: " + _pifs.get("public") + " on " + _publicBridgeName); - _canBridgeFirewall = can_bridge_firewall(_pifs.get("public")); + _canBridgeFirewall = canBridgeFirewall(_pifs.get("public")); _localGateway = Script.runSimpleBashScript("ip route |grep default|awk '{print $3}'"); if (_localGateway == null) { @@ -4917,7 +4926,7 @@ private class VmStats { Calendar _timestamp; } - VmStatsEntry getVmStat(final Connect conn, final String vmName) throws LibvirtException { + public VmStatsEntry getVmStat(final Connect conn, final String vmName) throws LibvirtException { Domain dm = null; try { dm = getDomain(conn, vmName); @@ -5020,7 +5029,7 @@ VmStatsEntry getVmStat(final Connect conn, final String vmName) throws LibvirtEx } } - private boolean can_bridge_firewall(final String prvNic) { + private boolean canBridgeFirewall(final String prvNic) { final Script cmd = new Script(_securityGroupPath, _timeout, s_logger); cmd.add("can_bridge_firewall"); cmd.add(prvNic); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConnectionWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConnectionWrapper.java new file mode 100644 index 000000000000..40643c13b203 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConnectionWrapper.java @@ -0,0 +1,33 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package com.cloud.hypervisor.kvm.resource.wrapper; + +import org.libvirt.Connect; +import org.libvirt.LibvirtException; + +import com.cloud.hypervisor.kvm.resource.LibvirtConnection; + +/** + * This class is used to wrapp the calls to LibvirtConnection and ease the burden of the unit tests. + * Please do not instantiate this class directly, but inject it using the {@code @Inject} annotation. + */ +public class LibvirtConnectionWrapper { + + public Connect getConnectionByName(final String vmName) throws LibvirtException { + return LibvirtConnection.getConnectionByVmName(vmName); + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmStatsCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmStatsCommandWrapper.java new file mode 100644 index 000000000000..d894243fa8ac --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmStatsCommandWrapper.java @@ -0,0 +1,63 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import java.util.HashMap; +import java.util.List; + +import org.apache.log4j.Logger; +import org.libvirt.Connect; +import org.libvirt.LibvirtException; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.GetVmStatsAnswer; +import com.cloud.agent.api.GetVmStatsCommand; +import com.cloud.agent.api.VmStatsEntry; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; + +public final class LibvirtGetVmStatsCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtGetVmStatsCommandWrapper.class); + + @Override + public Answer execute(final GetVmStatsCommand command, final LibvirtComputingResource libvirtComputingResource) { + final List vmNames = command.getVmNames(); + try { + final HashMap vmStatsNameMap = new HashMap(); + for (final String vmName : vmNames) { + + final LibvirtConnectionWrapper libvirtConnectionWrapper = libvirtComputingResource.getLibvirtConnectionWrapper(); + + final Connect conn = libvirtConnectionWrapper.getConnectionByName(vmName); + final VmStatsEntry statEntry = libvirtComputingResource.getVmStat(conn, vmName); + if (statEntry == null) { + continue; + } + + vmStatsNameMap.put(vmName, statEntry); + } + return new GetVmStatsAnswer(command, vmStatsNameMap); + } catch (final LibvirtException e) { + s_logger.debug("Can't get vm stats: " + e.toString()); + return new GetVmStatsAnswer(command, null); + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java index fc039b8d1639..26dc305e68d1 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java @@ -22,6 +22,7 @@ import com.cloud.agent.api.Answer; import com.cloud.agent.api.Command; +import com.cloud.agent.api.GetVmStatsCommand; import com.cloud.agent.api.StopCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; @@ -46,6 +47,7 @@ private void init() { final Hashtable, CommandWrapper> linbvirtCommands = new Hashtable, CommandWrapper>(); linbvirtCommands.put(StopCommand.class, new LibvirtStopCommandWrapper()); + linbvirtCommands.put(GetVmStatsCommand.class, new LibvirtGetVmStatsCommandWrapper()); resources.put(LibvirtComputingResource.class, linbvirtCommands); } diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStopCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStopCommandWrapper.java index 3e6c6b4adfa8..c5d6a5bd56e9 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStopCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStopCommandWrapper.java @@ -31,7 +31,6 @@ import com.cloud.agent.api.StopAnswer; import com.cloud.agent.api.StopCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; -import com.cloud.hypervisor.kvm.resource.LibvirtConnection; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef; import com.cloud.hypervisor.kvm.resource.VifDriver; @@ -42,12 +41,14 @@ public final class LibvirtStopCommandWrapper extends CommandWrapper disks = citrixResourceBase.getDisks(conn, vmName); - final List ifaces = citrixResourceBase.getInterfaces(conn, vmName); + final List disks = libvirtComputingResource.getDisks(conn, vmName); + final List ifaces = libvirtComputingResource.getInterfaces(conn, vmName); - citrixResourceBase.destroyNetworkRulesForVM(conn, vmName); - final String result = citrixResourceBase.stopVM(conn, vmName); + libvirtComputingResource.destroyNetworkRulesForVM(conn, vmName); + final String result = libvirtComputingResource.stopVM(conn, vmName); if (result == null) { for (final DiskDef disk : disks) { - citrixResourceBase.cleanupDisk(disk); + libvirtComputingResource.cleanupDisk(disk); } for (final InterfaceDef iface : ifaces) { // We don't know which "traffic type" is associated with // each interface at this point, so inform all vif drivers - for (final VifDriver vifDriver : citrixResourceBase.getAllVifDrivers()) { + for (final VifDriver vifDriver : libvirtComputingResource.getAllVifDrivers()) { vifDriver.unplug(iface); } } diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index 881ebc522b11..0d8c3f509f0f 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -20,9 +20,15 @@ package com.cloud.hypervisor.kvm.resource; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import java.io.ByteArrayInputStream; import java.io.IOException; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Random; @@ -54,11 +60,14 @@ import org.w3c.dom.Document; import org.xml.sax.SAXException; +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.GetVmStatsCommand; import com.cloud.agent.api.StopCommand; import com.cloud.agent.api.VmStatsEntry; import com.cloud.agent.api.to.VirtualMachineTO; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef; +import com.cloud.hypervisor.kvm.resource.wrapper.LibvirtConnectionWrapper; import com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper; import com.cloud.template.VirtualMachineTemplate.BootloaderType; import com.cloud.utils.Pair; @@ -379,16 +388,107 @@ public void getCpuSpeed() { * New Tests */ - @Test(expected = UnsatisfiedLinkError.class) - public void testStopCommand() { + @Test + public void testStopCommandNoCheck() { // We cannot do much here due to the Native libraries and Static methods used by the LibvirtConnection we need // a better way to mock stuff! + + final Connect conn = Mockito.mock(Connect.class); + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final String vmName = "Test"; final StopCommand stopCommand = new StopCommand(vmName, false, false); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + try { + when(libvirtConnectionWrapper.getConnectionByName(vmName)).thenReturn(conn); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); assertNotNull(wrapper); - wrapper.execute(stopCommand, libvirtComputingResource); + final Answer answer = wrapper.execute(stopCommand, libvirtComputingResource); + + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByName(vmName); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + + @Test + public void testStopCommandCheck() { + // We cannot do much here due to the Native libraries and Static methods used by the LibvirtConnection we need + // a better way to mock stuff! + + final Connect conn = Mockito.mock(Connect.class); + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final Domain domain = Mockito.mock(Domain.class); + + final String vmName = "Test"; + final StopCommand stopCommand = new StopCommand(vmName, false, true); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + try { + when(libvirtConnectionWrapper.getConnectionByName(vmName)).thenReturn(conn); + when(conn.domainLookupByName(stopCommand.getVmName())).thenReturn(domain); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(stopCommand, libvirtComputingResource); + + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(2)).getConnectionByName(vmName); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + + @Test + public void testGetVmStatsCommand() { + // We cannot do much here due to the Native libraries and Static methods used by the LibvirtConnection we need + // a better way to mock stuff! + + final Connect conn = Mockito.mock(Connect.class); + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + + final String vmName = "Test"; + final String uuid = "e8d6b4d0-bc6d-4613-b8bb-cb9e0600f3c6"; + final List vms = new ArrayList(); + vms.add(vmName); + + final GetVmStatsCommand stopCommand = new GetVmStatsCommand(vms, uuid, "hostname"); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + try { + when(libvirtConnectionWrapper.getConnectionByName(vmName)).thenReturn(conn); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(stopCommand, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByName(vmName); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } } } \ No newline at end of file From 51093afcf11ef37b3d54c5430b955e87e17d2be2 Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Wed, 22 Apr 2015 15:05:59 +0200 Subject: [PATCH 003/175] Refactoring the LibvirtComputingResource - Adding LibvirtGetVmDiskStatsCommandWrapper - 1 unit test Added getConnection() to LibvirtConnectionWrapper --- .../resource/LibvirtComputingResource.java | 96 +------------------ .../wrapper/LibvirtConnectionWrapper.java | 6 +- .../LibvirtGetVmDiskStatsCommandWrapper.java | 62 ++++++++++++ .../wrapper/LibvirtRequestWrapper.java | 2 + .../LibvirtComputingResourceTest.java | 37 +++++++ 5 files changed, 108 insertions(+), 95 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmDiskStatsCommandWrapper.java diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 5969df355735..82ea791333d2 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -117,10 +117,6 @@ import com.cloud.agent.api.GetHostStatsCommand; import com.cloud.agent.api.GetStorageStatsAnswer; import com.cloud.agent.api.GetStorageStatsCommand; -import com.cloud.agent.api.GetVmDiskStatsAnswer; -import com.cloud.agent.api.GetVmDiskStatsCommand; -import com.cloud.agent.api.GetVmStatsAnswer; -import com.cloud.agent.api.GetVmStatsCommand; import com.cloud.agent.api.GetVncPortAnswer; import com.cloud.agent.api.GetVncPortCommand; import com.cloud.agent.api.HostStatsEntry; @@ -169,8 +165,6 @@ import com.cloud.agent.api.StartupCommand; import com.cloud.agent.api.StartupRoutingCommand; import com.cloud.agent.api.StartupStorageCommand; -import com.cloud.agent.api.StopAnswer; -import com.cloud.agent.api.StopCommand; import com.cloud.agent.api.UnPlugNicAnswer; import com.cloud.agent.api.UnPlugNicCommand; import com.cloud.agent.api.UpgradeSnapshotCommand; @@ -1304,11 +1298,7 @@ public Answer executeRequest(final Command cmd) { } try { - if (cmd instanceof GetVmStatsCommand) { - return execute((GetVmStatsCommand)cmd); - } else if (cmd instanceof GetVmDiskStatsCommand) { - return execute((GetVmDiskStatsCommand)cmd); - } else if (cmd instanceof RebootRouterCommand) { + if (cmd instanceof RebootRouterCommand) { return execute((RebootRouterCommand)cmd); } else if (cmd instanceof RebootCommand) { return execute((RebootCommand)cmd); @@ -3460,88 +3450,6 @@ protected Answer execute(final RebootRouterCommand cmd) { } } - protected GetVmDiskStatsAnswer execute(final GetVmDiskStatsCommand cmd) { - final List vmNames = cmd.getVmNames(); - try { - final HashMap> vmDiskStatsNameMap = new HashMap>(); - final Connect conn = LibvirtConnection.getConnection(); - for (final String vmName : vmNames) { - final List statEntry = getVmDiskStat(conn, vmName); - if (statEntry == null) { - continue; - } - - vmDiskStatsNameMap.put(vmName, statEntry); - } - return new GetVmDiskStatsAnswer(cmd, "", cmd.getHostName(), vmDiskStatsNameMap); - } catch (final LibvirtException e) { - s_logger.debug("Can't get vm disk stats: " + e.toString()); - return new GetVmDiskStatsAnswer(cmd, null, null, null); - } - } - - protected GetVmStatsAnswer execute(final GetVmStatsCommand cmd) { - final List vmNames = cmd.getVmNames(); - try { - final HashMap vmStatsNameMap = new HashMap(); - for (final String vmName : vmNames) { - final Connect conn = LibvirtConnection.getConnectionByVmName(vmName); - final VmStatsEntry statEntry = getVmStat(conn, vmName); - if (statEntry == null) { - continue; - } - - vmStatsNameMap.put(vmName, statEntry); - } - return new GetVmStatsAnswer(cmd, vmStatsNameMap); - } catch (final LibvirtException e) { - s_logger.debug("Can't get vm stats: " + e.toString()); - return new GetVmStatsAnswer(cmd, null); - } - } - - protected Answer execute(final StopCommand cmd) { - final String vmName = cmd.getVmName(); - - if (cmd.checkBeforeCleanup()) { - try { - final Connect conn = LibvirtConnection.getConnectionByVmName(vmName); - final Domain vm = conn.domainLookupByName(cmd.getVmName()); - if (vm != null && vm.getInfo().state == DomainState.VIR_DOMAIN_RUNNING) { - return new StopAnswer(cmd, "vm is still running on host", false); - } - } catch (final Exception e) { - s_logger.debug("Failed to get vm status in case of checkboforecleanup is true", e); - } - } - - try { - final Connect conn = LibvirtConnection.getConnectionByVmName(vmName); - - final List disks = getDisks(conn, vmName); - final List ifaces = getInterfaces(conn, vmName); - - destroyNetworkRulesForVM(conn, vmName); - final String result = stopVM(conn, vmName); - if (result == null) { - for (final DiskDef disk : disks) { - cleanupDisk(disk); - } - for (final InterfaceDef iface : ifaces) { - // We don't know which "traffic type" is associated with - // each interface at this point, so inform all vif drivers - for (final VifDriver vifDriver : getAllVifDrivers()) { - vifDriver.unplug(iface); - } - } - } - - return new StopAnswer(cmd, result, true); - } catch (final LibvirtException e) { - return new StopAnswer(cmd, e.getMessage(), false); - } - } - protected Answer execute(final ModifySshKeysCommand cmd) { final File sshKeysDir = new File(SSHKEYSPATH); String result = null; @@ -4881,7 +4789,7 @@ private String executeBashScript(final String script) { return command.execute(); } - private List getVmDiskStat(final Connect conn, final String vmName) throws LibvirtException { + public List getVmDiskStat(final Connect conn, final String vmName) throws LibvirtException { Domain dm = null; try { dm = getDomain(conn, vmName); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConnectionWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConnectionWrapper.java index 40643c13b203..0a6b966d61af 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConnectionWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConnectionWrapper.java @@ -22,7 +22,7 @@ import com.cloud.hypervisor.kvm.resource.LibvirtConnection; /** - * This class is used to wrapp the calls to LibvirtConnection and ease the burden of the unit tests. + * This class is used to wrap the calls to LibvirtConnection and ease the burden of the unit tests. * Please do not instantiate this class directly, but inject it using the {@code @Inject} annotation. */ public class LibvirtConnectionWrapper { @@ -30,4 +30,8 @@ public class LibvirtConnectionWrapper { public Connect getConnectionByName(final String vmName) throws LibvirtException { return LibvirtConnection.getConnectionByVmName(vmName); } + + public Connect getConnection() throws LibvirtException { + return LibvirtConnection.getConnection(); + } } \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmDiskStatsCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmDiskStatsCommandWrapper.java new file mode 100644 index 000000000000..32ff7dfc9e2f --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmDiskStatsCommandWrapper.java @@ -0,0 +1,62 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import java.util.HashMap; +import java.util.List; + +import org.apache.log4j.Logger; +import org.libvirt.Connect; +import org.libvirt.LibvirtException; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.GetVmDiskStatsAnswer; +import com.cloud.agent.api.GetVmDiskStatsCommand; +import com.cloud.agent.api.VmDiskStatsEntry; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; + +public final class LibvirtGetVmDiskStatsCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtGetVmDiskStatsCommandWrapper.class); + + @Override + public Answer execute(final GetVmDiskStatsCommand command, final LibvirtComputingResource libvirtComputingResource) { + final List vmNames = command.getVmNames(); + final LibvirtConnectionWrapper libvirtConnectionWrapper = libvirtComputingResource.getLibvirtConnectionWrapper(); + + try { + final HashMap> vmDiskStatsNameMap = new HashMap>(); + final Connect conn = libvirtConnectionWrapper.getConnection(); + for (final String vmName : vmNames) { + final List statEntry = libvirtComputingResource.getVmDiskStat(conn, vmName); + if (statEntry == null) { + continue; + } + + vmDiskStatsNameMap.put(vmName, statEntry); + } + return new GetVmDiskStatsAnswer(command, "", command.getHostName(), vmDiskStatsNameMap); + } catch (final LibvirtException e) { + s_logger.debug("Can't get vm disk stats: " + e.toString()); + return new GetVmDiskStatsAnswer(command, null, null, null); + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java index 26dc305e68d1..c74a09797fed 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java @@ -22,6 +22,7 @@ import com.cloud.agent.api.Answer; import com.cloud.agent.api.Command; +import com.cloud.agent.api.GetVmDiskStatsCommand; import com.cloud.agent.api.GetVmStatsCommand; import com.cloud.agent.api.StopCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; @@ -48,6 +49,7 @@ private void init() { linbvirtCommands.put(StopCommand.class, new LibvirtStopCommandWrapper()); linbvirtCommands.put(GetVmStatsCommand.class, new LibvirtGetVmStatsCommandWrapper()); + linbvirtCommands.put(GetVmDiskStatsCommand.class, new LibvirtGetVmDiskStatsCommandWrapper()); resources.put(LibvirtComputingResource.class, linbvirtCommands); } diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index 0d8c3f509f0f..cd1255631ced 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -61,6 +61,7 @@ import org.xml.sax.SAXException; import com.cloud.agent.api.Answer; +import com.cloud.agent.api.GetVmDiskStatsCommand; import com.cloud.agent.api.GetVmStatsCommand; import com.cloud.agent.api.StopCommand; import com.cloud.agent.api.VmStatsEntry; @@ -491,4 +492,40 @@ public void testGetVmStatsCommand() { fail(e.getMessage()); } } + + @Test + public void testGetVmDiskStatsCommand() { + // We cannot do much here due to the Native libraries and Static methods used by the LibvirtConnection we need + // a better way to mock stuff! + + final Connect conn = Mockito.mock(Connect.class); + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + + final String vmName = "Test"; + final String uuid = "e8d6b4d0-bc6d-4613-b8bb-cb9e0600f3c6"; + final List vms = new ArrayList(); + vms.add(vmName); + + final GetVmDiskStatsCommand stopCommand = new GetVmDiskStatsCommand(vms, uuid, "hostname"); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + try { + when(libvirtConnectionWrapper.getConnection()).thenReturn(conn); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(stopCommand, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnection(); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } } \ No newline at end of file From 7a90c018fbba0419c55c245aa1cb3488472d2a62 Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Wed, 22 Apr 2015 16:06:43 +0200 Subject: [PATCH 004/175] Refactoring the LibvirtComputingResource - Adding LibvirtRebootCommandWrapper and LibVirtRebootRouterCommandWrapper - 2 unit tests added - KVM hypervisor with 10.5% coverage --- .../resource/LibvirtComputingResource.java | 55 ++-------- .../wrapper/LibvirtConnectionWrapper.java | 2 +- .../LibvirtGetVmStatsCommandWrapper.java | 2 +- .../wrapper/LibvirtRebootCommandWrapper.java | 59 ++++++++++ .../LibvirtRebootRouterCommandWrapper.java | 47 ++++++++ .../wrapper/LibvirtRequestWrapper.java | 4 + .../wrapper/LibvirtStopCommandWrapper.java | 4 +- .../LibvirtComputingResourceTest.java | 102 +++++++++++++++--- 8 files changed, 211 insertions(+), 64 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRebootCommandWrapper.java create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRebootRouterCommandWrapper.java diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 82ea791333d2..a559e9965c76 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -154,9 +154,6 @@ import com.cloud.agent.api.PvlanSetupCommand; import com.cloud.agent.api.ReadyAnswer; import com.cloud.agent.api.ReadyCommand; -import com.cloud.agent.api.RebootAnswer; -import com.cloud.agent.api.RebootCommand; -import com.cloud.agent.api.RebootRouterCommand; import com.cloud.agent.api.SecurityGroupRuleAnswer; import com.cloud.agent.api.SecurityGroupRulesCmd; import com.cloud.agent.api.SetupGuestNetworkCommand; @@ -396,6 +393,10 @@ public LibvirtConnectionWrapper getLibvirtConnectionWrapper() { return libvirtConnectionWrapper; } + public VirtualRoutingResource getVirtRouterResource() { + return _virtRouterResource; + } + private static final class KeyValueInterpreter extends OutputInterpreter { private final Map map = new HashMap(); @@ -1298,11 +1299,7 @@ public Answer executeRequest(final Command cmd) { } try { - if (cmd instanceof RebootRouterCommand) { - return execute((RebootRouterCommand)cmd); - } else if (cmd instanceof RebootCommand) { - return execute((RebootCommand)cmd); - } else if (cmd instanceof GetHostStatsCommand) { + if (cmd instanceof GetHostStatsCommand) { return execute((GetHostStatsCommand)cmd); } else if (cmd instanceof CheckStateCommand) { return executeRequest(cmd); @@ -3310,7 +3307,7 @@ private Answer execute(final GetHostStatsCommand cmd) { return new GetHostStatsAnswer(cmd, hostStats); } - protected String networkUsage(final String privateIpAddress, final String option, final String vif) { + public String networkUsage(final String privateIpAddress, final String option, final String vif) { final Script getUsage = new Script(_routerProxyPath, s_logger); getUsage.add("netusage.sh"); getUsage.add(privateIpAddress); @@ -3418,38 +3415,6 @@ private Answer execute(final NetworkUsageCommand cmd) { } } - private Answer execute(final RebootCommand cmd) { - - try { - final Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); - final String result = rebootVM(conn, cmd.getVmName()); - if (result == null) { - Integer vncPort = null; - try { - vncPort = getVncPort(conn, cmd.getVmName()); - } catch (final LibvirtException e) { - s_logger.trace("Ignoring libvirt error.", e); - } - get_rule_logs_for_vms(); - return new RebootAnswer(cmd, null, vncPort); - } else { - return new RebootAnswer(cmd, result, false); - } - } catch (final LibvirtException e) { - return new RebootAnswer(cmd, e.getMessage(), false); - } - } - - protected Answer execute(final RebootRouterCommand cmd) { - final RebootAnswer answer = (RebootAnswer)execute((RebootCommand)cmd); - if (_virtRouterResource.connect(cmd.getPrivateIpAddress())) { - networkUsage(cmd.getPrivateIpAddress(), "create", null); - return answer; - } else { - return new Answer(cmd, false, "Failed to connect to virtual router " + cmd.getVmName()); - } - } - protected Answer execute(final ModifySshKeysCommand cmd) { final File sshKeysDir = new File(SSHKEYSPATH); String result = null; @@ -4466,7 +4431,7 @@ protected static long getCpuSpeed(final NodeInfo nodeInfo) { } } - protected String rebootVM(final Connect conn, final String vmName) { + public String rebootVM(final Connect conn, final String vmName) { Domain dm = null; String msg = null; try { @@ -4625,7 +4590,7 @@ protected String stopVM(final Connect conn, final String vmName, final boolean f return null; } - protected Integer getVncPort(final Connect conn, final String vmName) throws LibvirtException { + public Integer getVncPort(final Connect conn, final String vmName) throws LibvirtException { final LibvirtDomainXMLParser parser = new LibvirtDomainXMLParser(); Domain dm = null; try { @@ -5114,7 +5079,7 @@ private boolean cleanup_rules() { return true; } - private String get_rule_logs_for_vms() { + public String getRuleLogsForVms() { final Script cmd = new Script(_securityGroupPath, _timeout, s_logger); cmd.add("get_rule_logs_for_vms"); final OutputInterpreter.OneLineParser parser = new OutputInterpreter.OneLineParser(); @@ -5128,7 +5093,7 @@ private String get_rule_logs_for_vms() { private HashMap> syncNetworkGroups(final long id) { final HashMap> states = new HashMap>(); - final String result = get_rule_logs_for_vms(); + final String result = getRuleLogsForVms(); s_logger.trace("syncNetworkGroups: id=" + id + " got: " + result); final String[] rulelogs = result != null ? result.split(";") : new String[0]; for (final String rulesforvm : rulelogs) { diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConnectionWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConnectionWrapper.java index 0a6b966d61af..e6743ace118c 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConnectionWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConnectionWrapper.java @@ -27,7 +27,7 @@ */ public class LibvirtConnectionWrapper { - public Connect getConnectionByName(final String vmName) throws LibvirtException { + public Connect getConnectionByVmName(final String vmName) throws LibvirtException { return LibvirtConnection.getConnectionByVmName(vmName); } diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmStatsCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmStatsCommandWrapper.java index d894243fa8ac..e0649dae837a 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmStatsCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmStatsCommandWrapper.java @@ -46,7 +46,7 @@ public Answer execute(final GetVmStatsCommand command, final LibvirtComputingRes final LibvirtConnectionWrapper libvirtConnectionWrapper = libvirtComputingResource.getLibvirtConnectionWrapper(); - final Connect conn = libvirtConnectionWrapper.getConnectionByName(vmName); + final Connect conn = libvirtConnectionWrapper.getConnectionByVmName(vmName); final VmStatsEntry statEntry = libvirtComputingResource.getVmStat(conn, vmName); if (statEntry == null) { continue; diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRebootCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRebootCommandWrapper.java new file mode 100644 index 000000000000..e91604a73997 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRebootCommandWrapper.java @@ -0,0 +1,59 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import org.apache.log4j.Logger; +import org.libvirt.Connect; +import org.libvirt.LibvirtException; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.RebootAnswer; +import com.cloud.agent.api.RebootCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; + +public final class LibvirtRebootCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtRebootCommandWrapper.class); + + @Override + public Answer execute(final RebootCommand command, final LibvirtComputingResource libvirtComputingResource) { + final LibvirtConnectionWrapper libvirtConnectionWrapper = libvirtComputingResource.getLibvirtConnectionWrapper(); + + try { + final Connect conn = libvirtConnectionWrapper.getConnectionByVmName(command.getVmName()); + final String result = libvirtComputingResource.rebootVM(conn, command.getVmName()); + if (result == null) { + Integer vncPort = null; + try { + vncPort = libvirtComputingResource.getVncPort(conn, command.getVmName()); + } catch (final LibvirtException e) { + s_logger.trace("Ignoring libvirt error.", e); + } + libvirtComputingResource.getRuleLogsForVms(); + return new RebootAnswer(command, null, vncPort); + } else { + return new RebootAnswer(command, result, false); + } + } catch (final LibvirtException e) { + return new RebootAnswer(command, e.getMessage(), false); + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRebootRouterCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRebootRouterCommandWrapper.java new file mode 100644 index 000000000000..671b8c800c41 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRebootRouterCommandWrapper.java @@ -0,0 +1,47 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.RebootCommand; +import com.cloud.agent.api.RebootRouterCommand; +import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; + +public final class LibvirtRebootRouterCommandWrapper extends CommandWrapper { + + @Override + public Answer execute(final RebootRouterCommand command, final LibvirtComputingResource libvirtComputingResource) { + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + + final RebootCommand rebootCommand = new RebootCommand(command.getVmName()); + final Answer answer = wrapper.execute(rebootCommand, libvirtComputingResource); + + final VirtualRoutingResource virtualRouterResource = libvirtComputingResource.getVirtRouterResource(); + if (virtualRouterResource.connect(command.getPrivateIpAddress())) { + libvirtComputingResource.networkUsage(command.getPrivateIpAddress(), "create", null); + + return answer; + } else { + return new Answer(command, false, "Failed to connect to virtual router " + command.getVmName()); + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java index c74a09797fed..c2c3d8b5d285 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java @@ -24,6 +24,8 @@ import com.cloud.agent.api.Command; import com.cloud.agent.api.GetVmDiskStatsCommand; import com.cloud.agent.api.GetVmStatsCommand; +import com.cloud.agent.api.RebootCommand; +import com.cloud.agent.api.RebootRouterCommand; import com.cloud.agent.api.StopCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; @@ -50,6 +52,8 @@ private void init() { linbvirtCommands.put(StopCommand.class, new LibvirtStopCommandWrapper()); linbvirtCommands.put(GetVmStatsCommand.class, new LibvirtGetVmStatsCommandWrapper()); linbvirtCommands.put(GetVmDiskStatsCommand.class, new LibvirtGetVmDiskStatsCommandWrapper()); + linbvirtCommands.put(RebootRouterCommand.class, new LibvirtRebootRouterCommandWrapper()); + linbvirtCommands.put(RebootCommand.class, new LibvirtRebootCommandWrapper()); resources.put(LibvirtComputingResource.class, linbvirtCommands); } diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStopCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStopCommandWrapper.java index c5d6a5bd56e9..280c7f1e7de4 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStopCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStopCommandWrapper.java @@ -48,7 +48,7 @@ public Answer execute(final StopCommand command, final LibvirtComputingResource if (command.checkBeforeCleanup()) { try { - final Connect conn = libvirtConnectionWrapper.getConnectionByName(vmName); + final Connect conn = libvirtConnectionWrapper.getConnectionByVmName(vmName); final Domain vm = conn.domainLookupByName(command.getVmName()); if (vm != null && vm.getInfo().state == DomainState.VIR_DOMAIN_RUNNING) { return new StopAnswer(command, "vm is still running on host", false); @@ -59,7 +59,7 @@ public Answer execute(final StopCommand command, final LibvirtComputingResource } try { - final Connect conn = libvirtConnectionWrapper.getConnectionByName(vmName); + final Connect conn = libvirtConnectionWrapper.getConnectionByVmName(vmName); final List disks = libvirtComputingResource.getDisks(conn, vmName); final List ifaces = libvirtComputingResource.getInterfaces(conn, vmName); diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index cd1255631ced..8457e23b7686 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -19,6 +19,7 @@ package com.cloud.hypervisor.kvm.resource; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -63,9 +64,12 @@ import com.cloud.agent.api.Answer; import com.cloud.agent.api.GetVmDiskStatsCommand; import com.cloud.agent.api.GetVmStatsCommand; +import com.cloud.agent.api.RebootCommand; +import com.cloud.agent.api.RebootRouterCommand; import com.cloud.agent.api.StopCommand; import com.cloud.agent.api.VmStatsEntry; import com.cloud.agent.api.to.VirtualMachineTO; +import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef; import com.cloud.hypervisor.kvm.resource.wrapper.LibvirtConnectionWrapper; @@ -398,11 +402,11 @@ public void testStopCommandNoCheck() { final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); final String vmName = "Test"; - final StopCommand stopCommand = new StopCommand(vmName, false, false); + final StopCommand command = new StopCommand(vmName, false, false); when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); try { - when(libvirtConnectionWrapper.getConnectionByName(vmName)).thenReturn(conn); + when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenReturn(conn); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -410,13 +414,13 @@ public void testStopCommandNoCheck() { final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); assertNotNull(wrapper); - final Answer answer = wrapper.execute(stopCommand, libvirtComputingResource); + final Answer answer = wrapper.execute(command, libvirtComputingResource); assertTrue(answer.getResult()); verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByName(vmName); + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vmName); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -432,12 +436,12 @@ public void testStopCommandCheck() { final Domain domain = Mockito.mock(Domain.class); final String vmName = "Test"; - final StopCommand stopCommand = new StopCommand(vmName, false, true); + final StopCommand command = new StopCommand(vmName, false, true); when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); try { - when(libvirtConnectionWrapper.getConnectionByName(vmName)).thenReturn(conn); - when(conn.domainLookupByName(stopCommand.getVmName())).thenReturn(domain); + when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenReturn(conn); + when(conn.domainLookupByName(command.getVmName())).thenReturn(domain); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -445,13 +449,13 @@ public void testStopCommandCheck() { final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); assertNotNull(wrapper); - final Answer answer = wrapper.execute(stopCommand, libvirtComputingResource); + final Answer answer = wrapper.execute(command, libvirtComputingResource); assertTrue(answer.getResult()); verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(2)).getConnectionByName(vmName); + verify(libvirtConnectionWrapper, times(2)).getConnectionByVmName(vmName); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -470,11 +474,11 @@ public void testGetVmStatsCommand() { final List vms = new ArrayList(); vms.add(vmName); - final GetVmStatsCommand stopCommand = new GetVmStatsCommand(vms, uuid, "hostname"); + final GetVmStatsCommand command = new GetVmStatsCommand(vms, uuid, "hostname"); when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); try { - when(libvirtConnectionWrapper.getConnectionByName(vmName)).thenReturn(conn); + when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenReturn(conn); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -482,12 +486,12 @@ public void testGetVmStatsCommand() { final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); assertNotNull(wrapper); - final Answer answer = wrapper.execute(stopCommand, libvirtComputingResource); + final Answer answer = wrapper.execute(command, libvirtComputingResource); assertTrue(answer.getResult()); verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByName(vmName); + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vmName); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -506,7 +510,7 @@ public void testGetVmDiskStatsCommand() { final List vms = new ArrayList(); vms.add(vmName); - final GetVmDiskStatsCommand stopCommand = new GetVmDiskStatsCommand(vms, uuid, "hostname"); + final GetVmDiskStatsCommand command = new GetVmDiskStatsCommand(vms, uuid, "hostname"); when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); try { @@ -518,7 +522,7 @@ public void testGetVmDiskStatsCommand() { final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); assertNotNull(wrapper); - final Answer answer = wrapper.execute(stopCommand, libvirtComputingResource); + final Answer answer = wrapper.execute(command, libvirtComputingResource); assertTrue(answer.getResult()); verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); @@ -528,4 +532,72 @@ public void testGetVmDiskStatsCommand() { fail(e.getMessage()); } } + + @Test + public void testRebootCommand() { + // We cannot do much here due to the Native libraries and Static methods used by the LibvirtConnection we need + // a better way to mock stuff! + + final Connect conn = Mockito.mock(Connect.class); + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + + final String vmName = "Test"; + final RebootCommand command = new RebootCommand(vmName); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + try { + when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenReturn(conn); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vmName); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + + @Test + public void testRebootRouterCommand() { + // We cannot do much here due to the Native libraries and Static methods used by the LibvirtConnection we need + // a better way to mock stuff! + + final VirtualRoutingResource routingResource = Mockito.mock(VirtualRoutingResource.class); + final Connect conn = Mockito.mock(Connect.class); + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + + final String vmName = "Test"; + final RebootRouterCommand command = new RebootRouterCommand(vmName, "192.168.0.10"); + + when(libvirtComputingResource.getVirtRouterResource()).thenReturn(routingResource); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + try { + when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenReturn(conn); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getVirtRouterResource(); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vmName); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } } \ No newline at end of file From 6e568125fc282a3d0984f59fa0755b087e29cf7f Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Thu, 23 Apr 2015 10:30:13 +0200 Subject: [PATCH 005/175] Refactoring the LibvirtComputingResource - Adding LibvirtGetHosStatsCommandWrapper - 1 unit test added - KVM hypervisor with 10.5% coverage Tests are a bit limited on this one becuause of the current implementation. Would clean it up later in a separate branch --- .../resource/LibvirtComputingResource.java | 55 ++----------- .../LibvirtGetHostStatsCommandWrapper.java | 80 +++++++++++++++++++ .../wrapper/LibvirtRequestWrapper.java | 3 + .../LibvirtComputingResourceTest.java | 34 ++++---- 4 files changed, 104 insertions(+), 68 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetHostStatsCommandWrapper.java diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index a559e9965c76..5d8fc3a7f6ca 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -113,13 +113,10 @@ import com.cloud.agent.api.DeleteStoragePoolCommand; import com.cloud.agent.api.FenceAnswer; import com.cloud.agent.api.FenceCommand; -import com.cloud.agent.api.GetHostStatsAnswer; -import com.cloud.agent.api.GetHostStatsCommand; import com.cloud.agent.api.GetStorageStatsAnswer; import com.cloud.agent.api.GetStorageStatsCommand; import com.cloud.agent.api.GetVncPortAnswer; import com.cloud.agent.api.GetVncPortCommand; -import com.cloud.agent.api.HostStatsEntry; import com.cloud.agent.api.HostVmStateReportEntry; import com.cloud.agent.api.MaintainAnswer; import com.cloud.agent.api.MaintainCommand; @@ -397,6 +394,10 @@ public VirtualRoutingResource getVirtRouterResource() { return _virtRouterResource; } + public String getPublicBridgeName() { + return _publicBridgeName; + } + private static final class KeyValueInterpreter extends OutputInterpreter { private final Map map = new HashMap(); @@ -1299,9 +1300,7 @@ public Answer executeRequest(final Command cmd) { } try { - if (cmd instanceof GetHostStatsCommand) { - return execute((GetHostStatsCommand)cmd); - } else if (cmd instanceof CheckStateCommand) { + if (cmd instanceof CheckStateCommand) { return executeRequest(cmd); } else if (cmd instanceof CheckHealthCommand) { return execute((CheckHealthCommand)cmd); @@ -3265,48 +3264,6 @@ private Answer execute(final CheckHealthCommand cmd) { return new CheckHealthAnswer(cmd, true); } - private Answer execute(final GetHostStatsCommand cmd) { - final Script cpuScript = new Script("/bin/bash", s_logger); - cpuScript.add("-c"); - cpuScript.add("idle=$(top -b -n 1| awk -F, '/^[%]*[Cc]pu/{$0=$4; gsub(/[^0-9.,]+/,\"\"); print }'); echo $idle"); - - final OutputInterpreter.OneLineParser parser = new OutputInterpreter.OneLineParser(); - String result = cpuScript.execute(parser); - if (result != null) { - s_logger.debug("Unable to get the host CPU state: " + result); - return new Answer(cmd, false, result); - } - final double cpuUtil = 100.0D - Double.parseDouble(parser.getLine()); - - long freeMem = 0; - final Script memScript = new Script("/bin/bash", s_logger); - memScript.add("-c"); - memScript.add("freeMem=$(free|grep cache:|awk '{print $4}');echo $freeMem"); - final OutputInterpreter.OneLineParser Memparser = new OutputInterpreter.OneLineParser(); - result = memScript.execute(Memparser); - if (result != null) { - s_logger.debug("Unable to get the host Mem state: " + result); - return new Answer(cmd, false, result); - } - freeMem = Long.parseLong(Memparser.getLine()); - - final Script totalMem = new Script("/bin/bash", s_logger); - totalMem.add("-c"); - totalMem.add("free|grep Mem:|awk '{print $2}'"); - final OutputInterpreter.OneLineParser totMemparser = new OutputInterpreter.OneLineParser(); - result = totalMem.execute(totMemparser); - if (result != null) { - s_logger.debug("Unable to get the host Mem state: " + result); - return new Answer(cmd, false, result); - } - final long totMem = Long.parseLong(totMemparser.getLine()); - - final Pair nicStats = getNicStats(_publicBridgeName); - - final HostStatsEntry hostStats = new HostStatsEntry(cmd.getHostId(), cpuUtil, nicStats.first() / 1024, nicStats.second() / 1024, "host", totMem, freeMem, 0, 0); - return new GetHostStatsAnswer(cmd, hostStats); - } - public String networkUsage(final String privateIpAddress, final String option, final String vif) { final Script getUsage = new Script(_routerProxyPath, s_logger); getUsage.add("netusage.sh"); @@ -5120,7 +5077,7 @@ private boolean isSnapshotSupported() { } } - static Pair getNicStats(final String nicName) { + public Pair getNicStats(final String nicName) { return new Pair(readDouble(nicName, "rx_bytes"), readDouble(nicName, "tx_bytes")); } diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetHostStatsCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetHostStatsCommandWrapper.java new file mode 100644 index 000000000000..ba9ba188dad7 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetHostStatsCommandWrapper.java @@ -0,0 +1,80 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import org.apache.log4j.Logger; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.GetHostStatsAnswer; +import com.cloud.agent.api.GetHostStatsCommand; +import com.cloud.agent.api.HostStatsEntry; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; +import com.cloud.utils.Pair; +import com.cloud.utils.script.OutputInterpreter; +import com.cloud.utils.script.Script; + +public final class LibvirtGetHostStatsCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtGetHostStatsCommandWrapper.class); + + @Override + public Answer execute(final GetHostStatsCommand command, final LibvirtComputingResource libvirtComputingResource) { + final Script cpuScript = new Script("/bin/bash", s_logger); + cpuScript.add("-c"); + cpuScript.add("idle=$(top -b -n 1| awk -F, '/^[%]*[Cc]pu/{$0=$4; gsub(/[^0-9.,]+/,\"\"); print }'); echo $idle"); + + final OutputInterpreter.OneLineParser parser = new OutputInterpreter.OneLineParser(); + String result = cpuScript.execute(parser); + if (result != null) { + s_logger.debug("Unable to get the host CPU state: " + result); + return new Answer(command, false, result); + } + final double cpuUtil = 100.0D - Double.parseDouble(parser.getLine()); + + long freeMem = 0; + final Script memScript = new Script("/bin/bash", s_logger); + memScript.add("-c"); + memScript.add("freeMem=$(free|grep cache:|awk '{print $4}');echo $freeMem"); + final OutputInterpreter.OneLineParser Memparser = new OutputInterpreter.OneLineParser(); + result = memScript.execute(Memparser); + if (result != null) { + s_logger.debug("Unable to get the host Mem state: " + result); + return new Answer(command, false, result); + } + freeMem = Long.parseLong(Memparser.getLine()); + + final Script totalMem = new Script("/bin/bash", s_logger); + totalMem.add("-c"); + totalMem.add("free|grep Mem:|awk '{print $2}'"); + final OutputInterpreter.OneLineParser totMemparser = new OutputInterpreter.OneLineParser(); + result = totalMem.execute(totMemparser); + if (result != null) { + s_logger.debug("Unable to get the host Mem state: " + result); + return new Answer(command, false, result); + } + final long totMem = Long.parseLong(totMemparser.getLine()); + + final Pair nicStats = libvirtComputingResource.getNicStats(libvirtComputingResource.getPublicBridgeName()); + + final HostStatsEntry hostStats = new HostStatsEntry(command.getHostId(), cpuUtil, nicStats.first() / 1024, nicStats.second() / 1024, "host", totMem, freeMem, 0, 0); + return new GetHostStatsAnswer(command, hostStats); + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java index c2c3d8b5d285..e76a4eb46806 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java @@ -22,6 +22,7 @@ import com.cloud.agent.api.Answer; import com.cloud.agent.api.Command; +import com.cloud.agent.api.GetHostStatsCommand; import com.cloud.agent.api.GetVmDiskStatsCommand; import com.cloud.agent.api.GetVmStatsCommand; import com.cloud.agent.api.RebootCommand; @@ -54,6 +55,8 @@ private void init() { linbvirtCommands.put(GetVmDiskStatsCommand.class, new LibvirtGetVmDiskStatsCommandWrapper()); linbvirtCommands.put(RebootRouterCommand.class, new LibvirtRebootRouterCommandWrapper()); linbvirtCommands.put(RebootCommand.class, new LibvirtRebootCommandWrapper()); + linbvirtCommands.put(GetHostStatsCommand.class, new LibvirtGetHostStatsCommandWrapper()); + resources.put(LibvirtComputingResource.class, linbvirtCommands); } diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index 8457e23b7686..85f2c74c0f9a 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -62,6 +62,7 @@ import org.xml.sax.SAXException; import com.cloud.agent.api.Answer; +import com.cloud.agent.api.GetHostStatsCommand; import com.cloud.agent.api.GetVmDiskStatsCommand; import com.cloud.agent.api.GetVmStatsCommand; import com.cloud.agent.api.RebootCommand; @@ -289,7 +290,8 @@ public void testGetNicStats() { //this test is only working on linux because of the loopback interface name //also the tested code seems to work only on linux Assume.assumeTrue(SystemUtils.IS_OS_LINUX); - final Pair stats = LibvirtComputingResource.getNicStats("lo"); + final LibvirtComputingResource libvirtComputingResource = new LibvirtComputingResource(); + final Pair stats = libvirtComputingResource.getNicStats("lo"); assertNotNull(stats); } @@ -395,9 +397,6 @@ public void getCpuSpeed() { @Test public void testStopCommandNoCheck() { - // We cannot do much here due to the Native libraries and Static methods used by the LibvirtConnection we need - // a better way to mock stuff! - final Connect conn = Mockito.mock(Connect.class); final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); @@ -428,9 +427,6 @@ public void testStopCommandNoCheck() { @Test public void testStopCommandCheck() { - // We cannot do much here due to the Native libraries and Static methods used by the LibvirtConnection we need - // a better way to mock stuff! - final Connect conn = Mockito.mock(Connect.class); final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); final Domain domain = Mockito.mock(Domain.class); @@ -463,9 +459,6 @@ public void testStopCommandCheck() { @Test public void testGetVmStatsCommand() { - // We cannot do much here due to the Native libraries and Static methods used by the LibvirtConnection we need - // a better way to mock stuff! - final Connect conn = Mockito.mock(Connect.class); final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); @@ -499,9 +492,6 @@ public void testGetVmStatsCommand() { @Test public void testGetVmDiskStatsCommand() { - // We cannot do much here due to the Native libraries and Static methods used by the LibvirtConnection we need - // a better way to mock stuff! - final Connect conn = Mockito.mock(Connect.class); final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); @@ -535,9 +525,6 @@ public void testGetVmDiskStatsCommand() { @Test public void testRebootCommand() { - // We cannot do much here due to the Native libraries and Static methods used by the LibvirtConnection we need - // a better way to mock stuff! - final Connect conn = Mockito.mock(Connect.class); final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); @@ -567,9 +554,6 @@ public void testRebootCommand() { @Test public void testRebootRouterCommand() { - // We cannot do much here due to the Native libraries and Static methods used by the LibvirtConnection we need - // a better way to mock stuff! - final VirtualRoutingResource routingResource = Mockito.mock(VirtualRoutingResource.class); final Connect conn = Mockito.mock(Connect.class); final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); @@ -600,4 +584,16 @@ public void testRebootRouterCommand() { fail(e.getMessage()); } } + + @Test(expected = NumberFormatException.class) + public void testGetHostStatsCommand() { + final String uuid = "e8d6b4d0-bc6d-4613-b8bb-cb9e0600f3c6"; + final GetHostStatsCommand command = new GetHostStatsCommand(uuid, "summer", 1l); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + } } \ No newline at end of file From 54f68f519fc3baefe435f9b37f028ff2cca9106f Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Thu, 23 Apr 2015 10:45:57 +0200 Subject: [PATCH 006/175] Removing the CheckStateCommand form the IF statement on LibvirtComputingResource - It's not used and if so would cause an infinite loop. --- .../hypervisor/kvm/resource/LibvirtComputingResource.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 5d8fc3a7f6ca..b90b28b86fc0 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -100,7 +100,6 @@ import com.cloud.agent.api.CheckNetworkAnswer; import com.cloud.agent.api.CheckNetworkCommand; import com.cloud.agent.api.CheckOnHostCommand; -import com.cloud.agent.api.CheckStateCommand; import com.cloud.agent.api.CheckVirtualMachineAnswer; import com.cloud.agent.api.CheckVirtualMachineCommand; import com.cloud.agent.api.CleanupNetworkRulesCmd; @@ -1300,9 +1299,7 @@ public Answer executeRequest(final Command cmd) { } try { - if (cmd instanceof CheckStateCommand) { - return executeRequest(cmd); - } else if (cmd instanceof CheckHealthCommand) { + if (cmd instanceof CheckHealthCommand) { return execute((CheckHealthCommand)cmd); } else if (cmd instanceof PrepareForMigrationCommand) { return execute((PrepareForMigrationCommand)cmd); From d730efb86681b2206b82cbacc828e77e1204367b Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Thu, 23 Apr 2015 11:36:38 +0200 Subject: [PATCH 007/175] Refactoring the LibvirtComputingResource - Adding LibvirtCheckHealthCommandWrapper and LibvirtPrepareForMigrationCommandWrapper - 2 unit tests added - KVM hypervisor plugin with 10.8% coverage --- .../resource/LibvirtComputingResource.java | 68 ++------------ .../LibvirtCheckHealthCommandWrapper.java | 34 +++++++ ...virtPrepareForMigrationCommandWrapper.java | 89 +++++++++++++++++++ .../wrapper/LibvirtRequestWrapper.java | 4 + .../LibvirtComputingResourceTest.java | 72 +++++++++++++++ 5 files changed, 206 insertions(+), 61 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckHealthCommandWrapper.java create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPrepareForMigrationCommandWrapper.java diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index b90b28b86fc0..69f291e2bc29 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -95,8 +95,6 @@ import com.cloud.agent.api.AttachVolumeCommand; import com.cloud.agent.api.BackupSnapshotAnswer; import com.cloud.agent.api.BackupSnapshotCommand; -import com.cloud.agent.api.CheckHealthAnswer; -import com.cloud.agent.api.CheckHealthCommand; import com.cloud.agent.api.CheckNetworkAnswer; import com.cloud.agent.api.CheckNetworkCommand; import com.cloud.agent.api.CheckOnHostCommand; @@ -145,8 +143,6 @@ import com.cloud.agent.api.PingTestCommand; import com.cloud.agent.api.PlugNicAnswer; import com.cloud.agent.api.PlugNicCommand; -import com.cloud.agent.api.PrepareForMigrationAnswer; -import com.cloud.agent.api.PrepareForMigrationCommand; import com.cloud.agent.api.PvlanSetupCommand; import com.cloud.agent.api.ReadyAnswer; import com.cloud.agent.api.ReadyCommand; @@ -397,6 +393,10 @@ public String getPublicBridgeName() { return _publicBridgeName; } + public KVMStoragePoolManager getStoragePoolMgr() { + return _storagePoolMgr; + } + private static final class KeyValueInterpreter extends OutputInterpreter { private final Map map = new HashMap(); @@ -1044,7 +1044,7 @@ protected VifDriver getVifDriverClass(final String vifDriverClassName, final Map return vifDriver; } - protected VifDriver getVifDriver(final TrafficType trafficType) { + public VifDriver getVifDriver(final TrafficType trafficType) { VifDriver vifDriver = _trafficTypeVifDrivers.get(trafficType); if (vifDriver == null) { @@ -1299,11 +1299,7 @@ public Answer executeRequest(final Command cmd) { } try { - if (cmd instanceof CheckHealthCommand) { - return execute((CheckHealthCommand)cmd); - } else if (cmd instanceof PrepareForMigrationCommand) { - return execute((PrepareForMigrationCommand)cmd); - } else if (cmd instanceof MigrateCommand) { + if (cmd instanceof MigrateCommand) { return execute((MigrateCommand)cmd); } else if (cmd instanceof PingTestCommand) { return execute((PingTestCommand)cmd); @@ -3211,56 +3207,6 @@ public Domain call() throws LibvirtException { } } - private synchronized Answer execute(final PrepareForMigrationCommand cmd) { - - final VirtualMachineTO vm = cmd.getVirtualMachine(); - if (s_logger.isDebugEnabled()) { - s_logger.debug("Preparing host for migrating " + vm); - } - - final NicTO[] nics = vm.getNics(); - - boolean skipDisconnect = false; - - try { - final Connect conn = LibvirtConnection.getConnectionByVmName(vm.getName()); - for (final NicTO nic : nics) { - getVifDriver(nic.getType()).plug(nic, null, ""); - } - - /* setup disks, e.g for iso */ - final DiskTO[] volumes = vm.getDisks(); - for (final DiskTO volume : volumes) { - if (volume.getType() == Volume.Type.ISO) { - getVolumePath(conn, volume); - } - } - - if (!_storagePoolMgr.connectPhysicalDisksViaVmSpec(vm)) { - skipDisconnect = true; - return new PrepareForMigrationAnswer(cmd, "failed to connect physical disks to host"); - } - - skipDisconnect = true; - - return new PrepareForMigrationAnswer(cmd); - } catch (final LibvirtException e) { - return new PrepareForMigrationAnswer(cmd, e.toString()); - } catch (final InternalErrorException e) { - return new PrepareForMigrationAnswer(cmd, e.toString()); - } catch (final URISyntaxException e) { - return new PrepareForMigrationAnswer(cmd, e.toString()); - } finally { - if (!skipDisconnect) { - _storagePoolMgr.disconnectPhysicalDisksViaVmSpec(vm); - } - } - } - - private Answer execute(final CheckHealthCommand cmd) { - return new CheckHealthAnswer(cmd, true); - } - public String networkUsage(final String privateIpAddress, final String option, final String vif) { final Script getUsage = new Script(_routerProxyPath, s_logger); getUsage.add("netusage.sh"); @@ -3740,7 +3686,7 @@ protected StartAnswer execute(final StartCommand cmd) { } } - private String getVolumePath(final Connect conn, final DiskTO volume) throws LibvirtException, URISyntaxException { + public String getVolumePath(final Connect conn, final DiskTO volume) throws LibvirtException, URISyntaxException { final DataTO data = volume.getData(); final DataStoreTO store = data.getDataStore(); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckHealthCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckHealthCommandWrapper.java new file mode 100644 index 000000000000..c89d031ccd7d --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckHealthCommandWrapper.java @@ -0,0 +1,34 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.CheckHealthAnswer; +import com.cloud.agent.api.CheckHealthCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; + +public final class LibvirtCheckHealthCommandWrapper extends CommandWrapper { + + @Override + public Answer execute(final CheckHealthCommand command, final LibvirtComputingResource libvirtComputingResource) { + return new CheckHealthAnswer(command, true); + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPrepareForMigrationCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPrepareForMigrationCommandWrapper.java new file mode 100644 index 000000000000..921d5b8cf644 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPrepareForMigrationCommandWrapper.java @@ -0,0 +1,89 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import java.net.URISyntaxException; + +import org.apache.log4j.Logger; +import org.libvirt.Connect; +import org.libvirt.LibvirtException; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.PrepareForMigrationAnswer; +import com.cloud.agent.api.PrepareForMigrationCommand; +import com.cloud.agent.api.to.DiskTO; +import com.cloud.agent.api.to.NicTO; +import com.cloud.agent.api.to.VirtualMachineTO; +import com.cloud.exception.InternalErrorException; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; +import com.cloud.storage.Volume; + +public final class LibvirtPrepareForMigrationCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtPrepareForMigrationCommandWrapper.class); + + @Override + public Answer execute(final PrepareForMigrationCommand command, final LibvirtComputingResource libvirtComputingResource) { + final VirtualMachineTO vm = command.getVirtualMachine(); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Preparing host for migrating " + vm); + } + + final NicTO[] nics = vm.getNics(); + + boolean skipDisconnect = false; + + try { + final LibvirtConnectionWrapper libvirtConnectionWrapper = libvirtComputingResource.getLibvirtConnectionWrapper(); + + final Connect conn = libvirtConnectionWrapper.getConnectionByVmName(vm.getName()); + for (final NicTO nic : nics) { + libvirtComputingResource.getVifDriver(nic.getType()).plug(nic, null, ""); + } + + /* setup disks, e.g for iso */ + final DiskTO[] volumes = vm.getDisks(); + for (final DiskTO volume : volumes) { + if (volume.getType() == Volume.Type.ISO) { + libvirtComputingResource.getVolumePath(conn, volume); + } + } + + skipDisconnect = true; + + if (!libvirtComputingResource.getStoragePoolMgr().connectPhysicalDisksViaVmSpec(vm)) { + return new PrepareForMigrationAnswer(command, "failed to connect physical disks to host"); + } + + return new PrepareForMigrationAnswer(command); + } catch (final LibvirtException e) { + return new PrepareForMigrationAnswer(command, e.toString()); + } catch (final InternalErrorException e) { + return new PrepareForMigrationAnswer(command, e.toString()); + } catch (final URISyntaxException e) { + return new PrepareForMigrationAnswer(command, e.toString()); + } finally { + if (!skipDisconnect) { + libvirtComputingResource.getStoragePoolMgr().disconnectPhysicalDisksViaVmSpec(vm); + } + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java index e76a4eb46806..d8ca27fd2800 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java @@ -21,10 +21,12 @@ import java.util.Hashtable; import com.cloud.agent.api.Answer; +import com.cloud.agent.api.CheckHealthCommand; import com.cloud.agent.api.Command; import com.cloud.agent.api.GetHostStatsCommand; import com.cloud.agent.api.GetVmDiskStatsCommand; import com.cloud.agent.api.GetVmStatsCommand; +import com.cloud.agent.api.PrepareForMigrationCommand; import com.cloud.agent.api.RebootCommand; import com.cloud.agent.api.RebootRouterCommand; import com.cloud.agent.api.StopCommand; @@ -56,6 +58,8 @@ private void init() { linbvirtCommands.put(RebootRouterCommand.class, new LibvirtRebootRouterCommandWrapper()); linbvirtCommands.put(RebootCommand.class, new LibvirtRebootCommandWrapper()); linbvirtCommands.put(GetHostStatsCommand.class, new LibvirtGetHostStatsCommandWrapper()); + linbvirtCommands.put(CheckHealthCommand.class, new LibvirtCheckHealthCommandWrapper()); + linbvirtCommands.put(PrepareForMigrationCommand.class, new LibvirtPrepareForMigrationCommandWrapper()); resources.put(LibvirtComputingResource.class, linbvirtCommands); } diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index 85f2c74c0f9a..9b4b4213d337 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -62,19 +62,26 @@ import org.xml.sax.SAXException; import com.cloud.agent.api.Answer; +import com.cloud.agent.api.CheckHealthCommand; import com.cloud.agent.api.GetHostStatsCommand; import com.cloud.agent.api.GetVmDiskStatsCommand; import com.cloud.agent.api.GetVmStatsCommand; +import com.cloud.agent.api.PrepareForMigrationCommand; import com.cloud.agent.api.RebootCommand; import com.cloud.agent.api.RebootRouterCommand; import com.cloud.agent.api.StopCommand; import com.cloud.agent.api.VmStatsEntry; +import com.cloud.agent.api.to.DiskTO; +import com.cloud.agent.api.to.NicTO; import com.cloud.agent.api.to.VirtualMachineTO; import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef; import com.cloud.hypervisor.kvm.resource.wrapper.LibvirtConnectionWrapper; import com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper; +import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; +import com.cloud.network.Networks.TrafficType; +import com.cloud.storage.Volume; import com.cloud.template.VirtualMachineTemplate.BootloaderType; import com.cloud.utils.Pair; import com.cloud.vm.VirtualMachine; @@ -587,6 +594,9 @@ public void testRebootRouterCommand() { @Test(expected = NumberFormatException.class) public void testGetHostStatsCommand() { + // A bit difficult top test due to the logger being passed and the parser itself relying on the connection. + // Have to spend some more time afterwards in order to refactor the wrapper itself. + final String uuid = "e8d6b4d0-bc6d-4613-b8bb-cb9e0600f3c6"; final GetHostStatsCommand command = new GetHostStatsCommand(uuid, "summer", 1l); @@ -596,4 +606,66 @@ public void testGetHostStatsCommand() { final Answer answer = wrapper.execute(command, libvirtComputingResource); assertFalse(answer.getResult()); } + + @Test + public void testCheckHealthCommand() { + // A bit difficult top test due to the logger being passed and the parser itself relying on the connection. + // Have to spend some more time afterwards in order to refactor the wrapper itself. + + final CheckHealthCommand command = new CheckHealthCommand(); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + } + + @Test + public void testPrepareForMigrationCommand() { + final Connect conn = Mockito.mock(Connect.class); + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + + final VirtualMachineTO vm = Mockito.mock(VirtualMachineTO.class); + final KVMStoragePoolManager storagePoolManager = Mockito.mock(KVMStoragePoolManager.class); + final NicTO nicTO = Mockito.mock(NicTO.class); + final DiskTO diskTO = Mockito.mock(DiskTO.class); + final VifDriver vifDriver = Mockito.mock(VifDriver.class); + + final PrepareForMigrationCommand command = new PrepareForMigrationCommand(vm); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + try { + when(libvirtConnectionWrapper.getConnectionByVmName(vm.getName())).thenReturn(conn); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + when(vm.getNics()).thenReturn(new NicTO[]{nicTO}); + when(vm.getDisks()).thenReturn(new DiskTO[]{diskTO}); + + when(nicTO.getType()).thenReturn(TrafficType.Guest); + when(diskTO.getType()).thenReturn(Volume.Type.ISO); + + when(libvirtComputingResource.getVifDriver(nicTO.getType())).thenReturn(vifDriver); + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolManager); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vm.getName()); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + verify(vm, times(1)).getNics(); + verify(vm, times(1)).getDisks(); + verify(diskTO, times(1)).getType(); + } } \ No newline at end of file From 28e55462f15bdd8699e97b668c4ffc01735a533d Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Thu, 23 Apr 2015 13:31:58 +0200 Subject: [PATCH 008/175] Refactoring the LibvirtComputingResource - Adding LibvirtMigrateCommandWrapper - 1 unit tests added - KVM hypervisor plugin with 10.9% coverage --- .../resource/LibvirtComputingResource.java | 185 ++---------------- .../kvm/resource/MigrateKVMAsync.java | 38 ++++ .../wrapper/LibvirtMigrateCommandWrapper.java | 183 +++++++++++++++++ .../wrapper/LibvirtRequestWrapper.java | 2 + .../LibvirtComputingResourceTest.java | 75 +++++++ 5 files changed, 319 insertions(+), 164 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/MigrateKVMAsync.java create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 69f291e2bc29..893f82dc40a3 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -47,14 +47,11 @@ import java.util.Properties; import java.util.Set; import java.util.UUID; -import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -119,8 +116,6 @@ import com.cloud.agent.api.MaintainCommand; import com.cloud.agent.api.ManageSnapshotAnswer; import com.cloud.agent.api.ManageSnapshotCommand; -import com.cloud.agent.api.MigrateAnswer; -import com.cloud.agent.api.MigrateCommand; import com.cloud.agent.api.ModifySshKeysCommand; import com.cloud.agent.api.ModifyStoragePoolAnswer; import com.cloud.agent.api.ModifyStoragePoolCommand; @@ -298,9 +293,6 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv private String _dcId; private String _pod; private String _clusterId; - private int _migrateSpeed; - private int _migrateDowntime; - private int _migratePauseAfter; private long _hvVersion; private long _kernelVersion; @@ -397,6 +389,22 @@ public KVMStoragePoolManager getStoragePoolMgr() { return _storagePoolMgr; } + public String getPrivateIp() { + return _privateIp; + } + + public int getMigrateDowntime() { + return _migrateDowntime; + } + + public int getMigratePauseAfter() { + return _migratePauseAfter; + } + + public int getMigrateSpeed() { + return _migrateSpeed; + } + private static final class KeyValueInterpreter extends OutputInterpreter { private final Map map = new HashMap(); @@ -459,6 +467,10 @@ protected String getDefaultScriptsDir() { protected String _videoHw; protected int _videoRam; protected Pair hostOsVersion; + protected int _migrateSpeed; + protected int _migrateDowntime; + protected int _migratePauseAfter; + private final Map _pifs = new HashMap(); private final Map _vmStats = new ConcurrentHashMap(); @@ -1299,9 +1311,7 @@ public Answer executeRequest(final Command cmd) { } try { - if (cmd instanceof MigrateCommand) { - return execute((MigrateCommand)cmd); - } else if (cmd instanceof PingTestCommand) { + if (cmd instanceof PingTestCommand) { return execute((PingTestCommand)cmd); } else if (cmd instanceof CheckVirtualMachineCommand) { return execute((CheckVirtualMachineCommand)cmd); @@ -3054,159 +3064,6 @@ private String doPingTest(final String domRIp, final String vmIp) { return command.execute(); } - private Answer execute(final MigrateCommand cmd) { - final String vmName = cmd.getVmName(); - - String result = null; - - List ifaces = null; - List disks = null; - - Domain dm = null; - Connect dconn = null; - Domain destDomain = null; - Connect conn = null; - String xmlDesc = null; - try { - conn = LibvirtConnection.getConnectionByVmName(vmName); - ifaces = getInterfaces(conn, vmName); - disks = getDisks(conn, vmName); - dm = conn.domainLookupByName(vmName); - /* - We replace the private IP address with the address of the destination host. - This is because the VNC listens on the private IP address of the hypervisor, - but that address is ofcourse different on the target host. - - MigrateCommand.getDestinationIp() returns the private IP address of the target - hypervisor. So it's safe to use. - - The Domain.migrate method from libvirt supports passing a different XML - description for the instance to be used on the target host. - - This is supported by libvirt-java from version 0.50.0 - */ - xmlDesc = dm.getXMLDesc(0).replace(_privateIp, cmd.getDestinationIp()); - - dconn = new Connect("qemu+tcp://" + cmd.getDestinationIp() + "/system"); - - //run migration in thread so we can monitor it - s_logger.info("Live migration of instance " + vmName + " initiated"); - final ExecutorService executor = Executors.newFixedThreadPool(1); - final Callable worker = new MigrateKVMAsync(dm, dconn, xmlDesc, vmName, cmd.getDestinationIp()); - final Future migrateThread = executor.submit(worker); - executor.shutdown(); - long sleeptime = 0; - while (!executor.isTerminated()) { - Thread.sleep(100); - sleeptime += 100; - if (sleeptime == 1000) { // wait 1s before attempting to set downtime on migration, since I don't know of a VIR_DOMAIN_MIGRATING state - if (_migrateDowntime > 0 ) { - try { - final int setDowntime = dm.migrateSetMaxDowntime(_migrateDowntime); - if (setDowntime == 0 ) { - s_logger.debug("Set max downtime for migration of " + vmName + " to " + String.valueOf(_migrateDowntime) + "ms"); - } - } catch (final LibvirtException e) { - s_logger.debug("Failed to set max downtime for migration, perhaps migration completed? Error: " + e.getMessage()); - } - } - } - if (sleeptime % 1000 == 0) { - s_logger.info("Waiting for migration of " + vmName + " to complete, waited " + sleeptime + "ms"); - } - - // pause vm if we meet the vm.migrate.pauseafter threshold and not already paused - if (_migratePauseAfter > 0 && sleeptime > _migratePauseAfter && dm.getInfo().state == DomainState.VIR_DOMAIN_RUNNING ) { - s_logger.info("Pausing VM " + vmName + " due to property vm.migrate.pauseafter setting to " + _migratePauseAfter+ "ms to complete migration"); - try { - dm.suspend(); - } catch (final LibvirtException e) { - // pause could be racy if it attempts to pause right when vm is finished, simply warn - s_logger.info("Failed to pause vm " + vmName + " : " + e.getMessage()); - } - } - } - s_logger.info("Migration thread for " + vmName + " is done"); - - destDomain = migrateThread.get(10, TimeUnit.SECONDS); - - if (destDomain != null) { - for (final DiskDef disk : disks) { - cleanupDisk(disk); - } - } - } catch (final LibvirtException e) { - s_logger.debug("Can't migrate domain: " + e.getMessage()); - result = e.getMessage(); - } catch (final InterruptedException e) { - s_logger.debug("Interrupted while migrating domain: " + e.getMessage()); - result = e.getMessage(); - } catch (final ExecutionException e) { - s_logger.debug("Failed to execute while migrating domain: " + e.getMessage()); - result = e.getMessage(); - } catch (final TimeoutException e) { - s_logger.debug("Timed out while migrating domain: " + e.getMessage()); - result = e.getMessage(); - } finally { - try { - if (dm != null) { - if (dm.isPersistent() == 1) { - dm.undefine(); - } - dm.free(); - } - if (dconn != null) { - dconn.close(); - } - if (destDomain != null) { - destDomain.free(); - } - } catch (final LibvirtException e) { - s_logger.trace("Ignoring libvirt error.", e); - } - } - - if (result != null) { - } else { - destroyNetworkRulesForVM(conn, vmName); - for (final InterfaceDef iface : ifaces) { - // We don't know which "traffic type" is associated with - // each interface at this point, so inform all vif drivers - for (final VifDriver vifDriver : getAllVifDrivers()) { - vifDriver.unplug(iface); - } - } - } - - return new MigrateAnswer(cmd, result == null, result, null); - } - - private class MigrateKVMAsync implements Callable { - Domain dm = null; - Connect dconn = null; - String dxml = ""; - String vmName = ""; - String destIp = ""; - - MigrateKVMAsync(final Domain dm, final Connect dconn, final String dxml, final String vmName, final String destIp) { - this.dm = dm; - this.dconn = dconn; - this.dxml = dxml; - this.vmName = vmName; - this.destIp = destIp; - } - - @Override - public Domain call() throws LibvirtException { - // set compression flag for migration if libvirt version supports it - if (dconn.getLibVirVersion() < 1003000) { - return dm.migrate(dconn, 1 << 0, dxml, vmName, "tcp:" + destIp, _migrateSpeed); - } else { - return dm.migrate(dconn, 1 << 0|1 << 11, dxml, vmName, "tcp:" + destIp, _migrateSpeed); - } - } - } - public String networkUsage(final String privateIpAddress, final String option, final String vif) { final Script getUsage = new Script(_routerProxyPath, s_logger); getUsage.add("netusage.sh"); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/MigrateKVMAsync.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/MigrateKVMAsync.java new file mode 100644 index 000000000000..fdec032ed5b0 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/MigrateKVMAsync.java @@ -0,0 +1,38 @@ +package com.cloud.hypervisor.kvm.resource; + +import java.util.concurrent.Callable; + +import org.libvirt.Connect; +import org.libvirt.Domain; +import org.libvirt.LibvirtException; + +public class MigrateKVMAsync implements Callable { + + private final LibvirtComputingResource libvirtComputingResource; + + private Domain dm = null; + private Connect dconn = null; + private String dxml = ""; + private String vmName = ""; + private String destIp = ""; + + public MigrateKVMAsync(final LibvirtComputingResource libvirtComputingResource, final Domain dm, final Connect dconn, final String dxml, final String vmName, final String destIp) { + this.libvirtComputingResource = libvirtComputingResource; + + this.dm = dm; + this.dconn = dconn; + this.dxml = dxml; + this.vmName = vmName; + this.destIp = destIp; + } + + @Override + public Domain call() throws LibvirtException { + // set compression flag for migration if libvirt version supports it + if (dconn.getLibVirVersion() < 1003000) { + return dm.migrate(dconn, 1 << 0, dxml, vmName, "tcp:" + destIp, libvirtComputingResource.getMigrateSpeed()); + } else { + return dm.migrate(dconn, 1 << 0|1 << 11, dxml, vmName, "tcp:" + destIp, libvirtComputingResource.getMigrateSpeed()); + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java new file mode 100644 index 000000000000..d3637e62e3c0 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java @@ -0,0 +1,183 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import java.util.List; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import org.apache.log4j.Logger; +import org.libvirt.Connect; +import org.libvirt.Domain; +import org.libvirt.DomainInfo.DomainState; +import org.libvirt.LibvirtException; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.MigrateAnswer; +import com.cloud.agent.api.MigrateCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef; +import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef; +import com.cloud.hypervisor.kvm.resource.MigrateKVMAsync; +import com.cloud.hypervisor.kvm.resource.VifDriver; +import com.cloud.resource.CommandWrapper; + +public final class LibvirtMigrateCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtMigrateCommandWrapper.class); + + @Override + public Answer execute(final MigrateCommand command, final LibvirtComputingResource libvirtComputingResource) { + final String vmName = command.getVmName(); + + String result = null; + + List ifaces = null; + List disks = null; + + Domain dm = null; + Connect dconn = null; + Domain destDomain = null; + Connect conn = null; + String xmlDesc = null; + try { + final LibvirtConnectionWrapper libvirtConnectionWrapper = libvirtComputingResource.getLibvirtConnectionWrapper(); + + conn = libvirtConnectionWrapper.getConnectionByVmName(vmName); + ifaces = libvirtComputingResource.getInterfaces(conn, vmName); + disks = libvirtComputingResource.getDisks(conn, vmName); + dm = conn.domainLookupByName(vmName); + /* + We replace the private IP address with the address of the destination host. + This is because the VNC listens on the private IP address of the hypervisor, + but that address is ofcourse different on the target host. + + MigrateCommand.getDestinationIp() returns the private IP address of the target + hypervisor. So it's safe to use. + + The Domain.migrate method from libvirt supports passing a different XML + description for the instance to be used on the target host. + + This is supported by libvirt-java from version 0.50.0 + */ + xmlDesc = dm.getXMLDesc(0).replace(libvirtComputingResource.getPrivateIp(), command.getDestinationIp()); + + dconn = new Connect("qemu+tcp://" + command.getDestinationIp() + "/system"); + + //run migration in thread so we can monitor it + s_logger.info("Live migration of instance " + vmName + " initiated"); + final ExecutorService executor = Executors.newFixedThreadPool(1); + final Callable worker = new MigrateKVMAsync(libvirtComputingResource, dm, dconn, xmlDesc, vmName, command.getDestinationIp()); + final Future migrateThread = executor.submit(worker); + executor.shutdown(); + long sleeptime = 0; + while (!executor.isTerminated()) { + Thread.sleep(100); + sleeptime += 100; + if (sleeptime == 1000) { // wait 1s before attempting to set downtime on migration, since I don't know of a VIR_DOMAIN_MIGRATING state + final int migrateDowntime = libvirtComputingResource.getMigrateDowntime(); + if (migrateDowntime > 0 ) { + try { + final int setDowntime = dm.migrateSetMaxDowntime(migrateDowntime); + if (setDowntime == 0 ) { + s_logger.debug("Set max downtime for migration of " + vmName + " to " + String.valueOf(migrateDowntime) + "ms"); + } + } catch (final LibvirtException e) { + s_logger.debug("Failed to set max downtime for migration, perhaps migration completed? Error: " + e.getMessage()); + } + } + } + if (sleeptime % 1000 == 0) { + s_logger.info("Waiting for migration of " + vmName + " to complete, waited " + sleeptime + "ms"); + } + + // pause vm if we meet the vm.migrate.pauseafter threshold and not already paused + final int migratePauseAfter = libvirtComputingResource.getMigratePauseAfter(); + if (migratePauseAfter > 0 && sleeptime > migratePauseAfter && dm.getInfo().state == DomainState.VIR_DOMAIN_RUNNING ) { + s_logger.info("Pausing VM " + vmName + " due to property vm.migrate.pauseafter setting to " + migratePauseAfter+ "ms to complete migration"); + try { + dm.suspend(); + } catch (final LibvirtException e) { + // pause could be racy if it attempts to pause right when vm is finished, simply warn + s_logger.info("Failed to pause vm " + vmName + " : " + e.getMessage()); + } + } + } + s_logger.info("Migration thread for " + vmName + " is done"); + + destDomain = migrateThread.get(10, TimeUnit.SECONDS); + + if (destDomain != null) { + for (final DiskDef disk : disks) { + libvirtComputingResource.cleanupDisk(disk); + } + } + } catch (final LibvirtException e) { + s_logger.debug("Can't migrate domain: " + e.getMessage()); + result = e.getMessage(); + } catch (final InterruptedException e) { + s_logger.debug("Interrupted while migrating domain: " + e.getMessage()); + result = e.getMessage(); + } catch (final ExecutionException e) { + s_logger.debug("Failed to execute while migrating domain: " + e.getMessage()); + result = e.getMessage(); + } catch (final TimeoutException e) { + s_logger.debug("Timed out while migrating domain: " + e.getMessage()); + result = e.getMessage(); + } finally { + try { + if (dm != null) { + if (dm.isPersistent() == 1) { + dm.undefine(); + } + dm.free(); + } + if (dconn != null) { + dconn.close(); + } + if (destDomain != null) { + destDomain.free(); + } + } catch (final LibvirtException e) { + s_logger.trace("Ignoring libvirt error.", e); + } + } + + if (result != null) { + } else { + libvirtComputingResource.destroyNetworkRulesForVM(conn, vmName); + for (final InterfaceDef iface : ifaces) { + // We don't know which "traffic type" is associated with + // each interface at this point, so inform all vif drivers + final List allVifDrivers = libvirtComputingResource.getAllVifDrivers(); + for (final VifDriver vifDriver : allVifDrivers) { + vifDriver.unplug(iface); + } + } + } + + return new MigrateAnswer(command, result == null, result, null); + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java index d8ca27fd2800..ee444b8e88f3 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java @@ -26,6 +26,7 @@ import com.cloud.agent.api.GetHostStatsCommand; import com.cloud.agent.api.GetVmDiskStatsCommand; import com.cloud.agent.api.GetVmStatsCommand; +import com.cloud.agent.api.MigrateCommand; import com.cloud.agent.api.PrepareForMigrationCommand; import com.cloud.agent.api.RebootCommand; import com.cloud.agent.api.RebootRouterCommand; @@ -60,6 +61,7 @@ private void init() { linbvirtCommands.put(GetHostStatsCommand.class, new LibvirtGetHostStatsCommandWrapper()); linbvirtCommands.put(CheckHealthCommand.class, new LibvirtCheckHealthCommandWrapper()); linbvirtCommands.put(PrepareForMigrationCommand.class, new LibvirtPrepareForMigrationCommandWrapper()); + linbvirtCommands.put(MigrateCommand.class, new LibvirtMigrateCommandWrapper()); resources.put(LibvirtComputingResource.class, linbvirtCommands); } diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index 9b4b4213d337..4aa249e7f0a2 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -23,6 +23,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -66,6 +67,7 @@ import com.cloud.agent.api.GetHostStatsCommand; import com.cloud.agent.api.GetVmDiskStatsCommand; import com.cloud.agent.api.GetVmStatsCommand; +import com.cloud.agent.api.MigrateCommand; import com.cloud.agent.api.PrepareForMigrationCommand; import com.cloud.agent.api.RebootCommand; import com.cloud.agent.api.RebootRouterCommand; @@ -668,4 +670,77 @@ public void testPrepareForMigrationCommand() { verify(vm, times(1)).getDisks(); verify(diskTO, times(1)).getType(); } + + @Test(expected = UnsatisfiedLinkError.class) + public void testMigrateCommand() { + // The Connect constructor used inside the LibvirtMigrateCommandWrapper has a call to native methods, which + // makes difficult to test it now. + // Will keep it expecting the UnsatisfiedLinkError and fix later. + + final Connect conn = Mockito.mock(Connect.class); + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + + final String vmName = "Test"; + final String destIp = "10.1.1.100"; + final boolean isWindows = false; + final VirtualMachineTO vmTO = Mockito.mock(VirtualMachineTO.class); + final boolean executeInSequence = false; + + final MigrateCommand command = new MigrateCommand(vmName, destIp, isWindows, vmTO, executeInSequence ); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + try { + when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenReturn(conn); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final InterfaceDef interfaceDef = Mockito.mock(InterfaceDef.class); + final List ifaces = new ArrayList(); + ifaces.add(interfaceDef); + + when(libvirtComputingResource.getInterfaces(conn, vmName)).thenReturn(ifaces); + + final DiskDef diskDef = Mockito.mock(DiskDef.class); + final List disks = new ArrayList(); + disks.add(diskDef); + + when(libvirtComputingResource.getDisks(conn, vmName)).thenReturn(disks); + final Domain dm = Mockito.mock(Domain.class); + try { + when(conn.domainLookupByName(vmName)).thenReturn(dm); + + when(libvirtComputingResource.getPrivateIp()).thenReturn("192.168.1.10"); + when(dm.getXMLDesc(0)).thenReturn("host_domain"); + when(dm.isPersistent()).thenReturn(1); + doNothing().when(dm).undefine(); + + } catch (final LibvirtException e) { + fail(e.getMessage()); + } catch (final Exception e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vmName); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + verify(libvirtComputingResource, times(1)).getInterfaces(conn, vmName); + verify(libvirtComputingResource, times(1)).getDisks(conn, vmName); + try { + verify(conn, times(1)).domainLookupByName(vmName); + verify(dm, times(1)).getXMLDesc(0); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } } \ No newline at end of file From be1e5176156d9b7eb78e53c703b48d679ad52f56 Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Thu, 23 Apr 2015 13:57:13 +0200 Subject: [PATCH 009/175] Refactoring the LibvirtComputingResource - Adding LibvirtPingTestCommandWrapper - 3 unit tests added - KVM hypervisor plugin with 11.2% coverage --- .../resource/LibvirtComputingResource.java | 44 ++----------- .../LibvirtPingTestCommandWrapper.java | 65 +++++++++++++++++++ .../wrapper/LibvirtRequestWrapper.java | 2 + .../LibvirtComputingResourceTest.java | 39 +++++++++-- 4 files changed, 107 insertions(+), 43 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPingTestCommandWrapper.java diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 893f82dc40a3..1c7aa2414115 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -135,7 +135,6 @@ import com.cloud.agent.api.PingCommand; import com.cloud.agent.api.PingRoutingCommand; import com.cloud.agent.api.PingRoutingWithNwGroupsCommand; -import com.cloud.agent.api.PingTestCommand; import com.cloud.agent.api.PlugNicAnswer; import com.cloud.agent.api.PlugNicCommand; import com.cloud.agent.api.PvlanSetupCommand; @@ -405,6 +404,10 @@ public int getMigrateSpeed() { return _migrateSpeed; } + public String getPingTestPath() { + return _pingTestPath; + } + private static final class KeyValueInterpreter extends OutputInterpreter { private final Map map = new HashMap(); @@ -1311,9 +1314,7 @@ public Answer executeRequest(final Command cmd) { } try { - if (cmd instanceof PingTestCommand) { - return execute((PingTestCommand)cmd); - } else if (cmd instanceof CheckVirtualMachineCommand) { + if (cmd instanceof CheckVirtualMachineCommand) { return execute((CheckVirtualMachineCommand)cmd); } else if (cmd instanceof ReadyCommand) { return execute((ReadyCommand)cmd); @@ -3029,41 +3030,6 @@ private Answer execute(final CheckVirtualMachineCommand cmd) { } } - private Answer execute(final PingTestCommand cmd) { - String result = null; - final String computingHostIp = cmd.getComputingHostIp(); // TODO, split - // the - // command - // into 2 - // types - - if (computingHostIp != null) { - result = doPingTest(computingHostIp); - } else if (cmd.getRouterIp() != null && cmd.getPrivateIp() != null) { - result = doPingTest(cmd.getRouterIp(), cmd.getPrivateIp()); - } else { - return new Answer(cmd, false, "routerip and private ip is null"); - } - - if (result != null) { - return new Answer(cmd, false, result); - } - return new Answer(cmd); - } - - private String doPingTest(final String computingHostIp) { - final Script command = new Script(_pingTestPath, 10000, s_logger); - command.add("-h", computingHostIp); - return command.execute(); - } - - private String doPingTest(final String domRIp, final String vmIp) { - final Script command = new Script(_pingTestPath, 10000, s_logger); - command.add("-i", domRIp); - command.add("-p", vmIp); - return command.execute(); - } - public String networkUsage(final String privateIpAddress, final String option, final String vif) { final Script getUsage = new Script(_routerProxyPath, s_logger); getUsage.add("netusage.sh"); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPingTestCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPingTestCommandWrapper.java new file mode 100644 index 000000000000..3ef9e2c73ce7 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPingTestCommandWrapper.java @@ -0,0 +1,65 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import org.apache.log4j.Logger; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.PingTestCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; +import com.cloud.utils.script.Script; + +public final class LibvirtPingTestCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtPingTestCommandWrapper.class); + + @Override + public Answer execute(final PingTestCommand command, final LibvirtComputingResource libvirtComputingResource) { + String result = null; + final String computingHostIp = command.getComputingHostIp(); // TODO, split the command into 2 types + + if (computingHostIp != null) { + result = doPingTest(libvirtComputingResource, computingHostIp); + } else if (command.getRouterIp() != null && command.getPrivateIp() != null) { + result = doPingTest(libvirtComputingResource, command.getRouterIp(), command.getPrivateIp()); + } else { + return new Answer(command, false, "routerip and private ip is null"); + } + + if (result != null) { + return new Answer(command, false, result); + } + return new Answer(command); + } + + protected String doPingTest(final LibvirtComputingResource libvirtComputingResource, final String computingHostIp) { + final Script command = new Script(libvirtComputingResource.getPingTestPath(), 10000, s_logger); + command.add("-h", computingHostIp); + return command.execute(); + } + + protected String doPingTest(final LibvirtComputingResource libvirtComputingResource, final String domRIp, final String vmIp) { + final Script command = new Script(libvirtComputingResource.getPingTestPath(), 10000, s_logger); + command.add("-i", domRIp); + command.add("-p", vmIp); + return command.execute(); + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java index ee444b8e88f3..aeac43c5d721 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java @@ -27,6 +27,7 @@ import com.cloud.agent.api.GetVmDiskStatsCommand; import com.cloud.agent.api.GetVmStatsCommand; import com.cloud.agent.api.MigrateCommand; +import com.cloud.agent.api.PingTestCommand; import com.cloud.agent.api.PrepareForMigrationCommand; import com.cloud.agent.api.RebootCommand; import com.cloud.agent.api.RebootRouterCommand; @@ -62,6 +63,7 @@ private void init() { linbvirtCommands.put(CheckHealthCommand.class, new LibvirtCheckHealthCommandWrapper()); linbvirtCommands.put(PrepareForMigrationCommand.class, new LibvirtPrepareForMigrationCommandWrapper()); linbvirtCommands.put(MigrateCommand.class, new LibvirtMigrateCommandWrapper()); + linbvirtCommands.put(PingTestCommand.class, new LibvirtPingTestCommandWrapper()); resources.put(LibvirtComputingResource.class, linbvirtCommands); } diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index 4aa249e7f0a2..50c8ca68a6d1 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -68,6 +68,7 @@ import com.cloud.agent.api.GetVmDiskStatsCommand; import com.cloud.agent.api.GetVmStatsCommand; import com.cloud.agent.api.MigrateCommand; +import com.cloud.agent.api.PingTestCommand; import com.cloud.agent.api.PrepareForMigrationCommand; import com.cloud.agent.api.RebootCommand; import com.cloud.agent.api.RebootRouterCommand; @@ -596,7 +597,7 @@ public void testRebootRouterCommand() { @Test(expected = NumberFormatException.class) public void testGetHostStatsCommand() { - // A bit difficult top test due to the logger being passed and the parser itself relying on the connection. + // A bit difficult to test due to the logger being passed and the parser itself relying on the connection. // Have to spend some more time afterwards in order to refactor the wrapper itself. final String uuid = "e8d6b4d0-bc6d-4613-b8bb-cb9e0600f3c6"; @@ -611,9 +612,6 @@ public void testGetHostStatsCommand() { @Test public void testCheckHealthCommand() { - // A bit difficult top test due to the logger being passed and the parser itself relying on the connection. - // Have to spend some more time afterwards in order to refactor the wrapper itself. - final CheckHealthCommand command = new CheckHealthCommand(); final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); @@ -743,4 +741,37 @@ public void testMigrateCommand() { fail(e.getMessage()); } } + + @Test + public void testPingTestHostIpCommand() { + final PingTestCommand command = new PingTestCommand("172.1.10.10"); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + } + + @Test + public void testPingTestPvtIpCommand() { + final PingTestCommand command = new PingTestCommand("169.17.1.10", "192.168.10.10"); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + } + + @Test + public void testPingOnlyOneIpCommand() { + final PingTestCommand command = new PingTestCommand("169.17.1.10", null); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + } } \ No newline at end of file From 4d216f1a6382c42cf94a947aa5432f4d18782811 Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Thu, 23 Apr 2015 14:24:53 +0200 Subject: [PATCH 010/175] Refactoring the LibvirtComputingResource - Adding LibvirtAttachIsoCommandWrapper, LibvirtAttachIsoCommandWrapper and LibvirtAttachIsoCommandWrapper - 7 unit tests added - KVM hypervisor plugin with 11.5% coverage --- .../resource/LibvirtComputingResource.java | 53 +---- .../LibvirtAttachIsoCommandWrapper.java | 52 +++++ ...virtCheckVirtualMachineCommandWrapper.java | 51 +++++ .../wrapper/LibvirtReadyCommandWrapper.java | 34 +++ .../wrapper/LibvirtRequestWrapper.java | 6 + .../LibvirtComputingResourceTest.java | 196 ++++++++++++++++++ 6 files changed, 343 insertions(+), 49 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtAttachIsoCommandWrapper.java create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckVirtualMachineCommandWrapper.java create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtReadyCommandWrapper.java diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 1c7aa2414115..0fb20ee79ac8 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -87,7 +87,6 @@ import com.ceph.rbd.RbdException; import com.ceph.rbd.RbdImage; import com.cloud.agent.api.Answer; -import com.cloud.agent.api.AttachIsoCommand; import com.cloud.agent.api.AttachVolumeAnswer; import com.cloud.agent.api.AttachVolumeCommand; import com.cloud.agent.api.BackupSnapshotAnswer; @@ -95,8 +94,6 @@ import com.cloud.agent.api.CheckNetworkAnswer; import com.cloud.agent.api.CheckNetworkCommand; import com.cloud.agent.api.CheckOnHostCommand; -import com.cloud.agent.api.CheckVirtualMachineAnswer; -import com.cloud.agent.api.CheckVirtualMachineCommand; import com.cloud.agent.api.CleanupNetworkRulesCmd; import com.cloud.agent.api.Command; import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand; @@ -138,8 +135,6 @@ import com.cloud.agent.api.PlugNicAnswer; import com.cloud.agent.api.PlugNicCommand; import com.cloud.agent.api.PvlanSetupCommand; -import com.cloud.agent.api.ReadyAnswer; -import com.cloud.agent.api.ReadyCommand; import com.cloud.agent.api.SecurityGroupRuleAnswer; import com.cloud.agent.api.SecurityGroupRulesCmd; import com.cloud.agent.api.SetupGuestNetworkCommand; @@ -1314,13 +1309,7 @@ public Answer executeRequest(final Command cmd) { } try { - if (cmd instanceof CheckVirtualMachineCommand) { - return execute((CheckVirtualMachineCommand)cmd); - } else if (cmd instanceof ReadyCommand) { - return execute((ReadyCommand)cmd); - } else if (cmd instanceof AttachIsoCommand) { - return execute((AttachIsoCommand)cmd); - } else if (cmd instanceof AttachVolumeCommand) { + if (cmd instanceof AttachVolumeCommand) { return execute((AttachVolumeCommand)cmd); } else if (cmd instanceof CheckConsoleProxyLoadCommand) { return execute((CheckConsoleProxyLoadCommand)cmd); @@ -2951,21 +2940,6 @@ private Answer executeProxyLoadScan(final Command cmd, final long proxyVmId, fin return new ConsoleProxyLoadAnswer(cmd, proxyVmId, proxyVmName, success, result); } - private Answer execute(final AttachIsoCommand cmd) { - try { - final Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); - attachOrDetachISO(conn, cmd.getVmName(), cmd.getIsoPath(), cmd.isAttach()); - } catch (final LibvirtException e) { - return new Answer(cmd, false, e.toString()); - } catch (final URISyntaxException e) { - return new Answer(cmd, false, e.toString()); - } catch (final InternalErrorException e) { - return new Answer(cmd, false, e.toString()); - } - - return new Answer(cmd); - } - private AttachVolumeAnswer execute(final AttachVolumeCommand cmd) { try { final Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); @@ -2983,16 +2957,12 @@ private AttachVolumeAnswer execute(final AttachVolumeCommand cmd) { return new AttachVolumeAnswer(cmd, cmd.getDeviceId(), cmd.getVolumePath()); } - private Answer execute(final ReadyCommand cmd) { - return new ReadyAnswer(cmd); - } - protected PowerState convertToPowerState(final DomainState ps) { final PowerState state = s_powerStatesTable.get(ps); return state == null ? PowerState.PowerUnknown : state; } - protected PowerState getVmState(final Connect conn, final String vmName) { + public PowerState getVmState(final Connect conn, final String vmName) { int retry = 3; Domain vms = null; while (retry-- > 0) { @@ -3015,21 +2985,6 @@ protected PowerState getVmState(final Connect conn, final String vmName) { return PowerState.PowerOff; } - private Answer execute(final CheckVirtualMachineCommand cmd) { - try { - final Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); - final PowerState state = getVmState(conn, cmd.getVmName()); - Integer vncPort = null; - if (state == PowerState.PowerOn) { - vncPort = getVncPort(conn, cmd.getVmName()); - } - - return new CheckVirtualMachineAnswer(cmd, state, vncPort); - } catch (final LibvirtException e) { - return new CheckVirtualMachineAnswer(cmd, e.getMessage()); - } - } - public String networkUsage(final String privateIpAddress, final String option, final String vif) { final Script getUsage = new Script(_routerProxyPath, s_logger); getUsage.add("netusage.sh"); @@ -3719,7 +3674,7 @@ protected KVMStoragePoolManager getPoolManager() { return _storagePoolMgr; } - protected synchronized String attachOrDetachISO(final Connect conn, final String vmName, String isoPath, final boolean isAttach) throws LibvirtException, URISyntaxException, + public synchronized String attachOrDetachISO(final Connect conn, final String vmName, String isoPath, final boolean isAttach) throws LibvirtException, URISyntaxException, InternalErrorException { String isoXml = null; if (isoPath != null && isAttach) { @@ -4948,4 +4903,4 @@ public String mapRbdDevice(final KVMPhysicalDisk disk){ } return device; } -} +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtAttachIsoCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtAttachIsoCommandWrapper.java new file mode 100644 index 000000000000..4380b6664944 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtAttachIsoCommandWrapper.java @@ -0,0 +1,52 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import java.net.URISyntaxException; + +import org.libvirt.Connect; +import org.libvirt.LibvirtException; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.AttachIsoCommand; +import com.cloud.exception.InternalErrorException; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; + +public final class LibvirtAttachIsoCommandWrapper extends CommandWrapper { + + @Override + public Answer execute(final AttachIsoCommand command, final LibvirtComputingResource libvirtComputingResource) { + try { + final LibvirtConnectionWrapper libvirtConnectionWrapper = libvirtComputingResource.getLibvirtConnectionWrapper(); + + final Connect conn = libvirtConnectionWrapper.getConnectionByVmName(command.getVmName()); + libvirtComputingResource.attachOrDetachISO(conn, command.getVmName(), command.getIsoPath(), command.isAttach()); + } catch (final LibvirtException e) { + return new Answer(command, false, e.toString()); + } catch (final URISyntaxException e) { + return new Answer(command, false, e.toString()); + } catch (final InternalErrorException e) { + return new Answer(command, false, e.toString()); + } + + return new Answer(command); + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckVirtualMachineCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckVirtualMachineCommandWrapper.java new file mode 100644 index 000000000000..3ad3300b95b2 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckVirtualMachineCommandWrapper.java @@ -0,0 +1,51 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import org.libvirt.Connect; +import org.libvirt.LibvirtException; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.CheckVirtualMachineAnswer; +import com.cloud.agent.api.CheckVirtualMachineCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; +import com.cloud.vm.VirtualMachine.PowerState; + +public final class LibvirtCheckVirtualMachineCommandWrapper extends CommandWrapper { + + @Override + public Answer execute(final CheckVirtualMachineCommand command, final LibvirtComputingResource libvirtComputingResource) { + try { + final LibvirtConnectionWrapper libvirtConnectionWrapper = libvirtComputingResource.getLibvirtConnectionWrapper(); + + final Connect conn = libvirtConnectionWrapper.getConnectionByVmName(command.getVmName()); + final PowerState state = libvirtComputingResource.getVmState(conn, command.getVmName()); + Integer vncPort = null; + if (state == PowerState.PowerOn) { + vncPort = libvirtComputingResource.getVncPort(conn, command.getVmName()); + } + + return new CheckVirtualMachineAnswer(command, state, vncPort); + } catch (final LibvirtException e) { + return new CheckVirtualMachineAnswer(command, e.getMessage()); + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtReadyCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtReadyCommandWrapper.java new file mode 100644 index 000000000000..7fce9096595d --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtReadyCommandWrapper.java @@ -0,0 +1,34 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.ReadyAnswer; +import com.cloud.agent.api.ReadyCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; + +public final class LibvirtReadyCommandWrapper extends CommandWrapper { + + @Override + public Answer execute(final ReadyCommand command, final LibvirtComputingResource libvirtComputingResource) { + return new ReadyAnswer(command); + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java index aeac43c5d721..ff0a8a56a898 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java @@ -21,7 +21,9 @@ import java.util.Hashtable; import com.cloud.agent.api.Answer; +import com.cloud.agent.api.AttachIsoCommand; import com.cloud.agent.api.CheckHealthCommand; +import com.cloud.agent.api.CheckVirtualMachineCommand; import com.cloud.agent.api.Command; import com.cloud.agent.api.GetHostStatsCommand; import com.cloud.agent.api.GetVmDiskStatsCommand; @@ -29,6 +31,7 @@ import com.cloud.agent.api.MigrateCommand; import com.cloud.agent.api.PingTestCommand; import com.cloud.agent.api.PrepareForMigrationCommand; +import com.cloud.agent.api.ReadyCommand; import com.cloud.agent.api.RebootCommand; import com.cloud.agent.api.RebootRouterCommand; import com.cloud.agent.api.StopCommand; @@ -64,6 +67,9 @@ private void init() { linbvirtCommands.put(PrepareForMigrationCommand.class, new LibvirtPrepareForMigrationCommandWrapper()); linbvirtCommands.put(MigrateCommand.class, new LibvirtMigrateCommandWrapper()); linbvirtCommands.put(PingTestCommand.class, new LibvirtPingTestCommandWrapper()); + linbvirtCommands.put(CheckVirtualMachineCommand.class, new LibvirtCheckVirtualMachineCommandWrapper()); + linbvirtCommands.put(ReadyCommand.class, new LibvirtReadyCommandWrapper()); + linbvirtCommands.put(AttachIsoCommand.class, new LibvirtAttachIsoCommandWrapper()); resources.put(LibvirtComputingResource.class, linbvirtCommands); } diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index 50c8ca68a6d1..f122a2a04421 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -30,6 +30,7 @@ import java.io.ByteArrayInputStream; import java.io.IOException; +import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -63,13 +64,16 @@ import org.xml.sax.SAXException; import com.cloud.agent.api.Answer; +import com.cloud.agent.api.AttachIsoCommand; import com.cloud.agent.api.CheckHealthCommand; +import com.cloud.agent.api.CheckVirtualMachineCommand; import com.cloud.agent.api.GetHostStatsCommand; import com.cloud.agent.api.GetVmDiskStatsCommand; import com.cloud.agent.api.GetVmStatsCommand; import com.cloud.agent.api.MigrateCommand; import com.cloud.agent.api.PingTestCommand; import com.cloud.agent.api.PrepareForMigrationCommand; +import com.cloud.agent.api.ReadyCommand; import com.cloud.agent.api.RebootCommand; import com.cloud.agent.api.RebootRouterCommand; import com.cloud.agent.api.StopCommand; @@ -78,6 +82,7 @@ import com.cloud.agent.api.to.NicTO; import com.cloud.agent.api.to.VirtualMachineTO; import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource; +import com.cloud.exception.InternalErrorException; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef; import com.cloud.hypervisor.kvm.resource.wrapper.LibvirtConnectionWrapper; @@ -88,6 +93,7 @@ import com.cloud.template.VirtualMachineTemplate.BootloaderType; import com.cloud.utils.Pair; import com.cloud.vm.VirtualMachine; +import com.cloud.vm.VirtualMachine.PowerState; @RunWith(PowerMockRunner.class) public class LibvirtComputingResourceTest { @@ -774,4 +780,194 @@ public void testPingOnlyOneIpCommand() { final Answer answer = wrapper.execute(command, libvirtComputingResource); assertFalse(answer.getResult()); } + + @Test + public void testCheckVirtualMachineCommand() { + final Connect conn = Mockito.mock(Connect.class); + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + + final String vmName = "Test"; + final CheckVirtualMachineCommand command = new CheckVirtualMachineCommand(vmName); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + try { + when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenReturn(conn); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + when(libvirtComputingResource.getVmState(conn, command.getVmName())).thenReturn(PowerState.PowerOn); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vmName); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + + @SuppressWarnings("unchecked") + @Test + public void testExceptionCheckVirtualMachineCommand() { + final Connect conn = Mockito.mock(Connect.class); + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + + final String vmName = "Test"; + final CheckVirtualMachineCommand command = new CheckVirtualMachineCommand(vmName); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + try { + when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenThrow(LibvirtException.class); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + when(libvirtComputingResource.getVmState(conn, command.getVmName())).thenReturn(PowerState.PowerOn); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vmName); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + + @Test + public void testReadyCommand() { + final ReadyCommand command = new ReadyCommand(1l); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + } + + @Test + public void testAttachIsoCommand() { + final Connect conn = Mockito.mock(Connect.class); + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + + final String vmName = "Test"; + final AttachIsoCommand command = new AttachIsoCommand(vmName, "/path", true); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + try { + when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenReturn(conn); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vmName); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + + @SuppressWarnings("unchecked") + @Test + public void testAttachIsoCommandLibvirtException() { + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + + final String vmName = "Test"; + final AttachIsoCommand command = new AttachIsoCommand(vmName, "/path", true); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + try { + when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenThrow(LibvirtException.class); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vmName); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + + @SuppressWarnings("unchecked") + @Test + public void testAttachIsoCommandURISyntaxException() { + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + + final String vmName = "Test"; + final AttachIsoCommand command = new AttachIsoCommand(vmName, "/path", true); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + try { + when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenThrow(URISyntaxException.class); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vmName); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + + @SuppressWarnings("unchecked") + @Test + public void testAttachIsoCommandInternalErrorException() { + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + + final String vmName = "Test"; + final AttachIsoCommand command = new AttachIsoCommand(vmName, "/path", true); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + try { + when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenThrow(InternalErrorException.class); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vmName); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } } \ No newline at end of file From 40886b337c953378b93c03c899f801bb24e3aff6 Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Thu, 23 Apr 2015 14:44:13 +0200 Subject: [PATCH 011/175] Refactoring the LibvirtComputingResource - Adding LibvirtAttachVolumeCommandWrapper - 3 unit tests added - KVM hypervisor plugin with 11.7% coverage --- .../resource/LibvirtComputingResource.java | 25 +--- .../LibvirtAttachVolumeCommandWrapper.java | 58 ++++++++ .../wrapper/LibvirtRequestWrapper.java | 2 + .../LibvirtComputingResourceTest.java | 139 ++++++++++++++++++ 4 files changed, 201 insertions(+), 23 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtAttachVolumeCommandWrapper.java diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 0fb20ee79ac8..95b2faffe417 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -87,8 +87,6 @@ import com.ceph.rbd.RbdException; import com.ceph.rbd.RbdImage; import com.cloud.agent.api.Answer; -import com.cloud.agent.api.AttachVolumeAnswer; -import com.cloud.agent.api.AttachVolumeCommand; import com.cloud.agent.api.BackupSnapshotAnswer; import com.cloud.agent.api.BackupSnapshotCommand; import com.cloud.agent.api.CheckNetworkAnswer; @@ -1309,9 +1307,7 @@ public Answer executeRequest(final Command cmd) { } try { - if (cmd instanceof AttachVolumeCommand) { - return execute((AttachVolumeCommand)cmd); - } else if (cmd instanceof CheckConsoleProxyLoadCommand) { + if (cmd instanceof CheckConsoleProxyLoadCommand) { return execute((CheckConsoleProxyLoadCommand)cmd); } else if (cmd instanceof WatchConsoleProxyLoadCommand) { return execute((WatchConsoleProxyLoadCommand)cmd); @@ -2940,23 +2936,6 @@ private Answer executeProxyLoadScan(final Command cmd, final long proxyVmId, fin return new ConsoleProxyLoadAnswer(cmd, proxyVmId, proxyVmName, success, result); } - private AttachVolumeAnswer execute(final AttachVolumeCommand cmd) { - try { - final Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); - final KVMStoragePool primary = _storagePoolMgr.getStoragePool(cmd.getPooltype(), cmd.getPoolUuid()); - final KVMPhysicalDisk disk = primary.getPhysicalDisk(cmd.getVolumePath()); - attachOrDetachDisk(conn, cmd.getAttach(), cmd.getVmName(), disk, - cmd.getDeviceId().intValue(), cmd.getBytesReadRate(), cmd.getBytesWriteRate(), cmd.getIopsReadRate(), cmd.getIopsWriteRate(), - cmd.getCacheMode()); - } catch (final LibvirtException e) { - return new AttachVolumeAnswer(cmd, e.toString()); - } catch (final InternalErrorException e) { - return new AttachVolumeAnswer(cmd, e.toString()); - } - - return new AttachVolumeAnswer(cmd, cmd.getDeviceId(), cmd.getVolumePath()); - } - protected PowerState convertToPowerState(final DomainState ps) { final PowerState state = s_powerStatesTable.get(ps); return state == null ? PowerState.PowerUnknown : state; @@ -3707,7 +3686,7 @@ public synchronized String attachOrDetachISO(final Connect conn, final String vm return result; } - protected synchronized String attachOrDetachDisk(final Connect conn, + public synchronized String attachOrDetachDisk(final Connect conn, final boolean attach, final String vmName, final KVMPhysicalDisk attachingDisk, final int devId, final Long bytesReadRate, final Long bytesWriteRate, final Long iopsReadRate, final Long iopsWriteRate, final String cacheMode) throws LibvirtException, InternalErrorException { List disks = null; diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtAttachVolumeCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtAttachVolumeCommandWrapper.java new file mode 100644 index 000000000000..861bccc28c40 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtAttachVolumeCommandWrapper.java @@ -0,0 +1,58 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import org.libvirt.Connect; +import org.libvirt.LibvirtException; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.AttachVolumeAnswer; +import com.cloud.agent.api.AttachVolumeCommand; +import com.cloud.exception.InternalErrorException; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk; +import com.cloud.hypervisor.kvm.storage.KVMStoragePool; +import com.cloud.resource.CommandWrapper; + +public final class LibvirtAttachVolumeCommandWrapper extends CommandWrapper { + + @Override + public Answer execute(final AttachVolumeCommand command, final LibvirtComputingResource libvirtComputingResource) { + try { + final LibvirtConnectionWrapper libvirtConnectionWrapper = libvirtComputingResource.getLibvirtConnectionWrapper(); + + final Connect conn = libvirtConnectionWrapper.getConnectionByVmName(command.getVmName()); + + final KVMStoragePool primary = libvirtComputingResource.getStoragePoolMgr().getStoragePool(command.getPooltype(), command.getPoolUuid()); + final KVMPhysicalDisk disk = primary.getPhysicalDisk(command.getVolumePath()); + + libvirtComputingResource.attachOrDetachDisk(conn, command.getAttach(), command.getVmName(), disk, + command.getDeviceId().intValue(), command.getBytesReadRate(), command.getBytesWriteRate(), command.getIopsReadRate(), command.getIopsWriteRate(), + command.getCacheMode()); + + } catch (final LibvirtException e) { + return new AttachVolumeAnswer(command, e.toString()); + } catch (final InternalErrorException e) { + return new AttachVolumeAnswer(command, e.toString()); + } + + return new AttachVolumeAnswer(command, command.getDeviceId(), command.getVolumePath()); + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java index ff0a8a56a898..601db130615d 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java @@ -22,6 +22,7 @@ import com.cloud.agent.api.Answer; import com.cloud.agent.api.AttachIsoCommand; +import com.cloud.agent.api.AttachVolumeCommand; import com.cloud.agent.api.CheckHealthCommand; import com.cloud.agent.api.CheckVirtualMachineCommand; import com.cloud.agent.api.Command; @@ -70,6 +71,7 @@ private void init() { linbvirtCommands.put(CheckVirtualMachineCommand.class, new LibvirtCheckVirtualMachineCommandWrapper()); linbvirtCommands.put(ReadyCommand.class, new LibvirtReadyCommandWrapper()); linbvirtCommands.put(AttachIsoCommand.class, new LibvirtAttachIsoCommandWrapper()); + linbvirtCommands.put(AttachVolumeCommand.class, new LibvirtAttachVolumeCommandWrapper()); resources.put(LibvirtComputingResource.class, linbvirtCommands); } diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index f122a2a04421..e274485d920b 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -65,6 +65,7 @@ import com.cloud.agent.api.Answer; import com.cloud.agent.api.AttachIsoCommand; +import com.cloud.agent.api.AttachVolumeCommand; import com.cloud.agent.api.CheckHealthCommand; import com.cloud.agent.api.CheckVirtualMachineCommand; import com.cloud.agent.api.GetHostStatsCommand; @@ -87,8 +88,11 @@ import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef; import com.cloud.hypervisor.kvm.resource.wrapper.LibvirtConnectionWrapper; import com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper; +import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk; +import com.cloud.hypervisor.kvm.storage.KVMStoragePool; import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; import com.cloud.network.Networks.TrafficType; +import com.cloud.storage.Storage.StoragePoolType; import com.cloud.storage.Volume; import com.cloud.template.VirtualMachineTemplate.BootloaderType; import com.cloud.utils.Pair; @@ -970,4 +974,139 @@ public void testAttachIsoCommandInternalErrorException() { fail(e.getMessage()); } } + + @Test + public void testAttachVolumeCommand() { + final Connect conn = Mockito.mock(Connect.class); + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + + final boolean attach = true; + final boolean managed = true; + final String vmName = "Test"; + final StoragePoolType poolType = StoragePoolType.ISO; + final String volumePath = "/path"; + final String volumeName = "volume"; + final Long volumeSize = 200l; + final Long deviceId = 1l; + final String chainInfo = "none"; + final AttachVolumeCommand command = new AttachVolumeCommand(attach, managed, vmName, poolType, volumePath, volumeName, volumeSize, deviceId, chainInfo); + + final KVMStoragePoolManager poolManager = Mockito.mock(KVMStoragePoolManager.class); + final KVMStoragePool primary = Mockito.mock(KVMStoragePool.class); + final KVMPhysicalDisk disk = Mockito.mock(KVMPhysicalDisk.class); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + try { + when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenReturn(conn); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(poolManager); + when(poolManager.getStoragePool(command.getPooltype(), command.getPoolUuid())).thenReturn(primary); + when(primary.getPhysicalDisk(command.getVolumePath())).thenReturn(disk); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vmName); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + + @SuppressWarnings("unchecked") + @Test + public void testAttachVolumeCommandLibvirtException() { + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + + final boolean attach = true; + final boolean managed = true; + final String vmName = "Test"; + final StoragePoolType poolType = StoragePoolType.ISO; + final String volumePath = "/path"; + final String volumeName = "volume"; + final Long volumeSize = 200l; + final Long deviceId = 1l; + final String chainInfo = "none"; + final AttachVolumeCommand command = new AttachVolumeCommand(attach, managed, vmName, poolType, volumePath, volumeName, volumeSize, deviceId, chainInfo); + + final KVMStoragePoolManager poolManager = Mockito.mock(KVMStoragePoolManager.class); + final KVMStoragePool primary = Mockito.mock(KVMStoragePool.class); + final KVMPhysicalDisk disk = Mockito.mock(KVMPhysicalDisk.class); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + try { + when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenThrow(LibvirtException.class); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(poolManager); + when(poolManager.getStoragePool(command.getPooltype(), command.getPoolUuid())).thenReturn(primary); + when(primary.getPhysicalDisk(command.getVolumePath())).thenReturn(disk); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vmName); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + + @SuppressWarnings("unchecked") + @Test + public void testAttachVolumeCommandInternalErrorException() { + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + + final boolean attach = true; + final boolean managed = true; + final String vmName = "Test"; + final StoragePoolType poolType = StoragePoolType.ISO; + final String volumePath = "/path"; + final String volumeName = "volume"; + final Long volumeSize = 200l; + final Long deviceId = 1l; + final String chainInfo = "none"; + final AttachVolumeCommand command = new AttachVolumeCommand(attach, managed, vmName, poolType, volumePath, volumeName, volumeSize, deviceId, chainInfo); + + final KVMStoragePoolManager poolManager = Mockito.mock(KVMStoragePoolManager.class); + final KVMStoragePool primary = Mockito.mock(KVMStoragePool.class); + final KVMPhysicalDisk disk = Mockito.mock(KVMPhysicalDisk.class); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + try { + when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenThrow(InternalErrorException.class); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(poolManager); + when(poolManager.getStoragePool(command.getPooltype(), command.getPoolUuid())).thenReturn(primary); + when(primary.getPhysicalDisk(command.getVolumePath())).thenReturn(disk); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vmName); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } } \ No newline at end of file From 08a9523dcdd5b4d736c4ef29b9ea93daa2b6e400 Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Thu, 23 Apr 2015 14:46:09 +0200 Subject: [PATCH 012/175] Fixing assertion on the tests that are execting exceptions --- .../hypervisor/kvm/resource/LibvirtComputingResourceTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index e274485d920b..75ce22131f0e 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -1055,7 +1055,7 @@ public void testAttachVolumeCommandLibvirtException() { assertNotNull(wrapper); final Answer answer = wrapper.execute(command, libvirtComputingResource); - assertTrue(answer.getResult()); + assertFalse(answer.getResult()); verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { @@ -1100,7 +1100,7 @@ public void testAttachVolumeCommandInternalErrorException() { assertNotNull(wrapper); final Answer answer = wrapper.execute(command, libvirtComputingResource); - assertTrue(answer.getResult()); + assertFalse(answer.getResult()); verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { From 7319a12600a7823aef8167348ee66a74a43ede8b Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Fri, 24 Apr 2015 11:49:00 +0200 Subject: [PATCH 013/175] Refactoring the LibvirtComputingResource - Adding LibvirtCheckConsoleProxyLoadCommandWrapper, LibvirtConsoleProxyLoadCommandWrapper, LibvirtWatchConsoleProxyLoadCommandWrapperand CitrixConsoleProxyLoadCommandWrapper - 2 unit tests added - KVM hypervisor plugin with 12% coverage Refactored the CommandWrapper interface in order to remove the esecuteProxyLoadScan, which is now implemented bu subclasses. --- .../com/cloud/resource/CommandWrapper.java | 65 --------------- .../resource/LibvirtComputingResource.java | 59 +------------ ...rtCheckConsoleProxyLoadCommandWrapper.java | 41 +++++++++ ...LibvirtConsoleProxyLoadCommandWrapper.java | 78 +++++++++++++++++ .../wrapper/LibvirtRequestWrapper.java | 4 + ...rtWatchConsoleProxyLoadCommandWrapper.java | 41 +++++++++ .../LibvirtComputingResourceTest.java | 35 ++++++++ ...ixCheckConsoleProxyLoadCommandWrapper.java | 17 ++-- .../CitrixConsoleProxyLoadCommandWrapper.java | 83 +++++++++++++++++++ ...ixWatchConsoleProxyLoadCommandWrapper.java | 17 ++-- 10 files changed, 303 insertions(+), 137 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckConsoleProxyLoadCommandWrapper.java create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConsoleProxyLoadCommandWrapper.java create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtWatchConsoleProxyLoadCommandWrapper.java create mode 100644 plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixConsoleProxyLoadCommandWrapper.java diff --git a/core/src/com/cloud/resource/CommandWrapper.java b/core/src/com/cloud/resource/CommandWrapper.java index 48c105f55754..f68e92a2327e 100644 --- a/core/src/com/cloud/resource/CommandWrapper.java +++ b/core/src/com/cloud/resource/CommandWrapper.java @@ -19,81 +19,16 @@ package com.cloud.resource; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; -import java.net.URLConnection; -import java.nio.charset.Charset; - -import org.apache.log4j.Logger; - import com.cloud.agent.api.Answer; import com.cloud.agent.api.Command; -import com.cloud.agent.api.proxy.ConsoleProxyLoadAnswer; public abstract class CommandWrapper { - private static final Logger s_logger = Logger.getLogger(CommandWrapper.class); - /** * @param T is the command to be used. * @param R is the resource base to be used. * @return A and the Answer from the command. */ public abstract A execute(T command, R serverResource); - - /** - * Common method so we added it here. - * - * @param cmd - * @param proxyVmId - * @param proxyVmName - * @param proxyManagementIp - * @param cmdPort - * @return - */ - protected Answer executeProxyLoadScan(final Command cmd, final long proxyVmId, final String proxyVmName, final String proxyManagementIp, final int cmdPort) { - String result = null; - - final StringBuffer sb = new StringBuffer(); - sb.append("http://").append(proxyManagementIp).append(":" + cmdPort).append("/cmd/getstatus"); - - boolean success = true; - try { - final URL url = new URL(sb.toString()); - final URLConnection conn = url.openConnection(); - - // setting TIMEOUTs to avoid possible waiting until death situations - conn.setConnectTimeout(5000); - conn.setReadTimeout(5000); - - final InputStream is = conn.getInputStream(); - final BufferedReader reader = new BufferedReader(new InputStreamReader(is, Charset.defaultCharset())); - final StringBuilder sb2 = new StringBuilder(); - String line = null; - try { - while ((line = reader.readLine()) != null) { - sb2.append(line + "\n"); - } - result = sb2.toString(); - } catch (final IOException e) { - success = false; - } finally { - try { - is.close(); - } catch (final IOException e) { - s_logger.warn("Exception when closing , console proxy address : " + proxyManagementIp); - success = false; - } - } - } catch (final IOException e) { - s_logger.warn("Unable to open console proxy command port url, console proxy address : " + proxyManagementIp); - success = false; - } - - return new ConsoleProxyLoadAnswer(cmd, proxyVmId, proxyVmName, success, result); - } } \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 95b2faffe417..07cb4ddeedfd 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -23,14 +23,10 @@ import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; import java.io.Reader; import java.net.InetAddress; import java.net.URI; import java.net.URISyntaxException; -import java.net.URL; -import java.net.URLConnection; import java.text.DateFormat; import java.text.MessageFormat; import java.text.SimpleDateFormat; @@ -148,9 +144,6 @@ import com.cloud.agent.api.VmStatsEntry; import com.cloud.agent.api.check.CheckSshAnswer; import com.cloud.agent.api.check.CheckSshCommand; -import com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand; -import com.cloud.agent.api.proxy.ConsoleProxyLoadAnswer; -import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand; import com.cloud.agent.api.routing.IpAssocCommand; import com.cloud.agent.api.routing.IpAssocVpcCommand; import com.cloud.agent.api.routing.NetworkElementCommand; @@ -1307,11 +1300,7 @@ public Answer executeRequest(final Command cmd) { } try { - if (cmd instanceof CheckConsoleProxyLoadCommand) { - return execute((CheckConsoleProxyLoadCommand)cmd); - } else if (cmd instanceof WatchConsoleProxyLoadCommand) { - return execute((WatchConsoleProxyLoadCommand)cmd); - } else if (cmd instanceof GetVncPortCommand) { + if (cmd instanceof GetVncPortCommand) { return execute((GetVncPortCommand)cmd); } else if (cmd instanceof ModifySshKeysCommand) { return execute((ModifySshKeysCommand)cmd); @@ -2886,56 +2875,10 @@ protected GetVncPortAnswer execute(final GetVncPortCommand cmd) { } } - protected Answer execute(final CheckConsoleProxyLoadCommand cmd) { - return executeProxyLoadScan(cmd, cmd.getProxyVmId(), cmd.getProxyVmName(), cmd.getProxyManagementIp(), cmd.getProxyCmdPort()); - } - - protected Answer execute(final WatchConsoleProxyLoadCommand cmd) { - return executeProxyLoadScan(cmd, cmd.getProxyVmId(), cmd.getProxyVmName(), cmd.getProxyManagementIp(), cmd.getProxyCmdPort()); - } - protected MaintainAnswer execute(final MaintainCommand cmd) { return new MaintainAnswer(cmd); } - private Answer executeProxyLoadScan(final Command cmd, final long proxyVmId, final String proxyVmName, final String proxyManagementIp, final int cmdPort) { - String result = null; - - final StringBuffer sb = new StringBuffer(); - sb.append("http://").append(proxyManagementIp).append(":" + cmdPort).append("/cmd/getstatus"); - - boolean success = true; - try { - final URL url = new URL(sb.toString()); - final URLConnection conn = url.openConnection(); - - final InputStream is = conn.getInputStream(); - final BufferedReader reader = new BufferedReader(new InputStreamReader(is)); - final StringBuilder sb2 = new StringBuilder(); - String line = null; - try { - while ((line = reader.readLine()) != null) { - sb2.append(line + "\n"); - } - result = sb2.toString(); - } catch (final IOException e) { - success = false; - } finally { - try { - is.close(); - } catch (final IOException e) { - s_logger.warn("Exception when closing , console proxy address : " + proxyManagementIp); - success = false; - } - } - } catch (final IOException e) { - s_logger.warn("Unable to open console proxy command port url, console proxy address : " + proxyManagementIp); - success = false; - } - - return new ConsoleProxyLoadAnswer(cmd, proxyVmId, proxyVmName, success, result); - } - protected PowerState convertToPowerState(final DomainState ps) { final PowerState state = s_powerStatesTable.get(ps); return state == null ? PowerState.PowerUnknown : state; diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckConsoleProxyLoadCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckConsoleProxyLoadCommandWrapper.java new file mode 100644 index 000000000000..1267984069dc --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckConsoleProxyLoadCommandWrapper.java @@ -0,0 +1,41 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.Command; +import com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.ServerResource; + +public class LibvirtCheckConsoleProxyLoadCommandWrapper extends LibvirtConsoleProxyLoadCommandWrapper { + + @Override + public Answer execute(final Command command, final ServerResource serverResource) { + final CheckConsoleProxyLoadCommand cmd = (CheckConsoleProxyLoadCommand) command; + + final long proxyVmId = cmd.getProxyVmId(); + final String proxyVmName = cmd.getProxyVmName(); + final String proxyManagementIp = cmd.getProxyManagementIp(); + final int proxyCmdPort = cmd.getProxyCmdPort(); + + return executeProxyLoadScan(cmd, proxyVmId, proxyVmName, proxyManagementIp, proxyCmdPort); + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConsoleProxyLoadCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConsoleProxyLoadCommandWrapper.java new file mode 100644 index 000000000000..125a295eb903 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConsoleProxyLoadCommandWrapper.java @@ -0,0 +1,78 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLConnection; + +import org.apache.log4j.Logger; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.Command; +import com.cloud.agent.api.proxy.ConsoleProxyLoadAnswer; +import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ServerResource; + +public abstract class LibvirtConsoleProxyLoadCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtConsoleProxyLoadCommandWrapper.class); + + public Answer executeProxyLoadScan(final Command cmd, final long proxyVmId, final String proxyVmName, final String proxyManagementIp, final int cmdPort) { + String result = null; + + final StringBuffer sb = new StringBuffer(); + sb.append("http://").append(proxyManagementIp).append(":" + cmdPort).append("/cmd/getstatus"); + + boolean success = true; + try { + final URL url = new URL(sb.toString()); + final URLConnection conn = url.openConnection(); + + final InputStream is = conn.getInputStream(); + final BufferedReader reader = new BufferedReader(new InputStreamReader(is)); + final StringBuilder sb2 = new StringBuilder(); + String line = null; + try { + while ((line = reader.readLine()) != null) { + sb2.append(line + "\n"); + } + result = sb2.toString(); + } catch (final IOException e) { + success = false; + } finally { + try { + is.close(); + } catch (final IOException e) { + s_logger.warn("Exception when closing , console proxy address : " + proxyManagementIp); + success = false; + } + } + } catch (final IOException e) { + s_logger.warn("Unable to open console proxy command port url, console proxy address : " + proxyManagementIp); + success = false; + } + + return new ConsoleProxyLoadAnswer(cmd, proxyVmId, proxyVmName, success, result); + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java index 601db130615d..72d3a874c6b4 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java @@ -36,6 +36,8 @@ import com.cloud.agent.api.RebootCommand; import com.cloud.agent.api.RebootRouterCommand; import com.cloud.agent.api.StopCommand; +import com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand; +import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; import com.cloud.resource.RequestWrapper; @@ -72,6 +74,8 @@ private void init() { linbvirtCommands.put(ReadyCommand.class, new LibvirtReadyCommandWrapper()); linbvirtCommands.put(AttachIsoCommand.class, new LibvirtAttachIsoCommandWrapper()); linbvirtCommands.put(AttachVolumeCommand.class, new LibvirtAttachVolumeCommandWrapper()); + linbvirtCommands.put(WatchConsoleProxyLoadCommand.class, new LibvirtWatchConsoleProxyLoadCommandWrapper()); + linbvirtCommands.put(CheckConsoleProxyLoadCommand.class, new LibvirtCheckConsoleProxyLoadCommandWrapper()); resources.put(LibvirtComputingResource.class, linbvirtCommands); } diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtWatchConsoleProxyLoadCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtWatchConsoleProxyLoadCommandWrapper.java new file mode 100644 index 000000000000..62fff110714b --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtWatchConsoleProxyLoadCommandWrapper.java @@ -0,0 +1,41 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.Command; +import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.ServerResource; + +public class LibvirtWatchConsoleProxyLoadCommandWrapper extends LibvirtConsoleProxyLoadCommandWrapper { + + @Override + public Answer execute(final Command command, final ServerResource serverResource) { + final WatchConsoleProxyLoadCommand cmd = (WatchConsoleProxyLoadCommand) command; + + final long proxyVmId = cmd.getProxyVmId(); + final String proxyVmName = cmd.getProxyVmName(); + final String proxyManagementIp = cmd.getProxyManagementIp(); + final int proxyCmdPort = cmd.getProxyCmdPort(); + + return executeProxyLoadScan(cmd, proxyVmId, proxyVmName, proxyManagementIp, proxyCmdPort); + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index 75ce22131f0e..8f56ee052e69 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -79,6 +79,8 @@ import com.cloud.agent.api.RebootRouterCommand; import com.cloud.agent.api.StopCommand; import com.cloud.agent.api.VmStatsEntry; +import com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand; +import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand; import com.cloud.agent.api.to.DiskTO; import com.cloud.agent.api.to.NicTO; import com.cloud.agent.api.to.VirtualMachineTO; @@ -1109,4 +1111,37 @@ public void testAttachVolumeCommandInternalErrorException() { fail(e.getMessage()); } } + + @Test + public void testWatchConsoleProxyLoadCommand() { + final int interval = 0; + final long proxyVmId = 0l; + final String proxyVmName = "host"; + final String proxyManagementIp = "169.172.15.16"; + final int proxyCmdPort = 0; + + final WatchConsoleProxyLoadCommand command = new WatchConsoleProxyLoadCommand(interval, proxyVmId, proxyVmName, proxyManagementIp, proxyCmdPort); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + } + + @Test + public void testCheckConsoleProxyLoadCommand() { + final long proxyVmId = 0l; + final String proxyVmName = "host"; + final String proxyManagementIp = "169.172.15.16"; + final int proxyCmdPort = 0; + + final CheckConsoleProxyLoadCommand command = new CheckConsoleProxyLoadCommand(proxyVmId, proxyVmName, proxyManagementIp, proxyCmdPort); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + } } \ No newline at end of file diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckConsoleProxyLoadCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckConsoleProxyLoadCommandWrapper.java index bdf7c319a59c..08d36b3d995e 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckConsoleProxyLoadCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckConsoleProxyLoadCommandWrapper.java @@ -20,18 +20,21 @@ package com.cloud.hypervisor.xenserver.resource.wrapper; import com.cloud.agent.api.Answer; +import com.cloud.agent.api.Command; import com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; -import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ServerResource; -public final class CitrixCheckConsoleProxyLoadCommandWrapper extends CommandWrapper { +public final class CitrixCheckConsoleProxyLoadCommandWrapper extends CitrixConsoleProxyLoadCommandWrapper { @Override - public Answer execute(final CheckConsoleProxyLoadCommand command, final CitrixResourceBase citrixResourceBase) { - final long proxyVmId = command.getProxyVmId(); - final String proxyVmName = command.getProxyVmName(); - final String proxyManagementIp = command.getProxyManagementIp(); - final int cmdPort = command.getProxyCmdPort(); + public Answer execute(final Command command, final ServerResource serverResource) { + final CheckConsoleProxyLoadCommand cmd = (CheckConsoleProxyLoadCommand) command; + + final long proxyVmId = cmd.getProxyVmId(); + final String proxyVmName = cmd.getProxyVmName(); + final String proxyManagementIp = cmd.getProxyManagementIp(); + final int cmdPort = cmd.getProxyCmdPort(); return executeProxyLoadScan(command, proxyVmId, proxyVmName, proxyManagementIp, cmdPort); } diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixConsoleProxyLoadCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixConsoleProxyLoadCommandWrapper.java new file mode 100644 index 000000000000..4e71b0e1237a --- /dev/null +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixConsoleProxyLoadCommandWrapper.java @@ -0,0 +1,83 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.xenserver.resource.wrapper; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLConnection; +import java.nio.charset.Charset; + +import org.apache.log4j.Logger; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.Command; +import com.cloud.agent.api.proxy.ConsoleProxyLoadAnswer; +import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ServerResource; + +public abstract class CitrixConsoleProxyLoadCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(CitrixConsoleProxyLoadCommandWrapper.class); + + protected Answer executeProxyLoadScan(final Command cmd, final long proxyVmId, final String proxyVmName, final String proxyManagementIp, final int cmdPort) { + String result = null; + + final StringBuffer sb = new StringBuffer(); + sb.append("http://").append(proxyManagementIp).append(":" + cmdPort).append("/cmd/getstatus"); + + boolean success = true; + try { + final URL url = new URL(sb.toString()); + final URLConnection conn = url.openConnection(); + + // setting TIMEOUTs to avoid possible waiting until death situations + conn.setConnectTimeout(5000); + conn.setReadTimeout(5000); + + final InputStream is = conn.getInputStream(); + final BufferedReader reader = new BufferedReader(new InputStreamReader(is, Charset.defaultCharset())); + final StringBuilder sb2 = new StringBuilder(); + String line = null; + try { + while ((line = reader.readLine()) != null) { + sb2.append(line + "\n"); + } + result = sb2.toString(); + } catch (final IOException e) { + success = false; + } finally { + try { + is.close(); + } catch (final IOException e) { + s_logger.warn("Exception when closing , console proxy address : " + proxyManagementIp); + success = false; + } + } + } catch (final IOException e) { + s_logger.warn("Unable to open console proxy command port url, console proxy address : " + proxyManagementIp); + success = false; + } + + return new ConsoleProxyLoadAnswer(cmd, proxyVmId, proxyVmName, success, result); + } +} \ No newline at end of file diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixWatchConsoleProxyLoadCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixWatchConsoleProxyLoadCommandWrapper.java index 4ee961402f97..f188c20a30dc 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixWatchConsoleProxyLoadCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixWatchConsoleProxyLoadCommandWrapper.java @@ -20,18 +20,21 @@ package com.cloud.hypervisor.xenserver.resource.wrapper; import com.cloud.agent.api.Answer; +import com.cloud.agent.api.Command; import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; -import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ServerResource; -public final class CitrixWatchConsoleProxyLoadCommandWrapper extends CommandWrapper { +public final class CitrixWatchConsoleProxyLoadCommandWrapper extends CitrixConsoleProxyLoadCommandWrapper { @Override - public Answer execute(final WatchConsoleProxyLoadCommand command, final CitrixResourceBase citrixResourceBase) { - final long proxyVmId = command.getProxyVmId(); - final String proxyVmName = command.getProxyVmName(); - final String proxyManagementIp = command.getProxyManagementIp(); - final int cmdPort = command.getProxyCmdPort(); + public Answer execute(final Command command, final ServerResource serverResource) { + final WatchConsoleProxyLoadCommand cmd = (WatchConsoleProxyLoadCommand) command; + + final long proxyVmId = cmd.getProxyVmId(); + final String proxyVmName = cmd.getProxyVmName(); + final String proxyManagementIp = cmd.getProxyManagementIp(); + final int cmdPort = cmd.getProxyCmdPort(); return executeProxyLoadScan(command, proxyVmId, proxyVmName, proxyManagementIp, cmdPort); } From f14c7c207494c1c01d73713f6a2c4ab5452d07e9 Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Fri, 24 Apr 2015 13:17:58 +0200 Subject: [PATCH 014/175] Refactoring the LibvirtComputingResource - Adding LibvirtGetVncPortCommandWrapper - 2 unit tests added - KVM hypervisor plugin with 12.1% coverage --- .../resource/LibvirtComputingResource.java | 16 +----- .../LibvirtGetVncPortCommandWrapper.java | 45 +++++++++++++++ .../wrapper/LibvirtRequestWrapper.java | 2 + .../LibvirtComputingResourceTest.java | 57 +++++++++++++++++++ 4 files changed, 105 insertions(+), 15 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVncPortCommandWrapper.java diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 07cb4ddeedfd..788a3e4bde82 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -100,8 +100,6 @@ import com.cloud.agent.api.FenceCommand; import com.cloud.agent.api.GetStorageStatsAnswer; import com.cloud.agent.api.GetStorageStatsCommand; -import com.cloud.agent.api.GetVncPortAnswer; -import com.cloud.agent.api.GetVncPortCommand; import com.cloud.agent.api.HostVmStateReportEntry; import com.cloud.agent.api.MaintainAnswer; import com.cloud.agent.api.MaintainCommand; @@ -1300,9 +1298,7 @@ public Answer executeRequest(final Command cmd) { } try { - if (cmd instanceof GetVncPortCommand) { - return execute((GetVncPortCommand)cmd); - } else if (cmd instanceof ModifySshKeysCommand) { + if (cmd instanceof ModifySshKeysCommand) { return execute((ModifySshKeysCommand)cmd); } else if (cmd instanceof MaintainCommand) { return execute((MaintainCommand)cmd); @@ -2865,16 +2861,6 @@ private Answer execute(final CleanupNetworkRulesCmd cmd) { return new Answer(cmd, result, ""); } - protected GetVncPortAnswer execute(final GetVncPortCommand cmd) { - try { - final Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getName()); - final Integer vncPort = getVncPort(conn, cmd.getName()); - return new GetVncPortAnswer(cmd, _privateIp, 5900 + vncPort); - } catch (final LibvirtException e) { - return new GetVncPortAnswer(cmd, e.toString()); - } - } - protected MaintainAnswer execute(final MaintainCommand cmd) { return new MaintainAnswer(cmd); } diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVncPortCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVncPortCommandWrapper.java new file mode 100644 index 000000000000..9b76374d4c33 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVncPortCommandWrapper.java @@ -0,0 +1,45 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import org.libvirt.Connect; +import org.libvirt.LibvirtException; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.GetVncPortAnswer; +import com.cloud.agent.api.GetVncPortCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; + +public final class LibvirtGetVncPortCommandWrapper extends CommandWrapper { + + @Override + public Answer execute(final GetVncPortCommand command, final LibvirtComputingResource libvirtComputingResource) { + try { + final LibvirtConnectionWrapper libvirtConnectionWrapper = libvirtComputingResource.getLibvirtConnectionWrapper(); + + final Connect conn = libvirtConnectionWrapper.getConnectionByVmName(command.getName()); + final Integer vncPort = libvirtComputingResource.getVncPort(conn, command.getName()); + return new GetVncPortAnswer(command, libvirtComputingResource.getPrivateIp(), 5900 + vncPort); + } catch (final LibvirtException e) { + return new GetVncPortAnswer(command, e.toString()); + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java index 72d3a874c6b4..daa5a0ca39ff 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java @@ -29,6 +29,7 @@ import com.cloud.agent.api.GetHostStatsCommand; import com.cloud.agent.api.GetVmDiskStatsCommand; import com.cloud.agent.api.GetVmStatsCommand; +import com.cloud.agent.api.GetVncPortCommand; import com.cloud.agent.api.MigrateCommand; import com.cloud.agent.api.PingTestCommand; import com.cloud.agent.api.PrepareForMigrationCommand; @@ -76,6 +77,7 @@ private void init() { linbvirtCommands.put(AttachVolumeCommand.class, new LibvirtAttachVolumeCommandWrapper()); linbvirtCommands.put(WatchConsoleProxyLoadCommand.class, new LibvirtWatchConsoleProxyLoadCommandWrapper()); linbvirtCommands.put(CheckConsoleProxyLoadCommand.class, new LibvirtCheckConsoleProxyLoadCommandWrapper()); + linbvirtCommands.put(GetVncPortCommand.class, new LibvirtGetVncPortCommandWrapper()); resources.put(LibvirtComputingResource.class, linbvirtCommands); } diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index 8f56ee052e69..09a9e369687b 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -71,6 +71,7 @@ import com.cloud.agent.api.GetHostStatsCommand; import com.cloud.agent.api.GetVmDiskStatsCommand; import com.cloud.agent.api.GetVmStatsCommand; +import com.cloud.agent.api.GetVncPortCommand; import com.cloud.agent.api.MigrateCommand; import com.cloud.agent.api.PingTestCommand; import com.cloud.agent.api.PrepareForMigrationCommand; @@ -1144,4 +1145,60 @@ public void testCheckConsoleProxyLoadCommand() { final Answer answer = wrapper.execute(command, libvirtComputingResource); assertFalse(answer.getResult()); } + + @Test + public void testGetVncPortCommand() { + final Connect conn = Mockito.mock(Connect.class); + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + + final GetVncPortCommand command = new GetVncPortCommand(1l, "host"); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + try { + when(libvirtConnectionWrapper.getConnectionByVmName(command.getName())).thenReturn(conn); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getName()); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + + @SuppressWarnings("unchecked") + @Test + public void testGetVncPortCommandLibvirtException() { + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + + final GetVncPortCommand command = new GetVncPortCommand(1l, "host"); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + try { + when(libvirtConnectionWrapper.getConnectionByVmName(command.getName())).thenThrow(LibvirtException.class); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getName()); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } } \ No newline at end of file From 6f757c6bf062d75c726f12dac49548dad9104cd0 Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Wed, 29 Apr 2015 15:24:18 +0200 Subject: [PATCH 015/175] Refactoring the LibvirtComputingResource - Adding LibvirtModifySshKeysCommandWrapper - 1 unit test added - KVM hypervisor plugin with 12.3% coverage --- .../resource/LibvirtComputingResource.java | 210 ++++++------------ .../LibvirtModifySshKeysCommandWrapper.java | 112 ++++++++++ .../wrapper/LibvirtRequestWrapper.java | 2 + .../LibvirtComputingResourceTest.java | 16 ++ 4 files changed, 201 insertions(+), 139 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtModifySshKeysCommandWrapper.java diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 788a3e4bde82..62c714892291 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -105,7 +105,6 @@ import com.cloud.agent.api.MaintainCommand; import com.cloud.agent.api.ManageSnapshotAnswer; import com.cloud.agent.api.ManageSnapshotCommand; -import com.cloud.agent.api.ModifySshKeysCommand; import com.cloud.agent.api.ModifyStoragePoolAnswer; import com.cloud.agent.api.ModifyStoragePoolCommand; import com.cloud.agent.api.NetworkRulesSystemVmCommand; @@ -279,19 +278,82 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv private long _hvVersion; private long _kernelVersion; + private int _timeout; + private KVMHAMonitor _monitor; - private static final String SSHKEYSPATH = "/root/.ssh"; - private static final String SSHPRVKEYPATH = SSHKEYSPATH + File.separator + "id_rsa.cloud"; - private static final String SSHPUBKEYPATH = SSHKEYSPATH + File.separator + "id_rsa.pub.cloud"; + public static final String SSHKEYSPATH = "/root/.ssh"; + public static final String SSHPRVKEYPATH = SSHKEYSPATH + File.separator + "id_rsa.cloud"; + public static final String SSHPUBKEYPATH = SSHKEYSPATH + File.separator + "id_rsa.pub.cloud"; + private String _mountPoint = "/mnt"; StorageLayer _storage; private KVMStoragePoolManager _storagePoolMgr; private VifDriver _defaultVifDriver; private Map _trafficTypeVifDrivers; + protected static final String DEFAULT_OVS_VIF_DRIVER_CLASS_NAME = "com.cloud.hypervisor.kvm.resource.OvsVifDriver"; protected static final String DEFAULT_BRIDGE_VIF_DRIVER_CLASS_NAME = "com.cloud.hypervisor.kvm.resource.BridgeVifDriver"; + protected HypervisorType _hypervisorType; + protected String _hypervisorURI; + protected long _hypervisorLibvirtVersion; + protected long _hypervisorQemuVersion; + protected String _hypervisorPath; + protected String _networkDirectSourceMode; + protected String _networkDirectDevice; + protected String _sysvmISOPath; + protected String _privNwName; + protected String _privBridgeName; + protected String _linkLocalBridgeName; + protected String _publicBridgeName; + protected String _guestBridgeName; + protected String _privateIp; + protected String _pool; + protected String _localGateway; + private boolean _canBridgeFirewall; + protected String _localStoragePath; + protected String _localStorageUUID; + protected boolean _noMemBalloon = false; + protected String _guestCpuMode; + protected String _guestCpuModel; + protected boolean _noKvmClock; + protected String _videoHw; + protected int _videoRam; + protected Pair hostOsVersion; + protected int _migrateSpeed; + protected int _migrateDowntime; + protected int _migratePauseAfter; + + private final Map _pifs = new HashMap(); + private final Map _vmStats = new ConcurrentHashMap(); + + protected static final MessageFormat SnapshotXML = new MessageFormat(" " + " {0}" + " " + + " {1}" + " " + " "); + + protected static final HashMap s_powerStatesTable; + static { + s_powerStatesTable = new HashMap(); + s_powerStatesTable.put(DomainState.VIR_DOMAIN_SHUTOFF, PowerState.PowerOff); + s_powerStatesTable.put(DomainState.VIR_DOMAIN_PAUSED, PowerState.PowerOn); + s_powerStatesTable.put(DomainState.VIR_DOMAIN_RUNNING, PowerState.PowerOn); + s_powerStatesTable.put(DomainState.VIR_DOMAIN_BLOCKED, PowerState.PowerOn); + s_powerStatesTable.put(DomainState.VIR_DOMAIN_NOSTATE, PowerState.PowerUnknown); + s_powerStatesTable.put(DomainState.VIR_DOMAIN_SHUTDOWN, PowerState.PowerOff); + } + + protected List _vmsKilled = new ArrayList(); + + private VirtualRoutingResource _virtRouterResource; + + private String _pingTestPath; + + private int _dom0MinMem; + + protected boolean _disconnected = true; + protected int _cmdsTimeout; + protected int _stopTimeout; + @Inject private LibvirtConnectionWrapper libvirtConnectionWrapper; @@ -392,6 +454,10 @@ public String getPingTestPath() { return _pingTestPath; } + public int getTimeout() { + return _timeout; + } + private static final class KeyValueInterpreter extends OutputInterpreter { private final Map map = new HashMap(); @@ -424,66 +490,7 @@ protected String getDefaultScriptsDir() { return null; } - protected static final MessageFormat SnapshotXML = new MessageFormat(" " + " {0}" + " " - + " {1}" + " " + " "); - - protected HypervisorType _hypervisorType; - protected String _hypervisorURI; - protected long _hypervisorLibvirtVersion; - protected long _hypervisorQemuVersion; - protected String _hypervisorPath; - protected String _networkDirectSourceMode; - protected String _networkDirectDevice; - protected String _sysvmISOPath; - protected String _privNwName; - protected String _privBridgeName; - protected String _linkLocalBridgeName; - protected String _publicBridgeName; - protected String _guestBridgeName; - protected String _privateIp; - protected String _pool; - protected String _localGateway; - private boolean _canBridgeFirewall; - protected String _localStoragePath; - protected String _localStorageUUID; - protected boolean _noMemBalloon = false; - protected String _guestCpuMode; - protected String _guestCpuModel; protected List _cpuFeatures; - protected boolean _noKvmClock; - protected String _videoHw; - protected int _videoRam; - protected Pair hostOsVersion; - protected int _migrateSpeed; - protected int _migrateDowntime; - protected int _migratePauseAfter; - - private final Map _pifs = new HashMap(); - private final Map _vmStats = new ConcurrentHashMap(); - - protected boolean _disconnected = true; - protected int _timeout; - protected int _cmdsTimeout; - protected int _stopTimeout; - - protected static final HashMap s_powerStatesTable; - static { - s_powerStatesTable = new HashMap(); - s_powerStatesTable.put(DomainState.VIR_DOMAIN_SHUTOFF, PowerState.PowerOff); - s_powerStatesTable.put(DomainState.VIR_DOMAIN_PAUSED, PowerState.PowerOn); - s_powerStatesTable.put(DomainState.VIR_DOMAIN_RUNNING, PowerState.PowerOn); - s_powerStatesTable.put(DomainState.VIR_DOMAIN_BLOCKED, PowerState.PowerOn); - s_powerStatesTable.put(DomainState.VIR_DOMAIN_NOSTATE, PowerState.PowerUnknown); - s_powerStatesTable.put(DomainState.VIR_DOMAIN_SHUTDOWN, PowerState.PowerOff); - } - - protected List _vmsKilled = new ArrayList(); - - private VirtualRoutingResource _virtRouterResource; - - private String _pingTestPath; - - private int _dom0MinMem; protected enum BridgeType { NATIVE, OPENVSWITCH @@ -1298,9 +1305,7 @@ public Answer executeRequest(final Command cmd) { } try { - if (cmd instanceof ModifySshKeysCommand) { - return execute((ModifySshKeysCommand)cmd); - } else if (cmd instanceof MaintainCommand) { + if (cmd instanceof MaintainCommand) { return execute((MaintainCommand)cmd); } else if (cmd instanceof CreateCommand) { return execute((CreateCommand)cmd); @@ -3001,79 +3006,6 @@ private Answer execute(final NetworkUsageCommand cmd) { } } - protected Answer execute(final ModifySshKeysCommand cmd) { - final File sshKeysDir = new File(SSHKEYSPATH); - String result = null; - if (!sshKeysDir.exists()) { - // Change permissions for the 700 - final Script script = new Script("mkdir", _timeout, s_logger); - script.add("-m", "700"); - script.add(SSHKEYSPATH); - script.execute(); - - if (!sshKeysDir.exists()) { - s_logger.debug("failed to create directory " + SSHKEYSPATH); - } - } - - final File pubKeyFile = new File(SSHPUBKEYPATH); - if (!pubKeyFile.exists()) { - try { - pubKeyFile.createNewFile(); - } catch (final IOException e) { - result = "Failed to create file: " + e.toString(); - s_logger.debug(result); - } - } - - if (pubKeyFile.exists()) { - try (FileOutputStream pubkStream = new FileOutputStream(pubKeyFile)) { - pubkStream.write(cmd.getPubKey().getBytes()); - } catch (final FileNotFoundException e) { - result = "File" + SSHPUBKEYPATH + "is not found:" - + e.toString(); - s_logger.debug(result); - } catch (final IOException e) { - result = "Write file " + SSHPUBKEYPATH + ":" + e.toString(); - s_logger.debug(result); - } - } - - final File prvKeyFile = new File(SSHPRVKEYPATH); - if (!prvKeyFile.exists()) { - try { - prvKeyFile.createNewFile(); - } catch (final IOException e) { - result = "Failed to create file: " + e.toString(); - s_logger.debug(result); - } - } - - if (prvKeyFile.exists()) { - final String prvKey = cmd.getPrvKey(); - try (FileOutputStream prvKStream = new FileOutputStream(prvKeyFile);){ - if ( prvKStream != null) { - prvKStream.write(prvKey.getBytes()); - } - } catch (final FileNotFoundException e) { - result = "File" + SSHPRVKEYPATH + "is not found:" + e.toString(); - s_logger.debug(result); - } catch (final IOException e) { - result = "Write file " + SSHPRVKEYPATH + ":" + e.toString(); - s_logger.debug(result); - } - final Script script = new Script("chmod", _timeout, s_logger); - script.add("600", SSHPRVKEYPATH); - script.execute(); - } - - if (result != null) { - return new Answer(cmd, false, result); - } else { - return new Answer(cmd, true, null); - } - } - protected void handleVmStartFailure(final Connect conn, final String vmName, final LibvirtVMDef vm) { if (vm != null && vm.getDevices() != null) { cleanupVMNetworks(conn, vm.getDevices().getInterfaces()); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtModifySshKeysCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtModifySshKeysCommandWrapper.java new file mode 100644 index 000000000000..d5943c5f034a --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtModifySshKeysCommandWrapper.java @@ -0,0 +1,112 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; + +import org.apache.log4j.Logger; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.ModifySshKeysCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; +import com.cloud.utils.script.Script; + +public final class LibvirtModifySshKeysCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtModifySshKeysCommandWrapper.class); + + @Override + public Answer execute(final ModifySshKeysCommand command, final LibvirtComputingResource libvirtComputingResource) { + final File sshKeysDir = new File(LibvirtComputingResource.SSHKEYSPATH); + String result = null; + if (!sshKeysDir.exists()) { + // Change permissions for the 700 + final Script script = new Script("mkdir", libvirtComputingResource.getTimeout(), s_logger); + script.add("-m", "700"); + script.add(LibvirtComputingResource.SSHKEYSPATH); + script.execute(); + + if (!sshKeysDir.exists()) { + s_logger.debug("failed to create directory " + LibvirtComputingResource.SSHKEYSPATH); + } + } + + final File pubKeyFile = new File(LibvirtComputingResource.SSHPUBKEYPATH); + if (!pubKeyFile.exists()) { + try { + pubKeyFile.createNewFile(); + } catch (final IOException e) { + result = "Failed to create file: " + e.toString(); + s_logger.debug(result); + } + } + + if (pubKeyFile.exists()) { + try (FileOutputStream pubkStream = new FileOutputStream(pubKeyFile)) { + pubkStream.write(command.getPubKey().getBytes()); + } catch (final FileNotFoundException e) { + result = "File" + LibvirtComputingResource.SSHPUBKEYPATH + "is not found:" + + e.toString(); + s_logger.debug(result); + } catch (final IOException e) { + result = "Write file " + LibvirtComputingResource.SSHPUBKEYPATH + ":" + e.toString(); + s_logger.debug(result); + } + } + + final File prvKeyFile = new File(LibvirtComputingResource.SSHPRVKEYPATH); + if (!prvKeyFile.exists()) { + try { + prvKeyFile.createNewFile(); + } catch (final IOException e) { + result = "Failed to create file: " + e.toString(); + s_logger.debug(result); + } + } + + if (prvKeyFile.exists()) { + final String prvKey = command.getPrvKey(); + try (FileOutputStream prvKStream = new FileOutputStream(prvKeyFile);){ + if ( prvKStream != null) { + prvKStream.write(prvKey.getBytes()); + } + } catch (final FileNotFoundException e) { + result = "File" + LibvirtComputingResource.SSHPRVKEYPATH + "is not found:" + e.toString(); + s_logger.debug(result); + } catch (final IOException e) { + result = "Write file " + LibvirtComputingResource.SSHPRVKEYPATH + ":" + e.toString(); + s_logger.debug(result); + } + final Script script = new Script("chmod", libvirtComputingResource.getTimeout(), s_logger); + script.add("600", LibvirtComputingResource.SSHPRVKEYPATH); + script.execute(); + } + + if (result != null) { + return new Answer(command, false, result); + } else { + return new Answer(command, true, null); + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java index daa5a0ca39ff..c5001c47386d 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java @@ -31,6 +31,7 @@ import com.cloud.agent.api.GetVmStatsCommand; import com.cloud.agent.api.GetVncPortCommand; import com.cloud.agent.api.MigrateCommand; +import com.cloud.agent.api.ModifySshKeysCommand; import com.cloud.agent.api.PingTestCommand; import com.cloud.agent.api.PrepareForMigrationCommand; import com.cloud.agent.api.ReadyCommand; @@ -78,6 +79,7 @@ private void init() { linbvirtCommands.put(WatchConsoleProxyLoadCommand.class, new LibvirtWatchConsoleProxyLoadCommandWrapper()); linbvirtCommands.put(CheckConsoleProxyLoadCommand.class, new LibvirtCheckConsoleProxyLoadCommandWrapper()); linbvirtCommands.put(GetVncPortCommand.class, new LibvirtGetVncPortCommandWrapper()); + linbvirtCommands.put(ModifySshKeysCommand.class, new LibvirtModifySshKeysCommandWrapper()); resources.put(LibvirtComputingResource.class, linbvirtCommands); } diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index 09a9e369687b..a2b3b7fc4ee2 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -73,6 +73,7 @@ import com.cloud.agent.api.GetVmStatsCommand; import com.cloud.agent.api.GetVncPortCommand; import com.cloud.agent.api.MigrateCommand; +import com.cloud.agent.api.ModifySshKeysCommand; import com.cloud.agent.api.PingTestCommand; import com.cloud.agent.api.PrepareForMigrationCommand; import com.cloud.agent.api.ReadyCommand; @@ -1201,4 +1202,19 @@ public void testGetVncPortCommandLibvirtException() { fail(e.getMessage()); } } + + @Test + public void testModifySshKeysCommand() { + final ModifySshKeysCommand command = new ModifySshKeysCommand("", ""); + + when(libvirtComputingResource.getTimeout()).thenReturn(0); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getTimeout(); + } } \ No newline at end of file From cb4670279f764e1747f6eaaf1e39b1516cce6a5d Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Wed, 29 Apr 2015 16:05:44 +0200 Subject: [PATCH 016/175] Refactoring the LibvirtComputingResource - Adding LibvirtCreateCommandWrapper and LibvirtMaintainCommandWrapper - 4 unit tests added - KVM hypervisor plugin with 12.7% coverage --- .../resource/LibvirtComputingResource.java | 12 +-- .../wrapper/LibvirtCreateCommandWrapper.java | 83 ++++++++++++++ .../LibvirtMaintainCommandWrapper.java | 34 ++++++ .../wrapper/LibvirtRequestWrapper.java | 4 + .../LibvirtComputingResourceTest.java | 102 ++++++++++++++++++ 5 files changed, 225 insertions(+), 10 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreateCommandWrapper.java create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMaintainCommandWrapper.java diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 62c714892291..3c959ef70b8d 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -101,8 +101,6 @@ import com.cloud.agent.api.GetStorageStatsAnswer; import com.cloud.agent.api.GetStorageStatsCommand; import com.cloud.agent.api.HostVmStateReportEntry; -import com.cloud.agent.api.MaintainAnswer; -import com.cloud.agent.api.MaintainCommand; import com.cloud.agent.api.ManageSnapshotAnswer; import com.cloud.agent.api.ManageSnapshotCommand; import com.cloud.agent.api.ModifyStoragePoolAnswer; @@ -1305,9 +1303,7 @@ public Answer executeRequest(final Command cmd) { } try { - if (cmd instanceof MaintainCommand) { - return execute((MaintainCommand)cmd); - } else if (cmd instanceof CreateCommand) { + if (cmd instanceof CreateCommand) { return execute((CreateCommand)cmd); } else if (cmd instanceof DestroyCommand) { return execute((DestroyCommand)cmd); @@ -1769,7 +1765,7 @@ protected Answer execute(final CreateCommand cmd) { } // this is much like PrimaryStorageDownloadCommand, but keeping it separate - protected KVMPhysicalDisk templateToPrimaryDownload(final String templateUrl, final KVMStoragePool primaryPool, final String volUuid) { + public KVMPhysicalDisk templateToPrimaryDownload(final String templateUrl, final KVMStoragePool primaryPool, final String volUuid) { final int index = templateUrl.lastIndexOf("/"); final String mountpoint = templateUrl.substring(0, index); String templateName = null; @@ -2866,10 +2862,6 @@ private Answer execute(final CleanupNetworkRulesCmd cmd) { return new Answer(cmd, result, ""); } - protected MaintainAnswer execute(final MaintainCommand cmd) { - return new MaintainAnswer(cmd); - } - protected PowerState convertToPowerState(final DomainState ps) { final PowerState state = s_powerStatesTable.get(ps); return state == null ? PowerState.PowerUnknown : state; diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreateCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreateCommandWrapper.java new file mode 100644 index 000000000000..f169e720c529 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreateCommandWrapper.java @@ -0,0 +1,83 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import org.apache.log4j.Logger; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.storage.CreateAnswer; +import com.cloud.agent.api.storage.CreateCommand; +import com.cloud.agent.api.to.StorageFilerTO; +import com.cloud.agent.api.to.VolumeTO; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk; +import com.cloud.hypervisor.kvm.storage.KVMStoragePool; +import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; +import com.cloud.resource.CommandWrapper; +import com.cloud.storage.Storage.StoragePoolType; +import com.cloud.utils.exception.CloudRuntimeException; +import com.cloud.vm.DiskProfile; + +public final class LibvirtCreateCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtCreateCommandWrapper.class); + + @Override + public Answer execute(final CreateCommand command, final LibvirtComputingResource libvirtComputingResource) { + final StorageFilerTO pool = command.getPool(); + final DiskProfile dskch = command.getDiskCharacteristics(); + KVMPhysicalDisk baseVol = null; + KVMStoragePool primaryPool = null; + KVMPhysicalDisk vol = null; + long disksize; + try { + final KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr(); + primaryPool = storagePoolMgr.getStoragePool(pool.getType(), pool.getUuid()); + disksize = dskch.getSize(); + + if (command.getTemplateUrl() != null) { + if (primaryPool.getType() == StoragePoolType.CLVM) { + vol = libvirtComputingResource.templateToPrimaryDownload(command.getTemplateUrl(), primaryPool, dskch.getPath()); + } else { + baseVol = primaryPool.getPhysicalDisk(command.getTemplateUrl()); + vol = storagePoolMgr.createDiskFromTemplate(baseVol, + dskch.getPath(), dskch.getProvisioningType(), primaryPool, 0); + } + if (vol == null) { + return new Answer(command, false, " Can't create storage volume on storage pool"); + } + } else { + vol = primaryPool.createPhysicalDisk(dskch.getPath(), dskch.getProvisioningType(), dskch.getSize()); + } + final VolumeTO volume = + new VolumeTO(command.getVolumeId(), dskch.getType(), pool.getType(), pool.getUuid(), pool.getPath(), vol.getName(), vol.getName(), disksize, null); + + volume.setBytesReadRate(dskch.getBytesReadRate()); + volume.setBytesWriteRate(dskch.getBytesWriteRate()); + volume.setIopsReadRate(dskch.getIopsReadRate()); + volume.setIopsWriteRate(dskch.getIopsWriteRate()); + volume.setCacheMode(dskch.getCacheMode()); + return new CreateAnswer(command, volume); + } catch (final CloudRuntimeException e) { + s_logger.debug("Failed to create volume: " + e.toString()); + return new CreateAnswer(command, e); + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMaintainCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMaintainCommandWrapper.java new file mode 100644 index 000000000000..c1aba38ffe46 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMaintainCommandWrapper.java @@ -0,0 +1,34 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.MaintainAnswer; +import com.cloud.agent.api.MaintainCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; + +public final class LibvirtMaintainCommandWrapper extends CommandWrapper { + + @Override + public Answer execute(final MaintainCommand command, final LibvirtComputingResource libvirtComputingResource) { + return new MaintainAnswer(command); + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java index c5001c47386d..bced7f88d8a4 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java @@ -30,6 +30,7 @@ import com.cloud.agent.api.GetVmDiskStatsCommand; import com.cloud.agent.api.GetVmStatsCommand; import com.cloud.agent.api.GetVncPortCommand; +import com.cloud.agent.api.MaintainCommand; import com.cloud.agent.api.MigrateCommand; import com.cloud.agent.api.ModifySshKeysCommand; import com.cloud.agent.api.PingTestCommand; @@ -40,6 +41,7 @@ import com.cloud.agent.api.StopCommand; import com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand; import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand; +import com.cloud.agent.api.storage.CreateCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; import com.cloud.resource.RequestWrapper; @@ -80,6 +82,8 @@ private void init() { linbvirtCommands.put(CheckConsoleProxyLoadCommand.class, new LibvirtCheckConsoleProxyLoadCommandWrapper()); linbvirtCommands.put(GetVncPortCommand.class, new LibvirtGetVncPortCommandWrapper()); linbvirtCommands.put(ModifySshKeysCommand.class, new LibvirtModifySshKeysCommandWrapper()); + linbvirtCommands.put(MaintainCommand.class, new LibvirtMaintainCommandWrapper()); + linbvirtCommands.put(CreateCommand.class, new LibvirtCreateCommandWrapper()); resources.put(LibvirtComputingResource.class, linbvirtCommands); } diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index a2b3b7fc4ee2..22fa80863e49 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -72,6 +72,7 @@ import com.cloud.agent.api.GetVmDiskStatsCommand; import com.cloud.agent.api.GetVmStatsCommand; import com.cloud.agent.api.GetVncPortCommand; +import com.cloud.agent.api.MaintainCommand; import com.cloud.agent.api.MigrateCommand; import com.cloud.agent.api.ModifySshKeysCommand; import com.cloud.agent.api.PingTestCommand; @@ -83,8 +84,10 @@ import com.cloud.agent.api.VmStatsEntry; import com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand; import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand; +import com.cloud.agent.api.storage.CreateCommand; import com.cloud.agent.api.to.DiskTO; import com.cloud.agent.api.to.NicTO; +import com.cloud.agent.api.to.StorageFilerTO; import com.cloud.agent.api.to.VirtualMachineTO; import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource; import com.cloud.exception.InternalErrorException; @@ -100,6 +103,7 @@ import com.cloud.storage.Volume; import com.cloud.template.VirtualMachineTemplate.BootloaderType; import com.cloud.utils.Pair; +import com.cloud.vm.DiskProfile; import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachine.PowerState; @@ -1217,4 +1221,102 @@ public void testModifySshKeysCommand() { verify(libvirtComputingResource, times(1)).getTimeout(); } + + @Test + public void testMaintainCommand() { + final MaintainCommand command = new MaintainCommand(); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + } + + @Test + public void testCreateCommandNoTemplate() { + final DiskProfile diskCharacteristics = Mockito.mock(DiskProfile.class); + final StorageFilerTO pool = Mockito.mock(StorageFilerTO.class); + final boolean executeInSequence = false; + + final CreateCommand command = new CreateCommand(diskCharacteristics, pool, executeInSequence ); + + final KVMStoragePoolManager poolManager = Mockito.mock(KVMStoragePoolManager.class); + final KVMStoragePool primary = Mockito.mock(KVMStoragePool.class); + final KVMPhysicalDisk vol = Mockito.mock(KVMPhysicalDisk.class); + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(poolManager); + when(poolManager.getStoragePool(pool.getType(), pool.getUuid())).thenReturn(primary); + + when(primary.createPhysicalDisk(diskCharacteristics.getPath(), diskCharacteristics.getProvisioningType(), diskCharacteristics.getSize())).thenReturn(vol); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + verify(poolManager, times(1)).getStoragePool(pool.getType(), pool.getUuid()); + } + + @Test + public void testCreateCommand() { + final DiskProfile diskCharacteristics = Mockito.mock(DiskProfile.class); + final StorageFilerTO pool = Mockito.mock(StorageFilerTO.class); + final String templateUrl = "http://template"; + final boolean executeInSequence = false; + + final CreateCommand command = new CreateCommand(diskCharacteristics, templateUrl, pool, executeInSequence ); + + final KVMStoragePoolManager poolManager = Mockito.mock(KVMStoragePoolManager.class); + final KVMStoragePool primary = Mockito.mock(KVMStoragePool.class); + final KVMPhysicalDisk vol = Mockito.mock(KVMPhysicalDisk.class); + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(poolManager); + when(poolManager.getStoragePool(pool.getType(), pool.getUuid())).thenReturn(primary); + + when(primary.getType()).thenReturn(StoragePoolType.CLVM); + when(libvirtComputingResource.templateToPrimaryDownload(command.getTemplateUrl(), primary, diskCharacteristics.getPath())).thenReturn(vol); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + verify(poolManager, times(1)).getStoragePool(pool.getType(), pool.getUuid()); + } + + @Test + public void testCreateCommandCLVM() { + final DiskProfile diskCharacteristics = Mockito.mock(DiskProfile.class); + final StorageFilerTO pool = Mockito.mock(StorageFilerTO.class); + final String templateUrl = "http://template"; + final boolean executeInSequence = false; + + final CreateCommand command = new CreateCommand(diskCharacteristics, templateUrl, pool, executeInSequence ); + + final KVMStoragePoolManager poolManager = Mockito.mock(KVMStoragePoolManager.class); + final KVMStoragePool primary = Mockito.mock(KVMStoragePool.class); + final KVMPhysicalDisk vol = Mockito.mock(KVMPhysicalDisk.class); + final KVMPhysicalDisk baseVol = Mockito.mock(KVMPhysicalDisk.class); + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(poolManager); + when(poolManager.getStoragePool(pool.getType(), pool.getUuid())).thenReturn(primary); + + when(primary.getPhysicalDisk(command.getTemplateUrl())).thenReturn(baseVol); + when(poolManager.createDiskFromTemplate(baseVol, + diskCharacteristics.getPath(), diskCharacteristics.getProvisioningType(), primary, 0)).thenReturn(vol); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + verify(poolManager, times(1)).getStoragePool(pool.getType(), pool.getUuid()); + } } \ No newline at end of file From 4472cade2f1c079d96ed738d32c0e046f76c832e Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Wed, 29 Apr 2015 17:19:57 +0200 Subject: [PATCH 017/175] Refactoring the LibvirtComputingResource - Adding LibvirtDestroyCommandWrapper - 2 unit tests added - KVM hypervisor plugin with 12.9% coverage --- .../resource/LibvirtComputingResource.java | 62 +------------------ .../wrapper/LibvirtDestroyCommandWrapper.java | 50 +++++++++++++++ .../wrapper/LibvirtRequestWrapper.java | 2 + .../LibvirtComputingResourceTest.java | 59 ++++++++++++++++++ 4 files changed, 112 insertions(+), 61 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtDestroyCommandWrapper.java diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 3c959ef70b8d..4abc04880f61 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -145,10 +145,7 @@ import com.cloud.agent.api.routing.SetSourceNatCommand; import com.cloud.agent.api.storage.CopyVolumeAnswer; import com.cloud.agent.api.storage.CopyVolumeCommand; -import com.cloud.agent.api.storage.CreateAnswer; -import com.cloud.agent.api.storage.CreateCommand; import com.cloud.agent.api.storage.CreatePrivateTemplateAnswer; -import com.cloud.agent.api.storage.DestroyCommand; import com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer; import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand; import com.cloud.agent.api.storage.ResizeVolumeAnswer; @@ -161,7 +158,6 @@ import com.cloud.agent.api.to.NicTO; import com.cloud.agent.api.to.StorageFilerTO; import com.cloud.agent.api.to.VirtualMachineTO; -import com.cloud.agent.api.to.VolumeTO; import com.cloud.agent.resource.virtualnetwork.VirtualRouterDeployer; import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource; import com.cloud.dc.Vlan; @@ -225,7 +221,6 @@ import com.cloud.utils.script.OutputInterpreter.AllLinesParser; import com.cloud.utils.script.Script; import com.cloud.utils.ssh.SshHelper; -import com.cloud.vm.DiskProfile; import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachine.PowerState; @@ -1303,11 +1298,7 @@ public Answer executeRequest(final Command cmd) { } try { - if (cmd instanceof CreateCommand) { - return execute((CreateCommand)cmd); - } else if (cmd instanceof DestroyCommand) { - return execute((DestroyCommand)cmd); - } else if (cmd instanceof PrimaryStorageDownloadCommand) { + if (cmd instanceof PrimaryStorageDownloadCommand) { return execute((PrimaryStorageDownloadCommand)cmd); } else if (cmd instanceof CreatePrivateTemplateFromVolumeCommand) { return execute((CreatePrivateTemplateFromVolumeCommand)cmd); @@ -1725,45 +1716,6 @@ protected Storage.StorageResourceType getStorageResourceType() { return Storage.StorageResourceType.STORAGE_POOL; } - protected Answer execute(final CreateCommand cmd) { - final StorageFilerTO pool = cmd.getPool(); - final DiskProfile dskch = cmd.getDiskCharacteristics(); - KVMPhysicalDisk BaseVol = null; - KVMStoragePool primaryPool = null; - KVMPhysicalDisk vol = null; - long disksize; - try { - primaryPool = _storagePoolMgr.getStoragePool(pool.getType(), pool.getUuid()); - disksize = dskch.getSize(); - - if (cmd.getTemplateUrl() != null) { - if (primaryPool.getType() == StoragePoolType.CLVM) { - vol = templateToPrimaryDownload(cmd.getTemplateUrl(), primaryPool, dskch.getPath()); - } else { - BaseVol = primaryPool.getPhysicalDisk(cmd.getTemplateUrl()); - vol = _storagePoolMgr.createDiskFromTemplate(BaseVol, - dskch.getPath(), dskch.getProvisioningType(), primaryPool, 0); - } - if (vol == null) { - return new Answer(cmd, false, " Can't create storage volume on storage pool"); - } - } else { - vol = primaryPool.createPhysicalDisk(dskch.getPath(), dskch.getProvisioningType(), dskch.getSize()); - } - final VolumeTO volume = - new VolumeTO(cmd.getVolumeId(), dskch.getType(), pool.getType(), pool.getUuid(), pool.getPath(), vol.getName(), vol.getName(), disksize, null); - volume.setBytesReadRate(dskch.getBytesReadRate()); - volume.setBytesWriteRate(dskch.getBytesWriteRate()); - volume.setIopsReadRate(dskch.getIopsReadRate()); - volume.setIopsWriteRate(dskch.getIopsWriteRate()); - volume.setCacheMode(dskch.getCacheMode()); - return new CreateAnswer(cmd, volume); - } catch (final CloudRuntimeException e) { - s_logger.debug("Failed to create volume: " + e.toString()); - return new CreateAnswer(cmd, e); - } - } - // this is much like PrimaryStorageDownloadCommand, but keeping it separate public KVMPhysicalDisk templateToPrimaryDownload(final String templateUrl, final KVMStoragePool primaryPool, final String volUuid) { final int index = templateUrl.lastIndexOf("/"); @@ -1915,18 +1867,6 @@ public Answer execute(final ResizeVolumeCommand cmd) { } - public Answer execute(final DestroyCommand cmd) { - final VolumeTO vol = cmd.getVolume(); - try { - final KVMStoragePool pool = _storagePoolMgr.getStoragePool(vol.getPoolType(), vol.getPoolUuid()); - pool.deletePhysicalDisk(vol.getPath(), null); - return new Answer(cmd, true, "Success"); - } catch (final CloudRuntimeException e) { - s_logger.debug("Failed to delete volume: " + e.toString()); - return new Answer(cmd, false, e.toString()); - } - } - private String getBroadcastUriFromBridge(final String brName) { final String pif = matchPifFileInDirectory(brName); final Pattern pattern = Pattern.compile("(\\D+)(\\d+)(\\D*)(\\d*)"); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtDestroyCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtDestroyCommandWrapper.java new file mode 100644 index 000000000000..d87929516851 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtDestroyCommandWrapper.java @@ -0,0 +1,50 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import org.apache.log4j.Logger; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.storage.DestroyCommand; +import com.cloud.agent.api.to.VolumeTO; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.hypervisor.kvm.storage.KVMStoragePool; +import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; +import com.cloud.resource.CommandWrapper; +import com.cloud.utils.exception.CloudRuntimeException; + +public final class LibvirtDestroyCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtDestroyCommandWrapper.class); + + @Override + public Answer execute(final DestroyCommand command, final LibvirtComputingResource libvirtComputingResource) { + final VolumeTO vol = command.getVolume(); + try { + KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr(); + final KVMStoragePool pool = storagePoolMgr.getStoragePool(vol.getPoolType(), vol.getPoolUuid()); + pool.deletePhysicalDisk(vol.getPath(), null); + return new Answer(command, true, "Success"); + } catch (final CloudRuntimeException e) { + s_logger.debug("Failed to delete volume: " + e.toString()); + return new Answer(command, false, e.toString()); + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java index bced7f88d8a4..eb8d569e2348 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java @@ -42,6 +42,7 @@ import com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand; import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand; import com.cloud.agent.api.storage.CreateCommand; +import com.cloud.agent.api.storage.DestroyCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; import com.cloud.resource.RequestWrapper; @@ -84,6 +85,7 @@ private void init() { linbvirtCommands.put(ModifySshKeysCommand.class, new LibvirtModifySshKeysCommandWrapper()); linbvirtCommands.put(MaintainCommand.class, new LibvirtMaintainCommandWrapper()); linbvirtCommands.put(CreateCommand.class, new LibvirtCreateCommandWrapper()); + linbvirtCommands.put(DestroyCommand.class, new LibvirtDestroyCommandWrapper()); resources.put(LibvirtComputingResource.class, linbvirtCommands); } diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index 22fa80863e49..0865fb59e8ba 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -85,10 +85,12 @@ import com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand; import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand; import com.cloud.agent.api.storage.CreateCommand; +import com.cloud.agent.api.storage.DestroyCommand; import com.cloud.agent.api.to.DiskTO; import com.cloud.agent.api.to.NicTO; import com.cloud.agent.api.to.StorageFilerTO; import com.cloud.agent.api.to.VirtualMachineTO; +import com.cloud.agent.api.to.VolumeTO; import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource; import com.cloud.exception.InternalErrorException; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef; @@ -100,9 +102,11 @@ import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; import com.cloud.network.Networks.TrafficType; import com.cloud.storage.Storage.StoragePoolType; +import com.cloud.storage.StoragePool; import com.cloud.storage.Volume; import com.cloud.template.VirtualMachineTemplate.BootloaderType; import com.cloud.utils.Pair; +import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.vm.DiskProfile; import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachine.PowerState; @@ -1319,4 +1323,59 @@ public void testCreateCommandCLVM() { verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); verify(poolManager, times(1)).getStoragePool(pool.getType(), pool.getUuid()); } + + @Test + public void testDestroyCommand() { + final StoragePool pool = Mockito.mock(StoragePool.class); + final Volume volume = Mockito.mock(Volume.class); + final String vmName = "Test"; + + final DestroyCommand command = new DestroyCommand(pool, volume, vmName); + + final KVMStoragePoolManager poolManager = Mockito.mock(KVMStoragePoolManager.class); + final KVMStoragePool primary = Mockito.mock(KVMStoragePool.class); + + final VolumeTO vol = command.getVolume(); + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(poolManager); + when(poolManager.getStoragePool(vol.getPoolType(), vol.getPoolUuid())).thenReturn(primary); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + verify(poolManager, times(1)).getStoragePool(vol.getPoolType(), vol.getPoolUuid()); + } + + @SuppressWarnings("unchecked") + @Test + public void testDestroyCommandError() { + final StoragePool pool = Mockito.mock(StoragePool.class); + final Volume volume = Mockito.mock(Volume.class); + final String vmName = "Test"; + + final DestroyCommand command = new DestroyCommand(pool, volume, vmName); + + final KVMStoragePoolManager poolManager = Mockito.mock(KVMStoragePoolManager.class); + final KVMStoragePool primary = Mockito.mock(KVMStoragePool.class); + + final VolumeTO vol = command.getVolume(); + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(poolManager); + when(poolManager.getStoragePool(vol.getPoolType(), vol.getPoolUuid())).thenReturn(primary); + + when(primary.deletePhysicalDisk(vol.getPath(), null)).thenThrow(CloudRuntimeException.class); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + verify(poolManager, times(1)).getStoragePool(vol.getPoolType(), vol.getPoolUuid()); + } } \ No newline at end of file From 8268d353a2a5ffb032017687f7df82c4a6871812 Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Thu, 30 Apr 2015 14:53:17 +0200 Subject: [PATCH 018/175] Refactoring the LibvirtComputingResource - Adding LibvirtPrimaryStorageDownloadCommandWrapper - 4 unit tests added - KVM hypervisor plugin with 13.3% coverage --- .../resource/LibvirtComputingResource.java | 55 +----- ...tPrimaryStorageDownloadCommandWrapper.java | 88 ++++++++++ .../wrapper/LibvirtRequestWrapper.java | 2 + .../LibvirtComputingResourceTest.java | 157 +++++++++++++++++- 4 files changed, 247 insertions(+), 55 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPrimaryStorageDownloadCommandWrapper.java diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 4abc04880f61..8e9cbc1d1215 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -146,8 +146,6 @@ import com.cloud.agent.api.storage.CopyVolumeAnswer; import com.cloud.agent.api.storage.CopyVolumeCommand; import com.cloud.agent.api.storage.CreatePrivateTemplateAnswer; -import com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer; -import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand; import com.cloud.agent.api.storage.ResizeVolumeAnswer; import com.cloud.agent.api.storage.ResizeVolumeCommand; import com.cloud.agent.api.to.DataStoreTO; @@ -1298,9 +1296,7 @@ public Answer executeRequest(final Command cmd) { } try { - if (cmd instanceof PrimaryStorageDownloadCommand) { - return execute((PrimaryStorageDownloadCommand)cmd); - } else if (cmd instanceof CreatePrivateTemplateFromVolumeCommand) { + if (cmd instanceof CreatePrivateTemplateFromVolumeCommand) { return execute((CreatePrivateTemplateFromVolumeCommand)cmd); } else if (cmd instanceof GetStorageStatsCommand) { return execute((GetStorageStatsCommand)cmd); @@ -2704,55 +2700,6 @@ protected CreatePrivateTemplateAnswer execute(final CreatePrivateTemplateFromVol } } - protected PrimaryStorageDownloadAnswer execute(final PrimaryStorageDownloadCommand cmd) { - final String tmplturl = cmd.getUrl(); - final int index = tmplturl.lastIndexOf("/"); - final String mountpoint = tmplturl.substring(0, index); - String tmpltname = null; - if (index < tmplturl.length() - 1) { - tmpltname = tmplturl.substring(index + 1); - } - - KVMPhysicalDisk tmplVol = null; - KVMStoragePool secondaryPool = null; - try { - secondaryPool = _storagePoolMgr.getStoragePoolByURI(mountpoint); - - /* Get template vol */ - if (tmpltname == null) { - secondaryPool.refresh(); - final List disks = secondaryPool.listPhysicalDisks(); - if (disks == null || disks.isEmpty()) { - return new PrimaryStorageDownloadAnswer("Failed to get volumes from pool: " + secondaryPool.getUuid()); - } - for (final KVMPhysicalDisk disk : disks) { - if (disk.getName().endsWith("qcow2")) { - tmplVol = disk; - break; - } - } - if (tmplVol == null) { - return new PrimaryStorageDownloadAnswer("Failed to get template from pool: " + secondaryPool.getUuid()); - } - } else { - tmplVol = secondaryPool.getPhysicalDisk(tmpltname); - } - - /* Copy volume to primary storage */ - final KVMStoragePool primaryPool = _storagePoolMgr.getStoragePool(cmd.getPool().getType(), cmd.getPoolUuid()); - - final KVMPhysicalDisk primaryVol = _storagePoolMgr.copyPhysicalDisk(tmplVol, UUID.randomUUID().toString(), primaryPool, 0); - - return new PrimaryStorageDownloadAnswer(primaryVol.getName(), primaryVol.getSize()); - } catch (final CloudRuntimeException e) { - return new PrimaryStorageDownloadAnswer(e.toString()); - } finally { - if (secondaryPool != null) { - _storagePoolMgr.deleteStoragePool(secondaryPool.getType(), secondaryPool.getUuid()); - } - } - } - protected Answer execute(final CreateStoragePoolCommand cmd) { return new Answer(cmd, true, "success"); } diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPrimaryStorageDownloadCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPrimaryStorageDownloadCommandWrapper.java new file mode 100644 index 000000000000..391ab2787bab --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPrimaryStorageDownloadCommandWrapper.java @@ -0,0 +1,88 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import java.util.List; +import java.util.UUID; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer; +import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk; +import com.cloud.hypervisor.kvm.storage.KVMStoragePool; +import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; +import com.cloud.resource.CommandWrapper; +import com.cloud.utils.exception.CloudRuntimeException; + +public final class LibvirtPrimaryStorageDownloadCommandWrapper extends CommandWrapper { + + @Override + public Answer execute(final PrimaryStorageDownloadCommand command, final LibvirtComputingResource libvirtComputingResource) { + final String tmplturl = command.getUrl(); + final int index = tmplturl.lastIndexOf("/"); + final String mountpoint = tmplturl.substring(0, index); + String tmpltname = null; + + if (index < tmplturl.length() - 1) { + tmpltname = tmplturl.substring(index + 1); + } + + KVMPhysicalDisk tmplVol = null; + KVMStoragePool secondaryPool = null; + final KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr(); + try { + secondaryPool = storagePoolMgr.getStoragePoolByURI(mountpoint); + + /* Get template vol */ + if (tmpltname == null) { + secondaryPool.refresh(); + final List disks = secondaryPool.listPhysicalDisks(); + if (disks == null || disks.isEmpty()) { + return new PrimaryStorageDownloadAnswer("Failed to get volumes from pool: " + secondaryPool.getUuid()); + } + for (final KVMPhysicalDisk disk : disks) { + if (disk.getName().endsWith("qcow2")) { + tmplVol = disk; + break; + } + } + if (tmplVol == null) { + return new PrimaryStorageDownloadAnswer("Failed to get template from pool: " + secondaryPool.getUuid()); + } + } else { + tmplVol = secondaryPool.getPhysicalDisk(tmpltname); + } + + /* Copy volume to primary storage */ + final KVMStoragePool primaryPool = storagePoolMgr.getStoragePool(command.getPool().getType(), command.getPoolUuid()); + + final KVMPhysicalDisk primaryVol = storagePoolMgr.copyPhysicalDisk(tmplVol, UUID.randomUUID().toString(), primaryPool, 0); + + return new PrimaryStorageDownloadAnswer(primaryVol.getName(), primaryVol.getSize()); + } catch (final CloudRuntimeException e) { + return new PrimaryStorageDownloadAnswer(e.toString()); + } finally { + if (secondaryPool != null) { + storagePoolMgr.deleteStoragePool(secondaryPool.getType(), secondaryPool.getUuid()); + } + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java index eb8d569e2348..7c9b443c91dd 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java @@ -43,6 +43,7 @@ import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand; import com.cloud.agent.api.storage.CreateCommand; import com.cloud.agent.api.storage.DestroyCommand; +import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; import com.cloud.resource.RequestWrapper; @@ -86,6 +87,7 @@ private void init() { linbvirtCommands.put(MaintainCommand.class, new LibvirtMaintainCommandWrapper()); linbvirtCommands.put(CreateCommand.class, new LibvirtCreateCommandWrapper()); linbvirtCommands.put(DestroyCommand.class, new LibvirtDestroyCommandWrapper()); + linbvirtCommands.put(PrimaryStorageDownloadCommand.class, new LibvirtPrimaryStorageDownloadCommandWrapper()); resources.put(LibvirtComputingResource.class, linbvirtCommands); } diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index 0865fb59e8ba..946d87139bc8 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -86,6 +86,7 @@ import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand; import com.cloud.agent.api.storage.CreateCommand; import com.cloud.agent.api.storage.DestroyCommand; +import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand; import com.cloud.agent.api.to.DiskTO; import com.cloud.agent.api.to.NicTO; import com.cloud.agent.api.to.StorageFilerTO; @@ -101,6 +102,7 @@ import com.cloud.hypervisor.kvm.storage.KVMStoragePool; import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; import com.cloud.network.Networks.TrafficType; +import com.cloud.storage.Storage.ImageFormat; import com.cloud.storage.Storage.StoragePoolType; import com.cloud.storage.StoragePool; import com.cloud.storage.Volume; @@ -1378,4 +1380,157 @@ public void testDestroyCommandError() { verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); verify(poolManager, times(1)).getStoragePool(vol.getPoolType(), vol.getPoolUuid()); } -} \ No newline at end of file + + @Test(expected = NullPointerException.class) + public void testPrimaryStorageDownloadCommandNOTemplateDisk() { + final StoragePool pool = Mockito.mock(StoragePool.class); + + final List disks = new ArrayList(); + + final String name = "Test"; + final String url = "http://template/"; + final ImageFormat format = ImageFormat.QCOW2; + final long accountId = 1l; + final int wait = 0; + final PrimaryStorageDownloadCommand command = new PrimaryStorageDownloadCommand(name, url, format, accountId, pool, wait); + + final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class); + final KVMStoragePool primaryPool = Mockito.mock(KVMStoragePool.class); + final KVMStoragePool secondaryPool = Mockito.mock(KVMStoragePool.class); + final KVMPhysicalDisk tmplVol = Mockito.mock(KVMPhysicalDisk.class); + final KVMPhysicalDisk primaryVol = Mockito.mock(KVMPhysicalDisk.class); + + final KVMPhysicalDisk disk = new KVMPhysicalDisk("/path", "disk.qcow2", primaryPool); + disks.add(disk); + + final int index = url.lastIndexOf("/"); + final String mountpoint = url.substring(0, index); + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr); + when(storagePoolMgr.getStoragePoolByURI(mountpoint)).thenReturn(secondaryPool); + when(secondaryPool.listPhysicalDisks()).thenReturn(disks); + when(storagePoolMgr.getStoragePool(command.getPool().getType(), command.getPoolUuid())).thenReturn(primaryPool); + when(storagePoolMgr.copyPhysicalDisk(tmplVol, UUID.randomUUID().toString(), primaryPool, 0)).thenReturn(primaryVol); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + } + + @Test + public void testPrimaryStorageDownloadCommandNOTemplateNODisk() { + final StoragePool pool = Mockito.mock(StoragePool.class); + + final List disks = new ArrayList(); + + final String name = "Test"; + final String url = "http://template/"; + final ImageFormat format = ImageFormat.QCOW2; + final long accountId = 1l; + final int wait = 0; + final PrimaryStorageDownloadCommand command = new PrimaryStorageDownloadCommand(name, url, format, accountId, pool, wait); + + final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class); + final KVMStoragePool primaryPool = Mockito.mock(KVMStoragePool.class); + final KVMStoragePool secondaryPool = Mockito.mock(KVMStoragePool.class); + final KVMPhysicalDisk tmplVol = Mockito.mock(KVMPhysicalDisk.class); + final KVMPhysicalDisk primaryVol = Mockito.mock(KVMPhysicalDisk.class); + + final int index = url.lastIndexOf("/"); + final String mountpoint = url.substring(0, index); + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr); + when(storagePoolMgr.getStoragePoolByURI(mountpoint)).thenReturn(secondaryPool); + when(secondaryPool.listPhysicalDisks()).thenReturn(disks); + when(storagePoolMgr.getStoragePool(command.getPool().getType(), command.getPoolUuid())).thenReturn(primaryPool); + when(storagePoolMgr.copyPhysicalDisk(tmplVol, UUID.randomUUID().toString(), primaryPool, 0)).thenReturn(primaryVol); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + } + + @Test + public void testPrimaryStorageDownloadCommandNOTemplateNOQcow2() { + final StoragePool pool = Mockito.mock(StoragePool.class); + + final List disks = new ArrayList(); + final List spiedDisks = Mockito.spy(disks); + + final String name = "Test"; + final String url = "http://template/"; + final ImageFormat format = ImageFormat.QCOW2; + final long accountId = 1l; + final int wait = 0; + final PrimaryStorageDownloadCommand command = new PrimaryStorageDownloadCommand(name, url, format, accountId, pool, wait); + + final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class); + final KVMStoragePool primaryPool = Mockito.mock(KVMStoragePool.class); + final KVMStoragePool secondaryPool = Mockito.mock(KVMStoragePool.class); + final KVMPhysicalDisk tmplVol = Mockito.mock(KVMPhysicalDisk.class); + final KVMPhysicalDisk primaryVol = Mockito.mock(KVMPhysicalDisk.class); + + final int index = url.lastIndexOf("/"); + final String mountpoint = url.substring(0, index); + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr); + when(storagePoolMgr.getStoragePoolByURI(mountpoint)).thenReturn(secondaryPool); + when(secondaryPool.listPhysicalDisks()).thenReturn(spiedDisks); + when(spiedDisks.isEmpty()).thenReturn(false); + + when(storagePoolMgr.getStoragePool(command.getPool().getType(), command.getPoolUuid())).thenReturn(primaryPool); + when(storagePoolMgr.copyPhysicalDisk(tmplVol, UUID.randomUUID().toString(), primaryPool, 0)).thenReturn(primaryVol); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + } + + @Test(expected = NullPointerException.class) + public void testPrimaryStorageDownloadCommandTemplateNoDisk() { + final StoragePool pool = Mockito.mock(StoragePool.class); + + final String name = "Test"; + final String url = "http://template/template.qcow2"; + final ImageFormat format = ImageFormat.VHD; + final long accountId = 1l; + final int wait = 0; + final PrimaryStorageDownloadCommand command = new PrimaryStorageDownloadCommand(name, url, format, accountId, pool, wait); + + final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class); + final KVMStoragePool primaryPool = Mockito.mock(KVMStoragePool.class); + final KVMStoragePool secondaryPool = Mockito.mock(KVMStoragePool.class); + final KVMPhysicalDisk tmplVol = Mockito.mock(KVMPhysicalDisk.class); + final KVMPhysicalDisk primaryVol = Mockito.mock(KVMPhysicalDisk.class); + + final int index = url.lastIndexOf("/"); + final String mountpoint = url.substring(0, index); + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr); + when(storagePoolMgr.getStoragePoolByURI(mountpoint)).thenReturn(secondaryPool); + when(secondaryPool.getPhysicalDisk("template.qcow2")).thenReturn(tmplVol); + when(storagePoolMgr.getStoragePool(command.getPool().getType(), command.getPoolUuid())).thenReturn(primaryPool); + when(storagePoolMgr.copyPhysicalDisk(tmplVol, UUID.randomUUID().toString(), primaryPool, 0)).thenReturn(primaryVol); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + verify(storagePoolMgr, times(1)).getStoragePool(command.getPool().getType(), command.getPoolUuid()); + } +} From 0d860af659da24b509910e5edbce95d58c6fe569 Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Thu, 30 Apr 2015 21:33:19 +0200 Subject: [PATCH 019/175] Refactoring the LibvirtComputingResource - Adding LibvirtDeleteStoragePoolCommandWrapper, LibvirtGetStorageStatsCommandWrapper and LibvirtUpgradeSnapshotCommandWrapper - 7 unit tests added - KVM hypervisor plugin with 13.6% coverage --- .../resource/LibvirtComputingResource.java | 33 ---- ...ibvirtDeleteStoragePoolCommandWrapper.java | 43 +++++ .../LibvirtGetStorageStatsCommandWrapper.java | 43 +++++ .../wrapper/LibvirtRequestWrapper.java | 6 + .../LibvirtUpgradeSnapshotCommandWrapper.java | 33 ++++ .../LibvirtComputingResourceTest.java | 177 +++++++++++++++++- 6 files changed, 301 insertions(+), 34 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtDeleteStoragePoolCommandWrapper.java create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetStorageStatsCommandWrapper.java create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUpgradeSnapshotCommandWrapper.java diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 8e9cbc1d1215..f72fecf756c3 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -95,11 +95,8 @@ import com.cloud.agent.api.CreateStoragePoolCommand; import com.cloud.agent.api.CreateVolumeFromSnapshotAnswer; import com.cloud.agent.api.CreateVolumeFromSnapshotCommand; -import com.cloud.agent.api.DeleteStoragePoolCommand; import com.cloud.agent.api.FenceAnswer; import com.cloud.agent.api.FenceCommand; -import com.cloud.agent.api.GetStorageStatsAnswer; -import com.cloud.agent.api.GetStorageStatsCommand; import com.cloud.agent.api.HostVmStateReportEntry; import com.cloud.agent.api.ManageSnapshotAnswer; import com.cloud.agent.api.ManageSnapshotCommand; @@ -134,7 +131,6 @@ import com.cloud.agent.api.StartupStorageCommand; import com.cloud.agent.api.UnPlugNicAnswer; import com.cloud.agent.api.UnPlugNicCommand; -import com.cloud.agent.api.UpgradeSnapshotCommand; import com.cloud.agent.api.VmDiskStatsEntry; import com.cloud.agent.api.VmStatsEntry; import com.cloud.agent.api.check.CheckSshAnswer; @@ -1298,8 +1294,6 @@ public Answer executeRequest(final Command cmd) { try { if (cmd instanceof CreatePrivateTemplateFromVolumeCommand) { return execute((CreatePrivateTemplateFromVolumeCommand)cmd); - } else if (cmd instanceof GetStorageStatsCommand) { - return execute((GetStorageStatsCommand)cmd); } else if (cmd instanceof ManageSnapshotCommand) { return execute((ManageSnapshotCommand)cmd); } else if (cmd instanceof BackupSnapshotCommand) { @@ -1308,16 +1302,12 @@ public Answer executeRequest(final Command cmd) { return execute((CreateVolumeFromSnapshotCommand)cmd); } else if (cmd instanceof CreatePrivateTemplateFromSnapshotCommand) { return execute((CreatePrivateTemplateFromSnapshotCommand)cmd); - } else if (cmd instanceof UpgradeSnapshotCommand) { - return execute((UpgradeSnapshotCommand)cmd); } else if (cmd instanceof CreateStoragePoolCommand) { return execute((CreateStoragePoolCommand)cmd); } else if (cmd instanceof ModifyStoragePoolCommand) { return execute((ModifyStoragePoolCommand)cmd); } else if (cmd instanceof SecurityGroupRulesCmd) { return execute((SecurityGroupRulesCmd)cmd); - } else if (cmd instanceof DeleteStoragePoolCommand) { - return execute((DeleteStoragePoolCommand)cmd); } else if (cmd instanceof FenceCommand) { return execute((FenceCommand)cmd); } else if (cmd instanceof StartCommand) { @@ -1657,15 +1647,6 @@ private CopyVolumeAnswer execute(final CopyVolumeCommand cmd) { } } - protected Answer execute(final DeleteStoragePoolCommand cmd) { - try { - _storagePoolMgr.deleteStoragePool(cmd.getPool().getType(), cmd.getPool().getUuid()); - return new Answer(cmd); - } catch (final CloudRuntimeException e) { - return new Answer(cmd, false, e.toString()); - } - } - protected FenceAnswer execute(final FenceCommand cmd) { final ExecutorService executors = Executors.newSingleThreadExecutor(); final List pools = _monitor.getStoragePools(); @@ -2520,11 +2501,6 @@ protected CreateVolumeFromSnapshotAnswer execute(final CreateVolumeFromSnapshotC } } - protected Answer execute(final UpgradeSnapshotCommand cmd) { - - return new Answer(cmd, true, "success"); - } - protected CreatePrivateTemplateAnswer execute(final CreatePrivateTemplateFromSnapshotCommand cmd) { final String templateFolder = cmd.getAccountId() + File.separator + cmd.getNewTemplateId(); final String templateInstallFolder = "template/tmpl/" + templateFolder; @@ -2582,15 +2558,6 @@ protected CreatePrivateTemplateAnswer execute(final CreatePrivateTemplateFromSna } } - protected GetStorageStatsAnswer execute(final GetStorageStatsCommand cmd) { - try { - final KVMStoragePool sp = _storagePoolMgr.getStoragePool(cmd.getPooltype(), cmd.getStorageId(), true); - return new GetStorageStatsAnswer(cmd, sp.getCapacity(), sp.getUsed()); - } catch (final CloudRuntimeException e) { - return new GetStorageStatsAnswer(cmd, e.toString()); - } - } - protected CreatePrivateTemplateAnswer execute(final CreatePrivateTemplateFromVolumeCommand cmd) { final String secondaryStorageURL = cmd.getSecondaryStorageUrl(); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtDeleteStoragePoolCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtDeleteStoragePoolCommandWrapper.java new file mode 100644 index 000000000000..9b0b245f80d6 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtDeleteStoragePoolCommandWrapper.java @@ -0,0 +1,43 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.DeleteStoragePoolCommand; +import com.cloud.agent.api.to.StorageFilerTO; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; +import com.cloud.resource.CommandWrapper; +import com.cloud.utils.exception.CloudRuntimeException; + +public final class LibvirtDeleteStoragePoolCommandWrapper extends CommandWrapper { + + @Override + public Answer execute(final DeleteStoragePoolCommand command, final LibvirtComputingResource libvirtComputingResource) { + try { + StorageFilerTO pool = command.getPool(); + KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr(); + storagePoolMgr.deleteStoragePool(pool.getType(), pool.getUuid()); + return new Answer(command); + } catch (final CloudRuntimeException e) { + return new Answer(command, false, e.toString()); + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetStorageStatsCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetStorageStatsCommandWrapper.java new file mode 100644 index 000000000000..98deae2c382d --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetStorageStatsCommandWrapper.java @@ -0,0 +1,43 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.GetStorageStatsAnswer; +import com.cloud.agent.api.GetStorageStatsCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.hypervisor.kvm.storage.KVMStoragePool; +import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; +import com.cloud.resource.CommandWrapper; +import com.cloud.utils.exception.CloudRuntimeException; + +public final class LibvirtGetStorageStatsCommandWrapper extends CommandWrapper { + + @Override + public Answer execute(final GetStorageStatsCommand command, final LibvirtComputingResource libvirtComputingResource) { + try { + final KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr(); + final KVMStoragePool sp = storagePoolMgr.getStoragePool(command.getPooltype(), command.getStorageId(), true); + return new GetStorageStatsAnswer(command, sp.getCapacity(), sp.getUsed()); + } catch (final CloudRuntimeException e) { + return new GetStorageStatsAnswer(command, e.toString()); + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java index 7c9b443c91dd..04aa2ea518d9 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java @@ -26,7 +26,9 @@ import com.cloud.agent.api.CheckHealthCommand; import com.cloud.agent.api.CheckVirtualMachineCommand; import com.cloud.agent.api.Command; +import com.cloud.agent.api.DeleteStoragePoolCommand; import com.cloud.agent.api.GetHostStatsCommand; +import com.cloud.agent.api.GetStorageStatsCommand; import com.cloud.agent.api.GetVmDiskStatsCommand; import com.cloud.agent.api.GetVmStatsCommand; import com.cloud.agent.api.GetVncPortCommand; @@ -39,6 +41,7 @@ import com.cloud.agent.api.RebootCommand; import com.cloud.agent.api.RebootRouterCommand; import com.cloud.agent.api.StopCommand; +import com.cloud.agent.api.UpgradeSnapshotCommand; import com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand; import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand; import com.cloud.agent.api.storage.CreateCommand; @@ -88,6 +91,9 @@ private void init() { linbvirtCommands.put(CreateCommand.class, new LibvirtCreateCommandWrapper()); linbvirtCommands.put(DestroyCommand.class, new LibvirtDestroyCommandWrapper()); linbvirtCommands.put(PrimaryStorageDownloadCommand.class, new LibvirtPrimaryStorageDownloadCommandWrapper()); + linbvirtCommands.put(GetStorageStatsCommand.class, new LibvirtGetStorageStatsCommandWrapper()); + linbvirtCommands.put(UpgradeSnapshotCommand.class, new LibvirtUpgradeSnapshotCommandWrapper()); + linbvirtCommands.put(DeleteStoragePoolCommand.class, new LibvirtDeleteStoragePoolCommandWrapper()); resources.put(LibvirtComputingResource.class, linbvirtCommands); } diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUpgradeSnapshotCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUpgradeSnapshotCommandWrapper.java new file mode 100644 index 000000000000..0f0fb9a73dc2 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUpgradeSnapshotCommandWrapper.java @@ -0,0 +1,33 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.UpgradeSnapshotCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; + +public final class LibvirtUpgradeSnapshotCommandWrapper extends CommandWrapper { + + @Override + public Answer execute(final UpgradeSnapshotCommand command, final LibvirtComputingResource libvirtComputingResource) { + return new Answer(command, true, "success"); + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index 946d87139bc8..2432c98c39ad 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -68,7 +68,9 @@ import com.cloud.agent.api.AttachVolumeCommand; import com.cloud.agent.api.CheckHealthCommand; import com.cloud.agent.api.CheckVirtualMachineCommand; +import com.cloud.agent.api.DeleteStoragePoolCommand; import com.cloud.agent.api.GetHostStatsCommand; +import com.cloud.agent.api.GetStorageStatsCommand; import com.cloud.agent.api.GetVmDiskStatsCommand; import com.cloud.agent.api.GetVmStatsCommand; import com.cloud.agent.api.GetVncPortCommand; @@ -81,12 +83,14 @@ import com.cloud.agent.api.RebootCommand; import com.cloud.agent.api.RebootRouterCommand; import com.cloud.agent.api.StopCommand; +import com.cloud.agent.api.UpgradeSnapshotCommand; import com.cloud.agent.api.VmStatsEntry; import com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand; import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand; import com.cloud.agent.api.storage.CreateCommand; import com.cloud.agent.api.storage.DestroyCommand; import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand; +import com.cloud.agent.api.to.DataStoreTO; import com.cloud.agent.api.to.DiskTO; import com.cloud.agent.api.to.NicTO; import com.cloud.agent.api.to.StorageFilerTO; @@ -557,6 +561,40 @@ public void testGetVmDiskStatsCommand() { } } + @SuppressWarnings("unchecked") + @Test + public void testGetVmDiskStatsCommandException() { + final Connect conn = Mockito.mock(Connect.class); + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + + final String vmName = "Test"; + final String uuid = "e8d6b4d0-bc6d-4613-b8bb-cb9e0600f3c6"; + final List vms = new ArrayList(); + vms.add(vmName); + + final GetVmDiskStatsCommand command = new GetVmDiskStatsCommand(vms, uuid, "hostname"); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + try { + when(libvirtConnectionWrapper.getConnection()).thenThrow(LibvirtException.class); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnection(); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + @Test public void testRebootCommand() { final Connect conn = Mockito.mock(Connect.class); @@ -619,6 +657,39 @@ public void testRebootRouterCommand() { } } + @Test + public void testRebootRouterCommandConnect() { + final VirtualRoutingResource routingResource = Mockito.mock(VirtualRoutingResource.class); + final Connect conn = Mockito.mock(Connect.class); + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + + final String vmName = "Test"; + final RebootRouterCommand command = new RebootRouterCommand(vmName, "192.168.0.10"); + + when(libvirtComputingResource.getVirtRouterResource()).thenReturn(routingResource); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(routingResource.connect(command.getPrivateIpAddress())).thenReturn(true); + try { + when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenReturn(conn); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getVirtRouterResource(); + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vmName); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + @Test(expected = NumberFormatException.class) public void testGetHostStatsCommand() { // A bit difficult to test due to the logger being passed and the parser itself relying on the connection. @@ -1533,4 +1604,108 @@ public void testPrimaryStorageDownloadCommandTemplateNoDisk() { verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); verify(storagePoolMgr, times(1)).getStoragePool(command.getPool().getType(), command.getPoolUuid()); } -} + + @Test + public void testGetStorageStatsCommand() { + final DataStoreTO store = Mockito.mock(DataStoreTO.class); + final GetStorageStatsCommand command = new GetStorageStatsCommand(store ); + + final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class); + final KVMStoragePool secondaryPool = Mockito.mock(KVMStoragePool.class); + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr); + when(storagePoolMgr.getStoragePool(command.getPooltype(), command.getStorageId(), true)).thenReturn(secondaryPool); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + verify(storagePoolMgr, times(1)).getStoragePool(command.getPooltype(), command.getStorageId(), true); + } + + @SuppressWarnings("unchecked") + @Test + public void testGetStorageStatsCommandException() { + final DataStoreTO store = Mockito.mock(DataStoreTO.class); + final GetStorageStatsCommand command = new GetStorageStatsCommand(store ); + + when(libvirtComputingResource.getStoragePoolMgr()).thenThrow(CloudRuntimeException.class); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + } + + @Test + public void testUpgradeSnapshotCommand() { + final StoragePool pool = null; + final String secondaryStoragePoolURL = null; + final Long dcId = null; + final Long accountId = null; + final Long volumeId = null; + final Long templateId = null; + final Long tmpltAccountId = null; + final String volumePath = null; + final String snapshotUuid = null; + final String snapshotName = null; + final String version = null; + + final UpgradeSnapshotCommand command = new UpgradeSnapshotCommand(pool, secondaryStoragePoolURL, dcId, accountId, volumeId, templateId, tmpltAccountId, volumePath, snapshotUuid, snapshotName, version); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + } + + @Test + public void testDeleteStoragePoolCommand() { + final StoragePool storagePool = Mockito.mock(StoragePool.class); + final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class); + + final DeleteStoragePoolCommand command = new DeleteStoragePoolCommand(storagePool); + + final StorageFilerTO pool = command.getPool(); + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr); + when(storagePoolMgr.deleteStoragePool(pool.getType(), pool.getUuid())).thenReturn(true); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + verify(storagePoolMgr, times(1)).deleteStoragePool(pool.getType(), pool.getUuid()); + } + + @SuppressWarnings("unchecked") + @Test + public void testDeleteStoragePoolCommandException() { + final StoragePool storagePool = Mockito.mock(StoragePool.class); + final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class); + + final DeleteStoragePoolCommand command = new DeleteStoragePoolCommand(storagePool); + + final StorageFilerTO pool = command.getPool(); + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr); + when(storagePoolMgr.deleteStoragePool(pool.getType(), pool.getUuid())).thenThrow(CloudRuntimeException.class); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + verify(storagePoolMgr, times(1)).deleteStoragePool(pool.getType(), pool.getUuid()); + } +} \ No newline at end of file From 4887ce72544c3a9b9f507a916ec0c3a22e6b25f5 Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Fri, 1 May 2015 12:04:16 +0200 Subject: [PATCH 020/175] Refactoring the LibvirtComputingResource - Adding LibvirtOvsDestroyBridgeCommandWrapper, LibvirtOvsSetupBridgeCommandWrapper - 4 unit tests added - KVM hypervisor plugin with 13.9% coverage More tests added to cover LibvirtPrepareForMigrationCommandWrapper - Coverage of this wrapper broght from 37% to 90.6% - 4 new tests added --- .../resource/LibvirtComputingResource.java | 55 +--- ...LibvirtOvsDestroyBridgeCommandWrapper.java | 43 +++ .../LibvirtOvsSetupBridgeCommandWrapper.java | 47 +++ ...virtPrepareForMigrationCommandWrapper.java | 6 +- .../wrapper/LibvirtRequestWrapper.java | 4 + .../LibvirtComputingResourceTest.java | 287 ++++++++++++++++++ 6 files changed, 400 insertions(+), 42 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsDestroyBridgeCommandWrapper.java create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsSetupBridgeCommandWrapper.java diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index f72fecf756c3..cc73e65768e2 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -108,11 +108,9 @@ import com.cloud.agent.api.NetworkUsageCommand; import com.cloud.agent.api.OvsCreateTunnelAnswer; import com.cloud.agent.api.OvsCreateTunnelCommand; -import com.cloud.agent.api.OvsDestroyBridgeCommand; import com.cloud.agent.api.OvsDestroyTunnelCommand; import com.cloud.agent.api.OvsFetchInterfaceAnswer; import com.cloud.agent.api.OvsFetchInterfaceCommand; -import com.cloud.agent.api.OvsSetupBridgeCommand; import com.cloud.agent.api.OvsVpcPhysicalTopologyConfigCommand; import com.cloud.agent.api.OvsVpcRoutingPolicyConfigCommand; import com.cloud.agent.api.PingCommand; @@ -1342,10 +1340,6 @@ public Answer executeRequest(final Command cmd) { return execute((CheckOnHostCommand)cmd); } else if (cmd instanceof OvsFetchInterfaceCommand) { return execute((OvsFetchInterfaceCommand)cmd); - } else if (cmd instanceof OvsSetupBridgeCommand) { - return execute((OvsSetupBridgeCommand)cmd); - } else if (cmd instanceof OvsDestroyBridgeCommand) { - return execute((OvsDestroyBridgeCommand)cmd); } else if (cmd instanceof OvsCreateTunnelCommand) { return execute((OvsCreateTunnelCommand)cmd); } else if (cmd instanceof OvsDestroyTunnelCommand) { @@ -1381,20 +1375,6 @@ private OvsFetchInterfaceAnswer execute(final OvsFetchInterfaceCommand cmd) { } - private Answer execute(final OvsSetupBridgeCommand cmd) { - findOrCreateTunnelNetwork(cmd.getBridgeName()); - configureTunnelNetwork(cmd.getNetworkId(), cmd.getHostId(), - cmd.getBridgeName()); - s_logger.debug("OVS Bridge configured"); - return new Answer(cmd, true, null); - } - - private Answer execute(final OvsDestroyBridgeCommand cmd) { - destroyTunnelNetwork(cmd.getBridgeName()); - s_logger.debug("OVS Bridge destroyed"); - return new Answer(cmd, true, null); - } - public Answer execute(final OvsVpcPhysicalTopologyConfigCommand cmd) { final String bridge = cmd.getBridgeName(); @@ -1436,28 +1416,23 @@ public Answer execute(final OvsVpcRoutingPolicyConfigCommand cmd) { } } - private synchronized void destroyTunnelNetwork(final String bridge) { - try { - findOrCreateTunnelNetwork(bridge); - final Script cmd = new Script(_ovsTunnelPath, _timeout, s_logger); - cmd.add("destroy_ovs_bridge"); - cmd.add("--bridge", bridge); - final String result = cmd.execute(); - if (result != null) { - // TODO: Should make this error not fatal? - // Can Concurrent VM shutdown/migration/reboot events can cause - // this method - // to be executed on a bridge which has already been removed? - throw new CloudRuntimeException("Unable to remove OVS bridge " + bridge); - } - return; - } catch (final Exception e) { - s_logger.warn("destroyTunnelNetwork failed:", e); - return; + public synchronized boolean destroyTunnelNetwork(final String bridge) { + findOrCreateTunnelNetwork(bridge); + + final Script cmd = new Script(_ovsTunnelPath, _timeout, s_logger); + cmd.add("destroy_ovs_bridge"); + cmd.add("--bridge", bridge); + + final String result = cmd.execute(); + + if (result != null) { + s_logger.debug("OVS Bridge could not be destroyed due to error ==> " + result); + return false; } + return true; } - private synchronized boolean findOrCreateTunnelNetwork(final String nwName) { + public synchronized boolean findOrCreateTunnelNetwork(final String nwName) { try { if (checkNetwork(nwName)) { return true; @@ -1475,7 +1450,7 @@ private synchronized boolean findOrCreateTunnelNetwork(final String nwName) { return true; } - private synchronized boolean configureTunnelNetwork(final long networkId, + public synchronized boolean configureTunnelNetwork(final long networkId, final long hostId, final String nwName) { try { findOrCreateTunnelNetwork(nwName); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsDestroyBridgeCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsDestroyBridgeCommandWrapper.java new file mode 100644 index 000000000000..ab2b9c40c40a --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsDestroyBridgeCommandWrapper.java @@ -0,0 +1,43 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import org.apache.log4j.Logger; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.OvsDestroyBridgeCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; + +public final class LibvirtOvsDestroyBridgeCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtOvsDestroyBridgeCommandWrapper.class); + + @Override + public Answer execute(final OvsDestroyBridgeCommand command, final LibvirtComputingResource libvirtComputingResource) { + final boolean result = libvirtComputingResource.destroyTunnelNetwork(command.getBridgeName()); + + if (!result) { + s_logger.debug("Error trying to destroy OVS Bridge!"); + } + + return new Answer(command, result, null); + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsSetupBridgeCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsSetupBridgeCommandWrapper.java new file mode 100644 index 000000000000..4c979a7be437 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsSetupBridgeCommandWrapper.java @@ -0,0 +1,47 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import org.apache.log4j.Logger; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.OvsSetupBridgeCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; + +public final class LibvirtOvsSetupBridgeCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtOvsSetupBridgeCommandWrapper.class); + + @Override + public Answer execute(final OvsSetupBridgeCommand command, final LibvirtComputingResource libvirtComputingResource) { + final boolean findResult = libvirtComputingResource.findOrCreateTunnelNetwork(command.getBridgeName()); + final boolean configResult = libvirtComputingResource.configureTunnelNetwork(command.getNetworkId(), command.getHostId(), + command.getBridgeName()); + + final boolean finalResult = findResult && configResult; + + if (!finalResult) { + s_logger.debug("::FAILURE:: OVS Bridge was NOT configured properly!"); + } + + return new Answer(command, finalResult, null); + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPrepareForMigrationCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPrepareForMigrationCommandWrapper.java index 921d5b8cf644..108b0d2f3d74 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPrepareForMigrationCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPrepareForMigrationCommandWrapper.java @@ -33,6 +33,7 @@ import com.cloud.agent.api.to.VirtualMachineTO; import com.cloud.exception.InternalErrorException; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; import com.cloud.resource.CommandWrapper; import com.cloud.storage.Volume; @@ -51,6 +52,7 @@ public Answer execute(final PrepareForMigrationCommand command, final LibvirtCom boolean skipDisconnect = false; + final KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr(); try { final LibvirtConnectionWrapper libvirtConnectionWrapper = libvirtComputingResource.getLibvirtConnectionWrapper(); @@ -69,7 +71,7 @@ public Answer execute(final PrepareForMigrationCommand command, final LibvirtCom skipDisconnect = true; - if (!libvirtComputingResource.getStoragePoolMgr().connectPhysicalDisksViaVmSpec(vm)) { + if (!storagePoolMgr.connectPhysicalDisksViaVmSpec(vm)) { return new PrepareForMigrationAnswer(command, "failed to connect physical disks to host"); } @@ -82,7 +84,7 @@ public Answer execute(final PrepareForMigrationCommand command, final LibvirtCom return new PrepareForMigrationAnswer(command, e.toString()); } finally { if (!skipDisconnect) { - libvirtComputingResource.getStoragePoolMgr().disconnectPhysicalDisksViaVmSpec(vm); + storagePoolMgr.disconnectPhysicalDisksViaVmSpec(vm); } } } diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java index 04aa2ea518d9..05dbe2d1606b 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java @@ -35,6 +35,8 @@ import com.cloud.agent.api.MaintainCommand; import com.cloud.agent.api.MigrateCommand; import com.cloud.agent.api.ModifySshKeysCommand; +import com.cloud.agent.api.OvsDestroyBridgeCommand; +import com.cloud.agent.api.OvsSetupBridgeCommand; import com.cloud.agent.api.PingTestCommand; import com.cloud.agent.api.PrepareForMigrationCommand; import com.cloud.agent.api.ReadyCommand; @@ -94,6 +96,8 @@ private void init() { linbvirtCommands.put(GetStorageStatsCommand.class, new LibvirtGetStorageStatsCommandWrapper()); linbvirtCommands.put(UpgradeSnapshotCommand.class, new LibvirtUpgradeSnapshotCommandWrapper()); linbvirtCommands.put(DeleteStoragePoolCommand.class, new LibvirtDeleteStoragePoolCommandWrapper()); + linbvirtCommands.put(OvsSetupBridgeCommand.class, new LibvirtOvsSetupBridgeCommandWrapper()); + linbvirtCommands.put(OvsDestroyBridgeCommand.class, new LibvirtOvsDestroyBridgeCommandWrapper()); resources.put(LibvirtComputingResource.class, linbvirtCommands); } diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index 2432c98c39ad..b8046f5f2a33 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -77,6 +77,8 @@ import com.cloud.agent.api.MaintainCommand; import com.cloud.agent.api.MigrateCommand; import com.cloud.agent.api.ModifySshKeysCommand; +import com.cloud.agent.api.OvsDestroyBridgeCommand; +import com.cloud.agent.api.OvsSetupBridgeCommand; import com.cloud.agent.api.PingTestCommand; import com.cloud.agent.api.PrepareForMigrationCommand; import com.cloud.agent.api.ReadyCommand; @@ -764,6 +766,203 @@ public void testPrepareForMigrationCommand() { verify(diskTO, times(1)).getType(); } + @Test + public void testPrepareForMigrationCommandMigration() { + final Connect conn = Mockito.mock(Connect.class); + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + + final VirtualMachineTO vm = Mockito.mock(VirtualMachineTO.class); + final KVMStoragePoolManager storagePoolManager = Mockito.mock(KVMStoragePoolManager.class); + final NicTO nicTO = Mockito.mock(NicTO.class); + final DiskTO diskTO = Mockito.mock(DiskTO.class); + final VifDriver vifDriver = Mockito.mock(VifDriver.class); + + final PrepareForMigrationCommand command = new PrepareForMigrationCommand(vm); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + try { + when(libvirtConnectionWrapper.getConnectionByVmName(vm.getName())).thenReturn(conn); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + when(vm.getNics()).thenReturn(new NicTO[]{nicTO}); + when(vm.getDisks()).thenReturn(new DiskTO[]{diskTO}); + + when(nicTO.getType()).thenReturn(TrafficType.Guest); + when(diskTO.getType()).thenReturn(Volume.Type.ISO); + + when(libvirtComputingResource.getVifDriver(nicTO.getType())).thenReturn(vifDriver); + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolManager); + when(storagePoolManager.connectPhysicalDisksViaVmSpec(vm)).thenReturn(true); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vm.getName()); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + verify(vm, times(1)).getNics(); + verify(vm, times(1)).getDisks(); + verify(diskTO, times(1)).getType(); + } + + @SuppressWarnings("unchecked") + @Test + public void testPrepareForMigrationCommandLibvirtException() { + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + + final VirtualMachineTO vm = Mockito.mock(VirtualMachineTO.class); + final KVMStoragePoolManager storagePoolManager = Mockito.mock(KVMStoragePoolManager.class); + final NicTO nicTO = Mockito.mock(NicTO.class); + final VifDriver vifDriver = Mockito.mock(VifDriver.class); + + final PrepareForMigrationCommand command = new PrepareForMigrationCommand(vm); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + try { + when(libvirtConnectionWrapper.getConnectionByVmName(vm.getName())).thenThrow(LibvirtException.class); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + when(vm.getNics()).thenReturn(new NicTO[]{nicTO}); + when(nicTO.getType()).thenReturn(TrafficType.Guest); + + when(libvirtComputingResource.getVifDriver(nicTO.getType())).thenReturn(vifDriver); + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolManager); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vm.getName()); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + verify(vm, times(1)).getNics(); + } + + @SuppressWarnings("unchecked") + @Test + public void testPrepareForMigrationCommandURISyntaxException() { + final Connect conn = Mockito.mock(Connect.class); + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + + final VirtualMachineTO vm = Mockito.mock(VirtualMachineTO.class); + final KVMStoragePoolManager storagePoolManager = Mockito.mock(KVMStoragePoolManager.class); + final NicTO nicTO = Mockito.mock(NicTO.class); + final DiskTO volume = Mockito.mock(DiskTO.class); + final VifDriver vifDriver = Mockito.mock(VifDriver.class); + + final PrepareForMigrationCommand command = new PrepareForMigrationCommand(vm); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + try { + when(libvirtConnectionWrapper.getConnectionByVmName(vm.getName())).thenReturn(conn); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + when(vm.getNics()).thenReturn(new NicTO[]{nicTO}); + when(vm.getDisks()).thenReturn(new DiskTO[]{volume}); + + when(nicTO.getType()).thenReturn(TrafficType.Guest); + when(volume.getType()).thenReturn(Volume.Type.ISO); + + when(libvirtComputingResource.getVifDriver(nicTO.getType())).thenReturn(vifDriver); + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolManager); + try { + when(libvirtComputingResource.getVolumePath(conn, volume)).thenThrow(URISyntaxException.class); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } catch (final URISyntaxException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vm.getName()); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + verify(vm, times(1)).getNics(); + verify(vm, times(1)).getDisks(); + verify(volume, times(1)).getType(); + } + + @SuppressWarnings("unchecked") + @Test + public void testPrepareForMigrationCommandInternalErrorException() { + final Connect conn = Mockito.mock(Connect.class); + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + + final VirtualMachineTO vm = Mockito.mock(VirtualMachineTO.class); + final KVMStoragePoolManager storagePoolManager = Mockito.mock(KVMStoragePoolManager.class); + final NicTO nicTO = Mockito.mock(NicTO.class); + final DiskTO volume = Mockito.mock(DiskTO.class); + + final PrepareForMigrationCommand command = new PrepareForMigrationCommand(vm); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + try { + when(libvirtConnectionWrapper.getConnectionByVmName(vm.getName())).thenReturn(conn); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + when(vm.getNics()).thenReturn(new NicTO[]{nicTO}); + when(nicTO.getType()).thenReturn(TrafficType.Guest); + + when(libvirtComputingResource.getVifDriver(nicTO.getType())).thenThrow(InternalErrorException.class); + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolManager); + try { + when(libvirtComputingResource.getVolumePath(conn, volume)).thenReturn("/path"); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } catch (final URISyntaxException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vm.getName()); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + verify(vm, times(1)).getNics(); + } + @Test(expected = UnsatisfiedLinkError.class) public void testMigrateCommand() { // The Connect constructor used inside the LibvirtMigrateCommandWrapper has a call to native methods, which @@ -1708,4 +1907,92 @@ public void testDeleteStoragePoolCommandException() { verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); verify(storagePoolMgr, times(1)).deleteStoragePool(pool.getType(), pool.getUuid()); } + + @Test + public void testOvsSetupBridgeCommand() { + final String name = "Test"; + final Long hostId = 1l; + final Long networkId = 1l; + + final OvsSetupBridgeCommand command = new OvsSetupBridgeCommand(name, hostId, networkId); + + when(libvirtComputingResource.findOrCreateTunnelNetwork(command.getBridgeName())).thenReturn(true); + when(libvirtComputingResource.configureTunnelNetwork(command.getNetworkId(), command.getHostId(), + command.getBridgeName())).thenReturn(true); + + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).findOrCreateTunnelNetwork(command.getBridgeName()); + verify(libvirtComputingResource, times(1)).configureTunnelNetwork(command.getNetworkId(), command.getHostId(), + command.getBridgeName()); + } + + @Test + public void testOvsSetupBridgeCommandFailure() { + final String name = "Test"; + final Long hostId = 1l; + final Long networkId = 1l; + + final OvsSetupBridgeCommand command = new OvsSetupBridgeCommand(name, hostId, networkId); + + when(libvirtComputingResource.findOrCreateTunnelNetwork(command.getBridgeName())).thenReturn(true); + when(libvirtComputingResource.configureTunnelNetwork(command.getNetworkId(), command.getHostId(), + command.getBridgeName())).thenReturn(false); + + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).findOrCreateTunnelNetwork(command.getBridgeName()); + verify(libvirtComputingResource, times(1)).configureTunnelNetwork(command.getNetworkId(), command.getHostId(), + command.getBridgeName()); + } + + @Test + public void testOvsDestroyBridgeCommand() { + final String name = "Test"; + final Long hostId = 1l; + final Long networkId = 1l; + + final OvsDestroyBridgeCommand command = new OvsDestroyBridgeCommand(networkId, name, hostId); + + when(libvirtComputingResource.destroyTunnelNetwork(command.getBridgeName())).thenReturn(true); + + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).destroyTunnelNetwork(command.getBridgeName()); + } + + @Test + public void testOvsDestroyBridgeCommandFailure() { + final String name = "Test"; + final Long hostId = 1l; + final Long networkId = 1l; + + final OvsDestroyBridgeCommand command = new OvsDestroyBridgeCommand(networkId, name, hostId); + + when(libvirtComputingResource.destroyTunnelNetwork(command.getBridgeName())).thenReturn(false); + + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).destroyTunnelNetwork(command.getBridgeName()); + } } \ No newline at end of file From 5499eecd33d93c88ed9c0b4828deb0d11ac0a66e Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Fri, 1 May 2015 14:43:30 +0200 Subject: [PATCH 021/175] Refactoring the LibvirtComputingResource - Adding 7 new command wrappers - 10 unit tests added - KVM hypervisor plugin with 14.8% coverage --- .../resource/LibvirtComputingResource.java | 128 +---------- ...virtCleanupNetworkRulesCommandWrapper.java | 34 +++ ...ibvirtCreateStoragePoolCommandWrapper.java | 33 +++ ...ibvirtModifyStoragePoolCommandWrapper.java | 51 +++++ ...tworkRulesVmSecondaryIpCommandWrapper.java | 49 ++++ ...ibvirtOvsFetchInterfaceCommandWrapper.java | 53 +++++ ...cPhysicalTopologyConfigCommandWrapper.java | 53 +++++ ...sVpcRoutingPolicyConfigCommandWrapper.java | 53 +++++ .../wrapper/LibvirtRequestWrapper.java | 14 ++ .../LibvirtComputingResourceTest.java | 212 ++++++++++++++++++ 10 files changed, 558 insertions(+), 122 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCleanupNetworkRulesCommandWrapper.java create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreateStoragePoolCommandWrapper.java create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtModifyStoragePoolCommandWrapper.java create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkRulesVmSecondaryIpCommandWrapper.java create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsFetchInterfaceCommandWrapper.java create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsVpcPhysicalTopologyConfigCommandWrapper.java create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsVpcRoutingPolicyConfigCommandWrapper.java diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index cc73e65768e2..75c9663e35f3 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -88,11 +88,9 @@ import com.cloud.agent.api.CheckNetworkAnswer; import com.cloud.agent.api.CheckNetworkCommand; import com.cloud.agent.api.CheckOnHostCommand; -import com.cloud.agent.api.CleanupNetworkRulesCmd; import com.cloud.agent.api.Command; import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand; import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand; -import com.cloud.agent.api.CreateStoragePoolCommand; import com.cloud.agent.api.CreateVolumeFromSnapshotAnswer; import com.cloud.agent.api.CreateVolumeFromSnapshotCommand; import com.cloud.agent.api.FenceAnswer; @@ -100,19 +98,12 @@ import com.cloud.agent.api.HostVmStateReportEntry; import com.cloud.agent.api.ManageSnapshotAnswer; import com.cloud.agent.api.ManageSnapshotCommand; -import com.cloud.agent.api.ModifyStoragePoolAnswer; -import com.cloud.agent.api.ModifyStoragePoolCommand; import com.cloud.agent.api.NetworkRulesSystemVmCommand; -import com.cloud.agent.api.NetworkRulesVmSecondaryIpCommand; import com.cloud.agent.api.NetworkUsageAnswer; import com.cloud.agent.api.NetworkUsageCommand; import com.cloud.agent.api.OvsCreateTunnelAnswer; import com.cloud.agent.api.OvsCreateTunnelCommand; import com.cloud.agent.api.OvsDestroyTunnelCommand; -import com.cloud.agent.api.OvsFetchInterfaceAnswer; -import com.cloud.agent.api.OvsFetchInterfaceCommand; -import com.cloud.agent.api.OvsVpcPhysicalTopologyConfigCommand; -import com.cloud.agent.api.OvsVpcRoutingPolicyConfigCommand; import com.cloud.agent.api.PingCommand; import com.cloud.agent.api.PingRoutingCommand; import com.cloud.agent.api.PingRoutingWithNwGroupsCommand; @@ -202,7 +193,6 @@ import com.cloud.storage.template.Processor.FormatInfo; import com.cloud.storage.template.QCOW2Processor; import com.cloud.storage.template.TemplateLocation; -import com.cloud.storage.template.TemplateProp; import com.cloud.utils.ExecutionResult; import com.cloud.utils.NumbersUtil; import com.cloud.utils.Pair; @@ -443,6 +433,10 @@ public int getTimeout() { return _timeout; } + public String getOvsTunnelPath() { + return _ovsTunnelPath; + } + private static final class KeyValueInterpreter extends OutputInterpreter { private final Map map = new HashMap(); @@ -1300,10 +1294,6 @@ public Answer executeRequest(final Command cmd) { return execute((CreateVolumeFromSnapshotCommand)cmd); } else if (cmd instanceof CreatePrivateTemplateFromSnapshotCommand) { return execute((CreatePrivateTemplateFromSnapshotCommand)cmd); - } else if (cmd instanceof CreateStoragePoolCommand) { - return execute((CreateStoragePoolCommand)cmd); - } else if (cmd instanceof ModifyStoragePoolCommand) { - return execute((ModifyStoragePoolCommand)cmd); } else if (cmd instanceof SecurityGroupRulesCmd) { return execute((SecurityGroupRulesCmd)cmd); } else if (cmd instanceof FenceCommand) { @@ -1322,32 +1312,22 @@ public Answer executeRequest(final Command cmd) { return execute((NetworkUsageCommand)cmd); } else if (cmd instanceof NetworkRulesSystemVmCommand) { return execute((NetworkRulesSystemVmCommand)cmd); - } else if (cmd instanceof CleanupNetworkRulesCmd) { - return execute((CleanupNetworkRulesCmd)cmd); } else if (cmd instanceof CopyVolumeCommand) { return execute((CopyVolumeCommand)cmd); } else if (cmd instanceof ResizeVolumeCommand) { return execute((ResizeVolumeCommand)cmd); } else if (cmd instanceof CheckNetworkCommand) { return execute((CheckNetworkCommand)cmd); - } else if (cmd instanceof NetworkRulesVmSecondaryIpCommand) { - return execute((NetworkRulesVmSecondaryIpCommand)cmd); } else if (cmd instanceof StorageSubSystemCommand) { return storageHandler.handleStorageCommands((StorageSubSystemCommand)cmd); } else if (cmd instanceof PvlanSetupCommand) { return execute((PvlanSetupCommand)cmd); } else if (cmd instanceof CheckOnHostCommand) { return execute((CheckOnHostCommand)cmd); - } else if (cmd instanceof OvsFetchInterfaceCommand) { - return execute((OvsFetchInterfaceCommand)cmd); } else if (cmd instanceof OvsCreateTunnelCommand) { return execute((OvsCreateTunnelCommand)cmd); } else if (cmd instanceof OvsDestroyTunnelCommand) { return execute((OvsDestroyTunnelCommand)cmd); - } else if (cmd instanceof OvsVpcPhysicalTopologyConfigCommand) { - return execute((OvsVpcPhysicalTopologyConfigCommand) cmd); - } else if (cmd instanceof OvsVpcRoutingPolicyConfigCommand) { - return execute((OvsVpcRoutingPolicyConfigCommand) cmd); } else { s_logger.warn("Unsupported command "); return Answer.createUnsupportedCommandAnswer(cmd); @@ -1357,65 +1337,6 @@ public Answer executeRequest(final Command cmd) { } } - private OvsFetchInterfaceAnswer execute(final OvsFetchInterfaceCommand cmd) { - final String label = cmd.getLabel(); - s_logger.debug("Will look for network with name-label:" + label); - try { - final String ipadd = Script.runSimpleBashScript("ifconfig " + label + " | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'"); - final String mask = Script.runSimpleBashScript("ifconfig " + label + " | grep 'inet addr:' | cut -d: -f4"); - final String mac = Script.runSimpleBashScript("ifconfig " + label + " | grep HWaddr | awk -F \" \" '{print $5}'"); - return new OvsFetchInterfaceAnswer(cmd, true, "Interface " + label - + " retrieved successfully", ipadd, mask, mac); - - } catch (final Exception e) { - s_logger.warn("Caught execption when fetching interface", e); - return new OvsFetchInterfaceAnswer(cmd, false, "EXCEPTION:" - + e.getMessage()); - } - - } - - public Answer execute(final OvsVpcPhysicalTopologyConfigCommand cmd) { - - final String bridge = cmd.getBridgeName(); - try { - final Script command = new Script(_ovsTunnelPath, _timeout, s_logger); - command.add("configure_ovs_bridge_for_network_topology"); - command.add("--bridge", bridge); - command.add("--config", cmd.getVpcConfigInJson()); - - final String result = command.execute(); - if (result.equalsIgnoreCase("SUCCESS")) { - return new Answer(cmd, true, result); - } else { - return new Answer(cmd, false, result); - } - } catch (final Exception e) { - s_logger.warn("caught exception while updating host with latest routing polcies", e); - return new Answer(cmd, false, e.getMessage()); - } - } - - public Answer execute(final OvsVpcRoutingPolicyConfigCommand cmd) { - - try { - final Script command = new Script(_ovsTunnelPath, _timeout, s_logger); - command.add("configure_ovs_bridge_for_routing_policies"); - command.add("--bridge", cmd.getBridgeName()); - command.add("--config", cmd.getVpcConfigInJson()); - - final String result = command.execute(); - if (result.equalsIgnoreCase("SUCCESS")) { - return new Answer(cmd, true, result); - } else { - return new Answer(cmd, false, result); - } - } catch (final Exception e) { - s_logger.warn("caught exception while updating host with latest VPC topology", e); - return new Answer(cmd, false, e.getMessage()); - } - } - public synchronized boolean destroyTunnelNetwork(final String bridge) { findOrCreateTunnelNetwork(bridge); @@ -2642,24 +2563,6 @@ protected CreatePrivateTemplateAnswer execute(final CreatePrivateTemplateFromVol } } - protected Answer execute(final CreateStoragePoolCommand cmd) { - return new Answer(cmd, true, "success"); - } - - protected Answer execute(final ModifyStoragePoolCommand cmd) { - final KVMStoragePool storagepool = - _storagePoolMgr.createStoragePool(cmd.getPool().getUuid(), cmd.getPool().getHost(), cmd.getPool().getPort(), cmd.getPool().getPath(), cmd.getPool() - .getUserInfo(), cmd.getPool().getType()); - if (storagepool == null) { - return new Answer(cmd, false, " Failed to create storage pool"); - } - - final Map tInfo = new HashMap(); - final ModifyStoragePoolAnswer answer = new ModifyStoragePoolAnswer(cmd, storagepool.getCapacity(), storagepool.getAvailable(), tInfo); - - return answer; - } - private Answer execute(final SecurityGroupRulesCmd cmd) { String vif = null; String brname = null; @@ -2686,11 +2589,6 @@ private Answer execute(final SecurityGroupRulesCmd cmd) { } } - private Answer execute(final CleanupNetworkRulesCmd cmd) { - final boolean result = cleanup_rules(); - return new Answer(cmd, result, ""); - } - protected PowerState convertToPowerState(final DomainState ps) { final PowerState state = s_powerStatesTable.get(ps); return state == null ? PowerState.PowerUnknown : state; @@ -4386,7 +4284,7 @@ private boolean add_network_rules(final String vmName, final String vmId, final return true; } - private boolean network_rules_vmSecondaryIp(final Connect conn, final String vmName, final String secIp, final String action) { + public boolean configureNetworkRulesVMSecondaryIP(final Connect conn, final String vmName, final String secIp, final String action) { if (!_canBridgeFirewall) { return false; @@ -4405,7 +4303,7 @@ private boolean network_rules_vmSecondaryIp(final Connect conn, final String vmN return true; } - private boolean cleanup_rules() { + public boolean cleanupRules() { if (!_canBridgeFirewall) { return false; } @@ -4486,20 +4384,6 @@ private Answer execute(final NetworkRulesSystemVmCommand cmd) { return new Answer(cmd, success, ""); } - private Answer execute(final NetworkRulesVmSecondaryIpCommand cmd) { - boolean success = false; - Connect conn; - try { - conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); - success = network_rules_vmSecondaryIp(conn, cmd.getVmName(), cmd.getVmSecIp(), cmd.getAction()); - } catch (final LibvirtException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - return new Answer(cmd, success, ""); - } - private String prettyVersion(final long version) { final long major = version / 1000000; final long minor = version % 1000000 / 1000; diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCleanupNetworkRulesCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCleanupNetworkRulesCommandWrapper.java new file mode 100644 index 000000000000..59c353b594ce --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCleanupNetworkRulesCommandWrapper.java @@ -0,0 +1,34 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.CleanupNetworkRulesCmd; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; + +public final class LibvirtCleanupNetworkRulesCommandWrapper extends CommandWrapper { + + @Override + public Answer execute(final CleanupNetworkRulesCmd command, final LibvirtComputingResource libvirtComputingResource) { + final boolean result = libvirtComputingResource.cleanupRules(); + return new Answer(command, result, ""); + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreateStoragePoolCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreateStoragePoolCommandWrapper.java new file mode 100644 index 000000000000..e233b4fcd918 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreateStoragePoolCommandWrapper.java @@ -0,0 +1,33 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.CreateStoragePoolCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; + +public final class LibvirtCreateStoragePoolCommandWrapper extends CommandWrapper { + + @Override + public Answer execute(final CreateStoragePoolCommand command, final LibvirtComputingResource libvirtComputingResource) { + return new Answer(command, true, "success"); + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtModifyStoragePoolCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtModifyStoragePoolCommandWrapper.java new file mode 100644 index 000000000000..34d12bad4ddb --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtModifyStoragePoolCommandWrapper.java @@ -0,0 +1,51 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import java.util.HashMap; +import java.util.Map; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.ModifyStoragePoolAnswer; +import com.cloud.agent.api.ModifyStoragePoolCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.hypervisor.kvm.storage.KVMStoragePool; +import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; +import com.cloud.resource.CommandWrapper; +import com.cloud.storage.template.TemplateProp; + +public final class LibvirtModifyStoragePoolCommandWrapper extends CommandWrapper { + + @Override + public Answer execute(final ModifyStoragePoolCommand command, final LibvirtComputingResource libvirtComputingResource) { + final KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr(); + final KVMStoragePool storagepool = + storagePoolMgr.createStoragePool(command.getPool().getUuid(), command.getPool().getHost(), command.getPool().getPort(), command.getPool().getPath(), command.getPool() + .getUserInfo(), command.getPool().getType()); + if (storagepool == null) { + return new Answer(command, false, " Failed to create storage pool"); + } + + final Map tInfo = new HashMap(); + final ModifyStoragePoolAnswer answer = new ModifyStoragePoolAnswer(command, storagepool.getCapacity(), storagepool.getAvailable(), tInfo); + + return answer; + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkRulesVmSecondaryIpCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkRulesVmSecondaryIpCommandWrapper.java new file mode 100644 index 000000000000..6f1534508905 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkRulesVmSecondaryIpCommandWrapper.java @@ -0,0 +1,49 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import org.apache.log4j.Logger; +import org.libvirt.Connect; +import org.libvirt.LibvirtException; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.NetworkRulesVmSecondaryIpCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; + +public final class LibvirtNetworkRulesVmSecondaryIpCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtOvsVpcRoutingPolicyConfigCommandWrapper.class); + + @Override + public Answer execute(final NetworkRulesVmSecondaryIpCommand command, final LibvirtComputingResource libvirtComputingResource) { + boolean result = false; + try { + final LibvirtConnectionWrapper libvirtConnectionWrapper = libvirtComputingResource.getLibvirtConnectionWrapper(); + + final Connect conn = libvirtConnectionWrapper.getConnectionByVmName(command.getVmName()); + result = libvirtComputingResource.configureNetworkRulesVMSecondaryIP(conn, command.getVmName(), command.getVmSecIp(), command.getAction()); + } catch (final LibvirtException e) { + s_logger.debug("Could not configure VM secondary IP! => " + e.getLocalizedMessage()); + } + + return new Answer(command, result, ""); + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsFetchInterfaceCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsFetchInterfaceCommandWrapper.java new file mode 100644 index 000000000000..e7d0b7e9536b --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsFetchInterfaceCommandWrapper.java @@ -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 com.cloud.hypervisor.kvm.resource.wrapper; + +import org.apache.log4j.Logger; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.OvsFetchInterfaceAnswer; +import com.cloud.agent.api.OvsFetchInterfaceCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; +import com.cloud.utils.script.Script; + +public final class LibvirtOvsFetchInterfaceCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtOvsFetchInterfaceCommandWrapper.class); + + @Override + public Answer execute(final OvsFetchInterfaceCommand command, final LibvirtComputingResource libvirtComputingResource) { + final String label = command.getLabel(); + + s_logger.debug("Will look for network with name-label:" + label); + try { + final String ipadd = Script.runSimpleBashScript("ifconfig " + label + " | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'"); + final String mask = Script.runSimpleBashScript("ifconfig " + label + " | grep 'inet addr:' | cut -d: -f4"); + final String mac = Script.runSimpleBashScript("ifconfig " + label + " | grep HWaddr | awk -F \" \" '{print $5}'"); + return new OvsFetchInterfaceAnswer(command, true, "Interface " + label + + " retrieved successfully", ipadd, mask, mac); + + } catch (final Exception e) { + s_logger.warn("Caught execption when fetching interface", e); + return new OvsFetchInterfaceAnswer(command, false, "EXCEPTION:" + + e.getMessage()); + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsVpcPhysicalTopologyConfigCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsVpcPhysicalTopologyConfigCommandWrapper.java new file mode 100644 index 000000000000..d1e86516d0ec --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsVpcPhysicalTopologyConfigCommandWrapper.java @@ -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 com.cloud.hypervisor.kvm.resource.wrapper; + +import org.apache.log4j.Logger; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.OvsVpcPhysicalTopologyConfigCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; +import com.cloud.utils.script.Script; + +public final class LibvirtOvsVpcPhysicalTopologyConfigCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtOvsVpcPhysicalTopologyConfigCommandWrapper.class); + + @Override + public Answer execute(final OvsVpcPhysicalTopologyConfigCommand command, final LibvirtComputingResource libvirtComputingResource) { + try { + final Script scriptCommand = new Script(libvirtComputingResource.getOvsTunnelPath(), libvirtComputingResource.getTimeout(), s_logger); + scriptCommand.add("configure_ovs_bridge_for_network_topology"); + scriptCommand.add("--bridge", command.getBridgeName()); + scriptCommand.add("--config", command.getVpcConfigInJson()); + + final String result = scriptCommand.execute(); + if (result.equalsIgnoreCase("SUCCESS")) { + return new Answer(command, true, result); + } else { + return new Answer(command, false, result); + } + } catch (final Exception e) { + s_logger.warn("caught exception while updating host with latest routing polcies", e); + return new Answer(command, false, e.getMessage()); + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsVpcRoutingPolicyConfigCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsVpcRoutingPolicyConfigCommandWrapper.java new file mode 100644 index 000000000000..36762ed0a4a9 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsVpcRoutingPolicyConfigCommandWrapper.java @@ -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 com.cloud.hypervisor.kvm.resource.wrapper; + +import org.apache.log4j.Logger; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.OvsVpcRoutingPolicyConfigCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; +import com.cloud.utils.script.Script; + +public final class LibvirtOvsVpcRoutingPolicyConfigCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtOvsVpcRoutingPolicyConfigCommandWrapper.class); + + @Override + public Answer execute(final OvsVpcRoutingPolicyConfigCommand command, final LibvirtComputingResource libvirtComputingResource) { + try { + final Script scriptCommand = new Script(libvirtComputingResource.getOvsTunnelPath(), libvirtComputingResource.getTimeout(), s_logger); + scriptCommand.add("configure_ovs_bridge_for_routing_policies"); + scriptCommand.add("--bridge", command.getBridgeName()); + scriptCommand.add("--config", command.getVpcConfigInJson()); + + final String result = scriptCommand.execute(); + if (result.equalsIgnoreCase("SUCCESS")) { + return new Answer(command, true, result); + } else { + return new Answer(command, false, result); + } + } catch (final Exception e) { + s_logger.warn("caught exception while updating host with latest VPC topology", e); + return new Answer(command, false, e.getMessage()); + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java index 05dbe2d1606b..87b4ec24d354 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java @@ -25,7 +25,9 @@ import com.cloud.agent.api.AttachVolumeCommand; import com.cloud.agent.api.CheckHealthCommand; import com.cloud.agent.api.CheckVirtualMachineCommand; +import com.cloud.agent.api.CleanupNetworkRulesCmd; import com.cloud.agent.api.Command; +import com.cloud.agent.api.CreateStoragePoolCommand; import com.cloud.agent.api.DeleteStoragePoolCommand; import com.cloud.agent.api.GetHostStatsCommand; import com.cloud.agent.api.GetStorageStatsCommand; @@ -35,8 +37,13 @@ import com.cloud.agent.api.MaintainCommand; import com.cloud.agent.api.MigrateCommand; import com.cloud.agent.api.ModifySshKeysCommand; +import com.cloud.agent.api.ModifyStoragePoolCommand; +import com.cloud.agent.api.NetworkRulesVmSecondaryIpCommand; import com.cloud.agent.api.OvsDestroyBridgeCommand; +import com.cloud.agent.api.OvsFetchInterfaceCommand; import com.cloud.agent.api.OvsSetupBridgeCommand; +import com.cloud.agent.api.OvsVpcPhysicalTopologyConfigCommand; +import com.cloud.agent.api.OvsVpcRoutingPolicyConfigCommand; import com.cloud.agent.api.PingTestCommand; import com.cloud.agent.api.PrepareForMigrationCommand; import com.cloud.agent.api.ReadyCommand; @@ -98,6 +105,13 @@ private void init() { linbvirtCommands.put(DeleteStoragePoolCommand.class, new LibvirtDeleteStoragePoolCommandWrapper()); linbvirtCommands.put(OvsSetupBridgeCommand.class, new LibvirtOvsSetupBridgeCommandWrapper()); linbvirtCommands.put(OvsDestroyBridgeCommand.class, new LibvirtOvsDestroyBridgeCommandWrapper()); + linbvirtCommands.put(OvsFetchInterfaceCommand.class, new LibvirtOvsFetchInterfaceCommandWrapper()); + linbvirtCommands.put(OvsVpcPhysicalTopologyConfigCommand.class, new LibvirtOvsVpcPhysicalTopologyConfigCommandWrapper()); + linbvirtCommands.put(OvsVpcRoutingPolicyConfigCommand.class, new LibvirtOvsVpcRoutingPolicyConfigCommandWrapper()); + linbvirtCommands.put(CreateStoragePoolCommand.class, new LibvirtCreateStoragePoolCommandWrapper()); + linbvirtCommands.put(ModifyStoragePoolCommand.class, new LibvirtModifyStoragePoolCommandWrapper()); + linbvirtCommands.put(CleanupNetworkRulesCmd.class, new LibvirtCleanupNetworkRulesCommandWrapper()); + linbvirtCommands.put(NetworkRulesVmSecondaryIpCommand.class, new LibvirtNetworkRulesVmSecondaryIpCommandWrapper()); resources.put(LibvirtComputingResource.class, linbvirtCommands); } diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index b8046f5f2a33..8fd1ecfd66e7 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -68,6 +68,8 @@ import com.cloud.agent.api.AttachVolumeCommand; import com.cloud.agent.api.CheckHealthCommand; import com.cloud.agent.api.CheckVirtualMachineCommand; +import com.cloud.agent.api.CleanupNetworkRulesCmd; +import com.cloud.agent.api.CreateStoragePoolCommand; import com.cloud.agent.api.DeleteStoragePoolCommand; import com.cloud.agent.api.GetHostStatsCommand; import com.cloud.agent.api.GetStorageStatsCommand; @@ -77,8 +79,17 @@ import com.cloud.agent.api.MaintainCommand; import com.cloud.agent.api.MigrateCommand; import com.cloud.agent.api.ModifySshKeysCommand; +import com.cloud.agent.api.ModifyStoragePoolCommand; +import com.cloud.agent.api.NetworkRulesVmSecondaryIpCommand; import com.cloud.agent.api.OvsDestroyBridgeCommand; +import com.cloud.agent.api.OvsFetchInterfaceCommand; import com.cloud.agent.api.OvsSetupBridgeCommand; +import com.cloud.agent.api.OvsVpcPhysicalTopologyConfigCommand; +import com.cloud.agent.api.OvsVpcPhysicalTopologyConfigCommand.Host; +import com.cloud.agent.api.OvsVpcPhysicalTopologyConfigCommand.Tier; +import com.cloud.agent.api.OvsVpcPhysicalTopologyConfigCommand.Vm; +import com.cloud.agent.api.OvsVpcRoutingPolicyConfigCommand; +import com.cloud.agent.api.OvsVpcRoutingPolicyConfigCommand.Acl; import com.cloud.agent.api.PingTestCommand; import com.cloud.agent.api.PrepareForMigrationCommand; import com.cloud.agent.api.ReadyCommand; @@ -1995,4 +2006,205 @@ public void testOvsDestroyBridgeCommandFailure() { verify(libvirtComputingResource, times(1)).destroyTunnelNetwork(command.getBridgeName()); } + + @Test + public void testOvsFetchInterfaceCommand() { + final String label = "eth0"; + + final OvsFetchInterfaceCommand command = new OvsFetchInterfaceCommand(label); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + } + + @Test + public void testOvsVpcPhysicalTopologyConfigCommand() { + final Host[] hosts = null; + final Tier[] tiers = null; + final Vm[] vms = null; + final String cidr = null; + + final OvsVpcPhysicalTopologyConfigCommand command = new OvsVpcPhysicalTopologyConfigCommand(hosts, tiers, vms, cidr); + + when(libvirtComputingResource.getOvsTunnelPath()).thenReturn("/path"); + when(libvirtComputingResource.getTimeout()).thenReturn(0); + + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getOvsTunnelPath(); + verify(libvirtComputingResource, times(1)).getTimeout(); + } + + @Test + public void testOvsVpcRoutingPolicyConfigCommand() { + final String id = null; + final String cidr = null; + final Acl[] acls = null; + final com.cloud.agent.api.OvsVpcRoutingPolicyConfigCommand.Tier[] tiers = null; + + final OvsVpcRoutingPolicyConfigCommand command = new OvsVpcRoutingPolicyConfigCommand(id, cidr, acls, tiers); + + when(libvirtComputingResource.getOvsTunnelPath()).thenReturn("/path"); + when(libvirtComputingResource.getTimeout()).thenReturn(0); + + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getOvsTunnelPath(); + verify(libvirtComputingResource, times(1)).getTimeout(); + } + + @Test + public void testCreateStoragePoolCommand() { + final StoragePool pool = Mockito.mock(StoragePool.class); + final CreateStoragePoolCommand command = new CreateStoragePoolCommand(true, pool); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + } + + @Test + public void testModifyStoragePoolCommand() { + final StoragePool pool = Mockito.mock(StoragePool.class);; + final ModifyStoragePoolCommand command = new ModifyStoragePoolCommand(true, pool); + + final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class); + final KVMStoragePool kvmStoragePool = Mockito.mock(KVMStoragePool.class); + + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr); + when(storagePoolMgr.createStoragePool(command.getPool().getUuid(), command.getPool().getHost(), command.getPool().getPort(), command.getPool().getPath(), command.getPool() + .getUserInfo(), command.getPool().getType())).thenReturn(kvmStoragePool); + + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + verify(storagePoolMgr, times(1)).createStoragePool(command.getPool().getUuid(), command.getPool().getHost(), command.getPool().getPort(), command.getPool().getPath(), command.getPool() + .getUserInfo(), command.getPool().getType()); + } + + @Test + public void testModifyStoragePoolCommandFailure() { + final StoragePool pool = Mockito.mock(StoragePool.class);; + final ModifyStoragePoolCommand command = new ModifyStoragePoolCommand(true, pool); + + final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class); + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr); + when(storagePoolMgr.createStoragePool(command.getPool().getUuid(), command.getPool().getHost(), command.getPool().getPort(), command.getPool().getPath(), command.getPool() + .getUserInfo(), command.getPool().getType())).thenReturn(null); + + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + verify(storagePoolMgr, times(1)).createStoragePool(command.getPool().getUuid(), command.getPool().getHost(), command.getPool().getPort(), command.getPool().getPath(), command.getPool() + .getUserInfo(), command.getPool().getType()); + } + + @Test + public void testCleanupNetworkRulesCmd() { + final CleanupNetworkRulesCmd command = new CleanupNetworkRulesCmd(1); + + when(libvirtComputingResource.cleanupRules()).thenReturn(true); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).cleanupRules(); + } + + @Test + public void testNetworkRulesVmSecondaryIpCommand() { + final String vmName = "Test"; + final String vmMac = "00:00:00:00"; + final String secondaryIp = "172.168.25.25"; + final boolean action = true; + + final NetworkRulesVmSecondaryIpCommand command = new NetworkRulesVmSecondaryIpCommand(vmName, vmMac, secondaryIp, action ); + + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final Connect conn = Mockito.mock(Connect.class); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + try { + when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenReturn(conn); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + when(libvirtComputingResource.configureNetworkRulesVMSecondaryIP(conn, command.getVmName(), command.getVmSecIp(), command.getAction())).thenReturn(true); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + verify(libvirtComputingResource, times(1)).configureNetworkRulesVMSecondaryIP(conn, command.getVmName(), command.getVmSecIp(), command.getAction()); + } + + @SuppressWarnings("unchecked") + @Test + public void testNetworkRulesVmSecondaryIpCommandFailure() { + final String vmName = "Test"; + final String vmMac = "00:00:00:00"; + final String secondaryIp = "172.168.25.25"; + final boolean action = true; + + final NetworkRulesVmSecondaryIpCommand command = new NetworkRulesVmSecondaryIpCommand(vmName, vmMac, secondaryIp, action ); + + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + try { + when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenThrow(LibvirtException.class); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + } } \ No newline at end of file From 6748a73b82bb7d1d45fdde1cbcc02f78b8f7b330 Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Fri, 1 May 2015 16:17:09 +0200 Subject: [PATCH 022/175] Refactoring the LibvirtComputingResource - Adding 4 new command wrappers - 12 unit tests added - KVM hypervisor plugin with 15.5% coverage --- .../resource/LibvirtComputingResource.java | 108 +----- .../LibvirtCheckNetworkCommandWrapper.java | 57 +++ .../LibvirtCheckSshCommandWrapper.java | 56 +++ ...irtNetworkRulesSystemVmCommandWrapper.java | 49 +++ ...LibvirtOvsDestroyTunnelCommandWrapper.java | 58 +++ .../wrapper/LibvirtRequestWrapper.java | 8 + .../LibvirtComputingResourceTest.java | 337 +++++++++++++++++- 7 files changed, 573 insertions(+), 100 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckNetworkCommandWrapper.java create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckSshCommandWrapper.java create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkRulesSystemVmCommandWrapper.java create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsDestroyTunnelCommandWrapper.java diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 75c9663e35f3..9c1a6b425709 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -85,8 +85,6 @@ import com.cloud.agent.api.Answer; import com.cloud.agent.api.BackupSnapshotAnswer; import com.cloud.agent.api.BackupSnapshotCommand; -import com.cloud.agent.api.CheckNetworkAnswer; -import com.cloud.agent.api.CheckNetworkCommand; import com.cloud.agent.api.CheckOnHostCommand; import com.cloud.agent.api.Command; import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand; @@ -98,12 +96,10 @@ import com.cloud.agent.api.HostVmStateReportEntry; import com.cloud.agent.api.ManageSnapshotAnswer; import com.cloud.agent.api.ManageSnapshotCommand; -import com.cloud.agent.api.NetworkRulesSystemVmCommand; import com.cloud.agent.api.NetworkUsageAnswer; import com.cloud.agent.api.NetworkUsageCommand; import com.cloud.agent.api.OvsCreateTunnelAnswer; import com.cloud.agent.api.OvsCreateTunnelCommand; -import com.cloud.agent.api.OvsDestroyTunnelCommand; import com.cloud.agent.api.PingCommand; import com.cloud.agent.api.PingRoutingCommand; import com.cloud.agent.api.PingRoutingWithNwGroupsCommand; @@ -122,8 +118,6 @@ import com.cloud.agent.api.UnPlugNicCommand; import com.cloud.agent.api.VmDiskStatsEntry; import com.cloud.agent.api.VmStatsEntry; -import com.cloud.agent.api.check.CheckSshAnswer; -import com.cloud.agent.api.check.CheckSshCommand; import com.cloud.agent.api.routing.IpAssocCommand; import com.cloud.agent.api.routing.IpAssocVpcCommand; import com.cloud.agent.api.routing.NetworkElementCommand; @@ -178,7 +172,6 @@ import com.cloud.network.Networks.IsolationType; import com.cloud.network.Networks.RouterPrivateIpStrategy; import com.cloud.network.Networks.TrafficType; -import com.cloud.network.PhysicalNetworkSetupInfo; import com.cloud.resource.ServerResource; import com.cloud.resource.ServerResourceBase; import com.cloud.storage.JavaStorageLayer; @@ -1161,7 +1154,7 @@ private String matchPifFileInDirectory(final String bridgeName) { return ""; } - private boolean checkNetwork(final String networkName) { + public boolean checkNetwork(final String networkName) { if (networkName == null) { return true; } @@ -1306,18 +1299,12 @@ public Answer executeRequest(final Command cmd) { return execute((UnPlugNicCommand)cmd); } else if (cmd instanceof NetworkElementCommand) { return _virtRouterResource.executeRequest((NetworkElementCommand)cmd); - } else if (cmd instanceof CheckSshCommand) { - return execute((CheckSshCommand)cmd); } else if (cmd instanceof NetworkUsageCommand) { return execute((NetworkUsageCommand)cmd); - } else if (cmd instanceof NetworkRulesSystemVmCommand) { - return execute((NetworkRulesSystemVmCommand)cmd); } else if (cmd instanceof CopyVolumeCommand) { return execute((CopyVolumeCommand)cmd); } else if (cmd instanceof ResizeVolumeCommand) { return execute((ResizeVolumeCommand)cmd); - } else if (cmd instanceof CheckNetworkCommand) { - return execute((CheckNetworkCommand)cmd); } else if (cmd instanceof StorageSubSystemCommand) { return storageHandler.handleStorageCommands((StorageSubSystemCommand)cmd); } else if (cmd instanceof PvlanSetupCommand) { @@ -1326,8 +1313,6 @@ public Answer executeRequest(final Command cmd) { return execute((CheckOnHostCommand)cmd); } else if (cmd instanceof OvsCreateTunnelCommand) { return execute((OvsCreateTunnelCommand)cmd); - } else if (cmd instanceof OvsDestroyTunnelCommand) { - return execute((OvsDestroyTunnelCommand)cmd); } else { s_logger.warn("Unsupported command "); return Answer.createUnsupportedCommandAnswer(cmd); @@ -1367,6 +1352,7 @@ public synchronized boolean findOrCreateTunnelNetwork(final String nwName) { s_logger.debug("### KVM network for tunnels created:" + nwName); } catch (final Exception e) { s_logger.warn("createTunnelNetwork failed", e); + return false; } return true; } @@ -1374,7 +1360,11 @@ public synchronized boolean findOrCreateTunnelNetwork(final String nwName) { public synchronized boolean configureTunnelNetwork(final long networkId, final long hostId, final String nwName) { try { - findOrCreateTunnelNetwork(nwName); + final boolean findResult = findOrCreateTunnelNetwork(nwName); + if (!findResult) { + s_logger.warn("LibvirtComputingResource.findOrCreateTunnelNetwork() failed! Cannot proceed creating the tunnel."); + return false; + } final String configuredHosts = Script .runSimpleBashScript("ovs-vsctl get bridge " + nwName + " other_config:ovs-host-setup"); @@ -1441,53 +1431,6 @@ private OvsCreateTunnelAnswer execute(final OvsCreateTunnelCommand cmd) { } } - private Answer execute(final OvsDestroyTunnelCommand cmd) { - try { - if (!findOrCreateTunnelNetwork(cmd.getBridgeName())) { - s_logger.warn("Unable to find tunnel network for GRE key:" - + cmd.getBridgeName()); - return new Answer(cmd, false, "No network found"); - } - - final Script command = new Script(_ovsTunnelPath, _timeout, s_logger); - command.add("destroy_tunnel"); - command.add("--bridge", cmd.getBridgeName()); - command.add("--iface_name", cmd.getInPortName()); - final String result = command.execute(); - if (result == null) { - return new Answer(cmd, true, result); - } else { - return new Answer(cmd, false, result); - } - } catch (final Exception e) { - s_logger.warn("caught execption when destroy ovs tunnel", e); - return new Answer(cmd, false, e.getMessage()); - } - } - - private CheckNetworkAnswer execute(final CheckNetworkCommand cmd) { - final List phyNics = cmd.getPhysicalNetworkInfoList(); - String errMsg = null; - for (final PhysicalNetworkSetupInfo nic : phyNics) { - if (!checkNetwork(nic.getGuestNetworkName())) { - errMsg = "Can not find network: " + nic.getGuestNetworkName(); - break; - } else if (!checkNetwork(nic.getPrivateNetworkName())) { - errMsg = "Can not find network: " + nic.getPrivateNetworkName(); - break; - } else if (!checkNetwork(nic.getPublicNetworkName())) { - errMsg = "Can not find network: " + nic.getPublicNetworkName(); - break; - } - } - - if (errMsg != null) { - return new CheckNetworkAnswer(cmd, false, errMsg); - } else { - return new CheckNetworkAnswer(cmd, true, null); - } - } - private CopyVolumeAnswer execute(final CopyVolumeCommand cmd) { /** This method is only used for copying files from Primary Storage TO Secondary Storage @@ -2957,7 +2900,7 @@ protected StartAnswer execute(final StartCommand cmd) { for (final NicTO nic : nics) { if (nic.isSecurityGroupEnabled() || nic.getIsolationUri() != null && nic.getIsolationUri().getScheme().equalsIgnoreCase(IsolationType.Ec2.toString())) { if (vmSpec.getType() != VirtualMachine.Type.User) { - default_network_rules_for_systemvm(conn, vmName); + configureDefaultNetworkRulesForSystemVm(conn, vmName); break; } else { final List nicSecIps = nic.getNicSecIps(); @@ -3193,26 +3136,6 @@ private void createVif(final LibvirtVMDef vm, final NicTO nic, final String nicA vm.getDevices().addDevice(getVifDriver(nic.getType()).plug(nic, vm.getPlatformEmulator().toString(), nicAdapter).toString()); } - protected CheckSshAnswer execute(final CheckSshCommand cmd) { - final String vmName = cmd.getName(); - final String privateIp = cmd.getIp(); - final int cmdPort = cmd.getPort(); - - if (s_logger.isDebugEnabled()) { - s_logger.debug("Ping command port, " + privateIp + ":" + cmdPort); - } - - if (!_virtRouterResource.connect(privateIp, cmdPort)) { - return new CheckSshAnswer(cmd, "Can not ping System vm " + vmName + " because of a connection failure"); - } - - if (s_logger.isDebugEnabled()) { - s_logger.debug("Ping command port succeeded for vm " + vmName); - } - - return new CheckSshAnswer(cmd); - } - public boolean cleanupDisk(final DiskDef disk) { final String path = disk.getDiskPath(); @@ -4240,7 +4163,7 @@ protected boolean post_default_network_rules(final Connect conn, final String vm return true; } - protected boolean default_network_rules_for_systemvm(final Connect conn, final String vmName) { + public boolean configureDefaultNetworkRulesForSystemVm(final Connect conn, final String vmName) { if (!_canBridgeFirewall) { return false; } @@ -4371,19 +4294,6 @@ static double readDouble(final String nicName, final String fileName) { } } - private Answer execute(final NetworkRulesSystemVmCommand cmd) { - boolean success = false; - Connect conn; - try { - conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); - success = default_network_rules_for_systemvm(conn, cmd.getVmName()); - } catch (final LibvirtException e) { - s_logger.trace("Ignoring libvirt error.", e); - } - - return new Answer(cmd, success, ""); - } - private String prettyVersion(final long version) { final long major = version / 1000000; final long minor = version % 1000000 / 1000; diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckNetworkCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckNetworkCommandWrapper.java new file mode 100644 index 000000000000..4cf012d6cd6e --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckNetworkCommandWrapper.java @@ -0,0 +1,57 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import java.util.List; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.CheckNetworkAnswer; +import com.cloud.agent.api.CheckNetworkCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.network.PhysicalNetworkSetupInfo; +import com.cloud.resource.CommandWrapper; + +public final class LibvirtCheckNetworkCommandWrapper extends CommandWrapper { + + @Override + public Answer execute(final CheckNetworkCommand command, final LibvirtComputingResource libvirtComputingResource) { + final List phyNics = command.getPhysicalNetworkInfoList(); + String errMsg = null; + + for (final PhysicalNetworkSetupInfo nic : phyNics) { + if (!libvirtComputingResource.checkNetwork(nic.getGuestNetworkName())) { + errMsg = "Can not find network: " + nic.getGuestNetworkName(); + break; + } else if (!libvirtComputingResource.checkNetwork(nic.getPrivateNetworkName())) { + errMsg = "Can not find network: " + nic.getPrivateNetworkName(); + break; + } else if (!libvirtComputingResource.checkNetwork(nic.getPublicNetworkName())) { + errMsg = "Can not find network: " + nic.getPublicNetworkName(); + break; + } + } + + if (errMsg != null) { + return new CheckNetworkAnswer(command, false, errMsg); + } else { + return new CheckNetworkAnswer(command, true, null); + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckSshCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckSshCommandWrapper.java new file mode 100644 index 000000000000..d258d6d41d3a --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckSshCommandWrapper.java @@ -0,0 +1,56 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import org.apache.log4j.Logger; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.check.CheckSshAnswer; +import com.cloud.agent.api.check.CheckSshCommand; +import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; + +public final class LibvirtCheckSshCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtOvsVpcRoutingPolicyConfigCommandWrapper.class); + + @Override + public Answer execute(final CheckSshCommand command, final LibvirtComputingResource libvirtComputingResource) { + final String vmName = command.getName(); + final String privateIp = command.getIp(); + final int cmdPort = command.getPort(); + + if (s_logger.isDebugEnabled()) { + s_logger.debug("Ping command port, " + privateIp + ":" + cmdPort); + } + + final VirtualRoutingResource virtRouterResource = libvirtComputingResource.getVirtRouterResource(); + if (!virtRouterResource.connect(privateIp, cmdPort)) { + return new CheckSshAnswer(command, "Can not ping System vm " + vmName + " because of a connection failure"); + } + + if (s_logger.isDebugEnabled()) { + s_logger.debug("Ping command port succeeded for vm " + vmName); + } + + return new CheckSshAnswer(command); + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkRulesSystemVmCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkRulesSystemVmCommandWrapper.java new file mode 100644 index 000000000000..b8ef8a8ac2f1 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkRulesSystemVmCommandWrapper.java @@ -0,0 +1,49 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import org.apache.log4j.Logger; +import org.libvirt.Connect; +import org.libvirt.LibvirtException; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.NetworkRulesSystemVmCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; + +public final class LibvirtNetworkRulesSystemVmCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtOvsVpcRoutingPolicyConfigCommandWrapper.class); + + @Override + public Answer execute(final NetworkRulesSystemVmCommand command, final LibvirtComputingResource libvirtComputingResource) { + boolean success = false; + try { + final LibvirtConnectionWrapper libvirtConnectionWrapper = libvirtComputingResource.getLibvirtConnectionWrapper(); + + final Connect conn = libvirtConnectionWrapper.getConnectionByVmName(command.getVmName()); + success = libvirtComputingResource.configureDefaultNetworkRulesForSystemVm(conn, command.getVmName()); + } catch (final LibvirtException e) { + s_logger.trace("Ignoring libvirt error.", e); + } + + return new Answer(command, success, ""); + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsDestroyTunnelCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsDestroyTunnelCommandWrapper.java new file mode 100644 index 000000000000..ca694f817974 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsDestroyTunnelCommandWrapper.java @@ -0,0 +1,58 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import org.apache.log4j.Logger; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.OvsDestroyTunnelCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; +import com.cloud.utils.script.Script; + +public final class LibvirtOvsDestroyTunnelCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtOvsDestroyTunnelCommandWrapper.class); + + @Override + public Answer execute(final OvsDestroyTunnelCommand command, final LibvirtComputingResource libvirtComputingResource) { + try { + if (!libvirtComputingResource.findOrCreateTunnelNetwork(command.getBridgeName())) { + s_logger.warn("Unable to find tunnel network for GRE key:" + + command.getBridgeName()); + return new Answer(command, false, "No network found"); + } + + final Script scriptCommand = new Script(libvirtComputingResource.getOvsTunnelPath(), libvirtComputingResource.getTimeout(), s_logger); + scriptCommand.add("destroy_tunnel"); + scriptCommand.add("--bridge", command.getBridgeName()); + scriptCommand.add("--iface_name", command.getInPortName()); + final String result = scriptCommand.execute(); + if (result == null) { + return new Answer(command, true, result); + } else { + return new Answer(command, false, result); + } + } catch (final Exception e) { + s_logger.warn("caught execption when destroy ovs tunnel", e); + return new Answer(command, false, e.getMessage()); + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java index 87b4ec24d354..ca7a7d2638cd 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java @@ -24,6 +24,7 @@ import com.cloud.agent.api.AttachIsoCommand; import com.cloud.agent.api.AttachVolumeCommand; import com.cloud.agent.api.CheckHealthCommand; +import com.cloud.agent.api.CheckNetworkCommand; import com.cloud.agent.api.CheckVirtualMachineCommand; import com.cloud.agent.api.CleanupNetworkRulesCmd; import com.cloud.agent.api.Command; @@ -38,8 +39,10 @@ import com.cloud.agent.api.MigrateCommand; import com.cloud.agent.api.ModifySshKeysCommand; import com.cloud.agent.api.ModifyStoragePoolCommand; +import com.cloud.agent.api.NetworkRulesSystemVmCommand; import com.cloud.agent.api.NetworkRulesVmSecondaryIpCommand; import com.cloud.agent.api.OvsDestroyBridgeCommand; +import com.cloud.agent.api.OvsDestroyTunnelCommand; import com.cloud.agent.api.OvsFetchInterfaceCommand; import com.cloud.agent.api.OvsSetupBridgeCommand; import com.cloud.agent.api.OvsVpcPhysicalTopologyConfigCommand; @@ -51,6 +54,7 @@ import com.cloud.agent.api.RebootRouterCommand; import com.cloud.agent.api.StopCommand; import com.cloud.agent.api.UpgradeSnapshotCommand; +import com.cloud.agent.api.check.CheckSshCommand; import com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand; import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand; import com.cloud.agent.api.storage.CreateCommand; @@ -112,6 +116,10 @@ private void init() { linbvirtCommands.put(ModifyStoragePoolCommand.class, new LibvirtModifyStoragePoolCommandWrapper()); linbvirtCommands.put(CleanupNetworkRulesCmd.class, new LibvirtCleanupNetworkRulesCommandWrapper()); linbvirtCommands.put(NetworkRulesVmSecondaryIpCommand.class, new LibvirtNetworkRulesVmSecondaryIpCommandWrapper()); + linbvirtCommands.put(NetworkRulesSystemVmCommand.class, new LibvirtNetworkRulesSystemVmCommandWrapper()); + linbvirtCommands.put(CheckSshCommand.class, new LibvirtCheckSshCommandWrapper()); + linbvirtCommands.put(CheckNetworkCommand.class, new LibvirtCheckNetworkCommandWrapper()); + linbvirtCommands.put(OvsDestroyTunnelCommand.class, new LibvirtOvsDestroyTunnelCommandWrapper()); resources.put(LibvirtComputingResource.class, linbvirtCommands); } diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index 8fd1ecfd66e7..1551f98e4d53 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -67,6 +67,7 @@ import com.cloud.agent.api.AttachIsoCommand; import com.cloud.agent.api.AttachVolumeCommand; import com.cloud.agent.api.CheckHealthCommand; +import com.cloud.agent.api.CheckNetworkCommand; import com.cloud.agent.api.CheckVirtualMachineCommand; import com.cloud.agent.api.CleanupNetworkRulesCmd; import com.cloud.agent.api.CreateStoragePoolCommand; @@ -80,8 +81,10 @@ import com.cloud.agent.api.MigrateCommand; import com.cloud.agent.api.ModifySshKeysCommand; import com.cloud.agent.api.ModifyStoragePoolCommand; +import com.cloud.agent.api.NetworkRulesSystemVmCommand; import com.cloud.agent.api.NetworkRulesVmSecondaryIpCommand; import com.cloud.agent.api.OvsDestroyBridgeCommand; +import com.cloud.agent.api.OvsDestroyTunnelCommand; import com.cloud.agent.api.OvsFetchInterfaceCommand; import com.cloud.agent.api.OvsSetupBridgeCommand; import com.cloud.agent.api.OvsVpcPhysicalTopologyConfigCommand; @@ -98,6 +101,7 @@ import com.cloud.agent.api.StopCommand; import com.cloud.agent.api.UpgradeSnapshotCommand; import com.cloud.agent.api.VmStatsEntry; +import com.cloud.agent.api.check.CheckSshCommand; import com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand; import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand; import com.cloud.agent.api.storage.CreateCommand; @@ -119,6 +123,7 @@ import com.cloud.hypervisor.kvm.storage.KVMStoragePool; import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; import com.cloud.network.Networks.TrafficType; +import com.cloud.network.PhysicalNetworkSetupInfo; import com.cloud.storage.Storage.ImageFormat; import com.cloud.storage.Storage.StoragePoolType; import com.cloud.storage.StoragePool; @@ -129,6 +134,7 @@ import com.cloud.vm.DiskProfile; import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachine.PowerState; +import com.cloud.vm.VirtualMachine.Type; @RunWith(PowerMockRunner.class) public class LibvirtComputingResourceTest { @@ -1944,7 +1950,7 @@ public void testOvsSetupBridgeCommand() { } @Test - public void testOvsSetupBridgeCommandFailure() { + public void testOvsSetupBridgeCommandFailure1() { final String name = "Test"; final Long hostId = 1l; final Long networkId = 1l; @@ -1967,6 +1973,30 @@ public void testOvsSetupBridgeCommandFailure() { command.getBridgeName()); } + @Test + public void testOvsSetupBridgeCommandFailure2() { + final String name = "Test"; + final Long hostId = 1l; + final Long networkId = 1l; + + final OvsSetupBridgeCommand command = new OvsSetupBridgeCommand(name, hostId, networkId); + + when(libvirtComputingResource.findOrCreateTunnelNetwork(command.getBridgeName())).thenReturn(false); + when(libvirtComputingResource.configureTunnelNetwork(command.getNetworkId(), command.getHostId(), + command.getBridgeName())).thenReturn(true); + + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).findOrCreateTunnelNetwork(command.getBridgeName()); + verify(libvirtComputingResource, times(1)).configureTunnelNetwork(command.getNetworkId(), command.getHostId(), + command.getBridgeName()); + } + @Test public void testOvsDestroyBridgeCommand() { final String name = "Test"; @@ -2043,6 +2073,27 @@ public void testOvsVpcPhysicalTopologyConfigCommand() { verify(libvirtComputingResource, times(1)).getTimeout(); } + @SuppressWarnings("unchecked") + @Test + public void testOvsVpcPhysicalTopologyConfigCommandFailure() { + final Host[] hosts = null; + final Tier[] tiers = null; + final Vm[] vms = null; + final String cidr = null; + + final OvsVpcPhysicalTopologyConfigCommand command = new OvsVpcPhysicalTopologyConfigCommand(hosts, tiers, vms, cidr); + + when(libvirtComputingResource.getOvsTunnelPath()).thenThrow(Exception.class); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getOvsTunnelPath(); + } + @Test public void testOvsVpcRoutingPolicyConfigCommand() { final String id = null; @@ -2066,6 +2117,27 @@ public void testOvsVpcRoutingPolicyConfigCommand() { verify(libvirtComputingResource, times(1)).getTimeout(); } + @SuppressWarnings("unchecked") + @Test + public void testOvsVpcRoutingPolicyConfigCommandFailure() { + final String id = null; + final String cidr = null; + final Acl[] acls = null; + final com.cloud.agent.api.OvsVpcRoutingPolicyConfigCommand.Tier[] tiers = null; + + final OvsVpcRoutingPolicyConfigCommand command = new OvsVpcRoutingPolicyConfigCommand(id, cidr, acls, tiers); + + when(libvirtComputingResource.getOvsTunnelPath()).thenThrow(Exception.class); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getOvsTunnelPath(); + } + @Test public void testCreateStoragePoolCommand() { final StoragePool pool = Mockito.mock(StoragePool.class); @@ -2207,4 +2279,267 @@ public void testNetworkRulesVmSecondaryIpCommandFailure() { } verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); } + + @Test + public void testNetworkRulesSystemVmCommand() { + final String vmName = "Test"; + final Type type = Type.SecondaryStorageVm; + + final NetworkRulesSystemVmCommand command = new NetworkRulesSystemVmCommand(vmName, type); + + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final Connect conn = Mockito.mock(Connect.class); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + try { + when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenReturn(conn); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + when(libvirtComputingResource.configureDefaultNetworkRulesForSystemVm(conn, command.getVmName())).thenReturn(true); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + verify(libvirtComputingResource, times(1)).configureDefaultNetworkRulesForSystemVm(conn, command.getVmName()); + } + + @SuppressWarnings("unchecked") + @Test + public void testNetworkRulesSystemVmCommandFailure() { + final String vmName = "Test"; + final Type type = Type.SecondaryStorageVm; + + final NetworkRulesSystemVmCommand command = new NetworkRulesSystemVmCommand(vmName, type); + + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + try { + when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenThrow(LibvirtException.class); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + } + + @Test + public void testCheckSshCommand() { + final String instanceName = "Test"; + final String ip = "172.16.16.16"; + final int port = 22; + + final CheckSshCommand command = new CheckSshCommand(instanceName, ip, port); + + final VirtualRoutingResource virtRouterResource = Mockito.mock(VirtualRoutingResource.class); + + final String privateIp = command.getIp(); + final int cmdPort = command.getPort(); + + when(libvirtComputingResource.getVirtRouterResource()).thenReturn(virtRouterResource); + when(virtRouterResource.connect(privateIp, cmdPort)).thenReturn(true); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getVirtRouterResource(); + verify(virtRouterResource, times(1)).connect(privateIp, cmdPort); + } + + @Test + public void testCheckSshCommandFailure() { + final String instanceName = "Test"; + final String ip = "172.16.16.16"; + final int port = 22; + + final CheckSshCommand command = new CheckSshCommand(instanceName, ip, port); + + final VirtualRoutingResource virtRouterResource = Mockito.mock(VirtualRoutingResource.class); + + final String privateIp = command.getIp(); + final int cmdPort = command.getPort(); + + when(libvirtComputingResource.getVirtRouterResource()).thenReturn(virtRouterResource); + when(virtRouterResource.connect(privateIp, cmdPort)).thenReturn(false); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getVirtRouterResource(); + verify(virtRouterResource, times(1)).connect(privateIp, cmdPort); + } + + @Test + public void testCheckNetworkCommand() { + final List networkInfoList = new ArrayList(); + + final PhysicalNetworkSetupInfo nic = Mockito.mock(PhysicalNetworkSetupInfo.class); + networkInfoList.add(nic); + + final CheckNetworkCommand command = new CheckNetworkCommand(networkInfoList); + + when(libvirtComputingResource.checkNetwork(nic.getGuestNetworkName())).thenReturn(true); + when(libvirtComputingResource.checkNetwork(nic.getPrivateNetworkName())).thenReturn(true); + when(libvirtComputingResource.checkNetwork(nic.getPublicNetworkName())).thenReturn(true); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(3)).checkNetwork(nic.getGuestNetworkName()); + verify(libvirtComputingResource, times(3)).checkNetwork(nic.getPrivateNetworkName()); + verify(libvirtComputingResource, times(3)).checkNetwork(nic.getPublicNetworkName()); + } + + @Test + public void testCheckNetworkCommandFail1() { + final List networkInfoList = new ArrayList(); + + final PhysicalNetworkSetupInfo networkSetupInfo = Mockito.mock(PhysicalNetworkSetupInfo.class); + networkInfoList.add(networkSetupInfo); + + final CheckNetworkCommand command = new CheckNetworkCommand(networkInfoList); + + when(libvirtComputingResource.checkNetwork(networkSetupInfo.getGuestNetworkName())).thenReturn(false); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).checkNetwork(networkSetupInfo.getGuestNetworkName()); + } + + @Test + public void testCheckNetworkCommandFail2() { + final List networkInfoList = new ArrayList(); + + final PhysicalNetworkSetupInfo networkSetupInfo = Mockito.mock(PhysicalNetworkSetupInfo.class); + networkInfoList.add(networkSetupInfo); + + final CheckNetworkCommand command = new CheckNetworkCommand(networkInfoList); + + when(libvirtComputingResource.checkNetwork(networkSetupInfo.getGuestNetworkName())).thenReturn(true); + when(libvirtComputingResource.checkNetwork(networkSetupInfo.getPrivateNetworkName())).thenReturn(false); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).checkNetwork(networkSetupInfo.getGuestNetworkName()); + verify(libvirtComputingResource, times(1)).checkNetwork(networkSetupInfo.getPrivateNetworkName()); + } + + @Test + public void testCheckNetworkCommandFail3() { + final List networkInfoList = new ArrayList(); + + final PhysicalNetworkSetupInfo networkSetupInfo = Mockito.mock(PhysicalNetworkSetupInfo.class); + networkInfoList.add(networkSetupInfo); + + final CheckNetworkCommand command = new CheckNetworkCommand(networkInfoList); + + when(libvirtComputingResource.checkNetwork(networkSetupInfo.getGuestNetworkName())).thenReturn(true); + when(libvirtComputingResource.checkNetwork(networkSetupInfo.getPrivateNetworkName())).thenReturn(true); + when(libvirtComputingResource.checkNetwork(networkSetupInfo.getPublicNetworkName())).thenReturn(false); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).checkNetwork(networkSetupInfo.getGuestNetworkName()); + verify(libvirtComputingResource, times(1)).checkNetwork(networkSetupInfo.getPrivateNetworkName()); + } + + @Test + public void testOvsDestroyTunnelCommand() { + final String networkName = "Test"; + final Long networkId = 1l; + final String inPortName = "eth"; + + final OvsDestroyTunnelCommand command = new OvsDestroyTunnelCommand(networkId, networkName, inPortName); + + when(libvirtComputingResource.findOrCreateTunnelNetwork(command.getBridgeName())).thenReturn(true); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).findOrCreateTunnelNetwork(command.getBridgeName()); + } + + @Test + public void testOvsDestroyTunnelCommandFailure1() { + final String networkName = "Test"; + final Long networkId = 1l; + final String inPortName = "eth"; + + final OvsDestroyTunnelCommand command = new OvsDestroyTunnelCommand(networkId, networkName, inPortName); + + when(libvirtComputingResource.findOrCreateTunnelNetwork(command.getBridgeName())).thenReturn(false); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).findOrCreateTunnelNetwork(command.getBridgeName()); + } + + @SuppressWarnings("unchecked") + @Test + public void testOvsDestroyTunnelCommandFailure2() { + final String networkName = "Test"; + final Long networkId = 1l; + final String inPortName = "eth"; + + final OvsDestroyTunnelCommand command = new OvsDestroyTunnelCommand(networkId, networkName, inPortName); + + when(libvirtComputingResource.findOrCreateTunnelNetwork(command.getBridgeName())).thenThrow(Exception.class); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).findOrCreateTunnelNetwork(command.getBridgeName()); + } } \ No newline at end of file From 3c8b217262e08053fd59329f7466b65b150a18c2 Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Fri, 1 May 2015 19:17:30 +0200 Subject: [PATCH 023/175] Refactoring the LibvirtComputingResource - Adding LibvirtCheckOnHostCommandWrapper and LibvirtOvsCreateTunnelCommandWrapper - 4 unit tests added - KVM hypervisor plugin with 16.2% coverage --- .../resource/LibvirtComputingResource.java | 89 +------------- .../LibvirtCheckOnHostCommandWrapper.java | 64 ++++++++++ .../LibvirtOvsCreateTunnelCommandWrapper.java | 68 +++++++++++ .../wrapper/LibvirtRequestWrapper.java | 4 + .../LibvirtComputingResourceTest.java | 112 ++++++++++++++++++ 5 files changed, 252 insertions(+), 85 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckOnHostCommandWrapper.java create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsCreateTunnelCommandWrapper.java diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 9c1a6b425709..6d13ce61c72b 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -85,7 +85,6 @@ import com.cloud.agent.api.Answer; import com.cloud.agent.api.BackupSnapshotAnswer; import com.cloud.agent.api.BackupSnapshotCommand; -import com.cloud.agent.api.CheckOnHostCommand; import com.cloud.agent.api.Command; import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand; import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand; @@ -98,8 +97,6 @@ import com.cloud.agent.api.ManageSnapshotCommand; import com.cloud.agent.api.NetworkUsageAnswer; import com.cloud.agent.api.NetworkUsageCommand; -import com.cloud.agent.api.OvsCreateTunnelAnswer; -import com.cloud.agent.api.OvsCreateTunnelCommand; import com.cloud.agent.api.PingCommand; import com.cloud.agent.api.PingRoutingCommand; import com.cloud.agent.api.PingRoutingWithNwGroupsCommand; @@ -430,6 +427,10 @@ public String getOvsTunnelPath() { return _ovsTunnelPath; } + public KVMHAMonitor getMonitor() { + return _monitor; + } + private static final class KeyValueInterpreter extends OutputInterpreter { private final Map map = new HashMap(); @@ -1309,10 +1310,6 @@ public Answer executeRequest(final Command cmd) { return storageHandler.handleStorageCommands((StorageSubSystemCommand)cmd); } else if (cmd instanceof PvlanSetupCommand) { return execute((PvlanSetupCommand)cmd); - } else if (cmd instanceof CheckOnHostCommand) { - return execute((CheckOnHostCommand)cmd); - } else if (cmd instanceof OvsCreateTunnelCommand) { - return execute((OvsCreateTunnelCommand)cmd); } else { s_logger.warn("Unsupported command "); return Answer.createUnsupportedCommandAnswer(cmd); @@ -1398,39 +1395,6 @@ public synchronized boolean configureTunnelNetwork(final long networkId, return true; } - private OvsCreateTunnelAnswer execute(final OvsCreateTunnelCommand cmd) { - final String bridge = cmd.getNetworkName(); - try { - if (!findOrCreateTunnelNetwork(bridge)) { - s_logger.debug("Error during bridge setup"); - return new OvsCreateTunnelAnswer(cmd, false, - "Cannot create network", bridge); - } - - configureTunnelNetwork(cmd.getNetworkId(), cmd.getFrom(), - cmd.getNetworkName()); - final Script command = new Script(_ovsTunnelPath, _timeout, s_logger); - command.add("create_tunnel"); - command.add("--bridge", bridge); - command.add("--remote_ip", cmd.getRemoteIp()); - command.add("--key", cmd.getKey().toString()); - command.add("--src_host", cmd.getFrom().toString()); - command.add("--dst_host", cmd.getTo().toString()); - - final String result = command.execute(); - if (result != null) { - return new OvsCreateTunnelAnswer(cmd, true, result, null, - bridge); - } else { - return new OvsCreateTunnelAnswer(cmd, false, result, bridge); - } - } catch (final Exception e) { - s_logger.debug("Error during tunnel setup"); - s_logger.warn("Caught execption when creating ovs tunnel", e); - return new OvsCreateTunnelAnswer(cmd, false, e.getMessage(), bridge); - } - } - private CopyVolumeAnswer execute(final CopyVolumeCommand cmd) { /** This method is only used for copying files from Primary Storage TO Secondary Storage @@ -1508,26 +1472,6 @@ protected FenceAnswer execute(final FenceCommand cmd) { } - protected Answer execute(final CheckOnHostCommand cmd) { - final ExecutorService executors = Executors.newSingleThreadExecutor(); - final List pools = _monitor.getStoragePools(); - final KVMHAChecker ha = new KVMHAChecker(pools, cmd.getHost().getPrivateNetwork().getIp()); - final Future future = executors.submit(ha); - try { - final Boolean result = future.get(); - if (result) { - return new Answer(cmd, false, "Heart is still beating..."); - } else { - return new Answer(cmd); - } - } catch (final InterruptedException e) { - return new Answer(cmd, false, "can't get status of host:"); - } catch (final ExecutionException e) { - return new Answer(cmd, false, "can't get status of host:"); - } - - } - protected Storage.StorageResourceType getStorageResourceType() { return Storage.StorageResourceType.STORAGE_POOL; } @@ -3795,28 +3739,6 @@ private String getHypervisorPath(final Connect conn) { return parser.getEmulator(); } - private String getGuestType(final Connect conn, final String vmName) { - final LibvirtDomainXMLParser parser = new LibvirtDomainXMLParser(); - Domain dm = null; - try { - dm = conn.domainLookupByName(vmName); - final String xmlDesc = dm.getXMLDesc(0); - parser.parseDomainXML(xmlDesc); - return parser.getDescription(); - } catch (final LibvirtException e) { - s_logger.trace("Ignoring libvirt error.", e); - return null; - } finally { - try { - if (dm != null) { - dm.free(); - } - } catch (final LibvirtException l) { - s_logger.trace("Ignoring libvirt error.", l); - } - } - } - boolean isGuestPVEnabled(final String guestOSName) { if (guestOSName == null) { return false; @@ -4304,13 +4226,11 @@ private String prettyVersion(final long version) { @Override public void setName(final String name) { // TODO Auto-generated method stub - } @Override public void setConfigParams(final Map params) { // TODO Auto-generated method stub - } @Override @@ -4328,7 +4248,6 @@ public int getRunLevel() { @Override public void setRunLevel(final int level) { // TODO Auto-generated method stub - } public HypervisorType getHypervisorType(){ diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckOnHostCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckOnHostCommandWrapper.java new file mode 100644 index 000000000000..5e5602351a3b --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckOnHostCommandWrapper.java @@ -0,0 +1,64 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.CheckOnHostCommand; +import com.cloud.agent.api.to.HostTO; +import com.cloud.agent.api.to.NetworkTO; +import com.cloud.hypervisor.kvm.resource.KVMHABase.NfsStoragePool; +import com.cloud.hypervisor.kvm.resource.KVMHAChecker; +import com.cloud.hypervisor.kvm.resource.KVMHAMonitor; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; + +public final class LibvirtCheckOnHostCommandWrapper extends CommandWrapper { + + @Override + public Answer execute(final CheckOnHostCommand command, final LibvirtComputingResource libvirtComputingResource) { + final ExecutorService executors = Executors.newSingleThreadExecutor(); + final KVMHAMonitor monitor = libvirtComputingResource.getMonitor(); + + final List pools = monitor.getStoragePools(); + HostTO host = command.getHost(); + NetworkTO privateNetwork = host.getPrivateNetwork(); + final KVMHAChecker ha = new KVMHAChecker(pools, privateNetwork.getIp()); + + final Future future = executors.submit(ha); + try { + final Boolean result = future.get(); + if (result) { + return new Answer(command, false, "Heart is still beating..."); + } else { + return new Answer(command); + } + } catch (final InterruptedException e) { + return new Answer(command, false, "can't get status of host:"); + } catch (final ExecutionException e) { + return new Answer(command, false, "can't get status of host:"); + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsCreateTunnelCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsCreateTunnelCommandWrapper.java new file mode 100644 index 000000000000..3a620577d12c --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsCreateTunnelCommandWrapper.java @@ -0,0 +1,68 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import org.apache.log4j.Logger; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.OvsCreateTunnelAnswer; +import com.cloud.agent.api.OvsCreateTunnelCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; +import com.cloud.utils.script.Script; + +public final class LibvirtOvsCreateTunnelCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtOvsCreateTunnelCommandWrapper.class); + + @Override + public Answer execute(final OvsCreateTunnelCommand command, final LibvirtComputingResource libvirtComputingResource) { + final String bridge = command.getNetworkName(); + try { + if (!libvirtComputingResource.findOrCreateTunnelNetwork(bridge)) { + s_logger.debug("Error during bridge setup"); + return new OvsCreateTunnelAnswer(command, false, + "Cannot create network", bridge); + } + + libvirtComputingResource.configureTunnelNetwork(command.getNetworkId(), command.getFrom(), + command.getNetworkName()); + + final Script scriptCommand = new Script(libvirtComputingResource.getOvsTunnelPath(), libvirtComputingResource.getTimeout(), s_logger); + scriptCommand.add("create_tunnel"); + scriptCommand.add("--bridge", bridge); + scriptCommand.add("--remote_ip", command.getRemoteIp()); + scriptCommand.add("--key", command.getKey().toString()); + scriptCommand.add("--src_host", command.getFrom().toString()); + scriptCommand.add("--dst_host", command.getTo().toString()); + + final String result = scriptCommand.execute(); + if (result != null) { + return new OvsCreateTunnelAnswer(command, true, result, null, + bridge); + } else { + return new OvsCreateTunnelAnswer(command, false, result, bridge); + } + } catch (final Exception e) { + s_logger.warn("Caught execption when creating ovs tunnel", e); + return new OvsCreateTunnelAnswer(command, false, e.getMessage(), bridge); + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java index ca7a7d2638cd..af2f544e0944 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java @@ -25,6 +25,7 @@ import com.cloud.agent.api.AttachVolumeCommand; import com.cloud.agent.api.CheckHealthCommand; import com.cloud.agent.api.CheckNetworkCommand; +import com.cloud.agent.api.CheckOnHostCommand; import com.cloud.agent.api.CheckVirtualMachineCommand; import com.cloud.agent.api.CleanupNetworkRulesCmd; import com.cloud.agent.api.Command; @@ -41,6 +42,7 @@ import com.cloud.agent.api.ModifyStoragePoolCommand; import com.cloud.agent.api.NetworkRulesSystemVmCommand; import com.cloud.agent.api.NetworkRulesVmSecondaryIpCommand; +import com.cloud.agent.api.OvsCreateTunnelCommand; import com.cloud.agent.api.OvsDestroyBridgeCommand; import com.cloud.agent.api.OvsDestroyTunnelCommand; import com.cloud.agent.api.OvsFetchInterfaceCommand; @@ -120,6 +122,8 @@ private void init() { linbvirtCommands.put(CheckSshCommand.class, new LibvirtCheckSshCommandWrapper()); linbvirtCommands.put(CheckNetworkCommand.class, new LibvirtCheckNetworkCommandWrapper()); linbvirtCommands.put(OvsDestroyTunnelCommand.class, new LibvirtOvsDestroyTunnelCommandWrapper()); + linbvirtCommands.put(CheckOnHostCommand.class, new LibvirtCheckOnHostCommandWrapper()); + linbvirtCommands.put(OvsCreateTunnelCommand.class, new LibvirtOvsCreateTunnelCommandWrapper()); resources.put(LibvirtComputingResource.class, linbvirtCommands); } diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index 1551f98e4d53..f01ad7a76dc5 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -68,6 +68,7 @@ import com.cloud.agent.api.AttachVolumeCommand; import com.cloud.agent.api.CheckHealthCommand; import com.cloud.agent.api.CheckNetworkCommand; +import com.cloud.agent.api.CheckOnHostCommand; import com.cloud.agent.api.CheckVirtualMachineCommand; import com.cloud.agent.api.CleanupNetworkRulesCmd; import com.cloud.agent.api.CreateStoragePoolCommand; @@ -83,6 +84,7 @@ import com.cloud.agent.api.ModifyStoragePoolCommand; import com.cloud.agent.api.NetworkRulesSystemVmCommand; import com.cloud.agent.api.NetworkRulesVmSecondaryIpCommand; +import com.cloud.agent.api.OvsCreateTunnelCommand; import com.cloud.agent.api.OvsDestroyBridgeCommand; import com.cloud.agent.api.OvsDestroyTunnelCommand; import com.cloud.agent.api.OvsFetchInterfaceCommand; @@ -2542,4 +2544,114 @@ public void testOvsDestroyTunnelCommandFailure2() { verify(libvirtComputingResource, times(1)).findOrCreateTunnelNetwork(command.getBridgeName()); } + + @Test + public void testCheckOnHostCommand() { + final com.cloud.host.Host host = Mockito.mock(com.cloud.host.Host.class);; + + final CheckOnHostCommand command = new CheckOnHostCommand(host); + + final KVMHAMonitor monitor = Mockito.mock(KVMHAMonitor.class); + + when(libvirtComputingResource.getMonitor()).thenReturn(monitor); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getMonitor(); + } + + @Test + public void testOvsCreateTunnelCommand() { + final String remoteIp = "172.16.16.16"; + final Integer key = 1; + final Long from = 1l; + final Long to = 2l; + final long networkId = 1l; + final String fromIp = "172.15.15.15"; + final String networkName = "eth"; + final String networkUuid = "8edb1156-a851-4914-afc6-468ee52ac861"; + + final OvsCreateTunnelCommand command = new OvsCreateTunnelCommand(remoteIp, key, from, to, networkId, fromIp, networkName, networkUuid); + + final String bridge = command.getNetworkName(); + + when(libvirtComputingResource.findOrCreateTunnelNetwork(bridge)).thenReturn(true); + when(libvirtComputingResource.configureTunnelNetwork(command.getNetworkId(), command.getFrom(), + command.getNetworkName())).thenReturn(true); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).findOrCreateTunnelNetwork(bridge); + verify(libvirtComputingResource, times(1)).configureTunnelNetwork(command.getNetworkId(), command.getFrom(), + command.getNetworkName()); + } + + @Test + public void testOvsCreateTunnelCommandFailure1() { + final String remoteIp = "172.16.16.16"; + final Integer key = 1; + final Long from = 1l; + final Long to = 2l; + final long networkId = 1l; + final String fromIp = "172.15.15.15"; + final String networkName = "eth"; + final String networkUuid = "8edb1156-a851-4914-afc6-468ee52ac861"; + + final OvsCreateTunnelCommand command = new OvsCreateTunnelCommand(remoteIp, key, from, to, networkId, fromIp, networkName, networkUuid); + + final String bridge = command.getNetworkName(); + + when(libvirtComputingResource.findOrCreateTunnelNetwork(bridge)).thenReturn(false); + when(libvirtComputingResource.configureTunnelNetwork(command.getNetworkId(), command.getFrom(), + command.getNetworkName())).thenReturn(true); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).findOrCreateTunnelNetwork(bridge); + verify(libvirtComputingResource, times(0)).configureTunnelNetwork(command.getNetworkId(), command.getFrom(), + command.getNetworkName()); + } + + @SuppressWarnings("unchecked") + @Test + public void testOvsCreateTunnelCommandFailure2() { + final String remoteIp = "172.16.16.16"; + final Integer key = 1; + final Long from = 1l; + final Long to = 2l; + final long networkId = 1l; + final String fromIp = "172.15.15.15"; + final String networkName = "eth"; + final String networkUuid = "8edb1156-a851-4914-afc6-468ee52ac861"; + + final OvsCreateTunnelCommand command = new OvsCreateTunnelCommand(remoteIp, key, from, to, networkId, fromIp, networkName, networkUuid); + + final String bridge = command.getNetworkName(); + + when(libvirtComputingResource.findOrCreateTunnelNetwork(bridge)).thenReturn(true); + when(libvirtComputingResource.configureTunnelNetwork(command.getNetworkId(), command.getFrom(), + command.getNetworkName())).thenThrow(Exception.class); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).findOrCreateTunnelNetwork(bridge); + verify(libvirtComputingResource, times(1)).configureTunnelNetwork(command.getNetworkId(), command.getFrom(), + command.getNetworkName()); + } } \ No newline at end of file From ff7ae9ca0c9714dca684f3972eacae56254b76fd Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Sat, 2 May 2015 09:37:59 +0200 Subject: [PATCH 024/175] Refactoring the LibvirtComputingResource - Adding LibvirtCreateVolumeFromSnapshotCommandWrapper, LibvirtFenceCommandWrapper and LibvirtSecurityGroupRulesCommandWrapper - 6 unit tests added - KVM hypervisor plugin with 17.2% coverage --- .../com/cloud/agent/api/SnapshotCommand.java | 8 +- .../resource/LibvirtComputingResource.java | 86 +---- ...reateVolumeFromSnapshotCommandWrapper.java | 68 ++++ .../wrapper/LibvirtFenceCommandWrapper.java | 67 ++++ .../wrapper/LibvirtRequestWrapper.java | 6 + ...bvirtSecurityGroupRulesCommandWrapper.java | 67 ++++ .../LibvirtComputingResourceTest.java | 296 +++++++++++++++++- 7 files changed, 498 insertions(+), 100 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreateVolumeFromSnapshotCommandWrapper.java create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtFenceCommandWrapper.java create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtSecurityGroupRulesCommandWrapper.java diff --git a/core/src/com/cloud/agent/api/SnapshotCommand.java b/core/src/com/cloud/agent/api/SnapshotCommand.java index a4975e68fe73..cf4eeb5da58c 100644 --- a/core/src/com/cloud/agent/api/SnapshotCommand.java +++ b/core/src/com/cloud/agent/api/SnapshotCommand.java @@ -53,9 +53,9 @@ protected SnapshotCommand() { * is the value of that field If you have better ideas on how to * get it, you are welcome. */ - public SnapshotCommand(StoragePool pool, String secondaryStorageUrl, String snapshotUuid, String snapshotName, Long dcId, Long accountId, Long volumeId) { - // this.primaryStoragePoolNameLabel = pool.getUuid(); - //this.primaryPool = new StorageFilerTO(pool); + public SnapshotCommand(final StoragePool pool, final String secondaryStorageUrl, final String snapshotUuid, final String snapshotName, final Long dcId, final Long accountId, final Long volumeId) { + primaryStoragePoolNameLabel = pool.getUuid(); + primaryPool = new StorageFilerTO(pool); this.snapshotUuid = snapshotUuid; this.secondaryStorageUrl = secondaryStorageUrl; this.dcId = dcId; @@ -112,7 +112,7 @@ public String getVolumePath() { return volumePath; } - public void setVolumePath(String path) { + public void setVolumePath(final String path) { volumePath = path; } diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 6d13ce61c72b..6f24b31b716e 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -44,10 +44,6 @@ import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -88,10 +84,6 @@ import com.cloud.agent.api.Command; import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand; import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand; -import com.cloud.agent.api.CreateVolumeFromSnapshotAnswer; -import com.cloud.agent.api.CreateVolumeFromSnapshotCommand; -import com.cloud.agent.api.FenceAnswer; -import com.cloud.agent.api.FenceCommand; import com.cloud.agent.api.HostVmStateReportEntry; import com.cloud.agent.api.ManageSnapshotAnswer; import com.cloud.agent.api.ManageSnapshotCommand; @@ -103,8 +95,6 @@ import com.cloud.agent.api.PlugNicAnswer; import com.cloud.agent.api.PlugNicCommand; import com.cloud.agent.api.PvlanSetupCommand; -import com.cloud.agent.api.SecurityGroupRuleAnswer; -import com.cloud.agent.api.SecurityGroupRulesCmd; import com.cloud.agent.api.SetupGuestNetworkCommand; import com.cloud.agent.api.StartAnswer; import com.cloud.agent.api.StartCommand; @@ -138,7 +128,6 @@ import com.cloud.exception.InternalErrorException; import com.cloud.host.Host.Type; import com.cloud.hypervisor.Hypervisor.HypervisorType; -import com.cloud.hypervisor.kvm.resource.KVMHABase.NfsStoragePool; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.ClockDef; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.ConsoleDef; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.CpuModeDef; @@ -1284,14 +1273,8 @@ public Answer executeRequest(final Command cmd) { return execute((ManageSnapshotCommand)cmd); } else if (cmd instanceof BackupSnapshotCommand) { return execute((BackupSnapshotCommand)cmd); - } else if (cmd instanceof CreateVolumeFromSnapshotCommand) { - return execute((CreateVolumeFromSnapshotCommand)cmd); } else if (cmd instanceof CreatePrivateTemplateFromSnapshotCommand) { return execute((CreatePrivateTemplateFromSnapshotCommand)cmd); - } else if (cmd instanceof SecurityGroupRulesCmd) { - return execute((SecurityGroupRulesCmd)cmd); - } else if (cmd instanceof FenceCommand) { - return execute((FenceCommand)cmd); } else if (cmd instanceof StartCommand) { return execute((StartCommand)cmd); } else if (cmd instanceof PlugNicCommand) { @@ -1450,28 +1433,6 @@ private CopyVolumeAnswer execute(final CopyVolumeCommand cmd) { } } - protected FenceAnswer execute(final FenceCommand cmd) { - final ExecutorService executors = Executors.newSingleThreadExecutor(); - final List pools = _monitor.getStoragePools(); - final KVMHAChecker ha = new KVMHAChecker(pools, cmd.getHostIp()); - final Future future = executors.submit(ha); - try { - final Boolean result = future.get(); - if (result) { - return new FenceAnswer(cmd, false, "Heart is still beating..."); - } else { - return new FenceAnswer(cmd); - } - } catch (final InterruptedException e) { - s_logger.warn("Unable to fence", e); - return new FenceAnswer(cmd, false, e.getMessage()); - } catch (final ExecutionException e) { - s_logger.warn("Unable to fence", e); - return new FenceAnswer(cmd, false, e.getMessage()); - } - - } - protected Storage.StorageResourceType getStorageResourceType() { return Storage.StorageResourceType.STORAGE_POOL; } @@ -2265,25 +2226,6 @@ protected BackupSnapshotAnswer execute(final BackupSnapshotCommand cmd) { return new BackupSnapshotAnswer(cmd, true, null, snapshotRelPath + File.separator + snapshotName, true); } - protected CreateVolumeFromSnapshotAnswer execute(final CreateVolumeFromSnapshotCommand cmd) { - try { - - String snapshotPath = cmd.getSnapshotUuid(); - final int index = snapshotPath.lastIndexOf("/"); - snapshotPath = snapshotPath.substring(0, index); - final KVMStoragePool secondaryPool = _storagePoolMgr.getStoragePoolByURI(cmd.getSecondaryStorageUrl() + snapshotPath); - final KVMPhysicalDisk snapshot = secondaryPool.getPhysicalDisk(cmd.getSnapshotName()); - - final String primaryUuid = cmd.getPrimaryStoragePoolNameLabel(); - final KVMStoragePool primaryPool = _storagePoolMgr.getStoragePool(cmd.getPool().getType(), primaryUuid); - final String volUuid = UUID.randomUUID().toString(); - final KVMPhysicalDisk disk = _storagePoolMgr.copyPhysicalDisk(snapshot, volUuid, primaryPool, 0); - return new CreateVolumeFromSnapshotAnswer(cmd, true, "", disk.getName()); - } catch (final CloudRuntimeException e) { - return new CreateVolumeFromSnapshotAnswer(cmd, false, e.toString(), null); - } - } - protected CreatePrivateTemplateAnswer execute(final CreatePrivateTemplateFromSnapshotCommand cmd) { final String templateFolder = cmd.getAccountId() + File.separator + cmd.getNewTemplateId(); final String templateInstallFolder = "template/tmpl/" + templateFolder; @@ -2450,32 +2392,6 @@ protected CreatePrivateTemplateAnswer execute(final CreatePrivateTemplateFromVol } } - private Answer execute(final SecurityGroupRulesCmd cmd) { - String vif = null; - String brname = null; - try { - final Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); - final List nics = getInterfaces(conn, cmd.getVmName()); - vif = nics.get(0).getDevName(); - brname = nics.get(0).getBrName(); - } catch (final LibvirtException e) { - return new SecurityGroupRuleAnswer(cmd, false, e.toString()); - } - - final boolean result = - add_network_rules(cmd.getVmName(), Long.toString(cmd.getVmId()), cmd.getGuestIp(), cmd.getSignature(), Long.toString(cmd.getSeqNum()), cmd.getGuestMac(), - cmd.stringifyRules(), vif, brname, cmd.getSecIpsString()); - - if (!result) { - s_logger.warn("Failed to program network rules for vm " + cmd.getVmName()); - return new SecurityGroupRuleAnswer(cmd, false, "programming network rules failed"); - } else { - s_logger.debug("Programmed network rules for vm " + cmd.getVmName() + " guestIp=" + cmd.getGuestIp() + ",ingress numrules=" + cmd.getIngressRuleSet().length + - ",egress numrules=" + cmd.getEgressRuleSet().length); - return new SecurityGroupRuleAnswer(cmd); - } - } - protected PowerState convertToPowerState(final DomainState ps) { final PowerState state = s_powerStatesTable.get(ps); return state == null ? PowerState.PowerUnknown : state; @@ -4101,7 +4017,7 @@ public boolean configureDefaultNetworkRulesForSystemVm(final Connect conn, final return true; } - private boolean add_network_rules(final String vmName, final String vmId, final String guestIP, final String sig, final String seq, final String mac, final String rules, final String vif, final String brname, + public boolean addNetworkRules(final String vmName, final String vmId, final String guestIP, final String sig, final String seq, final String mac, final String rules, final String vif, final String brname, final String secIps) { if (!_canBridgeFirewall) { return false; diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreateVolumeFromSnapshotCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreateVolumeFromSnapshotCommandWrapper.java new file mode 100644 index 000000000000..b30c3f8777da --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreateVolumeFromSnapshotCommandWrapper.java @@ -0,0 +1,68 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import java.util.UUID; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.CreateVolumeFromSnapshotAnswer; +import com.cloud.agent.api.CreateVolumeFromSnapshotCommand; +import com.cloud.agent.api.to.StorageFilerTO; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk; +import com.cloud.hypervisor.kvm.storage.KVMStoragePool; +import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; +import com.cloud.resource.CommandWrapper; +import com.cloud.utils.exception.CloudRuntimeException; + +public final class LibvirtCreateVolumeFromSnapshotCommandWrapper extends CommandWrapper { + + @Override + public Answer execute(final CreateVolumeFromSnapshotCommand command, final LibvirtComputingResource libvirtComputingResource) { + try { + + String snapshotPath = command.getSnapshotUuid(); + final int index = snapshotPath.lastIndexOf("/"); + snapshotPath = snapshotPath.substring(0, index); + + final KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr(); + final KVMStoragePool secondaryPool = storagePoolMgr.getStoragePoolByURI(command.getSecondaryStorageUrl() + snapshotPath); + final KVMPhysicalDisk snapshot = secondaryPool.getPhysicalDisk(command.getSnapshotName()); + + final String primaryUuid = command.getPrimaryStoragePoolNameLabel(); + + final StorageFilerTO pool = command.getPool(); + final KVMStoragePool primaryPool = storagePoolMgr.getStoragePool(pool.getType(), primaryUuid); + + final String volUuid = UUID.randomUUID().toString(); + final KVMPhysicalDisk disk = storagePoolMgr.copyPhysicalDisk(snapshot, volUuid, primaryPool, 0); + + if (disk == null) { + throw new NullPointerException("Disk was not successfully copied to the new storage."); + } + + return new CreateVolumeFromSnapshotAnswer(command, true, "", disk.getName()); + } catch (final CloudRuntimeException e) { + return new CreateVolumeFromSnapshotAnswer(command, false, e.toString(), null); + } catch (final Exception e) { + return new CreateVolumeFromSnapshotAnswer(command, false, e.toString(), null); + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtFenceCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtFenceCommandWrapper.java new file mode 100644 index 000000000000..53e3845db71b --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtFenceCommandWrapper.java @@ -0,0 +1,67 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +import org.apache.log4j.Logger; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.FenceAnswer; +import com.cloud.agent.api.FenceCommand; +import com.cloud.hypervisor.kvm.resource.KVMHABase.NfsStoragePool; +import com.cloud.hypervisor.kvm.resource.KVMHAChecker; +import com.cloud.hypervisor.kvm.resource.KVMHAMonitor; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; + +public final class LibvirtFenceCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtFenceCommandWrapper.class); + + @Override + public Answer execute(final FenceCommand command, final LibvirtComputingResource libvirtComputingResource) { + final ExecutorService executors = Executors.newSingleThreadExecutor(); + final KVMHAMonitor monitor = libvirtComputingResource.getMonitor(); + + final List pools = monitor.getStoragePools(); + final KVMHAChecker ha = new KVMHAChecker(pools, command.getHostIp()); + + final Future future = executors.submit(ha); + try { + final Boolean result = future.get(); + if (result) { + return new FenceAnswer(command, false, "Heart is still beating..."); + } else { + return new FenceAnswer(command); + } + } catch (final InterruptedException e) { + s_logger.warn("Unable to fence", e); + return new FenceAnswer(command, false, e.getMessage()); + } catch (final ExecutionException e) { + s_logger.warn("Unable to fence", e); + return new FenceAnswer(command, false, e.getMessage()); + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java index af2f544e0944..23248c4a6d2a 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java @@ -30,7 +30,9 @@ import com.cloud.agent.api.CleanupNetworkRulesCmd; import com.cloud.agent.api.Command; import com.cloud.agent.api.CreateStoragePoolCommand; +import com.cloud.agent.api.CreateVolumeFromSnapshotCommand; import com.cloud.agent.api.DeleteStoragePoolCommand; +import com.cloud.agent.api.FenceCommand; import com.cloud.agent.api.GetHostStatsCommand; import com.cloud.agent.api.GetStorageStatsCommand; import com.cloud.agent.api.GetVmDiskStatsCommand; @@ -54,6 +56,7 @@ import com.cloud.agent.api.ReadyCommand; import com.cloud.agent.api.RebootCommand; import com.cloud.agent.api.RebootRouterCommand; +import com.cloud.agent.api.SecurityGroupRulesCmd; import com.cloud.agent.api.StopCommand; import com.cloud.agent.api.UpgradeSnapshotCommand; import com.cloud.agent.api.check.CheckSshCommand; @@ -124,6 +127,9 @@ private void init() { linbvirtCommands.put(OvsDestroyTunnelCommand.class, new LibvirtOvsDestroyTunnelCommandWrapper()); linbvirtCommands.put(CheckOnHostCommand.class, new LibvirtCheckOnHostCommandWrapper()); linbvirtCommands.put(OvsCreateTunnelCommand.class, new LibvirtOvsCreateTunnelCommandWrapper()); + linbvirtCommands.put(CreateVolumeFromSnapshotCommand.class, new LibvirtCreateVolumeFromSnapshotCommandWrapper()); + linbvirtCommands.put(FenceCommand.class, new LibvirtFenceCommandWrapper()); + linbvirtCommands.put(SecurityGroupRulesCmd.class, new LibvirtSecurityGroupRulesCommandWrapper()); resources.put(LibvirtComputingResource.class, linbvirtCommands); } diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtSecurityGroupRulesCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtSecurityGroupRulesCommandWrapper.java new file mode 100644 index 000000000000..5bdafe7b2d83 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtSecurityGroupRulesCommandWrapper.java @@ -0,0 +1,67 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import java.util.List; + +import org.apache.log4j.Logger; +import org.libvirt.Connect; +import org.libvirt.LibvirtException; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.SecurityGroupRuleAnswer; +import com.cloud.agent.api.SecurityGroupRulesCmd; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef; +import com.cloud.resource.CommandWrapper; + +public final class LibvirtSecurityGroupRulesCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtSecurityGroupRulesCommandWrapper.class); + + @Override + public Answer execute(final SecurityGroupRulesCmd command, final LibvirtComputingResource libvirtComputingResource) { + String vif = null; + String brname = null; + try { + final LibvirtConnectionWrapper libvirtConnectionWrapper = libvirtComputingResource.getLibvirtConnectionWrapper(); + + final Connect conn = libvirtConnectionWrapper.getConnectionByVmName(command.getVmName()); + final List nics = libvirtComputingResource.getInterfaces(conn, command.getVmName()); + + vif = nics.get(0).getDevName(); + brname = nics.get(0).getBrName(); + } catch (final LibvirtException e) { + return new SecurityGroupRuleAnswer(command, false, e.toString()); + } + + final boolean result = libvirtComputingResource.addNetworkRules(command.getVmName(), Long.toString(command.getVmId()), command.getGuestIp(), command.getSignature(), + Long.toString(command.getSeqNum()), command.getGuestMac(), command.stringifyRules(), vif, brname, command.getSecIpsString()); + + if (!result) { + s_logger.warn("Failed to program network rules for vm " + command.getVmName()); + return new SecurityGroupRuleAnswer(command, false, "programming network rules failed"); + } else { + s_logger.debug("Programmed network rules for vm " + command.getVmName() + " guestIp=" + command.getGuestIp() + ",ingress numrules=" + + command.getIngressRuleSet().length + ",egress numrules=" + command.getEgressRuleSet().length); + return new SecurityGroupRuleAnswer(command); + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index f01ad7a76dc5..15ba52b251d7 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -72,7 +72,9 @@ import com.cloud.agent.api.CheckVirtualMachineCommand; import com.cloud.agent.api.CleanupNetworkRulesCmd; import com.cloud.agent.api.CreateStoragePoolCommand; +import com.cloud.agent.api.CreateVolumeFromSnapshotCommand; import com.cloud.agent.api.DeleteStoragePoolCommand; +import com.cloud.agent.api.FenceCommand; import com.cloud.agent.api.GetHostStatsCommand; import com.cloud.agent.api.GetStorageStatsCommand; import com.cloud.agent.api.GetVmDiskStatsCommand; @@ -100,6 +102,8 @@ import com.cloud.agent.api.ReadyCommand; import com.cloud.agent.api.RebootCommand; import com.cloud.agent.api.RebootRouterCommand; +import com.cloud.agent.api.SecurityGroupRulesCmd; +import com.cloud.agent.api.SecurityGroupRulesCmd.IpPortAndProto; import com.cloud.agent.api.StopCommand; import com.cloud.agent.api.UpgradeSnapshotCommand; import com.cloud.agent.api.VmStatsEntry; @@ -117,6 +121,7 @@ import com.cloud.agent.api.to.VolumeTO; import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource; import com.cloud.exception.InternalErrorException; +import com.cloud.hypervisor.kvm.resource.KVMHABase.NfsStoragePool; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef; import com.cloud.hypervisor.kvm.resource.wrapper.LibvirtConnectionWrapper; @@ -1863,17 +1868,17 @@ public void testGetStorageStatsCommandException() { @Test public void testUpgradeSnapshotCommand() { - final StoragePool pool = null; - final String secondaryStoragePoolURL = null; - final Long dcId = null; - final Long accountId = null; - final Long volumeId = null; - final Long templateId = null; - final Long tmpltAccountId = null; - final String volumePath = null; - final String snapshotUuid = null; - final String snapshotName = null; - final String version = null; + final StoragePool pool = Mockito.mock(StoragePool.class);; + final String secondaryStoragePoolURL = "url"; + final Long dcId = 1l; + final Long accountId = 1l; + final Long volumeId = 1l; + final Long templateId = 1l; + final Long tmpltAccountId = 1l; + final String volumePath = "/opt/path"; + final String snapshotUuid = "uuid:/8edb1156-a851-4914-afc6-468ee52ac861/"; + final String snapshotName = "uuid:/8edb1156-a851-4914-afc6-468ee52ac861/"; + final String version = "1"; final UpgradeSnapshotCommand command = new UpgradeSnapshotCommand(pool, secondaryStoragePoolURL, dcId, accountId, volumeId, templateId, tmpltAccountId, volumePath, snapshotUuid, snapshotName, version); @@ -2654,4 +2659,273 @@ public void testOvsCreateTunnelCommandFailure2() { verify(libvirtComputingResource, times(1)).configureTunnelNetwork(command.getNetworkId(), command.getFrom(), command.getNetworkName()); } + + @Test + public void testCreateVolumeFromSnapshotCommand() { + // This tests asserts to False because there will be a NPE due to UUID static method calls. + + final StoragePool pool = Mockito.mock(StoragePool.class); + final String secondaryStoragePoolURL = "/opt/storage/"; + final Long dcId = 1l; + final Long accountId = 1l; + final Long volumeId = 1l; + final String backedUpSnapshotUuid = "uuid:/8edb1156-a851-4914-afc6-468ee52ac861/"; + final String backedUpSnapshotName = "uuid:/8edb1156-a851-4914-afc6-468ee52ac862/"; + final int wait = 0; + + final CreateVolumeFromSnapshotCommand command = new CreateVolumeFromSnapshotCommand(pool, secondaryStoragePoolURL, dcId, accountId, volumeId, backedUpSnapshotUuid, backedUpSnapshotName, wait); + + final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class); + final KVMStoragePool secondaryPool = Mockito.mock(KVMStoragePool.class); + final KVMPhysicalDisk snapshot = Mockito.mock(KVMPhysicalDisk.class); + final KVMStoragePool primaryPool = Mockito.mock(KVMStoragePool.class); + + String snapshotPath = command.getSnapshotUuid(); + final int index = snapshotPath.lastIndexOf("/"); + snapshotPath = snapshotPath.substring(0, index); + + final String primaryUuid = command.getPrimaryStoragePoolNameLabel(); + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr); + when(storagePoolMgr.getStoragePoolByURI(command.getSecondaryStorageUrl() + snapshotPath)).thenReturn(secondaryPool); + when(secondaryPool.getPhysicalDisk(command.getSnapshotName())).thenReturn(snapshot); + when(storagePoolMgr.getStoragePool(command.getPool().getType(), primaryUuid)).thenReturn(primaryPool); + + //when(storagePoolMgr.copyPhysicalDisk(snapshot, volUuid, primaryPool, 0)).thenReturn(disk); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + verify(storagePoolMgr, times(1)).getStoragePoolByURI(command.getSecondaryStorageUrl() + snapshotPath); + verify(secondaryPool, times(1)).getPhysicalDisk(command.getSnapshotName()); + verify(storagePoolMgr, times(1)).getStoragePool(command.getPool().getType(), primaryUuid); + //verify(storagePoolMgr, times(1)).copyPhysicalDisk(snapshot, volUuid, primaryPool, 0); + } + + @SuppressWarnings("unchecked") + @Test + public void testCreateVolumeFromSnapshotCommandCloudException() { + final StoragePool pool = Mockito.mock(StoragePool.class); + final String secondaryStoragePoolURL = "/opt/storage/"; + final Long dcId = 1l; + final Long accountId = 1l; + final Long volumeId = 1l; + final String backedUpSnapshotUuid = "uuid:/8edb1156-a851-4914-afc6-468ee52ac861/"; + final String backedUpSnapshotName = "uuid:/8edb1156-a851-4914-afc6-468ee52ac862/"; + final int wait = 0; + + final CreateVolumeFromSnapshotCommand command = new CreateVolumeFromSnapshotCommand(pool, secondaryStoragePoolURL, dcId, accountId, volumeId, backedUpSnapshotUuid, backedUpSnapshotName, wait); + + final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class); + final KVMStoragePool secondaryPool = Mockito.mock(KVMStoragePool.class); + final KVMPhysicalDisk snapshot = Mockito.mock(KVMPhysicalDisk.class); + + String snapshotPath = command.getSnapshotUuid(); + final int index = snapshotPath.lastIndexOf("/"); + snapshotPath = snapshotPath.substring(0, index); + + final String primaryUuid = command.getPrimaryStoragePoolNameLabel(); + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr); + when(storagePoolMgr.getStoragePoolByURI(command.getSecondaryStorageUrl() + snapshotPath)).thenReturn(secondaryPool); + when(secondaryPool.getPhysicalDisk(command.getSnapshotName())).thenReturn(snapshot); + when(storagePoolMgr.getStoragePool(command.getPool().getType(), primaryUuid)).thenThrow(CloudRuntimeException.class); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + verify(storagePoolMgr, times(1)).getStoragePoolByURI(command.getSecondaryStorageUrl() + snapshotPath); + verify(secondaryPool, times(1)).getPhysicalDisk(command.getSnapshotName()); + verify(storagePoolMgr, times(1)).getStoragePool(command.getPool().getType(), primaryUuid); + } + + @Test + public void testFenceCommand() { + final VirtualMachine vm = Mockito.mock(VirtualMachine.class);; + final com.cloud.host.Host host = Mockito.mock(com.cloud.host.Host.class); + + final FenceCommand command = new FenceCommand(vm, host); + + final KVMHAMonitor monitor = Mockito.mock(KVMHAMonitor.class); + + final NfsStoragePool storagePool = Mockito.mock(NfsStoragePool.class); + final List pools = new ArrayList(); + pools.add(storagePool); + + when(libvirtComputingResource.getMonitor()).thenReturn(monitor); + when(monitor.getStoragePools()).thenReturn(pools); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getMonitor(); + verify(monitor, times(1)).getStoragePools(); + } + + @Test + public void testSecurityGroupRulesCmdFalse() { + final String guestIp = "172.16.16.16"; + final String guestMac = "00:00:00:00"; + final String vmName = "Test"; + final Long vmId = 1l; + final String signature = "signature"; + final Long seqNum = 1l; + final IpPortAndProto[] ingressRuleSet = new IpPortAndProto[]{Mockito.mock(IpPortAndProto.class)}; + final IpPortAndProto[] egressRuleSet = new IpPortAndProto[]{Mockito.mock(IpPortAndProto.class)}; + + final SecurityGroupRulesCmd command = new SecurityGroupRulesCmd(guestIp, guestMac, vmName, vmId, signature, seqNum, ingressRuleSet, egressRuleSet); + + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final Connect conn = Mockito.mock(Connect.class); + + final List nics = new ArrayList(); + final InterfaceDef interfaceDef = Mockito.mock(InterfaceDef.class); + nics.add(interfaceDef); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getInterfaces(conn, command.getVmName())).thenReturn(nics); + try { + when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenReturn(conn); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + when(ingressRuleSet[0].getProto()).thenReturn("tcp"); + when(ingressRuleSet[0].getStartPort()).thenReturn(22); + when(ingressRuleSet[0].getEndPort()).thenReturn(22); + when(ingressRuleSet[0].getAllowedCidrs()).thenReturn(new String[]{"0.0.0.0/0"}); + + when(egressRuleSet[0].getProto()).thenReturn("tcp"); + when(egressRuleSet[0].getStartPort()).thenReturn(22); + when(egressRuleSet[0].getEndPort()).thenReturn(22); + when(egressRuleSet[0].getAllowedCidrs()).thenReturn(new String[]{"0.0.0.0/0"}); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + + @Test + public void testSecurityGroupRulesCmdTrue() { + final String guestIp = "172.16.16.16"; + final String guestMac = "00:00:00:00"; + final String vmName = "Test"; + final Long vmId = 1l; + final String signature = "signature"; + final Long seqNum = 1l; + final IpPortAndProto[] ingressRuleSet = new IpPortAndProto[]{Mockito.mock(IpPortAndProto.class)}; + final IpPortAndProto[] egressRuleSet = new IpPortAndProto[]{Mockito.mock(IpPortAndProto.class)}; + + final SecurityGroupRulesCmd command = new SecurityGroupRulesCmd(guestIp, guestMac, vmName, vmId, signature, seqNum, ingressRuleSet, egressRuleSet); + + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final Connect conn = Mockito.mock(Connect.class); + + final List nics = new ArrayList(); + final InterfaceDef interfaceDef = Mockito.mock(InterfaceDef.class); + nics.add(interfaceDef); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getInterfaces(conn, command.getVmName())).thenReturn(nics); + try { + when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenReturn(conn); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + when(interfaceDef.getDevName()).thenReturn("eth0"); + when(interfaceDef.getBrName()).thenReturn("br0"); + + final String vif = nics.get(0).getDevName(); + final String brname = nics.get(0).getBrName(); + + when(ingressRuleSet[0].getProto()).thenReturn("tcp"); + when(ingressRuleSet[0].getStartPort()).thenReturn(22); + when(ingressRuleSet[0].getEndPort()).thenReturn(22); + when(ingressRuleSet[0].getAllowedCidrs()).thenReturn(new String[]{"0.0.0.0/0"}); + + when(egressRuleSet[0].getProto()).thenReturn("tcp"); + when(egressRuleSet[0].getStartPort()).thenReturn(22); + when(egressRuleSet[0].getEndPort()).thenReturn(22); + when(egressRuleSet[0].getAllowedCidrs()).thenReturn(new String[]{"0.0.0.0/0"}); + + when(libvirtComputingResource.addNetworkRules(command.getVmName(), Long.toString(command.getVmId()), command.getGuestIp(), command.getSignature(), + Long.toString(command.getSeqNum()), command.getGuestMac(), command.stringifyRules(), vif, brname, command.getSecIpsString())).thenReturn(true); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + + @SuppressWarnings("unchecked") + @Test + public void testSecurityGroupRulesCmdException() { + final String guestIp = "172.16.16.16"; + final String guestMac = "00:00:00:00"; + final String vmName = "Test"; + final Long vmId = 1l; + final String signature = "signature"; + final Long seqNum = 1l; + final IpPortAndProto[] ingressRuleSet = new IpPortAndProto[]{Mockito.mock(IpPortAndProto.class)}; + final IpPortAndProto[] egressRuleSet = new IpPortAndProto[]{Mockito.mock(IpPortAndProto.class)}; + + final SecurityGroupRulesCmd command = new SecurityGroupRulesCmd(guestIp, guestMac, vmName, vmId, signature, seqNum, ingressRuleSet, egressRuleSet); + + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final Connect conn = Mockito.mock(Connect.class); + + final List nics = new ArrayList(); + final InterfaceDef interfaceDef = Mockito.mock(InterfaceDef.class); + nics.add(interfaceDef); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getInterfaces(conn, command.getVmName())).thenReturn(nics); + try { + when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenThrow(LibvirtException.class); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } } \ No newline at end of file From 52d9f0c20624e74dd2852038cd3912e1756d11e3 Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Tue, 5 May 2015 10:39:50 +0200 Subject: [PATCH 025/175] Refactoring the LibvirtComputingResource - Adding LibvirtNetworkUsageCommandWrapper, LibvirtPlugNicCommandWrapper and LibvirtUnPlugNicCommandWrapper - 9 unit tests added - KVM hypervisor plugin with 18.3% coverage --- .../resource/LibvirtComputingResource.java | 120 +---- .../LibvirtNetworkUsageCommandWrapper.java | 57 +++ .../wrapper/LibvirtPlugNicCommandWrapper.java | 85 ++++ .../wrapper/LibvirtRequestWrapper.java | 6 + .../LibvirtUnPlugNicCommandWrapper.java | 80 +++ .../LibvirtComputingResourceTest.java | 481 ++++++++++++++++++ 6 files changed, 713 insertions(+), 116 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkUsageCommandWrapper.java create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPlugNicCommandWrapper.java create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUnPlugNicCommandWrapper.java diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 6f24b31b716e..3c40c908071e 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -87,13 +87,9 @@ import com.cloud.agent.api.HostVmStateReportEntry; import com.cloud.agent.api.ManageSnapshotAnswer; import com.cloud.agent.api.ManageSnapshotCommand; -import com.cloud.agent.api.NetworkUsageAnswer; -import com.cloud.agent.api.NetworkUsageCommand; import com.cloud.agent.api.PingCommand; import com.cloud.agent.api.PingRoutingCommand; import com.cloud.agent.api.PingRoutingWithNwGroupsCommand; -import com.cloud.agent.api.PlugNicAnswer; -import com.cloud.agent.api.PlugNicCommand; import com.cloud.agent.api.PvlanSetupCommand; import com.cloud.agent.api.SetupGuestNetworkCommand; import com.cloud.agent.api.StartAnswer; @@ -101,8 +97,6 @@ import com.cloud.agent.api.StartupCommand; import com.cloud.agent.api.StartupRoutingCommand; import com.cloud.agent.api.StartupStorageCommand; -import com.cloud.agent.api.UnPlugNicAnswer; -import com.cloud.agent.api.UnPlugNicCommand; import com.cloud.agent.api.VmDiskStatsEntry; import com.cloud.agent.api.VmStatsEntry; import com.cloud.agent.api.routing.IpAssocCommand; @@ -1277,14 +1271,8 @@ public Answer executeRequest(final Command cmd) { return execute((CreatePrivateTemplateFromSnapshotCommand)cmd); } else if (cmd instanceof StartCommand) { return execute((StartCommand)cmd); - } else if (cmd instanceof PlugNicCommand) { - return execute((PlugNicCommand)cmd); - } else if (cmd instanceof UnPlugNicCommand) { - return execute((UnPlugNicCommand)cmd); } else if (cmd instanceof NetworkElementCommand) { return _virtRouterResource.executeRequest((NetworkElementCommand)cmd); - } else if (cmd instanceof NetworkUsageCommand) { - return execute((NetworkUsageCommand)cmd); } else if (cmd instanceof CopyVolumeCommand) { return execute((CopyVolumeCommand)cmd); } else if (cmd instanceof ResizeVolumeCommand) { @@ -1702,79 +1690,6 @@ private void vifHotUnPlug (final Connect conn, final String vmName, final String } } - private PlugNicAnswer execute(final PlugNicCommand cmd) { - final NicTO nic = cmd.getNic(); - final String vmName = cmd.getVmName(); - Domain vm = null; - try { - final Connect conn = LibvirtConnection.getConnectionByVmName(vmName); - vm = getDomain(conn, vmName); - final List pluggedNics = getInterfaces(conn, vmName); - Integer nicnum = 0; - for (final InterfaceDef pluggedNic : pluggedNics) { - if (pluggedNic.getMacAddress().equalsIgnoreCase(nic.getMac())) { - s_logger.debug("found existing nic for mac " + pluggedNic.getMacAddress() + " at index " + nicnum); - return new PlugNicAnswer(cmd, true, "success"); - } - nicnum++; - } - vm.attachDevice(getVifDriver(nic.getType()).plug(nic, "Other PV", "").toString()); - return new PlugNicAnswer(cmd, true, "success"); - } catch (final LibvirtException e) { - final String msg = " Plug Nic failed due to " + e.toString(); - s_logger.warn(msg, e); - return new PlugNicAnswer(cmd, false, msg); - } catch (final InternalErrorException e) { - final String msg = " Plug Nic failed due to " + e.toString(); - s_logger.warn(msg, e); - return new PlugNicAnswer(cmd, false, msg); - } finally { - if (vm != null) { - try { - vm.free(); - } catch (final LibvirtException l) { - s_logger.trace("Ignoring libvirt error.", l); - } - } - } - } - - private UnPlugNicAnswer execute(final UnPlugNicCommand cmd) { - Connect conn; - final NicTO nic = cmd.getNic(); - final String vmName = cmd.getVmName(); - Domain vm = null; - try { - conn = LibvirtConnection.getConnectionByVmName(vmName); - vm = getDomain(conn, vmName); - final List pluggedNics = getInterfaces(conn, vmName); - for (final InterfaceDef pluggedNic : pluggedNics) { - if (pluggedNic.getMacAddress().equalsIgnoreCase(nic.getMac())) { - vm.detachDevice(pluggedNic.toString()); - // We don't know which "traffic type" is associated with - // each interface at this point, so inform all vif drivers - for (final VifDriver vifDriver : getAllVifDrivers()) { - vifDriver.unplug(pluggedNic); - } - return new UnPlugNicAnswer(cmd, true, "success"); - } - } - return new UnPlugNicAnswer(cmd, true, "success"); - } catch (final LibvirtException e) { - final String msg = " Unplug Nic failed due to " + e.toString(); - s_logger.warn(msg, e); - return new UnPlugNicAnswer(cmd, false, msg); - } finally { - if (vm != null) { - try { - vm.free(); - } catch (final LibvirtException l) { - s_logger.trace("Ignoring libvirt error.", l); - } - } - } - } - private ExecutionResult prepareNetworkElementCommand(final SetupGuestNetworkCommand cmd) { Connect conn; final NicTO nic = cmd.getNic(); @@ -2445,7 +2360,7 @@ public String networkUsage(final String privateIpAddress, final String option, f return usageParser.getLine(); } - protected long[] getNetworkStats(final String privateIP) { + public long[] getNetworkStats(final String privateIP) { final String result = networkUsage(privateIP, "get", null); final long[] stats = new long[2]; if (result != null) { @@ -2459,7 +2374,7 @@ protected long[] getNetworkStats(final String privateIP) { return stats; } - protected String VPCNetworkUsage(final String privateIpAddress, final String publicIp, final String option, final String vpcCIDR) { + public String configureVPCNetworkUsage(final String privateIpAddress, final String publicIp, final String option, final String vpcCIDR) { final Script getUsage = new Script(_routerProxyPath, s_logger); getUsage.add("vpc_netusage.sh"); getUsage.add(privateIpAddress); @@ -2487,8 +2402,8 @@ protected String VPCNetworkUsage(final String privateIpAddress, final String pub return usageParser.getLine(); } - protected long[] getVPCNetworkStats(final String privateIP, final String publicIp, final String option) { - final String result = VPCNetworkUsage(privateIP, publicIp, option, null); + public long[] getVPCNetworkStats(final String privateIP, final String publicIp, final String option) { + final String result = configureVPCNetworkUsage(privateIP, publicIp, option, null); final long[] stats = new long[2]; if (result != null) { final String[] splitResult = result.split(":"); @@ -2501,33 +2416,6 @@ protected long[] getVPCNetworkStats(final String privateIP, final String publicI return stats; } - private Answer execute(final NetworkUsageCommand cmd) { - if (cmd.isForVpc()) { - if (cmd.getOption() != null && cmd.getOption().equals("create")) { - final String result = VPCNetworkUsage(cmd.getPrivateIP(), cmd.getGatewayIP(), "create", cmd.getVpcCIDR()); - final NetworkUsageAnswer answer = new NetworkUsageAnswer(cmd, result, 0L, 0L); - return answer; - } else if (cmd.getOption() != null && (cmd.getOption().equals("get") || cmd.getOption().equals("vpn"))) { - final long[] stats = getVPCNetworkStats(cmd.getPrivateIP(), cmd.getGatewayIP(), cmd.getOption()); - final NetworkUsageAnswer answer = new NetworkUsageAnswer(cmd, "", stats[0], stats[1]); - return answer; - } else { - final String result = VPCNetworkUsage(cmd.getPrivateIP(), cmd.getGatewayIP(), cmd.getOption(), cmd.getVpcCIDR()); - final NetworkUsageAnswer answer = new NetworkUsageAnswer(cmd, result, 0L, 0L); - return answer; - } - } else { - if (cmd.getOption() != null && cmd.getOption().equals("create")) { - final String result = networkUsage(cmd.getPrivateIP(), "create", null); - final NetworkUsageAnswer answer = new NetworkUsageAnswer(cmd, result, 0L, 0L); - return answer; - } - final long[] stats = getNetworkStats(cmd.getPrivateIP()); - final NetworkUsageAnswer answer = new NetworkUsageAnswer(cmd, "", stats[0], stats[1]); - return answer; - } - } - protected void handleVmStartFailure(final Connect conn, final String vmName, final LibvirtVMDef vm) { if (vm != null && vm.getDevices() != null) { cleanupVMNetworks(conn, vm.getDevices().getInterfaces()); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkUsageCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkUsageCommandWrapper.java new file mode 100644 index 000000000000..3ac21825beef --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkUsageCommandWrapper.java @@ -0,0 +1,57 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.NetworkUsageAnswer; +import com.cloud.agent.api.NetworkUsageCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; + +public final class LibvirtNetworkUsageCommandWrapper extends CommandWrapper { + + @Override + public Answer execute(final NetworkUsageCommand command, final LibvirtComputingResource libvirtComputingResource) { + if (command.isForVpc()) { + if (command.getOption() != null && command.getOption().equals("create")) { + final String result = libvirtComputingResource.configureVPCNetworkUsage(command.getPrivateIP(), command.getGatewayIP(), "create", command.getVpcCIDR()); + final NetworkUsageAnswer answer = new NetworkUsageAnswer(command, result, 0L, 0L); + return answer; + } else if (command.getOption() != null && (command.getOption().equals("get") || command.getOption().equals("vpn"))) { + final long[] stats = libvirtComputingResource.getVPCNetworkStats(command.getPrivateIP(), command.getGatewayIP(), command.getOption()); + final NetworkUsageAnswer answer = new NetworkUsageAnswer(command, "", stats[0], stats[1]); + return answer; + } else { + final String result = libvirtComputingResource.configureVPCNetworkUsage(command.getPrivateIP(), command.getGatewayIP(), command.getOption(), command.getVpcCIDR()); + final NetworkUsageAnswer answer = new NetworkUsageAnswer(command, result, 0L, 0L); + return answer; + } + } else { + if (command.getOption() != null && command.getOption().equals("create")) { + final String result = libvirtComputingResource.networkUsage(command.getPrivateIP(), "create", null); + final NetworkUsageAnswer answer = new NetworkUsageAnswer(command, result, 0L, 0L); + return answer; + } + final long [] stats = libvirtComputingResource.getNetworkStats(command.getPrivateIP()); + final NetworkUsageAnswer answer = new NetworkUsageAnswer(command, "", stats[0], stats[1]); + return answer; + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPlugNicCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPlugNicCommandWrapper.java new file mode 100644 index 000000000000..7e6f642964ad --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPlugNicCommandWrapper.java @@ -0,0 +1,85 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import java.util.List; + +import org.apache.log4j.Logger; +import org.libvirt.Connect; +import org.libvirt.Domain; +import org.libvirt.LibvirtException; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.PlugNicAnswer; +import com.cloud.agent.api.PlugNicCommand; +import com.cloud.agent.api.to.NicTO; +import com.cloud.exception.InternalErrorException; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef; +import com.cloud.hypervisor.kvm.resource.VifDriver; +import com.cloud.resource.CommandWrapper; + +public final class LibvirtPlugNicCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtPlugNicCommandWrapper.class); + + @Override + public Answer execute(final PlugNicCommand command, final LibvirtComputingResource libvirtComputingResource) { + final NicTO nic = command.getNic(); + final String vmName = command.getVmName(); + Domain vm = null; + try { + final LibvirtConnectionWrapper libvirtConnectionWrapper = libvirtComputingResource.getLibvirtConnectionWrapper(); + final Connect conn = libvirtConnectionWrapper.getConnectionByVmName(vmName); + vm = libvirtComputingResource.getDomain(conn, vmName); + + final List pluggedNics = libvirtComputingResource.getInterfaces(conn, vmName); + Integer nicnum = 0; + for (final InterfaceDef pluggedNic : pluggedNics) { + if (pluggedNic.getMacAddress().equalsIgnoreCase(nic.getMac())) { + s_logger.debug("found existing nic for mac " + pluggedNic.getMacAddress() + " at index " + nicnum); + return new PlugNicAnswer(command, true, "success"); + } + nicnum++; + } + VifDriver vifDriver = libvirtComputingResource.getVifDriver(nic.getType()); + InterfaceDef interfaceDef = vifDriver.plug(nic, "Other PV", ""); + vm.attachDevice(interfaceDef.toString()); + + return new PlugNicAnswer(command, true, "success"); + } catch (final LibvirtException e) { + final String msg = " Plug Nic failed due to " + e.toString(); + s_logger.warn(msg, e); + return new PlugNicAnswer(command, false, msg); + } catch (final InternalErrorException e) { + final String msg = " Plug Nic failed due to " + e.toString(); + s_logger.warn(msg, e); + return new PlugNicAnswer(command, false, msg); + } finally { + if (vm != null) { + try { + vm.free(); + } catch (final LibvirtException l) { + s_logger.trace("Ignoring libvirt error.", l); + } + } + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java index 23248c4a6d2a..148075b8575a 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java @@ -44,6 +44,7 @@ import com.cloud.agent.api.ModifyStoragePoolCommand; import com.cloud.agent.api.NetworkRulesSystemVmCommand; import com.cloud.agent.api.NetworkRulesVmSecondaryIpCommand; +import com.cloud.agent.api.NetworkUsageCommand; import com.cloud.agent.api.OvsCreateTunnelCommand; import com.cloud.agent.api.OvsDestroyBridgeCommand; import com.cloud.agent.api.OvsDestroyTunnelCommand; @@ -52,12 +53,14 @@ import com.cloud.agent.api.OvsVpcPhysicalTopologyConfigCommand; import com.cloud.agent.api.OvsVpcRoutingPolicyConfigCommand; import com.cloud.agent.api.PingTestCommand; +import com.cloud.agent.api.PlugNicCommand; import com.cloud.agent.api.PrepareForMigrationCommand; import com.cloud.agent.api.ReadyCommand; import com.cloud.agent.api.RebootCommand; import com.cloud.agent.api.RebootRouterCommand; import com.cloud.agent.api.SecurityGroupRulesCmd; import com.cloud.agent.api.StopCommand; +import com.cloud.agent.api.UnPlugNicCommand; import com.cloud.agent.api.UpgradeSnapshotCommand; import com.cloud.agent.api.check.CheckSshCommand; import com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand; @@ -130,6 +133,9 @@ private void init() { linbvirtCommands.put(CreateVolumeFromSnapshotCommand.class, new LibvirtCreateVolumeFromSnapshotCommandWrapper()); linbvirtCommands.put(FenceCommand.class, new LibvirtFenceCommandWrapper()); linbvirtCommands.put(SecurityGroupRulesCmd.class, new LibvirtSecurityGroupRulesCommandWrapper()); + linbvirtCommands.put(PlugNicCommand.class, new LibvirtPlugNicCommandWrapper()); + linbvirtCommands.put(UnPlugNicCommand.class, new LibvirtUnPlugNicCommandWrapper()); + linbvirtCommands.put(NetworkUsageCommand.class, new LibvirtNetworkUsageCommandWrapper()); resources.put(LibvirtComputingResource.class, linbvirtCommands); } diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUnPlugNicCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUnPlugNicCommandWrapper.java new file mode 100644 index 000000000000..4ce14f2c8240 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUnPlugNicCommandWrapper.java @@ -0,0 +1,80 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import java.util.List; + +import org.apache.log4j.Logger; +import org.libvirt.Connect; +import org.libvirt.Domain; +import org.libvirt.LibvirtException; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.UnPlugNicAnswer; +import com.cloud.agent.api.UnPlugNicCommand; +import com.cloud.agent.api.to.NicTO; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef; +import com.cloud.hypervisor.kvm.resource.VifDriver; +import com.cloud.resource.CommandWrapper; + +public final class LibvirtUnPlugNicCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtUnPlugNicCommandWrapper.class); + + @Override + public Answer execute(final UnPlugNicCommand command, final LibvirtComputingResource libvirtComputingResource) { + final NicTO nic = command.getNic(); + final String vmName = command.getVmName(); + Domain vm = null; + try { + final LibvirtConnectionWrapper libvirtConnectionWrapper = libvirtComputingResource.getLibvirtConnectionWrapper(); + + final Connect conn = libvirtConnectionWrapper.getConnectionByVmName(vmName); + vm = libvirtComputingResource.getDomain(conn, vmName); + final List pluggedNics = libvirtComputingResource.getInterfaces(conn, vmName); + + for (final InterfaceDef pluggedNic : pluggedNics) { + if (pluggedNic.getMacAddress().equalsIgnoreCase(nic.getMac())) { + vm.detachDevice(pluggedNic.toString()); + // We don't know which "traffic type" is associated with + // each interface at this point, so inform all vif drivers + for (final VifDriver vifDriver : libvirtComputingResource.getAllVifDrivers()) { + vifDriver.unplug(pluggedNic); + } + return new UnPlugNicAnswer(command, true, "success"); + } + } + return new UnPlugNicAnswer(command, true, "success"); + } catch (final LibvirtException e) { + final String msg = " Unplug Nic failed due to " + e.toString(); + s_logger.warn(msg, e); + return new UnPlugNicAnswer(command, false, msg); + } finally { + if (vm != null) { + try { + vm.free(); + } catch (final LibvirtException l) { + s_logger.trace("Ignoring libvirt error.", l); + } + } + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index 15ba52b251d7..9b0be08cb063 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -86,6 +86,7 @@ import com.cloud.agent.api.ModifyStoragePoolCommand; import com.cloud.agent.api.NetworkRulesSystemVmCommand; import com.cloud.agent.api.NetworkRulesVmSecondaryIpCommand; +import com.cloud.agent.api.NetworkUsageCommand; import com.cloud.agent.api.OvsCreateTunnelCommand; import com.cloud.agent.api.OvsDestroyBridgeCommand; import com.cloud.agent.api.OvsDestroyTunnelCommand; @@ -98,6 +99,7 @@ import com.cloud.agent.api.OvsVpcRoutingPolicyConfigCommand; import com.cloud.agent.api.OvsVpcRoutingPolicyConfigCommand.Acl; import com.cloud.agent.api.PingTestCommand; +import com.cloud.agent.api.PlugNicCommand; import com.cloud.agent.api.PrepareForMigrationCommand; import com.cloud.agent.api.ReadyCommand; import com.cloud.agent.api.RebootCommand; @@ -105,6 +107,7 @@ import com.cloud.agent.api.SecurityGroupRulesCmd; import com.cloud.agent.api.SecurityGroupRulesCmd.IpPortAndProto; import com.cloud.agent.api.StopCommand; +import com.cloud.agent.api.UnPlugNicCommand; import com.cloud.agent.api.UpgradeSnapshotCommand; import com.cloud.agent.api.VmStatsEntry; import com.cloud.agent.api.check.CheckSshCommand; @@ -2928,4 +2931,482 @@ public void testSecurityGroupRulesCmdException() { fail(e.getMessage()); } } + + @Test + public void testPlugNicCommandMatchMack() { + final NicTO nic = Mockito.mock(NicTO.class); + final String instanceName = "Test"; + final Type vmtype = Type.DomainRouter; + + final PlugNicCommand command = new PlugNicCommand(nic, instanceName, vmtype); + + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final Connect conn = Mockito.mock(Connect.class); + final Domain vm = Mockito.mock(Domain.class); + + final List nics = new ArrayList(); + final InterfaceDef intDef = Mockito.mock(InterfaceDef.class); + nics.add(intDef); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getInterfaces(conn, command.getVmName())).thenReturn(nics); + + when(intDef.getDevName()).thenReturn("eth0"); + when(intDef.getBrName()).thenReturn("br0"); + when(intDef.getMacAddress()).thenReturn("00:00:00:00"); + + when(nic.getMac()).thenReturn("00:00:00:00"); + + try { + when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenReturn(conn); + when(libvirtComputingResource.getDomain(conn, instanceName)).thenReturn(vm); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + verify(libvirtComputingResource, times(1)).getDomain(conn, instanceName); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + + @Test + public void testPlugNicCommandNoMatchMack() { + final NicTO nic = Mockito.mock(NicTO.class); + final String instanceName = "Test"; + final Type vmtype = Type.DomainRouter; + + final PlugNicCommand command = new PlugNicCommand(nic, instanceName, vmtype); + + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final Connect conn = Mockito.mock(Connect.class); + final Domain vm = Mockito.mock(Domain.class); + final VifDriver vifDriver = Mockito.mock(VifDriver.class); + final InterfaceDef interfaceDef = Mockito.mock(InterfaceDef.class); + + final List nics = new ArrayList(); + final InterfaceDef intDef = Mockito.mock(InterfaceDef.class); + nics.add(intDef); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getInterfaces(conn, command.getVmName())).thenReturn(nics); + + when(intDef.getDevName()).thenReturn("eth0"); + when(intDef.getBrName()).thenReturn("br0"); + when(intDef.getMacAddress()).thenReturn("00:00:00:00"); + + when(nic.getMac()).thenReturn("00:00:00:01"); + + try { + when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenReturn(conn); + when(libvirtComputingResource.getDomain(conn, instanceName)).thenReturn(vm); + + when(libvirtComputingResource.getVifDriver(nic.getType())).thenReturn(vifDriver); + + when(vifDriver.plug(nic, "Other PV", "")).thenReturn(interfaceDef); + when(interfaceDef.toString()).thenReturn("Interface"); + + final String interfaceDefStr = interfaceDef.toString(); + doNothing().when(vm).attachDevice(interfaceDefStr); + + } catch (final LibvirtException e) { + fail(e.getMessage()); + } catch (final InternalErrorException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + verify(libvirtComputingResource, times(1)).getDomain(conn, instanceName); + verify(libvirtComputingResource, times(1)).getVifDriver(nic.getType()); + verify(vifDriver, times(1)).plug(nic, "Other PV", ""); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } catch (final InternalErrorException e) { + fail(e.getMessage()); + } + } + + @SuppressWarnings("unchecked") + @Test + public void testPlugNicCommandLibvirtException() { + final NicTO nic = Mockito.mock(NicTO.class); + final String instanceName = "Test"; + final Type vmtype = Type.DomainRouter; + + final PlugNicCommand command = new PlugNicCommand(nic, instanceName, vmtype); + + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + + try { + when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenThrow(LibvirtException.class); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + + @SuppressWarnings("unchecked") + @Test + public void testPlugNicCommandInternalError() { + final NicTO nic = Mockito.mock(NicTO.class); + final String instanceName = "Test"; + final Type vmtype = Type.DomainRouter; + + final PlugNicCommand command = new PlugNicCommand(nic, instanceName, vmtype); + + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final Connect conn = Mockito.mock(Connect.class); + final Domain vm = Mockito.mock(Domain.class); + final VifDriver vifDriver = Mockito.mock(VifDriver.class); + + final List nics = new ArrayList(); + final InterfaceDef intDef = Mockito.mock(InterfaceDef.class); + nics.add(intDef); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getInterfaces(conn, command.getVmName())).thenReturn(nics); + + when(intDef.getDevName()).thenReturn("eth0"); + when(intDef.getBrName()).thenReturn("br0"); + when(intDef.getMacAddress()).thenReturn("00:00:00:00"); + + when(nic.getMac()).thenReturn("00:00:00:01"); + + try { + when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenReturn(conn); + when(libvirtComputingResource.getDomain(conn, instanceName)).thenReturn(vm); + + when(libvirtComputingResource.getVifDriver(nic.getType())).thenReturn(vifDriver); + + when(vifDriver.plug(nic, "Other PV", "")).thenThrow(InternalErrorException.class); + + } catch (final LibvirtException e) { + fail(e.getMessage()); + } catch (final InternalErrorException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + verify(libvirtComputingResource, times(1)).getDomain(conn, instanceName); + verify(libvirtComputingResource, times(1)).getVifDriver(nic.getType()); + verify(vifDriver, times(1)).plug(nic, "Other PV", ""); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } catch (final InternalErrorException e) { + fail(e.getMessage()); + } + } + + @Test + public void testUnPlugNicCommandMatchMack() { + final NicTO nic = Mockito.mock(NicTO.class); + final String instanceName = "Test"; + + final UnPlugNicCommand command = new UnPlugNicCommand(nic, instanceName); + + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final Connect conn = Mockito.mock(Connect.class); + final Domain vm = Mockito.mock(Domain.class); + final InterfaceDef interfaceDef = Mockito.mock(InterfaceDef.class); + + final List nics = new ArrayList(); + final InterfaceDef intDef = Mockito.mock(InterfaceDef.class); + nics.add(intDef); + + final VifDriver vifDriver = Mockito.mock(VifDriver.class); + final List drivers = new ArrayList(); + drivers.add(vifDriver); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getInterfaces(conn, command.getVmName())).thenReturn(nics); + + when(intDef.getDevName()).thenReturn("eth0"); + when(intDef.getBrName()).thenReturn("br0"); + when(intDef.getMacAddress()).thenReturn("00:00:00:00"); + + when(nic.getMac()).thenReturn("00:00:00:00"); + + try { + when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenReturn(conn); + when(libvirtComputingResource.getDomain(conn, instanceName)).thenReturn(vm); + + when(interfaceDef.toString()).thenReturn("Interface"); + + final String interfaceDefStr = interfaceDef.toString(); + doNothing().when(vm).detachDevice(interfaceDefStr); + + when(libvirtComputingResource.getAllVifDrivers()).thenReturn(drivers); + + doNothing().when(vifDriver).unplug(intDef); + + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + verify(libvirtComputingResource, times(1)).getDomain(conn, instanceName); + verify(libvirtComputingResource, times(1)).getAllVifDrivers(); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + + @Test + public void testUnPlugNicCommandNoNics() { + final NicTO nic = Mockito.mock(NicTO.class); + final String instanceName = "Test"; + + final UnPlugNicCommand command = new UnPlugNicCommand(nic, instanceName); + + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final Connect conn = Mockito.mock(Connect.class); + final Domain vm = Mockito.mock(Domain.class); + + final List nics = new ArrayList(); + + final VifDriver vifDriver = Mockito.mock(VifDriver.class); + final List drivers = new ArrayList(); + drivers.add(vifDriver); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getInterfaces(conn, command.getVmName())).thenReturn(nics); + + try { + when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenReturn(conn); + when(libvirtComputingResource.getDomain(conn, instanceName)).thenReturn(vm); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + verify(libvirtComputingResource, times(1)).getDomain(conn, instanceName); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + + @SuppressWarnings("unchecked") + @Test + public void testUnPlugNicCommandLibvirtException() { + final NicTO nic = Mockito.mock(NicTO.class); + final String instanceName = "Test"; + + final UnPlugNicCommand command = new UnPlugNicCommand(nic, instanceName); + + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + + try { + when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenThrow(LibvirtException.class); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + + @Test + public void testNetworkUsageCommandNonVpc() { + final String privateIP = "169.16.16.16"; + final String domRName = "domR"; + final boolean forVpc = false; + final String gatewayIP = "10.1.1.1"; + + final NetworkUsageCommand command = new NetworkUsageCommand(privateIP, domRName, forVpc, gatewayIP); + + libvirtComputingResource.getNetworkStats(command.getPrivateIP()); + + when(libvirtComputingResource.getNetworkStats(command.getPrivateIP())).thenReturn(new long[]{10l, 10l}); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + //Being called twice, although I did not find the second place yet. + verify(libvirtComputingResource, times(2)).getNetworkStats(command.getPrivateIP()); + } + + @Test + public void testNetworkUsageCommandNonVpcCreate() { + final String privateIP = "169.16.16.16"; + final String domRName = "domR"; + final boolean forVpc = false; + + final NetworkUsageCommand command = new NetworkUsageCommand(privateIP, domRName, "create", forVpc); + + libvirtComputingResource.getNetworkStats(command.getPrivateIP()); + + when(libvirtComputingResource.networkUsage(command.getPrivateIP(), "create", null)).thenReturn("SUCCESS"); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + //Being called twice, although I did not find the second place yet. + verify(libvirtComputingResource, times(1)).networkUsage(command.getPrivateIP(), "create", null); + } + + @Test + public void testNetworkUsageCommandVpcCreate() { + final String privateIP = "169.16.16.16"; + final String domRName = "domR"; + final boolean forVpc = true; + final String gatewayIP = "10.1.1.1"; + final String vpcCidr = "10.1.1.0/24"; + + final NetworkUsageCommand command = new NetworkUsageCommand(privateIP, domRName, forVpc, gatewayIP, vpcCidr); + + libvirtComputingResource.getNetworkStats(command.getPrivateIP()); + + when(libvirtComputingResource.configureVPCNetworkUsage(command.getPrivateIP(), command.getGatewayIP(), "create", command.getVpcCIDR())).thenReturn("SUCCESS"); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + //Being called twice, although I did not find the second place yet. + verify(libvirtComputingResource, times(1)).configureVPCNetworkUsage(command.getPrivateIP(), command.getGatewayIP(), "create", command.getVpcCIDR()); + } + + @Test + public void testNetworkUsageCommandVpcGet() { + final String privateIP = "169.16.16.16"; + final String domRName = "domR"; + final boolean forVpc = true; + final String gatewayIP = "10.1.1.1"; + + final NetworkUsageCommand command = new NetworkUsageCommand(privateIP, domRName, forVpc, gatewayIP); + + libvirtComputingResource.getNetworkStats(command.getPrivateIP()); + + when(libvirtComputingResource.getVPCNetworkStats(command.getPrivateIP(), command.getGatewayIP(), command.getOption())).thenReturn(new long[]{10l, 10l}); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + //Being called twice, although I did not find the second place yet. + verify(libvirtComputingResource, times(1)).getVPCNetworkStats(command.getPrivateIP(), command.getGatewayIP(), command.getOption()); + } + + @Test + public void testNetworkUsageCommandVpcVpn() { + final String privateIP = "169.16.16.16"; + final String domRName = "domR"; + final boolean forVpc = true; + final String gatewayIP = "10.1.1.1"; + + final NetworkUsageCommand command = new NetworkUsageCommand(privateIP, domRName, "vpn", forVpc, gatewayIP); + + libvirtComputingResource.getNetworkStats(command.getPrivateIP()); + + when(libvirtComputingResource.getVPCNetworkStats(command.getPrivateIP(), command.getGatewayIP(), command.getOption())).thenReturn(new long[]{10l, 10l}); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + //Being called twice, although I did not find the second place yet. + verify(libvirtComputingResource, times(1)).getVPCNetworkStats(command.getPrivateIP(), command.getGatewayIP(), command.getOption()); + } + + @Test + public void testNetworkUsageCommandVpcNoOption() { + final String privateIP = "169.16.16.16"; + final String domRName = "domR"; + final boolean forVpc = true; + final String gatewayIP = "10.1.1.1"; + + final NetworkUsageCommand command = new NetworkUsageCommand(privateIP, domRName, null, forVpc, gatewayIP); + + libvirtComputingResource.getNetworkStats(command.getPrivateIP()); + + when(libvirtComputingResource.configureVPCNetworkUsage(command.getPrivateIP(), command.getGatewayIP(), command.getOption(), command.getVpcCIDR())).thenReturn("FAILURE"); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + //Being called twice, although I did not find the second place yet. + verify(libvirtComputingResource, times(1)).configureVPCNetworkUsage(command.getPrivateIP(), command.getGatewayIP(), command.getOption(), command.getVpcCIDR()); + } } \ No newline at end of file From bcf78d3b4304800d9a60db72742fb169c470093b Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Tue, 5 May 2015 11:48:55 +0200 Subject: [PATCH 026/175] Refactoring the LibvirtComputingResource - Adding LibvirtBackupSnapshotCommandWrapper, LibvirtCreatePrivateTemplateFromVolumeCommandWrapper and LibvirtManageSnapshotCommandWrapper - 3 unit tests added - KVM hypervisor plugin with 18.3% coverage Less tests added to those classes because the code is quite complex and way too long. The tests added are just covering the new flow, to make sure it works fine. I will come back to those classes later. --- .../resource/LibvirtComputingResource.java | 402 +----------------- .../LibvirtBackupSnapshotCommandWrapper.java | 204 +++++++++ ...ivateTemplateFromVolumeCommandWrapper.java | 176 ++++++++ .../LibvirtManageSnapshotCommandWrapper.java | 163 +++++++ .../wrapper/LibvirtRequestWrapper.java | 6 + .../LibvirtComputingResourceTest.java | 137 +++++- 6 files changed, 699 insertions(+), 389 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtBackupSnapshotCommandWrapper.java create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreatePrivateTemplateFromVolumeCommandWrapper.java create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtManageSnapshotCommandWrapper.java diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 3c40c908071e..4e8b4cf0c813 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -16,26 +16,20 @@ // under the License. package com.cloud.hypervisor.kvm.resource; -import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; -import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.Reader; import java.net.InetAddress; import java.net.URI; import java.net.URISyntaxException; -import java.text.DateFormat; -import java.text.MessageFormat; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; import java.util.Collections; import java.util.Comparator; -import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -54,10 +48,7 @@ import org.apache.cloudstack.storage.command.StorageSubSystemCommand; import org.apache.cloudstack.storage.to.PrimaryDataStoreTO; import org.apache.cloudstack.storage.to.VolumeObjectTO; -import org.apache.cloudstack.utils.qemu.QemuImg; import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat; -import org.apache.cloudstack.utils.qemu.QemuImgException; -import org.apache.cloudstack.utils.qemu.QemuImgFile; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.log4j.Logger; @@ -67,26 +58,14 @@ import org.libvirt.DomainInfo; import org.libvirt.DomainInfo.DomainState; import org.libvirt.DomainInterfaceStats; -import org.libvirt.DomainSnapshot; import org.libvirt.LibvirtException; import org.libvirt.NodeInfo; import org.libvirt.StorageVol; -import com.ceph.rados.IoCTX; -import com.ceph.rados.Rados; -import com.ceph.rados.RadosException; -import com.ceph.rbd.Rbd; -import com.ceph.rbd.RbdException; -import com.ceph.rbd.RbdImage; import com.cloud.agent.api.Answer; -import com.cloud.agent.api.BackupSnapshotAnswer; -import com.cloud.agent.api.BackupSnapshotCommand; import com.cloud.agent.api.Command; import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand; -import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand; import com.cloud.agent.api.HostVmStateReportEntry; -import com.cloud.agent.api.ManageSnapshotAnswer; -import com.cloud.agent.api.ManageSnapshotCommand; import com.cloud.agent.api.PingCommand; import com.cloud.agent.api.PingRoutingCommand; import com.cloud.agent.api.PingRoutingWithNwGroupsCommand; @@ -156,7 +135,6 @@ import com.cloud.resource.ServerResourceBase; import com.cloud.storage.JavaStorageLayer; import com.cloud.storage.Storage; -import com.cloud.storage.Storage.ImageFormat; import com.cloud.storage.Storage.StoragePoolType; import com.cloud.storage.StorageLayer; import com.cloud.storage.Volume; @@ -234,7 +212,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv public static final String SSHPUBKEYPATH = SSHKEYSPATH + File.separator + "id_rsa.pub.cloud"; private String _mountPoint = "/mnt"; - StorageLayer _storage; + private StorageLayer _storage; private KVMStoragePoolManager _storagePoolMgr; private VifDriver _defaultVifDriver; @@ -276,9 +254,6 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv private final Map _pifs = new HashMap(); private final Map _vmStats = new ConcurrentHashMap(); - protected static final MessageFormat SnapshotXML = new MessageFormat(" " + " {0}" + " " - + " {1}" + " " + " "); - protected static final HashMap s_powerStatesTable; static { s_powerStatesTable = new HashMap(); @@ -414,6 +389,22 @@ public KVMHAMonitor getMonitor() { return _monitor; } + public StorageLayer getStorage() { + return _storage; + } + + public String createTmplPath() { + return _createTmplPath; + } + + public int getCmdsTimeout() { + return _cmdsTimeout; + } + + public String manageSnapshotPath() { + return _manageSnapshotPath; + } + private static final class KeyValueInterpreter extends OutputInterpreter { private final Map map = new HashMap(); @@ -1261,13 +1252,7 @@ public Answer executeRequest(final Command cmd) { } try { - if (cmd instanceof CreatePrivateTemplateFromVolumeCommand) { - return execute((CreatePrivateTemplateFromVolumeCommand)cmd); - } else if (cmd instanceof ManageSnapshotCommand) { - return execute((ManageSnapshotCommand)cmd); - } else if (cmd instanceof BackupSnapshotCommand) { - return execute((BackupSnapshotCommand)cmd); - } else if (cmd instanceof CreatePrivateTemplateFromSnapshotCommand) { + if (cmd instanceof CreatePrivateTemplateFromSnapshotCommand) { return execute((CreatePrivateTemplateFromSnapshotCommand)cmd); } else if (cmd instanceof StartCommand) { return execute((StartCommand)cmd); @@ -1899,248 +1884,6 @@ protected ExecutionResult cleanupNetworkElementCommand(final IpAssocCommand cmd) return new ExecutionResult(true, null); } - protected ManageSnapshotAnswer execute(final ManageSnapshotCommand cmd) { - final String snapshotName = cmd.getSnapshotName(); - final String snapshotPath = cmd.getSnapshotPath(); - final String vmName = cmd.getVmName(); - try { - final Connect conn = LibvirtConnection.getConnectionByVmName(vmName); - DomainState state = null; - Domain vm = null; - if (vmName != null) { - try { - vm = getDomain(conn, cmd.getVmName()); - state = vm.getInfo().state; - } catch (final LibvirtException e) { - s_logger.trace("Ignoring libvirt error.", e); - } - } - - final KVMStoragePool primaryPool = _storagePoolMgr.getStoragePool(cmd.getPool().getType(), cmd.getPool().getUuid()); - - final KVMPhysicalDisk disk = primaryPool.getPhysicalDisk(cmd.getVolumePath()); - if (state == DomainState.VIR_DOMAIN_RUNNING && !primaryPool.isExternalSnapshot()) { - final String vmUuid = vm.getUUIDString(); - final Object[] args = new Object[] {snapshotName, vmUuid}; - final String snapshot = SnapshotXML.format(args); - s_logger.debug(snapshot); - if (cmd.getCommandSwitch().equalsIgnoreCase(ManageSnapshotCommand.CREATE_SNAPSHOT)) { - vm.snapshotCreateXML(snapshot); - } else { - final DomainSnapshot snap = vm.snapshotLookupByName(snapshotName); - snap.delete(0); - } - - /* - * libvirt on RHEL6 doesn't handle resume event emitted from - * qemu - */ - vm = getDomain(conn, cmd.getVmName()); - state = vm.getInfo().state; - if (state == DomainState.VIR_DOMAIN_PAUSED) { - vm.resume(); - } - } else { - /** - * For RBD we can't use libvirt to do our snapshotting or any Bash scripts. - * libvirt also wants to store the memory contents of the Virtual Machine, - * but that's not possible with RBD since there is no way to store the memory - * contents in RBD. - * - * So we rely on the Java bindings for RBD to create our snapshot - * - * This snapshot might not be 100% consistent due to writes still being in the - * memory of the Virtual Machine, but if the VM runs a kernel which supports - * barriers properly (>2.6.32) this won't be any different then pulling the power - * cord out of a running machine. - */ - if (primaryPool.getType() == StoragePoolType.RBD) { - try { - final Rados r = new Rados(primaryPool.getAuthUserName()); - r.confSet("mon_host", primaryPool.getSourceHost() + ":" + primaryPool.getSourcePort()); - r.confSet("key", primaryPool.getAuthSecret()); - r.confSet("client_mount_timeout", "30"); - r.connect(); - s_logger.debug("Succesfully connected to Ceph cluster at " + r.confGet("mon_host")); - - final IoCTX io = r.ioCtxCreate(primaryPool.getSourceDir()); - final Rbd rbd = new Rbd(io); - final RbdImage image = rbd.open(disk.getName()); - - if (cmd.getCommandSwitch().equalsIgnoreCase(ManageSnapshotCommand.CREATE_SNAPSHOT)) { - s_logger.debug("Attempting to create RBD snapshot " + disk.getName() + "@" + snapshotName); - image.snapCreate(snapshotName); - } else { - s_logger.debug("Attempting to remove RBD snapshot " + disk.getName() + "@" + snapshotName); - image.snapRemove(snapshotName); - } - - rbd.close(image); - r.ioCtxDestroy(io); - } catch (final Exception e) { - s_logger.error("A RBD snapshot operation on " + disk.getName() + " failed. The error was: " + e.getMessage()); - } - } else { - /* VM is not running, create a snapshot by ourself */ - final Script command = new Script(_manageSnapshotPath, _cmdsTimeout, s_logger); - if (cmd.getCommandSwitch().equalsIgnoreCase(ManageSnapshotCommand.CREATE_SNAPSHOT)) { - command.add("-c", disk.getPath()); - } else { - command.add("-d", snapshotPath); - } - - command.add("-n", snapshotName); - final String result = command.execute(); - if (result != null) { - s_logger.debug("Failed to manage snapshot: " + result); - return new ManageSnapshotAnswer(cmd, false, "Failed to manage snapshot: " + result); - } - } - } - return new ManageSnapshotAnswer(cmd, cmd.getSnapshotId(), disk.getPath() + File.separator + snapshotName, true, null); - } catch (final LibvirtException e) { - s_logger.debug("Failed to manage snapshot: " + e.toString()); - return new ManageSnapshotAnswer(cmd, false, "Failed to manage snapshot: " + e.toString()); - } - - } - - protected BackupSnapshotAnswer execute(final BackupSnapshotCommand cmd) { - final Long dcId = cmd.getDataCenterId(); - final Long accountId = cmd.getAccountId(); - final Long volumeId = cmd.getVolumeId(); - final String secondaryStoragePoolUrl = cmd.getSecondaryStorageUrl(); - final String snapshotName = cmd.getSnapshotName(); - String snapshotDestPath = null; - String snapshotRelPath = null; - final String vmName = cmd.getVmName(); - KVMStoragePool secondaryStoragePool = null; - try { - final Connect conn = LibvirtConnection.getConnectionByVmName(vmName); - - secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(secondaryStoragePoolUrl); - - final String ssPmountPath = secondaryStoragePool.getLocalPath(); - snapshotRelPath = File.separator + "snapshots" + File.separator + dcId + File.separator + accountId + File.separator + volumeId; - - snapshotDestPath = ssPmountPath + File.separator + "snapshots" + File.separator + dcId + File.separator + accountId + File.separator + volumeId; - final KVMStoragePool primaryPool = _storagePoolMgr.getStoragePool(cmd.getPool().getType(), cmd.getPrimaryStoragePoolNameLabel()); - final KVMPhysicalDisk snapshotDisk = primaryPool.getPhysicalDisk(cmd.getVolumePath()); - - /** - * RBD snapshots can't be copied using qemu-img, so we have to use - * the Java bindings for librbd here. - * - * These bindings will read the snapshot and write the contents to - * the secondary storage directly - * - * It will stop doing so if the amount of time spend is longer then - * cmds.timeout - */ - if (primaryPool.getType() == StoragePoolType.RBD) { - try { - final Rados r = new Rados(primaryPool.getAuthUserName()); - r.confSet("mon_host", primaryPool.getSourceHost() + ":" + primaryPool.getSourcePort()); - r.confSet("key", primaryPool.getAuthSecret()); - r.confSet("client_mount_timeout", "30"); - r.connect(); - s_logger.debug("Succesfully connected to Ceph cluster at " + r.confGet("mon_host")); - - final IoCTX io = r.ioCtxCreate(primaryPool.getSourceDir()); - final Rbd rbd = new Rbd(io); - final RbdImage image = rbd.open(snapshotDisk.getName(), snapshotName); - final File fh = new File(snapshotDestPath); - try(BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(fh));) { - final int chunkSize = 4194304; - long offset = 0; - s_logger.debug("Backuping up RBD snapshot " + snapshotName + " to " + snapshotDestPath); - while (true) { - final byte[] buf = new byte[chunkSize]; - final int bytes = image.read(offset, buf, chunkSize); - if (bytes <= 0) { - break; - } - bos.write(buf, 0, bytes); - offset += bytes; - } - s_logger.debug("Completed backing up RBD snapshot " + snapshotName + " to " + snapshotDestPath + ". Bytes written: " + offset); - }catch(final IOException ex) - { - s_logger.error("BackupSnapshotAnswer:Exception:"+ ex.getMessage()); - } - r.ioCtxDestroy(io); - } catch (final RadosException e) { - s_logger.error("A RADOS operation failed. The error was: " + e.getMessage()); - return new BackupSnapshotAnswer(cmd, false, e.toString(), null, true); - } catch (final RbdException e) { - s_logger.error("A RBD operation on " + snapshotDisk.getName() + " failed. The error was: " + e.getMessage()); - return new BackupSnapshotAnswer(cmd, false, e.toString(), null, true); - } - } else { - final Script command = new Script(_manageSnapshotPath, _cmdsTimeout, s_logger); - command.add("-b", snapshotDisk.getPath()); - command.add("-n", snapshotName); - command.add("-p", snapshotDestPath); - command.add("-t", snapshotName); - final String result = command.execute(); - if (result != null) { - s_logger.debug("Failed to backup snaptshot: " + result); - return new BackupSnapshotAnswer(cmd, false, result, null, true); - } - } - /* Delete the snapshot on primary */ - - DomainState state = null; - Domain vm = null; - if (vmName != null) { - try { - vm = getDomain(conn, cmd.getVmName()); - state = vm.getInfo().state; - } catch (final LibvirtException e) { - s_logger.trace("Ignoring libvirt error.", e); - } - } - - final KVMStoragePool primaryStorage = _storagePoolMgr.getStoragePool(cmd.getPool().getType(), cmd.getPool().getUuid()); - if (state == DomainState.VIR_DOMAIN_RUNNING && !primaryStorage.isExternalSnapshot()) { - final String vmUuid = vm.getUUIDString(); - final Object[] args = new Object[] {snapshotName, vmUuid}; - final String snapshot = SnapshotXML.format(args); - s_logger.debug(snapshot); - final DomainSnapshot snap = vm.snapshotLookupByName(snapshotName); - snap.delete(0); - - /* - * libvirt on RHEL6 doesn't handle resume event emitted from - * qemu - */ - vm = getDomain(conn, cmd.getVmName()); - state = vm.getInfo().state; - if (state == DomainState.VIR_DOMAIN_PAUSED) { - vm.resume(); - } - } else { - final Script command = new Script(_manageSnapshotPath, _cmdsTimeout, s_logger); - command.add("-d", snapshotDisk.getPath()); - command.add("-n", snapshotName); - final String result = command.execute(); - if (result != null) { - s_logger.debug("Failed to backup snapshot: " + result); - return new BackupSnapshotAnswer(cmd, false, "Failed to backup snapshot: " + result, null, true); - } - } - } catch (final LibvirtException e) { - return new BackupSnapshotAnswer(cmd, false, e.toString(), null, true); - } catch (final CloudRuntimeException e) { - return new BackupSnapshotAnswer(cmd, false, e.toString(), null, true); - } finally { - if (secondaryStoragePool != null) { - _storagePoolMgr.deleteStoragePool(secondaryStoragePool.getType(), secondaryStoragePool.getUuid()); - } - } - return new BackupSnapshotAnswer(cmd, true, null, snapshotRelPath + File.separator + snapshotName, true); - } - protected CreatePrivateTemplateAnswer execute(final CreatePrivateTemplateFromSnapshotCommand cmd) { final String templateFolder = cmd.getAccountId() + File.separator + cmd.getNewTemplateId(); final String templateInstallFolder = "template/tmpl/" + templateFolder; @@ -2198,115 +1941,6 @@ protected CreatePrivateTemplateAnswer execute(final CreatePrivateTemplateFromSna } } - protected CreatePrivateTemplateAnswer execute(final CreatePrivateTemplateFromVolumeCommand cmd) { - final String secondaryStorageURL = cmd.getSecondaryStorageUrl(); - - KVMStoragePool secondaryStorage = null; - KVMStoragePool primary = null; - try { - final String templateFolder = cmd.getAccountId() + File.separator + cmd.getTemplateId() + File.separator; - final String templateInstallFolder = "/template/tmpl/" + templateFolder; - - secondaryStorage = _storagePoolMgr.getStoragePoolByURI(secondaryStorageURL); - - try { - primary = _storagePoolMgr.getStoragePool(cmd.getPool().getType(), cmd.getPrimaryStoragePoolNameLabel()); - } catch (final CloudRuntimeException e) { - if (e.getMessage().contains("not found")) { - primary = - _storagePoolMgr.createStoragePool(cmd.getPool().getUuid(), cmd.getPool().getHost(), cmd.getPool().getPort(), cmd.getPool().getPath(), - cmd.getPool().getUserInfo(), cmd.getPool().getType()); - } else { - return new CreatePrivateTemplateAnswer(cmd, false, e.getMessage()); - } - } - - final KVMPhysicalDisk disk = primary.getPhysicalDisk(cmd.getVolumePath()); - final String tmpltPath = secondaryStorage.getLocalPath() + File.separator + templateInstallFolder; - _storage.mkdirs(tmpltPath); - - if (primary.getType() != StoragePoolType.RBD) { - final Script command = new Script(_createTmplPath, _cmdsTimeout, s_logger); - command.add("-f", disk.getPath()); - command.add("-t", tmpltPath); - command.add("-n", cmd.getUniqueName() + ".qcow2"); - - final String result = command.execute(); - - if (result != null) { - s_logger.debug("failed to create template: " + result); - return new CreatePrivateTemplateAnswer(cmd, false, result); - } - } else { - s_logger.debug("Converting RBD disk " + disk.getPath() + " into template " + cmd.getUniqueName()); - - final QemuImgFile srcFile = - new QemuImgFile(KVMPhysicalDisk.RBDStringBuilder(primary.getSourceHost(), primary.getSourcePort(), primary.getAuthUserName(), - primary.getAuthSecret(), disk.getPath())); - srcFile.setFormat(PhysicalDiskFormat.RAW); - - final QemuImgFile destFile = new QemuImgFile(tmpltPath + "/" + cmd.getUniqueName() + ".qcow2"); - destFile.setFormat(PhysicalDiskFormat.QCOW2); - - final QemuImg q = new QemuImg(0); - try { - q.convert(srcFile, destFile); - } catch (final QemuImgException e) { - s_logger.error("Failed to create new template while converting " + srcFile.getFileName() + " to " + destFile.getFileName() + " the error was: " + - e.getMessage()); - } - - final File templateProp = new File(tmpltPath + "/template.properties"); - if (!templateProp.exists()) { - templateProp.createNewFile(); - } - - String templateContent = "filename=" + cmd.getUniqueName() + ".qcow2" + System.getProperty("line.separator"); - - final DateFormat dateFormat = new SimpleDateFormat("MM_dd_yyyy"); - final Date date = new Date(); - templateContent += "snapshot.name=" + dateFormat.format(date) + System.getProperty("line.separator"); - - try(FileOutputStream templFo = new FileOutputStream(templateProp);) { - templFo.write(templateContent.getBytes()); - templFo.flush(); - }catch(final IOException ex) - { - s_logger.error("CreatePrivateTemplateAnswer:Exception:"+ex.getMessage()); - } - - } - - final Map params = new HashMap(); - params.put(StorageLayer.InstanceConfigKey, _storage); - final Processor qcow2Processor = new QCOW2Processor(); - - qcow2Processor.configure("QCOW2 Processor", params); - - final FormatInfo info = qcow2Processor.process(tmpltPath, null, cmd.getUniqueName()); - - final TemplateLocation loc = new TemplateLocation(_storage, tmpltPath); - loc.create(1, true, cmd.getUniqueName()); - loc.addFormat(info); - loc.save(); - - return new CreatePrivateTemplateAnswer(cmd, true, null, templateInstallFolder + cmd.getUniqueName() + ".qcow2", info.virtualSize, info.size, - cmd.getUniqueName(), ImageFormat.QCOW2); - } catch (final InternalErrorException e) { - return new CreatePrivateTemplateAnswer(cmd, false, e.toString()); - } catch (final IOException e) { - return new CreatePrivateTemplateAnswer(cmd, false, e.toString()); - } catch (final ConfigurationException e) { - return new CreatePrivateTemplateAnswer(cmd, false, e.toString()); - } catch (final CloudRuntimeException e) { - return new CreatePrivateTemplateAnswer(cmd, false, e.toString()); - } finally { - if (secondaryStorage != null) { - _storagePoolMgr.deleteStoragePool(secondaryStorage.getType(), secondaryStorage.getUuid()); - } - } - } - protected PowerState convertToPowerState(final DomainState ps) { final PowerState state = s_powerStatesTable.get(ps); return state == null ? PowerState.PowerUnknown : state; diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtBackupSnapshotCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtBackupSnapshotCommandWrapper.java new file mode 100644 index 000000000000..afbbf73e0fbd --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtBackupSnapshotCommandWrapper.java @@ -0,0 +1,204 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.MessageFormat; + +import org.apache.log4j.Logger; +import org.libvirt.Connect; +import org.libvirt.Domain; +import org.libvirt.DomainInfo.DomainState; +import org.libvirt.DomainSnapshot; +import org.libvirt.LibvirtException; + +import com.ceph.rados.IoCTX; +import com.ceph.rados.Rados; +import com.ceph.rados.RadosException; +import com.ceph.rbd.Rbd; +import com.ceph.rbd.RbdException; +import com.ceph.rbd.RbdImage; +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.BackupSnapshotAnswer; +import com.cloud.agent.api.BackupSnapshotCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk; +import com.cloud.hypervisor.kvm.storage.KVMStoragePool; +import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; +import com.cloud.resource.CommandWrapper; +import com.cloud.storage.Storage.StoragePoolType; +import com.cloud.utils.exception.CloudRuntimeException; +import com.cloud.utils.script.Script; + +public final class LibvirtBackupSnapshotCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtBackupSnapshotCommandWrapper.class); + + @Override + public Answer execute(final BackupSnapshotCommand command, final LibvirtComputingResource libvirtComputingResource) { + final Long dcId = command.getDataCenterId(); + final Long accountId = command.getAccountId(); + final Long volumeId = command.getVolumeId(); + final String secondaryStoragePoolUrl = command.getSecondaryStorageUrl(); + final String snapshotName = command.getSnapshotName(); + String snapshotDestPath = null; + String snapshotRelPath = null; + final String vmName = command.getVmName(); + KVMStoragePool secondaryStoragePool = null; + final KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr(); + + try { + final LibvirtConnectionWrapper libvirtConnectionWrapper = libvirtComputingResource.getLibvirtConnectionWrapper(); + final Connect conn = libvirtConnectionWrapper.getConnectionByVmName(vmName); + + secondaryStoragePool = storagePoolMgr.getStoragePoolByURI(secondaryStoragePoolUrl); + + final String ssPmountPath = secondaryStoragePool.getLocalPath(); + snapshotRelPath = File.separator + "snapshots" + File.separator + dcId + File.separator + accountId + File.separator + volumeId; + + snapshotDestPath = ssPmountPath + File.separator + "snapshots" + File.separator + dcId + File.separator + accountId + File.separator + volumeId; + final KVMStoragePool primaryPool = storagePoolMgr.getStoragePool(command.getPool().getType(), command.getPrimaryStoragePoolNameLabel()); + final KVMPhysicalDisk snapshotDisk = primaryPool.getPhysicalDisk(command.getVolumePath()); + + final String manageSnapshotPath = libvirtComputingResource.manageSnapshotPath(); + final int cmdsTimeout = libvirtComputingResource.getCmdsTimeout(); + + /** + * RBD snapshots can't be copied using qemu-img, so we have to use + * the Java bindings for librbd here. + * + * These bindings will read the snapshot and write the contents to + * the secondary storage directly + * + * It will stop doing so if the amount of time spend is longer then + * cmds.timeout + */ + if (primaryPool.getType() == StoragePoolType.RBD) { + try { + final Rados r = new Rados(primaryPool.getAuthUserName()); + r.confSet("mon_host", primaryPool.getSourceHost() + ":" + primaryPool.getSourcePort()); + r.confSet("key", primaryPool.getAuthSecret()); + r.confSet("client_mount_timeout", "30"); + r.connect(); + s_logger.debug("Succesfully connected to Ceph cluster at " + r.confGet("mon_host")); + + final IoCTX io = r.ioCtxCreate(primaryPool.getSourceDir()); + final Rbd rbd = new Rbd(io); + final RbdImage image = rbd.open(snapshotDisk.getName(), snapshotName); + final File fh = new File(snapshotDestPath); + try(BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(fh));) { + final int chunkSize = 4194304; + long offset = 0; + s_logger.debug("Backuping up RBD snapshot " + snapshotName + " to " + snapshotDestPath); + while (true) { + final byte[] buf = new byte[chunkSize]; + final int bytes = image.read(offset, buf, chunkSize); + if (bytes <= 0) { + break; + } + bos.write(buf, 0, bytes); + offset += bytes; + } + s_logger.debug("Completed backing up RBD snapshot " + snapshotName + " to " + snapshotDestPath + ". Bytes written: " + offset); + }catch(final IOException ex) + { + s_logger.error("BackupSnapshotAnswer:Exception:"+ ex.getMessage()); + } + r.ioCtxDestroy(io); + } catch (final RadosException e) { + s_logger.error("A RADOS operation failed. The error was: " + e.getMessage()); + return new BackupSnapshotAnswer(command, false, e.toString(), null, true); + } catch (final RbdException e) { + s_logger.error("A RBD operation on " + snapshotDisk.getName() + " failed. The error was: " + e.getMessage()); + return new BackupSnapshotAnswer(command, false, e.toString(), null, true); + } + } else { + final Script scriptCommand = new Script(manageSnapshotPath, cmdsTimeout, s_logger); + scriptCommand.add("-b", snapshotDisk.getPath()); + scriptCommand.add("-n", snapshotName); + scriptCommand.add("-p", snapshotDestPath); + scriptCommand.add("-t", snapshotName); + final String result = scriptCommand.execute(); + + if (result != null) { + s_logger.debug("Failed to backup snaptshot: " + result); + return new BackupSnapshotAnswer(command, false, result, null, true); + } + } + /* Delete the snapshot on primary */ + + DomainState state = null; + Domain vm = null; + if (vmName != null) { + try { + vm = libvirtComputingResource.getDomain(conn, command.getVmName()); + state = vm.getInfo().state; + } catch (final LibvirtException e) { + s_logger.trace("Ignoring libvirt error.", e); + } + } + + final KVMStoragePool primaryStorage = storagePoolMgr.getStoragePool(command.getPool().getType(), command.getPool().getUuid()); + + if (state == DomainState.VIR_DOMAIN_RUNNING && !primaryStorage.isExternalSnapshot()) { + final MessageFormat snapshotXML = new MessageFormat(" " + " {0}" + " " + + " {1}" + " " + " "); + + final String vmUuid = vm.getUUIDString(); + final Object[] args = new Object[] {snapshotName, vmUuid}; + final String snapshot = snapshotXML.format(args); + s_logger.debug(snapshot); + final DomainSnapshot snap = vm.snapshotLookupByName(snapshotName); + snap.delete(0); + + /* + * libvirt on RHEL6 doesn't handle resume event emitted from + * qemu + */ + vm = libvirtComputingResource.getDomain(conn, command.getVmName()); + state = vm.getInfo().state; + if (state == DomainState.VIR_DOMAIN_PAUSED) { + vm.resume(); + } + } else { + final Script scriptCommand = new Script(manageSnapshotPath, cmdsTimeout, s_logger); + scriptCommand.add("-d", snapshotDisk.getPath()); + scriptCommand.add("-n", snapshotName); + final String result = scriptCommand.execute(); + if (result != null) { + s_logger.debug("Failed to backup snapshot: " + result); + return new BackupSnapshotAnswer(command, false, "Failed to backup snapshot: " + result, null, true); + } + } + } catch (final LibvirtException e) { + return new BackupSnapshotAnswer(command, false, e.toString(), null, true); + } catch (final CloudRuntimeException e) { + return new BackupSnapshotAnswer(command, false, e.toString(), null, true); + } finally { + if (secondaryStoragePool != null) { + storagePoolMgr.deleteStoragePool(secondaryStoragePool.getType(), secondaryStoragePool.getUuid()); + } + } + return new BackupSnapshotAnswer(command, true, null, snapshotRelPath + File.separator + snapshotName, true); + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreatePrivateTemplateFromVolumeCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreatePrivateTemplateFromVolumeCommandWrapper.java new file mode 100644 index 000000000000..f3bfe1ffd19e --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreatePrivateTemplateFromVolumeCommandWrapper.java @@ -0,0 +1,176 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +import javax.naming.ConfigurationException; + +import org.apache.cloudstack.utils.qemu.QemuImg; +import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat; +import org.apache.cloudstack.utils.qemu.QemuImgException; +import org.apache.cloudstack.utils.qemu.QemuImgFile; +import org.apache.log4j.Logger; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand; +import com.cloud.agent.api.storage.CreatePrivateTemplateAnswer; +import com.cloud.exception.InternalErrorException; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk; +import com.cloud.hypervisor.kvm.storage.KVMStoragePool; +import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; +import com.cloud.resource.CommandWrapper; +import com.cloud.storage.Storage.ImageFormat; +import com.cloud.storage.Storage.StoragePoolType; +import com.cloud.storage.StorageLayer; +import com.cloud.storage.template.Processor; +import com.cloud.storage.template.Processor.FormatInfo; +import com.cloud.storage.template.QCOW2Processor; +import com.cloud.storage.template.TemplateLocation; +import com.cloud.utils.exception.CloudRuntimeException; +import com.cloud.utils.script.Script; + +public final class LibvirtCreatePrivateTemplateFromVolumeCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtCreatePrivateTemplateFromVolumeCommandWrapper.class); + + @Override + public Answer execute(final CreatePrivateTemplateFromVolumeCommand command, final LibvirtComputingResource libvirtComputingResource) { + final String secondaryStorageURL = command.getSecondaryStorageUrl(); + + KVMStoragePool secondaryStorage = null; + KVMStoragePool primary = null; + final KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr(); + try { + final String templateFolder = command.getAccountId() + File.separator + command.getTemplateId() + File.separator; + final String templateInstallFolder = "/template/tmpl/" + templateFolder; + + secondaryStorage = storagePoolMgr.getStoragePoolByURI(secondaryStorageURL); + + try { + primary = storagePoolMgr.getStoragePool(command.getPool().getType(), command.getPrimaryStoragePoolNameLabel()); + } catch (final CloudRuntimeException e) { + if (e.getMessage().contains("not found")) { + primary = + storagePoolMgr.createStoragePool(command.getPool().getUuid(), command.getPool().getHost(), command.getPool().getPort(), command.getPool().getPath(), + command.getPool().getUserInfo(), command.getPool().getType()); + } else { + return new CreatePrivateTemplateAnswer(command, false, e.getMessage()); + } + } + + final KVMPhysicalDisk disk = primary.getPhysicalDisk(command.getVolumePath()); + final String tmpltPath = secondaryStorage.getLocalPath() + File.separator + templateInstallFolder; + final StorageLayer storage = libvirtComputingResource.getStorage(); + storage.mkdirs(tmpltPath); + + if (primary.getType() != StoragePoolType.RBD) { + final String createTmplPath = libvirtComputingResource.createTmplPath(); + final int cmdsTimeout = libvirtComputingResource.getCmdsTimeout(); + + final Script scriptCommand = new Script(createTmplPath, cmdsTimeout, s_logger); + scriptCommand.add("-f", disk.getPath()); + scriptCommand.add("-t", tmpltPath); + scriptCommand.add("-n", command.getUniqueName() + ".qcow2"); + + final String result = scriptCommand.execute(); + + if (result != null) { + s_logger.debug("failed to create template: " + result); + return new CreatePrivateTemplateAnswer(command, false, result); + } + } else { + s_logger.debug("Converting RBD disk " + disk.getPath() + " into template " + command.getUniqueName()); + + final QemuImgFile srcFile = + new QemuImgFile(KVMPhysicalDisk.RBDStringBuilder(primary.getSourceHost(), primary.getSourcePort(), primary.getAuthUserName(), + primary.getAuthSecret(), disk.getPath())); + srcFile.setFormat(PhysicalDiskFormat.RAW); + + final QemuImgFile destFile = new QemuImgFile(tmpltPath + "/" + command.getUniqueName() + ".qcow2"); + destFile.setFormat(PhysicalDiskFormat.QCOW2); + + final QemuImg q = new QemuImg(0); + try { + q.convert(srcFile, destFile); + } catch (final QemuImgException e) { + s_logger.error("Failed to create new template while converting " + srcFile.getFileName() + " to " + destFile.getFileName() + " the error was: " + + e.getMessage()); + } + + final File templateProp = new File(tmpltPath + "/template.properties"); + if (!templateProp.exists()) { + templateProp.createNewFile(); + } + + String templateContent = "filename=" + command.getUniqueName() + ".qcow2" + System.getProperty("line.separator"); + + final DateFormat dateFormat = new SimpleDateFormat("MM_dd_yyyy"); + final Date date = new Date(); + templateContent += "snapshot.name=" + dateFormat.format(date) + System.getProperty("line.separator"); + + try(FileOutputStream templFo = new FileOutputStream(templateProp);) { + templFo.write(templateContent.getBytes()); + templFo.flush(); + }catch(final IOException ex) + { + s_logger.error("CreatePrivateTemplateAnswer:Exception:"+ex.getMessage()); + } + + } + + final Map params = new HashMap(); + params.put(StorageLayer.InstanceConfigKey, storage); + final Processor qcow2Processor = new QCOW2Processor(); + + qcow2Processor.configure("QCOW2 Processor", params); + + final FormatInfo info = qcow2Processor.process(tmpltPath, null, command.getUniqueName()); + + final TemplateLocation loc = new TemplateLocation(storage, tmpltPath); + loc.create(1, true, command.getUniqueName()); + loc.addFormat(info); + loc.save(); + + return new CreatePrivateTemplateAnswer(command, true, null, templateInstallFolder + command.getUniqueName() + ".qcow2", info.virtualSize, info.size, + command.getUniqueName(), ImageFormat.QCOW2); + } catch (final InternalErrorException e) { + return new CreatePrivateTemplateAnswer(command, false, e.toString()); + } catch (final IOException e) { + return new CreatePrivateTemplateAnswer(command, false, e.toString()); + } catch (final ConfigurationException e) { + return new CreatePrivateTemplateAnswer(command, false, e.toString()); + } catch (final CloudRuntimeException e) { + return new CreatePrivateTemplateAnswer(command, false, e.toString()); + } finally { + if (secondaryStorage != null) { + storagePoolMgr.deleteStoragePool(secondaryStorage.getType(), secondaryStorage.getUuid()); + } + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtManageSnapshotCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtManageSnapshotCommandWrapper.java new file mode 100644 index 000000000000..9a991a15e61d --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtManageSnapshotCommandWrapper.java @@ -0,0 +1,163 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import java.io.File; +import java.text.MessageFormat; + +import org.apache.log4j.Logger; +import org.libvirt.Connect; +import org.libvirt.Domain; +import org.libvirt.DomainInfo.DomainState; +import org.libvirt.DomainSnapshot; +import org.libvirt.LibvirtException; + +import com.ceph.rados.IoCTX; +import com.ceph.rados.Rados; +import com.ceph.rbd.Rbd; +import com.ceph.rbd.RbdImage; +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.ManageSnapshotAnswer; +import com.cloud.agent.api.ManageSnapshotCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk; +import com.cloud.hypervisor.kvm.storage.KVMStoragePool; +import com.cloud.resource.CommandWrapper; +import com.cloud.storage.Storage.StoragePoolType; +import com.cloud.utils.script.Script; + +public final class LibvirtManageSnapshotCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtManageSnapshotCommandWrapper.class); + + @Override + public Answer execute(final ManageSnapshotCommand command, final LibvirtComputingResource libvirtComputingResource) { + final String snapshotName = command.getSnapshotName(); + final String snapshotPath = command.getSnapshotPath(); + final String vmName = command.getVmName(); + try { + final LibvirtConnectionWrapper libvirtConnectionWrapper = libvirtComputingResource.getLibvirtConnectionWrapper(); + final Connect conn = libvirtConnectionWrapper.getConnectionByVmName(vmName); + DomainState state = null; + Domain vm = null; + if (vmName != null) { + try { + vm = libvirtComputingResource.getDomain(conn, command.getVmName()); + state = vm.getInfo().state; + } catch (final LibvirtException e) { + s_logger.trace("Ignoring libvirt error.", e); + } + } + + final KVMStoragePool primaryPool = libvirtComputingResource.getStoragePoolMgr().getStoragePool(command.getPool().getType(), command.getPool().getUuid()); + + final KVMPhysicalDisk disk = primaryPool.getPhysicalDisk(command.getVolumePath()); + if (state == DomainState.VIR_DOMAIN_RUNNING && !primaryPool.isExternalSnapshot()) { + + final MessageFormat snapshotXML = new MessageFormat(" " + " {0}" + " " + + " {1}" + " " + " "); + + final String vmUuid = vm.getUUIDString(); + final Object[] args = new Object[] {snapshotName, vmUuid}; + final String snapshot = snapshotXML.format(args); + s_logger.debug(snapshot); + if (command.getCommandSwitch().equalsIgnoreCase(ManageSnapshotCommand.CREATE_SNAPSHOT)) { + vm.snapshotCreateXML(snapshot); + } else { + final DomainSnapshot snap = vm.snapshotLookupByName(snapshotName); + snap.delete(0); + } + + /* + * libvirt on RHEL6 doesn't handle resume event emitted from + * qemu + */ + vm = libvirtComputingResource.getDomain(conn, command.getVmName()); + state = vm.getInfo().state; + if (state == DomainState.VIR_DOMAIN_PAUSED) { + vm.resume(); + } + } else { + /** + * For RBD we can't use libvirt to do our snapshotting or any Bash scripts. + * libvirt also wants to store the memory contents of the Virtual Machine, + * but that's not possible with RBD since there is no way to store the memory + * contents in RBD. + * + * So we rely on the Java bindings for RBD to create our snapshot + * + * This snapshot might not be 100% consistent due to writes still being in the + * memory of the Virtual Machine, but if the VM runs a kernel which supports + * barriers properly (>2.6.32) this won't be any different then pulling the power + * cord out of a running machine. + */ + if (primaryPool.getType() == StoragePoolType.RBD) { + try { + final Rados r = new Rados(primaryPool.getAuthUserName()); + r.confSet("mon_host", primaryPool.getSourceHost() + ":" + primaryPool.getSourcePort()); + r.confSet("key", primaryPool.getAuthSecret()); + r.confSet("client_mount_timeout", "30"); + r.connect(); + s_logger.debug("Succesfully connected to Ceph cluster at " + r.confGet("mon_host")); + + final IoCTX io = r.ioCtxCreate(primaryPool.getSourceDir()); + final Rbd rbd = new Rbd(io); + final RbdImage image = rbd.open(disk.getName()); + + if (command.getCommandSwitch().equalsIgnoreCase(ManageSnapshotCommand.CREATE_SNAPSHOT)) { + s_logger.debug("Attempting to create RBD snapshot " + disk.getName() + "@" + snapshotName); + image.snapCreate(snapshotName); + } else { + s_logger.debug("Attempting to remove RBD snapshot " + disk.getName() + "@" + snapshotName); + image.snapRemove(snapshotName); + } + + rbd.close(image); + r.ioCtxDestroy(io); + } catch (final Exception e) { + s_logger.error("A RBD snapshot operation on " + disk.getName() + " failed. The error was: " + e.getMessage()); + } + } else { + /* VM is not running, create a snapshot by ourself */ + final int cmdsTimeout = libvirtComputingResource.getCmdsTimeout(); + final String manageSnapshotPath = libvirtComputingResource.manageSnapshotPath(); + + final Script scriptCommand = new Script(manageSnapshotPath, cmdsTimeout, s_logger); + if (command.getCommandSwitch().equalsIgnoreCase(ManageSnapshotCommand.CREATE_SNAPSHOT)) { + scriptCommand.add("-c", disk.getPath()); + } else { + scriptCommand.add("-d", snapshotPath); + } + + scriptCommand.add("-n", snapshotName); + final String result = scriptCommand.execute(); + if (result != null) { + s_logger.debug("Failed to manage snapshot: " + result); + return new ManageSnapshotAnswer(command, false, "Failed to manage snapshot: " + result); + } + } + } + return new ManageSnapshotAnswer(command, command.getSnapshotId(), disk.getPath() + File.separator + snapshotName, true, null); + } catch (final LibvirtException e) { + s_logger.debug("Failed to manage snapshot: " + e.toString()); + return new ManageSnapshotAnswer(command, false, "Failed to manage snapshot: " + e.toString()); + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java index 148075b8575a..2656037f4560 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java @@ -23,12 +23,14 @@ import com.cloud.agent.api.Answer; import com.cloud.agent.api.AttachIsoCommand; import com.cloud.agent.api.AttachVolumeCommand; +import com.cloud.agent.api.BackupSnapshotCommand; import com.cloud.agent.api.CheckHealthCommand; import com.cloud.agent.api.CheckNetworkCommand; import com.cloud.agent.api.CheckOnHostCommand; import com.cloud.agent.api.CheckVirtualMachineCommand; import com.cloud.agent.api.CleanupNetworkRulesCmd; import com.cloud.agent.api.Command; +import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand; import com.cloud.agent.api.CreateStoragePoolCommand; import com.cloud.agent.api.CreateVolumeFromSnapshotCommand; import com.cloud.agent.api.DeleteStoragePoolCommand; @@ -39,6 +41,7 @@ import com.cloud.agent.api.GetVmStatsCommand; import com.cloud.agent.api.GetVncPortCommand; import com.cloud.agent.api.MaintainCommand; +import com.cloud.agent.api.ManageSnapshotCommand; import com.cloud.agent.api.MigrateCommand; import com.cloud.agent.api.ModifySshKeysCommand; import com.cloud.agent.api.ModifyStoragePoolCommand; @@ -136,6 +139,9 @@ private void init() { linbvirtCommands.put(PlugNicCommand.class, new LibvirtPlugNicCommandWrapper()); linbvirtCommands.put(UnPlugNicCommand.class, new LibvirtUnPlugNicCommandWrapper()); linbvirtCommands.put(NetworkUsageCommand.class, new LibvirtNetworkUsageCommandWrapper()); + linbvirtCommands.put(CreatePrivateTemplateFromVolumeCommand.class, new LibvirtCreatePrivateTemplateFromVolumeCommandWrapper()); + linbvirtCommands.put(ManageSnapshotCommand.class, new LibvirtManageSnapshotCommandWrapper()); + linbvirtCommands.put(BackupSnapshotCommand.class, new LibvirtBackupSnapshotCommandWrapper()); resources.put(LibvirtComputingResource.class, linbvirtCommands); } diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index 9b0be08cb063..b0c273404b78 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -66,11 +66,13 @@ import com.cloud.agent.api.Answer; import com.cloud.agent.api.AttachIsoCommand; import com.cloud.agent.api.AttachVolumeCommand; +import com.cloud.agent.api.BackupSnapshotCommand; import com.cloud.agent.api.CheckHealthCommand; import com.cloud.agent.api.CheckNetworkCommand; import com.cloud.agent.api.CheckOnHostCommand; import com.cloud.agent.api.CheckVirtualMachineCommand; import com.cloud.agent.api.CleanupNetworkRulesCmd; +import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand; import com.cloud.agent.api.CreateStoragePoolCommand; import com.cloud.agent.api.CreateVolumeFromSnapshotCommand; import com.cloud.agent.api.DeleteStoragePoolCommand; @@ -81,6 +83,7 @@ import com.cloud.agent.api.GetVmStatsCommand; import com.cloud.agent.api.GetVncPortCommand; import com.cloud.agent.api.MaintainCommand; +import com.cloud.agent.api.ManageSnapshotCommand; import com.cloud.agent.api.MigrateCommand; import com.cloud.agent.api.ModifySshKeysCommand; import com.cloud.agent.api.ModifyStoragePoolCommand; @@ -3313,7 +3316,6 @@ public void testNetworkUsageCommandNonVpcCreate() { final Answer answer = wrapper.execute(command, libvirtComputingResource); assertTrue(answer.getResult()); - //Being called twice, although I did not find the second place yet. verify(libvirtComputingResource, times(1)).networkUsage(command.getPrivateIP(), "create", null); } @@ -3337,7 +3339,6 @@ public void testNetworkUsageCommandVpcCreate() { final Answer answer = wrapper.execute(command, libvirtComputingResource); assertTrue(answer.getResult()); - //Being called twice, although I did not find the second place yet. verify(libvirtComputingResource, times(1)).configureVPCNetworkUsage(command.getPrivateIP(), command.getGatewayIP(), "create", command.getVpcCIDR()); } @@ -3360,7 +3361,6 @@ public void testNetworkUsageCommandVpcGet() { final Answer answer = wrapper.execute(command, libvirtComputingResource); assertTrue(answer.getResult()); - //Being called twice, although I did not find the second place yet. verify(libvirtComputingResource, times(1)).getVPCNetworkStats(command.getPrivateIP(), command.getGatewayIP(), command.getOption()); } @@ -3383,7 +3383,6 @@ public void testNetworkUsageCommandVpcVpn() { final Answer answer = wrapper.execute(command, libvirtComputingResource); assertTrue(answer.getResult()); - //Being called twice, although I did not find the second place yet. verify(libvirtComputingResource, times(1)).getVPCNetworkStats(command.getPrivateIP(), command.getGatewayIP(), command.getOption()); } @@ -3406,7 +3405,135 @@ public void testNetworkUsageCommandVpcNoOption() { final Answer answer = wrapper.execute(command, libvirtComputingResource); assertTrue(answer.getResult()); - //Being called twice, although I did not find the second place yet. verify(libvirtComputingResource, times(1)).configureVPCNetworkUsage(command.getPrivateIP(), command.getGatewayIP(), command.getOption(), command.getVpcCIDR()); } + + @SuppressWarnings("unchecked") + @Test + public void testCreatePrivateTemplateFromVolumeCommand() { + //Simple test used to make sure the flow (LibvirtComputingResource => Request => CommandWrapper) is working. + //The code is way to big and complex. Will finish the refactor and come back to this to add more cases. + + final StoragePool pool = Mockito.mock(StoragePool.class);; + final String secondaryStorageUrl = "nfs:/192.168.2.2/storage/secondary"; + final long templateId = 1l; + final long accountId = 1l; + final String userSpecifiedName = "User"; + final String uniqueName = "Unique"; + final String volumePath = "/123/vol"; + final String vmName = "Test"; + final int wait = 0; + + final CreatePrivateTemplateFromVolumeCommand command = new CreatePrivateTemplateFromVolumeCommand(pool, secondaryStorageUrl, templateId, accountId, userSpecifiedName, uniqueName, volumePath, vmName, wait); + + final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class); + final KVMStoragePool secondaryStorage = Mockito.mock(KVMStoragePool.class); + //final KVMStoragePool primary = Mockito.mock(KVMStoragePool.class); + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr); + when(storagePoolMgr.getStoragePoolByURI(secondaryStorageUrl)).thenReturn(secondaryStorage); + when(storagePoolMgr.getStoragePool(command.getPool().getType(), command.getPrimaryStoragePoolNameLabel())).thenThrow(new CloudRuntimeException("error")); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + verify(storagePoolMgr, times(1)).getStoragePoolByURI(secondaryStorageUrl); + verify(storagePoolMgr, times(1)).getStoragePool(command.getPool().getType(), command.getPrimaryStoragePoolNameLabel()); + } + + @SuppressWarnings("unchecked") + @Test + public void testManageSnapshotCommandLibvirtException() { + //Simple test used to make sure the flow (LibvirtComputingResource => Request => CommandWrapper) is working. + //The code is way to big and complex. Will finish the refactor and come back to this to add more cases. + + final StoragePool pool = Mockito.mock(StoragePool.class);; + final String volumePath = "/123/vol"; + final String vmName = "Test"; + + final long snapshotId = 1l; + final String preSnapshotPath = "/snapshot/path"; + final String snapshotName = "snap"; + + final ManageSnapshotCommand command = new ManageSnapshotCommand(snapshotId, volumePath, pool, preSnapshotPath, snapshotName, vmName); + + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + //final Connect conn = Mockito.mock(Connect.class); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + + try { + when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenThrow(LibvirtException.class); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + + @SuppressWarnings("unchecked") + @Test + public void testBackupSnapshotCommandLibvirtException() { + //Simple test used to make sure the flow (LibvirtComputingResource => Request => CommandWrapper) is working. + //The code is way to big and complex. Will finish the refactor and come back to this to add more cases. + + final StoragePool pool = Mockito.mock(StoragePool.class);; + final String secondaryStorageUrl = "nfs:/192.168.2.2/storage/secondary"; + final long accountId = 1l; + final String volumePath = "/123/vol"; + final String vmName = "Test"; + final int wait = 0; + + final long snapshotId = 1l; + final String snapshotName = "snap"; + + final Long dcId = 1l; + final Long volumeId = 1l; + final Long secHostId = 1l; + final String snapshotUuid = "9a0afe7c-26a7-4585-bf87-abf82ae106d9"; + final String prevBackupUuid = "003a0cc2-2e04-417a-bee0-534ef1724561"; + final boolean isVolumeInactive = false; + final String prevSnapshotUuid = "1791efae-f22d-474b-87c6-92547d6c5877"; + + final BackupSnapshotCommand command = new BackupSnapshotCommand(secondaryStorageUrl, dcId, accountId, volumeId, snapshotId, secHostId, volumePath, pool, snapshotUuid, snapshotName, prevSnapshotUuid, prevBackupUuid, isVolumeInactive, vmName, wait); + + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + //final Connect conn = Mockito.mock(Connect.class); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + + try { + when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenThrow(LibvirtException.class); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + try { + verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } } \ No newline at end of file From b3913ca1fbd3b400961608a4434cd7619cf1606d Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Tue, 5 May 2015 12:53:10 +0200 Subject: [PATCH 027/175] Refactoring the LibvirtComputingResource - Adding LibvirtCreatePrivateTemplateFromSnapshotCommandWrapper - 5 unit tests added - KVM hypervisor plugin with 19.5% coverage --- .../resource/LibvirtComputingResource.java | 67 +--- .../wrapper/LibvirtConnectionWrapper.java | 33 +- ...ateTemplateFromSnapshotCommandWrapper.java | 113 ++++++ .../wrapper/LibvirtRequestWrapper.java | 2 + .../LibvirtComputingResourceTest.java | 354 ++++++++++++++++++ 5 files changed, 502 insertions(+), 67 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreatePrivateTemplateFromSnapshotCommandWrapper.java diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 4e8b4cf0c813..977288b2c862 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -64,7 +64,6 @@ import com.cloud.agent.api.Answer; import com.cloud.agent.api.Command; -import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand; import com.cloud.agent.api.HostVmStateReportEntry; import com.cloud.agent.api.PingCommand; import com.cloud.agent.api.PingRoutingCommand; @@ -84,7 +83,6 @@ import com.cloud.agent.api.routing.SetSourceNatCommand; import com.cloud.agent.api.storage.CopyVolumeAnswer; import com.cloud.agent.api.storage.CopyVolumeCommand; -import com.cloud.agent.api.storage.CreatePrivateTemplateAnswer; import com.cloud.agent.api.storage.ResizeVolumeAnswer; import com.cloud.agent.api.storage.ResizeVolumeCommand; import com.cloud.agent.api.to.DataStoreTO; @@ -140,10 +138,6 @@ import com.cloud.storage.Volume; import com.cloud.storage.resource.StorageSubsystemCommandHandler; import com.cloud.storage.resource.StorageSubsystemCommandHandlerBase; -import com.cloud.storage.template.Processor; -import com.cloud.storage.template.Processor.FormatInfo; -import com.cloud.storage.template.QCOW2Processor; -import com.cloud.storage.template.TemplateLocation; import com.cloud.utils.ExecutionResult; import com.cloud.utils.NumbersUtil; import com.cloud.utils.Pair; @@ -1252,9 +1246,7 @@ public Answer executeRequest(final Command cmd) { } try { - if (cmd instanceof CreatePrivateTemplateFromSnapshotCommand) { - return execute((CreatePrivateTemplateFromSnapshotCommand)cmd); - } else if (cmd instanceof StartCommand) { + if (cmd instanceof StartCommand) { return execute((StartCommand)cmd); } else if (cmd instanceof NetworkElementCommand) { return _virtRouterResource.executeRequest((NetworkElementCommand)cmd); @@ -1884,63 +1876,6 @@ protected ExecutionResult cleanupNetworkElementCommand(final IpAssocCommand cmd) return new ExecutionResult(true, null); } - protected CreatePrivateTemplateAnswer execute(final CreatePrivateTemplateFromSnapshotCommand cmd) { - final String templateFolder = cmd.getAccountId() + File.separator + cmd.getNewTemplateId(); - final String templateInstallFolder = "template/tmpl/" + templateFolder; - final String tmplName = UUID.randomUUID().toString(); - final String tmplFileName = tmplName + ".qcow2"; - KVMStoragePool secondaryPool = null; - KVMStoragePool snapshotPool = null; - try { - String snapshotPath = cmd.getSnapshotUuid(); - final int index = snapshotPath.lastIndexOf("/"); - snapshotPath = snapshotPath.substring(0, index); - snapshotPool = _storagePoolMgr.getStoragePoolByURI(cmd.getSecondaryStorageUrl() + snapshotPath); - final KVMPhysicalDisk snapshot = snapshotPool.getPhysicalDisk(cmd.getSnapshotName()); - - secondaryPool = _storagePoolMgr.getStoragePoolByURI(cmd.getSecondaryStorageUrl()); - - final String templatePath = secondaryPool.getLocalPath() + File.separator + templateInstallFolder; - - _storage.mkdirs(templatePath); - - final String tmplPath = templateInstallFolder + File.separator + tmplFileName; - final Script command = new Script(_createTmplPath, _cmdsTimeout, s_logger); - command.add("-t", templatePath); - command.add("-n", tmplFileName); - command.add("-f", snapshot.getPath()); - command.execute(); - - final Map params = new HashMap(); - params.put(StorageLayer.InstanceConfigKey, _storage); - final Processor qcow2Processor = new QCOW2Processor(); - qcow2Processor.configure("QCOW2 Processor", params); - final FormatInfo info = qcow2Processor.process(templatePath, null, tmplName); - - final TemplateLocation loc = new TemplateLocation(_storage, templatePath); - loc.create(1, true, tmplName); - loc.addFormat(info); - loc.save(); - - return new CreatePrivateTemplateAnswer(cmd, true, "", tmplPath, info.virtualSize, info.size, tmplName, info.format); - } catch (final ConfigurationException e) { - return new CreatePrivateTemplateAnswer(cmd, false, e.getMessage()); - } catch (final InternalErrorException e) { - return new CreatePrivateTemplateAnswer(cmd, false, e.getMessage()); - } catch (final IOException e) { - return new CreatePrivateTemplateAnswer(cmd, false, e.getMessage()); - } catch (final CloudRuntimeException e) { - return new CreatePrivateTemplateAnswer(cmd, false, e.getMessage()); - } finally { - if (secondaryPool != null) { - _storagePoolMgr.deleteStoragePool(secondaryPool.getType(), secondaryPool.getUuid()); - } - if (snapshotPool != null) { - _storagePoolMgr.deleteStoragePool(snapshotPool.getType(), snapshotPool.getUuid()); - } - } - } - protected PowerState convertToPowerState(final DomainState ps) { final PowerState state = s_powerStatesTable.get(ps); return state == null ? PowerState.PowerUnknown : state; diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConnectionWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConnectionWrapper.java index e6743ace118c..3a51a37e376d 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConnectionWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConnectionWrapper.java @@ -16,13 +16,25 @@ // under the License. package com.cloud.hypervisor.kvm.resource.wrapper; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import javax.naming.ConfigurationException; + import org.libvirt.Connect; import org.libvirt.LibvirtException; import com.cloud.hypervisor.kvm.resource.LibvirtConnection; +import com.cloud.storage.StorageLayer; +import com.cloud.storage.template.Processor; +import com.cloud.storage.template.QCOW2Processor; +import com.cloud.storage.template.TemplateLocation; /** - * This class is used to wrap the calls to LibvirtConnection and ease the burden of the unit tests. + * This class is used to wrap the calls to several static methods. By doing so, we make easier to mock this class + * and the methods wrapped here. + * * Please do not instantiate this class directly, but inject it using the {@code @Inject} annotation. */ public class LibvirtConnectionWrapper { @@ -34,4 +46,23 @@ public Connect getConnectionByVmName(final String vmName) throws LibvirtExceptio public Connect getConnection() throws LibvirtException { return LibvirtConnection.getConnection(); } + + public TemplateLocation buildTemplateLocation(final StorageLayer storage, final String templatePath) { + final TemplateLocation location = new TemplateLocation(storage, templatePath); + return location; + } + + public Processor buildQCOW2Processor(final StorageLayer storage) throws ConfigurationException { + final Map params = new HashMap(); + params.put(StorageLayer.InstanceConfigKey, storage); + + final Processor qcow2Processor = new QCOW2Processor(); + qcow2Processor.configure("QCOW2 Processor", params); + + return qcow2Processor; + } + + public String buildTemplateUUIDName() { + return UUID.randomUUID().toString(); + } } \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreatePrivateTemplateFromSnapshotCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreatePrivateTemplateFromSnapshotCommandWrapper.java new file mode 100644 index 000000000000..20bebad81d40 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreatePrivateTemplateFromSnapshotCommandWrapper.java @@ -0,0 +1,113 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import java.io.File; +import java.io.IOException; + +import javax.naming.ConfigurationException; + +import org.apache.log4j.Logger; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand; +import com.cloud.agent.api.storage.CreatePrivateTemplateAnswer; +import com.cloud.exception.InternalErrorException; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk; +import com.cloud.hypervisor.kvm.storage.KVMStoragePool; +import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; +import com.cloud.resource.CommandWrapper; +import com.cloud.storage.StorageLayer; +import com.cloud.storage.template.Processor; +import com.cloud.storage.template.Processor.FormatInfo; +import com.cloud.storage.template.TemplateLocation; +import com.cloud.utils.exception.CloudRuntimeException; +import com.cloud.utils.script.Script; + +public final class LibvirtCreatePrivateTemplateFromSnapshotCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtCreatePrivateTemplateFromSnapshotCommandWrapper.class); + + @Override + public Answer execute(final CreatePrivateTemplateFromSnapshotCommand command, final LibvirtComputingResource libvirtComputingResource) { + final LibvirtConnectionWrapper libvirtConnectionWrapper = libvirtComputingResource.getLibvirtConnectionWrapper(); + + final String templateFolder = command.getAccountId() + File.separator + command.getNewTemplateId(); + final String templateInstallFolder = "template/tmpl/" + templateFolder; + final String tmplName = libvirtConnectionWrapper.buildTemplateUUIDName(); + final String tmplFileName = tmplName + ".qcow2"; + + KVMStoragePool secondaryPool = null; + KVMStoragePool snapshotPool = null; + final KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr(); + + try { + String snapshotPath = command.getSnapshotUuid(); + final int index = snapshotPath.lastIndexOf("/"); + snapshotPath = snapshotPath.substring(0, index); + + snapshotPool = storagePoolMgr.getStoragePoolByURI(command.getSecondaryStorageUrl() + snapshotPath); + secondaryPool = storagePoolMgr.getStoragePoolByURI(command.getSecondaryStorageUrl()); + + final KVMPhysicalDisk snapshot = snapshotPool.getPhysicalDisk(command.getSnapshotName()); + + final String templatePath = secondaryPool.getLocalPath() + File.separator + templateInstallFolder; + + final StorageLayer storage = libvirtComputingResource.getStorage(); + storage.mkdirs(templatePath); + + final String tmplPath = templateInstallFolder + File.separator + tmplFileName; + final String createTmplPath = libvirtComputingResource.createTmplPath(); + final int cmdsTimeout = libvirtComputingResource.getCmdsTimeout(); + + final Script scriptCommand = new Script(createTmplPath, cmdsTimeout, s_logger); + scriptCommand.add("-t", templatePath); + scriptCommand.add("-n", tmplFileName); + scriptCommand.add("-f", snapshot.getPath()); + scriptCommand.execute(); + + final Processor qcow2Processor = libvirtConnectionWrapper.buildQCOW2Processor(storage); + final FormatInfo info = qcow2Processor.process(templatePath, null, tmplName); + final TemplateLocation loc = libvirtConnectionWrapper.buildTemplateLocation(storage, templatePath); + + loc.create(1, true, tmplName); + loc.addFormat(info); + loc.save(); + + return new CreatePrivateTemplateAnswer(command, true, "", tmplPath, info.virtualSize, info.size, tmplName, info.format); + } catch (final ConfigurationException e) { + return new CreatePrivateTemplateAnswer(command, false, e.getMessage()); + } catch (final InternalErrorException e) { + return new CreatePrivateTemplateAnswer(command, false, e.getMessage()); + } catch (final IOException e) { + return new CreatePrivateTemplateAnswer(command, false, e.getMessage()); + } catch (final CloudRuntimeException e) { + return new CreatePrivateTemplateAnswer(command, false, e.getMessage()); + } finally { + if (secondaryPool != null) { + storagePoolMgr.deleteStoragePool(secondaryPool.getType(), secondaryPool.getUuid()); + } + if (snapshotPool != null) { + storagePoolMgr.deleteStoragePool(snapshotPool.getType(), snapshotPool.getUuid()); + } + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java index 2656037f4560..7e732640c504 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java @@ -30,6 +30,7 @@ import com.cloud.agent.api.CheckVirtualMachineCommand; import com.cloud.agent.api.CleanupNetworkRulesCmd; import com.cloud.agent.api.Command; +import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand; import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand; import com.cloud.agent.api.CreateStoragePoolCommand; import com.cloud.agent.api.CreateVolumeFromSnapshotCommand; @@ -142,6 +143,7 @@ private void init() { linbvirtCommands.put(CreatePrivateTemplateFromVolumeCommand.class, new LibvirtCreatePrivateTemplateFromVolumeCommandWrapper()); linbvirtCommands.put(ManageSnapshotCommand.class, new LibvirtManageSnapshotCommandWrapper()); linbvirtCommands.put(BackupSnapshotCommand.class, new LibvirtBackupSnapshotCommandWrapper()); + linbvirtCommands.put(CreatePrivateTemplateFromSnapshotCommand.class, new LibvirtCreatePrivateTemplateFromSnapshotCommandWrapper()); resources.put(LibvirtComputingResource.class, linbvirtCommands); } diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index b0c273404b78..5f9c50ad0120 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -29,6 +29,7 @@ import static org.mockito.Mockito.when; import java.io.ByteArrayInputStream; +import java.io.File; import java.io.IOException; import java.net.URISyntaxException; import java.util.ArrayList; @@ -37,6 +38,7 @@ import java.util.Random; import java.util.UUID; +import javax.naming.ConfigurationException; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.xpath.XPathConstants; @@ -72,6 +74,7 @@ import com.cloud.agent.api.CheckOnHostCommand; import com.cloud.agent.api.CheckVirtualMachineCommand; import com.cloud.agent.api.CleanupNetworkRulesCmd; +import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand; import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand; import com.cloud.agent.api.CreateStoragePoolCommand; import com.cloud.agent.api.CreateVolumeFromSnapshotCommand; @@ -139,8 +142,12 @@ import com.cloud.network.PhysicalNetworkSetupInfo; import com.cloud.storage.Storage.ImageFormat; import com.cloud.storage.Storage.StoragePoolType; +import com.cloud.storage.StorageLayer; import com.cloud.storage.StoragePool; import com.cloud.storage.Volume; +import com.cloud.storage.template.Processor; +import com.cloud.storage.template.Processor.FormatInfo; +import com.cloud.storage.template.TemplateLocation; import com.cloud.template.VirtualMachineTemplate.BootloaderType; import com.cloud.utils.Pair; import com.cloud.utils.exception.CloudRuntimeException; @@ -3536,4 +3543,351 @@ public void testBackupSnapshotCommandLibvirtException() { fail(e.getMessage()); } } + + @Test + public void testCreatePrivateTemplateFromSnapshotCommand() { + final StoragePool pool = Mockito.mock(StoragePool.class); + final String secondaryStoragePoolURL = "nfs:/192.168.2.2/storage/secondary"; + final Long dcId = 1l; + final Long accountId = 1l; + final Long volumeId = 1l; + final String backedUpSnapshotUuid = "/run/9a0afe7c-26a7-4585-bf87-abf82ae106d9/"; + final String backedUpSnapshotName = "snap"; + final String origTemplateInstallPath = "/install/path/"; + final Long newTemplateId = 2l; + final String templateName = "templ"; + final int wait = 0; + + final CreatePrivateTemplateFromSnapshotCommand command = new CreatePrivateTemplateFromSnapshotCommand(pool, secondaryStoragePoolURL, dcId, accountId, volumeId, backedUpSnapshotUuid, backedUpSnapshotName, origTemplateInstallPath, newTemplateId, templateName, wait); + + final String templatePath = "/template/path"; + final String localPath = "/mnt/local"; + final String tmplName = "ce97bbc1-34fe-4259-9202-74bbce2562ab"; + + final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class); + final KVMStoragePool secondaryPool = Mockito.mock(KVMStoragePool.class); + final KVMStoragePool snapshotPool = Mockito.mock(KVMStoragePool.class); + final KVMPhysicalDisk snapshot = Mockito.mock(KVMPhysicalDisk.class); + final StorageLayer storage = Mockito.mock(StorageLayer.class); + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final TemplateLocation location = Mockito.mock(TemplateLocation.class); + final Processor qcow2Processor = Mockito.mock(Processor.class); + final FormatInfo info = Mockito.mock(FormatInfo.class); + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr); + + String snapshotPath = command.getSnapshotUuid(); + final int index = snapshotPath.lastIndexOf("/"); + snapshotPath = snapshotPath.substring(0, index); + + when(storagePoolMgr.getStoragePoolByURI(command.getSecondaryStorageUrl() + snapshotPath)).thenReturn(snapshotPool); + when(storagePoolMgr.getStoragePoolByURI(command.getSecondaryStorageUrl())).thenReturn(secondaryPool); + when(snapshotPool.getPhysicalDisk(command.getSnapshotName())).thenReturn(snapshot); + when(secondaryPool.getLocalPath()).thenReturn(localPath); + when(libvirtComputingResource.getStorage()).thenReturn(storage); + + when(libvirtComputingResource.createTmplPath()).thenReturn(templatePath); + when(libvirtComputingResource.getCmdsTimeout()).thenReturn(1); + + final String templateFolder = command.getAccountId() + File.separator + command.getNewTemplateId(); + final String templateInstallFolder = "template/tmpl/" + templateFolder; + final String tmplPath = secondaryPool.getLocalPath() + File.separator + templateInstallFolder; + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtConnectionWrapper.buildTemplateLocation(storage, tmplPath)).thenReturn(location); + when(libvirtConnectionWrapper.buildTemplateUUIDName()).thenReturn(tmplName); + + try { + when(libvirtConnectionWrapper.buildQCOW2Processor(storage)).thenReturn(qcow2Processor); + when(qcow2Processor.process(tmplPath, null, tmplName)).thenReturn(info); + } catch (final ConfigurationException e) { + fail(e.getMessage()); + } catch (final InternalErrorException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + verify(storagePoolMgr, times(1)).getStoragePoolByURI(command.getSecondaryStorageUrl() + snapshotPath); + verify(storagePoolMgr, times(1)).getStoragePoolByURI(command.getSecondaryStorageUrl()); + } + + @SuppressWarnings("unchecked") + @Test + public void testCreatePrivateTemplateFromSnapshotCommandConfigurationException() { + final StoragePool pool = Mockito.mock(StoragePool.class); + final String secondaryStoragePoolURL = "nfs:/192.168.2.2/storage/secondary"; + final Long dcId = 1l; + final Long accountId = 1l; + final Long volumeId = 1l; + final String backedUpSnapshotUuid = "/run/9a0afe7c-26a7-4585-bf87-abf82ae106d9/"; + final String backedUpSnapshotName = "snap"; + final String origTemplateInstallPath = "/install/path/"; + final Long newTemplateId = 2l; + final String templateName = "templ"; + final int wait = 0; + + final CreatePrivateTemplateFromSnapshotCommand command = new CreatePrivateTemplateFromSnapshotCommand(pool, secondaryStoragePoolURL, dcId, accountId, volumeId, backedUpSnapshotUuid, backedUpSnapshotName, origTemplateInstallPath, newTemplateId, templateName, wait); + + final String templatePath = "/template/path"; + final String localPath = "/mnt/local"; + final String tmplName = "ce97bbc1-34fe-4259-9202-74bbce2562ab"; + + final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class); + final KVMStoragePool secondaryPool = Mockito.mock(KVMStoragePool.class); + final KVMStoragePool snapshotPool = Mockito.mock(KVMStoragePool.class); + final KVMPhysicalDisk snapshot = Mockito.mock(KVMPhysicalDisk.class); + final StorageLayer storage = Mockito.mock(StorageLayer.class); + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final TemplateLocation location = Mockito.mock(TemplateLocation.class); + final Processor qcow2Processor = Mockito.mock(Processor.class); + final FormatInfo info = Mockito.mock(FormatInfo.class); + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr); + + String snapshotPath = command.getSnapshotUuid(); + final int index = snapshotPath.lastIndexOf("/"); + snapshotPath = snapshotPath.substring(0, index); + + when(storagePoolMgr.getStoragePoolByURI(command.getSecondaryStorageUrl() + snapshotPath)).thenReturn(snapshotPool); + when(storagePoolMgr.getStoragePoolByURI(command.getSecondaryStorageUrl())).thenReturn(secondaryPool); + when(snapshotPool.getPhysicalDisk(command.getSnapshotName())).thenReturn(snapshot); + when(secondaryPool.getLocalPath()).thenReturn(localPath); + when(libvirtComputingResource.getStorage()).thenReturn(storage); + + when(libvirtComputingResource.createTmplPath()).thenReturn(templatePath); + when(libvirtComputingResource.getCmdsTimeout()).thenReturn(1); + + final String templateFolder = command.getAccountId() + File.separator + command.getNewTemplateId(); + final String templateInstallFolder = "template/tmpl/" + templateFolder; + final String tmplPath = secondaryPool.getLocalPath() + File.separator + templateInstallFolder; + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtConnectionWrapper.buildTemplateLocation(storage, tmplPath)).thenReturn(location); + when(libvirtConnectionWrapper.buildTemplateUUIDName()).thenReturn(tmplName); + + try { + when(libvirtConnectionWrapper.buildQCOW2Processor(storage)).thenThrow(ConfigurationException.class); + when(qcow2Processor.process(tmplPath, null, tmplName)).thenReturn(info); + } catch (final ConfigurationException e) { + fail(e.getMessage()); + } catch (final InternalErrorException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + verify(storagePoolMgr, times(1)).getStoragePoolByURI(command.getSecondaryStorageUrl() + snapshotPath); + verify(storagePoolMgr, times(1)).getStoragePoolByURI(command.getSecondaryStorageUrl()); + } + + @SuppressWarnings("unchecked") + @Test + public void testCreatePrivateTemplateFromSnapshotCommandInternalErrorException() { + final StoragePool pool = Mockito.mock(StoragePool.class); + final String secondaryStoragePoolURL = "nfs:/192.168.2.2/storage/secondary"; + final Long dcId = 1l; + final Long accountId = 1l; + final Long volumeId = 1l; + final String backedUpSnapshotUuid = "/run/9a0afe7c-26a7-4585-bf87-abf82ae106d9/"; + final String backedUpSnapshotName = "snap"; + final String origTemplateInstallPath = "/install/path/"; + final Long newTemplateId = 2l; + final String templateName = "templ"; + final int wait = 0; + + final CreatePrivateTemplateFromSnapshotCommand command = new CreatePrivateTemplateFromSnapshotCommand(pool, secondaryStoragePoolURL, dcId, accountId, volumeId, backedUpSnapshotUuid, backedUpSnapshotName, origTemplateInstallPath, newTemplateId, templateName, wait); + + final String templatePath = "/template/path"; + final String localPath = "/mnt/local"; + final String tmplName = "ce97bbc1-34fe-4259-9202-74bbce2562ab"; + + final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class); + final KVMStoragePool secondaryPool = Mockito.mock(KVMStoragePool.class); + final KVMStoragePool snapshotPool = Mockito.mock(KVMStoragePool.class); + final KVMPhysicalDisk snapshot = Mockito.mock(KVMPhysicalDisk.class); + final StorageLayer storage = Mockito.mock(StorageLayer.class); + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final TemplateLocation location = Mockito.mock(TemplateLocation.class); + final Processor qcow2Processor = Mockito.mock(Processor.class); + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr); + + String snapshotPath = command.getSnapshotUuid(); + final int index = snapshotPath.lastIndexOf("/"); + snapshotPath = snapshotPath.substring(0, index); + + when(storagePoolMgr.getStoragePoolByURI(command.getSecondaryStorageUrl() + snapshotPath)).thenReturn(snapshotPool); + when(storagePoolMgr.getStoragePoolByURI(command.getSecondaryStorageUrl())).thenReturn(secondaryPool); + when(snapshotPool.getPhysicalDisk(command.getSnapshotName())).thenReturn(snapshot); + when(secondaryPool.getLocalPath()).thenReturn(localPath); + when(libvirtComputingResource.getStorage()).thenReturn(storage); + + when(libvirtComputingResource.createTmplPath()).thenReturn(templatePath); + when(libvirtComputingResource.getCmdsTimeout()).thenReturn(1); + + final String templateFolder = command.getAccountId() + File.separator + command.getNewTemplateId(); + final String templateInstallFolder = "template/tmpl/" + templateFolder; + final String tmplPath = secondaryPool.getLocalPath() + File.separator + templateInstallFolder; + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtConnectionWrapper.buildTemplateLocation(storage, tmplPath)).thenReturn(location); + when(libvirtConnectionWrapper.buildTemplateUUIDName()).thenReturn(tmplName); + + try { + when(libvirtConnectionWrapper.buildQCOW2Processor(storage)).thenReturn(qcow2Processor); + when(qcow2Processor.process(tmplPath, null, tmplName)).thenThrow(InternalErrorException.class); + } catch (final ConfigurationException e) { + fail(e.getMessage()); + } catch (final InternalErrorException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + verify(storagePoolMgr, times(1)).getStoragePoolByURI(command.getSecondaryStorageUrl() + snapshotPath); + verify(storagePoolMgr, times(1)).getStoragePoolByURI(command.getSecondaryStorageUrl()); + } + + @SuppressWarnings("unchecked") + @Test + public void testCreatePrivateTemplateFromSnapshotCommandIOException() { + final StoragePool pool = Mockito.mock(StoragePool.class); + final String secondaryStoragePoolURL = "nfs:/192.168.2.2/storage/secondary"; + final Long dcId = 1l; + final Long accountId = 1l; + final Long volumeId = 1l; + final String backedUpSnapshotUuid = "/run/9a0afe7c-26a7-4585-bf87-abf82ae106d9/"; + final String backedUpSnapshotName = "snap"; + final String origTemplateInstallPath = "/install/path/"; + final Long newTemplateId = 2l; + final String templateName = "templ"; + final int wait = 0; + + final CreatePrivateTemplateFromSnapshotCommand command = new CreatePrivateTemplateFromSnapshotCommand(pool, secondaryStoragePoolURL, dcId, accountId, volumeId, backedUpSnapshotUuid, backedUpSnapshotName, origTemplateInstallPath, newTemplateId, templateName, wait); + + final String templatePath = "/template/path"; + final String localPath = "/mnt/local"; + final String tmplName = "ce97bbc1-34fe-4259-9202-74bbce2562ab"; + + final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class); + final KVMStoragePool secondaryPool = Mockito.mock(KVMStoragePool.class); + final KVMStoragePool snapshotPool = Mockito.mock(KVMStoragePool.class); + final KVMPhysicalDisk snapshot = Mockito.mock(KVMPhysicalDisk.class); + final StorageLayer storage = Mockito.mock(StorageLayer.class); + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final TemplateLocation location = Mockito.mock(TemplateLocation.class); + final Processor qcow2Processor = Mockito.mock(Processor.class); + final FormatInfo info = Mockito.mock(FormatInfo.class); + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr); + + String snapshotPath = command.getSnapshotUuid(); + final int index = snapshotPath.lastIndexOf("/"); + snapshotPath = snapshotPath.substring(0, index); + + when(storagePoolMgr.getStoragePoolByURI(command.getSecondaryStorageUrl() + snapshotPath)).thenReturn(snapshotPool); + when(storagePoolMgr.getStoragePoolByURI(command.getSecondaryStorageUrl())).thenReturn(secondaryPool); + when(snapshotPool.getPhysicalDisk(command.getSnapshotName())).thenReturn(snapshot); + when(secondaryPool.getLocalPath()).thenReturn(localPath); + when(libvirtComputingResource.getStorage()).thenReturn(storage); + + when(libvirtComputingResource.createTmplPath()).thenReturn(templatePath); + when(libvirtComputingResource.getCmdsTimeout()).thenReturn(1); + + final String templateFolder = command.getAccountId() + File.separator + command.getNewTemplateId(); + final String templateInstallFolder = "template/tmpl/" + templateFolder; + final String tmplPath = secondaryPool.getLocalPath() + File.separator + templateInstallFolder; + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtConnectionWrapper.buildTemplateLocation(storage, tmplPath)).thenReturn(location); + when(libvirtConnectionWrapper.buildTemplateUUIDName()).thenReturn(tmplName); + + try { + when(libvirtConnectionWrapper.buildQCOW2Processor(storage)).thenReturn(qcow2Processor); + when(qcow2Processor.process(tmplPath, null, tmplName)).thenReturn(info); + + when(location.create(1, true, tmplName)).thenThrow(IOException.class); + + } catch (final ConfigurationException e) { + fail(e.getMessage()); + } catch (final InternalErrorException e) { + fail(e.getMessage()); + } catch (final IOException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + verify(storagePoolMgr, times(1)).getStoragePoolByURI(command.getSecondaryStorageUrl() + snapshotPath); + verify(storagePoolMgr, times(1)).getStoragePoolByURI(command.getSecondaryStorageUrl()); + } + + @SuppressWarnings("unchecked") + @Test + public void testCreatePrivateTemplateFromSnapshotCommandCloudRuntime() { + final StoragePool pool = Mockito.mock(StoragePool.class); + final String secondaryStoragePoolURL = "nfs:/192.168.2.2/storage/secondary"; + final Long dcId = 1l; + final Long accountId = 1l; + final Long volumeId = 1l; + final String backedUpSnapshotUuid = "/run/9a0afe7c-26a7-4585-bf87-abf82ae106d9/"; + final String backedUpSnapshotName = "snap"; + final String origTemplateInstallPath = "/install/path/"; + final Long newTemplateId = 2l; + final String templateName = "templ"; + final int wait = 0; + + final CreatePrivateTemplateFromSnapshotCommand command = new CreatePrivateTemplateFromSnapshotCommand(pool, secondaryStoragePoolURL, dcId, accountId, volumeId, backedUpSnapshotUuid, backedUpSnapshotName, origTemplateInstallPath, newTemplateId, templateName, wait); + + final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class); + final KVMStoragePool secondaryPool = Mockito.mock(KVMStoragePool.class); + final KVMStoragePool snapshotPool = Mockito.mock(KVMStoragePool.class); + final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + + final String tmplName = "ce97bbc1-34fe-4259-9202-74bbce2562ab"; + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr); + + String snapshotPath = command.getSnapshotUuid(); + final int index = snapshotPath.lastIndexOf("/"); + snapshotPath = snapshotPath.substring(0, index); + + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtConnectionWrapper.buildTemplateUUIDName()).thenReturn(tmplName); + + when(storagePoolMgr.getStoragePoolByURI(command.getSecondaryStorageUrl() + snapshotPath)).thenReturn(snapshotPool); + when(storagePoolMgr.getStoragePoolByURI(command.getSecondaryStorageUrl())).thenReturn(secondaryPool); + when(snapshotPool.getPhysicalDisk(command.getSnapshotName())).thenThrow(CloudRuntimeException.class); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + verify(storagePoolMgr, times(1)).getStoragePoolByURI(command.getSecondaryStorageUrl() + snapshotPath); + verify(storagePoolMgr, times(1)).getStoragePoolByURI(command.getSecondaryStorageUrl()); + } } \ No newline at end of file From 885b9e45d767d9c1e97f9f89323733446b0815f0 Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Tue, 5 May 2015 13:44:52 +0200 Subject: [PATCH 028/175] Renaming LibvirtConnectionWrapper to LibvirtUtilitiesHelper - Gave it a better, more suggestive, name since I now added other methods to the class. - It makes easier to mock objects and get a better coverage of the classes --- .../spring-kvm-compute-context.xml | 4 +- .../resource/LibvirtComputingResource.java | 8 +- .../LibvirtAttachIsoCommandWrapper.java | 4 +- .../LibvirtAttachVolumeCommandWrapper.java | 4 +- .../LibvirtBackupSnapshotCommandWrapper.java | 4 +- ...virtCheckVirtualMachineCommandWrapper.java | 4 +- ...ateTemplateFromSnapshotCommandWrapper.java | 8 +- .../LibvirtGetVmDiskStatsCommandWrapper.java | 4 +- .../LibvirtGetVmStatsCommandWrapper.java | 4 +- .../LibvirtGetVncPortCommandWrapper.java | 4 +- .../LibvirtManageSnapshotCommandWrapper.java | 4 +- .../wrapper/LibvirtMigrateCommandWrapper.java | 4 +- ...irtNetworkRulesSystemVmCommandWrapper.java | 4 +- ...tworkRulesVmSecondaryIpCommandWrapper.java | 4 +- .../wrapper/LibvirtPlugNicCommandWrapper.java | 4 +- ...virtPrepareForMigrationCommandWrapper.java | 4 +- .../wrapper/LibvirtRebootCommandWrapper.java | 4 +- ...bvirtSecurityGroupRulesCommandWrapper.java | 4 +- .../wrapper/LibvirtStopCommandWrapper.java | 6 +- .../LibvirtUnPlugNicCommandWrapper.java | 4 +- ...apper.java => LibvirtUtilitiesHelper.java} | 2 +- .../LibvirtComputingResourceTest.java | 376 +++++++++--------- 22 files changed, 234 insertions(+), 234 deletions(-) rename plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/{LibvirtConnectionWrapper.java => LibvirtUtilitiesHelper.java} (98%) diff --git a/plugins/hypervisors/kvm/resources/META-INF/cloudstack/kvm-compute/spring-kvm-compute-context.xml b/plugins/hypervisors/kvm/resources/META-INF/cloudstack/kvm-compute/spring-kvm-compute-context.xml index de6853e3b9d8..10f33ec6322f 100644 --- a/plugins/hypervisors/kvm/resources/META-INF/cloudstack/kvm-compute/spring-kvm-compute-context.xml +++ b/plugins/hypervisors/kvm/resources/META-INF/cloudstack/kvm-compute/spring-kvm-compute-context.xml @@ -31,7 +31,7 @@ - + diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 977288b2c862..a9410fb1c329 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -119,7 +119,7 @@ import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.TermPolicy; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.VideoDef; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.VirtioSerialDef; -import com.cloud.hypervisor.kvm.resource.wrapper.LibvirtConnectionWrapper; +import com.cloud.hypervisor.kvm.resource.wrapper.LibvirtUtilitiesHelper; import com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper; import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk; import com.cloud.hypervisor.kvm.storage.KVMStoragePool; @@ -272,7 +272,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv protected int _stopTimeout; @Inject - private LibvirtConnectionWrapper libvirtConnectionWrapper; + private LibvirtUtilitiesHelper libvirtUtilitiesHelper; @Override public ExecutionResult executeInVR(final String routerIp, final String script, final String args) { @@ -335,8 +335,8 @@ public ExecutionResult cleanupCommand(final NetworkElementCommand cmd) { return new ExecutionResult(true, null); } - public LibvirtConnectionWrapper getLibvirtConnectionWrapper() { - return libvirtConnectionWrapper; + public LibvirtUtilitiesHelper getLibvirtConnectionWrapper() { + return libvirtUtilitiesHelper; } public VirtualRoutingResource getVirtRouterResource() { diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtAttachIsoCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtAttachIsoCommandWrapper.java index 4380b6664944..9c128456d337 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtAttachIsoCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtAttachIsoCommandWrapper.java @@ -35,9 +35,9 @@ public final class LibvirtAttachIsoCommandWrapper extends CommandWrapper vmNames = command.getVmNames(); - final LibvirtConnectionWrapper libvirtConnectionWrapper = libvirtComputingResource.getLibvirtConnectionWrapper(); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtConnectionWrapper(); try { final HashMap> vmDiskStatsNameMap = new HashMap>(); - final Connect conn = libvirtConnectionWrapper.getConnection(); + final Connect conn = libvirtUtilitiesHelper.getConnection(); for (final String vmName : vmNames) { final List statEntry = libvirtComputingResource.getVmDiskStat(conn, vmName); if (statEntry == null) { diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmStatsCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmStatsCommandWrapper.java index e0649dae837a..f1ddca1d14a3 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmStatsCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmStatsCommandWrapper.java @@ -44,9 +44,9 @@ public Answer execute(final GetVmStatsCommand command, final LibvirtComputingRes final HashMap vmStatsNameMap = new HashMap(); for (final String vmName : vmNames) { - final LibvirtConnectionWrapper libvirtConnectionWrapper = libvirtComputingResource.getLibvirtConnectionWrapper(); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtConnectionWrapper(); - final Connect conn = libvirtConnectionWrapper.getConnectionByVmName(vmName); + final Connect conn = libvirtUtilitiesHelper.getConnectionByVmName(vmName); final VmStatsEntry statEntry = libvirtComputingResource.getVmStat(conn, vmName); if (statEntry == null) { continue; diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVncPortCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVncPortCommandWrapper.java index 9b76374d4c33..d7c182088cab 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVncPortCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVncPortCommandWrapper.java @@ -33,9 +33,9 @@ public final class LibvirtGetVncPortCommandWrapper extends CommandWrapper " + e.getLocalizedMessage()); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPlugNicCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPlugNicCommandWrapper.java index 7e6f642964ad..692f79e7777c 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPlugNicCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPlugNicCommandWrapper.java @@ -46,8 +46,8 @@ public Answer execute(final PlugNicCommand command, final LibvirtComputingResour final String vmName = command.getVmName(); Domain vm = null; try { - final LibvirtConnectionWrapper libvirtConnectionWrapper = libvirtComputingResource.getLibvirtConnectionWrapper(); - final Connect conn = libvirtConnectionWrapper.getConnectionByVmName(vmName); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtConnectionWrapper(); + final Connect conn = libvirtUtilitiesHelper.getConnectionByVmName(vmName); vm = libvirtComputingResource.getDomain(conn, vmName); final List pluggedNics = libvirtComputingResource.getInterfaces(conn, vmName); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPrepareForMigrationCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPrepareForMigrationCommandWrapper.java index 108b0d2f3d74..b9bf770a5a8d 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPrepareForMigrationCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPrepareForMigrationCommandWrapper.java @@ -54,9 +54,9 @@ public Answer execute(final PrepareForMigrationCommand command, final LibvirtCom final KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr(); try { - final LibvirtConnectionWrapper libvirtConnectionWrapper = libvirtComputingResource.getLibvirtConnectionWrapper(); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtConnectionWrapper(); - final Connect conn = libvirtConnectionWrapper.getConnectionByVmName(vm.getName()); + final Connect conn = libvirtUtilitiesHelper.getConnectionByVmName(vm.getName()); for (final NicTO nic : nics) { libvirtComputingResource.getVifDriver(nic.getType()).plug(nic, null, ""); } diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRebootCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRebootCommandWrapper.java index e91604a73997..414fcd661a2c 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRebootCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRebootCommandWrapper.java @@ -35,10 +35,10 @@ public final class LibvirtRebootCommandWrapper extends CommandWrapper nics = libvirtComputingResource.getInterfaces(conn, command.getVmName()); vif = nics.get(0).getDevName(); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStopCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStopCommandWrapper.java index 280c7f1e7de4..0d5f8920f52b 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStopCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStopCommandWrapper.java @@ -44,11 +44,11 @@ public final class LibvirtStopCommandWrapper extends CommandWrapper disks = libvirtComputingResource.getDisks(conn, vmName); final List ifaces = libvirtComputingResource.getInterfaces(conn, vmName); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUnPlugNicCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUnPlugNicCommandWrapper.java index 4ce14f2c8240..b3016fa0f5cf 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUnPlugNicCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUnPlugNicCommandWrapper.java @@ -45,9 +45,9 @@ public Answer execute(final UnPlugNicCommand command, final LibvirtComputingReso final String vmName = command.getVmName(); Domain vm = null; try { - final LibvirtConnectionWrapper libvirtConnectionWrapper = libvirtComputingResource.getLibvirtConnectionWrapper(); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtConnectionWrapper(); - final Connect conn = libvirtConnectionWrapper.getConnectionByVmName(vmName); + final Connect conn = libvirtUtilitiesHelper.getConnectionByVmName(vmName); vm = libvirtComputingResource.getDomain(conn, vmName); final List pluggedNics = libvirtComputingResource.getInterfaces(conn, vmName); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConnectionWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUtilitiesHelper.java similarity index 98% rename from plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConnectionWrapper.java rename to plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUtilitiesHelper.java index 3a51a37e376d..5930bf0015b6 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConnectionWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUtilitiesHelper.java @@ -37,7 +37,7 @@ * * Please do not instantiate this class directly, but inject it using the {@code @Inject} annotation. */ -public class LibvirtConnectionWrapper { +public class LibvirtUtilitiesHelper { public Connect getConnectionByVmName(final String vmName) throws LibvirtException { return LibvirtConnection.getConnectionByVmName(vmName); diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index 5f9c50ad0120..1504f707d35f 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -133,7 +133,7 @@ import com.cloud.hypervisor.kvm.resource.KVMHABase.NfsStoragePool; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef; -import com.cloud.hypervisor.kvm.resource.wrapper.LibvirtConnectionWrapper; +import com.cloud.hypervisor.kvm.resource.wrapper.LibvirtUtilitiesHelper; import com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper; import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk; import com.cloud.hypervisor.kvm.storage.KVMStoragePool; @@ -475,14 +475,14 @@ public void getCpuSpeed() { @Test public void testStopCommandNoCheck() { final Connect conn = Mockito.mock(Connect.class); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final String vmName = "Test"; final StopCommand command = new StopCommand(vmName, false, false); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenReturn(conn); + when(libvirtUtilitiesHelper.getConnectionByVmName(vmName)).thenReturn(conn); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -496,7 +496,7 @@ public void testStopCommandNoCheck() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vmName); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(vmName); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -505,15 +505,15 @@ public void testStopCommandNoCheck() { @Test public void testStopCommandCheck() { final Connect conn = Mockito.mock(Connect.class); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final Domain domain = Mockito.mock(Domain.class); final String vmName = "Test"; final StopCommand command = new StopCommand(vmName, false, true); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenReturn(conn); + when(libvirtUtilitiesHelper.getConnectionByVmName(vmName)).thenReturn(conn); when(conn.domainLookupByName(command.getVmName())).thenReturn(domain); } catch (final LibvirtException e) { fail(e.getMessage()); @@ -528,7 +528,7 @@ public void testStopCommandCheck() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(2)).getConnectionByVmName(vmName); + verify(libvirtUtilitiesHelper, times(2)).getConnectionByVmName(vmName); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -537,7 +537,7 @@ public void testStopCommandCheck() { @Test public void testGetVmStatsCommand() { final Connect conn = Mockito.mock(Connect.class); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final String vmName = "Test"; final String uuid = "e8d6b4d0-bc6d-4613-b8bb-cb9e0600f3c6"; @@ -546,9 +546,9 @@ public void testGetVmStatsCommand() { final GetVmStatsCommand command = new GetVmStatsCommand(vms, uuid, "hostname"); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenReturn(conn); + when(libvirtUtilitiesHelper.getConnectionByVmName(vmName)).thenReturn(conn); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -561,7 +561,7 @@ public void testGetVmStatsCommand() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vmName); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(vmName); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -570,7 +570,7 @@ public void testGetVmStatsCommand() { @Test public void testGetVmDiskStatsCommand() { final Connect conn = Mockito.mock(Connect.class); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final String vmName = "Test"; final String uuid = "e8d6b4d0-bc6d-4613-b8bb-cb9e0600f3c6"; @@ -579,9 +579,9 @@ public void testGetVmDiskStatsCommand() { final GetVmDiskStatsCommand command = new GetVmDiskStatsCommand(vms, uuid, "hostname"); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnection()).thenReturn(conn); + when(libvirtUtilitiesHelper.getConnection()).thenReturn(conn); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -594,7 +594,7 @@ public void testGetVmDiskStatsCommand() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnection(); + verify(libvirtUtilitiesHelper, times(1)).getConnection(); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -604,7 +604,7 @@ public void testGetVmDiskStatsCommand() { @Test public void testGetVmDiskStatsCommandException() { final Connect conn = Mockito.mock(Connect.class); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final String vmName = "Test"; final String uuid = "e8d6b4d0-bc6d-4613-b8bb-cb9e0600f3c6"; @@ -613,9 +613,9 @@ public void testGetVmDiskStatsCommandException() { final GetVmDiskStatsCommand command = new GetVmDiskStatsCommand(vms, uuid, "hostname"); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnection()).thenThrow(LibvirtException.class); + when(libvirtUtilitiesHelper.getConnection()).thenThrow(LibvirtException.class); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -628,7 +628,7 @@ public void testGetVmDiskStatsCommandException() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnection(); + verify(libvirtUtilitiesHelper, times(1)).getConnection(); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -637,14 +637,14 @@ public void testGetVmDiskStatsCommandException() { @Test public void testRebootCommand() { final Connect conn = Mockito.mock(Connect.class); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final String vmName = "Test"; final RebootCommand command = new RebootCommand(vmName); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenReturn(conn); + when(libvirtUtilitiesHelper.getConnectionByVmName(vmName)).thenReturn(conn); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -657,7 +657,7 @@ public void testRebootCommand() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vmName); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(vmName); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -667,15 +667,15 @@ public void testRebootCommand() { public void testRebootRouterCommand() { final VirtualRoutingResource routingResource = Mockito.mock(VirtualRoutingResource.class); final Connect conn = Mockito.mock(Connect.class); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final String vmName = "Test"; final RebootRouterCommand command = new RebootRouterCommand(vmName, "192.168.0.10"); when(libvirtComputingResource.getVirtRouterResource()).thenReturn(routingResource); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenReturn(conn); + when(libvirtUtilitiesHelper.getConnectionByVmName(vmName)).thenReturn(conn); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -690,7 +690,7 @@ public void testRebootRouterCommand() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vmName); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(vmName); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -700,16 +700,16 @@ public void testRebootRouterCommand() { public void testRebootRouterCommandConnect() { final VirtualRoutingResource routingResource = Mockito.mock(VirtualRoutingResource.class); final Connect conn = Mockito.mock(Connect.class); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final String vmName = "Test"; final RebootRouterCommand command = new RebootRouterCommand(vmName, "192.168.0.10"); when(libvirtComputingResource.getVirtRouterResource()).thenReturn(routingResource); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); when(routingResource.connect(command.getPrivateIpAddress())).thenReturn(true); try { - when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenReturn(conn); + when(libvirtUtilitiesHelper.getConnectionByVmName(vmName)).thenReturn(conn); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -723,7 +723,7 @@ public void testRebootRouterCommandConnect() { verify(libvirtComputingResource, times(1)).getVirtRouterResource(); verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vmName); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(vmName); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -758,7 +758,7 @@ public void testCheckHealthCommand() { @Test public void testPrepareForMigrationCommand() { final Connect conn = Mockito.mock(Connect.class); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final VirtualMachineTO vm = Mockito.mock(VirtualMachineTO.class); final KVMStoragePoolManager storagePoolManager = Mockito.mock(KVMStoragePoolManager.class); @@ -768,9 +768,9 @@ public void testPrepareForMigrationCommand() { final PrepareForMigrationCommand command = new PrepareForMigrationCommand(vm); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnectionByVmName(vm.getName())).thenReturn(conn); + when(libvirtUtilitiesHelper.getConnectionByVmName(vm.getName())).thenReturn(conn); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -792,7 +792,7 @@ public void testPrepareForMigrationCommand() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vm.getName()); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(vm.getName()); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -806,7 +806,7 @@ public void testPrepareForMigrationCommand() { @Test public void testPrepareForMigrationCommandMigration() { final Connect conn = Mockito.mock(Connect.class); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final VirtualMachineTO vm = Mockito.mock(VirtualMachineTO.class); final KVMStoragePoolManager storagePoolManager = Mockito.mock(KVMStoragePoolManager.class); @@ -816,9 +816,9 @@ public void testPrepareForMigrationCommandMigration() { final PrepareForMigrationCommand command = new PrepareForMigrationCommand(vm); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnectionByVmName(vm.getName())).thenReturn(conn); + when(libvirtUtilitiesHelper.getConnectionByVmName(vm.getName())).thenReturn(conn); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -841,7 +841,7 @@ public void testPrepareForMigrationCommandMigration() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vm.getName()); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(vm.getName()); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -855,7 +855,7 @@ public void testPrepareForMigrationCommandMigration() { @SuppressWarnings("unchecked") @Test public void testPrepareForMigrationCommandLibvirtException() { - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final VirtualMachineTO vm = Mockito.mock(VirtualMachineTO.class); final KVMStoragePoolManager storagePoolManager = Mockito.mock(KVMStoragePoolManager.class); @@ -864,9 +864,9 @@ public void testPrepareForMigrationCommandLibvirtException() { final PrepareForMigrationCommand command = new PrepareForMigrationCommand(vm); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnectionByVmName(vm.getName())).thenThrow(LibvirtException.class); + when(libvirtUtilitiesHelper.getConnectionByVmName(vm.getName())).thenThrow(LibvirtException.class); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -885,7 +885,7 @@ public void testPrepareForMigrationCommandLibvirtException() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vm.getName()); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(vm.getName()); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -898,7 +898,7 @@ public void testPrepareForMigrationCommandLibvirtException() { @Test public void testPrepareForMigrationCommandURISyntaxException() { final Connect conn = Mockito.mock(Connect.class); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final VirtualMachineTO vm = Mockito.mock(VirtualMachineTO.class); final KVMStoragePoolManager storagePoolManager = Mockito.mock(KVMStoragePoolManager.class); @@ -908,9 +908,9 @@ public void testPrepareForMigrationCommandURISyntaxException() { final PrepareForMigrationCommand command = new PrepareForMigrationCommand(vm); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnectionByVmName(vm.getName())).thenReturn(conn); + when(libvirtUtilitiesHelper.getConnectionByVmName(vm.getName())).thenReturn(conn); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -939,7 +939,7 @@ public void testPrepareForMigrationCommandURISyntaxException() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vm.getName()); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(vm.getName()); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -954,7 +954,7 @@ public void testPrepareForMigrationCommandURISyntaxException() { @Test public void testPrepareForMigrationCommandInternalErrorException() { final Connect conn = Mockito.mock(Connect.class); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final VirtualMachineTO vm = Mockito.mock(VirtualMachineTO.class); final KVMStoragePoolManager storagePoolManager = Mockito.mock(KVMStoragePoolManager.class); @@ -963,9 +963,9 @@ public void testPrepareForMigrationCommandInternalErrorException() { final PrepareForMigrationCommand command = new PrepareForMigrationCommand(vm); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnectionByVmName(vm.getName())).thenReturn(conn); + when(libvirtUtilitiesHelper.getConnectionByVmName(vm.getName())).thenReturn(conn); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -991,7 +991,7 @@ public void testPrepareForMigrationCommandInternalErrorException() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vm.getName()); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(vm.getName()); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -1007,7 +1007,7 @@ public void testMigrateCommand() { // Will keep it expecting the UnsatisfiedLinkError and fix later. final Connect conn = Mockito.mock(Connect.class); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final String vmName = "Test"; final String destIp = "10.1.1.100"; @@ -1017,9 +1017,9 @@ public void testMigrateCommand() { final MigrateCommand command = new MigrateCommand(vmName, destIp, isWindows, vmTO, executeInSequence ); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenReturn(conn); + when(libvirtUtilitiesHelper.getConnectionByVmName(vmName)).thenReturn(conn); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -1058,7 +1058,7 @@ public void testMigrateCommand() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vmName); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(vmName); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -1109,14 +1109,14 @@ public void testPingOnlyOneIpCommand() { @Test public void testCheckVirtualMachineCommand() { final Connect conn = Mockito.mock(Connect.class); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final String vmName = "Test"; final CheckVirtualMachineCommand command = new CheckVirtualMachineCommand(vmName); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenReturn(conn); + when(libvirtUtilitiesHelper.getConnectionByVmName(vmName)).thenReturn(conn); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -1131,7 +1131,7 @@ public void testCheckVirtualMachineCommand() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vmName); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(vmName); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -1141,14 +1141,14 @@ public void testCheckVirtualMachineCommand() { @Test public void testExceptionCheckVirtualMachineCommand() { final Connect conn = Mockito.mock(Connect.class); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final String vmName = "Test"; final CheckVirtualMachineCommand command = new CheckVirtualMachineCommand(vmName); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenThrow(LibvirtException.class); + when(libvirtUtilitiesHelper.getConnectionByVmName(vmName)).thenThrow(LibvirtException.class); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -1163,7 +1163,7 @@ public void testExceptionCheckVirtualMachineCommand() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vmName); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(vmName); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -1183,14 +1183,14 @@ public void testReadyCommand() { @Test public void testAttachIsoCommand() { final Connect conn = Mockito.mock(Connect.class); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final String vmName = "Test"; final AttachIsoCommand command = new AttachIsoCommand(vmName, "/path", true); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenReturn(conn); + when(libvirtUtilitiesHelper.getConnectionByVmName(vmName)).thenReturn(conn); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -1203,7 +1203,7 @@ public void testAttachIsoCommand() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vmName); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(vmName); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -1212,14 +1212,14 @@ public void testAttachIsoCommand() { @SuppressWarnings("unchecked") @Test public void testAttachIsoCommandLibvirtException() { - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final String vmName = "Test"; final AttachIsoCommand command = new AttachIsoCommand(vmName, "/path", true); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenThrow(LibvirtException.class); + when(libvirtUtilitiesHelper.getConnectionByVmName(vmName)).thenThrow(LibvirtException.class); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -1232,7 +1232,7 @@ public void testAttachIsoCommandLibvirtException() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vmName); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(vmName); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -1241,14 +1241,14 @@ public void testAttachIsoCommandLibvirtException() { @SuppressWarnings("unchecked") @Test public void testAttachIsoCommandURISyntaxException() { - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final String vmName = "Test"; final AttachIsoCommand command = new AttachIsoCommand(vmName, "/path", true); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenThrow(URISyntaxException.class); + when(libvirtUtilitiesHelper.getConnectionByVmName(vmName)).thenThrow(URISyntaxException.class); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -1261,7 +1261,7 @@ public void testAttachIsoCommandURISyntaxException() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vmName); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(vmName); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -1270,14 +1270,14 @@ public void testAttachIsoCommandURISyntaxException() { @SuppressWarnings("unchecked") @Test public void testAttachIsoCommandInternalErrorException() { - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final String vmName = "Test"; final AttachIsoCommand command = new AttachIsoCommand(vmName, "/path", true); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenThrow(InternalErrorException.class); + when(libvirtUtilitiesHelper.getConnectionByVmName(vmName)).thenThrow(InternalErrorException.class); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -1290,7 +1290,7 @@ public void testAttachIsoCommandInternalErrorException() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vmName); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(vmName); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -1299,7 +1299,7 @@ public void testAttachIsoCommandInternalErrorException() { @Test public void testAttachVolumeCommand() { final Connect conn = Mockito.mock(Connect.class); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final boolean attach = true; final boolean managed = true; @@ -1316,9 +1316,9 @@ public void testAttachVolumeCommand() { final KVMStoragePool primary = Mockito.mock(KVMStoragePool.class); final KVMPhysicalDisk disk = Mockito.mock(KVMPhysicalDisk.class); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenReturn(conn); + when(libvirtUtilitiesHelper.getConnectionByVmName(vmName)).thenReturn(conn); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -1335,7 +1335,7 @@ public void testAttachVolumeCommand() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vmName); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(vmName); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -1344,7 +1344,7 @@ public void testAttachVolumeCommand() { @SuppressWarnings("unchecked") @Test public void testAttachVolumeCommandLibvirtException() { - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final boolean attach = true; final boolean managed = true; @@ -1361,9 +1361,9 @@ public void testAttachVolumeCommandLibvirtException() { final KVMStoragePool primary = Mockito.mock(KVMStoragePool.class); final KVMPhysicalDisk disk = Mockito.mock(KVMPhysicalDisk.class); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenThrow(LibvirtException.class); + when(libvirtUtilitiesHelper.getConnectionByVmName(vmName)).thenThrow(LibvirtException.class); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -1380,7 +1380,7 @@ public void testAttachVolumeCommandLibvirtException() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vmName); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(vmName); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -1389,7 +1389,7 @@ public void testAttachVolumeCommandLibvirtException() { @SuppressWarnings("unchecked") @Test public void testAttachVolumeCommandInternalErrorException() { - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final boolean attach = true; final boolean managed = true; @@ -1406,9 +1406,9 @@ public void testAttachVolumeCommandInternalErrorException() { final KVMStoragePool primary = Mockito.mock(KVMStoragePool.class); final KVMPhysicalDisk disk = Mockito.mock(KVMPhysicalDisk.class); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnectionByVmName(vmName)).thenThrow(InternalErrorException.class); + when(libvirtUtilitiesHelper.getConnectionByVmName(vmName)).thenThrow(InternalErrorException.class); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -1425,7 +1425,7 @@ public void testAttachVolumeCommandInternalErrorException() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(vmName); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(vmName); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -1467,13 +1467,13 @@ public void testCheckConsoleProxyLoadCommand() { @Test public void testGetVncPortCommand() { final Connect conn = Mockito.mock(Connect.class); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final GetVncPortCommand command = new GetVncPortCommand(1l, "host"); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnectionByVmName(command.getName())).thenReturn(conn); + when(libvirtUtilitiesHelper.getConnectionByVmName(command.getName())).thenReturn(conn); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -1486,7 +1486,7 @@ public void testGetVncPortCommand() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getName()); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(command.getName()); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -1495,13 +1495,13 @@ public void testGetVncPortCommand() { @SuppressWarnings("unchecked") @Test public void testGetVncPortCommandLibvirtException() { - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final GetVncPortCommand command = new GetVncPortCommand(1l, "host"); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnectionByVmName(command.getName())).thenThrow(LibvirtException.class); + when(libvirtUtilitiesHelper.getConnectionByVmName(command.getName())).thenThrow(LibvirtException.class); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -1514,7 +1514,7 @@ public void testGetVncPortCommandLibvirtException() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getName()); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(command.getName()); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -2242,12 +2242,12 @@ public void testNetworkRulesVmSecondaryIpCommand() { final NetworkRulesVmSecondaryIpCommand command = new NetworkRulesVmSecondaryIpCommand(vmName, vmMac, secondaryIp, action ); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final Connect conn = Mockito.mock(Connect.class); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenReturn(conn); + when(libvirtUtilitiesHelper.getConnectionByVmName(command.getVmName())).thenReturn(conn); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -2260,7 +2260,7 @@ public void testNetworkRulesVmSecondaryIpCommand() { assertTrue(answer.getResult()); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(command.getVmName()); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -2278,11 +2278,11 @@ public void testNetworkRulesVmSecondaryIpCommandFailure() { final NetworkRulesVmSecondaryIpCommand command = new NetworkRulesVmSecondaryIpCommand(vmName, vmMac, secondaryIp, action ); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenThrow(LibvirtException.class); + when(libvirtUtilitiesHelper.getConnectionByVmName(command.getVmName())).thenThrow(LibvirtException.class); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -2293,7 +2293,7 @@ public void testNetworkRulesVmSecondaryIpCommandFailure() { assertFalse(answer.getResult()); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(command.getVmName()); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -2307,12 +2307,12 @@ public void testNetworkRulesSystemVmCommand() { final NetworkRulesSystemVmCommand command = new NetworkRulesSystemVmCommand(vmName, type); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final Connect conn = Mockito.mock(Connect.class); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenReturn(conn); + when(libvirtUtilitiesHelper.getConnectionByVmName(command.getVmName())).thenReturn(conn); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -2325,7 +2325,7 @@ public void testNetworkRulesSystemVmCommand() { assertTrue(answer.getResult()); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(command.getVmName()); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -2341,11 +2341,11 @@ public void testNetworkRulesSystemVmCommandFailure() { final NetworkRulesSystemVmCommand command = new NetworkRulesSystemVmCommand(vmName, type); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenThrow(LibvirtException.class); + when(libvirtUtilitiesHelper.getConnectionByVmName(command.getVmName())).thenThrow(LibvirtException.class); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -2357,7 +2357,7 @@ public void testNetworkRulesSystemVmCommandFailure() { assertFalse(answer.getResult()); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(command.getVmName()); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -2799,17 +2799,17 @@ public void testSecurityGroupRulesCmdFalse() { final SecurityGroupRulesCmd command = new SecurityGroupRulesCmd(guestIp, guestMac, vmName, vmId, signature, seqNum, ingressRuleSet, egressRuleSet); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final Connect conn = Mockito.mock(Connect.class); final List nics = new ArrayList(); final InterfaceDef interfaceDef = Mockito.mock(InterfaceDef.class); nics.add(interfaceDef); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); when(libvirtComputingResource.getInterfaces(conn, command.getVmName())).thenReturn(nics); try { - when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenReturn(conn); + when(libvirtUtilitiesHelper.getConnectionByVmName(command.getVmName())).thenReturn(conn); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -2832,7 +2832,7 @@ public void testSecurityGroupRulesCmdFalse() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(command.getVmName()); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -2851,17 +2851,17 @@ public void testSecurityGroupRulesCmdTrue() { final SecurityGroupRulesCmd command = new SecurityGroupRulesCmd(guestIp, guestMac, vmName, vmId, signature, seqNum, ingressRuleSet, egressRuleSet); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final Connect conn = Mockito.mock(Connect.class); final List nics = new ArrayList(); final InterfaceDef interfaceDef = Mockito.mock(InterfaceDef.class); nics.add(interfaceDef); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); when(libvirtComputingResource.getInterfaces(conn, command.getVmName())).thenReturn(nics); try { - when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenReturn(conn); + when(libvirtUtilitiesHelper.getConnectionByVmName(command.getVmName())).thenReturn(conn); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -2893,7 +2893,7 @@ public void testSecurityGroupRulesCmdTrue() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(command.getVmName()); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -2913,17 +2913,17 @@ public void testSecurityGroupRulesCmdException() { final SecurityGroupRulesCmd command = new SecurityGroupRulesCmd(guestIp, guestMac, vmName, vmId, signature, seqNum, ingressRuleSet, egressRuleSet); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final Connect conn = Mockito.mock(Connect.class); final List nics = new ArrayList(); final InterfaceDef interfaceDef = Mockito.mock(InterfaceDef.class); nics.add(interfaceDef); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); when(libvirtComputingResource.getInterfaces(conn, command.getVmName())).thenReturn(nics); try { - when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenThrow(LibvirtException.class); + when(libvirtUtilitiesHelper.getConnectionByVmName(command.getVmName())).thenThrow(LibvirtException.class); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -2936,7 +2936,7 @@ public void testSecurityGroupRulesCmdException() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(command.getVmName()); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -2950,7 +2950,7 @@ public void testPlugNicCommandMatchMack() { final PlugNicCommand command = new PlugNicCommand(nic, instanceName, vmtype); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final Connect conn = Mockito.mock(Connect.class); final Domain vm = Mockito.mock(Domain.class); @@ -2958,7 +2958,7 @@ public void testPlugNicCommandMatchMack() { final InterfaceDef intDef = Mockito.mock(InterfaceDef.class); nics.add(intDef); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); when(libvirtComputingResource.getInterfaces(conn, command.getVmName())).thenReturn(nics); when(intDef.getDevName()).thenReturn("eth0"); @@ -2968,7 +2968,7 @@ public void testPlugNicCommandMatchMack() { when(nic.getMac()).thenReturn("00:00:00:00"); try { - when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenReturn(conn); + when(libvirtUtilitiesHelper.getConnectionByVmName(command.getVmName())).thenReturn(conn); when(libvirtComputingResource.getDomain(conn, instanceName)).thenReturn(vm); } catch (final LibvirtException e) { fail(e.getMessage()); @@ -2982,7 +2982,7 @@ public void testPlugNicCommandMatchMack() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(command.getVmName()); verify(libvirtComputingResource, times(1)).getDomain(conn, instanceName); } catch (final LibvirtException e) { fail(e.getMessage()); @@ -2997,7 +2997,7 @@ public void testPlugNicCommandNoMatchMack() { final PlugNicCommand command = new PlugNicCommand(nic, instanceName, vmtype); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final Connect conn = Mockito.mock(Connect.class); final Domain vm = Mockito.mock(Domain.class); final VifDriver vifDriver = Mockito.mock(VifDriver.class); @@ -3007,7 +3007,7 @@ public void testPlugNicCommandNoMatchMack() { final InterfaceDef intDef = Mockito.mock(InterfaceDef.class); nics.add(intDef); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); when(libvirtComputingResource.getInterfaces(conn, command.getVmName())).thenReturn(nics); when(intDef.getDevName()).thenReturn("eth0"); @@ -3017,7 +3017,7 @@ public void testPlugNicCommandNoMatchMack() { when(nic.getMac()).thenReturn("00:00:00:01"); try { - when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenReturn(conn); + when(libvirtUtilitiesHelper.getConnectionByVmName(command.getVmName())).thenReturn(conn); when(libvirtComputingResource.getDomain(conn, instanceName)).thenReturn(vm); when(libvirtComputingResource.getVifDriver(nic.getType())).thenReturn(vifDriver); @@ -3042,7 +3042,7 @@ public void testPlugNicCommandNoMatchMack() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(command.getVmName()); verify(libvirtComputingResource, times(1)).getDomain(conn, instanceName); verify(libvirtComputingResource, times(1)).getVifDriver(nic.getType()); verify(vifDriver, times(1)).plug(nic, "Other PV", ""); @@ -3062,12 +3062,12 @@ public void testPlugNicCommandLibvirtException() { final PlugNicCommand command = new PlugNicCommand(nic, instanceName, vmtype); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenThrow(LibvirtException.class); + when(libvirtUtilitiesHelper.getConnectionByVmName(command.getVmName())).thenThrow(LibvirtException.class); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -3080,7 +3080,7 @@ public void testPlugNicCommandLibvirtException() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(command.getVmName()); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -3095,7 +3095,7 @@ public void testPlugNicCommandInternalError() { final PlugNicCommand command = new PlugNicCommand(nic, instanceName, vmtype); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final Connect conn = Mockito.mock(Connect.class); final Domain vm = Mockito.mock(Domain.class); final VifDriver vifDriver = Mockito.mock(VifDriver.class); @@ -3104,7 +3104,7 @@ public void testPlugNicCommandInternalError() { final InterfaceDef intDef = Mockito.mock(InterfaceDef.class); nics.add(intDef); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); when(libvirtComputingResource.getInterfaces(conn, command.getVmName())).thenReturn(nics); when(intDef.getDevName()).thenReturn("eth0"); @@ -3114,7 +3114,7 @@ public void testPlugNicCommandInternalError() { when(nic.getMac()).thenReturn("00:00:00:01"); try { - when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenReturn(conn); + when(libvirtUtilitiesHelper.getConnectionByVmName(command.getVmName())).thenReturn(conn); when(libvirtComputingResource.getDomain(conn, instanceName)).thenReturn(vm); when(libvirtComputingResource.getVifDriver(nic.getType())).thenReturn(vifDriver); @@ -3135,7 +3135,7 @@ public void testPlugNicCommandInternalError() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(command.getVmName()); verify(libvirtComputingResource, times(1)).getDomain(conn, instanceName); verify(libvirtComputingResource, times(1)).getVifDriver(nic.getType()); verify(vifDriver, times(1)).plug(nic, "Other PV", ""); @@ -3153,7 +3153,7 @@ public void testUnPlugNicCommandMatchMack() { final UnPlugNicCommand command = new UnPlugNicCommand(nic, instanceName); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final Connect conn = Mockito.mock(Connect.class); final Domain vm = Mockito.mock(Domain.class); final InterfaceDef interfaceDef = Mockito.mock(InterfaceDef.class); @@ -3166,7 +3166,7 @@ public void testUnPlugNicCommandMatchMack() { final List drivers = new ArrayList(); drivers.add(vifDriver); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); when(libvirtComputingResource.getInterfaces(conn, command.getVmName())).thenReturn(nics); when(intDef.getDevName()).thenReturn("eth0"); @@ -3176,7 +3176,7 @@ public void testUnPlugNicCommandMatchMack() { when(nic.getMac()).thenReturn("00:00:00:00"); try { - when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenReturn(conn); + when(libvirtUtilitiesHelper.getConnectionByVmName(command.getVmName())).thenReturn(conn); when(libvirtComputingResource.getDomain(conn, instanceName)).thenReturn(vm); when(interfaceDef.toString()).thenReturn("Interface"); @@ -3200,7 +3200,7 @@ public void testUnPlugNicCommandMatchMack() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(command.getVmName()); verify(libvirtComputingResource, times(1)).getDomain(conn, instanceName); verify(libvirtComputingResource, times(1)).getAllVifDrivers(); } catch (final LibvirtException e) { @@ -3215,7 +3215,7 @@ public void testUnPlugNicCommandNoNics() { final UnPlugNicCommand command = new UnPlugNicCommand(nic, instanceName); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final Connect conn = Mockito.mock(Connect.class); final Domain vm = Mockito.mock(Domain.class); @@ -3225,11 +3225,11 @@ public void testUnPlugNicCommandNoNics() { final List drivers = new ArrayList(); drivers.add(vifDriver); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); when(libvirtComputingResource.getInterfaces(conn, command.getVmName())).thenReturn(nics); try { - when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenReturn(conn); + when(libvirtUtilitiesHelper.getConnectionByVmName(command.getVmName())).thenReturn(conn); when(libvirtComputingResource.getDomain(conn, instanceName)).thenReturn(vm); } catch (final LibvirtException e) { fail(e.getMessage()); @@ -3243,7 +3243,7 @@ public void testUnPlugNicCommandNoNics() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(command.getVmName()); verify(libvirtComputingResource, times(1)).getDomain(conn, instanceName); } catch (final LibvirtException e) { fail(e.getMessage()); @@ -3258,12 +3258,12 @@ public void testUnPlugNicCommandLibvirtException() { final UnPlugNicCommand command = new UnPlugNicCommand(nic, instanceName); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenThrow(LibvirtException.class); + when(libvirtUtilitiesHelper.getConnectionByVmName(command.getVmName())).thenThrow(LibvirtException.class); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -3276,7 +3276,7 @@ public void testUnPlugNicCommandLibvirtException() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(command.getVmName()); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -3468,13 +3468,13 @@ public void testManageSnapshotCommandLibvirtException() { final ManageSnapshotCommand command = new ManageSnapshotCommand(snapshotId, volumePath, pool, preSnapshotPath, snapshotName, vmName); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); //final Connect conn = Mockito.mock(Connect.class); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenThrow(LibvirtException.class); + when(libvirtUtilitiesHelper.getConnectionByVmName(command.getVmName())).thenThrow(LibvirtException.class); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -3487,7 +3487,7 @@ public void testManageSnapshotCommandLibvirtException() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(command.getVmName()); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -3519,13 +3519,13 @@ public void testBackupSnapshotCommandLibvirtException() { final BackupSnapshotCommand command = new BackupSnapshotCommand(secondaryStorageUrl, dcId, accountId, volumeId, snapshotId, secHostId, volumePath, pool, snapshotUuid, snapshotName, prevSnapshotUuid, prevBackupUuid, isVolumeInactive, vmName, wait); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); //final Connect conn = Mockito.mock(Connect.class); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); try { - when(libvirtConnectionWrapper.getConnectionByVmName(command.getVmName())).thenThrow(LibvirtException.class); + when(libvirtUtilitiesHelper.getConnectionByVmName(command.getVmName())).thenThrow(LibvirtException.class); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -3538,7 +3538,7 @@ public void testBackupSnapshotCommandLibvirtException() { verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); try { - verify(libvirtConnectionWrapper, times(1)).getConnectionByVmName(command.getVmName()); + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(command.getVmName()); } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -3569,7 +3569,7 @@ public void testCreatePrivateTemplateFromSnapshotCommand() { final KVMStoragePool snapshotPool = Mockito.mock(KVMStoragePool.class); final KVMPhysicalDisk snapshot = Mockito.mock(KVMPhysicalDisk.class); final StorageLayer storage = Mockito.mock(StorageLayer.class); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final TemplateLocation location = Mockito.mock(TemplateLocation.class); final Processor qcow2Processor = Mockito.mock(Processor.class); final FormatInfo info = Mockito.mock(FormatInfo.class); @@ -3593,12 +3593,12 @@ public void testCreatePrivateTemplateFromSnapshotCommand() { final String templateInstallFolder = "template/tmpl/" + templateFolder; final String tmplPath = secondaryPool.getLocalPath() + File.separator + templateInstallFolder; - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); - when(libvirtConnectionWrapper.buildTemplateLocation(storage, tmplPath)).thenReturn(location); - when(libvirtConnectionWrapper.buildTemplateUUIDName()).thenReturn(tmplName); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); + when(libvirtUtilitiesHelper.buildTemplateLocation(storage, tmplPath)).thenReturn(location); + when(libvirtUtilitiesHelper.buildTemplateUUIDName()).thenReturn(tmplName); try { - when(libvirtConnectionWrapper.buildQCOW2Processor(storage)).thenReturn(qcow2Processor); + when(libvirtUtilitiesHelper.buildQCOW2Processor(storage)).thenReturn(qcow2Processor); when(qcow2Processor.process(tmplPath, null, tmplName)).thenReturn(info); } catch (final ConfigurationException e) { fail(e.getMessage()); @@ -3643,7 +3643,7 @@ public void testCreatePrivateTemplateFromSnapshotCommandConfigurationException() final KVMStoragePool snapshotPool = Mockito.mock(KVMStoragePool.class); final KVMPhysicalDisk snapshot = Mockito.mock(KVMPhysicalDisk.class); final StorageLayer storage = Mockito.mock(StorageLayer.class); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final TemplateLocation location = Mockito.mock(TemplateLocation.class); final Processor qcow2Processor = Mockito.mock(Processor.class); final FormatInfo info = Mockito.mock(FormatInfo.class); @@ -3667,12 +3667,12 @@ public void testCreatePrivateTemplateFromSnapshotCommandConfigurationException() final String templateInstallFolder = "template/tmpl/" + templateFolder; final String tmplPath = secondaryPool.getLocalPath() + File.separator + templateInstallFolder; - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); - when(libvirtConnectionWrapper.buildTemplateLocation(storage, tmplPath)).thenReturn(location); - when(libvirtConnectionWrapper.buildTemplateUUIDName()).thenReturn(tmplName); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); + when(libvirtUtilitiesHelper.buildTemplateLocation(storage, tmplPath)).thenReturn(location); + when(libvirtUtilitiesHelper.buildTemplateUUIDName()).thenReturn(tmplName); try { - when(libvirtConnectionWrapper.buildQCOW2Processor(storage)).thenThrow(ConfigurationException.class); + when(libvirtUtilitiesHelper.buildQCOW2Processor(storage)).thenThrow(ConfigurationException.class); when(qcow2Processor.process(tmplPath, null, tmplName)).thenReturn(info); } catch (final ConfigurationException e) { fail(e.getMessage()); @@ -3717,7 +3717,7 @@ public void testCreatePrivateTemplateFromSnapshotCommandInternalErrorException() final KVMStoragePool snapshotPool = Mockito.mock(KVMStoragePool.class); final KVMPhysicalDisk snapshot = Mockito.mock(KVMPhysicalDisk.class); final StorageLayer storage = Mockito.mock(StorageLayer.class); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final TemplateLocation location = Mockito.mock(TemplateLocation.class); final Processor qcow2Processor = Mockito.mock(Processor.class); @@ -3740,12 +3740,12 @@ public void testCreatePrivateTemplateFromSnapshotCommandInternalErrorException() final String templateInstallFolder = "template/tmpl/" + templateFolder; final String tmplPath = secondaryPool.getLocalPath() + File.separator + templateInstallFolder; - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); - when(libvirtConnectionWrapper.buildTemplateLocation(storage, tmplPath)).thenReturn(location); - when(libvirtConnectionWrapper.buildTemplateUUIDName()).thenReturn(tmplName); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); + when(libvirtUtilitiesHelper.buildTemplateLocation(storage, tmplPath)).thenReturn(location); + when(libvirtUtilitiesHelper.buildTemplateUUIDName()).thenReturn(tmplName); try { - when(libvirtConnectionWrapper.buildQCOW2Processor(storage)).thenReturn(qcow2Processor); + when(libvirtUtilitiesHelper.buildQCOW2Processor(storage)).thenReturn(qcow2Processor); when(qcow2Processor.process(tmplPath, null, tmplName)).thenThrow(InternalErrorException.class); } catch (final ConfigurationException e) { fail(e.getMessage()); @@ -3790,7 +3790,7 @@ public void testCreatePrivateTemplateFromSnapshotCommandIOException() { final KVMStoragePool snapshotPool = Mockito.mock(KVMStoragePool.class); final KVMPhysicalDisk snapshot = Mockito.mock(KVMPhysicalDisk.class); final StorageLayer storage = Mockito.mock(StorageLayer.class); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final TemplateLocation location = Mockito.mock(TemplateLocation.class); final Processor qcow2Processor = Mockito.mock(Processor.class); final FormatInfo info = Mockito.mock(FormatInfo.class); @@ -3814,12 +3814,12 @@ public void testCreatePrivateTemplateFromSnapshotCommandIOException() { final String templateInstallFolder = "template/tmpl/" + templateFolder; final String tmplPath = secondaryPool.getLocalPath() + File.separator + templateInstallFolder; - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); - when(libvirtConnectionWrapper.buildTemplateLocation(storage, tmplPath)).thenReturn(location); - when(libvirtConnectionWrapper.buildTemplateUUIDName()).thenReturn(tmplName); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); + when(libvirtUtilitiesHelper.buildTemplateLocation(storage, tmplPath)).thenReturn(location); + when(libvirtUtilitiesHelper.buildTemplateUUIDName()).thenReturn(tmplName); try { - when(libvirtConnectionWrapper.buildQCOW2Processor(storage)).thenReturn(qcow2Processor); + when(libvirtUtilitiesHelper.buildQCOW2Processor(storage)).thenReturn(qcow2Processor); when(qcow2Processor.process(tmplPath, null, tmplName)).thenReturn(info); when(location.create(1, true, tmplName)).thenThrow(IOException.class); @@ -3863,7 +3863,7 @@ public void testCreatePrivateTemplateFromSnapshotCommandCloudRuntime() { final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class); final KVMStoragePool secondaryPool = Mockito.mock(KVMStoragePool.class); final KVMStoragePool snapshotPool = Mockito.mock(KVMStoragePool.class); - final LibvirtConnectionWrapper libvirtConnectionWrapper = Mockito.mock(LibvirtConnectionWrapper.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final String tmplName = "ce97bbc1-34fe-4259-9202-74bbce2562ab"; @@ -3873,8 +3873,8 @@ public void testCreatePrivateTemplateFromSnapshotCommandCloudRuntime() { final int index = snapshotPath.lastIndexOf("/"); snapshotPath = snapshotPath.substring(0, index); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtConnectionWrapper); - when(libvirtConnectionWrapper.buildTemplateUUIDName()).thenReturn(tmplName); + when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); + when(libvirtUtilitiesHelper.buildTemplateUUIDName()).thenReturn(tmplName); when(storagePoolMgr.getStoragePoolByURI(command.getSecondaryStorageUrl() + snapshotPath)).thenReturn(snapshotPool); when(storagePoolMgr.getStoragePoolByURI(command.getSecondaryStorageUrl())).thenReturn(secondaryPool); From 0b1b2b6d925ec919e5b467ce5da1fc91f60673cb Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Wed, 6 May 2015 07:38:51 +0200 Subject: [PATCH 029/175] Refactoring the LibvirtComputingResource - Adding LibvirtCopyVolumeCommandWrapper Refactoring the LibvirtUtilitiesHelper - Changing method name Did not add any test to this commit due to the refactor mentioned abot. Will proceed and add the tests i# Please enter the commit message for your changes. Lines starting --- .../resource/LibvirtComputingResource.java | 63 +----- .../LibvirtAttachIsoCommandWrapper.java | 2 +- .../LibvirtAttachVolumeCommandWrapper.java | 2 +- .../LibvirtBackupSnapshotCommandWrapper.java | 2 +- ...virtCheckVirtualMachineCommandWrapper.java | 2 +- .../LibvirtCopyVolumeCommandWrapper.java | 99 ++++++++++ ...ateTemplateFromSnapshotCommandWrapper.java | 4 +- .../LibvirtGetVmDiskStatsCommandWrapper.java | 2 +- .../LibvirtGetVmStatsCommandWrapper.java | 2 +- .../LibvirtGetVncPortCommandWrapper.java | 2 +- .../LibvirtManageSnapshotCommandWrapper.java | 2 +- .../wrapper/LibvirtMigrateCommandWrapper.java | 2 +- ...irtNetworkRulesSystemVmCommandWrapper.java | 2 +- ...tworkRulesVmSecondaryIpCommandWrapper.java | 2 +- .../wrapper/LibvirtPlugNicCommandWrapper.java | 2 +- ...virtPrepareForMigrationCommandWrapper.java | 2 +- .../wrapper/LibvirtRebootCommandWrapper.java | 2 +- .../wrapper/LibvirtRequestWrapper.java | 2 + ...bvirtSecurityGroupRulesCommandWrapper.java | 2 +- .../wrapper/LibvirtStopCommandWrapper.java | 2 +- .../LibvirtUnPlugNicCommandWrapper.java | 2 +- .../wrapper/LibvirtUtilitiesHelper.java | 2 +- .../LibvirtComputingResourceTest.java | 184 +++++++++--------- 23 files changed, 215 insertions(+), 173 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCopyVolumeCommandWrapper.java diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index a9410fb1c329..8b74b1c3b589 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -81,8 +81,6 @@ import com.cloud.agent.api.routing.IpAssocVpcCommand; import com.cloud.agent.api.routing.NetworkElementCommand; import com.cloud.agent.api.routing.SetSourceNatCommand; -import com.cloud.agent.api.storage.CopyVolumeAnswer; -import com.cloud.agent.api.storage.CopyVolumeCommand; import com.cloud.agent.api.storage.ResizeVolumeAnswer; import com.cloud.agent.api.storage.ResizeVolumeCommand; import com.cloud.agent.api.to.DataStoreTO; @@ -119,8 +117,8 @@ import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.TermPolicy; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.VideoDef; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.VirtioSerialDef; -import com.cloud.hypervisor.kvm.resource.wrapper.LibvirtUtilitiesHelper; import com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper; +import com.cloud.hypervisor.kvm.resource.wrapper.LibvirtUtilitiesHelper; import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk; import com.cloud.hypervisor.kvm.storage.KVMStoragePool; import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; @@ -335,7 +333,7 @@ public ExecutionResult cleanupCommand(final NetworkElementCommand cmd) { return new ExecutionResult(true, null); } - public LibvirtUtilitiesHelper getLibvirtConnectionWrapper() { + public LibvirtUtilitiesHelper getLibvirtUtilitiesHelper() { return libvirtUtilitiesHelper; } @@ -1250,8 +1248,6 @@ public Answer executeRequest(final Command cmd) { return execute((StartCommand)cmd); } else if (cmd instanceof NetworkElementCommand) { return _virtRouterResource.executeRequest((NetworkElementCommand)cmd); - } else if (cmd instanceof CopyVolumeCommand) { - return execute((CopyVolumeCommand)cmd); } else if (cmd instanceof ResizeVolumeCommand) { return execute((ResizeVolumeCommand)cmd); } else if (cmd instanceof StorageSubSystemCommand) { @@ -1343,61 +1339,6 @@ public synchronized boolean configureTunnelNetwork(final long networkId, return true; } - private CopyVolumeAnswer execute(final CopyVolumeCommand cmd) { - /** - This method is only used for copying files from Primary Storage TO Secondary Storage - - It COULD also do it the other way around, but the code in the ManagementServerImpl shows - that it always sets copyToSecondary to true - - */ - final boolean copyToSecondary = cmd.toSecondaryStorage(); - String volumePath = cmd.getVolumePath(); - final StorageFilerTO pool = cmd.getPool(); - final String secondaryStorageUrl = cmd.getSecondaryStorageURL(); - KVMStoragePool secondaryStoragePool = null; - KVMStoragePool primaryPool = null; - try { - try { - primaryPool = _storagePoolMgr.getStoragePool(pool.getType(), pool.getUuid()); - } catch (final CloudRuntimeException e) { - if (e.getMessage().contains("not found")) { - primaryPool = - _storagePoolMgr.createStoragePool(cmd.getPool().getUuid(), cmd.getPool().getHost(), cmd.getPool().getPort(), cmd.getPool().getPath(), - cmd.getPool().getUserInfo(), cmd.getPool().getType()); - } else { - return new CopyVolumeAnswer(cmd, false, e.getMessage(), null, null); - } - } - - final String volumeName = UUID.randomUUID().toString(); - - if (copyToSecondary) { - final String destVolumeName = volumeName + ".qcow2"; - final KVMPhysicalDisk volume = primaryPool.getPhysicalDisk(cmd.getVolumePath()); - final String volumeDestPath = "/volumes/" + cmd.getVolumeId() + File.separator; - secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(secondaryStorageUrl); - secondaryStoragePool.createFolder(volumeDestPath); - _storagePoolMgr.deleteStoragePool(secondaryStoragePool.getType(), secondaryStoragePool.getUuid()); - secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(secondaryStorageUrl + volumeDestPath); - _storagePoolMgr.copyPhysicalDisk(volume, destVolumeName, secondaryStoragePool, 0); - return new CopyVolumeAnswer(cmd, true, null, null, volumeName); - } else { - volumePath = "/volumes/" + cmd.getVolumeId() + File.separator; - secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(secondaryStorageUrl + volumePath); - final KVMPhysicalDisk volume = secondaryStoragePool.getPhysicalDisk(cmd.getVolumePath() + ".qcow2"); - _storagePoolMgr.copyPhysicalDisk(volume, volumeName, primaryPool, 0); - return new CopyVolumeAnswer(cmd, true, null, null, volumeName); - } - } catch (final CloudRuntimeException e) { - return new CopyVolumeAnswer(cmd, false, e.toString(), null, null); - } finally { - if (secondaryStoragePool != null) { - _storagePoolMgr.deleteStoragePool(secondaryStoragePool.getType(), secondaryStoragePool.getUuid()); - } - } - } - protected Storage.StorageResourceType getStorageResourceType() { return Storage.StorageResourceType.STORAGE_POOL; } diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtAttachIsoCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtAttachIsoCommandWrapper.java index 9c128456d337..a85ea54ebf7c 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtAttachIsoCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtAttachIsoCommandWrapper.java @@ -35,7 +35,7 @@ public final class LibvirtAttachIsoCommandWrapper extends CommandWrapper { + + @Override + public Answer execute(final CopyVolumeCommand command, final LibvirtComputingResource libvirtComputingResource) { + /** + This method is only used for copying files from Primary Storage TO Secondary Storage + + It COULD also do it the other way around, but the code in the ManagementServerImpl shows + that it always sets copyToSecondary to true + + */ + final boolean copyToSecondary = command.toSecondaryStorage(); + String volumePath = command.getVolumePath(); + final StorageFilerTO pool = command.getPool(); + final String secondaryStorageUrl = command.getSecondaryStorageURL(); + KVMStoragePool secondaryStoragePool = null; + KVMStoragePool primaryPool = null; + + final KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr(); + try { + try { + primaryPool = storagePoolMgr.getStoragePool(pool.getType(), pool.getUuid()); + } catch (final CloudRuntimeException e) { + if (e.getMessage().contains("not found")) { + primaryPool = + storagePoolMgr.createStoragePool(command.getPool().getUuid(), command.getPool().getHost(), command.getPool().getPort(), command.getPool().getPath(), + command.getPool().getUserInfo(), command.getPool().getType()); + } else { + return new CopyVolumeAnswer(command, false, e.getMessage(), null, null); + } + } + + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtUtilitiesHelper(); + final String volumeName = libvirtUtilitiesHelper.generatereUUIDName(); + + if (copyToSecondary) { + final String destVolumeName = volumeName + ".qcow2"; + final KVMPhysicalDisk volume = primaryPool.getPhysicalDisk(command.getVolumePath()); + final String volumeDestPath = "/volumes/" + command.getVolumeId() + File.separator; + + secondaryStoragePool = storagePoolMgr.getStoragePoolByURI(secondaryStorageUrl); + secondaryStoragePool.createFolder(volumeDestPath); + storagePoolMgr.deleteStoragePool(secondaryStoragePool.getType(), secondaryStoragePool.getUuid()); + secondaryStoragePool = storagePoolMgr.getStoragePoolByURI(secondaryStorageUrl + volumeDestPath); + storagePoolMgr.copyPhysicalDisk(volume, destVolumeName, secondaryStoragePool, 0); + + return new CopyVolumeAnswer(command, true, null, null, volumeName); + } else { + volumePath = "/volumes/" + command.getVolumeId() + File.separator; + secondaryStoragePool = storagePoolMgr.getStoragePoolByURI(secondaryStorageUrl + volumePath); + + final KVMPhysicalDisk volume = secondaryStoragePool.getPhysicalDisk(command.getVolumePath() + ".qcow2"); + storagePoolMgr.copyPhysicalDisk(volume, volumeName, primaryPool, 0); + + return new CopyVolumeAnswer(command, true, null, null, volumeName); + } + } catch (final CloudRuntimeException e) { + return new CopyVolumeAnswer(command, false, e.toString(), null, null); + } finally { + if (secondaryStoragePool != null) { + storagePoolMgr.deleteStoragePool(secondaryStoragePool.getType(), secondaryStoragePool.getUuid()); + } + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreatePrivateTemplateFromSnapshotCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreatePrivateTemplateFromSnapshotCommandWrapper.java index 0778586437f0..35c14f86dcd3 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreatePrivateTemplateFromSnapshotCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreatePrivateTemplateFromSnapshotCommandWrapper.java @@ -48,11 +48,11 @@ public final class LibvirtCreatePrivateTemplateFromSnapshotCommandWrapper extend @Override public Answer execute(final CreatePrivateTemplateFromSnapshotCommand command, final LibvirtComputingResource libvirtComputingResource) { - final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtConnectionWrapper(); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtUtilitiesHelper(); final String templateFolder = command.getAccountId() + File.separator + command.getNewTemplateId(); final String templateInstallFolder = "template/tmpl/" + templateFolder; - final String tmplName = libvirtUtilitiesHelper.buildTemplateUUIDName(); + final String tmplName = libvirtUtilitiesHelper.generatereUUIDName(); final String tmplFileName = tmplName + ".qcow2"; KVMStoragePool secondaryPool = null; diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmDiskStatsCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmDiskStatsCommandWrapper.java index 7c76833ff312..4a8ee49b88d7 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmDiskStatsCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmDiskStatsCommandWrapper.java @@ -40,7 +40,7 @@ public final class LibvirtGetVmDiskStatsCommandWrapper extends CommandWrapper vmNames = command.getVmNames(); - final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtConnectionWrapper(); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtUtilitiesHelper(); try { final HashMap> vmDiskStatsNameMap = new HashMap>(); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmStatsCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmStatsCommandWrapper.java index f1ddca1d14a3..2e6f0a78d1fd 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmStatsCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmStatsCommandWrapper.java @@ -44,7 +44,7 @@ public Answer execute(final GetVmStatsCommand command, final LibvirtComputingRes final HashMap vmStatsNameMap = new HashMap(); for (final String vmName : vmNames) { - final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtConnectionWrapper(); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtUtilitiesHelper(); final Connect conn = libvirtUtilitiesHelper.getConnectionByVmName(vmName); final VmStatsEntry statEntry = libvirtComputingResource.getVmStat(conn, vmName); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVncPortCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVncPortCommandWrapper.java index d7c182088cab..abd9bf9ad0e3 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVncPortCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVncPortCommandWrapper.java @@ -33,7 +33,7 @@ public final class LibvirtGetVncPortCommandWrapper extends CommandWrapper nics = libvirtComputingResource.getInterfaces(conn, command.getVmName()); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStopCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStopCommandWrapper.java index 0d5f8920f52b..59a44fc01ea7 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStopCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStopCommandWrapper.java @@ -44,7 +44,7 @@ public final class LibvirtStopCommandWrapper extends CommandWrapper drivers = new ArrayList(); drivers.add(vifDriver); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); when(libvirtComputingResource.getInterfaces(conn, command.getVmName())).thenReturn(nics); when(intDef.getDevName()).thenReturn("eth0"); @@ -3198,7 +3198,7 @@ public void testUnPlugNicCommandMatchMack() { final Answer answer = wrapper.execute(command, libvirtComputingResource); assertTrue(answer.getResult()); - verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + verify(libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper(); try { verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(command.getVmName()); verify(libvirtComputingResource, times(1)).getDomain(conn, instanceName); @@ -3225,7 +3225,7 @@ public void testUnPlugNicCommandNoNics() { final List drivers = new ArrayList(); drivers.add(vifDriver); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); when(libvirtComputingResource.getInterfaces(conn, command.getVmName())).thenReturn(nics); try { @@ -3241,7 +3241,7 @@ public void testUnPlugNicCommandNoNics() { final Answer answer = wrapper.execute(command, libvirtComputingResource); assertTrue(answer.getResult()); - verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + verify(libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper(); try { verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(command.getVmName()); verify(libvirtComputingResource, times(1)).getDomain(conn, instanceName); @@ -3260,7 +3260,7 @@ public void testUnPlugNicCommandLibvirtException() { final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); try { when(libvirtUtilitiesHelper.getConnectionByVmName(command.getVmName())).thenThrow(LibvirtException.class); @@ -3274,7 +3274,7 @@ public void testUnPlugNicCommandLibvirtException() { final Answer answer = wrapper.execute(command, libvirtComputingResource); assertFalse(answer.getResult()); - verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + verify(libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper(); try { verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(command.getVmName()); } catch (final LibvirtException e) { @@ -3471,7 +3471,7 @@ public void testManageSnapshotCommandLibvirtException() { final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); //final Connect conn = Mockito.mock(Connect.class); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); try { when(libvirtUtilitiesHelper.getConnectionByVmName(command.getVmName())).thenThrow(LibvirtException.class); @@ -3485,7 +3485,7 @@ public void testManageSnapshotCommandLibvirtException() { final Answer answer = wrapper.execute(command, libvirtComputingResource); assertFalse(answer.getResult()); - verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + verify(libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper(); try { verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(command.getVmName()); } catch (final LibvirtException e) { @@ -3522,7 +3522,7 @@ public void testBackupSnapshotCommandLibvirtException() { final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); //final Connect conn = Mockito.mock(Connect.class); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); try { when(libvirtUtilitiesHelper.getConnectionByVmName(command.getVmName())).thenThrow(LibvirtException.class); @@ -3536,7 +3536,7 @@ public void testBackupSnapshotCommandLibvirtException() { final Answer answer = wrapper.execute(command, libvirtComputingResource); assertFalse(answer.getResult()); - verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + verify(libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper(); try { verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(command.getVmName()); } catch (final LibvirtException e) { @@ -3593,9 +3593,9 @@ public void testCreatePrivateTemplateFromSnapshotCommand() { final String templateInstallFolder = "template/tmpl/" + templateFolder; final String tmplPath = secondaryPool.getLocalPath() + File.separator + templateInstallFolder; - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); when(libvirtUtilitiesHelper.buildTemplateLocation(storage, tmplPath)).thenReturn(location); - when(libvirtUtilitiesHelper.buildTemplateUUIDName()).thenReturn(tmplName); + when(libvirtUtilitiesHelper.generatereUUIDName()).thenReturn(tmplName); try { when(libvirtUtilitiesHelper.buildQCOW2Processor(storage)).thenReturn(qcow2Processor); @@ -3667,9 +3667,9 @@ public void testCreatePrivateTemplateFromSnapshotCommandConfigurationException() final String templateInstallFolder = "template/tmpl/" + templateFolder; final String tmplPath = secondaryPool.getLocalPath() + File.separator + templateInstallFolder; - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); when(libvirtUtilitiesHelper.buildTemplateLocation(storage, tmplPath)).thenReturn(location); - when(libvirtUtilitiesHelper.buildTemplateUUIDName()).thenReturn(tmplName); + when(libvirtUtilitiesHelper.generatereUUIDName()).thenReturn(tmplName); try { when(libvirtUtilitiesHelper.buildQCOW2Processor(storage)).thenThrow(ConfigurationException.class); @@ -3740,9 +3740,9 @@ public void testCreatePrivateTemplateFromSnapshotCommandInternalErrorException() final String templateInstallFolder = "template/tmpl/" + templateFolder; final String tmplPath = secondaryPool.getLocalPath() + File.separator + templateInstallFolder; - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); when(libvirtUtilitiesHelper.buildTemplateLocation(storage, tmplPath)).thenReturn(location); - when(libvirtUtilitiesHelper.buildTemplateUUIDName()).thenReturn(tmplName); + when(libvirtUtilitiesHelper.generatereUUIDName()).thenReturn(tmplName); try { when(libvirtUtilitiesHelper.buildQCOW2Processor(storage)).thenReturn(qcow2Processor); @@ -3814,9 +3814,9 @@ public void testCreatePrivateTemplateFromSnapshotCommandIOException() { final String templateInstallFolder = "template/tmpl/" + templateFolder; final String tmplPath = secondaryPool.getLocalPath() + File.separator + templateInstallFolder; - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); when(libvirtUtilitiesHelper.buildTemplateLocation(storage, tmplPath)).thenReturn(location); - when(libvirtUtilitiesHelper.buildTemplateUUIDName()).thenReturn(tmplName); + when(libvirtUtilitiesHelper.generatereUUIDName()).thenReturn(tmplName); try { when(libvirtUtilitiesHelper.buildQCOW2Processor(storage)).thenReturn(qcow2Processor); @@ -3873,8 +3873,8 @@ public void testCreatePrivateTemplateFromSnapshotCommandCloudRuntime() { final int index = snapshotPath.lastIndexOf("/"); snapshotPath = snapshotPath.substring(0, index); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); - when(libvirtUtilitiesHelper.buildTemplateUUIDName()).thenReturn(tmplName); + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); + when(libvirtUtilitiesHelper.generatereUUIDName()).thenReturn(tmplName); when(storagePoolMgr.getStoragePoolByURI(command.getSecondaryStorageUrl() + snapshotPath)).thenReturn(snapshotPool); when(storagePoolMgr.getStoragePoolByURI(command.getSecondaryStorageUrl())).thenReturn(secondaryPool); From 7fd43f33d35fc514cc480c0e15f934e58be2cfdc Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Wed, 6 May 2015 08:48:24 +0200 Subject: [PATCH 030/175] Refactoring the LibvirtComputingResource - 5 unit tests added - KVM hypervisor plugin with 20.1% coverage --- .../LibvirtCopyVolumeCommandWrapper.java | 15 +- .../LibvirtComputingResourceTest.java | 210 +++++++++++++++++- 2 files changed, 216 insertions(+), 9 deletions(-) diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCopyVolumeCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCopyVolumeCommandWrapper.java index d14b045ce0e6..348c421edbd1 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCopyVolumeCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCopyVolumeCommandWrapper.java @@ -37,11 +37,12 @@ public final class LibvirtCopyVolumeCommandWrapper extends CommandWrapper Date: Wed, 6 May 2015 11:38:00 +0200 Subject: [PATCH 031/175] Refactoring the LibvirtComputingResource - Addin LibvirtPvlanSetupCommandWrapper - 6 unit tests added - KVM hypervisor plugin with 21% coverage From the 6 tests added, 2 were extra tests to increase the coverage of the LibvirtStopCommandWrapper - Increased from 35% to 78.7% --- .../resource/LibvirtComputingResource.java | 70 +----- .../LibvirtPvlanSetupCommandWrapper.java | 105 ++++++++ .../wrapper/LibvirtRequestWrapper.java | 2 + .../LibvirtComputingResourceTest.java | 236 +++++++++++++++++- 4 files changed, 352 insertions(+), 61 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPvlanSetupCommandWrapper.java diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 8b74b1c3b589..31a9ed71234a 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -68,7 +68,6 @@ import com.cloud.agent.api.PingCommand; import com.cloud.agent.api.PingRoutingCommand; import com.cloud.agent.api.PingRoutingWithNwGroupsCommand; -import com.cloud.agent.api.PvlanSetupCommand; import com.cloud.agent.api.SetupGuestNetworkCommand; import com.cloud.agent.api.StartAnswer; import com.cloud.agent.api.StartCommand; @@ -397,6 +396,18 @@ public String manageSnapshotPath() { return _manageSnapshotPath; } + public String getGuestBridgeName() { + return _guestBridgeName; + } + + public String getOvsPvlanDhcpHostPath() { + return _ovsPvlanDhcpHostPath; + } + + public String getOvsPvlanVmPath() { + return _ovsPvlanVmPath; + } + private static final class KeyValueInterpreter extends OutputInterpreter { private final Map map = new HashMap(); @@ -1252,8 +1263,6 @@ public Answer executeRequest(final Command cmd) { return execute((ResizeVolumeCommand)cmd); } else if (cmd instanceof StorageSubSystemCommand) { return storageHandler.handleStorageCommands((StorageSubSystemCommand)cmd); - } else if (cmd instanceof PvlanSetupCommand) { - return execute((PvlanSetupCommand)cmd); } else { s_logger.warn("Unsupported command "); return Answer.createUnsupportedCommandAnswer(cmd); @@ -1519,61 +1528,6 @@ private String getBroadcastUriFromBridge(final String brName) { } } - private Answer execute(final PvlanSetupCommand cmd) { - final String primaryPvlan = cmd.getPrimary(); - final String isolatedPvlan = cmd.getIsolated(); - final String op = cmd.getOp(); - final String dhcpName = cmd.getDhcpName(); - final String dhcpMac = cmd.getDhcpMac(); - final String dhcpIp = cmd.getDhcpIp(); - final String vmMac = cmd.getVmMac(); - boolean add = true; - - String opr = "-A"; - if (op.equals("delete")) { - opr = "-D"; - add = false; - } - - String result = null; - Connect conn; - try { - if (cmd.getType() == PvlanSetupCommand.Type.DHCP) { - final Script script = new Script(_ovsPvlanDhcpHostPath, _timeout, s_logger); - if (add) { - conn = LibvirtConnection.getConnectionByVmName(dhcpName); - final List ifaces = getInterfaces(conn, dhcpName); - final InterfaceDef guestNic = ifaces.get(0); - script.add(opr, "-b", _guestBridgeName, "-p", primaryPvlan, "-i", isolatedPvlan, "-n", dhcpName, "-d", dhcpIp, "-m", dhcpMac, "-I", - guestNic.getDevName()); - } else { - script.add(opr, "-b", _guestBridgeName, "-p", primaryPvlan, "-i", isolatedPvlan, "-n", dhcpName, "-d", dhcpIp, "-m", dhcpMac); - } - result = script.execute(); - if (result != null) { - s_logger.warn("Failed to program pvlan for dhcp server with mac " + dhcpMac); - return new Answer(cmd, false, result); - } else { - s_logger.info("Programmed pvlan for dhcp server with mac " + dhcpMac); - } - } else if (cmd.getType() == PvlanSetupCommand.Type.VM) { - final Script script = new Script(_ovsPvlanVmPath, _timeout, s_logger); - script.add(opr, "-b", _guestBridgeName, "-p", primaryPvlan, "-i", isolatedPvlan, "-v", vmMac); - result = script.execute(); - if (result != null) { - s_logger.warn("Failed to program pvlan for vm with mac " + vmMac); - return new Answer(cmd, false, result); - } else { - s_logger.info("Programmed pvlan for vm with mac " + vmMac); - } - } - } catch (final LibvirtException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return new Answer(cmd, true, result); - } - private void VifHotPlug(final Connect conn, final String vmName, final String broadcastUri, final String macAddr) throws InternalErrorException, LibvirtException { final NicTO nicTO = new NicTO(); nicTO.setMac(macAddr); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPvlanSetupCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPvlanSetupCommandWrapper.java new file mode 100644 index 000000000000..7233723ae1a5 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPvlanSetupCommandWrapper.java @@ -0,0 +1,105 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import java.util.List; + +import org.apache.log4j.Logger; +import org.libvirt.Connect; +import org.libvirt.LibvirtException; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.PvlanSetupCommand; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef; +import com.cloud.resource.CommandWrapper; +import com.cloud.utils.script.Script; + +public final class LibvirtPvlanSetupCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtPvlanSetupCommandWrapper.class); + + @Override + public Answer execute(final PvlanSetupCommand command, final LibvirtComputingResource libvirtComputingResource) { + final String primaryPvlan = command.getPrimary(); + final String isolatedPvlan = command.getIsolated(); + final String op = command.getOp(); + final String dhcpName = command.getDhcpName(); + final String dhcpMac = command.getDhcpMac(); + final String dhcpIp = command.getDhcpIp(); + final String vmMac = command.getVmMac(); + boolean add = true; + + String opr = "-A"; + if (op.equals("delete")) { + opr = "-D"; + add = false; + } + + String result = null; + try { + final String guestBridgeName = libvirtComputingResource.getGuestBridgeName(); + final int timeout = libvirtComputingResource.getTimeout(); + + if (command.getType() == PvlanSetupCommand.Type.DHCP) { + final String ovsPvlanDhcpHostPath = libvirtComputingResource.getOvsPvlanDhcpHostPath(); + final Script script = new Script(ovsPvlanDhcpHostPath, timeout, s_logger); + + if (add) { + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtUtilitiesHelper(); + final Connect conn = libvirtUtilitiesHelper.getConnectionByVmName(dhcpName); + + final List ifaces = libvirtComputingResource.getInterfaces(conn, dhcpName); + final InterfaceDef guestNic = ifaces.get(0); + script.add(opr, "-b", guestBridgeName, "-p", primaryPvlan, "-i", isolatedPvlan, "-n", dhcpName, "-d", dhcpIp, "-m", dhcpMac, "-I", + guestNic.getDevName()); + } else { + script.add(opr, "-b", guestBridgeName, "-p", primaryPvlan, "-i", isolatedPvlan, "-n", dhcpName, "-d", dhcpIp, "-m", dhcpMac); + } + + result = script.execute(); + + if (result != null) { + s_logger.warn("Failed to program pvlan for dhcp server with mac " + dhcpMac); + return new Answer(command, false, result); + } else { + s_logger.info("Programmed pvlan for dhcp server with mac " + dhcpMac); + } + } else if (command.getType() == PvlanSetupCommand.Type.VM) { + final String ovsPvlanVmPath = libvirtComputingResource.getOvsPvlanVmPath(); + + final Script script = new Script(ovsPvlanVmPath, timeout, s_logger); + script.add(opr, "-b", guestBridgeName, "-p", primaryPvlan, "-i", isolatedPvlan, "-v", vmMac); + result = script.execute(); + + if (result != null) { + s_logger.warn("Failed to program pvlan for vm with mac " + vmMac); + return new Answer(command, false, result); + } else { + s_logger.info("Programmed pvlan for vm with mac " + vmMac); + } + } + } catch (final LibvirtException e) { + s_logger.error("Error whislt executing OVS Setup command! ==> " + e.getMessage()); + return new Answer(command, false, e.getMessage()); + } + return new Answer(command, true, result); + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java index 1ee14a1dfe94..c103ef397b8b 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java @@ -59,6 +59,7 @@ import com.cloud.agent.api.PingTestCommand; import com.cloud.agent.api.PlugNicCommand; import com.cloud.agent.api.PrepareForMigrationCommand; +import com.cloud.agent.api.PvlanSetupCommand; import com.cloud.agent.api.ReadyCommand; import com.cloud.agent.api.RebootCommand; import com.cloud.agent.api.RebootRouterCommand; @@ -146,6 +147,7 @@ private void init() { linbvirtCommands.put(BackupSnapshotCommand.class, new LibvirtBackupSnapshotCommandWrapper()); linbvirtCommands.put(CreatePrivateTemplateFromSnapshotCommand.class, new LibvirtCreatePrivateTemplateFromSnapshotCommandWrapper()); linbvirtCommands.put(CopyVolumeCommand.class, new LibvirtCopyVolumeCommandWrapper()); + linbvirtCommands.put(PvlanSetupCommand.class, new LibvirtPvlanSetupCommandWrapper()); resources.put(LibvirtComputingResource.class, linbvirtCommands); } diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index 86ff007917c8..ad75b5327515 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -31,6 +31,7 @@ import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; +import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Arrays; @@ -54,6 +55,7 @@ import org.libvirt.Domain; import org.libvirt.DomainBlockStats; import org.libvirt.DomainInfo; +import org.libvirt.DomainInfo.DomainState; import org.libvirt.DomainInterfaceStats; import org.libvirt.LibvirtException; import org.libvirt.NodeInfo; @@ -107,6 +109,7 @@ import com.cloud.agent.api.PingTestCommand; import com.cloud.agent.api.PlugNicCommand; import com.cloud.agent.api.PrepareForMigrationCommand; +import com.cloud.agent.api.PvlanSetupCommand; import com.cloud.agent.api.ReadyCommand; import com.cloud.agent.api.RebootCommand; import com.cloud.agent.api.RebootRouterCommand; @@ -504,10 +507,13 @@ public void testStopCommandNoCheck() { } @Test - public void testStopCommandCheck() { + public void testStopCommandCheckVmNOTRunning() { final Connect conn = Mockito.mock(Connect.class); final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); - final Domain domain = Mockito.mock(Domain.class); + final Domain vm = Mockito.mock(Domain.class); + final DomainInfo info = Mockito.mock(DomainInfo.class); + final DomainState state = DomainInfo.DomainState.VIR_DOMAIN_SHUTDOWN; + info.state = state; final String vmName = "Test"; final StopCommand command = new StopCommand(vmName, false, true); @@ -515,7 +521,10 @@ public void testStopCommandCheck() { when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); try { when(libvirtUtilitiesHelper.getConnectionByVmName(vmName)).thenReturn(conn); - when(conn.domainLookupByName(command.getVmName())).thenReturn(domain); + when(conn.domainLookupByName(command.getVmName())).thenReturn(vm); + + when(vm.getInfo()).thenReturn(info); + } catch (final LibvirtException e) { fail(e.getMessage()); } @@ -535,6 +544,83 @@ public void testStopCommandCheck() { } } + @SuppressWarnings("unchecked") + @Test + public void testStopCommandCheckException1() { + final Connect conn = Mockito.mock(Connect.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); + final Domain vm = Mockito.mock(Domain.class); + final DomainInfo info = Mockito.mock(DomainInfo.class); + final DomainState state = DomainInfo.DomainState.VIR_DOMAIN_RUNNING; + info.state = state; + + final String vmName = "Test"; + final StopCommand command = new StopCommand(vmName, false, true); + + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); + try { + when(libvirtUtilitiesHelper.getConnectionByVmName(vmName)).thenThrow(LibvirtException.class); + when(conn.domainLookupByName(command.getVmName())).thenReturn(vm); + + when(vm.getInfo()).thenReturn(info); + + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper(); + try { + verify(libvirtUtilitiesHelper, times(2)).getConnectionByVmName(vmName); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + + @Test + public void testStopCommandCheckVmRunning() { + final Connect conn = Mockito.mock(Connect.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); + final Domain vm = Mockito.mock(Domain.class); + final DomainInfo info = Mockito.mock(DomainInfo.class); + final DomainState state = DomainInfo.DomainState.VIR_DOMAIN_RUNNING; + info.state = state; + + final String vmName = "Test"; + final StopCommand command = new StopCommand(vmName, false, true); + + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); + try { + when(libvirtUtilitiesHelper.getConnectionByVmName(vmName)).thenReturn(conn); + when(conn.domainLookupByName(command.getVmName())).thenReturn(vm); + + when(vm.getInfo()).thenReturn(info); + + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper(); + try { + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(vmName); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + @Test public void testGetVmStatsCommand() { final Connect conn = Mockito.mock(Connect.class); @@ -4098,4 +4184,148 @@ public void testCopyVolumeCommandPrimaryNotFound() { verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); } + + @Test + public void testPvlanSetupCommandDhcpAdd() { + final String op = "add"; + final URI uri = URI.create("http://localhost"); + final String networkTag = "/105"; + final String dhcpName = "dhcp"; + final String dhcpMac = "00:00:00:00"; + final String dhcpIp = "172.10.10.10"; + + final PvlanSetupCommand command = PvlanSetupCommand.createDhcpSetup(op, uri, networkTag, dhcpName, dhcpMac, dhcpIp); + + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); + final Connect conn = Mockito.mock(Connect.class); + + final String guestBridgeName = "br0"; + when(libvirtComputingResource.getGuestBridgeName()).thenReturn(guestBridgeName); + + final int timeout = 0; + when(libvirtComputingResource.getTimeout()).thenReturn(timeout); + final String ovsPvlanDhcpHostPath = "/pvlan"; + when(libvirtComputingResource.getOvsPvlanDhcpHostPath()).thenReturn(ovsPvlanDhcpHostPath); + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); + + final List ifaces = new ArrayList(); + final InterfaceDef nic = Mockito.mock(InterfaceDef.class); + ifaces.add(nic); + + try { + when(libvirtUtilitiesHelper.getConnectionByVmName(dhcpName)).thenReturn(conn); + when(libvirtComputingResource.getInterfaces(conn, dhcpName)).thenReturn(ifaces); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper(); + try { + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(dhcpName); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + + @Test + public void testPvlanSetupCommandVm() { + final String op = "add"; + final URI uri = URI.create("http://localhost"); + final String networkTag = "/105"; + final String vmMac = "00:00:00:00"; + + final PvlanSetupCommand command = PvlanSetupCommand.createVmSetup(op, uri, networkTag, vmMac); + + final String guestBridgeName = "br0"; + when(libvirtComputingResource.getGuestBridgeName()).thenReturn(guestBridgeName); + final int timeout = 0; + when(libvirtComputingResource.getTimeout()).thenReturn(timeout); + + final String ovsPvlanVmPath = "/pvlan"; + when(libvirtComputingResource.getOvsPvlanVmPath()).thenReturn(ovsPvlanVmPath); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + } + + @SuppressWarnings("unchecked") + @Test + public void testPvlanSetupCommandDhcpException() { + final String op = "add"; + final URI uri = URI.create("http://localhost"); + final String networkTag = "/105"; + final String dhcpName = "dhcp"; + final String dhcpMac = "00:00:00:00"; + final String dhcpIp = "172.10.10.10"; + + final PvlanSetupCommand command = PvlanSetupCommand.createDhcpSetup(op, uri, networkTag, dhcpName, dhcpMac, dhcpIp); + + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); + + final String guestBridgeName = "br0"; + when(libvirtComputingResource.getGuestBridgeName()).thenReturn(guestBridgeName); + + final int timeout = 0; + when(libvirtComputingResource.getTimeout()).thenReturn(timeout); + final String ovsPvlanDhcpHostPath = "/pvlan"; + when(libvirtComputingResource.getOvsPvlanDhcpHostPath()).thenReturn(ovsPvlanDhcpHostPath); + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); + + try { + when(libvirtUtilitiesHelper.getConnectionByVmName(dhcpName)).thenThrow(LibvirtException.class); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper(); + try { + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(dhcpName); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + + @Test + public void testPvlanSetupCommandDhcpDelete() { + final String op = "delete"; + final URI uri = URI.create("http://localhost"); + final String networkTag = "/105"; + final String dhcpName = "dhcp"; + final String dhcpMac = "00:00:00:00"; + final String dhcpIp = "172.10.10.10"; + + final PvlanSetupCommand command = PvlanSetupCommand.createDhcpSetup(op, uri, networkTag, dhcpName, dhcpMac, dhcpIp); + + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); + + final String guestBridgeName = "br0"; + when(libvirtComputingResource.getGuestBridgeName()).thenReturn(guestBridgeName); + + final int timeout = 0; + when(libvirtComputingResource.getTimeout()).thenReturn(timeout); + final String ovsPvlanDhcpHostPath = "/pvlan"; + when(libvirtComputingResource.getOvsPvlanDhcpHostPath()).thenReturn(ovsPvlanDhcpHostPath); + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + } } \ No newline at end of file From 08106e34d0eb8e4a182b32aa24e625f294555724 Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Wed, 6 May 2015 13:36:15 +0200 Subject: [PATCH 032/175] Refactoring the LibvirtComputingResource - Adding LibvirtResizeVolumeCommandWrapper - 5 unit tests added - KVM hypervisor plugin with 22.1% coverage --- .../resource/LibvirtComputingResource.java | 98 +--------- .../wrapper/LibvirtRequestWrapper.java | 2 + .../LibvirtResizeVolumeCommandWrapper.java | 136 +++++++++++++ .../LibvirtComputingResourceTest.java | 178 ++++++++++++++++++ 4 files changed, 321 insertions(+), 93 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtResizeVolumeCommandWrapper.java diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 31a9ed71234a..e98e9459698e 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -60,7 +60,6 @@ import org.libvirt.DomainInterfaceStats; import org.libvirt.LibvirtException; import org.libvirt.NodeInfo; -import org.libvirt.StorageVol; import com.cloud.agent.api.Answer; import com.cloud.agent.api.Command; @@ -80,15 +79,12 @@ import com.cloud.agent.api.routing.IpAssocVpcCommand; import com.cloud.agent.api.routing.NetworkElementCommand; import com.cloud.agent.api.routing.SetSourceNatCommand; -import com.cloud.agent.api.storage.ResizeVolumeAnswer; -import com.cloud.agent.api.storage.ResizeVolumeCommand; import com.cloud.agent.api.to.DataStoreTO; import com.cloud.agent.api.to.DataTO; import com.cloud.agent.api.to.DiskTO; import com.cloud.agent.api.to.IpAddressTO; import com.cloud.agent.api.to.NfsTO; import com.cloud.agent.api.to.NicTO; -import com.cloud.agent.api.to.StorageFilerTO; import com.cloud.agent.api.to.VirtualMachineTO; import com.cloud.agent.resource.virtualnetwork.VirtualRouterDeployer; import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource; @@ -408,6 +404,10 @@ public String getOvsPvlanVmPath() { return _ovsPvlanVmPath; } + public String getResizeVolumePath() { + return _resizeVolumePath; + } + private static final class KeyValueInterpreter extends OutputInterpreter { private final Map map = new HashMap(); @@ -1259,8 +1259,6 @@ public Answer executeRequest(final Command cmd) { return execute((StartCommand)cmd); } else if (cmd instanceof NetworkElementCommand) { return _virtRouterResource.executeRequest((NetworkElementCommand)cmd); - } else if (cmd instanceof ResizeVolumeCommand) { - return execute((ResizeVolumeCommand)cmd); } else if (cmd instanceof StorageSubSystemCommand) { return storageHandler.handleStorageCommands((StorageSubSystemCommand)cmd); } else { @@ -1401,7 +1399,7 @@ public KVMPhysicalDisk templateToPrimaryDownload(final String templateUrl, final } } - private String getResizeScriptType(final KVMStoragePool pool, final KVMPhysicalDisk vol) { + public String getResizeScriptType(final KVMStoragePool pool, final KVMPhysicalDisk vol) { final StoragePoolType poolType = pool.getType(); final PhysicalDiskFormat volFormat = vol.getFormat(); @@ -1417,92 +1415,6 @@ private String getResizeScriptType(final KVMStoragePool pool, final KVMPhysicalD throw new CloudRuntimeException("Cannot determine resize type from pool type " + pool.getType()); } - /* uses a local script now, eventually support for virStorageVolResize() will maybe work on - qcow2 and lvm and we can do this in libvirt calls */ - public Answer execute(final ResizeVolumeCommand cmd) { - final String volid = cmd.getPath(); - final long newSize = cmd.getNewSize(); - final long currentSize = cmd.getCurrentSize(); - final String vmInstanceName = cmd.getInstanceName(); - final boolean shrinkOk = cmd.getShrinkOk(); - final StorageFilerTO spool = cmd.getPool(); - final String notifyOnlyType = "NOTIFYONLY"; - - if ( currentSize == newSize) { - // nothing to do - s_logger.info("No need to resize volume: current size " + currentSize + " is same as new size " + newSize); - return new ResizeVolumeAnswer(cmd, true, "success", currentSize); - } - - try { - KVMStoragePool pool = _storagePoolMgr.getStoragePool(spool.getType(), spool.getUuid()); - final KVMPhysicalDisk vol = pool.getPhysicalDisk(volid); - final String path = vol.getPath(); - String type = getResizeScriptType(pool, vol); - - if (pool.getType() != StoragePoolType.RBD) { - if (type.equals("QCOW2") && shrinkOk) { - return new ResizeVolumeAnswer(cmd, false, "Unable to shrink volumes of type " + type); - } - } else { - s_logger.debug("Volume " + path + " is on a RBD storage pool. No need to query for additional information."); - } - - s_logger.debug("Resizing volume: " + path + "," + currentSize + "," + newSize + "," + type + "," + vmInstanceName + "," + shrinkOk); - - /* libvirt doesn't support resizing (C)LVM devices, and corrupts QCOW2 in some scenarios, so we have to do these via Bash script */ - if (pool.getType() != StoragePoolType.CLVM && vol.getFormat() != PhysicalDiskFormat.QCOW2) { - s_logger.debug("Volume " + path + " can be resized by libvirt. Asking libvirt to resize the volume."); - try { - final Connect conn = LibvirtConnection.getConnection(); - final StorageVol v = conn.storageVolLookupByPath(path); - int flags = 0; - - if (conn.getLibVirVersion() > 1001000 && vol.getFormat() == PhysicalDiskFormat.RAW && pool.getType() != StoragePoolType.RBD) { - flags = 1; - } - if (shrinkOk) { - flags = 4; - } - - v.resize(newSize, flags); - type = notifyOnlyType; - } catch (final LibvirtException e) { - return new ResizeVolumeAnswer(cmd, false, e.toString()); - } - } - s_logger.debug("Invoking resize script to handle type " + type); - final Script resizecmd = new Script(_resizeVolumePath, _cmdsTimeout, s_logger); - resizecmd.add("-s", String.valueOf(newSize)); - resizecmd.add("-c", String.valueOf(currentSize)); - resizecmd.add("-p", path); - resizecmd.add("-t", type); - resizecmd.add("-r", String.valueOf(shrinkOk)); - resizecmd.add("-v", vmInstanceName); - final String result = resizecmd.execute(); - - if (result != null) { - if(type.equals(notifyOnlyType)) { - return new ResizeVolumeAnswer(cmd, true, "Resize succeeded, but need reboot to notify guest"); - } else { - return new ResizeVolumeAnswer(cmd, false, result); - } - } - - /* fetch new size as seen from libvirt, don't want to assume anything */ - pool = _storagePoolMgr.getStoragePool(spool.getType(), spool.getUuid()); - pool.refresh(); - final long finalSize = pool.getPhysicalDisk(volid).getVirtualSize(); - s_logger.debug("after resize, size reports as " + finalSize + ", requested " + newSize); - return new ResizeVolumeAnswer(cmd, true, "success", finalSize); - } catch (final CloudRuntimeException e) { - final String error = "Failed to resize volume: " + e.getMessage(); - s_logger.debug(error); - return new ResizeVolumeAnswer(cmd, false, error); - } - - } - private String getBroadcastUriFromBridge(final String brName) { final String pif = matchPifFileInDirectory(brName); final Pattern pattern = Pattern.compile("(\\D+)(\\d+)(\\D*)(\\d*)"); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java index c103ef397b8b..363981d47ccf 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java @@ -74,6 +74,7 @@ import com.cloud.agent.api.storage.CreateCommand; import com.cloud.agent.api.storage.DestroyCommand; import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand; +import com.cloud.agent.api.storage.ResizeVolumeCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; import com.cloud.resource.RequestWrapper; @@ -148,6 +149,7 @@ private void init() { linbvirtCommands.put(CreatePrivateTemplateFromSnapshotCommand.class, new LibvirtCreatePrivateTemplateFromSnapshotCommandWrapper()); linbvirtCommands.put(CopyVolumeCommand.class, new LibvirtCopyVolumeCommandWrapper()); linbvirtCommands.put(PvlanSetupCommand.class, new LibvirtPvlanSetupCommandWrapper()); + linbvirtCommands.put(ResizeVolumeCommand.class, new LibvirtResizeVolumeCommandWrapper()); resources.put(LibvirtComputingResource.class, linbvirtCommands); } diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtResizeVolumeCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtResizeVolumeCommandWrapper.java new file mode 100644 index 000000000000..bbcba4756e56 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtResizeVolumeCommandWrapper.java @@ -0,0 +1,136 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat; +import org.apache.log4j.Logger; +import org.libvirt.Connect; +import org.libvirt.LibvirtException; +import org.libvirt.StorageVol; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.storage.ResizeVolumeAnswer; +import com.cloud.agent.api.storage.ResizeVolumeCommand; +import com.cloud.agent.api.to.StorageFilerTO; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk; +import com.cloud.hypervisor.kvm.storage.KVMStoragePool; +import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; +import com.cloud.resource.CommandWrapper; +import com.cloud.storage.Storage.StoragePoolType; +import com.cloud.utils.exception.CloudRuntimeException; +import com.cloud.utils.script.Script; + +/* + * Uses a local script now, eventually support for virStorageVolResize() will maybe work on qcow2 and lvm and we can do this in libvirt calls + */ +public final class LibvirtResizeVolumeCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtResizeVolumeCommandWrapper.class); + + @Override + public Answer execute(final ResizeVolumeCommand command, final LibvirtComputingResource libvirtComputingResource) { + final String volid = command.getPath(); + final long newSize = command.getNewSize(); + final long currentSize = command.getCurrentSize(); + final String vmInstanceName = command.getInstanceName(); + final boolean shrinkOk = command.getShrinkOk(); + final StorageFilerTO spool = command.getPool(); + final String notifyOnlyType = "NOTIFYONLY"; + + if ( currentSize == newSize) { + // nothing to do + s_logger.info("No need to resize volume: current size " + currentSize + " is same as new size " + newSize); + return new ResizeVolumeAnswer(command, true, "success", currentSize); + } + + try { + final KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr(); + KVMStoragePool pool = storagePoolMgr.getStoragePool(spool.getType(), spool.getUuid()); + + final KVMPhysicalDisk vol = pool.getPhysicalDisk(volid); + final String path = vol.getPath(); + String type = libvirtComputingResource.getResizeScriptType(pool, vol); + + if (pool.getType() != StoragePoolType.RBD) { + if (type.equals("QCOW2") && shrinkOk) { + return new ResizeVolumeAnswer(command, false, "Unable to shrink volumes of type " + type); + } + } else { + s_logger.debug("Volume " + path + " is on a RBD storage pool. No need to query for additional information."); + } + + s_logger.debug("Resizing volume: " + path + "," + currentSize + "," + newSize + "," + type + "," + vmInstanceName + "," + shrinkOk); + + /* libvirt doesn't support resizing (C)LVM devices, and corrupts QCOW2 in some scenarios, so we have to do these via Bash script */ + if (pool.getType() != StoragePoolType.CLVM && vol.getFormat() != PhysicalDiskFormat.QCOW2) { + s_logger.debug("Volume " + path + " can be resized by libvirt. Asking libvirt to resize the volume."); + try { + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtUtilitiesHelper(); + + final Connect conn = libvirtUtilitiesHelper.getConnection(); + final StorageVol v = conn.storageVolLookupByPath(path); + int flags = 0; + + if (conn.getLibVirVersion() > 1001000 && vol.getFormat() == PhysicalDiskFormat.RAW && pool.getType() != StoragePoolType.RBD) { + flags = 1; + } + if (shrinkOk) { + flags = 4; + } + + v.resize(newSize, flags); + type = notifyOnlyType; + } catch (final LibvirtException e) { + return new ResizeVolumeAnswer(command, false, e.toString()); + } + } + s_logger.debug("Invoking resize script to handle type " + type); + + final Script resizecmd = new Script(libvirtComputingResource.getResizeVolumePath(), libvirtComputingResource.getCmdsTimeout(), s_logger); + resizecmd.add("-s", String.valueOf(newSize)); + resizecmd.add("-c", String.valueOf(currentSize)); + resizecmd.add("-p", path); + resizecmd.add("-t", type); + resizecmd.add("-r", String.valueOf(shrinkOk)); + resizecmd.add("-v", vmInstanceName); + final String result = resizecmd.execute(); + + if (result != null) { + if(type.equals(notifyOnlyType)) { + return new ResizeVolumeAnswer(command, true, "Resize succeeded, but need reboot to notify guest"); + } else { + return new ResizeVolumeAnswer(command, false, result); + } + } + + /* fetch new size as seen from libvirt, don't want to assume anything */ + pool = storagePoolMgr.getStoragePool(spool.getType(), spool.getUuid()); + pool.refresh(); + final long finalSize = pool.getPhysicalDisk(volid).getVirtualSize(); + s_logger.debug("after resize, size reports as " + finalSize + ", requested " + newSize); + return new ResizeVolumeAnswer(command, true, "success", finalSize); + } catch (final CloudRuntimeException e) { + final String error = "Failed to resize volume: " + e.getMessage(); + s_logger.debug(error); + return new ResizeVolumeAnswer(command, false, error); + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index ad75b5327515..4e8d7bdc52ce 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -46,6 +46,7 @@ import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; +import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat; import org.apache.commons.lang.SystemUtils; import org.junit.Assert; import org.junit.Assume; @@ -59,6 +60,7 @@ import org.libvirt.DomainInterfaceStats; import org.libvirt.LibvirtException; import org.libvirt.NodeInfo; +import org.libvirt.StorageVol; import org.mockito.Matchers; import org.mockito.Mock; import org.mockito.Mockito; @@ -126,6 +128,7 @@ import com.cloud.agent.api.storage.CreateCommand; import com.cloud.agent.api.storage.DestroyCommand; import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand; +import com.cloud.agent.api.storage.ResizeVolumeCommand; import com.cloud.agent.api.to.DataStoreTO; import com.cloud.agent.api.to.DiskTO; import com.cloud.agent.api.to.NicTO; @@ -4328,4 +4331,179 @@ public void testPvlanSetupCommandDhcpDelete() { final Answer answer = wrapper.execute(command, libvirtComputingResource); assertFalse(answer.getResult()); } + + @Test + public void testResizeVolumeCommand() { + final String path = "nfs:/192.168.2.2/storage/secondary"; + final StorageFilerTO pool = Mockito.mock(StorageFilerTO.class); + final Long currentSize = 100l; + final Long newSize = 200l; + final boolean shrinkOk = true; + final String vmInstance = "Test"; + + final ResizeVolumeCommand command = new ResizeVolumeCommand(path, pool, currentSize, newSize, shrinkOk, vmInstance); + + final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class); + final KVMStoragePool storagePool = Mockito.mock(KVMStoragePool.class); + final KVMPhysicalDisk vol = Mockito.mock(KVMPhysicalDisk.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); + final Connect conn = Mockito.mock(Connect.class); + final StorageVol v = Mockito.mock(StorageVol.class); + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr); + when(storagePoolMgr.getStoragePool(pool.getType(), pool.getUuid())).thenReturn(storagePool); + when(storagePool.getPhysicalDisk(path)).thenReturn(vol); + when(vol.getPath()).thenReturn(path); + when(libvirtComputingResource.getResizeScriptType(storagePool, vol)).thenReturn("FILE"); + when(storagePool.getType()).thenReturn(StoragePoolType.RBD); + when(vol.getFormat()).thenReturn(PhysicalDiskFormat.FILE); + + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); + try { + when(libvirtUtilitiesHelper.getConnection()).thenReturn(conn); + when(conn.storageVolLookupByPath(path)).thenReturn(v); + + when(conn.getLibVirVersion()).thenReturn(10010l); + + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + + verify(libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper(); + try { + verify(libvirtUtilitiesHelper, times(1)).getConnection(); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + + @Test + public void testResizeVolumeCommandSameSize() { + final String path = "nfs:/192.168.2.2/storage/secondary"; + final StorageFilerTO pool = Mockito.mock(StorageFilerTO.class); + final Long currentSize = 100l; + final Long newSize = 100l; + final boolean shrinkOk = false; + final String vmInstance = "Test"; + + final ResizeVolumeCommand command = new ResizeVolumeCommand(path, pool, currentSize, newSize, shrinkOk, vmInstance); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + } + + @Test + public void testResizeVolumeCommandShrink() { + final String path = "nfs:/192.168.2.2/storage/secondary"; + final StorageFilerTO pool = Mockito.mock(StorageFilerTO.class); + final Long currentSize = 100l; + final Long newSize = 200l; + final boolean shrinkOk = true; + final String vmInstance = "Test"; + + final ResizeVolumeCommand command = new ResizeVolumeCommand(path, pool, currentSize, newSize, shrinkOk, vmInstance); + + final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class); + final KVMStoragePool storagePool = Mockito.mock(KVMStoragePool.class); + final KVMPhysicalDisk vol = Mockito.mock(KVMPhysicalDisk.class); + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr); + when(storagePoolMgr.getStoragePool(pool.getType(), pool.getUuid())).thenReturn(storagePool); + when(storagePool.getPhysicalDisk(path)).thenReturn(vol); + when(vol.getPath()).thenReturn(path); + when(libvirtComputingResource.getResizeScriptType(storagePool, vol)).thenReturn("QCOW2"); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + } + + @SuppressWarnings("unchecked") + @Test + public void testResizeVolumeCommandException() { + final String path = "nfs:/192.168.2.2/storage/secondary"; + final StorageFilerTO pool = Mockito.mock(StorageFilerTO.class); + final Long currentSize = 100l; + final Long newSize = 200l; + final boolean shrinkOk = false; + final String vmInstance = "Test"; + + final ResizeVolumeCommand command = new ResizeVolumeCommand(path, pool, currentSize, newSize, shrinkOk, vmInstance); + + final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class); + final KVMStoragePool storagePool = Mockito.mock(KVMStoragePool.class); + final KVMPhysicalDisk vol = Mockito.mock(KVMPhysicalDisk.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr); + when(storagePoolMgr.getStoragePool(pool.getType(), pool.getUuid())).thenReturn(storagePool); + when(storagePool.getPhysicalDisk(path)).thenReturn(vol); + when(vol.getPath()).thenReturn(path); + when(libvirtComputingResource.getResizeScriptType(storagePool, vol)).thenReturn("FILE"); + when(storagePool.getType()).thenReturn(StoragePoolType.RBD); + when(vol.getFormat()).thenReturn(PhysicalDiskFormat.FILE); + + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); + try { + when(libvirtUtilitiesHelper.getConnection()).thenThrow(LibvirtException.class); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + + verify(libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper(); + try { + verify(libvirtUtilitiesHelper, times(1)).getConnection(); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + + @SuppressWarnings("unchecked") + @Test + public void testResizeVolumeCommandException2() { + final String path = "nfs:/192.168.2.2/storage/secondary"; + final StorageFilerTO pool = Mockito.mock(StorageFilerTO.class); + final Long currentSize = 100l; + final Long newSize = 200l; + final boolean shrinkOk = false; + final String vmInstance = "Test"; + + final ResizeVolumeCommand command = new ResizeVolumeCommand(path, pool, currentSize, newSize, shrinkOk, vmInstance); + + final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class); + final KVMStoragePool storagePool = Mockito.mock(KVMStoragePool.class); + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr); + when(storagePoolMgr.getStoragePool(pool.getType(), pool.getUuid())).thenReturn(storagePool); + when(storagePool.getPhysicalDisk(path)).thenThrow(CloudRuntimeException.class); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + } } \ No newline at end of file From 09656ca84ef1afbc2603b2cd70186c52430daa5c Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Wed, 6 May 2015 14:31:02 +0200 Subject: [PATCH 033/175] Refactoring the LibvirtComputingResource - Adding LibvirtNetworkElementCommandWrapper and LibvirtStorageSubSystemCommandWrapper - 2 unit tests added - KVM hypervisor plugin with 22.2% coverage I also refactored the StorageSubSystemCommand interface into an abstract class - Remove the pseudo-multiple-inheritance implementation - The StorageSubSystemCommand was an interface, not related to the Command class and its implementation were extending the Command class anyway. The whole structure is better now. --- .../storage/command/AttachCommand.java | 13 +++---- .../command/AttachPrimaryDataStoreCmd.java | 7 ++-- .../storage/command/CopyCommand.java | 31 +++++++-------- .../storage/command/CreateObjectCommand.java | 7 ++-- .../command/CreatePrimaryDataStoreCmd.java | 11 +++--- .../storage/command/DeleteCommand.java | 7 ++-- .../storage/command/DettachCommand.java | 19 +++++---- .../storage/command/ForgetObjectCmd.java | 9 ++--- .../storage/command/IntroduceObjectCmd.java | 9 ++--- .../command/SnapshotAndCopyCommand.java | 14 +++---- .../command/StorageSubSystemCommand.java | 8 ++-- .../resource/LibvirtComputingResource.java | 9 ++--- .../LibvirtNetworkElementCommandWrapper.java | 35 +++++++++++++++++ .../wrapper/LibvirtRequestWrapper.java | 5 +++ ...LibvirtStorageSubSystemCommandWrapper.java | 36 +++++++++++++++++ .../LibvirtComputingResourceTest.java | 39 +++++++++++++++++++ 16 files changed, 182 insertions(+), 77 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkElementCommandWrapper.java create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStorageSubSystemCommandWrapper.java diff --git a/core/src/org/apache/cloudstack/storage/command/AttachCommand.java b/core/src/org/apache/cloudstack/storage/command/AttachCommand.java index 795deb2c0649..34aaac927785 100644 --- a/core/src/org/apache/cloudstack/storage/command/AttachCommand.java +++ b/core/src/org/apache/cloudstack/storage/command/AttachCommand.java @@ -19,15 +19,14 @@ package org.apache.cloudstack.storage.command; -import com.cloud.agent.api.Command; import com.cloud.agent.api.to.DiskTO; -public final class AttachCommand extends Command implements StorageSubSystemCommand { +public final class AttachCommand extends StorageSubSystemCommand { private DiskTO disk; private String vmName; - private boolean inSeq = false; + private boolean inSeq; - public AttachCommand(DiskTO disk, String vmName) { + public AttachCommand(final DiskTO disk, final String vmName) { super(); this.disk = disk; this.vmName = vmName; @@ -42,7 +41,7 @@ public DiskTO getDisk() { return disk; } - public void setDisk(DiskTO disk) { + public void setDisk(final DiskTO disk) { this.disk = disk; } @@ -50,12 +49,12 @@ public String getVmName() { return vmName; } - public void setVmName(String vmName) { + public void setVmName(final String vmName) { this.vmName = vmName; } @Override - public void setExecuteInSequence(boolean inSeq) { + public void setExecuteInSequence(final boolean inSeq) { this.inSeq = inSeq; } } diff --git a/core/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreCmd.java b/core/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreCmd.java index 4a72c9705877..9f4d14eb7ab8 100644 --- a/core/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreCmd.java +++ b/core/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreCmd.java @@ -19,17 +19,16 @@ package org.apache.cloudstack.storage.command; -import com.cloud.agent.api.Command; -public final class AttachPrimaryDataStoreCmd extends Command implements StorageSubSystemCommand { +public final class AttachPrimaryDataStoreCmd extends StorageSubSystemCommand { @Override - public void setExecuteInSequence(boolean inSeq) { + public void setExecuteInSequence(final boolean inSeq) { } private final String dataStore; - public AttachPrimaryDataStoreCmd(String uri) { + public AttachPrimaryDataStoreCmd(final String uri) { super(); dataStore = uri; } diff --git a/core/src/org/apache/cloudstack/storage/command/CopyCommand.java b/core/src/org/apache/cloudstack/storage/command/CopyCommand.java index cfede1483003..f1895a4ae519 100644 --- a/core/src/org/apache/cloudstack/storage/command/CopyCommand.java +++ b/core/src/org/apache/cloudstack/storage/command/CopyCommand.java @@ -22,10 +22,9 @@ import java.util.HashMap; import java.util.Map; -import com.cloud.agent.api.Command; import com.cloud.agent.api.to.DataTO; -public final class CopyCommand extends Command implements StorageSubSystemCommand { +public final class CopyCommand extends StorageSubSystemCommand { private DataTO srcTO; private DataTO destTO; private DataTO cacheTO; @@ -33,28 +32,28 @@ public final class CopyCommand extends Command implements StorageSubSystemComman private Map options = new HashMap(); private Map options2 = new HashMap(); - public CopyCommand(DataTO srcData, DataTO destData, int timeout, boolean executeInSequence) { + public CopyCommand(final DataTO srcData, final DataTO destData, final int timeout, final boolean executeInSequence) { super(); - this.srcTO = srcData; - this.destTO = destData; - this.setWait(timeout); + srcTO = srcData; + destTO = destData; + setWait(timeout); this.executeInSequence = executeInSequence; } public DataTO getDestTO() { - return this.destTO; + return destTO; } - public void setSrcTO(DataTO srcTO) { + public void setSrcTO(final DataTO srcTO) { this.srcTO = srcTO; } - public void setDestTO(DataTO destTO) { + public void setDestTO(final DataTO destTO) { this.destTO = destTO; } public DataTO getSrcTO() { - return this.srcTO; + return srcTO; } @Override @@ -66,15 +65,15 @@ public DataTO getCacheTO() { return cacheTO; } - public void setCacheTO(DataTO cacheTO) { + public void setCacheTO(final DataTO cacheTO) { this.cacheTO = cacheTO; } public int getWaitInMillSeconds() { - return this.getWait() * 1000; + return getWait() * 1000; } - public void setOptions(Map options) { + public void setOptions(final Map options) { this.options = options; } @@ -82,7 +81,7 @@ public Map getOptions() { return options; } - public void setOptions2(Map options2) { + public void setOptions2(final Map options2) { this.options2 = options2; } @@ -91,7 +90,7 @@ public Map getOptions2() { } @Override - public void setExecuteInSequence(boolean inSeq) { - this.executeInSequence = inSeq; + public void setExecuteInSequence(final boolean inSeq) { + executeInSequence = inSeq; } } diff --git a/core/src/org/apache/cloudstack/storage/command/CreateObjectCommand.java b/core/src/org/apache/cloudstack/storage/command/CreateObjectCommand.java index 6079a95b7351..88a582d03167 100644 --- a/core/src/org/apache/cloudstack/storage/command/CreateObjectCommand.java +++ b/core/src/org/apache/cloudstack/storage/command/CreateObjectCommand.java @@ -19,13 +19,12 @@ package org.apache.cloudstack.storage.command; -import com.cloud.agent.api.Command; import com.cloud.agent.api.to.DataTO; -public final class CreateObjectCommand extends Command implements StorageSubSystemCommand { +public final class CreateObjectCommand extends StorageSubSystemCommand { private DataTO data; - public CreateObjectCommand(DataTO obj) { + public CreateObjectCommand(final DataTO obj) { super(); data = obj; } @@ -44,7 +43,7 @@ public DataTO getData() { } @Override - public void setExecuteInSequence(boolean inSeq) { + public void setExecuteInSequence(final boolean inSeq) { } } diff --git a/core/src/org/apache/cloudstack/storage/command/CreatePrimaryDataStoreCmd.java b/core/src/org/apache/cloudstack/storage/command/CreatePrimaryDataStoreCmd.java index 0017dd2038ce..b1f32a9d3213 100644 --- a/core/src/org/apache/cloudstack/storage/command/CreatePrimaryDataStoreCmd.java +++ b/core/src/org/apache/cloudstack/storage/command/CreatePrimaryDataStoreCmd.java @@ -19,18 +19,17 @@ package org.apache.cloudstack.storage.command; -import com.cloud.agent.api.Command; -public final class CreatePrimaryDataStoreCmd extends Command implements StorageSubSystemCommand { +public final class CreatePrimaryDataStoreCmd extends StorageSubSystemCommand { private final String dataStore; - public CreatePrimaryDataStoreCmd(String uri) { + public CreatePrimaryDataStoreCmd(final String uri) { super(); - this.dataStore = uri; + dataStore = uri; } public String getDataStore() { - return this.dataStore; + return dataStore; } @Override @@ -39,7 +38,7 @@ public boolean executeInSequence() { } @Override - public void setExecuteInSequence(boolean inSeq) { + public void setExecuteInSequence(final boolean inSeq) { } } diff --git a/core/src/org/apache/cloudstack/storage/command/DeleteCommand.java b/core/src/org/apache/cloudstack/storage/command/DeleteCommand.java index 5683f41784dd..6f82fa97818d 100644 --- a/core/src/org/apache/cloudstack/storage/command/DeleteCommand.java +++ b/core/src/org/apache/cloudstack/storage/command/DeleteCommand.java @@ -19,13 +19,12 @@ package org.apache.cloudstack.storage.command; -import com.cloud.agent.api.Command; import com.cloud.agent.api.to.DataTO; -public final class DeleteCommand extends Command implements StorageSubSystemCommand { +public final class DeleteCommand extends StorageSubSystemCommand { private DataTO data; - public DeleteCommand(DataTO data) { + public DeleteCommand(final DataTO data) { super(); this.data = data; } @@ -44,7 +43,7 @@ public DataTO getData() { } @Override - public void setExecuteInSequence(boolean inSeq) { + public void setExecuteInSequence(final boolean inSeq) { } } diff --git a/core/src/org/apache/cloudstack/storage/command/DettachCommand.java b/core/src/org/apache/cloudstack/storage/command/DettachCommand.java index b6998629e5ec..8d89dd501e9b 100644 --- a/core/src/org/apache/cloudstack/storage/command/DettachCommand.java +++ b/core/src/org/apache/cloudstack/storage/command/DettachCommand.java @@ -19,10 +19,9 @@ package org.apache.cloudstack.storage.command; -import com.cloud.agent.api.Command; import com.cloud.agent.api.to.DiskTO; -public class DettachCommand extends Command implements StorageSubSystemCommand { +public class DettachCommand extends StorageSubSystemCommand { private DiskTO disk; private String vmName; private boolean _managed; @@ -30,7 +29,7 @@ public class DettachCommand extends Command implements StorageSubSystemCommand { private String _storageHost; private int _storagePort; - public DettachCommand(DiskTO disk, String vmName) { + public DettachCommand(final DiskTO disk, final String vmName) { super(); this.disk = disk; this.vmName = vmName; @@ -45,7 +44,7 @@ public DiskTO getDisk() { return disk; } - public void setDisk(DiskTO disk) { + public void setDisk(final DiskTO disk) { this.disk = disk; } @@ -53,11 +52,11 @@ public String getVmName() { return vmName; } - public void setVmName(String vmName) { + public void setVmName(final String vmName) { this.vmName = vmName; } - public void setManaged(boolean managed) { + public void setManaged(final boolean managed) { _managed = managed; } @@ -65,7 +64,7 @@ public boolean isManaged() { return _managed; } - public void set_iScsiName(String iScsiName) { + public void set_iScsiName(final String iScsiName) { _iScsiName = iScsiName; } @@ -73,7 +72,7 @@ public String get_iScsiName() { return _iScsiName; } - public void setStorageHost(String storageHost) { + public void setStorageHost(final String storageHost) { _storageHost = storageHost; } @@ -81,7 +80,7 @@ public String getStorageHost() { return _storageHost; } - public void setStoragePort(int storagePort) { + public void setStoragePort(final int storagePort) { _storagePort = storagePort; } @@ -90,7 +89,7 @@ public int getStoragePort() { } @Override - public void setExecuteInSequence(boolean inSeq) { + public void setExecuteInSequence(final boolean inSeq) { } } diff --git a/core/src/org/apache/cloudstack/storage/command/ForgetObjectCmd.java b/core/src/org/apache/cloudstack/storage/command/ForgetObjectCmd.java index 9bcaa62fe110..c47ee882c916 100644 --- a/core/src/org/apache/cloudstack/storage/command/ForgetObjectCmd.java +++ b/core/src/org/apache/cloudstack/storage/command/ForgetObjectCmd.java @@ -19,13 +19,12 @@ package org.apache.cloudstack.storage.command; -import com.cloud.agent.api.Command; import com.cloud.agent.api.to.DataTO; -public class ForgetObjectCmd extends Command implements StorageSubSystemCommand { - private DataTO dataTO; +public class ForgetObjectCmd extends StorageSubSystemCommand { + private final DataTO dataTO; - public ForgetObjectCmd(DataTO data) { + public ForgetObjectCmd(final DataTO data) { dataTO = data; } @@ -39,7 +38,7 @@ public boolean executeInSequence() { } @Override - public void setExecuteInSequence(boolean inSeq) { + public void setExecuteInSequence(final boolean inSeq) { } } diff --git a/core/src/org/apache/cloudstack/storage/command/IntroduceObjectCmd.java b/core/src/org/apache/cloudstack/storage/command/IntroduceObjectCmd.java index c20c50faf3cb..8c3bc5e5cc7e 100644 --- a/core/src/org/apache/cloudstack/storage/command/IntroduceObjectCmd.java +++ b/core/src/org/apache/cloudstack/storage/command/IntroduceObjectCmd.java @@ -19,13 +19,12 @@ package org.apache.cloudstack.storage.command; -import com.cloud.agent.api.Command; import com.cloud.agent.api.to.DataTO; -public class IntroduceObjectCmd extends Command implements StorageSubSystemCommand { - private DataTO dataTO; +public class IntroduceObjectCmd extends StorageSubSystemCommand { + private final DataTO dataTO; - public IntroduceObjectCmd(DataTO dataTO) { + public IntroduceObjectCmd(final DataTO dataTO) { this.dataTO = dataTO; } @@ -39,7 +38,7 @@ public boolean executeInSequence() { } @Override - public void setExecuteInSequence(boolean inSeq) { + public void setExecuteInSequence(final boolean inSeq) { } } diff --git a/core/src/org/apache/cloudstack/storage/command/SnapshotAndCopyCommand.java b/core/src/org/apache/cloudstack/storage/command/SnapshotAndCopyCommand.java index c5999161765d..0a1a84d4fc3d 100644 --- a/core/src/org/apache/cloudstack/storage/command/SnapshotAndCopyCommand.java +++ b/core/src/org/apache/cloudstack/storage/command/SnapshotAndCopyCommand.java @@ -19,18 +19,16 @@ package org.apache.cloudstack.storage.command; -import com.cloud.agent.api.Command; - import java.util.Map; -public final class SnapshotAndCopyCommand extends Command implements StorageSubSystemCommand { - private String _uuidOfSourceVdi; - private Map _sourceDetails; - private Map _destDetails; +public final class SnapshotAndCopyCommand extends StorageSubSystemCommand { + private final String _uuidOfSourceVdi; + private final Map _sourceDetails; + private final Map _destDetails; private boolean _executeInSequence = true; - public SnapshotAndCopyCommand(String uuidOfSourceVdi, Map sourceDetails, Map destDetails) { + public SnapshotAndCopyCommand(final String uuidOfSourceVdi, final Map sourceDetails, final Map destDetails) { _uuidOfSourceVdi = uuidOfSourceVdi; _sourceDetails = sourceDetails; _destDetails = destDetails; @@ -49,7 +47,7 @@ public Map getDestDetails() { } @Override - public void setExecuteInSequence(boolean executeInSequence) { + public void setExecuteInSequence(final boolean executeInSequence) { _executeInSequence = executeInSequence; } diff --git a/core/src/org/apache/cloudstack/storage/command/StorageSubSystemCommand.java b/core/src/org/apache/cloudstack/storage/command/StorageSubSystemCommand.java index 5893f62587fe..6507bb08ccdf 100644 --- a/core/src/org/apache/cloudstack/storage/command/StorageSubSystemCommand.java +++ b/core/src/org/apache/cloudstack/storage/command/StorageSubSystemCommand.java @@ -19,6 +19,8 @@ package org.apache.cloudstack.storage.command; -public interface StorageSubSystemCommand { - void setExecuteInSequence(boolean inSeq); -} +import com.cloud.agent.api.Command; + +public abstract class StorageSubSystemCommand extends Command { + abstract void setExecuteInSequence(boolean inSeq); +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index e98e9459698e..d7b4b1877cb8 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -45,7 +45,6 @@ import javax.inject.Inject; import javax.naming.ConfigurationException; -import org.apache.cloudstack.storage.command.StorageSubSystemCommand; import org.apache.cloudstack.storage.to.PrimaryDataStoreTO; import org.apache.cloudstack.storage.to.VolumeObjectTO; import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat; @@ -408,6 +407,10 @@ public String getResizeVolumePath() { return _resizeVolumePath; } + public StorageSubsystemCommandHandler getStorageHandler() { + return storageHandler; + } + private static final class KeyValueInterpreter extends OutputInterpreter { private final Map map = new HashMap(); @@ -1257,10 +1260,6 @@ public Answer executeRequest(final Command cmd) { try { if (cmd instanceof StartCommand) { return execute((StartCommand)cmd); - } else if (cmd instanceof NetworkElementCommand) { - return _virtRouterResource.executeRequest((NetworkElementCommand)cmd); - } else if (cmd instanceof StorageSubSystemCommand) { - return storageHandler.handleStorageCommands((StorageSubSystemCommand)cmd); } else { s_logger.warn("Unsupported command "); return Answer.createUnsupportedCommandAnswer(cmd); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkElementCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkElementCommandWrapper.java new file mode 100644 index 000000000000..3046b09ffc74 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkElementCommandWrapper.java @@ -0,0 +1,35 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.routing.NetworkElementCommand; +import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; + +public final class LibvirtNetworkElementCommandWrapper extends CommandWrapper { + + @Override + public Answer execute(final NetworkElementCommand command, final LibvirtComputingResource libvirtComputingResource) { + final VirtualRoutingResource virtRouterResource = libvirtComputingResource.getVirtRouterResource(); + return virtRouterResource.executeRequest(command); + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java index 363981d47ccf..e8b7b8c3bad8 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java @@ -20,6 +20,8 @@ import java.util.Hashtable; +import org.apache.cloudstack.storage.command.StorageSubSystemCommand; + import com.cloud.agent.api.Answer; import com.cloud.agent.api.AttachIsoCommand; import com.cloud.agent.api.AttachVolumeCommand; @@ -70,6 +72,7 @@ import com.cloud.agent.api.check.CheckSshCommand; import com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand; import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand; +import com.cloud.agent.api.routing.NetworkElementCommand; import com.cloud.agent.api.storage.CopyVolumeCommand; import com.cloud.agent.api.storage.CreateCommand; import com.cloud.agent.api.storage.DestroyCommand; @@ -150,6 +153,8 @@ private void init() { linbvirtCommands.put(CopyVolumeCommand.class, new LibvirtCopyVolumeCommandWrapper()); linbvirtCommands.put(PvlanSetupCommand.class, new LibvirtPvlanSetupCommandWrapper()); linbvirtCommands.put(ResizeVolumeCommand.class, new LibvirtResizeVolumeCommandWrapper()); + linbvirtCommands.put(NetworkElementCommand.class, new LibvirtNetworkElementCommandWrapper()); + linbvirtCommands.put(StorageSubSystemCommand.class, new LibvirtStorageSubSystemCommandWrapper()); resources.put(LibvirtComputingResource.class, linbvirtCommands); } diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStorageSubSystemCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStorageSubSystemCommandWrapper.java new file mode 100644 index 000000000000..d2044ed693de --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStorageSubSystemCommandWrapper.java @@ -0,0 +1,36 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import org.apache.cloudstack.storage.command.StorageSubSystemCommand; + +import com.cloud.agent.api.Answer; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.CommandWrapper; +import com.cloud.storage.resource.StorageSubsystemCommandHandler; + +public final class LibvirtStorageSubSystemCommandWrapper extends CommandWrapper { + + @Override + public Answer execute(final StorageSubSystemCommand command, final LibvirtComputingResource libvirtComputingResource) { + final StorageSubsystemCommandHandler handler = libvirtComputingResource.getStorageHandler(); + return handler.handleStorageCommands(command); + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index 4e8d7bdc52ce..140262fa8505 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -46,6 +46,8 @@ import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; +import org.apache.cloudstack.storage.command.AttachAnswer; +import org.apache.cloudstack.storage.command.AttachCommand; import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat; import org.apache.commons.lang.SystemUtils; import org.junit.Assert; @@ -76,6 +78,8 @@ import com.cloud.agent.api.CheckHealthCommand; import com.cloud.agent.api.CheckNetworkCommand; import com.cloud.agent.api.CheckOnHostCommand; +import com.cloud.agent.api.CheckRouterAnswer; +import com.cloud.agent.api.CheckRouterCommand; import com.cloud.agent.api.CheckVirtualMachineCommand; import com.cloud.agent.api.CleanupNetworkRulesCmd; import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand; @@ -152,6 +156,7 @@ import com.cloud.storage.StorageLayer; import com.cloud.storage.StoragePool; import com.cloud.storage.Volume; +import com.cloud.storage.resource.StorageSubsystemCommandHandler; import com.cloud.storage.template.Processor; import com.cloud.storage.template.Processor.FormatInfo; import com.cloud.storage.template.TemplateLocation; @@ -4506,4 +4511,38 @@ public void testResizeVolumeCommandException2() { verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); } + + @Test + public void testNetworkElementCommand() { + final CheckRouterCommand command = new CheckRouterCommand(); + + final VirtualRoutingResource virtRouterResource = Mockito.mock(VirtualRoutingResource.class); + when(libvirtComputingResource.getVirtRouterResource()).thenReturn(virtRouterResource); + + when(virtRouterResource.executeRequest(command)).thenReturn(new CheckRouterAnswer(command, "mock_resource")); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + } + + @Test + public void testStorageSubSystemCommand() { + final DiskTO disk = Mockito.mock(DiskTO.class); + final String vmName = "Test"; + final AttachCommand command = new AttachCommand(disk, vmName); + + final StorageSubsystemCommandHandler handler = Mockito.mock(StorageSubsystemCommandHandler.class); + when(libvirtComputingResource.getStorageHandler()).thenReturn(handler); + + when(handler.handleStorageCommands(command)).thenReturn(new AttachAnswer(disk)); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + } } \ No newline at end of file From 74ad48db55d141f697b6e8235e7ac472d844dd57 Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Wed, 6 May 2015 16:11:49 +0200 Subject: [PATCH 034/175] Refactoring the LibvirtComputingResource - Adding LibvirtStartCommandWrapper - 8 unit tests added - KVM hypervisor plugin with 23.2% coverage --- .../resource/LibvirtComputingResource.java | 150 +----- .../LibvirtManageSnapshotCommandWrapper.java | 6 +- .../wrapper/LibvirtRequestWrapper.java | 2 + .../wrapper/LibvirtStartCommandWrapper.java | 151 ++++++ .../wrapper/LibvirtUtilitiesHelper.java | 4 + .../LibvirtComputingResourceTest.java | 502 ++++++++++++++++++ 6 files changed, 672 insertions(+), 143 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStartCommandWrapper.java diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index d7b4b1877cb8..a04074bee94a 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -67,8 +67,6 @@ import com.cloud.agent.api.PingRoutingCommand; import com.cloud.agent.api.PingRoutingWithNwGroupsCommand; import com.cloud.agent.api.SetupGuestNetworkCommand; -import com.cloud.agent.api.StartAnswer; -import com.cloud.agent.api.StartCommand; import com.cloud.agent.api.StartupCommand; import com.cloud.agent.api.StartupRoutingCommand; import com.cloud.agent.api.StartupStorageCommand; @@ -118,7 +116,6 @@ import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; import com.cloud.hypervisor.kvm.storage.KVMStorageProcessor; import com.cloud.network.Networks.BroadcastDomainType; -import com.cloud.network.Networks.IsolationType; import com.cloud.network.Networks.RouterPrivateIpStrategy; import com.cloud.network.Networks.TrafficType; import com.cloud.resource.ServerResource; @@ -1173,7 +1170,7 @@ private boolean checkOvsNetwork(final String networkName) { return "0".equals(command.execute(null)); } - private boolean passCmdLine(final String vmName, final String cmdLine) throws InternalErrorException { + public boolean passCmdLine(final String vmName, final String cmdLine) throws InternalErrorException { final Script command = new Script(_patchViaSocketPath, 5 * 1000, s_logger); String result; command.add("-n", vmName); @@ -1199,7 +1196,7 @@ boolean isDirectAttachedNetwork(final String type) { } } - protected String startVM(final Connect conn, final String vmName, final String domainXML) throws LibvirtException, InternalErrorException { + public String startVM(final Connect conn, final String vmName, final String domainXML) throws LibvirtException, InternalErrorException { try { /* We create a transient domain here. When this method gets @@ -1253,19 +1250,7 @@ public Answer executeRequest(final Command cmd) { try { return wrapper.execute(cmd, this); } catch (final Exception e) { - //[TODO] ignore for now, we still need to finish the other commands. - //return Answer.createUnsupportedCommandAnswer(cmd); - } - - try { - if (cmd instanceof StartCommand) { - return execute((StartCommand)cmd); - } else { - s_logger.warn("Unsupported command "); - return Answer.createUnsupportedCommandAnswer(cmd); - } - } catch (final IllegalArgumentException e) { - return new Answer(cmd, false, e.getMessage()); + return Answer.createUnsupportedCommandAnswer(cmd); } } @@ -1791,7 +1776,7 @@ public long[] getVPCNetworkStats(final String privateIP, final String publicIp, return stats; } - protected void handleVmStartFailure(final Connect conn, final String vmName, final LibvirtVMDef vm) { + public void handleVmStartFailure(final Connect conn, final String vmName, final LibvirtVMDef vm) { if (vm != null && vm.getDevices() != null) { cleanupVMNetworks(conn, vm.getDevices().getInterfaces()); } @@ -1814,25 +1799,7 @@ protected String getUuid(String uuid) { return uuid; } - private void getOsVersion() { - final String version = Script.runSimpleBashScript("cat /etc/redhat-release | awk '{print $7}'"); - if (version != null) { - final String[] versions = version.split("\\."); - if (versions.length == 2) { - final String major = versions[0]; - final String minor = versions[1]; - try { - final Integer m = Integer.parseInt(major); - final Integer min = Integer.parseInt(minor); - hostOsVersion = new Pair<>(m, min); - } catch(final NumberFormatException e) { - - } - } - } - } - - protected LibvirtVMDef createVMFromSpec(final VirtualMachineTO vmTO) { + public LibvirtVMDef createVMFromSpec(final VirtualMachineTO vmTO) { final LibvirtVMDef vm = new LibvirtVMDef(); vm.setDomainName(vmTO.getName()); String uuid = vmTO.getUuid(); @@ -1972,7 +1939,7 @@ So if getMinSpeed() returns null we fall back to getSpeed(). return vm; } - protected void createVifs(final VirtualMachineTO vmSpec, final LibvirtVMDef vm) throws InternalErrorException, LibvirtException { + public void createVifs(final VirtualMachineTO vmSpec, final LibvirtVMDef vm) throws InternalErrorException, LibvirtException { final NicTO[] nics = vmSpec.getNics(); final Map params = vmSpec.getDetails(); String nicAdapter = ""; @@ -1988,107 +1955,6 @@ protected void createVifs(final VirtualMachineTO vmSpec, final LibvirtVMDef vm) } } - protected StartAnswer execute(final StartCommand cmd) { - final VirtualMachineTO vmSpec = cmd.getVirtualMachine(); - vmSpec.setVncAddr(cmd.getHostIp()); - final String vmName = vmSpec.getName(); - LibvirtVMDef vm = null; - - DomainState state = DomainState.VIR_DOMAIN_SHUTOFF; - Connect conn = null; - try { - final NicTO[] nics = vmSpec.getNics(); - - for (final NicTO nic : nics) { - if (vmSpec.getType() != VirtualMachine.Type.User) { - nic.setPxeDisable(true); - } - } - - vm = createVMFromSpec(vmSpec); - - conn = LibvirtConnection.getConnectionByType(vm.getHvsType()); - - createVbd(conn, vmSpec, vmName, vm); - - if (!_storagePoolMgr.connectPhysicalDisksViaVmSpec(vmSpec)) { - return new StartAnswer(cmd, "Failed to connect physical disks to host"); - } - - createVifs(vmSpec, vm); - - s_logger.debug("starting " + vmName + ": " + vm.toString()); - startVM(conn, vmName, vm.toString()); - - for (final NicTO nic : nics) { - if (nic.isSecurityGroupEnabled() || nic.getIsolationUri() != null && nic.getIsolationUri().getScheme().equalsIgnoreCase(IsolationType.Ec2.toString())) { - if (vmSpec.getType() != VirtualMachine.Type.User) { - configureDefaultNetworkRulesForSystemVm(conn, vmName); - break; - } else { - final List nicSecIps = nic.getNicSecIps(); - String secIpsStr; - final StringBuilder sb = new StringBuilder(); - if (nicSecIps != null) { - for (final String ip : nicSecIps) { - sb.append(ip).append(":"); - } - secIpsStr = sb.toString(); - } else { - secIpsStr = "0:"; - } - default_network_rules(conn, vmName, nic, vmSpec.getId(), secIpsStr); - } - } - } - - // pass cmdline info to system vms - if (vmSpec.getType() != VirtualMachine.Type.User) { - //wait and try passCmdLine for 5 minutes at most for CLOUDSTACK-2823 - String controlIp = null; - for (final NicTO nic : nics) { - if (nic.getType() == TrafficType.Control) { - controlIp = nic.getIp(); - break; - } - } - for (int count = 0; count < 30; count++) { - passCmdLine(vmName, vmSpec.getBootArgs()); - //check router is up? - final boolean result = _virtRouterResource.connect(controlIp, 1, 5000); - if (result) { - break; - } - } - } - - state = DomainState.VIR_DOMAIN_RUNNING; - return new StartAnswer(cmd); - } catch (final LibvirtException e) { - s_logger.warn("LibvirtException ", e); - if (conn != null) { - handleVmStartFailure(conn, vmName, vm); - } - return new StartAnswer(cmd, e.getMessage()); - } catch (final InternalErrorException e) { - s_logger.warn("InternalErrorException ", e); - if (conn != null) { - handleVmStartFailure(conn, vmName, vm); - } - return new StartAnswer(cmd, e.getMessage()); - } catch (final URISyntaxException e) { - s_logger.warn("URISyntaxException ", e); - if (conn != null) { - handleVmStartFailure(conn, vmName, vm); - } - return new StartAnswer(cmd, e.getMessage()); - } finally { - if (state != DomainState.VIR_DOMAIN_RUNNING) { - _storagePoolMgr.disconnectPhysicalDisksViaVmSpec(vmSpec); - } - } - } - public String getVolumePath(final Connect conn, final DiskTO volume) throws LibvirtException, URISyntaxException { final DataTO data = volume.getData(); final DataStoreTO store = data.getDataStore(); @@ -2107,7 +1973,7 @@ public String getVolumePath(final Connect conn, final DiskTO volume) throws Libv } } - protected void createVbd(final Connect conn, final VirtualMachineTO vmSpec, final String vmName, final LibvirtVMDef vm) throws InternalErrorException, LibvirtException, URISyntaxException { + public void createVbd(final Connect conn, final VirtualMachineTO vmSpec, final String vmName, final LibvirtVMDef vm) throws InternalErrorException, LibvirtException, URISyntaxException { final List disks = Arrays.asList(vmSpec.getDisks()); Collections.sort(disks, new Comparator() { @Override @@ -3197,7 +3063,7 @@ public boolean destroyNetworkRulesForVM(final Connect conn, final String vmName) return true; } - protected boolean default_network_rules(final Connect conn, final String vmName, final NicTO nic, final Long vmId, final String secIpStr) { + public boolean defaultNetworkRules(final Connect conn, final String vmName, final NicTO nic, final Long vmId, final String secIpStr) { if (!_canBridgeFirewall) { return false; } diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtManageSnapshotCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtManageSnapshotCommandWrapper.java index 966a43149795..225634005c51 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtManageSnapshotCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtManageSnapshotCommandWrapper.java @@ -36,9 +36,11 @@ import com.cloud.agent.api.Answer; import com.cloud.agent.api.ManageSnapshotAnswer; import com.cloud.agent.api.ManageSnapshotCommand; +import com.cloud.agent.api.to.StorageFilerTO; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk; import com.cloud.hypervisor.kvm.storage.KVMStoragePool; +import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; import com.cloud.resource.CommandWrapper; import com.cloud.storage.Storage.StoragePoolType; import com.cloud.utils.script.Script; @@ -66,7 +68,9 @@ public Answer execute(final ManageSnapshotCommand command, final LibvirtComputin } } - final KVMStoragePool primaryPool = libvirtComputingResource.getStoragePoolMgr().getStoragePool(command.getPool().getType(), command.getPool().getUuid()); + KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr(); + StorageFilerTO pool = command.getPool(); + final KVMStoragePool primaryPool = storagePoolMgr.getStoragePool(pool.getType(), pool.getUuid()); final KVMPhysicalDisk disk = primaryPool.getPhysicalDisk(command.getVolumePath()); if (state == DomainState.VIR_DOMAIN_RUNNING && !primaryPool.isExternalSnapshot()) { diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java index e8b7b8c3bad8..b181426cfdae 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java @@ -66,6 +66,7 @@ import com.cloud.agent.api.RebootCommand; import com.cloud.agent.api.RebootRouterCommand; import com.cloud.agent.api.SecurityGroupRulesCmd; +import com.cloud.agent.api.StartCommand; import com.cloud.agent.api.StopCommand; import com.cloud.agent.api.UnPlugNicCommand; import com.cloud.agent.api.UpgradeSnapshotCommand; @@ -155,6 +156,7 @@ private void init() { linbvirtCommands.put(ResizeVolumeCommand.class, new LibvirtResizeVolumeCommandWrapper()); linbvirtCommands.put(NetworkElementCommand.class, new LibvirtNetworkElementCommandWrapper()); linbvirtCommands.put(StorageSubSystemCommand.class, new LibvirtStorageSubSystemCommandWrapper()); + linbvirtCommands.put(StartCommand.class, new LibvirtStartCommandWrapper()); resources.put(LibvirtComputingResource.class, linbvirtCommands); } diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStartCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStartCommandWrapper.java new file mode 100644 index 000000000000..649e11cb8f74 --- /dev/null +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStartCommandWrapper.java @@ -0,0 +1,151 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.kvm.resource.wrapper; + +import java.net.URISyntaxException; +import java.util.List; + +import org.apache.log4j.Logger; +import org.libvirt.Connect; +import org.libvirt.DomainInfo.DomainState; +import org.libvirt.LibvirtException; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.StartAnswer; +import com.cloud.agent.api.StartCommand; +import com.cloud.agent.api.to.NicTO; +import com.cloud.agent.api.to.VirtualMachineTO; +import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource; +import com.cloud.exception.InternalErrorException; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.hypervisor.kvm.resource.LibvirtVMDef; +import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; +import com.cloud.network.Networks.IsolationType; +import com.cloud.network.Networks.TrafficType; +import com.cloud.resource.CommandWrapper; +import com.cloud.vm.VirtualMachine; + +public final class LibvirtStartCommandWrapper extends CommandWrapper { + + private static final Logger s_logger = Logger.getLogger(LibvirtStartCommandWrapper.class); + + @Override + public Answer execute(final StartCommand command, final LibvirtComputingResource libvirtComputingResource) { + final VirtualMachineTO vmSpec = command.getVirtualMachine(); + vmSpec.setVncAddr(command.getHostIp()); + final String vmName = vmSpec.getName(); + LibvirtVMDef vm = null; + + DomainState state = DomainState.VIR_DOMAIN_SHUTOFF; + final KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr(); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtUtilitiesHelper(); + Connect conn = null; + try { + final NicTO[] nics = vmSpec.getNics(); + + for (final NicTO nic : nics) { + if (vmSpec.getType() != VirtualMachine.Type.User) { + nic.setPxeDisable(true); + } + } + + vm = libvirtComputingResource.createVMFromSpec(vmSpec); + conn = libvirtUtilitiesHelper.getConnectionByType(vm.getHvsType()); + libvirtComputingResource.createVbd(conn, vmSpec, vmName, vm); + + if (!storagePoolMgr.connectPhysicalDisksViaVmSpec(vmSpec)) { + return new StartAnswer(command, "Failed to connect physical disks to host"); + } + + libvirtComputingResource.createVifs(vmSpec, vm); + + s_logger.debug("starting " + vmName + ": " + vm.toString()); + libvirtComputingResource.startVM(conn, vmName, vm.toString()); + + for (final NicTO nic : nics) { + if (nic.isSecurityGroupEnabled() || nic.getIsolationUri() != null && nic.getIsolationUri().getScheme().equalsIgnoreCase(IsolationType.Ec2.toString())) { + if (vmSpec.getType() != VirtualMachine.Type.User) { + libvirtComputingResource.configureDefaultNetworkRulesForSystemVm(conn, vmName); + break; + } else { + final List nicSecIps = nic.getNicSecIps(); + String secIpsStr; + final StringBuilder sb = new StringBuilder(); + if (nicSecIps != null) { + for (final String ip : nicSecIps) { + sb.append(ip).append(":"); + } + secIpsStr = sb.toString(); + } else { + secIpsStr = "0:"; + } + libvirtComputingResource.defaultNetworkRules(conn, vmName, nic, vmSpec.getId(), secIpsStr); + } + } + } + + // pass cmdline info to system vms + if (vmSpec.getType() != VirtualMachine.Type.User) { + //wait and try passCmdLine for 5 minutes at most for CLOUDSTACK-2823 + String controlIp = null; + for (final NicTO nic : nics) { + if (nic.getType() == TrafficType.Control) { + controlIp = nic.getIp(); + break; + } + } + for (int count = 0; count < 30; count++) { + libvirtComputingResource.passCmdLine(vmName, vmSpec.getBootArgs()); + //check router is up? + final VirtualRoutingResource virtRouterResource = libvirtComputingResource.getVirtRouterResource(); + final boolean result = virtRouterResource.connect(controlIp, 1, 5000); + if (result) { + break; + } + } + } + + state = DomainState.VIR_DOMAIN_RUNNING; + return new StartAnswer(command); + } catch (final LibvirtException e) { + s_logger.warn("LibvirtException ", e); + if (conn != null) { + libvirtComputingResource.handleVmStartFailure(conn, vmName, vm); + } + return new StartAnswer(command, e.getMessage()); + } catch (final InternalErrorException e) { + s_logger.warn("InternalErrorException ", e); + if (conn != null) { + libvirtComputingResource.handleVmStartFailure(conn, vmName, vm); + } + return new StartAnswer(command, e.getMessage()); + } catch (final URISyntaxException e) { + s_logger.warn("URISyntaxException ", e); + if (conn != null) { + libvirtComputingResource.handleVmStartFailure(conn, vmName, vm); + } + return new StartAnswer(command, e.getMessage()); + } finally { + if (state != DomainState.VIR_DOMAIN_RUNNING) { + storagePoolMgr.disconnectPhysicalDisksViaVmSpec(vmSpec); + } + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUtilitiesHelper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUtilitiesHelper.java index c0f1cb55ca46..74a41c651b99 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUtilitiesHelper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUtilitiesHelper.java @@ -65,4 +65,8 @@ public Processor buildQCOW2Processor(final StorageLayer storage) throws Configur public String generatereUUIDName() { return UUID.randomUUID().toString(); } + + public Connect getConnectionByType(final String hvsType) throws LibvirtException { + return LibvirtConnection.getConnectionByType(hvsType); + } } \ No newline at end of file diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index 140262fa8505..4a1dcc43be5c 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -24,6 +24,7 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -121,6 +122,7 @@ import com.cloud.agent.api.RebootRouterCommand; import com.cloud.agent.api.SecurityGroupRulesCmd; import com.cloud.agent.api.SecurityGroupRulesCmd.IpPortAndProto; +import com.cloud.agent.api.StartCommand; import com.cloud.agent.api.StopCommand; import com.cloud.agent.api.UnPlugNicCommand; import com.cloud.agent.api.UpgradeSnapshotCommand; @@ -758,6 +760,96 @@ public void testRebootCommand() { } } + @SuppressWarnings("unchecked") + @Test + public void testRebootCommandException1() { + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); + + final String vmName = "Test"; + final RebootCommand command = new RebootCommand(vmName); + + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); + try { + when(libvirtUtilitiesHelper.getConnectionByVmName(vmName)).thenThrow(LibvirtException.class); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper(); + try { + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(vmName); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + + @Test + public void testRebootCommandError() { + final Connect conn = Mockito.mock(Connect.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); + + final String vmName = "Test"; + final RebootCommand command = new RebootCommand(vmName); + + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); + try { + when(libvirtUtilitiesHelper.getConnectionByVmName(vmName)).thenReturn(conn); + when(libvirtComputingResource.rebootVM(conn, command.getVmName())).thenReturn("error"); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper(); + try { + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(vmName); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + + @SuppressWarnings("unchecked") + @Test + public void testRebootCommandException2() { + final Connect conn = Mockito.mock(Connect.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); + + final String vmName = "Test"; + final RebootCommand command = new RebootCommand(vmName); + + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); + try { + when(libvirtUtilitiesHelper.getConnectionByVmName(vmName)).thenReturn(conn); + when(libvirtComputingResource.rebootVM(conn, command.getVmName())).thenThrow(LibvirtException.class); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper(); + try { + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(vmName); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + @Test public void testRebootRouterCommand() { final VirtualRoutingResource routingResource = Mockito.mock(VirtualRoutingResource.class); @@ -3588,6 +3680,65 @@ public void testManageSnapshotCommandLibvirtException() { } } + @Test + public void testManageSnapshotCommandLibvirt() { + final StoragePool storagePool = Mockito.mock(StoragePool.class);; + final String volumePath = "/123/vol"; + final String vmName = "Test"; + final long snapshotId = 1l; + final String preSnapshotPath = "/snapshot/path"; + final String snapshotName = "snap"; + + final ManageSnapshotCommand command = new ManageSnapshotCommand(snapshotId, volumePath, storagePool, preSnapshotPath, snapshotName, vmName); + + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); + final Connect conn = Mockito.mock(Connect.class); + final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class); + final KVMStoragePool primaryPool = Mockito.mock(KVMStoragePool.class); + final Domain vm = Mockito.mock(Domain.class); + final DomainInfo info = Mockito.mock(DomainInfo.class); + final DomainState state = DomainInfo.DomainState.VIR_DOMAIN_RUNNING; + info.state = state; + + final KVMPhysicalDisk disk = Mockito.mock(KVMPhysicalDisk.class); + + final StorageFilerTO pool = command.getPool(); + + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); + try { + when(libvirtUtilitiesHelper.getConnectionByVmName(vmName)).thenReturn(conn); + when(libvirtComputingResource.getDomain(conn, command.getVmName())).thenReturn(vm); + when(vm.getInfo()).thenReturn(info); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr); + when(storagePoolMgr.getStoragePool(pool.getType(), pool.getUuid())).thenReturn(primaryPool); + when(primaryPool.getPhysicalDisk(command.getVolumePath())).thenReturn(disk); + when(primaryPool.isExternalSnapshot()).thenReturn(false); + + try { + when(vm.getUUIDString()).thenReturn("cdb18980-546d-4153-b916-70ee9edf0908"); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + verify(libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper(); + try { + verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(vmName); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + @SuppressWarnings("unchecked") @Test public void testBackupSnapshotCommandLibvirtException() { @@ -4545,4 +4696,355 @@ public void testStorageSubSystemCommand() { final Answer answer = wrapper.execute(command, libvirtComputingResource); assertTrue(answer.getResult()); } + + @Test + public void testStartCommandFailedConnect() { + final VirtualMachineTO vmSpec = Mockito.mock(VirtualMachineTO.class); + final com.cloud.host.Host host = Mockito.mock(com.cloud.host.Host.class); + final boolean executeInSequence = false; + + final StartCommand command = new StartCommand(vmSpec, host, executeInSequence); + + final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); + final Connect conn = Mockito.mock(Connect.class); + final LibvirtVMDef vmDef = Mockito.mock(LibvirtVMDef.class); + + final NicTO nic = Mockito.mock(NicTO.class); + final NicTO[] nics = new NicTO[]{nic}; + + final String vmName = "Test"; + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr); + when(vmSpec.getNics()).thenReturn(nics); + when(vmSpec.getType()).thenReturn(VirtualMachine.Type.DomainRouter); + when(vmSpec.getName()).thenReturn(vmName); + when(libvirtComputingResource.createVMFromSpec(vmSpec)).thenReturn(vmDef); + + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); + try { + when(libvirtUtilitiesHelper.getConnectionByType(vmDef.getHvsType())).thenReturn(conn); + doNothing().when(libvirtComputingResource).createVbd(conn, vmSpec, vmName, vmDef); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } catch (final InternalErrorException e) { + fail(e.getMessage()); + } catch (final URISyntaxException e) { + fail(e.getMessage()); + } + + when(storagePoolMgr.connectPhysicalDisksViaVmSpec(vmSpec)).thenReturn(false); + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + verify(libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper(); + try { + verify(libvirtUtilitiesHelper, times(1)).getConnectionByType(vmDef.getHvsType()); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + + @SuppressWarnings("unchecked") + @Test + public void testStartCommandLibvirtException() { + final VirtualMachineTO vmSpec = Mockito.mock(VirtualMachineTO.class); + final com.cloud.host.Host host = Mockito.mock(com.cloud.host.Host.class); + final boolean executeInSequence = false; + + final StartCommand command = new StartCommand(vmSpec, host, executeInSequence); + + final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); + final LibvirtVMDef vmDef = Mockito.mock(LibvirtVMDef.class); + + final NicTO nic = Mockito.mock(NicTO.class); + final NicTO[] nics = new NicTO[]{nic}; + + final String vmName = "Test"; + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr); + when(vmSpec.getNics()).thenReturn(nics); + when(vmSpec.getType()).thenReturn(VirtualMachine.Type.DomainRouter); + when(vmSpec.getName()).thenReturn(vmName); + when(libvirtComputingResource.createVMFromSpec(vmSpec)).thenReturn(vmDef); + + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); + try { + when(libvirtUtilitiesHelper.getConnectionByType(vmDef.getHvsType())).thenThrow(LibvirtException.class); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + verify(libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper(); + try { + verify(libvirtUtilitiesHelper, times(1)).getConnectionByType(vmDef.getHvsType()); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + + @Test + public void testStartCommandInternalError() { + final VirtualMachineTO vmSpec = Mockito.mock(VirtualMachineTO.class); + final com.cloud.host.Host host = Mockito.mock(com.cloud.host.Host.class); + final boolean executeInSequence = false; + + final StartCommand command = new StartCommand(vmSpec, host, executeInSequence); + + final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); + final Connect conn = Mockito.mock(Connect.class); + final LibvirtVMDef vmDef = Mockito.mock(LibvirtVMDef.class); + + final NicTO nic = Mockito.mock(NicTO.class); + final NicTO[] nics = new NicTO[]{nic}; + + final String vmName = "Test"; + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr); + when(vmSpec.getNics()).thenReturn(nics); + when(vmSpec.getType()).thenReturn(VirtualMachine.Type.DomainRouter); + when(vmSpec.getName()).thenReturn(vmName); + when(libvirtComputingResource.createVMFromSpec(vmSpec)).thenReturn(vmDef); + + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); + try { + when(libvirtUtilitiesHelper.getConnectionByType(vmDef.getHvsType())).thenReturn(conn); + doThrow(InternalErrorException.class).when(libvirtComputingResource).createVbd(conn, vmSpec, vmName, vmDef); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } catch (final InternalErrorException e) { + fail(e.getMessage()); + } catch (final URISyntaxException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + verify(libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper(); + try { + verify(libvirtUtilitiesHelper, times(1)).getConnectionByType(vmDef.getHvsType()); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + + @Test + public void testStartCommandUriException() { + final VirtualMachineTO vmSpec = Mockito.mock(VirtualMachineTO.class); + final com.cloud.host.Host host = Mockito.mock(com.cloud.host.Host.class); + final boolean executeInSequence = false; + + final StartCommand command = new StartCommand(vmSpec, host, executeInSequence); + + final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); + final Connect conn = Mockito.mock(Connect.class); + final LibvirtVMDef vmDef = Mockito.mock(LibvirtVMDef.class); + + final NicTO nic = Mockito.mock(NicTO.class); + final NicTO[] nics = new NicTO[]{nic}; + + final String vmName = "Test"; + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr); + when(vmSpec.getNics()).thenReturn(nics); + when(vmSpec.getType()).thenReturn(VirtualMachine.Type.DomainRouter); + when(vmSpec.getName()).thenReturn(vmName); + when(libvirtComputingResource.createVMFromSpec(vmSpec)).thenReturn(vmDef); + + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); + try { + when(libvirtUtilitiesHelper.getConnectionByType(vmDef.getHvsType())).thenReturn(conn); + doThrow(URISyntaxException.class).when(libvirtComputingResource).createVbd(conn, vmSpec, vmName, vmDef); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } catch (final InternalErrorException e) { + fail(e.getMessage()); + } catch (final URISyntaxException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + verify(libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper(); + try { + verify(libvirtUtilitiesHelper, times(1)).getConnectionByType(vmDef.getHvsType()); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + + @Test + public void testStartCommand() { + final VirtualMachineTO vmSpec = Mockito.mock(VirtualMachineTO.class); + final com.cloud.host.Host host = Mockito.mock(com.cloud.host.Host.class); + final boolean executeInSequence = false; + + final StartCommand command = new StartCommand(vmSpec, host, executeInSequence); + + final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); + final Connect conn = Mockito.mock(Connect.class); + final LibvirtVMDef vmDef = Mockito.mock(LibvirtVMDef.class); + final VirtualRoutingResource virtRouterResource = Mockito.mock(VirtualRoutingResource.class); + + final NicTO nic = Mockito.mock(NicTO.class); + final NicTO[] nics = new NicTO[]{nic}; + + final String vmName = "Test"; + final String controlIp = "169.122.10.10"; + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr); + when(vmSpec.getNics()).thenReturn(nics); + when(vmSpec.getType()).thenReturn(VirtualMachine.Type.DomainRouter); + when(vmSpec.getName()).thenReturn(vmName); + when(libvirtComputingResource.createVMFromSpec(vmSpec)).thenReturn(vmDef); + + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); + try { + when(libvirtUtilitiesHelper.getConnectionByType(vmDef.getHvsType())).thenReturn(conn); + doNothing().when(libvirtComputingResource).createVbd(conn, vmSpec, vmName, vmDef); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } catch (final InternalErrorException e) { + fail(e.getMessage()); + } catch (final URISyntaxException e) { + fail(e.getMessage()); + } + + when(storagePoolMgr.connectPhysicalDisksViaVmSpec(vmSpec)).thenReturn(true); + try { + doNothing().when(libvirtComputingResource).createVifs(vmSpec, vmDef); + + when(libvirtComputingResource.startVM(conn, vmName, vmDef.toString())).thenReturn("SUCCESS"); + + when(vmSpec.getBootArgs()).thenReturn("ls -lart"); + when(libvirtComputingResource.passCmdLine(vmName, vmSpec.getBootArgs())).thenReturn(true); + + when(nic.getIp()).thenReturn(controlIp); + when(nic.getType()).thenReturn(TrafficType.Control); + when(libvirtComputingResource.getVirtRouterResource()).thenReturn(virtRouterResource); + when(virtRouterResource.connect(controlIp, 1, 5000)).thenReturn(true); + } catch (final InternalErrorException e) { + fail(e.getMessage()); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + verify(libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper(); + try { + verify(libvirtUtilitiesHelper, times(1)).getConnectionByType(vmDef.getHvsType()); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } + + @Test + public void testStartCommandIsolationEc2() { + final VirtualMachineTO vmSpec = Mockito.mock(VirtualMachineTO.class); + final com.cloud.host.Host host = Mockito.mock(com.cloud.host.Host.class); + final boolean executeInSequence = false; + + final StartCommand command = new StartCommand(vmSpec, host, executeInSequence); + + final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); + final Connect conn = Mockito.mock(Connect.class); + final LibvirtVMDef vmDef = Mockito.mock(LibvirtVMDef.class); + final VirtualRoutingResource virtRouterResource = Mockito.mock(VirtualRoutingResource.class); + + final NicTO nic = Mockito.mock(NicTO.class); + final NicTO[] nics = new NicTO[]{nic}; + + final String vmName = "Test"; + final String controlIp = "169.122.10.10"; + + when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr); + when(vmSpec.getNics()).thenReturn(nics); + when(vmSpec.getType()).thenReturn(VirtualMachine.Type.DomainRouter); + when(vmSpec.getName()).thenReturn(vmName); + when(libvirtComputingResource.createVMFromSpec(vmSpec)).thenReturn(vmDef); + + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); + try { + when(libvirtUtilitiesHelper.getConnectionByType(vmDef.getHvsType())).thenReturn(conn); + doNothing().when(libvirtComputingResource).createVbd(conn, vmSpec, vmName, vmDef); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } catch (final InternalErrorException e) { + fail(e.getMessage()); + } catch (final URISyntaxException e) { + fail(e.getMessage()); + } + + when(storagePoolMgr.connectPhysicalDisksViaVmSpec(vmSpec)).thenReturn(true); + try { + doNothing().when(libvirtComputingResource).createVifs(vmSpec, vmDef); + + when(libvirtComputingResource.startVM(conn, vmName, vmDef.toString())).thenReturn("SUCCESS"); + + when(nic.isSecurityGroupEnabled()).thenReturn(true); + when(nic.getIsolationUri()).thenReturn(new URI("ec2://test")); + + + when(vmSpec.getBootArgs()).thenReturn("ls -lart"); + when(libvirtComputingResource.passCmdLine(vmName, vmSpec.getBootArgs())).thenReturn(true); + + when(nic.getIp()).thenReturn(controlIp); + when(nic.getType()).thenReturn(TrafficType.Control); + when(libvirtComputingResource.getVirtRouterResource()).thenReturn(virtRouterResource); + when(virtRouterResource.connect(controlIp, 1, 5000)).thenReturn(true); + } catch (final InternalErrorException e) { + fail(e.getMessage()); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } catch (final URISyntaxException e) { + fail(e.getMessage()); + } + + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, libvirtComputingResource); + assertTrue(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getStoragePoolMgr(); + verify(libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper(); + try { + verify(libvirtUtilitiesHelper, times(1)).getConnectionByType(vmDef.getHvsType()); + } catch (final LibvirtException e) { + fail(e.getMessage()); + } + } } \ No newline at end of file From b284b841929c74a8e5273f8a31a26ed9bba5d139 Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Wed, 6 May 2015 16:55:03 +0200 Subject: [PATCH 035/175] Fixing method call on KVMGuru to reach StorageSubSystemCommand --- .../cloudstack/storage/command/StorageSubSystemCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/org/apache/cloudstack/storage/command/StorageSubSystemCommand.java b/core/src/org/apache/cloudstack/storage/command/StorageSubSystemCommand.java index 6507bb08ccdf..f50a5fb5759a 100644 --- a/core/src/org/apache/cloudstack/storage/command/StorageSubSystemCommand.java +++ b/core/src/org/apache/cloudstack/storage/command/StorageSubSystemCommand.java @@ -22,5 +22,5 @@ import com.cloud.agent.api.Command; public abstract class StorageSubSystemCommand extends Command { - abstract void setExecuteInSequence(boolean inSeq); + public abstract void setExecuteInSequence(boolean inSeq); } \ No newline at end of file From fcd74d5fefa890d6f39fa22a99a831bca04e7984 Mon Sep 17 00:00:00 2001 From: Gaurav Aradhye Date: Fri, 8 May 2015 19:39:37 +0530 Subject: [PATCH 036/175] CLOUDSTACK-8453: Fix DB result check in test_VirtualRouter_alerts.py Signed-off-by: Gaurav Aradhye This closes #239 --- test/integration/component/test_VirtualRouter_alerts.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/integration/component/test_VirtualRouter_alerts.py b/test/integration/component/test_VirtualRouter_alerts.py index bb3b12959be1..64066f8e357a 100644 --- a/test/integration/component/test_VirtualRouter_alerts.py +++ b/test/integration/component/test_VirtualRouter_alerts.py @@ -203,9 +203,9 @@ def test_01_VRServiceFailureAlerting(self): # 30minutes) qresultset = self.dbclient.execute( - "select id from alert where subject \ - = '%s' ORDER BY id DESC LIMIT 1;" % - str(alertSubject)) + "select id from alert where subject like\ + '%{0}%' ORDER BY id DESC LIMIT 1;".format( + str(alertSubject))) self.assertNotEqual( len(qresultset), 0, From f575206ad4348fb7fc0fe312a1e797bac23d011b Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Fri, 8 May 2015 19:53:03 +0200 Subject: [PATCH 037/175] Fixing testModifySshKeysCommand in the LibvirtComputingResourceTest class - The test was okay, but when running in an environment where a /root/.ssh/id_rsa existed, it would return true then fail - We now mock the calls to methods that return the key paths, instead of relying in the static variables --- .../LibvirtModifySshKeysCommandWrapper.java | 27 ++++++++++++------- .../wrapper/LibvirtUtilitiesHelper.java | 13 +++++++++ .../LibvirtComputingResourceTest.java | 7 +++++ 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtModifySshKeysCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtModifySshKeysCommandWrapper.java index d5943c5f034a..1295e7d3e542 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtModifySshKeysCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtModifySshKeysCommandWrapper.java @@ -38,21 +38,28 @@ public final class LibvirtModifySshKeysCommandWrapper extends CommandWrapper Date: Sat, 2 May 2015 19:30:02 +0200 Subject: [PATCH 038/175] Added hu to the language list Signed-off-by: Laszlo Hornyak Signed-off-by: Rohit Yadav This closes #237 --- tools/transifex/sync-transifex-ui.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/transifex/sync-transifex-ui.sh b/tools/transifex/sync-transifex-ui.sh index 8f24642413cf..b0487446ad6c 100755 --- a/tools/transifex/sync-transifex-ui.sh +++ b/tools/transifex/sync-transifex-ui.sh @@ -17,7 +17,7 @@ # under the License. SRCLANG=en -LIST_LANG="ar ca de_DE es fr_FR it_IT ja_JP ko_KR nb_NO nl_NL pl pt_BR ru_RU zh_CN" +LIST_LANG="ar ca de_DE es fr_FR it_IT ja_JP ko_KR nb_NO nl_NL pl pt_BR ru_RU zh_CN hu" DIRECTORY_RESOURCES="../../client/WEB-INF/classes/resources" WORKDIR="./work-dir" From cb1f25d17fec38ea3ddc556b749d265fb0e22d38 Mon Sep 17 00:00:00 2001 From: Laszlo Hornyak Date: Sat, 2 May 2015 18:10:52 +0200 Subject: [PATCH 039/175] CSS for the hungarian localization Signed-off-by: Laszlo Hornyak Signed-off-by: Rohit Yadav --- ui/css/cloudstack3.hu.css | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 ui/css/cloudstack3.hu.css diff --git a/ui/css/cloudstack3.hu.css b/ui/css/cloudstack3.hu.css new file mode 100644 index 000000000000..77259e14d57a --- /dev/null +++ b/ui/css/cloudstack3.hu.css @@ -0,0 +1,26 @@ +/* +* 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. +*/ + +/* + * correct the breadcrumbs, hungarian translation is longer + * than the english default. + */ +#breadcrumbs div.home { + width: 100px; +} From e77226b07b589dfc2d72a4ef194d67c1af452f1f Mon Sep 17 00:00:00 2001 From: Laszlo Hornyak Date: Fri, 1 May 2015 19:42:02 +0200 Subject: [PATCH 040/175] added hungarian to the list of localized languages Signed-off-by: Laszlo Hornyak Signed-off-by: Rohit Yadav --- client/WEB-INF/classes/resources/messages.properties | 1 + ui/dictionary.jsp | 1 + ui/index.jsp | 1 + 3 files changed, 3 insertions(+) diff --git a/client/WEB-INF/classes/resources/messages.properties b/client/WEB-INF/classes/resources/messages.properties index b05bb784b393..54ac2f3fe3a0 100644 --- a/client/WEB-INF/classes/resources/messages.properties +++ b/client/WEB-INF/classes/resources/messages.properties @@ -740,6 +740,7 @@ label.lang.norwegian=Norwegian label.lang.polish=Polish label.lang.russian=Russian label.lang.spanish=Spanish +label.lang.hungarian=Hungarian label.last.disconnected=Last Disconnected label.last.name=Last Name label.latest.events=Latest events diff --git a/ui/dictionary.jsp b/ui/dictionary.jsp index a967c9044d19..63d22bd7c17c 100644 --- a/ui/dictionary.jsp +++ b/ui/dictionary.jsp @@ -744,6 +744,7 @@ dictionary = { 'label.lang.japanese': '', 'label.lang.korean': '', 'label.lang.spanish': '', +'label.lang.hungarian': '', 'label.last.disconnected': '', 'label.last.name': '', 'label.latest.events': '', diff --git a/ui/index.jsp b/ui/index.jsp index ca8eb3cabfb5..aa20dbf5aa66 100644 --- a/ui/index.jsp +++ b/ui/index.jsp @@ -88,6 +88,7 @@ + From d75ce3f5cd99d9d0d33825dba80f5d5c7012fd40 Mon Sep 17 00:00:00 2001 From: Milamber Date: Sat, 9 May 2015 08:37:09 +0200 Subject: [PATCH 041/175] Update L10N resource files on master branch (with 4.6 translation strings from Transifex) Add new HU resource file for Hungarian translation --- .../resources/messages_de_DE.properties | 68 +- .../classes/resources/messages_es.properties | 1 - .../resources/messages_fr_FR.properties | 4 +- .../classes/resources/messages_hu.properties | 2044 +++++++++++++++++ .../resources/messages_it_IT.properties | 1 - .../resources/messages_ja_JP.properties | 53 +- .../resources/messages_ko_KR.properties | 1 - .../resources/messages_nb_NO.properties | 68 +- .../resources/messages_nl_NL.properties | 1 - .../classes/resources/messages_pl.properties | 1 - .../resources/messages_pt_BR.properties | 1 - .../resources/messages_ru_RU.properties | 1 - .../resources/messages_zh_CN.properties | 1 - tools/transifex/.tx/config | 1 + 14 files changed, 2218 insertions(+), 28 deletions(-) create mode 100644 client/WEB-INF/classes/resources/messages_hu.properties diff --git a/client/WEB-INF/classes/resources/messages_de_DE.properties b/client/WEB-INF/classes/resources/messages_de_DE.properties index 91342aa9334f..5980a69930a3 100644 --- a/client/WEB-INF/classes/resources/messages_de_DE.properties +++ b/client/WEB-INF/classes/resources/messages_de_DE.properties @@ -15,6 +15,7 @@ # specific language governing permissions and limitations # under the License. +changed.item.properties=Ge\u00e4nderte Eintragseigenschaften error.could.not.enable.zone=Zone konnte nicht aktiviert werden error.installWizard.message=Ein Fehler ist aufgetreten; Sie k\u00f6nnen zur\u00fcckgehen und den Fehler korregieren error.invalid.username.password=Ung\u00fcltiger Benutzername oder ung\u00fcltiges Passwort @@ -59,6 +60,8 @@ label.action.change.password=Passwort \u00e4ndern label.action.change.service=Dienst \u00e4ndern label.action.change.service.processing=Dienst wird gewechselt.... label.action.copy.ISO=ISO kopieren +label.action.copy.ISO.processing=ISO wird kopiert.... +label.action.copy.template.processing=Vorlage wird kopiert.... label.action.copy.template=Vorlage kopieren label.action.create.template.from.vm=Erstelle Vorlage aus VM label.action.create.template.from.volume=Vorlage vom Volumen erstellen @@ -193,7 +196,6 @@ label.action.reboot.router=Router neu starten label.action.reboot.systemvm.processing=System-VM wird neu gebootet.... label.action.reboot.systemvm=System-VM neu starten label.action.register.iso=ISO registrieren -label.action.register.template=Vorlage registrieren label.action.release.ip=IP ver\u00f6ffentlichen label.action.release.ip.processing=IP wird ver\u00f6ffentlicht.... label.action.remove.host=Host entfernen @@ -205,6 +207,7 @@ label.action.resize.volume=Volumengr\u00f6\u00dfe \u00e4ndern label.action.resource.limits=Grenzen der Ressourcen label.action.restore.instance=Instanz wiederherstellen label.action.restore.instance.processing=Instanz wird wiederhergestellt.... +label.action.revert.snapshot=Auf Schnappschuss zur\u00fcckkehren label.actions=Aktionen label.action.start.instance=Instanz beginnen label.action.start.instance.processing=Instanz wird gestartet.... @@ -226,6 +229,8 @@ label.action.update.OS.preference=Betriebssystem Pr\u00e4verenz aktualisieren label.action.update.OS.preference.processing=Betriebssystemeinstellung wird aktualisiert.... label.action.update.resource.count.processing=Ressourcenanzahl wird aktualisiert.... label.action.update.resource.count=Ressourcenanzahl aktualisieren +label.action.vmsnapshot.create=VM-Schnappschuss machen +label.action.vmsnapshot.delete=VM-Schnappschuss l\u00f6schen label.activate.project=Projekt aktivieren label.active.sessions=Aktive Sitzungen label.add.account=Konto hinzuf\u00fcgen @@ -316,6 +321,9 @@ label.agent.password=Agent-Passwort label.agent.port=Agent-Port label.agent.username=Agent-Benutzername label.agree=Zustimmen +label.alert.archived=Alarm archiviert +label.alert.deleted=Alarm gel\u00f6scht +label.alert.details=Alarmdetails label.alert=Warnung label.algorithm=Algorithmus label.allocated=Zugeteilt @@ -326,6 +334,7 @@ label.api.version=API-Version label.apply=Anwenden label.app.name=CloudStack label.archive.alerts=Alarme archivieren +label.archive=Archiv label.archive.events=Ereignisse archivieren label.assign.to.load.balancer=Instanz zum Lastverteiler hinzuf\u00fcgen label.assign=Zuweisen @@ -382,7 +391,7 @@ label.ciscovnmc.resource.details=CiscoVNMC-Ressourcendetails label.clean.up=Bereinigen label.clear.list=Liste l\u00f6schen label.close=Schliessen -label.cloud.console=Cloud Management Konsole +label.cloud.console=Cloud Verwaltungskonsole label.cloud.managed=Geleitet von cloud.com label.cluster=Cluster label.cluster.name=Clustername @@ -402,6 +411,7 @@ label.congratulations=Herzlichen Gl\u00fcckwunsch label.console.proxy=Konsolenproxy label.console.proxy.vm=Konsolenproxy-VM label.continue=Fortsetzen +label.copying.iso=ISO wird kopiert label.corrections.saved=Korrekturen gespeichert label.counter=Z\u00e4hler label.cpu.allocated=Zugeteilte CPU @@ -519,6 +529,7 @@ label.error.upper=FEHLER label.ESP.encryption=ESP-Verschl\u00fcsselung label.ESP.hash=ESP-Pr\u00fcfsumme label.ESP.lifetime=ESP-Lebensdauer (Sekunde) +label.ESP.policy=ESP-Richtlinie label.esx.host=ESX / ESXi-Host label.event.archived=Ereignis archiviert label.event.deleted=Ereignis gel\u00f6scht @@ -575,6 +586,7 @@ label.guest.ip.range=Gast-IP-Bereich label.guest.netmask=Gast Netzmaske label.guest.network.details=Gastnetzwerkdetails label.guest.networks=Gastnetzwerke +label.guest.traffic=Gast-Datenverkehr label.guest.type=Gasttyp label.ha.enabled=HA aktiviert label.help=Hilfe @@ -597,6 +609,7 @@ label.id=Identifikation label.IKE.encryption=IKE-Verschl\u00fcsselung label.IKE.hash=IKE-Pr\u00fcfsumme label.IKE.lifetime=IKE-Lebensdauer (Sekunde) +label.IKE.policy=IKE-Richtlinie label.info=Info label.info.upper=INFO label.ingress.rule=Zutrittsregel @@ -663,6 +676,7 @@ label.isolation.mode=Isolationsmodus label.is.redundant.router=Redundant label.is.shared=Gemeinsam label.is.system=Ist System +label.item.listing=Eintragsauflistung label.japanese.keyboard=Japanische Tastatur label.keep=Behalten label.keep.colon=Behalten\: @@ -691,6 +705,7 @@ label.last.name=Nachname label.latest.events=Neueste Ereignisse label.launch=Start label.launch.vm=VM starten +label.lb.algorithm.roundrobin=Rundlauf-Verfahren label.lb.algorithm.source=Quelle label.ldap.configuration=LDAP-Konfiguration label.ldap.group.name=LDAP-Gruppe @@ -770,11 +785,16 @@ label.menu.virtual.resources=Virtuelle Ressourcen label.menu.volumes=Volumina label.menu.vpc.offerings=VPC-Angebote label.migrate.instance.to.host=Instanz auf einen anderen Host migrieren +label.migrate.instance.to=Instanz migrieren zu label.migrate.instance.to.ps=Instanz auf einen anderen Speicher migrieren label.migrate.lb.vm=LB-VM migrieren +label.migrate.router.to=Router migrieren zu +label.migrate.systemvm.to=System-VM migrieren zu +label.migrate.to.host=Zu Host migrieren label.migrate.volume=Volumen migrieren label.minimum=Minimum label.min.past.the.hr=min seit Std. vergangen +label.minute.past.hour=Minute(n) seit der Stunde vergangen label.minutes.past.hour=Minute(n) seit der Stunde vergangen label.mode=Modus label.monday=Montag @@ -851,6 +871,7 @@ label.ok=OK label.openDaylight=OpenDaylight label.operator=Betreiber label.optional=optional +label.order=Reihenfolge label.os.preference=OS Pr\u00e4ferenz label.os.type=OS Typ label.override.guest.traffic=Gast-Datenverkehr \u00fcberschreiben @@ -873,6 +894,7 @@ label.physical.network=Physikalisches Netzwerk label.PING.CIFS.password=PING CIFS Passwort label.PING.CIFS.username=PING CIFS Benutzername label.PING.dir=PING-Verzeichnis +label.ping.path=Ping-Pfad label.PING.storage.IP=IP des externen Speichers anpingen label.please.wait=Bitte warten label.pod=Pod @@ -881,6 +903,7 @@ label.portable.ip=Portable IP label.portable.ip.range.details=Portable IP-Bereichsdetails label.portable.ip.ranges=Portable IP-Bereiche label.portable.ips=Portable IPs +label.port.forwarding.policies=Portweiterleitungsrichtlinien label.port.forwarding=Portweiterleitung label.port=Port label.port.range=Portbereich @@ -942,6 +965,8 @@ label.remove.ACL=ACL entfernen label.remove.ip.range=IP-Bereich entfernen label.remove.ldap=LDAP entfernen label.remove.network.offering=Netzwerkangebot entfernen +label.remove.pf=Portweiterleitungsregel entfernen +label.remove.project.account=Konto aus Projekt entfernen label.remove.region=Region entfernen label.remove.rule=Regel entfernen label.remove.vmware.datacenter=VMware-Rechenzentrum entfernen @@ -1034,6 +1059,7 @@ label.snapshot.limits=Schnappschuss Grenzen label.snapshot.name=Schnappschuss Name label.snapshot=Schnappschuss label.snapshots=Schnappsch\u00fcsse +label.snapshot.s=Schnappschuss (Schnappsch\u00fcsse) label.SNMP.port=SNMP-Port label.sockets=CPU-Sockets label.specify.IP.ranges=IP-Bereiche angeben @@ -1046,6 +1072,7 @@ label.start.IP=Start-IP label.start.lb.vm=LB-VM starten label.start.port=Startport label.start.reserved.system.IP=Reservierte System-IP starten +label.start.vxlan=VXLAN starten label.state=Status label.static.nat=Statische NAT label.statistics=Statistiken @@ -1072,9 +1099,10 @@ label.stopped.vms=Gestoppte VMs label.stop=Stopp label.storage=Speicherung label.storage.tags=Datenspeicher-Markierung +label.storage.traffic=Datenspeicherverkehr label.storage.type=Speichertyp +label.submit=Absenden label.submitted.by=[Eingereicht von\: ] -label.submit=\u00dcberreichen label.succeeded=Erfolgreich label.sunday=Sonntag label.supported.services=Unterst\u00fctzte Dienste @@ -1085,18 +1113,19 @@ label.system.vm.details=System-VM-Details label.system.vms=System-VMs label.system.vm=System-VM label.system.vm.type=System-VM-Typ +label.system.wide.capacity=Systemweite Kapazit\u00e4t label.tagged=Markiert label.tag.key=Schlagwortschl\u00fcssel label.tags=Markierungen label.tag.value=Schlagwortwert -label.target.iqn=Ziel IQN +label.target.iqn=Ziel-IQN label.task.completed=Aufgabe fertiggestellt -label.template.limits=Vorlagen Grenzen +label.template.limits=Vorlagenbegrenzungen label.template=Vorlage label.TFTP.dir=TFTP-Verzeichnis label.theme.default=Motiv-Standardeinstellung -label.theme.grey=personalisiertes - grau -label.theme.lightblue=personalisiertes - hellblau +label.theme.grey=Benutzerdefiniert - Grau +label.theme.lightblue=Benutzerdefiniert - Hellblau label.threshold=Schwellenwert label.thursday=Donnerstag label.time.colon=Zeit\: @@ -1109,24 +1138,26 @@ label.timezone=Zeitzone label.token=Token label.total.cpu=Gesamtanzahl CPU label.total.CPU=Gesamtanzahl CPU +label.total.hosts=Gesamtanzahl Hosts label.total.memory=Gesamter Speicher -label.total.of.vm=Insgesamte VMs +label.total.of.vm=Gesamtanzahl VMs label.total.storage=Gesamter Speicher -label.total.vms=Insgesamte VMs -label.traffic.type=Traffic Typ +label.total.vms=Gesamtanzahl VMs +label.traffic.type=Datenverkehrstyp +label.traffic.types=Datenverkehrstypen label.tuesday=Dienstag -label.type.id=Typ ID +label.type.id=Typenkennung label.type.lower=Typ label.type=Typ label.ucs=UCS label.uk.keyboard=UK-Tastatur -label.unavailable=nichtverf\u00fcgbar -label.unlimited=uneingeschr\u00e4nkt +label.unavailable=Nicht verf\u00fcgbar +label.unlimited=Unbegrenzt label.untagged=Unmarkiert label.update.project.resources=Projektressourcen aktualisieren label.update.ssl.cert= SSL-Zertifikat label.update.ssl= SSL-Zertifikat -label.updating=Aktualisierung +label.updating=Aktualisierungsvorgang label.upgrade.required=Aktualisierung ist erforderlich label.upload=Hochladen label.upload.volume=Volumen hochladen @@ -1218,6 +1249,7 @@ label.vpc=VPC label.VPN.connection=VPN-Verbindung label.VPN.gateway=VPN-Gateway label.vpn=VPN +label.vsmctrlvlanid=Steuerungs-VLAN-Kennung label.vsmpktvlanid=Paket-VLAN-Kennung label.vsmstoragevlanid=Speicher-VLAN-Kennung label.vswitch.name=vSwitch-Name @@ -1231,6 +1263,7 @@ label.warn.upper=WARNEN label.warn=Warnen label.wednesday=Mittwoch label.weekly=W\u00f6chentlich +label.welcome.cloud.console=Willkommen bei der Verwaltungskonsole label.welcome=Willkommen label.what.is.cloudstack=Was ist CloudStack&\#8482? label.xenserver.tools.version.61.plus=Originale XS-Version ist 6.1\\+ @@ -1368,12 +1401,19 @@ message.number.hosts=

\# of Hosts

message.number.storage=

\# von Hauptspeichervolumina

message.number.zones=

\# of Zonen

message.pending.projects.1=Sie haben ausstehende Projekteinladungen\: +message.please.select.a.configuration.for.your.zone=Bitte w\u00e4hlen Sie eine Konfiguration f\u00fcr Ihre Zone aus. +message.please.select.networks=Bitte w\u00e4hlen Sie Netzwerke f\u00fcr Ihre virtuelle Maschine aus. message.recover.vm=Bitte best\u00e4tigen Sie, dass Sie diese VM wiederherstellen m\u00f6chten. message.redirecting.region=Weiterleitung zu Region... message.remove.vpn.access=Bitte best\u00e4tigen Sie, dass Sie den VPN-Zugriff vom folgenden Benutzer entfernen m\u00f6chten. +message.reset.VPN.connection=Bitte best\u00e4tigen Sie, dass Sie die VPN-Verbindung zur\u00fccksetzen m\u00f6chten +message.restart.vpc=Bitte best\u00e4tigen Sie, dass Sie den VPC neu starten m\u00f6chten message.restoreVM=M\u00f6chten Sie die VM wiederherstellen? message.select.instance=Bitte w\u00e4hlen Sie eine Instanz aus. +message.select.iso=Bitte w\u00e4hlen Sie ein ISO f\u00fcr Ihre neue virtuelle Instanz aus. message.select.item=Bitte w\u00e4hlen Sie ein Element aus. +message.select.security.groups=Bitte w\u00e4hlen Sie (eine) Sicherheitsgruppe(n) f\u00fcr Ihre neue VM aus +message.select.template=Bitte w\u00e4hlen Sie eine Vorlage f\u00fcr Ihre neue virtuelle Instanz aus. message.setup.successful=Cloud setup erfolgreich message.specify.url=Bitte geben Sie eine URL an message.step.1.continue=Bitte w\u00e4hlen Sie eine Vorlage oder ISO, um fortzufahren diff --git a/client/WEB-INF/classes/resources/messages_es.properties b/client/WEB-INF/classes/resources/messages_es.properties index 032ddbe71ff8..345353177831 100644 --- a/client/WEB-INF/classes/resources/messages_es.properties +++ b/client/WEB-INF/classes/resources/messages_es.properties @@ -181,7 +181,6 @@ label.action.reboot.systemvm.processing=reinicio del sistema VM .... label.action.reboot.systemvm=Reiniciar sistema VM label.action.recurring.snapshot=recurrente instant\u00c3\u00a1neas label.action.register.iso=Registrar ISO -label.action.register.template=Registrar template label.action.release.ip=estreno IP label.action.release.ip.processing=Liberar IP .... label.action.remove.host.processing=Extracci\u00c3\u00b3n de host .... diff --git a/client/WEB-INF/classes/resources/messages_fr_FR.properties b/client/WEB-INF/classes/resources/messages_fr_FR.properties index 4ff9101fcfa3..54acfc84b79a 100644 --- a/client/WEB-INF/classes/resources/messages_fr_FR.properties +++ b/client/WEB-INF/classes/resources/messages_fr_FR.properties @@ -212,7 +212,7 @@ label.action.reboot.systemvm.processing=Red\u00e9marrage de la VM Syst\u00e8me.. label.action.reboot.systemvm=Red\u00e9marrer VM Syst\u00e8me label.action.recurring.snapshot=Instantan\u00e9s r\u00e9currents label.action.register.iso=Enregistrer ISO -label.action.register.template=Enregistrer mod\u00e8le +label.action.register.template=Enregistrer mod\u00e8le depuis une URL label.action.release.ip=Lib\u00e9rer l\\'adresse IP label.action.release.ip.processing=Lib\u00e9ration de l\\'adresse IP... label.action.remove.host.processing=Suppression de l\\'h\u00f4te... @@ -875,6 +875,7 @@ label.lang.dutch=N\u00e9erlandais label.lang.english=Anglais label.lang.french=Fran\u00e7ais label.lang.german=Allemand +label.lang.hungarian=Hongrois label.lang.italian=Italien label.lang.japanese=Japonais label.lang.korean=Cor\u00e9en @@ -2092,7 +2093,6 @@ state.Destroyed=Supprim\u00e9e state.detached=D\u00e9tach\u00e9 state.Disabled=D\u00e9sactiv\u00e9 state.Enabled=Actifs -state.enabled=Activ\u00e9 state.Error=Erreur state.Expunging=Purge en cours state.Migrating=Migration en cours diff --git a/client/WEB-INF/classes/resources/messages_hu.properties b/client/WEB-INF/classes/resources/messages_hu.properties new file mode 100644 index 000000000000..3904234ab152 --- /dev/null +++ b/client/WEB-INF/classes/resources/messages_hu.properties @@ -0,0 +1,2044 @@ +# 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. + +changed.item.properties=Az elem tulajdons\u00e1gai megv\u00e1ltoztak +confirm.enable.s3=T\u00f6ltsd ki a k\u00f6vetkez\u0151 inform\u00e1ci\u00f3kat az S3 m\u00e1sodlagos t\u00e1r bekapcsol\u00e1s\u00e1hoz\! +confirm.enable.swift=T\u00f6ltsd ki a k\u00f6vetkez\u0151 inform\u00e1ci\u00f3kat a Swift t\u00e1mogat\u00e1s bekapcsol\u00e1s\u00e1hoz\! +error.could.not.change.your.password.because.ldap.is.enabled=Nem siker\u00fclt megv\u00e1ltoztatni a jelszavadat, mert az LDAP be van kapcsolva. +error.could.not.enable.zone=A z\u00f3na enged\u00e9lyez\u00e9se sikertelen +error.installWizard.message=Valami nem siker\u00fclt, visszamehetsz kijav\u00edtani a hib\u00e1kat. +error.invalid.username.password=\u00c9rv\u00e9nytelen felhaszn\u00e1l\u00f3n\u00e9v vagy jelsz\u00f3 +error.login=A felhaszn\u00e1l\u00f3n\u00e9v/jelsz\u00f3 p\u00e1r nem \u00e9rv\u00e9nyes. +error.menu.select=A m\u0171velet nem hajthat\u00f3 v\u00e9gre, mert nincsenek kiv\u00e1lasztott elemek. +error.mgmt.server.inaccessible=A vez\u00e9rl\u0151 szerver nem \u00e9rhet\u0151 el. Pr\u00f3b\u00e1ld \u00fajra k\u00e9s\u0151bb\! +error.password.not.match=A jelszavak nem egyeznek. +error.please.specify.physical.network.tags=Network offerings is not available until you specify tags for this physical network. +error.session.expired=A munkamenet lej\u00e1rt. +error.something.went.wrong.please.correct.the.following=Valami nem j\u00f3\! Jav\u00edtsd a k\u00f6vetkez\u0151ket\: +error.unable.to.reach.management.server=A vez\u00e9rl\u0151 szerver nem el\u00e9rhet\u0151 +error.unresolved.internet.name=Az internet neved nem oldhat\u00f3 fel. +force.delete.domain.warning=Warning\: Choosing this option will cause the deletion of all child domains and all associated accounts and their resources. +force.delete=T\u00f6rl\u00e9s kik\u00e9nyszer\u00edt\u00e9se +force.remove=Elt\u00e1vol\u00edt\u00e1s kik\u00e9nyszer\u00edt\u00e9se +force.remove.host.warning=Figyelmeztet\u00e9s\: Ha ezt az opci\u00f3t v\u00e1lasztod, a CloudStack minden virtu\u00e1lis g\u00e9pet le\u00e1ll\u00edt miel\u0151tt elt\u00e1vol\u00edtja a kiszolg\u00e1l\u00f3t a f\u00fcrtb\u0151l. +force.stop.instance.warning=Figyelmeztet\u00e9s\: A p\u00e9ld\u00e1ny er\u0151szakos le\u00e1ll\u00edt\u00e1sa az utols\u00f3 lehet\u0151s\u00e9g. Ez adatveszt\u00e9shez \u00e9s a virtu\u00e1lis g\u00e9p inkonzisztens viselked\u00e9s\u00e9hez vezethet. +force.stop=Le\u00e1ll\u00e1s kik\u00e9nyszer\u00edt\u00e9se +ICMP.code=ICMP k\u00f3d +ICMP.type=ICMP t\u00edpus +image.directory=Image Directory +inline=Inline +instances.actions.reboot.label=P\u00e9ld\u00e1ny \u00fajraind\u00edt\u00e1sa +label.about.app=A CloudStack-r\u0151l +label.about=N\u00e9vjegy +label.accept.project.invitation=Project-megh\u00edv\u00f3 elfogad\u00e1sa +label.account.and.security.group=Account, Security group +label.account.id=Sz\u00e1mla azonos\u00edt\u00f3 +label.account.lower=sz\u00e1mla +label.account.name=Sz\u00e1mla n\u00e9v +label.account.specific=Account-Specific +label.accounts=Sz\u00e1ml\u00e1k +label.account=Sz\u00e1mla +label.acl=ACL +label.acl.id=ACL ID +label.acl.name=ACL n\u00e9v +label.acl.replaced=ACL lehelyettes\u00edtve +label.acquire.new.ip=\u00daj IP c\u00edm beszerz\u00e9se +label.acquire.new.secondary.ip=\u00daj m\u00e1sodlagos IP c\u00edm beszerz\u00e9se +label.action.attach.disk=Merevlemez csatlakoztat\u00e1sa +label.action.attach.disk.processing=Merevlemez csatlakoztat\u00e1sa... +label.action.attach.iso=ISO csatlakoztat\u00e1sa +label.action.attach.iso.processing=ISO csatlakoztat\u00e1sa... +label.action.cancel.maintenance.mode=Karbantart\u00e1si m\u00f3d megszak\u00edt\u00e1sa +label.action.cancel.maintenance.mode.processing=Karbantart\u00e1si m\u00f3d megszak\u00edt\u00e1sa... +label.action.change.password=Jelsz\u00f3 csere +label.action.change.service=Change Service +label.action.change.service.processing=Changing Service.... +label.action.copy.ISO=ISO m\u00e1sol\u00e1sa +label.action.copy.ISO.processing=ISO m\u00e1sol\u00e1sa... +label.action.copy.template.processing=Sablon m\u00e1sol\u00e1sa... +label.action.copy.template=Sablon m\u00e1sol\u00e1sa +label.action.create.template.from.vm=Sablon l\u00e9trehoz\u00e1sa VM-b\u0151l +label.action.create.template.from.volume=Sablon l\u00e9trehoz\u00e1sa k\u00f6tetb\u0151l +label.action.create.template.processing=Sablon l\u00e9trehoz\u00e1sa... +label.action.create.template=Sablon l\u00e9trehoz\u00e1sa +label.action.create.vm.processing=VM l\u00e9trehoz\u00e1sa... +label.action.create.vm=VM l\u00e9trehoz\u00e1sa +label.action.create.volume=K\u00f6tet l\u00e9trehoz\u00e1sa +label.action.create.volume.processing=K\u00f6tet l\u00e9trehoz\u00e1sa.... +label.action.delete.account.processing=Sz\u00e1mla t\u00f6rl\u00e9se... +label.action.delete.account=Sz\u00e1mla t\u00f6rl\u00e9se +label.action.delete.cluster=F\u00fcrt t\u00f6rl\u00e9se +label.action.delete.cluster.processing=F\u00fcrt t\u00f6rl\u00e9se... +label.action.delete.disk.offering.processing=T\u00e1r aj\u00e1nlat t\u00f6rl\u00e9se... +label.action.delete.disk.offering=T\u00e1r aj\u00e1nlat t\u00f6rl\u00e9se +label.action.delete.domain=Dom\u00e9n t\u00f6rl\u00e9se +label.action.delete.domain.processing=Dom\u00e9n t\u00f6rl\u00e9se... +label.action.delete.firewall.processing=T\u0171zfal t\u00f6rl\u00e9se... +label.action.delete.firewall=T\u0171zfal szab\u00e1ly t\u00f6rl\u00e9se +label.action.delete.ingress.rule=Delete Ingress Rule +label.action.delete.ingress.rule.processing=Deleting Ingress Rule.... +label.action.delete.IP.range=IP c\u00edmtartom\u00e1ny t\u00f6rl\u00e9se +label.action.delete.IP.range.processing=IP c\u00edmtartom\u00e1ny t\u00f6rl\u00e9se... +label.action.delete.ISO=ISO t\u00f6rl\u00e9se +label.action.delete.ISO.processing=ISO t\u00f6rl\u00e9se... +label.action.delete.load.balancer.processing=Terhel\u00e9seloszt\u00f3 t\u00f6rl\u00e9se... +label.action.delete.load.balancer=Terhel\u00e9seloszt\u00f3 szab\u00e1ly t\u00f6rl\u00e9se +label.action.delete.network=H\u00e1l\u00f3zat t\u00f6rl\u00e9se +label.action.delete.network.processing=H\u00e1l\u00f3zat t\u00f6rl\u00e9se... +label.action.delete.nexusVswitch=Nexus 1000v t\u00f6rl\u00e9se +label.action.delete.nic=NIC elt\u00e1vol\u00edt\u00e1sa +label.action.delete.physical.network=Fizikai h\u00e1l\u00f3zat t\u00f6rl\u00e9se +label.action.delete.pod=Pod t\u00f6rl\u00e9se +label.action.delete.pod.processing=Pod t\u00f6rl\u00e9se... +label.action.delete.primary.storage=Els\u0151dleges t\u00e1r t\u00f6rl\u00e9se +label.action.delete.primary.storage.processing=Els\u0151dleges t\u00e1r t\u00f6rl\u00e9se... +label.action.delete.secondary.storage=M\u00e1sodlagos t\u00e1r t\u00f6rl\u00e9se +label.action.delete.secondary.storage.processing=M\u00e1sodlagos t\u00e1r t\u00f6rl\u00e9se... +label.action.delete.security.group=Biztons\u00e1gi csoport t\u00f6rl\u00e9se +label.action.delete.security.group.processing=Biztons\u00e1gi csoport t\u00f6rl\u00e9se... +label.action.delete.service.offering=Delete Service Offering +label.action.delete.service.offering.processing=Deleting Service Offering.... +label.action.delete.snapshot=Pillanatfelv\u00e9tel t\u00f6rl\u00e9se +label.action.delete.snapshot.processing=Pillanatfelv\u00e9tel t\u00f6rl\u00e9se... +label.action.delete.system.service.offering=Delete System Service Offering +label.action.delete.template.processing=Sablon t\u00f6rl\u00e9se... +label.action.delete.template=Sablon t\u00f6rl\u00e9se +label.action.delete.user=Felhaszn\u00e1l\u00f3 t\u00f6rl\u00e9se +label.action.delete.user.processing=Felhaszn\u00e1l\u00f3 t\u00f6rl\u00e9se... +label.action.delete.volume=K\u00f6tet t\u00f6rl\u00e9se +label.action.delete.volume.processing=K\u00f6tet t\u00f6rl\u00e9se... +label.action.delete.zone.processing=Z\u00f3na t\u00f6rl\u00e9se... +label.action.delete.zone=Z\u00f3na t\u00f6rl\u00e9se +label.action.destroy.instance.processing=P\u00e9ld\u00e1ny elpuszt\u00edt\u00e1sa... +label.action.destroy.instance=P\u00e9ld\u00e1ny elpuszt\u00edt\u00e1sa +label.action.destroy.systemvm.processing=Rendszer VM elpuszt\u00edt\u00e1sa... +label.action.destroy.systemvm=Rendszer VM elpuszt\u00edt\u00e1sa +label.action.detach.disk=Merevlemez lev\u00e1laszt\u00e1sa +label.action.detach.disk.processing=Merevlemez lev\u00e1laszt\u00e1sa... +label.action.detach.iso=ISO lev\u00e1laszt\u00e1sa +label.action.detach.iso.processing=ISO lev\u00e1laszt\u00e1sa... +label.action.disable.account.processing=Sz\u00e1mla kikapcsol\u00e1sa... +label.action.disable.account=Sz\u00e1mla kikapcsol\u00e1sa +label.action.disable.cluster=F\u00fcrt kikapcsol\u00e1sa +label.action.disable.cluster.processing=F\u00fcrt kikapcsol\u00e1sa... +label.action.disable.nexusVswitch=Disable Nexus 1000v +label.action.disable.physical.network=Disable physical network +label.action.disable.pod=Pod kikapcsol\u00e1sa +label.action.disable.pod.processing=Pod kikapcsol\u00e1sa... +label.action.disable.static.NAT.processing=Statikus NAT kikapcsol\u00e1sa... +label.action.disable.static.NAT=Statikus NAT kikapcsol\u00e1sa +label.action.disable.user=Felhaszn\u00e1l\u00f3 kikapcsol\u00e1sa +label.action.disable.user.processing=Felhaszn\u00e1l\u00f3 kikapcsol\u00e1sa... +label.action.disable.zone.processing=Z\u00f3na kikapcsol\u00e1sa... +label.action.disable.zone=Z\u00f3na kikapcsol\u00e1sa +label.action.download.ISO=ISO let\u00f6lt\u00e9se +label.action.download.template=Sablon let\u00f6lt\u00e9se +label.action.download.volume=K\u00f6tet let\u00f6lt\u00e9se +label.action.download.volume.processing=K\u00f6tet let\u00f6lt\u00e9se... +label.action.edit.account=Sz\u00e1mla enged\u00e9lyez\u00e9se +label.action.edit.disk.offering=Merevlemez aj\u00e1nlat szerkeszt\u00e9se +label.action.edit.domain=Edit Domain +label.action.edit.global.setting=Edit Global Setting +label.action.edit.host=Kiszolg\u00e1l\u00f3 szerkeszt\u00e9se +label.action.edit.instance=P\u00e9ld\u00e1ny szerkeszt\u00e9se +label.action.edit.ISO=ISO szerkeszt\u00e9se +label.action.edit.network=H\u00e1l\u00f3zat szerkeszt\u00e9se +label.action.edit.network.offering=H\u00e1l\u00f3zat aj\u00e1nlat szerkeszt\u00e9se +label.action.edit.network.processing=H\u00e1l\u00f3zat szerkeszt\u00e9se... +label.action.edit.pod=Pod szerkeszt\u00e9se +label.action.edit.primary.storage=Els\u0151dleges t\u00e1r szerkeszt\u00e9se +label.action.edit.resource.limits=Er\u0151forr\u00e1s korl\u00e1tok szerkeszt\u00e9se +label.action.edit.service.offering=Edit Service Offering +label.action.edit.template=Sablon szerkeszt\u00e9se +label.action.edit.user=Felhaszn\u00e1l\u00f3 szerkeszt\u00e9se +label.action.edit.zone=Z\u00f3na szerkeszt\u00e9se +label.action.enable.account.processing=Sz\u00e1mla szerkeszt\u00e9se... +label.action.enable.account=Sz\u00e1mla enged\u00e9lyez\u00e9se +label.action.enable.cluster=F\u00fcrt enged\u00e9lyez\u00e9se +label.action.enable.cluster.processing=F\u00fcrt enged\u00e9lyez\u00e9se... +label.action.enable.maintenance.mode=Karbantart\u00e1si \u00fczemm\u00f3d enged\u00e9lyez\u00e9se +label.action.enable.maintenance.mode.processing=Karbantart\u00e1si \u00fczemm\u00f3d enged\u00e9lyez\u00e9se... +label.action.enable.nexusVswitch=Enable Nexus 1000v +label.action.enable.physical.network=Enable physical network +label.action.enable.pod=Pod bekapcsol\u00e1sa +label.action.enable.pod.processing=Pod bekapcsol\u00e1sa... +label.action.enable.static.NAT.processing=Enabling Static NAT.... +label.action.enable.static.NAT=Statikus NAT bekapcsol\u00e1sa +label.action.enable.user=Felhaszn\u00e1l\u00f3 bekapcsol\u00e1sa +label.action.enable.user.processing=Felhaszn\u00e1l\u00f3 bekapcsol\u00e1sa... +label.action.enable.zone.processing=Z\u00f3na bekapcsol\u00e1sa.... +label.action.enable.zone=Z\u00f3na bekapcsol\u00e1sa +label.action.expunge.instance=Expunge Instance +label.action.expunge.instance.processing=Expunging Instance.... +label.action.force.reconnect.processing=\u00dajrakapcsol\u00f3d\u00e1s... +label.action.force.reconnect=\u00dajracsatlakoz\u00e1s kik\u00e9nyszer\u00edt\u00e9se +label.action.generate.keys=Kulcsgener\u00e1l\u00e1s +label.action.generate.keys.processing=Kulcsgener\u00e1l\u00e1s.... +label.action.list.nexusVswitch=Nexus 1000v lista +label.action.lock.account.processing=Sz\u00e1mla z\u00e1r\u00e1sa... +label.action.lock.account=Sz\u00e1mla z\u00e1r\u00e1sa +label.action.manage.cluster=F\u00fcrt vez\u00e9rl\u00e9se +label.action.manage.cluster.processing=F\u00fcrt vez\u00e9rl\u00e9se... +label.action.migrate.instance.processing=P\u00e9ld\u00e1ny mozgat\u00e1sa... +label.action.migrate.instance=P\u00e9ld\u00e1ny k\u00f6lt\u00f6ztet\u00e9se +label.action.migrate.router.processing=Router mozgat\u00e1sa... +label.action.migrate.router=Router k\u00f6lt\u00f6ztet\u00e9se +label.action.migrate.systemvm.processing=Rendszer VM mozgat\u00e1sa... +label.action.migrate.systemvm=Rendszer VM k\u00f6lt\u00f6ztet\u00e9se +label.action=M\u0171velet +label.action.reboot.instance.processing=P\u00e9ld\u00e1ny \u00fajraind\u00edt\u00e1sa +label.action.reboot.instance=P\u00e9ld\u00e1ny \u00fajraind\u00edt\u00e1sa +label.action.reboot.router.processing=Router \u00fajraind\u00edt\u00e1sa... +label.action.reboot.router=Router \u00fajraind\u00edt\u00e1sa +label.action.reboot.systemvm.processing=Rendszer VM \u00fajraind\u00edt\u00e1sa +label.action.reboot.systemvm=Rendszer VM \u00fajraind\u00edt\u00e1sa +label.action.recurring.snapshot=Ism\u00e9tl\u0151d\u0151 pillanatfelv\u00e9telek +label.action.register.iso=ISO regisztr\u00e1ci\u00f3ja +label.action.release.ip=IP c\u00edm elenged\u00e9se +label.action.release.ip.processing=IP c\u00edm elenged\u00e9se +label.action.remove.host=Kiszolg\u00e1l\u00f3 elt\u00e1vol\u00edt\u00e1sa +label.action.remove.host.processing=Kiszolg\u00e1l\u00f3 elt\u00e1vol\u00edt\u00e1sa... +label.action.reset.password=Jelsz\u00f3 \u00fajrabe\u00e1ll\u00edt\u00e1sa +label.action.reset.password.processing=Jelsz\u00f3 \u00fajrabe\u00e1ll\u00edt\u00e1sa... +label.action.resize.volume=K\u00f6tet \u00e1tm\u00e9retez\u00e9se +label.action.resize.volume.processing=K\u00f6tet \u00e1tm\u00e9retez\u00e9se +label.action.resource.limits=Er\u0151forr\u00e1s korl\u00e1tok +label.action.restore.instance.processing=P\u00e9ld\u00e1ny helyre\u00e1ll\u00edt\u00e1sa... +label.action.restore.instance=P\u00e9ld\u00e1ny helyre\u00e1ll\u00edt\u00e1sa +label.action.revert.snapshot.processing=Vissza\u00e1ll\u00e1s pillanatfelv\u00e9telre... +label.action.revert.snapshot=Vissza\u00e1ll\u00e1s pillanatfelv\u00e9telre +label.actions=Actions +label.action.start.instance.processing=P\u00e9ld\u00e1ny ind\u00edt\u00e1sa... +label.action.start.instance=P\u00e9ld\u00e1ny ind\u00edt\u00e1sa +label.action.start.router.processing=Router le\u00e1ll\u00edt\u00e1sa... +label.action.start.router=Router ind\u00edt\u00e1sa +label.action.start.systemvm.processing=Rendszer VM ind\u00edt\u00e1sa +label.action.start.systemvm=Rendszer VM ind\u00edt\u00e1sa +label.action.stop.instance.processing=P\u00e9ld\u00e1ny le\u00e1ll\u00edt\u00e1sa... +label.action.stop.instance=P\u00e9ld\u00e1ny le\u00e1ll\u00edt\u00e1sa +label.action.stop.router.processing=Router le\u00e1ll\u00edt\u00e1sa... +label.action.stop.router=Router le\u00e1ll\u00edt\u00e1sa +label.action.stop.systemvm.processing=Rendszer VM le\u00e1ll\u00edt\u00e1sa... +label.action.stop.systemvm=Rendszer VM le\u00e1ll\u00edt\u00e1sa +label.action.take.snapshot=Pillanatfelv\u00e9tel k\u00e9sz\u00edt\u00e9se +label.action.take.snapshot.processing=Pillanatfelv\u00e9tel k\u00e9sz\u00edt\u00e9se... +label.action.unmanage.cluster.processing=Unmanaging Cluster.... +label.action.unmanage.cluster=Unmanage Cluster +label.action.update.OS.preference.processing=Updating OS Preference.... +label.action.update.OS.preference=Update OS Preference +label.action.update.resource.count=Er\u0151forr\u00e1s sz\u00e1m m\u00f3dos\u00edt\u00e1sa +label.action.update.resource.count.processing=Er\u0151forr\u00e1s sz\u00e1m m\u00f3dos\u00edt\u00e1sa... +label.action.vmsnapshot.create=VM pillanatfelv\u00e9tel k\u00e9sz\u00edt\u00e9se +label.action.vmsnapshot.delete=VM pillanatfelv\u00e9tel k\u00e9sz\u00edt\u00e9se +label.action.vmsnapshot.revert=Vissza\u00e1ll\u00e1s VM pillanatfelv\u00e9telre +label.activate.project=Projekt aktiv\u00e1l\u00e1sa +label.active.sessions=Akt\u00edv munkamenetek +label.add.accounts=Add accounts +label.add.accounts.to=Sz\u00e1mla felv\u00e9tele\: +label.add.account=Sz\u00e1mla felv\u00e9tele +label.add.account.to.project=Sz\u00e1mla felv\u00e9tele a projekthez +label.add.ACL=ACL felv\u00e9tele +label.add.acl.list=Add ACL List +label.add.affinity.group=Add new affinity group +label.add.baremetal.dhcp.device=Add Baremetal DHCP Device +label.add.BrocadeVcs.device=Brocade Vcs Switch felv\u00e9tele +label.add.by=Add by +label.add.by.cidr=Add By CIDR +label.add.by.group=Add By Group +label.add.ciscoASA1000v=Add CiscoASA1000v Resource +label.add.cluster=F\u00fcrt felv\u00e9tele +label.add.compute.offering=CPU aj\u00e1nlat felv\u00e9tele +label.add.direct.iprange=IP tartom\u00e1ny felv\u00e9tele +label.add.disk.offering=Merevlemez aj\u00e1nlat felv\u00e9tele +label.add.domain=Add Domain +label.added.brocade.vcs.switch=Added new Brocade Vcs Switch +label.added.nicira.nvp.controller=Added new Nicira NVP Controller +label.add.egress.rule=Kimen\u0151 szab\u00e1ly felv\u00e9tele +label.addes.new.f5=Added new F5 +label.add.F5.device=F5 eszk\u00f6z felv\u00e9tele +label.add=Felv\u00e9tel +label.add.firewall=T\u0171zfal szab\u00e1ly felv\u00e9tele +label.add.gslb=Add GSLB +label.add.guest.network=Vend\u00e9g h\u00e1l\u00f3zat felv\u00e9tele +label.add.host=Kiszolg\u00e1l\u00f3 felv\u00e9tele +label.adding.cluster=F\u00fcrt felv\u00e9tele +label.adding.failed=Hiba a felv\u00e9tel sor\u00e1n +label.adding=Felv\u00e9tel +label.adding.pod=Pod felv\u00e9tele +label.adding.processing=Felv\u00e9tel... +label.add.ingress.rule=Add Ingress Rule +label.adding.succeeded=Sikeres felv\u00e9tel +label.adding.user=Felhaszn\u00e1l\u00f3 felv\u00e9tele +label.adding.zone=Z\u00f3na felv\u00e9tele +label.add.intermediate.certificate=Add intermediate certificate +label.add.internal.lb=Add Internal LB +label.add.ip.range=IP c\u00edmtartom\u00e1ny felv\u00e9tele +label.add.isolated.guest.network=Izol\u00e1lt vend\u00e9g h\u00e1l\u00f3zat felv\u00e9tele +label.add.isolated.network=Izol\u00e1lt h\u00e1l\u00f3zat felv\u00e9tele +label.additional.networks=Tov\u00e1bbi h\u00e1l\u00f3zatok +label.add.list.name=ACL List Name +label.add.load.balancer=Terhel\u00e9seloszt\u00f3 felv\u00e9tele +label.add.more=Tov\u00e1bbi felv\u00e9tele +label.add.netScaler.device=Netscaler eszk\u00f6z felv\u00e9tele +label.add.network.ACL=H\u00e1l\u00f3zati ACL felv\u00e9tele +label.add.network.acl.list=Add Network ACL List +label.add.network.device=Add Network Device +label.add.network=H\u00e1l\u00f3zat felv\u00e9tele +label.add.network.offering=Add network offering +label.add.new.F5=\u00daj F5 felv\u00e9tele +label.add.new.gateway=\u00daj \u00e1tj\u00e1r\u00f3 felv\u00e9tele +label.add.new.NetScaler=\u00daj NetScaler felv\u00e9tele +label.add.new.PA=\u00daj Palo Alto felv\u00e9tele +label.add.new.SRX=\u00daj SRX felv\u00e9tele +label.add.new.tier=\u00daj r\u00e9teg felv\u00e9tele +label.add.nfs.secondary.staging.store=Add NFS Secondary Staging Store +label.add.NiciraNvp.device=Nvp Controller felv\u00e9tele +label.add.NuageVsp.device=Nuage Virtualized Services Directory (VSD) felv\u00e9tele +label.add.OpenDaylight.device=OpenDaylight Controller hozz\u00e1ad\u00e1sa +label.add.PA.device=Palo Alto eszk\u00f6z felv\u00e9tele +label.add.physical.network=Fizikai h\u00e1l\u00f3zat felv\u00e9tele +label.add.pod=Pod felv\u00e9tele +label.add.portable.ip.range=Add Portable IP Range +label.add.port.forwarding.rule=Port tov\u00e1bb\u00edt\u00f3 szab\u00e1ly felv\u00e9tele +label.add.primary.storage=Els\u0151dleges t\u00e1r felv\u00e9tele +label.add.region=R\u00e9gi\u00f3 felv\u00e9tele +label.add.resources=Er\u0151forr\u00e1sok felv\u00e9tele +label.add.route=\u00datvonal felv\u00e9tele +label.add.rule=Szab\u00e1ly felv\u00e9tele +label.add.secondary.storage=M\u00e1sodlagos t\u00e1r felv\u00e9tele +label.add.security.group=Biztons\u00e1gi csoport felv\u00e9tele +label.add.service.offering=Szolg\u00e1ltat\u00e1s aj\u00e1nlat felv\u00e9tele +label.add.SRX.device=SRX szk\u00f6z felv\u00e9tele +label.add.static.nat.rule=Statikus NAT szab\u00e1ly felv\u00e9tele +label.add.static.route=Statikus \u00fatvonal felv\u00e9tele +label.add.system.service.offering=Add System Service Offering +label.add.template=Sablon felv\u00e9tele +label.add.to.group=Felv\u00e9tel a csoportba +label.add.ucs.manager=Add UCS Manager +label.add.user=Felhaszn\u00e1l\u00f3 felv\u00e9tele +label.add.vlan=VLAN felv\u00e9tele +label.add.vms=Add VMs +label.add.vms.to.lb=Add VM(s) to load balancer rule +label.add.VM.to.tier=Add VM to tier +label.add.vm=VM felv\u00e9tele +label.add.vmware.datacenter=Add VMware datacenter +label.add.vnmc.device=Add VNMC device +label.add.vnmc.provider=Add VNMC provider +label.add.volume=K\u00f6tet felv\u00e9tele +label.add.vpc=Add VPC +label.add.vpc.offering=Add VPC Offering +label.add.vpn.customer.gateway=VPN \u00fcgyf\u00e9lkapu felv\u00e9tele +label.add.VPN.gateway=VPN \u00e1tj\u00e1r\u00f3 felv\u00e9tele +label.add.vpn.user=VPN felhaszn\u00e1l\u00f3 felv\u00e9tele +label.add.vxlan=VXLAN felv\u00e9tele +label.add.zone=Z\u00f3na felv\u00e9tele +label.admin.accounts=Adminisztr\u00e1tor hozz\u00e1f\u00e9r\u00e9sek +label.admin=Adminisztr\u00e1tor +label.advanced=Halad\u00f3 +label.advanced.mode=Halad\u00f3 m\u00f3d +label.advanced.search=Halad\u00f3 keres\u00e9s +label.affinity=Affinity +label.affinity.group=Affinity Group +label.affinity.groups=Affinity Groups +label.agent.password=\u00dcgyn\u00f6k jelsz\u00f3 +label.agent.state=Agent State +label.agent.username=Agent Username +label.agree=Elfogadom +label.alert.archived=Riaszt\u00e1s archiv\u00e1lva +label.alert.deleted=Riaszt\u00e1s t\u00f6r\u00f6lve +label.alert.details=Riaszt\u00e1s r\u00e9szletei +label.alert=Riaszt\u00e1s +label.algorithm=Algoritmus +label.allocated=Lek\u00f6t\u00f6ve +label.allocation.state=Allocation State +label.allow=Enged\u00e9lyez +label.anti.affinity=Anti-affinity +label.anti.affinity.group=Anti-affinity Group +label.anti.affinity.groups=Anti-affinity Groups +label.api.key=API kulcs +label.api.version=API verzi\u00f3 +label.apply=Alkalmaz +label.app.name=CloudStack +label.archive.alerts=Riaszt\u00e1sok archiv\u00e1l\u00e1sa +label.archive=Archive +label.archive.events=Archive events +label.assigned.vms=Hozz\u00e1rendelt VM-ek +label.assign=Hozz\u00e1rendel\u00e9s +label.assign.instance.another=Assign Instance to Another Account +label.assign.to.load.balancer=P\u00e9ld\u00e1ny hozz\u00e1rendel\u00e9se terhel\u00e9seloszt\u00f3hoz +label.associated.network=Associated Network +label.associated.network.id=Associated Network ID +label.associated.profile=Associated Profile +label.associate.public.ip=Publikus IP c\u00edm hozz\u00e1rendel\u00e9se +label.attached.iso=Attached ISO +label.author.email=Szerz\u0151 e-mail +label.author.name=Szerz\u0151 n\u00e9v +label.autoscale=AutoScale +label.availability=El\u00e9rhet\u0151s\u00e9g +label.availability.zone=El\u00e9rhet\u0151s\u00e9gi z\u00f3na +label.available=El\u00e9rhet\u0151 +label.available.public.ips=Available Public IP Addresses +label.back=Vissza +label.bandwidth=S\u00e1vsz\u00e9less\u00e9g +label.baremetal.dhcp.devices=Baremetal DHCP Devices +label.baremetal.dhcp.provider=Baremetal DHCP Provider +label.baremetal.pxe.device=Add Baremetal PXE Device +label.baremetal.pxe.devices=Baremetal PXE Devices +label.baremetal.pxe.provider=Baremetal PXE Provider +label.basic=Alap +label.basic.mode=Alap m\u00f3d +label.blade.id=Blade ID +label.blades=Blades +label.bootable=Ind\u00edthat\u00f3 +label.broadcast.domain.range=Broadcast domain range +label.broadcast.domain.type=Broadcast Domain Type +label.broadcast.uri=Broadcast URI +label.broadcasturi=broadcasturi +label.broadcat.uri=Broadcast URI +label.brocade.vcs.address=Vcs Switch Address +label.brocade.vcs.details=Brocade Vcs Switch details +label.by.account=By Account +label.by.alert.type=Riaszt\u00e1s t\u00edpus szerint +label.by.availability=By Availability +label.by.date.end=D\u00e1tum szerint (v\u00e9g) +label.by.date.start=D\u00e1tum szerint (kezd\u0151) +label.by.domain=By Domain +label.by.end.date=By End Date +label.by.event.type=Esem\u00e9ny t\u00edpus szerint +label.by.level=By Level +label.by.pod=By Pod +label.by.role=By Role +label.by.start.date=By Start Date +label.by.state=By State +label.bytes.received=Fogadott byte-ok +label.bytes.sent=K\u00fcld\u00f6tt byte-ok +label.by.traffic.type=By Traffic Type +label.by.type=By Type +label.by.type.id=By Type ID +label.by.zone=By Zone +label.cache.mode=Write-cache Type +label.cancel=Megszak\u00edt\u00e1s +label.capacity.bytes=Byte kapac\u00edt\u00e1s +label.capacity.iops=IOPS kapac\u00edt\u00e1s +label.capacity=Kapac\u00edt\u00e1s +label.certificate=Server certificate +label.change.affinity=Change Affinity +label.change.service.offering=Change service offering +label.change.value=\u00c9rt\u00e9k v\u00e1ltoztat\u00e1sa +label.character=Karakter +label.chassis=Chassis +label.cidr.account=CIDR vagy sz\u00e1mla/biztons\u00e1gi csoport +label.cidr=CIDR +label.CIDR.list=CIDR lista +label.cidr.list=Forr\u00e1s CIDR +label.CIDR.of.destination.network=A c\u00e9l h\u00e1l\u00f3zat CIDR +label.cisco.nexus1000v.ip.address=Nexus 1000v IP c\u00edm +label.cisco.nexus1000v.password=Nexus 1000v jelsz\u00f3 +label.cisco.nexus1000v.username=Nexus 1000v felhaszn\u00e1l\u00f3n\u00e9v +label.ciscovnmc.resource.details=CiscoVNMC resource details +label.clean.up=Clean up +label.clear.list=Lista t\u00f6rl\u00e9se +label.close=Bez\u00e1r\u00e1s +label.cloud.console=Cloud Management Console +label.cloud.managed=Cloud.com Managed +label.cluster=F\u00fcrt +label.cluster.name=F\u00fcrt n\u00e9v +label.clusters=F\u00fcrt +label.cluster.type=F\u00fcrt t\u00edpus +label.clvm=CLVM +label.code=K\u00f3d +label.community=K\u00f6z\u00f6ss\u00e9g +label.compute.and.storage=Compute and Storage +label.compute.offering=Compute offering +label.compute.offerings=Compute Offerings +label.compute=Sz\u00e1m\u00edt\u00e1s +label.configuration=Konfigur\u00e1ci\u00f3 +label.configure=Konfigur\u00e1ci\u00f3 +label.configure.ldap=LDAP konfigur\u00e1ci\u00f3ja +label.configure.network.ACLs=Configure Network ACLs +label.configure.vpc=Configure VPC +label.confirmation=Meger\u0151s\u00edt\u00e9s +label.confirm.password=Jelsz\u00f3 meger\u0151s\u00edt\u00e9s +label.congratulations=Gratul\u00e1ci\u00f3\! +label.conserve.mode=Conserve mode +label.console.proxy=Console proxy +label.console.proxy.vm=Console Proxy VM +label.continue.basic.install=Folytat\u00e1s alaptelep\u00edt\u00e9ssel +label.continue=Tov\u00e1bb +label.copying.iso=Copying ISO +label.corrections.saved=Jav\u00edt\u00e1sok mentve +label.counter=Sz\u00e1ml\u00e1l\u00f3 +label.cpu.allocated=CPU allok\u00e1lva +label.cpu.allocated.for.VMs=CPU Allocated for VMs +label.CPU.cap=CPU Cap +label.cpu=CPU +label.cpu.limits=CPU korl\u00e1tok +label.cpu.mhz=CPU (MHz) +label.cpu.utilized=CPU haszn\u00e1lat +label.created.by.system=Created by system +label.created=Created +label.create.nfs.secondary.staging.storage=Create NFS Secondary Staging Store +label.create.nfs.secondary.staging.store=NFS m\u00e1sodlagos t\u00e1r l\u00e9trehoz\u00e1sa +label.create.project=Projekt l\u00e9trehoz\u00e1sa +label.create.template=Sablon l\u00e9trehoz\u00e1sa +label.create.VPN.connection=VPN kapcsolat l\u00e9trehoz\u00e1sa +label.cross.zones=Cross Zones +label.custom.disk.iops=Egyedi IOPS +label.custom.disk.size=Egyedi merevlemez m\u00e9ret +label.custom=Egyedi +label.daily=Napi +label.data.disk.offering=Data Disk Offering +label.date=D\u00e1tum +label.day.of.month=H\u00f3nap napja +label.day.of.week=H\u00e9t napja +label.dc.name=DC n\u00e9v +label.dead.peer.detection=Dead Peer Detection +label.decline.invitation=Decline invitation +label.dedicate.cluster=Dedicate Cluster +label.dedicated=Dedik\u00e1lt +label.dedicate=Dedicate +label.dedicated.vlan.vni.ranges=Dedicated VLAN/VNI Ranges +label.dedicate.host=Kiszolg\u00e1l\u00f3 dedik\u00e1l\u00e1sa +label.dedicate.pod=Dedicate Pod +label.dedicate.vlan.vni.range=Dedicate VLAN/VNI Range +label.dedicate.zone=Dedik\u00e1lt z\u00f3na +label.default=Alap\u00e9rtelmezett +label.default.egress.policy=Default egress policy +label.default.use=Alap\u00e9rtelmezett haszn\u00e1lat +label.default.view=Alap\u00e9rtelmezett n\u00e9zet +label.delete.acl.list=Delete ACL List +label.delete.affinity.group=Delete Affinity Group +label.delete.alerts=T\u00f6rl\u00e9s riaszt\u00e1sok +label.delete.BrocadeVcs=Remove Brocade Vcs Switch +label.delete.ciscoASA1000v=Delete CiscoASA1000v +label.delete.ciscovnmc.resource=Delete CiscoVNMC resource +label.delete.events=T\u00f6rl\u00e9s esem\u00e9nyek +label.delete.F5=F5 t\u00f6rl\u00e9se +label.delete.gateway=\u00c1tj\u00e1r\u00f3 t\u00f6rl\u00e9se +label.delete.internal.lb=Delete Internal LB +label.delete.NetScaler=NetScaler t\u00f6rl\u00e9se +label.delete.NiciraNvp=Remove Nvp Controller +label.delete.NuageVsp=Remove Nuage VSD +label.delete.OpenDaylight.device=OpenDaylight Controller t\u00f6rl\u00e9se +label.delete.PA=Palo Alto t\u00f6rl\u00e9se +label.delete.portable.ip.range=Delete Portable IP Range +label.delete.profile=Profil t\u00f6rl\u00e9se +label.delete.project=Projekt t\u00f6rl\u00e9se +label.delete.secondary.staging.store=Delete Secondary Staging Store +label.delete.SRX=SRX t\u00f6rl\u00e9se +label.delete=T\u00f6rl\u00e9s +label.delete.ucs.manager=Delete UCS Manager +label.delete.VPN.connection=VPN kapcsolat t\u00f6rl\u00e9se +label.delete.VPN.customer.gateway=VPN \u00fcgyf\u00e9l kapu t\u00f6rl\u00e9se +label.delete.VPN.gateway=VPN kapu t\u00f6rl\u00e9se +label.delete.vpn.user=VPN felhaszn\u00e1l\u00f3 t\u00f6rl\u00e9se +label.deleting.failed=T\u00f6rl\u00e9s sikertelen +label.deleting.processing=T\u00f6rl\u00e9s... +label.deny=Megtilt +label.deployment.planner=Felhaszn\u00e1l\u00e1s tervez\u0151 +label.description=Le\u00edr\u00e1s +label.destination.physical.network.id=Destination physical network ID +label.destination.zone=Destination Zone +label.destroy=Elpuszt\u00edt +label.destroy.router=Destroy router +label.destroy.vm.graceperiod=Destroy VM Grace Period +label.detaching.disk=Merevlemez lev\u00e1laszt\u00e1sa +label.details=R\u00e9szletek +label.device.id=Eszk\u00f6z ID +label.devices=Eszk\u00f6z\u00f6k +label.dhcp=DHCP +label.DHCP.server.type=DHCP kiszolg\u00e1l\u00f3 t\u00edpus +label.direct.attached.public.ip=Direct Attached Public IP +label.direct.ips=Shared Network IPs +label.disable.autoscale=Automatikus sk\u00e1l\u00e1z\u00e1s kikapcsol\u00e1sa +label.disabled=Kikapcsolt +label.disable.host=Kiszolg\u00e1l\u00f3 kikapcsol\u00e1sa +label.disable.network.offering=H\u00e1l\u00f3zati aj\u00e1nlat kikapcsol\u00e1sa +label.disable.provider=Szolg\u00e1ltat\u00f3 kikapcsol\u00e1sa +label.disable.vnmc.provider=Disable VNMC provider +label.disable.vpc.offering=Disable VPC offering +label.disable.vpn=Disable Remote Access VPN +label.disabling.vpn.access=Disabling VPN Access +label.disassociate.profile.blade=Disassociate Profile from Blade +label.disbale.vnmc.device=Disable VNMC device +label.disk.allocated=Disk Allocated +label.disk.bytes.read.rate=Olvas\u00e1si r\u00e1ta (BPS) +label.disk.bytes.write.rate=\u00cdr\u00e1si r\u00e1ta (BPS) +label.disk.iops.max=IOPS maximum +label.disk.iops.min=IOPS minimum +label.disk.iops.read.rate=Olvas\u00e1si r\u00e1ta (IOPS) +label.disk.iops.total=IOPS \u00f6sszesen +label.disk.iops.write.rate=\u00cdr\u00e1si r\u00e1ta (IOPS) +label.disk.offering=Merevlemez aj\u00e1nlat +label.disk.provisioningtype=Provisioning Type +label.disk.read.bytes=Merevlemez olvas\u00e1s (Byte) +label.disk.read.io=Merevlemez \u00edr\u00e1s (IO) +label.disk.size.gb=Merevlemez m\u00e9ret (GB) +label.disk.size=Merevlemez m\u00e9ret +label.disk.total=Merevlemez \u00f6sszes +label.disk.volume=Disk Volume +label.disk.write.bytes=Disk Write (Bytes) +label.disk.write.io=Disk Write (IO) +label.display.text=Display Text +label.distributedrouter=Elosztott router +label.dns.1=1. DNS +label.dns.2=2. DNS +label.dns=DNS +label.DNS.domain.for.guest.networks=Vend\u00e9g h\u00e1l\u00f3zatok DNS tartom\u00e1nya +label.domain.admin=Tartom\u00e1ny adminisztr\u00e1tor +label.domain=Dom\u00e9n +label.domain.id=Tartom\u00e1ny ID +label.domain.lower=domain +label.domain.name=Tartom\u00e1ny n\u00e9v +label.domain.router=Domain router +label.domain.suffix=DNS Domain Suffix (i.e., xyz.com) +label.done=K\u00e9sz +label.double.quotes.are.not.allowed=Double quotes are not allowed +label.download.progress=Download Progress +label.drag.new.position=Drag to new position +label.duration.in.sec=Id\u0151tartam (mp) +label.dynamically.scalable=Dinakikusan sk\u00e1l\u00e1zhat\u00f3 +label.edit.acl.rule=Edit ACL rule +label.edit.affinity.group=Edit Affinity Group +label.edit=Edit +label.edit.lb.rule=Edit LB rule +label.edit.network.details=Edit network details +label.edit.project.details=Edit project details +label.edit.region=Edit Region +label.edit.tags=Edit tags +label.edit.traffic.type=Edit traffic type +label.edit.vpc=Edit VPC +label.egress.default.policy=Egress Default Policy +label.egress.rule=Egress rule +label.egress.rules=Egress rules +label.elastic=Elasztikus +label.elastic.IP=Elasztikus IP +label.elastic.LB=Elasztikus LB +label.email=Email +label.email.lower=email +label.enable.autoscale=Automatikus sk\u00e1l\u00e1z\u00e1s bekapcsol\u00e1sa +label.enable.host=Kiszolg\u00e1l\u00f3 bekapcsol\u00e1sa +label.enable.network.offering=H\u00e1l\u00f3zati aj\u00e1nlat bekapcsol\u00e1sa +label.enable.provider=Enable provider +label.enable.s3=Enable S3-backed Secondary Storage +label.enable.swift=Swift enged\u00e9lyez\u00e9se +label.enable.vnmc.device=Enable VNMC device +label.enable.vnmc.provider=Enable VNMC provider +label.enable.vpc.offering=Enable VPC offering +label.enable.vpn=Enable Remote Access VPN +label.enabling.vpn.access=Enabling VPN Access +label.enabling.vpn=VPN enged\u00e9lyez\u00e9se +label.end.IP=End IP +label.endpoint.or.operation=Endpoint or Operation +label.endpoint=V\u00e9gpont +label.end.port=End Port +label.end.reserved.system.IP=End Reserved system IP +label.end.vlan=Utols\u00f3 VLAN +label.end.vxlan=Utols\u00f3 VXLAN +label.enter.token=Enter token +label.error.code=Hibak\u00f3d +label.error=Hiba +label.error.upper=ERROR +label.ESP.encryption=ESP titkos\u00edt\u00e1s +label.ESP.hash=ESP Hash +label.ESP.lifetime=ESP \u00e9lettartam (mp) +label.ESP.policy=ESP policy +label.esx.host=ESX/ESXi Host +label.event.archived=Event Archived +label.event.deleted=Event Deleted +label.example=Example +label.expunge=Expunge +label.external.link=External link +label.extractable=Kicsomagolhat\u00f3 +label.f5.details=F5 r\u00e9szletek +label.f5=F5 +label.failed=Hiba +label.featured=Kiemelt +label.fetch.latest=Legfrissebb let\u00f6lt\u00e9se +label.filterBy=Filter by +label.firewall=T\u0171zfal +label.first.name=Keresztn\u00e9v +label.firstname.lower=keresztn\u00e9v +label.format=Form\u00e1tum +label.friday=P\u00e9ntek +label.full.path=Teljes el\u00e9r\u00e9si \u00fatvonal +label.full=Teljes +label.gateway=\u00c1tj\u00e1r\u00f3 +label.general.alerts=\u00c1ltal\u00e1nos riaszt\u00e1sok +label.generating.url=URL gener\u00e1l\u00e1sa +label.gluster.volume=K\u00f6tet +label.go.step.2=2. l\u00e9p\u00e9sre +label.go.step.3=3. l\u00e9p\u00e9sre +label.go.step.4=4. l\u00e9p\u00e9sre +label.go.step.5=5. l\u00e9psre +label.gpu=CPU +label.group.by.account=Group by account +label.group.by.cluster=Group by cluster +label.group.by.pod=Group by pod +label.group.by.zone=Z\u00f3n\u00e1nk\u00e9nt csoportos\u00edtva +label.group=Csoport +label.group.optional=Csoport (opcion\u00e1lis) +label.gslb.assigned.lb=Assigned load balancing +label.gslb.assigned.lb.more=Assign more load balancing +label.gslb.delete=GSLB t\u00f6rl\u00e9se +label.gslb.details=GSLB r\u00e9szletek +label.gslb.domain.name=GSLB Domain Name +label.gslb=GSLB +label.gslb.lb.details=Terhel\u00e9seloszt\u00f3 r\u00e9szletek +label.gslb.lb.remove=Remove load balancing from this GSLB +label.gslb.lb.rule=Terhel\u00e9seloszt\u00f3 szab\u00e1ly +label.gslb.service=GSLB szolg\u00e1ltat\u00e1s +label.gslb.service.private.ip=GSLB service Private IP +label.gslb.service.public.ip=GSLB service Public IP +label.gslb.servicetype=Szolg\u00e1ltat\u00e1s t\u00edpus +label.guest.cidr=Vend\u00e9g CIDR +label.guest.end.ip=Guest end IP +label.guest.gateway=Guest Gateway +label.guest.ip=Guest IP Address +label.guest.ip.range=Guest IP Range +label.guest.netmask=Guest Netmask +label.guest.network.details=Guest network details +label.guest.networks=Guest networks +label.guest.start.ip=Guest start IP +label.guest.traffic=Vend\u00e9g forgalom +label.guest.traffic.vswitch.name=Guest Traffic vSwitch Name +label.guest.traffic.vswitch.type=Guest Traffic vSwitch Type +label.guest.type=Vend\u00e9g t\u00edpus +label.guest=Vend\u00e9g +label.ha.enabled=HA bekapcsolva +label.health.check=Ellen\u0151rz\u00e9s +label.health.check.interval.in.sec=Ellen\u0151rz\u00e9s id\u0151k\u00f6z (mp) +label.healthy.threshold=Eg\u00e9szs\u00e9ges k\u00fcsz\u00f6b +label.help=Seg\u00edts\u00e9g +label.hide.ingress.rule=Hide Ingress Rule +label.hints=Tippek +label.home=Kezd\u0151lap +label.host.alerts=Kiszolg\u00e1l\u00f3 riaszt\u00e1sok +label.host=Kiszolg\u00e1l\u00f3 +label.host.MAC=Kiszolg\u00e1l\u00f3 MAC +label.host.name=Kiszolg\u00e1l\u00f3 n\u00e9v +label.hosts=Kiszolg\u00e1l\u00f3k +label.host.tags=Kiszolg\u00e1l\u00f3 c\u00edmk\u00e9k +label.hourly=\u00d3r\u00e1nk\u00e9nt +label.hvm=HVM +label.hypervisor.capabilities=Hpervizor k\u00e9pess\u00e9gek +label.hypervisor=Hipervizor +label.hypervisors=Hipervizorok +label.hypervisor.snapshot.reserve=Hipervizor Snapshot Reserve +label.hypervisor.type=Hipervizor t\u00edpus +label.hypervisor.version=Hipervizor verzi\u00f3 +label.hyperv.traffic.label=HyperV Traffic Label +label.id=ID +label.IKE.DH=IKE DH +label.IKE.encryption=IKE Encryption +label.IKE.hash=IKE Hash +label.IKE.lifetime=IKE lifetime (second) +label.IKE.policy=IKE policy +label.info=Inf\u00f3 +label.info.upper=INFO +label.ingress.rule=Ingress Rule +label.initiated.by=Initiated By +label.inside.port.profile=Inside Port Profile +label.installWizard.addClusterIntro.subtitle=Mi a f\u00fcrt? +label.installWizard.addClusterIntro.title=Csin\u00e1ljunk egy f\u00fcrt\u00f6t\! +label.installWizard.addHostIntro.subtitle=Mi a kiszolg\u00e1l\u00f3? +label.installWizard.addHostIntro.title=Regisztr\u00e1ljunk egy kiszolg\u00e1l\u00f3t\! +label.installWizard.addPodIntro.subtitle=Mi a pod? +label.installWizard.addPodIntro.title=Csin\u00e1ljunk egy pod-ot\! +label.installWizard.addPrimaryStorageIntro.subtitle=Mi az els\u0151dleges t\u00e1r? +label.installWizard.addPrimaryStorageIntro.title=Hozzuk l\u00e9tre az els\u0151dleges t\u00e1rol\u00f3t\! +label.installWizard.addSecondaryStorageIntro.subtitle=Mi a m\u00e1sodlagos t\u00e1r? +label.installWizard.addSecondaryStorageIntro.title=Hozzuk l\u00e9tre a m\u00e1sodlagos t\u00e1rol\u00f3t\! +label.installWizard.addZoneIntro.subtitle=Mi a z\u00f3na? +label.installWizard.addZoneIntro.title=Hozzunk l\u00e9tre egy z\u00f3n\u00e1t\! +label.installWizard.addZone.title=Z\u00f3na l\u00e9troz\u00e1sa +label.installWizard.click.launch=Kattints az ind\u00edt\u00e1s gombra\! +label.installWizard.subtitle=Ez a p\u00e1rbesz\u00e9dablak seg\u00edt konfigur\u00e1lni a CloudStack&\#8482 rendszered +label.installWizard.title=\u00dcdv\u00f6z\u00f6l a CloudStack&\#8482 +label.instance.limits=P\u00e9ld\u00e1ny korl\u00e1tok +label.instance.name=P\u00e9ld\u00e1ny n\u00e9v +label.instance.port=P\u00e9ld\u00e1ny port +label.instance=P\u00e9ld\u00e1ny +label.instances=P\u00e9ld\u00e1nyok +label.instanciate.template.associate.profile.blade=Instanciate Template and Associate Profile to Blade +label.intermediate.certificate=Intermediate certificate {0} +label.internal.dns.1=1. bels\u0151 DNS +label.internal.dns.2=2. bels\u0151 DNS +label.internal.lb.details=Internal LB details +label.internallbvm=InternalLbVm +label.internal.name=Bels\u0151 n\u00e9v +label.interval.type=Id\u0151k\u00f6z t\u00edpus +label.introduction.to.cloudstack=Bemutatkozik a CloudStack&\#8482 +label.invalid.integer=\u00c9rv\u00e9nytelen eg\u00e9sz sz\u00e1m +label.invalid.number=\u00c9rv\u00e9nytelen sz\u00e1m +label.invitations=Megh\u00edv\u00f3k +label.invited.accounts=Invited accounts +label.invite=Meghiv\u00e1s +label.invite.to=Megh\u00edv\u00e1s\: +label.ip.address=IP c\u00edm +label.ipaddress=IP c\u00edm +label.ip.allocations=IP Allocations +label.ip=IP +label.ip.limits=Publikus IP korl\u00e1tok +label.ip.or.fqdn=IP vagy FQDN +label.ip.range=IP tartom\u00e1ny +label.ip.ranges=IP tartom\u00e1nyok +label.IPsec.preshared.key=IPsec Preshared-Key +label.ips=IP c\u00edmek +label.ipv4.cidr=IPv4 CIDR +label.ipv4.dns1=IPv4 1. DNS +label.ipv4.dns2=IPv4 2. DNS +label.ipv4.end.ip=IPv4 utols\u00f3 IP +label.ipv4.gateway=IPv4 \u00e1tj\u00e1r\u00f3 +label.ipv4.netmask=IPv4 h\u00e1l\u00f3zati maszk +label.ipv4.start.ip=IPv4 kezd\u0151 IP +label.ipv6.address=IPv6 IP c\u00edm +label.ipv6.CIDR=IPv6 CIDR +label.ipv6.dns1=IPv6 1. DNS +label.ipv6.dns2=IPv6 2. DNS +label.ipv6.end.ip=IPv6 utols\u00f3 IP +label.ipv6.gateway=IPv6 \u00e1tj\u00e1r\u00f3 +label.ipv6.start.ip=IPv6 kezd\u0151 IP +label.iscsi=iSCSI +label.is.default=Alap\u00e9rtelmezett +label.iso.boot=ISO Boot +label.iso=ISO +label.isolated.networks=Isolated networks +label.isolation.method=Isolation method +label.isolation.mode=Izol\u00e1ci\u00f3 m\u00f3d +label.isolation.uri=Isolation URI +label.is.redundant.router=Redund\u00e1ns +label.is.shared=Osztott +label.is.system=Rendszer +label.item.listing=Item listing +label.keep=Megtart\u00e1s +label.keyboard.type=Billenty\u0171zet t\u00edpus +label.key=Kulcs +label.kvm.traffic.label=KVM traffic label +label.label=Cimke +label.lang.arabic=Arab +label.lang.brportugese=Brazil-portug\u00e1l +label.lang.catalan=Katal\u00e1n +label.lang.chinese=K\u00ednai (egyszer\u0171s\u00edtett) +label.lang.dutch=Holland (Hollandia) +label.lang.english=Angol +label.lang.french=Francia +label.lang.german=N\u00e9met +label.lang.hungarian=Magyar +label.lang.italian=Olasz +label.lang.japanese=Jap\u00e1n +label.lang.korean=K\u00f3reai +label.lang.norwegian=Norv\u00e9g +label.lang.polish=Lengyel +label.lang.russian=Orosz +label.lang.spanish=Spanyol +label.last.disconnected=Last Disconnected +label.last.name=Csal\u00e1dn\u00e9v +label.lastname.lower=csal\u00e1dn\u00e9v +label.latest.events=Utols\u00f3 esem\u00e9nyek +label.launch=Ind\u00edt\u00e1s +label.launch.vm=VM ind\u00edt\u00e1sa +label.launch.zone=Z\u00f3na ind\u00edt\u00e1sa +label.lb.algorithm.leastconn=Least connections +label.lb.algorithm.roundrobin=K\u00f6rbe forg\u00f3 +label.lb.algorithm.source=Forr\u00e1s +label.LB.isolation=Terhel\u00e9seloszt\u00f3 izol\u00e1ci\u00f3 +label.ldap.configuration=LDAP konfigur\u00e1ci\u00f3 +label.ldap.group.name=LDAP Group +label.ldap.port=LDAP port +label.level=Szint +label.linklocal.ip=Link Local IP Address +label.load.balancer=Terhel\u00e9seloszt\u00f3 +label.load.balancer.type=Terhel\u00e9seloszt\u00f3 t\u00edpus +label.load.balancing.policies=Terhel\u00e9seloszt\u00f3 szab\u00e1lyok +label.load.balancing=Terhel\u00e9seloszt\u00e1s +label.loading=Bet\u00f6lt\u00e9s +label.local=Helyi +label.local.storage.enabled=Helyi t\u00e1r bekapcsolva +label.local.storage=Helyi t\u00e1r +label.login=Bejelentkez\u00e9s +label.logout=Kijelentkez\u00e9s +label.lun=LUN +label.LUN.number=LUN \# +label.lxc.traffic.label=LXC Traffic Label +label.make.project.owner=Make account project owner +label.managed=Managed +label.manage=Manage +label.management.ips=Management IP Addresses +label.management.server=Management Server +label.management=Vez\u00e9rl\u00e9s +label.manage.resources=Manage Resources +label.max.cpus=Max. CPU cores +label.max.guest.limit=Max guest limit +label.maximum=Maximum +label.max.instances=P\u00e9ld\u00e1nyok maxim\u00e1lis sz\u00e1ma +label.max.memory=Max. memory (MiB) +label.max.networks=Max. networks +label.max.primary.storage=Max. primary (GiB) +label.max.public.ips=Max. public IPs +label.max.secondary.storage=Max. secondary (GiB) +label.max.snapshots=Max. snapshots +label.max.templates=Max. templates +label.max.vms=Max. user VMs +label.max.volumes=Max. volumes +label.max.vpcs=Max. VPCs +label.may.continue=Most folytathatod +label.md5.checksum=MD5 ellen\u00f6rz\u0151\u00f6sszeg +label.memory.allocated=Allok\u00e1lt mem\u00f3ria +label.memory.limits=Mem\u00f3ria korl\u00e1tok (MiB) +label.memory.mb=Mem\u00f3ria (MB) +label.memory=Memory +label.memory.total=Tejes mem\u00f3ria +label.memory.used=Haszn\u00e1lt mem\u00f3ria +label.menu.accounts=Sz\u00e1ml\u00e1k +label.menu.alerts=Riaszt\u00e1sok +label.menu.all.accounts=Minden sz\u00e1mla +label.menu.all.instances=Minden p\u00e9ld\u00e1ny +label.menu.community.isos=K\u00f6z\u00f6ss\u00e9gi ISO-k +label.menu.community.templates=K\u00f6z\u00f6ss\u00e9gi sablonok +label.menu.configuration=Konfigur\u00e1ci\u00f3 +label.menu.dashboard=M\u0171szert\u00e1bla +label.menu.destroyed.instances=Elpuszt\u00edtott p\u00e9ld\u00e1nyok +label.menu.disk.offerings=Merevlemez aj\u00e1nlatok +label.menu.domains=Dom\u00e9nek +label.menu.events=Esem\u00e9nyek +label.menu.featured.isos=Kiemelt ISO-k +label.menu.featured.templates=Kiemelt sablonok +label.menu.global.settings=Glob\u00e1lis be\u00e1ll\u00edt\u00e1sok +label.menu.infrastructure=Infrastrukt\u00fara +label.menu.instances=P\u00e9ld\u00e1nyok +label.menu.ipaddresses=IP c\u00edm +label.menu.isos=ISO-k +label.menu.my.accounts=Saj\u00e1t sz\u00e1ml\u00e1k +label.menu.my.instances=Saj\u00e1t p\u00e9ld\u00e1nyok +label.menu.my.isos=Saj\u00e1t ISO-k +label.menu.my.templates=Saj\u00e1t sablonok +label.menu.network=H\u00e1l\u00f3zatok +label.menu.network.offerings=Network Offerings +label.menu.physical.resources=Physical Resources +label.menu.regions=R\u00e9gi\u00f3k +label.menu.running.instances=Running Instances +label.menu.security.groups=Biztons\u00e1gi csoportok +label.menu.service.offerings=Service Offerings +label.menu.snapshots=Pillanatfelv\u00e9telek +label.menu.stopped.instances=Le\u00e1ll\u00edtott p\u00e9ld\u00e1nyok +label.menu.storage=T\u00e1r +label.menu.system=Rendszer +label.menu.system.service.offerings=System Offerings +label.menu.system.vms=Rendszer VM-ek +label.menu.templates=Sablonok +label.menu.virtual.appliances=Virtual Appliances +label.menu.virtual.resources=Virtual Resources +label.menu.volumes=K\u00f6tetek +label.menu.vpc.offerings=VPC Offerings +label.migrate.instance.to.host=P\u00e9ld\u00e1ny mozgat\u00e1sa m\u00e1sik kiszolg\u00e1l\u00f3ra +label.migrate.instance.to=Migrate instance to +label.migrate.instance.to.ps=Migrate instance to another primary storage +label.migrate.lb.vm=Terhel\u00e9seloszt\u00f3 VM mozgat\u00e1sa +label.migrate.router.to=Migrate Router to +label.migrate.systemvm.to=Migrate System VM to +label.migrate.to.host=Mozgat\u00e1s kiszolg\u00e1l\u00f3ra +label.migrate.to.storage=Mozgat\u00e1s t\u00e1rra +label.migrate.volume=K\u00f6tet mozgat\u00e1sa +label.migrate.volume.to.primary.storage=K\u00f6tet mozgat\u00e1sa m\u00e1sik els\u0151dleges t\u00e1rra +label.minimum=Minimum +label.min.instances=P\u00e9ld\u00e1nyok minim\u00e1lis sz\u00e1ma +label.minute.past.hour=Perc +label.mode=M\u00f3d +label.monday=H\u00e9tf\u0151 +label.monthly=Havi +label.more.templates=Tov\u00e1bbi sablonok +label.move.down.row=Egy sorral lejjebb +label.move.to.bottom=Alj\u00e1ra +label.move.to.top=Tetej\u00e9re +label.move.up.row=Egy sorral feljebb +label.my.account=Saj\u00e1t sz\u00e1ml\u00e1m +label.my.network=Saj\u00e1t h\u00e1l\u00f3zat +label.my.templates=Saj\u00e1t sablonok +label.name.lower=N\u00e9v +label.name=N\u00e9v +label.name.optional=N\u00e9v (opcion\u00e1lis) +label.na=Nem \u00e9rtelmezett +label.nat.port.range=NAT Port Range +label.netmask=H\u00e1l\u00f3zati maszk +label.netscaler.details=NetScaler r\u00e9szletek +label.netScaler=NetScaler +label.network.ACL=H\u00e1l\u00f3zati ACL +label.network.ACLs=H\u00e1l\u00f3zati ACL-ek +label.network.ACL.total=Network ACL Total +label.network.addVM=Add network to VM +label.network.cidr=H\u00e1l\u00f3zat CIDR +label.network.desc=H\u00e1l\u00f3zat le\u00edr\u00e1s +label.network.device=H\u00e1l\u00f3zati eszk\u00f6z +label.network.device.type=H\u00e1l\u00f3zati eszk\u00f6z t\u00edpus +label.network.domain=Network Domain +label.network.domain.text=Network domain +label.network=H\u00e1l\u00f3zatok +label.network.id=H\u00e1l\u00f3zat ID +label.networking.and.security=H\u00e1l\u00f3zat \u00e9s biztons\u00e1g +label.network.label.display.for.blank.value=Alap\u00e9rtelmezett \u00e1tj\u00e1r\u00f3 haszn\u00e1lata +label.network.limits=H\u00e1l\u00f3zat korl\u00e1tok +label.network.name=H\u00e1l\u00f3zat n\u00e9v +label.network.offering.display.text=Network Offering Display Text +label.network.offering.id=Network Offering ID +label.network.offering.name=Network Offering Name +label.network.offering=Network Offering +label.network.rate.megabytes=Network Rate (MB/s) +label.network.rate=Network Rate (Mb/s) +label.network.read=Network Read +label.network.service.providers=Network Service Providers +label.networks=H\u00e1l\u00f3zatok +label.network.type=H\u00e1l\u00f3zat t\u00edpus +label.network.write=Network Write +label.new.password=\u00daj jelsz\u00f3 +label.new.project=\u00daj projekt +label.new=\u00daj +label.new.vm=\u00daj VM +label.next=K\u00f6vetkez\u0151 +label.nexusVswitch=Nexus 1000v +label.nfs=NFS +label.nfs.server=NFS kiszolg\u00e1l\u00f3 +label.nfs.storage=NFS t\u00e1r +label.nic.adapter.type=NIC adapter t\u00edpus +label.nicira.controller.address=Controller Address +label.nicira.l3gatewayserviceuuid=L3 Gateway Service Uuid +label.nicira.nvp.details=Nicira NVP r\u00e9szletek +label.nicira.transportzoneuuid=Transport Zone Uuid +label.nics=NIC-ek +label.no.actions=Nincs el\u00e9rhet\u0151 m\u0171velet +label.no.alerts=Nem voltak riaszt\u00e1sok a k\u00f6zelm\u00faltban +label.no.data=Nincs megjelen\u00edtend\u0151 adat +label.no.errors=Nem voltak hib\u00e1k a k\u00f6zelm\u00faltban +label.no.grouping=(nincs csoportos\u00edt\u00e1s) +label.no.isos=Nincsenek el\u00e9rhet\u0151 ISO-k +label.no.items=Nincsenek el\u00e9rhet\u0151 elemek +label.no=Nem +label.none=Nincs +label.no.security.groups=Nincs el\u00e9rhet\u0151 biztons\u00e1gi csoport +label.not.found=Nem tal\u00e1lhat\u00f3 +label.no.thanks=Nem, k\u00f6szi\! +label.notifications=\u00c9rtes\u00edt\u00e9sek +label.number.of.clusters=F\u00fcrt\u00f6k sz\u00e1ma +label.number.of.cpu.sockets=CPU-aljzatok sz\u00e1ma +label.number.of.hosts=Kiszolg\u00e1l\u00f3k sz\u00e1ma +label.number.of.pods=Pod-ok sz\u00e1ma\: +label.number.of.system.vms=Rendszer VM-ek sz\u00e1ma +label.number.of.virtual.routers=Virtu\u00e1lis routerek sz\u00e1ma +label.number.of.zones=Z\u00f3n\u00e1k sz\u00e1ma +label.num.cpu.cores=CPU magok sz\u00e1ma +label.numretries=\u00dajrapr\u00f3b\u00e1lkoz\u00e1sok sz\u00e1ma +label.ocfs2=OCFS2 +label.offer.ha=Offer HA +label.ok=Rendben +label.opendaylight.controllerdetail=OpenDaylight Controller Details +label.opendaylight.controller=OpenDaylight vez\u00e9rl\u0151 +label.opendaylight.controllers=OpenDaylight vez\u00e9rl\u0151k +label.openDaylight=OpenDaylight +label.operator=Oper\u00e1tor +label.optional=Opcion\u00e1lis +label.order=Sorrend +label.os.preference=OS preferencia +label.os.type=OS t\u00edpus +label.other=M\u00e1s +label.override.guest.traffic=Override Guest-Traffic +label.override.public.traffic=Override Public-Traffic +label.ovm.traffic.label=OVM traffic label +label.ovs=OVS +label.owned.public.ips=Owned Public IP Addresses +label.owner.account=Owner Account +label.owner.domain=Owner Domain +label.palo.alto.details=Palo Alto r\u00e9szletek +label.PA.log.profile=Palo Alto Log Profile +label.PA=Palo Alto +label.parent.domain=Parent Domain +label.passive=Passz\u00edv +label.password.enabled=Jelsz\u00f3 bekapcsolva +label.password=Jelsz\u00f3 +label.password.lower=jelsz\u00f3 +label.password.reset.confirm=Az \u00faj jelsz\u00f3 +label.PA.threat.profile=Palo Alto Threat Profile +label.path=\u00datvonal +label.perfect.forward.secrecy=Perfect Forward Secrecy +label.persistent=Perzisztens +label.physical.network.ID=Physical network ID +label.physical.network=Physical Network +label.PING.CIFS.password=PING CIFS jelsz\u00f3 +label.PING.CIFS.username=PING CIFS felhaszn\u00e1l\u00f3 +label.PING.dir=PING Directory +label.ping.path=Ping \u00fatvonal +label.PING.storage.IP=PING t\u00e1r IP +label.planner.mode=Tervez\u0151 m\u00f3d +label.please.specify.netscaler.info=Please specify Netscaler info +label.please.wait=K\u00e9rlek v\u00e1rj\! +label.plugin.details=Plugin details +label.plugins=Plugins +label.pod.dedicated=Pod Dedicated +label.pod.name=Pod n\u00e9v +label.pod=Pod +label.pods=Pod-ok +label.polling.interval.sec=Polling Interval (in sec) +label.portable.ip=Mozgathat\u00f3 IP +label.portable.ip.range.details=Portable IP Range details +label.portable.ip.ranges=Portable IP Ranges +label.portable.ips=Portable IPs +label.port.forwarding.policies=Port forwarding policies +label.port.forwarding=Port Forwarding +label.port=Port +label.port.range=Port Range +label.PreSetup=PreSetup +label.prev=El\u0151z\u0151 +label.previous=El\u0151z\u0151 +label.primary.allocated=Primary Storage Allocated +label.primary.network=Primary Network +label.primary.storage.count=Primary Storage Pools +label.primary.storage=Els\u0151dleges t\u00e1r +label.primary.storage.limits=Primary Storage limits (GiB) +label.primary.used=Haszn\u00e1lt els\u0151dleges t\u00e1r +label.private.Gateway=Priv\u00e1t \u00e1tj\u00e1r\u00f3 +label.private.interface=Private Interface +label.private.ip=Priv\u00e1t IP c\u00edm +label.private.ip.range=Priv\u00e1t IP tartom\u00e1ny +label.private.ips=Priv\u00e1t IP c\u00edmek +label.privatekey=PKCS\#8 Private Key +label.private.network=Priv\u00e1t h\u00e1l\u00f3zat +label.private.port=Priv\u00e1t port +label.private.zone=Priv\u00e1t z\u00f3na +label.profile=Profil +label.project.dashboard=Projekt m\u0171szerfal +label.project.id=Projekt ID +label.project.invite=Megh\u00edv\u00e1s a projektbe +label.project.name=Projekt n\u00e9v +label.project=Projekt +label.projects=Projektek +label.project.view=Projekt n\u00e9zet +label.protocol.number=Protokoll sz\u00e1m +label.protocol=Protokol +label.providers=Szolg\u00e1ltat\u00f3k +label.provider=Szolg\u00e1ltat\u00f3 +label.public.interface=Public Interface +label.public.ip=Publikus IP c\u00edm +label.public.ips=Publikus IP c\u00edmek +label.public.load.balancer.provider=Publikus terhel\u00e9seloszt\u00f3 szolg\u00e1ltat\u00f3 +label.public.network=Publikus h\u00e1l\u00f3zat +label.public.port=Publikus port +label.public=Publikus +label.public.traffic=Publikus forgalom +label.public.traffic.vswitch.name=Public Traffic vSwitch Name +label.public.traffic.vswitch.type=Public Traffic vSwitch Type +label.public.zone=Publikus z\u00f3na +label.purpose=Rendeltet\u00e9s +label.Pxe.server.type=Pxe szerver t\u00edpus +label.qos.type=QoS t\u00edpus +label.quickview=Gyorsn\u00e9zet +label.quiesce.vm=VM felf\u00fcggeszt\u00e9se +label.quiet.time.sec=Quiet Time (in sec) +label.rbd.id=Cephx felhaszn\u00e1l\u00f3 +label.rbd.monitor=Ceph monitor +label.rbd.pool=Ceph pool +label.rbd=RBD +label.rbd.secret=Cephx secret +label.reboot=\u00dajraind\u00edt\u00e1s +label.recent.errors=Legut\u00f3bbi hib\u00e1k +label.recover.vm=VM helyre\u00e1ll\u00edt\u00e1sa +label.redundant.router.capability=Redundant router capability +label.redundant.router=Redundant Router +label.redundant.state=Redundant state +label.refresh.blades=Refresh Blades +label.refresh=Frissit\u00e9s +label.regionlevelvpc=Region Level VPC +label.region=R\u00e9gi\u00f3 +label.reinstall.vm=VM \u00fajratelep\u00edt\u00e9se +label.related=Kapcsol\u00f3d\u00f3 +label.release.account.lowercase=Release from account +label.release.account=Release from Account +label.release.dedicated.cluster=Release Dedicated Cluster +label.release.dedicated.host=Dedik\u00e1lt kiszolg\u00e1l\u00f3 elenged\u00e9se +label.release.dedicated.pod=Release Dedicated Pod +label.release.dedicated.vlan.range=Release dedicated VLAN range +label.release.dedicated.zone=Dedik\u00e1lt z\u00f3na elenged\u00e9se +label.remind.later=Eml\u00e9keztess k\u00e9s\u0151bb\! +label.remove.ACL=ACL elt\u00e1vol\u00edt\u00e1sa +label.remove.egress.rule=Remove egress rule +label.remove.from.load.balancer=Removing instance from load balancer +label.remove.ingress.rule=Remove ingress rule +label.remove.ip.range=Remove IP range +label.remove.ldap=LDAP elt\u00e1vol\u00edt\u00e1sa +label.remove.network.offering=H\u00e1l\u00f3zati aj\u00e1nlat elt\u00e1vol\u00edt\u00e1sa +label.remove.pf=Remove port forwarding rule +label.remove.project.account=Remove account from project +label.remove.region=Remove Region +label.remove.rule=Szab\u00e1ly elt\u00e1vol\u00edt\u00e1sa +label.remove.static.nat.rule=Remove static NAT rule +label.remove.static.route=Remove static route +label.remove.tier=Remove tier +label.remove.vm.from.lb=Remove VM from load balancer rule +label.remove.vm.load.balancer=VM elt\u00e1vol\u00edt\u00e1sa a terhel\u00e9seloszt\u00f3b\u00f3l +label.remove.vmware.datacenter=Remove VMware datacenter +label.remove.vpc.offering=Remove VPC offering +label.remove.vpc=Remove VPC +label.removing=Removing +label.removing.user=Felhaszn\u00e1l\u00f3 elt\u00e1vol\u00edt\u00e1sa +label.reource.id=Resource ID +label.replace.acl=ACL csere +label.replace.acl.list=Replace ACL List +label.required=Required +label.requires.upgrade=Friss\u00edt\u00e9st ig\u00e9nyel +label.reserved.ip.range=Elk\u00fcl\u00f6n\u00edtett IP c\u00edmtartom\u00e1ny +label.reserved.system.gateway=Reserved system gateway +label.reserved.system.ip=Reserved System IP +label.reserved.system.netmask=Reserved system netmask +label.resetVM=Reset VM +label.reset.VPN.connection=Reset VPN connection +label.resize.new.offering.id=\u00daj aj\u00e1nlat +label.resize.new.size=\u00daj m\u00e9ret (GB) +label.resize.shrink.ok=Cs\u00f6kkent\u00e9s OK +label.resource=Er\u0151forr\u00e1s +label.resource.limit.exceeded=Resource Limit Exceeded +label.resource.limits=Er\u0151forr\u00e1s korl\u00e1tok +label.resource.name=Resource Name +label.resources=Er\u0151forr\u00e1sok +label.resource.state=Er\u0151forr\u00e1s \u00e1llapot +label.response.timeout.in.sec=V\u00e1lasz id\u0151t\u00fall\u00e9p\u00e9s (mp) +label.restart.network=H\u00e1l\u00f3zat \u00fajraind\u00edt\u00e1sa +label.restart.required=\u00dajraind\u00edt\u00e1s sz\u00fcks\u00e9ges +label.restart.vpc=VPC \u00fajraind\u00edt\u00e1sa +label.restore=Helyre\u00e1ll\u00edt\u00e1s +label.retry.interval=\u00dajraprob\u00e1lkoz\u00e1s id\u0151k\u00f6z +label.review=Ellen\u0151rz\u00e9s +label.revoke.project.invite=Megh\u00edv\u00f3 visszavon\u00e1sa +label.role=Szerep +label.root.certificate=Root certificate +label.root.disk.controller=Root disk controller +label.root.disk.offering=Root Disk Offering +label.root.disk.size=Root merevlemez m\u00e9ret +label.router.vm.scaled.up=Router VM Scaled Up +label.routing.host=Routing Host +label.routing=\u00datvonalv\u00e1laszt\u00e1s +label.rule.number=Rule Number +label.rules=Szab\u00e1lyok +label.running.vms=Fut\u00f3 VM-ek +label.s3.access_key=Hozz\u00e1f\u00e9r\u00e9si kulcs +label.s3.bucket=Kos\u00e1r +label.s3.connection_timeout=Kapcsol\u00f3d\u00e1si id\u0151t\u00fall\u00e9p\u00e9s +label.s3.endpoint=V\u00e9gpont +label.s3.max_error_retry=\u00dajrapr\u00f3b\u00e1lkoz\u00e1s max. +label.s3.nfs.path=S3 NFS \u00fatvonal +label.s3.nfs.server=S3 NFS kiszolg\u00e1l\u00f3 +label.s3.secret_key=Titkos kulcs +label.s3.socket_timeout=Socket Timeout +label.s3.use_https=HTTPS haszn\u00e1lata +label.saml.login=SAML bejelentkez\u00e9s +label.saturday=Szombat +label.save.and.continue=Ment\u00e9s \u00e9s folytat\u00e1s +label.save=Ment\u00e9s +label.saving.processing=Ment\u00e9s... +label.scale.up.policy=SCALE UP POLICY +label.scope=Hat\u00e1ly +label.search=Keres\u00e9s +label.secondary.isolated.vlan.id=M\u00e1sodlagos izol\u00e1lt VLAN ID +label.secondary.staging.store.details=Secondary Staging Store details +label.secondary.staging.store=Secondary Staging Store +label.secondary.storage.count=Secondary Storage Pools +label.secondary.storage.details=Secondary storage details +label.secondary.storage.limits=Secondary Storage limits (GiB) +label.secondary.storage=M\u00e1sodlagos t\u00e1r +label.secondary.storage.vm=Secondary storage VM +label.secondary.used=Haszn\u00e1lt m\u00e1sodlagos t\u00e1r +label.secret.key=Titkos kulcs +label.security.group=Biztons\u00e1gi csoport +label.security.group.name=Biztons\u00e1gi csoport n\u00e9v +label.security.groups=Biztons\u00e1gi csoportok +label.security.groups.enabled=Biztons\u00e1gi csoportok bekapcsolva +label.select.a.template=V\u00e1lassz egy sablont\! +label.select.a.zone=V\u00e1lassz egy z\u00f3n\u00e1t\! +label.select.instance.to.attach.volume.to=V\u00e1laszd ki a p\u00e9ld\u00e1nyt, amelyikhez a k\u00f6tetet csatlakoztatni szeretn\u00e9d\! +label.select.instance=V\u00e1laszd ki a p\u00e9d\u00e1nyt\! +label.select.iso.or.template=V\u00e1lassz ISO-t vagy sablont\! +label.select=Kiv\u00e1laszt\u00e1s +label.select.offering=V\u00e1lassz aj\u00e1nlatot\! +label.select.project=V\u00e1lassz projektet\! +label.select.region=Select region +label.select.template=Sablon kiv\u00e1laszt\u00e1sa +label.select.tier=V\u00e1lassz r\u00e9teget\! +label.select-view=Select view +label.select.vm.for.static.nat=V\u00e1lassz VM-et a statikus NAT-hoz +label.sent=Elk\u00fcld\u00f6tt +label.server=Szerver +label.service.capabilities=Service Capabilities +label.service.offering=Szolg\u00e1ltat\u00e1s aj\u00e1nlat +label.services=Szolg\u00e1ltat\u00e1sok +label.service.state=Szolg\u00e1ltat\u00e1s \u00e1llapot +label.session.expired=A munkamenet lej\u00e1rt +label.set.default.NIC=Set default NIC +label.settings=Be\u00e1ll\u00edt\u00e1sok +label.setup=Be\u00e1ll\u00edt\u00e1sok +label.setup.network=H\u00e1l\u00f3zat be\u00e1ll\u00edt\u00e1sa +label.set.up.zone.type=Z\u00f3na-t\u00edpus be\u00e1ll\u00edt\u00e1sa +label.setup.zone=Z\u00f3na be\u00e1ll\u00edt\u00e1sa +label.SharedMountPoint=SharedMountPoint +label.shared=Osztott +label.show.advanced.settings=Halad\u00f3 szint\u0171 be\u00e1ll\u00edt\u00e1sok +label.show.ingress.rule=Show Ingress Rule +label.shutdown.provider=Shutdown provider +label.site.to.site.VPN=Site-to-site VPN +label.size=M\u00e9ret +label.skip.guide=Haszn\u00e1ltam m\u00e1r a CloudStack-et, kihagyom ezt az \u00fatmutat\u00f3t +label.smb.domain=SMB dom\u00e9n +label.smb.password=SMB jelsz\u00f3 +label.smb.username=SMB felhaszn\u00e1l\u00f3n\u00e9v +label.snapshot.limits=Snapshot Limits +label.snapshot.name=Pillanatfelv\u00e9tel n\u00e9v +label.snapshot=Pillanatfelv\u00e9tel +label.snapshot.schedule=Setup Recurring Snapshot +label.snapshot.s=Pillanatfelv\u00e9tel(ek) +label.snapshots=Pillanatfelv\u00e9telek +label.SNMP.community=SNMP Community +label.SNMP.port=SNMP Port +label.sockets=CPU aljzatok +label.source.ip.address=Forr\u00e1s IP c\u00edm +label.source.nat=Forr\u00e1s NAT +label.source.nat.supported=SourceNAT Supported +label.source.port=Forr\u00e1s port +label.specify.IP.ranges=Add meg az IP tartom\u00e1nyokat\! +label.specify.vlan=Specify VLAN +label.specify.vxlan=Specify VXLAN +label.SR.name=SR Name-Label +label.srx.details=SRX details +label.srx=SRX +label.start.IP=Kezd\u0151 IP +label.start.lb.vm=Terhel\u00e9seloszt\u00f3 VM ind\u00edt\u00e1sa +label.start.port=Kezd\u0151 port +label.start.reserved.system.IP=Start Reserved system IP +label.start.vlan=Els\u0151 VLAN +label.start.vxlan=Els\u0151 VXLAN +label.state=\u00c1llapot +label.static.nat.enabled=Static NAT Enabled +label.static.nat=Static NAT +label.static.nat.to=Static NAT to +label.static.nat.vm.details=Static NAT VM Details +label.statistics=Statisztika +label.status=\u00c1llapot +label.step.1=1. l\u00e9p\u00e9s +label.step.1.title=1. l\u00e9p\u00e9s\: Sablon kiv\u00e1laszt\u00e1sa +label.step.2=2. l\u00e9p\u00e9s +label.step.2.title=2. l\u00e9p\u00e9s\: Szolg\u00e1ltat\u00e1s aj\u00e1nlat +label.step.3=3. l\u00e9p\u00e9s +label.step.3.title=3. l\u00e9p\u00e9s\: Merevlemez aj\u00e1nlat v\u00e1laszt\u00e1sa +label.step.4=4. l\u00e9p\u00e9s +label.step.4.title=4. l\u00e9p\u00e9s\: H\u00e1l\u00f3zat +label.step.5=5. l\u00e9p\u00e9s +label.step.5.title=5. l\u00e9p\u00e9s\: Ellen\u0151rz\u00e9s +label.stickiness.method=Stickiness method +label.stickiness=Stickiness +label.sticky.cookie-name=Cookie name +label.sticky.domain=Dom\u00e9n +label.sticky.expire=Lej\u00e1rat +label.sticky.holdtime=Hold time +label.sticky.indirect=Indirekt +label.sticky.length=Hossz +label.sticky.mode=M\u00f3d +label.sticky.name=Sticky Name +label.sticky.nocache=Nincs gyors\u00edt\u00f3t\u00e1r +label.sticky.postonly=Post only +label.sticky.prefix=Prefix +label.sticky.request-learn=Request learn +label.sticky.tablesize=T\u00e1bla m\u00e9ret +label.stop.lb.vm=Terhel\u00e9seloszt\u00f3 VM le\u00e1ll\u00edt\u00e1sa +label.stopped.vms=Stopped VMs +label.stop=\u00c1lj +label.storage.pool=Storage Pool +label.storage.tags=T\u00e1r c\u00edmk\u00e9k +label.storage.traffic=T\u00e1r forgalom +label.storage=T\u00e1r +label.storage.type=T\u00e1r t\u00edpus +label.subdomain.access=Subdomain Access +label.submit=Submit +label.submitted.by=[Submitted by\: ] +label.succeeded=Siker\u00fclt +label.sunday=Vas\u00e1rnap +label.super.cidr.for.guest.networks=Super CIDR for Guest Networks +label.supported.services=Supported Services +label.supported.source.NAT.type=Supported Source NAT type +label.supportsstrechedl2subnet=Supports Streched L2 Subnet +label.suspend.project=Projekt felf\u00fcggeszt\u00e9se +label.switch.type=Switch t\u00edpus +label.system.capacity=Rendszer kapac\u00edt\u00e1s +label.system.offering.for.router=Rendszer aj\u00e1nlat router-re +label.system.offering=Rendszer aj\u00e1nlat +label.system.service.offering=Rendszer szolg\u00e1ltat\u00e1s aj\u00e1nlat +label.system.vm.details=Rendszer VM r\u00e9szletek +label.system.vm=Rendszer VM +label.system.vm.scaled.up=System VM Scaled Up +label.system.vms=Rendszer VM-ek +label.system.vm.type=Rendszer VM t\u00edpus +label.system.wide.capacity=Rendszer-szint\u0171 kapac\u00edt\u00e1s +label.tagged=Cimk\u00e9zve +label.tag.key=Tag Key +label.tags=Cimk\u00e9k +label.tag.value=C\u00edmke \u00e9rt\u00e9k +label.target.iqn=C\u00e9l IQN +label.task.completed=Feladat v\u00e9grehajtva +label.template.limits=Sablon korl\u00e1tok +label.template=Sablon +label.TFTP.dir=TFTP k\u00f6nyvt\u00e1r +label.tftp.root.directory=Tftp root directory +label.theme.default=Alap\u00e9rtelmezett t\u00e9ma +label.theme.grey=Egyedi - sz\u00fcrke +label.theme.lightblue=Egyedi - vil\u00e1gosk\u00e9k +label.threshold=K\u00fcsz\u00f6b\u00e9rt\u00e9k +label.thursday=Cs\u00fct\u00f6rt\u00f6k +label.tier.details=R\u00e9teg r\u00e9szletei +label.tier=R\u00e9teg +label.time=Id\u0151 +label.timeout=Id\u0151t\u00fall\u00e9p\u00e9s +label.timeout.in.second = Id\u0151t\u00fall\u00e9p\u00e9s (mp) +label.time.zone=Id\u0151z\u00f3na +label.timezone=Id\u0151z\u00f3na +label.token=Token +label.total.cpu=Total CPU +label.total.CPU=Total CPU +label.total.hosts=\u00d6sszes kiszolg\u00e1l\u00f3 +label.total.memory=Mem\u00f3ria \u00f6sszesen +label.total.of.ip=IP c\u00edmek \u00f6sszesen +label.total.of.vm=Total VMs +label.total.storage=Total Storage +label.total.virtual.routers=Total of Virtual Routers +label.total.virtual.routers.upgrade=Total of Virtual Routers that require upgrade +label.total.vms=Total VMs +label.traffic.label=Traffic label +label.traffic.types=Traffic Types +label.traffic.type=Traffic Type +label.tuesday=Kedd +label.type.id=T\u00edpus ID +label.type.lower=t\u00edpus +label.type=T\u00edpus +label.ucs=UCS +label.unavailable=Nem el\u00e9rhet\u0151 +label.unhealthy.threshold=Nem eg\u00e9szs\u00e9ges k\u00fcsz\u00f6b +label.unlimited=Korl\u00e1tlan +label.untagged=Cimk\u00e9zetlen +label.update.project.resources=Update project resources +label.update.ssl.cert= SSL tan\u00fastv\u00e1ny +label.update.ssl= SSL tan\u00fastv\u00e1ny +label.updating=Updating +label.upgrade.required=Frissit\u00e9sre van sz\u00fcks\u00e9g +label.upgrade.router.newer.template=Upgrade Router to Use Newer Template +label.upload=Felt\u00f6lt\u00e9s +label.upload.volume=Upload volume +label.url=URL +label.usage.interface=Usage Interface +label.usage.sanity.result=Usage Sanity Result +label.usage.server=Usage Server +label.used=Haszn\u00e1lt +label.user.data=Felhaszn\u00e1l\u00f3i adat +label.user=Felhaszn\u00e1l\u00f3 +label.username=Felhaszn\u00e1l\u00f3n\u00e9v +label.username.lower=felhaszn\u00e1l\u00f3n\u00e9v +label.users=Felhaszn\u00e1l\u00f3k +label.user.vm=Felhaszn\u00e1l\u00f3i VM +label.use.vm.ips=VM IP c\u00edmek haszn\u00e1lata +label.use.vm.ip=Use VM IP\: +label.value=\u00c9rt\u00e9k +label.vcdcname=vCenter DC n\u00e9v +label.vcenter.cluster=vCenter f\u00fcrt +label.vcenter.datacenter=vCenter adatk\u00f6zpont +label.vcenter.datastore=vCenter t\u00e1r +label.vcenter.host=vCenter kiszolg\u00e1l\u00f3k +label.vcenter.password=vCenter jelsz\u00f3 +label.vcenter.username=vCenter felhaszn\u00e1l\u00f3n\u00e9v +label.vcenter=vcenter +label.vcipaddress=vCenter IP c\u00edm +label.version=Verzi\u00f3 +label.vgpu.max.resolution=Max k\u00e9pm\u00e9ret +label.vgpu.max.vgpu.per.gpu=vGPU-k GPU-nk\u00e9nt +label.vgpu.remaining.capacity=Megmarad\u00f3 kapac\u00edt\u00e1s +label.vgpu.type=vGPU t\u00edpus +label.vgpu=VGPU +label.vgpu.video.ram=Video RAM +label.view.all=View all +label.view.console=View console +label.viewing=Viewing +label.view.more=View more +label.view=N\u00e9zet +label.view.secondary.ips=M\u00e1sodlagos IP c\u00edmek megtekint\u00e9se +label.virtual.appliance.details=Virtual applicance details +label.virtual.appliances=Virtual Appliances +label.virtual.appliance=Virtual Appliance +label.virtual.networking=Virtu\u00e1lis h\u00e1l\u00f3zat +label.virtual.network=Virtu\u00e1lis h\u00e1l\u00f3zat +label.virtual.routers.group.account=Virtual Routers group by account +label.virtual.routers.group.cluster=Virtual Routers group by cluster +label.virtual.routers.group.pod=Virtual Routers group by pod +label.virtual.routers.group.zone=Virtu\u00e1lis routerek z\u00f3n\u00e1nk\u00e9nt csoportos\u00edtva +label.virtual.routers=Virtu\u00e1lis routerek +label.virtual.router=Virtu\u00e1lis router +label.vlan.id=VLAN/VNI ID +label.vlan.only=VLAN +label.vlan.range.details=VLAN Range details +label.vlan.ranges=VLAN Range(s) +label.vlan.range=VLAN/VNI tartom\u00e1ny +label.vlan=VLAN/VNI +label.vlan.vni.ranges=VLAN/VNI Range(s) +label.vlan.vni.range=VLAN/VNI tartom\u00e1ny +label.vm.add=P\u00e9ld\u00e1ny felv\u00e9tele +label.vm.destroy=Elpuszt\u00edt +label.vm.display.name=VM display name +label.VMFS.datastore=VMFS adatt\u00e1r +label.vmfs=VMFS +label.vm.id=VM ID +label.vm.ip=VM IP c\u00edm +label.vm.name=VM n\u00e9v +label.vm.password=A VM jelszava +label.vm.reboot=\u00dajraind\u00edt\u00e1s +label.VMs.in.tier=VMs in tier +label.vmsnapshot.current=Jelnlegi +label.vmsnapshot.memory=Pillanatfelv\u00e9tel mem\u00f3ria +label.vmsnapshot.parentname=Sz\u00fcl\u0151 +label.vmsnapshot.type=T\u00edpus +label.vmsnapshot=VM pillanatfelv\u00e9telek +label.vm.start=Ind\u00edt\u00e1s +label.vm.state=VM \u00e1llapot +label.vm.stop=\u00c1lj +label.vms=VM-ek +label.vmware.datacenter.id=VMware adatk\u00f6zpont ID +label.vmware.datacenter.name=VMware datacenter Name +label.vmware.datacenter.vcenter=VMware datacenter vcenter +label.vmware.traffic.label=VMware traffic label +label.vnet.id=VLAN/VNI ID +label.vnet=VLAN/VNI +label.vnmc.devices=VNMC eszk\u00f6z\u00f6k +label.vnmc=VNMC +label.volatile=Ill\u00e9kony +label.volgroup=K\u00f6tet csoport +label.volume.details=K\u00f6tet r\u00e9szletek +label.volume=K\u00f6tet +label.volume.limits=Volume Limits +label.volume.migrated=K\u00f6tet \u00e1tk\u00f6lt\u00f6ztetve +label.volume.name=K\u00f6tet n\u00e9v +label.volumes=K\u00f6tetek +label.vpc.distributedvpcrouter=Distributed VPC Router +label.vpc.id=VPC ID +label.VPC.limits=VPC korl\u00e1tok +label.vpc.offering.details=VPC offering details +label.vpc.offering=VPC Offering +label.VPC.router.details=VPC router details +label.vpc.supportsregionlevelvpc=Supports Region Level VPC +label.vpc.virtual.router=VPC Virtual Router +label.vpc=VPC +label.VPN.connection=VPN kapcsolat +label.vpn.customer.gateway=VPN \u00fcgyf\u00e9lkapu +label.VPN.customer.gateway=VPN \u00fcgyf\u00e9lkapu +label.VPN.gateway=VPN Gateway +label.vpn=VPN +label.vsmctrlvlanid=Control VLAN ID +label.vsmpktvlanid=Packet VLAN ID +label.vsmstoragevlanid=Storage VLAN ID +label.vsphere.managed=vSphere Managed +label.vswitch.name=vSwitch n\u00e9v +label.vSwitch.type=vSwitch t\u00edpus +label.vxlan.id=VXLAN ID +label.vxlan.range=VXLAN tartom\u00e1ny +label.vxlan=VXLAN +label.waiting=V\u00e1rakoz\u00e1s +label.warn=Figyelmeztet\u00e9s +label.warn.upper=WARN +label.wednesday=Szerda +label.weekly=Heti +label.welcome.cloud.console=\u00dcdv\u00f6z\u00f6l a vez\u00e9rl\u0151konzol\! +label.welcome=\u00dcdv\u00f6z\u00f6llek\! +label.what.is.cloudstack=Mi a CloudStack&\#8482? +label.xenserver.tools.version.61.plus=Original XS Version is 6.1\\+ +label.Xenserver.Tools.Version61plus=Original XS Version is 6.1\\+ +label.xenserver.traffic.label=XenServer traffic label +label.yes=Igen +label.zone.dedicated=A z\u00f3na dedik\u00e1lva +label.zone.details=Z\u00f3na r\u00e9szletei +label.zone.id=Z\u00f3na ID +label.zone.lower=z\u00f3na +label.zone.step.1.title=1. l\u00e9p\u00e9s\: H\u00e1l\u00f3zat kiv\u00e1laszt\u00e1sa +label.zone.step.2.title=2. l\u00e9p\u00e9s\: Z\u00f3na felv\u00e9tele +label.zone.step.3.title=3. l\u00e9p\u00e9s\: Pod felv\u00e9tele +label.zone.step.4.title=4. l\u00e9p\u00e9s\: IP c\u00edmtartom\u00e1ny felv\u00e9tele +label.zones=Z\u00f3n\u00e1k +label.zone.type=Z\u00f3na t\u00edpus +label.zone.wide=Eg\u00e9sz z\u00f3n\u00e1ra kiterjed\u0151 +label.zoneWizard.trafficType.guest=Guest\: Traffic between end-user virtual machines +label.zoneWizard.trafficType.management=Management\: Traffic between CloudStack\\\\'s internal resources, including any components that communicate with the Management Server, such as hosts and CloudStack system VMs +label.zoneWizard.trafficType.public=Public\: Traffic between the internet and virtual machines in the cloud. +label.zoneWizard.trafficType.storage=Storage\: Traffic between primary and secondary storage servers, such as VM templates and snapshots +label.zone=Z\u00f3na +managed.state=Managed State +message.acquire.ip.nic=Please confirm that you would like to acquire a new secondary IP for this NIC.
NOTE\: You need to manually configure the newly-acquired secondary IP inside the virtual machine. +message.acquire.new.ip=Er\u0151s\u00edtsd meg, hogy \u00faj IP c\u00edmet k\u00e9rsz ennek a h\u00e1l\u00f3zatnak\! +message.acquire.new.ip.vpc=Er\u0151s\u00edtsd meg, hogy \u00faj IP c\u00edmet k\u00e9rsz ennek a VPC-nek\! +message.acquire.public.ip=V\u00e1lassz ki egy z\u00f3n\u00e1t, amelyikb\u0151l az \u00faj IP c\u00edmet k\u00e9rni akarod\! +message.action.cancel.maintenance=A kiszolg\u00e1l\u00f3 karbantart\u00e1s\u00e1t sikeresen megszak\u00edtottad. Ez a folyamat t\u00f6bb percet vehet ig\u00e9nybe. +message.action.cancel.maintenance.mode=Er\u0151s\u00edtsd meg, hogy meg akarod szak\u00edtani ezt a karbantart\u00e1st\! +message.action.change.service.warning.for.instance=A p\u00e9ld\u00e1nyt le kell \u00e1ll\u00edtani, miel\u0151tt a jelenlegi szolg\u00e1ltat\u00e1si aj\u00e1nlatait megpr\u00f3b\u00e1lod megv\u00e1ltoztatni. +message.action.change.service.warning.for.router=A routert le kell \u00e1ll\u00edtani miel\u00f6tt a jelenlegi szolg\u00e1ltat\u00e1si aj\u00e1nlatait megpr\u00f3b\u00e1lod megv\u00e1ltoztatni. +message.action.delete.cluster=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod a f\u00fcrt\u00f6t\! +message.action.delete.disk.offering=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod a merevlemez aj\u00e1nlatot\! +message.action.delete.domain=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt a dom\u00e9nt\! +message.action.delete.external.firewall=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt a k\u00fcls\u0151 t\u0171zfalat\! Figyelmeztet\u00e9s\: Ha azt tervezed, hogy ugyanazt a k\u00fcls\u0151 t\u0171zfalat regisztr\u00e1lod \u00fajra, az eszk\u00f6z\u00f6n t\u00f6r\u00f6ln\u00f6d kell a haszn\u00e1lati adatokat. +message.action.delete.external.load.balancer=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt a k\u00fcls\u0151 terhel\u00e9seloszt\u00f3t\! Figyelmeztet\u00e9s\: Ha azt tervezed, hogy ugyanazt a k\u00fcls\u0151 terhel\u00e9seloszt\u00f3t regisztr\u00e1lod \u00fajra, az eszk\u00f6z\u00f6n t\u00f6r\u00f6ln\u00f6d kell a haszn\u00e1lati adatokat. +message.action.delete.ingress.rule=Please confirm that you want to delete this ingress rule. +message.action.delete.ISO=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt az ISO-t\! +message.action.delete.ISO.for.all.zones=Az ISO-t minden z\u00f3na haszn\u00e1lja. Er\u0151s\u00edtsd meg, hogy minden z\u00f3n\u00e1b\u00f3l t\u00f6r\u00f6lni akarod\! +message.action.delete.network=Er\u0151s\u00edtsd meg, hogy le akarod t\u00f6r\u00f6lni ezt a h\u00e1l\u00f3zatot\! +message.action.delete.nexusVswitch=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt a nexus 1000v-t\! +message.action.delete.nic=Er\u0151s\u00edtsd meg, hogy el akarod t\u00e1vol\u00edtani a NIC-t\! A hozz\u00e1 kapcsolt h\u00e1l\u00f3zat is t\u00f6rl\u0151dik a VM-b\u0151l. +message.action.delete.physical.network=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt a fizikai h\u00e1l\u00f3zatot\! +message.action.delete.pod=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt a pod-ot\! +message.action.delete.primary.storage=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt az els\u0151dleges t\u00e1rat\! +message.action.delete.secondary.storage=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt a m\u00e1sodlagos t\u00e1rat\! +message.action.delete.security.group=K\u00e9rlek er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt a biztons\u00e1gi csoportot\! +message.action.delete.service.offering=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt a szolg\u00e1ltat\u00e1s aj\u00e1nlatot\! +message.action.delete.snapshot=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt a pillanatfelv\u00e9telt\! +message.action.delete.system.service.offering=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt a rendszer szolg\u00e1ltat\u00e1s aj\u00e1nlatot\! +message.action.delete.template=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt a sablont\! +message.action.delete.template.for.all.zones=The template is used by all zones. Please confirm that you want to delete it from all zones. +message.action.delete.volume=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt a k\u00f6tetet\! +message.action.delete.zone=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt a z\u00f3n\u00e1t\! +message.action.destroy.instance=Er\u0151s\u00edtsd meg, hogy el akarod puszt\u00edtani ezt a p\u00e9ld\u00e1nyt\! +message.action.destroy.systemvm=Er\u0151s\u00edtsd meg, hogy el akarod puszt\u00edtani ezt a rendszer VM-et\! +message.action.disable.cluster=Er\u0151s\u00edtsd meg, hogy ki akarod kapcsolni ezt a f\u00fcrt\u00f6t\! +message.action.disable.nexusVswitch=Er\u0151s\u00edtsd meg, hogy ki akarod kapcsolni ezt a nexus 1000v-t\! +message.action.disable.physical.network=Er\u0151s\u00edtsd meg, hogy ki akarod kapcsolni ezt a fizikai h\u00e1l\u00f3zatot\! +message.action.disable.pod=Er\u0151s\u00edtsd meg, hogy ki akarod kapcsolni ezt a pod-ot\! +message.action.disable.static.NAT=Er\u0151s\u00edtsd meg, hogy ki akarod kapcsolni a statikus NAT-ot\! +message.action.disable.zone=Er\u0151s\u00edtsd meg, hogy ki akarod kapcsolni ezt a z\u00f3n\u00e1t\! +message.action.downloading.template=Sablon let\u00f6lt\u00e9se +message.action.download.iso=Er\u0151s\u00edtsd meg, hogy le akarod t\u00f6lteni ezt az ISO-t\! +message.action.download.template=Er\u0151s\u00edtsd meg, hogy le akarod t\u00f6lteni ezt a sablont\! +message.action.enable.cluster=Er\u0151s\u00edtsd meg, hogy be akarod kapcsolni ezt a f\u00fcrt\u00f6t\! +message.action.enable.maintenance=A kiszolg\u00e1l\u00f3 sikeresen felk\u00e9sz\u00fclt a karbantart\u00e1sra. Ez a m\u0171velet t\u00f6bb percet is ig\u00e9nybe vehet att\u00f3l f\u00fcgg\u0151en, mennyi VM fut rajta jelenleg. +message.action.enable.nexusVswitch=Please confirm that you want to enable this nexus 1000v +message.action.enable.physical.network=Please confirm that you want to enable this physical network. +message.action.enable.pod=Er\u0151s\u00edtsd meg, hogy be akarod kapcsolni ezt a pod-ot\! +message.action.enable.zone=Er\u0151s\u00edtsd meg, hogy be akarod kapcsolni ezt a z\u00f3n\u00e1t\! +message.action.expunge.instance=Please confirm that you want to expunge this instance. +message.action.force.reconnect=A kiszolg\u00e1l\u00f3 \u00fajrakapcsol\u00f3d\u00e1s\u00e1t siker\u00fclt kik\u00e9nyszer\u00edteni. Ez a folyamat t\u00f6bb percet veet ig\u00e9nybe. +message.action.host.enable.maintenance.mode=A karbantart\u00e1s elind\u00edt\u00e1sa az \u00f6sszes a kiszolg\u00e1l\u00f3n fut\u00f3 p\u00e9ld\u00e1ny m\u00e1s kiszolg\u00e1l\u00f3ra k\u00f6lt\u00f6ztet\u00e9s\u00e9t ind\u00edtja el. +message.action.instance.reset.password=Er\u0151s\u00edtsd meg, hogy meg akarod v\u00e1ltoztatni a virtu\u00e1lis g\u00e9p ROOT jelszav\u00e1t\! +message.action.manage.cluster=Please confirm that you want to manage the cluster. +message.action.primarystorage.enable.maintenance.mode=Figyelmeztet\u00e9s\: az els\u0151dleges t\u00e1r karbantart\u00e1si m\u00f3dba helyez\u00e9se minden azt haszn\u00e1l\u00f3 VM-et le\u00e1ll\u00edt. Akarod folytatni? +message.action.reboot.instance=Please confirm that you want to reboot this instance. +message.action.reboot.router=All services provided by this virtual router will be interrupted. Please confirm that you want to reboot this router. +message.action.reboot.systemvm=Please confirm that you want to reboot this system VM. +message.action.release.ip=Please confirm that you want to release this IP. +message.action.remove.host=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt a kiszolg\u00e1l\u00f3t\! +message.action.reset.password.off=Your instance currently does not support this feature. +message.action.reset.password.warning=A p\u00e9ld\u00e1nyt le kell \u00e1ll\u00edtanod, miel\u00f6tt megpr\u00f3b\u00e1ln\u00e1d lecser\u00e9lni a jelszav\u00e1t. +message.action.restore.instance=Er\u0151s\u00edtsd meg, hogy helyre akarod \u00e1ll\u00edtani ezt a p\u00e9ld\u00e1nyt\! +message.action.revert.snapshot=Please confirm that you want to revert the owning volume to this snapshot. +message.action.start.instance=Er\u0151s\u00edtsd meg, hogy el akarod ind\u00edtani ezt a p\u00e9ld\u00e1nyt\! +message.action.start.router=Er\u0151s\u00edtsd meg, hogy el akarod ind\u00edtani ezt a routert\! +message.action.start.systemvm=Er\u0151s\u00edtsd meg, hogy el akarod ind\u00edtani ezt a rendszer VM-et\! +message.action.stop.instance=Er\u0151s\u00edtsd meg, hogy le akarod \u00e1ll\u00edtani ezt a p\u00e9ld\u00e1nyt\! +message.action.stop.router=Minden ezzel a routerrel kapcsolatos szolg\u00e1ltat\u00e1s megszakad. Er\u0151s\u00edtsd meg, hogy le akarod \u00e1ll\u00edtani ezt a routert\! +message.action.stop.systemvm=Er\u0151s\u00edtsd meg, hogy le akarod \u00e1ll\u00edtani ezt a rendszer VM-et\! +message.action.take.snapshot=Er\u0151s\u00edtsd meg, hogy pillanatfelv\u00e9telt k\u00e9rsz err\u0151l a k\u00f6tetr\u0151l\! +message.action.unmanage.cluster=Please confirm that you want to unmanage the cluster. +message.action.vmsnapshot.delete=Please confirm that you want to delete this VM snapshot. +message.action.vmsnapshot.revert=Revert VM snapshot +message.activate.project=Biztosan aktiv\u00e1lni szeretn\u00e9d ezt a projektet? +message.add.cluster=Add a hypervisor managed cluster for zone , pod +message.add.cluster.zone=Add a hypervisor managed cluster for zone +message.add.disk.offering=Add meg a k\u00f6vetkez\u0151 param\u00e9tereket az \u00faj merevlemez aj\u00e1nlat felv\u00e9tel\u00e9hez +message.add.domain=Please specify the subdomain you want to create under this domain +message.add.firewall=Add a firewall to zone +message.add.guest.network=Please confirm that you would like to add a guest network +message.add.host=Add meg a k\u00f6vetkez\u0151 adatokat az \u00faj kiszolg\u00e1l\u00f3 felv\u00e9tel\u00e9hez +message.adding.host=Kiszolg\u00e1l\u00f3 felv\u00e9tele +message.adding.Netscaler.device=Netscaler eszk\u00f6z felv\u00e9tele +message.adding.Netscaler.provider=Netscaler szolg\u00e1ltat\u00f3 felv\u00e9tele +message.add.ip.range=Add an IP range to public network in zone +message.add.ip.range.direct.network=Add an IP range to direct network in zone +message.add.ip.range.to.pod=

Add an IP range to pod\:

+message.additional.networks.desc=Please select additional network(s) that your virtual instance will be connected to. +message.add.load.balancer=Add a load balancer to zone +message.add.load.balancer.under.ip=The load balancer rule has been added under IP\: +message.add.network=Add a new network for zone\: +message.add.new.gateway.to.vpc=Please specify the information to add a new gateway to this VPC. +message.add.pod=Add a new pod for zone +message.add.primary=Please specify the following parameters to add a new primary storage +message.add.primary.storage=Add a new Primary Storage for zone , pod +message.add.region=Please specify the required information to add a new region. +message.add.secondary.storage=Add a new storage for zone +message.add.service.offering=Please fill in the following data to add a new compute offering. +message.add.system.service.offering=Please fill in the following data to add a new system service offering. +message.add.template=Please enter the following data to create your new template +message.add.volume=Please fill in the following data to add a new volume. +message.add.VPN.gateway=Please confirm that you want to add a VPN Gateway +message.admin.guide.read=For VMware-based VMs, please read the dynamic scaling section in the admin guide before scaling. Would you like to continue?\\, +message.advanced.mode.desc=Akkor v\u00e1laszd ezt a h\u00e1l\u00f3zat modellt, ha szeretn\u00e9d haszn\u00e1lni a VLAN t\u00e1mogat\u00e1st. Ez a h\u00e1l\u00f3zat modell biztos\u00edtja a legnagyobb rugalmass\u00e1got \u00e9s lehet\u0151v\u00e9 teszi, hogy a rendszergazd\u00e1k olyan aj\u00e1nlatokat biztos\u00edtsanak, mint a t\u0171zfalak, VPN vagy terhel\u00e9seloszt\u00f3k valamint a direkt \u00e9s virtu\u00e1lis h\u00e1l\u00f3zatok. +message.advanced.security.group=V\u00e1laszd ezt, ha biztons\u00e1gi csoportokat akarsz haszn\u00e1lni a vend\u00e9g VM izol\u00e1ci\u00f3hoz\! +message.advanced.virtual=Choose this if you wish to use zone-wide VLANs to provide guest VM isolation. +message.after.enable.s3=S3-backed Secondary Storage configured. Note\: When you leave this page, you will not be able to re-configure S3 again. +message.after.enable.swift=Swift configured. Note\: When you leave this page, you will not be able to re-configure Swift again. +message.alert.state.detected=Alert state detected +message.allow.vpn.access=Add meg a VPN felhaszn\u00e1l\u00f3 nev\u00e9t \u00e9s jelszav\u00e1t +message.apply.snapshot.policy=You have successfully updated your current snapshot policy. +message.attach.iso.confirm=Please confirm that you want to attach the ISO to this virtual instance. +message.attach.volume=Please fill in the following data to attach a new volume. If you are attaching a disk volume to a Windows based virtual machine, you will need to reboot the instance to see the attached disk. +message.basic.mode.desc=Akkor v\u00e1laszd ezt a h\u00e1l\u00f3zati modellt, ha *nem* akarsz VLAN t\u00e1mogat\u00e1st bekapcsolni. Ezen a h\u00e1l\u00f3zaton minden p\u00e9ld\u00e1ny k\u00f6zvetlen\u00fcl a h\u00e1l\u00f3zatt\u00f3l kap IP c\u00edmet \u00e9s a biztons\u00e1gi csoportok szolg\u00e1ltatnak biztons\u00e1got \u00e9s szegreg\u00e1ci\u00f3t. +message.change.offering.confirm=Please confirm that you wish to change the service offering of this virtual instance. +message.change.password=V\u00e1ltoztass jelsz\u00f3t\! +message.cluster.dedicated=Cluster Dedicated +message.cluster.dedication.released=Cluster dedication released +message.configure.all.traffic.types=You have multiple physical networks; please configure labels for each traffic type by clicking on the Edit button. +message.configure.ldap=Please confirm you would like to configure LDAP. +message.configuring.guest.traffic=Configuring guest traffic +message.configuring.physical.networks=Configuring physical networks +message.configuring.public.traffic=Configuring public traffic +message.configuring.storage.traffic=Configuring storage traffic +message.confirm.action.force.reconnect=Er\u0151s\u00edtsd meg, hogy \u00fajrakapcsol\u00f3dni akarsz a kiszolg\u00e1l\u00f3hoz\! +message.confirm.add.vnmc.provider=Please confirm you would like to add the VNMC provider. +message.confirm.archive.alert=Er\u0151s\u00edtsd meg, hogy archiv\u00e1lni akarod ezt a riaszt\u00e1st\! +message.confirm.archive.event=Please confirm that you want to archive this event. +message.confirm.archive.selected.alerts=Er\u0151s\u00edtsd meg, hogy le akarod archiv\u00e1lni a kiv\u00e1lasztott riaszt\u00e1sokat\! +message.confirm.archive.selected.events=Please confirm you would like to archive the selected events +message.confirm.attach.disk=Are you sure you want to attach disk? +message.confirm.create.volume=Are you sure you want to create volume? +message.confirm.current.guest.CIDR.unchanged=Do you want to keep the current guest network CIDR unchanged? +message.confirm.dedicate.cluster.domain.account=T\u00e9nyleg dedik\u00e1lni akarod ezt a f\u00fcrt\u00f6t egy dom\u00e9nnek/sz\u00e1ml\u00e1nak? +message.confirm.dedicate.host.domain.account=T\u00e9nyleg dedik\u00e1lni akarod ezt a kiszolg\u00e1l\u00f3t egy dom\u00e9nnek vagy sz\u00e1ml\u00e1nak? +message.confirm.dedicate.pod.domain.account=Do you really want to dedicate this pod to a domain/account? +message.confirm.dedicate.zone=Do you really want to dedicate this zone to a domain/account? +message.confirm.delete.acl.list=Are you sure you want to delete this ACL list? +message.confirm.delete.alert=Biztosan t\u00f6r\u00f6lni akarod ezt a riaszt\u00e1st? +message.confirm.delete.BrocadeVcs=Please confirm that you would like to delete Brocade Vcs Switch +message.confirm.delete.ciscoASA1000v=Please confirm you want to delete CiscoASA1000v +message.confirm.delete.ciscovnmc.resource=Please confirm you want to delete CiscoVNMC resource +message.confirm.delete.F5=Please confirm that you would like to delete F5 +message.confirm.delete.internal.lb=Please confirm you want to delete Internal LB +message.confirm.delete.NetScaler=Please confirm that you would like to delete NetScaler +message.confirm.delete.NuageVsp=Please confirm that you would like to delete Nuage Virtualized Services Directory +message.confirm.delete.PA=Please confirm that you would like to delete Palo Alto +message.confirm.delete.secondary.staging.store=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod a m\u00e1sodlagos t\u00e1rat\! +message.confirm.delete.SRX=Please confirm that you would like to delete SRX +message.confirm.delete.ucs.manager=Please confirm that you want to delete UCS Manager +message.confirm.destroy.router=Please confirm that you would like to destroy this router +message.confirm.disable.host=Er\u0151s\u00edtsd meg, hogy ki akarod kapcsolni a kiszolg\u00e1l\u00f3t +message.confirm.disable.network.offering=Biztos vagy abban, hogy ki akarod kapcsolni ezt a h\u00e1l\u00f3zat aj\u00e1nlatot? +message.confirm.disable.provider=Please confirm that you would like to disable this provider +message.confirm.disable.vnmc.provider=Please confirm you would like to disable the VNMC provider. +message.confirm.disable.vpc.offering=Biztos vagy abban, hogy ki akarod kapcsolni ezt a VPC aj\u00e1nlatot? +message.confirm.enable.host=Er\u0151s\u00edtsd meg, hogy be akarod kapcsolni a kiszolg\u00e1l\u00f3t +message.confirm.enable.network.offering=Biztos vagy abban, hogy be akarod kapcsolni ezt a h\u00e1l\u00f3zati aj\u00e1nlatot? +message.confirm.enable.provider=Please confirm that you would like to enable this provider +message.confirm.enable.vnmc.provider=Please confirm you would like to enable the VNMC provider. +message.confirm.enable.vpc.offering=Biztos vagy abban, hogy be akarod kapcsolni ezt a VPC aj\u00e1nlatot? +message.confirm.join.project=Please confirm you wish to join this project. +message.confirm.migrate.volume=El akarod k\u00f6lt\u00f6ztetni ezt a k\u00f6tetet? +message.confirm.refresh.blades=Please confirm that you want to refresh blades. +message.confirm.release.dedicated.cluster=El akarod engedni ezt a dedik\u00e1lt f\u00fcrt\u00f6t? +message.confirm.release.dedicated.host=El akarod engedni ezt a dedik\u00e1lt kiszolg\u00e1l\u00f3t? +message.confirm.release.dedicated.pod=El akarod engedni ezt a dedik\u00e1lt pod-ot? +message.confirm.release.dedicated.zone=Do you want to release this dedicated zone ? +message.confirm.release.dedicate.vlan.range=Please confirm you want to release dedicated VLAN range +message.confirm.remove.event=Are you sure you want to remove this event? +message.confirm.remove.IP.range=Please confirm that you would like to remove this IP range. +message.confirm.remove.load.balancer=Please confirm you want to remove VM from load balancer +message.confirm.remove.network.offering=Biztos vagy abban, hogy t\u00f6r\u00f6lni akarod ezt a h\u00e1l\u00f3zati aj\u00e1nlatot? +message.confirm.remove.selected.alerts=Er\u0151s\u00edtsd meg, hogy el akarod t\u00e1vol\u00edtani a kiv\u00e1lasztott riaszt\u00e1sokat\! +message.confirm.remove.selected.events=Please confirm you would like to remove the selected events +message.confirm.remove.vmware.datacenter=Please confirm you want to remove VMware datacenter +message.confirm.remove.vpc.offering=Biztos vagy abban, hogy t\u00f6r\u00f6lni akarod ezt a VPC aj\u00e1nlatot? +message.confirm.replace.acl.new.one=Do you want to replace the ACL with a new one? +message.confirm.scale.up.router.vm=Do you really want to scale up the Router VM ? +message.confirm.scale.up.system.vm=Do you really want to scale up the system VM ? +message.confirm.shutdown.provider=Please confirm that you would like to shutdown this provider +message.confirm.start.lb.vm=Please confirm you want to start LB VM +message.confirm.stop.lb.vm=Please confirm you want to stop LB VM +message.confirm.upgrade.router.newer.template=Please confirm that you want to upgrade router to use newer template +message.confirm.upgrade.routers.account.newtemplate=Please confirm that you want to upgrade all routers in this account to use newer template +message.confirm.upgrade.routers.cluster.newtemplate=Please confirm that you want to upgrade all routers in this cluster to use newer template +message.confirm.upgrade.routers.newtemplate=Please confirm that you want to upgrade all routers in this zone to use newer template +message.confirm.upgrade.routers.pod.newtemplate=Please confirm that you want to upgrade all routers in this pod to use newer template +message.copy.iso.confirm=Please confirm that you wish to copy your ISO to +message.copy.template=A XXX sablon m\u00e1sol\u00e1sa a z\u00f3n\u00e1b\u00f3l a +message.copy.template.confirm=Biztos vagy benne, hogy le akarod m\u00e1solni a sablont? +message.create.template=Are you sure you want to create template? +message.create.template.vm=Create VM from template +message.create.template.volume=Please specify the following information before creating a template of your disk volume\: . Creation of the template can range from several minutes to longer depending on the size of the volume. +message.creating.cluster=Creating cluster +message.creating.guest.network=Creating guest network +message.creating.physical.networks=Creating physical networks +message.creating.pod=Creating pod +message.creating.primary.storage=Creating primary storage +message.creating.secondary.storage=Creating secondary storage +message.creating.systemVM=A rendszer VM-ek l\u00e9trehoz\u00e1sa folyamatban (ez eltarthat egy darabig) +message.creating.zone=Z\u00f3na l\u00e9trehoz\u00e1sa +message.decline.invitation=Are you sure you want to decline this project invitation? +message.dedicated.zone.released=Z\u00f3na elengedve +message.dedicate.zone=Dedicating zone +message.delete.account=Please confirm that you want to delete this account. +message.delete.affinity.group=Please confirm that you would like to remove this affinity group. +message.delete.gateway=Please confirm you want to delete the gateway +message.delete.project=Are you sure you want to delete this project? +message.delete.user=Please confirm that you would like to delete this user. +message.delete.VPN.connection=Please confirm that you want to delete VPN connection +message.delete.VPN.customer.gateway=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt a VPN \u00fcgyf\u00e9lkaput\! +message.delete.VPN.gateway=Please confirm that you want to delete this VPN Gateway +message.desc.advanced.zone=\u00d6sszetettebb h\u00e1l\u00f3zati topol\u00f3gi\u00e1khoz. Ez a h\u00e1l\u00f3zat modell biztos\u00edtja a legnagyobb rugalmass\u00e1got a vend\u00e9g h\u00e1l\u00f3zatok fel\u00e9p\u00edt\u00e9s\u00e9ben \u00e9s olyan h\u00e1l\u00f3zati aj\u00e1nlatokat tesz lehet\u0151v\u00e9, mint a t\u0171zfalak, VPN vagy terhel\u00e9seloszt\u00f3k. +message.desc.basic.zone=Adj meg egy h\u00e1l\u00f3zatot, amelyen minden egyes VM p\u00e9ld\u00e1ny k\u00f6zvetlen\u00fcl a h\u00e1l\u00f3zatt\u00f3l kap IP c\u00edmet. A vend\u00e9g rendszerek izol\u00e1ci\u00f3j\u00e1t 3. r\u00e9teg-b\u00e9li megold\u00e1sokkal, mint p\u00e9ld\u00e1ul biztons\u00e1gi csoportokkal (IP c\u00edm filterez\u00e9s) oldhat\u00f3 meg. +message.desc.cluster=Minden pod-nak tartalmaznia kell egy vagy t\u00f6bb f\u00fcrt\u00f6t \u00e9s most l\u00e9trehozzuk az els\u0151 f\u00fcrt\u00f6t. A f\u00fcrt csoportos\u00edtja a kiszolg\u00e1l\u00f3kat. Egy f\u00fcrtben tal\u00e1lhat\u00f3 kiszolg\u00e1l\u00f3k ugyanolyan hardverrel rendelkeznek, ugyanolyan hipervizort futtatnak \u00e9s ugyanahhoz az els\u0151dleges t\u00e1rol\u00f3hoz f\u00e9rnek hozz\u00e1. Minden f\u00fcrt egy vagy t\u00f6bb kiszolg\u00e1l\u00f3t \u00e9s els\u0151dleges t\u00e1r szervert tartalmaz. +message.desc.host=Minden f\u00fcrtnek legal\u00e1bb egy kiszolg\u00e1l\u00f3t kell tartalmaznia, amelyen a VM-ek futhatnak. Most vegy\u00fck fel az els\u0151 kiszolg\u00e1l\u00f3t\! Hogy a kiszolg\u00e1l\u00f3 m\u0171k\u00f6dhessen, hipervizor szoftvert kell r\u00e1 telep\u00edteni, IP c\u00edmet rendelni hozz\u00e1 \u00e9s biztos\u00edtani a kapcsolatot a CloudStack vez\u00e9rl\u0151 szerverrel.

Add meg a kiszolg\u00e1l\u00f3 DNS vagy IP c\u00edm\u00e9t, a felhaszn\u00e1l\u00f3 nev\u00e9t (\u00e1ltal\u00e1ban root) \u00e9s jelszav\u00e1t, valamint a kiszolg\u00e1l\u00f3 kategoriz\u00e1l\u00e1s\u00e1ra szolg\u00e1l\u00f3 c\u00edmk\u00e9ket. +message.desc.primary.storage=Minden f\u00fcrt tartalmaz egy vagy t\u00f6bb els\u0151dleges t\u00e1r szervert \u00e9s most l\u00e9trehozzuk az els\u0151t. Az els\u0151dleges t\u00e1r tartalmazza a f\u00fcrt kiszolg\u00e1l\u00f3in fut\u00f3 \u00f6sszes VM virtu\u00e1lis merevlemezeit. +message.desc.secondary.storage=Minden z\u00f3n\u00e1nak rendelkeznie kell legal\u00e1bb egy NFS vagy m\u00e1sodlagos t\u00e1r szervert \u00e9s most l\u00e9trehozzuk az els\u0151t. A m\u00e1sodlagos t\u00e1r t\u00e1rolja a VM sablonok, ISO f\u00e1jlok \u00e9s pillanatfelv\u00e9telek adatait. Ennek a szervernek minden kiszolg\u00e1l\u00f3 sz\u00e1m\u00e1ra hozz\u00e1f\u00e9rhet\u0151nek kell lennie.

Add meg az IP c\u00edmet \u00e9s az \u00fatvonalat\! +message.desc.zone=A z\u00f3na a CloudStack legnagyobb egys\u00e9ge \u00e9s \u00e1ltal\u00e1ban egy adatk\u00f6zpontnak felel meg. A z\u00f3n\u00e1k fizikai izol\u00e1ci\u00f3t adnak. Egy z\u00f3na egy vagy t\u00f6bb pod-b\u00f3l \u00e1ll (amelyek kiszolg\u00e1l\u00f3kat \u00e9s els\u0151dleges t\u00e1rol\u00f3kat tartalmaznak) \u00e9s egy m\u00e1sodlagos t\u00e1rb\u00f3l, amelyet az \u00f6sszes pod haszn\u00e1l. +message.detach.disk=Biztosan la akarod v\u00e1lasztani a merevlemezt? +message.detach.iso.confirm=Er\u0151s\u00edtsd meg, hogy le akarod v\u00e1lasztani az ISO-t a virtu\u00e1lis g\u00e9pr\u0151l\! +message.disable.account=Er\u0151s\u00edtsd meg, hogy ki szeretn\u00e9d kapcsolni ezt a sz\u00e1ml\u00e1t. A sz\u00e1mla kikapcsol\u00e1s\u00e1val a sz\u00e1mla felhaszn\u00e1l\u00f3inak hozz\u00e1f\u00e9r\u00e9se az er\u0151forr\u00e1sokhoz megsz\u00fcnik. Minden fut\u00f3 virtu\u00e1lis g\u00e9p azonnal le lesz \u00e1ll\u00edtva. +message.disable.snapshot.policy=You have successfully disabled your current snapshot policy. +message.disable.user=Er\u0151s\u00edtsd meg, hogy ki akarod kapcsolni a felhaszn\u00e1l\u00f3t\! +message.disable.vpn.access=Please confirm that you want to disable Remote Access VPN. +message.disable.vpn=Biztosan ki akarod kapcsolni a VPN-t? +message.disabling.network.offering=H\u00e1l\u00f3zat aj\u00e1nlat kikapcsol\u00e1sa +message.disabling.vpc.offering=VPC aj\u00e1nlat kikapcsol\u00e1sa +message.disallowed.characters=Nem enged\u00e9lyezett karakterek\: \\<\\,\\> +message.download.ISO=Az ISO let\u00f6lt\u00e9s\u00e9hez kattints 00000 +message.download.template=A sablon let\u00f6lt\u00e9s\u00e9hez kattints 00000 +message.download.volume=A k\u00f6tet let\u00f6lt\u00e9s\u00e9hez kattints href\="\#">00000 +message.download.volume.confirm=Er\u0151s\u00edtsd meg, hogy le akarod t\u00f6lteni ezt a k\u00f6tetet\! +message.edit.account=Edit ("-1" indicates no limit to the amount of resources create) +message.edit.confirm=Er\u0151s\u00edtsd meg a v\u00e1ltoztat\u00e1sokat miel\u00f6tt a ment\u00e9sre kattintassz\! +message.edit.limits=Hat\u00e1rozz meg korl\u00e1tokat a k\u00f6vetkez\u0151 er\u0151forr\u00e1sokhoz\! A "-1" jelzi a korl\u00e1tlanan felhaszn\u00e1l\u00e1st. +message.edit.traffic.type=Please specify the traffic label you want associated with this traffic type. +message.enable.account=Er\u0151s\u00edtsd meg, hogy be akarod kapcsolni ezt a sz\u00e1ml\u00e1t\! +message.enabled.vpn.ip.sec=Your IPSec pre-shared key is +message.enabled.vpn=Your Remote Access VPN is currently enabled and can be accessed via the IP +message.enable.user=Er\u0151s\u00edtsd meg, hogy be akarod kapcsolni ezt a felhaszn\u00e1l\u00f3t\! +message.enable.vpn.access=VPN is currently disabled for this IP Address. Would you like to enable VPN access? +message.enable.vpn=Please confirm that you want Remote Access VPN enabled for this IP address. +message.enabling.network.offering=H\u00e1l\u00f3zat aj\u00e1nlat bekapcsol\u00e1sa +message.enabling.security.group.provider=Biztons\u00e1gi csoport szolg\u00e1ltat\u00f3 bekapcsol\u00e1sa +message.enabling.vpc.offering=VPC aj\u00e1nlat bekapcsol\u00e1sa +message.enabling.zone.dots=Z\u00f3na enged\u00e9lyez\u00e9se... +message.enabling.zone=Z\u00f3na bekapcsol\u00e1sa +message.enter.seperated.list.multiple.cidrs=Add meg a CIDR list\u00e1t vessz\u0151kkel elv\u00e1laszva, ha egyn\u00e9l t\u00f6b van\! +message.enter.token=Please enter the token that you were given in your invite e-mail. +message.generate.keys=Er\u0151s\u00edtsd meg, hogy \u00faj kulcsokat szeretn\u00e9l gener\u00e1lni a felhaszn\u00e1l\u00f3nak\! +message.gslb.delete.confirm=Please confirm you want to delete this GSLB +message.gslb.lb.remove.confirm=Please confirm you want to remove load balancing from GSLB +message.guest.traffic.in.advanced.zone=Guest network traffic is communication between end-user virtual machines. Specify a range of VLAN IDs to carry guest traffic for each physical network. +message.guest.traffic.in.basic.zone=Guest network traffic is communication between end-user virtual machines. Specify a range of IP addresses that CloudStack can assign to guest VMs. Make sure this range does not overlap the reserved system IP range. +message.host.dedicated=Dedik\u00e1lt kiszolg\u00e1l\u00f3 +message.host.dedication.released=Kiszolg\u00e1l\u00f3 elengedve +message.installWizard.click.retry=Kattints az ind\u00edt\u00e1s gombra az ism\u00e9tl\u00e9shez. +message.installWizard.copy.whatIsACluster=A f\u00fcrt kiszolg\u00e1l\u00f3k csoportja. A f\u00fcrt kiszolg\u00e1l\u00f3i egyforma hardverrel rendelkeznek, ugyanazt a hi\u0151erv\u00edzort haszn\u00e1lj\u00e1k, ugyanazon az alh\u00e1l\u00f3zaton tal\u00e1lhat\u00f3ak \u00e9s hozz\u00e1f\u00e9rnek ugyanahhoz az osztott t\u00e1rhoz. A virtu\u00e1lis g\u00e9pek egy f\u00fcrt\u00f6n bel\u00fcl \u00e1tk\u00f6lt\u00f6ztethet\u0151 m\u00e1sik kiszolg\u00e1l\u00f3ra ann\u00e9lk\u00fcl, hogy annak m\u0171k\u00f6d\u00e9s\u00e9t megszak\u00edtan\u00e1nk. A f\u00fcrt a CloudStack&\#8482; harmadik legnagyobb egys\u00e9ge. A f\u00fcrt\u00f6k pod-okba, a pod-ok z\u00f3n\u00e1kba rendez\u0151dnek.

A CloudStack&\#8482; lehet\u0151v\u00e9 teszi, hogy t\u00f6bb f\u00fcrt\u00f6t haszn\u00e1lj, de egy alap telep\u00edt\u00e9sben csak egy f\u00fcrtre van sz\u00fcks\u00e9g. +message.installWizard.copy.whatIsAHost=A kiszolg\u00e1l\u00f3 egy sz\u00e1m\u00edt\u00f3g\u00e9p. A kiszolg\u00e1l\u00f3k biztos\u00edtj\u00e1k a sz\u00e1m\u00edt\u00e1si er\u0151forr\u00e1sokat, amelyeket a virtu\u00e1lis g\u00e9pek felhaszn\u00e1lnak. Minden kiszolg\u00e1l\u00f3 rendelkezik hipervizor szoftverrel, amely a vend\u00e9g VM-eket futtatja (kiv\u00e9tel a bare-metal kiszolg\u00e1l\u00f3k). P\u00e9ld\u00e1ul egy Linux KVM szerver, Citrix XenServer vagy egy ESXi szerver. Az alaptelep\u00edt\u00e9sben csak egy KVM-et vagy XenServer-t futtat\u00f3 kiszolg\u00e1l\u00f3t haszn\u00e1lunk.

A kiszolg\u00e1l\u00f3 a CloudStack&\#8482; telep\u00edt\u00e9s legkissebb egys\u00e9ge. A kiszolg\u00e1l\u00f3k f\u00fcrt\u00f6kbe, a f\u00fcrt\u00f6k pod-okba, a pod-ok z\u00f3n\u00e1kba rendez\u0151dnek. +message.installWizard.copy.whatIsAPod=A pod-ra gyakran egy rack-szekr\u00e9nyt jelent. Az egy pod-ban tal\u00e1lhat\u00f3 kiszolg\u00e1l\u00f3k egy alh\u00e1l\u00f3zaton vannak.

A pod a CloudStack&\#8482; telep\u00edt\u00e9s m\u00e1sodik legnagyobb egys\u00e9ge. A pod-ok z\u00f3n\u00e1kat alkotnak. Minden z\u00f3na tartalmazhat egy vagy t\u00f6bb pod-ot. Az alaptelep\u00edt\u00e9sben csak egy pod-ra van sz\u00fcks\u00e9g\u00fcnk. +message.installWizard.copy.whatIsAZone=A z\u00f3na a CloudStack&\#8482; telep\u00edt\u00e9s legnagyobb egys\u00e9ge. Egy z\u00f3na \u00e1ltal\u00e1ban egy adatk\u00f6zpontnak felel meg, b\u00e1r megengedhet\u0151 egy adatk\u00f6zponton bel\u00fcl t\u00f6bb z\u00f3na l\u00e9trehoz\u00e1sa. Az er\u0151forr\u00e1sok z\u00f3n\u00e1kra val\u00f3 oszt\u00e1s\u00e1nak c\u00e9lja a redundancia \u00e9s a fizikai izol\u00e1ci\u00f3. P\u00e9ld\u00e1ul minden z\u00f3n\u00e1nak lehet saj\u00e1t \u00e1ramell\u00e1t\u00e1sa \u00e9s h\u00e1l\u00f3zati kapcsolata, valamint a z\u00f3n\u00e1k f\u00f6ldrajzilag egym\u00e1st\u00f3l t\u00e1vol helyezkedhetnek el (b\u00e1r ez nem felt\u00e9tlen\u00fcl sz\u00fcks\u00e9ges). +message.installWizard.copy.whatIsCloudStack=A CloudStack&\#8482 egy szoftver, amely sz\u00e1m\u00edt\u00e1si er\u0151forr\u00e1sokat fel\u00fcgyel \u00e9s alkalmas publikus, priv\u00e1t, vagy hibrid infrastrukt\u00fara szolg\u00e1ltat\u00e1s (IaaS) felh\u0151k \u00e9p\u00edt\u00e9s\u00e9re. A CloudStack&\#8482 ir\u00e1ny\u00edtja a h\u00e1l\u00f3zatokat, az adatt\u00e1rol\u00f3kat \u00e9s kiszolg\u00e1l\u00f3kat, amelyek a felh\u0151 infrastrukt\u00far\u00e1t alkotj\u00e1k.

A k\u00fcl\u00f6n\u00e1ll\u00f3 virtu\u00e1lis g\u00e9peken t\u00fal a CloudStack&\#8482 teljes felh\u0151 insfrastrukt\u00far\u00e1t szolg\u00e1ltat. Ny\u00edlt forr\u00e1sk\u00f3d\u00fa \u00e9s pr\u00e9mium verzi\u00f3k egyar\u00e1nt el\u00e9rhet\u0151ek, a ny\u00edlt forr\u00e1sk\u00f3d\u00fa verzi\u00f3k k\u00f6zel azonos k\u00e9pess\u00e9gekkel rendelkeznek. +message.installWizard.copy.whatIsPrimaryStorage=A CloudStack&\#8482; infrastrukt\u00fara k\u00e9t f\u00e9le afatt\u00e1rol\u00f3t haszn\u00e1l\: els\u0151dleges \u00e9s m\u00e1sodlagos t\u00e1rat. Mindkett\u0151 lehet ezek k\u00f6z\u00fcl iSCIS, NFS vagy helyi merevlemez.

Az els\u0151dleges t\u00e1r egy f\u00fcrth\u00f6z kapcsol\u00f3dik \u00e9s a f\u00fcrt\u00f6n fut\u00f3 virtu\u00e1lis g\u00e9pek virtu\u00e1lis merevlemezeit t\u00e1rolja. Az els\u0151dleges t\u00e1r tipikusan a kiszolg\u00e1l\u00f3khoz k\u00f6zel tal\u00e1lhat\u00f3. +message.installWizard.copy.whatIsSecondaryStorage=A m\u00e1sodlagos t\u00e1r egyz\u00f3n\u00e1hoz tartozik \u00e9s a k\u00f6vetkez\u0151ket tartalmazza\:
  • Sablonok - Telep\u00edtett oper\u00e1ci\u00f3s rendszerek, amelyek a VM-ek l\u00e9trehoz\u00e1s\u00e1ra haszn\u00e1lhat\u00f3 \u00e9s tartalmazhat egy\u00e9b konfigur\u00e1ci\u00f3s inform\u00e1ci\u00f3kat, mint pl telep\u00edtett alkalmaz\u00e1sok.
  • ISO f\u00e1jlok - OS images that can be bootable or non-bootable
  • Disk volume snapshots - saved copies of VM data which can be used for data recovery or to create new templates
+message.installWizard.now.building=A felh\u0151d most \u00e9p\u00fcl... +message.installWizard.tooltip.addCluster.name=A f\u00fcrt neve. Ez tetsz\u0151leges \u00e1ltalad v\u00e1lasztott sz\u00f6veg lehet. +message.installWizard.tooltip.addHost.hostname=A kiszolg\u00e1l\u00f3 IP c\u00edme vagy DNS neve. +message.installWizard.tooltip.addHost.password=A fenti felhaszn\u00e1l\u00f3 jelszava. +message.installWizard.tooltip.addHost.username=\u00c1ltal\u00e1ban root. +message.installWizard.tooltip.addPod.name=A pod neve +message.installWizard.tooltip.addPod.reservedSystemEndIp=This is the IP range in the private network that the CloudStack uses to manage Secondary Storage VMs and Console Proxy VMs. These IP addresses are taken from the same subnet as computing servers. +message.installWizard.tooltip.addPod.reservedSystemGateway=\u00c1tj\u00e1r\u00f3 a pod kiszolg\u00e1l\u00f3inak. +message.installWizard.tooltip.addPod.reservedSystemNetmask=A h\u00e1l\u00f3zati maszk, amit a vend\u00e9g oper\u00e1ci\u00f3s rendszerek haszn\u00e1lnak majd. +message.installWizard.tooltip.addPod.reservedSystemStartIp=This is the IP range in the private network that the CloudStack uses to manage Secondary Storage VMs and Console Proxy VMs. These IP addresses are taken from the same subnet as computing servers. +message.installWizard.tooltip.addPrimaryStorage.name=A t\u00e1r eszk\u00f6z neve. +message.installWizard.tooltip.addPrimaryStorage.path=(NFS eset\u00e9ben) In NFS this is the exported path from the server. Path (for SharedMountPoint). With KVM this is the path on each host that is where this primary storage is mounted. For example, "/mnt/primary". +message.installWizard.tooltip.addPrimaryStorage.server=(NFS, iSCSI vagy PreSetup eset\u00e9ben) A t\u00e1reszk\u00f6z IP vagy DNS c\u00edme. +message.installWizard.tooltip.addSecondaryStorage.nfsServer=A m\u00e1sodlagos t\u00e1rat kiszolg\u00e1l\u00f3 NFS szerver IP c\u00edme +message.installWizard.tooltip.addSecondaryStorage.path=A fenti szerveren kiexport\u00e1lt \u00fatvonal +message.installWizard.tooltip.addZone.dns1=These are DNS servers for use by guest VMs in the zone. These DNS servers will be accessed via the public network you will add later. The public IP addresses for the zone must have a route to the DNS server named here. +message.installWizard.tooltip.addZone.dns2=These are DNS servers for use by guest VMs in the zone. These DNS servers will be accessed via the public network you will add later. The public IP addresses for the zone must have a route to the DNS server named here. +message.installWizard.tooltip.addZone.internaldns1=These are DNS servers for use by system VMs in the zone. These DNS servers will be accessed via the private network interface of the System VMs. The private IP address you provide for the pods must have a route to the DNS server named here. +message.installWizard.tooltip.addZone.internaldns2=These are DNS servers for use by system VMs in the zone. These DNS servers will be accessed via the private network interface of the System VMs. The private IP address you provide for the pods must have a route to the DNS server named here. +message.installWizard.tooltip.addZone.name=A z\u00f3na neve +message.installWizard.tooltip.configureGuestTraffic.description=A h\u00e1l\u00f3zat le\u00edr\u00e1sa +message.installWizard.tooltip.configureGuestTraffic.guestEndIp=The range of IP addresses that will be available for allocation to guests in this zone. If one NIC is used, these IPs should be in the same CIDR as the pod CIDR. +message.installWizard.tooltip.configureGuestTraffic.guestGateway=A h\u00e1l\u00f3zati \u00e1tj\u00e1r\u00f3, amelyet a vend\u00e9g rendszerek haszn\u00e1lhatnak +message.installWizard.tooltip.configureGuestTraffic.guestNetmask=A veng\u00e9g rendszerek h\u00e1l\u00f3zat\u00e1nak maszkja +message.installWizard.tooltip.configureGuestTraffic.guestStartIp=The range of IP addresses that will be available for allocation to guests in this zone. If one NIC is used, these IPs should be in the same CIDR as the pod CIDR. +message.installWizard.tooltip.configureGuestTraffic.name=A h\u00e1l\u00f3zat neve +message.instance.scaled.up.confirm=T\u00e9nyleg nagyobbra akarod m\u00e9retezni a p\u00e9ld\u00e1nyt? +message.instanceWizard.noTemplates=You do not have any templates available; please add a compatible template, and re-launch the instance wizard. +message.ip.address.changed=Your IP addresses may have changed; would you like to refresh the listing? Note that in this case the details pane will close. +message.iso.desc=Disc image containing data or bootable media for OS +message.join.project=You have now joined a project. Please switch to Project view to see the project. +message.launch.vm.on.private.network=Do you wish to launch your instance on your own private dedicated network? +message.launch.zone=A z\u00f3na k\u00e9szen \u00e1ll az ind\u00edt\u00e1sra, folytasd a k\u00f6vetkez\u0151 l\u00e9p\u00e9ssel +message.listView.subselect.multi=(Ctrl/Cmd-kattint\u00e1s) +message.lock.account=Please confirm that you want to lock this account. By locking the account, all users for this account will no longer be able to manage their cloud resources. Existing resources can still be accessed. +message.migrate.instance.confirm=Er\u0151s\u00edtsd meg a kiszolg\u00e1l\u00f3 v\u00e1laszt\u00e1st, ahova a virtu\u00e1lis g\u00e9pet mozgatn\u00e1d\! +message.migrate.instance.to.host=Er\u0151s\u00edtsd meg, hogy m\u00e1sik kiszolg\u00e1l\u00f3ra akarod mozgatni a p\u00e9ld\u00e1nyt\! +message.migrate.instance.to.ps=Please confirm that you want to migrate instance to another primary storage. +message.migrate.router.confirm=Please confirm the host you wish to migrate the router to\: +message.migrate.systemvm.confirm=Please confirm the host you wish to migrate the system VM to\: +message.migrate.volume=Er\u0151s\u00edtsd meg, hogy m\u00e1sik els\u0151dleges t\u00e1rra akarod mozgatni a k\u00f6tetet +message.network.addVM.desc=Please specify the network that you would like to add this VM to. A new NIC will be added for this network. +message.network.addVMNIC=Please confirm that you would like to add a new VM NIC for this network. +message.new.user=A k\u00f6vetkez\u0151ket adja meg \u00faj sz\u00e1mla l\u00e9trehoz\u00e1s\u00e1hoz +message.no.affinity.groups=You do not have any affinity groups. Please continue to the next step. +message.no.host.available=Nincs el\u00e9rhet\u0151 kiszolg\u00e1l\u00f3 az \u00e1tk\u00f6lt\u00f6ztet\u00e9shez +message.no.network.support=A kiv\u00e1lasztott hipervizor, a vSphere nem t\u00e1mogat semmilyen tov\u00e1bbi h\u00e1l\u00f3zat be\u00e1ll\u00edt\u00e1st. Folytasd az 5. l\u00e9p\u00e9ssel\! +message.no.network.support.configuration.not.true=Nincs olyan z\u00f3n\u00e1d, amelyben a biztons\u00e1gi csoportok be lenne kapcsolva, \u00edgy a tov\u00e1bbi h\u00e1l\u00f3zati lehet\u0151s\u00e9gek nem \u00e9rhet\u0151ek el. Folytasd az 5. l\u00e9p\u00e9ssel\! +message.no.projects.adminOnly=Nincsenek projekteid.
K\u00e9rd meg az adminisztr\u00e1tort, hogy hozzon l\u00e9tre neked egyet\! +message.no.projects=Nincsenek projekteid.
A Projektek szekci\u00f3ban tudsz \u00fajat csin\u00e1lni. +message.number.clusters=

\# of Clusters

+message.number.hosts=

\# of Hosts

+message.number.pods=

\# of Pods

+message.number.storage=

\# of Primary Storage Volumes

+message.number.zones=

\# of Zones

+message.pending.projects.1=You have pending project invitations\: +message.pending.projects.2=To view, please go to the projects section, then select invitations from the drop-down. +message.please.add.at.lease.one.traffic.range=Please add at least one traffic range. +message.please.proceed=Please proceed to the next step. +message.please.select.a.configuration.for.your.zone=Please select a configuration for your zone. +message.please.select.a.different.public.and.management.network.before.removing=Please select a different public and management network before removing +message.please.select.networks=Please select networks for your virtual machine. +message.please.wait.while.zone.is.being.created=Please wait while your zone is being created; this may take a while... +message.pod.dedication.released=Pod dedication released +message.portable.ip.delete.confirm=Please confirm you want to delete Portable IP Range +message.project.invite.sent=Invite sent to user; they will be added to the project once they accept the invitation +message.public.traffic.in.advanced.zone=Public traffic is generated when VMs in the cloud access the internet. Publicly-accessible IPs must be allocated for this purpose. End users can use the CloudStack UI to acquire these IPs to implement NAT between their guest network and their public network.

Provide at least one range of IP addresses for internet traffic. +message.public.traffic.in.basic.zone=Public traffic is generated when VMs in the cloud access the Internet or provide services to clients over the Internet. Publicly accessible IPs must be allocated for this purpose. When a instance is created, an IP from this set of Public IPs will be allocated to the instance in addition to the guest IP address. Static 1-1 NAT will be set up automatically between the public IP and the guest IP. End users can also use the CloudStack UI to acquire additional IPs to implement static NAT between their instances and the public IP. +message.read.admin.guide.scaling.up=Please read the dynamic scaling section in the admin guide before scaling up. +message.recover.vm=Er\u0151s\u00edtsd meg, hogy helyre akarod \u00e1ll\u00edtani a VM-et. +message.redirecting.region=Redirecting to region... +message.reinstall.vm=Figyelmeztet\u00e9s\: \u00d3vatosan\! Ha folytatod, a VM \u00fajra lesz telep\u00edtve a sablon alapj\u00e1n, a f\u0151 lemez\u00e9n tal\u00e1lhat\u00f3 adat elveszik. Amennyiben vannak tov\u00e1bbi merevlemezek, azok \u00e9rintetlenek maradnak. +message.remove.ldap=Are you sure you want to delete the LDAP configuration? +message.remove.region=Are you sure you want to remove this region from this management server? +message.remove.vpc=Please confirm that you want to remove the VPC +message.remove.vpn.access=Please confirm that you want to remove VPN access from the following user. +message.reset.password.warning.notPasswordEnabled=A p\u00e9ld\u00e1ny sablonja jelsz\u00f3 bekapcsol\u00e1sa n\u00e9lk\u00fcl lett l\u00e9trehozva +message.reset.password.warning.notStopped=A p\u00e9ld\u00e1nyt le kell \u00e1ll\u00edtanod, miel\u0151tt megpr\u00f3b\u00e1ln\u00e1l jelsz\u00f3t be\u00e1ll\u00edtani. +message.reset.VPN.connection=Please confirm that you want to reset VPN connection +message.restart.mgmt.server=Please restart your management server(s) for your new settings to take effect. +message.restart.mgmt.usage.server=Please restart your management server(s) and usage server(s) for your new settings to take effect. +message.restart.network=All services provided by this network will be interrupted. Please confirm that you want to restart this network. +message.restart.vpc=Please confirm that you want to restart the VPC +message.restoreVM=Helyre akarod \u00e1ll\u00edtani a VM-et? +message.security.group.usage=(A Ctrl-kattint\u00e1s haszn\u00e1lat\u00e1val tudod az \u00f6sszes alkalmazhat\u00f3 biztons\u00e1gi csoportot kiv\u00e1lasztani) +message.select.affinity.groups=Please select any affinity groups you want this VM to belong to\: +message.select.a.zone=A zone typically corresponds to a single datacenter. Multiple zones help make the cloud more reliable by providing physical isolation and redundancy. +message.select.instance=Please select an instance. +message.select.iso=Please select an ISO for your new virtual instance. +message.select.item=Please select an item. +message.select.security.groups=V\u00e1lassz biztons\u00e1gi csoportokat az \u00faj VM-hez\! +message.select.template=Please select a template for your new virtual instance. +message.select.tier=V\u00e1lassz egy r\u00e9teget\! +message.set.default.NIC.manual=Please manually update the default NIC on the VM now. +message.set.default.NIC=Please confirm that you would like to make this NIC the default for this VM. +message.setup.physical.network.during.zone.creation.basic=When adding a basic zone, you can set up one physical network, which corresponds to a NIC on the hypervisor. The network carries several types of traffic.

You may also drag and drop other traffic types onto the physical network. +message.setup.physical.network.during.zone.creation=When adding an advanced zone, you need to set up one or more physical networks. Each network corresponds to a NIC on the hypervisor. Each physical network can carry one or more types of traffic, with certain restrictions on how they may be combined.

Drag and drop one or more traffic types onto each physical network. +message.setup.successful=Cloud setup successful\! +message.snapshot.schedule=You can setup recurring snapshot schedules by selecting from the available options below and applying your policy preference +message.specifiy.tag.key.value=Please specify a tag key and value +message.specify.url=K\u00e9rlek adj meg egy URL-t\! +message.step.1.continue=V\u00e1lassz egy sablont vagy ISO-t a folytat\u00e1shoz +message.step.1.desc=Please select a template for your new virtual instance. You can also choose to select a blank template from which an ISO image can be installed onto. +message.step.2.continue=V\u00e1lassz egy aj\u00e1nlatot a folytat\u00e1shoz\! +message.step.3.continue=V\u00e1lassz egy merevlemez aj\u00e1nlatot a folytat\u00e1shoz\! +message.step.4.continue=V\u00e1lassz legal\u00e1bb egy h\u00e1l\u00f3zatot a folytat\u00e1shoz\! +message.step.4.desc=Please select the primary network that your virtual instance will be connected to. +message.storage.traffic=Traffic between CloudStack\\'s internal resources, including any components that communicate with the Management Server, such as hosts and CloudStack system VMs. Please configure storage traffic here. +message.suspend.project=Biztosan fel akarod f\u00fcggeszteni ezt a projektet? +message.systems.vms.ready=A rendszer VM-ek elk\u00e9sz\u00fcltek. +message.template.copying=A sablon m\u00e1sol\u00e1s alatt \u00e1ll. +message.template.desc=OS image that can be used to boot VMs +message.tier.required=A r\u00e9teg k\u00f6telez\u0151. +message.tooltip.dns.1=Name of a DNS server for use by VMs in the zone. The public IP addresses for the zone must have a route to this server. +message.tooltip.dns.2=A second DNS server name for use by VMs in the zone. The public IP addresses for the zone must have a route to this server. +message.tooltip.internal.dns.1=Name of a DNS server for use by CloudStack internal system VMs in the zone. The private IP address for the pods must have a route to this server. +message.tooltip.internal.dns.2=Name of a DNS server for use by CloudStack internal system VMs in the zone. The private IP address for the pods must have a route to this server. +message.tooltip.network.domain=A DNS suffix that will create a custom domain name for the network that is accessed by guest VMs. +message.tooltip.pod.name=A name for this pod. +message.tooltip.reserved.system.gateway=Az \u00e1tj\u00e1r\u00f3 a pod kiszolg\u00e1l\u00f3i sz\u00e1m\u00e1ra +message.tooltip.reserved.system.netmask=The network prefix that defines the pod subnet. Uses CIDR notation. +message.tooltip.zone.name=N\u00e9v a z\u00f3n\u00e1nak. +message.update.os.preference=Hat\u00e1rozz meg egy OS preferenci\u00e1t a kiszolg\u00e1l\u00f3hoz. Minden p\u00e9ld\u00e1ny, aminek hasonl\u00f3 preferenci\u00e1i vannak el\u0151sz\u00f6r ezen a kiszolg\u00e1l\u00f3n indul el. +message.update.resource.count=Please confirm that you want to update resource counts for this account. +message.update.ssl.failed=Failed to update SSL Certificate. +message.update.ssl=Please submit a new X.509 compliant SSL certificate chain to be updated to each console proxy and secondary storage virtual instance\: +message.update.ssl.succeeded=Update SSL Certificates succeeded +message.validate.accept=Please enter a value with a valid extension. +message.validate.creditcard=Adj meg egy \u00e9rv\u00e9nyes bankk\u00e1rtyasz\u00e1mot\! +message.validate.date=Adj meg egy \u00e9rv\u00e9nyes d\u00e1tumot\! +message.validate.date.ISO=Adj meg egy \u00e9rv\u00e9nyes (ISO) d\u00e1tumot\! +message.validate.digits=Csak sz\u00e1mjegyeket \u00edrj\! +message.validate.email.address=Adj meg egy \u00e9rv\u00e9nyes e-mail c\u00edmet\! +message.validate.equalto=\u00cdrd be ugyanazt az \u00e9rt\u00e9ket \u00fajra\! +message.validate.fieldrequired=Ez a mez\u0151 k\u00f6telez\u0151. +message.validate.fixfield=Jav\u00edtsd ki ez a mez\u0151t\! +message.validate.instance.name=Instance name can not be longer than 63 characters. Only ASCII letters a~z, A~Z, digits 0~9, hyphen are allowed. Must start with a letter and end with a letter or a digit. +message.validate.invalid.characters=\u00c9rv\u00e9nytelen karakter; k\u00e9rlek jav\u00edtsd\! +message.validate.max=Adj meg egy \u00e9rt\u00e9ket, ami legfeljebb {0}\! +message.validate.maxlength=Legfeljebb {0} karaktert adj meg\! +message.validate.minlength=Legal\u00e1bb {0} karaktert adj meg\! +message.validate.number=Adj meg egy \u00e9rv\u00e9nyes sz\u00e1mot\! +message.validate.range=Adj meg egy \u00e9rt\u00e9ket {0} \u00e9s {1} k\u00f6z\u00f6tt\! +message.validate.range.length=Adj meg egy {0} \u00e9s {1} k\u00f6z\u00f6tti hossz\u00fas\u00e1g\u00fa \u00e9rt\u00e9ket\! +message.validate.URL=Adj meg egy \u00e9rv\u00e9nyes URL-t\! +message.virtual.network.desc=A dedicated virtualized network for your account. The broadcast domain is contained within a VLAN and all public network access is routed out by a virtual router. +message.vm.create.template.confirm=Create Template will reboot the VM automatically. +message.vm.review.launch=Please review the following information and confirm that your virtual instance is correct before launch. +message.vnmc.available.list=VNMC is not available from provider list. +message.vnmc.not.available.list=VNMC is not available from provider list. +message.volume.create.template.confirm=Please confirm that you wish to create a template for this disk volume. Creation of the template can range from several minutes to longer depending on the size of the volume. +message.waiting.for.builtin.templates.to.load=V\u00e1rakoz\u00e1s a be\u00e9p\u00edtett sablonk bet\u00f6lt\u00e9s\u00e9re... +message.XSTools61plus.update.failed=Failed to update Original XS Version is 6.1\\+ field. Error\: +message.you.must.have.at.least.one.physical.network=You must have at least one physical network +message.your.cloudstack.is.ready=A CloudStack k\u00e9szen \u00e1ll\! +message.Zone.creation.complete=A z\u00f3na l\u00e9trehoz\u00e1sa befejez\u0151d\u00f6tt +message.zone.creation.complete.would.you.like.to.enable.this.zone=Zone creation complete. Would you like to enable this zone? +message.zone.no.network.selection=The zone you selected does not have any choices for network selection. +message.zone.step.1.desc=Please select a network model for your zone. +message.zone.step.2.desc=Please enter the following info to add a new zone +message.zone.step.3.desc=Please enter the following info to add a new pod +message.zoneWizard.enable.local.storage=WARNING\: If you enable local storage for this zone, you must do the following, depending on where you would like your system VMs to launch\:

1. If system VMs need to be launched in shared primary storage, shared primary storage needs to be added to the zone after creation. You must also start the zone in a disabled state.

2. If system VMs need to be launched in local primary storage, system.vm.use.local.storage needs to be set to true before you enable the zone.


Would you like to continue? +messgae.validate.min=Adj meg egy \u00e9rt\u00e9ket, ami legal\u00e1bb {0}\! +mode=M\u00f3d +network.rate=H\u00e1l\u00f3zati r\u00e1ta +notification.reboot.instance=P\u00e9ld\u00e1ny \u00fajraind\u00edt\u00e1sa +notification.start.instance=P\u00e9ld\u00e1ny ind\u00edt\u00e1sa +notification.stop.instance=P\u00e9ld\u00e1ny le\u00e1ll\u00edt\u00e1sa +side.by.side=Egym\u00e1s mellett +state.Accepted=Elfogadva +state.Active=Akt\u00edv +state.Allocated=Lek\u00f6t\u00f6ve +state.Allocating=Lek\u00f6t\u00e9s folyamatban +state.BackedUp=Lementve +state.BackingUp=Ment\u00e9s folyamatban +state.Completed=K\u00e9sz +state.Creating=K\u00e9sz\u00fcl +state.Declined=Elromlott +state.Destroyed=T\u00f6r\u00f6lt +state.detached=Lecsatolt +state.Disabled=Kikapcsolt +state.Enabled=Enged\u00e9lyezett +state.Error=Hiba +state.Expunging=T\u00f6rl\u00e9s alatt +state.Migrating=\u00c1thelyez\u00e9s alatt +state.Pending=F\u00fcgg +state.Ready=K\u00e9szen \u00e1ll +state.Running=Fut +state.Starting=Indul +state.Stopped=Le\u00e1ll\u00edtva +state.Stopping=Le\u00e1ll\u00e1s folyamatban +state.Suspended=Felf\u00fcggesztett +ui.listView.filters.all=Mind +ui.listView.filters.mine=Saj\u00e1t diff --git a/client/WEB-INF/classes/resources/messages_it_IT.properties b/client/WEB-INF/classes/resources/messages_it_IT.properties index 3399036829bc..a295226b599e 100644 --- a/client/WEB-INF/classes/resources/messages_it_IT.properties +++ b/client/WEB-INF/classes/resources/messages_it_IT.properties @@ -185,7 +185,6 @@ label.action.reboot.router=Riavvio Router label.action.reboot.systemvm.processing=Riavvio VM di Sistema in corso.... label.action.reboot.systemvm=Riavvio VM di Sistema label.action.register.iso=Registrare una ISO -label.action.register.template=Registrare un template label.action.release.ip.processing=Rilascio indirizzo IP in corso.... label.action.release.ip=Rilascio indirizzo IP label.action.remove.host.processing=Rimozione Host in corso.... diff --git a/client/WEB-INF/classes/resources/messages_ja_JP.properties b/client/WEB-INF/classes/resources/messages_ja_JP.properties index a0ecb34685a3..c952cc33e557 100644 --- a/client/WEB-INF/classes/resources/messages_ja_JP.properties +++ b/client/WEB-INF/classes/resources/messages_ja_JP.properties @@ -37,6 +37,10 @@ force.remove.host.warning=\u8b66\u544a\: \u3053\u306e\u30aa\u30d7\u30b7\u30e7\u3 force.remove=\u5f37\u5236\u7684\u306b\u89e3\u9664\u3059\u308b force.stop.instance.warning=\u8b66\u544a\: \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u5f37\u5236\u505c\u6b62\u306f\u3001\u6700\u7d42\u624b\u6bb5\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u30c7\u30fc\u30bf\u3092\u640d\u5931\u3059\u308b\u3060\u3051\u3067\u306a\u304f\u3001\u4eee\u60f3\u30de\u30b7\u30f3\u306e\u52d5\u4f5c\u304c\u4e00\u8cab\u3057\u306a\u304f\u306a\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002 force.stop=\u5f37\u5236\u7684\u306b\u505c\u6b62\u3059\u308b +hint.no.host.tags=\u30db\u30b9\u30c8\u30bf\u30b0\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093 +hint.no.storage.tags=\u30b9\u30c8\u30ec\u30fc\u30b8\u30bf\u30b0\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093 +hint.type.part.host.tag=\u30db\u30b9\u30c8\u30bf\u30b0\u306e\u7a2e\u985e +hint.type.part.storage.tag=\u30b9\u30c8\u30ec\u30fc\u30b8\u30bf\u30b0\u306e\u7a2e\u985e ICMP.code=ICMP \u30b3\u30fc\u30c9 ICMP.type=ICMP \u306e\u7a2e\u985e image.directory=\u753b\u50cf\u30c7\u30a3\u30ec\u30af\u30c8\u30ea @@ -68,6 +72,8 @@ label.action.change.password=\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u5909\u66f4 label.action.change.service.processing=\u30b5\u30fc\u30d3\u30b9\u3092\u5909\u66f4\u3057\u3066\u3044\u307e\u3059... label.action.change.service=\u30b5\u30fc\u30d3\u30b9\u306e\u5909\u66f4 label.action.copy.ISO=ISO \u306e\u30b3\u30d4\u30fc +label.action.copy.ISO.processing=ISO \u3092\u30b3\u30d4\u30fc\u3057\u3066\u3044\u307e\u3059.... +label.action.copy.template.processing=\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u30b3\u30d4\u30fc\u3057\u3066\u3044\u307e\u3059.... label.action.copy.template=\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u30b3\u30d4\u30fc label.action.create.template.from.vm=VM \u304b\u3089\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u4f5c\u6210 label.action.create.template.from.volume=\u30dc\u30ea\u30e5\u30fc\u30e0\u304b\u3089\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u4f5c\u6210 @@ -205,7 +211,6 @@ label.action.reboot.systemvm.processing=\u30b7\u30b9\u30c6\u30e0 VM \u3092\u518d label.action.reboot.systemvm=\u30b7\u30b9\u30c6\u30e0 VM \u306e\u518d\u8d77\u52d5 label.action.recurring.snapshot=\u5b9a\u671f\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8 label.action.register.iso=ISO \u306e\u767b\u9332 -label.action.register.template=\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u767b\u9332 label.action.release.ip=IP \u30a2\u30c9\u30ec\u30b9\u306e\u89e3\u653e label.action.release.ip.processing=IP \u30a2\u30c9\u30ec\u30b9\u3092\u89e3\u653e\u3057\u3066\u3044\u307e\u3059... label.action.remove.host.processing=\u30db\u30b9\u30c8\u3092\u524a\u9664\u3057\u3066\u3044\u307e\u3059... @@ -254,6 +259,7 @@ label.add.ACL=ACL \u306e\u8ffd\u52a0 label.add.acl.list=ACL \u4e00\u89a7\u306e\u8ffd\u52a0 label.add.affinity.group=\u65b0\u3057\u3044\u30a2\u30d5\u30a3\u30cb\u30c6\u30a3 \u30b0\u30eb\u30fc\u30d7\u306e\u8ffd\u52a0 label.add.baremetal.dhcp.device=\u30d9\u30a2\u30e1\u30bf\u30eb DHCP \u30c7\u30d0\u30a4\u30b9\u306e\u8ffd\u52a0 +label.add.baremetal.rack.configuration=\u30d9\u30a2\u30e1\u30bf\u30eb\u30e9\u30c3\u30af\u8a2d\u5b9a\u306e\u8ffd\u52a0 label.add.BigSwitchBcf.device=BigSwitch BCF \u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u306e\u8ffd\u52a0 label.add.BrocadeVcs.device=Brocade VCS \u30b9\u30a4\u30c3\u30c1\u306e\u8ffd\u52a0 label.add.by.cidr=CIDR \u3067\u8ffd\u52a0 @@ -273,6 +279,7 @@ label.add.egress.rule=\u9001\u4fe1\u898f\u5247\u306e\u8ffd\u52a0 label.addes.new.f5=\u65b0\u3057\u3044 F5 \u3092\u8ffd\u52a0\u3057\u307e\u3057\u305f label.add.F5.device=F5 \u30c7\u30d0\u30a4\u30b9\u306e\u8ffd\u52a0 label.add.firewall=\u30d5\u30a1\u30a4\u30a2\u30a6\u30a9\u30fc\u30eb\u898f\u5247\u306e\u8ffd\u52a0 +label.add.globo.dns=GloboDNS \u306e\u8ffd\u52a0 label.add.gslb=GSLB \u306e\u8ffd\u52a0 label.add.guest.network=\u30b2\u30b9\u30c8 \u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306e\u8ffd\u52a0 label.add.host=\u30db\u30b9\u30c8\u306e\u8ffd\u52a0 @@ -317,6 +324,7 @@ label.add.pod=\u30dd\u30c3\u30c9\u306e\u8ffd\u52a0 label.add.portable.ip.range=\u30dd\u30fc\u30bf\u30d6\u30eb IP \u30a2\u30c9\u30ec\u30b9\u306e\u7bc4\u56f2\u306e\u8ffd\u52a0 label.add.port.forwarding.rule=\u30dd\u30fc\u30c8\u8ee2\u9001\u898f\u5247\u306e\u8ffd\u52a0 label.add.primary.storage=\u30d7\u30e9\u30a4\u30de\u30ea \u30b9\u30c8\u30ec\u30fc\u30b8\u306e\u8ffd\u52a0 +label.add.private.gateway=\u30d7\u30e9\u30a4\u30d9\u30fc\u30c8\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u306e\u8ffd\u52a0 label.add.region=\u30ea\u30fc\u30b8\u30e7\u30f3\u306e\u8ffd\u52a0 label.add.resources=\u30ea\u30bd\u30fc\u30b9\u306e\u8ffd\u52a0 label.add.route=\u30eb\u30fc\u30c8\u306e\u8ffd\u52a0 @@ -385,6 +393,7 @@ label.assigned.vms=\u5272\u308a\u5f53\u3066\u6e08\u307f VM label.assign.instance.another=\u307b\u304b\u306e\u30a2\u30ab\u30a6\u30f3\u30c8\u3078\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u5272\u308a\u5f53\u3066 label.assign.to.load.balancer=\u30ed\u30fc\u30c9 \u30d0\u30e9\u30f3\u30b5\u30fc\u306b\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u5272\u308a\u5f53\u3066\u3066\u3044\u307e\u3059 label.assign=\u5272\u308a\u5f53\u3066 +label.assign.vms=\u4eee\u60f3\u30de\u30b7\u30f3\u306e\u5272\u308a\u5f53\u3066 label.associated.network.id=\u95a2\u9023\u4ed8\u3051\u3089\u308c\u305f\u30cd\u30c3\u30c8\u30ef\u30fc\u30af ID label.associated.network=\u95a2\u9023\u4ed8\u3051\u3089\u308c\u305f\u30cd\u30c3\u30c8\u30ef\u30fc\u30af label.associated.profile=\u95a2\u9023\u4ed8\u3051\u3089\u308c\u305f\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb @@ -395,6 +404,7 @@ label.author.name=\u4f5c\u6210\u8005\u306e\u540d\u524d label.autoscale=\u81ea\u52d5\u30b5\u30a4\u30ba\u8a2d\u5b9a label.availability=\u53ef\u7528\u6027 label.availability.zone=\u30a2\u30d9\u30a4\u30e9\u30d3\u30ea\u30c6\u30a3 \u30be\u30fc\u30f3 +label.availabilityZone=\u30a2\u30d9\u30a4\u30e9\u30d3\u30ea\u30c6\u30a3\u30be\u30fc\u30f3 label.available.public.ips=\u4f7f\u7528\u3067\u304d\u308b\u30d1\u30d6\u30ea\u30c3\u30af IP \u30a2\u30c9\u30ec\u30b9 label.available=\u4f7f\u7528\u53ef\u80fd label.back=\u623b\u308b @@ -404,6 +414,7 @@ label.baremetal.dhcp.provider=\u30d9\u30a2\u30e1\u30bf\u30eb DHCP \u30d7\u30ed\u label.baremetal.pxe.devices=\u30d9\u30a2\u30e1\u30bf\u30eb PXE \u30c7\u30d0\u30a4\u30b9 label.baremetal.pxe.device=\u30d9\u30a2\u30e1\u30bf\u30eb PXE \u30c7\u30d0\u30a4\u30b9\u306e\u8ffd\u52a0 label.baremetal.pxe.provider=\u30d9\u30a2\u30e1\u30bf\u30eb PXE \u30d7\u30ed\u30d0\u30a4\u30c0\u30fc +label.baremetal.rack.configuration=\u30d9\u30a2\u30e1\u30bf\u30eb\u30e9\u30c3\u30af\u8a2d\u5b9a label.basic.mode=\u57fa\u672c\u30e2\u30fc\u30c9 label.basic=\u57fa\u672c label.bigswitch.bcf.details=BigSwitch BCF \u306e\u8a73\u7d30 @@ -449,6 +460,7 @@ label.change.service.offering=\u30b5\u30fc\u30d3\u30b9 \u30aa\u30d5\u30a1\u30ea\ label.change.value=\u5024\u306e\u5909\u66f4 label.character=\u6587\u5b57 label.chassis=\u30b7\u30e3\u30fc\u30b7 +label.checksum=\u30c1\u30a7\u30c3\u30af\u30b5\u30e0 label.cidr.account=CIDR \u307e\u305f\u306f\u30a2\u30ab\u30a6\u30f3\u30c8/\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3 \u30b0\u30eb\u30fc\u30d7 label.cidr=CIDR label.CIDR.list=CIDR \u4e00\u89a7 @@ -513,6 +525,7 @@ label.data.disk.offering=\u30c7\u30fc\u30bf \u30c7\u30a3\u30b9\u30af \u30aa\u30d label.date=\u65e5\u6642 label.day.of.month=\u6bce\u6708\u6307\u5b9a\u65e5 label.day.of.week=\u6bce\u9031\u6307\u5b9a\u65e5 +label.day=\u65e5 label.dc.name=DC \u540d label.dead.peer.detection=\u505c\u6b62\u30d4\u30a2\u3092\u691c\u51fa\u3059\u308b label.decline.invitation=\u62db\u5f85\u306e\u8f9e\u9000 @@ -531,6 +544,7 @@ label.default.view=\u30c7\u30d5\u30a9\u30eb\u30c8 \u30d3\u30e5\u30fc label.delete.acl.list=ACL \u4e00\u89a7\u306e\u524a\u9664 label.delete.affinity.group=\u30a2\u30d5\u30a3\u30cb\u30c6\u30a3 \u30b0\u30eb\u30fc\u30d7\u306e\u524a\u9664 label.delete.alerts=\u30a2\u30e9\u30fc\u30c8\u306e\u524a\u9664 +label.delete.baremetal.rack.configuration=\u30d9\u30a2\u30e1\u30bf\u30eb\u30e9\u30c3\u30af\u8a2d\u5b9a\u306e\u524a\u9664 label.delete.BigSwitchBcf=BigSwitch BCF \u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u306e\u524a\u9664 label.delete.BrocadeVcs=Brocade VCS \u30b9\u30a4\u30c3\u30c1\u306e\u524a\u9664 label.delete.ciscoASA1000v=Cisco ASA 1000V \u30ea\u30bd\u30fc\u30b9\u306e\u524a\u9664 @@ -593,6 +607,7 @@ label.disk.iops.read.rate=\u30c7\u30a3\u30b9\u30af\u8aad\u307f\u53d6\u308a\u901f label.disk.iops.total=IOPS \u5408\u8a08 label.disk.iops.write.rate=\u30c7\u30a3\u30b9\u30af\u66f8\u304d\u8fbc\u307f\u901f\u5ea6 (IOPS) label.disk.offering=\u30c7\u30a3\u30b9\u30af \u30aa\u30d5\u30a1\u30ea\u30f3\u30b0 +label.diskoffering=\u30c7\u30a3\u30b9\u30af\u30aa\u30d5\u30a1\u30ea\u30f3\u30b0 label.disk.provisioningtype=\u30d7\u30ed\u30d3\u30b8\u30e7\u30cb\u30f3\u30b0\u306e\u7a2e\u985e label.disk.read.bytes=\u30c7\u30a3\u30b9\u30af\u8aad\u307f\u53d6\u308a (\u30d0\u30a4\u30c8) label.disk.read.io=\u30c7\u30a3\u30b9\u30af\u8aad\u307f\u53d6\u308a (IO) @@ -602,6 +617,7 @@ label.disk.total=\u30c7\u30a3\u30b9\u30af\u5408\u8a08 label.disk.volume=\u30c7\u30a3\u30b9\u30af \u30dc\u30ea\u30e5\u30fc\u30e0 label.disk.write.bytes=\u30c7\u30a3\u30b9\u30af\u66f8\u304d\u8fbc\u307f (\u30d0\u30a4\u30c8) label.disk.write.io=\u30c7\u30a3\u30b9\u30af\u66f8\u304d\u8fbc\u307f (IO) +label.display.name=\u8868\u793a\u540d label.display.text=\u8868\u793a\u30c6\u30ad\u30b9\u30c8 label.distributedrouter=\u5206\u6563\u30eb\u30fc\u30bf\u30fc label.dns.1=DNS 1 @@ -657,6 +673,8 @@ label.endpoint.or.operation=\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u307e\u30 label.endpoint=\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8 label.end.port=\u7d42\u4e86\u30dd\u30fc\u30c8 label.end.reserved.system.IP=\u4e88\u7d04\u6e08\u307f\u7d42\u4e86\u30b7\u30b9\u30c6\u30e0 IP \u30a2\u30c9\u30ec\u30b9 +label.end.vlan=\u7d42\u4e86 VLAN +label.end.vxlan=\u7d42\u4e86 VXLAN label.enter.token=\u30c8\u30fc\u30af\u30f3\u306e\u5165\u529b label.error.code=\u30a8\u30e9\u30fc \u30b3\u30fc\u30c9 label.error=\u30a8\u30e9\u30fc @@ -668,9 +686,12 @@ label.ESP.policy=ESP \u30dd\u30ea\u30b7\u30fc label.esx.host=ESX/ESXi \u30db\u30b9\u30c8 label.event.archived=\u30a4\u30d9\u30f3\u30c8\u304c\u30a2\u30fc\u30ab\u30a4\u30d6\u3055\u308c\u307e\u3057\u305f label.event.deleted=\u30a4\u30d9\u30f3\u30c8\u304c\u524a\u9664\u3055\u308c\u307e\u3057\u305f +label.event=\u30a4\u30d9\u30f3\u30c8 +label.every=\u6bce label.example=\u4f8b label.expunge=\u62b9\u6d88 label.external.link=\u5916\u90e8\u30ea\u30f3\u30af +label.extractable.lower=\u5c55\u958b label.extractable=\u62bd\u51fa\u53ef\u80fd label.f5.details=F5 \u306e\u8a73\u7d30 label.f5=F5 @@ -681,6 +702,7 @@ label.filterBy=\u30d5\u30a3\u30eb\u30bf\u30fc label.firewall=\u30d5\u30a1\u30a4\u30a2\u30a6\u30a9\u30fc\u30eb label.firstname.lower=\u540d label.first.name=\u540d +label.format.lower=\u30d5\u30a9\u30fc\u30de\u30c3\u30c8 label.format=\u5f62\u5f0f label.friday=\u91d1\u66dc\u65e5 label.full.path=\u30d5\u30eb \u30d1\u30b9 @@ -688,6 +710,8 @@ label.full=\u5b8c\u5168 label.gateway=\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4 label.general.alerts=\u4e00\u822c\u30a2\u30e9\u30fc\u30c8 label.generating.url=URL \u3092\u751f\u6210\u3057\u3066\u3044\u307e\u3059 +label.globo.dns.configuration=GloboDNS \u306e\u8a2d\u5b9a +label.globo.dns=GloboDNS label.gluster.volume=\u30dc\u30ea\u30e5\u30fc\u30e0 label.go.step.2=\u624b\u9806 2 \u306b\u9032\u3080 label.go.step.3=\u624b\u9806 3 \u306b\u9032\u3080 @@ -834,7 +858,10 @@ label.is.redundant.router=\u5197\u9577 label.is.shared=\u5171\u6709 label.is.system=\u30b7\u30b9\u30c6\u30e0 label.item.listing=\u9805\u76ee\u4e00\u89a7 -label.keep=\u7dad\u6301 +label.japanese.keyboard=\u65e5\u672c\u8a9e\u30ad\u30fc\u30dc\u30fc\u30c9 +label.keep.colon=\u4fdd\u6301\: +label.keep=\u4fdd\u6301 +label.keyboard.language=\u30ad\u30fc\u30dc\u30fc\u30c9\u306e\u8a00\u8a9e label.keyboard.type=\u30ad\u30fc\u30dc\u30fc\u30c9\u306e\u7a2e\u985e label.key=\u30ad\u30fc label.kvm.traffic.label=KVM \u306e\u30c8\u30e9\u30d5\u30a3\u30c3\u30af \u30e9\u30d9\u30eb @@ -967,6 +994,9 @@ label.migrate.volume.to.primary.storage=\u5225\u306e\u30d7\u30e9\u30a4\u30de\u30 label.migrate.volume=\u30dc\u30ea\u30e5\u30fc\u30e0\u306e\u79fb\u884c label.minimum=\u6700\u5c0f label.min.instances=\u6700\u5c0f\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u6570 +label.min.past.the.hr=\u5206(\u6bce\u6642) +label.minute.past.hour=\u5206(\u6bce\u6642) +label.minutes.past.hour=\u5206(\u6bce\u6642) label.mode=\u30e2\u30fc\u30c9 label.monday=\u6708\u66dc\u65e5 label.monthly=\u6bce\u6708 @@ -1052,6 +1082,7 @@ label.num.cpu.cores=CPU \u30b3\u30a2\u6570 label.numretries=\u518d\u8a66\u884c\u56de\u6570 label.ocfs2=OCFS2 label.offer.ha=\u9ad8\u53ef\u7528\u6027\u3092\u63d0\u4f9b\u3059\u308b +label.of.month=\u6708\u6bce label.ok=OK label.opendaylight.controllerdetail=OpenDaylight \u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306e\u8a73\u7d30 label.opendaylight.controller=OpenDaylight \u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc @@ -1172,6 +1203,7 @@ label.redundant.state=\u5197\u9577\u72b6\u614b label.redundant.vpc=\u5197\u9577 VPC label.refresh.blades=\u30d6\u30ec\u30fc\u30c9\u306e\u66f4\u65b0 label.refresh=\u66f4\u65b0 +label.region.details=\u30ea\u30fc\u30b8\u30e7\u30f3\u306e\u8a73\u7d30 label.regionlevelvpc=\u30ea\u30fc\u30b8\u30e7\u30f3\u30ec\u30d9\u30eb\u306e VPC label.region=\u30ea\u30fc\u30b8\u30e7\u30f3 label.reinstall.vm=VM \u306e\u518d\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb @@ -1308,6 +1340,7 @@ label.shared=\u5171\u6709 label.show.advanced.settings=\u8a73\u7d30\u8a2d\u5b9a\u306e\u8868\u793a label.show.ingress.rule=\u53d7\u4fe1\u898f\u5247\u306e\u8868\u793a label.shutdown.provider=\u30d7\u30ed\u30d0\u30a4\u30c0\u30fc\u306e\u30b7\u30e3\u30c3\u30c8\u30c0\u30a6\u30f3 +label.simplified.chinese.keyboard=\u7c21\u6613\u4e2d\u56fd\u8a9e\u30ad\u30fc\u30dc\u30fc\u30c9 label.site.to.site.VPN=\u30b5\u30a4\u30c8\u9593 VPN label.size=\u30b5\u30a4\u30ba label.skip.guide=CloudStack \u3092\u4f7f\u7528\u3057\u305f\u3053\u3068\u304c\u3042\u308b\u306e\u3067\u3001\u3053\u306e\u30ac\u30a4\u30c9\u3092\u30b9\u30ad\u30c3\u30d7\u3059\u308b @@ -1333,10 +1366,13 @@ label.specify.vxlan=VXLAN \u3092\u6307\u5b9a\u3059\u308b label.SR.name=SR \u540d\u30e9\u30d9\u30eb label.srx.details=SRX \u306e\u8a73\u7d30 label.srx=SRX +label.standard.us.keyboard=\u6a19\u6e96(US) \u30ad\u30fc\u30dc\u30fc\u30c9 label.start.IP=\u958b\u59cb IP \u30a2\u30c9\u30ec\u30b9 label.start.lb.vm=LB VM \u306e\u8d77\u52d5 label.start.port=\u958b\u59cb\u30dd\u30fc\u30c8 label.start.reserved.system.IP=\u4e88\u7d04\u6e08\u307f\u958b\u59cb\u30b7\u30b9\u30c6\u30e0 IP \u30a2\u30c9\u30ec\u30b9 +label.start.vlan=\u958b\u59cb VLAN +label.start.vxlan=\u958b\u59cb VXLAN label.state=\u72b6\u614b label.static.nat.enabled=\u9759\u7684 NAT \u6709\u52b9 label.static.nat.to=\u9759\u7684 NAT \u306e\u8a2d\u5b9a\u5148\: @@ -1415,9 +1451,11 @@ label.threshold=\u3057\u304d\u3044\u5024 label.thursday=\u6728\u66dc\u65e5 label.tier.details=\u968e\u5c64\u306e\u8a73\u7d30 label.tier=\u968e\u5c64 +label.time.colon=\u6642\u9593\: label.timeout.in.second = \u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u5024(\u79d2) label.timeout=\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8 -label.time=\u6642\u523b +label.time=\u6642\u9593 +label.timezone.colon=\u30bf\u30a4\u30e0\u30be\u30fc\u30f3\: label.time.zone=\u30bf\u30a4\u30e0\u30be\u30fc\u30f3 label.timezone=\u30bf\u30a4\u30e0\u30be\u30fc\u30f3 label.token=\u30c8\u30fc\u30af\u30f3 @@ -1439,6 +1477,7 @@ label.type.id=\u7a2e\u985e ID label.type.lower=\u7a2e\u985e label.type=\u7a2e\u985e label.ucs=UCS +label.uk.keyboard=UK \u30ad\u30fc\u30dc\u30fc\u30c9 label.unavailable=\u4f7f\u7528\u4e0d\u80fd label.unhealthy.threshold=\u7570\u5e38\u3057\u304d\u3044\u5024 label.unlimited=\u7121\u5236\u9650 @@ -1584,6 +1623,7 @@ label.zone.dedicated=\u5c02\u7528\u30be\u30fc\u30f3 label.zone.details=\u30be\u30fc\u30f3\u306e\u8a73\u7d30 label.zone.id=\u30be\u30fc\u30f3 ID label.zone.lower=\u30be\u30fc\u30f3 +label.zone.name=\u30be\u30fc\u30f3\u540d label.zone.step.1.title=\u624b\u9806 1\: \u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306e\u9078\u629e label.zone.step.2.title=\u624b\u9806 2\: \u30be\u30fc\u30f3\u306e\u8ffd\u52a0 label.zone.step.3.title=\u624b\u9806 3\: \u30dd\u30c3\u30c9\u306e\u8ffd\u52a0 @@ -1675,6 +1715,8 @@ message.add.cluster=\u30be\u30fc\u30f3 \u30 message.add.cluster.zone=\u30be\u30fc\u30f3 \u306b\u30cf\u30a4\u30d1\u30fc\u30d0\u30a4\u30b6\u30fc\u3067\u7ba1\u7406\u3055\u308c\u308b\u30af\u30e9\u30b9\u30bf\u30fc\u3092\u8ffd\u52a0\u3057\u307e\u3059 message.add.disk.offering=\u65b0\u3057\u3044\u30c7\u30a3\u30b9\u30af \u30aa\u30d5\u30a1\u30ea\u30f3\u30b0\u3092\u8ffd\u52a0\u3059\u308b\u305f\u3081\u306b\u3001\u6b21\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u3092\u6307\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002 message.add.domain=\u3053\u306e\u30c9\u30e1\u30a4\u30f3\u306b\u4f5c\u6210\u3059\u308b\u30b5\u30d6\u30c9\u30e1\u30a4\u30f3\u3092\u6307\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002 +message.added.new.nuage.vsp.controller=\u65b0\u3057\u3044 Nuage VSP \u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u8ffd\u52a0\u3057\u307e\u3057\u305f +message.added.vpc.offering=VPC \u30aa\u30d5\u30a1\u30ea\u30f3\u30b0\u3092\u8ffd\u52a0\u3057\u307e\u3057\u305f message.add.firewall=\u30be\u30fc\u30f3\u306b\u30d5\u30a1\u30a4\u30a2\u30a6\u30a9\u30fc\u30eb\u3092\u8ffd\u52a0\u3057\u307e\u3059 message.add.guest.network=\u30b2\u30b9\u30c8 \u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3092\u8ffd\u52a0\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? message.add.host=\u65b0\u3057\u3044\u30db\u30b9\u30c8\u3092\u8ffd\u52a0\u3059\u308b\u305f\u3081\u306b\u3001\u6b21\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u3092\u6307\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002 @@ -1737,6 +1779,8 @@ message.confirm.dedicate.pod.domain.account=\u3053\u306e\u30dd\u30c3\u30c9\u3092 message.confirm.dedicate.zone=\u3053\u306e\u30be\u30fc\u30f3\u3092\u30c9\u30e1\u30a4\u30f3/\u30a2\u30ab\u30a6\u30f3\u30c8\u5c02\u7528\u306b\u8a2d\u5b9a\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? message.confirm.delete.acl.list=\u3053\u306e ACL \u4e00\u89a7\u3092\u524a\u9664\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? message.confirm.delete.alert=\u3053\u306e\u30a2\u30e9\u30fc\u30c8\u3092\u524a\u9664\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.confirm.delete.baremetal.rack.configuration=\u30d9\u30a2\u30e1\u30bf\u30eb\u30e9\u30c3\u30af\u8a2d\u5b9a\u3092\u524a\u9664\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.confirm.delete.BigSwitchBcf=\u3053\u306e BigSwitch BCF \u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u524a\u9664\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? message.confirm.delete.BrocadeVcs=Brocade VCS \u30b9\u30a4\u30c3\u30c1\u3092\u524a\u9664\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? message.confirm.delete.ciscoASA1000v=Cisco ASA 1000V \u3092\u524a\u9664\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? message.confirm.delete.ciscovnmc.resource=Cisco VNMC \u30ea\u30bd\u30fc\u30b9\u3092\u524a\u9664\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? @@ -1830,6 +1874,7 @@ message.disabling.vpc.offering=VPC \u30aa\u30d5\u30a1\u30ea\u30f3\u30b0\u3092\u7 message.disallowed.characters=\u8a31\u53ef\u3055\u308c\u306a\u3044\u6587\u5b57\: <,> message.download.ISO=ISO \u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u306b\u306f 00000 \u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059 message.download.template=\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u306b\u306f 00000 \u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059 +message.download.volume.confirm=\u3053\u306e\u30dc\u30ea\u30e5\u30fc\u30e0\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? message.download.volume=\u30dc\u30ea\u30e5\u30fc\u30e0\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u306b\u306f 00000 \u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059 message.edit.account=\u7de8\u96c6 (\u300c-1\u300d\u306f\u3001\u30ea\u30bd\u30fc\u30b9\u4f5c\u6210\u306e\u91cf\u306b\u5236\u9650\u304c\u306a\u3044\u3053\u3068\u3092\u793a\u3057\u307e\u3059) message.edit.confirm=[\u4fdd\u5b58] \u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u524d\u306b\u5909\u66f4\u5185\u5bb9\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002 @@ -1945,6 +1990,7 @@ message.reset.VPN.connection=VPN \u63a5\u7d9a\u3092\u30ea\u30bb\u30c3\u30c8\u305 message.restart.mgmt.server=\u65b0\u3057\u3044\u8a2d\u5b9a\u3092\u6709\u52b9\u306b\u3059\u308b\u305f\u3081\u306b\u3001\u7ba1\u7406\u30b5\u30fc\u30d0\u30fc\u3092\u518d\u8d77\u52d5\u3057\u3066\u304f\u3060\u3055\u3044\u3002 message.restart.mgmt.usage.server=\u65b0\u3057\u3044\u8a2d\u5b9a\u3092\u6709\u52b9\u306b\u3059\u308b\u305f\u3081\u306b\u3001\u7ba1\u7406\u30b5\u30fc\u30d0\u30fc\u3068\u4f7f\u7528\u72b6\u6cc1\u6e2c\u5b9a\u30b5\u30fc\u30d0\u30fc\u3092\u518d\u8d77\u52d5\u3057\u3066\u304f\u3060\u3055\u3044\u3002 message.restart.network=\u3053\u306e\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3067\u63d0\u4f9b\u3059\u308b\u3059\u3079\u3066\u306e\u30b5\u30fc\u30d3\u30b9\u304c\u4e2d\u65ad\u3055\u308c\u307e\u3059\u3002\u3053\u306e\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3092\u518d\u8d77\u52d5\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.restart.vpc.remark=VPC \u3092\u518d\u8d77\u52d5\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?

\u6ce8\u610f\: \u975e\u5197\u9577 VPC \u306e\u5197\u9577\u5316\u306f\u5f37\u5236\u7684\u306b\u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7\u3055\u308c\u307e\u3059. \u307e\u305f\u3001\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306f\u6570\u5206\u9593\u5229\u7528\u51fa\u6765\u306a\u304f\u306a\u308a\u307e\u3059.

message.restart.vpc=VPC \u3092\u518d\u8d77\u52d5\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? message.restoreVM=VM \u3092\u5fa9\u5143\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? message.security.group.usage=(\u8a72\u5f53\u3059\u308b\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3 \u30b0\u30eb\u30fc\u30d7\u3092\u3059\u3079\u3066\u9078\u629e\u3059\u308b\u306b\u306f\u3001Ctrl \u30ad\u30fc\u3092\u62bc\u3057\u306a\u304c\u3089\u30af\u30ea\u30c3\u30af\u3057\u3066\u304f\u3060\u3055\u3044) @@ -2055,5 +2101,6 @@ state.Starting=\u958b\u59cb\u4e2d state.Stopped=\u505c\u6b62\u6e08\u307f state.Stopping=\u505c\u6b62\u3057\u3066\u3044\u307e\u3059 state.Suspended=\u4e00\u6642\u505c\u6b62 +title.upload.volume=\u30dc\u30ea\u30e5\u30fc\u30e0\u306e\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9 ui.listView.filters.all=\u3059\u3079\u3066 ui.listView.filters.mine=\u81ea\u5206\u306e\u3082\u306e diff --git a/client/WEB-INF/classes/resources/messages_ko_KR.properties b/client/WEB-INF/classes/resources/messages_ko_KR.properties index 9a2c291303f1..512fcd9206c4 100644 --- a/client/WEB-INF/classes/resources/messages_ko_KR.properties +++ b/client/WEB-INF/classes/resources/messages_ko_KR.properties @@ -196,7 +196,6 @@ label.action.reboot.systemvm.processing=\uc2dc\uc2a4\ud15c VM\ub97c \uc7ac\uc2dc label.action.reboot.systemvm=\uc2dc\uc2a4\ud15c VM \uc7ac\uc2dc\uc791 label.action.recurring.snapshot=\uc815\uae30 \uc2a4\ub0c5\uc0f7 label.action.register.iso=ISO \ub4f1\ub85d -label.action.register.template=\ud15c\ud50c\ub9bf \ub4f1\ub85d label.action.release.ip=IP \uc8fc\uc18c \ud574\uc81c label.action.release.ip.processing=IP \uc8fc\uc18c\ub97c \ud574\uc81c\ud558\ub294 \uc911... label.action.remove.host.processing=\ud638\uc2a4\ud2b8\ub97c \uc0ad\uc81c\ud558\ub294 \uc911... diff --git a/client/WEB-INF/classes/resources/messages_nb_NO.properties b/client/WEB-INF/classes/resources/messages_nb_NO.properties index b57779949c18..94dcf0a072b3 100644 --- a/client/WEB-INF/classes/resources/messages_nb_NO.properties +++ b/client/WEB-INF/classes/resources/messages_nb_NO.properties @@ -39,6 +39,7 @@ label.accept.project.invitation=Aksepter prosjektinvitasjon label.account.and.security.group=Konto, Sikkerhetsgruppe label.account.id=Konto ID label.account=Konto +label.account.lower=konto label.account.name=Kontonavn label.accounts=Kontoer label.action.attach.disk.processing=Tilknytter Disk.... @@ -49,7 +50,9 @@ label.action.change.password=Endre passord label.action.change.service=Endre Tjeneste label.action.change.service.processing=Endrer Tjeneste.... label.action.copy.ISO=Kopier ISO +label.action.copy.ISO.processing=Kopierer ISO.... label.action.copy.template=Kopier mal +label.action.copy.template.processing=Kopierer \u00f8yeblikksbilde.... label.action.create.template.from.vm=Lag Mal fra VM label.action.create.template.from.volume=Lag Mal fra Volum label.action.create.template=Opprett mal @@ -91,6 +94,8 @@ label.action.delete.security.group.processing=Slett Sikkerhetsgruppe.... label.action.delete.security.group=Slett Sikkerhetsgruppe label.action.delete.service.offering.processing=Sletter tjenestetilbud.... label.action.delete.service.offering=Slett tjenestetilbud +label.action.delete.snapshot.processing=Sletter \u00f8yeblikksbilde.... +label.action.delete.snapshot=Slett \u00f8yeblikksbilde label.action.delete.system.service.offering=Slett system-tjenestetilbud label.action.delete.template.processing=Sletter mal.... label.action.delete.template=Slett mal @@ -171,7 +176,6 @@ label.action.reboot.router.processing=Omstaer Instans.... label.action.reboot.systemvm=Omstart System VM label.action.reboot.systemvm.processing=Omstarter System VM label.action.register.iso=Registrer ISO -label.action.register.template=Registrer mal label.action.remove.host=Fjern Vert label.action.remove.host.processing=Fjerner Vest.... label.action.reset.password.processing=Tilbakestiller passord.... @@ -194,7 +198,11 @@ label.action.stop.router.processing=Stopper ruter.... label.action.stop.router=Stopp ruter label.action.stop.systemvm.processing=Stopper System VM.... label.action.stop.systemvm=Stopp System VM +label.action.take.snapshot.processing=Tar \u00f8yeblikksbilde.... +label.action.take.snapshot=Ta \u00f8yeblikksbilde label.action.unmanage.cluster.processing=Fjerner administrasjon av klynge... +label.action.vmsnapshot.create=Ta VM \u00f8yeblikksbilde +label.action.vmsnapshot.delete=Slett VM \u00f8yeblikksbilde label.activate.project=Aktiver prosjekt label.active.sessions=Aktive sesjoner label.add.account=Legg til konto @@ -219,6 +227,7 @@ label.adding=Tillegger label.adding.user=Legger til bruker label.adding.zone=Legger til sone label.add.ip.range=Legg til IP-rekke +label.add.ldap.account=Legg til LDAP konto label.add=Legg til label.add.load.balancer=Legg til lastbalanserer label.add.more=Legg til mer @@ -305,6 +314,8 @@ label.by.type=Etter Type label.by.type.id=Etter Type ID label.by.zone=Etter Sone label.cancel=Avbryt +label.capacity.bytes=Kapasitet Bytes +label.capacity.iops=Kapasitet IOPS label.capacity=Kapasitet label.certificate=Sertifikat label.change.service.offering=Endre tjenestetilbud @@ -329,6 +340,7 @@ label.compute.offering=Regnekraftstilbud label.compute.offerings=Regnekraftstilbud label.configuration=Konfigurering label.configure=Konfigurer +label.configure.ldap=Konfigurer LDAP label.configure.vpc=Konfigurer VPC label.confirmation=Bekreftelse label.confirm.password=Bekreft passord @@ -337,6 +349,7 @@ label.conserve.mode=Konserveringsmodus label.console.proxy=Konsollproxy label.continue.basic.install=Fortsett med enkelt oppsett label.continue=Fortsett +label.copying.iso=Kopierer ISO label.corrections.saved=Endringer lagret label.cpu.allocated=CPU allokert label.cpu.allocated.for.VMs=CPU Allokert for VMer @@ -354,6 +367,7 @@ label.custom.disk.size=Tilpasset Diskst\u00f8rrelse label.daily=Daglig label.data.disk.offering=Datadisktilbud label.date=Dato +label.day=Dag label.decline.invitation=Avvis invitasjon label.dedicated=Dedikert label.default=Standardverdi @@ -365,6 +379,7 @@ label.delete.F5=Slett F5 label.delete.gateway=slett gateway label.delete.NetScaler=Slett Netscaler label.delete.PA=Slett Palo Alto +label.delete.profile=Slett Profil label.delete.project=Slett prosjekt label.delete=Slett label.delete.SRX=Slett SRX @@ -408,6 +423,7 @@ label.DNS.domain.for.guest.networks=DNS domene for gjestenettverk label.domain.admin=Domeneadministrator label.domain=Domene label.domain.id=Domene ID +label.domain.lower=domene label.domain.name=Domenenavn label.domain.router=Domeneruter label.done=Utf\u00f8rt @@ -416,12 +432,14 @@ label.edit=Editer label.edit.lb.rule=Endre LB-regel label.edit.network.details=Edit\u00e9r nettverksdetaljer label.edit.project.details=Editer prosjektdetaljer +label.edit.secondary.ips=Endre sekund\u00e6re IPer label.edit.traffic.type=Endre trafikktype label.edit.vpc=Rediger VPC label.elastic=Elastisk label.elastic.IP=Elastisk IP label.elastic.LB=Elastisk LB label.email=E-post +label.email.lower=epost label.enable.provider=Aktiver tilbyder label.enable.swift=Aktiver Swift label.enable.vpn=Aktiver VPN @@ -440,6 +458,7 @@ label.fetch.latest=Hent siste label.filterBy=Filtrer etter label.firewall=Brannmur label.first.name=Fornavn +label.firstname.lower=fornavn label.format=Format label.friday=Fredag label.full=Full @@ -538,6 +557,7 @@ label.lang.norwegian=Norsk label.lang.russian=Russisk label.lang.spanish=Spansk label.last.name=Etternavn +label.lastname.lower=etternavn label.latest.events=Siste hendelser label.launch=Start label.launch.vm=Start VM @@ -562,6 +582,7 @@ label.management=Administrasjon label.management.ips=Administrasjons IP-adresser label.manage.resources=Behandle ressurser label.maximum=Maksimum +label.max.instances=Maks Instanser label.max.public.ips=Maks offentlige IPer label.max.snapshots=Maks \u00f8yeblikksbilder label.max.templates=Maks maler @@ -596,6 +617,7 @@ label.menu.regions=Regioner label.menu.running.instances=Kj\u00f8rende instanser label.menu.security.groups=Sikkerhetsgrupper label.menu.service.offerings=Tjenestetilbud +label.menu.snapshots=\u00d8yebliksbilder label.menu.stopped.instances=Stoppede instanser label.menu.storage=Lagring label.menu.system.service.offerings=Systemtilbud @@ -613,6 +635,7 @@ label.migrate.to.host=Migrer til vert label.migrate.to.storage=Migrer til lagring label.migrate.volume.to.primary.storage=Migrer volumet til en annen prim\u00e6rlagring. label.minimum=Minimum +label.min.instances=Min Instanser label.monday=Mandag label.monthly=M\u00e5nedlig label.more.templates=Flere maler @@ -669,6 +692,8 @@ label.optional=Valgfritt label.order=Rekkef\u00f8lge label.os.type=OS-type label.PA=Palo Alto +label.passive=Passiv +label.password.lower=passord label.password=Passord label.path=Sti label.physical.network=Fysisk nettverk @@ -684,6 +709,7 @@ label.pod=Pod label.pods=Pods label.port.forwarding.policies=Regler for portvideresending label.port.forwarding=Portvideresending +label.port=Port label.port.range=Portrekke label.prev=Forrige label.previous=Forrige @@ -698,6 +724,7 @@ label.private.ips=Private IP-adresser label.private.network=Privat nettverk label.private.port=Privat port label.private.zone=Privat sone +label.profile=Profil label.project.dashboard=Prosjektoversikt label.project.id=Prosjektid label.project.invite=Inviter til prosjekt @@ -707,6 +734,7 @@ label.projects=Prosjekter label.project.view=Prosjektvisning label.protocol=Protokoll label.providers=Tilbydere +label.provider=Tilbyder label.public.ip=Offentlig IP-adresse label.public.ips=Offentlig IP-adresser label.public.network=Offentlig nettverk @@ -716,6 +744,9 @@ label.public.traffic=Offentlig trafikk label.public.zone=Offentlig sone label.purpose=Form\u00e5l label.Pxe.server.type=PXE Servertype +label.rbd.id=Cephx user +label.rbd.monitor=Ceph monitor +label.rbd.pool=Ceph pool label.rbd=RBD label.reboot=Restart label.redundant.router.capability=Redundant ruter @@ -723,11 +754,13 @@ label.redundant.router=Redundant ruter label.redundant.state=Redundant tilstand label.refresh=Oppfrisk label.region=Region +label.reinstall.vm=Reinstaller VM label.related=Relaterte label.remind.later=P\u00e5minn meg senere label.remove.ACL=Fjern ACL label.remove.from.load.balancer=Fjerner instans fra lastbalanserer label.remove.ip.range=Fjern IP-rekke +label.remove.ldap=Fjern LDAP label.remove.pf=Fjern portvideresendingsregel label.remove.region=Fjern region label.remove.rule=Fjern regel @@ -760,6 +793,7 @@ label.save.and.continue=Lagre og fortsett label.save=Lagre label.saving.processing=Lagrer.... label.search=S\u00f8k +label.secondary.ips=Sekund\u00e6re IPer label.secondary.storage=Sekund\u00e6rlagring label.secondary.storage.vm=Sekund\u00e6rlagring VM label.security.group.name=Sikkerhetsgruppenavn @@ -779,7 +813,9 @@ label.sent=Sendt label.server=Tjener label.service.offering=Tjenestetilbud label.service.state=Tjeneste Status +label.services=Tjenester label.session.expired=Sesjon utl\u00f8pt +label.settings=Innstillinger label.setup.network=Nettverksoppsett label.setup=Oppsett label.setup.zone=Soneoppsett @@ -791,6 +827,10 @@ label.skip.guide=Jeg har brukt CloudStack tidligere. Hopp over denne veiviseren label.smb.domain=SMB Domene label.smb.password=SMB Passord label.smb.username=SMB Brukernavn +label.snapshots=\u00d8yeblikksbilder +label.snapshot=\u00d8yeblikksbilde +label.SNMP.port=SNM Port +label.sockets=CPU Sokkel label.source.nat=Kilde NAT label.specify.IP.ranges=Spesifiser IP-rekker label.specify.vlan=Spesifiser VLAN @@ -836,12 +876,16 @@ label.system.capacity=Systemkapasistet label.system.offering=Systemtilbud label.system.vms=System VMer label.system.vm=System VM +label.tagged=Tagget +label.tags=Tagger label.task.completed=Oppgave utf\u00f8rt label.template=Mal label.TFTP.dir=TFTP-mappe label.thursday=Torsdag +label.time.colon=Time\: label.timeout=Tidsavbrudd label.time=Tid +label.timezone.colon=Tidssone\: label.time.zone=Tidssone label.timezone=Tidssone label.token=Kode @@ -855,26 +899,31 @@ label.traffic.types=Trafikktyper label.traffic.type=Trafikktype label.tuesday=Tirsdag label.type.id=Type ID +label.type.lower=type label.type=Type label.unlimited=Ubegrenset label.update.project.resources=Oppdater prosjektressurser label.update.ssl.cert= SSL-sertifikat label.update.ssl= SSL-sertifikat label.updating=Oppdaterer +label.upgrade.required=Oppgradering er p\u00e5krevd label.upload=Last opp label.upload.volume=Last opp volum label.url=URL label.used=Brukt label.user=Bruker label.username=Brukernavn +label.username.lower=brukernavn label.users=Brukere label.use.vm.ip=Bruk VM IP\: +label.use.vm.ips=Bruk VM IPer label.value=Verdi label.vcdcname=vCenter DC navn label.vcenter.cluster=vCenter Klynge label.vcenter.host=vCenter Vert label.vcenter.password=vCenter passord label.vcenter.username=vCenter brukernavn +label.vcenter=vcenter label.vcipaddress=vCenter IP-adresse label.version=Versjon label.view.all=Vis alle @@ -883,6 +932,8 @@ label.viewing=Viser label.view.more=Vis mer label.view.secondary.ips=Se sekund\u00e6re IPer label.view=Vis +label.virtual.machines=Virtuelle Maskiner +label.virtual.machine=Virtuell Maskin label.virtual.network=Virtuelt-nettverk label.virtual.routers=Virtuelle rutere label.virtual.router=Virtuell ruter @@ -894,9 +945,11 @@ label.vm.destroy=Destruer label.vm.display.name=Visningsnavn for VM label.VMFS.datastore=VMFS lagringsomr\u00e5de label.vmfs=VMFS +label.vm.ip=VM IP Adresse label.vm.name=VM-navn label.vm.reboot=Restart label.vmsnapshot.type=Type +label.vmsnapshot=VM \u00d8yeblikksbilder label.vm.start=Start label.vm.stop=Stopp label.vms=VMer @@ -918,6 +971,7 @@ label.vxlan.id=VXLAN ID label.vxlan.range=VXLAN-rekke label.vxlan=VXLAN label.waiting=Venter +label.warning=Advarsel label.warn=Varsle label.wednesday=Onsdag label.weekly=Ukentlig @@ -970,9 +1024,18 @@ message.action.enable.nexusVswitch=Vennligst bekreft at du \u00f8nsker \u00e5 ak message.action.enable.physical.network=Vennligst bekreft at du \u00f8nsker \u00e5 aktivere dette fysiske nettverket. message.action.enable.pod=Vennligst bekreft at du \u00f8nsker \u00e5 aktivere denne poden. message.action.enable.zone=Vennligst bekreft at du \u00f8nsker \u00e5 aktivere denne sonen. +message.action.reboot.instance=Vennligst bekreft at du vill restarte denne instansen. +message.action.reboot.systemvm=Vennligst bekreft at du vil restarte denne system VM +message.action.remove.host=Vennligst bekreft at du vil gjerne denne tjeneren. message.action.start.instance=Vennligst bekreft at du \u00f8nsker \u00e5 starte denne instansen. +message.action.start.router=Vennligst bekreft at du vil starte denne ruter. +message.action.start.systemvm=Vennligst bekreft at du vil starte denne system VM. +message.action.stop.instance=Vennligst bekreft at du vil stoppe denne instansen. +message.action.stop.systemvm=Vennligst bekreft at du vil stoppe denne system VM. +message.action.take.snapshot=Vennligst bekreft at du vil ta et \u00f8yeblikksbilde av dette volumet. message.activate.project=Er du sikker p\u00e5 du \u00f8nsker \u00e5 aktivere dette prosjektet? message.add.domain=Vennligst bekreft underdomenet du \u00f8nsker \u00e5 opprette under dette domenet +message.add.firewall=Legg en brannmur til sonen message.add.guest.network=Vennligst bekreft at du \u00f8nsker \u00e5 legge til gjestenettverk message.adding.host=Legger til vert message.adding.Netscaler.device=Legg til NetScaler-enhet @@ -984,8 +1047,10 @@ message.configuring.guest.traffic=Konfigurerer gjestetrafikk message.configuring.physical.networks=Konfigurer fysisk nettverk message.configuring.public.traffic=Konfigurerer offentlig trafikk message.configuring.storage.traffic=Konfigurerer lagringstrafikk +message.confirm.delete.ciscoASA1000v=Vennligst bekreft at du vil slette CiscoASA1000v message.confirm.delete.F5=Vennligst bekreft at du \u00f8nsker \u00e5 slette F5 message.confirm.delete.NetScaler=Vennligst bekreft at du \u00f8nsker \u00e5 slette Netscaler +message.confirm.delete.PA=Vennligst bekreft at du vil slette Palo Alto message.confirm.delete.SRX=Vennligst bekreft at du \u00f8nsker \u00e5 slette SRX message.confirm.destroy.router=Vennligst bekreft at du \u00f8nsker \u00e5 fjerne denne ruteren message.confirm.disable.provider=Vennligst bekreft at du \u00f8nsker \u00e5 deaktivere denne tilbyderen @@ -1037,6 +1102,7 @@ message.instanceWizard.noTemplates=Du har ingen maler tilgjengelig. Vennligst le message.ip.address.changed=Din IP-adresse kan ha endret seg. \u00d8nsker du \u00e5 oppdatere visningen? Merk at detaljvisningen vil i s\u00e5fall lukkes. message.iso.desc=Diskimage som inneholder data etter oppstartsbar media for OS message.join.project=Du har n\u00e5 deltatt i et prosjekt. Vennligst bytt til prosjektvisning for \u00e5 se prosjektet. +message.listView.subselect.multi=(Ctrl/Cmd-klikk) message.migrate.instance.to.host=Vennligst bekreft at du \u00f8nsker \u00e5 migrere instansen til en annen vert. message.migrate.instance.to.ps=Vennligst bekreft at du \u00f8nsker \u00e5 migrere instansen til en annen sekund\u00e6r lagring. message.migrate.router.confirm=Vennligst bekreft verten du \u00f8nsker \u00e5 migrere ruteren til\: diff --git a/client/WEB-INF/classes/resources/messages_nl_NL.properties b/client/WEB-INF/classes/resources/messages_nl_NL.properties index be2d626ac9a3..e5582a7d2ee6 100644 --- a/client/WEB-INF/classes/resources/messages_nl_NL.properties +++ b/client/WEB-INF/classes/resources/messages_nl_NL.properties @@ -203,7 +203,6 @@ label.action.reboot.systemvm=Herstart Systeem VM label.action.reboot.systemvm.processing=Bezig met herstarten van Systeem VM.... label.action.recurring.snapshot=Terugkerende Snapshots label.action.register.iso=Registreer ISO -label.action.register.template=Registreer Template label.action.release.ip=Ontkoppel IP label.action.release.ip.processing=Bezig met ontkoppelen van IP.... label.action.remove.host.processing=Bezig met verwijderen van Host.... diff --git a/client/WEB-INF/classes/resources/messages_pl.properties b/client/WEB-INF/classes/resources/messages_pl.properties index 72cbf66efe13..491cb97da231 100644 --- a/client/WEB-INF/classes/resources/messages_pl.properties +++ b/client/WEB-INF/classes/resources/messages_pl.properties @@ -116,7 +116,6 @@ label.action.reboot.router=Restartuj router label.action.reboot.systemvm.processing=Restartuje system VM.... label.action.reboot.systemvm=Restartuj system VM label.action.register.iso=Rejestruj ISO -label.action.register.template=Rejestruj szablon label.action.remove.host.processing=Usuwam host.... label.action.remove.host=Usu\u0144 host label.action.reset.password.processing=Resetuj\u0119 has\u0142o.... diff --git a/client/WEB-INF/classes/resources/messages_pt_BR.properties b/client/WEB-INF/classes/resources/messages_pt_BR.properties index bd83637ad992..bc3d912122d1 100644 --- a/client/WEB-INF/classes/resources/messages_pt_BR.properties +++ b/client/WEB-INF/classes/resources/messages_pt_BR.properties @@ -200,7 +200,6 @@ label.action.reboot.systemvm.processing=Reiniciando VM de Sistema.... label.action.reboot.systemvm=Reiniciar VM de Sistema label.action.recurring.snapshot=Snapshots recorrentes label.action.register.iso=Registrar ISO -label.action.register.template=Registrar template label.action.release.ip=Liberar IP label.action.release.ip.processing=Liberando IP.... label.action.remove.host.processing=Removendo Host.... diff --git a/client/WEB-INF/classes/resources/messages_ru_RU.properties b/client/WEB-INF/classes/resources/messages_ru_RU.properties index ab995fb068c4..c9cf295b40bd 100644 --- a/client/WEB-INF/classes/resources/messages_ru_RU.properties +++ b/client/WEB-INF/classes/resources/messages_ru_RU.properties @@ -197,7 +197,6 @@ label.action.reboot.systemvm.processing=\u041f\u0435\u0440\u0435\u0437\u0430\u04 label.action.reboot.systemvm=\u041f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u0443\u044e \u0412\u041c label.action.recurring.snapshot=\u041f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u043c\u044b\u0435 \u0441\u043d\u0438\u043c\u043a\u0438 label.action.register.iso=\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f ISO -label.action.register.template=\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0430 label.action.release.ip.processing=\u041e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u0435 IP... label.action.release.ip=\u041e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442\u044c IP label.action.remove.host.processing=\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0443\u0437\u043b\u0430... diff --git a/client/WEB-INF/classes/resources/messages_zh_CN.properties b/client/WEB-INF/classes/resources/messages_zh_CN.properties index e4096c79c420..93c13424cccc 100644 --- a/client/WEB-INF/classes/resources/messages_zh_CN.properties +++ b/client/WEB-INF/classes/resources/messages_zh_CN.properties @@ -205,7 +205,6 @@ label.action.reboot.systemvm.processing=\u6b63\u5728\u91cd\u65b0\u542f\u52a8\u7c label.action.reboot.systemvm=\u91cd\u65b0\u542f\u52a8\u7cfb\u7edf VM label.action.recurring.snapshot=\u91cd\u73b0\u5feb\u7167 label.action.register.iso=\u6ce8\u518c ISO -label.action.register.template=\u6ce8\u518c\u6a21\u677f label.action.release.ip.processing=\u6b63\u5728\u91ca\u653e IP... label.action.release.ip=\u91ca\u653e IP label.action.remove.host.processing=\u6b63\u5728\u5220\u9664\u4e3b\u673a... diff --git a/tools/transifex/.tx/config b/tools/transifex/.tx/config index 5a19f9a5ced5..2b66feb80687 100644 --- a/tools/transifex/.tx/config +++ b/tools/transifex/.tx/config @@ -59,6 +59,7 @@ trans.ca = work-dir/messages_ca.properties trans.de_DE = work-dir/messages_de_DE.properties trans.es = work-dir/messages_es.properties trans.fr_FR = work-dir/messages_fr_FR.properties +trans.hu = work-dir/messages_hu.properties trans.it_IT = work-dir/messages_it_IT.properties trans.ja_JP = work-dir/messages_ja_JP.properties trans.ko_KR = work-dir/messages_ko_KR.properties From ab1df169f25641df8da452e41a0d9feee71e7cce Mon Sep 17 00:00:00 2001 From: Erik Weber Date: Tue, 12 May 2015 12:37:51 +0200 Subject: [PATCH 042/175] CLOUDSTACK-1667: Make a better description of the extractable flag Signed-off-by: Rohit Yadav This closes #245 --- ui/scripts/docs.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/scripts/docs.js b/ui/scripts/docs.js index dea68814bc92..c8337e1ecd4c 100755 --- a/ui/scripts/docs.js +++ b/ui/scripts/docs.js @@ -1168,7 +1168,7 @@ cloudStack.docs = { externalLink: '' }, helpRegisterISOExtractable: { - desc: 'Whether the ISO is extractable or not', + desc: 'Whether the ISO is downloadable by users or not', externalLink: '' }, helpRegisterISOPublic: { @@ -1209,7 +1209,7 @@ cloudStack.docs = { externalLink: '' }, helpRegisterTemplateExtractable: { - desc: 'Whether the template is extractable or not', + desc: 'Whether the template is downloadable by users or not', externalLink: '' }, helpRegisterTemplateDynamicallyScalable: { From 43d20e67f821b04d46a0b6cb8fc70fd761958579 Mon Sep 17 00:00:00 2001 From: Wido den Hollander Date: Tue, 12 May 2015 13:47:59 +0200 Subject: [PATCH 043/175] graphite: Do not cache DNS names for Graphite host --- .../src/org/apache/cloudstack/utils/graphite/GraphiteClient.java | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/src/org/apache/cloudstack/utils/graphite/GraphiteClient.java b/utils/src/org/apache/cloudstack/utils/graphite/GraphiteClient.java index 3338ccf213f0..4143f0998201 100644 --- a/utils/src/org/apache/cloudstack/utils/graphite/GraphiteClient.java +++ b/utils/src/org/apache/cloudstack/utils/graphite/GraphiteClient.java @@ -79,6 +79,7 @@ public void sendMetrics(Map metrics) { */ public void sendMetrics(Map metrics, long timeStamp) { try (DatagramSocket sock = new DatagramSocket()){ + java.security.Security.setProperty("networkaddress.cache.ttl", "0"); InetAddress addr = InetAddress.getByName(this.graphiteHost); for (Map.Entry metric: metrics.entrySet()) { From 0f82650dcf34a90d66bad134646fa8ec964dfe79 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Tue, 12 May 2015 16:46:23 +0200 Subject: [PATCH 044/175] systemvmtemplate: use ovftool for building vmware template if available This commit fixes a chmod issue where extracted vmdk file is not readable by all users/groups. The other improvement is to use ovftool to build systemvm template for vmware if it's available. This is based on a dev ML discussion and a suggested approach by Ilya: http://markmail.org/message/kntsetgxdbppfh22 Signed-off-by: Rohit Yadav Signed-off-by: Rohit Yadav --- tools/appliance/build.sh | 94 +++++++++++++++++++++++++++++++++------- 1 file changed, 79 insertions(+), 15 deletions(-) diff --git a/tools/appliance/build.sh b/tools/appliance/build.sh index fe0f4e100cd4..96fe6dfa7d12 100755 --- a/tools/appliance/build.sh +++ b/tools/appliance/build.sh @@ -386,6 +386,61 @@ function compact_hdd() { vboxmanage modifyhd "${1}" --compact } +function stage_vmx (){ + cat << VMXFILE > "${1}.vmx" +.encoding = "UTF-8" +displayname = "${1}" +annotation = "${1}" +guestos = "otherlinux-64" +virtualhw.version = "7" +config.version = "8" +numvcpus = "1" +cpuid.coresPerSocket = "1" +memsize = "256" +pciBridge0.present = "TRUE" +pciBridge4.present = "TRUE" +pciBridge4.virtualDev = "pcieRootPort" +pciBridge4.functions = "8" +pciBridge5.present = "TRUE" +pciBridge5.virtualDev = "pcieRootPort" +pciBridge5.functions = "8" +pciBridge6.present = "TRUE" +pciBridge6.virtualDev = "pcieRootPort" +pciBridge6.functions = "8" +pciBridge7.present = "TRUE" +pciBridge7.virtualDev = "pcieRootPort" +pciBridge7.functions = "8" +vmci0.present = "TRUE" +floppy0.present = "FALSE" +ide0:0.clientDevice = "FALSE" +ide0:0.present = "TRUE" +ide0:0.deviceType = "atapi-cdrom" +ide0:0.autodetect = "TRUE" +ide0:0.startConnected = "FALSE" +mks.enable3d = "false" +svga.autodetect = "false" +svga.vramSize = "4194304" +scsi0:0.present = "TRUE" +scsi0:0.deviceType = "disk" +scsi0:0.fileName = "$2" +scsi0:0.mode = "persistent" +scsi0:0.writeThrough = "false" +scsi0.virtualDev = "lsilogic" +scsi0.present = "TRUE" +vmci0.unrestricted = "false" +ethernet0.present = "TRUE" +ethernet0.virtualDev = "e1000" +ethernet0.connectionType = "bridged" +ethernet0.startConnected = "TRUE" +ethernet0.addressType = "generated" +ethernet0.wakeonpcktrcv = "false" +vcpu.hotadd = "false" +vcpu.hotremove = "false" +firmware = "bios" +mem.hotadd = "false" +VMXFILE +} + function xen_server_export() { log INFO "creating xen server export" local hdd_path="${1}" @@ -450,23 +505,32 @@ function vmware_export() { local machine_uuid="${1}" local hdd_uuid="${2}" vboxmanage clonehd "${hdd_uuid}" "${appliance_build_name}-vmware.vmdk" --format VMDK + + if ! ovftool_loc="$(type -p "ovftool")" || [ -z "$ovftool_loc" ]; then + log INFO "ovftool not found, using traditional method to export ova file" + vboxmanage export "${machine_uuid}" --output "${appliance_build_name}-vmware.ovf" + log INFO "${appliance} exported for VMWare: dist/${appliance_build_name}-vmware.{vmdk.bz2,ovf}" + add_on_exit rm -f ${appliance_build_name}-vmware.ovf + add_on_exit rm -f ${appliance_build_name}-vmware-disk[0-9].vmdk + + # xsltproc doesn't support this XSLT so we use java to run this one XSLT + mv ${appliance_build_name}-vmware.ovf ${appliance_build_name}-vmware.ovf-orig + java -cp convert Convert convert_ovf_vbox_to_esx.xslt \ + ${appliance_build_name}-vmware.ovf-orig \ + ${appliance_build_name}-vmware.ovf + add_on_exit rm -f ${appliance_build_name}-vmware.ovf-orig + chmod 666 *.vmdk *.ovf + tar -cf ${appliance_build_name}-vmware.ova \ + ${appliance_build_name}-vmware.ovf \ + ${appliance_build_name}-vmware-disk[0-9].vmdk + else + log INFO "ovftool found, using it to export ova file" + chmod 666 ${appliance_build_name}-vmware.vmdk + stage_vmx ${appliance_build_name}-vmware ${appliance_build_name}-vmware.vmdk + ovftool ${appliance_build_name}-vmware.vmx ${appliance_build_name}-vmware.ova + fi bzip2 "${appliance_build_name}-vmware.vmdk" mv "${appliance_build_name}-vmware.vmdk.bz2" dist/ - vboxmanage export "${machine_uuid}" --output "${appliance_build_name}-vmware.ovf" - log INFO "${appliance} exported for VMWare: dist/${appliance_build_name}-vmware.{vmdk.bz2,ovf}" - add_on_exit rm -f ${appliance_build_name}-vmware.ovf - add_on_exit rm -f ${appliance_build_name}-vmware-disk[0-9].vmdk - - # xsltproc doesn't support this XSLT so we use java to run this one XSLT - mv ${appliance_build_name}-vmware.ovf ${appliance_build_name}-vmware.ovf-orig - java -cp convert Convert convert_ovf_vbox_to_esx.xslt \ - ${appliance_build_name}-vmware.ovf-orig \ - ${appliance_build_name}-vmware.ovf - add_on_exit rm -f ${appliance_build_name}-vmware.ovf-orig - - tar -cf ${appliance_build_name}-vmware.ova \ - ${appliance_build_name}-vmware.ovf \ - ${appliance_build_name}-vmware-disk[0-9].vmdk mv ${appliance_build_name}-vmware.ova dist/ log INFO "${appliance} exported for VMWare: dist/${appliance_build_name}-vmware.ova" } From 8a1ec9d0f673512e45e8f3e12eabf9093be84583 Mon Sep 17 00:00:00 2001 From: Abhinandan Prateek Date: Wed, 13 May 2015 10:11:22 +0530 Subject: [PATCH 045/175] adding mysql dependency for usage --- usage/pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/usage/pom.xml b/usage/pom.xml index a63a225ba941..7746e0139c37 100644 --- a/usage/pom.xml +++ b/usage/pom.xml @@ -38,6 +38,12 @@ commons-daemon commons-daemon + + + mysql + mysql-connector-java + ${cs.mysql.version} + provided javax.mail From bcb33b381535f3f02cfcc9aa6d6b7f7536de5d67 Mon Sep 17 00:00:00 2001 From: Abhinandan Prateek Date: Wed, 13 May 2015 10:57:37 +0530 Subject: [PATCH 046/175] adding simple logging for java version dependency --- usage/pom.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/usage/pom.xml b/usage/pom.xml index 7746e0139c37..c1cbb92086b2 100644 --- a/usage/pom.xml +++ b/usage/pom.xml @@ -45,6 +45,16 @@ ${cs.mysql.version} provided + + org.slf4j + slf4j-api + 1.7.7 + + + org.slf4j + slf4j-log4j12 + 1.7.7 + javax.mail mail From b8e82a97b6bc342d868fa4589c2fc15e3a482b85 Mon Sep 17 00:00:00 2001 From: Gaurav Aradhye Date: Wed, 13 May 2015 11:12:09 +0530 Subject: [PATCH 047/175] CLOUDSTACK-8466: Fixed import error in testpath_snapshot_limits.py Signed-off-by: Gaurav Aradhye --- test/integration/testpaths/testpath_snapshot_limits.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/integration/testpaths/testpath_snapshot_limits.py b/test/integration/testpaths/testpath_snapshot_limits.py index 94d5e95c688b..e30161dd4e53 100644 --- a/test/integration/testpaths/testpath_snapshot_limits.py +++ b/test/integration/testpaths/testpath_snapshot_limits.py @@ -34,7 +34,7 @@ get_template ) -from marvin.codes import (BACKEDUP, PASS, FAIL) +from marvin.codes import (BACKED_UP, PASS, FAIL) class TestStorageSnapshotsLimits(cloudstackTestCase): @@ -202,7 +202,7 @@ def test_05_storage_snapshots_limits(self): # Verify Snapshot state self.assertEqual( snapshots_list[0].state.lower() in [ - BACKEDUP, + BACKED_UP, ], True, "Snapshot state is not as expected. It is %s" % @@ -285,7 +285,7 @@ def test_05_storage_snapshots_limits(self): # Verify Snapshot state self.assertEqual( snapshots_list[0].state.lower() in [ - BACKEDUP, + BACKED_UP, ], True, "Snapshot state is not as expected. It is %s" % @@ -321,7 +321,7 @@ def test_05_storage_snapshots_limits(self): # Verify Snapshot state self.assertEqual( snapshots_list[0].state.lower() in [ - BACKEDUP, + BACKED_UP, ], True, "Snapshot state is not as expected. It is %s" % From 60b6dc1368620cb9c08bdee26b410b5409e05949 Mon Sep 17 00:00:00 2001 From: Abhinandan Prateek Date: Wed, 13 May 2015 12:28:50 +0530 Subject: [PATCH 048/175] CLOUDSTACK-8467: set version to unknown instead of null --- usage/src/com/cloud/usage/UsageManagerImpl.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/usage/src/com/cloud/usage/UsageManagerImpl.java b/usage/src/com/cloud/usage/UsageManagerImpl.java index 5453be993171..c1e26b30c0c7 100644 --- a/usage/src/com/cloud/usage/UsageManagerImpl.java +++ b/usage/src/com/cloud/usage/UsageManagerImpl.java @@ -182,10 +182,7 @@ public boolean configure(String name, Map params) throws Configu final Class c = UsageServer.class; _version = c.getPackage().getImplementationVersion(); - if (_version == null) { - // TODO - // throw new CloudRuntimeException("Unable to find the implementation version of this usage server"); - } + if (_version == null) _version="unknown"; if (s_logger.isInfoEnabled()) { s_logger.info("Implementation Version is " + _version); From c7d2e444d2981464dd115d1030371cde2fdaeb68 Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Wed, 13 May 2015 11:56:43 +0200 Subject: [PATCH 049/175] Fixing license header in a file added during the LibVirt refactor - New class is MigrateKVMAsync --- .../kvm/resource/MigrateKVMAsync.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/MigrateKVMAsync.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/MigrateKVMAsync.java index fdec032ed5b0..2df6c651e3de 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/MigrateKVMAsync.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/MigrateKVMAsync.java @@ -1,3 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package com.cloud.hypervisor.kvm.resource; import java.util.concurrent.Callable; @@ -35,4 +53,4 @@ public Domain call() throws LibvirtException { return dm.migrate(dconn, 1 << 0|1 << 11, dxml, vmName, "tcp:" + destIp, libvirtComputingResource.getMigrateSpeed()); } } -} \ No newline at end of file +} From b1f2e598e83e8ec018ae993f918accb0199b9237 Mon Sep 17 00:00:00 2001 From: Gaurav Aradhye Date: Wed, 13 May 2015 16:36:56 +0530 Subject: [PATCH 050/175] CLOUDSTACK-8468: Correct test case in test_bugs.py Signed-off-by: Gaurav Aradhye This closes #251 --- test/integration/component/maint/test_bugs.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/integration/component/maint/test_bugs.py b/test/integration/component/maint/test_bugs.py index 96d0f77e593e..6652b04e3be4 100644 --- a/test/integration/component/maint/test_bugs.py +++ b/test/integration/component/maint/test_bugs.py @@ -532,6 +532,12 @@ def test_es_47_list_os_types_win_2012(self): """ + if not is_config_suitable(apiclient=self.apiClient, + name='apply.allocation.algorithm.to.pods', + value='true'): + self.skipTest('apply.allocation.algorithm.to.pods ' + 'should be true. skipping') + # register windows 2012 VM template as windows 8 template self.hypervisor = self.testClient.getHypervisorInfo() if self.hypervisor.lower() in ['lxc']: From e26722daa3d9282a04378733d0c4988bb3cb0a73 Mon Sep 17 00:00:00 2001 From: Koushik Das Date: Wed, 13 May 2015 17:35:29 +0530 Subject: [PATCH 051/175] CLOUDSTACK-8301: Enable configuring local storage use for system VMs at zone level Made system.vm.use.local.storage a zone level configuration. --- api/src/com/cloud/dc/DataCenter.java | 4 -- .../cloud/service/dao/ServiceOfferingDao.java | 6 +++ .../service/dao/ServiceOfferingDaoImpl.java | 38 +++++++++++++++ .../lb/ElasticLoadBalancerManagerImpl.java | 19 ++++---- .../network/lb/LoadBalanceRuleHandler.java | 26 +++++++--- .../lb/InternalLoadBalancerVMManagerImpl.java | 36 ++++++++++---- .../InternalLBVMManagerTest.java | 8 +++- .../InternalLBVMServiceTest.java | 10 +++- .../src/com/cloud/configuration/Config.java | 1 - .../ConfigurationManagerImpl.java | 48 ++++++------------- .../consoleproxy/ConsoleProxyManagerImpl.java | 48 +++++++++++-------- .../deploy/DeploymentPlanningManagerImpl.java | 36 ++++---------- .../VirtualNetworkApplianceManagerImpl.java | 15 +++--- .../com/cloud/storage/StorageManagerImpl.java | 13 ++++- .../RouterDeploymentDefinition.java | 24 ++++++++-- .../RouterDeploymentDefinitionBuilder.java | 4 ++ .../VpcRouterDeploymentDefinition.java | 6 +-- .../element/VirtualRouterElementTest.java | 6 ++- .../RouterDeploymentDefinitionTest.java | 13 +++-- .../RouterDeploymentDefinitionTestBase.java | 7 +++ .../VpcRouterDeploymentDefinitionTest.java | 14 +++--- .../SecondaryStorageManagerImpl.java | 48 ++++++++++++------- 22 files changed, 273 insertions(+), 157 deletions(-) diff --git a/api/src/com/cloud/dc/DataCenter.java b/api/src/com/cloud/dc/DataCenter.java index 6cd054e28bcf..5b3d3c01f300 100644 --- a/api/src/com/cloud/dc/DataCenter.java +++ b/api/src/com/cloud/dc/DataCenter.java @@ -20,7 +20,6 @@ import org.apache.cloudstack.acl.InfrastructureEntity; import org.apache.cloudstack.api.Identity; import org.apache.cloudstack.api.InternalIdentity; -import org.apache.cloudstack.framework.config.ConfigKey; import java.util.Map; @@ -28,9 +27,6 @@ * */ public interface DataCenter extends InfrastructureEntity, Grouping, Identity, InternalIdentity { - public static final String SystemVMUseLocalStorageCK = "system.vm.use.local.storage"; - public static final ConfigKey UseSystemVMLocalStorage = new ConfigKey(Boolean.class, SystemVMUseLocalStorageCK, "Advanced", "false", - "Indicates whether to use local storage pools or shared storage pools for system VMs.", true, ConfigKey.Scope.Zone, null); public enum NetworkType { Basic, Advanced, diff --git a/engine/schema/src/com/cloud/service/dao/ServiceOfferingDao.java b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDao.java index ab818538d2aa..98dc3178de4f 100644 --- a/engine/schema/src/com/cloud/service/dao/ServiceOfferingDao.java +++ b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDao.java @@ -20,7 +20,9 @@ import java.util.Map; import com.cloud.service.ServiceOfferingVO; +import com.cloud.storage.Storage.ProvisioningType; import com.cloud.utils.db.GenericDao; +import com.cloud.vm.VirtualMachine; /* * Data Access Object for service_offering table @@ -28,6 +30,10 @@ public interface ServiceOfferingDao extends GenericDao { ServiceOfferingVO findByName(String name); + List createSystemServiceOfferings(String name, String uniqueName, int cpuCount, int ramSize, int cpuSpeed, + Integer rateMbps, Integer multicastRateMbps, boolean offerHA, String displayText, ProvisioningType provisioningType, + boolean recreatable, String tags, boolean systemUse, VirtualMachine.Type vmType, boolean defaultUse); + ServiceOfferingVO persistSystemServiceOffering(ServiceOfferingVO vo); List findPublicServiceOfferings(); diff --git a/engine/schema/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java index a3ff45ca3ad3..a3ffbc1396df 100644 --- a/engine/schema/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java +++ b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java @@ -31,11 +31,13 @@ import com.cloud.event.UsageEventVO; import com.cloud.service.ServiceOfferingDetailsVO; import com.cloud.service.ServiceOfferingVO; +import com.cloud.storage.Storage.ProvisioningType; import com.cloud.utils.db.DB; import com.cloud.utils.db.GenericDaoBase; import com.cloud.utils.db.SearchBuilder; import com.cloud.utils.db.SearchCriteria; import com.cloud.utils.exception.CloudRuntimeException; +import com.cloud.vm.VirtualMachine; import com.cloud.vm.dao.UserVmDetailsDao; @Component @@ -110,6 +112,13 @@ public ServiceOfferingVO persistSystemServiceOffering(ServiceOfferingVO offering vo.setSpeed(500); update(vo.getId(), vo); } + if (!vo.getUniqueName().endsWith("-Local")) { + if (vo.getUseLocalStorage()) { + vo.setUniqueName(vo.getUniqueName() + "-Local"); + vo.setName(vo.getName() + " - Local Storage"); + update(vo.getId(), vo); + } + } return vo; } try { @@ -238,4 +247,33 @@ public ServiceOfferingVO getcomputeOffering(ServiceOfferingVO serviceOffering, M return dummyoffering; } + + @Override + public List createSystemServiceOfferings(String name, String uniqueName, int cpuCount, int ramSize, int cpuSpeed, + Integer rateMbps, Integer multicastRateMbps, boolean offerHA, String displayText, ProvisioningType provisioningType, + boolean recreatable, String tags, boolean systemUse, VirtualMachine.Type vmType, boolean defaultUse) { + List list = new ArrayList(); + ServiceOfferingVO offering = new ServiceOfferingVO(name, cpuCount, ramSize, cpuSpeed, rateMbps, multicastRateMbps, offerHA, displayText, + provisioningType, false, recreatable, tags, systemUse, vmType, defaultUse); + offering.setUniqueName(uniqueName); + offering = persistSystemServiceOffering(offering); + if (offering != null) { + list.add(offering); + } + + boolean useLocal = true; + if (offering.getUseLocalStorage()) { // if 1st one is already local then 2nd needs to be shared + useLocal = false; + } + + offering = new ServiceOfferingVO(name + (useLocal ? " - Local Storage" : ""), cpuCount, ramSize, cpuSpeed, rateMbps, multicastRateMbps, offerHA, displayText, + provisioningType, useLocal, recreatable, tags, systemUse, vmType, defaultUse); + offering.setUniqueName(uniqueName + (useLocal ? "-Local" : "")); + offering = persistSystemServiceOffering(offering); + if (offering != null) { + list.add(offering); + } + + return list; + } } diff --git a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java index d853299eefdb..9aba5ae4d013 100644 --- a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java +++ b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java @@ -148,7 +148,6 @@ public class ElasticLoadBalancerManagerImpl extends ManagerBase implements Elast TrafficType _frontendTrafficType = TrafficType.Guest; Account _systemAcct; - ServiceOfferingVO _elasticLbVmOffering; ScheduledExecutorService _gcThreadPool; String _mgmtCidr; @@ -290,16 +289,18 @@ public boolean configure(String name, Map params) throws Configu } _mgmtCidr = _configDao.getValue(Config.ManagementNetwork.key()); - boolean useLocalStorage = Boolean.parseBoolean(configs.get(DataCenter.SystemVMUseLocalStorageCK)); - _elasticLbVmRamSize = NumbersUtil.parseInt(configs.get(Config.ElasticLoadBalancerVmMemory.key()), DEFAULT_ELB_VM_RAMSIZE); _elasticLbvmCpuMHz = NumbersUtil.parseInt(configs.get(Config.ElasticLoadBalancerVmCpuMhz.key()), DEFAULT_ELB_VM_CPU_MHZ); _elasticLbvmNumCpu = NumbersUtil.parseInt(configs.get(Config.ElasticLoadBalancerVmNumVcpu.key()), 1); - _elasticLbVmOffering = new ServiceOfferingVO("System Offering For Elastic LB VM", _elasticLbvmNumCpu, - _elasticLbVmRamSize, _elasticLbvmCpuMHz, 0, 0, true, null, Storage.ProvisioningType.THIN, useLocalStorage, - true, null, true, VirtualMachine.Type.ElasticLoadBalancerVm, true); - _elasticLbVmOffering.setUniqueName(ServiceOffering.elbVmDefaultOffUniqueName); - _elasticLbVmOffering = _serviceOfferingDao.persistSystemServiceOffering(_elasticLbVmOffering); + List offerings = _serviceOfferingDao.createSystemServiceOfferings("System Offering For Elastic LB VM", + ServiceOffering.elbVmDefaultOffUniqueName, _elasticLbvmNumCpu, _elasticLbVmRamSize, _elasticLbvmCpuMHz, 0, 0, true, null, + Storage.ProvisioningType.THIN, true, null, true, VirtualMachine.Type.ElasticLoadBalancerVm, true); + // this can sometimes happen, if DB is manually or programmatically manipulated + if (offerings == null || offerings.size() < 2) { + String msg = "Data integrity problem : System Offering For Elastic LB VM has been removed?"; + s_logger.error(msg); + throw new ConfigurationException(msg); + } String enabled = _configDao.getValue(Config.ElasticLoadBalancerEnabled.key()); _enabled = (enabled == null) ? false : Boolean.parseBoolean(enabled); @@ -322,7 +323,7 @@ public boolean configure(String name, Map params) throws Configu _itMgr.registerGuru(VirtualMachine.Type.ElasticLoadBalancerVm, this); } - loadBalanceRuleHandler = new LoadBalanceRuleHandler(_elasticLbVmOffering, _instance, _systemAcct); + loadBalanceRuleHandler = new LoadBalanceRuleHandler(_instance, _systemAcct); return true; } diff --git a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/LoadBalanceRuleHandler.java b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/LoadBalanceRuleHandler.java index 497913f2e925..f2c4685280ad 100644 --- a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/LoadBalanceRuleHandler.java +++ b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/LoadBalanceRuleHandler.java @@ -32,6 +32,7 @@ import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; import org.apache.log4j.Logger; +import com.cloud.configuration.ConfigurationManagerImpl; import com.cloud.dc.DataCenter; import com.cloud.dc.Pod; import com.cloud.dc.PodVlanMapVO; @@ -70,8 +71,10 @@ import com.cloud.network.router.VirtualRouter.Role; import com.cloud.network.rules.LoadBalancer; import com.cloud.offering.NetworkOffering; +import com.cloud.offering.ServiceOffering; import com.cloud.offerings.dao.NetworkOfferingDao; import com.cloud.service.ServiceOfferingVO; +import com.cloud.service.dao.ServiceOfferingDao; import com.cloud.storage.VMTemplateVO; import com.cloud.storage.dao.VMTemplateDao; import com.cloud.user.Account; @@ -141,16 +144,16 @@ public class LoadBalanceRuleHandler { @Inject private VirtualRouterProviderDao _vrProviderDao; @Inject + private ServiceOfferingDao _serviceOfferingDao; + @Inject private UserDao _userDao; static final private String ELB_VM_NAME_PREFIX = "l"; - private final ServiceOfferingVO _elasticLbVmOffering; private final String _instance; private final Account _systemAcct; - public LoadBalanceRuleHandler(final ServiceOfferingVO elasticLbVmOffering, final String instance, final Account systemAcct) { - _elasticLbVmOffering = elasticLbVmOffering; + public LoadBalanceRuleHandler(String instance, Account systemAcct) { _instance = instance; _systemAcct = systemAcct; } @@ -279,12 +282,23 @@ private DomainRouterVO deployELBVm(Network guestNetwork, final DeployDestination userId = _userDao.listByAccount(owner.getAccountId()).get(0).getId(); } - elbVm = new DomainRouterVO(id, _elasticLbVmOffering.getId(), vrProvider.getId(), VirtualMachineName.getSystemVmName(id, _instance, ELB_VM_NAME_PREFIX), + String offeringName = ServiceOffering.elbVmDefaultOffUniqueName; + Boolean useLocalStorage = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId()); + if (useLocalStorage != null && useLocalStorage.booleanValue()) { + offeringName += "-Local"; + } + ServiceOfferingVO elasticLbVmOffering = _serviceOfferingDao.findByName(offeringName); + if (elasticLbVmOffering == null) { + String message = "System service offering " + offeringName + " not found"; + s_logger.error(message); + throw new CloudRuntimeException(message); + } + elbVm = new DomainRouterVO(id, elasticLbVmOffering.getId(), vrProvider.getId(), VirtualMachineName.getSystemVmName(id, _instance, ELB_VM_NAME_PREFIX), template.getId(), template.getHypervisorType(), template.getGuestOSId(), owner.getDomainId(), owner.getId(), userId, false, RedundantState.UNKNOWN, - _elasticLbVmOffering.getOfferHA(), false, null); + elasticLbVmOffering.getOfferHA(), false, null); elbVm.setRole(Role.LB); elbVm = _routerDao.persist(elbVm); - _itMgr.allocate(elbVm.getInstanceName(), template, _elasticLbVmOffering, networks, plan, null); + _itMgr.allocate(elbVm.getInstanceName(), template, elasticLbVmOffering, networks, plan, null); elbVm = _routerDao.findById(elbVm.getId()); //TODO: create usage stats } diff --git a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java index affbd5c0d1e8..818ad88b07ae 100644 --- a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java +++ b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java @@ -46,6 +46,7 @@ import com.cloud.agent.api.to.LoadBalancerTO; import com.cloud.agent.manager.Commands; import com.cloud.configuration.Config; +import com.cloud.configuration.ConfigurationManagerImpl; import com.cloud.dc.DataCenter; import com.cloud.dc.DataCenterVO; import com.cloud.dc.dao.DataCenterDao; @@ -380,15 +381,15 @@ public boolean configure(final String name, final Map params) th //if offering wasn't set, try to get the default one if (_internalLbVmOfferingId == 0L) { - final boolean useLocalStorage = Boolean.parseBoolean(configs.get(DataCenter.SystemVMUseLocalStorageCK)); - ServiceOfferingVO newOff = - new ServiceOfferingVO("System Offering For Internal LB VM", 1, InternalLoadBalancerVMManager.DEFAULT_INTERNALLB_VM_RAMSIZE, - InternalLoadBalancerVMManager.DEFAULT_INTERNALLB_VM_CPU_MHZ, null, null, true, null, - Storage.ProvisioningType.THIN, useLocalStorage, true, null, true, - VirtualMachine.Type.InternalLoadBalancerVm, true); - newOff.setUniqueName(ServiceOffering.internalLbVmDefaultOffUniqueName); - newOff = _serviceOfferingDao.persistSystemServiceOffering(newOff); - _internalLbVmOfferingId = newOff.getId(); + List offerings = _serviceOfferingDao.createSystemServiceOfferings("System Offering For Internal LB VM", + ServiceOffering.internalLbVmDefaultOffUniqueName, 1, InternalLoadBalancerVMManager.DEFAULT_INTERNALLB_VM_RAMSIZE, + InternalLoadBalancerVMManager.DEFAULT_INTERNALLB_VM_CPU_MHZ, null, null, true, null, + Storage.ProvisioningType.THIN, true, null, true, VirtualMachine.Type.InternalLoadBalancerVm, true); + if (offerings == null || offerings.size() < 2) { + String msg = "Data integrity problem : System Offering For Internal LB VM has been removed?"; + s_logger.error(msg); + throw new ConfigurationException(msg); + } } _itMgr.registerGuru(VirtualMachine.Type.InternalLoadBalancerVm, this); @@ -620,9 +621,24 @@ protected List findOrDeployInternalLbVm(final Network guestNetwo } final LinkedHashMap> networks = createInternalLbVmNetworks(guestNetwork, plan, requestedGuestIp); + long internalLbVmOfferingId = _internalLbVmOfferingId; + if (internalLbVmOfferingId == 0L) { + String offeringName = ServiceOffering.internalLbVmDefaultOffUniqueName; + Boolean useLocalStorage = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId()); + if (useLocalStorage != null && useLocalStorage.booleanValue()) { + offeringName += "-Local"; + } + ServiceOfferingVO serviceOffering = _serviceOfferingDao.findByName(offeringName); + if (serviceOffering == null) { + String message = "System service offering " + offeringName + " not found"; + s_logger.error(message); + throw new CloudRuntimeException(message); + } + internalLbVmOfferingId = serviceOffering.getId(); + } //Pass startVm=false as we are holding the network lock that needs to be released at the end of vm allocation final DomainRouterVO internalLbVm = - deployInternalLbVm(owner, dest, plan, params, internalLbProviderId, _internalLbVmOfferingId, guestNetwork.getVpcId(), networks, false); + deployInternalLbVm(owner, dest, plan, params, internalLbProviderId, internalLbVmOfferingId, guestNetwork.getVpcId(), networks, false); if (internalLbVm != null) { _internalLbVmDao.addRouterToGuestNetwork(internalLbVm, guestNetwork); internalLbVms.add(internalLbVm); diff --git a/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMManagerTest.java b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMManagerTest.java index 0b47b1f5418d..bc48d468ded2 100644 --- a/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMManagerTest.java +++ b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMManagerTest.java @@ -59,6 +59,7 @@ import com.cloud.service.ServiceOfferingVO; import com.cloud.service.dao.ServiceOfferingDao; import com.cloud.storage.Storage; +import com.cloud.storage.Storage.ProvisioningType; import com.cloud.user.AccountManager; import com.cloud.user.AccountVO; import com.cloud.utils.component.ComponentContext; @@ -120,7 +121,12 @@ public void setUp() { ServiceOfferingVO off = new ServiceOfferingVO("alena", 1, 1, 1, 1, 1, false, "alena", Storage.ProvisioningType.THIN, false, false, null, false, VirtualMachine.Type.InternalLoadBalancerVm, false); off = setId(off, 1); - Mockito.when(_svcOffDao.persistSystemServiceOffering(Matchers.any(ServiceOfferingVO.class))).thenReturn(off); + List list = new ArrayList(); + list.add(off); + list.add(off); + Mockito.when(_svcOffDao.createSystemServiceOfferings(Matchers.anyString(), Matchers.anyString(), Matchers.anyInt(), Matchers.anyInt(), Matchers.anyInt(), + Matchers.anyInt(), Matchers.anyInt(), Matchers.anyBoolean(), Matchers.anyString(), Matchers.any(ProvisioningType.class), Matchers.anyBoolean(), + Matchers.anyString(), Matchers.anyBoolean(), Matchers.any(VirtualMachine.Type.class), Matchers.anyBoolean())).thenReturn(list); ComponentContext.initComponentsLifeCycle(); diff --git a/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMServiceTest.java b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMServiceTest.java index e376e51485d2..84c5f1ba6abb 100644 --- a/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMServiceTest.java +++ b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMServiceTest.java @@ -17,6 +17,8 @@ package org.apache.cloudstack.internallbvmmgr; import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; import javax.inject.Inject; @@ -44,6 +46,7 @@ import com.cloud.service.ServiceOfferingVO; import com.cloud.service.dao.ServiceOfferingDao; import com.cloud.storage.Storage; +import com.cloud.storage.Storage.ProvisioningType; import com.cloud.user.AccountManager; import com.cloud.user.AccountVO; import com.cloud.user.UserVO; @@ -90,7 +93,12 @@ public void setUp() { ServiceOfferingVO off = new ServiceOfferingVO("alena", 1, 1, 1, 1, 1, false, "alena", Storage.ProvisioningType.THIN, false, false, null, false, VirtualMachine.Type.InternalLoadBalancerVm, false); off = setId(off, 1); - Mockito.when(_svcOffDao.persistSystemServiceOffering(Matchers.any(ServiceOfferingVO.class))).thenReturn(off); + List list = new ArrayList(); + list.add(off); + list.add(off); + Mockito.when(_svcOffDao.createSystemServiceOfferings(Matchers.anyString(), Matchers.anyString(), Matchers.anyInt(), Matchers.anyInt(), Matchers.anyInt(), + Matchers.anyInt(), Matchers.anyInt(), Matchers.anyBoolean(), Matchers.anyString(), Matchers.any(ProvisioningType.class), Matchers.anyBoolean(), + Matchers.anyString(), Matchers.anyBoolean(), Matchers.any(VirtualMachine.Type.class), Matchers.anyBoolean())).thenReturn(list); ComponentContext.initComponentsLifeCycle(); diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java index 8dcddc838538..2352313e7bdd 100644 --- a/server/src/com/cloud/configuration/Config.java +++ b/server/src/com/cloud/configuration/Config.java @@ -685,7 +685,6 @@ public enum Config { "/var/cloudstack/mnt", "The mount point on the Management Server for Secondary Storage.", null), -// UpgradeURL("Advanced", ManagementServer.class, String.class, "upgrade.url", "http://example.com:8080/client/agent/update.zip", "The upgrade URL is the URL of the management server that agents will connect to in order to automatically upgrade.", null), SystemVMAutoReserveCapacity( "Advanced", ManagementServer.class, diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index a73969540c66..d08cac6566d4 100644 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -38,7 +38,6 @@ import javax.naming.ConfigurationException; import org.apache.log4j.Logger; - import org.apache.cloudstack.acl.SecurityChecker; import org.apache.cloudstack.affinity.AffinityGroup; import org.apache.cloudstack.affinity.AffinityGroupService; @@ -72,6 +71,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; import org.apache.cloudstack.framework.config.ConfigDepot; import org.apache.cloudstack.framework.config.ConfigKey; +import org.apache.cloudstack.framework.config.Configurable; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.framework.config.impl.ConfigurationVO; import org.apache.cloudstack.region.PortableIp; @@ -215,7 +215,7 @@ import com.cloud.vm.dao.NicSecondaryIpDao; @Local(value = {ConfigurationManager.class, ConfigurationService.class}) -public class ConfigurationManagerImpl extends ManagerBase implements ConfigurationManager, ConfigurationService { +public class ConfigurationManagerImpl extends ManagerBase implements ConfigurationManager, ConfigurationService, Configurable { public static final Logger s_logger = Logger.getLogger(ConfigurationManagerImpl.class); @Inject @@ -335,6 +335,9 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati private Set weightBasedParametersForValidation; private Set overprovisioningFactorsForValidation; + public static final ConfigKey SystemVMUseLocalStorage = new ConfigKey(Boolean.class, "system.vm.use.local.storage", "Advanced", "false", + "Indicates whether to use local storage pools or shared storage pools for system VMs.", false, ConfigKey.Scope.Zone, null); + @Override public boolean configure(final String name, final Map params) throws ConfigurationException { String maxVolumeSizeInGbString = _configDao.getValue(Config.MaxVolumeSize.key()); @@ -575,35 +578,7 @@ public String updateConfiguration(long userId, String name, String category, Str } catch (Throwable e) { throw new CloudRuntimeException("Failed to update storage.network.device2 in host_details due to exception ", e); } - } else if (DataCenter.SystemVMUseLocalStorageCK.equalsIgnoreCase(name)) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("Config 'system.vm.use.local.storage' changed to value:" + value + ", need to update System VM offerings"); - } - boolean useLocalStorage = Boolean.parseBoolean(_configDao.getValue(DataCenter.SystemVMUseLocalStorageCK)); - ServiceOfferingVO serviceOffering = _serviceOfferingDao.findByName(ServiceOffering.consoleProxyDefaultOffUniqueName); - if (serviceOffering != null) { - serviceOffering.setUseLocalStorage(useLocalStorage); - if (!_serviceOfferingDao.update(serviceOffering.getId(), serviceOffering)) { - throw new CloudRuntimeException("Failed to update ConsoleProxy offering's use_local_storage option to value:" + useLocalStorage); - } - } - - serviceOffering = _serviceOfferingDao.findByName(ServiceOffering.routerDefaultOffUniqueName); - if (serviceOffering != null) { - serviceOffering.setUseLocalStorage(useLocalStorage); - if (!_serviceOfferingDao.update(serviceOffering.getId(), serviceOffering)) { - throw new CloudRuntimeException("Failed to update SoftwareRouter offering's use_local_storage option to value:" + useLocalStorage); - } - } - - serviceOffering = _serviceOfferingDao.findByName(ServiceOffering.ssvmDefaultOffUniqueName); - if (serviceOffering != null) { - serviceOffering.setUseLocalStorage(useLocalStorage); - if (!_serviceOfferingDao.update(serviceOffering.getId(), serviceOffering)) { - throw new CloudRuntimeException("Failed to update SecondaryStorage offering's use_local_storage option to value:" + useLocalStorage); - } - } - }else if (Config.SecStorageSecureCopyCert.key().equalsIgnoreCase(name)) { + } else if (Config.SecStorageSecureCopyCert.key().equalsIgnoreCase(name)) { //FIXME - Ideally there should be a listener model to listen to global config changes and be able to take action gracefully. //Expire the download urls String sqlTemplate = "update template_store_ref set download_url_created=?"; @@ -622,8 +597,6 @@ public String updateConfiguration(long userId, String name, String category, Str } catch (Throwable e) { throw new CloudRuntimeException("Failed to clean up download URLs in template_store_ref or volume_store_ref due to exception ", e); } - - } txn.commit(); @@ -5200,4 +5173,13 @@ public void setSecChecker(List secChecker) { _secChecker = secChecker; } + @Override + public String getConfigComponentName() { + return ConfigurationManagerImpl.class.getSimpleName(); + } + + @Override + public ConfigKey[] getConfigKeys() { + return new ConfigKey[] {SystemVMUseLocalStorage}; + } } diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java index bfcef5f93cea..f8d7474cb224 100644 --- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java +++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java @@ -60,6 +60,7 @@ import com.cloud.agent.manager.Commands; import com.cloud.cluster.ClusterManager; import com.cloud.configuration.Config; +import com.cloud.configuration.ConfigurationManagerImpl; import com.cloud.configuration.ZoneConfig; import com.cloud.dc.DataCenter; import com.cloud.dc.DataCenter.NetworkType; @@ -225,7 +226,6 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy private int _capacityPerProxy = ConsoleProxyManager.DEFAULT_PROXY_CAPACITY; private int _standbyCapacity = ConsoleProxyManager.DEFAULT_STANDBY_CAPACITY; - private boolean _useLvm; private boolean _useStorageVm; private boolean _disableRpFilter = false; private String _instance; @@ -716,13 +716,27 @@ protected Map createProxyInstance(long dataCenterId, VMTemplateV networks.put(_networkMgr.setupNetwork(systemAcct, offering, plan, null, null, false).get(0), new ArrayList()); } + ServiceOfferingVO serviceOffering = _serviceOffering; + if (serviceOffering == null) { + String offeringName = ServiceOffering.consoleProxyDefaultOffUniqueName; + Boolean useLocalStorage = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dataCenterId); + if (useLocalStorage != null && useLocalStorage.booleanValue()) { + offeringName += "-Local"; + } + serviceOffering = _offeringDao.findByName(offeringName); + if (serviceOffering == null) { + String message = "System service offering " + offeringName + " not found"; + s_logger.error(message); + throw new CloudRuntimeException(message); + } + } ConsoleProxyVO proxy = - new ConsoleProxyVO(id, _serviceOffering.getId(), name, template.getId(), template.getHypervisorType(), template.getGuestOSId(), dataCenterId, - systemAcct.getDomainId(), systemAcct.getId(), _accountMgr.getSystemUser().getId(), 0, _serviceOffering.getOfferHA()); + new ConsoleProxyVO(id, serviceOffering.getId(), name, template.getId(), template.getHypervisorType(), template.getGuestOSId(), dataCenterId, + systemAcct.getDomainId(), systemAcct.getId(), _accountMgr.getSystemUser().getId(), 0, serviceOffering.getOfferHA()); proxy.setDynamicallyScalable(template.isDynamicallyScalable()); proxy = _consoleProxyDao.persist(proxy); try { - _itMgr.allocate(name, template, _serviceOffering, networks, plan, null); + _itMgr.allocate(name, template, serviceOffering, networks, plan, null); } catch (InsufficientCapacityException e) { s_logger.warn("InsufficientCapacity", e); throw new CloudRuntimeException("Insufficient capacity exception", e); @@ -951,7 +965,12 @@ public boolean isZoneReady(Map zoneHostInfoMap, long dataCen TemplateDataStoreVO templateHostRef = _vmTemplateStoreDao.findByTemplateZoneDownloadStatus(template.getId(), dataCenterId, Status.DOWNLOADED); if (templateHostRef != null) { - List> l = _consoleProxyDao.getDatacenterStoragePoolHostInfo(dataCenterId, _useLvm); + boolean useLocalStorage = false; + Boolean useLocal = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dataCenterId); + if (useLocal != null) { + useLocalStorage = useLocal.booleanValue(); + } + List> l = _consoleProxyDao.getDatacenterStoragePoolHostInfo(dataCenterId, useLocalStorage); if (l != null && l.size() > 0 && l.get(0).second().intValue() > 0) { return true; } else { @@ -1208,11 +1227,6 @@ public boolean configure(String name, Map params) throws Configu _disableRpFilter = true; } - value = configs.get(DataCenter.SystemVMUseLocalStorageCK); - if (value != null && value.equalsIgnoreCase("true")) { - _useLvm = true; - } - value = configs.get("secondary.storage.vm"); if (value != null && value.equalsIgnoreCase("true")) { _useStorageVm = true; @@ -1238,8 +1252,6 @@ public boolean configure(String name, Map params) throws Configu _itMgr.registerGuru(VirtualMachine.Type.ConsoleProxy, this); - boolean useLocalStorage = Boolean.parseBoolean(configs.get(DataCenter.SystemVMUseLocalStorageCK)); - //check if there is a default service offering configured String cpvmSrvcOffIdStr = configs.get(Config.ConsoleProxyServiceOffering.key()); if (cpvmSrvcOffIdStr != null) { @@ -1259,15 +1271,11 @@ public boolean configure(String name, Map params) throws Configu if (_serviceOffering == null || !_serviceOffering.getSystemUse()) { int ramSize = NumbersUtil.parseInt(_configDao.getValue("console.ram.size"), DEFAULT_PROXY_VM_RAMSIZE); int cpuFreq = NumbersUtil.parseInt(_configDao.getValue("console.cpu.mhz"), DEFAULT_PROXY_VM_CPUMHZ); - _serviceOffering = - new ServiceOfferingVO("System Offering For Console Proxy", 1, ramSize, cpuFreq, 0, 0, false, null, - Storage.ProvisioningType.THIN, useLocalStorage, true, null, true, - VirtualMachine.Type.ConsoleProxy, true); - _serviceOffering.setUniqueName(ServiceOffering.consoleProxyDefaultOffUniqueName); - _serviceOffering = _offeringDao.persistSystemServiceOffering(_serviceOffering); - + List offerings = _offeringDao.createSystemServiceOfferings("System Offering For Console Proxy", + ServiceOffering.consoleProxyDefaultOffUniqueName, 1, ramSize, cpuFreq, 0, 0, false, null, + Storage.ProvisioningType.THIN, true, null, true, VirtualMachine.Type.ConsoleProxy, true); // this can sometimes happen, if DB is manually or programmatically manipulated - if (_serviceOffering == null) { + if (offerings == null || offerings.size() < 2) { String msg = "Data integrity problem : System Offering For Console Proxy has been removed?"; s_logger.error(msg); throw new ConfigurationException(msg); diff --git a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java index 3a7173b95b5f..57abb9204c4a 100644 --- a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java +++ b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java @@ -32,8 +32,8 @@ import javax.naming.ConfigurationException; import com.cloud.utils.fsm.StateMachine2; -import org.apache.log4j.Logger; +import org.apache.log4j.Logger; import org.apache.cloudstack.affinity.AffinityGroupProcessor; import org.apache.cloudstack.affinity.AffinityGroupService; import org.apache.cloudstack.affinity.AffinityGroupVMMapVO; @@ -46,8 +46,6 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; -import org.apache.cloudstack.framework.config.ConfigKey; -import org.apache.cloudstack.framework.config.Configurable; import org.apache.cloudstack.framework.messagebus.MessageBus; import org.apache.cloudstack.framework.messagebus.MessageSubscriber; import org.apache.cloudstack.managed.context.ManagedContextTimerTask; @@ -67,6 +65,7 @@ import com.cloud.capacity.CapacityManager; import com.cloud.capacity.dao.CapacityDao; import com.cloud.configuration.Config; +import com.cloud.configuration.ConfigurationManagerImpl; import com.cloud.dc.ClusterDetailsDao; import com.cloud.dc.ClusterDetailsVO; import com.cloud.dc.ClusterVO; @@ -134,7 +133,7 @@ @Local(value = {DeploymentPlanningManager.class}) public class DeploymentPlanningManagerImpl extends ManagerBase implements DeploymentPlanningManager, Manager, Listener, -StateListener, Configurable { +StateListener { private static final Logger s_logger = Logger.getLogger(DeploymentPlanningManagerImpl.class); @Inject @@ -762,16 +761,6 @@ public Boolean doInTransaction(TransactionStatus status) { return false; } - @Override - public String getConfigComponentName() { - return DeploymentPlanningManagerImpl.class.getSimpleName(); - } - - @Override - public ConfigKey[] getConfigKeys() { - return new ConfigKey[] {DataCenter.UseSystemVMLocalStorage}; - } - class HostReservationReleaseChecker extends ManagedContextTimerTask { @Override protected void runInContext() { @@ -1301,20 +1290,11 @@ protected Pair>, List> findSuitablePoolsFo boolean useLocalStorage = false; if (vmProfile.getType() != VirtualMachine.Type.User) { DataCenterVO zone = _dcDao.findById(plan.getDataCenterId()); - // It should not happen to have a "null" zone here. There can be NO instance if there is NO zone, - // so this part of the code would never be reached if no zone has been created. - // Added the check and the comment just to make it clear. - boolean zoneUsesLocalStorage = zone != null ? zone.isLocalStorageEnabled() : false; - boolean ssvmUseLocalStorage = DataCenter.UseSystemVMLocalStorage.value(); - if (zone != null) { - ssvmUseLocalStorage = DataCenter.UseSystemVMLocalStorage.valueIn(plan.getDataCenterId()); - } - s_logger.debug("Checking if we need local storage for systemvms is needed for zone id=" + plan.getDataCenterId() + " with system.vm.use.local.storage=" + ssvmUseLocalStorage); - // Local storage is used for the NON User VMs if, and only if, the Zone is marked to use local storage AND - // the global settings (ssvmUseLocalStorage) is set to true. Otherwise, the global settings won't be applied. - if (ssvmUseLocalStorage && zoneUsesLocalStorage) { - useLocalStorage = true; - s_logger.debug("SystemVMs will use local storage for zone id=" + plan.getDataCenterId()); + assert (zone != null) : "Invalid zone in deployment plan"; + Boolean useLocalStorageForSystemVM = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(zone.getId()); + if (useLocalStorageForSystemVM != null) { + useLocalStorage = useLocalStorageForSystemVM.booleanValue(); + s_logger.debug("System VMs will use " + (useLocalStorage ? "local" : "shared") + " storage for zone id=" + plan.getDataCenterId()); } } else { useLocalStorage = diskOffering.getUseLocalStorage(); diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index c7e0c2951fbd..2a518e46e61c 100644 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -631,12 +631,15 @@ public boolean configure(final String name, final Map params) th _agentMgr.registerForHostEvents(new SshKeysDistriMonitor(_agentMgr, _hostDao, _configDao), true, false, false); - final boolean useLocalStorage = Boolean.parseBoolean(configs.get(DataCenter.SystemVMUseLocalStorageCK)); - ServiceOfferingVO offering = new ServiceOfferingVO("System Offering For Software Router", 1, _routerRamSize, _routerCpuMHz, null, null, true, null, ProvisioningType.THIN, - useLocalStorage, true, null, true, VirtualMachine.Type.DomainRouter, true); - offering.setUniqueName(ServiceOffering.routerDefaultOffUniqueName); - offering = _serviceOfferingDao.persistSystemServiceOffering(offering); - _routerDeploymentManagerBuilder.setOfferingId(offering.getId()); + List offerings = _serviceOfferingDao.createSystemServiceOfferings("System Offering For Software Router", + ServiceOffering.routerDefaultOffUniqueName, 1, _routerRamSize, _routerCpuMHz, null, + null, true, null, ProvisioningType.THIN, true, null, true, VirtualMachine.Type.DomainRouter, true); + // this can sometimes happen, if DB is manually or programmatically manipulated + if (offerings == null || offerings.size() < 2) { + final String msg = "Data integrity problem : System Offering For Software router VM has been removed?"; + s_logger.error(msg); + throw new ConfigurationException(msg); + } NetworkHelperImpl.setSystemAccount(_accountMgr.getSystemAccount()); diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index f31095b68b80..2a38de3d539a 100644 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -42,6 +42,7 @@ import javax.naming.ConfigurationException; import com.cloud.hypervisor.Hypervisor; + import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import org.apache.cloudstack.api.command.admin.storage.CancelPrimaryStorageMaintenanceCmd; @@ -111,6 +112,7 @@ import com.cloud.cluster.ManagementServerHost; import com.cloud.configuration.Config; import com.cloud.configuration.ConfigurationManager; +import com.cloud.configuration.ConfigurationManagerImpl; import com.cloud.configuration.Resource.ResourceType; import com.cloud.dc.ClusterVO; import com.cloud.dc.DataCenterVO; @@ -544,9 +546,16 @@ public boolean stop() { @DB @Override public DataStore createLocalStorage(Host host, StoragePoolInfo pInfo) throws ConnectionException { - DataCenterVO dc = _dcDao.findById(host.getDataCenterId()); - if (dc == null || !dc.isLocalStorageEnabled()) { + if (dc == null) { + return null; + } + boolean useLocalStorageForSystemVM = false; + Boolean isLocal = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dc.getId()); + if (isLocal != null) { + useLocalStorageForSystemVM = isLocal.booleanValue(); + } + if (!(dc.isLocalStorageEnabled() || useLocalStorageForSystemVM)) { return null; } DataStore store; diff --git a/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinition.java b/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinition.java index 5ef20703146c..569200c93c3f 100644 --- a/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinition.java +++ b/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinition.java @@ -23,6 +23,7 @@ import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; import org.apache.log4j.Logger; +import com.cloud.configuration.ConfigurationManagerImpl; import com.cloud.dc.DataCenter.NetworkType; import com.cloud.dc.HostPodVO; import com.cloud.dc.Pod; @@ -52,7 +53,10 @@ import com.cloud.network.router.NetworkHelper; import com.cloud.network.router.VirtualRouter.Role; import com.cloud.network.vpc.Vpc; +import com.cloud.offering.ServiceOffering; import com.cloud.offerings.dao.NetworkOfferingDao; +import com.cloud.service.ServiceOfferingVO; +import com.cloud.service.dao.ServiceOfferingDao; import com.cloud.user.Account; import com.cloud.user.AccountManager; import com.cloud.utils.db.DB; @@ -80,6 +84,7 @@ public class RouterDeploymentDefinition { protected NetworkModel networkModel; protected VirtualRouterProviderDao vrProviderDao; protected NetworkOfferingDao networkOfferingDao; + protected ServiceOfferingDao serviceOfferingDao; protected IpAddressManager ipAddrMgr; protected VMInstanceDao vmDao; protected HostPodDao podDao; @@ -354,10 +359,23 @@ protected void findSourceNatIP() throws InsufficientAddressCapacityException, Co } } + protected void findDefaultServiceOfferingId() { + String offeringName = ServiceOffering.routerDefaultOffUniqueName; + Boolean useLocalStorage = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId()); + if (useLocalStorage != null && useLocalStorage.booleanValue()) { + offeringName += "-Local"; + } + ServiceOfferingVO serviceOffering = serviceOfferingDao.findByName(offeringName); + if (serviceOffering == null) { + throw new CloudRuntimeException("System service offering " + offeringName + " not found"); + } + serviceOfferingId = serviceOffering.getId(); + } + protected void findServiceOfferingId() { - final Long networkOfferingId = networkOfferingDao.findById(guestNetwork.getNetworkOfferingId()).getServiceOfferingId(); - if (networkOfferingId != null) { - serviceOfferingId = networkOfferingId; + serviceOfferingId = networkOfferingDao.findById(guestNetwork.getNetworkOfferingId()).getServiceOfferingId(); + if (serviceOfferingId == null) { + findDefaultServiceOfferingId(); } } diff --git a/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinitionBuilder.java b/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinitionBuilder.java index 33ed9d093a1e..3ba4fad77de8 100644 --- a/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinitionBuilder.java +++ b/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinitionBuilder.java @@ -45,6 +45,7 @@ import com.cloud.network.vpc.dao.VpcDao; import com.cloud.network.vpc.dao.VpcOfferingDao; import com.cloud.offerings.dao.NetworkOfferingDao; +import com.cloud.service.dao.ServiceOfferingDao; import com.cloud.user.Account; import com.cloud.user.AccountManager; import com.cloud.vm.DomainRouterVO; @@ -68,6 +69,8 @@ public class RouterDeploymentDefinitionBuilder { @Inject private NetworkOfferingDao networkOfferingDao; @Inject + private ServiceOfferingDao serviceOfferingDao; + @Inject private IpAddressManager ipAddrMgr; @Inject private VMInstanceDao vmDao; @@ -120,6 +123,7 @@ protected RouterDeploymentDefinition injectDependencies( routerDeploymentDefinition.networkModel = networkModel; routerDeploymentDefinition.vrProviderDao = vrProviderDao; routerDeploymentDefinition.networkOfferingDao = networkOfferingDao; + routerDeploymentDefinition.serviceOfferingDao = serviceOfferingDao; routerDeploymentDefinition.ipAddrMgr = ipAddrMgr; routerDeploymentDefinition.vmDao = vmDao; routerDeploymentDefinition.podDao = podDao; diff --git a/server/src/org/cloud/network/router/deployment/VpcRouterDeploymentDefinition.java b/server/src/org/cloud/network/router/deployment/VpcRouterDeploymentDefinition.java index 5124195d04c7..26f2379804ef 100644 --- a/server/src/org/cloud/network/router/deployment/VpcRouterDeploymentDefinition.java +++ b/server/src/org/cloud/network/router/deployment/VpcRouterDeploymentDefinition.java @@ -156,9 +156,9 @@ protected void findVirtualProvider() { @Override protected void findServiceOfferingId() { - final Long vpcOfferingId = vpcOffDao.findById(vpc.getVpcOfferingId()).getServiceOfferingId(); - if (vpcOfferingId != null) { - serviceOfferingId = vpcOfferingId; + serviceOfferingId = vpcOffDao.findById(vpc.getVpcOfferingId()).getServiceOfferingId(); + if (serviceOfferingId == null) { + findDefaultServiceOfferingId(); } } diff --git a/server/test/com/cloud/network/element/VirtualRouterElementTest.java b/server/test/com/cloud/network/element/VirtualRouterElementTest.java index f139852436d9..659277824ea3 100644 --- a/server/test/com/cloud/network/element/VirtualRouterElementTest.java +++ b/server/test/com/cloud/network/element/VirtualRouterElementTest.java @@ -33,6 +33,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; +import org.mockito.Matchers; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; @@ -169,7 +170,7 @@ public class VirtualRouterElementTest { private RouterDeploymentDefinitionBuilder routerDeploymentDefinitionBuilder; @InjectMocks - private VpcVirtualNetworkApplianceManagerImpl _routerMgr ; + private VpcVirtualNetworkApplianceManagerImpl _routerMgr; @InjectMocks private VirtualRouterElement virtualRouterElement; @@ -210,7 +211,7 @@ public void testImplementInAdvancedZoneOnXenServer() throws Exception { public void testPrepare() { virtualRouterElement._routerMgr = _routerMgr; virtualRouterElement.routerDeploymentDefinitionBuilder = routerDeploymentDefinitionBuilder; - mockDAOs(testNetwork,testOffering); + mockDAOs(testNetwork, testOffering); mockMgrs(); boolean done = false; @@ -276,6 +277,7 @@ private void mockDAOs(final NetworkVO network, final NetworkOfferingVO offering) VirtualMachine.Type.DomainRouter, /* defaultUse */ false); when(_serviceOfferingDao.findById(0L)).thenReturn(svcoff); + when(_serviceOfferingDao.findByName(Matchers.anyString())).thenReturn(svcoff); final DomainRouterVO router = new DomainRouterVO(/* id */ 1L, /* serviceOfferingId */ 1L, /* elementId */ 0L, diff --git a/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTest.java b/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTest.java index abd80d75eb41..b266f880c1ec 100644 --- a/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTest.java +++ b/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTest.java @@ -38,6 +38,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.Matchers; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; @@ -635,7 +636,7 @@ public void testFindSourceNatIPNonPublicNw() throws InsufficientAddressCapacityE } @Test - public void testFindOfferingIdReceivingNewOne() { + public void testFindOfferingIdFromNetwork() { // Prepare deployment.serviceOfferingId = 1L; when(mockNw.getNetworkOfferingId()).thenReturn(OFFERING_ID); @@ -646,24 +647,26 @@ public void testFindOfferingIdReceivingNewOne() { deployment.findServiceOfferingId(); // Assert - assertEquals("Given that no Offering was found, the previous Offering Id should be kept", + assertEquals("Service offering id not matching the one associated with network offering", OFFERING_ID, deployment.serviceOfferingId.longValue()); } @Test - public void testFindOfferingIdReceivingKeepingPrevious() { + public void testFindOfferingIdDefault() { // Prepare deployment.serviceOfferingId = 1L; when(mockNw.getNetworkOfferingId()).thenReturn(OFFERING_ID); when(mockNetworkOfferingDao.findById(OFFERING_ID)).thenReturn(mockNwOfferingVO); when(mockNwOfferingVO.getServiceOfferingId()).thenReturn(null); + when(mockServiceOfferingDao.findByName(Matchers.anyString())).thenReturn(mockSvcOfferingVO); + when(mockSvcOfferingVO.getId()).thenReturn(DEFAULT_OFFERING_ID); // Execute deployment.findServiceOfferingId(); // Assert - assertEquals("Found Offering Id didn't replace previous one", - 1L, deployment.serviceOfferingId.longValue()); + assertEquals("Since there is no service offering associated with network offering, offering id should have matched default one", + DEFAULT_OFFERING_ID, deployment.serviceOfferingId.longValue()); } @Test diff --git a/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTestBase.java b/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTestBase.java index 0978ac96ea97..4225083ca2bd 100644 --- a/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTestBase.java +++ b/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTestBase.java @@ -43,6 +43,8 @@ import com.cloud.network.router.VpcNetworkHelperImpl; import com.cloud.offerings.NetworkOfferingVO; import com.cloud.offerings.dao.NetworkOfferingDao; +import com.cloud.service.ServiceOfferingVO; +import com.cloud.service.dao.ServiceOfferingDao; import com.cloud.user.Account; import com.cloud.user.AccountManager; import com.cloud.vm.VirtualMachineProfile.Param; @@ -57,6 +59,7 @@ public class RouterDeploymentDefinitionTestBase { protected static final String ONLY_THE_PROVIDED_AS_DEFAULT_DESTINATION_WAS_EXPECTED = "Only the provided as default destination was expected"; protected static final long OFFERING_ID = 16L; + protected static final long DEFAULT_OFFERING_ID = 17L; protected static final Long DATA_CENTER_ID = 100l; protected static final Long NW_ID_1 = 101l; protected static final Long NW_ID_2= 102l; @@ -92,6 +95,8 @@ public class RouterDeploymentDefinitionTestBase { @Mock protected NetworkOfferingDao mockNetworkOfferingDao; @Mock + protected ServiceOfferingDao mockServiceOfferingDao; + @Mock protected AccountManager mockAccountMgr; // Instance specific parameters to use during build @@ -112,6 +117,8 @@ public class RouterDeploymentDefinitionTestBase { @Mock NetworkOfferingVO mockNwOfferingVO; @Mock + ServiceOfferingVO mockSvcOfferingVO; + @Mock protected Account mockOwner; diff --git a/server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java b/server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java index 4ef35931926a..5a34ebf037ee 100644 --- a/server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java +++ b/server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java @@ -31,6 +31,7 @@ import org.junit.Before; import org.junit.Test; +import org.mockito.Matchers; import org.mockito.Mock; import com.cloud.deploy.DeployDestination; @@ -178,23 +179,24 @@ public void testGenerateDeploymentPlan() { } @Test - public void testFindOfferingIdLeavingPrevious() { + public void testFindOfferingIdDefault() { // Prepare - final Long initialOfferingId = deployment.serviceOfferingId; final VpcOfferingVO vpcOffering = mock(VpcOfferingVO.class); when(mockVpcOffDao.findById(VPC_OFFERING_ID)).thenReturn(vpcOffering); when(vpcOffering.getServiceOfferingId()).thenReturn(null); + when(mockServiceOfferingDao.findByName(Matchers.anyString())).thenReturn(mockSvcOfferingVO); + when(mockSvcOfferingVO.getId()).thenReturn(DEFAULT_OFFERING_ID); // Execute deployment.findServiceOfferingId(); // Assert - assertEquals("Offering Id shouldn't have been updated", - initialOfferingId, deployment.serviceOfferingId); + assertEquals("Since there is no service offering associated with VPC offering, offering id should have matched default one", + DEFAULT_OFFERING_ID, deployment.serviceOfferingId.longValue()); } @Test - public void testFindOfferingIdSettingNewOne() { + public void testFindOfferingIdFromVPC() { // Prepare final VpcOfferingVO vpcOffering = mock(VpcOfferingVO.class); when(mockVpcOffDao.findById(VPC_OFFERING_ID)).thenReturn(vpcOffering); @@ -204,7 +206,7 @@ public void testFindOfferingIdSettingNewOne() { deployment.findServiceOfferingId(); // Assert - assertEquals("Offering Id should have been updated", + assertEquals("Service offering id not matching the one associated with VPC offering", VPC_OFFERING_ID, deployment.serviceOfferingId.longValue()); } diff --git a/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java b/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java index 4dc6dbbfe3fb..445852d33f08 100644 --- a/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java +++ b/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java @@ -32,7 +32,6 @@ import javax.naming.ConfigurationException; import org.apache.cloudstack.config.ApiServiceConfiguration; - import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; @@ -64,6 +63,7 @@ import com.cloud.capacity.dao.CapacityDao; import com.cloud.cluster.ClusterManager; import com.cloud.configuration.Config; +import com.cloud.configuration.ConfigurationManagerImpl; import com.cloud.configuration.ZoneConfig; import com.cloud.consoleproxy.ConsoleProxyManager; import com.cloud.dc.DataCenter; @@ -242,7 +242,6 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar private int _secStorageVmMtuSize; private String _instance; - private boolean _useLocalStorage; private boolean _useSSlCopy; private String _httpProxy; private String _allowedInternalSites; @@ -577,13 +576,27 @@ protected Map createSecStorageVmInstance(long dataCenterId, Seco throw new CloudRuntimeException("Not able to find the System templates or not downloaded in zone " + dataCenterId); } + ServiceOfferingVO serviceOffering = _serviceOffering; + if (serviceOffering == null) { + String offeringName = ServiceOffering.ssvmDefaultOffUniqueName; + Boolean useLocalStorage = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dataCenterId); + if (useLocalStorage != null && useLocalStorage.booleanValue()) { + offeringName += "-Local"; + } + serviceOffering = _offeringDao.findByName(offeringName); + if (serviceOffering == null) { + String message = "System service offering " + offeringName + " not found"; + s_logger.error(message); + throw new CloudRuntimeException(message); + } + } SecondaryStorageVmVO secStorageVm = - new SecondaryStorageVmVO(id, _serviceOffering.getId(), name, template.getId(), template.getHypervisorType(), template.getGuestOSId(), dataCenterId, - systemAcct.getDomainId(), systemAcct.getId(), _accountMgr.getSystemUser().getId(), role, _serviceOffering.getOfferHA()); + new SecondaryStorageVmVO(id, serviceOffering.getId(), name, template.getId(), template.getHypervisorType(), template.getGuestOSId(), dataCenterId, + systemAcct.getDomainId(), systemAcct.getId(), _accountMgr.getSystemUser().getId(), role, serviceOffering.getOfferHA()); secStorageVm.setDynamicallyScalable(template.isDynamicallyScalable()); secStorageVm = _secStorageVmDao.persist(secStorageVm); try { - _itMgr.allocate(name, template, _serviceOffering, networks, plan, null); + _itMgr.allocate(name, template, serviceOffering, networks, plan, null); secStorageVm = _secStorageVmDao.findById(secStorageVm.getId()); } catch (InsufficientCapacityException e) { s_logger.warn("InsufficientCapacity", e); @@ -763,14 +776,19 @@ public boolean isZoneReady(Map zoneHostInfoMap, long dataCen return false; } - List> l = _storagePoolHostDao.getDatacenterStoragePoolHostInfo(dataCenterId, !_useLocalStorage); + boolean useLocalStorage = false; + Boolean useLocal = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dataCenterId); + if (useLocal != null) { + useLocalStorage = useLocal.booleanValue(); + } + List> l = _storagePoolHostDao.getDatacenterStoragePoolHostInfo(dataCenterId, !useLocalStorage); if (l != null && l.size() > 0 && l.get(0).second().intValue() > 0) { return true; } else { if (s_logger.isDebugEnabled()) { s_logger.debug("Primary storage is not ready, wait until it is ready to launch secondary storage vm. dcId: " + dataCenterId + - " system.vm.use.local.storage: " + _useLocalStorage + - "If you want to use local storage to start ssvm, need to set system.vm.use.local.storage to true"); + ", " + ConfigurationManagerImpl.SystemVMUseLocalStorage.key() + ": " + useLocalStorage + ". " + + "If you want to use local storage to start SSVM, need to set " + ConfigurationManagerImpl.SystemVMUseLocalStorage.key() + " to true"); } } @@ -872,18 +890,14 @@ public boolean configure(String name, Map params) throws Configu } } - if(_serviceOffering == null || !_serviceOffering.getSystemUse()){ + if (_serviceOffering == null || !_serviceOffering.getSystemUse()) { int ramSize = NumbersUtil.parseInt(_configDao.getValue("ssvm.ram.size"), DEFAULT_SS_VM_RAMSIZE); int cpuFreq = NumbersUtil.parseInt(_configDao.getValue("ssvm.cpu.mhz"), DEFAULT_SS_VM_CPUMHZ); - _useLocalStorage = Boolean.parseBoolean(configs.get(DataCenter.SystemVMUseLocalStorageCK)); - _serviceOffering = - new ServiceOfferingVO("System Offering For Secondary Storage VM", 1, ramSize, cpuFreq, null, null, false, null, - Storage.ProvisioningType.THIN, _useLocalStorage, true, null, true, VirtualMachine.Type.SecondaryStorageVm, true); - _serviceOffering.setUniqueName(ServiceOffering.ssvmDefaultOffUniqueName); - _serviceOffering = _offeringDao.persistSystemServiceOffering(_serviceOffering); - + List offerings = _offeringDao.createSystemServiceOfferings("System Offering For Secondary Storage VM", + ServiceOffering.ssvmDefaultOffUniqueName, 1, ramSize, cpuFreq, null, null, false, null, + Storage.ProvisioningType.THIN, true, null, true, VirtualMachine.Type.SecondaryStorageVm, true); // this can sometimes happen, if DB is manually or programmatically manipulated - if (_serviceOffering == null) { + if (offerings == null || offerings.size() < 2) { String msg = "Data integrity problem : System Offering For Secondary Storage VM has been removed?"; s_logger.error(msg); throw new ConfigurationException(msg); From 256e227cd5be63186a989e2c99ded0da5e7dea71 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Wed, 13 May 2015 14:10:14 +0200 Subject: [PATCH 052/175] schema: fix foreign key checks for 3.0.7 to 4.1.0 upgrade path Without this upgrades from 3.0.7 version fails. Signed-off-by: Rohit Yadav (cherry picked from commit a0cff4ca48bbd2140c35b586d42d997ad5f167b2) Signed-off-by: Rohit Yadav --- setup/db/db/schema-307to410.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup/db/db/schema-307to410.sql b/setup/db/db/schema-307to410.sql index 7feb53eb16e5..5624f0010e2e 100644 --- a/setup/db/db/schema-307to410.sql +++ b/setup/db/db/schema-307to410.sql @@ -20,6 +20,7 @@ --; +SET foreign_key_checks = 0; -- DB upgrade steps from 302-40 CREATE TABLE `cloud`.`external_nicira_nvp_devices` ( @@ -1508,7 +1509,6 @@ CREATE TABLE `cloud`.`ucs_manager` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -SET foreign_key_checks = 1; UPDATE `cloud`.`configuration` SET value='KVM,XenServer,VMware,Ovm' WHERE name='hypervisor.list'; @@ -1585,3 +1585,5 @@ ALTER TABLE `cloud_usage`.`cloud_usage` CHANGE COLUMN `virtual_size` `virtual_si ALTER TABLE `cloud`.`network_offerings` CHANGE COLUMN `concurrent_connections` `concurrent_connections1` int(10) unsigned COMMENT 'Load Balancer(haproxy) maximum number of concurrent connections(global max)'; ALTER TABLE `cloud`.`volumes` CHANGE COLUMN `iso_id` `iso_id1` bigint(20) unsigned COMMENT 'The id of the iso from which the volume was created'; + +SET foreign_key_checks = 1; From 7451f13f911e0044d0981046bcde31a18f77db83 Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Wed, 13 May 2015 01:06:13 +0200 Subject: [PATCH 053/175] debian: allow tomcat7 as optional dependency This closes #247 Signed-off-by: Rohit Yadav --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/control b/debian/control index 2d2c125143fb..f6e9be0bde42 100644 --- a/debian/control +++ b/debian/control @@ -15,7 +15,7 @@ Description: A common package which contains files which are shared by several C Package: cloudstack-management Architecture: all -Depends: ${misc:Depends}, ${python:Depends}, cloudstack-common (= ${source:Version}), tomcat6, sudo, jsvc, python-mysqldb, libmysql-java, python-paramiko, augeas-tools, mysql-client, adduser +Depends: ${misc:Depends}, ${python:Depends}, cloudstack-common (= ${source:Version}), tomcat6 | tomcat7 | tomcat8, sudo, jsvc, python-mysqldb, libmysql-java, python-paramiko, augeas-tools, mysql-client, adduser Conflicts: cloud-server, cloud-client, cloud-client-ui Description: CloudStack server library The CloudStack management server From e8f8e0e3f23732559a2664b3b9573be8ef76f479 Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Wed, 13 May 2015 01:13:00 +0200 Subject: [PATCH 054/175] listPortForwardingRules: fix typo in doc Signed-off-by: Rohit Yadav This closes #248 --- .../api/command/user/firewall/ListPortForwardingRulesCmd.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/ListPortForwardingRulesCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/ListPortForwardingRulesCmd.java index cde2563f9ab2..5d448154c826 100644 --- a/api/src/org/apache/cloudstack/api/command/user/firewall/ListPortForwardingRulesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/ListPortForwardingRulesCmd.java @@ -57,7 +57,7 @@ public class ListPortForwardingRulesCmd extends BaseListTaggedResourcesCmd { @Parameter(name = ApiConstants.NETWORK_ID, type = CommandType.UUID, entityType = NetworkResponse.class, - description = "list port forwarding rules for ceratin network", + description = "list port forwarding rules for certain network", since = "4.3") private Long networkId; From ff0160c71e8e0f7a80c01d17b743df1a6e7b6e0e Mon Sep 17 00:00:00 2001 From: Koushik Das Date: Thu, 14 May 2015 17:30:19 +0530 Subject: [PATCH 055/175] CLOUDSTACK-8301: Enable configuring local storage use for system VMs at zone level Code cleanup, added helper method to get default system offering based on "system.vm.use.local.storage". --- .../com/cloud/service/dao/ServiceOfferingDao.java | 2 ++ .../cloud/service/dao/ServiceOfferingDaoImpl.java | 15 +++++++++++++++ .../cloud/network/lb/LoadBalanceRuleHandler.java | 12 +----------- .../lb/InternalLoadBalancerVMManagerImpl.java | 12 +----------- .../consoleproxy/ConsoleProxyManagerImpl.java | 12 +----------- .../deployment/RouterDeploymentDefinition.java | 10 +--------- .../RouterDeploymentDefinitionTest.java | 2 +- .../VpcRouterDeploymentDefinitionTest.java | 2 +- .../SecondaryStorageManagerImpl.java | 12 +----------- 9 files changed, 24 insertions(+), 55 deletions(-) diff --git a/engine/schema/src/com/cloud/service/dao/ServiceOfferingDao.java b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDao.java index 98dc3178de4f..aae61a120943 100644 --- a/engine/schema/src/com/cloud/service/dao/ServiceOfferingDao.java +++ b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDao.java @@ -55,4 +55,6 @@ List createSystemServiceOfferings(String name, String uniqueN boolean isDynamic(long serviceOfferingId); ServiceOfferingVO getcomputeOffering(ServiceOfferingVO serviceOffering, Map customParameters); + + ServiceOfferingVO findDefaultSystemOffering(String offeringName, Boolean useLocalStorage); } diff --git a/engine/schema/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java index a3ffbc1396df..4a5a8b5448bd 100644 --- a/engine/schema/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java +++ b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java @@ -276,4 +276,19 @@ public List createSystemServiceOfferings(String name, String return list; } + + @Override + public ServiceOfferingVO findDefaultSystemOffering(String offeringName, Boolean useLocalStorage) { + String name = offeringName; + if (useLocalStorage != null && useLocalStorage.booleanValue()) { + name += "-Local"; + } + ServiceOfferingVO serviceOffering = findByName(name); + if (serviceOffering == null) { + String message = "System service offering " + name + " not found"; + s_logger.error(message); + throw new CloudRuntimeException(message); + } + return serviceOffering; + } } diff --git a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/LoadBalanceRuleHandler.java b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/LoadBalanceRuleHandler.java index f2c4685280ad..e90af37809c5 100644 --- a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/LoadBalanceRuleHandler.java +++ b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/LoadBalanceRuleHandler.java @@ -282,17 +282,7 @@ private DomainRouterVO deployELBVm(Network guestNetwork, final DeployDestination userId = _userDao.listByAccount(owner.getAccountId()).get(0).getId(); } - String offeringName = ServiceOffering.elbVmDefaultOffUniqueName; - Boolean useLocalStorage = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId()); - if (useLocalStorage != null && useLocalStorage.booleanValue()) { - offeringName += "-Local"; - } - ServiceOfferingVO elasticLbVmOffering = _serviceOfferingDao.findByName(offeringName); - if (elasticLbVmOffering == null) { - String message = "System service offering " + offeringName + " not found"; - s_logger.error(message); - throw new CloudRuntimeException(message); - } + ServiceOfferingVO elasticLbVmOffering = _serviceOfferingDao.findDefaultSystemOffering(ServiceOffering.elbVmDefaultOffUniqueName, ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId())); elbVm = new DomainRouterVO(id, elasticLbVmOffering.getId(), vrProvider.getId(), VirtualMachineName.getSystemVmName(id, _instance, ELB_VM_NAME_PREFIX), template.getId(), template.getHypervisorType(), template.getGuestOSId(), owner.getDomainId(), owner.getId(), userId, false, RedundantState.UNKNOWN, elasticLbVmOffering.getOfferHA(), false, null); diff --git a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java index 818ad88b07ae..4bd852d19dbe 100644 --- a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java +++ b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java @@ -623,17 +623,7 @@ protected List findOrDeployInternalLbVm(final Network guestNetwo final LinkedHashMap> networks = createInternalLbVmNetworks(guestNetwork, plan, requestedGuestIp); long internalLbVmOfferingId = _internalLbVmOfferingId; if (internalLbVmOfferingId == 0L) { - String offeringName = ServiceOffering.internalLbVmDefaultOffUniqueName; - Boolean useLocalStorage = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId()); - if (useLocalStorage != null && useLocalStorage.booleanValue()) { - offeringName += "-Local"; - } - ServiceOfferingVO serviceOffering = _serviceOfferingDao.findByName(offeringName); - if (serviceOffering == null) { - String message = "System service offering " + offeringName + " not found"; - s_logger.error(message); - throw new CloudRuntimeException(message); - } + ServiceOfferingVO serviceOffering = _serviceOfferingDao.findDefaultSystemOffering(ServiceOffering.internalLbVmDefaultOffUniqueName, ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId())); internalLbVmOfferingId = serviceOffering.getId(); } //Pass startVm=false as we are holding the network lock that needs to be released at the end of vm allocation diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java index f8d7474cb224..476cc8e794f9 100644 --- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java +++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java @@ -718,17 +718,7 @@ protected Map createProxyInstance(long dataCenterId, VMTemplateV ServiceOfferingVO serviceOffering = _serviceOffering; if (serviceOffering == null) { - String offeringName = ServiceOffering.consoleProxyDefaultOffUniqueName; - Boolean useLocalStorage = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dataCenterId); - if (useLocalStorage != null && useLocalStorage.booleanValue()) { - offeringName += "-Local"; - } - serviceOffering = _offeringDao.findByName(offeringName); - if (serviceOffering == null) { - String message = "System service offering " + offeringName + " not found"; - s_logger.error(message); - throw new CloudRuntimeException(message); - } + serviceOffering = _offeringDao.findDefaultSystemOffering(ServiceOffering.consoleProxyDefaultOffUniqueName, ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dataCenterId)); } ConsoleProxyVO proxy = new ConsoleProxyVO(id, serviceOffering.getId(), name, template.getId(), template.getHypervisorType(), template.getGuestOSId(), dataCenterId, diff --git a/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinition.java b/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinition.java index 569200c93c3f..2d04a7e633f1 100644 --- a/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinition.java +++ b/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinition.java @@ -360,15 +360,7 @@ protected void findSourceNatIP() throws InsufficientAddressCapacityException, Co } protected void findDefaultServiceOfferingId() { - String offeringName = ServiceOffering.routerDefaultOffUniqueName; - Boolean useLocalStorage = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId()); - if (useLocalStorage != null && useLocalStorage.booleanValue()) { - offeringName += "-Local"; - } - ServiceOfferingVO serviceOffering = serviceOfferingDao.findByName(offeringName); - if (serviceOffering == null) { - throw new CloudRuntimeException("System service offering " + offeringName + " not found"); - } + ServiceOfferingVO serviceOffering = serviceOfferingDao.findDefaultSystemOffering(ServiceOffering.routerDefaultOffUniqueName, ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId())); serviceOfferingId = serviceOffering.getId(); } diff --git a/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTest.java b/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTest.java index b266f880c1ec..1570a2e15a94 100644 --- a/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTest.java +++ b/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTest.java @@ -658,7 +658,7 @@ public void testFindOfferingIdDefault() { when(mockNw.getNetworkOfferingId()).thenReturn(OFFERING_ID); when(mockNetworkOfferingDao.findById(OFFERING_ID)).thenReturn(mockNwOfferingVO); when(mockNwOfferingVO.getServiceOfferingId()).thenReturn(null); - when(mockServiceOfferingDao.findByName(Matchers.anyString())).thenReturn(mockSvcOfferingVO); + when(mockServiceOfferingDao.findDefaultSystemOffering(Matchers.anyString(), Matchers.anyBoolean())).thenReturn(mockSvcOfferingVO); when(mockSvcOfferingVO.getId()).thenReturn(DEFAULT_OFFERING_ID); // Execute diff --git a/server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java b/server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java index 5a34ebf037ee..13c20ae7e507 100644 --- a/server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java +++ b/server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java @@ -184,7 +184,7 @@ public void testFindOfferingIdDefault() { final VpcOfferingVO vpcOffering = mock(VpcOfferingVO.class); when(mockVpcOffDao.findById(VPC_OFFERING_ID)).thenReturn(vpcOffering); when(vpcOffering.getServiceOfferingId()).thenReturn(null); - when(mockServiceOfferingDao.findByName(Matchers.anyString())).thenReturn(mockSvcOfferingVO); + when(mockServiceOfferingDao.findDefaultSystemOffering(Matchers.anyString(), Matchers.anyBoolean())).thenReturn(mockSvcOfferingVO); when(mockSvcOfferingVO.getId()).thenReturn(DEFAULT_OFFERING_ID); // Execute diff --git a/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java b/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java index 445852d33f08..453a4cbab0be 100644 --- a/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java +++ b/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java @@ -578,17 +578,7 @@ protected Map createSecStorageVmInstance(long dataCenterId, Seco ServiceOfferingVO serviceOffering = _serviceOffering; if (serviceOffering == null) { - String offeringName = ServiceOffering.ssvmDefaultOffUniqueName; - Boolean useLocalStorage = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dataCenterId); - if (useLocalStorage != null && useLocalStorage.booleanValue()) { - offeringName += "-Local"; - } - serviceOffering = _offeringDao.findByName(offeringName); - if (serviceOffering == null) { - String message = "System service offering " + offeringName + " not found"; - s_logger.error(message); - throw new CloudRuntimeException(message); - } + serviceOffering = _offeringDao.findDefaultSystemOffering(ServiceOffering.ssvmDefaultOffUniqueName, ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dataCenterId)); } SecondaryStorageVmVO secStorageVm = new SecondaryStorageVmVO(id, serviceOffering.getId(), name, template.getId(), template.getHypervisorType(), template.getGuestOSId(), dataCenterId, From e5cee452b917781e3b911d5fc0df9a9fd2a9bcbe Mon Sep 17 00:00:00 2001 From: nitt10prashant Date: Thu, 14 May 2015 17:02:23 +0530 Subject: [PATCH 056/175] CLOUDSTACK-8471:Automation for feature Enable configuring local storage use for system VMs at zone level Signed-off-by: Koushik Das This closes #253 --- .../test_zone_level_local_storage_setting.py | 734 ++++++++++++++++++ 1 file changed, 734 insertions(+) create mode 100644 test/integration/component/maint/test_zone_level_local_storage_setting.py diff --git a/test/integration/component/maint/test_zone_level_local_storage_setting.py b/test/integration/component/maint/test_zone_level_local_storage_setting.py new file mode 100644 index 000000000000..466f1f9fd42e --- /dev/null +++ b/test/integration/component/maint/test_zone_level_local_storage_setting.py @@ -0,0 +1,734 @@ +# 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. +""" +Test cases for zone level settings "system.vm.use.local.storage" +""" +# Import Local Modules +from marvin.cloudstackTestCase import * +from marvin.lib.utils import * +from marvin.lib.base import * +from marvin.lib.common import * +from marvin.codes import FAILED, PASS +from requests.exceptions import ConnectionError + +import time +from nose.plugins.attrib import attr +from ddt import ddt, data + + +def destroy_systemvm(self, type): + """ + Destroy system vms + #1-List system vms for current zone + #2-Destroy system vm + #3-Check if system vm came up after destroy + #4-check system vm storage type in disk offering + """ + list_response = list_ssvms( + self.apiclient, + systemvmtype=type, + zoneid=self.zone.id + ) + + self.assertEqual( + validateList(list_response)[0], + PASS, + "Check List ssvm response for %s" % + type) + + response = list_response[0] + self.debug("Destroying CPVM: %s" % response.id) + cmd = destroySystemVm.destroySystemVmCmd() + cmd.id = response.id + self.apiclient.destroySystemVm(cmd) + + timeout = self.testdata["timeout"] + while True: + time.sleep(self.testdata["sleep"]) + list_response = list_ssvms( + self.apiclient, + systemvmtype=type, + zoneid=self.zone.id + ) + if validateList(list_response)[0] == PASS: + if list_response[0].state == 'Running': + break + if timeout == 0: + raise Exception("List %s call failed!" % type) + timeout = timeout - 1 + + +def storage_check(self, type, value): + """test if system vms are using local or shared storage + #1-Get zone id from db using self.zone.id + #2-Get service offering id from vm_instance table for running system vms + #3-Get use_local_storage value from disk_offering table + #4-Verify storage type""" + query_zone_id = self.dbclient.execute( + "select id from data_center where uuid= '%s';" % self.zone.id + ) + query_so_id = self.dbclient.execute( + "select service_offering_id from vm_instance where type='%s'and " + "state='Running' and data_center_id= '%s';" % + (type, query_zone_id[0][0])) + + query_disk_offering = self.dbclient.execute( + "select use_local_storage from disk_offering where id= '%s';" % + query_so_id[0][0]) + + if value == 1: + self.assertEqual(query_disk_offering[0][0], + 1, + "system vm is not using local storage" + ) + elif value == 0: + self.assertEqual(query_disk_offering[0][0], + 0, + "system vm is not using shared storage" + ) + else: + # evil ValueError that doesn't tell you what the wrong value was + raise ValueError + + +def create_system_so(self, offering_type, storage_type): + """Create system offerings """ + self.testdata["service_offerings"]["issystem"] = "true" + self.testdata["service_offerings"]["systemvmtype"] = offering_type + self.testdata["service_offerings"]["storagetype"] = storage_type + + service_offering = ServiceOffering.create( + self.apiclient, + self.testdata["service_offerings"] + ) + + if service_offering is None: + raise Exception("service offering not created") + + list_service_response = list_service_offering( + self.apiclient, + id=service_offering.id, + issystem='true' + ) + self.assertEqual( + validateList(list_service_response)[0], + PASS, + "Check List srvice offering response for %s" % + type) + + self.debug( + "Created service offering with ID: %s" % + service_offering.id) + + self.assertEqual( + list_service_response[0].cpunumber, + self.testdata["service_offerings"]["cpunumber"], + "Check server id in createServiceOffering" + ) + self.assertEqual( + list_service_response[0].cpuspeed, + self.testdata["service_offerings"]["cpuspeed"], + "Check cpuspeed in createServiceOffering" + ) + self.assertEqual( + list_service_response[0].displaytext, + self.testdata["service_offerings"]["displaytext"], + "Check server displaytext in createServiceOfferings" + ) + self.assertEqual( + list_service_response[0].memory, + self.testdata["service_offerings"]["memory"], + "Check memory in createServiceOffering" + ) + self.assertEqual( + list_service_response[0].name, + self.testdata["service_offerings"]["name"], + "Check name in createServiceOffering" + ) + self.assertEqual( + list_service_response[0].storagetype, + self.testdata["service_offerings"]["storagetype"], + "Check storagetype in createServiceOffering" + ) + self._cleanup.append(service_offering) + return service_offering.id + + +def restart_ms(self): + """Restart MS + #1-ssh into m/c running MS + #2-restart ms + #3-verify the response + #4-loop unitl you get list_zone api answer """ + sshClient = SshClient( + self.mgtSvrDetails["mgtSvrIp"], + 22, + self.mgtSvrDetails["user"], + self.mgtSvrDetails["passwd"] + ) + command = "service cloudstack-management restart" + ms_restart_response = sshClient.execute(command) + self.assertEqual( + validateList(ms_restart_response)[0], + PASS, + "Check the MS restart response") + self.assertEqual( + ms_restart_response[0], + 'Stopping cloudstack-management:[ OK ]', + "MS i not stopped" + ) + self.assertEqual( + ms_restart_response[1], + 'Starting cloudstack-management: [ OK ]', + "MS not started" + ) + timeout = self.testdata["timeout"] + while True: + time.sleep(self.testdata["sleep"]) + try: + list_response = Zone.list( + self.apiclient + ) + if validateList(list_response)[0] == PASS: + break + except ConnectionError as e: + self.debug("list zone response is not available due to %s" % e) + + if timeout == 0: + raise Exception("Ms is not comming up !") + timeout = timeout - 1 + + +def update_global_settings(self, value, name, zoneid=None): + """Update Gloabal/zonelevel settings and verify + #1-Update configuration + #2-Restart ms if zone id is None""" + Configurations.update(self.apiclient, + name=name, + zoneid=zoneid, + value=value + ) + if zoneid is None: + restart_ms(self) + + list_conf = Configurations.list(self.apiclient, + name=name, + zoneid=zoneid) + + self.assertEqual( + validateList(list_conf)[0], + PASS, + "Check List configuration response for %s" % name) + + self.assertEqual( + str(list_conf[0].value), + str(value), + "Check if configuration values are equal" + ) + + +def str_to_bool(s): + """Converts str "True/False to Boolean TRUE/FALSE""" + if s == 'true': + return True + elif s == 'false': + return False + else: + # evil ValueError that doesn't tell you what the wrong value was + raise ValueError + + +@ddt +class TestSystemVmLocalStorage(cloudstackTestCase): + + @classmethod + def setUpClass(cls): + testClient = super(TestSystemVmLocalStorage, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.dbclient = cls.testClient.getDbConnection() + cls.mgtSvrDetails = cls.config.__dict__["mgtSvr"][0].__dict__ + cls.testdata = testClient.getParsedTestDataConfig() + # Get Zone, and template Domain + cls.domain = get_domain(cls.apiclient) + cls.zone = get_zone(cls.apiclient) + cls.testdata["mode"] = cls.zone.networktype + cls.hypervisor = testClient.getHypervisorInfo() + cls._cleanup = [] + + list_local_storage_pool = StoragePool.list( + cls.apiclient, + scope='HOST', + zoneid=cls.zone.id, + + ) + + if list_local_storage_pool is None: + + Configurations.update( + cls.apiclient, + value='true', + name='system.vm.use.local.storage', + zoneid=cls.zone.id + ) + + # Restart MS + sshClient = SshClient( + cls.mgtSvrDetails["mgtSvrIp"], + 22, + cls.mgtSvrDetails["user"], + cls.mgtSvrDetails["passwd"] + ) + command = "service cloudstack-management restart" + ms_restart_response = sshClient.execute(command) + + if validateList(ms_restart_response)[0] != PASS: + raise Exception("Check the MS restart response") + if ms_restart_response[ + 0] != 'Stopping cloudstack-management:[ OK ]': + raise Exception("MS i not stopped") + + if ms_restart_response[ + 1] != 'Starting cloudstack-management: [ OK ]': + raise Exception("MS not started") + + timeout = cls.testdata["timeout"] + while True: + # time.sleep(cls.testdata["sleep"]) + try: + list_response = Zone.list( + cls.apiclient + ) + if validateList(list_response)[0] == PASS: + break + except ConnectionError as e: + cls.debug( + "list zone response is not available due to %s" % + e) + + if timeout == 0: + raise Exception("Ms is not comming up !") + + time.sleep(cls.testdata["sleep"]) + timeout = timeout - 1 + + list_local_storage_pool = StoragePool.list( + cls.apiclient, + scope='HOST', + zoneid=cls.zone.id, + + ) + if list_local_storage_pool is None: + raise Exception("Could not discover local storage pool") + + try: + cls.account = Account.create(cls.apiclient, + cls.testdata["account"], + domainid=cls.domain.id + ) + cls._cleanup.append(cls.account) + + except Exception as e: + cls.tearDownClass() + raise e + + return + + @classmethod + def tearDownClass(cls): + try: + cleanup_resources(cls.apiclient, cls._cleanup) + except Exception as e: + raise Exception("Warning:Exception during cleanup: %s" % e) + + @attr(tags=["advanced", "basic"]) + @data( + 'consoleproxy', + 'secondarystoragevm', + 'domainrouter', + 'internalloadbalancervm') + def test_01_list_system_offerngs(self, value): + """List service offerings for systemvms and verify there should be two + (local and shared) SO for each system vm""" + + list_custom_so = ServiceOffering.list(self.apiclient, + issystem='true', + listall='true', + systemvmtype=value + ) + + self.assertEqual( + validateList(list_custom_so)[0], + PASS, + "Check List service offerings response for %s" % + value) + + local_custom_so = [] + for item in list_custom_so: + if(str(item.defaultuse) == 'True'): + local_custom_so.append(item.storagetype) + + self.assertEqual( + len(local_custom_so), + 2, + "Check default system offering for system vm type %s" % value) + if 'local' in local_custom_so and 'shared' in local_custom_so: + self.debug( + "there are exactly to Service offerings{share,local} are " + "there for system vm %s" % + value) + else: + raise Exception( + "check local and shared service offerings for %s" % + value) + + @attr(tags=["advanced", "basic"]) + @data('consoleproxy', 'secondarystoragevm') + def test_02_system_vm_storage(self, value): + """ Check if system vms are honouring zone level setting + system.vm.use.local.storage + 1-List zone level config + 2-update the zone level config with service offering uuid + 3-destroy system vms + 4-check used storage by system vms + """ + # 1 List zone level config + if value == "consoleproxy": + update_global_settings( + self, + value=None, + name="consoleproxy.service.offering") + + if value == "secondarystoragevm": + update_global_settings( + self, + value=None, + name="secstorage.service.offering") + + list_conf = Configurations.list(self.apiclient, + name="system.vm.use.local.storage", + zoneid=self.zone.id) + self.assertEqual( + validateList(list_conf)[0], + PASS, + "Check List configuration response for " + "system.vm.use.local.storage") + + val = str_to_bool(list_conf[0].value) + # 2 update the zone level config with service offering uuid + update_global_settings(self, + value=((str(not(val)).lower())), + name='system.vm.use.local.storage', + zoneid=self.zone.id) + + # 3,4 for cpvm + destroy_systemvm(self, value) + storage_check(self, value, int(not(val))) + + # 2 update the zone level config with service offering uuid + update_global_settings( + self, + value=( + str(val).lower()), + name='system.vm.use.local.storage', + zoneid=self.zone.id) + # 3,4 for cpvm + destroy_systemvm(self, value) + storage_check(self, value, int(val)) + + # 1 List zone level config + if value == "consoleproxy": + update_global_settings( + self, + value=None, + name="consoleproxy.service.offering") + + if value == "secondarystoragevm": + update_global_settings( + self, + value=None, + name="secstorage.service.offering") + + @attr(tags=["advanced", "basic"]) + @data('consoleproxy', 'secondarystoragevm') + def test_03_custom_so(self, value): + """ + update global setting with system offering and check if it is being + honoured + 1-update zone level settings "system.vm.use.local.storage={true,false}} + to use local storage + 2-create system offerings{shared,local} + 3-update global settings with system offering uuid and restart ms + 4-destroy system vms + 5-Check if new system vms are using offering updated in global + settings + """ + + # 1-update zone level settings "system.vm.use.local.storage" + # to use local storage + update_global_settings( + self, + value='true', + name='system.vm.use.local.storage', + zoneid=self.zone.id) + # 2-create system offerings + + created_so_id = create_system_so(self, value, "shared") + + if value == "consoleproxy": + name = "consoleproxy.service.offering" + elif value == 'secondarystoragevm': + name = 'secstorage.service.offering' + else: + raise Exception( + "type paramter is not correct it should be system vm " + "type{console proxy,secsroragevm}") + + # 3-update global settings with system offering uuid + update_global_settings(self, value=created_so_id, name=name) + + # 4-destroy system vms + destroy_systemvm(self, value) + + # 5-Check if new system vms are using offering updated in global + # settings + + query_zone_id = self.dbclient.execute( + "select id from data_center where uuid= '%s';" % self.zone.id + ) + query_so_id = self.dbclient.execute( + "select service_offering_id from vm_instance where type='%s'and " + "state='Running' and data_center_id= '%s';" % + (value, query_zone_id[0][0])) + query_disk_offering = self.dbclient.execute( + "select uuid from disk_offering where id= '%s';" % + query_so_id[0][0]) + + self.assertEqual( + created_so_id, + query_disk_offering[0][0], + "system vms are not using service offering mentioned in " + "global settings") + + # 6-repeate 1 with system.vm.use.local.storage=false + update_global_settings( + self, + value='false', + name='system.vm.use.local.storage', + zoneid=self.zone.id) + # 7-repeate 2 with storage type local + created_so_id = create_system_so(self, value, "local") + # 8-repeate 3 + update_global_settings(self, value=created_so_id, name=name) + + # 9-repeate 4 + destroy_systemvm(self, value) + # repeate 5 + query_zone_id = self.dbclient.execute( + "select id from data_center where uuid= '%s';" % self.zone.id + ) + query_so_id = self.dbclient.execute( + "select service_offering_id from vm_instance where type='%s'and " + "state='Running' and data_center_id= '%s';" % + (value, query_zone_id[0][0])) + query_disk_offering = self.dbclient.execute( + "select uuid from disk_offering where id= '%s';" % + query_so_id[0][0]) + + self.assertEqual( + created_so_id, + query_disk_offering[0][0], + "system vms are not using service offering mentioned in" + " global settings") + + @attr(tags=["advanced"]) + def test_04_router_vms(self): + """ Check if router vm is honouring zone level setting + system.vm.use.local.storage""" + + # 1-list configurations + list_conf = Configurations.list(self.apiclient, + name="system.vm.use.local.storage", + zoneid=self.zone.id) + self.assertEqual( + validateList(list_conf)[0], + PASS, + "Check List configuration response for " + "system.vm.use.local.storage") + + # 2-create network offering + self.network_offering = NetworkOffering.create( + self.apiclient, + self.testdata["network_offering"], + ispersistent='true' + ) + + # 3-list netwrok offerings + list_nw_of = NetworkOffering.list(self.apiclient, + id=self.network_offering.id) + self.assertEqual( + validateList(list_nw_of)[0], + PASS, + "Check the list network response" + ) + self.assertEqual( + str(list_nw_of[0].id), + str(self.network_offering.id), + "Check the created network offering id and " + "listed network offering id" + ) + self._cleanup.append(self.network_offering) + + # 4-Enable network offering + self.network_offering.update(self.apiclient, state='Enabled') + + # 5-List network offering + list_nw_of1 = NetworkOffering.list(self.apiclient, + id=self.network_offering.id) + self.assertEqual( + validateList(list_nw_of1)[0], + PASS, + "Check the list network response" + ) + self.assertEqual( + str(list_nw_of1[0].state), + "Enabled", + "Check the created network state" + ) + + # 6-crete network using network offering + self.network = Network.create( + self.apiclient, + self.testdata["network"], + networkofferingid=self.network_offering.id, + zoneid=self.zone.id, + accountid=self.account.name, + domainid=self.account.domainid + ) + # 7-List network + list_network = Network.list(self.apiclient, + accountid=self.account.name, + domainid=self.account.domainid, + id=self.network.id) + self.assertEqual(validateList(list_network)[0], + PASS, + "check list netwok response ") + self.assertEqual( + list_network[0].id, + self.network.id, + "List network id %s and created network id %s does not match" % + (list_network[0].id, + self.network.id)) + + # 8-List router + list_router = Router.list(self.apiclient, + networkid=self.network.id, + accountid=self.account.name, + domainid=self.account.domainid) + + self.assertEqual( + validateList(list_router)[0], + PASS, + "check list router response") + + # 9-List service offerings + list_so = ServiceOffering.list(self.apiclient, + issystem='true', + id=list_router[0].serviceofferingid + ) + self.assertEqual( + validateList(list_so)[0], + PASS, + "check list service offering response") + if list_conf[0].value == 'true': + storage_type = 'local' + value1 = 'false' + elif list_conf[0].value == 'false': + storage_type = 'shared' + value1 = 'true' + else: + raise Exception("check list_conf[0].value") + self.assertEqual( + list_so[0].storagetype, + storage_type, + "Check VR storage type and zone level settig" + ) + + # 10-Update zone level setting + update_global_settings( + self, + value=value1, + name="system.vm.use.local.storage", + zoneid=self.zone.id) + + # 11-List configurations + list_conf1 = Configurations.list(self.apiclient, + name="system.vm.use.local.storage", + zoneid=self.zone.id) + self.assertEqual( + validateList(list_conf1)[0], + PASS, + "Check List configuration response for " + "system.vm.use.local.storage") + + self.assertEqual( + list_conf1[0].value, + value1, + "Check the system.vm.use.local.storage value" + ) + self.network.restart(self.apiclient, + cleanup='true' + ) + # 12-List network + list_network1 = Network.list(self.apiclient, + accountid=self.account.name, + domainid=self.account.domainid, + id=self.network.id) + self.assertEqual(validateList(list_network1)[0], + PASS, + "check list netwok response ") + + # 13-list VR + list_router1 = Router.list(self.apiclient, + networkid=list_network1[0].id, + accountid=self.account.name, + domainid=self.account.domainid) + self.assertEqual( + validateList(list_router1)[0], + PASS, + "check list router response" + ) + # 14-list service offerings + list_so1 = ServiceOffering.list(self.apiclient, + issystem='true', + id=list_router1[0].serviceofferingid + ) + self.assertEqual( + validateList(list_so1)[0], + PASS, + "check list service offering response" + ) + if list_conf1[0].value == 'true': + storage_type1 = 'local' + elif list_conf1[0].value == 'false': + storage_type1 = 'shared' + else: + raise Exception("check list_conf[0].value") + self.assertEqual( + list_so1[0].storagetype, + storage_type1, + "Check VR storage type and zone level settings" + ) From f6789532b0012287a0fcd8bfaa9df0cbc4d632a0 Mon Sep 17 00:00:00 2001 From: pritisarap12 Date: Mon, 11 May 2015 22:36:14 +0530 Subject: [PATCH 057/175] CLOUDSTACK-8476: Disabling Zone, Pod, Cluster: --Test cases for testing the behaviour of resources running on zone and admin/non-admin user after disabling the Zone Signed-off-by: Gaurav Aradhye This closes #242 --- .../maint/testpath_disable_enable_zone.py | 499 ++++++++++++++++++ tools/marvin/marvin/codes.py | 1 + 2 files changed, 500 insertions(+) create mode 100644 test/integration/component/maint/testpath_disable_enable_zone.py diff --git a/test/integration/component/maint/testpath_disable_enable_zone.py b/test/integration/component/maint/testpath_disable_enable_zone.py new file mode 100644 index 000000000000..ba3a014deaee --- /dev/null +++ b/test/integration/component/maint/testpath_disable_enable_zone.py @@ -0,0 +1,499 @@ +# 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. +""" Test cases for Disable enable Zone Test Path +""" + +from nose.plugins.attrib import attr +from marvin.cloudstackTestCase import cloudstackTestCase +from marvin.lib.utils import (cleanup_resources) +from marvin.lib.base import (Account, + VirtualMachine, + ServiceOffering, + Zone, + Template, + Snapshot, + Volume, + DiskOffering, + Iso + ) +from marvin.lib.common import (get_domain, + get_zone, + get_template, + list_volumes, + list_snapshots, + get_builtin_template_info + ) + +from marvin.cloudstackAPI import updateZone +from marvin.codes import (ENABLED, + DISABLED, + STOPPED, + RUNNING) + + +class TestDisableEnableZone(cloudstackTestCase): + + @classmethod + def setUpClass(cls): + testClient = super(TestDisableEnableZone, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.testdata = testClient.getParsedTestDataConfig() + cls.hypervisor = cls.testClient.getHypervisorInfo() + + # Get Zone, Domain and templates + cls.domain = get_domain(cls.apiclient) + cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) + + cls.template = get_template( + cls.apiclient, + cls.zone.id, + cls.testdata["ostype"]) + + cls._cleanup = [] + + try: + cls.service_offering = ServiceOffering.create( + cls.apiclient, + cls.testdata["service_offering"], + ) + cls._cleanup.append(cls.service_offering) + + cls.disk_offering = DiskOffering.create( + cls.apiclient, + cls.testdata["disk_offering"], + ) + cls._cleanup.append(cls.disk_offering) + + # Create an account + cls.account = Account.create( + cls.apiclient, + cls.testdata["account"], + domainid=cls.domain.id + ) + cls._cleanup.append(cls.account) + + # Create user api client of the account + cls.userapiclient = testClient.getUserApiClient( + UserName=cls.account.name, + DomainName=cls.account.domain + ) + + except Exception as e: + cls.tearDownClass() + raise e + return + + @classmethod + def tearDownClass(cls): + try: + zoneList = Zone.list(cls.apiclient, id=cls.zone.id) + if zoneList[0].allocationstate == DISABLED: + cmd = updateZone.updateZoneCmd() + cmd.id = zoneList[0].id + cmd.allocationstate = ENABLED + cls.apiclient.updateZone(cmd) + cleanup_resources(cls.apiclient, cls._cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + + def setUp(self): + self.apiclient = self.testClient.getApiClient() + self.dbclient = self.testClient.getDbConnection() + self.cleanup = [] + + def tearDown(self): + try: + cleanup_resources(self.apiclient, self.cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return + + @attr(tags=["advanced", "basic"], required_hardware="true") + def test_01_disable_enable_zone(self): + """disable enable zone + 1. Disable zone and verify following things: + For admin user: + 1. Should be create to start/stop exsiting vms + 2. Should be create to deploy new vm, snapshot,volume, + template,iso in the same zone + For Non-admin user: + 1. Should be create to start/stop exsiting vms + 2. Should not be create to deploy new vm, snapshot,volume, + template,iso in the same zone + 2. Enable the above disabled zone and verify that: + -All users should be create to deploy new vm, + snapshot,volume,template,iso in the same zone + 3. Try to delete the zone and it should fail with error message: + -"The zone is not deletable because there are + servers running in this zone" + """ + # Step 1 + vm_user = VirtualMachine.create( + self.userapiclient, + self.testdata["small"], + templateid=self.template.id, + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.service_offering.id, + zoneid=self.zone.id + ) + + vm_root = VirtualMachine.create( + self.apiclient, + self.testdata["small"], + templateid=self.template.id, + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.service_offering.id, + zoneid=self.zone.id + ) + + cmd = updateZone.updateZoneCmd() + cmd.id = self.zone.id + cmd.allocationstate = DISABLED + self.apiclient.updateZone(cmd) + zoneList = Zone.list(self.apiclient, id=self.zone.id) + + self.assertEqual(zoneList[0].allocationstate, + DISABLED, + "Check if the zone is in disabled state" + ) + + # Both user and admin vms shoul be running + self.assertEqual(vm_user.state, + RUNNING, + "Verify that the user vm is running") + + self.assertEqual(vm_root.state, + RUNNING, + "Verify that the admin vm is running") + + vm_root.stop(self.apiclient) + vm_user.stop(self.apiclient) + + root_state = self.dbclient.execute( + "select state from vm_instance where name='%s'" % + vm_root.name)[0][0] + + user_state = self.dbclient.execute( + "select state from vm_instance where name='%s'" % + vm_user.name)[0][0] + + self.assertEqual(root_state, + STOPPED, + "verify that vm is Stopped") + + self.assertEqual(user_state, + STOPPED, + "verify that vm is stopped") + + root_volume = list_volumes( + self.userapiclient, + virtualmachineid=vm_root.id, + type='ROOT', + listall=True + ) + + snap = Snapshot.create( + self.apiclient, + root_volume[0].id) + + self.assertNotEqual(snap, + None, + "Verify that admin should be \ + able to create snapshot") + + snapshots = list_snapshots( + self.apiclient, + volumeid=root_volume[0].id, + listall=True) + + template_from_snapshot = Template.create_from_snapshot( + self.apiclient, + snapshots[0], + self.testdata["privatetemplate"]) + + self.assertNotEqual( + template_from_snapshot, + None, + "Verify that admin should be able to create template" + ) + + builtin_info = get_builtin_template_info(self.apiclient, self.zone.id) + self.testdata["privatetemplate"]["url"] = builtin_info[0] + self.testdata["privatetemplate"]["hypervisor"] = builtin_info[1] + self.testdata["privatetemplate"]["format"] = builtin_info[2] + + template_regis = Template.register( + self.apiclient, + self.testdata["privatetemplate"], + zoneid=self.zone.id) + + self.assertNotEqual( + template_regis, + None, + "Check if template gets created" + ) + self.assertNotEqual( + template_from_snapshot, + None, + "Check if template gets created" + ) + + data_volume = Volume.create( + self.apiclient, + self.testdata["volume"], + zoneid=self.zone.id, + account=self.account.name, + domainid=self.account.domainid, + diskofferingid=self.disk_offering.id + ) + self.assertNotEqual( + data_volume, + None, + "Check if volume gets created" + ) + + ISO = Iso.create( + self.apiclient, + self.testdata["iso2"], + zoneid=self.zone.id, + account=self.account.name, + domainid=self.account.domainid, + ) + + self.assertNotEqual( + ISO, + None, + "Check if volume gets created" + ) + # non-admin user should fail to create vm, snap, temp etc + with self.assertRaises(Exception): + VirtualMachine.create(self.userapiclient, + self.testdata["small"], + templateid=self.template.id, + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.service_offering.id, + zoneid=self.zone.id + ) + + root_volume = list_volumes( + self.userapiclient, + virtualmachineid=vm_user.id, + type='ROOT', + listall=True + ) + + with self.assertRaises(Exception): + snap = Snapshot.create( + self.userapiclient, + root_volume[0].id) + + with self.assertRaises(Exception): + Template.register( + self.userapiclient, + self.testdata["privatetemplate"], + zoneid=self.zone.id) + + with self.assertRaises(Exception): + Volume.create( + self.userapiclient, + self.testdata["volume"], + zoneid=self.zone.id, + account=self.account.name, + domainid=self.account.domainid, + diskofferingid=self.disk_offering.id + ) + + with self.assertRaises(Exception): + ISO = Iso.create( + self.userapiclient, + self.testdata["iso2"], + zoneid=self.zone.id, + account=self.account.name, + domainid=self.account.domainid, + ) + + # Step 2 + cmd.allocationstate = ENABLED + self.apiclient.updateZone(cmd) + + # After enabling the zone all users should be able to add new VM, + # volume, template and iso + + root_vm_new = VirtualMachine.create( + self.apiclient, + self.testdata["small"], + templateid=self.template.id, + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.service_offering.id, + zoneid=self.zone.id + ) + + self.assertNotEqual(root_vm_new, + None, + "Verify that admin should create new VM") + + snap = Snapshot.create( + self.apiclient, + root_volume[0].id) + + self.assertNotEqual(snap, + None, + "Verify that admin should snashot") + + snapshots = list_snapshots( + self.apiclient, + volumeid=root_volume[0].id, + listall=True) + + template_from_snapshot = Template.create_from_snapshot( + self.apiclient, + snapshots[0], + self.testdata["privatetemplate"]) + + self.assertNotEqual( + template_from_snapshot, + None, + "Check if template gets created" + ) + + template_regis = Template.register( + self.apiclient, + self.testdata["privatetemplate"], + zoneid=self.zone.id) + + self.assertNotEqual( + template_regis, + None, + "Check if template gets created" + ) + self.assertNotEqual( + template_from_snapshot, + None, + "Check if template gets created" + ) + + data_volume = Volume.create( + self.apiclient, + self.testdata["volume"], + zoneid=self.zone.id, + account=self.account.name, + domainid=self.account.domainid, + diskofferingid=self.disk_offering.id + ) + self.assertNotEqual( + data_volume, + None, + "Check if volume gets created" + ) + + ISO = Iso.create( + self.apiclient, + self.testdata["iso2"], + zoneid=self.zone.id, + account=self.account.name, + domainid=self.account.domainid, + ) + + self.assertNotEqual( + ISO, + None, + "Check if volume gets created" + ) + root_vm_new.delete(self.apiclient) + # Non root user + user_vm_new = VirtualMachine.create( + self.userapiclient, + self.testdata["small"], + templateid=self.template.id, + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.service_offering.id, + zoneid=self.zone.id + ) + + self.assertNotEqual(user_vm_new, + None, + "Verify that admin should create new VM") + + snap = Snapshot.create( + self.userapiclient, + root_volume[0].id) + + self.assertNotEqual(snap, + None, + "Verify that admin should snashot") + + snapshots = list_snapshots( + self.userapiclient, + volumeid=root_volume[0].id, + listall=True) + + template_regis = Template.register( + self.userapiclient, + self.testdata["privatetemplate"], + zoneid=self.zone.id) + + self.assertNotEqual( + template_regis, + None, + "Check if template gets created" + ) + self.assertNotEqual( + template_from_snapshot, + None, + "Check if template gets created" + ) + + data_volume = Volume.create( + self.userapiclient, + self.testdata["volume"], + zoneid=self.zone.id, + account=self.account.name, + domainid=self.account.domainid, + diskofferingid=self.disk_offering.id + ) + self.assertNotEqual( + data_volume, + None, + "Check if volume gets created" + ) + + ISO = Iso.create( + self.userapiclient, + self.testdata["iso2"], + zoneid=self.zone.id, + account=self.account.name, + domainid=self.account.domainid, + ) + + self.assertNotEqual( + ISO, + None, + "Check if volume gets created" + ) + user_vm_new.delete(self.apiclient) + + # Step 3 + # Deletion of zone should fail if vm,volume is present on the zone + with self.assertRaises(Exception): + self.zone.delete(self.apiclient) + + return diff --git a/tools/marvin/marvin/codes.py b/tools/marvin/marvin/codes.py index 921b619d0563..502e49e2addb 100644 --- a/tools/marvin/marvin/codes.py +++ b/tools/marvin/marvin/codes.py @@ -54,6 +54,7 @@ RECURRING = "RECURRING" ENABLED = "Enabled" +DISABLED = "Disabled" NETWORK_OFFERING = "network_offering" ROOT = "ROOT" INVALID_INPUT = "INVALID INPUT" From 95e7673a55455736ae736b029197487ba1acfe62 Mon Sep 17 00:00:00 2001 From: Remi Bergsma Date: Mon, 18 May 2015 13:38:46 +0200 Subject: [PATCH 058/175] Systemvm: Disable services that slow down boot The console-setup service brings a nice font to the console, but why would we want to use it. In most cases it takes a <10 seconds to set it up. When using nested hypervising, I found this takes much longer time that causes tests to time-out. I'd suggest turning off these services. They are not required for the services the systemvm provides. --- .../systemvmtemplate/configure_systemvm_services.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/appliance/definitions/systemvmtemplate/configure_systemvm_services.sh b/tools/appliance/definitions/systemvmtemplate/configure_systemvm_services.sh index 69612dc1083a..4f655436172c 100644 --- a/tools/appliance/definitions/systemvmtemplate/configure_systemvm_services.sh +++ b/tools/appliance/definitions/systemvmtemplate/configure_systemvm_services.sh @@ -70,6 +70,10 @@ function configure_services() { chkconfig xl2tpd off + # Disable services that slow down boot and are not used anyway + chkconfig x11-common off + chkconfig console-setup off + # Hyperv kvp daemon - 64bit only local arch=`dpkg --print-architecture` if [ "${arch}" == "amd64" ]; then From 9d8a62d0ee379bf8b67405944c86f68587245db6 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Mon, 18 May 2015 19:58:57 +0200 Subject: [PATCH 059/175] systemvmtemplate: install libc6:i386 for 64bit template Signed-off-by: Rohit Yadav --- .../definitions/systemvmtemplate/install_systemvm_packages.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/appliance/definitions/systemvmtemplate/install_systemvm_packages.sh b/tools/appliance/definitions/systemvmtemplate/install_systemvm_packages.sh index fc90eba5c313..83117a12366d 100644 --- a/tools/appliance/definitions/systemvmtemplate/install_systemvm_packages.sh +++ b/tools/appliance/definitions/systemvmtemplate/install_systemvm_packages.sh @@ -48,7 +48,7 @@ function install_packages() { if [ "${arch}" != "i386" ]; then dpkg --add-architecture i386 apt-get update - ${apt_get} install links:i386 libuuid1:i386 + ${apt_get} install links:i386 libuuid1:i386 libc6:i386 fi ${apt_get} install \ From 0cdb4b610865fa5493cc79e9c9ef310bdf09ccaf Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Mon, 18 May 2015 14:30:36 +0200 Subject: [PATCH 060/175] Fixing the testGetHostStatsCommand test under LibvirtComputingResourceTest. - Removed the expected value from the Test annotation - Mocking the bash path in order to avoid environment/OS issues Fixing typo on LibvirtRequestWrapper - Replace linbvirtCommands by libvirtCommands on LibvirtRequestWrapper Signed-off-by: Rohit Yadav This closes #255 --- .../resource/LibvirtComputingResource.java | 2 + .../LibvirtGetHostStatsCommandWrapper.java | 10 +- .../wrapper/LibvirtRequestWrapper.java | 120 +++++++++--------- .../wrapper/LibvirtUtilitiesHelper.java | 4 + .../LibvirtComputingResourceTest.java | 11 +- 5 files changed, 83 insertions(+), 64 deletions(-) diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index a04074bee94a..995a8cfd2ec3 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -194,6 +194,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv public static final String SSHPRVKEYPATH = SSHKEYSPATH + File.separator + "id_rsa.cloud"; public static final String SSHPUBKEYPATH = SSHKEYSPATH + File.separator + "id_rsa.pub.cloud"; + public static final String BASH_SCRIPT_PATH = "/bin/bash"; + private String _mountPoint = "/mnt"; private StorageLayer _storage; private KVMStoragePoolManager _storagePoolMgr; diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetHostStatsCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetHostStatsCommandWrapper.java index ba9ba188dad7..45713cb30834 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetHostStatsCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetHostStatsCommandWrapper.java @@ -37,7 +37,11 @@ public final class LibvirtGetHostStatsCommandWrapper extends CommandWrapper, CommandWrapper> linbvirtCommands = new Hashtable, CommandWrapper>(); - - linbvirtCommands.put(StopCommand.class, new LibvirtStopCommandWrapper()); - linbvirtCommands.put(GetVmStatsCommand.class, new LibvirtGetVmStatsCommandWrapper()); - linbvirtCommands.put(GetVmDiskStatsCommand.class, new LibvirtGetVmDiskStatsCommandWrapper()); - linbvirtCommands.put(RebootRouterCommand.class, new LibvirtRebootRouterCommandWrapper()); - linbvirtCommands.put(RebootCommand.class, new LibvirtRebootCommandWrapper()); - linbvirtCommands.put(GetHostStatsCommand.class, new LibvirtGetHostStatsCommandWrapper()); - linbvirtCommands.put(CheckHealthCommand.class, new LibvirtCheckHealthCommandWrapper()); - linbvirtCommands.put(PrepareForMigrationCommand.class, new LibvirtPrepareForMigrationCommandWrapper()); - linbvirtCommands.put(MigrateCommand.class, new LibvirtMigrateCommandWrapper()); - linbvirtCommands.put(PingTestCommand.class, new LibvirtPingTestCommandWrapper()); - linbvirtCommands.put(CheckVirtualMachineCommand.class, new LibvirtCheckVirtualMachineCommandWrapper()); - linbvirtCommands.put(ReadyCommand.class, new LibvirtReadyCommandWrapper()); - linbvirtCommands.put(AttachIsoCommand.class, new LibvirtAttachIsoCommandWrapper()); - linbvirtCommands.put(AttachVolumeCommand.class, new LibvirtAttachVolumeCommandWrapper()); - linbvirtCommands.put(WatchConsoleProxyLoadCommand.class, new LibvirtWatchConsoleProxyLoadCommandWrapper()); - linbvirtCommands.put(CheckConsoleProxyLoadCommand.class, new LibvirtCheckConsoleProxyLoadCommandWrapper()); - linbvirtCommands.put(GetVncPortCommand.class, new LibvirtGetVncPortCommandWrapper()); - linbvirtCommands.put(ModifySshKeysCommand.class, new LibvirtModifySshKeysCommandWrapper()); - linbvirtCommands.put(MaintainCommand.class, new LibvirtMaintainCommandWrapper()); - linbvirtCommands.put(CreateCommand.class, new LibvirtCreateCommandWrapper()); - linbvirtCommands.put(DestroyCommand.class, new LibvirtDestroyCommandWrapper()); - linbvirtCommands.put(PrimaryStorageDownloadCommand.class, new LibvirtPrimaryStorageDownloadCommandWrapper()); - linbvirtCommands.put(GetStorageStatsCommand.class, new LibvirtGetStorageStatsCommandWrapper()); - linbvirtCommands.put(UpgradeSnapshotCommand.class, new LibvirtUpgradeSnapshotCommandWrapper()); - linbvirtCommands.put(DeleteStoragePoolCommand.class, new LibvirtDeleteStoragePoolCommandWrapper()); - linbvirtCommands.put(OvsSetupBridgeCommand.class, new LibvirtOvsSetupBridgeCommandWrapper()); - linbvirtCommands.put(OvsDestroyBridgeCommand.class, new LibvirtOvsDestroyBridgeCommandWrapper()); - linbvirtCommands.put(OvsFetchInterfaceCommand.class, new LibvirtOvsFetchInterfaceCommandWrapper()); - linbvirtCommands.put(OvsVpcPhysicalTopologyConfigCommand.class, new LibvirtOvsVpcPhysicalTopologyConfigCommandWrapper()); - linbvirtCommands.put(OvsVpcRoutingPolicyConfigCommand.class, new LibvirtOvsVpcRoutingPolicyConfigCommandWrapper()); - linbvirtCommands.put(CreateStoragePoolCommand.class, new LibvirtCreateStoragePoolCommandWrapper()); - linbvirtCommands.put(ModifyStoragePoolCommand.class, new LibvirtModifyStoragePoolCommandWrapper()); - linbvirtCommands.put(CleanupNetworkRulesCmd.class, new LibvirtCleanupNetworkRulesCommandWrapper()); - linbvirtCommands.put(NetworkRulesVmSecondaryIpCommand.class, new LibvirtNetworkRulesVmSecondaryIpCommandWrapper()); - linbvirtCommands.put(NetworkRulesSystemVmCommand.class, new LibvirtNetworkRulesSystemVmCommandWrapper()); - linbvirtCommands.put(CheckSshCommand.class, new LibvirtCheckSshCommandWrapper()); - linbvirtCommands.put(CheckNetworkCommand.class, new LibvirtCheckNetworkCommandWrapper()); - linbvirtCommands.put(OvsDestroyTunnelCommand.class, new LibvirtOvsDestroyTunnelCommandWrapper()); - linbvirtCommands.put(CheckOnHostCommand.class, new LibvirtCheckOnHostCommandWrapper()); - linbvirtCommands.put(OvsCreateTunnelCommand.class, new LibvirtOvsCreateTunnelCommandWrapper()); - linbvirtCommands.put(CreateVolumeFromSnapshotCommand.class, new LibvirtCreateVolumeFromSnapshotCommandWrapper()); - linbvirtCommands.put(FenceCommand.class, new LibvirtFenceCommandWrapper()); - linbvirtCommands.put(SecurityGroupRulesCmd.class, new LibvirtSecurityGroupRulesCommandWrapper()); - linbvirtCommands.put(PlugNicCommand.class, new LibvirtPlugNicCommandWrapper()); - linbvirtCommands.put(UnPlugNicCommand.class, new LibvirtUnPlugNicCommandWrapper()); - linbvirtCommands.put(NetworkUsageCommand.class, new LibvirtNetworkUsageCommandWrapper()); - linbvirtCommands.put(CreatePrivateTemplateFromVolumeCommand.class, new LibvirtCreatePrivateTemplateFromVolumeCommandWrapper()); - linbvirtCommands.put(ManageSnapshotCommand.class, new LibvirtManageSnapshotCommandWrapper()); - linbvirtCommands.put(BackupSnapshotCommand.class, new LibvirtBackupSnapshotCommandWrapper()); - linbvirtCommands.put(CreatePrivateTemplateFromSnapshotCommand.class, new LibvirtCreatePrivateTemplateFromSnapshotCommandWrapper()); - linbvirtCommands.put(CopyVolumeCommand.class, new LibvirtCopyVolumeCommandWrapper()); - linbvirtCommands.put(PvlanSetupCommand.class, new LibvirtPvlanSetupCommandWrapper()); - linbvirtCommands.put(ResizeVolumeCommand.class, new LibvirtResizeVolumeCommandWrapper()); - linbvirtCommands.put(NetworkElementCommand.class, new LibvirtNetworkElementCommandWrapper()); - linbvirtCommands.put(StorageSubSystemCommand.class, new LibvirtStorageSubSystemCommandWrapper()); - linbvirtCommands.put(StartCommand.class, new LibvirtStartCommandWrapper()); - - resources.put(LibvirtComputingResource.class, linbvirtCommands); + final Hashtable, CommandWrapper> libvirtCommands = new Hashtable, CommandWrapper>(); + + libvirtCommands.put(StopCommand.class, new LibvirtStopCommandWrapper()); + libvirtCommands.put(GetVmStatsCommand.class, new LibvirtGetVmStatsCommandWrapper()); + libvirtCommands.put(GetVmDiskStatsCommand.class, new LibvirtGetVmDiskStatsCommandWrapper()); + libvirtCommands.put(RebootRouterCommand.class, new LibvirtRebootRouterCommandWrapper()); + libvirtCommands.put(RebootCommand.class, new LibvirtRebootCommandWrapper()); + libvirtCommands.put(GetHostStatsCommand.class, new LibvirtGetHostStatsCommandWrapper()); + libvirtCommands.put(CheckHealthCommand.class, new LibvirtCheckHealthCommandWrapper()); + libvirtCommands.put(PrepareForMigrationCommand.class, new LibvirtPrepareForMigrationCommandWrapper()); + libvirtCommands.put(MigrateCommand.class, new LibvirtMigrateCommandWrapper()); + libvirtCommands.put(PingTestCommand.class, new LibvirtPingTestCommandWrapper()); + libvirtCommands.put(CheckVirtualMachineCommand.class, new LibvirtCheckVirtualMachineCommandWrapper()); + libvirtCommands.put(ReadyCommand.class, new LibvirtReadyCommandWrapper()); + libvirtCommands.put(AttachIsoCommand.class, new LibvirtAttachIsoCommandWrapper()); + libvirtCommands.put(AttachVolumeCommand.class, new LibvirtAttachVolumeCommandWrapper()); + libvirtCommands.put(WatchConsoleProxyLoadCommand.class, new LibvirtWatchConsoleProxyLoadCommandWrapper()); + libvirtCommands.put(CheckConsoleProxyLoadCommand.class, new LibvirtCheckConsoleProxyLoadCommandWrapper()); + libvirtCommands.put(GetVncPortCommand.class, new LibvirtGetVncPortCommandWrapper()); + libvirtCommands.put(ModifySshKeysCommand.class, new LibvirtModifySshKeysCommandWrapper()); + libvirtCommands.put(MaintainCommand.class, new LibvirtMaintainCommandWrapper()); + libvirtCommands.put(CreateCommand.class, new LibvirtCreateCommandWrapper()); + libvirtCommands.put(DestroyCommand.class, new LibvirtDestroyCommandWrapper()); + libvirtCommands.put(PrimaryStorageDownloadCommand.class, new LibvirtPrimaryStorageDownloadCommandWrapper()); + libvirtCommands.put(GetStorageStatsCommand.class, new LibvirtGetStorageStatsCommandWrapper()); + libvirtCommands.put(UpgradeSnapshotCommand.class, new LibvirtUpgradeSnapshotCommandWrapper()); + libvirtCommands.put(DeleteStoragePoolCommand.class, new LibvirtDeleteStoragePoolCommandWrapper()); + libvirtCommands.put(OvsSetupBridgeCommand.class, new LibvirtOvsSetupBridgeCommandWrapper()); + libvirtCommands.put(OvsDestroyBridgeCommand.class, new LibvirtOvsDestroyBridgeCommandWrapper()); + libvirtCommands.put(OvsFetchInterfaceCommand.class, new LibvirtOvsFetchInterfaceCommandWrapper()); + libvirtCommands.put(OvsVpcPhysicalTopologyConfigCommand.class, new LibvirtOvsVpcPhysicalTopologyConfigCommandWrapper()); + libvirtCommands.put(OvsVpcRoutingPolicyConfigCommand.class, new LibvirtOvsVpcRoutingPolicyConfigCommandWrapper()); + libvirtCommands.put(CreateStoragePoolCommand.class, new LibvirtCreateStoragePoolCommandWrapper()); + libvirtCommands.put(ModifyStoragePoolCommand.class, new LibvirtModifyStoragePoolCommandWrapper()); + libvirtCommands.put(CleanupNetworkRulesCmd.class, new LibvirtCleanupNetworkRulesCommandWrapper()); + libvirtCommands.put(NetworkRulesVmSecondaryIpCommand.class, new LibvirtNetworkRulesVmSecondaryIpCommandWrapper()); + libvirtCommands.put(NetworkRulesSystemVmCommand.class, new LibvirtNetworkRulesSystemVmCommandWrapper()); + libvirtCommands.put(CheckSshCommand.class, new LibvirtCheckSshCommandWrapper()); + libvirtCommands.put(CheckNetworkCommand.class, new LibvirtCheckNetworkCommandWrapper()); + libvirtCommands.put(OvsDestroyTunnelCommand.class, new LibvirtOvsDestroyTunnelCommandWrapper()); + libvirtCommands.put(CheckOnHostCommand.class, new LibvirtCheckOnHostCommandWrapper()); + libvirtCommands.put(OvsCreateTunnelCommand.class, new LibvirtOvsCreateTunnelCommandWrapper()); + libvirtCommands.put(CreateVolumeFromSnapshotCommand.class, new LibvirtCreateVolumeFromSnapshotCommandWrapper()); + libvirtCommands.put(FenceCommand.class, new LibvirtFenceCommandWrapper()); + libvirtCommands.put(SecurityGroupRulesCmd.class, new LibvirtSecurityGroupRulesCommandWrapper()); + libvirtCommands.put(PlugNicCommand.class, new LibvirtPlugNicCommandWrapper()); + libvirtCommands.put(UnPlugNicCommand.class, new LibvirtUnPlugNicCommandWrapper()); + libvirtCommands.put(NetworkUsageCommand.class, new LibvirtNetworkUsageCommandWrapper()); + libvirtCommands.put(CreatePrivateTemplateFromVolumeCommand.class, new LibvirtCreatePrivateTemplateFromVolumeCommandWrapper()); + libvirtCommands.put(ManageSnapshotCommand.class, new LibvirtManageSnapshotCommandWrapper()); + libvirtCommands.put(BackupSnapshotCommand.class, new LibvirtBackupSnapshotCommandWrapper()); + libvirtCommands.put(CreatePrivateTemplateFromSnapshotCommand.class, new LibvirtCreatePrivateTemplateFromSnapshotCommandWrapper()); + libvirtCommands.put(CopyVolumeCommand.class, new LibvirtCopyVolumeCommandWrapper()); + libvirtCommands.put(PvlanSetupCommand.class, new LibvirtPvlanSetupCommandWrapper()); + libvirtCommands.put(ResizeVolumeCommand.class, new LibvirtResizeVolumeCommandWrapper()); + libvirtCommands.put(NetworkElementCommand.class, new LibvirtNetworkElementCommandWrapper()); + libvirtCommands.put(StorageSubSystemCommand.class, new LibvirtStorageSubSystemCommandWrapper()); + libvirtCommands.put(StartCommand.class, new LibvirtStartCommandWrapper()); + + resources.put(LibvirtComputingResource.class, libvirtCommands); } public static LibvirtRequestWrapper getInstance() { diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUtilitiesHelper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUtilitiesHelper.java index dfff12d0ab96..98bf642e0d5a 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUtilitiesHelper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUtilitiesHelper.java @@ -82,4 +82,8 @@ public String retrieveSshPubKeyPath() { public String retrieveSshPrvKeyPath() { return LibvirtComputingResource.SSHPRVKEYPATH; } + + public String retrieveBashScriptPath() { + return LibvirtComputingResource.BASH_SCRIPT_PATH; + } } \ No newline at end of file diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index 36227a55035a..7f378a346e85 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -916,19 +916,28 @@ public void testRebootRouterCommandConnect() { } } - @Test(expected = NumberFormatException.class) + @Test public void testGetHostStatsCommand() { // A bit difficult to test due to the logger being passed and the parser itself relying on the connection. // Have to spend some more time afterwards in order to refactor the wrapper itself. + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); + final String bashScriptPath = "/path"; + final String uuid = "e8d6b4d0-bc6d-4613-b8bb-cb9e0600f3c6"; final GetHostStatsCommand command = new GetHostStatsCommand(uuid, "summer", 1l); + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); + when(libvirtUtilitiesHelper.retrieveBashScriptPath()).thenReturn(bashScriptPath); + final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); assertNotNull(wrapper); final Answer answer = wrapper.execute(command, libvirtComputingResource); assertFalse(answer.getResult()); + + verify(libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper(); + verify(libvirtUtilitiesHelper, times(1)).retrieveBashScriptPath(); } @Test From 98a1059413a20424351b8169003ec6216a2ce3fb Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Mon, 18 May 2015 22:09:11 +0100 Subject: [PATCH 061/175] ui: add custom error handling page This makes sure we don't expose CloudStack stacktrace (if any) on the frontend instead redirect to show an error handling page. This closes #256 (cherry picked from commit 112cecc2d4e44d032fb57d9794b02fe694122447) Signed-off-by: Rohit Yadav --- client/WEB-INF/web.xml | 6 ++++++ ui/error.jsp | 12 ++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 ui/error.jsp diff --git a/client/WEB-INF/web.xml b/client/WEB-INF/web.xml index 7ccfc3166179..a384f0647946 100644 --- a/client/WEB-INF/web.xml +++ b/client/WEB-INF/web.xml @@ -77,4 +77,10 @@ *.html *.js + + + java.lang.Exception + /error.jsp + + diff --git a/ui/error.jsp b/ui/error.jsp new file mode 100644 index 000000000000..88fdfa1043e0 --- /dev/null +++ b/ui/error.jsp @@ -0,0 +1,12 @@ + + + + + + Apache CloudStack + + + +

Oops, looks like CloudStack hit an error. Ask your CloudStack Administrator to look into it.

+ + From 4b597ca2b99ff693972b6f8601c204c4478bbbf7 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Mon, 18 May 2015 23:21:52 +0100 Subject: [PATCH 062/175] rat: add license header to error.jsp (cherry picked from commit 9c995f1cab259eb88d802887ee6333e164a6c6f8) Signed-off-by: Rohit Yadav --- ui/error.jsp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ui/error.jsp b/ui/error.jsp index 88fdfa1043e0..9fecfb730c7d 100644 --- a/ui/error.jsp +++ b/ui/error.jsp @@ -1,3 +1,21 @@ +<%-- + 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. +--%> From 19c436fd592de6cebd347892c8225362c90b4660 Mon Sep 17 00:00:00 2001 From: Gaurav Aradhye Date: Tue, 19 May 2015 15:15:29 +0530 Subject: [PATCH 063/175] CLOUDSTACK-8481: Adding test cases for validating global limit on concurrent snapshots Signed-off-by: Gaurav Aradhye This closes #252 --- .../test_concurrent_snapshots_limit.py | 299 ++++++++++++++++++ 1 file changed, 299 insertions(+) create mode 100644 test/integration/component/test_concurrent_snapshots_limit.py diff --git a/test/integration/component/test_concurrent_snapshots_limit.py b/test/integration/component/test_concurrent_snapshots_limit.py new file mode 100644 index 000000000000..910cb0042965 --- /dev/null +++ b/test/integration/component/test_concurrent_snapshots_limit.py @@ -0,0 +1,299 @@ +# 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. +""" Test cases for validating global limit for concurrent snapshots +""" +from nose.plugins.attrib import attr +from marvin.cloudstackTestCase import cloudstackTestCase +from marvin.lib.utils import (cleanup_resources, + validateList) +from marvin.lib.base import (Account, + ServiceOffering, + VirtualMachine, + Snapshot, + Volume, + Configurations + ) +from marvin.lib.common import (get_domain, + get_zone, + get_template + ) + +from marvin.codes import PASS, BACKED_UP +from threading import Thread + + +class TestConcurrentSnapshotLimit(cloudstackTestCase): + + @classmethod + def setUpClass(cls): + testClient = super(TestConcurrentSnapshotLimit, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.testdata = testClient.getParsedTestDataConfig() + cls.hypervisor = cls.testClient.getHypervisorInfo() + + # Get Zone, Domain and templates + cls.domain = get_domain(cls.apiclient) + cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) + + cls.template = get_template( + cls.apiclient, + cls.zone.id, + cls.testdata["ostype"]) + + cls._cleanup = [] + cls.supportedHypervisor = True + + if cls.hypervisor.lower() in [ + "hyperv", + "lxc"]: + cls.supportedHypervisor = False + return + + # Create Service offering + cls.service_offering = ServiceOffering.create( + cls.apiclient, + cls.testdata["service_offering"], + ) + cls._cleanup.append(cls.service_offering) + return + + @classmethod + def tearDownClass(cls): + try: + cleanup_resources(cls.apiclient, cls._cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + + def setUp(self): + self.apiclient = self.testClient.getApiClient() + self.dbclient = self.testClient.getDbConnection() + self.cleanup = [] + + self.exceptionOccured = False + + if not self.supportedHypervisor: + self.skipTest("Snapshot not supported on %s" % self.hypervisor) + + def createSnapshot(self, volumeid): + try: + Snapshot.create( + self.apiclient, + volumeid + ) + except Exception as e: + self.debug("Exception occured: %s" % e) + self.exceptionOccured = True + + def tearDown(self): + try: + cleanup_resources(self.apiclient, self.cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return + + @attr(tags=["advanced", "basic"], required_hardware="true") + def test_01_concurrent_snapshot_global_limit(self): + """ Test if global value concurrent.snapshots.threshold.perhost + value respected + This is positive test cases and tests if we are able to create + as many snapshots mentioned in global value + # 1. Create an account and a VM in it + # 2. Read the global value for concurrent.snapshots.threshold.perhost + # 3. If the value is Null, create at least 10 concurrent snapshots + and verify they are created successfully + # 4. Else, create as many snapshots specified in the global value, and + verify they are created successfully + """ + + # Create an account + account = Account.create( + self.apiclient, + self.testdata["account"], + domainid=self.domain.id + ) + + self.cleanup.append(account) + # Create user api client of the account + userapiclient = self.testClient.getUserApiClient( + UserName=account.name, + DomainName=account.domain + ) + + # Create VM + virtual_machine = VirtualMachine.create( + userapiclient, + self.testdata["small"], + templateid=self.template.id, + accountid=account.name, + domainid=account.domainid, + serviceofferingid=self.service_offering.id, + zoneid=self.zone.id + ) + + # Create 10 concurrent snapshots by default + # We can have any value, so keeping it 10 as it + # seems good enough to test + concurrentSnapshots = 10 + + # Step 1 + # Get ROOT Volume Id + volumes = Volume.list( + self.apiclient, + virtualmachineid=virtual_machine.id, + type='ROOT', + listall=True + ) + + self.assertEqual(validateList(volumes)[0], PASS, + "Volumes list validation failed") + + root_volume = volumes[0] + + config = Configurations.list( + self.apiclient, + name="concurrent.snapshots.threshold.perhost" + ) + self.assertEqual( + isinstance( + config, + list), + True, + "concurrent.snapshots.threshold.perhost should be present\ + in global config") + if config[0].value: + concurrentSnapshots = int(config[0].value) + self.debug("concurrent Snapshots: %s" % concurrentSnapshots) + + threads = [] + for i in range(0, (concurrentSnapshots)): + thread = Thread( + target=Snapshot.create, + args=( + self.apiclient, + root_volume.id + )) + threads.append(thread) + thread.start() + for thread in threads: + thread.join() + + snapshots = Snapshot.list(self.apiclient, + volumeid=root_volume.id, + listall=True) + + self.assertEqual(validateList(snapshots)[0], PASS, + "Snapshots list validation failed") + self.assertEqual( + len(snapshots), + concurrentSnapshots, + "There should be exactly %s snapshots present" % + concurrentSnapshots) + + for snapshot in snapshots: + self.assertEqual(str(snapshot.state).lower(), BACKED_UP, + "Snapshot state should be backedUp but it is\ + %s" % snapshot.state) + return + + @attr(tags=["advanced", "basic"], required_hardware="true") + def test_02_concurrent_snapshot_global_limit(self): + """ Test if global value concurrent.snapshots.threshold.perhost + value is respected + This is negative test cases and tests no more concurrent + snapshots as specified in global value are created + # 1. Read the global value for concurrent.snapshots.threshold.perhost + # 2. If the value is Null, skip the test case + # 3. Create an account and a VM in it + # 4. Create more concurrent snapshots than specified in + global allowed limit + # 5. Verify that exception is raised while creating snapshots + """ + + config = Configurations.list( + self.apiclient, + name="concurrent.snapshots.threshold.perhost" + ) + self.assertEqual( + isinstance( + config, + list), + True, + "concurrent.snapshots.threshold.perhost should be present\ + in global config") + if config[0].value: + concurrentSnapshots = int(config[0].value) + else: + self.skipTest("Skipping tests as the config value \ + concurrent.snapshots.threshold.perhost is Null") + + # Create an account + account = Account.create( + self.apiclient, + self.testdata["account"], + domainid=self.domain.id + ) + + self.cleanup.append(account) + # Create user api client of the account + userapiclient = self.testClient.getUserApiClient( + UserName=account.name, + DomainName=account.domain + ) + + # Create VM + virtual_machine = VirtualMachine.create( + userapiclient, + self.testdata["small"], + templateid=self.template.id, + accountid=account.name, + domainid=account.domainid, + serviceofferingid=self.service_offering.id, + zoneid=self.zone.id + ) + + # Step 1 + # Get ROOT Volume Id + volumes = Volume.list( + self.apiclient, + virtualmachineid=virtual_machine.id, + type='ROOT', + listall=True + ) + + self.assertEqual(validateList(volumes)[0], PASS, + "Volumes list validation failed") + + root_volume = volumes[0] + + threads = [] + for i in range(0, (concurrentSnapshots + 1)): + thread = Thread( + target=self.createSnapshot, + args=( + self.apiclient, + root_volume.id + )) + threads.append(thread) + thread.start() + + for thread in threads: + thread.join() + + self.assertTrue(self.exceptionOccured, "Concurrent snapshots\ + more than concurrent.snapshots.threshold.perhost\ + value successfully created") + return From bab4e3a6af5ff5f8c20063d8ba82ac1dd021493f Mon Sep 17 00:00:00 2001 From: Sowmya Krishnan Date: Wed, 6 May 2015 16:04:51 +0530 Subject: [PATCH 064/175] Tests for Disable Storage Provisioning Signed-off-by: Rohit Yadav This closes #257 --- .../testpaths/testpath_disablestoragepool.py | 1285 +++++++++++++++++ 1 file changed, 1285 insertions(+) create mode 100644 test/integration/testpaths/testpath_disablestoragepool.py diff --git a/test/integration/testpaths/testpath_disablestoragepool.py b/test/integration/testpaths/testpath_disablestoragepool.py new file mode 100644 index 000000000000..3d34ac35619b --- /dev/null +++ b/test/integration/testpaths/testpath_disablestoragepool.py @@ -0,0 +1,1285 @@ +# 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. +"""Utilities functions +""" +#All tests inherit from cloudstackTestCase + +from marvin.cloudstackTestCase import cloudstackTestCase +from marvin.cloudstackTestCase import cloudstackTestCase, unittest +from marvin.codes import FAILED, PASS +from marvin.lib.base import (Account, + VirtualMachine, + ServiceOffering, + User, + DiskOffering, + Volume, + Template, + VmSnapshot, + StoragePool, + Host, + Capacities) +from marvin.lib.utils import cleanup_resources, validateList +from marvin.lib.common import get_zone, get_domain, list_clusters, get_template, list_volumes, list_virtual_machines +from nose.plugins.attrib import attr +from ddt import ddt, data + +def verify_vm_state(self, vmid, state): + list_vm = list_virtual_machines(self.userapiclient, account=self.account.name, domainid=self.account.domainid, id=vmid) + self.assertEqual(validateList(list_vm)[0], PASS, 'Check List vm response for vmid: %s' % vmid) + self.assertGreater(len(list_vm), 0, 'Check the list vm response for vm id: %s' % vmid) + vm = list_vm[0] + self.assertEqual(vm.id, str(vmid), 'Vm deployed is different from the test') + self.assertEqual(vm.state, state, 'VM is not in %s state' % state) + self.debug('VM is in is %s state' % state) + + + +def verify_pool_state(self, poolid, state): + list_storage_pool_response = StoragePool.list(self.userapiclient, id=poolid) + self.assertGreater(len(list_storage_pool_response), 0, 'Check list pool response is greater than 0') + self.assertEqual(list_storage_pool_response[0].state, state, 'Storage pool is not in %s state' % state) + + + +def verify_vm_storage_pool(self, vmid, storageid): + root_volume = Volume.list(self.userapiclient, virtualmachineid=vmid, type='ROOT')[0] + list_volume = Volume.list(self.userapiclient, id=root_volume.id) + self.assertEqual(list_volume[0].storageid, storageid, 'check list volume response for Storage id: % s ' % storageid) + + + +@ddt +class TestPathDisableStorage_Basic(cloudstackTestCase): + """ + # Tests in this path requires to be run independently (not to be run in parallel with any other tests since it involves disabling/enabling storage pools and may cause unexpected failures in other tests + # The test also requires to have 2 Cluster-wide and 2 zone-wide storage pools available in the setup. + # For running the tests on local storage, ensure there are 2 local storage pools set up on each host + + """ + + + @classmethod + def setUpClass(cls): + testClient = super(TestPathDisableStorage_Basic, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.testdata = testClient.getParsedTestDataConfig() + cls.domain = get_domain(cls.apiclient) + cls.zone = get_zone(cls.apiclient) + cls.testdata['mode'] = cls.zone.networktype + cls.template = get_template(cls.apiclient, cls.zone.id, cls.testdata['ostype']) + cls.testdata['template']['ostypeid'] = cls.template.ostypeid + if cls.template == FAILED: + cls.fail('get_template() failed to return template with description %s' % cls.testdata['ostype']) + cls._cleanup = [] + cls.disabled_list = [] + cls.testdata['template_2']['zoneid'] = cls.zone.id + cls.testdata['template_2']['ostypeid'] = cls.template.ostypeid + cls.hypervisor = testClient.getHypervisorInfo() + try: + cls.debug('Creating account') + cls.account = Account.create(cls.apiclient, + cls.testdata['account'], + admin=True + ) + cls._cleanup.append(cls.account) + except Exception as e: + cls.tearDownClass() + raise e + + # Create shared storage offerings + cls.service_offering_shared = ServiceOffering.create(cls.apiclient, + cls.testdata['service_offering'] + ) + cls._cleanup.append(cls.service_offering_shared) + cls.disk_offering_shared = DiskOffering.create(cls.apiclient, + cls.testdata['disk_offering'] + ) + cls.resized_disk_offering = DiskOffering.create(cls.apiclient, + cls.testdata['resized_disk_offering'] + ) + cls._cleanup.append(cls.disk_offering_shared) + + # Create offerings for local storage if local storage is enabled + if cls.zone.localstorageenabled: + cls.testdata["service_offerings"]["storagetype"] = 'local' + cls.service_offering_local = ServiceOffering.create(cls.apiclient, + cls.testdata["service_offerings"] + ) + cls._cleanup.append(cls.service_offering_local) + cls.testdata["disk_offering"]["storagetype"] = 'local' + cls.disk_offering_local = DiskOffering.create(cls.apiclient, + cls.testdata["disk_offering"] + ) + cls._cleanup.append(cls.disk_offering_local) + cls.testdata["disk_offering"]["storagetype"] = ' ' + cls.testdata["service_offerings"]["storagetype"] = ' ' + else: + cls.debug("No local storage found") + + cls.userapiclient = testClient.getUserApiClient(UserName=cls.account.name, + DomainName=cls.account.domain + ) + response = User.login(cls.userapiclient, + username=cls.account.name, + password=cls.testdata['account']['password'] + ) + assert response.sessionkey is not None + + @classmethod + def tearDownClass(cls): + try: + cleanup_resources(cls.apiclient, cls._cleanup) + except Exception as e: + raise Exception('Warning:Exception during cleanup: %s' % e) + + def setUp(self): + self.apiclient = self.testClient.getApiClient() + self.cleanup = [] + + def tearDown(self): + if self.disabled_list: + for poolid in self.disabled_list: + if StoragePool.list(self.userapiclient, id=poolid)[0].state != 'Up': + try: + StoragePool.update(self.userapiclient, id=poolid, enabled=True) + self.debug('Enabling: % s ' % poolid) + except Exception as e: + self.fail("Couldn't enable storage % s" % id) + + try: + cleanup_resources(self.apiclient, self.cleanup) + except Exception as e: + self.fail('Warning: Exception during cleanup : %s' % e) + + + @data('host', 'CLUSTER', 'ZONE') + @attr(tags=['advanced', 'advancedsg', 'basic'], required_hardware='false') + def test_01_disable_enable_pool(self, value): + """ + + Test Steps: + ========= + 1. Deploy 2 VMs + 2. Stop VM2 + 3. Disable storage pool SP1 + 4. Try to deploy a new VM, should fail + 5. Start VM2 which was stopped, should run from same pool + 6. Remove disabled Storage pool SP1, should fail + 7. Enable storage pool SP1 + 8. Deploy new VM, VM4 - should succeed + 9. Create and attach new disk to VM4 + 10. Disable storage pool SP1 again and enable new pool + 11. Deploy new VM, VM5 - should succeed + 12. Stop VM1 which is running from disabled pool + 13. Migrate ROOT volume of VM1 to another enabled storage pool - should succeed + 14. findStoragePoolsforMigration should not list the disabled pool + """ + + # Choose appropriate service offering depending on the scope the test is being run on + self.disabled_list = [] + if value == 'CLUSTER': + other_scope = 'ZONE' + self.service_offering = self.service_offering_shared + self.disk_offering = self.disk_offering_shared + elif value == 'ZONE': + other_scope = 'CLUSTER' + self.service_offering = self.service_offering_shared + self.disk_offering = self.disk_offering_shared + else: + # local storage + other_scope = None + self.service_offering = self.service_offering_local + self.disk_offering = self.disk_offering_local + + # Keep only one pool active and disable the rest + try: + self.list_storage = StoragePool.list(self.userapiclient, scope=value) + count_st_pools = len(self.list_storage) + if count_st_pools > 1: + self.debug('Found % s storage pools, keeping one and disabling rest' % count_st_pools) + for pool in self.list_storage[1:]: + self.disabled_pool_1 = self.list_storage[1] + if pool.state == 'Up': + self.debug('Trying to disable storage %s' % pool.id) + try: + StoragePool.update(self.userapiclient, id=pool.id, enabled=False) + self.disabled_list.append(pool.id) + self.debug('Appended to list of disabled pools. List is now: % s ' % self.disabled_list) + except Exception as e: + raise e + elif count_st_pools == 1: + self.debug('Only one % s wide storage found - will not be able to complete all tests' % value) + else: + self.fail('No % s storage pools found' % value) + except Exception as e: + raise e + + # Disable the other scope shared storage pools while we are testing on one - applicable for only shared storage + if value != 'host': + try: + self.list_storage = StoragePool.list(self.userapiclient, scope=other_scope) + if self.list_storage: + for pool in self.list_storage: + if pool.state == 'Up': + self.debug('Trying to disable storage % s' % pool.id) + try: + StoragePool.update(self.userapiclient, id=pool.id, enabled=False) + self.disabled_list.append(pool.id) + self.debug('Appended to list of disabled pools. List is now: % s ' % self.disabled_list) + except Exception as e: + self.fail("Couldn't disable storage % s" % pool.id) + else: + self.debug('No % s wide storage pools found' % other_scope) + except Exception as e: + raise e + + # Step 1: Deploy 2 VMs + self.virtual_machine_1 = VirtualMachine.create(self.userapiclient, + self.testdata['small'], + templateid=self.template.id, + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.service_offering.id, + zoneid=self.zone.id) + verify_vm_state(self, self.virtual_machine_1.id, 'Running') + self.virtual_machine_2 = VirtualMachine.create(self.userapiclient, + self.testdata['small'], + templateid=self.template.id, + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.service_offering.id, + zoneid=self.zone.id) + verify_vm_state(self, self.virtual_machine_2.id, 'Running') + + # Step 2: Keep one VM in stopped state while other keeps running + try: + self.debug('Step 2: Stopping one of the VMs') + self.virtual_machine_2.stop(self.userapiclient) + verify_vm_state(self, self.virtual_machine_2.id, 'Stopped') + except Exception as e: + self.fail('Step 2: Failed to stop VM: %s' % e) + + # Step 3: Disable the Storage Pool, verify VMs are in same state as before + self.storage_pools_list = StoragePool.list(self.userapiclient, scope=value, state='Up') + self.storage_pool_1 = self.storage_pools_list[0] + try: + self.debug('Step 3: Disabling Storage Pool: %s' % self.storage_pool_1.id) + StoragePool.update(self.userapiclient, id=self.storage_pool_1.id, enabled=False) + except Exception as e: + self.debug("Step 3: Couldn't disable pool %s" % e) + + verify_pool_state(self, self.storage_pool_1.id, 'Disabled') + verify_vm_state(self, self.virtual_machine_1.id, 'Running') + verify_vm_state(self, self.virtual_machine_2.id, 'Stopped') + + # Step 4: Deploying new VM on disabled pool should fail + self.debug('Step 4: Trying to deploy VM on disabled storage - should fail') + with self.assertRaises(Exception): + VirtualMachine.create(self.userapiclient, + self.testdata['small'], + templateid=self.template.id, + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.service_offering.id, + zoneid=self.zone.id) + + # Step 5: Should be able to start VM on disabled pool + try: + self.virtual_machine_2.start(self.userapiclient) + verify_vm_state(self, self.virtual_machine_2.id, 'Running') + verify_vm_storage_pool(self, self.virtual_machine_2.id, self.storage_pool_1.id) + except Exception as e: + self.fail('Step 5: Failed to start VM: %s' % e) + + # Step 6: Removing disabled pool should fail + self.debug('Step 6: Trying to remove disabled storage pool') + with self.assertRaises(Exception): + StoragePool.delete(self.userapiclient, self.storage_pool_1.id) + + # Step 7: Enable Storage pool + try: + self.debug('Step 7: Enabling Storage Pool: %s' % self.storage_pool_1.id) + StoragePool.update(self.userapiclient, id=self.storage_pool_1.id, enabled=True) + except Exception as e: + self.debug("Step 7: Couldn't enable pool %s" % e) + verify_pool_state(self, self.storage_pool_1.id, 'Up') + + # Step 8: Deploy a VM on the pool + self.virtual_machine_3 = VirtualMachine.create(self.userapiclient, + self.testdata['small'], + templateid=self.template.id, + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.service_offering.id, + zoneid=self.zone.id) + verify_vm_state(self, self.virtual_machine_3.id, 'Running') + + # Step 9: Create and attach new disk to VM + self.volume = Volume.create(self.userapiclient, + services=self.testdata['volume'], + diskofferingid=self.disk_offering.id, + zoneid=self.zone.id) + list_volume = Volume.list(self.userapiclient, id=self.volume.id, accountid=self.account.name, domainid=self.account.domainid) + self.assertEqual(validateList(list_volume)[0], + PASS, + 'Step 9: Check List volume response for volume %s' % self.volume.id) + self.assertEqual(list_volume[0].id, + self.volume.id, + 'Step 9: check list volume response for volume id: %s' % self.volume.id) + self.debug('Step 9: volume id %s got created successfully' % list_volume[0].id) + + self.virtual_machine_3.attach_volume(self.userapiclient, self.volume) + list_volume = Volume.list(self.userapiclient, id=self.volume.id) + self.assertEqual(list_volume[0].virtualmachineid, + self.virtual_machine_3.id, + 'Step 9: Check if volume state (attached) is reflected') + self.debug('Step 9: volume id:%s successfully attached to vm id%s' % (self.volume.id, self.virtual_machine_3.id)) + if self.disabled_pool_1: + newpoolid = self.disabled_pool_1.id + else: + self.fail('Step 9: Could not find a second storage pool to complete the remaining tests') + + # Step 10: Disable storage pool SP1 again and enable new pool + try: + StoragePool.update(self.userapiclient, id=newpoolid, enabled=True) + except Exception as e: + self.fail('Step 10: Enable storage pool %s' % e, 'failed') + verify_pool_state(self, newpoolid, 'Up') + try: + self.debug('Step 10: Disabling Storage Pool: %s' % self.storage_pool_1.id) + StoragePool.update(self.userapiclient, id=self.storage_pool_1.id, enabled=False) + self.disabled_list.append(self.storage_pool_1.id) + self.debug('Step 10: Appended to list of disabled pools. List is now: % s ' % self.disabled_list) + except Exception as e: + self.debug("Step 10: Couldn't disable pool %s" % e) + verify_pool_state(self, self.storage_pool_1.id, 'Disabled') + + # Step 11: Deploy new VM, VM5 - should succeed + self.virtual_machine_4 = VirtualMachine.create(self.userapiclient, + self.testdata['small'], + templateid=self.template.id, + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.service_offering.id, + zoneid=self.zone.id) + verify_vm_state(self, self.virtual_machine_4.id, 'Running') + + # Step 12: Stop VM1 which is running from disabled pool + self.virtual_machine_1.stop(self.userapiclient) + verify_vm_state(self, self.virtual_machine_1.id, 'Stopped') + + # Step 13: Migrate ROOT volume of VM1 to another enabled storage pool - should succeed + if value != 'host': + root_volume = Volume.list(self.userapiclient, virtualmachineid=self.virtual_machine_1.id, type='ROOT') + try: + Volume.migrate(self.userapiclient, volumeid=root_volume[0].id, storageid=newpoolid) + except Exception as e: + raise e + list_volume = list_volumes(self.userapiclient, id=root_volume[0].id) + self.assertEqual(isinstance(list_volume, list), True, 'Step 13: Check list volumes response for valid list') + + # Step 14: findStoragePoolsforMigration should not list the disabled pool + if value != 'host': + pools_for_migration = StoragePool.listForMigration(self.userapiclient, id=root_volume[0].id) + self.debug('Step 14: List of pools suitable for migration: % s ' % pools_for_migration) + if pools_for_migration: + if self.storage_pool_1 in pools_for_migration: + self.fail('Step 14: Storage pool % s is supposed to be disabled and not suitable for migration, \ + but found in the list of pools suitable for migration' % self.storage_pool_1.id) + + + @data('host', 'CLUSTER', 'ZONE') + @attr(tags=['advanced', 'advancedsg', 'basic', 'debug'], required_hardware='false') + def test_02_vm_operations_on_disabled_pool(self, value): + + """ + Test Steps: + ========= + + 1. Deploy a VM and attach volume + 2. Create Template from root volume of the VM + 3. Deploy a VM using the template + 4. Disable the storage pool + 5. Attach a new volume - should fail + 6. Resize DATA disk to a higher value + 7. Take VM Snapshot of the VM (for supported hypervisors) + 8. Destroy the VM and immediately restore the VM + 9. Enable a new storage pool + 10. Re-install the VM with same template + 11. Re-install the VM with the new template created earlier + 12. Repeat tests with enabled pool, Attach new Volume to VM2 + 13. Resize disk to a higher value + 14. Reboot the VM + 15. Take VM Snapshot of the VM + 16. Destroy the VM and immediately restore the VM + + """ + + # Choose appropriate service offering depending on the scope the test is being run on + self.disabled_list = [] + if value == 'CLUSTER': + other_scope = 'ZONE' + self.service_offering = self.service_offering_shared + self.disk_offering = self.disk_offering_shared + elif value == 'ZONE': + other_scope = 'CLUSTER' + self.service_offering = self.service_offering_shared + self.disk_offering = self.disk_offering_shared + else: + # local storage + other_scope = None + self.service_offering = self.service_offering_local + self.disk_offering = self.disk_offering_local + + # Keep one storage pool active and disable the rest + try: + self.list_storage = StoragePool.list(self.userapiclient, scope=value) + count_st_pools = len(self.list_storage) + if count_st_pools > 1: + self.debug('Found % s storage pools, keeping one and disabling rest' % count_st_pools) + for pool in self.list_storage[1:]: + self.disabled_pool_1 = self.list_storage[1] + if pool.state == 'Up': + self.debug('Trying to disable storage %s' % pool.id) + try: + StoragePool.update(self.userapiclient, id=pool.id, enabled=False) + self.disabled_list.append(pool.id) + self.debug('Appended to list of disabled pools. List is now: % s ' % self.disabled_list) + except Exception as e: + raise e + elif count_st_pools == 1: + self.debug('Only one % s wide storage found - will not be able to complete all tests' % value) + else: + self.fail('No % s wide storage pools found' % value) + except Exception as e: + raise e + + # Disable the other scope shared storage pools while we are testing on one - applicable for only shared storage + if value != 'host': + try: + self.list_storage = StoragePool.list(self.userapiclient, scope=other_scope) + if self.list_storage: + for pool in self.list_storage: + if pool.state == 'Up': + self.debug('Trying to disable storage % s' % pool.id) + try: + StoragePool.update(self.userapiclient, id=pool.id, enabled=False) + self.disabled_list.append(pool.id) + self.debug('Appended to list of disabled pools. List is now: % s ' % self.disabled_list) + except Exception as e: + self.fail("Couldn't disable storage % s" % pool.id) + else: + self.debug('No % s wide storage pools found' % other_scope) + except Exception as e: + raise e + + # Step 1: Deploy a VM and attach data disk to one VM + self.virtual_machine_1 = VirtualMachine.create(self.userapiclient, + self.testdata['small'], + templateid=self.template.id, + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.service_offering.id, + zoneid=self.zone.id) + verify_vm_state(self, self.virtual_machine_1.id, 'Running') + + self.volume_1 = Volume.create(self.userapiclient, + services=self.testdata['volume'], + diskofferingid=self.disk_offering.id, + zoneid=self.zone.id) + self.virtual_machine_1.attach_volume(self.userapiclient, self.volume_1) + list_volume = Volume.list(self.userapiclient, id=self.volume_1.id) + self.assertEqual(list_volume[0].virtualmachineid, + self.virtual_machine_1.id, '' + 'Check if volume state (attached) is reflected') + self.debug('Step 1: volume id:%s successfully attached to vm id%s' % (self.volume_1.id, self.virtual_machine_1.id)) + + # Step 2: Create Template from root volume of VM1 + root_volume_1 = Volume.list(self.userapiclient, virtualmachineid=self.virtual_machine_1.id, type='ROOT')[0] + self.virtual_machine_1.stop(self.userapiclient) + try: + template_2 = Template.create(self.userapiclient, + self.testdata['template_2'], + volumeid=root_volume_1.id, + account=self.account.name, + domainid=self.account.domainid) + self.cleanup.append(template_2) + self.debug('Step 2: Created template with ID: %s' % template_2.id) + list_template = Template.list(self.userapiclient, templatefilter='self', id=template_2.id) + except Exception as e: + self.fail('Step 2: Template from volume failed') + + # Step 3: Deploy a VM using the template + self.debug("Step 3: Deploying VM using template created") + self.virtual_machine_2 = VirtualMachine.create(self.userapiclient, + self.testdata['small'], + templateid=template_2.id, + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.service_offering.id, + zoneid=self.zone.id) + + verify_vm_state(self, self.virtual_machine_2.id, 'Running') + + # Step 4: Disable the storage pool + self.storage_pools_list = StoragePool.list(self.userapiclient, scope=value, state='Up') + self.storage_pool_1 = self.storage_pools_list[0] + try: + self.debug('Step 4: Disabling Storage Pool: %s' % self.storage_pool_1.id) + StoragePool.update(self.userapiclient, id=self.storage_pool_1.id, enabled=False) + self.disabled_list.append(self.storage_pool_1.id) + except Exception as e: + self.debug("Step 4: Couldn't disable pool %s" % e) + verify_pool_state(self, self.storage_pool_1.id, 'Disabled') + verify_vm_state(self, self.virtual_machine_1.id, 'Stopped') + verify_vm_state(self, self.virtual_machine_2.id, 'Running') + + # Step 5: Attach a new volume - should fail + self.volume_2 = Volume.create(self.userapiclient, + services=self.testdata['volume'], + diskofferingid=self.disk_offering.id, + zoneid=self.zone.id) + self.debug('Step 5: Trying to attach new volume to VM on disabled storage - should fail') + with self.assertRaises(Exception): + self.virtual_machine_2.attach_volume(self.userapiclient, self.volume_2) + + # Step 6: Resize DATA disk to a higher value for attached disk + try: + self.volume_1.resize(self.userapiclient, diskofferingid=self.resized_disk_offering.id) + list_volume_1 = Volume.list(self.userapiclient, id=self.volume_1.id) + self.assertEqual(list_volume_1[0].diskofferingid, + self.resized_disk_offering.id, + 'check list volume response for volume id: %s' % self.volume_1.id) + self.debug('Step 6: volume id %s got resized successfully' % list_volume_1[0].id) + except Exception as e: + self.fail('Step 6: Volume resize on disabled pool failed: % s' % e) + + # Step 7: Take VM Snapshot + if self.hypervisor.lower() not in ('kvm', 'hyperv', 'lxc'): + try: + self.debug("Step 7: Taking VM Snapshot for vm id % s" % self.virtual_machine_1.id) + vm_snapshot = VmSnapshot.create(self.userapiclient, + self.virtual_machine_1.id, + 'false', + 'TestSnapshot', + 'Display Text') + self.assertEqual(vm_snapshot.state, 'Ready', 'Check VM snapshot is ready') + except Exception as e: + self.fail('Step 7: VM Snapshot on disabled pool failed: % s' % e) + + # Step 8: Destroy VM and immediately restore the VM + self.debug("Step 8: Deleting and restoring the VM, should continue to run from same storage pool") + self.virtual_machine_1.delete(self.userapiclient, expunge=False) + self.virtual_machine_1.recover(self.userapiclient) + verify_vm_state(self, self.virtual_machine_1.id, 'Stopped') + self.virtual_machine_1.start(self.userapiclient) + verify_vm_state(self, self.virtual_machine_1.id, 'Running') + verify_vm_storage_pool(self, self.virtual_machine_1.id, self.storage_pool_1.id) + + # Step 9: Enable new pool + if self.disabled_pool_1: + try: + newpoolid = self.disabled_pool_1.id + StoragePool.update(self.userapiclient, id=newpoolid, enabled=True) + self.debug("Step 9: Enabling new pool % s " % newpoolid) + if newpoolid in self.disabled_list: + self.disabled_list.remove(newpoolid) + except Exception as e: + self.fail('Step 9: Enable storage pool %s' % e, 'failed') + else: + self.debug('Step 9: Could not find a second storage pool, so enabling the first storage pool and running the tests') + try: + self.debug('Step 9: Enabling Storage Pool: %s' % self.storage_pool_1.id) + StoragePool.update(self.userapiclient, id=self.storage_pool_1.id, enabled=True) + if self.storage_pool_1.id in self.disabled_list: + self.disabled_list.remove(self.storage_pool_1.id) + newpoolid = self.storage_pool_1.id + except Exception as e: + self.fail("Step 9: Couldn't enable pool %s" % e) + verify_pool_state(self, newpoolid, 'Up') + + # Step 10: Re-install the VM with same template + self.debug("Step 10: Re-installing VM 1") + vm_restore = self.virtual_machine_1.restore(self.userapiclient, templateid=self.template.id) + verify_vm_storage_pool(self, self.virtual_machine_1.id, newpoolid) + + # Step 11 : Re-install VM with different template + self.debug("Step 11: re-installing VM with different template") + vm_restore = self.virtual_machine_1.restore(self.userapiclient, templateid=template_2.id) + verify_vm_storage_pool(self, self.virtual_machine_1.id, newpoolid) + + # Step 12, Repeat tests with enabled pool. Start with attach VM + self.debug("Step 12: Attach volume to VM") + self.virtual_machine_1.attach_volume(self.userapiclient, self.volume_2) + list_volume_2 = Volume.list(self.userapiclient, id=self.volume_2.id) + self.assertEqual(list_volume_2[0].virtualmachineid, + self.virtual_machine_1.id, + 'Check if volume state (attached) is reflected') + self.debug('Step 12: volume id:% s successfully attached to vm id % s' % (self.volume_2.id, self.virtual_machine_1.id)) + + # Step 13: Re-size Volume to higher disk offering + try: + self.virtual_machine_1.stop(self.userapiclient) + self.volume_2.resize(self.userapiclient, diskofferingid=self.resized_disk_offering.id) + list_volume_2 = Volume.list(self.userapiclient, id=self.volume_2.id) + self.assertEqual(list_volume_2[0].diskofferingid, self.resized_disk_offering.id, 'check list volume response for volume id: %s' % self.volume_2.id) + self.debug('Step 13: volume id %s got resized successfully' % list_volume_2[0].id) + except Exception as e: + self.fail('Step 13: Failed to resize volume % s ' % e) + self.virtual_machine_1.start(self.userapiclient) + + # Step 14: Reboot VM + self.virtual_machine_1.reboot(self.userapiclient) + verify_vm_storage_pool(self, self.virtual_machine_1.id, newpoolid) + + # Step 15: Take Snapshot of VM + if self.hypervisor.lower() not in ('kvm', 'hyperv', 'lxc'): + try: + vm_snapshot = VmSnapshot.create(self.userapiclient, self.virtual_machine_1.id, 'false', 'TestSnapshot2', 'Display Text') + self.assertEqual(vm_snapshot.state, 'Ready', 'Check the snapshot of vm is ready!') + except Exception as e: + self.fail('Step 15: Snapshot failed post enabling new storage pool') + verify_vm_storage_pool(self, self.virtual_machine_1.id, newpoolid) + + # Step 16: Delete and recover VM + self.debug("Step 16: Deleting and recovering VM") + self.virtual_machine_1.delete(self.userapiclient, expunge=False) + self.virtual_machine_1.recover(self.userapiclient) + verify_vm_state(self, self.virtual_machine_1.id, 'Stopped') + self.virtual_machine_1.start(self.userapiclient) + verify_vm_state(self, self.virtual_machine_1.id, 'Running') + verify_vm_storage_pool(self, self.virtual_machine_1.id, newpoolid) + + +@ddt +class TestPathDisableStorage_Maint_Tags(cloudstackTestCase): + """ + # Tests in this path requires to be run independently (not to be run in parallel with any other tests since it involves disabling/enabling storage pools and may cause unexpected failures in other tests + # The test also requires to have 2 Cluster-wide and 2 zone-wide storage pools available in the setup. + # For running the tests on local storage, ensure there are 2 local storage pools set up on each host or different hosts + + """ + + + @classmethod + def setUpClass(cls): + testClient = super(TestPathDisableStorage_Maint_Tags, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.testdata = testClient.getParsedTestDataConfig() + cls.domain = get_domain(cls.apiclient) + cls.zone = get_zone(cls.apiclient) + cls.testdata['mode'] = cls.zone.networktype + cls.template = get_template(cls.apiclient, cls.zone.id, cls.testdata['ostype']) + cls.testdata['template']['ostypeid'] = cls.template.ostypeid + if cls.template == FAILED: + cls.fail('get_template() failed to return template with description %s' % cls.testdata['ostype']) + cls._cleanup = [] + cls.disabled_list = [] + cls.maint_list = [] + cls.testdata['template_2']['zoneid'] = cls.zone.id + cls.testdata['template_2']['ostypeid'] = cls.template.ostypeid + cls.hypervisor = testClient.getHypervisorInfo() + try: + cls.account = Account.create(cls.apiclient, + cls.testdata['account'], + admin=True) + cls.debug('Creating account') + cls._cleanup.append(cls.account) + + + # Create shared storage offerings + cls.service_offering_shared = ServiceOffering.create(cls.apiclient, + cls.testdata['service_offering'] + ) + cls._cleanup.append(cls.service_offering_shared) + cls.disk_offering_shared = DiskOffering.create(cls.apiclient, + cls.testdata['disk_offering'] + ) + cls.resized_disk_offering = DiskOffering.create(cls.apiclient, + cls.testdata['resized_disk_offering'] + ) + cls._cleanup.append(cls.disk_offering_shared) + + # Create offerings for local storage if local storage is enabled + if cls.zone.localstorageenabled: + cls.testdata["service_offerings"]["storagetype"] = 'local' + cls.debug("Creating local storage offering") + cls.service_offering_local = ServiceOffering.create(cls.apiclient, + cls.testdata["service_offerings"] + ) + cls._cleanup.append(cls.service_offering_local) + cls.testdata["disk_offering"]["storagetype"] = 'local' + cls.debug("Creating local storage disk offering") + cls.disk_offering_local = DiskOffering.create(cls.apiclient, + cls.testdata["disk_offering"] + ) + cls._cleanup.append(cls.disk_offering_local) + cls.testdata["disk_offering"]["storagetype"] = ' ' + cls.testdata["service_offerings"]["storagetype"] = ' ' + else: + cls.debug("No local storage found") + + cls.userapiclient = testClient.getUserApiClient(UserName=cls.account.name, DomainName=cls.account.domain) + response = User.login(cls.userapiclient, + username=cls.account.name, + password=cls.testdata['account']['password']) + assert response.sessionkey is not None + except Exception as e: + cls.tearDownClass() + raise e + + @classmethod + def tearDownClass(cls): + try: + cleanup_resources(cls.apiclient, cls._cleanup) + except Exception as e: + raise Exception('Warning:Exception during cleanup: %s' % e) + + def setUp(self): + self.apiclient = self.testClient.getApiClient() + self.cleanup = [] + + def tearDown(self): + if self.disabled_list: + for poolid in self.disabled_list: + if StoragePool.list(self.userapiclient, id=poolid)[0].state == 'Disabled': + try: + StoragePool.update(self.userapiclient, id=poolid, enabled=True) + self.debug('Enabling: % s ' % poolid) + except Exception as e: + self.fail("Couldn't enable storage % s" % id) + + if self.maint_list: + for poolid in self.maint_list: + if StoragePool.list(self.userapiclient, id=poolid)[0].state == 'Maintenance': + try: + StoragePool.cancelMaintenance(self.userapiclient, id=poolid) + self.debug('Cancelled Maintenance mode for % s' % poolid) + except Exception as e: + self.fail("Couldn't cancel Maintenance mode for storage % s " % poolid) + + try: + cleanup_resources(self.apiclient, self.cleanup) + except Exception as e: + self.fail('Warning: Exception during cleanup : %s' % e) + + + @data('host','CLUSTER', 'ZONE') + @attr(tags=['advanced', 'advancedsg', 'debug', 'basic'], required_hardware='false') + def test_01_maint_capacity_tags(self, value): + """ + + Test Steps: + ======== + + 1. Deploy VM + 2. Add storage to maintenance + 3. Cancel Maintenance + 4. Disable pool and then Start the VM - verify it runs off the same pool + 5. Perform more VM operations - reboot + 6. Add tags to pool + 7. Create tagged offering with same tags + 8. Enable pool + 9. Deploy VM using the tagged offering + 10. Disable storage pool again + 11. Calculate current capacity used so far for the storage pool + 12. Delete VM and check capacity is re-calculated in the disabled pool + 13. Perform VM deploy - should fail since pool is disabled + 14. Re-calculate Capacity, should not be altered + + + """ + + # Choose appropriate service offering depending on the scope the test is being run on + self.disabled_list = [] + if value == 'CLUSTER': + other_scope = 'ZONE' + self.service_offering = self.service_offering_shared + self.disk_offering = self.disk_offering_shared + elif value == 'ZONE': + other_scope = 'CLUSTER' + self.service_offering = self.service_offering_shared + self.disk_offering = self.disk_offering_shared + else: + # local storage + other_scope = None + self.service_offering = self.service_offering_local + self.disk_offering = self.disk_offering_local + + # Keep 2 storage pools active and disable the rest. If only one storage pool is present, then skip the test + try: + self.list_storage = StoragePool.list(self.userapiclient, scope=value) + count_st_pools = len(self.list_storage) + if count_st_pools <= 1: + raise unittest.SkipTest('Found 1 or less storage pools in % s wide scope- cannot proceed' % value) + elif count_st_pools > 2: + for pool in self.list_storage[2:]: + if pool.state == 'Up': + self.debug('Trying to disable storage %s' % pool.id) + try: + StoragePool.update(self.userapiclient, id=pool.id, enabled=False) + self.disabled_list.append(pool.id) + self.debug('Appended to list of disabled pools. List is now: % s ' % self.disabled_list) + except Exception as e: + raise e + elif count_st_pools == 2: + for pool in self.list_storage: + if pool.state != 'Up': + raise unittest.SkipTest('Found storage pool % s not in Up State.. cannot proceed' % pool.id) + except Exception as e: + raise e + + + # Disable the other scope shared storage pools while we are testing on one - applicable for only shared storage + if value != 'host': + try: + self.list_storage = StoragePool.list(self.userapiclient, scope=other_scope) + if self.list_storage: + for pool in self.list_storage: + if pool.state == 'Up': + self.debug('Trying to disable storage % s' % pool.id) + try: + StoragePool.update(self.userapiclient, id=pool.id, enabled=False) + self.disabled_list.append(pool.id) + self.debug('Appended to list of disabled pools. List is now: % s ' % self.disabled_list) + except Exception as e: + self.fail("Couldn't disable storage % s" % pool.id) + else: + self.debug('No % s wide storage pools found' % other_scope) + except Exception as e: + raise e + + self.debug("Step 1: Deploy VM") + self.virtual_machine_1 = VirtualMachine.create(self.userapiclient, + self.testdata['small'], + templateid=self.template.id, + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.service_offering.id, + zoneid=self.zone.id) + verify_vm_state(self, self.virtual_machine_1.id, 'Running') + + # Step 2: Add storage to Maintenance mode + self.debug("Step 2: Adding storage to maintenance mode ") + root_volume = Volume.list(self.userapiclient, virtualmachineid=self.virtual_machine_1.id, type='ROOT')[0] + list_volume = Volume.list(self.userapiclient, id=root_volume.id) + storage_id = list_volume[0].storageid + try: + StoragePool.enableMaintenance(self.userapiclient, id=storage_id) + self.debug('Step 2: Added % s to Maintenance mode') + self.maint_list.append(storage_id) + except Exception as e: + self.fail('Step 2: Failed to add Storage pool % s to Maintenance mode' % storage_id) + verify_vm_state(self, self.virtual_machine_1.id, 'Stopped') + + #Step 3: Cancel maintenance mode + try: + StoragePool.cancelMaintenance(self.userapiclient, id=storage_id) + self.debug('Step 3: Cancelled Maintenance mode for % s' % storage_id) + self.maint_list.remove(storage_id) + except Exception as e: + self.fail("Step 3: Couldn't cancel Maintenance mode for storage % s " % storage_id) + + # Step 4: Start the VM after disabling pool and verify it's running from same pool + try: + self.debug("Step 4: Starting VM after disabling pool") + self.list_storage = StoragePool.list(self.userapiclient, id=storage_id) + if self.list_storage[0].state == 'Up': + StoragePool.update(self.userapiclient, id=storage_id, enabled=False) + self.debug("Step 4: Disabled pool % s" % storage_id) + self.disabled_list.append(storage_id) + except Exception as e: + raise e + + list_vm = list_virtual_machines(self.userapiclient, account=self.account.name, domainid=self.account.domainid, id=self.virtual_machine_1.id) + vm = list_vm[0] + if vm.state != 'Running': + self.virtual_machine_1.start(self.userapiclient) + verify_vm_state(self, self.virtual_machine_1.id, 'Running') + verify_vm_storage_pool(self, self.virtual_machine_1.id, storage_id) + + # Step 5: Perform some VM operations - reboot + self.debug("Step 5: Performing reboot of VM % s" % self.virtual_machine_1.id) + self.virtual_machine_1.reboot(self.userapiclient) + verify_vm_storage_pool(self, self.virtual_machine_1.id, storage_id) + + # TO BE REMOVED + try: + self.list_storage = StoragePool.list(self.userapiclient, id=storage_id) + if self.list_storage[0].state == 'Disabled': + StoragePool.update(self.userapiclient, id=storage_id, enabled=True) + self.disabled_list.remove(storage_id) + except Exception as e: + raise e + + + # Step 6: Add tags to the storage pool + self.debug("Step 6: Adding tags to storage pool") + StoragePool.update(self.userapiclient, id=storage_id, tags='disable_prov') + + # Step 7: Add tagged service offering + self.testdata['service_offerings']['tags'] = 'disable_prov' + self.testdata["service_offerings"]["storagetype"] = 'local' + self.tagged_so = ServiceOffering.create(self.userapiclient, self.testdata['service_offerings']) + self.testdata['service_offerings']['tags'] = ' ' + self.testdata["service_offerings"]["storagetype"] = ' ' + self.cleanup.append(self.tagged_so) + + # Step 8: Enable the pool + try: + self.debug("Step 8: Enabling pool") + self.list_storage = StoragePool.list(self.userapiclient, id=storage_id) + if self.list_storage[0].state == 'Disabled': + StoragePool.update(self.userapiclient, id=storage_id, enabled=True) + self.disabled_list.remove(storage_id) + except Exception as e: + raise e + + # Step 9: Deploy VM using the tagged offering + self.debug("Step 9: Deploying VM using tagged offering") + self.virtual_machine_2 = VirtualMachine.create(self.userapiclient, + self.testdata['small'], + templateid=self.template.id, + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.tagged_so.id, + zoneid=self.zone.id) + verify_vm_state(self, self.virtual_machine_2.id, 'Running') + verify_vm_storage_pool(self, self.virtual_machine_2.id, storage_id) + + # Step 10: Disable storage Pool + try: + self.list_storage = StoragePool.list(self.userapiclient, id=storage_id) + if self.list_storage[0].state == 'Up': + StoragePool.update(self.userapiclient, id=storage_id, enabled=False) + if storage_id not in self.disabled_list: + self.disabled_list.append(storage_id) + except Exception as e: + raise e + + if value != 'host': + capacity_type = 2 + else: + capacity_type = 9 + + # Step 11: View current capacity of storage pool + self.debug("Step 11: Getting current capacity...") + list_capacity_allocated = Capacities.list(self.userapiclient, fetchlatest='true', type=capacity_type) + capacity_1 = list_capacity_allocated[0].capacityused + self.debug("Capacity 1: % s" % capacity_1) + + # Step 12: Delete VM and check capacity is recalculated in disabled pool + self.debug("Step 12: Deleting Vm and re-calculating capacity") + self.virtual_machine_2.delete(self.userapiclient) + list_capacity_allocated = Capacities.list(self.userapiclient, fetchlatest='true', type=capacity_type) + capacity_2 = list_capacity_allocated[0].capacityused + self.debug("Capacity 2: % s" % capacity_2) + self.assertGreater(capacity_1, + capacity_2, + 'Step 12: Capacity Used should be greater after VM delete although Storage is not enabled') + + # Step 13: Deploy new VM with tagged offering again - should fail + with self.assertRaises(Exception): + self.virtual_machine_3 = VirtualMachine.create(self.userapiclient, + self.testdata['small'], + templateid=self.template.id, + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.tagged_so.id, + zoneid=self.zone.id) + + # Step 14: Capacity should not be altered in disabled pool since deploy VM failed + self.debug("Step 14: Checking capacity is not altered after deploy VM fails") + list_capacity_allocated = Capacities.list(self.userapiclient, fetchlatest='true', type=capacity_type) + capacity_3 = list_capacity_allocated[0].capacityused + self.assertEqual(capacity_2, capacity_3, "Step 14: Capacity Used shouldn't be altered since VM deployment failed") + + +class TestPathDisableStorage_Cross_Cluster(cloudstackTestCase): + """ + # Tests in this path requires to be run independently (not to be run in parallel with any other tests \ + since it involves disabling/enabling storage pools and may cause unexpected failures in other tests + # This test atleast 2 Clusters in the set up wiht suitable hosts for migration. + # For running the tests on local storage, ensure there are 2 local storage pools set up on each host + + """ + + + @classmethod + def setUpClass(cls): + testClient = super(TestPathDisableStorage_Cross_Cluster, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.testdata = testClient.getParsedTestDataConfig() + cls.domain = get_domain(cls.apiclient) + cls.zone = get_zone(cls.apiclient) + cls.testdata['mode'] = cls.zone.networktype + cls.template = get_template(cls.apiclient, cls.zone.id, cls.testdata['ostype']) + cls.testdata['template']['ostypeid'] = cls.template.ostypeid + if cls.template == FAILED: + cls.fail('get_template() failed to return template with description %s' % cls.testdata['ostype']) + + cls._cleanup = [] + cls.disabled_list = [] + cls.maint_list = [] + cls.testdata['template_2']['zoneid'] = cls.zone.id + cls.testdata['template_2']['ostypeid'] = cls.template.ostypeid + cls.hypervisor = testClient.getHypervisorInfo() + + try: + cls.account = Account.create(cls.apiclient, cls.testdata['account'], admin=True) + cls.debug('Creating account') + cls._cleanup.append(cls.account) + cls.service_offering = ServiceOffering.create(cls.apiclient, + cls.testdata['service_offering']) + cls._cleanup.append(cls.service_offering) + cls.disk_offering = DiskOffering.create(cls.apiclient, + cls.testdata['disk_offering']) + cls.resized_disk_offering = DiskOffering.create(cls.apiclient, + cls.testdata['resized_disk_offering']) + cls._cleanup.append(cls.disk_offering) + + cls.userapiclient = testClient.getUserApiClient(UserName=cls.account.name, + DomainName=cls.account.domain) + response = User.login(cls.userapiclient, + username=cls.account.name, + password=cls.testdata['account']['password']) + assert response.sessionkey is not None + except Exception as e: + cls.tearDownClass() + raise e + + + @classmethod + def tearDownClass(cls): + try: + cleanup_resources(cls.apiclient, cls._cleanup) + except Exception as e: + raise Exception('Warning:Exception during cleanup: %s' % e) + + + def setUp(self): + self.apiclient = self.testClient.getApiClient() + self.cleanup = [] + + def tearDown(self): + if self.disabled_list: + for poolid in self.disabled_list: + if StoragePool.list(self.userapiclient, id=poolid)[0].state == 'Disabled': + try: + StoragePool.update(self.userapiclient, id=poolid, enabled=True) + self.debug('Enabling: % s ' % poolid) + except Exception as e: + self.fail("Couldn't enable storage % s" % id) + try: + cleanup_resources(self.apiclient, self.cleanup) + except Exception as e: + self.fail('Warning: Exception during cleanup : %s' % e) + + @attr(tags=['advanced', 'advancedsg', 'basic'], required_hardware='false') + def test_01_cross_cluster_attach_disk(self): + """ + Test Steps: + ======== + + 1. Deploy VM in one cluster + 2. Migrate to other cluster + 3. Add data disk, Attach to VM + 4. Disable first storage pool + 5. List for migration should not list the first pool anymore + 6. Stop VM and detach disk + 7. Enable first Pool + 8. Migrate root to first pool + 9. Now disable first pool again + 10. Attach the disk which is running from enabled pool - Should fail + 11.Enable pool again + 12. Attach disk should now pass + + """ + cluster_id_list = [] + clusters = list_clusters(self.userapiclient, listall='true') + if len(clusters) == 1: + raise unittest.SkipTest('Found only one cluster... skipping test') + for cluster in clusters: + try: + self.debug('Processing for cluster % s ' % cluster.id) + self.list_storage = StoragePool.list(self.userapiclient, clusterid=cluster.id, scope='CLUSTER') + count_st_pools = len(self.list_storage) + if count_st_pools > 1: + self.debug('Found % s storage pools in cluster % s, keeping one and disabling rest' % (count_st_pools, cluster.id)) + for pool in self.list_storage[1:]: + self.disabled_pool_1 = self.list_storage[1] + if pool.state == 'Up': + self.debug('Trying to disable storage %s' % pool.id) + try: + StoragePool.update(self.userapiclient, id=pool.id, enabled=False) + self.disabled_list.append(pool.id) + self.debug('Appended to list of disabled pools. List is now: % s ' % self.disabled_list) + except Exception as e: + raise e + elif count_st_pools == 1: + self.debug('Only one cluster wide storage found') + else: + self.fail('No cluster wide storage pools found') + except Exception as e: + raise e + + try: + self.list_storage = StoragePool.list(self.userapiclient, scope='ZONE') + if self.list_storage: + for pool in self.list_storage: + if pool.state == 'Up': + self.debug('Trying to disable storage % s' % pool.id) + try: + StoragePool.update(self.userapiclient, id=pool.id, enabled=False) + self.disabled_list.append(pool.id) + self.debug('Appended to list of disabled pools. List is now: % s ' % self.disabled_list) + except Exception as e: + self.fail("Couldn't disable storage % s" % pool.id) + else: + self.debug('No zone wide storage pools found') + except Exception as e: + raise e + + # Step 1: Deploy VM in a cluster + self.virtual_machine_1 = VirtualMachine.create(self.userapiclient, + self.testdata['small'], + templateid=self.template.id, + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.service_offering.id, + zoneid=self.zone.id) + verify_vm_state(self, self.virtual_machine_1.id, 'Running') + + root_vol = Volume.list(self.userapiclient, virtualmachineid=self.virtual_machine_1.id, type='ROOT')[0] + storage_1 = root_vol.storageid + host_1 = self.virtual_machine_1.hostid + self.debug("Step 1: VM1 is running on % s host and % s storage pool" % (host_1, storage_1)) + + # Step 2: Live Migrate VM to another cluster + hosts_for_migration = Host.listForMigration(self.userapiclient, virtualmachineid=self.virtual_machine_1.id) + self.debug('Step 2: List of hosts suitable for migration: % s ' % hosts_for_migration) + host_2 = None + for host in hosts_for_migration: + self.debug('Step 2: Host Requires storage motion is % s ' % host.requiresStorageMotion) + if host.requiresStorageMotion == True: + host_2 = host.id + + if host_2: + self.debug('Step 2: Migrating VM % s to Host % s' % (self.virtual_machine_1.id, host_2)) + self.virtual_machine_1.migrate_vm_with_volume(self.userapiclient, hostid=host_2) + else: + self.fail('Step 2: No host found suitable for migration') + + # Step 3: Add data disk and attach to VM + self.volume_1 = Volume.create(self.userapiclient, + services=self.testdata['volume'], + diskofferingid=self.disk_offering.id, + zoneid=self.zone.id) + self.virtual_machine_1.attach_volume(self.userapiclient, self.volume_1) + list_volume = Volume.list(self.userapiclient, id=self.volume_1.id) + + + self.assertEqual(list_volume[0].virtualmachineid, + self.virtual_machine_1.id, + 'Step 3: Check if volume state (attached) is reflected') + self.debug('Step 3: volume id:% s successfully attached to vm id % s' % (self.volume_1.id, self.virtual_machine_1.id)) + + root_vol = Volume.list(self.userapiclient, virtualmachineid=self.virtual_machine_1.id, type='ROOT')[0] + storage_2 = root_vol.storageid + data_vol = Volume.list(self.userapiclient, virtualmachineid=self.virtual_machine_1.id, type='DATA')[0] + self.debug("Step 3: Data Volume is in storage pool: % s" % data_vol.storageid) + self.assertEqual(data_vol.storageid, + root_vol.storageid, + "Step 3: Root and Data disk should be running from 2nd storage pool where the VM was live migrated") + + # Step 4: Disable first Storage Pool and verify it is not listed in hosts suitable for migration + try: + StoragePool.update(self.userapiclient, id=storage_1, enabled=False) + self.disabled_list.append(storage_1) + self.debug('Step 4: Appended to list of disabled pools. List is now: % s ' % self.disabled_list) + except Exception as e: + self.fail("Step 4: Couldn't disable storage % s" % storage_1) + + # Step 5: Disabled pool shouldn't be listed in hostsforMigration since all pools in the cluster are disabled + hosts_for_migration = Host.listForMigration(self.userapiclient, virtualmachineid=self.virtual_machine_1.id) + self.debug("Step 5: List of Hosts For Migration is % s" % hosts_for_migration) + if hosts_for_migration: + for host in hosts_for_migration: + if host_1 == host.id: + self.fail("Step 5: All pools in the cluster are disabled, hence host should not be listed for migration") + + # Step 6: Stop VM and Detach Disk + self.virtual_machine_1.stop(self.userapiclient) + verify_vm_state(self, self.virtual_machine_1.id, 'Stopped') + verify_vm_storage_pool(self, self.virtual_machine_1.id, storage_2) + self.debug("Step 6: Stopping VM and detaching disk") + self.virtual_machine_1.detach_volume(self.userapiclient, volume=self.volume_1) + + # Step 7, 8: Enable Pool for Migrating VM and disable again + try: + StoragePool.update(self.userapiclient, id=storage_1, enabled=True) + if storage_1 in self.disabled_list: + self.disabled_list.remove(storage_1) + except Exception as e: + self.fail("Step 7: Couldn't enable storage % s" % storage_1) + + + self.virtual_machine_1.start(self.userapiclient) + verify_vm_state(self, self.virtual_machine_1.id, 'Running') + + try: + self.debug('Step 8: Migrating VM % s to Host % s' % (self.virtual_machine_1.id, host_1)) + self.virtual_machine_1.migrate_vm_with_volume(self.userapiclient, hostid=host_1) + except Exception as e: + self.fail("Step 8: Couldn't live migrate VM to host % s due to % s" % (host_1, e)) + + # Step 9: disable pool again + try: + StoragePool.update(self.userapiclient, id=storage_1, enabled=False) + self.debug("Step 9: Disabling storage pool: % s " % storage_1) + self.disabled_list.append(storage_1) + except Exception as e: + self.fail("Step 9: Couldn't disable storage % s" % storage_1) + + + st_list = StoragePool.list(self.userapiclient, id=storage_1) + self.debug("9.5 Status of storage pool 1 % s is % s " % (st_list[0].name, st_list[0].state)) + + + # Step 10: Try to attach data disk running from enabled pool with Root running in disabled pool - this should fail + with self.assertRaises(Exception): + self.virtual_machine_1.attach_volume(self.userapiclient, self.volume_1) + self.debug("Step 10: Trying to attach volume % s" % self.volume_1.id) + + + # Step 11: Enable the pool and try to attach again - this should pass + try: + StoragePool.update(self.userapiclient, id=storage_1, enabled=True) + self.debug("Step 11: Enable storage pool: % s " % storage_1) + self.disabled_list.remove(storage_1) + except Exception as e: + self.fail("Step 11: Couldn't enable storage % s" % storage_1) + + # Step 12: Repeat attach volume - should succeed + self.virtual_machine_1.attach_volume(self.userapiclient, self.volume_1) + self.debug("Step 12: Trying to attach volume") + list_volume = Volume.list(self.userapiclient, id=self.volume_1.id) + + self.assertEqual(list_volume[0].virtualmachineid, + self.virtual_machine_1.id, + 'Step 12: Check if volume state (attached) is reflected') + self.debug('Step 12: volume id:%s successfully attached to vm id%s' % (self.volume_1.id, self.virtual_machine_1.id)) From a99c9d0e68b42725a9f174d94f8d91c8a05398f3 Mon Sep 17 00:00:00 2001 From: Devdeep Singh Date: Tue, 5 May 2015 18:24:04 +0530 Subject: [PATCH 065/175] Implementation for the ability to disable a storage pool for provisioning ... of new volumes. Following changes are implemented 1. Disable or enable a pool with the updateStoragePool api. A new 'enabled' parameter added for the same. 2. When a pool is disabled the state of the pool is updated to 'Disabled' in the db. On enabling it is updated back to 'Up'. Alert is raised when a pool is disabled or enabled. 3. Updated other storage providers to also honour the disabled state. 4. A disabled pool is skipped by allocators for provisioing of new volumes. 5. Since the allocators skip a disabled pool for provisioning of volumes, the volumes are also not listed as a destination for volume migration. FS: https://cwiki.apache.org/confluence/display/CLOUDSTACK/Disabling+Storage+Pool+for+Provisioning This closes #257 Signed-off-by: Rohit Yadav --- api/src/com/cloud/event/EventTypes.java | 9 +++++ .../com/cloud/storage/StoragePoolStatus.java | 2 +- .../admin/storage/UpdateStoragePoolCmd.java | 8 ++++ .../storage/PrimaryDataStoreLifeCycle.java | 2 + .../datastore/db/PrimaryDataStoreDao.java | 2 + .../datastore/db/PrimaryDataStoreDaoImpl.java | 21 +++++++++++ .../ClusterScopeStoragePoolAllocator.java | 16 +++++++- .../allocator/LocalStoragePoolAllocator.java | 11 ++++++ .../ZoneWideStoragePoolAllocator.java | 11 ++++++ .../datastore/PrimaryDataStoreHelper.java | 14 +++++++ .../ElastistorPrimaryDataStoreLifeCycle.java | 10 +++++ ...oudStackPrimaryDataStoreLifeCycleImpl.java | 10 +++++ .../NexentaPrimaryDataStoreLifeCycle.java | 10 +++++ .../SamplePrimaryDataStoreLifeCycleImpl.java | 8 ++++ .../SolidFirePrimaryDataStoreLifeCycle.java | 10 +++++ ...idFireSharedPrimaryDataStoreLifeCycle.java | 10 +++++ .../com/cloud/storage/StorageManagerImpl.java | 37 ++++++++++++++++++- 17 files changed, 187 insertions(+), 4 deletions(-) diff --git a/api/src/com/cloud/event/EventTypes.java b/api/src/com/cloud/event/EventTypes.java index 20f287a36c70..78236fabbbe3 100644 --- a/api/src/com/cloud/event/EventTypes.java +++ b/api/src/com/cloud/event/EventTypes.java @@ -54,6 +54,7 @@ import com.cloud.offering.ServiceOffering; import com.cloud.projects.Project; import com.cloud.server.ResourceTag; +import com.cloud.storage.StoragePool; import com.cloud.storage.GuestOS; import com.cloud.storage.GuestOSHypervisor; import com.cloud.storage.Snapshot; @@ -306,6 +307,10 @@ public class EventTypes { public static final String EVENT_MAINTENANCE_PREPARE = "MAINT.PREPARE"; public static final String EVENT_MAINTENANCE_PREPARE_PRIMARY_STORAGE = "MAINT.PREPARE.PS"; + // Primary storage pool + public static final String EVENT_ENABLE_PRIMARY_STORAGE = "ENABLE.PS"; + public static final String EVENT_DISABLE_PRIMARY_STORAGE = "DISABLE.PS"; + // VPN public static final String EVENT_REMOTE_ACCESS_VPN_CREATE = "VPN.REMOTE.ACCESS.CREATE"; public static final String EVENT_REMOTE_ACCESS_VPN_DESTROY = "VPN.REMOTE.ACCESS.DESTROY"; @@ -728,6 +733,10 @@ public class EventTypes { entityEventDetails.put(EVENT_MAINTENANCE_PREPARE, Host.class); entityEventDetails.put(EVENT_MAINTENANCE_PREPARE_PRIMARY_STORAGE, Host.class); + // Primary storage pool + entityEventDetails.put(EVENT_ENABLE_PRIMARY_STORAGE, StoragePool.class); + entityEventDetails.put(EVENT_DISABLE_PRIMARY_STORAGE, StoragePool.class); + // VPN entityEventDetails.put(EVENT_REMOTE_ACCESS_VPN_CREATE, RemoteAccessVpn.class); entityEventDetails.put(EVENT_REMOTE_ACCESS_VPN_DESTROY, RemoteAccessVpn.class); diff --git a/api/src/com/cloud/storage/StoragePoolStatus.java b/api/src/com/cloud/storage/StoragePoolStatus.java index c7ff0ff2879b..778d3881e3ea 100644 --- a/api/src/com/cloud/storage/StoragePoolStatus.java +++ b/api/src/com/cloud/storage/StoragePoolStatus.java @@ -17,5 +17,5 @@ package com.cloud.storage; public enum StoragePoolStatus { - Initial, Initialized, Creating, Attaching, Up, PrepareForMaintenance, ErrorInMaintenance, CancelMaintenance, Maintenance, Removed; + Initial, Initialized, Creating, Attaching, Up, PrepareForMaintenance, ErrorInMaintenance, CancelMaintenance, Maintenance, Disabled, Removed; } diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/UpdateStoragePoolCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/UpdateStoragePoolCmd.java index 3d1a77353257..6bf62282a7ae 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/storage/UpdateStoragePoolCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/storage/UpdateStoragePoolCmd.java @@ -54,6 +54,10 @@ public class UpdateStoragePoolCmd extends BaseCmd { @Parameter(name = ApiConstants.CAPACITY_BYTES, type = CommandType.LONG, required = false, description = "bytes CloudStack can provision from this storage pool") private Long capacityBytes; + @Parameter(name = ApiConstants.ENABLED, type = CommandType.BOOLEAN, required = false, description = "false to disable the pool for allocation of new volumes, true to" + + " enable it back.") + private Boolean enabled; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -74,6 +78,10 @@ public Long getCapacityBytes() { return capacityBytes; } + public Boolean getEnabled() { + return enabled; + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreLifeCycle.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreLifeCycle.java index 7640cf33abce..fcbc19c28b7b 100644 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreLifeCycle.java +++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreLifeCycle.java @@ -27,4 +27,6 @@ public interface PrimaryDataStoreLifeCycle extends DataStoreLifeCycle { public static final String CAPACITY_IOPS = "capacityIops"; void updateStoragePool(StoragePool storagePool, Map details); + void enableStoragePool(DataStore store); + void disableStoragePool(DataStore store); } diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java index a976bfbf6fe4..393954588221 100644 --- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java +++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java @@ -77,6 +77,8 @@ public interface PrimaryDataStoreDao extends GenericDao { List findPoolsByTags(long dcId, long podId, Long clusterId, String[] tags); + List findDisabledPoolsByScope(long dcId, Long podId, Long clusterId, ScopeType scope); + /** * Find pool by UUID. * diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java index ae2287e9181d..faf5291554a6 100644 --- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java +++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java @@ -76,6 +76,7 @@ public PrimaryDataStoreDaoImpl() { AllFieldSearch.and("datacenterId", AllFieldSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ); AllFieldSearch.and("hostAddress", AllFieldSearch.entity().getHostAddress(), SearchCriteria.Op.EQ); AllFieldSearch.and("status", AllFieldSearch.entity().getStatus(), SearchCriteria.Op.EQ); + AllFieldSearch.and("scope", AllFieldSearch.entity().getScope(), SearchCriteria.Op.EQ); AllFieldSearch.and("path", AllFieldSearch.entity().getPath(), SearchCriteria.Op.EQ); AllFieldSearch.and("podId", AllFieldSearch.entity().getPodId(), Op.EQ); AllFieldSearch.and("clusterId", AllFieldSearch.entity().getClusterId(), Op.EQ); @@ -309,6 +310,26 @@ public List findPoolsByTags(long dcId, long podId, Long clusterId return storagePools; } + @Override + public List findDisabledPoolsByScope(long dcId, Long podId, Long clusterId, ScopeType scope) { + List storagePools = null; + SearchCriteria sc = AllFieldSearch.create(); + sc.setParameters("status", StoragePoolStatus.Disabled); + sc.setParameters("scope", scope); + + if (scope == ScopeType.ZONE) { + sc.setParameters("datacenterId", dcId); + storagePools = listBy(sc); + } else if ((scope == ScopeType.CLUSTER || scope == ScopeType.HOST) && podId != null && clusterId != null) { + sc.setParameters("datacenterId", dcId); + sc.setParameters("podId", podId); + sc.setParameters("clusterId", clusterId); + storagePools = listBy(sc); + } + + return storagePools; + } + @Override public List findLocalStoragePoolsByTags(long dcId, long podId, Long clusterId, String[] tags) { List storagePools = null; diff --git a/engine/storage/src/org/apache/cloudstack/storage/allocator/ClusterScopeStoragePoolAllocator.java b/engine/storage/src/org/apache/cloudstack/storage/allocator/ClusterScopeStoragePoolAllocator.java index 0f4df4f1b030..d78bd09e017e 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/allocator/ClusterScopeStoragePoolAllocator.java +++ b/engine/storage/src/org/apache/cloudstack/storage/allocator/ClusterScopeStoragePoolAllocator.java @@ -33,6 +33,7 @@ import com.cloud.deploy.DeploymentPlan; import com.cloud.deploy.DeploymentPlanner.ExcludeList; import com.cloud.offering.ServiceOffering; +import com.cloud.storage.ScopeType; import com.cloud.storage.StoragePool; import com.cloud.storage.dao.DiskOfferingDao; import com.cloud.vm.DiskProfile; @@ -70,9 +71,20 @@ protected List select(DiskProfile dskCh, VirtualMachineProfile vmPr return null; } if (dskCh.getTags() != null && dskCh.getTags().length != 0) { - s_logger.debug("Looking for pools in dc: " + dcId + " pod:" + podId + " cluster:" + clusterId + " having tags:" + Arrays.toString(dskCh.getTags())); + s_logger.debug("Looking for pools in dc: " + dcId + " pod:" + podId + " cluster:" + clusterId + " having tags:" + Arrays.toString(dskCh.getTags()) + + ". Disabled pools will be ignored."); } else { - s_logger.debug("Looking for pools in dc: " + dcId + " pod:" + podId + " cluster:" + clusterId); + s_logger.debug("Looking for pools in dc: " + dcId + " pod:" + podId + " cluster:" + clusterId + ". Disabled pools will be ignored."); + } + + if (s_logger.isTraceEnabled()) { + // Log the pools details that are ignored because they are in disabled state + List disabledPools = _storagePoolDao.findDisabledPoolsByScope(dcId, podId, clusterId, ScopeType.CLUSTER); + if (disabledPools != null && !disabledPools.isEmpty()) { + for (StoragePoolVO pool : disabledPools) { + s_logger.trace("Ignoring pool " + pool + " as it is in disabled state."); + } + } } List pools = _storagePoolDao.findPoolsByTags(dcId, podId, clusterId, dskCh.getTags()); diff --git a/engine/storage/src/org/apache/cloudstack/storage/allocator/LocalStoragePoolAllocator.java b/engine/storage/src/org/apache/cloudstack/storage/allocator/LocalStoragePoolAllocator.java index 446e101141ba..a4edf76c1053 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/allocator/LocalStoragePoolAllocator.java +++ b/engine/storage/src/org/apache/cloudstack/storage/allocator/LocalStoragePoolAllocator.java @@ -35,6 +35,7 @@ import com.cloud.deploy.DeploymentPlan; import com.cloud.deploy.DeploymentPlanner.ExcludeList; import com.cloud.service.dao.ServiceOfferingDao; +import com.cloud.storage.ScopeType; import com.cloud.storage.StoragePool; import com.cloud.storage.dao.StoragePoolHostDao; import com.cloud.utils.NumbersUtil; @@ -69,6 +70,16 @@ protected List select(DiskProfile dskCh, VirtualMachineProfile vmPr return null; } + if (s_logger.isTraceEnabled()) { + // Log the pools details that are ignored because they are in disabled state + List disabledPools = _storagePoolDao.findDisabledPoolsByScope(plan.getDataCenterId(), plan.getPodId(), plan.getClusterId(), ScopeType.HOST); + if (disabledPools != null && !disabledPools.isEmpty()) { + for (StoragePoolVO pool : disabledPools) { + s_logger.trace("Ignoring pool " + pool + " as it is in disabled state."); + } + } + } + List suitablePools = new ArrayList(); // data disk and host identified from deploying vm (attach volume case) diff --git a/engine/storage/src/org/apache/cloudstack/storage/allocator/ZoneWideStoragePoolAllocator.java b/engine/storage/src/org/apache/cloudstack/storage/allocator/ZoneWideStoragePoolAllocator.java index b38b76f6bfa5..7a109669ab75 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/allocator/ZoneWideStoragePoolAllocator.java +++ b/engine/storage/src/org/apache/cloudstack/storage/allocator/ZoneWideStoragePoolAllocator.java @@ -33,6 +33,7 @@ import com.cloud.deploy.DeploymentPlan; import com.cloud.deploy.DeploymentPlanner.ExcludeList; import com.cloud.hypervisor.Hypervisor.HypervisorType; +import com.cloud.storage.ScopeType; import com.cloud.storage.StoragePool; import com.cloud.user.Account; import com.cloud.vm.DiskProfile; @@ -55,6 +56,16 @@ protected List select(DiskProfile dskCh, VirtualMachineProfile vmPr return null; } + if (s_logger.isTraceEnabled()) { + // Log the pools details that are ignored because they are in disabled state + List disabledPools = _storagePoolDao.findDisabledPoolsByScope(plan.getDataCenterId(), null, null, ScopeType.ZONE); + if (disabledPools != null && !disabledPools.isEmpty()) { + for (StoragePoolVO pool : disabledPools) { + s_logger.trace("Ignoring pool " + pool + " as it is in disabled state."); + } + } + } + List suitablePools = new ArrayList(); List storagePools = _storagePoolDao.findZoneWideStoragePoolsByTags(plan.getDataCenterId(), dskCh.getTags()); diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/datastore/PrimaryDataStoreHelper.java b/engine/storage/src/org/apache/cloudstack/storage/volume/datastore/PrimaryDataStoreHelper.java index ef0db853520c..8752c198e3d8 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/volume/datastore/PrimaryDataStoreHelper.java +++ b/engine/storage/src/org/apache/cloudstack/storage/volume/datastore/PrimaryDataStoreHelper.java @@ -192,6 +192,20 @@ public boolean cancelMaintain(DataStore store) { return true; } + public boolean disable(DataStore store) { + StoragePoolVO pool = this.dataStoreDao.findById(store.getId()); + pool.setStatus(StoragePoolStatus.Disabled); + this.dataStoreDao.update(pool.getId(), pool); + return true; + } + + public boolean enable(DataStore store) { + StoragePoolVO pool = this.dataStoreDao.findById(store.getId()); + pool.setStatus(StoragePoolStatus.Up); + dataStoreDao.update(pool.getId(), pool); + return true; + } + protected boolean deletePoolStats(Long poolId) { CapacityVO capacity1 = _capacityDao.findByHostIdType(poolId, Capacity.CAPACITY_TYPE_STORAGE); CapacityVO capacity2 = _capacityDao.findByHostIdType(poolId, Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED); diff --git a/plugins/storage/volume/cloudbyte/src/org/apache/cloudstack/storage/datastore/lifecycle/ElastistorPrimaryDataStoreLifeCycle.java b/plugins/storage/volume/cloudbyte/src/org/apache/cloudstack/storage/datastore/lifecycle/ElastistorPrimaryDataStoreLifeCycle.java index 1778d43be475..5a8ccf17fa12 100644 --- a/plugins/storage/volume/cloudbyte/src/org/apache/cloudstack/storage/datastore/lifecycle/ElastistorPrimaryDataStoreLifeCycle.java +++ b/plugins/storage/volume/cloudbyte/src/org/apache/cloudstack/storage/datastore/lifecycle/ElastistorPrimaryDataStoreLifeCycle.java @@ -464,6 +464,16 @@ public boolean cancelMaintain(DataStore store) { return true; } + @Override + public void enableStoragePool(DataStore dataStore) { + _dataStoreHelper.enable(dataStore); + } + + @Override + public void disableStoragePool(DataStore dataStore) { + _dataStoreHelper.disable(dataStore); + } + @SuppressWarnings("finally") @Override public boolean deleteDataStore(DataStore store) { diff --git a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java index d11342c03311..38e9d9c9d0cc 100644 --- a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java +++ b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java @@ -522,4 +522,14 @@ public boolean migrateToObjectStore(DataStore store) { @Override public void updateStoragePool(StoragePool storagePool, Map details) { } + + @Override + public void enableStoragePool(DataStore dataStore) { + dataStoreHelper.enable(dataStore); + } + + @Override + public void disableStoragePool(DataStore dataStore) { + dataStoreHelper.disable(dataStore); + } } diff --git a/plugins/storage/volume/nexenta/src/org/apache/cloudstack/storage/datastore/lifecylce/NexentaPrimaryDataStoreLifeCycle.java b/plugins/storage/volume/nexenta/src/org/apache/cloudstack/storage/datastore/lifecylce/NexentaPrimaryDataStoreLifeCycle.java index 493f2742e36f..4fffb348a8b7 100644 --- a/plugins/storage/volume/nexenta/src/org/apache/cloudstack/storage/datastore/lifecylce/NexentaPrimaryDataStoreLifeCycle.java +++ b/plugins/storage/volume/nexenta/src/org/apache/cloudstack/storage/datastore/lifecylce/NexentaPrimaryDataStoreLifeCycle.java @@ -165,6 +165,16 @@ public boolean cancelMaintain(DataStore store) { return true; } + @Override + public void enableStoragePool(DataStore dataStore) { + dataStoreHelper.enable(dataStore); + } + + @Override + public void disableStoragePool(DataStore dataStore) { + dataStoreHelper.disable(dataStore); + } + @Override public boolean deleteDataStore(DataStore store) { return dataStoreHelper.deletePrimaryDataStore(store); diff --git a/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SamplePrimaryDataStoreLifeCycleImpl.java b/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SamplePrimaryDataStoreLifeCycleImpl.java index ee38072879b1..3a0ce83f9513 100644 --- a/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SamplePrimaryDataStoreLifeCycleImpl.java +++ b/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SamplePrimaryDataStoreLifeCycleImpl.java @@ -138,4 +138,12 @@ public boolean migrateToObjectStore(DataStore store) { @Override public void updateStoragePool(StoragePool storagePool, Map details) { } + + @Override + public void enableStoragePool(DataStore store) { + } + + @Override + public void disableStoragePool(DataStore store) { + } } diff --git a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/lifecycle/SolidFirePrimaryDataStoreLifeCycle.java b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/lifecycle/SolidFirePrimaryDataStoreLifeCycle.java index 7c36416970b9..4b38f221df01 100644 --- a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/lifecycle/SolidFirePrimaryDataStoreLifeCycle.java +++ b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/lifecycle/SolidFirePrimaryDataStoreLifeCycle.java @@ -287,4 +287,14 @@ public void updateStoragePool(StoragePool storagePool, Map detai } } } + + @Override + public void enableStoragePool(DataStore dataStore) { + dataStoreHelper.enable(dataStore); + } + + @Override + public void disableStoragePool(DataStore dataStore) { + dataStoreHelper.disable(dataStore); + } } diff --git a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/lifecycle/SolidFireSharedPrimaryDataStoreLifeCycle.java b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/lifecycle/SolidFireSharedPrimaryDataStoreLifeCycle.java index 4fa49ef9daaf..bc22ac7342b4 100644 --- a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/lifecycle/SolidFireSharedPrimaryDataStoreLifeCycle.java +++ b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/lifecycle/SolidFireSharedPrimaryDataStoreLifeCycle.java @@ -659,4 +659,14 @@ public void updateStoragePool(StoragePool storagePool, Map detai SolidFireUtil.updateCsDbWithSolidFireIopsInfo(storagePool.getId(), _primaryDataStoreDao, _storagePoolDetailsDao, minIops, maxIops, burstIops); } + + @Override + public void enableStoragePool(DataStore dataStore) { + _primaryDataStoreHelper.enable(dataStore); + } + + @Override + public void disableStoragePool(DataStore dataStore) { + _primaryDataStoreHelper.disable(dataStore); + } } diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index f31095b68b80..e725ce30cd61 100644 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -116,6 +116,8 @@ import com.cloud.dc.DataCenterVO; import com.cloud.dc.dao.ClusterDao; import com.cloud.dc.dao.DataCenterDao; +import com.cloud.event.ActionEvent; +import com.cloud.event.EventTypes; import com.cloud.exception.AgentUnavailableException; import com.cloud.exception.ConnectionException; import com.cloud.exception.DiscoveryException; @@ -732,6 +734,32 @@ private Map extractApiParamAsMap(Map ds) { return details; } + @ActionEvent(eventType = EventTypes.EVENT_DISABLE_PRIMARY_STORAGE, eventDescription = "disable storage pool") + private void disablePrimaryStoragePool(StoragePoolVO primaryStorage) { + if (!primaryStorage.getStatus().equals(StoragePoolStatus.Up)) { + throw new InvalidParameterValueException("Primary storage with id " + primaryStorage.getId() + " cannot be disabled. Storage pool state : " + + primaryStorage.getStatus().toString()); + } + + DataStoreProvider provider = _dataStoreProviderMgr.getDataStoreProvider(primaryStorage.getStorageProviderName()); + DataStoreLifeCycle dataStoreLifeCycle = provider.getDataStoreLifeCycle(); + DataStore store = _dataStoreMgr.getDataStore(primaryStorage.getId(), DataStoreRole.Primary); + ((PrimaryDataStoreLifeCycle)dataStoreLifeCycle).disableStoragePool(store); + } + + @ActionEvent(eventType = EventTypes.EVENT_ENABLE_PRIMARY_STORAGE, eventDescription = "enable storage pool") + private void enablePrimaryStoragePool(StoragePoolVO primaryStorage) { + if (!primaryStorage.getStatus().equals(StoragePoolStatus.Disabled)) { + throw new InvalidParameterValueException("Primary storage with id " + primaryStorage.getId() + " cannot be enabled. Storage pool state : " + + primaryStorage.getStatus().toString()); + } + + DataStoreProvider provider = _dataStoreProviderMgr.getDataStoreProvider(primaryStorage.getStorageProviderName()); + DataStoreLifeCycle dataStoreLifeCycle = provider.getDataStoreLifeCycle(); + DataStore store = _dataStoreMgr.getDataStore(primaryStorage.getId(), DataStoreRole.Primary); + ((PrimaryDataStoreLifeCycle)dataStoreLifeCycle).enableStoragePool(store); + } + @Override public PrimaryDataStoreInfo updateStoragePool(UpdateStoragePoolCmd cmd) throws IllegalArgumentException { // Input validation @@ -816,7 +844,14 @@ public PrimaryDataStoreInfo updateStoragePool(UpdateStoragePoolCmd cmd) throws I } } - if (updatedDetails.size() >= 0) { + Boolean enabled = cmd.getEnabled(); + if (enabled != null) { + if (enabled) { + enablePrimaryStoragePool(pool); + } else { + disablePrimaryStoragePool(pool); + } + } else if (updatedDetails.size() >= 0) { _storagePoolDao.updateDetails(id, updatedDetails); } From dacdf97427f17ea80695898c40565da3be188e47 Mon Sep 17 00:00:00 2001 From: Gaurav Aradhye Date: Tue, 19 May 2015 16:55:05 +0530 Subject: [PATCH 066/175] CLOUDSTACK-8482: Enhacing recurring snapshots test cases Signed-off-by: Gaurav Aradhye This closes #260 --- .../component/test_recurring_snapshots.py | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/test/integration/component/test_recurring_snapshots.py b/test/integration/component/test_recurring_snapshots.py index 58dd769a0beb..9912fdab2601 100644 --- a/test/integration/component/test_recurring_snapshots.py +++ b/test/integration/component/test_recurring_snapshots.py @@ -104,7 +104,7 @@ def __init__(self): "recurring_snapshot": { "intervaltype": 'HOURLY', # Frequency of snapshots - "maxsnaps": 1, # Should be min 2 + "maxsnaps": 2, # Should be min 2 "schedule": 1, "timezone": 'US/Arizona', # Timezone Formats - @@ -182,15 +182,14 @@ def setUpClass(cls): cls.api_client, cls.services["service_offering"] ) - cls.virtual_machine = cls.virtual_machine_with_disk = \ + cls.virtual_machine_with_disk = \ VirtualMachine.create( cls.api_client, cls.services["server_with_disk"], templateid=template.id, accountid=cls.account.name, domainid=cls.account.domainid, - serviceofferingid=cls.service_offering.id, - mode=cls.services["mode"] + serviceofferingid=cls.service_offering.id ) cls.virtual_machine_without_disk = \ VirtualMachine.create( @@ -199,8 +198,7 @@ def setUpClass(cls): templateid=template.id, accountid=cls.account.name, domainid=cls.account.domainid, - serviceofferingid=cls.service_offering.id, - mode=cls.services["mode"] + serviceofferingid=cls.service_offering.id ) cls._cleanup = [ cls.service_offering, @@ -233,7 +231,7 @@ def tearDown(self): return @attr(speed="slow") - @attr(tags=["advanced", "advancedns", "smoke"], required_hardware="false") + @attr(tags=["advanced", "advancedns", "basic"], required_hardware="true") def test_recurring_snapshot_root_disk(self): """Test Recurring Snapshot Root Disk """ @@ -243,7 +241,7 @@ def test_recurring_snapshot_root_disk(self): volume = list_volumes( self.apiclient, - virtualmachineid=self.virtual_machine_with_disk.id, + virtualmachineid=self.virtual_machine_without_disk.id, type='ROOT', listall=True ) @@ -286,10 +284,12 @@ def test_recurring_snapshot_root_disk(self): self.services["recurring_snapshot"]["maxsnaps"], "Check interval type in list resources call" ) - # Sleep for (maxsnaps+1) hours to verify + + max_snapshots = self.services["recurring_snapshot"]["maxsnaps"] + # Sleep for (max_snapshots*2) hours to verify # only maxsnaps snapshots are retained time.sleep( - (self.services["recurring_snapshot"]["maxsnaps"]) * 3600 + (max_snapshots * 2) * 3600 ) timeout = self.services["timeout"] @@ -319,13 +319,13 @@ def test_recurring_snapshot_root_disk(self): self.assertEqual( len(snapshots), - self.services["recurring_snapshot"]["maxsnaps"], + max_snapshots, "Check maximum number of recurring snapshots retained" ) return @attr(speed="slow") - @attr(tags=["advanced", "advancedns", "smoke"], required_hardware="false") + @attr(tags=["advanced", "advancedns", "basic"], required_hardware="true") def test_recurring_snapshot_data_disk(self): """Test Recurring Snapshot data Disk """ @@ -382,10 +382,11 @@ def test_recurring_snapshot_data_disk(self): "Check interval type in list resources call" ) + max_snapshots = self.services["recurring_snapshot"]["maxsnaps"] # Sleep for (maxsnaps) hours to verify only maxsnaps snapshots are # retained time.sleep( - (self.services["recurring_snapshot"]["maxsnaps"]) * 3600 + (max_snapshots * 2) * 3600 ) timeout = self.services["timeout"] @@ -414,7 +415,7 @@ def test_recurring_snapshot_data_disk(self): ) self.assertEqual( len(snapshots), - self.services["recurring_snapshot"]["maxsnaps"], + max_snapshots, "Check maximum number of recurring snapshots retained" ) return From ab915b6c921452fa7999c1f882add4ea3a82419a Mon Sep 17 00:00:00 2001 From: Ian Southam Date: Tue, 19 May 2015 12:54:38 +0000 Subject: [PATCH 067/175] Allow forward to fix port forwarding rules --- .../debian/config/opt/cloud/bin/configure.py | 33 ++++++++++++++----- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/systemvm/patches/debian/config/opt/cloud/bin/configure.py b/systemvm/patches/debian/config/opt/cloud/bin/configure.py index 799e279a2cf1..c0b2ad513439 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/configure.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/configure.py @@ -529,7 +529,8 @@ def processForwardRule(self, rule): def forward_vr(self, rule): fw1 = "-A PREROUTING -d %s/32 -i %s -p %s -m %s --dport %s -j DNAT --to-destination %s:%s" % \ - ( rule['public_ip'], + ( + rule['public_ip'], self.getDeviceByIp(rule['public_ip']), rule['protocol'], rule['protocol'], @@ -538,7 +539,8 @@ def forward_vr(self, rule): self.portsToString(rule['internal_ports'], '-') ) fw2 = "-A PREROUTING -d %s/32 -i %s -p %s -m %s --dport %s -j DNAT --to-destination %s:%s" % \ - ( rule['public_ip'], + ( + rule['public_ip'], self.getDeviceByIp(rule['internal_ip']), rule['protocol'], rule['protocol'], @@ -547,7 +549,8 @@ def forward_vr(self, rule): self.portsToString(rule['internal_ports'], '-') ) fw3 = "-A OUTPUT -d %s/32 -p %s -m %s --dport %s -j DNAT --to-destination %s:%s" % \ - ( rule['public_ip'], + ( + rule['public_ip'], rule['protocol'], rule['protocol'], self.portsToString(rule['public_ports'], ':'), @@ -555,35 +558,47 @@ def forward_vr(self, rule): self.portsToString(rule['internal_ports'], '-') ) fw4 = "-j SNAT --to-source %s -A POSTROUTING -s %s -d %s/32 -o %s -p %s -m %s --dport %s" % \ - ( self.getGatewayByIp(rule['internal_ip']), + ( + self.getGatewayByIp(rule['internal_ip']), self.getNetworkByIp(rule['internal_ip']), rule['internal_ip'], self.getDeviceByIp(rule['internal_ip']), rule['protocol'], rule['protocol'], self.portsToString(rule['internal_ports'], ':') - ) + ) fw5 = "-A PREROUTING -d %s/32 -i %s -p %s -m %s --dport %s -j MARK --set-xmark %s/0xffffffff" % \ - ( rule['public_ip'], + ( + rule['public_ip'], self.getDeviceByIp(rule['public_ip']), rule['protocol'], rule['protocol'], self.portsToString(rule['public_ports'], ':'), hex(int(self.getDeviceByIp(rule['public_ip'])[3:])) - ) + ) fw6 = "-A PREROUTING -d %s/32 -i %s -p %s -m %s --dport %s -m state --state NEW -j CONNMARK --save-mark --nfmask 0xffffffff --ctmask 0xffffffff" % \ - ( rule['public_ip'], + ( + rule['public_ip'], self.getDeviceByIp(rule['public_ip']), rule['protocol'], rule['protocol'], self.portsToString(rule['public_ports'], ':'), - ) + ) + fw7 = "-A FORWARD -i %s -o %s -p %s -m %s --dport %s -m state --state NEW -j ACCEPT" % \ + ( + self.getDeviceByIp(rule['public_ip']), + self.getDeviceByIp(rule['internal_ip']), + rule['protocol'], + rule['protocol'], + self.portsToString(rule['internal_ports'], ':') + ) self.fw.append(["nat", "", fw1]) self.fw.append(["nat", "", fw2]) self.fw.append(["nat", "", fw3]) self.fw.append(["nat", "", fw4]) self.fw.append(["nat", "", fw5]) self.fw.append(["nat", "", fw6]) + self.fw.append(["", "", fw7]) def forward_vpc(self, rule): fw_prerout_rule = "-A PREROUTING -d %s/32 -i %s" % (rule["public_ip"], self.getDeviceByIp(rule['public_ip'])) From 3f7e31ed05edf7f235b13d168ff1a5db16b5e2f9 Mon Sep 17 00:00:00 2001 From: Koushik Das Date: Wed, 13 May 2015 17:35:29 +0530 Subject: [PATCH 068/175] CLOUDSTACK-8301: Enable configuring local storage use for system VMs at zone level Made system.vm.use.local.storage a zone level configuration. --- api/src/com/cloud/dc/DataCenter.java | 4 -- .../cloud/service/dao/ServiceOfferingDao.java | 6 +++ .../service/dao/ServiceOfferingDaoImpl.java | 38 +++++++++++++++ .../lb/ElasticLoadBalancerManagerImpl.java | 19 ++++---- .../network/lb/LoadBalanceRuleHandler.java | 26 +++++++--- .../lb/InternalLoadBalancerVMManagerImpl.java | 36 ++++++++++---- .../InternalLBVMManagerTest.java | 8 +++- .../InternalLBVMServiceTest.java | 10 +++- .../src/com/cloud/configuration/Config.java | 1 - .../ConfigurationManagerImpl.java | 48 ++++++------------- .../consoleproxy/ConsoleProxyManagerImpl.java | 48 +++++++++++-------- .../deploy/DeploymentPlanningManagerImpl.java | 36 ++++---------- .../VirtualNetworkApplianceManagerImpl.java | 15 +++--- .../com/cloud/storage/StorageManagerImpl.java | 13 ++++- .../RouterDeploymentDefinition.java | 24 ++++++++-- .../RouterDeploymentDefinitionBuilder.java | 4 ++ .../VpcRouterDeploymentDefinition.java | 6 +-- .../element/VirtualRouterElementTest.java | 6 ++- .../RouterDeploymentDefinitionTest.java | 13 +++-- .../RouterDeploymentDefinitionTestBase.java | 7 +++ .../VpcRouterDeploymentDefinitionTest.java | 14 +++--- .../SecondaryStorageManagerImpl.java | 48 ++++++++++++------- 22 files changed, 273 insertions(+), 157 deletions(-) diff --git a/api/src/com/cloud/dc/DataCenter.java b/api/src/com/cloud/dc/DataCenter.java index 6cd054e28bcf..5b3d3c01f300 100644 --- a/api/src/com/cloud/dc/DataCenter.java +++ b/api/src/com/cloud/dc/DataCenter.java @@ -20,7 +20,6 @@ import org.apache.cloudstack.acl.InfrastructureEntity; import org.apache.cloudstack.api.Identity; import org.apache.cloudstack.api.InternalIdentity; -import org.apache.cloudstack.framework.config.ConfigKey; import java.util.Map; @@ -28,9 +27,6 @@ * */ public interface DataCenter extends InfrastructureEntity, Grouping, Identity, InternalIdentity { - public static final String SystemVMUseLocalStorageCK = "system.vm.use.local.storage"; - public static final ConfigKey UseSystemVMLocalStorage = new ConfigKey(Boolean.class, SystemVMUseLocalStorageCK, "Advanced", "false", - "Indicates whether to use local storage pools or shared storage pools for system VMs.", true, ConfigKey.Scope.Zone, null); public enum NetworkType { Basic, Advanced, diff --git a/engine/schema/src/com/cloud/service/dao/ServiceOfferingDao.java b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDao.java index ab818538d2aa..98dc3178de4f 100644 --- a/engine/schema/src/com/cloud/service/dao/ServiceOfferingDao.java +++ b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDao.java @@ -20,7 +20,9 @@ import java.util.Map; import com.cloud.service.ServiceOfferingVO; +import com.cloud.storage.Storage.ProvisioningType; import com.cloud.utils.db.GenericDao; +import com.cloud.vm.VirtualMachine; /* * Data Access Object for service_offering table @@ -28,6 +30,10 @@ public interface ServiceOfferingDao extends GenericDao { ServiceOfferingVO findByName(String name); + List createSystemServiceOfferings(String name, String uniqueName, int cpuCount, int ramSize, int cpuSpeed, + Integer rateMbps, Integer multicastRateMbps, boolean offerHA, String displayText, ProvisioningType provisioningType, + boolean recreatable, String tags, boolean systemUse, VirtualMachine.Type vmType, boolean defaultUse); + ServiceOfferingVO persistSystemServiceOffering(ServiceOfferingVO vo); List findPublicServiceOfferings(); diff --git a/engine/schema/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java index a3ff45ca3ad3..a3ffbc1396df 100644 --- a/engine/schema/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java +++ b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java @@ -31,11 +31,13 @@ import com.cloud.event.UsageEventVO; import com.cloud.service.ServiceOfferingDetailsVO; import com.cloud.service.ServiceOfferingVO; +import com.cloud.storage.Storage.ProvisioningType; import com.cloud.utils.db.DB; import com.cloud.utils.db.GenericDaoBase; import com.cloud.utils.db.SearchBuilder; import com.cloud.utils.db.SearchCriteria; import com.cloud.utils.exception.CloudRuntimeException; +import com.cloud.vm.VirtualMachine; import com.cloud.vm.dao.UserVmDetailsDao; @Component @@ -110,6 +112,13 @@ public ServiceOfferingVO persistSystemServiceOffering(ServiceOfferingVO offering vo.setSpeed(500); update(vo.getId(), vo); } + if (!vo.getUniqueName().endsWith("-Local")) { + if (vo.getUseLocalStorage()) { + vo.setUniqueName(vo.getUniqueName() + "-Local"); + vo.setName(vo.getName() + " - Local Storage"); + update(vo.getId(), vo); + } + } return vo; } try { @@ -238,4 +247,33 @@ public ServiceOfferingVO getcomputeOffering(ServiceOfferingVO serviceOffering, M return dummyoffering; } + + @Override + public List createSystemServiceOfferings(String name, String uniqueName, int cpuCount, int ramSize, int cpuSpeed, + Integer rateMbps, Integer multicastRateMbps, boolean offerHA, String displayText, ProvisioningType provisioningType, + boolean recreatable, String tags, boolean systemUse, VirtualMachine.Type vmType, boolean defaultUse) { + List list = new ArrayList(); + ServiceOfferingVO offering = new ServiceOfferingVO(name, cpuCount, ramSize, cpuSpeed, rateMbps, multicastRateMbps, offerHA, displayText, + provisioningType, false, recreatable, tags, systemUse, vmType, defaultUse); + offering.setUniqueName(uniqueName); + offering = persistSystemServiceOffering(offering); + if (offering != null) { + list.add(offering); + } + + boolean useLocal = true; + if (offering.getUseLocalStorage()) { // if 1st one is already local then 2nd needs to be shared + useLocal = false; + } + + offering = new ServiceOfferingVO(name + (useLocal ? " - Local Storage" : ""), cpuCount, ramSize, cpuSpeed, rateMbps, multicastRateMbps, offerHA, displayText, + provisioningType, useLocal, recreatable, tags, systemUse, vmType, defaultUse); + offering.setUniqueName(uniqueName + (useLocal ? "-Local" : "")); + offering = persistSystemServiceOffering(offering); + if (offering != null) { + list.add(offering); + } + + return list; + } } diff --git a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java index d853299eefdb..9aba5ae4d013 100644 --- a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java +++ b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java @@ -148,7 +148,6 @@ public class ElasticLoadBalancerManagerImpl extends ManagerBase implements Elast TrafficType _frontendTrafficType = TrafficType.Guest; Account _systemAcct; - ServiceOfferingVO _elasticLbVmOffering; ScheduledExecutorService _gcThreadPool; String _mgmtCidr; @@ -290,16 +289,18 @@ public boolean configure(String name, Map params) throws Configu } _mgmtCidr = _configDao.getValue(Config.ManagementNetwork.key()); - boolean useLocalStorage = Boolean.parseBoolean(configs.get(DataCenter.SystemVMUseLocalStorageCK)); - _elasticLbVmRamSize = NumbersUtil.parseInt(configs.get(Config.ElasticLoadBalancerVmMemory.key()), DEFAULT_ELB_VM_RAMSIZE); _elasticLbvmCpuMHz = NumbersUtil.parseInt(configs.get(Config.ElasticLoadBalancerVmCpuMhz.key()), DEFAULT_ELB_VM_CPU_MHZ); _elasticLbvmNumCpu = NumbersUtil.parseInt(configs.get(Config.ElasticLoadBalancerVmNumVcpu.key()), 1); - _elasticLbVmOffering = new ServiceOfferingVO("System Offering For Elastic LB VM", _elasticLbvmNumCpu, - _elasticLbVmRamSize, _elasticLbvmCpuMHz, 0, 0, true, null, Storage.ProvisioningType.THIN, useLocalStorage, - true, null, true, VirtualMachine.Type.ElasticLoadBalancerVm, true); - _elasticLbVmOffering.setUniqueName(ServiceOffering.elbVmDefaultOffUniqueName); - _elasticLbVmOffering = _serviceOfferingDao.persistSystemServiceOffering(_elasticLbVmOffering); + List offerings = _serviceOfferingDao.createSystemServiceOfferings("System Offering For Elastic LB VM", + ServiceOffering.elbVmDefaultOffUniqueName, _elasticLbvmNumCpu, _elasticLbVmRamSize, _elasticLbvmCpuMHz, 0, 0, true, null, + Storage.ProvisioningType.THIN, true, null, true, VirtualMachine.Type.ElasticLoadBalancerVm, true); + // this can sometimes happen, if DB is manually or programmatically manipulated + if (offerings == null || offerings.size() < 2) { + String msg = "Data integrity problem : System Offering For Elastic LB VM has been removed?"; + s_logger.error(msg); + throw new ConfigurationException(msg); + } String enabled = _configDao.getValue(Config.ElasticLoadBalancerEnabled.key()); _enabled = (enabled == null) ? false : Boolean.parseBoolean(enabled); @@ -322,7 +323,7 @@ public boolean configure(String name, Map params) throws Configu _itMgr.registerGuru(VirtualMachine.Type.ElasticLoadBalancerVm, this); } - loadBalanceRuleHandler = new LoadBalanceRuleHandler(_elasticLbVmOffering, _instance, _systemAcct); + loadBalanceRuleHandler = new LoadBalanceRuleHandler(_instance, _systemAcct); return true; } diff --git a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/LoadBalanceRuleHandler.java b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/LoadBalanceRuleHandler.java index 497913f2e925..f2c4685280ad 100644 --- a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/LoadBalanceRuleHandler.java +++ b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/LoadBalanceRuleHandler.java @@ -32,6 +32,7 @@ import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; import org.apache.log4j.Logger; +import com.cloud.configuration.ConfigurationManagerImpl; import com.cloud.dc.DataCenter; import com.cloud.dc.Pod; import com.cloud.dc.PodVlanMapVO; @@ -70,8 +71,10 @@ import com.cloud.network.router.VirtualRouter.Role; import com.cloud.network.rules.LoadBalancer; import com.cloud.offering.NetworkOffering; +import com.cloud.offering.ServiceOffering; import com.cloud.offerings.dao.NetworkOfferingDao; import com.cloud.service.ServiceOfferingVO; +import com.cloud.service.dao.ServiceOfferingDao; import com.cloud.storage.VMTemplateVO; import com.cloud.storage.dao.VMTemplateDao; import com.cloud.user.Account; @@ -141,16 +144,16 @@ public class LoadBalanceRuleHandler { @Inject private VirtualRouterProviderDao _vrProviderDao; @Inject + private ServiceOfferingDao _serviceOfferingDao; + @Inject private UserDao _userDao; static final private String ELB_VM_NAME_PREFIX = "l"; - private final ServiceOfferingVO _elasticLbVmOffering; private final String _instance; private final Account _systemAcct; - public LoadBalanceRuleHandler(final ServiceOfferingVO elasticLbVmOffering, final String instance, final Account systemAcct) { - _elasticLbVmOffering = elasticLbVmOffering; + public LoadBalanceRuleHandler(String instance, Account systemAcct) { _instance = instance; _systemAcct = systemAcct; } @@ -279,12 +282,23 @@ private DomainRouterVO deployELBVm(Network guestNetwork, final DeployDestination userId = _userDao.listByAccount(owner.getAccountId()).get(0).getId(); } - elbVm = new DomainRouterVO(id, _elasticLbVmOffering.getId(), vrProvider.getId(), VirtualMachineName.getSystemVmName(id, _instance, ELB_VM_NAME_PREFIX), + String offeringName = ServiceOffering.elbVmDefaultOffUniqueName; + Boolean useLocalStorage = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId()); + if (useLocalStorage != null && useLocalStorage.booleanValue()) { + offeringName += "-Local"; + } + ServiceOfferingVO elasticLbVmOffering = _serviceOfferingDao.findByName(offeringName); + if (elasticLbVmOffering == null) { + String message = "System service offering " + offeringName + " not found"; + s_logger.error(message); + throw new CloudRuntimeException(message); + } + elbVm = new DomainRouterVO(id, elasticLbVmOffering.getId(), vrProvider.getId(), VirtualMachineName.getSystemVmName(id, _instance, ELB_VM_NAME_PREFIX), template.getId(), template.getHypervisorType(), template.getGuestOSId(), owner.getDomainId(), owner.getId(), userId, false, RedundantState.UNKNOWN, - _elasticLbVmOffering.getOfferHA(), false, null); + elasticLbVmOffering.getOfferHA(), false, null); elbVm.setRole(Role.LB); elbVm = _routerDao.persist(elbVm); - _itMgr.allocate(elbVm.getInstanceName(), template, _elasticLbVmOffering, networks, plan, null); + _itMgr.allocate(elbVm.getInstanceName(), template, elasticLbVmOffering, networks, plan, null); elbVm = _routerDao.findById(elbVm.getId()); //TODO: create usage stats } diff --git a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java index affbd5c0d1e8..818ad88b07ae 100644 --- a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java +++ b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java @@ -46,6 +46,7 @@ import com.cloud.agent.api.to.LoadBalancerTO; import com.cloud.agent.manager.Commands; import com.cloud.configuration.Config; +import com.cloud.configuration.ConfigurationManagerImpl; import com.cloud.dc.DataCenter; import com.cloud.dc.DataCenterVO; import com.cloud.dc.dao.DataCenterDao; @@ -380,15 +381,15 @@ public boolean configure(final String name, final Map params) th //if offering wasn't set, try to get the default one if (_internalLbVmOfferingId == 0L) { - final boolean useLocalStorage = Boolean.parseBoolean(configs.get(DataCenter.SystemVMUseLocalStorageCK)); - ServiceOfferingVO newOff = - new ServiceOfferingVO("System Offering For Internal LB VM", 1, InternalLoadBalancerVMManager.DEFAULT_INTERNALLB_VM_RAMSIZE, - InternalLoadBalancerVMManager.DEFAULT_INTERNALLB_VM_CPU_MHZ, null, null, true, null, - Storage.ProvisioningType.THIN, useLocalStorage, true, null, true, - VirtualMachine.Type.InternalLoadBalancerVm, true); - newOff.setUniqueName(ServiceOffering.internalLbVmDefaultOffUniqueName); - newOff = _serviceOfferingDao.persistSystemServiceOffering(newOff); - _internalLbVmOfferingId = newOff.getId(); + List offerings = _serviceOfferingDao.createSystemServiceOfferings("System Offering For Internal LB VM", + ServiceOffering.internalLbVmDefaultOffUniqueName, 1, InternalLoadBalancerVMManager.DEFAULT_INTERNALLB_VM_RAMSIZE, + InternalLoadBalancerVMManager.DEFAULT_INTERNALLB_VM_CPU_MHZ, null, null, true, null, + Storage.ProvisioningType.THIN, true, null, true, VirtualMachine.Type.InternalLoadBalancerVm, true); + if (offerings == null || offerings.size() < 2) { + String msg = "Data integrity problem : System Offering For Internal LB VM has been removed?"; + s_logger.error(msg); + throw new ConfigurationException(msg); + } } _itMgr.registerGuru(VirtualMachine.Type.InternalLoadBalancerVm, this); @@ -620,9 +621,24 @@ protected List findOrDeployInternalLbVm(final Network guestNetwo } final LinkedHashMap> networks = createInternalLbVmNetworks(guestNetwork, plan, requestedGuestIp); + long internalLbVmOfferingId = _internalLbVmOfferingId; + if (internalLbVmOfferingId == 0L) { + String offeringName = ServiceOffering.internalLbVmDefaultOffUniqueName; + Boolean useLocalStorage = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId()); + if (useLocalStorage != null && useLocalStorage.booleanValue()) { + offeringName += "-Local"; + } + ServiceOfferingVO serviceOffering = _serviceOfferingDao.findByName(offeringName); + if (serviceOffering == null) { + String message = "System service offering " + offeringName + " not found"; + s_logger.error(message); + throw new CloudRuntimeException(message); + } + internalLbVmOfferingId = serviceOffering.getId(); + } //Pass startVm=false as we are holding the network lock that needs to be released at the end of vm allocation final DomainRouterVO internalLbVm = - deployInternalLbVm(owner, dest, plan, params, internalLbProviderId, _internalLbVmOfferingId, guestNetwork.getVpcId(), networks, false); + deployInternalLbVm(owner, dest, plan, params, internalLbProviderId, internalLbVmOfferingId, guestNetwork.getVpcId(), networks, false); if (internalLbVm != null) { _internalLbVmDao.addRouterToGuestNetwork(internalLbVm, guestNetwork); internalLbVms.add(internalLbVm); diff --git a/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMManagerTest.java b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMManagerTest.java index 0b47b1f5418d..bc48d468ded2 100644 --- a/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMManagerTest.java +++ b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMManagerTest.java @@ -59,6 +59,7 @@ import com.cloud.service.ServiceOfferingVO; import com.cloud.service.dao.ServiceOfferingDao; import com.cloud.storage.Storage; +import com.cloud.storage.Storage.ProvisioningType; import com.cloud.user.AccountManager; import com.cloud.user.AccountVO; import com.cloud.utils.component.ComponentContext; @@ -120,7 +121,12 @@ public void setUp() { ServiceOfferingVO off = new ServiceOfferingVO("alena", 1, 1, 1, 1, 1, false, "alena", Storage.ProvisioningType.THIN, false, false, null, false, VirtualMachine.Type.InternalLoadBalancerVm, false); off = setId(off, 1); - Mockito.when(_svcOffDao.persistSystemServiceOffering(Matchers.any(ServiceOfferingVO.class))).thenReturn(off); + List list = new ArrayList(); + list.add(off); + list.add(off); + Mockito.when(_svcOffDao.createSystemServiceOfferings(Matchers.anyString(), Matchers.anyString(), Matchers.anyInt(), Matchers.anyInt(), Matchers.anyInt(), + Matchers.anyInt(), Matchers.anyInt(), Matchers.anyBoolean(), Matchers.anyString(), Matchers.any(ProvisioningType.class), Matchers.anyBoolean(), + Matchers.anyString(), Matchers.anyBoolean(), Matchers.any(VirtualMachine.Type.class), Matchers.anyBoolean())).thenReturn(list); ComponentContext.initComponentsLifeCycle(); diff --git a/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMServiceTest.java b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMServiceTest.java index e376e51485d2..84c5f1ba6abb 100644 --- a/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMServiceTest.java +++ b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMServiceTest.java @@ -17,6 +17,8 @@ package org.apache.cloudstack.internallbvmmgr; import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; import javax.inject.Inject; @@ -44,6 +46,7 @@ import com.cloud.service.ServiceOfferingVO; import com.cloud.service.dao.ServiceOfferingDao; import com.cloud.storage.Storage; +import com.cloud.storage.Storage.ProvisioningType; import com.cloud.user.AccountManager; import com.cloud.user.AccountVO; import com.cloud.user.UserVO; @@ -90,7 +93,12 @@ public void setUp() { ServiceOfferingVO off = new ServiceOfferingVO("alena", 1, 1, 1, 1, 1, false, "alena", Storage.ProvisioningType.THIN, false, false, null, false, VirtualMachine.Type.InternalLoadBalancerVm, false); off = setId(off, 1); - Mockito.when(_svcOffDao.persistSystemServiceOffering(Matchers.any(ServiceOfferingVO.class))).thenReturn(off); + List list = new ArrayList(); + list.add(off); + list.add(off); + Mockito.when(_svcOffDao.createSystemServiceOfferings(Matchers.anyString(), Matchers.anyString(), Matchers.anyInt(), Matchers.anyInt(), Matchers.anyInt(), + Matchers.anyInt(), Matchers.anyInt(), Matchers.anyBoolean(), Matchers.anyString(), Matchers.any(ProvisioningType.class), Matchers.anyBoolean(), + Matchers.anyString(), Matchers.anyBoolean(), Matchers.any(VirtualMachine.Type.class), Matchers.anyBoolean())).thenReturn(list); ComponentContext.initComponentsLifeCycle(); diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java index 8dcddc838538..2352313e7bdd 100644 --- a/server/src/com/cloud/configuration/Config.java +++ b/server/src/com/cloud/configuration/Config.java @@ -685,7 +685,6 @@ public enum Config { "/var/cloudstack/mnt", "The mount point on the Management Server for Secondary Storage.", null), -// UpgradeURL("Advanced", ManagementServer.class, String.class, "upgrade.url", "http://example.com:8080/client/agent/update.zip", "The upgrade URL is the URL of the management server that agents will connect to in order to automatically upgrade.", null), SystemVMAutoReserveCapacity( "Advanced", ManagementServer.class, diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index a73969540c66..d08cac6566d4 100644 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -38,7 +38,6 @@ import javax.naming.ConfigurationException; import org.apache.log4j.Logger; - import org.apache.cloudstack.acl.SecurityChecker; import org.apache.cloudstack.affinity.AffinityGroup; import org.apache.cloudstack.affinity.AffinityGroupService; @@ -72,6 +71,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; import org.apache.cloudstack.framework.config.ConfigDepot; import org.apache.cloudstack.framework.config.ConfigKey; +import org.apache.cloudstack.framework.config.Configurable; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.framework.config.impl.ConfigurationVO; import org.apache.cloudstack.region.PortableIp; @@ -215,7 +215,7 @@ import com.cloud.vm.dao.NicSecondaryIpDao; @Local(value = {ConfigurationManager.class, ConfigurationService.class}) -public class ConfigurationManagerImpl extends ManagerBase implements ConfigurationManager, ConfigurationService { +public class ConfigurationManagerImpl extends ManagerBase implements ConfigurationManager, ConfigurationService, Configurable { public static final Logger s_logger = Logger.getLogger(ConfigurationManagerImpl.class); @Inject @@ -335,6 +335,9 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati private Set weightBasedParametersForValidation; private Set overprovisioningFactorsForValidation; + public static final ConfigKey SystemVMUseLocalStorage = new ConfigKey(Boolean.class, "system.vm.use.local.storage", "Advanced", "false", + "Indicates whether to use local storage pools or shared storage pools for system VMs.", false, ConfigKey.Scope.Zone, null); + @Override public boolean configure(final String name, final Map params) throws ConfigurationException { String maxVolumeSizeInGbString = _configDao.getValue(Config.MaxVolumeSize.key()); @@ -575,35 +578,7 @@ public String updateConfiguration(long userId, String name, String category, Str } catch (Throwable e) { throw new CloudRuntimeException("Failed to update storage.network.device2 in host_details due to exception ", e); } - } else if (DataCenter.SystemVMUseLocalStorageCK.equalsIgnoreCase(name)) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("Config 'system.vm.use.local.storage' changed to value:" + value + ", need to update System VM offerings"); - } - boolean useLocalStorage = Boolean.parseBoolean(_configDao.getValue(DataCenter.SystemVMUseLocalStorageCK)); - ServiceOfferingVO serviceOffering = _serviceOfferingDao.findByName(ServiceOffering.consoleProxyDefaultOffUniqueName); - if (serviceOffering != null) { - serviceOffering.setUseLocalStorage(useLocalStorage); - if (!_serviceOfferingDao.update(serviceOffering.getId(), serviceOffering)) { - throw new CloudRuntimeException("Failed to update ConsoleProxy offering's use_local_storage option to value:" + useLocalStorage); - } - } - - serviceOffering = _serviceOfferingDao.findByName(ServiceOffering.routerDefaultOffUniqueName); - if (serviceOffering != null) { - serviceOffering.setUseLocalStorage(useLocalStorage); - if (!_serviceOfferingDao.update(serviceOffering.getId(), serviceOffering)) { - throw new CloudRuntimeException("Failed to update SoftwareRouter offering's use_local_storage option to value:" + useLocalStorage); - } - } - - serviceOffering = _serviceOfferingDao.findByName(ServiceOffering.ssvmDefaultOffUniqueName); - if (serviceOffering != null) { - serviceOffering.setUseLocalStorage(useLocalStorage); - if (!_serviceOfferingDao.update(serviceOffering.getId(), serviceOffering)) { - throw new CloudRuntimeException("Failed to update SecondaryStorage offering's use_local_storage option to value:" + useLocalStorage); - } - } - }else if (Config.SecStorageSecureCopyCert.key().equalsIgnoreCase(name)) { + } else if (Config.SecStorageSecureCopyCert.key().equalsIgnoreCase(name)) { //FIXME - Ideally there should be a listener model to listen to global config changes and be able to take action gracefully. //Expire the download urls String sqlTemplate = "update template_store_ref set download_url_created=?"; @@ -622,8 +597,6 @@ public String updateConfiguration(long userId, String name, String category, Str } catch (Throwable e) { throw new CloudRuntimeException("Failed to clean up download URLs in template_store_ref or volume_store_ref due to exception ", e); } - - } txn.commit(); @@ -5200,4 +5173,13 @@ public void setSecChecker(List secChecker) { _secChecker = secChecker; } + @Override + public String getConfigComponentName() { + return ConfigurationManagerImpl.class.getSimpleName(); + } + + @Override + public ConfigKey[] getConfigKeys() { + return new ConfigKey[] {SystemVMUseLocalStorage}; + } } diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java index bfcef5f93cea..f8d7474cb224 100644 --- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java +++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java @@ -60,6 +60,7 @@ import com.cloud.agent.manager.Commands; import com.cloud.cluster.ClusterManager; import com.cloud.configuration.Config; +import com.cloud.configuration.ConfigurationManagerImpl; import com.cloud.configuration.ZoneConfig; import com.cloud.dc.DataCenter; import com.cloud.dc.DataCenter.NetworkType; @@ -225,7 +226,6 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy private int _capacityPerProxy = ConsoleProxyManager.DEFAULT_PROXY_CAPACITY; private int _standbyCapacity = ConsoleProxyManager.DEFAULT_STANDBY_CAPACITY; - private boolean _useLvm; private boolean _useStorageVm; private boolean _disableRpFilter = false; private String _instance; @@ -716,13 +716,27 @@ protected Map createProxyInstance(long dataCenterId, VMTemplateV networks.put(_networkMgr.setupNetwork(systemAcct, offering, plan, null, null, false).get(0), new ArrayList()); } + ServiceOfferingVO serviceOffering = _serviceOffering; + if (serviceOffering == null) { + String offeringName = ServiceOffering.consoleProxyDefaultOffUniqueName; + Boolean useLocalStorage = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dataCenterId); + if (useLocalStorage != null && useLocalStorage.booleanValue()) { + offeringName += "-Local"; + } + serviceOffering = _offeringDao.findByName(offeringName); + if (serviceOffering == null) { + String message = "System service offering " + offeringName + " not found"; + s_logger.error(message); + throw new CloudRuntimeException(message); + } + } ConsoleProxyVO proxy = - new ConsoleProxyVO(id, _serviceOffering.getId(), name, template.getId(), template.getHypervisorType(), template.getGuestOSId(), dataCenterId, - systemAcct.getDomainId(), systemAcct.getId(), _accountMgr.getSystemUser().getId(), 0, _serviceOffering.getOfferHA()); + new ConsoleProxyVO(id, serviceOffering.getId(), name, template.getId(), template.getHypervisorType(), template.getGuestOSId(), dataCenterId, + systemAcct.getDomainId(), systemAcct.getId(), _accountMgr.getSystemUser().getId(), 0, serviceOffering.getOfferHA()); proxy.setDynamicallyScalable(template.isDynamicallyScalable()); proxy = _consoleProxyDao.persist(proxy); try { - _itMgr.allocate(name, template, _serviceOffering, networks, plan, null); + _itMgr.allocate(name, template, serviceOffering, networks, plan, null); } catch (InsufficientCapacityException e) { s_logger.warn("InsufficientCapacity", e); throw new CloudRuntimeException("Insufficient capacity exception", e); @@ -951,7 +965,12 @@ public boolean isZoneReady(Map zoneHostInfoMap, long dataCen TemplateDataStoreVO templateHostRef = _vmTemplateStoreDao.findByTemplateZoneDownloadStatus(template.getId(), dataCenterId, Status.DOWNLOADED); if (templateHostRef != null) { - List> l = _consoleProxyDao.getDatacenterStoragePoolHostInfo(dataCenterId, _useLvm); + boolean useLocalStorage = false; + Boolean useLocal = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dataCenterId); + if (useLocal != null) { + useLocalStorage = useLocal.booleanValue(); + } + List> l = _consoleProxyDao.getDatacenterStoragePoolHostInfo(dataCenterId, useLocalStorage); if (l != null && l.size() > 0 && l.get(0).second().intValue() > 0) { return true; } else { @@ -1208,11 +1227,6 @@ public boolean configure(String name, Map params) throws Configu _disableRpFilter = true; } - value = configs.get(DataCenter.SystemVMUseLocalStorageCK); - if (value != null && value.equalsIgnoreCase("true")) { - _useLvm = true; - } - value = configs.get("secondary.storage.vm"); if (value != null && value.equalsIgnoreCase("true")) { _useStorageVm = true; @@ -1238,8 +1252,6 @@ public boolean configure(String name, Map params) throws Configu _itMgr.registerGuru(VirtualMachine.Type.ConsoleProxy, this); - boolean useLocalStorage = Boolean.parseBoolean(configs.get(DataCenter.SystemVMUseLocalStorageCK)); - //check if there is a default service offering configured String cpvmSrvcOffIdStr = configs.get(Config.ConsoleProxyServiceOffering.key()); if (cpvmSrvcOffIdStr != null) { @@ -1259,15 +1271,11 @@ public boolean configure(String name, Map params) throws Configu if (_serviceOffering == null || !_serviceOffering.getSystemUse()) { int ramSize = NumbersUtil.parseInt(_configDao.getValue("console.ram.size"), DEFAULT_PROXY_VM_RAMSIZE); int cpuFreq = NumbersUtil.parseInt(_configDao.getValue("console.cpu.mhz"), DEFAULT_PROXY_VM_CPUMHZ); - _serviceOffering = - new ServiceOfferingVO("System Offering For Console Proxy", 1, ramSize, cpuFreq, 0, 0, false, null, - Storage.ProvisioningType.THIN, useLocalStorage, true, null, true, - VirtualMachine.Type.ConsoleProxy, true); - _serviceOffering.setUniqueName(ServiceOffering.consoleProxyDefaultOffUniqueName); - _serviceOffering = _offeringDao.persistSystemServiceOffering(_serviceOffering); - + List offerings = _offeringDao.createSystemServiceOfferings("System Offering For Console Proxy", + ServiceOffering.consoleProxyDefaultOffUniqueName, 1, ramSize, cpuFreq, 0, 0, false, null, + Storage.ProvisioningType.THIN, true, null, true, VirtualMachine.Type.ConsoleProxy, true); // this can sometimes happen, if DB is manually or programmatically manipulated - if (_serviceOffering == null) { + if (offerings == null || offerings.size() < 2) { String msg = "Data integrity problem : System Offering For Console Proxy has been removed?"; s_logger.error(msg); throw new ConfigurationException(msg); diff --git a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java index 3a7173b95b5f..57abb9204c4a 100644 --- a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java +++ b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java @@ -32,8 +32,8 @@ import javax.naming.ConfigurationException; import com.cloud.utils.fsm.StateMachine2; -import org.apache.log4j.Logger; +import org.apache.log4j.Logger; import org.apache.cloudstack.affinity.AffinityGroupProcessor; import org.apache.cloudstack.affinity.AffinityGroupService; import org.apache.cloudstack.affinity.AffinityGroupVMMapVO; @@ -46,8 +46,6 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; -import org.apache.cloudstack.framework.config.ConfigKey; -import org.apache.cloudstack.framework.config.Configurable; import org.apache.cloudstack.framework.messagebus.MessageBus; import org.apache.cloudstack.framework.messagebus.MessageSubscriber; import org.apache.cloudstack.managed.context.ManagedContextTimerTask; @@ -67,6 +65,7 @@ import com.cloud.capacity.CapacityManager; import com.cloud.capacity.dao.CapacityDao; import com.cloud.configuration.Config; +import com.cloud.configuration.ConfigurationManagerImpl; import com.cloud.dc.ClusterDetailsDao; import com.cloud.dc.ClusterDetailsVO; import com.cloud.dc.ClusterVO; @@ -134,7 +133,7 @@ @Local(value = {DeploymentPlanningManager.class}) public class DeploymentPlanningManagerImpl extends ManagerBase implements DeploymentPlanningManager, Manager, Listener, -StateListener, Configurable { +StateListener { private static final Logger s_logger = Logger.getLogger(DeploymentPlanningManagerImpl.class); @Inject @@ -762,16 +761,6 @@ public Boolean doInTransaction(TransactionStatus status) { return false; } - @Override - public String getConfigComponentName() { - return DeploymentPlanningManagerImpl.class.getSimpleName(); - } - - @Override - public ConfigKey[] getConfigKeys() { - return new ConfigKey[] {DataCenter.UseSystemVMLocalStorage}; - } - class HostReservationReleaseChecker extends ManagedContextTimerTask { @Override protected void runInContext() { @@ -1301,20 +1290,11 @@ protected Pair>, List> findSuitablePoolsFo boolean useLocalStorage = false; if (vmProfile.getType() != VirtualMachine.Type.User) { DataCenterVO zone = _dcDao.findById(plan.getDataCenterId()); - // It should not happen to have a "null" zone here. There can be NO instance if there is NO zone, - // so this part of the code would never be reached if no zone has been created. - // Added the check and the comment just to make it clear. - boolean zoneUsesLocalStorage = zone != null ? zone.isLocalStorageEnabled() : false; - boolean ssvmUseLocalStorage = DataCenter.UseSystemVMLocalStorage.value(); - if (zone != null) { - ssvmUseLocalStorage = DataCenter.UseSystemVMLocalStorage.valueIn(plan.getDataCenterId()); - } - s_logger.debug("Checking if we need local storage for systemvms is needed for zone id=" + plan.getDataCenterId() + " with system.vm.use.local.storage=" + ssvmUseLocalStorage); - // Local storage is used for the NON User VMs if, and only if, the Zone is marked to use local storage AND - // the global settings (ssvmUseLocalStorage) is set to true. Otherwise, the global settings won't be applied. - if (ssvmUseLocalStorage && zoneUsesLocalStorage) { - useLocalStorage = true; - s_logger.debug("SystemVMs will use local storage for zone id=" + plan.getDataCenterId()); + assert (zone != null) : "Invalid zone in deployment plan"; + Boolean useLocalStorageForSystemVM = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(zone.getId()); + if (useLocalStorageForSystemVM != null) { + useLocalStorage = useLocalStorageForSystemVM.booleanValue(); + s_logger.debug("System VMs will use " + (useLocalStorage ? "local" : "shared") + " storage for zone id=" + plan.getDataCenterId()); } } else { useLocalStorage = diskOffering.getUseLocalStorage(); diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index c7e0c2951fbd..2a518e46e61c 100644 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -631,12 +631,15 @@ public boolean configure(final String name, final Map params) th _agentMgr.registerForHostEvents(new SshKeysDistriMonitor(_agentMgr, _hostDao, _configDao), true, false, false); - final boolean useLocalStorage = Boolean.parseBoolean(configs.get(DataCenter.SystemVMUseLocalStorageCK)); - ServiceOfferingVO offering = new ServiceOfferingVO("System Offering For Software Router", 1, _routerRamSize, _routerCpuMHz, null, null, true, null, ProvisioningType.THIN, - useLocalStorage, true, null, true, VirtualMachine.Type.DomainRouter, true); - offering.setUniqueName(ServiceOffering.routerDefaultOffUniqueName); - offering = _serviceOfferingDao.persistSystemServiceOffering(offering); - _routerDeploymentManagerBuilder.setOfferingId(offering.getId()); + List offerings = _serviceOfferingDao.createSystemServiceOfferings("System Offering For Software Router", + ServiceOffering.routerDefaultOffUniqueName, 1, _routerRamSize, _routerCpuMHz, null, + null, true, null, ProvisioningType.THIN, true, null, true, VirtualMachine.Type.DomainRouter, true); + // this can sometimes happen, if DB is manually or programmatically manipulated + if (offerings == null || offerings.size() < 2) { + final String msg = "Data integrity problem : System Offering For Software router VM has been removed?"; + s_logger.error(msg); + throw new ConfigurationException(msg); + } NetworkHelperImpl.setSystemAccount(_accountMgr.getSystemAccount()); diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index e725ce30cd61..2c70b170dc30 100644 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -42,6 +42,7 @@ import javax.naming.ConfigurationException; import com.cloud.hypervisor.Hypervisor; + import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import org.apache.cloudstack.api.command.admin.storage.CancelPrimaryStorageMaintenanceCmd; @@ -111,6 +112,7 @@ import com.cloud.cluster.ManagementServerHost; import com.cloud.configuration.Config; import com.cloud.configuration.ConfigurationManager; +import com.cloud.configuration.ConfigurationManagerImpl; import com.cloud.configuration.Resource.ResourceType; import com.cloud.dc.ClusterVO; import com.cloud.dc.DataCenterVO; @@ -546,9 +548,16 @@ public boolean stop() { @DB @Override public DataStore createLocalStorage(Host host, StoragePoolInfo pInfo) throws ConnectionException { - DataCenterVO dc = _dcDao.findById(host.getDataCenterId()); - if (dc == null || !dc.isLocalStorageEnabled()) { + if (dc == null) { + return null; + } + boolean useLocalStorageForSystemVM = false; + Boolean isLocal = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dc.getId()); + if (isLocal != null) { + useLocalStorageForSystemVM = isLocal.booleanValue(); + } + if (!(dc.isLocalStorageEnabled() || useLocalStorageForSystemVM)) { return null; } DataStore store; diff --git a/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinition.java b/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinition.java index 5ef20703146c..569200c93c3f 100644 --- a/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinition.java +++ b/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinition.java @@ -23,6 +23,7 @@ import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; import org.apache.log4j.Logger; +import com.cloud.configuration.ConfigurationManagerImpl; import com.cloud.dc.DataCenter.NetworkType; import com.cloud.dc.HostPodVO; import com.cloud.dc.Pod; @@ -52,7 +53,10 @@ import com.cloud.network.router.NetworkHelper; import com.cloud.network.router.VirtualRouter.Role; import com.cloud.network.vpc.Vpc; +import com.cloud.offering.ServiceOffering; import com.cloud.offerings.dao.NetworkOfferingDao; +import com.cloud.service.ServiceOfferingVO; +import com.cloud.service.dao.ServiceOfferingDao; import com.cloud.user.Account; import com.cloud.user.AccountManager; import com.cloud.utils.db.DB; @@ -80,6 +84,7 @@ public class RouterDeploymentDefinition { protected NetworkModel networkModel; protected VirtualRouterProviderDao vrProviderDao; protected NetworkOfferingDao networkOfferingDao; + protected ServiceOfferingDao serviceOfferingDao; protected IpAddressManager ipAddrMgr; protected VMInstanceDao vmDao; protected HostPodDao podDao; @@ -354,10 +359,23 @@ protected void findSourceNatIP() throws InsufficientAddressCapacityException, Co } } + protected void findDefaultServiceOfferingId() { + String offeringName = ServiceOffering.routerDefaultOffUniqueName; + Boolean useLocalStorage = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId()); + if (useLocalStorage != null && useLocalStorage.booleanValue()) { + offeringName += "-Local"; + } + ServiceOfferingVO serviceOffering = serviceOfferingDao.findByName(offeringName); + if (serviceOffering == null) { + throw new CloudRuntimeException("System service offering " + offeringName + " not found"); + } + serviceOfferingId = serviceOffering.getId(); + } + protected void findServiceOfferingId() { - final Long networkOfferingId = networkOfferingDao.findById(guestNetwork.getNetworkOfferingId()).getServiceOfferingId(); - if (networkOfferingId != null) { - serviceOfferingId = networkOfferingId; + serviceOfferingId = networkOfferingDao.findById(guestNetwork.getNetworkOfferingId()).getServiceOfferingId(); + if (serviceOfferingId == null) { + findDefaultServiceOfferingId(); } } diff --git a/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinitionBuilder.java b/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinitionBuilder.java index 33ed9d093a1e..3ba4fad77de8 100644 --- a/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinitionBuilder.java +++ b/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinitionBuilder.java @@ -45,6 +45,7 @@ import com.cloud.network.vpc.dao.VpcDao; import com.cloud.network.vpc.dao.VpcOfferingDao; import com.cloud.offerings.dao.NetworkOfferingDao; +import com.cloud.service.dao.ServiceOfferingDao; import com.cloud.user.Account; import com.cloud.user.AccountManager; import com.cloud.vm.DomainRouterVO; @@ -68,6 +69,8 @@ public class RouterDeploymentDefinitionBuilder { @Inject private NetworkOfferingDao networkOfferingDao; @Inject + private ServiceOfferingDao serviceOfferingDao; + @Inject private IpAddressManager ipAddrMgr; @Inject private VMInstanceDao vmDao; @@ -120,6 +123,7 @@ protected RouterDeploymentDefinition injectDependencies( routerDeploymentDefinition.networkModel = networkModel; routerDeploymentDefinition.vrProviderDao = vrProviderDao; routerDeploymentDefinition.networkOfferingDao = networkOfferingDao; + routerDeploymentDefinition.serviceOfferingDao = serviceOfferingDao; routerDeploymentDefinition.ipAddrMgr = ipAddrMgr; routerDeploymentDefinition.vmDao = vmDao; routerDeploymentDefinition.podDao = podDao; diff --git a/server/src/org/cloud/network/router/deployment/VpcRouterDeploymentDefinition.java b/server/src/org/cloud/network/router/deployment/VpcRouterDeploymentDefinition.java index 5124195d04c7..26f2379804ef 100644 --- a/server/src/org/cloud/network/router/deployment/VpcRouterDeploymentDefinition.java +++ b/server/src/org/cloud/network/router/deployment/VpcRouterDeploymentDefinition.java @@ -156,9 +156,9 @@ protected void findVirtualProvider() { @Override protected void findServiceOfferingId() { - final Long vpcOfferingId = vpcOffDao.findById(vpc.getVpcOfferingId()).getServiceOfferingId(); - if (vpcOfferingId != null) { - serviceOfferingId = vpcOfferingId; + serviceOfferingId = vpcOffDao.findById(vpc.getVpcOfferingId()).getServiceOfferingId(); + if (serviceOfferingId == null) { + findDefaultServiceOfferingId(); } } diff --git a/server/test/com/cloud/network/element/VirtualRouterElementTest.java b/server/test/com/cloud/network/element/VirtualRouterElementTest.java index f139852436d9..659277824ea3 100644 --- a/server/test/com/cloud/network/element/VirtualRouterElementTest.java +++ b/server/test/com/cloud/network/element/VirtualRouterElementTest.java @@ -33,6 +33,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; +import org.mockito.Matchers; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; @@ -169,7 +170,7 @@ public class VirtualRouterElementTest { private RouterDeploymentDefinitionBuilder routerDeploymentDefinitionBuilder; @InjectMocks - private VpcVirtualNetworkApplianceManagerImpl _routerMgr ; + private VpcVirtualNetworkApplianceManagerImpl _routerMgr; @InjectMocks private VirtualRouterElement virtualRouterElement; @@ -210,7 +211,7 @@ public void testImplementInAdvancedZoneOnXenServer() throws Exception { public void testPrepare() { virtualRouterElement._routerMgr = _routerMgr; virtualRouterElement.routerDeploymentDefinitionBuilder = routerDeploymentDefinitionBuilder; - mockDAOs(testNetwork,testOffering); + mockDAOs(testNetwork, testOffering); mockMgrs(); boolean done = false; @@ -276,6 +277,7 @@ private void mockDAOs(final NetworkVO network, final NetworkOfferingVO offering) VirtualMachine.Type.DomainRouter, /* defaultUse */ false); when(_serviceOfferingDao.findById(0L)).thenReturn(svcoff); + when(_serviceOfferingDao.findByName(Matchers.anyString())).thenReturn(svcoff); final DomainRouterVO router = new DomainRouterVO(/* id */ 1L, /* serviceOfferingId */ 1L, /* elementId */ 0L, diff --git a/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTest.java b/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTest.java index abd80d75eb41..b266f880c1ec 100644 --- a/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTest.java +++ b/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTest.java @@ -38,6 +38,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.Matchers; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; @@ -635,7 +636,7 @@ public void testFindSourceNatIPNonPublicNw() throws InsufficientAddressCapacityE } @Test - public void testFindOfferingIdReceivingNewOne() { + public void testFindOfferingIdFromNetwork() { // Prepare deployment.serviceOfferingId = 1L; when(mockNw.getNetworkOfferingId()).thenReturn(OFFERING_ID); @@ -646,24 +647,26 @@ public void testFindOfferingIdReceivingNewOne() { deployment.findServiceOfferingId(); // Assert - assertEquals("Given that no Offering was found, the previous Offering Id should be kept", + assertEquals("Service offering id not matching the one associated with network offering", OFFERING_ID, deployment.serviceOfferingId.longValue()); } @Test - public void testFindOfferingIdReceivingKeepingPrevious() { + public void testFindOfferingIdDefault() { // Prepare deployment.serviceOfferingId = 1L; when(mockNw.getNetworkOfferingId()).thenReturn(OFFERING_ID); when(mockNetworkOfferingDao.findById(OFFERING_ID)).thenReturn(mockNwOfferingVO); when(mockNwOfferingVO.getServiceOfferingId()).thenReturn(null); + when(mockServiceOfferingDao.findByName(Matchers.anyString())).thenReturn(mockSvcOfferingVO); + when(mockSvcOfferingVO.getId()).thenReturn(DEFAULT_OFFERING_ID); // Execute deployment.findServiceOfferingId(); // Assert - assertEquals("Found Offering Id didn't replace previous one", - 1L, deployment.serviceOfferingId.longValue()); + assertEquals("Since there is no service offering associated with network offering, offering id should have matched default one", + DEFAULT_OFFERING_ID, deployment.serviceOfferingId.longValue()); } @Test diff --git a/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTestBase.java b/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTestBase.java index 0978ac96ea97..4225083ca2bd 100644 --- a/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTestBase.java +++ b/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTestBase.java @@ -43,6 +43,8 @@ import com.cloud.network.router.VpcNetworkHelperImpl; import com.cloud.offerings.NetworkOfferingVO; import com.cloud.offerings.dao.NetworkOfferingDao; +import com.cloud.service.ServiceOfferingVO; +import com.cloud.service.dao.ServiceOfferingDao; import com.cloud.user.Account; import com.cloud.user.AccountManager; import com.cloud.vm.VirtualMachineProfile.Param; @@ -57,6 +59,7 @@ public class RouterDeploymentDefinitionTestBase { protected static final String ONLY_THE_PROVIDED_AS_DEFAULT_DESTINATION_WAS_EXPECTED = "Only the provided as default destination was expected"; protected static final long OFFERING_ID = 16L; + protected static final long DEFAULT_OFFERING_ID = 17L; protected static final Long DATA_CENTER_ID = 100l; protected static final Long NW_ID_1 = 101l; protected static final Long NW_ID_2= 102l; @@ -92,6 +95,8 @@ public class RouterDeploymentDefinitionTestBase { @Mock protected NetworkOfferingDao mockNetworkOfferingDao; @Mock + protected ServiceOfferingDao mockServiceOfferingDao; + @Mock protected AccountManager mockAccountMgr; // Instance specific parameters to use during build @@ -112,6 +117,8 @@ public class RouterDeploymentDefinitionTestBase { @Mock NetworkOfferingVO mockNwOfferingVO; @Mock + ServiceOfferingVO mockSvcOfferingVO; + @Mock protected Account mockOwner; diff --git a/server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java b/server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java index 4ef35931926a..5a34ebf037ee 100644 --- a/server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java +++ b/server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java @@ -31,6 +31,7 @@ import org.junit.Before; import org.junit.Test; +import org.mockito.Matchers; import org.mockito.Mock; import com.cloud.deploy.DeployDestination; @@ -178,23 +179,24 @@ public void testGenerateDeploymentPlan() { } @Test - public void testFindOfferingIdLeavingPrevious() { + public void testFindOfferingIdDefault() { // Prepare - final Long initialOfferingId = deployment.serviceOfferingId; final VpcOfferingVO vpcOffering = mock(VpcOfferingVO.class); when(mockVpcOffDao.findById(VPC_OFFERING_ID)).thenReturn(vpcOffering); when(vpcOffering.getServiceOfferingId()).thenReturn(null); + when(mockServiceOfferingDao.findByName(Matchers.anyString())).thenReturn(mockSvcOfferingVO); + when(mockSvcOfferingVO.getId()).thenReturn(DEFAULT_OFFERING_ID); // Execute deployment.findServiceOfferingId(); // Assert - assertEquals("Offering Id shouldn't have been updated", - initialOfferingId, deployment.serviceOfferingId); + assertEquals("Since there is no service offering associated with VPC offering, offering id should have matched default one", + DEFAULT_OFFERING_ID, deployment.serviceOfferingId.longValue()); } @Test - public void testFindOfferingIdSettingNewOne() { + public void testFindOfferingIdFromVPC() { // Prepare final VpcOfferingVO vpcOffering = mock(VpcOfferingVO.class); when(mockVpcOffDao.findById(VPC_OFFERING_ID)).thenReturn(vpcOffering); @@ -204,7 +206,7 @@ public void testFindOfferingIdSettingNewOne() { deployment.findServiceOfferingId(); // Assert - assertEquals("Offering Id should have been updated", + assertEquals("Service offering id not matching the one associated with VPC offering", VPC_OFFERING_ID, deployment.serviceOfferingId.longValue()); } diff --git a/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java b/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java index 4dc6dbbfe3fb..445852d33f08 100644 --- a/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java +++ b/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java @@ -32,7 +32,6 @@ import javax.naming.ConfigurationException; import org.apache.cloudstack.config.ApiServiceConfiguration; - import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; @@ -64,6 +63,7 @@ import com.cloud.capacity.dao.CapacityDao; import com.cloud.cluster.ClusterManager; import com.cloud.configuration.Config; +import com.cloud.configuration.ConfigurationManagerImpl; import com.cloud.configuration.ZoneConfig; import com.cloud.consoleproxy.ConsoleProxyManager; import com.cloud.dc.DataCenter; @@ -242,7 +242,6 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar private int _secStorageVmMtuSize; private String _instance; - private boolean _useLocalStorage; private boolean _useSSlCopy; private String _httpProxy; private String _allowedInternalSites; @@ -577,13 +576,27 @@ protected Map createSecStorageVmInstance(long dataCenterId, Seco throw new CloudRuntimeException("Not able to find the System templates or not downloaded in zone " + dataCenterId); } + ServiceOfferingVO serviceOffering = _serviceOffering; + if (serviceOffering == null) { + String offeringName = ServiceOffering.ssvmDefaultOffUniqueName; + Boolean useLocalStorage = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dataCenterId); + if (useLocalStorage != null && useLocalStorage.booleanValue()) { + offeringName += "-Local"; + } + serviceOffering = _offeringDao.findByName(offeringName); + if (serviceOffering == null) { + String message = "System service offering " + offeringName + " not found"; + s_logger.error(message); + throw new CloudRuntimeException(message); + } + } SecondaryStorageVmVO secStorageVm = - new SecondaryStorageVmVO(id, _serviceOffering.getId(), name, template.getId(), template.getHypervisorType(), template.getGuestOSId(), dataCenterId, - systemAcct.getDomainId(), systemAcct.getId(), _accountMgr.getSystemUser().getId(), role, _serviceOffering.getOfferHA()); + new SecondaryStorageVmVO(id, serviceOffering.getId(), name, template.getId(), template.getHypervisorType(), template.getGuestOSId(), dataCenterId, + systemAcct.getDomainId(), systemAcct.getId(), _accountMgr.getSystemUser().getId(), role, serviceOffering.getOfferHA()); secStorageVm.setDynamicallyScalable(template.isDynamicallyScalable()); secStorageVm = _secStorageVmDao.persist(secStorageVm); try { - _itMgr.allocate(name, template, _serviceOffering, networks, plan, null); + _itMgr.allocate(name, template, serviceOffering, networks, plan, null); secStorageVm = _secStorageVmDao.findById(secStorageVm.getId()); } catch (InsufficientCapacityException e) { s_logger.warn("InsufficientCapacity", e); @@ -763,14 +776,19 @@ public boolean isZoneReady(Map zoneHostInfoMap, long dataCen return false; } - List> l = _storagePoolHostDao.getDatacenterStoragePoolHostInfo(dataCenterId, !_useLocalStorage); + boolean useLocalStorage = false; + Boolean useLocal = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dataCenterId); + if (useLocal != null) { + useLocalStorage = useLocal.booleanValue(); + } + List> l = _storagePoolHostDao.getDatacenterStoragePoolHostInfo(dataCenterId, !useLocalStorage); if (l != null && l.size() > 0 && l.get(0).second().intValue() > 0) { return true; } else { if (s_logger.isDebugEnabled()) { s_logger.debug("Primary storage is not ready, wait until it is ready to launch secondary storage vm. dcId: " + dataCenterId + - " system.vm.use.local.storage: " + _useLocalStorage + - "If you want to use local storage to start ssvm, need to set system.vm.use.local.storage to true"); + ", " + ConfigurationManagerImpl.SystemVMUseLocalStorage.key() + ": " + useLocalStorage + ". " + + "If you want to use local storage to start SSVM, need to set " + ConfigurationManagerImpl.SystemVMUseLocalStorage.key() + " to true"); } } @@ -872,18 +890,14 @@ public boolean configure(String name, Map params) throws Configu } } - if(_serviceOffering == null || !_serviceOffering.getSystemUse()){ + if (_serviceOffering == null || !_serviceOffering.getSystemUse()) { int ramSize = NumbersUtil.parseInt(_configDao.getValue("ssvm.ram.size"), DEFAULT_SS_VM_RAMSIZE); int cpuFreq = NumbersUtil.parseInt(_configDao.getValue("ssvm.cpu.mhz"), DEFAULT_SS_VM_CPUMHZ); - _useLocalStorage = Boolean.parseBoolean(configs.get(DataCenter.SystemVMUseLocalStorageCK)); - _serviceOffering = - new ServiceOfferingVO("System Offering For Secondary Storage VM", 1, ramSize, cpuFreq, null, null, false, null, - Storage.ProvisioningType.THIN, _useLocalStorage, true, null, true, VirtualMachine.Type.SecondaryStorageVm, true); - _serviceOffering.setUniqueName(ServiceOffering.ssvmDefaultOffUniqueName); - _serviceOffering = _offeringDao.persistSystemServiceOffering(_serviceOffering); - + List offerings = _offeringDao.createSystemServiceOfferings("System Offering For Secondary Storage VM", + ServiceOffering.ssvmDefaultOffUniqueName, 1, ramSize, cpuFreq, null, null, false, null, + Storage.ProvisioningType.THIN, true, null, true, VirtualMachine.Type.SecondaryStorageVm, true); // this can sometimes happen, if DB is manually or programmatically manipulated - if (_serviceOffering == null) { + if (offerings == null || offerings.size() < 2) { String msg = "Data integrity problem : System Offering For Secondary Storage VM has been removed?"; s_logger.error(msg); throw new ConfigurationException(msg); From d423df66cc73c47d363736b7762e820d85f05b93 Mon Sep 17 00:00:00 2001 From: Koushik Das Date: Thu, 14 May 2015 17:30:19 +0530 Subject: [PATCH 069/175] CLOUDSTACK-8301: Enable configuring local storage use for system VMs at zone level Code cleanup, added helper method to get default system offering based on "system.vm.use.local.storage". --- .../com/cloud/service/dao/ServiceOfferingDao.java | 2 ++ .../cloud/service/dao/ServiceOfferingDaoImpl.java | 15 +++++++++++++++ .../cloud/network/lb/LoadBalanceRuleHandler.java | 12 +----------- .../lb/InternalLoadBalancerVMManagerImpl.java | 12 +----------- .../consoleproxy/ConsoleProxyManagerImpl.java | 12 +----------- .../deployment/RouterDeploymentDefinition.java | 10 +--------- .../RouterDeploymentDefinitionTest.java | 2 +- .../VpcRouterDeploymentDefinitionTest.java | 2 +- .../SecondaryStorageManagerImpl.java | 12 +----------- 9 files changed, 24 insertions(+), 55 deletions(-) diff --git a/engine/schema/src/com/cloud/service/dao/ServiceOfferingDao.java b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDao.java index 98dc3178de4f..aae61a120943 100644 --- a/engine/schema/src/com/cloud/service/dao/ServiceOfferingDao.java +++ b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDao.java @@ -55,4 +55,6 @@ List createSystemServiceOfferings(String name, String uniqueN boolean isDynamic(long serviceOfferingId); ServiceOfferingVO getcomputeOffering(ServiceOfferingVO serviceOffering, Map customParameters); + + ServiceOfferingVO findDefaultSystemOffering(String offeringName, Boolean useLocalStorage); } diff --git a/engine/schema/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java index a3ffbc1396df..4a5a8b5448bd 100644 --- a/engine/schema/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java +++ b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java @@ -276,4 +276,19 @@ public List createSystemServiceOfferings(String name, String return list; } + + @Override + public ServiceOfferingVO findDefaultSystemOffering(String offeringName, Boolean useLocalStorage) { + String name = offeringName; + if (useLocalStorage != null && useLocalStorage.booleanValue()) { + name += "-Local"; + } + ServiceOfferingVO serviceOffering = findByName(name); + if (serviceOffering == null) { + String message = "System service offering " + name + " not found"; + s_logger.error(message); + throw new CloudRuntimeException(message); + } + return serviceOffering; + } } diff --git a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/LoadBalanceRuleHandler.java b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/LoadBalanceRuleHandler.java index f2c4685280ad..e90af37809c5 100644 --- a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/LoadBalanceRuleHandler.java +++ b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/LoadBalanceRuleHandler.java @@ -282,17 +282,7 @@ private DomainRouterVO deployELBVm(Network guestNetwork, final DeployDestination userId = _userDao.listByAccount(owner.getAccountId()).get(0).getId(); } - String offeringName = ServiceOffering.elbVmDefaultOffUniqueName; - Boolean useLocalStorage = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId()); - if (useLocalStorage != null && useLocalStorage.booleanValue()) { - offeringName += "-Local"; - } - ServiceOfferingVO elasticLbVmOffering = _serviceOfferingDao.findByName(offeringName); - if (elasticLbVmOffering == null) { - String message = "System service offering " + offeringName + " not found"; - s_logger.error(message); - throw new CloudRuntimeException(message); - } + ServiceOfferingVO elasticLbVmOffering = _serviceOfferingDao.findDefaultSystemOffering(ServiceOffering.elbVmDefaultOffUniqueName, ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId())); elbVm = new DomainRouterVO(id, elasticLbVmOffering.getId(), vrProvider.getId(), VirtualMachineName.getSystemVmName(id, _instance, ELB_VM_NAME_PREFIX), template.getId(), template.getHypervisorType(), template.getGuestOSId(), owner.getDomainId(), owner.getId(), userId, false, RedundantState.UNKNOWN, elasticLbVmOffering.getOfferHA(), false, null); diff --git a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java index 818ad88b07ae..4bd852d19dbe 100644 --- a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java +++ b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java @@ -623,17 +623,7 @@ protected List findOrDeployInternalLbVm(final Network guestNetwo final LinkedHashMap> networks = createInternalLbVmNetworks(guestNetwork, plan, requestedGuestIp); long internalLbVmOfferingId = _internalLbVmOfferingId; if (internalLbVmOfferingId == 0L) { - String offeringName = ServiceOffering.internalLbVmDefaultOffUniqueName; - Boolean useLocalStorage = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId()); - if (useLocalStorage != null && useLocalStorage.booleanValue()) { - offeringName += "-Local"; - } - ServiceOfferingVO serviceOffering = _serviceOfferingDao.findByName(offeringName); - if (serviceOffering == null) { - String message = "System service offering " + offeringName + " not found"; - s_logger.error(message); - throw new CloudRuntimeException(message); - } + ServiceOfferingVO serviceOffering = _serviceOfferingDao.findDefaultSystemOffering(ServiceOffering.internalLbVmDefaultOffUniqueName, ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId())); internalLbVmOfferingId = serviceOffering.getId(); } //Pass startVm=false as we are holding the network lock that needs to be released at the end of vm allocation diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java index f8d7474cb224..476cc8e794f9 100644 --- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java +++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java @@ -718,17 +718,7 @@ protected Map createProxyInstance(long dataCenterId, VMTemplateV ServiceOfferingVO serviceOffering = _serviceOffering; if (serviceOffering == null) { - String offeringName = ServiceOffering.consoleProxyDefaultOffUniqueName; - Boolean useLocalStorage = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dataCenterId); - if (useLocalStorage != null && useLocalStorage.booleanValue()) { - offeringName += "-Local"; - } - serviceOffering = _offeringDao.findByName(offeringName); - if (serviceOffering == null) { - String message = "System service offering " + offeringName + " not found"; - s_logger.error(message); - throw new CloudRuntimeException(message); - } + serviceOffering = _offeringDao.findDefaultSystemOffering(ServiceOffering.consoleProxyDefaultOffUniqueName, ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dataCenterId)); } ConsoleProxyVO proxy = new ConsoleProxyVO(id, serviceOffering.getId(), name, template.getId(), template.getHypervisorType(), template.getGuestOSId(), dataCenterId, diff --git a/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinition.java b/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinition.java index 569200c93c3f..2d04a7e633f1 100644 --- a/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinition.java +++ b/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinition.java @@ -360,15 +360,7 @@ protected void findSourceNatIP() throws InsufficientAddressCapacityException, Co } protected void findDefaultServiceOfferingId() { - String offeringName = ServiceOffering.routerDefaultOffUniqueName; - Boolean useLocalStorage = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId()); - if (useLocalStorage != null && useLocalStorage.booleanValue()) { - offeringName += "-Local"; - } - ServiceOfferingVO serviceOffering = serviceOfferingDao.findByName(offeringName); - if (serviceOffering == null) { - throw new CloudRuntimeException("System service offering " + offeringName + " not found"); - } + ServiceOfferingVO serviceOffering = serviceOfferingDao.findDefaultSystemOffering(ServiceOffering.routerDefaultOffUniqueName, ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId())); serviceOfferingId = serviceOffering.getId(); } diff --git a/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTest.java b/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTest.java index b266f880c1ec..1570a2e15a94 100644 --- a/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTest.java +++ b/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTest.java @@ -658,7 +658,7 @@ public void testFindOfferingIdDefault() { when(mockNw.getNetworkOfferingId()).thenReturn(OFFERING_ID); when(mockNetworkOfferingDao.findById(OFFERING_ID)).thenReturn(mockNwOfferingVO); when(mockNwOfferingVO.getServiceOfferingId()).thenReturn(null); - when(mockServiceOfferingDao.findByName(Matchers.anyString())).thenReturn(mockSvcOfferingVO); + when(mockServiceOfferingDao.findDefaultSystemOffering(Matchers.anyString(), Matchers.anyBoolean())).thenReturn(mockSvcOfferingVO); when(mockSvcOfferingVO.getId()).thenReturn(DEFAULT_OFFERING_ID); // Execute diff --git a/server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java b/server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java index 5a34ebf037ee..13c20ae7e507 100644 --- a/server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java +++ b/server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java @@ -184,7 +184,7 @@ public void testFindOfferingIdDefault() { final VpcOfferingVO vpcOffering = mock(VpcOfferingVO.class); when(mockVpcOffDao.findById(VPC_OFFERING_ID)).thenReturn(vpcOffering); when(vpcOffering.getServiceOfferingId()).thenReturn(null); - when(mockServiceOfferingDao.findByName(Matchers.anyString())).thenReturn(mockSvcOfferingVO); + when(mockServiceOfferingDao.findDefaultSystemOffering(Matchers.anyString(), Matchers.anyBoolean())).thenReturn(mockSvcOfferingVO); when(mockSvcOfferingVO.getId()).thenReturn(DEFAULT_OFFERING_ID); // Execute diff --git a/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java b/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java index 445852d33f08..453a4cbab0be 100644 --- a/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java +++ b/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java @@ -578,17 +578,7 @@ protected Map createSecStorageVmInstance(long dataCenterId, Seco ServiceOfferingVO serviceOffering = _serviceOffering; if (serviceOffering == null) { - String offeringName = ServiceOffering.ssvmDefaultOffUniqueName; - Boolean useLocalStorage = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dataCenterId); - if (useLocalStorage != null && useLocalStorage.booleanValue()) { - offeringName += "-Local"; - } - serviceOffering = _offeringDao.findByName(offeringName); - if (serviceOffering == null) { - String message = "System service offering " + offeringName + " not found"; - s_logger.error(message); - throw new CloudRuntimeException(message); - } + serviceOffering = _offeringDao.findDefaultSystemOffering(ServiceOffering.ssvmDefaultOffUniqueName, ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dataCenterId)); } SecondaryStorageVmVO secStorageVm = new SecondaryStorageVmVO(id, serviceOffering.getId(), name, template.getId(), template.getHypervisorType(), template.getGuestOSId(), dataCenterId, From b776cbc2144869e4fda9801fe84a4cf5a71dd067 Mon Sep 17 00:00:00 2001 From: nitt10prashant Date: Thu, 14 May 2015 17:02:23 +0530 Subject: [PATCH 070/175] CLOUDSTACK-8471:Automation for feature Enable configuring local storage use for system VMs at zone level Signed-off-by: Koushik Das This closes #253 --- .../test_zone_level_local_storage_setting.py | 734 ++++++++++++++++++ 1 file changed, 734 insertions(+) create mode 100644 test/integration/component/maint/test_zone_level_local_storage_setting.py diff --git a/test/integration/component/maint/test_zone_level_local_storage_setting.py b/test/integration/component/maint/test_zone_level_local_storage_setting.py new file mode 100644 index 000000000000..466f1f9fd42e --- /dev/null +++ b/test/integration/component/maint/test_zone_level_local_storage_setting.py @@ -0,0 +1,734 @@ +# 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. +""" +Test cases for zone level settings "system.vm.use.local.storage" +""" +# Import Local Modules +from marvin.cloudstackTestCase import * +from marvin.lib.utils import * +from marvin.lib.base import * +from marvin.lib.common import * +from marvin.codes import FAILED, PASS +from requests.exceptions import ConnectionError + +import time +from nose.plugins.attrib import attr +from ddt import ddt, data + + +def destroy_systemvm(self, type): + """ + Destroy system vms + #1-List system vms for current zone + #2-Destroy system vm + #3-Check if system vm came up after destroy + #4-check system vm storage type in disk offering + """ + list_response = list_ssvms( + self.apiclient, + systemvmtype=type, + zoneid=self.zone.id + ) + + self.assertEqual( + validateList(list_response)[0], + PASS, + "Check List ssvm response for %s" % + type) + + response = list_response[0] + self.debug("Destroying CPVM: %s" % response.id) + cmd = destroySystemVm.destroySystemVmCmd() + cmd.id = response.id + self.apiclient.destroySystemVm(cmd) + + timeout = self.testdata["timeout"] + while True: + time.sleep(self.testdata["sleep"]) + list_response = list_ssvms( + self.apiclient, + systemvmtype=type, + zoneid=self.zone.id + ) + if validateList(list_response)[0] == PASS: + if list_response[0].state == 'Running': + break + if timeout == 0: + raise Exception("List %s call failed!" % type) + timeout = timeout - 1 + + +def storage_check(self, type, value): + """test if system vms are using local or shared storage + #1-Get zone id from db using self.zone.id + #2-Get service offering id from vm_instance table for running system vms + #3-Get use_local_storage value from disk_offering table + #4-Verify storage type""" + query_zone_id = self.dbclient.execute( + "select id from data_center where uuid= '%s';" % self.zone.id + ) + query_so_id = self.dbclient.execute( + "select service_offering_id from vm_instance where type='%s'and " + "state='Running' and data_center_id= '%s';" % + (type, query_zone_id[0][0])) + + query_disk_offering = self.dbclient.execute( + "select use_local_storage from disk_offering where id= '%s';" % + query_so_id[0][0]) + + if value == 1: + self.assertEqual(query_disk_offering[0][0], + 1, + "system vm is not using local storage" + ) + elif value == 0: + self.assertEqual(query_disk_offering[0][0], + 0, + "system vm is not using shared storage" + ) + else: + # evil ValueError that doesn't tell you what the wrong value was + raise ValueError + + +def create_system_so(self, offering_type, storage_type): + """Create system offerings """ + self.testdata["service_offerings"]["issystem"] = "true" + self.testdata["service_offerings"]["systemvmtype"] = offering_type + self.testdata["service_offerings"]["storagetype"] = storage_type + + service_offering = ServiceOffering.create( + self.apiclient, + self.testdata["service_offerings"] + ) + + if service_offering is None: + raise Exception("service offering not created") + + list_service_response = list_service_offering( + self.apiclient, + id=service_offering.id, + issystem='true' + ) + self.assertEqual( + validateList(list_service_response)[0], + PASS, + "Check List srvice offering response for %s" % + type) + + self.debug( + "Created service offering with ID: %s" % + service_offering.id) + + self.assertEqual( + list_service_response[0].cpunumber, + self.testdata["service_offerings"]["cpunumber"], + "Check server id in createServiceOffering" + ) + self.assertEqual( + list_service_response[0].cpuspeed, + self.testdata["service_offerings"]["cpuspeed"], + "Check cpuspeed in createServiceOffering" + ) + self.assertEqual( + list_service_response[0].displaytext, + self.testdata["service_offerings"]["displaytext"], + "Check server displaytext in createServiceOfferings" + ) + self.assertEqual( + list_service_response[0].memory, + self.testdata["service_offerings"]["memory"], + "Check memory in createServiceOffering" + ) + self.assertEqual( + list_service_response[0].name, + self.testdata["service_offerings"]["name"], + "Check name in createServiceOffering" + ) + self.assertEqual( + list_service_response[0].storagetype, + self.testdata["service_offerings"]["storagetype"], + "Check storagetype in createServiceOffering" + ) + self._cleanup.append(service_offering) + return service_offering.id + + +def restart_ms(self): + """Restart MS + #1-ssh into m/c running MS + #2-restart ms + #3-verify the response + #4-loop unitl you get list_zone api answer """ + sshClient = SshClient( + self.mgtSvrDetails["mgtSvrIp"], + 22, + self.mgtSvrDetails["user"], + self.mgtSvrDetails["passwd"] + ) + command = "service cloudstack-management restart" + ms_restart_response = sshClient.execute(command) + self.assertEqual( + validateList(ms_restart_response)[0], + PASS, + "Check the MS restart response") + self.assertEqual( + ms_restart_response[0], + 'Stopping cloudstack-management:[ OK ]', + "MS i not stopped" + ) + self.assertEqual( + ms_restart_response[1], + 'Starting cloudstack-management: [ OK ]', + "MS not started" + ) + timeout = self.testdata["timeout"] + while True: + time.sleep(self.testdata["sleep"]) + try: + list_response = Zone.list( + self.apiclient + ) + if validateList(list_response)[0] == PASS: + break + except ConnectionError as e: + self.debug("list zone response is not available due to %s" % e) + + if timeout == 0: + raise Exception("Ms is not comming up !") + timeout = timeout - 1 + + +def update_global_settings(self, value, name, zoneid=None): + """Update Gloabal/zonelevel settings and verify + #1-Update configuration + #2-Restart ms if zone id is None""" + Configurations.update(self.apiclient, + name=name, + zoneid=zoneid, + value=value + ) + if zoneid is None: + restart_ms(self) + + list_conf = Configurations.list(self.apiclient, + name=name, + zoneid=zoneid) + + self.assertEqual( + validateList(list_conf)[0], + PASS, + "Check List configuration response for %s" % name) + + self.assertEqual( + str(list_conf[0].value), + str(value), + "Check if configuration values are equal" + ) + + +def str_to_bool(s): + """Converts str "True/False to Boolean TRUE/FALSE""" + if s == 'true': + return True + elif s == 'false': + return False + else: + # evil ValueError that doesn't tell you what the wrong value was + raise ValueError + + +@ddt +class TestSystemVmLocalStorage(cloudstackTestCase): + + @classmethod + def setUpClass(cls): + testClient = super(TestSystemVmLocalStorage, cls).getClsTestClient() + cls.apiclient = testClient.getApiClient() + cls.dbclient = cls.testClient.getDbConnection() + cls.mgtSvrDetails = cls.config.__dict__["mgtSvr"][0].__dict__ + cls.testdata = testClient.getParsedTestDataConfig() + # Get Zone, and template Domain + cls.domain = get_domain(cls.apiclient) + cls.zone = get_zone(cls.apiclient) + cls.testdata["mode"] = cls.zone.networktype + cls.hypervisor = testClient.getHypervisorInfo() + cls._cleanup = [] + + list_local_storage_pool = StoragePool.list( + cls.apiclient, + scope='HOST', + zoneid=cls.zone.id, + + ) + + if list_local_storage_pool is None: + + Configurations.update( + cls.apiclient, + value='true', + name='system.vm.use.local.storage', + zoneid=cls.zone.id + ) + + # Restart MS + sshClient = SshClient( + cls.mgtSvrDetails["mgtSvrIp"], + 22, + cls.mgtSvrDetails["user"], + cls.mgtSvrDetails["passwd"] + ) + command = "service cloudstack-management restart" + ms_restart_response = sshClient.execute(command) + + if validateList(ms_restart_response)[0] != PASS: + raise Exception("Check the MS restart response") + if ms_restart_response[ + 0] != 'Stopping cloudstack-management:[ OK ]': + raise Exception("MS i not stopped") + + if ms_restart_response[ + 1] != 'Starting cloudstack-management: [ OK ]': + raise Exception("MS not started") + + timeout = cls.testdata["timeout"] + while True: + # time.sleep(cls.testdata["sleep"]) + try: + list_response = Zone.list( + cls.apiclient + ) + if validateList(list_response)[0] == PASS: + break + except ConnectionError as e: + cls.debug( + "list zone response is not available due to %s" % + e) + + if timeout == 0: + raise Exception("Ms is not comming up !") + + time.sleep(cls.testdata["sleep"]) + timeout = timeout - 1 + + list_local_storage_pool = StoragePool.list( + cls.apiclient, + scope='HOST', + zoneid=cls.zone.id, + + ) + if list_local_storage_pool is None: + raise Exception("Could not discover local storage pool") + + try: + cls.account = Account.create(cls.apiclient, + cls.testdata["account"], + domainid=cls.domain.id + ) + cls._cleanup.append(cls.account) + + except Exception as e: + cls.tearDownClass() + raise e + + return + + @classmethod + def tearDownClass(cls): + try: + cleanup_resources(cls.apiclient, cls._cleanup) + except Exception as e: + raise Exception("Warning:Exception during cleanup: %s" % e) + + @attr(tags=["advanced", "basic"]) + @data( + 'consoleproxy', + 'secondarystoragevm', + 'domainrouter', + 'internalloadbalancervm') + def test_01_list_system_offerngs(self, value): + """List service offerings for systemvms and verify there should be two + (local and shared) SO for each system vm""" + + list_custom_so = ServiceOffering.list(self.apiclient, + issystem='true', + listall='true', + systemvmtype=value + ) + + self.assertEqual( + validateList(list_custom_so)[0], + PASS, + "Check List service offerings response for %s" % + value) + + local_custom_so = [] + for item in list_custom_so: + if(str(item.defaultuse) == 'True'): + local_custom_so.append(item.storagetype) + + self.assertEqual( + len(local_custom_so), + 2, + "Check default system offering for system vm type %s" % value) + if 'local' in local_custom_so and 'shared' in local_custom_so: + self.debug( + "there are exactly to Service offerings{share,local} are " + "there for system vm %s" % + value) + else: + raise Exception( + "check local and shared service offerings for %s" % + value) + + @attr(tags=["advanced", "basic"]) + @data('consoleproxy', 'secondarystoragevm') + def test_02_system_vm_storage(self, value): + """ Check if system vms are honouring zone level setting + system.vm.use.local.storage + 1-List zone level config + 2-update the zone level config with service offering uuid + 3-destroy system vms + 4-check used storage by system vms + """ + # 1 List zone level config + if value == "consoleproxy": + update_global_settings( + self, + value=None, + name="consoleproxy.service.offering") + + if value == "secondarystoragevm": + update_global_settings( + self, + value=None, + name="secstorage.service.offering") + + list_conf = Configurations.list(self.apiclient, + name="system.vm.use.local.storage", + zoneid=self.zone.id) + self.assertEqual( + validateList(list_conf)[0], + PASS, + "Check List configuration response for " + "system.vm.use.local.storage") + + val = str_to_bool(list_conf[0].value) + # 2 update the zone level config with service offering uuid + update_global_settings(self, + value=((str(not(val)).lower())), + name='system.vm.use.local.storage', + zoneid=self.zone.id) + + # 3,4 for cpvm + destroy_systemvm(self, value) + storage_check(self, value, int(not(val))) + + # 2 update the zone level config with service offering uuid + update_global_settings( + self, + value=( + str(val).lower()), + name='system.vm.use.local.storage', + zoneid=self.zone.id) + # 3,4 for cpvm + destroy_systemvm(self, value) + storage_check(self, value, int(val)) + + # 1 List zone level config + if value == "consoleproxy": + update_global_settings( + self, + value=None, + name="consoleproxy.service.offering") + + if value == "secondarystoragevm": + update_global_settings( + self, + value=None, + name="secstorage.service.offering") + + @attr(tags=["advanced", "basic"]) + @data('consoleproxy', 'secondarystoragevm') + def test_03_custom_so(self, value): + """ + update global setting with system offering and check if it is being + honoured + 1-update zone level settings "system.vm.use.local.storage={true,false}} + to use local storage + 2-create system offerings{shared,local} + 3-update global settings with system offering uuid and restart ms + 4-destroy system vms + 5-Check if new system vms are using offering updated in global + settings + """ + + # 1-update zone level settings "system.vm.use.local.storage" + # to use local storage + update_global_settings( + self, + value='true', + name='system.vm.use.local.storage', + zoneid=self.zone.id) + # 2-create system offerings + + created_so_id = create_system_so(self, value, "shared") + + if value == "consoleproxy": + name = "consoleproxy.service.offering" + elif value == 'secondarystoragevm': + name = 'secstorage.service.offering' + else: + raise Exception( + "type paramter is not correct it should be system vm " + "type{console proxy,secsroragevm}") + + # 3-update global settings with system offering uuid + update_global_settings(self, value=created_so_id, name=name) + + # 4-destroy system vms + destroy_systemvm(self, value) + + # 5-Check if new system vms are using offering updated in global + # settings + + query_zone_id = self.dbclient.execute( + "select id from data_center where uuid= '%s';" % self.zone.id + ) + query_so_id = self.dbclient.execute( + "select service_offering_id from vm_instance where type='%s'and " + "state='Running' and data_center_id= '%s';" % + (value, query_zone_id[0][0])) + query_disk_offering = self.dbclient.execute( + "select uuid from disk_offering where id= '%s';" % + query_so_id[0][0]) + + self.assertEqual( + created_so_id, + query_disk_offering[0][0], + "system vms are not using service offering mentioned in " + "global settings") + + # 6-repeate 1 with system.vm.use.local.storage=false + update_global_settings( + self, + value='false', + name='system.vm.use.local.storage', + zoneid=self.zone.id) + # 7-repeate 2 with storage type local + created_so_id = create_system_so(self, value, "local") + # 8-repeate 3 + update_global_settings(self, value=created_so_id, name=name) + + # 9-repeate 4 + destroy_systemvm(self, value) + # repeate 5 + query_zone_id = self.dbclient.execute( + "select id from data_center where uuid= '%s';" % self.zone.id + ) + query_so_id = self.dbclient.execute( + "select service_offering_id from vm_instance where type='%s'and " + "state='Running' and data_center_id= '%s';" % + (value, query_zone_id[0][0])) + query_disk_offering = self.dbclient.execute( + "select uuid from disk_offering where id= '%s';" % + query_so_id[0][0]) + + self.assertEqual( + created_so_id, + query_disk_offering[0][0], + "system vms are not using service offering mentioned in" + " global settings") + + @attr(tags=["advanced"]) + def test_04_router_vms(self): + """ Check if router vm is honouring zone level setting + system.vm.use.local.storage""" + + # 1-list configurations + list_conf = Configurations.list(self.apiclient, + name="system.vm.use.local.storage", + zoneid=self.zone.id) + self.assertEqual( + validateList(list_conf)[0], + PASS, + "Check List configuration response for " + "system.vm.use.local.storage") + + # 2-create network offering + self.network_offering = NetworkOffering.create( + self.apiclient, + self.testdata["network_offering"], + ispersistent='true' + ) + + # 3-list netwrok offerings + list_nw_of = NetworkOffering.list(self.apiclient, + id=self.network_offering.id) + self.assertEqual( + validateList(list_nw_of)[0], + PASS, + "Check the list network response" + ) + self.assertEqual( + str(list_nw_of[0].id), + str(self.network_offering.id), + "Check the created network offering id and " + "listed network offering id" + ) + self._cleanup.append(self.network_offering) + + # 4-Enable network offering + self.network_offering.update(self.apiclient, state='Enabled') + + # 5-List network offering + list_nw_of1 = NetworkOffering.list(self.apiclient, + id=self.network_offering.id) + self.assertEqual( + validateList(list_nw_of1)[0], + PASS, + "Check the list network response" + ) + self.assertEqual( + str(list_nw_of1[0].state), + "Enabled", + "Check the created network state" + ) + + # 6-crete network using network offering + self.network = Network.create( + self.apiclient, + self.testdata["network"], + networkofferingid=self.network_offering.id, + zoneid=self.zone.id, + accountid=self.account.name, + domainid=self.account.domainid + ) + # 7-List network + list_network = Network.list(self.apiclient, + accountid=self.account.name, + domainid=self.account.domainid, + id=self.network.id) + self.assertEqual(validateList(list_network)[0], + PASS, + "check list netwok response ") + self.assertEqual( + list_network[0].id, + self.network.id, + "List network id %s and created network id %s does not match" % + (list_network[0].id, + self.network.id)) + + # 8-List router + list_router = Router.list(self.apiclient, + networkid=self.network.id, + accountid=self.account.name, + domainid=self.account.domainid) + + self.assertEqual( + validateList(list_router)[0], + PASS, + "check list router response") + + # 9-List service offerings + list_so = ServiceOffering.list(self.apiclient, + issystem='true', + id=list_router[0].serviceofferingid + ) + self.assertEqual( + validateList(list_so)[0], + PASS, + "check list service offering response") + if list_conf[0].value == 'true': + storage_type = 'local' + value1 = 'false' + elif list_conf[0].value == 'false': + storage_type = 'shared' + value1 = 'true' + else: + raise Exception("check list_conf[0].value") + self.assertEqual( + list_so[0].storagetype, + storage_type, + "Check VR storage type and zone level settig" + ) + + # 10-Update zone level setting + update_global_settings( + self, + value=value1, + name="system.vm.use.local.storage", + zoneid=self.zone.id) + + # 11-List configurations + list_conf1 = Configurations.list(self.apiclient, + name="system.vm.use.local.storage", + zoneid=self.zone.id) + self.assertEqual( + validateList(list_conf1)[0], + PASS, + "Check List configuration response for " + "system.vm.use.local.storage") + + self.assertEqual( + list_conf1[0].value, + value1, + "Check the system.vm.use.local.storage value" + ) + self.network.restart(self.apiclient, + cleanup='true' + ) + # 12-List network + list_network1 = Network.list(self.apiclient, + accountid=self.account.name, + domainid=self.account.domainid, + id=self.network.id) + self.assertEqual(validateList(list_network1)[0], + PASS, + "check list netwok response ") + + # 13-list VR + list_router1 = Router.list(self.apiclient, + networkid=list_network1[0].id, + accountid=self.account.name, + domainid=self.account.domainid) + self.assertEqual( + validateList(list_router1)[0], + PASS, + "check list router response" + ) + # 14-list service offerings + list_so1 = ServiceOffering.list(self.apiclient, + issystem='true', + id=list_router1[0].serviceofferingid + ) + self.assertEqual( + validateList(list_so1)[0], + PASS, + "check list service offering response" + ) + if list_conf1[0].value == 'true': + storage_type1 = 'local' + elif list_conf1[0].value == 'false': + storage_type1 = 'shared' + else: + raise Exception("check list_conf[0].value") + self.assertEqual( + list_so1[0].storagetype, + storage_type1, + "Check VR storage type and zone level settings" + ) From 2148dca24b1d3f7a345a6e5c7653b4df20a86c02 Mon Sep 17 00:00:00 2001 From: ramamurtis Date: Tue, 19 May 2015 16:52:43 +0530 Subject: [PATCH 071/175] CLOUDSTACK-8301: Enable configuring local storage use for system VMs at zone level. This commit contains the UI changes for the feature. Signed-off-by: Koushik Das This closes #259 --- .../classes/resources/messages.properties | 3 +- ui/dictionary2.jsp | 3 +- ui/scripts/zoneWizard.js | 92 +++++++++++-------- 3 files changed, 59 insertions(+), 39 deletions(-) diff --git a/client/WEB-INF/classes/resources/messages.properties b/client/WEB-INF/classes/resources/messages.properties index 54ac2f3fe3a0..20970fea94d2 100644 --- a/client/WEB-INF/classes/resources/messages.properties +++ b/client/WEB-INF/classes/resources/messages.properties @@ -757,7 +757,8 @@ label.load.balancer=Load Balancer label.load.balancing.policies=Load balancing policies label.load.balancing=Load Balancing label.loading=Loading -label.local.storage.enabled=Local storage enabled +label.local.storage.enabled=Enable local storage for User VMs +label.local.storage.enabled.system.vms=Enable local storage for System VMs label.local.storage=Local Storage label.local=Local label.login=Login diff --git a/ui/dictionary2.jsp b/ui/dictionary2.jsp index e588528b9d2a..12518beee936 100644 --- a/ui/dictionary2.jsp +++ b/ui/dictionary2.jsp @@ -1057,6 +1057,7 @@ under the License. 'label.add.private.gateway': '', 'label.ovm3.pool': '', 'label.ovm3.cluster': '', -'label.ovm3.vip': '' +'label.ovm3.vip': '', +'label.local.storage.enabled.system.vms': '' }); diff --git a/ui/scripts/zoneWizard.js b/ui/scripts/zoneWizard.js index 2ae056b8a336..f39f25e03f83 100755 --- a/ui/scripts/zoneWizard.js +++ b/ui/scripts/zoneWizard.js @@ -388,7 +388,10 @@ }, addPrimaryStorage: function(args) { - return args.data.localstorageenabled != 'on'; + if(args.data.localstorageenabled == 'on' && args.data.localstorageenabledforsystemvm == 'on') { + return false; //skip step only when both localstorage and localstorage for system vm are checked + } + return true; } }, @@ -689,23 +692,15 @@ label: 'label.local.storage.enabled', isBoolean: true, onChange: function(args) { - var $checkbox = args.$checkbox; - if ($checkbox.is(':checked')) { - cloudStack.dialog.confirm({ - message: 'message.zoneWizard.enable.local.storage', - action: function() { - $checkbox.attr('checked', true); - }, - cancelAction: function() { - $checkbox.attr('checked', false); - } - }); + } + }, - return false; - } + localstorageenabledforsystemvm: { + label: 'label.local.storage.enabled.system.vms', + isBoolean: true, + onChange: function(args) { - return true; } } } @@ -2346,8 +2341,8 @@ }, action: function(args) { - var $wizard = args.wizard; - + var $wizard = args.wizard; + var formData = args.data; var advZoneConfiguredVirtualRouterCount = 0; //for multiple physical networks in advanced zone. Each physical network has 2 virtual routers: regular one and VPC one. var success = args.response.success; @@ -4522,29 +4517,52 @@ }); } - $.ajax({ - url: createURL("addHost"), - type: "POST", - data: data, - success: function(json) { - stepFns.addPrimaryStorage({ - data: $.extend(args.data, { - returnedHost: json.addhostresponse.host[0] - }) - }); - }, - error: function(XMLHttpResponse) { - var errorMsg = parseXMLHttpResponse(XMLHttpResponse); - error('addHost', errorMsg, { - fn: 'addHost', - args: args - }); - } - }); + var addHostAjax = function() { + $.ajax({ + url: createURL("addHost"), + type: "POST", + data: data, + success: function(json) { + stepFns.addPrimaryStorage({ + data: $.extend(args.data, { + returnedHost: json.addhostresponse.host[0] + }) + }); + }, + error: function(XMLHttpResponse) { + var errorMsg = parseXMLHttpResponse(XMLHttpResponse); + error('addHost', errorMsg, { + fn: 'addHost', + args: args + }); + } + }); + }; + + if(args.data.zone.localstorageenabledforsystemvm == 'on') { + $.ajax({ + url: createURL("updateConfiguration&name=system.vm.use.local.storage&value=true&zoneid=" + args.data.returnedZone.id), + dataType: "json", + success: function(json) { + addHostAjax(); + }, + error: function(XMLHttpResponse) { + var errorMsg = parseXMLHttpResponse(XMLHttpResponse); + error('addHost', errorMsg, { + fn: 'addHost', + args: args + }); + } + }); + } else { + addHostAjax(); + } + + }, addPrimaryStorage: function(args) { - if (args.data.zone.localstorageenabled == 'on') { //use local storage, don't need primary storage. So, skip this step. + if (args.data.zone.localstorageenabled == 'on' && args.data.zone.localstorageenabledforsystemvm == 'on') { //use local storage, don't need primary storage. So, skip this step. stepFns.addSecondaryStorage({ data: args.data }); From 166df0f153c46cc0098757e0493b32b45a1da8cc Mon Sep 17 00:00:00 2001 From: Gaurav Aradhye Date: Wed, 20 May 2015 11:32:16 +0530 Subject: [PATCH 072/175] CLOUDSTACK-8394: Skipping recurring snapshot test cases for Hyperv and LXC Signed-off-by: Gaurav Aradhye This closes #267 --- .../component/test_recurring_snapshots.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/test/integration/component/test_recurring_snapshots.py b/test/integration/component/test_recurring_snapshots.py index 9912fdab2601..9d3c61876a96 100644 --- a/test/integration/component/test_recurring_snapshots.py +++ b/test/integration/component/test_recurring_snapshots.py @@ -144,6 +144,14 @@ def setUpClass(cls): cls.testClient = super(TestRecurringSnapshots, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() + cls._cleanup = [] + + cls.unsupportedHypervisor = False + cls.hypervisor = cls.testClient.getHypervisorInfo() + if cls.hypervisor.lower() in ['hyperv', "lxc"]: + cls.unsupportedHypervisor = True + return + cls.services = Services().services # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) @@ -153,6 +161,7 @@ def setUpClass(cls): cls.api_client, cls.services["disk_offering"] ) + cls._cleanup.append(cls.disk_offering) template = get_template( cls.api_client, cls.zone.id, @@ -175,6 +184,7 @@ def setUpClass(cls): cls.services["account"], domainid=cls.domain.id ) + cls._cleanup.append(cls.account) cls.services["account"] = cls.account.name @@ -182,6 +192,7 @@ def setUpClass(cls): cls.api_client, cls.services["service_offering"] ) + cls._cleanup.append(cls.service_offering) cls.virtual_machine_with_disk = \ VirtualMachine.create( cls.api_client, @@ -200,11 +211,6 @@ def setUpClass(cls): domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) - cls._cleanup = [ - cls.service_offering, - cls.disk_offering, - cls.account, - ] return @classmethod @@ -220,6 +226,9 @@ def setUp(self): self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection() self.cleanup = [] + + if self.unsupportedHypervisor: + self.skipTest("Snapshots feature is not supported on Hyper-V/LXC") return def tearDown(self): From ab7473eea0cf34ce50fbdeb62f2e3ddd8adfd839 Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Mon, 18 May 2015 16:24:00 +0200 Subject: [PATCH 073/175] Changing the JUnit runner in order to avoid problems with Java 8 - All tests passed using different approaches - Maven with parameters: -Dmaven.compiler.source=1.8 -Dmaven.compiler.target=1.8 - Maven without parameters All builds were executed using javac 1.8.0_31 Signed-off-by: Rohit Yadav This closes #266 --- .../hypervisor/kvm/resource/LibvirtComputingResourceTest.java | 4 ++-- .../xenserver/resource/wrapper/CitrixRequestWrapperTest.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index 7f378a346e85..456265b61f11 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -68,7 +68,7 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; -import org.powermock.modules.junit4.PowerMockRunner; +import org.mockito.runners.MockitoJUnitRunner; import org.w3c.dom.Document; import org.xml.sax.SAXException; @@ -170,7 +170,7 @@ import com.cloud.vm.VirtualMachine.PowerState; import com.cloud.vm.VirtualMachine.Type; -@RunWith(PowerMockRunner.class) +@RunWith(MockitoJUnitRunner.class) public class LibvirtComputingResourceTest { @Mock diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapperTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapperTest.java index 28fc3708d614..6a1be8c27b6c 100644 --- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapperTest.java +++ b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapperTest.java @@ -41,8 +41,8 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; import org.powermock.api.mockito.PowerMockito; -import org.powermock.modules.junit4.PowerMockRunner; import com.cloud.agent.api.Answer; import com.cloud.agent.api.AttachIsoCommand; @@ -134,7 +134,7 @@ import com.xensource.xenapi.Types.BadServerResponse; import com.xensource.xenapi.Types.XenAPIException; -@RunWith(PowerMockRunner.class) +@RunWith(MockitoJUnitRunner.class) public class CitrixRequestWrapperTest { @Mock From 3894d34b2c64c999ec7e61730f8344d37e09e2d4 Mon Sep 17 00:00:00 2001 From: Wido den Hollander Date: Wed, 20 May 2015 13:27:24 +0200 Subject: [PATCH 074/175] CLOUDSTACK-8489: Set smbios information for guest This allows a guest to easily detect that it is running inside CloudStack and see which UUID it has. --- .../kvm/resource/LibvirtComputingResource.java | 3 ++- .../hypervisor/kvm/resource/LibvirtVMDef.java | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 995a8cfd2ec3..13f8dc565002 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -1824,6 +1824,7 @@ public LibvirtVMDef createVMFromSpec(final VirtualMachineTO vmTO) { } guest.setGuestArch(vmTO.getArch()); guest.setMachineType("pc"); + guest.setUuid(uuid); guest.setBootOrder(GuestDef.bootOrder.CDROM); guest.setBootOrder(GuestDef.bootOrder.HARDISK); @@ -3324,4 +3325,4 @@ public String mapRbdDevice(final KVMPhysicalDisk disk){ } return device; } -} \ No newline at end of file +} diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java index 9be12c305793..25ad8e957785 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java @@ -59,6 +59,7 @@ public String toString() { private String _initrd; private String _root; private String _cmdline; + private String _uuid; private final List _bootdevs = new ArrayList(); private String _machine; @@ -93,10 +94,23 @@ public void setBootOrder(bootOrder order) { _bootdevs.add(order); } + public void setUuid(String uuid) { + _uuid = uuid; + } + @Override public String toString() { if (_type == guestType.KVM) { StringBuilder guestDef = new StringBuilder(); + + guestDef.append("\n"); + guestDef.append("\n"); + guestDef.append("Apache Software Foundation\n"); + guestDef.append("CloudStack " + _type.toString() + " Hypervisor\n"); + guestDef.append("" + _uuid + "\n"); + guestDef.append("\n"); + guestDef.append("\n"); + guestDef.append("\n"); guestDef.append("\n"); } } + guestDef.append("\n"); guestDef.append("\n"); return guestDef.toString(); } else if (_type == guestType.LXC) { From 8571314406cb396dbe18eae1ad8da40884e6888b Mon Sep 17 00:00:00 2001 From: Rajani Karuturi Date: Wed, 20 May 2015 17:17:09 +0530 Subject: [PATCH 075/175] Fixed blocker issues reported by sonarqube in js files All of them are trailing comma in array or object more details @ https://analysis.apache.org/component_issues?id=org.apache.cloudstack%3Acloudstack#resolved=false|severities=BLOCKER|languages=js --- ui/scripts/accounts.js | 4 ++-- ui/scripts/configuration.js | 6 +++--- ui/scripts/docs.js | 2 +- ui/scripts/network.js | 2 +- ui/scripts/storage.js | 2 +- ui/scripts/system.js | 12 ++++++------ ui/scripts/templates.js | 9 ++++----- ui/scripts/ui-custom/instanceWizard.js | 2 +- ui/scripts/ui-custom/login.js | 2 +- ui/scripts/zoneWizard.js | 2 +- 10 files changed, 21 insertions(+), 22 deletions(-) diff --git a/ui/scripts/accounts.js b/ui/scripts/accounts.js index d539af4d354d..9e47d11bca68 100644 --- a/ui/scripts/accounts.js +++ b/ui/scripts/accounts.js @@ -1531,7 +1531,7 @@ label: 'label.name', validation: { required: true - }, + } }, publickey: { label: 'Public Key' @@ -1587,7 +1587,7 @@ data: items }); } - }, + } }, account: { label: 'label.account', diff --git a/ui/scripts/configuration.js b/ui/scripts/configuration.js index 184e38a90986..5cb6f8d64686 100644 --- a/ui/scripts/configuration.js +++ b/ui/scripts/configuration.js @@ -2157,7 +2157,7 @@ label: 'label.disk.iops.write.rate' }, cacheMode: { - label: 'label.cache.mode', + label: 'label.cache.mode' }, tags: { label: 'label.storage.tags' @@ -3684,7 +3684,7 @@ fields[id.isEnabled] = { label: serviceDisplayName, - isBoolean: true, + isBoolean: true }; serviceFields.push(id.isEnabled); @@ -3734,7 +3734,7 @@ dependsOn: 'service.SourceNat.isEnabled', isBoolean: true } - },//end of fields + }//end of fields }, //end of createForm action: function(args) { diff --git a/ui/scripts/docs.js b/ui/scripts/docs.js index c8337e1ecd4c..53c31c2f36de 100755 --- a/ui/scripts/docs.js +++ b/ui/scripts/docs.js @@ -368,7 +368,7 @@ cloudStack.docs = { externalLink: '' }, helpDiskOfferingHypervisorSnapshotReserve: { - desc: 'Hypervisor snapshot reserve space as a percent of a volume (for managed storage using XenServer or VMware) (Ex. The value 25 means 25%.)).', + desc: 'Hypervisor snapshot reserve space as a percent of a volume (for managed storage using XenServer or VMware) (Ex. The value 25 means 25%.)).' }, helpDiskOfferingCacheMode: { desc: 'The write caching mode to use for disks created with this disk offering. This can improve write performance.', diff --git a/ui/scripts/network.js b/ui/scripts/network.js index 3ae3a731d35b..28fca5e0d65d 100755 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -677,7 +677,7 @@ data: null }); } - }, + } }, account: { label: 'label.account', diff --git a/ui/scripts/storage.js b/ui/scripts/storage.js index 618bd6647bb7..9cabaf9a83a3 100644 --- a/ui/scripts/storage.js +++ b/ui/scripts/storage.js @@ -810,7 +810,7 @@ } }, name: { - label: 'label.name', + label: 'label.name' } } }, diff --git a/ui/scripts/system.js b/ui/scripts/system.js index 5e6adcfc8278..0f8fe6a9b381 100644 --- a/ui/scripts/system.js +++ b/ui/scripts/system.js @@ -3985,7 +3985,7 @@ }) }); } - }, + } }, actions: { enable: { @@ -7486,7 +7486,7 @@ actionFilter: networkProviderActionFilter('GloboDns') }); } - }, + } }, actions: { add: { @@ -12917,7 +12917,7 @@ label: 'label.api.version' }, retrycount: { - label: 'label.numretries', + label: 'label.numretries' }, retryinterval: { label: 'label.retry.interval' @@ -13073,7 +13073,7 @@ label: 'label.api.version' }, retrycount: { - label: 'label.numretries', + label: 'label.numretries' }, retryinterval: { label: 'label.retry.interval' @@ -15710,7 +15710,7 @@ $.extend(data, { agentusername: args.data.agentUsername, agentpassword: args.data.agentPassword, - agentport: args.data.agentPort, + agentport: args.data.agentPort }); } } @@ -20286,7 +20286,7 @@ var jid = json[apiCmdRes].jobid; args.response.success({ _custom: { - jobId: jid, + jobId: jid } }); } diff --git a/ui/scripts/templates.js b/ui/scripts/templates.js index 521e022e9792..a535d8a2fd94 100644 --- a/ui/scripts/templates.js +++ b/ui/scripts/templates.js @@ -992,7 +992,7 @@ //***** updateTemplatePermissions ***** var data = { - id: args.context.templates[0].id, + id: args.context.templates[0].id //zoneid: args.context.templates[0].zoneid //can't update template/ISO in only one zone. It always get updated in all zones. }; @@ -1148,7 +1148,7 @@ notification: { poll: pollAsyncJobResult } - }, + } }, tabs: { @@ -1726,8 +1726,7 @@ templatetype: { label: 'label.type' - }, - + } }], @@ -2134,7 +2133,7 @@ //***** updateIsoPermissions ***** var data = { - id: args.context.isos[0].id, + id: args.context.isos[0].id //zoneid: args.context.isos[0].zoneid //can't update template/ISO in only one zone. It always get updated in all zones. }; //if args.data.ispublic is undefined(i.e. checkbox is hidden), do not pass ispublic to API call. diff --git a/ui/scripts/ui-custom/instanceWizard.js b/ui/scripts/ui-custom/instanceWizard.js index 4f8c2e85652d..0a5370e53cb0 100644 --- a/ui/scripts/ui-custom/instanceWizard.js +++ b/ui/scripts/ui-custom/instanceWizard.js @@ -407,7 +407,7 @@ ['featuredisos', 'instance-wizard-featured-isos'], ['communityisos', 'instance-wizard-community-isos'], ['myisos', 'instance-wizard-my-isos'], - ['sharedisos', 'instance-wizard-shared-isos'], + ['sharedisos', 'instance-wizard-shared-isos'] //['isos', 'instance-wizard-all-isos'] ] ).each(function() { diff --git a/ui/scripts/ui-custom/login.js b/ui/scripts/ui-custom/login.js index 1f82c8299822..194c8812c305 100644 --- a/ui/scripts/ui-custom/login.js +++ b/ui/scripts/ui-custom/login.js @@ -142,7 +142,7 @@ }, error: function(xhr) { $login.find('#saml-login').hide(); - }, + } }); // Select language diff --git a/ui/scripts/zoneWizard.js b/ui/scripts/zoneWizard.js index 2ae056b8a336..30fee38e90ea 100755 --- a/ui/scripts/zoneWizard.js +++ b/ui/scripts/zoneWizard.js @@ -471,7 +471,7 @@ desc: 'message.tooltip.internal.dns.2', validation: { ipv4: true - }, + } }, hypervisor: { label: 'label.hypervisor', From 982a0235a0143864e5b0eda1836fb913d91252f6 Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Wed, 20 May 2015 14:52:08 +0200 Subject: [PATCH 076/175] CLOUDSTACK-8486 Removing real IPs from the tests because they cause a long running time for LibvirtComputingResourceTest - In a local machine it takes 1.977s, but in a KVM test environment it's taking 257.879 sec --- .../LibvirtComputingResourceTest.java | 82 +++++++++---------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index 456265b61f11..6d8dc807262b 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -857,7 +857,7 @@ public void testRebootRouterCommand() { final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final String vmName = "Test"; - final RebootRouterCommand command = new RebootRouterCommand(vmName, "192.168.0.10"); + final RebootRouterCommand command = new RebootRouterCommand(vmName, "127.0.0.1"); when(libvirtComputingResource.getVirtRouterResource()).thenReturn(routingResource); when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); @@ -890,7 +890,7 @@ public void testRebootRouterCommandConnect() { final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); final String vmName = "Test"; - final RebootRouterCommand command = new RebootRouterCommand(vmName, "192.168.0.10"); + final RebootRouterCommand command = new RebootRouterCommand(vmName, "127.0.0.1"); when(libvirtComputingResource.getVirtRouterResource()).thenReturn(routingResource); when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); @@ -1235,7 +1235,7 @@ public void testMigrateCommand() { try { when(conn.domainLookupByName(vmName)).thenReturn(dm); - when(libvirtComputingResource.getPrivateIp()).thenReturn("192.168.1.10"); + when(libvirtComputingResource.getPrivateIp()).thenReturn("127.0.0.1"); when(dm.getXMLDesc(0)).thenReturn("host_domain"); when(dm.isPersistent()).thenReturn(1); doNothing().when(dm).undefine(); @@ -1271,7 +1271,7 @@ public void testMigrateCommand() { @Test public void testPingTestHostIpCommand() { - final PingTestCommand command = new PingTestCommand("172.1.10.10"); + final PingTestCommand command = new PingTestCommand("127.0.0.1"); final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); assertNotNull(wrapper); @@ -1282,7 +1282,7 @@ public void testPingTestHostIpCommand() { @Test public void testPingTestPvtIpCommand() { - final PingTestCommand command = new PingTestCommand("169.17.1.10", "192.168.10.10"); + final PingTestCommand command = new PingTestCommand("127.0.0.1", "127.0.0.1"); final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); assertNotNull(wrapper); @@ -1293,7 +1293,7 @@ public void testPingTestPvtIpCommand() { @Test public void testPingOnlyOneIpCommand() { - final PingTestCommand command = new PingTestCommand("169.17.1.10", null); + final PingTestCommand command = new PingTestCommand("127.0.0.1", null); final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); assertNotNull(wrapper); @@ -1632,7 +1632,7 @@ public void testWatchConsoleProxyLoadCommand() { final int interval = 0; final long proxyVmId = 0l; final String proxyVmName = "host"; - final String proxyManagementIp = "169.172.15.16"; + final String proxyManagementIp = "127.0.0.1"; final int proxyCmdPort = 0; final WatchConsoleProxyLoadCommand command = new WatchConsoleProxyLoadCommand(interval, proxyVmId, proxyVmName, proxyManagementIp, proxyCmdPort); @@ -1648,7 +1648,7 @@ public void testWatchConsoleProxyLoadCommand() { public void testCheckConsoleProxyLoadCommand() { final long proxyVmId = 0l; final String proxyVmName = "host"; - final String proxyManagementIp = "169.172.15.16"; + final String proxyManagementIp = "127.0.0.1"; final int proxyCmdPort = 0; final CheckConsoleProxyLoadCommand command = new CheckConsoleProxyLoadCommand(proxyVmId, proxyVmName, proxyManagementIp, proxyCmdPort); @@ -2440,7 +2440,7 @@ public void testCleanupNetworkRulesCmd() { public void testNetworkRulesVmSecondaryIpCommand() { final String vmName = "Test"; final String vmMac = "00:00:00:00"; - final String secondaryIp = "172.168.25.25"; + final String secondaryIp = "127.0.0.1"; final boolean action = true; final NetworkRulesVmSecondaryIpCommand command = new NetworkRulesVmSecondaryIpCommand(vmName, vmMac, secondaryIp, action ); @@ -2476,7 +2476,7 @@ public void testNetworkRulesVmSecondaryIpCommand() { public void testNetworkRulesVmSecondaryIpCommandFailure() { final String vmName = "Test"; final String vmMac = "00:00:00:00"; - final String secondaryIp = "172.168.25.25"; + final String secondaryIp = "127.0.0.1"; final boolean action = true; final NetworkRulesVmSecondaryIpCommand command = new NetworkRulesVmSecondaryIpCommand(vmName, vmMac, secondaryIp, action ); @@ -2570,7 +2570,7 @@ public void testNetworkRulesSystemVmCommandFailure() { @Test public void testCheckSshCommand() { final String instanceName = "Test"; - final String ip = "172.16.16.16"; + final String ip = "127.0.0.1"; final int port = 22; final CheckSshCommand command = new CheckSshCommand(instanceName, ip, port); @@ -2596,7 +2596,7 @@ public void testCheckSshCommand() { @Test public void testCheckSshCommandFailure() { final String instanceName = "Test"; - final String ip = "172.16.16.16"; + final String ip = "127.0.0.1"; final int port = 22; final CheckSshCommand command = new CheckSshCommand(instanceName, ip, port); @@ -2787,12 +2787,12 @@ public void testCheckOnHostCommand() { @Test public void testOvsCreateTunnelCommand() { - final String remoteIp = "172.16.16.16"; + final String remoteIp = "127.0.0.1"; final Integer key = 1; final Long from = 1l; final Long to = 2l; final long networkId = 1l; - final String fromIp = "172.15.15.15"; + final String fromIp = "127.0.0.1"; final String networkName = "eth"; final String networkUuid = "8edb1156-a851-4914-afc6-468ee52ac861"; @@ -2817,12 +2817,12 @@ public void testOvsCreateTunnelCommand() { @Test public void testOvsCreateTunnelCommandFailure1() { - final String remoteIp = "172.16.16.16"; + final String remoteIp = "127.0.0.1"; final Integer key = 1; final Long from = 1l; final Long to = 2l; final long networkId = 1l; - final String fromIp = "172.15.15.15"; + final String fromIp = "127.0.0.1"; final String networkName = "eth"; final String networkUuid = "8edb1156-a851-4914-afc6-468ee52ac861"; @@ -2848,12 +2848,12 @@ public void testOvsCreateTunnelCommandFailure1() { @SuppressWarnings("unchecked") @Test public void testOvsCreateTunnelCommandFailure2() { - final String remoteIp = "172.16.16.16"; + final String remoteIp = "127.0.0.1"; final Integer key = 1; final Long from = 1l; final Long to = 2l; final long networkId = 1l; - final String fromIp = "172.15.15.15"; + final String fromIp = "127.0.0.1"; final String networkName = "eth"; final String networkUuid = "8edb1156-a851-4914-afc6-468ee52ac861"; @@ -2991,7 +2991,7 @@ public void testFenceCommand() { @Test public void testSecurityGroupRulesCmdFalse() { - final String guestIp = "172.16.16.16"; + final String guestIp = "127.0.0.1"; final String guestMac = "00:00:00:00"; final String vmName = "Test"; final Long vmId = 1l; @@ -3043,7 +3043,7 @@ public void testSecurityGroupRulesCmdFalse() { @Test public void testSecurityGroupRulesCmdTrue() { - final String guestIp = "172.16.16.16"; + final String guestIp = "127.0.0.1"; final String guestMac = "00:00:00:00"; final String vmName = "Test"; final Long vmId = 1l; @@ -3105,7 +3105,7 @@ public void testSecurityGroupRulesCmdTrue() { @SuppressWarnings("unchecked") @Test public void testSecurityGroupRulesCmdException() { - final String guestIp = "172.16.16.16"; + final String guestIp = "127.0.0.1"; final String guestMac = "00:00:00:00"; final String vmName = "Test"; final Long vmId = 1l; @@ -3625,7 +3625,7 @@ public void testCreatePrivateTemplateFromVolumeCommand() { //The code is way to big and complex. Will finish the refactor and come back to this to add more cases. final StoragePool pool = Mockito.mock(StoragePool.class);; - final String secondaryStorageUrl = "nfs:/192.168.2.2/storage/secondary"; + final String secondaryStorageUrl = "nfs:/127.0.0.1/storage/secondary"; final long templateId = 1l; final long accountId = 1l; final String userSpecifiedName = "User"; @@ -3762,7 +3762,7 @@ public void testBackupSnapshotCommandLibvirtException() { //The code is way to big and complex. Will finish the refactor and come back to this to add more cases. final StoragePool pool = Mockito.mock(StoragePool.class);; - final String secondaryStorageUrl = "nfs:/192.168.2.2/storage/secondary"; + final String secondaryStorageUrl = "nfs:/127.0.0.1/storage/secondary"; final long accountId = 1l; final String volumePath = "/123/vol"; final String vmName = "Test"; @@ -3809,7 +3809,7 @@ public void testBackupSnapshotCommandLibvirtException() { @Test public void testCreatePrivateTemplateFromSnapshotCommand() { final StoragePool pool = Mockito.mock(StoragePool.class); - final String secondaryStoragePoolURL = "nfs:/192.168.2.2/storage/secondary"; + final String secondaryStoragePoolURL = "nfs:/127.0.0.1/storage/secondary"; final Long dcId = 1l; final Long accountId = 1l; final Long volumeId = 1l; @@ -3883,7 +3883,7 @@ public void testCreatePrivateTemplateFromSnapshotCommand() { @Test public void testCreatePrivateTemplateFromSnapshotCommandConfigurationException() { final StoragePool pool = Mockito.mock(StoragePool.class); - final String secondaryStoragePoolURL = "nfs:/192.168.2.2/storage/secondary"; + final String secondaryStoragePoolURL = "nfs:/127.0.0.1/storage/secondary"; final Long dcId = 1l; final Long accountId = 1l; final Long volumeId = 1l; @@ -3957,7 +3957,7 @@ public void testCreatePrivateTemplateFromSnapshotCommandConfigurationException() @Test public void testCreatePrivateTemplateFromSnapshotCommandInternalErrorException() { final StoragePool pool = Mockito.mock(StoragePool.class); - final String secondaryStoragePoolURL = "nfs:/192.168.2.2/storage/secondary"; + final String secondaryStoragePoolURL = "nfs:/127.0.0.1/storage/secondary"; final Long dcId = 1l; final Long accountId = 1l; final Long volumeId = 1l; @@ -4030,7 +4030,7 @@ public void testCreatePrivateTemplateFromSnapshotCommandInternalErrorException() @Test public void testCreatePrivateTemplateFromSnapshotCommandIOException() { final StoragePool pool = Mockito.mock(StoragePool.class); - final String secondaryStoragePoolURL = "nfs:/192.168.2.2/storage/secondary"; + final String secondaryStoragePoolURL = "nfs:/127.0.0.1/storage/secondary"; final Long dcId = 1l; final Long accountId = 1l; final Long volumeId = 1l; @@ -4109,7 +4109,7 @@ public void testCreatePrivateTemplateFromSnapshotCommandIOException() { @Test public void testCreatePrivateTemplateFromSnapshotCommandCloudRuntime() { final StoragePool pool = Mockito.mock(StoragePool.class); - final String secondaryStoragePoolURL = "nfs:/192.168.2.2/storage/secondary"; + final String secondaryStoragePoolURL = "nfs:/127.0.0.1/storage/secondary"; final Long dcId = 1l; final Long accountId = 1l; final Long volumeId = 1l; @@ -4156,7 +4156,7 @@ public void testCreatePrivateTemplateFromSnapshotCommandCloudRuntime() { @Test public void testCopyVolumeCommand() { final StoragePool storagePool = Mockito.mock(StoragePool.class); - final String secondaryStoragePoolURL = "nfs:/192.168.2.2/storage/secondary"; + final String secondaryStoragePoolURL = "nfs:/127.0.0.1/storage/secondary"; final Long volumeId = 1l; final int wait = 0; final String volumePath = "/vol/path"; @@ -4203,7 +4203,7 @@ public void testCopyVolumeCommand() { @Test public void testCopyVolumeCommandToSecFalse() { final StoragePool storagePool = Mockito.mock(StoragePool.class); - final String secondaryStoragePoolURL = "nfs:/192.168.2.2/storage/secondary"; + final String secondaryStoragePoolURL = "nfs:/127.0.0.1/storage/secondary"; final Long volumeId = 1l; final int wait = 0; final String volumePath = "/vol/path"; @@ -4247,7 +4247,7 @@ public void testCopyVolumeCommandToSecFalse() { @Test public void testCopyVolumeCommandCloudRuntime() { final StoragePool storagePool = Mockito.mock(StoragePool.class); - final String secondaryStoragePoolURL = "nfs:/192.168.2.2/storage/secondary"; + final String secondaryStoragePoolURL = "nfs:/127.0.0.1/storage/secondary"; final Long volumeId = 1l; final int wait = 0; final String volumePath = "/vol/path"; @@ -4288,7 +4288,7 @@ public void testCopyVolumeCommandCloudRuntime() { @Test public void testCopyVolumeCommandCloudRuntime2() { final StoragePool storagePool = Mockito.mock(StoragePool.class); - final String secondaryStoragePoolURL = "nfs:/192.168.2.2/storage/secondary"; + final String secondaryStoragePoolURL = "nfs:/127.0.0.1/storage/secondary"; final Long volumeId = 1l; final int wait = 0; final String volumePath = "/vol/path"; @@ -4316,7 +4316,7 @@ public void testCopyVolumeCommandCloudRuntime2() { @Test public void testCopyVolumeCommandPrimaryNotFound() { final StoragePool storagePool = Mockito.mock(StoragePool.class); - final String secondaryStoragePoolURL = "nfs:/192.168.2.2/storage/secondary"; + final String secondaryStoragePoolURL = "nfs:/127.0.0.1/storage/secondary"; final Long volumeId = 1l; final int wait = 0; final String volumePath = "/vol/path"; @@ -4367,7 +4367,7 @@ public void testPvlanSetupCommandDhcpAdd() { final String networkTag = "/105"; final String dhcpName = "dhcp"; final String dhcpMac = "00:00:00:00"; - final String dhcpIp = "172.10.10.10"; + final String dhcpIp = "127.0.0.1"; final PvlanSetupCommand command = PvlanSetupCommand.createDhcpSetup(op, uri, networkTag, dhcpName, dhcpMac, dhcpIp); @@ -4440,7 +4440,7 @@ public void testPvlanSetupCommandDhcpException() { final String networkTag = "/105"; final String dhcpName = "dhcp"; final String dhcpMac = "00:00:00:00"; - final String dhcpIp = "172.10.10.10"; + final String dhcpIp = "127.0.0.1"; final PvlanSetupCommand command = PvlanSetupCommand.createDhcpSetup(op, uri, networkTag, dhcpName, dhcpMac, dhcpIp); @@ -4482,7 +4482,7 @@ public void testPvlanSetupCommandDhcpDelete() { final String networkTag = "/105"; final String dhcpName = "dhcp"; final String dhcpMac = "00:00:00:00"; - final String dhcpIp = "172.10.10.10"; + final String dhcpIp = "127.0.0.1"; final PvlanSetupCommand command = PvlanSetupCommand.createDhcpSetup(op, uri, networkTag, dhcpName, dhcpMac, dhcpIp); @@ -4506,7 +4506,7 @@ public void testPvlanSetupCommandDhcpDelete() { @Test public void testResizeVolumeCommand() { - final String path = "nfs:/192.168.2.2/storage/secondary"; + final String path = "nfs:/127.0.0.1/storage/secondary"; final StorageFilerTO pool = Mockito.mock(StorageFilerTO.class); final Long currentSize = 100l; final Long newSize = 200l; @@ -4559,7 +4559,7 @@ public void testResizeVolumeCommand() { @Test public void testResizeVolumeCommandSameSize() { - final String path = "nfs:/192.168.2.2/storage/secondary"; + final String path = "nfs:/127.0.0.1/storage/secondary"; final StorageFilerTO pool = Mockito.mock(StorageFilerTO.class); final Long currentSize = 100l; final Long newSize = 100l; @@ -4577,7 +4577,7 @@ public void testResizeVolumeCommandSameSize() { @Test public void testResizeVolumeCommandShrink() { - final String path = "nfs:/192.168.2.2/storage/secondary"; + final String path = "nfs:/127.0.0.1/storage/secondary"; final StorageFilerTO pool = Mockito.mock(StorageFilerTO.class); final Long currentSize = 100l; final Long newSize = 200l; @@ -4606,7 +4606,7 @@ public void testResizeVolumeCommandShrink() { @SuppressWarnings("unchecked") @Test public void testResizeVolumeCommandException() { - final String path = "nfs:/192.168.2.2/storage/secondary"; + final String path = "nfs:/127.0.0.1/storage/secondary"; final StorageFilerTO pool = Mockito.mock(StorageFilerTO.class); final Long currentSize = 100l; final Long newSize = 200l; @@ -4654,7 +4654,7 @@ public void testResizeVolumeCommandException() { @SuppressWarnings("unchecked") @Test public void testResizeVolumeCommandException2() { - final String path = "nfs:/192.168.2.2/storage/secondary"; + final String path = "nfs:/127.0.0.1/storage/secondary"; final StorageFilerTO pool = Mockito.mock(StorageFilerTO.class); final Long currentSize = 100l; final Long newSize = 200l; From c43e4db4e046977e14e4be9a15a3b8b66416c281 Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Tue, 19 May 2015 16:10:58 +0200 Subject: [PATCH 077/175] ListFirewallEgressRulesCmd: add interfaces and minor cleanup This commit does not implement new functionality: * Fixes duplicate parameter in API docs. * Fixes a bunch of typos. * Add interfaces to make it easier for the FirewallService interface. Signed-off-by: Rohit Yadav This closes #249 --- .../network/firewall/FirewallService.java | 6 ++-- .../api/BaseListAccountResourcesCmd.java | 4 ++- .../apache/cloudstack/api/BaseListCmd.java | 8 ++++- .../api/BaseListDomainResourcesCmd.java | 5 ++- ...BaseListProjectAndAccountResourcesCmd.java | 3 +- .../api/BaseListTaggedResourcesCmd.java | 3 +- .../api/IBaseListAccountResourcesCmd.java | 24 ++++++++++++++ .../apache/cloudstack/api/IBaseListCmd.java | 32 +++++++++++++++++++ .../api/IBaseListDomainResourcesCmd.java | 26 +++++++++++++++ ...BaseListProjectAndAccountResourcesCmd.java | 22 +++++++++++++ .../api/IBaseListTaggedResourcesCmd.java | 24 ++++++++++++++ .../user/firewall/IListFirewallRulesCmd.java | 31 ++++++++++++++++++ .../firewall/ListEgressFirewallRulesCmd.java | 31 +++++++++++++++--- .../user/firewall/ListFirewallRulesCmd.java | 10 ++++-- .../network/firewall/FirewallManagerImpl.java | 4 +-- .../network/MockFirewallManagerImpl.java | 4 +-- 16 files changed, 216 insertions(+), 21 deletions(-) create mode 100644 api/src/org/apache/cloudstack/api/IBaseListAccountResourcesCmd.java create mode 100644 api/src/org/apache/cloudstack/api/IBaseListCmd.java create mode 100644 api/src/org/apache/cloudstack/api/IBaseListDomainResourcesCmd.java create mode 100644 api/src/org/apache/cloudstack/api/IBaseListProjectAndAccountResourcesCmd.java create mode 100644 api/src/org/apache/cloudstack/api/IBaseListTaggedResourcesCmd.java create mode 100644 api/src/org/apache/cloudstack/api/command/user/firewall/IListFirewallRulesCmd.java diff --git a/api/src/com/cloud/network/firewall/FirewallService.java b/api/src/com/cloud/network/firewall/FirewallService.java index 41b170da5b8e..6525c0778a06 100644 --- a/api/src/com/cloud/network/firewall/FirewallService.java +++ b/api/src/com/cloud/network/firewall/FirewallService.java @@ -18,7 +18,7 @@ import java.util.List; -import org.apache.cloudstack.api.command.user.firewall.ListFirewallRulesCmd; +import org.apache.cloudstack.api.command.user.firewall.IListFirewallRulesCmd; import com.cloud.exception.NetworkRuleConflictException; import com.cloud.exception.ResourceUnavailableException; @@ -28,10 +28,9 @@ public interface FirewallService { FirewallRule createIngressFirewallRule(FirewallRule rule) throws NetworkRuleConflictException; - FirewallRule createEgressFirewallRule(FirewallRule rule) throws NetworkRuleConflictException; - Pair, Integer> listFirewallRules(ListFirewallRulesCmd cmd); + Pair, Integer> listFirewallRules(IListFirewallRulesCmd cmd); /** * Revokes a firewall rule @@ -44,7 +43,6 @@ public interface FirewallService { boolean revokeEgressFirewallRule(long ruleId, boolean apply); boolean applyEgressFirewallRules(FirewallRule rule, Account caller) throws ResourceUnavailableException; - boolean applyIngressFirewallRules(long ipId, Account caller) throws ResourceUnavailableException; FirewallRule getFirewallRule(long ruleId); diff --git a/api/src/org/apache/cloudstack/api/BaseListAccountResourcesCmd.java b/api/src/org/apache/cloudstack/api/BaseListAccountResourcesCmd.java index d494f6403fba..aa5273ace3bc 100644 --- a/api/src/org/apache/cloudstack/api/BaseListAccountResourcesCmd.java +++ b/api/src/org/apache/cloudstack/api/BaseListAccountResourcesCmd.java @@ -17,15 +17,17 @@ package org.apache.cloudstack.api; -public abstract class BaseListAccountResourcesCmd extends BaseListDomainResourcesCmd { +public abstract class BaseListAccountResourcesCmd extends BaseListDomainResourcesCmd implements IBaseListAccountResourcesCmd { @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "list resources by account. Must be used with the domainId parameter.") private String accountName; + @Override public String getAccountName() { return accountName; } + @Override public Boolean getDisplay() { return true; } diff --git a/api/src/org/apache/cloudstack/api/BaseListCmd.java b/api/src/org/apache/cloudstack/api/BaseListCmd.java index 407ad22b6067..36fa36fcfc9a 100644 --- a/api/src/org/apache/cloudstack/api/BaseListCmd.java +++ b/api/src/org/apache/cloudstack/api/BaseListCmd.java @@ -21,7 +21,7 @@ import com.cloud.exception.InvalidParameterValueException; import com.cloud.utils.exception.CSExceptionErrorCode; -public abstract class BaseListCmd extends BaseCmd { +public abstract class BaseListCmd extends BaseCmd implements IBaseListCmd { private static Long s_maxPageSize = null; public static final Long s_pageSizeUnlimited = -1L; @@ -47,14 +47,17 @@ public abstract class BaseListCmd extends BaseCmd { public BaseListCmd() { } + @Override public String getKeyword() { return keyword; } + @Override public Integer getPage() { return page; } + @Override public Integer getPageSize() { if (pageSize != null && s_maxPageSize.longValue() != s_pageSizeUnlimited && pageSize.longValue() > s_maxPageSize.longValue()) { throw new InvalidParameterValueException("Page size can't exceed max allowed page size value: " + s_maxPageSize.longValue()); @@ -84,6 +87,7 @@ public long getEntityOwnerId() { return 0; } + @Override public Long getPageSizeVal() { Long defaultPageSize = s_maxPageSize; final Integer pageSizeInt = getPageSize(); @@ -97,6 +101,7 @@ public Long getPageSizeVal() { return defaultPageSize; } + @Override public Long getStartIndex() { Long startIndex = Long.valueOf(0); final Long pageSizeVal = getPageSizeVal(); @@ -112,6 +117,7 @@ public Long getStartIndex() { return startIndex; } + @Override public ApiCommandJobType getInstanceType() { return ApiCommandJobType.None; } diff --git a/api/src/org/apache/cloudstack/api/BaseListDomainResourcesCmd.java b/api/src/org/apache/cloudstack/api/BaseListDomainResourcesCmd.java index 79f7edc2297c..c402a3c91850 100644 --- a/api/src/org/apache/cloudstack/api/BaseListDomainResourcesCmd.java +++ b/api/src/org/apache/cloudstack/api/BaseListDomainResourcesCmd.java @@ -18,7 +18,7 @@ import org.apache.cloudstack.api.response.DomainResponse; -public abstract class BaseListDomainResourcesCmd extends BaseListCmd { +public abstract class BaseListDomainResourcesCmd extends BaseListCmd implements IBaseListDomainResourcesCmd { @Parameter(name = ApiConstants.LIST_ALL, type = CommandType.BOOLEAN, description = "If set to false, " + "list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false") @@ -34,14 +34,17 @@ public abstract class BaseListDomainResourcesCmd extends BaseListCmd { + " but if true, lists all resources from the parent specified by the domainId till leaves.") private Boolean recursive; + @Override public boolean listAll() { return listAll == null ? false : listAll; } + @Override public boolean isRecursive() { return recursive == null ? false : recursive; } + @Override public Long getDomainId() { return domainId; } diff --git a/api/src/org/apache/cloudstack/api/BaseListProjectAndAccountResourcesCmd.java b/api/src/org/apache/cloudstack/api/BaseListProjectAndAccountResourcesCmd.java index 01ebd7f895b1..46d09b279272 100644 --- a/api/src/org/apache/cloudstack/api/BaseListProjectAndAccountResourcesCmd.java +++ b/api/src/org/apache/cloudstack/api/BaseListProjectAndAccountResourcesCmd.java @@ -18,11 +18,12 @@ import org.apache.cloudstack.api.response.ProjectResponse; -public abstract class BaseListProjectAndAccountResourcesCmd extends BaseListAccountResourcesCmd { +public abstract class BaseListProjectAndAccountResourcesCmd extends BaseListAccountResourcesCmd implements IBaseListProjectAndAccountResourcesCmd { @Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, entityType = ProjectResponse.class, description = "list objects by project") private Long projectId; + @Override public Long getProjectId() { return projectId; } diff --git a/api/src/org/apache/cloudstack/api/BaseListTaggedResourcesCmd.java b/api/src/org/apache/cloudstack/api/BaseListTaggedResourcesCmd.java index 98b88e7a6992..5f177423bd5e 100644 --- a/api/src/org/apache/cloudstack/api/BaseListTaggedResourcesCmd.java +++ b/api/src/org/apache/cloudstack/api/BaseListTaggedResourcesCmd.java @@ -23,10 +23,11 @@ import com.cloud.exception.InvalidParameterValueException; -public abstract class BaseListTaggedResourcesCmd extends BaseListProjectAndAccountResourcesCmd { +public abstract class BaseListTaggedResourcesCmd extends BaseListProjectAndAccountResourcesCmd implements IBaseListTaggedResourcesCmd { @Parameter(name = ApiConstants.TAGS, type = CommandType.MAP, description = "List resources by tags (key/value pairs)") private Map tags; + @Override public Map getTags() { Map tagsMap = null; if (tags != null && !tags.isEmpty()) { diff --git a/api/src/org/apache/cloudstack/api/IBaseListAccountResourcesCmd.java b/api/src/org/apache/cloudstack/api/IBaseListAccountResourcesCmd.java new file mode 100644 index 000000000000..88b7ea5aa68f --- /dev/null +++ b/api/src/org/apache/cloudstack/api/IBaseListAccountResourcesCmd.java @@ -0,0 +1,24 @@ +// 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.api; + +public interface IBaseListAccountResourcesCmd extends IBaseListDomainResourcesCmd { + String getAccountName(); + + Boolean getDisplay(); +} diff --git a/api/src/org/apache/cloudstack/api/IBaseListCmd.java b/api/src/org/apache/cloudstack/api/IBaseListCmd.java new file mode 100644 index 000000000000..70957ea91533 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/IBaseListCmd.java @@ -0,0 +1,32 @@ +// 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.api; + +public interface IBaseListCmd { + String getKeyword(); + + Integer getPage(); + + Integer getPageSize(); + + Long getPageSizeVal(); + + Long getStartIndex(); + + ApiCommandJobType getInstanceType(); +} diff --git a/api/src/org/apache/cloudstack/api/IBaseListDomainResourcesCmd.java b/api/src/org/apache/cloudstack/api/IBaseListDomainResourcesCmd.java new file mode 100644 index 000000000000..6ce6091ad263 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/IBaseListDomainResourcesCmd.java @@ -0,0 +1,26 @@ +// 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.api; + +public interface IBaseListDomainResourcesCmd extends IBaseListCmd { + boolean listAll(); + + boolean isRecursive(); + + Long getDomainId(); +} diff --git a/api/src/org/apache/cloudstack/api/IBaseListProjectAndAccountResourcesCmd.java b/api/src/org/apache/cloudstack/api/IBaseListProjectAndAccountResourcesCmd.java new file mode 100644 index 000000000000..457972e3ddcd --- /dev/null +++ b/api/src/org/apache/cloudstack/api/IBaseListProjectAndAccountResourcesCmd.java @@ -0,0 +1,22 @@ +// 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.api; + +public interface IBaseListProjectAndAccountResourcesCmd extends IBaseListAccountResourcesCmd { + Long getProjectId(); +} diff --git a/api/src/org/apache/cloudstack/api/IBaseListTaggedResourcesCmd.java b/api/src/org/apache/cloudstack/api/IBaseListTaggedResourcesCmd.java new file mode 100644 index 000000000000..6833769b9453 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/IBaseListTaggedResourcesCmd.java @@ -0,0 +1,24 @@ +// 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.api; + +import java.util.Map; + +public interface IBaseListTaggedResourcesCmd extends IBaseListProjectAndAccountResourcesCmd { + Map getTags(); +} diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/IListFirewallRulesCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/IListFirewallRulesCmd.java new file mode 100644 index 000000000000..c63f6477ba27 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/IListFirewallRulesCmd.java @@ -0,0 +1,31 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package org.apache.cloudstack.api.command.user.firewall; + +import com.cloud.network.rules.FirewallRule; +import org.apache.cloudstack.api.IBaseListTaggedResourcesCmd; + +public interface IListFirewallRulesCmd extends IBaseListTaggedResourcesCmd { + Long getIpAddressId(); + + FirewallRule.TrafficType getTrafficType(); + + Long getId(); + + Long getNetworkId(); +} \ No newline at end of file diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/ListEgressFirewallRulesCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/ListEgressFirewallRulesCmd.java index 9e163259e80f..c56e13361a0f 100644 --- a/api/src/org/apache/cloudstack/api/command/user/firewall/ListEgressFirewallRulesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/ListEgressFirewallRulesCmd.java @@ -22,11 +22,14 @@ import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.BaseListTaggedResourcesCmd; import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.response.FirewallResponse; import org.apache.cloudstack.api.response.FirewallRuleResponse; +import org.apache.cloudstack.api.response.IPAddressResponse; import org.apache.cloudstack.api.response.ListResponse; import org.apache.cloudstack.api.response.NetworkResponse; @@ -35,7 +38,7 @@ @APICommand(name = "listEgressFirewallRules", description = "Lists all egress firewall rules for network id.", responseObject = FirewallResponse.class, entityType = {FirewallRule.class}, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) -public class ListEgressFirewallRulesCmd extends ListFirewallRulesCmd { +public class ListEgressFirewallRulesCmd extends BaseListTaggedResourcesCmd implements IListFirewallRulesCmd { public static final Logger s_logger = Logger.getLogger(ListEgressFirewallRulesCmd.class.getName()); private static final String s_name = "listegressfirewallrulesresponse"; @@ -48,28 +51,46 @@ public class ListEgressFirewallRulesCmd extends ListFirewallRulesCmd { @Parameter(name = ApiConstants.NETWORK_ID, type = CommandType.UUID, entityType = NetworkResponse.class, - description = "the id network network for the egress firwall services") + description = "the network id for the egress firewall services") private Long networkId; + @Parameter(name = ApiConstants.IP_ADDRESS_ID, + type = CommandType.UUID, + entityType = IPAddressResponse.class, + description = "the id of IP address of the firewall services") + private Long ipAddressId; + + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "list resources by display flag; only ROOT admin is eligible to pass this parameter", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// - @Override + public Long getIpAddressId() { + return ipAddressId; + } + public Long getNetworkId() { return networkId; } - @Override public FirewallRule.TrafficType getTrafficType() { return FirewallRule.TrafficType.Egress; } - @Override public Long getId() { return id; } + @Override + public Boolean getDisplay() { + if (display != null) { + return display; + } + return super.getDisplay(); + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/ListFirewallRulesCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/ListFirewallRulesCmd.java index 9c9fbc839710..9ace5bdd27d0 100644 --- a/api/src/org/apache/cloudstack/api/command/user/firewall/ListFirewallRulesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/ListFirewallRulesCmd.java @@ -37,7 +37,7 @@ @APICommand(name = "listFirewallRules", description = "Lists all firewall rules for an IP address.", responseObject = FirewallResponse.class, entityType = {FirewallRule.class}, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) -public class ListFirewallRulesCmd extends BaseListTaggedResourcesCmd { +public class ListFirewallRulesCmd extends BaseListTaggedResourcesCmd implements IListFirewallRulesCmd { public static final Logger s_logger = Logger.getLogger(ListFirewallRulesCmd.class.getName()); private static final String s_name = "listfirewallrulesresponse"; @@ -50,13 +50,13 @@ public class ListFirewallRulesCmd extends BaseListTaggedResourcesCmd { @Parameter(name = ApiConstants.IP_ADDRESS_ID, type = CommandType.UUID, entityType = IPAddressResponse.class, - description = "the id of IP address of the firwall services") + description = "the id of IP address of the firewall services") private Long ipAddressId; @Parameter(name = ApiConstants.NETWORK_ID, type = CommandType.UUID, entityType = NetworkResponse.class, - description = "list firewall rules for ceratin network", + description = "list firewall rules for certain network", since = "4.3") private Long networkId; @@ -67,18 +67,22 @@ public class ListFirewallRulesCmd extends BaseListTaggedResourcesCmd { /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// + @Override public Long getIpAddressId() { return ipAddressId; } + @Override public FirewallRule.TrafficType getTrafficType() { return FirewallRule.TrafficType.Ingress; } + @Override public Long getId() { return id; } + @Override public Long getNetworkId() { return networkId; } diff --git a/server/src/com/cloud/network/firewall/FirewallManagerImpl.java b/server/src/com/cloud/network/firewall/FirewallManagerImpl.java index 0537a2758bea..b4e3bc3780d1 100644 --- a/server/src/com/cloud/network/firewall/FirewallManagerImpl.java +++ b/server/src/com/cloud/network/firewall/FirewallManagerImpl.java @@ -30,7 +30,7 @@ import org.apache.log4j.Logger; import org.springframework.stereotype.Component; -import org.apache.cloudstack.api.command.user.firewall.ListFirewallRulesCmd; +import org.apache.cloudstack.api.command.user.firewall.IListFirewallRulesCmd; import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; @@ -254,7 +254,7 @@ public FirewallRuleVO doInTransaction(TransactionStatus status) throws NetworkRu } @Override - public Pair, Integer> listFirewallRules(ListFirewallRulesCmd cmd) { + public Pair, Integer> listFirewallRules(IListFirewallRulesCmd cmd) { Long ipId = cmd.getIpAddressId(); Long id = cmd.getId(); Long networkId = cmd.getNetworkId(); diff --git a/server/test/com/cloud/network/MockFirewallManagerImpl.java b/server/test/com/cloud/network/MockFirewallManagerImpl.java index e484e61b9b6b..52090695bac8 100644 --- a/server/test/com/cloud/network/MockFirewallManagerImpl.java +++ b/server/test/com/cloud/network/MockFirewallManagerImpl.java @@ -22,7 +22,7 @@ import javax.ejb.Local; import javax.naming.ConfigurationException; -import org.apache.cloudstack.api.command.user.firewall.ListFirewallRulesCmd; +import org.apache.cloudstack.api.command.user.firewall.IListFirewallRulesCmd; import com.cloud.exception.NetworkRuleConflictException; import com.cloud.exception.ResourceUnavailableException; @@ -64,7 +64,7 @@ public String getName() { } @Override - public Pair, Integer> listFirewallRules(ListFirewallRulesCmd cmd) { + public Pair, Integer> listFirewallRules(IListFirewallRulesCmd cmd) { // TODO Auto-generated method stub return null; } From bede3a87ad39545081b2e17d8d72bd6851a1b9b3 Mon Sep 17 00:00:00 2001 From: Vadim Kimlaychuk Date: Wed, 20 May 2015 22:08:29 +0300 Subject: [PATCH 078/175] CLOUDSTACK-8231: Fixed UI empty drop-down list for LB rules Signed-off-by: Rohit Yadav This closes #271 --- ui/scripts/network.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/scripts/network.js b/ui/scripts/network.js index 28fca5e0d65d..d857b732db3c 100755 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -1703,7 +1703,7 @@ name: 'source', description: _l('label.lb.algorithm.source') }]; - if (typeof args.context != 'undefined') { + if (typeof args.context == 'undefined') { data = getLBAlgorithms(args.context.networks[0]); } args.response.success({ @@ -3551,7 +3551,7 @@ name: 'source', description: _l('label.lb.algorithm.source') }]; - if (typeof args.context != 'undefined') { + if (typeof args.context == 'undefined') { data = getLBAlgorithms(args.context.networks[0]); } args.response.success({ From 19f3166a3d0da960543984950187323e5300cae9 Mon Sep 17 00:00:00 2001 From: Abhinandan Prateek Date: Thu, 21 May 2015 09:24:03 +0530 Subject: [PATCH 079/175] CLOUDSTACK-8250: host cpu memory used reported incorrectly in host stat --- core/src/com/cloud/agent/api/HostStatsEntry.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/com/cloud/agent/api/HostStatsEntry.java b/core/src/com/cloud/agent/api/HostStatsEntry.java index a7eb524db6e8..82041a604e8b 100644 --- a/core/src/com/cloud/agent/api/HostStatsEntry.java +++ b/core/src/com/cloud/agent/api/HostStatsEntry.java @@ -101,7 +101,7 @@ public void setCpuUtilization(double cpuUtilization) { @Override public double getUsedMemory() { - return (totalMemoryKBs - freeMemoryKBs); + return (totalMemoryKBs - freeMemoryKBs) * 1024; } @Override From 4222364beabb65ea09e7b32114070ab1afd13cd0 Mon Sep 17 00:00:00 2001 From: Abhinandan Prateek Date: Thu, 21 May 2015 10:40:59 +0530 Subject: [PATCH 080/175] CLOUDSTACK-8491: Host maintenance fails if a vm on it is running a custom service offering VM --- .../src/com/cloud/vm/VirtualMachineManagerImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java index a48db6119e09..ad31fdda0a78 100644 --- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java @@ -2358,7 +2358,8 @@ private void orchestrateMigrateAway(final String vmUuid, final long srcHostId, f throw new CloudRuntimeException("Unable to find " + vmUuid); } - final VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm); + ServiceOfferingVO offeringVO = _offeringDao.findById(vm.getId(), vm.getServiceOfferingId()); + final VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm, null, offeringVO, null, null); final Long hostId = vm.getHostId(); if (hostId == null) { From 832f0293b33a8cbfe88cba3a80e514a03ece66ba Mon Sep 17 00:00:00 2001 From: Gaurav Aradhye Date: Thu, 21 May 2015 12:21:35 +0530 Subject: [PATCH 081/175] CLOUDSTACK-8492: Fix dictionary access issue in createChecksum method - common.py Signed-off-by: Gaurav Aradhye This closes #272 --- tools/marvin/marvin/config/test_data.py | 2 +- tools/marvin/marvin/lib/common.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/marvin/marvin/config/test_data.py b/tools/marvin/marvin/config/test_data.py index 2cbcf84d2766..bc5f87513bf0 100644 --- a/tools/marvin/marvin/config/test_data.py +++ b/tools/marvin/marvin/config/test_data.py @@ -936,7 +936,7 @@ "datadiskdevice_1": '/dev/xvdb', "datadiskdevice_2": '/dev/xvdc', # Data Disk }, - "KVM": {"rootdiskdevice": "/dev/vda", + "kvm": {"rootdiskdevice": "/dev/vda", "datadiskdevice_1": "/dev/vdb", "datadiskdevice_2": "/dev/vdc" }, diff --git a/tools/marvin/marvin/lib/common.py b/tools/marvin/marvin/lib/common.py index b1efb626f68a..fb21073658da 100644 --- a/tools/marvin/marvin/lib/common.py +++ b/tools/marvin/marvin/lib/common.py @@ -1438,13 +1438,13 @@ def createChecksum(service=None, format_volume_to_ext3( ssh_client, service["volume_write_path"][ - virtual_machine.hypervisor][disk_type] + virtual_machine.hypervisor.lower()][disk_type] ) cmds = ["fdisk -l", "mkdir -p %s" % service["data_write_paths"]["mount_dir"], "mount -t ext3 %s1 %s" % ( service["volume_write_path"][ - virtual_machine.hypervisor][disk_type], + virtual_machine.hypervisor.lower()][disk_type], service["data_write_paths"]["mount_dir"] ), "mkdir -p %s/%s/%s " % ( @@ -1514,7 +1514,7 @@ def compareChecksum( "mkdir -p %s" % service["data_write_paths"]["mount_dir"], "mount -t ext3 %s1 %s" % ( service["volume_write_path"][ - virt_machine.hypervisor][disk_type], + virt_machine.hypervisor.lower()][disk_type], service["data_write_paths"]["mount_dir"] ), ] From 309c1b466f040d8703476505d3ab5178a542ed4b Mon Sep 17 00:00:00 2001 From: Gaurav Aradhye Date: Thu, 21 May 2015 14:15:45 +0530 Subject: [PATCH 082/175] CLOUDSTACK-8498: Including schedule as default key in recurring_snapshot dict used to create recurring snapshot policy Signed-off-by: Gaurav Aradhye This closes #276 --- tools/marvin/marvin/config/test_data.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/marvin/marvin/config/test_data.py b/tools/marvin/marvin/config/test_data.py index bc5f87513bf0..a691a72a7c9f 100644 --- a/tools/marvin/marvin/config/test_data.py +++ b/tools/marvin/marvin/config/test_data.py @@ -959,6 +959,7 @@ "recurring_snapshot": { "maxsnaps": 2, "timezone": "US/Arizona", + "schedule": 1 }, "volume_offerings": { 0: {"diskname": "TestDiskServ"}, From 59388b09abcc6abe19c138cfba5f907abc147678 Mon Sep 17 00:00:00 2001 From: Gaurav Aradhye Date: Thu, 21 May 2015 16:02:48 +0530 Subject: [PATCH 083/175] CLOUDSTACK-8500: Adding missing key in test_data.py Signed-off-by: Gaurav Aradhye This closes #279 --- tools/marvin/marvin/config/test_data.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/marvin/marvin/config/test_data.py b/tools/marvin/marvin/config/test_data.py index a691a72a7c9f..4c1a1ba54b7d 100644 --- a/tools/marvin/marvin/config/test_data.py +++ b/tools/marvin/marvin/config/test_data.py @@ -1709,6 +1709,7 @@ "mode": 'HTTP_DOWNLOAD' }, "setHostConfigurationForIngressRule": False, + "restartManagementServerThroughTestCase": False, "vmxnet3template": { "displaytext": "VMXNET3 Template", "name": "VMXNET3 template", From 7ff1a81cee2ba631984a18c3c5a201e4e56f2552 Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Thu, 21 May 2015 12:46:39 +0200 Subject: [PATCH 084/175] CLOUDSTACK-8502 Using Annotations on the Citrix wrappers in order to increase maintainability - All wrappers modified - All 100 unit tests are green --- .../com/cloud/resource/CommandWrapper.java | 1 - .../com/cloud/resource/RequestWrapper.java | 30 +++ .../com/cloud/resource/ResourceWrapper.java | 35 ++++ .../CitrixAttachIsoCommandWrapper.java | 2 + .../CitrixAttachVolumeCommandWrapper.java | 2 + ...ixCheckConsoleProxyLoadCommandWrapper.java | 2 + .../CitrixCheckHealthCommandWrapper.java | 2 + .../CitrixCheckNetworkCommandWrapper.java | 2 + .../CitrixCheckOnHostCommandWrapper.java | 2 + .../wrapper/CitrixCheckSshCommandWrapper.java | 2 + ...trixCheckVirtualMachineCommandWrapper.java | 2 + .../CitrixCleanupNetworkRulesCmdWrapper.java | 2 + ...ixClusterVMMetaDataSyncCommandWrapper.java | 2 + .../wrapper/CitrixCreateCommandWrapper.java | 2 + ...CitrixCreateStoragePoolCommandWrapper.java | 2 + .../CitrixCreateVMSnapshotCommandWrapper.java | 2 + ...CitrixDeleteStoragePoolCommandWrapper.java | 2 + .../CitrixDeleteVMSnapshotCommandWrapper.java | 2 + .../wrapper/CitrixDestroyCommandWrapper.java | 2 + .../CitrixGetHostStatsCommandWrapper.java | 2 + .../CitrixGetStorageStatsCommandWrapper.java | 2 + .../CitrixGetVmDiskStatsCommandWrapper.java | 2 + .../CitrixGetVmStatsCommandWrapper.java | 2 + .../CitrixGetVncPortCommandWrapper.java | 2 + .../wrapper/CitrixMaintainCommandWrapper.java | 2 + .../wrapper/CitrixMigrateCommandWrapper.java | 2 + .../CitrixModifySshKeysCommandWrapper.java | 2 + ...CitrixModifyStoragePoolCommandWrapper.java | 2 + .../CitrixNetworkElementCommandWrapper.java | 2 + ...rixNetworkRulesSystemVmCommandWrapper.java | 2 + ...tworkRulesVmSecondaryIpCommandWrapper.java | 2 + ...itrixOvsCreateGreTunnelCommandWrapper.java | 2 + .../CitrixOvsCreateTunnelCommandWrapper.java | 2 + .../CitrixOvsDeleteFlowCommandWrapper.java | 2 + .../CitrixOvsDestroyBridgeCommandWrapper.java | 2 + .../CitrixOvsDestroyTunnelCommandWrapper.java | 2 + ...CitrixOvsFetchInterfaceCommandWrapper.java | 2 + .../CitrixOvsSetTagAndFlowCommandWrapper.java | 2 + .../CitrixOvsSetupBridgeCommandWrapper.java | 2 + ...cPhysicalTopologyConfigCommandWrapper.java | 2 + ...sVpcRoutingPolicyConfigCommandWrapper.java | 2 + ...itrixPerformanceMonitorCommandWrapper.java | 2 + .../wrapper/CitrixPingTestCommandWrapper.java | 2 + .../wrapper/CitrixPlugNicCommandWrapper.java | 2 + ...trixPrepareForMigrationCommandWrapper.java | 2 + ...xPrimaryStorageDownloadCommandWrapper.java | 2 + .../CitrixPvlanSetupCommandWrapper.java | 2 + .../wrapper/CitrixReadyCommandWrapper.java | 2 + .../wrapper/CitrixRebootCommandWrapper.java | 2 + .../CitrixRebootRouterCommandWrapper.java | 2 + .../wrapper/CitrixRequestWrapper.java | 176 ++++-------------- .../CitrixResizeVolumeCommandWrapper.java | 2 + ...itrixRevertToVMSnapshotCommandWrapper.java | 2 + .../wrapper/CitrixScaleVmCommandWrapper.java | 2 + ...itrixSecurityGroupRulesCommandWrapper.java | 2 + .../wrapper/CitrixSetupCommandWrapper.java | 2 + .../wrapper/CitrixStartCommandWrapper.java | 2 + .../wrapper/CitrixStopCommandWrapper.java | 2 + .../CitrixUnPlugNicCommandWrapper.java | 2 + ...itrixUpdateHostPasswordCommandWrapper.java | 2 + .../CitrixUpgradeSnapshotCommandWrapper.java | 2 + ...ixWatchConsoleProxyLoadCommandWrapper.java | 2 + .../XcpServerNetworkUsageCommandWrapper.java | 4 +- .../XenServer56CheckOnHostCommandWrapper.java | 4 +- .../XenServer56FenceCommandWrapper.java | 4 +- ...XenServer56NetworkUsageCommandWrapper.java | 7 +- .../XenServer56FP1FenceCommandWrapper.java | 4 +- ...nServer610MigrateVolumeCommandWrapper.java | 6 +- ...er610MigrateWithStorageCommandWrapper.java | 4 +- ...rateWithStorageCompleteCommandWrapper.java | 4 +- ...grateWithStorageReceiveCommandWrapper.java | 4 +- ...0MigrateWithStorageSendCommandWrapper.java | 8 +- ...Server620SP1GetGPUStatsCommandWrapper.java | 4 +- 73 files changed, 253 insertions(+), 158 deletions(-) create mode 100644 core/src/com/cloud/resource/ResourceWrapper.java rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => xcp}/XcpServerNetworkUsageCommandWrapper.java (93%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => xen56}/XenServer56CheckOnHostCommandWrapper.java (92%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => xen56}/XenServer56FenceCommandWrapper.java (95%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => xen56}/XenServer56NetworkUsageCommandWrapper.java (96%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => xen56p1}/XenServer56FP1FenceCommandWrapper.java (96%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => xen610}/XenServer610MigrateVolumeCommandWrapper.java (93%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => xen610}/XenServer610MigrateWithStorageCommandWrapper.java (97%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => xen610}/XenServer610MigrateWithStorageCompleteCommandWrapper.java (95%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => xen610}/XenServer610MigrateWithStorageReceiveCommandWrapper.java (96%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => xen610}/XenServer610MigrateWithStorageSendCommandWrapper.java (95%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => xen620sp1}/XenServer620SP1GetGPUStatsCommandWrapper.java (92%) diff --git a/core/src/com/cloud/resource/CommandWrapper.java b/core/src/com/cloud/resource/CommandWrapper.java index f68e92a2327e..f8596998b18e 100644 --- a/core/src/com/cloud/resource/CommandWrapper.java +++ b/core/src/com/cloud/resource/CommandWrapper.java @@ -22,7 +22,6 @@ import com.cloud.agent.api.Answer; import com.cloud.agent.api.Command; - public abstract class CommandWrapper { /** diff --git a/core/src/com/cloud/resource/RequestWrapper.java b/core/src/com/cloud/resource/RequestWrapper.java index 0311e2543ce1..31388d64dec3 100644 --- a/core/src/com/cloud/resource/RequestWrapper.java +++ b/core/src/com/cloud/resource/RequestWrapper.java @@ -19,13 +19,19 @@ package com.cloud.resource; +import java.text.MessageFormat; import java.util.Hashtable; +import java.util.Set; + +import org.apache.log4j.Logger; import com.cloud.agent.api.Answer; import com.cloud.agent.api.Command; public abstract class RequestWrapper { + private static final Logger s_logger = Logger.getLogger(RequestWrapper.class); + @SuppressWarnings("rawtypes") protected Hashtable, Hashtable, CommandWrapper>> resources = new Hashtable, Hashtable, CommandWrapper>>(); @@ -108,4 +114,28 @@ protected CommandWrapper retryWhenAllFails(fina } return commandWrapper; } + + @SuppressWarnings("rawtypes") + protected Hashtable, CommandWrapper> processAnnotations(final Set> wrappers) { + final String errorMessage = "Error when adding Xen command to map ==> '{0}'. CommandWrapper class is ==> '{1}'"; + + final Hashtable, CommandWrapper> commands = new Hashtable, CommandWrapper>(); + + for (final Class wrapper : wrappers) { + final ResourceWrapper annotation = wrapper.getAnnotation(ResourceWrapper.class); + if (annotation == null) { + // Just in case people add classes without the annotation in the package and we don't see it. + continue; + } + try { + commands.put(annotation.handles(), wrapper.newInstance()); + } catch (final InstantiationException e) { + s_logger.warn(MessageFormat.format(errorMessage, e.getLocalizedMessage(), wrapper.toString())); + } catch (final IllegalAccessException e) { + s_logger.warn(MessageFormat.format(errorMessage, e.getLocalizedMessage(), wrapper.toString())); + } + } + + return commands; + } } \ No newline at end of file diff --git a/core/src/com/cloud/resource/ResourceWrapper.java b/core/src/com/cloud/resource/ResourceWrapper.java new file mode 100644 index 000000000000..1ea0b8d8c951 --- /dev/null +++ b/core/src/com/cloud/resource/ResourceWrapper.java @@ -0,0 +1,35 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.resource; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import com.cloud.agent.api.Command; + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +public @interface ResourceWrapper { + + Class handles(); + +} \ No newline at end of file diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixAttachIsoCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixAttachIsoCommandWrapper.java index cc444c5a92d5..22fc1ac92190 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixAttachIsoCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixAttachIsoCommandWrapper.java @@ -27,6 +27,7 @@ import com.cloud.agent.api.AttachIsoCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.utils.exception.CloudRuntimeException; import com.xensource.xenapi.Connection; import com.xensource.xenapi.SR; @@ -36,6 +37,7 @@ import com.xensource.xenapi.VDI; import com.xensource.xenapi.VM; +@ResourceWrapper(handles = AttachIsoCommand.class) public final class CitrixAttachIsoCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixAttachIsoCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixAttachVolumeCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixAttachVolumeCommandWrapper.java index 01fd874e55c0..37d28b740c31 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixAttachVolumeCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixAttachVolumeCommandWrapper.java @@ -28,6 +28,7 @@ import com.cloud.agent.api.AttachVolumeCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; import com.xensource.xenapi.SR; import com.xensource.xenapi.Types; @@ -36,6 +37,7 @@ import com.xensource.xenapi.VDI; import com.xensource.xenapi.VM; +@ResourceWrapper(handles = AttachVolumeCommand.class) public final class CitrixAttachVolumeCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixAttachVolumeCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckConsoleProxyLoadCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckConsoleProxyLoadCommandWrapper.java index 08d36b3d995e..83f5a8023717 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckConsoleProxyLoadCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckConsoleProxyLoadCommandWrapper.java @@ -23,8 +23,10 @@ import com.cloud.agent.api.Command; import com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; +import com.cloud.resource.ResourceWrapper; import com.cloud.resource.ServerResource; +@ResourceWrapper(handles = CheckConsoleProxyLoadCommand.class) public final class CitrixCheckConsoleProxyLoadCommandWrapper extends CitrixConsoleProxyLoadCommandWrapper { @Override diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckHealthCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckHealthCommandWrapper.java index f77e3092ab71..4e36ab7991e7 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckHealthCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckHealthCommandWrapper.java @@ -24,7 +24,9 @@ import com.cloud.agent.api.CheckHealthCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = CheckHealthCommand.class) public final class CitrixCheckHealthCommandWrapper extends CommandWrapper { @Override diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckNetworkCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckNetworkCommandWrapper.java index fb62fcebbc35..ca55ab6f74d1 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckNetworkCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckNetworkCommandWrapper.java @@ -29,8 +29,10 @@ import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.network.PhysicalNetworkSetupInfo; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Types.XenAPIException; +@ResourceWrapper(handles = CheckNetworkCommand.class) public final class CitrixCheckNetworkCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixCheckNetworkCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckOnHostCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckOnHostCommandWrapper.java index aaee57b498e5..ffe11951d187 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckOnHostCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckOnHostCommandWrapper.java @@ -24,7 +24,9 @@ import com.cloud.agent.api.CheckOnHostCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = CheckOnHostCommand.class) public final class CitrixCheckOnHostCommandWrapper extends CommandWrapper { @Override diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckSshCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckSshCommandWrapper.java index 4437641d405d..64a4a3f335eb 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckSshCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckSshCommandWrapper.java @@ -26,8 +26,10 @@ import com.cloud.agent.api.check.CheckSshCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; +@ResourceWrapper(handles = CheckSshCommand.class) public final class CitrixCheckSshCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixCheckSshCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckVirtualMachineCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckVirtualMachineCommandWrapper.java index 1ae20c1bcfb2..a1954f42b80d 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckVirtualMachineCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckVirtualMachineCommandWrapper.java @@ -26,9 +26,11 @@ import com.cloud.agent.api.CheckVirtualMachineCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.vm.VirtualMachine.PowerState; import com.xensource.xenapi.Connection; +@ResourceWrapper(handles = CheckVirtualMachineCommand.class) public final class CitrixCheckVirtualMachineCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixCheckVirtualMachineCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCleanupNetworkRulesCmdWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCleanupNetworkRulesCmdWrapper.java index 471c1e8a9ebf..4b2d5d3ba31d 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCleanupNetworkRulesCmdWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCleanupNetworkRulesCmdWrapper.java @@ -25,8 +25,10 @@ import com.cloud.agent.api.CleanupNetworkRulesCmd; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; +@ResourceWrapper(handles = CleanupNetworkRulesCmd.class) public final class CitrixCleanupNetworkRulesCmdWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixCleanupNetworkRulesCmdWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixClusterVMMetaDataSyncCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixClusterVMMetaDataSyncCommandWrapper.java index fb7384be75e9..84bbf984e70a 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixClusterVMMetaDataSyncCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixClusterVMMetaDataSyncCommandWrapper.java @@ -28,10 +28,12 @@ import com.cloud.agent.api.ClusterVMMetaDataSyncCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; import com.xensource.xenapi.Host; import com.xensource.xenapi.Pool; +@ResourceWrapper(handles = ClusterVMMetaDataSyncCommand.class) public final class CitrixClusterVMMetaDataSyncCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixClusterVMMetaDataSyncCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCreateCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCreateCommandWrapper.java index c58c5a9a87a0..c658fd9685e0 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCreateCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCreateCommandWrapper.java @@ -30,12 +30,14 @@ import com.cloud.agent.api.to.VolumeTO; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.vm.DiskProfile; import com.xensource.xenapi.Connection; import com.xensource.xenapi.SR; import com.xensource.xenapi.Types; import com.xensource.xenapi.VDI; +@ResourceWrapper(handles = CreateCommand.class) public final class CitrixCreateCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixCreateCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCreateStoragePoolCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCreateStoragePoolCommandWrapper.java index f749abb04a95..309859736b7c 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCreateStoragePoolCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCreateStoragePoolCommandWrapper.java @@ -26,9 +26,11 @@ import com.cloud.agent.api.to.StorageFilerTO; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.storage.Storage.StoragePoolType; import com.xensource.xenapi.Connection; +@ResourceWrapper(handles = CreateStoragePoolCommand.class) public final class CitrixCreateStoragePoolCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixCreateStoragePoolCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCreateVMSnapshotCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCreateVMSnapshotCommandWrapper.java index 7ccf9279b04c..4b8d616bf9f4 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCreateVMSnapshotCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCreateVMSnapshotCommandWrapper.java @@ -31,6 +31,7 @@ import com.cloud.agent.api.CreateVMSnapshotCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.vm.snapshot.VMSnapshot; import com.xensource.xenapi.Connection; import com.xensource.xenapi.Pool; @@ -42,6 +43,7 @@ import com.xensource.xenapi.VDI; import com.xensource.xenapi.VM; +@ResourceWrapper(handles = CreateVMSnapshotCommand.class) public final class CitrixCreateVMSnapshotCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixCreateVMSnapshotCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixDeleteStoragePoolCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixDeleteStoragePoolCommandWrapper.java index e95a2729b68a..6d2054b64de3 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixDeleteStoragePoolCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixDeleteStoragePoolCommandWrapper.java @@ -26,9 +26,11 @@ import com.cloud.agent.api.to.StorageFilerTO; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; import com.xensource.xenapi.SR; +@ResourceWrapper(handles = DeleteStoragePoolCommand.class) public final class CitrixDeleteStoragePoolCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixDeleteStoragePoolCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixDeleteVMSnapshotCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixDeleteVMSnapshotCommandWrapper.java index 10f409176ff6..4f9d57ab4e7c 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixDeleteVMSnapshotCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixDeleteVMSnapshotCommandWrapper.java @@ -31,6 +31,7 @@ import com.cloud.agent.api.DeleteVMSnapshotCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.vm.snapshot.VMSnapshot; import com.xensource.xenapi.Connection; import com.xensource.xenapi.Types; @@ -38,6 +39,7 @@ import com.xensource.xenapi.VDI; import com.xensource.xenapi.VM; +@ResourceWrapper(handles = DeleteVMSnapshotCommand.class) public final class CitrixDeleteVMSnapshotCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixDeleteVMSnapshotCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixDestroyCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixDestroyCommandWrapper.java index 0685a1b8eb9d..15f9f1c7602b 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixDestroyCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixDestroyCommandWrapper.java @@ -28,10 +28,12 @@ import com.cloud.agent.api.to.VolumeTO; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; import com.xensource.xenapi.VBD; import com.xensource.xenapi.VDI; +@ResourceWrapper(handles = DestroyCommand.class) public final class CitrixDestroyCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixDestroyCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetHostStatsCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetHostStatsCommandWrapper.java index 21d9d3d91381..02c3770ba86e 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetHostStatsCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetHostStatsCommandWrapper.java @@ -27,8 +27,10 @@ import com.cloud.agent.api.HostStatsEntry; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; +@ResourceWrapper(handles = GetHostStatsCommand.class) public final class CitrixGetHostStatsCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixGetHostStatsCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetStorageStatsCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetStorageStatsCommandWrapper.java index e0001ccd9feb..8726141029e8 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetStorageStatsCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetStorageStatsCommandWrapper.java @@ -29,10 +29,12 @@ import com.cloud.agent.api.GetStorageStatsCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; import com.xensource.xenapi.SR; import com.xensource.xenapi.Types.XenAPIException; +@ResourceWrapper(handles = GetStorageStatsCommand.class) public final class CitrixGetStorageStatsCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixGetStorageStatsCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetVmDiskStatsCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetVmDiskStatsCommandWrapper.java index 682d20250560..18e05c47e555 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetVmDiskStatsCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetVmDiskStatsCommandWrapper.java @@ -24,7 +24,9 @@ import com.cloud.agent.api.GetVmDiskStatsCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = GetVmDiskStatsCommand.class) public final class CitrixGetVmDiskStatsCommandWrapper extends CommandWrapper { @Override diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetVmStatsCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetVmStatsCommandWrapper.java index 2b535ea1c41d..5dce256dd2d2 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetVmStatsCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetVmStatsCommandWrapper.java @@ -33,10 +33,12 @@ import com.cloud.agent.api.VmStatsEntry; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; import com.xensource.xenapi.Types.XenAPIException; import com.xensource.xenapi.VM; +@ResourceWrapper(handles = GetVmStatsCommand.class) public final class CitrixGetVmStatsCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixGetVmStatsCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetVncPortCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetVncPortCommandWrapper.java index d69ce27d6060..d57ab5731683 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetVncPortCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetVncPortCommandWrapper.java @@ -28,9 +28,11 @@ import com.cloud.agent.api.GetVncPortCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; import com.xensource.xenapi.VM; +@ResourceWrapper(handles = GetVncPortCommand.class) public final class CitrixGetVncPortCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixGetVncPortCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixMaintainCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixMaintainCommandWrapper.java index d1c5b70f1ffe..8b56e9b9585d 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixMaintainCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixMaintainCommandWrapper.java @@ -30,10 +30,12 @@ import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.hypervisor.xenserver.resource.XsHost; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; import com.xensource.xenapi.Host; import com.xensource.xenapi.Types.XenAPIException; +@ResourceWrapper(handles = MaintainCommand.class) public final class CitrixMaintainCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixMaintainCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixMigrateCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixMigrateCommandWrapper.java index 6c5e55c071a1..a4265ddd9ca4 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixMigrateCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixMigrateCommandWrapper.java @@ -28,12 +28,14 @@ import com.cloud.agent.api.MigrateCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; import com.xensource.xenapi.Host; import com.xensource.xenapi.Types; import com.xensource.xenapi.VBD; import com.xensource.xenapi.VM; +@ResourceWrapper(handles = MigrateCommand.class) public final class CitrixMigrateCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixMigrateCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixModifySshKeysCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixModifySshKeysCommandWrapper.java index 8ea852d91276..f44307425bb6 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixModifySshKeysCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixModifySshKeysCommandWrapper.java @@ -23,7 +23,9 @@ import com.cloud.agent.api.ModifySshKeysCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = ModifySshKeysCommand.class) public final class CitrixModifySshKeysCommandWrapper extends CommandWrapper { @Override diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixModifyStoragePoolCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixModifyStoragePoolCommandWrapper.java index 1a6fb2756aac..64848a408eda 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixModifyStoragePoolCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixModifyStoragePoolCommandWrapper.java @@ -30,12 +30,14 @@ import com.cloud.agent.api.to.StorageFilerTO; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.storage.template.TemplateProp; import com.cloud.utils.exception.CloudRuntimeException; import com.xensource.xenapi.Connection; import com.xensource.xenapi.SR; import com.xensource.xenapi.Types.XenAPIException; +@ResourceWrapper(handles = ModifyStoragePoolCommand.class) public final class CitrixModifyStoragePoolCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixModifyStoragePoolCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixNetworkElementCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixNetworkElementCommandWrapper.java index 801a43b29b63..d59dca359922 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixNetworkElementCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixNetworkElementCommandWrapper.java @@ -24,7 +24,9 @@ import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = NetworkElementCommand.class) public final class CitrixNetworkElementCommandWrapper extends CommandWrapper { @Override diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixNetworkRulesSystemVmCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixNetworkRulesSystemVmCommandWrapper.java index cdd93ae665ba..3c2f5efc2198 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixNetworkRulesSystemVmCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixNetworkRulesSystemVmCommandWrapper.java @@ -23,9 +23,11 @@ import com.cloud.agent.api.NetworkRulesSystemVmCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.vm.VirtualMachine; import com.xensource.xenapi.Connection; +@ResourceWrapper(handles = NetworkRulesSystemVmCommand.class) public final class CitrixNetworkRulesSystemVmCommandWrapper extends CommandWrapper { @Override diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixNetworkRulesVmSecondaryIpCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixNetworkRulesVmSecondaryIpCommandWrapper.java index 48e57d8444af..f19771f91bf6 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixNetworkRulesVmSecondaryIpCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixNetworkRulesVmSecondaryIpCommandWrapper.java @@ -23,8 +23,10 @@ import com.cloud.agent.api.NetworkRulesVmSecondaryIpCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; +@ResourceWrapper(handles = NetworkRulesVmSecondaryIpCommand.class) public final class CitrixNetworkRulesVmSecondaryIpCommandWrapper extends CommandWrapper { @Override diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsCreateGreTunnelCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsCreateGreTunnelCommandWrapper.java index c944e9a16dfa..93d6208c2f11 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsCreateGreTunnelCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsCreateGreTunnelCommandWrapper.java @@ -27,11 +27,13 @@ import com.cloud.agent.api.OvsCreateGreTunnelCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; import com.xensource.xenapi.Network; import com.xensource.xenapi.Types.BadServerResponse; import com.xensource.xenapi.Types.XenAPIException; +@ResourceWrapper(handles = OvsCreateGreTunnelCommand.class) public final class CitrixOvsCreateGreTunnelCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixOvsCreateGreTunnelCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsCreateTunnelCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsCreateTunnelCommandWrapper.java index 3e25a743822a..14d57d874c80 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsCreateTunnelCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsCreateTunnelCommandWrapper.java @@ -26,9 +26,11 @@ import com.cloud.agent.api.OvsCreateTunnelCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; import com.xensource.xenapi.Network; +@ResourceWrapper(handles = OvsCreateTunnelCommand.class) public final class CitrixOvsCreateTunnelCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixOvsCreateTunnelCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsDeleteFlowCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsDeleteFlowCommandWrapper.java index e96f1364b375..8c782ee508bd 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsDeleteFlowCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsDeleteFlowCommandWrapper.java @@ -26,11 +26,13 @@ import com.cloud.agent.api.OvsDeleteFlowCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; import com.xensource.xenapi.Network; import com.xensource.xenapi.Types.BadServerResponse; import com.xensource.xenapi.Types.XenAPIException; +@ResourceWrapper(handles = OvsDeleteFlowCommand.class) public final class CitrixOvsDeleteFlowCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixOvsDeleteFlowCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsDestroyBridgeCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsDestroyBridgeCommandWrapper.java index ee6e4dd9c0ec..62739fb644b1 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsDestroyBridgeCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsDestroyBridgeCommandWrapper.java @@ -25,9 +25,11 @@ import com.cloud.agent.api.OvsDestroyBridgeCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; import com.xensource.xenapi.Network; +@ResourceWrapper(handles = OvsDestroyBridgeCommand.class) public final class CitrixOvsDestroyBridgeCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixOvsDestroyBridgeCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsDestroyTunnelCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsDestroyTunnelCommandWrapper.java index da0fd1f2f91b..543c2f5b3201 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsDestroyTunnelCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsDestroyTunnelCommandWrapper.java @@ -25,9 +25,11 @@ import com.cloud.agent.api.OvsDestroyTunnelCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; import com.xensource.xenapi.Network; +@ResourceWrapper(handles = OvsDestroyTunnelCommand.class) public final class CitrixOvsDestroyTunnelCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixOvsDestroyTunnelCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsFetchInterfaceCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsFetchInterfaceCommandWrapper.java index 1f211a484946..8be62dbd5ba4 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsFetchInterfaceCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsFetchInterfaceCommandWrapper.java @@ -28,12 +28,14 @@ import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.hypervisor.xenserver.resource.XsLocalNetwork; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.utils.exception.CloudRuntimeException; import com.xensource.xenapi.Connection; import com.xensource.xenapi.PIF; import com.xensource.xenapi.Types.BadServerResponse; import com.xensource.xenapi.Types.XenAPIException; +@ResourceWrapper(handles = OvsFetchInterfaceCommand.class) public final class CitrixOvsFetchInterfaceCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixOvsFetchInterfaceCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsSetTagAndFlowCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsSetTagAndFlowCommandWrapper.java index 2048f4d16d2a..087453daec0e 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsSetTagAndFlowCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsSetTagAndFlowCommandWrapper.java @@ -27,11 +27,13 @@ import com.cloud.agent.api.OvsSetTagAndFlowCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; import com.xensource.xenapi.Network; import com.xensource.xenapi.Types.BadServerResponse; import com.xensource.xenapi.Types.XenAPIException; +@ResourceWrapper(handles = OvsSetTagAndFlowCommand.class) public final class CitrixOvsSetTagAndFlowCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixOvsSetTagAndFlowCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsSetupBridgeCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsSetupBridgeCommandWrapper.java index 0c553b4981aa..20c6abc3d535 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsSetupBridgeCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsSetupBridgeCommandWrapper.java @@ -25,8 +25,10 @@ import com.cloud.agent.api.OvsSetupBridgeCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; +@ResourceWrapper(handles = OvsSetupBridgeCommand.class) public final class CitrixOvsSetupBridgeCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixOvsSetupBridgeCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsVpcPhysicalTopologyConfigCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsVpcPhysicalTopologyConfigCommandWrapper.java index 0dc4fb6df747..4b0a66dbca63 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsVpcPhysicalTopologyConfigCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsVpcPhysicalTopologyConfigCommandWrapper.java @@ -25,9 +25,11 @@ import com.cloud.agent.api.OvsVpcPhysicalTopologyConfigCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; import com.xensource.xenapi.Network; +@ResourceWrapper(handles = OvsVpcPhysicalTopologyConfigCommand.class) public final class CitrixOvsVpcPhysicalTopologyConfigCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixOvsVpcPhysicalTopologyConfigCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsVpcRoutingPolicyConfigCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsVpcRoutingPolicyConfigCommandWrapper.java index 4b1e56d7598d..de29dc63acce 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsVpcRoutingPolicyConfigCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsVpcRoutingPolicyConfigCommandWrapper.java @@ -25,9 +25,11 @@ import com.cloud.agent.api.OvsVpcRoutingPolicyConfigCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; import com.xensource.xenapi.Network; +@ResourceWrapper(handles = OvsVpcRoutingPolicyConfigCommand.class) public final class CitrixOvsVpcRoutingPolicyConfigCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixOvsVpcRoutingPolicyConfigCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPerformanceMonitorCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPerformanceMonitorCommandWrapper.java index ad670c1fa3bf..e3f51ce03461 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPerformanceMonitorCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPerformanceMonitorCommandWrapper.java @@ -24,8 +24,10 @@ import com.cloud.agent.api.PerformanceMonitorCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; +@ResourceWrapper(handles = PerformanceMonitorCommand.class) public final class CitrixPerformanceMonitorCommandWrapper extends CommandWrapper { @Override diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPingTestCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPingTestCommandWrapper.java index 8a7a01cf7b01..caf0242552bf 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPingTestCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPingTestCommandWrapper.java @@ -23,8 +23,10 @@ import com.cloud.agent.api.PingTestCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; +@ResourceWrapper(handles = PingTestCommand.class) public final class CitrixPingTestCommandWrapper extends CommandWrapper { @Override diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPlugNicCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPlugNicCommandWrapper.java index a3edfbe13f17..b233baca21b3 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPlugNicCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPlugNicCommandWrapper.java @@ -29,10 +29,12 @@ import com.cloud.agent.api.to.NicTO; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; import com.xensource.xenapi.VIF; import com.xensource.xenapi.VM; +@ResourceWrapper(handles = PlugNicCommand.class) public final class CitrixPlugNicCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixPlugNicCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPrepareForMigrationCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPrepareForMigrationCommandWrapper.java index a8bc18248be4..fde2155394fc 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPrepareForMigrationCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPrepareForMigrationCommandWrapper.java @@ -28,8 +28,10 @@ import com.cloud.agent.api.to.VirtualMachineTO; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; +@ResourceWrapper(handles = PrepareForMigrationCommand.class) public final class CitrixPrepareForMigrationCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixPrepareForMigrationCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPrimaryStorageDownloadCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPrimaryStorageDownloadCommandWrapper.java index 270520777d4a..22eca930f657 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPrimaryStorageDownloadCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPrimaryStorageDownloadCommandWrapper.java @@ -30,10 +30,12 @@ import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; import com.xensource.xenapi.SR; import com.xensource.xenapi.VDI; +@ResourceWrapper(handles = PrimaryStorageDownloadCommand.class) public final class CitrixPrimaryStorageDownloadCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixPrimaryStorageDownloadCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPvlanSetupCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPvlanSetupCommandWrapper.java index 6db9383a79ae..8b7c1749ac10 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPvlanSetupCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPvlanSetupCommandWrapper.java @@ -28,10 +28,12 @@ import com.cloud.hypervisor.xenserver.resource.XsLocalNetwork; import com.cloud.network.Networks.TrafficType; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.utils.exception.CloudRuntimeException; import com.xensource.xenapi.Connection; import com.xensource.xenapi.Types.XenAPIException; +@ResourceWrapper(handles = PvlanSetupCommand.class) public final class CitrixPvlanSetupCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixPvlanSetupCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixReadyCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixReadyCommandWrapper.java index d4c73ebb272d..708ea56bd8a8 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixReadyCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixReadyCommandWrapper.java @@ -29,11 +29,13 @@ import com.cloud.agent.api.ReadyCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; import com.xensource.xenapi.Host; import com.xensource.xenapi.Types.XenAPIException; import com.xensource.xenapi.VM; +@ResourceWrapper(handles = ReadyCommand.class) public final class CitrixReadyCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixReadyCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRebootCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRebootCommandWrapper.java index f2cb54c3cc1f..cc27528b5790 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRebootCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRebootCommandWrapper.java @@ -28,10 +28,12 @@ import com.cloud.agent.api.RebootCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; import com.xensource.xenapi.Types.XenAPIException; import com.xensource.xenapi.VM; +@ResourceWrapper(handles = RebootCommand.class) public final class CitrixRebootCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixRebootCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRebootRouterCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRebootRouterCommandWrapper.java index 5d860b9e6332..182048c5839b 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRebootRouterCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRebootRouterCommandWrapper.java @@ -24,8 +24,10 @@ import com.cloud.agent.api.RebootRouterCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; +@ResourceWrapper(handles = RebootRouterCommand.class) public final class CitrixRebootRouterCommandWrapper extends CommandWrapper { @Override diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapper.java index 02f377428a29..8dabaf244408 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapper.java @@ -20,75 +20,12 @@ package com.cloud.hypervisor.xenserver.resource.wrapper; import java.util.Hashtable; +import java.util.Set; + +import org.reflections.Reflections; import com.cloud.agent.api.Answer; -import com.cloud.agent.api.AttachIsoCommand; -import com.cloud.agent.api.AttachVolumeCommand; -import com.cloud.agent.api.CheckHealthCommand; -import com.cloud.agent.api.CheckNetworkCommand; -import com.cloud.agent.api.CheckOnHostCommand; -import com.cloud.agent.api.CheckVirtualMachineCommand; -import com.cloud.agent.api.CleanupNetworkRulesCmd; -import com.cloud.agent.api.ClusterVMMetaDataSyncCommand; import com.cloud.agent.api.Command; -import com.cloud.agent.api.CreateStoragePoolCommand; -import com.cloud.agent.api.CreateVMSnapshotCommand; -import com.cloud.agent.api.DeleteStoragePoolCommand; -import com.cloud.agent.api.DeleteVMSnapshotCommand; -import com.cloud.agent.api.FenceCommand; -import com.cloud.agent.api.GetGPUStatsCommand; -import com.cloud.agent.api.GetHostStatsCommand; -import com.cloud.agent.api.GetStorageStatsCommand; -import com.cloud.agent.api.GetVmDiskStatsCommand; -import com.cloud.agent.api.GetVmStatsCommand; -import com.cloud.agent.api.GetVncPortCommand; -import com.cloud.agent.api.MaintainCommand; -import com.cloud.agent.api.MigrateCommand; -import com.cloud.agent.api.MigrateWithStorageCommand; -import com.cloud.agent.api.MigrateWithStorageCompleteCommand; -import com.cloud.agent.api.MigrateWithStorageReceiveCommand; -import com.cloud.agent.api.MigrateWithStorageSendCommand; -import com.cloud.agent.api.ModifySshKeysCommand; -import com.cloud.agent.api.ModifyStoragePoolCommand; -import com.cloud.agent.api.NetworkRulesSystemVmCommand; -import com.cloud.agent.api.NetworkRulesVmSecondaryIpCommand; -import com.cloud.agent.api.NetworkUsageCommand; -import com.cloud.agent.api.OvsCreateGreTunnelCommand; -import com.cloud.agent.api.OvsCreateTunnelCommand; -import com.cloud.agent.api.OvsDeleteFlowCommand; -import com.cloud.agent.api.OvsDestroyBridgeCommand; -import com.cloud.agent.api.OvsDestroyTunnelCommand; -import com.cloud.agent.api.OvsFetchInterfaceCommand; -import com.cloud.agent.api.OvsSetTagAndFlowCommand; -import com.cloud.agent.api.OvsSetupBridgeCommand; -import com.cloud.agent.api.OvsVpcPhysicalTopologyConfigCommand; -import com.cloud.agent.api.OvsVpcRoutingPolicyConfigCommand; -import com.cloud.agent.api.PerformanceMonitorCommand; -import com.cloud.agent.api.PingTestCommand; -import com.cloud.agent.api.PlugNicCommand; -import com.cloud.agent.api.PrepareForMigrationCommand; -import com.cloud.agent.api.PvlanSetupCommand; -import com.cloud.agent.api.ReadyCommand; -import com.cloud.agent.api.RebootCommand; -import com.cloud.agent.api.RebootRouterCommand; -import com.cloud.agent.api.RevertToVMSnapshotCommand; -import com.cloud.agent.api.ScaleVmCommand; -import com.cloud.agent.api.SecurityGroupRulesCmd; -import com.cloud.agent.api.SetupCommand; -import com.cloud.agent.api.StartCommand; -import com.cloud.agent.api.StopCommand; -import com.cloud.agent.api.UnPlugNicCommand; -import com.cloud.agent.api.UpdateHostPasswordCommand; -import com.cloud.agent.api.UpgradeSnapshotCommand; -import com.cloud.agent.api.check.CheckSshCommand; -import com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand; -import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand; -import com.cloud.agent.api.routing.NetworkElementCommand; -import com.cloud.agent.api.storage.CreateCommand; -import com.cloud.agent.api.storage.DestroyCommand; -import com.cloud.agent.api.storage.MigrateVolumeCommand; -import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand; -import com.cloud.agent.api.storage.ResizeVolumeCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.hypervisor.xenserver.resource.XcpServerResource; import com.cloud.hypervisor.xenserver.resource.XenServer56FP1Resource; @@ -107,103 +44,60 @@ public class CitrixRequestWrapper extends RequestWrapper { instance = new CitrixRequestWrapper(); } + Reflections baseWrappers = new Reflections("com.cloud.hypervisor.xenserver.resource.wrapper"); + @SuppressWarnings("rawtypes") + Set> baseSet = baseWrappers.getSubTypesOf(CommandWrapper.class); + + Reflections xenServer56Wrappers = new Reflections("com.cloud.hypervisor.xenserver.resource.wrapper.xen56"); + @SuppressWarnings("rawtypes") + Set> xenServer56Set = xenServer56Wrappers.getSubTypesOf(CommandWrapper.class); + + Reflections xenServer56P1Wrappers = new Reflections("com.cloud.hypervisor.xenserver.resource.wrapper.xen56p1"); + @SuppressWarnings("rawtypes") + Set> xenServer56P1Set = xenServer56P1Wrappers.getSubTypesOf(CommandWrapper.class); + + Reflections xenServer610Wrappers = new Reflections("com.cloud.hypervisor.xenserver.resource.wrapper.xen610"); + @SuppressWarnings("rawtypes") + Set> xenServer610Set = xenServer610Wrappers.getSubTypesOf(CommandWrapper.class); + + Reflections xenServer620SP1Wrappers = new Reflections("com.cloud.hypervisor.xenserver.resource.wrapper.xen620sp1"); + @SuppressWarnings("rawtypes") + Set> xenServer620SP1Set = xenServer620SP1Wrappers.getSubTypesOf(CommandWrapper.class); + + Reflections xcpWrappers = new Reflections("com.cloud.hypervisor.xenserver.resource.wrapper.xcp"); + @SuppressWarnings("rawtypes") + Set> xcpSet = xcpWrappers.getSubTypesOf(CommandWrapper.class); + private CitrixRequestWrapper() { init(); } @SuppressWarnings("rawtypes") private void init() { + + final Hashtable, CommandWrapper> citrixCommands = processAnnotations(baseSet); + final Hashtable, CommandWrapper> xenServer56Commands = processAnnotations(xenServer56Set); + final Hashtable, CommandWrapper> xenServer56P1Commands = processAnnotations(xenServer56P1Set); + final Hashtable, CommandWrapper> xenServer610Commands = processAnnotations(xenServer610Set); + final Hashtable, CommandWrapper> xenServer620SP1Commands = processAnnotations(xenServer620SP1Set); + final Hashtable, CommandWrapper> xcpServerResourceCommand = processAnnotations(xcpSet); + // CitrixResourceBase commands - final Hashtable, CommandWrapper> citrixCommands = new Hashtable, CommandWrapper>(); - citrixCommands.put(RebootRouterCommand.class, new CitrixRebootRouterCommandWrapper()); - citrixCommands.put(CreateCommand.class, new CitrixCreateCommandWrapper()); - citrixCommands.put(CheckConsoleProxyLoadCommand.class, new CitrixCheckConsoleProxyLoadCommandWrapper()); - citrixCommands.put(WatchConsoleProxyLoadCommand.class, new CitrixWatchConsoleProxyLoadCommandWrapper()); - citrixCommands.put(ReadyCommand.class, new CitrixReadyCommandWrapper()); - citrixCommands.put(GetHostStatsCommand.class, new CitrixGetHostStatsCommandWrapper()); - citrixCommands.put(GetVmStatsCommand.class, new CitrixGetVmStatsCommandWrapper()); - citrixCommands.put(GetVmDiskStatsCommand.class, new CitrixGetVmDiskStatsCommandWrapper()); - citrixCommands.put(CheckHealthCommand.class, new CitrixCheckHealthCommandWrapper()); - citrixCommands.put(StopCommand.class, new CitrixStopCommandWrapper()); - citrixCommands.put(RebootCommand.class, new CitrixRebootCommandWrapper()); - citrixCommands.put(CheckVirtualMachineCommand.class, new CitrixCheckVirtualMachineCommandWrapper()); - citrixCommands.put(PrepareForMigrationCommand.class, new CitrixPrepareForMigrationCommandWrapper()); - citrixCommands.put(MigrateCommand.class, new CitrixMigrateCommandWrapper()); - citrixCommands.put(DestroyCommand.class, new CitrixDestroyCommandWrapper()); - citrixCommands.put(CreateStoragePoolCommand.class, new CitrixCreateStoragePoolCommandWrapper()); - citrixCommands.put(ModifyStoragePoolCommand.class, new CitrixModifyStoragePoolCommandWrapper()); - citrixCommands.put(DeleteStoragePoolCommand.class, new CitrixDeleteStoragePoolCommandWrapper()); - citrixCommands.put(ResizeVolumeCommand.class, new CitrixResizeVolumeCommandWrapper()); - citrixCommands.put(AttachVolumeCommand.class, new CitrixAttachVolumeCommandWrapper()); - citrixCommands.put(AttachIsoCommand.class, new CitrixAttachIsoCommandWrapper()); - citrixCommands.put(UpgradeSnapshotCommand.class, new CitrixUpgradeSnapshotCommandWrapper()); - citrixCommands.put(GetStorageStatsCommand.class, new CitrixGetStorageStatsCommandWrapper()); - citrixCommands.put(PrimaryStorageDownloadCommand.class, new CitrixPrimaryStorageDownloadCommandWrapper()); - citrixCommands.put(GetVncPortCommand.class, new CitrixGetVncPortCommandWrapper()); - citrixCommands.put(SetupCommand.class, new CitrixSetupCommandWrapper()); - citrixCommands.put(MaintainCommand.class, new CitrixMaintainCommandWrapper()); - citrixCommands.put(PingTestCommand.class, new CitrixPingTestCommandWrapper()); - citrixCommands.put(CheckOnHostCommand.class, new CitrixCheckOnHostCommandWrapper()); - citrixCommands.put(ModifySshKeysCommand.class, new CitrixModifySshKeysCommandWrapper()); - citrixCommands.put(StartCommand.class, new CitrixStartCommandWrapper()); - citrixCommands.put(OvsSetTagAndFlowCommand.class, new CitrixOvsSetTagAndFlowCommandWrapper()); - citrixCommands.put(CheckSshCommand.class, new CitrixCheckSshCommandWrapper()); - citrixCommands.put(SecurityGroupRulesCmd.class, new CitrixSecurityGroupRulesCommandWrapper()); - citrixCommands.put(OvsFetchInterfaceCommand.class, new CitrixOvsFetchInterfaceCommandWrapper()); - citrixCommands.put(OvsCreateGreTunnelCommand.class, new CitrixOvsCreateGreTunnelCommandWrapper()); - citrixCommands.put(OvsDeleteFlowCommand.class, new CitrixOvsDeleteFlowCommandWrapper()); - citrixCommands.put(OvsVpcPhysicalTopologyConfigCommand.class, new CitrixOvsVpcPhysicalTopologyConfigCommandWrapper()); - citrixCommands.put(OvsVpcRoutingPolicyConfigCommand.class, new CitrixOvsVpcRoutingPolicyConfigCommandWrapper()); - citrixCommands.put(CleanupNetworkRulesCmd.class, new CitrixCleanupNetworkRulesCmdWrapper()); - citrixCommands.put(NetworkRulesSystemVmCommand.class, new CitrixNetworkRulesSystemVmCommandWrapper()); - citrixCommands.put(OvsCreateTunnelCommand.class, new CitrixOvsCreateTunnelCommandWrapper()); - citrixCommands.put(OvsSetupBridgeCommand.class, new CitrixOvsSetupBridgeCommandWrapper()); - citrixCommands.put(OvsDestroyBridgeCommand.class, new CitrixOvsDestroyBridgeCommandWrapper()); - citrixCommands.put(OvsDestroyTunnelCommand.class, new CitrixOvsDestroyTunnelCommandWrapper()); - citrixCommands.put(UpdateHostPasswordCommand.class, new CitrixUpdateHostPasswordCommandWrapper()); - citrixCommands.put(ClusterVMMetaDataSyncCommand.class, new CitrixClusterVMMetaDataSyncCommandWrapper()); - citrixCommands.put(CheckNetworkCommand.class, new CitrixCheckNetworkCommandWrapper()); - citrixCommands.put(PlugNicCommand.class, new CitrixPlugNicCommandWrapper()); - citrixCommands.put(UnPlugNicCommand.class, new CitrixUnPlugNicCommandWrapper()); - citrixCommands.put(CreateVMSnapshotCommand.class, new CitrixCreateVMSnapshotCommandWrapper()); - citrixCommands.put(DeleteVMSnapshotCommand.class, new CitrixDeleteVMSnapshotCommandWrapper()); - citrixCommands.put(RevertToVMSnapshotCommand.class, new CitrixRevertToVMSnapshotCommandWrapper()); - citrixCommands.put(NetworkRulesVmSecondaryIpCommand.class, new CitrixNetworkRulesVmSecondaryIpCommandWrapper()); - citrixCommands.put(ScaleVmCommand.class, new CitrixScaleVmCommandWrapper()); - citrixCommands.put(PvlanSetupCommand.class, new CitrixPvlanSetupCommandWrapper()); - citrixCommands.put(PerformanceMonitorCommand.class, new CitrixPerformanceMonitorCommandWrapper()); - citrixCommands.put(NetworkElementCommand.class, new CitrixNetworkElementCommandWrapper()); resources.put(CitrixResourceBase.class, citrixCommands); // XenServer56Resource commands - final Hashtable, CommandWrapper> xenServer56Commands = new Hashtable, CommandWrapper>(); - xenServer56Commands.put(CheckOnHostCommand.class, new XenServer56CheckOnHostCommandWrapper()); - xenServer56Commands.put(FenceCommand.class, new XenServer56FenceCommandWrapper()); - xenServer56Commands.put(NetworkUsageCommand.class, new XenServer56NetworkUsageCommandWrapper()); resources.put(XenServer56Resource.class, xenServer56Commands); // XenServer56FP1Resource commands - final Hashtable, CommandWrapper> xenServer56P1Commands = new Hashtable, CommandWrapper>(); - xenServer56P1Commands.put(FenceCommand.class, new XenServer56FP1FenceCommandWrapper()); resources.put(XenServer56FP1Resource.class, xenServer56P1Commands); // XenServer620SP1Resource commands - final Hashtable, CommandWrapper> xenServer620SP1Commands = new Hashtable, CommandWrapper>(); - xenServer620SP1Commands.put(GetGPUStatsCommand.class, new XenServer620SP1GetGPUStatsCommandWrapper()); resources.put(XenServer620SP1Resource.class, xenServer620SP1Commands); // XenServer610Resource commands - final Hashtable, CommandWrapper> xenServer610Commands = new Hashtable, CommandWrapper>(); - xenServer610Commands.put(MigrateWithStorageCommand.class, new XenServer610MigrateWithStorageCommandWrapper()); - xenServer610Commands.put(MigrateWithStorageReceiveCommand.class, new XenServer610MigrateWithStorageReceiveCommandWrapper()); - xenServer610Commands.put(MigrateWithStorageSendCommand.class, new XenServer610MigrateWithStorageSendCommandWrapper()); - xenServer610Commands.put(MigrateWithStorageCompleteCommand.class, new XenServer610MigrateWithStorageCompleteCommandWrapper()); - xenServer610Commands.put(MigrateVolumeCommand.class, new XenServer610MigrateVolumeCommandWrapper()); resources.put(XenServer610Resource.class, xenServer610Commands); // XcpServerResource commands - final Hashtable, CommandWrapper> xcpServerResourceCommand = new Hashtable, CommandWrapper>(); - xcpServerResourceCommand.put(NetworkUsageCommand.class, new XcpServerNetworkUsageCommandWrapper()); resources.put(XcpServerResource.class, xcpServerResourceCommand); } diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixResizeVolumeCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixResizeVolumeCommandWrapper.java index 62f90933bd24..25f350f0c2cb 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixResizeVolumeCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixResizeVolumeCommandWrapper.java @@ -26,9 +26,11 @@ import com.cloud.agent.api.storage.ResizeVolumeCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; import com.xensource.xenapi.VDI; +@ResourceWrapper(handles = ResizeVolumeCommand.class) public final class CitrixResizeVolumeCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixResizeVolumeCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRevertToVMSnapshotCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRevertToVMSnapshotCommandWrapper.java index a9291322ad86..def4df73c65d 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRevertToVMSnapshotCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRevertToVMSnapshotCommandWrapper.java @@ -32,6 +32,7 @@ import com.cloud.agent.api.RevertToVMSnapshotCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.vm.VirtualMachine.PowerState; import com.cloud.vm.snapshot.VMSnapshot; import com.xensource.xenapi.Connection; @@ -40,6 +41,7 @@ import com.xensource.xenapi.VDI; import com.xensource.xenapi.VM; +@ResourceWrapper(handles = RevertToVMSnapshotCommand.class) public final class CitrixRevertToVMSnapshotCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixRevertToVMSnapshotCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixScaleVmCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixScaleVmCommandWrapper.java index 47a30f59fa75..d21bcbd5d659 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixScaleVmCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixScaleVmCommandWrapper.java @@ -31,6 +31,7 @@ import com.cloud.agent.api.to.VirtualMachineTO; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.utils.exception.CloudRuntimeException; import com.xensource.xenapi.Connection; import com.xensource.xenapi.Host; @@ -38,6 +39,7 @@ import com.xensource.xenapi.Types.XenAPIException; import com.xensource.xenapi.VM; +@ResourceWrapper(handles = ScaleVmCommand.class) public final class CitrixScaleVmCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixScaleVmCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixSecurityGroupRulesCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixSecurityGroupRulesCommandWrapper.java index 0cf4a8ab29b5..793a5641b175 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixSecurityGroupRulesCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixSecurityGroupRulesCommandWrapper.java @@ -26,8 +26,10 @@ import com.cloud.agent.api.SecurityGroupRulesCmd; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; +@ResourceWrapper(handles = SecurityGroupRulesCmd.class) public final class CitrixSecurityGroupRulesCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixSecurityGroupRulesCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixSetupCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixSetupCommandWrapper.java index 3b24aa388764..3ff0dfe6a90b 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixSetupCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixSetupCommandWrapper.java @@ -30,6 +30,7 @@ import com.cloud.agent.api.SetupCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.utils.Pair; import com.cloud.utils.exception.CloudRuntimeException; import com.xensource.xenapi.Bond; @@ -41,6 +42,7 @@ import com.xensource.xenapi.Types; import com.xensource.xenapi.Types.XenAPIException; +@ResourceWrapper(handles = SetupCommand.class) public final class CitrixSetupCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixSetupCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStartCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStartCommandWrapper.java index ceaaf3498d6d..27f8474ae30e 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStartCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStartCommandWrapper.java @@ -40,6 +40,7 @@ import com.cloud.network.Networks.BroadcastDomainType; import com.cloud.network.Networks.IsolationType; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.vm.VirtualMachine; import com.xensource.xenapi.Connection; import com.xensource.xenapi.Host; @@ -47,6 +48,7 @@ import com.xensource.xenapi.VDI; import com.xensource.xenapi.VM; +@ResourceWrapper(handles = StartCommand.class) public final class CitrixStartCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixStartCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStopCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStopCommandWrapper.java index ce8517f85c86..8310cd8ea569 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStopCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStopCommandWrapper.java @@ -34,6 +34,7 @@ import com.cloud.agent.api.to.GPUDeviceTO; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.utils.StringUtils; import com.xensource.xenapi.Connection; import com.xensource.xenapi.Network; @@ -44,6 +45,7 @@ import com.xensource.xenapi.VIF; import com.xensource.xenapi.VM; +@ResourceWrapper(handles = StopCommand.class) public final class CitrixStopCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixStopCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixUnPlugNicCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixUnPlugNicCommandWrapper.java index 625083504dee..639cfb0334aa 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixUnPlugNicCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixUnPlugNicCommandWrapper.java @@ -29,11 +29,13 @@ import com.cloud.agent.api.to.NicTO; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; import com.xensource.xenapi.Network; import com.xensource.xenapi.VIF; import com.xensource.xenapi.VM; +@ResourceWrapper(handles = UnPlugNicCommand.class) public final class CitrixUnPlugNicCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixUnPlugNicCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixUpdateHostPasswordCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixUpdateHostPasswordCommandWrapper.java index f2f1fb5fce91..c5654fd74cbd 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixUpdateHostPasswordCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixUpdateHostPasswordCommandWrapper.java @@ -23,7 +23,9 @@ import com.cloud.agent.api.UpdateHostPasswordCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = UpdateHostPasswordCommand.class) public final class CitrixUpdateHostPasswordCommandWrapper extends CommandWrapper { @Override diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixUpgradeSnapshotCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixUpgradeSnapshotCommandWrapper.java index a7f3a5008bc5..c23ba1b99368 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixUpgradeSnapshotCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixUpgradeSnapshotCommandWrapper.java @@ -27,8 +27,10 @@ import com.cloud.agent.api.UpgradeSnapshotCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; +@ResourceWrapper(handles = UpgradeSnapshotCommand.class) public final class CitrixUpgradeSnapshotCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(CitrixUpgradeSnapshotCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixWatchConsoleProxyLoadCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixWatchConsoleProxyLoadCommandWrapper.java index f188c20a30dc..74ca0ddf6534 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixWatchConsoleProxyLoadCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixWatchConsoleProxyLoadCommandWrapper.java @@ -23,8 +23,10 @@ import com.cloud.agent.api.Command; import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand; import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; +import com.cloud.resource.ResourceWrapper; import com.cloud.resource.ServerResource; +@ResourceWrapper(handles = WatchConsoleProxyLoadCommand.class) public final class CitrixWatchConsoleProxyLoadCommandWrapper extends CitrixConsoleProxyLoadCommandWrapper { @Override diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XcpServerNetworkUsageCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xcp/XcpServerNetworkUsageCommandWrapper.java similarity index 93% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XcpServerNetworkUsageCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xcp/XcpServerNetworkUsageCommandWrapper.java index d22c60801f2a..e034021be938 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XcpServerNetworkUsageCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xcp/XcpServerNetworkUsageCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.xcp; import org.apache.log4j.Logger; @@ -26,8 +26,10 @@ import com.cloud.agent.api.NetworkUsageCommand; import com.cloud.hypervisor.xenserver.resource.XcpServerResource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; +@ResourceWrapper(handles = NetworkUsageCommand.class) public final class XcpServerNetworkUsageCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(XcpServerNetworkUsageCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer56CheckOnHostCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen56/XenServer56CheckOnHostCommandWrapper.java similarity index 92% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer56CheckOnHostCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen56/XenServer56CheckOnHostCommandWrapper.java index 972936ec8d30..5374e8e641af 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer56CheckOnHostCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen56/XenServer56CheckOnHostCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.xen56; import org.apache.log4j.Logger; @@ -26,7 +26,9 @@ import com.cloud.agent.api.CheckOnHostCommand; import com.cloud.hypervisor.xenserver.resource.XenServer56Resource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = CheckOnHostCommand.class) public final class XenServer56CheckOnHostCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(XenServer56CheckOnHostCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer56FenceCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen56/XenServer56FenceCommandWrapper.java similarity index 95% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer56FenceCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen56/XenServer56FenceCommandWrapper.java index ece3329594d8..f877a868d8fd 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer56FenceCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen56/XenServer56FenceCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.xen56; import java.util.Set; @@ -29,10 +29,12 @@ import com.cloud.agent.api.FenceCommand; import com.cloud.hypervisor.xenserver.resource.XenServer56Resource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; import com.xensource.xenapi.Types.XenAPIException; import com.xensource.xenapi.VM; +@ResourceWrapper(handles = FenceCommand.class) public final class XenServer56FenceCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(XenServer56FenceCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer56NetworkUsageCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen56/XenServer56NetworkUsageCommandWrapper.java similarity index 96% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer56NetworkUsageCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen56/XenServer56NetworkUsageCommandWrapper.java index 9132aa1336b5..ad414a4ea321 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer56NetworkUsageCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen56/XenServer56NetworkUsageCommandWrapper.java @@ -17,19 +17,20 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.xen56; import org.apache.log4j.Logger; -import com.xensource.xenapi.Connection; - import com.cloud.agent.api.Answer; import com.cloud.agent.api.NetworkUsageAnswer; import com.cloud.agent.api.NetworkUsageCommand; import com.cloud.hypervisor.xenserver.resource.XenServer56Resource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.utils.ExecutionResult; +import com.xensource.xenapi.Connection; +@ResourceWrapper(handles = NetworkUsageCommand.class) public final class XenServer56NetworkUsageCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(XenServer56NetworkUsageCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer56FP1FenceCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen56p1/XenServer56FP1FenceCommandWrapper.java similarity index 96% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer56FP1FenceCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen56p1/XenServer56FP1FenceCommandWrapper.java index b169636cb4ab..a03c36bf617b 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer56FP1FenceCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen56p1/XenServer56FP1FenceCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.xen56p1; import java.util.HashSet; import java.util.Map; @@ -31,12 +31,14 @@ import com.cloud.agent.api.FenceCommand; import com.cloud.hypervisor.xenserver.resource.XenServer56Resource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; import com.xensource.xenapi.Types.XenAPIException; import com.xensource.xenapi.VBD; import com.xensource.xenapi.VDI; import com.xensource.xenapi.VM; +@ResourceWrapper(handles = FenceCommand.class) public final class XenServer56FP1FenceCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(XenServer56FP1FenceCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer610MigrateVolumeCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen610/XenServer610MigrateVolumeCommandWrapper.java similarity index 93% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer610MigrateVolumeCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen610/XenServer610MigrateVolumeCommandWrapper.java index 284ec89568d3..72208ead4fa5 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer610MigrateVolumeCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen610/XenServer610MigrateVolumeCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.xen610; import java.util.HashMap; import java.util.Map; @@ -30,12 +30,14 @@ import com.cloud.agent.api.to.StorageFilerTO; import com.cloud.hypervisor.xenserver.resource.XenServer610Resource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; import com.xensource.xenapi.SR; import com.xensource.xenapi.Task; import com.xensource.xenapi.Types; import com.xensource.xenapi.VDI; +@ResourceWrapper(handles = MigrateVolumeCommand.class) public final class XenServer610MigrateVolumeCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(XenServer610MigrateVolumeCommandWrapper.class); @@ -47,7 +49,7 @@ public Answer execute(final MigrateVolumeCommand command, final XenServer610Reso final StorageFilerTO poolTO = command.getPool(); try { - String uuid = poolTO.getUuid(); + final String uuid = poolTO.getUuid(); final SR destinationPool = xenServer610Resource.getStorageRepository(connection, uuid); final VDI srcVolume = xenServer610Resource.getVDIbyUuid(connection, volumeUUID); final Map other = new HashMap(); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer610MigrateWithStorageCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen610/XenServer610MigrateWithStorageCommandWrapper.java similarity index 97% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer610MigrateWithStorageCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen610/XenServer610MigrateWithStorageCommandWrapper.java index 970ed107a0f3..b5c175a9a7c9 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer610MigrateWithStorageCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen610/XenServer610MigrateWithStorageCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.xen610; import java.util.HashMap; import java.util.List; @@ -39,6 +39,7 @@ import com.cloud.hypervisor.xenserver.resource.XsLocalNetwork; import com.cloud.network.Networks.TrafficType; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.utils.exception.CloudRuntimeException; import com.xensource.xenapi.Connection; import com.xensource.xenapi.Host; @@ -50,6 +51,7 @@ import com.xensource.xenapi.VIF; import com.xensource.xenapi.VM; +@ResourceWrapper(handles = MigrateWithStorageCommand.class) public final class XenServer610MigrateWithStorageCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(XenServer610MigrateWithStorageCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer610MigrateWithStorageCompleteCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen610/XenServer610MigrateWithStorageCompleteCommandWrapper.java similarity index 95% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer610MigrateWithStorageCompleteCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen610/XenServer610MigrateWithStorageCompleteCommandWrapper.java index e993b9672c69..a28a3b339ef5 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer610MigrateWithStorageCompleteCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen610/XenServer610MigrateWithStorageCompleteCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.xen610; import java.util.List; import java.util.Set; @@ -32,11 +32,13 @@ import com.cloud.hypervisor.xenserver.resource.XenServer610Resource; import com.cloud.hypervisor.xenserver.resource.XsHost; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.utils.exception.CloudRuntimeException; import com.xensource.xenapi.Connection; import com.xensource.xenapi.Host; import com.xensource.xenapi.VM; +@ResourceWrapper(handles = MigrateWithStorageCompleteCommand.class) public final class XenServer610MigrateWithStorageCompleteCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(XenServer610MigrateWithStorageCompleteCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer610MigrateWithStorageReceiveCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen610/XenServer610MigrateWithStorageReceiveCommandWrapper.java similarity index 96% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer610MigrateWithStorageReceiveCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen610/XenServer610MigrateWithStorageReceiveCommandWrapper.java index 57f5851c46a3..68814ef39c49 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer610MigrateWithStorageReceiveCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen610/XenServer610MigrateWithStorageReceiveCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.xen610; import java.util.HashMap; import java.util.Map; @@ -36,12 +36,14 @@ import com.cloud.hypervisor.xenserver.resource.XsLocalNetwork; import com.cloud.network.Networks.TrafficType; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.utils.exception.CloudRuntimeException; import com.xensource.xenapi.Connection; import com.xensource.xenapi.Host; import com.xensource.xenapi.Network; import com.xensource.xenapi.SR; +@ResourceWrapper(handles = MigrateWithStorageReceiveCommand.class) public final class XenServer610MigrateWithStorageReceiveCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(XenServer610MigrateWithStorageReceiveCommandWrapper.class); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer610MigrateWithStorageSendCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen610/XenServer610MigrateWithStorageSendCommandWrapper.java similarity index 95% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer610MigrateWithStorageSendCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen610/XenServer610MigrateWithStorageSendCommandWrapper.java index 267f528e7dc1..6d4afde3a96d 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer610MigrateWithStorageSendCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen610/XenServer610MigrateWithStorageSendCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.xen610; import java.util.HashMap; import java.util.Map; @@ -33,6 +33,7 @@ import com.cloud.agent.api.to.VolumeTO; import com.cloud.hypervisor.xenserver.resource.XenServer610Resource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.utils.exception.CloudRuntimeException; import com.xensource.xenapi.Connection; import com.xensource.xenapi.Network; @@ -43,6 +44,7 @@ import com.xensource.xenapi.VIF; import com.xensource.xenapi.VM; +@ResourceWrapper(handles = MigrateWithStorageSendCommand.class) public final class XenServer610MigrateWithStorageSendCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(XenServer610MigrateWithStorageSendCommandWrapper.class); @@ -87,10 +89,10 @@ public Answer execute(final MigrateWithStorageSendCommand command, final XenServ // Create the vif map. final Map vifMap = new HashMap(); for (final Map.Entry entry : nicToNetwork.entrySet()) { - Object networkObj = entry.getValue(); + final Object networkObj = entry.getValue(); if (networkObj instanceof Network) { final Network network = (Network) networkObj; - NicTO nic = entry.getKey(); + final NicTO nic = entry.getKey(); final VIF vif = xenServer610Resource.getVifByMac(connection, vmToMigrate, nic.getMac()); vifMap.put(vif, network); } else { diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer620SP1GetGPUStatsCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen620sp1/XenServer620SP1GetGPUStatsCommandWrapper.java similarity index 92% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer620SP1GetGPUStatsCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen620sp1/XenServer620SP1GetGPUStatsCommandWrapper.java index e177256c94bd..c054db8ad7ef 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer620SP1GetGPUStatsCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen620sp1/XenServer620SP1GetGPUStatsCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.xen620sp1; import java.util.HashMap; @@ -29,8 +29,10 @@ import com.cloud.agent.api.VgpuTypesInfo; import com.cloud.hypervisor.xenserver.resource.XenServer620SP1Resource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.xensource.xenapi.Connection; +@ResourceWrapper(handles = GetGPUStatsCommand.class) public final class XenServer620SP1GetGPUStatsCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(XenServer620SP1GetGPUStatsCommandWrapper.class); From 3efdc6c356504a089b76a4653f3f4d4ac21d8d02 Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Thu, 21 May 2015 13:37:27 +0200 Subject: [PATCH 085/175] CLOUDSTACK-8502 Using Annotations on the Libvirt wrappers in order to increase maintainability - All wrappers modified - All 143 unit tests are green --- .../LibvirtAttachIsoCommandWrapper.java | 2 + .../LibvirtAttachVolumeCommandWrapper.java | 2 + .../LibvirtBackupSnapshotCommandWrapper.java | 2 + ...rtCheckConsoleProxyLoadCommandWrapper.java | 2 + .../LibvirtCheckHealthCommandWrapper.java | 2 + .../LibvirtCheckNetworkCommandWrapper.java | 2 + .../LibvirtCheckOnHostCommandWrapper.java | 6 +- .../LibvirtCheckSshCommandWrapper.java | 2 + ...virtCheckVirtualMachineCommandWrapper.java | 2 + ...virtCleanupNetworkRulesCommandWrapper.java | 2 + .../LibvirtCopyVolumeCommandWrapper.java | 2 + .../wrapper/LibvirtCreateCommandWrapper.java | 2 + ...ateTemplateFromSnapshotCommandWrapper.java | 2 + ...ivateTemplateFromVolumeCommandWrapper.java | 2 + ...ibvirtCreateStoragePoolCommandWrapper.java | 2 + ...reateVolumeFromSnapshotCommandWrapper.java | 2 + ...ibvirtDeleteStoragePoolCommandWrapper.java | 6 +- .../wrapper/LibvirtDestroyCommandWrapper.java | 4 +- .../wrapper/LibvirtFenceCommandWrapper.java | 2 + .../LibvirtGetHostStatsCommandWrapper.java | 2 + .../LibvirtGetStorageStatsCommandWrapper.java | 2 + .../LibvirtGetVmDiskStatsCommandWrapper.java | 2 + .../LibvirtGetVmStatsCommandWrapper.java | 2 + .../LibvirtGetVncPortCommandWrapper.java | 2 + .../LibvirtMaintainCommandWrapper.java | 2 + .../LibvirtManageSnapshotCommandWrapper.java | 6 +- .../wrapper/LibvirtMigrateCommandWrapper.java | 2 + .../LibvirtModifySshKeysCommandWrapper.java | 2 + ...ibvirtModifyStoragePoolCommandWrapper.java | 2 + .../LibvirtNetworkElementCommandWrapper.java | 2 + ...irtNetworkRulesSystemVmCommandWrapper.java | 2 + ...tworkRulesVmSecondaryIpCommandWrapper.java | 2 + .../LibvirtNetworkUsageCommandWrapper.java | 2 + .../LibvirtOvsCreateTunnelCommandWrapper.java | 2 + ...LibvirtOvsDestroyBridgeCommandWrapper.java | 2 + ...LibvirtOvsDestroyTunnelCommandWrapper.java | 2 + ...ibvirtOvsFetchInterfaceCommandWrapper.java | 2 + .../LibvirtOvsSetupBridgeCommandWrapper.java | 2 + ...cPhysicalTopologyConfigCommandWrapper.java | 2 + ...sVpcRoutingPolicyConfigCommandWrapper.java | 2 + .../LibvirtPingTestCommandWrapper.java | 2 + .../wrapper/LibvirtPlugNicCommandWrapper.java | 6 +- ...virtPrepareForMigrationCommandWrapper.java | 2 + ...tPrimaryStorageDownloadCommandWrapper.java | 2 + .../LibvirtPvlanSetupCommandWrapper.java | 2 + .../wrapper/LibvirtReadyCommandWrapper.java | 2 + .../wrapper/LibvirtRebootCommandWrapper.java | 2 + .../LibvirtRebootRouterCommandWrapper.java | 2 + .../wrapper/LibvirtRequestWrapper.java | 121 +----------------- .../LibvirtResizeVolumeCommandWrapper.java | 2 + ...bvirtSecurityGroupRulesCommandWrapper.java | 2 + .../wrapper/LibvirtStartCommandWrapper.java | 2 + .../wrapper/LibvirtStopCommandWrapper.java | 2 + ...LibvirtStorageSubSystemCommandWrapper.java | 2 + .../LibvirtUnPlugNicCommandWrapper.java | 2 + .../LibvirtUpgradeSnapshotCommandWrapper.java | 2 + ...rtWatchConsoleProxyLoadCommandWrapper.java | 2 + 57 files changed, 128 insertions(+), 123 deletions(-) diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtAttachIsoCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtAttachIsoCommandWrapper.java index a85ea54ebf7c..3c6da922e464 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtAttachIsoCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtAttachIsoCommandWrapper.java @@ -29,7 +29,9 @@ import com.cloud.exception.InternalErrorException; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = AttachIsoCommand.class) public final class LibvirtAttachIsoCommandWrapper extends CommandWrapper { @Override diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtAttachVolumeCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtAttachVolumeCommandWrapper.java index aa0cd84eb6d6..c78f0ed60789 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtAttachVolumeCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtAttachVolumeCommandWrapper.java @@ -30,7 +30,9 @@ import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk; import com.cloud.hypervisor.kvm.storage.KVMStoragePool; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = AttachVolumeCommand.class) public final class LibvirtAttachVolumeCommandWrapper extends CommandWrapper { @Override diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtBackupSnapshotCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtBackupSnapshotCommandWrapper.java index 438f97c690ba..25da0468dea0 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtBackupSnapshotCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtBackupSnapshotCommandWrapper.java @@ -46,10 +46,12 @@ import com.cloud.hypervisor.kvm.storage.KVMStoragePool; import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.storage.Storage.StoragePoolType; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.script.Script; +@ResourceWrapper(handles = BackupSnapshotCommand.class) public final class LibvirtBackupSnapshotCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtBackupSnapshotCommandWrapper.class); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckConsoleProxyLoadCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckConsoleProxyLoadCommandWrapper.java index 1267984069dc..559db71efbbb 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckConsoleProxyLoadCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckConsoleProxyLoadCommandWrapper.java @@ -23,8 +23,10 @@ import com.cloud.agent.api.Command; import com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.ResourceWrapper; import com.cloud.resource.ServerResource; +@ResourceWrapper(handles = CheckConsoleProxyLoadCommand.class) public class LibvirtCheckConsoleProxyLoadCommandWrapper extends LibvirtConsoleProxyLoadCommandWrapper { @Override diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckHealthCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckHealthCommandWrapper.java index c89d031ccd7d..da523feb5ffc 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckHealthCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckHealthCommandWrapper.java @@ -24,7 +24,9 @@ import com.cloud.agent.api.CheckHealthCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = CheckHealthCommand.class) public final class LibvirtCheckHealthCommandWrapper extends CommandWrapper { @Override diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckNetworkCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckNetworkCommandWrapper.java index 4cf012d6cd6e..0d3df1f274c6 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckNetworkCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckNetworkCommandWrapper.java @@ -27,7 +27,9 @@ import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.network.PhysicalNetworkSetupInfo; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = CheckNetworkCommand.class) public final class LibvirtCheckNetworkCommandWrapper extends CommandWrapper { @Override diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckOnHostCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckOnHostCommandWrapper.java index 5e5602351a3b..bc648f2f446c 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckOnHostCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckOnHostCommandWrapper.java @@ -34,7 +34,9 @@ import com.cloud.hypervisor.kvm.resource.KVMHAMonitor; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = CheckOnHostCommand.class) public final class LibvirtCheckOnHostCommandWrapper extends CommandWrapper { @Override @@ -43,8 +45,8 @@ public Answer execute(final CheckOnHostCommand command, final LibvirtComputingRe final KVMHAMonitor monitor = libvirtComputingResource.getMonitor(); final List pools = monitor.getStoragePools(); - HostTO host = command.getHost(); - NetworkTO privateNetwork = host.getPrivateNetwork(); + final HostTO host = command.getHost(); + final NetworkTO privateNetwork = host.getPrivateNetwork(); final KVMHAChecker ha = new KVMHAChecker(pools, privateNetwork.getIp()); final Future future = executors.submit(ha); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckSshCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckSshCommandWrapper.java index d258d6d41d3a..0b5c56658bc7 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckSshCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckSshCommandWrapper.java @@ -27,7 +27,9 @@ import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = CheckSshCommand.class) public final class LibvirtCheckSshCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtOvsVpcRoutingPolicyConfigCommandWrapper.class); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckVirtualMachineCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckVirtualMachineCommandWrapper.java index 45e2e0be89b7..cf28a562a2e2 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckVirtualMachineCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckVirtualMachineCommandWrapper.java @@ -27,8 +27,10 @@ import com.cloud.agent.api.CheckVirtualMachineCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.vm.VirtualMachine.PowerState; +@ResourceWrapper(handles = CheckVirtualMachineCommand.class) public final class LibvirtCheckVirtualMachineCommandWrapper extends CommandWrapper { @Override diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCleanupNetworkRulesCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCleanupNetworkRulesCommandWrapper.java index 59c353b594ce..0dbae6a20fbc 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCleanupNetworkRulesCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCleanupNetworkRulesCommandWrapper.java @@ -23,7 +23,9 @@ import com.cloud.agent.api.CleanupNetworkRulesCmd; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = CleanupNetworkRulesCmd.class) public final class LibvirtCleanupNetworkRulesCommandWrapper extends CommandWrapper { @Override diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCopyVolumeCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCopyVolumeCommandWrapper.java index 348c421edbd1..e6df5258067a 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCopyVolumeCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCopyVolumeCommandWrapper.java @@ -30,8 +30,10 @@ import com.cloud.hypervisor.kvm.storage.KVMStoragePool; import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.utils.exception.CloudRuntimeException; +@ResourceWrapper(handles = CopyVolumeCommand.class) public final class LibvirtCopyVolumeCommandWrapper extends CommandWrapper { @Override diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreateCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreateCommandWrapper.java index f169e720c529..dfbacaa71765 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreateCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreateCommandWrapper.java @@ -31,10 +31,12 @@ import com.cloud.hypervisor.kvm.storage.KVMStoragePool; import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.storage.Storage.StoragePoolType; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.vm.DiskProfile; +@ResourceWrapper(handles = CreateCommand.class) public final class LibvirtCreateCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtCreateCommandWrapper.class); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreatePrivateTemplateFromSnapshotCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreatePrivateTemplateFromSnapshotCommandWrapper.java index 35c14f86dcd3..440a2529aecb 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreatePrivateTemplateFromSnapshotCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreatePrivateTemplateFromSnapshotCommandWrapper.java @@ -35,6 +35,7 @@ import com.cloud.hypervisor.kvm.storage.KVMStoragePool; import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.storage.StorageLayer; import com.cloud.storage.template.Processor; import com.cloud.storage.template.Processor.FormatInfo; @@ -42,6 +43,7 @@ import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.script.Script; +@ResourceWrapper(handles = CreatePrivateTemplateFromSnapshotCommand.class) public final class LibvirtCreatePrivateTemplateFromSnapshotCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtCreatePrivateTemplateFromSnapshotCommandWrapper.class); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreatePrivateTemplateFromVolumeCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreatePrivateTemplateFromVolumeCommandWrapper.java index f3bfe1ffd19e..00f0e93a8233 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreatePrivateTemplateFromVolumeCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreatePrivateTemplateFromVolumeCommandWrapper.java @@ -45,6 +45,7 @@ import com.cloud.hypervisor.kvm.storage.KVMStoragePool; import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.storage.Storage.ImageFormat; import com.cloud.storage.Storage.StoragePoolType; import com.cloud.storage.StorageLayer; @@ -55,6 +56,7 @@ import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.script.Script; +@ResourceWrapper(handles = CreatePrivateTemplateFromVolumeCommand.class) public final class LibvirtCreatePrivateTemplateFromVolumeCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtCreatePrivateTemplateFromVolumeCommandWrapper.class); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreateStoragePoolCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreateStoragePoolCommandWrapper.java index e233b4fcd918..63767b3f744c 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreateStoragePoolCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreateStoragePoolCommandWrapper.java @@ -23,7 +23,9 @@ import com.cloud.agent.api.CreateStoragePoolCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = CreateStoragePoolCommand.class) public final class LibvirtCreateStoragePoolCommandWrapper extends CommandWrapper { @Override diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreateVolumeFromSnapshotCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreateVolumeFromSnapshotCommandWrapper.java index b30c3f8777da..86fd18129fa8 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreateVolumeFromSnapshotCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreateVolumeFromSnapshotCommandWrapper.java @@ -30,8 +30,10 @@ import com.cloud.hypervisor.kvm.storage.KVMStoragePool; import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.utils.exception.CloudRuntimeException; +@ResourceWrapper(handles = CreateVolumeFromSnapshotCommand.class) public final class LibvirtCreateVolumeFromSnapshotCommandWrapper extends CommandWrapper { @Override diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtDeleteStoragePoolCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtDeleteStoragePoolCommandWrapper.java index 9b0b245f80d6..12ba874cf61a 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtDeleteStoragePoolCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtDeleteStoragePoolCommandWrapper.java @@ -25,15 +25,17 @@ import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.utils.exception.CloudRuntimeException; +@ResourceWrapper(handles = DeleteStoragePoolCommand.class) public final class LibvirtDeleteStoragePoolCommandWrapper extends CommandWrapper { @Override public Answer execute(final DeleteStoragePoolCommand command, final LibvirtComputingResource libvirtComputingResource) { try { - StorageFilerTO pool = command.getPool(); - KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr(); + final StorageFilerTO pool = command.getPool(); + final KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr(); storagePoolMgr.deleteStoragePool(pool.getType(), pool.getUuid()); return new Answer(command); } catch (final CloudRuntimeException e) { diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtDestroyCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtDestroyCommandWrapper.java index d87929516851..359d6588f590 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtDestroyCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtDestroyCommandWrapper.java @@ -28,8 +28,10 @@ import com.cloud.hypervisor.kvm.storage.KVMStoragePool; import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.utils.exception.CloudRuntimeException; +@ResourceWrapper(handles = DestroyCommand.class) public final class LibvirtDestroyCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtDestroyCommandWrapper.class); @@ -38,7 +40,7 @@ public final class LibvirtDestroyCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtFenceCommandWrapper.class); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetHostStatsCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetHostStatsCommandWrapper.java index 45713cb30834..32bec3535b25 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetHostStatsCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetHostStatsCommandWrapper.java @@ -27,10 +27,12 @@ import com.cloud.agent.api.HostStatsEntry; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.utils.Pair; import com.cloud.utils.script.OutputInterpreter; import com.cloud.utils.script.Script; +@ResourceWrapper(handles = GetHostStatsCommand.class) public final class LibvirtGetHostStatsCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtGetHostStatsCommandWrapper.class); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetStorageStatsCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetStorageStatsCommandWrapper.java index 98deae2c382d..294af5376a4b 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetStorageStatsCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetStorageStatsCommandWrapper.java @@ -26,8 +26,10 @@ import com.cloud.hypervisor.kvm.storage.KVMStoragePool; import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.utils.exception.CloudRuntimeException; +@ResourceWrapper(handles = GetStorageStatsCommand.class) public final class LibvirtGetStorageStatsCommandWrapper extends CommandWrapper { @Override diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmDiskStatsCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmDiskStatsCommandWrapper.java index 4a8ee49b88d7..52449e93f6d0 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmDiskStatsCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmDiskStatsCommandWrapper.java @@ -32,7 +32,9 @@ import com.cloud.agent.api.VmDiskStatsEntry; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = GetVmDiskStatsCommand.class) public final class LibvirtGetVmDiskStatsCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtGetVmDiskStatsCommandWrapper.class); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmStatsCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmStatsCommandWrapper.java index 2e6f0a78d1fd..6a71d2f63830 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmStatsCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmStatsCommandWrapper.java @@ -32,7 +32,9 @@ import com.cloud.agent.api.VmStatsEntry; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = GetVmStatsCommand.class) public final class LibvirtGetVmStatsCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtGetVmStatsCommandWrapper.class); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVncPortCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVncPortCommandWrapper.java index abd9bf9ad0e3..1e9ecc6f7523 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVncPortCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVncPortCommandWrapper.java @@ -27,7 +27,9 @@ import com.cloud.agent.api.GetVncPortCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = GetVncPortCommand.class) public final class LibvirtGetVncPortCommandWrapper extends CommandWrapper { @Override diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMaintainCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMaintainCommandWrapper.java index c1aba38ffe46..1d306a5b3b1c 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMaintainCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMaintainCommandWrapper.java @@ -24,7 +24,9 @@ import com.cloud.agent.api.MaintainCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = MaintainCommand.class) public final class LibvirtMaintainCommandWrapper extends CommandWrapper { @Override diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtManageSnapshotCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtManageSnapshotCommandWrapper.java index 225634005c51..1775f24c2b6e 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtManageSnapshotCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtManageSnapshotCommandWrapper.java @@ -42,9 +42,11 @@ import com.cloud.hypervisor.kvm.storage.KVMStoragePool; import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.storage.Storage.StoragePoolType; import com.cloud.utils.script.Script; +@ResourceWrapper(handles = ManageSnapshotCommand.class) public final class LibvirtManageSnapshotCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtManageSnapshotCommandWrapper.class); @@ -68,8 +70,8 @@ public Answer execute(final ManageSnapshotCommand command, final LibvirtComputin } } - KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr(); - StorageFilerTO pool = command.getPool(); + final KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr(); + final StorageFilerTO pool = command.getPool(); final KVMStoragePool primaryPool = storagePoolMgr.getStoragePool(pool.getType(), pool.getUuid()); final KVMPhysicalDisk disk = primaryPool.getPhysicalDisk(command.getVolumePath()); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java index 4b30cd929132..235793cc6e92 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java @@ -43,7 +43,9 @@ import com.cloud.hypervisor.kvm.resource.MigrateKVMAsync; import com.cloud.hypervisor.kvm.resource.VifDriver; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = MigrateCommand.class) public final class LibvirtMigrateCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtMigrateCommandWrapper.class); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtModifySshKeysCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtModifySshKeysCommandWrapper.java index 1295e7d3e542..28d647fe0d61 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtModifySshKeysCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtModifySshKeysCommandWrapper.java @@ -30,8 +30,10 @@ import com.cloud.agent.api.ModifySshKeysCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.utils.script.Script; +@ResourceWrapper(handles = ModifySshKeysCommand.class) public final class LibvirtModifySshKeysCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtModifySshKeysCommandWrapper.class); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtModifyStoragePoolCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtModifyStoragePoolCommandWrapper.java index 34d12bad4ddb..0d6cdaccb905 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtModifyStoragePoolCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtModifyStoragePoolCommandWrapper.java @@ -29,8 +29,10 @@ import com.cloud.hypervisor.kvm.storage.KVMStoragePool; import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.storage.template.TemplateProp; +@ResourceWrapper(handles = ModifyStoragePoolCommand.class) public final class LibvirtModifyStoragePoolCommandWrapper extends CommandWrapper { @Override diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkElementCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkElementCommandWrapper.java index 3046b09ffc74..95fbd41f7802 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkElementCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkElementCommandWrapper.java @@ -24,7 +24,9 @@ import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = NetworkElementCommand.class) public final class LibvirtNetworkElementCommandWrapper extends CommandWrapper { @Override diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkRulesSystemVmCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkRulesSystemVmCommandWrapper.java index 0a8743227a5a..1c5a9adeaf84 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkRulesSystemVmCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkRulesSystemVmCommandWrapper.java @@ -27,7 +27,9 @@ import com.cloud.agent.api.NetworkRulesSystemVmCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = NetworkRulesSystemVmCommand.class) public final class LibvirtNetworkRulesSystemVmCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtOvsVpcRoutingPolicyConfigCommandWrapper.class); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkRulesVmSecondaryIpCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkRulesVmSecondaryIpCommandWrapper.java index f955b891c50b..1ad5cb459cfb 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkRulesVmSecondaryIpCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkRulesVmSecondaryIpCommandWrapper.java @@ -27,7 +27,9 @@ import com.cloud.agent.api.NetworkRulesVmSecondaryIpCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = NetworkRulesVmSecondaryIpCommand.class) public final class LibvirtNetworkRulesVmSecondaryIpCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtOvsVpcRoutingPolicyConfigCommandWrapper.class); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkUsageCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkUsageCommandWrapper.java index 3ac21825beef..eaa90f0e0506 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkUsageCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkUsageCommandWrapper.java @@ -24,7 +24,9 @@ import com.cloud.agent.api.NetworkUsageCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = NetworkUsageCommand.class) public final class LibvirtNetworkUsageCommandWrapper extends CommandWrapper { @Override diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsCreateTunnelCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsCreateTunnelCommandWrapper.java index 3a620577d12c..b840e8b472c3 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsCreateTunnelCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsCreateTunnelCommandWrapper.java @@ -26,8 +26,10 @@ import com.cloud.agent.api.OvsCreateTunnelCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.utils.script.Script; +@ResourceWrapper(handles = OvsCreateTunnelCommand.class) public final class LibvirtOvsCreateTunnelCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtOvsCreateTunnelCommandWrapper.class); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsDestroyBridgeCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsDestroyBridgeCommandWrapper.java index ab2b9c40c40a..9248b3179d72 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsDestroyBridgeCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsDestroyBridgeCommandWrapper.java @@ -25,7 +25,9 @@ import com.cloud.agent.api.OvsDestroyBridgeCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = OvsDestroyBridgeCommand.class) public final class LibvirtOvsDestroyBridgeCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtOvsDestroyBridgeCommandWrapper.class); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsDestroyTunnelCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsDestroyTunnelCommandWrapper.java index ca694f817974..d2e100a5c57f 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsDestroyTunnelCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsDestroyTunnelCommandWrapper.java @@ -25,8 +25,10 @@ import com.cloud.agent.api.OvsDestroyTunnelCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.utils.script.Script; +@ResourceWrapper(handles = OvsDestroyTunnelCommand.class) public final class LibvirtOvsDestroyTunnelCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtOvsDestroyTunnelCommandWrapper.class); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsFetchInterfaceCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsFetchInterfaceCommandWrapper.java index e7d0b7e9536b..3da77d5f6c4e 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsFetchInterfaceCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsFetchInterfaceCommandWrapper.java @@ -26,8 +26,10 @@ import com.cloud.agent.api.OvsFetchInterfaceCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.utils.script.Script; +@ResourceWrapper(handles = OvsFetchInterfaceCommand.class) public final class LibvirtOvsFetchInterfaceCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtOvsFetchInterfaceCommandWrapper.class); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsSetupBridgeCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsSetupBridgeCommandWrapper.java index 4c979a7be437..7d73ff29ffa1 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsSetupBridgeCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsSetupBridgeCommandWrapper.java @@ -25,7 +25,9 @@ import com.cloud.agent.api.OvsSetupBridgeCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = OvsSetupBridgeCommand.class) public final class LibvirtOvsSetupBridgeCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtOvsSetupBridgeCommandWrapper.class); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsVpcPhysicalTopologyConfigCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsVpcPhysicalTopologyConfigCommandWrapper.java index d1e86516d0ec..2d69ba95ad08 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsVpcPhysicalTopologyConfigCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsVpcPhysicalTopologyConfigCommandWrapper.java @@ -25,8 +25,10 @@ import com.cloud.agent.api.OvsVpcPhysicalTopologyConfigCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.utils.script.Script; +@ResourceWrapper(handles = OvsVpcPhysicalTopologyConfigCommand.class) public final class LibvirtOvsVpcPhysicalTopologyConfigCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtOvsVpcPhysicalTopologyConfigCommandWrapper.class); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsVpcRoutingPolicyConfigCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsVpcRoutingPolicyConfigCommandWrapper.java index 36762ed0a4a9..06f18475c4ea 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsVpcRoutingPolicyConfigCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsVpcRoutingPolicyConfigCommandWrapper.java @@ -25,8 +25,10 @@ import com.cloud.agent.api.OvsVpcRoutingPolicyConfigCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.utils.script.Script; +@ResourceWrapper(handles = OvsVpcRoutingPolicyConfigCommand.class) public final class LibvirtOvsVpcRoutingPolicyConfigCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtOvsVpcRoutingPolicyConfigCommandWrapper.class); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPingTestCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPingTestCommandWrapper.java index 3ef9e2c73ce7..b90c9203c994 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPingTestCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPingTestCommandWrapper.java @@ -25,8 +25,10 @@ import com.cloud.agent.api.PingTestCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.utils.script.Script; +@ResourceWrapper(handles = PingTestCommand.class) public final class LibvirtPingTestCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtPingTestCommandWrapper.class); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPlugNicCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPlugNicCommandWrapper.java index 6b6d54fbc4a7..018d6a784c34 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPlugNicCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPlugNicCommandWrapper.java @@ -35,7 +35,9 @@ import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef; import com.cloud.hypervisor.kvm.resource.VifDriver; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = PlugNicCommand.class) public final class LibvirtPlugNicCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtPlugNicCommandWrapper.class); @@ -59,8 +61,8 @@ public Answer execute(final PlugNicCommand command, final LibvirtComputingResour } nicnum++; } - VifDriver vifDriver = libvirtComputingResource.getVifDriver(nic.getType()); - InterfaceDef interfaceDef = vifDriver.plug(nic, "Other PV", ""); + final VifDriver vifDriver = libvirtComputingResource.getVifDriver(nic.getType()); + final InterfaceDef interfaceDef = vifDriver.plug(nic, "Other PV", ""); vm.attachDevice(interfaceDef.toString()); return new PlugNicAnswer(command, true, "success"); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPrepareForMigrationCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPrepareForMigrationCommandWrapper.java index 66aabaccbde8..2dfca5d6fc41 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPrepareForMigrationCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPrepareForMigrationCommandWrapper.java @@ -35,8 +35,10 @@ import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.storage.Volume; +@ResourceWrapper(handles = PrepareForMigrationCommand.class) public final class LibvirtPrepareForMigrationCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtPrepareForMigrationCommandWrapper.class); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPrimaryStorageDownloadCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPrimaryStorageDownloadCommandWrapper.java index 391ab2787bab..daaf7e7de323 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPrimaryStorageDownloadCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPrimaryStorageDownloadCommandWrapper.java @@ -30,8 +30,10 @@ import com.cloud.hypervisor.kvm.storage.KVMStoragePool; import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.utils.exception.CloudRuntimeException; +@ResourceWrapper(handles = PrimaryStorageDownloadCommand.class) public final class LibvirtPrimaryStorageDownloadCommandWrapper extends CommandWrapper { @Override diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPvlanSetupCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPvlanSetupCommandWrapper.java index 7233723ae1a5..435b98a18ab0 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPvlanSetupCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPvlanSetupCommandWrapper.java @@ -30,8 +30,10 @@ import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.utils.script.Script; +@ResourceWrapper(handles = PvlanSetupCommand.class) public final class LibvirtPvlanSetupCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtPvlanSetupCommandWrapper.class); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtReadyCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtReadyCommandWrapper.java index 7fce9096595d..c48f91f3eb3f 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtReadyCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtReadyCommandWrapper.java @@ -24,7 +24,9 @@ import com.cloud.agent.api.ReadyCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = ReadyCommand.class) public final class LibvirtReadyCommandWrapper extends CommandWrapper { @Override diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRebootCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRebootCommandWrapper.java index 518c36719066..f54ed6f6cc8a 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRebootCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRebootCommandWrapper.java @@ -28,7 +28,9 @@ import com.cloud.agent.api.RebootCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = RebootCommand.class) public final class LibvirtRebootCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtRebootCommandWrapper.class); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRebootRouterCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRebootRouterCommandWrapper.java index 671b8c800c41..4d13c1bf5c94 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRebootRouterCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRebootRouterCommandWrapper.java @@ -25,7 +25,9 @@ import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = RebootRouterCommand.class) public final class LibvirtRebootRouterCommandWrapper extends CommandWrapper { @Override diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java index 9f157ebab7f7..0b413bc6e9ff 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java @@ -19,66 +19,12 @@ package com.cloud.hypervisor.kvm.resource.wrapper; import java.util.Hashtable; +import java.util.Set; -import org.apache.cloudstack.storage.command.StorageSubSystemCommand; +import org.reflections.Reflections; import com.cloud.agent.api.Answer; -import com.cloud.agent.api.AttachIsoCommand; -import com.cloud.agent.api.AttachVolumeCommand; -import com.cloud.agent.api.BackupSnapshotCommand; -import com.cloud.agent.api.CheckHealthCommand; -import com.cloud.agent.api.CheckNetworkCommand; -import com.cloud.agent.api.CheckOnHostCommand; -import com.cloud.agent.api.CheckVirtualMachineCommand; -import com.cloud.agent.api.CleanupNetworkRulesCmd; import com.cloud.agent.api.Command; -import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand; -import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand; -import com.cloud.agent.api.CreateStoragePoolCommand; -import com.cloud.agent.api.CreateVolumeFromSnapshotCommand; -import com.cloud.agent.api.DeleteStoragePoolCommand; -import com.cloud.agent.api.FenceCommand; -import com.cloud.agent.api.GetHostStatsCommand; -import com.cloud.agent.api.GetStorageStatsCommand; -import com.cloud.agent.api.GetVmDiskStatsCommand; -import com.cloud.agent.api.GetVmStatsCommand; -import com.cloud.agent.api.GetVncPortCommand; -import com.cloud.agent.api.MaintainCommand; -import com.cloud.agent.api.ManageSnapshotCommand; -import com.cloud.agent.api.MigrateCommand; -import com.cloud.agent.api.ModifySshKeysCommand; -import com.cloud.agent.api.ModifyStoragePoolCommand; -import com.cloud.agent.api.NetworkRulesSystemVmCommand; -import com.cloud.agent.api.NetworkRulesVmSecondaryIpCommand; -import com.cloud.agent.api.NetworkUsageCommand; -import com.cloud.agent.api.OvsCreateTunnelCommand; -import com.cloud.agent.api.OvsDestroyBridgeCommand; -import com.cloud.agent.api.OvsDestroyTunnelCommand; -import com.cloud.agent.api.OvsFetchInterfaceCommand; -import com.cloud.agent.api.OvsSetupBridgeCommand; -import com.cloud.agent.api.OvsVpcPhysicalTopologyConfigCommand; -import com.cloud.agent.api.OvsVpcRoutingPolicyConfigCommand; -import com.cloud.agent.api.PingTestCommand; -import com.cloud.agent.api.PlugNicCommand; -import com.cloud.agent.api.PrepareForMigrationCommand; -import com.cloud.agent.api.PvlanSetupCommand; -import com.cloud.agent.api.ReadyCommand; -import com.cloud.agent.api.RebootCommand; -import com.cloud.agent.api.RebootRouterCommand; -import com.cloud.agent.api.SecurityGroupRulesCmd; -import com.cloud.agent.api.StartCommand; -import com.cloud.agent.api.StopCommand; -import com.cloud.agent.api.UnPlugNicCommand; -import com.cloud.agent.api.UpgradeSnapshotCommand; -import com.cloud.agent.api.check.CheckSshCommand; -import com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand; -import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand; -import com.cloud.agent.api.routing.NetworkElementCommand; -import com.cloud.agent.api.storage.CopyVolumeCommand; -import com.cloud.agent.api.storage.CreateCommand; -import com.cloud.agent.api.storage.DestroyCommand; -import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand; -import com.cloud.agent.api.storage.ResizeVolumeCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; import com.cloud.resource.RequestWrapper; @@ -92,6 +38,10 @@ public class LibvirtRequestWrapper extends RequestWrapper { instance = new LibvirtRequestWrapper(); } + Reflections baseWrappers = new Reflections("com.cloud.hypervisor.kvm.resource.wrapper"); + @SuppressWarnings("rawtypes") + Set> baseSet = baseWrappers.getSubTypesOf(CommandWrapper.class); + private LibvirtRequestWrapper() { init(); } @@ -99,64 +49,7 @@ private LibvirtRequestWrapper() { @SuppressWarnings("rawtypes") private void init() { // LibvirtComputingResource commands - final Hashtable, CommandWrapper> libvirtCommands = new Hashtable, CommandWrapper>(); - - libvirtCommands.put(StopCommand.class, new LibvirtStopCommandWrapper()); - libvirtCommands.put(GetVmStatsCommand.class, new LibvirtGetVmStatsCommandWrapper()); - libvirtCommands.put(GetVmDiskStatsCommand.class, new LibvirtGetVmDiskStatsCommandWrapper()); - libvirtCommands.put(RebootRouterCommand.class, new LibvirtRebootRouterCommandWrapper()); - libvirtCommands.put(RebootCommand.class, new LibvirtRebootCommandWrapper()); - libvirtCommands.put(GetHostStatsCommand.class, new LibvirtGetHostStatsCommandWrapper()); - libvirtCommands.put(CheckHealthCommand.class, new LibvirtCheckHealthCommandWrapper()); - libvirtCommands.put(PrepareForMigrationCommand.class, new LibvirtPrepareForMigrationCommandWrapper()); - libvirtCommands.put(MigrateCommand.class, new LibvirtMigrateCommandWrapper()); - libvirtCommands.put(PingTestCommand.class, new LibvirtPingTestCommandWrapper()); - libvirtCommands.put(CheckVirtualMachineCommand.class, new LibvirtCheckVirtualMachineCommandWrapper()); - libvirtCommands.put(ReadyCommand.class, new LibvirtReadyCommandWrapper()); - libvirtCommands.put(AttachIsoCommand.class, new LibvirtAttachIsoCommandWrapper()); - libvirtCommands.put(AttachVolumeCommand.class, new LibvirtAttachVolumeCommandWrapper()); - libvirtCommands.put(WatchConsoleProxyLoadCommand.class, new LibvirtWatchConsoleProxyLoadCommandWrapper()); - libvirtCommands.put(CheckConsoleProxyLoadCommand.class, new LibvirtCheckConsoleProxyLoadCommandWrapper()); - libvirtCommands.put(GetVncPortCommand.class, new LibvirtGetVncPortCommandWrapper()); - libvirtCommands.put(ModifySshKeysCommand.class, new LibvirtModifySshKeysCommandWrapper()); - libvirtCommands.put(MaintainCommand.class, new LibvirtMaintainCommandWrapper()); - libvirtCommands.put(CreateCommand.class, new LibvirtCreateCommandWrapper()); - libvirtCommands.put(DestroyCommand.class, new LibvirtDestroyCommandWrapper()); - libvirtCommands.put(PrimaryStorageDownloadCommand.class, new LibvirtPrimaryStorageDownloadCommandWrapper()); - libvirtCommands.put(GetStorageStatsCommand.class, new LibvirtGetStorageStatsCommandWrapper()); - libvirtCommands.put(UpgradeSnapshotCommand.class, new LibvirtUpgradeSnapshotCommandWrapper()); - libvirtCommands.put(DeleteStoragePoolCommand.class, new LibvirtDeleteStoragePoolCommandWrapper()); - libvirtCommands.put(OvsSetupBridgeCommand.class, new LibvirtOvsSetupBridgeCommandWrapper()); - libvirtCommands.put(OvsDestroyBridgeCommand.class, new LibvirtOvsDestroyBridgeCommandWrapper()); - libvirtCommands.put(OvsFetchInterfaceCommand.class, new LibvirtOvsFetchInterfaceCommandWrapper()); - libvirtCommands.put(OvsVpcPhysicalTopologyConfigCommand.class, new LibvirtOvsVpcPhysicalTopologyConfigCommandWrapper()); - libvirtCommands.put(OvsVpcRoutingPolicyConfigCommand.class, new LibvirtOvsVpcRoutingPolicyConfigCommandWrapper()); - libvirtCommands.put(CreateStoragePoolCommand.class, new LibvirtCreateStoragePoolCommandWrapper()); - libvirtCommands.put(ModifyStoragePoolCommand.class, new LibvirtModifyStoragePoolCommandWrapper()); - libvirtCommands.put(CleanupNetworkRulesCmd.class, new LibvirtCleanupNetworkRulesCommandWrapper()); - libvirtCommands.put(NetworkRulesVmSecondaryIpCommand.class, new LibvirtNetworkRulesVmSecondaryIpCommandWrapper()); - libvirtCommands.put(NetworkRulesSystemVmCommand.class, new LibvirtNetworkRulesSystemVmCommandWrapper()); - libvirtCommands.put(CheckSshCommand.class, new LibvirtCheckSshCommandWrapper()); - libvirtCommands.put(CheckNetworkCommand.class, new LibvirtCheckNetworkCommandWrapper()); - libvirtCommands.put(OvsDestroyTunnelCommand.class, new LibvirtOvsDestroyTunnelCommandWrapper()); - libvirtCommands.put(CheckOnHostCommand.class, new LibvirtCheckOnHostCommandWrapper()); - libvirtCommands.put(OvsCreateTunnelCommand.class, new LibvirtOvsCreateTunnelCommandWrapper()); - libvirtCommands.put(CreateVolumeFromSnapshotCommand.class, new LibvirtCreateVolumeFromSnapshotCommandWrapper()); - libvirtCommands.put(FenceCommand.class, new LibvirtFenceCommandWrapper()); - libvirtCommands.put(SecurityGroupRulesCmd.class, new LibvirtSecurityGroupRulesCommandWrapper()); - libvirtCommands.put(PlugNicCommand.class, new LibvirtPlugNicCommandWrapper()); - libvirtCommands.put(UnPlugNicCommand.class, new LibvirtUnPlugNicCommandWrapper()); - libvirtCommands.put(NetworkUsageCommand.class, new LibvirtNetworkUsageCommandWrapper()); - libvirtCommands.put(CreatePrivateTemplateFromVolumeCommand.class, new LibvirtCreatePrivateTemplateFromVolumeCommandWrapper()); - libvirtCommands.put(ManageSnapshotCommand.class, new LibvirtManageSnapshotCommandWrapper()); - libvirtCommands.put(BackupSnapshotCommand.class, new LibvirtBackupSnapshotCommandWrapper()); - libvirtCommands.put(CreatePrivateTemplateFromSnapshotCommand.class, new LibvirtCreatePrivateTemplateFromSnapshotCommandWrapper()); - libvirtCommands.put(CopyVolumeCommand.class, new LibvirtCopyVolumeCommandWrapper()); - libvirtCommands.put(PvlanSetupCommand.class, new LibvirtPvlanSetupCommandWrapper()); - libvirtCommands.put(ResizeVolumeCommand.class, new LibvirtResizeVolumeCommandWrapper()); - libvirtCommands.put(NetworkElementCommand.class, new LibvirtNetworkElementCommandWrapper()); - libvirtCommands.put(StorageSubSystemCommand.class, new LibvirtStorageSubSystemCommandWrapper()); - libvirtCommands.put(StartCommand.class, new LibvirtStartCommandWrapper()); + final Hashtable, CommandWrapper> libvirtCommands = processAnnotations(baseSet); resources.put(LibvirtComputingResource.class, libvirtCommands); } diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtResizeVolumeCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtResizeVolumeCommandWrapper.java index bbcba4756e56..167c72aac18c 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtResizeVolumeCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtResizeVolumeCommandWrapper.java @@ -34,6 +34,7 @@ import com.cloud.hypervisor.kvm.storage.KVMStoragePool; import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.storage.Storage.StoragePoolType; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.script.Script; @@ -41,6 +42,7 @@ /* * Uses a local script now, eventually support for virStorageVolResize() will maybe work on qcow2 and lvm and we can do this in libvirt calls */ +@ResourceWrapper(handles = ResizeVolumeCommand.class) public final class LibvirtResizeVolumeCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtResizeVolumeCommandWrapper.class); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtSecurityGroupRulesCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtSecurityGroupRulesCommandWrapper.java index ef4318290203..f1a2e02dea75 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtSecurityGroupRulesCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtSecurityGroupRulesCommandWrapper.java @@ -31,7 +31,9 @@ import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = SecurityGroupRulesCmd.class) public final class LibvirtSecurityGroupRulesCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtSecurityGroupRulesCommandWrapper.class); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStartCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStartCommandWrapper.java index 649e11cb8f74..d9606194b1d7 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStartCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStartCommandWrapper.java @@ -40,8 +40,10 @@ import com.cloud.network.Networks.IsolationType; import com.cloud.network.Networks.TrafficType; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.vm.VirtualMachine; +@ResourceWrapper(handles = StartCommand.class) public final class LibvirtStartCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtStartCommandWrapper.class); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStopCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStopCommandWrapper.java index 59a44fc01ea7..f7e088bfd23a 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStopCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStopCommandWrapper.java @@ -35,7 +35,9 @@ import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef; import com.cloud.hypervisor.kvm.resource.VifDriver; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = StopCommand.class) public final class LibvirtStopCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtStopCommandWrapper.class); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStorageSubSystemCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStorageSubSystemCommandWrapper.java index d2044ed693de..9424c03280fe 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStorageSubSystemCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStorageSubSystemCommandWrapper.java @@ -24,8 +24,10 @@ import com.cloud.agent.api.Answer; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; import com.cloud.storage.resource.StorageSubsystemCommandHandler; +@ResourceWrapper(handles = StorageSubSystemCommand.class) public final class LibvirtStorageSubSystemCommandWrapper extends CommandWrapper { @Override diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUnPlugNicCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUnPlugNicCommandWrapper.java index 55707930f977..57f4083c96ff 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUnPlugNicCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUnPlugNicCommandWrapper.java @@ -34,7 +34,9 @@ import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef; import com.cloud.hypervisor.kvm.resource.VifDriver; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = UnPlugNicCommand.class) public final class LibvirtUnPlugNicCommandWrapper extends CommandWrapper { private static final Logger s_logger = Logger.getLogger(LibvirtUnPlugNicCommandWrapper.class); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUpgradeSnapshotCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUpgradeSnapshotCommandWrapper.java index 0f0fb9a73dc2..2096d87a3b16 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUpgradeSnapshotCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUpgradeSnapshotCommandWrapper.java @@ -23,7 +23,9 @@ import com.cloud.agent.api.UpgradeSnapshotCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +@ResourceWrapper(handles = UpgradeSnapshotCommand.class) public final class LibvirtUpgradeSnapshotCommandWrapper extends CommandWrapper { @Override diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtWatchConsoleProxyLoadCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtWatchConsoleProxyLoadCommandWrapper.java index 62fff110714b..1468c1fb3d17 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtWatchConsoleProxyLoadCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtWatchConsoleProxyLoadCommandWrapper.java @@ -23,8 +23,10 @@ import com.cloud.agent.api.Command; import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand; import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.resource.ResourceWrapper; import com.cloud.resource.ServerResource; +@ResourceWrapper(handles = WatchConsoleProxyLoadCommand.class) public class LibvirtWatchConsoleProxyLoadCommandWrapper extends LibvirtConsoleProxyLoadCommandWrapper { @Override From add42777203999e99c310005e02d8dd31fff2f95 Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Thu, 21 May 2015 13:59:49 +0200 Subject: [PATCH 086/175] CLOUDSTACK-8502 Added CitrixStorageSubSystemCommandWrapper to complete the CitrixResourceBase refactor. - All 101 unit tests are green --- .../com/cloud/resource/RequestWrapper.java | 4 ++ .../resource/CitrixResourceBase.java | 14 +++---- .../CitrixStorageSubSystemCommandWrapper.java | 38 +++++++++++++++++++ .../wrapper/CitrixRequestWrapperTest.java | 22 +++++++++++ 4 files changed, 69 insertions(+), 9 deletions(-) create mode 100644 plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStorageSubSystemCommandWrapper.java diff --git a/core/src/com/cloud/resource/RequestWrapper.java b/core/src/com/cloud/resource/RequestWrapper.java index 31388d64dec3..4e754d60a299 100644 --- a/core/src/com/cloud/resource/RequestWrapper.java +++ b/core/src/com/cloud/resource/RequestWrapper.java @@ -75,6 +75,8 @@ protected CommandWrapper retrieveCommands(final commandWrapper = resourceCommands.get(commandClass2); keepCommandClass = commandClass2; + } catch (final ClassCastException e) { + throw new NullPointerException("No key found for '" + keepCommandClass.getClass() + "' in the Map!"); } catch (final NullPointerException e) { // Will now traverse all the resource hierarchy. Returning null // is not a problem. @@ -108,6 +110,8 @@ protected CommandWrapper retryWhenAllFails(fina keepResourceClass = resourceClass2; commandWrapper = retrieveCommands(command.getClass(), resourceCommands2); + } catch (final ClassCastException e) { + throw new NullPointerException("No key found for '" + command.getClass() + "' in the Map!"); } catch (final NullPointerException e) { throw e; } diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java index 2b3035c7570a..6aaaf0e737ba 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java @@ -46,7 +46,6 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; -import org.apache.cloudstack.storage.command.StorageSubSystemCommand; import org.apache.cloudstack.storage.to.TemplateObjectTO; import org.apache.cloudstack.storage.to.VolumeObjectTO; import org.apache.log4j.Logger; @@ -717,7 +716,7 @@ public HashMap clusterVMMetaDataSync(final Connection conn) { if (record.isControlDomain || record.isASnapshot || record.isATemplate) { continue; // Skip DOM0 } - String platform = StringUtils.mapToString(record.platform); + final String platform = StringUtils.mapToString(record.platform); if (platform.isEmpty()) { continue; //Skip if platform is null } @@ -1642,13 +1641,6 @@ public ExecutionResult executeInVR(final String routerIP, final String script, f @Override public Answer executeRequest(final Command cmd) { - - // We need this one because the StorageSubSystemCommand is from another - // hierarchy. - if (cmd instanceof StorageSubSystemCommand) { - return storageHandler.handleStorageCommands((StorageSubSystemCommand) cmd); - } - final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance(); try { return wrapper.execute(cmd, this); @@ -2012,6 +2004,10 @@ public int getMigrateWait() { return _migratewait; } + public StorageSubsystemCommandHandler getStorageHandler() { + return storageHandler; + } + protected boolean getHostInfo(final Connection conn) throws IllegalArgumentException { try { final Host myself = Host.getByUuid(conn, _host.getUuid()); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStorageSubSystemCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStorageSubSystemCommandWrapper.java new file mode 100644 index 000000000000..c14818ed6209 --- /dev/null +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStorageSubSystemCommandWrapper.java @@ -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 +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.hypervisor.xenserver.resource.wrapper; + +import org.apache.cloudstack.storage.command.StorageSubSystemCommand; + +import com.cloud.agent.api.Answer; +import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase; +import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +import com.cloud.storage.resource.StorageSubsystemCommandHandler; + +@ResourceWrapper(handles = StorageSubSystemCommand.class) +public final class CitrixStorageSubSystemCommandWrapper extends CommandWrapper { + + @Override + public Answer execute(final StorageSubSystemCommand command, final CitrixResourceBase citrixResourceBase) { + final StorageSubsystemCommandHandler handler = citrixResourceBase.getStorageHandler(); + return handler.handleStorageCommands(command); + } +} \ No newline at end of file diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapperTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapperTest.java index 6a1be8c27b6c..8d66c6597a46 100644 --- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapperTest.java +++ b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapperTest.java @@ -33,6 +33,8 @@ import java.util.List; import java.util.Map; +import org.apache.cloudstack.storage.command.AttachAnswer; +import org.apache.cloudstack.storage.command.AttachCommand; import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; import org.apache.cloudstack.storage.to.VolumeObjectTO; import org.apache.xmlrpc.XmlRpcException; @@ -109,6 +111,7 @@ import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand; import com.cloud.agent.api.storage.ResizeVolumeCommand; import com.cloud.agent.api.to.DataStoreTO; +import com.cloud.agent.api.to.DiskTO; import com.cloud.agent.api.to.IpAddressTO; import com.cloud.agent.api.to.NicTO; import com.cloud.agent.api.to.StorageFilerTO; @@ -123,6 +126,7 @@ import com.cloud.storage.Storage.ImageFormat; import com.cloud.storage.Storage.StoragePoolType; import com.cloud.storage.VMTemplateStorageResourceAssoc; +import com.cloud.storage.resource.StorageSubsystemCommandHandler; import com.cloud.vm.DiskProfile; import com.cloud.vm.VirtualMachine; import com.xensource.xenapi.Connection; @@ -1807,6 +1811,24 @@ public void testIpAssocCommand() { // Requires more testing, but the VirtualResourceRouting is quite big. assertNull(answer); } + + @Test + public void testStorageSubSystemCommand() { + final DiskTO disk = Mockito.mock(DiskTO.class); + final String vmName = "Test"; + final AttachCommand command = new AttachCommand(disk, vmName); + + final StorageSubsystemCommandHandler handler = Mockito.mock(StorageSubsystemCommandHandler.class); + when(citrixResourceBase.getStorageHandler()).thenReturn(handler); + + when(handler.handleStorageCommands(command)).thenReturn(new AttachAnswer(disk)); + + final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance(); + assertNotNull(wrapper); + + final Answer answer = wrapper.execute(command, citrixResourceBase); + assertTrue(answer.getResult()); + } } class NotAValidCommand extends Command { From 3824d997d6b2741e31be187680155be46f682203 Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Wed, 20 May 2015 20:58:15 +0200 Subject: [PATCH 087/175] queryService: fix style, remove public statement on interfaces Signed-off-by: Daan Hoogland --- .../apache/cloudstack/query/QueryService.java | 56 ++++++++++--------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/api/src/org/apache/cloudstack/query/QueryService.java b/api/src/org/apache/cloudstack/query/QueryService.java index a39a2d740e33..0cf05a643f1d 100644 --- a/api/src/org/apache/cloudstack/query/QueryService.java +++ b/api/src/org/apache/cloudstack/query/QueryService.java @@ -80,60 +80,62 @@ */ public interface QueryService { - public ListResponse searchForUsers(ListUsersCmd cmd) throws PermissionDeniedException; + ListResponse searchForUsers(ListUsersCmd cmd) throws PermissionDeniedException; - public ListResponse searchForEvents(ListEventsCmd cmd); + ListResponse searchForEvents(ListEventsCmd cmd); - public ListResponse listTags(ListTagsCmd cmd); + ListResponse listTags(ListTagsCmd cmd); - public ListResponse searchForVmGroups(ListVMGroupsCmd cmd); + ListResponse searchForVmGroups(ListVMGroupsCmd cmd); - public ListResponse searchForUserVMs(ListVMsCmd cmd); + ListResponse searchForUserVMs(ListVMsCmd cmd); - public ListResponse searchForSecurityGroups(ListSecurityGroupsCmd cmd); + ListResponse searchForSecurityGroups(ListSecurityGroupsCmd cmd); - public ListResponse searchForRouters(ListRoutersCmd cmd); + ListResponse searchForRouters(ListRoutersCmd cmd); - public ListResponse listProjectInvitations(ListProjectInvitationsCmd cmd); + ListResponse listProjectInvitations(ListProjectInvitationsCmd cmd); - public ListResponse listProjects(ListProjectsCmd cmd); + ListResponse listProjects(ListProjectsCmd cmd); - public ListResponse listProjectAccounts(ListProjectAccountsCmd cmd); + ListResponse listProjectAccounts(ListProjectAccountsCmd cmd); - public ListResponse searchForServers(ListHostsCmd cmd); + ListResponse searchForServers(ListHostsCmd cmd); - public ListResponse searchForVolumes(ListVolumesCmd cmd); + ListResponse searchForVolumes(ListVolumesCmd cmd); - public ListResponse searchForStoragePools(ListStoragePoolsCmd cmd); + ListResponse searchForStoragePools(ListStoragePoolsCmd cmd); - public ListResponse searchForImageStores(ListImageStoresCmd cmd); + ListResponse searchForImageStores(ListImageStoresCmd cmd); - public ListResponse searchForSecondaryStagingStores(ListSecondaryStagingStoresCmd cmd); + ListResponse searchForSecondaryStagingStores(ListSecondaryStagingStoresCmd cmd); - public ListResponse searchForDomains(ListDomainsCmd cmd); + ListResponse searchForDomains(ListDomainsCmd cmd); - public ListResponse searchForAccounts(ListAccountsCmd cmd); + ListResponse searchForAccounts(ListAccountsCmd cmd); - public ListResponse searchForAsyncJobs(ListAsyncJobsCmd cmd); + ListResponse searchForAsyncJobs(ListAsyncJobsCmd cmd); - public ListResponse searchForDiskOfferings(ListDiskOfferingsCmd cmd); + ListResponse searchForDiskOfferings(ListDiskOfferingsCmd cmd); - public ListResponse searchForServiceOfferings(ListServiceOfferingsCmd cmd); + ListResponse searchForServiceOfferings(ListServiceOfferingsCmd cmd); - public ListResponse listDataCenters(ListZonesCmd cmd); + ListResponse listDataCenters(ListZonesCmd cmd); - public ListResponse listTemplates(ListTemplatesCmd cmd); + ListResponse listTemplates(ListTemplatesCmd cmd); - public ListResponse listIsos(ListIsosCmd cmd); + ListResponse listIsos(ListIsosCmd cmd); - public ListResponse listAffinityGroups(Long affinityGroupId, String affinityGroupName, + ListResponse listAffinityGroups(Long affinityGroupId, String affinityGroupName, String affinityGroupType, Long vmId, String accountName, Long domainId, boolean isRecursive, boolean listAll, Long startIndex, Long pageSize, String keyword); - public List listResourceDetails(ListResourceDetailsCmd cmd); + List listResourceDetails(ListResourceDetailsCmd cmd); ListResponse searchForInternalLbVms(ListInternalLBVMsCmd cmd); - public ListResponse searchForStorageTags(ListStorageTagsCmd cmd); - public ListResponse searchForHostTags(ListHostTagsCmd cmd); + + ListResponse searchForStorageTags(ListStorageTagsCmd cmd); + + ListResponse searchForHostTags(ListHostTagsCmd cmd); } From 23a44d6417fc1eca6e61d64a79ef4e1d01928b30 Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Wed, 20 May 2015 21:13:12 +0200 Subject: [PATCH 088/175] instanceGroupResponse: fix description Signed-off-by: Daan Hoogland --- .../cloudstack/api/response/InstanceGroupResponse.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/api/src/org/apache/cloudstack/api/response/InstanceGroupResponse.java b/api/src/org/apache/cloudstack/api/response/InstanceGroupResponse.java index a2baf992f0ea..39f4b2f85385 100644 --- a/api/src/org/apache/cloudstack/api/response/InstanceGroupResponse.java +++ b/api/src/org/apache/cloudstack/api/response/InstanceGroupResponse.java @@ -30,8 +30,9 @@ @SuppressWarnings("unused") @EntityReference(value = InstanceGroup.class) public class InstanceGroupResponse extends BaseResponse implements ControlledViewEntityResponse { + @SerializedName(ApiConstants.ID) - @Param(description = "the id of the instance group") + @Param(description = "the ID of the instance group") private String id; @SerializedName(ApiConstants.NAME) @@ -47,11 +48,11 @@ public class InstanceGroupResponse extends BaseResponse implements ControlledVie private String accountName; @SerializedName(ApiConstants.PROJECT_ID) - @Param(description = "the project id of the group") + @Param(description = "the project ID of the instance group") private String projectId; @SerializedName(ApiConstants.PROJECT) - @Param(description = "the project name of the group") + @Param(description = "the project name of the instance group") private String projectName; @SerializedName(ApiConstants.DOMAIN_ID) From 5cd35a2237d4402c0e3520db08c6d42a10595c29 Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Wed, 20 May 2015 21:29:51 +0200 Subject: [PATCH 089/175] fix typos balacner -> balancer Signed-off-by: Daan Hoogland --- api/src/org/apache/cloudstack/api/BaseAsyncCmd.java | 2 +- .../region/ha/gslb/AssignToGlobalLoadBalancerRuleCmd.java | 2 +- .../region/ha/gslb/RemoveFromGlobalLoadBalancerRuleCmd.java | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java b/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java index e1b4d70ed604..8963415d8e33 100644 --- a/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java +++ b/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java @@ -28,7 +28,7 @@ public abstract class BaseAsyncCmd extends BaseCmd { public static final String networkSyncObject = "network"; public static final String vpcSyncObject = "vpc"; public static final String snapshotHostSyncObject = "snapshothost"; - public static final String gslbSyncObject = "globalserverloadbalacner"; + public static final String gslbSyncObject = "globalserverloadbalancer"; private static final Logger s_logger = Logger.getLogger(BaseAsyncCmd.class.getName()); private Object job; diff --git a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/AssignToGlobalLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/AssignToGlobalLoadBalancerRuleCmd.java index 8e1b4ddf12eb..99971bf67d1f 100644 --- a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/AssignToGlobalLoadBalancerRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/AssignToGlobalLoadBalancerRuleCmd.java @@ -73,7 +73,7 @@ public class AssignToGlobalLoadBalancerRuleCmd extends BaseAsyncCmd { collectionType = CommandType.UUID, entityType = FirewallRuleResponse.class, required = true, - description = "the list load balancer rules that " + "will be assigned to gloabal load balacner rule") + description = "the list load balancer rules that will be assigned to global load balancer rule") private List loadBalancerRulesIds; @Parameter(name = ApiConstants.GSLB_LBRULE_WEIGHT_MAP, diff --git a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/RemoveFromGlobalLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/RemoveFromGlobalLoadBalancerRuleCmd.java index af3fa349322d..c514984d2171 100644 --- a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/RemoveFromGlobalLoadBalancerRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/RemoveFromGlobalLoadBalancerRuleCmd.java @@ -42,7 +42,7 @@ import com.cloud.utils.StringUtils; @APICommand(name = "removeFromGlobalLoadBalancerRule", - description = "Removes a load balancer rule association with" + " global load balancer rule", + description = "Removes a load balancer rule association with global load balancer rule", responseObject = SuccessResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) @@ -67,7 +67,7 @@ public class RemoveFromGlobalLoadBalancerRuleCmd extends BaseAsyncCmd { collectionType = CommandType.UUID, entityType = FirewallRuleResponse.class, required = true, - description = "the list load balancer rules that " + "will be assigned to gloabal load balacner rule") + description = "the list load balancer rules that will be assigned to gloabal load balancer rule") private List loadBalancerRulesIds; ///////////////////////////////////////////////////// From 68e867f0c6565755f55dea086d21163048d11a9d Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Thu, 21 May 2015 09:36:27 +0200 Subject: [PATCH 090/175] api: account: fix and reformat descriptions Signed-off-by: Daan Hoogland --- .../api/command/user/account/AddAccountToProjectCmd.java | 8 ++++---- .../command/user/account/DeleteAccountFromProjectCmd.java | 6 +++--- .../api/command/user/account/ListAccountsCmd.java | 2 +- .../api/command/user/account/ListProjectAccountsCmd.java | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/api/src/org/apache/cloudstack/api/command/user/account/AddAccountToProjectCmd.java b/api/src/org/apache/cloudstack/api/command/user/account/AddAccountToProjectCmd.java index ef36038c5c48..22deb035b518 100644 --- a/api/src/org/apache/cloudstack/api/command/user/account/AddAccountToProjectCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/account/AddAccountToProjectCmd.java @@ -32,7 +32,7 @@ import com.cloud.exception.InvalidParameterValueException; import com.cloud.projects.Project; -@APICommand(name = "addAccountToProject", description = "Adds acoount to a project", responseObject = SuccessResponse.class, since = "3.0.0", +@APICommand(name = "addAccountToProject", description = "Adds account to a project", responseObject = SuccessResponse.class, since = "3.0.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class AddAccountToProjectCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(AddAccountToProjectCmd.class.getName()); @@ -47,7 +47,7 @@ public class AddAccountToProjectCmd extends BaseAsyncCmd { type = CommandType.UUID, entityType = ProjectResponse.class, required = true, - description = "id of the project to add the account to") + description = "ID of the project to add the account to") private Long projectId; @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "name of the account to be added to the project") @@ -87,7 +87,7 @@ public void execute() { throw new InvalidParameterValueException("Either accountName or email is required"); } - CallContext.current().setEventDetails("Project id: " + projectId + "; accountName " + accountName); + CallContext.current().setEventDetails("Project ID: " + projectId + "; accountName " + accountName); boolean result = _projectService.addAccountToProject(getProjectId(), getAccountName(), getEmail()); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); @@ -102,7 +102,7 @@ public long getEntityOwnerId() { Project project = _projectService.getProject(getProjectId()); //verify input parameters if (project == null) { - InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find project with specified id"); + InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find project with specified ID"); ex.addProxyObject(getProjectId().toString(), "projectId"); throw ex; } diff --git a/api/src/org/apache/cloudstack/api/command/user/account/DeleteAccountFromProjectCmd.java b/api/src/org/apache/cloudstack/api/command/user/account/DeleteAccountFromProjectCmd.java index 5c891733b5ae..60003b7b8fd1 100644 --- a/api/src/org/apache/cloudstack/api/command/user/account/DeleteAccountFromProjectCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/account/DeleteAccountFromProjectCmd.java @@ -47,7 +47,7 @@ public class DeleteAccountFromProjectCmd extends BaseAsyncCmd { type = CommandType.UUID, entityType = ProjectResponse.class, required = true, - description = "id of the project to remove the account from") + description = "ID of the project to remove the account from") private Long projectId; @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, required = true, description = "name of the account to be removed from the project") @@ -76,7 +76,7 @@ public String getAccountName() { @Override public void execute() { - CallContext.current().setEventDetails("Project id: " + projectId + "; accountName " + accountName); + CallContext.current().setEventDetails("Project ID: " + projectId + "; accountName " + accountName); boolean result = _projectService.deleteAccountFromProject(projectId, accountName); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); @@ -91,7 +91,7 @@ public long getEntityOwnerId() { Project project = _projectService.getProject(projectId); //verify input parameters if (project == null) { - throw new InvalidParameterValueException("Unable to find project by id " + projectId); + throw new InvalidParameterValueException("Unable to find project by ID " + projectId); } return _projectService.getProjectOwner(projectId).getId(); diff --git a/api/src/org/apache/cloudstack/api/command/user/account/ListAccountsCmd.java b/api/src/org/apache/cloudstack/api/command/user/account/ListAccountsCmd.java index 0b5ae7c0baf8..167f23306f28 100644 --- a/api/src/org/apache/cloudstack/api/command/user/account/ListAccountsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/account/ListAccountsCmd.java @@ -46,7 +46,7 @@ public class ListAccountsCmd extends BaseListDomainResourcesCmd { @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = AccountResponse.class, description = "list account by account ID") private Long id; - @Parameter(name = ApiConstants.IS_CLEANUP_REQUIRED, type = CommandType.BOOLEAN, description = "list accounts by cleanuprequred attribute (values are true or false)") + @Parameter(name = ApiConstants.IS_CLEANUP_REQUIRED, type = CommandType.BOOLEAN, description = "list accounts by cleanuprequired attribute (values are true or false)") private Boolean cleanupRequired; @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "list account by account name") diff --git a/api/src/org/apache/cloudstack/api/command/user/account/ListProjectAccountsCmd.java b/api/src/org/apache/cloudstack/api/command/user/account/ListProjectAccountsCmd.java index a70024edd510..3fcb1989fa56 100644 --- a/api/src/org/apache/cloudstack/api/command/user/account/ListProjectAccountsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/account/ListProjectAccountsCmd.java @@ -39,7 +39,7 @@ public class ListProjectAccountsCmd extends BaseListCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, entityType = ProjectResponse.class, required = true, description = "id of the project") + @Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, entityType = ProjectResponse.class, required = true, description = "ID of the project") private Long projectId; @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "list accounts of the project by account name") From 4c65acfff7bfd5633a7adfaf062603ddea4742df Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Thu, 21 May 2015 09:37:27 +0200 Subject: [PATCH 091/175] api: address: fix and reformat descriptions Signed-off-by: Daan Hoogland --- .../user/address/AssociateIPAddrCmd.java | 30 +++++++++---------- .../user/address/DisassociateIPAddrCmd.java | 14 ++++----- .../address/ListPublicIpAddressesCmd.java | 16 +++++----- .../command/user/address/UpdateIPAddrCmd.java | 12 ++++---- 4 files changed, 36 insertions(+), 36 deletions(-) diff --git a/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java b/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java index 63939dcc7767..75bd9d21d1bd 100644 --- a/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java @@ -85,13 +85,13 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd { @Parameter(name = ApiConstants.NETWORK_ID, type = CommandType.UUID, entityType = NetworkResponse.class, - description = "The network this ip address should be associated to.") + description = "The network this IP address should be associated to.") private Long networkId; - @Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, entityType = ProjectResponse.class, description = "Deploy vm for the project") + @Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, entityType = ProjectResponse.class, description = "Deploy VM for the project") private Long projectId; - @Parameter(name = ApiConstants.VPC_ID, type = CommandType.UUID, entityType = VpcResponse.class, description = "the VPC you want the ip address to " + @Parameter(name = ApiConstants.VPC_ID, type = CommandType.UUID, entityType = VpcResponse.class, description = "the VPC you want the IP address to " + "be associated with") private Long vpcId; @@ -103,10 +103,10 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd { type = CommandType.INTEGER, entityType = RegionResponse.class, required = false, - description = "region ID from where portable ip is to be associated.") + description = "region ID from where portable IP is to be associated.") private Integer regionId; - @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the ip to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the IP to the end user or not", since = "4.4", authorized = {RoleType.Admin}) private Boolean display; ///////////////////////////////////////////////////// @@ -142,7 +142,7 @@ private long getZoneId() { } } - throw new InvalidParameterValueException("Unable to figure out zone to assign ip to." + throw new InvalidParameterValueException("Unable to figure out zone to assign IP to." + " Please specify either zoneId, or networkId, or vpcId in the call"); } @@ -182,16 +182,16 @@ public Long getNetworkId() { } if (networks.size() < 1) { - throw new InvalidParameterValueException("Account doesn't have any Isolated networks in the zone"); + throw new InvalidParameterValueException("Account doesn't have any isolated networks in the zone"); } else if (networks.size() > 1) { - throw new InvalidParameterValueException("Account has more than one Isolated network in the zone"); + throw new InvalidParameterValueException("Account has more than one isolated network in the zone"); } return networks.get(0).getId(); } else { Network defaultGuestNetwork = _networkService.getExclusiveGuestNetwork(zoneId); if (defaultGuestNetwork == null) { - throw new InvalidParameterValueException("Unable to find a default Guest network for account " + getAccountName() + " in domain id=" + getDomainId()); + throw new InvalidParameterValueException("Unable to find a default guest network for account " + getAccountName() + " in domain ID=" + getDomainId()); } else { return defaultGuestNetwork.getId(); } @@ -227,7 +227,7 @@ public long getEntityOwnerId() { " as it's no longer active"); } } else { - throw new InvalidParameterValueException("Unable to find project by id"); + throw new InvalidParameterValueException("Unable to find project by ID"); } } else if (networkId != null) { Network network = _networkService.getNetwork(networkId); @@ -249,7 +249,7 @@ public long getEntityOwnerId() { } else if (vpcId != null) { Vpc vpc = _entityMgr.findById(Vpc.class, getVpcId()); if (vpc == null) { - throw new InvalidParameterValueException("Can't find Enabled vpc by id specified"); + throw new InvalidParameterValueException("Can't find enabled VPC by ID specified"); } return vpc.getAccountId(); } @@ -268,7 +268,7 @@ public String getEventType() { @Override public String getEventDescription() { - return "associating ip to network id: " + getNetworkId() + " in zone " + getZoneId(); + return "associating IP to network ID: " + getNetworkId() + " in zone " + getZoneId(); } ///////////////////////////////////////////////////// @@ -299,7 +299,7 @@ public void create() throws ResourceAllocationException { setEntityId(ip.getId()); setEntityUuid(ip.getUuid()); } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to allocate ip address"); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to allocate IP address"); } } catch (ConcurrentOperationException ex) { s_logger.warn("Exception: ", ex); @@ -313,7 +313,7 @@ public void create() throws ResourceAllocationException { @Override public void execute() throws ResourceUnavailableException, ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException { - CallContext.current().setEventDetails("Ip Id: " + getEntityId()); + CallContext.current().setEventDetails("IP ID: " + getEntityId()); IpAddress result = null; @@ -328,7 +328,7 @@ public void execute() throws ResourceUnavailableException, ResourceAllocationExc ipResponse.setResponseName(getCommandName()); setResponseObject(ipResponse); } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to assign ip address"); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to assign IP address"); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/address/DisassociateIPAddrCmd.java b/api/src/org/apache/cloudstack/api/command/user/address/DisassociateIPAddrCmd.java index ba4184434e9b..c2e173c0fa5c 100644 --- a/api/src/org/apache/cloudstack/api/command/user/address/DisassociateIPAddrCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/address/DisassociateIPAddrCmd.java @@ -36,7 +36,7 @@ import com.cloud.network.IpAddress; import com.cloud.user.Account; -@APICommand(name = "disassociateIpAddress", description = "Disassociates an ip address from the account.", responseObject = SuccessResponse.class, +@APICommand(name = "disassociateIpAddress", description = "Disassociates an IP address from the account.", responseObject = SuccessResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, entityType = { IpAddress.class }) public class DisassociateIPAddrCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DisassociateIPAddrCmd.class.getName()); @@ -47,7 +47,7 @@ public class DisassociateIPAddrCmd extends BaseAsyncCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = IPAddressResponse.class, required = true, description = "the id of the public ip address" + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = IPAddressResponse.class, required = true, description = "the ID of the public IP address" + " to disassociate") private Long id; @@ -74,7 +74,7 @@ public String getCommandName() { @Override public void execute() throws InsufficientAddressCapacityException { - CallContext.current().setEventDetails("Ip Id: " + getIpAddressId()); + CallContext.current().setEventDetails("IP ID: " + getIpAddressId()); boolean result = false; if (!isPortable(id)) { result = _networkService.releaseIpAddress(getIpAddressId()); @@ -85,7 +85,7 @@ public void execute() throws InsufficientAddressCapacityException { SuccessResponse response = new SuccessResponse(getCommandName()); this.setResponseObject(response); } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to disassociate ip address"); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to disassociate IP address"); } } @@ -100,7 +100,7 @@ public String getEventType() { @Override public String getEventDescription() { - return ("Disassociating ip address with id=" + id); + return ("Disassociating IP address with ID=" + id); } @Override @@ -108,7 +108,7 @@ public long getEntityOwnerId() { if (ownerId == null) { IpAddress ip = getIpAddress(id); if (ip == null) { - throw new InvalidParameterValueException("Unable to find ip address by id=" + id); + throw new InvalidParameterValueException("Unable to find IP address by ID=" + id); } ownerId = ip.getAccountId(); } @@ -134,7 +134,7 @@ private IpAddress getIpAddress(long id) { IpAddress ip = _entityMgr.findById(IpAddress.class, id); if (ip == null) { - throw new InvalidParameterValueException("Unable to find ip address by id=" + id); + throw new InvalidParameterValueException("Unable to find IP address by ID=" + id); } else { return ip; } diff --git a/api/src/org/apache/cloudstack/api/command/user/address/ListPublicIpAddressesCmd.java b/api/src/org/apache/cloudstack/api/command/user/address/ListPublicIpAddressesCmd.java index 5720a507ab7c..0a0e7a120761 100644 --- a/api/src/org/apache/cloudstack/api/command/user/address/ListPublicIpAddressesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/address/ListPublicIpAddressesCmd.java @@ -39,7 +39,7 @@ import com.cloud.network.IpAddress; import com.cloud.utils.Pair; -@APICommand(name = "listPublicIpAddresses", description = "Lists all public ip addresses", responseObject = IPAddressResponse.class, responseView = ResponseView.Restricted, +@APICommand(name = "listPublicIpAddresses", description = "Lists all public IP addresses", responseObject = IPAddressResponse.class, responseView = ResponseView.Restricted, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, entityType = { IpAddress.class }) public class ListPublicIpAddressesCmd extends BaseListTaggedResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListPublicIpAddressesCmd.class.getName()); @@ -59,7 +59,7 @@ public class ListPublicIpAddressesCmd extends BaseListTaggedResourcesCmd { @Parameter(name = ApiConstants.FOR_VIRTUAL_NETWORK, type = CommandType.BOOLEAN, description = "the virtual network for the IP address") private Boolean forVirtualNetwork; - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = IPAddressResponse.class, description = "lists ip address by id") + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = IPAddressResponse.class, description = "lists IP address by ID") private Long id; @Parameter(name = ApiConstants.IP_ADDRESS, type = CommandType.STRING, description = "lists the specified IP address") @@ -68,16 +68,16 @@ public class ListPublicIpAddressesCmd extends BaseListTaggedResourcesCmd { @Parameter(name = ApiConstants.VLAN_ID, type = CommandType.UUID, entityType = VlanIpRangeResponse.class, description = "lists all public IP addresses by VLAN ID") private Long vlanId; - @Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, description = "lists all public IP addresses by Zone ID") + @Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, description = "lists all public IP addresses by zone ID") private Long zoneId; - @Parameter(name = ApiConstants.FOR_LOAD_BALANCING, type = CommandType.BOOLEAN, description = "list only ips used for load balancing") + @Parameter(name = ApiConstants.FOR_LOAD_BALANCING, type = CommandType.BOOLEAN, description = "list only IPs used for load balancing") private Boolean forLoadBalancing; @Parameter(name = ApiConstants.PHYSICAL_NETWORK_ID, type = CommandType.UUID, entityType = PhysicalNetworkResponse.class, - description = "lists all public IP addresses by physical network id") + description = "lists all public IP addresses by physical network ID") private Long physicalNetworkId; @Parameter(name = ApiConstants.ASSOCIATED_NETWORK_ID, @@ -86,13 +86,13 @@ public class ListPublicIpAddressesCmd extends BaseListTaggedResourcesCmd { description = "lists all public IP addresses associated to the network specified") private Long associatedNetworkId; - @Parameter(name = ApiConstants.IS_SOURCE_NAT, type = CommandType.BOOLEAN, description = "list only source nat ip addresses") + @Parameter(name = ApiConstants.IS_SOURCE_NAT, type = CommandType.BOOLEAN, description = "list only source NAT IP addresses") private Boolean isSourceNat; - @Parameter(name = ApiConstants.IS_STATIC_NAT, type = CommandType.BOOLEAN, description = "list only static nat ip addresses") + @Parameter(name = ApiConstants.IS_STATIC_NAT, type = CommandType.BOOLEAN, description = "list only static NAT IP addresses") private Boolean isStaticNat; - @Parameter(name = ApiConstants.VPC_ID, type = CommandType.UUID, entityType = VpcResponse.class, description = "List ips belonging to the VPC") + @Parameter(name = ApiConstants.VPC_ID, type = CommandType.UUID, entityType = VpcResponse.class, description = "List IPs belonging to the VPC") private Long vpcId; @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "list resources by display flag; only ROOT admin is eligible to pass this parameter", since = "4.4", authorized = {RoleType.Admin}) diff --git a/api/src/org/apache/cloudstack/api/command/user/address/UpdateIPAddrCmd.java b/api/src/org/apache/cloudstack/api/command/user/address/UpdateIPAddrCmd.java index f0ea6672c786..6d20283984b7 100644 --- a/api/src/org/apache/cloudstack/api/command/user/address/UpdateIPAddrCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/address/UpdateIPAddrCmd.java @@ -38,7 +38,7 @@ import com.cloud.network.IpAddress; import com.cloud.user.Account; -@APICommand(name = "updateIpAddress", description = "Updates an ip address", responseObject = IPAddressResponse.class, +@APICommand(name = "updateIpAddress", description = "Updates an IP address", responseObject = IPAddressResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, entityType = { IpAddress.class }) public class UpdateIPAddrCmd extends BaseAsyncCustomIdCmd { public static final Logger s_logger = Logger.getLogger(UpdateIPAddrCmd.class.getName()); @@ -48,14 +48,14 @@ public class UpdateIPAddrCmd extends BaseAsyncCustomIdCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = IPAddressResponse.class, required = true, description = "the id of the public ip address" + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = IPAddressResponse.class, required = true, description = "the ID of the public IP address" + " to update") private Long id; // unexposed parameter needed for events logging @Parameter(name = ApiConstants.ACCOUNT_ID, type = CommandType.UUID, entityType = AccountResponse.class, expose = false) private Long ownerId; - @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the ip to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the IP to the end user or not", since = "4.4", authorized = {RoleType.Admin}) private Boolean display; ///////////////////////////////////////////////////// @@ -85,7 +85,7 @@ public String getEventType() { @Override public String getEventDescription() { - return ("Updating ip address with id=" + id); + return ("Updating IP address with ID=" + id); } @@ -94,7 +94,7 @@ public long getEntityOwnerId() { if (ownerId == null) { IpAddress ip = getIpAddress(id); if (ip == null) { - throw new InvalidParameterValueException("Unable to find ip address by id=" + id); + throw new InvalidParameterValueException("Unable to find IP address by ID=" + id); } ownerId = ip.getAccountId(); } @@ -109,7 +109,7 @@ private IpAddress getIpAddress(long id) { IpAddress ip = _entityMgr.findById(IpAddress.class, id); if (ip == null) { - throw new InvalidParameterValueException("Unable to find ip address by id=" + id); + throw new InvalidParameterValueException("Unable to find IP address by ID=" + id); } else { return ip; } From f17ab71bdf299a42d16a3ee55508e8c1b0e30c6c Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Thu, 21 May 2015 09:38:12 +0200 Subject: [PATCH 092/175] api: affinitygroup: fix and reformat descriptions Signed-off-by: Daan Hoogland --- .../command/user/affinitygroup/DeleteAffinityGroupCmd.java | 6 +++--- .../command/user/affinitygroup/ListAffinityGroupsCmd.java | 4 ++-- .../user/affinitygroup/UpdateVMAffinityGroupCmd.java | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/api/src/org/apache/cloudstack/api/command/user/affinitygroup/DeleteAffinityGroupCmd.java b/api/src/org/apache/cloudstack/api/command/user/affinitygroup/DeleteAffinityGroupCmd.java index 21c2fa86d043..4eeff06a00f2 100644 --- a/api/src/org/apache/cloudstack/api/command/user/affinitygroup/DeleteAffinityGroupCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/affinitygroup/DeleteAffinityGroupCmd.java @@ -64,7 +64,7 @@ public class DeleteAffinityGroupCmd extends BaseAsyncCmd { entityType = AffinityGroupResponse.class) private Long id; - @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "The name of the affinity group. Mutually exclusive with id parameter") + @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "The name of the affinity group. Mutually exclusive with ID parameter") private String name; ///////////////////////////////////////////////////// @@ -87,12 +87,12 @@ public Long getId() { if (name != null) { id = _responseGenerator.getAffinityGroupId(name, getEntityOwnerId()); if (id == null) { - throw new InvalidParameterValueException("Unable to find affinity group by name " + name + " for the account id=" + getEntityOwnerId()); + throw new InvalidParameterValueException("Unable to find affinity group by name " + name + " for the account ID=" + getEntityOwnerId()); } } if (id == null) { - throw new InvalidParameterValueException("Either id or name parameter is requred by deleteAffinityGroup command"); + throw new InvalidParameterValueException("Either ID or name parameter is required by deleteAffinityGroup command"); } return id; diff --git a/api/src/org/apache/cloudstack/api/command/user/affinitygroup/ListAffinityGroupsCmd.java b/api/src/org/apache/cloudstack/api/command/user/affinitygroup/ListAffinityGroupsCmd.java index 6313c4812e93..41ed6fb01c72 100644 --- a/api/src/org/apache/cloudstack/api/command/user/affinitygroup/ListAffinityGroupsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/affinitygroup/ListAffinityGroupsCmd.java @@ -44,11 +44,11 @@ public class ListAffinityGroupsCmd extends BaseListAccountResourcesCmd { @Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, type = CommandType.UUID, - description = "lists affinity groups by virtual machine id", + description = "lists affinity groups by virtual machine ID", entityType = UserVmResponse.class) private Long virtualMachineId; - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, description = "list the affinity group by the id provided", entityType = AffinityGroupResponse.class) + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, description = "list the affinity group by the ID provided", entityType = AffinityGroupResponse.class) private Long id; @Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, description = "lists affinity groups by type") diff --git a/api/src/org/apache/cloudstack/api/command/user/affinitygroup/UpdateVMAffinityGroupCmd.java b/api/src/org/apache/cloudstack/api/command/user/affinitygroup/UpdateVMAffinityGroupCmd.java index 66201477b978..703b051ef866 100644 --- a/api/src/org/apache/cloudstack/api/command/user/affinitygroup/UpdateVMAffinityGroupCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/affinitygroup/UpdateVMAffinityGroupCmd.java @@ -138,7 +138,7 @@ public long getEntityOwnerId() { @Override public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException { - CallContext.current().setEventDetails("Vm Id: " + getId()); + CallContext.current().setEventDetails("VM ID: " + getId()); UserVm result = _affinityGroupService.updateVMAffinityGroups(getId(), getAffinityGroupIdList()); ArrayList dc = new ArrayList(); dc.add(VMDetails.valueOf("affgrp")); @@ -149,7 +149,7 @@ public void execute() throws ResourceUnavailableException, InsufficientCapacityE response.setResponseName(getCommandName()); setResponseObject(response); } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update vm's affinity groups"); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update VM's affinity groups"); } } @@ -160,7 +160,7 @@ public String getEventType() { @Override public String getEventDescription() { - return "updating VM Affinity Group"; + return "updating VM affinity group"; } @Override From 897c73867d85fdc4b41c2d303ed422e34d2a9eb9 Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Thu, 21 May 2015 09:52:53 +0200 Subject: [PATCH 093/175] api: firewall: fix and reformat descriptions Signed-off-by: Daan Hoogland --- .../firewall/CreateEgressFirewallRuleCmd.java | 2 +- .../user/firewall/CreateFirewallRuleCmd.java | 20 +++++++++---------- .../firewall/CreatePortForwardingRuleCmd.java | 2 +- .../firewall/DeleteEgressFirewallRuleCmd.java | 2 +- .../user/firewall/DeleteFirewallRuleCmd.java | 4 ++-- .../firewall/DeletePortForwardingRuleCmd.java | 6 +++--- .../firewall/ListEgressFirewallRulesCmd.java | 6 +++--- .../user/firewall/ListFirewallRulesCmd.java | 2 +- .../firewall/ListPortForwardingRulesCmd.java | 2 +- .../firewall/UpdateEgressFirewallRuleCmd.java | 2 +- .../user/firewall/UpdateFirewallRuleCmd.java | 4 ++-- .../firewall/UpdatePortForwardingRuleCmd.java | 2 +- 12 files changed, 27 insertions(+), 27 deletions(-) diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/CreateEgressFirewallRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/CreateEgressFirewallRuleCmd.java index b130370c3a5e..0303445af77d 100644 --- a/api/src/org/apache/cloudstack/api/command/user/firewall/CreateEgressFirewallRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/CreateEgressFirewallRuleCmd.java @@ -247,7 +247,7 @@ public void create() { } if (getProtocol().equalsIgnoreCase(NetUtils.ALL_PROTO)) { if (getSourcePortStart() != null && getSourcePortEnd() != null) { - throw new InvalidParameterValueException("Do not pass ports to protocol ALL, porotocol ALL do not require ports. Unable to create " + + throw new InvalidParameterValueException("Do not pass ports to protocol ALL, protocol ALL do not require ports. Unable to create " + "firewall rule for the network id=" + networkId); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/CreateFirewallRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/CreateFirewallRuleCmd.java index 7595d368ae5a..ee62aa5ad4ad 100644 --- a/api/src/org/apache/cloudstack/api/command/user/firewall/CreateFirewallRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/CreateFirewallRuleCmd.java @@ -43,7 +43,7 @@ import com.cloud.user.Account; import com.cloud.utils.net.NetUtils; -@APICommand(name = "createFirewallRule", description = "Creates a firewall rule for a given ip address", responseObject = FirewallResponse.class, entityType = {FirewallRule.class}, +@APICommand(name = "createFirewallRule", description = "Creates a firewall rule for a given IP address", responseObject = FirewallResponse.class, entityType = {FirewallRule.class}, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements FirewallRule { public static final Logger s_logger = Logger.getLogger(CreateFirewallRuleCmd.class.getName()); @@ -73,10 +73,10 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal @Parameter(name = ApiConstants.END_PORT, type = CommandType.INTEGER, description = "the ending port of firewall rule") private Integer publicEndPort; - @Parameter(name = ApiConstants.CIDR_LIST, type = CommandType.LIST, collectionType = CommandType.STRING, description = "the cidr list to forward traffic from") + @Parameter(name = ApiConstants.CIDR_LIST, type = CommandType.LIST, collectionType = CommandType.STRING, description = "the CIDR list to forward traffic from") private List cidrlist; - @Parameter(name = ApiConstants.ICMP_TYPE, type = CommandType.INTEGER, description = "type of the icmp message being sent") + @Parameter(name = ApiConstants.ICMP_TYPE, type = CommandType.INTEGER, description = "type of the ICMP message being sent") private Integer icmpType; @Parameter(name = ApiConstants.ICMP_CODE, type = CommandType.INTEGER, description = "error code for this icmp message") @@ -133,7 +133,7 @@ public void execute() throws ResourceUnavailableException { boolean success = false; FirewallRule rule = _entityMgr.findById(FirewallRule.class, getEntityId()); try { - CallContext.current().setEventDetails("Rule Id: " + getEntityId()); + CallContext.current().setEventDetails("Rule ID: " + getEntityId()); success = _firewallService.applyIngressFwRules(rule.getSourceIpAddressId(), callerContext.getCallingAccount()); // State is different after the rule is applied, so get new object here @@ -154,7 +154,7 @@ public void execute() throws ResourceUnavailableException { @Override public long getId() { - throw new UnsupportedOperationException("database id can only provided by VO objects"); + throw new UnsupportedOperationException("database ID can only provided by VO objects"); } @Override @@ -215,8 +215,8 @@ public long getNetworkId() { } if (ntwkId == null) { - throw new InvalidParameterValueException("Unable to create firewall rule for the ipAddress id=" + ipAddressId + - " as ip is not associated with any network and no networkId is passed in"); + throw new InvalidParameterValueException("Unable to create firewall rule for the IP address ID=" + ipAddressId + + " as IP is not associated with any network and no networkId is passed in"); } return ntwkId; } @@ -243,7 +243,7 @@ public void create() { if (getSourceCidrList() != null) { for (String cidr : getSourceCidrList()) { if (!NetUtils.isValidCIDR(cidr)) { - throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Source cidrs formatting error " + cidr); + throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Source CIDRs formatting error " + cidr); } } } @@ -268,7 +268,7 @@ public String getEventType() { @Override public String getEventDescription() { IpAddress ip = _networkService.getIp(ipAddressId); - return ("Creating firewall rule for Ip: " + ip.getAddress() + " for protocol:" + getProtocol()); + return ("Creating firewall rule for IP: " + ip.getAddress() + " for protocol:" + getProtocol()); } @Override @@ -290,7 +290,7 @@ public Long getSyncObjId() { private IpAddress getIp() { IpAddress ip = _networkService.getIp(ipAddressId); if (ip == null) { - throw new InvalidParameterValueException("Unable to find ip address by id " + ipAddressId); + throw new InvalidParameterValueException("Unable to find IP address by ID " + ipAddressId); } return ip; } diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java index 122cad0399e3..9a0dffe1fdc5 100644 --- a/api/src/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java @@ -79,7 +79,7 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P @Parameter(name = ApiConstants.PROTOCOL, type = CommandType.STRING, required = true, - description = "the protocol for the port fowarding rule. Valid values are TCP or UDP.") + description = "the protocol for the port forwarding rule. Valid values are TCP or UDP.") private String protocol; @Parameter(name = ApiConstants.PRIVATE_END_PORT, diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/DeleteEgressFirewallRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/DeleteEgressFirewallRuleCmd.java index d08169d28769..59a0519df4da 100644 --- a/api/src/org/apache/cloudstack/api/command/user/firewall/DeleteEgressFirewallRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/DeleteEgressFirewallRuleCmd.java @@ -38,7 +38,7 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.rules.FirewallRule; -@APICommand(name = "deleteEgressFirewallRule", description = "Deletes an ggress firewall rule", responseObject = SuccessResponse.class, entityType = {FirewallRule.class}, +@APICommand(name = "deleteEgressFirewallRule", description = "Deletes an egress firewall rule", responseObject = SuccessResponse.class, entityType = {FirewallRule.class}, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteEgressFirewallRuleCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteEgressFirewallRuleCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/DeleteFirewallRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/DeleteFirewallRuleCmd.java index 0f1001246109..ba8b18eacf02 100644 --- a/api/src/org/apache/cloudstack/api/command/user/firewall/DeleteFirewallRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/DeleteFirewallRuleCmd.java @@ -77,7 +77,7 @@ public String getEventType() { @Override public String getEventDescription() { - return ("Deleting firewall rule id=" + id); + return ("Deleting firewall rule ID=" + id); } @Override @@ -85,7 +85,7 @@ public long getEntityOwnerId() { if (ownerId == null) { FirewallRule rule = _entityMgr.findById(FirewallRule.class, id); if (rule == null) { - throw new InvalidParameterValueException("Unable to find firewall rule by id=" + id); + throw new InvalidParameterValueException("Unable to find firewall rule by ID=" + id); } else { ownerId = _entityMgr.findById(FirewallRule.class, id).getAccountId(); } diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/DeletePortForwardingRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/DeletePortForwardingRuleCmd.java index 4c7b07f14f09..1c45280a8372 100644 --- a/api/src/org/apache/cloudstack/api/command/user/firewall/DeletePortForwardingRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/DeletePortForwardingRuleCmd.java @@ -81,7 +81,7 @@ public String getEventType() { @Override public String getEventDescription() { - return ("Deleting port forwarding rule for id=" + id); + return ("Deleting port forwarding rule for ID=" + id); } @Override @@ -89,7 +89,7 @@ public long getEntityOwnerId() { if (ownerId == null) { PortForwardingRule rule = _entityMgr.findById(PortForwardingRule.class, id); if (rule == null) { - throw new InvalidParameterValueException("Unable to find port forwarding rule by id=" + id); + throw new InvalidParameterValueException("Unable to find port forwarding rule by ID=" + id); } else { ownerId = _entityMgr.findById(PortForwardingRule.class, id).getAccountId(); } @@ -100,7 +100,7 @@ public long getEntityOwnerId() { @Override public void execute() { - CallContext.current().setEventDetails("Rule Id: " + id); + CallContext.current().setEventDetails("Rule ID: " + id); //revoke corresponding firewall rule first boolean result = _firewallService.revokeRelatedFirewallRule(id, true); result = result && _rulesService.revokePortForwardingRule(id, true); diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/ListEgressFirewallRulesCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/ListEgressFirewallRulesCmd.java index c56e13361a0f..3664031d5502 100644 --- a/api/src/org/apache/cloudstack/api/command/user/firewall/ListEgressFirewallRulesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/ListEgressFirewallRulesCmd.java @@ -36,7 +36,7 @@ import com.cloud.network.rules.FirewallRule; import com.cloud.utils.Pair; -@APICommand(name = "listEgressFirewallRules", description = "Lists all egress firewall rules for network id.", responseObject = FirewallResponse.class, entityType = {FirewallRule.class}, +@APICommand(name = "listEgressFirewallRules", description = "Lists all egress firewall rules for network ID.", responseObject = FirewallResponse.class, entityType = {FirewallRule.class}, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListEgressFirewallRulesCmd extends BaseListTaggedResourcesCmd implements IListFirewallRulesCmd { public static final Logger s_logger = Logger.getLogger(ListEgressFirewallRulesCmd.class.getName()); @@ -51,13 +51,13 @@ public class ListEgressFirewallRulesCmd extends BaseListTaggedResourcesCmd imple @Parameter(name = ApiConstants.NETWORK_ID, type = CommandType.UUID, entityType = NetworkResponse.class, - description = "the network id for the egress firewall services") + description = "the network ID for the egress firewall services") private Long networkId; @Parameter(name = ApiConstants.IP_ADDRESS_ID, type = CommandType.UUID, entityType = IPAddressResponse.class, - description = "the id of IP address of the firewall services") + description = "the ID of IP address of the firewall services") private Long ipAddressId; @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "list resources by display flag; only ROOT admin is eligible to pass this parameter", since = "4.4", authorized = {RoleType.Admin}) diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/ListFirewallRulesCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/ListFirewallRulesCmd.java index 9ace5bdd27d0..3c3feeabfe17 100644 --- a/api/src/org/apache/cloudstack/api/command/user/firewall/ListFirewallRulesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/ListFirewallRulesCmd.java @@ -50,7 +50,7 @@ public class ListFirewallRulesCmd extends BaseListTaggedResourcesCmd implements @Parameter(name = ApiConstants.IP_ADDRESS_ID, type = CommandType.UUID, entityType = IPAddressResponse.class, - description = "the id of IP address of the firewall services") + description = "the ID of IP address of the firewall services") private Long ipAddressId; @Parameter(name = ApiConstants.NETWORK_ID, diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/ListPortForwardingRulesCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/ListPortForwardingRulesCmd.java index 5d448154c826..d5c49a9a4d2f 100644 --- a/api/src/org/apache/cloudstack/api/command/user/firewall/ListPortForwardingRulesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/ListPortForwardingRulesCmd.java @@ -51,7 +51,7 @@ public class ListPortForwardingRulesCmd extends BaseListTaggedResourcesCmd { @Parameter(name = ApiConstants.IP_ADDRESS_ID, type = CommandType.UUID, entityType = IPAddressResponse.class, - description = "the id of IP address of the port forwarding services") + description = "the ID of IP address of the port forwarding services") private Long ipAddressId; @Parameter(name = ApiConstants.NETWORK_ID, diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/UpdateEgressFirewallRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/UpdateEgressFirewallRuleCmd.java index b597a891ba35..ddaaf7135b43 100644 --- a/api/src/org/apache/cloudstack/api/command/user/firewall/UpdateEgressFirewallRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/UpdateEgressFirewallRuleCmd.java @@ -112,7 +112,7 @@ public long getEntityOwnerId() { if (ownerId == null) { FirewallRule rule = _entityMgr.findById(FirewallRule.class, id); if (rule == null || rule.getTrafficType() != TrafficType.Egress) { - throw new InvalidParameterValueException("Unable to find egress firewall rule by id"); + throw new InvalidParameterValueException("Unable to find egress firewall rule by ID"); } else { ownerId = _entityMgr.findById(FirewallRule.class, id).getAccountId(); } diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/UpdateFirewallRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/UpdateFirewallRuleCmd.java index e9c87d016310..3d11ed0f3f5c 100644 --- a/api/src/org/apache/cloudstack/api/command/user/firewall/UpdateFirewallRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/UpdateFirewallRuleCmd.java @@ -78,7 +78,7 @@ public String getCommandName() { @Override public void execute() throws ResourceUnavailableException { - CallContext.current().setEventDetails("Rule Id: " + id); + CallContext.current().setEventDetails("Rule ID: " + id); FirewallRule rule = _firewallService.updateIngressFirewallRule(id, this.getCustomId(), getDisplay()); FirewallResponse fwResponse = new FirewallResponse(); @@ -113,7 +113,7 @@ public long getEntityOwnerId() { if (ownerId == null) { FirewallRule rule = _entityMgr.findById(FirewallRule.class, id); if (rule == null || rule.getTrafficType() != TrafficType.Ingress) { - throw new InvalidParameterValueException("Unable to find firewall rule by id"); + throw new InvalidParameterValueException("Unable to find firewall rule by ID"); } else { ownerId = _entityMgr.findById(FirewallRule.class, id).getAccountId(); } diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/UpdatePortForwardingRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/UpdatePortForwardingRuleCmd.java index 596b1d274e80..5f609b726f80 100644 --- a/api/src/org/apache/cloudstack/api/command/user/firewall/UpdatePortForwardingRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/UpdatePortForwardingRuleCmd.java @@ -35,7 +35,7 @@ @APICommand(name = "updatePortForwardingRule", responseObject = FirewallRuleResponse.class, - description = "Updates a port forwarding rule. Only the private port and the virtual machine can be updated.", entityType = {PortForwardingRule.class}, + description = "Updates a port forwarding rule. Only the private port and the virtual machine can be updated.", entityType = {PortForwardingRule.class}, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdatePortForwardingRuleCmd extends BaseAsyncCustomIdCmd { public static final Logger s_logger = Logger.getLogger(UpdatePortForwardingRuleCmd.class.getName()); From a1f58c48ec0b2dd33232c7a0e04af1f99289421e Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Thu, 21 May 2015 09:56:13 +0200 Subject: [PATCH 094/175] api: iso: fix and reformat descriptions Signed-off-by: Daan Hoogland --- .../api/command/user/iso/AttachIsoCmd.java | 10 +++++----- .../cloudstack/api/command/user/iso/CopyIsoCmd.java | 2 +- .../api/command/user/iso/DeleteIsoCmd.java | 4 ++-- .../api/command/user/iso/DetachIsoCmd.java | 6 +++--- .../api/command/user/iso/ExtractIsoCmd.java | 6 +++--- .../api/command/user/iso/ListIsoPermissionsCmd.java | 2 +- .../cloudstack/api/command/user/iso/ListIsosCmd.java | 4 ++-- .../api/command/user/iso/RegisterIsoCmd.java | 12 ++++++------ .../api/command/user/iso/UpdateIsoCmd.java | 2 +- .../command/user/iso/UpdateIsoPermissionsCmd.java | 2 +- 10 files changed, 25 insertions(+), 25 deletions(-) diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/AttachIsoCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/AttachIsoCmd.java index 1b8087b8c122..c1d67e5ae2f7 100644 --- a/api/src/org/apache/cloudstack/api/command/user/iso/AttachIsoCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/iso/AttachIsoCmd.java @@ -78,7 +78,7 @@ public String getCommandName() { public long getEntityOwnerId() { UserVm vm = _entityMgr.findById(UserVm.class, getVirtualMachineId()); if (vm == null) { - throw new InvalidParameterValueException("Unable to find virtual machine by id " + getVirtualMachineId()); + throw new InvalidParameterValueException("Unable to find virtual machine by ID " + getVirtualMachineId()); } return vm.getAccountId(); @@ -91,12 +91,12 @@ public String getEventType() { @Override public String getEventDescription() { - return "attaching ISO: " + getId() + " to vm: " + getVirtualMachineId(); + return "attaching ISO: " + getId() + " to VM: " + getVirtualMachineId(); } @Override public void execute() { - CallContext.current().setEventDetails("Vm Id: " + getVirtualMachineId() + " ISO Id: " + getId()); + CallContext.current().setEventDetails("Vm Id: " + getVirtualMachineId() + " ISO ID: " + getId()); boolean result = _templateService.attachIso(id, virtualMachineId); if (result) { UserVm userVm = _responseGenerator.findUserVmById(virtualMachineId); @@ -105,10 +105,10 @@ public void execute() { response.setResponseName(DeployVMCmd.getResultObjectName()); setResponseObject(response); } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to attach iso"); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to attach ISO"); } } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to attach iso"); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to attach ISO"); } } } diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/CopyIsoCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/CopyIsoCmd.java index 9002624c4872..b7c13ce4adb2 100644 --- a/api/src/org/apache/cloudstack/api/command/user/iso/CopyIsoCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/iso/CopyIsoCmd.java @@ -23,7 +23,7 @@ import org.apache.cloudstack.api.command.user.template.CopyTemplateCmd; import org.apache.cloudstack.api.response.TemplateResponse; -@APICommand(name = "copyIso", description = "Copies an iso from one zone to another.", responseObject = TemplateResponse.class, responseView = ResponseView.Restricted, +@APICommand(name = "copyIso", description = "Copies an ISO from one zone to another.", responseObject = TemplateResponse.class, responseView = ResponseView.Restricted, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CopyIsoCmd extends CopyTemplateCmd { public static final Logger s_logger = Logger.getLogger(CopyIsoCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/DeleteIsoCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/DeleteIsoCmd.java index 6101e9f9c063..103e9227c248 100644 --- a/api/src/org/apache/cloudstack/api/command/user/iso/DeleteIsoCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/iso/DeleteIsoCmd.java @@ -95,7 +95,7 @@ public String getEventType() { @Override public String getEventDescription() { - return "Deleting iso " + getId(); + return "Deleting ISO " + getId(); } @Override @@ -116,7 +116,7 @@ public void execute() { SuccessResponse response = new SuccessResponse(getCommandName()); this.setResponseObject(response); } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete iso"); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete ISO"); } } } diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/DetachIsoCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/DetachIsoCmd.java index 97db2f375984..9ee8ef59c478 100644 --- a/api/src/org/apache/cloudstack/api/command/user/iso/DetachIsoCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/iso/DetachIsoCmd.java @@ -70,7 +70,7 @@ public long getEntityOwnerId() { if (vm != null) { return vm.getAccountId(); } else { - throw new InvalidParameterValueException("Unable to find vm by id " + getVirtualMachineId()); + throw new InvalidParameterValueException("Unable to find VM by ID " + getVirtualMachineId()); } } @@ -81,7 +81,7 @@ public String getEventType() { @Override public String getEventDescription() { - return "detaching ISO from vm: " + getVirtualMachineId(); + return "detaching ISO from VM: " + getVirtualMachineId(); } @Override @@ -93,7 +93,7 @@ public void execute() { response.setResponseName(DeployVMCmd.getResultObjectName()); setResponseObject(response); } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to detach iso"); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to detach ISO"); } } } diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/ExtractIsoCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/ExtractIsoCmd.java index b78a3d3db66d..85f600859893 100644 --- a/api/src/org/apache/cloudstack/api/command/user/iso/ExtractIsoCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/iso/ExtractIsoCmd.java @@ -49,7 +49,7 @@ public class ExtractIsoCmd extends BaseAsyncCmd { @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = TemplateResponse.class, required = true, description = "the ID of the ISO file") private Long id; - @Parameter(name = ApiConstants.URL, type = CommandType.STRING, required = false, description = "the url to which the ISO would be extracted") + @Parameter(name = ApiConstants.URL, type = CommandType.STRING, required = false, description = "the URL to which the ISO would be extracted") private String url; @Parameter(name = ApiConstants.ZONE_ID, @@ -109,7 +109,7 @@ public long getEntityOwnerId() { @Override public String getEventDescription() { - return "extracting iso: " + getId() + " from zone: " + getZoneId(); + return "extracting ISO: " + getId() + " from zone: " + getZoneId(); } public static String getStaticName() { @@ -137,7 +137,7 @@ public void execute() { response.setObjectName("iso"); this.setResponseObject(response); } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to extract iso"); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to extract ISO"); } } catch (InternalErrorException ex) { s_logger.warn("Exception: ", ex); diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/ListIsoPermissionsCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/ListIsoPermissionsCmd.java index f8863d1f7534..9a3db4300bfd 100644 --- a/api/src/org/apache/cloudstack/api/command/user/iso/ListIsoPermissionsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/iso/ListIsoPermissionsCmd.java @@ -26,7 +26,7 @@ import com.cloud.storage.Storage.ImageFormat; import com.cloud.template.VirtualMachineTemplate; -@APICommand(name = "listIsoPermissions", description = "List iso visibility and all accounts that have permissions to view this iso.", responseObject = TemplatePermissionsResponse.class, responseView = ResponseView.Restricted, +@APICommand(name = "listIsoPermissions", description = "List ISO visibility and all accounts that have permissions to view this ISO.", responseObject = TemplatePermissionsResponse.class, responseView = ResponseView.Restricted, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListIsoPermissionsCmd extends BaseListTemplateOrIsoPermissionsCmd { diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java index 88e4326c7dcb..dee60f4f8d53 100644 --- a/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java @@ -49,7 +49,7 @@ public class ListIsosCmd extends BaseListTaggedResourcesCmd { @Parameter(name = ApiConstants.HYPERVISOR, type = CommandType.STRING, description = "the hypervisor for which to restrict the search") private String hypervisor; - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = TemplateResponse.class, description = "list ISO by id") + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = TemplateResponse.class, description = "list ISO by ID") private Long id; @Parameter(name = ApiConstants.IS_PUBLIC, type = CommandType.BOOLEAN, description = "true if the ISO is publicly available to all users, false otherwise.") @@ -69,7 +69,7 @@ public class ListIsosCmd extends BaseListTaggedResourcesCmd { + "* community : templates that have been marked as public but not featured. " + "* all : all templates (only usable by admins).") private String isoFilter = TemplateFilter.selfexecutable.toString(); - @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "list all isos by name") + @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "list all ISOs by name") private String isoName; @Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, description = "the ID of the zone") diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java index 453b4b603226..a1cb4780c733 100644 --- a/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java @@ -66,7 +66,7 @@ public class RegisterIsoCmd extends BaseCmd { description = "true if you want to register the ISO to be publicly available to all users, false otherwise.") private Boolean publicIso; - @Parameter(name = ApiConstants.IS_EXTRACTABLE, type = CommandType.BOOLEAN, description = "true if the iso or its derivatives are extractable; default is false") + @Parameter(name = ApiConstants.IS_EXTRACTABLE, type = CommandType.BOOLEAN, description = "true if the ISO or its derivatives are extractable; default is false") private Boolean extractable; @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "the name of the ISO") @@ -75,7 +75,7 @@ public class RegisterIsoCmd extends BaseCmd { @Parameter(name = ApiConstants.OS_TYPE_ID, type = CommandType.UUID, entityType = GuestOSResponse.class, - description = "the ID of the OS Type that best represents the OS of this ISO. If the iso is bootable this parameter needs to be passed") + description = "the ID of the OS type that best represents the OS of this ISO. If the ISO is bootable this parameter needs to be passed") private Long osTypeId; @Parameter(name = ApiConstants.URL, type = CommandType.STRING, required = true, description = "the URL to where the ISO is currently being hosted") @@ -97,15 +97,15 @@ public class RegisterIsoCmd extends BaseCmd { @Parameter(name = ApiConstants.CHECKSUM, type = CommandType.STRING, description = "the MD5 checksum value of this ISO") private String checksum; - @Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, entityType = ProjectResponse.class, description = "Register iso for the project") + @Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, entityType = ProjectResponse.class, description = "Register ISO for the project") private Long projectId; - @Parameter(name = ApiConstants.IMAGE_STORE_UUID, type = CommandType.STRING, description = "Image store uuid") + @Parameter(name = ApiConstants.IMAGE_STORE_UUID, type = CommandType.STRING, description = "Image store UUID") private String imageStoreUuid; @Parameter(name = ApiConstants.IS_DYNAMICALLY_SCALABLE, type = CommandType.BOOLEAN, - description = "true if iso contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory") + description = "true if ISO contains XS/VMWare tools inorder to support dynamic scaling of VM CPU/memory") protected Boolean isDynamicallyScalable; ///////////////////////////////////////////////////// @@ -197,7 +197,7 @@ public void execute() throws ResourceAllocationException { response.setResponseName(getCommandName()); setResponseObject(response); } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to register iso"); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to register ISO"); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/UpdateIsoCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/UpdateIsoCmd.java index 5e61160cd044..d072c0aec478 100644 --- a/api/src/org/apache/cloudstack/api/command/user/iso/UpdateIsoCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/iso/UpdateIsoCmd.java @@ -80,7 +80,7 @@ public void execute() { response.setResponseName(getCommandName()); setResponseObject(response); } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update iso"); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update ISO"); } } } diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/UpdateIsoPermissionsCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/UpdateIsoPermissionsCmd.java index b52bc91c7a5c..dd07faf9a873 100644 --- a/api/src/org/apache/cloudstack/api/command/user/iso/UpdateIsoPermissionsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/iso/UpdateIsoPermissionsCmd.java @@ -25,7 +25,7 @@ import com.cloud.template.VirtualMachineTemplate; import com.cloud.user.Account; -@APICommand(name = "updateIsoPermissions", description = "Updates iso permissions", responseObject = SuccessResponse.class, +@APICommand(name = "updateIsoPermissions", description = "Updates ISO permissions", responseObject = SuccessResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateIsoPermissionsCmd extends BaseUpdateTemplateOrIsoPermissionsCmd { @Override From c1fbb7821afb3e93cca8558f2d1d7590557b9ade Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Thu, 21 May 2015 10:14:33 +0200 Subject: [PATCH 095/175] api: loadbalancer: fix and reformat descriptions Signed-off-by: Daan Hoogland --- .../AssignCertToLoadBalancerCmd.java | 6 ++--- .../CreateApplicationLoadBalancerCmd.java | 18 +++++++------- .../CreateLBHealthCheckPolicyCmd.java | 12 +++++----- .../CreateLBStickinessPolicyCmd.java | 12 +++++----- .../CreateLoadBalancerRuleCmd.java | 24 +++++++++---------- .../DeleteApplicationLoadBalancerCmd.java | 2 +- .../DeleteLBHealthCheckPolicyCmd.java | 14 +++++------ .../DeleteLBStickinessPolicyCmd.java | 4 ++-- .../DeleteLoadBalancerRuleCmd.java | 2 +- .../user/loadbalancer/DeleteSslCertCmd.java | 2 +- .../ListApplicationLoadBalancersCmd.java | 16 ++++++------- .../ListLBHealthCheckPoliciesCmd.java | 6 ++--- .../ListLBStickinessPoliciesCmd.java | 8 +++---- .../ListLoadBalancerRuleInstancesCmd.java | 2 +- .../ListLoadBalancerRulesCmd.java | 4 ++-- .../user/loadbalancer/ListSslCertsCmd.java | 10 ++++---- .../RemoveCertFromLoadBalancerCmd.java | 4 ++-- .../UpdateApplicationLoadBalancerCmd.java | 8 +++---- .../UpdateLBHealthCheckPolicyCmd.java | 6 ++--- .../UpdateLBStickinessPolicyCmd.java | 4 ++-- .../UpdateLoadBalancerRuleCmd.java | 6 ++--- .../user/loadbalancer/UploadSslCertCmd.java | 10 ++++---- 22 files changed, 90 insertions(+), 90 deletions(-) diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/AssignCertToLoadBalancerCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/AssignCertToLoadBalancerCmd.java index ddafa72a6749..663815106e51 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/AssignCertToLoadBalancerCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/AssignCertToLoadBalancerCmd.java @@ -38,7 +38,7 @@ import com.cloud.network.rules.LoadBalancer; import com.cloud.user.Account; -@APICommand(name = "assignCertToLoadBalancer", description = "Assigns a certificate to a Load Balancer Rule", responseObject = SuccessResponse.class, +@APICommand(name = "assignCertToLoadBalancer", description = "Assigns a certificate to a load balancer rule", responseObject = SuccessResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class AssignCertToLoadBalancerCmd extends BaseAsyncCmd { @@ -68,7 +68,7 @@ public void execute() throws ResourceUnavailableException, InsufficientCapacityE SuccessResponse response = new SuccessResponse(getCommandName()); this.setResponseObject(response); } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to assign certificate to loadbalancer"); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to assign certificate to load balancer"); } } @@ -84,7 +84,7 @@ public String getCommandName() { @Override public String getEventDescription() { - return "Assigining a certificate to a loadbalancer"; + return "Assigning a certificate to a load balancer"; } @Override diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateApplicationLoadBalancerCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateApplicationLoadBalancerCmd.java index 2257180198de..4e31c6abf341 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateApplicationLoadBalancerCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateApplicationLoadBalancerCmd.java @@ -41,7 +41,7 @@ import com.cloud.network.rules.LoadBalancerContainer.Scheme; import com.cloud.utils.net.NetUtils; -@APICommand(name = "createLoadBalancer", description = "Creates a Load Balancer", responseObject = ApplicationLoadBalancerResponse.class, since = "4.2.0", +@APICommand(name = "createLoadBalancer", description = "Creates a load balancer", responseObject = ApplicationLoadBalancerResponse.class, since = "4.2.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateApplicationLoadBalancerCmd extends BaseAsyncCreateCmd { public static final Logger s_logger = Logger.getLogger(CreateApplicationLoadBalancerCmd.class.getName()); @@ -51,17 +51,17 @@ public class CreateApplicationLoadBalancerCmd extends BaseAsyncCreateCmd { ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "name of the Load Balancer") + @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "name of the load balancer") private String loadBalancerName; - @Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "the description of the Load Balancer", length = 4096) + @Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "the description of the load balancer", length = 4096) private String description; @Parameter(name = ApiConstants.NETWORK_ID, type = CommandType.UUID, required = true, entityType = NetworkResponse.class, - description = "The guest network the Load Balancer will be created for") + description = "The guest network the load balancer will be created for") private Long networkId; @Parameter(name = ApiConstants.SOURCE_PORT, @@ -79,7 +79,7 @@ public class CreateApplicationLoadBalancerCmd extends BaseAsyncCreateCmd { description = "the TCP port of the virtual machine where the network traffic will be load balanced to") private Integer instancePort; - @Parameter(name = ApiConstants.SOURCE_IP, type = CommandType.STRING, description = "the source ip address the network traffic will be load balanced from") + @Parameter(name = ApiConstants.SOURCE_IP, type = CommandType.STRING, description = "the source IP address the network traffic will be load balanced from") private String sourceIp; @Parameter(name = ApiConstants.SOURCE_IP_NETWORK_ID, @@ -141,7 +141,7 @@ public long getAccountId() { //get account info from the network object Network ntwk = _networkService.getNetwork(networkId); if (ntwk == null) { - throw new InvalidParameterValueException("Invalid network id specified"); + throw new InvalidParameterValueException("Invalid network ID specified"); } return ntwk.getAccountId(); @@ -180,7 +180,7 @@ public Scheme getScheme() { if (scheme.equalsIgnoreCase(Scheme.Internal.toString())) { return Scheme.Internal; } else { - throw new InvalidParameterValueException("Invalid value for scheme. Supported value is Internal"); + throw new InvalidParameterValueException("Invalid value for scheme. Supported value is internal"); } } @@ -208,10 +208,10 @@ public void execute() throws ResourceAllocationException, ResourceUnavailableExc setResponseObject(lbResponse); lbResponse.setResponseName(getCommandName()); } catch (Exception ex) { - s_logger.warn("Failed to create Load Balancer due to exception ", ex); + s_logger.warn("Failed to create load balancer due to exception ", ex); } finally { if (rule == null) { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create Load Balancer"); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create load balancer"); } } } diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLBHealthCheckPolicyCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLBHealthCheckPolicyCmd.java index f6eb48e800f8..94c5324c23e2 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLBHealthCheckPolicyCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLBHealthCheckPolicyCmd.java @@ -37,7 +37,7 @@ import com.cloud.user.Account; @APICommand(name = "createLBHealthCheckPolicy", - description = "Creates a Load Balancer healthcheck policy ", + description = "Creates a load balancer health check policy", responseObject = LBHealthCheckResponse.class, since = "4.2.0", requestHasSensitiveInfo = false, @@ -59,10 +59,10 @@ public class CreateLBHealthCheckPolicyCmd extends BaseAsyncCreateCmd { description = "the ID of the load balancer rule") private Long lbRuleId; - @Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "the description of the load balancer HealthCheck policy") + @Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "the description of the load balancer health check policy") private String description; - @Parameter(name = ApiConstants.HEALTHCHECK_PINGPATH, type = CommandType.STRING, required = false, description = "HTTP Ping Path") + @Parameter(name = ApiConstants.HEALTHCHECK_PINGPATH, type = CommandType.STRING, required = false, description = "HTTP ping path") private String pingPath; @Parameter(name = ApiConstants.HEALTHCHECK_RESPONSE_TIMEOUT, @@ -163,7 +163,7 @@ public void execute() throws ResourceAllocationException, ResourceUnavailableExc boolean success = false; try { - CallContext.current().setEventDetails("Load balancer healthcheck policy Id : " + getEntityId()); + CallContext.current().setEventDetails("Load balancer health check policy ID : " + getEntityId()); success = _lbService.applyLBHealthCheckPolicy(this); if (success) { // State might be different after the rule is applied, so get new object here @@ -175,7 +175,7 @@ public void execute() throws ResourceAllocationException, ResourceUnavailableExc } } finally { if (!success || (policy == null)) { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create healthcheck policy "); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create health check policy"); } } } @@ -199,6 +199,6 @@ public String getEventType() { @Override public String getEventDescription() { - return "Create Load Balancer HealthCheck policy"; + return "Create load balancer health check policy"; } } diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLBStickinessPolicyCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLBStickinessPolicyCmd.java index 152f6612f0cd..45e6f81a0aa3 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLBStickinessPolicyCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLBStickinessPolicyCmd.java @@ -40,7 +40,7 @@ import com.cloud.network.rules.StickinessPolicy; import com.cloud.user.Account; -@APICommand(name = "createLBStickinessPolicy", description = "Creates a Load Balancer stickiness policy ", responseObject = LBStickinessResponse.class, since = "3.0.0", +@APICommand(name = "createLBStickinessPolicy", description = "Creates a load balancer stickiness policy ", responseObject = LBStickinessResponse.class, since = "3.0.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) @SuppressWarnings("rawtypes") public class CreateLBStickinessPolicyCmd extends BaseAsyncCreateCmd { @@ -59,16 +59,16 @@ public class CreateLBStickinessPolicyCmd extends BaseAsyncCreateCmd { description = "the ID of the load balancer rule") private Long lbRuleId; - @Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "the description of the LB Stickiness policy") + @Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "the description of the load balancer stickiness policy") private String description; - @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "name of the LB Stickiness policy") + @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "name of the load balancer stickiness policy") private String lbStickinessPolicyName; @Parameter(name = ApiConstants.METHOD_NAME, type = CommandType.STRING, required = true, - description = "name of the LB Stickiness policy method, possible values can be obtained from ListNetworks API ") + description = "name of the load balancer stickiness policy method, possible values can be obtained from listNetworks API") private String stickinessMethodName; @Parameter(name = ApiConstants.PARAM_LIST, type = CommandType.MAP, description = "param list. Example: param[0].name=cookiename¶m[0].value=LBCookie ") @@ -152,7 +152,7 @@ public void execute() throws ResourceAllocationException, ResourceUnavailableExc } } finally { if (!success || (policy == null)) { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create stickiness policy "); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create stickiness policy"); } } } @@ -176,7 +176,7 @@ public String getEventType() { @Override public String getEventDescription() { - return "creating a Load Balancer Stickiness policy: " + getLBStickinessPolicyName(); + return "creating a load balancer stickiness policy: " + getLBStickinessPolicyName(); } @Override diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java index 132bf883532c..da0c1d32b469 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java @@ -72,13 +72,13 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements L @Parameter(name = ApiConstants.PRIVATE_PORT, type = CommandType.INTEGER, required = true, - description = "the private port of the private ip address/virtual machine where the network traffic will be load balanced to") + description = "the private port of the private IP address/virtual machine where the network traffic will be load balanced to") private Integer privatePort; @Parameter(name = ApiConstants.PUBLIC_IP_ID, type = CommandType.UUID, entityType = IPAddressResponse.class, - description = "public ip address id from where the network traffic will be load balanced from") + description = "public IP address ID from where the network traffic will be load balanced from") private Long publicIpId; @Parameter(name = ApiConstants.ZONE_ID, @@ -107,7 +107,7 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements L @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "the domain ID associated with the load balancer") private Long domainId; - @Parameter(name = ApiConstants.CIDR_LIST, type = CommandType.LIST, collectionType = CommandType.STRING, description = "the cidr list to forward traffic from") + @Parameter(name = ApiConstants.CIDR_LIST, type = CommandType.LIST, collectionType = CommandType.STRING, description = "the CIDR list to forward traffic from") private List cidrlist; @Parameter(name = ApiConstants.NETWORK_ID, type = CommandType.UUID, entityType = NetworkResponse.class, description = "The guest network this " @@ -153,7 +153,7 @@ public Long getSourceIpAddressId() { if (publicIpId != null) { IpAddress ipAddr = _networkService.getIp(publicIpId); if (ipAddr == null || !ipAddr.readyToUse()) { - throw new InvalidParameterValueException("Unable to create load balancer rule, invalid IP address id " + publicIpId); + throw new InvalidParameterValueException("Unable to create load balancer rule, invalid IP address ID " + publicIpId); } } else if (getEntityId() != null) { LoadBalancer rule = _entityMgr.findById(LoadBalancer.class, getEntityId()); @@ -167,7 +167,7 @@ private Long getVpcId() { if (publicIpId != null) { IpAddress ipAddr = _networkService.getIp(publicIpId); if (ipAddr == null || !ipAddr.readyToUse()) { - throw new InvalidParameterValueException("Unable to create load balancer rule, invalid IP address id " + publicIpId); + throw new InvalidParameterValueException("Unable to create load balancer rule, invalid IP address ID " + publicIpId); } else { return ipAddr.getVpcId(); } @@ -199,16 +199,16 @@ public long getNetworkId() { } if (networks.size() < 1) { - throw new InvalidParameterValueException("Account doesn't have any Isolated networks in the zone"); + throw new InvalidParameterValueException("Account doesn't have any isolated networks in the zone"); } else if (networks.size() > 1) { - throw new InvalidParameterValueException("Account has more than one Isolated network in the zone"); + throw new InvalidParameterValueException("Account has more than one isolated network in the zone"); } return networks.get(0).getId(); } else { Network defaultGuestNetwork = _networkService.getExclusiveGuestNetwork(zoneId); if (defaultGuestNetwork == null) { - throw new InvalidParameterValueException("Unable to find a default Guest network for account " + getAccountName() + " in domain id=" + getDomainId()); + throw new InvalidParameterValueException("Unable to find a default guest network for account " + getAccountName() + " in domain ID=" + getDomainId()); } else { return defaultGuestNetwork.getId(); } @@ -218,7 +218,7 @@ public long getNetworkId() { if (ipAddr.getAssociatedWithNetworkId() != null) { return ipAddr.getAssociatedWithNetworkId(); } else { - throw new InvalidParameterValueException("Ip address id=" + publicIpId + " is not associated with any network"); + throw new InvalidParameterValueException("IP address ID=" + publicIpId + " is not associated with any network"); } } } @@ -249,7 +249,7 @@ public Boolean getOpenFirewall() { public List getSourceCidrList() { if (cidrlist != null) { throw new InvalidParameterValueException( - "Parameter cidrList is deprecated; if you need to open firewall rule for the specific cidr, please refer to createFirewallRule command"); + "Parameter cidrList is deprecated; if you need to open firewall rule for the specific CIDR, please refer to createFirewallRule command"); } return null; } @@ -309,7 +309,7 @@ public void create() { //cidr list parameter is deprecated if (cidrlist != null) { throw new InvalidParameterValueException( - "Parameter cidrList is deprecated; if you need to open firewall rule for the specific cidr, please refer to createFirewallRule command"); + "Parameter cidrList is deprecated; if you need to open firewall rule for the specific CIDR, please refer to createFirewallRule command"); } try { LoadBalancer result = @@ -350,7 +350,7 @@ public long getAccountId() { if (account != null) { return account.getId(); } else { - throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain id=" + domainId); + throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain ID=" + domainId); } } else { throw new InvalidParameterValueException("Can't define IP owner. Either specify account/domainId or publicIpId"); diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteApplicationLoadBalancerCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteApplicationLoadBalancerCmd.java index 8f4ecca58f8a..a723279890a1 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteApplicationLoadBalancerCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteApplicationLoadBalancerCmd.java @@ -84,7 +84,7 @@ public String getEventDescription() { @Override public void execute() { - CallContext.current().setEventDetails("Load balancer Id: " + getId()); + CallContext.current().setEventDetails("Load balancer ID: " + getId()); boolean result = _appLbService.deleteApplicationLoadBalancer(getId()); if (result) { diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLBHealthCheckPolicyCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLBHealthCheckPolicyCmd.java index 3f27477903c8..74df888b8101 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLBHealthCheckPolicyCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLBHealthCheckPolicyCmd.java @@ -34,7 +34,7 @@ import com.cloud.network.rules.LoadBalancer; import com.cloud.user.Account; -@APICommand(name = "deleteLBHealthCheckPolicy", description = "Deletes a load balancer HealthCheck policy.", responseObject = SuccessResponse.class, since = "4.2.0", +@APICommand(name = "deleteLBHealthCheckPolicy", description = "Deletes a load balancer health check policy.", responseObject = SuccessResponse.class, since = "4.2.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteLBHealthCheckPolicyCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteLBHealthCheckPolicyCmd.class.getName()); @@ -47,7 +47,7 @@ public class DeleteLBHealthCheckPolicyCmd extends BaseAsyncCmd { type = CommandType.UUID, entityType = LBHealthCheckResponse.class, required = true, - description = "the ID of the load balancer HealthCheck policy") + description = "the ID of the load balancer health check policy") private Long id; // /////////////////////////////////////////////////// @@ -84,19 +84,19 @@ public String getEventType() { @Override public String getEventDescription() { - return "deleting load balancer HealthCheck policy: " + getId(); + return "deleting load balancer health check policy: " + getId(); } @Override public void execute() { - CallContext.current().setEventDetails("Load balancer healthcheck policy Id: " + getId()); + CallContext.current().setEventDetails("Load balancer health check policy Id: " + getId()); boolean result = _lbService.deleteLBHealthCheckPolicy(getId(), true); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); this.setResponseObject(response); } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete load balancer healthcheck policy"); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete load balancer health check policy"); } } @@ -109,11 +109,11 @@ public String getSyncObjType() { public Long getSyncObjId() { HealthCheckPolicy policy = _entityMgr.findById(HealthCheckPolicy.class, getId()); if (policy == null) { - throw new InvalidParameterValueException("Unable to find load balancer healthcheck rule: " + id); + throw new InvalidParameterValueException("Unable to find load balancer health check rule: " + id); } LoadBalancer lb = _lbService.findById(policy.getLoadBalancerId()); if (lb == null) { - throw new InvalidParameterValueException("Unable to find load balancer rule for healthcheck rule: " + id); + throw new InvalidParameterValueException("Unable to find load balancer rule for health check rule: " + id); } return lb.getNetworkId(); } diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLBStickinessPolicyCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLBStickinessPolicyCmd.java index ffed94bff129..10c342911b44 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLBStickinessPolicyCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLBStickinessPolicyCmd.java @@ -34,7 +34,7 @@ import com.cloud.network.rules.StickinessPolicy; import com.cloud.user.Account; -@APICommand(name = "deleteLBStickinessPolicy", description = "Deletes a LB stickiness policy.", responseObject = SuccessResponse.class, since = "3.0.0", +@APICommand(name = "deleteLBStickinessPolicy", description = "Deletes a load balancer stickiness policy.", responseObject = SuccessResponse.class, since = "3.0.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteLBStickinessPolicyCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteLBStickinessPolicyCmd.class.getName()); @@ -89,7 +89,7 @@ public String getEventDescription() { @Override public void execute() { - CallContext.current().setEventDetails("Load balancer stickiness policy Id: " + getId()); + CallContext.current().setEventDetails("Load balancer stickiness policy ID: " + getId()); boolean result = _lbService.deleteLBStickinessPolicy(getId(), true); if (result) { diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLoadBalancerRuleCmd.java index 3423cab05188..112f6cf7fc8b 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLoadBalancerRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLoadBalancerRuleCmd.java @@ -89,7 +89,7 @@ public String getEventDescription() { @Override public void execute() { - CallContext.current().setEventDetails("Load balancer Id: " + getId()); + CallContext.current().setEventDetails("Load balancer ID: " + getId()); boolean result = _firewallService.revokeRelatedFirewallRule(id, true); result = result && _lbService.deleteLoadBalancerRule(id, true); diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteSslCertCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteSslCertCmd.java index fab11250687f..2efd036cc97f 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteSslCertCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteSslCertCmd.java @@ -37,7 +37,7 @@ import com.cloud.network.lb.CertService; import com.cloud.utils.exception.CloudRuntimeException; -@APICommand(name = "deleteSslCert", description = "Delete a certificate to cloudstack", responseObject = SuccessResponse.class, +@APICommand(name = "deleteSslCert", description = "Delete a certificate to CloudStack", responseObject = SuccessResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteSslCertCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(DeleteSslCertCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListApplicationLoadBalancersCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListApplicationLoadBalancersCmd.java index 299d7308bb48..79322c2a6ecc 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListApplicationLoadBalancersCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListApplicationLoadBalancersCmd.java @@ -35,7 +35,7 @@ import com.cloud.network.rules.LoadBalancerContainer.Scheme; import com.cloud.utils.Pair; -@APICommand(name = "listLoadBalancers", description = "Lists Load Balancers", responseObject = ApplicationLoadBalancerResponse.class, since = "4.2.0", +@APICommand(name = "listLoadBalancers", description = "Lists load balancers", responseObject = ApplicationLoadBalancerResponse.class, since = "4.2.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListApplicationLoadBalancersCmd extends BaseListTaggedResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListApplicationLoadBalancersCmd.class.getName()); @@ -46,25 +46,25 @@ public class ListApplicationLoadBalancersCmd extends BaseListTaggedResourcesCmd // ////////////// API parameters ///////////////////// // /////////////////////////////////////////////////// - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = FirewallRuleResponse.class, description = "the ID of the Load Balancer") + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = FirewallRuleResponse.class, description = "the ID of the load balancer") private Long id; - @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "the name of the Load Balancer") + @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "the name of the load balancer") private String loadBalancerName; - @Parameter(name = ApiConstants.SOURCE_IP, type = CommandType.STRING, description = "the source ip address of the Load Balancer") + @Parameter(name = ApiConstants.SOURCE_IP, type = CommandType.STRING, description = "the source IP address of the load balancer") private String sourceIp; @Parameter(name = ApiConstants.SOURCE_IP_NETWORK_ID, type = CommandType.UUID, entityType = NetworkResponse.class, - description = "the network id of the source ip address") + description = "the network ID of the source IP address") private Long sourceIpNetworkId; - @Parameter(name = ApiConstants.SCHEME, type = CommandType.STRING, description = "the scheme of the Load Balancer. Supported value is Internal in the current release") + @Parameter(name = ApiConstants.SCHEME, type = CommandType.STRING, description = "the scheme of the load balancer. Supported value is internal in the current release") private String scheme; - @Parameter(name = ApiConstants.NETWORK_ID, type = CommandType.UUID, entityType = NetworkResponse.class, description = "the network id of the Load Balancer") + @Parameter(name = ApiConstants.NETWORK_ID, type = CommandType.UUID, entityType = NetworkResponse.class, description = "the network ID of the load balancer") private Long networkId; @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "list resources by display flag; only ROOT admin is eligible to pass this parameter", since = "4.4", authorized = {RoleType.Admin}) @@ -112,7 +112,7 @@ public Scheme getScheme() { if (scheme.equalsIgnoreCase(Scheme.Internal.toString())) { return Scheme.Internal; } else { - throw new InvalidParameterValueException("Invalid value for scheme. Supported value is Internal"); + throw new InvalidParameterValueException("Invalid value for scheme. Supported value is internal"); } } return null; diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLBHealthCheckPoliciesCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLBHealthCheckPoliciesCmd.java index 3f2082af5cad..ad0486f31cc5 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLBHealthCheckPoliciesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLBHealthCheckPoliciesCmd.java @@ -34,7 +34,7 @@ import com.cloud.network.rules.HealthCheckPolicy; import com.cloud.network.rules.LoadBalancer; -@APICommand(name = "listLBHealthCheckPolicies", description = "Lists load balancer HealthCheck policies.", responseObject = LBHealthCheckResponse.class, since = "4.2.0", +@APICommand(name = "listLBHealthCheckPolicies", description = "Lists load balancer health check policies.", responseObject = LBHealthCheckResponse.class, since = "4.2.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListLBHealthCheckPoliciesCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListLBHealthCheckPoliciesCmd.class.getName()); @@ -53,7 +53,7 @@ public class ListLBHealthCheckPoliciesCmd extends BaseListCmd { @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "list resources by display flag; only ROOT admin is eligible to pass this parameter", since = "4.4", authorized = {RoleType.Admin}) private Boolean display; - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = LBHealthCheckResponse.class, description = "the ID of the healthcheck policy", since = "4.4") + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = LBHealthCheckResponse.class, description = "the ID of the health check policy", since = "4.4") private Long id; // /////////////////////////////////////////////////// @@ -93,7 +93,7 @@ public void execute() { if(hId != null) { lbRuleId = _lbService.findLBIdByHealtCheckPolicyId(hId); } else { - throw new InvalidParameterValueException("Either LB Ruleid or HealthCheckpolicy Id should be specified"); + throw new InvalidParameterValueException("Either load balancer rule ID or health check policy ID should be specified"); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLBStickinessPoliciesCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLBStickinessPoliciesCmd.java index 64776213019c..4e11430d0b41 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLBStickinessPoliciesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLBStickinessPoliciesCmd.java @@ -35,7 +35,7 @@ import com.cloud.network.rules.StickinessPolicy; import com.cloud.user.Account; -@APICommand(name = "listLBStickinessPolicies", description = "Lists LBStickiness policies.", responseObject = LBStickinessResponse.class, since = "3.0.0", +@APICommand(name = "listLBStickinessPolicies", description = "Lists load balancer stickiness policies.", responseObject = LBStickinessResponse.class, since = "3.0.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListLBStickinessPoliciesCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListLBStickinessPoliciesCmd.class.getName()); @@ -93,17 +93,17 @@ public void execute() { LoadBalancer lb = null; if (lbRuleId == null && id == null) { - throw new InvalidParameterValueException("LB rule id and stickiness policy id can't be null"); + throw new InvalidParameterValueException("load balancer rule ID and stickiness policy ID can't be null"); } if (id != null) { lb = _lbService.findLbByStickinessId(id); if (lb == null) { - throw new InvalidParameterValueException("stickiness policy id doesn't exist"); + throw new InvalidParameterValueException("stickiness policy ID doesn't exist"); } if ((lbRuleId != null) && (lbRuleId != lb.getId())) { - throw new InvalidParameterValueException("stickiness policy id doesn't belong to lbId" + lbRuleId); + throw new InvalidParameterValueException("stickiness policy ID doesn't belong to lbId" + lbRuleId); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLoadBalancerRuleInstancesCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLoadBalancerRuleInstancesCmd.java index 8827557518ac..e3cde0ba640f 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLoadBalancerRuleInstancesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLoadBalancerRuleInstancesCmd.java @@ -62,7 +62,7 @@ public class ListLoadBalancerRuleInstancesCmd extends BaseListCmd { @Parameter(name = ApiConstants.LIST_LB_VMIPS, type = CommandType.BOOLEAN, - description = "true if lb rule vm ip information to be included; default is false") + description = "true if load balancer rule VM IP information to be included; default is false") private boolean isListLbVmip; diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLoadBalancerRulesCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLoadBalancerRulesCmd.java index 71d82327a131..d1fa8da48f40 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLoadBalancerRulesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLoadBalancerRulesCmd.java @@ -56,7 +56,7 @@ public class ListLoadBalancerRulesCmd extends BaseListTaggedResourcesCmd { @Parameter(name = ApiConstants.PUBLIC_IP_ID, type = CommandType.UUID, entityType = IPAddressResponse.class, - description = "the public IP address id of the load balancer rule ") + description = "the public IP address ID of the load balancer rule") private Long publicIpId; @Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, @@ -68,7 +68,7 @@ public class ListLoadBalancerRulesCmd extends BaseListTaggedResourcesCmd { @Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, description = "the availability zone ID") private Long zoneId; - @Parameter(name = ApiConstants.NETWORK_ID, type = CommandType.UUID, entityType = NetworkResponse.class, description = "list by network id the rule belongs to") + @Parameter(name = ApiConstants.NETWORK_ID, type = CommandType.UUID, entityType = NetworkResponse.class, description = "list by network ID the rule belongs to") private Long networkId; @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "list resources by display flag; only ROOT admin is eligible to pass this parameter", since = "4.4", authorized = {RoleType.Admin}) diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListSslCertsCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListSslCertsCmd.java index 470968faae10..d1dbdcb28236 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListSslCertsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListSslCertsCmd.java @@ -50,16 +50,16 @@ public class ListSslCertsCmd extends BaseCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @Parameter(name = ApiConstants.CERTIFICATE_ID, type = CommandType.UUID, entityType = SslCertResponse.class, required = false, description = "Id of SSL certificate") + @Parameter(name = ApiConstants.CERTIFICATE_ID, type = CommandType.UUID, entityType = SslCertResponse.class, required = false, description = "ID of SSL certificate") private Long certId; - @Parameter(name = ApiConstants.ACCOUNT_ID, type = CommandType.UUID, entityType = AccountResponse.class, required = false, description = "Account Id") + @Parameter(name = ApiConstants.ACCOUNT_ID, type = CommandType.UUID, entityType = AccountResponse.class, required = false, description = "Account ID") private Long accountId; - @Parameter(name = ApiConstants.LBID, type = CommandType.UUID, entityType = FirewallRuleResponse.class, required = false, description = "Loadbalancer Rule Id") + @Parameter(name = ApiConstants.LBID, type = CommandType.UUID, entityType = FirewallRuleResponse.class, required = false, description = "Load balancer rule ID") private Long lbId; - @Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, entityType = ProjectResponse.class, required = false, description = "project who owns the ssl cert") + @Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, entityType = ProjectResponse.class, required = false, description = "Project that owns the SSL certificate") private Long projectId; ///////////////////////////////////////////////////// @@ -111,4 +111,4 @@ public String getCommandName() { public long getEntityOwnerId() { return CallContext.current().getCallingAccount().getId(); } -} \ No newline at end of file +} diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/RemoveCertFromLoadBalancerCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/RemoveCertFromLoadBalancerCmd.java index 14da0893d193..d794384b4fa1 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/RemoveCertFromLoadBalancerCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/RemoveCertFromLoadBalancerCmd.java @@ -36,7 +36,7 @@ import com.cloud.network.rules.LoadBalancer; import com.cloud.user.Account; -@APICommand(name = "removeCertFromLoadBalancer", description = "Removes a certificate from a Load Balancer Rule", responseObject = SuccessResponse.class, +@APICommand(name = "removeCertFromLoadBalancer", description = "Removes a certificate from a load balancer rule", responseObject = SuccessResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class RemoveCertFromLoadBalancerCmd extends BaseAsyncCmd { @@ -75,7 +75,7 @@ public String getCommandName() { @Override public String getEventDescription() { - return "Removing a certificate from a loadbalancer with ID " + getLbRuleId(); + return "Removing a certificate from a load balancer with ID " + getLbRuleId(); } @Override diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/UpdateApplicationLoadBalancerCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/UpdateApplicationLoadBalancerCmd.java index fbda84ddce91..3dd156417737 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/UpdateApplicationLoadBalancerCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/UpdateApplicationLoadBalancerCmd.java @@ -31,7 +31,7 @@ import com.cloud.exception.InvalidParameterValueException; import com.cloud.network.rules.FirewallRule; -@APICommand(name = "updateLoadBalancer", description = "Updates a Load Balancer", responseObject = ApplicationLoadBalancerResponse.class, since = "4.4.0", +@APICommand(name = "updateLoadBalancer", description = "Updates a load balancer", responseObject = ApplicationLoadBalancerResponse.class, since = "4.4.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateApplicationLoadBalancerCmd extends BaseAsyncCustomIdCmd { public static final Logger s_logger = Logger.getLogger(UpdateApplicationLoadBalancerCmd.class.getName()); @@ -41,7 +41,7 @@ public class UpdateApplicationLoadBalancerCmd extends BaseAsyncCustomIdCmd { ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = FirewallRuleResponse.class, required = true, description = "the ID of the Load Balancer") + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = FirewallRuleResponse.class, required = true, description = "the ID of the load balancer") private Long id; @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the rule to the end user or not", since = "4.4", authorized = {RoleType.Admin}) @@ -69,7 +69,7 @@ public long getEntityOwnerId() { if (lb != null) { return lb.getAccountId(); } else { - throw new InvalidParameterValueException("Can't find load balancer by id specified"); + throw new InvalidParameterValueException("Can't find load balancer by ID specified"); } } @@ -89,7 +89,7 @@ public String getEventDescription() { ///////////////////////////////////////////////////// @Override public void execute() { - CallContext.current().setEventDetails("Load balancer Id: " + getId()); + CallContext.current().setEventDetails("Load balancer ID: " + getId()); ApplicationLoadBalancerRule rule = _appLbService.updateApplicationLoadBalancer(getId(), this.getCustomId(), getDisplay()); ApplicationLoadBalancerResponse lbResponse = _responseGenerator.createLoadBalancerContainerReponse(rule, _lbService.getLbInstances(getId())); setResponseObject(lbResponse); diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/UpdateLBHealthCheckPolicyCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/UpdateLBHealthCheckPolicyCmd.java index 0b0c34fff9e4..06d9263c9547 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/UpdateLBHealthCheckPolicyCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/UpdateLBHealthCheckPolicyCmd.java @@ -27,7 +27,7 @@ import com.cloud.network.rules.StickinessPolicy; import com.cloud.user.Account; -@APICommand(name = "updateLBHealthCheckPolicy", description = "Updates LB HealthCheck policy", responseObject = LBHealthCheckResponse.class, since = "4.4", +@APICommand(name = "updateLBHealthCheckPolicy", description = "Updates load balancer health check policy", responseObject = LBHealthCheckResponse.class, since = "4.4", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateLBHealthCheckPolicyCmd extends BaseAsyncCustomIdCmd{ public static final Logger s_logger = Logger.getLogger(UpdateLBHealthCheckPolicyCmd.class.getName()); @@ -37,7 +37,7 @@ public class UpdateLBHealthCheckPolicyCmd extends BaseAsyncCustomIdCmd{ ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = LBHealthCheckResponse.class, required = true, description = "id of lb healthcheck policy") + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = LBHealthCheckResponse.class, required = true, description = "ID of load balancer health check policy") private Long id; @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the policy to the end user or not", since = "4.4", authorized = {RoleType.Admin}) @@ -71,7 +71,7 @@ public long getEntityOwnerId() { @Override public String getEventDescription() { - return "Update LB healthcheck policy id= " + id; + return "Update load balancer health check policy ID= " + id; } @Override diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/UpdateLBStickinessPolicyCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/UpdateLBStickinessPolicyCmd.java index c6529454771e..55b3d578c67f 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/UpdateLBStickinessPolicyCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/UpdateLBStickinessPolicyCmd.java @@ -26,7 +26,7 @@ import com.cloud.network.rules.StickinessPolicy; import com.cloud.user.Account; -@APICommand(name = "updateLBStickinessPolicy", description = "Updates LB Stickiness policy", responseObject = LBStickinessResponse.class, since = "4.4", +@APICommand(name = "updateLBStickinessPolicy", description = "Updates load balancer stickiness policy", responseObject = LBStickinessResponse.class, since = "4.4", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateLBStickinessPolicyCmd extends BaseAsyncCustomIdCmd{ public static final Logger s_logger = Logger.getLogger(UpdateLBStickinessPolicyCmd.class.getName()); @@ -70,7 +70,7 @@ public long getEntityOwnerId() { @Override public String getEventDescription() { - return "Update LB stickiness policy id= " + id; + return "Update load balancer stickiness policy ID= " + id; } @Override diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/UpdateLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/UpdateLoadBalancerRuleCmd.java index 03dd62179ea2..6b1e0fddd54a 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/UpdateLoadBalancerRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/UpdateLoadBalancerRuleCmd.java @@ -55,7 +55,7 @@ public class UpdateLoadBalancerRuleCmd extends BaseAsyncCustomIdCmd { type = CommandType.UUID, entityType = FirewallRuleResponse.class, required = true, - description = "the id of the load balancer rule to update") + description = "the ID of the load balancer rule to update") private Long id; @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "the name of the load balancer rule") @@ -118,7 +118,7 @@ public String getEventDescription() { @Override public void execute() { - CallContext.current().setEventDetails("Load balancer Id: " + getId()); + CallContext.current().setEventDetails("Load balancer ID: " + getId()); LoadBalancer result = _lbService.updateLoadBalancerRule(this); if (result != null) { LoadBalancerResponse response = _responseGenerator.createLoadBalancerResponse(result); @@ -138,7 +138,7 @@ public String getSyncObjType() { public Long getSyncObjId() { LoadBalancer lb = _lbService.findById(getId()); if (lb == null) { - throw new InvalidParameterValueException("Unable to find load balancer rule " + getId()); + throw new InvalidParameterValueException("Unable to find load balancer rule by ID " + getId()); } return lb.getNetworkId(); } diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/UploadSslCertCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/UploadSslCertCmd.java index cd5bb27c346c..4bd2de9017f4 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/UploadSslCertCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/UploadSslCertCmd.java @@ -38,7 +38,7 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.lb.CertService; -@APICommand(name = "uploadSslCert", description = "Upload a certificate to cloudstack", responseObject = SslCertResponse.class, +@APICommand(name = "uploadSslCert", description = "Upload a certificate to CloudStack", responseObject = SslCertResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UploadSslCertCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(UploadSslCertCmd.class.getName()); @@ -64,13 +64,13 @@ public class UploadSslCertCmd extends BaseCmd { @Parameter(name = ApiConstants.PASSWORD, type = CommandType.STRING, description = "Password for the private key") private String password; - @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "account who will own the ssl cert") + @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "account that will own the SSL certificate") private String accountName; - @Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, entityType = ProjectResponse.class, description = "an optional project for the ssl cert") + @Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, entityType = ProjectResponse.class, description = "an optional project for the SSL certificate") private Long projectId; - @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "domain ID of the account owning the ssl cert") + @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "domain ID of the account owning the SSL certificate") private Long domainId; ///////////////////////////////////////////////////// @@ -133,4 +133,4 @@ public long getEntityOwnerId() { return CallContext.current().getCallingAccount().getId(); } -} \ No newline at end of file +} From 84266b1c727056246b26721cc9be90b9c0a07320 Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Thu, 21 May 2015 10:43:14 +0200 Subject: [PATCH 096/175] api: network: fix and reformat descriptions Signed-off-by: Daan Hoogland This closes #275 --- .../user/nat/CreateIpForwardingRuleCmd.java | 22 +++++++-------- .../user/nat/DeleteIpForwardingRuleCmd.java | 12 ++++---- .../command/user/nat/DisableStaticNatCmd.java | 10 +++---- .../command/user/nat/EnableStaticNatCmd.java | 18 ++++++------ .../user/nat/ListIpForwardingRulesCmd.java | 6 ++-- .../user/network/CreateNetworkACLCmd.java | 16 +++++------ .../user/network/CreateNetworkACLListCmd.java | 10 +++---- .../user/network/CreateNetworkCmd.java | 28 +++++++++---------- .../user/network/DeleteNetworkACLCmd.java | 8 +++--- .../user/network/DeleteNetworkACLListCmd.java | 6 ++-- .../user/network/DeleteNetworkCmd.java | 2 +- .../user/network/ListNetworkACLListsCmd.java | 4 +-- .../user/network/ListNetworkACLsCmd.java | 10 +++---- .../user/network/ListNetworkOfferingsCmd.java | 10 +++---- .../command/user/network/ListNetworksCmd.java | 14 +++++----- .../network/ReplaceNetworkACLListCmd.java | 10 +++---- .../user/network/RestartNetworkCmd.java | 8 +++--- .../user/network/UpdateNetworkACLItemCmd.java | 12 ++++---- .../user/network/UpdateNetworkACLListCmd.java | 4 +-- .../user/network/UpdateNetworkCmd.java | 14 +++++----- 20 files changed, 112 insertions(+), 112 deletions(-) diff --git a/api/src/org/apache/cloudstack/api/command/user/nat/CreateIpForwardingRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/nat/CreateIpForwardingRuleCmd.java index 8925d066fe97..94db9156fd55 100644 --- a/api/src/org/apache/cloudstack/api/command/user/nat/CreateIpForwardingRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/nat/CreateIpForwardingRuleCmd.java @@ -42,7 +42,7 @@ import com.cloud.network.rules.StaticNatRule; import com.cloud.user.Account; -@APICommand(name = "createIpForwardingRule", description = "Creates an ip forwarding rule", responseObject = FirewallRuleResponse.class, +@APICommand(name = "createIpForwardingRule", description = "Creates an IP forwarding rule", responseObject = FirewallRuleResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements StaticNatRule { public static final Logger s_logger = Logger.getLogger(CreateIpForwardingRuleCmd.class.getName()); @@ -57,7 +57,7 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta type = CommandType.UUID, entityType = IPAddressResponse.class, required = true, - description = "the public IP address id of the forwarding rule, already associated via associateIp") + description = "the public IP address ID of the forwarding rule, already associated via associateIp") private Long ipAddressId; @Parameter(name = ApiConstants.START_PORT, type = CommandType.INTEGER, required = true, description = "the start port for the rule") @@ -71,10 +71,10 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta @Parameter(name = ApiConstants.OPEN_FIREWALL, type = CommandType.BOOLEAN, - description = "if true, firewall rule for source/end pubic port is automatically created; if false - firewall rule has to be created explicitely. Has value true by default") + description = "if true, firewall rule for source/end pubic port is automatically created; if false - firewall rule has to be created explicitly. Has value true by default") private Boolean openFirewall; - @Parameter(name = ApiConstants.CIDR_LIST, type = CommandType.LIST, collectionType = CommandType.STRING, description = "the cidr list to forward traffic from") + @Parameter(name = ApiConstants.CIDR_LIST, type = CommandType.LIST, collectionType = CommandType.STRING, description = "the CIDR list to forward traffic from") private List cidrlist; ///////////////////////////////////////////////////// @@ -116,7 +116,7 @@ public void execute() throws ResourceUnavailableException { boolean result = true; FirewallRule rule = null; try { - CallContext.current().setEventDetails("Rule Id: " + getEntityId()); + CallContext.current().setEventDetails("Rule ID: " + getEntityId()); if (getOpenFirewall()) { result = result && _firewallService.applyIngressFirewallRules(ipAddressId, CallContext.current().getCallingAccount()); @@ -137,7 +137,7 @@ public void execute() throws ResourceUnavailableException { _rulesService.revokeStaticNatRule(getEntityId(), true); - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Error in creating ip forwarding rule on the domr"); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Error in creating IP forwarding rule on the domr"); } } } @@ -148,7 +148,7 @@ public void create() { //cidr list parameter is deprecated if (cidrlist != null) { throw new InvalidParameterValueException( - "Parameter cidrList is deprecated; if you need to open firewall rule for the specific cidr, please refer to createFirewallRule command"); + "Parameter cidrList is deprecated; if you need to open firewall rule for the specific CIDR, please refer to createFirewallRule command"); } try { @@ -156,7 +156,7 @@ public void create() { setEntityId(rule.getId()); setEntityUuid(rule.getUuid()); } catch (NetworkRuleConflictException e) { - s_logger.info("Unable to create Static Nat Rule due to ", e); + s_logger.info("Unable to create static NAT rule due to ", e); throw new ServerApiException(ApiErrorCode.NETWORK_RULE_CONFLICT_ERROR, e.getMessage()); } } @@ -180,14 +180,14 @@ public String getEventType() { @Override public String getEventDescription() { IpAddress ip = _networkService.getIp(ipAddressId); - return ("Applying an ipforwarding 1:1 NAT rule for Ip: " + ip.getAddress() + " with virtual machine:" + getVirtualMachineId()); + return ("Applying an ipforwarding 1:1 NAT rule for IP: " + ip.getAddress() + " with virtual machine:" + getVirtualMachineId()); } private long getVirtualMachineId() { Long vmId = _networkService.getIp(ipAddressId).getAssociatedWithVmId(); if (vmId == null) { - throw new InvalidParameterValueException("Ip address is not associated with any network, unable to create static nat rule"); + throw new InvalidParameterValueException("IP address is not associated with any network, unable to create static NAT rule"); } return vmId; } @@ -278,7 +278,7 @@ public Long getSyncObjId() { private IpAddress getIp() { IpAddress ip = _networkService.getIp(ipAddressId); if (ip == null) { - throw new InvalidParameterValueException("Unable to find ip address by id " + ipAddressId); + throw new InvalidParameterValueException("Unable to find IP address by ID " + ipAddressId); } return ip; } diff --git a/api/src/org/apache/cloudstack/api/command/user/nat/DeleteIpForwardingRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/nat/DeleteIpForwardingRuleCmd.java index 52a5ba777e0b..9059d5073198 100644 --- a/api/src/org/apache/cloudstack/api/command/user/nat/DeleteIpForwardingRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/nat/DeleteIpForwardingRuleCmd.java @@ -34,7 +34,7 @@ import com.cloud.exception.InvalidParameterValueException; import com.cloud.network.rules.FirewallRule; -@APICommand(name = "deleteIpForwardingRule", description = "Deletes an ip forwarding rule", responseObject = SuccessResponse.class, +@APICommand(name = "deleteIpForwardingRule", description = "Deletes an IP forwarding rule", responseObject = SuccessResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteIpForwardingRuleCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteIpForwardingRuleCmd.class.getName()); @@ -45,7 +45,7 @@ public class DeleteIpForwardingRuleCmd extends BaseAsyncCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = FirewallRuleResponse.class, required = true, description = "the id of the forwarding rule") + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = FirewallRuleResponse.class, required = true, description = "the ID of the forwarding rule") private Long id; // unexposed parameter needed for events logging @@ -71,7 +71,7 @@ public String getCommandName() { @Override public void execute() { - CallContext.current().setEventDetails("Rule Id: " + id); + CallContext.current().setEventDetails("Rule ID: " + id); boolean result = _firewallService.revokeRelatedFirewallRule(id, true); result = result && _rulesService.revokeStaticNatRule(id, true); @@ -79,7 +79,7 @@ public void execute() { SuccessResponse response = new SuccessResponse(getCommandName()); setResponseObject(response); } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete ip forwarding rule"); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete IP forwarding rule"); } } @@ -88,7 +88,7 @@ public long getEntityOwnerId() { if (ownerId == null) { FirewallRule rule = _entityMgr.findById(FirewallRule.class, id); if (rule == null) { - throw new InvalidParameterValueException("Unable to find static nat rule by id: " + id); + throw new InvalidParameterValueException("Unable to find static NAT rule by ID: " + id); } else { ownerId = rule.getAccountId(); } @@ -103,7 +103,7 @@ public String getEventType() { @Override public String getEventDescription() { - return ("Deleting an ipforwarding 1:1 NAT rule id:" + id); + return ("Deleting an IP forwarding 1:1 NAT rule ID:" + id); } @Override diff --git a/api/src/org/apache/cloudstack/api/command/user/nat/DisableStaticNatCmd.java b/api/src/org/apache/cloudstack/api/command/user/nat/DisableStaticNatCmd.java index 1df77ec0fda3..6c59e70443d7 100644 --- a/api/src/org/apache/cloudstack/api/command/user/nat/DisableStaticNatCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/nat/DisableStaticNatCmd.java @@ -35,7 +35,7 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.IpAddress; -@APICommand(name = "disableStaticNat", description = "Disables static rule for given ip address", responseObject = SuccessResponse.class, +@APICommand(name = "disableStaticNat", description = "Disables static rule for given IP address", responseObject = SuccessResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DisableStaticNatCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeletePortForwardingRuleCmd.class.getName()); @@ -49,7 +49,7 @@ public class DisableStaticNatCmd extends BaseAsyncCmd { type = CommandType.UUID, entityType = IPAddressResponse.class, required = true, - description = "the public IP address id for which static nat feature is being disableed") + description = "the public IP address ID for which static NAT feature is being disabled") private Long ipAddressId; ///////////////////////////////////////////////////// @@ -75,7 +75,7 @@ public String getEventType() { @Override public String getEventDescription() { - return ("Disabling static nat for ip id=" + ipAddressId); + return ("Disabling static NAT for IP ID=" + ipAddressId); } @Override @@ -91,7 +91,7 @@ public void execute() throws ResourceUnavailableException, NetworkRuleConflictEx SuccessResponse response = new SuccessResponse(getCommandName()); this.setResponseObject(response); } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to disable static nat"); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to disable static NAT"); } } @@ -108,7 +108,7 @@ public Long getSyncObjId() { private IpAddress getIp() { IpAddress ip = _networkService.getIp(ipAddressId); if (ip == null) { - throw new InvalidParameterValueException("Unable to find ip address by id " + ipAddressId); + throw new InvalidParameterValueException("Unable to find IP address by ID " + ipAddressId); } return ip; } diff --git a/api/src/org/apache/cloudstack/api/command/user/nat/EnableStaticNatCmd.java b/api/src/org/apache/cloudstack/api/command/user/nat/EnableStaticNatCmd.java index aa4e28768a60..cddd23d5223f 100644 --- a/api/src/org/apache/cloudstack/api/command/user/nat/EnableStaticNatCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/nat/EnableStaticNatCmd.java @@ -36,7 +36,7 @@ import com.cloud.user.Account; import com.cloud.uservm.UserVm; -@APICommand(name = "enableStaticNat", description = "Enables static nat for given ip address", responseObject = SuccessResponse.class, +@APICommand(name = "enableStaticNat", description = "Enables static NAT for given IP address", responseObject = SuccessResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class EnableStaticNatCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(CreateIpForwardingRuleCmd.class.getName()); @@ -48,23 +48,23 @@ public class EnableStaticNatCmd extends BaseCmd { ///////////////////////////////////////////////////// @Parameter(name = ApiConstants.IP_ADDRESS_ID, type = CommandType.UUID, entityType = IPAddressResponse.class, required = true, description = "the public IP " - + "address id for which static nat feature is being enabled") + + "address ID for which static NAT feature is being enabled") private Long ipAddressId; @Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, type = CommandType.UUID, entityType = UserVmResponse.class, required = true, description = "the ID of " - + "the virtual machine for enabling static nat feature") + + "the virtual machine for enabling static NAT feature") private Long virtualMachineId; @Parameter(name = ApiConstants.NETWORK_ID, type = CommandType.UUID, entityType = NetworkResponse.class, - description = "The network of the vm the static nat will be enabled for." - + " Required when public Ip address is not associated with any Guest network yet (VPC case)") + description = "The network of the VM the static NAT will be enabled for." + + " Required when public IP address is not associated with any guest network yet (VPC case)") private Long networkId; @Parameter(name = ApiConstants.VM_GUEST_IP, type = CommandType.STRING, required = false, - description = "VM guest nic Secondary ip address for the port forwarding rule") + description = "VM guest NIC secondary IP address for the port forwarding rule") private String vmSecondaryIp; ///////////////////////////////////////////////////// @@ -102,8 +102,8 @@ public long getNetworkId() { } if (ntwkId == null) { - throw new InvalidParameterValueException("Unable to enable static nat for the ipAddress id=" + ipAddressId + - " as ip is not associated with any network and no networkId is passed in"); + throw new InvalidParameterValueException("Unable to enable static NAT for the ipAddress id=" + ipAddressId + + " as IP is not associated with any network and no networkId is passed in"); } return ntwkId; } @@ -135,7 +135,7 @@ public void execute() throws ResourceUnavailableException { SuccessResponse response = new SuccessResponse(getCommandName()); this.setResponseObject(response); } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to enable static nat"); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to enable static NAT"); } } catch (NetworkRuleConflictException ex) { s_logger.info("Network rule conflict: " + ex.getMessage()); diff --git a/api/src/org/apache/cloudstack/api/command/user/nat/ListIpForwardingRulesCmd.java b/api/src/org/apache/cloudstack/api/command/user/nat/ListIpForwardingRulesCmd.java index ecb0c44c700f..bc157fc9e1f3 100644 --- a/api/src/org/apache/cloudstack/api/command/user/nat/ListIpForwardingRulesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/nat/ListIpForwardingRulesCmd.java @@ -35,7 +35,7 @@ import com.cloud.network.rules.StaticNatRule; import com.cloud.utils.Pair; -@APICommand(name = "listIpForwardingRules", description = "List the ip forwarding rules", responseObject = FirewallRuleResponse.class, +@APICommand(name = "listIpForwardingRules", description = "List the IP forwarding rules", responseObject = FirewallRuleResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListIpForwardingRulesCmd extends BaseListProjectAndAccountResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListIpForwardingRulesCmd.class.getName()); @@ -49,7 +49,7 @@ public class ListIpForwardingRulesCmd extends BaseListProjectAndAccountResources @Parameter(name = ApiConstants.IP_ADDRESS_ID, type = CommandType.UUID, entityType = IPAddressResponse.class, - description = "list the rule belonging to this public ip address") + description = "list the rule belonging to this public IP address") private Long publicIpAddressId; @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = FirewallRuleResponse.class, description = "Lists rule with the specified ID.") @@ -58,7 +58,7 @@ public class ListIpForwardingRulesCmd extends BaseListProjectAndAccountResources @Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, type = CommandType.UUID, entityType = UserVmResponse.class, - description = "Lists all rules applied to the specified Vm.") + description = "Lists all rules applied to the specified VM.") private Long vmId; ///////////////////////////////////////////////////// diff --git a/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLCmd.java index b4d54896d9b9..c8a8f8cae394 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLCmd.java @@ -66,32 +66,32 @@ public class CreateNetworkACLCmd extends BaseAsyncCreateCmd { @Parameter(name = ApiConstants.END_PORT, type = CommandType.INTEGER, description = "the ending port of ACL") private Integer publicEndPort; - @Parameter(name = ApiConstants.CIDR_LIST, type = CommandType.LIST, collectionType = CommandType.STRING, description = "the cidr list to allow traffic from/to") + @Parameter(name = ApiConstants.CIDR_LIST, type = CommandType.LIST, collectionType = CommandType.STRING, description = "the CIDR list to allow traffic from/to") private List cidrlist; - @Parameter(name = ApiConstants.ICMP_TYPE, type = CommandType.INTEGER, description = "type of the icmp message being sent") + @Parameter(name = ApiConstants.ICMP_TYPE, type = CommandType.INTEGER, description = "type of the ICMP message being sent") private Integer icmpType; - @Parameter(name = ApiConstants.ICMP_CODE, type = CommandType.INTEGER, description = "error code for this icmp message") + @Parameter(name = ApiConstants.ICMP_CODE, type = CommandType.INTEGER, description = "error code for this ICMP message") private Integer icmpCode; @Parameter(name = ApiConstants.NETWORK_ID, type = CommandType.UUID, entityType = NetworkResponse.class, - description = "The network of the vm the ACL will be created for") + description = "The network of the VM the ACL will be created for") private Long networkId; @Parameter(name = ApiConstants.ACL_ID, type = CommandType.UUID, entityType = NetworkACLResponse.class, - description = "The network of the vm the ACL will be created for") + description = "The network of the VM the ACL will be created for") private Long aclId; @Parameter(name = ApiConstants.TRAFFIC_TYPE, type = CommandType.STRING, description = "the traffic type for the ACL," - + "can be Ingress or Egress, defaulted to Ingress if not specified") + + "can be ingress or egress, defaulted to ingress if not specified") private String trafficType; - @Parameter(name = ApiConstants.NUMBER, type = CommandType.INTEGER, description = "The network of the vm the ACL will be created for") + @Parameter(name = ApiConstants.NUMBER, type = CommandType.INTEGER, description = "The network of the VM the ACL will be created for") private Integer number; @Parameter(name = ApiConstants.ACTION, type = CommandType.STRING, description = "scl entry action, allow or deny") @@ -239,7 +239,7 @@ public void execute() throws ResourceUnavailableException { boolean success = false; NetworkACLItem rule = _networkACLService.getNetworkACLItem(getEntityId()); try { - CallContext.current().setEventDetails("Rule Id: " + getEntityId()); + CallContext.current().setEventDetails("Rule ID: " + getEntityId()); success = _networkACLService.applyNetworkACL(rule.getAclId()); // State is different after the rule is applied, so get new object here diff --git a/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLListCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLListCmd.java index 9aa0bab5ae9e..530dc4e7030a 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLListCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLListCmd.java @@ -34,7 +34,7 @@ import com.cloud.network.vpc.Vpc; import com.cloud.user.Account; -@APICommand(name = "createNetworkACLList", description = "Creates a Network ACL for the given VPC", responseObject = NetworkACLResponse.class, +@APICommand(name = "createNetworkACLList", description = "Creates a network ACL for the given VPC", responseObject = NetworkACLResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateNetworkACLListCmd extends BaseAsyncCreateCmd { public static final Logger s_logger = Logger.getLogger(CreateNetworkACLListCmd.class.getName()); @@ -45,17 +45,17 @@ public class CreateNetworkACLListCmd extends BaseAsyncCreateCmd { // ////////////// API parameters ///////////////////// // /////////////////////////////////////////////////// - @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "Name of the network ACL List") + @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "Name of the network ACL list") private String name; - @Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "Description of the network ACL List") + @Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "Description of the network ACL list") private String description; @Parameter(name = ApiConstants.VPC_ID, type = CommandType.UUID, required = true, entityType = VpcResponse.class, - description = "Id of the VPC associated with this network ACL List") + description = "ID of the VPC associated with this network ACL list") private Long vpcId; @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the list to the end user or not", since = "4.4", authorized = {RoleType.Admin}) @@ -132,6 +132,6 @@ public String getEventType() { @Override public String getEventDescription() { - return "Creating Network ACL with id: " + getEntityUuid(); + return "Creating Network ACL with ID: " + getEntityUuid(); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java index e030163b6a0b..173126148082 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java @@ -66,24 +66,24 @@ public class CreateNetworkCmd extends BaseCmd { type = CommandType.UUID, entityType = NetworkOfferingResponse.class, required = true, - description = "the network offering id") + description = "the network offering ID") private Long networkOfferingId; - @Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, required = true, description = "the Zone ID for the network") + @Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, required = true, description = "the zone ID for the network") private Long zoneId; @Parameter(name = ApiConstants.PHYSICAL_NETWORK_ID, type = CommandType.UUID, entityType = PhysicalNetworkResponse.class, - description = "the Physical Network ID the network belongs to") + description = "the physical network ID the network belongs to") private Long physicalNetworkId; @Parameter(name = ApiConstants.GATEWAY, type = CommandType.STRING, description = "the gateway of the network. Required " - + "for Shared networks and Isolated networks when it belongs to VPC") + + "for shared networks and isolated networks when it belongs to VPC") private String gateway; @Parameter(name = ApiConstants.NETMASK, type = CommandType.STRING, description = "the netmask of the network. Required " - + "for Shared networks and Isolated networks when it belongs to VPC") + + "for shared networks and isolated networks when it belongs to VPC") private String netmask; @Parameter(name = ApiConstants.START_IP, type = CommandType.STRING, description = "the beginning IP address in the network IP range") @@ -93,21 +93,21 @@ public class CreateNetworkCmd extends BaseCmd { + " range. If not specified, will be defaulted to startIP") private String endIp; - @Parameter(name = ApiConstants.ISOLATED_PVLAN, type = CommandType.STRING, description = "the isolated private vlan for this network") + @Parameter(name = ApiConstants.ISOLATED_PVLAN, type = CommandType.STRING, description = "the isolated private VLAN for this network") private String isolatedPvlan; @Parameter(name = ApiConstants.NETWORK_DOMAIN, type = CommandType.STRING, description = "network domain") private String networkDomain; @Parameter(name = ApiConstants.ACL_TYPE, type = CommandType.STRING, description = "Access control type; supported values" - + " are account and domain. In 3.0 all shared networks should have aclType=Domain, and all Isolated networks" - + " - Account. Account means that only the account owner can use the network, domain - all accouns in the domain can use the network") + + " are account and domain. In 3.0 all shared networks should have aclType=Domain, and all isolated networks" + + " - Account. Account means that only the account owner can use the network, domain - all accounts in the domain can use the network") private String aclType; - @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "account who will own the network") + @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "account that will own the network") private String accountName; - @Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, entityType = ProjectResponse.class, description = "an optional project for the ssh key") + @Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, entityType = ProjectResponse.class, description = "an optional project for the SSH key") private Long projectId; @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "domain ID of the account owning a network") @@ -139,7 +139,7 @@ public class CreateNetworkCmd extends BaseCmd { description = "an optional field, whether to the display the network to the end user or not.", authorized = {RoleType.Admin}) private Boolean displayNetwork; - @Parameter(name = ApiConstants.ACL_ID, type = CommandType.UUID, entityType = NetworkACLResponse.class, description = "Network ACL Id associated for the network") + @Parameter(name = ApiConstants.ACL_ID, type = CommandType.UUID, entityType = NetworkACLResponse.class, description = "Network ACL ID associated for the network") private Long aclId; ///////////////////////////////////////////////////// @@ -221,7 +221,7 @@ public Long getZoneId() { Long physicalNetworkId = getPhysicalNetworkId(); if (physicalNetworkId == null && zoneId == null) { - throw new InvalidParameterValueException("Zone id is required"); + throw new InvalidParameterValueException("Zone ID is required"); } return zoneId; @@ -230,14 +230,14 @@ public Long getZoneId() { public Long getPhysicalNetworkId() { NetworkOffering offering = _entityMgr.findById(NetworkOffering.class, networkOfferingId); if (offering == null) { - throw new InvalidParameterValueException("Unable to find network offering by id " + networkOfferingId); + throw new InvalidParameterValueException("Unable to find network offering by ID " + networkOfferingId); } if (physicalNetworkId != null) { if (offering.getGuestType() == GuestType.Shared) { return physicalNetworkId; } else { - throw new InvalidParameterValueException("Physical network id can be specified for networks of guest ip type " + GuestType.Shared + " only."); + throw new InvalidParameterValueException("Physical network OD can be specified for networks of guest IP type " + GuestType.Shared + " only."); } } else { if (zoneId == null) { diff --git a/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLCmd.java index ecc651dbfa8e..ab6df801fe94 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLCmd.java @@ -32,7 +32,7 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.user.Account; -@APICommand(name = "deleteNetworkACL", description = "Deletes a Network ACL", responseObject = SuccessResponse.class, +@APICommand(name = "deleteNetworkACL", description = "Deletes a network ACL", responseObject = SuccessResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteNetworkACLCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteNetworkACLCmd.class.getName()); @@ -68,7 +68,7 @@ public String getEventType() { @Override public String getEventDescription() { - return ("Deleting Network ACL id=" + id); + return ("Deleting Network ACL ID=" + id); } @Override @@ -79,14 +79,14 @@ public long getEntityOwnerId() { @Override public void execute() throws ResourceUnavailableException { - CallContext.current().setEventDetails("Network ACL Item Id: " + id); + CallContext.current().setEventDetails("Network ACL item ID: " + id); boolean result = _networkACLService.revokeNetworkACLItem(id); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); setResponseObject(response); } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete network ACL Item"); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete network ACL item"); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLListCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLListCmd.java index 3b3a4ec4ae4c..19cf601d63aa 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLListCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLListCmd.java @@ -32,7 +32,7 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.user.Account; -@APICommand(name = "deleteNetworkACLList", description = "Deletes a Network ACL", responseObject = SuccessResponse.class, +@APICommand(name = "deleteNetworkACLList", description = "Deletes a network ACL", responseObject = SuccessResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteNetworkACLListCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteNetworkACLListCmd.class.getName()); @@ -68,7 +68,7 @@ public String getEventType() { @Override public String getEventDescription() { - return ("Deleting Network ACL id=" + id); + return ("Deleting network ACL ID=" + id); } @Override @@ -79,7 +79,7 @@ public long getEntityOwnerId() { @Override public void execute() throws ResourceUnavailableException { - CallContext.current().setEventDetails("Network ACL Id: " + id); + CallContext.current().setEventDetails("Network ACL ID: " + id); boolean result = _networkACLService.deleteNetworkACL(id); if (result) { diff --git a/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkCmd.java index 4c3a292c4a9f..2811434f8056 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkCmd.java @@ -109,7 +109,7 @@ public String getEventDescription() { public long getEntityOwnerId() { Network network = _networkService.getNetwork(id); if (network == null) { - throw new InvalidParameterValueException("Networkd id=" + id + " doesn't exist"); + throw new InvalidParameterValueException("Network ID=" + id + " doesn't exist"); } else { return _networkService.getNetwork(id).getAccountId(); } diff --git a/api/src/org/apache/cloudstack/api/command/user/network/ListNetworkACLListsCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/ListNetworkACLListsCmd.java index c115fb761652..80d616ab6fce 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/ListNetworkACLListsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/ListNetworkACLListsCmd.java @@ -46,10 +46,10 @@ public class ListNetworkACLListsCmd extends BaseListProjectAndAccountResourcesCm @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = NetworkACLResponse.class, description = "Lists network ACL with the specified ID.") private Long id; - @Parameter(name = ApiConstants.NETWORK_ID, type = CommandType.UUID, entityType = NetworkResponse.class, description = "list network ACLs by network Id") + @Parameter(name = ApiConstants.NETWORK_ID, type = CommandType.UUID, entityType = NetworkResponse.class, description = "list network ACLs by network ID") private Long networkId; - @Parameter(name = ApiConstants.VPC_ID, type = CommandType.UUID, entityType = VpcResponse.class, description = "list network ACLs by Vpc Id") + @Parameter(name = ApiConstants.VPC_ID, type = CommandType.UUID, entityType = VpcResponse.class, description = "list network ACLs by VPC ID") private Long vpcId; @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "list network ACLs by specified name") diff --git a/api/src/org/apache/cloudstack/api/command/user/network/ListNetworkACLsCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/ListNetworkACLsCmd.java index 4f9065bf2cd6..4815bf400e45 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/ListNetworkACLsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/ListNetworkACLsCmd.java @@ -47,19 +47,19 @@ public class ListNetworkACLsCmd extends BaseListTaggedResourcesCmd { description = "Lists network ACL Item with the specified ID") private Long id; - @Parameter(name = ApiConstants.NETWORK_ID, type = CommandType.UUID, entityType = NetworkResponse.class, description = "list network ACL Items by network Id") + @Parameter(name = ApiConstants.NETWORK_ID, type = CommandType.UUID, entityType = NetworkResponse.class, description = "list network ACL items by network ID") private Long networkId; - @Parameter(name = ApiConstants.TRAFFIC_TYPE, type = CommandType.STRING, description = "list network ACL Items by traffic type - Ingress or Egress") + @Parameter(name = ApiConstants.TRAFFIC_TYPE, type = CommandType.STRING, description = "list network ACL items by traffic type - ingress or egress") private String trafficType; - @Parameter(name = ApiConstants.ACL_ID, type = CommandType.UUID, entityType = NetworkACLResponse.class, description = "list network ACL Items by ACL Id") + @Parameter(name = ApiConstants.ACL_ID, type = CommandType.UUID, entityType = NetworkACLResponse.class, description = "list network ACL items by ACL ID") private Long aclId; - @Parameter(name = ApiConstants.PROTOCOL, type = CommandType.STRING, description = "list network ACL Items by Protocol") + @Parameter(name = ApiConstants.PROTOCOL, type = CommandType.STRING, description = "list network ACL items by protocol") private String protocol; - @Parameter(name = ApiConstants.ACTION, type = CommandType.STRING, description = "list network ACL Items by Action") + @Parameter(name = ApiConstants.ACTION, type = CommandType.STRING, description = "list network ACL items by action") private String action; @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "list resources by display flag; only ROOT admin is eligible to pass this parameter", since = "4.4", authorized = {RoleType.Admin}) diff --git a/api/src/org/apache/cloudstack/api/command/user/network/ListNetworkOfferingsCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/ListNetworkOfferingsCmd.java index 27b3e8915b81..0c57bf96c8fe 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/ListNetworkOfferingsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/ListNetworkOfferingsCmd.java @@ -41,7 +41,7 @@ public class ListNetworkOfferingsCmd extends BaseListCmd { ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = NetworkOfferingResponse.class, description = "list network offerings by id") + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = NetworkOfferingResponse.class, description = "list network offerings by ID") private Long id; @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "list network offerings by name") @@ -59,13 +59,13 @@ public class ListNetworkOfferingsCmd extends BaseListCmd { @Parameter(name = ApiConstants.SPECIFY_VLAN, type = CommandType.BOOLEAN, description = "the tags for the network offering.") private Boolean specifyVlan; - @Parameter(name = ApiConstants.AVAILABILITY, type = CommandType.STRING, description = "the availability of network offering. Default value is Required") + @Parameter(name = ApiConstants.AVAILABILITY, type = CommandType.STRING, description = "the availability of network offering. Default value is required") private String availability; @Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, - description = "list netowrk offerings available for network creation in specific zone") + description = "list network offerings available for network creation in specific zone") private Long zoneId; @Parameter(name = ApiConstants.STATE, type = CommandType.STRING, description = "list network offerings by state") @@ -77,7 +77,7 @@ public class ListNetworkOfferingsCmd extends BaseListCmd { description = "the ID of the network. Pass this in if you want to see the available network offering that a network can be changed to.") private Long networkId; - @Parameter(name = ApiConstants.GUEST_IP_TYPE, type = CommandType.STRING, description = "list network offerings by guest type: Shared or Isolated") + @Parameter(name = ApiConstants.GUEST_IP_TYPE, type = CommandType.STRING, description = "list network offerings by guest type: shared or isolated") private String guestIpType; @Parameter(name = ApiConstants.SUPPORTED_SERVICES, @@ -88,7 +88,7 @@ public class ListNetworkOfferingsCmd extends BaseListCmd { @Parameter(name = ApiConstants.SOURCE_NAT_SUPPORTED, type = CommandType.BOOLEAN, - description = "true if need to list only netwok offerings where source nat is supported, false otherwise") + description = "true if need to list only netwok offerings where source NAT is supported, false otherwise") private Boolean sourceNatSupported; @Parameter(name = ApiConstants.SPECIFY_IP_RANGES, diff --git a/api/src/org/apache/cloudstack/api/command/user/network/ListNetworksCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/ListNetworksCmd.java index 86f3ba2ad6be..041d64170445 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/ListNetworksCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/ListNetworksCmd.java @@ -45,19 +45,19 @@ public class ListNetworksCmd extends BaseListTaggedResourcesCmd { ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = NetworkResponse.class, description = "list networks by id") + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = NetworkResponse.class, description = "list networks by ID") private Long id; - @Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, description = "the Zone ID of the network") + @Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, description = "the zone ID of the network") private Long zoneId; - @Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, description = "the type of the network. Supported values are: Isolated and Shared") + @Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, description = "the type of the network. Supported values are: isolated and shared") private String guestIpType; @Parameter(name = ApiConstants.IS_SYSTEM, type = CommandType.BOOLEAN, description = "true if network is system, false otherwise") private Boolean isSystem; - @Parameter(name = ApiConstants.ACL_TYPE, type = CommandType.STRING, description = "list networks by ACL (access control list) type. Supported values are Account and Domain") + @Parameter(name = ApiConstants.ACL_TYPE, type = CommandType.STRING, description = "list networks by ACL (access control list) type. Supported values are account and domain") private String aclType; @Parameter(name = ApiConstants.TRAFFIC_TYPE, type = CommandType.STRING, description = "type of the traffic") @@ -72,16 +72,16 @@ public class ListNetworksCmd extends BaseListTaggedResourcesCmd { @Parameter(name = ApiConstants.RESTART_REQUIRED, type = CommandType.BOOLEAN, description = "list networks by restartRequired") private Boolean restartRequired; - @Parameter(name = ApiConstants.SPECIFY_IP_RANGES, type = CommandType.BOOLEAN, description = "true if need to list only networks which support specifying ip ranges") + @Parameter(name = ApiConstants.SPECIFY_IP_RANGES, type = CommandType.BOOLEAN, description = "true if need to list only networks which support specifying IP ranges") private Boolean specifyIpRanges; @Parameter(name = ApiConstants.VPC_ID, type = CommandType.UUID, entityType = VpcResponse.class, description = "List networks by VPC") private Long vpcId; - @Parameter(name = ApiConstants.CAN_USE_FOR_DEPLOY, type = CommandType.BOOLEAN, description = "list networks available for vm deployment") + @Parameter(name = ApiConstants.CAN_USE_FOR_DEPLOY, type = CommandType.BOOLEAN, description = "list networks available for VM deployment") private Boolean canUseForDeploy; - @Parameter(name = ApiConstants.FOR_VPC, type = CommandType.BOOLEAN, description = "the network belongs to vpc") + @Parameter(name = ApiConstants.FOR_VPC, type = CommandType.BOOLEAN, description = "the network belongs to VPC") private Boolean forVpc; @Parameter(name = ApiConstants.DISPLAY_NETWORK, type = CommandType.BOOLEAN, description = "list resources by display flag; only ROOT admin is eligible to pass this parameter", since = "4.4", authorized = {RoleType.Admin}) diff --git a/api/src/org/apache/cloudstack/api/command/user/network/ReplaceNetworkACLListCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/ReplaceNetworkACLListCmd.java index d005718428e6..fc08753a679c 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/ReplaceNetworkACLListCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/ReplaceNetworkACLListCmd.java @@ -34,7 +34,7 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.user.Account; -@APICommand(name = "replaceNetworkACLList", description = "Replaces ACL associated with a Network or private gateway", responseObject = SuccessResponse.class, +@APICommand(name = "replaceNetworkACLList", description = "Replaces ACL associated with a network or private gateway", responseObject = SuccessResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ReplaceNetworkACLListCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(ReplaceNetworkACLListCmd.class.getName()); @@ -84,7 +84,7 @@ public String getEventType() { @Override public String getEventDescription() { - return ("Associating Network ACL id=" + aclId + " with Network id=" + networkId); + return ("Associating network ACL ID=" + aclId + " with network ID=" + networkId); } @Override @@ -96,14 +96,14 @@ public long getEntityOwnerId() { @Override public void execute() throws ResourceUnavailableException { if (getNetworkId() == null && getPrivateGatewayId() == null) { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Network id and private gateway can't be null at the same time"); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Network ID and private gateway can't be null at the same time"); } if (getNetworkId() != null && getPrivateGatewayId() != null) { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Network id and private gateway can't be passed at the same time"); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Network ID and private gateway can't be passed at the same time"); } - CallContext.current().setEventDetails("Network ACL Id: " + aclId); + CallContext.current().setEventDetails("Network ACL ID: " + aclId); boolean result = false; if (getPrivateGatewayId() != null) { result = _networkACLService.replaceNetworkACLonPrivateGw(aclId, privateGatewayId); diff --git a/api/src/org/apache/cloudstack/api/command/user/network/RestartNetworkCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/RestartNetworkCmd.java index eba831042182..62566653bca7 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/RestartNetworkCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/RestartNetworkCmd.java @@ -39,7 +39,7 @@ import com.cloud.network.Network; @APICommand(name = "restartNetwork", - description = "Restarts the network; includes 1) restarting network elements - virtual routers, dhcp servers 2) reapplying all public ips 3) reapplying loadBalancing/portForwarding rules", + description = "Restarts the network; includes 1) restarting network elements - virtual routers, DHCP servers 2) reapplying all public IPs 3) reapplying loadBalancing/portForwarding rules", responseObject = IPAddressResponse.class, entityType = {Network.class}, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) @@ -51,7 +51,7 @@ public class RestartNetworkCmd extends BaseAsyncCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// @ACL(accessType = AccessType.OperateEntry) - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = NetworkResponse.class, required = true, description = "The id of the network to restart.") + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = NetworkResponse.class, required = true, description = "The ID of the network to restart.") private Long id; @Parameter(name = ApiConstants.CLEANUP, type = CommandType.BOOLEAN, required = false, description = "If cleanup old network elements") @@ -64,7 +64,7 @@ public class RestartNetworkCmd extends BaseAsyncCmd { public Long getNetworkId() { Network network = _networkService.getNetwork(id); if (network == null) { - throw new InvalidParameterValueException("Unable to find network by id " + id); + throw new InvalidParameterValueException("Unable to find network by ID " + id); } else { return network.getId(); } @@ -125,7 +125,7 @@ public String getEventType() { public long getEntityOwnerId() { Network network = _networkService.getNetwork(id); if (network == null) { - throw new InvalidParameterValueException("Networkd id=" + id + " doesn't exist"); + throw new InvalidParameterValueException("Networkd ID=" + id + " doesn't exist"); } else { return _networkService.getNetwork(id).getAccountId(); } diff --git a/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLItemCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLItemCmd.java index 59ae05df4000..acc2ae864200 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLItemCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLItemCmd.java @@ -34,7 +34,7 @@ import com.cloud.network.vpc.NetworkACLItem; import com.cloud.user.Account; -@APICommand(name = "updateNetworkACLItem", description = "Updates ACL Item with specified Id", responseObject = NetworkACLItemResponse.class, +@APICommand(name = "updateNetworkACLItem", description = "Updates ACL item with specified ID", responseObject = NetworkACLItemResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateNetworkACLItemCmd extends BaseAsyncCustomIdCmd { public static final Logger s_logger = Logger.getLogger(UpdateNetworkACLItemCmd.class.getName()); @@ -49,7 +49,7 @@ public class UpdateNetworkACLItemCmd extends BaseAsyncCustomIdCmd { type = CommandType.UUID, entityType = NetworkACLItemResponse.class, required = true, - description = "the ID of the network ACL Item") + description = "the ID of the network ACL item") private Long id; @Parameter(name = ApiConstants.PROTOCOL, @@ -66,10 +66,10 @@ public class UpdateNetworkACLItemCmd extends BaseAsyncCustomIdCmd { @Parameter(name = ApiConstants.CIDR_LIST, type = CommandType.LIST, collectionType = CommandType.STRING, description = "the cidr list to allow traffic from/to") private List cidrlist; - @Parameter(name = ApiConstants.ICMP_TYPE, type = CommandType.INTEGER, description = "type of the icmp message being sent") + @Parameter(name = ApiConstants.ICMP_TYPE, type = CommandType.INTEGER, description = "type of the ICMP message being sent") private Integer icmpType; - @Parameter(name = ApiConstants.ICMP_CODE, type = CommandType.INTEGER, description = "error code for this icmp message") + @Parameter(name = ApiConstants.ICMP_CODE, type = CommandType.INTEGER, description = "error code for this ICMP message") private Integer icmpCode; @Parameter(name = ApiConstants.TRAFFIC_TYPE, type = CommandType.STRING, description = "the traffic type for the ACL," @@ -162,7 +162,7 @@ public String getEventType() { @Override public String getEventDescription() { - return "Updating Network ACL Item"; + return "Updating network ACL item"; } public Integer getIcmpCode() { @@ -180,7 +180,7 @@ public void execute() throws ResourceUnavailableException { _networkACLService.updateNetworkACLItem(getId(), getProtocol(), getSourceCidrList(), getTrafficType(), getAction(), getNumber(), getSourcePortStart(), getSourcePortEnd(), getIcmpCode(), getIcmpType(), this.getCustomId(), this.isDisplay()); if (aclItem == null) { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update network ACL Item"); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update network ACL item"); } NetworkACLItemResponse aclResponse = _responseGenerator.createNetworkACLItemResponse(aclItem); setResponseObject(aclResponse); diff --git a/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLListCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLListCmd.java index c58f96583642..aa1f557e72b4 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLListCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLListCmd.java @@ -31,7 +31,7 @@ import com.cloud.network.vpc.NetworkACL; import com.cloud.user.Account; -@APICommand(name = "updateNetworkACLList", description = "Updates Network ACL list", responseObject = SuccessResponse.class, since = "4.4", +@APICommand(name = "updateNetworkACLList", description = "Updates network ACL list", responseObject = SuccessResponse.class, since = "4.4", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateNetworkACLListCmd extends BaseAsyncCustomIdCmd { public static final Logger s_logger = Logger.getLogger(UpdateNetworkACLListCmd.class.getName()); @@ -74,7 +74,7 @@ public String getEventType() { @Override public String getEventDescription() { - return ("Updating network acl list id=" + id); + return ("Updating network ACL list ID=" + id); } @Override diff --git a/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java index 0f73ddef93af..921e74b67b2c 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java @@ -66,13 +66,13 @@ public class UpdateNetworkCmd extends BaseAsyncCustomIdCmd { @Parameter(name = ApiConstants.NETWORK_DOMAIN, type = CommandType.STRING, description = "network domain") private String networkDomain; - @Parameter(name = ApiConstants.CHANGE_CIDR, type = CommandType.BOOLEAN, description = "Force update even if cidr type is different") + @Parameter(name = ApiConstants.CHANGE_CIDR, type = CommandType.BOOLEAN, description = "Force update even if CIDR type is different") private Boolean changeCidr; @Parameter(name = ApiConstants.NETWORK_OFFERING_ID, type = CommandType.UUID, entityType = NetworkOfferingResponse.class, description = "network offering ID") private Long networkOfferingId; - @Parameter(name = ApiConstants.GUEST_VM_CIDR, type = CommandType.STRING, description = "CIDR for Guest VMs,Cloudstack allocates IPs to Guest VMs only from this CIDR") + @Parameter(name = ApiConstants.GUEST_VM_CIDR, type = CommandType.STRING, description = "CIDR for guest VMs, CloudStack allocates IPs to guest VMs only from this CIDR") private String guestVmCidr; @Parameter(name = ApiConstants.DISPLAY_NETWORK, @@ -132,7 +132,7 @@ public String getCommandName() { public long getEntityOwnerId() { Network network = _networkService.getNetwork(id); if (network == null) { - throw new InvalidParameterValueException("Networkd id=" + id + " doesn't exist"); + throw new InvalidParameterValueException("Networkd ID=" + id + " doesn't exist"); } else { return _networkService.getNetwork(id).getAccountId(); } @@ -144,7 +144,7 @@ public void execute() throws InsufficientCapacityException, ConcurrentOperationE Account callerAccount = _accountService.getActiveAccountById(callerUser.getAccountId()); Network network = _networkService.getNetwork(id); if (network == null) { - throw new InvalidParameterValueException("Couldn't find network by id"); + throw new InvalidParameterValueException("Couldn't find network by ID"); } Network result = @@ -166,16 +166,16 @@ public String getEventDescription() { if (getNetworkOfferingId() != null) { Network network = _networkService.getNetwork(getId()); if (network == null) { - throw new InvalidParameterValueException("Networkd id=" + id + " doesn't exist"); + throw new InvalidParameterValueException("Networkd ID=" + id + " doesn't exist"); } if (network.getNetworkOfferingId() != getNetworkOfferingId()) { NetworkOffering oldOff = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId()); NetworkOffering newOff = _entityMgr.findById(NetworkOffering.class, getNetworkOfferingId()); if (newOff == null) { - throw new InvalidParameterValueException("Networkd offering id supplied is invalid"); + throw new InvalidParameterValueException("Networkd offering ID supplied is invalid"); } - eventMsg.append(". Original network offering id: " + oldOff.getUuid() + ", new network offering id: " + newOff.getUuid()); + eventMsg.append(". Original network offering ID: " + oldOff.getUuid() + ", new network offering ID: " + newOff.getUuid()); } } From b5cc1478623458a9a4c9b6e938f338e7fad27073 Mon Sep 17 00:00:00 2001 From: Rafael da Fonseca Date: Fri, 22 May 2015 00:54:29 +0200 Subject: [PATCH 097/175] Fixes breadcrumbs problem described in CLOUDSTACK-7907 Signed-off-by: Rajani Karuturi This closes #282 --- ui/css/cloudstack3.css | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ui/css/cloudstack3.css b/ui/css/cloudstack3.css index 887364a0d967..954aa73c61b3 100644 --- a/ui/css/cloudstack3.css +++ b/ui/css/cloudstack3.css @@ -3530,7 +3530,7 @@ div.toolbar div.filters select { } #breadcrumbs div.home { - width: 71px; + width: auto; height: 23px; float: left; /*+placement:shift -1px 0px;*/ @@ -3556,7 +3556,7 @@ div.toolbar div.filters select { float: left; font-size: 13px; color: #FFFFFF; - padding: 9px 5px 0px 8px; + padding: 9px 5px 0px 0px; cursor: pointer; /*+placement:shift -13px 0px;*/ position: relative; @@ -3589,6 +3589,7 @@ div.toolbar div.filters select { left: 0px; top: 0px; color: #63A9F1; + padding: 9px 5px 0px 8px; } #breadcrumbs ul li:hover, @@ -3614,11 +3615,7 @@ div.toolbar div.filters select { #breadcrumbs ul li { position: relative; /*+placement:shift -36px 0px;*/ - position: relative; - left: -36px; top: 0px; - margin-left: -10px; - text-indent: 13px; font-size: 13px; } From 8e67045a4bd0a00ea5c257faeb4ae8831b919f5a Mon Sep 17 00:00:00 2001 From: Milamber Date: Fri, 22 May 2015 07:47:16 +0100 Subject: [PATCH 098/175] Update L10N resource files on master branch with 4.6 translation strings from Transifex (20150522) --- .../classes/resources/messages_ar.properties | 1 - .../resources/messages_de_DE.properties | 2 +- .../resources/messages_fr_FR.properties | 7 +- .../classes/resources/messages_hu.properties | 900 ++++++++++-------- .../resources/messages_it_IT.properties | 1 - .../resources/messages_ja_JP.properties | 1 - .../resources/messages_ko_KR.properties | 1 - .../resources/messages_nb_NO.properties | 31 + .../resources/messages_nl_NL.properties | 1 - .../classes/resources/messages_pl.properties | 1 - .../resources/messages_pt_BR.properties | 1 - .../resources/messages_ru_RU.properties | 1 - .../resources/messages_zh_CN.properties | 1 - 13 files changed, 514 insertions(+), 435 deletions(-) diff --git a/client/WEB-INF/classes/resources/messages_ar.properties b/client/WEB-INF/classes/resources/messages_ar.properties index 934eb5fda1b4..3dc7ce1788b5 100644 --- a/client/WEB-INF/classes/resources/messages_ar.properties +++ b/client/WEB-INF/classes/resources/messages_ar.properties @@ -99,7 +99,6 @@ label.isolation.uri=\u0639\u0632\u0644 \u0627\u0644\u0631\u0627\u0628\u0637 label.keyboard.type=\u0646\u0648\u0639 \u0644\u0648\u062d\u0629 \u0627\u0644\u0645\u0641\u0627\u062a\u064a\u062d label.lb.algorithm.leastconn=\u0623\u0642\u0644 \u0627\u0644\u0625\u062a\u0635\u0627\u0644\u0627\u062a label.lb.algorithm.source=\u0645\u0635\u062f\u0631 -label.local.storage.enabled=\u062a\u0645\u0643\u064a\u0646 \u0627\u0644\u062a\u062e\u0632\u064a\u0646 \u0627\u0644\u0645\u062d\u0644\u064a label.make.project.owner=\u062c\u0639\u0644 \u0627\u0644\u062d\u0633\u0627\u0628 \u0645\u0627\u0644\u0643 \u0644\u0644\u0645\u0634\u0631\u0648\u0639 label.max.guest.limit=\u0627\u0644\u062d\u062f \u0627\u0644\u0623\u0642\u0635\u0627\u0621 \u0644\u0636\u064a\u0641 label.memory.mb=\u0627\u0644\u0630\u0627\u0643\u0631\u0629 ( \u0628\u0627\u0644\u0645\u064a\u062c\u0627\u0628\u0627\u064a\u0628\u062a) diff --git a/client/WEB-INF/classes/resources/messages_de_DE.properties b/client/WEB-INF/classes/resources/messages_de_DE.properties index 5980a69930a3..3b820fcb51cd 100644 --- a/client/WEB-INF/classes/resources/messages_de_DE.properties +++ b/client/WEB-INF/classes/resources/messages_de_DE.properties @@ -692,6 +692,7 @@ label.lang.dutch=Niederl\u00e4ndisch label.lang.english=englisch label.lang.french=Franz\u00f6sisch label.lang.german=Deutsch +label.lang.hungarian=Ungarisch label.lang.italian=Italienisch label.lang.japanese=japanisch label.lang.korean=Koreanisch @@ -716,7 +717,6 @@ label.load.balancer.type=Lastverteilungstyp label.load.balancing=Lastverteilung label.loading=Laden label.local=Lokal -label.local.storage.enabled=Lokaler Speicher aktiviert label.local.storage=Lokaler Speicher label.login=Login label.logout=Abmelden diff --git a/client/WEB-INF/classes/resources/messages_fr_FR.properties b/client/WEB-INF/classes/resources/messages_fr_FR.properties index 54acfc84b79a..118f7f936cc8 100644 --- a/client/WEB-INF/classes/resources/messages_fr_FR.properties +++ b/client/WEB-INF/classes/resources/messages_fr_FR.properties @@ -905,7 +905,8 @@ label.load.balancing.policies=R\u00e8gles de r\u00e9partition de charge label.load.balancing=R\u00e9partition de charge label.loading=Chargement en cours label.local=Local -label.local.storage.enabled=Stockage local activ\u00e9 +label.local.storage.enabled=Activer le stockage local pour les VMs Utilisateurs +label.local.storage.enabled.system.vms=Active le stockage local pour les VMs Syst\u00e8mes label.local.storage=Stockage local label.login=Connexion label.logout=D\u00e9connexion @@ -1269,9 +1270,9 @@ label.review=Revoir label.revoke.project.invite=R\u00e9voquer l\\'invitation label.role=R\u00f4le label.root.certificate=Certificat racine -label.root.disk.controller=Contr\u00f4leur de disque principal +label.root.disk.controller=Contr\u00f4leur de disque racine label.root.disk.offering=Offre de disque racine -label.root.disk.size=Taille disque principal +label.root.disk.size=Taille disque racine label.router.vm.scaled.up=VM Routeur agrandi label.routing.host=H\u00f4te de routage label.routing=Routage diff --git a/client/WEB-INF/classes/resources/messages_hu.properties b/client/WEB-INF/classes/resources/messages_hu.properties index 3904234ab152..397c43f6b815 100644 --- a/client/WEB-INF/classes/resources/messages_hu.properties +++ b/client/WEB-INF/classes/resources/messages_hu.properties @@ -26,17 +26,21 @@ error.login=A felhaszn\u00e1l\u00f3n\u00e9v/jelsz\u00f3 p\u00e1r nem \u00e9rv\u0 error.menu.select=A m\u0171velet nem hajthat\u00f3 v\u00e9gre, mert nincsenek kiv\u00e1lasztott elemek. error.mgmt.server.inaccessible=A vez\u00e9rl\u0151 szerver nem \u00e9rhet\u0151 el. Pr\u00f3b\u00e1ld \u00fajra k\u00e9s\u0151bb\! error.password.not.match=A jelszavak nem egyeznek. -error.please.specify.physical.network.tags=Network offerings is not available until you specify tags for this physical network. +error.please.specify.physical.network.tags=A h\u00e1l\u00f3zati aj\u00e1nlatok nem \u00e9rhet\u0151ek el addig, am\u00edg meg nem adsz c\u00edmk\u00e9ket a fizikai h\u00e1l\u00f3tathoz. error.session.expired=A munkamenet lej\u00e1rt. error.something.went.wrong.please.correct.the.following=Valami nem j\u00f3\! Jav\u00edtsd a k\u00f6vetkez\u0151ket\: error.unable.to.reach.management.server=A vez\u00e9rl\u0151 szerver nem el\u00e9rhet\u0151 error.unresolved.internet.name=Az internet neved nem oldhat\u00f3 fel. -force.delete.domain.warning=Warning\: Choosing this option will cause the deletion of all child domains and all associated accounts and their resources. +force.delete.domain.warning=Figyelmeztet\u00e9s\: Ha ezt v\u00e1lasztod, t\u00f6rl\u0151dni fog minden al\u00e1rendelt dom\u00e9n \u00e9s minden kapcsol\u00f3d\u00f3 sz\u00e1mla \u00e9s a hozz\u00e1juk tartoz\u00f3 er\u0151forr\u00e1sok. force.delete=T\u00f6rl\u00e9s kik\u00e9nyszer\u00edt\u00e9se force.remove=Elt\u00e1vol\u00edt\u00e1s kik\u00e9nyszer\u00edt\u00e9se force.remove.host.warning=Figyelmeztet\u00e9s\: Ha ezt az opci\u00f3t v\u00e1lasztod, a CloudStack minden virtu\u00e1lis g\u00e9pet le\u00e1ll\u00edt miel\u0151tt elt\u00e1vol\u00edtja a kiszolg\u00e1l\u00f3t a f\u00fcrtb\u0151l. force.stop.instance.warning=Figyelmeztet\u00e9s\: A p\u00e9ld\u00e1ny er\u0151szakos le\u00e1ll\u00edt\u00e1sa az utols\u00f3 lehet\u0151s\u00e9g. Ez adatveszt\u00e9shez \u00e9s a virtu\u00e1lis g\u00e9p inkonzisztens viselked\u00e9s\u00e9hez vezethet. force.stop=Le\u00e1ll\u00e1s kik\u00e9nyszer\u00edt\u00e9se +hint.no.host.tags=Nincsenek kiszolg\u00e1l\u00f3 c\u00edmk\u00e9k +hint.no.storage.tags=Nincsenek t\u00e1r c\u00edmk\u00e9k +hint.type.part.host.tag=\u00cdrd be egy kiszolg\u00e1l\u00f3 c\u00edmke r\u00e9sz\u00e9t +hint.type.part.storage.tag=\u00cdrd be egy t\u00e1r c\u00edmke r\u00e9sz\u00e9t ICMP.code=ICMP k\u00f3d ICMP.type=ICMP t\u00edpus image.directory=Image Directory @@ -65,8 +69,8 @@ label.action.attach.iso.processing=ISO csatlakoztat\u00e1sa... label.action.cancel.maintenance.mode=Karbantart\u00e1si m\u00f3d megszak\u00edt\u00e1sa label.action.cancel.maintenance.mode.processing=Karbantart\u00e1si m\u00f3d megszak\u00edt\u00e1sa... label.action.change.password=Jelsz\u00f3 csere -label.action.change.service=Change Service -label.action.change.service.processing=Changing Service.... +label.action.change.service.processing=Szolg\u00e1ltat\u00e1s v\u00e1ltoztat\u00e1sa... +label.action.change.service=Szolg\u00e1ltat\u00e1s v\u00e1ltoztat\u00e1sa label.action.copy.ISO=ISO m\u00e1sol\u00e1sa label.action.copy.ISO.processing=ISO m\u00e1sol\u00e1sa... label.action.copy.template.processing=Sablon m\u00e1sol\u00e1sa... @@ -89,8 +93,8 @@ label.action.delete.domain=Dom\u00e9n t\u00f6rl\u00e9se label.action.delete.domain.processing=Dom\u00e9n t\u00f6rl\u00e9se... label.action.delete.firewall.processing=T\u0171zfal t\u00f6rl\u00e9se... label.action.delete.firewall=T\u0171zfal szab\u00e1ly t\u00f6rl\u00e9se -label.action.delete.ingress.rule=Delete Ingress Rule -label.action.delete.ingress.rule.processing=Deleting Ingress Rule.... +label.action.delete.ingress.rule=Ingress szab\u00e1ly t\u00f6rl\u00e9se +label.action.delete.ingress.rule.processing=Ingress szab\u00e1ly t\u00f6rl\u00e9se... label.action.delete.IP.range=IP c\u00edmtartom\u00e1ny t\u00f6rl\u00e9se label.action.delete.IP.range.processing=IP c\u00edmtartom\u00e1ny t\u00f6rl\u00e9se... label.action.delete.ISO=ISO t\u00f6rl\u00e9se @@ -110,11 +114,11 @@ label.action.delete.secondary.storage=M\u00e1sodlagos t\u00e1r t\u00f6rl\u00e9se label.action.delete.secondary.storage.processing=M\u00e1sodlagos t\u00e1r t\u00f6rl\u00e9se... label.action.delete.security.group=Biztons\u00e1gi csoport t\u00f6rl\u00e9se label.action.delete.security.group.processing=Biztons\u00e1gi csoport t\u00f6rl\u00e9se... -label.action.delete.service.offering=Delete Service Offering -label.action.delete.service.offering.processing=Deleting Service Offering.... +label.action.delete.service.offering.processing=Szolg\u00e1ltat\u00e1s aj\u00e1nlat t\u00f6rl\u00e9se... +label.action.delete.service.offering=Szolg\u00e1ltat\u00e1s aj\u00e1nlat t\u00f6rl\u00e9se label.action.delete.snapshot=Pillanatfelv\u00e9tel t\u00f6rl\u00e9se label.action.delete.snapshot.processing=Pillanatfelv\u00e9tel t\u00f6rl\u00e9se... -label.action.delete.system.service.offering=Delete System Service Offering +label.action.delete.system.service.offering=Rendszer szolg\u00e1ltat\u00e1s aj\u00e1nlat t\u00f6rl\u00e9se label.action.delete.template.processing=Sablon t\u00f6rl\u00e9se... label.action.delete.template=Sablon t\u00f6rl\u00e9se label.action.delete.user=Felhaszn\u00e1l\u00f3 t\u00f6rl\u00e9se @@ -135,8 +139,8 @@ label.action.disable.account.processing=Sz\u00e1mla kikapcsol\u00e1sa... label.action.disable.account=Sz\u00e1mla kikapcsol\u00e1sa label.action.disable.cluster=F\u00fcrt kikapcsol\u00e1sa label.action.disable.cluster.processing=F\u00fcrt kikapcsol\u00e1sa... -label.action.disable.nexusVswitch=Disable Nexus 1000v -label.action.disable.physical.network=Disable physical network +label.action.disable.nexusVswitch=Nexus 1000v kikapcsol\u00e1sa +label.action.disable.physical.network=Fizikikai h\u00e1l\u00f3zat kikapcsol\u00e1sa label.action.disable.pod=Pod kikapcsol\u00e1sa label.action.disable.pod.processing=Pod kikapcsol\u00e1sa... label.action.disable.static.NAT.processing=Statikus NAT kikapcsol\u00e1sa... @@ -151,8 +155,8 @@ label.action.download.volume=K\u00f6tet let\u00f6lt\u00e9se label.action.download.volume.processing=K\u00f6tet let\u00f6lt\u00e9se... label.action.edit.account=Sz\u00e1mla enged\u00e9lyez\u00e9se label.action.edit.disk.offering=Merevlemez aj\u00e1nlat szerkeszt\u00e9se -label.action.edit.domain=Edit Domain -label.action.edit.global.setting=Edit Global Setting +label.action.edit.domain=Dom\u00e9n szerkeszt\u00e9se +label.action.edit.global.setting=Glob\u00e1lis be\u00e1ll\u00edt\u00e1s szerkeszt\u00e9se label.action.edit.host=Kiszolg\u00e1l\u00f3 szerkeszt\u00e9se label.action.edit.instance=P\u00e9ld\u00e1ny szerkeszt\u00e9se label.action.edit.ISO=ISO szerkeszt\u00e9se @@ -162,7 +166,7 @@ label.action.edit.network.processing=H\u00e1l\u00f3zat szerkeszt\u00e9se... label.action.edit.pod=Pod szerkeszt\u00e9se label.action.edit.primary.storage=Els\u0151dleges t\u00e1r szerkeszt\u00e9se label.action.edit.resource.limits=Er\u0151forr\u00e1s korl\u00e1tok szerkeszt\u00e9se -label.action.edit.service.offering=Edit Service Offering +label.action.edit.service.offering=Szolg\u00e1ltat\u00e1s aj\u00e1nlat szerkeszt\u00e9se label.action.edit.template=Sablon szerkeszt\u00e9se label.action.edit.user=Felhaszn\u00e1l\u00f3 szerkeszt\u00e9se label.action.edit.zone=Z\u00f3na szerkeszt\u00e9se @@ -172,18 +176,18 @@ label.action.enable.cluster=F\u00fcrt enged\u00e9lyez\u00e9se label.action.enable.cluster.processing=F\u00fcrt enged\u00e9lyez\u00e9se... label.action.enable.maintenance.mode=Karbantart\u00e1si \u00fczemm\u00f3d enged\u00e9lyez\u00e9se label.action.enable.maintenance.mode.processing=Karbantart\u00e1si \u00fczemm\u00f3d enged\u00e9lyez\u00e9se... -label.action.enable.nexusVswitch=Enable Nexus 1000v -label.action.enable.physical.network=Enable physical network +label.action.enable.nexusVswitch=Nexus 1000v bekapcsol\u00e1sa +label.action.enable.physical.network=Fizikai h\u00e1l\u00f3zat bekapcsol\u00e1sa label.action.enable.pod=Pod bekapcsol\u00e1sa label.action.enable.pod.processing=Pod bekapcsol\u00e1sa... -label.action.enable.static.NAT.processing=Enabling Static NAT.... +label.action.enable.static.NAT.processing=Statikus NAT bekapcsol\u00e1sa... label.action.enable.static.NAT=Statikus NAT bekapcsol\u00e1sa label.action.enable.user=Felhaszn\u00e1l\u00f3 bekapcsol\u00e1sa label.action.enable.user.processing=Felhaszn\u00e1l\u00f3 bekapcsol\u00e1sa... label.action.enable.zone.processing=Z\u00f3na bekapcsol\u00e1sa.... label.action.enable.zone=Z\u00f3na bekapcsol\u00e1sa -label.action.expunge.instance=Expunge Instance -label.action.expunge.instance.processing=Expunging Instance.... +label.action.expunge.instance.processing=P\u00e9ld\u00e1ny t\u00f6rl\u00e9se... +label.action.expunge.instance=P\u00e9ld\u00e1ny t\u00f6rl\u00e9se label.action.force.reconnect.processing=\u00dajrakapcsol\u00f3d\u00e1s... label.action.force.reconnect=\u00dajracsatlakoz\u00e1s kik\u00e9nyszer\u00edt\u00e9se label.action.generate.keys=Kulcsgener\u00e1l\u00e1s @@ -208,6 +212,7 @@ label.action.reboot.systemvm.processing=Rendszer VM \u00fajraind\u00edt\u00e1sa label.action.reboot.systemvm=Rendszer VM \u00fajraind\u00edt\u00e1sa label.action.recurring.snapshot=Ism\u00e9tl\u0151d\u0151 pillanatfelv\u00e9telek label.action.register.iso=ISO regisztr\u00e1ci\u00f3ja +label.action.register.template=Sablon regisztr\u00e1ci\u00f3ja URL-r\u0151l label.action.release.ip=IP c\u00edm elenged\u00e9se label.action.release.ip.processing=IP c\u00edm elenged\u00e9se label.action.remove.host=Kiszolg\u00e1l\u00f3 elt\u00e1vol\u00edt\u00e1sa @@ -221,7 +226,7 @@ label.action.restore.instance.processing=P\u00e9ld\u00e1ny helyre\u00e1ll\u00edt label.action.restore.instance=P\u00e9ld\u00e1ny helyre\u00e1ll\u00edt\u00e1sa label.action.revert.snapshot.processing=Vissza\u00e1ll\u00e1s pillanatfelv\u00e9telre... label.action.revert.snapshot=Vissza\u00e1ll\u00e1s pillanatfelv\u00e9telre -label.actions=Actions +label.actions=M\u0171veletek label.action.start.instance.processing=P\u00e9ld\u00e1ny ind\u00edt\u00e1sa... label.action.start.instance=P\u00e9ld\u00e1ny ind\u00edt\u00e1sa label.action.start.router.processing=Router le\u00e1ll\u00edt\u00e1sa... @@ -236,10 +241,10 @@ label.action.stop.systemvm.processing=Rendszer VM le\u00e1ll\u00edt\u00e1sa... label.action.stop.systemvm=Rendszer VM le\u00e1ll\u00edt\u00e1sa label.action.take.snapshot=Pillanatfelv\u00e9tel k\u00e9sz\u00edt\u00e9se label.action.take.snapshot.processing=Pillanatfelv\u00e9tel k\u00e9sz\u00edt\u00e9se... -label.action.unmanage.cluster.processing=Unmanaging Cluster.... -label.action.unmanage.cluster=Unmanage Cluster -label.action.update.OS.preference.processing=Updating OS Preference.... -label.action.update.OS.preference=Update OS Preference +label.action.unmanage.cluster=F\u00fcrt vez\u00e9rl\u00e9s le\u00e1ll\u00edt\u00e1sa +label.action.unmanage.cluster.processing=F\u00fcrt vez\u00e9rl\u00e9s le\u00e1ll\u00edt\u00e1sa... +label.action.update.OS.preference=OS preferencia m\u00f3dos\u00edt\u00e1sa +label.action.update.OS.preference.processing=OS preferencia m\u00f3dos\u00edt\u00e1sa... label.action.update.resource.count=Er\u0151forr\u00e1s sz\u00e1m m\u00f3dos\u00edt\u00e1sa label.action.update.resource.count.processing=Er\u0151forr\u00e1s sz\u00e1m m\u00f3dos\u00edt\u00e1sa... label.action.vmsnapshot.create=VM pillanatfelv\u00e9tel k\u00e9sz\u00edt\u00e9se @@ -247,32 +252,37 @@ label.action.vmsnapshot.delete=VM pillanatfelv\u00e9tel k\u00e9sz\u00edt\u00e9se label.action.vmsnapshot.revert=Vissza\u00e1ll\u00e1s VM pillanatfelv\u00e9telre label.activate.project=Projekt aktiv\u00e1l\u00e1sa label.active.sessions=Akt\u00edv munkamenetek -label.add.accounts=Add accounts +label.add.accounts=Sz\u00e1ml\u00e1k felv\u00e9tele label.add.accounts.to=Sz\u00e1mla felv\u00e9tele\: label.add.account=Sz\u00e1mla felv\u00e9tele label.add.account.to.project=Sz\u00e1mla felv\u00e9tele a projekthez label.add.ACL=ACL felv\u00e9tele -label.add.acl.list=Add ACL List -label.add.affinity.group=Add new affinity group -label.add.baremetal.dhcp.device=Add Baremetal DHCP Device +label.add.acl.list=ACL lista felv\u00e9tele +label.add.affinity.group=\u00daj affin\u00edt\u00e1si csoport felv\u00e9tele +label.add.baremetal.dhcp.device=Baremetal DHCP eszk\u00f6z felv\u00e9tele +label.add.baremetal.rack.configuration=Baremetal rack konfigur\u00e1ci\u00f3 felv\u00e9tele +label.add.BigSwitchBcf.device=BigSwitch BCF vez\u00e9rl\u0151 felv\u00e9tele label.add.BrocadeVcs.device=Brocade Vcs Switch felv\u00e9tele label.add.by=Add by label.add.by.cidr=Add By CIDR label.add.by.group=Add By Group -label.add.ciscoASA1000v=Add CiscoASA1000v Resource +label.add.ciscoASA1000v=CiscoASA1000v er\u0151forr\u00e1s felv\u00e9tele label.add.cluster=F\u00fcrt felv\u00e9tele label.add.compute.offering=CPU aj\u00e1nlat felv\u00e9tele label.add.direct.iprange=IP tartom\u00e1ny felv\u00e9tele label.add.disk.offering=Merevlemez aj\u00e1nlat felv\u00e9tele -label.add.domain=Add Domain +label.add.domain=Dom\u00e9n felv\u00e9tele label.added.brocade.vcs.switch=Added new Brocade Vcs Switch +label.added.network.offering=H\u00e1l\u00f3zat aj\u00e1nlat felv\u00e9ve +label.added.new.bigswitch.bcf.controller=BigSwitch BCF vez\u00e9rl\u0151 felv\u00e9ve label.added.nicira.nvp.controller=Added new Nicira NVP Controller label.add.egress.rule=Kimen\u0151 szab\u00e1ly felv\u00e9tele -label.addes.new.f5=Added new F5 +label.addes.new.f5=\u00daj F5 felv\u00e9tele label.add.F5.device=F5 eszk\u00f6z felv\u00e9tele label.add=Felv\u00e9tel label.add.firewall=T\u0171zfal szab\u00e1ly felv\u00e9tele -label.add.gslb=Add GSLB +label.add.globo.dns=GloboDNS felv\u00e9tele +label.add.gslb=GSLB felv\u00e9tele label.add.guest.network=Vend\u00e9g h\u00e1l\u00f3zat felv\u00e9tele label.add.host=Kiszolg\u00e1l\u00f3 felv\u00e9tele label.adding.cluster=F\u00fcrt felv\u00e9tele @@ -280,25 +290,26 @@ label.adding.failed=Hiba a felv\u00e9tel sor\u00e1n label.adding=Felv\u00e9tel label.adding.pod=Pod felv\u00e9tele label.adding.processing=Felv\u00e9tel... -label.add.ingress.rule=Add Ingress Rule +label.add.ingress.rule=Ingress szab\u00e1ly felv\u00e9tele label.adding.succeeded=Sikeres felv\u00e9tel label.adding.user=Felhaszn\u00e1l\u00f3 felv\u00e9tele label.adding.zone=Z\u00f3na felv\u00e9tele -label.add.intermediate.certificate=Add intermediate certificate -label.add.internal.lb=Add Internal LB +label.add.intermediate.certificate=K\u00f6zb\u00fcls\u0151 tan\u00fas\u00edtv\u00e1ny felv\u00e9tele +label.add.internal.lb=Bels\u0151 LB felv\u00e9tele label.add.ip.range=IP c\u00edmtartom\u00e1ny felv\u00e9tele label.add.isolated.guest.network=Izol\u00e1lt vend\u00e9g h\u00e1l\u00f3zat felv\u00e9tele label.add.isolated.network=Izol\u00e1lt h\u00e1l\u00f3zat felv\u00e9tele label.additional.networks=Tov\u00e1bbi h\u00e1l\u00f3zatok -label.add.list.name=ACL List Name +label.add.ldap.account=LDAP hozz\u00e1f\u00e9r\u00e9s felv\u00e9tele +label.add.list.name=ACL lista n\u00e9v label.add.load.balancer=Terhel\u00e9seloszt\u00f3 felv\u00e9tele label.add.more=Tov\u00e1bbi felv\u00e9tele label.add.netScaler.device=Netscaler eszk\u00f6z felv\u00e9tele label.add.network.ACL=H\u00e1l\u00f3zati ACL felv\u00e9tele -label.add.network.acl.list=Add Network ACL List +label.add.network.acl.list=H\u00e1l\u00f3zati ACL lista felv\u00e9tele label.add.network.device=Add Network Device label.add.network=H\u00e1l\u00f3zat felv\u00e9tele -label.add.network.offering=Add network offering +label.add.network.offering=H\u00e1l\u00f3zati aj\u00e1nlat felv\u00e9tele label.add.new.F5=\u00daj F5 felv\u00e9tele label.add.new.gateway=\u00daj \u00e1tj\u00e1r\u00f3 felv\u00e9tele label.add.new.NetScaler=\u00daj NetScaler felv\u00e9tele @@ -312,9 +323,10 @@ label.add.OpenDaylight.device=OpenDaylight Controller hozz\u00e1ad\u00e1sa label.add.PA.device=Palo Alto eszk\u00f6z felv\u00e9tele label.add.physical.network=Fizikai h\u00e1l\u00f3zat felv\u00e9tele label.add.pod=Pod felv\u00e9tele -label.add.portable.ip.range=Add Portable IP Range +label.add.portable.ip.range=Portolhat\u00f3 IP tartom\u00e1ny felv\u00e9tele label.add.port.forwarding.rule=Port tov\u00e1bb\u00edt\u00f3 szab\u00e1ly felv\u00e9tele label.add.primary.storage=Els\u0151dleges t\u00e1r felv\u00e9tele +label.add.private.gateway=Priv\u00e1t \u00e1tj\u00e1r\u00f3 felv\u00e9tele label.add.region=R\u00e9gi\u00f3 felv\u00e9tele label.add.resources=Er\u0151forr\u00e1sok felv\u00e9tele label.add.route=\u00datvonal felv\u00e9tele @@ -329,18 +341,19 @@ label.add.system.service.offering=Add System Service Offering label.add.template=Sablon felv\u00e9tele label.add.to.group=Felv\u00e9tel a csoportba label.add.ucs.manager=Add UCS Manager +label.add.userdata=Felhaszn\u00e1l\u00f3 adat label.add.user=Felhaszn\u00e1l\u00f3 felv\u00e9tele label.add.vlan=VLAN felv\u00e9tele -label.add.vms=Add VMs -label.add.vms.to.lb=Add VM(s) to load balancer rule -label.add.VM.to.tier=Add VM to tier +label.add.vms.to.lb=VM(ek) felv\u00e9tele a terhel\u00e9seloszt\u00f3 szab\u00e1lyba +label.add.vms=VM-ek felv\u00e9tele +label.add.VM.to.tier=VM felv\u00e9tele r\u00e9tegbe label.add.vm=VM felv\u00e9tele -label.add.vmware.datacenter=Add VMware datacenter -label.add.vnmc.device=Add VNMC device -label.add.vnmc.provider=Add VNMC provider +label.add.vmware.datacenter=VMware adatk\u00f6zpont felv\u00e9tele +label.add.vnmc.device=VNMC eszk\u00f6z felv\u00e9tele +label.add.vnmc.provider=VNMC szolg\u00e1ltat\u00f3 felv\u00e9tele label.add.volume=K\u00f6tet felv\u00e9tele -label.add.vpc=Add VPC -label.add.vpc.offering=Add VPC Offering +label.add.vpc.offering=VPC aj\u00e1nlat felv\u00e9tele +label.add.vpc=VPC felv\u00e9tele label.add.vpn.customer.gateway=VPN \u00fcgyf\u00e9lkapu felv\u00e9tele label.add.VPN.gateway=VPN \u00e1tj\u00e1r\u00f3 felv\u00e9tele label.add.vpn.user=VPN felhaszn\u00e1l\u00f3 felv\u00e9tele @@ -351,12 +364,13 @@ label.admin=Adminisztr\u00e1tor label.advanced=Halad\u00f3 label.advanced.mode=Halad\u00f3 m\u00f3d label.advanced.search=Halad\u00f3 keres\u00e9s -label.affinity=Affinity -label.affinity.group=Affinity Group -label.affinity.groups=Affinity Groups +label.affinity=Affin\u00edt\u00e1s +label.affinity.group=Affin\u00edt\u00e1si csoport +label.affinity.groups=Affin\u00edt\u00e1si csoportok label.agent.password=\u00dcgyn\u00f6k jelsz\u00f3 +label.agent.port=\u00dcgyn\u00f6k port label.agent.state=Agent State -label.agent.username=Agent Username +label.agent.username=\u00dcgyn\u00f6k felhaszn\u00e1l\u00f3n\u00e9v label.agree=Elfogadom label.alert.archived=Riaszt\u00e1s archiv\u00e1lva label.alert.deleted=Riaszt\u00e1s t\u00f6r\u00f6lve @@ -364,45 +378,51 @@ label.alert.details=Riaszt\u00e1s r\u00e9szletei label.alert=Riaszt\u00e1s label.algorithm=Algoritmus label.allocated=Lek\u00f6t\u00f6ve -label.allocation.state=Allocation State +label.allocation.state=Lefoglal\u00e1s \u00e1llapota label.allow=Enged\u00e9lyez -label.anti.affinity=Anti-affinity -label.anti.affinity.group=Anti-affinity Group -label.anti.affinity.groups=Anti-affinity Groups +label.anti.affinity=Anti-affin\u00edt\u00e1s +label.anti.affinity.group=Anti-affin\u00edt\u00e1s csoport +label.anti.affinity.groups=Anti-affin\u00edt\u00e1s csoportok label.api.key=API kulcs label.api.version=API verzi\u00f3 label.apply=Alkalmaz label.app.name=CloudStack label.archive.alerts=Riaszt\u00e1sok archiv\u00e1l\u00e1sa label.archive=Archive -label.archive.events=Archive events +label.archive.events=Esem\u00e9nyek archiv\u00e1l\u00e1sa label.assigned.vms=Hozz\u00e1rendelt VM-ek label.assign=Hozz\u00e1rendel\u00e9s label.assign.instance.another=Assign Instance to Another Account label.assign.to.load.balancer=P\u00e9ld\u00e1ny hozz\u00e1rendel\u00e9se terhel\u00e9seloszt\u00f3hoz -label.associated.network=Associated Network -label.associated.network.id=Associated Network ID -label.associated.profile=Associated Profile +label.assign.vms=VM-ek hozz\u00e1rendel\u00e9se +label.associated.network.id=Kapcsolt h\u00e1l\u00f3zat ID +label.associated.network=Kapcsolt h\u00e1l\u00f3zat +label.associated.profile=Kapacsolt profil label.associate.public.ip=Publikus IP c\u00edm hozz\u00e1rendel\u00e9se -label.attached.iso=Attached ISO +label.attached.iso=Kapcsolt ISO label.author.email=Szerz\u0151 e-mail label.author.name=Szerz\u0151 n\u00e9v label.autoscale=AutoScale label.availability=El\u00e9rhet\u0151s\u00e9g label.availability.zone=El\u00e9rhet\u0151s\u00e9gi z\u00f3na +label.availabilityZone=El\u00e9rhet\u0151s\u00e9gi z\u00f3na label.available=El\u00e9rhet\u0151 -label.available.public.ips=Available Public IP Addresses +label.available.public.ips=El\u00e9rhet\u0151 publikus PI c\u00edmek label.back=Vissza label.bandwidth=S\u00e1vsz\u00e9less\u00e9g -label.baremetal.dhcp.devices=Baremetal DHCP Devices -label.baremetal.dhcp.provider=Baremetal DHCP Provider -label.baremetal.pxe.device=Add Baremetal PXE Device -label.baremetal.pxe.devices=Baremetal PXE Devices -label.baremetal.pxe.provider=Baremetal PXE Provider +label.baremetal.dhcp.devices=Baremetal DHCP eszk\u00f6z\u00f6k +label.baremetal.dhcp.provider=Baremetal DHCP szolg\u00e1ltat\u00f3 +label.baremetal.pxe.device=Baremetal PXE eszk\u00f6z felv\u00e9tele +label.baremetal.pxe.devices=Baremetal PXE eszk\u00f6z\u00f6k +label.baremetal.pxe.provider=Baremetal PXE szolg\u00e1ltat\u00f3 +label.baremetal.rack.configuration=Baremetal rack konfigur\u00e1ci\u00f3 label.basic=Alap label.basic.mode=Alap m\u00f3d +label.bigswitch.bcf.details=BigSwitch BCF r\u00e9szletek +label.bigswitch.bcf.nat=BigSwitch BCF NAT bekapcsolva +label.bigswitch.controller.address=BigSwitch BCF vez\u00e9rl\u0151 c\u00edm label.blade.id=Blade ID -label.blades=Blades +label.blades=Blade-k label.bootable=Ind\u00edthat\u00f3 label.broadcast.domain.range=Broadcast domain range label.broadcast.domain.type=Broadcast Domain Type @@ -436,11 +456,12 @@ label.capacity.bytes=Byte kapac\u00edt\u00e1s label.capacity.iops=IOPS kapac\u00edt\u00e1s label.capacity=Kapac\u00edt\u00e1s label.certificate=Server certificate -label.change.affinity=Change Affinity +label.change.affinity=Affin\u00edt\u00e1s v\u00e1ltoztat\u00e1sa label.change.service.offering=Change service offering label.change.value=\u00c9rt\u00e9k v\u00e1ltoztat\u00e1sa label.character=Karakter -label.chassis=Chassis +label.chassis=H\u00e1z +label.checksum=ellen\u00f6rz\u0151 \u00f6sszeg label.cidr.account=CIDR vagy sz\u00e1mla/biztons\u00e1gi csoport label.cidr=CIDR label.CIDR.list=CIDR lista @@ -449,8 +470,8 @@ label.CIDR.of.destination.network=A c\u00e9l h\u00e1l\u00f3zat CIDR label.cisco.nexus1000v.ip.address=Nexus 1000v IP c\u00edm label.cisco.nexus1000v.password=Nexus 1000v jelsz\u00f3 label.cisco.nexus1000v.username=Nexus 1000v felhaszn\u00e1l\u00f3n\u00e9v -label.ciscovnmc.resource.details=CiscoVNMC resource details -label.clean.up=Clean up +label.ciscovnmc.resource.details=CiscoVNMC er\u0151forr\u00e1s r\u00e9szletek +label.clean.up=Takar\u00edt\u00e1s label.clear.list=Lista t\u00f6rl\u00e9se label.close=Bez\u00e1r\u00e1s label.cloud.console=Cloud Management Console @@ -462,35 +483,35 @@ label.cluster.type=F\u00fcrt t\u00edpus label.clvm=CLVM label.code=K\u00f3d label.community=K\u00f6z\u00f6ss\u00e9g -label.compute.and.storage=Compute and Storage -label.compute.offering=Compute offering -label.compute.offerings=Compute Offerings +label.compute.and.storage=Sz\u00e1m\u00edt\u00e1s \u00e9s t\u00e1r +label.compute.offering=CPU aj\u00e1nlat +label.compute.offerings=Sz\u00e1m\u00edt\u00e1si aj\u00e1nlatok label.compute=Sz\u00e1m\u00edt\u00e1s label.configuration=Konfigur\u00e1ci\u00f3 label.configure=Konfigur\u00e1ci\u00f3 label.configure.ldap=LDAP konfigur\u00e1ci\u00f3ja -label.configure.network.ACLs=Configure Network ACLs -label.configure.vpc=Configure VPC +label.configure.network.ACLs=H\u00e1l\u00f3zati ACL-ek konfigur\u00e1ci\u00f3ja +label.configure.vpc=VPC konfigur\u00e1ci\u00f3ja label.confirmation=Meger\u0151s\u00edt\u00e9s label.confirm.password=Jelsz\u00f3 meger\u0151s\u00edt\u00e9s label.congratulations=Gratul\u00e1ci\u00f3\! label.conserve.mode=Conserve mode -label.console.proxy=Console proxy +label.console.proxy=Konzol proxy label.console.proxy.vm=Console Proxy VM label.continue.basic.install=Folytat\u00e1s alaptelep\u00edt\u00e9ssel label.continue=Tov\u00e1bb -label.copying.iso=Copying ISO +label.copying.iso=ISO m\u00e1sol\u00e1sa label.corrections.saved=Jav\u00edt\u00e1sok mentve label.counter=Sz\u00e1ml\u00e1l\u00f3 label.cpu.allocated=CPU allok\u00e1lva -label.cpu.allocated.for.VMs=CPU Allocated for VMs +label.cpu.allocated.for.VMs=CPU lefoglalva a VM-ek r\u00e9sz\u00e9re label.CPU.cap=CPU Cap label.cpu=CPU label.cpu.limits=CPU korl\u00e1tok label.cpu.mhz=CPU (MHz) label.cpu.utilized=CPU haszn\u00e1lat label.created.by.system=Created by system -label.created=Created +label.created=L\u00e9trehoz\u00e1s d\u00e1tuma label.create.nfs.secondary.staging.storage=Create NFS Secondary Staging Store label.create.nfs.secondary.staging.store=NFS m\u00e1sodlagos t\u00e1r l\u00e9trehoz\u00e1sa label.create.project=Projekt l\u00e9trehoz\u00e1sa @@ -503,39 +524,42 @@ label.custom=Egyedi label.daily=Napi label.data.disk.offering=Data Disk Offering label.date=D\u00e1tum +label.day=Nap label.day.of.month=H\u00f3nap napja label.day.of.week=H\u00e9t napja label.dc.name=DC n\u00e9v label.dead.peer.detection=Dead Peer Detection -label.decline.invitation=Decline invitation -label.dedicate.cluster=Dedicate Cluster +label.decline.invitation=Megh\u00edv\u00f3 elutas\u00edt\u00e1sa +label.dedicate.cluster=F\u00fcrt dedik\u00e1l\u00e1sa label.dedicated=Dedik\u00e1lt -label.dedicate=Dedicate -label.dedicated.vlan.vni.ranges=Dedicated VLAN/VNI Ranges +label.dedicate=Dedik\u00e1l\u00e1s +label.dedicated.vlan.vni.ranges=Dedik\u00e1lt VLAN/VNI tartom\u00e1nyok label.dedicate.host=Kiszolg\u00e1l\u00f3 dedik\u00e1l\u00e1sa -label.dedicate.pod=Dedicate Pod -label.dedicate.vlan.vni.range=Dedicate VLAN/VNI Range +label.dedicate.pod=Pod dedik\u00e1l\u00e1sa +label.dedicate.vlan.vni.range=Dedik\u00e1lt VLAN/VNI tartom\u00e1ny label.dedicate.zone=Dedik\u00e1lt z\u00f3na label.default=Alap\u00e9rtelmezett label.default.egress.policy=Default egress policy label.default.use=Alap\u00e9rtelmezett haszn\u00e1lat label.default.view=Alap\u00e9rtelmezett n\u00e9zet -label.delete.acl.list=Delete ACL List -label.delete.affinity.group=Delete Affinity Group +label.delete.acl.list=ACL lista t\u00f6rl\u00e9se +label.delete.affinity.group=Affin\u00edt\u00e1si csoport t\u00f6rl\u00e9se label.delete.alerts=T\u00f6rl\u00e9s riaszt\u00e1sok -label.delete.BrocadeVcs=Remove Brocade Vcs Switch -label.delete.ciscoASA1000v=Delete CiscoASA1000v -label.delete.ciscovnmc.resource=Delete CiscoVNMC resource +label.delete.baremetal.rack.configuration=Baremetal rack konfigur\u00e1ci\u00f3 t\u00f6rl\u00e9se +label.delete.BigSwitchBcf=BigSwitch BCF vez\u00e9rl\u0151 elt\u00e1vol\u00edt\u00e1sa +label.delete.BrocadeVcs=Brocade Vcs Switch t\u00f6rl\u00e9se +label.delete.ciscoASA1000v=CiscoASA1000v t\u00f6rl\u00e9se +label.delete.ciscovnmc.resource=CiscoVNMC er\u0151forr\u00e1s t\u00f6rl\u00e9se label.delete.events=T\u00f6rl\u00e9s esem\u00e9nyek label.delete.F5=F5 t\u00f6rl\u00e9se label.delete.gateway=\u00c1tj\u00e1r\u00f3 t\u00f6rl\u00e9se -label.delete.internal.lb=Delete Internal LB +label.delete.internal.lb=Bels\u0151 LB t\u00f6rl\u00e9se label.delete.NetScaler=NetScaler t\u00f6rl\u00e9se -label.delete.NiciraNvp=Remove Nvp Controller -label.delete.NuageVsp=Remove Nuage VSD +label.delete.NiciraNvp=Nvp vez\u00e9rl\u0151 t\u00f6rl\u00e9se +label.delete.NuageVsp=Nuage VSD t\u00f6rl\u00e9se label.delete.OpenDaylight.device=OpenDaylight Controller t\u00f6rl\u00e9se label.delete.PA=Palo Alto t\u00f6rl\u00e9se -label.delete.portable.ip.range=Delete Portable IP Range +label.delete.portable.ip.range=Hordozhat\u00f3 IP tartom\u00e1ny t\u00f6rl\u00e9se label.delete.profile=Profil t\u00f6rl\u00e9se label.delete.project=Projekt t\u00f6rl\u00e9se label.delete.secondary.staging.store=Delete Secondary Staging Store @@ -551,11 +575,11 @@ label.deleting.processing=T\u00f6rl\u00e9s... label.deny=Megtilt label.deployment.planner=Felhaszn\u00e1l\u00e1s tervez\u0151 label.description=Le\u00edr\u00e1s -label.destination.physical.network.id=Destination physical network ID -label.destination.zone=Destination Zone +label.destination.physical.network.id=C\u00e9l fizikai h\u00e1l\u00f3zat ID +label.destination.zone=C\u00e9l z\u00f3na label.destroy=Elpuszt\u00edt -label.destroy.router=Destroy router -label.destroy.vm.graceperiod=Destroy VM Grace Period +label.destroy.router=Router elpuszt\u00edt\u00e1sa +label.destroy.vm.graceperiod=VM elpuszt\u00edt\u00e1s t\u00fcrelmi id\u0151 label.detaching.disk=Merevlemez lev\u00e1laszt\u00e1sa label.details=R\u00e9szletek label.device.id=Eszk\u00f6z ID @@ -563,19 +587,19 @@ label.devices=Eszk\u00f6z\u00f6k label.dhcp=DHCP label.DHCP.server.type=DHCP kiszolg\u00e1l\u00f3 t\u00edpus label.direct.attached.public.ip=Direct Attached Public IP -label.direct.ips=Shared Network IPs +label.direct.ips=Osztott h\u00e1l\u00f3zati IP c\u00edmek label.disable.autoscale=Automatikus sk\u00e1l\u00e1z\u00e1s kikapcsol\u00e1sa label.disabled=Kikapcsolt label.disable.host=Kiszolg\u00e1l\u00f3 kikapcsol\u00e1sa label.disable.network.offering=H\u00e1l\u00f3zati aj\u00e1nlat kikapcsol\u00e1sa label.disable.provider=Szolg\u00e1ltat\u00f3 kikapcsol\u00e1sa -label.disable.vnmc.provider=Disable VNMC provider -label.disable.vpc.offering=Disable VPC offering -label.disable.vpn=Disable Remote Access VPN -label.disabling.vpn.access=Disabling VPN Access +label.disable.vnmc.provider=VNMC szolg\u00e1ltat\u00f3 kikapcsol\u00e1sa +label.disable.vpc.offering=VPC aj\u00e1nlat kikapcsol\u00e1sa +label.disable.vpn=T\u00e1voli VPN hozz\u00e1f\u00e9r\u00e9s kikapcsol\u00e1sa +label.disabling.vpn.access=VPN hozz\u00e1f\u00e9r\u00e9s kikapcsol\u00e1sa label.disassociate.profile.blade=Disassociate Profile from Blade -label.disbale.vnmc.device=Disable VNMC device -label.disk.allocated=Disk Allocated +label.disbale.vnmc.device=VNMC eszk\u00f6sz kikapcsol\u00e1sa +label.disk.allocated=Merevlemez lefoglalva label.disk.bytes.read.rate=Olvas\u00e1si r\u00e1ta (BPS) label.disk.bytes.write.rate=\u00cdr\u00e1si r\u00e1ta (BPS) label.disk.iops.max=IOPS maximum @@ -584,16 +608,17 @@ label.disk.iops.read.rate=Olvas\u00e1si r\u00e1ta (IOPS) label.disk.iops.total=IOPS \u00f6sszesen label.disk.iops.write.rate=\u00cdr\u00e1si r\u00e1ta (IOPS) label.disk.offering=Merevlemez aj\u00e1nlat -label.disk.provisioningtype=Provisioning Type +label.disk.provisioningtype=L\u00e9trehoz\u00e1s t\u00edpusa label.disk.read.bytes=Merevlemez olvas\u00e1s (Byte) label.disk.read.io=Merevlemez \u00edr\u00e1s (IO) label.disk.size.gb=Merevlemez m\u00e9ret (GB) label.disk.size=Merevlemez m\u00e9ret label.disk.total=Merevlemez \u00f6sszes -label.disk.volume=Disk Volume -label.disk.write.bytes=Disk Write (Bytes) -label.disk.write.io=Disk Write (IO) -label.display.text=Display Text +label.disk.volume=Merevlemez k\u00f6tet +label.disk.write.bytes=Merevlemez \u00edr\u00e1s (byte) +label.disk.write.io=Merevlemez \u00edr\u00e1s (IO) +label.display.name=Megjelen\u00edtend\u0151 n\u00e9v +label.display.text=Megjelen\u00edtend\u0151 sz\u00f6veg label.distributedrouter=Elosztott router label.dns.1=1. DNS label.dns.2=2. DNS @@ -605,26 +630,27 @@ label.domain.id=Tartom\u00e1ny ID label.domain.lower=domain label.domain.name=Tartom\u00e1ny n\u00e9v label.domain.router=Domain router -label.domain.suffix=DNS Domain Suffix (i.e., xyz.com) +label.domain.suffix=DNS dom\u00e9n v\u00e9gz\u0151d\u00e9s (pl. xyz.com) label.done=K\u00e9sz -label.double.quotes.are.not.allowed=Double quotes are not allowed -label.download.progress=Download Progress -label.drag.new.position=Drag to new position +label.double.quotes.are.not.allowed=A kett\u0151s id\u00e9z\u0151jel nem enged\u00e9lyezett +label.download.progress=Let\u00f6lt\u00e9s folyamat +label.drag.new.position=\u00daj helyre h\u00faz\u00e1s label.duration.in.sec=Id\u0151tartam (mp) label.dynamically.scalable=Dinakikusan sk\u00e1l\u00e1zhat\u00f3 -label.edit.acl.rule=Edit ACL rule -label.edit.affinity.group=Edit Affinity Group -label.edit=Edit -label.edit.lb.rule=Edit LB rule -label.edit.network.details=Edit network details -label.edit.project.details=Edit project details +label.edit.acl.rule=ACL szab\u00e1ly szerkeszt\u00e9se +label.edit.affinity.group=Affin\u00edt\u00e1si csoport szerkeszt\u00e9se +label.edit.lb.rule=LB szab\u00e1ly m\u00f3dos\u00edt\u00e1sa +label.edit.network.details=H\u00e1l\u00f3zat r\u00e9szleteinek szerkeszt\u00e9se +label.edit.project.details=Projekt r\u00e9szletek szerkeszt\u00e9se label.edit.region=Edit Region -label.edit.tags=Edit tags -label.edit.traffic.type=Edit traffic type -label.edit.vpc=Edit VPC -label.egress.default.policy=Egress Default Policy -label.egress.rule=Egress rule -label.egress.rules=Egress rules +label.edit.secondary.ips=M\u00e1sodlagos IP c\u00edmek m\u00f3dos\u00edt\u00e1sa +label.edit=Szerkeszt\u00e9s +label.edit.tags=Cimk\u00e9k szerkeszt\u00e9se +label.edit.traffic.type=Forgalom t\u00edpus szerkeszt\u00e9se +label.edit.vpc=VPC szerkeszt\u00e9se +label.egress.default.policy=Alap\u00e9rtelmezett egress szab\u00e1lyzat +label.egress.rule=Egress szab\u00e1ly +label.egress.rules=Egress szab\u00e1lyok label.elastic=Elasztikus label.elastic.IP=Elasztikus IP label.elastic.LB=Elasztikus LB @@ -633,53 +659,59 @@ label.email.lower=email label.enable.autoscale=Automatikus sk\u00e1l\u00e1z\u00e1s bekapcsol\u00e1sa label.enable.host=Kiszolg\u00e1l\u00f3 bekapcsol\u00e1sa label.enable.network.offering=H\u00e1l\u00f3zati aj\u00e1nlat bekapcsol\u00e1sa -label.enable.provider=Enable provider -label.enable.s3=Enable S3-backed Secondary Storage +label.enable.provider=Szolg\u00e1ltat\u00f3 bekapcsol\u00e1sa +label.enable.s3=S3-alap\u00fa m\u00e1sodlagos t\u00e1r bekapcsol\u00e1sa label.enable.swift=Swift enged\u00e9lyez\u00e9se -label.enable.vnmc.device=Enable VNMC device -label.enable.vnmc.provider=Enable VNMC provider -label.enable.vpc.offering=Enable VPC offering +label.enable.vnmc.device=VNMC eszk\u00f6z bekapcsol\u00e1sa +label.enable.vnmc.provider=VNMC szolg\u00e1ltat\u00f3 bekapcsol\u00e1sa +label.enable.vpc.offering=VPC aj\u00e1nlat bekapcsol\u00e1sa label.enable.vpn=Enable Remote Access VPN -label.enabling.vpn.access=Enabling VPN Access +label.enabling.vpn.access=VPN hozz\u00e1f\u00e9r\u00e9s enged\u00e9lyez\u00e9se label.enabling.vpn=VPN enged\u00e9lyez\u00e9se -label.end.IP=End IP -label.endpoint.or.operation=Endpoint or Operation +label.end.IP=Utols\u00f3 IP +label.endpoint.or.operation=V\u00e9gpont vagy m\u0171velet label.endpoint=V\u00e9gpont -label.end.port=End Port -label.end.reserved.system.IP=End Reserved system IP +label.end.port=Utols\u00f3 Port +label.end.reserved.system.IP=Utols\u00f3 elk\u00fcl\u00f6n\u00edtett rendszer IP label.end.vlan=Utols\u00f3 VLAN label.end.vxlan=Utols\u00f3 VXLAN -label.enter.token=Enter token +label.enter.token=Add meg a token-t\! label.error.code=Hibak\u00f3d label.error=Hiba label.error.upper=ERROR label.ESP.encryption=ESP titkos\u00edt\u00e1s label.ESP.hash=ESP Hash label.ESP.lifetime=ESP \u00e9lettartam (mp) -label.ESP.policy=ESP policy -label.esx.host=ESX/ESXi Host -label.event.archived=Event Archived -label.event.deleted=Event Deleted -label.example=Example -label.expunge=Expunge -label.external.link=External link +label.ESP.policy=ESP szab\u00e1lyzat +label.esx.host=ESX/ESXi kiszolg\u00e1l\u00f3 +label.event.archived=Esem\u00e9ny archiv\u00e1lva +label.event.deleted=Esem\u00e9ny t\u00f6r\u00f6lve +label.event=Esem\u00e9ny +label.every=Minden +label.example=P\u00e9lda +label.expunge=T\u00f6rl\u00e9s +label.external.link=K\u00fcls\u0151 hivatkoz\u00e1s label.extractable=Kicsomagolhat\u00f3 +label.extractable.lower=kicsomagolhat\u00f3 label.f5.details=F5 r\u00e9szletek label.f5=F5 label.failed=Hiba label.featured=Kiemelt label.fetch.latest=Legfrissebb let\u00f6lt\u00e9se -label.filterBy=Filter by +label.filterBy=Sz\u0171r\u00e9s label.firewall=T\u0171zfal label.first.name=Keresztn\u00e9v label.firstname.lower=keresztn\u00e9v label.format=Form\u00e1tum +label.format.lower=form\u00e1tum label.friday=P\u00e9ntek label.full.path=Teljes el\u00e9r\u00e9si \u00fatvonal label.full=Teljes label.gateway=\u00c1tj\u00e1r\u00f3 label.general.alerts=\u00c1ltal\u00e1nos riaszt\u00e1sok label.generating.url=URL gener\u00e1l\u00e1sa +label.globo.dns.configuration=GloboDNS konfigur\u00e1ci\u00f3 +label.globo.dns=GloboDNS label.gluster.volume=K\u00f6tet label.go.step.2=2. l\u00e9p\u00e9sre label.go.step.3=3. l\u00e9p\u00e9sre @@ -692,28 +724,28 @@ label.group.by.pod=Group by pod label.group.by.zone=Z\u00f3n\u00e1nk\u00e9nt csoportos\u00edtva label.group=Csoport label.group.optional=Csoport (opcion\u00e1lis) -label.gslb.assigned.lb=Assigned load balancing -label.gslb.assigned.lb.more=Assign more load balancing +label.gslb.assigned.lb=Hozz\u00e1rendelt terhel\u00e9seloszt\u00e1s +label.gslb.assigned.lb.more=T\u00f6bb terhel\u00e9seloszt\u00e1s hozz\u00e1rendel\u00e9se label.gslb.delete=GSLB t\u00f6rl\u00e9se label.gslb.details=GSLB r\u00e9szletek -label.gslb.domain.name=GSLB Domain Name +label.gslb.domain.name=GSLB dom\u00e9n n\u00e9v label.gslb=GSLB label.gslb.lb.details=Terhel\u00e9seloszt\u00f3 r\u00e9szletek label.gslb.lb.remove=Remove load balancing from this GSLB label.gslb.lb.rule=Terhel\u00e9seloszt\u00f3 szab\u00e1ly label.gslb.service=GSLB szolg\u00e1ltat\u00e1s -label.gslb.service.private.ip=GSLB service Private IP -label.gslb.service.public.ip=GSLB service Public IP +label.gslb.service.private.ip=GSLB szolg\u00e1ltat\u00e1s priv\u00e1t IP +label.gslb.service.public.ip=GSLB szolg\u00e1ltat\u00e1s publikus IP label.gslb.servicetype=Szolg\u00e1ltat\u00e1s t\u00edpus label.guest.cidr=Vend\u00e9g CIDR -label.guest.end.ip=Guest end IP -label.guest.gateway=Guest Gateway -label.guest.ip=Guest IP Address -label.guest.ip.range=Guest IP Range -label.guest.netmask=Guest Netmask -label.guest.network.details=Guest network details -label.guest.networks=Guest networks -label.guest.start.ip=Guest start IP +label.guest.end.ip=Utols\u00f3 veng\u00e9g IP +label.guest.gateway=Vend\u00e9g \u00e1tj\u00e1r\u00f3 +label.guest.ip.range=Vend\u00e9g IP tartom\u00e1ny +label.guest.ip=Vend\u00e9g IP c\u00edm +label.guest.netmask=Vend\u00e9g h\u00e1l\u00f3zati maszk +label.guest.network.details=Vend\u00e9g h\u00e1l\u00f3zat r\u00e9szletek +label.guest.networks=Vend\u00e9g h\u00e1l\u00f3zatok +label.guest.start.ip=Kezd\u0151 vend\u00e9g IP label.guest.traffic=Vend\u00e9g forgalom label.guest.traffic.vswitch.name=Guest Traffic vSwitch Name label.guest.traffic.vswitch.type=Guest Traffic vSwitch Type @@ -724,7 +756,7 @@ label.health.check=Ellen\u0151rz\u00e9s label.health.check.interval.in.sec=Ellen\u0151rz\u00e9s id\u0151k\u00f6z (mp) label.healthy.threshold=Eg\u00e9szs\u00e9ges k\u00fcsz\u00f6b label.help=Seg\u00edts\u00e9g -label.hide.ingress.rule=Hide Ingress Rule +label.hide.ingress.rule=Ingress szab\u00e1ly rejt\u00e9se label.hints=Tippek label.home=Kezd\u0151lap label.host.alerts=Kiszolg\u00e1l\u00f3 riaszt\u00e1sok @@ -735,7 +767,7 @@ label.hosts=Kiszolg\u00e1l\u00f3k label.host.tags=Kiszolg\u00e1l\u00f3 c\u00edmk\u00e9k label.hourly=\u00d3r\u00e1nk\u00e9nt label.hvm=HVM -label.hypervisor.capabilities=Hpervizor k\u00e9pess\u00e9gek +label.hypervisor.capabilities=Hipervizor k\u00e9pess\u00e9gek label.hypervisor=Hipervizor label.hypervisors=Hipervizorok label.hypervisor.snapshot.reserve=Hipervizor Snapshot Reserve @@ -744,14 +776,14 @@ label.hypervisor.version=Hipervizor verzi\u00f3 label.hyperv.traffic.label=HyperV Traffic Label label.id=ID label.IKE.DH=IKE DH -label.IKE.encryption=IKE Encryption +label.IKE.encryption=IKE titkos\u00edt\u00e1s label.IKE.hash=IKE Hash -label.IKE.lifetime=IKE lifetime (second) +label.IKE.lifetime=IKE \u00e9lettartam (mp) label.IKE.policy=IKE policy label.info=Inf\u00f3 label.info.upper=INFO -label.ingress.rule=Ingress Rule -label.initiated.by=Initiated By +label.ingress.rule=Ingress szab\u00e1ly +label.initiated.by=Kezdem\u00e9nyez\u0151 label.inside.port.profile=Inside Port Profile label.installWizard.addClusterIntro.subtitle=Mi a f\u00fcrt? label.installWizard.addClusterIntro.title=Csin\u00e1ljunk egy f\u00fcrt\u00f6t\! @@ -773,12 +805,13 @@ label.instance.limits=P\u00e9ld\u00e1ny korl\u00e1tok label.instance.name=P\u00e9ld\u00e1ny n\u00e9v label.instance.port=P\u00e9ld\u00e1ny port label.instance=P\u00e9ld\u00e1ny +label.instance.scaled.up=P\u00e9ld\u00e1ny \u00e1tm\u00e9retezve a k\u00e9rt aj\u00e1nlathoz label.instances=P\u00e9ld\u00e1nyok label.instanciate.template.associate.profile.blade=Instanciate Template and Associate Profile to Blade -label.intermediate.certificate=Intermediate certificate {0} +label.intermediate.certificate=K\u00f6zb\u00fcls\u0151 tan\u00fas\u00edtv\u00e1ny {0} label.internal.dns.1=1. bels\u0151 DNS label.internal.dns.2=2. bels\u0151 DNS -label.internal.lb.details=Internal LB details +label.internal.lb.details=Bels\u0151 LB r\u00e9szletek label.internallbvm=InternalLbVm label.internal.name=Bels\u0151 n\u00e9v label.interval.type=Id\u0151k\u00f6z t\u00edpus @@ -786,12 +819,12 @@ label.introduction.to.cloudstack=Bemutatkozik a CloudStack&\#8482 label.invalid.integer=\u00c9rv\u00e9nytelen eg\u00e9sz sz\u00e1m label.invalid.number=\u00c9rv\u00e9nytelen sz\u00e1m label.invitations=Megh\u00edv\u00f3k -label.invited.accounts=Invited accounts +label.invited.accounts=Megh\u00edvottak label.invite=Meghiv\u00e1s label.invite.to=Megh\u00edv\u00e1s\: label.ip.address=IP c\u00edm label.ipaddress=IP c\u00edm -label.ip.allocations=IP Allocations +label.ip.allocations=IP c\u00edmfoglal\u00e1sok label.ip=IP label.ip.limits=Publikus IP korl\u00e1tok label.ip.or.fqdn=IP vagy FQDN @@ -817,19 +850,21 @@ label.iscsi=iSCSI label.is.default=Alap\u00e9rtelmezett label.iso.boot=ISO Boot label.iso=ISO -label.isolated.networks=Isolated networks -label.isolation.method=Isolation method +label.isolated.networks=Izol\u00e1lt h\u00e1l\u00f3zatok +label.isolation.method=Izol\u00e1ci\u00f3 m\u00f3dszer label.isolation.mode=Izol\u00e1ci\u00f3 m\u00f3d -label.isolation.uri=Isolation URI +label.isolation.uri=Izol\u00e1ci\u00f3 URI label.is.redundant.router=Redund\u00e1ns label.is.shared=Osztott label.is.system=Rendszer -label.item.listing=Item listing +label.item.listing=Lista +label.japanese.keyboard=Jap\u00e1n billenty\u0171zet label.keep=Megtart\u00e1s +label.keyboard.language=Billenty\u0171zet kioszt\u00e1s label.keyboard.type=Billenty\u0171zet t\u00edpus label.key=Kulcs label.kvm.traffic.label=KVM traffic label -label.label=Cimke +label.label=C\u00edmke label.lang.arabic=Arab label.lang.brportugese=Brazil-portug\u00e1l label.lang.catalan=Katal\u00e1n @@ -846,14 +881,14 @@ label.lang.norwegian=Norv\u00e9g label.lang.polish=Lengyel label.lang.russian=Orosz label.lang.spanish=Spanyol -label.last.disconnected=Last Disconnected +label.last.disconnected=Utolj\u00e1ra lecsatlakozott label.last.name=Csal\u00e1dn\u00e9v label.lastname.lower=csal\u00e1dn\u00e9v label.latest.events=Utols\u00f3 esem\u00e9nyek label.launch=Ind\u00edt\u00e1s label.launch.vm=VM ind\u00edt\u00e1sa label.launch.zone=Z\u00f3na ind\u00edt\u00e1sa -label.lb.algorithm.leastconn=Least connections +label.lb.algorithm.leastconn=Legkevesebb kapcsolat label.lb.algorithm.roundrobin=K\u00f6rbe forg\u00f3 label.lb.algorithm.source=Forr\u00e1s label.LB.isolation=Terhel\u00e9seloszt\u00f3 izol\u00e1ci\u00f3 @@ -868,7 +903,6 @@ label.load.balancing.policies=Terhel\u00e9seloszt\u00f3 szab\u00e1lyok label.load.balancing=Terhel\u00e9seloszt\u00e1s label.loading=Bet\u00f6lt\u00e9s label.local=Helyi -label.local.storage.enabled=Helyi t\u00e1r bekapcsolva label.local.storage=Helyi t\u00e1r label.login=Bejelentkez\u00e9s label.logout=Kijelentkez\u00e9s @@ -876,32 +910,33 @@ label.lun=LUN label.LUN.number=LUN \# label.lxc.traffic.label=LXC Traffic Label label.make.project.owner=Make account project owner -label.managed=Managed -label.manage=Manage -label.management.ips=Management IP Addresses -label.management.server=Management Server +label.make.redundant=Redund\u00e1nss\u00e1 t\u00e9tel +label.managed=Vez\u00e9relt +label.management.ips=Vez\u00e9rl\u0151 IP c\u00edm +label.management.server=Vez\u00e9rl\u0151 szerver label.management=Vez\u00e9rl\u00e9s -label.manage.resources=Manage Resources -label.max.cpus=Max. CPU cores +label.manage.resources=Er\u0151forr\u00e1sok vez\u00e9rl\u00e9se +label.manage=Vez\u00e9rl\u00e9s +label.max.cpus=CPU magok max. label.max.guest.limit=Max guest limit label.maximum=Maximum label.max.instances=P\u00e9ld\u00e1nyok maxim\u00e1lis sz\u00e1ma -label.max.memory=Max. memory (MiB) -label.max.networks=Max. networks -label.max.primary.storage=Max. primary (GiB) -label.max.public.ips=Max. public IPs -label.max.secondary.storage=Max. secondary (GiB) -label.max.snapshots=Max. snapshots -label.max.templates=Max. templates -label.max.vms=Max. user VMs -label.max.volumes=Max. volumes -label.max.vpcs=Max. VPCs +label.max.memory=Max. mem\u00f3ria (MB) +label.max.networks=Max. h\u00e1l\u00f3zatok +label.max.primary.storage=Max. els\u0151dleges (GiB) +label.max.public.ips=Publikus IP c\u00edmek max. +label.max.secondary.storage=Max. m\u00e1sodlagos (GiB) +label.max.snapshots=Pillanatfelv\u00e9telek max. +label.max.templates=Sablonok max. +label.max.vms=Felhaszn\u00e1l\u00f3i VMek max. +label.max.volumes=K\u00f6tetek max. +label.max.vpcs=VPC-k max. label.may.continue=Most folytathatod label.md5.checksum=MD5 ellen\u00f6rz\u0151\u00f6sszeg label.memory.allocated=Allok\u00e1lt mem\u00f3ria label.memory.limits=Mem\u00f3ria korl\u00e1tok (MiB) label.memory.mb=Mem\u00f3ria (MB) -label.memory=Memory +label.memory=Mem\u00f3ria label.memory.total=Tejes mem\u00f3ria label.memory.used=Haszn\u00e1lt mem\u00f3ria label.menu.accounts=Sz\u00e1ml\u00e1k @@ -928,36 +963,39 @@ label.menu.my.instances=Saj\u00e1t p\u00e9ld\u00e1nyok label.menu.my.isos=Saj\u00e1t ISO-k label.menu.my.templates=Saj\u00e1t sablonok label.menu.network=H\u00e1l\u00f3zatok -label.menu.network.offerings=Network Offerings -label.menu.physical.resources=Physical Resources +label.menu.network.offerings=H\u00e1l\u00f3zati aj\u00e1nlatok +label.menu.physical.resources=Fizikai er\u0151forr\u00e1sok label.menu.regions=R\u00e9gi\u00f3k -label.menu.running.instances=Running Instances +label.menu.running.instances=Fut\u00f3 p\u00e9ld\u00e1nyok label.menu.security.groups=Biztons\u00e1gi csoportok -label.menu.service.offerings=Service Offerings +label.menu.service.offerings=Szolg\u00e1ltat\u00e1s aj\u00e1nlatok label.menu.snapshots=Pillanatfelv\u00e9telek +label.menu.sshkeypair=SSH kulcsp\u00e1r label.menu.stopped.instances=Le\u00e1ll\u00edtott p\u00e9ld\u00e1nyok label.menu.storage=T\u00e1r label.menu.system=Rendszer -label.menu.system.service.offerings=System Offerings +label.menu.system.service.offerings=Rendszer aj\u00e1nlatok label.menu.system.vms=Rendszer VM-ek label.menu.templates=Sablonok -label.menu.virtual.appliances=Virtual Appliances -label.menu.virtual.resources=Virtual Resources +label.menu.virtual.appliances=Virtu\u00e1lis k\u00e9sz\u00fcl\u00e9kek +label.menu.virtual.resources=Virtu\u00e1lis er\u0151forr\u00e1sok label.menu.volumes=K\u00f6tetek -label.menu.vpc.offerings=VPC Offerings +label.menu.vpc.offerings=VPC aj\u00e1nlatok label.migrate.instance.to.host=P\u00e9ld\u00e1ny mozgat\u00e1sa m\u00e1sik kiszolg\u00e1l\u00f3ra -label.migrate.instance.to=Migrate instance to -label.migrate.instance.to.ps=Migrate instance to another primary storage +label.migrate.instance.to.ps=P\u00e9ld\u00e1ny mozgat\u00e1sa m\u00e1sik els\u0151dleges t\u00e1rra +label.migrate.instance.to=P\u00e9ld\u00e1ny mozgat\u00e1sa\: label.migrate.lb.vm=Terhel\u00e9seloszt\u00f3 VM mozgat\u00e1sa -label.migrate.router.to=Migrate Router to -label.migrate.systemvm.to=Migrate System VM to +label.migrate.router.to=Router mozgat\u00e1sa\: +label.migrate.systemvm.to=Rendszer Vm mozgat\u00e1sa\: label.migrate.to.host=Mozgat\u00e1s kiszolg\u00e1l\u00f3ra label.migrate.to.storage=Mozgat\u00e1s t\u00e1rra label.migrate.volume=K\u00f6tet mozgat\u00e1sa label.migrate.volume.to.primary.storage=K\u00f6tet mozgat\u00e1sa m\u00e1sik els\u0151dleges t\u00e1rra label.minimum=Minimum label.min.instances=P\u00e9ld\u00e1nyok minim\u00e1lis sz\u00e1ma +label.min.past.the.hr=percben label.minute.past.hour=Perc +label.minutes.past.hour=percben az eg\u00e9sz \u00f3ra ut\u00e1n label.mode=M\u00f3d label.monday=H\u00e9tf\u0151 label.monthly=Havi @@ -973,13 +1011,13 @@ label.name.lower=N\u00e9v label.name=N\u00e9v label.name.optional=N\u00e9v (opcion\u00e1lis) label.na=Nem \u00e9rtelmezett -label.nat.port.range=NAT Port Range +label.nat.port.range=NAT port tartom\u00e1ny label.netmask=H\u00e1l\u00f3zati maszk label.netscaler.details=NetScaler r\u00e9szletek label.netScaler=NetScaler label.network.ACL=H\u00e1l\u00f3zati ACL label.network.ACLs=H\u00e1l\u00f3zati ACL-ek -label.network.ACL.total=Network ACL Total +label.network.ACL.total=H\u00e1l\u00f3zati ACL \u00f6sszesen label.network.addVM=Add network to VM label.network.cidr=H\u00e1l\u00f3zat CIDR label.network.desc=H\u00e1l\u00f3zat le\u00edr\u00e1s @@ -993,17 +1031,17 @@ label.networking.and.security=H\u00e1l\u00f3zat \u00e9s biztons\u00e1g label.network.label.display.for.blank.value=Alap\u00e9rtelmezett \u00e1tj\u00e1r\u00f3 haszn\u00e1lata label.network.limits=H\u00e1l\u00f3zat korl\u00e1tok label.network.name=H\u00e1l\u00f3zat n\u00e9v -label.network.offering.display.text=Network Offering Display Text -label.network.offering.id=Network Offering ID -label.network.offering.name=Network Offering Name -label.network.offering=Network Offering -label.network.rate.megabytes=Network Rate (MB/s) -label.network.rate=Network Rate (Mb/s) -label.network.read=Network Read -label.network.service.providers=Network Service Providers +label.network.offering.display.text=H\u00e1l\u00f3zat aj\u00e1nlat megjelen\u00edtend\u0151 sz\u00f6veg +label.network.offering=H\u00e1l\u00f3zat aj\u00e1nlat +label.network.offering.id=H\u00e1l\u00f3zat aj\u00e1nlat ID +label.network.offering.name=H\u00e1l\u00f3zat aj\u00e1nlat neve +label.network.rate=H\u00e1l\u00f3zati r\u00e1ta (Mb/mp) +label.network.rate.megabytes=H\u00e1l\u00f3zati r\u00e1ta (MB/mp) +label.network.read=H\u00e1l\u00f3zat olvas\u00e1s +label.network.service.providers=H\u00e1l\u00f3zat szolg\u00e1ltat\u00f3k label.networks=H\u00e1l\u00f3zatok label.network.type=H\u00e1l\u00f3zat t\u00edpus -label.network.write=Network Write +label.network.write=H\u00e1l\u00f3zat \u00edr\u00e1s label.new.password=\u00daj jelsz\u00f3 label.new.project=\u00daj projekt label.new=\u00daj @@ -1014,7 +1052,7 @@ label.nfs=NFS label.nfs.server=NFS kiszolg\u00e1l\u00f3 label.nfs.storage=NFS t\u00e1r label.nic.adapter.type=NIC adapter t\u00edpus -label.nicira.controller.address=Controller Address +label.nicira.controller.address=Vez\u00e9rl\u0151 c\u00edm label.nicira.l3gatewayserviceuuid=L3 Gateway Service Uuid label.nicira.nvp.details=Nicira NVP r\u00e9szletek label.nicira.transportzoneuuid=Transport Zone Uuid @@ -1044,7 +1082,7 @@ label.numretries=\u00dajrapr\u00f3b\u00e1lkoz\u00e1sok sz\u00e1ma label.ocfs2=OCFS2 label.offer.ha=Offer HA label.ok=Rendben -label.opendaylight.controllerdetail=OpenDaylight Controller Details +label.opendaylight.controllerdetail=OpenDaylight vez\u00e9rl\u0151 r\u00e9szletek label.opendaylight.controller=OpenDaylight vez\u00e9rl\u0151 label.opendaylight.controllers=OpenDaylight vez\u00e9rl\u0151k label.openDaylight=OpenDaylight @@ -1055,27 +1093,28 @@ label.os.preference=OS preferencia label.os.type=OS t\u00edpus label.other=M\u00e1s label.override.guest.traffic=Override Guest-Traffic -label.override.public.traffic=Override Public-Traffic +label.override.public.traffic=Publikus forgalom fel\u00fclb\u00edr\u00e1l\u00e1sa +label.ovm3.cluster=Nat\u00edv f\u00fcrt\u00f6z\u00e9s label.ovm.traffic.label=OVM traffic label label.ovs=OVS label.owned.public.ips=Owned Public IP Addresses label.owner.account=Owner Account label.owner.domain=Owner Domain label.palo.alto.details=Palo Alto r\u00e9szletek -label.PA.log.profile=Palo Alto Log Profile +label.PA.log.profile=Palo Alto log profil label.PA=Palo Alto -label.parent.domain=Parent Domain +label.parent.domain=Sz\u00fcl\u0151 dom\u00e9n label.passive=Passz\u00edv label.password.enabled=Jelsz\u00f3 bekapcsolva label.password=Jelsz\u00f3 label.password.lower=jelsz\u00f3 label.password.reset.confirm=Az \u00faj jelsz\u00f3 -label.PA.threat.profile=Palo Alto Threat Profile +label.PA.threat.profile=Palo Alto fenyeget\u00e9s profil label.path=\u00datvonal label.perfect.forward.secrecy=Perfect Forward Secrecy label.persistent=Perzisztens -label.physical.network.ID=Physical network ID -label.physical.network=Physical Network +label.physical.network=Fizikai h\u00e1l\u00f3zat +label.physical.network.ID=Fizikai h\u00e1l\u00f3zat ID label.PING.CIFS.password=PING CIFS jelsz\u00f3 label.PING.CIFS.username=PING CIFS felhaszn\u00e1l\u00f3 label.PING.dir=PING Directory @@ -1084,26 +1123,26 @@ label.PING.storage.IP=PING t\u00e1r IP label.planner.mode=Tervez\u0151 m\u00f3d label.please.specify.netscaler.info=Please specify Netscaler info label.please.wait=K\u00e9rlek v\u00e1rj\! -label.plugin.details=Plugin details -label.plugins=Plugins -label.pod.dedicated=Pod Dedicated +label.plugin.details=Plugin r\u00e9szletek +label.plugins=Plugin-ek +label.pod.dedicated=Pod dedik\u00e1lva label.pod.name=Pod n\u00e9v label.pod=Pod label.pods=Pod-ok -label.polling.interval.sec=Polling Interval (in sec) +label.polling.interval.sec=Lek\u00e9rdez\u00e9s id\u0151k\u00f6ze (mp) label.portable.ip=Mozgathat\u00f3 IP -label.portable.ip.range.details=Portable IP Range details -label.portable.ip.ranges=Portable IP Ranges -label.portable.ips=Portable IPs +label.portable.ip.range.details=Hordozhat\u00f3 IP tartom\u00e1ny r\u00e9szletek +label.portable.ip.ranges=Hordozhat\u00f3 IP tartom\u00e1nyok +label.portable.ips=Hordozhat\u00f3 IP c\u00edmek label.port.forwarding.policies=Port forwarding policies -label.port.forwarding=Port Forwarding +label.port.forwarding=Port tov\u00e1bb\u00edt\u00e1s label.port=Port -label.port.range=Port Range +label.port.range=Port tartom\u00e1ny label.PreSetup=PreSetup label.prev=El\u0151z\u0151 label.previous=El\u0151z\u0151 -label.primary.allocated=Primary Storage Allocated -label.primary.network=Primary Network +label.primary.allocated=Els\u0151dleges t\u00e1r elk\u00fcl\u00f6n\u00edtve +label.primary.network=Els\u0151dleges h\u00e1l\u00f3zat label.primary.storage.count=Primary Storage Pools label.primary.storage=Els\u0151dleges t\u00e1r label.primary.storage.limits=Primary Storage limits (GiB) @@ -1113,7 +1152,7 @@ label.private.interface=Private Interface label.private.ip=Priv\u00e1t IP c\u00edm label.private.ip.range=Priv\u00e1t IP tartom\u00e1ny label.private.ips=Priv\u00e1t IP c\u00edmek -label.privatekey=PKCS\#8 Private Key +label.privatekey=PKCS\#8 priv\u00e1t kulcs label.private.network=Priv\u00e1t h\u00e1l\u00f3zat label.private.port=Priv\u00e1t port label.private.zone=Priv\u00e1t z\u00f3na @@ -1137,7 +1176,7 @@ label.public.network=Publikus h\u00e1l\u00f3zat label.public.port=Publikus port label.public=Publikus label.public.traffic=Publikus forgalom -label.public.traffic.vswitch.name=Public Traffic vSwitch Name +label.public.traffic.vswitch.name=Publikus forgalom vSwitch n\u00e9v label.public.traffic.vswitch.type=Public Traffic vSwitch Type label.public.zone=Publikus z\u00f3na label.purpose=Rendeltet\u00e9s @@ -1154,12 +1193,14 @@ label.rbd.secret=Cephx secret label.reboot=\u00dajraind\u00edt\u00e1s label.recent.errors=Legut\u00f3bbi hib\u00e1k label.recover.vm=VM helyre\u00e1ll\u00edt\u00e1sa -label.redundant.router.capability=Redundant router capability -label.redundant.router=Redundant Router -label.redundant.state=Redundant state -label.refresh.blades=Refresh Blades +label.redundant.router.capability=Redund\u00e1ns router k\u00e9pess\u00e9g +label.redundant.router=Redund\u00e1ns router +label.redundant.state=Redund\u00e1ns \u00e1llapot +label.redundant.vpc=Redund\u00e1ns VPC +label.refresh.blades=Blade-k friss\u00edt\u00e9se label.refresh=Frissit\u00e9s -label.regionlevelvpc=Region Level VPC +label.region.details=R\u00e9gi\u00f3 r\u00e9szletek +label.regionlevelvpc=R\u00e9gi\u00f3 szint\u0171 VPC label.region=R\u00e9gi\u00f3 label.reinstall.vm=VM \u00fajratelep\u00edt\u00e9se label.related=Kapcsol\u00f3d\u00f3 @@ -1167,49 +1208,49 @@ label.release.account.lowercase=Release from account label.release.account=Release from Account label.release.dedicated.cluster=Release Dedicated Cluster label.release.dedicated.host=Dedik\u00e1lt kiszolg\u00e1l\u00f3 elenged\u00e9se -label.release.dedicated.pod=Release Dedicated Pod -label.release.dedicated.vlan.range=Release dedicated VLAN range +label.release.dedicated.pod=Dedik\u00e1lt pod elenged\u00e9se +label.release.dedicated.vlan.range=Dedik\u00e1lt VLAN tartom\u00e1ny elenged\u00e9se label.release.dedicated.zone=Dedik\u00e1lt z\u00f3na elenged\u00e9se label.remind.later=Eml\u00e9keztess k\u00e9s\u0151bb\! label.remove.ACL=ACL elt\u00e1vol\u00edt\u00e1sa -label.remove.egress.rule=Remove egress rule -label.remove.from.load.balancer=Removing instance from load balancer -label.remove.ingress.rule=Remove ingress rule -label.remove.ip.range=Remove IP range +label.remove.egress.rule=Egress szab\u00e1ly t\u00f6rl\u00e9se +label.remove.from.load.balancer=P\u00e9ld\u00e1ny elt\u00e1vol\u00edt\u00e1sa terhel\u00e9seloszt\u00f3b\u00f3l +label.remove.ingress.rule=Ingress szab\u00e1ly t\u00f6rl\u00e9se +label.remove.ip.range=IP tartom\u00e1ny elt\u00e1vol\u00edt\u00e1sa label.remove.ldap=LDAP elt\u00e1vol\u00edt\u00e1sa label.remove.network.offering=H\u00e1l\u00f3zati aj\u00e1nlat elt\u00e1vol\u00edt\u00e1sa -label.remove.pf=Remove port forwarding rule -label.remove.project.account=Remove account from project -label.remove.region=Remove Region +label.remove.pf=Port tov\u00e1bb\u00edt\u00f3 szab\u00e1ly elt\u00e1vol\u00edt\u00e1sa +label.remove.project.account=Sz\u00e1mla elt\u00e1vol\u00edt\u00e1sa a projektb\u0151l +label.remove.region=R\u00e9gi\u00f3 elt\u00e1vol\u00edt\u00e1sa label.remove.rule=Szab\u00e1ly elt\u00e1vol\u00edt\u00e1sa -label.remove.static.nat.rule=Remove static NAT rule +label.remove.static.nat.rule=Statikus NAT szab\u00e1ly elt\u00e1vol\u00edt\u00e1sa label.remove.static.route=Remove static route -label.remove.tier=Remove tier -label.remove.vm.from.lb=Remove VM from load balancer rule +label.remove.tier=R\u00e9teg elt\u00e1vol\u00edt\u00e1sa +label.remove.vm.from.lb=VM elt\u00e1vol\u00edt\u00e1sa terhel\u00e9seloszt\u00f3 szab\u00e1lyb\u00f3l label.remove.vm.load.balancer=VM elt\u00e1vol\u00edt\u00e1sa a terhel\u00e9seloszt\u00f3b\u00f3l -label.remove.vmware.datacenter=Remove VMware datacenter +label.remove.vmware.datacenter=VMware adatk\u00f6zpont elt\u00e1vol\u00edt\u00e1sa label.remove.vpc.offering=Remove VPC offering -label.remove.vpc=Remove VPC -label.removing=Removing +label.remove.vpc=VPC elt\u00e1vol\u00edt\u00e1sa +label.removing=T\u00f6rl\u00e9s label.removing.user=Felhaszn\u00e1l\u00f3 elt\u00e1vol\u00edt\u00e1sa -label.reource.id=Resource ID +label.reource.id=Er\u0151forr\u00e1s ID label.replace.acl=ACL csere -label.replace.acl.list=Replace ACL List -label.required=Required +label.replace.acl.list=ACL lista cser\u00e9je +label.required=Sz\u00fcks\u00e9ges label.requires.upgrade=Friss\u00edt\u00e9st ig\u00e9nyel label.reserved.ip.range=Elk\u00fcl\u00f6n\u00edtett IP c\u00edmtartom\u00e1ny label.reserved.system.gateway=Reserved system gateway -label.reserved.system.ip=Reserved System IP -label.reserved.system.netmask=Reserved system netmask +label.reserved.system.ip=Elk\u00fcl\u00f6n\u00edtett rendszer IP +label.reserved.system.netmask=Elk\u00fcl\u00f6n\u00edtett rendszer h\u00e1l\u00f3zati maszk label.resetVM=Reset VM -label.reset.VPN.connection=Reset VPN connection +label.reset.VPN.connection=VPN kapcsolat \u00fajraind\u00edt\u00e1sa label.resize.new.offering.id=\u00daj aj\u00e1nlat label.resize.new.size=\u00daj m\u00e9ret (GB) label.resize.shrink.ok=Cs\u00f6kkent\u00e9s OK label.resource=Er\u0151forr\u00e1s label.resource.limit.exceeded=Resource Limit Exceeded label.resource.limits=Er\u0151forr\u00e1s korl\u00e1tok -label.resource.name=Resource Name +label.resource.name=Er\u0151forr\u00e1s n\u00e9v label.resources=Er\u0151forr\u00e1sok label.resource.state=Er\u0151forr\u00e1s \u00e1llapot label.response.timeout.in.sec=V\u00e1lasz id\u0151t\u00fall\u00e9p\u00e9s (mp) @@ -1221,7 +1262,7 @@ label.retry.interval=\u00dajraprob\u00e1lkoz\u00e1s id\u0151k\u00f6z label.review=Ellen\u0151rz\u00e9s label.revoke.project.invite=Megh\u00edv\u00f3 visszavon\u00e1sa label.role=Szerep -label.root.certificate=Root certificate +label.root.certificate=F\u0151tan\u00fas\u00edtv\u00e1ny label.root.disk.controller=Root disk controller label.root.disk.offering=Root Disk Offering label.root.disk.size=Root merevlemez m\u00e9ret @@ -1239,7 +1280,7 @@ label.s3.max_error_retry=\u00dajrapr\u00f3b\u00e1lkoz\u00e1s max. label.s3.nfs.path=S3 NFS \u00fatvonal label.s3.nfs.server=S3 NFS kiszolg\u00e1l\u00f3 label.s3.secret_key=Titkos kulcs -label.s3.socket_timeout=Socket Timeout +label.s3.socket_timeout=Kapcsolat id\u0151t\u00fall\u00e9p\u00e9s label.s3.use_https=HTTPS haszn\u00e1lata label.saml.login=SAML bejelentkez\u00e9s label.saturday=Szombat @@ -1249,6 +1290,7 @@ label.saving.processing=Ment\u00e9s... label.scale.up.policy=SCALE UP POLICY label.scope=Hat\u00e1ly label.search=Keres\u00e9s +label.secondary.ips=M\u00e1sodlagos IP c\u00edmek label.secondary.isolated.vlan.id=M\u00e1sodlagos izol\u00e1lt VLAN ID label.secondary.staging.store.details=Secondary Staging Store details label.secondary.staging.store=Secondary Staging Store @@ -1271,14 +1313,14 @@ label.select.iso.or.template=V\u00e1lassz ISO-t vagy sablont\! label.select=Kiv\u00e1laszt\u00e1s label.select.offering=V\u00e1lassz aj\u00e1nlatot\! label.select.project=V\u00e1lassz projektet\! -label.select.region=Select region +label.select.region=R\u00e9gi\u00f3 kiv\u00e1laszt\u00e1sa label.select.template=Sablon kiv\u00e1laszt\u00e1sa label.select.tier=V\u00e1lassz r\u00e9teget\! label.select-view=Select view label.select.vm.for.static.nat=V\u00e1lassz VM-et a statikus NAT-hoz label.sent=Elk\u00fcld\u00f6tt label.server=Szerver -label.service.capabilities=Service Capabilities +label.service.capabilities=Szolg\u00e1ltat\u00e1s k\u00e9pess\u00e9gek label.service.offering=Szolg\u00e1ltat\u00e1s aj\u00e1nlat label.services=Szolg\u00e1ltat\u00e1sok label.service.state=Szolg\u00e1ltat\u00e1s \u00e1llapot @@ -1292,18 +1334,19 @@ label.setup.zone=Z\u00f3na be\u00e1ll\u00edt\u00e1sa label.SharedMountPoint=SharedMountPoint label.shared=Osztott label.show.advanced.settings=Halad\u00f3 szint\u0171 be\u00e1ll\u00edt\u00e1sok -label.show.ingress.rule=Show Ingress Rule -label.shutdown.provider=Shutdown provider +label.show.ingress.rule=Ingress szab\u00e1ly megjelen\u00edt\u00e9se +label.shutdown.provider=Szolg\u00e1ltat\u00f3 le\u00e1ll\u00edt\u00e1sa +label.simplified.chinese.keyboard=Egyszer\u0171s\u00edtett k\u00ednai billenty\u0171zet label.site.to.site.VPN=Site-to-site VPN label.size=M\u00e9ret label.skip.guide=Haszn\u00e1ltam m\u00e1r a CloudStack-et, kihagyom ezt az \u00fatmutat\u00f3t label.smb.domain=SMB dom\u00e9n label.smb.password=SMB jelsz\u00f3 label.smb.username=SMB felhaszn\u00e1l\u00f3n\u00e9v -label.snapshot.limits=Snapshot Limits +label.snapshot.limits=Pillanatfelv\u00e9tel korl\u00e1tok label.snapshot.name=Pillanatfelv\u00e9tel n\u00e9v label.snapshot=Pillanatfelv\u00e9tel -label.snapshot.schedule=Setup Recurring Snapshot +label.snapshot.schedule=Ism\u00e9tl\u0151d\u0151 pillanatfelv\u00e9telek be\u00e1ll\u00edt\u00e1sa label.snapshot.s=Pillanatfelv\u00e9tel(ek) label.snapshots=Pillanatfelv\u00e9telek label.SNMP.community=SNMP Community @@ -1314,21 +1357,22 @@ label.source.nat=Forr\u00e1s NAT label.source.nat.supported=SourceNAT Supported label.source.port=Forr\u00e1s port label.specify.IP.ranges=Add meg az IP tartom\u00e1nyokat\! -label.specify.vlan=Specify VLAN -label.specify.vxlan=Specify VXLAN +label.specify.vlan=VLAN megad\u00e1sa +label.specify.vxlan=VXLAN megad\u00e1sa label.SR.name=SR Name-Label -label.srx.details=SRX details +label.srx.details=SRX r\u00e9szletek label.srx=SRX +label.standard.us.keyboard=Amerikai (USA) szabv\u00e1nyos billenty\u0171zet label.start.IP=Kezd\u0151 IP label.start.lb.vm=Terhel\u00e9seloszt\u00f3 VM ind\u00edt\u00e1sa label.start.port=Kezd\u0151 port -label.start.reserved.system.IP=Start Reserved system IP +label.start.reserved.system.IP=Kezd\u0151 elk\u00fcl\u00f6n\u00edtett rendszer IP label.start.vlan=Els\u0151 VLAN label.start.vxlan=Els\u0151 VXLAN label.state=\u00c1llapot -label.static.nat.enabled=Static NAT Enabled -label.static.nat=Static NAT -label.static.nat.to=Static NAT to +label.static.nat.enabled=Statikus NAT bekapcsolva +label.static.nat=Statikus NAT +label.static.nat.to=Statikus NAT c\u00e9lpont label.static.nat.vm.details=Static NAT VM Details label.statistics=Statisztika label.status=\u00c1llapot @@ -1366,12 +1410,12 @@ label.storage.traffic=T\u00e1r forgalom label.storage=T\u00e1r label.storage.type=T\u00e1r t\u00edpus label.subdomain.access=Subdomain Access -label.submit=Submit +label.submit=Elk\u00fcld\u00e9s label.submitted.by=[Submitted by\: ] label.succeeded=Siker\u00fclt label.sunday=Vas\u00e1rnap label.super.cidr.for.guest.networks=Super CIDR for Guest Networks -label.supported.services=Supported Services +label.supported.services=T\u00e1mogatott szolg\u00e1ltat\u00e1sok label.supported.source.NAT.type=Supported Source NAT type label.supportsstrechedl2subnet=Supports Streched L2 Subnet label.suspend.project=Projekt felf\u00fcggeszt\u00e9se @@ -1403,22 +1447,24 @@ label.threshold=K\u00fcsz\u00f6b\u00e9rt\u00e9k label.thursday=Cs\u00fct\u00f6rt\u00f6k label.tier.details=R\u00e9teg r\u00e9szletei label.tier=R\u00e9teg +label.time.colon=Id\u0151\: label.time=Id\u0151 label.timeout=Id\u0151t\u00fall\u00e9p\u00e9s label.timeout.in.second = Id\u0151t\u00fall\u00e9p\u00e9s (mp) +label.timezone.colon=Id\u0151z\u00f3na label.time.zone=Id\u0151z\u00f3na label.timezone=Id\u0151z\u00f3na label.token=Token -label.total.cpu=Total CPU -label.total.CPU=Total CPU +label.total.cpu=\u00d6sszes CPU +label.total.CPU=\u00d6sszes CPU label.total.hosts=\u00d6sszes kiszolg\u00e1l\u00f3 label.total.memory=Mem\u00f3ria \u00f6sszesen label.total.of.ip=IP c\u00edmek \u00f6sszesen -label.total.of.vm=Total VMs -label.total.storage=Total Storage +label.total.of.vm=\u00d6sszes VM +label.total.storage=\u00d6sszes t\u00e1r label.total.virtual.routers=Total of Virtual Routers label.total.virtual.routers.upgrade=Total of Virtual Routers that require upgrade -label.total.vms=Total VMs +label.total.vms=\u00d6sszes VM label.traffic.label=Traffic label label.traffic.types=Traffic Types label.traffic.type=Traffic Type @@ -1427,6 +1473,7 @@ label.type.id=T\u00edpus ID label.type.lower=t\u00edpus label.type=T\u00edpus label.ucs=UCS +label.uk.keyboard=UK billenty\u0171zet label.unavailable=Nem el\u00e9rhet\u0151 label.unhealthy.threshold=Nem eg\u00e9szs\u00e9ges k\u00fcsz\u00f6b label.unlimited=Korl\u00e1tlan @@ -1438,7 +1485,7 @@ label.updating=Updating label.upgrade.required=Frissit\u00e9sre van sz\u00fcks\u00e9g label.upgrade.router.newer.template=Upgrade Router to Use Newer Template label.upload=Felt\u00f6lt\u00e9s -label.upload.volume=Upload volume +label.upload.volume=K\u00f6tet felt\u00f6lt\u00e9se label.url=URL label.usage.interface=Usage Interface label.usage.sanity.result=Usage Sanity Result @@ -1469,18 +1516,20 @@ label.vgpu.remaining.capacity=Megmarad\u00f3 kapac\u00edt\u00e1s label.vgpu.type=vGPU t\u00edpus label.vgpu=VGPU label.vgpu.video.ram=Video RAM -label.view.all=View all -label.view.console=View console -label.viewing=Viewing -label.view.more=View more +label.view.all=\u00d6sszes megtekint\u00e9se +label.view.console=Konzol megtekint\u00e9se +label.viewing=Megtekint\u00e9s +label.view.more=Tov\u00e1bbiak megtekint\u00e9se label.view=N\u00e9zet label.view.secondary.ips=M\u00e1sodlagos IP c\u00edmek megtekint\u00e9se -label.virtual.appliance.details=Virtual applicance details -label.virtual.appliances=Virtual Appliances -label.virtual.appliance=Virtual Appliance +label.virtual.appliance.details=Virtu\u00e1lis k\u00e9sz\u00fcl\u00e9k r\u00e9szletei +label.virtual.appliances=Virtu\u00e1lis k\u00e9sz\u00fcl\u00e9kek +label.virtual.appliance=Virtu\u00e1lis k\u00e9sz\u00fcl\u00e9k +label.virtual.machines=Virtu\u00e1lis g\u00e9pek +label.virtual.machine=Virtu\u00e1lis g\u00e9p label.virtual.networking=Virtu\u00e1lis h\u00e1l\u00f3zat label.virtual.network=Virtu\u00e1lis h\u00e1l\u00f3zat -label.virtual.routers.group.account=Virtual Routers group by account +label.virtual.routers.group.account=Virtu\u00e1lis routerek sz\u00e1ml\u00e1nk\u00e9nt label.virtual.routers.group.cluster=Virtual Routers group by cluster label.virtual.routers.group.pod=Virtual Routers group by pod label.virtual.routers.group.zone=Virtu\u00e1lis routerek z\u00f3n\u00e1nk\u00e9nt csoportos\u00edtva @@ -1488,15 +1537,15 @@ label.virtual.routers=Virtu\u00e1lis routerek label.virtual.router=Virtu\u00e1lis router label.vlan.id=VLAN/VNI ID label.vlan.only=VLAN -label.vlan.range.details=VLAN Range details -label.vlan.ranges=VLAN Range(s) +label.vlan.range.details=VLAN tartom\u00e1ny r\u00e9szletei +label.vlan.ranges=VLAN tartom\u00e1ny(ok) label.vlan.range=VLAN/VNI tartom\u00e1ny label.vlan=VLAN/VNI -label.vlan.vni.ranges=VLAN/VNI Range(s) +label.vlan.vni.ranges=VLAN/VNI tartom\u00e1ny(ok) label.vlan.vni.range=VLAN/VNI tartom\u00e1ny label.vm.add=P\u00e9ld\u00e1ny felv\u00e9tele label.vm.destroy=Elpuszt\u00edt -label.vm.display.name=VM display name +label.vm.display.name=VM megjelen\u00edtend\u0151 n\u00e9v label.VMFS.datastore=VMFS adatt\u00e1r label.vmfs=VMFS label.vm.id=VM ID @@ -1504,7 +1553,7 @@ label.vm.ip=VM IP c\u00edm label.vm.name=VM n\u00e9v label.vm.password=A VM jelszava label.vm.reboot=\u00dajraind\u00edt\u00e1s -label.VMs.in.tier=VMs in tier +label.VMs.in.tier=R\u00e9teg VM-ei label.vmsnapshot.current=Jelnlegi label.vmsnapshot.memory=Pillanatfelv\u00e9tel mem\u00f3ria label.vmsnapshot.parentname=Sz\u00fcl\u0151 @@ -1526,27 +1575,27 @@ label.volatile=Ill\u00e9kony label.volgroup=K\u00f6tet csoport label.volume.details=K\u00f6tet r\u00e9szletek label.volume=K\u00f6tet -label.volume.limits=Volume Limits +label.volume.limits=K\u00f6teg korl\u00e1tok label.volume.migrated=K\u00f6tet \u00e1tk\u00f6lt\u00f6ztetve label.volume.name=K\u00f6tet n\u00e9v label.volumes=K\u00f6tetek label.vpc.distributedvpcrouter=Distributed VPC Router label.vpc.id=VPC ID label.VPC.limits=VPC korl\u00e1tok -label.vpc.offering.details=VPC offering details -label.vpc.offering=VPC Offering +label.vpc.offering.details=VPC aj\u00e1nlat r\u00e9szletei +label.vpc.offering=VPC aj\u00e1nlat label.VPC.router.details=VPC router details label.vpc.supportsregionlevelvpc=Supports Region Level VPC -label.vpc.virtual.router=VPC Virtual Router +label.vpc.virtual.router=VPC virtu\u00e1lis router label.vpc=VPC label.VPN.connection=VPN kapcsolat label.vpn.customer.gateway=VPN \u00fcgyf\u00e9lkapu label.VPN.customer.gateway=VPN \u00fcgyf\u00e9lkapu -label.VPN.gateway=VPN Gateway +label.VPN.gateway=VPN \u00e1tj\u00e1r\u00f3 label.vpn=VPN -label.vsmctrlvlanid=Control VLAN ID -label.vsmpktvlanid=Packet VLAN ID -label.vsmstoragevlanid=Storage VLAN ID +label.vsmctrlvlanid=Vez\u00e9rl\u0151 VLAN ID +label.vsmpktvlanid=Csomag VLAN ID +label.vsmstoragevlanid=T\u00e1r VLAN ID label.vsphere.managed=vSphere Managed label.vswitch.name=vSwitch n\u00e9v label.vSwitch.type=vSwitch t\u00edpus @@ -1555,6 +1604,7 @@ label.vxlan.range=VXLAN tartom\u00e1ny label.vxlan=VXLAN label.waiting=V\u00e1rakoz\u00e1s label.warn=Figyelmeztet\u00e9s +label.warning=Figyelmeztet\u00e9s label.warn.upper=WARN label.wednesday=Szerda label.weekly=Heti @@ -1569,6 +1619,7 @@ label.zone.dedicated=A z\u00f3na dedik\u00e1lva label.zone.details=Z\u00f3na r\u00e9szletei label.zone.id=Z\u00f3na ID label.zone.lower=z\u00f3na +label.zone.name=Z\u00f3na n\u00e9v label.zone.step.1.title=1. l\u00e9p\u00e9s\: H\u00e1l\u00f3zat kiv\u00e1laszt\u00e1sa label.zone.step.2.title=2. l\u00e9p\u00e9s\: Z\u00f3na felv\u00e9tele label.zone.step.3.title=3. l\u00e9p\u00e9s\: Pod felv\u00e9tele @@ -1582,7 +1633,7 @@ label.zoneWizard.trafficType.public=Public\: Traffic between the internet and vi label.zoneWizard.trafficType.storage=Storage\: Traffic between primary and secondary storage servers, such as VM templates and snapshots label.zone=Z\u00f3na managed.state=Managed State -message.acquire.ip.nic=Please confirm that you would like to acquire a new secondary IP for this NIC.
NOTE\: You need to manually configure the newly-acquired secondary IP inside the virtual machine. +message.acquire.ip.nic=Er\u0151s\u00edtsd meg, hogy \u00faj m\u00e1sodlagos IP c\u00edmet k\u00e9rsz ehhez a NIC-hez\!
Megjegyz\u00e9s\: manu\u00e1lisan kell be\u00e1ll\u00edtanod a frissen beszerzett m\u00e1sodlagos IP c\u00edmet a virtu\u00e1lis g\u00e9pben. message.acquire.new.ip=Er\u0151s\u00edtsd meg, hogy \u00faj IP c\u00edmet k\u00e9rsz ennek a h\u00e1l\u00f3zatnak\! message.acquire.new.ip.vpc=Er\u0151s\u00edtsd meg, hogy \u00faj IP c\u00edmet k\u00e9rsz ennek a VPC-nek\! message.acquire.public.ip=V\u00e1lassz ki egy z\u00f3n\u00e1t, amelyikb\u0151l az \u00faj IP c\u00edmet k\u00e9rni akarod\! @@ -1595,7 +1646,7 @@ message.action.delete.disk.offering=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6l message.action.delete.domain=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt a dom\u00e9nt\! message.action.delete.external.firewall=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt a k\u00fcls\u0151 t\u0171zfalat\! Figyelmeztet\u00e9s\: Ha azt tervezed, hogy ugyanazt a k\u00fcls\u0151 t\u0171zfalat regisztr\u00e1lod \u00fajra, az eszk\u00f6z\u00f6n t\u00f6r\u00f6ln\u00f6d kell a haszn\u00e1lati adatokat. message.action.delete.external.load.balancer=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt a k\u00fcls\u0151 terhel\u00e9seloszt\u00f3t\! Figyelmeztet\u00e9s\: Ha azt tervezed, hogy ugyanazt a k\u00fcls\u0151 terhel\u00e9seloszt\u00f3t regisztr\u00e1lod \u00fajra, az eszk\u00f6z\u00f6n t\u00f6r\u00f6ln\u00f6d kell a haszn\u00e1lati adatokat. -message.action.delete.ingress.rule=Please confirm that you want to delete this ingress rule. +message.action.delete.ingress.rule=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt az ingress szab\u00e1lyt\! message.action.delete.ISO=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt az ISO-t\! message.action.delete.ISO.for.all.zones=Az ISO-t minden z\u00f3na haszn\u00e1lja. Er\u0151s\u00edtsd meg, hogy minden z\u00f3n\u00e1b\u00f3l t\u00f6r\u00f6lni akarod\! message.action.delete.network=Er\u0151s\u00edtsd meg, hogy le akarod t\u00f6r\u00f6lni ezt a h\u00e1l\u00f3zatot\! @@ -1610,7 +1661,7 @@ message.action.delete.service.offering=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00 message.action.delete.snapshot=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt a pillanatfelv\u00e9telt\! message.action.delete.system.service.offering=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt a rendszer szolg\u00e1ltat\u00e1s aj\u00e1nlatot\! message.action.delete.template=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt a sablont\! -message.action.delete.template.for.all.zones=The template is used by all zones. Please confirm that you want to delete it from all zones. +message.action.delete.template.for.all.zones=Ezt a sablont minden z\u00f3na haszn\u00e1lja. Er\u0151s\u00edtsd meg, hogy minden z\u00f3n\u00e1b\u00f3l t\u00f6r\u00f6lni szeretn\u00e9d\! message.action.delete.volume=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt a k\u00f6tetet\! message.action.delete.zone=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt a z\u00f3n\u00e1t\! message.action.destroy.instance=Er\u0151s\u00edtsd meg, hogy el akarod puszt\u00edtani ezt a p\u00e9ld\u00e1nyt\! @@ -1626,25 +1677,25 @@ message.action.download.iso=Er\u0151s\u00edtsd meg, hogy le akarod t\u00f6lteni message.action.download.template=Er\u0151s\u00edtsd meg, hogy le akarod t\u00f6lteni ezt a sablont\! message.action.enable.cluster=Er\u0151s\u00edtsd meg, hogy be akarod kapcsolni ezt a f\u00fcrt\u00f6t\! message.action.enable.maintenance=A kiszolg\u00e1l\u00f3 sikeresen felk\u00e9sz\u00fclt a karbantart\u00e1sra. Ez a m\u0171velet t\u00f6bb percet is ig\u00e9nybe vehet att\u00f3l f\u00fcgg\u0151en, mennyi VM fut rajta jelenleg. -message.action.enable.nexusVswitch=Please confirm that you want to enable this nexus 1000v -message.action.enable.physical.network=Please confirm that you want to enable this physical network. +message.action.enable.nexusVswitch=Er\u0151s\u00edtsd meg, hogy be akarod kapcsolni ezt a nexus 1000v-t\! +message.action.enable.physical.network=Er\u0151s\u00edtsd meg, hogy be akarod kapcsolni ezt a fizikai h\u00e1l\u00f3zatot. message.action.enable.pod=Er\u0151s\u00edtsd meg, hogy be akarod kapcsolni ezt a pod-ot\! message.action.enable.zone=Er\u0151s\u00edtsd meg, hogy be akarod kapcsolni ezt a z\u00f3n\u00e1t\! -message.action.expunge.instance=Please confirm that you want to expunge this instance. +message.action.expunge.instance=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt a p\u00e9ld\u00e1nyt\! message.action.force.reconnect=A kiszolg\u00e1l\u00f3 \u00fajrakapcsol\u00f3d\u00e1s\u00e1t siker\u00fclt kik\u00e9nyszer\u00edteni. Ez a folyamat t\u00f6bb percet veet ig\u00e9nybe. message.action.host.enable.maintenance.mode=A karbantart\u00e1s elind\u00edt\u00e1sa az \u00f6sszes a kiszolg\u00e1l\u00f3n fut\u00f3 p\u00e9ld\u00e1ny m\u00e1s kiszolg\u00e1l\u00f3ra k\u00f6lt\u00f6ztet\u00e9s\u00e9t ind\u00edtja el. message.action.instance.reset.password=Er\u0151s\u00edtsd meg, hogy meg akarod v\u00e1ltoztatni a virtu\u00e1lis g\u00e9p ROOT jelszav\u00e1t\! -message.action.manage.cluster=Please confirm that you want to manage the cluster. +message.action.manage.cluster=Er\u0151s\u00edtsd meg, hogy vez\u00e9relni akarod ezt a f\u00fcrt\u00f6t\! message.action.primarystorage.enable.maintenance.mode=Figyelmeztet\u00e9s\: az els\u0151dleges t\u00e1r karbantart\u00e1si m\u00f3dba helyez\u00e9se minden azt haszn\u00e1l\u00f3 VM-et le\u00e1ll\u00edt. Akarod folytatni? -message.action.reboot.instance=Please confirm that you want to reboot this instance. -message.action.reboot.router=All services provided by this virtual router will be interrupted. Please confirm that you want to reboot this router. -message.action.reboot.systemvm=Please confirm that you want to reboot this system VM. -message.action.release.ip=Please confirm that you want to release this IP. +message.action.reboot.instance=Er\u0151s\u00edtsd meg, hogy \u00fajra akarod ind\u00edtani ezt a p\u00e9ld\u00e1nyt\! +message.action.reboot.router=Minden a router \u00e1ltal ny\u00fajtott szolg\u00e1ltat\u00e1s megszakad. Er\u0151s\u00edtsd meg, hogy \u00fajra akarod ind\u00edtani a routert\! +message.action.reboot.systemvm=Er\u0151s\u00edtsd meg, hogy \u00fajra akarod ind\u00edtani ezt a rendszer VM-et\! +message.action.release.ip=Er\u0151s\u00edtsd meg, hogy el akarod engedni ezt az IP c\u00edmet\! message.action.remove.host=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt a kiszolg\u00e1l\u00f3t\! -message.action.reset.password.off=Your instance currently does not support this feature. +message.action.reset.password.off=A p\u00e9ld\u00e1ny nem t\u00e1mogatja ezt a lehet\u0151s\u00e9get. message.action.reset.password.warning=A p\u00e9ld\u00e1nyt le kell \u00e1ll\u00edtanod, miel\u00f6tt megpr\u00f3b\u00e1ln\u00e1d lecser\u00e9lni a jelszav\u00e1t. message.action.restore.instance=Er\u0151s\u00edtsd meg, hogy helyre akarod \u00e1ll\u00edtani ezt a p\u00e9ld\u00e1nyt\! -message.action.revert.snapshot=Please confirm that you want to revert the owning volume to this snapshot. +message.action.revert.snapshot=Er\u0151s\u00edtsd meg, hogy vissza akarod \u00e1ll\u00edtani a k\u00f6tetet erre a pillanatfelv\u00e9tlere\! message.action.start.instance=Er\u0151s\u00edtsd meg, hogy el akarod ind\u00edtani ezt a p\u00e9ld\u00e1nyt\! message.action.start.router=Er\u0151s\u00edtsd meg, hogy el akarod ind\u00edtani ezt a routert\! message.action.start.systemvm=Er\u0151s\u00edtsd meg, hogy el akarod ind\u00edtani ezt a rendszer VM-et\! @@ -1653,14 +1704,16 @@ message.action.stop.router=Minden ezzel a routerrel kapcsolatos szolg\u00e1ltat\ message.action.stop.systemvm=Er\u0151s\u00edtsd meg, hogy le akarod \u00e1ll\u00edtani ezt a rendszer VM-et\! message.action.take.snapshot=Er\u0151s\u00edtsd meg, hogy pillanatfelv\u00e9telt k\u00e9rsz err\u0151l a k\u00f6tetr\u0151l\! message.action.unmanage.cluster=Please confirm that you want to unmanage the cluster. -message.action.vmsnapshot.delete=Please confirm that you want to delete this VM snapshot. +message.action.vmsnapshot.delete=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt a VM pillanatfelv\u00e9telt\! message.action.vmsnapshot.revert=Revert VM snapshot message.activate.project=Biztosan aktiv\u00e1lni szeretn\u00e9d ezt a projektet? message.add.cluster=Add a hypervisor managed cluster for zone , pod message.add.cluster.zone=Add a hypervisor managed cluster for zone message.add.disk.offering=Add meg a k\u00f6vetkez\u0151 param\u00e9tereket az \u00faj merevlemez aj\u00e1nlat felv\u00e9tel\u00e9hez message.add.domain=Please specify the subdomain you want to create under this domain -message.add.firewall=Add a firewall to zone +message.added.new.nuage.vsp.controller=\u00daj Nicira Vsp vez\u00e9rl\u0151 felv\u00e9ve +message.added.vpc.offering=VPC aj\u00e1nlat felv\u00e9ve +message.add.firewall=T\u0171zfal felv\u00e9tele a z\u00f3n\u00e1ba message.add.guest.network=Please confirm that you would like to add a guest network message.add.host=Add meg a k\u00f6vetkez\u0151 adatokat az \u00faj kiszolg\u00e1l\u00f3 felv\u00e9tel\u00e9hez message.adding.host=Kiszolg\u00e1l\u00f3 felv\u00e9tele @@ -1669,8 +1722,8 @@ message.adding.Netscaler.provider=Netscaler szolg\u00e1ltat\u00f3 felv\u00e9tele message.add.ip.range=Add an IP range to public network in zone message.add.ip.range.direct.network=Add an IP range to direct network in zone message.add.ip.range.to.pod=

Add an IP range to pod\:

-message.additional.networks.desc=Please select additional network(s) that your virtual instance will be connected to. -message.add.load.balancer=Add a load balancer to zone +message.additional.networks.desc=V\u00e1laszd ki a tov\u00e1bbi h\u00e1l\u00f3zatokat, amelyhez a p\u00e9ld\u00e1ny csatlakozni fog\! +message.add.load.balancer=Terhel\u00e9seloszt\u00f3 felv\u00e9tele a z\u00f3n\u00e1ba message.add.load.balancer.under.ip=The load balancer rule has been added under IP\: message.add.network=Add a new network for zone\: message.add.new.gateway.to.vpc=Please specify the information to add a new gateway to this VPC. @@ -1679,11 +1732,11 @@ message.add.primary=Please specify the following parameters to add a new primary message.add.primary.storage=Add a new Primary Storage for zone , pod message.add.region=Please specify the required information to add a new region. message.add.secondary.storage=Add a new storage for zone -message.add.service.offering=Please fill in the following data to add a new compute offering. -message.add.system.service.offering=Please fill in the following data to add a new system service offering. -message.add.template=Please enter the following data to create your new template -message.add.volume=Please fill in the following data to add a new volume. -message.add.VPN.gateway=Please confirm that you want to add a VPN Gateway +message.add.service.offering=T\u00f6ltsd ki a k\u00f6vetkez\u0151 adatokat \u00faj sz\u00e1m\u00edt\u00e1si aj\u00e1nlat felv\u00e9tel\u00e9hez +message.add.system.service.offering=T\u00f6ltsd ki a k\u00f6vetkez\u0151 adatokat \u00faj rendszer szolg\u00e1ltat\u00e1s aj\u00e1nlat felv\u00e9tel\u00e9hez +message.add.template=Add meg a k\u00f6vetkez\u0151 adatokat \u00faj sablon l\u00e9trehoz\u00e1s\u00e1hoz +message.add.volume=T\u00f6ltsd ki a k\u00f6vetkez\u0151 adatokat \u00faj k\u00f6tet l\u00e9trehoz\u00e1s\u00e1hoz +message.add.VPN.gateway=Er\u0151s\u00edtsd meg, hogy \u00faj VPN \u00e1tj\u00e1r\u00f3t akarsz felvenni\! message.admin.guide.read=For VMware-based VMs, please read the dynamic scaling section in the admin guide before scaling. Would you like to continue?\\, message.advanced.mode.desc=Akkor v\u00e1laszd ezt a h\u00e1l\u00f3zat modellt, ha szeretn\u00e9d haszn\u00e1lni a VLAN t\u00e1mogat\u00e1st. Ez a h\u00e1l\u00f3zat modell biztos\u00edtja a legnagyobb rugalmass\u00e1got \u00e9s lehet\u0151v\u00e9 teszi, hogy a rendszergazd\u00e1k olyan aj\u00e1nlatokat biztos\u00edtsanak, mint a t\u0171zfalak, VPN vagy terhel\u00e9seloszt\u00f3k valamint a direkt \u00e9s virtu\u00e1lis h\u00e1l\u00f3zatok. message.advanced.security.group=V\u00e1laszd ezt, ha biztons\u00e1gi csoportokat akarsz haszn\u00e1lni a vend\u00e9g VM izol\u00e1ci\u00f3hoz\! @@ -1693,108 +1746,110 @@ message.after.enable.swift=Swift configured. Note\: When you leave this page, yo message.alert.state.detected=Alert state detected message.allow.vpn.access=Add meg a VPN felhaszn\u00e1l\u00f3 nev\u00e9t \u00e9s jelszav\u00e1t message.apply.snapshot.policy=You have successfully updated your current snapshot policy. -message.attach.iso.confirm=Please confirm that you want to attach the ISO to this virtual instance. -message.attach.volume=Please fill in the following data to attach a new volume. If you are attaching a disk volume to a Windows based virtual machine, you will need to reboot the instance to see the attached disk. +message.attach.iso.confirm=Er\u0151s\u00edtsd meg, hogy az ISO-t ehhez a virtu\u00e1lis g\u00e9phez akarod csatolni\! +message.attach.volume=T\u00f6ltsd ki a k\u00f6vetkez\u0151 adatokat a k\u00f6tet csatlakoztat\u00e1s\u00e1hoz\! Ha Windows-alap\u00fa virtu\u00e1lis g\u00e9phez csatlakoztatsz merevlemezt, akkor \u00fajra kell ind\u00edtanod a p\u00e9ld\u00e1nyt ahhoz, hogy l\u00e1sd a merevlemezt. message.basic.mode.desc=Akkor v\u00e1laszd ezt a h\u00e1l\u00f3zati modellt, ha *nem* akarsz VLAN t\u00e1mogat\u00e1st bekapcsolni. Ezen a h\u00e1l\u00f3zaton minden p\u00e9ld\u00e1ny k\u00f6zvetlen\u00fcl a h\u00e1l\u00f3zatt\u00f3l kap IP c\u00edmet \u00e9s a biztons\u00e1gi csoportok szolg\u00e1ltatnak biztons\u00e1got \u00e9s szegreg\u00e1ci\u00f3t. message.change.offering.confirm=Please confirm that you wish to change the service offering of this virtual instance. message.change.password=V\u00e1ltoztass jelsz\u00f3t\! -message.cluster.dedicated=Cluster Dedicated -message.cluster.dedication.released=Cluster dedication released -message.configure.all.traffic.types=You have multiple physical networks; please configure labels for each traffic type by clicking on the Edit button. +message.cluster.dedicated=F\u00fcrt dedik\u00e1lva +message.cluster.dedication.released=F\u00fcrt dedik\u00e1l\u00e1s elengedve +message.configure.all.traffic.types=T\u00f6bb fizikai h\u00e1l\u00f3zatod van. Kattints a \\'Szerkeszt\u00e9s\\' gombra \u00e9s \u00e1ll\u00edts be c\u00edmk\u00e9ket minden egyes forgalom t\u00edpushoz\! message.configure.ldap=Please confirm you would like to configure LDAP. -message.configuring.guest.traffic=Configuring guest traffic -message.configuring.physical.networks=Configuring physical networks -message.configuring.public.traffic=Configuring public traffic -message.configuring.storage.traffic=Configuring storage traffic +message.configuring.guest.traffic=Vend\u00e9g forgalom konfigur\u00e1l\u00e1sa +message.configuring.physical.networks=Fizikai h\u00e1l\u00f3zatok konfigur\u00e1l\u00e1sa +message.configuring.public.traffic=Publikus forgalom konfigur\u00e1l\u00e1sa +message.configuring.storage.traffic=T\u00e1r forgalom konfigur\u00e1l\u00e1sa message.confirm.action.force.reconnect=Er\u0151s\u00edtsd meg, hogy \u00fajrakapcsol\u00f3dni akarsz a kiszolg\u00e1l\u00f3hoz\! message.confirm.add.vnmc.provider=Please confirm you would like to add the VNMC provider. message.confirm.archive.alert=Er\u0151s\u00edtsd meg, hogy archiv\u00e1lni akarod ezt a riaszt\u00e1st\! -message.confirm.archive.event=Please confirm that you want to archive this event. +message.confirm.archive.event=Er\u0151s\u00edtsd meg, hogy archiv\u00e1lni szeretn\u00e9d az esem\u00e9nyt\! message.confirm.archive.selected.alerts=Er\u0151s\u00edtsd meg, hogy le akarod archiv\u00e1lni a kiv\u00e1lasztott riaszt\u00e1sokat\! -message.confirm.archive.selected.events=Please confirm you would like to archive the selected events -message.confirm.attach.disk=Are you sure you want to attach disk? -message.confirm.create.volume=Are you sure you want to create volume? -message.confirm.current.guest.CIDR.unchanged=Do you want to keep the current guest network CIDR unchanged? +message.confirm.archive.selected.events=Er\u0151s\u00edtsd meg, hogy archiv\u00e1lni szeretn\u00e9d a kiv\u00e1lasztott esem\u00e9nyeket\! +message.confirm.attach.disk=Biztosan csatolni szeretn\u00e9d a merevlemezt? +message.confirm.create.volume=Biztosan szeretn\u00e9l k\u00f6tetet l\u00e9trehozni? +message.confirm.current.guest.CIDR.unchanged=V\u00e1ltozatlanul akarod hagyni a vend\u00e9g h\u00e1l\u00f3zat CIDR-j\u00e9t? message.confirm.dedicate.cluster.domain.account=T\u00e9nyleg dedik\u00e1lni akarod ezt a f\u00fcrt\u00f6t egy dom\u00e9nnek/sz\u00e1ml\u00e1nak? message.confirm.dedicate.host.domain.account=T\u00e9nyleg dedik\u00e1lni akarod ezt a kiszolg\u00e1l\u00f3t egy dom\u00e9nnek vagy sz\u00e1ml\u00e1nak? -message.confirm.dedicate.pod.domain.account=Do you really want to dedicate this pod to a domain/account? -message.confirm.dedicate.zone=Do you really want to dedicate this zone to a domain/account? -message.confirm.delete.acl.list=Are you sure you want to delete this ACL list? +message.confirm.dedicate.pod.domain.account=T\u00e9nyleg dedik\u00e1lni szeretn\u00e9d ezt a pod-ot egy dom\u00e9nnek/sz\u00e1ml\u00e1nak? +message.confirm.dedicate.zone=Biztosan dedik\u00e1lni akarod ezt a z\u00f3n\u00e1t egy dom\u00e9nhoz/sz\u00e1ml\u00e1hoz? +message.confirm.delete.acl.list=Biztosan t\u00f6r\u00f6lni akarod ezt a ACL list\u00e1t? message.confirm.delete.alert=Biztosan t\u00f6r\u00f6lni akarod ezt a riaszt\u00e1st? -message.confirm.delete.BrocadeVcs=Please confirm that you would like to delete Brocade Vcs Switch -message.confirm.delete.ciscoASA1000v=Please confirm you want to delete CiscoASA1000v +message.confirm.delete.baremetal.rack.configuration=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod a Baremetal rack konfigur\u00e1ci\u00f3t\! +message.confirm.delete.BigSwitchBcf=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni szeretn\u00e9d ezt a BigSwitch BCF vez\u00e9rl\u0151t\! +message.confirm.delete.BrocadeVcs=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni szeretn\u00e9d a Brocade Vcs Switch-et +message.confirm.delete.ciscoASA1000v=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod a CiscoASA1000v-t message.confirm.delete.ciscovnmc.resource=Please confirm you want to delete CiscoVNMC resource -message.confirm.delete.F5=Please confirm that you would like to delete F5 -message.confirm.delete.internal.lb=Please confirm you want to delete Internal LB -message.confirm.delete.NetScaler=Please confirm that you would like to delete NetScaler -message.confirm.delete.NuageVsp=Please confirm that you would like to delete Nuage Virtualized Services Directory -message.confirm.delete.PA=Please confirm that you would like to delete Palo Alto +message.confirm.delete.F5=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni szeretn\u00e9d az F5-\u00f6t +message.confirm.delete.internal.lb=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt a bels\u0151 LB-t\! +message.confirm.delete.NetScaler=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni szeretn\u00e9d a NetScaler-t +message.confirm.delete.NuageVsp=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni szeretn\u00e9d a Muage Virtualized Services Directory-t +message.confirm.delete.PA=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni szeretn\u00e9d a Palo Alto-t message.confirm.delete.secondary.staging.store=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod a m\u00e1sodlagos t\u00e1rat\! -message.confirm.delete.SRX=Please confirm that you would like to delete SRX +message.confirm.delete.SRX=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni szeretn\u00e9d a SRX-et message.confirm.delete.ucs.manager=Please confirm that you want to delete UCS Manager -message.confirm.destroy.router=Please confirm that you would like to destroy this router +message.confirm.destroy.router=Er\u0151s\u00edtsd meg, hogy el akarod puszt\u00edtani ezt a routert message.confirm.disable.host=Er\u0151s\u00edtsd meg, hogy ki akarod kapcsolni a kiszolg\u00e1l\u00f3t message.confirm.disable.network.offering=Biztos vagy abban, hogy ki akarod kapcsolni ezt a h\u00e1l\u00f3zat aj\u00e1nlatot? -message.confirm.disable.provider=Please confirm that you would like to disable this provider +message.confirm.disable.provider=Er\u0151s\u00edtsd meg, hogy ki akarod kapcsolni ezt a szolg\u00e1ltat\u00f3t message.confirm.disable.vnmc.provider=Please confirm you would like to disable the VNMC provider. message.confirm.disable.vpc.offering=Biztos vagy abban, hogy ki akarod kapcsolni ezt a VPC aj\u00e1nlatot? message.confirm.enable.host=Er\u0151s\u00edtsd meg, hogy be akarod kapcsolni a kiszolg\u00e1l\u00f3t message.confirm.enable.network.offering=Biztos vagy abban, hogy be akarod kapcsolni ezt a h\u00e1l\u00f3zati aj\u00e1nlatot? -message.confirm.enable.provider=Please confirm that you would like to enable this provider +message.confirm.enable.provider=Er\u0151s\u00edtsd meg, hogy be szeretn\u00e9d kapcsolni ezt a szolg\u00e1ltat\u00f3t message.confirm.enable.vnmc.provider=Please confirm you would like to enable the VNMC provider. message.confirm.enable.vpc.offering=Biztos vagy abban, hogy be akarod kapcsolni ezt a VPC aj\u00e1nlatot? -message.confirm.join.project=Please confirm you wish to join this project. +message.confirm.join.project=Er\u0151s\u00edtsd meg, hogy csatlakozni szeretn\u00e9l a projekthez message.confirm.migrate.volume=El akarod k\u00f6lt\u00f6ztetni ezt a k\u00f6tetet? message.confirm.refresh.blades=Please confirm that you want to refresh blades. message.confirm.release.dedicated.cluster=El akarod engedni ezt a dedik\u00e1lt f\u00fcrt\u00f6t? message.confirm.release.dedicated.host=El akarod engedni ezt a dedik\u00e1lt kiszolg\u00e1l\u00f3t? message.confirm.release.dedicated.pod=El akarod engedni ezt a dedik\u00e1lt pod-ot? -message.confirm.release.dedicated.zone=Do you want to release this dedicated zone ? +message.confirm.release.dedicated.zone=El akarod engedni ezt a dedik\u00e1lt z\u00f3n\u00e1t? message.confirm.release.dedicate.vlan.range=Please confirm you want to release dedicated VLAN range -message.confirm.remove.event=Are you sure you want to remove this event? -message.confirm.remove.IP.range=Please confirm that you would like to remove this IP range. -message.confirm.remove.load.balancer=Please confirm you want to remove VM from load balancer +message.confirm.remove.event=Biztosan t\u00f6r\u00f6lni szeretn\u00e9d ezt az esem\u00e9nyt? +message.confirm.remove.IP.range=Er\u0151s\u00edtsd meg, hogy el akarod t\u00e1vol\u00edtani ezt az IP tartom\u00e1nyt +message.confirm.remove.load.balancer=Er\u0151s\u00edtsd meg, hogy el akarod t\u00e1vol\u00edtani a VM-et a terhel\u00e9seloszt\u00f3r\u00f3l\! message.confirm.remove.network.offering=Biztos vagy abban, hogy t\u00f6r\u00f6lni akarod ezt a h\u00e1l\u00f3zati aj\u00e1nlatot? message.confirm.remove.selected.alerts=Er\u0151s\u00edtsd meg, hogy el akarod t\u00e1vol\u00edtani a kiv\u00e1lasztott riaszt\u00e1sokat\! -message.confirm.remove.selected.events=Please confirm you would like to remove the selected events -message.confirm.remove.vmware.datacenter=Please confirm you want to remove VMware datacenter +message.confirm.remove.selected.events=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni szeretn\u00e9d a kiv\u00e1lasztott esem\u00e9nyeket +message.confirm.remove.vmware.datacenter=Er\u0151s\u00edtsd meg, hogy el akarod t\u00e1vol\u00edtani a VMware adatk\u00f6zpontot\! message.confirm.remove.vpc.offering=Biztos vagy abban, hogy t\u00f6r\u00f6lni akarod ezt a VPC aj\u00e1nlatot? -message.confirm.replace.acl.new.one=Do you want to replace the ACL with a new one? -message.confirm.scale.up.router.vm=Do you really want to scale up the Router VM ? -message.confirm.scale.up.system.vm=Do you really want to scale up the system VM ? -message.confirm.shutdown.provider=Please confirm that you would like to shutdown this provider -message.confirm.start.lb.vm=Please confirm you want to start LB VM -message.confirm.stop.lb.vm=Please confirm you want to stop LB VM +message.confirm.replace.acl.new.one=Le akarod cser\u00e9lni ez ACL list\u00e1t egy \u00fajjal? +message.confirm.scale.up.router.vm=Biztosan fel akarod m\u00e9retezni a router VM-et? +message.confirm.scale.up.system.vm=Biztosan fel akarod m\u00e9retezni a rendszer VM-et? +message.confirm.shutdown.provider=Er\u0151s\u00edtsd meg, hogy le akarod \u00e1ll\u00edtani ezt a szolg\u00e1ltat\u00f3t +message.confirm.start.lb.vm=Er\u0151s\u00edtsd meg, hogy el akarod ind\u00edtani az LB VM-et\! +message.confirm.stop.lb.vm=Er\u0151s\u00edtsd meg, hogy le akarod \u00e1ll\u00edtani az LB VM-et\! message.confirm.upgrade.router.newer.template=Please confirm that you want to upgrade router to use newer template -message.confirm.upgrade.routers.account.newtemplate=Please confirm that you want to upgrade all routers in this account to use newer template +message.confirm.upgrade.routers.account.newtemplate=Er\u0151s\u00edtsd meg, hogy minden a sz\u00e1mla minden router\u00e9t friss\u00edteni akarod az \u00faj sablonnal\! message.confirm.upgrade.routers.cluster.newtemplate=Please confirm that you want to upgrade all routers in this cluster to use newer template message.confirm.upgrade.routers.newtemplate=Please confirm that you want to upgrade all routers in this zone to use newer template message.confirm.upgrade.routers.pod.newtemplate=Please confirm that you want to upgrade all routers in this pod to use newer template -message.copy.iso.confirm=Please confirm that you wish to copy your ISO to +message.copy.iso.confirm=Er\u0151s\u00edtsd meg, hogy az ISO-t m\u00e1solni akarod\: message.copy.template=A XXX sablon m\u00e1sol\u00e1sa a z\u00f3n\u00e1b\u00f3l a message.copy.template.confirm=Biztos vagy benne, hogy le akarod m\u00e1solni a sablont? -message.create.template=Are you sure you want to create template? -message.create.template.vm=Create VM from template +message.create.template=Biztosan szeretn\u00e9l sablont l\u00e9trehozni? +message.create.template.vm=VM l\u00e9rehoz\u00e1sa sablonb\u00f3l message.create.template.volume=Please specify the following information before creating a template of your disk volume\: . Creation of the template can range from several minutes to longer depending on the size of the volume. -message.creating.cluster=Creating cluster -message.creating.guest.network=Creating guest network -message.creating.physical.networks=Creating physical networks -message.creating.pod=Creating pod -message.creating.primary.storage=Creating primary storage -message.creating.secondary.storage=Creating secondary storage +message.creating.cluster=F\u00fcrt l\u00e9trehoz\u00e1sa +message.creating.guest.network=Vend\u00e9g h\u00e1l\u00f3zat l\u00e9trehoz\u00e1sa +message.creating.physical.networks=Fizikai h\u00e1l\u00f3zat l\u00e9trehoz\u00e1sa +message.creating.pod=Pod l\u00e9trehoz\u00e1sa +message.creating.primary.storage=Els\u0151dleges t\u00e1r l\u00e9trehoz\u00e1sa +message.creating.secondary.storage=M\u00e1sodlagos t\u00e1r l\u00e9trehoz\u00e1sa message.creating.systemVM=A rendszer VM-ek l\u00e9trehoz\u00e1sa folyamatban (ez eltarthat egy darabig) message.creating.zone=Z\u00f3na l\u00e9trehoz\u00e1sa -message.decline.invitation=Are you sure you want to decline this project invitation? +message.decline.invitation=Biztosan el akarod utas\u00edtani ezt a projekt megh\u00edv\u00e1st? message.dedicated.zone.released=Z\u00f3na elengedve -message.dedicate.zone=Dedicating zone -message.delete.account=Please confirm that you want to delete this account. -message.delete.affinity.group=Please confirm that you would like to remove this affinity group. -message.delete.gateway=Please confirm you want to delete the gateway -message.delete.project=Are you sure you want to delete this project? -message.delete.user=Please confirm that you would like to delete this user. -message.delete.VPN.connection=Please confirm that you want to delete VPN connection +message.dedicate.zone=Z\u00f3na dedik\u00e1l\u00e1sa +message.delete.account=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni szeretn\u00e9d ezt a sz\u00e1ml\u00e1t\! +message.delete.affinity.group=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni szeretn\u00e9d ezt az affin\u00edt\u00e1s csoportot +message.delete.gateway=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt az \u00e1tj\u00e1r\u00f3t +message.delete.project=Biztosan t\u00f6r\u00f6lni akarod ezt a projektet? +message.delete.user=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni szeretn\u00e9d ezt a felhaszn\u00e1l\u00f3t\! +message.delete.VPN.connection=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod a VPN kapcsolatot message.delete.VPN.customer.gateway=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt a VPN \u00fcgyf\u00e9lkaput\! -message.delete.VPN.gateway=Please confirm that you want to delete this VPN Gateway +message.delete.VPN.gateway=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod ezt a VPN \u00e1tj\u00e1r\u00f3t\! message.desc.advanced.zone=\u00d6sszetettebb h\u00e1l\u00f3zati topol\u00f3gi\u00e1khoz. Ez a h\u00e1l\u00f3zat modell biztos\u00edtja a legnagyobb rugalmass\u00e1got a vend\u00e9g h\u00e1l\u00f3zatok fel\u00e9p\u00edt\u00e9s\u00e9ben \u00e9s olyan h\u00e1l\u00f3zati aj\u00e1nlatokat tesz lehet\u0151v\u00e9, mint a t\u0171zfalak, VPN vagy terhel\u00e9seloszt\u00f3k. message.desc.basic.zone=Adj meg egy h\u00e1l\u00f3zatot, amelyen minden egyes VM p\u00e9ld\u00e1ny k\u00f6zvetlen\u00fcl a h\u00e1l\u00f3zatt\u00f3l kap IP c\u00edmet. A vend\u00e9g rendszerek izol\u00e1ci\u00f3j\u00e1t 3. r\u00e9teg-b\u00e9li megold\u00e1sokkal, mint p\u00e9ld\u00e1ul biztons\u00e1gi csoportokkal (IP c\u00edm filterez\u00e9s) oldhat\u00f3 meg. message.desc.cluster=Minden pod-nak tartalmaznia kell egy vagy t\u00f6bb f\u00fcrt\u00f6t \u00e9s most l\u00e9trehozzuk az els\u0151 f\u00fcrt\u00f6t. A f\u00fcrt csoportos\u00edtja a kiszolg\u00e1l\u00f3kat. Egy f\u00fcrtben tal\u00e1lhat\u00f3 kiszolg\u00e1l\u00f3k ugyanolyan hardverrel rendelkeznek, ugyanolyan hipervizort futtatnak \u00e9s ugyanahhoz az els\u0151dleges t\u00e1rol\u00f3hoz f\u00e9rnek hozz\u00e1. Minden f\u00fcrt egy vagy t\u00f6bb kiszolg\u00e1l\u00f3t \u00e9s els\u0151dleges t\u00e1r szervert tartalmaz. @@ -1805,9 +1860,9 @@ message.desc.zone=A z\u00f3na a CloudStack legnagyobb egys\u00e9ge \u00e9s \u00e message.detach.disk=Biztosan la akarod v\u00e1lasztani a merevlemezt? message.detach.iso.confirm=Er\u0151s\u00edtsd meg, hogy le akarod v\u00e1lasztani az ISO-t a virtu\u00e1lis g\u00e9pr\u0151l\! message.disable.account=Er\u0151s\u00edtsd meg, hogy ki szeretn\u00e9d kapcsolni ezt a sz\u00e1ml\u00e1t. A sz\u00e1mla kikapcsol\u00e1s\u00e1val a sz\u00e1mla felhaszn\u00e1l\u00f3inak hozz\u00e1f\u00e9r\u00e9se az er\u0151forr\u00e1sokhoz megsz\u00fcnik. Minden fut\u00f3 virtu\u00e1lis g\u00e9p azonnal le lesz \u00e1ll\u00edtva. -message.disable.snapshot.policy=You have successfully disabled your current snapshot policy. +message.disable.snapshot.policy=Sikeresen kikapcsoltad a jelenlegi pillanatfelv\u00e9tel szab\u00e1lyt. message.disable.user=Er\u0151s\u00edtsd meg, hogy ki akarod kapcsolni a felhaszn\u00e1l\u00f3t\! -message.disable.vpn.access=Please confirm that you want to disable Remote Access VPN. +message.disable.vpn.access=Er\u0151s\u00edtsd meg, hogy ki akarod kapcsolni a t\u00e1voli VPN hozz\u00e1f\u00e9r\u00e9st\! message.disable.vpn=Biztosan ki akarod kapcsolni a VPN-t? message.disabling.network.offering=H\u00e1l\u00f3zat aj\u00e1nlat kikapcsol\u00e1sa message.disabling.vpc.offering=VPC aj\u00e1nlat kikapcsol\u00e1sa @@ -1816,13 +1871,13 @@ message.download.ISO=Az ISO let\u00f6lt\u00e9s\u00e9hez kattints 0 message.download.template=A sablon let\u00f6lt\u00e9s\u00e9hez kattints 00000 message.download.volume=A k\u00f6tet let\u00f6lt\u00e9s\u00e9hez kattints href\="\#">00000 message.download.volume.confirm=Er\u0151s\u00edtsd meg, hogy le akarod t\u00f6lteni ezt a k\u00f6tetet\! -message.edit.account=Edit ("-1" indicates no limit to the amount of resources create) +message.edit.account=Szerkeszt\u00e9s ("-1" jelzi az er\u0151forr\u00e1s haszn\u00e1lat\u00e1nak korl\u00e1tlans\u00e1g\u00e1t) message.edit.confirm=Er\u0151s\u00edtsd meg a v\u00e1ltoztat\u00e1sokat miel\u00f6tt a ment\u00e9sre kattintassz\! message.edit.limits=Hat\u00e1rozz meg korl\u00e1tokat a k\u00f6vetkez\u0151 er\u0151forr\u00e1sokhoz\! A "-1" jelzi a korl\u00e1tlanan felhaszn\u00e1l\u00e1st. message.edit.traffic.type=Please specify the traffic label you want associated with this traffic type. message.enable.account=Er\u0151s\u00edtsd meg, hogy be akarod kapcsolni ezt a sz\u00e1ml\u00e1t\! +message.enabled.vpn=A t\u00e1voli hozz\u00e1f\u00e9r\u00e9s\u0171 VPN jelenleg be van kapcsolva \u00e9s hozz\u00e1f\u00e9rhet\u0151 az IP c\u00edmmel message.enabled.vpn.ip.sec=Your IPSec pre-shared key is -message.enabled.vpn=Your Remote Access VPN is currently enabled and can be accessed via the IP message.enable.user=Er\u0151s\u00edtsd meg, hogy be akarod kapcsolni ezt a felhaszn\u00e1l\u00f3t\! message.enable.vpn.access=VPN is currently disabled for this IP Address. Would you like to enable VPN access? message.enable.vpn=Please confirm that you want Remote Access VPN enabled for this IP address. @@ -1832,12 +1887,12 @@ message.enabling.vpc.offering=VPC aj\u00e1nlat bekapcsol\u00e1sa message.enabling.zone.dots=Z\u00f3na enged\u00e9lyez\u00e9se... message.enabling.zone=Z\u00f3na bekapcsol\u00e1sa message.enter.seperated.list.multiple.cidrs=Add meg a CIDR list\u00e1t vessz\u0151kkel elv\u00e1laszva, ha egyn\u00e9l t\u00f6b van\! -message.enter.token=Please enter the token that you were given in your invite e-mail. +message.enter.token=Add meg a token-t, amit a megh\u00edv\u00f3ban kapt\u00e1l\! message.generate.keys=Er\u0151s\u00edtsd meg, hogy \u00faj kulcsokat szeretn\u00e9l gener\u00e1lni a felhaszn\u00e1l\u00f3nak\! -message.gslb.delete.confirm=Please confirm you want to delete this GSLB +message.gslb.delete.confirm=Er\u0151s\u00edtsd meg, hogy t\u00f6r\u00f6lni akarod a GSLB-t\! message.gslb.lb.remove.confirm=Please confirm you want to remove load balancing from GSLB -message.guest.traffic.in.advanced.zone=Guest network traffic is communication between end-user virtual machines. Specify a range of VLAN IDs to carry guest traffic for each physical network. -message.guest.traffic.in.basic.zone=Guest network traffic is communication between end-user virtual machines. Specify a range of IP addresses that CloudStack can assign to guest VMs. Make sure this range does not overlap the reserved system IP range. +message.guest.traffic.in.advanced.zone=A vend\u00e9g h\u00e1l\u00f3zat forgalom kommunik\u00e1ci\u00f3 v\u00e9gfelhaszn\u00e1l\u00f3i virtu\u00e1lis g\u00e9pek k\u00f6z\u00f6tt. Hat\u00e1rozz meg egy VLAN ID tartom\u00e1nyt a vend\u00e9g h\u00e1l\u00f3zatok forgalm\u00e1nak minden fizikai h\u00e1l\u00f3zathoz\! +message.guest.traffic.in.basic.zone=A vend\u00e9g h\u00e1l\u00f3zat forgalma kommunik\u00f3ci\u00f3 v\u00e9gfelhaszn\u00e1l\u00f3i virtu\u00e1lis g\u00e9pek k\u00f6z\u00f6tt. Hat\u00e1rozz meg egy IP c\u00edmtartom\u00e1nyt, amelyb\u0151l a CloudStack a virtu\u00e1lis g\u00e9pekhez rendelhet c\u00edmet. Gy\u0151z\u0151dj meg r\u00f3la, hogy ez a tartom\u00e1ny nincs \u00e1tfed\u00e9sben az elk\u00fcl\u00f6n\u00edtett rendszer IP tartom\u00e1nnyal\! message.host.dedicated=Dedik\u00e1lt kiszolg\u00e1l\u00f3 message.host.dedication.released=Kiszolg\u00e1l\u00f3 elengedve message.installWizard.click.retry=Kattints az ind\u00edt\u00e1s gombra az ism\u00e9tl\u00e9shez. @@ -1863,10 +1918,10 @@ message.installWizard.tooltip.addPrimaryStorage.path=(NFS eset\u00e9ben) In NFS message.installWizard.tooltip.addPrimaryStorage.server=(NFS, iSCSI vagy PreSetup eset\u00e9ben) A t\u00e1reszk\u00f6z IP vagy DNS c\u00edme. message.installWizard.tooltip.addSecondaryStorage.nfsServer=A m\u00e1sodlagos t\u00e1rat kiszolg\u00e1l\u00f3 NFS szerver IP c\u00edme message.installWizard.tooltip.addSecondaryStorage.path=A fenti szerveren kiexport\u00e1lt \u00fatvonal -message.installWizard.tooltip.addZone.dns1=These are DNS servers for use by guest VMs in the zone. These DNS servers will be accessed via the public network you will add later. The public IP addresses for the zone must have a route to the DNS server named here. -message.installWizard.tooltip.addZone.dns2=These are DNS servers for use by guest VMs in the zone. These DNS servers will be accessed via the public network you will add later. The public IP addresses for the zone must have a route to the DNS server named here. -message.installWizard.tooltip.addZone.internaldns1=These are DNS servers for use by system VMs in the zone. These DNS servers will be accessed via the private network interface of the System VMs. The private IP address you provide for the pods must have a route to the DNS server named here. -message.installWizard.tooltip.addZone.internaldns2=These are DNS servers for use by system VMs in the zone. These DNS servers will be accessed via the private network interface of the System VMs. The private IP address you provide for the pods must have a route to the DNS server named here. +message.installWizard.tooltip.addZone.dns1=Ezeket a DNS szervereket a z\u00f3na vend\u00e9g VM-ei haszn\u00e1lj\u00e1k. A DNS szervereket publikus h\u00e1l\u00f3zaton fogj\u00e1k el\u00e9rni, amelyet k\u00e9s\u0151bb veszel fel. A z\u00f3na publikus IP c\u00edmeinek hozz\u00e1 kell tudni f\u00e9rnie az itt megnevezett DNS szerverhez. +message.installWizard.tooltip.addZone.dns2=Ezeket a DNS szervereket a z\u00f3na vend\u00e9g VM-ei haszn\u00e1lj\u00e1k. A DNS szervereket publikus h\u00e1l\u00f3zaton fogj\u00e1k el\u00e9rni, amelyet k\u00e9s\u0151bb veszel fel. A z\u00f3na publikus IP c\u00edmeinek hozz\u00e1 kell tudni f\u00e9rnie az itt megnevezett DNS szerverhez. +message.installWizard.tooltip.addZone.internaldns1=Ezeket a DNS szervereket a z\u00f3na rendszer VM-ei haszn\u00e1lj\u00e1k. A DNS szervereket priv\u00e1t h\u00e1l\u00f3zaton fogj\u00e1k el\u00e9rni. A z\u00f3na priv\u00e1t IP c\u00edmeinek hozz\u00e1 kell tudni f\u00e9rnie az itt megnevezett DNS szerverhez. +message.installWizard.tooltip.addZone.internaldns2=Ezeket a DNS szervereket a z\u00f3na rendszer VM-ei haszn\u00e1lj\u00e1k. A DNS szervereket priv\u00e1t h\u00e1l\u00f3zaton fogj\u00e1k el\u00e9rni. A z\u00f3na priv\u00e1t IP c\u00edmeinek hozz\u00e1 kell tudni f\u00e9rnie az itt megnevezett DNS szerverhez. message.installWizard.tooltip.addZone.name=A z\u00f3na neve message.installWizard.tooltip.configureGuestTraffic.description=A h\u00e1l\u00f3zat le\u00edr\u00e1sa message.installWizard.tooltip.configureGuestTraffic.guestEndIp=The range of IP addresses that will be available for allocation to guests in this zone. If one NIC is used, these IPs should be in the same CIDR as the pod CIDR. @@ -1892,26 +1947,26 @@ message.migrate.volume=Er\u0151s\u00edtsd meg, hogy m\u00e1sik els\u0151dleges t message.network.addVM.desc=Please specify the network that you would like to add this VM to. A new NIC will be added for this network. message.network.addVMNIC=Please confirm that you would like to add a new VM NIC for this network. message.new.user=A k\u00f6vetkez\u0151ket adja meg \u00faj sz\u00e1mla l\u00e9trehoz\u00e1s\u00e1hoz -message.no.affinity.groups=You do not have any affinity groups. Please continue to the next step. +message.no.affinity.groups=Nincsenek affin\u00edt\u00e1si csoportaid. K\u00e9rlek folytasd a k\u00f6vetkez\u0151 l\u00e9p\u00e9ssel\! message.no.host.available=Nincs el\u00e9rhet\u0151 kiszolg\u00e1l\u00f3 az \u00e1tk\u00f6lt\u00f6ztet\u00e9shez message.no.network.support=A kiv\u00e1lasztott hipervizor, a vSphere nem t\u00e1mogat semmilyen tov\u00e1bbi h\u00e1l\u00f3zat be\u00e1ll\u00edt\u00e1st. Folytasd az 5. l\u00e9p\u00e9ssel\! message.no.network.support.configuration.not.true=Nincs olyan z\u00f3n\u00e1d, amelyben a biztons\u00e1gi csoportok be lenne kapcsolva, \u00edgy a tov\u00e1bbi h\u00e1l\u00f3zati lehet\u0151s\u00e9gek nem \u00e9rhet\u0151ek el. Folytasd az 5. l\u00e9p\u00e9ssel\! message.no.projects.adminOnly=Nincsenek projekteid.
K\u00e9rd meg az adminisztr\u00e1tort, hogy hozzon l\u00e9tre neked egyet\! message.no.projects=Nincsenek projekteid.
A Projektek szekci\u00f3ban tudsz \u00fajat csin\u00e1lni. -message.number.clusters=

\# of Clusters

-message.number.hosts=

\# of Hosts

-message.number.pods=

\# of Pods

-message.number.storage=

\# of Primary Storage Volumes

-message.number.zones=

\# of Zones

-message.pending.projects.1=You have pending project invitations\: -message.pending.projects.2=To view, please go to the projects section, then select invitations from the drop-down. +message.number.clusters=

F\u00fcrt\u00f6k sz\u00e1ma

+message.number.hosts=

Kiszolg\u00e1l\u00f3k sz\u00e1ma

+message.number.pods=

Pods-ok sz\u00e1ma

+message.number.storage=

Els\u0151dleges t\u00e1r k\u00f6teteksz\u00e1ma

+message.number.zones=

Z\u00f3n\u00e1k sz\u00e1ma

+message.pending.projects.1=Projekt megh\u00edv\u00f3k v\u00e1rnak r\u00e1d\: +message.pending.projects.2=A megtekint\u00e9shez menj a projektek szekci\u00f3hoz \u00e9s v\u00e1laszd a megh\u00edv\u00f3kat a leg\u00f6rd\u00fcl\u0151 men\u00fcb\u0151l\! message.please.add.at.lease.one.traffic.range=Please add at least one traffic range. message.please.proceed=Please proceed to the next step. message.please.select.a.configuration.for.your.zone=Please select a configuration for your zone. message.please.select.a.different.public.and.management.network.before.removing=Please select a different public and management network before removing message.please.select.networks=Please select networks for your virtual machine. message.please.wait.while.zone.is.being.created=Please wait while your zone is being created; this may take a while... -message.pod.dedication.released=Pod dedication released +message.pod.dedication.released=Pod dedik\u00e1ci\u00f3 elengedve message.portable.ip.delete.confirm=Please confirm you want to delete Portable IP Range message.project.invite.sent=Invite sent to user; they will be added to the project once they accept the invitation message.public.traffic.in.advanced.zone=Public traffic is generated when VMs in the cloud access the internet. Publicly-accessible IPs must be allocated for this purpose. End users can use the CloudStack UI to acquire these IPs to implement NAT between their guest network and their public network.

Provide at least one range of IP addresses for internet traffic. @@ -1920,7 +1975,7 @@ message.read.admin.guide.scaling.up=Please read the dynamic scaling section in t message.recover.vm=Er\u0151s\u00edtsd meg, hogy helyre akarod \u00e1ll\u00edtani a VM-et. message.redirecting.region=Redirecting to region... message.reinstall.vm=Figyelmeztet\u00e9s\: \u00d3vatosan\! Ha folytatod, a VM \u00fajra lesz telep\u00edtve a sablon alapj\u00e1n, a f\u0151 lemez\u00e9n tal\u00e1lhat\u00f3 adat elveszik. Amennyiben vannak tov\u00e1bbi merevlemezek, azok \u00e9rintetlenek maradnak. -message.remove.ldap=Are you sure you want to delete the LDAP configuration? +message.remove.ldap=Biztosan t\u00f6r\u00f6lni akarod az LDAP konfigur\u00e1ci\u00f3t? message.remove.region=Are you sure you want to remove this region from this management server? message.remove.vpc=Please confirm that you want to remove the VPC message.remove.vpn.access=Please confirm that you want to remove VPN access from the following user. @@ -1933,7 +1988,7 @@ message.restart.network=All services provided by this network will be interrupte message.restart.vpc=Please confirm that you want to restart the VPC message.restoreVM=Helyre akarod \u00e1ll\u00edtani a VM-et? message.security.group.usage=(A Ctrl-kattint\u00e1s haszn\u00e1lat\u00e1val tudod az \u00f6sszes alkalmazhat\u00f3 biztons\u00e1gi csoportot kiv\u00e1lasztani) -message.select.affinity.groups=Please select any affinity groups you want this VM to belong to\: +message.select.affinity.groups=V\u00e1lasszd ki azokat az affinit\u00e1si csoportokat, amelyekhez a VM tartozzon\: message.select.a.zone=A zone typically corresponds to a single datacenter. Multiple zones help make the cloud more reliable by providing physical isolation and redundancy. message.select.instance=Please select an instance. message.select.iso=Please select an ISO for your new virtual instance. @@ -1945,8 +2000,8 @@ message.set.default.NIC.manual=Please manually update the default NIC on the VM message.set.default.NIC=Please confirm that you would like to make this NIC the default for this VM. message.setup.physical.network.during.zone.creation.basic=When adding a basic zone, you can set up one physical network, which corresponds to a NIC on the hypervisor. The network carries several types of traffic.

You may also drag and drop other traffic types onto the physical network. message.setup.physical.network.during.zone.creation=When adding an advanced zone, you need to set up one or more physical networks. Each network corresponds to a NIC on the hypervisor. Each physical network can carry one or more types of traffic, with certain restrictions on how they may be combined.

Drag and drop one or more traffic types onto each physical network. -message.setup.successful=Cloud setup successful\! -message.snapshot.schedule=You can setup recurring snapshot schedules by selecting from the available options below and applying your policy preference +message.setup.successful=A felh\u0151 be\u00e1ll\u00edt\u00e1sa sikeres\! +message.snapshot.schedule=Az ism\u00e9tl\u0151d\u0151 pillanatfelv\u00e9teleket az al\u00e1bbi opci\u00f3k kiv\u00e1laszt\u00e1s\u00e1val tudod be\u00e1ll\u00edtani message.specifiy.tag.key.value=Please specify a tag key and value message.specify.url=K\u00e9rlek adj meg egy URL-t\! message.step.1.continue=V\u00e1lassz egy sablont vagy ISO-t a folytat\u00e1shoz @@ -1966,15 +2021,15 @@ message.tooltip.dns.2=A second DNS server name for use by VMs in the zone. The p message.tooltip.internal.dns.1=Name of a DNS server for use by CloudStack internal system VMs in the zone. The private IP address for the pods must have a route to this server. message.tooltip.internal.dns.2=Name of a DNS server for use by CloudStack internal system VMs in the zone. The private IP address for the pods must have a route to this server. message.tooltip.network.domain=A DNS suffix that will create a custom domain name for the network that is accessed by guest VMs. -message.tooltip.pod.name=A name for this pod. +message.tooltip.pod.name=N\u00e9v a pod-nak message.tooltip.reserved.system.gateway=Az \u00e1tj\u00e1r\u00f3 a pod kiszolg\u00e1l\u00f3i sz\u00e1m\u00e1ra message.tooltip.reserved.system.netmask=The network prefix that defines the pod subnet. Uses CIDR notation. message.tooltip.zone.name=N\u00e9v a z\u00f3n\u00e1nak. message.update.os.preference=Hat\u00e1rozz meg egy OS preferenci\u00e1t a kiszolg\u00e1l\u00f3hoz. Minden p\u00e9ld\u00e1ny, aminek hasonl\u00f3 preferenci\u00e1i vannak el\u0151sz\u00f6r ezen a kiszolg\u00e1l\u00f3n indul el. message.update.resource.count=Please confirm that you want to update resource counts for this account. -message.update.ssl.failed=Failed to update SSL Certificate. +message.update.ssl.failed=Nem siker\u00fclt az SSL tan\u00fas\u00edtv\u00e1nyt m\u00f3dos\u00edtani message.update.ssl=Please submit a new X.509 compliant SSL certificate chain to be updated to each console proxy and secondary storage virtual instance\: -message.update.ssl.succeeded=Update SSL Certificates succeeded +message.update.ssl.succeeded=Az SSL tan\u00fas\u00edtv\u00e1nyok m\u00f3dos\u00edt\u00e1sa sikeres message.validate.accept=Please enter a value with a valid extension. message.validate.creditcard=Adj meg egy \u00e9rv\u00e9nyes bankk\u00e1rtyasz\u00e1mot\! message.validate.date=Adj meg egy \u00e9rv\u00e9nyes d\u00e1tumot\! @@ -1994,17 +2049,17 @@ message.validate.range=Adj meg egy \u00e9rt\u00e9ket {0} \u00e9s {1} k\u00f6z\u0 message.validate.range.length=Adj meg egy {0} \u00e9s {1} k\u00f6z\u00f6tti hossz\u00fas\u00e1g\u00fa \u00e9rt\u00e9ket\! message.validate.URL=Adj meg egy \u00e9rv\u00e9nyes URL-t\! message.virtual.network.desc=A dedicated virtualized network for your account. The broadcast domain is contained within a VLAN and all public network access is routed out by a virtual router. -message.vm.create.template.confirm=Create Template will reboot the VM automatically. +message.vm.create.template.confirm=Sablon l\u00e9trehoz\u00e1sa automatikusan \u00fajraind\u00edtja a VM-et\! message.vm.review.launch=Please review the following information and confirm that your virtual instance is correct before launch. message.vnmc.available.list=VNMC is not available from provider list. message.vnmc.not.available.list=VNMC is not available from provider list. message.volume.create.template.confirm=Please confirm that you wish to create a template for this disk volume. Creation of the template can range from several minutes to longer depending on the size of the volume. message.waiting.for.builtin.templates.to.load=V\u00e1rakoz\u00e1s a be\u00e9p\u00edtett sablonk bet\u00f6lt\u00e9s\u00e9re... message.XSTools61plus.update.failed=Failed to update Original XS Version is 6.1\\+ field. Error\: -message.you.must.have.at.least.one.physical.network=You must have at least one physical network +message.you.must.have.at.least.one.physical.network=Sz\u00fcks\u00e9ged van legal\u00e1bb egy fizikai h\u00e1l\u00f3zatra. message.your.cloudstack.is.ready=A CloudStack k\u00e9szen \u00e1ll\! message.Zone.creation.complete=A z\u00f3na l\u00e9trehoz\u00e1sa befejez\u0151d\u00f6tt -message.zone.creation.complete.would.you.like.to.enable.this.zone=Zone creation complete. Would you like to enable this zone? +message.zone.creation.complete.would.you.like.to.enable.this.zone=A z\u00f3na l\u00e9trehoz\u00e1sa befejez\u0151d\u00f6tt. Szeretn\u00e9d bekapcsolni a z\u00f3n\u00e1t? message.zone.no.network.selection=The zone you selected does not have any choices for network selection. message.zone.step.1.desc=Please select a network model for your zone. message.zone.step.2.desc=Please enter the following info to add a new zone @@ -2040,5 +2095,6 @@ state.Starting=Indul state.Stopped=Le\u00e1ll\u00edtva state.Stopping=Le\u00e1ll\u00e1s folyamatban state.Suspended=Felf\u00fcggesztett +title.upload.volume=K\u00f6tet felt\u00f6lt\u00e9se ui.listView.filters.all=Mind ui.listView.filters.mine=Saj\u00e1t diff --git a/client/WEB-INF/classes/resources/messages_it_IT.properties b/client/WEB-INF/classes/resources/messages_it_IT.properties index a295226b599e..d423d31981a5 100644 --- a/client/WEB-INF/classes/resources/messages_it_IT.properties +++ b/client/WEB-INF/classes/resources/messages_it_IT.properties @@ -408,7 +408,6 @@ label.lb.algorithm.source=Sorgente label.LB.isolation=Isolamento di LB label.load.balancing=Bilanciamento di Carico label.load.balancing.policies=Politiche di Bilanciamento di Carico -label.local.storage.enabled=Local storage abilitato label.local.storage=Storage locale label.LUN.number=LUN \# label.management=Gestione diff --git a/client/WEB-INF/classes/resources/messages_ja_JP.properties b/client/WEB-INF/classes/resources/messages_ja_JP.properties index c952cc33e557..56f7ad3358e3 100644 --- a/client/WEB-INF/classes/resources/messages_ja_JP.properties +++ b/client/WEB-INF/classes/resources/messages_ja_JP.properties @@ -902,7 +902,6 @@ label.load.balancer=\u30ed\u30fc\u30c9 \u30d0\u30e9\u30f3\u30b5\u30fc label.load.balancing.policies=\u8ca0\u8377\u5206\u6563\u30dd\u30ea\u30b7\u30fc label.load.balancing=\u8ca0\u8377\u5206\u6563 label.loading=\u30ed\u30fc\u30c9\u3057\u3066\u3044\u307e\u3059 -label.local.storage.enabled=\u30ed\u30fc\u30ab\u30eb \u30b9\u30c8\u30ec\u30fc\u30b8\u3092\u6709\u52b9\u306b\u3059\u308b label.local.storage=\u30ed\u30fc\u30ab\u30eb \u30b9\u30c8\u30ec\u30fc\u30b8 label.local=\u30ed\u30fc\u30ab\u30eb label.login=\u30ed\u30b0\u30aa\u30f3 diff --git a/client/WEB-INF/classes/resources/messages_ko_KR.properties b/client/WEB-INF/classes/resources/messages_ko_KR.properties index 512fcd9206c4..a08b909c188c 100644 --- a/client/WEB-INF/classes/resources/messages_ko_KR.properties +++ b/client/WEB-INF/classes/resources/messages_ko_KR.properties @@ -639,7 +639,6 @@ label.load.balancer=\ub124\ud2b8\uc6cc\ud06c \ub85c\ub4dc \uacf5\uc720 \uc7a5\uc label.load.balancing.policies=\ub124\ud2b8\uc6cc\ud06c \ub85c\ub4dc \uacf5\uc720 \uc815\ucc45 label.load.balancing=\ub124\ud2b8\uc6cc\ud06c \ub85c\ub4dc \uacf5\uc720 label.loading=\ub85c\ub4dc \ud558\ub294 \uc911 -label.local.storage.enabled=\ub85c\uceec \uc2a4\ud1a0\ub9ac\uc9c0\ub294 \uc720\ud6a8 label.local.storage=\ub85c\uceec \uc2a4\ud1a0\ub9ac\uc9c0 label.local=\ub85c\uceec label.login=\ub85c\uadf8\uc778 diff --git a/client/WEB-INF/classes/resources/messages_nb_NO.properties b/client/WEB-INF/classes/resources/messages_nb_NO.properties index 94dcf0a072b3..30c3c7d0ed39 100644 --- a/client/WEB-INF/classes/resources/messages_nb_NO.properties +++ b/client/WEB-INF/classes/resources/messages_nb_NO.properties @@ -42,6 +42,8 @@ label.account=Konto label.account.lower=konto label.account.name=Kontonavn label.accounts=Kontoer +label.acl=ACL +label.acl.name=ACL Navn label.action.attach.disk.processing=Tilknytter Disk.... label.action.attach.disk=Tilknytt Disk label.action.attach.iso.processing=Tilknytter ISO.... @@ -285,6 +287,7 @@ label.api.version=API Versjon label.apply=Bruk label.app.name=CloudStack label.archive.alerts=Arkiver varsler +label.archive=Arkiv label.archive.events=Arkiver hendelser label.assign=Tildel label.attached.iso=Tilknyttet ISO @@ -298,6 +301,7 @@ label.back=Tilbake label.bandwidth=B\u00e5ndbredde label.basic=Basis label.basic.mode=Basismodus +label.bigswitch.bcf.details=BigSwitch BCF detaljer label.by.account=Etter Konto label.by.alert.type=Etter varseltype label.by.availability=Etter Tilgjengelighet @@ -324,6 +328,9 @@ label.character=Karakter label.cidr=CIDR label.CIDR.list=CIDR liste label.cidr.list=Kilde-CIDR +label.cisco.nexus1000v.ip.address=Nexus 1000v IP Addresse +label.cisco.nexus1000v.password=Nexus 1000v Passord +label.cisco.nexus1000v.username=Nexus 1000v Brukernavn label.clean.up=Rydd opp label.clear.list=T\u00f8m liste label.close=Lukk @@ -374,6 +381,7 @@ label.default=Standardverdi label.default.use=Standard bruk label.default.view=Standardvisning label.delete.alerts=Slette varsler +label.delete.ciscoASA1000v=Slett CiscoASA1000v label.delete.events=Slett hendelser label.delete.F5=Slett F5 label.delete.gateway=slett gateway @@ -449,9 +457,11 @@ label.end.IP=Slutt-IP label.end.port=Sluttport label.enter.token=Skriv inn koden label.error=Feil +label.error.upper=ERROR label.esx.host=ESX/ESXi vert label.example=Eksempel label.extractable=Utpakkbar +label.f5.details=F5 detaljer label.f5=F5 label.failed=Feilet label.fetch.latest=Hent siste @@ -495,6 +505,7 @@ label.hourly=Hver time label.hvm=HVM label.id=ID label.info=Info +label.info.upper=INFO label.installWizard.addClusterIntro.subtitle=Hva er en klynge? label.installWizard.addClusterIntro.title=La oss legge til en klynge label.installWizard.addHostIntro.subtitle=Hva er en vert? @@ -531,6 +542,15 @@ label.ip.or.fqdn=IP eller FQDN label.ip.range=IP-rekke label.ip.ranges=IP-rekker label.ips=IPer +label.ipv4.cidr=IPv4 CIDR +label.ipv4.dns1=IPv4 DNS1 +label.ipv4.dns2=IPv4 DNS2 +label.ipv4.end.ip=IPv4 Slutt IP +label.ipv4.start.ip=IPv4 Start IP +label.ipv6.address=IPv6 IP Adresse +label.ipv6.end.ip=IPv6 Slutt IP +label.ipv6.gateway=IPv6 Gateway +label.ipv6.start.ip=IPv6 Start IP label.is.default=Er standard label.iso=ISO label.isolated.networks=Isolerte nettverk @@ -566,6 +586,7 @@ label.lb.algorithm.roundrobin=Ringdistribusjon label.lb.algorithm.source=Kilde label.LB.isolation=LB-isolering label.ldap.configuration=LDAP Konfigurering +label.ldap.group.name=LDAP Gruppe label.ldap.port=LDAP port label.load.balancer=Lastbalanserer label.load.balancing=Lastbalansering @@ -651,6 +672,7 @@ label.name=Navn label.name.optional=Navn (Valgfritt) label.nat.port.range=NAT portrekke label.netmask=Nettmaske +label.netscaler.details=NetScaler detaljer label.netScaler=NetScaler label.network.ACL=Nettverk ACL label.network.ACLs=Nettverk ACLer @@ -675,6 +697,7 @@ label.nexusVswitch=Nexus 1000v label.nfs=NFS label.nfs.server=NFS Server label.nfs.storage=NFS Lagring +label.nicira.nvp.details=Nicira NVP detaljer label.nics=NICer label.no.data=Ingen data \u00e5 vise label.no=Nei @@ -691,10 +714,13 @@ label.ok=OK label.optional=Valgfritt label.order=Rekkef\u00f8lge label.os.type=OS-type +label.ovs=OVS +label.palo.alto.details=Palo Alto detaljer label.PA=Palo Alto label.passive=Passiv label.password.lower=passord label.password=Passord +label.password.reset.confirm=Passordet har blitt resatt til label.path=Sti label.physical.network=Fysisk nettverk label.physical.network.ID=Fysisk nettverksid @@ -744,6 +770,7 @@ label.public.traffic=Offentlig trafikk label.public.zone=Offentlig sone label.purpose=Form\u00e5l label.Pxe.server.type=PXE Servertype +label.qos.type=QoS Type label.rbd.id=Cephx user label.rbd.monitor=Ceph monitor label.rbd.pool=Ceph pool @@ -806,6 +833,8 @@ label.select.instance=Velg instans label.select.iso.or.template=Velg ISO eller mal label.select.offering=Velg tilbud label.select.project=Velg prosjekt +label.select.region=Velg region +label.select.template=Velg Mal label.select=Velg label.select-view=Velg visning label.select.vm.for.static.nat=Velg instans for statisk NAT @@ -836,6 +865,7 @@ label.specify.IP.ranges=Spesifiser IP-rekker label.specify.vlan=Spesifiser VLAN label.specify.vxlan=Spesifiser VXLAN label.SR.name=SR navnelapp +label.srx.details=SRX detaljer label.srx=SRX label.start.IP=Start-IP label.start.port=Start port @@ -972,6 +1002,7 @@ label.vxlan.range=VXLAN-rekke label.vxlan=VXLAN label.waiting=Venter label.warning=Advarsel +label.warn.upper=WARN label.warn=Varsle label.wednesday=Onsdag label.weekly=Ukentlig diff --git a/client/WEB-INF/classes/resources/messages_nl_NL.properties b/client/WEB-INF/classes/resources/messages_nl_NL.properties index e5582a7d2ee6..8b71d168e9cd 100644 --- a/client/WEB-INF/classes/resources/messages_nl_NL.properties +++ b/client/WEB-INF/classes/resources/messages_nl_NL.properties @@ -809,7 +809,6 @@ label.load.balancing=Load Balancing label.load.balancing.policies=Load balancing policies label.loading=Laden label.local=Lokaal -label.local.storage.enabled=Lokale opslag ingeschakeld label.local.storage=Lokale Opslag label.login=Login label.logout=Log uit diff --git a/client/WEB-INF/classes/resources/messages_pl.properties b/client/WEB-INF/classes/resources/messages_pl.properties index 491cb97da231..28e9fea1920d 100644 --- a/client/WEB-INF/classes/resources/messages_pl.properties +++ b/client/WEB-INF/classes/resources/messages_pl.properties @@ -284,7 +284,6 @@ label.lb.algorithm.leastconn=Ostatnie po\u0142\u0105czenie label.level=Poziom label.loading=Wczytywanie label.local=Lokalne -label.local.storage.enabled=Pami\u0119\u0107 lokalna w\u0142\u0105czona label.local.storage=Pami\u0119\u0107 lokalna label.login=Zaloguj label.logout=Wyloguj diff --git a/client/WEB-INF/classes/resources/messages_pt_BR.properties b/client/WEB-INF/classes/resources/messages_pt_BR.properties index bc3d912122d1..78d2b6bdc652 100644 --- a/client/WEB-INF/classes/resources/messages_pt_BR.properties +++ b/client/WEB-INF/classes/resources/messages_pt_BR.properties @@ -715,7 +715,6 @@ label.load.balancing=Balanceamento de Carga label.load.balancing.policies=Pol\u00edticas de balanceamento de carga label.loading=Carregando label.local=Local -label.local.storage.enabled=Storage local habilitada label.local.storage=Storage Local label.login=Entrar label.logout=Sair diff --git a/client/WEB-INF/classes/resources/messages_ru_RU.properties b/client/WEB-INF/classes/resources/messages_ru_RU.properties index c9cf295b40bd..94f2481a425e 100644 --- a/client/WEB-INF/classes/resources/messages_ru_RU.properties +++ b/client/WEB-INF/classes/resources/messages_ru_RU.properties @@ -675,7 +675,6 @@ label.load.balancer=\u0411\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432 label.load.balancing.policies=\u041f\u043e\u043b\u0438\u0442\u0438\u043a\u0438 \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u043a\u0438 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 label.load.balancing=\u0411\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u043a\u0430 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 label.loading=\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 -label.local.storage.enabled=\u041b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043e label.local.storage=\u041b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 label.local=\u041b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 label.login=\u0412\u0445\u043e\u0434 diff --git a/client/WEB-INF/classes/resources/messages_zh_CN.properties b/client/WEB-INF/classes/resources/messages_zh_CN.properties index 93c13424cccc..698453856148 100644 --- a/client/WEB-INF/classes/resources/messages_zh_CN.properties +++ b/client/WEB-INF/classes/resources/messages_zh_CN.properties @@ -861,7 +861,6 @@ label.load.balancer=\u8d1f\u8f7d\u5e73\u8861\u5668 label.load.balancing.policies=\u8d1f\u8f7d\u5e73\u8861\u7b56\u7565 label.load.balancing=\u8d1f\u8f7d\u5e73\u8861 label.loading=\u6b63\u5728\u52a0\u8f7d -label.local.storage.enabled=\u5df2\u542f\u7528\u672c\u5730\u5b58\u50a8 label.local.storage=\u672c\u5730\u5b58\u50a8 label.local=\u672c\u5730 label.login=\u767b\u5f55 From 67ad418299ae1849a1419348ff3fcbecef7848db Mon Sep 17 00:00:00 2001 From: sanjeev Date: Fri, 22 May 2015 12:20:32 +0530 Subject: [PATCH 099/175] CLOUDSTACK-8504: Remove creating network with RVR by default This closes #283 --- test/integration/component/test_egress_fw_rules.py | 1 - 1 file changed, 1 deletion(-) diff --git a/test/integration/component/test_egress_fw_rules.py b/test/integration/component/test_egress_fw_rules.py index de222d3ec922..4082981f73cd 100755 --- a/test/integration/component/test_egress_fw_rules.py +++ b/test/integration/component/test_egress_fw_rules.py @@ -108,7 +108,6 @@ def __init__(self): "serviceCapabilityList": { "SourceNat": { "SupportedSourceNatTypes": "peraccount", - "RedundantRouter": "true" } }, }, From 22ee66eea686bbedc45aa2325f7bc344b94961fc Mon Sep 17 00:00:00 2001 From: Daan Hoogland Date: Fri, 22 May 2015 09:17:55 +0200 Subject: [PATCH 100/175] debian snapshot packaging break on merged versioning --- debian/rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/rules b/debian/rules index 9768e5a34b18..b27b3c4821ad 100755 --- a/debian/rules +++ b/debian/rules @@ -3,7 +3,7 @@ DEBVERS := $(shell dpkg-parsechangelog | sed -n -e 's/^Version: //p') VERSION := $(shell echo '$(DEBVERS)' | sed -e 's/^[[:digit:]]*://' -e 's/[~-].*//') -MVNADD := $(shell if echo '$(DEBVERS)' | grep -q snapshot; then echo ; fi ) +MVNADD := $(shell if echo '$(DEBVERS)' | grep -q snapshot; then echo -SNAPSHOT; fi ) PACKAGE = $(shell dh_listpackages|head -n 1|cut -d '-' -f 1) SYSCONFDIR = "/etc" DESTDIR = "debian/tmp" From 424b5bb8d0a86639f539e655aa08960679e46627 Mon Sep 17 00:00:00 2001 From: Gaurav Aradhye Date: Fri, 22 May 2015 15:36:17 +0530 Subject: [PATCH 101/175] CLOUDSTACK-8492: Fix string case issue Signed-off-by: Gaurav Aradhye This closes #284 --- test/integration/component/test_snapshots.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/component/test_snapshots.py b/test/integration/component/test_snapshots.py index 4ff5411ed018..655a287b5601 100644 --- a/test/integration/component/test_snapshots.py +++ b/test/integration/component/test_snapshots.py @@ -169,7 +169,7 @@ def setUpClass(cls): cls.services['mode'] = cls.zone.networktype cls._cleanup = [] cls.unsupportedHypervisor = False - cls.hypervisor = get_hypervisor_type(cls.api_client) + cls.hypervisor = str(get_hypervisor_type(cls.api_client)).lower() if cls.hypervisor.lower() in ['hyperv', 'lxc']: cls.unsupportedHypervisor = True return From 1c81b241e7914b24b06c3b7b3ee98bc0d3b4f68b Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Fri, 22 May 2015 10:11:15 +0100 Subject: [PATCH 102/175] CLOUDSTACK-8505: Don't allow non-POST requests for default login API We add a new contract to pass Http request to authentication plugin system. In the default login API, we disallow non-POST requests. Signed-off-by: Rohit Yadav (cherry picked from commit 9e9b231672e934292f9940d1363039a553fc7ad9) Signed-off-by: Rohit Yadav Conflicts: api/src/org/apache/cloudstack/api/auth/APIAuthenticator.java plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/GetServiceProviderMetaDataCmd.java plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmd.java plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LogoutAPIAuthenticatorCmd.java plugins/user-authenticators/saml2/test/org/apache/cloudstack/api/command/GetServiceProviderMetaDataCmdTest.java plugins/user-authenticators/saml2/test/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmdTest.java plugins/user-authenticators/saml2/test/org/apache/cloudstack/api/command/SAML2LogoutAPIAuthenticatorCmdTest.java server/src/com/cloud/api/ApiServlet.java server/src/com/cloud/api/auth/DefaultLoginAPIAuthenticatorCmd.java server/src/com/cloud/api/auth/DefaultLogoutAPIAuthenticatorCmd.java server/test/com/cloud/api/ApiServletTest.java --- .../apache/cloudstack/api/auth/APIAuthenticator.java | 3 ++- .../api/command/GetServiceProviderMetaDataCmd.java | 3 ++- .../api/command/SAML2LoginAPIAuthenticatorCmd.java | 3 ++- .../api/command/SAML2LogoutAPIAuthenticatorCmd.java | 3 ++- .../api/command/GetServiceProviderMetaDataCmdTest.java | 8 ++++++-- .../api/command/SAML2LoginAPIAuthenticatorCmdTest.java | 10 +++++++--- .../command/SAML2LogoutAPIAuthenticatorCmdTest.java | 8 ++++++-- server/src/com/cloud/api/ApiServlet.java | 2 +- .../api/auth/DefaultLoginAPIAuthenticatorCmd.java | 8 ++++++-- .../api/auth/DefaultLogoutAPIAuthenticatorCmd.java | 3 ++- server/test/com/cloud/api/ApiServletTest.java | 6 +++--- 11 files changed, 39 insertions(+), 18 deletions(-) diff --git a/api/src/org/apache/cloudstack/api/auth/APIAuthenticator.java b/api/src/org/apache/cloudstack/api/auth/APIAuthenticator.java index 00875614f7c9..7e33b1347db3 100644 --- a/api/src/org/apache/cloudstack/api/auth/APIAuthenticator.java +++ b/api/src/org/apache/cloudstack/api/auth/APIAuthenticator.java @@ -18,6 +18,7 @@ import org.apache.cloudstack.api.ServerApiException; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.util.List; @@ -37,7 +38,7 @@ public interface APIAuthenticator { public String authenticate(String command, Map params, HttpSession session, InetAddress remoteAddress, String responseType, - StringBuilder auditTrailSb, final HttpServletResponse resp) throws ServerApiException; + StringBuilder auditTrailSb, final HttpServletRequest req, final HttpServletResponse resp) throws ServerApiException; public APIAuthenticationType getAPIType(); diff --git a/plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/GetServiceProviderMetaDataCmd.java b/plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/GetServiceProviderMetaDataCmd.java index 4697438a10c5..721b18e1d9e8 100644 --- a/plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/GetServiceProviderMetaDataCmd.java +++ b/plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/GetServiceProviderMetaDataCmd.java @@ -58,6 +58,7 @@ import org.w3c.dom.Document; import javax.inject.Inject; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import javax.xml.parsers.DocumentBuilder; @@ -105,7 +106,7 @@ public void execute() throws ServerApiException { } @Override - public String authenticate(String command, Map params, HttpSession session, InetAddress remoteAddress, String responseType, StringBuilder auditTrailSb, HttpServletResponse resp) throws ServerApiException { + public String authenticate(String command, Map params, HttpSession session, InetAddress remoteAddress, String responseType, StringBuilder auditTrailSb, final HttpServletRequest req, final HttpServletResponse resp) throws ServerApiException { SAMLMetaDataResponse response = new SAMLMetaDataResponse(); response.setResponseName(getCommandName()); diff --git a/plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmd.java b/plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmd.java index de6031c1cffd..dda5876213e5 100644 --- a/plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmd.java +++ b/plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmd.java @@ -62,6 +62,7 @@ import javax.inject.Inject; import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import javax.xml.parsers.ParserConfigurationException; @@ -165,7 +166,7 @@ public Response processSAMLResponse(String responseMessage) { } @Override - public String authenticate(final String command, final Map params, final HttpSession session, final InetAddress remoteAddress, final String responseType, final StringBuilder auditTrailSb, final HttpServletResponse resp) throws ServerApiException { + public String authenticate(final String command, final Map params, final HttpSession session, final InetAddress remoteAddress, final String responseType, final StringBuilder auditTrailSb, final HttpServletRequest req, final HttpServletResponse resp) throws ServerApiException { try { if (!params.containsKey("SAMLResponse") && !params.containsKey("SAMLart")) { String idpUrl = null; diff --git a/plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LogoutAPIAuthenticatorCmd.java b/plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LogoutAPIAuthenticatorCmd.java index 3608fed8138c..17a0a30ca53c 100644 --- a/plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LogoutAPIAuthenticatorCmd.java +++ b/plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LogoutAPIAuthenticatorCmd.java @@ -43,6 +43,7 @@ import org.xml.sax.SAXException; import javax.inject.Inject; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import javax.xml.parsers.ParserConfigurationException; @@ -84,7 +85,7 @@ public void execute() throws ServerApiException { } @Override - public String authenticate(String command, Map params, HttpSession session, InetAddress remoteAddress, String responseType, StringBuilder auditTrailSb, final HttpServletResponse resp) throws ServerApiException { + public String authenticate(String command, Map params, HttpSession session, InetAddress remoteAddress, String responseType, StringBuilder auditTrailSb, final HttpServletRequest req, final HttpServletResponse resp) throws ServerApiException { auditTrailSb.append("=== SAML SLO Logging out ==="); LogoutCmdResponse response = new LogoutCmdResponse(); response.setDescription("success"); diff --git a/plugins/user-authenticators/saml2/test/org/apache/cloudstack/api/command/GetServiceProviderMetaDataCmdTest.java b/plugins/user-authenticators/saml2/test/org/apache/cloudstack/api/command/GetServiceProviderMetaDataCmdTest.java index c727d84ca4e5..e53e70193c05 100644 --- a/plugins/user-authenticators/saml2/test/org/apache/cloudstack/api/command/GetServiceProviderMetaDataCmdTest.java +++ b/plugins/user-authenticators/saml2/test/org/apache/cloudstack/api/command/GetServiceProviderMetaDataCmdTest.java @@ -31,6 +31,7 @@ import org.mockito.Mockito; import org.mockito.runners.MockitoJUnitRunner; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.lang.reflect.Field; @@ -59,6 +60,9 @@ public class GetServiceProviderMetaDataCmdTest { @Mock HttpServletResponse resp; + @Mock + HttpServletRequest req; + @Test public void testAuthenticate() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, CertificateParsingException, CertificateEncodingException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException, UnknownHostException { GetServiceProviderMetaDataCmd cmd = new GetServiceProviderMetaDataCmd(); @@ -79,7 +83,7 @@ public void testAuthenticate() throws NoSuchFieldException, SecurityException, I Mockito.when(samlAuthManager.getIdpSingleLogOutUrl()).thenReturn(url); Mockito.when(samlAuthManager.getSpSingleLogOutUrl()).thenReturn(url); - String result = cmd.authenticate("command", null, session, InetAddress.getByName("127.0.0.1"), HttpUtils.RESPONSE_TYPE_JSON, new StringBuilder(), resp); + String result = cmd.authenticate("command", null, session, InetAddress.getByName("127.0.0.1"), HttpUtils.RESPONSE_TYPE_JSON, new StringBuilder(), req, resp); Assert.assertTrue(result.contains("md:EntityDescriptor")); Mockito.verify(samlAuthManager, Mockito.atLeast(1)).getServiceProviderId(); @@ -93,4 +97,4 @@ public void testAuthenticate() throws NoSuchFieldException, SecurityException, I public void testGetAPIType() { Assert.assertTrue(new GetServiceProviderMetaDataCmd().getAPIType() == APIAuthenticationType.LOGIN_API); } -} \ No newline at end of file +} diff --git a/plugins/user-authenticators/saml2/test/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmdTest.java b/plugins/user-authenticators/saml2/test/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmdTest.java index 321b6fa90dfd..8fbed4143634 100644 --- a/plugins/user-authenticators/saml2/test/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmdTest.java +++ b/plugins/user-authenticators/saml2/test/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmdTest.java @@ -58,6 +58,7 @@ import org.opensaml.saml2.core.impl.StatusCodeBuilder; import org.opensaml.saml2.core.impl.SubjectBuilder; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.lang.reflect.Field; @@ -96,6 +97,9 @@ public class SAML2LoginAPIAuthenticatorCmdTest { @Mock HttpServletResponse resp; + @Mock + HttpServletRequest req; + private Response buildMockResponse() throws Exception { Response samlMessage = new ResponseBuilder().buildObject(); samlMessage.setID("foo"); @@ -172,14 +176,14 @@ public void testAuthenticate() throws Exception { Map params = new HashMap(); // SSO redirection test - cmd.authenticate("command", params, session, InetAddress.getByName("127.0.0.1"), HttpUtils.RESPONSE_TYPE_JSON, new StringBuilder(), resp); + cmd.authenticate("command", params, session, InetAddress.getByName("127.0.0.1"), HttpUtils.RESPONSE_TYPE_JSON, new StringBuilder(), req, resp); Mockito.verify(resp, Mockito.times(1)).sendRedirect(Mockito.anyString()); // SSO SAMLResponse verification test, this should throw ServerApiException for auth failure params.put(SAMLUtils.SAML_RESPONSE, new String[]{"Some String"}); Mockito.stub(cmd.processSAMLResponse(Mockito.anyString())).toReturn(buildMockResponse()); try { - cmd.authenticate("command", params, session, InetAddress.getByName("127.0.0.1"), HttpUtils.RESPONSE_TYPE_JSON, new StringBuilder(), resp); + cmd.authenticate("command", params, session, InetAddress.getByName("127.0.0.1"), HttpUtils.RESPONSE_TYPE_JSON, new StringBuilder(), req, resp); } catch (ServerApiException ignored) { } Mockito.verify(configDao, Mockito.atLeastOnce()).getValue(Mockito.anyString()); @@ -192,4 +196,4 @@ public void testAuthenticate() throws Exception { public void testGetAPIType() { Assert.assertTrue(new GetServiceProviderMetaDataCmd().getAPIType() == APIAuthenticationType.LOGIN_API); } -} \ No newline at end of file +} diff --git a/plugins/user-authenticators/saml2/test/org/apache/cloudstack/api/command/SAML2LogoutAPIAuthenticatorCmdTest.java b/plugins/user-authenticators/saml2/test/org/apache/cloudstack/api/command/SAML2LogoutAPIAuthenticatorCmdTest.java index 9ef00b4184fe..4388b886c225 100644 --- a/plugins/user-authenticators/saml2/test/org/apache/cloudstack/api/command/SAML2LogoutAPIAuthenticatorCmdTest.java +++ b/plugins/user-authenticators/saml2/test/org/apache/cloudstack/api/command/SAML2LogoutAPIAuthenticatorCmdTest.java @@ -32,6 +32,7 @@ import org.mockito.Mockito; import org.mockito.runners.MockitoJUnitRunner; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.lang.reflect.Field; @@ -56,6 +57,9 @@ public class SAML2LogoutAPIAuthenticatorCmdTest { @Mock HttpServletResponse resp; + @Mock + HttpServletRequest req; + @Test public void testAuthenticate() throws Exception { SAML2LogoutAPIAuthenticatorCmd cmd = new SAML2LogoutAPIAuthenticatorCmd(); @@ -82,7 +86,7 @@ public void testAuthenticate() throws Exception { Mockito.when(session.getAttribute(Mockito.anyString())).thenReturn(null); Mockito.when(configDao.getValue(Mockito.anyString())).thenReturn("someString"); - cmd.authenticate("command", null, session, InetAddress.getByName("127.0.0.1"), HttpUtils.RESPONSE_TYPE_JSON, new StringBuilder(), resp); + cmd.authenticate("command", null, session, InetAddress.getByName("127.0.0.1"), HttpUtils.RESPONSE_TYPE_JSON, new StringBuilder(), req, resp); Mockito.verify(resp, Mockito.times(1)).sendRedirect(Mockito.anyString()); Mockito.verify(session, Mockito.atLeastOnce()).getAttribute(Mockito.anyString()); } @@ -91,4 +95,4 @@ public void testAuthenticate() throws Exception { public void testGetAPIType() throws Exception { Assert.assertTrue(new SAML2LogoutAPIAuthenticatorCmd().getAPIType() == APIAuthenticationType.LOGOUT_API); } -} \ No newline at end of file +} diff --git a/server/src/com/cloud/api/ApiServlet.java b/server/src/com/cloud/api/ApiServlet.java index dccc9e7edd40..3b3a0be7c461 100644 --- a/server/src/com/cloud/api/ApiServlet.java +++ b/server/src/com/cloud/api/ApiServlet.java @@ -197,7 +197,7 @@ void processRequestInContext(final HttpServletRequest req, final HttpServletResp } try { - responseString = apiAuthenticator.authenticate(command, params, session, InetAddress.getByName(remoteAddress), responseType, auditTrailSb, resp); + responseString = apiAuthenticator.authenticate(command, params, session, InetAddress.getByName(remoteAddress), responseType, auditTrailSb, req, resp); } catch (ServerApiException e) { httpResponseCode = e.getErrorCode().getHttpCode(); responseString = e.getMessage(); diff --git a/server/src/com/cloud/api/auth/DefaultLoginAPIAuthenticatorCmd.java b/server/src/com/cloud/api/auth/DefaultLoginAPIAuthenticatorCmd.java index 39c95ea7877d..d6eac7864d48 100644 --- a/server/src/com/cloud/api/auth/DefaultLoginAPIAuthenticatorCmd.java +++ b/server/src/com/cloud/api/auth/DefaultLoginAPIAuthenticatorCmd.java @@ -33,6 +33,7 @@ import org.apache.log4j.Logger; import javax.inject.Inject; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.util.List; @@ -104,8 +105,11 @@ public void execute() throws ServerApiException { } @Override - public String authenticate(String command, Map params, HttpSession session, InetAddress remoteAddress, String responseType, StringBuilder auditTrailSb, final HttpServletResponse resp) throws ServerApiException { - + public String authenticate(String command, Map params, HttpSession session, InetAddress remoteAddress, String responseType, StringBuilder auditTrailSb, final HttpServletRequest req, final HttpServletResponse resp) throws ServerApiException { + // Disallow non POST requests + if (HTTPMethod.valueOf(req.getMethod()) != HTTPMethod.POST) { + throw new ServerApiException(ApiErrorCode.METHOD_NOT_ALLOWED, "Please use HTTP POST to authenticate using this API"); + } // FIXME: ported from ApiServlet, refactor and cleanup final String[] username = (String[])params.get(ApiConstants.USERNAME); final String[] password = (String[])params.get(ApiConstants.PASSWORD); diff --git a/server/src/com/cloud/api/auth/DefaultLogoutAPIAuthenticatorCmd.java b/server/src/com/cloud/api/auth/DefaultLogoutAPIAuthenticatorCmd.java index 748c8e549324..eb3d448a535c 100644 --- a/server/src/com/cloud/api/auth/DefaultLogoutAPIAuthenticatorCmd.java +++ b/server/src/com/cloud/api/auth/DefaultLogoutAPIAuthenticatorCmd.java @@ -28,6 +28,7 @@ import org.apache.cloudstack.api.response.LogoutCmdResponse; import org.apache.log4j.Logger; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.util.List; @@ -61,7 +62,7 @@ public void execute() throws ServerApiException { } @Override - public String authenticate(String command, Map params, HttpSession session, InetAddress remoteAddress, String responseType, StringBuilder auditTrailSb, final HttpServletResponse resp) throws ServerApiException { + public String authenticate(String command, Map params, HttpSession session, InetAddress remoteAddress, String responseType, StringBuilder auditTrailSb, final HttpServletRequest req, final HttpServletResponse resp) throws ServerApiException { auditTrailSb.append("=== Logging out ==="); LogoutCmdResponse response = new LogoutCmdResponse(); response.setDescription("success"); diff --git a/server/test/com/cloud/api/ApiServletTest.java b/server/test/com/cloud/api/ApiServletTest.java index 57caa44bf904..a0a600409c6e 100644 --- a/server/test/com/cloud/api/ApiServletTest.java +++ b/server/test/com/cloud/api/ApiServletTest.java @@ -105,7 +105,7 @@ public void setup() throws SecurityException, NoSuchFieldException, Mockito.when(authManager.getAPIAuthenticator(Mockito.anyString())).thenReturn(authenticator); Mockito.when(authenticator.authenticate(Mockito.anyString(), Mockito.anyMap(), Mockito.isA(HttpSession.class), - Mockito.same(InetAddress.getByName("127.0.0.1")), Mockito.anyString(), Mockito.isA(StringBuilder.class), Mockito.isA(HttpServletResponse.class))).thenReturn("{\"loginresponse\":{}"); + Mockito.same(InetAddress.getByName("127.0.0.1")), Mockito.anyString(), Mockito.isA(StringBuilder.class), Mockito.isA(HttpServletRequest.class), Mockito.isA(HttpServletResponse.class))).thenReturn("{\"loginresponse\":{}"); Field authManagerField = ApiServlet.class.getDeclaredField("_authManager"); authManagerField.setAccessible(true); @@ -217,7 +217,7 @@ public void processRequestInContextLogout() throws UnknownHostException { Mockito.verify(authManager).getAPIAuthenticator("logout"); Mockito.verify(authenticator).authenticate(Mockito.anyString(), Mockito.anyMap(), Mockito.isA(HttpSession.class), - Mockito.eq(InetAddress.getByName("127.0.0.1")), Mockito.anyString(), Mockito.isA(StringBuilder.class), Mockito.isA(HttpServletResponse.class)); + Mockito.eq(InetAddress.getByName("127.0.0.1")), Mockito.anyString(), Mockito.isA(StringBuilder.class), Mockito.isA(HttpServletRequest.class), Mockito.isA(HttpServletResponse.class)); Mockito.verify(session).invalidate(); } @@ -239,7 +239,7 @@ public void processRequestInContextLogin() throws UnknownHostException { Mockito.verify(authManager).getAPIAuthenticator("login"); Mockito.verify(authenticator).authenticate(Mockito.anyString(), Mockito.anyMap(), Mockito.isA(HttpSession.class), - Mockito.eq(InetAddress.getByName("127.0.0.1")), Mockito.anyString(), Mockito.isA(StringBuilder.class), Mockito.isA(HttpServletResponse.class)); + Mockito.eq(InetAddress.getByName("127.0.0.1")), Mockito.anyString(), Mockito.isA(StringBuilder.class), Mockito.isA(HttpServletRequest.class), Mockito.isA(HttpServletResponse.class)); } @Test From ad6ac9bb10eb9744d672e4b715eb6afcc22f0343 Mon Sep 17 00:00:00 2001 From: Abhinandan Prateek Date: Fri, 22 May 2015 16:24:20 +0530 Subject: [PATCH 103/175] CLOUDSTACK-8488: network with LB fails to restart as the bash script mangles the escape characters, fixed --- systemvm/patches/debian/config/opt/cloud/bin/vr_cfg.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/systemvm/patches/debian/config/opt/cloud/bin/vr_cfg.sh b/systemvm/patches/debian/config/opt/cloud/bin/vr_cfg.sh index dffa45a30573..7ed7d6b6e871 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/vr_cfg.sh +++ b/systemvm/patches/debian/config/opt/cloud/bin/vr_cfg.sh @@ -77,7 +77,7 @@ do file=$line log_it "VR config: creating file: $file" rm -f $file - while read line + while read -r line do if [ "$line" == "" ] then From c37060a1ffc1e63ea2f7ec01887b4c9ff5fcbb48 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Fri, 22 May 2015 09:25:03 +0100 Subject: [PATCH 104/175] CLOUDSTACK-8338: Fix hypervisor stats reporting for KVM on EL7 EL7 has a different output to 'free', use /proc/meminfo instead of a tool to be more consistent across distros (cherry picked from commit 212a05a345aa19cd2597b7ff5d6a1da7b35b9fc1) Signed-off-by: Rohit Yadav Conflicts: plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java --- .../LibvirtGetHostStatsCommandWrapper.java | 27 ++----- .../cloudstack/utils/linux/MemStat.java | 71 +++++++++++++++++++ .../cloudstack/utils/linux/MemStatTest.java | 54 ++++++++++++++ 3 files changed, 130 insertions(+), 22 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/org/apache/cloudstack/utils/linux/MemStat.java create mode 100644 plugins/hypervisors/kvm/test/org/apache/cloudstack/utils/linux/MemStatTest.java diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetHostStatsCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetHostStatsCommandWrapper.java index 32bec3535b25..198eb3b24dab 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetHostStatsCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetHostStatsCommandWrapper.java @@ -19,6 +19,7 @@ package com.cloud.hypervisor.kvm.resource.wrapper; +import org.apache.cloudstack.utils.linux.MemStat; import org.apache.log4j.Logger; import com.cloud.agent.api.Answer; @@ -55,28 +56,10 @@ public Answer execute(final GetHostStatsCommand command, final LibvirtComputingR } final double cpuUtil = 100.0D - Double.parseDouble(parser.getLine()); - long freeMem = 0; - final Script memScript = new Script(bashScriptPath, s_logger); - memScript.add("-c"); - memScript.add("freeMem=$(free|grep cache:|awk '{print $4}');echo $freeMem"); - final OutputInterpreter.OneLineParser Memparser = new OutputInterpreter.OneLineParser(); - result = memScript.execute(Memparser); - if (result != null) { - s_logger.debug("Unable to get the host Mem state: " + result); - return new Answer(command, false, result); - } - freeMem = Long.parseLong(Memparser.getLine()); - - final Script totalMem = new Script(bashScriptPath, s_logger); - totalMem.add("-c"); - totalMem.add("free|grep Mem:|awk '{print $2}'"); - final OutputInterpreter.OneLineParser totMemparser = new OutputInterpreter.OneLineParser(); - result = totalMem.execute(totMemparser); - if (result != null) { - s_logger.debug("Unable to get the host Mem state: " + result); - return new Answer(command, false, result); - } - final long totMem = Long.parseLong(totMemparser.getLine()); + MemStat memStat = new MemStat(); + memStat.refresh(); + double totMem = memStat.getTotal(); + double freeMem = memStat.getAvailable(); final Pair nicStats = libvirtComputingResource.getNicStats(libvirtComputingResource.getPublicBridgeName()); diff --git a/plugins/hypervisors/kvm/src/org/apache/cloudstack/utils/linux/MemStat.java b/plugins/hypervisors/kvm/src/org/apache/cloudstack/utils/linux/MemStat.java new file mode 100644 index 000000000000..1e3c872c353f --- /dev/null +++ b/plugins/hypervisors/kvm/src/org/apache/cloudstack/utils/linux/MemStat.java @@ -0,0 +1,71 @@ +// 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.utils.linux; + +import java.util.HashMap; +import java.util.Map; + +import java.io.File; +import java.io.FileNotFoundException; +import java.util.Scanner; + +public class MemStat { + protected final static String MEMINFO_FILE = "/proc/meminfo"; + protected final static String FREE_KEY = "MemFree"; + protected final static String CACHE_KEY = "Cached"; + protected final static String TOTAL_KEY = "MemTotal"; + + private Map _memStats = new HashMap(); + + public MemStat() { + } + + public Double getTotal() { + return _memStats.get(TOTAL_KEY); + } + + public Double getAvailable() { + return getFree() + getCache(); + } + + public Double getFree() { + return _memStats.get(FREE_KEY); + } + + public Double getCache() { + return _memStats.get(CACHE_KEY); + } + + public void refresh() { + try { + Scanner fileScanner = new Scanner(new File(MEMINFO_FILE)); + parseFromScanner(fileScanner); + } catch (FileNotFoundException ex) { + throw new RuntimeException("File " + MEMINFO_FILE + " not found:" + ex.toString()); + } + } + + protected void parseFromScanner(Scanner scanner) { + scanner.useDelimiter("\\n"); + while(scanner.hasNext()) { + String[] stats = scanner.next().split("\\:\\s+"); + if (stats.length == 2) { + _memStats.put(stats[0], Double.valueOf(stats[1].replaceAll("\\s+\\w+",""))); + } + } + } +} diff --git a/plugins/hypervisors/kvm/test/org/apache/cloudstack/utils/linux/MemStatTest.java b/plugins/hypervisors/kvm/test/org/apache/cloudstack/utils/linux/MemStatTest.java new file mode 100644 index 000000000000..5e77606d36e3 --- /dev/null +++ b/plugins/hypervisors/kvm/test/org/apache/cloudstack/utils/linux/MemStatTest.java @@ -0,0 +1,54 @@ +// 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.utils.linux; + +import org.junit.Assert; +import org.junit.Test; + +import java.util.Scanner; + +public class MemStatTest { + @Test + public void getMemInfoParseTest() { + String memInfo = "MemTotal: 5830236 kB\n" + + "MemFree: 156752 kB\n" + + "Buffers: 326836 kB\n" + + "Cached: 2606764 kB\n" + + "SwapCached: 0 kB\n" + + "Active: 4260808 kB\n" + + "Inactive: 949392 kB\n"; + + MemStat memStat = null; + try { + memStat = new MemStat(); + } catch (RuntimeException ex) { + // If test isn't run on linux we'll fail creation of linux-specific MemStat class due + // to dependency on /proc/meminfo if we don't catch here. + // We are really only interested in testing the parsing algorithm and getters. + if (memStat == null) { + throw ex; + } + } + Scanner scanner = new Scanner(memInfo); + memStat.parseFromScanner(scanner); + + Assert.assertEquals(memStat.getTotal(), Double.valueOf(5830236)); + Assert.assertEquals(memStat.getAvailable(), Double.valueOf(2763516)); + Assert.assertEquals(memStat.getFree(), Double.valueOf(156752)); + Assert.assertEquals(memStat.getCache(), Double.valueOf(2606764)); + } +} From 274222769acb1b90d3465a4b8bcab0f1688ff0b5 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Fri, 22 May 2015 13:22:40 +0100 Subject: [PATCH 105/175] CLOUDSTACK-8252: Ignore VLAN 4095 which is n/a on linux VLAN id 4095 is commonly used as a 'tag passthrough' in virtualization environments (VMware, specifically). This vlan id is incompatible with Linux, but we can allow the admin to manually configure the bridge if the same passthrough is desired. Signed-off-by: Rohit Yadav (cherry picked from commit aee35c96a8157e36b1237dc537bb5b01e1657d61) Signed-off-by: Rohit Yadav --- scripts/vm/network/vnet/modifyvlan.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/vm/network/vnet/modifyvlan.sh b/scripts/vm/network/vnet/modifyvlan.sh index 021dfa20a0e4..24a38a18050e 100755 --- a/scripts/vm/network/vnet/modifyvlan.sh +++ b/scripts/vm/network/vnet/modifyvlan.sh @@ -167,6 +167,11 @@ then modprobe 8021q >& /dev/null fi +if [ "$vlanId" -eq 4095 ] +then + exit 0 +fi + if [ "$op" == "add" ] then # Add the vlan From d7f4498f76e3b743b4f968a456aab66be510f5e3 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Fri, 22 May 2015 13:32:56 +0100 Subject: [PATCH 106/175] kvm: Strip trailing comma for qemu-img convert options Fix trailing comma for qemu-img convert options, Qemu 2.0+ not tolerant to it Signed-off-by: Rohit Yadav (cherry picked from commit 90ac1aba13d431cdccf51dde2c4727b96388d985) Signed-off-by: Rohit Yadav --- .../kvm/src/org/apache/cloudstack/utils/qemu/QemuImg.java | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/hypervisors/kvm/src/org/apache/cloudstack/utils/qemu/QemuImg.java b/plugins/hypervisors/kvm/src/org/apache/cloudstack/utils/qemu/QemuImg.java index e8dbf9269298..500c2d0d6607 100644 --- a/plugins/hypervisors/kvm/src/org/apache/cloudstack/utils/qemu/QemuImg.java +++ b/plugins/hypervisors/kvm/src/org/apache/cloudstack/utils/qemu/QemuImg.java @@ -236,6 +236,7 @@ public void convert(QemuImgFile srcFile, QemuImgFile destFile, Map option : options.entrySet()) { optionsStr += option.getKey() + "=" + option.getValue() + ","; } + optionsStr = optionsStr.replaceAll(",$", ""); s.add(optionsStr); } From 345db34583ac4989308a740b17db67bc828b293b Mon Sep 17 00:00:00 2001 From: sanjeev Date: Fri, 22 May 2015 18:52:40 +0530 Subject: [PATCH 107/175] CLOUDSTACK-8507: Added code to install httpd package inside vm if not found This closes #287 --- test/integration/component/test_vpc_network_pfrules.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/integration/component/test_vpc_network_pfrules.py b/test/integration/component/test_vpc_network_pfrules.py index e49642b427cd..3f3f988f254b 100644 --- a/test/integration/component/test_vpc_network_pfrules.py +++ b/test/integration/component/test_vpc_network_pfrules.py @@ -339,6 +339,13 @@ def check_wget_from_vm(self, vm, public_ip, network=None, testnegative=False, is time.sleep(5) ssh_response = str(sshClient.execute("service httpd status")).lower() self.debug("httpd service status is: %s" % ssh_response) + if "httpd: unrecognized service" in ssh_response or "inactive" in ssh_response: + ssh_res = sshClient.execute("yum install httpd -y") + if "Complete!" not in ssh_res: + raise Exception("Failed to install http server") + sshClient.execute("service httpd start") + time.sleep(5) + ssh_response = str(sshClient.execute("service httpd status")).lower() if not "running" in ssh_response: raise Exception("Failed to start httpd service") From 487d90148c945851d91d2298ba55bbfe6e374b2c Mon Sep 17 00:00:00 2001 From: Rafael da Fonseca Date: Thu, 21 May 2015 10:10:05 +0200 Subject: [PATCH 108/175] Fixed problem with static files reload: - Tomcat was not caching most static files in index.jsp due to changing timestamp - Page reload performance was very poor - Issue affects all versions since 4.0 Signed-off-by: Rohit Yadav This closes #277 --- ui/index.jsp | 132 +++++++++++++++++++++++++-------------------------- 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/ui/index.jsp b/ui/index.jsp index aa20dbf5aa66..19c2dbf04909 100644 --- a/ui/index.jsp +++ b/ui/index.jsp @@ -1762,73 +1762,73 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + From 14863bbaffda55bf99bb96915f240db1605ce79c Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Fri, 22 May 2015 18:17:16 +0200 Subject: [PATCH 109/175] CLOUDSTACK-8506 - Added subnetUtils.setInclusiveHostCount(true) to NetUtils.isIpWithtInCidrRange() method. It makes the 31-bit prefixes work just fine - Added 3 unit tests to test valid and invalid ranges. --- utils/src/com/cloud/utils/net/NetUtils.java | 718 +++++++++--------- .../com/cloud/utils/net/NetUtilsTest.java | 89 ++- 2 files changed, 421 insertions(+), 386 deletions(-) diff --git a/utils/src/com/cloud/utils/net/NetUtils.java b/utils/src/com/cloud/utils/net/NetUtils.java index cc48ef150f53..a93f65d79e07 100644 --- a/utils/src/com/cloud/utils/net/NetUtils.java +++ b/utils/src/com/cloud/utils/net/NetUtils.java @@ -45,13 +45,12 @@ import org.apache.commons.validator.routines.InetAddressValidator; import org.apache.log4j.Logger; -import com.googlecode.ipv6.IPv6Address; -import com.googlecode.ipv6.IPv6AddressRange; -import com.googlecode.ipv6.IPv6Network; - import com.cloud.utils.IteratorUtil; import com.cloud.utils.Pair; import com.cloud.utils.script.Script; +import com.googlecode.ipv6.IPv6Address; +import com.googlecode.ipv6.IPv6AddressRange; +import com.googlecode.ipv6.IPv6Network; public class NetUtils { protected final static Logger s_logger = Logger.getLogger(NetUtils.class); @@ -79,17 +78,17 @@ public class NetUtils { public final static int DEFAULT_AUTOSCALE_POLICY_QUIET_TIME = 5 * 60; private final static Random s_rand = new Random(System.currentTimeMillis()); - public static long createSequenceBasedMacAddress(long macAddress) { - return macAddress | 0x060000000000l | (((long)s_rand.nextInt(32768) << 25) & 0x00fffe000000l); + public static long createSequenceBasedMacAddress(final long macAddress) { + return macAddress | 0x060000000000l | (long)s_rand.nextInt(32768) << 25 & 0x00fffe000000l; } public static String getHostName() { try { - InetAddress localAddr = InetAddress.getLocalHost(); + final InetAddress localAddr = InetAddress.getLocalHost(); if (localAddr != null) { return localAddr.getHostName(); } - } catch (UnknownHostException e) { + } catch (final UnknownHostException e) { s_logger.warn("UnknownHostException when trying to get host name. ", e); } return "localhost"; @@ -98,37 +97,37 @@ public static String getHostName() { public static InetAddress getLocalInetAddress() { try { return InetAddress.getLocalHost(); - } catch (UnknownHostException e) { + } catch (final UnknownHostException e) { s_logger.warn("UnknownHostException in getLocalInetAddress().", e); return null; } } - public static String resolveToIp(String host) { + public static String resolveToIp(final String host) { try { - InetAddress addr = InetAddress.getByName(host); + final InetAddress addr = InetAddress.getByName(host); return ipFromInetAddress(addr); - } catch (UnknownHostException e) { + } catch (final UnknownHostException e) { s_logger.warn("Unable to resolve " + host + " to IP due to UnknownHostException"); return null; } } public static InetAddress[] getAllLocalInetAddresses() { - List addrList = new ArrayList(); + final List addrList = new ArrayList(); try { - for (NetworkInterface ifc : IteratorUtil.enumerationAsIterable(NetworkInterface.getNetworkInterfaces())) { + for (final NetworkInterface ifc : IteratorUtil.enumerationAsIterable(NetworkInterface.getNetworkInterfaces())) { if (ifc.isUp() && !ifc.isVirtual()) { - for (InetAddress addr : IteratorUtil.enumerationAsIterable(ifc.getInetAddresses())) { + for (final InetAddress addr : IteratorUtil.enumerationAsIterable(ifc.getInetAddresses())) { addrList.add(addr); } } } - } catch (SocketException e) { + } catch (final SocketException e) { s_logger.warn("SocketException in getAllLocalInetAddresses().", e); } - InetAddress[] addrs = new InetAddress[addrList.size()]; + final InetAddress[] addrs = new InetAddress[addrList.size()]; if (addrList.size() > 0) { System.arraycopy(addrList.toArray(), 0, addrs, 0, addrList.size()); } @@ -136,24 +135,25 @@ public static InetAddress[] getAllLocalInetAddresses() { } public static String[] getLocalCidrs() { - String defaultHostIp = getDefaultHostIp(); + final String defaultHostIp = getDefaultHostIp(); - List cidrList = new ArrayList(); + final List cidrList = new ArrayList(); try { - for (NetworkInterface ifc : IteratorUtil.enumerationAsIterable(NetworkInterface.getNetworkInterfaces())) { + for (final NetworkInterface ifc : IteratorUtil.enumerationAsIterable(NetworkInterface.getNetworkInterfaces())) { if (ifc.isUp() && !ifc.isVirtual() && !ifc.isLoopback()) { - for (InterfaceAddress address : ifc.getInterfaceAddresses()) { - InetAddress addr = address.getAddress(); - int prefixLength = address.getNetworkPrefixLength(); + for (final InterfaceAddress address : ifc.getInterfaceAddresses()) { + final InetAddress addr = address.getAddress(); + final int prefixLength = address.getNetworkPrefixLength(); if (prefixLength < 32 && prefixLength > 0) { - String ip = ipFromInetAddress(addr); - if (ip.equalsIgnoreCase(defaultHostIp)) + final String ip = ipFromInetAddress(addr); + if (ip.equalsIgnoreCase(defaultHostIp)) { cidrList.add(ipAndNetMaskToCidr(ip, getCidrNetmask(prefixLength))); + } } } } } - } catch (SocketException e) { + } catch (final SocketException e) { s_logger.warn("UnknownHostException in getLocalCidrs().", e); } @@ -162,26 +162,26 @@ public static String[] getLocalCidrs() { public static String getDefaultHostIp() { if (SystemUtils.IS_OS_WINDOWS) { - Pattern pattern = Pattern.compile("\\s*0.0.0.0\\s*0.0.0.0\\s*(\\S*)\\s*(\\S*)\\s*"); + final Pattern pattern = Pattern.compile("\\s*0.0.0.0\\s*0.0.0.0\\s*(\\S*)\\s*(\\S*)\\s*"); try { - Process result = Runtime.getRuntime().exec("route print -4"); - BufferedReader output = new BufferedReader(new InputStreamReader(result.getInputStream())); + final Process result = Runtime.getRuntime().exec("route print -4"); + final BufferedReader output = new BufferedReader(new InputStreamReader(result.getInputStream())); String line = output.readLine(); while (line != null) { - Matcher matcher = pattern.matcher(line); + final Matcher matcher = pattern.matcher(line); if (matcher.find()) { return matcher.group(2); } line = output.readLine(); } - } catch (IOException e) { + } catch (final IOException e) { s_logger.debug("Caught IOException", e); } return null; } else { NetworkInterface nic = null; - String pubNic = getDefaultEthDevice(); + final String pubNic = getDefaultEthDevice(); if (pubNic == null) { return null; @@ -196,7 +196,7 @@ public static String getDefaultHostIp() { String[] info = null; try { info = NetUtils.getNetworkParams(nic); - } catch (NullPointerException ignored) { + } catch (final NullPointerException ignored) { s_logger.debug("Caught NullPointerException when trying to getDefaultHostIp"); } if (info != null) { @@ -208,16 +208,16 @@ public static String getDefaultHostIp() { public static String getDefaultEthDevice() { if (SystemUtils.IS_OS_MAC) { - String defDev = Script.runSimpleBashScript("/sbin/route -n get default 2> /dev/null | grep interface | awk '{print $2}'"); + final String defDev = Script.runSimpleBashScript("/sbin/route -n get default 2> /dev/null | grep interface | awk '{print $2}'"); return defDev; } - String defaultRoute = Script.runSimpleBashScript("/sbin/route | grep default"); + final String defaultRoute = Script.runSimpleBashScript("/sbin/route | grep default"); if (defaultRoute == null) { return null; } - String[] defaultRouteList = defaultRoute.split("\\s+"); + final String[] defaultRouteList = defaultRoute.split("\\s+"); if (defaultRouteList.length != 8) { return null; @@ -227,9 +227,9 @@ public static String getDefaultEthDevice() { } public static InetAddress getFirstNonLoopbackLocalInetAddress() { - InetAddress[] addrs = getAllLocalInetAddresses(); + final InetAddress[] addrs = getAllLocalInetAddresses(); if (addrs != null) { - for (InetAddress addr : addrs) { + for (final InetAddress addr : addrs) { if (s_logger.isInfoEnabled()) { s_logger.info("Check local InetAddress : " + addr.toString() + ", total count :" + addrs.length); } @@ -244,21 +244,21 @@ public static InetAddress getFirstNonLoopbackLocalInetAddress() { return null; } - public static InetAddress[] getInterfaceInetAddresses(String ifName) { - List addrList = new ArrayList(); + public static InetAddress[] getInterfaceInetAddresses(final String ifName) { + final List addrList = new ArrayList(); try { - for (NetworkInterface ifc : IteratorUtil.enumerationAsIterable(NetworkInterface.getNetworkInterfaces())) { + for (final NetworkInterface ifc : IteratorUtil.enumerationAsIterable(NetworkInterface.getNetworkInterfaces())) { if (ifc.isUp() && !ifc.isVirtual() && ifc.getName().equals(ifName)) { - for (InetAddress addr : IteratorUtil.enumerationAsIterable(ifc.getInetAddresses())) { + for (final InetAddress addr : IteratorUtil.enumerationAsIterable(ifc.getInetAddresses())) { addrList.add(addr); } } } - } catch (SocketException e) { + } catch (final SocketException e) { s_logger.warn("SocketException in getAllLocalInetAddresses().", e); } - InetAddress[] addrs = new InetAddress[addrList.size()]; + final InetAddress[] addrs = new InetAddress[addrList.size()]; if (addrList.size() > 0) { System.arraycopy(addrList.toArray(), 0, addrs, 0, addrList.size()); } @@ -266,7 +266,7 @@ public static InetAddress[] getInterfaceInetAddresses(String ifName) { } public static String getLocalIPString() { - InetAddress addr = getLocalInetAddress(); + final InetAddress addr = getLocalInetAddress(); if (addr != null) { return ipFromInetAddress(addr); } @@ -274,11 +274,11 @@ public static String getLocalIPString() { return "127.0.0.1"; } - public static String ipFromInetAddress(InetAddress addr) { - assert (addr != null); + public static String ipFromInetAddress(final InetAddress addr) { + assert addr != null; - byte[] ipBytes = addr.getAddress(); - StringBuffer sb = new StringBuffer(); + final byte[] ipBytes = addr.getAddress(); + final StringBuffer sb = new StringBuffer(); sb.append(ipBytes[0] & 0xff).append("."); sb.append(ipBytes[1] & 0xff).append("."); sb.append(ipBytes[2] & 0xff).append("."); @@ -287,11 +287,11 @@ public static String ipFromInetAddress(InetAddress addr) { return sb.toString(); } - public static boolean isLocalAddress(InetAddress addr) { - InetAddress[] addrs = getAllLocalInetAddresses(); + public static boolean isLocalAddress(final InetAddress addr) { + final InetAddress[] addrs = getAllLocalInetAddresses(); if (addrs != null) { - for (InetAddress self : addrs) { + for (final InetAddress self : addrs) { if (self.equals(addr)) { return true; } @@ -300,28 +300,28 @@ public static boolean isLocalAddress(InetAddress addr) { return false; } - public static boolean isLocalAddress(String strAddress) { + public static boolean isLocalAddress(final String strAddress) { InetAddress addr; try { addr = InetAddress.getByName(strAddress); return isLocalAddress(addr); - } catch (UnknownHostException e) { + } catch (final UnknownHostException e) { } return false; } - public static String getMacAddress(InetAddress address) { - StringBuffer sb = new StringBuffer(); - Formatter formatter = new Formatter(sb); + public static String getMacAddress(final InetAddress address) { + final StringBuffer sb = new StringBuffer(); + final Formatter formatter = new Formatter(sb); try { - NetworkInterface ni = NetworkInterface.getByInetAddress(address); - byte[] mac = ni.getHardwareAddress(); + final NetworkInterface ni = NetworkInterface.getByInetAddress(address); + final byte[] mac = ni.getHardwareAddress(); for (int i = 0; i < mac.length; i++) { - formatter.format("%02X%s", mac[i], (i < mac.length - 1) ? ":" : ""); + formatter.format("%02X%s", mac[i], i < mac.length - 1 ? ":" : ""); } - } catch (SocketException e) { + } catch (final SocketException e) { s_logger.error("SocketException when trying to retrieve MAC address", e); } finally { formatter.close(); @@ -329,30 +329,30 @@ public static String getMacAddress(InetAddress address) { return sb.toString(); } - public static long getMacAddressAsLong(InetAddress address) { + public static long getMacAddressAsLong(final InetAddress address) { long macAddressAsLong = 0; try { - NetworkInterface ni = NetworkInterface.getByInetAddress(address); - byte[] mac = ni.getHardwareAddress(); + final NetworkInterface ni = NetworkInterface.getByInetAddress(address); + final byte[] mac = ni.getHardwareAddress(); for (int i = 0; i < mac.length; i++) { - macAddressAsLong |= ((long)(mac[i] & 0xff) << (mac.length - i - 1) * 8); + macAddressAsLong |= (long)(mac[i] & 0xff) << (mac.length - i - 1) * 8; } - } catch (SocketException e) { + } catch (final SocketException e) { s_logger.error("SocketException when trying to retrieve MAC address", e); } return macAddressAsLong; } - public static boolean ipRangesOverlap(String startIp1, String endIp1, String startIp2, String endIp2) { - long startIp1Long = ip2Long(startIp1); + public static boolean ipRangesOverlap(final String startIp1, final String endIp1, final String startIp2, final String endIp2) { + final long startIp1Long = ip2Long(startIp1); long endIp1Long = startIp1Long; if (endIp1 != null) { endIp1Long = ip2Long(endIp1); } - long startIp2Long = ip2Long(startIp2); + final long startIp2Long = ip2Long(startIp2); long endIp2Long = startIp2Long; if (endIp2 != null) { endIp2Long = ip2Long(endIp2); @@ -374,13 +374,13 @@ public static boolean ipRangesOverlap(String startIp1, String endIp1, String sta } public static long ip2Long(final String ip) { - String[] tokens = ip.split("[.]"); - assert (tokens.length == 4); + final String[] tokens = ip.split("[.]"); + assert tokens.length == 4; long result = 0; for (int i = 0; i < tokens.length; i++) { try { - result = (result << 8) | Integer.parseInt(tokens[i]); - } catch (NumberFormatException e) { + result = result << 8 | Integer.parseInt(tokens[i]); + } catch (final NumberFormatException e) { throw new RuntimeException("Incorrect number", e); } } @@ -390,9 +390,9 @@ public static long ip2Long(final String ip) { public static String long2Ip(final long ip) { final StringBuilder result = new StringBuilder(15); - result.append((ip >> 24 & 0xff)).append("."); - result.append((ip >> 16 & 0xff)).append("."); - result.append((ip >> 8 & 0xff)).append("."); + result.append(ip >> 24 & 0xff).append("."); + result.append(ip >> 16 & 0xff).append("."); + result.append(ip >> 8 & 0xff).append("."); result.append(ip & 0xff); return result.toString(); @@ -400,7 +400,7 @@ public static String long2Ip(final long ip) { public static long mac2Long(final String macAddress) { final String[] tokens = macAddress.split(":"); - assert (tokens.length == 6); + assert tokens.length == 6; long result = 0; for (int i = 0; i < tokens.length; i++) { result = result << 8; @@ -409,23 +409,23 @@ public static long mac2Long(final String macAddress) { return result; } - public static String[] getNicParams(String nicName) { + public static String[] getNicParams(final String nicName) { try { - NetworkInterface nic = NetworkInterface.getByName(nicName); + final NetworkInterface nic = NetworkInterface.getByName(nicName); return getNetworkParams(nic); - } catch (SocketException e) { + } catch (final SocketException e) { return null; } } - public static String[] getNetworkParams(NetworkInterface nic) { - List addrs = nic.getInterfaceAddresses(); + public static String[] getNetworkParams(final NetworkInterface nic) { + final List addrs = nic.getInterfaceAddresses(); if (addrs == null || addrs.size() == 0) { return null; } InterfaceAddress addr = null; - for (InterfaceAddress iaddr : addrs) { - InetAddress inet = iaddr.getAddress(); + for (final InterfaceAddress iaddr : addrs) { + final InetAddress inet = iaddr.getAddress(); if (!inet.isLinkLocalAddress() && !inet.isLoopbackAddress() && !inet.isMulticastAddress() && inet.getAddress().length == 4) { addr = iaddr; break; @@ -434,12 +434,12 @@ public static String[] getNetworkParams(NetworkInterface nic) { if (addr == null) { return null; } - String[] result = new String[3]; + final String[] result = new String[3]; result[0] = addr.getAddress().getHostAddress(); try { - byte[] mac = nic.getHardwareAddress(); + final byte[] mac = nic.getHardwareAddress(); result[1] = byte2Mac(mac); - } catch (SocketException e) { + } catch (final SocketException e) { s_logger.debug("Caught exception when trying to get the mac address ", e); } @@ -447,18 +447,18 @@ public static String[] getNetworkParams(NetworkInterface nic) { return result; } - public static String prefix2Netmask(short prefix) { + public static String prefix2Netmask(final short prefix) { long addr = 0; for (int i = 0; i < prefix; i++) { - addr = addr | (1 << (31 - i)); + addr = addr | 1 << 31 - i; } return long2Ip(addr); } - public static String byte2Mac(byte[] m) { - StringBuilder result = new StringBuilder(17); - Formatter formatter = new Formatter(result); + public static String byte2Mac(final byte[] m) { + final StringBuilder result = new StringBuilder(17); + final Formatter formatter = new Formatter(result); formatter.format("%02x:%02x:%02x:%02x:%02x:%02x", m[0], m[1], m[2], m[3], m[4], m[5]); formatter.close(); return result.toString(); @@ -468,16 +468,16 @@ public static String long2Mac(final long macAddress) { final StringBuilder result = new StringBuilder(17); try (Formatter formatter = new Formatter(result)) { formatter.format("%02x:%02x:%02x:%02x:%02x:%02x", - (macAddress >> 40) & 0xff, (macAddress >> 32) & 0xff, - (macAddress >> 24) & 0xff, (macAddress >> 16) & 0xff, - (macAddress >> 8) & 0xff, (macAddress & 0xff)); + macAddress >> 40 & 0xff, macAddress >> 32 & 0xff, + macAddress >> 24 & 0xff, macAddress >> 16 & 0xff, + macAddress >> 8 & 0xff, macAddress & 0xff); } return result.toString(); } - public static boolean isValidPrivateIp(String ipAddress, String guestIPAddress) { + public static boolean isValidPrivateIp(final String ipAddress, final String guestIPAddress) { - InetAddress privIp = parseIpAddress(ipAddress); + final InetAddress privIp = parseIpAddress(ipAddress); if (privIp == null) { return false; } @@ -487,11 +487,11 @@ public static boolean isValidPrivateIp(String ipAddress, String guestIPAddress) String firstGuestOctet = "10"; if (guestIPAddress != null && !guestIPAddress.isEmpty()) { - String[] guestIPList = guestIPAddress.split("\\."); + final String[] guestIPList = guestIPAddress.split("\\."); firstGuestOctet = guestIPList[0]; } - String[] ipList = ipAddress.split("\\."); + final String[] ipList = ipAddress.split("\\."); if (!ipList[0].equals(firstGuestOctet)) { return false; } @@ -499,11 +499,11 @@ public static boolean isValidPrivateIp(String ipAddress, String guestIPAddress) return true; } - public static boolean isSiteLocalAddress(String ipAddress) { + public static boolean isSiteLocalAddress(final String ipAddress) { if (ipAddress == null) { return false; } else { - InetAddress ip = parseIpAddress(ipAddress); + final InetAddress ip = parseIpAddress(ipAddress); if(ip != null) { return ip.isSiteLocalAddress(); } @@ -511,18 +511,18 @@ public static boolean isSiteLocalAddress(String ipAddress) { } } - public static boolean validIpRange(String startIP, String endIP) { + public static boolean validIpRange(final String startIP, final String endIP) { if (endIP == null || endIP.isEmpty()) { return true; } - long startIPLong = NetUtils.ip2Long(startIP); - long endIPLong = NetUtils.ip2Long(endIP); - return (startIPLong <= endIPLong); + final long startIPLong = NetUtils.ip2Long(startIP); + final long endIPLong = NetUtils.ip2Long(endIP); + return startIPLong <= endIPLong; } public static boolean isValidIp(final String ip) { - InetAddressValidator validator = InetAddressValidator.getInstance(); + final InetAddressValidator validator = InetAddressValidator.getInstance(); return validator.isValidInet4Address(ip); } @@ -531,12 +531,12 @@ public static boolean isValidCIDR(final String cidr) { if (cidr == null || cidr.isEmpty()) { return false; } - String[] cidrPair = cidr.split("\\/"); + final String[] cidrPair = cidr.split("\\/"); if (cidrPair.length != 2) { return false; } - String cidrAddress = cidrPair[0]; - String cidrSize = cidrPair[1]; + final String cidrAddress = cidrPair[0]; + final String cidrSize = cidrPair[1]; if (!isValidIp(cidrAddress)) { return false; } @@ -544,7 +544,7 @@ public static boolean isValidCIDR(final String cidr) { try { cidrSizeNum = Integer.parseInt(cidrSize); - } catch (Exception e) { + } catch (final Exception e) { return false; } @@ -555,16 +555,16 @@ public static boolean isValidCIDR(final String cidr) { return true; } - public static boolean isValidNetmask(String netmask) { + public static boolean isValidNetmask(final String netmask) { if (!isValidIp(netmask)) { return false; } - long ip = ip2Long(netmask); + final long ip = ip2Long(netmask); int count = 0; boolean finished = false; for (int i = 31; i >= 0; i--) { - if (((ip >> i) & 0x1) == 0) { + if ((ip >> i & 0x1) == 0) { finished = true; } else { if (finished) { @@ -581,9 +581,9 @@ public static boolean isValidNetmask(String netmask) { return true; } - private static InetAddress parseIpAddress(String address) { - StringTokenizer st = new StringTokenizer(address, "."); - byte[] bytes = new byte[4]; + private static InetAddress parseIpAddress(final String address) { + final StringTokenizer st = new StringTokenizer(address, "."); + final byte[] bytes = new byte[4]; if (st.countTokens() == 4) { try { @@ -591,35 +591,35 @@ private static InetAddress parseIpAddress(String address) { bytes[i] = (byte)Integer.parseInt(st.nextToken()); } return InetAddress.getByAddress(address, bytes); - } catch (NumberFormatException nfe) { + } catch (final NumberFormatException nfe) { return null; - } catch (UnknownHostException uhe) { + } catch (final UnknownHostException uhe) { return null; } } return null; } - public static String getCidrFromGatewayAndNetmask(String gatewayStr, String netmaskStr) { - long netmask = ip2Long(netmaskStr); - long gateway = ip2Long(gatewayStr); - long firstPart = gateway & netmask; - long size = getCidrSize(netmaskStr); + public static String getCidrFromGatewayAndNetmask(final String gatewayStr, final String netmaskStr) { + final long netmask = ip2Long(netmaskStr); + final long gateway = ip2Long(gatewayStr); + final long firstPart = gateway & netmask; + final long size = getCidrSize(netmaskStr); return long2Ip(firstPart) + "/" + size; } - public static String[] getIpRangeFromCidr(String cidr, long size) { - assert (size < 32) : "You do know this is not for ipv6 right? Keep it smaller than 32 but you have " + size; - String[] result = new String[2]; - long ip = ip2Long(cidr); - long startNetMask = ip2Long(getCidrNetmask(size)); - long start = (ip & startNetMask) + 1; + public static String[] getIpRangeFromCidr(final String cidr, final long size) { + assert size < 32 : "You do know this is not for ipv6 right? Keep it smaller than 32 but you have " + size; + final String[] result = new String[2]; + final long ip = ip2Long(cidr); + final long startNetMask = ip2Long(getCidrNetmask(size)); + final long start = (ip & startNetMask) + 1; long end = start; - end = end >> (32 - size); + end = end >> 32 - size; end++; - end = (end << (32 - size)) - 2; + end = (end << 32 - size) - 2; result[0] = long2Ip(start); result[1] = long2Ip(end); @@ -627,18 +627,18 @@ public static String[] getIpRangeFromCidr(String cidr, long size) { return result; } - public static Set getAllIpsFromCidr(String cidr, long size, Set usedIps) { - assert (size < 32) : "You do know this is not for ipv6 right? Keep it smaller than 32 but you have " + size; - Set result = new TreeSet(); - long ip = ip2Long(cidr); - long startNetMask = ip2Long(getCidrNetmask(size)); + public static Set getAllIpsFromCidr(final String cidr, final long size, final Set usedIps) { + assert size < 32 : "You do know this is not for ipv6 right? Keep it smaller than 32 but you have " + size; + final Set result = new TreeSet(); + final long ip = ip2Long(cidr); + final long startNetMask = ip2Long(getCidrNetmask(size)); long start = (ip & startNetMask) + 1; long end = start; - end = end >> (32 - size); + end = end >> 32 - size; end++; - end = (end << (32 - size)) - 2; + end = (end << 32 - size) - 2; int maxIps = 255; // get 255 ips as maximum while (start <= end && maxIps > 0) { if (!usedIps.contains(start)) { @@ -660,7 +660,7 @@ public static Set getAllIpsFromCidr(String cidr, long size, Set used * @param avoid set of ips to avoid * @return ip that is within the cidr range but not in the avoid set. -1 if unable to find one. */ - public static long getRandomIpFromCidr(String startIp, int size, SortedSet avoid) { + public static long getRandomIpFromCidr(final String startIp, final int size, final SortedSet avoid) { return getRandomIpFromCidr(ip2Long(startIp), size, avoid); } @@ -675,12 +675,12 @@ public static long getRandomIpFromCidr(String startIp, int size, SortedSet * @param avoid set of ips to avoid * @return ip that is within the cidr range but not in the avoid set. -1 if unable to find one. */ - public static long getRandomIpFromCidr(long cidr, int size, SortedSet avoid) { - assert (size < 32) : "You do know this is not for ipv6 right? Keep it smaller than 32 but you have " + size; + public static long getRandomIpFromCidr(final long cidr, final int size, final SortedSet avoid) { + assert size < 32 : "You do know this is not for ipv6 right? Keep it smaller than 32 but you have " + size; - long startNetMask = ip2Long(getCidrNetmask(size)); - long startIp = (cidr & startNetMask) + 1; //exclude the first ip since it isnt valid, e.g., 192.168.10.0 - int range = 1 << (32 - size); //e.g., /24 = 2^8 = 256 + final long startNetMask = ip2Long(getCidrNetmask(size)); + final long startIp = (cidr & startNetMask) + 1; //exclude the first ip since it isnt valid, e.g., 192.168.10.0 + int range = 1 << 32 - size; //e.g., /24 = 2^8 = 256 range = range - 1; //exclude end of the range since that is the broadcast address, e.g., 192.168.10.255 if (avoid.size() >= range) { @@ -691,9 +691,9 @@ public static long getRandomIpFromCidr(long cidr, int size, SortedSet avoi //e.g., cidr = 192.168.10.0, size = /24, avoid = 192.168.10.1, 192.168.10.20, 192.168.10.254 // range = 2^8 - 1 - 3 = 252 range = range - avoid.size(); - int next = s_rand.nextInt(range); //note: nextInt excludes last value + final int next = s_rand.nextInt(range); //note: nextInt excludes last value long ip = startIp + next; - for (Long avoidable : avoid) { + for (final Long avoidable : avoid) { if (ip >= avoidable) { ip++; } else { @@ -704,22 +704,22 @@ public static long getRandomIpFromCidr(long cidr, int size, SortedSet avoi return ip; } - public static String getIpRangeStartIpFromCidr(String cidr, long size) { - long ip = ip2Long(cidr); - long startNetMask = ip2Long(getCidrNetmask(size)); - long start = (ip & startNetMask) + 1; + public static String getIpRangeStartIpFromCidr(final String cidr, final long size) { + final long ip = ip2Long(cidr); + final long startNetMask = ip2Long(getCidrNetmask(size)); + final long start = (ip & startNetMask) + 1; return long2Ip(start); } - public static String getIpRangeEndIpFromCidr(String cidr, long size) { - long ip = ip2Long(cidr); - long startNetMask = ip2Long(getCidrNetmask(size)); - long start = (ip & startNetMask) + 1; + public static String getIpRangeEndIpFromCidr(final String cidr, final long size) { + final long ip = ip2Long(cidr); + final long startNetMask = ip2Long(getCidrNetmask(size)); + final long start = (ip & startNetMask) + 1; long end = start; - end = end >> (32 - size); + end = end >> 32 - size; end++; - end = (end << (32 - size)) - 2; + end = (end << 32 - size) - 2; return long2Ip(end); } @@ -727,36 +727,36 @@ public static boolean sameSubnet(final String ip1, final String ip2, final Strin if (ip1 == null || ip1.isEmpty() || ip2 == null || ip2.isEmpty()) { return true; } - String subnet1 = NetUtils.getSubNet(ip1, netmask); - String subnet2 = NetUtils.getSubNet(ip2, netmask); + final String subnet1 = NetUtils.getSubNet(ip1, netmask); + final String subnet2 = NetUtils.getSubNet(ip2, netmask); - return (subnet1.equals(subnet2)); + return subnet1.equals(subnet2); } public static boolean sameSubnetCIDR(final String ip1, final String ip2, final long cidrSize) { if (ip1 == null || ip1.isEmpty() || ip2 == null || ip2.isEmpty()) { return true; } - String subnet1 = NetUtils.getCidrSubNet(ip1, cidrSize); - String subnet2 = NetUtils.getCidrSubNet(ip2, cidrSize); + final String subnet1 = NetUtils.getCidrSubNet(ip1, cidrSize); + final String subnet2 = NetUtils.getCidrSubNet(ip2, cidrSize); - return (subnet1.equals(subnet2)); + return subnet1.equals(subnet2); } - public static String getSubNet(String ip, String netmask) { - long ipAddr = ip2Long(ip); - long subnet = ip2Long(netmask); - long result = ipAddr & subnet; + public static String getSubNet(final String ip, final String netmask) { + final long ipAddr = ip2Long(ip); + final long subnet = ip2Long(netmask); + final long result = ipAddr & subnet; return long2Ip(result); } - public static String getCidrSubNet(String ip, long cidrSize) { - long numericNetmask = (0xffffffff >> (32 - cidrSize)) << (32 - cidrSize); - String netmask = NetUtils.long2Ip(numericNetmask); + public static String getCidrSubNet(final String ip, final long cidrSize) { + final long numericNetmask = 0xffffffff >> 32 - cidrSize << 32 - cidrSize; + final String netmask = NetUtils.long2Ip(numericNetmask); return getSubNet(ip, netmask); } - public static String ipAndNetMaskToCidr(String ip, String netmask) { + public static String ipAndNetMaskToCidr(final String ip, final String netmask) { if (!isValidIp(ip)) { return null; } @@ -765,38 +765,38 @@ public static String ipAndNetMaskToCidr(String ip, String netmask) { return null; } - long ipAddr = ip2Long(ip); - long subnet = ip2Long(netmask); - long result = ipAddr & subnet; - int bits = (subnet == 0) ? 0 : 1; + final long ipAddr = ip2Long(ip); + final long subnet = ip2Long(netmask); + final long result = ipAddr & subnet; + int bits = subnet == 0 ? 0 : 1; long subnet2 = subnet; - while ((subnet2 = (subnet2 >> 1) & subnet) != 0) { + while ((subnet2 = subnet2 >> 1 & subnet) != 0) { bits++; } return long2Ip(result) + "/" + Integer.toString(bits); } - public static String[] ipAndNetMaskToRange(String ip, String netmask) { - long ipAddr = ip2Long(ip); + public static String[] ipAndNetMaskToRange(final String ip, final String netmask) { + final long ipAddr = ip2Long(ip); long subnet = ip2Long(netmask); - long start = (ipAddr & subnet) + 1; + final long start = (ipAddr & subnet) + 1; long end = start; - int bits = (subnet == 0) ? 0 : 1; - while ((subnet = (subnet >> 1) & subnet) != 0) { + int bits = subnet == 0 ? 0 : 1; + while ((subnet = subnet >> 1 & subnet) != 0) { bits++; } - end = end >> (32 - bits); + end = end >> 32 - bits; end++; - end = (end << (32 - bits)) - 2; + end = (end << 32 - bits) - 2; return new String[] {long2Ip(start), long2Ip(end)}; } - public static Pair getCidr(String cidr) { - String[] tokens = cidr.split("/"); + public static Pair getCidr(final String cidr) { + final String[] tokens = cidr.split("/"); return new Pair(tokens[0], Integer.parseInt(tokens[1])); } @@ -804,9 +804,9 @@ public static enum SupersetOrSubset { isSuperset, isSubset, neitherSubetNorSuperset, sameSubnet, errorInCidrFormat } - public static SupersetOrSubset isNetowrkASubsetOrSupersetOfNetworkB(String cidrA, String cidrB) { - Long[] cidrALong = cidrToLong(cidrA); - Long[] cidrBLong = cidrToLong(cidrB); + public static SupersetOrSubset isNetowrkASubsetOrSupersetOfNetworkB(final String cidrA, final String cidrB) { + final Long[] cidrALong = cidrToLong(cidrA); + final Long[] cidrBLong = cidrToLong(cidrB); long shift = 0; if (cidrALong == null || cidrBLong == null) { //implies error in the cidr format @@ -817,7 +817,7 @@ public static SupersetOrSubset isNetowrkASubsetOrSupersetOfNetworkB(String cidrA } else { shift = 32 - cidrALong[1]; } - long result = (cidrALong[0] >> shift) - (cidrBLong[0] >> shift); + final long result = (cidrALong[0] >> shift) - (cidrBLong[0] >> shift); if (result == 0) { if (cidrALong[1] < cidrBLong[1]) { //this implies cidrA is super set of cidrB @@ -833,26 +833,26 @@ public static SupersetOrSubset isNetowrkASubsetOrSupersetOfNetworkB(String cidrA return SupersetOrSubset.neitherSubetNorSuperset; } - public static boolean isNetworkAWithinNetworkB(String cidrA, String cidrB) { - Long[] cidrALong = cidrToLong(cidrA); - Long[] cidrBLong = cidrToLong(cidrB); + public static boolean isNetworkAWithinNetworkB(final String cidrA, final String cidrB) { + final Long[] cidrALong = cidrToLong(cidrA); + final Long[] cidrBLong = cidrToLong(cidrB); if (cidrALong == null || cidrBLong == null) { return false; } - long shift = 32 - cidrBLong[1]; - return ((cidrALong[0] >> shift) == (cidrBLong[0] >> shift)); + final long shift = 32 - cidrBLong[1]; + return cidrALong[0] >> shift == cidrBLong[0] >> shift; } - public static Long[] cidrToLong(String cidr) { + public static Long[] cidrToLong(final String cidr) { if (cidr == null || cidr.isEmpty()) { return null; } - String[] cidrPair = cidr.split("\\/"); + final String[] cidrPair = cidr.split("\\/"); if (cidrPair.length != 2) { return null; } - String cidrAddress = cidrPair[0]; - String cidrSize = cidrPair[1]; + final String cidrAddress = cidrPair[0]; + final String cidrSize = cidrPair[1]; if (!isValidIp(cidrAddress)) { return null; } @@ -860,26 +860,26 @@ public static Long[] cidrToLong(String cidr) { try { cidrSizeNum = Integer.parseInt(cidrSize); - } catch (Exception e) { + } catch (final Exception e) { return null; } - long numericNetmask = (0xffffffff >> (32 - cidrSizeNum)) << (32 - cidrSizeNum); - long ipAddr = ip2Long(cidrAddress); - Long[] cidrlong = {ipAddr & numericNetmask, (long)cidrSizeNum}; + final long numericNetmask = 0xffffffff >> 32 - cidrSizeNum << 32 - cidrSizeNum; + final long ipAddr = ip2Long(cidrAddress); + final Long[] cidrlong = {ipAddr & numericNetmask, (long)cidrSizeNum}; return cidrlong; } - public static String getCidrSubNet(String cidr) { + public static String getCidrSubNet(final String cidr) { if (cidr == null || cidr.isEmpty()) { return null; } - String[] cidrPair = cidr.split("\\/"); + final String[] cidrPair = cidr.split("\\/"); if (cidrPair.length != 2) { return null; } - String cidrAddress = cidrPair[0]; - String cidrSize = cidrPair[1]; + final String cidrAddress = cidrPair[0]; + final String cidrSize = cidrPair[1]; if (!isValidIp(cidrAddress)) { return null; } @@ -887,35 +887,35 @@ public static String getCidrSubNet(String cidr) { try { cidrSizeNum = Integer.parseInt(cidrSize); - } catch (Exception e) { + } catch (final Exception e) { return null; } - long numericNetmask = (0xffffffff >> (32 - cidrSizeNum)) << (32 - cidrSizeNum); - String netmask = NetUtils.long2Ip(numericNetmask); + final long numericNetmask = 0xffffffff >> 32 - cidrSizeNum << 32 - cidrSizeNum; + final String netmask = NetUtils.long2Ip(numericNetmask); return getSubNet(cidrAddress, netmask); } - public static String getCidrNetmask(long cidrSize) { - long numericNetmask = (0xffffffff >> (32 - cidrSize)) << (32 - cidrSize); + public static String getCidrNetmask(final long cidrSize) { + final long numericNetmask = 0xffffffff >> 32 - cidrSize << 32 - cidrSize; return long2Ip(numericNetmask); } - public static String getCidrNetmask(String cidr) { - String[] cidrPair = cidr.split("\\/"); - long guestCidrSize = Long.parseLong(cidrPair[1]); + public static String getCidrNetmask(final String cidr) { + final String[] cidrPair = cidr.split("\\/"); + final long guestCidrSize = Long.parseLong(cidrPair[1]); return getCidrNetmask(guestCidrSize); } - public static String cidr2Netmask(String cidr) { - String[] tokens = cidr.split("\\/"); + public static String cidr2Netmask(final String cidr) { + final String[] tokens = cidr.split("\\/"); return getCidrNetmask(Integer.parseInt(tokens[1])); } - public static long getCidrSize(String netmask) { - long ip = ip2Long(netmask); + public static long getCidrSize(final String netmask) { + final long ip = ip2Long(netmask); int count = 0; for (int i = 0; i < 32; i++) { - if (((ip >> i) & 0x1) == 0) { + if ((ip >> i & 0x1) == 0) { count++; } else { break; @@ -925,46 +925,46 @@ public static long getCidrSize(String netmask) { return 32 - count; } - public static boolean isValidPort(String p) { + public static boolean isValidPort(final String p) { try { - int port = Integer.parseInt(p); + final int port = Integer.parseInt(p); return !(port > 65535 || port < 1); - } catch (NumberFormatException e) { + } catch (final NumberFormatException e) { return false; } } - public static boolean isValidPort(int p) { + public static boolean isValidPort(final int p) { return !(p > 65535 || p < 1); } - public static boolean isValidLBPort(String p) { + public static boolean isValidLBPort(final String p) { try { - int port = Integer.parseInt(p); + final int port = Integer.parseInt(p); return !(port > 65535 || port < 1); - } catch (NumberFormatException e) { + } catch (final NumberFormatException e) { return false; } } - public static boolean isValidProto(String p) { - String proto = p.toLowerCase(); - return (proto.equals(TCP_PROTO) || proto.equals(UDP_PROTO) || proto.equals(ICMP_PROTO)); + public static boolean isValidProto(final String p) { + final String proto = p.toLowerCase(); + return proto.equals(TCP_PROTO) || proto.equals(UDP_PROTO) || proto.equals(ICMP_PROTO); } - public static boolean isValidSecurityGroupProto(String p) { - String proto = p.toLowerCase(); - return (proto.equals(TCP_PROTO) || proto.equals(UDP_PROTO) || proto.equals(ICMP_PROTO) || proto.equals(ALL_PROTO)); + public static boolean isValidSecurityGroupProto(final String p) { + final String proto = p.toLowerCase(); + return proto.equals(TCP_PROTO) || proto.equals(UDP_PROTO) || proto.equals(ICMP_PROTO) || proto.equals(ALL_PROTO); } - public static boolean isValidAlgorithm(String p) { - String algo = p.toLowerCase(); - return (algo.equals("roundrobin") || algo.equals("leastconn") || algo.equals("source")); + public static boolean isValidAlgorithm(final String p) { + final String algo = p.toLowerCase(); + return algo.equals("roundrobin") || algo.equals("leastconn") || algo.equals("source"); } - public static boolean isValidAutoScaleAction(String p) { - String action = p.toLowerCase(); - return (action.equals("scaleup") || action.equals("scaledown")); + public static boolean isValidAutoScaleAction(final String p) { + final String action = p.toLowerCase(); + return action.equals("scaleup") || action.equals("scaledown"); } public static String getLinkLocalNetMask() { @@ -979,12 +979,12 @@ public static String getLinkLocalCIDR() { return "169.254.0.0/16"; } - public static String[] getLinkLocalIPRange(int size) { + public static String[] getLinkLocalIPRange(final int size) { if (size > 16 || size <= 0) { return null; } /* reserve gateway */ - String[] range = getIpRangeFromCidr(getLinkLocalGateway(), 32 - size); + final String[] range = getIpRangeFromCidr(getLinkLocalGateway(), 32 - size); if (range[0].equalsIgnoreCase(getLinkLocalGateway())) { /* remove the gateway */ @@ -996,17 +996,17 @@ public static String[] getLinkLocalIPRange(int size) { } public static String getLinkLocalIpEnd() { - String[] cidrPair = getLinkLocalCIDR().split("\\/"); - String cidr = cidrPair[0]; + final String[] cidrPair = getLinkLocalCIDR().split("\\/"); + final String cidr = cidrPair[0]; return getIpRangeEndIpFromCidr(cidr, 32 - Long.parseLong(cidrPair[1])); } - public static String portRangeToString(int portRange[]) { + public static String portRangeToString(final int portRange[]) { return Integer.toString(portRange[0]) + ":" + Integer.toString(portRange[1]); } - public static boolean verifyDomainNameLabel(String hostName, boolean isHostName) { + public static boolean verifyDomainNameLabel(final String hostName, final boolean isHostName) { // must be between 1 and 63 characters long and may contain only the ASCII letters 'a' through 'z' (in a // case-insensitive manner), // the digits '0' through '9', and the hyphen ('-'). @@ -1030,7 +1030,7 @@ public static boolean verifyDomainNameLabel(String hostName, boolean isHostName) return true; } - public static boolean verifyDomainName(String domainName) { + public static boolean verifyDomainName(final String domainName) { // don't allow domain name length to exceed 190 chars (190 + 63 (max host name length) = 253 = max domainName length if (domainName.length() < 1 || domainName.length() > 190) { s_logger.trace("Domain name must be between 1 and 190 characters long"); @@ -1042,7 +1042,7 @@ public static boolean verifyDomainName(String domainName) { return false; } - String[] domainNameLabels = domainName.split("\\."); + final String[] domainNameLabels = domainName.split("\\."); for (int i = 0; i < domainNameLabels.length; i++) { if (!verifyDomainNameLabel(domainNameLabels[i], false)) { @@ -1054,14 +1054,14 @@ public static boolean verifyDomainName(String domainName) { return true; } - public static String getDhcpRange(String cidr) { - String[] splitResult = cidr.split("\\/"); - long size = Long.valueOf(splitResult[1]); + public static String getDhcpRange(final String cidr) { + final String[] splitResult = cidr.split("\\/"); + final long size = Long.valueOf(splitResult[1]); return NetUtils.getIpRangeStartIpFromCidr(splitResult[0], size); } // Check if 2 CIDRs have exactly same IP Range - public static boolean isSameIpRange(String cidrA, String cidrB) { + public static boolean isSameIpRange(final String cidrA, final String cidrB) { if (!NetUtils.isValidCIDR(cidrA)) { s_logger.info("Invalid value of cidr " + cidrA); @@ -1071,34 +1071,34 @@ public static boolean isSameIpRange(String cidrA, String cidrB) { s_logger.info("Invalid value of cidr " + cidrB); return false; } - String[] cidrPairFirst = cidrA.split("\\/"); - String[] cidrPairSecond = cidrB.split("\\/"); + final String[] cidrPairFirst = cidrA.split("\\/"); + final String[] cidrPairSecond = cidrB.split("\\/"); - Long networkSizeFirst = Long.valueOf(cidrPairFirst[1]); - Long networkSizeSecond = Long.valueOf(cidrPairSecond[1]); - String ipRangeFirst[] = NetUtils.getIpRangeFromCidr(cidrPairFirst[0], networkSizeFirst); - String ipRangeSecond[] = NetUtils.getIpRangeFromCidr(cidrPairFirst[0], networkSizeSecond); + final Long networkSizeFirst = Long.valueOf(cidrPairFirst[1]); + final Long networkSizeSecond = Long.valueOf(cidrPairSecond[1]); + final String ipRangeFirst[] = NetUtils.getIpRangeFromCidr(cidrPairFirst[0], networkSizeFirst); + final String ipRangeSecond[] = NetUtils.getIpRangeFromCidr(cidrPairFirst[0], networkSizeSecond); - long startIpFirst = NetUtils.ip2Long(ipRangeFirst[0]); - long endIpFirst = NetUtils.ip2Long(ipRangeFirst[1]); - long startIpSecond = NetUtils.ip2Long(ipRangeSecond[0]); - long endIpSecond = NetUtils.ip2Long(ipRangeSecond[1]); + final long startIpFirst = NetUtils.ip2Long(ipRangeFirst[0]); + final long endIpFirst = NetUtils.ip2Long(ipRangeFirst[1]); + final long startIpSecond = NetUtils.ip2Long(ipRangeSecond[0]); + final long endIpSecond = NetUtils.ip2Long(ipRangeSecond[1]); if (startIpFirst == startIpSecond && endIpFirst == endIpSecond) { return true; } return false; } - public static boolean validateGuestCidr(String cidr) { + public static boolean validateGuestCidr(final String cidr) { // RFC 1918 - The Internet Assigned Numbers Authority (IANA) has reserved the // following three blocks of the IP address space for private internets: // 10.0.0.0 - 10.255.255.255 (10/8 prefix) // 172.16.0.0 - 172.31.255.255 (172.16/12 prefix) // 192.168.0.0 - 192.168.255.255 (192.168/16 prefix) - String cidr1 = "10.0.0.0/8"; - String cidr2 = "172.16.0.0/12"; - String cidr3 = "192.168.0.0/16"; + final String cidr1 = "10.0.0.0/8"; + final String cidr2 = "172.16.0.0/12"; + final String cidr3 = "192.168.0.0/16"; if (!isValidCIDR(cidr)) { s_logger.warn("Cidr " + cidr + " is not valid"); @@ -1113,7 +1113,7 @@ public static boolean validateGuestCidr(String cidr) { } } - public static boolean verifyInstanceName(String instanceName) { + public static boolean verifyInstanceName(final String instanceName) { //instance name for cloudstack vms shouldn't contain - and spaces if (instanceName.contains("-") || instanceName.contains(" ") || instanceName.contains("+")) { s_logger.warn("Instance name can not contain hyphen, spaces and \"+\" char"); @@ -1123,34 +1123,34 @@ public static boolean verifyInstanceName(String instanceName) { return true; } - public static boolean isNetworksOverlap(String cidrA, String cidrB) { - Long[] cidrALong = cidrToLong(cidrA); - Long[] cidrBLong = cidrToLong(cidrB); + public static boolean isNetworksOverlap(final String cidrA, final String cidrB) { + final Long[] cidrALong = cidrToLong(cidrA); + final Long[] cidrBLong = cidrToLong(cidrB); if (cidrALong == null || cidrBLong == null) { return false; } - long shift = 32 - (cidrALong[1] > cidrBLong[1] ? cidrBLong[1] : cidrALong[1]); - return ((cidrALong[0] >> shift) == (cidrBLong[0] >> shift)); + final long shift = 32 - (cidrALong[1] > cidrBLong[1] ? cidrBLong[1] : cidrALong[1]); + return cidrALong[0] >> shift == cidrBLong[0] >> shift; } - public static boolean isValidS2SVpnPolicy(String policys) { + public static boolean isValidS2SVpnPolicy(final String policys) { if (policys == null || policys.isEmpty()) { return false; } - for (String policy : policys.split(",")) { + for (final String policy : policys.split(",")) { if (policy.isEmpty()) { return false; } - String cipherHash = policy.split(";")[0]; + final String cipherHash = policy.split(";")[0]; if (cipherHash.isEmpty()) { return false; } - String[] list = cipherHash.split("-"); + final String[] list = cipherHash.split("-"); if (list.length != 2) { return false; } - String cipher = list[0]; - String hash = list[1]; + final String cipher = list[0]; + final String hash = list[1]; if (!cipher.matches("3des|aes128|aes192|aes256")) { return false; } @@ -1168,8 +1168,8 @@ public static boolean isValidS2SVpnPolicy(String policys) { return true; } - public static boolean isValidCidrList(String cidrList) { - for (String guestCidr : cidrList.split(",")) { + public static boolean isValidCidrList(final String cidrList) { + for (final String guestCidr : cidrList.split(",")) { if (!isValidCIDR(guestCidr)) { return false; } @@ -1177,8 +1177,8 @@ public static boolean isValidCidrList(String cidrList) { return true; } - public static boolean validateGuestCidrList(String guestCidrList) { - for (String guestCidr : guestCidrList.split(",")) { + public static boolean validateGuestCidrList(final String guestCidrList) { + for (final String guestCidr : guestCidrList.split(",")) { if (!validateGuestCidr(guestCidr)) { return false; } @@ -1186,7 +1186,7 @@ public static boolean validateGuestCidrList(String guestCidrList) { return true; } - public static boolean validateIcmpType(long icmpType) { + public static boolean validateIcmpType(final long icmpType) { //Source - http://www.erg.abdn.ac.uk/~gorry/course/inet-pages/icmp-code.html if (!(icmpType >= 0 && icmpType <= 255)) { s_logger.warn("impcType is not within 0-255 range"); @@ -1195,7 +1195,7 @@ public static boolean validateIcmpType(long icmpType) { return true; } - public static boolean validateIcmpCode(long icmpCode) { + public static boolean validateIcmpCode(final long icmpCode) { //Source - http://www.erg.abdn.ac.uk/~gorry/course/inet-pages/icmp-code.html if (!(icmpCode >= 0 && icmpCode <= 15)) { @@ -1206,162 +1206,162 @@ public static boolean validateIcmpCode(long icmpCode) { return true; } - public static boolean isValidIpv6(String ip) { + public static boolean isValidIpv6(final String ip) { try { IPv6Address.fromString(ip); - } catch (IllegalArgumentException ex) { + } catch (final IllegalArgumentException ex) { return false; } return true; } - public static boolean isValidIp6Cidr(String ip6Cidr) { + public static boolean isValidIp6Cidr(final String ip6Cidr) { try { IPv6Network.fromString(ip6Cidr); - } catch (IllegalArgumentException ex) { + } catch (final IllegalArgumentException ex) { return false; } return true; } - public static int getIp6CidrSize(String ip6Cidr) { + public static int getIp6CidrSize(final String ip6Cidr) { IPv6Network network = null; try { network = IPv6Network.fromString(ip6Cidr); - } catch (IllegalArgumentException ex) { + } catch (final IllegalArgumentException ex) { return 0; } return network.getNetmask().asPrefixLength(); } // Can cover 127 bits - public static String getIp6FromRange(String ip6Range) { - String[] ips = ip6Range.split("-"); - String startIp = ips[0]; - IPv6Address start = IPv6Address.fromString(startIp); - BigInteger gap = countIp6InRange(ip6Range); + public static String getIp6FromRange(final String ip6Range) { + final String[] ips = ip6Range.split("-"); + final String startIp = ips[0]; + final IPv6Address start = IPv6Address.fromString(startIp); + final BigInteger gap = countIp6InRange(ip6Range); BigInteger next = new BigInteger(gap.bitLength(), s_rand); while (next.compareTo(gap) >= 0) { next = new BigInteger(gap.bitLength(), s_rand); } InetAddress resultAddr = null; - BigInteger startInt = convertIPv6AddressToBigInteger(start); + final BigInteger startInt = convertIPv6AddressToBigInteger(start); if (startInt != null) { - BigInteger resultInt = startInt.add(next); + final BigInteger resultInt = startInt.add(next); try { resultAddr = InetAddress.getByAddress(resultInt.toByteArray()); - } catch (UnknownHostException e) { + } catch (final UnknownHostException e) { return null; } } if( resultAddr != null) { - IPv6Address ip = IPv6Address.fromInetAddress(resultAddr); + final IPv6Address ip = IPv6Address.fromInetAddress(resultAddr); return ip.toString(); } return null; } //RFC3315, section 9.4 - public static String getDuidLL(String macAddress) { - String duid = "00:03:00:01:" + macAddress; + public static String getDuidLL(final String macAddress) { + final String duid = "00:03:00:01:" + macAddress; return duid; } - private static BigInteger convertIPv6AddressToBigInteger(IPv6Address addr) { + private static BigInteger convertIPv6AddressToBigInteger(final IPv6Address addr) { InetAddress inetAddr; try { inetAddr = addr.toInetAddress(); - } catch (UnknownHostException e) { + } catch (final UnknownHostException e) { return null; } return new BigInteger(inetAddr.getAddress()); } // Can cover 127 bits - public static BigInteger countIp6InRange(String ip6Range) { + public static BigInteger countIp6InRange(final String ip6Range) { if (ip6Range == null) { return null; } - String[] ips = ip6Range.split("-"); - String startIp = ips[0]; + final String[] ips = ip6Range.split("-"); + final String startIp = ips[0]; String endIp = ips[0]; if (ips.length > 1) { endIp = ips[1]; } try { - BigInteger startInt = convertIPv6AddressToBigInteger(IPv6Address.fromString(startIp)); - BigInteger endInt = convertIPv6AddressToBigInteger(IPv6Address.fromString(endIp)); + final BigInteger startInt = convertIPv6AddressToBigInteger(IPv6Address.fromString(startIp)); + final BigInteger endInt = convertIPv6AddressToBigInteger(IPv6Address.fromString(endIp)); if (endInt != null && startInt != null && startInt.compareTo(endInt) <= 0) { return endInt.subtract(startInt).add(BigInteger.ONE); } - } catch (IllegalArgumentException ex) { + } catch (final IllegalArgumentException ex) { s_logger.error("Failed to convert a string to an IPv6 address", ex); } return null; } - public static boolean isIp6InRange(String ip6, String ip6Range) { + public static boolean isIp6InRange(final String ip6, final String ip6Range) { if (ip6Range == null) { return false; } - String[] ips = ip6Range.split("-"); - String startIp = ips[0]; + final String[] ips = ip6Range.split("-"); + final String startIp = ips[0]; String endIp = null; if (ips.length > 1) { endIp = ips[1]; } - IPv6Address start = IPv6Address.fromString(startIp); - IPv6Address end = IPv6Address.fromString(endIp); - IPv6Address ip = IPv6Address.fromString(ip6); + final IPv6Address start = IPv6Address.fromString(startIp); + final IPv6Address end = IPv6Address.fromString(endIp); + final IPv6Address ip = IPv6Address.fromString(ip6); if (start.compareTo(ip) <= 0 && end.compareTo(ip) >= 0) { return true; } return false; } - public static boolean isIp6InNetwork(String ip6, String ip6Cidr) { + public static boolean isIp6InNetwork(final String ip6, final String ip6Cidr) { IPv6Network network = null; try { network = IPv6Network.fromString(ip6Cidr); - } catch (IllegalArgumentException ex) { + } catch (final IllegalArgumentException ex) { return false; } - IPv6Address ip = IPv6Address.fromString(ip6); + final IPv6Address ip = IPv6Address.fromString(ip6); return network.contains(ip); } - public static boolean isIp6RangeOverlap(String ipRange1, String ipRange2) { + public static boolean isIp6RangeOverlap(final String ipRange1, final String ipRange2) { String[] ips = ipRange1.split("-"); - String startIp1 = ips[0]; + final String startIp1 = ips[0]; String endIp1 = null; if (ips.length > 1) { endIp1 = ips[1]; } - IPv6Address start1 = IPv6Address.fromString(startIp1); - IPv6Address end1 = IPv6Address.fromString(endIp1); - IPv6AddressRange range1 = IPv6AddressRange.fromFirstAndLast(start1, end1); + final IPv6Address start1 = IPv6Address.fromString(startIp1); + final IPv6Address end1 = IPv6Address.fromString(endIp1); + final IPv6AddressRange range1 = IPv6AddressRange.fromFirstAndLast(start1, end1); ips = ipRange2.split("-"); - String startIp2 = ips[0]; + final String startIp2 = ips[0]; String endIp2 = null; if (ips.length > 1) { endIp2 = ips[1]; } - IPv6Address start2 = IPv6Address.fromString(startIp2); - IPv6Address end2 = IPv6Address.fromString(endIp2); - IPv6AddressRange range2 = IPv6AddressRange.fromFirstAndLast(start2, end2); + final IPv6Address start2 = IPv6Address.fromString(startIp2); + final IPv6Address end2 = IPv6Address.fromString(endIp2); + final IPv6AddressRange range2 = IPv6AddressRange.fromFirstAndLast(start2, end2); return range1.overlaps(range2); } - public static String getNextIp6InRange(String currentIp, String ipRange) { - String[] ips = ipRange.split("-"); - String startIp = ips[0]; + public static String getNextIp6InRange(final String currentIp, final String ipRange) { + final String[] ips = ipRange.split("-"); + final String startIp = ips[0]; String endIp = null; if (ips.length > 1) { endIp = ips[1]; } - IPv6Address start = IPv6Address.fromString(startIp); - IPv6Address end = IPv6Address.fromString(endIp); - IPv6Address current = IPv6Address.fromString(currentIp); + final IPv6Address start = IPv6Address.fromString(startIp); + final IPv6Address end = IPv6Address.fromString(endIp); + final IPv6Address current = IPv6Address.fromString(currentIp); IPv6Address result = null; if (current.equals(end)) { result = start; @@ -1375,18 +1375,18 @@ public static String getNextIp6InRange(String currentIp, String ipRange) { return resultIp; } - public static String standardizeIp6Address(String ip6Addr) { + public static String standardizeIp6Address(final String ip6Addr) { try { return IPv6Address.fromString(ip6Addr).toString(); - } catch (IllegalArgumentException ex) { + } catch (final IllegalArgumentException ex) { throw new IllegalArgumentException("Invalid IPv6 address: " + ex.getMessage()); } } - public static String standardizeIp6Cidr(String ip6Cidr){ + public static String standardizeIp6Cidr(final String ip6Cidr){ try { return IPv6Network.fromString(ip6Cidr).toString(); - } catch (IllegalArgumentException ex) { + } catch (final IllegalArgumentException ex) { throw new IllegalArgumentException("Invalid IPv6 CIDR: " + ex.getMessage()); } } @@ -1395,17 +1395,19 @@ public static String standardizeIp6Cidr(String ip6Cidr){ static final int VLAN_PREFIX_LENGTH = VLAN_PREFIX.length(); public static boolean isValidVlan(String vlan) { - if (null == vlan || "".equals(vlan)) + if (null == vlan || "".equals(vlan)) { return false; - if (vlan.startsWith(VLAN_PREFIX)) + } + if (vlan.startsWith(VLAN_PREFIX)) { vlan = vlan.substring(VLAN_PREFIX_LENGTH); + } try { - int vnet = Integer.parseInt(vlan); + final int vnet = Integer.parseInt(vlan); if (vnet <= 0 || vnet >= 4095) { // the valid range is 1- 4094 return false; } return true; - } catch (NumberFormatException e) { + } catch (final NumberFormatException e) { return false; } } @@ -1443,24 +1445,24 @@ public static boolean isSameIsolationId(String one, String other) { // Attention maintainers: these pvlan functions should take into account code // in Networks.BroadcastDomainType, where URI construction is done for other // types of BroadcastDomainTypes - public static URI generateUriForPvlan(String primaryVlan, String isolatedPvlan) { + public static URI generateUriForPvlan(final String primaryVlan, final String isolatedPvlan) { return URI.create("pvlan://" + primaryVlan + "-i" + isolatedPvlan); } - public static String getPrimaryPvlanFromUri(URI uri) { - String[] vlans = uri.getHost().split("-"); + public static String getPrimaryPvlanFromUri(final URI uri) { + final String[] vlans = uri.getHost().split("-"); if (vlans.length < 1) { return null; } return vlans[0]; } - public static String getIsolatedPvlanFromUri(URI uri) { - String[] vlans = uri.getHost().split("-"); + public static String getIsolatedPvlanFromUri(final URI uri) { + final String[] vlans = uri.getHost().split("-"); if (vlans.length < 2) { return null; } - for (String vlan : vlans) { + for (final String vlan : vlans) { if (vlan.startsWith("i")) { return vlan.replace("i", " ").trim(); } @@ -1468,7 +1470,7 @@ public static String getIsolatedPvlanFromUri(URI uri) { return null; } - public static String generateMacOnIncrease(String baseMac, long l) { + public static String generateMacOnIncrease(final String baseMac, final long l) { long mac = mac2Long(baseMac); if (l > 0xFFFFl) { return null; @@ -1478,32 +1480,36 @@ public static String generateMacOnIncrease(String baseMac, long l) { return long2Mac(mac); } - public static boolean isIpWithtInCidrRange(String ipAddress, String cidr) { + public static boolean isIpWithtInCidrRange(final String ipAddress, final String cidr) { if (!isValidIp(ipAddress)) { return false; } if (!isValidCIDR(cidr)) { return false; } - SubnetUtils subnetUtils = new SubnetUtils(cidr); - return subnetUtils.getInfo().isInRange(ipAddress); + final SubnetUtils subnetUtils = new SubnetUtils(cidr); + subnetUtils.setInclusiveHostCount(true); + + final boolean isInRange = subnetUtils.getInfo().isInRange(ipAddress); + + return isInRange; } - public static Boolean IsIpEqualToNetworkOrBroadCastIp(String requestedIp, String cidr, long size) { - assert (size < 32) : "You do know this is not for ipv6 right? Keep it smaller than 32 but you have " + size; + public static Boolean IsIpEqualToNetworkOrBroadCastIp(final String requestedIp, final String cidr, final long size) { + assert size < 32 : "You do know this is not for ipv6 right? Keep it smaller than 32 but you have " + size; - long ip = ip2Long(cidr); - long startNetMask = ip2Long(getCidrNetmask(size)); + final long ip = ip2Long(cidr); + final long startNetMask = ip2Long(getCidrNetmask(size)); - long start = (ip & startNetMask); + final long start = ip & startNetMask; long end = start; - end = end >> (32 - size); + end = end >> 32 - size; end++; - end = (end << (32 - size)) - 1; + end = (end << 32 - size) - 1; - long reqIp = ip2Long(requestedIp); + final long reqIp = ip2Long(requestedIp); if (reqIp == start || reqIp == end) { return true; } diff --git a/utils/test/com/cloud/utils/net/NetUtilsTest.java b/utils/test/com/cloud/utils/net/NetUtilsTest.java index c4eceaba7f79..fa4042d318aa 100644 --- a/utils/test/com/cloud/utils/net/NetUtilsTest.java +++ b/utils/test/com/cloud/utils/net/NetUtilsTest.java @@ -46,11 +46,11 @@ public class NetUtilsTest { @Test public void testGetRandomIpFromCidrWithSize24() throws Exception { - String cidr = "192.168.124.1"; - int size = 24; - int netCharacters = 12; + final String cidr = "192.168.124.1"; + final int size = 24; + final int netCharacters = 12; - long ip = NetUtils.getRandomIpFromCidr(cidr, size, new TreeSet()); + final long ip = NetUtils.getRandomIpFromCidr(cidr, size, new TreeSet()); assertThat("The ip " + NetUtils.long2Ip(ip) + " retrieved must be within the cidr " + cidr + "/" + size, cidr.substring(0, netCharacters), equalTo(NetUtils.long2Ip(ip) .substring(0, netCharacters))); @@ -58,11 +58,11 @@ public void testGetRandomIpFromCidrWithSize24() throws Exception { @Test public void testGetRandomIpFromCidrWithSize16() throws Exception { - String cidr = "192.168.124.1"; - int size = 16; - int netCharacters = 8; + final String cidr = "192.168.124.1"; + final int size = 16; + final int netCharacters = 8; - long ip = NetUtils.getRandomIpFromCidr(cidr, 16, new TreeSet()); + final long ip = NetUtils.getRandomIpFromCidr(cidr, 16, new TreeSet()); assertThat("The ip " + NetUtils.long2Ip(ip) + " retrieved must be within the cidr " + cidr + "/" + size, cidr.substring(0, netCharacters), equalTo(NetUtils.long2Ip(ip) .substring(0, netCharacters))); @@ -70,11 +70,11 @@ public void testGetRandomIpFromCidrWithSize16() throws Exception { @Test public void testGetRandomIpFromCidrWithSize8() throws Exception { - String cidr = "192.168.124.1"; - int size = 8; - int netCharacters = 4; + final String cidr = "192.168.124.1"; + final int size = 8; + final int netCharacters = 4; - long ip = NetUtils.getRandomIpFromCidr(cidr, 16, new TreeSet()); + final long ip = NetUtils.getRandomIpFromCidr(cidr, 16, new TreeSet()); assertThat("The ip " + NetUtils.long2Ip(ip) + " retrieved must be within the cidr " + cidr + "/" + size, cidr.substring(0, netCharacters), equalTo(NetUtils.long2Ip(ip) .substring(0, netCharacters))); @@ -82,10 +82,10 @@ public void testGetRandomIpFromCidrWithSize8() throws Exception { @Test public void testGetRandomIpFromCidrUsignAvoid() throws Exception { - String cidr = "192.168.124.1"; - int size = 30; + final String cidr = "192.168.124.1"; + final int size = 30; - SortedSet avoid = new TreeSet(); + final SortedSet avoid = new TreeSet(); long ip = NetUtils.getRandomIpFromCidr(cidr, size, avoid); assertThat("We should be able to retrieve an ip on the first call.", ip, not(equalTo(-1L))); avoid.add(ip); @@ -121,17 +121,17 @@ public void testIsValidS2SVpnPolicy() { public void testGetIp6FromRange() { assertEquals(NetUtils.getIp6FromRange("1234:5678::1-1234:5678::1"), "1234:5678::1"); for (int i = 0; i < 5; i++) { - String ip = NetUtils.getIp6FromRange("1234:5678::1-1234:5678::2"); + final String ip = NetUtils.getIp6FromRange("1234:5678::1-1234:5678::2"); assertThat(ip, anyOf(equalTo("1234:5678::1"), equalTo("1234:5678::2"))); s_logger.info("IP is " + ip); } String ipString = null; - IPv6Address ipStart = IPv6Address.fromString("1234:5678::1"); - IPv6Address ipEnd = IPv6Address.fromString("1234:5678::ffff:ffff:ffff:ffff"); + final IPv6Address ipStart = IPv6Address.fromString("1234:5678::1"); + final IPv6Address ipEnd = IPv6Address.fromString("1234:5678::ffff:ffff:ffff:ffff"); for (int i = 0; i < 10; i++) { ipString = NetUtils.getIp6FromRange(ipStart.toString() + "-" + ipEnd.toString()); s_logger.info("IP is " + ipString); - IPv6Address ip = IPv6Address.fromString(ipString); + final IPv6Address ip = IPv6Address.fromString(ipString); assertThat(ip, greaterThanOrEqualTo(ipStart)); assertThat(ip, lessThanOrEqualTo(ipEnd)); } @@ -236,9 +236,9 @@ public void testGetIsolatedPvlanFromUri() { @Test public void testIsValidCIDR() throws Exception { //Test to check IP Range of 2 CIDR - String cidrFirst = "10.0.144.0/20"; - String cidrSecond = "10.0.151.0/20"; - String cidrThird = "10.0.144.0/21"; + final String cidrFirst = "10.0.144.0/20"; + final String cidrSecond = "10.0.151.0/20"; + final String cidrThird = "10.0.144.0/21"; assertTrue(NetUtils.isValidCIDR(cidrFirst)); assertTrue(NetUtils.isValidCIDR(cidrSecond)); @@ -247,9 +247,9 @@ public void testIsValidCIDR() throws Exception { @Test public void testIsValidCidrList() throws Exception { - String cidrFirst = "10.0.144.0/20,1.2.3.4/32,5.6.7.8/24"; - String cidrSecond = "10.0.151.0/20,129.0.0.0/4"; - String cidrThird = "10.0.144.0/21"; + final String cidrFirst = "10.0.144.0/20,1.2.3.4/32,5.6.7.8/24"; + final String cidrSecond = "10.0.151.0/20,129.0.0.0/4"; + final String cidrThird = "10.0.144.0/21"; assertTrue(NetUtils.isValidCidrList(cidrFirst)); assertTrue(NetUtils.isValidCidrList(cidrSecond)); @@ -258,9 +258,9 @@ public void testIsValidCidrList() throws Exception { @Test public void testIsSameIpRange() { - String cidrFirst = "10.0.144.0/20"; - String cidrSecond = "10.0.151.0/20"; - String cidrThird = "10.0.144.0/21"; + final String cidrFirst = "10.0.144.0/20"; + final String cidrSecond = "10.0.151.0/20"; + final String cidrThird = "10.0.144.0/21"; //Check for exactly same CIDRs assertTrue(NetUtils.isSameIpRange(cidrFirst, cidrFirst)); @@ -299,7 +299,7 @@ public void testSameIsolationId() { @Test public void testValidateGuestCidr() throws Exception { - String guestCidr = "192.168.1.0/24"; + final String guestCidr = "192.168.1.0/24"; assertTrue(NetUtils.validateGuestCidr(guestCidr)); } @@ -342,4 +342,33 @@ public void testLong2Ip() { assertEquals("8.8.8.8", NetUtils.long2Ip(0x08080808l)); } -} + @Test + public void test31BitPrefixStart() { + final String ipAddress = "192.168.0.0"; + final String cidr = "192.168.0.0/31"; + + final boolean isInRange = NetUtils.isIpWithtInCidrRange(ipAddress, cidr); + + assertTrue("Check if the subnetUtils.setInclusiveHostCount(true) has been called.", isInRange); + } + + @Test + public void test31BitPrefixEnd() { + final String ipAddress = "192.168.0.1"; + final String cidr = "192.168.0.0/31"; + + final boolean isInRange = NetUtils.isIpWithtInCidrRange(ipAddress, cidr); + + assertTrue("Check if the subnetUtils.setInclusiveHostCount(true) has been called.", isInRange); + } + + @Test + public void test31BitPrefixFail() { + final String ipAddress = "192.168.0.2"; + final String cidr = "192.168.0.0/31"; + + final boolean isInRange = NetUtils.isIpWithtInCidrRange(ipAddress, cidr); + + assertFalse("Out of the range. Why did it return true?", isInRange); + } +} \ No newline at end of file From cd55413c6ac469c49f1c19b9596a9390cedd611b Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Fri, 22 May 2015 14:21:36 +0100 Subject: [PATCH 110/175] CLOUDSTACK-8243: KVM agent should not use hardcoded string tails For KVM agent, guid is configurable in agent.properties, this fix allows the configuration to work by removing string tail (the -LibvirtComputingResource suffix). Signed-off-by: Rohit Yadav This closes #286 (cherry picked from commit 803b946c2feae193d04219d2360c6d4440f212f1) Signed-off-by: Rohit Yadav --- .../discoverer/LibvirtServerDiscoverer.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/server/src/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java b/server/src/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java index 350b9a72ca1d..774f68e9326c 100644 --- a/server/src/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java +++ b/server/src/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java @@ -139,15 +139,15 @@ public boolean processTimeout(long agentId, long seq) { InetAddress ia = InetAddress.getByName(hostname); agentIp = ia.getHostAddress(); String guid = UUID.nameUUIDFromBytes(agentIp.getBytes()).toString(); - String guidWithTail = guid + "-LibvirtComputingResource";/* - * tail - * added by - * agent - * .java - */ - if (_resourceMgr.findHostByGuid(guidWithTail) != null) { - s_logger.debug("Skipping " + agentIp + " because " + guidWithTail + " is already in the database."); - return null; + + List existingHosts = _resourceMgr.listAllHostsInOneZoneByType(Host.Type.Routing, dcId); + if (existingHosts != null) { + for (HostVO existingHost : existingHosts) { + if (existingHost.getGuid().toLowerCase().startsWith(guid.toLowerCase())) { + s_logger.debug("Skipping " + agentIp + " because " + guid + " is already in the database for resource " + existingHost.getGuid()); + return null; + } + } } sshConnection = new com.trilead.ssh2.Connection(agentIp, 22); @@ -225,11 +225,11 @@ public boolean processTimeout(long agentId, long seq) { kvmResource.configure("kvm agent", params); resources.put(kvmResource, details); - HostVO connectedHost = waitForHostConnect(dcId, podId, clusterId, guidWithTail); + HostVO connectedHost = waitForHostConnect(dcId, podId, clusterId, guid); if (connectedHost == null) return null; - details.put("guid", guidWithTail); + details.put("guid", connectedHost.getGuid()); // place a place holder guid derived from cluster ID if (cluster.getGuid() == null) { @@ -261,7 +261,7 @@ private HostVO waitForHostConnect(long dcId, long podId, long clusterId, String for (int i = 0; i < _waitTime * 2; i++) { List hosts = _resourceMgr.listAllUpAndEnabledHosts(Host.Type.Routing, clusterId, podId, dcId); for (HostVO host : hosts) { - if (host.getGuid().equalsIgnoreCase(guid)) { + if (host.getGuid().toLowerCase().startsWith(guid.toLowerCase())) { return host; } } From a83f74d83e4d0699ad631d2efa4cd674bc53076b Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Fri, 22 May 2015 20:08:09 +0200 Subject: [PATCH 111/175] CLOUDSTACK-8506 - Changing the implementation of the NetUtils.ipRangesOverlap() a little bit in order to be compliant with RFC 3021 - 2 unit tests added - ranges from 0 to 255 covered by the tests, which also test the negative cases. --- .../ConfigurationManagerImpl.java | 5 +++ utils/src/com/cloud/utils/net/NetUtils.java | 18 +++++++++ .../com/cloud/utils/net/NetUtilsTest.java | 40 +++++++++++++++++++ 3 files changed, 63 insertions(+) diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index d08cac6566d4..182c67c19002 100644 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -3556,6 +3556,11 @@ private void checkPublicIpRangeErrors(long zoneId, String vlanId, String vlanGat throw new InvalidParameterValueException("Please ensure that your end IP is in the same subnet as your IP range's gateway, as per the IP range's netmask."); } // check if the gatewayip is the part of the ip range being added. + // RFC 3021 - 31-Bit Prefixes on IPv4 Point-to-Point Links + // GW Netmask Stat IP End IP + // 192.168.24.0 - 255.255.255.254 - 192.168.24.0 - 192.168.24.1 + // https://tools.ietf.org/html/rfc3021 + // Added by Wilder Rodrigues if (NetUtils.ipRangesOverlap(startIP, endIP, vlanGateway, vlanGateway)) { throw new InvalidParameterValueException( "The gateway ip should not be the part of the ip range being added."); diff --git a/utils/src/com/cloud/utils/net/NetUtils.java b/utils/src/com/cloud/utils/net/NetUtils.java index a93f65d79e07..19dec36367b4 100644 --- a/utils/src/com/cloud/utils/net/NetUtils.java +++ b/utils/src/com/cloud/utils/net/NetUtils.java @@ -358,6 +358,17 @@ public static boolean ipRangesOverlap(final String startIp1, final String endIp1 endIp2Long = ip2Long(endIp2); } + // check if the gatewayip is the part of the ip range being added. + // RFC 3021 - 31-Bit Prefixes on IPv4 Point-to-Point Links + // GW Netmask Stat IP End IP + // 192.168.24.0 - 255.255.255.254 - 192.168.24.0 - 192.168.24.1 + // https://tools.ietf.org/html/rfc3021 + // Added by Wilder Rodrigues + final int ip31bitPrefixOffSet = 1; + if (startIp2Long - startIp1Long == startIp2Long - (endIp1Long - ip31bitPrefixOffSet)) { + return false; + } + if (startIp1Long == startIp2Long || startIp1Long == endIp2Long || endIp1Long == startIp2Long || endIp1Long == endIp2Long) { return true; } else if (startIp1Long > startIp2Long && startIp1Long < endIp2Long) { @@ -1487,6 +1498,13 @@ public static boolean isIpWithtInCidrRange(final String ipAddress, final String if (!isValidCIDR(cidr)) { return false; } + + // check if the gatewayip is the part of the ip range being added. + // RFC 3021 - 31-Bit Prefixes on IPv4 Point-to-Point Links + // GW Netmask Stat IP End IP + // 192.168.24.0 - 255.255.255.254 - 192.168.24.0 - 192.168.24.1 + // https://tools.ietf.org/html/rfc3021 + // Added by Wilder Rodrigues final SubnetUtils subnetUtils = new SubnetUtils(cidr); subnetUtils.setInclusiveHostCount(true); diff --git a/utils/test/com/cloud/utils/net/NetUtilsTest.java b/utils/test/com/cloud/utils/net/NetUtilsTest.java index fa4042d318aa..0130b9a1b7f9 100644 --- a/utils/test/com/cloud/utils/net/NetUtilsTest.java +++ b/utils/test/com/cloud/utils/net/NetUtilsTest.java @@ -371,4 +371,44 @@ public void test31BitPrefixFail() { assertFalse("Out of the range. Why did it return true?", isInRange); } + + @Test + public void test31BitPrefixIpRangesOverlapd() { + final String gw = "192.168.0.0"; + String ip1; + String ip2; + + // 192.168.0.0 - 192.168.0.0 - 192.168.0.1 + // GW and IP1 overlaps, but in that case it's a 31bit IP. + // 192.168.0.0 - 192.168.0.1 - 192.168.0.2 + // GW and IP1 overlaps, but in that case it's a 31bit IP. + // and so on. + + for (int i = 0, j = 1; i <= 254; i++, j++) { + ip1 = "192.168.0." + i; + ip2 = "192.168.0." + j; + + final boolean doesOverlap = NetUtils.ipRangesOverlap(ip1, ip2, gw, gw); + assertFalse("It should overlap, but it's a 31-bit ip", doesOverlap); + } + } + + @Test + public void test31BitPrefixIpRangesOverlapdFail() { + String gw; + String ip1; + String ip2; + + // 192.168.0.10 - 192.168.0.10 - 192.168.0.12 + // GW and IP1 overlaps and in that case it's not a 31bit IP. + + for (int i = 10, j = 12; i <= 254; i++, j++) { + gw = "192.168.0." + i; + ip1 = "192.168.0." + i; + ip2 = "192.168.0." + j; + + final boolean doesOverlap = NetUtils.ipRangesOverlap(ip1, ip2, gw, gw); + assertTrue("It overlaps!", doesOverlap); + } + } } \ No newline at end of file From 79d24ae218889b36674f2c064701638b3f2c5e29 Mon Sep 17 00:00:00 2001 From: Rafael da Fonseca Date: Sat, 23 May 2015 16:14:09 +0200 Subject: [PATCH 112/175] Fix xenserver tests for travis --- .../hypervisor/xenserver/resource/CitrixResourceBase.java | 4 ++-- .../wrapper/{ => citrix}/CitrixAttachIsoCommandWrapper.java | 2 +- .../{ => citrix}/CitrixAttachVolumeCommandWrapper.java | 2 +- .../CitrixCheckConsoleProxyLoadCommandWrapper.java | 2 +- .../{ => citrix}/CitrixCheckHealthCommandWrapper.java | 2 +- .../{ => citrix}/CitrixCheckNetworkCommandWrapper.java | 2 +- .../{ => citrix}/CitrixCheckOnHostCommandWrapper.java | 2 +- .../wrapper/{ => citrix}/CitrixCheckSshCommandWrapper.java | 2 +- .../CitrixCheckVirtualMachineCommandWrapper.java | 2 +- .../{ => citrix}/CitrixCleanupNetworkRulesCmdWrapper.java | 2 +- .../CitrixClusterVMMetaDataSyncCommandWrapper.java | 2 +- .../{ => citrix}/CitrixConsoleProxyLoadCommandWrapper.java | 2 +- .../wrapper/{ => citrix}/CitrixCreateCommandWrapper.java | 2 +- .../{ => citrix}/CitrixCreateStoragePoolCommandWrapper.java | 2 +- .../{ => citrix}/CitrixCreateVMSnapshotCommandWrapper.java | 2 +- .../{ => citrix}/CitrixDeleteStoragePoolCommandWrapper.java | 2 +- .../{ => citrix}/CitrixDeleteVMSnapshotCommandWrapper.java | 2 +- .../wrapper/{ => citrix}/CitrixDestroyCommandWrapper.java | 2 +- .../{ => citrix}/CitrixGetHostStatsCommandWrapper.java | 2 +- .../{ => citrix}/CitrixGetStorageStatsCommandWrapper.java | 2 +- .../{ => citrix}/CitrixGetVmDiskStatsCommandWrapper.java | 2 +- .../{ => citrix}/CitrixGetVmStatsCommandWrapper.java | 2 +- .../{ => citrix}/CitrixGetVncPortCommandWrapper.java | 2 +- .../wrapper/{ => citrix}/CitrixMaintainCommandWrapper.java | 2 +- .../wrapper/{ => citrix}/CitrixMigrateCommandWrapper.java | 2 +- .../{ => citrix}/CitrixModifySshKeysCommandWrapper.java | 2 +- .../{ => citrix}/CitrixModifyStoragePoolCommandWrapper.java | 2 +- .../{ => citrix}/CitrixNetworkElementCommandWrapper.java | 2 +- .../CitrixNetworkRulesSystemVmCommandWrapper.java | 2 +- .../CitrixNetworkRulesVmSecondaryIpCommandWrapper.java | 2 +- .../CitrixOvsCreateGreTunnelCommandWrapper.java | 2 +- .../{ => citrix}/CitrixOvsCreateTunnelCommandWrapper.java | 2 +- .../{ => citrix}/CitrixOvsDeleteFlowCommandWrapper.java | 2 +- .../{ => citrix}/CitrixOvsDestroyBridgeCommandWrapper.java | 2 +- .../{ => citrix}/CitrixOvsDestroyTunnelCommandWrapper.java | 2 +- .../{ => citrix}/CitrixOvsFetchInterfaceCommandWrapper.java | 2 +- .../{ => citrix}/CitrixOvsSetTagAndFlowCommandWrapper.java | 2 +- .../{ => citrix}/CitrixOvsSetupBridgeCommandWrapper.java | 2 +- .../CitrixOvsVpcPhysicalTopologyConfigCommandWrapper.java | 2 +- .../CitrixOvsVpcRoutingPolicyConfigCommandWrapper.java | 2 +- .../CitrixPerformanceMonitorCommandWrapper.java | 2 +- .../wrapper/{ => citrix}/CitrixPingTestCommandWrapper.java | 2 +- .../wrapper/{ => citrix}/CitrixPlugNicCommandWrapper.java | 2 +- .../CitrixPrepareForMigrationCommandWrapper.java | 2 +- .../CitrixPrimaryStorageDownloadCommandWrapper.java | 2 +- .../{ => citrix}/CitrixPvlanSetupCommandWrapper.java | 2 +- .../wrapper/{ => citrix}/CitrixReadyCommandWrapper.java | 2 +- .../wrapper/{ => citrix}/CitrixRebootCommandWrapper.java | 2 +- .../{ => citrix}/CitrixRebootRouterCommandWrapper.java | 2 +- .../resource/wrapper/{ => citrix}/CitrixRequestWrapper.java | 6 +++--- .../{ => citrix}/CitrixResizeVolumeCommandWrapper.java | 2 +- .../CitrixRevertToVMSnapshotCommandWrapper.java | 2 +- .../wrapper/{ => citrix}/CitrixScaleVmCommandWrapper.java | 2 +- .../CitrixSecurityGroupRulesCommandWrapper.java | 2 +- .../wrapper/{ => citrix}/CitrixSetupCommandWrapper.java | 2 +- .../wrapper/{ => citrix}/CitrixStartCommandWrapper.java | 2 +- .../wrapper/{ => citrix}/CitrixStopCommandWrapper.java | 2 +- .../{ => citrix}/CitrixStorageSubSystemCommandWrapper.java | 2 +- .../wrapper/{ => citrix}/CitrixUnPlugNicCommandWrapper.java | 2 +- .../CitrixUpdateHostPasswordCommandWrapper.java | 2 +- .../{ => citrix}/CitrixUpgradeSnapshotCommandWrapper.java | 2 +- .../CitrixWatchConsoleProxyLoadCommandWrapper.java | 2 +- .../resource/wrapper/CitrixRequestWrapperTest.java | 5 +++-- .../xenserver/resource/wrapper/XcpServerWrapperTest.java | 2 +- .../resource/wrapper/XenServer56FP1WrapperTest.java | 2 +- .../xenserver/resource/wrapper/XenServer56WrapperTest.java | 2 +- .../xenserver/resource/wrapper/XenServer610WrapperTest.java | 2 +- .../resource/wrapper/XenServer620SP1WrapperTest.java | 2 +- .../xenserver/resource/wrapper/XenServer620WrapperTest.java | 2 +- 69 files changed, 74 insertions(+), 73 deletions(-) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixAttachIsoCommandWrapper.java (98%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixAttachVolumeCommandWrapper.java (98%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixCheckConsoleProxyLoadCommandWrapper.java (96%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixCheckHealthCommandWrapper.java (95%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixCheckNetworkCommandWrapper.java (98%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixCheckOnHostCommandWrapper.java (95%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixCheckSshCommandWrapper.java (97%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixCheckVirtualMachineCommandWrapper.java (97%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixCleanupNetworkRulesCmdWrapper.java (97%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixClusterVMMetaDataSyncCommandWrapper.java (97%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixConsoleProxyLoadCommandWrapper.java (98%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixCreateCommandWrapper.java (98%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixCreateStoragePoolCommandWrapper.java (97%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixCreateVMSnapshotCommandWrapper.java (99%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixDeleteStoragePoolCommandWrapper.java (97%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixDeleteVMSnapshotCommandWrapper.java (98%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixDestroyCommandWrapper.java (98%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixGetHostStatsCommandWrapper.java (97%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixGetStorageStatsCommandWrapper.java (98%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixGetVmDiskStatsCommandWrapper.java (95%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixGetVmStatsCommandWrapper.java (98%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixGetVncPortCommandWrapper.java (97%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixMaintainCommandWrapper.java (98%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixMigrateCommandWrapper.java (98%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixModifySshKeysCommandWrapper.java (95%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixModifyStoragePoolCommandWrapper.java (98%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixNetworkElementCommandWrapper.java (96%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixNetworkRulesSystemVmCommandWrapper.java (96%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixNetworkRulesVmSecondaryIpCommandWrapper.java (96%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixOvsCreateGreTunnelCommandWrapper.java (98%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixOvsCreateTunnelCommandWrapper.java (98%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixOvsDeleteFlowCommandWrapper.java (97%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixOvsDestroyBridgeCommandWrapper.java (97%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixOvsDestroyTunnelCommandWrapper.java (97%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixOvsFetchInterfaceCommandWrapper.java (98%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixOvsSetTagAndFlowCommandWrapper.java (98%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixOvsSetupBridgeCommandWrapper.java (96%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixOvsVpcPhysicalTopologyConfigCommandWrapper.java (97%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixOvsVpcRoutingPolicyConfigCommandWrapper.java (97%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixPerformanceMonitorCommandWrapper.java (96%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixPingTestCommandWrapper.java (96%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixPlugNicCommandWrapper.java (98%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixPrepareForMigrationCommandWrapper.java (97%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixPrimaryStorageDownloadCommandWrapper.java (98%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixPvlanSetupCommandWrapper.java (98%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixReadyCommandWrapper.java (98%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixRebootCommandWrapper.java (97%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixRebootRouterCommandWrapper.java (97%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixRequestWrapper.java (98%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixResizeVolumeCommandWrapper.java (97%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixRevertToVMSnapshotCommandWrapper.java (98%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixScaleVmCommandWrapper.java (98%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixSecurityGroupRulesCommandWrapper.java (98%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixSetupCommandWrapper.java (99%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixStartCommandWrapper.java (99%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixStopCommandWrapper.java (99%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixStorageSubSystemCommandWrapper.java (96%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixUnPlugNicCommandWrapper.java (97%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixUpdateHostPasswordCommandWrapper.java (95%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixUpgradeSnapshotCommandWrapper.java (97%) rename plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/{ => citrix}/CitrixWatchConsoleProxyLoadCommandWrapper.java (96%) diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java index 6aaaf0e737ba..720fca27433c 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java @@ -98,7 +98,7 @@ import com.cloud.exception.InternalErrorException; import com.cloud.host.Host.Type; import com.cloud.hypervisor.Hypervisor.HypervisorType; -import com.cloud.hypervisor.xenserver.resource.wrapper.CitrixRequestWrapper; +import com.cloud.hypervisor.xenserver.resource.wrapper.citrix.CitrixRequestWrapper; import com.cloud.network.Networks; import com.cloud.network.Networks.BroadcastDomainType; import com.cloud.network.Networks.TrafficType; @@ -4940,4 +4940,4 @@ public void waitForTask(final Connection c, final Task task, final long pollInte } } } -} \ No newline at end of file +} diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixAttachIsoCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixAttachIsoCommandWrapper.java similarity index 98% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixAttachIsoCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixAttachIsoCommandWrapper.java index 22fc1ac92190..aa84b837ebdf 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixAttachIsoCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixAttachIsoCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import java.util.Set; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixAttachVolumeCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixAttachVolumeCommandWrapper.java similarity index 98% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixAttachVolumeCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixAttachVolumeCommandWrapper.java index 37d28b740c31..9a1afa0bc166 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixAttachVolumeCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixAttachVolumeCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import java.util.Set; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckConsoleProxyLoadCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixCheckConsoleProxyLoadCommandWrapper.java similarity index 96% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckConsoleProxyLoadCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixCheckConsoleProxyLoadCommandWrapper.java index 83f5a8023717..f48f8785f50d 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckConsoleProxyLoadCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixCheckConsoleProxyLoadCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import com.cloud.agent.api.Answer; import com.cloud.agent.api.Command; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckHealthCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixCheckHealthCommandWrapper.java similarity index 95% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckHealthCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixCheckHealthCommandWrapper.java index 4e36ab7991e7..577fbc19a73c 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckHealthCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixCheckHealthCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import com.cloud.agent.api.Answer; import com.cloud.agent.api.CheckHealthAnswer; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckNetworkCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixCheckNetworkCommandWrapper.java similarity index 98% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckNetworkCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixCheckNetworkCommandWrapper.java index ca55ab6f74d1..04189b5b5b86 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckNetworkCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixCheckNetworkCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import java.util.List; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckOnHostCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixCheckOnHostCommandWrapper.java similarity index 95% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckOnHostCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixCheckOnHostCommandWrapper.java index ffe11951d187..e8a0affbcabe 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckOnHostCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixCheckOnHostCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import com.cloud.agent.api.Answer; import com.cloud.agent.api.CheckOnHostAnswer; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckSshCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixCheckSshCommandWrapper.java similarity index 97% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckSshCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixCheckSshCommandWrapper.java index 64a4a3f335eb..605340f08542 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckSshCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixCheckSshCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import org.apache.log4j.Logger; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckVirtualMachineCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixCheckVirtualMachineCommandWrapper.java similarity index 97% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckVirtualMachineCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixCheckVirtualMachineCommandWrapper.java index a1954f42b80d..4fbd15ba3c22 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCheckVirtualMachineCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixCheckVirtualMachineCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import org.apache.log4j.Logger; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCleanupNetworkRulesCmdWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixCleanupNetworkRulesCmdWrapper.java similarity index 97% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCleanupNetworkRulesCmdWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixCleanupNetworkRulesCmdWrapper.java index 4b2d5d3ba31d..8be398932d06 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCleanupNetworkRulesCmdWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixCleanupNetworkRulesCmdWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import org.apache.log4j.Logger; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixClusterVMMetaDataSyncCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixClusterVMMetaDataSyncCommandWrapper.java similarity index 97% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixClusterVMMetaDataSyncCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixClusterVMMetaDataSyncCommandWrapper.java index 84bbf984e70a..e601bb6ad540 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixClusterVMMetaDataSyncCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixClusterVMMetaDataSyncCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import java.util.HashMap; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixConsoleProxyLoadCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixConsoleProxyLoadCommandWrapper.java similarity index 98% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixConsoleProxyLoadCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixConsoleProxyLoadCommandWrapper.java index 4e71b0e1237a..d3f694aae3c1 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixConsoleProxyLoadCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixConsoleProxyLoadCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import java.io.BufferedReader; import java.io.IOException; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCreateCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixCreateCommandWrapper.java similarity index 98% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCreateCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixCreateCommandWrapper.java index c658fd9685e0..81dabffcd300 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCreateCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixCreateCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import java.util.HashMap; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCreateStoragePoolCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixCreateStoragePoolCommandWrapper.java similarity index 97% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCreateStoragePoolCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixCreateStoragePoolCommandWrapper.java index 309859736b7c..c74cb1a67d00 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCreateStoragePoolCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixCreateStoragePoolCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import org.apache.log4j.Logger; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCreateVMSnapshotCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixCreateVMSnapshotCommandWrapper.java similarity index 99% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCreateVMSnapshotCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixCreateVMSnapshotCommandWrapper.java index 4b8d616bf9f4..0456686b4525 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixCreateVMSnapshotCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixCreateVMSnapshotCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import java.util.LinkedHashSet; import java.util.List; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixDeleteStoragePoolCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixDeleteStoragePoolCommandWrapper.java similarity index 97% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixDeleteStoragePoolCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixDeleteStoragePoolCommandWrapper.java index 6d2054b64de3..83d518e31953 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixDeleteStoragePoolCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixDeleteStoragePoolCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import org.apache.log4j.Logger; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixDeleteVMSnapshotCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixDeleteVMSnapshotCommandWrapper.java similarity index 98% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixDeleteVMSnapshotCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixDeleteVMSnapshotCommandWrapper.java index 4f9d57ab4e7c..fb00205d7fd1 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixDeleteVMSnapshotCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixDeleteVMSnapshotCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import java.util.ArrayList; import java.util.List; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixDestroyCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixDestroyCommandWrapper.java similarity index 98% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixDestroyCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixDestroyCommandWrapper.java index 15f9f1c7602b..2b7df86789e6 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixDestroyCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixDestroyCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import java.util.Set; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetHostStatsCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixGetHostStatsCommandWrapper.java similarity index 97% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetHostStatsCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixGetHostStatsCommandWrapper.java index 02c3770ba86e..a50737f37ff3 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetHostStatsCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixGetHostStatsCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import org.apache.log4j.Logger; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetStorageStatsCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixGetStorageStatsCommandWrapper.java similarity index 98% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetStorageStatsCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixGetStorageStatsCommandWrapper.java index 8726141029e8..404531a1d171 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetStorageStatsCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixGetStorageStatsCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import java.util.Set; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetVmDiskStatsCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixGetVmDiskStatsCommandWrapper.java similarity index 95% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetVmDiskStatsCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixGetVmDiskStatsCommandWrapper.java index 18e05c47e555..958d48fc7ece 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetVmDiskStatsCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixGetVmDiskStatsCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import com.cloud.agent.api.Answer; import com.cloud.agent.api.GetVmDiskStatsAnswer; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetVmStatsCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixGetVmStatsCommandWrapper.java similarity index 98% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetVmStatsCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixGetVmStatsCommandWrapper.java index 5dce256dd2d2..43aefb8f8c8d 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetVmStatsCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixGetVmStatsCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import java.util.ArrayList; import java.util.HashMap; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetVncPortCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixGetVncPortCommandWrapper.java similarity index 97% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetVncPortCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixGetVncPortCommandWrapper.java index d57ab5731683..a432088a7d7d 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixGetVncPortCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixGetVncPortCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import java.util.Set; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixMaintainCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixMaintainCommandWrapper.java similarity index 98% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixMaintainCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixMaintainCommandWrapper.java index 8b56e9b9585d..86f05eec5e04 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixMaintainCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixMaintainCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import java.util.Iterator; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixMigrateCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixMigrateCommandWrapper.java similarity index 98% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixMigrateCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixMigrateCommandWrapper.java index a4265ddd9ca4..a8d2d22c889b 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixMigrateCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixMigrateCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import java.util.Set; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixModifySshKeysCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixModifySshKeysCommandWrapper.java similarity index 95% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixModifySshKeysCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixModifySshKeysCommandWrapper.java index f44307425bb6..012e8b7c0a0f 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixModifySshKeysCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixModifySshKeysCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import com.cloud.agent.api.Answer; import com.cloud.agent.api.ModifySshKeysCommand; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixModifyStoragePoolCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixModifyStoragePoolCommandWrapper.java similarity index 98% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixModifyStoragePoolCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixModifyStoragePoolCommandWrapper.java index 64848a408eda..3d51493512e4 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixModifyStoragePoolCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixModifyStoragePoolCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import java.util.HashMap; import java.util.Map; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixNetworkElementCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixNetworkElementCommandWrapper.java similarity index 96% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixNetworkElementCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixNetworkElementCommandWrapper.java index d59dca359922..c06124cbb84d 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixNetworkElementCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixNetworkElementCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import com.cloud.agent.api.Answer; import com.cloud.agent.api.routing.NetworkElementCommand; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixNetworkRulesSystemVmCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixNetworkRulesSystemVmCommandWrapper.java similarity index 96% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixNetworkRulesSystemVmCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixNetworkRulesSystemVmCommandWrapper.java index 3c2f5efc2198..462dbfead747 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixNetworkRulesSystemVmCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixNetworkRulesSystemVmCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import com.cloud.agent.api.Answer; import com.cloud.agent.api.NetworkRulesSystemVmCommand; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixNetworkRulesVmSecondaryIpCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixNetworkRulesVmSecondaryIpCommandWrapper.java similarity index 96% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixNetworkRulesVmSecondaryIpCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixNetworkRulesVmSecondaryIpCommandWrapper.java index f19771f91bf6..4ebc8210378f 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixNetworkRulesVmSecondaryIpCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixNetworkRulesVmSecondaryIpCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import com.cloud.agent.api.Answer; import com.cloud.agent.api.NetworkRulesVmSecondaryIpCommand; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsCreateGreTunnelCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixOvsCreateGreTunnelCommandWrapper.java similarity index 98% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsCreateGreTunnelCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixOvsCreateGreTunnelCommandWrapper.java index 93d6208c2f11..31c1a9b64d9f 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsCreateGreTunnelCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixOvsCreateGreTunnelCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import org.apache.log4j.Logger; import org.apache.xmlrpc.XmlRpcException; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsCreateTunnelCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixOvsCreateTunnelCommandWrapper.java similarity index 98% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsCreateTunnelCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixOvsCreateTunnelCommandWrapper.java index 14d57d874c80..2929bb468c36 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsCreateTunnelCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixOvsCreateTunnelCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import org.apache.log4j.Logger; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsDeleteFlowCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixOvsDeleteFlowCommandWrapper.java similarity index 97% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsDeleteFlowCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixOvsDeleteFlowCommandWrapper.java index 8c782ee508bd..c2037319d1ae 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsDeleteFlowCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixOvsDeleteFlowCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import org.apache.log4j.Logger; import org.apache.xmlrpc.XmlRpcException; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsDestroyBridgeCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixOvsDestroyBridgeCommandWrapper.java similarity index 97% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsDestroyBridgeCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixOvsDestroyBridgeCommandWrapper.java index 62739fb644b1..09067ba72f50 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsDestroyBridgeCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixOvsDestroyBridgeCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import org.apache.log4j.Logger; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsDestroyTunnelCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixOvsDestroyTunnelCommandWrapper.java similarity index 97% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsDestroyTunnelCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixOvsDestroyTunnelCommandWrapper.java index 543c2f5b3201..391f31b870aa 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsDestroyTunnelCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixOvsDestroyTunnelCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import org.apache.log4j.Logger; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsFetchInterfaceCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixOvsFetchInterfaceCommandWrapper.java similarity index 98% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsFetchInterfaceCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixOvsFetchInterfaceCommandWrapper.java index 8be62dbd5ba4..ff42c5de30d1 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsFetchInterfaceCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixOvsFetchInterfaceCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import org.apache.log4j.Logger; import org.apache.xmlrpc.XmlRpcException; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsSetTagAndFlowCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixOvsSetTagAndFlowCommandWrapper.java similarity index 98% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsSetTagAndFlowCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixOvsSetTagAndFlowCommandWrapper.java index 087453daec0e..5e47c76a428d 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsSetTagAndFlowCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixOvsSetTagAndFlowCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import org.apache.log4j.Logger; import org.apache.xmlrpc.XmlRpcException; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsSetupBridgeCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixOvsSetupBridgeCommandWrapper.java similarity index 96% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsSetupBridgeCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixOvsSetupBridgeCommandWrapper.java index 20c6abc3d535..89b0d92edf1c 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsSetupBridgeCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixOvsSetupBridgeCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import org.apache.log4j.Logger; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsVpcPhysicalTopologyConfigCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixOvsVpcPhysicalTopologyConfigCommandWrapper.java similarity index 97% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsVpcPhysicalTopologyConfigCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixOvsVpcPhysicalTopologyConfigCommandWrapper.java index 4b0a66dbca63..3d2b986a913e 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsVpcPhysicalTopologyConfigCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixOvsVpcPhysicalTopologyConfigCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import org.apache.log4j.Logger; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsVpcRoutingPolicyConfigCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixOvsVpcRoutingPolicyConfigCommandWrapper.java similarity index 97% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsVpcRoutingPolicyConfigCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixOvsVpcRoutingPolicyConfigCommandWrapper.java index de29dc63acce..ea854562d674 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixOvsVpcRoutingPolicyConfigCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixOvsVpcRoutingPolicyConfigCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import org.apache.log4j.Logger; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPerformanceMonitorCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixPerformanceMonitorCommandWrapper.java similarity index 96% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPerformanceMonitorCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixPerformanceMonitorCommandWrapper.java index e3f51ce03461..58abeb5652c8 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPerformanceMonitorCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixPerformanceMonitorCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import com.cloud.agent.api.Answer; import com.cloud.agent.api.PerformanceMonitorAnswer; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPingTestCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixPingTestCommandWrapper.java similarity index 96% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPingTestCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixPingTestCommandWrapper.java index caf0242552bf..9cd2dff3f586 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPingTestCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixPingTestCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import com.cloud.agent.api.Answer; import com.cloud.agent.api.PingTestCommand; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPlugNicCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixPlugNicCommandWrapper.java similarity index 98% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPlugNicCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixPlugNicCommandWrapper.java index b233baca21b3..a75b4e5bd1bc 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPlugNicCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixPlugNicCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import java.util.Set; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPrepareForMigrationCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixPrepareForMigrationCommandWrapper.java similarity index 97% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPrepareForMigrationCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixPrepareForMigrationCommandWrapper.java index fde2155394fc..eb89c1135ab8 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPrepareForMigrationCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixPrepareForMigrationCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import org.apache.log4j.Logger; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPrimaryStorageDownloadCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixPrimaryStorageDownloadCommandWrapper.java similarity index 98% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPrimaryStorageDownloadCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixPrimaryStorageDownloadCommandWrapper.java index 22eca930f657..39ea92cf3475 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPrimaryStorageDownloadCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixPrimaryStorageDownloadCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import java.net.URI; import java.util.HashMap; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPvlanSetupCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixPvlanSetupCommandWrapper.java similarity index 98% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPvlanSetupCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixPvlanSetupCommandWrapper.java index 8b7c1749ac10..198c6fb37c33 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPvlanSetupCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixPvlanSetupCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import org.apache.log4j.Logger; import org.apache.xmlrpc.XmlRpcException; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixReadyCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixReadyCommandWrapper.java similarity index 98% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixReadyCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixReadyCommandWrapper.java index 708ea56bd8a8..d2bc4ffef694 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixReadyCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixReadyCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import java.util.Set; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRebootCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixRebootCommandWrapper.java similarity index 97% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRebootCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixRebootCommandWrapper.java index cc27528b5790..2e408eef214a 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRebootCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixRebootCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import java.util.Set; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRebootRouterCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixRebootRouterCommandWrapper.java similarity index 97% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRebootRouterCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixRebootRouterCommandWrapper.java index 182048c5839b..11a382ddb9a2 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRebootRouterCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixRebootRouterCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import com.cloud.agent.api.Answer; import com.cloud.agent.api.RebootCommand; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixRequestWrapper.java similarity index 98% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixRequestWrapper.java index 8dabaf244408..a26ea67fce00 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixRequestWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import java.util.Hashtable; import java.util.Set; @@ -44,7 +44,7 @@ public class CitrixRequestWrapper extends RequestWrapper { instance = new CitrixRequestWrapper(); } - Reflections baseWrappers = new Reflections("com.cloud.hypervisor.xenserver.resource.wrapper"); + Reflections baseWrappers = new Reflections("com.cloud.hypervisor.xenserver.resource.wrapper.citrix"); @SuppressWarnings("rawtypes") Set> baseSet = baseWrappers.getSubTypesOf(CommandWrapper.class); @@ -121,4 +121,4 @@ public Answer execute(final Command command, final ServerResource serverResource return commandWrapper.execute(command, serverResource); } -} \ No newline at end of file +} diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixResizeVolumeCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixResizeVolumeCommandWrapper.java similarity index 97% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixResizeVolumeCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixResizeVolumeCommandWrapper.java index 25f350f0c2cb..e7a54261eeee 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixResizeVolumeCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixResizeVolumeCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import org.apache.log4j.Logger; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRevertToVMSnapshotCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixRevertToVMSnapshotCommandWrapper.java similarity index 98% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRevertToVMSnapshotCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixRevertToVMSnapshotCommandWrapper.java index def4df73c65d..4522d85c57ba 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRevertToVMSnapshotCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixRevertToVMSnapshotCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import java.util.HashMap; import java.util.List; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixScaleVmCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixScaleVmCommandWrapper.java similarity index 98% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixScaleVmCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixScaleVmCommandWrapper.java index d21bcbd5d659..989857034c0e 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixScaleVmCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixScaleVmCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import java.util.Iterator; import java.util.Set; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixSecurityGroupRulesCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixSecurityGroupRulesCommandWrapper.java similarity index 98% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixSecurityGroupRulesCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixSecurityGroupRulesCommandWrapper.java index 793a5641b175..ce39ecfc818c 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixSecurityGroupRulesCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixSecurityGroupRulesCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import org.apache.log4j.Logger; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixSetupCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixSetupCommandWrapper.java similarity index 99% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixSetupCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixSetupCommandWrapper.java index 3ff0dfe6a90b..63416ed03f57 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixSetupCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixSetupCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import java.util.Map; import java.util.Set; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStartCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixStartCommandWrapper.java similarity index 99% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStartCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixStartCommandWrapper.java index 27f8474ae30e..62c3f562184d 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStartCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixStartCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import java.util.HashMap; import java.util.List; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStopCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixStopCommandWrapper.java similarity index 99% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStopCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixStopCommandWrapper.java index 8310cd8ea569..41aad8306f7d 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStopCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixStopCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import java.util.ArrayList; import java.util.HashMap; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStorageSubSystemCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixStorageSubSystemCommandWrapper.java similarity index 96% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStorageSubSystemCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixStorageSubSystemCommandWrapper.java index c14818ed6209..21700121dfcd 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixStorageSubSystemCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixStorageSubSystemCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import org.apache.cloudstack.storage.command.StorageSubSystemCommand; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixUnPlugNicCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixUnPlugNicCommandWrapper.java similarity index 97% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixUnPlugNicCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixUnPlugNicCommandWrapper.java index 639cfb0334aa..5fbd77050881 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixUnPlugNicCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixUnPlugNicCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import java.util.Set; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixUpdateHostPasswordCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixUpdateHostPasswordCommandWrapper.java similarity index 95% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixUpdateHostPasswordCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixUpdateHostPasswordCommandWrapper.java index c5654fd74cbd..6c11a1873986 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixUpdateHostPasswordCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixUpdateHostPasswordCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import com.cloud.agent.api.Answer; import com.cloud.agent.api.UpdateHostPasswordCommand; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixUpgradeSnapshotCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixUpgradeSnapshotCommandWrapper.java similarity index 97% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixUpgradeSnapshotCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixUpgradeSnapshotCommandWrapper.java index c23ba1b99368..a15893870b15 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixUpgradeSnapshotCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixUpgradeSnapshotCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import java.net.URI; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixWatchConsoleProxyLoadCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixWatchConsoleProxyLoadCommandWrapper.java similarity index 96% rename from plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixWatchConsoleProxyLoadCommandWrapper.java rename to plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixWatchConsoleProxyLoadCommandWrapper.java index 74ca0ddf6534..eb2790ddb2a6 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixWatchConsoleProxyLoadCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/citrix/CitrixWatchConsoleProxyLoadCommandWrapper.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import com.cloud.agent.api.Answer; import com.cloud.agent.api.Command; diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapperTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapperTest.java index 8d66c6597a46..b40e42bd20b2 100644 --- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapperTest.java +++ b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapperTest.java @@ -14,7 +14,7 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -138,6 +138,7 @@ import com.xensource.xenapi.Types.BadServerResponse; import com.xensource.xenapi.Types.XenAPIException; + @RunWith(MockitoJUnitRunner.class) public class CitrixRequestWrapperTest { @@ -1838,4 +1839,4 @@ public boolean executeInSequence() { return false; } -} \ No newline at end of file +} diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XcpServerWrapperTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XcpServerWrapperTest.java index 358d670c11ee..304d4cd49609 100644 --- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XcpServerWrapperTest.java +++ b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XcpServerWrapperTest.java @@ -14,7 +14,7 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer56FP1WrapperTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer56FP1WrapperTest.java index c2d2131b8c74..8333f3c9fee6 100644 --- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer56FP1WrapperTest.java +++ b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer56FP1WrapperTest.java @@ -14,7 +14,7 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer56WrapperTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer56WrapperTest.java index c5bb73aeb7a4..57f4d8255431 100644 --- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer56WrapperTest.java +++ b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer56WrapperTest.java @@ -14,7 +14,7 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer610WrapperTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer610WrapperTest.java index 0a539e970d38..bf8099b154d3 100644 --- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer610WrapperTest.java +++ b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer610WrapperTest.java @@ -14,7 +14,7 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer620SP1WrapperTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer620SP1WrapperTest.java index 67795fe93cd4..48d971770664 100644 --- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer620SP1WrapperTest.java +++ b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer620SP1WrapperTest.java @@ -14,7 +14,7 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer620WrapperTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer620WrapperTest.java index 3954dc48efba..60435581ba1e 100644 --- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer620WrapperTest.java +++ b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/XenServer620WrapperTest.java @@ -14,7 +14,7 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package com.cloud.hypervisor.xenserver.resource.wrapper; +package com.cloud.hypervisor.xenserver.resource.wrapper.citrix; import static org.junit.Assert.assertTrue; From 87d4086a64a6ebf387bda03509e0c03dac685cae Mon Sep 17 00:00:00 2001 From: Milamber Date: Sat, 23 May 2015 16:58:05 +0100 Subject: [PATCH 113/175] CLOUDSTACK-6181 Specify GB for the value of rootdisksize parameter. Add some Bytes/GB for log or exception messages. Fix Gb->GB. --- .../cloudstack/api/command/user/vm/DeployVMCmd.java | 2 +- .../engine/orchestration/VolumeOrchestrator.java | 8 ++++---- server/src/com/cloud/vm/UserVmManagerImpl.java | 4 +++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java index 3d13d6bb2090..f17c1c1fb380 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java @@ -121,7 +121,7 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd { @Parameter(name = ApiConstants.ROOT_DISK_SIZE, type = CommandType.LONG, - description = "Optional field to resize root disk on deploy. Only applies to template-based deployments. Analogous to details[0].rootdisksize, which takes precedence over this parameter if both are provided", + description = "Optional field to resize root disk on deploy. Value is in GB. Only applies to template-based deployments. Analogous to details[0].rootdisksize, which takes precedence over this parameter if both are provided", since = "4.4") private Long rootdisksize; diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java index 884da257cb7d..d407bb1afff7 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java @@ -599,9 +599,9 @@ public String getVmNameOnVolume(Volume volume) { @Override public boolean validateVolumeSizeRange(long size) { if (size < 0 || (size > 0 && size < (1024 * 1024 * 1024))) { - throw new InvalidParameterValueException("Please specify a size of at least 1 Gb."); + throw new InvalidParameterValueException("Please specify a size of at least 1 GB."); } else if (size > (MaxVolumeSize.value() * 1024 * 1024 * 1024)) { - throw new InvalidParameterValueException("volume size " + size + ", but the maximum size allowed is " + MaxVolumeSize + " Gb."); + throw new InvalidParameterValueException("volume size " + size + ", but the maximum size allowed is " + MaxVolumeSize + " GB."); } return true; @@ -674,10 +674,10 @@ public DiskProfile allocateTemplatedVolume(Type type, String name, DiskOffering if (rootDisksize != null ) { rootDisksize = rootDisksize * 1024 * 1024 * 1024; if (rootDisksize > size) { - s_logger.debug("Using root disk size of " + rootDisksize + " for volume " + name); + s_logger.debug("Using root disk size of " + rootDisksize + " Bytes for volume " + name); size = rootDisksize; } else { - s_logger.debug("Using root disk size of " + size + " for volume " + name + "since specified root disk size of " + rootDisksize + " is smaller than template"); + s_logger.debug("Using root disk size of " + size + " Bytes for volume " + name + "since specified root disk size of " + rootDisksize + " Bytes is smaller than template"); } } diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 4b043a37c4a9..a413d1131d64 100644 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -3095,7 +3095,9 @@ public UserVmVO doInTransaction(TransactionStatus status) throws InsufficientCap } if ((rootDiskSize << 30) < templateVO.getSize()) { - throw new InvalidParameterValueException("unsupported: rootdisksize override is smaller than template size " + templateVO.getSize()); + Long templateVOSizeGB = templateVO.getSize() / 1024 / 1024 / 1024; + throw new InvalidParameterValueException("unsupported: rootdisksize override is smaller than template size " + templateVO.getSize() + + "B (" + templateVOSizeGB + "GB)"); } else { s_logger.debug("rootdisksize of " + (rootDiskSize << 30) + " was larger than template size of " + templateVO.getSize()); } From 9dcfbceae71865b4de1a4744ceac8f48255733a2 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Fri, 22 May 2015 15:03:35 +0100 Subject: [PATCH 114/175] kvm: for disabling pxe, pass empty file Passing the file argument to the xml break for EL 7.1, the fix removes the argument as just passing rombar='off' with its file arg to be empty string. This closes #290 (cherry picked from commit aafa0c80b35a9f0e533e5a4b18d03f1e47cf9bfe) Signed-off-by: Rohit Yadav --- .../kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java index 25ad8e957785..c4c4b0294d19 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java @@ -982,7 +982,7 @@ public String toString() { netBuilder.append("