mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
merged from master
This commit is contained in:
commit
d6f44a4d6a
@ -31,7 +31,7 @@ import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
@APICommand(description="Creates a private network", responseObject=NetworkResponse.class)
|
||||
//@APICommand(description="Creates a private network", responseObject=NetworkResponse.class)
|
||||
public class CreatePrivateNetworkCmd extends BaseAsyncCreateCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(CreatePrivateNetworkCmd.class.getName());
|
||||
|
||||
@ -153,6 +153,7 @@ public class CreatePrivateNetworkCmd extends BaseAsyncCreateCmd {
|
||||
|
||||
if (result != null) {
|
||||
this.setEntityId(result.getId());
|
||||
this.setEntityUuid(result.getUuid());
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create a Private network");
|
||||
}
|
||||
@ -190,8 +191,4 @@ public class CreatePrivateNetworkCmd extends BaseAsyncCreateCmd {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEntityTable() {
|
||||
return "networks";
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ import com.cloud.event.EventTypes;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
@APICommand(description="Destroys console proxy", responseObject=SuccessResponse.class)
|
||||
//@APICommand(description="Destroys console proxy", responseObject=SuccessResponse.class)
|
||||
public class DestroyConsoleProxyCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(DestroyConsoleProxyCmd.class.getName());
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.SnapshotScheduleResponse;
|
||||
import com.cloud.storage.snapshot.SnapshotSchedule;
|
||||
|
||||
@APICommand(description="Lists recurring snapshot schedule", responseObject=SnapshotScheduleResponse.class)
|
||||
//@APICommand(description="Lists recurring snapshot schedule", responseObject=SnapshotScheduleResponse.class)
|
||||
public class ListRecurringSnapshotScheduleCmd extends BaseListCmd {
|
||||
private static final String s_name = "listrecurringsnapshotscheduleresponse";
|
||||
|
||||
|
||||
@ -16,10 +16,8 @@
|
||||
// under the License.
|
||||
package com.cloud.exception;
|
||||
|
||||
import com.cloud.utils.IdentityProxy;
|
||||
import java.util.ArrayList;
|
||||
import com.cloud.utils.exception.CSExceptionErrorCode;
|
||||
import com.cloud.utils.AnnotationHelper;
|
||||
|
||||
/**
|
||||
* by the API response serializer. Any exceptions that are thrown by
|
||||
@ -56,6 +54,7 @@ public class CloudException extends Exception {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
public ArrayList<String> getIdProxyList() {
|
||||
return idList;
|
||||
}
|
||||
|
||||
@ -16,11 +16,8 @@
|
||||
// under the License.
|
||||
package org.apache.cloudstack.acl;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.utils.component.Adapter;
|
||||
|
||||
/**
|
||||
@ -28,5 +25,5 @@ import com.cloud.utils.component.Adapter;
|
||||
*/
|
||||
public interface APIAccessChecker extends Adapter {
|
||||
// Interface for checking access to an API for an user
|
||||
boolean canAccessAPI(User user, String apiCommandName) throws PermissionDeniedException;
|
||||
boolean canAccessAPI(RoleType roleType, String apiCommandName) throws PermissionDeniedException;
|
||||
}
|
||||
|
||||
@ -25,6 +25,8 @@ public abstract class BaseAsyncCreateCmd extends BaseAsyncCmd {
|
||||
@Parameter(name = "id", type = CommandType.LONG)
|
||||
private Long id;
|
||||
|
||||
private String uuid;
|
||||
|
||||
public abstract void create() throws ResourceAllocationException;
|
||||
|
||||
public Long getEntityId() {
|
||||
@ -35,14 +37,19 @@ public abstract class BaseAsyncCreateCmd extends BaseAsyncCmd {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public abstract String getEntityTable();
|
||||
public String getEntityUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public String getResponse(long jobId, long objectId, String objectEntityTable) {
|
||||
public void setEntityUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public String getResponse(long jobId, String objectUuid) {
|
||||
CreateCmdResponse response = new CreateCmdResponse();
|
||||
AsyncJob job = _entityMgr.findById(AsyncJob.class, jobId);
|
||||
response.setJobId(job.getUuid());
|
||||
response.setId(objectId);
|
||||
response.setIdEntityTable(objectEntityTable);
|
||||
response.setId(objectUuid);
|
||||
response.setResponseName(getCommandName());
|
||||
return _responseGenerator.toSerializedString(response, getResponseType());
|
||||
}
|
||||
|
||||
@ -17,7 +17,6 @@
|
||||
package org.apache.cloudstack.api;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import com.cloud.utils.IdentityProxy;
|
||||
import org.apache.cloudstack.api.ResponseObject;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
@ -46,6 +45,7 @@ public abstract class BaseResponse implements ResponseObject {
|
||||
this.objectName = objectName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getObjectId() {
|
||||
return null;
|
||||
}
|
||||
@ -56,18 +56,22 @@ public abstract class BaseResponse implements ResponseObject {
|
||||
@SerializedName(ApiConstants.JOB_STATUS) @Param(description="the current status of the latest async job acting on this object")
|
||||
private Integer jobStatus;
|
||||
|
||||
@Override
|
||||
public String getJobId() {
|
||||
return jobId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setJobId(String jobId) {
|
||||
this.jobId = jobId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getJobStatus() {
|
||||
return jobStatus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setJobStatus(Integer jobStatus) {
|
||||
this.jobStatus = jobStatus;
|
||||
}
|
||||
|
||||
@ -81,6 +81,7 @@ public class CreateCounterCmd extends BaseAsyncCreateCmd {
|
||||
|
||||
if (ctr != null) {
|
||||
this.setEntityId(ctr.getId());
|
||||
this.setEntityUuid(ctr.getUuid());
|
||||
CounterResponse response = _responseGenerator.createCounterResponse(ctr);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
@ -113,8 +114,5 @@ public class CreateCounterCmd extends BaseAsyncCreateCmd {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEntityTable() {
|
||||
return "counter";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -59,10 +59,6 @@ public class AddNetworkServiceProviderCmd extends BaseAsyncCreateCmd {
|
||||
@Parameter(name=ApiConstants.SERVICE_LIST, type=CommandType.LIST, collectionType = CommandType.STRING, description="the list of services to be enabled for this physical network service provider")
|
||||
private List<String> enabledServices;
|
||||
|
||||
@Override
|
||||
public String getEntityTable() {
|
||||
return "physical_network_service_providers";
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
@ -116,6 +112,7 @@ public class AddNetworkServiceProviderCmd extends BaseAsyncCreateCmd {
|
||||
PhysicalNetworkServiceProvider result = _networkService.addProviderToPhysicalNetwork(getPhysicalNetworkId(), getProviderName(), getDestinationPhysicalNetworkId(), getEnabledServices());
|
||||
if (result != null) {
|
||||
setEntityId(result.getId());
|
||||
setEntityUuid(result.getUuid());
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add service provider entity to physical network");
|
||||
}
|
||||
|
||||
@ -79,10 +79,6 @@ public class CreatePhysicalNetworkCmd extends BaseAsyncCreateCmd {
|
||||
return tags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEntityTable() {
|
||||
return "physical_network";
|
||||
}
|
||||
|
||||
public Long getZoneId() {
|
||||
return zoneId;
|
||||
@ -164,6 +160,7 @@ public class CreatePhysicalNetworkCmd extends BaseAsyncCreateCmd {
|
||||
PhysicalNetwork result = _networkService.createPhysicalNetwork(getZoneId(),getVlan(),getNetworkSpeed(), getIsolationMethods(),getBroadcastDomainRange(),getDomainId(), getTags(), getNetworkName());
|
||||
if (result != null) {
|
||||
setEntityId(result.getId());
|
||||
setEntityUuid(result.getUuid());
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create physical network entity");
|
||||
}
|
||||
|
||||
@ -53,10 +53,7 @@ public class CreateVirtualRouterElementCmd extends BaseAsyncCreateCmd {
|
||||
this.nspId = nspId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEntityTable() {
|
||||
return "virtual_router_providers";
|
||||
}
|
||||
|
||||
|
||||
public Long getNspId() {
|
||||
return nspId;
|
||||
@ -94,6 +91,7 @@ public class CreateVirtualRouterElementCmd extends BaseAsyncCreateCmd {
|
||||
VirtualRouterProvider result = _service.addElement(getNspId(), VirtualRouterProviderType.VirtualRouter);
|
||||
if (result != null) {
|
||||
setEntityId(result.getId());
|
||||
setEntityUuid(result.getUuid());
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add Virtual Router entity to physical network");
|
||||
}
|
||||
|
||||
@ -66,10 +66,6 @@ public class AddTrafficTypeCmd extends BaseAsyncCreateCmd {
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getEntityTable() {
|
||||
return "physical_network_traffic_types";
|
||||
}
|
||||
|
||||
public Long getPhysicalNetworkId() {
|
||||
return physicalNetworkId;
|
||||
@ -136,6 +132,7 @@ public class AddTrafficTypeCmd extends BaseAsyncCreateCmd {
|
||||
PhysicalNetworkTrafficType result = _networkService.addTrafficTypeToPhysicalNetwork(getPhysicalNetworkId(), getTrafficType(), getXenLabel(), getKvmLabel(), getVmwareLabel(), getSimulatorLabel(), getVlan());
|
||||
if (result != null) {
|
||||
setEntityId(result.getId());
|
||||
setEntityUuid(result.getUuid());
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add traffic type to physical network");
|
||||
}
|
||||
|
||||
@ -123,6 +123,7 @@ public class CreatePrivateGatewayCmd extends BaseAsyncCreateCmd {
|
||||
|
||||
if (result != null) {
|
||||
this.setEntityId(result.getId());
|
||||
this.setEntityUuid(result.getUuid());
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create private gateway");
|
||||
}
|
||||
@ -156,10 +157,6 @@ public class CreatePrivateGatewayCmd extends BaseAsyncCreateCmd {
|
||||
return "creating private gateway";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEntityTable() {
|
||||
return "vpc_gateways";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@ -70,6 +70,7 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd{
|
||||
VpcOffering vpcOff = _vpcService.createVpcOffering(getVpcOfferingName(), getDisplayText(), getSupportedServices());
|
||||
if (vpcOff != null) {
|
||||
this.setEntityId(vpcOff.getId());
|
||||
this.setEntityUuid(vpcOff.getUuid());
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create a VPC offering");
|
||||
}
|
||||
@ -87,10 +88,6 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEntityTable() {
|
||||
return "vpc_offerings";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
|
||||
@ -87,9 +87,6 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "user_ip_address";
|
||||
}
|
||||
|
||||
public String getAccountName() {
|
||||
if (accountName != null) {
|
||||
@ -220,6 +217,7 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
|
||||
|
||||
if (ip != null) {
|
||||
this.setEntityId(ip.getId());
|
||||
this.setEntityUuid(ip.getUuid());
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to allocate ip address");
|
||||
}
|
||||
|
||||
@ -62,10 +62,6 @@ public class CreateAutoScalePolicyCmd extends BaseAsyncCreateCmd {
|
||||
private Long conditionDomainId;
|
||||
private Long conditionAccountId;
|
||||
|
||||
@Override
|
||||
public String getEntityTable() {
|
||||
return "autoscale_policies";
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
return duration;
|
||||
@ -159,6 +155,7 @@ public class CreateAutoScalePolicyCmd extends BaseAsyncCreateCmd {
|
||||
AutoScalePolicy result = _autoScaleService.createAutoScalePolicy(this);
|
||||
if (result != null) {
|
||||
this.setEntityId(result.getId());
|
||||
this.setEntityUuid(result.getUuid());
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create AutoScale Policy");
|
||||
}
|
||||
|
||||
@ -72,10 +72,6 @@ public class CreateAutoScaleVmGroupCmd extends BaseAsyncCreateCmd {
|
||||
// ///////////////// Accessors ///////////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getEntityTable() {
|
||||
return "autoscale_vmgroups";
|
||||
}
|
||||
|
||||
public int getMinMembers() {
|
||||
return minMembers;
|
||||
@ -161,6 +157,7 @@ public class CreateAutoScaleVmGroupCmd extends BaseAsyncCreateCmd {
|
||||
AutoScaleVmGroup result = _autoScaleService.createAutoScaleVmGroup(this);
|
||||
if (result != null) {
|
||||
this.setEntityId(result.getId());
|
||||
this.setEntityUuid(result.getUuid());
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create Autoscale Vm Group");
|
||||
}
|
||||
|
||||
@ -86,10 +86,7 @@ public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd {
|
||||
private Long domainId;
|
||||
private Long accountId;
|
||||
|
||||
@Override
|
||||
public String getEntityTable() {
|
||||
return "autoscale_vmprofiles";
|
||||
}
|
||||
|
||||
|
||||
public Long getDomainId() {
|
||||
if (domainId == null) {
|
||||
@ -232,6 +229,7 @@ public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd {
|
||||
AutoScaleVmProfile result = _autoScaleService.createAutoScaleVmProfile(this);
|
||||
if (result != null) {
|
||||
this.setEntityId(result.getId());
|
||||
this.setEntityUuid(result.getUuid());
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create Autoscale Vm Profile");
|
||||
}
|
||||
|
||||
@ -72,6 +72,7 @@ public class CreateConditionCmd extends BaseAsyncCreateCmd {
|
||||
|
||||
if (condition != null) {
|
||||
this.setEntityId(condition.getId());
|
||||
this.setEntityUuid(condition.getUuid());
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create condition.");
|
||||
}
|
||||
@ -146,8 +147,5 @@ public class CreateConditionCmd extends BaseAsyncCreateCmd {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEntityTable() {
|
||||
return "conditions";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -80,9 +80,6 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal
|
||||
// ///////////////// Accessors ///////////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "firewall_rules";
|
||||
}
|
||||
|
||||
public Long getIpAddressId() {
|
||||
return ipAddressId;
|
||||
@ -242,6 +239,7 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal
|
||||
try {
|
||||
FirewallRule result = _firewallService.createFirewallRule(this);
|
||||
setEntityId(result.getId());
|
||||
setEntityUuid(result.getUuid());
|
||||
} catch (NetworkRuleConflictException ex) {
|
||||
s_logger.info("Network rule conflict: " + ex.getMessage());
|
||||
s_logger.trace("Network Rule Conflict: ", ex);
|
||||
|
||||
@ -94,9 +94,6 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
|
||||
// ///////////////// Accessors ///////////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "firewall_rules";
|
||||
}
|
||||
|
||||
public Long getIpAddressId() {
|
||||
return ipAddressId;
|
||||
@ -301,6 +298,7 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
|
||||
try {
|
||||
PortForwardingRule result = _rulesService.createPortForwardingRule(this, virtualMachineId, getOpenFirewall());
|
||||
setEntityId(result.getId());
|
||||
setEntityUuid(result.getUuid());
|
||||
} catch (NetworkRuleConflictException ex) {
|
||||
s_logger.info("Network rule conflict: " , ex);
|
||||
s_logger.trace("Network Rule Conflict: ", ex);
|
||||
|
||||
@ -91,9 +91,7 @@ public class CreateLBStickinessPolicyCmd extends BaseAsyncCreateCmd {
|
||||
return paramList;
|
||||
}
|
||||
|
||||
public String getEntityTable() {
|
||||
return "firewall_rules";
|
||||
}
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
// ///////////// API Implementation///////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
@ -141,6 +139,7 @@ public class CreateLBStickinessPolicyCmd extends BaseAsyncCreateCmd {
|
||||
try {
|
||||
StickinessPolicy result = _lbService.createLBStickinessPolicy(this);
|
||||
this.setEntityId(result.getId());
|
||||
this.setEntityUuid(result.getUuid());
|
||||
} catch (NetworkRuleConflictException e) {
|
||||
s_logger.warn("Exception: ", e);
|
||||
throw new ServerApiException(BaseCmd.NETWORK_RULE_CONFLICT_ERROR, e.getMessage());
|
||||
|
||||
@ -120,9 +120,6 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements
|
||||
return privatePort;
|
||||
}
|
||||
|
||||
public String getEntityTable() {
|
||||
return "firewall_rules";
|
||||
}
|
||||
|
||||
public Long getSourceIpAddressId() {
|
||||
if (publicIpId != null) {
|
||||
@ -283,6 +280,7 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements
|
||||
try {
|
||||
LoadBalancer result = _lbService.createLoadBalancerRule(this, getOpenFirewall());
|
||||
this.setEntityId(result.getId());
|
||||
this.setEntityUuid(result.getUuid());
|
||||
} catch (NetworkRuleConflictException e) {
|
||||
s_logger.warn("Exception: ", e);
|
||||
throw new ServerApiException(BaseCmd.NETWORK_RULE_CONFLICT_ERROR, e.getMessage());
|
||||
|
||||
@ -75,9 +75,6 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "firewall_rules";
|
||||
}
|
||||
|
||||
public Long getIpAddressId() {
|
||||
return ipAddressId;
|
||||
@ -151,6 +148,7 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta
|
||||
try {
|
||||
StaticNatRule rule = _rulesService.createStaticNatRule(this, getOpenFirewall());
|
||||
this.setEntityId(rule.getId());
|
||||
this.setEntityUuid(rule.getUuid());
|
||||
} catch (NetworkRuleConflictException e) {
|
||||
s_logger.info("Unable to create Static Nat Rule due to ", e);
|
||||
throw new ServerApiException(BaseCmd.NETWORK_RULE_CONFLICT_ERROR, e.getMessage());
|
||||
|
||||
@ -86,10 +86,6 @@ public class CreateNetworkACLCmd extends BaseAsyncCreateCmd implements FirewallR
|
||||
// ///////////////// Accessors ///////////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "firewall_rules";
|
||||
}
|
||||
|
||||
public Long getIpAddressId() {
|
||||
return null;
|
||||
}
|
||||
@ -262,6 +258,7 @@ public class CreateNetworkACLCmd extends BaseAsyncCreateCmd implements FirewallR
|
||||
try {
|
||||
FirewallRule result = _networkACLService.createNetworkACL(this);
|
||||
setEntityId(result.getId());
|
||||
setEntityUuid(result.getUuid());
|
||||
} catch (NetworkRuleConflictException ex) {
|
||||
s_logger.info("Network rule conflict: " + ex.getMessage());
|
||||
s_logger.trace("Network Rule Conflict: ", ex);
|
||||
|
||||
@ -56,9 +56,6 @@ public class CreateProjectCmd extends BaseAsyncCreateCmd {
|
||||
// ///////////////// Accessors ///////////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "projects";
|
||||
}
|
||||
|
||||
public String getAccountName() {
|
||||
if (accountName != null) {
|
||||
@ -127,6 +124,7 @@ public class CreateProjectCmd extends BaseAsyncCreateCmd {
|
||||
Project project = _projectService.createProject(getName(), getDisplayText(), getAccountName(), getDomainId());
|
||||
if (project != null) {
|
||||
this.setEntityId(project.getId());
|
||||
this.setEntityUuid(project.getUuid());
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create a project");
|
||||
}
|
||||
|
||||
@ -65,9 +65,6 @@ public class CreateSnapshotCmd extends BaseAsyncCreateCmd {
|
||||
// ///////////////// Accessors ///////////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "snapshots";
|
||||
}
|
||||
|
||||
public String getAccountName() {
|
||||
return accountName;
|
||||
@ -153,6 +150,7 @@ public class CreateSnapshotCmd extends BaseAsyncCreateCmd {
|
||||
Snapshot snapshot = _snapshotService.allocSnapshot(getVolumeId(), getPolicyId());
|
||||
if (snapshot != null) {
|
||||
this.setEntityId(snapshot.getId());
|
||||
this.setEntityUuid(snapshot.getUuid());
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create snapshot");
|
||||
}
|
||||
|
||||
@ -102,9 +102,6 @@ import com.cloud.user.UserContext;
|
||||
// ///////////////// Accessors ///////////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "vm_template";
|
||||
}
|
||||
|
||||
public Integer getBits() {
|
||||
return bits;
|
||||
@ -240,13 +237,15 @@ import com.cloud.user.UserContext;
|
||||
public void create() throws ResourceAllocationException {
|
||||
if (isBareMetal()) {
|
||||
_bareMetalVmService.createPrivateTemplateRecord(this, _accountService.getAccount(getEntityOwnerId()));
|
||||
/*Baremetal creates template record after taking image proceeded, use vmId as entity id here*/
|
||||
/*Baremetal creates template record after taking image proceeded, use vmId as entity id and uuid here*/
|
||||
this.setEntityId(vmId);
|
||||
this.setEntityUuid(vmId.toString());
|
||||
} else {
|
||||
VirtualMachineTemplate template = null;
|
||||
template = _userVmService.createPrivateTemplateRecord(this, _accountService.getAccount(getEntityOwnerId()));
|
||||
if (template != null) {
|
||||
this.setEntityId(template.getId());
|
||||
this.setEntityUuid(template.getUuid());
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR,
|
||||
"Failed to create a template");
|
||||
|
||||
@ -171,9 +171,6 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "vm_instance";
|
||||
}
|
||||
|
||||
public String getAccountName() {
|
||||
if (accountName == null) {
|
||||
@ -446,6 +443,7 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
|
||||
|
||||
if (vm != null) {
|
||||
setEntityId(vm.getId());
|
||||
setEntityUuid(vm.getUuid());
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to deploy vm");
|
||||
}
|
||||
|
||||
@ -76,9 +76,6 @@ public class CreateVolumeCmd extends BaseAsyncCreateCmd {
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "volumes";
|
||||
}
|
||||
|
||||
public String getAccountName() {
|
||||
return accountName;
|
||||
@ -154,6 +151,7 @@ public class CreateVolumeCmd extends BaseAsyncCreateCmd {
|
||||
Volume volume = _storageService.allocVolume(this);
|
||||
if (volume != null) {
|
||||
this.setEntityId(volume.getId());
|
||||
this.setEntityUuid(volume.getUuid());
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create volume");
|
||||
}
|
||||
|
||||
@ -67,6 +67,7 @@ public class CreateStaticRouteCmd extends BaseAsyncCreateCmd{
|
||||
try {
|
||||
StaticRoute result = _vpcService.createStaticRoute(getGatewayId(), getCidr());
|
||||
setEntityId(result.getId());
|
||||
setEntityUuid(result.getUuid());
|
||||
} catch (NetworkRuleConflictException ex) {
|
||||
s_logger.info("Network rule conflict: " + ex.getMessage());
|
||||
s_logger.trace("Network rule conflict: ", ex);
|
||||
@ -74,10 +75,6 @@ public class CreateStaticRouteCmd extends BaseAsyncCreateCmd{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEntityTable() {
|
||||
return "static_routes";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
|
||||
@ -124,6 +124,7 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd{
|
||||
getCidr(), getNetworkDomain());
|
||||
if (vpc != null) {
|
||||
this.setEntityId(vpc.getId());
|
||||
this.setEntityUuid(vpc.getUuid());
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create a VPC");
|
||||
}
|
||||
@ -157,11 +158,6 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEntityTable() {
|
||||
return "vpc";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
|
||||
@ -103,9 +103,6 @@ public class AddVpnUserCmd extends BaseAsyncCreateCmd {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
public String getEntityTable() {
|
||||
return "vpn_users";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
@ -150,5 +147,6 @@ public class AddVpnUserCmd extends BaseAsyncCreateCmd {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add vpn user");
|
||||
}
|
||||
setEntityId(vpnUser.getId());
|
||||
setEntityUuid(vpnUser.getUuid());
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,10 +62,6 @@ public class CreateRemoteAccessVpnCmd extends BaseAsyncCreateCmd {
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "user_ip_address";
|
||||
}
|
||||
|
||||
public Long getPublicIpId() {
|
||||
return publicIpId;
|
||||
}
|
||||
@ -146,6 +142,11 @@ public class CreateRemoteAccessVpnCmd extends BaseAsyncCreateCmd {
|
||||
RemoteAccessVpn vpn = _ravService.createRemoteAccessVpn(publicIpId, ipRange, getOpenFirewall(), getNetworkId());
|
||||
if (vpn != null) {
|
||||
this.setEntityId(vpn.getServerAddressId());
|
||||
// find uuid for server ip address
|
||||
IpAddress ipAddr = _entityMgr.findById(IpAddress.class, vpn.getServerAddressId());
|
||||
if (ipAddr != null) {
|
||||
this.setEntityUuid(ipAddr.getUuid());
|
||||
}
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create remote access vpn");
|
||||
}
|
||||
|
||||
@ -51,9 +51,6 @@ public class CreateVpnConnectionCmd extends BaseAsyncCreateCmd {
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "s2s_vpn_connection";
|
||||
}
|
||||
|
||||
public Long getVpnGatewayId() {
|
||||
return vpnGatewayId;
|
||||
@ -95,6 +92,7 @@ public class CreateVpnConnectionCmd extends BaseAsyncCreateCmd {
|
||||
Site2SiteVpnConnection conn = _s2sVpnService.createVpnConnection(this);
|
||||
if (conn != null) {
|
||||
this.setEntityId(conn.getId());
|
||||
this.setEntityUuid(conn.getUuid());
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create site to site vpn connection");
|
||||
}
|
||||
|
||||
@ -78,9 +78,6 @@ public class CreateVpnCustomerGatewayCmd extends BaseAsyncCmd {
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "s2s_customer_gateway";
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
|
||||
@ -47,10 +47,6 @@ public class CreateVpnGatewayCmd extends BaseAsyncCmd {
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "s2s_vpn_gateway";
|
||||
}
|
||||
|
||||
public Long getVpcId() {
|
||||
return vpcId;
|
||||
}
|
||||
|
||||
@ -44,9 +44,6 @@ public class DeleteVpnConnectionCmd extends BaseAsyncCmd {
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "s2s_vpn_connection";
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
|
||||
@ -43,9 +43,6 @@ public class DeleteVpnCustomerGatewayCmd extends BaseAsyncCmd {
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "s2s_customer_gateway";
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
|
||||
@ -43,9 +43,6 @@ public class DeleteVpnGatewayCmd extends BaseAsyncCmd {
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "s2s_vpn_gateway";
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
|
||||
@ -53,9 +53,6 @@ public class ResetVpnConnectionCmd extends BaseAsyncCmd {
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "s2s_vpn_connection";
|
||||
}
|
||||
|
||||
public Long getDomainId() {
|
||||
return domainId;
|
||||
|
||||
@ -78,11 +78,7 @@ public class UpdateVpnCustomerGatewayCmd extends BaseAsyncCmd {
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "s2s_customer_gateway";
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
@ -17,7 +17,6 @@
|
||||
package org.apache.cloudstack.api.response;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import com.cloud.utils.IdentityProxy;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
|
||||
@ -16,24 +16,16 @@
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.response;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import com.cloud.utils.IdentityProxy;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
|
||||
public class CreateCmdResponse extends BaseResponse {
|
||||
@SerializedName(ApiConstants.ID)
|
||||
private IdentityProxy id = new IdentityProxy();
|
||||
private String id;
|
||||
|
||||
public Long getId() {
|
||||
return id.getValue();
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id.setValue(id);
|
||||
}
|
||||
|
||||
public void setIdEntityTable(String entityTable) {
|
||||
this.id.setTableName(entityTable);
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,7 +17,6 @@
|
||||
package org.apache.cloudstack.api.response;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import com.cloud.utils.IdentityProxy;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
|
||||
@ -19,7 +19,6 @@
|
||||
package org.apache.cloudstack.api.response;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
import com.cloud.utils.IdentityProxy;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
|
||||
@ -29,7 +28,7 @@ public class S3Response extends BaseResponse {
|
||||
|
||||
@SerializedName(ID)
|
||||
@Param(description = "The ID of the S3 configuration")
|
||||
private IdentityProxy id = new IdentityProxy("s3");
|
||||
private String id;
|
||||
|
||||
@SerializedName(S3_ACCESS_KEY)
|
||||
@Param(description = "The S3 access key")
|
||||
@ -135,11 +134,11 @@ public class S3Response extends BaseResponse {
|
||||
|
||||
@Override
|
||||
public String getObjectId() {
|
||||
return this.id.getValue().toString();
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setObjectId(Long id) {
|
||||
this.id.setValue(id);
|
||||
public void setObjectId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getAccessKey() {
|
||||
|
||||
@ -135,8 +135,8 @@ public class TemplateResponse extends BaseResponse implements ControlledEntityRe
|
||||
@SerializedName(ApiConstants.TAGS) @Param(description="the list of resource tags associated with tempate", responseObject = ResourceTagResponse.class)
|
||||
private List<ResourceTagResponse> tags;
|
||||
|
||||
|
||||
|
||||
@SerializedName(ApiConstants.SSHKEY_ENABLED) @Param(description="true if template is sshkey enabled, false otherwise")
|
||||
private Boolean sshKeyEnabled;
|
||||
|
||||
@Override
|
||||
public String getObjectId() {
|
||||
@ -290,4 +290,9 @@ public class TemplateResponse extends BaseResponse implements ControlledEntityRe
|
||||
public void setTags(List<ResourceTagResponse> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public void setSshKeyEnabled(boolean sshKeyEnabled) {
|
||||
this.sshKeyEnabled = sshKeyEnabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -56,9 +56,6 @@ under the License.
|
||||
<adapters key="org.apache.cloudstack.acl.APIAccessChecker">
|
||||
<adapter name="StaticRoleBasedAPIAccessChecker" class="org.apache.cloudstack.acl.StaticRoleBasedAPIAccessChecker"/>
|
||||
</adapters>
|
||||
<adapters key="org.apache.cloudstack.discovery.ApiDiscoveryService">
|
||||
<adapter name="ApiDiscoveryService" class="org.apache.cloudstack.discovery.ApiDiscoveryServiceImpl"/>
|
||||
</adapters>
|
||||
<adapters key="com.cloud.agent.manager.allocator.HostAllocator">
|
||||
<adapter name="FirstFitRouting" class="com.cloud.agent.manager.allocator.impl.FirstFitRoutingAllocator"/>
|
||||
<!--adapter name="FirstFitRouting" class="com.cloud.agent.manager.allocator.impl.RecreateHostAllocator"/-->
|
||||
|
||||
@ -22,26 +22,19 @@
|
||||
under the License.
|
||||
-->
|
||||
<section id="accessing-vms">
|
||||
<title>Accessing VMs</title>
|
||||
<para>Any user can access their own virtual machines. The administrator can access all VMs running in the cloud.</para>
|
||||
<para>To access a VM through the &PRODUCT; UI:</para>
|
||||
<orderedlist>
|
||||
<listitem><para>Log in to the &PRODUCT; UI as a user or admin.</para></listitem>
|
||||
<listitem><para>Click Instances, then click the name of a running VM.</para></listitem>
|
||||
<listitem><para>Click the View Console <inlinemediaobject>
|
||||
<imageobject>
|
||||
<imagedata fileref="./images/console-icon.png"/>
|
||||
</imageobject>
|
||||
<textobject>
|
||||
<phrase>consoleicon.png: button to view the console.</phrase>
|
||||
</textobject>
|
||||
</inlinemediaobject></para></listitem>
|
||||
</orderedlist>
|
||||
<para>To access a VM directly over the network:</para>
|
||||
<orderedlist>
|
||||
<listitem><para>The VM must have some port open to incoming traffic. For example, in a basic zone, a new VM might be assigned to a security group which allows incoming traffic. This depends on what security group you picked when creating the VM. In other cases, you can open a port by setting up a port forwarding policy. See IP Forwarding and Firewalling.</para></listitem>
|
||||
<listitem><para>If a port is open but you can not access the VM using ssh, it’s possible that ssh is not already enabled on the VM. This will depend on whether ssh is enabled in the template you picked when creating the VM. Access the VM through the &PRODUCT; UI and enable ssh on the machine using the commands for the VM’s operating system.</para></listitem>
|
||||
<listitem><para>If the network has an external firewall device, you will need to create a firewall rule to allow access. See IP Forwarding and Firewalling.</para></listitem>
|
||||
</orderedlist>
|
||||
<title>Accessing VMs</title>
|
||||
<para>Any user can access their own virtual machines. The administrator can access all VMs running in the cloud.</para>
|
||||
<para>To access a VM through the &PRODUCT; UI:</para>
|
||||
<orderedlist>
|
||||
<listitem><para>Log in to the &PRODUCT; UI as a user or admin.</para></listitem>
|
||||
<listitem><para>Click Instances, then click the name of a running VM.</para></listitem>
|
||||
<listitem><para>Click the View Console button <inlinegraphic format="PNG" fileref="images/view-console-button.png"/>.</para></listitem>
|
||||
</orderedlist>
|
||||
<para>To access a VM directly over the network:</para>
|
||||
<orderedlist>
|
||||
<listitem><para>The VM must have some port open to incoming traffic. For example, in a basic zone, a new VM might be assigned to a security group which allows incoming traffic. This depends on what security group you picked when creating the VM. In other cases, you can open a port by setting up a port forwarding policy. See IP Forwarding and Firewalling.</para></listitem>
|
||||
<listitem><para>If a port is open but you can not access the VM using ssh, it’s possible that ssh is not already enabled on the VM. This will depend on whether ssh is enabled in the template you picked when creating the VM. Access the VM through the &PRODUCT; UI and enable ssh on the machine using the commands for the VM’s operating system.</para></listitem>
|
||||
<listitem><para>If the network has an external firewall device, you will need to create a firewall rule to allow access. See IP Forwarding and Firewalling.</para></listitem>
|
||||
</orderedlist>
|
||||
</section>
|
||||
|
||||
|
||||
145
docs/en-US/aws-api-examples.xml
Normal file
145
docs/en-US/aws-api-examples.xml
Normal file
@ -0,0 +1,145 @@
|
||||
<?xml version='1.0' encoding='utf-8' ?>
|
||||
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
||||
<!ENTITY % BOOK_ENTITIES SYSTEM "cloudstack.ent">
|
||||
%BOOK_ENTITIES;
|
||||
]>
|
||||
|
||||
<!-- 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.
|
||||
-->
|
||||
|
||||
<section id="aws-api-examples">
|
||||
<title>Examples</title>
|
||||
<para>There are many tools available to interface with a AWS compatible API. In this section we provide
|
||||
a few examples that users of &PRODUCT; can build upon.</para>
|
||||
|
||||
<section id="aws-api-boto-examples">
|
||||
<title>Boto Examples</title>
|
||||
<para>Boto is one of them. It is a Python package available at https://github.com/boto/boto.
|
||||
In this section we provide two examples of Python scripts that use Boto and have been tested with the
|
||||
&PRODUCT; AWS API Interface.</para>
|
||||
<para>First is an EC2 example. Replace the Access and Secret Keys with your own and
|
||||
update the endpoint.</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>An EC2 Boto example</title>
|
||||
<programlisting>#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import os
|
||||
import boto
|
||||
import boto.ec2
|
||||
|
||||
region = boto.ec2.regioninfo.RegionInfo(name="ROOT",endpoint="localhost")
|
||||
apikey='GwNnpUPrO6KgIdZu01z_ZhhZnKjtSdRwuYd4DvpzvFpyxGMvrzno2q05MB0ViBoFYtdqKd'
|
||||
secretkey='t4eXLEYWw7chBhDlaKf38adCMSHx_wlds6JfSx3z9fSpSOm0AbP9Moj0oGIzy2LSC8iw'
|
||||
|
||||
def main():
|
||||
'''Establish connection to EC2 cloud'''
|
||||
conn =boto.connect_ec2(aws_access_key_id=apikey,
|
||||
aws_secret_access_key=secretkey,
|
||||
is_secure=False,
|
||||
region=region,
|
||||
port=7080,
|
||||
path="/awsapi",
|
||||
api_version="2010-11-15")
|
||||
|
||||
'''Get list of images that I own'''
|
||||
images = conn.get_all_images()
|
||||
print images
|
||||
myimage = images[0]
|
||||
'''Pick an instance type'''
|
||||
vm_type='m1.small'
|
||||
reservation = myimage.run(instance_type=vm_type,security_groups=['default'])
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>Second is an S3 example. Replace the Access and Secret keys with your own,
|
||||
as well as the endpoint of the service. Be sure to also update the file paths to something
|
||||
that exists on your machine.</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>An S3 Boto Example</title>
|
||||
<programlisting>#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import os
|
||||
from boto.s3.key import Key
|
||||
from boto.s3.connection import S3Connection
|
||||
from boto.s3.connection import OrdinaryCallingFormat
|
||||
|
||||
apikey='ChOw-pwdcCFy6fpeyv6kUaR0NnhzmG3tE7HLN2z3OB_s-ogF5HjZtN4rnzKnq2UjtnHeg_yLA5gOw'
|
||||
secretkey='IMY8R7CJQiSGFk4cHwfXXN3DUFXz07cCiU80eM3MCmfLs7kusgyOfm0g9qzXRXhoAPCH-IRxXc3w'
|
||||
|
||||
cf=OrdinaryCallingFormat()
|
||||
|
||||
def main():
|
||||
'''Establish connection to S3 service'''
|
||||
conn =S3Connection(aws_access_key_id=apikey,aws_secret_access_key=secretkey, \
|
||||
is_secure=False, \
|
||||
host='localhost', \
|
||||
port=7080, \
|
||||
calling_format=cf, \
|
||||
path="/awsapi/rest/AmazonS3")
|
||||
|
||||
try:
|
||||
bucket=conn.create_bucket('cloudstack')
|
||||
k = Key(bucket)
|
||||
k.key = 'test'
|
||||
try:
|
||||
k.set_contents_from_filename('/Users/runseb/Desktop/s3cs.py')
|
||||
except:
|
||||
print 'could not write file'
|
||||
pass
|
||||
except:
|
||||
bucket = conn.get_bucket('cloudstack')
|
||||
k = Key(bucket)
|
||||
k.key = 'test'
|
||||
try:
|
||||
k.get_contents_to_filename('/Users/runseb/Desktop/foobar')
|
||||
except:
|
||||
print 'Could not get file'
|
||||
pass
|
||||
|
||||
try:
|
||||
bucket1=conn.create_bucket('teststring')
|
||||
k=Key(bucket1)
|
||||
k.key('foobar')
|
||||
k.set_contents_from_string('This is my silly test')
|
||||
except:
|
||||
bucket1=conn.get_bucket('teststring')
|
||||
k = Key(bucket1)
|
||||
k.key='foobar'
|
||||
k.get_contents_as_string()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section id="aws-api-jclouds-examples">
|
||||
<title>JClouds Examples</title>
|
||||
<para></para>
|
||||
</section>
|
||||
|
||||
</section>
|
||||
@ -23,26 +23,88 @@
|
||||
-->
|
||||
|
||||
<section id="aws-ec2-configuration">
|
||||
<title>Enabling the AWS API Compatible Interface</title>
|
||||
<para>
|
||||
The software that provides AWS API compatibility is installed along with &PRODUCT;. However, you must enable the feature and perform some setup steps.
|
||||
</para>
|
||||
<orderedlist>
|
||||
<listitem><para>Set the global configuration parameter enable.ec2.api to true. See <xref linkend="global-config" />.</para></listitem>
|
||||
<listitem><para>Create a set of &PRODUCT; service offerings with names that match the Amazon service offerings.
|
||||
You can do this through the &PRODUCT; UI as described in the Administration Guide.</para>
|
||||
<warning><para>Be sure you have included the Amazon default service offering, m1.small.</para></warning></listitem>
|
||||
<listitem><para>If you did not already do so when you set the configuration parameter in step 1, restart the Management Server.</para>
|
||||
<programlisting># service cloud-management restart</programlisting></listitem>
|
||||
<listitem><para>(Optional) The AWS API listens for requests on port 7080. If you prefer AWS API to listen on another port, you can change it as follows:</para>
|
||||
<orderedlist numeration="loweralpha">
|
||||
<listitem><para>Edit the files /etc/cloud/management/server.xml, /etc/cloud/management/server-nonssl.xml, and /etc/cloud/management/server-ssl.xml.</para></listitem>
|
||||
<listitem><para>In each file, find the tag <Service name="Catalina7080">. Under this tag, locate <Connector executor="tomcatThreadPool-internal" port= ....<.</para></listitem>
|
||||
<listitem><para>Change the port to whatever port you want to use, then save the files.</para></listitem>
|
||||
<listitem><para>Restart the Management Server.</para>
|
||||
<note><para>If you re-install CloudStack, you will have to make these changes again.</para></note>
|
||||
<title>Enabling the EC2 and S3 Compatible Interface</title>
|
||||
|
||||
<para>The software that provides AWS API compatibility is installed along with &PRODUCT;. You must enable the services and perform some setup steps prior to using it.
|
||||
</para>
|
||||
<orderedlist>
|
||||
<listitem><para>Set the global configuration parameters for each service to true.
|
||||
See <xref linkend="global-config" />.</para></listitem>
|
||||
<listitem><para>Create a set of &PRODUCT; service offerings with names that match the Amazon service offerings.
|
||||
You can do this through the &PRODUCT; UI as described in the Administration Guide.</para>
|
||||
<warning><para>Be sure you have included the Amazon default service offering, m1.small. As well as any EC2 instance types that you will use.</para></warning>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
<listitem><para>If you did not already do so when you set the configuration parameter in step 1,
|
||||
restart the Management Server.</para>
|
||||
<programlisting># service cloud-management restart</programlisting>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
<para>The following sections provides details to perform these steps</para>
|
||||
|
||||
<section id="aws-api-settings">
|
||||
<title>Enabling the Services</title>
|
||||
<para>To enable the EC2 and S3 compatible services you need to set the configuration variables <emphasis>enable.ec2.api</emphasis>
|
||||
and <emphasis>enable.s3.api</emphasis> to true. You do not have to enable both at the same time. Enable the ones you need.
|
||||
This can be done via the &PRODUCT; GUI by going in <emphasis>Global Settings</emphasis> or via the API.</para>
|
||||
<para>The snapshot below shows you how to use the GUI to enable these services</para>
|
||||
|
||||
<para>
|
||||
<mediaobject>
|
||||
<imageobject>
|
||||
<imagedata fileref="./images/ec2-s3-configuration.png"/>
|
||||
</imageobject>
|
||||
<textobject>
|
||||
<phrase>Use the GUI to set the configuration variable to <emphasis>true</emphasis></phrase>
|
||||
</textobject>
|
||||
</mediaobject>
|
||||
</para>
|
||||
|
||||
<para>Using the &PRODUCT; API, the easiest is to use the so-called integration port on which you can make
|
||||
unauthenticated calls. In Global Settings set the port to 8096 and subsequently call the <emphasis>updateConfiguration</emphasis> method.
|
||||
The following urls shows you how:</para>
|
||||
|
||||
<para>
|
||||
<programlisting>
|
||||
http://localhost:8096/client/api?command=updateConfiguration&name=enable.ec2.api&value=true
|
||||
http://localhost:8096/client/api?command=updateConfiguration&name=enable.ec2.api&value=true
|
||||
</programlisting>
|
||||
</para>
|
||||
|
||||
<para>Once you have enabled the services, restart the server.</para>
|
||||
</section>
|
||||
|
||||
<section id="aws-ec2-service-offerings">
|
||||
<title>Creating EC2 Compatible Service Offerings</title>
|
||||
<para>You will also need to define compute service offerings with names compatible with the <ulink url="http://aws.amazon.com/ec2/instance-types/">
|
||||
Amazon EC2 instance types</ulink> API names (e.g m1.small,m1.large). This can be done via the &PRODUCT; GUI.
|
||||
Go under <emphasis>Service Offerings</emphasis> select <emphasis>Compute offering</emphasis> and either create
|
||||
a new compute offering or modify an existing one, ensuring that the name matches an EC2 instance type API name. The snapshot below shows you how:</para>
|
||||
<para>
|
||||
<mediaobject>
|
||||
<imageobject>
|
||||
<imagedata fileref="./images/compute-service-offerings.png"/>
|
||||
</imageobject>
|
||||
<textobject>
|
||||
<phrase>Use the GUI to set the name of a compute service offering to an EC2 instance
|
||||
type API name.</phrase>
|
||||
</textobject>
|
||||
</mediaobject>
|
||||
</para>
|
||||
</section>
|
||||
<section id="aws-api-port-change">
|
||||
<title>Modifying the AWS API Port</title>
|
||||
<note>
|
||||
<para>(Optional) The AWS API listens for requests on port 7080. If you prefer AWS API to listen on another port, you can change it as follows:</para>
|
||||
<orderedlist numeration="loweralpha">
|
||||
<listitem><para>Edit the files /etc/cloud/management/server.xml, /etc/cloud/management/server-nonssl.xml,
|
||||
and /etc/cloud/management/server-ssl.xml.</para></listitem>
|
||||
<listitem><para>In each file, find the tag <Service name="Catalina7080">. Under this tag,
|
||||
locate <Connector executor="tomcatThreadPool-internal" port= ....<.</para></listitem>
|
||||
<listitem><para>Change the port to whatever port you want to use, then save the files.</para></listitem>
|
||||
<listitem><para>Restart the Management Server.</para></listitem>
|
||||
</orderedlist>
|
||||
<para>If you re-install &PRODUCT;, you will have to re-enable the services and if need be update the port.</para>
|
||||
</note>
|
||||
</section>
|
||||
|
||||
</section>
|
||||
|
||||
@ -23,16 +23,19 @@
|
||||
-->
|
||||
|
||||
<section id="aws-ec2-introduction">
|
||||
<title>Amazon Web Services EC2 Compatible Interface</title>
|
||||
<title>Amazon Web Services Compatible Interface</title>
|
||||
<para>&PRODUCT; can translate Amazon Web Services (AWS) API calls to native &PRODUCT; API calls
|
||||
so that users can continue using existing AWS-compatible tools. This translation service runs as
|
||||
a separate web application in the same tomcat server as the management server of &PRODUCT;,
|
||||
listening on the same port. This Amazon EC2-compatible API is accessible through a SOAP web
|
||||
service.</para>
|
||||
listening on a different port. The Amazon Web Services (AWS) compatible interface provides the
|
||||
EC2 SOAP and Query APIs as well as the S3 REST API.</para>
|
||||
<note>
|
||||
<para>This service was previously enabled by separate software called CloudBridge. It is now
|
||||
fully integrated with the &PRODUCT; management server. </para>
|
||||
</note>
|
||||
<warning>
|
||||
<para>The compatible interface for the EC2 Query API and the S3 API are Work In Progress. The S3 compatible API offers a way to store data on the management server file system, it is not an implementation of the S3 backend.</para>
|
||||
</warning>
|
||||
<para>Limitations</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
@ -42,7 +45,9 @@
|
||||
<para>Available in fresh installations of &PRODUCT;. Not available through upgrade of previous versions.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>If you need to support features such as elastic IP, set up a Citrix NetScaler to provide this service. The commands such as ec2-associate-address will not work without EIP setup. Users running VMs in this zone will be using the NetScaler-enabled network offering (DefaultSharedNetscalerEIP and ELBNetworkOffering).</para>
|
||||
<para>Features such as Elastic IP (EIP) and Elastic Load Balacing (ELB) are only available in an infrastructure
|
||||
with a Citrix NetScaler device. Users accessing a Zone with a NetScaler device will need to use a
|
||||
NetScaler-enabled network offering (DefaultSharedNetscalerEIP and ELBNetworkOffering).</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
|
||||
@ -23,13 +23,14 @@
|
||||
-->
|
||||
|
||||
<section id="aws-ec2-requirements">
|
||||
<title>System Requirements</title>
|
||||
<title>Supported API Version</title>
|
||||
<itemizedlist>
|
||||
<listitem><para>This interface complies with Amazon's WDSL version dated November 15, 2010, available at
|
||||
<listitem><para>The EC2 interface complies with Amazon's WDSL version dated November 15, 2010, available at
|
||||
<ulink url="http://ec2.amazonaws.com/doc/2010-11-15/">http://ec2.amazonaws.com/doc/2010-11-15/</ulink>.</para></listitem>
|
||||
<listitem><para>Compatible with the EC2 command-line
|
||||
<listitem><para>The interface is compatible with the EC2 command-line
|
||||
tools <emphasis>EC2 tools v. 1.3.6230</emphasis>, which can be downloaded at <ulink
|
||||
url="http://s3.amazonaws.com/ec2-downloads/ec2-api-tools-1.3-62308.zip">http://s3.amazonaws.com/ec2-downloads/ec2-api-tools-1.3-62308.zip</ulink>.</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
<note><para>Work is underway to support a more recent version of the EC2 API</para></note>
|
||||
</section>
|
||||
@ -24,7 +24,7 @@
|
||||
|
||||
<section id="aws-ec2-supported-commands">
|
||||
<title>Supported AWS API Calls</title>
|
||||
<para>The following Amazon EC2 commands are supported by &PRODUCT; when the AWS API compatibility feature is enabled.
|
||||
<para>The following Amazon EC2 commands are supported by &PRODUCT; when the AWS API compatible interface is enabled.
|
||||
For a few commands, there are differences between the &PRODUCT; and Amazon EC2 versions, and these differences are noted. The underlying SOAP call for each command is also given, for those who have built tools using those calls.
|
||||
</para>
|
||||
<table frame='all'>
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
|
||||
<section id="aws-ec2-timeouts">
|
||||
<title>Using Timeouts to Ensure AWS API Command Completion</title>
|
||||
<para>The Amazon EC2 command-line tools have a default connection timeout. When used with &PRODUCT;, a longer timeout might be needed for some commands. If you find that commands are not completing due to timeouts, you can gain more time for commands to finish by overriding the default timeouts on individual commands. You can add the following optional command-line parameters to any &PRODUCT;-supported EC2 command:</para>
|
||||
<para>The Amazon EC2 command-line tools have a default connection timeout. When used with &PRODUCT;, a longer timeout might be needed for some commands. If you find that commands are not completing due to timeouts, you can specify a custom timeouts. You can add the following optional command-line parameters to any &PRODUCT;-supported EC2 command:</para>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="2" align="left" colsep="1" rowsep="1">
|
||||
<colspec colname="c1" />
|
||||
@ -47,4 +47,5 @@
|
||||
</informaltable>
|
||||
<para>Example:</para>
|
||||
<programlisting>ec2-run-instances 2 –z us-test1 –n 1-3 --connection-timeout 120 --request-timeout 120</programlisting>
|
||||
<note><para>The timeouts optional arguments are not specific to &PRODUCT;.</para></note>
|
||||
</section>
|
||||
@ -22,76 +22,84 @@
|
||||
under the License.
|
||||
-->
|
||||
<section id="aws-ec2-user-setup">
|
||||
<title>AWS API User Setup Steps</title>
|
||||
<title>AWS API User Setup</title>
|
||||
<para>In general, users need not be aware that they are using a translation service provided by &PRODUCT;.
|
||||
They need only send AWS API calls to &PRODUCT;'s endpoint, and it will translate the calls to the native API.
|
||||
Users of the Amazon EC2 compatible interface will be able to keep their existing EC2 tools
|
||||
They only need to send AWS API calls to &PRODUCT;'s endpoint, and it will translate the calls to the native &PRODUCT; API. Users of the Amazon EC2 compatible interface will be able to keep their existing EC2 tools
|
||||
and scripts and use them with their &PRODUCT; deployment, by specifying the endpoint of the
|
||||
management server and using the proper user credentials. In order to do this, each user must
|
||||
perform the following configuration steps: </para>
|
||||
<para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>Generate user credentials and register with the service.</para>
|
||||
<para>Generate user credentials.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Set up the environment variables for the EC2 command-line tools.</para>
|
||||
<para>Register with the service.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>For SOAP access, use the endpoint http://<replaceable>&PRODUCT;-management-server</replaceable>:7080/awsapi.
|
||||
The <replaceable>&PRODUCT;-management-server</replaceable> can be specified by a fully-qualified domain name or IP address.</para>
|
||||
<para>For convenience, set up environment variables for the EC2 SOAP command-line tools.</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<section id="aws-ec2-user-registration">
|
||||
<title>AWS API User Registration</title>
|
||||
<para>Each user must perform a one-time registration. The user follows these steps:</para>
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<para>Obtain the following by looking in the &PRODUCT; UI, using the API, or asking the cloud administrator:</para>
|
||||
<itemizedlist>
|
||||
<listitem><para>The &PRODUCT; server's publicly available DNS name or IP address</para></listitem>
|
||||
<listitem><para>The user account's API key and Secret key</para></listitem>
|
||||
</itemizedlist>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
Generate a private key and a self-signed X.509 certificate. The user substitutes their own desired storage location for /path/to/… below.
|
||||
</para>
|
||||
<para><programlisting>$ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /path/to/private_key.pem -out /path/to/cert.pem</programlisting>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
Register the mapping from the X.509 certificate to the API/Secret keys.
|
||||
Download the following script from http://download.cloud.com/releases/3.0.3/cloudstack-aws-api-register and run it.
|
||||
Substitute the values that were obtained in step 1 in the URL below.
|
||||
</para>
|
||||
<para>
|
||||
<programlisting>$ cloudstack-aws-api-register --apikey=<replaceable>User’s &PRODUCT; API key</replaceable> --secretkey=<replaceable>User’s &PRODUCT; Secret key</replaceable> --cert=<replaceable>/path/to/cert.pem</replaceable> --url=http://<replaceable>&PRODUCT;.server</replaceable>:7080/awsapi</programlisting>
|
||||
</para>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
<para>Each user must perform a one-time registration. The user follows these steps:</para>
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<para>Obtain the following by looking in the &PRODUCT; UI, using the API, or asking the cloud administrator:
|
||||
</para>
|
||||
<itemizedlist>
|
||||
<listitem><para>The &PRODUCT; server's publicly available DNS name or IP address</para></listitem>
|
||||
<listitem><para>The user account's Access key and Secret key</para></listitem>
|
||||
</itemizedlist>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Generate a private key and a self-signed X.509 certificate. The user substitutes their own desired storage location for /path/to/… below.
|
||||
</para>
|
||||
<para>
|
||||
<programlisting>$ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /path/to/private_key.pem -out /path/to/cert.pem</programlisting>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Register the user X.509 certificate and Access/Secret keys with the AWS compatible service.
|
||||
If you have the source code of &PRODUCT; go to the awsapi-setup/setup directory and use the Python script
|
||||
cloudstack-aws-api-register. If you do not have the source then download the script using the following command.
|
||||
</para>
|
||||
<para>
|
||||
<programlisting>wget -O cloudstack-aws-api-register <ulink url="https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;a=blob_plain;f=awsapi-setup/setup/cloudstack-aws-api-register;hb=HEAD">"https://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git;a=blob_plain;f=awsapi-setup/setup/cloudstack-aws-api-register;hb=HEAD"</ulink>
|
||||
</programlisting>
|
||||
</para>
|
||||
<para> Then execute it, using the parameter values that were obtained in step 1. An example is shown below.</para>
|
||||
<para>
|
||||
<programlisting>$ cloudstack-aws-api-register --apikey=<replaceable>User’s &PRODUCT; API key</replaceable> --secretkey=<replaceable>User’s &PRODUCT; Secret key</replaceable> --cert=<replaceable>/path/to/cert.pem</replaceable> --url=http://<replaceable>&PRODUCT;.server</replaceable>:7080/awsapi</programlisting>
|
||||
</para>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
<note>
|
||||
<para>
|
||||
A user with an existing AWS certificate could choose to use the same certificate with &PRODUCT;, but the public key would be uploaded to the &PRODUCT; management server database.
|
||||
A user with an existing AWS certificate could choose to use the same certificate with &PRODUCT;, but note that the certificate would be uploaded to the &PRODUCT; management server database.
|
||||
</para>
|
||||
</note>
|
||||
</section>
|
||||
<section id="aws-api-tools-setup">
|
||||
<title>AWS API Command-Line Tools Setup</title>
|
||||
<para>To use the EC2 command-line tools, the user must perform these steps:</para>
|
||||
<orderedlist>
|
||||
<listitem><para>Be sure you have the right version of EC2 Tools.
|
||||
The supported version is available at <ulink url="http://s3.amazonaws.com/ec2-downloads/ec2-api-tools-1.3-62308.zip">http://s3.amazonaws.com/ec2-downloads/ec2-api-tools-1.3-62308.zip</ulink>.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Set up the environment variables that will direct the tools to the server. As a best practice, you may wish to place these commands in a script that may be sourced before using the AWS API translation feature.</para>
|
||||
<programlisting>$ export EC2_CERT=/path/to/cert.pem
|
||||
$ export EC2_PRIVATE_KEY=/path/to/private_key.pem
|
||||
$ export EC2_URL=http://<replaceable>&PRODUCT;.server</replaceable>:7080/awsapi
|
||||
$ export EC2_HOME=/path/to/EC2_tools_directory</programlisting>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
<title>AWS API Command-Line Tools Setup</title>
|
||||
<para>To use the EC2 command-line tools, the user must perform these steps:</para>
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<para>Be sure you have the right version of EC2 Tools.
|
||||
The supported version is available at <ulink url="http://s3.amazonaws.com/ec2-downloads/ec2-api-tools-1.3-62308.zip">http://s3.amazonaws.com/ec2-downloads/ec2-api-tools-1.3-62308.zip</ulink>.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Set up the EC2 environment variables. This can be done every time you use the service or you can set them up in the proper shell profile. Replace the endpoint (i.e EC2_URL) with the proper address of your &PRODUCT; management server and port. In a bash shell do the following.
|
||||
</para>
|
||||
<programlisting>
|
||||
$ export EC2_CERT=/path/to/cert.pem
|
||||
$ export EC2_PRIVATE_KEY=/path/to/private_key.pem
|
||||
$ export EC2_URL=http://localhost:7080/awsapi
|
||||
$ export EC2_HOME=/path/to/EC2_tools_directory
|
||||
</programlisting>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
</section>
|
||||
</section>
|
||||
@ -23,11 +23,12 @@
|
||||
-->
|
||||
|
||||
<chapter id="aws-interface-compatibility">
|
||||
<title>Amazon Web Service Interface Compatibility</title>
|
||||
<title>Amazon Web Services Compatible Interface</title>
|
||||
<xi:include href="aws-ec2-introduction.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
<xi:include href="aws-ec2-requirements.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
<xi:include href="aws-ec2-configuration.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
<xi:include href="aws-ec2-user-setup.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
<xi:include href="aws-ec2-timeouts.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
<xi:include href="aws-ec2-supported-commands.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
<xi:include href="aws-api-examples.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
</chapter>
|
||||
|
||||
BIN
docs/en-US/images/compute-service-offerings.png
Normal file
BIN
docs/en-US/images/compute-service-offerings.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 74 KiB |
0
docs/en-US/images/ec2-s3-configuration.png
Normal file
0
docs/en-US/images/ec2-s3-configuration.png
Normal file
BIN
docs/en-US/images/view-console-button.png
Normal file
BIN
docs/en-US/images/view-console-button.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 59 KiB |
@ -23,9 +23,11 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
@ -34,18 +36,13 @@ import javax.naming.ConfigurationException;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.utils.PropertiesUtil;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.utils.component.PluggableService;
|
||||
|
||||
/*
|
||||
* This is the default API access checker that grab's the user's account
|
||||
* based on the account type, access is granted referring to commands in all *.properties files.
|
||||
*/
|
||||
|
||||
// This is the default API access checker that grab's the user's account
|
||||
// based on the account type, access is granted
|
||||
@Local(value=APIAccessChecker.class)
|
||||
public class StaticRoleBasedAPIAccessChecker extends AdapterBase implements APIAccessChecker {
|
||||
|
||||
@ -54,53 +51,50 @@ public class StaticRoleBasedAPIAccessChecker extends AdapterBase implements APIA
|
||||
public static final short DOMAIN_ADMIN_COMMAND = 4;
|
||||
public static final short RESOURCE_DOMAIN_ADMIN_COMMAND = 2;
|
||||
public static final short USER_COMMAND = 8;
|
||||
private static List<String> s_userCommands = null;
|
||||
private static List<String> s_resellerCommands = null; // AKA domain-admin
|
||||
private static List<String> s_adminCommands = null;
|
||||
private static List<String> s_resourceDomainAdminCommands = null;
|
||||
private static List<String> s_allCommands = null;
|
||||
|
||||
@Inject AccountManager _accountMgr;
|
||||
@Inject List<PluggableService> _services;
|
||||
private static Set<String> s_userCommands = null;
|
||||
private static Set<String> s_resellerCommands = null; // AKA domain-admin
|
||||
private static Set<String> s_adminCommands = null;
|
||||
private static Set<String> s_resourceDomainAdminCommands = null;
|
||||
private static Set<String> s_allCommands = null;
|
||||
|
||||
protected StaticRoleBasedAPIAccessChecker() {
|
||||
super();
|
||||
s_allCommands = new ArrayList<String>();
|
||||
s_userCommands = new ArrayList<String>();
|
||||
s_resellerCommands = new ArrayList<String>();
|
||||
s_adminCommands = new ArrayList<String>();
|
||||
s_resourceDomainAdminCommands = new ArrayList<String>();
|
||||
s_allCommands = new HashSet<String>();
|
||||
s_userCommands = new HashSet<String>();
|
||||
s_resellerCommands = new HashSet<String>();
|
||||
s_adminCommands = new HashSet<String>();
|
||||
s_resourceDomainAdminCommands = new HashSet<String>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAccessAPI(User user, String apiCommandName)
|
||||
public boolean canAccessAPI(RoleType roleType, String apiCommandName)
|
||||
throws PermissionDeniedException{
|
||||
|
||||
boolean commandExists = s_allCommands.contains(apiCommandName);
|
||||
|
||||
if(commandExists && user != null){
|
||||
Long accountId = user.getAccountId();
|
||||
Account userAccount = _accountMgr.getAccount(accountId);
|
||||
short accountType = userAccount.getType();
|
||||
return isCommandAvailableForAccount(accountType, apiCommandName);
|
||||
if(commandExists) {
|
||||
return isCommandAvailableForAccount(roleType, apiCommandName);
|
||||
}
|
||||
|
||||
return commandExists;
|
||||
}
|
||||
|
||||
private static boolean isCommandAvailableForAccount(short accountType, String commandName) {
|
||||
private static boolean isCommandAvailableForAccount(RoleType roleType, String commandName) {
|
||||
boolean isCommandAvailable = false;
|
||||
switch (accountType) {
|
||||
case Account.ACCOUNT_TYPE_ADMIN:
|
||||
switch (roleType) {
|
||||
case Admin:
|
||||
isCommandAvailable = s_adminCommands.contains(commandName);
|
||||
break;
|
||||
case Account.ACCOUNT_TYPE_DOMAIN_ADMIN:
|
||||
case DomainAdmin:
|
||||
isCommandAvailable = s_resellerCommands.contains(commandName);
|
||||
break;
|
||||
case Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN:
|
||||
case ResourceAdmin:
|
||||
isCommandAvailable = s_resourceDomainAdminCommands.contains(commandName);
|
||||
break;
|
||||
case Account.ACCOUNT_TYPE_NORMAL:
|
||||
case User:
|
||||
isCommandAvailable = s_userCommands.contains(commandName);
|
||||
break;
|
||||
}
|
||||
@ -154,16 +148,16 @@ public class StaticRoleBasedAPIAccessChecker extends AdapterBase implements APIA
|
||||
|
||||
try {
|
||||
short cmdPermissions = Short.parseShort(mask);
|
||||
if ((cmdPermissions & ADMIN_COMMAND) != 0) {
|
||||
if ((cmdPermissions & Admin.getValue()) != 0) {
|
||||
s_adminCommands.add((String) key);
|
||||
}
|
||||
if ((cmdPermissions & RESOURCE_DOMAIN_ADMIN_COMMAND) != 0) {
|
||||
if ((cmdPermissions & ResourceAdmin.getValue()) != 0) {
|
||||
s_resourceDomainAdminCommands.add((String) key);
|
||||
}
|
||||
if ((cmdPermissions & DOMAIN_ADMIN_COMMAND) != 0) {
|
||||
if ((cmdPermissions & DomainAdmin.getValue()) != 0) {
|
||||
s_resellerCommands.add((String) key);
|
||||
}
|
||||
if ((cmdPermissions & USER_COMMAND) != 0) {
|
||||
if ((cmdPermissions & User.getValue()) != 0) {
|
||||
s_userCommands.add((String) key);
|
||||
}
|
||||
s_allCommands.addAll(s_adminCommands);
|
||||
|
||||
@ -16,14 +16,10 @@
|
||||
// under the License.
|
||||
package org.apache.cloudstack.discovery;
|
||||
|
||||
import com.cloud.utils.component.Adapter;
|
||||
import com.cloud.utils.component.PluggableService;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface ApiDiscoveryService extends Adapter, PluggableService {
|
||||
public interface ApiDiscoveryService extends PluggableService {
|
||||
ListResponse<? extends BaseResponse> listApis();
|
||||
Map<String, Class<?>> getApiNameCmdClassMapping();
|
||||
}
|
||||
@ -17,7 +17,6 @@
|
||||
package org.apache.cloudstack.discovery;
|
||||
|
||||
import com.cloud.utils.ReflectUtil;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.BaseCmd;
|
||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
||||
@ -30,7 +29,6 @@ import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -39,36 +37,28 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Local(value = ApiDiscoveryService.class)
|
||||
public class ApiDiscoveryServiceImpl extends AdapterBase implements ApiDiscoveryService {
|
||||
|
||||
public class ApiDiscoveryServiceImpl implements ApiDiscoveryService {
|
||||
private static final Logger s_logger = Logger.getLogger(ApiDiscoveryServiceImpl.class);
|
||||
private Map<String, Class<?>> _apiNameCmdClassMap;
|
||||
private ListResponse<ApiDiscoveryResponse> _discoveryResponse;
|
||||
|
||||
private ListResponse<ApiDiscoveryResponse> _discoveryResponse = new ListResponse<ApiDiscoveryResponse>();
|
||||
|
||||
private Map<String, Class<?>> _apiNameCmdClassMap = new HashMap<String, Class<?>>();
|
||||
|
||||
protected ApiDiscoveryServiceImpl() {
|
||||
super();
|
||||
generateApiNameCmdClassMap();
|
||||
cacheListApiResponse();
|
||||
}
|
||||
|
||||
private void generateApiNameCmdClassMapping() {
|
||||
_apiNameCmdClassMap = new HashMap<String, Class<?>>();
|
||||
Set<Class<?>> cmdClasses = ReflectUtil.getClassesWithAnnotation(APICommand.class, new String[]{"org.apache.cloudstack.api", "com.cloud.api"});
|
||||
private void generateApiNameCmdClassMap() {
|
||||
Set<Class<?>> cmdClasses = ReflectUtil.getClassesWithAnnotation(APICommand.class,
|
||||
new String[]{"org.apache.cloudstack.api", "com.cloud.api"});
|
||||
|
||||
for(Class<?> cmdClass: cmdClasses) {
|
||||
String apiName = cmdClass.getAnnotation(APICommand.class).name();
|
||||
if (_apiNameCmdClassMap.containsKey(apiName)) {
|
||||
s_logger.error("API Cmd class " + cmdClass.getName() + " has non-unique apiname" + apiName);
|
||||
continue;
|
||||
}
|
||||
_apiNameCmdClassMap.put(apiName, cmdClass);
|
||||
}
|
||||
for(Class<?> cmdClass: cmdClasses)
|
||||
_apiNameCmdClassMap.put(cmdClass.getAnnotation(APICommand.class).name(), cmdClass);
|
||||
}
|
||||
|
||||
private void precacheListApiResponse() {
|
||||
|
||||
if(_apiNameCmdClassMap == null)
|
||||
return;
|
||||
|
||||
_discoveryResponse = new ListResponse<ApiDiscoveryResponse>();
|
||||
private void cacheListApiResponse() {
|
||||
|
||||
List<ApiDiscoveryResponse> apiDiscoveryResponses = new ArrayList<ApiDiscoveryResponse>();
|
||||
|
||||
@ -117,21 +107,6 @@ public class ApiDiscoveryServiceImpl extends AdapterBase implements ApiDiscovery
|
||||
_discoveryResponse.setResponses(apiDiscoveryResponses);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params)
|
||||
throws ConfigurationException {
|
||||
super.configure(name, params);
|
||||
|
||||
generateApiNameCmdClassMapping();
|
||||
precacheListApiResponse();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Map<String, Class<?>> getApiNameCmdClassMapping() {
|
||||
return _apiNameCmdClassMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListResponse<? extends BaseResponse> listApis() {
|
||||
return _discoveryResponse;
|
||||
|
||||
@ -662,7 +662,7 @@ public class NetappManagerImpl implements NetappManager
|
||||
lun = _lunDao.persist(lun);
|
||||
|
||||
//Lun id created: 6 digits right justified eg. 000045
|
||||
String lunIdStr = lun.getId().toString();
|
||||
String lunIdStr = String.valueOf(lun.getId());
|
||||
String zeroStr = "000000";
|
||||
int length = lunIdStr.length();
|
||||
int offset = 6-length;
|
||||
|
||||
@ -343,7 +343,9 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
|
||||
s_logger.error("Failed to add cluster: specified Nexus VSM is already associated with another cluster");
|
||||
_clusterDao.remove(clusterId);
|
||||
ResourceInUseException ex = new ResourceInUseException("Failed to add cluster: specified Nexus VSM is already associated with another cluster with specified Id");
|
||||
ex.addProxyObject("cluster", clusterList.get(0).getClusterId(), "clusterId");
|
||||
// get clusterUuid to report error
|
||||
ClusterVO cluster = _clusterDao.findById(clusterList.get(0).getClusterId());
|
||||
ex.addProxyObject(cluster.getUuid());
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,6 +26,7 @@ import org.apache.log4j.Logger;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.response.HostResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.network.element.F5ExternalLoadBalancerElementService;
|
||||
import org.apache.cloudstack.api.response.ExternalLoadBalancerResponse;
|
||||
@ -40,7 +41,7 @@ public class ListExternalLoadBalancersCmd extends BaseListCmd {
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneRespones.class,
|
||||
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class,
|
||||
description="zone Id")
|
||||
private long zoneId;
|
||||
|
||||
|
||||
@ -31,6 +31,7 @@ import org.apache.cloudstack.api.PlugService;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.NetworkResponse;
|
||||
import com.cloud.api.response.F5LoadBalancerResponse;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
|
||||
@ -262,8 +262,8 @@ public class F5ExternalLoadBalancerElement extends ExternalLoadBalancerDeviceMan
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPropertiesFile() {
|
||||
return "f5bigip_commands.properties";
|
||||
public String[] getPropertiesFiles() {
|
||||
return new String[] { "f5bigip_commands.properties" };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -404,8 +404,8 @@ public class JuniperSRXExternalFirewallElement extends ExternalFirewallDeviceMan
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPropertiesFile() {
|
||||
return "junipersrx_commands.properties";
|
||||
public String[] getPropertiesFiles() {
|
||||
return new String[] { "junipersrx_commands.properties"};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -49,7 +49,7 @@ public class ListNetscalerLoadBalancerNetworksCmd extends BaseListCmd {
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.LOAD_BALANCER_DEVICE_ID, type=CommandType.UUID, entityType = NetscalerLoadBalancerResponse.class, ,
|
||||
@Parameter(name=ApiConstants.LOAD_BALANCER_DEVICE_ID, type=CommandType.UUID, entityType = NetscalerLoadBalancerResponse.class,
|
||||
required = true, description="netscaler load balancer device ID")
|
||||
private Long lbDeviceId;
|
||||
|
||||
|
||||
@ -466,8 +466,8 @@ StaticNatServiceProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPropertiesFile() {
|
||||
return "netscalerloadbalancer_commands.properties";
|
||||
public String[] getPropertiesFiles() {
|
||||
return new String[] { "netscalerloadbalancer_commands.properties" };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
2
pom.xml
2
pom.xml
@ -346,6 +346,7 @@
|
||||
<exclude>scripts/vm/systemvm/id_rsa.cloud</exclude>
|
||||
<exclude>tools/devcloud/basebuild/puppet-devcloudinitial/files/network.conf</exclude>
|
||||
<exclude>tools/devcloud/devcloud.cfg</exclude>
|
||||
<exclude>tools/devcloud-kvm/devcloud-kvm.cfg</exclude>
|
||||
<exclude>ui/lib/flot/jquery.colorhelpers.js</exclude>
|
||||
<exclude>ui/lib/flot/jquery.flot.crosshair.js</exclude>
|
||||
<exclude>ui/lib/flot/jquery.flot.fillbetween.js</exclude>
|
||||
@ -472,6 +473,7 @@
|
||||
<module>developer</module>
|
||||
<module>tools/apidoc</module>
|
||||
<module>tools/devcloud</module>
|
||||
<module>tools/devcloud-kvm</module>
|
||||
<module>tools/marvin</module>
|
||||
<module>tools/cli</module>
|
||||
</modules>
|
||||
|
||||
@ -17,7 +17,6 @@
|
||||
package com.cloud.api;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.cloud.utils.IdentityProxy;
|
||||
import org.apache.cloudstack.api.ResponseObject;
|
||||
|
||||
import java.util.Map;
|
||||
@ -28,7 +27,6 @@ public class ApiGsonHelper {
|
||||
s_gBuilder = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
|
||||
s_gBuilder.setVersion(1.3);
|
||||
s_gBuilder.registerTypeAdapter(ResponseObject.class, new ResponseObjectTypeAdapter());
|
||||
s_gBuilder.registerTypeAdapter(IdentityProxy.class, new IdentityTypeAdapter());
|
||||
s_gBuilder.registerTypeAdapter(Map.class, new StringMapTypeAdapter());
|
||||
}
|
||||
|
||||
|
||||
@ -17,7 +17,6 @@
|
||||
package com.cloud.api;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.cloud.utils.IdentityProxy;
|
||||
import org.apache.cloudstack.api.ResponseObject;
|
||||
|
||||
/**
|
||||
@ -31,7 +30,6 @@ public class ApiResponseGsonHelper {
|
||||
s_gBuilder.setVersion(1.3);
|
||||
s_gBuilder.registerTypeAdapter(ResponseObject.class, new ResponseObjectTypeAdapter());
|
||||
s_gBuilder.registerTypeAdapter(String.class, new EncodedStringTypeAdapter());
|
||||
s_gBuilder.registerTypeAdapter(IdentityProxy.class, new IdentityTypeAdapter());
|
||||
}
|
||||
|
||||
public static GsonBuilder getBuilder() {
|
||||
|
||||
@ -482,7 +482,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
response.setEndPoint(result.getEndPoint());
|
||||
response.setHttpsFlag(result.getHttpsFlag());
|
||||
response.setMaxErrorRetry(result.getMaxErrorRetry());
|
||||
response.setObjectId(result.getId());
|
||||
response.setObjectId(result.getUuid());
|
||||
response.setSecretKey(result.getSecretKey());
|
||||
response.setSocketTimeout(result.getSocketTimeout());
|
||||
response.setTemplateBucketName(result.getBucketName());
|
||||
@ -1265,6 +1265,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
templateResponse.setFeatured(template.isFeatured());
|
||||
templateResponse.setExtractable(template.isExtractable() && !(template.getTemplateType() == TemplateType.SYSTEM));
|
||||
templateResponse.setPasswordEnabled(template.getEnablePassword());
|
||||
templateResponse.setSshKeyEnabled(template.getEnableSshKey());
|
||||
templateResponse.setCrossZones(template.isCrossZones());
|
||||
templateResponse.setFormat(template.getFormat());
|
||||
templateResponse.setDetails(template.getDetails());
|
||||
@ -1346,6 +1347,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
templateResponse.setFeatured(template.isFeatured());
|
||||
templateResponse.setExtractable(template.isExtractable() && !(template.getTemplateType() == TemplateType.SYSTEM));
|
||||
templateResponse.setPasswordEnabled(template.getEnablePassword());
|
||||
templateResponse.setSshKeyEnabled(template.getEnableSshKey());
|
||||
templateResponse.setCrossZones(template.isCrossZones());
|
||||
templateResponse.setFormat(template.getFormat());
|
||||
if (template.getTemplateType() != null) {
|
||||
|
||||
@ -62,6 +62,9 @@ import org.apache.cloudstack.api.command.admin.host.ListHostsCmd;
|
||||
import org.apache.cloudstack.api.command.admin.router.ListRoutersCmd;
|
||||
import org.apache.cloudstack.api.command.admin.storage.ListStoragePoolsCmd;
|
||||
import org.apache.cloudstack.api.command.admin.user.ListUsersCmd;
|
||||
import org.apache.cloudstack.acl.ControlledEntity;
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
import org.apache.cloudstack.api.*;
|
||||
import org.apache.cloudstack.api.command.user.account.ListAccountsCmd;
|
||||
import org.apache.cloudstack.api.command.user.account.ListProjectAccountsCmd;
|
||||
import org.apache.cloudstack.api.command.user.event.ListEventsCmd;
|
||||
@ -72,9 +75,12 @@ import org.apache.cloudstack.api.command.user.tag.ListTagsCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.ListVMsCmd;
|
||||
import org.apache.cloudstack.api.command.user.vmgroup.ListVMGroupsCmd;
|
||||
import org.apache.cloudstack.api.command.user.volume.ListVolumesCmd;
|
||||
<<<<<<< HEAD
|
||||
import org.apache.cloudstack.api.response.ExceptionResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.discovery.ApiDiscoveryService;
|
||||
=======
|
||||
>>>>>>> master
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.http.ConnectionClosedException;
|
||||
import org.apache.http.HttpException;
|
||||
@ -149,19 +155,19 @@ public class ApiServer implements HttpRequestHandler {
|
||||
@Inject DomainManager _domainMgr;
|
||||
@Inject AsyncJobManager _asyncMgr;
|
||||
@Inject ConfigurationDao _configDao;
|
||||
@Inject List<APIAccessChecker> _apiAccessCheckers;
|
||||
|
||||
@Inject List<PluggableService> _pluggableServices;
|
||||
@Inject IdentityDao _identityDao;
|
||||
|
||||
protected List<ApiDiscoveryService> _apiDiscoveryServices;
|
||||
@Inject
|
||||
protected List<APIAccessChecker> _apiAccessCheckers;
|
||||
|
||||
private Account _systemAccount = null;
|
||||
private User _systemUser = null;
|
||||
private static int _workerCount = 0;
|
||||
private static ApiServer s_instance = null;
|
||||
private static final DateFormat _dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
|
||||
private final Map<String, Class<?>> _apiNameCmdClassMap = new HashMap<String, Class<?>>();
|
||||
private static Map<String, Class<?>> _apiNameCmdClassMap = new HashMap<String, Class<?>>();
|
||||
|
||||
private static ExecutorService _executor = new ThreadPoolExecutor(10, 150, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new NamedThreadFactory("ApiServer"));
|
||||
|
||||
@ -169,7 +175,7 @@ public class ApiServer implements HttpRequestHandler {
|
||||
super();
|
||||
}
|
||||
|
||||
public static void initApiServer(String[] apiConfig) {
|
||||
public static void initApiServer() {
|
||||
if (s_instance == null) {
|
||||
s_instance = new ApiServer();
|
||||
s_instance = ComponentContext.inject(s_instance);
|
||||
@ -178,14 +184,13 @@ public class ApiServer implements HttpRequestHandler {
|
||||
}
|
||||
|
||||
public static ApiServer getInstance() {
|
||||
// Assumption: CloudStartupServlet would initialize ApiServer
|
||||
if (s_instance == null) {
|
||||
s_logger.fatal("ApiServer instance failed to initialize");
|
||||
ApiServer.initApiServer();
|
||||
}
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
public void init(String[] apiConfig) {
|
||||
public void init() {
|
||||
BaseCmd.setComponents(new ApiResponseHelper());
|
||||
BaseListCmd.configure();
|
||||
|
||||
@ -203,13 +208,16 @@ public class ApiServer implements HttpRequestHandler {
|
||||
}
|
||||
}
|
||||
|
||||
for (ApiDiscoveryService discoveryService: _apiDiscoveryServices) {
|
||||
_apiNameCmdClassMap.putAll(discoveryService.getApiNameCmdClassMapping());
|
||||
}
|
||||
Set<Class<?>> cmdClasses = ReflectUtil.getClassesWithAnnotation(APICommand.class,
|
||||
new String[]{"org.apache.cloudstack.api", "com.cloud.api"});
|
||||
|
||||
if (_apiNameCmdClassMap.size() == 0) {
|
||||
s_logger.fatal("ApiServer failed to generate apiname, cmd class mappings."
|
||||
+ "Please check and enable at least one ApiDiscovery adapter.");
|
||||
for(Class<?> cmdClass: cmdClasses) {
|
||||
String apiName = cmdClass.getAnnotation(APICommand.class).name();
|
||||
if (_apiNameCmdClassMap.containsKey(apiName)) {
|
||||
s_logger.error("API Cmd class " + cmdClass.getName() + " has non-unique apiname" + apiName);
|
||||
continue;
|
||||
}
|
||||
_apiNameCmdClassMap.put(apiName, cmdClass);
|
||||
}
|
||||
|
||||
encodeApiResponse = Boolean.valueOf(_configDao.getValue(Config.EncodeApiResponse.key()));
|
||||
@ -403,12 +411,12 @@ public class ApiServer implements HttpRequestHandler {
|
||||
// BaseAsyncCmd: cmd is processed and submitted as an AsyncJob, job related info is serialized and returned.
|
||||
if (cmdObj instanceof BaseAsyncCmd) {
|
||||
Long objectId = null;
|
||||
String objectEntityTable = null;
|
||||
String objectUuid = null;
|
||||
if (cmdObj instanceof BaseAsyncCreateCmd) {
|
||||
BaseAsyncCreateCmd createCmd = (BaseAsyncCreateCmd) cmdObj;
|
||||
_dispatcher.dispatchCreateCmd(createCmd, params);
|
||||
objectId = createCmd.getEntityId();
|
||||
objectEntityTable = createCmd.getEntityTable();
|
||||
objectUuid = createCmd.getEntityUuid();
|
||||
params.put("id", objectId.toString());
|
||||
} else {
|
||||
ApiDispatcher.processParameters(cmdObj, params);
|
||||
@ -452,8 +460,8 @@ public class ApiServer implements HttpRequestHandler {
|
||||
}
|
||||
|
||||
if (objectId != null) {
|
||||
SerializationContext.current().setUuidTranslation(true);
|
||||
return ((BaseAsyncCreateCmd) asyncCmd).getResponse(jobId, objectId, objectEntityTable);
|
||||
String objUuid = (objectUuid == null) ? objectId.toString() : objectUuid;
|
||||
return ((BaseAsyncCreateCmd) asyncCmd).getResponse(jobId, objUuid);
|
||||
}
|
||||
|
||||
SerializationContext.current().setUuidTranslation(true);
|
||||
@ -463,6 +471,7 @@ public class ApiServer implements HttpRequestHandler {
|
||||
|
||||
// if the command is of the listXXXCommand, we will need to also return the
|
||||
// the job id and status if possible
|
||||
// For those listXXXCommand which we have already created DB views, this step is not needed since async job is joined in their db views.
|
||||
if (cmdObj instanceof BaseListCmd && !(cmdObj instanceof ListVMsCmd) && !(cmdObj instanceof ListRoutersCmd)
|
||||
&& !(cmdObj instanceof ListSecurityGroupsCmd)
|
||||
&& !(cmdObj instanceof ListTagsCmd)
|
||||
@ -790,9 +799,39 @@ public class ApiServer implements HttpRequestHandler {
|
||||
}
|
||||
|
||||
private boolean isCommandAvailable(User user, String commandName) {
|
||||
if (user == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Account account = _accountMgr.getAccount(user.getAccountId());
|
||||
if (account == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RoleType roleType = RoleType.Unknown;
|
||||
short accountType = account.getType();
|
||||
|
||||
// Account type to role type translation
|
||||
switch (accountType) {
|
||||
case Account.ACCOUNT_TYPE_ADMIN:
|
||||
roleType = RoleType.Admin;
|
||||
break;
|
||||
case Account.ACCOUNT_TYPE_DOMAIN_ADMIN:
|
||||
roleType = RoleType.DomainAdmin;
|
||||
break;
|
||||
case Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN:
|
||||
roleType = RoleType.ResourceAdmin;
|
||||
break;
|
||||
case Account.ACCOUNT_TYPE_NORMAL:
|
||||
roleType = RoleType.User;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
for (APIAccessChecker apiChecker : _apiAccessCheckers) {
|
||||
// Fail the checking if any checker fails to verify
|
||||
if (!apiChecker.canAccessAPI(user, commandName))
|
||||
if (!apiChecker.canAccessAPI(roleType, commandName))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@ -1,80 +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.api;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import com.cloud.uuididentity.dao.IdentityDao;
|
||||
import com.cloud.uuididentity.dao.IdentityDaoImpl;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import com.cloud.utils.IdentityProxy;
|
||||
|
||||
|
||||
public class IdentityTypeAdapter implements JsonSerializer<IdentityProxy>, JsonDeserializer<IdentityProxy> {
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(IdentityProxy src, Type srcType, JsonSerializationContext context) {
|
||||
if(SerializationContext.current().getUuidTranslation()) {
|
||||
assert(src != null);
|
||||
if(src.getValue() == null)
|
||||
return context.serialize(null);
|
||||
|
||||
IdentityDao identityDao = new IdentityDaoImpl();
|
||||
if(src.getTableName() != null) {
|
||||
String uuid = identityDao.getIdentityUuid(src.getTableName(), String.valueOf(src.getValue()));
|
||||
if(uuid == null)
|
||||
return context.serialize(null);
|
||||
|
||||
// Exceptions set the _idFieldName in the IdentityProxy structure. So if this field is not
|
||||
// null, prepare a structure of uuid and idFieldName and return the json representation of that.
|
||||
String idName = src.getidFieldName();
|
||||
if (idName != null) {
|
||||
// Prepare a structure.
|
||||
JsonObject jsonObj = new JsonObject();
|
||||
jsonObj.add("uuid", new JsonPrimitive(uuid));
|
||||
jsonObj.add("uuidProperty", new JsonPrimitive(idName));
|
||||
return jsonObj;
|
||||
}
|
||||
return new JsonPrimitive(uuid);
|
||||
} else {
|
||||
return new JsonPrimitive(String.valueOf(src.getValue()));
|
||||
}
|
||||
} else {
|
||||
return new Gson().toJsonTree(src);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IdentityProxy deserialize(JsonElement src, Type srcType,
|
||||
JsonDeserializationContext context) throws JsonParseException {
|
||||
|
||||
IdentityProxy obj = new IdentityProxy();
|
||||
JsonObject json = src.getAsJsonObject();
|
||||
obj.setTableName(json.get("_tableName").getAsString());
|
||||
if(json.get("_value") != null)
|
||||
obj.setValue(json.get("_value").getAsLong());
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
@ -37,7 +37,6 @@ import com.cloud.api.ApiResponseGsonHelper;
|
||||
import com.cloud.api.ApiServer;
|
||||
import org.apache.cloudstack.api.BaseCmd;
|
||||
import org.apache.cloudstack.api.ResponseObject;
|
||||
import com.cloud.utils.IdentityProxy;
|
||||
import com.cloud.utils.encoding.URLEncoder;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.uuididentity.dao.IdentityDao;
|
||||
@ -226,27 +225,17 @@ public class ApiResponseSerializer {
|
||||
subObj.setObjectName(serializedName.value());
|
||||
}
|
||||
serializeResponseObjXML(sb, subObj);
|
||||
} else if (value instanceof IdentityProxy) {
|
||||
// Only exception reponses carry a list of IdentityProxy objects.
|
||||
IdentityProxy idProxy = (IdentityProxy)value;
|
||||
String id = (idProxy.getValue() != null ? String.valueOf(idProxy.getValue()) : "");
|
||||
if(!id.isEmpty()) {
|
||||
IdentityDao identityDao = new IdentityDaoImpl();
|
||||
id = identityDao.getIdentityUuid(idProxy.getTableName(), id);
|
||||
}
|
||||
if(id != null && !id.isEmpty()) {
|
||||
// If this is the first IdentityProxy field encountered, put in a uuidList tag.
|
||||
if (!usedUuidList) {
|
||||
sb.append("<").append(serializedName.value()).append(">");
|
||||
usedUuidList = true;
|
||||
}
|
||||
sb.append("<uuid>").append(id).append("</uuid>");
|
||||
}
|
||||
// Append the new idFieldName property also.
|
||||
String idFieldName = idProxy.getidFieldName();
|
||||
if (idFieldName != null) {
|
||||
sb.append("<uuidProperty>").append(idFieldName).append("</uuidProperty>");
|
||||
}
|
||||
} else {
|
||||
// Only exception reponses carry a list of uuid
|
||||
// strings.
|
||||
// If this is the first IdentityProxy field
|
||||
// encountered, put in a uuidList tag.
|
||||
if (!usedUuidList) {
|
||||
sb.append("<").append(serializedName.value()).append(">");
|
||||
usedUuidList = true;
|
||||
}
|
||||
sb.append("<uuid>").append(value).append("</uuid>");
|
||||
// We have removed uuid property field due to removal of IdentityProxy class.
|
||||
}
|
||||
}
|
||||
if (usedUuidList) {
|
||||
@ -256,19 +245,6 @@ public class ApiResponseSerializer {
|
||||
} else if (fieldValue instanceof Date) {
|
||||
sb.append("<").append(serializedName.value()).append(">").append(BaseCmd.getDateString((Date) fieldValue)).
|
||||
append("</").append(serializedName.value()).append(">");
|
||||
} else if (fieldValue instanceof IdentityProxy) {
|
||||
IdentityProxy idProxy = (IdentityProxy)fieldValue;
|
||||
String id = (idProxy.getValue() != null ? String.valueOf(idProxy.getValue()) : "");
|
||||
if(!id.isEmpty()) {
|
||||
IdentityDao identityDao = new IdentityDaoImpl();
|
||||
if(idProxy.getTableName() != null) {
|
||||
id = identityDao.getIdentityUuid(idProxy.getTableName(), id);
|
||||
} else {
|
||||
s_logger.warn("IdentityProxy sanity check issue, invalid IdentityProxy table name found in class: " + obj.getClass().getName());
|
||||
}
|
||||
}
|
||||
if(id != null && !id.isEmpty())
|
||||
sb.append("<").append(serializedName.value()).append(">").append(id).append("</").append(serializedName.value()).append(">");
|
||||
} else {
|
||||
String resultString = escapeSpecialXmlChars(fieldValue.toString());
|
||||
if (!(obj instanceof ExceptionResponse)) {
|
||||
|
||||
@ -818,26 +818,29 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
String privateIP = router.getPrivateIpAddress();
|
||||
|
||||
if (privateIP != null) {
|
||||
boolean forVpc = router.getVpcId() != null;
|
||||
List<? extends Nic> routerNics = _nicDao.listByVmId(router.getId());
|
||||
for (Nic routerNic : routerNics) {
|
||||
Network network = _networkMgr.getNetwork(routerNic.getNetworkId());
|
||||
if (network.getTrafficType() == TrafficType.Public) {
|
||||
boolean forVpc = router.getVpcId() != null;
|
||||
//Send network usage command for public nic in VPC VR
|
||||
//Send network usage command for isolated guest nic of non VPC VR
|
||||
if ((forVpc && network.getTrafficType() == TrafficType.Public) || (!forVpc && network.getTrafficType() == TrafficType.Guest && network.getGuestType() == Network.GuestType.Isolated)) {
|
||||
final NetworkUsageCommand usageCmd = new NetworkUsageCommand(privateIP, router.getHostName(),
|
||||
forVpc, routerNic.getIp4Address());
|
||||
String routerType = router.getType().toString();
|
||||
UserStatisticsVO previousStats = _statsDao.findBy(router.getAccountId(),
|
||||
router.getDataCenterIdToDeployIn(), network.getId(), null, router.getId(), router.getType().toString());
|
||||
router.getDataCenterIdToDeployIn(), network.getId(), (forVpc ? routerNic.getIp4Address() : null), router.getId(), routerType);
|
||||
NetworkUsageAnswer answer = null;
|
||||
try {
|
||||
answer = (NetworkUsageAnswer) _agentMgr.easySend(router.getHostId(), usageCmd);
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Error while collecting network stats from router: "+router.getInstanceName()+" from host: "+router.getHostId(), e);
|
||||
s_logger.warn("Error while collecting network stats from router: " + router.getInstanceName() + " from host: " + router.getHostId(), e);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (answer != null) {
|
||||
if (!answer.getResult()) {
|
||||
s_logger.warn("Error while collecting network stats from router: "+router.getInstanceName()+" from host: "+router.getHostId() + "; details: " + answer.getDetails());
|
||||
s_logger.warn("Error while collecting network stats from router: " + router.getInstanceName() + " from host: " + router.getHostId() + "; details: " + answer.getDetails());
|
||||
continue;
|
||||
}
|
||||
Transaction txn = Transaction.open(Transaction.CLOUD_DB);
|
||||
@ -848,18 +851,18 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
}
|
||||
txn.start();
|
||||
UserStatisticsVO stats = _statsDao.lock(router.getAccountId(),
|
||||
router.getDataCenterIdToDeployIn(), network.getId(), routerNic.getIp4Address(), router.getId(), router.getType().toString());
|
||||
router.getDataCenterIdToDeployIn(), network.getId(), (forVpc ? routerNic.getIp4Address() : null), router.getId(), routerType);
|
||||
if (stats == null) {
|
||||
s_logger.warn("unable to find stats for account: " + router.getAccountId());
|
||||
continue;
|
||||
}
|
||||
|
||||
if(previousStats != null
|
||||
if (previousStats != null
|
||||
&& ((previousStats.getCurrentBytesReceived() != stats.getCurrentBytesReceived())
|
||||
|| (previousStats.getCurrentBytesSent() != stats.getCurrentBytesSent()))){
|
||||
|| (previousStats.getCurrentBytesSent() != stats.getCurrentBytesSent()))) {
|
||||
s_logger.debug("Router stats changed from the time NetworkUsageCommand was sent. " +
|
||||
"Ignoring current answer. Router: "+answer.getRouterName()+" Rcvd: " +
|
||||
answer.getBytesReceived()+ "Sent: " +answer.getBytesSent());
|
||||
"Ignoring current answer. Router: " + answer.getRouterName() + " Rcvd: " +
|
||||
answer.getBytesReceived() + "Sent: " + answer.getBytesSent());
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -867,7 +870,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Received # of bytes that's less than the last one. " +
|
||||
"Assuming something went wrong and persisting it. Router: " +
|
||||
answer.getRouterName()+" Reported: " + answer.getBytesReceived()
|
||||
answer.getRouterName() + " Reported: " + answer.getBytesReceived()
|
||||
+ " Stored: " + stats.getCurrentBytesReceived());
|
||||
}
|
||||
stats.setNetBytesReceived(stats.getNetBytesReceived() + stats.getCurrentBytesReceived());
|
||||
@ -877,7 +880,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Received # of bytes that's less than the last one. " +
|
||||
"Assuming something went wrong and persisting it. Router: " +
|
||||
answer.getRouterName()+" Reported: " + answer.getBytesSent()
|
||||
answer.getRouterName() + " Reported: " + answer.getBytesSent()
|
||||
+ " Stored: " + stats.getCurrentBytesSent());
|
||||
}
|
||||
stats.setNetBytesSent(stats.getNetBytesSent() + stats.getCurrentBytesSent());
|
||||
|
||||
@ -287,7 +287,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
_identityDao.initializeDefaultUuid("user_ip_address");
|
||||
_identityDao.initializeDefaultUuid("counter");
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
||||
private String getMountParent() {
|
||||
return getEnvironmentProperty("mount.parent");
|
||||
|
||||
@ -16,22 +16,17 @@
|
||||
// under the License.
|
||||
package com.cloud.servlet;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.PropertyConfigurator;
|
||||
import org.apache.log4j.xml.DOMConfigurator;
|
||||
|
||||
import com.cloud.api.ApiServer;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.server.ConfigurationServer;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.cloud.utils.PropertiesUtil;
|
||||
import com.cloud.utils.SerialVersionUID;
|
||||
import com.cloud.utils.component.ComponentContext;
|
||||
|
||||
@ -42,17 +37,15 @@ public class CloudStartupServlet extends HttpServlet implements ServletContextLi
|
||||
|
||||
@Override
|
||||
public void init() throws ServletException {
|
||||
initLog4j();
|
||||
|
||||
// Save Configuration Values
|
||||
ConfigurationServer c = ComponentContext.getComponent(ConfigurationServer.class);
|
||||
//ComponentLocator loc = ComponentLocator.getLocator(ConfigurationServer.Name);
|
||||
ConfigurationServer c = (ConfigurationServer)ComponentContext.getComponent(ConfigurationServer.Name);
|
||||
//ConfigurationServer c = new ConfigurationServerImpl();
|
||||
try {
|
||||
c.persistDefaultValues();
|
||||
|
||||
ManagementServer ms = ComponentContext.getComponent(ManagementServer.class);
|
||||
ms.startup();
|
||||
ManagementServer ms = (ManagementServer)ComponentContext.getComponent(ManagementServer.Name);
|
||||
ms.enableAdminUser("password");
|
||||
ApiServer.initApiServer(ms.getPropertiesFiles());
|
||||
ApiServer.initApiServer();
|
||||
} catch (InvalidParameterValueException ipve) {
|
||||
s_logger.error("Exception starting management server ", ipve);
|
||||
throw new ServletException (ipve.getMessage());
|
||||
@ -75,18 +68,4 @@ public class CloudStartupServlet extends HttpServlet implements ServletContextLi
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent sce) {
|
||||
}
|
||||
|
||||
private void initLog4j() {
|
||||
File file = PropertiesUtil.findConfigFile("log4j-cloud.xml");
|
||||
if (file != null) {
|
||||
s_logger.info("log4j configuration found at " + file.getAbsolutePath());
|
||||
DOMConfigurator.configureAndWatch(file.getAbsolutePath());
|
||||
} else {
|
||||
file = PropertiesUtil.findConfigFile("log4j-cloud.properties");
|
||||
if (file != null) {
|
||||
s_logger.info("log4j configuration found at " + file.getAbsolutePath());
|
||||
PropertyConfigurator.configureAndWatch(file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -219,14 +219,14 @@ class TestISO(cloudstackTestCase):
|
||||
# Finding the OsTypeId from Ostype
|
||||
ostypes = list_os_types(
|
||||
cls.api_client,
|
||||
description=self.services["ostype"]
|
||||
description=cls.services["ostype"]
|
||||
)
|
||||
if not isinstance(ostypes, list):
|
||||
raise unittest.SkipTest("OSTypeId for given description not found")
|
||||
|
||||
self.services["iso_1"]["ostypeid"] = ostypes[0].id
|
||||
self.services["iso_2"]["ostypeid"] = ostypes[0].id
|
||||
self.services["ostypeid"] = ostypes[0].id
|
||||
cls.services["iso_1"]["ostypeid"] = ostypes[0].id
|
||||
cls.services["iso_2"]["ostypeid"] = ostypes[0].id
|
||||
cls.services["ostypeid"] = ostypes[0].id
|
||||
|
||||
cls.iso_1 = Iso.create(
|
||||
cls.api_client,
|
||||
|
||||
21
tools/devcloud-kvm/README.md
Normal file
21
tools/devcloud-kvm/README.md
Normal file
@ -0,0 +1,21 @@
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
|
||||
===========================================================
|
||||
|
||||
This directory hosts configs for setting up the devcloud-kvm
|
||||
environment.
|
||||
97
tools/devcloud-kvm/devcloud-kvm.cfg
Normal file
97
tools/devcloud-kvm/devcloud-kvm.cfg
Normal file
@ -0,0 +1,97 @@
|
||||
{
|
||||
"zones": [
|
||||
{
|
||||
"name": "DevCloudKVM0",
|
||||
"physical_networks": [
|
||||
{
|
||||
"broadcastdomainrange": "Zone",
|
||||
"name": "test-network",
|
||||
"traffictypes": [
|
||||
{
|
||||
"typ": "Guest"
|
||||
},
|
||||
{
|
||||
"typ": "Management"
|
||||
}
|
||||
],
|
||||
"providers": [
|
||||
{
|
||||
"broadcastdomainrange": "ZONE",
|
||||
"name": "VirtualRouter"
|
||||
},
|
||||
{
|
||||
"broadcastdomainrange": "Pod",
|
||||
"name": "SecurityGroupProvider"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"dns2": "4.4.4.4",
|
||||
"dns1": "8.8.8.8",
|
||||
"securitygroupenabled": "true",
|
||||
"localstorageenabled": "true",
|
||||
"networktype": "Basic",
|
||||
"pods": [
|
||||
{
|
||||
"endip": "192.168.100.250",
|
||||
"name": "test00",
|
||||
"startip": "192.168.100.200",
|
||||
"guestIpRanges": [
|
||||
{
|
||||
"startip": "192.168.100.100",
|
||||
"endip": "192.168.100.199",
|
||||
"netmask": "255.255.255.0",
|
||||
"gateway": "192.168.100.1"
|
||||
}
|
||||
],
|
||||
"netmask": "255.255.255.0",
|
||||
"clusters": [
|
||||
{
|
||||
"clustername": "test000",
|
||||
"hypervisor": "KVM",
|
||||
"hosts": [
|
||||
{
|
||||
"username": "root",
|
||||
"url": "http://192.168.100.10/",
|
||||
"password": "password"
|
||||
}
|
||||
],
|
||||
"clustertype": "CloudManaged"
|
||||
}
|
||||
],
|
||||
"gateway": "192.168.100.1"
|
||||
}
|
||||
],
|
||||
"internaldns1": "192.168.100.10",
|
||||
"secondaryStorages": [
|
||||
{
|
||||
"url": "nfs://192.168.100.10:/nfs/secondary"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"logger": [
|
||||
{
|
||||
"name": "TestClient",
|
||||
"file": "/tmp/testclient.log"
|
||||
},
|
||||
{
|
||||
"name": "TestCase",
|
||||
"file": "/tmp/testcase.log"
|
||||
}
|
||||
],
|
||||
"mgtSvr": [
|
||||
{
|
||||
"mgtSvrIp": "127.0.0.1",
|
||||
"port": 8096
|
||||
}
|
||||
],
|
||||
"dbSvr":
|
||||
{
|
||||
"dbSvr": "127.0.0.1",
|
||||
"port": 3306,
|
||||
"user": "cloud",
|
||||
"passwd": "cloud",
|
||||
"db": "cloud"
|
||||
}
|
||||
}
|
||||
40
tools/devcloud-kvm/devcloud-kvm.sql
Normal file
40
tools/devcloud-kvm/devcloud-kvm.sql
Normal file
@ -0,0 +1,40 @@
|
||||
-- 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.
|
||||
|
||||
|
||||
INSERT INTO `cloud`.`disk_offering` (id, name, uuid, display_text, created, use_local_storage, type, disk_size) VALUES (17, 'tinyOffering', UUID(), 'tinyOffering', NOW(), 1, 'Service', 0);
|
||||
INSERT INTO `cloud`.`service_offering` (id, cpu, speed, ram_size) VALUES (17, 1, 100, 100);
|
||||
INSERT INTO `cloud`.`disk_offering` (id, name, uuid, display_text, created, type, disk_size) VALUES (18, 'tinyDiskOffering', UUID(), 'tinyDiskOffering', NOW(), 'Disk', 1073741824);
|
||||
INSERT INTO `cloud`.`configuration` (instance, name,value) VALUE('DEFAULT','router.ram.size', '100');
|
||||
INSERT INTO `cloud`.`configuration` (instance, name,value) VALUE('DEFAULT','router.cpu.mhz','100');
|
||||
INSERT INTO `cloud`.`configuration` (instance, name,value) VALUE('DEFAULT','console.ram.size','100');
|
||||
INSERT INTO `cloud`.`configuration` (instance, name,value) VALUE('DEFAULT','console.cpu.mhz', '100');
|
||||
INSERT INTO `cloud`.`configuration` (instance, name,value) VALUE('DEFAULT','ssvm.ram.size','100');
|
||||
INSERT INTO `cloud`.`configuration` (instance, name,value) VALUE('DEFAULT','ssvm.cpu.mhz','100');
|
||||
INSERT INTO `cloud`.`configuration` (instance, name, value) VALUE('DEFAULT', 'system.vm.use.local.storage', 'true');
|
||||
INSERT INTO `cloud`.`configuration` (instance, name, value) VALUE('DEFAULT', 'expunge.workers', '3');
|
||||
INSERT INTO `cloud`.`configuration` (instance, name, value) VALUE('DEFAULT', 'expunge.delay', '60');
|
||||
INSERT INTO `cloud`.`configuration` (instance, name, value) VALUE('DEFAULT', 'expunge.interval', '60');
|
||||
INSERT INTO `cloud`.`configuration` (instance, name, value) VALUE('DEFAULT', 'enable.ec2.api', 'true');
|
||||
INSERT INTO `cloud`.`configuration` (instance, name, value) VALUE('DEFAULT', 'enable.s3.api', 'true');
|
||||
INSERT INTO `cloud`.`configuration` (instance, name, value) VALUE('DEFAULT', 'host', '192.168.100.10');
|
||||
INSERT INTO `cloud`.`configuration` (instance, name, value) VALUE('DEFAULT', 'management.network.cidr', '192.168.100.0/24');
|
||||
INSERT INTO `cloud`.`configuration` (instance, name, value) VALUE('DEFAULT', 'secstorage.allowed.internal.sites', '192.168.0.0/8');
|
||||
UPDATE `cloud`.`configuration` SET value='10' where name = 'storage.overprovisioning.factor';
|
||||
UPDATE `cloud`.`configuration` SET value='10' where name = 'cpu.overprovisioning.factor';
|
||||
UPDATE `cloud`.`configuration` SET value='10' where name = 'mem.overprovisioning.factor';
|
||||
UPDATE `cloud`.`vm_template` SET unique_name="tiny Linux",name="tiny Linux",url="https://dl.dropbox.com/u/678991/cloudstack-extras/ttylinux_pv.qcow2",checksum="81dcf4b4ca05a3b637a040e851568f29",display_text="tiny Linux",format='QCOW2',hypervisor_type='KVM' where id=5;
|
||||
138
tools/devcloud-kvm/pom.xml
Normal file
138
tools/devcloud-kvm/pom.xml
Normal file
@ -0,0 +1,138 @@
|
||||
<!-- 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. -->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>cloud-devcloud-kvm</artifactId>
|
||||
<name>Apache CloudStack Developer Tools</name>
|
||||
<packaging>pom</packaging>
|
||||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack</artifactId>
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.21</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<defaultGoal>install</defaultGoal>
|
||||
</build>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>deploydb</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>deploydb</name>
|
||||
</property>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>properties-maven-plugin</artifactId>
|
||||
<version>1.0-alpha-2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>initialize</phase>
|
||||
<goals>
|
||||
<goal>read-project-properties</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<files>
|
||||
<file>${project.parent.basedir}/utils/conf/db.properties</file>
|
||||
<file>${project.parent.basedir}/utils/conf/db.properties.override</file>
|
||||
</files>
|
||||
<quiet>true</quiet>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>sql-maven-plugin</artifactId>
|
||||
<version>1.5</version>
|
||||
<dependencies>
|
||||
<!-- specify the dependent jdbc driver here -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>${cs.mysql.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<configuration>
|
||||
<driver>org.gjt.mm.mysql.Driver</driver>
|
||||
<url>jdbc:mysql://${db.cloud.host}:${db.cloud.port}/cloud</url>
|
||||
<username>${db.cloud.username}</username>
|
||||
<password>${db.cloud.password}</password>
|
||||
<!--all executions are ignored if -Dmaven.test.skip=true -->
|
||||
<skip>${maven.test.skip}</skip>
|
||||
<forceMojoExecution>true</forceMojoExecution>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>create-schema</id>
|
||||
<phase>process-test-resources</phase>
|
||||
<goals>
|
||||
<goal>execute</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<srcFiles>
|
||||
<srcFile>${basedir}/devcloud-kvm.sql</srcFile>
|
||||
</srcFiles>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>deploysvr</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>deploysvr</name>
|
||||
</property>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<executable>python</executable>
|
||||
<arguments>
|
||||
<argument>../marvin/marvin/deployDataCenter.py</argument>
|
||||
<argument>-i</argument>
|
||||
<argument>devcloud-kvm.cfg</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
@ -1,60 +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
|
||||
// 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.utils;
|
||||
|
||||
public class IdentityProxy {
|
||||
private String _tableName;
|
||||
private Long _value;
|
||||
private String _idFieldName;
|
||||
|
||||
public IdentityProxy() {
|
||||
}
|
||||
|
||||
public IdentityProxy(String tableName) {
|
||||
_tableName = tableName;
|
||||
}
|
||||
|
||||
public IdentityProxy(String tableName, Long id, String fieldName) {
|
||||
_tableName = tableName;
|
||||
_value = id;
|
||||
_idFieldName = fieldName;
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return _tableName;
|
||||
}
|
||||
|
||||
public void setTableName(String tableName) {
|
||||
_tableName = tableName;
|
||||
}
|
||||
|
||||
public Long getValue() {
|
||||
return _value;
|
||||
}
|
||||
|
||||
public void setValue(Long value) {
|
||||
_value = value;
|
||||
}
|
||||
|
||||
public void setidFieldName(String value) {
|
||||
_idFieldName = value;
|
||||
}
|
||||
|
||||
public String getidFieldName() {
|
||||
return _idFieldName;
|
||||
}
|
||||
}
|
||||
@ -17,7 +17,6 @@
|
||||
package com.cloud.utils.exception;
|
||||
|
||||
import com.cloud.utils.AnnotationHelper;
|
||||
import com.cloud.utils.IdentityProxy;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
|
||||
@ -840,11 +840,9 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
|
||||
|
||||
VmwareHypervisorHostResourceSummary summary = new VmwareHypervisorHostResourceSummary();
|
||||
|
||||
HostConnectInfo hostInfo = _context.getService().queryHostConnectionInfo(_mor);
|
||||
HostHardwareSummary hardwareSummary = hostInfo.getHost().getHardware();
|
||||
|
||||
HostHardwareSummary hardwareSummary = getHostHardwareSummary();
|
||||
// TODO: not sure how hyper-thread is counted in VMware resource pool
|
||||
summary.setCpuCount(hardwareSummary.getNumCpuCores()*hardwareSummary.getNumCpuPkgs());
|
||||
summary.setCpuCount(hardwareSummary.getNumCpuCores());
|
||||
summary.setMemoryBytes(hardwareSummary.getMemorySize());
|
||||
summary.setCpuSpeed(hardwareSummary.getCpuMhz());
|
||||
|
||||
@ -922,14 +920,13 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
|
||||
ComputeResourceSummary resourceSummary = new ComputeResourceSummary();
|
||||
|
||||
// TODO: not sure how hyper-threading is counted in VMware
|
||||
short totalCores = (short)(hardwareSummary.getNumCpuCores()*hardwareSummary.getNumCpuPkgs());
|
||||
resourceSummary.setNumCpuCores(totalCores);
|
||||
resourceSummary.setNumCpuCores(hardwareSummary.getNumCpuCores());
|
||||
|
||||
// Note: memory here is in Byte unit
|
||||
resourceSummary.setTotalMemory(hardwareSummary.getMemorySize());
|
||||
|
||||
// Total CPU is based on socket x core x Mhz
|
||||
int totalCpu = hardwareSummary.getCpuMhz() * totalCores;
|
||||
// Total CPU is based on (# of cores) x Mhz
|
||||
int totalCpu = hardwareSummary.getCpuMhz() * hardwareSummary.getNumCpuCores();
|
||||
resourceSummary.setTotalCpu(totalCpu);
|
||||
|
||||
HostListSummaryQuickStats stats = getHostQuickStats();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user