Related jira: https://issues.apache.org/jira/browse/STRATOS-418


On Sat, Feb 8, 2014 at 12:44 PM, Nirmal Fernando <nirmal070...@gmail.com>wrote:

> Hi All,
>
> It's time to refactor the definition a bit and following is the
> re-factored version [1].
>
> Any thoughts?
>
> [1]
>
> /**
>  * All IaaSes that are going to support by Cloud Controller, should extend
> this abstract class.
>  */
> public abstract class Iaas {
>     /**
>      * Reference to the corresponding {@link IaasProvider}
>      */
>     private IaasProvider iaasProvider;
>
>     public Iaas(IaasProvider iaasProvider) {
>         this.setIaasProvider(iaasProvider);
>     }
>
>     public IaasProvider getIaasProvider() {
>         return iaasProvider;
>     }
>
>     public void setIaasProvider(IaasProvider iaasProvider) {
>         this.iaasProvider = iaasProvider;
>     }
>
>     /**
>      * This should build the {@link ComputeService} object and the {@link
> Template} object,
>      * using the information from {@link IaasProvider} and should set the
> built
>      * {@link ComputeService} object in the {@link
> IaasProvider#setComputeService(ComputeService)}
>      * and also should set the built {@link Template} object in the
>      * {@link IaasProvider#setTemplate(Template)}.
>      */
>     public abstract void buildComputeServiceAndTemplate();
>
>     /**
>      * This method provides a way to set payload that can be obtained from
> {@link IaasProvider#getPayload()}
>      * in the {@link Template} of this IaaS.
>      */
>     public abstract void setDynamicPayload();
>
>     /**
>      * This will obtain an IP address from the allocated list and
> associate that IP with this node.
>      * @param node Node to be associated with an IP.
>      * @return associated public IP.
>      */
>     public abstract String associateAddress(NodeMetadata node);
>
>     /**
>      * This will deallocate/release the given IP address back to pool.
>      * @param iaasInfo corresponding {@link IaasProvider}
>      * @param ip public IP address to be released.
>      */
>     public abstract void releaseAddress(String ip);
>
>     /**
>      * This method should create a Key Pair corresponds to a given public
> key in the respective region having the name given.
>      * Also should override the value of the key pair in the {@link
> Template} of this IaaS.
>      * @param region region that the key pair will get created.
>      * @param keyPairName name of the key pair. NOTE: Jclouds adds a
> prefix : <code>jclouds#</code>
>      * @param publicKey public key, from which the key pair will be
> created.
>      * @return whether the key pair creation is successful or not.
>      */
>     public abstract boolean createKeyPairFromPublicKey(String region,
> String keyPairName, String publicKey);
>
>     /**
>      * Validate a given region name against a particular IaaS.
>      * If a particular IaaS doesn't have a concept called region, it can
> simply throw {@link InvalidRegionException}.
>      * @param region name of the region.
>      * @return whether the region is valid.
>      * @throws InvalidRegionException if the region is invalid.
>      */
>     public abstract boolean isValidRegion(String region) throws
> InvalidRegionException;
>
>     /**
>      * Validate a given zone name against a particular region in an IaaS.
>      * If a particular IaaS doesn't have a concept called zone, it can
> simply throw {@link InvalidZoneException}.
>      * @param region region of the IaaS that the zone belongs to.
>      * @param zone
>      * @return whether the zone is valid in the given region or not.
>      * @throws InvalidZoneException if the zone is invalid in a given
> region.
>      */
>     public abstract boolean isValidZone(String region, String zone) throws
> InvalidZoneException;
>
>     /**
>      * Validate a given host id against a particular zone in an IaaS.
>      * If a particular IaaS doesn't have a concept called hosts, it can
> simply throw {@link InvalidHostException}.
>      * @param zone zone of the IaaS that the host belongs to.
>      * @param host
>      * @return whether the host is valid in the given zone or not.
>      * @throws InvalidHostException if the host is invalid in a given zone.
>      */
>     public abstract boolean isValidHost(String zone, String host) throws
> InvalidHostException;
>
>     /**
>      * provides the {@link PartitionValidator} corresponds to this
> particular IaaS.
>      * @return {@link PartitionValidator}
>      */
>     public abstract PartitionValidator getPartitionValidator();
>
>     /**
>      * Builds only the jclouds {@link Template}
>      */
>     public abstract void buildTemplate();
>
> }
>
>
> --
> Best Regards,
> Nirmal
>
> Nirmal Fernando.
> PPMC Member & Committer of Apache Stratos,
> Senior Software Engineer, WSO2 Inc.
>
> Blog: http://nirmalfdo.blogspot.com/
>



-- 
Best Regards,
Nirmal

Nirmal Fernando.
PPMC Member & Committer of Apache Stratos,
Senior Software Engineer, WSO2 Inc.

Blog: http://nirmalfdo.blogspot.com/

Reply via email to