Merge branch '3.0.x' of ssh://git.cloud.com/var/lib/git/cloudstack-oss into 3.0.x

This commit is contained in:
Sanjay Tripathi 2012-05-08 12:35:26 +05:30
commit 62fa67409d
23 changed files with 513 additions and 144 deletions

View File

@ -14,7 +14,7 @@
<property name="hibernate.order_updates">true</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<property name="show_sql">false</property>
<!-- to debug hibernate generated SQL, open following configuration property -->
<!--
<property name="show_sql">true</property>

View File

@ -14,7 +14,7 @@
<property name="hibernate.order_updates">true</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<property name="show_sql">false</property>
<!-- to debug hibernate generated SQL, open following configuration property -->
<!--
<property name="show_sql">true</property>

View File

@ -1,68 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<!-- ================================= -->
<!-- Preserve messages in a local file -->
<!-- ================================= -->
<!-- A time/date based rolling appender -->
<appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="${catalina.base}/logs/cloudbridge.log"/>
<param name="Append" value="true"/>
<param name="Threshold" value="DEBUG"/>
<!-- Rollover at midnight each day -->
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%c{3}] (%t:%x) %m%n"/>
</layout>
</appender>
<!-- ============================== -->
<!-- Append messages to the console -->
<!-- ============================== -->
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out"/>
<param name="Threshold" value="DEBUG"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ABSOLUTE} %5p %c{1}:%L - %m%n"/>
</layout>
</appender>
<!-- ================ -->
<!-- Limit categories -->
<!-- ================ -->
<category name="com.cloud">
<priority value="DEBUG"/>
</category>
<!-- Limit the org.apache category to INFO as its DEBUG is verbose -->
<category name="org.apache">
<priority value="INFO"/>
</category>
<category name="org">
<priority value="INFO"/>
</category>
<category name="net">
<priority value="INFO"/>
</category>
<!-- ======================= -->
<!-- Setup the Root category -->
<!-- ======================= -->
<root>
<level value="INFO"/>
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</root>
</log4j:configuration>

View File

@ -37,8 +37,9 @@ public class EC2MainServlet extends HttpServlet{
if(value != null){
isEC2APIEnabled = Boolean.valueOf(value);
}
PersistContext.commitTransaction(true);
}finally {
PersistContext.commitTransaction(true);
PersistContext.closeSession(true);
}

View File

