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