Cisco Cisco Intercloud Fabric for Provider Developer's Guide

Page of 41
 
 
Page 22 
 
 
 
 
throws
 CapiPluginSecurityException { 
 
 
// 
TODO
 Auto-generated method stub 
 
 
return true; 
 
CapiPluginTemplatesIf 
Template operations are implemented as methods with the signature as discussed in the following sections. These 
methods are invoked by the infrastructure code in the context of a Java thread. 
createTemplate 
This method creates a new template based on an image that was uploaded to the Cisco ICFPP data store. 
API 
CapiTemplate createTemplate( 
CapiTenantAccountVO tenantAccountInfo, 
CapiTemplate templateDetails) 
throws CapiPluginTemplateException; 
Adapter Development 
1.  Using templateDetails, fetch the imageId
2.  Using the imageId, fetch the CapiImage object as follows: 
 
CapiImage image = ImageUtils.getImage(String imageId); 
3.  Fetch the image details from the image object. Image details include the image path, image name, length, and 
so on. 
4.  Invoke the cloud provider’s template creation API. 
This call results in an identifier that is returned by the cloud provider.  
5.  Save the identifier into templateBackendId in the templateDetails object. 
 
6.  Wait for the creation status to be returned. We recommend that you check status once every 20 or 30 
seconds, while being sure to minimize CPU impact.  
7.  If the returned status indicates a successful upload, set the templateStatus variable to 
TemplateStatusEnum.COMPLETE. If the status that is returned indicates failure, set it to 
TemplateStatusEnum.FAILED
8.  If an exception is issued, return a clear message string with the exception by using the following: 
 
throw new CapiPluginTemplateException(errorCode, errorMessage, 
e.getCause()); 
This method should not return unless one of the above templateStatus statuses has been reached.  
9.  If this method exceeds the specified timeout period, the operation is stopped and cleaned up. In addition, the 
templateStatus is marked failed and a fault is posted with appropriate error comments. 
10.  Return the templateDetails object. 
Multi-Disk Support 
A template can have a single disk or multiple disks. Depending on the cloud provider infrastructure, there are 
several ways to support this situation. The following describes a generic approach that is specific to multiple disks. 
In a multi-disk system, index 0 is considered the root disk and any other disks are data disks. 
1.  As part of the template creation task, uncompress the original image bundle received from Cisco ICFD. 
The package contains a manifest file and the disk images. 
The manifest file contains the following items: 
1:filename1:os 
2:filename2:data