@ -36,6 +36,8 @@ import com.cloud.bridge.service.core.ec2.EC2DescribeAddresses;
import com.cloud.bridge.service.core.ec2.EC2DescribeAddressesResponse;
import com.cloud.bridge.service.core.ec2.EC2DescribeAvailabilityZones;
import com.cloud.bridge.service.core.ec2.EC2DescribeAvailabilityZonesResponse;
import com.cloud.bridge.service.core.ec2.EC2DescribeImageAttribute;
import com.cloud.bridge.service.core.ec2.EC2DescribeImages;
import com.cloud.bridge.service.core.ec2.EC2DescribeImagesResponse;
import com.cloud.bridge.service.core.ec2.EC2DescribeInstances;
@ -53,11 +55,14 @@ import com.cloud.bridge.service.core.ec2.EC2Engine;
import com.cloud.bridge.service.core.ec2.EC2Filter;
import com.cloud.bridge.service.core.ec2.EC2GroupFilterSet;
import com.cloud.bridge.service.core.ec2.EC2Image;
import com.cloud.bridge.service.core.ec2.EC2ImageAttributes;
import com.cloud.bridge.service.core.ec2.EC2ImageAttributes.ImageAttribute;
import com.cloud.bridge.service.core.ec2.EC2ImportKeyPair;
import com.cloud.bridge.service.core.ec2.EC2Instance;
import com.cloud.bridge.service.core.ec2.EC2InstanceFilterSet;
import com.cloud.bridge.service.core.ec2.EC2IpPermission;
import com.cloud.bridge.service.core.ec2.EC2KeyPairFilterSet;
import com.cloud.bridge.service.core.ec2.EC2ModifyImageAttribute;
import com.cloud.bridge.service.core.ec2.EC2PasswordData;
import com.cloud.bridge.service.core.ec2.EC2RebootInstances;
import com.cloud.bridge.service.core.ec2.EC2RegisterImage;
@ -76,6 +81,7 @@ import com.cloud.bridge.service.core.ec2.EC2Volume;
import com.cloud.bridge.service.core.ec2.EC2VolumeFilterSet;
import com.cloud.bridge.service.exception.EC2ServiceException;
import com.cloud.bridge.service.exception.EC2ServiceException.ClientError;
import com.cloud.bridge.service.exception.EC2ServiceException.ServerError;
import com.cloud.bridge.util.EC2RestAuth;
@ -226,18 +232,25 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
/**
* This only supports a query about description.
*/
public DescribeImageAttributeResponse describeImageAttribute(DescribeImageAttribute describeImageAttribute) {
EC2DescribeImages request = new EC2DescribeImages();
DescribeImageAttributeType diat = describeImageAttribute.getDescribeImageAttribute();
DescribeImageAttributesGroup diag = diat.getDescribeImageAttributesGroup();
EmptyElementType description = diag.getDescription();
public DescribeImageAttributeResponse describeImageAttribute(DescribeImageAttribute describeImageAttribute) {
EC2DescribeImageAttribute request = new EC2DescribeImageAttribute();
DescribeImageAttributeType diat = describeImageAttribute.getDescribeImageAttribute();
DescribeImageAttributesGroup diag = diat.getDescribeImageAttributesGroup();
EmptyElementType description = diag.getDescription();
EmptyElementType launchPermission = diag.getLaunchPermission();
if ( null != description ) {
request.setImageId(diat.getImageId());
request.setAttribute(ImageAttribute.description);
return toDescribeImageAttributeResponse( engine.describeImageAttribute( request ));
}else if(launchPermission != null){
request.setImageId(diat.getImageId());
request.setAttribute(ImageAttribute.launchPermission);
return toDescribeImageAttributeResponse( engine.describeImageAttribute( request ));
}
else throw new EC2ServiceException( ClientError.Unsupported, "Unsupported - only description or launchPermission supported" );
}
if ( null != description ) {
request.addImageSet(diat.getImageId());
return toDescribeImageAttributeResponse( engine.describeImages( request ));
}
else throw new EC2ServiceException( "Unsupported - only description supported", 501 );
}
public DescribeImagesResponse describeImages(DescribeImages describeImages) {
EC2DescribeImages request = new EC2DescribeImages();
@ -280,7 +293,7 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
request.addInstanceId( diat.getInstanceId());
return toDescribeInstanceAttributeResponse( engine.describeInstances( request ));
}
throw new EC2ServiceException( "Unsupported - only instanceType supported", 501 );
throw new EC2ServiceException( ClientError.Unsupported, "Unsupported - only instanceType supported");
}
@ -446,26 +459,50 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
}
public ModifyImageAttributeResponse modifyImageAttribute(ModifyImageAttribute modifyImageAttribute) {
// TODO: This is broken
EC2Image request = new EC2Image();
EC2ModifyImageAttribute request = new EC2ModifyImageAttribute();
ModifyImageAttributeType miat = modifyImageAttribute.getModifyImageAttribute();
ModifyImageAttributeTypeChoice_type0 item = miat.getModifyImageAttributeTypeChoice_type0();
AttributeValueType description = item.getDescription();
/*
LaunchPermissionOperationType launchPermOp = item.getLaunchPermission();
ProductCodeListType prodCodeList =item.getProductCodes();
*/
if (null != description) {
request.setId( miat.getImageId());
request.setImageId(miat.getImageId());
request.setAttribute(ImageAttribute.description);
request.setDescription(description.getValue());
return toModifyImageAttributeResponse( engine.modifyImageAttribute( request ));
}else if(launchPermOp != null){
request.setImageId(miat.getImageId());
request.setAttribute(ImageAttribute.launchPermission);
if(launchPermOp.getAdd() != null){
request.setLaunchPermOperation(EC2ModifyImageAttribute.Operation.add);
setAccountOrGroupList(launchPermOp.getAdd().getItem(), request);
}else if(launchPermOp.getRemove() != null){
request.setLaunchPermOperation(EC2ModifyImageAttribute.Operation.remove);
setAccountOrGroupList(launchPermOp.getRemove().getItem(), request);
}
return toModifyImageAttributeResponse( engine.modifyImageAttribute( request ));
}
throw new EC2ServiceException( "Unsupported - can only modify image description", 501 );
throw new EC2ServiceException( ClientError.Unsupported, "Unsupported - can only modify image description or launchPermission");
}
private void setAccountOrGroupList(LaunchPermissionItemType[] items, EC2ModifyImageAttribute request){
List<String> launchPermissionAccountsOrGroupList = new ArrayList<String>();
for (LaunchPermissionItemType lpItem : items) {
if(lpItem.getGroup() != null){
launchPermissionAccountsOrGroupList.add(lpItem.getGroup());
}else if(lpItem.getUserId() != null){
launchPermissionAccountsOrGroupList.add(lpItem.getUserId());
}
}
request.setLaunchPermissionAccountsOrGroupList(launchPermissionAccountsOrGroupList);
}
/**
* Did not find a matching service offering so for now we just return disabled
* for each instance request. We could verify that all of the specified instances
@ -541,12 +578,16 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
*/
public ResetImageAttributeResponse resetImageAttribute(ResetImageAttribute resetImageAttribute) {
EC2Image request = new EC2Image();
EC2ModifyImageAttribute request = new EC2ModifyImageAttribute();
ResetImageAttributeType riat = resetImageAttribute.getResetImageAttribute();
request.setId( riat.getImageId());
request.setDescription( "" );
return toResetImageAttributeResponse( engine.modifyImageAttribute( request ));
EmptyElementType elementType = riat.getResetImageAttributesGroup().getLaunchPermission();
if(elementType != null){
request.setImageId( riat.getImageId());
request.setAttribute(ImageAttribute.launchPermission);
request.setLaunchPermOperation(EC2ModifyImageAttribute.Operation.reset);
return toResetImageAttributeResponse( engine.modifyImageAttribute( request ));
}
throw new EC2ServiceException( ClientError.Unsupported, "Unsupported - can only reset image launchPermission" );
}
/**
@ -678,6 +719,45 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
return response;
}
public static DescribeImageAttributeResponse toDescribeImageAttributeResponse(EC2ImageAttributes engineResponse) {
DescribeImageAttributeResponse response = new DescribeImageAttributeResponse();
DescribeImageAttributeResponseType param1 = new DescribeImageAttributeResponseType();
if (engineResponse != null ) {
DescribeImageAttributeResponseTypeChoice_type0 param2 = new DescribeImageAttributeResponseTypeChoice_type0();
if(engineResponse.getIsPublic()){
LaunchPermissionListType param3 = new LaunchPermissionListType();
LaunchPermissionItemType param4 = new LaunchPermissionItemType();
param4.setGroup("all");
param3.addItem(param4);
param2.setLaunchPermission(param3);
}else if(engineResponse.getAccountNamesWithLaunchPermission() != null){
LaunchPermissionListType param3 = new LaunchPermissionListType();
for(String accountName : engineResponse.getAccountNamesWithLaunchPermission()){
LaunchPermissionItemType param4 = new LaunchPermissionItemType();
param4.setUserId(accountName);
param3.addItem(param4);
}
param2.setLaunchPermission(param3);
}else if(engineResponse.getDescription() != null){
NullableAttributeValueType param3 = new NullableAttributeValueType();
param3.setValue( engineResponse.getDescription());
param2.setDescription( param3 );
}
param1.setDescribeImageAttributeResponseTypeChoice_type0( param2 );
param1.setImageId(engineResponse.getImageId());
}
param1.setRequestId( UUID.randomUUID().toString());
response.setDescribeImageAttributeResponse( param1 );
return response;
}
public static ModifyImageAttributeResponse toModifyImageAttributeResponse( boolean engineResponse ) {
ModifyImageAttributeResponse response = new ModifyImageAttributeResponse();
ModifyImageAttributeResponseType param1 = new ModifyImageAttributeResponseType();

View File

@ -198,7 +198,7 @@ public class ServiceProvider {
if(logger.isInfoEnabled())
logger.info("Initializing ServiceProvider...");
File file = ConfigurationHelper.findConfigurationFile("log4j-cloud-bridge.xml");
File file = ConfigurationHelper.findConfigurationFile("log4j-cloud.xml");
if(file != null) {
System.out.println("Log4j configuration from : " + file.getAbsolutePath());
DOMConfigurator.configureAndWatch(file.getAbsolutePath(), 10000);
@ -327,6 +327,7 @@ public class ServiceProvider {
try {
result = method.invoke(serviceObject, args);
PersistContext.commitTransaction();
PersistContext.commitTransaction(true);
} catch (PersistException e) {
} catch (SessionException e) {
} catch(Throwable e) {
@ -345,6 +346,7 @@ public class ServiceProvider {
}
} finally {
PersistContext.closeSession();
PersistContext.closeSession(true);
}
return result;
}

View File

@ -0,0 +1,46 @@
/*
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.cloud.bridge.service.core.ec2;
import com.cloud.bridge.service.core.ec2.EC2ImageAttributes.ImageAttribute;
public class EC2DescribeImageAttribute {
private String imageId = null; //AMI id
private ImageAttribute attribute = null;
public EC2DescribeImageAttribute() {
}
public void setAttribute(ImageAttribute attribute) {
this.attribute = attribute;
}
public ImageAttribute getAttribute() {
return attribute;
}
public void setImageId(String imageId) {
this.imageId = imageId;
}
public String getImageId() {
return imageId;
}
}

View File

@ -31,11 +31,14 @@ import java.util.UUID;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.log4j.Logger;
import org.hibernate.ejb.criteria.expression.UnaryArithmeticOperation.Operation;
import org.xml.sax.SAXException;
import com.cloud.bridge.persist.dao.CloudStackSvcOfferingDao;
import com.cloud.bridge.persist.dao.OfferingDao;
import com.cloud.bridge.service.UserContext;
import com.cloud.bridge.service.core.ec2.EC2ImageAttributes.ImageAttribute;
import com.cloud.bridge.service.exception.EC2ServiceException;
import com.cloud.bridge.service.exception.EC2ServiceException.ClientError;
import com.cloud.bridge.service.exception.EC2ServiceException.ServerError;
@ -59,6 +62,7 @@ import com.cloud.stack.models.CloudStackSecurityGroupIngress;
import com.cloud.stack.models.CloudStackServiceOffering;
import com.cloud.stack.models.CloudStackSnapshot;
import com.cloud.stack.models.CloudStackTemplate;
import com.cloud.stack.models.CloudStackTemplatePermission;
import com.cloud.stack.models.CloudStackUser;
import com.cloud.stack.models.CloudStackUserVm;
import com.cloud.stack.models.CloudStackVolume;
@ -518,6 +522,34 @@ public class EC2Engine {
throw new EC2ServiceException(ServerError.InternalError, e.getMessage() != null ? e.getMessage() : "An unexpected error occurred.");
}
}
/** REST API calls this method.
* Modify an existing template
*
* @param request
* @return
*/
public boolean modifyImageAttribute( EC2Image request )
{
// TODO: This is incomplete
EC2DescribeImagesResponse images = new EC2DescribeImagesResponse();
try {
images = listTemplates( request.getId(), images );
EC2Image[] imageSet = images.getImageSet();
CloudStackTemplate resp = getApi().updateTemplate(request.getId(), null, request.getDescription(), null, imageSet[0].getName(), null, null);
if (resp != null) {
return true;
}
return false;
} catch( Exception e ) {
logger.error( "EC2 ModifyImage - ", e);
throw new EC2ServiceException(ServerError.InternalError, e.getMessage());
}
}
/**
* Modify an existing template
@ -525,25 +557,87 @@ public class EC2Engine {
* @param request
* @return
*/
public boolean modifyImageAttribute( EC2Image request )
public boolean modifyImageAttribute( EC2ModifyImageAttribute request )
{
// TODO: This is incomplete
EC2DescribeImagesResponse images = new EC2DescribeImagesResponse();
try {
if(request.getAttribute().equals(ImageAttribute.launchPermission)){
String accounts = "";
Boolean isPublic = null;
EC2ModifyImageAttribute.Operation operation = request.getLaunchPermOperation();
List<String> accountOrGroupList = request.getLaunchPermissionAccountsList();
if(accountOrGroupList != null && !accountOrGroupList.isEmpty()){
boolean first = true;
for(String accountOrGroup : accountOrGroupList){
if("all".equalsIgnoreCase(accountOrGroup)){
if(operation.equals(EC2ModifyImageAttribute.Operation.add)){
isPublic = true;
}else{
isPublic = false;
}
}else{
if(!first){
accounts = accounts + ",";
}
accounts = accounts + accountOrGroup;
first = false;
}
}
}
CloudStackInfoResponse resp = getApi().updateTemplatePermissions(request.getImageId(), accounts, null, null, isPublic, operation.toString());
return resp.getSuccess();
}else if(request.getAttribute().equals(ImageAttribute.description)){
CloudStackTemplate resp = getApi().updateTemplate(request.getImageId(), null, request.getDescription(), null, null, null, null);
if (resp != null) {
return true;
}
return false;
}
try {
images = listTemplates( request.getId(), images );
EC2Image[] imageSet = images.getImageSet();
CloudStackTemplate resp = getApi().updateTemplate(request.getId(), null, request.getDescription(), null, imageSet[0].getName(), null, null);
if (resp != null) {
return true;
}
return false;
} catch( Exception e ) {
logger.error( "EC2 ModifyImage - ", e);
throw new EC2ServiceException(ServerError.InternalError, e.getMessage());
}
} catch (Exception e) {
logger.error( "EC2 modifyImageAttribute - ", e);
throw new EC2ServiceException(ServerError.InternalError, e.getMessage());
}
return false;
}
public EC2ImageAttributes describeImageAttribute(EC2DescribeImageAttribute request) {
EC2ImageAttributes imageAtts = new EC2ImageAttributes();
try {
imageAtts.setImageId(request.getImageId());
if(request.getAttribute().equals(ImageAttribute.launchPermission)){
CloudStackTemplatePermission tempPerm = getApi().listTemplatePermissions(request.getImageId(), null, null);
if(tempPerm != null){
imageAtts.setDomainId(tempPerm.getDomainId());
List<String> accntList = tempPerm.getAccounts();
imageAtts.setAccountNamesWithLaunchPermission(accntList);
imageAtts.setIsPublic(tempPerm.getIsPublic());
}
}else if(request.getAttribute().equals(ImageAttribute.description)){
EC2DescribeImagesResponse descriptionResp = new EC2DescribeImagesResponse();
listTemplates(request.getImageId(), descriptionResp);
if(descriptionResp.getImageSet() != null){
EC2Image[] images = descriptionResp.getImageSet();
imageAtts.setDescription(images[0].getDescription());
}
}
} catch (Exception e) {
logger.error( "EC2 describeImageAttribute - ", e);
throw new EC2ServiceException(ServerError.InternalError, e.getMessage());
}
return imageAtts;
}
/**
* If given a specific list of snapshots of interest, then only values from those snapshots are returned.
@ -1283,7 +1377,7 @@ public class EC2Engine {
}
if ( canCreateInstances < request.getMaxCount())
createInstances = canCreateInstances;
createInstances = request.getMinCount();
else
createInstances = request.getMaxCount();
@ -1701,6 +1795,11 @@ public class EC2Engine {
}
instances.addInstance(ec2Vm);
}
}else{
if(instanceId != null){
//no such instance found
throw new EC2ServiceException(ServerError.InternalError, "Instance:" + instanceId + " not found");
}
}
return instances;
}

View File

@ -0,0 +1,86 @@
/*
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.cloud.bridge.service.core.ec2;
import java.util.List;
public class EC2ImageAttributes {
private String imageId;
private String description;
private boolean isPublic;
private List<String> accountNamesWithLaunchPermission;
private String domainId;
public enum ImageAttribute{
description,
launchPermission,
kernel,
ramdisk,
productCodes,
blockDeviceMapping
};
public EC2ImageAttributes() {
imageId = null;
description = null;
isPublic = false;
accountNamesWithLaunchPermission= null;
domainId = null;
}
public void setImageId( String imageId ) {
this.imageId = imageId;
}
public String getImageId() {
return this.imageId;
}
public void setDescription( String description ) {
this.description = description;
}
public String getDescription() {
return this.description;
}
public void setIsPublic( boolean isPublic ) {
this.isPublic = isPublic;
}
public boolean getIsPublic() {
return this.isPublic;
}
public String getDomainId() {
return domainId;
}
public void setDomainId(String domainId) {
this.domainId = domainId;
}
public void setAccountNamesWithLaunchPermission(List<String> accountNamesWithLaunchPermission) {
this.accountNamesWithLaunchPermission = accountNamesWithLaunchPermission;
}
public List<String> getAccountNamesWithLaunchPermission() {
return accountNamesWithLaunchPermission;
}
}

View File

@ -55,10 +55,10 @@ public class EC2InstanceFilterSet {
String value = (String) filterTypes.get( filterName );
if (null == value)
throw new EC2ServiceException( "Unsupported filter [" + filterName + "] - 1", 501 );
throw new EC2ServiceException( "Unsupported filter [" + filterName + "]", 501 );
if (null != value && value.equalsIgnoreCase( "null" ))
throw new EC2ServiceException( "Unsupported filter [" + filterName + "] - 2", 501 );
throw new EC2ServiceException( "Unsupported filter [" + filterName + "]", 501 );
// ToDo we could add checks to make sure the type of a filters value is correct (e.g., an integer)
filterSet.add( param );

View File

@ -0,0 +1,94 @@
/*
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.cloud.bridge.service.core.ec2;
import java.util.List;
import com.cloud.bridge.service.core.ec2.EC2ImageAttributes.ImageAttribute;
public class EC2ModifyImageAttribute {
private String imageId = null; //AMI id
private ImageAttribute attribute = null;
private String description;
private Boolean isPublic = null;
private Operation launchPermOperation = null;
public enum Operation{
add,
remove,
reset;
}
private List<String> launchPermissionAccountsOrGroupList;
public EC2ModifyImageAttribute() {
}
public void setAttribute(ImageAttribute attribute) {
this.attribute = attribute;
}
public ImageAttribute getAttribute() {
return attribute;
}
public void setImageId(String imageId) {
this.imageId = imageId;
}
public String getImageId() {
return imageId;
}
public void setDescription( String description ) {
this.description = description;
}
public String getDescription() {
return this.description;
}
public void setLaunchPermissionAccountsOrGroupList(List<String> launchPermissionAccountsOrGroupList) {
this.launchPermissionAccountsOrGroupList = launchPermissionAccountsOrGroupList;
}
public List<String> getLaunchPermissionAccountsList() {
return launchPermissionAccountsOrGroupList;
}
public void setLaunchPermOperation( Operation launchPermOperation ) {
this.launchPermOperation = launchPermOperation;
}
public Operation getLaunchPermOperation() {
return this.launchPermOperation;
}
public void setIsPublic(Boolean isPublic) {
this.isPublic = isPublic;
}
public Boolean getIsPublic() {
return isPublic;
}
}

View File

@ -29,7 +29,7 @@ public class EC2ServiceException extends RuntimeException {
InsufficientInstanceCapacity("Server.InsufficientInstanceCapacity", 500),
InsufficientReservedInstanceCapacity("Server.InsufficientReservedInstanceCapacity", 500),
InternalError("Server.InternalError", 500),
Unavailable("Server.Unavailable", 500);
Unavailable("Server.Unavailable", 501);
private String errorString;
private int httpErrorCode;
@ -126,7 +126,7 @@ public class EC2ServiceException extends RuntimeException {
}
public EC2ServiceException(String message, int errorCode) {
super(message);
super(message, new AxisFault(message, new QName("Error")));
this.httpErrorCode = errorCode;
}

View File

@ -348,7 +348,7 @@ public class CloudStackApi {
if (cmd != null)
cmd.setParam(ApiConstants.ID, id);
// TODO: This probably isn't right. Need to test with an instance that has a VM Password
return _client.call(cmd, apiKey, secretKey, true, ApiConstants.GET_VM_PASSWORD_RESPONSE, null, CloudStackPasswordData.class);
return _client.call(cmd, apiKey, secretKey, true, ApiConstants.GET_VM_PASSWORD_RESPONSE, ApiConstants.PASSWORD, CloudStackPasswordData.class);
}
// Templates
@ -566,15 +566,15 @@ public class CloudStackApi {
* @return
* @throws Exception
*/
public List<CloudStackTemplatePermission> listTemplatePermissions(String id, String account, String domainId) throws Exception {
public CloudStackTemplatePermission listTemplatePermissions(String id, String account, String domainId) throws Exception {
CloudStackCommand cmd = new CloudStackCommand(ApiConstants.LIST_TEMPLATE_PERMISSIONS);
if (cmd != null) {
cmd.setParam(ApiConstants.ID, id);
if (account != null) cmd.setParam(ApiConstants.ACCOUNT, account);
if (domainId != null) cmd.setParam(ApiConstants.DOMAIN_ID, domainId);
}
return _client.listCall(cmd, apiKey, secretKey, ApiConstants.LIST_TEMPLATE_PERMISSIONS_RESPONSE, ApiConstants.TEMPLATE_PERMISSION,
new TypeToken<List<CloudStackTemplatePermission>>() {}.getType());
return _client.call(cmd, apiKey, secretKey, false, ApiConstants.LIST_TEMPLATE_PERMISSIONS_RESPONSE, ApiConstants.TEMPLATE_PERMISSION,
CloudStackTemplatePermission.class);
}
/**

View File

@ -26,13 +26,13 @@ import com.google.gson.annotations.SerializedName;
*/
public class CloudStackTemplatePermission {
@SerializedName(ApiConstants.ID)
private Long id;
private String id;
@SerializedName(ApiConstants.IS_PUBLIC)
private Boolean isPublic;
@SerializedName(ApiConstants.DOMAIN_ID)
private Long domainId;
private String domainId;
@SerializedName(ApiConstants.ACCOUNT)
private List<CloudStackAccount> accounts;
private List<String> accounts;
/**
@ -45,7 +45,7 @@ public class CloudStackTemplatePermission {
/**
* @return the id
*/
public Long getId() {
public String getId() {
return id;
}
@ -61,7 +61,7 @@ public class CloudStackTemplatePermission {
/**
* @return the domainId
*/
public Long getDomainId() {
public String getDomainId() {
return domainId;
}
@ -69,7 +69,7 @@ public class CloudStackTemplatePermission {
/**
* @return the accounts
*/
public List<CloudStackAccount> getAccounts() {
public List<String> getAccounts() {
return accounts;
}

View File

@ -11,6 +11,7 @@ label.number.of.virtual.routers=Number of Virtual Routers
label.action.register.iso=Register ISO
label.isolation.method=Isolation method
label.action.register.template=Register template
label.checksum=MD5 checksum
#new labels (end) ************************************************************************************************

View File

@ -54,6 +54,8 @@
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
maxThreads="150" minSpareThreads="25"/>
<Executor name="tomcatThreadPool-internal" namePrefix="catalina-exec-int-"
maxThreads="150" minSpareThreads="25"/>
<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at :
@ -73,6 +75,13 @@
connectionTimeout="20000" disableUploadTimeout="true"
acceptCount="150" enableLookups="false" maxThreads="150"
maxHttpHeaderSize="8192" redirectPort="8443" />
<Connector executor="tomcatThreadPool-internal" address="127.0.0.1"
port="7080" protocol="org.apache.coyote.http11.Http11NioProtocol"
connectionTimeout="20000" disableUploadTimeout="true"
acceptCount="150" enableLookups="false" maxThreads="150"
maxHttpHeaderSize="8192" redirectPort="8443" />
<!-- Define a SSL HTTP/1.1 Connector on port 8443
This connector uses the JSSE configuration, when using APR, the
connector should be using the OpenSSL style configuration

View File

@ -54,6 +54,8 @@
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
maxThreads="150" minSpareThreads="25"/>
<Executor name="tomcatThreadPool-internal" namePrefix="catalina-exec-int-"
maxThreads="150" minSpareThreads="25"/>
<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at :
@ -96,6 +98,13 @@
keystoreType="JKS"
keystoreFile="/etc/cloud/management/cloudmanagementserver.keystore"
keystorePass="vmops.com"/>
<Connector executor="tomcatThreadPool-internal" address="127.0.0.1" port="5443" protocol="org.apache.coyote.http11.Http11NioProtocol" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreType="JKS"
keystoreFile="/etc/cloud/management/cloudmanagementserver.keystore"
keystorePass="vmops.com"/>
<!-- Define an AJP 1.3 Connector on port 20400 -->
<Connector port="20400" protocol="AJP/1.3" redirectPort="6443" />

View File

@ -1296,6 +1296,11 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe
accountNames.add(acct.getAccountName());
}
}
//also add the owner if not public
if(!template.isPublicTemplate()){
Account templateOwner = _accountDao.findById(template.getAccountId());
accountNames.add(templateOwner.getAccountName());
}
return accountNames;
}

View File

@ -2959,6 +2959,7 @@ dictionary = {
'message.validate.instance.name': '<fmt:message key="message.validate.instance.name" />',
'label.action.register.template': '<fmt:message key="label.action.register.template" />',
'label.action.register.iso': '<fmt:message key="label.action.register.iso" />',
'label.isolation.method': '<fmt:message key="label.isolation.method" />'
'label.isolation.method': '<fmt:message key="label.isolation.method" />',
'label.checksum': '<fmt:message key="label.checksum" />'
};
</script>

View File

@ -23,10 +23,14 @@ the session ID has been changed (i.e. another user logging into the UI via a dif
or it's the first time the user has come to this page.
*/
function onLogoutCallback() {
// Returning true means the LOGIN page will be show. If you wish to redirect the user
// to different login page, this is where you would do that.
g_loginResponse = null;
return true;
g_loginResponse = null; //clear single signon variable g_loginResponse
return true; // return true means the login page will show
/*
window.location.replace("http://www.google.com"); //redirect to a different location
return false; //return false means it will stay in the location window.location.replace() sets it to (i.e. "http://www.google.com")
*/
}
var g_loginResponse = null;

View File

@ -317,15 +317,14 @@
$.cookie('timezone', null);
$.cookie('supportELB', null);
if(onLogoutCallback()) { //set g_loginResponse(single-sign-on variable) to null, then bypassLoginCheck() will show login screen.
document.location.reload();
if(onLogoutCallback()) { //onLogoutCallback() will set g_loginResponse(single-sign-on variable) to null, then bypassLoginCheck() will show login screen.
document.location.reload(); //when onLogoutCallback() returns true, reload the current document.
}
},
error: function() {
if(onLogoutCallback()) { //set g_loginResponse(single-sign-on variable) to null, then bypassLoginCheck() will show login screen.
document.location.reload();
}
document.location.reload();
if(onLogoutCallback()) { //onLogoutCallback() will set g_loginResponse(single-sign-on variable) to null, then bypassLoginCheck() will show login screen.
document.location.reload(); //when onLogoutCallback() returns true, reload the current document.
}
},
beforeSend : function(XMLHttpResponse) {
return true;

View File

@ -899,11 +899,7 @@
title: 'label.menu.ipaddresses',
listView: {
id: 'ipAddresses',
label: 'IPs',
filters: {
allocated: { label: 'label.allocated' },
mine: { label: 'label.my.network' }
},
label: 'IPs',
fields: {
ipaddress: {
label: 'IP',

View File

@ -214,7 +214,10 @@
url: {
label: 'label.url',
validation: { required: true }
}
},
checksum : {
label: 'label.checksum'
}
}
},
@ -224,6 +227,8 @@
array1.push("&zoneId=" + args.data.availabilityZone);
array1.push("&format=" + args.data.format);
array1.push("&url=" + todb(args.data.url));
if(args.data.checksum != null && args.data.checksum.length > 0)
array1.push("&checksum=" + todb(args.data.checksum));
$.ajax({
url: createURL("uploadVolume" + array1.join("")),