fixed cloudstack tests

This commit is contained in:
Adrian Cole 2011-11-10 13:37:06 +02:00
parent 1cf2be9b09
commit 975033bb72
3 changed files with 113 additions and 54 deletions

View File

@ -45,6 +45,7 @@ import org.jclouds.rest.annotations.OnlyElement;
import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SelectJson;
import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.annotations.Unwrap;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
@ -62,6 +63,7 @@ import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
*/
@RequestFilters(QuerySigner.class)
@QueryParams(keys = "response", values = "json")
@SkipEncoding(',')
public interface TemplateAsyncClient {
/**

View File

@ -24,6 +24,7 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.cloudstack.domain.AsyncCreateResponse;
import org.jclouds.cloudstack.domain.Template;
import org.jclouds.cloudstack.domain.TemplateFilter;
import org.jclouds.cloudstack.domain.TemplateMetadata;
import org.jclouds.cloudstack.domain.TemplatePermission;
import org.jclouds.cloudstack.options.AccountInDomainOptions;
import org.jclouds.cloudstack.options.CreateTemplateOptions;
@ -40,74 +41,112 @@ import org.jclouds.concurrent.Timeout;
* <p/>
*
* @see TemplateAsyncClient
* @see <a href="http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_User.html" />
* @see <a
* href="http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_User.html"
* />
* @author Adrian Cole
*/
@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS)
public interface TemplateClient {
/**
* Creates a template of a virtual machine. The virtual machine must be in a STOPPED state. A template created from this command is automatically designated as a private template visible to the account that created it.
* @see http://download.cloud.com/releases/2.2.0/api_2.2.8/user/createTemplate.html
* @param name the name of the template
* @param osTypeId the ID of the OS Type that best represents the OS of this template.
* @param displayText the display text of the template. This is usually used for display purposes.
* @param options optional arguments
* Creates a template of a virtual machine. The virtual machine must be in a
* STOPPED state. A template created from this command is automatically
* designated as a private template visible to the account that created it.
*
* @see http
* ://download.cloud.com/releases/2.2.0/api_2.2.8/user/createTemplate
* .html
* @param templateMetadata
* overall description of the template
* @param options
* optional arguments
* @return an asynchronous job response
*/
AsyncCreateResponse createTemplate(String name, long osTypeId, String displayText, CreateTemplateOptions... options);
AsyncCreateResponse createTemplate(TemplateMetadata templateMetadata, CreateTemplateOptions... options);
/**
* Registers an existing template into the Cloud.com cloud.
* @see http://download.cloud.com/releases/2.2.0/api_2.2.8/user/registerTemplate.html
* @param name the name of the template
* @param osTypeId the ID of the OS Type that best represents the OS of this template.
* @param format the format for the template. Possible values include QCOW2, RAW, and VHD.
* @param hypervisor the target hypervisor for the template
* @param url the URL of where the template is hosted. Possible URL include http:// and https://
* @param zoneId the ID of the zone the template is to be hosted on
* @param displayText the display text of the template. This is usually used for display purposes.
* @param options optional arguments
*
* @see http
* ://download.cloud.com/releases/2.2.0/api_2.2.8/user/registerTemplate
* .html
* @param templateMetadata
* overall description of the template
* @param format
* the format for the template. Possible values include QCOW2, RAW,
* and VHD.
*
* @param url
* the URL of where the template is hosted. Possible URL include
* http:// and https://
* @param zoneId
* the ID of the zone the template is to be hosted on
* @param options
* optional arguments
* @return data about the newly-registered template
*/
Template registerTemplate(String name, long osTypeId, String format, String hypervisor, String url, long zoneId, String displayText, RegisterTemplateOptions... options);
Template registerTemplate(TemplateMetadata templateMetadata, String format, String hypervisor, String url,
long zoneId, RegisterTemplateOptions... options);
/**
* Updates attributes of a template.
* @see http://download.cloud.com/releases/2.2.0/api_2.2.8/user/updateTemplate.html
* @param id the ID of the image file
* @param options optional arguments
*
* @see http
* ://download.cloud.com/releases/2.2.0/api_2.2.8/user/updateTemplate
* .html
* @param id
* the ID of the image file
* @param options
* optional arguments
* @return updated data about the template
*/
Template updateTemplate(long id, UpdateTemplateOptions... options);
/**
* Copies a template from one zone to another.
* @see http://download.cloud.com/releases/2.2.0/api_2.2.8/user/copyTemplate.html
* @param id Template ID.
* @param sourceZoneId ID of the zone the template is currently hosted on.
* @param destZoneId ID of the zone the template is being copied to.
*
* @see http
* ://download.cloud.com/releases/2.2.0/api_2.2.8/user/copyTemplate.html
* @param id
* Template ID.
* @param sourceZoneId
* ID of the zone the template is currently hosted on.
* @param destZoneId
* ID of the zone the template is being copied to.
* @return an asynchronous job response
*/
AsyncCreateResponse copyTemplateToZone(long id, long sourceZoneId, long destZoneId);
/**
* Deletes a template from the system. All virtual machines using the deleted template will not be affected.
* @see http://download.cloud.com/releases/2.2.0/api_2.2.8/user/deleteTemplate.html
* @param id the ID of the template
* @param options optional arguments
* Deletes a template from the system. All virtual machines using the deleted
* template will not be affected.
*
* @see http
* ://download.cloud.com/releases/2.2.0/api_2.2.8/user/deleteTemplate
* .html
* @param id
* the ID of the template
* @param options
* optional arguments
*/
void deleteTemplate(long id, DeleteTemplateOptions... options);
/**
* List all executable templates.
* @see http://download.cloud.com/releases/2.2.0/api_2.2.8/user/listTemplates.html
*
* @see http
* ://download.cloud.com/releases/2.2.0/api_2.2.8/user/listTemplates.
* html
* @return all executable templates, or empty set, if no templates are found
*/
Set<Template> listTemplates();
/**
* List all public, private, and privileged templates.
* @see http://download.cloud.com/releases/2.2.0/api_2.2.8/user/listTemplates.html
*
* @see http
* ://download.cloud.com/releases/2.2.0/api_2.2.8/user/listTemplates.
* html
* @param options
* if present, how to constrain the list, defaults to all
* executable templates
@ -128,32 +167,50 @@ public interface TemplateClient {
Template getTemplateInZone(long templateId, long zoneId);
/**
* Updates a template visibility permissions. A public template is visible to all accounts within the same domain. A private
* template is visible only to the owner of the template. A priviledged template is a private template with account
* permissions added. Only accounts specified under the template permissions are visible to them.
* @see http://download.cloud.com/releases/2.2.0/api_2.2.8/user/updateTemplatePermissions.html
* @param id the template ID
* @param options optional arguments
* Updates a template visibility permissions. A public template is visible to
* all accounts within the same domain. A private template is visible only to
* the owner of the template. A priviledged template is a private template
* with account permissions added. Only accounts specified under the template
* permissions are visible to them.
*
* @see http://download.cloud.com/releases/2.2.0/api_2.2.8/user/
* updateTemplatePermissions.html
* @param id
* the template ID
* @param options
* optional arguments
*/
void updateTemplatePermissions(long id, UpdateTemplatePermissionsOptions... options);
/**
* List template visibility and all accounts that have permissions to view this template.
* @see http://download.cloud.com/releases/2.2.0/api_2.2.8/user/listTemplatePermissions.html
* @param id the template ID
* @param options optional arguments
* List template visibility and all accounts that have permissions to view
* this template.
*
* @see http://download.cloud.com/releases/2.2.0/api_2.2.8/user/
* listTemplatePermissions.html
* @param id
* the template ID
* @param options
* optional arguments
* @return the list of permissions that apply to the template
*/
Set<TemplatePermission> listTemplatePermissions(long id, AccountInDomainOptions... options);
/**
*
* @see http://download.cloud.com/releases/2.2.0/api_2.2.8/user/extractTemplate.html
* @param id the ID of the template
* @param mode FIXME the mode of extraction - HTTP_DOWNLOAD or FTP_UPLOAD
* @param zoneId the ID of the zone where the ISO is originally located
* @param options optional arguments
* @see http
* ://download.cloud.com/releases/2.2.0/api_2.2.8/user/extractTemplate
* .html
* @param id
* the ID of the template
* @param mode
* FIXME the mode of extraction - HTTP_DOWNLOAD or FTP_UPLOAD
* @param zoneId
* the ID of the zone where the ISO is originally located
* @param options
* optional arguments
* @return an asynchronous job response
*/
AsyncCreateResponse extractTemplate(long id, String mode, long zoneId, ExtractTemplateOptions... options);
AsyncCreateResponse extractTemplate(long id, Template.ExtractMode mode, long zoneId,
ExtractTemplateOptions... options);
}

View File

@ -18,11 +18,11 @@
*/
package org.jclouds.cloudstack.options;
import com.google.common.base.Functions;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import org.jclouds.http.options.BaseHttpRequestOptions;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableSet;
/**
* Options used to control how a template should be updated.
*
@ -37,7 +37,7 @@ public class UpdateTemplatePermissionsOptions extends BaseHttpRequestOptions {
* a list of accounts. If specified, "op" parameter has to be passed in.
*/
public UpdateTemplatePermissionsOptions accounts(Iterable<Long> accounts) {
this.queryParameters.replaceValues("accounts", Iterables.transform(accounts, Functions.toStringFunction()));
this.queryParameters.replaceValues("accounts", ImmutableSet.of(Joiner.on(',').join(accounts)));
return this;
}