diff --git a/.travis.yml b/.travis.yml index 868348cbf04..fd67a9eff78 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. - +sudo: required language: java cache: directories: diff --git a/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/CreateVMSnapshotCmd.java b/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/CreateVMSnapshotCmd.java index 10ff5cddb12..f18793ac581 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/CreateVMSnapshotCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/CreateVMSnapshotCmd.java @@ -47,7 +47,7 @@ public class CreateVMSnapshotCmd extends BaseAsyncCreateCmd { @Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, type = CommandType.UUID, required = true, entityType = UserVmResponse.class, description = "The ID of the vm") private Long vmId; - @Parameter(name = ApiConstants.VM_SNAPSHOT_DESCRIPTION, type = CommandType.STRING, required = false, description = "The discription of the snapshot") + @Parameter(name = ApiConstants.VM_SNAPSHOT_DESCRIPTION, type = CommandType.STRING, required = false, description = "The description of the snapshot") private String description; @Parameter(name = ApiConstants.VM_SNAPSHOT_DISPLAYNAME, type = CommandType.STRING, required = false, description = "The display name of the snapshot") diff --git a/core/src/com/cloud/agent/api/PlugNicCommand.java b/core/src/com/cloud/agent/api/PlugNicCommand.java index e68931d5e36..322b755b86a 100644 --- a/core/src/com/cloud/agent/api/PlugNicCommand.java +++ b/core/src/com/cloud/agent/api/PlugNicCommand.java @@ -22,11 +22,14 @@ package com.cloud.agent.api; import com.cloud.agent.api.to.NicTO; import com.cloud.vm.VirtualMachine; +import java.util.Map; + public class PlugNicCommand extends Command { NicTO nic; String instanceName; VirtualMachine.Type vmType; + Map details; public NicTO getNic() { return nic; @@ -46,6 +49,13 @@ public class PlugNicCommand extends Command { this.vmType = vmtype; } + public PlugNicCommand(NicTO nic, String instanceName, VirtualMachine.Type vmtype, Map details) { + this.nic = nic; + this.instanceName = instanceName; + this.vmType = vmtype; + this.details = details; + } + public String getVmName() { return instanceName; } @@ -53,4 +63,8 @@ public class PlugNicCommand extends Command { public VirtualMachine.Type getVMType() { return vmType; } + + public Map getDetails() { + return this.details; + } } diff --git a/core/src/com/cloud/resource/CommandWrapper.java b/core/src/com/cloud/resource/CommandWrapper.java index 15f7b080992..48c105f5575 100644 --- a/core/src/com/cloud/resource/CommandWrapper.java +++ b/core/src/com/cloud/resource/CommandWrapper.java @@ -25,6 +25,7 @@ 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; @@ -70,7 +71,7 @@ public abstract class CommandWrapper 1) { for (DataStore store : cacheStores) { DataObjectInStore obj = objectInStoreMgr.findObject(data, store); - if (obj != null && obj.getState() == ObjectInDataStoreStateMachine.State.Ready) { + if (obj != null && obj.getState() == ObjectInDataStoreStateMachine.State.Ready && statsCollector.imageStoreHasEnoughCapacity(store)) { s_logger.debug("pick the cache store " + store.getId() + " where data is already there"); return store; } } - - // otherwise, just random pick one - Collections.shuffle(cacheStores); } - return cacheStores.get(0); - + return imageStoreMgr.getImageStore(cacheStores); } - - } diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageStoreProviderManagerImpl.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageStoreProviderManagerImpl.java index 882cf1856f2..cb9a97e5965 100644 --- a/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageStoreProviderManagerImpl.java +++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageStoreProviderManagerImpl.java @@ -19,7 +19,9 @@ package org.apache.cloudstack.storage.image.manager; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; @@ -41,6 +43,7 @@ import org.apache.cloudstack.storage.image.datastore.ImageStoreEntity; import org.apache.cloudstack.storage.image.datastore.ImageStoreProviderManager; import org.apache.cloudstack.storage.image.store.ImageStoreImpl; +import com.cloud.server.StatsCollector; import com.cloud.storage.ScopeType; import com.cloud.storage.dao.VMTemplateDao; @@ -53,6 +56,8 @@ public class ImageStoreProviderManagerImpl implements ImageStoreProviderManager VMTemplateDao imageDataDao; @Inject DataStoreProviderManager providerManager; + @Inject + StatsCollector _statsCollector; Map driverMaps; @PostConstruct @@ -137,4 +142,21 @@ public class ImageStoreProviderManagerImpl implements ImageStoreProviderManager } return imageStores; } + + @Override + public DataStore getImageStore(List imageStores) { + if (imageStores.size() > 1) { + Collections.shuffle(imageStores); // Randomize image store list. + Iterator i = imageStores.iterator(); + DataStore imageStore = null; + while(i.hasNext()) { + imageStore = i.next(); + // Return image store if used percentage is less then threshold value i.e. 90%. + if (_statsCollector.imageStoreHasEnoughCapacity(imageStore)) { + return imageStore; + } + } + } + return imageStores.get(0); + } } diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManagerImpl.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManagerImpl.java index d44fb42045c..aa23a43291c 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManagerImpl.java +++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManagerImpl.java @@ -18,7 +18,6 @@ */ package org.apache.cloudstack.storage.datastore; -import java.util.Collections; import java.util.List; import javax.inject.Inject; @@ -79,8 +78,7 @@ public class DataStoreManagerImpl implements DataStoreManager { if (stores == null || stores.size() == 0) { return null; } - Collections.shuffle(stores); - return stores.get(0); + return imageDataStoreMgr.getImageStore(stores); } @Override @@ -112,8 +110,7 @@ public class DataStoreManagerImpl implements DataStoreManager { if (stores == null || stores.size() == 0) { return null; } - Collections.shuffle(stores); - return stores.get(0); + return imageDataStoreMgr.getImageStore(stores); } @Override diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageStoreProviderManager.java b/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageStoreProviderManager.java index 8afb3d9f31a..70b7a7c3c68 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageStoreProviderManager.java +++ b/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageStoreProviderManager.java @@ -41,4 +41,6 @@ public interface ImageStoreProviderManager { List listImageCacheStores(Scope scope); boolean registerDriver(String uuid, ImageStoreDriver driver); + + DataStore getImageStore(List imageStores); } diff --git a/plugins/hypervisors/kvm/pom.xml b/plugins/hypervisors/kvm/pom.xml index 3f3a3e9464f..e116a7af85e 100644 --- a/plugins/hypervisors/kvm/pom.xml +++ b/plugins/hypervisors/kvm/pom.xml @@ -28,7 +28,7 @@ ceph-com - http://ceph.com/maven + http://eu.ceph.com/maven false diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java index 12eda749d22..aaf75ff9214 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java @@ -294,7 +294,7 @@ public class BridgeVifDriver extends VifDriverBase { } } if (!foundLinkLocalBr) { - Script.runSimpleBashScript("ifconfig " + linkLocalBr + " 169.254.0.1;" + "ip route add " + NetUtils.getLinkLocalCIDR() + " dev " + linkLocalBr + " src " + + Script.runSimpleBashScript("ip address add 169.254.0.1/16 dev " + linkLocalBr + ";" + "ip route add " + NetUtils.getLinkLocalCIDR() + " dev " + linkLocalBr + " src " + NetUtils.getLinkLocalGateway()); } } @@ -302,7 +302,7 @@ public class BridgeVifDriver extends VifDriverBase { private void createControlNetwork(String privBrName) { deleteExitingLinkLocalRouteTable(privBrName); if (!isBridgeExists(privBrName)) { - Script.runSimpleBashScript("brctl addbr " + privBrName + "; ifconfig " + privBrName + " up; ifconfig " + privBrName + " 169.254.0.1", _timeout); + Script.runSimpleBashScript("brctl addbr " + privBrName + "; ip link set " + privBrName + " up; ip address add 169.254.0.1/16 dev " + privBrName, _timeout); } } diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/IvsVifDriver.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/IvsVifDriver.java index b5036744705..1aae2b58933 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/IvsVifDriver.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/IvsVifDriver.java @@ -263,7 +263,7 @@ public class IvsVifDriver extends VifDriverBase { } } if (!foundLinkLocalBr) { - Script.runSimpleBashScript("ifconfig " + linkLocalBr + " 169.254.0.1;" + "ip route add " + NetUtils.getLinkLocalCIDR() + " dev " + linkLocalBr + " src " + + Script.runSimpleBashScript("ip address add 169.254.0.1/16 dev " + linkLocalBr + ";" + "ip route add " + NetUtils.getLinkLocalCIDR() + " dev " + linkLocalBr + " src " + NetUtils.getLinkLocalGateway()); } } @@ -271,7 +271,7 @@ public class IvsVifDriver extends VifDriverBase { private void createControlNetwork(String privBrName) { deleteExitingLinkLocalRouteTable(privBrName); if (!isBridgeExists(privBrName)) { - Script.runSimpleBashScript("brctl addbr " + privBrName + "; ifconfig " + privBrName + " up; ifconfig " + privBrName + " 169.254.0.1", _timeout); + Script.runSimpleBashScript("brctl addbr " + privBrName + "; ip link set " + privBrName + " up; ip address add 169.254.0.1/16 dev " + privBrName, _timeout); } } 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 b5723ed66d5..5c8d3377ecc 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 @@ -16,6 +16,8 @@ // under the License. package com.cloud.hypervisor.kvm.resource; +import org.apache.commons.lang.StringEscapeUtils; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -1168,7 +1170,7 @@ public class LibvirtVMDef { _port = port; _autoPort = autoPort; _listenAddr = listenAddr; - _passwd = passwd; + _passwd = StringEscapeUtils.escapeXml(passwd); _keyMap = keyMap; } diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/OvsVifDriver.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/OvsVifDriver.java index 1420682006c..6462df7cf30 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/OvsVifDriver.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/OvsVifDriver.java @@ -151,7 +151,7 @@ public class OvsVifDriver extends VifDriverBase { } } if (!foundLinkLocalBr) { - Script.runSimpleBashScript("ifconfig " + linkLocalBr + " 169.254.0.1;" + "ip route add " + NetUtils.getLinkLocalCIDR() + " dev " + linkLocalBr + " src " + + Script.runSimpleBashScript("ip address add 169.254.0.1/16 dev " + linkLocalBr + ";" + "ip route add " + NetUtils.getLinkLocalCIDR() + " dev " + linkLocalBr + " src " + NetUtils.getLinkLocalGateway()); } } @@ -159,7 +159,7 @@ public class OvsVifDriver extends VifDriverBase { private void createControlNetwork(String privBrName) { deleteExitingLinkLocalRouteTable(privBrName); if (!isBridgeExists(privBrName)) { - Script.runSimpleBashScript("ovs-vsctl add-br " + privBrName + "; ifconfig " + privBrName + " up; ifconfig " + privBrName + " 169.254.0.1", _timeout); + Script.runSimpleBashScript("ovs-vsctl add-br " + privBrName + "; ip link set " + privBrName + " up; ip address add 169.254.0.1/16 dev " + privBrName, _timeout); } } diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java index 808cb5bdeea..9ac32d4757e 100644 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java @@ -378,12 +378,22 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co //NOTE: the hostid can be a hypervisor host, or a ssvm agent. For copycommand, if it's for volume upload, the hypervisor //type is empty, so we need to check the format of volume at first. if (cmd instanceof CopyCommand) { - CopyCommand cpyCommand = (CopyCommand)cmd; + CopyCommand cpyCommand = (CopyCommand) cmd; DataTO srcData = cpyCommand.getSrcTO(); DataStoreTO srcStoreTO = srcData.getDataStore(); DataTO destData = cpyCommand.getDestTO(); DataStoreTO destStoreTO = destData.getDataStore(); + boolean inSeq = true; + if ((srcData.getObjectType() == DataObjectType.SNAPSHOT) || (destData.getObjectType() == DataObjectType.SNAPSHOT)) { + inSeq = false; + } else if ((destStoreTO.getRole() == DataStoreRole.Image) || (destStoreTO.getRole() == DataStoreRole.ImageCache)) { + inSeq = false; + } else if (!VmwareFullClone.value()) { + inSeq = false; + } + cpyCommand.setExecuteInSequence(inSeq); + if (srcData.getObjectType() == DataObjectType.VOLUME) { VolumeObjectTO volumeObjectTO = (VolumeObjectTO)srcData; if (Storage.ImageFormat.OVA == volumeObjectTO.getFormat()) { diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java index 3416319ad97..e852948b499 100644 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java @@ -765,7 +765,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw // Change permissions for the mountpoint script = new Script(true, "chmod", _timeout, s_logger); - script.add("777", mountPoint); + script.add("1777", mountPoint); result = script.execute(); if (result != null) { s_logger.warn("Unable to set permissions for " + mountPoint + " due to " + result); diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java index f90a666bf8c..a628fb7387f 100644 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java @@ -916,8 +916,12 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa return new PlugNicAnswer(cmd, false, "Unable to execute PlugNicCommand due to " + errMsg); } */ - // TODO need a way to specify the control of NIC device type + // Fallback to E1000 if no specific nicAdapter is passed VirtualEthernetCardType nicDeviceType = VirtualEthernetCardType.E1000; + Map details = cmd.getDetails(); + if (details != null) { + nicDeviceType = VirtualEthernetCardType.valueOf((String) details.get("nicAdapter")); + } // find a usable device number in VMware environment VirtualDevice[] nicDevices = vmMo.getNicDevices(); @@ -1818,7 +1822,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa int getReservedCpuMHZ(VirtualMachineTO vmSpec) { if (vmSpec.getDetails().get(VMwareGuru.VmwareReserveCpu.key()).equalsIgnoreCase("true")) { - return vmSpec.getMinSpeed(); + return vmSpec.getMinSpeed() * vmSpec.getCpus(); } return 0; } @@ -2468,7 +2472,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa private Pair prepareNetworkFromNicInfo(HostMO hostMo, NicTO nicTo, boolean configureVServiceInNexus, VirtualMachine.Type vmType) throws Exception { Ternary switchDetails = getTargetSwitch(nicTo); - nicTo.getType(); VirtualSwitchType switchType = VirtualSwitchType.getType(switchDetails.second()); String switchName = switchDetails.first(); String vlanToken = switchDetails.third(); @@ -4242,7 +4245,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa DatastoreSummary dsSummary = dsMo.getSummary(); String address = hostMo.getHostName(); StoragePoolInfo pInfo = - new StoragePoolInfo(poolUuid, address, dsMo.getMor().getValue(), "", StoragePoolType.LVM, dsSummary.getCapacity(), dsSummary.getFreeSpace()); + new StoragePoolInfo(poolUuid, address, dsMo.getMor().getValue(), "", StoragePoolType.VMFS, dsSummary.getCapacity(), dsSummary.getFreeSpace()); StartupStorageCommand cmd = new StartupStorageCommand(); cmd.setName(poolUuid); cmd.setPoolInfo(pInfo); 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 bf0ea6cc66d..bc812e80e99 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,9 +46,6 @@ import javax.naming.ConfigurationException; 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; import org.apache.xmlrpc.XmlRpcException; import org.w3c.dom.Document; @@ -57,6 +54,35 @@ import org.w3c.dom.NodeList; import org.xml.sax.InputSource; import org.xml.sax.SAXException; +import com.trilead.ssh2.SCPClient; +import com.xensource.xenapi.Bond; +import com.xensource.xenapi.Connection; +import com.xensource.xenapi.Console; +import com.xensource.xenapi.Host; +import com.xensource.xenapi.HostCpu; +import com.xensource.xenapi.HostMetrics; +import com.xensource.xenapi.Network; +import com.xensource.xenapi.PBD; +import com.xensource.xenapi.PIF; +import com.xensource.xenapi.Pool; +import com.xensource.xenapi.SR; +import com.xensource.xenapi.Session; +import com.xensource.xenapi.Task; +import com.xensource.xenapi.Types; +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VmPowerState; +import com.xensource.xenapi.Types.XenAPIException; +import com.xensource.xenapi.VBD; +import com.xensource.xenapi.VDI; +import com.xensource.xenapi.VIF; +import com.xensource.xenapi.VLAN; +import com.xensource.xenapi.VM; +import com.xensource.xenapi.XenAPIObject; + +import org.apache.cloudstack.storage.command.StorageSubSystemCommand; +import org.apache.cloudstack.storage.to.TemplateObjectTO; +import org.apache.cloudstack.storage.to.VolumeObjectTO; + import com.cloud.agent.IAgentControl; import com.cloud.agent.api.Answer; import com.cloud.agent.api.Command; @@ -123,30 +149,6 @@ import com.cloud.utils.net.NetUtils; import com.cloud.utils.ssh.SSHCmdHelper; import com.cloud.utils.ssh.SshHelper; import com.cloud.vm.VirtualMachine.PowerState; -import com.trilead.ssh2.SCPClient; -import com.xensource.xenapi.Bond; -import com.xensource.xenapi.Connection; -import com.xensource.xenapi.Console; -import com.xensource.xenapi.Host; -import com.xensource.xenapi.HostCpu; -import com.xensource.xenapi.HostMetrics; -import com.xensource.xenapi.Network; -import com.xensource.xenapi.PBD; -import com.xensource.xenapi.PIF; -import com.xensource.xenapi.Pool; -import com.xensource.xenapi.SR; -import com.xensource.xenapi.Session; -import com.xensource.xenapi.Task; -import com.xensource.xenapi.Types; -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VmPowerState; -import com.xensource.xenapi.Types.XenAPIException; -import com.xensource.xenapi.VBD; -import com.xensource.xenapi.VDI; -import com.xensource.xenapi.VIF; -import com.xensource.xenapi.VLAN; -import com.xensource.xenapi.VM; -import com.xensource.xenapi.XenAPIObject; /** * CitrixResourceBase encapsulates the calls to the XenServer Xapi process to @@ -4862,7 +4864,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe dest.reconfigureIp(conn, spr.ipConfigurationMode, spr.IP, spr.netmask, spr.gateway, spr.DNS); Host.managementReconfigure(conn, dest); String hostUuid = null; - final int count = 0; + int count = 0; while (count < 10) { try { Thread.sleep(10000); @@ -4870,6 +4872,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe if (hostUuid != null) { break; } + ++count; } catch (final XmlRpcException e) { s_logger.debug("Waiting for host to come back: " + e.getMessage()); } catch (final XenAPIException e) { diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServer56Resource.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServer56Resource.java index 12e4fc5617a..b1649637d66 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServer56Resource.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServer56Resource.java @@ -23,20 +23,19 @@ import java.util.List; import javax.ejb.Local; import org.apache.log4j.Logger; -import org.apache.xmlrpc.XmlRpcException; + +import com.xensource.xenapi.Connection; +import com.xensource.xenapi.Host; +import com.xensource.xenapi.Network; +import com.xensource.xenapi.PIF; +import com.xensource.xenapi.Types.XenAPIException; +import com.xensource.xenapi.VLAN; import com.cloud.agent.api.StartupCommand; import com.cloud.resource.ServerResource; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.script.Script; import com.cloud.utils.ssh.SSHCmdHelper; -import com.xensource.xenapi.Connection; -import com.xensource.xenapi.Host; -import com.xensource.xenapi.Network; -import com.xensource.xenapi.PIF; -import com.xensource.xenapi.Types.IpConfigurationMode; -import com.xensource.xenapi.Types.XenAPIException; -import com.xensource.xenapi.VLAN; @Local(value = ServerResource.class) public class XenServer56Resource extends CitrixResourceBase { @@ -142,37 +141,6 @@ public class XenServer56Resource extends CitrixResourceBase { } } - @Override - public boolean transferManagementNetwork(final Connection conn, final Host host, final PIF src, final PIF.Record spr, final PIF dest) throws XmlRpcException, XenAPIException { - dest.reconfigureIp(conn, spr.ipConfigurationMode, spr.IP, spr.netmask, spr.gateway, spr.DNS); - Host.managementReconfigure(conn, dest); - String hostUuid = null; - final int count = 0; - while (count < 10) { - try { - Thread.sleep(10000); - hostUuid = host.getUuid(conn); - if (hostUuid != null) { - break; - } - } catch (final XmlRpcException e) { - s_logger.debug("Waiting for host to come back: " + e.getMessage()); - } catch (final XenAPIException e) { - s_logger.debug("Waiting for host to come back: " + e.getMessage()); - } catch (final InterruptedException e) { - s_logger.debug("Gotta run"); - return false; - } - } - if (hostUuid == null) { - s_logger.warn("Unable to transfer the management network from " + spr.uuid); - return false; - } - - src.reconfigureIp(conn, IpConfigurationMode.NONE, null, null, null, null); - return true; - } - @Override public StartupCommand[] initialize() { pingXAPI(); 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/XenServer56NetworkUsageCommandWrapper.java index 0e3f922f630..9132aa1336b 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/XenServer56NetworkUsageCommandWrapper.java @@ -21,13 +21,14 @@ package com.cloud.hypervisor.xenserver.resource.wrapper; 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.utils.ExecutionResult; -import com.xensource.xenapi.Connection; public final class XenServer56NetworkUsageCommandWrapper extends CommandWrapper { @@ -87,8 +88,8 @@ public final class XenServer56NetworkUsageCommandWrapper extends CommandWrapper< final String[] splitResult = detail.split(":"); int i = 0; while (i < splitResult.length - 1) { - stats[0] += new Long(splitResult[i++]).longValue(); - stats[1] += new Long(splitResult[i++]).longValue(); + stats[0] += Long.parseLong(splitResult[i++]); + stats[1] += Long.parseLong(splitResult[i++]); } return new NetworkUsageAnswer(command, "success", stats[0], stats[1]); } diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/BcfAnswer.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/BcfAnswer.java index d1443867edc..45bb0245dd8 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/BcfAnswer.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/BcfAnswer.java @@ -22,17 +22,17 @@ package com.cloud.agent.api; public class BcfAnswer extends Answer{ private final String hash; - public BcfAnswer(Command command, boolean success, String details) { + public BcfAnswer(final Command command, final boolean success, final String details) { super(command, success, details); this.hash = ""; } - public BcfAnswer(Command command, boolean success, String details, String hash) { + public BcfAnswer(final Command command, final boolean success, final String details, final String hash) { super(command, success, details); this.hash = hash; } - public BcfAnswer(Command command, Exception e) { + public BcfAnswer(final Command command, final Exception e) { super(command, e); this.hash = ""; } diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/BcfCommand.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/BcfCommand.java index b245945c043..6e08dadcc1b 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/BcfCommand.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/BcfCommand.java @@ -22,8 +22,8 @@ package com.cloud.agent.api; import com.cloud.network.bigswitch.TopologyData; public class BcfCommand extends Command { - private TopologyData topology = null; - private boolean _topologySyncRequested = false; + private TopologyData topology; + private boolean topologySyncRequested; @Override public boolean executeInSequence() { @@ -34,15 +34,15 @@ public class BcfCommand extends Command { return topology; } - public void setTopology(TopologyData topology) { + public void setTopology(final TopologyData topology) { this.topology = topology; } - public boolean is_topologySyncRequested() { - return _topologySyncRequested; + public boolean isTopologySyncRequested() { + return topologySyncRequested; } - public void set_topologySyncRequested(boolean requested) { - this._topologySyncRequested = requested; + public void setTopologySyncRequested(final boolean requested) { + this.topologySyncRequested = requested; } } diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CacheBcfTopologyCommand.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CacheBcfTopologyCommand.java index 39e7b66c363..1ab22a52db4 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CacheBcfTopologyCommand.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CacheBcfTopologyCommand.java @@ -22,10 +22,10 @@ package com.cloud.agent.api; import com.cloud.network.bigswitch.TopologyData; public class CacheBcfTopologyCommand extends Command{ - private final TopologyData topology; + private final TopologyData _topology; - public CacheBcfTopologyCommand(TopologyData topology){ - this.topology = topology; + public CacheBcfTopologyCommand(final TopologyData topology){ + this._topology = topology; } @Override @@ -34,6 +34,6 @@ public class CacheBcfTopologyCommand extends Command{ } public TopologyData getTopology() { - return topology; + return _topology; } } diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfAttachmentCommand.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfAttachmentCommand.java index 97d56a5b5e0..74e1215d45a 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfAttachmentCommand.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfAttachmentCommand.java @@ -20,18 +20,18 @@ package com.cloud.agent.api; public class CreateBcfAttachmentCommand extends BcfCommand { - private String _tenantId; - private String _tenantName; - private String _networkId; - private String _portId; - private String _nicId; - private Integer _vlan; - private String _ipv4; - private String _mac; + private final String _tenantId; + private final String _tenantName; + private final String _networkId; + private final String _portId; + private final String _nicId; + private final Integer _vlan; + private final String _ipv4; + private final String _mac; - public CreateBcfAttachmentCommand(String tenantId, String tenantName, - String networkId, String portId, String nicId, - Integer vlan, String ipv4, String mac) { + public CreateBcfAttachmentCommand(final String tenantId, final String tenantName, + final String networkId, final String portId, final String nicId, + final Integer vlan, final String ipv4, final String mac) { this._tenantId = tenantId; this._tenantName = tenantName; this._networkId = networkId; diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfRouterCommand.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfRouterCommand.java index 4379ed4b853..8fcab6b597b 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfRouterCommand.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfRouterCommand.java @@ -22,11 +22,11 @@ package com.cloud.agent.api; public class CreateBcfRouterCommand extends BcfCommand { private final String _tenantId; - public CreateBcfRouterCommand(String tenantId){ + public CreateBcfRouterCommand(final String tenantId){ this._tenantId = tenantId; } - public String get_tenantId() { + public String getTenantId() { return _tenantId; } } diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfRouterInterfaceCommand.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfRouterInterfaceCommand.java index 4b8d227c9a1..66ad1a05630 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfRouterInterfaceCommand.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfRouterInterfaceCommand.java @@ -26,8 +26,8 @@ public class CreateBcfRouterInterfaceCommand extends BcfCommand{ private final String _gateway; private final String _networkName; - public CreateBcfRouterInterfaceCommand(String tenantId, String networkId, String cidr, - String gateway, String networkName){ + public CreateBcfRouterInterfaceCommand(final String tenantId, final String networkId, + final String cidr, final String gateway, final String networkName){ this._tenantId = tenantId; this._networkId = networkId; this._networkName = networkName; @@ -35,23 +35,23 @@ public class CreateBcfRouterInterfaceCommand extends BcfCommand{ this._gateway = gateway; } - public String get_tenantId() { + public String getTenantId() { return _tenantId; } - public String get_networkId() { + public String getNetworkId() { return _networkId; } - public String get_networkName() { + public String getNetworkName() { return _networkName; } - public String get_cidr() { + public String getCidr() { return _cidr; } - public String get_gateway() { + public String getGateway() { return _gateway; } } diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfSegmentCommand.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfSegmentCommand.java index d54dac69af8..9bb75fe016c 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfSegmentCommand.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfSegmentCommand.java @@ -20,14 +20,14 @@ package com.cloud.agent.api; public class CreateBcfSegmentCommand extends BcfCommand { - private String _tenantId; - private String _tenantName; - private String _networkId; - private String _networkName; - private Integer _vlan; + private final String _tenantId; + private final String _tenantName; + private final String _networkId; + private final String _networkName; + private final Integer _vlan; - public CreateBcfSegmentCommand(String tenantId, String tenantName, - String networkId, String networkName, Integer vlan) { + public CreateBcfSegmentCommand(final String tenantId, final String tenantName, + final String networkId, final String networkName, final Integer vlan) { this._tenantId = tenantId; this._tenantName = tenantName; this._networkId = networkId; diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfStaticNatCommand.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfStaticNatCommand.java index 917f48097f3..3db96f114b7 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfStaticNatCommand.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfStaticNatCommand.java @@ -26,8 +26,8 @@ public class CreateBcfStaticNatCommand extends BcfCommand { private final String _publicIp; private final String _mac; - public CreateBcfStaticNatCommand(String tenantId, String networkId, - String privateIp, String publicIp, String mac){ + public CreateBcfStaticNatCommand(final String tenantId, final String networkId, + final String privateIp, final String publicIp, final String mac){ this._tenantId = tenantId; this._networkId = networkId; this._privateIp = privateIp; @@ -35,23 +35,23 @@ public class CreateBcfStaticNatCommand extends BcfCommand { this._mac = mac; } - public String get_tenantId() { + public String getTenantId() { return _tenantId; } - public String get_networkId() { + public String getNetworkId() { return _networkId; } - public String get_privateIp() { + public String getPrivateIp() { return _privateIp; } - public String get_publicIp() { + public String getPublicIp() { return _publicIp; } - public String get_mac() { + public String getMac() { return _mac; } } diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/DeleteBcfAttachmentCommand.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/DeleteBcfAttachmentCommand.java index d5cf13fcc35..fc9f05f573e 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/DeleteBcfAttachmentCommand.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/DeleteBcfAttachmentCommand.java @@ -20,12 +20,12 @@ package com.cloud.agent.api; public class DeleteBcfAttachmentCommand extends BcfCommand { - private String _tenantId; - private String _networkId; - private String _attachmentId; + private final String _tenantId; + private final String _networkId; + private final String _attachmentId; - public DeleteBcfAttachmentCommand(String tenantId, - String networkId, String attachmentId) { + public DeleteBcfAttachmentCommand(final String tenantId, + final String networkId, final String attachmentId) { this._tenantId = tenantId; this._networkId = networkId; this._attachmentId = attachmentId; diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/DeleteBcfSegmentCommand.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/DeleteBcfSegmentCommand.java index a6987a5b4c2..6c133a356b8 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/DeleteBcfSegmentCommand.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/DeleteBcfSegmentCommand.java @@ -21,19 +21,19 @@ package com.cloud.agent.api; public class DeleteBcfSegmentCommand extends BcfCommand { - private String _tenantUuid; - private String _networkUuid; + private final String _tenantUuid; + private final String _networkUuid; - public DeleteBcfSegmentCommand(String tenantUuid, String networkUuid) { + public DeleteBcfSegmentCommand(final String tenantUuid, final String networkUuid) { this._tenantUuid = tenantUuid; this._networkUuid = networkUuid; } - public String get_tenantUuid() { + public String getTenantUuid() { return _tenantUuid; } public String getNetworkUuid() { return _networkUuid; } -} \ No newline at end of file +} diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/DeleteBcfStaticNatCommand.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/DeleteBcfStaticNatCommand.java index 7861bfbde8c..e476565dd58 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/DeleteBcfStaticNatCommand.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/DeleteBcfStaticNatCommand.java @@ -24,21 +24,21 @@ public class DeleteBcfStaticNatCommand extends BcfCommand { private final String _publicIp; private final String _floatingIpId; - public DeleteBcfStaticNatCommand(String tenantId, String publicIp){ + public DeleteBcfStaticNatCommand(final String tenantId, final String publicIp){ this._tenantId = tenantId; this._publicIp = publicIp; this._floatingIpId = publicIp.replace(".", "-"); } - public String get_tenantId() { + public String getTenantId() { return _tenantId; } - public String get_publicIp() { + public String getPublicIp() { return _publicIp; } - public String get_floatingIpId() { + public String getFloatingIpId() { return _floatingIpId; } } diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerDataAnswer.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerDataAnswer.java index e32bfb005ff..9f200d838db 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerDataAnswer.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerDataAnswer.java @@ -20,26 +20,27 @@ package com.cloud.agent.api; public class GetControllerDataAnswer extends Answer { - private final String ipAddress; - private final boolean isMaster; + private final String _ipAddress; + private final boolean _isMaster; - public GetControllerDataAnswer(GetControllerDataCommand cmd, - String ipAddress, boolean isMaster){ - this.ipAddress = ipAddress; - this.isMaster = isMaster; + public GetControllerDataAnswer(final GetControllerDataCommand cmd, + final String ipAddress, final boolean isMaster){ + super(cmd); + this._ipAddress = ipAddress; + this._isMaster = isMaster; } - public GetControllerDataAnswer(Command command, Exception e) { + public GetControllerDataAnswer(final Command command, final Exception e) { super(command, e); - this.ipAddress = null; - this.isMaster = false; + this._ipAddress = null; + this._isMaster = false; } public String getIpAddress() { - return ipAddress; + return _ipAddress; } public boolean isMaster() { - return isMaster; + return _isMaster; } -} \ No newline at end of file +} diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerDataCommand.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerDataCommand.java index 661ad1651c5..96ad1193a08 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerDataCommand.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerDataCommand.java @@ -20,6 +20,4 @@ package com.cloud.agent.api; public class GetControllerDataCommand extends BcfCommand { - public GetControllerDataCommand() { - } } diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerHostsAnswer.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerHostsAnswer.java index 413e83e15a7..e4c889cbd99 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerHostsAnswer.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerHostsAnswer.java @@ -28,13 +28,13 @@ public class GetControllerHostsAnswer { public HostVO getMaster() { return master; } - public void setMaster(HostVO master) { + public void setMaster(final HostVO master) { this.master = master; } public HostVO getSlave() { return slave; } - public void setSlave(HostVO slave) { + public void setSlave(final HostVO slave) { this.slave = slave; } } diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerHostsCommand.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerHostsCommand.java index 253c8e29354..c984b289aad 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerHostsCommand.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerHostsCommand.java @@ -20,6 +20,4 @@ package com.cloud.agent.api; public class GetControllerHostsCommand extends BcfCommand { - public GetControllerHostsCommand() { - } -} \ No newline at end of file +} diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/SyncBcfTopologyCommand.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/SyncBcfTopologyCommand.java index 660151ce35e..89c3e1c343e 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/SyncBcfTopologyCommand.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/SyncBcfTopologyCommand.java @@ -20,19 +20,19 @@ package com.cloud.agent.api; public class SyncBcfTopologyCommand extends BcfCommand { - private final boolean networkIncluded; - private final boolean routerIncluded; + private final boolean _networkIncluded; + private final boolean _routerIncluded; - public SyncBcfTopologyCommand(boolean networkIncluded, boolean routerIncluded) { - this.networkIncluded = networkIncluded; - this.routerIncluded = routerIncluded; + public SyncBcfTopologyCommand(final boolean networkIncluded, final boolean routerIncluded) { + this._networkIncluded = networkIncluded; + this._routerIncluded = routerIncluded; } public boolean isNetworkIncluded() { - return networkIncluded; + return _networkIncluded; } public boolean isRouterIncluded() { - return routerIncluded; + return _routerIncluded; } } diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/UpdateBcfAttachmentCommand.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/UpdateBcfAttachmentCommand.java index 412ee215ef1..4e054f08733 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/UpdateBcfAttachmentCommand.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/UpdateBcfAttachmentCommand.java @@ -20,12 +20,13 @@ package com.cloud.agent.api; public class UpdateBcfAttachmentCommand extends BcfCommand { - private String _networkId; - private String _attachmentId; - private String _tenantId; - private String _attachmentName; + private final String _networkId; + private final String _attachmentId; + private final String _tenantId; + private final String _attachmentName; - public UpdateBcfAttachmentCommand(String networkId, String attachmentId, String tenantId, String attachmentName) { + public UpdateBcfAttachmentCommand(final String networkId, final String attachmentId, + final String tenantId, final String attachmentName) { this._networkId = networkId; this._attachmentId = attachmentId; this._tenantId = tenantId; diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/UpdateBcfRouterCommand.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/UpdateBcfRouterCommand.java index 675a1ee430c..47a9356b1c3 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/UpdateBcfRouterCommand.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/UpdateBcfRouterCommand.java @@ -27,9 +27,9 @@ import com.cloud.network.bigswitch.AclData; public class UpdateBcfRouterCommand extends BcfCommand { private String tenantId; private String publicIp; - private List acls; + private final List acls; - public UpdateBcfRouterCommand(String tenantId){ + public UpdateBcfRouterCommand(final String tenantId){ this.tenantId = tenantId; this.publicIp = null; this.acls = new ArrayList(); @@ -39,7 +39,7 @@ public class UpdateBcfRouterCommand extends BcfCommand { return tenantId; } - public void setTenantId(String tenantId) { + public void setTenantId(final String tenantId) { this.tenantId = tenantId; } @@ -47,7 +47,7 @@ public class UpdateBcfRouterCommand extends BcfCommand { return publicIp; } - public void setPublicIp(String publicIp) { + public void setPublicIp(final String publicIp) { this.publicIp = publicIp; } @@ -55,7 +55,7 @@ public class UpdateBcfRouterCommand extends BcfCommand { return acls; } - public void addAcl(AclData acl){ + public void addAcl(final AclData acl){ this.acls.add(acl); } } diff --git a/plugins/network-elements/bigswitch/src/com/cloud/api/commands/AddBigSwitchBcfDeviceCmd.java b/plugins/network-elements/bigswitch/src/com/cloud/api/commands/AddBigSwitchBcfDeviceCmd.java index 24334ea249e..8231484840f 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/api/commands/AddBigSwitchBcfDeviceCmd.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/api/commands/AddBigSwitchBcfDeviceCmd.java @@ -43,9 +43,9 @@ import com.cloud.utils.exception.CloudRuntimeException; @APICommand(name = "addBigSwitchBcfDevice", responseObject = BigSwitchBcfDeviceResponse.class, description = "Adds a BigSwitch BCF Controller device", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class AddBigSwitchBcfDeviceCmd extends BaseAsyncCmd { - private static final String s_name = "addbigswitchbcfdeviceresponse"; + private static final String S_NAME = "addbigswitchbcfdeviceresponse"; @Inject - BigSwitchBcfElementService _bigswitchBcfElementService; + private BigSwitchBcfElementService bcfElementService; ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// @@ -105,25 +105,24 @@ public class AddBigSwitchBcfDeviceCmd extends BaseAsyncCmd { public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException { try { - BigSwitchBcfDeviceVO bigswitchBcfDeviceVO = _bigswitchBcfElementService.addBigSwitchBcfDevice(this); - if (bigswitchBcfDeviceVO != null) { - BigSwitchBcfDeviceResponse response = _bigswitchBcfElementService.createBigSwitchBcfDeviceResponse(bigswitchBcfDeviceVO); - response.setObjectName("bigswitchbcfdevice"); - response.setResponseName(getCommandName()); - this.setResponseObject(response); - } else { + final BigSwitchBcfDeviceVO bigswitchBcfDeviceVO = bcfElementService.addBigSwitchBcfDevice(this); + if (bigswitchBcfDeviceVO == null) { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add BigSwitch BCF Controller device due to internal error."); } + final BigSwitchBcfDeviceResponse response = bcfElementService.createBigSwitchBcfDeviceResponse(bigswitchBcfDeviceVO); + response.setObjectName("bigswitchbcfdevice"); + response.setResponseName(getCommandName()); + this.setResponseObject(response); } catch (InvalidParameterValueException invalidParamExcp) { - throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage()); + throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage(), invalidParamExcp); } catch (CloudRuntimeException runtimeExcp) { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage()); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage(), runtimeExcp); } } @Override public String getCommandName() { - return s_name; + return S_NAME; } @Override @@ -133,7 +132,7 @@ public class AddBigSwitchBcfDeviceCmd extends BaseAsyncCmd { @Override public String getEventType() { - return BcfConstants.EVENT_EXTERNAL_BCF_CONTROLLER_ADD; + return BcfConstants.EVENT_BCF_CONTROLLER_ADD; } @Override diff --git a/plugins/network-elements/bigswitch/src/com/cloud/api/commands/BcfConstants.java b/plugins/network-elements/bigswitch/src/com/cloud/api/commands/BcfConstants.java index 4b6cc3a4738..157d9a31616 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/api/commands/BcfConstants.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/api/commands/BcfConstants.java @@ -27,11 +27,11 @@ public class BcfConstants { public static final String BIGSWITCH_BCF_DEVICE_ID = "bcfdeviceid"; public static final String BIGSWITCH_BCF_DEVICE_NAME = "bigswitchdevicename"; public static final String BIGSWITCH_BCF_DEVICE_NAT = "nat"; - public static final String EVENT_EXTERNAL_BCF_CONTROLLER_ADD = "PHYSICAL.BCFCONTROLLER.ADD"; - public static final String EVENT_EXTERNAL_BCF_CONTROLLER_DELETE = "PHYSICAL.BCFCONTROLLER.DELETE"; + public static final String EVENT_BCF_CONTROLLER_ADD = "PHYSICAL.BCFCONTROLLER.ADD"; + public static final String EVENT_BCF_CONTROLLER_DELETE = "PHYSICAL.BCFCONTROLLER.DELETE"; - public static final Provider BigSwitchBcf = new Provider("BigSwitchBcf", true); + public static final Provider BIG_SWITCH_BCF = new Provider("BigSwitchBcf", true); - public static final NetworkDevice BigSwitchBcfDevice = new NetworkDevice("BigSwitchBcf", BigSwitchBcf.getName()); + public static final NetworkDevice BIG_SWITCH_BCF_DEVICE = new NetworkDevice("BigSwitchBcf", BIG_SWITCH_BCF.getName()); } diff --git a/plugins/network-elements/bigswitch/src/com/cloud/api/commands/DeleteBigSwitchBcfDeviceCmd.java b/plugins/network-elements/bigswitch/src/com/cloud/api/commands/DeleteBigSwitchBcfDeviceCmd.java index 520be8dc3d0..f558562d587 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/api/commands/DeleteBigSwitchBcfDeviceCmd.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/api/commands/DeleteBigSwitchBcfDeviceCmd.java @@ -41,9 +41,9 @@ import com.cloud.utils.exception.CloudRuntimeException; @APICommand(name = "deleteBigSwitchBcfDevice", responseObject = SuccessResponse.class, description = " delete a BigSwitch BCF Controller device", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteBigSwitchBcfDeviceCmd extends BaseAsyncCmd { - private static final String s_name = "deletebigswitchbcfdeviceresponse"; + private static final String S_NAME = "deletebigswitchbcfdeviceresponse"; @Inject - BigSwitchBcfElementService _bigswitchBcfElementService; + private BigSwitchBcfElementService bigswitchBcfElementService; ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// @@ -72,24 +72,24 @@ public class DeleteBigSwitchBcfDeviceCmd extends BaseAsyncCmd { public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException { try { - boolean result = _bigswitchBcfElementService.deleteBigSwitchBcfDevice(this); + final boolean result = bigswitchBcfElementService.deleteBigSwitchBcfDevice(this); if (result) { - SuccessResponse response = new SuccessResponse(getCommandName()); + final SuccessResponse response = new SuccessResponse(getCommandName()); response.setResponseName(getCommandName()); this.setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete BigSwitch device."); } } catch (InvalidParameterValueException invalidParamExcp) { - throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage()); + throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage(), invalidParamExcp); } catch (CloudRuntimeException runtimeExcp) { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage()); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage(), runtimeExcp); } } @Override public String getCommandName() { - return s_name; + return S_NAME; } @Override @@ -99,7 +99,7 @@ public class DeleteBigSwitchBcfDeviceCmd extends BaseAsyncCmd { @Override public String getEventType() { - return BcfConstants.EVENT_EXTERNAL_BCF_CONTROLLER_DELETE; + return BcfConstants.EVENT_BCF_CONTROLLER_DELETE; } @Override diff --git a/plugins/network-elements/bigswitch/src/com/cloud/api/commands/ListBigSwitchBcfDevicesCmd.java b/plugins/network-elements/bigswitch/src/com/cloud/api/commands/ListBigSwitchBcfDevicesCmd.java index 25c67523fe3..3e25848804d 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/api/commands/ListBigSwitchBcfDevicesCmd.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/api/commands/ListBigSwitchBcfDevicesCmd.java @@ -48,10 +48,10 @@ import com.cloud.utils.exception.CloudRuntimeException; @APICommand(name = "listBigSwitchBcfDevices", responseObject = BigSwitchBcfDeviceResponse.class, description = "Lists BigSwitch BCF Controller devices", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListBigSwitchBcfDevicesCmd extends BaseListCmd { - public static final Logger s_logger = Logger.getLogger(ListBigSwitchBcfDevicesCmd.class.getName()); - private static final String s_name = "listbigswitchbcfdeviceresponse"; + public static final Logger S_LOGGER = Logger.getLogger(ListBigSwitchBcfDevicesCmd.class.getName()); + private static final String S_NAME = "listbigswitchbcfdeviceresponse"; @Inject - BigSwitchBcfElementService _bigswitchBcfElementService; + private BigSwitchBcfElementService bigswitchBcfElementService; ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// @@ -86,13 +86,13 @@ public class ListBigSwitchBcfDevicesCmd extends BaseListCmd { public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException { try { - List bigswitchDevices = _bigswitchBcfElementService.listBigSwitchBcfDevices(this); - ListResponse response = new ListResponse(); - List bigswitchDevicesResponse = new ArrayList(); + final List bigswitchDevices = bigswitchBcfElementService.listBigSwitchBcfDevices(this); + final ListResponse response = new ListResponse(); + final List bigswitchDevicesResponse = new ArrayList(); if (bigswitchDevices != null && !bigswitchDevices.isEmpty()) { - for (BigSwitchBcfDeviceVO bigswitchDeviceVO : bigswitchDevices) { - BigSwitchBcfDeviceResponse bigswitchDeviceResponse = _bigswitchBcfElementService.createBigSwitchBcfDeviceResponse(bigswitchDeviceVO); + for (final BigSwitchBcfDeviceVO bigswitchDeviceVO : bigswitchDevices) { + final BigSwitchBcfDeviceResponse bigswitchDeviceResponse = bigswitchBcfElementService.createBigSwitchBcfDeviceResponse(bigswitchDeviceVO); bigswitchDevicesResponse.add(bigswitchDeviceResponse); } } @@ -101,14 +101,14 @@ public class ListBigSwitchBcfDevicesCmd extends BaseListCmd { response.setResponseName(getCommandName()); this.setResponseObject(response); } catch (InvalidParameterValueException invalidParamExcp) { - throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage()); + throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage(), invalidParamExcp); } catch (CloudRuntimeException runtimeExcp) { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage()); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage(), runtimeExcp); } } @Override public String getCommandName() { - return s_name; + return S_NAME; } } diff --git a/plugins/network-elements/bigswitch/src/com/cloud/api/response/BigSwitchBcfDeviceResponse.java b/plugins/network-elements/bigswitch/src/com/cloud/api/response/BigSwitchBcfDeviceResponse.java index 37906a5c1db..1d1fe442430 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/api/response/BigSwitchBcfDeviceResponse.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/api/response/BigSwitchBcfDeviceResponse.java @@ -65,35 +65,35 @@ public class BigSwitchBcfDeviceResponse extends BaseResponse { return this.id; } - public void setId(String bcfDeviceId) { + public void setId(final String bcfDeviceId) { this.id = bcfDeviceId; } - public void setPhysicalNetworkId(String physicalNetworkId) { + public void setPhysicalNetworkId(final String physicalNetworkId) { this.physicalNetworkId = physicalNetworkId; } - public void setProviderName(String providerName) { + public void setProviderName(final String providerName) { this.providerName = providerName; } - public void setDeviceName(String deviceName) { + public void setDeviceName(final String deviceName) { this.deviceName = deviceName; } - public void setHostName(String hostName) { + public void setHostName(final String hostName) { this.hostName = hostName; } - public void setUserName(String username) { + public void setUserName(final String username) { this.username = username; } - public void setPassword(String password) { + public void setPassword(final String password) { this.password = password; } - public void setNat(Boolean nat) { + public void setNat(final Boolean nat) { this.nat = nat; } } diff --git a/plugins/network-elements/bigswitch/src/com/cloud/network/BigSwitchBcfDeviceVO.java b/plugins/network-elements/bigswitch/src/com/cloud/network/BigSwitchBcfDeviceVO.java index 8c7269eb788..1338eebdb73 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/network/BigSwitchBcfDeviceVO.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/network/BigSwitchBcfDeviceVO.java @@ -73,8 +73,10 @@ public class BigSwitchBcfDeviceVO implements InternalIdentity { this.uuid = UUID.randomUUID().toString(); } - public BigSwitchBcfDeviceVO(long hostId, long physicalNetworkId, String providerName, String deviceName, - String hostName, String username, String password, Boolean nat, String hash) { + public BigSwitchBcfDeviceVO(final long hostId, final long physicalNetworkId, + final String providerName, final String deviceName,final String hostName, + final String username, final String password, final Boolean nat, + final String hash) { super(); this.hostId = hostId; this.physicalNetworkId = physicalNetworkId; @@ -97,7 +99,7 @@ public class BigSwitchBcfDeviceVO implements InternalIdentity { return uuid; } - public void setUuid(String uuid) { + public void setUuid(final String uuid) { this.uuid = uuid; } @@ -121,7 +123,7 @@ public class BigSwitchBcfDeviceVO implements InternalIdentity { return hash; } - public void setHash(String h) { + public void setHash(final String h) { hash = h; } diff --git a/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/AclData.java b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/AclData.java index 72b0cc90b71..150bc61cff5 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/AclData.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/AclData.java @@ -19,6 +19,8 @@ package com.cloud.network.bigswitch; +import java.util.Locale; + import com.cloud.network.vpc.NetworkACLItem; import com.google.gson.annotations.SerializedName; @@ -41,19 +43,19 @@ public class AclData { this.action = null; this.ipProto = null; this.source = new AclNetwork(); - this.destination = new AclNetwork();; + this.destination = new AclNetwork(); } public class AclNetwork{ - @SerializedName("cidr") private String cidr; - @SerializedName("port") private Integer port; + @SerializedName("cidr") final private String cidr; + @SerializedName("port") final private Integer port; public AclNetwork(){ this.cidr = null; this.port = null; } - public AclNetwork(String cidr, Integer port){ + public AclNetwork(final String cidr, final Integer port){ this.cidr = cidr; this.port = port; } @@ -62,19 +64,19 @@ public class AclData { public String getId() { return id; } - public void setId(String id) { + public void setId(final String id) { this.id = id; } public int getPriority() { return priority; } - public void setPriority(int priority) { + public void setPriority(final int priority) { this.priority = priority; } public String getAction() { return action; } - public void setAction(String action) { + public void setAction(final String action) { if(action.equalsIgnoreCase(NetworkACLItem.Action.Allow.name())){ this.action = "permit"; } else { @@ -84,9 +86,9 @@ public class AclData { public String getIpProto() { return ipProto; } - public void setIpProto(String ipProto) { - if (!ipProto.equalsIgnoreCase("all")){ - switch(ipProto.toLowerCase()){ + public void setIpProto(final String ipProto) { + if (ipProto != null && !ipProto.equalsIgnoreCase("all")){ + switch(ipProto.toLowerCase(Locale.ENGLISH)){ case "tcp": this.ipProto = "6"; break; @@ -96,19 +98,21 @@ public class AclData { case "icmp": this.ipProto = "1"; break; + default: + throw new IllegalArgumentException("Protocol in ACL rule not supported"); } } } public AclNetwork getSource() { return source; } - public void setSource(AclNetwork source) { + public void setSource(final AclNetwork source) { this.source = source; } public AclNetwork getDestination() { return destination; } - public void setDestination(AclNetwork destination) { + public void setDestination(final AclNetwork destination) { this.destination = destination; } } diff --git a/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/AttachmentData.java b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/AttachmentData.java index 649f7043abf..40d99e3204e 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/AttachmentData.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/AttachmentData.java @@ -20,6 +20,7 @@ package com.cloud.network.bigswitch; import java.util.ArrayList; +import java.util.List; import com.google.gson.annotations.SerializedName; @@ -28,7 +29,7 @@ import com.google.gson.annotations.SerializedName; * in CreateBcfAttachmentCommand */ public class AttachmentData { - @SerializedName("port") private Attachment attachment; + @SerializedName("port") final private Attachment attachment; public Attachment getAttachment() { return this.attachment; @@ -42,9 +43,9 @@ public class AttachmentData { @SerializedName("id") private String id; @SerializedName("tenant_name") private String tenantName; @SerializedName("vlan") private Integer vlan; - @SerializedName("fixed_ips") private ArrayList fixedIps; + @SerializedName("fixed_ips") final private List fixedIps; @SerializedName("mac_address") private String macAddress; - @SerializedName("bound_segment") private BoundSegment boundSegment; + @SerializedName("bound_segment") final private BoundSegment boundSegment; @SerializedName("binding:host_id") private String hostId; public Attachment(){ @@ -65,14 +66,14 @@ public class AttachmentData { } public class IpAddress { - @SerializedName("ip_address") private String ipAddress; + @SerializedName("ip_address") private String address; - public IpAddress(String ipAddr) { - this.ipAddress = ipAddr; + public IpAddress(final String ipAddr) { + this.address = ipAddr; } public String getIpAddress(){ - return ipAddress; + return address; } } @@ -82,7 +83,7 @@ public class AttachmentData { return tenantName; } - public void setTenantName(String tenantName) { + public void setTenantName(final String tenantName) { this.tenantName = tenantName; } @@ -90,7 +91,7 @@ public class AttachmentData { return id; } - public void setId(String id) { + public void setId(final String id) { this.id = id; } @@ -98,7 +99,7 @@ public class AttachmentData { return hostId; } - public void setHostId(String hostId) { + public void setHostId(final String hostId) { this.hostId = hostId; } @@ -106,16 +107,16 @@ public class AttachmentData { return vlan; } - public void setVlan(Integer vlan) { + public void setVlan(final Integer vlan) { this.vlan = vlan; this.boundSegment.setSegmentationId(vlan); } - public ArrayList getIpv4List() { + public List getIpv4List() { return fixedIps; } - public void addIpv4(String ipv4) { + public void addIpv4(final String ipv4) { this.fixedIps.add(new IpAddress(ipv4)); } @@ -123,7 +124,7 @@ public class AttachmentData { return macAddress; } - public void setMac(String mac) { + public void setMac(final String mac) { this.macAddress = mac; } @@ -135,7 +136,7 @@ public class AttachmentData { return state; } - public void setState(String state) { + public void setState(final String state) { this.state = state; } } diff --git a/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchBcfApi.java b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchBcfApi.java index 5c1efb0b5c4..16cb3f70fc7 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchBcfApi.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchBcfApi.java @@ -53,25 +53,25 @@ import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; public class BigSwitchBcfApi { - private static final Logger s_logger = Logger.getLogger(BigSwitchBcfApi.class); - private final static String s_protocol = "https"; - private final static String s_nsBaseUri = "/networkService/v1.1"; + private static final Logger S_LOGGER = Logger.getLogger(BigSwitchBcfApi.class); + private final static String S_PROTOCOL = "https"; + private final static String S_NS_BASE_URL = "/networkService/v1.1"; private final static String CONTENT_TYPE = "Content-type"; private final static String ACCEPT = "Accept"; private final static String CONTENT_JSON = "application/json"; private final static String HTTP_HEADER_INSTANCE_ID = "Instance-ID"; private final static String CLOUDSTACK_INSTANCE_ID = "cloudstack"; private final static String HASH_MATCH = "X-BSN-BVS-HASH-MATCH"; - private final static MultiThreadedHttpConnectionManager s_httpClientManager = new MultiThreadedHttpConnectionManager(); + private final static MultiThreadedHttpConnectionManager S_HTTP_CLIENT_MANAGER = new MultiThreadedHttpConnectionManager(); - private String _host; - private String _username; - private String _password; - private String _hash; - private String _zoneId; - private Boolean _nat; + private String host; + private String username; + private String password; + private String hash; + private String zoneId; + private Boolean nat; - private boolean _isMaster = false; + private boolean isMaster; private int _port = 8000; @@ -85,15 +85,15 @@ public class BigSwitchBcfApi { * in the unittests. */ protected HttpClient createHttpClient() { - return new HttpClient(s_httpClientManager); + return new HttpClient(S_HTTP_CLIENT_MANAGER); } - protected HttpMethod createMethod(String type, String uri, int port) throws BigSwitchBcfApiException { + protected HttpMethod createMethod(final String type, final String uri, final int port) throws BigSwitchBcfApiException { String url; try { - url = new URL(s_protocol, _host, port, uri).toString(); + url = new URL(S_PROTOCOL, host, port, uri).toString(); } catch (MalformedURLException e) { - s_logger.error("Unable to build Big Switch API URL", e); + S_LOGGER.error("Unable to build Big Switch API URL", e); throw new BigSwitchBcfApiException("Unable to build Big Switch API URL", e); } @@ -118,7 +118,7 @@ public class BigSwitchBcfApi { // Cast to ProtocolSocketFactory to avoid the deprecated constructor with the SecureProtocolSocketFactory parameter Protocol.registerProtocol("https", new Protocol("https", (ProtocolSocketFactory) new TrustingProtocolSocketFactory(), _port)); } catch (IOException e) { - s_logger.warn("Failed to register the TrustingProtocolSocketFactory, falling back to default SSLSocketFactory", e); + S_LOGGER.warn("Failed to register the TrustingProtocolSocketFactory, falling back to default SSLSocketFactory", e); } } @@ -126,99 +126,99 @@ public class BigSwitchBcfApi { * Setter used by UI to set BSN controller address * @param address */ - public void setControllerAddress(String address) { - this._host = address; + public void setControllerAddress(final String address) { + this.host = address; } /** * Setter used by UI to set BSN controller user name * @param username */ - public void setControllerUsername(String username) { - this._username = username; + public void setControllerUsername(final String username) { + this.username = username; } /** * Setter used by UI to set BSN controller password * @param password */ - public void setControllerPassword(String password) { - this._password = password; + public void setControllerPassword(final String password) { + this.password = password; } /** * Setter used by UI to set BSN controller NAT mode * @param nat */ - public void setControllerNat(Boolean nat) { - this._nat = nat; + public void setControllerNat(final Boolean nat) { + this.nat = nat; } public boolean isNatEnabled() { - return this._nat; + return this.nat; } - /** - * Setter used by UI to set BSN controller password - * @param password - */ - public void setZoneId(String zoneId) { - this._zoneId = zoneId; + public void setZoneId(final String zoneId) { + this.zoneId = zoneId; } - public String createNetwork(NetworkData network) throws BigSwitchBcfApiException { - String uri = s_nsBaseUri + "/tenants/" + network.getNetwork().getTenantId() + "/networks"; + public String createNetwork(final NetworkData network) throws BigSwitchBcfApiException { + String uri = S_NS_BASE_URL + "/tenants/" + network.getNetwork().getTenantId() + "/networks"; return executeCreateObject(network, uri, Collections. emptyMap()); } - public String deleteNetwork(String tenantId, String networkId) throws BigSwitchBcfApiException { - String uri = s_nsBaseUri + "/tenants/" + tenantId + "/networks/" + networkId; + public String deleteNetwork(final String tenantId, final String networkId) throws BigSwitchBcfApiException { + String uri = S_NS_BASE_URL + "/tenants/" + tenantId + "/networks/" + networkId; return executeDeleteObject(uri); } - public String createAttachment(String tenantId, String networkId, AttachmentData attachment) throws BigSwitchBcfApiException { - String uri = s_nsBaseUri + "/tenants/" + tenantId + "/networks/" + networkId + "/ports/" + attachment.getAttachment().getId() + "/attachment"; + public String createAttachment(final String tenantId, final String networkId, + final AttachmentData attachment) throws BigSwitchBcfApiException { + String uri = S_NS_BASE_URL + "/tenants/" + tenantId + "/networks/" + networkId + "/ports/" + attachment.getAttachment().getId() + "/attachment"; return executeCreateObject(attachment, uri, Collections. emptyMap()); } - public String modifyAttachment(String tenantId, String networkId, AttachmentData attachment) throws BigSwitchBcfApiException { - String uri = s_nsBaseUri + "/tenants/" + tenantId + "/networks/" + networkId + "/ports/" + attachment.getAttachment().getId() + "/attachment"; + public String modifyAttachment(final String tenantId, final String networkId, + final AttachmentData attachment) throws BigSwitchBcfApiException { + String uri = S_NS_BASE_URL + "/tenants/" + tenantId + "/networks/" + networkId + "/ports/" + attachment.getAttachment().getId() + "/attachment"; return executeUpdateObject(attachment, uri, Collections. emptyMap()); } - public String deleteAttachment(String tenantId, String networkId, String attachmentId) throws BigSwitchBcfApiException { - String uri = s_nsBaseUri + "/tenants/" + tenantId + "/networks/" + networkId + "/ports/" + attachmentId + "/attachment"; + public String deleteAttachment(final String tenantId, final String networkId, + final String attachmentId) throws BigSwitchBcfApiException { + String uri = S_NS_BASE_URL + "/tenants/" + tenantId + "/networks/" + networkId + "/ports/" + attachmentId + "/attachment"; return executeDeleteObject(uri); } - public String createRouter(String tenantId, RouterData router) throws BigSwitchBcfApiException { - String uri = s_nsBaseUri + "/tenants/" + tenantId + "/routers"; + public String createRouter(final String tenantId, final RouterData router) throws BigSwitchBcfApiException { + String uri = S_NS_BASE_URL + "/tenants/" + tenantId + "/routers"; return executeCreateObject(router, uri, Collections. emptyMap()); } - public String modifyRouter(String tenantId, RouterData router) throws BigSwitchBcfApiException, + public String modifyRouter(final String tenantId, final RouterData router) throws BigSwitchBcfApiException, IllegalArgumentException{ - String uri = s_nsBaseUri + "/tenants/" + tenantId + "/routers"; + String uri = S_NS_BASE_URL + "/tenants/" + tenantId + "/routers"; return executeCreateObject(router, uri, Collections. emptyMap()); } - public String createRouterInterface(String tenantId, String routerId, RouterInterfaceData routerInterface) throws BigSwitchBcfApiException { - String uri = s_nsBaseUri + "/tenants/" + tenantId + "/routers/" + routerId + "/interfaces"; + public String createRouterInterface(final String tenantId, final String routerId, + final RouterInterfaceData routerInterface) throws BigSwitchBcfApiException { + String uri = S_NS_BASE_URL + "/tenants/" + tenantId + "/routers/" + routerId + "/interfaces"; return executeCreateObject(routerInterface, uri, Collections. emptyMap()); } - public String createFloatingIp(String tenantId, FloatingIpData fip) throws BigSwitchBcfApiException { - String uri = s_nsBaseUri + "/tenants/" + tenantId + "/floatingips"; + public String createFloatingIp(final String tenantId, final FloatingIpData fip) throws BigSwitchBcfApiException { + String uri = S_NS_BASE_URL + "/tenants/" + tenantId + "/floatingips"; return executeCreateObject(fip, uri, Collections. emptyMap()); } - public String deleteFloatingIp(String tenantId, String fipId) throws BigSwitchBcfApiException { - String uri = s_nsBaseUri + "/tenants/" + tenantId + "/floatingips/" + fipId; + public String deleteFloatingIp(final String tenantId, final String fipId) throws BigSwitchBcfApiException { + String uri = S_NS_BASE_URL + "/tenants/" + tenantId + "/floatingips/" + fipId; return executeDeleteObject(uri); } public ControlClusterStatus getControlClusterStatus() throws BigSwitchBcfApiException { - String uri = s_nsBaseUri + "/health"; + String uri = S_NS_BASE_URL + "/health"; ControlClusterStatus ccs = executeRetrieveObject(new TypeToken() { }.getType(), uri, null); ccs.setStatus(true); @@ -226,7 +226,7 @@ public class BigSwitchBcfApi { } public Capabilities getCapabilities() throws BigSwitchBcfApiException { - String uri = s_nsBaseUri + "/capabilities"; + String uri = S_NS_BASE_URL + "/capabilities"; List capslist = executeRetrieveObject(new TypeToken>() { }.getType(), uri, null); Capabilities caps = new Capabilities(); @@ -234,28 +234,28 @@ public class BigSwitchBcfApi { return caps; } - public String syncTopology(TopologyData topo) throws BigSwitchBcfApiException { - String uri = s_nsBaseUri + "/topology"; + public String syncTopology(final TopologyData topo) throws BigSwitchBcfApiException { + String uri = S_NS_BASE_URL + "/topology"; return executeCreateObject(topo, uri, Collections. emptyMap()); } public ControllerData getControllerData() { - return new ControllerData(_host, _isMaster); + return new ControllerData(host, isMaster); } private void checkInvariants() throws BigSwitchBcfApiException{ - if (_host == null || _host.isEmpty()) { + if (host == null || host.isEmpty()) { throw new BigSwitchBcfApiException("Hostname is null or empty"); } - if (_username == null || _username.isEmpty()){ + if (username == null || username.isEmpty()){ throw new BigSwitchBcfApiException("Username is null or empty"); } - if (_password == null || _password.isEmpty()){ + if (password == null || password.isEmpty()){ throw new BigSwitchBcfApiException("Password is null or empty"); } } - private String checkResponse(HttpMethodBase m, String errorMessageBase) throws BigSwitchBcfApiException, + private String checkResponse(final HttpMethodBase m, final String errorMessageBase) throws BigSwitchBcfApiException, IllegalArgumentException{ String customErrorMsg = null; if (m.getStatusCode() == HttpStatus.SC_OK) { @@ -273,7 +273,7 @@ public class BigSwitchBcfApi { throw new BigSwitchBcfApiException("BCF topology sync required", true); } if (m.getStatusCode() == HttpStatus.SC_SEE_OTHER) { - _isMaster = false; + isMaster = false; set_hash(HASH_IGNORE); return HASH_IGNORE; } @@ -288,24 +288,25 @@ public class BigSwitchBcfApi { } String errorMessage = responseToErrorMessage(m); m.releaseConnection(); - s_logger.error(errorMessageBase + errorMessage); + S_LOGGER.error(errorMessageBase + errorMessage); throw new BigSwitchBcfApiException(errorMessageBase + errorMessage + customErrorMsg); } - private void setHttpHeader(HttpMethodBase m) { + private void setHttpHeader(final HttpMethodBase m) { m.setRequestHeader(CONTENT_TYPE, CONTENT_JSON); m.setRequestHeader(ACCEPT, CONTENT_JSON); - m.setRequestHeader(HTTP_HEADER_INSTANCE_ID, CLOUDSTACK_INSTANCE_ID + "-" + _zoneId); - if (_hash != "" ) { - m.setRequestHeader(HASH_MATCH, _hash); + m.setRequestHeader(HTTP_HEADER_INSTANCE_ID, CLOUDSTACK_INSTANCE_ID + "-" + zoneId); + if (hash != "" ) { + m.setRequestHeader(HASH_MATCH, hash); } - String authString = _username + ":" + _password; + String authString = username + ":" + password; String encodedAuthString = "Basic " + Base64.encodeBase64String(authString.getBytes(Charset.forName("UTF-8"))); m.setRequestHeader("Authorization", encodedAuthString); } - protected String executeUpdateObject(T newObject, String uri, Map parameters) throws BigSwitchBcfApiException, + protected String executeUpdateObject(final T newObject, final String uri, + final Map parameters) throws BigSwitchBcfApiException, IllegalArgumentException{ checkInvariants(); @@ -328,7 +329,8 @@ public class BigSwitchBcfApi { return hash; } - protected String executeCreateObject(T newObject, String uri, Map parameters) throws BigSwitchBcfApiException { + protected String executeCreateObject(final T newObject, final String uri, + final Map parameters) throws BigSwitchBcfApiException { checkInvariants(); PostMethod pm = (PostMethod)createMethod("post", uri, _port); @@ -350,7 +352,7 @@ public class BigSwitchBcfApi { return hash; } - protected String executeDeleteObject(String uri) throws BigSwitchBcfApiException { + protected String executeDeleteObject(final String uri) throws BigSwitchBcfApiException { checkInvariants(); DeleteMethod dm = (DeleteMethod)createMethod("delete", uri, _port); @@ -367,8 +369,8 @@ public class BigSwitchBcfApi { } @SuppressWarnings("unchecked") - protected T executeRetrieveObject(Type returnObjectType, - String uri, Map parameters) throws BigSwitchBcfApiException { + protected T executeRetrieveObject(final Type returnObjectType, + final String uri, final Map parameters) throws BigSwitchBcfApiException { checkInvariants(); GetMethod gm = (GetMethod)createMethod("get", uri, _port); @@ -392,41 +394,41 @@ public class BigSwitchBcfApi { // CAUTIOUS: Safety margin of 2048 characters - extend if needed. returnValue = (T)gson.fromJson(gm.getResponseBodyAsString(2048), returnObjectType); } catch (IOException e) { - s_logger.error("IOException while retrieving response body", e); + S_LOGGER.error("IOException while retrieving response body", e); throw new BigSwitchBcfApiException(e); } finally { gm.releaseConnection(); } if(returnValue instanceof ControlClusterStatus) { if(hash == HASH_CONFLICT) { - _isMaster = true; + isMaster = true; ((ControlClusterStatus) returnValue).setTopologySyncRequested(true); - } else if (hash != HASH_IGNORE && !_isMaster) { - _isMaster = true; + } else if (hash != HASH_IGNORE && !isMaster) { + isMaster = true; ((ControlClusterStatus) returnValue).setTopologySyncRequested(true); } } return returnValue; } - protected void executeMethod(HttpMethodBase method) throws BigSwitchBcfApiException { + protected void executeMethod(final HttpMethodBase method) throws BigSwitchBcfApiException { try { _client.executeMethod(method); if (method.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) { method.releaseConnection(); } } catch (HttpException e) { - s_logger.error("HttpException caught while trying to connect to the BigSwitch Controller", e); + S_LOGGER.error("HttpException caught while trying to connect to the BigSwitch Controller", e); method.releaseConnection(); throw new BigSwitchBcfApiException("API call to BigSwitch Controller Failed", e); } catch (IOException e) { - s_logger.error("IOException caught while trying to connect to the BigSwitch Controller", e); + S_LOGGER.error("IOException caught while trying to connect to the BigSwitch Controller", e); method.releaseConnection(); throw new BigSwitchBcfApiException("API call to BigSwitch Controller Failed", e); } } - private String responseToErrorMessage(HttpMethodBase method) { + private String responseToErrorMessage(final HttpMethodBase method) { assert method.isRequestSent() : "no use getting an error message unless the request is sent"; if ("text/html".equals(method.getResponseHeader(CONTENT_TYPE).getValue())) { @@ -436,7 +438,7 @@ public class BigSwitchBcfApi { try { return method.getResponseBodyAsString(2048); } catch (IOException e) { - s_logger.debug("Error while loading response body", e); + S_LOGGER.debug("Error while loading response body", e); } } @@ -449,11 +451,11 @@ public class BigSwitchBcfApi { } public String get_hash() { - return _hash; + return hash; } - public void set_hash(String hash) { - this._hash = hash; + public void set_hash(final String hash) { + this.hash = hash; } } diff --git a/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchBcfUtils.java b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchBcfUtils.java index b6e3359d7e1..61f3d481637 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchBcfUtils.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchBcfUtils.java @@ -177,7 +177,7 @@ public class BigSwitchBcfUtils { // handle external network first, only if NAT service is enabled if(networks != null) { - if(!(networks.isEmpty()) && isNatEnabled()!=null && isNatEnabled()){ + if(!(networks.isEmpty()) && isNatEnabled()){ // get public net info - needed to set up source nat gateway NetworkVO pubNet = getPublicNetwork(physicalNetworkId); @@ -380,7 +380,7 @@ public class BigSwitchBcfUtils { Integer port = rule.getSourcePortStart(); fwCidrList = _fwCidrsDao.listByFirewallRuleId(rule.getId()); if(fwCidrList != null){ - if(fwCidrList.size()>1 || rule.getSourcePortEnd()!=port){ + if(fwCidrList.size()>1 || !rule.getSourcePortEnd().equals(port)){ continue; } else { cidr = fwCidrList.get(0).getCidr(); @@ -414,7 +414,7 @@ public class BigSwitchBcfUtils { Integer port = item.getSourcePortStart(); // currently BCF supports single port policy aclCidrList = _aclItemCidrsDao.listByNetworkACLItemId(item.getId()); if(aclCidrList != null){ - if(aclCidrList.size()>1 || item.getSourcePortEnd()!=port){ + if(aclCidrList.size()>1 || !item.getSourcePortEnd().equals(port)){ continue; } else { cidr = aclCidrList.get(0).getCidr(); @@ -440,7 +440,7 @@ public class BigSwitchBcfUtils { public String syncTopologyToBcfHost(HostVO bigswitchBcfHost){ SyncBcfTopologyCommand syncCmd; - if(isNatEnabled()!=null && isNatEnabled()){ + if(isNatEnabled()){ syncCmd = new SyncBcfTopologyCommand(true, true); } else { syncCmd = new SyncBcfTopologyCommand(true, false); @@ -486,7 +486,7 @@ public class BigSwitchBcfUtils { } String newHash = answer.getHash(); - if (cmd.is_topologySyncRequested()) { + if (cmd.isTopologySyncRequested()) { newHash = syncTopologyToBcfHost(cluster.getMaster()); } if(newHash != null){ @@ -524,7 +524,7 @@ public class BigSwitchBcfUtils { if(devices != null && !devices.isEmpty()){ return devices.get(0).getNat(); } else { - return null; + return false; } } @@ -532,7 +532,7 @@ public class BigSwitchBcfUtils { if(!IPAddress.isValidIPv4(maskString)){ return null; } - String[] octets = maskString.split("."); + String[] octets = maskString.split("\\."); Integer bits = 0; for (String o: octets){ switch(o){ diff --git a/plugins/network-elements/bigswitch/src/com/cloud/network/element/BigSwitchBcfElement.java b/plugins/network-elements/bigswitch/src/com/cloud/network/element/BigSwitchBcfElement.java index 2de447efb80..3c69f3bf9ce 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/network/element/BigSwitchBcfElement.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/network/element/BigSwitchBcfElement.java @@ -208,7 +208,7 @@ NetworkACLServiceProvider, FirewallServiceProvider, ResourceStateAdapter { return false; } - if (!_ntwkSrvcDao.canProviderSupportServiceInNetwork(network.getId(), service, BcfConstants.BigSwitchBcf)) { + if (!_ntwkSrvcDao.canProviderSupportServiceInNetwork(network.getId(), service, BcfConstants.BIG_SWITCH_BCF)) { s_logger.debug("BigSwitchBcfElement can't provide the " + service.getName() + " service on network " + network.getDisplayText()); return false; } @@ -410,7 +410,7 @@ NetworkACLServiceProvider, FirewallServiceProvider, ResourceStateAdapter { ServerResource resource = new BigSwitchBcfResource(); - final String deviceName = BcfConstants.BigSwitchBcf.getName(); + final String deviceName = BcfConstants.BIG_SWITCH_BCF.getName(); NetworkDevice networkDevice = NetworkDevice.getNetworkDevice(deviceName); final Long physicalNetworkId = cmd.getPhysicalNetworkId(); final String hostname = cmd.getHost(); @@ -452,7 +452,6 @@ NetworkACLServiceProvider, FirewallServiceProvider, ResourceStateAdapter { } Boolean natNow = _bcfUtils.isNatEnabled(); - if( natNow != null) if (!nat && natNow){ throw new CloudRuntimeException("NAT is enabled in existing controller. Enable NAT for new controller or remove existing controller first."); } else if (nat && !natNow){ @@ -684,7 +683,7 @@ NetworkACLServiceProvider, FirewallServiceProvider, ResourceStateAdapter { } cidrList = r.getSourceCidrList(); if(cidrList != null){ - if(cidrList.size()>1 || r.getSourcePortEnd()!=r.getSourcePortStart()){ + if(cidrList.size()>1 || !r.getSourcePortEnd().equals(r.getSourcePortStart())){ throw new ResourceUnavailableException("One CIDR and one port only please.", Network.class, network.getId()); } else { @@ -718,7 +717,7 @@ NetworkACLServiceProvider, FirewallServiceProvider, ResourceStateAdapter { } cidrList = r.getSourceCidrList(); if(cidrList != null){ - if(cidrList.size()>1 || r.getSourcePortEnd()!=r.getSourcePortStart()){ + if(cidrList.size()>1 || !r.getSourcePortEnd().equals(r.getSourcePortStart())){ throw new ResourceUnavailableException("One CIDR and one port only please.", Network.class, network.getId()); } else { diff --git a/plugins/network-elements/bigswitch/src/com/cloud/network/resource/BigSwitchBcfResource.java b/plugins/network-elements/bigswitch/src/com/cloud/network/resource/BigSwitchBcfResource.java index c5407bc8a80..a43cad31371 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/network/resource/BigSwitchBcfResource.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/network/resource/BigSwitchBcfResource.java @@ -312,7 +312,7 @@ public class BigSwitchBcfResource extends ManagerBase implements ServerResource return new BcfAnswer(cmd, true, "Segment " + network.getNetwork().getId() + " created", hash); } catch (BigSwitchBcfApiException e) { if (e.is_topologySyncRequested()) { - cmd.set_topologySyncRequested(true); + cmd.setTopologySyncRequested(true); return new BcfAnswer(cmd, true, "Segment " + network.getNetwork().getId() + " created; topology sync required."); } else { if (numRetries > 0) { @@ -327,11 +327,11 @@ public class BigSwitchBcfResource extends ManagerBase implements ServerResource private Answer executeRequest(DeleteBcfSegmentCommand cmd, int numRetries) { try { - String hash = _bigswitchBcfApi.deleteNetwork(cmd.get_tenantUuid(), cmd.getNetworkUuid()); + String hash = _bigswitchBcfApi.deleteNetwork(cmd.getTenantUuid(), cmd.getNetworkUuid()); return new BcfAnswer(cmd, true, "Segment " + cmd.getNetworkUuid() + " deleted", hash); } catch (BigSwitchBcfApiException e) { if (e.is_topologySyncRequested()) { - cmd.set_topologySyncRequested(true); + cmd.setTopologySyncRequested(true); return new BcfAnswer(cmd, true, "Segment " + cmd.getNetworkUuid() + " deleted; topology sync required."); } else { if (numRetries > 0) { @@ -357,7 +357,7 @@ public class BigSwitchBcfResource extends ManagerBase implements ServerResource return new BcfAnswer(cmd, true, "network attachment " + cmd.getPortId() + " created", hash); } catch (BigSwitchBcfApiException e) { if (e.is_topologySyncRequested()) { - cmd.set_topologySyncRequested(true); + cmd.setTopologySyncRequested(true); return new BcfAnswer(cmd, true, "network attachment " + cmd.getPortId() + " created; topology sync required."); } else { if (numRetries > 0) { @@ -376,7 +376,7 @@ public class BigSwitchBcfResource extends ManagerBase implements ServerResource return new BcfAnswer(cmd, true, "network attachment " + nicName + " deleted", hash); } catch (BigSwitchBcfApiException e) { if (e.is_topologySyncRequested()) { - cmd.set_topologySyncRequested(true); + cmd.setTopologySyncRequested(true); return new BcfAnswer(cmd, true, "network attachment " + nicName + " deleted; topology sync required."); } else { if (numRetries > 0) { @@ -398,7 +398,7 @@ public class BigSwitchBcfResource extends ManagerBase implements ServerResource return new BcfAnswer(cmd, true, "Network attachment " + cmd.getAttachmentId() + " updated", hash); } catch (BigSwitchBcfApiException e) { if (e.is_topologySyncRequested()) { - cmd.set_topologySyncRequested(true); + cmd.setTopologySyncRequested(true); return new BcfAnswer(cmd, true, "Network attachment " + cmd.getAttachmentId() + " updated; topology sync required."); } else { if (numRetries > 0) { @@ -412,21 +412,21 @@ public class BigSwitchBcfResource extends ManagerBase implements ServerResource private Answer executeRequest(CreateBcfStaticNatCommand cmd, int numRetries) { FloatingIpData fip = new FloatingIpData(); - fip.setTenantId(cmd.get_tenantId()); - fip.setNetworkId(cmd.get_networkId()); - fip.setFixedIp(cmd.get_privateIp()); - fip.setFloatingIpAndId(cmd.get_publicIp()); - fip.setMac(cmd.get_mac()); + fip.setTenantId(cmd.getTenantId()); + fip.setNetworkId(cmd.getNetworkId()); + fip.setFixedIp(cmd.getPrivateIp()); + fip.setFloatingIpAndId(cmd.getPublicIp()); + fip.setMac(cmd.getMac()); try { - String hash = _bigswitchBcfApi.createFloatingIp(cmd.get_tenantId(), fip); - return new BcfAnswer(cmd, true, "floating ip " + cmd.get_publicIp() + ":" + - cmd.get_privateIp() + " created", hash); + String hash = _bigswitchBcfApi.createFloatingIp(cmd.getTenantId(), fip); + return new BcfAnswer(cmd, true, "floating ip " + cmd.getPublicIp() + ":" + + cmd.getPrivateIp() + " created", hash); } catch (BigSwitchBcfApiException e) { if (e.is_topologySyncRequested()) { - cmd.set_topologySyncRequested(true); - return new BcfAnswer(cmd, true, "floating ip " + cmd.get_publicIp() + ":" + - cmd.get_privateIp() + " created; topology sync required."); + cmd.setTopologySyncRequested(true); + return new BcfAnswer(cmd, true, "floating ip " + cmd.getPublicIp() + ":" + + cmd.getPrivateIp() + " created; topology sync required."); } else { if (numRetries > 0) { return retry(cmd, --numRetries); @@ -439,12 +439,12 @@ public class BigSwitchBcfResource extends ManagerBase implements ServerResource private Answer executeRequest(DeleteBcfStaticNatCommand cmd, int numRetries) { try { - String hash = _bigswitchBcfApi.deleteFloatingIp(cmd.get_tenantId(), cmd.get_floatingIpId()); - return new BcfAnswer(cmd, true, "floating ip " + cmd.get_publicIp() + " deleted", hash); + String hash = _bigswitchBcfApi.deleteFloatingIp(cmd.getTenantId(), cmd.getFloatingIpId()); + return new BcfAnswer(cmd, true, "floating ip " + cmd.getPublicIp() + " deleted", hash); } catch (BigSwitchBcfApiException e) { if (e.is_topologySyncRequested()) { - cmd.set_topologySyncRequested(true); - return new BcfAnswer(cmd, true, "floating ip " + cmd.get_publicIp() + " deleted; topology sync required."); + cmd.setTopologySyncRequested(true); + return new BcfAnswer(cmd, true, "floating ip " + cmd.getPublicIp() + " deleted; topology sync required."); } else { if (numRetries > 0) { return retry(cmd, --numRetries); @@ -456,16 +456,16 @@ public class BigSwitchBcfResource extends ManagerBase implements ServerResource } private Answer executeRequest(CreateBcfRouterCommand cmd, int numRetries) { - RouterData router = new RouterData(cmd.get_tenantId()); + RouterData router = new RouterData(cmd.getTenantId()); try { String hash; - hash = _bigswitchBcfApi.createRouter(cmd.get_tenantId(), router); + hash = _bigswitchBcfApi.createRouter(cmd.getTenantId(), router); - return new BcfAnswer(cmd, true, "router " + cmd.get_tenantId() + + return new BcfAnswer(cmd, true, "router " + cmd.getTenantId() + " created.", hash); } catch (BigSwitchBcfApiException e) { if (e.is_topologySyncRequested()) { - cmd.set_topologySyncRequested(true); + cmd.setTopologySyncRequested(true); return new BcfAnswer(cmd, true, " created; topology sync required."); } else { if (numRetries > 0) { @@ -478,18 +478,18 @@ public class BigSwitchBcfResource extends ManagerBase implements ServerResource } private Answer executeRequest(CreateBcfRouterInterfaceCommand cmd, int numRetries) { - RouterInterfaceData routerInterface = new RouterInterfaceData(cmd.get_tenantId(), - cmd.get_gateway(), cmd.get_cidr(), cmd.get_networkId(), cmd.get_networkName()); + RouterInterfaceData routerInterface = new RouterInterfaceData(cmd.getTenantId(), + cmd.getGateway(), cmd.getCidr(), cmd.getNetworkId(), cmd.getNetworkName()); try { String hash; - hash = _bigswitchBcfApi.createRouterInterface(cmd.get_tenantId(), - cmd.get_tenantId(), routerInterface); + hash = _bigswitchBcfApi.createRouterInterface(cmd.getTenantId(), + cmd.getTenantId(), routerInterface); - return new BcfAnswer(cmd, true, "router " + cmd.get_tenantId() + + return new BcfAnswer(cmd, true, "router " + cmd.getTenantId() + " created.", hash); } catch (BigSwitchBcfApiException e) { if (e.is_topologySyncRequested()) { - cmd.set_topologySyncRequested(true); + cmd.setTopologySyncRequested(true); return new BcfAnswer(cmd, true, " created; topology sync required."); } else { if (numRetries > 0) { @@ -515,7 +515,7 @@ public class BigSwitchBcfResource extends ManagerBase implements ServerResource return new BcfAnswer(cmd, true, "tenant " + cmd.getTenantId() + " router updated", hash); } catch (BigSwitchBcfApiException e) { if (e.is_topologySyncRequested()) { - cmd.set_topologySyncRequested(true); + cmd.setTopologySyncRequested(true); return new BcfAnswer(cmd, true, "tenant " + cmd.getTenantId() + " router updated but topology sync required."); } else { if (numRetries > 0) { diff --git a/plugins/network-elements/bigswitch/test/com/cloud/network/bigswitch/BigSwitchBcfUtilsTest.java b/plugins/network-elements/bigswitch/test/com/cloud/network/bigswitch/BigSwitchBcfUtilsTest.java new file mode 100644 index 00000000000..554eac9aa2a --- /dev/null +++ b/plugins/network-elements/bigswitch/test/com/cloud/network/bigswitch/BigSwitchBcfUtilsTest.java @@ -0,0 +1,93 @@ +// +// 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.network.bigswitch; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import com.cloud.agent.AgentManager; +import com.cloud.dc.dao.VlanDao; +import com.cloud.host.dao.HostDao; +import com.cloud.network.NetworkModel; +import com.cloud.network.dao.BigSwitchBcfDao; +import com.cloud.network.dao.FirewallRulesCidrsDao; +import com.cloud.network.dao.FirewallRulesDao; +import com.cloud.network.dao.IPAddressDao; +import com.cloud.network.dao.NetworkDao; +import com.cloud.network.vpc.NetworkACLItemCidrsDao; +import com.cloud.network.vpc.NetworkACLItemDao; +import com.cloud.network.vpc.dao.VpcDao; +import com.cloud.vm.dao.NicDao; +import com.cloud.vm.dao.VMInstanceDao; + +public class BigSwitchBcfUtilsTest { + + @Mock + NetworkDao networkDao; + @Mock + NicDao nicDao; + @Mock + VMInstanceDao vmDao; + @Mock + HostDao hostDao; + @Mock + VpcDao vpcDao; + @Mock + BigSwitchBcfDao bigswitchBcfDao; + @Mock + AgentManager agentMgr; + @Mock + VlanDao vlanDao; + @Mock + IPAddressDao ipAddressDao; + @Mock + FirewallRulesDao fwRulesDao; + @Mock + FirewallRulesCidrsDao fwCidrsDao; + @Mock + NetworkACLItemDao aclItemDao; + @Mock + NetworkACLItemCidrsDao aclItemCidrsDao; + @Mock + NetworkModel networkModel; + @Mock + BigSwitchBcfUtils bsUtil; + + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + bsUtil = new BigSwitchBcfUtils(networkDao, nicDao, vmDao, hostDao, + vpcDao, bigswitchBcfDao, agentMgr, vlanDao, ipAddressDao, + fwRulesDao, fwCidrsDao, aclItemDao, aclItemCidrsDao, + networkModel); + } + + @Test + public void getSubnetMaskLengthTest() { + Integer rc = bsUtil.getSubnetMaskLength("255.255.255.254"); + assertEquals("failed", new Integer(31), rc); + rc = bsUtil.getSubnetMaskLength("128.255.255.254"); + assertEquals("failed", new Integer(1), rc); + } +} diff --git a/plugins/pom.xml b/plugins/pom.xml index a547e1e5476..7368d20c5dd 100755 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -1,13 +1,22 @@ - + 4.0.0 diff --git a/pom.xml b/pom.xml index 7cf6735856b..175394c0ee0 100644 --- a/pom.xml +++ b/pom.xml @@ -843,6 +843,7 @@ tools/ngui/static/js/lib/* **/.checkstyle scripts/installer/windows/acs_license.rtf + **/*.md diff --git a/scripts/util/qemu-ivs-ifup b/scripts/util/qemu-ivs-ifup index 6830d23dda8..6c7b16fcedf 100755 --- a/scripts/util/qemu-ivs-ifup +++ b/scripts/util/qemu-ivs-ifup @@ -6,9 +6,9 @@ # 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 @@ -16,5 +16,5 @@ # specific language governing permissions and limitations # under the License. -/sbin/ifconfig $1 0.0.0.0 up -/usr/sbin/ivs-ctl add-port $1 +/sbin/ifconfig $1 0.0.0.0 up +/usr/sbin/ivs-ctl add-port $1 diff --git a/scripts/vm/hypervisor/kvm/kvmheartbeat.sh b/scripts/vm/hypervisor/kvm/kvmheartbeat.sh index ff6fd0ab6a0..7c8ee67f30c 100755 --- a/scripts/vm/hypervisor/kvm/kvmheartbeat.sh +++ b/scripts/vm/hypervisor/kvm/kvmheartbeat.sh @@ -156,7 +156,8 @@ then elif [ "$cflag" == "1" ] then /usr/bin/logger -t heartbeat "kvmheartbeat.sh rebooted system because it was unable to write the heartbeat to the storage." - sync + sync & + sleep 5 echo b > /proc/sysrq-trigger exit $? else diff --git a/server/src/com/cloud/api/dispatch/ParamGenericValidationWorker.java b/server/src/com/cloud/api/dispatch/ParamGenericValidationWorker.java index 7aaafbb55fc..6509d117012 100644 --- a/server/src/com/cloud/api/dispatch/ParamGenericValidationWorker.java +++ b/server/src/com/cloud/api/dispatch/ParamGenericValidationWorker.java @@ -90,7 +90,7 @@ public class ParamGenericValidationWorker implements DispatchWorker { break; } } - if (!matchedCurrentParam) { + if (!matchedCurrentParam && !((String)actualParamName).equalsIgnoreCase("expires") && !((String)actualParamName).equalsIgnoreCase("signatureversion")) { errorMsg.append(" ").append(actualParamName); foundUnknownParam= true; } diff --git a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java index e6c3f3a318d..7345c2a99f1 100644 --- a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java +++ b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java @@ -1215,7 +1215,7 @@ StateListener { // volume is ready and the pool should be reused. // In this case, also check if rest of the volumes are ready and can // be reused. - if (plan.getPoolId() != null) { + if (plan.getPoolId() != null || (toBeCreated.getVolumeType() == Volume.Type.DATADISK && toBeCreated.getPoolId() != null && toBeCreated.getState() == Volume.State.Ready)) { s_logger.debug("Volume has pool already allocated, checking if pool can be reused, poolId: " + toBeCreated.getPoolId()); List suitablePools = new ArrayList(); StoragePool pool = null; diff --git a/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java b/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java index f15889d1d38..1ecdfcdc17c 100644 --- a/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java +++ b/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java @@ -638,6 +638,9 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai _haDao.update(work.getId(), work); VMInstanceVO vm = _instanceDao.findById(vmId); + if (vm == null) { + return null; + } // First try starting the vm with its original planner, if it doesn't succeed send HAPlanner as its an emergency. _itMgr.migrateAway(vm.getUuid(), srcHostId); return null; @@ -757,7 +760,10 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai List works = _haDao.findTakenWorkItems(WorkType.Migration); List vms = new ArrayList(works.size()); for (HaWorkVO work : works) { - vms.add(_instanceDao.findById(work.getInstanceId())); + VMInstanceVO vm = _instanceDao.findById(work.getInstanceId()); + if (vm != null) { + vms.add(vm); + } } return vms; } @@ -917,6 +923,7 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai } else { s_logger.info("Rescheduling " + work + " to try again at " + new Date(nextTime << 10)); work.setTimeToTry(nextTime); + work.setTimesTried(work.getTimesTried() + 1); work.setServerId(null); work.setDateTaken(null); } @@ -927,6 +934,7 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai s_logger.info("Rescheduling " + work + " to try again at " + new Date(nextTime << 10)); work.setTimeToTry(nextTime); + work.setTimesTried(work.getTimesTried() + 1); work.setServerId(null); work.setDateTaken(null); @@ -935,6 +943,10 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai VMInstanceVO vm = _instanceDao.findById(work.getInstanceId()); work.setUpdateTime(vm.getUpdated()); work.setPreviousState(vm.getState()); + if (!Step.Done.equals(work.getStep()) && work.getTimesTried() >= _maxRetries) { + s_logger.warn("Giving up, retries max times for work: " + work); + work.setStep(Step.Done); + } } _haDao.update(work.getId(), work); } catch (final Throwable th) { diff --git a/server/src/com/cloud/server/ConfigurationServerImpl.java b/server/src/com/cloud/server/ConfigurationServerImpl.java index e839fc76ffe..157ea03d04e 100644 --- a/server/src/com/cloud/server/ConfigurationServerImpl.java +++ b/server/src/com/cloud/server/ConfigurationServerImpl.java @@ -473,7 +473,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio PreparedStatement stmt = txn.prepareAutoCloseStatement(insertSql); stmt.executeUpdate(); } catch (SQLException ex) { - s_logger.debug("Caught exception when inserting system account: " + ex.getMessage()); + s_logger.debug("Looks like system account already exists"); } // insert system user insertSql = "INSERT INTO `cloud`.`user` (id, uuid, username, password, account_id, firstname, lastname, created, user.default)" @@ -483,7 +483,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio PreparedStatement stmt = txn.prepareAutoCloseStatement(insertSql); stmt.executeUpdate(); } catch (SQLException ex) { - s_logger.debug("Caught SQLException when inserting system user: " + ex.getMessage()); + s_logger.debug("Looks like system user already exists"); } // insert admin user, but leave the account disabled until we set a @@ -500,7 +500,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio PreparedStatement stmt = txn.prepareAutoCloseStatement(insertSql); stmt.executeUpdate(); } catch (SQLException ex) { - s_logger.debug("Caught SQLException when creating admin account: " + ex.getMessage()); + s_logger.debug("Looks like admin account already exists"); } // now insert the user @@ -511,7 +511,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio PreparedStatement stmt = txn.prepareAutoCloseStatement(insertSql); stmt.executeUpdate(); } catch (SQLException ex) { - s_logger.debug("Caught SQLException when inserting admin user: " + ex.getMessage()); + s_logger.debug("Looks like admin user already exists"); } try { @@ -522,8 +522,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio stmt.executeQuery(); tableName = "network_group"; } catch (Exception ex) { - // if network_groups table exists, create the default security group there - s_logger.debug("Caught (SQL?)Exception: no network_group " + ex.getLocalizedMessage()); + // Ignore in case of exception, table must not exist } insertSql = "SELECT * FROM " + tableName + " where account_id=2 and name='default'"; diff --git a/server/src/com/cloud/server/StatsCollector.java b/server/src/com/cloud/server/StatsCollector.java index 60c25f0aad5..9f3c8cb89ab 100644 --- a/server/src/com/cloud/server/StatsCollector.java +++ b/server/src/com/cloud/server/StatsCollector.java @@ -212,6 +212,7 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc long autoScaleStatsInterval = -1L; int vmDiskStatsInterval = 0; List hostIds = null; + private double _imageStoreCapacityThreshold = 0.90; String externalStatsPrefix = ""; String externalStatsHost = null; @@ -1045,6 +1046,14 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc } } + public boolean imageStoreHasEnoughCapacity(DataStore imageStore) { + StorageStats imageStoreStats = _storageStats.get(imageStore.getId()); + if (imageStoreStats != null && (imageStoreStats.getByteUsed()/(imageStoreStats.getCapacityBytes()*1.0)) <= _imageStoreCapacityThreshold) { + return true; + } + return false; + } + public StorageStats getStorageStats(long id) { return _storageStats.get(id); } diff --git a/server/src/com/cloud/servlet/ConsoleProxyPasswordBasedEncryptor.java b/server/src/com/cloud/servlet/ConsoleProxyPasswordBasedEncryptor.java index b64bb019405..9d874e0844a 100644 --- a/server/src/com/cloud/servlet/ConsoleProxyPasswordBasedEncryptor.java +++ b/server/src/com/cloud/servlet/ConsoleProxyPasswordBasedEncryptor.java @@ -19,7 +19,6 @@ package com.cloud.servlet; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; @@ -159,33 +158,4 @@ public class ConsoleProxyPasswordBasedEncryptor { } } - public static void main(String[] args) { - SecureRandom random; - try { - random = SecureRandom.getInstance("SHA1PRNG"); - byte[] keyBytes = new byte[16]; - random.nextBytes(keyBytes); - - byte[] ivBytes = new byte[16]; - random.nextBytes(ivBytes); - - KeyIVPair keyIvPair = new KeyIVPair("8x/xUBgX0Up+3UEo39dSeG277JhVj31+ElHkN5+EC0Q=", "Y2SUiIN6JXTdKNK/ZMDyVtLB7gAM9MCCiyrP1xd3bSQ="); - //keyIvPair.setKeyBytes(keyBytes); - //keyIvPair.setIvBytes(ivBytes); - - Gson gson = new GsonBuilder().create(); - ConsoleProxyPasswordBasedEncryptor encryptor = new ConsoleProxyPasswordBasedEncryptor(gson.toJson(keyIvPair)); - - String encrypted = encryptor.encryptText("Hello, world"); - - System.out.println("Encrypted result: " + encrypted); - - String decrypted = encryptor.decryptText(encrypted); - - System.out.println("Decrypted result: " + decrypted); - - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - } - } } diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index d72cc691807..2a4659201c7 100644 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -41,6 +41,7 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; +import com.cloud.hypervisor.Hypervisor; import org.apache.log4j.Logger; import org.springframework.stereotype.Component; @@ -545,7 +546,11 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C } DataStore store; try { - StoragePoolVO pool = _storagePoolDao.findPoolByHostPath(host.getDataCenterId(), host.getPodId(), pInfo.getHost(), pInfo.getHostPath(), pInfo.getUuid()); + String hostAddress = pInfo.getHost(); + if (host.getHypervisorType() == Hypervisor.HypervisorType.VMware) { + hostAddress = "VMFS datastore: " + pInfo.getHostPath(); + } + StoragePoolVO pool = _storagePoolDao.findPoolByHostPath(host.getDataCenterId(), host.getPodId(), hostAddress, pInfo.getHostPath(), pInfo.getUuid()); if (pool == null && host.getHypervisorType() == HypervisorType.VMware) { // perform run-time upgrade. In versions prior to 2.2.12, there // is a bug that we don't save local datastore info (host path @@ -554,12 +559,12 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C // available on the host, to support smooth migration, we // need to perform runtime upgrade here if (pInfo.getHostPath().length() > 0) { - pool = _storagePoolDao.findPoolByHostPath(host.getDataCenterId(), host.getPodId(), pInfo.getHost(), "", pInfo.getUuid()); + pool = _storagePoolDao.findPoolByHostPath(host.getDataCenterId(), host.getPodId(), hostAddress, "", pInfo.getUuid()); } } if (pool == null) { //the path can be different, but if they have the same uuid, assume they are the same storage - pool = _storagePoolDao.findPoolByHostPath(host.getDataCenterId(), host.getPodId(), pInfo.getHost(), null, + pool = _storagePoolDao.findPoolByHostPath(host.getDataCenterId(), host.getPodId(), hostAddress, null, pInfo.getUuid()); if (pool != null) { s_logger.debug("Found a storage pool: " + pInfo.getUuid() + ", but with different hostpath " + pInfo.getHostPath() + ", still treat it as the same pool"); @@ -1600,7 +1605,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C } long totalOverProvCapacity; - if (pool.getPoolType() == StoragePoolType.NetworkFilesystem || pool.getPoolType() == StoragePoolType.VMFS) { + if (pool.getPoolType() == StoragePoolType.NetworkFilesystem || pool.getPoolType() == StoragePoolType.VMFS || pool.getPoolType() == StoragePoolType.Filesystem) { BigDecimal overProvFactor = getStorageOverProvisioningFactor(pool.getId()); totalOverProvCapacity = overProvFactor.multiply(new BigDecimal(pool.getCapacityBytes())).longValue(); s_logger.debug("Found storage pool " + poolVO.getName() + " of type " + pool.getPoolType().toString() + " with overprovisioning factor " diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java index cae1e1d1ac1..dbae1946a36 100644 --- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java @@ -1650,12 +1650,12 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic } HostVO host = null; - StoragePoolVO volumePool = _storagePoolDao.findById(volume.getPoolId()); + StoragePoolVO volumePool = _storagePoolDao.findByIdIncludingRemoved(volume.getPoolId()); if (hostId != null) { host = _hostDao.findById(hostId); - if (host != null && host.getHypervisorType() == HypervisorType.XenServer && volumePool.isManaged()) { + if (host != null && host.getHypervisorType() == HypervisorType.XenServer && volumePool != null && volumePool.isManaged()) { sendCommand = true; } } diff --git a/server/src/com/cloud/template/HypervisorTemplateAdapter.java b/server/src/com/cloud/template/HypervisorTemplateAdapter.java index 42f4b554cae..e58edb9efb3 100644 --- a/server/src/com/cloud/template/HypervisorTemplateAdapter.java +++ b/server/src/com/cloud/template/HypervisorTemplateAdapter.java @@ -60,6 +60,7 @@ import com.cloud.event.UsageEventUtils; import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.ResourceAllocationException; import com.cloud.org.Grouping; +import com.cloud.server.StatsCollector; import com.cloud.storage.ScopeType; import com.cloud.storage.Storage.ImageFormat; import com.cloud.storage.Storage.TemplateType; @@ -83,8 +84,10 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase { DownloadMonitor _downloadMonitor; @Inject AgentManager _agentMgr; - - @Inject TemplateDataStoreDao templateDataStoreDao; + @Inject + StatsCollector _statsCollector; + @Inject + TemplateDataStoreDao templateDataStoreDao; @Inject DataStoreManager storeMgr; @Inject @@ -164,13 +167,17 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase { continue; } + // Check if image store has enough capacity for template + if (!_statsCollector.imageStoreHasEnoughCapacity(imageStore)) { + s_logger.info("Image store doesn't has enough capacity, so skip downloading template to this image store " + imageStore.getId()); + continue; + } // We want to download private template to one of the image store in a zone if(isPrivateTemplate(template) && zoneSet.contains(zoneId)){ continue; }else { zoneSet.add(zoneId); } - } TemplateInfo tmpl = imageFactory.getTemplate(template.getId(), imageStore); diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 46275bea5b3..38ca3903ac5 100644 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -1016,6 +1016,9 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir NicProfile profile = new NicProfile(null, null); if (ipAddress != null) { + if (!(NetUtils.isValidIp(ipAddress) || NetUtils.isValidIpv6(ipAddress))) { + throw new InvalidParameterValueException("Invalid format for IP address parameter: " + ipAddress); + } profile = new NicProfile(ipAddress, null); } @@ -2892,6 +2895,19 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir } profile.setDefaultNic(true); + if (!_networkModel.areServicesSupportedInNetwork(network.getId(), new Service[]{Service.UserData})) { + if ((userData != null) && (!userData.isEmpty())) { + throw new InvalidParameterValueException("Unable to deploy VM as UserData is provided while deploying the VM, but there is no support for " + Network.Service.UserData.getName() + " service in the default network " + network.getId()); + } + + if ((sshPublicKey != null) && (!sshPublicKey.isEmpty())) { + throw new InvalidParameterValueException("Unable to deploy VM as SSH keypair is provided while deploying the VM, but there is no support for " + Network.Service.UserData.getName() + " service in the default network " + network.getId()); + } + + if (template.getEnablePassword()) { + throw new InvalidParameterValueException("Unable to deploy VM as template " + template.getId() + " is password enabled, but there is no support for " + Network.Service.UserData.getName() + " service in the default network " + network.getId()); + } + } } networks.add(new Pair(network, profile)); diff --git a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyPasswordBasedEncryptor.java b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyPasswordBasedEncryptor.java index 4ec2a726b5c..c623aff1aa2 100644 --- a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyPasswordBasedEncryptor.java +++ b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyPasswordBasedEncryptor.java @@ -19,7 +19,6 @@ package com.cloud.consoleproxy; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; @@ -165,33 +164,4 @@ public class ConsoleProxyPasswordBasedEncryptor { } } - public static void main(String[] args) { - SecureRandom random; - try { - random = SecureRandom.getInstance("SHA1PRNG"); - byte[] keyBytes = new byte[16]; - random.nextBytes(keyBytes); - - byte[] ivBytes = new byte[16]; - random.nextBytes(ivBytes); - - KeyIVPair keyIvPair = new KeyIVPair("8x/xUBgX0Up+3UEo39dSeG277JhVj31+ElHkN5+EC0Q=", "Y2SUiIN6JXTdKNK/ZMDyVtLB7gAM9MCCiyrP1xd3bSQ="); - //keyIvPair.setKeyBytes(keyBytes); - //keyIvPair.setIvBytes(ivBytes); - - Gson gson = new GsonBuilder().create(); - ConsoleProxyPasswordBasedEncryptor encryptor = new ConsoleProxyPasswordBasedEncryptor(gson.toJson(keyIvPair)); - - String encrypted = encryptor.encryptText("Hello, world"); - - System.out.println("Encrypted result: " + encrypted); - - String decrypted = encryptor.decryptText(encrypted); - - System.out.println("Decrypted result: " + decrypted); - - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - } - } } diff --git a/setup/db/db/schema-442to450.sql b/setup/db/db/schema-442to450.sql index 4a8f2507d7e..774eee50621 100644 --- a/setup/db/db/schema-442to450.sql +++ b/setup/db/db/schema-442to450.sql @@ -37,6 +37,7 @@ ALTER TABLE `cloud`.`volumes` ADD COLUMN `provisioning_type` VARCHAR(32) NOT NUL ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `provisioning_type` VARCHAR(32) NOT NULL DEFAULT 'thin' COMMENT 'pre allocation setting of the volume'; -- Have primary keys of following table AUTO_INCREMENT +SET foreign_key_checks = 0; ALTER TABLE `cloud`.`region` MODIFY `id` int unsigned AUTO_INCREMENT UNIQUE NOT NULL; ALTER TABLE `cloud`.`vm_instance` MODIFY `id` bigint unsigned AUTO_INCREMENT UNIQUE NOT NULL; ALTER TABLE `cloud`.`user_vm` MODIFY `id` bigint unsigned AUTO_INCREMENT UNIQUE NOT NULL; @@ -44,6 +45,7 @@ ALTER TABLE `cloud`.`domain_router` MODIFY `id` bigint unsigned AUTO_INCREMENT U ALTER TABLE `cloud`.`service_offering` MODIFY `id` bigint unsigned AUTO_INCREMENT NOT NULL; ALTER TABLE `cloud`.`load_balancing_rules` MODIFY `id` bigint unsigned AUTO_INCREMENT NOT NULL; ALTER TABLE `cloud`.`port_forwarding_rules` MODIFY `id` bigint unsigned AUTO_INCREMENT NOT NULL; +SET foreign_key_checks = 1; DROP VIEW IF EXISTS `cloud`.`disk_offering_view`; CREATE VIEW `cloud`.`disk_offering_view` AS diff --git a/setup/dev/advanced.cfg b/setup/dev/advanced.cfg index 18dee31636b..53a8221b834 100644 --- a/setup/dev/advanced.cfg +++ b/setup/dev/advanced.cfg @@ -55,6 +55,12 @@ ] } ], + "vmwaredc": { + "username": "", + "vcenter": "", + "password": "", + "name": "" + }, "ipranges": [ { "startip": "192.168.2.2", diff --git a/systemvm/patches/debian/config/etc/logrotate.d/apache2 b/systemvm/patches/debian/config/etc/logrotate.d/apache2 index 14c9675672d..3932c274825 100644 --- a/systemvm/patches/debian/config/etc/logrotate.d/apache2 +++ b/systemvm/patches/debian/config/etc/logrotate.d/apache2 @@ -4,6 +4,6 @@ rotate 3 compress dateext - size=+10M + size 10M notifempty } diff --git a/systemvm/patches/debian/config/etc/logrotate.d/cloud b/systemvm/patches/debian/config/etc/logrotate.d/cloud index 5d95942f6a7..82801f1c924 100644 --- a/systemvm/patches/debian/config/etc/logrotate.d/cloud +++ b/systemvm/patches/debian/config/etc/logrotate.d/cloud @@ -17,6 +17,7 @@ /var/log/cloud.log { rotate 4 daily + size 10M missingok notifempty compress diff --git a/systemvm/patches/debian/config/etc/logrotate.d/conntrackd b/systemvm/patches/debian/config/etc/logrotate.d/conntrackd index 8139191e27f..0229cd7e8c5 100644 --- a/systemvm/patches/debian/config/etc/logrotate.d/conntrackd +++ b/systemvm/patches/debian/config/etc/logrotate.d/conntrackd @@ -1,5 +1,6 @@ /var/log/conntrackd-stats.log { daily + size 10M rotate 2 missingok compress diff --git a/systemvm/patches/debian/config/etc/logrotate.d/dnsmasq b/systemvm/patches/debian/config/etc/logrotate.d/dnsmasq index 265459077f1..2f917855190 100644 --- a/systemvm/patches/debian/config/etc/logrotate.d/dnsmasq +++ b/systemvm/patches/debian/config/etc/logrotate.d/dnsmasq @@ -1,5 +1,6 @@ /var/log/dnsmasq.log { daily + size 10M missingok rotate 5 notifempty diff --git a/systemvm/patches/debian/config/etc/logrotate.d/ppp b/systemvm/patches/debian/config/etc/logrotate.d/ppp index 7181bc3f934..2004e77ff0f 100644 --- a/systemvm/patches/debian/config/etc/logrotate.d/ppp +++ b/systemvm/patches/debian/config/etc/logrotate.d/ppp @@ -1,5 +1,6 @@ /var/log/ppp-connect-errors { daily + size 10M rotate 5 missingok notifempty diff --git a/systemvm/patches/debian/config/etc/rc.local b/systemvm/patches/debian/config/etc/rc.local index 23e913e40b5..18e7cd1d43b 100755 --- a/systemvm/patches/debian/config/etc/rc.local +++ b/systemvm/patches/debian/config/etc/rc.local @@ -46,3 +46,16 @@ python /opt/cloud/bin/baremetal-vr.py & date > /var/cache/cloud/boot_up_done logger -t cloud "Boot up process done" + +#Restore the persistent iptables nat, rules and filters for IPv4 and IPv6 if they exist +ipv4="/etc/iptables/router_rules.v4" +if [ -e $ipv4 ] +then + iptables-restore < $ipv4 +fi + +ipv6="/etc/iptables/router_rules.v6" +if [ -e $ipv6 ] +then + iptables-restore < $ipv6 +fi \ No newline at end of file diff --git a/systemvm/patches/debian/config/opt/cloud/bin/configure.py b/systemvm/patches/debian/config/opt/cloud/bin/configure.py index b03928bc000..799e279a2cf 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/configure.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/configure.py @@ -676,6 +676,10 @@ def main(argv): mon = CsMonitor("monitorservice", config) mon.process() - + + #Save iptables configuration - will be loaded on reboot by the iptables-restore that is configured on /etc/rc.local + CsHelper.save_iptables("iptables-save", "/etc/iptables/router_rules.v4") + CsHelper.save_iptables("ip6tables-save", "/etc/iptables/router_rules.v6") + if __name__ == "__main__": main(sys.argv) diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsHelper.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsHelper.py index f01bb8cce68..708422c6e1e 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsHelper.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsHelper.py @@ -16,7 +16,7 @@ # specific language governing permissions and limitations # under the License. """ General helper functions -for use in the configuation process +for use in the configuration process """ import subprocess @@ -27,7 +27,6 @@ import shutil from netaddr import * from pprint import pprint - def is_mounted(name): for i in execute("mount"): vals = i.lstrip().split() @@ -163,6 +162,19 @@ def execute(command): return result.splitlines() +def save_iptables(command, iptables_file): + """ Execute command """ + logging.debug("Saving iptables for %s" % command) + + result = execute(command) + fIptables = open(iptables_file, "w+") + + for line in result: + fIptables.write(line) + fIptables.write("\n") + fIptables.close() + + def execute2(command): """ Execute command """ logging.debug("Executing %s" % command) diff --git a/test/integration/component/test_VirtualRouter_alerts.py b/test/integration/component/test_VirtualRouter_alerts.py index 5a3bbf09408..bb3b12959be 100644 --- a/test/integration/component/test_VirtualRouter_alerts.py +++ b/test/integration/component/test_VirtualRouter_alerts.py @@ -187,23 +187,24 @@ class TestVRServiceFailureAlerting(cloudstackTestCase): self.debug("apache process status: %s" % res) configs = Configurations.list( - self.apiclient, - name='router.alerts.check.interval' - ) + self.apiclient, + name='router.alerts.check.interval' + ) # Set the value for one more minute than # actual range to be on safer side waitingPeriod = ( - int(configs[0].value) + 600) # in seconds + int(configs[0].value) + 60) # in seconds time.sleep(waitingPeriod) - # wait for (router.alerts.check.interval + 10) minutes meanwhile monitor service on - # VR starts the apache service ( + # wait for (router.alerts.check.interval + 10) minutes meanwhile + # monitor service on VR starts the apache service ( # router.alerts.check.interval default value is # 30minutes) qresultset = self.dbclient.execute( - "select id from alert where subject = '%s' ORDER BY id DESC LIMIT 1;" % + "select id from alert where subject \ + = '%s' ORDER BY id DESC LIMIT 1;" % str(alertSubject)) self.assertNotEqual( len(qresultset), diff --git a/test/integration/component/test_accounts.py b/test/integration/component/test_accounts.py index cf4b0e3d0a9..e08ed912c41 100644 --- a/test/integration/component/test_accounts.py +++ b/test/integration/component/test_accounts.py @@ -5,9 +5,9 @@ # 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 @@ -16,9 +16,8 @@ # under the License. """ P1 tests for Account """ -#Import Local Modules +# Import Local Modules from marvin.cloudstackTestCase import cloudstackTestCase -#from marvin.cloudstackAPI import * from marvin.lib.utils import (random_gen, cleanup_resources) from marvin.lib.base import (Domain, @@ -44,76 +43,78 @@ from nose.plugins.attrib import attr from marvin.cloudstackException import CloudstackAPIException import time + class Services: + """Test Account Services """ def __init__(self): self.services = { - "domain": { - "name": "Domain", - }, - "account": { - "email": "test@test.com", - "firstname": "Test", - "lastname": "User", - "username": "test", - # Random characters are appended for unique - # username - "password": "fr3sca", - }, - "user": { - "email": "user@test.com", - "firstname": "User", - "lastname": "User", - "username": "User", - # Random characters are appended for unique - # username - "password": "fr3sca", - }, - "service_offering": { - "name": "Tiny Instance", - "displaytext": "Tiny Instance", - "cpunumber": 1, - "cpuspeed": 100, - # in MHz - "memory": 128, - # In MBs - }, - "virtual_machine": { - "displayname": "Test VM", - "username": "root", - "password": "password", - "ssh_port": 22, - "hypervisor": 'XenServer', - # Hypervisor type should be same as - # hypervisor type of cluster - "privateport": 22, - "publicport": 22, - "protocol": 'TCP', - }, - "template": { - "displaytext": "Public Template", - "name": "Public template", - "ostype": 'CentOS 5.3 (64-bit)', - "url": "", - "hypervisor": '', - "format": '', - "isfeatured": True, - "ispublic": True, - "isextractable": True, - "templatefilter": "self" - }, - "natrule": { - "publicport": 22, - "privateport": 22, - "protocol": 'TCP', - }, - "ostype": 'CentOS 5.3 (64-bit)', - # Cent OS 5.3 (64 bit) - "sleep": 60, - "timeout": 10, - } + "domain": { + "name": "Domain", + }, + "account": { + "email": "test@test.com", + "firstname": "Test", + "lastname": "User", + "username": "test", + # Random characters are appended for unique + # username + "password": "fr3sca", + }, + "user": { + "email": "user@test.com", + "firstname": "User", + "lastname": "User", + "username": "User", + # Random characters are appended for unique + # username + "password": "fr3sca", + }, + "service_offering": { + "name": "Tiny Instance", + "displaytext": "Tiny Instance", + "cpunumber": 1, + "cpuspeed": 100, + # in MHz + "memory": 128, + # In MBs + }, + "virtual_machine": { + "displayname": "Test VM", + "username": "root", + "password": "password", + "ssh_port": 22, + "hypervisor": 'XenServer', + # Hypervisor type should be same as + # hypervisor type of cluster + "privateport": 22, + "publicport": 22, + "protocol": 'TCP', + }, + "template": { + "displaytext": "Public Template", + "name": "Public template", + "ostype": 'CentOS 5.3 (64-bit)', + "url": "", + "hypervisor": '', + "format": '', + "isfeatured": True, + "ispublic": True, + "isextractable": True, + "templatefilter": "self" + }, + "natrule": { + "publicport": 22, + "privateport": 22, + "protocol": 'TCP', + }, + "ostype": 'CentOS 5.3 (64-bit)', + # Cent OS 5.3 (64 bit) + "sleep": 60, + "timeout": 10, + } class TestAccounts(cloudstackTestCase): @@ -127,24 +128,24 @@ class TestAccounts(cloudstackTestCase): cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype cls.template = get_template( - cls.api_client, - cls.zone.id, - cls.services["ostype"] - ) + cls.api_client, + cls.zone.id, + cls.services["ostype"] + ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.service_offering = ServiceOffering.create( - cls.api_client, - cls.services["service_offering"] - ) + cls.api_client, + cls.services["service_offering"] + ) cls._cleanup = [cls.service_offering] return @classmethod def tearDownClass(cls): try: - #Cleanup resources used + # Cleanup resources used cleanup_resources(cls.api_client, cls._cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) @@ -158,13 +159,20 @@ class TestAccounts(cloudstackTestCase): def tearDown(self): try: - #Clean up, terminate the created accounts, domains etc + # Clean up, terminate the created accounts, domains etc cleanup_resources(self.apiclient, self.cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return - @attr(tags=["advanced", "basic", "eip", "advancedns", "sg"], required_hardware="false") + @attr( + tags=[ + "advanced", + "basic", + "eip", + "advancedns", + "sg"], + required_hardware="false") def test_01_create_account(self): """Test Create Account and user for that account """ @@ -175,72 +183,72 @@ class TestAccounts(cloudstackTestCase): # Create an account account = Account.create( - self.apiclient, - self.services["account"] - ) + self.apiclient, + self.services["account"] + ) self.debug("Created account: %s" % account.name) self.cleanup.append(account) list_accounts_response = list_accounts( - self.apiclient, - id=account.id - ) + self.apiclient, + id=account.id + ) self.assertEqual( - isinstance(list_accounts_response, list), - True, - "Check list accounts for valid data" - ) + isinstance(list_accounts_response, list), + True, + "Check list accounts for valid data" + ) self.assertNotEqual( - len(list_accounts_response), - 0, - "Check List Account response" - ) + len(list_accounts_response), + 0, + "Check List Account response" + ) account_response = list_accounts_response[0] self.assertEqual( - account.accounttype, - account_response.accounttype, - "Check Account Type of Created account" - ) + account.accounttype, + account_response.accounttype, + "Check Account Type of Created account" + ) self.assertEqual( - account.name, - account_response.name, - "Check Account Name of Created account" - ) + account.name, + account_response.name, + "Check Account Name of Created account" + ) # Create an User associated with account user = User.create( - self.apiclient, - self.services["user"], - account=account.name, - domainid=account.domainid - ) + self.apiclient, + self.services["user"], + account=account.name, + domainid=account.domainid + ) self.debug("Created user: %s" % user.id) list_users_response = list_users( - self.apiclient, - id=user.id - ) + self.apiclient, + id=user.id + ) self.assertEqual( - isinstance(list_users_response, list), - True, - "Check list users for valid data" - ) + isinstance(list_users_response, list), + True, + "Check list users for valid data" + ) self.assertNotEqual( - len(list_users_response), - 0, - "Check List User response" - ) + len(list_users_response), + 0, + "Check List User response" + ) user_response = list_users_response[0] self.assertEqual( - user.username, - user_response.username, - "Check username of Created user" - ) + user.username, + user_response.username, + "Check username of Created user" + ) self.assertEqual( - user.state, - user_response.state, - "Check state of created user" - ) + user.state, + user_response.state, + "Check state of created user" + ) return @@ -248,39 +256,41 @@ class TestRemoveUserFromAccount(cloudstackTestCase): @classmethod def setUpClass(cls): - cls.testClient = super(TestRemoveUserFromAccount, cls).getClsTestClient() + cls.testClient = super( + TestRemoveUserFromAccount, + cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype cls.template = get_template( - cls.api_client, - cls.zone.id, - cls.services["ostype"] - ) + cls.api_client, + cls.zone.id, + cls.services["ostype"] + ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.service_offering = ServiceOffering.create( - cls.api_client, - cls.services["service_offering"] - ) + cls.api_client, + cls.services["service_offering"] + ) # Create an account cls.account = Account.create( - cls.api_client, - cls.services["account"] - ) + cls.api_client, + cls.services["account"] + ) - cls._cleanup = [cls.account, - cls.service_offering, + cls._cleanup = [cls.account, + cls.service_offering, ] return @classmethod def tearDownClass(cls): try: - #Cleanup resources used + # Cleanup resources used cleanup_resources(cls.api_client, cls._cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) @@ -294,13 +304,20 @@ class TestRemoveUserFromAccount(cloudstackTestCase): def tearDown(self): try: - #Clean up, terminate the created instance, users etc + # Clean up, terminate the created instance, users etc cleanup_resources(self.apiclient, self.cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return - @attr(tags=["advanced", "basic", "eip", "advancedns", "sg"], required_hardware="false") + @attr( + tags=[ + "advanced", + "basic", + "eip", + "advancedns", + "sg"], + required_hardware="false") def test_01_user_remove_VM_running(self): """Test Remove one user from the account """ @@ -308,51 +325,52 @@ class TestRemoveUserFromAccount(cloudstackTestCase): # Validate the following # 1. Create an account with 2 users. # 2. Start 2 VMs; one for each user of the account - # 3. Remove one user from the account. Verify that account still exists. + # 3. Remove one user from the account. Verify that account + # still exists. # 4. Verify that VM started by the removed user are still running # Create an User associated with account and VMs user_1 = User.create( - self.apiclient, - self.services["user"], - account=self.account.name, - domainid=self.account.domainid - ) + self.apiclient, + self.services["user"], + account=self.account.name, + domainid=self.account.domainid + ) self.debug("Created user: %s" % user_1.id) user_2 = User.create( - self.apiclient, - self.services["user"], - account=self.account.name, - domainid=self.account.domainid - ) + self.apiclient, + self.services["user"], + account=self.account.name, + domainid=self.account.domainid + ) self.debug("Created user: %s" % user_2.id) self.cleanup.append(user_2) vm_1 = VirtualMachine.create( - self.apiclient, - self.services["virtual_machine"], - accountid=self.account.name, - domainid=self.account.domainid, - serviceofferingid=self.service_offering.id - ) + self.apiclient, + self.services["virtual_machine"], + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.service_offering.id + ) self.debug("Deployed VM in account: %s, ID: %s" % ( - self.account.name, - vm_1.id - )) + self.account.name, + vm_1.id + )) self.cleanup.append(vm_1) vm_2 = VirtualMachine.create( - self.apiclient, - self.services["virtual_machine"], - accountid=self.account.name, - domainid=self.account.domainid, - serviceofferingid=self.service_offering.id - ) + self.apiclient, + self.services["virtual_machine"], + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.service_offering.id + ) self.debug("Deployed VM in account: %s, ID: %s" % ( - self.account.name, - vm_2.id - )) + self.account.name, + vm_2.id + )) self.cleanup.append(vm_2) # Remove one of the user @@ -361,44 +379,44 @@ class TestRemoveUserFromAccount(cloudstackTestCase): # Account should exist after deleting user accounts_response = list_accounts( - self.apiclient, - id=self.account.id - ) + self.apiclient, + id=self.account.id + ) self.assertEqual( - isinstance(accounts_response, list), - True, - "Check for valid list accounts response" - ) + isinstance(accounts_response, list), + True, + "Check for valid list accounts response" + ) self.assertNotEqual( - len(accounts_response), - 0, - "Check List Account response" - ) + len(accounts_response), + 0, + "Check List Account response" + ) vm_response = list_virtual_machines( - self.apiclient, - account=self.account.name, - domainid=self.account.domainid - ) + self.apiclient, + account=self.account.name, + domainid=self.account.domainid + ) self.assertEqual( - isinstance(vm_response, list), - True, - "Check for valid list VM response" - ) + isinstance(vm_response, list), + True, + "Check for valid list VM response" + ) self.assertNotEqual( - len(vm_response), - 0, - "Check List VM response" - ) + len(vm_response), + 0, + "Check List VM response" + ) # VMs associated with that account should be running for vm in vm_response: self.assertEqual( - vm.state, - 'Running', - "Check state of VMs associated with account" - ) + vm.state, + 'Running', + "Check state of VMs associated with account" + ) return @@ -406,7 +424,9 @@ class TestNonRootAdminsPrivileges(cloudstackTestCase): @classmethod def setUpClass(cls): - cls.testClient = super(TestNonRootAdminsPrivileges, cls).getClsTestClient() + cls.testClient = super( + TestNonRootAdminsPrivileges, + cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services @@ -414,25 +434,25 @@ class TestNonRootAdminsPrivileges(cloudstackTestCase): cls.services['mode'] = cls.zone.networktype # Create an account, domain etc cls.domain = Domain.create( - cls.api_client, - cls.services["domain"], - ) + cls.api_client, + cls.services["domain"], + ) cls.account = Account.create( - cls.api_client, - cls.services["account"], - admin=True, - domainid=cls.domain.id - ) + cls.api_client, + cls.services["account"], + admin=True, + domainid=cls.domain.id + ) cls._cleanup = [ - cls.account, - cls.domain - ] + cls.account, + cls.domain + ] return @classmethod def tearDownClass(cls): try: - #Cleanup resources used + # Cleanup resources used cleanup_resources(cls.api_client, cls._cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) @@ -446,13 +466,20 @@ class TestNonRootAdminsPrivileges(cloudstackTestCase): def tearDown(self): try: - #Clean up, terminate the created accounts + # Clean up, terminate the created accounts cleanup_resources(self.apiclient, self.cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return - @attr(tags=["advanced", "basic", "eip", "advancedns", "sg"], required_hardware="false") + @attr( + tags=[ + "advanced", + "basic", + "eip", + "advancedns", + "sg"], + required_hardware="false") def test_01_non_root_admin_Privileges(self): """Test to verify Non Root admin previleges""" @@ -463,42 +490,42 @@ class TestNonRootAdminsPrivileges(cloudstackTestCase): # Create accounts for ROOT domain account_1 = Account.create( - self.apiclient, - self.services["account"] - ) + self.apiclient, + self.services["account"] + ) self.debug("Created account: %s" % account_1.name) self.cleanup.append(account_1) account_2 = Account.create( - self.apiclient, - self.services["account"] - ) + self.apiclient, + self.services["account"] + ) self.debug("Created account: %s" % account_2.name) self.cleanup.append(account_2) accounts_response = list_accounts( - self.apiclient, - domainid=self.domain.id, - listall=True - ) + self.apiclient, + domainid=self.domain.id, + listall=True + ) self.assertEqual( - isinstance(accounts_response, list), - True, - "Check list accounts response for valid data" - ) + isinstance(accounts_response, list), + True, + "Check list accounts response for valid data" + ) self.assertEqual( - len(accounts_response), - 1, - "Check List accounts response" - ) + len(accounts_response), + 1, + "Check List accounts response" + ) # Verify only account associated with domain is listed for account in accounts_response: self.assertEqual( - account.domainid, - self.domain.id, - "Check domain ID of account" - ) + account.domainid, + self.domain.id, + "Check domain ID of account" + ) return @@ -507,54 +534,54 @@ class TestServiceOfferingSiblings(cloudstackTestCase): @classmethod def setUpClass(cls): cls.api_client = super( - TestServiceOfferingSiblings, - cls - ).getClsTestClient().getApiClient() + TestServiceOfferingSiblings, + cls + ).getClsTestClient().getApiClient() cls.services = Services().services # Create Domains, accounts etc cls.domain_1 = Domain.create( - cls.api_client, - cls.services["domain"] - ) + cls.api_client, + cls.services["domain"] + ) cls.domain_2 = Domain.create( - cls.api_client, - cls.services["domain"] - ) + cls.api_client, + cls.services["domain"] + ) cls.service_offering = ServiceOffering.create( - cls.api_client, - cls.services["service_offering"], - domainid=cls.domain_1.id - ) + cls.api_client, + cls.services["service_offering"], + domainid=cls.domain_1.id + ) # Create account for doamin_1 cls.account_1 = Account.create( - cls.api_client, - cls.services["account"], - admin=True, - domainid=cls.domain_1.id - ) + cls.api_client, + cls.services["account"], + admin=True, + domainid=cls.domain_1.id + ) # Create an account for domain_2 cls.account_2 = Account.create( - cls.api_client, - cls.services["account"], - admin=True, - domainid=cls.domain_2.id - ) + cls.api_client, + cls.services["account"], + admin=True, + domainid=cls.domain_2.id + ) cls._cleanup = [ - cls.account_1, - cls.account_2, - cls.service_offering, - cls.domain_1, - cls.domain_2, - ] + cls.account_1, + cls.account_2, + cls.service_offering, + cls.domain_1, + cls.domain_2, + ] return @classmethod def tearDownClass(cls): try: - #Cleanup resources used + # Cleanup resources used cleanup_resources(cls.api_client, cls._cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) @@ -568,13 +595,20 @@ class TestServiceOfferingSiblings(cloudstackTestCase): def tearDown(self): try: - #Clean up, terminate the created domains, accounts + # Clean up, terminate the created domains, accounts cleanup_resources(self.apiclient, self.cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return - @attr(tags=["advanced", "basic", "eip", "advancedns", "sg"], required_hardware="false") + @attr( + tags=[ + "advanced", + "basic", + "eip", + "advancedns", + "sg"], + required_hardware="false") def test_01_service_offering_siblings(self): """Test to verify service offerings at same level in hierarchy""" @@ -583,38 +617,39 @@ class TestServiceOfferingSiblings(cloudstackTestCase): # 2. Verify service offering is not visible for domain_2 service_offerings = list_service_offering( - self.apiclient, - domainid=self.domain_1.id - ) + self.apiclient, + domainid=self.domain_1.id + ) self.assertEqual( - isinstance(service_offerings, list), - True, - "Check if valid list service offerings response" - ) + isinstance(service_offerings, list), + True, + "Check if valid list service offerings response" + ) self.assertNotEqual( - len(service_offerings), - 0, - "Check List Service Offerings response" - ) + len(service_offerings), + 0, + "Check List Service Offerings response" + ) for service_offering in service_offerings: self.debug("Validating service offering: %s" % service_offering.id) self.assertEqual( - service_offering.id, - self.service_offering.id, - "Check Service offering ID for domain" + str(self.domain_1.name) + service_offering.id, + self.service_offering.id, + "Check Service offering ID for domain" + + str(self.domain_1.name) ) # Verify private service offering is not visible to other domain service_offerings = list_service_offering( - self.apiclient, - domainid=self.domain_2.id - ) + self.apiclient, + domainid=self.domain_2.id + ) self.assertEqual( - service_offerings, - None, - "Check List Service Offerings response for other domain" - ) + service_offerings, + None, + "Check List Service Offerings response for other domain" + ) return @@ -623,56 +658,56 @@ class TestServiceOfferingHierarchy(cloudstackTestCase): @classmethod def setUpClass(cls): cls.api_client = super( - TestServiceOfferingHierarchy, - cls - ).getClsTestClient().getApiClient() + TestServiceOfferingHierarchy, + cls + ).getClsTestClient().getApiClient() cls.services = Services().services # Create domain, service offerings etc cls.domain_1 = Domain.create( - cls.api_client, - cls.services["domain"] - ) + cls.api_client, + cls.services["domain"] + ) cls.domain_2 = Domain.create( - cls.api_client, - cls.services["domain"], - parentdomainid=cls.domain_1.id - ) + cls.api_client, + cls.services["domain"], + parentdomainid=cls.domain_1.id + ) cls.service_offering = ServiceOffering.create( - cls.api_client, - cls.services["service_offering"], - domainid=cls.domain_1.id - ) + cls.api_client, + cls.services["service_offering"], + domainid=cls.domain_1.id + ) # Create account for doamin_1 cls.account_1 = Account.create( - cls.api_client, - cls.services["account"], - admin=True, - domainid=cls.domain_1.id - ) + cls.api_client, + cls.services["account"], + admin=True, + domainid=cls.domain_1.id + ) # Create an account for domain_2 cls.account_2 = Account.create( - cls.api_client, - cls.services["account"], - admin=True, - domainid=cls.domain_2.id - ) + cls.api_client, + cls.services["account"], + admin=True, + domainid=cls.domain_2.id + ) cls._cleanup = [ - cls.account_2, - cls.domain_2, - cls.service_offering, - cls.account_1, - cls.domain_1, - ] + cls.account_2, + cls.domain_2, + cls.service_offering, + cls.account_1, + cls.domain_1, + ] return @classmethod def tearDownClass(cls): try: - #Cleanup resources used + # Cleanup resources used cleanup_resources(cls.api_client, cls._cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) @@ -686,13 +721,20 @@ class TestServiceOfferingHierarchy(cloudstackTestCase): def tearDown(self): try: - #Clean up, terminate the created instance, volumes and snapshots + # Clean up, terminate the created instance, volumes and snapshots cleanup_resources(self.apiclient, self.cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return - @attr(tags=["advanced", "basic", "eip", "advancedns", "sg"], required_hardware="false") + @attr( + tags=[ + "advanced", + "basic", + "eip", + "advancedns", + "sg"], + required_hardware="false") def test_01_service_offering_hierarchy(self): """Test to verify service offerings at same level in hierarchy""" @@ -701,37 +743,38 @@ class TestServiceOfferingHierarchy(cloudstackTestCase): # 2. Verify service offering is also visible for domain_2 service_offerings = list_service_offering( - self.apiclient, - domainid=self.domain_1.id - ) + self.apiclient, + domainid=self.domain_1.id + ) self.assertEqual( - isinstance(service_offerings, list), - True, - "Check List Service Offerings for a valid response" - ) + isinstance(service_offerings, list), + True, + "Check List Service Offerings for a valid response" + ) self.assertNotEqual( - len(service_offerings), - 0, - "Check List Service Offerings response" - ) + len(service_offerings), + 0, + "Check List Service Offerings response" + ) for service_offering in service_offerings: self.assertEqual( - service_offering.id, - self.service_offering.id, - "Check Service offering ID for domain" + str(self.domain_1.name) + service_offering.id, + self.service_offering.id, + "Check Service offering ID for domain" + + str(self.domain_1.name) ) # Verify private service offering is not visible to other domain service_offerings = list_service_offering( - self.apiclient, - domainid=self.domain_2.id - ) + self.apiclient, + domainid=self.domain_2.id + ) self.assertEqual( - service_offerings, - None, - "Check List Service Offerings for a valid response" - ) + service_offerings, + None, + "Check List Service Offerings for a valid response" + ) return @@ -745,56 +788,56 @@ class TestTemplateHierarchy(cloudstackTestCase): cls.services = Services().services cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) - cls.services['mode'] = cls.zone.networktype + cls.services['mode'] = cls.zone.networktype # Create domains, accounts and template cls.domain_1 = Domain.create( - cls.api_client, - cls.services["domain"] - ) + cls.api_client, + cls.services["domain"] + ) cls.domain_2 = Domain.create( - cls.api_client, - cls.services["domain"], - parentdomainid=cls.domain_1.id - ) + cls.api_client, + cls.services["domain"], + parentdomainid=cls.domain_1.id + ) # Create account for doamin_1 cls.account_1 = Account.create( - cls.api_client, - cls.services["account"], - admin=True, - domainid=cls.domain_1.id - ) + cls.api_client, + cls.services["account"], + admin=True, + domainid=cls.domain_1.id + ) # Create an account for domain_2 cls.account_2 = Account.create( - cls.api_client, - cls.services["account"], - admin=True, - domainid=cls.domain_2.id - ) + cls.api_client, + cls.services["account"], + admin=True, + domainid=cls.domain_2.id + ) cls._cleanup = [ - cls.account_2, - cls.domain_2, - cls.account_1, - cls.domain_1, - ] + cls.account_2, + cls.domain_2, + cls.account_1, + cls.domain_1, + ] builtin_info = get_builtin_template_info(cls.api_client, cls.zone.id) - cls.services["template"]["url"] = builtin_info[0] - cls.services["template"]["hypervisor"] = builtin_info[1] - cls.services["template"]["format"] = builtin_info[2] - + cls.services["template"]["url"] = builtin_info[0] + cls.services["template"]["hypervisor"] = builtin_info[1] + cls.services["template"]["format"] = builtin_info[2] + # Register new template cls.template = Template.register( - cls.api_client, - cls.services["template"], - zoneid=cls.zone.id, - account=cls.account_1.name, - domainid=cls.domain_1.id, - hypervisor=cls.hypervisor - ) + cls.api_client, + cls.services["template"], + zoneid=cls.zone.id, + account=cls.account_1.name, + domainid=cls.domain_1.id, + hypervisor=cls.hypervisor + ) # Wait for template to download cls.template.download(cls.api_client) @@ -806,7 +849,7 @@ class TestTemplateHierarchy(cloudstackTestCase): @classmethod def tearDownClass(cls): try: - #Cleanup resources used + # Cleanup resources used cleanup_resources(cls.api_client, cls._cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) @@ -820,7 +863,7 @@ class TestTemplateHierarchy(cloudstackTestCase): def tearDown(self): try: - #Clean up, terminate the created instance, volumes and snapshots + # Clean up, terminate the created instance, volumes and snapshots cleanup_resources(self.apiclient, self.cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) @@ -837,53 +880,53 @@ class TestTemplateHierarchy(cloudstackTestCase): # Sleep to ensure that template state is reflected across templates = list_templates( - self.apiclient, - templatefilter='self', - account=self.account_1.name, - domainid=self.domain_1.id - ) + self.apiclient, + templatefilter='self', + account=self.account_1.name, + domainid=self.domain_1.id + ) self.assertEqual( - isinstance(templates, list), - True, - "Template response %s is not a list" % templates - ) + isinstance(templates, list), + True, + "Template response %s is not a list" % templates + ) self.assertNotEqual( - len(templates), - 0, - "No templates found" - ) + len(templates), + 0, + "No templates found" + ) for template in templates: self.assertEqual( - template.id, - self.template.id, - "Check Template ID for domain" + str(self.domain_1.name) + template.id, + self.template.id, + "Check Template ID for domain" + str(self.domain_1.name) ) # Verify private service offering is not visible to other domain templates = list_templates( - self.apiclient, - id=self.template.id, - templatefilter='all', - account=self.account_2.name, - domainid=self.domain_2.id - ) + self.apiclient, + id=self.template.id, + templatefilter='all', + account=self.account_2.name, + domainid=self.domain_2.id + ) self.assertEqual( - isinstance(templates, list), - True, - "Template response %s is not a list" % templates - ) + isinstance(templates, list), + True, + "Template response %s is not a list" % templates + ) self.assertNotEqual( - len(templates), - 0, - "No templates found" - ) + len(templates), + 0, + "No templates found" + ) for template in templates: self.assertEqual( - template.id, - self.template.id, - "Check Template ID for domain" + str(self.domain_2.name) + template.id, + self.template.id, + "Check Template ID for domain" + str(self.domain_2.name) ) return @@ -900,68 +943,68 @@ class TestAddVmToSubDomain(cloudstackTestCase): cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype cls.sub_domain = Domain.create( - cls.api_client, - cls.services["domain"], - parentdomainid=cls.domain.id - ) + cls.api_client, + cls.services["domain"], + parentdomainid=cls.domain.id + ) # Create account for doamin_1 cls.account_1 = Account.create( - cls.api_client, - cls.services["account"], - admin=True, - domainid=cls.domain.id - ) + cls.api_client, + cls.services["account"], + admin=True, + domainid=cls.domain.id + ) # Create an account for domain_2 cls.account_2 = Account.create( - cls.api_client, - cls.services["account"], - admin=True, - domainid=cls.sub_domain.id - ) + cls.api_client, + cls.services["account"], + admin=True, + domainid=cls.sub_domain.id + ) cls.service_offering = ServiceOffering.create( - cls.api_client, - cls.services["service_offering"], - domainid=cls.domain.id - ) + cls.api_client, + cls.services["service_offering"], + domainid=cls.domain.id + ) cls._cleanup = [ - cls.account_2, - cls.account_1, - cls.sub_domain, - cls.service_offering - ] + cls.account_2, + cls.account_1, + cls.sub_domain, + cls.service_offering + ] cls.template = get_template( - cls.api_client, - cls.zone.id, - cls.services["ostype"] - ) + cls.api_client, + cls.zone.id, + cls.services["ostype"] + ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.vm_1 = VirtualMachine.create( - cls.api_client, - cls.services["virtual_machine"], - templateid=cls.template.id, - accountid=cls.account_1.name, - domainid=cls.account_1.domainid, - serviceofferingid=cls.service_offering.id - ) + cls.api_client, + cls.services["virtual_machine"], + templateid=cls.template.id, + accountid=cls.account_1.name, + domainid=cls.account_1.domainid, + serviceofferingid=cls.service_offering.id + ) cls.vm_2 = VirtualMachine.create( - cls.api_client, - cls.services["virtual_machine"], - templateid=cls.template.id, - accountid=cls.account_2.name, - domainid=cls.account_2.domainid, - serviceofferingid=cls.service_offering.id - ) + cls.api_client, + cls.services["virtual_machine"], + templateid=cls.template.id, + accountid=cls.account_2.name, + domainid=cls.account_2.domainid, + serviceofferingid=cls.service_offering.id + ) return @classmethod def tearDownClass(cls): try: - #Clean up, terminate the created resources + # Clean up, terminate the created resources cleanup_resources(cls.api_client, cls._cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) @@ -975,60 +1018,68 @@ class TestAddVmToSubDomain(cloudstackTestCase): def tearDown(self): try: - #Clean up, terminate the created resources + # Clean up, terminate the created resources cleanup_resources(self.apiclient, self.cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return - @attr(tags=["advanced", "basic", "eip", "advancedns", "sg"], required_hardware="false") + @attr( + tags=[ + "advanced", + "basic", + "eip", + "advancedns", + "sg"], + required_hardware="false") def test_01_add_vm_to_subdomain(self): - """ Test Sub domain allowed to launch VM when a Domain level zone is created""" + """ Test Sub domain allowed to launch VM when a Domain + level zone is created""" # Validate the following # 1. Verify VM created by Account_1 is in Running state # 2. Verify VM created by Account_2 is in Running state vm_response = list_virtual_machines( - self.apiclient, - id=self.vm_1.id - ) + self.apiclient, + id=self.vm_1.id + ) self.assertEqual( - isinstance(vm_response, list), - True, - "Check List VM for a valid response" - ) + isinstance(vm_response, list), + True, + "Check List VM for a valid response" + ) self.assertNotEqual( - len(vm_response), - 0, - "Check List Template response" - ) + len(vm_response), + 0, + "Check List Template response" + ) for vm in vm_response: self.debug("VM ID: %s and state: %s" % (vm.id, vm.state)) self.assertEqual( - vm.state, - 'Running', - "Check State of Virtual machine" - ) + vm.state, + 'Running', + "Check State of Virtual machine" + ) vm_response = list_virtual_machines( - self.apiclient, - id=self.vm_2.id - ) + self.apiclient, + id=self.vm_2.id + ) self.assertNotEqual( - len(vm_response), - 0, - "Check List Template response" - ) + len(vm_response), + 0, + "Check List Template response" + ) for vm in vm_response: self.debug("VM ID: %s and state: %s" % (vm.id, vm.state)) self.assertEqual( - vm.state, - 'Running', - "Check State of Virtual machine" - ) + vm.state, + 'Running', + "Check State of Virtual machine" + ) return @@ -1049,7 +1100,7 @@ class TestUserDetails(cloudstackTestCase): @classmethod def tearDownClass(cls): try: - #Cleanup resources used + # Cleanup resources used cleanup_resources(cls.api_client, cls._cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) @@ -1063,22 +1114,22 @@ class TestUserDetails(cloudstackTestCase): def tearDown(self): try: - #Clean up, terminate the created network offerings + # Clean up, terminate the created network offerings cleanup_resources(self.apiclient, self.cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return @attr(tags=[ - "role", - "accounts", - "simulator", - "advanced", - "advancedns", - "basic", - "eip", - "sg" - ]) + "role", + "accounts", + "simulator", + "advanced", + "advancedns", + "basic", + "eip", + "sg" + ]) def test_updateUserDetails(self): """Test user update API """ @@ -1096,26 +1147,26 @@ class TestUserDetails(cloudstackTestCase): self.debug("Creating an user account..") self.account = Account.create( - self.apiclient, - self.services["account"], - domainid=self.domain.id - ) + self.apiclient, + self.services["account"], + domainid=self.domain.id + ) self.cleanup.append(self.account) # Fetching the user details of account self.debug( - "Fetching user details for account: %s" % - self.account.name) + "Fetching user details for account: %s" % + self.account.name) users = User.list( - self.apiclient, - account=self.account.name, - domainid=self.account.domainid - ) + self.apiclient, + account=self.account.name, + domainid=self.account.domainid + ) self.assertEqual( - isinstance(users, list), - True, - "List users should return a valid list for account" - ) + isinstance(users, list), + True, + "List users should return a valid list for account" + ) user_1 = users[0] self.debug("Updating the details of user: %s" % user_1.name) firstname = random_gen() @@ -1123,49 +1174,49 @@ class TestUserDetails(cloudstackTestCase): self.debug("New firstname: %s, lastname: %s" % (firstname, lastname)) User.update( - self.apiclient, - user_1.id, - firstname=firstname, - lastname=lastname - ) + self.apiclient, + user_1.id, + firstname=firstname, + lastname=lastname + ) # Fetching the user details of account self.debug( - "Fetching user details for user: %s" % user_1.name) + "Fetching user details for user: %s" % user_1.name) users = User.list( - self.apiclient, - id=user_1.id, - listall=True - ) + self.apiclient, + id=user_1.id, + listall=True + ) self.assertEqual( - isinstance(users, list), - True, - "List users should return a valid list for account" - ) + isinstance(users, list), + True, + "List users should return a valid list for account" + ) user_1 = users[0] self.assertEqual( - user_1.firstname, - firstname, - "User's first name should be updated with new one" - ) + user_1.firstname, + firstname, + "User's first name should be updated with new one" + ) self.assertEqual( - user_1.lastname, - lastname, - "User's last name should be updated with new one" - ) + user_1.lastname, + lastname, + "User's last name should be updated with new one" + ) return @attr(tags=[ - "role", - "accounts", - "simulator", - "advanced", - "advancedns", - "basic", - "eip", - "sg" - ]) + "role", + "accounts", + "simulator", + "advanced", + "advancedns", + "basic", + "eip", + "sg" + ]) def test_updateAdminDetails(self): """Test update admin details """ @@ -1183,26 +1234,26 @@ class TestUserDetails(cloudstackTestCase): self.debug("Creating a ROOT admin account") self.account = Account.create( - self.apiclient, - self.services["account"], - admin=True, - ) + self.apiclient, + self.services["account"], + admin=True, + ) self.cleanup.append(self.account) # Fetching the user details of account self.debug( - "Fetching user details for account: %s" % - self.account.name) + "Fetching user details for account: %s" % + self.account.name) users = User.list( - self.apiclient, - account=self.account.name, - domainid=self.account.domainid - ) + self.apiclient, + account=self.account.name, + domainid=self.account.domainid + ) self.assertEqual( - isinstance(users, list), - True, - "List users should return a valid list for account" - ) + isinstance(users, list), + True, + "List users should return a valid list for account" + ) user_1 = users[0] self.debug("Updating the details of user: %s" % user_1.name) firstname = random_gen() @@ -1210,49 +1261,49 @@ class TestUserDetails(cloudstackTestCase): self.debug("New firstname: %s, lastname: %s" % (firstname, lastname)) User.update( - self.apiclient, - user_1.id, - firstname=firstname, - lastname=lastname - ) + self.apiclient, + user_1.id, + firstname=firstname, + lastname=lastname + ) # Fetching the user details of account self.debug( - "Fetching user details for user: %s" % user_1.name) + "Fetching user details for user: %s" % user_1.name) users = User.list( - self.apiclient, - id=user_1.id, - listall=True - ) + self.apiclient, + id=user_1.id, + listall=True + ) self.assertEqual( - isinstance(users, list), - True, - "List users should return a valid list for account" - ) + isinstance(users, list), + True, + "List users should return a valid list for account" + ) user_1 = users[0] self.assertEqual( - user_1.firstname, - firstname, - "User's first name should be updated with new one" - ) + user_1.firstname, + firstname, + "User's first name should be updated with new one" + ) self.assertEqual( - user_1.lastname, - lastname, - "User's last name should be updated with new one" - ) + user_1.lastname, + lastname, + "User's last name should be updated with new one" + ) return @attr(tags=[ - "role", - "accounts", - "simulator", - "advanced", - "advancedns", - "basic", - "eip", - "sg" - ]) + "role", + "accounts", + "simulator", + "advanced", + "advancedns", + "basic", + "eip", + "sg" + ]) def test_updateDomainAdminDetails(self): """Test update domain admin details """ @@ -1269,27 +1320,27 @@ class TestUserDetails(cloudstackTestCase): self.debug("Creating a domain admin account") self.account = Account.create( - self.apiclient, - self.services["account"], - admin=True, - domainid=self.domain.id - ) + self.apiclient, + self.services["account"], + admin=True, + domainid=self.domain.id + ) self.cleanup.append(self.account) # Fetching the user details of account self.debug( - "Fetching user details for account: %s" % - self.account.name) + "Fetching user details for account: %s" % + self.account.name) users = User.list( - self.apiclient, - account=self.account.name, - domainid=self.account.domainid - ) + self.apiclient, + account=self.account.name, + domainid=self.account.domainid + ) self.assertEqual( - isinstance(users, list), - True, - "List users should return a valid list for account" - ) + isinstance(users, list), + True, + "List users should return a valid list for account" + ) user_1 = users[0] self.debug("Updating the details of user: %s" % user_1.name) firstname = random_gen() @@ -1297,39 +1348,40 @@ class TestUserDetails(cloudstackTestCase): self.debug("New firstname: %s, lastname: %s" % (firstname, lastname)) User.update( - self.apiclient, - user_1.id, - firstname=firstname, - lastname=lastname - ) + self.apiclient, + user_1.id, + firstname=firstname, + lastname=lastname + ) # Fetching the user details of account self.debug( - "Fetching user details for user: %s" % user_1.name) + "Fetching user details for user: %s" % user_1.name) users = User.list( - self.apiclient, - id=user_1.id, - listall=True - ) + self.apiclient, + id=user_1.id, + listall=True + ) self.assertEqual( - isinstance(users, list), - True, - "List users should return a valid list for account" - ) + isinstance(users, list), + True, + "List users should return a valid list for account" + ) user_1 = users[0] self.assertEqual( - user_1.firstname, - firstname, - "User's first name should be updated with new one" - ) + user_1.firstname, + firstname, + "User's first name should be updated with new one" + ) self.assertEqual( - user_1.lastname, - lastname, - "User's last name should be updated with new one" - ) + user_1.lastname, + lastname, + "User's last name should be updated with new one" + ) return + class TestUserLogin(cloudstackTestCase): @classmethod @@ -1347,7 +1399,7 @@ class TestUserLogin(cloudstackTestCase): @classmethod def tearDownClass(cls): try: - #Cleanup resources used + # Cleanup resources used cleanup_resources(cls.api_client, cls._cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) @@ -1361,14 +1413,14 @@ class TestUserLogin(cloudstackTestCase): def tearDown(self): try: - #Clean up, terminate the created network offerings + # Clean up, terminate the created network offerings cleanup_resources(self.apiclient, self.cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return @attr(tags=["login", "accounts", "simulator", "advanced", - "advancedns", "basic", "eip", "sg"]) + "advancedns", "basic", "eip", "sg"]) def test_LoginApiUuidResponse(self): """Test if Login API does not return UUID's """ @@ -1385,31 +1437,31 @@ class TestUserLogin(cloudstackTestCase): self.debug("Creating an user account..") self.account = Account.create( - self.apiclient, - self.services["account"], - domainid=self.domain.id - ) + self.apiclient, + self.services["account"], + domainid=self.domain.id + ) self.cleanup.append(self.account) self.debug("Logging into the cloudstack with login API") respose = User.login( - self.apiclient, - username=self.account.name, - password=self.services["account"]["password"] - ) + self.apiclient, + username=self.account.name, + password=self.services["account"]["password"] + ) self.debug("Login API response: %s" % respose) self.assertNotEqual( - respose.sessionkey, - None, - "Login to the CloudStack should be successful" + - "response shall have non Null key" - ) + respose.sessionkey, + None, + "Login to the CloudStack should be successful" + + "response shall have non Null key" + ) return @attr(tags=["login", "accounts", "simulator", "advanced", - "advancedns", "basic", "eip", "sg"]) + "advancedns", "basic", "eip", "sg"]) def test_LoginApiDomain(self): """Test login API with domain """ @@ -1427,55 +1479,55 @@ class TestUserLogin(cloudstackTestCase): self.debug("Creating a domain for login with API domain test") domain = Domain.create( - self.apiclient, - self.services["domain"], - parentdomainid=self.domain.id - ) + self.apiclient, + self.services["domain"], + parentdomainid=self.domain.id + ) self.debug("Domain: %s is created succesfully." % domain.name) self.debug( "Checking if the created domain is listed in list domains API") domains = Domain.list(self.apiclient, id=domain.id, listall=True) self.assertEqual( - isinstance(domains, list), - True, - "List domains shall return a valid response" - ) + isinstance(domains, list), + True, + "List domains shall return a valid response" + ) self.debug("Creating an user account in domain: %s" % domain.name) self.account = Account.create( - self.apiclient, - self.services["account"], - domainid=domain.id - ) + self.apiclient, + self.services["account"], + domainid=domain.id + ) self.cleanup.append(self.account) accounts = Account.list( - self.apiclient, - name=self.account.name, - domainid=self.account.domainid, - listall=True - ) + self.apiclient, + name=self.account.name, + domainid=self.account.domainid, + listall=True + ) self.assertEqual( - isinstance(accounts, list), - True, - "List accounts should return a valid response" - ) + isinstance(accounts, list), + True, + "List accounts should return a valid response" + ) self.debug("Logging into the cloudstack with login API") respose = User.login( - self.apiclient, - username=self.account.name, - password=self.services["account"]["password"], - domainid=domain.id) + self.apiclient, + username=self.account.name, + password=self.services["account"]["password"], + domainid=domain.id) self.debug("Login API response: %s" % respose) self.assertNotEqual( - respose.sessionkey, - None, - "Login to the CloudStack should be successful" + - "response shall have non Null key" - ) + respose.sessionkey, + None, + "Login to the CloudStack should be successful" + + "response shall have non Null key" + ) return @@ -1492,10 +1544,10 @@ class TestDomainForceRemove(cloudstackTestCase): cls.services['mode'] = cls.zone.networktype cls.template = get_template( - cls.api_client, - cls.zone.id, - cls.services["ostype"] - ) + cls.api_client, + cls.zone.id, + cls.services["ostype"] + ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls._cleanup = [] @@ -1504,7 +1556,7 @@ class TestDomainForceRemove(cloudstackTestCase): @classmethod def tearDownClass(cls): try: - #Clean up, terminate the created resources + # Clean up, terminate the created resources cleanup_resources(cls.api_client, cls._cleanup) except Exception as e: @@ -1519,13 +1571,20 @@ class TestDomainForceRemove(cloudstackTestCase): def tearDown(self): try: - #Clean up, terminate the created resources + # Clean up, terminate the created resources cleanup_resources(self.apiclient, self.cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return - @attr(tags=["domains", "advanced", "advancedns", "simulator", "dvs"], required_hardware="false") + @attr( + tags=[ + "domains", + "advanced", + "advancedns", + "simulator", + "dvs"], + required_hardware="false") def test_forceDeleteDomain(self): """ Test delete domain with force option""" @@ -1547,124 +1606,124 @@ class TestDomainForceRemove(cloudstackTestCase): self.debug("Creating a domain for login with API domain test") domain = Domain.create( - self.apiclient, - self.services["domain"], - parentdomainid=self.domain.id - ) + self.apiclient, + self.services["domain"], + parentdomainid=self.domain.id + ) self.debug("Domain is created succesfully.") self.debug( "Checking if the created domain is listed in list domains API") domains = Domain.list(self.apiclient, id=domain.id, listall=True) self.assertEqual( - isinstance(domains, list), - True, - "List domains shall return a valid response" - ) + isinstance(domains, list), + True, + "List domains shall return a valid response" + ) self.debug("Creating 2 user accounts in domain: %s" % domain.name) self.account_1 = Account.create( - self.apiclient, - self.services["account"], - domainid=domain.id - ) + self.apiclient, + self.services["account"], + domainid=domain.id + ) self.account_2 = Account.create( - self.apiclient, - self.services["account"], - domainid=domain.id - ) + self.apiclient, + self.services["account"], + domainid=domain.id + ) try: self.debug("Creating a tiny service offering for VM deployment") self.service_offering = ServiceOffering.create( - self.apiclient, - self.services["service_offering"], - domainid=self.domain.id - ) + self.apiclient, + self.services["service_offering"], + domainid=self.domain.id + ) self.debug("Deploying virtual machine in account 1: %s" % - self.account_1.name) + self.account_1.name) vm_1 = VirtualMachine.create( - self.apiclient, - self.services["virtual_machine"], - templateid=self.template.id, - accountid=self.account_1.name, - domainid=self.account_1.domainid, - serviceofferingid=self.service_offering.id - ) + self.apiclient, + self.services["virtual_machine"], + templateid=self.template.id, + accountid=self.account_1.name, + domainid=self.account_1.domainid, + serviceofferingid=self.service_offering.id + ) self.debug("Deploying virtual machine in account 2: %s" % - self.account_2.name) + self.account_2.name) VirtualMachine.create( - self.apiclient, - self.services["virtual_machine"], - templateid=self.template.id, - accountid=self.account_2.name, - domainid=self.account_2.domainid, - serviceofferingid=self.service_offering.id - ) + self.apiclient, + self.services["virtual_machine"], + templateid=self.template.id, + accountid=self.account_2.name, + domainid=self.account_2.domainid, + serviceofferingid=self.service_offering.id + ) networks = Network.list( - self.apiclient, - account=self.account_1.name, - domainid=self.account_1.domainid, - listall=True - ) + self.apiclient, + account=self.account_1.name, + domainid=self.account_1.domainid, + listall=True + ) self.assertEqual( - isinstance(networks, list), - True, - "List networks should return a valid response" - ) + isinstance(networks, list), + True, + "List networks should return a valid response" + ) network_1 = networks[0] self.debug("Default network in account 1: %s is %s" % ( - self.account_1.name, - network_1.name)) + self.account_1.name, + network_1.name)) src_nat_list = PublicIPAddress.list( - self.apiclient, - associatednetworkid=network_1.id, - account=self.account_1.name, - domainid=self.account_1.domainid, - listall=True, - issourcenat=True, - ) + self.apiclient, + associatednetworkid=network_1.id, + account=self.account_1.name, + domainid=self.account_1.domainid, + listall=True, + issourcenat=True, + ) self.assertEqual( - isinstance(src_nat_list, list), - True, - "List Public IP should return a valid source NAT" - ) + isinstance(src_nat_list, list), + True, + "List Public IP should return a valid source NAT" + ) self.assertNotEqual( - len(src_nat_list), - 0, - "Length of response from listPublicIp should not be 0" - ) + len(src_nat_list), + 0, + "Length of response from listPublicIp should not be 0" + ) src_nat = src_nat_list[0] self.debug( - "Trying to create a port forwarding rule in source NAT: %s" % - src_nat.ipaddress) - #Create NAT rule + "Trying to create a port forwarding rule in source NAT: %s" % + src_nat.ipaddress) + # Create NAT rule nat_rule = NATRule.create( - self.apiclient, - vm_1, - self.services["natrule"], - ipaddressid=src_nat.id - ) + self.apiclient, + vm_1, + self.services["natrule"], + ipaddressid=src_nat.id + ) self.debug("Created PF rule on source NAT: %s" % src_nat.ipaddress) nat_rules = NATRule.list(self.apiclient, id=nat_rule.id) self.assertEqual( - isinstance(nat_rules, list), - True, - "List NAT should return a valid port forwarding rules" - ) + isinstance(nat_rules, list), + True, + "List NAT should return a valid port forwarding rules" + ) self.assertNotEqual( - len(nat_rules), - 0, - "Length of response from listLbRules should not be 0" - ) + len(nat_rules), + 0, + "Length of response from listLbRules should not be 0" + ) except Exception as e: self.clenaup.append(self.account_1) self.cleanup.append(self.account_2) @@ -1675,27 +1734,33 @@ class TestDomainForceRemove(cloudstackTestCase): domain.delete(self.apiclient, cleanup=True) except Exception as e: self.debug("Waiting for account.cleanup.interval" + - " to cleanup any remaining resouces") + " to cleanup any remaining resouces") # Sleep 3*account.gc to ensure that all resources are deleted - wait_for_cleanup(self.apiclient, ["account.cleanup.interval"]*3) + wait_for_cleanup(self.apiclient, ["account.cleanup.interval"] * 3) with self.assertRaises(CloudstackAPIException): Domain.list( - self.apiclient, - id=domain.id, - listall=True - ) + self.apiclient, + id=domain.id, + listall=True + ) self.debug("Checking if the resources in domain are deleted") with self.assertRaises(CloudstackAPIException): Account.list( - self.apiclient, - name=self.account_1.name, - domainid=self.account_1.domainid, - listall=True - ) + self.apiclient, + name=self.account_1.name, + domainid=self.account_1.domainid, + listall=True + ) return - @attr(tags=["domains", "advanced", "advancedns", "simulator"], required_hardware="false") + @attr( + tags=[ + "domains", + "advanced", + "advancedns", + "simulator"], + required_hardware="false") def test_DeleteDomain(self): """ Test delete domain without force option""" @@ -1715,126 +1780,126 @@ class TestDomainForceRemove(cloudstackTestCase): self.debug("Creating a domain for login with API domain test") domain = Domain.create( - self.apiclient, - self.services["domain"], - parentdomainid=self.domain.id - ) + self.apiclient, + self.services["domain"], + parentdomainid=self.domain.id + ) self.debug("Domain: %s is created successfully." % domain.name) self.debug( "Checking if the created domain is listed in list domains API") domains = Domain.list(self.apiclient, id=domain.id, listall=True) self.assertEqual( - isinstance(domains, list), - True, - "List domains shall return a valid response" - ) + isinstance(domains, list), + True, + "List domains shall return a valid response" + ) self.debug("Creating 2 user accounts in domain: %s" % domain.name) self.account_1 = Account.create( - self.apiclient, - self.services["account"], - domainid=domain.id - ) + self.apiclient, + self.services["account"], + domainid=domain.id + ) self.cleanup.append(self.account_1) self.account_2 = Account.create( - self.apiclient, - self.services["account"], - domainid=domain.id - ) + self.apiclient, + self.services["account"], + domainid=domain.id + ) self.cleanup.append(self.account_2) self.debug("Creating a tiny service offering for VM deployment") self.service_offering = ServiceOffering.create( - self.apiclient, - self.services["service_offering"], - domainid=self.domain.id - ) + self.apiclient, + self.services["service_offering"], + domainid=self.domain.id + ) self.cleanup.append(self.service_offering) self.debug("Deploying virtual machine in account 1: %s" % - self.account_1.name) + self.account_1.name) vm_1 = VirtualMachine.create( - self.apiclient, - self.services["virtual_machine"], - templateid=self.template.id, - accountid=self.account_1.name, - domainid=self.account_1.domainid, - serviceofferingid=self.service_offering.id - ) + self.apiclient, + self.services["virtual_machine"], + templateid=self.template.id, + accountid=self.account_1.name, + domainid=self.account_1.domainid, + serviceofferingid=self.service_offering.id + ) self.debug("Deploying virtual machine in account 2: %s" % - self.account_2.name) + self.account_2.name) VirtualMachine.create( - self.apiclient, - self.services["virtual_machine"], - templateid=self.template.id, - accountid=self.account_2.name, - domainid=self.account_2.domainid, - serviceofferingid=self.service_offering.id - ) + self.apiclient, + self.services["virtual_machine"], + templateid=self.template.id, + accountid=self.account_2.name, + domainid=self.account_2.domainid, + serviceofferingid=self.service_offering.id + ) networks = Network.list( - self.apiclient, - account=self.account_1.name, - domainid=self.account_1.domainid, - listall=True - ) + self.apiclient, + account=self.account_1.name, + domainid=self.account_1.domainid, + listall=True + ) self.assertEqual( - isinstance(networks, list), - True, - "List networks should return a valid response" - ) + isinstance(networks, list), + True, + "List networks should return a valid response" + ) network_1 = networks[0] self.debug("Default network in account 1: %s is %s" % ( - self.account_1.name, - network_1.name)) + self.account_1.name, + network_1.name)) src_nat_list = PublicIPAddress.list( - self.apiclient, - associatednetworkid=network_1.id, - account=self.account_1.name, - domainid=self.account_1.domainid, - listall=True, - issourcenat=True, - ) + self.apiclient, + associatednetworkid=network_1.id, + account=self.account_1.name, + domainid=self.account_1.domainid, + listall=True, + issourcenat=True, + ) self.assertEqual( - isinstance(src_nat_list, list), - True, - "List Public IP should return a valid source NAT" - ) + isinstance(src_nat_list, list), + True, + "List Public IP should return a valid source NAT" + ) self.assertNotEqual( - len(src_nat_list), - 0, - "Length of response from listPublicIp should not be 0" - ) + len(src_nat_list), + 0, + "Length of response from listPublicIp should not be 0" + ) src_nat = src_nat_list[0] self.debug( "Trying to create a port forwarding rule in source NAT: %s" % - src_nat.ipaddress) - #Create NAT rule + src_nat.ipaddress) + # Create NAT rule nat_rule = NATRule.create( - self.apiclient, - vm_1, - self.services["natrule"], - ipaddressid=src_nat.id - ) + self.apiclient, + vm_1, + self.services["natrule"], + ipaddressid=src_nat.id + ) self.debug("Created PF rule on source NAT: %s" % src_nat.ipaddress) nat_rules = NATRule.list(self.apiclient, id=nat_rule.id) self.assertEqual( - isinstance(nat_rules, list), - True, - "List NAT should return a valid port forwarding rules" - ) + isinstance(nat_rules, list), + True, + "List NAT should return a valid port forwarding rules" + ) self.assertNotEqual( - len(nat_rules), - 0, - "Length of response from listLbRules should not be 0" - ) + len(nat_rules), + 0, + "Length of response from listLbRules should not be 0" + ) self.debug("Deleting domain without force option") with self.assertRaises(Exception): diff --git a/test/integration/component/test_shared_networks.py b/test/integration/component/test_shared_networks.py index dde5983b873..3b21d8d0963 100644 --- a/test/integration/component/test_shared_networks.py +++ b/test/integration/component/test_shared_networks.py @@ -40,7 +40,8 @@ from marvin.lib.common import (get_domain, get_template, get_free_vlan, wait_for_cleanup, - verifyRouterState) + verifyRouterState, + verifyGuestTrafficPortGroups) from marvin.sshClient import SshClient from marvin.codes import PASS from ddt import ddt, data @@ -61,6 +62,7 @@ class TestSharedNetworks(cloudstackTestCase): # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) + cls.hypervisor = cls.testClient.getHypervisorInfo() cls.template = get_template( cls.api_client, cls.zone.id, @@ -3672,3 +3674,78 @@ class TestSharedNetworks(cloudstackTestCase): "Check if disassociated IP Address is no longer available" ) return + + @attr(tags=["advanced", "dvs"], required_hardware="true") + def test_guest_traffic_port_groups_shared_network(self): + """ Verify vcenter port groups are created for shared network + + # Steps, + # 1. Create a shared network + # 2. Deploy a VM in shared network so that router is + # created + # 3. Verify that corresponding port groups are created + for guest traffic + """ + + if self.hypervisor.lower() != "vmware": + self.skipTest("This test is intended for only vmware") + + physical_network, shared_vlan = get_free_vlan( + self.api_client, self.zone.id) + if shared_vlan is None: + self.fail("Failed to get free vlan id for shared network") + + self.testdata["shared_network_offering"]["specifyVlan"] = "True" + self.testdata["shared_network_offering"]["specifyIpRanges"] = "True" + + # Create Network Offering + self.shared_network_offering = NetworkOffering.create( + self.api_client, + self.testdata["shared_network_offering"], + conservemode=False + ) + + # Update network offering state from disabled to enabled. + NetworkOffering.update( + self.shared_network_offering, + self.api_client, + id=self.shared_network_offering.id, + state="enabled" + ) + + # create network using the shared network offering created + self.testdata["shared_network"]["acltype"] = "Domain" + self.testdata["shared_network"][ + "networkofferingid"] = self.shared_network_offering.id + self.testdata["shared_network"][ + "physicalnetworkid"] = physical_network.id + self.testdata["shared_network"]["vlan"] = shared_vlan + + self.network = Network.create( + self.api_client, + self.testdata["shared_network"], + networkofferingid=self.shared_network_offering.id, + zoneid=self.zone.id, + ) + self.cleanup_networks.append(self.network) + + vm = VirtualMachine.create( + self.api_client, + self.testdata["virtual_machine"], + networkids=self.network.id, + serviceofferingid=self.service_offering.id + ) + self.cleanup_vms.append(vm) + + routers = Router.list(self.api_client, + networkid=self.network.id, + listall=True) + + self.assertEqual(validateList(routers)[0], PASS, + "No Router associated with the network found") + + response = verifyGuestTrafficPortGroups(self.api_client, + self.config, + self.zone) + self.assertEqual(response[0], PASS, response[1]) + return diff --git a/test/integration/component/test_vpc_vm_life_cycle.py b/test/integration/component/test_vpc_vm_life_cycle.py index d146af10b05..e185e968b76 100644 --- a/test/integration/component/test_vpc_vm_life_cycle.py +++ b/test/integration/component/test_vpc_vm_life_cycle.py @@ -43,7 +43,8 @@ from marvin.lib.common import (get_domain, wait_for_cleanup, list_virtual_machines, list_hosts, - findSuitableHostForMigration) + findSuitableHostForMigration, + verifyGuestTrafficPortGroups) from marvin.codes import PASS, ERROR_NO_HOST_FOR_MIGRATION @@ -1734,6 +1735,7 @@ class TestVMLifeCycleBothIsolated(cloudstackTestCase): cls.api_client = cls.testClient.getApiClient() cls.services = Services().services + cls.hypervisor = cls.testClient.getHypervisorInfo() # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) @@ -2060,6 +2062,17 @@ class TestVMLifeCycleBothIsolated(cloudstackTestCase): ) return + @attr(tags=["advanced", "dvs"], required_hardware="true") + def test_guest_traffic_port_groups_vpc_network(self): + """ Verify port groups are created for guest traffic + used by vpc network """ + + if self.hypervisor.lower() == "vmware": + response = verifyGuestTrafficPortGroups(self.apiclient, + self.config, + self.zone) + assert response[0] == PASS, response[1] + class TestVMLifeCycleStoppedVPCVR(cloudstackTestCase): @classmethod diff --git a/test/integration/smoke/test_network.py b/test/integration/smoke/test_network.py index b1c58059ba5..00d20297a20 100644 --- a/test/integration/smoke/test_network.py +++ b/test/integration/smoke/test_network.py @@ -17,7 +17,8 @@ """ BVT tests for Network Life Cycle """ # Import Local Modules -from marvin.codes import FAILED, STATIC_NAT_RULE, LB_RULE, NAT_RULE +from marvin.codes import (FAILED, STATIC_NAT_RULE, LB_RULE, + NAT_RULE, PASS) from marvin.cloudstackTestCase import cloudstackTestCase from marvin.cloudstackException import CloudstackAPIException from marvin.cloudstackAPI import rebootRouter @@ -43,7 +44,8 @@ from marvin.lib.common import (get_domain, list_routers, list_virtual_machines, list_lb_rules, - list_configurations) + list_configurations, + verifyGuestTrafficPortGroups) from nose.plugins.attrib import attr from ddt import ddt, data # Import System modules @@ -247,6 +249,7 @@ class TestPortForwarding(cloudstackTestCase): testClient = super(TestPortForwarding, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.services = testClient.getParsedTestDataConfig() + cls.hypervisor = testClient.getHypervisorInfo() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) @@ -551,6 +554,17 @@ class TestPortForwarding(cloudstackTestCase): ) return + @attr(tags=["advanced", "dvs"], required_hardware="true") + def test_guest_traffic_port_groups_isolated_network(self): + """ Verify port groups are created for guest traffic + used by isolated network """ + + if self.hypervisor.lower() == "vmware": + response = verifyGuestTrafficPortGroups(self.apiclient, + self.config, + self.zone) + assert response[0] == PASS, response[1] + class TestRebootRouter(cloudstackTestCase): diff --git a/test/integration/testpaths/testpath_stopped_vm.py b/test/integration/testpaths/testpath_stopped_vm.py index 18a17c3ef04..54f4025b8bb 100644 --- a/test/integration/testpaths/testpath_stopped_vm.py +++ b/test/integration/testpaths/testpath_stopped_vm.py @@ -236,7 +236,7 @@ class TestAdvancedZoneStoppedVM(cloudstackTestCase): raise Exception("Warning: Exception during cleanup : %s" % e) return - @attr(tags=["advanced", "basic"], required_hardware="False") + @attr(tags=["advanced", "basic"], required_hardware="True") def test_01_pt_deploy_vm_without_startvm(self): """ Positive test for stopped VM test path - T1 @@ -304,7 +304,7 @@ class TestAdvancedZoneStoppedVM(cloudstackTestCase): self.assertTrue(response[0], response[1]) return - @attr(tags=["advanced", "basic"], required_hardware="False") + @attr(tags=["advanced", "basic"], required_hardware="True") def test_02_pt_deploy_vm_with_startvm_true(self): """ Positive test for stopped VM test path - T1 variant @@ -373,7 +373,7 @@ class TestAdvancedZoneStoppedVM(cloudstackTestCase): self.assertTrue(response[0], response[1]) return - @attr(tags=["advanced", "basic"], required_hardware="False") + @attr(tags=["advanced", "basic"], required_hardware="false") def test_03_pt_deploy_vm_with_startvm_false(self): """ Positive test for stopped VM test path - T2 @@ -415,7 +415,7 @@ class TestAdvancedZoneStoppedVM(cloudstackTestCase): self.assertTrue(response[0], response[1]) return - @attr(tags=["advanced", "basic"], required_hardware="False") + @attr(tags=["advanced", "basic"], required_hardware="false") def test_04_pt_startvm_false_attach_disk(self): """ Positive test for stopped VM test path - T3 and variant, T9 @@ -554,7 +554,7 @@ class TestAdvancedZoneStoppedVM(cloudstackTestCase): ) return - @attr(tags=["advanced", "basic"], required_hardware="False") + @attr(tags=["advanced", "basic"], required_hardware="false") def test_05_pt_startvm_false_attach_disk_change_SO(self): """ Positive test for stopped VM test path - T4 @@ -652,7 +652,7 @@ class TestAdvancedZoneStoppedVM(cloudstackTestCase): ) return - @attr(tags=["advanced", "basic"], required_hardware="False") + @attr(tags=["advanced", "basic"], required_hardware="True") def test_06_pt_startvm_false_attach_iso(self): """ Positive test for stopped VM test path - T5 @@ -712,7 +712,7 @@ class TestAdvancedZoneStoppedVM(cloudstackTestCase): ) return - @attr(tags=["advanced", "basic"], required_hardware="False") + @attr(tags=["advanced", "basic"], required_hardware="True") def test_07_pt_startvm_false_attach_iso_running_vm(self): """ Positive test for stopped VM test path - T5 variant @@ -780,7 +780,7 @@ class TestAdvancedZoneStoppedVM(cloudstackTestCase): ) return - @attr(tags=["advanced", "basic"], required_hardware="False") + @attr(tags=["advanced", "basic"], required_hardware="True") def test_08_pt_startvm_false_password_enabled_template(self): """ Positive test for stopped VM test path - T10 @@ -888,7 +888,7 @@ class TestAdvancedZoneStoppedVM(cloudstackTestCase): ) return - @attr(tags=["advanced", "basic"], required_hardware="False") + @attr(tags=["advanced", "basic"], required_hardware="false") def test_09_pt_destroy_stopped_vm(self): """ Positive test for stopped VM test path - T11 @@ -939,7 +939,7 @@ class TestAdvancedZoneStoppedVM(cloudstackTestCase): self.assertEqual(response[0], PASS, response[1]) return - @attr(tags=["advanced", "basic"], required_hardware="False") + @attr(tags=["advanced", "basic"], required_hardware="false") def test_10_max_account_limit(self): """ Positive test for stopped VM test path - T12 diff --git a/test/integration/testpaths/testpath_storage_migration.py b/test/integration/testpaths/testpath_storage_migration.py index 4f8ee65ccf9..892b3966feb 100644 --- a/test/integration/testpaths/testpath_storage_migration.py +++ b/test/integration/testpaths/testpath_storage_migration.py @@ -2791,7 +2791,8 @@ class TestLiveStorageMigration(cloudstackTestCase): raise Exception("Warning: Exception during cleanup : %s" % e) return - @attr(tags=["advanced", "basic"]) + @attr(tags=["advanced", "basic"], + required_hardware="True") def test_01_migrate_live(self): """ Test migrate Volume (root and data disk) diff --git a/test/integration/testpaths/testpath_vmlc.py b/test/integration/testpaths/testpath_vmlc.py index 226621fa5f3..52fbab52a98 100644 --- a/test/integration/testpaths/testpath_vmlc.py +++ b/test/integration/testpaths/testpath_vmlc.py @@ -170,6 +170,7 @@ class TestPathVMLC(cloudstackTestCase): testClient = super(TestPathVMLC, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.testdata = testClient.getParsedTestDataConfig() + cls.hypervisor = testClient.getHypervisorInfo() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) @@ -315,7 +316,7 @@ class TestPathVMLC(cloudstackTestCase): raise Exception("Warning: Exception during cleanup : %s" % e) return - @attr(tags=["advanced"], required_hardware="False") + @attr(tags=["advanced"], required_hardware="false") @data(ISOLATED_NETWORK, VPC_NETWORK) def test_01_positive_tests_vm_operations_advanced_zone(self, value): """ Positive tests for VMLC test path - Advanced Zone @@ -336,6 +337,8 @@ class TestPathVMLC(cloudstackTestCase): # 13. Find suitable host for VM to migrate and migrate the VM # 14. Verify VM accessibility on new host """ + if self.hypervisor.lower() == 'hyperv' and value == VPC_NETWORK: + self.skipTest("cann't be run for {} hypervisor".format(self.hypervisor)) # List created service offering in setUpClass by name listServiceOfferings = ServiceOffering.list( @@ -505,7 +508,7 @@ class TestPathVMLC(cloudstackTestCase): self.fail("Exception while SSHing to VM: %s" % e) return - @attr(tags=["advanced"], required_hardware="False") + @attr(tags=["advanced"], required_hardware="false") def test_01_positive_tests_vm_deploy_shared_nw(self): """ Positive tests for VMLC test path - Advanced Zone in Shared Network @@ -557,7 +560,7 @@ class TestPathVMLC(cloudstackTestCase): ) return - @attr(tags=["basic"], required_hardware="False") + @attr(tags=["basic"], required_hardware="false") def test_01_positive_tests_vm_operations_basic_zone(self): """ Positive tests for VMLC test path - Basic Zone @@ -719,7 +722,7 @@ class TestPathVMLC(cloudstackTestCase): self.fail("Exception while SSHing to VM: %s" % e) return - @attr(tags=["advanced"], required_hardware="False") + @attr(tags=["advanced"], required_hardware="false") @data(ISOLATED_NETWORK, SHARED_NETWORK, VPC_NETWORK) def test_02_negative_tests_destroy_VM_operations_advanced_zone( self, @@ -733,6 +736,8 @@ class TestPathVMLC(cloudstackTestCase): # 4. Try to stop the VM in destroyed state, operation should fail # 5. Try to reboot the VM in destroyed state, operation should fail """ + if self.hypervisor.lower() == 'hyperv' and value == VPC_NETWORK: + self.skipTest("cann't be run for {} hypervisor".format(self.hypervisor)) network = CreateNetwork(self, value) networkid = network.id @@ -769,7 +774,7 @@ class TestPathVMLC(cloudstackTestCase): return - @attr(tags=["basic"], required_hardware="False") + @attr(tags=["basic"], required_hardware="false") def test_02_negative_tests_destroy_VM_operations_basic_zone(self): """ Negative tests for VMLC test path - destroy VM @@ -812,7 +817,7 @@ class TestPathVMLC(cloudstackTestCase): return - @attr(tags=["advanced"], required_hardware="False") + @attr(tags=["advanced"], required_hardware="false") @data(ISOLATED_NETWORK, SHARED_NETWORK, VPC_NETWORK) def test_03_negative_tests_expunge_VM_operations_advanced_zone( self, @@ -827,6 +832,9 @@ class TestPathVMLC(cloudstackTestCase): # 6. Try to destroy the VM in expunging state, operation should fail # 7. Try to recover the VM in expunging state, operation should fail """ + + if self.hypervisor.lower() == 'hyperv' and value == VPC_NETWORK: + self.skipTest("cann't be run for {} hypervisor".format(self.hypervisor)) network = CreateNetwork(self, value) networkid = network.id @@ -867,7 +875,7 @@ class TestPathVMLC(cloudstackTestCase): return - @attr(tags=["basic"], required_hardware="False") + @attr(tags=["basic"], required_hardware="false") def test_03_negative_tests_expunge_VM_operations_basic_zone(self): """ Negative tests for VMLC test path - expunge VM diff --git a/test/integration/testpaths/testpath_volumelifecycle.py b/test/integration/testpaths/testpath_volumelifecycle.py index c55e36616c8..55bfc89d9df 100644 --- a/test/integration/testpaths/testpath_volumelifecycle.py +++ b/test/integration/testpaths/testpath_volumelifecycle.py @@ -37,7 +37,8 @@ from marvin.lib.utils import cleanup_resources, validateList from marvin.lib.common import (get_zone, get_domain, get_template, - list_virtual_machines) + list_virtual_machines, + find_storage_pool_type) from nose.plugins.attrib import attr import os import urllib @@ -235,7 +236,7 @@ class TestPathVolume(cloudstackTestCase): "advancedsg", "basic", ], - required_hardware="false") + required_hardware="True") def test_01_positive_path(self): """ positive test for volume life cycle @@ -819,7 +820,7 @@ class TestPathVolume(cloudstackTestCase): "advancedsg", "basic", ], - required_hardware="false") + required_hardware="True") def test_02_negative_path(self): """ negative test for volume life cycle diff --git a/tools/appliance/definitions/systemvmtemplate/install_systemvm_packages.sh b/tools/appliance/definitions/systemvmtemplate/install_systemvm_packages.sh index 1804a586568..fc90eba5c31 100644 --- a/tools/appliance/definitions/systemvmtemplate/install_systemvm_packages.sh +++ b/tools/appliance/definitions/systemvmtemplate/install_systemvm_packages.sh @@ -70,38 +70,28 @@ function install_packages() { openjdk-7-jre-headless \ iptables-persistent \ libtcnative-1 libssl-dev libapr1-dev \ - open-vm-tools \ python-flask \ haproxy \ radvd \ sharutils - ${apt_get} -t wheezy-backports install irqbalance + ${apt_get} -t wheezy-backports install irqbalance open-vm-tools # hold on installed openswan version, upgrade rest of the packages (if any) apt-mark hold openswan apt-get update apt-get -y --force-yes upgrade - # commented out installation of vmware-tools as we are using the open source open-vm-tools: - # ${apt_get} install build-essential linux-headers-`uname -r` - # df -h - # PREVDIR=$PWD - # cd /opt - # wget http://people.apache.org/~bhaisaab/cloudstack/VMwareTools-9.2.1-818201.tar.gz - # tar xzf VMwareTools-9.2.1-818201.tar.gz - # rm VMwareTools-*.tar.gz - # cd vmware-tools-distrib - # ./vmware-install.pl -d - # cd $PREV - # rm -fr /opt/vmware-tools-distrib - # apt-get -q -y --force-yes purge build-essential - - # Hyperv kvp daemon - 64bit only if [ "${arch}" == "amd64" ]; then + # Hyperv kvp daemon - 64bit only # Download the hv kvp daemon wget http://people.apache.org/~rajeshbattala/hv-kvp-daemon_3.1_amd64.deb dpkg -i hv-kvp-daemon_3.1_amd64.deb + rm -f hv-kvp-daemon_3.1_amd64.deb + # XS tools + wget https://raw.githubusercontent.com/bhaisaab/cloudstack-nonoss/master/xe-guest-utilities_6.5.0_amd64.deb + dpkg -i xe-guest-utilities_6.5.0_amd64.deb + rm -f xe-guest-utilities_6.5.0_amd64.deb fi } diff --git a/tools/devcloud4/.gitignore b/tools/devcloud4/.gitignore new file mode 100644 index 00000000000..3969b1b356b --- /dev/null +++ b/tools/devcloud4/.gitignore @@ -0,0 +1,4 @@ +tmp +cookbooks +*.lock +.vagrant \ No newline at end of file diff --git a/tools/devcloud4/README.md b/tools/devcloud4/README.md new file mode 100644 index 00000000000..00d6756b7a4 --- /dev/null +++ b/tools/devcloud4/README.md @@ -0,0 +1,101 @@ +# Devcloud 4 + +## Introduction + +The follow project aims to simplify getting a full Apache CloudStack environment running on your machine. You can either take the easy ride and run `vagrant up` in either one of the 'binary installation' directories or compile CloudStack yourself. See for instructions in the 'basic' and 'advanced' directories. + +The included VagrantFile will give you: + + - Management + - NFS Server + - MySQL Server + - Router + - * Cloudstack Management Server * (Only given in binary installation) + + - XenServer 6.2 + +## Getting started + +1. Due to the large amount of data to be pulled from the Internet, it's probably not a good idea to do this over WiFi or Mobile data. + +1. Given the amount of virtual machines this brings up it is recommended you have atleast 8gb of ram before attempting this. + +1. Ensure your system has `git` installed. + +1. When on Windows, make sure you've set the git option `autocrlf` to `false`: + + ``` + git config --global core.autocrlf false + ``` + +1. Clone the repository: + + ``` + git clone https://github.com/imduffy15/devcloud4.git + ``` + +1. Download and Install [VirtualBox](https://www.virtualbox.org/wiki/Downloads) + + On Windows7, the Xenserver VM crashed immediately after booting with a General Protection Fault. + Installing VirtualBox version 4.3.6r91406 (https://www.virtualbox.org/wiki/Download_Old_Builds_4_3) fixed the problem, but only downgrade if the latest version does not work for you. + +1. Download and install [Vagrant](https://www.vagrantup.com/downloads.html) + +1. Ensure all Vagrant Plugins are installed: + + ```bash + vagrant plugin install vagrant-berkshelf vagrant-omnibus + ``` + +1. Download and install [ChefDK](https://downloads.chef.io/chef-dk/) + +### Configure virtualbox + +1. Open virtualbox and navigate to its preferences/settings window. + +1. Click onto the network tab and then onto the host only network tab. + +1. Configure your adapters as follows: + + - On Windows, the adapternames are different, and map as follows: + - vboxnet0: VirtualBox Host-Only Ethernet Adapter + - vboxnet1: VirtualBox Host-Only Ethernet Adapter 2 + - vboxnet2: VirtualBox Host-Only Ethernet Adapter 3 + + #### For Basic Networking you only need: + + ##### vboxnet0 + - IPv4 IP address of 192.168.22.1 + - Subnet of 255.255.255.0 + - DHCP server disabled + + #### For Advanced Networking you will need: + + + + ##### vboxnet1 + - IPv4 IP address of 192.168.23.1 + - Subnet of 255.255.255.0 + - DHCP server disabled + + + + ##### vboxnet2 + - IPv4 IP address of 192.168.24.1 + - Subnet of 255.255.255.0 + - DHCP server disabled + +## Defaults + +### Management Server + + - IP: 192.168.22.5 + - Username: vagrant or root + - Password: vagrant + +### Hypervisor + + - IP: 192.168.22.10 + - Username: root + - Password: password + diff --git a/tools/devcloud4/advanced/Berksfile b/tools/devcloud4/advanced/Berksfile new file mode 100644 index 00000000000..616ca68dc24 --- /dev/null +++ b/tools/devcloud4/advanced/Berksfile @@ -0,0 +1,27 @@ +# +# 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. +# + +source "https://api.berkshelf.com" + +cookbook 'hostname' +cookbook 'selinux' +cookbook 'nat-router', git: 'http://github.com/imduffy15/cookbook_nat-router' +cookbook 'cloudstack', git: 'https://github.com/imduffy15/cookbook_cloudstack-1' +cookbook 'development-installation', path: '../common/development-installation' +cookbook 'python', git: 'https://github.com/imduffy15/python.git' diff --git a/tools/devcloud4/advanced/README.md b/tools/devcloud4/advanced/README.md new file mode 100644 index 00000000000..6171839e68a --- /dev/null +++ b/tools/devcloud4/advanced/README.md @@ -0,0 +1,95 @@ +### Configure virtualbox + +1. Open virtualbox and navigate to its preferences/settings window. + +1. Click onto the network tab and then onto the host only network tab. + +1. Configure your adapters as follows: + + ##### vboxnet0 + - IPv4 IP address of 192.168.22.1 + - Subnet of 255.255.255.0 + - DHCP server disabled + + ##### vboxnet1 + - IPv4 IP address of 192.168.23.1 + - Subnet of 255.255.255.0 + - DHCP server disabled + + ##### vboxnet2 + - IPv4 IP address of 192.168.24.1 + - Subnet of 255.255.255.0 + - DHCP server disabled + + +### Start the vagrant boxes + +```bash +vagrant up +``` + +*** Common issues: *** + +- 'Cannot forward the specified ports on this VM': There could be MySQL or some other + service running on the host OS causing vagrant to fail setting up local port forwarding. + + +### Start Cloudstack + +1. Clone the Cloudstack Repository: + + ``` + git clone https://github.com/apache/cloudstack.git + ``` + + *** Note: *** + + Personally I prefer to use the 4.3 codebase rather than master. If you wish to do the same: + + ``` + git reset --hard 0810029 + ``` + +1. Download vhd-util: + + ```bash + cd /path/to/cloudstack/repo + wget http://download.cloud.com.s3.amazonaws.com/tools/vhd-util -P scripts/vm/hypervisor/xenserver/ + chmod +x scripts/vm/hypervisor/xenserver/vhd-util + ``` + +1. Compile Cloudstack: + + ```bash + cd /path/to/cloudstack/repo + mvn -P developer,systemvm clean install -DskipTests=true + ``` + +1. Deploy Cloudstack Database: + + ```bash + cd /path/to/cloudstack/repo + mvn -P developer -pl developer,tools/devcloud4 -Ddeploydb + ``` + +1. Start Cloudstack: + + ```bash + cd /path/to/cloudstack/repo + mvn -pl :cloud-client-ui jetty:run + ``` + +1. Install Marvin: + + ``` + cd /path/to/cloudstack/repo + pip install tools/marvin/dist/Marvin-0.1.0.tar.gz + ``` + +1. Deploy: + + ``` + python -m marvin.deployDataCenter -i marvin.cfg + ``` + + diff --git a/tools/devcloud4/advanced/Vagrantfile b/tools/devcloud4/advanced/Vagrantfile new file mode 100644 index 00000000000..0bf843bcb73 --- /dev/null +++ b/tools/devcloud4/advanced/Vagrantfile @@ -0,0 +1,115 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : +# +# 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. +# + +VAGRANTFILE_API_VERSION = '2' + +Vagrant.require_version '>= 1.5.0' + +unless Vagrant.has_plugin?('vagrant-berkshelf') + raise 'vagrant-berkshelf is not installed!' +end + +unless Vagrant.has_plugin?('vagrant-omnibus') + raise 'vagrant-omnibus is not installed!' +end + +xenserver_networking_script = File.join(File.dirname(__FILE__), '../common/', 'configure-network.sh') + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + + config.vm.define 'xenserver' do |xenserver| + xenserver.vm.box = 'duffy/xenserver' + + # Public Network (IP address is ignored.) + xenserver.vm.network :private_network, :auto_config => false, :ip => '192.168.23.10' + + # Guest Network (IP address is ignored.) + xenserver.vm.network :private_network, :auto_config => false, :ip => '192.168.24.10' + + # Configure Interfaces + + ## Configure Management Interface + xenserver.vm.provision 'shell' do |s| + s.path = xenserver_networking_script + s.args = %w(eth1 192.168.22.10 255.255.255.0 MGMT) + end + + ## Configure Public Interface + xenserver.vm.provision 'shell' do |s| + s.path = xenserver_networking_script + s.args = %w(eth2 na na PUBLIC) + end + + ## Configure Guest Interface + xenserver.vm.provision 'shell' do |s| + s.path = xenserver_networking_script + s.args = %w(eth3 na na GUEST) + end + + ## Tweak kernel + xenserver.vm.provision "shell", inline: "sed -i -e 's/net.bridge.bridge-nf-call-iptables = 1/net.bridge.bridge-nf-call-iptables = 0/g' -e 's/net.bridge.bridge-nf-call-arptables = 1/net.bridge.bridge-nf-call-arptables = 0/g' /etc/sysctl.conf && /sbin/sysctl -p /etc/sysctl.conf" + + ## Map host only networks and the adapters + xenserver.vm.provider 'virtualbox' do |v| + v.customize ['modifyvm', :id, '--nicpromisc2', 'allow-all'] + v.customize ['modifyvm', :id, '--nicpromisc3', 'allow-all'] + v.customize ['modifyvm', :id, '--nicpromisc4', 'allow-all'] + v.customize ['modifyvm', :id, '--hostonlyadapter2', 'vboxnet0'] + v.customize ['modifyvm', :id, '--hostonlyadapter3', 'vboxnet1'] + v.customize ['modifyvm', :id, '--hostonlyadapter4', 'vboxnet2'] + v.customize ["modifyvm", :id, '--nictype2', 'Am79C973'] + v.customize ["modifyvm", :id, '--nictype3', 'Am79C973'] + v.customize ["modifyvm", :id, '--nictype4', 'Am79C973'] + end + end + + config.vm.define 'management' do |management| + management.vm.box = 'chef/centos-6.5' + + # Configure management interface + management.vm.network :private_network, :auto_config => true, :ip => '192.168.22.5' + + # Configure public interface + management.vm.network :private_network, :auto_config => true, :ip => '192.168.23.5' + + # Port forward MySQL + management.vm.network 'forwarded_port', guest: 3306, host: 3306 + + management.vm.provider 'virtualbox' do |v| + v.customize ['modifyvm', :id, '--memory', 512] + v.customize ['modifyvm', :id, '--hostonlyadapter2', 'vboxnet0'] + v.customize ['modifyvm', :id, '--hostonlyadapter3', 'vboxnet1'] + v.customize ["modifyvm", :id, '--nictype2', 'Am79C973'] + v.customize ["modifyvm", :id, '--nictype3', 'Am79C973'] + end + + management.omnibus.chef_version = "11.16.4" + management.berkshelf.berksfile_path = File.join(File.dirname(__FILE__), 'Berksfile') + management.berkshelf.enabled = true + + CHEF_CONFIGURATION = JSON.parse(Pathname(__FILE__).dirname.join('chef_configuration.json').read) + + management.vm.provision 'chef_solo' do |chef| + chef.run_list = CHEF_CONFIGURATION.delete('run_list') + chef.json = CHEF_CONFIGURATION + end + end +end diff --git a/tools/devcloud4/advanced/chef_configuration.json b/tools/devcloud4/advanced/chef_configuration.json new file mode 100644 index 00000000000..40d5bce3f28 --- /dev/null +++ b/tools/devcloud4/advanced/chef_configuration.json @@ -0,0 +1,24 @@ +{ + "run_list": [ + "recipe[development-installation]", + "recipe[nat-router]" + ], + "iptables": { + "lans": ["eth1", "eth2"] + }, + "set_fqdn": "*.localdomain", + "selinux": { + "state": "permissive" + }, + "cloudstack": { + "secondary": { + "path": "/exports/secondary" + }, + "primary": { + "path": "/exports/primary" + }, + "hypervisor_tpl": { + "xenserver": "http://jenkins.buildacloud.org/job/build-systemvm64-master/lastSuccessfulBuild/artifact/tools/appliance/dist/systemvm64template-master-4.6.0-xen.vhd.bz2" + } + } +} diff --git a/tools/devcloud4/advanced/marvin.cfg b/tools/devcloud4/advanced/marvin.cfg new file mode 100644 index 00000000000..9e2ac563236 --- /dev/null +++ b/tools/devcloud4/advanced/marvin.cfg @@ -0,0 +1,124 @@ +# +# 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. +# + +{ + "zones": [ + { + "name": "DevCloud-Advanced-01", + "guestcidraddress": "10.1.1.0/24", + "localstorageenabled": true, + "dns1": "8.8.8.8", + "physical_networks": [ + { + "broadcastdomainrange": "Zone", + "vlan": "100-200", + "name": "DevCloud-Network-01", + "traffictypes": [ + { + "xen": "GUEST", + "typ": "Guest" + }, + { + "xen": "MGMT", + "typ": "Management" + }, + { + "xen": "PUBLIC", + "typ": "Public" + } + ], + "providers": [ + { + "broadcastdomainrange": "ZONE", + "name": "VirtualRouter" + }, + { + "broadcastdomainrange": "ZONE", + "name": "VpcVirtualRouter" + }, + { + "broadcastdomainrange": "ZONE", + "name": "InternalLbVm" + } + ], + "isolationmethods": [ + "VLAN" + ] + } + ], + "ipranges": [ + { + "startip": "192.168.23.100", + "endip": "192.168.23.120", + "netmask": "255.255.255.0", + "vlan": "untagged", + "gateway": "192.168.23.5" + } + ], + "networktype": "Advanced", + "pods": [ + { + "startip": "192.168.22.100", + "endip": "192.168.22.120", + "name": "DevCloud-POD-01", + "netmask": "255.255.255.0", + "clusters": [ + { + "clustername": "DevCloud-CLUSTER-01", + "hypervisor": "XenServer", + "hosts": [ + { + "username": "root", + "url": "http://192.168.22.10/", + "password": "password" + } + ], + "clustertype": "CloudManaged" + } + ], + "gateway": "192.168.22.5" + } + ], + "internaldns1": "8.8.8.8", + "secondaryStorages": [ + { + "url": "nfs://192.168.22.5/exports/secondary", + "provider": "NFS", + "details": [ ] + } + ] + } + ], + "logger": { + "LogFolderPath": "/tmp/" + }, + "mgtSvr": [ + { + "mgtSvrIp": "192.168.22.1", + "port": 8096 + } + ], + "dbSvr": { + "dbSvr": "127.0.0.1", + "port": 3306, + "user": "cloud", + "passwd": "cloud", + "db": "cloud" + } +} diff --git a/tools/devcloud4/basic/Berksfile b/tools/devcloud4/basic/Berksfile new file mode 100644 index 00000000000..616ca68dc24 --- /dev/null +++ b/tools/devcloud4/basic/Berksfile @@ -0,0 +1,27 @@ +# +# 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. +# + +source "https://api.berkshelf.com" + +cookbook 'hostname' +cookbook 'selinux' +cookbook 'nat-router', git: 'http://github.com/imduffy15/cookbook_nat-router' +cookbook 'cloudstack', git: 'https://github.com/imduffy15/cookbook_cloudstack-1' +cookbook 'development-installation', path: '../common/development-installation' +cookbook 'python', git: 'https://github.com/imduffy15/python.git' diff --git a/tools/devcloud4/basic/README.md b/tools/devcloud4/basic/README.md new file mode 100644 index 00000000000..31cb62dbabc --- /dev/null +++ b/tools/devcloud4/basic/README.md @@ -0,0 +1,83 @@ +### Configure virtualbox + +1. Open virtualbox and navigate to its preferences/settings window. + +1. Click onto the network tab and then onto the host only network tab. + +1. Configure your adapters as follows: + + ##### vboxnet0 + - IPv4 IP address of 192.168.22.1 + - Subnet of 255.255.255.0 + - DHCP server disabled + + +### Start the vagrant boxes + +```bash +vagrant up +``` + +*** Common issues: *** + +- 'Cannot forward the specified ports on this VM': There could be MySQL or some other + service running on the host OS causing vagrant to fail setting up local port forwarding. + + +### Start Cloudstack + +1. Clone the Cloudstack Repository: + + ``` + git clone https://github.com/apache/cloudstack.git + ``` + + *** Note: *** + + Personally I prefer to use the 4.3 codebase rather than master. If you wish to do the same: + + ``` + git reset --hard 0810029 + ``` + +1. Download vhd-util: + + ```bash + cd /path/to/cloudstack/repo + wget http://download.cloud.com.s3.amazonaws.com/tools/vhd-util -P scripts/vm/hypervisor/xenserver/ + chmod +x scripts/vm/hypervisor/xenserver/vhd-util + ``` + +1. Compile Cloudstack: + + ```bash + cd /path/to/cloudstack/repo + mvn -P developer,systemvm clean install -DskipTests=true + ``` + +1. Deploy Cloudstack Database: + + ```bash + cd /path/to/cloudstack/repo + mvn -P developer -pl developer,tools/devcloud4 -Ddeploydb + ``` + +1. Start Cloudstack: + + ```bash + cd /path/to/cloudstack/repo + mvn -pl :cloud-client-ui jetty:run + ``` + +1. Install Marvin: + + ``` + cd /path/to/cloudstack/repo + pip install tools/marvin/dist/Marvin-4.6.0-SNAPSHOT.tar.gz --allow-external mysql-connector-python + ``` + +1. Deploying: + + ``` + python -m marvin.deployDataCenter -i marvin.cfg + ``` diff --git a/tools/devcloud4/basic/Vagrantfile b/tools/devcloud4/basic/Vagrantfile new file mode 100644 index 00000000000..5f22edc3076 --- /dev/null +++ b/tools/devcloud4/basic/Vagrantfile @@ -0,0 +1,81 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : +# +# 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. +# + +VAGRANTFILE_API_VERSION = '2' + +Vagrant.require_version '>= 1.5.0' + +unless Vagrant.has_plugin?('vagrant-berkshelf') + raise 'vagrant-berkshelf is not installed!' +end + +unless Vagrant.has_plugin?('vagrant-omnibus') + raise 'vagrant-omnibus is not installed!' +end + +xenserver_networking_script = File.join(File.dirname(__FILE__), '../common/', 'configure-network.sh') + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + + config.vm.define 'xenserver' do |xenserver| + xenserver.vm.box = 'duffy/xenserver' + + ## Map host only networks and the adapters + xenserver.vm.provider 'virtualbox' do |v| + v.customize ['modifyvm', :id, '--hostonlyadapter2', 'vboxnet0'] + v.customize ['modifyvm', :id, '--nicpromisc2', 'allow-all'] + v.customize ["modifyvm", :id, '--nictype2', 'Am79C973'] + end + + # Configure Interface + ## Configure Management Interface + xenserver.vm.provision 'shell' do |s| + s.path = xenserver_networking_script + s.args = %w(eth1 192.168.22.10 255.255.255.0 MGMT) + end + + end + + config.vm.define 'management' do |management| + management.vm.box = 'chef/centos-6.5' + + management.vm.network :private_network, :auto_config => true, :ip => '192.168.22.5' + + management.vm.network 'forwarded_port', guest: 3306, host: 3306 + + management.vm.provider 'virtualbox' do |v| + v.customize ['modifyvm', :id, '--memory', 512] + v.customize ['modifyvm', :id, '--hostonlyadapter2', 'vboxnet0'] + v.customize ["modifyvm", :id, '--nictype2', 'Am79C973'] + end + + management.omnibus.chef_version = "11.16.4" + management.berkshelf.berksfile_path = File.join(File.dirname(__FILE__), 'Berksfile') + management.berkshelf.enabled = true + + CHEF_CONFIGURATION = JSON.parse(Pathname(__FILE__).dirname.join('chef_configuration.json').read) + + management.vm.provision 'chef_solo' do |chef| + chef.run_list = CHEF_CONFIGURATION.delete('run_list') + chef.json = CHEF_CONFIGURATION + end + end +end diff --git a/tools/devcloud4/basic/chef_configuration.json b/tools/devcloud4/basic/chef_configuration.json new file mode 100644 index 00000000000..507a0dea5a8 --- /dev/null +++ b/tools/devcloud4/basic/chef_configuration.json @@ -0,0 +1,22 @@ + +{ + "run_list": [ + "recipe[development-installation]", + "recipe[nat-router]" + ], + "set_fqdn": "*.localdomain", + "selinux": { + "state": "permissive" + }, + "cloudstack": { + "secondary": { + "path": "/exports/secondary" + }, + "primary": { + "path": "/exports/primary" + }, + "hypervisor_tpl": { + "xenserver": "http://jenkins.buildacloud.org/job/build-systemvm64-master/lastSuccessfulBuild/artifact/tools/appliance/dist/systemvm64template-master-4.6.0-xen.vhd.bz2" + } + } +} diff --git a/tools/devcloud4/basic/marvin.cfg b/tools/devcloud4/basic/marvin.cfg new file mode 100644 index 00000000000..dcc1b8226a5 --- /dev/null +++ b/tools/devcloud4/basic/marvin.cfg @@ -0,0 +1,110 @@ +# +# 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. +# + +{ + "zones": [ + { + "name": "DevCloud-Basic-01", + "enabled": "True", + "physical_networks": [ + { + "broadcastdomainrange": "Zone", + "name": "Devcloud-Network-01", + "traffictypes": [ + { + "typ": "Guest" + }, + { + "typ": "Management" + } + ], + "providers": [ + { + "broadcastdomainrange": "ZONE", + "name": "VirtualRouter" + }, + { + "broadcastdomainrange": "Pod", + "name": "SecurityGroupProvider" + } + ] + } + ], + "dns2": "8.8.4.4", + "dns1": "8.8.8.8", + "securitygroupenabled": "true", + "localstorageenabled": "true", + "networktype": "Basic", + "pods": [ + { + "endip": "192.168.22.220", + "name": "DevCloud-POD-01", + "startip": "192.168.22.200", + "guestIpRanges": [ + { + "startip": "192.168.22.100", + "endip": "192.168.22.199", + "netmask": "255.255.255.0", + "gateway": "192.168.22.5" + } + ], + "netmask": "255.255.255.0", + "clusters": [ + { + "clustername": "DevCloud-CLUSTER-01", + "hypervisor": "XenServer", + "hosts": [ + { + "username": "root", + "url": "http://192.168.22.10/", + "password": "password" + } + ], + "clustertype": "CloudManaged" + } + ], + "gateway": "192.168.22.5" + } + ], + "internaldns1": "8.8.8.8", + "secondaryStorages": [ + { + "url": "nfs://192.168.22.5/exports/secondary", + "provider": "NFS" + } + ] + } + ], + "logger": { + "LogFolderPath": "/tmp/" + }, + "mgtSvr": [ + { + "mgtSvrIp": "192.168.22.1", + "port": 8096 + } + ], + "dbSvr": { + "dbSvr": "127.0.0.1", + "port": 3306, + "user": "cloud", + "passwd": "cloud", + "db": "cloud" + } +} diff --git a/tools/devcloud4/binary-installation-advanced/Berksfile b/tools/devcloud4/binary-installation-advanced/Berksfile new file mode 100644 index 00000000000..7ad09e1a382 --- /dev/null +++ b/tools/devcloud4/binary-installation-advanced/Berksfile @@ -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. +# + +source "https://api.berkshelf.com" + +cookbook 'hostname' +cookbook 'selinux' +cookbook 'nat-router', git: 'http://github.com/imduffy15/cookbook_nat-router' +cookbook 'cloudstack', git: 'https://github.com/imduffy15/cookbook_cloudstack-1' +cookbook 'binary-installation', path: '../common/binary-installation' \ No newline at end of file diff --git a/tools/devcloud4/binary-installation-advanced/Vagrantfile b/tools/devcloud4/binary-installation-advanced/Vagrantfile new file mode 100644 index 00000000000..255efc05f60 --- /dev/null +++ b/tools/devcloud4/binary-installation-advanced/Vagrantfile @@ -0,0 +1,119 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : +# +# 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. +# + +xenserver_networking_script = File.join(File.dirname(__FILE__), '../common/', 'configure-network.sh') + +is_windows = (RUBY_PLATFORM =~ /mswin|mingw|cygwin/) + +virtualbox_interface_0 = if is_windows then 'VirtualBox Host-Only Ethernet Adapter' else 'vboxnet0' end +virtualbox_interface_1 = if is_windows then 'VirtualBox Host-Only Ethernet Adapter #2' else 'vboxnet1' end +virtualbox_interface_2 = if is_windows then 'VirtualBox Host-Only Ethernet Adapter #3' else 'vboxnet2' end + +VAGRANTFILE_API_VERSION = '2' +Vagrant.require_version '>= 1.5.0' + +unless Vagrant.has_plugin?('vagrant-berkshelf') + raise 'vagrant-berkshelf is not installed!' +end + +unless Vagrant.has_plugin?('vagrant-omnibus') + raise 'vagrant-omnibus is not installed!' +end + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + + config.vm.define 'xenserver' do |xenserver| + xenserver.vm.box = 'duffy/xenserver' + + # Public Network (IP address is ignored.) + xenserver.vm.network :private_network, :auto_config => false, :ip => '192.168.23.10' + + # Guest Network (IP address is ignored.) + xenserver.vm.network :private_network, :auto_config => false, :ip => '192.168.24.10' + + ## Configure Management Interface + xenserver.vm.provision 'shell' do |s| + s.path = xenserver_networking_script + s.args = %w(eth1 192.168.22.10 255.255.255.0 MGMT) + end + + ## Configure Public Interface + xenserver.vm.provision 'shell' do |s| + s.path = xenserver_networking_script + s.args = %w(eth2 na na PUBLIC) + end + + ## Configure Guest Interface + xenserver.vm.provision 'shell' do |s| + s.path = xenserver_networking_script + s.args = %w(eth3 na na GUEST) + end + + ## Map host only networks and the adapters + xenserver.vm.provider 'virtualbox' do |v| + v.customize ['modifyvm', :id, '--nicpromisc2', 'allow-all'] + v.customize ['modifyvm', :id, '--nicpromisc3', 'allow-all'] + v.customize ['modifyvm', :id, '--nicpromisc4', 'allow-all'] + v.customize ['modifyvm', :id, '--hostonlyadapter2', virtualbox_interface_0] + v.customize ['modifyvm', :id, '--hostonlyadapter3', virtualbox_interface_1] + v.customize ['modifyvm', :id, '--hostonlyadapter4', virtualbox_interface_2] + v.customize ['modifyvm', :id, '--memory', 6144] + end + + ## Tweak kernel + xenserver.vm.provision "shell", inline: "sed -i -e 's/net.bridge.bridge-nf-call-iptables = 1/net.bridge.bridge-nf-call-iptables = 0/g' -e 's/net.bridge.bridge-nf-call-arptables = 1/net.bridge.bridge-nf-call-arptables = 0/g' /etc/sysctl.conf && /sbin/sysctl -p /etc/sysctl.conf" + end + + config.vm.define 'management' do |management| + management.vm.box = 'chef/centos-6.5' + + management.vm.network :private_network, :auto_config => true, :ip => '192.168.22.5' + management.vm.network :private_network, :auto_config => true, :ip => '192.168.23.5' + + management.vm.network 'forwarded_port', guest: 3306, host: 3306 + management.vm.network 'forwarded_port', guest: 8080, host: 8080 + + management.vm.provider 'virtualbox' do |v| + v.customize ['modifyvm', :id, '--memory', 2048] + v.customize ['modifyvm', :id, '--hostonlyadapter2', virtualbox_interface_0] + v.customize ['modifyvm', :id, '--hostonlyadapter3', virtualbox_interface_1] + end + + if Vagrant.has_plugin?('vagrant-cachier') + management.cache.scope = :box + management.cache.auto_detect = true + management.omnibus.cache_packages = true + end + + management.omnibus.chef_version = "11.16.4" + management.berkshelf.berksfile_path = File.join(File.dirname(__FILE__), 'Berksfile') + management.berkshelf.enabled = true + + + CHEF_CONFIGURATION = JSON.parse(Pathname(__FILE__).dirname.join('chef_configuration.json').read) + + management.vm.provision :chef_solo do |chef| + chef.log_level = :debug + chef.run_list = CHEF_CONFIGURATION.delete('run_list') + chef.json = CHEF_CONFIGURATION + end + end +end diff --git a/tools/devcloud4/binary-installation-advanced/chef_configuration.json b/tools/devcloud4/binary-installation-advanced/chef_configuration.json new file mode 100644 index 00000000000..ceae5d495e0 --- /dev/null +++ b/tools/devcloud4/binary-installation-advanced/chef_configuration.json @@ -0,0 +1,37 @@ +{ + "run_list": [ + "recipe[binary-installation]", + "recipe[nat-router]" + ], + "set_fqdn": "*.localdomain", + "selinux": { + "state": "permissive" + }, + "cloudstack": { + "db": { + "user": "cloud", + "password": "cloud", + "rootusername": "root", + "rootpassword": "password", + "management_server_key": "password", + "database_key": "password", + "prefill": "/vagrant/prefill.sql" + }, + "secondary": { + "path": "/exports/secondary" + }, + "primary": { + "path": "/exports/primary" + }, + "hypervisor_tpl": { + "xenserver": "http://packages.shapeblue.com/systemvmtemplate/4.5/systemvm64template-4.5-xen.vhd.bz2" + }, + "configuration": "/vagrant/marvin.cfg.erb", + "yum_repo": "http://packages.shapeblue.com/cloudstack/testing/centos/4.5/", + "apt_repo": "http://packages.shapeblue.com/cloudstack/testing/debian/4.5/", + "version": "4.5.0" + }, + "iptables": { + "lans": ["eth1", "eth2"] + } +} diff --git a/tools/devcloud4/binary-installation-advanced/marvin.cfg.erb b/tools/devcloud4/binary-installation-advanced/marvin.cfg.erb new file mode 100644 index 00000000000..6c847fb266d --- /dev/null +++ b/tools/devcloud4/binary-installation-advanced/marvin.cfg.erb @@ -0,0 +1,123 @@ +# 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. +# + +{ + "zones": [ + { + "name": "DevCloud-Advanced-01", + "guestcidraddress": "10.1.1.0/24", + "localstorageenabled": true, + "dns1": "8.8.8.8", + "physical_networks": [ + { + "broadcastdomainrange": "Zone", + "vlan": "100-200", + "name": "DevCloud-Network-01", + "traffictypes": [ + { + "xen": "GUEST", + "typ": "Guest" + }, + { + "xen": "MGMT", + "typ": "Management" + }, + { + "xen": "PUBLIC", + "typ": "Public" + } + ], + "providers": [ + { + "broadcastdomainrange": "ZONE", + "name": "VirtualRouter" + }, + { + "broadcastdomainrange": "ZONE", + "name": "VpcVirtualRouter" + }, + { + "broadcastdomainrange": "ZONE", + "name": "InternalLbVm" + } + ], + "isolationmethods": [ + "VLAN" + ] + } + ], + "ipranges": [ + { + "startip": "192.168.23.100", + "endip": "192.168.23.120", + "netmask": "255.255.255.0", + "vlan": "untagged", + "gateway": "192.168.23.5" + } + ], + "networktype": "Advanced", + "pods": [ + { + "startip": "192.168.22.100", + "endip": "192.168.22.120", + "name": "DevCloud-POD-01", + "netmask": "255.255.255.0", + "clusters": [ + { + "clustername": "DevCloud-CLUSTER-01", + "hypervisor": "XenServer", + "hosts": [ + { + "username": "root", + "url": "http://192.168.22.10/", + "password": "password" + } + ], + "clustertype": "CloudManaged" + } + ], + "gateway": "192.168.22.5" + } + ], + "internaldns1": "8.8.8.8", + "secondaryStorages": [ + { + "url": "nfs://192.168.22.5/exports/secondary", + "provider": "NFS", + "details": [ ] + } + ] + } + ], + "logger": { + "LogFolderPath": "/tmp/" + }, + "mgtSvr": [ + { + "mgtSvrIp": "<%= @management_server_ip %>", + "port": <%= @management_server_port %> + } + ], + "dbSvr": { + "dbSvr": "<%= @database_server_ip %>", + "port": <%= @database_server_port %>, + "user": "<%= @database_user %>", + "passwd": "<%= @database_password %>", + "db": "<%= @database %>" + } +} \ No newline at end of file diff --git a/tools/devcloud4/binary-installation-basic/Berksfile b/tools/devcloud4/binary-installation-basic/Berksfile new file mode 100644 index 00000000000..7ad09e1a382 --- /dev/null +++ b/tools/devcloud4/binary-installation-basic/Berksfile @@ -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. +# + +source "https://api.berkshelf.com" + +cookbook 'hostname' +cookbook 'selinux' +cookbook 'nat-router', git: 'http://github.com/imduffy15/cookbook_nat-router' +cookbook 'cloudstack', git: 'https://github.com/imduffy15/cookbook_cloudstack-1' +cookbook 'binary-installation', path: '../common/binary-installation' \ No newline at end of file diff --git a/tools/devcloud4/binary-installation-basic/Vagrantfile b/tools/devcloud4/binary-installation-basic/Vagrantfile new file mode 100644 index 00000000000..acc9be7a016 --- /dev/null +++ b/tools/devcloud4/binary-installation-basic/Vagrantfile @@ -0,0 +1,83 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : +# +# 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. +# + +xenserver_networking_script = File.join(File.dirname(__FILE__), '../common/', 'configure-network.sh') + +is_windows = (RUBY_PLATFORM =~ /mswin|mingw|cygwin/) + +virtualbox_interface_0 = if is_windows then 'VirtualBox Host-Only Ethernet Adapter' else 'vboxnet0' end + +VAGRANTFILE_API_VERSION = '2' +Vagrant.require_version '>= 1.5.0' + +unless Vagrant.has_plugin?('vagrant-berkshelf') + raise 'vagrant-berkshelf is not installed!' +end + +unless Vagrant.has_plugin?('vagrant-omnibus') + raise 'vagrant-omnibus is not installed!' +end + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + + config.vm.define 'xenserver' do |xenserver| + xenserver.vm.box = 'duffy/xenserver' + + ## Configure Management Interface + xenserver.vm.provision 'shell' do |s| + s.path = xenserver_networking_script + s.args = %w(eth1 192.168.22.10 255.255.255.0 MGMT) + end + + ## Map host only networks and the adapters + xenserver.vm.provider 'virtualbox' do |v| + v.customize ['modifyvm', :id, '--nicpromisc2', 'allow-all'] + v.customize ['modifyvm', :id, '--hostonlyadapter2', virtualbox_interface_0] + v.customize ['modifyvm', :id, '--memory', 6144] + end + end + + config.vm.define 'management' do |management| + management.vm.box = 'chef/centos-6.5' + + management.vm.network :private_network, :auto_config => true, :ip => '192.168.22.5' + + management.vm.network 'forwarded_port', guest: 3306, host: 3306 + management.vm.network 'forwarded_port', guest: 8080, host: 8080 + + management.vm.provider 'virtualbox' do |v| + v.customize ['modifyvm', :id, '--memory', 2048] + v.customize ['modifyvm', :id, '--hostonlyadapter2', virtualbox_interface_0] + end + + management.omnibus.chef_version = "11.16.4" + management.berkshelf.berksfile_path = File.join(File.dirname(__FILE__), 'Berksfile') + management.berkshelf.enabled = true + + + CHEF_CONFIGURATION = JSON.parse(Pathname(__FILE__).dirname.join('chef_configuration.json').read) + + management.vm.provision :chef_solo do |chef| + chef.run_list = CHEF_CONFIGURATION.delete('run_list') + chef.json = CHEF_CONFIGURATION + end + end +end diff --git a/tools/devcloud4/binary-installation-basic/chef_configuration.json b/tools/devcloud4/binary-installation-basic/chef_configuration.json new file mode 100644 index 00000000000..87464bf577d --- /dev/null +++ b/tools/devcloud4/binary-installation-basic/chef_configuration.json @@ -0,0 +1,34 @@ +{ + "run_list": [ + "recipe[binary-installation]", + "recipe[nat-router]" + ], + "set_fqdn": "*.localdomain", + "selinux": { + "state": "permissive" + }, + "cloudstack": { + "db": { + "user": "cloud", + "password": "cloud", + "rootusername": "root", + "rootpassword": "password", + "management_server_key": "password", + "database_key": "password", + "prefill": "/vagrant/prefill.sql" + }, + "secondary": { + "path": "/exports/secondary" + }, + "primary": { + "path": "/exports/primary" + }, + "hypervisor_tpl": { + "xenserver": "http://packages.shapeblue.com/systemvmtemplate/4.5/systemvm64template-4.5-xen.vhd.bz2" + }, + "configuration": "/vagrant/marvin.cfg.erb", + "yum_repo": "http://packages.shapeblue.com/cloudstack/testing/centos/4.5/", + "apt_repo": "http://packages.shapeblue.com/cloudstack/testing/debian/4.5/", + "version": "4.5.0" + } +} diff --git a/tools/devcloud4/binary-installation-basic/marvin.cfg.erb b/tools/devcloud4/binary-installation-basic/marvin.cfg.erb new file mode 100644 index 00000000000..62415c91ad2 --- /dev/null +++ b/tools/devcloud4/binary-installation-basic/marvin.cfg.erb @@ -0,0 +1,109 @@ +# 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. +# + +{ + "zones": [ + { + "name": "DevCloud-Basic-01", + "enabled": "True", + "physical_networks": [ + { + "broadcastdomainrange": "Zone", + "name": "Devcloud-Network-01", + "traffictypes": [ + { + "typ": "Guest" + }, + { + "typ": "Management" + } + ], + "providers": [ + { + "broadcastdomainrange": "ZONE", + "name": "VirtualRouter" + }, + { + "broadcastdomainrange": "Pod", + "name": "SecurityGroupProvider" + } + ] + } + ], + "dns2": "8.8.4.4", + "dns1": "8.8.8.8", + "securitygroupenabled": "true", + "localstorageenabled": "true", + "networktype": "Basic", + "pods": [ + { + "endip": "192.168.22.220", + "name": "DevCloud-POD-01", + "startip": "192.168.22.200", + "guestIpRanges": [ + { + "startip": "192.168.22.100", + "endip": "192.168.22.199", + "netmask": "255.255.255.0", + "gateway": "192.168.22.5" + } + ], + "netmask": "255.255.255.0", + "clusters": [ + { + "clustername": "DevCloud-CLUSTER-01", + "hypervisor": "XenServer", + "hosts": [ + { + "username": "root", + "url": "http://192.168.22.10/", + "password": "password" + } + ], + "clustertype": "CloudManaged" + } + ], + "gateway": "192.168.22.5" + } + ], + "internaldns1": "8.8.8.8", + "secondaryStorages": [ + { + "url": "nfs://192.168.22.5/exports/secondary", + "provider": "NFS" + } + ] + } + ], + "logger": { + "LogFolderPath": "/tmp/" + }, + "mgtSvr": [ + { + "mgtSvrIp": "<%= @management_server_ip %>", + "port": <%= @management_server_port %> + } + ], + "dbSvr": { + "dbSvr": "<%= @database_server_ip %>", + "port": <%= @database_server_port %>, + "user": "<%= @database_user %>", + "passwd": "<%= @database_password %>", + "db": "<%= @database %>" + } +} \ No newline at end of file diff --git a/tools/devcloud4/common/binary-installation/README.md b/tools/devcloud4/common/binary-installation/README.md new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tools/devcloud4/common/binary-installation/attributes/database_server.rb b/tools/devcloud4/common/binary-installation/attributes/database_server.rb new file mode 100644 index 00000000000..35a388f6d52 --- /dev/null +++ b/tools/devcloud4/common/binary-installation/attributes/database_server.rb @@ -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. +# + +default['mysql']['server_root_password'] = node['cloudstack']['db']['rootpassword'] +default['mysql']['allow_remote_root'] = true +default['mysql']['data_dir'] = '/data/mysql' diff --git a/tools/devcloud4/common/binary-installation/attributes/default.rb b/tools/devcloud4/common/binary-installation/attributes/default.rb new file mode 100644 index 00000000000..3b3eba0b02a --- /dev/null +++ b/tools/devcloud4/common/binary-installation/attributes/default.rb @@ -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. +# + +default['cloudstack']['db']['host'] = '127.0.0.1' +default['cloudstack']['db']['user'] = 'cloud' +default['cloudstack']['db']['password'] = 'password' +default['cloudstack']['db']['rootusername'] = 'root' +default['cloudstack']['db']['rootpassword'] = 'cloud' +default['cloudstack']['db']['management_server_key'] = 'password' +default['cloudstack']['db']['database_key'] = 'password' +default['cloudstack']['db']['prefill'] = '/vagrant/prefill.sql' + +default['cloudstack']['secondary']['host'] = node['ipaddress'] +default['cloudstack']['secondary']['path'] = '/data/secondary' +default['cloudstack']['secondary']['mgt_path'] = node['cloudstack']['secondary']['path'] + +default['cloudstack']['primary']['host'] = node['ipaddress'] +default['cloudstack']['primary']['path'] = '/data/primary' +default['cloudstack']['primary']['mgt_path'] = node['cloudstack']['primary']['path'] + + +default['cloudstack']['configuration'] = '/vagrant/marvin.cfg.erb' \ No newline at end of file diff --git a/tools/devcloud4/common/binary-installation/metadata.rb b/tools/devcloud4/common/binary-installation/metadata.rb new file mode 100644 index 00000000000..bc2f515c611 --- /dev/null +++ b/tools/devcloud4/common/binary-installation/metadata.rb @@ -0,0 +1,42 @@ +# +# 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. +# + +name 'binary-installation' +maintainer 'Ian Duffy' +maintainer_email 'ian@ianduffy.ie' +license 'Apache 2' +description 'Wrapper around several different cookbooks.' +long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) +version '0.1.0' + +depends 'mysql', '= 5.6.1' +depends 'cloudstack', '>= 3.0.0' +depends 'nfs', '>= 2.0.0' + +supports 'centos' +supports 'redhat' +supports 'debian' +supports 'ubuntu' +supports 'fedora' +supports 'oracle' + +provides 'binary-installation::default' +provides 'binary-installation::management_server' +provides 'binary-installation::database_server' +provides 'binary-installation::nfs_server' diff --git a/tools/devcloud4/common/binary-installation/recipes/database_server.rb b/tools/devcloud4/common/binary-installation/recipes/database_server.rb new file mode 100644 index 00000000000..28a374c8c7e --- /dev/null +++ b/tools/devcloud4/common/binary-installation/recipes/database_server.rb @@ -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. +# + +include_recipe 'mysql::server' +include_recipe 'mysql::client' + +include_recipe 'cloudstack::mysql_conf' + diff --git a/tools/devcloud4/common/binary-installation/recipes/default.rb b/tools/devcloud4/common/binary-installation/recipes/default.rb new file mode 100644 index 00000000000..6dcd47c5278 --- /dev/null +++ b/tools/devcloud4/common/binary-installation/recipes/default.rb @@ -0,0 +1,27 @@ +# +# 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. +# + +service 'iptables' do + action [:disable, :stop] + only_if { platform?(%w{redhat centos fedora oracle}) } +end + +include_recipe 'binary-installation::nfsshares' +include_recipe 'binary-installation::database_server' +include_recipe 'binary-installation::management_server' \ No newline at end of file diff --git a/tools/devcloud4/common/binary-installation/recipes/management_server.rb b/tools/devcloud4/common/binary-installation/recipes/management_server.rb new file mode 100644 index 00000000000..742f35f272e --- /dev/null +++ b/tools/devcloud4/common/binary-installation/recipes/management_server.rb @@ -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. +# + +include_recipe 'cloudstack::marvin' +include_recipe 'cloudstack::management_server' + +cloudstack_setup_database node['cloudstack']['db']['host'] do + root_user node['cloudstack']['db']['rootusername'] + root_password node['cloudstack']['db']['rootpassword'] + user node['cloudstack']['db']['username'] + password node['cloudstack']['db']['password'] + action :create +end + +cloudstack_prefill_database node['cloudstack']['db']['prefill'] do + ip node['cloudstack']['db']['host'] + user node['cloudstack']['db']['username'] + password node['cloudstack']['db']['password'] +end + +cloudstack_system_template 'xenserver' do + nfs_path node['cloudstack']['secondary']['path'] + nfs_server node['cloudstack']['secondary']['host'] + db_user node['cloudstack']['db']['username'] + url node['cloudstack']['hypervisor_tpl']['xenserver'] + db_password node['cloudstack']['db']['password'] + db_host node['cloudstack']['db']['host'] + action :create +end + +cloudstack_setup_management node.name + +service 'cloudstack-management' do + action [:enable, :start] +end + +cloudstack_configure_cloud node['cloudstack']['configuration'] do + database_server_ip node['cloudstack']['db']['host'] + database_user node['cloudstack']['db']['username'] + database_password node['cloudstack']['db']['password'] +end diff --git a/tools/devcloud4/common/binary-installation/recipes/nfsshares.rb b/tools/devcloud4/common/binary-installation/recipes/nfsshares.rb new file mode 100644 index 00000000000..100eab9f2e7 --- /dev/null +++ b/tools/devcloud4/common/binary-installation/recipes/nfsshares.rb @@ -0,0 +1,48 @@ +# +# 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. +# + +include_recipe 'nfs::server' + +directory node['cloudstack']['secondary']['path'] do + owner 'root' + group 'root' + action :create + recursive true +end + +nfs_export node['cloudstack']['secondary']['path'] do + network '*' + writeable true + sync false + options %w(no_root_squash no_subtree_check) +end + +directory node['cloudstack']['primary']['path'] do + owner 'root' + group 'root' + action :create + recursive true +end + +nfs_export node['cloudstack']['primary']['path'] do + network '*' + writeable true + sync false + options %w(no_root_squash no_subtree_check) +end diff --git a/tools/devcloud4/common/configure-network.sh b/tools/devcloud4/common/configure-network.sh new file mode 100644 index 00000000000..dde115dc9ab --- /dev/null +++ b/tools/devcloud4/common/configure-network.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# Usage ./reset-network.sh interface ip netmask +# +# 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. +# + +[ $# -lt 3 ] && { echo -e "Missing arguments\nUsage: ./reset-network interface ip netmask label"; exit 1; } + +. /etc/xensource-inventory + +PIF=$(/usr/bin/xe pif-introduce device=$1 host-uuid=${INSTALLATION_UUID}) + +NETWORKPIF=$(/usr/bin/xe pif-list uuid=${PIF} params="network-uuid" --minimal) +/usr/bin/xe network-param-set uuid=${NETWORKPIF} name-label=${4} + +if [ ${4} == "MGMT" ] +then + /usr/bin/xe pif-reconfigure-ip uuid=${PIF} mode=static ip=${2} netmask=${3} + /usr/bin/xe host-management-reconfigure pif-uuid=${PIF} +else + /usr/bin/xe pif-plug uuid=${PIF} +fi diff --git a/tools/devcloud4/common/development-installation/README.md b/tools/devcloud4/common/development-installation/README.md new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tools/devcloud4/common/development-installation/attributes/database_server.rb b/tools/devcloud4/common/development-installation/attributes/database_server.rb new file mode 100644 index 00000000000..314f9c1a550 --- /dev/null +++ b/tools/devcloud4/common/development-installation/attributes/database_server.rb @@ -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. +# + +default['mysql']['server_root_password'] = '' +default['mysql']['allow_remote_root'] = true +default['mysql']['data_dir'] = '/data/mysql' diff --git a/tools/devcloud4/common/development-installation/attributes/default.rb b/tools/devcloud4/common/development-installation/attributes/default.rb new file mode 100644 index 00000000000..705423b1fef --- /dev/null +++ b/tools/devcloud4/common/development-installation/attributes/default.rb @@ -0,0 +1,29 @@ +# +# 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. +# + +default['cloudstack']['secondary']['host'] = node['ipaddress'] +default['cloudstack']['secondary']['path'] = '/data/secondary' +default['cloudstack']['secondary']['mgt_path'] = node['cloudstack']['secondary']['path'] + +default['cloudstack']['primary']['host'] = node['ipaddress'] +default['cloudstack']['primary']['path'] = '/data/primary' +default['cloudstack']['primary']['mgt_path'] = node['cloudstack']['primary']['path'] + +default['cloudstack']['cloud-install-sys-tmplt'] = "#{Chef::Config['file_cache_path']}/cloud-install-sys-tmplt" +default['cloudstack']['createtmplt'] = "#{Chef::Config['file_cache_path']}/createtmplt.sh" \ No newline at end of file diff --git a/tools/devcloud4/common/development-installation/files/default/cloud-install-sys-tmplt b/tools/devcloud4/common/development-installation/files/default/cloud-install-sys-tmplt new file mode 100755 index 00000000000..313b5999e85 --- /dev/null +++ b/tools/devcloud4/common/development-installation/files/default/cloud-install-sys-tmplt @@ -0,0 +1,288 @@ +#!/usr/bin/env bash +# $Id: installrtng.sh 11251 2010-07-23 23:40:44Z abhishek $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/secondary/installrtng.sh $ + +# 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. + + +usage() { + printf "Usage: %s: -m -f [-h ] [ -s ][-u ] [-F ] [-e