Merge branch 'master' into planner_reserve

Conflicts:
	api/src/com/cloud/event/EventTypes.java
	server/src/com/cloud/capacity/CapacityManagerImpl.java
	server/src/com/cloud/server/ManagementServerImpl.java
	server/test/org/apache/cloudstack/networkoffering/ChildTestConfiguration.java
	server/test/resources/affinityContext.xml
	setup/db/db/schema-410to420.sql
This commit is contained in:
Prachi Damle 2013-05-08 17:02:35 -07:00
commit fb18223933
983 changed files with 6712 additions and 6264 deletions

6
.gitignore vendored
View File

@ -18,10 +18,7 @@
build/replace.properties
build/build.number
bin/
cloudstack-proprietary/
premium/
.lock-wscript
artifacts/
.waf-*
waf-*
target/
@ -37,7 +34,7 @@ cloud-*.tar.bz2
*.egg-info/
*.prefs
build.number
api.log.*.gz
*.log.*.gz
cloud.log.*.*
unittest
deps/cloud.userlibraries
@ -59,6 +56,7 @@ tools/cli/build/
*.iso
*.tar.gz
*.tgz
.*
target-eclipse
awsapi/modules/*
!.gitignore

View File

@ -50,7 +50,8 @@ public interface AsyncJob extends Identity, InternalIdentity {
AutoScaleVmProfile,
AutoScaleVmGroup,
GlobalLoadBalancerRule,
AffinityGroup
AffinityGroup,
DedicatedGuestVlanRange
}
long getUserId();

View File

@ -391,6 +391,9 @@ public class EventTypes {
public static final String EVENT_VM_AFFINITY_GROUP_UPDATE = "VM.AG.UPDATE";
public static final String EVENT_HOST_RESERVATION_RELEASE = "HOST.RESERVATION.RELEASE";
// 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 {
@ -692,7 +695,8 @@ 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) {

View File

@ -14,18 +14,18 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.vm;
package com.cloud.network;
import com.cloud.storage.Storage;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
/**
* VirtualDisk describes the disks that are plugged into
* the virtual machine.
*
*/
public class VirtualDisk {
public Storage.ImageFormat format;
public String url;
public boolean bootable;
public long size;
public interface GuestVlan extends InternalIdentity, Identity {
public long getId();
public long getAccountId();
public String getGuestVlanRange();
public long getPhysicalNetworkId();
}

View File

@ -263,4 +263,6 @@ public interface NetworkModel {
boolean isProviderEnabledInZone(long zoneId, String provider);
Nic getPlaceholderNicForRouter(Network network, Long podId);
Networks.IsolationType[] listNetworkIsolationMethods();
}

View File

@ -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<List<? extends GuestVlan>, Integer> listDedicatedGuestVlanRanges(ListDedicatedGuestVlanRangesCmd cmd);
boolean releaseDedicatedGuestVlanRange(Long dedicatedGuestVlanRangeId);
Pair<List<? extends PhysicalNetworkTrafficType>, Integer> listTrafficTypes(Long physicalNetworkId);

View File

@ -31,6 +31,8 @@ public interface SecurityGroupRules extends InternalIdentity {
Long getRuleId();
String getRuleUuid();
int getStartPort();
int getEndPort();

View File

@ -19,8 +19,6 @@ package com.cloud.storage;
import java.net.URI;
import java.util.Map;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import com.cloud.exception.DiscoveryException;
import com.cloud.utils.component.Adapter;
@ -29,7 +27,7 @@ import com.cloud.utils.component.Adapter;
*/
public interface StoragePoolDiscoverer extends Adapter {
Map<StoragePoolVO, Map<String, String>> find(long dcId, Long podId, URI uri, Map<String, String> details) throws DiscoveryException;
Map<StoragePoolVO, Map<String, String>> find(long dcId, Long podId, URI uri, Map<String, String> details, String username, String password) throws DiscoveryException;
Map<? extends StoragePool, Map<String, String>> find(long dcId, Long podId, URI uri, Map<String, String> details) throws DiscoveryException;
Map<? extends StoragePool, Map<String, String>> find(long dcId, Long podId, URI uri, Map<String, String> details, String username, String password) throws DiscoveryException;
}

View File

@ -16,12 +16,12 @@
// under the License.
package com.cloud.storage.snapshot;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
import java.util.Date;
public interface SnapshotSchedule {
long getId();
String getUuid();
public interface SnapshotSchedule extends InternalIdentity, Identity {
Long getVolumeId();
@ -38,10 +38,9 @@ public interface SnapshotSchedule {
Long getAsyncJobId();
void setAsyncJobId(long asyncJobId);
void setAsyncJobId(Long asyncJobId);
Long getSnapshotId();
void setSnapshotId(Long snapshotId);
}

View File

@ -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";

View File

@ -42,6 +42,7 @@ import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.NetworkModel;
import com.cloud.network.NetworkService;
import com.cloud.network.NetworkUsageService;
import com.cloud.network.StorageNetworkService;
@ -139,6 +140,7 @@ public abstract class BaseCmd {
@Inject public DataStoreProviderApiService dataStoreProviderApiService;
@Inject public VpcProvisioningService _vpcProvSvc;
@Inject public AffinityGroupService _affinityGroupService;
@Inject public NetworkModel _ntwkModel;
public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException;

View File

@ -50,6 +50,7 @@ import org.apache.cloudstack.api.response.HypervisorCapabilitiesResponse;
import org.apache.cloudstack.api.response.IPAddressResponse;
import org.apache.cloudstack.api.response.InstanceGroupResponse;
import org.apache.cloudstack.api.response.IpForwardingRuleResponse;
import org.apache.cloudstack.api.response.IsolationMethodResponse;
import org.apache.cloudstack.api.response.LBHealthCheckResponse;
import org.apache.cloudstack.api.response.LBStickinessResponse;
import org.apache.cloudstack.api.response.LDAPConfigResponse;
@ -120,6 +121,7 @@ import com.cloud.host.Host;
import com.cloud.hypervisor.HypervisorCapabilities;
import com.cloud.network.*;
import com.cloud.network.Network.Service;
import com.cloud.network.Networks.IsolationType;
import com.cloud.network.as.*;
import com.cloud.network.router.VirtualRouter;
import com.cloud.network.rules.FirewallRule;
@ -198,6 +200,8 @@ public interface ResponseGenerator {
IPAddressResponse createIPAddressResponse(IpAddress ipAddress);
GuestVlanRangeResponse createDedicatedGuestVlanRangeResponse(GuestVlan result);
GlobalLoadBalancerResponse createGlobalLoadBalancerResponse(GlobalLoadBalancerRule globalLoadBalancerRule);
LoadBalancerResponse createLoadBalancerResponse(LoadBalancer loadBalancer);
@ -396,4 +400,6 @@ public interface ResponseGenerator {
AffinityGroupResponse createAffinityGroupResponse(AffinityGroup group);
Long getAffinityGroupId(String name, long entityOwnerId);
IsolationMethodResponse createIsolationMethodResponse(IsolationType method);
}

View File

@ -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");
}
}
}

View File

@ -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<List<? extends GuestVlan>, Integer> vlans = _networkService.listDedicatedGuestVlanRanges(this);
ListResponse<GuestVlanRangeResponse> response = new ListResponse<GuestVlanRangeResponse>();
List<GuestVlanRangeResponse> guestVlanResponses = new ArrayList<GuestVlanRangeResponse>();
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);
}
}

