diff --git a/api/src/com/cloud/async/AsyncJob.java b/api/src/com/cloud/async/AsyncJob.java index 866429b6547..d384a7ad920 100644 --- a/api/src/com/cloud/async/AsyncJob.java +++ b/api/src/com/cloud/async/AsyncJob.java @@ -50,7 +50,8 @@ public interface AsyncJob extends Identity, InternalIdentity { AutoScaleVmProfile, AutoScaleVmGroup, GlobalLoadBalancerRule, - AffinityGroup + AffinityGroup, + DedicatedGuestVlanRange } long getUserId(); diff --git a/api/src/com/cloud/event/EventTypes.java b/api/src/com/cloud/event/EventTypes.java index 0ee7f402fd7..26c40abb4fb 100755 --- a/api/src/com/cloud/event/EventTypes.java +++ b/api/src/com/cloud/event/EventTypes.java @@ -390,6 +390,10 @@ public class EventTypes { public static final String EVENT_AFFINITY_GROUP_REMOVE = "AG.REMOVE"; public static final String EVENT_VM_AFFINITY_GROUP_UPDATE = "VM.AG.UPDATE"; + // Dedicated guest vlan range + public static final String EVENT_GUEST_VLAN_RANGE_DEDICATE = "GUESTVLANRANGE.DEDICATE"; + public static final String EVENT_DEDICATED_GUEST_VLAN_RANGE_RELEASE = "GUESTVLANRANGE.RELEASE"; + static { // TODO: need a way to force author adding event types to declare the entity details as well, with out braking @@ -690,6 +694,9 @@ public class EventTypes { entityEventDetails.put(EVENT_AUTOSCALEVMGROUP_UPDATE, AutoScaleVmGroup.class.getName()); entityEventDetails.put(EVENT_AUTOSCALEVMGROUP_ENABLE, AutoScaleVmGroup.class.getName()); entityEventDetails.put(EVENT_AUTOSCALEVMGROUP_DISABLE, AutoScaleVmGroup.class.getName()); + + entityEventDetails.put(EVENT_GUEST_VLAN_RANGE_DEDICATE, GuestVlan.class.getName()); + entityEventDetails.put(EVENT_DEDICATED_GUEST_VLAN_RANGE_RELEASE, GuestVlan.class.getName()); } public static String getEntityForEvent (String eventName) { diff --git a/api/src/com/cloud/network/GuestVlan.java b/api/src/com/cloud/network/GuestVlan.java new file mode 100644 index 00000000000..a5173d87830 --- /dev/null +++ b/api/src/com/cloud/network/GuestVlan.java @@ -0,0 +1,31 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package com.cloud.network; + +import org.apache.cloudstack.api.Identity; +import org.apache.cloudstack.api.InternalIdentity; + +public interface GuestVlan extends InternalIdentity, Identity { + + public long getId(); + + public long getAccountId(); + + public String getGuestVlanRange(); + + public long getPhysicalNetworkId(); +} diff --git a/api/src/com/cloud/network/NetworkService.java b/api/src/com/cloud/network/NetworkService.java index bea92dc2481..5d4fd67d326 100755 --- a/api/src/com/cloud/network/NetworkService.java +++ b/api/src/com/cloud/network/NetworkService.java @@ -18,6 +18,8 @@ package com.cloud.network; import java.util.List; +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.RestartNetworkCmd; import org.apache.cloudstack.api.command.user.network.CreateNetworkCmd; @@ -29,6 +31,7 @@ import com.cloud.exception.InsufficientAddressCapacityException; import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceUnavailableException; +import com.cloud.network.GuestVlan; import com.cloud.network.Network.Service; import com.cloud.network.Networks.TrafficType; import com.cloud.user.Account; @@ -114,6 +117,12 @@ public interface NetworkService { boolean deletePhysicalNetworkTrafficType(Long id); + GuestVlan dedicateGuestVlanRange(DedicateGuestVlanRangeCmd cmd); + + Pair, Integer> listDedicatedGuestVlanRanges(ListDedicatedGuestVlanRangesCmd cmd); + + boolean releaseDedicatedGuestVlanRange(Long dedicatedGuestVlanRangeId); + Pair, Integer> listTrafficTypes(Long physicalNetworkId); diff --git a/api/src/com/cloud/network/rules/RulesService.java b/api/src/com/cloud/network/rules/RulesService.java index d47b38f9d43..45abd84a9ec 100644 --- a/api/src/com/cloud/network/rules/RulesService.java +++ b/api/src/com/cloud/network/rules/RulesService.java @@ -67,7 +67,7 @@ public interface RulesService { boolean applyPortForwardingRules(long ipAdddressId, Account caller) throws ResourceUnavailableException; - boolean enableStaticNat(long ipAddressId, long vmId, long networkId, boolean isSystemVm, String vmGuestIp) throws NetworkRuleConflictException, ResourceUnavailableException; + boolean enableStaticNat(long ipAddressId, long vmId, long networkId, String vmGuestIp) throws NetworkRuleConflictException, ResourceUnavailableException; PortForwardingRule getPortForwardigRule(long ruleId); diff --git a/api/src/com/cloud/vm/UserVmService.java b/api/src/com/cloud/vm/UserVmService.java index c8ccb67caf3..fa89521af0a 100755 --- a/api/src/com/cloud/vm/UserVmService.java +++ b/api/src/com/cloud/vm/UserVmService.java @@ -451,6 +451,6 @@ public interface UserVmService { UserVm restoreVM(RestoreVMCmd cmd) throws InsufficientCapacityException, ResourceUnavailableException; - UserVm upgradeVirtualMachine(ScaleVMCmd scaleVMCmd) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException; + boolean upgradeVirtualMachine(ScaleVMCmd scaleVMCmd) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException; } diff --git a/api/src/org/apache/cloudstack/api/ApiConstants.java b/api/src/org/apache/cloudstack/api/ApiConstants.java index 1165c7b34f6..d57fe058d93 100755 --- a/api/src/org/apache/cloudstack/api/ApiConstants.java +++ b/api/src/org/apache/cloudstack/api/ApiConstants.java @@ -85,6 +85,7 @@ public class ApiConstants { public static final String GSLB_SERVICE_TYPE = "gslbservicetype"; public static final String GSLB_STICKY_SESSION_METHOD = "gslbstickysessionmethodname"; public static final String GUEST_CIDR_ADDRESS = "guestcidraddress"; + public static final String GUEST_VLAN_RANGE = "guestvlanrange"; public static final String HA_ENABLE = "haenable"; public static final String HOST_ID = "hostid"; public static final String HOST_NAME = "hostname"; @@ -221,6 +222,7 @@ public class ApiConstants { public static final String VIRTUAL_MACHINE_ID = "virtualmachineid"; public static final String VIRTUAL_MACHINE_IDS = "virtualmachineids"; public static final String VLAN = "vlan"; + public static final String VLAN_RANGE = "vlanrange"; public static final String REMOVE_VLAN="removevlan"; public static final String VLAN_ID = "vlanid"; public static final String VM_AVAILABLE = "vmavailable"; diff --git a/api/src/org/apache/cloudstack/api/ResponseGenerator.java b/api/src/org/apache/cloudstack/api/ResponseGenerator.java index cbf8bb27b90..8466bd8729e 100644 --- a/api/src/org/apache/cloudstack/api/ResponseGenerator.java +++ b/api/src/org/apache/cloudstack/api/ResponseGenerator.java @@ -198,6 +198,8 @@ public interface ResponseGenerator { IPAddressResponse createIPAddressResponse(IpAddress ipAddress); + GuestVlanRangeResponse createDedicatedGuestVlanRangeResponse(GuestVlan result); + GlobalLoadBalancerResponse createGlobalLoadBalancerResponse(GlobalLoadBalancerRule globalLoadBalancerRule); LoadBalancerResponse createLoadBalancerResponse(LoadBalancer loadBalancer); diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/DedicateGuestVlanRangeCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/DedicateGuestVlanRangeCmd.java new file mode 100644 index 00000000000..ec1436065ba --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/network/DedicateGuestVlanRangeCmd.java @@ -0,0 +1,118 @@ +/* + * 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.network; + +import com.cloud.exception.ResourceAllocationException; +import com.cloud.exception.ResourceUnavailableException; +import com.cloud.network.GuestVlan; +import com.cloud.user.Account; +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.BaseCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.response.DomainResponse; +import org.apache.cloudstack.api.response.GuestVlanRangeResponse; +import org.apache.cloudstack.api.response.PhysicalNetworkResponse; +import org.apache.cloudstack.api.response.ProjectResponse; +import org.apache.log4j.Logger; + +@APICommand(name = "dedicateGuestVlanRange", description="Dedicates a guest vlan range to an account", responseObject=GuestVlanRangeResponse.class) +public class DedicateGuestVlanRangeCmd extends BaseCmd { + public static final Logger s_logger = Logger.getLogger(DedicateGuestVlanRangeCmd.class.getName()); + + private static final String s_name = "dedicateguestvlanrangeresponse"; + + ///////////////////////////////////////////////////// + //////////////// API parameters ///////////////////// + ///////////////////////////////////////////////////// + + @Parameter(name=ApiConstants.VLAN_RANGE, type=CommandType.STRING, required=true, + description="guest vlan range to be dedicated") + private String vlan; + + @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, required=true, + description="account who will own the VLAN") + private String accountName; + + @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.UUID, entityType = ProjectResponse.class, + description="project who will own the VLAN") + private Long projectId; + + @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType = DomainResponse.class, + required=true, description="domain ID of the account owning a VLAN") + private Long domainId; + + @Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.UUID, entityType = PhysicalNetworkResponse.class, + required=true, description="physical network ID of the vlan") + private Long physicalNetworkId; + + ///////////////////////////////////////////////////// + /////////////////// Accessors /////////////////////// + ///////////////////////////////////////////////////// + + public String getVlan() { + return vlan; + } + + public String getAccountName() { + return accountName; + } + + public Long getDomainId() { + return domainId; + } + + public Long getPhysicalNetworkId() { + return physicalNetworkId; + } + + public Long getProjectId() { + return projectId; + } + + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public long getEntityOwnerId() { + return Account.ACCOUNT_ID_SYSTEM; + } + + @Override + public void execute() throws ResourceUnavailableException, ResourceAllocationException { + GuestVlan result = _networkService.dedicateGuestVlanRange(this); + if (result != null) { + GuestVlanRangeResponse response = _responseGenerator.createDedicatedGuestVlanRangeResponse(result); + response.setResponseName(getCommandName()); + response.setObjectName("dedicatedguestvlanrange"); + this.setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to dedicate guest vlan range"); + } + } + +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/ListDedicatedGuestVlanRangesCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/ListDedicatedGuestVlanRangesCmd.java new file mode 100644 index 00000000000..7f93efc780f --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/network/ListDedicatedGuestVlanRangesCmd.java @@ -0,0 +1,129 @@ +// 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.network; + +import com.cloud.network.GuestVlan; +import com.cloud.user.Account; +import com.cloud.utils.Pair; +import org.apache.cloudstack.api.*; +import org.apache.cloudstack.api.response.*; +import org.apache.log4j.Logger; + +import java.util.ArrayList; +import java.util.List; + + +@APICommand(name = "listDedicatedGuestVlanRanges", description="Lists dedicated guest vlan ranges", responseObject=GuestVlanRangeResponse.class) +public class ListDedicatedGuestVlanRangesCmd extends BaseListCmd { + public static final Logger s_logger = Logger.getLogger(ListDedicatedGuestVlanRangesCmd.class.getName()); + + private static final String s_name = "listdedicatedguestvlanrangesresponse"; + + ///////////////////////////////////////////////////// + //////////////// API parameters ///////////////////// + ///////////////////////////////////////////////////// + + @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=GuestVlanRangeResponse.class, + description="list dedicated guest vlan ranges by id") + private Long id; + + @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="the account with which the guest VLAN range is associated. Must be used with the domainId parameter.") + private String accountName; + + @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.UUID, entityType = ProjectResponse.class, + description="project who will own the guest VLAN range") + private Long projectId; + + @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType = DomainResponse.class, + description="the domain ID with which the guest VLAN range is associated. If used with the account parameter, returns all guest VLAN ranges for that account in the specified domain.") + private Long domainId; + + @Parameter(name=ApiConstants.GUEST_VLAN_RANGE, type=CommandType.STRING, description="the dedicated guest vlan range") + private String guestVlanRange; + + @Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.UUID, entityType = PhysicalNetworkResponse.class, + description="physical network id of the guest VLAN range") + private Long physicalNetworkId; + + @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class, + description="zone of the guest VLAN range") + private Long zoneId; + + ///////////////////////////////////////////////////// + /////////////////// Accessors /////////////////////// + ///////////////////////////////////////////////////// + + public Long getId() { + return id; + } + + public String getAccountName() { + return accountName; + } + + public Long getDomainId() { + return domainId; + } + + public Long getProjectId() { + return projectId; + } + + public String getGuestVlanRange() { + return guestVlanRange; + } + + public Long getPhysicalNetworkId() { + return physicalNetworkId; + } + + public Long getZoneId() { + return zoneId; + } + + + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public long getEntityOwnerId() { + return Account.ACCOUNT_ID_SYSTEM; + } + + @Override + public void execute(){ + Pair, Integer> vlans = _networkService.listDedicatedGuestVlanRanges(this); + ListResponse response = new ListResponse(); + List guestVlanResponses = new ArrayList(); + for (GuestVlan vlan : vlans.first()) { + GuestVlanRangeResponse guestVlanResponse = _responseGenerator.createDedicatedGuestVlanRangeResponse(vlan); + guestVlanResponse.setObjectName("dedicatedguestvlanrange"); + guestVlanResponses.add(guestVlanResponse); + } + + response.setResponses(guestVlanResponses, vlans.second()); + response.setResponseName(getCommandName()); + this.setResponseObject(response); + } + +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/ReleaseDedicatedGuestVlanRangeCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/ReleaseDedicatedGuestVlanRangeCmd.java new file mode 100644 index 00000000000..76cb42dab19 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/network/ReleaseDedicatedGuestVlanRangeCmd.java @@ -0,0 +1,94 @@ +// 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.network; + +import com.cloud.async.AsyncJob; +import com.cloud.event.EventTypes; +import com.cloud.exception.ResourceInUseException; +import com.cloud.user.Account; +import com.cloud.user.UserContext; +import org.apache.cloudstack.api.*; +import org.apache.cloudstack.api.response.CounterResponse; +import org.apache.cloudstack.api.response.GuestVlanRangeResponse; +import org.apache.cloudstack.api.response.SuccessResponse; +import org.apache.log4j.Logger; + +@APICommand(name = "releaseDedicatedGuestVlanRange", description = "Releases a dedicated guest vlan range to the system", responseObject = SuccessResponse.class) +public class ReleaseDedicatedGuestVlanRangeCmd extends BaseAsyncCmd { + public static final Logger s_logger = Logger.getLogger(ReleaseDedicatedGuestVlanRangeCmd.class.getName()); + private static final String s_name = "releasededicatedguestvlanrangeresponse"; + + // /////////////////////////////////////////////////// + // ////////////// API parameters ///////////////////// + // /////////////////////////////////////////////////// + + @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=GuestVlanRangeResponse.class, + required=true, description="the ID of the dedicated guest vlan range") + private Long id; + + // /////////////////////////////////////////////////// + // ///////////////// Accessors /////////////////////// + // /////////////////////////////////////////////////// + + @Override + public String getCommandName() { + return s_name; + } + + public Long getId() { + return id; + } + + @Override + public AsyncJob.Type getInstanceType() { + return AsyncJob.Type.DedicatedGuestVlanRange; + } + + @Override + public long getEntityOwnerId() { + return Account.ACCOUNT_ID_SYSTEM; + } + + @Override + public String getEventType() { + return EventTypes.EVENT_DEDICATED_GUEST_VLAN_RANGE_RELEASE; + } + + @Override + public String getEventDescription() { + return "Releasing a dedicated guest vlan range."; + } + + // /////////////////////////////////////////////////// + // ///////////// API Implementation/////////////////// + // /////////////////////////////////////////////////// + + + @Override + public void execute(){ + UserContext.current().setEventDetails("Dedicated guest vlan range Id: " + id); + boolean result = _networkService.releaseDedicatedGuestVlanRange(getId()); + if (result) { + SuccessResponse response = new SuccessResponse(getCommandName()); + this.setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to release dedicated guest vlan range"); + } + } + +} 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 a0ec68ef5dd..902dbae00aa 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 @@ -120,7 +120,7 @@ public class EnableStaticNatCmd extends BaseCmd{ @Override public void execute() throws ResourceUnavailableException{ try { - boolean result = _rulesService.enableStaticNat(ipAddressId, virtualMachineId, getNetworkId(), false, getVmSecondaryIp()); + boolean result = _rulesService.enableStaticNat(ipAddressId, virtualMachineId, getNetworkId(), getVmSecondaryIp()); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); this.setResponseObject(response); diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java index 4fc65c37e58..4f2ac750ce5 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java @@ -22,11 +22,12 @@ import com.cloud.user.UserContext; import com.cloud.uservm.UserVm; import org.apache.cloudstack.api.*; import org.apache.cloudstack.api.response.ServiceOfferingResponse; +import org.apache.cloudstack.api.response.SuccessResponse; import org.apache.cloudstack.api.response.UserVmResponse; import org.apache.log4j.Logger; -@APICommand(name = "scaleVirtualMachine", description="Scales the virtual machine to a new service offering.", responseObject=UserVmResponse.class) +@APICommand(name = "scaleVirtualMachine", description="Scales the virtual machine to a new service offering.", responseObject=SuccessResponse.class) public class ScaleVMCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(ScaleVMCmd.class.getName()); private static final String s_name = "scalevirtualmachineresponse"; @@ -83,7 +84,7 @@ public class ScaleVMCmd extends BaseCmd { @Override public void execute(){ //UserContext.current().setEventDetails("Vm Id: "+getId()); - UserVm result = null; + boolean result; try { result = _userVmService.upgradeVirtualMachine(this); } catch (ResourceUnavailableException ex) { @@ -99,9 +100,8 @@ public class ScaleVMCmd extends BaseCmd { s_logger.warn("Exception: ", ex); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); } - if (result != null){ - UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0); - response.setResponseName(getCommandName()); + if (result){ + SuccessResponse response = new SuccessResponse(getCommandName()); this.setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to scale vm"); diff --git a/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/RevertToSnapshotCmd.java b/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/RevertToVMSnapshotCmd.java similarity index 91% rename from api/src/org/apache/cloudstack/api/command/user/vmsnapshot/RevertToSnapshotCmd.java rename to api/src/org/apache/cloudstack/api/command/user/vmsnapshot/RevertToVMSnapshotCmd.java index ea7bf60d6a3..f6d8b2c4a35 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/RevertToSnapshotCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/RevertToVMSnapshotCmd.java @@ -37,11 +37,11 @@ import com.cloud.user.UserContext; import com.cloud.uservm.UserVm; import com.cloud.vm.snapshot.VMSnapshot; -@APICommand(name = "revertToSnapshot",description = "Revert VM from a vmsnapshot.", responseObject = UserVmResponse.class, since="4.2.0") -public class RevertToSnapshotCmd extends BaseAsyncCmd { +@APICommand(name = "revertToVMSnapshot",description = "Revert VM from a vmsnapshot.", responseObject = UserVmResponse.class, since="4.2.0") +public class RevertToVMSnapshotCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger - .getLogger(RevertToSnapshotCmd.class.getName()); - private static final String s_name = "reverttosnapshotresponse"; + .getLogger(RevertToVMSnapshotCmd.class.getName()); + private static final String s_name = "reverttovmsnapshotresponse"; @Parameter(name = ApiConstants.VM_SNAPSHOT_ID, type = CommandType.UUID, required = true,entityType=VMSnapshotResponse.class,description = "The ID of the vm snapshot") private Long vmSnapShotId; diff --git a/api/src/org/apache/cloudstack/api/response/GuestVlanRangeResponse.java b/api/src/org/apache/cloudstack/api/response/GuestVlanRangeResponse.java new file mode 100644 index 00000000000..bf19688c13f --- /dev/null +++ b/api/src/org/apache/cloudstack/api/response/GuestVlanRangeResponse.java @@ -0,0 +1,94 @@ +// 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 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.network.GuestVlan; + +@EntityReference(value=GuestVlan.class) +@SuppressWarnings("unused") +public class GuestVlanRangeResponse extends BaseResponse implements ControlledEntityResponse { + @SerializedName(ApiConstants.ID) @Param(description="the ID of the guest VLAN range") + private String id; + + @SerializedName(ApiConstants.ACCOUNT) @Param(description="the account of the guest VLAN range") + private String accountName; + + @SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the domain ID of the guest VLAN range") + private String domainId; + + @SerializedName(ApiConstants.DOMAIN) @Param(description="the domain name of the guest VLAN range") + private String domainName; + + @SerializedName(ApiConstants.GUEST_VLAN_RANGE) @Param(description="the guest VLAN range") + private String guestVlanRange; + + @SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id of the guest vlan range") + private String projectId; + + @SerializedName(ApiConstants.PROJECT) @Param(description="the project name of the guest vlan range") + private String projectName; + + @SerializedName(ApiConstants.PHYSICAL_NETWORK_ID) @Param(description="the physical network of the guest vlan range") + private Long physicalNetworkId; + + @SerializedName(ApiConstants.ZONE_ID) @Param(description="the zone of the guest vlan range") + private Long zoneId; + + + public void setId(String id) { + this.id = id; + } + + public void setAccountName(String accountName) { + this.accountName = accountName; + } + + public void setDomainId(String domainId) { + this.domainId = domainId; + } + + public void setDomainName(String domainName) { + this.domainName = domainName; + } + + public void setGuestVlanRange(String guestVlanRange) { + this.guestVlanRange = guestVlanRange; + } + + public void setProjectId(String projectId) { + this.projectId = projectId; + } + + public void setProjectName(String projectName) { + this.projectName = projectName; + } + + public void setPhysicalNetworkId(Long physicalNetworkId) { + this.physicalNetworkId = physicalNetworkId; + } + + public void setZoneId(Long zoneId) { + this.zoneId = zoneId; + } + +} diff --git a/api/test/org/apache/cloudstack/api/command/test/ScaleVMCmdTest.java b/api/test/org/apache/cloudstack/api/command/test/ScaleVMCmdTest.java index 301fa02ca29..8a28290e04b 100644 --- a/api/test/org/apache/cloudstack/api/command/test/ScaleVMCmdTest.java +++ b/api/test/org/apache/cloudstack/api/command/test/ScaleVMCmdTest.java @@ -16,31 +16,20 @@ // under the License. package org.apache.cloudstack.api.command.test; -import com.cloud.user.Account; -import com.cloud.user.UserContext; import com.cloud.uservm.UserVm; import com.cloud.vm.UserVmService; import junit.framework.Assert; import junit.framework.TestCase; import org.apache.cloudstack.api.ResponseGenerator; import org.apache.cloudstack.api.ServerApiException; -import org.apache.cloudstack.api.command.admin.region.AddRegionCmd; import org.apache.cloudstack.api.command.user.vm.ScaleVMCmd; -import org.apache.cloudstack.api.response.RegionResponse; -import org.apache.cloudstack.api.response.UserVmResponse; -import org.apache.cloudstack.region.Region; -import org.apache.cloudstack.region.RegionService; + import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockito.Mockito; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - - public class ScaleVMCmdTest extends TestCase{ private ScaleVMCmd scaleVMCmd; @@ -57,12 +46,11 @@ public class ScaleVMCmdTest extends TestCase{ public Long getId() { return 2L; } + @Override + public String getCommandName() { + return "scalevirtualmachineresponse"; + } }; - - //Account account = new AccountVO("testaccount", 1L, "networkdomain", (short) 0, "uuid"); - //UserContext.registerContext(1, account, null, true); - - } @@ -71,11 +59,10 @@ public class ScaleVMCmdTest extends TestCase{ UserVmService userVmService = Mockito.mock(UserVmService.class); - UserVm uservm = Mockito.mock(UserVm.class); try { Mockito.when( userVmService.upgradeVirtualMachine(scaleVMCmd)) - .thenReturn(uservm); + .thenReturn(true); }catch (Exception e){ Assert.fail("Received exception when success expected " +e.getMessage()); } @@ -83,13 +70,6 @@ public class ScaleVMCmdTest extends TestCase{ scaleVMCmd._userVmService = userVmService; responseGenerator = Mockito.mock(ResponseGenerator.class); - UserVmResponse userVmResponse = Mockito.mock(UserVmResponse.class); - List responseList = new ArrayList(); - responseList.add(userVmResponse); - - Mockito.when(responseGenerator.createUserVmResponse("virtualmachine",uservm)) - .thenReturn(responseList); - scaleVMCmd._responseGenerator = responseGenerator; scaleVMCmd.execute(); @@ -101,10 +81,9 @@ public class ScaleVMCmdTest extends TestCase{ UserVmService userVmService = Mockito.mock(UserVmService.class); try { - UserVm uservm = Mockito.mock(UserVm.class); Mockito.when( userVmService.upgradeVirtualMachine(scaleVMCmd)) - .thenReturn(null); + .thenReturn(false); }catch (Exception e){ Assert.fail("Received exception when success expected " +e.getMessage()); } diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in index 2e340bfbfab..d78700b4b64 100644 --- a/client/tomcatconf/applicationContext.xml.in +++ b/client/tomcatconf/applicationContext.xml.in @@ -165,6 +165,7 @@ + diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in index b49e1fbf5ff..7d950fe1696 100644 --- a/client/tomcatconf/commands.properties.in +++ b/client/tomcatconf/commands.properties.in @@ -569,7 +569,7 @@ removeFromGlobalLoadBalancerRule=15 listVMSnapshot=15 createVMSnapshot=15 deleteVMSnapshot=15 -revertToSnapshot=15 +revertToVMSnapshot=15 #### Baremetal commands addBaremetalHost=1 diff --git a/docs/en-US/libcloud-examples.xml b/docs/en-US/libcloud-examples.xml new file mode 100644 index 00000000000..d2db5269eb9 --- /dev/null +++ b/docs/en-US/libcloud-examples.xml @@ -0,0 +1,75 @@ + + +%BOOK_ENTITIES; +]> + + + +
+ Apache Libcloud + There are many tools available to interface with the &PRODUCT; API. Apache Libcloud is one of those. In this section + we provide a basic example of how to use Libcloud with &PRODUCT;. It assumes that you have access to a &PRODUCT; endpoint and that you have the API access key and secret key of a user. + To install Libcloud refer to the libcloud website. If you are familiar with Pypi simply do: + pip install apache-libcloud + You should see the following output: + +pip install apache-libcloud +Downloading/unpacking apache-libcloud + Downloading apache-libcloud-0.12.4.tar.bz2 (376kB): 376kB downloaded + Running setup.py egg_info for package apache-libcloud + +Installing collected packages: apache-libcloud + Running setup.py install for apache-libcloud + +Successfully installed apache-libcloud +Cleaning up... + + + You can then open a Python interactive shell, create an instance of a &PRODUCT; driver and call the available methods via the libcloud API. + + + >> from libcloud.compute.types import Provider +>>> from libcloud.compute.providers import get_driver +>>> Driver = get_driver(Provider.CLOUDSTACK) +>>> apikey='plgWJfZK4gyS3mOMTVmjUVg-X-jlWlnfaUJ9GAbBbf9EdM-kAYMmAiLqzzq1ElZLYq_u38zCm0bewzGUdP66mg' +>>> secretkey='VDaACYb0LV9eNjTetIOElcVQkvJck_J_QljX_FcHRj87ZKiy0z0ty0ZsYBkoXkY9b7eq1EhwJaw7FF3akA3KBQ' +>>> host='http://localhost:8080' +>>> path='/client/api' +>>> conn=Driver(apikey,secretkey,secure='False',host='localhost:8080',path=path) +>>> conn=Driver(key=apikey,secret=secretkey,secure=False,host='localhost',port='8080',path=path) +>>> conn.list_images() +[] +>>> conn.list_sizes() +[, , ] +>>> images=conn.list_images() +>>> offerings=conn.list_sizes() +>>> node=conn.create_node(name='toto',image=images[0],size=offerings[0]) +>>> help(node) +>>> node.get_uuid() +'b1aa381ba1de7f2d5048e248848993d5a900984f' +>>> node.name +u'toto' +]]> + + + One of the interesting use cases of Libcloud is that you can use multiple Cloud Providers, such as AWS, Rackspace, OpenNebula, vCloud and so on. You can then create Driver instances to each of these clouds and create your own multi cloud application. + +
diff --git a/docs/en-US/signing-api-calls-python.xml b/docs/en-US/signing-api-calls-python.xml new file mode 100644 index 00000000000..a2f897f6df1 --- /dev/null +++ b/docs/en-US/signing-api-calls-python.xml @@ -0,0 +1,101 @@ + + +%BOOK_ENTITIES; +]> + + + +
+ How to sign an API call with Python + To illustrate the procedure used to sign API calls we present a step by step interactive session + using Python. + + First import the required modules: + + + >> import urllib2 +>>> import urllib +>>> import hashlib +>>> import hmac +>>> import base64 + ]]> + + + Define the endpoint of the Cloud, the command that you want to execute and the keys of the user. + + >> baseurl='http://localhost:8080/client/api?' +>>> request={} +>>> request['command']='listUsers' +>>> request['response']='json' +>>> request['apikey']='plgWJfZK4gyS3mOMTVmjUVg-X-jlWlnfaUJ9GAbBbf9EdM-kAYMmAiLqzzq1ElZLYq_u38zCm0bewzGUdP66mg' +>>> secretkey='VDaACYb0LV9eNjTetIOElcVQkvJck_J_QljX_FcHRj87ZKiy0z0ty0ZsYBkoXkY9b7eq1EhwJaw7FF3akA3KBQ' + ]]> + + Build the request string: + + >> request_str='&'.join(['='.join([k,urllib.quote_plus(request[k])]) for k in request.keys()]) +>>> request_str +'apikey=plgWJfZK4gyS3mOMTVmjUVg-X-jlWlnfaUJ9GAbBbf9EdM-kAYMmAiLqzzq1ElZLYq_u38zCm0bewzGUdP66mg&command=listUsers&response=json' + ]]> + + + Compute the signature with hmac, do a 64 bit encoding and a url encoding: + + >> sig_str='&'.join(['='.join([k.lower(),urllib.quote_plus(request[k].lower().replace('+','%20'))])for k in sorted(request.iterkeys())]) +>>> sig_str +'apikey=plgwjfzk4gys3momtvmjuvg-x-jlwlnfauj9gabbbf9edm-kaymmailqzzq1elzlyq_u38zcm0bewzgudp66mg&command=listusers&response=json' +>>> sig=hmac.new(secretkey,sig_str,hashlib.sha1) +>>> sig + +>>> sig=hmac.new(secretkey,sig_str,hashlib.sha1).digest() +>>> sig +'M:]\x0e\xaf\xfb\x8f\xf2y\xf1p\x91\x1e\x89\x8a\xa1\x05\xc4A\xdb' +>>> sig=base64.encodestring(hmac.new(secretkey,sig_str,hashlib.sha1).digest()) +>>> sig +'TTpdDq/7j/J58XCRHomKoQXEQds=\n' +>>> sig=base64.encodestring(hmac.new(secretkey,sig_str,hashlib.sha1).digest()).strip() +>>> sig +'TTpdDq/7j/J58XCRHomKoQXEQds=' +>>> sig=urllib.quote_plus(base64.encodestring(hmac.new(secretkey,sig_str,hashlib.sha1).digest()).strip()) + ]]> + + + Finally, build the entire string and do an http GET: + + >> req=baseurl+request_str+'&signature='+sig +>>> req +'http://localhost:8080/client/api?apikey=plgWJfZK4gyS3mOMTVmjUVg-X-jlWlnfaUJ9GAbBbf9EdM-kAYMmAiLqzzq1ElZLYq_u38zCm0bewzGUdP66mg&command=listUsers&response=json&signature=TTpdDq%2F7j%2FJ58XCRHomKoQXEQds%3D' +>>> res=urllib2.urlopen(req) +>>> res.read() +'{ "listusersresponse" : { "count":3 ,"user" : [ {"id":"7ed6d5da-93b2-4545-a502-23d20b48ef2a","username":"admin","firstname":"admin","lastname":"cloud","created":"2012-07-05T12:18:27-0700","state":"enabled","account":"admin","accounttype":1,"domainid":"8a111e58-e155-4482-93ce-84efff3c7c77","domain":"ROOT","apikey":"plgWJfZK4gyS3mOMTVmjUVg-X-jlWlnfaUJ9GAbBbf9EdM-kAYMmAiLqzzq1ElZLYq_u38zCm0bewzGUdP66mg","secretkey":"VDaACYb0LV9eNjTetIOElcVQkvJck_J_QljX_FcHRj87ZKiy0z0ty0ZsYBkoXkY9b7eq1EhwJaw7FF3akA3KBQ","accountid":"7548ac03-af1d-4c1c-9064-2f3e2c0eda0d"}, {"id":"1fea6418-5576-4989-a21e-4790787bbee3","username":"runseb","firstname":"foobar","lastname":"goa","email":"joe@smith.com","created":"2013-04-10T16:52:06-0700","state":"enabled","account":"admin","accounttype":1,"domainid":"8a111e58-e155-4482-93ce-84efff3c7c77","domain":"ROOT","apikey":"Xhsb3MewjJQaXXMszRcLvQI9_NPy_UcbDj1QXikkVbDC9MDSPwWdtZ1bUY1H7JBEYTtDDLY3yuchCeW778GkBA","secretkey":"gIsgmi8C5YwxMHjX5o51pSe0kqs6JnKriw0jJBLceY5bgnfzKjL4aM6ctJX-i1ddQIHJLbLJDK9MRzsKk6xZ_w","accountid":"7548ac03-af1d-4c1c-9064-2f3e2c0eda0d"}, {"id":"52f65396-183c-4473-883f-a37e7bb93967","username":"toto","firstname":"john","lastname":"smith","email":"john@smith.com","created":"2013-04-23T04:27:22-0700","state":"enabled","account":"admin","accounttype":1,"domainid":"8a111e58-e155-4482-93ce-84efff3c7c77","domain":"ROOT","apikey":"THaA6fFWS_OmvU8od201omxFC8yKNL_Hc5ZCS77LFCJsRzSx48JyZucbUul6XYbEg-ZyXMl_wuEpECzK-wKnow","secretkey":"O5ywpqJorAsEBKR_5jEvrtGHfWL1Y_j1E4Z_iCr8OKCYcsPIOdVcfzjJQ8YqK0a5EzSpoRrjOFiLsG0hQrYnDA","accountid":"7548ac03-af1d-4c1c-9064-2f3e2c0eda0d"} ] } }' + ]]> + + +
diff --git a/docs/en-US/signing-api-requests.xml b/docs/en-US/signing-api-requests.xml index 581b32a41ba..fc8773b92c8 100644 --- a/docs/en-US/signing-api-requests.xml +++ b/docs/en-US/signing-api-requests.xml @@ -57,4 +57,7 @@ http://localhost:8080/client/api?command=deployVirtualMachine&serviceOfferingId=1&diskOfferingId=1&templateId=2&zoneId=4&apiKey=miVr6X7u6bN_sdahOBpjNejPgEsT35eXq-jB8CG20YI3yaxXcgpyuaIRmFI_EJTVwZ0nUkkJbPmY3y2bciKwFQ&signature=Lxx1DM40AjcXU%2FcaiK8RAP0O1hU%3D + + + diff --git a/docs/en-US/tools.xml b/docs/en-US/tools.xml index db6a510d593..8cddf28014f 100644 --- a/docs/en-US/tools.xml +++ b/docs/en-US/tools.xml @@ -27,4 +27,5 @@ + diff --git a/patches/systemvm/debian/config/etc/dnsmasq.conf b/patches/systemvm/debian/config/etc/dnsmasq.conf.tmpl similarity index 100% rename from patches/systemvm/debian/config/etc/dnsmasq.conf rename to patches/systemvm/debian/config/etc/dnsmasq.conf.tmpl diff --git a/patches/systemvm/debian/config/etc/init.d/cloud-early-config b/patches/systemvm/debian/config/etc/init.d/cloud-early-config index 6ffd648faeb..ed3894f61cb 100755 --- a/patches/systemvm/debian/config/etc/init.d/cloud-early-config +++ b/patches/systemvm/debian/config/etc/init.d/cloud-early-config @@ -442,6 +442,9 @@ setup_dnsmasq() { [ -z $DHCP_RANGE ] && [ $ETH0_IP ] && DHCP_RANGE=$ETH0_IP [ $ETH0_IP6 ] && DHCP_RANGE_IP6=$ETH0_IP6 [ -z $DOMAIN ] && DOMAIN="cloudnine.internal" + + #get the template + cp /etc/dnsmasq.conf.tmpl /etc/dnsmasq.conf if [ -n "$DOMAIN" ] then diff --git a/patches/systemvm/debian/config/root/edithosts.sh b/patches/systemvm/debian/config/root/edithosts.sh index 8609da79efd..fb0c34fbd42 100755 --- a/patches/systemvm/debian/config/root/edithosts.sh +++ b/patches/systemvm/debian/config/root/edithosts.sh @@ -19,12 +19,6 @@ # edithosts.sh -- edit the dhcphosts file on the routing domain -# $mac : the mac address -# $ip : the associated ip address -# $host : the hostname -# $4 : default router -# $5 : nameserver on default nic -# $6 : comma separated static routes usage() { printf "Usage: %s: -m -4 -6 -h -d -n -s -u [-N]\n" $(basename $0) >&2 @@ -84,6 +78,9 @@ fi grep "redundant_router=1" /var/cache/cloud/cmdline > /dev/null no_redundant=$? +command -v dhcp_release > /dev/null 2>&1 +no_dhcp_release=$? + wait_for_dnsmasq () { local _pid=$(pidof dnsmasq) for i in 0 1 2 3 4 5 6 7 8 9 10 @@ -97,7 +94,15 @@ wait_for_dnsmasq () { return 1 } -logger -t cloud "edithosts: update $1 $2 $3 to hosts" +if [ $no_dhcp_release -eq 0 ] +then + #release previous dhcp lease if present + logger -t cloud "edithosts: releasing $ipv4" + dhcp_release lo $ipv4 $(grep $ipv4 $DHCP_LEASES | awk '{print $2}') > /dev/null 2>&1 + logger -t cloud "edithosts: released $ipv4" +fi + +logger -t cloud "edithosts: update $mac $ipv4 $ipv6 $host to hosts" [ ! -f $DHCP_HOSTS ] && touch $DHCP_HOSTS [ ! -f $DHCP_OPTS ] && touch $DHCP_OPTS @@ -201,8 +206,13 @@ fi pid=$(pidof dnsmasq) if [ "$pid" != "" ] then - #service dnsmasq restart - kill -HUP $pid + # use SIGHUP to avoid service outage if dhcp_release is available. + if [ $no_dhcp_release -eq 0 ] + then + kill -HUP $pid + else + service dnsmasq restart + fi else if [ $no_redundant -eq 1 ] then diff --git a/plugins/network-elements/bigswitch-vns/src/com/cloud/network/element/BigSwitchVnsElement.java b/plugins/network-elements/bigswitch-vns/src/com/cloud/network/element/BigSwitchVnsElement.java index 4ee9c93ffcc..411feab7339 100644 --- a/plugins/network-elements/bigswitch-vns/src/com/cloud/network/element/BigSwitchVnsElement.java +++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/network/element/BigSwitchVnsElement.java @@ -138,7 +138,7 @@ public class BigSwitchVnsElement extends AdapterBase implements if (network.getBroadcastDomainType() != BroadcastDomainType.Lswitch) { return false; } -/* + if (!_networkModel.isProviderForNetwork(getProvider(), network.getId())) { s_logger.debug("BigSwitchVnsElement is not a provider for network " @@ -153,7 +153,7 @@ public class BigSwitchVnsElement extends AdapterBase implements + network.getDisplayText()); return false; } -*/ + return true; } diff --git a/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java b/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java index 677bc785b2c..98e14618248 100644 --- a/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java +++ b/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java @@ -1618,7 +1618,9 @@ public class NetscalerResource implements ServerResource { String srcIp = rule.getSrcIp(); String dstIP = rule.getDstIp(); String iNatRuleName = generateInatRuleName(srcIp, dstIP); + String rNatRuleName = generateRnatRuleName(srcIp, dstIP); inat iNatRule = null; + rnat rnatRule = null; if (!rule.revoked()) { try { @@ -1645,9 +1647,47 @@ public class NetscalerResource implements ServerResource { } s_logger.debug("Created Inat rule on the Netscaler device " + _ip + " to enable static NAT from " + srcIp + " to " + dstIP); } + try { + rnat[] rnatRules = rnat.get(_netscalerService); + if (rnatRules != null) { + for (rnat rantrule : rnatRules) { + if (rantrule.get_network().equalsIgnoreCase(rNatRuleName)) { + rnatRule = rantrule; + break; + } + } + } + } catch (nitro_exception e) { + throw e; + } + + if (rnatRule == null) { + rnatRule = new rnat(); + rnatRule.set_natip(srcIp); + rnatRule.set_network(dstIP); + rnatRule.set_netmask("255.255.255.255"); + try { + apiCallResult = rnat.update(_netscalerService, rnatRule); + } catch (nitro_exception e) { + if (e.getErrorCode() != NitroError.NS_RESOURCE_EXISTS) { + throw e; + } + } + s_logger.debug("Created Rnat rule on the Netscaler device " + _ip + " to enable revese static NAT from " + dstIP + " to " + srcIp); + } } else { try { inat.delete(_netscalerService, iNatRuleName); + rnat[] rnatRules = rnat.get(_netscalerService); + if (rnatRules != null) { + for (rnat rantrule : rnatRules) { + if (rantrule.get_network().equalsIgnoreCase(dstIP)) { + rnatRule = rantrule; + rnat.clear(_netscalerService, rnatRule); + break; + } + } + } } catch (nitro_exception e) { if (e.getErrorCode() != NitroError.NS_RESOURCE_NOT_EXISTS) { throw e; @@ -2257,6 +2297,7 @@ public class NetscalerResource implements ServerResource { } csMon.set_interval(hcp.getHealthcheckInterval()); + csMon.set_retries(Math.max(hcp.getHealthcheckThresshold(), hcp.getUnhealthThresshold()) + 1); csMon.set_resptimeout(hcp.getResponseTime()); csMon.set_failureretries(hcp.getUnhealthThresshold()); csMon.set_successretries(hcp.getHealthcheckThresshold()); @@ -3090,6 +3131,10 @@ public class NetscalerResource implements ServerResource { return genObjectName("Cloud-Inat", srcIp); } + private String generateRnatRuleName(String srcIp, String dstIP) { + return genObjectName("Cloud-Rnat", srcIp); + } + private String generateNSVirtualServerName(String srcIp, long srcPort) { return genObjectName("Cloud-VirtualServer", srcIp, srcPort); } diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpTag.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpTag.java index f8282b86d9c..157c3b522c7 100644 --- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpTag.java +++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpTag.java @@ -16,7 +16,10 @@ // under the License. package com.cloud.network.nicira; +import org.apache.log4j.Logger; + public class NiciraNvpTag { + private static final Logger s_logger = Logger.getLogger(NiciraNvpTag.class); private String scope; private String tag; @@ -24,7 +27,12 @@ public class NiciraNvpTag { public NiciraNvpTag(String scope, String tag) { this.scope = scope; - this.tag = tag; + if (tag.length() > 40) { + s_logger.warn("tag \"" + tag + "\" too long, truncating to 40 characters"); + this.tag = tag.substring(0, 40); + } else { + this.tag = tag; + } } public String getScope() { @@ -40,7 +48,12 @@ public class NiciraNvpTag { } public void setTag(String tag) { - this.tag = tag; + if (tag.length() > 40) { + s_logger.warn("tag \"" + tag + "\" too long, truncating to 40 characters"); + this.tag = tag.substring(0, 40); + } else { + this.tag = tag; + } } } diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraTagTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraTagTest.java new file mode 100644 index 00000000000..fd13e07ab59 --- /dev/null +++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraTagTest.java @@ -0,0 +1,54 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// 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.nicira; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class NiciraTagTest { + @Test + public void testCreateTag() { + NiciraNvpTag tag = new NiciraNvpTag("scope","tag"); + assertEquals("scope part set", "scope", tag.getScope()); + assertEquals("tag part set", "tag", tag.getTag()); + } + + @Test + public void testCreateLongTag() { + NiciraNvpTag tag = new NiciraNvpTag("scope","verylongtagthatshouldattheminimumexceedthefortycharacterlenght"); + assertEquals("scope part set", "scope", tag.getScope()); + assertEquals("tag part set", "verylongtagthatshouldattheminimumexceedt", tag.getTag()); + } + + @Test + public void testSetTag() { + NiciraNvpTag tag = new NiciraNvpTag(); + tag.setScope("scope"); + tag.setTag("tag"); + assertEquals("scope part set", "scope", tag.getScope()); + assertEquals("tag part set", "tag", tag.getTag()); + } + + @Test + public void testSetLongTag() { + NiciraNvpTag tag = new NiciraNvpTag(); + tag.setScope("scope"); + tag.setTag("verylongtagthatshouldattheminimumexceedthefortycharacterlenght"); + assertEquals("scope part set", "scope", tag.getScope()); + assertEquals("tag part set", "verylongtagthatshouldattheminimumexceedt", tag.getTag()); + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 9526d92c112..57073e3b19a 100644 --- a/pom.xml +++ b/pom.xml @@ -399,7 +399,7 @@ patches/systemvm/debian/config/etc/apache2/sites-available/default patches/systemvm/debian/config/etc/apache2/sites-available/default-ssl patches/systemvm/debian/config/etc/apache2/vhostexample.conf - patches/systemvm/debian/config/etc/dnsmasq.conf + patches/systemvm/debian/config/etc/dnsmasq.conf.tmpl patches/systemvm/debian/config/etc/vpcdnsmasq.conf patches/systemvm/debian/config/etc/ssh/sshd_config patches/systemvm/debian/config/etc/rsyslog.conf diff --git a/scripts/network/exdhcp/dnsmasq_edithosts.sh b/scripts/network/exdhcp/dnsmasq_edithosts.sh index 05285d9accf..7990356edc4 100755 --- a/scripts/network/exdhcp/dnsmasq_edithosts.sh +++ b/scripts/network/exdhcp/dnsmasq_edithosts.sh @@ -35,6 +35,9 @@ wait_for_dnsmasq () { return 1 } +command -v dhcp_release > /dev/null 2>&1 +no_dhcp_release=$? + [ ! -f /etc/dhcphosts.txt ] && touch /etc/dhcphosts.txt [ ! -f /var/lib/misc/dnsmasq.leases ] && touch /var/lib/misc/dnsmasq.leases @@ -44,6 +47,12 @@ sed -i /$3,/d /etc/dhcphosts.txt echo "$1,$2,$3,infinite" >>/etc/dhcphosts.txt +#release previous dhcp lease if present +if [ $no_dhcp_release -eq 0 ] +then + dhcp_release lo $2 $(grep $2 $DHCP_LEASES | awk '{print $2}') > /dev/null 2>&1 +fi + #delete leases to supplied mac and ip addresses sed -i /$1/d /var/lib/misc/dnsmasq.leases sed -i /"$2 "/d /var/lib/misc/dnsmasq.leases @@ -61,9 +70,13 @@ echo "$2 $3" >> /etc/hosts pid=$(pidof dnsmasq) if [ "$pid" != "" ] then - # send SIGHUP to dnsmasq to reload /etc/hosts /etc/dhcphosts.txt - # this will not reload /etc/dnsmasq.conf - kill -s 1 $pid + # use SIGHUP to avoid service outage if dhcp_release is available. + if [ $no_dhcp_release -eq 0 ] + then + kill -HUP $pid + else + service dnsmasq restart + fi else service dnsmasq start wait_for_dnsmasq diff --git a/server/src/com/cloud/api/ApiDBUtils.java b/server/src/com/cloud/api/ApiDBUtils.java index e291c844a8c..b8eea12b4cf 100755 --- a/server/src/com/cloud/api/ApiDBUtils.java +++ b/server/src/com/cloud/api/ApiDBUtils.java @@ -130,6 +130,8 @@ import com.cloud.host.HostVO; import com.cloud.host.dao.HostDao; import com.cloud.host.dao.HostDetailsDao; import com.cloud.hypervisor.Hypervisor.HypervisorType; +import com.cloud.network.dao.AccountGuestVlanMapDao; +import com.cloud.network.dao.AccountGuestVlanMapVO; import com.cloud.network.IpAddress; import com.cloud.network.Network; import com.cloud.network.Network.Capability; @@ -309,6 +311,7 @@ public class ApiDBUtils { static GuestOSDao _guestOSDao; static GuestOSCategoryDao _guestOSCategoryDao; static HostDao _hostDao; + static AccountGuestVlanMapDao _accountGuestVlanMapDao; static IPAddressDao _ipAddressDao; static LoadBalancerDao _loadBalancerDao; static SecurityGroupDao _securityGroupDao; @@ -416,6 +419,7 @@ public class ApiDBUtils { @Inject private GuestOSDao guestOSDao; @Inject private GuestOSCategoryDao guestOSCategoryDao; @Inject private HostDao hostDao; + @Inject private AccountGuestVlanMapDao accountGuestVlanMapDao; @Inject private IPAddressDao ipAddressDao; @Inject private LoadBalancerDao loadBalancerDao; @Inject private SecurityGroupDao securityGroupDao; @@ -512,6 +516,7 @@ public class ApiDBUtils { _templateMgr = templateMgr; _accountDao = accountDao; + _accountGuestVlanMapDao = accountGuestVlanMapDao; _accountVlanMapDao = accountVlanMapDao; _clusterDao = clusterDao; _capacityDao = capacityDao; @@ -945,6 +950,15 @@ public class ApiDBUtils { } } + public static Long getAccountIdForGuestVlan(long vlanDbId) { + List accountGuestVlanMaps = _accountGuestVlanMapDao.listAccountGuestVlanMapsByVlan(vlanDbId); + if (accountGuestVlanMaps.isEmpty()) { + return null; + } else { + return accountGuestVlanMaps.get(0).getAccountId(); + } + } + public static HypervisorType getVolumeHyperType(long volumeId) { return _volumeDao.getHypervisorType(volumeId); } diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index 790c366cb0d..2804d1e97f3 100755 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -180,7 +180,9 @@ import com.cloud.event.Event; import com.cloud.host.Host; import com.cloud.host.HostVO; import com.cloud.hypervisor.HypervisorCapabilities; +import com.cloud.network.dao.AccountGuestVlanMapVO; import com.cloud.network.IpAddress; +import com.cloud.network.GuestVlan; import com.cloud.network.Network; import com.cloud.network.Network.Capability; import com.cloud.network.Network.Provider; @@ -2725,6 +2727,25 @@ public class ApiResponseHelper implements ResponseGenerator { return response; } + @Override + public GuestVlanRangeResponse createDedicatedGuestVlanRangeResponse(GuestVlan vlan) { + GuestVlanRangeResponse guestVlanRangeResponse = new GuestVlanRangeResponse(); + + guestVlanRangeResponse.setId(vlan.getUuid()); + Long accountId= ApiDBUtils.getAccountIdForGuestVlan(vlan.getId()); + Account owner = ApiDBUtils.findAccountById(accountId); + if (owner != null) { + populateAccount(guestVlanRangeResponse, owner.getId()); + populateDomain(guestVlanRangeResponse, owner.getDomainId()); + } + guestVlanRangeResponse.setGuestVlanRange(vlan.getGuestVlanRange()); + guestVlanRangeResponse.setPhysicalNetworkId(vlan.getPhysicalNetworkId()); + PhysicalNetworkVO physicalNetwork = ApiDBUtils.findPhysicalNetworkById(vlan.getPhysicalNetworkId()); + guestVlanRangeResponse.setZoneId(physicalNetwork.getDataCenterId()); + + return guestVlanRangeResponse; + } + @Override public ServiceResponse createNetworkServiceResponse(Service service) { ServiceResponse response = new ServiceResponse(); diff --git a/server/src/com/cloud/dc/DataCenterVnetVO.java b/server/src/com/cloud/dc/DataCenterVnetVO.java index 52d7ad2067b..9bae132fb16 100755 --- a/server/src/com/cloud/dc/DataCenterVnetVO.java +++ b/server/src/com/cloud/dc/DataCenterVnetVO.java @@ -56,6 +56,9 @@ public class DataCenterVnetVO implements InternalIdentity { @Column(name="reservation_id") protected String reservationId; + + @Column(name="account_vnet_map_id") + protected Long accountGuestVlanMapId; public Date getTakenAt() { return takenAt; @@ -103,6 +106,14 @@ public class DataCenterVnetVO implements InternalIdentity { public long getPhysicalNetworkId() { return physicalNetworkId; } + + public void setAccountGuestVlanMapId(Long accountGuestVlanMapId) { + this.accountGuestVlanMapId = accountGuestVlanMapId; + } + + public Long getAccountGuestVlanMapId() { + return accountGuestVlanMapId; + } protected DataCenterVnetVO() { } diff --git a/server/src/com/cloud/dc/dao/DataCenterDaoImpl.java b/server/src/com/cloud/dc/dao/DataCenterDaoImpl.java index 4afd640d314..4d9d01065ca 100755 --- a/server/src/com/cloud/dc/dao/DataCenterDaoImpl.java +++ b/server/src/com/cloud/dc/dao/DataCenterDaoImpl.java @@ -16,6 +16,7 @@ // under the License. package com.cloud.dc.dao; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Random; @@ -33,6 +34,8 @@ import com.cloud.dc.DataCenterLinkLocalIpAddressVO; import com.cloud.dc.DataCenterVO; import com.cloud.dc.DataCenterVnetVO; import com.cloud.dc.PodVlanVO; +import com.cloud.network.dao.AccountGuestVlanMapDao; +import com.cloud.network.dao.AccountGuestVlanMapVO; import com.cloud.org.Grouping; import com.cloud.utils.NumbersUtil; import com.cloud.utils.Pair; @@ -68,6 +71,7 @@ public class DataCenterDaoImpl extends GenericDaoBase implem @Inject protected DataCenterVnetDao _vnetAllocDao = null; @Inject protected PodVlanDao _podVlanAllocDao = null; @Inject protected DcDetailsDao _detailsDao = null; + @Inject protected AccountGuestVlanMapDao _accountGuestVlanMapDao = null; protected long _prefix; protected Random _rand = new Random(System.currentTimeMillis()); @@ -189,11 +193,20 @@ public class DataCenterDaoImpl extends GenericDaoBase implem @Override public String allocateVnet(long dataCenterId, long physicalNetworkId, long accountId, String reservationId) { - DataCenterVnetVO vo = _vnetAllocDao.take(physicalNetworkId, accountId, reservationId); + ArrayList dedicatedVlanDbIds = new ArrayList(); + List maps = _accountGuestVlanMapDao.listAccountGuestVlanMapsByAccount(accountId); + for (AccountGuestVlanMapVO map : maps) { + dedicatedVlanDbIds.add(map.getId()); + } + if (dedicatedVlanDbIds != null && !dedicatedVlanDbIds.isEmpty()) { + DataCenterVnetVO vo = _vnetAllocDao.take(physicalNetworkId, accountId, reservationId, dedicatedVlanDbIds); + if (vo != null) + return vo.getVnet(); + } + DataCenterVnetVO vo = _vnetAllocDao.take(physicalNetworkId, accountId, reservationId, null); if (vo == null) { return null; } - return vo.getVnet(); } diff --git a/server/src/com/cloud/dc/dao/DataCenterVnetDao.java b/server/src/com/cloud/dc/dao/DataCenterVnetDao.java index 7fb68dcd7ac..778498d8898 100644 --- a/server/src/com/cloud/dc/dao/DataCenterVnetDao.java +++ b/server/src/com/cloud/dc/dao/DataCenterVnetDao.java @@ -37,8 +37,13 @@ public interface DataCenterVnetDao extends GenericDao { public void lockRange(long dcId, long physicalNetworkId, Integer start, Integer end); - public DataCenterVnetVO take(long physicalNetworkId, long accountId, String reservationId); + public DataCenterVnetVO take(long physicalNetworkId, long accountId, String reservationId, List vlanDbIds); public void release(String vnet, long physicalNetworkId, long accountId, String reservationId); + public void releaseDedicatedGuestVlans(Long dedicatedGuestVlanRangeId); + + public int countVnetsAllocatedToAccount(long dcId, long accountId); + + public int countVnetsDedicatedToAccount(long dcId, long accountId); } diff --git a/server/src/com/cloud/dc/dao/DataCenterVnetDaoImpl.java b/server/src/com/cloud/dc/dao/DataCenterVnetDaoImpl.java index 2e044394ddc..e97f2c62ee3 100755 --- a/server/src/com/cloud/dc/dao/DataCenterVnetDaoImpl.java +++ b/server/src/com/cloud/dc/dao/DataCenterVnetDaoImpl.java @@ -20,15 +20,22 @@ import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.Date; import java.util.List; +import java.util.Map; + +import javax.inject.Inject; +import javax.naming.ConfigurationException; import com.cloud.exception.InvalidParameterValueException; import org.springframework.stereotype.Component; import com.cloud.dc.DataCenterVnetVO; +import com.cloud.network.dao.AccountGuestVlanMapDao; +import com.cloud.network.dao.AccountGuestVlanMapVO; import com.cloud.utils.db.DB; import com.cloud.utils.db.GenericDao; import com.cloud.utils.db.GenericDaoBase; import com.cloud.utils.db.GenericSearchBuilder; +import com.cloud.utils.db.JoinBuilder; import com.cloud.utils.db.SearchBuilder; import com.cloud.utils.db.SearchCriteria; import com.cloud.utils.db.SearchCriteria.Func; @@ -43,7 +50,9 @@ import com.cloud.utils.exception.CloudRuntimeException; @Component @DB(txn=false) public class DataCenterVnetDaoImpl extends GenericDaoBase implements DataCenterVnetDao { + private final SearchBuilder FreeVnetSearch; + private final SearchBuilder FreeDedicatedVnetSearch; private final SearchBuilder VnetDcSearch; private final SearchBuilder VnetDcSearchAllocated; private final SearchBuilder DcSearchAllocated; @@ -51,6 +60,12 @@ public class DataCenterVnetDaoImpl extends GenericDaoBase countZoneVlans; private final GenericSearchBuilder countAllocatedZoneVlans; private final SearchBuilder SearchRange; + private final SearchBuilder DedicatedGuestVlanRangeSearch; + private final GenericSearchBuilder countVnetsAllocatedToAccount; + protected GenericSearchBuilder countVnetsDedicatedToAccount; + protected SearchBuilder AccountGuestVlanMapSearch; + + @Inject protected AccountGuestVlanMapDao _accountGuestVlanMapDao; public List listAllocatedVnets(long physicalNetworkId) { SearchCriteria sc = DcSearchAllocated.create(); @@ -141,9 +156,15 @@ public class DataCenterVnetDaoImpl extends GenericDaoBase sc = FreeVnetSearch.create(); - sc.setParameters("physicalNetworkId", physicalNetworkId); + public DataCenterVnetVO take(long physicalNetworkId, long accountId, String reservationId, List vlanDbIds) { + SearchCriteria sc; + if (vlanDbIds != null) { + sc = FreeDedicatedVnetSearch.create(); + sc.setParameters("accountGuestVlanMapId", vlanDbIds.toArray()); + } else { + sc = FreeVnetSearch.create(); + } + sc.setParameters("physicalNetworkId", physicalNetworkId); Date now = new Date(); Transaction txn = Transaction.currentTxn(); txn.start(); @@ -160,6 +181,7 @@ public class DataCenterVnetDaoImpl extends GenericDaoBase sc = VnetDcSearchAllocated.create(); sc.setParameters("vnet", vnet); @@ -178,6 +200,51 @@ public class DataCenterVnetDaoImpl extends GenericDaoBase sc = DedicatedGuestVlanRangeSearch.create(); + sc.setParameters("dedicatedGuestVlanRangeId", dedicatedGuestVlanRangeId); + List vnets = listBy(sc); + for(DataCenterVnetVO vnet : vnets) { + vnet.setAccountGuestVlanMapId(null); + update(vnet.getId(), vnet); + } + } + + @Override + public int countVnetsAllocatedToAccount(long dcId, long accountId) { + SearchCriteria sc = countVnetsAllocatedToAccount.create(); + sc.setParameters("dc", dcId); + sc.setParameters("accountId", accountId); + return customSearch(sc, null).get(0); + } + + @Override + public int countVnetsDedicatedToAccount(long dcId, long accountId) { + SearchCriteria sc = countVnetsDedicatedToAccount.create(); + sc.setParameters("dc", dcId); + sc.setParameters("accountId", accountId); + return customSearch(sc, null).get(0); + } + + @Override + public boolean configure(String name, Map params) throws ConfigurationException { + boolean result = super.configure(name, params); + + countVnetsDedicatedToAccount = createSearchBuilder(Integer.class); + countVnetsDedicatedToAccount.and("dc", countVnetsDedicatedToAccount.entity().getDataCenterId(), SearchCriteria.Op.EQ); + countVnetsDedicatedToAccount.and("accountGuestVlanMapId", countVnetsDedicatedToAccount.entity().getAccountGuestVlanMapId(), Op.NNULL); + AccountGuestVlanMapSearch = _accountGuestVlanMapDao.createSearchBuilder(); + AccountGuestVlanMapSearch.and("accountId", AccountGuestVlanMapSearch.entity().getAccountId(), SearchCriteria.Op.EQ); + countVnetsDedicatedToAccount.join("AccountGuestVlanMapSearch", AccountGuestVlanMapSearch, countVnetsDedicatedToAccount.entity().getAccountGuestVlanMapId(), + AccountGuestVlanMapSearch.entity().getId(), JoinBuilder.JoinType.INNER); + countVnetsDedicatedToAccount.select(null, Func.COUNT, countVnetsDedicatedToAccount.entity().getId()); + countVnetsDedicatedToAccount.done(); + AccountGuestVlanMapSearch.done(); + + return result; + } + public DataCenterVnetDaoImpl() { super(); DcSearchAllocated = createSearchBuilder(); @@ -202,7 +269,15 @@ public class DataCenterVnetDaoImpl extends GenericDaoBase _networkGurus; public List getNetworkGurus() { @@ -1998,8 +2003,29 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L // For Isolated networks, don't allow to create network with vlan that already exists in the zone if (ntwkOff.getGuestType() == GuestType.Isolated) { if (_networksDao.countByZoneAndUri(zoneId, uri) > 0) { - throw new InvalidParameterValueException("Network with vlan " + vlanId + " already exists in zone " + zoneId); - } + throw new InvalidParameterValueException("Network with vlan " + vlanId + " already exists in zone " + zoneId); + } else { + DataCenterVnetVO dcVnet = _datacenterVnetDao.findVnet(zoneId, vlanId.toString()).get(0); + // Fail network creation if specified vlan is dedicated to a different account + if (dcVnet.getAccountGuestVlanMapId() != null) { + Long accountGuestVlanMapId = dcVnet.getAccountGuestVlanMapId(); + AccountGuestVlanMapVO map = _accountGuestVlanMapDao.findById(accountGuestVlanMapId); + if (map.getAccountId() != owner.getAccountId()) { + throw new InvalidParameterValueException("Vlan " + vlanId + " is dedicated to a different account"); + } + // Fail network creation if owner has a dedicated range of vlans but the specified vlan belongs to the system pool + } else { + List maps = _accountGuestVlanMapDao.listAccountGuestVlanMapsByAccount(owner.getAccountId()); + if (maps != null && !maps.isEmpty()) { + int vnetsAllocatedToAccount = _datacenterVnetDao.countVnetsAllocatedToAccount(zoneId, owner.getAccountId()); + int vnetsDedicatedToAccount = _datacenterVnetDao.countVnetsDedicatedToAccount(zoneId, owner.getAccountId()); + if (vnetsAllocatedToAccount < vnetsDedicatedToAccount) { + throw new InvalidParameterValueException("Specified vlan " + vlanId + " doesn't belong" + + " to the vlan range dedicated to the owner "+ owner.getAccountName()); + } + } + } + } } else { // don't allow to creating shared network with given Vlan ID, if there already exists a isolated network or // shared network with same Vlan ID in the zone @@ -2008,7 +2034,10 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L throw new InvalidParameterValueException("There is a isolated/shared network with vlan id: " + vlanId + " already exists " + "in zone " + zoneId); } - } + } + + + } // If networkDomain is not specified, take it from the global configuration diff --git a/server/src/com/cloud/network/NetworkModelImpl.java b/server/src/com/cloud/network/NetworkModelImpl.java index 7b712ea9781..fdf722c33de 100755 --- a/server/src/com/cloud/network/NetworkModelImpl.java +++ b/server/src/com/cloud/network/NetworkModelImpl.java @@ -924,9 +924,9 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel { } } if (isUserVmsDefaultNetwork || isDomRGuestOrPublicNetwork) { - return _configMgr.getServiceOfferingNetworkRate(vm.getServiceOfferingId(), vm.getDataCenterId()); + return _configMgr.getServiceOfferingNetworkRate(vm.getServiceOfferingId(), network.getDataCenterId()); } else { - return _configMgr.getNetworkOfferingNetworkRate(ntwkOff.getId(), vm.getDataCenterId()); + return _configMgr.getNetworkOfferingNetworkRate(ntwkOff.getId(), network.getDataCenterId()); } } diff --git a/server/src/com/cloud/network/NetworkServiceImpl.java b/server/src/com/cloud/network/NetworkServiceImpl.java index b2db06cad54..230d907aaa3 100755 --- a/server/src/com/cloud/network/NetworkServiceImpl.java +++ b/server/src/com/cloud/network/NetworkServiceImpl.java @@ -85,6 +85,8 @@ 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; @@ -203,6 +205,8 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { HostPodDao _hostPodDao; @Inject DataCenterVnetDao _datacneter_vnet; + @Inject + AccountGuestVlanMapDao _accountGuestVlanMapDao; int _cidrLimit; boolean _allowSubdomainNetworkAccess; @@ -426,17 +430,19 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { } // if shared network in the advanced zone, then check the caller against the network for 'AccessType.UseNetwork' - if (isSharedNetworkOfferingWithServices(network.getNetworkOfferingId()) && zone.getNetworkType() == NetworkType.Advanced) { - 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()); + 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()); + } + return _networkMgr.allocateIp(ipOwner, false, caller, callerUserId, zone); + } 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"); } - return _networkMgr.allocateIp(ipOwner, false, caller, callerUserId, zone); - } 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"); } } } @@ -2532,6 +2538,19 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { txn.close(); throw new InvalidParameterValueException("Some of the vnets from this range are allocated, can only remove a range which has no allocated vnets"); } + // If the range is partially dedicated to an account fail the request + List maps = _accountGuestVlanMapDao.listAccountGuestVlanMapsByPhysicalNetwork(network.getId()); + for (AccountGuestVlanMapVO map : maps) { + String[] vlans = map.getGuestVlanRange().split("-"); + Integer dedicatedStartVlan = Integer.parseInt(vlans[0]); + Integer dedicatedEndVlan = Integer.parseInt(vlans[1]); + if ((start >= dedicatedStartVlan && start <= dedicatedEndVlan) || (end >= dedicatedStartVlan && end <= dedicatedEndVlan)) { + txn.close(); + throw new InvalidParameterValueException("Vnet range " + map.getGuestVlanRange() + " is dedicated" + + " to an account. The specified range " + start + "-" + end + " overlaps with the dedicated range " + + " Please release the overlapping dedicated range before deleting the range"); + } + } for (i=0; i= end){ temp = existingRanges.get(i).second(); @@ -2562,6 +2581,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { _physicalNetworkDao.update(network.getId(), network); txn.commit(); _physicalNetworkDao.releaseFromLockTable(network.getId()); + return true; } @@ -2698,6 +2718,260 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { } + @Override + @DB + @ActionEvent(eventType = EventTypes.EVENT_GUEST_VLAN_RANGE_DEDICATE, eventDescription = "dedicating guest vlan range", async = false) + public GuestVlan dedicateGuestVlanRange(DedicateGuestVlanRangeCmd cmd) { + String vlan = cmd.getVlan(); + String accountName = cmd.getAccountName(); + Long domainId = cmd.getDomainId(); + Long physicalNetworkId = cmd.getPhysicalNetworkId(); + Long projectId = cmd.getProjectId(); + + int startVlan, endVlan; + String updatedVlanRange = null; + long guestVlanMapId = 0; + long guestVlanMapAccountId = 0; + + // Verify account is valid + Account vlanOwner = null; + if (projectId != null) { + if (accountName != null) { + throw new InvalidParameterValueException("accountName and projectId are mutually exclusive"); + } + Project project = _projectMgr.getProject(projectId); + if (project == null) { + throw new InvalidParameterValueException("Unable to find project by id " + projectId); + } + vlanOwner = _accountMgr.getAccount(project.getProjectAccountId()); + } + + if ((accountName != null) && (domainId != null)) { + vlanOwner = _accountDao.findActiveAccount(accountName, domainId); + if (vlanOwner == null) { + throw new InvalidParameterValueException("Unable to find account by name " + accountName); + } + } + + // Verify physical network isolation type is VLAN + PhysicalNetworkVO physicalNetwork = _physicalNetworkDao.findById(physicalNetworkId); + if (physicalNetwork == null ) { + throw new InvalidParameterValueException("Unable to find physical network by id " + physicalNetworkId); + } else if (physicalNetwork.getIsolationMethods() == null || !physicalNetwork.getIsolationMethods().contains("VLAN")) { + throw new InvalidParameterValueException("Cannot dedicate guest vlan range. " + + "Physical isolation type of network " + physicalNetworkId + " is not VLAN"); + } + + // Get the start and end vlan + String[] vlanRange = vlan.split("-"); + if (vlanRange.length != 2) { + throw new InvalidParameterValueException("Invalid format for parameter value vlan " + vlan + " .Vlan should be specified as 'startvlan-endvlan'"); + } + + try { + startVlan = Integer.parseInt(vlanRange[0]); + endVlan = Integer.parseInt(vlanRange[1]); + } catch (NumberFormatException e) { + s_logger.warn("Unable to parse guest vlan range:", e); + throw new InvalidParameterValueException("Please provide valid guest vlan range"); + } + + // Verify guest vlan range exists in the system + List > existingRanges = physicalNetwork.getVnet(); + Boolean exists = false; + if (!existingRanges.isEmpty()) { + for (int i=0 ; i < existingRanges.size(); i++){ + int existingStartVlan = existingRanges.get(i).first(); + int existingEndVlan = existingRanges.get(i).second(); + if (startVlan >= existingStartVlan && endVlan <= existingEndVlan) { + exists = true; + break; + } + } + if (!exists) { + throw new InvalidParameterValueException("Unable to find guest vlan by range " + vlan); + } + } + + // Verify guest vlans in the range don't belong to a network of a different account + for (int i = startVlan; i <= endVlan; i++) { + List allocatedVlans = _datacneter_vnet.listAllocatedVnetsInRange(physicalNetwork.getDataCenterId(), physicalNetwork.getId(), startVlan, endVlan); + if (allocatedVlans != null && !allocatedVlans.isEmpty()){ + for (DataCenterVnetVO allocatedVlan : allocatedVlans) { + if (allocatedVlan.getAccountId() != vlanOwner.getAccountId()) { + throw new InvalidParameterValueException("Guest vlan from this range " + allocatedVlan.getVnet() + " is allocated to a different account." + + " Can only dedicate a range which has no allocated vlans or has vlans allocated to the same account "); + } + } + } + } + + List guestVlanMaps = _accountGuestVlanMapDao.listAccountGuestVlanMapsByPhysicalNetwork(physicalNetworkId); + for (AccountGuestVlanMapVO guestVlanMap : guestVlanMaps) { + List vlanTokens = getVlanFromRange(guestVlanMap.getGuestVlanRange()); + int dedicatedStartVlan = vlanTokens.get(0).intValue(); + int dedicatedEndVlan = vlanTokens.get(1).intValue(); + guestVlanMapId = guestVlanMap.getId(); + guestVlanMapAccountId = guestVlanMap.getAccountId(); + + // Verify if range is already dedicated + if (startVlan >= dedicatedStartVlan && endVlan <= dedicatedEndVlan) { + if (guestVlanMap.getAccountId() != vlanOwner.getAccountId()) { + throw new InvalidParameterValueException("Vlan range is already dedicated to another account. Cannot dedicate guest vlan range " + vlan); + } else { + s_logger.debug("Vlan range " + vlan +" is already dedicated to the specified account" + accountName); + return guestVlanMap; + } + } + // Verify if range overlaps with an existing range + if (startVlan < dedicatedStartVlan & endVlan+1 >= dedicatedStartVlan & endVlan <= dedicatedEndVlan) { // extend to the left + updatedVlanRange = startVlan + "-" + dedicatedEndVlan; + break; + } else if (startVlan >= dedicatedStartVlan & startVlan-1 <= dedicatedEndVlan & endVlan > dedicatedEndVlan) { // extend to right + updatedVlanRange = dedicatedStartVlan + "-" + endVlan; + break; + } else if (startVlan < dedicatedStartVlan & endVlan > dedicatedEndVlan){ // extend to the left and right + updatedVlanRange = startVlan + "-" + endVlan; + break; + } + } + + AccountGuestVlanMapVO accountGuestVlanMapVO; + if (updatedVlanRange != null) { + if (guestVlanMapAccountId != vlanOwner.getAccountId()) { + throw new InvalidParameterValueException("Vlan range is partially dedicated to another account. Cannot dedicate guest vlan range " + vlan); + } + accountGuestVlanMapVO = _accountGuestVlanMapDao.findById(guestVlanMapId); + accountGuestVlanMapVO.setGuestVlanRange(updatedVlanRange); + _accountGuestVlanMapDao.update(guestVlanMapId, accountGuestVlanMapVO); + } else { + Transaction txn = Transaction.currentTxn(); + accountGuestVlanMapVO = new AccountGuestVlanMapVO(vlanOwner.getAccountId(), physicalNetworkId); + accountGuestVlanMapVO.setGuestVlanRange(startVlan + "-" + endVlan); + _accountGuestVlanMapDao.persist(accountGuestVlanMapVO); + txn.commit(); + } + // For every guest vlan set the corresponding account guest vlan map id + for (int i = startVlan; i <= endVlan; i++) { + List dataCenterVnet = _datacneter_vnet.findVnet(physicalNetwork.getDataCenterId(),((Integer)i).toString()); + dataCenterVnet.get(0).setAccountGuestVlanMapId(accountGuestVlanMapVO.getId()); + _datacneter_vnet.update(dataCenterVnet.get(0).getId(), dataCenterVnet.get(0)); + } + return accountGuestVlanMapVO; + } + + private List getVlanFromRange(String vlanRange) { + // Get the start and end vlan + String[] vlanTokens = vlanRange.split("-"); + List tokens = new ArrayList(); + try { + int startVlan = Integer.parseInt(vlanTokens[0]); + int endVlan = Integer.parseInt(vlanTokens[1]); + tokens.add(startVlan); + tokens.add(endVlan); + } catch (NumberFormatException e) { + s_logger.warn("Unable to parse guest vlan range:", e); + throw new InvalidParameterValueException("Please provide valid guest vlan range"); + } + return tokens; + } + + @Override + public Pair, Integer> listDedicatedGuestVlanRanges(ListDedicatedGuestVlanRangesCmd cmd) { + Long id = cmd.getId(); + String accountName = cmd.getAccountName(); + Long domainId = cmd.getDomainId(); + Long projectId = cmd.getProjectId(); + String guestVlanRange = cmd.getGuestVlanRange(); + Long physicalNetworkId = cmd.getPhysicalNetworkId(); + Long zoneId = cmd.getZoneId(); + + Long accountId = null; + if (accountName != null && domainId != null) { + if (projectId != null) { + throw new InvalidParameterValueException("Account and projectId can't be specified together"); + } + Account account = _accountDao.findActiveAccount(accountName, domainId); + if (account == null) { + InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find account " + accountName); + ex.addProxyObject("domain", domainId, "domainId"); + throw ex; + } else { + accountId = account.getId(); + } + } + + // set project information + if (projectId != null) { + Project project = _projectMgr.getProject(projectId); + if (project == null) { + InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find project by id " + projectId); + ex.addProxyObject(project, projectId, "projectId"); + throw ex; + } + accountId = project.getProjectAccountId(); + } + + + SearchBuilder sb = _accountGuestVlanMapDao.createSearchBuilder(); + sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ); + sb.and("accountId", sb.entity().getAccountId(), SearchCriteria.Op.EQ); + sb.and("guestVlanRange", sb.entity().getGuestVlanRange(), SearchCriteria.Op.EQ); + sb.and("physicalNetworkId", sb.entity().getPhysicalNetworkId(), SearchCriteria.Op.EQ); + + if (zoneId != null) { + SearchBuilder physicalnetworkSearch = _physicalNetworkDao.createSearchBuilder(); + physicalnetworkSearch.and("zoneId", physicalnetworkSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ); + sb.join("physicalnetworkSearch", physicalnetworkSearch, sb.entity().getPhysicalNetworkId(), physicalnetworkSearch.entity().getId(), JoinBuilder.JoinType.INNER); + } + + SearchCriteria sc = sb.create(); + if (id != null) { + sc.setParameters("id", id); + } + + if (accountId != null) { + sc.setParameters("accountId", accountId); + } + + if (guestVlanRange != null) { + sc.setParameters("guestVlanRange", guestVlanRange); + } + + if (physicalNetworkId != null) { + sc.setParameters("physicalNetworkId", physicalNetworkId); + } + + if (zoneId != null) { + sc.setJoinParameters("physicalnetworkSearch", "zoneId", zoneId); + } + + Filter searchFilter = new Filter(AccountGuestVlanMapVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal()); + Pair, Integer> result = _accountGuestVlanMapDao.searchAndCount(sc, searchFilter); + return new Pair, Integer>(result.first(), result.second()); + } + + @Override + @ActionEvent(eventType = EventTypes.EVENT_DEDICATED_GUEST_VLAN_RANGE_RELEASE, eventDescription = "releasing" + + " dedicated guest vlan range", async = true) + @DB + public boolean releaseDedicatedGuestVlanRange(Long dedicatedGuestVlanRangeId) { + // Verify dedicated range exists + AccountGuestVlanMapVO dedicatedGuestVlan = _accountGuestVlanMapDao.findById(dedicatedGuestVlanRangeId); + if (dedicatedGuestVlan == null) { + throw new InvalidParameterValueException("Dedicated guest vlan with specified" + + " id doesn't exist in the system"); + } + + // Remove dedication for the guest vlan + _datacneter_vnet.releaseDedicatedGuestVlans(dedicatedGuestVlan.getId()); + if (_accountGuestVlanMapDao.remove(dedicatedGuestVlanRangeId)) { + return true; + } else { + return false; + } + } + @Override public List listNetworkServices(String providerName) { diff --git a/server/src/com/cloud/network/dao/AccountGuestVlanMapDao.java b/server/src/com/cloud/network/dao/AccountGuestVlanMapDao.java new file mode 100644 index 00000000000..dc1ec895d80 --- /dev/null +++ b/server/src/com/cloud/network/dao/AccountGuestVlanMapDao.java @@ -0,0 +1,34 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package com.cloud.network.dao; + +import com.cloud.network.dao.AccountGuestVlanMapVO; +import com.cloud.utils.db.GenericDao; + +import java.util.List; + +public interface AccountGuestVlanMapDao extends GenericDao { + + public List listAccountGuestVlanMapsByAccount(long accountId); + + public List listAccountGuestVlanMapsByVlan(long guestVlanId); + + public List listAccountGuestVlanMapsByPhysicalNetwork(long physicalNetworkId); + + public int removeByAccountId(long accountId); + +} diff --git a/server/src/com/cloud/network/dao/AccountGuestVlanMapDaoImpl.java b/server/src/com/cloud/network/dao/AccountGuestVlanMapDaoImpl.java new file mode 100644 index 00000000000..e7a7b34d9bd --- /dev/null +++ b/server/src/com/cloud/network/dao/AccountGuestVlanMapDaoImpl.java @@ -0,0 +1,83 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package com.cloud.network.dao; + +import com.cloud.network.dao.AccountGuestVlanMapVO; +import com.cloud.network.dao.AccountGuestVlanMapDao; + +import java.util.List; +import javax.ejb.Local; +import org.springframework.stereotype.Component; + +import com.cloud.utils.db.DB; +import com.cloud.utils.db.GenericDaoBase; +import com.cloud.utils.db.SearchBuilder; +import com.cloud.utils.db.SearchCriteria; + +@Component +@Local(value={AccountGuestVlanMapDao.class}) +@DB(txn=false) +public class AccountGuestVlanMapDaoImpl extends GenericDaoBase implements AccountGuestVlanMapDao { + + protected SearchBuilder AccountSearch; + protected SearchBuilder GuestVlanSearch; + protected SearchBuilder PhysicalNetworkSearch; + + @Override + public List listAccountGuestVlanMapsByAccount(long accountId) { + SearchCriteria sc = AccountSearch.create(); + sc.setParameters("accountId", accountId); + return listIncludingRemovedBy(sc); + } + + @Override + public List listAccountGuestVlanMapsByVlan(long guestVlanId) { + SearchCriteria sc = GuestVlanSearch.create(); + sc.setParameters("guestVlanId", guestVlanId); + return listIncludingRemovedBy(sc); + } + + @Override + public List listAccountGuestVlanMapsByPhysicalNetwork(long physicalNetworkId) { + SearchCriteria sc = GuestVlanSearch.create(); + sc.setParameters("physicalNetworkId", physicalNetworkId); + return listIncludingRemovedBy(sc); + } + + @Override + public int removeByAccountId(long accountId) { + SearchCriteria sc = AccountSearch.create(); + sc.setParameters("accountId", accountId); + return expunge(sc); + } + + public AccountGuestVlanMapDaoImpl() { + super(); + AccountSearch = createSearchBuilder(); + AccountSearch.and("accountId", AccountSearch.entity().getAccountId(), SearchCriteria.Op.EQ); + AccountSearch.done(); + + GuestVlanSearch = createSearchBuilder(); + GuestVlanSearch.and("guestVlanId", GuestVlanSearch.entity().getId(), SearchCriteria.Op.EQ); + GuestVlanSearch.done(); + + PhysicalNetworkSearch = createSearchBuilder(); + PhysicalNetworkSearch.and("physicalNetworkId", PhysicalNetworkSearch.entity().getId(), SearchCriteria.Op.EQ); + PhysicalNetworkSearch.done(); + } + +} diff --git a/server/src/com/cloud/network/dao/AccountGuestVlanMapVO.java b/server/src/com/cloud/network/dao/AccountGuestVlanMapVO.java new file mode 100644 index 00000000000..17c941a7e36 --- /dev/null +++ b/server/src/com/cloud/network/dao/AccountGuestVlanMapVO.java @@ -0,0 +1,94 @@ +// 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.dao; + +import com.cloud.network.GuestVlan; + +import javax.persistence.*; +import java.util.UUID; + +@Entity +@Table(name="account_vnet_map") +public class AccountGuestVlanMapVO implements GuestVlan { + + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + @Column(name="id") + private long id; + + @Column(name="account_id") + private long accountId; + + @Column(name="uuid") + private String uuid; + + @Column(name="vnet_range") + private String guestVlanRange; + + @Column(name="physical_network_id") + private long physicalNetworkId; + + public AccountGuestVlanMapVO(long accountId,long physicalNetworkId) { + this.accountId = accountId; + this.physicalNetworkId = physicalNetworkId; + this.guestVlanRange = null; + this.uuid = UUID.randomUUID().toString(); + } + + public AccountGuestVlanMapVO() { + + } + + @Override + public long getId() { + return id; + } + + @Override + public long getAccountId() { + return accountId; + } + + @Override + public String getGuestVlanRange() { + return guestVlanRange; + } + + + public void setGuestVlanRange(String guestVlanRange) { + this.guestVlanRange = guestVlanRange; + } + + @Override + public String getUuid() { + return this.uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + @Override + public long getPhysicalNetworkId() { + return this.physicalNetworkId; + } + + public void setPhysicalNetworkId(long physicalNetworkId) { + this.physicalNetworkId = physicalNetworkId; + } + +} diff --git a/server/src/com/cloud/network/rules/RulesManagerImpl.java b/server/src/com/cloud/network/rules/RulesManagerImpl.java index 8636d8503a3..23556354e3a 100755 --- a/server/src/com/cloud/network/rules/RulesManagerImpl.java +++ b/server/src/com/cloud/network/rules/RulesManagerImpl.java @@ -80,12 +80,14 @@ import com.cloud.utils.net.Ip; import com.cloud.vm.Nic; import com.cloud.vm.NicSecondaryIp; import com.cloud.vm.UserVmVO; +import com.cloud.vm.VMInstanceVO; import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachine.Type; import com.cloud.vm.dao.NicDao; import com.cloud.vm.dao.NicSecondaryIpDao; import com.cloud.vm.dao.NicSecondaryIpVO; import com.cloud.vm.dao.UserVmDao; +import com.cloud.vm.dao.VMInstanceDao; @Component @Local(value = { RulesManager.class, RulesService.class }) @@ -103,6 +105,8 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules @Inject UserVmDao _vmDao; @Inject + VMInstanceDao _vmInstanceDao; + @Inject AccountManager _accountMgr; @Inject NetworkManager _networkMgr; @@ -416,7 +420,12 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules @Override @ActionEvent(eventType = EventTypes.EVENT_ENABLE_STATIC_NAT, eventDescription = "enabling static nat") - public boolean enableStaticNat(long ipId, long vmId, long networkId, boolean isSystemVm, String vmGuestIp) + public boolean enableStaticNat(long ipId, long vmId, long networkId, String vmGuestIp) + throws NetworkRuleConflictException, ResourceUnavailableException { + return enableStaticNat(ipId, vmId, networkId, false, vmGuestIp); + } + + private boolean enableStaticNat(long ipId, long vmId, long networkId, boolean isSystemVm, String vmGuestIp) throws NetworkRuleConflictException, ResourceUnavailableException { UserContext ctx = UserContext.current(); Account caller = ctx.getCaller(); @@ -1370,7 +1379,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules throw new CloudRuntimeException("Ip address is not associated with any network"); } - UserVmVO vm = _vmDao.findById(sourceIp.getAssociatedWithVmId()); + VMInstanceVO vm = _vmInstanceDao.findById(sourceIp.getAssociatedWithVmId()); Network network = _networkModel.getNetwork(networkId); if (network == null) { CloudRuntimeException ex = new CloudRuntimeException("Unable to find an ip address to map to specified vm id"); diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index da01b83f79f..5ddae88f1dd 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -256,7 +256,7 @@ 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.vmsnapshot.RevertToSnapshotCmd; +import org.apache.cloudstack.api.command.user.vmsnapshot.RevertToVMSnapshotCmd; 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; @@ -2258,6 +2258,9 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe cmdList.add(UpdateNetworkServiceProviderCmd.class); cmdList.add(UpdatePhysicalNetworkCmd.class); cmdList.add(UpdateStorageNetworkIpRangeCmd.class); + cmdList.add(DedicateGuestVlanRangeCmd.class); + cmdList.add(ListDedicatedGuestVlanRangesCmd.class); + cmdList.add(ReleaseDedicatedGuestVlanRangeCmd.class); cmdList.add(CreateDiskOfferingCmd.class); cmdList.add(CreateServiceOfferingCmd.class); cmdList.add(DeleteDiskOfferingCmd.class); @@ -2524,7 +2527,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe cmdList.add(ListZonesByCmd.class); cmdList.add(ListVMSnapshotCmd.class); cmdList.add(CreateVMSnapshotCmd.class); - cmdList.add(RevertToSnapshotCmd.class); + cmdList.add(RevertToVMSnapshotCmd.class); cmdList.add(DeleteVMSnapshotCmd.class); cmdList.add(AddIpToVmNicCmd.class); cmdList.add(RemoveIpFromVmNicCmd.class); diff --git a/server/src/com/cloud/storage/download/DownloadMonitorImpl.java b/server/src/com/cloud/storage/download/DownloadMonitorImpl.java index 5d7a2106e6a..220cbffd5a3 100755 --- a/server/src/com/cloud/storage/download/DownloadMonitorImpl.java +++ b/server/src/com/cloud/storage/download/DownloadMonitorImpl.java @@ -875,7 +875,9 @@ public class DownloadMonitorImpl extends ManagerBase implements DownloadMonitor tmpltHost.setPhysicalSize(tmpltInfo.getPhysicalSize()); tmpltHost.setLastUpdated(new Date()); - if (tmpltInfo.getSize() > 0) { + // Skipping limit checks for SYSTEM Account and for the templates created from volumes or snapshots + // which already got checked and incremented during createTemplate API call. + if (tmpltInfo.getSize() > 0 && tmplt.getAccountId() != Account.ACCOUNT_ID_SYSTEM && tmplt.getUrl() != null) { long accountId = tmplt.getAccountId(); try { _resourceLimitMgr.checkResourceLimit(_accountMgr.getAccount(accountId), diff --git a/server/src/com/cloud/upgrade/dao/Upgrade2214to30.java b/server/src/com/cloud/upgrade/dao/Upgrade2214to30.java index 817231fa900..2d77429367a 100644 --- a/server/src/com/cloud/upgrade/dao/Upgrade2214to30.java +++ b/server/src/com/cloud/upgrade/dao/Upgrade2214to30.java @@ -630,7 +630,7 @@ public class Upgrade2214to30 extends Upgrade30xBase implements DbUpgrade { //XenServer try { //Get 3.0.0 or later xenserer system Vm template Id - pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name like 'systemvm-xenserver-%' and removed is null"); + pstmt = conn.prepareStatement("select max(id) from `cloud`.`vm_template` where name like 'systemvm-xenserver-%' and removed is null"); rs = pstmt.executeQuery(); if(rs.next()){ long templateId = rs.getLong(1); @@ -661,7 +661,7 @@ public class Upgrade2214to30 extends Upgrade30xBase implements DbUpgrade { s_logger.debug("Updating KVM System Vms"); try { //Get 3.0.0 or later KVM system Vm template Id - pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name like 'systemvm-kvm-%' and removed is null"); + pstmt = conn.prepareStatement("select max(id) from `cloud`.`vm_template` where name like 'systemvm-kvm-%' and removed is null"); rs = pstmt.executeQuery(); if(rs.next()){ long templateId = rs.getLong(1); @@ -692,7 +692,7 @@ public class Upgrade2214to30 extends Upgrade30xBase implements DbUpgrade { s_logger.debug("Updating VMware System Vms"); try { //Get 3.0.0 or later VMware system Vm template Id - pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name like 'systemvm-vmware-%' and removed is null"); + pstmt = conn.prepareStatement("select max(id) from `cloud`.`vm_template` where name like 'systemvm-vmware-%' and removed is null"); rs = pstmt.executeQuery(); if(rs.next()){ long templateId = rs.getLong(1); diff --git a/server/src/com/cloud/user/AccountManagerImpl.java b/server/src/com/cloud/user/AccountManagerImpl.java index 8de73fbd582..4088f64f58b 100755 --- a/server/src/com/cloud/user/AccountManagerImpl.java +++ b/server/src/com/cloud/user/AccountManagerImpl.java @@ -59,6 +59,7 @@ import com.cloud.configuration.dao.ConfigurationDao; import com.cloud.configuration.dao.ResourceCountDao; import com.cloud.dc.DataCenterVO; import com.cloud.dc.dao.DataCenterDao; +import com.cloud.dc.dao.DataCenterVnetDao; import com.cloud.domain.Domain; import com.cloud.domain.DomainVO; import com.cloud.domain.dao.DomainDao; @@ -76,6 +77,8 @@ import com.cloud.network.IpAddress; import com.cloud.network.NetworkManager; import com.cloud.network.VpnUserVO; import com.cloud.network.as.AutoScaleManager; +import com.cloud.network.dao.AccountGuestVlanMapDao; +import com.cloud.network.dao.AccountGuestVlanMapVO; import com.cloud.network.dao.IPAddressDao; import com.cloud.network.dao.IPAddressVO; import com.cloud.network.dao.NetworkDao; @@ -222,6 +225,10 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M @Inject VolumeManager volumeMgr; @Inject private AffinityGroupDao _affinityGroupDao; + @Inject + private AccountGuestVlanMapDao _accountGuestVlanMapDao; + @Inject + private DataCenterVnetDao _dataCenterVnetDao; private List _userAuthenticators; List _userPasswordEncoders; @@ -699,6 +706,14 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M } } + // release account specific guest vlans + List maps = _accountGuestVlanMapDao.listAccountGuestVlanMapsByAccount(accountId); + for (AccountGuestVlanMapVO map : maps) { + _dataCenterVnetDao.releaseDedicatedGuestVlans(map.getId()); + } + int vlansReleased = _accountGuestVlanMapDao.removeByAccountId(accountId); + s_logger.info("deleteAccount: Released " + vlansReleased + " dedicated guest vlan ranges from account " + accountId); + return true; } catch (Exception ex) { s_logger.warn("Failed to cleanup account " + account + " due to ", ex); diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 617994888bd..bc25bedde45 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -1050,7 +1050,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use @Override @ActionEvent(eventType = EventTypes.EVENT_VM_SCALE, eventDescription = "scaling Vm") - public UserVm + public boolean upgradeVirtualMachine(ScaleVMCmd cmd) throws InvalidParameterValueException { Long vmId = cmd.getId(); Long newServiceOfferingId = cmd.getServiceOfferingId(); @@ -1076,8 +1076,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use } // Dynamically upgrade the running vms + boolean success = false; if(vmInstance.getState().equals(State.Running)){ - boolean success = false; int retry = _scaleRetry; while (retry-- != 0) { // It's != so that it can match -1. try{ @@ -1095,7 +1095,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use vmInstance = _vmInstanceDao.findById(vmId); vmInstance = _itMgr.reConfigureVm(vmInstance, oldServiceOffering, existingHostHasCapacity); success = true; - return _vmDao.findById(vmInstance.getId()); + return success; }catch(InsufficientCapacityException e ){ s_logger.warn("Received exception while scaling ",e); } catch (ResourceUnavailableException e) { @@ -1112,11 +1112,9 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use } } } - if (!success) - return null; } - return _vmDao.findById(vmInstance.getId()); + return success; } diff --git a/server/test/com/cloud/network/DedicateGuestVlanRangesTest.java b/server/test/com/cloud/network/DedicateGuestVlanRangesTest.java new file mode 100644 index 00000000000..e81d7222a60 --- /dev/null +++ b/server/test/com/cloud/network/DedicateGuestVlanRangesTest.java @@ -0,0 +1,378 @@ +// 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 java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import java.lang.reflect.Field; + +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.network.ReleaseDedicatedGuestVlanRangeCmd; + +import org.apache.log4j.Logger; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import com.cloud.dc.DataCenterVnetVO; +import com.cloud.dc.dao.DataCenterVnetDao; +import com.cloud.network.dao.AccountGuestVlanMapDao; +import com.cloud.network.dao.AccountGuestVlanMapVO; +import com.cloud.network.dao.PhysicalNetworkDao; +import com.cloud.network.dao.PhysicalNetworkVO; +import com.cloud.projects.ProjectManager; +import com.cloud.user.Account; +import com.cloud.user.dao.AccountDao; +import com.cloud.user.AccountManager; +import com.cloud.user.AccountVO; +import com.cloud.user.UserContext; +import com.cloud.utils.db.Transaction; + +import junit.framework.Assert; + +import static org.mockito.Matchers.*; +import static org.mockito.Mockito.when; +import static org.mockito.Mockito.doNothing; + +public class DedicateGuestVlanRangesTest { + + private static final Logger s_logger = Logger.getLogger(DedicateGuestVlanRangesTest.class); + + NetworkServiceImpl networkService = new NetworkServiceImpl(); + + DedicateGuestVlanRangeCmd dedicateGuestVlanRangesCmd = new DedicateGuestVlanRangeCmdExtn(); + Class _dedicateGuestVlanRangeClass = dedicateGuestVlanRangesCmd.getClass().getSuperclass(); + + ReleaseDedicatedGuestVlanRangeCmd releaseDedicatedGuestVlanRangesCmd = new ReleaseDedicatedGuestVlanRangeCmdExtn(); + Class _releaseGuestVlanRangeClass = releaseDedicatedGuestVlanRangesCmd.getClass().getSuperclass(); + + ListDedicatedGuestVlanRangesCmd listDedicatedGuestVlanRangesCmd = new ListDedicatedGuestVlanRangesCmdExtn(); + Class _listDedicatedGuestVlanRangeClass = listDedicatedGuestVlanRangesCmd.getClass().getSuperclass(); + + + @Mock AccountManager _accountMgr; + @Mock AccountDao _accountDao; + @Mock ProjectManager _projectMgr; + @Mock PhysicalNetworkDao _physicalNetworkDao; + @Mock DataCenterVnetDao _dataCenterVnetDao; + @Mock AccountGuestVlanMapDao _accountGuestVlanMapDao; + + @Before + public void setup() throws Exception { + MockitoAnnotations.initMocks(this); + + networkService._accountMgr = _accountMgr; + networkService._accountDao = _accountDao; + networkService._projectMgr = _projectMgr; + networkService._physicalNetworkDao = _physicalNetworkDao; + networkService._datacneter_vnet = _dataCenterVnetDao; + networkService._accountGuestVlanMapDao = _accountGuestVlanMapDao; + + Account account = (Account) new AccountVO("testaccount", 1, "networkdomain", (short) 0, UUID.randomUUID().toString()); + when(networkService._accountMgr.getAccount(anyLong())).thenReturn(account); + when(networkService._accountDao.findActiveAccount(anyString(), anyLong())).thenReturn(account); + + UserContext.registerContext(1, account, null, true); + + Field accountNameField = _dedicateGuestVlanRangeClass.getDeclaredField("accountName"); + accountNameField.setAccessible(true); + accountNameField.set(dedicateGuestVlanRangesCmd, "accountname"); + + Field projectIdField = _dedicateGuestVlanRangeClass.getDeclaredField("projectId"); + projectIdField.setAccessible(true); + projectIdField.set(dedicateGuestVlanRangesCmd, null); + + Field domainIdField = _dedicateGuestVlanRangeClass.getDeclaredField("domainId"); + domainIdField.setAccessible(true); + domainIdField.set(dedicateGuestVlanRangesCmd, 1L); + + Field physicalNetworkIdField = _dedicateGuestVlanRangeClass.getDeclaredField("physicalNetworkId"); + physicalNetworkIdField.setAccessible(true); + physicalNetworkIdField.set(dedicateGuestVlanRangesCmd, 1L); + + Field releaseIdField = _releaseGuestVlanRangeClass.getDeclaredField("id"); + releaseIdField.setAccessible(true); + releaseIdField.set(releaseDedicatedGuestVlanRangesCmd, 1L); + } + + @Test + public void testDedicateGuestVlanRange() throws Exception { + s_logger.info("Running tests for DedicateGuestVlanRange API"); + + /* + * TEST 1: given valid parameters DedicateGuestVlanRange should succeed + */ + runDedicateGuestVlanRangePostiveTest(); + + /* + * TEST 2: given invalid format for vlan range DedicateGuestVlanRange should fail + */ + runDedicateGuestVlanRangeInvalidFormat(); + + /* + * TEST 3: given vlan range that doesn't exist in the system request should fail + */ + runDedicateGuestVlanRangeInvalidRangeValue(); + + /* + * TEST 4: given vlan range has vlans that are allocated to a different account request should fail + */ + runDedicateGuestVlanRangeAllocatedVlans(); + + /* + * TEST 5: given vlan range is already dedicated to another account request should fail + */ + runDedicateGuestVlanRangeDedicatedRange(); + + /* + * TEST 6: given vlan range is partially dedicated to a different account request should fail + */ + runDedicateGuestVlanRangePartiallyDedicated(); + } + + @Test + public void testReleaseDedicatedGuestVlanRange() throws Exception { + + s_logger.info("Running tests for ReleaseDedicatedGuestVlanRange API"); + + /* + * TEST 1: given valid parameters ReleaseDedicatedGuestVlanRange should succeed + */ + runReleaseDedicatedGuestVlanRangePostiveTest(); + + /* + * TEST 2: given range doesn't exist request should fail + */ + runReleaseDedicatedGuestVlanRangeInvalidRange(); + } + + void runDedicateGuestVlanRangePostiveTest() throws Exception { + Transaction txn = Transaction.open("runDedicateGuestVlanRangePostiveTest"); + + Field dedicateVlanField = _dedicateGuestVlanRangeClass.getDeclaredField("vlan"); + dedicateVlanField.setAccessible(true); + dedicateVlanField.set(dedicateGuestVlanRangesCmd, "2-5"); + + PhysicalNetworkVO physicalNetwork = new PhysicalNetworkVO(1L, 1L, "2-5", "200", 1L, null, "testphysicalnetwork"); + physicalNetwork.addIsolationMethod("VLAN"); + AccountGuestVlanMapVO accountGuestVlanMapVO = new AccountGuestVlanMapVO(1L,1L); + + when(networkService._physicalNetworkDao.findById(anyLong())).thenReturn(physicalNetwork); + + when(networkService._datacneter_vnet.listAllocatedVnetsInRange(anyLong(), anyLong(), anyInt(), anyInt())).thenReturn(null); + + when(networkService._accountGuestVlanMapDao.listAccountGuestVlanMapsByPhysicalNetwork(anyLong())).thenReturn(null); + + when(networkService._accountGuestVlanMapDao.persist(any(AccountGuestVlanMapVO.class))).thenReturn(accountGuestVlanMapVO); + + when(networkService._datacneter_vnet.update(anyLong(), any(DataCenterVnetVO.class))).thenReturn(true); + + List dataCenterVnetList = new ArrayList(); + DataCenterVnetVO dataCenterVnetVO = new DataCenterVnetVO("2-5", 1L, 1L); + dataCenterVnetList.add(dataCenterVnetVO); + when(networkService._datacneter_vnet.findVnet(anyLong(), anyString())).thenReturn(dataCenterVnetList); + + try { + GuestVlan result = networkService.dedicateGuestVlanRange(dedicateGuestVlanRangesCmd); + Assert.assertNotNull(result); + } catch (Exception e) { + s_logger.info("exception in testing runDedicateGuestVlanRangePostiveTest message: " + e.toString()); + } finally { + txn.close("runDedicateGuestRangePostiveTest"); + } + } + + void runDedicateGuestVlanRangeInvalidFormat() throws Exception { + Transaction txn = Transaction.open("runDedicateGuestVlanRangeInvalidFormat"); + + Field dedicateVlanField = _dedicateGuestVlanRangeClass.getDeclaredField("vlan"); + dedicateVlanField.setAccessible(true); + dedicateVlanField.set(dedicateGuestVlanRangesCmd, "2"); + + PhysicalNetworkVO physicalNetwork = new PhysicalNetworkVO(1L, 1L, "2-5", "200", 1L, null, "testphysicalnetwork"); + physicalNetwork.addIsolationMethod("VLAN"); + + when(networkService._physicalNetworkDao.findById(anyLong())).thenReturn(physicalNetwork); + + try { + networkService.dedicateGuestVlanRange(dedicateGuestVlanRangesCmd); + } catch (Exception e) { + Assert.assertTrue(e.getMessage().contains("Invalid format for parameter value vlan")); + } finally { + txn.close("runDedicateGuestVlanRangeInvalidFormat"); + } + } + + void runDedicateGuestVlanRangeInvalidRangeValue() throws Exception { + Transaction txn = Transaction.open("runDedicateGuestVlanRangeInvalidRangeValue"); + + Field dedicateVlanField = _dedicateGuestVlanRangeClass.getDeclaredField("vlan"); + dedicateVlanField.setAccessible(true); + dedicateVlanField.set(dedicateGuestVlanRangesCmd, "2-5"); + + PhysicalNetworkVO physicalNetwork = new PhysicalNetworkVO(1L, 1L, "6-10", "200", 1L, null, "testphysicalnetwork"); + physicalNetwork.addIsolationMethod("VLAN"); + + when(networkService._physicalNetworkDao.findById(anyLong())).thenReturn(physicalNetwork); + + try { + networkService.dedicateGuestVlanRange(dedicateGuestVlanRangesCmd); + } catch (Exception e) { + Assert.assertTrue(e.getMessage().contains("Unable to find guest vlan by range")); + } finally { + txn.close("runDedicateGuestVlanRangeInvalidRangeValue"); + } + } + + void runDedicateGuestVlanRangeAllocatedVlans() throws Exception { + Transaction txn = Transaction.open("runDedicateGuestVlanRangeAllocatedVlans"); + + Field dedicateVlanField = _dedicateGuestVlanRangeClass.getDeclaredField("vlan"); + dedicateVlanField.setAccessible(true); + dedicateVlanField.set(dedicateGuestVlanRangesCmd, "2-5"); + + PhysicalNetworkVO physicalNetwork = new PhysicalNetworkVO(1L, 1L, "2-5", "200", 1L, null, "testphysicalnetwork"); + physicalNetwork.addIsolationMethod("VLAN"); + when(networkService._physicalNetworkDao.findById(anyLong())).thenReturn(physicalNetwork); + + List dataCenterList = new ArrayList(); + DataCenterVnetVO dataCenter = new DataCenterVnetVO("2-5", 1L, 1L); + dataCenter.setAccountId(1L); + dataCenterList.add(dataCenter); + when(networkService._datacneter_vnet.listAllocatedVnetsInRange(anyLong(), anyLong(), anyInt(), anyInt())).thenReturn(dataCenterList); + + try { + networkService.dedicateGuestVlanRange(dedicateGuestVlanRangesCmd); + } catch (Exception e) { + Assert.assertTrue(e.getMessage().contains("is allocated to a different account")); + } finally { + txn.close("runDedicateGuestVlanRangeAllocatedVlans"); + } + } + + void runDedicateGuestVlanRangeDedicatedRange() throws Exception { + Transaction txn = Transaction.open("runDedicateGuestVlanRangeDedicatedRange"); + + Field dedicateVlanField = _dedicateGuestVlanRangeClass.getDeclaredField("vlan"); + dedicateVlanField.setAccessible(true); + dedicateVlanField.set(dedicateGuestVlanRangesCmd, "2-5"); + + PhysicalNetworkVO physicalNetwork = new PhysicalNetworkVO(1L, 1L, "2-5", "200", 1L, null, "testphysicalnetwork"); + physicalNetwork.addIsolationMethod("VLAN"); + + when(networkService._physicalNetworkDao.findById(anyLong())).thenReturn(physicalNetwork); + + when(networkService._datacneter_vnet.listAllocatedVnetsInRange(anyLong(), anyLong(), anyInt(), anyInt())).thenReturn(null); + + List guestVlanMaps = new ArrayList(); + AccountGuestVlanMapVO accountGuestVlanMap = new AccountGuestVlanMapVO(1L, 1L); + accountGuestVlanMap.setGuestVlanRange("2-5"); + guestVlanMaps.add(accountGuestVlanMap); + when(networkService._accountGuestVlanMapDao.listAccountGuestVlanMapsByPhysicalNetwork(anyLong())).thenReturn(guestVlanMaps); + + try { + networkService.dedicateGuestVlanRange(dedicateGuestVlanRangesCmd); + } catch (Exception e) { + Assert.assertTrue(e.getMessage().contains("Vlan range is already dedicated to another account")); + } finally { + txn.close("runDedicateGuestVlanRangeDedicatedRange"); + } + } + + void runDedicateGuestVlanRangePartiallyDedicated() throws Exception { + Transaction txn = Transaction.open("runDedicateGuestVlanRangePartiallyDedicated"); + + Field dedicateVlanField = _dedicateGuestVlanRangeClass.getDeclaredField("vlan"); + dedicateVlanField.setAccessible(true); + dedicateVlanField.set(dedicateGuestVlanRangesCmd, "2-5"); + + PhysicalNetworkVO physicalNetwork = new PhysicalNetworkVO(1L, 1L, "2-5", "200", 1L, null, "testphysicalnetwork"); + physicalNetwork.addIsolationMethod("VLAN"); + + when(networkService._physicalNetworkDao.findById(anyLong())).thenReturn(physicalNetwork); + + when(networkService._datacneter_vnet.listAllocatedVnetsInRange(anyLong(), anyLong(), anyInt(), anyInt())).thenReturn(null); + + List guestVlanMaps = new ArrayList(); + AccountGuestVlanMapVO accountGuestVlanMap = new AccountGuestVlanMapVO(2L, 1L); + accountGuestVlanMap.setGuestVlanRange("4-8"); + guestVlanMaps.add(accountGuestVlanMap); + when(networkService._accountGuestVlanMapDao.listAccountGuestVlanMapsByPhysicalNetwork(anyLong())).thenReturn(guestVlanMaps); + + try { + networkService.dedicateGuestVlanRange(dedicateGuestVlanRangesCmd); + } catch (Exception e) { + Assert.assertTrue(e.getMessage().contains("Vlan range is partially dedicated to another account")); + } finally { + txn.close("runDedicateGuestVlanRangePartiallyDedicated"); + } + } + + void runReleaseDedicatedGuestVlanRangePostiveTest() throws Exception { + Transaction txn = Transaction.open("runReleaseDedicatedGuestVlanRangePostiveTest"); + + AccountGuestVlanMapVO accountGuestVlanMap = new AccountGuestVlanMapVO(1L, 1L); + when(networkService._accountGuestVlanMapDao.findById(anyLong())).thenReturn(accountGuestVlanMap); + doNothing().when(networkService._datacneter_vnet).releaseDedicatedGuestVlans(anyLong()); + when(networkService._accountGuestVlanMapDao.remove(anyLong())).thenReturn(true); + + try { + Boolean result = networkService.releaseDedicatedGuestVlanRange(releaseDedicatedGuestVlanRangesCmd.getId()); + Assert.assertTrue(result); + } catch (Exception e) { + s_logger.info("exception in testing runReleaseGuestVlanRangePostiveTest1 message: " + e.toString()); + } finally { + txn.close("runReleaseDedicatedGuestVlanRangePostiveTest"); + } + } + + void runReleaseDedicatedGuestVlanRangeInvalidRange() throws Exception { + Transaction txn = Transaction.open("runReleaseDedicatedGuestVlanRangeInvalidRange"); + + when(networkService._accountGuestVlanMapDao.findById(anyLong())).thenReturn(null); + + try { + networkService.releaseDedicatedGuestVlanRange(releaseDedicatedGuestVlanRangesCmd.getId()); + } catch (Exception e) { + Assert.assertTrue(e.getMessage().contains("Dedicated guest vlan with specified id doesn't exist in the system")); + } finally { + txn.close("runReleaseDedicatedGuestVlanRangeInvalidRange"); + } + } + + public class DedicateGuestVlanRangeCmdExtn extends DedicateGuestVlanRangeCmd { + public long getEntityOwnerId() { + return 1; + } + } + + public class ReleaseDedicatedGuestVlanRangeCmdExtn extends ReleaseDedicatedGuestVlanRangeCmd { + public long getEntityOwnerId() { + return 1; + } + } + + public class ListDedicatedGuestVlanRangesCmdExtn extends ListDedicatedGuestVlanRangesCmd { + public long getEntityOwnerId() { + return 1; + } + } +} diff --git a/server/test/com/cloud/network/MockNetworkManagerImpl.java b/server/test/com/cloud/network/MockNetworkManagerImpl.java index 45562c6ea31..2f717c8c156 100755 --- a/server/test/com/cloud/network/MockNetworkManagerImpl.java +++ b/server/test/com/cloud/network/MockNetworkManagerImpl.java @@ -29,6 +29,7 @@ import com.cloud.network.Networks.TrafficType; import com.cloud.network.addr.PublicIp; import com.cloud.network.dao.IPAddressVO; import com.cloud.network.dao.NetworkVO; +import com.cloud.network.GuestVlan; import com.cloud.network.element.LoadBalancingServiceProvider; import com.cloud.network.element.StaticNatServiceProvider; import com.cloud.network.element.UserDataServiceProvider; @@ -46,6 +47,8 @@ import com.cloud.utils.component.ManagerBase; import com.cloud.vm.*; import com.cloud.vm.VirtualMachine.Type; 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; import org.apache.cloudstack.api.command.user.network.CreateNetworkCmd; import org.apache.cloudstack.api.command.user.network.ListNetworksCmd; @@ -326,6 +329,24 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkManage } @Override + public GuestVlan dedicateGuestVlanRange(DedicateGuestVlanRangeCmd cmd) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Pair, Integer> listDedicatedGuestVlanRanges(ListDedicatedGuestVlanRangesCmd cmd) { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean releaseDedicatedGuestVlanRange(Long dedicatedGuestVlanRangeId) { + // TODO Auto-generated method stub + return true; + } + + @Override public List listNetworkServices(String providerName) { // TODO Auto-generated method stub return null; diff --git a/server/test/com/cloud/network/MockRulesManagerImpl.java b/server/test/com/cloud/network/MockRulesManagerImpl.java index e5a6894d76d..200fd2c7462 100644 --- a/server/test/com/cloud/network/MockRulesManagerImpl.java +++ b/server/test/com/cloud/network/MockRulesManagerImpl.java @@ -76,8 +76,7 @@ public class MockRulesManagerImpl extends ManagerBase implements RulesManager, R @Override public boolean enableStaticNat(long ipAddressId, long vmId, long networkId, - boolean isSystemVm, String ipAddr) throws NetworkRuleConflictException, - ResourceUnavailableException { + String ipAddr) throws NetworkRuleConflictException, ResourceUnavailableException { // TODO Auto-generated method stub return false; } diff --git a/server/test/com/cloud/vm/MockUserVmManagerImpl.java b/server/test/com/cloud/vm/MockUserVmManagerImpl.java index 22bbbe8d5df..8b0b1c797c0 100644 --- a/server/test/com/cloud/vm/MockUserVmManagerImpl.java +++ b/server/test/com/cloud/vm/MockUserVmManagerImpl.java @@ -407,8 +407,8 @@ public class MockUserVmManagerImpl extends ManagerBase implements UserVmManager, } @Override - public UserVm upgradeVirtualMachine(ScaleVMCmd scaleVMCmd) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException { - return null; //To change body of implemented methods use File | Settings | File Templates. + public boolean upgradeVirtualMachine(ScaleVMCmd scaleVMCmd) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException { + return false; //To change body of implemented methods use File | Settings | File Templates. } diff --git a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java index 668935707ee..f884ba1d767 100644 --- a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java +++ b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java @@ -28,6 +28,7 @@ import com.cloud.network.Network.Provider; import com.cloud.network.Network.Service; import com.cloud.network.Networks.TrafficType; 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; @@ -50,6 +51,8 @@ import com.cloud.utils.component.ManagerBase; import com.cloud.vm.*; import com.cloud.vm.VirtualMachine.Type; 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; import org.apache.cloudstack.api.command.user.network.CreateNetworkCmd; import org.apache.cloudstack.api.command.user.network.ListNetworksCmd; @@ -338,9 +341,24 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkManage return false; } + @Override + public GuestVlan dedicateGuestVlanRange(DedicateGuestVlanRangeCmd cmd) { + // TODO Auto-generated method stub + return null; + } + @Override + public Pair, Integer> listDedicatedGuestVlanRanges(ListDedicatedGuestVlanRangesCmd cmd) { + // TODO Auto-generated method stub + return null; + } + @Override + public boolean releaseDedicatedGuestVlanRange(Long dedicatedGuestVlanRangeId) { + // TODO Auto-generated method stub + return true; + } /* (non-Javadoc) * @see com.cloud.network.NetworkService#listNetworkServices(java.lang.String) diff --git a/server/test/org/apache/cloudstack/affinity/AffinityApiTestConfiguration.java b/server/test/org/apache/cloudstack/affinity/AffinityApiTestConfiguration.java index 4dd6ad7e8d0..a1224db62c3 100644 --- a/server/test/org/apache/cloudstack/affinity/AffinityApiTestConfiguration.java +++ b/server/test/org/apache/cloudstack/affinity/AffinityApiTestConfiguration.java @@ -72,6 +72,7 @@ import com.cloud.network.NetworkManager; import com.cloud.network.NetworkModel; import com.cloud.network.NetworkService; import com.cloud.network.StorageNetworkManager; +import com.cloud.network.dao.AccountGuestVlanMapDaoImpl; import com.cloud.network.dao.FirewallRulesCidrsDaoImpl; import com.cloud.network.dao.FirewallRulesDaoImpl; import com.cloud.network.dao.IPAddressDaoImpl; @@ -136,7 +137,7 @@ import com.cloud.vm.dao.VMInstanceDaoImpl; FirewallRulesCidrsDaoImpl.class, PhysicalNetworkDaoImpl.class, PhysicalNetworkTrafficTypeDaoImpl.class, PhysicalNetworkServiceProviderDaoImpl.class, LoadBalancerDaoImpl.class, NetworkServiceMapDaoImpl.class, PrimaryDataStoreDaoImpl.class, StoragePoolDetailsDaoImpl.class, AffinityGroupServiceImpl.class, - ComponentContext.class, AffinityGroupProcessor.class, UserVmVO.class, EventUtils.class, UserVmVO.class + ComponentContext.class, AffinityGroupProcessor.class, UserVmVO.class, EventUtils.class, UserVmVO.class, AccountGuestVlanMapDaoImpl.class }, includeFilters = { @Filter(value = AffinityApiTestConfiguration.Library.class, type = FilterType.CUSTOM) }, useDefaultFilters = false) public class AffinityApiTestConfiguration { diff --git a/server/test/org/apache/cloudstack/networkoffering/ChildTestConfiguration.java b/server/test/org/apache/cloudstack/networkoffering/ChildTestConfiguration.java index 709dfe29ed1..d47deaa7018 100644 --- a/server/test/org/apache/cloudstack/networkoffering/ChildTestConfiguration.java +++ b/server/test/org/apache/cloudstack/networkoffering/ChildTestConfiguration.java @@ -53,6 +53,7 @@ import com.cloud.network.NetworkManager; import com.cloud.network.NetworkModel; import com.cloud.network.NetworkService; import com.cloud.network.StorageNetworkManager; +import com.cloud.network.dao.AccountGuestVlanMapDaoImpl; import com.cloud.network.dao.FirewallRulesCidrsDaoImpl; import com.cloud.network.dao.FirewallRulesDaoImpl; import com.cloud.network.dao.IPAddressDaoImpl; @@ -146,7 +147,8 @@ import com.cloud.vm.dao.VMInstanceDaoImpl; LoadBalancerDaoImpl.class, NetworkServiceMapDaoImpl.class, PrimaryDataStoreDaoImpl.class, - StoragePoolDetailsDaoImpl.class + StoragePoolDetailsDaoImpl.class, + AccountGuestVlanMapDaoImpl.class }, includeFilters={@Filter(value=ChildTestConfiguration.Library.class, type=FilterType.CUSTOM)}, useDefaultFilters=false diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql index 99b476d4581..c8ac1ecfc2e 100644 --- a/setup/db/db/schema-410to420.sql +++ b/setup/db/db/schema-410to420.sql @@ -1115,6 +1115,7 @@ CREATE VIEW `cloud`.`account_view` AS and async_job.instance_type = 'Account' and async_job.job_status = 0; + alter table `cloud_usage`.`usage_network_offering` add column nic_id bigint(20) unsigned NOT NULL; ALTER TABLE `cloud`.`data_center_details` MODIFY value varchar(1024); ALTER TABLE `cloud`.`cluster_details` MODIFY value varchar(255); @@ -1126,3 +1127,19 @@ INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network', 'DEFAULT', 'manage alter table cloud.vpc_gateways add column source_nat boolean default false; alter table cloud.private_ip_address add column source_nat boolean default false; + +CREATE TABLE `cloud`.`account_vnet_map` ( + `id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT, + `uuid` varchar(255) UNIQUE, + `vnet_range` varchar(255) NOT NULL COMMENT 'dedicated guest vlan range', + `account_id` bigint unsigned NOT NULL COMMENT 'account id. foreign key to account table', + `physical_network_id` bigint unsigned NOT NULL COMMENT 'physical network id. foreign key to the the physical network table', + PRIMARY KEY (`id`), + CONSTRAINT `fk_account_vnet_map__physical_network_id` FOREIGN KEY (`physical_network_id`) REFERENCES `physical_network` (`id`) ON DELETE CASCADE, + INDEX `i_account_vnet_map__physical_network_id`(`physical_network_id`), + CONSTRAINT `fk_account_vnet_map__account_id` FOREIGN KEY (`account_id`) REFERENCES `account` (`id`) ON DELETE CASCADE, + INDEX `i_account_vnet_map__account_id`(`account_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +ALTER TABLE `cloud`.`op_dc_vnet_alloc` ADD COLUMN account_vnet_map_id bigint unsigned; +ALTER TABLE `cloud`.`op_dc_vnet_alloc` ADD CONSTRAINT `fk_op_dc_vnet_alloc__account_vnet_map_id` FOREIGN KEY `fk_op_dc_vnet_alloc__account_vnet_map_id` (`account_vnet_map_id`) REFERENCES `account_vnet_map` (`id`); diff --git a/setup/dev/advanced.cfg b/setup/dev/advanced.cfg index c031c2a4f84..431598947c6 100644 --- a/setup/dev/advanced.cfg +++ b/setup/dev/advanced.cfg @@ -84,8 +84,12 @@ "clustertype": "CloudManaged", "primaryStorages": [ { - "url": "nfs://10.147.28.6:/export/home/sandbox/primary", + "url": "nfs://10.147.28.6:/export/home/sandbox/primary0", "name": "PS0" + }, + { + "url": "nfs://10.147.28.6:/export/home/sandbox/primary1", + "name": "PS1" } ] } diff --git a/test/integration/component/test_accounts.py b/test/integration/component/test_accounts.py index 459cfb3a251..fb38e627582 100644 --- a/test/integration/component/test_accounts.py +++ b/test/integration/component/test_accounts.py @@ -162,11 +162,11 @@ class TestAccounts(cloudstackTestCase): self.apiclient, self.services["account"] ) - self.debug("Created account: %s" % account.account.name) + self.debug("Created account: %s" % account.name) self.cleanup.append(account) list_accounts_response = list_accounts( self.apiclient, - id=account.account.id + id=account.id ) self.assertEqual( isinstance(list_accounts_response, list), @@ -181,12 +181,12 @@ class TestAccounts(cloudstackTestCase): account_response = list_accounts_response[0] self.assertEqual( - account.account.accounttype, + account.accounttype, account_response.accounttype, "Check Account Type of Created account" ) self.assertEqual( - account.account.name, + account.name, account_response.name, "Check Account Name of Created account" ) @@ -194,8 +194,8 @@ class TestAccounts(cloudstackTestCase): user = User.create( self.apiclient, self.services["user"], - account=account.account.name, - domainid=account.account.domainid + account=account.name, + domainid=account.domainid ) self.debug("Created user: %s" % user.id) list_users_response = list_users( @@ -301,15 +301,15 @@ class TestRemoveUserFromAccount(cloudstackTestCase): user_1 = User.create( self.apiclient, self.services["user"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("Created user: %s" % user_1.id) user_2 = User.create( self.apiclient, self.services["user"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("Created user: %s" % user_2.id) self.cleanup.append(user_2) @@ -317,12 +317,12 @@ class TestRemoveUserFromAccount(cloudstackTestCase): vm_1 = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) self.debug("Deployed VM in account: %s, ID: %s" % ( - self.account.account.name, + self.account.name, vm_1.id )) self.cleanup.append(vm_1) @@ -330,12 +330,12 @@ class TestRemoveUserFromAccount(cloudstackTestCase): vm_2 = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) self.debug("Deployed VM in account: %s, ID: %s" % ( - self.account.account.name, + self.account.name, vm_2.id )) self.cleanup.append(vm_2) @@ -347,7 +347,7 @@ class TestRemoveUserFromAccount(cloudstackTestCase): # Account should exist after deleting user accounts_response = list_accounts( self.apiclient, - id=self.account.account.id + id=self.account.id ) self.assertEqual( isinstance(accounts_response, list), @@ -362,8 +362,8 @@ class TestRemoveUserFromAccount(cloudstackTestCase): ) vm_response = list_virtual_machines( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(vm_response, list), @@ -401,43 +401,43 @@ class TestRemoveUserFromAccount(cloudstackTestCase): user_1 = User.create( self.apiclient, self.services["user"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("Created user: %s" % user_1.id) user_2 = User.create( self.apiclient, self.services["user"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("Created user: %s" % user_2.id) vm_1 = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], - accountid=self.account.account.name, + accountid=self.account.name, serviceofferingid=self.service_offering.id ) self.debug("Deployed VM in account: %s, ID: %s" % ( - self.account.account.name, + self.account.name, vm_1.id )) vm_2 = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], - accountid=self.account.account.name, + accountid=self.account.name, serviceofferingid=self.service_offering.id ) self.debug("Deployed VM in account: %s, ID: %s" % ( - self.account.account.name, + self.account.name, vm_2.id )) # Get users associated with an account # (Total 3: 2 - Created & 1 default generated while account creation) users = list_users( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(users, list), @@ -468,7 +468,7 @@ class TestRemoveUserFromAccount(cloudstackTestCase): # Account is removed after last user is deleted account_response = list_accounts( self.apiclient, - id=self.account.account.id + id=self.account.id ) self.assertEqual( account_response, @@ -478,8 +478,8 @@ class TestRemoveUserFromAccount(cloudstackTestCase): # All VMs associated with account are removed. vm_response = list_virtual_machines( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( vm_response, @@ -490,8 +490,8 @@ class TestRemoveUserFromAccount(cloudstackTestCase): with self.assertRaises(Exception): list_routers( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) return @@ -1217,11 +1217,11 @@ class TestUserDetails(cloudstackTestCase): # Fetching the user details of account self.debug( "Fetching user details for account: %s" % - self.account.account.name) + self.account.name) users = User.list( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(users, list), @@ -1304,11 +1304,11 @@ class TestUserDetails(cloudstackTestCase): # Fetching the user details of account self.debug( "Fetching user details for account: %s" % - self.account.account.name) + self.account.name) users = User.list( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(users, list), @@ -1391,11 +1391,11 @@ class TestUserDetails(cloudstackTestCase): # Fetching the user details of account self.debug( "Fetching user details for account: %s" % - self.account.account.name) + self.account.name) users = User.list( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(users, list), @@ -1515,7 +1515,7 @@ class TestUserLogin(cloudstackTestCase): self.debug("Logging into the cloudstack with login API") respose = User.login( self.apiclient, - username=self.account.account.name, + username=self.account.name, password=self.services["account"]["password"] ) self.assertEqual(respose, None, "Login response should not be none") @@ -1572,8 +1572,8 @@ class TestUserLogin(cloudstackTestCase): accounts = Account.list( self.apiclient, - name=self.account.account.name, - domainid=self.account.account.domainid, + name=self.account.name, + domainid=self.account.domainid, listall=True ) @@ -1586,7 +1586,7 @@ class TestUserLogin(cloudstackTestCase): self.debug("Logging into the cloudstack with login API") respose = User.login( self.apiclient, - username=self.account.account.name, + username=self.account.name, password=self.services["account"]["password"] ) self.assertEqual(respose, None, "Login response should not be none") diff --git a/test/integration/component/test_blocker_bugs.py b/test/integration/component/test_blocker_bugs.py index bfd1c13cb19..a6ea25a846a 100644 --- a/test/integration/component/test_blocker_bugs.py +++ b/test/integration/component/test_blocker_bugs.py @@ -136,7 +136,7 @@ class TestSnapshots(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client, @@ -146,8 +146,8 @@ class TestSnapshots(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], templateid=cls.template.id, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"] ) @@ -204,8 +204,8 @@ class TestSnapshots(cloudstackTestCase): self.apiclient, self.services["volume"], zoneid=self.zone.id, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, diskofferingid=self.disk_offering.id ) self.debug("Created volume with ID: %s" % volume.id) @@ -283,8 +283,8 @@ class TestSnapshots(cloudstackTestCase): snapshot = Snapshot.create( self.apiclient, volume_response.id, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("Created snapshot: %s" % snapshot.id) #Create volume from snapshot @@ -292,8 +292,8 @@ class TestSnapshots(cloudstackTestCase): self.apiclient, snapshot.id, self.services["volume"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("Created Volume: %s from Snapshot: %s" % ( volume_from_snapshot.id, @@ -323,12 +323,12 @@ class TestSnapshots(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], templateid=self.template.id, - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, mode=self.services["mode"] ) - self.debug("Deployed new VM for account: %s" % self.account.account.name) + self.debug("Deployed new VM for account: %s" % self.account.name) self.cleanup.append(new_virtual_machine) self.debug("Attaching volume: %s to VM: %s" % ( @@ -434,7 +434,7 @@ class TestTemplate(cloudstackTestCase): cls.services["account"], domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls._cleanup = [ cls.account, @@ -471,8 +471,8 @@ class TestTemplate(cloudstackTestCase): self.apiclient, self.services["templates"], zoneid=self.zone.id, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("Registering template with ID: %s" % template.id) try: @@ -519,8 +519,8 @@ class TestTemplate(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], templateid=template.id, - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, ) self.debug("Deployed VM with ID: %s " % virtual_machine.id) @@ -565,15 +565,15 @@ class TestNATRules(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], templateid=template.id, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) cls.public_ip = PublicIPAddress.create( cls.api_client, - accountid=cls.account.account.name, + accountid=cls.account.name, zoneid=cls.zone.id, - domainid=cls.account.account.domainid, + domainid=cls.account.domainid, services=cls.services["virtual_machine"] ) cls._cleanup = [ @@ -817,23 +817,23 @@ class TestRouters(cloudstackTestCase): vm_1 = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], - accountid=self.admin_account.account.name, - domainid=self.admin_account.account.domainid, + accountid=self.admin_account.name, + domainid=self.admin_account.domainid, serviceofferingid=self.service_offering.id ) self.debug("Deployed VM with ID: %s" % vm_1.id) vm_2 = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], - accountid=self.user_account.account.name, - domainid=self.user_account.account.domainid, + accountid=self.user_account.name, + domainid=self.user_account.domainid, serviceofferingid=self.service_offering.id ) self.debug("Deployed VM with ID: %s" % vm_2.id) routers = list_routers( self.apiclient, - account=self.admin_account.account.name, - domainid=self.admin_account.account.domainid, + account=self.admin_account.name, + domainid=self.admin_account.domainid, ) self.assertEqual( isinstance(routers, list), @@ -887,8 +887,8 @@ class TestRouterRestart(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], templateid=template.id, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) cls.cleanup = [ @@ -927,8 +927,8 @@ class TestRouterRestart(cloudstackTestCase): # Find router associated with user account list_router_response = list_routers( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(list_router_response, list), @@ -945,8 +945,8 @@ class TestRouterRestart(cloudstackTestCase): while True: networks = Network.list( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) network = networks[0] if network.state in ["Implemented", "Setup"]: @@ -966,8 +966,8 @@ class TestRouterRestart(cloudstackTestCase): # Get router details after restart list_router_response = list_routers( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(list_router_response, list), @@ -1009,7 +1009,7 @@ class TestTemplates(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] @@ -1020,8 +1020,8 @@ class TestTemplates(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], templateid=template.id, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, ) #Stop virtual machine @@ -1091,8 +1091,8 @@ class TestTemplates(cloudstackTestCase): self.apiclient, self.services["templates"], self.volume.id, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("Creating template with ID: %s" % template.id) # Volume and Template Size should be same @@ -1121,8 +1121,8 @@ class TestTemplates(cloudstackTestCase): snapshot = Snapshot.create( self.apiclient, self.volume.id, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("Created snapshot with ID: %s" % snapshot.id) snapshots = Snapshot.list( @@ -1203,8 +1203,8 @@ class TestTemplates(cloudstackTestCase): snapshot = Snapshot.create( self.apiclient, self.volume.id, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("Created snapshot with ID: %s" % snapshot.id) snapshots = Snapshot.list( diff --git a/test/integration/component/test_egress_rules.py b/test/integration/component/test_egress_rules.py index 7972aa50639..4af6eee94f4 100644 --- a/test/integration/component/test_egress_rules.py +++ b/test/integration/component/test_egress_rules.py @@ -175,7 +175,7 @@ class TestDefaultSecurityGroupEgress(cloudstackTestCase): admin=True, domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls._cleanup = [ cls.account, @@ -208,12 +208,12 @@ class TestDefaultSecurityGroupEgress(cloudstackTestCase): # 4. listVirtualMachines should show that the VM belongs to default # security group - self.debug("Deploying VM in account: %s" % self.account.account.name) + self.debug("Deploying VM in account: %s" % self.account.name) self.virtual_machine = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) self.debug("Deployed VM with ID: %s" % self.virtual_machine.id) @@ -260,8 +260,8 @@ class TestDefaultSecurityGroupEgress(cloudstackTestCase): # Verify listSecurity groups response security_groups = SecurityGroup.list( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(security_groups, list), @@ -333,7 +333,7 @@ class TestAuthorizeIngressRule(cloudstackTestCase): cls.services["account"], domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls._cleanup = [ cls.account, cls.service_offering @@ -371,15 +371,15 @@ class TestAuthorizeIngressRule(cloudstackTestCase): security_group = SecurityGroup.create( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("Created security group with ID: %s" % security_group.id) # Default Security group should not have any ingress rule sercurity_groups = SecurityGroup.list( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(sercurity_groups, list), @@ -396,8 +396,8 @@ class TestAuthorizeIngressRule(cloudstackTestCase): ingress_rule = security_group.authorize( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(ingress_rule, dict), @@ -410,12 +410,12 @@ class TestAuthorizeIngressRule(cloudstackTestCase): self.virtual_machine = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, securitygroupids=[security_group.id] ) - self.debug("Deploying VM in account: %s" % self.account.account.name) + self.debug("Deploying VM in account: %s" % self.account.name) # Should be able to SSH VM try: self.debug("SSH into VM: %s" % self.virtual_machine.ssh_ip) @@ -491,7 +491,7 @@ class TestDefaultGroupEgress(cloudstackTestCase): cls.services["account"], domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls._cleanup = [ cls.account, cls.service_offering @@ -529,16 +529,16 @@ class TestDefaultGroupEgress(cloudstackTestCase): security_group = SecurityGroup.create( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("Created security group with ID: %s" % security_group.id) # Default Security group should not have any ingress rule sercurity_groups = SecurityGroup.list( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(sercurity_groups, list), @@ -557,8 +557,8 @@ class TestDefaultGroupEgress(cloudstackTestCase): ingress_rule = security_group.authorize( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( @@ -575,8 +575,8 @@ class TestDefaultGroupEgress(cloudstackTestCase): egress_rule = security_group.authorizeEgress( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( @@ -589,12 +589,12 @@ class TestDefaultGroupEgress(cloudstackTestCase): self.virtual_machine = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, securitygroupids=[security_group.id] ) - self.debug("Deploying VM in account: %s" % self.account.account.name) + self.debug("Deploying VM in account: %s" % self.account.name) # Should be able to SSH VM try: @@ -692,7 +692,7 @@ class TestDefaultGroupEgressAfterDeploy(cloudstackTestCase): cls.services["account"], domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls._cleanup = [ cls.account, cls.service_offering @@ -730,16 +730,16 @@ class TestDefaultGroupEgressAfterDeploy(cloudstackTestCase): security_group = SecurityGroup.create( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("Created security group with ID: %s" % security_group.id) # Default Security group should not have any ingress rule sercurity_groups = SecurityGroup.list( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(sercurity_groups, list), @@ -758,8 +758,8 @@ class TestDefaultGroupEgressAfterDeploy(cloudstackTestCase): ingress_rule = security_group.authorize( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( @@ -773,12 +773,12 @@ class TestDefaultGroupEgressAfterDeploy(cloudstackTestCase): self.virtual_machine = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, securitygroupids=[security_group.id] ) - self.debug("Deploying VM in account: %s" % self.account.account.name) + self.debug("Deploying VM in account: %s" % self.account.name) # Authorize Security group to SSH to VM self.debug( @@ -787,8 +787,8 @@ class TestDefaultGroupEgressAfterDeploy(cloudstackTestCase): egress_rule = security_group.authorizeEgress( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( @@ -875,7 +875,7 @@ class TestRevokeEgressRule(cloudstackTestCase): cls.services["account"], domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls._cleanup = [ cls.account, cls.service_offering @@ -915,16 +915,16 @@ class TestRevokeEgressRule(cloudstackTestCase): security_group = SecurityGroup.create( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("Created security group with ID: %s" % security_group.id) # Default Security group should not have any ingress rule sercurity_groups = SecurityGroup.list( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(sercurity_groups, list), @@ -944,8 +944,8 @@ class TestRevokeEgressRule(cloudstackTestCase): ingress_rule = security_group.authorize( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( @@ -963,8 +963,8 @@ class TestRevokeEgressRule(cloudstackTestCase): egress_rule = security_group.authorizeEgress( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( @@ -977,12 +977,12 @@ class TestRevokeEgressRule(cloudstackTestCase): self.virtual_machine = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, securitygroupids=[security_group.id] ) - self.debug("Deploying VM in account: %s" % self.account.account.name) + self.debug("Deploying VM in account: %s" % self.account.name) # Should be able to SSH VM try: @@ -1033,7 +1033,7 @@ class TestRevokeEgressRule(cloudstackTestCase): "Revoke Egress Rule for Security Group %s for account: %s" \ % ( security_group.id, - self.account.account.name + self.account.name )) result = security_group.revokeEgress( @@ -1137,7 +1137,7 @@ class TestInvalidAccountAuthroize(cloudstackTestCase): cls.services["account"], domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls._cleanup = [ cls.account, cls.service_offering @@ -1173,16 +1173,16 @@ class TestInvalidAccountAuthroize(cloudstackTestCase): security_group = SecurityGroup.create( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("Created security group with ID: %s" % security_group.id) # Default Security group should not have any ingress rule sercurity_groups = SecurityGroup.list( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(sercurity_groups, list), @@ -1205,7 +1205,7 @@ class TestInvalidAccountAuthroize(cloudstackTestCase): self.apiclient, self.services["security_group"], account=random_gen(), - domainid=self.account.account.domainid + domainid=self.account.domainid ) return @@ -1804,7 +1804,7 @@ class TestStartStopVMWithEgressRule(cloudstackTestCase): cls.services["account"], domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls._cleanup = [ cls.account, cls.service_offering @@ -1842,16 +1842,16 @@ class TestStartStopVMWithEgressRule(cloudstackTestCase): security_group = SecurityGroup.create( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("Created security group with ID: %s" % security_group.id) # Default Security group should not have any ingress rule sercurity_groups = SecurityGroup.list( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(sercurity_groups, list), @@ -1871,8 +1871,8 @@ class TestStartStopVMWithEgressRule(cloudstackTestCase): ingress_rule = security_group.authorize( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( @@ -1886,12 +1886,12 @@ class TestStartStopVMWithEgressRule(cloudstackTestCase): self.virtual_machine = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, securitygroupids=[security_group.id] ) - self.debug("Deploying VM in account: %s" % self.account.account.name) + self.debug("Deploying VM in account: %s" % self.account.name) # Authorize Security group to SSH to VM self.debug( @@ -1900,8 +1900,8 @@ class TestStartStopVMWithEgressRule(cloudstackTestCase): egress_rule = security_group.authorizeEgress( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( @@ -2016,7 +2016,7 @@ class TestInvalidParametersForEgress(cloudstackTestCase): cls.services["account"], domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls._cleanup = [ cls.account, cls.service_offering @@ -2054,16 +2054,16 @@ class TestInvalidParametersForEgress(cloudstackTestCase): security_group = SecurityGroup.create( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("Created security group with ID: %s" % security_group.id) # Default Security group should not have any ingress rule sercurity_groups = SecurityGroup.list( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(sercurity_groups, list), @@ -2085,8 +2085,8 @@ class TestInvalidParametersForEgress(cloudstackTestCase): egress_rule = security_group.authorizeEgress( self.apiclient, self.services["sg_invalid_port"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug( "Authorizing egress rule for sec group ID: %s with invalid cidr" @@ -2095,8 +2095,8 @@ class TestInvalidParametersForEgress(cloudstackTestCase): egress_rule = security_group.authorizeEgress( self.apiclient, self.services["sg_invalid_cidr"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug( "Authorizing egress rule for sec group ID: %s with invalid account" @@ -2106,7 +2106,7 @@ class TestInvalidParametersForEgress(cloudstackTestCase): self.apiclient, self.services["security_group"], account=random_gen(), - domainid=self.account.account.domainid + domainid=self.account.domainid ) self.debug( "Authorizing egress rule for sec group ID: %s with cidr: anywhere and port: 22" @@ -2114,8 +2114,8 @@ class TestInvalidParametersForEgress(cloudstackTestCase): egress_rule_A = security_group.authorizeEgress( self.apiclient, self.services["sg_cidr_anywhere"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( @@ -2127,8 +2127,8 @@ class TestInvalidParametersForEgress(cloudstackTestCase): egress_rule_R = security_group.authorizeEgress( self.apiclient, self.services["sg_cidr_restricted"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( @@ -2144,8 +2144,8 @@ class TestInvalidParametersForEgress(cloudstackTestCase): security_group.authorizeEgress( self.apiclient, self.services["sg_cidr_restricted"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) return @@ -2203,7 +2203,7 @@ class TestEgressAfterHostMaintainance(cloudstackTestCase): cls.services["account"], domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls._cleanup = [ cls.account, cls.service_offering @@ -2241,16 +2241,16 @@ class TestEgressAfterHostMaintainance(cloudstackTestCase): security_group = SecurityGroup.create( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("Created security group with ID: %s" % security_group.id) # Default Security group should not have any ingress rule sercurity_groups = SecurityGroup.list( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(sercurity_groups, list), @@ -2270,8 +2270,8 @@ class TestEgressAfterHostMaintainance(cloudstackTestCase): ingress_rule = security_group.authorize( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( @@ -2289,8 +2289,8 @@ class TestEgressAfterHostMaintainance(cloudstackTestCase): egress_rule = security_group.authorizeEgress( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( @@ -2303,12 +2303,12 @@ class TestEgressAfterHostMaintainance(cloudstackTestCase): self.virtual_machine = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, securitygroupids=[security_group.id] ) - self.debug("Deploying VM in account: %s" % self.account.account.name) + self.debug("Deploying VM in account: %s" % self.account.name) # Should be able to SSH VM try: diff --git a/test/integration/component/test_eip_elb.py b/test/integration/component/test_eip_elb.py index c1ad50530b5..cb41859acd3 100644 --- a/test/integration/component/test_eip_elb.py +++ b/test/integration/component/test_eip_elb.py @@ -119,8 +119,8 @@ class TestEIP(cloudstackTestCase): cls.virtual_machine = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) networks = Network.list( @@ -140,8 +140,8 @@ class TestEIP(cloudstackTestCase): cls.api_client, associatednetworkid=cls.guest_network.id, isstaticnat=True, - account=cls.account.account.name, - domainid=cls.account.account.domainid, + account=cls.account.name, + domainid=cls.account.domainid, listall=True ) if isinstance(ip_addrs, list): @@ -240,8 +240,8 @@ class TestEIP(cloudstackTestCase): # Verify listSecurity groups response security_groups = SecurityGroup.list( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(security_groups, list), @@ -262,8 +262,8 @@ class TestEIP(cloudstackTestCase): "Creating Ingress rule to allow SSH on default security group") cmd = authorizeSecurityGroupIngress.authorizeSecurityGroupIngressCmd() - cmd.domainid = self.account.account.domainid - cmd.account = self.account.account.name + cmd.domainid = self.account.domainid + cmd.account = self.account.name cmd.securitygroupid = security_group.id cmd.protocol = 'TCP' cmd.startport = 22 @@ -370,16 +370,16 @@ class TestEIP(cloudstackTestCase): public_ip = PublicIPAddress.create( self.apiclient, - accountid=self.account.account.name, + accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, services=self.services["virtual_machine"] ) self.debug("IP address: %s is acquired by network: %s" % ( - public_ip.ipaddress.ipaddress, + public_ip.ipaddress, self.guest_network.id)) self.debug("Enabling static NAT for IP Address: %s" % - public_ip.ipaddress.ipaddress) + public_ip.ipaddress) StaticNATRule.enable( self.apiclient, @@ -390,11 +390,11 @@ class TestEIP(cloudstackTestCase): # Fetch details from user_ip_address table in database self.debug( "select is_system, one_to_one_nat from user_ip_address where public_ip_address='%s';" \ - % public_ip.ipaddress.ipaddress) + % public_ip.ipaddress) qresultset = self.dbclient.execute( "select is_system, one_to_one_nat from user_ip_address where public_ip_address='%s';" \ - % public_ip.ipaddress.ipaddress + % public_ip.ipaddress ) self.assertEqual( isinstance(qresultset, list), @@ -449,12 +449,12 @@ class TestEIP(cloudstackTestCase): ) # try: -# self.debug("SSH into VM: %s" % public_ip.ipaddress.ipaddress) +# self.debug("SSH into VM: %s" % public_ip.ipaddress) # ssh = self.virtual_machine.get_ssh_client( -# ipaddress=public_ip.ipaddress.ipaddress) +# ipaddress=public_ip.ipaddress) # except Exception as e: # self.fail("SSH Access failed for %s: %s" % \ -# (public_ip.ipaddress.ipaddress, e) +# (public_ip.ipaddress, e) # ) self.debug("SSH into netscaler: %s" % @@ -472,7 +472,7 @@ class TestEIP(cloudstackTestCase): self.debug("Output: %s" % result) self.assertEqual( - result.count(public_ip.ipaddress.ipaddress), + result.count(public_ip.ipaddress), 1, "One IP from EIP pool should be taken and configured on NS" ) @@ -484,7 +484,7 @@ class TestEIP(cloudstackTestCase): self.debug("Output: %s" % result) self.assertEqual( - result.count("NAME: Cloud-Inat-%s" % public_ip.ipaddress.ipaddress), + result.count("NAME: Cloud-Inat-%s" % public_ip.ipaddress), 1, "User source IP should be enabled for INAT service" ) @@ -517,8 +517,8 @@ class TestEIP(cloudstackTestCase): self.api_client, associatednetworkid=self.guest_network.id, isstaticnat=True, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -602,8 +602,8 @@ class TestEIP(cloudstackTestCase): self.api_client, associatednetworkid=self.guest_network.id, isstaticnat=True, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -711,8 +711,8 @@ class TestEIP(cloudstackTestCase): self.api_client, associatednetworkid=self.guest_network.id, isstaticnat=True, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -784,8 +784,8 @@ class TestEIP(cloudstackTestCase): self.api_client, associatednetworkid=self.guest_network.id, isstaticnat=True, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, listall=True ) self.assertEqual( @@ -942,15 +942,15 @@ class TestELB(cloudstackTestCase): cls.vm_1 = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) cls.vm_2 = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) networks = Network.list( @@ -968,9 +968,9 @@ class TestELB(cloudstackTestCase): cls.lb_rule = LoadBalancerRule.create( cls.api_client, cls.services["lbrule"], - accountid=cls.account.account.name, + accountid=cls.account.name, networkid=cls.guest_network.id, - domainid=cls.account.account.domainid + domainid=cls.account.domainid ) cls.lb_rule.assign(cls.api_client, [cls.vm_1, cls.vm_2]) @@ -1024,8 +1024,8 @@ class TestELB(cloudstackTestCase): # Verify listSecurity groups response security_groups = SecurityGroup.list( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(security_groups, list), @@ -1046,8 +1046,8 @@ class TestELB(cloudstackTestCase): "Creating Ingress rule to allow SSH on default security group") cmd = authorizeSecurityGroupIngress.authorizeSecurityGroupIngressCmd() - cmd.domainid = self.account.account.domainid - cmd.account = self.account.account.name + cmd.domainid = self.account.domainid + cmd.account = self.account.name cmd.securitygroupid = security_group.id cmd.protocol = 'TCP' cmd.startport = 22 @@ -1056,12 +1056,12 @@ class TestELB(cloudstackTestCase): self.apiclient.authorizeSecurityGroupIngress(cmd) self.debug( - "Fetching LB IP for account: %s" % self.account.account.name) + "Fetching LB IP for account: %s" % self.account.name) ip_addrs = PublicIPAddress.list( self.api_client, associatednetworkid=self.guest_network.id, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, forloadbalancing=True, listall=True ) @@ -1073,7 +1073,7 @@ class TestELB(cloudstackTestCase): lb_ip = ip_addrs[0] self.debug("LB IP generated for account: %s is: %s" % ( - self.account.account.name, + self.account.name, lb_ip.ipaddress )) #TODO: uncomment this after ssh issue is resolved @@ -1199,24 +1199,24 @@ class TestELB(cloudstackTestCase): public_ip = PublicIPAddress.create( self.apiclient, - accountid=self.account.account.name, + accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, services=self.services["virtual_machine"] ) self.debug("IP address: %s is acquired by network: %s" % ( - public_ip.ipaddress.ipaddress, + public_ip.ipaddress, self.guest_network.id)) self.debug("Creating LB rule for public IP: %s" % - public_ip.ipaddress.ipaddress) + public_ip.ipaddress) lb_rule = LoadBalancerRule.create( self.apiclient, self.services["lbrule"], - accountid=self.account.account.name, + accountid=self.account.name, ipaddressid=public_ip.ipaddress.id, networkid=self.guest_network.id, - domainid=self.account.account.domaind + domainid=self.account.domaind ) self.debug("Assigning VMs (%s, %s) to LB rule: %s" % (self.vm_1.name, self.vm_2.name, @@ -1225,10 +1225,10 @@ class TestELB(cloudstackTestCase): #TODO: workaround : add route in the guest VM for SNIP # # self.debug("SSHing into VMs using ELB IP: %s" % -# public_ip.ipaddress.ipaddress) +# public_ip.ipaddress) # try: # ssh_1 = self.vm_1.get_ssh_client( -# ipaddress=public_ip.ipaddress.ipaddress) +# ipaddress=public_ip.ipaddress) # self.debug("Command: hostname") # result = ssh_1.execute("hostname") # self.debug("Result: %s" % result) @@ -1244,7 +1244,7 @@ class TestELB(cloudstackTestCase): # ) # # ssh_2 = self.vm_2.get_ssh_client( -# ipaddress=public_ip.ipaddress.ipaddress) +# ipaddress=public_ip.ipaddress) # self.debug("Command: hostname") # result = ssh_2.execute("hostname") # self.debug("Result: %s" % result) @@ -1265,11 +1265,11 @@ class TestELB(cloudstackTestCase): ## Fetch details from user_ip_address table in database self.debug( "select is_system from user_ip_address where public_ip_address='%s';" \ - % public_ip.ipaddress.ipaddress) + % public_ip.ipaddress) qresultset = self.dbclient.execute( "select is_system from user_ip_address where public_ip_address='%s';" \ - % public_ip.ipaddress.ipaddress) + % public_ip.ipaddress) self.assertEqual( isinstance(qresultset, list), @@ -1304,7 +1304,7 @@ class TestELB(cloudstackTestCase): self.debug("Output: %s" % result) self.assertEqual( - result.count(public_ip.ipaddress.ipaddress), + result.count(public_ip.ipaddress), 1, "One IP from EIP pool should be taken and configured on NS" ) @@ -1316,7 +1316,7 @@ class TestELB(cloudstackTestCase): self.debug("Output: %s" % result) self.assertEqual( - result.count("Cloud-VirtualServer-%s-22 (%s:22) - TCP" % (public_ip.ipaddress.ipaddress, public_ip.ipaddress.ipaddress)), + result.count("Cloud-VirtualServer-%s-22 (%s:22) - TCP" % (public_ip.ipaddress, public_ip.ipaddress)), 1, "User subnet IP should be enabled for LB service" ) @@ -1342,12 +1342,12 @@ class TestELB(cloudstackTestCase): # running and USNIP : ON self.debug( - "Fetching LB IP for account: %s" % self.account.account.name) + "Fetching LB IP for account: %s" % self.account.name) ip_addrs = PublicIPAddress.list( self.api_client, associatednetworkid=self.guest_network.id, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, forloadbalancing=True, listall=True ) @@ -1359,7 +1359,7 @@ class TestELB(cloudstackTestCase): lb_ip = ip_addrs[0] self.debug("LB IP generated for account: %s is: %s" % ( - self.account.account.name, + self.account.name, lb_ip.ipaddress )) @@ -1424,11 +1424,11 @@ class TestELB(cloudstackTestCase): # Fetch details from account_id table in database self.debug( "select id from account where account_name='%s';" \ - % self.account.account.name) + % self.account.name) qresultset = self.dbclient.execute( "select id from account where account_name='%s';" \ - % self.account.account.name) + % self.account.name) self.assertEqual( isinstance(qresultset, list), @@ -1467,7 +1467,7 @@ class TestELB(cloudstackTestCase): public_ip = qresult[0] self.debug( - "Fetching public IP for account: %s" % self.account.account.name) + "Fetching public IP for account: %s" % self.account.name) ip_addrs = PublicIPAddress.list( self.api_client, ipaddress=public_ip, diff --git a/test/integration/component/test_multiple_ip_ranges.py b/test/integration/component/test_multiple_ip_ranges.py index 489e7ca3bdf..29942bd3af2 100644 --- a/test/integration/component/test_multiple_ip_ranges.py +++ b/test/integration/component/test_multiple_ip_ranges.py @@ -18,6 +18,7 @@ """ from marvin.cloudstackTestCase import * from marvin.cloudstackAPI import * +from marvin.cloudstackException import cloudstackAPIException from marvin.integration.lib.utils import * from marvin.integration.lib.base import * from marvin.integration.lib.common import * @@ -88,7 +89,7 @@ class TestMultipleIpRanges(cloudstackTestCase): cls.services["account"], domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls._cleanup = [ cls.account, ] @@ -144,23 +145,23 @@ class TestMultipleIpRanges(cloudstackTestCase): "check list vlan response" ) self.assertEqual( - vlan[0].startip, - services["startip"], + str(vlan[0].startip), + str(services["startip"]), "Start IP in vlan ip range is not matched with the configured start ip" ) self.assertEqual( - vlan[0].endip, - services["endip"], + str(vlan[0].endip), + str(services["endip"]), "End IP in vlan ip range is not matched with the configured end ip" ) self.assertEqual( - vlan[0].gateway, - services["gateway"], + str(vlan[0].gateway), + str(services["gateway"]), "gateway in vlan ip range is not matched with the configured gateway" ) self.assertEqual( - vlan[0].netmask, - services["netmask"], + str(vlan[0].netmask), + str(services["netmask"]), "netmask in vlan ip range is not matched with the configured netmask" ) return @@ -172,12 +173,13 @@ class TestMultipleIpRanges(cloudstackTestCase): #call increment_cidr function to get exiting cidr from the setup and increment it ip2 = self.increment_cidr() test_nw = ip2.network + ip = IPAddress(test_nw) #Add IP range(5 IPs) in the new CIDR - test_gateway = test_nw+1 - test_startIp = test_nw+2 - test_endIp = test_startIp+5 - test_startIp2= test_endIp+5 - test_endIp2 = test_startIp2+5 + test_gateway = ip.__add__(1) + test_startIp = ip.__add__(3) + test_endIp = ip.__add__(10) + test_startIp2= ip.__add__(11) + test_endIp2 = ip.__add__(15) #Populating services with new IP range self.services["vlan_ip_range"]["startip"] = test_startIp self.services["vlan_ip_range"]["endip"] = test_endIp @@ -189,7 +191,7 @@ class TestMultipleIpRanges(cloudstackTestCase): new_vlan = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"]) self.debug("Created new vlan range with startip:%s and endip:%s" %(test_startIp,test_endIp)) self.cleanup.append(new_vlan) - new_vlan_res = new_vlan.list(self.apiclient,new_vlan.id) + new_vlan_res = new_vlan.list(self.apiclient,id=new_vlan.vlan.id) #Compare list output with configured values self.verify_vlan_range(new_vlan_res,self.services["vlan_ip_range"]) #Add few more ips in the same CIDR @@ -199,7 +201,7 @@ class TestMultipleIpRanges(cloudstackTestCase): self.debug("Created new vlan range with startip:%s and endip:%s" %(test_startIp2,test_endIp2)) self.cleanup.append(new_vlan2) #list new vlan ip range - new_vlan2_res = new_vlan2.list(self.apiclient,new_vlan2.id) + new_vlan2_res = new_vlan2.list(self.apiclient,id=new_vlan2.vlan.id) #Compare list output with configured values self.verify_vlan_range(new_vlan2_res,self.services["vlan_ip_range"]) return @@ -215,10 +217,11 @@ class TestMultipleIpRanges(cloudstackTestCase): #call increment_cidr function to get exiting cidr from the setup and increment it ip2 = self.increment_cidr() test_nw = ip2.network + ip = IPAddress(test_nw) #Add IP range(5 IPs) in the new CIDR - test_gateway = test_nw+1 - test_startIp = test_nw+2 - test_endIp = test_startIp+5 + test_gateway = ip.__add__(1) + test_startIp = ip.__add__(3) + test_endIp = ip.__add__(10) #Populating services with new IP range self.services["vlan_ip_range"]["startip"] = test_startIp self.services["vlan_ip_range"]["endip"] = test_endIp @@ -230,9 +233,138 @@ class TestMultipleIpRanges(cloudstackTestCase): new_vlan = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"]) self.debug("Created new vlan range with startip:%s and endip:%s" %(test_startIp,test_endIp)) self.cleanup.append(new_vlan) - new_vlan_res = new_vlan.list(self.apiclient,new_vlan.id) + new_vlan_res = new_vlan.list(self.apiclient,id=new_vlan.vlan.id) #Compare list output with configured values self.verify_vlan_range(new_vlan_res,self.services["vlan_ip_range"]) return + @attr(tags=["advanced-sg", "sg"]) + def test_03_del_ip_range(self): + """Test delete ip range + Steps: + 1.Add ip range in same/new cidr + 2.delete the ip range added at step1 + 3.Verify the ip range deletion using list APIs + """ + #call increment_cidr function to get exiting cidr from the setup and increment it + ip2 = self.increment_cidr() + test_nw = ip2.network + ip = IPAddress(test_nw) + #Add IP range(5 IPs) in the new CIDR + test_gateway = ip.__add__(1) + test_startIp = ip.__add__(3) + test_endIp = ip.__add__(10) + #Populating services with new IP range + self.services["vlan_ip_range"]["startip"] = test_startIp + self.services["vlan_ip_range"]["endip"] = test_endIp + self.services["vlan_ip_range"]["gateway"] = test_gateway + self.services["vlan_ip_range"]["netmask"] = self.netmask + self.services["vlan_ip_range"]["zoneid"] = self.zone.id + self.services["vlan_ip_range"]["podid"] = self.pod.id + #create new vlan ip range + new_vlan = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"]) + self.debug("Created new vlan range with startip:%s and endip:%s" %(test_startIp,test_endIp)) + new_vlan_res = new_vlan.list(self.apiclient,id=new_vlan.vlan.id) + #Compare list output with configured values + self.verify_vlan_range(new_vlan_res,self.services["vlan_ip_range"]) + #Delete the above IP range + new_vlan.delete(self.apiclient) + #listing vlan ip ranges with the id should through exception , if not mark the test case as failed + try: + new_vlan.list(self.apiclient, id=new_vlan.vlan.id) + except cloudstackAPIException as cs: + self.debug(cs.errorMsg) + self.assertTrue(cs.errorMsg.find("entity does not exist")>0, msg="Failed to delete IP range") + return + + @attr(tags=["advanced-sg", "sg"]) + def test_04_add_noncontiguous_ip_range(self): + """Test adding non-contiguous ip range in existing cidr + + 1.Add ip range in new cidr + 1.Add non-contigous ip range in cidr added at step1 + 2.Verify the ip range using list APIs + """ + #call increment_cidr function to get exiting cidr from the setup and increment it + ip2 = self.increment_cidr() + test_nw = ip2.network + ip = IPAddress(test_nw) + #Add IP range(5 IPs) in the new CIDR + test_gateway = ip.__add__(1) + test_startIp = ip.__add__(50) + test_endIp = ip.__add__(60) + #Populating services with new IP range + self.services["vlan_ip_range"]["startip"] = test_startIp + self.services["vlan_ip_range"]["endip"] = test_endIp + self.services["vlan_ip_range"]["gateway"] = test_gateway + self.services["vlan_ip_range"]["netmask"] = self.netmask + self.services["vlan_ip_range"]["zoneid"] = self.zone.id + self.services["vlan_ip_range"]["podid"] = self.pod.id + #create new vlan ip range + new_vlan = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"]) + self.debug("Created new vlan range with startip:%s and endip:%s" %(test_startIp,test_endIp)) + self.cleanup.append(new_vlan) + new_vlan_res = new_vlan.list(self.apiclient,id=new_vlan.vlan.id) + #Compare list output with configured values + self.verify_vlan_range(new_vlan_res,self.services["vlan_ip_range"]) + #Add non-contiguous ip range in exiting cidr + test_startIp2 = ip.__add__(10) + test_endIp2 = ip.__add__(20) + #Populating services with new IP range + self.services["vlan_ip_range"]["startip"] = test_startIp2 + self.services["vlan_ip_range"]["endip"] = test_endIp2 + #create new vlan ip range + new_vlan = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"]) + self.debug("Created new vlan range with startip:%s and endip:%s" %(test_startIp,test_endIp)) + self.cleanup.append(new_vlan) + new_vlan_res = new_vlan.list(self.apiclient,id=new_vlan.vlan.id) + #Compare list output with configured values + self.verify_vlan_range(new_vlan_res,self.services["vlan_ip_range"]) + return + + @attr(tags=["advanced-sg", "sg"]) + def test_05_add_overlapped_ip_range(self): + """Test adding overlapped ip range in existing cidr + + 1.Add ip range in new cidr e.g:10.147.40.10-10.147.40.100 + 2.Add ip range overlapped with the ip range in step1 e.g.10.147.40.90-150 + """ + #call increment_cidr function to get exiting cidr from the setup and increment it + ip2 = self.increment_cidr() + test_nw = ip2.network + ip = IPAddress(test_nw) + #Add IP range in the new CIDR + test_gateway = ip.__add__(1) + test_startIp = ip.__add__(10) + test_endIp = ip.__add__(100) + test_startIp2 = ip.__add__(90) + test_endIp2 = ip.__add__(150) + #Populating services with new IP range + self.services["vlan_ip_range"]["startip"] = test_startIp + self.services["vlan_ip_range"]["endip"] = test_endIp + self.services["vlan_ip_range"]["gateway"] = test_gateway + self.services["vlan_ip_range"]["netmask"] = self.netmask + self.services["vlan_ip_range"]["zoneid"] = self.zone.id + self.services["vlan_ip_range"]["podid"] = self.pod.id + #create new vlan ip range + new_vlan = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"]) + self.debug("Created new vlan range with startip:%s and endip:%s" %(test_startIp,test_endIp)) + self.cleanup.append(new_vlan) + new_vlan_res = new_vlan.list(self.apiclient,id=new_vlan.vlan.id) + #Compare list output with configured values + self.verify_vlan_range(new_vlan_res,self.services["vlan_ip_range"]) + #Add overlapped ip range + #Populating services with new IP range + self.services["vlan_ip_range"]["startip"] = test_startIp2 + self.services["vlan_ip_range"]["endip"] = test_endIp2 + #Try to create ip range overlapped with exiting ip range + try: + PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"]) + except cloudstackAPIException as cs: + self.debug(cs.errorMsg) + self.assertTrue(cs.errorMsg.find("already has IPs that overlap with the new range")>0, msg="Fail:CS allowed adding overlapped ip ranges in guest cidr") + return + #Test will reach here there is a bug in overlap ip range checking + self.fail("CS should not accept overlapped ip ranges in guest traffic, but it allowed") + return diff --git a/test/integration/component/test_network_offering.py b/test/integration/component/test_network_offering.py index 8b12525103a..00566a0d400 100644 --- a/test/integration/component/test_network_offering.py +++ b/test/integration/component/test_network_offering.py @@ -256,21 +256,21 @@ class TestNOVirtualRouter(cloudstackTestCase): self.network = Network.create( self.apiclient, self.services["network"], - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id ) self.debug("Created network with ID: %s" % self.network.id) - self.debug("Deploying VM in account: %s" % self.account.account.name) + self.debug("Deploying VM in account: %s" % self.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, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(self.network.id)] ) @@ -279,8 +279,8 @@ class TestNOVirtualRouter(cloudstackTestCase): src_nat_list = PublicIPAddress.list( self.apiclient, associatednetworkid=self.network.id, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, listall=True, issourcenat=True, ) @@ -305,7 +305,7 @@ class TestNOVirtualRouter(cloudstackTestCase): self.apiclient, self.services["lbrule"], ipaddressid=src_nat.id, - accountid=self.account.account.name + accountid=self.account.name ) self.debug( "Trying to create a port forwarding rule in source NAT: %s" % @@ -322,18 +322,18 @@ class TestNOVirtualRouter(cloudstackTestCase): self.debug("Associating public IP for network: %s" % self.network.id) ip_with_nat_rule = PublicIPAddress.create( self.apiclient, - accountid=self.account.account.name, + accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=self.network.id ) self.debug("Associated %s with network %s" % ( - ip_with_nat_rule.ipaddress.ipaddress, + ip_with_nat_rule.ipaddress, self.network.id )) self.debug("Creating PF rule for IP address: %s" % - ip_with_nat_rule.ipaddress.ipaddress) + ip_with_nat_rule.ipaddress) NATRule.create( self.apiclient, virtual_machine, @@ -342,7 +342,7 @@ class TestNOVirtualRouter(cloudstackTestCase): ) self.debug("Trying to create LB rule on IP with NAT: %s" % - ip_with_nat_rule.ipaddress.ipaddress) + ip_with_nat_rule.ipaddress) # Create Load Balancer rule on IP already having NAT rule with self.assertRaises(Exception): @@ -350,7 +350,7 @@ class TestNOVirtualRouter(cloudstackTestCase): self.apiclient, self.services["lbrule"], ipaddressid=ip_with_nat_rule.ipaddress.id, - accountid=self.account.account.name + accountid=self.account.name ) self.debug("Creating PF rule with public port: 66") @@ -376,27 +376,27 @@ class TestNOVirtualRouter(cloudstackTestCase): self.debug("Associating public IP for network: %s" % self.network.id) ip_with_lb_rule = PublicIPAddress.create( self.apiclient, - accountid=self.account.account.name, + accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=self.network.id ) self.debug("Associated %s with network %s" % ( - ip_with_lb_rule.ipaddress.ipaddress, + ip_with_lb_rule.ipaddress, self.network.id )) self.debug("Creating LB rule for IP address: %s" % - ip_with_lb_rule.ipaddress.ipaddress) + ip_with_lb_rule.ipaddress) LoadBalancerRule.create( self.apiclient, self.services["lbrule"], ipaddressid=ip_with_lb_rule.ipaddress.id, - accountid=self.account.account.name + accountid=self.account.name ) self.debug("Trying to create PF rule on IP with LB rule: %s" % - ip_with_nat_rule.ipaddress.ipaddress) + ip_with_nat_rule.ipaddress) with self.assertRaises(Exception): NATRule.create( @@ -411,7 +411,7 @@ class TestNOVirtualRouter(cloudstackTestCase): self.apiclient, self.services["lbrule_port_2221"], ipaddressid=ip_with_lb_rule.ipaddress.id, - accountid=self.account.account.name + accountid=self.account.name ) # Check if NAT rule created successfully @@ -499,21 +499,21 @@ class TestNOVirtualRouter(cloudstackTestCase): self.network = Network.create( self.apiclient, self.services["network"], - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id ) self.debug("Created network with ID: %s" % self.network.id) - self.debug("Deploying VM in account: %s" % self.account.account.name) + self.debug("Deploying VM in account: %s" % self.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, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(self.network.id)] ) @@ -522,8 +522,8 @@ class TestNOVirtualRouter(cloudstackTestCase): src_nat_list = PublicIPAddress.list( self.apiclient, associatednetworkid=self.network.id, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, listall=True, issourcenat=True, ) @@ -547,7 +547,7 @@ class TestNOVirtualRouter(cloudstackTestCase): self.apiclient, self.services["lbrule"], ipaddressid=src_nat.id, - accountid=self.account.account.name + accountid=self.account.name ) self.debug("Created LB rule on source NAT: %s" % src_nat.ipaddress) @@ -624,18 +624,18 @@ class TestNOVirtualRouter(cloudstackTestCase): self.debug("Associating public IP for network: %s" % self.network.id) public_ip = PublicIPAddress.create( self.apiclient, - accountid=self.account.account.name, + accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=self.network.id ) self.debug("Associated %s with network %s" % ( - public_ip.ipaddress.ipaddress, + public_ip.ipaddress, self.network.id )) self.debug("Creating PF rule for IP address: %s" % - public_ip.ipaddress.ipaddress) + public_ip.ipaddress) NATRule.create( self.apiclient, virtual_machine, @@ -644,14 +644,14 @@ class TestNOVirtualRouter(cloudstackTestCase): ) self.debug("Trying to create LB rule on IP with NAT: %s" % - public_ip.ipaddress.ipaddress) + public_ip.ipaddress) # Create Load Balancer rule on IP already having NAT rule lb_rule = LoadBalancerRule.create( self.apiclient, self.services["lbrule"], ipaddressid=public_ip.ipaddress.id, - accountid=self.account.account.name + accountid=self.account.name ) self.debug("Creating PF rule with public port: 66") @@ -679,7 +679,7 @@ class TestNOVirtualRouter(cloudstackTestCase): self.apiclient, self.services["lbrule_port_2221"], ipaddressid=public_ip.ipaddress.id, - accountid=self.account.account.name + accountid=self.account.name ) # Check if NAT rule created successfully @@ -700,8 +700,8 @@ class TestNOVirtualRouter(cloudstackTestCase): vpn = Vpn.create( self.apiclient, src_nat.id, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) vpns = Vpn.list( @@ -834,21 +834,21 @@ class TestNOWithNetscaler(cloudstackTestCase): self.network = Network.create( self.apiclient, self.services["network"], - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id ) self.debug("Created network with ID: %s" % self.network.id) - self.debug("Deploying VM in account: %s" % self.account.account.name) + self.debug("Deploying VM in account: %s" % self.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, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(self.network.id)] ) @@ -857,8 +857,8 @@ class TestNOWithNetscaler(cloudstackTestCase): src_nat_list = PublicIPAddress.list( self.apiclient, associatednetworkid=self.network.id, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, listall=True, issourcenat=True, ) @@ -883,7 +883,7 @@ class TestNOWithNetscaler(cloudstackTestCase): self.apiclient, self.services["lbrule"], ipaddressid=src_nat.id, - accountid=self.account.account.name + accountid=self.account.name ) self.debug( @@ -930,18 +930,18 @@ class TestNOWithNetscaler(cloudstackTestCase): self.debug("Associating public IP for network: %s" % self.network.id) ip_with_nat_rule = PublicIPAddress.create( self.apiclient, - accountid=self.account.account.name, + accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=self.network.id ) self.debug("Associated %s with network %s" % ( - ip_with_nat_rule.ipaddress.ipaddress, + ip_with_nat_rule.ipaddress, self.network.id )) self.debug("Creating PF rule for IP address: %s" % - ip_with_nat_rule.ipaddress.ipaddress) + ip_with_nat_rule.ipaddress) NATRule.create( self.apiclient, virtual_machine, @@ -950,7 +950,7 @@ class TestNOWithNetscaler(cloudstackTestCase): ) self.debug("Trying to create LB rule on IP with NAT: %s" % - ip_with_nat_rule.ipaddress.ipaddress) + ip_with_nat_rule.ipaddress) # Create Load Balancer rule on IP already having NAT rule with self.assertRaises(Exception): @@ -958,7 +958,7 @@ class TestNOWithNetscaler(cloudstackTestCase): self.apiclient, self.services["lbrule"], ipaddressid=ip_with_nat_rule.ipaddress.id, - accountid=self.account.account.name + accountid=self.account.name ) self.debug("Creating PF rule with public port: 66") @@ -984,28 +984,28 @@ class TestNOWithNetscaler(cloudstackTestCase): self.debug("Associating public IP for network: %s" % self.network.id) ip_with_lb_rule = PublicIPAddress.create( self.apiclient, - accountid=self.account.account.name, + accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=self.network.id ) self.debug("Associated %s with network %s" % ( - ip_with_lb_rule.ipaddress.ipaddress, + ip_with_lb_rule.ipaddress, self.network.id )) self.debug("Creating LB rule for IP address: %s" % - ip_with_lb_rule.ipaddress.ipaddress) + ip_with_lb_rule.ipaddress) LoadBalancerRule.create( self.apiclient, self.services["lbrule"], ipaddressid=ip_with_lb_rule.ipaddress.id, - accountid=self.account.account.name, + accountid=self.account.name, networkid=self.network.id ) self.debug("Trying to create PF rule on IP with LB rule: %s" % - ip_with_nat_rule.ipaddress.ipaddress) + ip_with_nat_rule.ipaddress) with self.assertRaises(Exception): NATRule.create( @@ -1031,7 +1031,7 @@ class TestNOWithNetscaler(cloudstackTestCase): self.apiclient, self.services["lbrule_port_2221"], ipaddressid=ip_with_lb_rule.ipaddress.id, - accountid=self.account.account.name, + accountid=self.account.name, networkid=self.network.id ) @@ -1054,8 +1054,8 @@ class TestNOWithNetscaler(cloudstackTestCase): Vpn.create( self.apiclient, src_nat.id, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) return @@ -1104,21 +1104,21 @@ class TestNOWithNetscaler(cloudstackTestCase): self.network = Network.create( self.apiclient, self.services["network"], - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id ) self.debug("Created network with ID: %s" % self.network.id) - self.debug("Deploying VM in account: %s" % self.account.account.name) + self.debug("Deploying VM in account: %s" % self.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, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(self.network.id)] ) @@ -1127,8 +1127,8 @@ class TestNOWithNetscaler(cloudstackTestCase): src_nat_list = PublicIPAddress.list( self.apiclient, associatednetworkid=self.network.id, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, listall=True, issourcenat=True, ) @@ -1153,7 +1153,7 @@ class TestNOWithNetscaler(cloudstackTestCase): self.apiclient, self.services["lbrule"], ipaddressid=src_nat.id, - accountid=self.account.account.name + accountid=self.account.name ) self.debug( @@ -1213,18 +1213,18 @@ class TestNOWithNetscaler(cloudstackTestCase): self.debug("Associating public IP for network: %s" % self.network.id) ip_with_nat_rule = PublicIPAddress.create( self.apiclient, - accountid=self.account.account.name, + accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=self.network.id ) self.debug("Associated %s with network %s" % ( - ip_with_nat_rule.ipaddress.ipaddress, + ip_with_nat_rule.ipaddress, self.network.id )) self.debug("Creating PF rule for IP address: %s" % - ip_with_nat_rule.ipaddress.ipaddress) + ip_with_nat_rule.ipaddress) NATRule.create( self.apiclient, virtual_machine, @@ -1233,7 +1233,7 @@ class TestNOWithNetscaler(cloudstackTestCase): ) self.debug("Trying to create LB rule on IP with NAT: %s" % - ip_with_nat_rule.ipaddress.ipaddress) + ip_with_nat_rule.ipaddress) # Create Load Balancer rule on IP already having NAT rule with self.assertRaises(Exception): @@ -1241,7 +1241,7 @@ class TestNOWithNetscaler(cloudstackTestCase): self.apiclient, self.services["lbrule"], ipaddressid=ip_with_nat_rule.ipaddress.id, - accountid=self.account.account.name + accountid=self.account.name ) self.debug("Creating PF rule with public port: 66") @@ -1267,28 +1267,28 @@ class TestNOWithNetscaler(cloudstackTestCase): self.debug("Associating public IP for network: %s" % self.network.id) ip_with_lb_rule = PublicIPAddress.create( self.apiclient, - accountid=self.account.account.name, + accountid=self.account.name, zoneid=self.zone.id, - domainid=self.account.account.domainid, + domainid=self.account.domainid, networkid=self.network.id ) self.debug("Associated %s with network %s" % ( - ip_with_lb_rule.ipaddress.ipaddress, + ip_with_lb_rule.ipaddress, self.network.id )) self.debug("Creating LB rule for IP address: %s" % - ip_with_lb_rule.ipaddress.ipaddress) + ip_with_lb_rule.ipaddress) LoadBalancerRule.create( self.apiclient, self.services["lbrule"], ipaddressid=ip_with_lb_rule.ipaddress.id, - accountid=self.account.account.name, + accountid=self.account.name, networkid=self.network.id ) self.debug("Trying to create PF rule on IP with LB rule: %s" % - ip_with_nat_rule.ipaddress.ipaddress) + ip_with_nat_rule.ipaddress) with self.assertRaises(Exception): NATRule.create( @@ -1314,7 +1314,7 @@ class TestNOWithNetscaler(cloudstackTestCase): self.apiclient, self.services["lbrule_port_2221"], ipaddressid=ip_with_lb_rule.ipaddress.id, - accountid=self.account.account.name, + accountid=self.account.name, networkid=self.network.id ) @@ -1336,8 +1336,8 @@ class TestNOWithNetscaler(cloudstackTestCase): vpn = Vpn.create( self.apiclient, src_nat.id, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) vpns = Vpn.list( @@ -1457,21 +1457,21 @@ class TestNetworkUpgrade(cloudstackTestCase): self.network = Network.create( self.apiclient, self.services["network"], - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id ) self.debug("Created network with ID: %s" % self.network.id) - self.debug("Deploying VM in account: %s" % self.account.account.name) + self.debug("Deploying VM in account: %s" % self.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, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(self.network.id)] ) @@ -1480,8 +1480,8 @@ class TestNetworkUpgrade(cloudstackTestCase): src_nat_list = PublicIPAddress.list( self.apiclient, associatednetworkid=self.network.id, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, listall=True, issourcenat=True, ) @@ -1504,7 +1504,7 @@ class TestNetworkUpgrade(cloudstackTestCase): self.apiclient, self.services["lbrule"], ipaddressid=src_nat.id, - accountid=self.account.account.name + accountid=self.account.name ) self.debug("Created LB rule on source NAT: %s" % src_nat.ipaddress) @@ -1585,8 +1585,8 @@ class TestNetworkUpgrade(cloudstackTestCase): vpn = Vpn.create( self.apiclient, src_nat.id, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) vpns = Vpn.list( @@ -1657,21 +1657,21 @@ class TestNetworkUpgrade(cloudstackTestCase): self.network = Network.create( self.apiclient, self.services["network"], - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id ) self.debug("Created network with ID: %s" % self.network.id) - self.debug("Deploying VM in account: %s" % self.account.account.name) + self.debug("Deploying VM in account: %s" % self.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, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(self.network.id)] ) @@ -1680,8 +1680,8 @@ class TestNetworkUpgrade(cloudstackTestCase): src_nat_list = PublicIPAddress.list( self.apiclient, associatednetworkid=self.network.id, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, listall=True, issourcenat=True, ) @@ -1704,7 +1704,7 @@ class TestNetworkUpgrade(cloudstackTestCase): self.apiclient, self.services["lbrule"], ipaddressid=src_nat.id, - accountid=self.account.account.name + accountid=self.account.name ) self.debug("Created LB rule on source NAT: %s" % src_nat.ipaddress) @@ -1785,8 +1785,8 @@ class TestNetworkUpgrade(cloudstackTestCase): vpn = Vpn.create( self.apiclient, src_nat.id, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) vpns = Vpn.list( @@ -1921,21 +1921,21 @@ class TestSharedNetworkWithoutIp(cloudstackTestCase): self.network = Network.create( self.apiclient, self.services["network"], - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, networkofferingid=shared_nw_off.id, zoneid=self.zone.id ) self.debug("Created network with ID: %s" % self.network.id) - self.debug("Deploying VM in account: %s" % self.account.account.name) + self.debug("Deploying VM in account: %s" % self.account.name) try: # Spawn an instance in that network VirtualMachine.create( self.apiclient, self.services["virtual_machine"], - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(self.network.id)] ) diff --git a/test/integration/component/test_project_configs.py b/test/integration/component/test_project_configs.py index f1469f22e52..fa2ee0adb2b 100644 --- a/test/integration/component/test_project_configs.py +++ b/test/integration/component/test_project_configs.py @@ -206,8 +206,8 @@ class TestUserProjectCreation(cloudstackTestCase): project = Project.create( self.apiclient, self.services["project"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) # Cleanup created project at end of test self.cleanup.append(project) @@ -373,8 +373,8 @@ class TestProjectCreationNegative(cloudstackTestCase): project = Project.create( self.apiclient, self.services["project"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) # Cleanup created project at end of test self.cleanup.append(project) @@ -498,8 +498,8 @@ class TestProjectInviteRequired(cloudstackTestCase): project = Project.create( self.apiclient, self.services["project"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) # Cleanup created project at end of test self.cleanup.append(project) @@ -650,8 +650,8 @@ class TestProjectInviteRequiredTrue(cloudstackTestCase): project = Project.create( self.apiclient, self.services["project"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) # Cleanup created project at end of test self.cleanup.append(project) @@ -819,8 +819,8 @@ class TestProjectInviteTimeout(cloudstackTestCase): project = Project.create( self.apiclient, self.services["project"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) # Cleanup created project at end of test self.cleanup.append(project) @@ -945,8 +945,8 @@ class TestProjectInviteTimeout(cloudstackTestCase): project = Project.create( self.apiclient, self.services["project"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) # Cleanup created project at end of test self.cleanup.append(project) @@ -1076,8 +1076,8 @@ class TestProjectInviteTimeout(cloudstackTestCase): project = Project.create( self.apiclient, self.services["project"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) # Cleanup created project at end of test self.cleanup.append(project) @@ -1205,8 +1205,8 @@ class TestProjectInviteTimeout(cloudstackTestCase): project = Project.create( self.apiclient, self.services["project"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) # Cleanup created project at end of test self.cleanup.append(project) @@ -1333,8 +1333,8 @@ class TestProjectInviteTimeout(cloudstackTestCase): project = Project.create( self.apiclient, self.services["project"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) # Cleanup created project at end of test self.cleanup.append(project) diff --git a/test/integration/component/test_project_limits.py b/test/integration/component/test_project_limits.py index ab13238e187..4a8b9d48227 100644 --- a/test/integration/component/test_project_limits.py +++ b/test/integration/component/test_project_limits.py @@ -505,10 +505,10 @@ class TestResourceLimitsProject(cloudstackTestCase): cls.project = Project.create( cls.api_client, cls.services["project"], - account=cls.account.account.name, - domainid=cls.account.account.domainid + account=cls.account.name, + domainid=cls.account.domainid ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name # Create Service offering and disk offerings etc cls.service_offering = ServiceOffering.create( @@ -720,7 +720,7 @@ class TestResourceLimitsProject(cloudstackTestCase): projectid=self.project.id ) - self.debug("Deploying VM for account: %s" % self.account.account.name) + self.debug("Deploying VM for account: %s" % self.account.name) virtual_machine_1 = VirtualMachine.create( self.apiclient, self.services["server"], @@ -843,7 +843,7 @@ class TestResourceLimitsProject(cloudstackTestCase): ) self.debug( "Updating template resource limits for domain: %s" % - self.account.account.domainid) + self.account.domainid) # Set usage_vm=1 for Account 1 update_resource_limit( self.apiclient, @@ -852,7 +852,7 @@ class TestResourceLimitsProject(cloudstackTestCase): projectid=self.project.id ) - self.debug("Deploying VM for account: %s" % self.account.account.name) + self.debug("Deploying VM for account: %s" % self.account.name) virtual_machine_1 = VirtualMachine.create( self.apiclient, self.services["server"], @@ -994,13 +994,13 @@ class TestMaxProjectNetworks(cloudstackTestCase): # 3. Create network should fail self.debug("Creating project with '%s' as admin" % - self.account.account.name) + self.account.name) # Create project as a domain admin project = Project.create( self.apiclient, self.services["project"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) # Cleanup created project at end of test self.cleanup.append(project) diff --git a/test/integration/component/test_project_resources.py b/test/integration/component/test_project_resources.py index 191ceb54cb6..e79254ce6ac 100644 --- a/test/integration/component/test_project_resources.py +++ b/test/integration/component/test_project_resources.py @@ -220,8 +220,8 @@ class TestOfferings(cloudstackTestCase): project = Project.create( self.apiclient, self.services["project"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) # Cleanup created project at end of test self.cleanup.append(project) @@ -263,8 +263,8 @@ class TestOfferings(cloudstackTestCase): project = Project.create( self.apiclient, self.services["project"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) # Cleanup created project at end of test self.cleanup.append(project) @@ -400,8 +400,8 @@ class TestNetwork(cloudstackTestCase): project = Project.create( self.apiclient, self.services["project"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) # Cleanup created project at end of test self.cleanup.append(project) @@ -546,10 +546,10 @@ class TestTemplates(cloudstackTestCase): cls.project = Project.create( cls.api_client, cls.services["project"], - account=cls.account.account.name, - domainid=cls.account.account.domainid + account=cls.account.name, + domainid=cls.account.domainid ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name # Create Service offering and disk offerings etc cls.service_offering = ServiceOffering.create( @@ -771,10 +771,10 @@ class TestSnapshots(cloudstackTestCase): cls.project = Project.create( cls.api_client, cls.services["project"], - account=cls.account.account.name, - domainid=cls.account.account.domainid + account=cls.account.name, + domainid=cls.account.domainid ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name # Create Service offering and disk offerings etc cls.service_offering = ServiceOffering.create( @@ -872,8 +872,8 @@ class TestSnapshots(cloudstackTestCase): snapshots = Snapshot.list( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( snapshots, @@ -918,10 +918,10 @@ class TestPublicIpAddress(cloudstackTestCase): cls.project = Project.create( cls.api_client, cls.services["project"], - account=cls.account.account.name, - domainid=cls.account.account.domainid + account=cls.account.name, + domainid=cls.account.domainid ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name # Create Service offering and disk offerings etc cls.service_offering = ServiceOffering.create( @@ -1037,7 +1037,7 @@ class TestPublicIpAddress(cloudstackTestCase): #Create Load Balancer rule and assign VMs to rule self.debug("Created LB rule for public IP: %s" % - public_ip.ipaddress.ipaddress) + public_ip.ipaddress) lb_rule = LoadBalancerRule.create( self.apiclient, self.services["lbrule"], @@ -1112,13 +1112,13 @@ class TestPublicIpAddress(cloudstackTestCase): "Check end port of firewall rule" ) - self.debug("Deploying VM for account: %s" % self.account.account.name) + self.debug("Deploying VM for account: %s" % self.account.name) virtual_machine_1 = VirtualMachine.create( self.apiclient, self.services["server"], templateid=self.template.id, - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, ) self.cleanup.append(virtual_machine_1) @@ -1142,17 +1142,17 @@ class TestPublicIpAddress(cloudstackTestCase): ) self.debug("Creating LB rule for public IP: %s outside project" % - public_ip.ipaddress.ipaddress) + public_ip.ipaddress) with self.assertRaises(Exception): LoadBalancerRule.create( self.apiclient, self.services["lbrule"], public_ip.ipaddress.id, - accountid=self.account.account.name + accountid=self.account.name ) self.debug( "Creating firewall rule for public IP: %s outside project" % - public_ip.ipaddress.ipaddress) + public_ip.ipaddress) with self.assertRaises(Exception): FireWallRule.create( self.apiclient, @@ -1219,10 +1219,10 @@ class TestSecurityGroup(cloudstackTestCase): cls.project = Project.create( cls.api_client, cls.services["project"], - account=cls.account.account.name, - domainid=cls.account.account.domainid + account=cls.account.name, + domainid=cls.account.domainid ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls._cleanup = [ cls.project, @@ -1317,8 +1317,8 @@ class TestSecurityGroup(cloudstackTestCase): self.apiclient, self.services["server"], serviceofferingid=self.service_offering.id, - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, securitygroupids=[security_group.id], ) return diff --git a/test/integration/component/test_project_usage.py b/test/integration/component/test_project_usage.py index 03c42fd196f..44ef2f9a0a9 100644 --- a/test/integration/component/test_project_usage.py +++ b/test/integration/component/test_project_usage.py @@ -142,13 +142,13 @@ class TestVmUsage(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.project = Project.create( cls.api_client, cls.services["project"], - account=cls.account.account.name, - domainid=cls.account.account.domainid + account=cls.account.name, + domainid=cls.account.domainid ) cls.service_offering = ServiceOffering.create( @@ -337,13 +337,13 @@ class TestPublicIPUsage(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.project = Project.create( cls.api_client, cls.services["project"], - account=cls.account.account.name, - domainid=cls.account.account.domainid + account=cls.account.name, + domainid=cls.account.domainid ) cls.service_offering = ServiceOffering.create( @@ -416,7 +416,7 @@ class TestPublicIPUsage(cloudstackTestCase): # 3. Delete the newly created account self.debug("Deleting public IP: %s" % - self.public_ip.ipaddress.ipaddress) + self.public_ip.ipaddress) # Release one of the IP self.public_ip.delete(self.apiclient) @@ -512,13 +512,13 @@ class TestVolumeUsage(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.project = Project.create( cls.api_client, cls.services["project"], - account=cls.account.account.name, - domainid=cls.account.account.domainid + account=cls.account.name, + domainid=cls.account.domainid ) cls.service_offering = ServiceOffering.create( @@ -689,13 +689,13 @@ class TestTemplateUsage(cloudstackTestCase): cls.services["account"], domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.project = Project.create( cls.api_client, cls.services["project"], - account=cls.account.account.name, - domainid=cls.account.account.domainid + account=cls.account.name, + domainid=cls.account.domainid ) cls.service_offering = ServiceOffering.create( @@ -858,12 +858,12 @@ class TestISOUsage(cloudstackTestCase): cls.services["account"], domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.project = Project.create( cls.api_client, cls.services["project"], - account=cls.account.account.name, - domainid=cls.account.account.domainid + account=cls.account.name, + domainid=cls.account.domainid ) cls.iso = Iso.create( @@ -1014,13 +1014,13 @@ class TestLBRuleUsage(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.project = Project.create( cls.api_client, cls.services["project"], - account=cls.account.account.name, - domainid=cls.account.account.domainid + account=cls.account.name, + domainid=cls.account.domainid ) cls.service_offering = ServiceOffering.create( @@ -1198,13 +1198,13 @@ class TestSnapshotUsage(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.project = Project.create( cls.api_client, cls.services["project"], - account=cls.account.account.name, - domainid=cls.account.account.domainid + account=cls.account.name, + domainid=cls.account.domainid ) cls.service_offering = ServiceOffering.create( @@ -1375,13 +1375,13 @@ class TestNatRuleUsage(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.project = Project.create( cls.api_client, cls.services["project"], - account=cls.account.account.name, - domainid=cls.account.account.domainid + account=cls.account.name, + domainid=cls.account.domainid ) cls.service_offering = ServiceOffering.create( @@ -1559,13 +1559,13 @@ class TestVpnUsage(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.project = Project.create( cls.api_client, cls.services["project"], - account=cls.account.account.name, - domainid=cls.account.account.domainid + account=cls.account.name, + domainid=cls.account.domainid ) cls.service_offering = ServiceOffering.create( @@ -1648,7 +1648,7 @@ class TestVpnUsage(cloudstackTestCase): ) self.debug("Created VPN user for account: %s" % - self.account.account.name) + self.account.name) vpnuser = VpnUser.create( self.apiclient, diff --git a/test/integration/component/test_projects.py b/test/integration/component/test_projects.py index 95df5bf8c30..9fa60750afe 100644 --- a/test/integration/component/test_projects.py +++ b/test/integration/component/test_projects.py @@ -183,8 +183,8 @@ class TestMultipleProjectCreation(cloudstackTestCase): project_1 = Project.create( self.apiclient, self.services["project"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) # Cleanup created project at end of test self.cleanup.append(project_1) @@ -218,8 +218,8 @@ class TestMultipleProjectCreation(cloudstackTestCase): project_2 = Project.create( self.apiclient, self.services["project"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) # Cleanup created project at end of test self.cleanup.append(project_2) @@ -398,8 +398,8 @@ class TestCrossDomainAccountAdd(cloudstackTestCase): project = Project.create( self.apiclient, self.services["project"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) # Cleanup created project at end of test self.cleanup.append(project) @@ -519,8 +519,8 @@ class TestDeleteAccountWithProject(cloudstackTestCase): project = Project.create( self.apiclient, self.services["project"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) # Cleanup created project at end of test self.cleanup.append(project) @@ -555,7 +555,7 @@ class TestDeleteAccountWithProject(cloudstackTestCase): with self.assertRaises(Exception): self.account.delete(self.apiclient) self.debug("Deleting account %s failed!" % - self.account.account.name) + self.account.name) return @@ -635,8 +635,8 @@ class TestDeleteDomainWithProject(cloudstackTestCase): project = Project.create( self.apiclient, self.services["project"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) # Cleanup created project at end of test self.debug("Created project with domain admin with ID: %s" % @@ -1215,8 +1215,8 @@ class TestProjectResources(cloudstackTestCase): project = Project.create( self.apiclient, self.services["project"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) # Cleanup created project at end of test self.cleanup.append(project) @@ -1331,8 +1331,8 @@ class TestProjectResources(cloudstackTestCase): project = Project.create( self.apiclient, self.services["project"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) # Cleanup created project at end of test self.debug("Created project with domain admin with ID: %s" % @@ -1496,8 +1496,8 @@ class TestProjectSuspendActivate(cloudstackTestCase): cls.project = Project.create( cls.api_client, cls.services["project"], - account=cls.account.account.name, - domainid=cls.account.account.domainid + account=cls.account.name, + domainid=cls.account.domainid ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls._cleanup = [ diff --git a/test/integration/component/test_resource_limits.py b/test/integration/component/test_resource_limits.py index 641825b4a0c..418080ab052 100644 --- a/test/integration/component/test_resource_limits.py +++ b/test/integration/component/test_resource_limits.py @@ -902,7 +902,7 @@ class TestResourceLimitsDomain(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name # Create Service offering and disk offerings etc cls.service_offering = ServiceOffering.create( @@ -957,22 +957,22 @@ class TestResourceLimitsDomain(cloudstackTestCase): self.debug( "Updating instance resource limits for domain: %s" % - self.account.account.domainid) + self.account.domainid) # Set usage_vm=1 for Account 1 update_resource_limit( self.apiclient, 0, # Instance - domainid=self.account.account.domainid, + domainid=self.account.domainid, max=2 ) - self.debug("Deploying VM for account: %s" % self.account.account.name) + self.debug("Deploying VM for account: %s" % self.account.name) virtual_machine_1 = VirtualMachine.create( self.apiclient, self.services["server"], templateid=self.template.id, - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) self.cleanup.append(virtual_machine_1) @@ -982,13 +982,13 @@ class TestResourceLimitsDomain(cloudstackTestCase): 'Running', "Check VM state is Running or not" ) - self.debug("Deploying VM for account: %s" % self.account.account.name) + self.debug("Deploying VM for account: %s" % self.account.name) virtual_machine_2 = VirtualMachine.create( self.apiclient, self.services["server"], templateid=self.template.id, - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) self.cleanup.append(virtual_machine_2) @@ -1005,7 +1005,7 @@ class TestResourceLimitsDomain(cloudstackTestCase): self.services["server"], templateid=self.template.id, accountid=self.account_1.account.name, - domainid=self.account.account.domainid, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) return @@ -1025,22 +1025,22 @@ class TestResourceLimitsDomain(cloudstackTestCase): self.debug( "Updating public IP resource limits for domain: %s" % - self.account.account.domainid) + self.account.domainid) # Set usage_vm=1 for Account 1 update_resource_limit( self.apiclient, 1, # Public Ip - domainid=self.account.account.domainid, + domainid=self.account.domainid, max=2 ) - self.debug("Deploying VM for account: %s" % self.account.account.name) + self.debug("Deploying VM for account: %s" % self.account.name) virtual_machine_1 = VirtualMachine.create( self.apiclient, self.services["server"], templateid=self.template.id, - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) self.cleanup.append(virtual_machine_1) @@ -1050,7 +1050,7 @@ class TestResourceLimitsDomain(cloudstackTestCase): 'Running', "Check VM state is Running or not" ) - self.debug("Associating public IP for account: %s" % self.account.account.name) + self.debug("Associating public IP for account: %s" % self.account.name) public_ip_1 = PublicIPAddress.create( self.apiclient, virtual_machine_1.account, @@ -1097,22 +1097,22 @@ class TestResourceLimitsDomain(cloudstackTestCase): self.debug( "Updating snapshot resource limits for domain: %s" % - self.account.account.domainid) + self.account.domainid) # Set usage_vm=1 for Account 1 update_resource_limit( self.apiclient, 3, # Snapshot - domainid=self.account.account.domainid, + domainid=self.account.domainid, max=1 ) - self.debug("Deploying VM for account: %s" % self.account.account.name) + self.debug("Deploying VM for account: %s" % self.account.name) virtual_machine_1 = VirtualMachine.create( self.apiclient, self.services["server"], templateid=self.template.id, - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) self.cleanup.append(virtual_machine_1) @@ -1141,8 +1141,8 @@ class TestResourceLimitsDomain(cloudstackTestCase): # Create a snapshot from the ROOTDISK snapshot_1 = Snapshot.create(self.apiclient, volumes[0].id, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, ) self.cleanup.append(snapshot_1) # Verify Snapshot state @@ -1159,8 +1159,8 @@ class TestResourceLimitsDomain(cloudstackTestCase): with self.assertRaises(Exception): Snapshot.create(self.apiclient, volumes[0].id, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, ) return @@ -1179,22 +1179,22 @@ class TestResourceLimitsDomain(cloudstackTestCase): self.debug( "Updating volume resource limits for domain: %s" % - self.account.account.domainid) + self.account.domainid) # Set usage_vm=1 for Account 1 update_resource_limit( self.apiclient, 2, # Volume - domainid=self.account.account.domainid, + domainid=self.account.domainid, max=2 ) - self.debug("Deploying VM for account: %s" % self.account.account.name) + self.debug("Deploying VM for account: %s" % self.account.name) virtual_machine_1 = VirtualMachine.create( self.apiclient, self.services["server"], templateid=self.template.id, - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) self.cleanup.append(virtual_machine_1) @@ -1211,8 +1211,8 @@ class TestResourceLimitsDomain(cloudstackTestCase): self.apiclient, self.services["volume"], zoneid=self.zone.id, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, diskofferingid=self.disk_offering.id ) return @@ -1234,28 +1234,28 @@ class TestResourceLimitsDomain(cloudstackTestCase): update_resource_limit( self.apiclient, 2, # Volume - domainid=self.account.account.domainid, + domainid=self.account.domainid, max=5 ) self.debug( "Updating template resource limits for domain: %s" % - self.account.account.domainid) + self.account.domainid) # Set usage_vm=1 for Account 1 update_resource_limit( self.apiclient, 4, # Template - domainid=self.account.account.domainid, + domainid=self.account.domainid, max=2 ) - self.debug("Deploying VM for account: %s" % self.account.account.name) + self.debug("Deploying VM for account: %s" % self.account.name) virtual_machine_1 = VirtualMachine.create( self.apiclient, self.services["server"], templateid=self.template.id, - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) self.cleanup.append(virtual_machine_1) @@ -1286,8 +1286,8 @@ class TestResourceLimitsDomain(cloudstackTestCase): self.apiclient, self.services["template"], volumeid=volume.id, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, ) self.cleanup.append(template_1) @@ -1303,8 +1303,8 @@ class TestResourceLimitsDomain(cloudstackTestCase): self.apiclient, self.services["template"], volumeid=volume.id, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, ) self.cleanup.append(template_2) @@ -1321,8 +1321,8 @@ class TestResourceLimitsDomain(cloudstackTestCase): self.apiclient, self.services["template"], volumeid=volume.id, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, ) return @@ -1432,8 +1432,8 @@ class TestMaxAccountNetworks(cloudstackTestCase): network = Network.create( self.apiclient, self.services["network"], - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id ) @@ -1446,8 +1446,8 @@ class TestMaxAccountNetworks(cloudstackTestCase): Network.create( self.apiclient, self.services["network"], - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id ) diff --git a/test/integration/component/test_routers.py b/test/integration/component/test_routers.py index 452c034d5eb..96eb9aae403 100644 --- a/test/integration/component/test_routers.py +++ b/test/integration/component/test_routers.py @@ -127,16 +127,16 @@ class TestRouterServices(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], templateid=cls.template.id, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) cls.vm_2 = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], templateid=cls.template.id, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) cls.cleanup = [ @@ -189,8 +189,8 @@ class TestRouterServices(cloudstackTestCase): routers = list_routers( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, ) self.assertEqual( @@ -216,8 +216,8 @@ class TestRouterServices(cloudstackTestCase): # Network state associated with account should be 'Implemented' networks = list_networks( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, ) self.assertEqual( isinstance(networks, list), @@ -243,8 +243,8 @@ class TestRouterServices(cloudstackTestCase): # VM state associated with account should be 'Running' virtual_machines = list_virtual_machines( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( @@ -271,8 +271,8 @@ class TestRouterServices(cloudstackTestCase): # Check status of DNS, DHCP, FIrewall, LB VPN processes networks = list_networks( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, ) self.assertEqual( isinstance(networks, list), @@ -332,8 +332,8 @@ class TestRouterServices(cloudstackTestCase): routers = list_routers( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, ) self.assertEqual( @@ -360,8 +360,8 @@ class TestRouterServices(cloudstackTestCase): # Network state associated with account should be 'Implemented' networks = list_networks( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, ) self.assertEqual( isinstance(networks, list), @@ -387,8 +387,8 @@ class TestRouterServices(cloudstackTestCase): # VM state associated with account should be 'Running' virtual_machines = list_virtual_machines( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, ) self.assertEqual( @@ -445,8 +445,8 @@ class TestRouterServices(cloudstackTestCase): routers = list_routers( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, ) self.assertEqual( @@ -488,8 +488,8 @@ class TestRouterServices(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], templateid=self.template.id, - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) self.debug("Deployed a VM with ID: %s" % vm.id) @@ -497,8 +497,8 @@ class TestRouterServices(cloudstackTestCase): virtual_machines = list_virtual_machines( self.apiclient, id=vm.id, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, ) self.assertEqual( @@ -522,8 +522,8 @@ class TestRouterServices(cloudstackTestCase): routers = list_routers( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, ) self.assertEqual( @@ -554,8 +554,8 @@ class TestRouterServices(cloudstackTestCase): virtual_machines = list_virtual_machines( self.apiclient, id=self.vm_1.id, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, ) self.assertEqual( @@ -615,8 +615,8 @@ class TestRouterStopCreatePF(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], templateid=template.id, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) cls.cleanup = [ @@ -668,8 +668,8 @@ class TestRouterStopCreatePF(cloudstackTestCase): # Get router details associated for that account routers = list_routers( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, ) self.assertEqual( @@ -693,8 +693,8 @@ class TestRouterStopCreatePF(cloudstackTestCase): routers = list_routers( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, ) self.assertEqual( isinstance(routers, list), @@ -711,8 +711,8 @@ class TestRouterStopCreatePF(cloudstackTestCase): public_ips = list_publicIP( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, zoneid=self.zone.id ) self.assertEqual( @@ -749,8 +749,8 @@ class TestRouterStopCreatePF(cloudstackTestCase): routers = list_routers( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, zoneid=self.zone.id ) self.assertEqual( @@ -827,8 +827,8 @@ class TestRouterStopCreateLB(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], templateid=template.id, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) cls.cleanup = [ @@ -874,8 +874,8 @@ class TestRouterStopCreateLB(cloudstackTestCase): # Get router details associated for that account routers = list_routers( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, ) self.assertEqual( @@ -900,8 +900,8 @@ class TestRouterStopCreateLB(cloudstackTestCase): routers = list_routers( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, ) self.assertEqual( isinstance(routers, list), @@ -918,8 +918,8 @@ class TestRouterStopCreateLB(cloudstackTestCase): public_ips = list_publicIP( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(public_ips, list), @@ -943,7 +943,7 @@ class TestRouterStopCreateLB(cloudstackTestCase): self.apiclient, self.services["lbrule"], public_ip.id, - accountid=self.account.account.name + accountid=self.account.name ) self.debug("Assigning VM %s to LB rule: %s" % ( self.vm_1.id, @@ -958,8 +958,8 @@ class TestRouterStopCreateLB(cloudstackTestCase): routers = list_routers( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, ) self.assertEqual( isinstance(routers, list), @@ -1038,8 +1038,8 @@ class TestRouterStopCreateFW(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], templateid=template.id, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) cls.cleanup = [ @@ -1084,8 +1084,8 @@ class TestRouterStopCreateFW(cloudstackTestCase): # Get the router details associated with account routers = list_routers( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, ) self.assertEqual( @@ -1110,8 +1110,8 @@ class TestRouterStopCreateFW(cloudstackTestCase): routers = list_routers( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, ) self.assertEqual( isinstance(routers, list), @@ -1128,8 +1128,8 @@ class TestRouterStopCreateFW(cloudstackTestCase): public_ips = list_publicIP( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(public_ips, list), @@ -1157,8 +1157,8 @@ class TestRouterStopCreateFW(cloudstackTestCase): routers = list_routers( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, ) self.assertEqual( isinstance(routers, list), diff --git a/test/integration/component/test_security_groups.py b/test/integration/component/test_security_groups.py index 7459d2a2913..fe2561aa084 100644 --- a/test/integration/component/test_security_groups.py +++ b/test/integration/component/test_security_groups.py @@ -144,7 +144,7 @@ class TestDefaultSecurityGroup(cloudstackTestCase): admin=True, domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls._cleanup = [ cls.account, @@ -178,8 +178,8 @@ class TestDefaultSecurityGroup(cloudstackTestCase): self.virtual_machine = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) self.debug("Deployed VM with ID: %s" % self.virtual_machine.id) @@ -222,7 +222,7 @@ class TestDefaultSecurityGroup(cloudstackTestCase): # Verify List Routers response for account self.debug( "Verify list routers response for account: %s" \ - % self.account.account.name + % self.account.name ) routers = list_routers( self.apiclient, @@ -256,8 +256,8 @@ class TestDefaultSecurityGroup(cloudstackTestCase): sercurity_groups = SecurityGroup.list( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(sercurity_groups, list), @@ -292,8 +292,8 @@ class TestDefaultSecurityGroup(cloudstackTestCase): self.virtual_machine = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) self.debug("Deployed VM with ID: %s" % self.virtual_machine.id) @@ -336,8 +336,8 @@ class TestDefaultSecurityGroup(cloudstackTestCase): # Default Security group should not have any ingress rule sercurity_groups = SecurityGroup.list( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(sercurity_groups, list), @@ -416,7 +416,7 @@ class TestAuthorizeIngressRule(cloudstackTestCase): cls.services["account"], domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls._cleanup = [ cls.account, cls.service_offering @@ -450,15 +450,15 @@ class TestAuthorizeIngressRule(cloudstackTestCase): security_group = SecurityGroup.create( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("Created security group with ID: %s" % security_group.id) # Default Security group should not have any ingress rule sercurity_groups = SecurityGroup.list( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(sercurity_groups, list), @@ -475,8 +475,8 @@ class TestAuthorizeIngressRule(cloudstackTestCase): ingress_rule = security_group.authorize( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(ingress_rule, dict), @@ -489,12 +489,12 @@ class TestAuthorizeIngressRule(cloudstackTestCase): self.virtual_machine = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, securitygroupids=[security_group.id] ) - self.debug("Deploying VM in account: %s" % self.account.account.name) + self.debug("Deploying VM in account: %s" % self.account.name) # Should be able to SSH VM try: self.debug("SSH into VM: %s" % self.virtual_machine.id) @@ -552,7 +552,7 @@ class TestRevokeIngressRule(cloudstackTestCase): cls.services["account"], domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls._cleanup = [ cls.account, cls.service_offering @@ -587,16 +587,16 @@ class TestRevokeIngressRule(cloudstackTestCase): security_group = SecurityGroup.create( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("Created security group with ID: %s" % security_group.id) # Default Security group should not have any ingress rule sercurity_groups = SecurityGroup.list( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(sercurity_groups, list), @@ -615,8 +615,8 @@ class TestRevokeIngressRule(cloudstackTestCase): ingress_rule = security_group.authorize( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( @@ -629,12 +629,12 @@ class TestRevokeIngressRule(cloudstackTestCase): self.virtual_machine = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, securitygroupids=[security_group.id] ) - self.debug("Deploying VM in account: %s" % self.account.account.name) + self.debug("Deploying VM in account: %s" % self.account.name) # Should be able to SSH VM try: @@ -712,12 +712,12 @@ class TestDhcpOnlyRouter(cloudstackTestCase): cls.services["account"], domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.virtual_machine = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) cls._cleanup = [ @@ -849,7 +849,7 @@ class TestdeployVMWithUserData(cloudstackTestCase): cls.services["account"], domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls._cleanup = [ cls.account, cls.service_offering @@ -897,15 +897,15 @@ class TestdeployVMWithUserData(cloudstackTestCase): security_group = SecurityGroup.create( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("Created security group with ID: %s" % security_group.id) # Default Security group should not have any ingress rule sercurity_groups = SecurityGroup.list( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(sercurity_groups, list), @@ -922,15 +922,15 @@ class TestdeployVMWithUserData(cloudstackTestCase): "Authorize Ingress Rule for Security Group %s for account: %s" \ % ( security_group.id, - self.account.account.name + self.account.name )) # Authorize Security group to SSH to VM ingress_rule = security_group.authorize( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(ingress_rule, dict), @@ -940,12 +940,12 @@ class TestdeployVMWithUserData(cloudstackTestCase): self.virtual_machine = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, securitygroupids=[security_group.id] ) - self.debug("Deploying VM in account: %s" % self.account.account.name) + self.debug("Deploying VM in account: %s" % self.account.name) # Should be able to SSH VM try: self.debug( @@ -1009,7 +1009,7 @@ class TestDeleteSecurityGroup(cloudstackTestCase): self.services["account"], domainid=self.domain.id ) - self.services["account"] = self.account.account.name + self.services["account"] = self.account.name self.cleanup = [ self.account, self.service_offering @@ -1059,15 +1059,15 @@ class TestDeleteSecurityGroup(cloudstackTestCase): security_group = SecurityGroup.create( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("Created security group with ID: %s" % security_group.id) # Default Security group should not have any ingress rule sercurity_groups = SecurityGroup.list( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(sercurity_groups, list), @@ -1084,15 +1084,15 @@ class TestDeleteSecurityGroup(cloudstackTestCase): "Authorize Ingress Rule for Security Group %s for account: %s" \ % ( security_group.id, - self.account.account.name + self.account.name )) # Authorize Security group to SSH to VM ingress_rule = security_group.authorize( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(ingress_rule, dict), @@ -1103,12 +1103,12 @@ class TestDeleteSecurityGroup(cloudstackTestCase): self.virtual_machine = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, securitygroupids=[security_group.id] ) - self.debug("Deploying VM in account: %s" % self.account.account.name) + self.debug("Deploying VM in account: %s" % self.account.name) # Deleting Security group should raise exception security_group.delete(self.apiclient) @@ -1143,15 +1143,15 @@ class TestDeleteSecurityGroup(cloudstackTestCase): security_group = SecurityGroup.create( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("Created security group with ID: %s" % security_group.id) # Default Security group should not have any ingress rule sercurity_groups = SecurityGroup.list( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(sercurity_groups, list), @@ -1168,14 +1168,14 @@ class TestDeleteSecurityGroup(cloudstackTestCase): "Authorize Ingress Rule for Security Group %s for account: %s" \ % ( security_group.id, - self.account.account.name + self.account.name )) # Authorize Security group to SSH to VM ingress_rule = security_group.authorize( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(ingress_rule, dict), @@ -1186,12 +1186,12 @@ class TestDeleteSecurityGroup(cloudstackTestCase): self.virtual_machine = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, securitygroupids=[security_group.id] ) - self.debug("Deploying VM in account: %s" % self.account.account.name) + self.debug("Deploying VM in account: %s" % self.account.name) # Destroy the VM self.virtual_machine.delete(self.apiclient) @@ -1255,7 +1255,7 @@ class TestIngressRule(cloudstackTestCase): self.services["account"], domainid=self.domain.id ) - self.services["account"] = self.account.account.name + self.services["account"] = self.account.name self.cleanup = [ self.account, self.service_offering @@ -1305,15 +1305,15 @@ class TestIngressRule(cloudstackTestCase): security_group = SecurityGroup.create( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("Created security group with ID: %s" % security_group.id) # Default Security group should not have any ingress rule sercurity_groups = SecurityGroup.list( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(sercurity_groups, list), @@ -1329,15 +1329,15 @@ class TestIngressRule(cloudstackTestCase): "Authorize Ingress Rule for Security Group %s for account: %s" \ % ( security_group.id, - self.account.account.name + self.account.name )) # Authorize Security group to SSH to VM ingress_rule_1 = security_group.authorize( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(ingress_rule_1, dict), @@ -1347,25 +1347,25 @@ class TestIngressRule(cloudstackTestCase): self.virtual_machine = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, securitygroupids=[security_group.id] ) - self.debug("Deploying VM in account: %s" % self.account.account.name) + self.debug("Deploying VM in account: %s" % self.account.name) self.debug( "Authorize Ingress Rule for Security Group %s for account: %s" \ % ( security_group.id, - self.account.account.name + self.account.name )) # Authorize Security group to SSH to VM ingress_rule_2 = security_group.authorize( self.apiclient, self.services["security_group_2"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(ingress_rule_2, dict), @@ -1421,16 +1421,16 @@ class TestIngressRule(cloudstackTestCase): security_group = SecurityGroup.create( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("Created security group with ID: %s" % security_group.id) # Default Security group should not have any ingress rule sercurity_groups = SecurityGroup.list( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(sercurity_groups, list), @@ -1447,15 +1447,15 @@ class TestIngressRule(cloudstackTestCase): "Authorize Ingress Rule for Security Group %s for account: %s" \ % ( security_group.id, - self.account.account.name + self.account.name )) # Authorize Security group to SSH to VM ingress_rule = security_group.authorize( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(ingress_rule, dict), @@ -1465,26 +1465,26 @@ class TestIngressRule(cloudstackTestCase): self.virtual_machine = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, securitygroupids=[security_group.id] ) - self.debug("Deploying VM in account: %s" % self.account.account.name) + self.debug("Deploying VM in account: %s" % self.account.name) self.debug( "Authorize Ingress Rule for Security Group %s for account: %s" \ % ( security_group.id, - self.account.account.name + self.account.name )) # Authorize Security group to SSH to VM ingress_rule_2 = security_group.authorize( self.apiclient, self.services["security_group_2"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(ingress_rule_2, dict), @@ -1528,7 +1528,7 @@ class TestIngressRule(cloudstackTestCase): "Revoke Ingress Rule for Security Group %s for account: %s" \ % ( security_group.id, - self.account.account.name + self.account.name )) result = security_group.revoke( @@ -1573,15 +1573,15 @@ class TestIngressRule(cloudstackTestCase): security_group = SecurityGroup.create( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("Created security group with ID: %s" % security_group.id) # Default Security group should not have any ingress rule sercurity_groups = SecurityGroup.list( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(sercurity_groups, list), @@ -1599,15 +1599,15 @@ class TestIngressRule(cloudstackTestCase): "Authorize Ingress Rule for Security Group %s for account: %s" \ % ( security_group.id, - self.account.account.name + self.account.name )) # Authorize Security group to SSH to VM ingress_rule = security_group.authorize( self.apiclient, self.services["security_group"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(ingress_rule, dict), @@ -1618,12 +1618,12 @@ class TestIngressRule(cloudstackTestCase): self.virtual_machine = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, securitygroupids=[security_group.id] ) - self.debug("Deploying VM in account: %s" % self.account.account.name) + self.debug("Deploying VM in account: %s" % self.account.name) # SSH should be allowed on 22 port try: diff --git a/test/integration/component/test_snapshots.py b/test/integration/component/test_snapshots.py index 5567917371e..014b55afcc1 100644 --- a/test/integration/component/test_snapshots.py +++ b/test/integration/component/test_snapshots.py @@ -152,7 +152,7 @@ class TestSnapshotRootDisk(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client, @@ -163,8 +163,8 @@ class TestSnapshotRootDisk(cloudstackTestCase): cls.api_client, cls.services["server_without_disk"], templateid=template.id, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"] ) @@ -220,8 +220,8 @@ class TestSnapshotRootDisk(cloudstackTestCase): snapshot = Snapshot.create( self.apiclient, volumes[0].id, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("Snapshot created: ID - %s" % snapshot.id) @@ -384,7 +384,7 @@ class TestSnapshots(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client, @@ -395,8 +395,8 @@ class TestSnapshots(cloudstackTestCase): cls.api_client, cls.services["server_with_disk"], templateid=template.id, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"] ) @@ -405,8 +405,8 @@ class TestSnapshots(cloudstackTestCase): cls.api_client, cls.services["server_without_disk"], templateid=template.id, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"] ) @@ -462,8 +462,8 @@ class TestSnapshots(cloudstackTestCase): snapshot = Snapshot.create( self.apiclient, volume[0].id, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) snapshots = list_snapshots( self.apiclient, @@ -663,8 +663,8 @@ class TestSnapshots(cloudstackTestCase): snapshot = Snapshot.create( self.apiclient, volume_response.id, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("Created Snapshot from volume: %s" % volume_response.id) @@ -674,8 +674,8 @@ class TestSnapshots(cloudstackTestCase): self.apiclient, snapshot.id, self.services, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) volumes = list_volumes( @@ -789,8 +789,8 @@ class TestSnapshots(cloudstackTestCase): snapshot = Snapshot.create( self.apiclient, volumes[0].id, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) snapshot.delete(self.apiclient) @@ -1079,8 +1079,8 @@ class TestSnapshots(cloudstackTestCase): snapshot = Snapshot.create( self.apiclient, volume.id, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("Snapshot created from volume ID: %s" % volume.id) @@ -1118,8 +1118,8 @@ class TestSnapshots(cloudstackTestCase): self.apiclient, self.services["server_without_disk"], templateid=template.id, - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, mode=self.services["mode"] ) @@ -1209,7 +1209,7 @@ class TestCreateVMsnapshotTemplate(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client, @@ -1269,8 +1269,8 @@ class TestCreateVMsnapshotTemplate(cloudstackTestCase): self.apiclient, self.services["server"], templateid=self.template.id, - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) self.debug("Created VM with ID: %s" % self.virtual_machine.id) @@ -1359,8 +1359,8 @@ class TestCreateVMsnapshotTemplate(cloudstackTestCase): self.apiclient, self.services["server"], templateid=template.id, - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) self.debug("Created VM with ID: %s from template: %s" % ( @@ -1373,8 +1373,8 @@ class TestCreateVMsnapshotTemplate(cloudstackTestCase): virtual_machines = list_virtual_machines( self.apiclient, id=new_virtual_machine.id, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(virtual_machines, list), @@ -1505,7 +1505,7 @@ class TestAccountSnapshotClean(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client, @@ -1515,8 +1515,8 @@ class TestAccountSnapshotClean(cloudstackTestCase): cls.api_client, cls.services["server"], templateid=template.id, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) # Get the Root disk of VM @@ -1577,7 +1577,7 @@ class TestAccountSnapshotClean(cloudstackTestCase): accounts = list_accounts( self.apiclient, - id=self.account.account.id + id=self.account.id ) self.assertEqual( isinstance(accounts, list), @@ -1737,7 +1737,7 @@ class TestAccountSnapshotClean(cloudstackTestCase): "Check snapshot UUID in secondary storage and database" ) - self.debug("Deleting account: %s" % self.account.account.name) + self.debug("Deleting account: %s" % self.account.name) # Delete account self.account.delete(self.apiclient) @@ -1757,7 +1757,7 @@ class TestAccountSnapshotClean(cloudstackTestCase): accounts = list_accounts( self.apiclient, - id=self.account.account.id + id=self.account.id ) self.assertEqual( @@ -1859,7 +1859,7 @@ class TestSnapshotDetachedDisk(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client, @@ -1869,8 +1869,8 @@ class TestSnapshotDetachedDisk(cloudstackTestCase): cls.api_client, cls.services["server"], templateid=template.id, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"] ) @@ -2142,7 +2142,7 @@ class TestSnapshotLimit(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client, @@ -2152,8 +2152,8 @@ class TestSnapshotLimit(cloudstackTestCase): cls.api_client, cls.services["server"], templateid=template.id, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) cls._cleanup = [ @@ -2401,7 +2401,7 @@ class TestSnapshotEvents(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client, @@ -2411,8 +2411,8 @@ class TestSnapshotEvents(cloudstackTestCase): cls.api_client, cls.services["server"], templateid=template.id, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) @@ -2498,8 +2498,8 @@ class TestSnapshotEvents(cloudstackTestCase): time.sleep(self.services["sleep"]) events = list_events( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, type='SNAPSHOT.DELETE' ) self.assertEqual( diff --git a/test/integration/component/test_storage_motion.py b/test/integration/component/test_storage_motion.py index b893b8b7df4..086ec77b48d 100644 --- a/test/integration/component/test_storage_motion.py +++ b/test/integration/component/test_storage_motion.py @@ -126,8 +126,8 @@ class TestStorageMotion(cloudstackTestCase): cls.virtual_machine = VirtualMachine.create( cls.api_client, cls.services["small"], - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.small_offering.id, mode=cls.services["mode"] ) diff --git a/test/integration/component/test_templates.py b/test/integration/component/test_templates.py index a743bf7e690..3867fb44d19 100644 --- a/test/integration/component/test_templates.py +++ b/test/integration/component/test_templates.py @@ -139,7 +139,7 @@ class TestCreateTemplate(cloudstackTestCase): cls.services["account"], domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls._cleanup = [ cls.account, @@ -183,8 +183,8 @@ class TestCreateTemplate(cloudstackTestCase): self.apiclient, v, zoneid=self.zone.id, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug( "Registered a template of format: %s with ID: %s" % ( @@ -205,8 +205,8 @@ class TestCreateTemplate(cloudstackTestCase): self.services["templatefilter"], id=template.id, zoneid=self.zone.id, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) if isinstance(list_template_response, list): break @@ -240,8 +240,8 @@ class TestCreateTemplate(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], templateid=template.id, - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, mode=self.services["mode"] ) @@ -249,8 +249,8 @@ class TestCreateTemplate(cloudstackTestCase): vm_response = list_virtual_machines( self.apiclient, id=virtual_machine.id, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(vm_response, list), @@ -304,7 +304,7 @@ class TestTemplates(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] @@ -315,8 +315,8 @@ class TestTemplates(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], templateid=template.id, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, ) #Stop virtual machine @@ -396,8 +396,8 @@ class TestTemplates(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], templateid=self.template.id, - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, ) @@ -406,8 +406,8 @@ class TestTemplates(cloudstackTestCase): vm_response = list_virtual_machines( self.apiclient, id=virtual_machine.id, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) #Verify VM response to check whether VM deployment was successful self.assertNotEqual( @@ -591,8 +591,8 @@ class TestTemplates(cloudstackTestCase): snapshot = Snapshot.create( self.apiclient, volume.id, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("Creating a template from snapshot: %s" % snapshot.id) # Generate template from the snapshot @@ -626,8 +626,8 @@ class TestTemplates(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], templateid=template.id, - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, ) self.cleanup.append(virtual_machine) @@ -635,8 +635,8 @@ class TestTemplates(cloudstackTestCase): vm_response = list_virtual_machines( self.apiclient, id=virtual_machine.id, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(vm_response, list), diff --git a/test/integration/component/test_usage.py b/test/integration/component/test_usage.py index 39228ba3b7a..dbd0be97b72 100644 --- a/test/integration/component/test_usage.py +++ b/test/integration/component/test_usage.py @@ -135,7 +135,7 @@ class TestVmUsage(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client, @@ -145,8 +145,8 @@ class TestVmUsage(cloudstackTestCase): cls.api_client, cls.services["server"], templateid=template.id, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) cls._cleanup = [ @@ -202,11 +202,11 @@ class TestVmUsage(cloudstackTestCase): # Fetch account ID from account_uuid self.debug("select id from account where uuid = '%s';" \ - % self.account.account.id) + % self.account.id) qresultset = self.dbclient.execute( "select id from account where uuid = '%s';" \ - % self.account.account.id + % self.account.id ) self.assertEqual( isinstance(qresultset, list), @@ -319,7 +319,7 @@ class TestPublicIPUsage(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client, @@ -329,8 +329,8 @@ class TestPublicIPUsage(cloudstackTestCase): cls.api_client, cls.services["server"], templateid=template.id, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) @@ -382,18 +382,18 @@ class TestPublicIPUsage(cloudstackTestCase): # 3. Delete the newly created account self.debug("Deleting public IP: %s" % - self.public_ip.ipaddress.ipaddress) + self.public_ip.ipaddress) # Release one of the IP self.public_ip.delete(self.apiclient) # Fetch account ID from account_uuid self.debug("select id from account where uuid = '%s';" \ - % self.account.account.id) + % self.account.id) qresultset = self.dbclient.execute( "select id from account where uuid = '%s';" \ - % self.account.account.id + % self.account.id ) self.assertEqual( isinstance(qresultset, list), @@ -474,7 +474,7 @@ class TestVolumeUsage(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client, @@ -484,8 +484,8 @@ class TestVolumeUsage(cloudstackTestCase): cls.api_client, cls.services["server"], templateid=template.id, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) cls._cleanup = [ @@ -562,11 +562,11 @@ class TestVolumeUsage(cloudstackTestCase): # Fetch account ID from account_uuid self.debug("select id from account where uuid = '%s';" \ - % self.account.account.id) + % self.account.id) qresultset = self.dbclient.execute( "select id from account where uuid = '%s';" \ - % self.account.account.id + % self.account.id ) self.assertEqual( isinstance(qresultset, list), @@ -640,7 +640,7 @@ class TestTemplateUsage(cloudstackTestCase): cls.services["account"], domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client, @@ -651,8 +651,8 @@ class TestTemplateUsage(cloudstackTestCase): cls.api_client, cls.services["server"], templateid=template.id, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"] ) @@ -726,11 +726,11 @@ class TestTemplateUsage(cloudstackTestCase): # Fetch account ID from account_uuid self.debug("select id from account where uuid = '%s';" \ - % self.account.account.id) + % self.account.id) qresultset = self.dbclient.execute( "select id from account where uuid = '%s';" \ - % self.account.account.id + % self.account.id ) self.assertEqual( isinstance(qresultset, list), @@ -801,12 +801,12 @@ class TestISOUsage(cloudstackTestCase): cls.services["account"], domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.iso = Iso.create( cls.api_client, cls.services["iso"], - account=cls.account.account.name, - domainid=cls.account.account.domainid + account=cls.account.name, + domainid=cls.account.domainid ) try: # Wait till ISO gets downloaded @@ -862,11 +862,11 @@ class TestISOUsage(cloudstackTestCase): # Fetch account ID from account_uuid self.debug("select id from account where uuid = '%s';" \ - % self.account.account.id) + % self.account.id) qresultset = self.dbclient.execute( "select id from account where uuid = '%s';" \ - % self.account.account.id + % self.account.id ) self.assertEqual( isinstance(qresultset, list), @@ -946,7 +946,7 @@ class TestLBRuleUsage(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client, @@ -956,8 +956,8 @@ class TestLBRuleUsage(cloudstackTestCase): cls.api_client, cls.services["server"], templateid=template.id, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) cls.public_ip_1 = PublicIPAddress.create( @@ -1016,7 +1016,7 @@ class TestLBRuleUsage(cloudstackTestCase): self.apiclient, self.services["lbrule"], self.public_ip_1.ipaddress.id, - accountid=self.account.account.name + accountid=self.account.name ) # Delete LB Rule self.debug("Deleting LB rule with ID: %s" % lb_rule.id) @@ -1024,11 +1024,11 @@ class TestLBRuleUsage(cloudstackTestCase): # Fetch account ID from account_uuid self.debug("select id from account where uuid = '%s';" \ - % self.account.account.id) + % self.account.id) qresultset = self.dbclient.execute( "select id from account where uuid = '%s';" \ - % self.account.account.id + % self.account.id ) self.assertEqual( isinstance(qresultset, list), @@ -1109,7 +1109,7 @@ class TestSnapshotUsage(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client, @@ -1119,8 +1119,8 @@ class TestSnapshotUsage(cloudstackTestCase): cls.api_client, cls.services["server"], templateid=template.id, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) cls._cleanup = [ @@ -1190,11 +1190,11 @@ class TestSnapshotUsage(cloudstackTestCase): # Fetch account ID from account_uuid self.debug("select id from account where uuid = '%s';" \ - % self.account.account.id) + % self.account.id) qresultset = self.dbclient.execute( "select id from account where uuid = '%s';" \ - % self.account.account.id + % self.account.id ) self.assertEqual( isinstance(qresultset, list), @@ -1275,7 +1275,7 @@ class TestNatRuleUsage(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client, @@ -1285,8 +1285,8 @@ class TestNatRuleUsage(cloudstackTestCase): cls.api_client, cls.services["server"], templateid=template.id, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) cls.public_ip_1 = PublicIPAddress.create( @@ -1354,11 +1354,11 @@ class TestNatRuleUsage(cloudstackTestCase): # Fetch account ID from account_uuid self.debug("select id from account where uuid = '%s';" \ - % self.account.account.id) + % self.account.id) qresultset = self.dbclient.execute( "select id from account where uuid = '%s';" \ - % self.account.account.id + % self.account.id ) self.assertEqual( isinstance(qresultset, list), @@ -1438,7 +1438,7 @@ class TestVpnUsage(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client, @@ -1448,8 +1448,8 @@ class TestVpnUsage(cloudstackTestCase): cls.api_client, cls.services["server"], templateid=template.id, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) cls.public_ip = PublicIPAddress.create( @@ -1506,19 +1506,19 @@ class TestVpnUsage(cloudstackTestCase): vpn = Vpn.create( self.apiclient, self.public_ip.ipaddress.id, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("Created VPN user for account: %s" % - self.account.account.name) + self.account.name) vpnuser = VpnUser.create( self.apiclient, self.services["vpn_user"]["username"], self.services["vpn_user"]["password"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) # Remove VPN user @@ -1531,11 +1531,11 @@ class TestVpnUsage(cloudstackTestCase): # Fetch account ID from account_uuid self.debug("select id from account where uuid = '%s';" \ - % self.account.account.id) + % self.account.id) qresultset = self.dbclient.execute( "select id from account where uuid = '%s';" \ - % self.account.account.id + % self.account.id ) self.assertEqual( isinstance(qresultset, list), diff --git a/test/integration/component/test_vm_passwdenabled.py b/test/integration/component/test_vm_passwdenabled.py index e3bcf678948..65b068dc2d2 100644 --- a/test/integration/component/test_vm_passwdenabled.py +++ b/test/integration/component/test_vm_passwdenabled.py @@ -108,8 +108,8 @@ class TestVMPasswordEnabled(cloudstackTestCase): cls.virtual_machine = VirtualMachine.create( cls.api_client, cls.services["small"], - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.small_offering.id, mode=cls.services["mode"] ) @@ -159,8 +159,8 @@ class TestVMPasswordEnabled(cloudstackTestCase): cls.api_client, cls.services["template"], cls.volume.id, - account=cls.account.account.name, - domainid=cls.account.account.domainid + account=cls.account.name, + domainid=cls.account.domainid ) # Delete the VM - No longer needed cls.virtual_machine.delete(cls.api_client) @@ -169,8 +169,8 @@ class TestVMPasswordEnabled(cloudstackTestCase): cls.vm = VirtualMachine.create( cls.api_client, cls.services["small"], - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.small_offering.id, mode=cls.services["mode"] ) diff --git a/test/integration/component/test_volumes.py b/test/integration/component/test_volumes.py index f50113b1532..f7eb9f92600 100644 --- a/test/integration/component/test_volumes.py +++ b/test/integration/component/test_volumes.py @@ -121,7 +121,7 @@ class TestAttachVolume(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] @@ -129,8 +129,8 @@ class TestAttachVolume(cloudstackTestCase): cls.virtual_machine = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, ) cls._cleanup = [ @@ -162,13 +162,13 @@ class TestAttachVolume(cloudstackTestCase): self.apiclient, self.services["volume"], zoneid=self.zone.id, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, diskofferingid=self.disk_offering.id ) self.debug("Created volume: %s for account: %s" % ( volume.id, - self.account.account.name + self.account.name )) # Check List Volume response for newly created volume list_volume_response = list_volumes( @@ -311,13 +311,13 @@ class TestAttachVolume(cloudstackTestCase): self.apiclient, self.services["volume"], zoneid=self.zone.id, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, diskofferingid=self.disk_offering.id ) self.debug("Created volume: %s for account: %s" % ( volume.id, - self.account.account.name + self.account.name )) # Check List Volume response for newly created volume list_volume_response = list_volumes( @@ -392,7 +392,7 @@ class TestAttachDetachVolume(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] @@ -400,8 +400,8 @@ class TestAttachDetachVolume(cloudstackTestCase): cls.virtual_machine = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, ) cls._cleanup = [ @@ -449,13 +449,13 @@ class TestAttachDetachVolume(cloudstackTestCase): self.apiclient, self.services["volume"], zoneid=self.zone.id, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, diskofferingid=self.disk_offering.id ) self.debug("Created volume: %s for account: %s" % ( volume.id, - self.account.account.name + self.account.name )) self.cleanup.append(volume) volumes.append(volume) @@ -639,7 +639,7 @@ class TestAttachVolumeISO(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] @@ -647,8 +647,8 @@ class TestAttachVolumeISO(cloudstackTestCase): cls.virtual_machine = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, ) cls._cleanup = [ @@ -694,13 +694,13 @@ class TestAttachVolumeISO(cloudstackTestCase): self.apiclient, self.services["volume"], zoneid=self.zone.id, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, diskofferingid=self.disk_offering.id ) self.debug("Created volume: %s for account: %s" % ( volume.id, - self.account.account.name + self.account.name )) # Check List Volume response for newly created volume list_volume_response = list_volumes( @@ -749,12 +749,12 @@ class TestAttachVolumeISO(cloudstackTestCase): iso = Iso.create( self.apiclient, self.services["iso"], - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, ) self.debug("Created ISO with ID: %s for account: %s" % ( iso.id, - self.account.account.name + self.account.name )) try: @@ -831,7 +831,7 @@ class TestVolumes(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] @@ -839,8 +839,8 @@ class TestVolumes(cloudstackTestCase): cls.virtual_machine = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, ) @@ -848,8 +848,8 @@ class TestVolumes(cloudstackTestCase): cls.api_client, cls.services["volume"], zoneid=cls.zone.id, - account=cls.account.account.name, - domainid=cls.account.account.domainid, + account=cls.account.name, + domainid=cls.account.domainid, diskofferingid=cls.disk_offering.id ) cls._cleanup = [ @@ -1071,7 +1071,7 @@ class TestDeployVmWithCustomDisk(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] @@ -1137,8 +1137,8 @@ class TestDeployVmWithCustomDisk(cloudstackTestCase): Volume.create_custom_disk( self.apiclient, self.services["custom_volume"], - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, diskofferingid=self.disk_offering.id ) self.debug("Create volume failed!") @@ -1149,8 +1149,8 @@ class TestDeployVmWithCustomDisk(cloudstackTestCase): Volume.create_custom_disk( self.apiclient, self.services["custom_volume"], - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, diskofferingid=self.disk_offering.id ) self.debug("Create volume failed!") @@ -1163,8 +1163,8 @@ class TestDeployVmWithCustomDisk(cloudstackTestCase): Volume.create_custom_disk( self.apiclient, self.services["custom_volume"], - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, diskofferingid=self.disk_offering.id ) self.debug("Create volume of cust disk size succeeded") diff --git a/test/integration/component/test_vpn_users.py b/test/integration/component/test_vpn_users.py index e18c5384707..93186546d94 100644 --- a/test/integration/component/test_vpn_users.py +++ b/test/integration/component/test_vpn_users.py @@ -138,8 +138,8 @@ class TestVPNUsers(cloudstackTestCase): self.apiclient, self.services["virtual_machine"], templateid=self.template.id, - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) self.public_ip = PublicIPAddress.create( @@ -170,8 +170,8 @@ class TestVPNUsers(cloudstackTestCase): # Assign VPN to Public IP vpn = Vpn.create(self.apiclient, self.public_ip.ipaddress.id, - account=self.account.account.name, - domainid=self.account.account.domainid) + account=self.account.name, + domainid=self.account.domainid) self.debug("Verifying the remote VPN access") vpns = Vpn.list(self.apiclient, @@ -190,7 +190,7 @@ class TestVPNUsers(cloudstackTestCase): """Creates VPN users for the network""" self.debug("Creating VPN users for account: %s" % - self.account.account.name) + self.account.name) if api_client is None: api_client = self.apiclient try: @@ -198,8 +198,8 @@ class TestVPNUsers(cloudstackTestCase): api_client, self.services["vpn_user"]["username"], self.services["vpn_user"]["password"], - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, rand_name=rand_name ) @@ -240,7 +240,7 @@ class TestVPNUsers(cloudstackTestCase): limit = int(configs[0].value) self.debug("Enabling the VPN access for IP: %s" % - self.public_ip.ipaddress.ipaddress) + self.public_ip.ipaddress) self.create_VPN(self.public_ip) self.debug("Creating %s VPN users" % limit) @@ -278,7 +278,7 @@ class TestVPNUsers(cloudstackTestCase): "List NAT rules should return a valid response") self.debug("Enabling the VPN connection for IP: %s" % - self.public_ip.ipaddress.ipaddress) + self.public_ip.ipaddress) with self.assertRaises(Exception): self.create_VPN(self.public_ip) self.debug("Create VPN connection failed! Test successful!") @@ -295,7 +295,7 @@ class TestVPNUsers(cloudstackTestCase): # saying that VPN is enabled over port 1701 self.debug("Enabling the VPN connection for IP: %s" % - self.public_ip.ipaddress.ipaddress) + self.public_ip.ipaddress) self.create_VPN(self.public_ip) self.debug("Creating a port forwarding rule on port 1701") @@ -321,12 +321,12 @@ class TestVPNUsers(cloudstackTestCase): # the newly added user credential. self.debug("Enabling the VPN connection for IP: %s" % - self.public_ip.ipaddress.ipaddress) + self.public_ip.ipaddress) self.create_VPN(self.public_ip) try: self.debug("Adding new VPN user to account: %s" % - self.account.account.name) + self.account.name) self.create_VPN_Users() # TODO: Verify the VPN connection @@ -348,11 +348,11 @@ class TestVPNUsers(cloudstackTestCase): # 3. Adding this VPN user should fail. self.debug("Enabling the VPN connection for IP: %s" % - self.public_ip.ipaddress.ipaddress) + self.public_ip.ipaddress) self.create_VPN(self.public_ip) self.debug("Adding new VPN user to account: %s" % - self.account.account.name) + self.account.name) self.create_VPN_Users(rand_name=False) # TODO: Verify the VPN connection @@ -378,22 +378,22 @@ class TestVPNUsers(cloudstackTestCase): # establish VPN connection that will give access all VMs of this user self.debug("Enabling VPN connection to account: %s" % - self.account.account.name) + self.account.name) self.create_VPN(self.public_ip) self.debug("Creating VPN user for the account: %s" % - self.account.account.name) + self.account.name) self.create_VPN_Users() self.debug("Creating a global admin account") admin = Account.create(self.apiclient, self.services["account"], admin=True, - domainid=self.account.account.domainid) + domainid=self.account.domainid) self.cleanup.append(admin) self.debug("Creating API client for newly created user") api_client = self.testClient.createUserApiClient( - UserName=self.account.account.name, - DomainName=self.account.account.domain) + UserName=self.account.name, + DomainName=self.account.domain) self.debug("Adding new user to VPN as a global admin: %s" % admin.account.name) @@ -421,21 +421,21 @@ class TestVPNUsers(cloudstackTestCase): # establish VPN connection that will give access all VMs of this user self.debug("Enabling VPN connection to account: %s" % - self.account.account.name) + self.account.name) self.create_VPN(self.public_ip) self.debug("Creating VPN user for the account: %s" % - self.account.account.name) + self.account.name) self.create_VPN_Users() self.debug("Creating a domain admin account") admin = Account.create(self.apiclient, self.services["account"], - domainid=self.account.account.domainid) + domainid=self.account.domainid) self.cleanup.append(admin) self.debug("Creating API client for newly created user") api_client = self.testClient.createUserApiClient( - UserName=self.account.account.name, - DomainName=self.account.account.domain) + UserName=self.account.name, + DomainName=self.account.domain) self.debug("Adding new user to VPN as a domain admin: %s" % admin.account.name) diff --git a/test/integration/smoke/test_affinity_groups.py b/test/integration/smoke/test_affinity_groups.py index 3ed31152643..6ccd478bf2d 100644 --- a/test/integration/smoke/test_affinity_groups.py +++ b/test/integration/smoke/test_affinity_groups.py @@ -187,7 +187,7 @@ class TestDeployVmWithAffinityGroup(cloudstackTestCase): @classmethod def tearDown(cls): try: - cls.api_client = super(TestDeployVmWithAffinityGroup, cls).getClsTestClient().getApiClient() + #cls.api_client = super(TestDeployVmWithAffinityGroup, cls).getClsTestClient().getApiClient() #Clean up, terminate the created templates cleanup_resources(cls.api_client, cls.cleanup) except Exception as e: diff --git a/test/integration/smoke/test_guest_vlan_range.py b/test/integration/smoke/test_guest_vlan_range.py new file mode 100644 index 00000000000..eca0e61f137 --- /dev/null +++ b/test/integration/smoke/test_guest_vlan_range.py @@ -0,0 +1,157 @@ +# 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 Dedicating Guest Vlan Ranges +""" +#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 * +import datetime + + +class Services: + """Test Dedicating Guest Vlan Ranges + """ + + def __init__(self): + self.services = { + "domain": { + "name": "Domain", + }, + "account": { + "email": "test@test.com", + "firstname": "Test", + "lastname": "User", + "username": "test", + "password": "password", + }, + "name": "testphysicalnetwork" + } + + +class TesDedicateGuestVlanRange(cloudstackTestCase): + + @classmethod + def setUpClass(cls): + cls.api_client = super(TesDedicateGuestVlanRange, 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", "advanced", "guestvlanrange", "dedicate", "release"]) + def test_dedicateGuestVlanRange(self): + """Test guest vlan range dedication + """ + + """Assume a physical network is available + """ + # Validate the following: + # 1. List the available physical network using ListPhysicalNetwork + # 2. Add a Guest Vlan range to the available physical network using UpdatePhysicalNetwork + # 3. Dedicate the created guest vlan range to user account using DedicateGuestVlanRange + # 4. Verify vlan range is dedicated with listDedicatedGuestVlanRanges + # 5. Release the dedicated guest vlan range back to the system + # 6. Verify guest vlan range has been released, verify with listDedicatedGuestVlanRanges + # 7. Remove the added guest vlan range using UpdatePhysicalNetwork + + self.debug("Listing available physical network") + list_physical_network_response = PhysicalNetwork.list( + self.apiclient + ) + self.assertEqual( + isinstance(list_physical_network_response, list), + True, + "Check for list guest vlan range response" + ) + physical_network_response = list_physical_network_response[0] + + self.debug("Adding guest vlan range") + addGuestVlanRangeResponse = physical_network_response.update(self.apiclient, id=physical_network_response.id, vlan="387-390") + + self.debug("Dedicating guest vlan range"); + dedicate_guest_vlan_range_response = PhysicalNetwork.dedicate( + self.apiclient, + "387-390", + physicalnetworkid=physical_network_response.id, + account=self.account.name, + domainid=self.account.domainid + ) + list_dedicated_guest_vlan_range_response = PhysicalNetwork.listDedicated( + self.apiclient, + id=dedicate_guest_vlan_range_response.id + ) + dedicated_guest_vlan_response = list_dedicated_guest_vlan_range_response[0] + self.assertEqual( + dedicated_guest_vlan_response.account, + self.account.name, + "Check account name is in listDedicatedGuestVlanRanges as the account the range is dedicated to" + ) + + self.debug("Releasing guest vlan range"); + dedicated_guest_vlan_response.release(self.apiclient) + list_dedicated_guest_vlan_range_response = PhysicalNetwork.listDedicated( + self.apiclient, + id=dedicate_guest_vlan_range_response.id + ) + dedicated_guest_vlan_response = list_dedicated_guest_vlan_range_response[0] + self.assertEqual( + dedicated_guest_vlan_response.account, + "system", + "Check account name is system account in listDedicatedGuestVlanRanges" + ) + + self.debug("Removing guest vlan range") + removeGuestVlanRangeResponse = physical_network_response.update(self.apiclient, id=physical_network_response.id, removevlan="387-390") diff --git a/test/integration/smoke/test_iso.py b/test/integration/smoke/test_iso.py index 0b7d2765775..ad4a8f280d1 100644 --- a/test/integration/smoke/test_iso.py +++ b/test/integration/smoke/test_iso.py @@ -139,8 +139,8 @@ class TestCreateIso(cloudstackTestCase): iso = Iso.create( self.apiclient, self.services["iso_2"], - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.debug("ISO created with ID: %s" % iso.id) @@ -214,7 +214,7 @@ class TestISO(cloudstackTestCase): cls.services["account"], domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name # Finding the OsTypeId from Ostype ostypes = list_os_types( cls.api_client, @@ -230,8 +230,8 @@ class TestISO(cloudstackTestCase): cls.iso_1 = Iso.create( cls.api_client, cls.services["iso_1"], - account=cls.account.account.name, - domainid=cls.account.account.domainid + account=cls.account.name, + domainid=cls.account.domainid ) try: cls.iso_1.download(cls.api_client) @@ -242,8 +242,8 @@ class TestISO(cloudstackTestCase): cls.iso_2 = Iso.create( cls.api_client, cls.services["iso_2"], - account=cls.account.account.name, - domainid=cls.account.account.domainid + account=cls.account.name, + domainid=cls.account.domainid ) try: cls.iso_2.download(cls.api_client) @@ -448,8 +448,8 @@ class TestISO(cloudstackTestCase): list_iso_response = list_isos( self.apiclient, id=self.iso_2.id, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(list_iso_response, list), diff --git a/test/integration/smoke/test_network.py b/test/integration/smoke/test_network.py index df89eaaa695..322e8c25c8e 100644 --- a/test/integration/smoke/test_network.py +++ b/test/integration/smoke/test_network.py @@ -145,8 +145,8 @@ class TestPublicIP(cloudstackTestCase): cls.account_network = Network.create( cls.api_client, cls.services["network"], - cls.account.account.name, - cls.account.account.domainid + cls.account.name, + cls.account.domainid ) cls.user_network = Network.create( cls.api_client, @@ -158,9 +158,9 @@ class TestPublicIP(cloudstackTestCase): # Create Source NAT IP addresses account_src_nat_ip = PublicIPAddress.create( cls.api_client, - cls.account.account.name, + cls.account.name, cls.zone.id, - cls.account.account.domainid + cls.account.domainid ) user_src_nat_ip = PublicIPAddress.create( cls.api_client, @@ -197,9 +197,9 @@ class TestPublicIP(cloudstackTestCase): ip_address = PublicIPAddress.create( self.apiclient, - self.account.account.name, + self.account.name, self.zone.id, - self.account.account.domainid + self.account.domainid ) list_pub_ip_addr_resp = list_publicIP( self.apiclient, @@ -321,8 +321,8 @@ class TestPortForwarding(cloudstackTestCase): cls.api_client, cls.services["server"], templateid=template.id, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) cls._cleanup = [ @@ -358,8 +358,8 @@ class TestPortForwarding(cloudstackTestCase): src_nat_ip_addrs = list_publicIP( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( @@ -481,9 +481,9 @@ class TestPortForwarding(cloudstackTestCase): ip_address = PublicIPAddress.create( self.apiclient, - self.account.account.name, + self.account.name, self.zone.id, - self.account.account.domainid, + self.account.domainid, self.services["server"] ) self.cleanup.append(ip_address) @@ -554,9 +554,9 @@ class TestPortForwarding(cloudstackTestCase): self.debug("SSHing into VM with IP address %s with NAT IP %s" % ( self.virtual_machine.ipaddress, - ip_address.ipaddress.ipaddress + ip_address.ipaddress )) - self.virtual_machine.get_ssh_client(ip_address.ipaddress.ipaddress) + self.virtual_machine.get_ssh_client(ip_address.ipaddress) except Exception as e: self.fail( "SSH Access failed for %s: %s" % \ @@ -581,7 +581,7 @@ class TestPortForwarding(cloudstackTestCase): self.virtual_machine.ipaddress) remoteSSHClient( - ip_address.ipaddress.ipaddress, + ip_address.ipaddress, self.virtual_machine.ssh_port, self.virtual_machine.username, self.virtual_machine.password @@ -621,23 +621,23 @@ class TestLoadBalancingRule(cloudstackTestCase): cls.api_client, cls.services["server"], templateid=template.id, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) cls.vm_2 = VirtualMachine.create( cls.api_client, cls.services["server"], templateid=template.id, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) cls.non_src_nat_ip = PublicIPAddress.create( cls.api_client, - cls.account.account.name, + cls.account.name, cls.zone.id, - cls.account.account.domainid, + cls.account.domainid, cls.services["server"] ) # Open up firewall port for SSH @@ -680,8 +680,8 @@ class TestLoadBalancingRule(cloudstackTestCase): src_nat_ip_addrs = list_publicIP( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(src_nat_ip_addrs, list), @@ -693,8 +693,8 @@ class TestLoadBalancingRule(cloudstackTestCase): # Check if VM is in Running state before creating LB rule vm_response = VirtualMachine.list( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( @@ -720,7 +720,7 @@ class TestLoadBalancingRule(cloudstackTestCase): self.apiclient, self.services["lbrule"], src_nat_ip_addr.id, - accountid=self.account.account.name + accountid=self.account.name ) self.cleanup.append(lb_rule) @@ -889,8 +889,8 @@ class TestLoadBalancingRule(cloudstackTestCase): # Check if VM is in Running state before creating LB rule vm_response = VirtualMachine.list( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( @@ -916,7 +916,7 @@ class TestLoadBalancingRule(cloudstackTestCase): self.apiclient, self.services["lbrule"], self.non_src_nat_ip.ipaddress.id, - accountid=self.account.account.name + accountid=self.account.name ) self.cleanup.append(lb_rule) @@ -974,12 +974,12 @@ class TestLoadBalancingRule(cloudstackTestCase): try: self.debug("SSHing into IP address: %s after adding VMs (ID: %s , %s)" % ( - self.non_src_nat_ip.ipaddress.ipaddress, + self.non_src_nat_ip.ipaddress, self.vm_1.id, self.vm_2.id )) ssh_1 = remoteSSHClient( - self.non_src_nat_ip.ipaddress.ipaddress, + self.non_src_nat_ip.ipaddress, self.services['lbrule']["publicport"], self.vm_1.username, self.vm_1.password @@ -993,12 +993,12 @@ class TestLoadBalancingRule(cloudstackTestCase): self.debug("SSHing again into IP address: %s with VMs (ID: %s , %s) added to LB rule" % ( - self.non_src_nat_ip.ipaddress.ipaddress, + self.non_src_nat_ip.ipaddress, self.vm_1.id, self.vm_2.id )) ssh_2 = remoteSSHClient( - self.non_src_nat_ip.ipaddress.ipaddress, + self.non_src_nat_ip.ipaddress, self.services['lbrule']["publicport"], self.vm_1.username, self.vm_1.password @@ -1022,11 +1022,11 @@ class TestLoadBalancingRule(cloudstackTestCase): self.debug("SSHing into IP address: %s after removing VM (ID: %s) from LB rule" % ( - self.non_src_nat_ip.ipaddress.ipaddress, + self.non_src_nat_ip.ipaddress, self.vm_2.id )) ssh_1 = remoteSSHClient( - self.non_src_nat_ip.ipaddress.ipaddress, + self.non_src_nat_ip.ipaddress, self.services['lbrule']["publicport"], self.vm_1.username, self.vm_1.password @@ -1036,7 +1036,7 @@ class TestLoadBalancingRule(cloudstackTestCase): self.debug("Hostnames after removing VM2: %s" % str(hostnames)) except Exception as e: self.fail("%s: SSH failed for VM with IP Address: %s" % - (e, self.non_src_nat_ip.ipaddress.ipaddress)) + (e, self.non_src_nat_ip.ipaddress)) self.assertIn( self.vm_1.name, @@ -1048,11 +1048,11 @@ class TestLoadBalancingRule(cloudstackTestCase): with self.assertRaises(Exception): self.fail("SSHing into IP address: %s after removing VM (ID: %s) from LB rule" % ( - self.non_src_nat_ip.ipaddress.ipaddress, + self.non_src_nat_ip.ipaddress, self.vm_1.id )) ssh_1 = remoteSSHClient( - self.non_src_nat_ip.ipaddress.ipaddress, + self.non_src_nat_ip.ipaddress, self.services['lbrule']["publicport"], self.vm_1.username, self.vm_1.password @@ -1093,15 +1093,15 @@ class TestRebootRouter(cloudstackTestCase): self.apiclient, self.services["server"], templateid=template.id, - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) src_nat_ip_addrs = list_publicIP( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) try: src_nat_ip_addr = src_nat_ip_addrs[0] @@ -1129,7 +1129,7 @@ class TestRebootRouter(cloudstackTestCase): self.apiclient, self.services["lbrule"], src_nat_ip_addr.id, - self.account.account.name + self.account.name ) lb_rule.assign(self.apiclient, [self.vm_1]) self.nat_rule = NATRule.create( @@ -1159,8 +1159,8 @@ class TestRebootRouter(cloudstackTestCase): #Retrieve router for the user account routers = list_routers( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(routers, list), @@ -1254,8 +1254,8 @@ class TestAssignRemoveLB(cloudstackTestCase): self.apiclient, self.services["server"], templateid=template.id, - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) @@ -1263,8 +1263,8 @@ class TestAssignRemoveLB(cloudstackTestCase): self.apiclient, self.services["server"], templateid=template.id, - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) @@ -1272,8 +1272,8 @@ class TestAssignRemoveLB(cloudstackTestCase): self.apiclient, self.services["server"], templateid=template.id, - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) @@ -1297,8 +1297,8 @@ class TestAssignRemoveLB(cloudstackTestCase): src_nat_ip_addrs = list_publicIP( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(src_nat_ip_addrs, list), @@ -1320,8 +1320,8 @@ class TestAssignRemoveLB(cloudstackTestCase): # Check if VM is in Running state before creating LB rule vm_response = VirtualMachine.list( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( @@ -1346,7 +1346,7 @@ class TestAssignRemoveLB(cloudstackTestCase): self.apiclient, self.services["lbrule"], self.non_src_nat_ip.id, - self.account.account.name + self.account.name ) lb_rule.assign(self.apiclient, [self.vm_1, self.vm_2]) @@ -1514,28 +1514,28 @@ class TestReleaseIP(cloudstackTestCase): self.apiclient, self.services["server"], templateid=template.id, - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) self.ip_address = PublicIPAddress.create( self.apiclient, - self.account.account.name, + self.account.name, self.zone.id, - self.account.account.domainid + self.account.domainid ) ip_addrs = list_publicIP( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) try: self.ip_addr = ip_addrs[0] except Exception as e: raise Exception("Failed: During acquiring source NAT for account: %s" % - self.account.account.name) + self.account.name) self.nat_rule = NATRule.create( self.apiclient, @@ -1547,7 +1547,7 @@ class TestReleaseIP(cloudstackTestCase): self.apiclient, self.services["lbrule"], self.ip_addr.id, - accountid=self.account.account.name + accountid=self.account.name ) self.cleanup = [ self.virtual_machine, @@ -1652,15 +1652,15 @@ class TestDeleteAccount(cloudstackTestCase): self.apiclient, self.services["server"], templateid=template.id, - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) src_nat_ip_addrs = list_publicIP( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) try: @@ -1674,7 +1674,7 @@ class TestDeleteAccount(cloudstackTestCase): self.apiclient, self.services["lbrule"], src_nat_ip_addr.id, - self.account.account.name + self.account.name ) self.lb_rule.assign(self.apiclient, [self.vm_1]) @@ -1717,8 +1717,8 @@ class TestDeleteAccount(cloudstackTestCase): try: list_lb_reponse = list_lb_rules( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( list_lb_reponse, @@ -1729,14 +1729,14 @@ class TestDeleteAccount(cloudstackTestCase): raise Exception( "Exception raised while fetching LB rules for account: %s" % - self.account.account.name) + self.account.name) # ListPortForwardingRules should not # list associated rules with deleted account try: list_nat_reponse = list_nat_rules( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( list_nat_reponse, @@ -1747,13 +1747,13 @@ class TestDeleteAccount(cloudstackTestCase): raise Exception( "Exception raised while fetching NAT rules for account: %s" % - self.account.account.name) + self.account.name) #Retrieve router for the user account try: routers = list_routers( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( routers, @@ -1764,7 +1764,7 @@ class TestDeleteAccount(cloudstackTestCase): raise Exception( "Exception raised while fetching routers for account: %s" % - self.account.account.name) + self.account.name) return def tearDown(self): diff --git a/test/integration/smoke/test_nic.py b/test/integration/smoke/test_nic.py index ad30122cd47..bae6dfda15d 100644 --- a/test/integration/smoke/test_nic.py +++ b/test/integration/smoke/test_nic.py @@ -181,8 +181,8 @@ class TestDeployVM(cloudstackTestCase): self.test_network = Network.create( self.apiclient, self.services["network"], - self.account.account.name, - self.account.account.domainid, + self.account.name, + self.account.domainid, ) self.cleanup.insert(0, self.test_network) except Exception as ex: @@ -198,8 +198,8 @@ class TestDeployVM(cloudstackTestCase): self.virtual_machine = VirtualMachine.create( self.apiclient, self.services["small"], - accountid=self.account.account.name, - domainid=self.account.account.domainid, + accountid=self.account.name, + domainid=self.account.domainid, serviceofferingid=self.service_offering.id, mode=self.services['mode'] ) diff --git a/test/integration/smoke/test_non_contigiousvlan.py b/test/integration/smoke/test_non_contigiousvlan.py index 91b6325782c..4e130d97aa0 100644 --- a/test/integration/smoke/test_non_contigiousvlan.py +++ b/test/integration/smoke/test_non_contigiousvlan.py @@ -81,6 +81,6 @@ class TestUpdatePhysicalNetwork(cloudstackTestCase): self.network = phy_networks[0] self.networkid = phy_networks[0].id updateResponse = self.network.update(self.apiClient, id = self.networkid, removevlan = self.vlan["full"]) - self.assert_(updateResponse.vlan.find(self.vlan["full"]) > 0, + self.assert_(updateResponse.vlan.find(self.vlan["full"]) < 0, "VLAN was not removed successfully") diff --git a/test/integration/smoke/test_routers.py b/test/integration/smoke/test_routers.py index 7785576423a..9ec2e918c42 100644 --- a/test/integration/smoke/test_routers.py +++ b/test/integration/smoke/test_routers.py @@ -102,8 +102,8 @@ class TestRouterServices(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], templateid=template.id, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) cls.cleanup = [ @@ -143,8 +143,8 @@ class TestRouterServices(cloudstackTestCase): # Find router associated with user account list_router_response = list_routers( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(list_router_response, list), @@ -205,8 +205,8 @@ class TestRouterServices(cloudstackTestCase): # Find router associated with user account list_router_response = list_routers( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(list_router_response, list), @@ -284,8 +284,8 @@ class TestRouterServices(cloudstackTestCase): # Find router associated with user account list_router_response = list_routers( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(list_router_response, list), @@ -302,8 +302,8 @@ class TestRouterServices(cloudstackTestCase): while True: networks = list_networks( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(networks, list), @@ -332,8 +332,8 @@ class TestRouterServices(cloudstackTestCase): # Get router details after restart list_router_response = list_routers( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(list_router_response, list), @@ -364,8 +364,8 @@ class TestRouterServices(cloudstackTestCase): while True: networks = list_networks( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(networks, list), @@ -394,8 +394,8 @@ class TestRouterServices(cloudstackTestCase): # Get router details after restart list_router_response = list_routers( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(list_router_response, list), @@ -462,8 +462,8 @@ class TestRouterServices(cloudstackTestCase): list_router_response = list_routers( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(list_router_response, list), @@ -528,8 +528,8 @@ class TestRouterServices(cloudstackTestCase): list_router_response = list_routers( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(list_router_response, list), @@ -609,8 +609,8 @@ class TestRouterServices(cloudstackTestCase): list_router_response = list_routers( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(list_router_response, list), @@ -653,8 +653,8 @@ class TestRouterServices(cloudstackTestCase): list_router_response = list_routers( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(list_router_response, list), @@ -698,8 +698,8 @@ class TestRouterServices(cloudstackTestCase): list_router_response = list_routers( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(list_router_response, list), @@ -755,8 +755,8 @@ class TestRouterServices(cloudstackTestCase): list_vms = list_virtual_machines( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(list_vms, list), @@ -809,8 +809,8 @@ class TestRouterServices(cloudstackTestCase): #Check status of network router list_router_response = list_routers( self.apiclient, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) if isinstance(list_router_response, list): break diff --git a/test/integration/smoke/test_scale_vm.py b/test/integration/smoke/test_scale_vm.py index 64fe4dc9aa4..fa2418b7cd8 100644 --- a/test/integration/smoke/test_scale_vm.py +++ b/test/integration/smoke/test_scale_vm.py @@ -137,8 +137,8 @@ class TestScaleVm(cloudstackTestCase): cls.virtual_machine = VirtualMachine.create( cls.api_client, cls.services["small"], - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.small_offering.id, mode=cls.services["mode"] ) diff --git a/test/integration/smoke/test_templates.py b/test/integration/smoke/test_templates.py index a648098079f..fa4bc4014ec 100644 --- a/test/integration/smoke/test_templates.py +++ b/test/integration/smoke/test_templates.py @@ -148,7 +148,7 @@ class TestCreateTemplate(cloudstackTestCase): cls.services["account"], domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client, @@ -159,8 +159,8 @@ class TestCreateTemplate(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], templateid=template.id, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"] ) @@ -235,8 +235,8 @@ class TestCreateTemplate(cloudstackTestCase): self.apiclient, self.services["template_1"], self.volume.id, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.cleanup.append(template) @@ -332,7 +332,7 @@ class TestTemplates(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client, @@ -343,8 +343,8 @@ class TestTemplates(cloudstackTestCase): cls.api_client, cls.services["virtual_machine"], templateid=template.id, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"] ) @@ -393,15 +393,15 @@ class TestTemplates(cloudstackTestCase): cls.api_client, cls.services["template_1"], cls.volume.id, - account=cls.account.account.name, - domainid=cls.account.account.domainid + account=cls.account.name, + domainid=cls.account.domainid ) cls.template_2 = Template.create( cls.api_client, cls.services["template_2"], cls.volume.id, - account=cls.account.account.name, - domainid=cls.account.account.domainid + account=cls.account.name, + domainid=cls.account.domainid ) cls._cleanup = [ cls.service_offering, @@ -474,8 +474,8 @@ class TestTemplates(cloudstackTestCase): templatefilter=\ self.services["templatefilter"], id=self.template_1.id, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) if isinstance(list_template_response, list): break @@ -540,8 +540,8 @@ class TestTemplates(cloudstackTestCase): templatefilter=\ self.services["templatefilter"], id=self.template_1.id, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) # Verify template is deleted properly using ListTemplates self.assertEqual( @@ -626,8 +626,8 @@ class TestTemplates(cloudstackTestCase): self.apiclient, templatefilter='featured', id=self.template_2.id, - account=self.account.account.name, - domainid=self.account.account.domainid + account=self.account.name, + domainid=self.account.domainid ) self.assertEqual( isinstance(list_template_response, list), diff --git a/test/integration/smoke/test_vm_snapshots.py b/test/integration/smoke/test_vm_snapshots.py new file mode 100644 index 00000000000..353d499f7a1 --- /dev/null +++ b/test/integration/smoke/test_vm_snapshots.py @@ -0,0 +1,308 @@ +# 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. + +# 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 + +class Services: + """Test Snapshots Services + """ + + def __init__(self): + self.services = { + "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": 200, # in MHz + "memory": 256, # In MBs + }, + "server": { + "displayname": "TestVM", + "username": "root", + "password": "password", + "ssh_port": 22, + "hypervisor": 'XenServer', + "privateport": 22, + "publicport": 22, + "protocol": 'TCP', + }, + "mgmt_server": { + "ipaddress": '1.2.2.152', + "username": "root", + "password": "password", + "port": 22, + }, + "templates": { + "displaytext": 'Template', + "name": 'Template', + "ostype": "CentOS 5.3 (64-bit)", + "templatefilter": 'self', + }, + "test_dir": "/tmp", + "random_data": "random.data", + "snapshot_name":"TestSnapshot", + "snapshot_displaytext":"Test", + "ostype": "CentOS 5.3 (64-bit)", + "sleep": 60, + "timeout": 10, + "mode": 'advanced', # Networking mode: Advanced, Basic + } + +class TestVmSnapshot(cloudstackTestCase): + @classmethod + def setUpClass(cls): + cls.api_client = super(TestVmSnapshot, cls).getClsTestClient().getApiClient() + cls.services = Services().services + # Get Zone, Domain and templates + cls.domain = get_domain(cls.api_client, cls.services) + cls.zone = get_zone(cls.api_client, cls.services) + + template = get_template( + cls.api_client, + cls.zone.id, + cls.services["ostype"] + ) + cls.services["domainid"] = cls.domain.id + cls.services["server"]["zoneid"] = cls.zone.id + cls.services["templates"]["ostypeid"] = template.ostypeid + cls.services["zoneid"] = cls.zone.id + + # Create VMs, NAT Rules etc + cls.account = Account.create( + cls.api_client, + cls.services["account"], + domainid=cls.domain.id + ) + + cls.services["account"] = cls.account.name + + cls.service_offering = ServiceOffering.create( + cls.api_client, + cls.services["service_offering"] + ) + cls.virtual_machine = VirtualMachine.create( + cls.api_client, + cls.services["server"], + templateid=template.id, + accountid=cls.account.name, + domainid=cls.account.domainid, + serviceofferingid=cls.service_offering.id, + mode=cls.services["mode"] + ) + cls.random_data_0 = random_gen(100) + cls._cleanup = [ + cls.service_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, terminate the created instance, volumes and snapshots + cleanup_resources(self.apiclient, self.cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return + + @attr(tags=["advanced", "advancedns", "smoke"]) + def test_01_create_vm_snapshots(self): + + try: + # Login to VM and write data to file system + ssh_client = self.virtual_machine.get_ssh_client() + + cmds = [ + "echo %s > %s/%s" % (self.random_data_0, self.services["test_dir"], self.services["random_data"]), + "cat %s/%s" % (self.services["test_dir"], self.services["random_data"]) + ] + + for c in cmds: + self.debug(c) + result = ssh_client.execute(c) + self.debug(result) + + except Exception: + self.fail("SSH failed for Virtual machine: %s" % + self.virtual_machine.ipaddress) + self.assertEqual( + self.random_data_0, + result[0], + "Check the random data has be write into temp file!" + ) + + time.sleep(self.services["sleep"]) + + vm_snapshot = VmSnapshot.create( + self.apiclient, + self.virtual_machine.id, + "false", + self.services["snapshot_name"], + self.services["snapshot_displaytext"] + ) + self.assertEqual( + vm_snapshot.state, + "Ready", + "Check the snapshot of vm is ready!" + ) + return + + @attr(tags=["advanced", "advancedns", "smoke"]) + def test_02_revert_vm_snapshots(self): + try: + ssh_client = self.virtual_machine.get_ssh_client() + + cmds = [ + "rm -rf %s/%s" % (self.services["test_dir"], self.services["random_data"]), + "ls %s/%s" % (self.services["test_dir"], self.services["random_data"]) + ] + + for c in cmds: + self.debug(c) + result = ssh_client.execute(c) + self.debug(result) + + except Exception: + self.fail("SSH failed for Virtual machine: %s" % + self.virtual_machine.ipaddress) + + if str(result[0]).index("No such file or directory") == -1: + self.fail("Check the random data has be delete from temp file!") + + time.sleep(self.services["sleep"]) + + list_snapshot_response = VmSnapshot.list(self.apiclient,vmid=self.virtual_machine.id,listall=True) + + self.assertEqual( + isinstance(list_snapshot_response, list), + True, + "Check list response returns a valid list" + ) + self.assertNotEqual( + list_snapshot_response, + None, + "Check if snapshot exists in ListSnapshot" + ) + + self.assertEqual( + list_snapshot_response[0].state, + "Ready", + "Check the snapshot of vm is ready!" + ) + + VmSnapshot.revertToSnapshot(self.apiclient,list_snapshot_response[0].id) + + list_vm_response = list_virtual_machines( + self.apiclient, + id=self.virtual_machine.id + ) + + self.assertEqual( + list_vm_response[0].state, + "Stopped", + "Check the state of vm is Stopped!" + ) + + cmd = startVirtualMachine.startVirtualMachineCmd() + cmd.id = list_vm_response[0].id + self.apiclient.startVirtualMachine(cmd) + + time.sleep(self.services["sleep"]) + + try: + ssh_client = self.virtual_machine.get_ssh_client(reconnect=True) + + cmds = [ + "cat %s/%s" % (self.services["test_dir"], self.services["random_data"]) + ] + + for c in cmds: + self.debug(c) + result = ssh_client.execute(c) + self.debug(result) + + except Exception: + self.fail("SSH failed for Virtual machine: %s" % + self.virtual_machine.ipaddress) + + self.assertEqual( + self.random_data_0, + result[0], + "Check the random data is equal with the ramdom file!" + ) + @attr(tags=["advanced", "advancedns", "smoke"]) + def test_03_delete_vm_snapshots(self): + + list_snapshot_response = VmSnapshot.list(self.apiclient,vmid=self.virtual_machine.id,listall=True) + + self.assertEqual( + isinstance(list_snapshot_response, list), + True, + "Check list response returns a valid list" + ) + self.assertNotEqual( + list_snapshot_response, + None, + "Check if snapshot exists in ListSnapshot" + ) + """ + cmd = deleteVMSnapshot.deleteVMSnapshotCmd() + cmd.vmsnapshotid = list_snapshot_response[0].id + self.apiclient.deleteVMSnapshot(cmd) + """ + VmSnapshot.deleteVMSnapshot(self.apiclient,list_snapshot_response[0].id) + + time.sleep(self.services["sleep"]*3) + + list_snapshot_response = VmSnapshot.list(self.apiclient,vmid=self.virtual_machine.id,listall=True) + + self.assertEqual( + list_snapshot_response, + None, + "Check list vm snapshot has be deleted" + ) diff --git a/test/integration/smoke/test_volumes.py b/test/integration/smoke/test_volumes.py index 750f9856b22..ecac8c903c1 100644 --- a/test/integration/smoke/test_volumes.py +++ b/test/integration/smoke/test_volumes.py @@ -126,7 +126,7 @@ class TestCreateVolume(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] @@ -134,8 +134,8 @@ class TestCreateVolume(cloudstackTestCase): cls.virtual_machine = VirtualMachine.create( cls.api_client, cls.services, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"] ) @@ -167,8 +167,8 @@ class TestCreateVolume(cloudstackTestCase): self.apiClient, v, zoneid=self.zone.id, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, diskofferingid=self.disk_offering.id ) self.debug("Created a volume with ID: %s" % volume.id) @@ -177,8 +177,8 @@ class TestCreateVolume(cloudstackTestCase): volume = Volume.create_custom_disk( self.apiClient, self.services, - account=self.account.account.name, - domainid=self.account.account.domainid, + account=self.account.name, + domainid=self.account.domainid, ) self.debug("Created a volume with custom offering: %s" % volume.id) self.volumes.append(volume) @@ -320,7 +320,7 @@ class TestVolumes(cloudstackTestCase): domainid=cls.domain.id ) - cls.services["account"] = cls.account.account.name + cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] @@ -328,8 +328,8 @@ class TestVolumes(cloudstackTestCase): cls.virtual_machine = VirtualMachine.create( cls.api_client, cls.services, - accountid=cls.account.account.name, - domainid=cls.account.account.domainid, + accountid=cls.account.name, + domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"] ) @@ -337,8 +337,8 @@ class TestVolumes(cloudstackTestCase): cls.volume = Volume.create( cls.api_client, cls.services, - account=cls.account.account.name, - domainid=cls.account.account.domainid + account=cls.account.name, + domainid=cls.account.domainid ) cls._cleanup = [ cls.resized_disk_offering, diff --git a/tools/appliance/definitions/systemvmtemplate/definition.rb b/tools/appliance/definitions/systemvmtemplate/definition.rb index 27336f17f8b..87dbfad09ad 100644 --- a/tools/appliance/definitions/systemvmtemplate/definition.rb +++ b/tools/appliance/definitions/systemvmtemplate/definition.rb @@ -3,9 +3,9 @@ Veewee::Definition.declare({ :memory_size=> '256', :disk_size => '2000', :disk_format => 'VDI', :hostiocache => 'off', :os_type_id => 'Debian', - :iso_file => "debian-wheezy-DI-rc1-i386-netinst.iso", - :iso_src => "http://cdimage.debian.org/cdimage/wheezy_di_rc1/i386/iso-cd/debian-wheezy-DI-rc1-i386-netinst.iso", - :iso_md5 => "db12ca9554bb8f121c98e268682a55d0", + :iso_file => "debian-7.0.0-i386-netinst.iso", + :iso_src => "http://cdimage.debian.org/debian-cd/7.0.0/i386/iso-cd/debian-7.0.0-i386-netinst.iso", + :iso_md5 => "a6b93666a5393334accb7ac4ee28d949", :iso_download_timeout => "1000", :boot_wait => "10", :boot_cmd_sequence => [ '', diff --git a/tools/appliance/definitions/systemvmtemplate/postinstall.sh b/tools/appliance/definitions/systemvmtemplate/postinstall.sh index ae8f1adfb9c..38363d91130 100644 --- a/tools/appliance/definitions/systemvmtemplate/postinstall.sh +++ b/tools/appliance/definitions/systemvmtemplate/postinstall.sh @@ -40,7 +40,7 @@ install_packages() { # haproxy apt-get --no-install-recommends -q -y --force-yes install haproxy # dnsmasq - apt-get --no-install-recommends -q -y --force-yes install dnsmasq + apt-get --no-install-recommends -q -y --force-yes install dnsmasq dnsmasq-utils # nfs client apt-get --no-install-recommends -q -y --force-yes install nfs-common diff --git a/tools/appliance/definitions/systemvmtemplate64/definition.rb b/tools/appliance/definitions/systemvmtemplate64/definition.rb index 35ef878d35a..38828da70de 100644 --- a/tools/appliance/definitions/systemvmtemplate64/definition.rb +++ b/tools/appliance/definitions/systemvmtemplate64/definition.rb @@ -3,9 +3,9 @@ Veewee::Definition.declare({ :memory_size=> '256', :disk_size => '2000', :disk_format => 'VDI', :hostiocache => 'off', :os_type_id => 'Debian_64', - :iso_file => "debian-wheezy-DI-rc1-amd64-netinst.iso", - :iso_src => "http://cdimage.debian.org/cdimage/wheezy_di_rc1/amd64/iso-cd/debian-wheezy-DI-rc1-amd64-netinst.iso", - :iso_md5 => "412f77d4b98adf2a7d575745fd282d78", + :iso_file => "debian-7.0.0-amd64-netinst.iso", + :iso_src => "http://cdimage.debian.org/debian-cd/7.0.0/amd64/iso-cd/debian-7.0.0-amd64-netinst.iso", + :iso_md5 => "6a55096340b5b1b7d335d5b559e13ea0", :iso_download_timeout => "1000", :boot_wait => "10", :boot_cmd_sequence => [ '', diff --git a/tools/appliance/definitions/systemvmtemplate64/postinstall.sh b/tools/appliance/definitions/systemvmtemplate64/postinstall.sh index ae8f1adfb9c..38363d91130 100644 --- a/tools/appliance/definitions/systemvmtemplate64/postinstall.sh +++ b/tools/appliance/definitions/systemvmtemplate64/postinstall.sh @@ -40,7 +40,7 @@ install_packages() { # haproxy apt-get --no-install-recommends -q -y --force-yes install haproxy # dnsmasq - apt-get --no-install-recommends -q -y --force-yes install dnsmasq + apt-get --no-install-recommends -q -y --force-yes install dnsmasq dnsmasq-utils # nfs client apt-get --no-install-recommends -q -y --force-yes install nfs-common diff --git a/tools/marvin/marvin/integration/lib/base.py b/tools/marvin/marvin/integration/lib/base.py index 1d86c6c1599..cdb6a36c41d 100755 --- a/tools/marvin/marvin/integration/lib/base.py +++ b/tools/marvin/marvin/integration/lib/base.py @@ -298,11 +298,10 @@ class VirtualMachine: if "userdata" in services: cmd.userdata = base64.b64encode(services["userdata"]) - virtual_machine = apiclient.deployVirtualMachine(cmd, method=method) - if group: cmd.group = group - virtual_machine = apiclient.deployVirtualMachine(cmd) + + virtual_machine = apiclient.deployVirtualMachine(cmd, method=method) if startvm == False: virtual_machine.ssh_ip = virtual_machine.nic[0].ipaddress @@ -2178,6 +2177,33 @@ class PhysicalNetwork: cmd.traffictype = type return apiclient.addTrafficType(cmd) + @classmethod + def dedicate(cls, apiclient, vlanrange, physicalnetworkid, account=None, domainid=None, projectid=None): + """Dedicate guest vlan range""" + + cmd = dedicateGuestVlanRange.dedicateGuestVlanRangeCmd() + cmd.vlanrange = vlanrange + cmd.physicalnetworkid = physicalnetworkid + cmd.account = account + cmd.domainid = domainid + cmd.projectid = projectid + return PhysicalNetwork(apiclient.dedicateGuestVlanRange(cmd).__dict__) + + def release(self, apiclient): + """Release guest vlan range""" + + cmd = releaseDedicatedGuestVlanRange.releaseDedicatedGuestVlanRangeCmd() + cmd.id = self.id + return apiclient.releaseDedicatedGuestVlanRange(cmd) + + @classmethod + def listDedicated(cls, apiclient, **kwargs): + """Lists all dedicated guest vlan ranges""" + + cmd = listDedicatedGuestVlanRanges.listDedicatedGuestVlanRangesCmd() + [setattr(cmd, k, v) for k, v in kwargs.items()] + return map(lambda pn : PhysicalNetwork(pn.__dict__), apiclient.listDedicatedGuestVlanRanges(cmd)) + @classmethod def list(cls, apiclient, **kwargs): """Lists all physical networks""" @@ -3045,3 +3071,40 @@ class ASA1000V: cmd = listCiscoAsa1000vResources.listCiscoAsa1000vResourcesCmd() [setattr(cmd, k, v) for k, v in kwargs.items()] return(apiclient.listCiscoAsa1000vResources(cmd)) + +class VmSnapshot: + """Manage VM Snapshot life cycle""" + def __init__(self, items): + self.__dict__.update(items) + @classmethod + def create(cls,apiclient,vmid,snapshotmemory="false",name=None,description=None): + cmd = createVMSnapshot.createVMSnapshotCmd() + cmd.virtualmachineid = vmid + + if snapshotmemory: + cmd.snapshotmemory = snapshotmemory + if name: + cmd.name = name + if description: + cmd.description = description + return VmSnapshot(apiclient.createVMSnapshot(cmd).__dict__) + + @classmethod + def list(cls, apiclient, **kwargs): + cmd = listVMSnapshot.listVMSnapshotCmd() + [setattr(cmd, k, v) for k, v in kwargs.items()] + return(apiclient.listVMSnapshot(cmd)) + + @classmethod + def revertToSnapshot(cls, apiclient,vmsnapshotid): + cmd = revertToVMSnapshot.revertToVMSnapshotCmd() + cmd.vmsnapshotid = vmsnapshotid + + return apiclient.revertToVMSnapshot(cmd) + + @classmethod + def deleteVMSnapshot(cls,apiclient,vmsnapshotid): + cmd = deleteVMSnapshot.deleteVMSnapshotCmd() + cmd.vmsnapshotid = vmsnapshotid + + return apiclient.deleteVMSnapshot(cmd) diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js index ab9d606b2b6..e5d7d14569b 100644 --- a/ui/scripts/instances.js +++ b/ui/scripts/instances.js @@ -1247,9 +1247,9 @@ dataType: "json", async: true, success: function(json) { - var jid = json.scalevirtualmachineresponse.jobid; - args.response.success( - {_custom: + // var jid = json.scalevirtualmachineresponse.jobid; + args.response.success(); + /* {_custom: {jobId: jid, getUpdatedItem: function(json) { return json.queryasyncjobresultresponse.jobresult.virtualmachine; @@ -1258,8 +1258,8 @@ return vmActionfilter; } } - } - ); + } */ + }, error:function(json){ args.response.error(parseXMLHttpResponse(json)); @@ -1618,7 +1618,16 @@ } ], dataProvider: function(args) { - args.response.success({data: args.context.instances[0].securitygroup}); + // args.response.success({data: args.context.instances[0].securitygroup}); + $.ajax({ + url:createURL("listVirtualMachines&details=secgrp&id=" + args.context.instances[0].id), + dataType: "json", + async:true, + success:function(json) { + args.response.success({data: json.listvirtualmachinesresponse.virtualmachine[0].securitygroup}); + } + + }); } }, @@ -1634,15 +1643,22 @@ networkkbswrite: { label: 'label.network.write' } }, dataProvider: function(args) { - var jsonObj = args.context.instances[0]; - args.response.success({ + $.ajax({ + url:createURL("listVirtualMachines&details=stats&id=" + args.context.instances[0].id), + dataType: "json", + async:true, + success:function(json) { + var jsonObj = json.listvirtualmachinesresponse.virtualmachine[0]; + args.response.success({ data: { totalCPU: jsonObj.cpunumber + " x " + cloudStack.converters.convertHz(jsonObj.cpuspeed), cpuused: jsonObj.cpuused, networkkbsread: (jsonObj.networkkbsread == null)? "N/A": cloudStack.converters.convertBytes(jsonObj.networkkbsread * 1024), networkkbswrite: (jsonObj.networkkbswrite == null)? "N/A": cloudStack.converters.convertBytes(jsonObj.networkkbswrite * 1024) - } - }); + } + }); + } + }); } } } diff --git a/ui/scripts/storage.js b/ui/scripts/storage.js index d73974a89f5..e81633466bc 100644 --- a/ui/scripts/storage.js +++ b/ui/scripts/storage.js @@ -1612,7 +1612,7 @@ if(jsonObj.hypervisor != "Ovm" && jsonObj.state == "Ready") { allowedActions.push("takeSnapshot"); allowedActions.push("recurringSnapshot"); - if((jsonObj.hypervisor == "XenServer" || jsonObj.hypervisor == "KVM" || jsonObj.hypervisor == "VMware") && jsonObj.type == "DATADISK") { + if(jsonObj.type == "DATADISK") { allowedActions.push("resize"); } } diff --git a/ui/scripts/system.js b/ui/scripts/system.js index b02b0abd8ba..c3ac694dff3 100644 --- a/ui/scripts/system.js +++ b/ui/scripts/system.js @@ -4928,8 +4928,11 @@ async: true, success: function(json) { args.response.success({data:{}}); - } - }); + }, + error:function(json){ + args.response.error(parseXMLHttpResponse(json)); + } + }); }, notification: { poll: function(args) { args.complete(); } @@ -5418,9 +5421,9 @@ dataType: "json", async: true, success: function(json) { - var jid = json.scalevirtualmachineresponse.jobid; - args.response.success( - {_custom: + // var jid = json.scalevirtualmachineresponse.jobid; + args.response.success(); + /* {_custom: {jobId: jid, getUpdatedItem: function(json) { return json.queryasyncjobresultresponse.jobresult.virtualmachine; @@ -5430,8 +5433,8 @@ } } - } - ); + } */ + }, error:function(json){ args.response.error(parseXMLHttpResponse(json)); @@ -6302,9 +6305,9 @@ dataType: "json", async: true, success: function(json) { - var jid = json.scalevirtualmachineresponse.jobid; - args.response.success( - {_custom: + // var jid = json.scalevirtualmachineresponse.jobid; + args.response.success(); + /* {_custom: {jobId: jid, getUpdatedItem: function(json) { return json.queryasyncjobresultresponse.jobresult.virtualmachine; @@ -6313,8 +6316,8 @@ return vmActionfilter; } } - } - ); + }*/ + }, error:function(json){ args.response.error(parseXMLHttpResponse(json)); @@ -10822,20 +10825,50 @@ // Granular settings for storage pool settings: { - title: 'label.menu.global.settings', + title: 'Settings', custom: cloudStack.uiCustom.granularSettings({ dataProvider: function(args) { - args.response.success({ - data: [ - { name: 'config.param.1', value: 1 }, - { name: 'config.param.2', value: 2 } - ] - }); + + $.ajax({ + url:createURL('listConfigurations&storageid=' + args.context.primarystorages[0].id), + data: { page: args.page, pageSize: pageSize, listAll: true }, + success:function(json){ + args.response.success({ + data:json.listconfigurationsresponse.configuration + + }); + + }, + + error:function(json){ + args.response.error(parseXMLHttpResponse(json)); + + } + }); + }, actions: { edit: function(args) { // call updateStorageLevelParameters - args.response.success(); + var data = { + name: args.data.jsonObj.name, + value: args.data.value + }; + + $.ajax({ + url:createURL('updateConfiguration&storageid=' + args.context.primarystorages[0].id), + data:data, + success:function(json){ + var item = json.updateconfigurationresponse.configuration; + args.response.success({data:item}); + }, + + error: function(json) { + args.response.error(parseXMLHttpResponse(json)); + } + + }); + } } }) diff --git a/ui/scripts/ui/widgets/listView.js b/ui/scripts/ui/widgets/listView.js index f368951f256..0d5ef6fc751 100644 --- a/ui/scripts/ui/widgets/listView.js +++ b/ui/scripts/ui/widgets/listView.js @@ -1687,6 +1687,9 @@ return false; }); + var tableHeight = $table.height(); + var endTable = false; + // Infinite scrolling event $listView.bind('scroll', function(event) { if (args.listView && args.listView.disableInfiniteScrolling) return false; @@ -1697,7 +1700,7 @@ var loadMoreData = $listView.scrollTop() >= ($table.height() - $listView.height()) - $listView.height() / 4; var context = $listView.data('view-args').context; - if (loadMoreData) { + if (loadMoreData && !endTable) { page = page + 1; var filterBy = { @@ -1725,6 +1728,7 @@ reorder: listViewData.reorder, detailView: listViewData.detailView }); + $table.height() == tableHeight ? endTable = true : tableHeight = $table.height(); } }, 500); diff --git a/ui/scripts/vm_snapshots.js b/ui/scripts/vm_snapshots.js index 0d6305bfbe4..190bf7521f3 100644 --- a/ui/scripts/vm_snapshots.js +++ b/ui/scripts/vm_snapshots.js @@ -170,7 +170,7 @@ }, action: function(args) { $.ajax({ - url: createURL("revertToSnapshot&vmsnapshotid=" + args.context.vmsnapshots[0].id), + url: createURL("revertToVMSnapshot&vmsnapshotid=" + args.context.vmsnapshots[0].id), dataType: "json", async: true, success: function(json) { diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java index e69a3d26c56..87c79096d60 100644 --- a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java @@ -528,7 +528,7 @@ public class VmwareClient { PropertySpec pSpec = new PropertySpec(); pSpec.setType(type); pSpec.setAll(false); - pSpec.getPathSet().add(name); + pSpec.getPathSet().add("name"); ObjectSpec oSpec = new ObjectSpec(); oSpec.setObj(root);