From 55c1e282e390e95a2639df28e1cfd743772ee001 Mon Sep 17 00:00:00 2001 From: Prachi Damle Date: Fri, 17 May 2013 11:39:20 -0700 Subject: [PATCH 01/51] CLOUDSTACK-2102: Anti-Affinity - Even after reserved capacity has been released for a Vm in "Stopped" state , we are not allowed to deploy new Vms as part of same anti-affinity group in the last_host_id where the stopped Vm was running. Changes: Do not add the last_host_id of a Stopped VM to avoid set, if the VM has been stopped for more that capacity.skip.counting.hours time limit --- .../affinity/HostAntiAffinityProcessor.java | 31 +++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/plugins/affinity-group-processors/host-anti-affinity/src/org/apache/cloudstack/affinity/HostAntiAffinityProcessor.java b/plugins/affinity-group-processors/host-anti-affinity/src/org/apache/cloudstack/affinity/HostAntiAffinityProcessor.java index 4c2c7f1c131..6c3f57f1691 100644 --- a/plugins/affinity-group-processors/host-anti-affinity/src/org/apache/cloudstack/affinity/HostAntiAffinityProcessor.java +++ b/plugins/affinity-group-processors/host-anti-affinity/src/org/apache/cloudstack/affinity/HostAntiAffinityProcessor.java @@ -17,17 +17,24 @@ package org.apache.cloudstack.affinity; import java.util.List; +import java.util.Map; import javax.ejb.Local; import javax.inject.Inject; +import javax.naming.ConfigurationException; import org.apache.cloudstack.affinity.dao.AffinityGroupDao; import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao; +import org.apache.cloudstack.framework.messagebus.MessageSubscriber; import org.apache.log4j.Logger; +import com.cloud.configuration.Config; +import com.cloud.configuration.dao.ConfigurationDao; import com.cloud.deploy.DeploymentPlan; import com.cloud.deploy.DeploymentPlanner.ExcludeList; import com.cloud.exception.AffinityConflictException; +import com.cloud.utils.DateUtil; +import com.cloud.utils.NumbersUtil; import com.cloud.vm.VMInstanceVO; import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachineProfile; @@ -46,7 +53,10 @@ public class HostAntiAffinityProcessor extends AffinityProcessorBase implements protected AffinityGroupDao _affinityGroupDao; @Inject protected AffinityGroupVMMapDao _affinityGroupVMMapDao; - + private int _vmCapacityReleaseInterval; + @Inject + protected ConfigurationDao _configDao; + @Override public void process(VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoid) @@ -76,12 +86,14 @@ public class HostAntiAffinityProcessor extends AffinityProcessorBase implements } } else if (VirtualMachine.State.Stopped.equals(groupVM.getState()) && groupVM.getLastHostId() != null) { - avoid.addHost(groupVM.getLastHostId()); - if (s_logger.isDebugEnabled()) { - s_logger.debug("Added host " + groupVM.getLastHostId() + " to avoid set, since VM " - + groupVM.getId() + " is present on the host, in Stopped state"); + long secondsSinceLastUpdate = (DateUtil.currentGMTTime().getTime() - groupVM.getUpdateTime().getTime()) / 1000; + if (secondsSinceLastUpdate < _vmCapacityReleaseInterval) { + avoid.addHost(groupVM.getLastHostId()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Added host " + groupVM.getLastHostId() + " to avoid set, since VM " + + groupVM.getId() + " is present on the host, in Stopped state but has reserved capacity"); + } } - } } } @@ -89,5 +101,12 @@ public class HostAntiAffinityProcessor extends AffinityProcessorBase implements } } + + @Override + public boolean configure(final String name, final Map params) throws ConfigurationException { + super.configure(name, params); + _vmCapacityReleaseInterval = NumbersUtil.parseInt(_configDao.getValue(Config.CapacitySkipcountingHours.key()),3600); + return true; + } } From 31a67706e402fc73c592f871291223107ed0c21c Mon Sep 17 00:00:00 2001 From: Prachi Damle Date: Fri, 17 May 2013 14:36:23 -0700 Subject: [PATCH 02/51] CLOUDSTACK-2070: Anti-Affinity - When Vm deployment fails because of not being able to satisfy the anti-affinity rule , user should be provided with more informative message. Changes: - There is no good mechanism currently to figure out if the deployment failed due to affinity groups only - We can just hint the user that the deployment might have failed due to the affinity groups and ask to review the input --- .../InsufficientServerCapacityException.java | 11 +++++++ .../api/command/user/vm/DeployVMCmd.java | 11 +++++-- .../api/command/user/vm/StartVMCmd.java | 14 ++++++-- .../cloud/entity/api/VMEntityManagerImpl.java | 18 ++++++++++- .../cloud/vm/VirtualMachineManagerImpl.java | 32 +++++++++++++------ 5 files changed, 72 insertions(+), 14 deletions(-) diff --git a/api/src/com/cloud/exception/InsufficientServerCapacityException.java b/api/src/com/cloud/exception/InsufficientServerCapacityException.java index af34e579943..8f889fee4c5 100755 --- a/api/src/com/cloud/exception/InsufficientServerCapacityException.java +++ b/api/src/com/cloud/exception/InsufficientServerCapacityException.java @@ -27,6 +27,8 @@ public class InsufficientServerCapacityException extends InsufficientCapacityExc private static final long serialVersionUID = SerialVersionUID.InsufficientServerCapacityException; + private boolean affinityGroupsApplied = false; + public InsufficientServerCapacityException(String msg, Long clusterId) { this(msg, Cluster.class, clusterId); } @@ -34,4 +36,13 @@ public class InsufficientServerCapacityException extends InsufficientCapacityExc public InsufficientServerCapacityException(String msg, Class scope, Long id) { super(msg, scope, id); } + + public InsufficientServerCapacityException(String msg, Class scope, Long id, boolean affinityGroupsApplied) { + super(msg, scope, id); + this.affinityGroupsApplied = affinityGroupsApplied; + } + + public boolean isAffinityApplied() { + return affinityGroupsApplied; + } } diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java index b5cf9f9c054..63198a420be 100755 --- a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java @@ -51,6 +51,7 @@ import com.cloud.dc.DataCenter.NetworkType; import com.cloud.event.EventTypes; import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.InsufficientCapacityException; +import com.cloud.exception.InsufficientServerCapacityException; import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceUnavailableException; @@ -424,9 +425,15 @@ public class DeployVMCmd extends BaseAsyncCreateCmd { s_logger.warn("Exception: ", ex); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); } catch (InsufficientCapacityException ex) { + StringBuilder message = new StringBuilder(ex.getMessage()); + if (ex instanceof InsufficientServerCapacityException) { + if(((InsufficientServerCapacityException)ex).isAffinityApplied()){ + message.append(", Please check the affinity groups provided, there may not be sufficient capacity to follow them"); + } + } s_logger.info(ex); - s_logger.info(ex.getMessage(), ex); - throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage()); + s_logger.info(message.toString(), ex); + throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, message.toString()); } } else { result = _userVmService.getUserVm(getEntityId()); diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/StartVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/StartVMCmd.java index 3012780cb81..09b34d4af3c 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vm/StartVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vm/StartVMCmd.java @@ -30,10 +30,10 @@ import com.cloud.async.AsyncJob; import com.cloud.event.EventTypes; import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.InsufficientCapacityException; +import com.cloud.exception.InsufficientServerCapacityException; import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.exception.StorageUnavailableException; -import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.user.Account; import com.cloud.user.UserContext; import com.cloud.uservm.UserVm; @@ -112,7 +112,7 @@ public class StartVMCmd extends BaseAsyncCmd { } @Override - public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ResourceAllocationException { + public void execute() throws ResourceUnavailableException, ResourceAllocationException { try { UserContext.current().setEventDetails("Vm Id: " + getId()); @@ -135,6 +135,16 @@ public class StartVMCmd extends BaseAsyncCmd { } catch (ExecutionException ex) { s_logger.warn("Exception: ", ex); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); + } catch (InsufficientCapacityException ex) { + StringBuilder message = new StringBuilder(ex.getMessage()); + if (ex instanceof InsufficientServerCapacityException) { + if (((InsufficientServerCapacityException) ex).isAffinityApplied()) { + message.append(", Please check the affinity groups provided, there may not be sufficient capacity to follow them"); + } + } + s_logger.info(ex); + s_logger.info(message.toString(), ex); + throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, message.toString()); } } diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManagerImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManagerImpl.java index 25e742301cf..38ed7e63605 100755 --- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManagerImpl.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManagerImpl.java @@ -24,6 +24,7 @@ import java.util.UUID; import javax.inject.Inject; +import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao; import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO; import org.apache.cloudstack.engine.cloud.entity.api.db.VMReservationVO; import org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMEntityDao; @@ -60,6 +61,7 @@ import com.cloud.user.dao.AccountDao; import com.cloud.user.dao.UserDao; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.vm.VMInstanceVO; +import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachineManager; import com.cloud.vm.VirtualMachineProfile; import com.cloud.vm.VirtualMachineProfileImpl; @@ -111,6 +113,9 @@ public class VMEntityManagerImpl implements VMEntityManager { @Inject DeploymentPlanningManager _dpMgr; + @Inject + protected AffinityGroupVMMapDao _affinityGroupVMMapDao; + @Override public VMEntityVO loadVirtualMachine(String vmId) { // TODO Auto-generated method stub @@ -123,6 +128,16 @@ public class VMEntityManagerImpl implements VMEntityManager { } + protected boolean areAffinityGroupsAssociated(VirtualMachineProfile vmProfile) { + VirtualMachine vm = vmProfile.getVirtualMachine(); + long vmGroupCount = _affinityGroupVMMapDao.countAffinityGroupsForVm(vm.getId()); + + if (vmGroupCount > 0) { + return true; + } + return false; + } + @Override public String reserveVirtualMachine(VMEntityVO vmEntityVO, String plannerToUse, DeploymentPlan planToDeploy, ExcludeList exclude) throws InsufficientCapacityException, ResourceUnavailableException { @@ -194,7 +209,8 @@ public class VMEntityManagerImpl implements VMEntityManager { // call retry it. return UUID.randomUUID().toString(); }else{ - throw new InsufficientServerCapacityException("Unable to create a deployment for " + vmProfile, DataCenter.class, plan.getDataCenterId()); + throw new InsufficientServerCapacityException("Unable to create a deployment for " + vmProfile, + DataCenter.class, plan.getDataCenterId(), areAffinityGroupsAssociated(vmProfile)); } } diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java index d153bb2cafe..cea05675f32 100755 --- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java @@ -36,6 +36,7 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; +import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator; import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory; @@ -253,6 +254,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac protected ResourceLimitService _resourceLimitMgr; @Inject protected RulesManager rulesMgr; + @Inject + protected AffinityGroupVMMapDao _affinityGroupVMMapDao; protected List _planners; public List getPlanners() { @@ -666,6 +669,16 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac } } + protected boolean areAffinityGroupsAssociated(VirtualMachineProfile vmProfile) { + VirtualMachine vm = vmProfile.getVirtualMachine(); + long vmGroupCount = _affinityGroupVMMapDao.countAffinityGroupsForVm(vm.getId()); + + if (vmGroupCount > 0) { + return true; + } + return false; + } + @Override public T advanceStart(T vm, Map params, User caller, Account account) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException { @@ -797,7 +810,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac reuseVolume = false; continue; } - throw new InsufficientServerCapacityException("Unable to create a deployment for " + vmProfile, DataCenter.class, plan.getDataCenterId()); + throw new InsufficientServerCapacityException("Unable to create a deployment for " + vmProfile, + DataCenter.class, plan.getDataCenterId(), areAffinityGroupsAssociated(vmProfile)); } if (dest != null) { @@ -1152,7 +1166,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac } vmGuru.prepareStop(profile); - + StopCommand stop = new StopCommand(vm); boolean stopped = false; StopAnswer answer = null; @@ -2802,7 +2816,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac VirtualMachineGuru vmGuru = getVmGuru(vmVO); s_logger.debug("Plugging nic for vm " + vm + " in network " + network); - + boolean result = false; try{ result = vmGuru.plugNic(network, nicTO, vmTO, context, dest); @@ -2812,17 +2826,17 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac // insert nic's Id into DB as resource_name UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NETWORK_OFFERING_ASSIGN, vmVO.getAccountId(), vmVO.getDataCenterId(), vmVO.getId(), Long.toString(nic.getId()), nic.getNetworkId(), - null, isDefault, VirtualMachine.class.getName(), vmVO.getUuid()); + null, isDefault, VirtualMachine.class.getName(), vmVO.getUuid()); return nic; } else { s_logger.warn("Failed to plug nic to the vm " + vm + " in network " + network); return null; - } + } }finally{ if(!result){ _networkMgr.removeNic(vmProfile, _nicsDao.findById(nic.getId())); } - } + } } else if (vm.getState() == State.Stopped) { //1) allocate nic return _networkMgr.createNicForVm(network, requested, context, vmProfile, false); @@ -2863,10 +2877,10 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac s_logger.warn("Failed to remove nic from " + vm + " in " + network + ", nic is default."); throw new CloudRuntimeException("Failed to remove nic from " + vm + " in " + network + ", nic is default."); } - + // if specified nic is associated with PF/LB/Static NAT if(rulesMgr.listAssociatedRulesForGuestNic(nic).size() > 0){ - throw new CloudRuntimeException("Failed to remove nic from " + vm + " in " + network + throw new CloudRuntimeException("Failed to remove nic from " + vm + " in " + network + ", nic has associated Port forwarding or Load balancer or Static NAT rules."); } @@ -2884,7 +2898,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac s_logger.debug("Nic is unplugged successfully for vm " + vm + " in network " + network ); long isDefault = (nic.isDefaultNic()) ? 1 : 0; UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NETWORK_OFFERING_REMOVE, vm.getAccountId(), vm.getDataCenterId(), - vm.getId(), Long.toString(nic.getId()), network.getNetworkOfferingId(), null, + vm.getId(), Long.toString(nic.getId()), network.getNetworkOfferingId(), null, isDefault, VirtualMachine.class.getName(), vm.getUuid()); } else { s_logger.warn("Failed to unplug nic for the vm " + vm + " from network " + network); From 7cae8ca23102a834509f0277a378e17670992ac6 Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Fri, 17 May 2013 15:06:50 -0700 Subject: [PATCH 03/51] CLOUDSTACK-751: 41-42 DB upgrade - insert new global config blacklisted.routes --- setup/db/db/schema-410to420.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql index fe66207e5e5..c088ac1c2f0 100644 --- a/setup/db/db/schema-410to420.sql +++ b/setup/db/db/schema-410to420.sql @@ -1667,6 +1667,10 @@ CREATE TABLE `cloud`.`nic_ip_alias` ( alter table `cloud`.`vpc_gateways` add column network_acl_id bigint unsigned default 1 NOT NULL; update `cloud`.`vpc_gateways` set network_acl_id = 2; + +INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'VpcManager', 'blacklisted.routes', NULL, 'Routes that are blacklisted, can not be used for Static Routes creation for the VPC Private Gateway'); + + -- Re-enable foreign key checking, at the end of the upgrade path SET foreign_key_checks = 1; From 1851f7f7f6bb4bcf3521ea44c51e9506cb86a72d Mon Sep 17 00:00:00 2001 From: Prachi Damle Date: Fri, 17 May 2013 15:32:21 -0700 Subject: [PATCH 04/51] CLOUDSTACK-2365: Anti-Affinity - As admin , we are allowed to deploy a Vm in an affinity group that belongs to different user. CLOUDSTACK-2349: Anti-Affinity - As admin user , using updateVMAffinityGroup() , we are allowed to update the affinity group of a Vm (that belongs to a regular user) to be set to admin's affinity group. Changes: - Even for root-admin make sure that the affinity group and the VM belong to same account --- server/src/com/cloud/vm/UserVmManagerImpl.java | 8 ++++++++ .../cloudstack/affinity/AffinityGroupServiceImpl.java | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 860daaf9a5e..05ff6aa74df 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -2366,6 +2366,14 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use } else { // verify permissions _accountMgr.checkAccess(caller, null, true, owner, ag); + // Root admin has access to both VM and AG by default, but + // make sure the owner of these entities is same + if (caller.getId() == Account.ACCOUNT_ID_SYSTEM || _accountMgr.isRootAdmin(caller.getType())) { + if (ag.getAccountId() != owner.getAccountId()) { + throw new PermissionDeniedException("Affinity Group " + ag + + " does not belong to the VM's account"); + } + } } } } diff --git a/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java b/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java index fc2cfcf8d95..efe18c3b375 100644 --- a/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java +++ b/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java @@ -36,6 +36,7 @@ import com.cloud.deploy.DeploymentPlanner; import com.cloud.event.ActionEvent; import com.cloud.event.EventTypes; import com.cloud.exception.InvalidParameterValueException; +import com.cloud.exception.PermissionDeniedException; import com.cloud.exception.ResourceInUseException; import com.cloud.network.security.SecurityGroup; import com.cloud.user.Account; @@ -332,6 +333,14 @@ public class AffinityGroupServiceImpl extends ManagerBase implements AffinityGro } else { // verify permissions _accountMgr.checkAccess(caller, null, true, owner, ag); + // Root admin has access to both VM and AG by default, but make sure the + // owner of these entities is same + if (caller.getId() == Account.ACCOUNT_ID_SYSTEM || _accountMgr.isRootAdmin(caller.getType())) { + if (ag.getAccountId() != owner.getAccountId()) { + throw new PermissionDeniedException("Affinity Group " + ag + + " does not belong to the VM's account"); + } + } } } _affinityGroupVMMapDao.updateMap(vmId, affinityGroupIds); From 239bb13dde0d32ca3e05a8ea2b35a8885cb30538 Mon Sep 17 00:00:00 2001 From: Wido den Hollander Date: Sat, 18 May 2013 10:10:45 +0200 Subject: [PATCH 05/51] Better parse domain XMLs so network devices can be detached as well --- .../kvm/resource/LibvirtDomainXMLParser.java | 57 ++++++++++++------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java index ac4baf122a9..b8645e1664a 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java @@ -35,6 +35,7 @@ import org.xml.sax.InputSource; import org.xml.sax.SAXException; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef; +import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef.diskProtocol; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef.nicModel; @@ -64,31 +65,45 @@ public class LibvirtDomainXMLParser { NodeList disks = devices.getElementsByTagName("disk"); for (int i = 0; i < disks.getLength(); i++) { Element disk = (Element) disks.item(i); - String diskFmtType = getAttrValue("driver", "type", disk); - String diskFile = getAttrValue("source", "file", disk); - String diskDev = getAttrValue("source", "dev", disk); - - String diskLabel = getAttrValue("target", "dev", disk); - String bus = getAttrValue("target", "bus", disk); String type = disk.getAttribute("type"); - String device = disk.getAttribute("device"); - DiskDef def = new DiskDef(); - if (type.equalsIgnoreCase("file")) { - if (device.equalsIgnoreCase("disk")) { - DiskDef.diskFmtType fmt = null; - if (diskFmtType != null) { - fmt = DiskDef.diskFmtType.valueOf(diskFmtType - .toUpperCase()); + if (type.equalsIgnoreCase("network")) { + String diskFmtType = getAttrValue("driver", "type", disk); + String diskPath = getAttrValue("source", "name", disk); + String protocol = getAttrValue("source", "protocol", disk); + String authUserName = getAttrValue("auth", "username", disk); + String poolUuid = getAttrValue("secret", "uuid", disk); + String host = getAttrValue("host", "name", disk); + int port = Integer.parseInt(getAttrValue("host", "port", disk)); + String diskLabel = getAttrValue("target", "dev", disk); + String bus = getAttrValue("target", "bus", disk); + def.defNetworkBasedDisk(diskPath, host, port, authUserName, poolUuid, diskLabel, + DiskDef.diskBus.valueOf(bus.toUpperCase()), DiskDef.diskProtocol.valueOf(protocol.toUpperCase())); + } else { + String diskFmtType = getAttrValue("driver", "type", disk); + String diskFile = getAttrValue("source", "file", disk); + String diskDev = getAttrValue("source", "dev", disk); + + String diskLabel = getAttrValue("target", "dev", disk); + String bus = getAttrValue("target", "bus", disk); + String device = disk.getAttribute("device"); + + if (type.equalsIgnoreCase("file")) { + if (device.equalsIgnoreCase("disk")) { + DiskDef.diskFmtType fmt = null; + if (diskFmtType != null) { + fmt = DiskDef.diskFmtType.valueOf(diskFmtType + .toUpperCase()); + } + def.defFileBasedDisk(diskFile, diskLabel, + DiskDef.diskBus.valueOf(bus.toUpperCase()), fmt); + } else if (device.equalsIgnoreCase("cdrom")) { + def.defISODisk(diskFile); } - def.defFileBasedDisk(diskFile, diskLabel, - DiskDef.diskBus.valueOf(bus.toUpperCase()), fmt); - } else if (device.equalsIgnoreCase("cdrom")) { - def.defISODisk(diskFile); + } else if (type.equalsIgnoreCase("block")) { + def.defBlockBasedDisk(diskDev, diskLabel, + DiskDef.diskBus.valueOf(bus.toUpperCase())); } - } else if (type.equalsIgnoreCase("block")) { - def.defBlockBasedDisk(diskDev, diskLabel, - DiskDef.diskBus.valueOf(bus.toUpperCase())); } diskDefs.add(def); } From 806aeb990d28179ff532e97dbf64f87cd3d5ca34 Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Sat, 18 May 2013 11:46:12 +0530 Subject: [PATCH 06/51] CLOUDSTACK-2554: CloudStack fails to load XCP 1.6 hypervisors Missing default constructor fails the agent manager reloading the XCP resource on reboot of management server. This is fixed by using the default constructor as do other Xen resources and include a new resource ala XenServers for XCP1.6. Signed-off-by: Prasanna Santhanam --- .../xen/discoverer/XcpServerDiscoverer.java | 109 +++++++++--------- .../hypervisor/xen/resource/CitrixHelper.java | 4 +- .../xen/resource/XcpServer16Resource.java | 32 +++++ .../xen/resource/XcpServerResource.java | 45 +++----- 4 files changed, 107 insertions(+), 83 deletions(-) create mode 100644 plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XcpServer16Resource.java diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java index 562a7feb96f..f0121e7220b 100755 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java @@ -16,24 +16,6 @@ // under the License. package com.cloud.hypervisor.xen.discoverer; -import java.net.InetAddress; -import java.net.URI; -import java.net.UnknownHostException; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Queue; -import java.util.Set; - -import javax.ejb.Local; -import javax.inject.Inject; -import javax.naming.ConfigurationException; -import javax.persistence.EntityExistsException; - -import org.apache.log4j.Logger; -import org.apache.xmlrpc.XmlRpcException; - import com.cloud.agent.AgentManager; import com.cloud.agent.Listener; import com.cloud.agent.api.AgentControlAnswer; @@ -65,6 +47,7 @@ import com.cloud.hypervisor.Hypervisor; import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.hypervisor.xen.resource.CitrixResourceBase; import com.cloud.hypervisor.xen.resource.XcpOssResource; +import com.cloud.hypervisor.xen.resource.XcpServer16Resource; import com.cloud.hypervisor.xen.resource.XcpServerResource; import com.cloud.hypervisor.xen.resource.XenServer56FP1Resource; import com.cloud.hypervisor.xen.resource.XenServer56Resource; @@ -79,9 +62,9 @@ import com.cloud.resource.ResourceManager; import com.cloud.resource.ResourceStateAdapter; import com.cloud.resource.ServerResource; import com.cloud.resource.UnableDeleteHostException; -import com.cloud.storage.VMTemplateVO; import com.cloud.storage.Storage.ImageFormat; import com.cloud.storage.Storage.TemplateType; +import com.cloud.storage.VMTemplateVO; import com.cloud.storage.dao.VMTemplateDao; import com.cloud.storage.dao.VMTemplateHostDao; import com.cloud.user.Account; @@ -97,6 +80,22 @@ import com.xensource.xenapi.Pool; import com.xensource.xenapi.Session; import com.xensource.xenapi.Types.SessionAuthenticationFailed; import com.xensource.xenapi.Types.XenAPIException; +import org.apache.log4j.Logger; +import org.apache.xmlrpc.XmlRpcException; + +import javax.ejb.Local; +import javax.inject.Inject; +import javax.naming.ConfigurationException; +import javax.persistence.EntityExistsException; +import java.net.InetAddress; +import java.net.URI; +import java.net.UnknownHostException; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Queue; +import java.util.Set; @Local(value=Discoverer.class) public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, Listener, ResourceStateAdapter { @@ -420,6 +419,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L } else { prodBrand = prodBrand.trim(); } + String prodVersion = record.softwareVersion.get("product_version"); if (prodVersion == null) { prodVersion = record.softwareVersion.get("platform_version").trim(); @@ -427,36 +427,35 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L prodVersion = prodVersion.trim(); } - if(prodBrand.equals("XCP") && (prodVersion.equals("1.0.0") || prodVersion.equals("1.1.0") || prodVersion.equals("5.6.100") || prodVersion.startsWith("1.4"))) { - return new XcpServerResource("1.1"); + // Xen Cloud Platform group of hypervisors + if (prodBrand.equals("XCP") && ( + prodVersion.equals("1.0.0") + || prodVersion.equals("1.1.0") + || prodVersion.equals("5.6.100") + || prodVersion.startsWith("1.4") + )) { + return new XcpServerResource(); } else if (prodBrand.equals("XCP") && prodVersion.startsWith("1.6")) { - return new XcpServerResource("1.6"); - } - - if(prodBrand.equals("XenServer") && prodVersion.equals("5.6.0")) - return new XenServer56Resource(); - - if (prodBrand.equals("XenServer") && prodVersion.equals("6.0.0")) - return new XenServer600Resource(); - - if (prodBrand.equals("XenServer") && prodVersion.equals("6.0.2")) - return new XenServer602Resource(); - - if (prodBrand.equals("XenServer") && prodVersion.equals("6.1.0")) + return new XcpServer16Resource(); + } // Citrix Xenserver group of hypervisors + else if (prodBrand.equals("XenServer") && prodVersion.equals("5.6.0")) + return new XenServer56Resource(); + else if (prodBrand.equals("XenServer") && prodVersion.equals("6.0.0")) + return new XenServer600Resource(); + else if (prodBrand.equals("XenServer") && prodVersion.equals("6.0.2")) + return new XenServer602Resource(); + else if (prodBrand.equals("XenServer") && prodVersion.equals("6.1.0")) return new XenServer610Resource(); - - if(prodBrand.equals("XenServer") && prodVersion.equals("5.6.100")) { - String prodVersionTextShort = record.softwareVersion.get("product_version_text_short").trim(); - if("5.6 SP2".equals(prodVersionTextShort)) { - return new XenServer56SP2Resource(); - } else if("5.6 FP1".equals(prodVersionTextShort)) { - return new XenServer56FP1Resource(); - } - } - - if (prodBrand.equals("XCP_Kronos")) { - return new XcpOssResource(); - } + else if (prodBrand.equals("XenServer") && prodVersion.equals("5.6.100")) { + String prodVersionTextShort = record.softwareVersion.get("product_version_text_short").trim(); + if ("5.6 SP2".equals(prodVersionTextShort)) { + return new XenServer56SP2Resource(); + } else if ("5.6 FP1".equals(prodVersionTextShort)) { + return new XenServer56FP1Resource(); + } + } else if (prodBrand.equals("XCP_Kronos")) { + return new XcpOssResource(); + } String msg = "Only support XCP 1.0.0, 1.1.0, 1.4.x, 1.5 beta, 1.6.x; XenServer 5.6, XenServer 5.6 FP1, XenServer 5.6 SP2, Xenserver 6.0, 6.0.2, 6.1.0 but this one is " + prodBrand + " " + prodVersion; _alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, dcId, podId, msg, msg); @@ -585,10 +584,12 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L Map details = startup.getHostDetails(); String prodBrand = details.get("product_brand").trim(); String prodVersion = details.get("product_version").trim(); - - if(prodBrand.equals("XCP") && (prodVersion.equals("1.0.0") || prodVersion.equals("1.1.0") || prodVersion.equals("5.6.100") || prodVersion.startsWith("1.4") || prodVersion.startsWith("1.6"))) { + + if (prodBrand.equals("XCP") && (prodVersion.equals("1.0.0") || prodVersion.equals("1.1.0") || prodVersion.equals("5.6.100") || prodVersion.startsWith("1.4"))) { resource = XcpServerResource.class.getName(); - } else if(prodBrand.equals("XenServer") && prodVersion.equals("5.6.0")) { + } else if (prodBrand.equals("XCP") && prodVersion.startsWith("1.6")) { + resource = XcpServer16Resource.class.getName(); + } else if (prodBrand.equals("XenServer") && prodVersion.equals("5.6.0")) { resource = XenServer56Resource.class.getName(); } else if (prodBrand.equals("XenServer") && prodVersion.equals("6.0.0")) { resource = XenServer600Resource.class.getName(); @@ -596,15 +597,15 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L resource = XenServer602Resource.class.getName(); } else if (prodBrand.equals("XenServer") && prodVersion.equals("6.1.0")) { resource = XenServer610Resource.class.getName(); - } else if(prodBrand.equals("XenServer") && prodVersion.equals("5.6.100")) { + } else if (prodBrand.equals("XenServer") && prodVersion.equals("5.6.100")) { String prodVersionTextShort = details.get("product_version_text_short").trim(); - if("5.6 SP2".equals(prodVersionTextShort)) { + if ("5.6 SP2".equals(prodVersionTextShort)) { resource = XenServer56SP2Resource.class.getName(); - } else if("5.6 FP1".equals(prodVersionTextShort)) { + } else if ("5.6 FP1".equals(prodVersionTextShort)) { resource = XenServer56FP1Resource.class.getName(); } } else if (prodBrand.equals("XCP_Kronos")) { - resource = XcpOssResource.class.getName(); + resource = XcpOssResource.class.getName(); } if( resource == null ){ diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixHelper.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixHelper.java index 34b8f2981e2..0f71c7ba9ad 100644 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixHelper.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixHelper.java @@ -16,11 +16,11 @@ // under the License. package com.cloud.hypervisor.xen.resource; +import org.apache.log4j.Logger; + import java.util.ArrayList; import java.util.HashMap; -import org.apache.log4j.Logger; - /** * Reduce bloat inside CitrixResourceBase * diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XcpServer16Resource.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XcpServer16Resource.java new file mode 100644 index 00000000000..8cb7997305f --- /dev/null +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XcpServer16Resource.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package com.cloud.hypervisor.xen.resource; + +public class XcpServer16Resource extends XcpServerResource { + + public XcpServer16Resource() { + super(); + } + + @Override + protected String getGuestOsType(String stdType, boolean bootFromCD) { + return CitrixHelper.getXcp160GuestOsType(stdType); + } +} diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XcpServerResource.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XcpServerResource.java index 6baf6a09e3f..77dcb8f568a 100644 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XcpServerResource.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XcpServerResource.java @@ -16,15 +16,6 @@ // under the License. package com.cloud.hypervisor.xen.resource; -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import javax.ejb.Local; - -import org.apache.log4j.Logger; -import org.apache.xmlrpc.XmlRpcException; - import com.cloud.agent.api.Answer; import com.cloud.agent.api.Command; import com.cloud.agent.api.NetworkUsageAnswer; @@ -33,18 +24,25 @@ import com.cloud.resource.ServerResource; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.script.Script; import com.xensource.xenapi.Connection; -import com.xensource.xenapi.VM; import com.xensource.xenapi.Types.XenAPIException; +import com.xensource.xenapi.VM; +import org.apache.log4j.Logger; +import org.apache.xmlrpc.XmlRpcException; + +import javax.ejb.Local; +import java.io.File; +import java.util.ArrayList; +import java.util.List; @Local(value=ServerResource.class) public class XcpServerResource extends CitrixResourceBase { - private final static Logger s_logger = Logger.getLogger(XcpServerResource.class); - private String version; - public XcpServerResource(String version) { + private final static Logger s_logger = Logger.getLogger(XcpServerResource.class); + private String version; + + public XcpServerResource() { super(); - this.version = version; } - + @Override public Answer executeRequest(Command cmd) { if (cmd instanceof NetworkUsageCommand) { @@ -53,15 +51,6 @@ public class XcpServerResource extends CitrixResourceBase { return super.executeRequest(cmd); } } - - @Override - protected String getGuestOsType(String stdType, boolean bootFromCD) { - if (version.equalsIgnoreCase("1.6")) { - return CitrixHelper.getXcp160GuestOsType(stdType); - } else { - return CitrixHelper.getXcpGuestOsType(stdType); - } - } @Override protected List getPatchFiles() { @@ -76,6 +65,11 @@ public class XcpServerResource extends CitrixResourceBase { return files; } + @Override + protected String getGuestOsType(String stdType, boolean bootFromCD) { + return CitrixHelper.getXcpGuestOsType(stdType); + } + @Override protected void setMemory(Connection conn, VM vm, long minMemsize, long maxMemsize) throws XmlRpcException, XenAPIException { @@ -90,7 +84,6 @@ public class XcpServerResource extends CitrixResourceBase { //vm.setMemoryStaticMin(conn, maxMemsize ); } - protected NetworkUsageAnswer execute(NetworkUsageCommand cmd) { try { Connection conn = getConnection(); @@ -107,6 +100,4 @@ public class XcpServerResource extends CitrixResourceBase { return new NetworkUsageAnswer(cmd, ex); } } - - } From 6ea2b06aab537f34733872e65041f3499481fb59 Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Sun, 19 May 2013 15:56:30 +0530 Subject: [PATCH 07/51] Fixing multiple minor annoyances: 1. Keeping the description consistent - Memory not RAM when referring to overcommit 2. getters And setters grouped, provided right casing. 3. Removed wildcard imports Signed-off-by: Prasanna Santhanam --- .../command/admin/cluster/AddClusterCmd.java | 36 ++++++++---------- .../admin/cluster/UpdateClusterCmd.java | 6 +-- .../api/response/ClusterResponse.java | 27 ++++++------- .../src/com/cloud/api/ApiResponseHelper.java | 10 +---- .../cloud/capacity/CapacityManagerImpl.java | 20 +++++----- .../cloud/resource/ResourceManagerImpl.java | 12 +++--- .../cloud/vm/VirtualMachineManagerImpl.java | 4 +- .../cloud/vm/VirtualMachineProfileImpl.java | 38 +++++++++---------- 8 files changed, 71 insertions(+), 82 deletions(-) diff --git a/api/src/org/apache/cloudstack/api/command/admin/cluster/AddClusterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/cluster/AddClusterCmd.java index d55ccd7dd11..c6ca9bc673b 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/cluster/AddClusterCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/cluster/AddClusterCmd.java @@ -17,13 +17,11 @@ package org.apache.cloudstack.api.command.admin.cluster; -import java.util.ArrayList; -import java.util.List; - +import com.cloud.exception.DiscoveryException; import com.cloud.exception.InvalidParameterValueException; -import org.apache.cloudstack.api.*; -import org.apache.log4j.Logger; - +import com.cloud.exception.ResourceInUseException; +import com.cloud.org.Cluster; +import com.cloud.user.Account; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; @@ -36,10 +34,8 @@ import org.apache.cloudstack.api.response.PodResponse; import org.apache.cloudstack.api.response.ZoneResponse; import org.apache.log4j.Logger; -import com.cloud.exception.DiscoveryException; -import com.cloud.exception.ResourceInUseException; -import com.cloud.org.Cluster; -import com.cloud.user.Account; +import java.util.ArrayList; +import java.util.List; @APICommand(name = "addCluster", description="Adds a new cluster", responseObject=ClusterResponse.class) public class AddClusterCmd extends BaseCmd { @@ -86,10 +82,10 @@ public class AddClusterCmd extends BaseCmd { private String vsmipaddress; @Parameter (name=ApiConstants.CPU_OVERCOMMIT_RATIO, type = CommandType.STRING, required = false , description = "value of the cpu overcommit ratio, defaults to 1") - private String cpuovercommitRatio; + private String cpuOvercommitRatio; - @Parameter(name = ApiConstants.MEMORY_OVERCOMMIT_RATIO, type = CommandType.STRING, required = false ,description = "value of the default ram overcommit ratio, defaults to 1") - private String memoryovercommitratio; + @Parameter(name = ApiConstants.MEMORY_OVERCOMMIT_RATIO, type = CommandType.STRING, required = false, description = "value of the default memory overcommit ratio, defaults to 1") + private String memoryOvercommitRatio; @Parameter(name = ApiConstants.VSWITCH_TYPE_GUEST_TRAFFIC, type = CommandType.STRING, required = false, description = "Type of virtual switch used for guest traffic in the cluster. Allowed values are, vmwaresvs (for VMware standard vSwitch) and vmwaredvs (for VMware distributed vSwitch)") private String vSwitchTypeGuestTraffic; @@ -186,15 +182,15 @@ public class AddClusterCmd extends BaseCmd { } public Float getCpuOvercommitRatio (){ - if(cpuovercommitRatio != null){ - return Float.parseFloat(cpuovercommitRatio); + if(cpuOvercommitRatio != null){ + return Float.parseFloat(cpuOvercommitRatio); } return 1.0f; } - public Float getMemoryOvercommitRaito (){ - if (memoryovercommitratio != null){ - return Float.parseFloat(memoryovercommitratio); + public Float getMemoryOvercommitRatio(){ + if (memoryOvercommitRatio != null){ + return Float.parseFloat(memoryOvercommitRatio); } return 1.0f; } @@ -202,8 +198,8 @@ public class AddClusterCmd extends BaseCmd { @Override public void execute(){ try { - if ((getMemoryOvercommitRaito().compareTo(1f) < 0) | (getCpuOvercommitRatio().compareTo(1f) < 0)) { - throw new InvalidParameterValueException("Cpu and ram overcommit ratios should not be less than 1"); + if (getMemoryOvercommitRatio().compareTo(1f) < 0 || getCpuOvercommitRatio().compareTo(1f) < 0) { + throw new InvalidParameterValueException("cpu and memory overcommit ratios should be greater than or equal to one"); } List result = _resourceService.discoverCluster(this); ListResponse response = new ListResponse(); diff --git a/api/src/org/apache/cloudstack/api/command/admin/cluster/UpdateClusterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/cluster/UpdateClusterCmd.java index c5130587ec5..a14f9055211 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/cluster/UpdateClusterCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/cluster/UpdateClusterCmd.java @@ -57,7 +57,7 @@ public class UpdateClusterCmd extends BaseCmd { @Parameter(name=ApiConstants.CPU_OVERCOMMIT_RATIO, type = CommandType.STRING, description = "Value of cpu overcommit ratio") private String cpuovercommitratio; - @Parameter(name=ApiConstants.MEMORY_OVERCOMMIT_RATIO, type = CommandType.STRING, description = "Value of ram overcommit ratio") + @Parameter(name=ApiConstants.MEMORY_OVERCOMMIT_RATIO, type = CommandType.STRING, description = "Value of memory overcommit ratio") private String memoryovercommitratio; @@ -129,13 +129,13 @@ public class UpdateClusterCmd extends BaseCmd { } if (getMemoryOvercommitRaito() !=null){ if ((getMemoryOvercommitRaito().compareTo(1f) < 0)) { - throw new InvalidParameterValueException("Memory overcommit ratio should be greater than or equal to one"); + throw new InvalidParameterValueException("Memory overcommit ratio should be greater than or equal to one"); } } if (getCpuOvercommitRatio() !=null){ if (getCpuOvercommitRatio().compareTo(1f) < 0) { - throw new InvalidParameterValueException("Cpu overcommit ratio should be greater than or equal to one"); + throw new InvalidParameterValueException("Cpu overcommit ratio should be greater than or equal to one"); } } diff --git a/api/src/org/apache/cloudstack/api/response/ClusterResponse.java b/api/src/org/apache/cloudstack/api/response/ClusterResponse.java index cfd772d7115..ef8cca65040 100644 --- a/api/src/org/apache/cloudstack/api/response/ClusterResponse.java +++ b/api/src/org/apache/cloudstack/api/response/ClusterResponse.java @@ -16,16 +16,15 @@ // under the License. package org.apache.cloudstack.api.response; -import java.util.ArrayList; -import java.util.List; - +import com.cloud.org.Cluster; +import com.cloud.serializer.Param; +import com.google.gson.annotations.SerializedName; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseResponse; import org.apache.cloudstack.api.EntityReference; -import com.cloud.org.Cluster; -import com.cloud.serializer.Param; -import com.google.gson.annotations.SerializedName; +import java.util.ArrayList; +import java.util.List; @EntityReference(value = Cluster.class) public class ClusterResponse extends BaseResponse { @@ -68,7 +67,7 @@ public class ClusterResponse extends BaseResponse { @SerializedName("cpuovercommitratio") @Param(description = "The cpu overcommit ratio of the cluster") private String cpuovercommitratio; - @SerializedName("memoryovercommitratio") @Param (description = "The ram overcommit ratio of the cluster") + @SerializedName("memoryovercommitratio") @Param (description = "The memory overcommit ratio of the cluster") private String memoryovercommitratio; public String getId() { @@ -162,18 +161,20 @@ public class ClusterResponse extends BaseResponse { public void setCapacitites(ArrayList arrayList) { this.capacitites = arrayList; } - public void setCpuovercommitratio(String cpuovercommitratio){ + + public void setCpuOvercommitRatio(String cpuovercommitratio){ this.cpuovercommitratio= cpuovercommitratio; } - public void setRamovercommitratio (String memoryOvercommitRatio){ - this.memoryovercommitratio= memoryOvercommitRatio; - } - public String getCpuovercommitratio (){ + public String getCpuOvercommitRatio(){ return cpuovercommitratio; } - public String getRamovercommitratio (){ + public void setMemoryOvercommitRatio(String memoryovercommitratio){ + this.memoryovercommitratio= memoryovercommitratio; + } + + public String getMemoryOvercommitRatio(){ return memoryovercommitratio; } } diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index 482594dd8f1..49e36dc47db 100755 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -40,12 +40,6 @@ import com.cloud.network.vpc.PrivateGateway; import com.cloud.network.vpc.StaticRoute; import com.cloud.network.vpc.Vpc; import com.cloud.network.vpc.VpcOffering; -import com.cloud.vm.*; -import com.cloud.network.vpc.NetworkACL; -import com.cloud.network.vpc.PrivateGateway; -import com.cloud.network.vpc.StaticRoute; -import com.cloud.network.vpc.Vpc; -import com.cloud.network.vpc.VpcOffering; import org.apache.cloudstack.acl.ControlledEntity; import org.apache.cloudstack.acl.ControlledEntity.ACLType; import org.apache.cloudstack.affinity.AffinityGroup; @@ -975,8 +969,8 @@ public class ApiResponseHelper implements ResponseGenerator { clusterResponse.setManagedState(cluster.getManagedState().toString()); String cpuOvercommitRatio=ApiDBUtils.findClusterDetails(cluster.getId(),"cpuOvercommitRatio").getValue(); String memoryOvercommitRatio=ApiDBUtils.findClusterDetails(cluster.getId(),"memoryOvercommitRatio").getValue(); - clusterResponse.setCpuovercommitratio(cpuOvercommitRatio); - clusterResponse.setRamovercommitratio(memoryOvercommitRatio); + clusterResponse.setCpuOvercommitRatio(cpuOvercommitRatio); + clusterResponse.setMemoryOvercommitRatio(memoryOvercommitRatio); if (showCapacities != null && showCapacities) { diff --git a/server/src/com/cloud/capacity/CapacityManagerImpl.java b/server/src/com/cloud/capacity/CapacityManagerImpl.java index 2f82b6875b3..e58ae4079bc 100755 --- a/server/src/com/cloud/capacity/CapacityManagerImpl.java +++ b/server/src/com/cloud/capacity/CapacityManagerImpl.java @@ -177,10 +177,10 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, ServiceOfferingVO svo = _offeringsDao.findById(vm.getServiceOfferingId()); CapacityVO capacityCpu = _capacityDao.findByHostIdType(hostId, CapacityVO.CAPACITY_TYPE_CPU); CapacityVO capacityMemory = _capacityDao.findByHostIdType(hostId, CapacityVO.CAPACITY_TYPE_MEMORY); - Long clusterId=null; + Long clusterId = null; if (hostId != null) { - HostVO host = _hostDao.findById(hostId); - clusterId= host.getClusterId(); + HostVO host = _hostDao.findById(hostId); + clusterId = host.getClusterId(); } if (capacityCpu == null || capacityMemory == null || svo == null) { return false; @@ -263,8 +263,8 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, long hostId = vm.getHostId(); HostVO host = _hostDao.findById(hostId); long clusterId = host.getClusterId(); - float cpuOvercommitRatio =Float.parseFloat(_clusterDetailsDao.findDetail(clusterId,"cpuOvercommitRatio").getValue()); - float memoryOvercommitRatio = Float.parseFloat(_clusterDetailsDao.findDetail(clusterId,"memoryOvercommitRatio").getValue()); + float cpuOvercommitRatio = Float.parseFloat(_clusterDetailsDao.findDetail(clusterId, "cpuOvercommitRatio").getValue()); + float memoryOvercommitRatio = Float.parseFloat(_clusterDetailsDao.findDetail(clusterId, "memoryOvercommitRatio").getValue()); ServiceOfferingVO svo = _offeringsDao.findById(vm.getServiceOfferingId()); @@ -348,7 +348,7 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, } @Override - public boolean checkIfHostHasCapacity(long hostId, Integer cpu, long ram, boolean checkFromReservedCapacity, float cpuOvercommitRatio,float memoryOvercommitRatio, boolean considerReservedCapacity) { + public boolean checkIfHostHasCapacity(long hostId, Integer cpu, long ram, boolean checkFromReservedCapacity, float cpuOvercommitRatio, float memoryOvercommitRatio, boolean considerReservedCapacity) { boolean hasCapacity = false; if (s_logger.isDebugEnabled()) { @@ -381,7 +381,7 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, long actualTotalCpu = capacityCpu.getTotalCapacity(); long actualTotalMem = capacityMem.getTotalCapacity(); long totalCpu = (long) (actualTotalCpu * cpuOvercommitRatio ); - long totalMem = (long) (actualTotalMem *memoryOvercommitRatio ); + long totalMem = (long) (actualTotalMem * memoryOvercommitRatio); if (s_logger.isDebugEnabled()) { s_logger.debug("Hosts's actual total CPU: " + actualTotalCpu + " and CPU after applying overprovisioning: " + totalCpu); } @@ -744,8 +744,8 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, capacityCPU.addAnd("podId", SearchCriteria.Op.EQ, server.getPodId()); capacityCPU.addAnd("capacityType", SearchCriteria.Op.EQ, CapacityVO.CAPACITY_TYPE_CPU); List capacityVOCpus = _capacityDao.search(capacitySC, null); - Float cpuovercommitratio = Float.parseFloat(_clusterDetailsDao.findDetail(server.getClusterId(),"cpuOvercommitRatio").getValue()); - Float memoryOvercommitRatio = Float.parseFloat(_clusterDetailsDao.findDetail(server.getClusterId(),"memoryOvercommitRatio").getValue()); + Float cpuovercommitratio = Float.parseFloat(_clusterDetailsDao.findDetail(server.getClusterId(), "cpuOvercommitRatio").getValue()); + Float memoryOvercommitRatio = Float.parseFloat(_clusterDetailsDao.findDetail(server.getClusterId(), "memoryOvercommitRatio").getValue()); if (capacityVOCpus != null && !capacityVOCpus.isEmpty()) { CapacityVO CapacityVOCpu = capacityVOCpus.get(0); @@ -778,7 +778,7 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, if (capacityVOMems != null && !capacityVOMems.isEmpty()) { CapacityVO CapacityVOMem = capacityVOMems.get(0); - long newTotalMem = (long)((server.getTotalMemory())* memoryOvercommitRatio); + long newTotalMem = (long) ((server.getTotalMemory()) * memoryOvercommitRatio); if (CapacityVOMem.getTotalCapacity() <= newTotalMem || (CapacityVOMem.getUsedCapacity() + CapacityVOMem.getReservedCapacity() <= newTotalMem)) { CapacityVOMem.setTotalCapacity(newTotalMem); diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java index c60f0953a78..25f451e7127 100755 --- a/server/src/com/cloud/resource/ResourceManagerImpl.java +++ b/server/src/com/cloud/resource/ResourceManagerImpl.java @@ -505,10 +505,10 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, clusterId = cluster.getId(); result.add(cluster); - ClusterDetailsVO cluster_detail_cpu = new ClusterDetailsVO(clusterId, "cpuOvercommitRatio", Float.toString(cmd.getCpuOvercommitRatio())); - ClusterDetailsVO cluster_detail_ram = new ClusterDetailsVO(clusterId, "memoryOvercommitRatio", Float.toString(cmd.getMemoryOvercommitRaito())); - _clusterDetailsDao.persist(cluster_detail_cpu); - _clusterDetailsDao.persist(cluster_detail_ram); + ClusterDetailsVO cluster_detail_cpu = new ClusterDetailsVO(clusterId, "cpuOvercommitRatio", Float.toString(cmd.getCpuOvercommitRatio())); + ClusterDetailsVO cluster_detail_ram = new ClusterDetailsVO(clusterId, "memoryOvercommitRatio", Float.toString(cmd.getMemoryOvercommitRatio())); + _clusterDetailsDao.persist(cluster_detail_cpu); + _clusterDetailsDao.persist(cluster_detail_ram); if (clusterType == Cluster.ClusterType.CloudManaged) { return result; @@ -530,8 +530,8 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, } - if(cmd.getMemoryOvercommitRaito().compareTo(1f) > 0) { - cluster_detail_ram = new ClusterDetailsVO(clusterId, "memoryOvercommitRatio", Float.toString(cmd.getMemoryOvercommitRaito())); + if(cmd.getMemoryOvercommitRatio().compareTo(1f) > 0) { + cluster_detail_ram = new ClusterDetailsVO(clusterId, "memoryOvercommitRatio", Float.toString(cmd.getMemoryOvercommitRatio())); _clusterDetailsDao.persist(cluster_detail_ram); } diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java index cea05675f32..58d95ab81a1 100755 --- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java @@ -824,8 +824,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac Long cluster_id = dest.getCluster().getId(); ClusterDetailsVO cluster_detail_cpu = _clusterDetailsDao.findDetail(cluster_id,"cpuOvercommitRatio"); ClusterDetailsVO cluster_detail_ram = _clusterDetailsDao.findDetail(cluster_id,"memoryOvercommitRatio"); - vmProfile.setcpuOvercommitRatio(Float.parseFloat(cluster_detail_cpu.getValue())); - vmProfile.setramOvercommitRatio(Float.parseFloat(cluster_detail_ram.getValue())); + vmProfile.setCpuOvercommitRatio(Float.parseFloat(cluster_detail_cpu.getValue())); + vmProfile.setMemoryOvercommitRatio(Float.parseFloat(cluster_detail_ram.getValue())); try { if (!changeState(vm, Event.OperationRetry, destHostId, work, Step.Prepare)) { diff --git a/server/src/com/cloud/vm/VirtualMachineProfileImpl.java b/server/src/com/cloud/vm/VirtualMachineProfileImpl.java index 24f44cb07ac..e777d5ef498 100644 --- a/server/src/com/cloud/vm/VirtualMachineProfileImpl.java +++ b/server/src/com/cloud/vm/VirtualMachineProfileImpl.java @@ -16,12 +16,6 @@ // under the License. package com.cloud.vm; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - - import com.cloud.agent.api.to.VolumeTO; import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.offering.ServiceOffering; @@ -34,6 +28,11 @@ import com.cloud.template.VirtualMachineTemplate.BootloaderType; import com.cloud.user.Account; import com.cloud.user.dao.AccountDao; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + /** * Implementation of VirtualMachineProfile. * @@ -239,28 +238,27 @@ public class VirtualMachineProfileImpl implements Virtua return _params; } - public void setServiceOffering(ServiceOfferingVO offering) { - _offering = offering; - } + public void setServiceOffering(ServiceOfferingVO offering) { + _offering = offering; + } - public void setcpuOvercommitRatio(Float cpuOvercommitRatio){ - this.cpuOvercommitRatio= cpuOvercommitRatio; + public void setCpuOvercommitRatio(Float cpuOvercommitRatio) { + this.cpuOvercommitRatio = cpuOvercommitRatio; } - public void setramOvercommitRatio(Float memoryOvercommitRatio){ - this.memoryOvercommitRatio= memoryOvercommitRatio; + public void setMemoryOvercommitRatio(Float memoryOvercommitRatio) { + this.memoryOvercommitRatio = memoryOvercommitRatio; } - @Override - public Float getCpuOvercommitRatio(){ - return this.cpuOvercommitRatio; - } @Override - public Float getMemoryOvercommitRatio(){ + public Float getCpuOvercommitRatio() { + return this.cpuOvercommitRatio; + } + + @Override + public Float getMemoryOvercommitRatio() { return this.memoryOvercommitRatio; } - - } From 7ea2c950f5c1c2446ae94087d7f78812cc94a658 Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Sun, 19 May 2013 16:07:18 +0530 Subject: [PATCH 08/51] CLOUDSTACK-2554: Ensuring that we honor hypervisor xen's memory constraints When setting memory constraints on Xen guests we should honor: static-min <= dynamic-min <= dynamic-max <= static-max Our VmSpec while allows the guests to like between dynamic-min and dynamic-max the memory set by the resource set the static min to be equal to the dynamic max. This restricts the hypervisor from ensuring optimized memory handling of guests. see: http://wiki.xen.org/wiki/XCP_FAQ_Dynamic_Memory_Control#How_does_XCP_choose_targets_for_guests_in_dynamic_range_mode.3F Another fix was related the restrict_dmc option. when enabled (true) this option disallows scaling a vm. The logic was reverse handled allowing scaling when restrict_dmc was on. This control flow is now fixed. Signed-off-by: Prasanna Santhanam --- .../xen/resource/CitrixResourceBase.java | 25 ++++++- .../xen/resource/XcpServerResource.java | 73 +++++++++++++++---- .../xen/resource/XenServer56FP1Resource.java | 36 +++++---- 3 files changed, 98 insertions(+), 36 deletions(-) diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index a1663473894..78bca32c92e 100644 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -335,6 +335,9 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe long _xs_memory_used = 128 * 1024 * 1024L; // xen hypervisor used 128 M double _xs_virtualization_factor = 63.0/64.0; // 1 - virtualization overhead + //static min values for guests on xen + private static final long mem_128m = 134217728L; + protected boolean _canBridgeFirewall = false; protected boolean _isOvs = false; protected List _tmpDom0Vif = new ArrayList(); @@ -1208,8 +1211,11 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe } Set templates = VM.getByNameLabel(conn, guestOsTypeName); assert templates.size() == 1 : "Should only have 1 template but found " + templates.size(); + if (!templates.iterator().hasNext()) { + throw new CloudRuntimeException("No matching OS type found for starting a [" + vmSpec.getOs() + + "] VM on host " + host.getHostname(conn)); + } VM template = templates.iterator().next(); - VM vm = template.createClone(conn, vmSpec.getName()); VM.Record vmr = vm.getRecord(conn); if (s_logger.isDebugEnabled()) { @@ -3503,8 +3509,21 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe } } + /** + * WARN: static-min <= dynamic-min <= dynamic-max <= static-max + * @see XcpServerResource#setMemory(com.xensource.xenapi.Connection, com.xensource.xenapi.VM, long, long) + * @param conn + * @param vm + * @param minMemsize + * @param maxMemsize + * @throws XmlRpcException + * @throws XenAPIException + */ protected void setMemory(Connection conn, VM vm, long minMemsize, long maxMemsize) throws XmlRpcException, XenAPIException { - vm.setMemoryLimits(conn, maxMemsize, maxMemsize, minMemsize, maxMemsize); + vm.setMemoryStaticMin(conn, mem_128m); + vm.setMemoryDynamicMin(conn, minMemsize); + vm.setMemoryDynamicMax(conn, maxMemsize); + vm.setMemoryStaticMax(conn, maxMemsize); } protected void waitForTask(Connection c, Task task, long pollInterval, long timeout) throws XenAPIException, XmlRpcException { @@ -4299,7 +4318,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe * @throws XenAPIException * @throws XmlRpcException * - * @see enableVlanNetwork + * @see CitrixResourceBase#enableVlanNetwork */ protected XsLocalNetwork getNetworkByName(Connection conn, String name) throws XenAPIException, XmlRpcException { Set networks = Network.getByNameLabel(conn, name); diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XcpServerResource.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XcpServerResource.java index 77dcb8f568a..7df4c46a63d 100644 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XcpServerResource.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XcpServerResource.java @@ -37,6 +37,8 @@ import java.util.List; @Local(value=ServerResource.class) public class XcpServerResource extends CitrixResourceBase { private final static Logger s_logger = Logger.getLogger(XcpServerResource.class); + private static final long mem_32m = 33554432L; + private String version; public XcpServerResource() { @@ -70,20 +72,6 @@ public class XcpServerResource extends CitrixResourceBase { return CitrixHelper.getXcpGuestOsType(stdType); } - @Override - protected void setMemory(Connection conn, VM vm, long minMemsize, long maxMemsize) throws XmlRpcException, XenAPIException { - - vm.setMemoryStaticMin(conn, 33554432L); - //vm.setMemoryDynamicMin(conn, 33554432L); - //vm.setMemoryDynamicMax(conn, 33554432L); - vm.setMemoryStaticMax(conn, 33554432L); - - //vm.setMemoryStaticMax(conn, maxMemsize ); - vm.setMemoryDynamicMax(conn, maxMemsize ); - vm.setMemoryDynamicMin(conn, minMemsize ); - //vm.setMemoryStaticMin(conn, maxMemsize ); - } - protected NetworkUsageAnswer execute(NetworkUsageCommand cmd) { try { Connection conn = getConnection(); @@ -100,4 +88,61 @@ public class XcpServerResource extends CitrixResourceBase { return new NetworkUsageAnswer(cmd, ex); } } + + /** + XCP provides four memory configuration fields through which + administrators can control this behaviour: + + * static-min + * dynamic-min + * dynamic-max + * static-max + + The fields static-{min,max} act as *hard* lower and upper + bounds for a guest's memory. For a running guest: + * it's not possible to assign the guest more memory than + static-max without first shutting down the guest. + * it's not possible to assign the guest less memory than + static-min without first shutting down the guest. + + The fields dynamic-{min,max} act as *soft* lower and upper + bounds for a guest's memory. It's possible to change these + fields even when a guest is running. + + The dynamic range must lie wholly within the static range. To + put it another way, XCP at all times ensures that: + + static-min <= dynamic-min <= dynamic-max <= static-max + + At all times, XCP will attempt to keep a guest's memory usage + between dynamic-min and dynamic-max. + + If dynamic-min = dynamic-max, then XCP will attempt to keep + a guest's memory allocation at a constant size. + + If dynamic-min < dynamic-max, then XCP will attempt to give + the guest as much memory as possible, while keeping the guest + within dynamic-min and dynamic-max. + + If there is enough memory on a given host to give all resident + guests dynamic-max, then XCP will attempt do so. + + If there is not enough memory to give all guests dynamic-max, + then XCP will ask each of the guests (on that host) to use + an amount of memory that is the same *proportional* distance + between dynamic-min and dynamic-max. + + XCP will refuse to start guests if starting those guests would + cause the sum of all the dynamic-min values to exceed the total + host memory (taking into account various memory overheads). + + cf: http://wiki.xen.org/wiki/XCP_FAQ_Dynamic_Memory_Control + */ + @Override + protected void setMemory(Connection conn, VM vm, long minMemsize, long maxMemsize) throws XmlRpcException, XenAPIException { + vm.setMemoryStaticMin(conn, mem_32m); + vm.setMemoryDynamicMin(conn, minMemsize); + vm.setMemoryDynamicMax(conn, maxMemsize); + vm.setMemoryStaticMax(conn, maxMemsize); + } } diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java index 24cb75cbf93..ad412c1e3d0 100644 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java @@ -17,18 +17,6 @@ package com.cloud.hypervisor.xen.resource; -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.ejb.Local; -import org.apache.log4j.Logger; -import org.apache.xmlrpc.XmlRpcException; - import com.cloud.agent.api.FenceAnswer; import com.cloud.agent.api.FenceCommand; import com.cloud.agent.api.to.VirtualMachineTO; @@ -39,13 +27,23 @@ import com.cloud.template.VirtualMachineTemplate.BootloaderType; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.script.Script; import com.xensource.xenapi.Connection; -import com.xensource.xenapi.Console; import com.xensource.xenapi.Host; import com.xensource.xenapi.Types; +import com.xensource.xenapi.Types.XenAPIException; import com.xensource.xenapi.VBD; import com.xensource.xenapi.VDI; import com.xensource.xenapi.VM; -import com.xensource.xenapi.Types.XenAPIException; +import org.apache.log4j.Logger; +import org.apache.xmlrpc.XmlRpcException; + +import javax.ejb.Local; +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; @Local(value=ServerResource.class) public class XenServer56FP1Resource extends XenServer56Resource { @@ -137,17 +135,17 @@ public class XenServer56FP1Resource extends XenServer56Resource { record.nameLabel = vmSpec.getName(); record.actionsAfterCrash = Types.OnCrashBehaviour.DESTROY; record.actionsAfterShutdown = Types.OnNormalExit.DESTROY; - record.memoryDynamicMax = vmSpec.getMaxRam(); record.memoryDynamicMin = vmSpec.getMinRam(); + record.memoryDynamicMax = vmSpec.getMaxRam(); Map hostParams = new HashMap(); hostParams = host.getLicenseParams(conn); if (hostParams.get("restrict_dmc").equalsIgnoreCase("false")) { - record.memoryStaticMax = 8589934592L; //8GB - record.memoryStaticMin = 134217728L; //128MB + record.memoryStaticMin = vmSpec.getMinRam(); + record.memoryStaticMax = vmSpec.getMaxRam(); } else { s_logger.warn("Host "+ _host.uuid + " does not support Dynamic Memory Control, so we cannot scale up the vm"); - record.memoryStaticMax = vmSpec.getMaxRam(); - record.memoryStaticMin = vmSpec.getMinRam(); + record.memoryStaticMin = 134217728L; //128MB + record.memoryStaticMax = 8589934592L; //8GB } if (guestOsTypeName.toLowerCase().contains("windows")) { From 85d54cd1c088997dd08f0328984bee1a55703636 Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Sun, 19 May 2013 16:12:31 +0530 Subject: [PATCH 09/51] CLOUDSTACK-2554: Incorrect compute of minmemory and cpu 23e54bb0 introduced multiple hypervisors support for cpu and memory overcommit. Here the HypervisorGuru base which determines the min, max range for the memory for all hypervisors computes the minCpu using the MemoryOverCommit ratio and minMemory using the CpuOverCommit ratio. Minor typo/logic issue but massive damage across all HV if enabled ;) Signed-off-by: Prasanna Santhanam --- .../hypervisor/xen/resource/CitrixResourceBase.java | 5 +---- .../hypervisor/xen/resource/XcpServerResource.java | 11 +++++++---- .../src/com/cloud/hypervisor/HypervisorGuruBase.java | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index 78bca32c92e..19444cccfbc 100644 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -3520,10 +3520,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe * @throws XenAPIException */ protected void setMemory(Connection conn, VM vm, long minMemsize, long maxMemsize) throws XmlRpcException, XenAPIException { - vm.setMemoryStaticMin(conn, mem_128m); - vm.setMemoryDynamicMin(conn, minMemsize); - vm.setMemoryDynamicMax(conn, maxMemsize); - vm.setMemoryStaticMax(conn, maxMemsize); + vm.setMemoryLimits(conn, mem_128m, maxMemsize, minMemsize, maxMemsize); } protected void waitForTask(Connection c, Task task, long pollInterval, long timeout) throws XenAPIException, XmlRpcException { diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XcpServerResource.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XcpServerResource.java index 7df4c46a63d..bf0a4089713 100644 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XcpServerResource.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XcpServerResource.java @@ -140,9 +140,12 @@ public class XcpServerResource extends CitrixResourceBase { */ @Override protected void setMemory(Connection conn, VM vm, long minMemsize, long maxMemsize) throws XmlRpcException, XenAPIException { - vm.setMemoryStaticMin(conn, mem_32m); - vm.setMemoryDynamicMin(conn, minMemsize); - vm.setMemoryDynamicMax(conn, maxMemsize); - vm.setMemoryStaticMax(conn, maxMemsize); + //setMemoryLimits(staticMin, staticMax, dynamicMin, dynamicMax) + if (s_logger.isDebugEnabled()) { + s_logger.debug("Memory Limits for VM [" + vm.getNameLabel(conn) + + "[staticMin:" + mem_32m + ", staticMax:" + maxMemsize + + ", dynamicMin: " + minMemsize + ", dynamicMax:" + maxMemsize+"]]"); + } + vm.setMemoryLimits(conn, mem_32m, maxMemsize, minMemsize, maxMemsize); } } diff --git a/server/src/com/cloud/hypervisor/HypervisorGuruBase.java b/server/src/com/cloud/hypervisor/HypervisorGuruBase.java index ca1644a4281..ea4fcc1e5bf 100644 --- a/server/src/com/cloud/hypervisor/HypervisorGuruBase.java +++ b/server/src/com/cloud/hypervisor/HypervisorGuruBase.java @@ -86,9 +86,9 @@ public abstract class HypervisorGuruBase extends AdapterBase implements Hypervis ServiceOffering offering = vmProfile.getServiceOffering(); VirtualMachine vm = vmProfile.getVirtualMachine(); - Long minMemory = (long) (offering.getRamSize()/vmProfile.getCpuOvercommitRatio()); - int minspeed= (int)(offering.getSpeed()/vmProfile.getMemoryOvercommitRatio()); - int maxspeed = (offering.getSpeed()); + Long minMemory = (long) (offering.getRamSize() / vmProfile.getMemoryOvercommitRatio()); + int minspeed = (int) (offering.getSpeed() / vmProfile.getCpuOvercommitRatio()); + int maxspeed = (offering.getSpeed()); VirtualMachineTO to = new VirtualMachineTO(vm.getId(), vm.getInstanceName(), vm.getType(), offering.getCpu(), minspeed, maxspeed, minMemory * 1024l * 1024l, offering.getRamSize() * 1024l * 1024l, null, null, vm.isHaEnabled(), vm.limitCpuUse(), vm.getVncPassword()); to.setBootArgs(vmProfile.getBootArgs()); From 63e92a4ea6766212d4450cde3cf205d661a6419d Mon Sep 17 00:00:00 2001 From: Isaac Chiang Date: Mon, 20 May 2013 08:54:13 +0800 Subject: [PATCH 10/51] CLOUDSTACK-1871 : domainId parameter to uploadVolume not working 1. Remove duplicated lines for setting domainId. 2. Set domainId with owner's domain if the owner is specified. --- server/src/com/cloud/storage/VolumeManagerImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/src/com/cloud/storage/VolumeManagerImpl.java b/server/src/com/cloud/storage/VolumeManagerImpl.java index 2f4b2c8d8a6..55e20cf0273 100644 --- a/server/src/com/cloud/storage/VolumeManagerImpl.java +++ b/server/src/com/cloud/storage/VolumeManagerImpl.java @@ -708,19 +708,19 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager { VolumeVO volume = new VolumeVO(volumeName, zoneId, -1, -1, -1, new Long(-1), null, null, 0, Volume.Type.DATADISK); + Account owner = (caller.getId() == ownerId) ? caller : _accountMgr + .getActiveAccountById(ownerId); volume.setPoolId(null); volume.setDataCenterId(zoneId); volume.setPodId(null); volume.setAccountId(ownerId); - volume.setDomainId(((caller == null) ? Domain.ROOT_DOMAIN : caller - .getDomainId())); long diskOfferingId = _diskOfferingDao.findByUniqueName( "Cloud.com-Custom").getId(); volume.setDiskOfferingId(diskOfferingId); // volume.setSize(size); volume.setInstanceId(null); volume.setUpdated(new Date()); - volume.setDomainId((caller == null) ? Domain.ROOT_DOMAIN : caller + volume.setDomainId((owner == null) ? Domain.ROOT_DOMAIN : owner .getDomainId()); volume = _volsDao.persist(volume); From e7332b7c0447c8fc9bde157e4f639fde453790cd Mon Sep 17 00:00:00 2001 From: Sanjay Tripathi Date: Fri, 10 May 2013 12:10:56 +0530 Subject: [PATCH 11/51] CLOUDSTACK-1901 : API:MS: DeleteEvents deletes Archived events as well --- engine/schema/src/com/cloud/alert/dao/AlertDaoImpl.java | 8 ++++++++ engine/schema/src/com/cloud/event/dao/EventDaoImpl.java | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/engine/schema/src/com/cloud/alert/dao/AlertDaoImpl.java b/engine/schema/src/com/cloud/alert/dao/AlertDaoImpl.java index 4b9bc6a2988..01a560a129a 100755 --- a/engine/schema/src/com/cloud/alert/dao/AlertDaoImpl.java +++ b/engine/schema/src/com/cloud/alert/dao/AlertDaoImpl.java @@ -43,6 +43,7 @@ public class AlertDaoImpl extends GenericDaoBase implements Alert AlertSearchByIdsAndType.and("type", AlertSearchByIdsAndType.entity().getType(), Op.EQ); AlertSearchByIdsAndType.and("createdDateL", AlertSearchByIdsAndType.entity().getCreatedDate(), Op.LT); AlertSearchByIdsAndType.and("data_center_id", AlertSearchByIdsAndType.entity().getDataCenterId(), Op.EQ); + AlertSearchByIdsAndType.and("archived", AlertSearchByIdsAndType.entity().getArchived(), Op.EQ); AlertSearchByIdsAndType.done(); } @@ -53,6 +54,7 @@ public class AlertDaoImpl extends GenericDaoBase implements Alert sc.addAnd("type", SearchCriteria.Op.EQ, Short.valueOf(type)); sc.addAnd("dataCenterId", SearchCriteria.Op.EQ, Long.valueOf(dataCenterId)); + sc.addAnd("archived", SearchCriteria.Op.EQ, false); if (podId != null) { sc.addAnd("podId", SearchCriteria.Op.EQ, podId); } @@ -74,6 +76,7 @@ public class AlertDaoImpl extends GenericDaoBase implements Alert sc.addAnd("type", SearchCriteria.Op.EQ, Short.valueOf(type)); sc.addAnd("dataCenterId", SearchCriteria.Op.EQ, Long.valueOf(dataCenterId)); + sc.addAnd("archived", SearchCriteria.Op.EQ, false); if (podId != null) { sc.addAnd("podId", SearchCriteria.Op.EQ, podId); } @@ -101,6 +104,8 @@ public class AlertDaoImpl extends GenericDaoBase implements Alert if(olderThan != null) { sc.setParameters("createdDateL", olderThan); } + sc.setParameters("archived", false); + boolean result = true;; List alerts = listBy(sc); if (Ids != null && alerts.size() < Ids.size()) { @@ -135,6 +140,8 @@ public class AlertDaoImpl extends GenericDaoBase implements Alert if(olderThan != null) { sc.setParameters("createdDateL", olderThan); } + sc.setParameters("archived", false); + boolean result = true; List alerts = listBy(sc); if (ids != null && alerts.size() < ids.size()) { @@ -150,6 +157,7 @@ public class AlertDaoImpl extends GenericDaoBase implements Alert if (oldTime == null) return null; SearchCriteria sc = createSearchCriteria(); sc.addAnd("createDate", SearchCriteria.Op.LT, oldTime); + sc.addAnd("archived", SearchCriteria.Op.EQ, false); return listIncludingRemovedBy(sc, null); } diff --git a/engine/schema/src/com/cloud/event/dao/EventDaoImpl.java b/engine/schema/src/com/cloud/event/dao/EventDaoImpl.java index 0d3d38a0204..cefe1078dbd 100644 --- a/engine/schema/src/com/cloud/event/dao/EventDaoImpl.java +++ b/engine/schema/src/com/cloud/event/dao/EventDaoImpl.java @@ -44,6 +44,7 @@ public class EventDaoImpl extends GenericDaoBase implements Event CompletedEventSearch = createSearchBuilder(); CompletedEventSearch.and("state",CompletedEventSearch.entity().getState(),SearchCriteria.Op.EQ); CompletedEventSearch.and("startId", CompletedEventSearch.entity().getStartId(), SearchCriteria.Op.EQ); + CompletedEventSearch.and("archived", CompletedEventSearch.entity().getArchived(), Op.EQ); CompletedEventSearch.done(); ToArchiveOrDeleteEventSearch = createSearchBuilder(); @@ -51,6 +52,7 @@ public class EventDaoImpl extends GenericDaoBase implements Event ToArchiveOrDeleteEventSearch.and("type", ToArchiveOrDeleteEventSearch.entity().getType(), Op.EQ); ToArchiveOrDeleteEventSearch.and("accountIds", ToArchiveOrDeleteEventSearch.entity().getAccountId(), Op.IN); ToArchiveOrDeleteEventSearch.and("createDateL", ToArchiveOrDeleteEventSearch.entity().getCreateDate(), Op.LT); + ToArchiveOrDeleteEventSearch.and("archived", ToArchiveOrDeleteEventSearch.entity().getArchived(), Op.EQ); ToArchiveOrDeleteEventSearch.done(); } @@ -64,6 +66,7 @@ public class EventDaoImpl extends GenericDaoBase implements Event if (oldTime == null) return null; SearchCriteria sc = createSearchCriteria(); sc.addAnd("createDate", SearchCriteria.Op.LT, oldTime); + sc.addAnd("archived", SearchCriteria.Op.EQ, false); return listIncludingRemovedBy(sc, null); } @@ -72,6 +75,7 @@ public class EventDaoImpl extends GenericDaoBase implements Event SearchCriteria sc = CompletedEventSearch.create(); sc.setParameters("state", State.Completed); sc.setParameters("startId", startId); + sc.setParameters("archived", false); return findOneIncludingRemovedBy(sc); } @@ -90,6 +94,7 @@ public class EventDaoImpl extends GenericDaoBase implements Event if (accountIds != null && !accountIds.isEmpty()) { sc.setParameters("accountIds", accountIds.toArray(new Object[accountIds.size()])); } + sc.setParameters("archived", false); return search(sc, null); } From a2fea4d4499a963a7bb5aed73b4ee03016684529 Mon Sep 17 00:00:00 2001 From: Sanjay Tripathi Date: Mon, 13 May 2013 10:54:52 +0530 Subject: [PATCH 12/51] CLOUDSTACK-2297 : Delete Account/Domain is not updating the resources usage of the parent domain --- .../configuration/dao/ResourceCountDao.java | 2 ++ .../configuration/dao/ResourceCountDaoImpl.java | 16 ++++++++++++++++ .../configuration/dao/ResourceLimitDao.java | 2 ++ .../configuration/dao/ResourceLimitDaoImpl.java | 14 ++++++++++++++ .../src/com/cloud/user/AccountManagerImpl.java | 17 +++++++++++++++++ .../src/com/cloud/user/DomainManagerImpl.java | 15 ++++++++++++--- 6 files changed, 63 insertions(+), 3 deletions(-) diff --git a/engine/schema/src/com/cloud/configuration/dao/ResourceCountDao.java b/engine/schema/src/com/cloud/configuration/dao/ResourceCountDao.java index 111bcb122d6..dc5a65c8ef7 100644 --- a/engine/schema/src/com/cloud/configuration/dao/ResourceCountDao.java +++ b/engine/schema/src/com/cloud/configuration/dao/ResourceCountDao.java @@ -55,4 +55,6 @@ public interface ResourceCountDao extends GenericDao { Set listAllRowsToUpdate(long ownerId, ResourceOwnerType ownerType, ResourceType type); Set listRowsToUpdateForDomain(long domainId, ResourceType type); + + long removeEntriesByOwner(long ownerId, ResourceOwnerType ownerType); } diff --git a/engine/schema/src/com/cloud/configuration/dao/ResourceCountDaoImpl.java b/engine/schema/src/com/cloud/configuration/dao/ResourceCountDaoImpl.java index 52bc746fd8e..cfd2137f479 100644 --- a/engine/schema/src/com/cloud/configuration/dao/ResourceCountDaoImpl.java +++ b/engine/schema/src/com/cloud/configuration/dao/ResourceCountDaoImpl.java @@ -219,4 +219,20 @@ public class ResourceCountDaoImpl extends GenericDaoBase return super.persist(resourceCountVO); } + + + @Override + public long removeEntriesByOwner(long ownerId, ResourceOwnerType ownerType) { + SearchCriteria sc = TypeSearch.create(); + + if (ownerType == ResourceOwnerType.Account) { + sc.setParameters("accountId", ownerId); + return remove(sc); + } else if (ownerType == ResourceOwnerType.Domain) { + sc.setParameters("domainId", ownerId); + return remove(sc); + } + return 0; + } + } \ No newline at end of file diff --git a/engine/schema/src/com/cloud/configuration/dao/ResourceLimitDao.java b/engine/schema/src/com/cloud/configuration/dao/ResourceLimitDao.java index 5fd79b37bc4..e47b38340c2 100644 --- a/engine/schema/src/com/cloud/configuration/dao/ResourceLimitDao.java +++ b/engine/schema/src/com/cloud/configuration/dao/ResourceLimitDao.java @@ -32,4 +32,6 @@ public interface ResourceLimitDao extends GenericDao { ResourceCount.ResourceType getLimitType(String type); ResourceLimitVO findByOwnerIdAndType(long ownerId, ResourceOwnerType ownerType, ResourceCount.ResourceType type); + + long removeEntriesByOwner(Long ownerId, ResourceOwnerType ownerType); } diff --git a/engine/schema/src/com/cloud/configuration/dao/ResourceLimitDaoImpl.java b/engine/schema/src/com/cloud/configuration/dao/ResourceLimitDaoImpl.java index d337070e921..bb67f6bbe21 100644 --- a/engine/schema/src/com/cloud/configuration/dao/ResourceLimitDaoImpl.java +++ b/engine/schema/src/com/cloud/configuration/dao/ResourceLimitDaoImpl.java @@ -97,4 +97,18 @@ public class ResourceLimitDaoImpl extends GenericDaoBase return null; } } + + @Override + public long removeEntriesByOwner(Long ownerId, ResourceOwnerType ownerType) { + SearchCriteria sc = IdTypeSearch.create(); + + if (ownerType == ResourceOwnerType.Account) { + sc.setParameters("accountId", ownerId); + return remove(sc); + } else if (ownerType == ResourceOwnerType.Domain) { + sc.setParameters("domainId", ownerId); + return remove(sc); + } + return 0; + } } diff --git a/server/src/com/cloud/user/AccountManagerImpl.java b/server/src/com/cloud/user/AccountManagerImpl.java index 4088f64f58b..aac8d19eb0e 100755 --- a/server/src/com/cloud/user/AccountManagerImpl.java +++ b/server/src/com/cloud/user/AccountManagerImpl.java @@ -54,9 +54,12 @@ import com.cloud.api.query.dao.UserAccountJoinDao; import com.cloud.api.query.vo.ControlledViewEntity; import com.cloud.configuration.Config; import com.cloud.configuration.ConfigurationManager; +import com.cloud.configuration.ResourceCountVO; import com.cloud.configuration.ResourceLimit; +import com.cloud.configuration.Resource.ResourceOwnerType; import com.cloud.configuration.dao.ConfigurationDao; import com.cloud.configuration.dao.ResourceCountDao; +import com.cloud.configuration.dao.ResourceLimitDao; import com.cloud.dc.DataCenterVO; import com.cloud.dc.dao.DataCenterDao; import com.cloud.dc.dao.DataCenterVnetDao; @@ -229,6 +232,10 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M private AccountGuestVlanMapDao _accountGuestVlanMapDao; @Inject private DataCenterVnetDao _dataCenterVnetDao; + @Inject + private ResourceLimitService _resourceLimitMgr; + @Inject + private ResourceLimitDao _resourceLimitDao; private List _userAuthenticators; List _userPasswordEncoders; @@ -714,6 +721,16 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M int vlansReleased = _accountGuestVlanMapDao.removeByAccountId(accountId); s_logger.info("deleteAccount: Released " + vlansReleased + " dedicated guest vlan ranges from account " + accountId); + // Update resource count for this account and for parent domains. + List resourceCounts = _resourceCountDao.listByOwnerId(accountId, ResourceOwnerType.Account); + for (ResourceCountVO resourceCount : resourceCounts) { + _resourceLimitMgr.decrementResourceCount(accountId, resourceCount.getType(), resourceCount.getCount()); + } + + // Delete resource count and resource limits entries set for this account (if there are any). + _resourceCountDao.removeEntriesByOwner(accountId, ResourceOwnerType.Account); + _resourceLimitDao.removeEntriesByOwner(accountId, ResourceOwnerType.Account); + return true; } catch (Exception ex) { s_logger.warn("Failed to cleanup account " + account + " due to ", ex); diff --git a/server/src/com/cloud/user/DomainManagerImpl.java b/server/src/com/cloud/user/DomainManagerImpl.java index dbcbe4ee431..c451041d951 100644 --- a/server/src/com/cloud/user/DomainManagerImpl.java +++ b/server/src/com/cloud/user/DomainManagerImpl.java @@ -16,11 +16,13 @@ // under the License. package com.cloud.user; -import java.util.*; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.UUID; import javax.ejb.Local; import javax.inject.Inject; -import javax.naming.ConfigurationException; import org.apache.cloudstack.api.command.admin.domain.ListDomainChildrenCmd; import org.apache.cloudstack.api.command.admin.domain.ListDomainsCmd; @@ -29,8 +31,10 @@ import org.apache.cloudstack.region.RegionManager; import org.apache.log4j.Logger; import org.springframework.stereotype.Component; +import com.cloud.configuration.Resource.ResourceOwnerType; import com.cloud.configuration.ResourceLimit; import com.cloud.configuration.dao.ResourceCountDao; +import com.cloud.configuration.dao.ResourceLimitDao; import com.cloud.domain.Domain; import com.cloud.domain.DomainVO; import com.cloud.domain.dao.DomainDao; @@ -49,7 +53,6 @@ import com.cloud.storage.DiskOfferingVO; import com.cloud.storage.dao.DiskOfferingDao; import com.cloud.user.dao.AccountDao; import com.cloud.utils.Pair; -import com.cloud.utils.component.Manager; import com.cloud.utils.component.ManagerBase; import com.cloud.utils.db.DB; import com.cloud.utils.db.Filter; @@ -82,6 +85,8 @@ public class DomainManagerImpl extends ManagerBase implements DomainManager, Dom private ProjectManager _projectMgr; @Inject private RegionManager _regionMgr; + @Inject + private ResourceLimitDao _resourceLimitDao; @Override public Domain getDomain(long domainId) { @@ -329,6 +334,10 @@ public class DomainManagerImpl extends ManagerBase implements DomainManager, Dom List accountsForCleanup = _accountDao.findCleanupsForRemovedAccounts(domainId); if (accountsForCleanup.isEmpty()) { deleteDomainSuccess = _domainDao.remove(domainId); + + // Delete resource count and resource limits entries set for this domain (if there are any). + _resourceCountDao.removeEntriesByOwner(domainId, ResourceOwnerType.Domain); + _resourceLimitDao.removeEntriesByOwner(domainId, ResourceOwnerType.Domain); } else { s_logger.debug("Can't delete the domain yet because it has " + accountsForCleanup.size() + "accounts that need a cleanup"); } From 8986e16e5f9f59fdf222704ec9716b9b821bdea8 Mon Sep 17 00:00:00 2001 From: Likitha Shetty Date: Mon, 20 May 2013 14:51:20 +0530 Subject: [PATCH 13/51] CLOUDSTACK-2576. AWS API not returning values in CFSimpleXML Object format. PHP SDK calls the CFSimpleXML parser class to parse the response body into CFSimpleXML Object format. In AWSAPI added an XML declaration during serialization of Axis beans to XML output --- awsapi/src/com/cloud/bridge/service/EC2RestServlet.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java b/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java index 630e16fb5f3..6dd7a8cbb75 100644 --- a/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java +++ b/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java @@ -2043,8 +2043,9 @@ public class EC2RestServlet extends HttpServlet { throws ADBException, XMLStreamException, IOException { OutputStream os = response.getOutputStream(); response.setStatus(200); - response.setContentType("text/xml; charset=UTF-8"); + response.setContentType("text/xml"); XMLStreamWriter xmlWriter = xmlOutFactory.createXMLStreamWriter( os ); + xmlWriter.writeStartDocument("UTF-8","1.0"); MTOMAwareXMLSerializer MTOMWriter = new MTOMAwareXMLSerializer( xmlWriter ); MTOMWriter.setDefaultNamespace("http://ec2.amazonaws.com/doc/" + wsdlVersion + "/"); EC2Response.serialize( null, factory, MTOMWriter ); From 2778486c34427dbc4e66a7f5db0e3b2364cf9f11 Mon Sep 17 00:00:00 2001 From: suresh sadhu Date: Mon, 20 May 2013 14:48:06 +0530 Subject: [PATCH 14/51] CLOUDSTACK-2287: Tests for the LDAP system API tests for the LDAP config/remove commands Signed-off-by: Prasanna Santhanam --- test/integration/smoke/test_ldap.py | 365 ++++++++++++++++++++++++++++ 1 file changed, 365 insertions(+) create mode 100755 test/integration/smoke/test_ldap.py diff --git a/test/integration/smoke/test_ldap.py b/test/integration/smoke/test_ldap.py new file mode 100755 index 00000000000..1b933dbccf7 --- /dev/null +++ b/test/integration/smoke/test_ldap.py @@ -0,0 +1,365 @@ +# 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. + +""" P1 for LDAP Config +""" + + +#!/usr/bin/env python + +import marvin +from marvin import cloudstackTestCase +from marvin.cloudstackTestCase import * +import unittest +import hashlib +import random +from marvin.cloudstackAPI import * +from marvin.cloudstackAPI import login +from marvin.integration.lib.utils import * +from marvin.integration.lib.base import * +from marvin.integration.lib.common import * +from nose.plugins.attrib import attr +import urllib + + + +class Services: + """Test LDAP Configuration + """ + + def __init__(self): + self.services = { + "account": { + "email": "test@test.com", + "firstname": "test", + "lastname": "t", + "username": "test", + "password": "password", + }, + "ldapCon_1":#valid values&Query filter as email. + { + "ldapHostname": "10.147.38.163", + "port": "389", + "binddn": "CN=test,CN=Users,DC=hyd-qa,DC=com", + "bindpass": "aaaa_1111", + "queryfilter": "(&(mail=%e))", + "searchbase": "CN=Users,DC=hyd-qa,DC=com", + "ldapusername": "test", + "ldappasswd": "aaaa_1111" + }, + "ldapCon_2": ##valid values&Query filter as displayName. + { + "ldapHostname": "10.147.38.163", + "port": "389", + "binddn": "CN=test,CN=Users,DC=hyd-qa,DC=com", + "bindpass": "aaaa_1111", + "queryfilter": "(&(displayName=%u))", + "searchbase": "CN=Users,DC=hyd-qa,DC=com", + "ldapusername": "test", + "ldappasswd": "aaaa_1111" + }, + "ldapCon_3": #Configuration with missing parameters value(queryfilter) + { + "ldapHostname": "10.147.38.163", + "port": "389", + "binddn": "CN=test,CN=Users,DC=hyd-qa,DC=com", + "bindpass": "aaaa_1111", + "queryfilter": "", + "searchbase": "CN=Users,DC=hyd-qa,DC=com", + "ldapusername": "test", + "ldappasswd": "aaaa_1111" + }, + + "ldapCon_4": #invalid configuration-wrong query filter + { + "ldapHostname": "10.147.38.163", + "port": "389", + "binddn": "CN=test,CN=Users,DC=hyd-qa,DC=com", + "bindpass": "aaaa_1111", + "queryfilter": "(&(displayName=%p))", + "searchbase":"CN=Users,DC=hyd-qa,DC=com", + "ldapusername": "test", + "ldappasswd": "aaaa_1111" + }, + "ldapCon_5": #Configuration with invalid ldap credentials + { + "ldapHostname": "10.147.38.163", + "port": "389", + "binddn": "CN=test,CN=Users,DC=hyd-qa,DC=com", + "bindpass": "aaaa_1111", + "queryfilter": "(&(displayName=%u))", + "searchbase": "CN=Users,DC=hyd-qa,DC=com", + "ldapusername": "test", + "ldappasswd": "aaaa" + } + + + + } + + +class TestLdap(cloudstackTestCase): + """ + This test perform registering ldap configuration details in CS and create a user[ldap user] in CS + and validate user credentials against LDAP server:AD + """ + + @classmethod + def setUpClass(cls): + + cls.api_client = super( + TestLdap, + cls + ).getClsTestClient().getApiClient() + cls.services = Services().services + cls.account = cls.services["account"] + cls._cleanup = [] + + + + @classmethod + def tearDownClass(cls): + try: + #Cleanup resources used + #print "tear down class" + cleanup_resources(cls.api_client, cls._cleanup) + + except Exception as tde: + raise Exception("Warning: Exception during cleanup : %s" % tde) + return + + def setUp(self): + + self.apiclient = self.testClient.getApiClient() + + self.acct = createAccount.createAccountCmd() + self.acct.accounttype = 0 #We need a regular user. admins have accounttype=1 + self.acct.firstname = self.services["account"]["firstname"] + self.acct.lastname = self.services["account"]["lastname"] + self.acct.password = self.services["account"]["password"] + self.acct.username = self.services["account"]["username"] + self.acct.email = self.services["account"]["email"] + self.acct.account = self.services["account"]["username"] + self.acct.domainid = 1 + # mapping ldap user by creating same user in cloudstack + + self.acctRes = self.apiclient.createAccount(self.acct) + + + return + + def tearDown(self): + + try: + #Clean up, terminate the created accounts, domains etc + + deleteAcct = deleteAccount.deleteAccountCmd() + deleteAcct.id = self.acctRes.id + + acct_name=self.acctRes.name + + self.apiclient.deleteAccount(deleteAcct) + + self.debug("Deleted the the following account name %s:" %acct_name) + #delete only if ldapconfig registered in CS + if(self.ldapconfRes): + deleteldapconfg=ldapRemove.ldapRemoveCmd() + res=self.apiclient.ldapRemove(deleteldapconfg) + + + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return + + + def test_01_configLDAP(self): + ''' + This test is to verify ldapConfig API with valid values.(i.e query fileter as email) + ''' + # 1. This test covers ldapConfig & login API with valid ldap credentials.. + # require ldap configuration:ldapCon_1 + + self.debug("start test") + + self.ldapconfRes=self._testldapConfig(self.services["ldapCon_1"]) + + if(self.ldapconfRes==1): + + + self.debug("configure ldap successful") + + #validating the user credentials with ldap Server + loginRes = self.chkLogin(self.services["ldapCon_1"]["ldapusername"], self.services["ldapCon_1"]["ldappasswd"]) + self.assertEquals(loginRes,1,"ldap Authentication failed") + + else: + + self.debug("LDAP Configuration failed with exception") + + self.assertEquals(self.ldapconfRes,1,"ldapConfig API failed") + + + self.debug("end test") + + + def test_02_configLDAP(self): + ''' + This test is to verify ldapConfig API with valid values.(i.e query fileter as displayName) + ''' + + # 1. This test covers ldapConfig & login API with valid ldap credentials. + # 2. require ldap configuration:ldapCon_2 + + self.debug("start test") + self.ldapconfRes=self._testldapConfig(self.services["ldapCon_2"]) + self.assertEquals(self.ldapconfRes,1,"ldapConfig API failed") + if(self.ldapconfRes==1): + self.debug("configure ldap successful") + #validating the user credentials with ldap Server + loginRes = self.chkLogin(self.services["ldapCon_2"]["ldapusername"], self.services["ldapCon_2"]["ldappasswd"]) + self.assertEquals(loginRes,1,"ldap Authentication failed") + else: + self.debug("LDAP Configuration failed with exception") + self.debug("end test") + + + def test_03_configLDAP(self): + + ''' + This test is to verify ldapConfig API with missing config parameters value(i.queryfilter) + ''' + + # 1. Issue ldapConfig API with no ldap config parameter value and check behavior + # 2. require ldap configuration:ldapCon_3 + + self.debug("start test...") + self.ldapconfRes=self._testldapConfig(self.services["ldapCon_3"]) + self.assertEquals(self.ldapconfRes,0,"LDAP configuration successful with invalid value.API failed") + self.debug("end test") + + def test_04_configLDAP(self): + ''' + This test is to verify ldapConfig API with invalid configuration values(by passing wrong query filter) + ''' + # 1. calling ldapConfig API with invalid query filter value and check behavior + # 2. require ldap configuration:ldapCon_4 + + self.debug("start test...") + self.ldapconfRes=self._testldapConfig(self.services["ldapCon_4"]) + self.assertEquals(self.ldapconfRes,0,"API failed") + + + + def test_05_configLDAP(self): + + ''' + This test is to verify login API functionality by passing wrong ldap credentials + ''' + # 1.This script first configure the ldap and validates the user credentials using login API + # 2. require ldap configuration:ldapCon_5 + + + self.debug("start test") + self.ldapconfRes=self._testldapConfig(self.services["ldapCon_5"]) + self.assertEquals(self.ldapconfRes,1,"API failed") + #validating the cloudstack user credentials with ldap Server + loginRes = self.chkLogin(self.services["ldapCon_5"]["ldapusername"], self.services["ldapCon_5"]["ldappasswd"]) + self.assertNotEqual(loginRes,1,"login API failed") + self.debug("end test") + + def test_06_removeLDAP(self): + ''' + This test is to verify ldapRemove API functionality + ''' + # 1. This script fist configures ldap and removes the configured ldap values + # 2. require ldap configuration:ldapCon_1 + + + self.debug("start test") + self.ldapconfRes=self._testldapConfig(self.services["ldapCon_1"]) + if(self.ldapconfRes==1): + self.debug("ldap configured successfully") + deleteldapconfg=ldapRemove.ldapRemoveCmd() + res=self.apiclient.ldapRemove(deleteldapconfg) + self.debug("ldap removed successfully") + self.ldapconfRes=0 + else: + + self.debug("LDAP Configuration failed with exception") + self.assertEquals(self.ldapconfRes,0,"ldapconfig API failed") + self.debug("end test") + + def _testldapConfig(self,ldapSrvD): + + """ + + :param ldapSrvD + + + """ + #This Method takes dictionary as parameter, + # reads the ldap configuration values from the passed dictionary and + # register the ldapconfig detail in cloudstack + # & return true or false based on ldapconfig API response + + self.debug("start ldapconfig test") + #creating the ldapconfig cmd object + lpconfig = ldapConfig.ldapConfigCmd() + #Config the ldap server by assigning the ldapconfig dict variable values to ldapConfig object + lpconfig.hostname = ldapSrvD["ldapHostname"] + lpconfig.port = ldapSrvD["port"] + lpconfig.binddn = ldapSrvD["binddn"] + lpconfig.bindpass = ldapSrvD["bindpass"] + lpconfig.searchbase = ldapSrvD["searchbase"] + lpconfig.queryfilter = ldapSrvD["queryfilter"] + + #end of assigning the variables + + #calling the ldapconfig Api + self.debug("calling ldapconfig API") + try: + lpconfig1 = self.apiclient.ldapConfig(lpconfig) + self.debug("ldapconfig API succesfful") + return 1 + except Exception, e: + self.debug("ldapconfig API failed %s" %e) + return 0 + + def chkLogin(self, username, password): + """ + + :param username: + :param password: + + """ + self.debug("login test") + + try: + login1 = login.loginCmd() + login1.username = username + login1.password = password + loginRes = self.apiclient.login(login1) + self.debug("login response %s" % loginRes) + if loginRes is None: + self.debug("login not successful") + else: + self.debug("login successful") + return 1 + + except Exception, p: + self.debug("login operation failed %s" %p) + self.debug("end of Login") From 8da7ec05f1c7dae0aab827ae0568e120111c6579 Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Mon, 20 May 2013 17:48:07 +0530 Subject: [PATCH 15/51] CLOUDSTACK-2085: DMC enable guest scaling When dmc is enabled allow cloudstack to scale the VM between dynamic ranges. This requires a further commit where there is enough memory available between dynamic-max and static-max for the VM to scale under memory pressure. See the TODO in Xenserver56FP1Resource.java Signed-off-by: Prasanna Santhanam --- .../xen/resource/CitrixResourceBase.java | 11 +++ .../xen/resource/XcpServerResource.java | 9 ++- .../xen/resource/XenServer56FP1Resource.java | 71 ++++++++++++------- 3 files changed, 64 insertions(+), 27 deletions(-) diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index 19444cccfbc..cd4977312ae 100644 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -3523,6 +3523,17 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe vm.setMemoryLimits(conn, mem_128m, maxMemsize, minMemsize, maxMemsize); } + /** + * When Dynamic Memory Control (DMC) is enabled - + * xen allows scaling the guest memory while the guest is running + * + * By default this is disallowed, override the specific xen resource + * if this is enabled + */ + protected boolean isDmcEnabled(Connection conn, Host host) throws XenAPIException, XmlRpcException { + return false; + } + protected void waitForTask(Connection c, Task task, long pollInterval, long timeout) throws XenAPIException, XmlRpcException { long beginTime = System.currentTimeMillis(); while (task.getStatus(c) == Types.TaskStatusType.PENDING) { diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XcpServerResource.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XcpServerResource.java index bf0a4089713..67e37d52a4a 100644 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XcpServerResource.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XcpServerResource.java @@ -24,6 +24,7 @@ import com.cloud.resource.ServerResource; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.script.Script; import com.xensource.xenapi.Connection; +import com.xensource.xenapi.Host; import com.xensource.xenapi.Types.XenAPIException; import com.xensource.xenapi.VM; import org.apache.log4j.Logger; @@ -38,7 +39,6 @@ import java.util.List; public class XcpServerResource extends CitrixResourceBase { private final static Logger s_logger = Logger.getLogger(XcpServerResource.class); private static final long mem_32m = 33554432L; - private String version; public XcpServerResource() { @@ -148,4 +148,11 @@ public class XcpServerResource extends CitrixResourceBase { } vm.setMemoryLimits(conn, mem_32m, maxMemsize, minMemsize, maxMemsize); } + + @Override + protected boolean isDmcEnabled(Connection conn, Host host) { + //Dynamic Memory Control (DMC) is a technology provided by Xen Cloud Platform (XCP), starting from the 0.5 release + //For the supported XCPs dmc is default enabled, XCP 1.0.0, 1.1.0, 1.4.x, 1.5 beta, 1.6.x; + return true; + } } diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java index ad412c1e3d0..78ad2361b07 100644 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java @@ -47,6 +47,7 @@ import java.util.Set; @Local(value=ServerResource.class) public class XenServer56FP1Resource extends XenServer56Resource { + private static final long mem_128m = 134217728L; private static final Logger s_logger = Logger.getLogger(XenServer56FP1Resource.class); public XenServer56FP1Resource() { @@ -126,41 +127,46 @@ public class XenServer56FP1Resource extends XenServer56Resource { assert templates.size() == 1 : "Should only have 1 template but found " + templates.size(); VM template = templates.iterator().next(); - VM.Record record = template.getRecord(conn); - record.affinity = host; - record.otherConfig.remove("disks"); - record.otherConfig.remove("default_template"); - record.otherConfig.remove("mac_seed"); - record.isATemplate = false; - record.nameLabel = vmSpec.getName(); - record.actionsAfterCrash = Types.OnCrashBehaviour.DESTROY; - record.actionsAfterShutdown = Types.OnNormalExit.DESTROY; - record.memoryDynamicMin = vmSpec.getMinRam(); - record.memoryDynamicMax = vmSpec.getMaxRam(); - Map hostParams = new HashMap(); - hostParams = host.getLicenseParams(conn); - if (hostParams.get("restrict_dmc").equalsIgnoreCase("false")) { - record.memoryStaticMin = vmSpec.getMinRam(); - record.memoryStaticMax = vmSpec.getMaxRam(); + VM.Record vmr = template.getRecord(conn); + vmr.affinity = host; + vmr.otherConfig.remove("disks"); + vmr.otherConfig.remove("default_template"); + vmr.otherConfig.remove("mac_seed"); + vmr.isATemplate = false; + vmr.nameLabel = vmSpec.getName(); + vmr.actionsAfterCrash = Types.OnCrashBehaviour.DESTROY; + vmr.actionsAfterShutdown = Types.OnNormalExit.DESTROY; + + if (isDmcEnabled(conn, host)) { + //scaling is allowed + vmr.memoryStaticMin = mem_128m; //128MB + //TODO: Remove hardcoded 8GB and assign proportionate to ServiceOffering and mem overcommit ratio + vmr.memoryStaticMax = 8589934592L; //8GB + vmr.memoryDynamicMin = vmSpec.getMinRam(); + vmr.memoryDynamicMax = vmSpec.getMaxRam(); } else { - s_logger.warn("Host "+ _host.uuid + " does not support Dynamic Memory Control, so we cannot scale up the vm"); - record.memoryStaticMin = 134217728L; //128MB - record.memoryStaticMax = 8589934592L; //8GB + //scaling disallowed, set static memory target + if (s_logger.isDebugEnabled()) { + s_logger.warn("Host "+ host.getHostname(conn) +" does not support dynamic scaling"); + } + vmr.memoryStaticMin = vmSpec.getMinRam(); + vmr.memoryStaticMax = vmSpec.getMaxRam(); + vmr.memoryDynamicMin = vmSpec.getMinRam(); + vmr.memoryDynamicMax = vmSpec.getMaxRam(); } if (guestOsTypeName.toLowerCase().contains("windows")) { - record.VCPUsMax = (long) vmSpec.getCpus(); + vmr.VCPUsMax = (long) vmSpec.getCpus(); } else { - record.VCPUsMax = 32L; + vmr.VCPUsMax = 32L; } - record.VCPUsAtStartup = (long) vmSpec.getCpus(); - record.consoles.clear(); + vmr.VCPUsAtStartup = (long) vmSpec.getCpus(); + vmr.consoles.clear(); - VM vm = VM.create(conn, record); - VM.Record vmr = vm.getRecord(conn); + VM vm = VM.create(conn, vmr); if (s_logger.isDebugEnabled()) { - s_logger.debug("Created VM " + vmr.uuid + " for " + vmSpec.getName()); + s_logger.debug("Created VM " + vm.getUuid(conn) + " for " + vmSpec.getName()); } Map vcpuParams = new HashMap(); @@ -227,4 +233,17 @@ public class XenServer56FP1Resource extends XenServer56Resource { return vm; } + /** + * When Dynamic Memory Control (DMC) is enabled - + * xen allows scaling the guest memory while the guest is running + * + * This is determined by the 'restrict_dmc' option on the host. + * When false, scaling is allowed hence DMC is enabled + */ + @Override + protected boolean isDmcEnabled(Connection conn, Host host) throws XenAPIException, XmlRpcException { + Map hostParams = new HashMap(); + hostParams = host.getLicenseParams(conn); + return hostParams.get("restrict_dmc").equalsIgnoreCase("false"); + } } From 92e635228731fb72461e757f523cd20fefcd370b Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Mon, 20 May 2013 17:50:32 +0530 Subject: [PATCH 16/51] Detect the second zone for copyImage operation When copying templates and ISOs detect that a second zone is available. Else skip the test. Signed-off-by: Prasanna Santhanam --- test/integration/smoke/test_iso.py | 10 ++++++---- test/integration/smoke/test_templates.py | 11 +++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/test/integration/smoke/test_iso.py b/test/integration/smoke/test_iso.py index ad4a8f280d1..c645d3b055d 100644 --- a/test/integration/smoke/test_iso.py +++ b/test/integration/smoke/test_iso.py @@ -202,11 +202,9 @@ class TestISO(cloudstackTestCase): cls.services["sourcezoneid"] = cls.zone.id #populate second zone id for iso copy cmd = listZones.listZonesCmd() - zones = cls.api_client.listZones(cmd) - if not isinstance(zones, list): + cls.zones = cls.api_client.listZones(cmd) + if not isinstance(cls.zones, list): raise Exception("Failed to find zones.") - if len(zones) >= 2: - cls.services["destzoneid"] = zones[1].id #Create an account, ISOs etc. cls.account = Account.create( @@ -484,6 +482,10 @@ class TestISO(cloudstackTestCase): #Validate the following #1. copy ISO should be successful and secondary storage # should contain new copied ISO. + if len(self.zones) <= 1: + self.skipTest("Not enough zones available to perform copy template") + + self.services["destzoneid"] = filter(lambda z: z.id != self.zone.id, self.zones)[0] self.debug("Copy ISO from %s to %s" % ( self.zone.id, diff --git a/test/integration/smoke/test_templates.py b/test/integration/smoke/test_templates.py index 382f56f8980..8b83f5e6e43 100644 --- a/test/integration/smoke/test_templates.py +++ b/test/integration/smoke/test_templates.py @@ -295,11 +295,9 @@ class TestTemplates(cloudstackTestCase): cls.services['mode'] = cls.zone.networktype #populate second zone id for iso copy cmd = listZones.listZonesCmd() - zones = cls.api_client.listZones(cmd) - if not isinstance(zones, list): + cls.zones = cls.api_client.listZones(cmd) + if not isinstance(cls.zones, list): raise Exception("Failed to find zones.") - if len(zones) >= 2: - cls.services["destzoneid"] = zones[1].id cls.disk_offering = DiskOffering.create( cls.api_client, @@ -664,6 +662,11 @@ class TestTemplates(cloudstackTestCase): # 1. copy template should be successful and # secondary storage should contain new copied template. + if len(self.zones) <= 1: + self.skipTest("Not enough zones available to perform copy template") + + self.services["destzoneid"] = filter(lambda z: z.id != self.services["sourcezoneid"], self.zones)[0] + self.debug("Copy template from Zone: %s to %s" % ( self.services["sourcezoneid"], self.services["destzoneid"] From e1ad36bccb70a9f73de1d06b408043a93876195c Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Mon, 20 May 2013 17:51:18 +0530 Subject: [PATCH 17/51] migrate only when hosts are available Identify the hosts that are suitable for migration before proceeding with migrateVM Signed-off-by: Prasanna Santhanam --- test/integration/smoke/test_vm_life_cycle.py | 131 ++++++++++--------- 1 file changed, 66 insertions(+), 65 deletions(-) diff --git a/test/integration/smoke/test_vm_life_cycle.py b/test/integration/smoke/test_vm_life_cycle.py index 21c26357ab2..3f7c17b9ed6 100644 --- a/test/integration/smoke/test_vm_life_cycle.py +++ b/test/integration/smoke/test_vm_life_cycle.py @@ -135,35 +135,34 @@ class TestDeployVM(cloudstackTestCase): cls.apiclient = super(TestDeployVM, cls).getClsTestClient().getApiClient() # Get Zone, Domain and templates domain = get_domain(cls.apiclient, cls.services) - zone = get_zone(cls.apiclient, cls.services) - cls.services['mode'] = zone.networktype + cls.zone = get_zone(cls.apiclient, cls.services) + cls.services['mode'] = cls.zone.networktype #If local storage is enabled, alter the offerings to use localstorage #this step is needed for devcloud - if zone.localstorageenabled == True: + if cls.zone.localstorageenabled == True: cls.services["service_offerings"]["tiny"]["storagetype"] = 'local' cls.services["service_offerings"]["small"]["storagetype"] = 'local' cls.services["service_offerings"]["medium"]["storagetype"] = 'local' template = get_template( cls.apiclient, - zone.id, + cls.zone.id, cls.services["ostype"] ) # Set Zones and disk offerings - cls.services["small"]["zoneid"] = zone.id + cls.services["small"]["zoneid"] = cls.zone.id cls.services["small"]["template"] = template.id - cls.services["medium"]["zoneid"] = zone.id + cls.services["medium"]["zoneid"] = cls.zone.id cls.services["medium"]["template"] = template.id - cls.services["iso"]["zoneid"] = zone.id + cls.services["iso"]["zoneid"] = cls.zone.id cls.account = Account.create( cls.apiclient, cls.services["account"], domainid=domain.id ) - cls.debug(str("============" )) cls.debug(cls.account.id) cls.service_offering = ServiceOffering.create( @@ -811,68 +810,76 @@ class TestVMLifeCycle(cloudstackTestCase): """Test migrate VM """ # Validate the following - # 1. Should be able to login to the VM. - # 2. listVM command should return this VM.State of this VM - # should be "Running" and the host should be the host - # to which the VM was migrated to + # 1. Environment has enough hosts for migration + # 2. DeployVM on suitable host (with another host in the cluster) + # 3. Migrate the VM and assert migration successful hosts = Host.list( - self.apiclient, - zoneid=self.medium_virtual_machine.zoneid, - type='Routing' - ) - + self.apiclient, + zoneid=self.zone.id, + type='Routing' + ) self.assertEqual( - isinstance(hosts, list), - True, - "Check the number of hosts in the zone" - ) + isinstance(hosts, list), + True, + "Check the number of hosts in the zone" + ) self.assertGreaterEqual( - len(hosts), - 2, - "Atleast 2 hosts should be present in a zone for VM migration" - ) - # Remove the host of current VM from the hosts list - hosts[:] = [host for host in hosts if host.id != self.medium_virtual_machine.hostid] + len(hosts), + 2, + "Atleast 2 hosts should be present for VM migration" + ) - host = hosts[0] + #identify suitable host + clusters = [h.clusterid for h in hosts] + #find hosts withe same clusterid + clusters = [cluster for index, cluster in enumerate(clusters) if clusters.count(cluster) > 1] + + if len(clusters) <= 1: + self.skipTest("Migration needs a cluster with at least two hosts") + + suitable_hosts = [host for host in hosts if host.clusterid == clusters[0]] + target_host = suitable_hosts[0] + migrate_host = suitable_hosts[1] + + #deploy VM on target host + self.vm_to_migrate = VirtualMachine.create( + self.api_client, + self.services["small"], + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.small_offering.id, + mode=self.services["mode"], + hostid=target_host.id + ) self.debug("Migrating VM-ID: %s to Host: %s" % ( - self.medium_virtual_machine.id, - host.id + self.vm_to_migrate.id, + migrate_host.id )) - cmd = migrateVirtualMachine.migrateVirtualMachineCmd() - cmd.hostid = host.id - cmd.virtualmachineid = self.medium_virtual_machine.id - self.apiclient.migrateVirtualMachine(cmd) + self.vm_to_migrate.migrate(self.api_client, migrate_host.id) list_vm_response = list_virtual_machines( self.apiclient, - id=self.medium_virtual_machine.id + id=self.vm_to_migrate.id ) - self.assertEqual( - isinstance(list_vm_response, list), - True, - "Check list response returns a valid list" - ) - self.assertNotEqual( list_vm_response, None, - "Check virtual machine is listVirtualMachines" + "Check virtual machine is listed" ) vm_response = list_vm_response[0] self.assertEqual( vm_response.id, - self.medium_virtual_machine.id, + self.vm_to_migrate.id, "Check virtual machine ID of migrated VM" ) self.assertEqual( vm_response.hostid, - host.id, + migrate_host.id, "Check destination hostID of migrated VM" ) return @@ -964,29 +971,25 @@ class TestVMLifeCycle(cloudstackTestCase): try: ssh_client = self.virtual_machine.get_ssh_client() - - cmds = [ - "mkdir -p %s" % self.services["mount_dir"], - "mount -rt iso9660 %s %s" \ - % ( - self.services["diskdevice"], - self.services["mount_dir"] - ), - ] - - for c in cmds: - res = ssh_client.execute(c) - - self.assertEqual(res, [], "Check mount is successful or not") - - c = "fdisk -l|grep %s|head -1" % self.services["diskdevice"] - res = ssh_client.execute(c) - #Disk /dev/xvdd: 4393 MB, 4393723904 bytes - except Exception as e: self.fail("SSH failed for virtual machine: %s - %s" % (self.virtual_machine.ipaddress, e)) + cmds = [ + "mkdir -p %s" % self.services["mount_dir"], + "mount -rt iso9660 %s %s" \ + % ( + self.services["diskdevice"], + self.services["mount_dir"] + ), + ] + for c in cmds: + res = ssh_client.execute(c) + self.assertEqual(res, [], "Check mount is successful or not") + c = "fdisk -l|grep %s|head -1" % self.services["diskdevice"] + res = ssh_client.execute(c) + #Disk /dev/xvdd: 4393 MB, 4393723904 bytes + # Res may contain more than one strings depending on environment # Split strings to form new list which is used for assertion on ISO size result = [] @@ -1015,7 +1018,6 @@ class TestVMLifeCycle(cloudstackTestCase): #Unmount ISO command = "umount %s" % self.services["mount_dir"] ssh_client.execute(command) - except Exception as e: self.fail("SSH failed for virtual machine: %s - %s" % (self.virtual_machine.ipaddress, e)) @@ -1027,7 +1029,6 @@ class TestVMLifeCycle(cloudstackTestCase): try: res = ssh_client.execute(c) - except Exception as e: self.fail("SSH failed for virtual machine: %s - %s" % (self.virtual_machine.ipaddress, e)) From 32e7ba23a3bd514f7b4026b522913def406383c1 Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Mon, 20 May 2013 17:59:19 +0530 Subject: [PATCH 18/51] LDAP moved to regression suite. LDAP requires a Directory server which isn't available by default in most environments. Moving this to the regression suite so it can be run on demand. Signed-off-by: Prasanna Santhanam --- test/integration/{smoke => component}/test_ldap.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/integration/{smoke => component}/test_ldap.py (100%) diff --git a/test/integration/smoke/test_ldap.py b/test/integration/component/test_ldap.py similarity index 100% rename from test/integration/smoke/test_ldap.py rename to test/integration/component/test_ldap.py From 612afbd17941ee840b1bba3e5951f89cafeea243 Mon Sep 17 00:00:00 2001 From: Kishan Kavala Date: Mon, 20 May 2013 17:58:14 +0530 Subject: [PATCH 19/51] CLOUDSTACK-2553: Made ACL item action case-insensitive --- server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java b/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java index 4d5d98192fa..2b02a888de9 100644 --- a/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java +++ b/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java @@ -342,9 +342,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ //Check ofr valid action Allow/Deny if(action != null){ - try { - NetworkACLItem.Action.valueOf(action); - } catch (IllegalArgumentException ex) { + if(!("Allow".equalsIgnoreCase(action) || "Deny".equalsIgnoreCase(action))){ throw new InvalidParameterValueException("Invalid action. Allowed actions are Allow and Deny"); } } From f5c8e386e5881c1d7aad1f85922752621bb96c1a Mon Sep 17 00:00:00 2001 From: Devdeep Singh Date: Mon, 20 May 2013 18:26:50 +0530 Subject: [PATCH 20/51] CLOUDSTACK-2379: Fix for issue destroy vm causing NPE. Made the following changes. 1. Made a fix to make sure a null object is added to the exception. 2. Also fixed the marvin test cases for the feature. Account cleanup will remove the vms deployed for the account. There is no need to explicitly delete the vms for the account. 3. Fixed the assertion checks for the vm created for an account. If there are multiple vms for an account, the test script needs to compare the ids with the correct instance. --- server/src/com/cloud/vm/UserVmManagerImpl.java | 1 - test/integration/smoke/test_deploy_vm_with_userdata.py | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 05ff6aa74df..86150a2ab9c 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -3228,7 +3228,6 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use if (vm == null || vm.getRemoved() != null) { InvalidParameterValueException ex = new InvalidParameterValueException( "Unable to find a virtual machine with specified vmId"); - ex.addProxyObject(vm, vmId, "vmId"); throw ex; } diff --git a/test/integration/smoke/test_deploy_vm_with_userdata.py b/test/integration/smoke/test_deploy_vm_with_userdata.py index 8ca9bd05a2d..260106cbb0f 100644 --- a/test/integration/smoke/test_deploy_vm_with_userdata.py +++ b/test/integration/smoke/test_deploy_vm_with_userdata.py @@ -105,13 +105,13 @@ class TestDeployVmWithUserData(cloudstackTestCase): vms = list_virtual_machines( self.apiClient, account=self.account.name, - domainid=self.account.domainid + domainid=self.account.domainid, + id=deployVmResponse.id ) self.assert_(len(vms) > 0, "There are no Vms deployed in the account %s" % self.account.name) vm = vms[0] self.assert_(vm.id == str(deployVmResponse.id), "Vm deployed is different from the test") self.assert_(vm.state == "Running", "VM is not in Running state") - self.cleanup.append(deployVmResponse) @attr(tags=["simulator", "devcloud", "basic", "advanced"]) def test_deployvm_userdata(self): @@ -129,13 +129,13 @@ class TestDeployVmWithUserData(cloudstackTestCase): vms = list_virtual_machines( self.apiClient, account=self.account.name, - domainid=self.account.domainid + domainid=self.account.domainid, + id=deployVmResponse.id ) self.assert_(len(vms) > 0, "There are no Vms deployed in the account %s" % self.account.name) vm = vms[0] self.assert_(vm.id == str(deployVmResponse.id), "Vm deployed is different from the test") self.assert_(vm.state == "Running", "VM is not in Running state") - self.cleanup.append(deployVmResponse) @classmethod def tearDownClass(cls): From d6452be8618198454c6f20f4210f6ac18ce9b11d Mon Sep 17 00:00:00 2001 From: Murali Reddy Date: Mon, 20 May 2013 20:05:47 +0530 Subject: [PATCH 21/51] CLOUDSTACK-652: meging 'portable public ip' feature Squashed commit of the following: commit f244f9ce7982db16984dd87c31545f1c0240c704 Merge: 993cbb0 f5c8e38 Author: Murali Reddy Date: Mon May 20 18:54:05 2013 +0530 Merge branch 'master' into portablepublicip Conflicts: server/src/com/cloud/server/ManagementServerImpl.java server/test/org/apache/cloudstack/networkoffering/ChildTestConfiguration.java commit 993cbb0df9fa6e64b96b18ed775b73cdf4a8f5d7 Author: Murali Reddy Date: Mon May 20 18:49:54 2013 +0530 introduce 'transferPortableIP' interface method in network manger. This method will transfer association of portable ip from one network to another network. commit 0c1c2652c1b39e9a81ca35464360e11ed9ef23f1 Merge: a718d35 a29e393 Author: Murali Reddy Date: Fri May 17 02:48:54 2013 +0530 Merge branch 'master' into portablepublicip Conflicts: utils/src/com/cloud/utils/net/NetUtils.java commit a718d353f7acf0328d928673df6f22de1abc0acb Merge: ecca117 c211818 Author: Murali Reddy Date: Mon May 13 21:22:19 2013 +0530 Merge branch 'master' into portablepublicip Conflicts: api/src/org/apache/cloudstack/api/ResponseGenerator.java server/src/com/cloud/api/ApiResponseHelper.java server/src/com/cloud/network/NetworkServiceImpl.java server/src/com/cloud/network/addr/PublicIp.java server/src/com/cloud/server/ManagementServerImpl.java server/test/com/cloud/network/MockNetworkManagerImpl.java server/test/com/cloud/vpc/MockConfigurationManagerImpl.java server/test/com/cloud/vpc/MockNetworkManagerImpl.java setup/db/db/schema-410to420.sql commit ecca117e345224059297f5c1ffa0f442209b3160 Author: Murali Reddy Date: Mon May 13 20:05:29 2013 +0530 added integration tests for testing portable ip ranges commit 895a27c2771dbb497ecc6fe0d212589f012a48d8 Author: Murali Reddy Date: Mon May 13 15:12:19 2013 +0530 - establish model for transferring portable IP association from a network with which it is associated to another network. - enabling static nat api, extended to transfer potrtable IP across the networks if the VM/network is different from the current associate network of the portable ip commit 51509751b290c0e51cbdd104a9aebff189cbe806 Author: Murali Reddy Date: Mon May 13 12:05:33 2013 +0530 seperate out associate/disassociate with guest network operations from alloc and release of portable ip commit bd058f58c2d8d36ec25e31ed9de4cd414e0ca051 Author: Murali Reddy Date: Sun May 12 21:14:48 2013 +0530 enhance disasociateIPAddr API to release protable IP associated with a guest network or VPC commit 27504d9098729e8c3ac3b33f053f2d66ac2c4401 Author: Murali Reddy Date: Sun May 12 16:53:45 2013 +0530 enhance asociateIPAddr API to acquire a protable IP and associate with a guest network or VPC commit f82c6a8431647114462665c1306c6215cb92afd3 Merge: 3dbfb44 0749013 Author: Murali Reddy Date: Sat May 11 23:32:13 2013 +0530 Merge branch 'master' into portablepublicip Conflicts: api/src/com/cloud/network/IpAddress.java api/src/org/apache/cloudstack/api/ResponseGenerator.java client/tomcatconf/commands.properties.in server/src/com/cloud/api/ApiResponseHelper.java server/src/com/cloud/configuration/ConfigurationManagerImpl.java server/src/com/cloud/server/ManagementServerImpl.java server/test/org/apache/cloudstack/affinity/AffinityApiTestConfiguration.java server/test/org/apache/cloudstack/networkoffering/ChildTestConfiguration.java setup/db/db/schema-410to420.sql commit 3dbfb44eb5b888367375a96b8ae0ac9cf54309a6 Author: Murali Reddy Date: Sat May 11 20:33:19 2013 +0530 - add 'portable' boolean as property of IpAddress, persist the property in IPAddressVO, return the property in IpAddressResponse - add ability to request portable IP in associateIpAddress api commit bf3cb274cfeb1ef41c63794ced83c7c6940f34cc Author: Murali Reddy Date: Sat May 11 16:08:40 2013 +0530 add the status of each portable IP (its state, details of associated data center/VPC/guest network etc) in the PortableIpRangeResponse returned by listPortableIpRanges API commit e7b2fb22557cb4ef0ce9c8dde3ed1b9c857038bf Author: Murali Reddy Date: Sat May 11 14:36:01 2013 +0530 Introdcues notion of 'portable IP' pool at region level. Introduces root admin only API's to provision portable ip to a region - createPortableIpRange - deletePortableIpRange - listPortableIpRanges --- api/src/com/cloud/async/AsyncJob.java | 1 + .../configuration/ConfigurationService.java | 13 + api/src/com/cloud/event/EventTypes.java | 5 + api/src/com/cloud/network/IpAddress.java | 4 +- api/src/com/cloud/network/NetworkService.java | 5 + .../apache/cloudstack/api/ApiConstants.java | 2 + .../cloudstack/api/ResponseGenerator.java | 9 +- .../region/CreatePortableIpRangeCmd.java | 156 +++++++++++ .../region/DeletePortableIpRangeCmd.java | 93 +++++++ .../admin/region/ListPortableIpRangesCmd.java | 109 ++++++++ .../user/address/AssociateIPAddrCmd.java | 28 +- .../user/address/DisassociateIPAddrCmd.java | 12 +- .../command/user/nat/EnableStaticNatCmd.java | 6 + .../api/response/IPAddressResponse.java | 7 + .../api/response/PortableIpRangeResponse.java | 93 +++++++ .../api/response/PortableIpResponse.java | 106 +++++++ .../apache/cloudstack/region/PortableIp.java | 58 ++++ .../cloudstack/region/PortableIpRange.java | 38 +++ client/tomcatconf/applicationContext.xml.in | 2 + client/tomcatconf/commands.properties.in | 6 + .../com/cloud/network/dao/IPAddressVO.java | 24 ++ .../src/com/cloud/api/ApiResponseHelper.java | 70 ++++- .../ConfigurationManagerImpl.java | 165 ++++++++++- .../src/com/cloud/network/NetworkManager.java | 14 + .../com/cloud/network/NetworkManagerImpl.java | 262 +++++++++++++++++- .../com/cloud/network/NetworkServiceImpl.java | 105 ++++--- .../src/com/cloud/network/addr/PublicIp.java | 9 + .../cloud/network/rules/RulesManagerImpl.java | 43 +++ .../cloud/server/ManagementServerImpl.java | 86 +++++- .../cloudstack/region/PortableIpDao.java | 39 +++ .../cloudstack/region/PortableIpDaoImpl.java | 131 +++++++++ .../cloudstack/region/PortableIpRangeDao.java | 30 ++ .../region/PortableIpRangeDaoImpl.java | 65 +++++ .../cloudstack/region/PortableIpRangeVO.java | 119 ++++++++ .../cloudstack/region/PortableIpVO.java | 222 +++++++++++++++ .../cloud/network/MockNetworkManagerImpl.java | 40 ++- .../vpc/MockConfigurationManagerImpl.java | 58 ++++ .../com/cloud/vpc/MockNetworkManagerImpl.java | 41 ++- .../ChildTestConfiguration.java | 7 + setup/db/db/schema-410to420.sql | 37 +++ .../smoke/test_portable_publicip.py | 237 ++++++++++++++++ tools/marvin/marvin/integration/lib/base.py | 36 +++ utils/src/com/cloud/utils/net/NetUtils.java | 13 + 43 files changed, 2542 insertions(+), 64 deletions(-) create mode 100644 api/src/org/apache/cloudstack/api/command/admin/region/CreatePortableIpRangeCmd.java create mode 100644 api/src/org/apache/cloudstack/api/command/admin/region/DeletePortableIpRangeCmd.java create mode 100644 api/src/org/apache/cloudstack/api/command/admin/region/ListPortableIpRangesCmd.java create mode 100644 api/src/org/apache/cloudstack/api/response/PortableIpRangeResponse.java create mode 100644 api/src/org/apache/cloudstack/api/response/PortableIpResponse.java create mode 100644 api/src/org/apache/cloudstack/region/PortableIp.java create mode 100644 api/src/org/apache/cloudstack/region/PortableIpRange.java create mode 100755 server/src/org/apache/cloudstack/region/PortableIpDao.java create mode 100755 server/src/org/apache/cloudstack/region/PortableIpDaoImpl.java create mode 100755 server/src/org/apache/cloudstack/region/PortableIpRangeDao.java create mode 100755 server/src/org/apache/cloudstack/region/PortableIpRangeDaoImpl.java create mode 100644 server/src/org/apache/cloudstack/region/PortableIpRangeVO.java create mode 100644 server/src/org/apache/cloudstack/region/PortableIpVO.java create mode 100644 test/integration/smoke/test_portable_publicip.py diff --git a/api/src/com/cloud/async/AsyncJob.java b/api/src/com/cloud/async/AsyncJob.java index ccdc40620b7..47f9b574e23 100644 --- a/api/src/com/cloud/async/AsyncJob.java +++ b/api/src/com/cloud/async/AsyncJob.java @@ -35,6 +35,7 @@ public interface AsyncJob extends Identity, InternalIdentity { Host, StoragePool, IpAddress, + PortableIpAddress, SecurityGroup, PhysicalNetwork, TrafficType, diff --git a/api/src/com/cloud/configuration/ConfigurationService.java b/api/src/com/cloud/configuration/ConfigurationService.java index fdbd9d6bb0b..381fcad95cc 100644 --- a/api/src/com/cloud/configuration/ConfigurationService.java +++ b/api/src/com/cloud/configuration/ConfigurationService.java @@ -39,6 +39,9 @@ import org.apache.cloudstack.api.command.admin.offering.UpdateDiskOfferingCmd; import org.apache.cloudstack.api.command.admin.offering.UpdateServiceOfferingCmd; import org.apache.cloudstack.api.command.admin.pod.DeletePodCmd; import org.apache.cloudstack.api.command.admin.pod.UpdatePodCmd; +import org.apache.cloudstack.api.command.admin.region.CreatePortableIpRangeCmd; +import org.apache.cloudstack.api.command.admin.region.DeletePortableIpRangeCmd; +import org.apache.cloudstack.api.command.admin.region.ListPortableIpRangesCmd; import org.apache.cloudstack.api.command.admin.vlan.CreateVlanIpRangeCmd; import org.apache.cloudstack.api.command.admin.vlan.DedicatePublicIpRangeCmd; import org.apache.cloudstack.api.command.admin.vlan.DeleteVlanIpRangeCmd; @@ -56,6 +59,8 @@ import com.cloud.offering.DiskOffering; import com.cloud.offering.NetworkOffering; import com.cloud.offering.ServiceOffering; import com.cloud.user.Account; +import org.apache.cloudstack.region.PortableIp; +import org.apache.cloudstack.region.PortableIpRange; public interface ConfigurationService { @@ -278,4 +283,12 @@ public interface ConfigurationService { * @return */ boolean isOfferingForVpc(NetworkOffering offering); + + PortableIpRange createPortableIpRange(CreatePortableIpRangeCmd cmd) throws ConcurrentOperationException; + + boolean deletePortableIpRange(DeletePortableIpRangeCmd cmd); + + List listPortableIpRanges(ListPortableIpRangesCmd cmd); + + List listPortableIps(long id); } diff --git a/api/src/com/cloud/event/EventTypes.java b/api/src/com/cloud/event/EventTypes.java index 9c83f13ea2a..fcac8e8e65d 100755 --- a/api/src/com/cloud/event/EventTypes.java +++ b/api/src/com/cloud/event/EventTypes.java @@ -102,6 +102,8 @@ public class EventTypes { // Network Events public static final String EVENT_NET_IP_ASSIGN = "NET.IPASSIGN"; public static final String EVENT_NET_IP_RELEASE = "NET.IPRELEASE"; + public static final String EVENT_PORTABLE_IP_ASSIGN = "PORTABLE.IPASSIGN"; + public static final String EVENT_PORTABLE_IP_RELEASE = "PORTABLEIPRELEASE"; public static final String EVENT_NET_RULE_ADD = "NET.RULEADD"; public static final String EVENT_NET_RULE_DELETE = "NET.RULEDELETE"; public static final String EVENT_NET_RULE_MODIFY = "NET.RULEMODIFY"; @@ -432,6 +434,9 @@ public class EventTypes { public static final String EVENT_DEDICATED_GUEST_VLAN_RANGE_RELEASE = "GUESTVLANRANGE.RELEASE"; + public static final String EVENT_PORTABLE_IP_RANGE_CREATE = "PORTABLE.IP.RANGE.CREATE"; + public static final String EVENT_PORTABLE_IP_RANGE_DELETE = "PORTABLE.IP.RANGE.DELETE"; + static { // TODO: need a way to force author adding event types to declare the entity details as well, with out braking diff --git a/api/src/com/cloud/network/IpAddress.java b/api/src/com/cloud/network/IpAddress.java index c48e8b97ca8..de11a6de79b 100644 --- a/api/src/com/cloud/network/IpAddress.java +++ b/api/src/com/cloud/network/IpAddress.java @@ -81,7 +81,9 @@ public interface IpAddress extends ControlledEntity, Identity, InternalIdentity Long getVpcId(); String getVmIp(); - + + boolean isPortable(); + Long getNetworkId(); } diff --git a/api/src/com/cloud/network/NetworkService.java b/api/src/com/cloud/network/NetworkService.java index 2e50c53d8bb..59702a2864e 100755 --- a/api/src/com/cloud/network/NetworkService.java +++ b/api/src/com/cloud/network/NetworkService.java @@ -52,6 +52,11 @@ public interface NetworkService { boolean releaseIpAddress(long ipAddressId) throws InsufficientAddressCapacityException; + IpAddress allocatePortableIP(Account ipOwner, int regionId, Long zoneId, Long networkId, Long vpcId) throws ResourceAllocationException, + InsufficientAddressCapacityException, ConcurrentOperationException; + + boolean releasePortableIpAddress(long ipAddressId) throws InsufficientAddressCapacityException; + Network createGuestNetwork(CreateNetworkCmd cmd) throws InsufficientCapacityException, ConcurrentOperationException, ResourceAllocationException; diff --git a/api/src/org/apache/cloudstack/api/ApiConstants.java b/api/src/org/apache/cloudstack/api/ApiConstants.java index cf093bf4c7c..1e9435f6a8e 100755 --- a/api/src/org/apache/cloudstack/api/ApiConstants.java +++ b/api/src/org/apache/cloudstack/api/ApiConstants.java @@ -114,6 +114,7 @@ public class ApiConstants { public static final String IS_CLEANUP_REQUIRED = "iscleanuprequired"; public static final String IS_EXTRACTABLE = "isextractable"; public static final String IS_FEATURED = "isfeatured"; + public static final String IS_PORTABLE = "isportable"; public static final String IS_PUBLIC = "ispublic"; public static final String IS_PERSISTENT = "ispersistent"; public static final String IS_READY = "isready"; @@ -158,6 +159,7 @@ public class ApiConstants { public static final String POLICY_ID = "policyid"; public static final String PORT = "port"; public static final String PORTAL = "portal"; + public static final String PORTABLE_IP_ADDRESS = "portableipaddress"; public static final String PORT_FORWARDING_SERVICE_ID = "portforwardingserviceid"; public static final String PRIVATE_INTERFACE = "privateinterface"; public static final String PRIVATE_IP = "privateip"; diff --git a/api/src/org/apache/cloudstack/api/ResponseGenerator.java b/api/src/org/apache/cloudstack/api/ResponseGenerator.java index 10bf305cb1c..0732e77a781 100644 --- a/api/src/org/apache/cloudstack/api/ResponseGenerator.java +++ b/api/src/org/apache/cloudstack/api/ResponseGenerator.java @@ -119,6 +119,8 @@ import org.apache.cloudstack.api.response.ZoneResponse; import org.apache.cloudstack.api.response.*; import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule; import org.apache.cloudstack.region.Region; +import org.apache.cloudstack.region.PortableIp; +import org.apache.cloudstack.region.PortableIpRange; import org.apache.cloudstack.usage.Usage; import com.cloud.async.AsyncJob; @@ -441,7 +443,12 @@ public interface ResponseGenerator { Long getAffinityGroupId(String name, long entityOwnerId); + PortableIpRangeResponse createPortableIPRangeResponse(PortableIpRange range); + + PortableIpResponse createPortableIPResponse(PortableIp portableIp); + InternalLoadBalancerElementResponse createInternalLbElementResponse(VirtualRouterProvider result); - + IsolationMethodResponse createIsolationMethodResponse(IsolationType method); + } diff --git a/api/src/org/apache/cloudstack/api/command/admin/region/CreatePortableIpRangeCmd.java b/api/src/org/apache/cloudstack/api/command/admin/region/CreatePortableIpRangeCmd.java new file mode 100644 index 00000000000..78e4c94ed4c --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/region/CreatePortableIpRangeCmd.java @@ -0,0 +1,156 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package org.apache.cloudstack.api.command.admin.region; + +import javax.inject.Inject; + +import com.cloud.async.AsyncJob; +import com.cloud.dc.Vlan; +import com.cloud.event.EventTypes; +import com.cloud.exception.ConcurrentOperationException; +import com.cloud.exception.InsufficientCapacityException; +import com.cloud.exception.ResourceAllocationException; +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.BaseAsyncCreateCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.response.PortableIpRangeResponse; +import org.apache.cloudstack.api.response.RegionResponse; +import org.apache.cloudstack.api.response.VlanIpRangeResponse; +import org.apache.cloudstack.region.PortableIpRange; +import org.apache.cloudstack.region.Region; +import org.apache.cloudstack.region.RegionService; +import org.apache.log4j.Logger; + +import com.cloud.user.Account; + +@APICommand(name = "createPortableIpRange", responseObject=PortableIpRangeResponse.class, description="adds a range of portable public IP's to a region", since="4.2.0") +public class CreatePortableIpRangeCmd extends BaseAsyncCreateCmd { + + public static final Logger s_logger = Logger.getLogger(CreatePortableIpRangeCmd.class.getName()); + + private static final String s_name = "createportableiprangeresponse"; + + ///////////////////////////////////////////////////// + //////////////// API parameters ///////////////////// + ///////////////////////////////////////////////////// + + @Parameter(name=ApiConstants.REGION_ID, type=CommandType.INTEGER, entityType = RegionResponse.class, required=true, description="Id of the Region") + private Integer regionId; + + @Parameter(name=ApiConstants.START_IP, type=CommandType.STRING, required=true, description="the beginning IP address in the portable IP range") + private String startIp; + + @Parameter(name=ApiConstants.END_IP, type=CommandType.STRING, required=true, description="the ending IP address in the portable IP range") + private String endIp; + + @Parameter(name=ApiConstants.GATEWAY, type=CommandType.STRING, required=true, description="the gateway for the portable IP range") + private String gateway; + + @Parameter(name=ApiConstants.NETMASK, type=CommandType.STRING, required=true, description="the netmask of the portable IP range") + private String netmask; + + @Parameter(name=ApiConstants.VLAN, type=CommandType.STRING, description="VLAN id, if not specified defaulted to untagged") + private String vlan; + + ///////////////////////////////////////////////////// + /////////////////// Accessors /////////////////////// + ///////////////////////////////////////////////////// + + public Integer getRegionId() { + return regionId; + } + + public String getStartIp() { + return startIp; + } + + public String getEndIp() { + return endIp; + } + + public String getVlan() { + return vlan; + } + + public String getGateway() { + return gateway; + } + + public String getNetmask() { + return netmask; + } + + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public long getEntityOwnerId() { + return Account.ACCOUNT_ID_SYSTEM; + } + + @Override + public void execute(){ + PortableIpRange portableIpRange = _entityMgr.findById(PortableIpRange.class, getEntityId()); + PortableIpRangeResponse response = null; + if (portableIpRange != null) { + response = _responseGenerator.createPortableIPRangeResponse(portableIpRange); + } + response.setResponseName(getCommandName()); + this.setResponseObject(response); + } + + @Override + public void create() throws ResourceAllocationException { + try { + PortableIpRange portableIpRange = _configService.createPortableIpRange(this); + if (portableIpRange != null) { + this.setEntityId(portableIpRange.getId()); + this.setEntityUuid(portableIpRange.getUuid()); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create portable public IP range"); + } + } catch (ConcurrentOperationException ex) { + s_logger.warn("Exception: ", ex); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); + } + } + + @Override + public String getEventType() { + return EventTypes.EVENT_PORTABLE_IP_RANGE_CREATE; + } + + @Override + public String getEventDescription() { + return "creating a portable public ip range in region: " + getRegionId(); + } + + @Override + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.PortableIpAddress; + } +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/region/DeletePortableIpRangeCmd.java b/api/src/org/apache/cloudstack/api/command/admin/region/DeletePortableIpRangeCmd.java new file mode 100644 index 00000000000..856e8efa210 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/region/DeletePortableIpRangeCmd.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 org.apache.cloudstack.api.command.admin.region; + +import javax.inject.Inject; + +import com.cloud.async.AsyncJob; +import com.cloud.event.EventTypes; +import org.apache.cloudstack.api.*; +import org.apache.cloudstack.api.response.PortableIpRangeResponse; +import org.apache.cloudstack.api.response.RegionResponse; +import org.apache.cloudstack.api.response.SuccessResponse; +import org.apache.cloudstack.region.Region; +import org.apache.cloudstack.region.RegionService; +import org.apache.log4j.Logger; + +import com.cloud.user.Account; + +@APICommand(name = "deletePortableIpRange", description="deletes a range of portable public IP's associated with a region", responseObject=SuccessResponse.class) +public class DeletePortableIpRangeCmd extends BaseAsyncCmd { + public static final Logger s_logger = Logger.getLogger(DeletePortableIpRangeCmd.class.getName()); + + private static final String s_name = "deleteportablepublicipresponse"; + + ///////////////////////////////////////////////////// + //////////////// API parameters ///////////////////// + ///////////////////////////////////////////////////// + @Parameter(name=ApiConstants.ID, type=CommandType.UUID, required=true, entityType = PortableIpRangeResponse.class, description="Id of the portable ip range") + private Long id; + + ///////////////////////////////////////////////////// + /////////////////// Accessors /////////////////////// + ///////////////////////////////////////////////////// + + public Long getId() { + return id; + } + + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public long getEntityOwnerId() { + return Account.ACCOUNT_ID_SYSTEM; + } + + @Override + public void execute(){ + boolean result = _configService.deletePortableIpRange(this); + if (result) { + SuccessResponse response = new SuccessResponse(getCommandName()); + this.setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete portable ip range"); + } + } + + @Override + public String getEventType() { + return EventTypes.EVENT_PORTABLE_IP_RANGE_DELETE; + } + + @Override + public String getEventDescription() { + return "deleting a portable public ip range"; + } + + @Override + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.PortableIpAddress; + } +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/region/ListPortableIpRangesCmd.java b/api/src/org/apache/cloudstack/api/command/admin/region/ListPortableIpRangesCmd.java new file mode 100644 index 00000000000..75bcce00acf --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/region/ListPortableIpRangesCmd.java @@ -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. +package org.apache.cloudstack.api.command.admin.region; + +import javax.inject.Inject; + +import org.apache.cloudstack.api.*; +import org.apache.cloudstack.api.response.ListResponse; +import org.apache.cloudstack.api.response.PortableIpRangeResponse; +import org.apache.cloudstack.api.response.PortableIpResponse; +import org.apache.cloudstack.api.response.RegionResponse; +import org.apache.cloudstack.region.PortableIp; +import org.apache.cloudstack.region.PortableIpRange; +import org.apache.cloudstack.region.Region; +import org.apache.cloudstack.region.RegionService; +import org.apache.log4j.Logger; + +import com.cloud.user.Account; + +import java.util.ArrayList; +import java.util.List; + +@APICommand(name = "listPortableIpRanges", description="list portable IP ranges", responseObject=PortableIpRangeResponse.class) +public class ListPortableIpRangesCmd extends BaseListCmd { + + public static final Logger s_logger = Logger.getLogger(ListPortableIpRangesCmd.class.getName()); + + private static final String s_name = "listportableipresponse"; + + ///////////////////////////////////////////////////// + //////////////// API parameters ///////////////////// + ///////////////////////////////////////////////////// + + @Parameter(name=ApiConstants.REGION_ID, type=CommandType.INTEGER, required=false, description="Id of a Region") + private Integer regionId; + + @Parameter(name=ApiConstants.ID, type=CommandType.UUID, required=false, entityType = PortableIpRangeResponse.class, description="Id of the portable ip range") + private Long id; + + ///////////////////////////////////////////////////// + /////////////////// Accessors /////////////////////// + ///////////////////////////////////////////////////// + + public Integer getRegionIdId() { + return regionId; + } + + public Long getPortableIpRangeId() { + return id; + } + + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public long getEntityOwnerId() { + return Account.ACCOUNT_ID_SYSTEM; + } + + @Override + public void execute(){ + ListResponse response = new ListResponse(); + List responses = new ArrayList(); + List portableIpRanges = new ArrayList(); + + portableIpRanges = _configService.listPortableIpRanges(this); + if (portableIpRanges != null && !portableIpRanges.isEmpty()) { + for (PortableIpRange range : portableIpRanges) { + PortableIpRangeResponse rangeResponse = _responseGenerator.createPortableIPRangeResponse(range); + + List portableIps = _configService.listPortableIps(range.getId()); + if (portableIps != null && !portableIps.isEmpty()) { + List portableIpResponses = new ArrayList(); + for (PortableIp portableIP: portableIps) { + PortableIpResponse portableIpresponse = _responseGenerator.createPortableIPResponse(portableIP); + portableIpResponses.add(portableIpresponse); + } + rangeResponse.setPortableIpResponses(portableIpResponses); + } + + rangeResponse.setObjectName("portableiprange"); + responses.add(rangeResponse); + } + } + response.setResponses(responses, portableIpRanges.size()); + response.setResponseName(getCommandName()); + this.setResponseObject(response); + } +} diff --git a/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java b/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java index 28fbae4437a..f37e82060fb 100644 --- a/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java @@ -66,6 +66,14 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd { "be associated with") private Long vpcId; + @Parameter(name=ApiConstants.IS_PORTABLE, type = BaseCmd.CommandType.BOOLEAN, description = "should be set to true " + + "if public IP is required to be transferable across zones, if not specified defaults to false") + private Boolean isPortable; + + @Parameter(name=ApiConstants.REGION_ID, type=CommandType.INTEGER, entityType = RegionResponse.class, + required=false, description="region ID from where portable ip is to be associated.") + private Integer regionId; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -107,6 +115,18 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd { return vpcId; } + public boolean isPortable() { + if (isPortable == null) { + return false; + } else { + return isPortable; + } + } + + public Integer getRegionId() { + return regionId; + } + public Long getNetworkId() { if (vpcId != null) { return null; @@ -196,7 +216,13 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd { @Override public void create() throws ResourceAllocationException{ try { - IpAddress ip = _networkService.allocateIP(_accountService.getAccount(getEntityOwnerId()), getZoneId(), getNetworkId()); + IpAddress ip = null; + + if (!isPortable()) { + ip = _networkService.allocateIP(_accountService.getAccount(getEntityOwnerId()), getZoneId(), getNetworkId()); + } else { + ip = _networkService.allocatePortableIP(_accountService.getAccount(getEntityOwnerId()), 1, getZoneId(), getNetworkId(), getVpcId()); + } if (ip != null) { this.setEntityId(ip.getId()); diff --git a/api/src/org/apache/cloudstack/api/command/user/address/DisassociateIPAddrCmd.java b/api/src/org/apache/cloudstack/api/command/user/address/DisassociateIPAddrCmd.java index 827111902ff..8f78fe3a959 100644 --- a/api/src/org/apache/cloudstack/api/command/user/address/DisassociateIPAddrCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/address/DisassociateIPAddrCmd.java @@ -74,7 +74,12 @@ public class DisassociateIPAddrCmd extends BaseAsyncCmd { @Override public void execute() throws InsufficientAddressCapacityException{ UserContext.current().setEventDetails("Ip Id: " + getIpAddressId()); - boolean result = _networkService.releaseIpAddress(getIpAddressId()); + boolean result = false; + if (!isPortable(id)) { + _networkService.releaseIpAddress(getIpAddressId()); + } else { + _networkService.releaseIpAddress(getIpAddressId()); + } if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); this.setResponseObject(response); @@ -139,4 +144,9 @@ public class DisassociateIPAddrCmd extends BaseAsyncCmd { public Long getInstanceId() { return getIpAddressId(); } + + private boolean isPortable(long id) { + IpAddress ip = getIpAddress(id); + return ip.isPortable(); + } } diff --git a/api/src/org/apache/cloudstack/api/command/user/nat/EnableStaticNatCmd.java b/api/src/org/apache/cloudstack/api/command/user/nat/EnableStaticNatCmd.java index 902dbae00aa..2e2e1507229 100644 --- a/api/src/org/apache/cloudstack/api/command/user/nat/EnableStaticNatCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/nat/EnableStaticNatCmd.java @@ -91,6 +91,12 @@ public class EnableStaticNatCmd extends BaseCmd{ } else { ntwkId = networkId; } + + // in case of portable public IP, network ID passed takes precedence + if (ip.isPortable() && networkId != null ) { + ntwkId = networkId; + } + if (ntwkId == null) { throw new InvalidParameterValueException("Unable to enable static nat for the ipAddress id=" + ipAddressId + " as ip is not associated with any network and no networkId is passed in"); diff --git a/api/src/org/apache/cloudstack/api/response/IPAddressResponse.java b/api/src/org/apache/cloudstack/api/response/IPAddressResponse.java index cede84f931e..e3d5cc6a101 100644 --- a/api/src/org/apache/cloudstack/api/response/IPAddressResponse.java +++ b/api/src/org/apache/cloudstack/api/response/IPAddressResponse.java @@ -115,6 +115,9 @@ public class IPAddressResponse extends BaseResponse implements ControlledEntityR @SerializedName(ApiConstants.TAGS) @Param(description="the list of resource tags associated with ip address", responseObject = ResourceTagResponse.class) private List tags; + @SerializedName(ApiConstants.IS_PORTABLE) @Param(description = "is public IP portable across the zones") + private Boolean isPortable; + /* @SerializedName(ApiConstants.JOB_ID) @Param(description="shows the current pending asynchronous job ID. This tag is not returned if no current pending jobs are acting on the volume") private IdentityProxy jobId = new IdentityProxy("async_job"); @@ -247,4 +250,8 @@ public class IPAddressResponse extends BaseResponse implements ControlledEntityR public void setAssociatedNetworkName(String associatedNetworkName) { this.associatedNetworkName = associatedNetworkName; } + + public void setPortable(Boolean portable) { + this.isPortable = portable; + } } diff --git a/api/src/org/apache/cloudstack/api/response/PortableIpRangeResponse.java b/api/src/org/apache/cloudstack/api/response/PortableIpRangeResponse.java new file mode 100644 index 00000000000..e7a15b8f606 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/response/PortableIpRangeResponse.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 org.apache.cloudstack.api.response; + +import java.util.Date; +import java.util.List; + +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.BaseResponse; +import org.apache.cloudstack.api.EntityReference; + +import com.cloud.network.IpAddress; +import com.cloud.serializer.Param; +import com.google.gson.annotations.SerializedName; +import org.apache.cloudstack.region.PortableIpRange; + +@EntityReference(value=PortableIpRange.class) +public class PortableIpRangeResponse extends BaseResponse { + + @SerializedName(ApiConstants.ID) + @Param(description = "portable IP range ID") + private String id; + + @SerializedName(ApiConstants.REGION_ID) + @Param(description = "Region Id in which portable ip range is provisioned") + private Integer regionId; + + @SerializedName(ApiConstants.GATEWAY) @Param(description="the gateway of the VLAN IP range") + private String gateway; + + @SerializedName(ApiConstants.NETMASK) @Param(description="the netmask of the VLAN IP range") + private String netmask; + + @SerializedName(ApiConstants.VLAN) @Param(description="the ID or VID of the VLAN.") + private String vlan; + + @SerializedName(ApiConstants.START_IP) @Param(description="the start ip of the portable IP range") + private String startIp; + + @SerializedName(ApiConstants.END_IP) @Param(description="the end ip of the portable IP range") + private String endIp; + + @SerializedName(ApiConstants.PORTABLE_IP_ADDRESS) + @Param(description="List of portable IP and association with zone/network/vpc details that are part of GSLB rule", responseObject = PortableIpResponse.class) + private List portableIpResponses; + + public void setId(String id) { + this.id = id; + } + + public void setRegionId(int regionId) { + this.regionId = regionId; + } + + public void setStartIp(String startIp) { + this.startIp = startIp; + } + + public void setEndIp(String endIp) { + this.endIp = endIp; + } + + public void setNetmask(String netmask) { + this.netmask = netmask; + } + + public void setGateway(String gateway) { + this.gateway = gateway; + } + + public void setVlan(String vlan) { + this.vlan = vlan; + } + + public void setPortableIpResponses(List portableIpResponses) { + this.portableIpResponses = portableIpResponses; + } +} diff --git a/api/src/org/apache/cloudstack/api/response/PortableIpResponse.java b/api/src/org/apache/cloudstack/api/response/PortableIpResponse.java new file mode 100644 index 00000000000..0ccbcc3e5f6 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/response/PortableIpResponse.java @@ -0,0 +1,106 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package org.apache.cloudstack.api.response; + +import java.util.Date; +import java.util.List; + +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.BaseResponse; +import org.apache.cloudstack.api.EntityReference; + +import com.cloud.network.IpAddress; +import com.cloud.serializer.Param; +import com.google.gson.annotations.SerializedName; +import org.apache.cloudstack.region.PortableIp; +import org.apache.cloudstack.region.PortableIpRange; + +@EntityReference(value=PortableIp.class) +public class PortableIpResponse extends BaseResponse { + + @SerializedName(ApiConstants.REGION_ID) + @Param(description = "Region Id in which global load balancer is created") + private Integer regionId; + + @SerializedName(ApiConstants.IP_ADDRESS) @Param(description="public IP address") + private String ipAddress; + + @SerializedName(ApiConstants.ZONE_ID) @Param(description="the ID of the zone the public IP address belongs to") + private String zoneId; + + @SerializedName(ApiConstants.NETWORK_ID) @Param(description="the ID of the Network where ip belongs to") + private String networkId; + + @SerializedName(ApiConstants.VPC_ID) @Param(description="VPC the ip belongs to") + private String vpcId; + + @SerializedName(ApiConstants.PHYSICAL_NETWORK_ID) @Param(description="the physical network this belongs to") + private String physicalNetworkId; + + @SerializedName(ApiConstants.ACCOUNT_ID) @Param(description="the account ID the portable IP address is associated with") + private String accountId; + + @SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the domain ID the portable IP address is associated with") + private String domainId; + + @SerializedName("allocated") @Param(description="date the portal IP address was acquired") + private Date allocated; + + @SerializedName(ApiConstants.STATE) @Param(description="State of the ip address. Can be: Allocatin, Allocated and Releasing") + private String state; + + public void setRegionId(Integer regionId) { + this.regionId = regionId; + } + + public void setAddress(String ipAddress) { + this.ipAddress = ipAddress; + } + + public void setAssociatedDataCenterId(String zoneId) { + this.zoneId = zoneId; + } + + public void setAssociatedWithNetworkId(String networkId) { + this.networkId = networkId; + } + + public void setAssociatedWithVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public void setPhysicalNetworkId(String physicalNetworkId) { + this.physicalNetworkId = physicalNetworkId; + } + + public void setAllocatedToAccountId(String accountId) { + this.accountId = accountId; + } + + public void setAllocatedInDomainId(String domainId) { + this.domainId = domainId; + } + + public void setAllocatedTime(Date allocatedTimetime) { + this.allocated = allocatedTimetime; + } + + public void setState(String state) { + this.state = state; + } +} diff --git a/api/src/org/apache/cloudstack/region/PortableIp.java b/api/src/org/apache/cloudstack/region/PortableIp.java new file mode 100644 index 00000000000..b95071e2456 --- /dev/null +++ b/api/src/org/apache/cloudstack/region/PortableIp.java @@ -0,0 +1,58 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package org.apache.cloudstack.region; + +import java.util.Date; + +import com.cloud.utils.net.Ip; +import org.apache.cloudstack.api.InternalIdentity; + +public interface PortableIp extends InternalIdentity { + + enum State { + Allocating, // The IP Address is being propagated to other network elements and is not ready for use yet. + Allocated, // The IP address is in used. + Releasing, // The IP address is being released for other network elements and is not ready for allocation. + Free // The IP address is ready to be allocated. + } + + Long getAllocatedToAccountId(); + + Long getAllocatedInDomainId(); + + Date getAllocatedTime(); + + State getState(); + + int getRegionId(); + + Long getAssociatedDataCenterId(); + + Long getAssociatedWithNetworkId(); + + Long getAssociatedWithVpcId(); + + Long getPhysicalNetworkId(); + + String getAddress(); + + String getVlan(); + + String getNetmask(); + + String getGateway(); +} diff --git a/api/src/org/apache/cloudstack/region/PortableIpRange.java b/api/src/org/apache/cloudstack/region/PortableIpRange.java new file mode 100644 index 00000000000..413a540f92a --- /dev/null +++ b/api/src/org/apache/cloudstack/region/PortableIpRange.java @@ -0,0 +1,38 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package org.apache.cloudstack.region; + +import org.apache.cloudstack.acl.InfrastructureEntity; +import org.apache.cloudstack.api.Identity; +import org.apache.cloudstack.api.InternalIdentity; + +public interface PortableIpRange extends InfrastructureEntity, InternalIdentity, Identity { + + public final static String UNTAGGED = "untagged"; + + public String getVlanTag(); + + public String getGateway(); + + public String getNetmask(); + + public int getRegionId(); + + public String getIpRange(); + +} diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in index b500fde8549..edf83a94ae6 100644 --- a/client/tomcatconf/applicationContext.xml.in +++ b/client/tomcatconf/applicationContext.xml.in @@ -271,6 +271,8 @@ + + diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in index 68a7511560b..fd5479f44b4 100644 --- a/client/tomcatconf/commands.properties.in +++ b/client/tomcatconf/commands.properties.in @@ -628,6 +628,11 @@ addCiscoAsa1000vResource=1 deleteCiscoAsa1000vResource=1 listCiscoAsa1000vResources=1 +#### portable public IP commands +createPortableIpRange=1 +deletePortableIpRange=1 +listPortableIpRanges=1 + #### Internal LB VM commands stopInternalLoadBalancerVM=1 startInternalLoadBalancerVM=1 @@ -635,3 +640,4 @@ listInternalLoadBalancerVMs=1 ### Network Isolation methods listing listNetworkIsolationMethods=1 + diff --git a/engine/schema/src/com/cloud/network/dao/IPAddressVO.java b/engine/schema/src/com/cloud/network/dao/IPAddressVO.java index ae27e95ce4b..5eb2500e0a6 100644 --- a/engine/schema/src/com/cloud/network/dao/IPAddressVO.java +++ b/engine/schema/src/com/cloud/network/dao/IPAddressVO.java @@ -111,6 +111,8 @@ public class IPAddressVO implements IpAddress { @Column(name="dnat_vmip") private String vmIp; + @Column(name="is_portable") + private boolean portable = false; protected IPAddressVO() { this.uuid = UUID.randomUUID().toString(); @@ -134,6 +136,19 @@ public class IPAddressVO implements IpAddress { this.uuid = UUID.randomUUID().toString(); } + public IPAddressVO(Ip address, long dataCenterId, Long networkId, Long vpcId, long physicalNetworkId, long sourceNetworkId, + long vlanDbId, boolean portable) { + this.address = address; + this.dataCenterId = dataCenterId; + this.associatedWithNetworkId = networkId; + this.vpcId = vpcId; + this.physicalNetworkId = physicalNetworkId; + this.sourceNetworkId = sourceNetworkId; + this.vlanId = vlanDbId; + this.portable = portable; + this.uuid = UUID.randomUUID().toString(); + } + public long getMacAddress() { return macAddress; } @@ -283,6 +298,15 @@ public class IPAddressVO implements IpAddress { this.system = isSystem; } + @Override + public boolean isPortable() { + return portable; + } + + public void setPortable(boolean portable) { + this.portable = portable; + } + @Override public Long getVpcId() { return vpcId; diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index 49e36dc47db..fc1c6a0be63 100755 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -49,6 +49,8 @@ import org.apache.cloudstack.api.ApiConstants.VMDetails; import org.apache.cloudstack.api.BaseCmd; import org.apache.cloudstack.api.ResponseGenerator; import org.apache.cloudstack.api.command.user.job.QueryAsyncJobResultCmd; +import org.apache.cloudstack.region.PortableIp; +import org.apache.cloudstack.region.PortableIpRange; import org.apache.cloudstack.api.response.AccountResponse; import org.apache.cloudstack.api.response.ApplicationLoadBalancerInstanceResponse; import org.apache.cloudstack.api.response.ApplicationLoadBalancerResponse; @@ -98,6 +100,8 @@ import org.apache.cloudstack.api.response.NicResponse; import org.apache.cloudstack.api.response.NicSecondaryIpResponse; import org.apache.cloudstack.api.response.PhysicalNetworkResponse; import org.apache.cloudstack.api.response.PodResponse; +import org.apache.cloudstack.api.response.PortableIpRangeResponse; +import org.apache.cloudstack.api.response.PortableIpResponse; import org.apache.cloudstack.api.response.PrivateGatewayResponse; import org.apache.cloudstack.api.response.ProjectAccountResponse; import org.apache.cloudstack.api.response.ProjectInvitationResponse; @@ -722,6 +726,8 @@ public class ApiResponseHelper implements ResponseGenerator { } } + ipResponse.setPortable(ipAddr.isPortable()); + //set tag information List tags = ApiDBUtils.listByResourceTypeAndId(TaggedResourceType.PublicIpAddress, ipAddr.getId()); List tagResponses = new ArrayList(); @@ -3824,6 +3830,69 @@ public class ApiResponseHelper implements ResponseGenerator { } } + @Override + public PortableIpRangeResponse createPortableIPRangeResponse(PortableIpRange ipRange) { + PortableIpRangeResponse response = new PortableIpRangeResponse(); + response.setId(ipRange.getUuid()); + String ipRangeStr = ipRange.getIpRange(); + if (ipRangeStr != null) { + String[] range = ipRangeStr.split("-"); + response.setStartIp(range[0]); + response.setEndIp(range[1]); + } + response.setVlan(ipRange.getVlanTag()); + response.setGateway(ipRange.getGateway()); + response.setNetmask(ipRange.getNetmask()); + response.setRegionId(ipRange.getRegionId()); + return response; + } + + @Override + public PortableIpResponse createPortableIPResponse(PortableIp portableIp) { + PortableIpResponse response = new PortableIpResponse(); + response.setAddress(portableIp.getAddress()); + Long accountId = portableIp.getAllocatedInDomainId(); + if (accountId != null) { + Account account = ApiDBUtils.findAccountById(accountId); + response.setAllocatedToAccountId(account.getAccountName()); + Domain domain = ApiDBUtils.findDomainById(account.getDomainId()); + response.setAllocatedInDomainId(domain.getUuid()); + } + + response.setAllocatedTime(portableIp.getAllocatedTime()); + + if (portableIp.getAssociatedDataCenterId() != null) { + DataCenter zone = ApiDBUtils.findZoneById(portableIp.getAssociatedDataCenterId()); + if (zone != null) { + response.setAssociatedDataCenterId(zone.getUuid()); + } + } + + if (portableIp.getPhysicalNetworkId() != null) { + PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(portableIp.getPhysicalNetworkId()); + if (pnw != null) { + response.setPhysicalNetworkId(pnw.getUuid()); + } + } + + if (portableIp.getAssociatedWithNetworkId() != null) { + Network ntwk = ApiDBUtils.findNetworkById(portableIp.getAssociatedWithNetworkId()); + if (ntwk != null) { + response.setAssociatedWithNetworkId(ntwk.getUuid()); + } + } + + if (portableIp.getAssociatedWithVpcId() != null) { + Vpc vpc = ApiDBUtils.findVpcById(portableIp.getAssociatedWithVpcId()); + if (vpc != null) { + response.setAssociatedWithVpcId(vpc.getUuid()); + } + } + + response.setState(portableIp.getState().name()); + + return response; + } @Override public InternalLoadBalancerElementResponse createInternalLbElementResponse(VirtualRouterProvider result) { @@ -3842,7 +3911,6 @@ public class ApiResponseHelper implements ResponseGenerator { return response; } - @Override public IsolationMethodResponse createIsolationMethodResponse(IsolationType method) { IsolationMethodResponse response = new IsolationMethodResponse(); diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index 52d617646af..47c54822adb 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -43,6 +43,7 @@ import com.cloud.dc.*; import com.cloud.dc.dao.*; import com.cloud.user.*; import com.cloud.event.UsageEventUtils; +import com.cloud.utils.db.*; import org.apache.cloudstack.acl.SecurityChecker; import org.apache.cloudstack.api.ApiConstants.LDAPParams; import org.apache.cloudstack.api.command.admin.config.UpdateCfgCmd; @@ -59,6 +60,9 @@ import org.apache.cloudstack.api.command.admin.offering.UpdateDiskOfferingCmd; import org.apache.cloudstack.api.command.admin.offering.UpdateServiceOfferingCmd; import org.apache.cloudstack.api.command.admin.pod.DeletePodCmd; import org.apache.cloudstack.api.command.admin.pod.UpdatePodCmd; +import org.apache.cloudstack.api.command.admin.region.CreatePortableIpRangeCmd; +import org.apache.cloudstack.api.command.admin.region.DeletePortableIpRangeCmd; +import org.apache.cloudstack.api.command.admin.region.ListPortableIpRangesCmd; import org.apache.cloudstack.api.command.admin.vlan.CreateVlanIpRangeCmd; import org.apache.cloudstack.api.command.admin.vlan.DedicatePublicIpRangeCmd; import org.apache.cloudstack.api.command.admin.vlan.DeleteVlanIpRangeCmd; @@ -67,6 +71,8 @@ import org.apache.cloudstack.api.command.admin.zone.CreateZoneCmd; import org.apache.cloudstack.api.command.admin.zone.DeleteZoneCmd; import org.apache.cloudstack.api.command.admin.zone.UpdateZoneCmd; import org.apache.cloudstack.api.command.user.network.ListNetworkOfferingsCmd; +import org.apache.cloudstack.region.*; +import org.apache.cloudstack.region.dao.RegionDao; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO; import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao; @@ -186,10 +192,6 @@ import com.cloud.utils.NumbersUtil; import com.cloud.utils.StringUtils; import com.cloud.utils.component.ManagerBase; import com.cloud.utils.crypt.DBEncryptionUtil; -import com.cloud.utils.db.DB; -import com.cloud.utils.db.Filter; -import com.cloud.utils.db.SearchCriteria; -import com.cloud.utils.db.Transaction; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.net.NetUtils; import com.cloud.vm.NicIpAlias; @@ -332,6 +334,12 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati @Inject VpcManager _vpcMgr; @Inject + PortableIpRangeDao _portableIpRangeDao; + @Inject + RegionDao _regionDao; + @Inject + PortableIpDao _portableIpDao; + @Inject ConfigurationServer _configServer; @Inject DcDetailsDao _dcDetailsDao; @@ -4718,4 +4726,153 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati return null; } + + @Override + @DB + @ActionEvent(eventType = EventTypes.EVENT_PORTABLE_IP_RANGE_CREATE, eventDescription = "creating portable ip range", async = false) + public PortableIpRange createPortableIpRange(CreatePortableIpRangeCmd cmd) throws ConcurrentOperationException { + Integer regionId = cmd.getRegionId(); + String startIP = cmd.getStartIp(); + String endIP = cmd.getEndIp(); + String gateway = cmd.getGateway(); + String netmask = cmd.getNetmask(); + Long userId = UserContext.current().getCallerUserId(); + String vlanId = cmd.getVlan(); + + Region region = _regionDao.findById(regionId); + if (region == null) { + throw new InvalidParameterValueException("Invalid region ID: " + regionId); + } + + if (!NetUtils.isValidIp(startIP) || !NetUtils.isValidIp(endIP) || !NetUtils.validIpRange(startIP, endIP)) { + throw new InvalidParameterValueException("Invalid portable ip range: " + startIP + "-" + endIP); + } + + if (!NetUtils.sameSubnet(startIP, gateway, netmask)) { + throw new InvalidParameterValueException("Please ensure that your start IP is in the same subnet as " + + "your portable IP range's gateway and as per the IP range's netmask."); + } + + if (!NetUtils.sameSubnet(endIP, gateway, netmask)) { + throw new InvalidParameterValueException("Please ensure that your end IP is in the same subnet as " + + "your portable IP range's gateway and as per the IP range's netmask."); + } + + if (checkOverlapPortableIpRange(regionId, startIP, endIP)) { + throw new InvalidParameterValueException("Ip range: " + startIP + "-" + endIP + " overlaps with a portable" + + " IP range already configured in the region " + regionId); + } + + if (vlanId == null) { + vlanId = Vlan.UNTAGGED; + } else { + if (!NetUtils.isValidVlan(vlanId)) { + throw new InvalidParameterValueException("Invalid vlan id " + vlanId); + } + } + GlobalLock portableIpLock = GlobalLock.getInternLock("PortablePublicIpRange"); + portableIpLock.lock(5); + Transaction txn = Transaction.currentTxn(); + txn.start(); + + PortableIpRangeVO portableIpRange = new PortableIpRangeVO(regionId, vlanId, gateway, netmask, startIP, endIP); + portableIpRange = _portableIpRangeDao.persist(portableIpRange); + + long startIpLong = NetUtils.ip2Long(startIP); + long endIpLong = NetUtils.ip2Long(endIP); + while(startIpLong <= endIpLong) { + PortableIpVO portableIP = new PortableIpVO(regionId, portableIpRange.getId(), vlanId, + gateway, netmask,NetUtils.long2Ip(startIpLong)); + _portableIpDao.persist(portableIP); + startIpLong++; + } + + txn.commit(); + portableIpLock.unlock(); + return portableIpRange; + } + + @Override + @DB + @ActionEvent(eventType = EventTypes.EVENT_PORTABLE_IP_RANGE_DELETE, eventDescription = "deleting portable ip range", async = false) + public boolean deletePortableIpRange(DeletePortableIpRangeCmd cmd) { + long rangeId = cmd.getId(); + PortableIpRangeVO portableIpRange = _portableIpRangeDao.findById(rangeId); + if (portableIpRange == null) { + throw new InvalidParameterValueException("Please specify a valid portable IP range id."); + } + + List fullIpRange = _portableIpDao.listByRangeId(portableIpRange.getId()); + List freeIpRange = _portableIpDao.listByRangeIdAndState(portableIpRange.getId(), PortableIp.State.Free); + + if (fullIpRange != null && freeIpRange != null) { + if (fullIpRange.size() == freeIpRange.size()) { + _portableIpRangeDao.expunge(portableIpRange.getId()); + return true; + } else { + throw new InvalidParameterValueException("Can't delete portable IP range as there are IP's assigned."); + } + } + + return false; + } + + @Override + public List listPortableIpRanges(ListPortableIpRangesCmd cmd) { + Integer regionId = cmd.getRegionIdId(); + Long rangeId = cmd.getPortableIpRangeId(); + + List ranges = new ArrayList(); + if (regionId != null) { + Region region = _regionDao.findById(regionId); + if (region == null) { + throw new InvalidParameterValueException("Invalid region ID: " + regionId); + } + return _portableIpRangeDao.listByRegionId(regionId); + } + + if (rangeId != null) { + PortableIpRangeVO range = _portableIpRangeDao.findById(rangeId); + if (range == null) { + throw new InvalidParameterValueException("Invalid portable IP range ID: " + regionId); + } + ranges.add(range); + return ranges; + } + + return _portableIpRangeDao.listAll(); + } + + @Override + public List listPortableIps(long id) { + + PortableIpRangeVO portableIpRange = _portableIpRangeDao.findById(id); + if (portableIpRange == null) { + throw new InvalidParameterValueException("Please specify a valid portable IP range id."); + } + + return _portableIpDao.listByRangeId(portableIpRange.getId()); + } + + private boolean checkOverlapPortableIpRange(int regionId, String newStartIpStr, String newEndIpStr) { + long newStartIp = NetUtils.ip2Long(newStartIpStr); + long newEndIp = NetUtils.ip2Long(newEndIpStr); + + List existingPortableIPRanges = _portableIpRangeDao.listByRegionId(regionId); + for (PortableIpRangeVO portableIpRange : existingPortableIPRanges) { + String ipRangeStr = portableIpRange.getIpRange(); + String[] range = ipRangeStr.split("-"); + long startip = NetUtils.ip2Long(range[0]); + long endIp = NetUtils.ip2Long(range[1]); + + if ((newStartIp >= startip && newStartIp <= endIp) || (newEndIp >= startip && newEndIp <= endIp)) { + return true; + } + + if ((startip >= newStartIp && startip <= newEndIp) || (endIp >= newStartIp && endIp <= newEndIp)) { + return true; + } + } + return false; + } } diff --git a/server/src/com/cloud/network/NetworkManager.java b/server/src/com/cloud/network/NetworkManager.java index 08198ee40e6..1e4fb8437ce 100755 --- a/server/src/com/cloud/network/NetworkManager.java +++ b/server/src/com/cloud/network/NetworkManager.java @@ -59,6 +59,7 @@ import com.cloud.vm.VMInstanceVO; import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachine.Type; import com.cloud.vm.VirtualMachineProfile; +import org.apache.cloudstack.region.PortableIp; /** * NetworkManager manages the network for the different end users. @@ -240,6 +241,16 @@ public interface NetworkManager { IPAddressVO associateIPToGuestNetwork(long ipAddrId, long networkId, boolean releaseOnFailure) throws ResourceAllocationException, ResourceUnavailableException, InsufficientAddressCapacityException, ConcurrentOperationException; + IPAddressVO associatePortableIPToGuestNetwork(long ipAddrId, long networkId, boolean releaseOnFailure) throws ResourceAllocationException, ResourceUnavailableException, + InsufficientAddressCapacityException, ConcurrentOperationException; + + IPAddressVO disassociatePortableIPToGuestNetwork(long ipAddrId, long networkId) throws ResourceAllocationException, ResourceUnavailableException, + InsufficientAddressCapacityException, ConcurrentOperationException; + + boolean isPortableIpTransferableFromNetwork(long ipAddrId, long networkId); + + void transferPortableIP(long ipAddrId, long currentNetworkId, long newNetworkId) throws ResourceAllocationException, ResourceUnavailableException, + InsufficientAddressCapacityException, ConcurrentOperationException;; /** * @param network @@ -325,6 +336,9 @@ public interface NetworkManager { DataCenter zone) throws ConcurrentOperationException, ResourceAllocationException, InsufficientAddressCapacityException; + IpAddress allocatePortableIp(Account ipOwner, Account caller, long dcId, Long networkId, Long vpcID) + throws ConcurrentOperationException, ResourceAllocationException, InsufficientAddressCapacityException; + Map finalizeServicesAndProvidersForNetwork(NetworkOffering offering, Long physicalNetworkId); diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index 40fc3d30154..b3df0da8ebe 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -105,6 +105,10 @@ import com.cloud.vm.VirtualMachine.Type; import com.cloud.vm.dao.*; import org.apache.cloudstack.acl.ControlledEntity.ACLType; import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.region.PortableIp; +import org.apache.cloudstack.region.PortableIpDao; +import org.apache.cloudstack.region.PortableIpVO; +import org.apache.cloudstack.region.Region; import org.apache.log4j.Logger; import org.springframework.stereotype.Component; @@ -251,6 +255,8 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L UserIpv6AddressDao _ipv6Dao; @Inject Ipv6AddressManager _ipv6Mgr; + @Inject + PortableIpDao _portableIpDao; protected StateMachine2 _stateMachine; private final HashMap _systemNetworks = new HashMap(5); @@ -702,6 +708,62 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L return ip; } + @Override + @DB + public IpAddress allocatePortableIp(Account ipOwner, Account caller, long dcId, Long networkId, Long vpcID) + throws ConcurrentOperationException, ResourceAllocationException, InsufficientAddressCapacityException { + + Transaction txn = Transaction.currentTxn(); + GlobalLock portableIpLock = GlobalLock.getInternLock("PortablePublicIpRange"); + PortableIpVO allocatedPortableIp; + IPAddressVO ipaddr; + + try { + portableIpLock.lock(5); + + txn.start(); + //TODO: get the region ID corresponding to running management server + List portableIpVOs = _portableIpDao.listByRegionIdAndState(1, PortableIp.State.Free); + if (portableIpVOs == null || portableIpVOs.isEmpty()) { + InsufficientAddressCapacityException ex = new InsufficientAddressCapacityException + ("Unable to find available portable IP addresses", Region.class, new Long(1)); + throw ex; + } + + // allocate first portable IP to the user + allocatedPortableIp = portableIpVOs.get(0); + allocatedPortableIp.setAllocatedTime(new Date()); + allocatedPortableIp.setAllocatedToAccountId(ipOwner.getAccountId()); + allocatedPortableIp.setAllocatedInDomainId(ipOwner.getDomainId()); + allocatedPortableIp.setState(PortableIp.State.Allocated); + _portableIpDao.update(allocatedPortableIp.getId(), allocatedPortableIp); + + // provision portable IP range VLAN + long physicalNetworkId = _networkModel.getDefaultPhysicalNetworkByZoneAndTrafficType(dcId, TrafficType.Public).getId(); + Network network = _networkModel.getNetwork(physicalNetworkId); + String range = allocatedPortableIp.getAddress() + "-" + allocatedPortableIp.getAddress(); + VlanVO vlan = new VlanVO(VlanType.VirtualNetwork, allocatedPortableIp.getVlan(), allocatedPortableIp.getGateway(), + allocatedPortableIp.getNetmask(), dcId, range, network.getId(), network.getId(), null, null, null); + vlan = _vlanDao.persist(vlan); + + // provision the portable IP in to user_ip_address table + ipaddr = new IPAddressVO(new Ip(allocatedPortableIp.getAddress()), dcId, networkId, vpcID, network.getId(), + network.getId(), vlan.getId(), true); + ipaddr.setState(State.Allocated); + ipaddr.setAllocatedTime(new Date()); + ipaddr.setAllocatedInDomainId(ipOwner.getDomainId()); + ipaddr.setAllocatedToAccountId(ipOwner.getId()); + ipaddr= _ipAddressDao.persist(ipaddr); + + txn.commit(); + + } finally { + portableIpLock.unlock(); + } + + return ipaddr; + } + protected IPAddressVO getExistingSourceNatInNetwork(long ownerId, Long networkId) { List addrs = _networkModel.listPublicIpsAssignedToGuestNtwk(ownerId, networkId, true); @@ -741,12 +803,14 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L } DataCenter zone = _configMgr.getZone(network.getDataCenterId()); - if (network.getGuestType() == Network.GuestType.Shared && zone.getNetworkType() == NetworkType.Advanced) { - if (isSharedNetworkOfferingWithServices(network.getNetworkOfferingId())) { - _accountMgr.checkAccess(UserContext.current().getCaller(), AccessType.UseNetwork, false, network); - } else { - throw new InvalidParameterValueException("IP can be associated with guest network of 'shared' type only if " + - "network services Source Nat, Static Nat, Port Forwarding, Load balancing, firewall are enabled in the network"); + if (zone.getNetworkType() == NetworkType.Advanced) { + if (network.getGuestType() == Network.GuestType.Shared) { + if (isSharedNetworkOfferingWithServices(network.getNetworkOfferingId())) { + _accountMgr.checkAccess(UserContext.current().getCaller(), AccessType.UseNetwork, false, network); + } else { + throw new InvalidParameterValueException("IP can be associated with guest network of 'shared' type only if " + + "network services Source Nat, Static Nat, Port Forwarding, Load balancing, firewall are enabled in the network"); + } } } else { _accountMgr.checkAccess(caller, null, true, ipToAssoc); @@ -844,6 +908,162 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L } } + @Override + public IPAddressVO associatePortableIPToGuestNetwork(long ipAddrId, long networkId, boolean releaseOnFailure) throws ResourceAllocationException, ResourceUnavailableException, + InsufficientAddressCapacityException, ConcurrentOperationException { + return associateIPToGuestNetwork(ipAddrId, networkId, releaseOnFailure); + } + + @DB + @Override + public IPAddressVO disassociatePortableIPToGuestNetwork(long ipId, long networkId) + throws ResourceAllocationException, ResourceUnavailableException, + InsufficientAddressCapacityException, ConcurrentOperationException { + + Account caller = UserContext.current().getCaller(); + Account owner = null; + + Network network = _networksDao.findById(networkId); + if (network == null) { + throw new InvalidParameterValueException("Invalid network id is given"); + } + + IPAddressVO ipToAssoc = _ipAddressDao.findById(ipId); + if (ipToAssoc != null) { + + if (ipToAssoc.getAssociatedWithNetworkId() == null) { + throw new InvalidParameterValueException("IP " + ipToAssoc + " is not associated with any network"); + } + + if (ipToAssoc.getAssociatedWithNetworkId() != network.getId()) { + throw new InvalidParameterValueException("IP " + ipToAssoc + " is not associated with network id" + networkId); + } + + DataCenter zone = _configMgr.getZone(network.getDataCenterId()); + if (zone.getNetworkType() == NetworkType.Advanced) { + if (network.getGuestType() == Network.GuestType.Shared) { + assert (isSharedNetworkOfferingWithServices(network.getNetworkOfferingId())); + _accountMgr.checkAccess(UserContext.current().getCaller(), AccessType.UseNetwork, false, network); + } + } else { + _accountMgr.checkAccess(caller, null, true, ipToAssoc); + } + owner = _accountMgr.getAccount(ipToAssoc.getAllocatedToAccountId()); + } else { + s_logger.debug("Unable to find ip address by id: " + ipId); + return null; + } + + DataCenter zone = _configMgr.getZone(network.getDataCenterId()); + + // Check that network belongs to IP owner - skip this check + // - if zone is basic zone as there is just one guest network, + // - if shared network in Advanced zone + // - and it belongs to the system + if (network.getAccountId() != owner.getId()) { + if (zone.getNetworkType() != NetworkType.Basic && !(zone.getNetworkType() == NetworkType.Advanced && network.getGuestType() == Network.GuestType.Shared)) { + throw new InvalidParameterValueException("The owner of the network is not the same as owner of the IP"); + } + } + + // Check if IP has any services (rules) associated in the network + List ipList = new ArrayList(); + PublicIp publicIp = PublicIp.createFromAddrAndVlan(ipToAssoc, _vlanDao.findById(ipToAssoc.getVlanId())); + ipList.add(publicIp); + Map> ipToServices = _networkModel.getIpToServices(ipList, false, true); + if (ipToServices != null & !ipToServices.isEmpty()) { + Set services = ipToServices.get(publicIp); + if (services != null && !services.isEmpty()) { + throw new InvalidParameterValueException("IP " + ipToAssoc + " has services and rules associated in the network " + networkId); + } + } + + IPAddressVO ip = _ipAddressDao.findById(ipId); + ip.setAssociatedWithNetworkId(null); + _ipAddressDao.update(ipId, ip); + + try { + boolean success = applyIpAssociations(network, false); + if (success) { + s_logger.debug("Successfully associated ip address " + ip.getAddress().addr() + " to network " + network); + } else { + s_logger.warn("Failed to associate ip address " + ip.getAddress().addr() + " to network " + network); + } + return ip; + } finally { + + } + } + + @Override + public boolean isPortableIpTransferableFromNetwork(long ipAddrId, long networkId) { + Network network = _networksDao.findById(networkId); + if (network == null) { + throw new InvalidParameterValueException("Invalid network id is given"); + } + + IPAddressVO ip = _ipAddressDao.findById(ipAddrId); + if (ip == null) { + throw new InvalidParameterValueException("Invalid network id is given"); + } + + // Check if IP has any services (rules) associated in the network + List ipList = new ArrayList(); + PublicIp publicIp = PublicIp.createFromAddrAndVlan(ip, _vlanDao.findById(ip.getVlanId())); + ipList.add(publicIp); + Map> ipToServices = _networkModel.getIpToServices(ipList, false, true); + if (ipToServices != null & !ipToServices.isEmpty()) { + Set ipServices = ipToServices.get(publicIp); + if (ipServices != null && !ipServices.isEmpty()) { + return false; + } + } + + return true; + } + + @DB + @Override + public void transferPortableIP(long ipAddrId, long currentNetworkId, long newNetworkId) throws ResourceAllocationException, ResourceUnavailableException, + InsufficientAddressCapacityException, ConcurrentOperationException { + + Network srcNetwork = _networksDao.findById(currentNetworkId); + if (srcNetwork == null) { + throw new InvalidParameterValueException("Invalid source network id " + currentNetworkId +" is given"); + } + + Network dstNetwork = _networksDao.findById(newNetworkId); + if (dstNetwork == null) { + throw new InvalidParameterValueException("Invalid source network id " + newNetworkId +" is given"); + } + + IPAddressVO ip = _ipAddressDao.findById(ipAddrId); + if (ip == null) { + throw new InvalidParameterValueException("Invalid portable ip address id is given"); + } + + Transaction txn = Transaction.currentTxn(); + txn.start(); + + assert(isPortableIpTransferableFromNetwork(ipAddrId, currentNetworkId)); + + if (srcNetwork.getVpcId() != null) { + _vpcMgr.unassignIPFromVpcNetwork(ipAddrId, currentNetworkId); + } else { + disassociatePortableIPToGuestNetwork(ipAddrId, currentNetworkId); + } + + associatePortableIPToGuestNetwork(ipAddrId, newNetworkId, false); + + if (dstNetwork.getVpcId() != null) { + ip.setVpcId(dstNetwork.getVpcId()); + } else { + ip.setVpcId(null); + } + + _ipAddressDao.update(ipAddrId, ip); + txn.commit(); + } @Override @DB @@ -884,12 +1104,42 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L } if (success) { + if (ip.isPortable()) { + releasePortableIpAddress(addrId); + } s_logger.debug("Released a public ip id=" + addrId); } return success; } + @DB + private void releasePortableIpAddress(long addrId) { + Transaction txn = Transaction.currentTxn(); + GlobalLock portableIpLock = GlobalLock.getInternLock("PortablePublicIpRange"); + + txn.start(); + try { + portableIpLock.lock(5); + IPAddressVO ip = _ipAddressDao.findById(addrId); + + // unassign portable IP + PortableIpVO portableIp = _portableIpDao.findByIpAddress(ip.getAddress().addr()); + _portableIpDao.unassignIpAddress(portableIp.getId()); + + // removed the provisioned vlan + VlanVO vlan = _vlanDao.findById(ip.getVlanId()); + _vlanDao.expunge(vlan.getId()); + + // remove the provisioned public ip address + _ipAddressDao.expunge(ip.getId()); + + txn.commit(); + } finally { + portableIpLock.releaseRef(); + } + } + @Override @DB public boolean configure(final String name, final Map params) throws ConfigurationException { diff --git a/server/src/com/cloud/network/NetworkServiceImpl.java b/server/src/com/cloud/network/NetworkServiceImpl.java index ed9a8c4ece7..1533ca9bc4f 100755 --- a/server/src/com/cloud/network/NetworkServiceImpl.java +++ b/server/src/com/cloud/network/NetworkServiceImpl.java @@ -39,6 +39,7 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; +import com.cloud.network.vpc.dao.VpcDao; import org.apache.cloudstack.acl.ControlledEntity.ACLType; import org.apache.cloudstack.acl.SecurityChecker; import org.apache.cloudstack.acl.SecurityChecker.AccessType; @@ -184,32 +185,6 @@ import com.cloud.vm.dao.NicSecondaryIpDao; import com.cloud.vm.dao.NicSecondaryIpVO; import com.cloud.vm.dao.UserVmDao; import com.cloud.vm.dao.VMInstanceDao; -import com.cloud.vm.*; -import com.cloud.vm.dao.*; -import org.apache.cloudstack.acl.ControlledEntity.ACLType; -import org.apache.cloudstack.acl.SecurityChecker; -import org.apache.cloudstack.acl.SecurityChecker.AccessType; -import org.apache.cloudstack.api.command.admin.network.DedicateGuestVlanRangeCmd; -import org.apache.cloudstack.api.command.admin.network.ListDedicatedGuestVlanRangesCmd; -import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementorsCmd; -import org.apache.cloudstack.api.command.user.network.CreateNetworkCmd; -import org.apache.cloudstack.api.command.user.network.ListNetworksCmd; -import org.apache.cloudstack.api.command.user.network.RestartNetworkCmd; -import org.apache.cloudstack.api.command.user.vm.ListNicsCmd; -import org.apache.log4j.Logger; -import org.springframework.stereotype.Component; - -import javax.ejb.Local; -import javax.inject.Inject; -import javax.naming.ConfigurationException; -import java.net.Inet6Address; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.security.InvalidParameterException; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.*; /** @@ -315,6 +290,8 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { @Inject AccountGuestVlanMapDao _accountGuestVlanMapDao; @Inject + VpcDao _vpcDao; + @Inject NetworkACLDao _networkACLDao; int _cidrLimit; @@ -527,22 +504,23 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { public IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId) throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException { + Account caller = UserContext.current().getCaller(); + long callerUserId = UserContext.current().getCallerUserId(); + DataCenter zone = _configMgr.getZone(zoneId); + if (networkId != null) { Network network = _networksDao.findById(networkId); if (network == null) { throw new InvalidParameterValueException("Invalid network id is given"); } + if (network.getGuestType() == Network.GuestType.Shared) { - DataCenter zone = _configMgr.getZone(zoneId); if (zone == null) { throw new InvalidParameterValueException("Invalid zone Id is given"); } - // if shared network in the advanced zone, then check the caller against the network for 'AccessType.UseNetwork' if (zone.getNetworkType() == NetworkType.Advanced) { if (isSharedNetworkOfferingWithServices(network.getNetworkOfferingId())) { - Account caller = UserContext.current().getCaller(); - long callerUserId = UserContext.current().getCallerUserId(); _accountMgr.checkAccess(caller, AccessType.UseNetwork, false, network); if (s_logger.isDebugEnabled()) { s_logger.debug("Associate IP address called by the user " + callerUserId + " account " + ipOwner.getId()); @@ -554,20 +532,67 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { } } } + } else { + _accountMgr.checkAccess(caller, null, false, ipOwner); } - return allocateIP(ipOwner, false, zoneId); + return _networkMgr.allocateIp(ipOwner, false, caller, callerUserId, zone); } - public IpAddress allocateIP(Account ipOwner, boolean isSystem, long zoneId) + @Override + @ActionEvent(eventType = EventTypes.EVENT_PORTABLE_IP_ASSIGN, eventDescription = "allocating portable public Ip", create = true) + public IpAddress allocatePortableIP(Account ipOwner, int regionId, Long zoneId, Long networkId, Long vpcId) throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException { Account caller = UserContext.current().getCaller(); - // check permissions - _accountMgr.checkAccess(caller, null, false, ipOwner); long callerUserId = UserContext.current().getCallerUserId(); DataCenter zone = _configMgr.getZone(zoneId); - return _networkMgr.allocateIp(ipOwner, isSystem, caller, callerUserId, zone); + if ((networkId == null && vpcId == null) && (networkId != null && vpcId != null)) { + throw new InvalidParameterValueException("One of Network id or VPC is should be passed"); + } + + if (networkId != null) { + Network network = _networksDao.findById(networkId); + if (network == null) { + throw new InvalidParameterValueException("Invalid network id is given"); + } + + if (network.getGuestType() == Network.GuestType.Shared) { + if (zone == null) { + throw new InvalidParameterValueException("Invalid zone Id is given"); + } + // if shared network in the advanced zone, then check the caller against the network for 'AccessType.UseNetwork' + if (zone.getNetworkType() == NetworkType.Advanced) { + if (isSharedNetworkOfferingWithServices(network.getNetworkOfferingId())) { + _accountMgr.checkAccess(caller, AccessType.UseNetwork, false, network); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Associate IP address called by the user " + callerUserId + " account " + ipOwner.getId()); + } + return _networkMgr.allocatePortableIp(ipOwner, caller, zoneId, networkId, null); + } else { + throw new InvalidParameterValueException("Associate IP address can only be called on the shared networks in the advanced zone" + + " with Firewall/Source Nat/Static Nat/Port Forwarding/Load balancing services enabled"); + } + } + } + } + + if (vpcId != null) { + Vpc vpc = _vpcDao.findById(vpcId); + if (vpc != null) { + throw new InvalidParameterValueException("Invalid vpc id is given"); + } + } + + _accountMgr.checkAccess(caller, null, false, ipOwner); + + return _networkMgr.allocatePortableIp(ipOwner, caller, zoneId, null, null); + } + + @Override + @ActionEvent(eventType = EventTypes.EVENT_PORTABLE_IP_RELEASE, eventDescription = "disassociating portable Ip", async = true) + public boolean releasePortableIpAddress(long ipAddressId) throws InsufficientAddressCapacityException { + return releaseIpAddressInternal(ipAddressId); } @Override @@ -810,9 +835,13 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { } @Override - @DB @ActionEvent(eventType = EventTypes.EVENT_NET_IP_RELEASE, eventDescription = "disassociating Ip", async = true) public boolean releaseIpAddress(long ipAddressId) throws InsufficientAddressCapacityException { + return releaseIpAddressInternal(ipAddressId); + } + + @DB + private boolean releaseIpAddressInternal(long ipAddressId) throws InsufficientAddressCapacityException { Long userId = UserContext.current().getCallerUserId(); Account caller = UserContext.current().getCaller(); @@ -851,6 +880,9 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { boolean success = _networkMgr.disassociatePublicIpAddress(ipAddressId, userId, caller); if (success) { + if (!ipVO.isPortable()) { + return success; + } Long networkId = ipVO.getAssociatedWithNetworkId(); if (networkId != null) { Network guestNetwork = getNetwork(networkId); @@ -867,7 +899,6 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { return success; } - @Override @DB public Network getNetwork(long id) { diff --git a/server/src/com/cloud/network/addr/PublicIp.java b/server/src/com/cloud/network/addr/PublicIp.java index c753b4927c8..b18c6912003 100644 --- a/server/src/com/cloud/network/addr/PublicIp.java +++ b/server/src/com/cloud/network/addr/PublicIp.java @@ -220,6 +220,15 @@ public class PublicIp implements PublicIpAddress { return _addr.getVmIp(); } + @Override + public boolean isPortable() { + return _addr.isPortable(); + } + + public void setPortable(boolean portable) { + _addr.setPortable(portable); + } + public Long getIpMacAddress() { return _addr.getMacAddress(); } diff --git a/server/src/com/cloud/network/rules/RulesManagerImpl.java b/server/src/com/cloud/network/rules/RulesManagerImpl.java index c9b47b44bab..883455377f4 100755 --- a/server/src/com/cloud/network/rules/RulesManagerImpl.java +++ b/server/src/com/cloud/network/rules/RulesManagerImpl.java @@ -491,6 +491,49 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules return false; } performedIpAssoc = true; + } else if (ipAddress.isPortable()) { + s_logger.info("Portable IP " + ipAddress.getUuid() + " is not associated with the network, so" + + "associate IP with the network " + networkId); + try { + // check if StaticNat service is enabled in the network + _networkModel.checkIpForService(ipAddress, Service.StaticNat, networkId); + + // associate portable IP to vpc, if network is part of VPC + if (network.getVpcId() != null) { + _vpcMgr.associateIPToVpc(ipId, network.getVpcId()); + } + + // associate portable IP with guest network + _networkMgr.associatePortableIPToGuestNetwork(ipId, networkId, false); + } catch (Exception e) { + s_logger.warn("Failed to associate portable id=" + ipId + " to network id=" + networkId + " as " + + "a part of enable static nat"); + return false; + } + performedIpAssoc = true; + } + } else if (ipAddress.getAssociatedWithNetworkId() != networkId) { + if (ipAddress.isPortable()) { + // check if destination network has StaticNat service enabled + _networkModel.checkIpForService(ipAddress, Service.StaticNat, networkId); + + // check if portable IP can be transferred across the networks + if (_networkMgr.isPortableIpTransferableFromNetwork(ipId, ipAddress.getAssociatedWithNetworkId() )) { + try { + _networkMgr.transferPortableIP(ipId, ipAddress.getAssociatedWithNetworkId(), networkId); + } catch (Exception e) { + s_logger.warn("Failed to associate portable id=" + ipId + " to network id=" + networkId + " as " + + "a part of enable static nat"); + return false; + } + } else { + throw new InvalidParameterValueException("Portable IP: " + ipId + " has associated services" + + "in network " + ipAddress.getAssociatedWithNetworkId() + " so can not be transferred to " + + " network " + networkId); + } + } else { + throw new InvalidParameterValueException("Invalid network Id=" + networkId + ". IP is associated with" + + " a different network than passed network id"); } } else { _networkModel.checkIpForService(ipAddress, Service.StaticNat, null); diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index 8b3eea4a1f2..8323af84981 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -47,6 +47,14 @@ import com.cloud.exception.*; import com.cloud.vm.*; import org.apache.cloudstack.acl.ControlledEntity; import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ApiConstants; + +import com.cloud.event.ActionEventUtils; +import org.apache.cloudstack.api.BaseUpdateTemplateOrIsoCmd; +import org.apache.cloudstack.api.command.admin.region.*; +import org.apache.cloudstack.api.response.ExtractResponse; +import org.apache.commons.codec.binary.Base64; +import org.apache.log4j.Logger; import org.apache.cloudstack.affinity.AffinityGroupProcessor; import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao; import org.apache.cloudstack.api.ApiConstants; @@ -124,9 +132,6 @@ import org.apache.cloudstack.api.command.admin.pod.CreatePodCmd; import org.apache.cloudstack.api.command.admin.pod.DeletePodCmd; import org.apache.cloudstack.api.command.admin.pod.ListPodsByCmd; import org.apache.cloudstack.api.command.admin.pod.UpdatePodCmd; -import org.apache.cloudstack.api.command.admin.region.AddRegionCmd; -import org.apache.cloudstack.api.command.admin.region.RemoveRegionCmd; -import org.apache.cloudstack.api.command.admin.region.UpdateRegionCmd; import org.apache.cloudstack.api.command.admin.resource.ArchiveAlertsCmd; import org.apache.cloudstack.api.command.admin.resource.DeleteAlertsCmd; import org.apache.cloudstack.api.command.admin.resource.ListAlertsCmd; @@ -571,8 +576,78 @@ import com.cloud.vm.dao.VMInstanceDao; import edu.emory.mathcs.backport.java.util.Arrays; import edu.emory.mathcs.backport.java.util.Collections; -import org.apache.cloudstack.api.command.admin.config.ListDeploymentPlannersCmd; +import org.apache.cloudstack.acl.ControlledEntity; +import org.apache.cloudstack.api.command.admin.autoscale.CreateCounterCmd; +import org.apache.cloudstack.api.command.admin.autoscale.DeleteCounterCmd; +import org.apache.cloudstack.api.command.admin.cluster.AddClusterCmd; +import org.apache.cloudstack.api.command.admin.cluster.DeleteClusterCmd; +import org.apache.cloudstack.api.command.admin.cluster.ListClustersCmd; +import org.apache.cloudstack.api.command.admin.cluster.UpdateClusterCmd; +import org.apache.cloudstack.api.command.admin.config.ListCfgsByCmd; +import org.apache.cloudstack.api.command.admin.config.ListHypervisorCapabilitiesCmd; +import org.apache.cloudstack.api.command.admin.config.UpdateCfgCmd; +import org.apache.cloudstack.api.command.admin.config.UpdateHypervisorCapabilitiesCmd; +import org.apache.cloudstack.api.command.admin.ldap.LDAPConfigCmd; +import org.apache.cloudstack.api.command.admin.ldap.LDAPRemoveCmd; +import org.apache.cloudstack.api.command.admin.pod.CreatePodCmd; +import org.apache.cloudstack.api.command.admin.pod.DeletePodCmd; +import org.apache.cloudstack.api.command.admin.pod.ListPodsByCmd; +import org.apache.cloudstack.api.command.admin.pod.UpdatePodCmd; +import org.apache.cloudstack.api.command.admin.swift.AddSwiftCmd; +import org.apache.cloudstack.api.command.admin.swift.ListSwiftsCmd; +import org.apache.cloudstack.api.command.admin.template.PrepareTemplateCmd; +import org.apache.cloudstack.api.command.admin.vlan.CreateVlanIpRangeCmd; +import org.apache.cloudstack.api.command.admin.vlan.DeleteVlanIpRangeCmd; +import org.apache.cloudstack.api.command.admin.vlan.ListVlanIpRangesCmd; +import org.apache.cloudstack.api.command.admin.vm.AssignVMCmd; +import org.apache.cloudstack.api.command.admin.vm.MigrateVMCmd; +import org.apache.cloudstack.api.command.admin.vm.MigrateVirtualMachineWithVolumeCmd; +import org.apache.cloudstack.api.command.admin.vm.RecoverVMCmd; +import org.apache.cloudstack.api.command.admin.zone.CreateZoneCmd; +import org.apache.cloudstack.api.command.admin.zone.DeleteZoneCmd; +import org.apache.cloudstack.api.command.admin.zone.MarkDefaultZoneForAccountCmd; +import org.apache.cloudstack.api.command.admin.zone.UpdateZoneCmd; +import org.apache.cloudstack.api.command.user.account.AddAccountToProjectCmd; +import org.apache.cloudstack.api.command.user.account.DeleteAccountFromProjectCmd; +import org.apache.cloudstack.api.command.user.account.ListAccountsCmd; +import org.apache.cloudstack.api.command.user.account.ListProjectAccountsCmd; +import org.apache.cloudstack.api.command.user.address.AssociateIPAddrCmd; +import org.apache.cloudstack.api.command.user.address.DisassociateIPAddrCmd; +import org.apache.cloudstack.api.command.user.address.ListPublicIpAddressesCmd; +import org.apache.cloudstack.api.command.user.config.ListCapabilitiesCmd; +import org.apache.cloudstack.api.command.user.event.ArchiveEventsCmd; +import org.apache.cloudstack.api.command.user.event.DeleteEventsCmd; +import org.apache.cloudstack.api.command.user.event.ListEventTypesCmd; +import org.apache.cloudstack.api.command.user.event.ListEventsCmd; +import org.apache.cloudstack.api.command.user.guest.ListGuestOsCategoriesCmd; +import org.apache.cloudstack.api.command.user.guest.ListGuestOsCmd; +import org.apache.cloudstack.api.command.user.job.ListAsyncJobsCmd; +import org.apache.cloudstack.api.command.user.job.QueryAsyncJobResultCmd; +import org.apache.cloudstack.api.command.user.offering.ListDiskOfferingsCmd; +import org.apache.cloudstack.api.command.user.offering.ListServiceOfferingsCmd; +import org.apache.cloudstack.api.command.user.region.ListRegionsCmd; +import org.apache.cloudstack.api.command.user.region.ha.gslb.*; +import org.apache.cloudstack.api.command.user.ssh.CreateSSHKeyPairCmd; +import org.apache.cloudstack.api.command.user.ssh.DeleteSSHKeyPairCmd; +import org.apache.cloudstack.api.command.user.ssh.ListSSHKeyPairsCmd; +import org.apache.cloudstack.api.command.user.ssh.RegisterSSHKeyPairCmd; +import org.apache.cloudstack.api.command.user.tag.CreateTagsCmd; +import org.apache.cloudstack.api.command.user.tag.DeleteTagsCmd; +import org.apache.cloudstack.api.command.user.tag.ListTagsCmd; +import org.apache.cloudstack.api.command.user.vmgroup.CreateVMGroupCmd; +import org.apache.cloudstack.api.command.user.vmgroup.DeleteVMGroupCmd; +import org.apache.cloudstack.api.command.user.vmgroup.ListVMGroupsCmd; +import org.apache.cloudstack.api.command.user.vmgroup.UpdateVMGroupCmd; +import org.apache.cloudstack.api.command.user.vmsnapshot.CreateVMSnapshotCmd; +import org.apache.cloudstack.api.command.user.vmsnapshot.DeleteVMSnapshotCmd; +import org.apache.cloudstack.api.command.user.vmsnapshot.ListVMSnapshotCmd; +import org.apache.cloudstack.api.command.user.zone.ListZonesByCmd; +import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; +import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator; +import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; +import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; +import org.apache.cloudstack.api.command.admin.config.ListDeploymentPlannersCmd; public class ManagementServerImpl extends ManagerBase implements ManagementServer { public static final Logger s_logger = Logger.getLogger(ManagementServerImpl.class.getName()); @@ -2897,6 +2972,9 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe cmdList.add(ListAffinityGroupsCmd.class); cmdList.add(UpdateVMAffinityGroupCmd.class); cmdList.add(ListAffinityGroupTypesCmd.class); + cmdList.add(CreatePortableIpRangeCmd.class); + cmdList.add(DeletePortableIpRangeCmd.class); + cmdList.add(ListPortableIpRangesCmd.class); cmdList.add(ListDeploymentPlannersCmd.class); cmdList.add(ReleaseHostReservationCmd.class); cmdList.add(ScaleSystemVMCmd.class); diff --git a/server/src/org/apache/cloudstack/region/PortableIpDao.java b/server/src/org/apache/cloudstack/region/PortableIpDao.java new file mode 100755 index 00000000000..9f5341fb6ec --- /dev/null +++ b/server/src/org/apache/cloudstack/region/PortableIpDao.java @@ -0,0 +1,39 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package org.apache.cloudstack.region; + +import java.util.List; + +import com.cloud.dc.Vlan; +import com.cloud.dc.Vlan.VlanType; +import com.cloud.dc.VlanVO; +import com.cloud.utils.db.GenericDao; + +public interface PortableIpDao extends GenericDao { + + List listByRegionId(int regionId); + + List listByRangeId(long rangeId); + + List listByRangeIdAndState(long rangeId, PortableIp.State state); + + List listByRegionIdAndState(int regionId, PortableIp.State state); + + PortableIpVO findByIpAddress(String ipAddress); + + void unassignIpAddress(long ipAddressId); +} diff --git a/server/src/org/apache/cloudstack/region/PortableIpDaoImpl.java b/server/src/org/apache/cloudstack/region/PortableIpDaoImpl.java new file mode 100755 index 00000000000..488761bc35f --- /dev/null +++ b/server/src/org/apache/cloudstack/region/PortableIpDaoImpl.java @@ -0,0 +1,131 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package org.apache.cloudstack.region; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.ejb.Local; +import javax.inject.Inject; +import javax.naming.ConfigurationException; + +import org.springframework.stereotype.Component; + +import com.cloud.dc.AccountVlanMapVO; +import com.cloud.dc.PodVlanMapVO; +import com.cloud.dc.Vlan; +import com.cloud.dc.Vlan.VlanType; +import com.cloud.dc.VlanVO; +import com.cloud.network.dao.IPAddressDao; +import com.cloud.utils.Pair; +import com.cloud.utils.db.DB; +import com.cloud.utils.db.GenericDaoBase; +import com.cloud.utils.db.JoinBuilder; +import com.cloud.utils.db.SearchBuilder; +import com.cloud.utils.db.SearchCriteria; +import com.cloud.utils.db.Transaction; +import com.cloud.utils.exception.CloudRuntimeException; + +@Component +@Local(value={PortableIpDao.class}) +public class PortableIpDaoImpl extends GenericDaoBase implements PortableIpDao { + + private final SearchBuilder listByRegionIDSearch; + private final SearchBuilder listByRangeIDSearch; + private final SearchBuilder listByRangeIDAndStateSearch; + private final SearchBuilder listByRegionIDAndStateSearch; + private final SearchBuilder findByIpAddressSearch; + + public PortableIpDaoImpl() { + listByRegionIDSearch = createSearchBuilder(); + listByRegionIDSearch.and("regionId", listByRegionIDSearch.entity().getRegionId(), SearchCriteria.Op.EQ); + listByRegionIDSearch.done(); + + listByRangeIDSearch = createSearchBuilder(); + listByRangeIDSearch.and("rangeId", listByRangeIDSearch.entity().getRangeId(), SearchCriteria.Op.EQ); + listByRangeIDSearch.done(); + + listByRangeIDAndStateSearch = createSearchBuilder(); + listByRangeIDAndStateSearch.and("rangeId", listByRangeIDAndStateSearch.entity().getRangeId(), SearchCriteria.Op.EQ); + listByRangeIDAndStateSearch.and("state", listByRangeIDAndStateSearch.entity().getState(), SearchCriteria.Op.EQ); + listByRangeIDAndStateSearch.done(); + + listByRegionIDAndStateSearch = createSearchBuilder(); + listByRegionIDAndStateSearch.and("regionId", listByRegionIDAndStateSearch.entity().getRangeId(), SearchCriteria.Op.EQ); + listByRegionIDAndStateSearch.and("state", listByRegionIDAndStateSearch.entity().getState(), SearchCriteria.Op.EQ); + listByRegionIDAndStateSearch.done(); + + findByIpAddressSearch = createSearchBuilder(); + findByIpAddressSearch.and("address", findByIpAddressSearch.entity().getAddress(), SearchCriteria.Op.EQ); + findByIpAddressSearch.done(); + } + + @Override + public List listByRegionId(int regionIdId) { + SearchCriteria sc = listByRegionIDSearch.create(); + sc.setParameters("regionId", regionIdId); + return listBy(sc); + } + + @Override + public List listByRangeId(long rangeId) { + SearchCriteria sc = listByRangeIDSearch.create(); + sc.setParameters("rangeId", rangeId); + return listBy(sc); + } + + @Override + public List listByRangeIdAndState(long rangeId, PortableIp.State state) { + SearchCriteria sc = listByRangeIDAndStateSearch.create(); + sc.setParameters("rangeId", rangeId); + sc.setParameters("state", state); + return listBy(sc); + } + + @Override + public List listByRegionIdAndState(int regionId, PortableIp.State state) { + SearchCriteria sc = listByRegionIDAndStateSearch.create(); + sc.setParameters("regionId", regionId); + sc.setParameters("state", state); + return listBy(sc); + } + + @Override + public PortableIpVO findByIpAddress(String ipAddress) { + SearchCriteria sc = findByIpAddressSearch.create(); + sc.setParameters("address", ipAddress); + return findOneBy(sc); + } + + @Override + public void unassignIpAddress(long ipAddressId) { + PortableIpVO address = createForUpdate(); + address.setAllocatedToAccountId(null); + address.setAllocatedInDomainId(null); + address.setAllocatedTime(null); + address.setState(PortableIp.State.Free); + address.setAssociatedWithNetworkId(null); + address.setAssociatedDataCenterId(null); + address.setAssociatedWithVpcId(null); + address.setPhysicalNetworkId(null); + update(ipAddressId, address); + } +} diff --git a/server/src/org/apache/cloudstack/region/PortableIpRangeDao.java b/server/src/org/apache/cloudstack/region/PortableIpRangeDao.java new file mode 100755 index 00000000000..85da6c0a87e --- /dev/null +++ b/server/src/org/apache/cloudstack/region/PortableIpRangeDao.java @@ -0,0 +1,30 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package org.apache.cloudstack.region; + +import java.util.List; + +import com.cloud.dc.Vlan; +import com.cloud.dc.Vlan.VlanType; +import com.cloud.dc.VlanVO; +import com.cloud.utils.db.GenericDao; + +public interface PortableIpRangeDao extends GenericDao { + + List listByRegionId(int regionId); + +} diff --git a/server/src/org/apache/cloudstack/region/PortableIpRangeDaoImpl.java b/server/src/org/apache/cloudstack/region/PortableIpRangeDaoImpl.java new file mode 100755 index 00000000000..496c9e6da40 --- /dev/null +++ b/server/src/org/apache/cloudstack/region/PortableIpRangeDaoImpl.java @@ -0,0 +1,65 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package org.apache.cloudstack.region; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.ejb.Local; +import javax.inject.Inject; +import javax.naming.ConfigurationException; + +import org.springframework.stereotype.Component; + +import com.cloud.dc.AccountVlanMapVO; +import com.cloud.dc.PodVlanMapVO; +import com.cloud.dc.Vlan; +import com.cloud.dc.Vlan.VlanType; +import com.cloud.dc.VlanVO; +import com.cloud.network.dao.IPAddressDao; +import com.cloud.utils.Pair; +import com.cloud.utils.db.DB; +import com.cloud.utils.db.GenericDaoBase; +import com.cloud.utils.db.JoinBuilder; +import com.cloud.utils.db.SearchBuilder; +import com.cloud.utils.db.SearchCriteria; +import com.cloud.utils.db.Transaction; +import com.cloud.utils.exception.CloudRuntimeException; + +@Component +@Local(value={PortableIpRangeDao.class}) +public class PortableIpRangeDaoImpl extends GenericDaoBase implements PortableIpRangeDao { + + private final SearchBuilder listByRegionIDSearch; + + public PortableIpRangeDaoImpl() { + listByRegionIDSearch = createSearchBuilder(); + listByRegionIDSearch.and("regionId", listByRegionIDSearch.entity().getRegionId(), SearchCriteria.Op.EQ); + listByRegionIDSearch.done(); + } + + @Override + public List listByRegionId(int regionIdId) { + SearchCriteria sc = listByRegionIDSearch.create(); + sc.setParameters("regionId", regionIdId); + return listBy(sc); + } +} diff --git a/server/src/org/apache/cloudstack/region/PortableIpRangeVO.java b/server/src/org/apache/cloudstack/region/PortableIpRangeVO.java new file mode 100644 index 00000000000..933fcc3d1d7 --- /dev/null +++ b/server/src/org/apache/cloudstack/region/PortableIpRangeVO.java @@ -0,0 +1,119 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package org.apache.cloudstack.region; + +import java.util.UUID; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + +import org.apache.cloudstack.api.Identity; +import org.apache.cloudstack.api.InternalIdentity; + +@Entity +@Table(name="portable_ip_range") +public class PortableIpRangeVO implements PortableIpRange { + + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + @Column(name="id") + Long id; + + @Column(name="uuid") + String uuid; + + @Column(name="region_id") + int regionId; + + @Column(name="vlan_id") + String vlan; + + @Column(name="gateway") + String gateway; + + @Column(name="netmask") + String netmask; + + @Column(name="start_ip") + String startIp; + + @Column(name="end_ip") + String endIp; + + public PortableIpRangeVO() { + this.uuid = UUID.randomUUID().toString(); + } + + public PortableIpRangeVO(int regionId, String vlan, String gateway, String netmask, String startIp, String endIp) { + this.uuid = UUID.randomUUID().toString(); + this.regionId =regionId; + this.vlan = vlan; + this.gateway = gateway; + this.netmask = netmask; + this.startIp = startIp; + this.endIp = endIp; + } + + @Override + public long getId() { + return id; + } + + @Override + public String getUuid() { + return this.uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + @Override + public String getVlanTag() { + return vlan; + } + + public void setVlanTag(String vlan) { + this.vlan = vlan; + } + + @Override + public String getGateway() { + return gateway; + } + + @Override + public String getNetmask() { + return netmask; + } + + @Override + public int getRegionId() { + return regionId; + } + + @Override + public String getIpRange() { + return startIp + "-" + endIp; + } +} diff --git a/server/src/org/apache/cloudstack/region/PortableIpVO.java b/server/src/org/apache/cloudstack/region/PortableIpVO.java new file mode 100644 index 00000000000..9a630094001 --- /dev/null +++ b/server/src/org/apache/cloudstack/region/PortableIpVO.java @@ -0,0 +1,222 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package org.apache.cloudstack.region; + +import java.util.Date; +import java.util.UUID; + +import javax.persistence.*; + +import org.apache.cloudstack.api.Identity; +import org.apache.cloudstack.api.InternalIdentity; + +@Entity +@Table(name="portable_ip_address") +public class PortableIpVO implements PortableIp { + + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + @Column(name="id") + Long id; + + @Column(name="region_id") + int regionId; + + @Column(name="allocated") + @Temporal(value=TemporalType.TIMESTAMP) + private Date allocatedTime; + + @Column(name="account_id") + private Long allocatedToAccountId = null; + + @Column(name="domain_id") + private Long allocatedInDomainId = null; + + @Column(name="state") + private State state; + + @Column(name="vlan") + String vlan; + + @Column(name="gateway") + String gateway; + + @Column(name="netmask") + String netmask; + + @Column(name="portable_ip_address") + String address; + + @Column(name="portable_ip_range_id") + private long rangeId; + + @Column(name="physical_network_id") + private Long physicalNetworkId; + + @Column(name="data_center_id") + private Long dataCenterId; + + @Column(name="network_id") + private Long networkId; + + @Column(name="vpc_id") + private Long vpcId; + + public PortableIpVO() { + + } + + public PortableIpVO(int regionId, Long rangeId, String vlan, String gateway, String netmask, String address) { + this.regionId =regionId; + this.vlan = vlan; + this.gateway = gateway; + this.netmask = netmask; + this.address = address; + state = State.Free; + this.rangeId = rangeId; + } + + @Override + public long getId() { + return id; + } + + @Override + public Long getAllocatedToAccountId() { + return allocatedToAccountId; + } + + public void setAllocatedToAccountId(Long accountId) { + this.allocatedToAccountId = accountId; + } + + @Override + public Long getAllocatedInDomainId() { + return allocatedInDomainId; + } + + public void setAllocatedInDomainId(Long domainId) { + this.allocatedInDomainId = domainId; + } + + @Override + public Date getAllocatedTime() { + return allocatedTime; + } + + public void setAllocatedTime(Date date) { + this.allocatedTime = date; + } + + @Override + public State getState() { + return state; + } + + public void setState(State state) { + this.state = state; + } + + @Override + public int getRegionId() { + return regionId; + } + + public void setRegionId(int regionId) { + this.regionId = regionId; + } + + @Override + public Long getAssociatedDataCenterId() { + return dataCenterId; + } + + public void setAssociatedDataCenterId(Long datacenterId) { + this.dataCenterId = datacenterId; + } + + @Override + public Long getAssociatedWithNetworkId() { + return networkId; + } + + public void setAssociatedWithNetworkId(Long networkId) { + this.networkId = networkId; + } + + @Override + public Long getAssociatedWithVpcId() { + return vpcId; + } + + public void setAssociatedWithVpcId(Long vpcId) { + this.vpcId = vpcId; + } + + @Override + public Long getPhysicalNetworkId() { + return physicalNetworkId; + } + + public void setPhysicalNetworkId(Long physicalNetworkId) { + this.physicalNetworkId = physicalNetworkId; + } + + @Override + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + @Override + public String getVlan() { + return vlan; + } + + public void setVlan(String vlan) { + this.vlan = vlan; + } + + @Override + public String getNetmask() { + return netmask; + } + + public void setNetmask(String netmask) { + this.netmask = netmask; + } + + @Override + public String getGateway() { + return gateway; + } + + public void setGateay(String gateway) { + this.gateway = gateway; + } + + Long getRangeId() { + return rangeId; + } + + public void setRangeId(Long rangeId) { + this.rangeId = rangeId; + } +} diff --git a/server/test/com/cloud/network/MockNetworkManagerImpl.java b/server/test/com/cloud/network/MockNetworkManagerImpl.java index 87431ab54ab..1ac014d502a 100755 --- a/server/test/com/cloud/network/MockNetworkManagerImpl.java +++ b/server/test/com/cloud/network/MockNetworkManagerImpl.java @@ -75,7 +75,6 @@ import com.cloud.vm.VirtualMachine; import com.cloud.vm.*; import com.cloud.vm.VirtualMachine.Type; import com.cloud.vm.VirtualMachineProfile; -import org.apache.cloudstack.acl.ControlledEntity.ACLType; import org.apache.cloudstack.api.command.admin.network.DedicateGuestVlanRangeCmd; import org.apache.cloudstack.api.command.admin.network.ListDedicatedGuestVlanRangesCmd; import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementorsCmd; @@ -89,7 +88,6 @@ import java.util.List; import java.util.Map; import java.util.Set; - @Component @Local(value = { NetworkManager.class, NetworkService.class }) public class MockNetworkManagerImpl extends ManagerBase implements NetworkManager, NetworkService { @@ -106,6 +104,27 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkManage return null; } + @Override + public IPAddressVO associatePortableIPToGuestNetwork(long ipAddrId, long networkId, boolean releaseOnFailure) throws ResourceAllocationException, ResourceUnavailableException { + return null;// TODO Auto-generated method stub + } + + @Override + public IPAddressVO disassociatePortableIPToGuestNetwork(long ipAddrId, long networkId) throws ResourceAllocationException, ResourceUnavailableException, InsufficientAddressCapacityException, ConcurrentOperationException { + return null; // TODO Auto-generated method stub + } + + @Override + public boolean isPortableIpTransferableFromNetwork(long ipAddrId, long networkId) { + return false; + } + + @Override + public void transferPortableIP(long ipAddrId, long currentNetworkId, long newNetworkId) throws ResourceAllocationException, ResourceUnavailableException, + InsufficientAddressCapacityException, ConcurrentOperationException { + + } + @Override public boolean releaseIpAddress(long ipAddressId) { // TODO Auto-generated method stub @@ -861,6 +880,23 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkManage return null; } + @Override + public IpAddress allocatePortableIp(Account ipOwner, Account caller, long dcId, Long networkId, Long vpcID) + throws ConcurrentOperationException, ResourceAllocationException, InsufficientAddressCapacityException { + return null;// TODO Auto-generated method stub + } + + @Override + public IpAddress allocatePortableIP(Account ipOwner, int regionId, Long zoneId, Long networkId, Long vpcId) throws ResourceAllocationException, + InsufficientAddressCapacityException, ConcurrentOperationException { + return null; + } + + @Override + public boolean releasePortableIpAddress(long ipAddressId) throws InsufficientAddressCapacityException { + return false;// TODO Auto-generated method stub + } + @Override public boolean isSecondaryIpSetForNic(long nicId) { // TODO Auto-generated method stub diff --git a/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java b/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java index 4fb182aae14..21b3590282d 100755 --- a/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java +++ b/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java @@ -16,6 +16,44 @@ // under the License. package com.cloud.vpc; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.ejb.Local; +import javax.inject.Inject; +import javax.naming.ConfigurationException; +import javax.naming.NamingException; + +import org.apache.cloudstack.api.command.admin.config.UpdateCfgCmd; +import org.apache.cloudstack.api.command.admin.ldap.LDAPConfigCmd; +import org.apache.cloudstack.api.command.admin.ldap.LDAPRemoveCmd; +import org.apache.cloudstack.api.command.admin.network.CreateNetworkOfferingCmd; +import org.apache.cloudstack.api.command.admin.network.DeleteNetworkOfferingCmd; +import org.apache.cloudstack.api.command.admin.network.UpdateNetworkOfferingCmd; +import org.apache.cloudstack.api.command.admin.offering.CreateDiskOfferingCmd; +import org.apache.cloudstack.api.command.admin.offering.CreateServiceOfferingCmd; +import org.apache.cloudstack.api.command.admin.offering.DeleteDiskOfferingCmd; +import org.apache.cloudstack.api.command.admin.offering.DeleteServiceOfferingCmd; +import org.apache.cloudstack.api.command.admin.offering.UpdateDiskOfferingCmd; +import org.apache.cloudstack.api.command.admin.offering.UpdateServiceOfferingCmd; +import org.apache.cloudstack.api.command.admin.pod.DeletePodCmd; +import org.apache.cloudstack.api.command.admin.pod.UpdatePodCmd; +import org.apache.cloudstack.api.command.admin.region.CreatePortableIpRangeCmd; +import org.apache.cloudstack.api.command.admin.region.DeletePortableIpRangeCmd; +import org.apache.cloudstack.api.command.admin.region.ListPortableIpRangesCmd; +import org.apache.cloudstack.api.command.admin.vlan.CreateVlanIpRangeCmd; +import org.apache.cloudstack.api.command.admin.vlan.DedicatePublicIpRangeCmd; +import org.apache.cloudstack.api.command.admin.vlan.DeleteVlanIpRangeCmd; +import org.apache.cloudstack.api.command.admin.vlan.ReleasePublicIpRangeCmd; +import org.apache.cloudstack.api.command.admin.zone.CreateZoneCmd; +import org.apache.cloudstack.api.command.admin.zone.DeleteZoneCmd; +import org.apache.cloudstack.api.command.admin.zone.UpdateZoneCmd; +import org.apache.cloudstack.api.command.user.network.ListNetworkOfferingsCmd; +import org.apache.cloudstack.region.PortableIp; +import org.apache.cloudstack.region.PortableIpRange; +import org.springframework.stereotype.Component; + import com.cloud.configuration.Configuration; import com.cloud.configuration.ConfigurationManager; import com.cloud.configuration.ConfigurationService; @@ -381,6 +419,26 @@ public class MockConfigurationManagerImpl extends ManagerBase implements Configu return false; } + @Override + public PortableIpRange createPortableIpRange(CreatePortableIpRangeCmd cmd) throws ConcurrentOperationException { + return null;// TODO Auto-generated method stub + } + + @Override + public boolean deletePortableIpRange(DeletePortableIpRangeCmd cmd) { + return false;// TODO Auto-generated method stub + } + + @Override + public List listPortableIpRanges(ListPortableIpRangesCmd cmd) { + return null;// TODO Auto-generated method stub + } + + @Override + public List listPortableIps(long id) { + return null;// TODO Auto-generated method stub + } + /* (non-Javadoc) * @see com.cloud.utils.component.Manager#configure(java.lang.String, java.util.Map) */ diff --git a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java index 3e6a08bdbf3..62599b8d504 100644 --- a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java +++ b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java @@ -63,7 +63,6 @@ import com.cloud.network.PhysicalNetworkServiceProvider; import com.cloud.network.PhysicalNetworkTrafficType; import com.cloud.network.PublicIpAddress; import com.cloud.network.addr.PublicIp; -import com.cloud.network.dao.AccountGuestVlanMapVO; import com.cloud.network.dao.IPAddressVO; import com.cloud.network.dao.NetworkServiceMapDao; import com.cloud.network.dao.NetworkVO; @@ -198,13 +197,36 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkManage return null; } + @Override + public IpAddress allocatePortableIp(Account ipOwner, Account caller, long dcId, Long networkId, Long vpcID) + throws ConcurrentOperationException, ResourceAllocationException, InsufficientAddressCapacityException { + return null;// TODO Auto-generated method stub + } + @Override + public IpAddress allocatePortableIP(Account ipOwner, int regionId, Long zoneId, Long networkId, Long vpcId) throws ResourceAllocationException, + InsufficientAddressCapacityException, ConcurrentOperationException { + return null; + } + @Override + public boolean releasePortableIpAddress(long ipAddressId) throws InsufficientAddressCapacityException { + return false;// TODO Auto-generated method stub + } + @Override + public boolean isPortableIpTransferableFromNetwork(long ipAddrId, long networkId) { + return false; + } + + @Override + public void transferPortableIP(long ipAddrId, long currentNetworkId, long newNetworkId) throws ResourceAllocationException, ResourceUnavailableException, + InsufficientAddressCapacityException, ConcurrentOperationException { + } /* (non-Javadoc) - * @see com.cloud.network.NetworkService#releaseIpAddress(long) - */ + * @see com.cloud.network.NetworkService#releaseIpAddress(long) + */ @Override public boolean releaseIpAddress(long ipAddressId) throws InsufficientAddressCapacityException { // TODO Auto-generated method stub @@ -1112,13 +1134,20 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkManage return null; } + @Override + public IPAddressVO associatePortableIPToGuestNetwork(long ipAddrId, long networkId, boolean releaseOnFailure) throws ResourceAllocationException, ResourceUnavailableException { + return null;// TODO Auto-generated method stub + } - + @Override + public IPAddressVO disassociatePortableIPToGuestNetwork(long ipAddrId, long networkId) throws ResourceAllocationException, ResourceUnavailableException, InsufficientAddressCapacityException, ConcurrentOperationException { + return null;// TODO Auto-generated method stub + } /* (non-Javadoc) - * @see com.cloud.network.NetworkManager#setupDns(com.cloud.network.Network, com.cloud.network.Network.Provider) - */ + * @see com.cloud.network.NetworkManager#setupDns(com.cloud.network.Network, com.cloud.network.Network.Provider) + */ @Override public boolean setupDns(Network network, Provider provider) { // TODO Auto-generated method stub diff --git a/server/test/org/apache/cloudstack/networkoffering/ChildTestConfiguration.java b/server/test/org/apache/cloudstack/networkoffering/ChildTestConfiguration.java index a8256990973..f862a2a4760 100644 --- a/server/test/org/apache/cloudstack/networkoffering/ChildTestConfiguration.java +++ b/server/test/org/apache/cloudstack/networkoffering/ChildTestConfiguration.java @@ -20,6 +20,9 @@ package org.apache.cloudstack.networkoffering; import java.io.IOException; import org.apache.cloudstack.acl.SecurityChecker; +import org.apache.cloudstack.region.PortableIpDaoImpl; +import org.apache.cloudstack.region.dao.RegionDaoImpl; +import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDaoImpl; import org.apache.cloudstack.test.utils.SpringUtils; import org.mockito.Mockito; @@ -113,6 +116,7 @@ import com.cloud.vm.dao.NicDaoImpl; import com.cloud.vm.dao.NicSecondaryIpDaoImpl; import com.cloud.vm.dao.UserVmDao; import com.cloud.vm.dao.VMInstanceDaoImpl; +import org.apache.cloudstack.region.PortableIpRangeDaoImpl; @Configuration @ComponentScan(basePackageClasses={ @@ -162,6 +166,9 @@ import com.cloud.vm.dao.VMInstanceDaoImpl; NetworkServiceMapDaoImpl.class, PrimaryDataStoreDaoImpl.class, StoragePoolDetailsDaoImpl.class, + PortableIpRangeDaoImpl.class, + RegionDaoImpl.class, + PortableIpDaoImpl.class, AccountGuestVlanMapDaoImpl.class }, includeFilters={@Filter(value=ChildTestConfiguration.Library.class, type=FilterType.CUSTOM)}, diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql index c088ac1c2f0..7b5e9cb5f29 100644 --- a/setup/db/db/schema-410to420.sql +++ b/setup/db/db/schema-410to420.sql @@ -1267,6 +1267,43 @@ INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'Netwo alter table `cloud_usage`.`usage_network_offering` add column nic_id bigint(20) unsigned NOT NULL; + +CREATE TABLE `cloud`.`portable_ip_range` ( + `id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT, + `uuid` varchar(40), + `region_id` int unsigned NOT NULL, + `vlan_id` varchar(255), + `gateway` varchar(255), + `netmask` varchar(255), + `start_ip` varchar(255), + `end_ip` varchar(255), + PRIMARY KEY (`id`), + CONSTRAINT `fk_portableip__region_id` FOREIGN KEY (`region_id`) REFERENCES `region`(`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `cloud`.`portable_ip_address` ( + `id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT, + `account_id` bigint unsigned NULL, + `domain_id` bigint unsigned NULL, + `allocated` datetime NULL COMMENT 'Date portable ip was allocated', + `state` char(32) NOT NULL default 'Free' COMMENT 'state of the portable ip address', + `region_id` int unsigned NOT NULL, + `vlan` varchar(255), + `gateway` varchar(255), + `netmask` varchar(255), + `portable_ip_address` varchar(255), + `portable_ip_range_id` bigint unsigned NOT NULL, + `data_center_id` bigint unsigned NULL COMMENT 'zone to which portable IP is associated', + `physical_network_id` bigint unsigned NULL COMMENT 'physical network id in the zone to which portable IP is associated', + `network_id` bigint unsigned NULL COMMENT 'guest network to which portable ip address is associated with', + `vpc_id` bigint unsigned COMMENT 'vpc to which portable ip address is associated with', + PRIMARY KEY (`id`), + CONSTRAINT `fk_portable_ip_address__portable_ip_range_id` FOREIGN KEY (`portable_ip_range_id`) REFERENCES `portable_ip_range`(`id`) ON DELETE CASCADE, + CONSTRAINT `fk_portable_ip_address__region_id` FOREIGN KEY (`region_id`) REFERENCES `region`(`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +ALTER TABLE `cloud`.`user_ip_address` ADD COLUMN is_portable int(1) unsigned NOT NULL default '0'; + DROP VIEW IF EXISTS `cloud`.`disk_offering_view`; CREATE VIEW `cloud`.`disk_offering_view` AS select diff --git a/test/integration/smoke/test_portable_publicip.py b/test/integration/smoke/test_portable_publicip.py new file mode 100644 index 00000000000..101747d958e --- /dev/null +++ b/test/integration/smoke/test_portable_publicip.py @@ -0,0 +1,237 @@ +#!/usr/bin/env python +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +from marvin.cloudstackTestCase import * +from marvin.cloudstackAPI import * +from marvin.integration.lib.utils import * +from marvin.integration.lib.base import * +from marvin.integration.lib.common import * +from marvin import remoteSSHClient +from nose.plugins.attrib import attr + +class Services: + """Test Data + """ + + 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": "password", + }, + "service_offering": { + "name": "Tiny Instance", + "displaytext": "Tiny Instance", + "cpunumber": 1, + "cpuspeed": 100, + # in MHz + "memory": 128, + # In MBs + }, + "network_offering": { + "name": 'Test Network offering', + "displaytext": 'Test Network offering', + "guestiptype": 'Isolated', + "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding', + "traffictype": 'GUEST', + "availability": 'Optional', + "serviceProviderList" : { + "Dhcp": 'VirtualRouter', + "Dns": 'VirtualRouter', + "SourceNat": 'VirtualRouter', + "PortForwarding": 'VirtualRouter', + }, + }, + "network": { + "name": "Test Network", + "displaytext": "Test Network", + }, + "ostype": 'CentOS 5.3 (64-bit)', + "gateway" : "10.1.1.1", + "netmask" : "255.255.255.0", + "startip" : "10.1.1.10", + "endip" : "10.1.1.20", + "regionid" : "1", + "vlan" :"10", + "isportable" : "true", + "virtual_machine" : { + "affinity": { + "name": "webvms", + "type": "host anti-affinity", + }, + "hypervisor" : "XenServer", + } + } + +class TestPortablePublicIPRange(cloudstackTestCase): + + """ + This test validates functionality where + - admin can provision a portable public ip range + - list provisioned portable public ip range + - delete provisioned portable public ip range + """ + @classmethod + def setUpClass(cls): + cls.api_client = super(TestPortablePublicIPRange, cls).getClsTestClient().getApiClient() + cls.services = Services().services + # Get Zone, Domain + cls.domain = get_domain(cls.api_client, cls.services) + cls.zone = get_zone(cls.api_client, cls.services) + + # Create Account + cls.account = Account.create( + cls.api_client, + cls.services["account"], + domainid=cls.domain.id + ) + cls._cleanup = [ + cls.account, + ] + return + + @classmethod + def tearDownClass(cls): + try: + # Cleanup resources used + cleanup_resources(cls.api_client, cls._cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return + + def setUp(self): + self.apiclient = self.testClient.getApiClient() + self.dbclient = self.testClient.getDbConnection() + self.cleanup = [] + return + + def tearDown(self): + try: + # Clean up + cleanup_resources(self.apiclient, self.cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return + + @attr(tags = ["simulator", "basic", "advanced", "portablepublicip"]) + def test_createPortablePublicIPRange(self): + """ + """ + self.debug("attempting to create a portable Public IP range") + self.portable_ip_range = PortablePublicIpRange.create( + self.api_client, + self.services + ) + self.debug("attempting to verify portable Public IP range is created") + list_portbale_ip_range_response = PortablePublicIpRange.list( + self.apiclient, + id=self.portable_ip_range.id + ) + self.portable_ip_range.delete(self.apiclient) + return + + +class TestPortablePublicIPAcquire(cloudstackTestCase): + + """ + This test validates functionality where + - admin has provisioned a portable public ip range + - user can acquire portable ip from the provisioned ip range + """ + @classmethod + def setUpClass(cls): + cls.api_client = super(TestPortablePublicIPAcquire, cls).getClsTestClient().getApiClient() + cls.services = Services().services + # Get Zone, Domain + cls.domain = get_domain(cls.api_client, cls.services) + cls.zone = get_zone(cls.api_client, cls.services) + # Create Account + cls.account = Account.create( + cls.api_client, + cls.services["account"], + domainid=cls.domain.id + ) + cls.services["network"]["zoneid"] = cls.zone.id + + cls.network_offering = NetworkOffering.create( + cls.api_client, + cls.services["network_offering"], + ) + # Enable Network offering + cls.network_offering.update(cls.api_client, state='Enabled') + + cls.services["network"]["networkoffering"] = cls.network_offering.id + cls.account_network = Network.create( + cls.api_client, + cls.services["network"], + cls.account.name, + cls.account.domainid + ) + cls._cleanup = [ + cls.account_network, + cls.network_offering, + cls.account + ] + + return + + @classmethod + def tearDownClass(cls): + try: + # Cleanup resources used + cleanup_resources(cls.api_client, cls._cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return + + def setUp(self): + self.apiclient = self.testClient.getApiClient() + self.dbclient = self.testClient.getDbConnection() + self.cleanup = [] + return + + def tearDown(self): + try: + # Clean up + cleanup_resources(self.apiclient, self.cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return + + @attr(tags = ["simulator", "basic", "advanced", "portablepublicip"]) + def test_createPortablePublicIPAcquire(self): + """ + """ + self.debug("attempting to create a portable Public IP range") + self.portable_ip_range = PortablePublicIpRange.create( + self.api_client, + self.services + ) + + ip_address = PublicIPAddress.create(self.api_client, self.account.name, self.zone.id, self.account.domainid) + + self.portable_ip_range.delete(self.apiclient) + return \ No newline at end of file diff --git a/tools/marvin/marvin/integration/lib/base.py b/tools/marvin/marvin/integration/lib/base.py index f3a96bd9bec..ec1c34e12c7 100755 --- a/tools/marvin/marvin/integration/lib/base.py +++ b/tools/marvin/marvin/integration/lib/base.py @@ -2131,6 +2131,42 @@ class PublicIpRange: cmd.id = self.vlan.id return apiclient.releasePublicIpRange(cmd) + +class PortablePublicIpRange: + """Manage portable public Ip Range""" + + def __init__(self, items): + self.__dict__.update(items) + + @classmethod + def create(cls, apiclient, services): + """Create portable public Ip Range""" + + cmd = createPortableIpRange.createPortableIpRangeCmd() + cmd.gateway = services["gateway"] + cmd.netmask = services["netmask"] + cmd.startip = services["startip"] + cmd.endip = services["endip"] + cmd.regionid = services["regionid"] + cmd.vlan = services["vlan"] + + return PortablePublicIpRange(apiclient.createVlanIpRange(cmd).__dict__) + + def delete(self, apiclient): + """Delete portable IpRange""" + + cmd = deletePortableIpRange.deletePortableIpRangeCmd() + cmd.id = self.id + apiclient.deletePortableIpRange(cmd) + + @classmethod + def list(cls, apiclient, **kwargs): + """Lists all portable public IP ranges.""" + + cmd = listPortableIpRanges.listPortableIpRangesCmd() + [setattr(cmd, k, v) for k, v in kwargs.items()] + return(apiclient.listPortableIpRanges(cmd)) + class SecondaryStorage: """Manage Secondary storage""" diff --git a/utils/src/com/cloud/utils/net/NetUtils.java b/utils/src/com/cloud/utils/net/NetUtils.java index 9551c262e54..37dcef382aa 100755 --- a/utils/src/com/cloud/utils/net/NetUtils.java +++ b/utils/src/com/cloud/utils/net/NetUtils.java @@ -1296,6 +1296,18 @@ public class NetUtils { return resultIp; } + public static boolean isValidVlan(String vlan) { + try { + int vnet = Integer.parseInt(vlan); + if (vnet < 0 || vnet > 4096) { + return false; + } + return true; + } catch (NumberFormatException e) { + return false; + } + } + public static URI generateUriForPvlan(String primaryVlan, String isolatedPvlan) { return URI.create("pvlan://" + primaryVlan + "-i" + isolatedPvlan); } @@ -1320,4 +1332,5 @@ public class NetUtils { } return null; } + } From aa60105a84e1260ec9687759a069a0c9cf0c46bf Mon Sep 17 00:00:00 2001 From: Sanjeev Neelarapu Date: Mon, 20 May 2013 20:36:00 +0530 Subject: [PATCH 22/51] CLOUDSTACK-2543: [Multiple_IP_Ranges] Failed to create IP alias on router vm createipAlias.sh/deleteipAlias.sh won't be copied to XenServer host. The directory of the scripts should be ".." rather "../../.." in all the xenserver patches file. Corrected the path to ".." because the scripts are located at scripts/vm/hypervisor/xenserver/xenserver56/patch --- scripts/vm/hypervisor/xenserver/xcposs/patch | 2 ++ scripts/vm/hypervisor/xenserver/xcpserver/patch | 4 ++-- scripts/vm/hypervisor/xenserver/xenserver56/patch | 4 ++-- scripts/vm/hypervisor/xenserver/xenserver56fp1/patch | 4 ++-- scripts/vm/hypervisor/xenserver/xenserver60/patch | 4 ++-- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/scripts/vm/hypervisor/xenserver/xcposs/patch b/scripts/vm/hypervisor/xenserver/xcposs/patch index 6dc3baae555..4d07c76a68f 100644 --- a/scripts/vm/hypervisor/xenserver/xcposs/patch +++ b/scripts/vm/hypervisor/xenserver/xcposs/patch @@ -65,3 +65,5 @@ getRouterStatus.sh=../../../../network/domr/,0755,/usr/lib/xcp/bin bumpUpPriority.sh=../../../../network/domr/,0755,/usr/lib/xcp/bin getDomRVersion.sh=../../../../network/domr/,0755,/usr/lib/xcp/bin router_proxy.sh=../../../../network/domr/,0755,/usr/lib/xcp/bin +createipAlias.sh=..,0755,/usr/lib/xcp/bin +deleteipAlias.sh=..,0755,/usr/lib/xcp/bin diff --git a/scripts/vm/hypervisor/xenserver/xcpserver/patch b/scripts/vm/hypervisor/xenserver/xcpserver/patch index a275df4a48b..7e92d5aa4ec 100644 --- a/scripts/vm/hypervisor/xenserver/xcpserver/patch +++ b/scripts/vm/hypervisor/xenserver/xcpserver/patch @@ -40,8 +40,8 @@ make_migratable.sh=..,0755,/opt/xensource/bin setup_iscsi.sh=..,0755,/opt/xensource/bin pingtest.sh=../../..,0755,/opt/xensource/bin dhcp_entry.sh=../../../../network/domr/,0755,/opt/xensource/bin -createipAlias.sh=../../..,0755,/opt/xensource/bin -deleteipAlias.sh=../../..,0755,/opt/xensource/bin +createipAlias.sh=..,0755,/opt/xensource/bin +deleteipAlias.sh=..,0755,/opt/xensource/bin router_proxy.sh=../../../../network/domr/,0755,/opt/xensource/bin vm_data.sh=../../../../network/domr/,0755,/opt/xensource/bin save_password_to_domr.sh=../../../../network/domr/,0755,/opt/xensource/bin diff --git a/scripts/vm/hypervisor/xenserver/xenserver56/patch b/scripts/vm/hypervisor/xenserver/xenserver56/patch index 5c4673df247..8abd6b2c850 100644 --- a/scripts/vm/hypervisor/xenserver/xenserver56/patch +++ b/scripts/vm/hypervisor/xenserver/xenserver56/patch @@ -38,8 +38,8 @@ make_migratable.sh=..,0755,/opt/xensource/bin setup_iscsi.sh=..,0755,/opt/xensource/bin cloud-setup-bonding.sh=..,0755,/opt/xensource/bin pingtest.sh=../../..,0755,/opt/xensource/bin -createipAlias.sh=../../..,0755,/opt/xensource/bin -deleteipAlias.sh=../../..,0755,/opt/xensource/bin +createipAlias.sh=..,0755,/opt/xensource/bin +deleteipAlias.sh=..,0755,/opt/xensource/bin dhcp_entry.sh=../../../../network/domr/,0755,/opt/xensource/bin vm_data.sh=../../../../network/domr/,0755,/opt/xensource/bin save_password_to_domr.sh=../../../../network/domr/,0755,/opt/xensource/bin diff --git a/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch b/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch index c7c58b98374..901f6de3643 100644 --- a/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch +++ b/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch @@ -37,8 +37,8 @@ setupxenserver.sh=..,0755,/opt/xensource/bin make_migratable.sh=..,0755,/opt/xensource/bin setup_iscsi.sh=..,0755,/opt/xensource/bin pingtest.sh=../../..,0755,/opt/xensource/bin -createipAlias.sh=../../..,0755,/opt/xensource/bin -deleteipAlias.sh=../../..,0755,/opt/xensource/bin +createipAlias.sh=..,0755,/opt/xensource/bin +deleteipAlias.sh=..,0755,/opt/xensource/bin dhcp_entry.sh=../../../../network/domr/,0755,/opt/xensource/bin vm_data.sh=../../../../network/domr/,0755,/opt/xensource/bin save_password_to_domr.sh=../../../../network/domr/,0755,/opt/xensource/bin diff --git a/scripts/vm/hypervisor/xenserver/xenserver60/patch b/scripts/vm/hypervisor/xenserver/xenserver60/patch index 26205f2e7e6..d7da3747183 100644 --- a/scripts/vm/hypervisor/xenserver/xenserver60/patch +++ b/scripts/vm/hypervisor/xenserver/xenserver60/patch @@ -40,8 +40,8 @@ id_rsa.cloud=../../../systemvm,0600,/root/.ssh network_info.sh=..,0755,/opt/xensource/bin setupxenserver.sh=..,0755,/opt/xensource/bin make_migratable.sh=..,0755,/opt/xensource/bin -createipAlias.sh=../../..,0755,/opt/xensource/bin -deleteipAlias.sh=../../..,0755,/opt/xensource/bin +createipAlias.sh=..,0755,/opt/xensource/bin +deleteipAlias.sh=..,0755,/opt/xensource/bin setup_iscsi.sh=..,0755,/opt/xensource/bin pingtest.sh=../../..,0755,/opt/xensource/bin dhcp_entry.sh=../../../../network/domr/,0755,/opt/xensource/bin From 145a116c9bbe69e3c5cb026ce9d659f449137d30 Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Mon, 20 May 2013 22:05:07 +0530 Subject: [PATCH 23/51] Fixing TestVMLifeCycle class Missed the reference to zone listed in setUpClass() Signed-off-by: Prasanna Santhanam --- test/integration/smoke/test_vm_life_cycle.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/integration/smoke/test_vm_life_cycle.py b/test/integration/smoke/test_vm_life_cycle.py index 3f7c17b9ed6..d52ed9b8df6 100644 --- a/test/integration/smoke/test_vm_life_cycle.py +++ b/test/integration/smoke/test_vm_life_cycle.py @@ -292,28 +292,28 @@ class TestVMLifeCycle(cloudstackTestCase): # Get Zone, Domain and templates domain = get_domain(cls.api_client, cls.services) - zone = get_zone(cls.api_client, cls.services) - cls.services['mode'] = zone.networktype + cls.zone = get_zone(cls.api_client, cls.services) + cls.services['mode'] = cls.zone.networktype #if local storage is enabled, alter the offerings to use localstorage #this step is needed for devcloud - if zone.localstorageenabled == True: + if cls.zone.localstorageenabled == True: cls.services["service_offerings"]["tiny"]["storagetype"] = 'local' cls.services["service_offerings"]["small"]["storagetype"] = 'local' cls.services["service_offerings"]["medium"]["storagetype"] = 'local' template = get_template( cls.api_client, - zone.id, + cls.zone.id, cls.services["ostype"] ) # Set Zones and disk offerings - cls.services["small"]["zoneid"] = zone.id + cls.services["small"]["zoneid"] = cls.zone.id cls.services["small"]["template"] = template.id - cls.services["medium"]["zoneid"] = zone.id + cls.services["medium"]["zoneid"] = cls.zone.id cls.services["medium"]["template"] = template.id - cls.services["iso"]["zoneid"] = zone.id + cls.services["iso"]["zoneid"] = cls.zone.id # Create VMs, NAT Rules etc cls.account = Account.create( From 54ac779b8f3a520a391902ae4163b922e2078061 Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Mon, 20 May 2013 22:59:52 +0530 Subject: [PATCH 24/51] Fix all occurrences of account.account Fixes the dereference of account objects with account.account. This is to conform to recent library changes in Marvin Signed-off-by: Prasanna Santhanam --- test/integration/component/test_accounts.py | 2 +- .../component/test_high_availability.py | 28 ++-- .../component/test_host_high_availability.py | 14 +- test/integration/component/test_ldap.py | 0 test/integration/component/test_projects.py | 34 ++-- .../component/test_redundant_router.py | 120 +++++++------- test/integration/component/test_stopped_vm.py | 70 ++++---- test/integration/component/test_tags.py | 110 ++++++------- test/integration/component/test_vpc.py | 124 +++++++------- .../component/test_vpc_host_maintenance.py | 44 ++--- .../integration/component/test_vpc_network.py | 106 ++++++------ .../component/test_vpc_network_lbrules.py | 18 +- .../component/test_vpc_network_pfrules.py | 18 +- .../test_vpc_network_staticnatrule.py | 18 +- .../component/test_vpc_offerings.py | 52 +++--- .../integration/component/test_vpc_routers.py | 56 +++---- .../component/test_vpc_vm_life_cycle.py | 98 +++++------ .../component/test_vpc_vms_deployment.py | 154 +++++++++--------- test/integration/component/test_vpn_users.py | 4 +- 19 files changed, 535 insertions(+), 535 deletions(-) mode change 100755 => 100644 test/integration/component/test_ldap.py diff --git a/test/integration/component/test_accounts.py b/test/integration/component/test_accounts.py index b2038a9bd3b..a25e63688f3 100644 --- a/test/integration/component/test_accounts.py +++ b/test/integration/component/test_accounts.py @@ -561,7 +561,7 @@ class TestNonRootAdminsPrivileges(cloudstackTestCase): self.apiclient, self.services["account"] ) - self.debug("Created account: %s" % account_1.account.name) + self.debug("Created account: %s" % account_1.name) self.cleanup.append(account_1) account_2 = Account.create( self.apiclient, diff --git a/test/integration/component/test_high_availability.py b/test/integration/component/test_high_availability.py index 12753c1707f..cd2dfcea559 100644 --- a/test/integration/component/test_high_availability.py +++ b/test/integration/component/test_high_availability.py @@ -220,7 +220,7 @@ class TestHighAvailability(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) vms = VirtualMachine.list( @@ -248,7 +248,7 @@ class TestHighAvailability(cloudstackTestCase): networks = Network.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -264,7 +264,7 @@ class TestHighAvailability(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network.id ) @@ -372,7 +372,7 @@ class TestHighAvailability(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) vms = VirtualMachine.list( @@ -424,7 +424,7 @@ class TestHighAvailability(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -464,7 +464,7 @@ class TestHighAvailability(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -513,7 +513,7 @@ class TestHighAvailability(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) vms = VirtualMachine.list( @@ -615,7 +615,7 @@ class TestHighAvailability(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) vms = VirtualMachine.list( @@ -643,7 +643,7 @@ class TestHighAvailability(cloudstackTestCase): networks = Network.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -659,7 +659,7 @@ class TestHighAvailability(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network.id ) @@ -833,7 +833,7 @@ class TestHighAvailability(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) vms = VirtualMachine.list( @@ -952,7 +952,7 @@ class TestHighAvailability(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -990,7 +990,7 @@ class TestHighAvailability(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -1037,7 +1037,7 @@ class TestHighAvailability(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) vms = VirtualMachine.list( diff --git a/test/integration/component/test_host_high_availability.py b/test/integration/component/test_host_high_availability.py index 7a3f62a520f..8c66d175dd7 100644 --- a/test/integration/component/test_host_high_availability.py +++ b/test/integration/component/test_host_high_availability.py @@ -190,7 +190,7 @@ class TestHostHighAvailability(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering_with_ha.id ) vms = VirtualMachine.list( @@ -235,7 +235,7 @@ class TestHostHighAvailability(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering_with_ha.id ) @@ -289,7 +289,7 @@ class TestHostHighAvailability(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering_without_ha.id ) @@ -358,7 +358,7 @@ class TestHostHighAvailability(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering_with_ha.id ) @@ -464,7 +464,7 @@ class TestHostHighAvailability(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering_with_ha.id ) @@ -573,7 +573,7 @@ class TestHostHighAvailability(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering_with_ha.id ) @@ -705,7 +705,7 @@ class TestHostHighAvailability(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering_without_ha.id ) diff --git a/test/integration/component/test_ldap.py b/test/integration/component/test_ldap.py old mode 100755 new mode 100644 diff --git a/test/integration/component/test_projects.py b/test/integration/component/test_projects.py index f013e99a0dd..e1975cf5295 100644 --- a/test/integration/component/test_projects.py +++ b/test/integration/component/test_projects.py @@ -782,8 +782,8 @@ class TestProjectOwners(cloudstackTestCase): project = Project.create( self.apiclient, self.services["project"], - account=self.admin.account.name, - domainid=self.admin.account.domainid + account=self.admin.name, + domainid=self.admin.domainid ) self.cleanup.append(project) # Cleanup created project at end of test @@ -815,20 +815,20 @@ class TestProjectOwners(cloudstackTestCase): "Check project name from list response" ) self.debug("Adding %s user to project: %s" % ( - self.new_admin.account.name, + self.new_admin.name, project.name )) # Add user to the project project.addAccount( self.apiclient, - self.new_admin.account.name, + self.new_admin.name, ) # listProjectAccount to verify the user is added to project or not accounts_reponse = Project.listAccounts( self.apiclient, projectid=project.id, - account=self.new_admin.account.name, + account=self.new_admin.name, ) self.debug(accounts_reponse) self.assertEqual( @@ -853,14 +853,14 @@ class TestProjectOwners(cloudstackTestCase): # Update the project with new admin project.update( self.apiclient, - account=self.new_admin.account.name + account=self.new_admin.name ) # listProjectAccount to verify the user is new admin of the project accounts_reponse = Project.listAccounts( self.apiclient, projectid=project.id, - account=self.new_admin.account.name, + account=self.new_admin.name, ) self.debug(accounts_reponse) self.assertEqual( @@ -886,7 +886,7 @@ class TestProjectOwners(cloudstackTestCase): accounts_reponse = Project.listAccounts( self.apiclient, projectid=project.id, - account=self.admin.account.name, + account=self.admin.name, ) self.debug(accounts_reponse) self.assertEqual( @@ -923,8 +923,8 @@ class TestProjectOwners(cloudstackTestCase): project = Project.create( self.apiclient, self.services["project"], - account=self.admin.account.name, - domainid=self.admin.account.domainid + account=self.admin.name, + domainid=self.admin.domainid ) # Cleanup created project at end of test self.cleanup.append(project) @@ -965,20 +965,20 @@ class TestProjectOwners(cloudstackTestCase): "Check project name from list response" ) self.debug("Adding %s user to project: %s" % ( - self.new_admin.account.name, + self.new_admin.name, project.name )) # Add user to the project project.addAccount( self.apiclient, - self.new_admin.account.name, + self.new_admin.name, ) # listProjectAccount to verify the user is added to project or not accounts_reponse = Project.listAccounts( self.apiclient, projectid=project.id, - account=self.new_admin.account.name, + account=self.new_admin.name, ) self.debug(accounts_reponse) self.assertEqual( @@ -1000,18 +1000,18 @@ class TestProjectOwners(cloudstackTestCase): "Newly added user is not added as a regular user" ) self.debug("Updating project with new Admin: %s" % - self.new_admin.account.name) + self.new_admin.name) # Update the project with new admin project.update( self.apiclient, - account=self.new_admin.account.name + account=self.new_admin.name ) # listProjectAccount to verify the user is new admin of the project accounts_reponse = Project.listAccounts( self.apiclient, projectid=project.id, - account=self.new_admin.account.name, + account=self.new_admin.name, ) self.assertEqual( isinstance(accounts_reponse, list), @@ -1106,7 +1106,7 @@ class TestProjectOwners(cloudstackTestCase): accounts_reponse = Project.listAccounts( self.apiclient, projectid=project.id, - account=self.new_admin.account.name, + account=self.new_admin.name, ) self.assertEqual( isinstance(accounts_reponse, list), diff --git a/test/integration/component/test_redundant_router.py b/test/integration/component/test_redundant_router.py index 8885241ef7b..a87818a4ccb 100644 --- a/test/integration/component/test_redundant_router.py +++ b/test/integration/component/test_redundant_router.py @@ -331,7 +331,7 @@ class TestCreateRvRNetwork(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id ) @@ -375,7 +375,7 @@ class TestCreateRvRNetwork(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network.id)] ) @@ -538,7 +538,7 @@ class TestCreateRvRNetworkNonDefaultGuestCidr(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id, guestcidr=' 192.168.2.0/23' @@ -593,7 +593,7 @@ class TestCreateRvRNetworkNonDefaultGuestCidr(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network.id)] ) @@ -760,7 +760,7 @@ class TestRVRInternals(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id ) @@ -804,7 +804,7 @@ class TestRVRInternals(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network.id)] ) @@ -1019,7 +1019,7 @@ class TestRedundancy(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id ) @@ -1031,7 +1031,7 @@ class TestRedundancy(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(self.network.id)] ) @@ -1572,7 +1572,7 @@ class TestRedundancy(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(self.network.id)] ) @@ -1712,7 +1712,7 @@ class TestApplyAndDeleteNetworkRulesOnRvR(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id ) @@ -1756,7 +1756,7 @@ class TestApplyAndDeleteNetworkRulesOnRvR(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network.id)] ) @@ -1801,7 +1801,7 @@ class TestApplyAndDeleteNetworkRulesOnRvR(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network.id ) self.debug("Associated %s with network %s" % ( @@ -1870,7 +1870,7 @@ class TestApplyAndDeleteNetworkRulesOnRvR(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network.id ) self.debug("Associated %s with network %s" % ( @@ -1902,7 +1902,7 @@ class TestApplyAndDeleteNetworkRulesOnRvR(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network.id ) self.debug("Associated %s with network %s" % ( @@ -2037,7 +2037,7 @@ class TestEnableVPNOverRvR(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id ) @@ -2081,7 +2081,7 @@ class TestEnableVPNOverRvR(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network.id)] ) @@ -2126,7 +2126,7 @@ class TestEnableVPNOverRvR(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network.id ) self.debug("Associated %s with network %s" % ( @@ -2142,7 +2142,7 @@ class TestEnableVPNOverRvR(cloudstackTestCase): self.apiclient, publicipid=public_ip.ipaddress.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) except Exception as e: self.fail("Failed to create VPN for account: %s - %s" % ( @@ -2154,7 +2154,7 @@ class TestEnableVPNOverRvR(cloudstackTestCase): username="root", password="password", account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) except Exception as e: self.fail("Failed to create VPN user: %s" % e) @@ -2163,7 +2163,7 @@ class TestEnableVPNOverRvR(cloudstackTestCase): remote_vpns = Vpn.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, publicipid=public_ip.ipaddress.id, listall=True ) @@ -2184,7 +2184,7 @@ class TestEnableVPNOverRvR(cloudstackTestCase): remote_vpns = Vpn.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, publicipid=public_ip.ipaddress.id, listall=True ) @@ -2306,7 +2306,7 @@ class TestNetworkRulesMasterDownDeleteNetworkRules(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id ) @@ -2350,7 +2350,7 @@ class TestNetworkRulesMasterDownDeleteNetworkRules(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network.id)] ) @@ -2412,7 +2412,7 @@ class TestNetworkRulesMasterDownDeleteNetworkRules(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network.id ) self.debug("Associated %s with network %s" % ( @@ -2481,7 +2481,7 @@ class TestNetworkRulesMasterDownDeleteNetworkRules(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network.id ) self.debug("Associated %s with network %s" % ( @@ -2513,7 +2513,7 @@ class TestNetworkRulesMasterDownDeleteNetworkRules(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network.id ) self.debug("Associated %s with network %s" % ( @@ -2694,7 +2694,7 @@ class TestApplyDeleteNetworkRulesRebootRouter(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id ) @@ -2738,7 +2738,7 @@ class TestApplyDeleteNetworkRulesRebootRouter(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network.id)] ) @@ -2790,7 +2790,7 @@ class TestApplyDeleteNetworkRulesRebootRouter(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network.id ) self.debug("Associated %s with network %s" % ( @@ -2851,7 +2851,7 @@ class TestApplyDeleteNetworkRulesRebootRouter(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network.id ) self.debug("Associated %s with network %s" % ( @@ -2872,7 +2872,7 @@ class TestApplyDeleteNetworkRulesRebootRouter(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network.id ) self.debug("Associated %s with network %s" % ( @@ -3058,7 +3058,7 @@ class TestRestartRvRNetworkWithoutCleanup(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id ) @@ -3102,7 +3102,7 @@ class TestRestartRvRNetworkWithoutCleanup(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network.id)] ) @@ -3279,7 +3279,7 @@ class TestRestartRvRNetworkWithCleanup(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id ) @@ -3323,7 +3323,7 @@ class TestRestartRvRNetworkWithCleanup(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network.id)] ) @@ -3500,7 +3500,7 @@ class TestDeleteRvRNetwork(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id ) @@ -3544,7 +3544,7 @@ class TestDeleteRvRNetwork(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network.id)] ) @@ -3719,7 +3719,7 @@ class TestNetworkGCRvR(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id ) @@ -3763,7 +3763,7 @@ class TestNetworkGCRvR(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network.id)] ) @@ -3999,7 +3999,7 @@ class TestApplyRulesRestartRvRNetwork(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id ) @@ -4043,7 +4043,7 @@ class TestApplyRulesRestartRvRNetwork(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network.id)] ) @@ -4095,7 +4095,7 @@ class TestApplyRulesRestartRvRNetwork(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network.id ) self.debug("Associated %s with network %s" % ( @@ -4156,7 +4156,7 @@ class TestApplyRulesRestartRvRNetwork(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network.id ) self.debug("Associated %s with network %s" % ( @@ -4177,7 +4177,7 @@ class TestApplyRulesRestartRvRNetwork(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network.id ) self.debug("Associated %s with network %s" % ( @@ -4439,7 +4439,7 @@ class TestUpgradeDowngradeRVR(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=network_off_vr.id, zoneid=self.zone.id ) @@ -4471,7 +4471,7 @@ class TestUpgradeDowngradeRVR(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network.id)] ) @@ -4500,7 +4500,7 @@ class TestUpgradeDowngradeRVR(cloudstackTestCase): routers = Router.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -4528,7 +4528,7 @@ class TestUpgradeDowngradeRVR(cloudstackTestCase): routers = Router.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -4574,7 +4574,7 @@ class TestUpgradeDowngradeRVR(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id ) @@ -4606,7 +4606,7 @@ class TestUpgradeDowngradeRVR(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network.id)] ) @@ -4635,7 +4635,7 @@ class TestUpgradeDowngradeRVR(cloudstackTestCase): routers = Router.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -4676,7 +4676,7 @@ class TestUpgradeDowngradeRVR(cloudstackTestCase): routers = Router.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -4808,7 +4808,7 @@ class TestRVRWithDiffEnvs(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id ) @@ -4852,7 +4852,7 @@ class TestRVRWithDiffEnvs(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network.id)] ) @@ -4972,7 +4972,7 @@ class TestRVRWithDiffEnvs(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id ) @@ -5016,7 +5016,7 @@ class TestRVRWithDiffEnvs(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network.id)] ) @@ -5208,7 +5208,7 @@ class TestRVRWithDiffEnvs(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id ) @@ -5265,7 +5265,7 @@ class TestRVRWithDiffEnvs(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network.id)], hostid=host.id @@ -5449,7 +5449,7 @@ class TestRVRWithDiffEnvs(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id ) @@ -5506,7 +5506,7 @@ class TestRVRWithDiffEnvs(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network.id)], hostid=host.id diff --git a/test/integration/component/test_stopped_vm.py b/test/integration/component/test_stopped_vm.py index 10e3d4d0b83..f1096919824 100644 --- a/test/integration/component/test_stopped_vm.py +++ b/test/integration/component/test_stopped_vm.py @@ -188,7 +188,7 @@ class TestDeployVM(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, diskofferingid=self.disk_offering.id, mode=self.zone.networktype @@ -242,7 +242,7 @@ class TestDeployVM(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, startvm=True, diskofferingid=self.disk_offering.id, @@ -299,7 +299,7 @@ class TestDeployVM(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, startvm=False, diskofferingid=self.disk_offering.id, @@ -332,7 +332,7 @@ class TestDeployVM(cloudstackTestCase): routers = Router.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -389,7 +389,7 @@ class TestDeployVM(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, startvm=False, diskofferingid=self.disk_offering.id, @@ -426,7 +426,7 @@ class TestDeployVM(cloudstackTestCase): self.services["volume"], zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, diskofferingid=self.disk_offering.id ) self.debug("Created volume in account: %s" % self.account.name) @@ -457,7 +457,7 @@ class TestDeployVM(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, startvm=False, diskofferingid=self.disk_offering.id, @@ -494,7 +494,7 @@ class TestDeployVM(cloudstackTestCase): self.services["volume"], zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, diskofferingid=self.disk_offering.id ) self.debug("Created volume in account: %s" % self.account.name) @@ -570,7 +570,7 @@ class TestDeployVM(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, startvm=False, diskofferingid=self.disk_offering.id, @@ -607,7 +607,7 @@ class TestDeployVM(cloudstackTestCase): self.services["volume"], zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, diskofferingid=self.disk_offering.id ) self.debug("Created volume in account: %s" % self.account.name) @@ -653,7 +653,7 @@ class TestDeployVM(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, startvm=False, diskofferingid=self.disk_offering.id, @@ -689,7 +689,7 @@ class TestDeployVM(cloudstackTestCase): self.apiclient, self.services["iso"], account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.debug("Successfully created ISO with ID: %s" % iso.id) @@ -746,7 +746,7 @@ class TestDeployVM(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, startvm=False, ) @@ -782,7 +782,7 @@ class TestDeployVM(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, diskofferingid=self.disk_offering.id ) @@ -819,7 +819,7 @@ class TestDeployVM(cloudstackTestCase): self.apiclient, type='DATADISK', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -943,7 +943,7 @@ class TestDeployHaEnabledVM(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, diskofferingid=self.disk_offering.id, startvm=False @@ -990,7 +990,7 @@ class TestDeployHaEnabledVM(cloudstackTestCase): self.apiclient, self.services["iso"], account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) try: # Dowanload the ISO @@ -1007,7 +1007,7 @@ class TestDeployHaEnabledVM(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, templateid=self.iso.id, serviceofferingid=self.service_offering.id, diskofferingid=self.disk_offering.id, @@ -1057,7 +1057,7 @@ class TestDeployHaEnabledVM(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, diskofferingid=self.disk_offering.id, startvm=False @@ -1175,7 +1175,7 @@ class TestRouterStateAfterDeploy(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, diskofferingid=self.disk_offering.id, startvm=False @@ -1210,7 +1210,7 @@ class TestRouterStateAfterDeploy(cloudstackTestCase): routers = Router.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -1225,7 +1225,7 @@ class TestRouterStateAfterDeploy(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, diskofferingid=self.disk_offering.id, startvm=True @@ -1260,7 +1260,7 @@ class TestRouterStateAfterDeploy(cloudstackTestCase): routers = Router.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -1295,7 +1295,7 @@ class TestRouterStateAfterDeploy(cloudstackTestCase): routers = Router.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertNotEqual( @@ -1397,7 +1397,7 @@ class TestDeployVMBasicZone(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, startvm=True, diskofferingid=self.disk_offering.id, @@ -1455,7 +1455,7 @@ class TestDeployVMBasicZone(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, startvm=False, mode=self.zone.networktype @@ -1570,7 +1570,7 @@ class TestDeployVMFromTemplate(cloudstackTestCase): self.services["template"], zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) try: self.template.download(self.apiclient) @@ -1606,7 +1606,7 @@ class TestDeployVMFromTemplate(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, templateid=self.template.id, startvm=False, @@ -1744,7 +1744,7 @@ class TestVMAccountLimit(cloudstackTestCase): self.apiclient, 0, # Instance account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, max=1 ) self.debug( @@ -1756,7 +1756,7 @@ class TestVMAccountLimit(cloudstackTestCase): self.services["virtual_machine"], templateid=self.template.id, accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, startvm=False ) @@ -1775,7 +1775,7 @@ class TestVMAccountLimit(cloudstackTestCase): self.services["virtual_machine"], templateid=self.template.id, accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, startvm=False ) @@ -1861,7 +1861,7 @@ class TestUploadAttachVolume(cloudstackTestCase): self.services["volume"], zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.debug("Uploading the volume: %s" % volume.name) volume.wait_for_upload(self.apiclient) @@ -1878,7 +1878,7 @@ class TestUploadAttachVolume(cloudstackTestCase): self.services["virtual_machine"], templateid=self.template.id, accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, startvm=False ) @@ -1999,7 +1999,7 @@ class TestDeployOnSpecificHost(cloudstackTestCase): self.services["virtual_machine"], templateid=self.template.id, accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, hostid=host.id ) @@ -2013,7 +2013,7 @@ class TestDeployOnSpecificHost(cloudstackTestCase): id=vm.id, listall=True, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.assertEqual( diff --git a/test/integration/component/test_tags.py b/test/integration/component/test_tags.py index ab5ab310094..12a586313f1 100644 --- a/test/integration/component/test_tags.py +++ b/test/integration/component/test_tags.py @@ -224,7 +224,7 @@ class TestResourceTags(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.zone.networktype ) @@ -280,7 +280,7 @@ class TestResourceTags(cloudstackTestCase): networks = Network.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -297,7 +297,7 @@ class TestResourceTags(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network.id ) self.cleanup.append(public_ip) @@ -346,7 +346,7 @@ class TestResourceTags(cloudstackTestCase): resourceType='LoadBalancer', key='LB', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, value=40 ) @@ -393,7 +393,7 @@ class TestResourceTags(cloudstackTestCase): resourceType='LoadBalancer', key='LB', account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.assertEqual( @@ -423,7 +423,7 @@ class TestResourceTags(cloudstackTestCase): networks = Network.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -440,7 +440,7 @@ class TestResourceTags(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network.id ) self.cleanup.append(public_ip) @@ -484,7 +484,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='portForwardingRule', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='PF', value=40 ) @@ -529,7 +529,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='portForwardingRule', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='PF', value=40 ) @@ -560,7 +560,7 @@ class TestResourceTags(cloudstackTestCase): networks = Network.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -577,7 +577,7 @@ class TestResourceTags(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network.id ) self.cleanup.append(public_ip) @@ -626,7 +626,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='FirewallRule', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='FW', value='40' ) @@ -671,7 +671,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='FirewallRule', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='FW', value='40' ) @@ -704,7 +704,7 @@ class TestResourceTags(cloudstackTestCase): networks = Network.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -721,7 +721,7 @@ class TestResourceTags(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network.id ) self.cleanup.append(public_ip) @@ -754,7 +754,7 @@ class TestResourceTags(cloudstackTestCase): self.apiclient, public_ip.ipaddress.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) except Exception as e: @@ -792,7 +792,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='VPN', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='protocol', value='L2TP' ) @@ -823,7 +823,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='VPN', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='protocol', value='L2TP' ) @@ -863,7 +863,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='userVM', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='region', value='India' ) @@ -907,7 +907,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='userVM', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='region', value='India' ) @@ -978,7 +978,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='Template', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='OS', value='CentOS' ) @@ -1019,7 +1019,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='Template', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='OS', value='CentOS' ) @@ -1042,7 +1042,7 @@ class TestResourceTags(cloudstackTestCase): self.apiclient, self.services["iso"], account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.debug("ISO created with ID: %s" % iso.id) @@ -1070,7 +1070,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='ISO', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='OS', value='CentOS' ) @@ -1115,7 +1115,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='ISO', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='OS', value='CentOS' ) @@ -1141,7 +1141,7 @@ class TestResourceTags(cloudstackTestCase): self.services["volume"], zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, diskofferingid=self.disk_offering.id ) self.cleanup.append(volume) @@ -1162,7 +1162,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='volume', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='region', value='India' ) @@ -1205,7 +1205,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='volume', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='region' ) self.assertEqual( @@ -1262,7 +1262,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='snapshot', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='type', value='manual' ) @@ -1312,7 +1312,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='snapshot', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='type', value='manual' ) @@ -1337,7 +1337,7 @@ class TestResourceTags(cloudstackTestCase): networks = Network.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -1363,7 +1363,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='Network', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='region', value='India' ) @@ -1381,7 +1381,7 @@ class TestResourceTags(cloudstackTestCase): networks = Network.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True, key='region', value='India' @@ -1409,7 +1409,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='Network', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='region', value='India' ) @@ -1479,7 +1479,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='userVM', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='region', value='India' ) @@ -1516,7 +1516,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='userVM', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='region', value='India' ) @@ -1550,7 +1550,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='userVM', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='region', value='India' ) @@ -1596,7 +1596,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='userVM', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='region', value='India' ) @@ -1642,7 +1642,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='userVM', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='region', value='India' ) @@ -1691,7 +1691,7 @@ class TestResourceTags(cloudstackTestCase): self.apiclient, self.services["project"], account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) # Cleanup created project at end of test self.cleanup.append(project) @@ -1758,7 +1758,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='project', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='region', value='India' ) @@ -1799,7 +1799,7 @@ class TestResourceTags(cloudstackTestCase): self.apiclient, self.services["iso"], account=user_account.name, - domainid=user_account.account.domainid + domainid=user_account.domainid ) self.debug("ISO created with ID: %s" % iso.id) @@ -1827,7 +1827,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='ISO', account=user_account.name, - domainid=user_account.account.domainid, + domainid=user_account.domainid, key='region', ) @@ -1849,7 +1849,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='ISO', account=other_user_account.name, - domainid=other_user_account.account.domainid, + domainid=other_user_account.domainid, key='region', ) @@ -1884,7 +1884,7 @@ class TestResourceTags(cloudstackTestCase): self.apiclient, self.services["iso"], account=user_account.name, - domainid=user_account.account.domainid + domainid=user_account.domainid ) self.debug("ISO created with ID: %s" % iso.id) @@ -1912,7 +1912,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='ISO', account=user_account.name, - domainid=user_account.account.domainid, + domainid=user_account.domainid, key='region', ) @@ -2009,7 +2009,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='userVM', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='region', value='India' ) @@ -2042,7 +2042,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='userVM', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='region', value='India' ) @@ -2065,7 +2065,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='userVM', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='region', value='India' ) @@ -2103,7 +2103,7 @@ class TestResourceTags(cloudstackTestCase): self.services["volume"], zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, diskofferingid=self.disk_offering.id ) self.cleanup.append(volume) @@ -2124,7 +2124,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='volume', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='region', ) self.assertEqual( @@ -2152,7 +2152,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='userVM', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='region', value='India' ) @@ -2185,7 +2185,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='userVM', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='region', value='India' ) @@ -2246,7 +2246,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='userVM', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='region', value='India' ) @@ -2295,7 +2295,7 @@ class TestResourceTags(cloudstackTestCase): listall=True, resourceType='userVM', account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, key='region', value='India' ) diff --git a/test/integration/component/test_vpc.py b/test/integration/component/test_vpc.py index 83b913a8738..7dbe7c4bf91 100644 --- a/test/integration/component/test_vpc.py +++ b/test/integration/component/test_vpc.py @@ -316,7 +316,7 @@ class TestVPC(cloudstackTestCase): vpcofferingid=self.vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -348,7 +348,7 @@ class TestVPC(cloudstackTestCase): vpcofferingid=self.vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -373,7 +373,7 @@ class TestVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id, gateway=gateway, @@ -397,7 +397,7 @@ class TestVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering_no_lb.id, zoneid=self.zone.id, gateway=gateway, @@ -432,7 +432,7 @@ class TestVPC(cloudstackTestCase): vpcofferingid=self.vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -475,7 +475,7 @@ class TestVPC(cloudstackTestCase): vpcofferingid=self.vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -500,7 +500,7 @@ class TestVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id, gateway=gateway, @@ -524,7 +524,7 @@ class TestVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering_no_lb.id, zoneid=self.zone.id, gateway=gateway, @@ -575,7 +575,7 @@ class TestVPC(cloudstackTestCase): routers = Router.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -613,7 +613,7 @@ class TestVPC(cloudstackTestCase): vpcofferingid=self.vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc_1) @@ -624,7 +624,7 @@ class TestVPC(cloudstackTestCase): vpcofferingid=self.vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc_2) @@ -714,7 +714,7 @@ class TestVPC(cloudstackTestCase): supportedservices='Vpn,Dhcp,Dns,SourceNat,PortForwarding,Lb,UserData,StaticNat,NetworkACL', listall=True, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.assertEqual( isinstance(vpcs, list), @@ -733,7 +733,7 @@ class TestVPC(cloudstackTestCase): restartrequired=True, listall=True, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) if vpcs is not None: for vpc in vpcs: @@ -748,7 +748,7 @@ class TestVPC(cloudstackTestCase): restartrequired=False, listall=True, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.assertEqual( isinstance(vpcs, list), @@ -789,7 +789,7 @@ class TestVPC(cloudstackTestCase): vpcofferingid=self.vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc_1) @@ -869,7 +869,7 @@ class TestVPC(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -898,7 +898,7 @@ class TestVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering_no_lb.id, zoneid=self.zone.id, gateway='10.1.1.1', @@ -913,7 +913,7 @@ class TestVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id, gateway='10.1.2.1', @@ -927,7 +927,7 @@ class TestVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_1.id)] ) @@ -937,7 +937,7 @@ class TestVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_1.id)] ) @@ -949,7 +949,7 @@ class TestVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_2.id)] ) @@ -959,7 +959,7 @@ class TestVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_2.id)] ) @@ -970,7 +970,7 @@ class TestVPC(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network_1.id, vpcid=vpc.id ) @@ -1002,7 +1002,7 @@ class TestVPC(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network_1.id, vpcid=vpc.id ) @@ -1031,7 +1031,7 @@ class TestVPC(cloudstackTestCase): listall=True, isstaticnat=True, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.assertEqual( isinstance(public_ips, list), @@ -1049,7 +1049,7 @@ class TestVPC(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network_2.id, vpcid=vpc.id ) @@ -1068,7 +1068,7 @@ class TestVPC(cloudstackTestCase): accountid=self.account.name, networkid=network_2.id, vpcid=vpc.id, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.debug("Adding virtual machines %s and %s to LB rule" % ( @@ -1214,7 +1214,7 @@ class TestVPC(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -1243,7 +1243,7 @@ class TestVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering_no_lb.id, zoneid=self.zone.id, gateway='10.1.1.1', @@ -1258,7 +1258,7 @@ class TestVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id, gateway='10.1.2.1', @@ -1272,7 +1272,7 @@ class TestVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_1.id)] ) @@ -1282,7 +1282,7 @@ class TestVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_1.id)] ) @@ -1294,7 +1294,7 @@ class TestVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_2.id)] ) @@ -1304,7 +1304,7 @@ class TestVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_2.id)] ) @@ -1315,7 +1315,7 @@ class TestVPC(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network_1.id, vpcid=vpc.id ) @@ -1347,7 +1347,7 @@ class TestVPC(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network_1.id, vpcid=vpc.id ) @@ -1376,7 +1376,7 @@ class TestVPC(cloudstackTestCase): listall=True, isstaticnat=True, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.assertEqual( isinstance(public_ips, list), @@ -1394,7 +1394,7 @@ class TestVPC(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network_2.id, vpcid=vpc.id ) @@ -1413,7 +1413,7 @@ class TestVPC(cloudstackTestCase): accountid=self.account.name, networkid=network_2.id, vpcid=vpc.id, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.debug("Adding virtual machines %s and %s to LB rule" % ( @@ -1558,7 +1558,7 @@ class TestVPC(cloudstackTestCase): vpcofferingid=self.vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -1574,7 +1574,7 @@ class TestVPC(cloudstackTestCase): routers = Router.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -1590,7 +1590,7 @@ class TestVPC(cloudstackTestCase): src_nat_list = PublicIPAddress.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True, issourcenat=True, vpcid=vpc.id @@ -1614,7 +1614,7 @@ class TestVPC(cloudstackTestCase): vpcofferingid=self.vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc_1) @@ -1628,7 +1628,7 @@ class TestVPC(cloudstackTestCase): vpcofferingid=self.vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc_2) @@ -1642,7 +1642,7 @@ class TestVPC(cloudstackTestCase): vpcofferingid=self.vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.debug("%s" % vpc_3) except Exception as e: @@ -1677,7 +1677,7 @@ class TestVPC(cloudstackTestCase): vpcofferingid=self.vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) self.network_offering = NetworkOffering.create( @@ -1701,7 +1701,7 @@ class TestVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id, gateway=gateway, @@ -1714,7 +1714,7 @@ class TestVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network.id)] ) @@ -1729,7 +1729,7 @@ class TestVPC(cloudstackTestCase): self.apiclient, zoneid=self.zone.id, accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network.id, vpcid=vpc.id ) @@ -1823,7 +1823,7 @@ class TestVPC(cloudstackTestCase): vpcofferingid=self.vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -1852,7 +1852,7 @@ class TestVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id, gateway=gateway, @@ -1879,7 +1879,7 @@ class TestVPC(cloudstackTestCase): vpcofferingid=self.vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkDomain=netdomain ) self.validate_vpc_network(vpc) @@ -1904,7 +1904,7 @@ class TestVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id, gateway=gateway, @@ -1917,7 +1917,7 @@ class TestVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network.id)] ) @@ -2355,7 +2355,7 @@ class TestVPC(cloudstackTestCase): self.services["vpc"], zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.services["vpc_no_name"]["cidr"] = "10.1.1.1/16" @@ -2367,7 +2367,7 @@ class TestVPC(cloudstackTestCase): vpcofferingid=self.vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) # Create VPC without zoneid param @@ -2377,7 +2377,7 @@ class TestVPC(cloudstackTestCase): self.services["vpc"], vpcofferingid=self.vpc_off.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) vpc_wo_cidr = {"name": "TestVPC_WO_CIDR", @@ -2392,7 +2392,7 @@ class TestVPC(cloudstackTestCase): vpcofferingid=self.vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) @attr(tags=["advanced", "intervlan"]) @@ -2414,7 +2414,7 @@ class TestVPC(cloudstackTestCase): vpcofferingid=self.vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -2439,7 +2439,7 @@ class TestVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id, gateway=gateway, @@ -2671,7 +2671,7 @@ class TestVPCHostMaintenance(cloudstackTestCase): vpcofferingid=self.vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc, state='Disabled') return @@ -2697,7 +2697,7 @@ class TestVPCHostMaintenance(cloudstackTestCase): vpcofferingid=self.vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc, state='Disabled') interval = list_configurations( diff --git a/test/integration/component/test_vpc_host_maintenance.py b/test/integration/component/test_vpc_host_maintenance.py index 4c14f991954..1cce2764fe8 100644 --- a/test/integration/component/test_vpc_host_maintenance.py +++ b/test/integration/component/test_vpc_host_maintenance.py @@ -242,7 +242,7 @@ class TestVMLifeCycleHostmaintenance(cloudstackTestCase): vpcofferingid=cls.vpc_off.id, zoneid=cls.zone.id, account=cls.account.name, - domainid=cls.account.account.domainid + domainid=cls.account.domainid ) cls.nw_off = NetworkOffering.create( @@ -258,7 +258,7 @@ class TestVMLifeCycleHostmaintenance(cloudstackTestCase): cls.api_client, cls.services["network"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, networkofferingid=cls.nw_off.id, zoneid=cls.zone.id, gateway='10.1.1.1', @@ -277,7 +277,7 @@ class TestVMLifeCycleHostmaintenance(cloudstackTestCase): cls.api_client, cls.services["network"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, networkofferingid=cls.nw_off_no_lb.id, zoneid=cls.zone.id, gateway='10.1.2.1', @@ -288,7 +288,7 @@ class TestVMLifeCycleHostmaintenance(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering_1.id, networkids=[str(cls.network_1.id)] ) @@ -297,7 +297,7 @@ class TestVMLifeCycleHostmaintenance(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering_1.id, networkids=[str(cls.network_1.id)] ) @@ -305,14 +305,14 @@ class TestVMLifeCycleHostmaintenance(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering_2.id, networkids=[str(cls.network_2.id)] ) routers = Router.list( cls.api_client, account=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, listall=True ) if isinstance(routers, list): @@ -376,7 +376,7 @@ class TestVMLifeCycleHostmaintenance(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=self.network_1.id, listall=True ) @@ -391,7 +391,7 @@ class TestVMLifeCycleHostmaintenance(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=self.network_2.id, listall=True ) @@ -441,7 +441,7 @@ class TestVMLifeCycleHostmaintenance(cloudstackTestCase): routers = Router.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -458,7 +458,7 @@ class TestVMLifeCycleHostmaintenance(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -618,7 +618,7 @@ class TestVPCNetworkRules(cloudstackTestCase): vpcofferingid=cls.vpc_off.id, zoneid=cls.zone.id, account=cls.account.name, - domainid=cls.account.account.domainid + domainid=cls.account.domainid ) cls.nw_off = NetworkOffering.create( @@ -634,7 +634,7 @@ class TestVPCNetworkRules(cloudstackTestCase): cls.api_client, cls.services["network"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, networkofferingid=cls.nw_off.id, zoneid=cls.zone.id, gateway='10.1.1.1', @@ -653,7 +653,7 @@ class TestVPCNetworkRules(cloudstackTestCase): cls.api_client, cls.services["network"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, networkofferingid=cls.nw_off_no_lb.id, zoneid=cls.zone.id, gateway='10.1.2.1', @@ -664,7 +664,7 @@ class TestVPCNetworkRules(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering_1.id, networkids=[str(cls.network_1.id)] ) @@ -673,7 +673,7 @@ class TestVPCNetworkRules(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering_2.id, networkids=[str(cls.network_1.id)] ) @@ -681,7 +681,7 @@ class TestVPCNetworkRules(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering_1.id, networkids=[str(cls.network_2.id)] ) @@ -689,7 +689,7 @@ class TestVPCNetworkRules(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering_2.id, networkids=[str(cls.network_2.id)] ) @@ -739,7 +739,7 @@ class TestVPCNetworkRules(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=self.network_1.id, listall=True ) @@ -754,7 +754,7 @@ class TestVPCNetworkRules(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=self.network_2.id, listall=True ) @@ -800,7 +800,7 @@ class TestVPCNetworkRules(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=self.network_1.id, vpcid=self.vpc.id ) @@ -825,7 +825,7 @@ class TestVPCNetworkRules(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=self.network_2.id, vpcid=self.vpc.id ) diff --git a/test/integration/component/test_vpc_network.py b/test/integration/component/test_vpc_network.py index 0adf9d7fcdc..dc535851858 100644 --- a/test/integration/component/test_vpc_network.py +++ b/test/integration/component/test_vpc_network.py @@ -333,7 +333,7 @@ class TestVPCNetwork(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -353,7 +353,7 @@ class TestVPCNetwork(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id, gateway='10.1.1.1', @@ -426,7 +426,7 @@ class TestVPCNetwork(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -451,7 +451,7 @@ class TestVPCNetwork(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id, gateway='10.1.1.1', @@ -497,7 +497,7 @@ class TestVPCNetwork(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -517,7 +517,7 @@ class TestVPCNetwork(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id, gateway='10.1.1.1', @@ -588,7 +588,7 @@ class TestVPCNetwork(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -608,7 +608,7 @@ class TestVPCNetwork(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id, gateway='10.1.1.1', @@ -646,7 +646,7 @@ class TestVPCNetwork(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id, gateway='10.1.2.1', @@ -693,7 +693,7 @@ class TestVPCNetwork(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -744,7 +744,7 @@ class TestVPCNetwork(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -772,7 +772,7 @@ class TestVPCNetwork(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id, gateway='10.1.2.1', @@ -821,7 +821,7 @@ class TestVPCNetwork(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -842,7 +842,7 @@ class TestVPCNetwork(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id, gateway='10.1.2.1', @@ -890,7 +890,7 @@ class TestVPCNetwork(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -952,7 +952,7 @@ class TestVPCNetwork(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -976,7 +976,7 @@ class TestVPCNetwork(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id, gateway='10.1.1.1', @@ -1022,7 +1022,7 @@ class TestVPCNetwork(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -1193,7 +1193,7 @@ class TestVPCNetworkRanges(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -1215,7 +1215,7 @@ class TestVPCNetworkRanges(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id, gateway='10.2.1.1', @@ -1255,7 +1255,7 @@ class TestVPCNetworkRanges(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -1277,7 +1277,7 @@ class TestVPCNetworkRanges(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id, gateway='10.2.1.1', @@ -1317,7 +1317,7 @@ class TestVPCNetworkRanges(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -1342,7 +1342,7 @@ class TestVPCNetworkRanges(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id, gateway='10.1.1.1', @@ -1384,7 +1384,7 @@ class TestVPCNetworkRanges(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -1406,7 +1406,7 @@ class TestVPCNetworkRanges(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id, gateway='10.1.1.1', @@ -1447,7 +1447,7 @@ class TestVPCNetworkRanges(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id, gateway='10.1.1.1', @@ -1465,7 +1465,7 @@ class TestVPCNetworkRanges(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id, gateway='10.1.1.1', @@ -1505,7 +1505,7 @@ class TestVPCNetworkRanges(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -1540,7 +1540,7 @@ class TestVPCNetworkRanges(cloudstackTestCase): self.apiclient, self.services["network"], accountid=account.name, - domainid=account.account.domainid, + domainid=account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id, gateway='10.1.1.1', @@ -1710,7 +1710,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -1751,7 +1751,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=nw_off_no_pf.id, zoneid=self.zone.id, gateway='10.1.1.1', @@ -1765,7 +1765,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_1.id)] ) @@ -1774,7 +1774,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_1.id)] ) @@ -1785,7 +1785,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network_1.id, vpcid=vpc.id ) @@ -1804,7 +1804,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase): accountid=self.account.name, networkid=network_1.id, vpcid=vpc.id, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.debug("Adding virtual machines %s and %s to LB rule" % ( @@ -1816,7 +1816,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network_1.id, vpcid=vpc.id ) @@ -1845,7 +1845,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase): listall=True, isstaticnat=True, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.assertEqual( isinstance(public_ips, list), @@ -1934,7 +1934,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network_1.id, vpcid=vpc.id ) @@ -2059,7 +2059,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -2099,7 +2099,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=nw_off.id, zoneid=self.zone.id, gateway='10.1.1.1', @@ -2113,7 +2113,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_1.id)] ) @@ -2182,7 +2182,7 @@ class TestVPCNetworkGc(cloudstackTestCase): vpcofferingid=cls.vpc_off.id, zoneid=cls.zone.id, account=cls.account.name, - domainid=cls.account.account.domainid + domainid=cls.account.domainid ) cls.nw_off = NetworkOffering.create( @@ -2197,7 +2197,7 @@ class TestVPCNetworkGc(cloudstackTestCase): cls.api_client, cls.services["network"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, networkofferingid=cls.nw_off.id, zoneid=cls.zone.id, gateway='10.1.1.1', @@ -2208,7 +2208,7 @@ class TestVPCNetworkGc(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, networkids=[str(cls.network_1.id)] ) @@ -2216,7 +2216,7 @@ class TestVPCNetworkGc(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, networkids=[str(cls.network_1.id)] ) @@ -2224,7 +2224,7 @@ class TestVPCNetworkGc(cloudstackTestCase): cls.api_client, accountid=cls.account.name, zoneid=cls.zone.id, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, networkid=cls.network_1.id, vpcid=cls.vpc.id ) @@ -2235,7 +2235,7 @@ class TestVPCNetworkGc(cloudstackTestCase): accountid=cls.account.name, networkid=cls.network_1.id, vpcid=cls.vpc.id, - domainid=cls.account.account.domainid + domainid=cls.account.domainid ) cls.lb_rule.assign(cls.api_client, [cls.vm_1, cls.vm_2]) @@ -2243,7 +2243,7 @@ class TestVPCNetworkGc(cloudstackTestCase): cls.api_client, accountid=cls.account.name, zoneid=cls.zone.id, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, networkid=cls.network_1.id, vpcid=cls.vpc.id ) @@ -2289,7 +2289,7 @@ class TestVPCNetworkGc(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) for vm in vms: @@ -2305,7 +2305,7 @@ class TestVPCNetworkGc(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) for vm in vms: @@ -2396,7 +2396,7 @@ class TestVPCNetworkGc(cloudstackTestCase): routers = Router.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -2515,7 +2515,7 @@ class TestVPCNetworkGc(cloudstackTestCase): routers = Router.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( diff --git a/test/integration/component/test_vpc_network_lbrules.py b/test/integration/component/test_vpc_network_lbrules.py index a24e8139b95..b4a66070d5b 100644 --- a/test/integration/component/test_vpc_network_lbrules.py +++ b/test/integration/component/test_vpc_network_lbrules.py @@ -244,7 +244,7 @@ class TestVPCNetworkLBRules(cloudstackTestCase): vpcofferingid=self.vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) return @@ -264,7 +264,7 @@ class TestVPCNetworkLBRules(cloudstackTestCase): def get_Router_For_VPC(self): routers = list_routers(self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, ) self.assertEqual(isinstance(routers, list), True, @@ -287,7 +287,7 @@ class TestVPCNetworkLBRules(cloudstackTestCase): routers = list_routers(self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, ) self.assertEqual(isinstance(routers, list), True, @@ -308,7 +308,7 @@ class TestVPCNetworkLBRules(cloudstackTestCase): routers = list_routers(self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, zoneid=self.zone.id ) self.assertEqual(isinstance(routers, list), @@ -391,7 +391,7 @@ class TestVPCNetworkLBRules(cloudstackTestCase): public_ip = PublicIPAddress.create(self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=None, #network.id, vpcid=self.vpc.id ) @@ -420,7 +420,7 @@ class TestVPCNetworkLBRules(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) return vpc @@ -442,7 +442,7 @@ class TestVPCNetworkLBRules(cloudstackTestCase): obj_network = Network.create(self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=nw_off.id, zoneid=self.zone.id, gateway=gateway, @@ -460,7 +460,7 @@ class TestVPCNetworkLBRules(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network.id)], hostid=host_id @@ -487,7 +487,7 @@ class TestVPCNetworkLBRules(cloudstackTestCase): accountid=self.account.name, networkid=network.id, vpcid=self.vpc.id, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.debug("Adding virtual machines %s and %s to LB rule" % (vmarray)) lb_rule.assign(self.apiclient, vmarray) diff --git a/test/integration/component/test_vpc_network_pfrules.py b/test/integration/component/test_vpc_network_pfrules.py index aac956810d1..56792f49d00 100644 --- a/test/integration/component/test_vpc_network_pfrules.py +++ b/test/integration/component/test_vpc_network_pfrules.py @@ -243,7 +243,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase): vpcofferingid=self.vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) return @@ -262,7 +262,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase): def get_Router_For_VPC(self): routers = list_routers(self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, ) self.assertEqual(isinstance(routers, list), True, @@ -285,7 +285,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase): routers = list_routers(self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, ) self.assertEqual(isinstance(routers, list), True, @@ -306,7 +306,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase): routers = list_routers(self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, zoneid=self.zone.id ) self.assertEqual(isinstance(routers, list), @@ -391,7 +391,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase): public_ip = PublicIPAddress.create(self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=None, #network.id, vpcid=self.vpc.id ) @@ -420,7 +420,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) return vpc @@ -442,7 +442,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase): obj_network = Network.create(self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=nw_off.id, zoneid=self.zone.id, gateway=gateway, @@ -460,7 +460,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network.id)], hostid=host_id @@ -487,7 +487,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase): accountid=self.account.name, networkid=network.id, vpcid=self.vpc.id, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.debug("Adding virtual machines %s and %s to LB rule" % (vmarray)) lb_rule.assign(self.apiclient, vmarray) diff --git a/test/integration/component/test_vpc_network_staticnatrule.py b/test/integration/component/test_vpc_network_staticnatrule.py index 842d20ad089..aceca62d1fb 100644 --- a/test/integration/component/test_vpc_network_staticnatrule.py +++ b/test/integration/component/test_vpc_network_staticnatrule.py @@ -243,7 +243,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase): vpcofferingid=self.vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) return @@ -262,7 +262,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase): def get_Router_For_VPC(self): routers = list_routers(self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, ) self.assertEqual(isinstance(routers, list), True, @@ -285,7 +285,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase): routers = list_routers(self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, ) self.assertEqual(isinstance(routers, list), True, @@ -306,7 +306,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase): routers = list_routers(self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, zoneid=self.zone.id ) self.assertEqual(isinstance(routers, list), @@ -391,7 +391,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase): public_ip = PublicIPAddress.create(self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=None, #network.id, vpcid=self.vpc.id ) @@ -420,7 +420,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) return vpc @@ -442,7 +442,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase): obj_network = Network.create(self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=nw_off.id, zoneid=self.zone.id, gateway=gateway, @@ -460,7 +460,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network.id)], hostid=host_id @@ -487,7 +487,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase): accountid=self.account.name, networkid=network.id, vpcid=self.vpc.id, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.debug("Adding virtual machines %s and %s to LB rule" % (vmarray)) lb_rule.assign(self.apiclient, vmarray) diff --git a/test/integration/component/test_vpc_offerings.py b/test/integration/component/test_vpc_offerings.py index 033a90522c4..4b9877506f2 100644 --- a/test/integration/component/test_vpc_offerings.py +++ b/test/integration/component/test_vpc_offerings.py @@ -315,7 +315,7 @@ class TestVPCOffering(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -340,7 +340,7 @@ class TestVPCOffering(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id, gateway=gateway, @@ -352,7 +352,7 @@ class TestVPCOffering(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network.id)] ) @@ -363,7 +363,7 @@ class TestVPCOffering(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network.id, vpcid=vpc.id ) @@ -382,7 +382,7 @@ class TestVPCOffering(cloudstackTestCase): accountid=self.account.name, networkid=network.id, vpcid=vpc.id, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.debug("Associating public IP for network: %s" % vpc.name) @@ -390,7 +390,7 @@ class TestVPCOffering(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network.id, vpcid=vpc.id ) @@ -438,7 +438,7 @@ class TestVPCOffering(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network.id, vpcid=vpc.id ) @@ -467,7 +467,7 @@ class TestVPCOffering(cloudstackTestCase): listall=True, isstaticnat=True, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.assertEqual( isinstance(public_ips, list), @@ -485,7 +485,7 @@ class TestVPCOffering(cloudstackTestCase): # self.apiclient, # accountid=self.account.name, # zoneid=self.zone.id, -# domainid=self.account.account.domainid, +# domainid=self.account.domainid, # networkid=network.id, # vpcid=vpc.id # ) @@ -502,7 +502,7 @@ class TestVPCOffering(cloudstackTestCase): # self.apiclient, # publicipid=public_ip_4.ipaddress.id, # account=self.account.name, -# domainid=self.account.account.domainid, +# domainid=self.account.domainid, # networkid=network.id, # vpcid=vpc.id # ) @@ -516,7 +516,7 @@ class TestVPCOffering(cloudstackTestCase): # username="root", # password="password", # account=self.account.name, -# domainid=self.account.account.domainid +# domainid=self.account.domainid # ) # except Exception as e: # self.fail("Failed to create VPN user: %s" % e) @@ -525,7 +525,7 @@ class TestVPCOffering(cloudstackTestCase): # remote_vpns = Vpn.list( # self.apiclient, # account=self.account.name, -# domainid=self.account.account.domainid, +# domainid=self.account.domainid, # publicipid=public_ip_4.ipaddress.id, # listall=True # ) @@ -596,7 +596,7 @@ class TestVPCOffering(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -612,7 +612,7 @@ class TestVPCOffering(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id, gateway=gateway, @@ -626,7 +626,7 @@ class TestVPCOffering(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network.id)] ) @@ -637,7 +637,7 @@ class TestVPCOffering(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network.id, vpcid=vpc.id ) @@ -715,7 +715,7 @@ class TestVPCOffering(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -731,7 +731,7 @@ class TestVPCOffering(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id, gateway=gateway, @@ -745,7 +745,7 @@ class TestVPCOffering(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network.id)] ) @@ -756,7 +756,7 @@ class TestVPCOffering(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network.id, vpcid=vpc.id ) @@ -836,7 +836,7 @@ class TestVPCOffering(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -852,7 +852,7 @@ class TestVPCOffering(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id, gateway=gateway, @@ -864,7 +864,7 @@ class TestVPCOffering(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network.id)] ) @@ -875,7 +875,7 @@ class TestVPCOffering(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network.id, vpcid=vpc.id ) @@ -975,7 +975,7 @@ class TestVPCOffering(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.debug("VPC network creation failed! (Test succeeded)") self.debug("Enabling the VPC offering created") @@ -989,7 +989,7 @@ class TestVPCOffering(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) diff --git a/test/integration/component/test_vpc_routers.py b/test/integration/component/test_vpc_routers.py index 55cb513130f..763a4cb14f9 100644 --- a/test/integration/component/test_vpc_routers.py +++ b/test/integration/component/test_vpc_routers.py @@ -214,7 +214,7 @@ class TestVPCRoutersBasic(cloudstackTestCase): vpcofferingid=cls.vpc_off.id, zoneid=cls.zone.id, account=cls.account.name, - domainid=cls.account.account.domainid + domainid=cls.account.domainid ) cls._cleanup.append(cls.service_offering) @@ -361,7 +361,7 @@ class TestVPCRoutersBasic(cloudstackTestCase): routers = Router.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -436,7 +436,7 @@ class TestVPCRoutersBasic(cloudstackTestCase): routers = Router.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -483,7 +483,7 @@ class TestVPCRoutersBasic(cloudstackTestCase): routers = Router.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -499,7 +499,7 @@ class TestVPCRoutersBasic(cloudstackTestCase): routers = Router.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -520,7 +520,7 @@ class TestVPCRoutersBasic(cloudstackTestCase): routers = Router.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -548,7 +548,7 @@ class TestVPCRoutersBasic(cloudstackTestCase): routers = Router.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -581,7 +581,7 @@ class TestVPCRoutersBasic(cloudstackTestCase): routers = Router.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) router = routers[0] @@ -639,7 +639,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase): vpcofferingid=cls.vpc_off.id, zoneid=cls.zone.id, account=cls.account.name, - domainid=cls.account.account.domainid + domainid=cls.account.domainid ) cls.nw_off = NetworkOffering.create( @@ -656,7 +656,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase): cls.apiclient, cls.services["network"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, networkofferingid=cls.nw_off.id, zoneid=cls.zone.id, gateway='10.1.1.1', @@ -668,7 +668,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase): cls.apiclient, cls.services["virtual_machine"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, networkids=[str(cls.network_1.id)] ) @@ -676,7 +676,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase): cls.apiclient, cls.services["virtual_machine"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, networkids=[str(cls.network_1.id)] ) @@ -686,7 +686,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase): cls.apiclient, cls.services["virtual_machine"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, networkids=[str(cls.network_1.id)] ) @@ -694,14 +694,14 @@ class TestVPCRouterOneNetwork(cloudstackTestCase): vms = VirtualMachine.list( cls.apiclient, account=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, listall=True ) public_ip_1 = PublicIPAddress.create( cls.apiclient, accountid=cls.account.name, zoneid=cls.zone.id, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, networkid=cls.network_1.id, vpcid=cls.vpc.id ) @@ -727,7 +727,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase): cls.apiclient, accountid=cls.account.name, zoneid=cls.zone.id, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, networkid=cls.network_1.id, vpcid=cls.vpc.id ) @@ -748,7 +748,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase): listall=True, isstaticnat=True, account=cls.account.name, - domainid=cls.account.account.domainid + domainid=cls.account.domainid ) # cls.assertEqual( # isinstance(public_ips, list), @@ -766,7 +766,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase): cls.apiclient, accountid=cls.account.name, zoneid=cls.zone.id, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, networkid=cls.network_1.id, vpcid=cls.vpc.id ) @@ -779,7 +779,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase): accountid=cls.account.name, networkid=cls.network_1.id, vpcid=cls.vpc.id, - domainid=cls.account.account.domainid + domainid=cls.account.domainid ) lb_rule.assign(cls.apiclient, [vm_3]) @@ -961,13 +961,13 @@ class TestVPCRouterOneNetwork(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) public_ips = PublicIPAddress.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) for vm, public_ip in zip(vms, public_ips): @@ -1086,7 +1086,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase): routers = Router.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -1180,7 +1180,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase): routers = Router.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -1247,7 +1247,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase): routers = Router.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -1263,7 +1263,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase): routers = Router.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -1306,7 +1306,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase): routers = Router.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -1351,7 +1351,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase): routers = Router.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -1384,7 +1384,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase): routers = Router.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) router = routers[0] diff --git a/test/integration/component/test_vpc_vm_life_cycle.py b/test/integration/component/test_vpc_vm_life_cycle.py index 13726c58ce4..7658bebe2e2 100644 --- a/test/integration/component/test_vpc_vm_life_cycle.py +++ b/test/integration/component/test_vpc_vm_life_cycle.py @@ -237,7 +237,7 @@ class TestVMLifeCycleVPC(cloudstackTestCase): vpcofferingid=cls.vpc_off.id, zoneid=cls.zone.id, account=cls.account.name, - domainid=cls.account.account.domainid + domainid=cls.account.domainid ) cls.nw_off = NetworkOffering.create( @@ -253,7 +253,7 @@ class TestVMLifeCycleVPC(cloudstackTestCase): cls.api_client, cls.services["network"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, networkofferingid=cls.nw_off.id, zoneid=cls.zone.id, gateway='10.1.1.1', @@ -272,7 +272,7 @@ class TestVMLifeCycleVPC(cloudstackTestCase): cls.api_client, cls.services["network"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, networkofferingid=cls.nw_off_no_lb.id, zoneid=cls.zone.id, gateway='10.1.2.1', @@ -283,7 +283,7 @@ class TestVMLifeCycleVPC(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, networkids=[str(cls.network_1.id)] ) @@ -292,7 +292,7 @@ class TestVMLifeCycleVPC(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, networkids=[str(cls.network_1.id)] ) @@ -300,7 +300,7 @@ class TestVMLifeCycleVPC(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, networkids=[str(cls.network_2.id)] ) @@ -309,7 +309,7 @@ class TestVMLifeCycleVPC(cloudstackTestCase): cls.api_client, accountid=cls.account.name, zoneid=cls.zone.id, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, networkid=cls.network_1.id, vpcid=cls.vpc.id ) @@ -320,7 +320,7 @@ class TestVMLifeCycleVPC(cloudstackTestCase): accountid=cls.account.name, networkid=cls.network_1.id, vpcid=cls.vpc.id, - domainid=cls.account.account.domainid + domainid=cls.account.domainid ) cls.lb_rule.assign(cls.api_client, [cls.vm_1, cls.vm_2]) @@ -328,7 +328,7 @@ class TestVMLifeCycleVPC(cloudstackTestCase): cls.api_client, accountid=cls.account.name, zoneid=cls.zone.id, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, networkid=cls.network_1.id, vpcid=cls.vpc.id ) @@ -516,7 +516,7 @@ class TestVMLifeCycleVPC(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -966,7 +966,7 @@ class TestVMLifeCycleSharedNwVPC(cloudstackTestCase): vpcofferingid=cls.vpc_off.id, zoneid=cls.zone.id, account=cls.account.name, - domainid=cls.account.account.domainid + domainid=cls.account.domainid ) cls.nw_off = NetworkOffering.create( @@ -982,7 +982,7 @@ class TestVMLifeCycleSharedNwVPC(cloudstackTestCase): cls.api_client, cls.services["network"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, networkofferingid=cls.nw_off.id, zoneid=cls.zone.id, gateway='10.1.1.1', @@ -1006,7 +1006,7 @@ class TestVMLifeCycleSharedNwVPC(cloudstackTestCase): cls.api_client, cls.services["network"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, networkofferingid=cls.shared_nw_off.id, zoneid=cls.zone.id, gateway='10.1.2.1', @@ -1017,7 +1017,7 @@ class TestVMLifeCycleSharedNwVPC(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, networkids=[str(cls.network_1.id), str(cls.network_2.id)] @@ -1027,7 +1027,7 @@ class TestVMLifeCycleSharedNwVPC(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, networkids=[str(cls.network_1.id), str(cls.network_2.id)] @@ -1036,7 +1036,7 @@ class TestVMLifeCycleSharedNwVPC(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, networkids=[str(cls.network_1.id), str(cls.network_2.id)] @@ -1045,7 +1045,7 @@ class TestVMLifeCycleSharedNwVPC(cloudstackTestCase): cls.api_client, accountid=cls.account.name, zoneid=cls.zone.id, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, networkid=cls.network_1.id, vpcid=cls.vpc.id ) @@ -1056,7 +1056,7 @@ class TestVMLifeCycleSharedNwVPC(cloudstackTestCase): accountid=cls.account.name, networkid=cls.network_1.id, vpcid=cls.vpc.id, - domainid=cls.account.account.domainid + domainid=cls.account.domainid ) cls.lb_rule.assign(cls.api_client, [cls.vm_1, cls.vm_2, cls.vm_3]) @@ -1064,7 +1064,7 @@ class TestVMLifeCycleSharedNwVPC(cloudstackTestCase): cls.api_client, accountid=cls.account.name, zoneid=cls.zone.id, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, networkid=cls.network_1.id, vpcid=cls.vpc.id ) @@ -1242,7 +1242,7 @@ class TestVMLifeCycleSharedNwVPC(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -1368,7 +1368,7 @@ class TestVMLifeCycleSharedNwVPC(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -1773,7 +1773,7 @@ class TestVMLifeCycleBothIsolated(cloudstackTestCase): vpcofferingid=cls.vpc_off.id, zoneid=cls.zone.id, account=cls.account.name, - domainid=cls.account.account.domainid + domainid=cls.account.domainid ) cls.nw_off = NetworkOffering.create( @@ -1789,7 +1789,7 @@ class TestVMLifeCycleBothIsolated(cloudstackTestCase): cls.api_client, cls.services["network"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, networkofferingid=cls.nw_off.id, zoneid=cls.zone.id, gateway='10.1.1.1', @@ -1809,7 +1809,7 @@ class TestVMLifeCycleBothIsolated(cloudstackTestCase): cls.api_client, cls.services["network"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, networkofferingid=cls.nw_off_no_lb.id, zoneid=cls.zone.id, gateway='10.1.2.1', @@ -1965,7 +1965,7 @@ class TestVMLifeCycleBothIsolated(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(self.network_1.id), str(self.network_2.id)] @@ -1990,7 +1990,7 @@ class TestVMLifeCycleBothIsolated(cloudstackTestCase): routers = Router.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=self.network_1.id, listall=True ) @@ -2033,7 +2033,7 @@ class TestVMLifeCycleBothIsolated(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(self.network_1.id)] ) @@ -2111,7 +2111,7 @@ class TestVMLifeCycleStoppedVPCVR(cloudstackTestCase): vpcofferingid=cls.vpc_off.id, zoneid=cls.zone.id, account=cls.account.name, - domainid=cls.account.account.domainid + domainid=cls.account.domainid ) cls.nw_off = NetworkOffering.create( @@ -2127,7 +2127,7 @@ class TestVMLifeCycleStoppedVPCVR(cloudstackTestCase): cls.api_client, cls.services["network"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, networkofferingid=cls.nw_off.id, zoneid=cls.zone.id, gateway='10.1.1.1', @@ -2146,7 +2146,7 @@ class TestVMLifeCycleStoppedVPCVR(cloudstackTestCase): cls.api_client, cls.services["network"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, networkofferingid=cls.nw_off_no_lb.id, zoneid=cls.zone.id, gateway='10.1.2.1', @@ -2157,7 +2157,7 @@ class TestVMLifeCycleStoppedVPCVR(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, networkids=[str(cls.network_1.id)] ) @@ -2166,7 +2166,7 @@ class TestVMLifeCycleStoppedVPCVR(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, networkids=[str(cls.network_1.id)] ) @@ -2174,7 +2174,7 @@ class TestVMLifeCycleStoppedVPCVR(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, networkids=[str(cls.network_2.id)] ) @@ -2183,7 +2183,7 @@ class TestVMLifeCycleStoppedVPCVR(cloudstackTestCase): cls.api_client, accountid=cls.account.name, zoneid=cls.zone.id, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, networkid=cls.network_1.id, vpcid=cls.vpc.id ) @@ -2194,7 +2194,7 @@ class TestVMLifeCycleStoppedVPCVR(cloudstackTestCase): accountid=cls.account.name, networkid=cls.network_1.id, vpcid=cls.vpc.id, - domainid=cls.account.account.domainid + domainid=cls.account.domainid ) cls.lb_rule.assign(cls.api_client, [cls.vm_1, cls.vm_2]) @@ -2202,7 +2202,7 @@ class TestVMLifeCycleStoppedVPCVR(cloudstackTestCase): cls.api_client, accountid=cls.account.name, zoneid=cls.zone.id, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, networkid=cls.network_1.id, vpcid=cls.vpc.id ) @@ -2405,7 +2405,7 @@ class TestVMLifeCycleStoppedVPCVR(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -2868,7 +2868,7 @@ class TestVMLifeCycleDiffHosts(cloudstackTestCase): vpcofferingid=cls.vpc_off.id, zoneid=cls.zone.id, account=cls.account.name, - domainid=cls.account.account.domainid + domainid=cls.account.domainid ) cls.nw_off = NetworkOffering.create( @@ -2884,7 +2884,7 @@ class TestVMLifeCycleDiffHosts(cloudstackTestCase): cls.api_client, cls.services["network"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, networkofferingid=cls.nw_off.id, zoneid=cls.zone.id, gateway='10.1.1.1', @@ -2903,7 +2903,7 @@ class TestVMLifeCycleDiffHosts(cloudstackTestCase): cls.api_client, cls.services["network"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, networkofferingid=cls.nw_off_no_lb.id, zoneid=cls.zone.id, gateway='10.1.2.1', @@ -2914,7 +2914,7 @@ class TestVMLifeCycleDiffHosts(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering_1.id, networkids=[str(cls.network_1.id)] ) @@ -2923,7 +2923,7 @@ class TestVMLifeCycleDiffHosts(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering_1.id, networkids=[str(cls.network_1.id)] ) @@ -2931,7 +2931,7 @@ class TestVMLifeCycleDiffHosts(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering_2.id, networkids=[str(cls.network_2.id)] ) @@ -2940,7 +2940,7 @@ class TestVMLifeCycleDiffHosts(cloudstackTestCase): cls.api_client, accountid=cls.account.name, zoneid=cls.zone.id, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, networkid=cls.network_1.id, vpcid=cls.vpc.id ) @@ -2951,7 +2951,7 @@ class TestVMLifeCycleDiffHosts(cloudstackTestCase): accountid=cls.account.name, networkid=cls.network_1.id, vpcid=cls.vpc.id, - domainid=cls.account.account.domainid + domainid=cls.account.domainid ) cls.lb_rule.assign(cls.api_client, [cls.vm_1, cls.vm_2]) @@ -2959,7 +2959,7 @@ class TestVMLifeCycleDiffHosts(cloudstackTestCase): cls.api_client, accountid=cls.account.name, zoneid=cls.zone.id, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, networkid=cls.network_1.id, vpcid=cls.vpc.id ) @@ -3057,7 +3057,7 @@ class TestVMLifeCycleDiffHosts(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=self.network_1.id, listall=True ) @@ -3072,7 +3072,7 @@ class TestVMLifeCycleDiffHosts(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=self.network_2.id, listall=True ) @@ -3204,7 +3204,7 @@ class TestVMLifeCycleDiffHosts(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( diff --git a/test/integration/component/test_vpc_vms_deployment.py b/test/integration/component/test_vpc_vms_deployment.py index 506ae348867..c49ef458a40 100644 --- a/test/integration/component/test_vpc_vms_deployment.py +++ b/test/integration/component/test_vpc_vms_deployment.py @@ -320,7 +320,7 @@ class TestVMDeployVPC(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -339,7 +339,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=nw_off.id, zoneid=self.zone.id, gateway='10.1.1.1', @@ -363,7 +363,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=nw_off_no_lb.id, zoneid=self.zone.id, gateway='10.1.2.1', @@ -378,7 +378,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=nw_off_no_lb.id, zoneid=self.zone.id, gateway='10.1.3.1', @@ -392,7 +392,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_1.id)] ) @@ -404,7 +404,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_2.id)] ) @@ -415,7 +415,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_3.id)] ) @@ -425,7 +425,7 @@ class TestVMDeployVPC(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -468,7 +468,7 @@ class TestVMDeployVPC(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, state="Running", listall=True ) @@ -535,7 +535,7 @@ class TestVMDeployVPC(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -554,7 +554,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=nw_off.id, zoneid=self.zone.id, gateway='10.1.1.1', @@ -578,7 +578,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=nw_off_no_lb.id, zoneid=self.zone.id, gateway='10.1.2.1', @@ -593,7 +593,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=nw_off_no_lb.id, zoneid=self.zone.id, gateway='10.1.3.1', @@ -607,7 +607,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_1.id)] ) @@ -619,7 +619,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_2.id)] ) @@ -630,7 +630,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_3.id)] ) @@ -640,7 +640,7 @@ class TestVMDeployVPC(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -720,7 +720,7 @@ class TestVMDeployVPC(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, state="Running", listall=True ) @@ -788,7 +788,7 @@ class TestVMDeployVPC(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -807,7 +807,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=nw_off.id, zoneid=self.zone.id, gateway='10.1.1.1', @@ -831,7 +831,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=nw_off_no_lb.id, zoneid=self.zone.id, gateway='10.1.2.1', @@ -846,7 +846,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=nw_off_no_lb.id, zoneid=self.zone.id, gateway='10.1.3.1', @@ -860,7 +860,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_1.id)] ) @@ -872,7 +872,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_2.id)] ) @@ -883,7 +883,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_3.id)] ) @@ -893,7 +893,7 @@ class TestVMDeployVPC(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -965,7 +965,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=nw_off.id, zoneid=self.zone.id, gateway='10.1.4.1', @@ -978,7 +978,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_4.id)] ) @@ -989,7 +989,7 @@ class TestVMDeployVPC(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, state="Running", listall=True ) @@ -1057,7 +1057,7 @@ class TestVMDeployVPC(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -1076,7 +1076,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=nw_off.id, zoneid=self.zone.id, gateway='10.1.1.1', @@ -1100,7 +1100,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=nw_off_no_lb.id, zoneid=self.zone.id, gateway='10.1.2.1', @@ -1115,7 +1115,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=nw_off_no_lb.id, zoneid=self.zone.id, gateway='10.1.3.1', @@ -1129,7 +1129,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_1.id)] ) @@ -1141,7 +1141,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_2.id)] ) @@ -1152,7 +1152,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_3.id)] ) @@ -1162,7 +1162,7 @@ class TestVMDeployVPC(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -1236,7 +1236,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=nw_off_no_lb.id, zoneid=self.zone.id, gateway='10.1.4.1', @@ -1249,7 +1249,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_4.id)] ) @@ -1283,7 +1283,7 @@ class TestVMDeployVPC(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, state="Running", listall=True ) @@ -1337,7 +1337,7 @@ class TestVMDeployVPC(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -1360,7 +1360,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=nw_off.id, zoneid=self.zone.id, gateway='10.1.0.1', @@ -1399,7 +1399,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=nw_off_no_lb.id, zoneid=self.zone.id, gateway=gateway, @@ -1417,7 +1417,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=nw_off_no_lb.id, zoneid=self.zone.id, gateway=gateway, @@ -1436,7 +1436,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=nw_off.id, zoneid=self.zone.id, gateway=gateway, @@ -1453,7 +1453,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network.id)] ) @@ -1512,7 +1512,7 @@ class TestVMDeployVPC(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -1531,7 +1531,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=nw_off.id, zoneid=self.zone.id, gateway='10.1.1.1', @@ -1555,7 +1555,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=nw_off_no_lb.id, zoneid=self.zone.id, gateway='10.1.2.1', @@ -1569,7 +1569,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_1.id)] ) @@ -1578,7 +1578,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_1.id)] ) @@ -1590,7 +1590,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_2.id)] ) @@ -1599,7 +1599,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_2.id)] ) @@ -1609,7 +1609,7 @@ class TestVMDeployVPC(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -1650,7 +1650,7 @@ class TestVMDeployVPC(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network_1.id, listall=True ) @@ -1685,7 +1685,7 @@ class TestVMDeployVPC(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network_2.id, listall=True ) @@ -1704,7 +1704,7 @@ class TestVMDeployVPC(cloudstackTestCase): routers = Router.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -1777,7 +1777,7 @@ class TestVMDeployVPC(cloudstackTestCase): vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.validate_vpc_network(vpc) @@ -1796,7 +1796,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=nw_off.id, zoneid=self.zone.id, gateway='10.1.1.1', @@ -1820,7 +1820,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["network"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkofferingid=nw_off_no_lb.id, zoneid=self.zone.id, gateway='10.1.2.1', @@ -1834,7 +1834,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_1.id)] ) @@ -1843,7 +1843,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_1.id)] ) @@ -1855,7 +1855,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_2.id)] ) @@ -1864,7 +1864,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], accountid=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(network_2.id)] ) @@ -1874,7 +1874,7 @@ class TestVMDeployVPC(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -1895,7 +1895,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network_1.id, vpcid=vpc.id ) @@ -1927,7 +1927,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network_1.id, vpcid=vpc.id ) @@ -1956,7 +1956,7 @@ class TestVMDeployVPC(cloudstackTestCase): listall=True, isstaticnat=True, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.assertEqual( isinstance(public_ips, list), @@ -1974,7 +1974,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network_2.id, vpcid=vpc.id ) @@ -1993,7 +1993,7 @@ class TestVMDeployVPC(cloudstackTestCase): accountid=self.account.name, networkid=network_2.id, vpcid=vpc.id, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.debug("Adding virtual machines %s and %s to LB rule" % ( @@ -2066,7 +2066,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network_2.id, vpcid=vpc.id ) @@ -2098,7 +2098,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network_2.id, vpcid=vpc.id ) @@ -2127,7 +2127,7 @@ class TestVMDeployVPC(cloudstackTestCase): listall=True, isstaticnat=True, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.assertEqual( isinstance(public_ips, list), @@ -2145,7 +2145,7 @@ class TestVMDeployVPC(cloudstackTestCase): self.apiclient, accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network_2.id, vpcid=vpc.id ) @@ -2164,7 +2164,7 @@ class TestVMDeployVPC(cloudstackTestCase): accountid=self.account.name, networkid=network_2.id, vpcid=vpc.id, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.debug("Adding virtual machines %s and %s to LB rule" % ( @@ -2339,7 +2339,7 @@ class TestVMDeployVPC(cloudstackTestCase): vms = VirtualMachine.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=network_1.id, listall=True ) @@ -2447,7 +2447,7 @@ class TestVMDeployVPC(cloudstackTestCase): networks = Network.list( self.apiclient, account=self.account.name, - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.assertEqual( networks, diff --git a/test/integration/component/test_vpn_users.py b/test/integration/component/test_vpn_users.py index 8f08fa09c38..fe020d0f555 100644 --- a/test/integration/component/test_vpn_users.py +++ b/test/integration/component/test_vpn_users.py @@ -396,7 +396,7 @@ class TestVPNUsers(cloudstackTestCase): DomainName=self.account.domain) self.debug("Adding new user to VPN as a global admin: %s" % - admin.account.name) + admin.name) try: self.create_VPN_Users(api_client=api_client) except Exception as e: @@ -438,7 +438,7 @@ class TestVPNUsers(cloudstackTestCase): DomainName=self.account.domain) self.debug("Adding new user to VPN as a domain admin: %s" % - admin.account.name) + admin.name) try: self.create_VPN_Users(api_client=api_client) except Exception as e: From cede6c11ab5e5ee7838dd84b0914a640267c7769 Mon Sep 17 00:00:00 2001 From: Dave Cahill Date: Mon, 20 May 2013 17:00:12 +0900 Subject: [PATCH 25/51] Adding package declaration to MidoNetElementTest --- .../test/com/cloud/network/element/MidoNetElementTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/network-elements/midonet/test/com/cloud/network/element/MidoNetElementTest.java b/plugins/network-elements/midonet/test/com/cloud/network/element/MidoNetElementTest.java index baf99b908d4..a7d96b0c310 100644 --- a/plugins/network-elements/midonet/test/com/cloud/network/element/MidoNetElementTest.java +++ b/plugins/network-elements/midonet/test/com/cloud/network/element/MidoNetElementTest.java @@ -17,7 +17,8 @@ * under the License. */ -import com.cloud.network.element.MidoNetElement; +package com.cloud.network.element; + import com.cloud.user.AccountVO; import com.cloud.user.dao.AccountDao; import junit.framework.TestCase; From 0365d555cf50ad551427ebe2c5634b807bd6a9c0 Mon Sep 17 00:00:00 2001 From: Chip Childers Date: Mon, 20 May 2013 19:17:33 +0100 Subject: [PATCH 26/51] Adding a name to the framework/jobs/pom.xml file Signed-off-by: Chip Childers --- framework/jobs/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/framework/jobs/pom.xml b/framework/jobs/pom.xml index 5ae63af77ad..cf1fdd585a6 100644 --- a/framework/jobs/pom.xml +++ b/framework/jobs/pom.xml @@ -19,6 +19,7 @@ 4.0.0 cloud-framework-jobs + Apache CloudStack Framework - Jobs org.apache.cloudstack cloudstack-framework From cf6045f1aa37674f0225144ae0a1f662f955f153 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Mon, 20 May 2013 13:40:37 -0700 Subject: [PATCH 27/51] CLOUDSTACK-747: internalLb in VPC - UI - create network offering - system offering dropdown is for router only. Change its variable name to be more intuitive. --- ui/scripts/configuration.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ui/scripts/configuration.js b/ui/scripts/configuration.js index 9a08c4c56b1..e3421a380ef 100644 --- a/ui/scripts/configuration.js +++ b/ui/scripts/configuration.js @@ -1122,7 +1122,7 @@ title: 'label.add.network.offering', preFilter: function(args) { var $availability = args.$form.find('.form-item[rel=availability]'); - var $serviceOfferingId = args.$form.find('.form-item[rel=serviceOfferingId]'); + var $systemOfferingForRouter = args.$form.find('.form-item[rel=systemOfferingForRouter]'); var $conservemode = args.$form.find('.form-item[rel=conservemode]'); var $serviceSourceNatRedundantRouterCapabilityCheckbox = args.$form.find('.form-item[rel="service.SourceNat.redundantRouterCapabilityCheckbox"]'); var hasAdvancedZones = false; @@ -1185,10 +1185,10 @@ } }); if(havingVirtualRouterForAtLeastOneService == true) { - $serviceOfferingId.css('display', 'inline-block'); + $systemOfferingForRouter.css('display', 'inline-block'); } else { - $serviceOfferingId.hide(); + $systemOfferingForRouter.hide(); } @@ -1569,8 +1569,8 @@ }, //show or hide upon checked services and selected providers above (begin) - serviceOfferingId: { - label: 'label.system.offering', + systemOfferingForRouter: { + label: 'System Offering for Router', docID: 'helpNetworkOfferingSystemOffering', select: function(args) { $.ajax({ @@ -1829,8 +1829,8 @@ if(args.$form.find('.form-item[rel=availability]').css("display") == "none") inputData['availability'] = 'Optional'; - if(args.$form.find('.form-item[rel=serviceOfferingId]').css("display") == "none") - delete inputData.serviceOfferingId; + if(args.$form.find('.form-item[rel=systemOfferingForRouter]').css("display") == "none") + delete inputData.systemOfferingForRouter; inputData['traffictype'] = 'GUEST'; //traffic type dropdown has been removed since it has only one option ('Guest'). Hardcode traffic type value here. From 7260e8d83f07d90b48c34adaeb227de265019487 Mon Sep 17 00:00:00 2001 From: Hiroaki Kawai Date: Fri, 3 May 2013 10:43:20 -0700 Subject: [PATCH 28/51] CLOUDSTACK-1638: Introduce NetworkMigrationResponder The location of the virtual machine is provided by DeployDestination, which will be passed in NetworkGuru#reserve and NetworkElement#prepare. During the virtual machine migration, it actually changes DeployDestination and it looks like that it will tell that event to network components as it has NetworkManager#prepareNicForMigration. The problem is that althogh the interface has that method, NetworkManagerImpl does not tell the DeployDestination changes to network components. So IMHO, we need to add calls of NetworkGuru#reserve and NetworkElement#prepare in NetworkManagerImpl#prepareNicForMigration . And then, we also need to add calls NetworkGuru#release and NetworkElement#release after the migration, otherwise the network resources that plugin reserved will be kept even when the vm leaves off. (Sheng Yang: rebase code, add license header) Signed-off-by: Sheng Yang --- .../network/NetworkMigrationResponder.java | 70 ++++++++++++++++++ .../src/com/cloud/network/NetworkManager.java | 29 +++++++- .../com/cloud/network/NetworkManagerImpl.java | 72 ++++++++++++++++++- .../cloud/vm/VirtualMachineManagerImpl.java | 11 +++ .../cloud/network/MockNetworkManagerImpl.java | 29 ++++++-- .../com/cloud/vpc/MockNetworkManagerImpl.java | 48 +++++++++---- 6 files changed, 239 insertions(+), 20 deletions(-) create mode 100644 api/src/com/cloud/network/NetworkMigrationResponder.java diff --git a/api/src/com/cloud/network/NetworkMigrationResponder.java b/api/src/com/cloud/network/NetworkMigrationResponder.java new file mode 100644 index 00000000000..6283cc54128 --- /dev/null +++ b/api/src/com/cloud/network/NetworkMigrationResponder.java @@ -0,0 +1,70 @@ +// 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; + +import com.cloud.deploy.DeployDestination; +import com.cloud.vm.NicProfile; +import com.cloud.vm.ReservationContext; +import com.cloud.vm.VirtualMachine; +import com.cloud.vm.VirtualMachineProfile; + +/** + * NetworkGuru and NetworkElements that implement this interface + * will be called during Virtual Machine migration. + */ +public interface NetworkMigrationResponder { + /** + * Prepare for migration. + * + * This method will be called per nic before the vm migration. + * @param nic + * @param network + * @param vm + * @param dest + * @param context + * @return true when operation was successful. + */ + public boolean prepareMigration(NicProfile nic, Network network, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context); + + /** + * Cancel for migration preparation. + * + * This method will be called per nic when the entire vm migration + * process failed and need to release the resouces that was + * allocated at the migration preparation. + * @param nic destination nic + * @param network destination network + * @param vm destination vm profile + * @param src The context nic migrates from. + * @param dst The context nic migrates to. + */ + public void rollbackMigration(NicProfile nic, Network network, VirtualMachineProfile vm, ReservationContext src, ReservationContext dst); + + /** + * Commit the migration resource. + * + * This method will be called per nic when the entire vm migration + * process was successful. This is useful to release the resource of + * source deployment where vm has left. + * @param nic source nic + * @param network source network + * @param vm source vm profile + * @param src the context nic migrates from. + * @param dst the context nic migrates to. + */ + public void commitMigration(NicProfile nic, Network network, VirtualMachineProfile vm, ReservationContext src, ReservationContext dst); +} diff --git a/server/src/com/cloud/network/NetworkManager.java b/server/src/com/cloud/network/NetworkManager.java index 1e4fb8437ce..05bc26ee5c2 100755 --- a/server/src/com/cloud/network/NetworkManager.java +++ b/server/src/com/cloud/network/NetworkManager.java @@ -123,7 +123,34 @@ public interface NetworkManager { Pair implementNetwork(long networkId, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException; - void prepareNicForMigration(VirtualMachineProfile vm, DeployDestination dest); + /** + * prepares vm nic change for migration + * + * This method will be called in migration transaction before the vm migration. + * @param vm + * @param dest + */ + void prepareNicForMigration(VirtualMachineProfile vm, DeployDestination dest); + + /** + * commit vm nic change for migration + * + * This method will be called in migration transaction after the successful + * vm migration. + * @param src + * @param dst + */ + void commitNicForMigration(VirtualMachineProfile src, VirtualMachineProfile dst); + + /** + * rollback vm nic change for migration + * + * This method will be called in migaration transaction after vm migration + * failure. + * @param src + * @param dst + */ + void rollbackNicForMigration(VirtualMachineProfile src, VirtualMachineProfile dst); boolean shutdownNetwork(long networkId, ReservationContext context, boolean cleanupElements); diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index b3df0da8ebe..0f43b87685e 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -2000,8 +2000,9 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L } @Override - public void prepareNicForMigration(VirtualMachineProfile vm, DeployDestination dest) { + public void prepareNicForMigration(VirtualMachineProfile vm, DeployDestination dest) { List nics = _nicDao.listByVmId(vm.getId()); + ReservationContext context = new ReservationContextImpl(UUID.randomUUID().toString(), null, null); for (NicVO nic : nics) { NetworkVO network = _networksDao.findById(nic.getNetworkId()); Integer networkRate = _networkModel.getNetworkRate(network.getId(), vm.getId()); @@ -2009,11 +2010,80 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L NetworkGuru guru = AdapterBase.getAdapterByName(_networkGurus, network.getGuruName()); NicProfile profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), networkRate, _networkModel.isSecurityGroupSupportedInNetwork(network), _networkModel.getNetworkTag(vm.getHypervisorType(), network)); + if(guru instanceof NetworkMigrationResponder){ + if(!((NetworkMigrationResponder) guru).prepareMigration(profile, network, vm, dest, context)){ + s_logger.error("NetworkGuru "+guru+" prepareForMigration failed."); // XXX: Transaction error + } + } + for (NetworkElement element : _networkElements) { + if(element instanceof NetworkMigrationResponder){ + if(!((NetworkMigrationResponder) element).prepareMigration(profile, network, vm, dest, context)){ + s_logger.error("NetworkElement "+element+" prepareForMigration failed."); // XXX: Transaction error + } + } + } guru.updateNicProfile(profile, network); vm.addNic(profile); } } + private NicProfile findNicProfileById(VirtualMachineProfile vm, long id){ + for(NicProfile nic: vm.getNics()){ + if(nic.getId() == id){ + return nic; + } + } + return null; + } + + @Override + public void commitNicForMigration( + VirtualMachineProfile src, + VirtualMachineProfile dst) { + for(NicProfile nicSrc: src.getNics()){ + NetworkVO network = _networksDao.findById(nicSrc.getNetworkId()); + NetworkGuru guru = AdapterBase.getAdapterByName(_networkGurus, network.getGuruName()); + NicProfile nicDst = findNicProfileById(dst, nicSrc.getId()); + ReservationContext src_context = new ReservationContextImpl(nicSrc.getReservationId(), null, null); + ReservationContext dst_context = new ReservationContextImpl(nicDst.getReservationId(), null, null); + + if(guru instanceof NetworkMigrationResponder){ + ((NetworkMigrationResponder) guru).commitMigration(nicSrc, network, src, src_context, dst_context); + } + for (NetworkElement element : _networkElements) { + if(element instanceof NetworkMigrationResponder){ + ((NetworkMigrationResponder) element).commitMigration(nicSrc, network, src, src_context, dst_context); + } + } + // update the reservation id + NicVO nicVo = _nicDao.findById(nicDst.getId()); + nicVo.setReservationId(nicDst.getReservationId()); + _nicDao.persist(nicVo); + } + } + + @Override + public void rollbackNicForMigration( + VirtualMachineProfile src, + VirtualMachineProfile dst) { + for(NicProfile nicDst: dst.getNics()){ + NetworkVO network = _networksDao.findById(nicDst.getNetworkId()); + NetworkGuru guru = AdapterBase.getAdapterByName(_networkGurus, network.getGuruName()); + NicProfile nicSrc = findNicProfileById(src, nicDst.getId()); + ReservationContext src_context = new ReservationContextImpl(nicSrc.getReservationId(), null, null); + ReservationContext dst_context = new ReservationContextImpl(nicDst.getReservationId(), null, null); + + if(guru instanceof NetworkMigrationResponder){ + ((NetworkMigrationResponder) guru).rollbackMigration(nicDst, network, dst, src_context, dst_context); + } + for (NetworkElement element : _networkElements) { + if(element instanceof NetworkMigrationResponder){ + ((NetworkMigrationResponder) element).rollbackMigration(nicDst, network, dst, src_context, dst_context); + } + } + } + } + @Override @DB public void release(VirtualMachineProfile vmProfile, boolean forced) throws diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java index 58d95ab81a1..f4875377f93 100755 --- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java @@ -1414,6 +1414,11 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac alertType = AlertManager.ALERT_TYPE_CONSOLE_PROXY_MIGRATE; } + VirtualMachineProfile vmSrc = new VirtualMachineProfileImpl(vm); + for(NicProfile nic: _networkMgr.getNicProfiles(vm)){ + vmSrc.addNic(nic); + } + VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm); _networkMgr.prepareNicForMigration(profile, dest); this.volumeMgr.prepareForMigration(profile, dest); @@ -1439,6 +1444,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac throw new AgentUnavailableException("Operation timed out", dstHostId); } finally { if (pfma == null) { + _networkMgr.rollbackNicForMigration(vmSrc, profile); work.setStep(Step.Done); _workDao.update(work.getId(), work); } @@ -1447,10 +1453,12 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac vm.setLastHostId(srcHostId); try { if (vm == null || vm.getHostId() == null || vm.getHostId() != srcHostId || !changeState(vm, Event.MigrationRequested, dstHostId, work, Step.Migrating)) { + _networkMgr.rollbackNicForMigration(vmSrc, profile); s_logger.info("Migration cancelled because state has changed: " + vm); throw new ConcurrentOperationException("Migration cancelled because state has changed: " + vm); } } catch (NoTransitionException e1) { + _networkMgr.rollbackNicForMigration(vmSrc, profile); s_logger.info("Migration cancelled because " + e1.getMessage()); throw new ConcurrentOperationException("Migration cancelled because " + e1.getMessage()); } @@ -1502,6 +1510,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac } finally { if (!migrated) { s_logger.info("Migration was unsuccessful. Cleaning up: " + vm); + _networkMgr.rollbackNicForMigration(vmSrc, profile); _alertMgr.sendAlert(alertType, fromHost.getDataCenterId(), fromHost.getPodId(), "Unable to migrate vm " + vm.getInstanceName() + " from host " + fromHost.getName() + " in zone " + dest.getDataCenter().getName() + " and pod " + dest.getPod().getName(), "Migrate Command failed. Please check logs."); @@ -1516,6 +1525,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac } catch (NoTransitionException e) { s_logger.warn(e.getMessage()); } + }else{ + _networkMgr.commitNicForMigration(vmSrc, profile); } work.setStep(Step.Done); diff --git a/server/test/com/cloud/network/MockNetworkManagerImpl.java b/server/test/com/cloud/network/MockNetworkManagerImpl.java index 1ac014d502a..e5d34fbacc7 100755 --- a/server/test/com/cloud/network/MockNetworkManagerImpl.java +++ b/server/test/com/cloud/network/MockNetworkManagerImpl.java @@ -277,12 +277,6 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkManage } - @Override - public void prepareNicForMigration(VirtualMachineProfile vm, DeployDestination dest) { - // TODO Auto-generated method stub - - } - @Override public boolean destroyNetwork(long networkId, ReservationContext context) { // TODO Auto-generated method stub @@ -966,4 +960,27 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkManage public PublicIp assignPublicIpAddressFromVlans(long dcId, Long podId, Account owner, VlanType type, List vlanDbIds, Long networkId, String requestedIp, boolean isSystem) throws InsufficientAddressCapacityException { return null; //To change body of implemented methods use File | Settings | File Templates. } + + @Override + public void prepareNicForMigration( + VirtualMachineProfile vm, + DeployDestination dest) { + // TODO Auto-generated method stub + + } + + @Override + public void commitNicForMigration( + VirtualMachineProfile src, + VirtualMachineProfile dst) { + // TODO Auto-generated method stub + + } + + @Override + public void rollbackNicForMigration( + VirtualMachineProfile src, + VirtualMachineProfile dst) { + // TODO Auto-generated method stub + } } diff --git a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java index 62599b8d504..7129273a50c 100644 --- a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java +++ b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java @@ -845,18 +845,6 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkManage - /* (non-Javadoc) - * @see com.cloud.network.NetworkManager#prepareNicForMigration(com.cloud.vm.VirtualMachineProfile, com.cloud.deploy.DeployDestination) - */ - @Override - public void prepareNicForMigration(VirtualMachineProfile vm, DeployDestination dest) { - // TODO Auto-generated method stub - - } - - - - /* (non-Javadoc) * @see com.cloud.network.NetworkManager#shutdownNetwork(long, com.cloud.vm.ReservationContext, boolean) @@ -1471,4 +1459,40 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkManage } + + + + @Override + public void prepareNicForMigration( + VirtualMachineProfile vm, + DeployDestination dest) { + // TODO Auto-generated method stub + + } + + + + + + @Override + public void commitNicForMigration( + VirtualMachineProfile src, + VirtualMachineProfile dst) { + // TODO Auto-generated method stub + + } + + + + + + @Override + public void rollbackNicForMigration( + VirtualMachineProfile src, + VirtualMachineProfile dst) { + // TODO Auto-generated method stub + + } + + } From eb7c3214260371b0551040831ad7404f5880fc8d Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 3 May 2013 11:02:44 -0700 Subject: [PATCH 29/51] PVLAN: CLOUDSTACK-2401: VM Migration support --- .../network/element/VirtualRouterElement.java | 70 ++++++++++++++++++- .../VirtualNetworkApplianceManager.java | 2 +- .../VirtualNetworkApplianceManagerImpl.java | 32 ++++++--- server/src/com/cloud/vm/UserVmManager.java | 1 + .../src/com/cloud/vm/UserVmManagerImpl.java | 13 ++-- .../com/cloud/vm/MockUserVmManagerImpl.java | 6 ++ ...MockVpcVirtualNetworkApplianceManager.java | 6 ++ 7 files changed, 110 insertions(+), 20 deletions(-) diff --git a/server/src/com/cloud/network/element/VirtualRouterElement.java b/server/src/com/cloud/network/element/VirtualRouterElement.java index 8021e6f0074..19166787e9b 100755 --- a/server/src/com/cloud/network/element/VirtualRouterElement.java +++ b/server/src/com/cloud/network/element/VirtualRouterElement.java @@ -47,7 +47,9 @@ import com.cloud.network.Network; import com.cloud.network.Network.Capability; import com.cloud.network.Network.Provider; import com.cloud.network.Network.Service; +import com.cloud.network.NetworkMigrationResponder; import com.cloud.network.NetworkModel; +import com.cloud.network.Networks; import com.cloud.network.Networks.BroadcastDomainType; import com.cloud.network.Networks.TrafficType; import com.cloud.network.PhysicalNetworkServiceProvider; @@ -85,9 +87,13 @@ import com.cloud.utils.db.SearchCriteriaService; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.vm.DomainRouterVO; import com.cloud.vm.NicProfile; +import com.cloud.vm.NicVO; import com.cloud.vm.ReservationContext; +import com.cloud.vm.UserVmManager; +import com.cloud.vm.UserVmVO; import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachine.State; +import com.cloud.vm.VirtualMachine.Type; import com.cloud.vm.VirtualMachineProfile; import com.cloud.vm.dao.DomainRouterDao; import com.cloud.vm.dao.UserVmDao; @@ -108,10 +114,12 @@ import java.util.Set; @Local(value = {NetworkElement.class, FirewallServiceProvider.class, DhcpServiceProvider.class, UserDataServiceProvider.class, StaticNatServiceProvider.class, LoadBalancingServiceProvider.class, - PortForwardingServiceProvider.class, IpDeployer.class, RemoteAccessVPNServiceProvider.class} ) + PortForwardingServiceProvider.class, IpDeployer.class, + RemoteAccessVPNServiceProvider.class, NetworkMigrationResponder.class} ) public class VirtualRouterElement extends AdapterBase implements VirtualRouterElementService, DhcpServiceProvider, UserDataServiceProvider, SourceNatServiceProvider, StaticNatServiceProvider, FirewallServiceProvider, - LoadBalancingServiceProvider, PortForwardingServiceProvider, RemoteAccessVPNServiceProvider, IpDeployer { + LoadBalancingServiceProvider, PortForwardingServiceProvider, RemoteAccessVPNServiceProvider, IpDeployer, + NetworkMigrationResponder { private static final Logger s_logger = Logger.getLogger(VirtualRouterElement.class); protected static final Map> capabilities = setCapabilities(); @@ -130,6 +138,8 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl ConfigurationManager _configMgr; @Inject RulesManager _rulesMgr; + @Inject + UserVmManager _userVmMgr; @Inject UserVmDao _userVmDao; @@ -1024,7 +1034,6 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl // TODO Auto-generated method stub return null; } - private boolean canHandleLbRules(List rules) { Map lbCaps = this.getCapabilities().get(Service.Lb); if (!lbCaps.isEmpty()) { @@ -1039,5 +1048,60 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl } } return true; + } + + @Override + public boolean prepareMigration(NicProfile nic, Network network, + VirtualMachineProfile vm, + DeployDestination dest, ReservationContext context) { + if (nic.getBroadcastType() != Networks.BroadcastDomainType.Pvlan) { + return true; + } + if (vm.getType() == Type.DomainRouter) { + assert vm instanceof DomainRouterVO; + DomainRouterVO router = (DomainRouterVO)vm.getVirtualMachine(); + _routerMgr.setupDhcpForPvlan(false, router, router.getHostId(), nic); + } else if (vm.getType() == Type.User){ + assert vm instanceof UserVmVO; + UserVmVO userVm = (UserVmVO)vm.getVirtualMachine(); + _userVmMgr.setupVmForPvlan(false, userVm.getHostId(), nic); + } + return true; + } + + @Override + public void rollbackMigration(NicProfile nic, Network network, + VirtualMachineProfile vm, + ReservationContext src, ReservationContext dst) { + if (nic.getBroadcastType() != Networks.BroadcastDomainType.Pvlan) { + return; + } + if (vm.getType() == Type.DomainRouter) { + assert vm instanceof DomainRouterVO; + DomainRouterVO router = (DomainRouterVO)vm.getVirtualMachine(); + _routerMgr.setupDhcpForPvlan(true, router, router.getHostId(), nic); + } else if (vm.getType() == Type.User){ + assert vm instanceof UserVmVO; + UserVmVO userVm = (UserVmVO)vm.getVirtualMachine(); + _userVmMgr.setupVmForPvlan(true, userVm.getHostId(), nic); + } + } + + @Override + public void commitMigration(NicProfile nic, Network network, + VirtualMachineProfile vm, + ReservationContext src, ReservationContext dst) { + if (nic.getBroadcastType() != Networks.BroadcastDomainType.Pvlan) { + return; + } + if (vm.getType() == Type.DomainRouter) { + assert vm instanceof DomainRouterVO; + DomainRouterVO router = (DomainRouterVO)vm.getVirtualMachine(); + _routerMgr.setupDhcpForPvlan(true, router, router.getHostId(), nic); + } else if (vm.getType() == Type.User){ + assert vm instanceof UserVmVO; + UserVmVO userVm = (UserVmVO)vm.getVirtualMachine(); + _userVmMgr.setupVmForPvlan(true, userVm.getHostId(), nic); + } } } diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java index 9852c47dc85..72fddf4f87d 100644 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java @@ -33,7 +33,6 @@ import com.cloud.user.User; import com.cloud.uservm.UserVm; import com.cloud.utils.component.Manager; import com.cloud.vm.DomainRouterVO; -import com.cloud.vm.Nic; import com.cloud.vm.NicProfile; import com.cloud.vm.VirtualMachineProfile; @@ -113,4 +112,5 @@ public interface VirtualNetworkApplianceManager extends Manager, VirtualNetworkA boolean removeDhcpSupportForSubnet(Network network, List routers) throws ResourceUnavailableException; + boolean setupDhcpForPvlan(boolean add, DomainRouterVO router, Long hostId, NicProfile nic); } diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index 50ae4c16fb6..64e412ad1df 100755 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -2223,8 +2223,9 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V return dhcpRange; } - private boolean setupDhcpForPvlan(boolean add, DomainRouterVO router, Nic nic) { - if (!nic.getBroadcastUri().getScheme().equals("pvlan")) { + @Override + public boolean setupDhcpForPvlan(boolean add, DomainRouterVO router, Long hostId, NicProfile nic) { + if (!nic.getBroadCastUri().getScheme().equals("pvlan")) { return false; } String op = "add"; @@ -2233,15 +2234,22 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V } Network network = _networkDao.findById(nic.getNetworkId()); String networkTag = _networkModel.getNetworkTag(router.getHypervisorType(), network); - PvlanSetupCommand cmd = PvlanSetupCommand.createDhcpSetup(op, nic.getBroadcastUri(), networkTag, router.getInstanceName(), nic.getMacAddress(), nic.getIp4Address()); - Commands cmds = new Commands(cmd); + PvlanSetupCommand cmd = PvlanSetupCommand.createDhcpSetup(op, nic.getBroadCastUri(), networkTag, router.getInstanceName(), nic.getMacAddress(), nic.getIp4Address()); // In fact we send command to the host of router, we're not programming router but the host - try { - sendCommandsToRouter(router, cmds); - } catch (AgentUnavailableException e) { + Answer answer = null; + try { + answer = _agentMgr.send(hostId, cmd); + } catch (OperationTimedoutException e) { + s_logger.warn("Timed Out", e); + return false; + } catch (AgentUnavailableException e) { s_logger.warn("Agent Unavailable ", e); - return false; - } + return false; + } + + if (answer == null || !answer.getResult()) { + return false; + } return true; } @@ -2563,7 +2571,8 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V if (network.getTrafficType() == TrafficType.Guest) { guestNetworks.add(network); if (nic.getBroadcastUri().getScheme().equals("pvlan")) { - result = setupDhcpForPvlan(true, router, nic); + NicProfile nicProfile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), 0, false, "pvlan-nic"); + result = setupDhcpForPvlan(true, router, router.getHostId(), nicProfile); } } } @@ -2601,7 +2610,8 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V for (Nic nic : routerNics) { Network network = _networkModel.getNetwork(nic.getNetworkId()); if (network.getTrafficType() == TrafficType.Guest && nic.getBroadcastUri().getScheme().equals("pvlan")) { - setupDhcpForPvlan(false, domR, nic); + NicProfile nicProfile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), 0, false, "pvlan-nic"); + setupDhcpForPvlan(false, domR, domR.getHostId(), nicProfile); } } diff --git a/server/src/com/cloud/vm/UserVmManager.java b/server/src/com/cloud/vm/UserVmManager.java index 0f8e36804bb..4dcfb73e2a1 100755 --- a/server/src/com/cloud/vm/UserVmManager.java +++ b/server/src/com/cloud/vm/UserVmManager.java @@ -94,4 +94,5 @@ public interface UserVmManager extends VirtualMachineGuru, UserVmServi boolean upgradeVirtualMachine(Long id, Long serviceOfferingId) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException; + boolean setupVmForPvlan(boolean add, Long hostId, NicProfile nic); } diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 86150a2ab9c..71b4e3fafb7 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -2821,8 +2821,9 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use return true; } - private boolean setupVmForPvlan(boolean add, Long hostId, NicVO nic) { - if (!nic.getBroadcastUri().getScheme().equals("pvlan")) { + @Override + public boolean setupVmForPvlan(boolean add, Long hostId, NicProfile nic) { + if (!nic.getBroadCastUri().getScheme().equals("pvlan")) { return false; } String op = "add"; @@ -2833,7 +2834,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use Network network = _networkDao.findById(nic.getNetworkId()); Host host = _hostDao.findById(hostId); String networkTag = _networkModel.getNetworkTag(host.getHypervisorType(), network); - PvlanSetupCommand cmd = PvlanSetupCommand.createVmSetup(op, nic.getBroadcastUri(), networkTag, nic.getMacAddress()); + PvlanSetupCommand cmd = PvlanSetupCommand.createVmSetup(op, nic.getBroadCastUri(), networkTag, nic.getMacAddress()); Answer answer = null; try { answer = _agentMgr.send(hostId, cmd); @@ -2916,7 +2917,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use // In vmware, we will be effecting pvlan settings in portgroups in StartCommand. if (profile.getHypervisorType() != HypervisorType.VMware) { if (nic.getBroadcastUri().getScheme().equals("pvlan")) { - if (!setupVmForPvlan(true, hostId, nic)) { + NicProfile nicProfile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), 0, false, "pvlan-nic"); + if (!setupVmForPvlan(true, hostId, nicProfile)) { return false; } } @@ -3058,7 +3060,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use NetworkVO network = _networkDao.findById(nic.getNetworkId()); if (network.getTrafficType() == TrafficType.Guest) { if (nic.getBroadcastUri().getScheme().equals("pvlan")) { - setupVmForPvlan(false, vm.getHostId(), nic); + NicProfile nicProfile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), 0, false, "pvlan-nic"); + setupVmForPvlan(false, vm.getHostId(), nicProfile); } } } diff --git a/server/test/com/cloud/vm/MockUserVmManagerImpl.java b/server/test/com/cloud/vm/MockUserVmManagerImpl.java index 50a90f200c9..448a5dd9a21 100644 --- a/server/test/com/cloud/vm/MockUserVmManagerImpl.java +++ b/server/test/com/cloud/vm/MockUserVmManagerImpl.java @@ -455,4 +455,10 @@ public class MockUserVmManagerImpl extends ManagerBase implements UserVmManager, // TODO Auto-generated method stub return null; } + + @Override + public boolean setupVmForPvlan(boolean add, Long hostId, NicProfile nic) { + // TODO Auto-generated method stub + return false; + } } diff --git a/server/test/com/cloud/vpc/MockVpcVirtualNetworkApplianceManager.java b/server/test/com/cloud/vpc/MockVpcVirtualNetworkApplianceManager.java index 8d502112e8d..f325c4af077 100644 --- a/server/test/com/cloud/vpc/MockVpcVirtualNetworkApplianceManager.java +++ b/server/test/com/cloud/vpc/MockVpcVirtualNetworkApplianceManager.java @@ -420,4 +420,10 @@ VpcVirtualNetworkApplianceService { return null; } + @Override + public boolean setupDhcpForPvlan(boolean add, DomainRouterVO router, Long hostId, + NicProfile nic) { + // TODO Auto-generated method stub + return false; + } } From 503392119d515a81742e9c36d3f285afe2a960fb Mon Sep 17 00:00:00 2001 From: Likitha Shetty Date: Tue, 21 May 2013 11:19:02 +0530 Subject: [PATCH 30/51] CLOUDSTACK-2599. Fix EC2 Rest to support tag related EC2 API's - CreateTags/DeleteTags/DescribeTags --- .../cloud/bridge/service/EC2RestServlet.java | 91 +++++++++++ .../bridge/service/EC2SoapServiceImpl.java | 143 ++++++++++-------- 2 files changed, 172 insertions(+), 62 deletions(-) diff --git a/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java b/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java index 6dd7a8cbb75..6b634e86d9d 100644 --- a/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java +++ b/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java @@ -35,8 +35,11 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.Enumeration; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Properties; +import java.util.Set; import java.util.UUID; import javax.inject.Inject; @@ -68,10 +71,12 @@ import com.amazon.ec2.CreateImageResponse; import com.amazon.ec2.CreateKeyPairResponse; import com.amazon.ec2.CreateSecurityGroupResponse; import com.amazon.ec2.CreateSnapshotResponse; +import com.amazon.ec2.CreateTagsResponse; import com.amazon.ec2.CreateVolumeResponse; import com.amazon.ec2.DeleteKeyPairResponse; import com.amazon.ec2.DeleteSecurityGroupResponse; import com.amazon.ec2.DeleteSnapshotResponse; +import com.amazon.ec2.DeleteTagsResponse; import com.amazon.ec2.DeleteVolumeResponse; import com.amazon.ec2.DeregisterImageResponse; import com.amazon.ec2.DescribeAvailabilityZonesResponse; @@ -82,6 +87,7 @@ import com.amazon.ec2.DescribeInstancesResponse; import com.amazon.ec2.DescribeKeyPairsResponse; import com.amazon.ec2.DescribeSecurityGroupsResponse; import com.amazon.ec2.DescribeSnapshotsResponse; +import com.amazon.ec2.DescribeTagsResponse; import com.amazon.ec2.DescribeVolumesResponse; import com.amazon.ec2.DetachVolumeResponse; import com.amazon.ec2.DisassociateAddressResponse; @@ -122,6 +128,7 @@ import com.cloud.bridge.service.core.ec2.EC2DescribeInstances; import com.cloud.bridge.service.core.ec2.EC2DescribeKeyPairs; import com.cloud.bridge.service.core.ec2.EC2DescribeSecurityGroups; import com.cloud.bridge.service.core.ec2.EC2DescribeSnapshots; +import com.cloud.bridge.service.core.ec2.EC2DescribeTags; import com.cloud.bridge.service.core.ec2.EC2DescribeVolumes; import com.cloud.bridge.service.core.ec2.EC2DisassociateAddress; import com.cloud.bridge.service.core.ec2.EC2Engine; @@ -143,6 +150,10 @@ import com.cloud.bridge.service.core.ec2.EC2SecurityGroup; import com.cloud.bridge.service.core.ec2.EC2SnapshotFilterSet; import com.cloud.bridge.service.core.ec2.EC2StartInstances; import com.cloud.bridge.service.core.ec2.EC2StopInstances; +import com.cloud.bridge.service.core.ec2.EC2TagKeyValue; +import com.cloud.bridge.service.core.ec2.EC2TagTypeId; +import com.cloud.bridge.service.core.ec2.EC2Tags; +import com.cloud.bridge.service.core.ec2.EC2TagsFilterSet; import com.cloud.bridge.service.core.ec2.EC2Volume; import com.cloud.bridge.service.core.ec2.EC2VolumeFilterSet; import com.cloud.bridge.service.exception.EC2ServiceException; @@ -294,6 +305,9 @@ public class EC2RestServlet extends HttpServlet { else if (action.equalsIgnoreCase( "ImportKeyPair" )) importKeyPair(request, response); else if (action.equalsIgnoreCase( "DeleteKeyPair" )) deleteKeyPair(request, response); else if (action.equalsIgnoreCase( "DescribeKeyPairs" )) describeKeyPairs(request, response); + else if (action.equalsIgnoreCase( "CreateTags" )) createTags(request, response); + else if (action.equalsIgnoreCase( "DeleteTags" )) deleteTags(request, response); + else if (action.equalsIgnoreCase( "DescribeTags" )) describeTags(request, response); else if (action.equalsIgnoreCase( "GetPasswordData" )) getPasswordData(request, response); else { logger.error("Unsupported action " + action); @@ -1824,6 +1838,83 @@ public class EC2RestServlet extends HttpServlet { serializeResponse(response, EC2Response); } + private void createTags(HttpServletRequest request, HttpServletResponse response) + throws ADBException, XMLStreamException, IOException { + EC2Tags ec2Request = createTagsRequest(request, response); + if (ec2Request == null) return; + CreateTagsResponse EC2Response = EC2SoapServiceImpl.toCreateTagsResponse( + ServiceProvider.getInstance().getEC2Engine().modifyTags( ec2Request, "create")); + serializeResponse(response, EC2Response); + } + + private void deleteTags(HttpServletRequest request, HttpServletResponse response) + throws ADBException, XMLStreamException, IOException { + EC2Tags ec2Request = createTagsRequest(request, response); + if (ec2Request == null) return; + DeleteTagsResponse EC2Response = EC2SoapServiceImpl.toDeleteTagsResponse( + ServiceProvider.getInstance().getEC2Engine().modifyTags( ec2Request, "delete")); + serializeResponse(response, EC2Response); + } + + private EC2Tags createTagsRequest(HttpServletRequest request, HttpServletResponse response) + throws IOException { + EC2Tags ec2Request = new EC2Tags(); + ArrayList resourceIdList = new ArrayList(); + Map resourceTagList = new HashMap(); + + int nCount = 1; + do { + String[] resourceIds = request.getParameterValues( "ResourceId." + nCount ); + if (resourceIds != null && resourceIds.length > 0) + resourceIdList.add(resourceIds[0]); + else break; + nCount++; + } while (true); + if ( resourceIdList.isEmpty() ) { + response.sendError(530, "At least one Resource is required" ); + return null; + } + ec2Request = EC2SoapServiceImpl.toResourceTypeAndIds(ec2Request, resourceIdList); + + nCount = 1; + do { + String[] tagKey = request.getParameterValues( "Tag." + nCount + ".Key" ); + if ( tagKey != null && tagKey.length > 0 ) { + String[] tagValue = request.getParameterValues( "Tag." + nCount + ".Value" ); + if ( tagValue != null && tagValue.length > 0 ) { + resourceTagList.put(tagKey[0], tagValue[0]); + } else + resourceTagList.put(tagKey[0], null); + } else break; + nCount++; + } while (true); + if ( resourceTagList.isEmpty() ) { + response.sendError(530, "At least one Tag is required" ); + return null; + } + ec2Request = EC2SoapServiceImpl.toResourceTag(ec2Request, resourceTagList); + + return ec2Request; + } + + private void describeTags(HttpServletRequest request, HttpServletResponse response) + throws ADBException, XMLStreamException, IOException { + EC2DescribeTags ec2Request = new EC2DescribeTags(); + + EC2Filter[] filterSet = extractFilters( request ); + if (null != filterSet) { + EC2TagsFilterSet tfs = new EC2TagsFilterSet(); + for( int i=0; i < filterSet.length; i++ ) + tfs.addFilter( filterSet[i] ); + ec2Request.setFilterSet( tfs ); + } + DescribeTagsResponse EC2Response = EC2SoapServiceImpl.toDescribeTagsResponse( + ServiceProvider.getInstance().getEC2Engine().describeTags( ec2Request)); + serializeResponse(response, EC2Response); + } + + + /** * This function implements the EC2 REST authentication algorithm. It uses the given * "AWSAccessKeyId" parameter to look up the Cloud.com account holder's secret key which is diff --git a/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java b/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java index cebac0b159e..9362b810e32 100644 --- a/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java +++ b/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java @@ -18,7 +18,10 @@ package com.cloud.bridge.service; import java.util.ArrayList; import java.util.Calendar; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.UUID; import org.apache.commons.codec.binary.Base64; @@ -210,87 +213,103 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface { public CreateTagsResponse createTags(CreateTags createTags) { EC2Tags request = new EC2Tags(); + ArrayList resourceIdList = new ArrayList(); + Map resourceTagList = new HashMap(); + CreateTagsType ctt = createTags.getCreateTags(); ResourceIdSetType resourceIds = ctt.getResourcesSet(); ResourceTagSetType resourceTags = ctt.getTagSet(); - request = toResourceTypeAndIds(resourceIds); - //add resource tag's to the request - if (resourceTags != null) { - ResourceTagSetItemType[] items = resourceTags.getItem(); - if (items != null) { - for( int i=0; i < items.length; i++ ) { - EC2TagKeyValue param1 = new EC2TagKeyValue(); - param1.setKey(items[i].getKey()); - param1.setValue(items[i].getValue()); - request.addResourceTag(param1); - } - } + + ResourceIdSetItemType[] resourceIdItems = resourceIds.getItem(); + if (resourceIdItems != null) { + for( int i=0; i < resourceIdItems.length; i++ ) + resourceIdList.add(resourceIdItems[i].getResourceId()); } + request = toResourceTypeAndIds(request, resourceIdList); + + //add resource tag's to the request + ResourceTagSetItemType[] resourceTagItems = resourceTags.getItem(); + if (resourceTagItems != null) { + for( int i=0; i < resourceTagItems.length; i++ ) + resourceTagList.put(resourceTagItems[i].getKey(), resourceTagItems[i].getValue()); + } + request = toResourceTag(request, resourceTagList); + return toCreateTagsResponse( engine.modifyTags( request, "create")); } public DeleteTagsResponse deleteTags(DeleteTags deleteTags) { EC2Tags request = new EC2Tags(); + ArrayList resourceIdList = new ArrayList(); + Map resourceTagList = new HashMap(); + DeleteTagsType dtt = deleteTags.getDeleteTags(); ResourceIdSetType resourceIds = dtt.getResourcesSet(); DeleteTagsSetType resourceTags = dtt.getTagSet(); - request = toResourceTypeAndIds(resourceIds); - //add resource tag's to the request - if (resourceTags != null) { - DeleteTagsSetItemType[] items = resourceTags.getItem(); - if (items != null) { - for( int i=0; i < items.length; i++ ) { - EC2TagKeyValue param1 = new EC2TagKeyValue(); - param1.setKey(items[i].getKey()); - if (items[i].getValue() != null) - param1.setValue(items[i].getValue()); - request.addResourceTag(param1); - } - } + + ResourceIdSetItemType[] resourceIdItems = resourceIds.getItem(); + + if (resourceIdItems != null) { + for( int i=0; i < resourceIdItems.length; i++ ) + resourceIdList.add(resourceIdItems[i].getResourceId()); } + request = toResourceTypeAndIds(request, resourceIdList); + + //add resource tag's to the request + DeleteTagsSetItemType[] resourceTagItems = resourceTags.getItem(); + if (resourceTagItems != null) { + for( int i=0; i < resourceTagItems.length; i++ ) + resourceTagList.put(resourceTagItems[i].getKey(), resourceTagItems[i].getValue()); + } + request = toResourceTag(request, resourceTagList); + return toDeleteTagsResponse( engine.modifyTags( request, "delete")); } - private EC2Tags toResourceTypeAndIds(ResourceIdSetType resourceIds) { - EC2Tags request = new EC2Tags(); - //add resource-type and resource-id's to the request - if (resourceIds != null) { - ResourceIdSetItemType[] items = resourceIds.getItem(); - List resourceTypeList = new ArrayList(); - if (items != null) { - for( int i=0; i < items.length; i++ ) { - if (!items[i].getResourceId().contains(":") || items[i].getResourceId().split(":").length != 2) { - throw new EC2ServiceException( ClientError.InvalidResourceId_Format, - "Invalid Format. ResourceId format is resource-type:resource-uuid"); - } - String resourceType = items[i].getResourceId().split(":")[0]; - if (resourceTypeList.isEmpty()) - resourceTypeList.add(resourceType); - else { - Boolean existsInList = false; - for (String addedResourceType : resourceTypeList) { - if (addedResourceType.equalsIgnoreCase(resourceType)) { - existsInList = true; - break; - } - } - if (!existsInList) - resourceTypeList.add(resourceType); - } - } - for (String resourceType : resourceTypeList){ - EC2TagTypeId param1 = new EC2TagTypeId(); - param1.setResourceType(resourceType); - for( int i=0; i < items.length; i++ ) { - String[] resourceTag = items[i].getResourceId().split(":"); - if (resourceType.equals(resourceTag[0])) - param1.addResourceId(resourceTag[1]); - } - request.addResourceType(param1); - } + public static EC2Tags toResourceTypeAndIds( EC2Tags request, ArrayList resourceIdList ) { + List resourceTypeList = new ArrayList(); + for (String resourceId : resourceIdList) { + if (!resourceId.contains(":") || resourceId.split(":").length != 2) { + throw new EC2ServiceException( ClientError.InvalidResourceId_Format, + "Invalid Format. ResourceId format is resource-type:resource-uuid"); } + String resourceType = resourceId.split(":")[0]; + if (resourceTypeList.isEmpty()) + resourceTypeList.add(resourceType); + else { + Boolean existsInList = false; + for (String addedResourceType : resourceTypeList) { + if (addedResourceType.equalsIgnoreCase(resourceType)) { + existsInList = true; + break; + } + } + if (!existsInList) + resourceTypeList.add(resourceType); + } + } + for (String resourceType : resourceTypeList) { + EC2TagTypeId param1 = new EC2TagTypeId(); + param1.setResourceType(resourceType); + for (String resourceId : resourceIdList) { + String[] resourceTag = resourceId.split(":"); + if (resourceType.equals(resourceTag[0])) + param1.addResourceId(resourceTag[1]); + } + request.addResourceType(param1); + } + return request; + } + + public static EC2Tags toResourceTag( EC2Tags request, Map resourceTagList ) { + Set resourceTagKeySet = resourceTagList.keySet(); + for (String resourceTagKey : resourceTagKeySet) { + EC2TagKeyValue param1 = new EC2TagKeyValue(); + param1.setKey(resourceTagKey); + param1.setValue(resourceTagList.get(resourceTagKey)); + request.addResourceTag(param1); } return request; } From 45d2e60656a7c9b2b4171bc63450afa229ca4e75 Mon Sep 17 00:00:00 2001 From: Dave Brosius Date: Tue, 21 May 2013 11:42:53 +0530 Subject: [PATCH 31/51] Nop assignment due to missing 'this.' Signed-off-by: Prasanna Santhanam --- .../src/com/cloud/network/dao/ExternalLoadBalancerDeviceVO.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/schema/src/com/cloud/network/dao/ExternalLoadBalancerDeviceVO.java b/engine/schema/src/com/cloud/network/dao/ExternalLoadBalancerDeviceVO.java index 04714a6a4de..c1c983489a3 100644 --- a/engine/schema/src/com/cloud/network/dao/ExternalLoadBalancerDeviceVO.java +++ b/engine/schema/src/com/cloud/network/dao/ExternalLoadBalancerDeviceVO.java @@ -198,7 +198,7 @@ public class ExternalLoadBalancerDeviceVO implements InternalIdentity, Identity } public void setGslbProvider(boolean gslbProvider) { - gslbProvider = gslbProvider; + this.gslbProvider = gslbProvider; } public void setGslbSitePublicIP(String gslbSitePublicIP) { From 49faa002e220311f10a5f99993fad66a22836dad Mon Sep 17 00:00:00 2001 From: Dave Brosius Date: Tue, 21 May 2013 11:45:10 +0530 Subject: [PATCH 32/51] code compares Long values with == which will work for Long cached values Fixed by switch to use .equals Signed-off-by: Prasanna Santhanam --- .../engine/subsystem/api/storage/AbstractScope.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/AbstractScope.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/AbstractScope.java index c94db66b202..083b1fe6c39 100644 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/AbstractScope.java +++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/AbstractScope.java @@ -21,10 +21,6 @@ package org.apache.cloudstack.engine.subsystem.api.storage; public abstract class AbstractScope implements Scope { @Override public boolean isSameScope(Scope scope) { - if (this.getScopeType() == scope.getScopeType() && this.getScopeId() == scope.getScopeId()) { - return true; - } else { - return false; - } + return this.getScopeType() == scope.getScopeType() && this.getScopeId().equals(scope.getScopeId()); } } From 55c384651acf3778a4cce57543f79c6e5838fef4 Mon Sep 17 00:00:00 2001 From: Sanjay Tripathi Date: Tue, 21 May 2013 11:49:42 +0530 Subject: [PATCH 33/51] CLOUDSTACK-2305: [Automation] NPE: not able to create volume from snapshot Signed off by : Nitin Mehta --- .../src/com/cloud/storage/VolumeManagerImpl.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/server/src/com/cloud/storage/VolumeManagerImpl.java b/server/src/com/cloud/storage/VolumeManagerImpl.java index 55e20cf0273..4b654eb2253 100644 --- a/server/src/com/cloud/storage/VolumeManagerImpl.java +++ b/server/src/com/cloud/storage/VolumeManagerImpl.java @@ -878,14 +878,6 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager { size = diskOffering.getDiskSize(); } - if(displayVolumeEnabled == null){ - displayVolumeEnabled = true; - } else{ - if(!_accountMgr.isRootAdmin(caller.getType())){ - throw new PermissionDeniedException( "Cannot update parameter displayvolume, only admin permitted "); - } - } - if (!validateVolumeSizeRange(size)) {// convert size from mb to gb // for validation throw new InvalidParameterValueException( @@ -917,6 +909,14 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager { _accountMgr.checkAccess(caller, null, true, snapshotCheck); } + if(displayVolumeEnabled == null){ + displayVolumeEnabled = true; + } else{ + if(!_accountMgr.isRootAdmin(caller.getType())){ + throw new PermissionDeniedException( "Cannot update parameter displayvolume, only admin permitted "); + } + } + // Check that the resource limit for primary storage won't be exceeded _resourceLimitMgr.checkResourceLimit(_accountMgr.getAccount(ownerId), ResourceType.primary_storage, new Long(size)); From 218d26be60a556dccd0a40499a04901f2ac4adc1 Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Tue, 21 May 2013 12:03:27 +0530 Subject: [PATCH 34/51] Adding the 'advanced' attribute for test_public_ip_range Fixing typo in class name. Signed-off-by: Prasanna Santhanam --- test/integration/smoke/test_public_ip_range.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/integration/smoke/test_public_ip_range.py b/test/integration/smoke/test_public_ip_range.py index f2099ff432a..e1d78d99d15 100644 --- a/test/integration/smoke/test_public_ip_range.py +++ b/test/integration/smoke/test_public_ip_range.py @@ -52,11 +52,11 @@ class Services: "vlan": "4444", } -class TesDedicatePublicIPRange(cloudstackTestCase): +class TestDedicatePublicIPRange(cloudstackTestCase): @classmethod def setUpClass(cls): - cls.api_client = super(TesDedicatePublicIPRange, cls).getClsTestClient().getApiClient() + cls.api_client = super(TestDedicatePublicIPRange, cls).getClsTestClient().getApiClient() cls.services = Services().services # Get Zone, Domain cls.domain = get_domain(cls.api_client, cls.services) @@ -96,7 +96,7 @@ class TesDedicatePublicIPRange(cloudstackTestCase): raise Exception("Warning: Exception during cleanup : %s" % e) return - @attr(tags = ["simulator", "publiciprange", "dedicate", "release"]) + @attr(tags = ["simulator", "advanced", "publiciprange", "dedicate", "release"]) def test_dedicatePublicIpRange(self): """Test public IP range dedication """ From 6217b0fb4cd79d7c39ce9fdff2c18e4e7504d62f Mon Sep 17 00:00:00 2001 From: Likitha Shetty Date: Tue, 21 May 2013 11:58:01 +0530 Subject: [PATCH 35/51] CLOUDSTACK-2600. Fix CS AWSAPI to add the below filters that are missing in DescribeImages API- architecture description image-id image-type is-public name owner-id state tag-key tag-value tag:key hypervisor --- .../cloud/bridge/service/EC2RestServlet.java | 10 ++ .../bridge/service/EC2SoapServiceImpl.java | 41 ++++- .../service/core/ec2/EC2DescribeImages.java | 10 ++ .../bridge/service/core/ec2/EC2Engine.java | 34 +++- .../bridge/service/core/ec2/EC2Image.java | 63 +++++-- .../service/core/ec2/EC2ImageFilterSet.java | 168 ++++++++++++++++++ 6 files changed, 290 insertions(+), 36 deletions(-) create mode 100644 awsapi/src/com/cloud/bridge/service/core/ec2/EC2ImageFilterSet.java diff --git a/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java b/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java index 6b634e86d9d..83645a38de8 100644 --- a/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java +++ b/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java @@ -135,6 +135,7 @@ import com.cloud.bridge.service.core.ec2.EC2Engine; import com.cloud.bridge.service.core.ec2.EC2Filter; import com.cloud.bridge.service.core.ec2.EC2GroupFilterSet; import com.cloud.bridge.service.core.ec2.EC2Image; +import com.cloud.bridge.service.core.ec2.EC2ImageFilterSet; import com.cloud.bridge.service.core.ec2.EC2ImageAttributes.ImageAttribute; import com.cloud.bridge.service.core.ec2.EC2ImageLaunchPermission; import com.cloud.bridge.service.core.ec2.EC2ImportKeyPair; @@ -1380,6 +1381,15 @@ public class EC2RestServlet extends HttpServlet { if (null != value && 0 < value.length) EC2request.addImageSet( value[0] ); } } + // add filters + EC2Filter[] filterSet = extractFilters( request ); + if ( filterSet != null ) { + EC2ImageFilterSet ifs = new EC2ImageFilterSet(); + for( int i=0; i < filterSet.length; i++ ) { + ifs.addFilter(filterSet[i]); + } + EC2request.setFilterSet( ifs ); + } // -> execute the request EC2Engine engine = ServiceProvider.getInstance().getEC2Engine(); DescribeImagesResponse EC2response = EC2SoapServiceImpl.toDescribeImagesResponse( engine.describeImages( EC2request )); diff --git a/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java b/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java index 9362b810e32..dc0d993e0b8 100644 --- a/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java +++ b/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java @@ -51,6 +51,7 @@ import com.cloud.bridge.service.core.ec2.EC2DescribeInstances; import com.cloud.bridge.service.core.ec2.EC2DescribeInstancesResponse; import com.cloud.bridge.service.core.ec2.EC2DescribeKeyPairs; import com.cloud.bridge.service.core.ec2.EC2DescribeKeyPairsResponse; +import com.cloud.bridge.service.core.ec2.EC2ImageFilterSet; import com.cloud.bridge.service.core.ec2.EC2ImageLaunchPermission; import com.cloud.bridge.service.core.ec2.EC2ResourceTag; import com.cloud.bridge.service.core.ec2.EC2DescribeSecurityGroups; @@ -407,7 +408,10 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface { for( int i=0; i < items3.length; i++ ) request.addOwnersSet( items3[i].getOwner()); } } - + FilterSetType fst = dit.getFilterSet(); + if ( fst != null) { + request.setFilterSet(toImageFilterSet(fst)); + } return toDescribeImagesResponse( engine.describeImages( request )); } @@ -948,7 +952,7 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface { DescribeImagesResponseItemType param3 = new DescribeImagesResponseItemType(); param3.setImageId( images[i].getId()); param3.setImageLocation( "" ); - param3.setImageState( (images[i].getIsReady() ? "available" : "unavailable" )); + param3.setImageState( images[i].getState()); param3.setImageOwnerId(ownerId); param3.setIsPublic( images[i].getIsPublic()); @@ -960,16 +964,14 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface { String description = images[i].getDescription(); param3.setDescription( (null == description ? "" : description)); - - if (null == description) param3.setArchitecture( "" ); - else if (-1 != description.indexOf( "x86_64" )) param3.setArchitecture( "x86_64" ); - else if (-1 != description.indexOf( "i386" )) param3.setArchitecture( "i386" ); - else param3.setArchitecture( "" ); - - param3.setImageType( "machine" ); + + param3.setArchitecture( images[i].getArchitecture()); + + param3.setImageType( images[i].getImageType()); param3.setKernelId( "" ); param3.setRamdiskId( "" ); param3.setPlatform( "" ); + param3.setHypervisor( images[i].getHypervisor()); StateReasonType param6 = new StateReasonType(); param6.setCode( "" ); @@ -1287,6 +1289,27 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface { return tfs; } + private EC2ImageFilterSet toImageFilterSet( FilterSetType fst ) { + EC2ImageFilterSet ifs = new EC2ImageFilterSet(); + + FilterType[] items = fst.getItem(); + if (items != null) { + for (FilterType item : items) { + EC2Filter oneFilter = new EC2Filter(); + String filterName = item.getName(); + oneFilter.setName( filterName ); + + ValueSetType vft = item.getValueSet(); + ValueType[] valueItems = vft.getItem(); + for (ValueType valueItem : valueItems) { + oneFilter.addValueEncoded( valueItem.getValue()); + } + ifs.addFilter( oneFilter ); + } + } + return ifs; + } + // toMethods public static DescribeVolumesResponse toDescribeVolumesResponse( EC2DescribeVolumesResponse engineResponse ) { diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2DescribeImages.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2DescribeImages.java index 9c51b68df7f..96f2a85ffe2 100644 --- a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2DescribeImages.java +++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2DescribeImages.java @@ -24,6 +24,7 @@ public class EC2DescribeImages { private List executableBySet = new ArrayList();; // a list of strings identifying users private List imageSet = new ArrayList(); // a list of AMI id's private List ownersSet = new ArrayList(); // a list of AMI owner id's + private EC2ImageFilterSet ifs = null; public EC2DescribeImages() { } @@ -51,4 +52,13 @@ public class EC2DescribeImages { public String[] getOwnersSet() { return ownersSet.toArray(new String[0]); } + + public EC2ImageFilterSet getFilterSet() { + return ifs; + } + + public void setFilterSet( EC2ImageFilterSet param ) { + ifs = param; + } + } diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java index e92f845f2b1..137111a3070 100644 --- a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java +++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java @@ -902,15 +902,19 @@ public class EC2Engine extends ManagerBase { try { String[] templateIds = request.getImageSet(); + EC2ImageFilterSet ifs = request.getFilterSet(); - if ( 0 == templateIds.length ) { - return listTemplates(null, images); + if ( templateIds.length == 0 ) { + images = listTemplates(null, images); + } else { + for (String s : templateIds) { + images = listTemplates(s, images); + } } - for (String s : templateIds) { - images = listTemplates(s, images); - } - return images; - + if (ifs == null) + return images; + else + return ifs.evaluate(images); } catch( Exception e ) { logger.error( "EC2 DescribeImages - ", e); throw new EC2ServiceException(ServerError.InternalError, e.getMessage() != null ? e.getMessage() : "An unexpected error occurred."); @@ -1951,8 +1955,22 @@ public class EC2Engine extends ManagerBase { ec2Image.setDescription(temp.getDisplayText()); ec2Image.setOsTypeId(temp.getOsTypeId().toString()); ec2Image.setIsPublic(temp.getIsPublic()); - ec2Image.setIsReady(temp.getIsReady()); + ec2Image.setState( temp.getIsReady() ? "available" : "pending"); ec2Image.setDomainId(temp.getDomainId()); + if ( temp.getHyperVisor().equalsIgnoreCase("xenserver")) + ec2Image.setHypervisor("xen"); + else if ( temp.getHyperVisor().equalsIgnoreCase("ovm")) + ec2Image.setHypervisor( "ovm"); // valid values for hypervisor is 'ovm' and 'xen' + else + ec2Image.setHypervisor(""); + if (temp.getDisplayText() == null) + ec2Image.setArchitecture(""); + else if (temp.getDisplayText().indexOf( "x86_64" ) != -1) + ec2Image.setArchitecture("x86_64"); + else if (temp.getDisplayText().indexOf( "i386" ) != -1) + ec2Image.setArchitecture("i386"); + else + ec2Image.setArchitecture(""); List resourceTags = temp.getTags(); for(CloudStackKeyValue resourceTag : resourceTags) { EC2TagKeyValue param = new EC2TagKeyValue(); diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Image.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Image.java index 1c30b674f60..8ca9ce7384c 100644 --- a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Image.java +++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Image.java @@ -28,10 +28,13 @@ public class EC2Image { private String name; private String description; private String osTypeId; - private boolean isPublic; - private boolean isReady; + private Boolean isPublic; + private String state; private String accountName; - private String domainId; + private String domainId; + private String hypervisor; + private String architecture; + private String imageType; private List tagsSet; public EC2Image() { @@ -40,9 +43,12 @@ public class EC2Image { description = null; osTypeId = null; isPublic = false; - isReady = false; + state = null; accountName = null; - domainId = null; + domainId = null; + hypervisor = null; + architecture = null; + imageType = "machine"; tagsSet = new ArrayList(); } @@ -78,21 +84,21 @@ public class EC2Image { return this.osTypeId; } - public void setIsPublic( boolean isPublic ) { - this.isPublic = isPublic; - } - - public boolean getIsPublic() { - return this.isPublic; - } + public void setIsPublic( Boolean isPublic ) { + this.isPublic = isPublic; + } - public void setIsReady( boolean isReady ) { - this.isReady = isReady; - } - - public boolean getIsReady() { - return this.isReady; - } + public Boolean getIsPublic() { + return this.isPublic; + } + + public void setState( String state ) { + this.state = state; + } + + public String getState() { + return this.state; + } public String getAccountName() { return accountName; @@ -110,6 +116,25 @@ public class EC2Image { this.domainId = domainId; } + public String getHypervisor() { + return hypervisor; + } + + public void setHypervisor(String hypervisor) { + this.hypervisor = hypervisor; + } + + public String getArchitecture() { + return architecture; + } + + public void setArchitecture(String architecture) { + this.architecture = architecture; + } + + public String getImageType() { + return imageType; + } public void addResourceTag( EC2TagKeyValue param ) { tagsSet.add( param ); diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2ImageFilterSet.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2ImageFilterSet.java new file mode 100644 index 00000000000..aea3df05dea --- /dev/null +++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2ImageFilterSet.java @@ -0,0 +1,168 @@ +// 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.bridge.service.core.ec2; + +import java.text.ParseException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + +import com.cloud.bridge.service.exception.EC2ServiceException; + +public class EC2ImageFilterSet { + protected final static Logger logger = Logger.getLogger(EC2ImageFilterSet.class); + + protected List filterSet = new ArrayList(); + private Map filterTypes = new HashMap(); + + public EC2ImageFilterSet() { + // -> supported filters + filterTypes.put( "architecture", "string" ); + filterTypes.put( "description", "string" ); + filterTypes.put( "hypervisor", "string" ); + filterTypes.put( "image-id", "string" ); + filterTypes.put( "image-type", "string" ); + filterTypes.put( "is-public", "Boolean" ); + filterTypes.put( "name", "string" ); + filterTypes.put( "owner-id", "string" ); + filterTypes.put( "state", "string" ); + filterTypes.put( "tag-key", "string" ); + filterTypes.put( "tag-value", "string" ); + } + + public void addFilter( EC2Filter param ) { + String filterName = param.getName(); + if ( !filterName.startsWith("tag:") ) { + String value = (String) filterTypes.get( filterName ); + if (null == value) + throw new EC2ServiceException( "Unsupported filter [" + filterName + "] - 1", 501 ); + if (null != value && value.equalsIgnoreCase( "null" )) + throw new EC2ServiceException( "Unsupported filter [" + filterName + "] - 2", 501 ); + } + + filterSet.add( param ); + } + + public EC2Filter[] getFilterSet() { + return filterSet.toArray(new EC2Filter[0]); + } + + public EC2DescribeImagesResponse evaluate( EC2DescribeImagesResponse sampleList) throws ParseException { + EC2DescribeImagesResponse resultList = new EC2DescribeImagesResponse(); + + boolean matched; + + EC2Image[] imageSet = sampleList.getImageSet(); + EC2Filter[] filterSet = getFilterSet(); + for (EC2Image image : imageSet) { + matched = true; + for (EC2Filter filter : filterSet) { + if (!filterMatched(image, filter)) { + matched = false; + break; + } + } + if (matched == true) + resultList.addImage(image); + } + return resultList; + } + +private boolean filterMatched( EC2Image image, EC2Filter filter ) throws ParseException { + String filterName = filter.getName(); + String[] valueSet = filter.getValueSet(); + + if ( filterName.equalsIgnoreCase( "architecture" )) + return containsString( image.getArchitecture(), valueSet ); + if ( filterName.equalsIgnoreCase( "description" )) + return containsString( image.getDescription(), valueSet ); + if ( filterName.equalsIgnoreCase( "hypervisor" )) + return containsString( image.getHypervisor(), valueSet ); + if ( filterName.equalsIgnoreCase( "image-id" )) + return containsString( image.getId(), valueSet ); + if ( filterName.equalsIgnoreCase( "image-type" )) + return containsString( image.getImageType(), valueSet ); + if ( filterName.equalsIgnoreCase( "is-public" )) + return image.getIsPublic().toString().equalsIgnoreCase(valueSet[0]); + if ( filterName.equalsIgnoreCase( "name" )) + return containsString( image.getName(), valueSet ); + if ( filterName.equalsIgnoreCase( "owner-id" )) { + String owner = new String( image.getDomainId() + ":" + image.getAccountName()); + return containsString( owner, valueSet ); + } + if ( filterName.equalsIgnoreCase( "state" )) + return containsString( image.getState(), valueSet ); + else if (filterName.equalsIgnoreCase("tag-key")) + { + EC2TagKeyValue[] tagSet = image.getResourceTags(); + for (EC2TagKeyValue tag : tagSet) + if (containsString(tag.getKey(), valueSet)) return true; + return false; + } + else if (filterName.equalsIgnoreCase("tag-value")) + { + EC2TagKeyValue[] tagSet = image.getResourceTags(); + for (EC2TagKeyValue tag : tagSet){ + if (tag.getValue() == null) { + if (containsEmptyValue(valueSet)) return true; + } + else { + if (containsString(tag.getValue(), valueSet)) return true; + } + } + return false; + } + else if (filterName.startsWith("tag:")) + { + String key = filterName.split(":")[1]; + EC2TagKeyValue[] tagSet = image.getResourceTags(); + for (EC2TagKeyValue tag : tagSet){ + if (tag.getKey().equalsIgnoreCase(key)) { + if (tag.getValue() == null) { + if (containsEmptyValue(valueSet)) return true; + } + else { + if (containsString(tag.getValue(), valueSet)) return true; + } + } + } + return false; + } + else return false; + } + + private boolean containsString( String lookingFor, String[] set ) { + if (lookingFor == null) + return false; + + for (String filter: set) { + if (lookingFor.matches( filter )) return true; + } + return false; + } + + private boolean containsEmptyValue( String[] set ) { + for( int i=0; i < set.length; i++ ) { + if (set[i].isEmpty()) return true; + } + return false; + } + +} From 9350441dd3dfc27a5852c5662463a1d5af1cd026 Mon Sep 17 00:00:00 2001 From: Dave Brosius Date: Tue, 21 May 2013 12:09:21 +0530 Subject: [PATCH 36/51] remove bogus self assign to parent Signed off by : Nitin Mehta --- .../cloud/agent/api/storage/CreateEntityDownloadURLCommand.java | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/com/cloud/agent/api/storage/CreateEntityDownloadURLCommand.java b/core/src/com/cloud/agent/api/storage/CreateEntityDownloadURLCommand.java index d928e0c5b2b..98a957f9a4e 100755 --- a/core/src/com/cloud/agent/api/storage/CreateEntityDownloadURLCommand.java +++ b/core/src/com/cloud/agent/api/storage/CreateEntityDownloadURLCommand.java @@ -28,7 +28,6 @@ public class CreateEntityDownloadURLCommand extends AbstractDownloadCommand { public CreateEntityDownloadURLCommand(String installPath, String uuid) { super(); - this.parent = parent; this.installPath = installPath; this.extractLinkUUID = uuid; } From 904a2a87f799392c70053f7949b9a6b1e6a2e4dc Mon Sep 17 00:00:00 2001 From: Devdeep Singh Date: Tue, 21 May 2013 13:32:09 +0530 Subject: [PATCH 37/51] CLOUDSTACK-2601 : xen.heartbeat.interval doesn't change the parameter passed to xenheartbeat.sh. Made changes to read the parameter from config and to pass it to the resource. Signed-off-by: Devdeep Singh --- .../com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java | 1 + server/src/com/cloud/resource/DiscovererBase.java | 1 + 2 files changed, 2 insertions(+) diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java index f0121e7220b..fd498365e3d 100755 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java @@ -315,6 +315,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L details.put("wait", Integer.toString(_wait)); params.put("migratewait", _configDao.getValue(Config.MigrateWait.toString())); params.put(Config.XenMaxNics.toString().toLowerCase(), _configDao.getValue(Config.XenMaxNics.toString())); + params.put(Config.XenHeartBeatInterval.toString().toLowerCase(), _configDao.getValue(Config.XenHeartBeatInterval.toString())); params.put(Config.InstanceName.toString().toLowerCase(), _instance); details.put(Config.InstanceName.toString().toLowerCase(), _instance); try { diff --git a/server/src/com/cloud/resource/DiscovererBase.java b/server/src/com/cloud/resource/DiscovererBase.java index b7c5b6f58de..0c9dd2551e5 100644 --- a/server/src/com/cloud/resource/DiscovererBase.java +++ b/server/src/com/cloud/resource/DiscovererBase.java @@ -129,6 +129,7 @@ public abstract class DiscovererBase extends AdapterBase implements Discoverer { params.put("max.template.iso.size", _configDao.getValue(Config.MaxTemplateAndIsoSize.toString())); params.put("migratewait", _configDao.getValue(Config.MigrateWait.toString())); params.put(Config.XenMaxNics.toString().toLowerCase(), _configDao.getValue(Config.XenMaxNics.toString())); + params.put(Config.XenHeartBeatInterval.toString().toLowerCase(), _configDao.getValue(Config.XenHeartBeatInterval.toString())); return params; } From eb92135d55e454799a647490c501f13505325bcb Mon Sep 17 00:00:00 2001 From: Likitha Shetty Date: Tue, 21 May 2013 15:13:18 +0530 Subject: [PATCH 38/51] CLOUDSTACK-2603. EC2RunInstances return xen or ovm as the response value for attribute "hypervisor" --- .../bridge/service/core/ec2/EC2Engine.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java index 137111a3070..9ac2bc68a88 100644 --- a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java +++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java @@ -1458,7 +1458,7 @@ public class EC2Engine extends ManagerBase { vm.setIpAddress(resp.getIpAddress()); vm.setAccountName(resp.getAccountName()); vm.setDomainId(resp.getDomainId()); - vm.setHypervisor(resp.getHypervisor()); + vm.setHypervisor( mapToAmazonHypervisorType(resp.getHypervisor()) ); vm.setServiceOffering( svcOffering.getName()); vm.setKeyPairName(resp.getKeyPairName()); instances.addInstance(vm); @@ -1860,7 +1860,7 @@ public class EC2Engine extends ManagerBase { ec2Vm.setIpAddress(cloudVm.getIpAddress()); ec2Vm.setAccountName(cloudVm.getAccountName()); ec2Vm.setDomainId(cloudVm.getDomainId()); - ec2Vm.setHypervisor(cloudVm.getHypervisor()); + ec2Vm.setHypervisor( mapToAmazonHypervisorType(cloudVm.getHypervisor()) ); ec2Vm.setRootDeviceType(cloudVm.getRootDeviceType()); ec2Vm.setRootDeviceId(cloudVm.getRootDeviceId()); ec2Vm.setServiceOffering(serviceOfferingIdToInstanceType(cloudVm.getServiceOfferingId().toString())); @@ -2498,6 +2498,21 @@ public class EC2Engine extends ManagerBase { return (resourceType.toLowerCase()); } + /** + * Map CloudStack hypervisor to CloudStack hypervisor + * + * @param CloudStack hypervisor + * @return Amazon hypervisor + */ + private String mapToAmazonHypervisorType( String hypervisor) { + if (hypervisor.equalsIgnoreCase("Xenserver")) + return("xen"); + else if(hypervisor.equalsIgnoreCase("Ovm")) + return("ovm"); + else + return (""); + } + /** * Stop an instance * Wait until one specific VM has stopped From 5fb1a1610933b989df25f717d6bd2df10ff34386 Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Tue, 21 May 2013 14:39:33 +0530 Subject: [PATCH 39/51] Fix apidocs build Portable IP section added post portable IP merge Signed-off-by: Prasanna Santhanam --- tools/apidoc/gen_toc.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/apidoc/gen_toc.py b/tools/apidoc/gen_toc.py index 375850304b7..793f7209449 100644 --- a/tools/apidoc/gen_toc.py +++ b/tools/apidoc/gen_toc.py @@ -143,6 +143,7 @@ known_categories = { 'AffinityGroup': 'Affinity Group', 'InternalLoadBalancer': 'Internal LB', 'DeploymentPlanners': 'Configuration', + 'PortableIp': 'Portable IP' } From 2adc8e9a03fd657423add436400f761bd155564f Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Tue, 21 May 2013 15:26:23 +0530 Subject: [PATCH 40/51] Adding docstrings for the portablip test 1. Test to create a portable public ip range 2. Test to acquire a provisioned public ip range Signed-off-by: Prasanna Santhanam --- test/integration/smoke/test_portable_publicip.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/integration/smoke/test_portable_publicip.py b/test/integration/smoke/test_portable_publicip.py index 101747d958e..5b2fbc7e307 100644 --- a/test/integration/smoke/test_portable_publicip.py +++ b/test/integration/smoke/test_portable_publicip.py @@ -138,7 +138,7 @@ class TestPortablePublicIPRange(cloudstackTestCase): @attr(tags = ["simulator", "basic", "advanced", "portablepublicip"]) def test_createPortablePublicIPRange(self): - """ + """ Test to create a portable public ip range """ self.debug("attempting to create a portable Public IP range") self.portable_ip_range = PortablePublicIpRange.create( @@ -155,7 +155,6 @@ class TestPortablePublicIPRange(cloudstackTestCase): class TestPortablePublicIPAcquire(cloudstackTestCase): - """ This test validates functionality where - admin has provisioned a portable public ip range @@ -223,7 +222,7 @@ class TestPortablePublicIPAcquire(cloudstackTestCase): @attr(tags = ["simulator", "basic", "advanced", "portablepublicip"]) def test_createPortablePublicIPAcquire(self): - """ + """ Test to acquire a provisioned public ip range """ self.debug("attempting to create a portable Public IP range") self.portable_ip_range = PortablePublicIpRange.create( From a58ee74e1c3760852214be28d8ef7051f27e1f29 Mon Sep 17 00:00:00 2001 From: Nitin Mehta Date: Tue, 21 May 2013 16:36:10 +0530 Subject: [PATCH 41/51] CLOUDSTACK-2567 - Check whether DMC - dynamic memory control is enabled for the hyervisor before trying to scale the vm. If its not then dont scale and instead throw and exception. --- .../cloud/hypervisor/xen/resource/CitrixResourceBase.java | 7 +++++++ .../hypervisor/xen/resource/CitrixResourceBaseTest.java | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index cd4977312ae..d08aaecb171 100644 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -660,6 +660,13 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe Connection conn = getConnection(); Set vms = VM.getByNameLabel(conn, vmName); Host host = Host.getByUuid(conn, _host.uuid); + + // If DMC is not enable then dont execute this command. + if (isDmcEnabled(conn, host)) { + String msg = "Unable to scale the vm: " + vmName + " as DMC - Dynamic memory control is not enabled for the XenServer:" + _host.uuid + " ,check your license and hypervisor version."; + s_logger.info(msg); + return new ScaleVmAnswer(cmd, false, msg); + } // stop vm which is running on this host or is in halted state Iterator iter = vms.iterator(); while ( iter.hasNext() ) { diff --git a/plugins/hypervisors/xen/test/com/cloud/hypervisor/xen/resource/CitrixResourceBaseTest.java b/plugins/hypervisors/xen/test/com/cloud/hypervisor/xen/resource/CitrixResourceBaseTest.java index 877e3bc5120..3328d4be50c 100644 --- a/plugins/hypervisors/xen/test/com/cloud/hypervisor/xen/resource/CitrixResourceBaseTest.java +++ b/plugins/hypervisors/xen/test/com/cloud/hypervisor/xen/resource/CitrixResourceBaseTest.java @@ -58,7 +58,10 @@ public class CitrixResourceBaseTest { super.scaleVM(conn, vm, vmSpec, host); } - + @Override + protected boolean isDmcEnabled(Connection conn, Host host) throws Types.XenAPIException, XmlRpcException { + return true; + } }; @Mock XsHost _host; @Mock Host host; From 730e6571f6c054b75777694be05ec00c9f16a0f8 Mon Sep 17 00:00:00 2001 From: Wido den Hollander Date: Tue, 21 May 2013 11:23:50 +0200 Subject: [PATCH 42/51] debian: Packaging fixes for AWSAPI --- debian/rules | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/rules b/debian/rules index ff12154db31..575a015effd 100755 --- a/debian/rules +++ b/debian/rules @@ -153,6 +153,7 @@ install: mkdir $(DESTDIR)/usr/share/$(PACKAGE)-bridge mkdir -p $(DESTDIR)/usr/share/$(PACKAGE)-bridge/webapps/awsapi mkdir $(DESTDIR)/usr/share/$(PACKAGE)-bridge/setup + ln -s /usr/share/$(PACKAGE)-bridge/webapps/awsapi $(DESTDIR)/usr/share/$(PACKAGE)-management/webapps7080/awsapi cp -r awsapi/target/cloud-awsapi-$(VERSION)-SNAPSHOT/* $(DESTDIR)/usr/share/$(PACKAGE)-bridge/webapps/awsapi install -D awsapi-setup/setup/cloud-setup-bridge $(DESTDIR)/usr/bin/cloudstack-setup-bridge install -D awsapi-setup/setup/cloudstack-aws-api-register $(DESTDIR)/usr/bin/cloudstack-aws-api-register From 79dc83d1ac055d62b70d172789a6883f29bab186 Mon Sep 17 00:00:00 2001 From: Bharat Kumar Date: Tue, 21 May 2013 17:02:19 +0530 Subject: [PATCH 43/51] blocker bug in dnsmaq config Signed-off-by: Abhinandan Prateek --- core/src/com/cloud/network/DnsMasqConfigurator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/com/cloud/network/DnsMasqConfigurator.java b/core/src/com/cloud/network/DnsMasqConfigurator.java index bbf721d5509..ee8e5fc2e13 100644 --- a/core/src/com/cloud/network/DnsMasqConfigurator.java +++ b/core/src/com/cloud/network/DnsMasqConfigurator.java @@ -110,7 +110,7 @@ import java.util.List; dnsServers = dnsServers+dnsMasqconfigcmd.getDns2()+","; } dnsServers = dnsServers +"*"; - dnsServers = dnsServers.replace(";*", ""); + dnsServers = dnsServers.replace(",*", ""); dnsMasqconf.set(24,"dhcp-option=6,"+dnsServers); return dnsMasqconf.toArray( new String[dnsMasqconf.size()]); } From 37308ebff4a28ae7a1fb7b0bece58ec2cb71de92 Mon Sep 17 00:00:00 2001 From: Wido den Hollander Date: Tue, 21 May 2013 14:35:46 +0200 Subject: [PATCH 44/51] debian: Create the webapps7080 directory --- debian/rules | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/rules b/debian/rules index 575a015effd..e381b1a8ebe 100755 --- a/debian/rules +++ b/debian/rules @@ -80,6 +80,7 @@ install: mkdir -p $(DESTDIR)/$(SYSCONFDIR)/sudoers.d/ mkdir -p $(DESTDIR)/usr/share/$(PACKAGE)-management mkdir -p $(DESTDIR)/usr/share/$(PACKAGE)-management/webapps/client + mkdir -p $(DESTDIR)/usr/share/$(PACKAGE)-management/webapps7080 mkdir $(DESTDIR)/usr/share/$(PACKAGE)-management/setup mkdir $(DESTDIR)/var/log/$(PACKAGE)/management mkdir $(DESTDIR)/var/cache/$(PACKAGE)/management From a8975f952214cd1e7f015934c53311ed7f710779 Mon Sep 17 00:00:00 2001 From: Girish Shilamkar Date: Tue, 21 May 2013 19:25:58 +0530 Subject: [PATCH 45/51] CLOUDSTACK-2474: Remove garbage code which was added while resolving merge conflicts. Signed-off-by: Prasanna Santhanam --- .../integration/component/test_vpc_routers.py | 37 ------------------- 1 file changed, 37 deletions(-) diff --git a/test/integration/component/test_vpc_routers.py b/test/integration/component/test_vpc_routers.py index 763a4cb14f9..7dc95e826e3 100644 --- a/test/integration/component/test_vpc_routers.py +++ b/test/integration/component/test_vpc_routers.py @@ -918,43 +918,6 @@ class TestVPCRouterOneNetwork(cloudstackTestCase): self.debug("VPC network validated - %s" % network.name) return - try: - ssh_1 = self.vm_1.get_ssh_client( - ipaddress=self.public_ip_1.ipaddress.ipaddress) - self.debug("SSH into VM is successfully") - - self.debug("Verifying if we can ping to outside world from VM?") - # Ping to outsite world - res = ssh_1.execute("ping -c 1 www.google.com") - # res = 64 bytes from maa03s17-in-f20.1e100.net (74.125.236.212): - # icmp_req=1 ttl=57 time=25.9 ms - # --- www.l.google.com ping statistics --- - # 1 packets transmitted, 1 received, 0% packet loss, time 0ms - # rtt min/avg/max/mdev = 25.970/25.970/25.970/0.000 ms - result = str(res) - self.assertEqual( - result.count("1 received"), - 1, - "Ping to outside world from VM should be successful" - ) - - self.debug("We should be allowed to ping virtual gateway") - self.debug("VM gateway: %s" % self.vm_1.nic[0].gateway) - - res = ssh_1.execute("ping -c 1 %s" % self.vm_1.nic[0].gateway) - self.debug("ping -c 1 %s: %s" % (self.vm_1.nic[0].gateway, res)) - - result = str(res) - self.assertEqual( - result.count("1 received"), - 1, - "Ping to VM gateway should be successful" - ) - except Exception as e: - self.fail("Failed to SSH into VM - %s, %s" % - (self.public_ip_1.ipaddress.ipaddress, e)) - return - def validate_network_rules(self): """ Validate network rules """ From 1736031fcbd51bcac29f2bd0feef0018bd27c715 Mon Sep 17 00:00:00 2001 From: Girish Shilamkar Date: Tue, 21 May 2013 17:02:58 +0530 Subject: [PATCH 46/51] CLOUDSTACK-2473: Fix a typo in test_vpc_network.py Signed-off-by: Prasanna Santhanam --- test/integration/component/test_vpc_network.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/component/test_vpc_network.py b/test/integration/component/test_vpc_network.py index dc535851858..c0c393c4ca1 100644 --- a/test/integration/component/test_vpc_network.py +++ b/test/integration/component/test_vpc_network.py @@ -2003,7 +2003,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase): ) self.debug("Checking if we can SSH into VM using NAT rule?") try: - ssh_3 = vm_3.get_ssh_client( + ssh_3 = vm_1.get_ssh_client( ipaddress=public_ip_3.ipaddress.ipaddress, reconnect=True, port=self.services["natrule"]["publicport"] From b74d13f9b1daf7e09fa3fa23d963b20ed12e588a Mon Sep 17 00:00:00 2001 From: Girish Shilamkar Date: Tue, 21 May 2013 16:38:39 +0530 Subject: [PATCH 47/51] CLOUDSTACK-2472: Fix unresolved reference to max_value Signed-off-by: Prasanna Santhanam --- test/integration/component/test_project_limits.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/integration/component/test_project_limits.py b/test/integration/component/test_project_limits.py index 17ddfc67da5..9184dca5202 100644 --- a/test/integration/component/test_project_limits.py +++ b/test/integration/component/test_project_limits.py @@ -193,7 +193,7 @@ class TestProjectLimits(cloudstackTestCase): # Also, verify resource limits for the project are independent of # account resource limits # 3. Increase Projects Resources limits above domains limit. Verify - # project can’t have more resources than domain level limit allows. + # project can't have more resources than domain level limit allows. # 4. Create Resource more than its set limit for a project. Verify # resource allocation should fail giving proper message @@ -312,6 +312,7 @@ class TestProjectLimits(cloudstackTestCase): max=2 ) with self.assertRaises(Exception): + max_value = 3 self.debug( "Attempting to update project: %s resource limit to: %s" % ( project.id, @@ -321,7 +322,7 @@ class TestProjectLimits(cloudstackTestCase): update_resource_limit( self.apiclient, resource.resourcetype, - max=3, + max=max_value, projectid=project.id ) return From 2bc88ea277a4024afd3b365910ea9f85fde44ebf Mon Sep 17 00:00:00 2001 From: Girish Shilamkar Date: Tue, 21 May 2013 14:46:24 +0530 Subject: [PATCH 48/51] CLOUDSTACK-778: Add tests for user provided hostname for vms Automation tests to qualify User provides hostname feature. 1. Defines services class 2. Test to verify custom hostname for the instance with internal name 3. Test to verify custom hostname for the instance without internal name Signed-off-by: Prasanna Santhanam --- .../component/test_custom_hostname.py | 369 ++++++++++++++++++ 1 file changed, 369 insertions(+) create mode 100644 test/integration/component/test_custom_hostname.py diff --git a/test/integration/component/test_custom_hostname.py b/test/integration/component/test_custom_hostname.py new file mode 100644 index 00000000000..e5452141d9c --- /dev/null +++ b/test/integration/component/test_custom_hostname.py @@ -0,0 +1,369 @@ +# 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. +""" P1 tests for user provide hostname cases +""" +#Import Local Modules +import marvin +from nose.plugins.attrib import attr +from marvin.cloudstackTestCase import * +from marvin.cloudstackAPI import * +from marvin.integration.lib.utils import * +from marvin.integration.lib.base import * +from marvin.integration.lib.common import * +from marvin.remoteSSHClient import remoteSSHClient +import datetime + + +class Services: + """Test user provided hostname Services + """ + + def __init__(self): + self.services = { + "domain": { + "name": "Domain", + }, + "project": { + "name": "Project", + "displaytext": "Test project", + }, + "account": { + "email": "administrator@clogeny.com", + "firstname": "Test", + "lastname": "User", + "username": "test", + # Random characters are appended for unique + # username + "password": "password", + }, + "user": { + "email": "administrator@clogeny.com", + "firstname": "User", + "lastname": "User", + "username": "User", + # Random characters are appended for unique + # username + "password": "password", + }, + "disk_offering": { + "displaytext": "Tiny Disk Offering", + "name": "Tiny Disk Offering", + "disksize": 1 + }, + "volume": { + "diskname": "Test Volume", + }, + "service_offering": { + "name": "Tiny Instance", + "displaytext": "Tiny Instance", + "cpunumber": 1, + "cpuspeed": 100, # in MHz + "memory": 128, # In MBs + }, + "virtual_machine": { + "displayname": "TestVM", + "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', + }, + "ostype": 'CentOS 5.3 (64-bit)', + # Cent OS 5.3 (64 bit) + "sleep": 60, + "timeout": 10, + } + + +class TestInstanceNameFlagTrue(cloudstackTestCase): + + @classmethod + def setUpClass(cls): + cls.api_client = super( + TestInstanceNameFlagTrue, + cls + ).getClsTestClient().getApiClient() + cls.services = Services().services + # Get Zone, default template + cls.zone = get_zone(cls.api_client, cls.services) + cls.services["mode"] = cls.zone.networktype + cls.template = get_template( + cls.api_client, + cls.zone.id, + cls.services["ostype"] + ) + + # Create domains, account etc. + cls.domain = get_domain( + cls.api_client, + cls.services + ) + + cls.account = Account.create( + cls.api_client, + cls.services["account"], + admin=True, + domainid=cls.domain.id + ) + + 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._cleanup = [cls.account] + return + + @classmethod + def tearDownClass(cls): + try: + #Cleanup resources used + cleanup_resources(cls.api_client, cls._cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return + + def setUp(self): + self.apiclient = self.testClient.getApiClient() + self.dbclient = self.testClient.getDbConnection() + self.cleanup = [] + return + + def tearDown(self): + try: + #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(configuration='vm.instancename.flag') + @attr(tags=["advanced", "basic", "sg", "eip", "advancedns", "simulator"]) + def test_01_user_provided_hostname(self): + """ Verify user provided hostname to an instance + """ + + # Validate the following + # 1. Set the vm.instancename.flag to true. Hostname and displayname + # should be user provided display name + # 2. Give the user provided user name. Internal name should be + # i---display name + + self.debug("Deploying VM in account: %s" % self.account.account.name) + # Spawn an instance in that network + virtual_machine = VirtualMachine.create( + self.apiclient, + self.services["virtual_machine"], + accountid=self.account.account.name, + domainid=self.account.account.domainid, + serviceofferingid=self.service_offering.id, + ) + self.debug( + "Checking if the virtual machine is created properly or not?") + vms = VirtualMachine.list( + self.apiclient, + id=virtual_machine.id, + listall=True + ) + + self.assertEqual( + isinstance(vms, list), + True, + "List vms should return a valid name" + ) + vm = vms[0] + self.assertEqual( + vm.state, + "Running", + "Vm state should be running after deployment" + ) + self.debug("vm.displayname: %s, original: %s" % + (vm.displayname, + self.services["virtual_machine"]["displayname"])) + self.assertEqual( + vm.displayname, + self.services["virtual_machine"]["displayname"], + "Vm display name should match the given name" + ) + + # Fetch account ID and VMID from database to check internal name + self.debug("select id from account where uuid = '%s';" \ + % self.account.account.id) + + qresultset = self.dbclient.execute( + "select id from account where uuid = '%s';" \ + % self.account.account.id + ) + self.assertEqual( + isinstance(qresultset, list), + True, + "Check DB query result set for valid data" + ) + + self.assertNotEqual( + len(qresultset), + 0, + "Check DB Query result set" + ) + qresult = qresultset[0] + account_id = qresult[0] + + self.debug("select id from vm_instance where uuid = '%s';" % vm.id) + + qresultset = self.dbclient.execute( + "select id from vm_instance where uuid = '%s';" % + vm.id) + + self.assertEqual( + isinstance(qresultset, list), + True, + "Check DB query result set for valid data" + ) + + self.assertNotEqual( + len(qresultset), + 0, + "Check DB Query result set" + ) + qresult = qresultset[0] + self.debug("Query result: %s" % qresult) + vmid = qresult[0] + + #internal Name = i---Display name + internal_name = "i-" + str(account_id) + "-" + str(vmid) + "-" + vm.displayname + self.debug("Internal name: %s" % internal_name) + self.assertEqual( + vm.instancename, + internal_name, + "VM internal name should match with that of the format" + ) + return + + @attr(configuration='vm.instancename.flag') + @attr(tags=["advanced", "basic", "sg", "eip", "advancedns", "simulator"]) + def test_02_instancename_from_default_configuration(self): + """ Verify for globally set instancename + """ + + # Validate the following + # 1. Set the vm.instancename.flag to true. Hostname and displayname + # should be user provided display name + # 2. Dont give the user provided user name. Internal name should be + # i--- in global config + + # Removing display name from config + del self.services["virtual_machine"]["displayname"] + self.debug("Deploying VM in account: %s" % self.account.account.name) + virtual_machine = VirtualMachine.create( + self.apiclient, + self.services["virtual_machine"], + accountid=self.account.account.name, + domainid=self.account.account.domainid, + serviceofferingid=self.service_offering.id, + ) + self.debug( + "Checking if the virtual machine is created properly or not?") + vms = VirtualMachine.list( + self.apiclient, + id=virtual_machine.id, + listall=True + ) + + self.assertEqual( + isinstance(vms, list), + True, + "List vms should retuen a valid name" + ) + vm = vms[0] + self.assertEqual( + vm.state, + "Running", + "Vm state should be running after deployment" + ) + self.assertEqual( + vm.displayname, + vm.id, + "Vm display name should not match the given name" + ) + # Fetch account ID and VMID from database to check internal name + self.debug("select id from account where uuid = '%s';" \ + % self.account.account.id) + + qresultset = self.dbclient.execute( + "select id from account where uuid = '%s';" \ + % self.account.account.id + ) + self.assertEqual( + isinstance(qresultset, list), + True, + "Check DB query result set for valid data" + ) + + self.assertNotEqual( + len(qresultset), + 0, + "Check DB Query result set" + ) + qresult = qresultset[0] + account_id = qresult[0] + + self.debug("select id from vm_instance where uuid = '%s';" % vm.id) + + qresultset = self.dbclient.execute( + "select id from vm_instance where uuid = '%s';" % + vm.id) + + self.assertEqual( + isinstance(qresultset, list), + True, + "Check DB query result set for valid data" + ) + + self.assertNotEqual( + len(qresultset), + 0, + "Check DB Query result set" + ) + qresult = qresultset[0] + self.debug("Query result: %s" % qresult) + vmid = qresult[0] + + self.debug("Fetching the global config value for instance.name") + configs = Configurations.list( + self.apiclient, + name="instance.name", + listall=True + ) + + config = configs[0] + instance_name = config.value + self.debug("Instance.name: %s" % instance_name) + + #internal Name = i--- Instance_name + internal_name = "i-" + str(account_id) + "-" + str(vmid) + "-" + instance_name + self.assertEqual( + vm.instancename, + internal_name, + "VM internal name should match with that of the format" + ) + return From e42ddb83c2a5bed8bec8640372518616592c6d4c Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Mon, 20 May 2013 19:17:21 -0700 Subject: [PATCH 49/51] CLOUDSTACK-747: internalLb in VPC - UI - create network offering - add LB Type dropdodwn which is shown when VPC is checked and LB service is checked, hidden otherwise. LB Type (publicLb, internalLb) will determine the options in LB Provider dropdown. --- ui/scripts/configuration.js | 85 +++++++++++++++++++++++++++++++++---- 1 file changed, 77 insertions(+), 8 deletions(-) diff --git a/ui/scripts/configuration.js b/ui/scripts/configuration.js index e3421a380ef..058f44097b8 100644 --- a/ui/scripts/configuration.js +++ b/ui/scripts/configuration.js @@ -1122,6 +1122,7 @@ title: 'label.add.network.offering', preFilter: function(args) { var $availability = args.$form.find('.form-item[rel=availability]'); + var $lbType = args.$form.find('.form-item[rel=lbType]'); var $systemOfferingForRouter = args.$form.find('.form-item[rel=systemOfferingForRouter]'); var $conservemode = args.$form.find('.form-item[rel=conservemode]'); var $serviceSourceNatRedundantRouterCapabilityCheckbox = args.$form.find('.form-item[rel="service.SourceNat.redundantRouterCapabilityCheckbox"]'); @@ -1147,18 +1148,18 @@ //check whether to show or hide availability field var $sourceNATField = args.$form.find('input[name=\"service.SourceNat.isEnabled\"]'); var $guestTypeField = args.$form.find('select[name=guestIpType]'); - + + var $useVpc = args.$form.find('.form-item[rel=\"useVpc\"]'); + var $useVpcCb = $useVpc.find("input[type=checkbox]"); if($guestTypeField.val() == 'Shared') { //Shared network offering - args.$form.find('.form-item[rel=\"useVpc\"]').hide(); - - var $useVpcCb = args.$form.find('.form-item[rel=\"useVpc\"]').find("input[type=checkbox]"); + $useVpc.hide(); if($useVpcCb.is(':checked')) { //if useVpc is checked, $useVpcCb.removeAttr("checked"); //remove "checked" attribute in useVpc $useVpcCb.trigger("click"); //trigger useVpc.onChange() } } else { //Isolated network offering - args.$form.find('.form-item[rel=\"useVpc\"]').css('display', 'inline-block'); + $useVpc.css('display', 'inline-block'); } @@ -1170,7 +1171,14 @@ $availability.hide(); } - + //when useVpc is checked and service.Lb.isEnabled is checked + if($useVpcCb.is(':checked') && $("input[name='service.Lb.isEnabled']").is(":checked") == true) { + $lbType.css('display', 'inline-block'); + } + else { + $lbType.hide(); + } + //when service(s) has Virtual Router as provider..... var havingVirtualRouterForAtLeastOneService = false; $(serviceCheckboxNames).each(function(){ @@ -1427,7 +1435,7 @@ label: 'VPC', docID: 'helpNetworkOfferingVPC', isBoolean: true, - onChange: function(args) { + onChange: function(args) { var $checkbox = args.$checkbox; var $selects = $checkbox.closest('form').find('.dynamic-input select'); var $vpcOptions = $selects.find('option[value=VpcVirtualRouter]'); @@ -1444,7 +1452,67 @@ } } }, - + + lbType: { //only shown when VPC is checked and LB service is checked + label: 'Load Balancer Type', + isHidden: true, + select: function(args) { + args.response.success({data: [ + {id: 'publicLb', description: 'Public LB'}, + {id: 'internalLb', description: 'Internal LB'} + ]}); + + args.$select.change(function() { + if($(this).is(':visible') == false) + return; //if lbType is not visible, do nothing. + + var $lbProvider = $(this).closest('form').find('.form-item[rel=\"service.Lb.provider\"]').find('select'); + var $lbProviderOptions = $lbProvider.find('option'); + + if($(this).val() == 'publicLb') { //disable all providers except the ones in lbProviderMap.publicLb.vpc => ["VpcVirtualRouter", "Netscaler"] + for(var i = 0; i < $lbProviderOptions.length; i++ ) { + var $option = $lbProviderOptions.eq(i); + var supportedProviders = lbProviderMap.publicLb.vpc; + var thisOpionIsSupported = false; + for(var k = 0; k < supportedProviders.length; k++ ) { + if($option.val() == supportedProviders[k]) { + thisOpionIsSupported = true; + break; + } + } + if(thisOpionIsSupported == true) { + $option.attr('disabled', false); + } + else { + $option.attr('disabled', true); + } + } + } + else if($(this).val() == 'internalLb') { //disable all providers except the ones in lbProviderMap.internalLb.vpc => ["InternalLbVm"] + for(var i = 0; i < $lbProviderOptions.length; i++ ) { + var $option = $lbProviderOptions.eq(i); + var supportedProviders = lbProviderMap.internalLb.vpc; + var thisOpionIsSupported = false; + for(var k = 0; k < supportedProviders.length; k++ ) { + if($option.val() == supportedProviders[k]) { + thisOpionIsSupported = true; + break; + } + } + if(thisOpionIsSupported == true) { + $option.attr('disabled', false); + } + else { + $option.attr('disabled', true); + } + } + } + + $lbProvider.val($lbProvider.find('option:first')); + }); + } + }, + supportedServices: { label: 'label.supported.services', @@ -1571,6 +1639,7 @@ //show or hide upon checked services and selected providers above (begin) systemOfferingForRouter: { label: 'System Offering for Router', + isHidden: true, docID: 'helpNetworkOfferingSystemOffering', select: function(args) { $.ajax({ From 263cc9a62c731a22518056a601c9c57fb3777690 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Tue, 21 May 2013 10:57:12 -0700 Subject: [PATCH 50/51] CLOUDSTACK-747: internalLb in VPC - UI - create network offering - when VPC checkbox is checked, enable provider InternalLbVm, VpcVirtualRouter, Netscaler. When VPC checkbox is unchecked, disable provider InternalLbVm, VpcVirtualRouter. --- ui/scripts/configuration.js | 41 ++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/ui/scripts/configuration.js b/ui/scripts/configuration.js index 058f44097b8..7485898dc19 100644 --- a/ui/scripts/configuration.js +++ b/ui/scripts/configuration.js @@ -1436,20 +1436,37 @@ docID: 'helpNetworkOfferingVPC', isBoolean: true, onChange: function(args) { - var $checkbox = args.$checkbox; - var $selects = $checkbox.closest('form').find('.dynamic-input select'); - var $vpcOptions = $selects.find('option[value=VpcVirtualRouter]'); + var $vpc = args.$checkbox; + var $providers = $vpc.closest('form').find('.dynamic-input select'); + var $optionsOfProviders = $providers.find('option'); - if ($checkbox.is(':checked')) { - $vpcOptions.siblings().attr('disabled', true); - $selects.val('VpcVirtualRouter'); - } else { - $vpcOptions.siblings().attr('disabled', false); - $vpcOptions.attr('disabled', true); - $selects.each(function() { - $(this).val($(this).find('option:first')); - }); + //p.s. Netscaler is supported in both vpc and non-vpc + + if ($vpc.is(':checked')) { //*** vpc *** + $optionsOfProviders.each(function(index) { + if($(this).val() == 'InternalLbVm' || $(this).val() == 'VpcVirtualRouter' || $(this).val() == 'Netscaler') { + $(this).attr('disabled', false); + } + else { + $(this).attr('disabled', true); + } + }); + } + else { //*** non-vpc *** + $optionsOfProviders.each(function(index) { + if($(this).val() == 'InternalLbVm' || $(this).val() == 'VpcVirtualRouter') { + $(this).attr('disabled', true); + } + else { + $(this).attr('disabled', false); + } + }); } + + $providers.each(function() { + $(this).val($(this).find('option:first')); + }); + } }, From a75cf9a79d9f3f3c6c399b03e73362523e3d815a Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Tue, 21 May 2013 11:37:12 -0700 Subject: [PATCH 51/51] CLOUDSTACK-747: internalLb in VPC - UI - create network offering - when Lb service is checked and LB provider is InternalLbVm, pass capability type as lbSchemes and capability value as internal. --- ui/scripts/configuration.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ui/scripts/configuration.js b/ui/scripts/configuration.js index 7485898dc19..92c3d00478e 100644 --- a/ui/scripts/configuration.js +++ b/ui/scripts/configuration.js @@ -1834,7 +1834,13 @@ inputData['servicecapabilitylist[' + serviceCapabilityIndex + '].capabilitytype'] = 'associatePublicIP'; inputData['servicecapabilitylist[' + serviceCapabilityIndex + '].capabilityvalue'] = true; //because this checkbox's value == "on" serviceCapabilityIndex++; - } + } + else if((key == 'service.Lb.provider') && ("Lb" in serviceProviderMap) && (serviceProviderMap.Lb == "InternalLbVm")) { + inputData['servicecapabilitylist[' + serviceCapabilityIndex + '].service'] = 'lb'; + inputData['servicecapabilitylist[' + serviceCapabilityIndex + '].capabilitytype'] = 'lbSchemes'; + inputData['servicecapabilitylist[' + serviceCapabilityIndex + '].capabilityvalue'] = 'internal'; + serviceCapabilityIndex++; + } } else if (value != '') { // Normal data inputData[key] = value;