View Javadoc

1   /**
2    *
3    * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
4    *
5    * ====================================================================
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   * ====================================================================
18   */
19  package org.jclouds.compute.domain;
20  
21  import java.util.NoSuchElementException;
22  
23  import org.jclouds.compute.domain.internal.TemplateBuilderImpl;
24  import org.jclouds.compute.options.TemplateOptions;
25  
26  import com.google.inject.ImplementedBy;
27  
28  /**
29   * Creates a customized template based on requirements.
30   * 
31   * @author Adrian Cole
32   */
33  @ImplementedBy(TemplateBuilderImpl.class)
34  public interface TemplateBuilder {
35  
36     /**
37      * prime this builder with parameters known to work on the current compute provider.
38      */
39     TemplateBuilder any();
40  
41     /**
42      * Configure this template to require the minimum hardware of the parameter.
43      */
44     TemplateBuilder fromHardware(Hardware hardware);
45  
46     /**
47      * Configure this template to fuzzy-match on the image parameter
48      */
49     TemplateBuilder fromImage(Image image);
50  
51     /**
52      * Configure this template to match the resources of the template parameter.
53      */
54     TemplateBuilder fromTemplate(Template image);
55  
56     /**
57      * configure this template to the smallest hardware, based on cores, ram, then disk
58      */
59     TemplateBuilder smallest();
60  
61     /**
62      * configure this template to the fastest hardware, based on cpu
63      */
64     TemplateBuilder fastest();
65  
66     /**
67      * configure this template to the largest hardware, based on cores, ram, then disk
68      */
69     TemplateBuilder biggest();
70  
71     /**
72      * Configure this template to use a specific operating system image.
73      */
74     TemplateBuilder osFamily(OsFamily os);
75  
76     /**
77      * Configure this template to start in a specific location
78      * 
79      * @throws NoSuchElementException
80      *            if no location matches the id specified
81      */
82     TemplateBuilder locationId(String locationId);
83  
84     /**
85      * Configure this template to require a specific imageId.
86      * <p/>
87      * Note that image Ids are often scoped to {@code location}
88      */
89     TemplateBuilder imageId(String imageId);
90  
91     /**
92      * Configure this template to require a specific hardwareId.
93      */
94     TemplateBuilder hardwareId(String hardwareId);
95  
96     /**
97      * Configure this template to have an operating system name that matches the regular expression
98      */
99     TemplateBuilder osNameMatches(String osNameRegex);
100 
101    /**
102     * Configure this template to have an operating system description that matches the regular
103     * expression
104     */
105    TemplateBuilder osDescriptionMatches(String osDescriptionRegex);
106 
107    /**
108     * Configure this template to have an os version that matches the regular expression
109     */
110    TemplateBuilder osVersionMatches(String osVersionRegex);
111 
112    /**
113     * Configure this template to require a specific architecture. ex. virtualizationType or
114     * 
115     */
116    TemplateBuilder osArchMatches(String architecture);
117 
118    /**
119     * Configure this template to require a 64 bit operating system.
120     */
121    TemplateBuilder os64Bit(boolean is64bit);
122 
123    /**
124     * Configure this template to have an image name that matches the regular expression
125     */
126    TemplateBuilder imageNameMatches(String imageNameRegex);
127 
128    /**
129     * Configure this template to have an image version that matches the regular expression
130     */
131    TemplateBuilder imageVersionMatches(String imageVersionRegex);
132 
133    /**
134     * Configure this template to have an image description that matches the regular expression
135     */
136    TemplateBuilder imageDescriptionMatches(String imageDescriptionRegex);
137 
138    /**
139     * Configure this template to require the minimum cores below
140     */
141    TemplateBuilder minCores(double minCores);
142 
143    /**
144     * Configure this template to require the minimum ram in megabytes below
145     */
146    TemplateBuilder minRam(int megabytes);
147 
148    /**
149     * Generate an immutable template from the current builder.
150     */
151    Template build();
152 
153    /**
154     * options such as inbound ports and run scripts.
155     */
156    TemplateBuilder options(TemplateOptions options);
157 
158 }