View File

@ -0,0 +1,58 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.api.command.admin.network;
import java.util.ArrayList;
import java.util.List;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.response.IsolationMethodResponse;
import org.apache.cloudstack.api.response.ListResponse;
import com.cloud.network.Networks;
@APICommand(name = "listNetworkIsolationMethods", description="Lists supported methods of network isolation",
responseObject=IsolationMethodResponse.class, since="4.2.0")
public class ListNetworkIsolationMethodsCmd extends BaseListCmd{
private static final String s_name = "listnetworkisolationmethodsresponse";
@Override
public void execute() {
Networks.IsolationType[] methods = _ntwkModel.listNetworkIsolationMethods();
ListResponse<IsolationMethodResponse> response = new ListResponse<IsolationMethodResponse>();
List<IsolationMethodResponse> isolationResponses = new ArrayList<IsolationMethodResponse>();
if (methods != null) {
for (Networks.IsolationType method : methods) {
IsolationMethodResponse isolationMethod = _responseGenerator.createIsolationMethodResponse(method);
isolationResponses.add(isolationMethod);
}
}
response.setResponses(isolationResponses, methods.length);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
@Override
public String getCommandName() {
return s_name;
}
}

View File

@ -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");
}
}
}

View File

@ -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;
}
}

View File

@ -14,21 +14,20 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.maint;
package org.apache.cloudstack.api.response;
/**
* has been released.
*
*/
public class UpgradeMonitor implements Runnable {
private String _url;
private long _period;
public UpgradeMonitor(String url, long period) {
_url = url;
}
public void run() {
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
@SuppressWarnings("unused")
public class IsolationMethodResponse extends BaseResponse{
@SerializedName(ApiConstants.NAME) @Param(description="Network isolation method name")
private String name;
public void setIsolationMethodName(String isolationMethodName) {
this.name = isolationMethodName;
}
}

View File

@ -286,12 +286,6 @@
</dependency>
</dependencies>
<build>
<defaultGoal>install</defaultGoal>
<sourceDirectory>src</sourceDirectory>
<!-- Tests still depend on hibernate,
so thats not going to work
<testSourceDirectory>test</testSourceDirectory>
-->
<resources>
<resource>
<directory>src</directory>
@ -307,6 +301,17 @@
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>com/cloud/gate/util/UtilTestCase.java</exclude>
<exclude>com/cloud/gate/service/ServiceTestCase.java</exclude>
<exclude>com/cloud/gate/util/CloudStackClientTestCase.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
@ -364,22 +369,6 @@
</executions>
</plugin>
</plugins>
<!--
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
-->
<pluginManagement>
<plugins>
<plugin>

View File

@ -1,368 +0,0 @@
// 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.gate.model;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import org.apache.log4j.Logger;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.junit.Assert;
import com.cloud.bridge.model.MHost;
import com.cloud.bridge.model.MHostMount;
import com.cloud.bridge.model.SBucket;
import com.cloud.bridge.model.SHost;
import com.cloud.bridge.model.SMeta;
import com.cloud.bridge.model.SObject;
import com.cloud.bridge.util.CloudSessionFactory;
import com.cloud.bridge.util.QueryHelper;
import com.cloud.gate.testcase.BaseTestCase;
public class ModelTestCase extends BaseTestCase {
protected final static Logger logger = Logger.getLogger(ModelTestCase.class);
public void testSHost() {
SHost host;
// create the record
Session session = CloudSessionFactory.getInstance().openSession();
try {
Transaction txn = session.beginTransaction();
host = new SHost();
host.setHost("localhost");
host.setExportRoot("/");
host.setUserOnHost("root");
host.setUserPassword("password");
session.saveOrUpdate(host);
txn.commit();
} finally {
session.close();
}
Assert.assertTrue(host.getId() != 0);
// retrive the record
session = CloudSessionFactory.getInstance().openSession();
try {
Transaction txn = session.beginTransaction();
host = (SHost)session.get(SHost.class, (long)host.getId());
txn.commit();
Assert.assertTrue(host.getHost().equals("localhost"));
Assert.assertTrue(host.getUserOnHost().equals("root"));
Assert.assertTrue(host.getUserPassword().equals("password"));
logger.info("Retrived record, host:" + host.getHost()
+ ", user: " + host.getUserOnHost()
+ ", password: " + host.getUserPassword());
} finally {
session.close();
}
// delete the record
session = CloudSessionFactory.getInstance().openSession();
try {
Transaction txn = session.beginTransaction();
host = (SHost)session.get(SHost.class, (long)host.getId());
session.delete(host);
txn.commit();
} finally {
session.close();
}
session = CloudSessionFactory.getInstance().openSession();
try {
Transaction txn = session.beginTransaction();
host = (SHost)session.get(SHost.class, (long)host.getId());
txn.commit();
Assert.assertTrue(host == null);
} finally {
session.close();
}
}
public void testSBucket() {
SHost host;
SBucket bucket;
Session session;
session = CloudSessionFactory.getInstance().openSession();
try {
Transaction txn = session.beginTransaction();
host = new SHost();
host.setHost("localhost");
host.setUserOnHost("root");
host.setUserPassword("password");
host.setExportRoot("/");
bucket = new SBucket();
bucket.setName("Bucket");
bucket.setOwnerCanonicalId("OwnerId-dummy");
bucket.setCreateTime(new Date());
host.getBuckets().add(bucket);
bucket.setShost(host);
session.save(host);
session.save(bucket);
txn.commit();
} finally {
session.close();
}
long bucketId = bucket.getId();
// load bucket
session = CloudSessionFactory.getInstance().openSession();
try {
Transaction txn = session.beginTransaction();
bucket = (SBucket)session.get(SBucket.class, bucketId);
txn.commit();
Assert.assertTrue(bucket.getShost().getHost().equals("localhost"));
Assert.assertTrue(bucket.getName().equals("Bucket"));
Assert.assertTrue(bucket.getOwnerCanonicalId().equals("OwnerId-dummy"));
} finally {
session.close();
}
// delete the bucket
session = CloudSessionFactory.getInstance().openSession();
try {
Transaction txn = session.beginTransaction();
bucket = (SBucket)session.get(SBucket.class, bucketId);
session.delete(bucket);
host = (SHost)session.get(SHost.class, host.getId());
session.delete(host);
txn.commit();
} finally {
session.close();
}
// verify the deletion
session = CloudSessionFactory.getInstance().openSession();
try {
Transaction txn = session.beginTransaction();
bucket = (SBucket)session.get(SBucket.class, bucketId);
txn.commit();
Assert.assertTrue(bucket == null);
} finally {
session.close();
}
}
public void testSObject() {
SHost host;
SBucket bucket;
Session session;
SObject sobject;
// setup
session = CloudSessionFactory.getInstance().openSession();
try {
Transaction txn = session.beginTransaction();
host = new SHost();
host.setHost("localhost");
host.setUserOnHost("root");
host.setUserPassword("password");
host.setExportRoot("/");
bucket = new SBucket();
bucket.setName("Bucket");
bucket.setOwnerCanonicalId("OwnerId-dummy");
bucket.setCreateTime(new Date());
bucket.setShost(host);
host.getBuckets().add(bucket);
sobject = new SObject();
sobject.setNameKey("ObjectNameKey");
sobject.setOwnerCanonicalId("OwnerId-dummy");
sobject.setCreateTime(new Date());
sobject.setBucket(bucket);
bucket.getObjectsInBucket().add(sobject);
session.save(host);
session.save(bucket);
session.save(sobject);
txn.commit();
} finally {
session.close();
}
session = CloudSessionFactory.getInstance().openSession();
try {
Transaction txn = session.beginTransaction();
sobject = (SObject)session.get(SObject.class, sobject.getId());
txn.commit();
Assert.assertTrue(sobject.getBucket().getName().equals("Bucket"));
Assert.assertTrue(sobject.getNameKey().equals("ObjectNameKey"));
Assert.assertTrue(sobject.getOwnerCanonicalId().equals("OwnerId-dummy"));
} finally {
session.close();
}
// test delete cascade
session = CloudSessionFactory.getInstance().openSession();
try {
Transaction txn = session.beginTransaction();
bucket = (SBucket)session.get(SBucket.class, bucket.getId());
session.delete(bucket);
host = (SHost)session.get(SHost.class, host.getId());
session.delete(host);
txn.commit();
} finally {
session.close();
}
}
public void testMeta() {
Session session;
session = CloudSessionFactory.getInstance().openSession();
try {
Transaction txn = session.beginTransaction();
SMeta meta = new SMeta();
meta.setTarget("SObject");
meta.setTargetId(1);
meta.setName("param1");
meta.setValue("value1");
session.save(meta);
logger.info("Meta 1: " + meta.getId());
meta = new SMeta();
meta.setTarget("SObject");
meta.setTargetId(1);
meta.setName("param2");
meta.setValue("value2");
session.save(meta);
logger.info("Meta 2: " + meta.getId());
txn.commit();
} finally {
session.close();
}
session = CloudSessionFactory.getInstance().openSession();
try {
Transaction txn = session.beginTransaction();
Query query = session.createQuery("from SMeta where target=? and targetId=?");
QueryHelper.bindParameters(query, new Object[] {
"SObject", new Long(1)
});
List<SMeta> l = QueryHelper.executeQuery(query);
txn.commit();
for(SMeta meta: l) {
logger.info("" + meta.getName() + "=" + meta.getValue());
}
} finally {
session.close();
}
session = CloudSessionFactory.getInstance().openSession();
try {
Transaction txn = session.beginTransaction();
Query query = session.createQuery("delete from SMeta where target=?");
QueryHelper.bindParameters(query, new Object[] {"SObject"});
query.executeUpdate();
txn.commit();
} finally {
session.close();
}
}
public void testHosts() {
Session session;
SHost shost;
MHost mhost;
MHostMount hostMount;
session = CloudSessionFactory.getInstance().openSession();
try {
Transaction txn = session.beginTransaction();
shost = new SHost();
shost.setHost("Storage host1");
shost.setUserOnHost("root");
shost.setUserPassword("password");
shost.setExportRoot("/");
session.save(shost);
mhost = new MHost();
mhost.setHostKey("1");
mhost.setHost("management host1");
mhost.setVersion("v1");
session.save(mhost);
hostMount = new MHostMount();
hostMount.setMhost(mhost);
hostMount.setShost(shost);
hostMount.setMountPath("/mnt");
session.save(hostMount);
txn.commit();
} finally {
session.close();
}
session = CloudSessionFactory.getInstance().openSession();
try {
Transaction txn = session.beginTransaction();
mhost = (MHost)session.createQuery("from MHost where hostKey=?").
setLong(0, new Long(1)).uniqueResult();
if(mhost != null) {
Iterator it = mhost.getMounts().iterator();
while(it.hasNext()) {
MHostMount mount = (MHostMount)it.next();
Assert.assertTrue(mount.getMountPath().equals("/mnt"));
logger.info(mount.getMountPath());
}
}
txn.commit();
} finally {
session.close();
}
session = CloudSessionFactory.getInstance().openSession();
try {
Transaction txn = session.beginTransaction();
mhost = (MHost)session.createQuery("from MHost where hostKey=?").
setLong(0, new Long(1)).uniqueResult();
if(mhost != null)
session.delete(mhost);
shost = (SHost)session.createQuery("from SHost where host=?").
setString(0, "Storage host1").uniqueResult();
if(shost != null)
session.delete(shost);
txn.commit();
} finally {
session.close();
}
}
}

View File

@ -1,73 +0,0 @@
// 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.gate.persist;
import org.apache.log4j.Logger;
import com.cloud.bridge.persist.PersistContext;
import com.cloud.gate.testcase.BaseTestCase;
public class PersitTestCase extends BaseTestCase {
protected final static Logger logger = Logger.getLogger(PersitTestCase.class);
public void testNamedLock() {
Thread t1 = new Thread(new Runnable() {
public void run() {
for(int i = 0; i < 10; i++) {
if(PersistContext.acquireNamedLock("TestLock", 3)) {
logger.info("Thread 1 acquired lock");
try {
Thread.currentThread().sleep(BaseTestCase.getRandomMilliseconds(5000, 10000));
} catch (InterruptedException e) {
}
logger.info("Thread 1 to release lock");
PersistContext.releaseNamedLock("TestLock");
} else {
logger.info("Thread 1 is unable to acquire lock");
}
}
}
});
Thread t2 = new Thread(new Runnable() {
public void run() {
for(int i = 0; i < 10; i++) {
if(PersistContext.acquireNamedLock("TestLock", 3)) {
logger.info("Thread 2 acquired lock");
try {
Thread.currentThread().sleep(BaseTestCase.getRandomMilliseconds(1000, 5000));
} catch (InterruptedException e) {
}
logger.info("Thread 2 to release lock");
PersistContext.releaseNamedLock("TestLock");
} else {
logger.info("Thread 2 is unable to acquire lock");
}
}
}
});
t1.start();
t2.start();
try {
t1.join();
t2.join();
} catch(InterruptedException e) {
}
}
}

View File

@ -239,6 +239,11 @@
<artifactId>cloud-plugin-host-anti-affinity</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-console-proxy</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<defaultGoal>install</defaultGoal>

View File

@ -165,8 +165,8 @@
<bean id="accountDaoImpl" class="com.cloud.user.dao.AccountDaoImpl" />
<bean id="accountDetailsDaoImpl" class="com.cloud.user.AccountDetailsDaoImpl" />
<bean id="accountJoinDaoImpl" class="com.cloud.api.query.dao.AccountJoinDaoImpl" />
<bean id="accountGuestVlanMapDaoImpl" class="com.cloud.network.dao.AccountGuestVlanMapDaoImpl" />
<bean id="accountVlanMapDaoImpl" class="com.cloud.dc.dao.AccountVlanMapDaoImpl" />
<bean id="agentUpgradeDaoImpl" class="com.cloud.maint.dao.AgentUpgradeDaoImpl" />
<bean id="alertDaoImpl" class="com.cloud.alert.dao.AlertDaoImpl" />
<bean id="asyncJobDaoImpl" class="com.cloud.async.dao.AsyncJobDaoImpl" />
<bean id="asyncJobJoinDaoImpl" class="com.cloud.api.query.dao.AsyncJobJoinDaoImpl" />
@ -302,7 +302,6 @@
<bean id="snapshotDaoImpl" class="com.cloud.storage.dao.SnapshotDaoImpl" />
<bean id="snapshotPolicyDaoImpl" class="com.cloud.storage.dao.SnapshotPolicyDaoImpl" />
<bean id="snapshotScheduleDaoImpl" class="com.cloud.storage.dao.SnapshotScheduleDaoImpl" />
<bean id="stackMaidDaoImpl" class="com.cloud.cluster.dao.StackMaidDaoImpl" />
<bean id="staticRouteDaoImpl" class="com.cloud.network.vpc.dao.StaticRouteDaoImpl" />
<bean id="storageNetworkIpAddressDaoImpl" class="com.cloud.dc.dao.StorageNetworkIpAddressDaoImpl" />
<bean id="storageNetworkIpRangeDaoImpl" class="com.cloud.dc.dao.StorageNetworkIpRangeDaoImpl" />
@ -695,7 +694,6 @@
<bean id="syncQueueManagerImpl" class="com.cloud.async.SyncQueueManagerImpl" />
<bean id="taggedResourceManagerImpl" class="com.cloud.tags.TaggedResourceManagerImpl" />
<bean id="templateManagerImpl" class="com.cloud.template.TemplateManagerImpl" />
<bean id="upgradeManagerImpl" class="com.cloud.maint.UpgradeManagerImpl" />
<bean id="uploadMonitorImpl" class="com.cloud.storage.upload.UploadMonitorImpl" />
<bean id="usageServiceImpl" class="com.cloud.usage.UsageServiceImpl" />
<bean id="virtualNetworkApplianceManagerImpl" class="com.cloud.network.router.VirtualNetworkApplianceManagerImpl" />

View File

@ -127,6 +127,9 @@ deleteVlanIpRange=1
listVlanIpRanges=1
dedicatePublicIpRange=1
releasePublicIpRange=1
dedicateGuestVlanRange=1
releaseDedicatedGuestVlanRange=1
listDedicatedGuestVlanRanges=1
#### address commands
associateIpAddress=15
@ -593,3 +596,5 @@ addCiscoAsa1000vResource=1
deleteCiscoAsa1000vResource=1
listCiscoAsa1000vResources=1
### Network Isolation methods listing
listNetworkIsolationMethods=1

View File

@ -36,6 +36,11 @@
<artifactId>cloud-engine-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-engine-schema</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
@ -55,7 +60,5 @@
</dependencies>
<build>
<defaultGoal>install</defaultGoal>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
</build>
</project>

View File

@ -1,31 +0,0 @@
// 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.agent;
import com.cloud.agent.api.Command;
public interface RecoveryHandler {
/**
* Perform the necessary recovery because the success of this command
* is not known.
*
* @param agentId agent the commands were sent to.
* @param seq sequence number.
* @param cmds commands that failed.
*/
public void handle(long agentId, long seq, Command[] cmds);
}

View File

@ -22,17 +22,17 @@ import com.cloud.agent.api.to.SwiftTO;
/**
* This currently assumes that both primary and secondary storage are mounted on the XenServer.
*/
public class downloadSnapshotFromSwiftCommand extends SnapshotCommand {
public class DownloadSnapshotFromSwiftCommand extends SnapshotCommand {
@LogLevel(Log4jLevel.Off)
private SwiftTO _swift;
private String _parent;
protected downloadSnapshotFromSwiftCommand() {
protected DownloadSnapshotFromSwiftCommand() {
}
public downloadSnapshotFromSwiftCommand(SwiftTO swift, String secondaryStorageUrl, Long dcId, Long accountId, Long volumeId, String parent, String BackupUuid, int wait) {
public DownloadSnapshotFromSwiftCommand(SwiftTO swift, String secondaryStorageUrl, Long dcId, Long accountId, Long volumeId, String parent, String BackupUuid, int wait) {
super(null, secondaryStorageUrl, BackupUuid, "", dcId, accountId, volumeId);
setParent(parent);

View File

@ -24,7 +24,7 @@ import com.cloud.agent.api.to.SwiftTO;
*
*/
public class downloadTemplateFromSwiftToSecondaryStorageCommand extends Command {
public class DownloadTemplateFromSwiftToSecondaryStorageCommand extends Command {
@LogLevel(Log4jLevel.Off)
private SwiftTO swift;
private String secondaryStorageUrl;
@ -34,11 +34,11 @@ public class downloadTemplateFromSwiftToSecondaryStorageCommand extends Command
private Long templateId;
private String path;
protected downloadTemplateFromSwiftToSecondaryStorageCommand() {
protected DownloadTemplateFromSwiftToSecondaryStorageCommand() {
}
public downloadTemplateFromSwiftToSecondaryStorageCommand(SwiftTO swift, String secondaryStorageUrl, Long dcId, Long accountId, Long templateId, String path, int wait) {
public DownloadTemplateFromSwiftToSecondaryStorageCommand(SwiftTO swift, String secondaryStorageUrl, Long dcId, Long accountId, Long templateId, String path, int wait) {
this.swift = swift;
this.secondaryStorageUrl = secondaryStorageUrl;

Some files were not shown because too many files have changed in this diff Show More