mirror of https://github.com/apache/jclouds.git
Issue 333: added OperatingSystem to Image
This commit is contained in:
parent
462a6e5617
commit
0394c29394
|
@ -19,19 +19,17 @@
|
||||||
|
|
||||||
package org.jclouds.aws.ec2.compute.domain;
|
package org.jclouds.aws.ec2.compute.domain;
|
||||||
|
|
||||||
import static org.jclouds.compute.predicates.ImagePredicates.architectureIn;
|
import static org.jclouds.compute.predicates.ImagePredicates.any;
|
||||||
import static org.jclouds.compute.predicates.ImagePredicates.idIn;
|
import static org.jclouds.compute.predicates.ImagePredicates.idIn;
|
||||||
|
import static org.jclouds.compute.predicates.ImagePredicates.is64Bit;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
import org.jclouds.aws.ec2.domain.InstanceType;
|
import org.jclouds.aws.ec2.domain.InstanceType;
|
||||||
import org.jclouds.compute.domain.Architecture;
|
|
||||||
import org.jclouds.compute.domain.internal.SizeImpl;
|
import org.jclouds.compute.domain.internal.SizeImpl;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -42,20 +40,15 @@ public class EC2Size extends SizeImpl {
|
||||||
private static final long serialVersionUID = 8605688733788974797L;
|
private static final long serialVersionUID = 8605688733788974797L;
|
||||||
private final String instanceType;
|
private final String instanceType;
|
||||||
|
|
||||||
EC2Size(String instanceType, Double cores, Integer ram, Integer disk,
|
EC2Size(String instanceType, Double cores, Integer ram, Integer disk, boolean is64Bit) {
|
||||||
Iterable<Architecture> supportedArchitectures) {
|
super(instanceType, instanceType, instanceType, null, null, ImmutableMap.<String, String> of(), cores, ram, disk,
|
||||||
super(instanceType, instanceType, instanceType, null, null, ImmutableMap
|
is64Bit ? is64Bit() : any());
|
||||||
.<String, String> of(), cores, ram, disk,
|
|
||||||
architectureIn(supportedArchitectures));
|
|
||||||
this.instanceType = instanceType;
|
this.instanceType = instanceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EC2Size(Location location, String instanceType, Double cores,
|
public EC2Size(Location location, String instanceType, Double cores, Integer ram, Integer disk, String[] ids) {
|
||||||
Integer ram, Integer disk, String[] ids) {
|
super(instanceType, instanceType, instanceType, location, null, ImmutableMap.<String, String> of(), cores, ram,
|
||||||
super(instanceType, instanceType, instanceType, location, null,
|
disk, (ids.length == 0 ? is64Bit() : idIn(Arrays.asList(ids))));
|
||||||
ImmutableMap.<String, String> of(), cores, ram, disk,
|
|
||||||
(ids.length == 0 ? architectureIn(Collections
|
|
||||||
.singleton(Architecture.X86_64)) : idIn(Arrays.asList(ids))));
|
|
||||||
this.instanceType = instanceType;
|
this.instanceType = instanceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,53 +62,42 @@ public class EC2Size extends SizeImpl {
|
||||||
/**
|
/**
|
||||||
* @see InstanceType#M1_SMALL
|
* @see InstanceType#M1_SMALL
|
||||||
*/
|
*/
|
||||||
public static final EC2Size M1_SMALL = new EC2Size(InstanceType.M1_SMALL,
|
public static final EC2Size M1_SMALL = new EC2Size(InstanceType.M1_SMALL, 1.0, 1740, 160, false);
|
||||||
1.0, 1740, 160, ImmutableSet.of(Architecture.X86_32));
|
|
||||||
/**
|
/**
|
||||||
* @see InstanceType#M1_LARGE
|
* @see InstanceType#M1_LARGE
|
||||||
*/
|
*/
|
||||||
public static final EC2Size M1_LARGE = new EC2Size(InstanceType.M1_LARGE,
|
public static final EC2Size M1_LARGE = new EC2Size(InstanceType.M1_LARGE, 4.0, 7680, 850, true);
|
||||||
4.0, 7680, 850, ImmutableSet.of(Architecture.X86_64));
|
|
||||||
/**
|
/**
|
||||||
* @see InstanceType#M1_XLARGE
|
* @see InstanceType#M1_XLARGE
|
||||||
*/
|
*/
|
||||||
public static final EC2Size M1_XLARGE = new EC2Size(InstanceType.M1_XLARGE,
|
public static final EC2Size M1_XLARGE = new EC2Size(InstanceType.M1_XLARGE, 8.0, 15360, 1690, true);
|
||||||
8.0, 15360, 1690, ImmutableSet.of(Architecture.X86_64));
|
|
||||||
/**
|
/**
|
||||||
* @see InstanceType#M2_XLARGE
|
* @see InstanceType#M2_XLARGE
|
||||||
*/
|
*/
|
||||||
public static final EC2Size M2_XLARGE = new EC2Size(InstanceType.M2_XLARGE,
|
public static final EC2Size M2_XLARGE = new EC2Size(InstanceType.M2_XLARGE, 6.5, 17510, 420, true);
|
||||||
6.5, 17510, 420, ImmutableSet.of(Architecture.X86_64));
|
|
||||||
/**
|
/**
|
||||||
* @see InstanceType#M2_2XLARGE
|
* @see InstanceType#M2_2XLARGE
|
||||||
*/
|
*/
|
||||||
public static final EC2Size M2_2XLARGE = new EC2Size(
|
public static final EC2Size M2_2XLARGE = new EC2Size(InstanceType.M2_2XLARGE, 13.0, 35020, 850, true);
|
||||||
InstanceType.M2_2XLARGE, 13.0, 35020, 850, ImmutableSet
|
|
||||||
.of(Architecture.X86_64));
|
|
||||||
/**
|
/**
|
||||||
* @see InstanceType#M2_4XLARGE
|
* @see InstanceType#M2_4XLARGE
|
||||||
*/
|
*/
|
||||||
public static final EC2Size M2_4XLARGE = new EC2Size(
|
public static final EC2Size M2_4XLARGE = new EC2Size(InstanceType.M2_4XLARGE, 26.0, 70041, 1690, true);
|
||||||
InstanceType.M2_4XLARGE, 26.0, 70041, 1690, ImmutableSet
|
|
||||||
.of(Architecture.X86_64));
|
|
||||||
/**
|
/**
|
||||||
* @see InstanceType#C1_MEDIUM
|
* @see InstanceType#C1_MEDIUM
|
||||||
*/
|
*/
|
||||||
public static final EC2Size C1_MEDIUM = new EC2Size(InstanceType.C1_MEDIUM,
|
public static final EC2Size C1_MEDIUM = new EC2Size(InstanceType.C1_MEDIUM, 5.0, 1740, 350, false);
|
||||||
5.0, 1740, 350, ImmutableSet.of(Architecture.X86_32));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see InstanceType#C1_XLARGE
|
* @see InstanceType#C1_XLARGE
|
||||||
*/
|
*/
|
||||||
public static final EC2Size C1_XLARGE = new EC2Size(InstanceType.C1_XLARGE,
|
public static final EC2Size C1_XLARGE = new EC2Size(InstanceType.C1_XLARGE, 20.0, 7168, 1690, true);
|
||||||
20.0, 7168, 1690, ImmutableSet.of(Architecture.X86_64));
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = super.hashCode();
|
int result = super.hashCode();
|
||||||
result = prime * result
|
result = prime * result + ((instanceType == null) ? 0 : instanceType.hashCode());
|
||||||
+ ((instanceType == null) ? 0 : instanceType.hashCode());
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.jclouds.aws.ec2.compute.options.EC2TemplateOptions;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.Size;
|
import org.jclouds.compute.domain.Size;
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
import org.jclouds.compute.domain.TemplateBuilder;
|
||||||
import org.jclouds.compute.internal.TemplateBuilderImpl;
|
import org.jclouds.compute.domain.internal.TemplateBuilderImpl;
|
||||||
import org.jclouds.compute.options.TemplateOptions;
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
protected void assertDefaultWorks() {
|
protected void assertDefaultWorks() {
|
||||||
Template defaultTemplate = client.templateBuilder().build();
|
Template defaultTemplate = client.templateBuilder().build();
|
||||||
assertEquals(defaultTemplate.getImage().getArchitecture(), Architecture.X86_32);
|
assertEquals(defaultTemplate.getImage().getArchitecture(), Architecture.X86_32);
|
||||||
assertEquals(defaultTemplate.getImage().getOsFamily(), OsFamily.UBUNTU);
|
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
|
||||||
assertEquals(defaultTemplate.getSize().getCores(), 1.0d);
|
assertEquals(defaultTemplate.getSize().getCores(), 1.0d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,8 +151,8 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
assert group.getIpPermissions().size() == 0 : group;
|
assert group.getIpPermissions().size() == 0 : group;
|
||||||
|
|
||||||
// try to run a script with the original keyPair
|
// try to run a script with the original keyPair
|
||||||
runScriptWithCreds(tag, first.getImage().getOsFamily(), new Credentials(first.getCredentials().identity,
|
runScriptWithCreds(tag, first.getImage().getOperatingSystem().getFamily(), new Credentials(first
|
||||||
result.getKeyMaterial()));
|
.getCredentials().identity, result.getKeyMaterial()));
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
client.destroyNodesMatching(NodePredicates.withTag(tag));
|
client.destroyNodesMatching(NodePredicates.withTag(tag));
|
||||||
|
|
|
@ -37,7 +37,7 @@ import org.jclouds.compute.domain.Size;
|
||||||
import org.jclouds.compute.domain.Template;
|
import org.jclouds.compute.domain.Template;
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
import org.jclouds.compute.domain.TemplateBuilder;
|
||||||
import org.jclouds.compute.domain.internal.ImageImpl;
|
import org.jclouds.compute.domain.internal.ImageImpl;
|
||||||
import org.jclouds.compute.internal.TemplateBuilderImpl;
|
import org.jclouds.compute.domain.internal.TemplateBuilderImpl;
|
||||||
import org.jclouds.compute.options.TemplateOptions;
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
|
|
|
@ -150,9 +150,9 @@ public class ImageParserTest extends BaseEC2HandlerTest {
|
||||||
assertEquals(image.getLocation(), defaultLocation);
|
assertEquals(image.getLocation(), defaultLocation);
|
||||||
assertEquals(image.getName(), "");
|
assertEquals(image.getName(), "");
|
||||||
assertEquals(image.getOsDescription(), "vostok-builds/vostok-0.95-5622/vostok-0.95-5622.manifest.xml");
|
assertEquals(image.getOsDescription(), "vostok-builds/vostok-0.95-5622/vostok-0.95-5622.manifest.xml");
|
||||||
assertEquals(image.getOsFamily(), null);
|
assertEquals(image.getOsFamily(), OsFamily.UNKNOWN);
|
||||||
assertEquals(image.getUserMetadata(), ImmutableMap.<String, String> of("owner", "133804938231"));
|
assertEquals(image.getUserMetadata(), ImmutableMap.<String, String> of("owner", "133804938231"));
|
||||||
assertEquals(image.getVersion(), "");
|
assertEquals(image.getVersion(), "5622");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,11 +35,12 @@ import org.jclouds.aws.ec2.compute.domain.RegionAndName;
|
||||||
import org.jclouds.aws.ec2.compute.options.EC2TemplateOptions;
|
import org.jclouds.aws.ec2.compute.options.EC2TemplateOptions;
|
||||||
import org.jclouds.compute.domain.Architecture;
|
import org.jclouds.compute.domain.Architecture;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
import org.jclouds.compute.domain.Size;
|
import org.jclouds.compute.domain.Size;
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
import org.jclouds.compute.domain.TemplateBuilder;
|
||||||
import org.jclouds.compute.domain.internal.SizeImpl;
|
import org.jclouds.compute.domain.internal.SizeImpl;
|
||||||
import org.jclouds.compute.internal.TemplateBuilderImpl;
|
import org.jclouds.compute.domain.internal.TemplateBuilderImpl;
|
||||||
import org.jclouds.compute.internal.TemplateBuilderImplTest;
|
import org.jclouds.compute.domain.internal.TemplateBuilderImplTest;
|
||||||
import org.jclouds.compute.options.TemplateOptions;
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
import org.jclouds.compute.predicates.ImagePredicates;
|
import org.jclouds.compute.predicates.ImagePredicates;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
|
@ -95,26 +96,35 @@ public class EC2TemplateBuilderImplTest extends TemplateBuilderImplTest {
|
||||||
.<Location> of(location));
|
.<Location> of(location));
|
||||||
Supplier<Set<? extends Image>> images = Suppliers.<Set<? extends Image>> ofInstance(ImmutableSet.<Image> of());
|
Supplier<Set<? extends Image>> images = Suppliers.<Set<? extends Image>> ofInstance(ImmutableSet.<Image> of());
|
||||||
Supplier<Set<? extends Size>> sizes = Suppliers.<Set<? extends Size>> ofInstance(ImmutableSet
|
Supplier<Set<? extends Size>> sizes = Suppliers.<Set<? extends Size>> ofInstance(ImmutableSet
|
||||||
.<Size> of(new SizeImpl("1", "1", "region/1", location, null, ImmutableMap.<String, String> of(), 1, 1,
|
.<Size> of(new SizeImpl("1", "1", "region/1", location, null, ImmutableMap.<String, String> of(), 1, 1, 1,
|
||||||
1, ImagePredicates.any())));
|
ImagePredicates.any())));
|
||||||
|
|
||||||
Provider<TemplateOptions> optionsProvider = createMock(Provider.class);
|
Provider<TemplateOptions> optionsProvider = createMock(Provider.class);
|
||||||
Provider<TemplateBuilder> templateBuilderProvider = createMock(Provider.class);
|
Provider<TemplateBuilder> templateBuilderProvider = createMock(Provider.class);
|
||||||
TemplateOptions defaultOptions = createMock(TemplateOptions.class);
|
TemplateOptions defaultOptions = createMock(TemplateOptions.class);
|
||||||
Image knownImage = createMock(Image.class);
|
Image knownImage = createMock(Image.class);
|
||||||
|
OperatingSystem os = createMock(OperatingSystem.class);
|
||||||
|
|
||||||
expect(optionsProvider.get()).andReturn(defaultOptions);
|
expect(optionsProvider.get()).andReturn(defaultOptions);
|
||||||
|
|
||||||
expect(knownImage.getId()).andReturn("region/ami").atLeastOnce();
|
expect(knownImage.getId()).andReturn("region/ami").atLeastOnce();
|
||||||
expect(knownImage.getLocation()).andReturn(location).atLeastOnce();
|
expect(knownImage.getLocation()).andReturn(location).atLeastOnce();
|
||||||
expect(knownImage.getOsFamily()).andReturn(null).atLeastOnce();
|
|
||||||
expect(knownImage.getName()).andReturn(null).atLeastOnce();
|
expect(knownImage.getName()).andReturn(null).atLeastOnce();
|
||||||
expect(knownImage.getDescription()).andReturn(null).atLeastOnce();
|
expect(knownImage.getDescription()).andReturn(null).atLeastOnce();
|
||||||
expect(knownImage.getOsDescription()).andReturn(null).atLeastOnce();
|
|
||||||
expect(knownImage.getVersion()).andReturn(null).atLeastOnce();
|
expect(knownImage.getVersion()).andReturn(null).atLeastOnce();
|
||||||
expect(knownImage.getArchitecture()).andReturn(Architecture.X86_32).atLeastOnce();
|
expect(knownImage.getArchitecture()).andReturn(Architecture.X86_32).atLeastOnce();
|
||||||
|
|
||||||
|
expect(knownImage.getOperatingSystem()).andReturn(os).atLeastOnce();
|
||||||
|
|
||||||
|
expect(os.getName()).andReturn(null).atLeastOnce();
|
||||||
|
expect(os.getVersion()).andReturn(null).atLeastOnce();
|
||||||
|
expect(os.getFamily()).andReturn(null).atLeastOnce();
|
||||||
|
expect(os.getDescription()).andReturn(null).atLeastOnce();
|
||||||
|
expect(os.getArch()).andReturn(null).atLeastOnce();
|
||||||
|
expect(os.is64Bit()).andReturn(false).atLeastOnce();
|
||||||
|
|
||||||
replay(knownImage);
|
replay(knownImage);
|
||||||
|
replay(os);
|
||||||
replay(defaultOptions);
|
replay(defaultOptions);
|
||||||
replay(optionsProvider);
|
replay(optionsProvider);
|
||||||
replay(templateBuilderProvider);
|
replay(templateBuilderProvider);
|
||||||
|
@ -125,6 +135,7 @@ public class EC2TemplateBuilderImplTest extends TemplateBuilderImplTest {
|
||||||
assertEquals(template.imageId("region/ami").build().getImage(), knownImage);
|
assertEquals(template.imageId("region/ami").build().getImage(), knownImage);
|
||||||
|
|
||||||
verify(knownImage);
|
verify(knownImage);
|
||||||
|
verify(os);
|
||||||
verify(defaultOptions);
|
verify(defaultOptions);
|
||||||
verify(optionsProvider);
|
verify(optionsProvider);
|
||||||
verify(templateBuilderProvider);
|
verify(templateBuilderProvider);
|
||||||
|
@ -139,8 +150,8 @@ public class EC2TemplateBuilderImplTest extends TemplateBuilderImplTest {
|
||||||
.<Location> of(location));
|
.<Location> of(location));
|
||||||
Supplier<Set<? extends Image>> images = Suppliers.<Set<? extends Image>> ofInstance(ImmutableSet.<Image> of());
|
Supplier<Set<? extends Image>> images = Suppliers.<Set<? extends Image>> ofInstance(ImmutableSet.<Image> of());
|
||||||
Supplier<Set<? extends Size>> sizes = Suppliers.<Set<? extends Size>> ofInstance(ImmutableSet
|
Supplier<Set<? extends Size>> sizes = Suppliers.<Set<? extends Size>> ofInstance(ImmutableSet
|
||||||
.<Size> of(new SizeImpl("1", "1", "region/1", location, null, ImmutableMap.<String, String> of(), 1, 1,
|
.<Size> of(new SizeImpl("1", "1", "region/1", location, null, ImmutableMap.<String, String> of(), 1, 1, 1,
|
||||||
1, ImagePredicates.any())));
|
ImagePredicates.any())));
|
||||||
|
|
||||||
Provider<TemplateOptions> optionsProvider = createMock(Provider.class);
|
Provider<TemplateOptions> optionsProvider = createMock(Provider.class);
|
||||||
Provider<TemplateBuilder> templateBuilderProvider = createMock(Provider.class);
|
Provider<TemplateBuilder> templateBuilderProvider = createMock(Provider.class);
|
||||||
|
@ -177,8 +188,8 @@ public class EC2TemplateBuilderImplTest extends TemplateBuilderImplTest {
|
||||||
.<Location> of(location));
|
.<Location> of(location));
|
||||||
Supplier<Set<? extends Image>> images = Suppliers.<Set<? extends Image>> ofInstance(ImmutableSet.<Image> of());
|
Supplier<Set<? extends Image>> images = Suppliers.<Set<? extends Image>> ofInstance(ImmutableSet.<Image> of());
|
||||||
Supplier<Set<? extends Size>> sizes = Suppliers.<Set<? extends Size>> ofInstance(ImmutableSet
|
Supplier<Set<? extends Size>> sizes = Suppliers.<Set<? extends Size>> ofInstance(ImmutableSet
|
||||||
.<Size> of(new SizeImpl("1", "1", "region/1", location, null, ImmutableMap.<String, String> of(), 1, 1,
|
.<Size> of(new SizeImpl("1", "1", "region/1", location, null, ImmutableMap.<String, String> of(), 1, 1, 1,
|
||||||
1, ImagePredicates.any())));
|
ImagePredicates.any())));
|
||||||
|
|
||||||
Location defaultLocation = createMock(Location.class);
|
Location defaultLocation = createMock(Location.class);
|
||||||
Provider<TemplateOptions> optionsProvider = createMock(Provider.class);
|
Provider<TemplateOptions> optionsProvider = createMock(Provider.class);
|
||||||
|
|
|
@ -316,7 +316,7 @@ See http://code.google.com/p/jclouds for details."
|
||||||
(define-accessors NodeMetadata "node" credentials extra state tag)
|
(define-accessors NodeMetadata "node" credentials extra state tag)
|
||||||
|
|
||||||
(defn builder-options [builder]
|
(defn builder-options [builder]
|
||||||
(or (get-field org.jclouds.compute.internal.TemplateBuilderImpl :options builder)
|
(or (get-field org.jclouds.compute.domain.internal.TemplateBuilderImpl :options builder)
|
||||||
(TemplateOptions.)))
|
(TemplateOptions.)))
|
||||||
|
|
||||||
(defmacro option-option-fn-0arg [key]
|
(defmacro option-option-fn-0arg [key]
|
||||||
|
@ -341,7 +341,8 @@ See http://code.google.com/p/jclouds for details."
|
||||||
(concat
|
(concat
|
||||||
(make-option-map option-fn-1arg
|
(make-option-map option-fn-1arg
|
||||||
[:os-family :location-id :architecture :image-id :size-id
|
[:os-family :location-id :architecture :image-id :size-id
|
||||||
:os-description-matches :image-version-matches :image-name-matches
|
:os-name-matches :os-version-matches :os-description-matches
|
||||||
|
:os-64-bit :image-version-matches :image-name-matches
|
||||||
:image-description-matches :min-cores :min-ram])
|
:image-description-matches :min-cores :min-ram])
|
||||||
(make-option-map option-option-fn-1arg
|
(make-option-map option-option-fn-1arg
|
||||||
[:run-script :install-private-key :authorize-public-key :inbound-ports]))))
|
[:run-script :install-private-key :authorize-public-key :inbound-ports]))))
|
||||||
|
|
|
@ -22,8 +22,12 @@ package org.jclouds.compute.domain;
|
||||||
/**
|
/**
|
||||||
* Architecture of a node
|
* Architecture of a node
|
||||||
*
|
*
|
||||||
|
* <p/>
|
||||||
|
* Please transition to {@link OperatingSystem}
|
||||||
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public enum Architecture {
|
public enum Architecture {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -19,11 +19,14 @@
|
||||||
|
|
||||||
package org.jclouds.compute.domain;
|
package org.jclouds.compute.domain;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.internal.ImageImpl;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.inject.ImplementedBy;
|
import org.jclouds.compute.domain.internal.ImageImpl;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
|
|
||||||
|
import com.google.common.annotations.Beta;
|
||||||
|
import com.google.inject.ImplementedBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Running Operating system
|
* Running Operating system
|
||||||
*
|
*
|
||||||
|
@ -31,6 +34,11 @@ import org.jclouds.domain.Credentials;
|
||||||
*/
|
*/
|
||||||
@ImplementedBy(ImageImpl.class)
|
@ImplementedBy(ImageImpl.class)
|
||||||
public interface Image extends ComputeMetadata {
|
public interface Image extends ComputeMetadata {
|
||||||
|
/**
|
||||||
|
* The operating system installed on this image
|
||||||
|
*/
|
||||||
|
@Beta
|
||||||
|
OperatingSystem getOperatingSystem();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Version of the image
|
* Version of the image
|
||||||
|
@ -43,18 +51,28 @@ public interface Image extends ComputeMetadata {
|
||||||
String getDescription();
|
String getDescription();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Operating System
|
* please use {#link {@link #getOperatingSystem()}
|
||||||
|
*
|
||||||
|
* @see OperatingSystem#getFamily()
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
OsFamily getOsFamily();
|
OsFamily getOsFamily();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of the operating system including the version.
|
* please use {#link {@link #getOperatingSystem()}
|
||||||
|
*
|
||||||
|
* @see OperatingSystem#getDescription()
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
String getOsDescription();
|
String getOsDescription();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Operating System
|
* please use {#link {@link #getOperatingSystem()}
|
||||||
|
*
|
||||||
|
* @see OperatingSystem#getDescription()
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
|
@Deprecated
|
||||||
Architecture getArchitecture();
|
Architecture getArchitecture();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,207 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.compute.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.common.annotations.Beta;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Running Operating system
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Beta
|
||||||
|
public class OperatingSystem {
|
||||||
|
@Nullable
|
||||||
|
private OsFamily family;
|
||||||
|
@Nullable
|
||||||
|
private String name;
|
||||||
|
@Nullable
|
||||||
|
private String arch;
|
||||||
|
@Nullable
|
||||||
|
private String version;
|
||||||
|
private String description;
|
||||||
|
private boolean is64Bit;
|
||||||
|
|
||||||
|
// for serialization/deserialization
|
||||||
|
protected OperatingSystem() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperatingSystem(@Nullable OsFamily family, @Nullable String name, @Nullable String version,
|
||||||
|
@Nullable String arch, String description, boolean is64Bit) {
|
||||||
|
this.family = family;
|
||||||
|
this.name = name;
|
||||||
|
this.arch = arch;
|
||||||
|
this.version = version;
|
||||||
|
this.description = checkNotNull(description, "description");
|
||||||
|
this.is64Bit = is64Bit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type of the operating system
|
||||||
|
* <p/>
|
||||||
|
* generally, this is used to compare the means by which you use an operating
|
||||||
|
* system. For example, to determine compatibility of a particular
|
||||||
|
* bootstrapping or package installation approach.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public OsFamily getFamily() {
|
||||||
|
return family;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* name of the operating system; ex. {@code Red Hat Enterprise Linux}
|
||||||
|
*
|
||||||
|
* <h2>note</h2> While this looks similar to, and may in some cases be the
|
||||||
|
* same as the java system property {@code os.name} it isn't guaranteed to
|
||||||
|
* match a particular value. For example, this value could be derived from
|
||||||
|
* data parsed for a cloud api or the OVF CIM OSType enum value;
|
||||||
|
*
|
||||||
|
* @return operating system name or null if it couldn't be determined.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* architecture of the operating system; ex. {@code x86_64}
|
||||||
|
* <p/>
|
||||||
|
* generally, this is used to decide whether an operating system will run
|
||||||
|
* certain binaries, for example, a 64bit JDK.
|
||||||
|
*
|
||||||
|
* <h2>note</h2>
|
||||||
|
* While this looks similar to, and may in some cases be the same as the java
|
||||||
|
* system property {@code os.arch} it isn't guaranteed to match a particular
|
||||||
|
* value. For example, this value could be derived from data parsed for a
|
||||||
|
* cloud api or the OVF CIM OSType enum value;
|
||||||
|
*
|
||||||
|
* @return operating system architecture or null if it couldn't be
|
||||||
|
* determined.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public String getArch() {
|
||||||
|
return arch;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* version of the operating system; ex. {@code 10.0.4}
|
||||||
|
* <p/>
|
||||||
|
* generally, this is used to compare versions of the same operating system
|
||||||
|
* name. It should be meaningful when sorted against, although this isn't
|
||||||
|
* necessary.
|
||||||
|
* <h2>note</h2>
|
||||||
|
* While this looks similar to, and may in some cases be the same as the java
|
||||||
|
* system property {@code os.version} it isn't guaranteed to match a
|
||||||
|
* particular value. For example, this value could be derived from data
|
||||||
|
* parsed for a cloud api or the OVF CIM OSType enum value;
|
||||||
|
*
|
||||||
|
* @return operating system version or null if it couldn't be determined.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public String getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* description of the operating system; ex. {@code CentOS 32-bit},{@code
|
||||||
|
* Other Linux (32-bit)}
|
||||||
|
* <p/>
|
||||||
|
* This is the only required field in the operating system object. In some
|
||||||
|
* implementations, it is this data that is used to parse the value of the
|
||||||
|
* {@link #name}, {@link #version}, and {@link #arch} fields.
|
||||||
|
*
|
||||||
|
* @return operating system description
|
||||||
|
*/
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return whether this operating system supports 64 bit computation.
|
||||||
|
*/
|
||||||
|
public boolean is64Bit() {
|
||||||
|
return is64Bit;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((arch == null) ? 0 : arch.hashCode());
|
||||||
|
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||||
|
result = prime * result + ((family == null) ? 0 : family.hashCode());
|
||||||
|
result = prime * result + (is64Bit ? 1231 : 1237);
|
||||||
|
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||||
|
result = prime * result + ((version == null) ? 0 : version.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
OperatingSystem other = (OperatingSystem) obj;
|
||||||
|
if (arch == null) {
|
||||||
|
if (other.arch != null)
|
||||||
|
return false;
|
||||||
|
} else if (!arch.equals(other.arch))
|
||||||
|
return false;
|
||||||
|
if (description == null) {
|
||||||
|
if (other.description != null)
|
||||||
|
return false;
|
||||||
|
} else if (!description.equals(other.description))
|
||||||
|
return false;
|
||||||
|
if (family == null) {
|
||||||
|
if (other.family != null)
|
||||||
|
return false;
|
||||||
|
} else if (!family.equals(other.family))
|
||||||
|
return false;
|
||||||
|
if (is64Bit != other.is64Bit)
|
||||||
|
return false;
|
||||||
|
if (name == null) {
|
||||||
|
if (other.name != null)
|
||||||
|
return false;
|
||||||
|
} else if (!name.equals(other.name))
|
||||||
|
return false;
|
||||||
|
if (version == null) {
|
||||||
|
if (other.version != null)
|
||||||
|
return false;
|
||||||
|
} else if (!version.equals(other.version))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[name=" + name + ", family=" + family + ", version=" + version + ", arch=" + arch + ", is64Bit="
|
||||||
|
+ is64Bit + ", description=" + description + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -26,14 +26,16 @@ import com.google.common.base.CaseFormat;
|
||||||
/**
|
/**
|
||||||
* Running Operating system
|
* Running Operating system
|
||||||
*
|
*
|
||||||
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public enum OsFamily {
|
public enum OsFamily {
|
||||||
CENTOS,
|
UNKNOWN, AIX, ARCH, CENTOS, DARWIN, DEBIAN, ESX, FEDORA, FREEBSD, GENTOO, HPUX, LINUX, MANDRIVA, NETBSD,
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* Oracle Enterprise Linux
|
* Oracle Enterprise Linux
|
||||||
*/
|
*/
|
||||||
OEL, RHEL, FEDORA, DEBIAN, UBUNTU, TTYLINUX, ARCH, SUSE, SOLARIS, GENTOO, WINDOWS;
|
OEL, OPENBSD, RHEL, SIGAR, SOLARIS, SUSE, TURBOLINUX, UBUNTU, WINDOWS;
|
||||||
public String value() {
|
public String value() {
|
||||||
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name());
|
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name());
|
||||||
}
|
}
|
||||||
|
@ -43,8 +45,11 @@ public enum OsFamily {
|
||||||
return value();
|
return value();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static OsFamily fromValue(String operatingSystem) {
|
public static OsFamily fromValue(String osFamily) {
|
||||||
return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE,
|
try {
|
||||||
checkNotNull(operatingSystem, "region")));
|
return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(osFamily, "osFamily")));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return UNKNOWN;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -21,7 +21,7 @@ package org.jclouds.compute.domain;
|
||||||
|
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
import org.jclouds.compute.internal.TemplateBuilderImpl;
|
import org.jclouds.compute.domain.internal.TemplateBuilderImpl;
|
||||||
import org.jclouds.compute.options.TemplateOptions;
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
|
|
||||||
import com.google.inject.ImplementedBy;
|
import com.google.inject.ImplementedBy;
|
||||||
|
@ -35,7 +35,8 @@ import com.google.inject.ImplementedBy;
|
||||||
public interface TemplateBuilder {
|
public interface TemplateBuilder {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* prime this builder with parameters known to work on the current compute provider.
|
* prime this builder with parameters known to work on the current compute
|
||||||
|
* provider.
|
||||||
*/
|
*/
|
||||||
TemplateBuilder any();
|
TemplateBuilder any();
|
||||||
|
|
||||||
|
@ -84,7 +85,10 @@ public interface TemplateBuilder {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure this template to require a specific architecture
|
* Configure this template to require a specific architecture
|
||||||
|
*
|
||||||
|
* Please switch to either architecture as a string, or {@link #is64bit()}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
TemplateBuilder architecture(Architecture architecture);
|
TemplateBuilder architecture(Architecture architecture);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -100,23 +104,50 @@ public interface TemplateBuilder {
|
||||||
TemplateBuilder sizeId(String sizeId);
|
TemplateBuilder sizeId(String sizeId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure this template to have an operating system description that matches the regular
|
* Configure this template to have an operating system name that matches the
|
||||||
* expression
|
* regular expression
|
||||||
|
*/
|
||||||
|
TemplateBuilder osNameMatches(String osNameRegex);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure this template to have an operating system description that
|
||||||
|
* matches the regular expression
|
||||||
*/
|
*/
|
||||||
TemplateBuilder osDescriptionMatches(String osDescriptionRegex);
|
TemplateBuilder osDescriptionMatches(String osDescriptionRegex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure this template to have an image name that matches the regular expression
|
* Configure this template to have an os version that matches the regular
|
||||||
|
* expression
|
||||||
|
*/
|
||||||
|
TemplateBuilder osVersionMatches(String osVersionRegex);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure this template to require a specific architecture. ex.
|
||||||
|
* virtualizationType or
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
TemplateBuilder osArchMatches(String architecture);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure this template to require a 64 bit operating system.
|
||||||
|
*/
|
||||||
|
TemplateBuilder os64bit(boolean is64bit);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure this template to have an image name that matches the regular
|
||||||
|
* expression
|
||||||
*/
|
*/
|
||||||
TemplateBuilder imageNameMatches(String imageNameRegex);
|
TemplateBuilder imageNameMatches(String imageNameRegex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure this template to have an image version that matches the regular expression
|
* Configure this template to have an image version that matches the regular
|
||||||
|
* expression
|
||||||
*/
|
*/
|
||||||
TemplateBuilder imageVersionMatches(String imageVersionRegex);
|
TemplateBuilder imageVersionMatches(String imageVersionRegex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure this template to have an image description that matches the regular expression
|
* Configure this template to have an image description that matches the
|
||||||
|
* regular expression
|
||||||
*/
|
*/
|
||||||
TemplateBuilder imageDescriptionMatches(String imageDescriptionRegex);
|
TemplateBuilder imageDescriptionMatches(String imageDescriptionRegex);
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ import javax.annotation.Nullable;
|
||||||
import org.jclouds.compute.domain.Architecture;
|
import org.jclouds.compute.domain.Architecture;
|
||||||
import org.jclouds.compute.domain.ComputeType;
|
import org.jclouds.compute.domain.ComputeType;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
|
@ -41,26 +42,42 @@ public class ImageImpl extends ComputeMetadataImpl implements Image {
|
||||||
/** The serialVersionUID */
|
/** The serialVersionUID */
|
||||||
private static final long serialVersionUID = 7856744554191025307L;
|
private static final long serialVersionUID = 7856744554191025307L;
|
||||||
|
|
||||||
|
private final OperatingSystem operatingSystem;
|
||||||
|
|
||||||
private final String version;
|
private final String version;
|
||||||
private final String description;
|
private final String description;
|
||||||
private final OsFamily osFamily;
|
@Nullable
|
||||||
private final String osDescription;
|
|
||||||
private final Architecture architecture;
|
private final Architecture architecture;
|
||||||
private final Credentials defaultCredentials;
|
private final Credentials defaultCredentials;
|
||||||
|
|
||||||
public ImageImpl(String providerId, String name, String id, Location location, URI uri,
|
public ImageImpl(String providerId, String name, String id, Location location, URI uri,
|
||||||
Map<String, String> userMetadata, String description, String version,
|
Map<String, String> userMetadata, OperatingSystem operatingSystem, String description, String version,
|
||||||
@Nullable OsFamily osFamily, String osDescription, Architecture architecture,
|
@Nullable Architecture architecture, Credentials defaultCredentials) {
|
||||||
Credentials defaultCredentials) {
|
|
||||||
super(ComputeType.IMAGE, providerId, name, id, location, uri, userMetadata);
|
super(ComputeType.IMAGE, providerId, name, id, location, uri, userMetadata);
|
||||||
|
this.operatingSystem = checkNotNull(operatingSystem, "operatingSystem");
|
||||||
this.version = checkNotNull(version, "version");
|
this.version = checkNotNull(version, "version");
|
||||||
this.osFamily = osFamily;
|
|
||||||
this.description = checkNotNull(description, "description");
|
this.description = checkNotNull(description, "description");
|
||||||
this.osDescription = checkNotNull(osDescription, "osDescription");
|
this.architecture = architecture;
|
||||||
this.architecture = checkNotNull(architecture, "architecture");
|
|
||||||
this.defaultCredentials = defaultCredentials;
|
this.defaultCredentials = defaultCredentials;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public ImageImpl(String providerId, String name, String id, Location location, URI uri,
|
||||||
|
Map<String, String> userMetadata, String description, String version, @Nullable OsFamily osFamily,
|
||||||
|
String osDescription, @Nullable Architecture architecture, Credentials defaultCredentials) {
|
||||||
|
this(providerId, name, id, location, uri, userMetadata, new OperatingSystem(osFamily, null, null,
|
||||||
|
architecture != null ? architecture.toString() : null, osDescription, architecture != null ? architecture
|
||||||
|
.equals(Architecture.X86_64) : false), description, version, architecture, defaultCredentials);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public OperatingSystem getOperatingSystem() {
|
||||||
|
return operatingSystem;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -82,21 +99,24 @@ public class ImageImpl extends ComputeMetadataImpl implements Image {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public OsFamily getOsFamily() {
|
public OsFamily getOsFamily() {
|
||||||
return osFamily;
|
return operatingSystem.getFamily();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public String getOsDescription() {
|
public String getOsDescription() {
|
||||||
return osDescription;
|
return operatingSystem.getDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
|
@Nullable
|
||||||
public Architecture getArchitecture() {
|
public Architecture getArchitecture() {
|
||||||
return architecture;
|
return architecture;
|
||||||
}
|
}
|
||||||
|
@ -111,10 +131,8 @@ public class ImageImpl extends ComputeMetadataImpl implements Image {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[id=" + getId() + ", providerId=" + getProviderId() + ", name=" + getName()
|
return "[id=" + getId() + ", name=" + getName() + ", operatingSystem=" + operatingSystem + ", description="
|
||||||
+ ", locationId=" + (getLocation() != null ? getLocation().getId() : "null")
|
+ description + ", version=" + version + ", location=" + getLocation() + "]";
|
||||||
+ ", architecture=" + architecture + ", osDescription=" + osDescription
|
|
||||||
+ ", version=" + version + ", osFamily=" + osFamily + "]";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -122,9 +140,9 @@ public class ImageImpl extends ComputeMetadataImpl implements Image {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = super.hashCode();
|
int result = super.hashCode();
|
||||||
result = prime * result + ((architecture == null) ? 0 : architecture.hashCode());
|
result = prime * result + ((architecture == null) ? 0 : architecture.hashCode());
|
||||||
|
result = prime * result + ((defaultCredentials == null) ? 0 : defaultCredentials.hashCode());
|
||||||
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||||
result = prime * result + ((osDescription == null) ? 0 : osDescription.hashCode());
|
result = prime * result + ((operatingSystem == null) ? 0 : operatingSystem.hashCode());
|
||||||
result = prime * result + ((osFamily == null) ? 0 : osFamily.hashCode());
|
|
||||||
result = prime * result + ((version == null) ? 0 : version.hashCode());
|
result = prime * result + ((version == null) ? 0 : version.hashCode());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -143,20 +161,20 @@ public class ImageImpl extends ComputeMetadataImpl implements Image {
|
||||||
return false;
|
return false;
|
||||||
} else if (!architecture.equals(other.architecture))
|
} else if (!architecture.equals(other.architecture))
|
||||||
return false;
|
return false;
|
||||||
|
if (defaultCredentials == null) {
|
||||||
|
if (other.defaultCredentials != null)
|
||||||
|
return false;
|
||||||
|
} else if (!defaultCredentials.equals(other.defaultCredentials))
|
||||||
|
return false;
|
||||||
if (description == null) {
|
if (description == null) {
|
||||||
if (other.description != null)
|
if (other.description != null)
|
||||||
return false;
|
return false;
|
||||||
} else if (!description.equals(other.description))
|
} else if (!description.equals(other.description))
|
||||||
return false;
|
return false;
|
||||||
if (osDescription == null) {
|
if (operatingSystem == null) {
|
||||||
if (other.osDescription != null)
|
if (other.operatingSystem != null)
|
||||||
return false;
|
return false;
|
||||||
} else if (!osDescription.equals(other.osDescription))
|
} else if (!operatingSystem.equals(other.operatingSystem))
|
||||||
return false;
|
|
||||||
if (osFamily == null) {
|
|
||||||
if (other.osFamily != null)
|
|
||||||
return false;
|
|
||||||
} else if (!osFamily.equals(other.osFamily))
|
|
||||||
return false;
|
return false;
|
||||||
if (version == null) {
|
if (version == null) {
|
||||||
if (other.version != null)
|
if (other.version != null)
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.compute.internal;
|
package org.jclouds.compute.domain.internal;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.base.Predicates.and;
|
import static com.google.common.base.Predicates.and;
|
||||||
|
@ -38,11 +38,11 @@ import javax.inject.Provider;
|
||||||
import org.jclouds.compute.domain.Architecture;
|
import org.jclouds.compute.domain.Architecture;
|
||||||
import org.jclouds.compute.domain.ComputeMetadata;
|
import org.jclouds.compute.domain.ComputeMetadata;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
import org.jclouds.compute.domain.Size;
|
import org.jclouds.compute.domain.Size;
|
||||||
import org.jclouds.compute.domain.Template;
|
import org.jclouds.compute.domain.Template;
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
import org.jclouds.compute.domain.TemplateBuilder;
|
||||||
import org.jclouds.compute.domain.internal.TemplateImpl;
|
|
||||||
import org.jclouds.compute.options.TemplateOptions;
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
|
@ -50,9 +50,11 @@ import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.collect.ComparisonChain;
|
import com.google.common.collect.ComparisonChain;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Ordering;
|
import com.google.common.collect.Ordering;
|
||||||
import com.google.common.primitives.Doubles;
|
import com.google.common.primitives.Doubles;
|
||||||
|
@ -75,8 +77,6 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
protected final Provider<TemplateOptions> optionsProvider;
|
protected final Provider<TemplateOptions> optionsProvider;
|
||||||
protected final Provider<TemplateBuilder> defaultTemplateProvider;
|
protected final Provider<TemplateBuilder> defaultTemplateProvider;
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
protected OsFamily os;
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected Architecture arch;
|
protected Architecture arch;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
@ -86,9 +86,19 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected String sizeId;
|
protected String sizeId;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
protected String imageVersion;
|
||||||
|
@VisibleForTesting
|
||||||
|
protected OsFamily osFamily;
|
||||||
|
@VisibleForTesting
|
||||||
|
protected String osVersion;
|
||||||
|
@VisibleForTesting
|
||||||
|
protected Boolean os64Bit;
|
||||||
|
@VisibleForTesting
|
||||||
|
protected String osName;
|
||||||
|
@VisibleForTesting
|
||||||
protected String osDescription;
|
protected String osDescription;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected String imageVersion;
|
protected String osArch;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected String imageName;
|
protected String imageName;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
@ -107,8 +117,7 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
@Inject
|
@Inject
|
||||||
protected TemplateBuilderImpl(Supplier<Set<? extends Location>> locations, Supplier<Set<? extends Image>> images,
|
protected TemplateBuilderImpl(Supplier<Set<? extends Location>> locations, Supplier<Set<? extends Image>> images,
|
||||||
Supplier<Set<? extends Size>> sizes, Supplier<Location> defaultLocation2,
|
Supplier<Set<? extends Size>> sizes, Supplier<Location> defaultLocation2,
|
||||||
Provider<TemplateOptions> optionsProvider,
|
Provider<TemplateOptions> optionsProvider, @Named("DEFAULT") Provider<TemplateBuilder> defaultTemplateProvider) {
|
||||||
@Named("DEFAULT") Provider<TemplateBuilder> defaultTemplateProvider) {
|
|
||||||
this.locations = locations;
|
this.locations = locations;
|
||||||
this.images = images;
|
this.images = images;
|
||||||
this.sizes = sizes;
|
this.sizes = sizes;
|
||||||
|
@ -118,11 +127,13 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the current location id is null, then we don't care where to launch a node.
|
* If the current location id is null, then we don't care where to launch a
|
||||||
|
* node.
|
||||||
*
|
*
|
||||||
* If the input location is null, then the data isn't location sensitive
|
* If the input location is null, then the data isn't location sensitive
|
||||||
*
|
*
|
||||||
* If the input location is a parent of the specified location, then we are ok.
|
* If the input location is a parent of the specified location, then we are
|
||||||
|
* ok.
|
||||||
*/
|
*/
|
||||||
private final Predicate<ComputeMetadata> locationPredicate = new Predicate<ComputeMetadata>() {
|
private final Predicate<ComputeMetadata> locationPredicate = new Predicate<ComputeMetadata>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -150,13 +161,13 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private final Predicate<Image> osPredicate = new Predicate<Image>() {
|
private final Predicate<OperatingSystem> osFamilyPredicate = new Predicate<OperatingSystem>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Image input) {
|
public boolean apply(OperatingSystem input) {
|
||||||
boolean returnVal = true;
|
boolean returnVal = true;
|
||||||
if (os != null)
|
if (osFamily != null)
|
||||||
returnVal = os.equals(input.getOsFamily());
|
returnVal = osFamily.equals(input.getFamily());
|
||||||
return returnVal;
|
return returnVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,21 +183,77 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
private final Predicate<OperatingSystem> osNamePredicate = new Predicate<OperatingSystem>() {
|
||||||
private final Predicate<Image> osDescriptionPredicate = new Predicate<Image>() {
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Image input) {
|
public boolean apply(OperatingSystem input) {
|
||||||
boolean returnVal = true;
|
boolean returnVal = true;
|
||||||
if (osDescription != null) {
|
if (osName != null) {
|
||||||
if (input.getOsDescription() == null)
|
if (input.getName() == null)
|
||||||
returnVal = false;
|
returnVal = false;
|
||||||
else
|
else
|
||||||
returnVal = input.getOsDescription().contains(osDescription)
|
returnVal = input.getName().contains(osName) || input.getName().matches(osName);
|
||||||
|| input.getOsDescription().matches(osDescription);
|
|
||||||
}
|
}
|
||||||
return returnVal;
|
return returnVal;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private final Predicate<OperatingSystem> osDescriptionPredicate = new Predicate<OperatingSystem>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(OperatingSystem input) {
|
||||||
|
boolean returnVal = true;
|
||||||
|
if (osDescription != null) {
|
||||||
|
if (input.getDescription() == null)
|
||||||
|
returnVal = false;
|
||||||
|
else
|
||||||
|
returnVal = input.getDescription().contains(osDescription)
|
||||||
|
|| input.getDescription().matches(osDescription);
|
||||||
|
}
|
||||||
|
return returnVal;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private final Predicate<OperatingSystem> osVersionPredicate = new Predicate<OperatingSystem>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(OperatingSystem input) {
|
||||||
|
boolean returnVal = true;
|
||||||
|
if (osVersion != null) {
|
||||||
|
if (input.getVersion() == null)
|
||||||
|
returnVal = false;
|
||||||
|
else
|
||||||
|
returnVal = input.getVersion().contains(osVersion) || input.getVersion().matches(osVersion);
|
||||||
|
}
|
||||||
|
return returnVal;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private final Predicate<OperatingSystem> os64BitPredicate = new Predicate<OperatingSystem>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(OperatingSystem input) {
|
||||||
|
boolean returnVal = true;
|
||||||
|
if (os64Bit != null) {
|
||||||
|
if (os64Bit)
|
||||||
|
return input.is64Bit();
|
||||||
|
else
|
||||||
|
return !input.is64Bit();
|
||||||
|
}
|
||||||
|
return returnVal;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private final Predicate<OperatingSystem> osArchPredicate = new Predicate<OperatingSystem>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(OperatingSystem input) {
|
||||||
|
boolean returnVal = true;
|
||||||
|
if (osArch != null) {
|
||||||
|
if (input.getArch() == null)
|
||||||
|
returnVal = false;
|
||||||
|
else
|
||||||
|
returnVal = input.getArch().contains(osArch) || input.getArch().matches(osArch);
|
||||||
|
}
|
||||||
|
return returnVal;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private final Predicate<Image> imageVersionPredicate = new Predicate<Image>() {
|
private final Predicate<Image> imageVersionPredicate = new Predicate<Image>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Image input) {
|
public boolean apply(Image input) {
|
||||||
|
@ -200,6 +267,7 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
return returnVal;
|
return returnVal;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private final Predicate<Image> imageNamePredicate = new Predicate<Image>() {
|
private final Predicate<Image> imageNamePredicate = new Predicate<Image>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Image input) {
|
public boolean apply(Image input) {
|
||||||
|
@ -274,9 +342,14 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
public int compare(Image left, Image right) {
|
public int compare(Image left, Image right) {
|
||||||
return ComparisonChain.start().compare(left.getName(), right.getName(),
|
return ComparisonChain.start().compare(left.getName(), right.getName(),
|
||||||
Ordering.<String> natural().nullsLast()).compare(left.getVersion(), right.getVersion(),
|
Ordering.<String> natural().nullsLast()).compare(left.getVersion(), right.getVersion(),
|
||||||
Ordering.<String> natural().nullsLast()).compare(left.getOsDescription(), right.getOsDescription(),
|
Ordering.<String> natural().nullsLast()).compare(left.getOperatingSystem().getName(),
|
||||||
Ordering.<String> natural().nullsLast()).compare(left.getArchitecture(), right.getArchitecture())
|
right.getOperatingSystem().getName(),//
|
||||||
.result();
|
Ordering.<String> natural().nullsLast()).compare(left.getOperatingSystem().getVersion(),
|
||||||
|
right.getOperatingSystem().getVersion(),//
|
||||||
|
Ordering.<String> natural().nullsLast()).compare(left.getOperatingSystem().getDescription(),
|
||||||
|
right.getOperatingSystem().getDescription(),//
|
||||||
|
Ordering.<String> natural().nullsLast()).compare(left.getOperatingSystem().getArch(),
|
||||||
|
right.getOperatingSystem().getArch()).result();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -309,16 +382,23 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
public TemplateBuilder fromImage(Image image) {
|
public TemplateBuilder fromImage(Image image) {
|
||||||
if (image.getLocation() != null)
|
if (image.getLocation() != null)
|
||||||
this.location = image.getLocation();
|
this.location = image.getLocation();
|
||||||
if (image.getOsFamily() != null)
|
if (image.getOperatingSystem().getFamily() != null)
|
||||||
this.os = image.getOsFamily();
|
this.osFamily = image.getOperatingSystem().getFamily();
|
||||||
if (image.getName() != null)
|
if (image.getName() != null)
|
||||||
this.imageName = image.getName();
|
this.imageName = image.getName();
|
||||||
if (image.getDescription() != null)
|
if (image.getDescription() != null)
|
||||||
this.imageDescription = image.getDescription();
|
this.imageDescription = image.getDescription();
|
||||||
if (image.getOsDescription() != null)
|
if (image.getOperatingSystem().getName() != null)
|
||||||
this.osDescription = image.getOsDescription();
|
this.osName = image.getOperatingSystem().getName();
|
||||||
|
if (image.getOperatingSystem().getDescription() != null)
|
||||||
|
this.osDescription = image.getOperatingSystem().getDescription();
|
||||||
if (image.getVersion() != null)
|
if (image.getVersion() != null)
|
||||||
this.imageVersion = image.getVersion();
|
this.imageVersion = image.getVersion();
|
||||||
|
if (image.getOperatingSystem().getVersion() != null)
|
||||||
|
this.osVersion = image.getOperatingSystem().getVersion();
|
||||||
|
this.os64Bit = image.getOperatingSystem().is64Bit();
|
||||||
|
if (image.getOperatingSystem().getArch() != null)
|
||||||
|
this.osArch = image.getOperatingSystem().getArch();
|
||||||
if (image.getArchitecture() != null)
|
if (image.getArchitecture() != null)
|
||||||
this.arch = image.getArchitecture();
|
this.arch = image.getArchitecture();
|
||||||
return this;
|
return this;
|
||||||
|
@ -372,7 +452,7 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public TemplateBuilder osFamily(OsFamily os) {
|
public TemplateBuilder osFamily(OsFamily os) {
|
||||||
this.os = os;
|
this.osFamily = os;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -494,9 +574,17 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
predicates.add(osPredicate);
|
predicates.add(new Predicate<Image>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Image input) {
|
||||||
|
return Predicates.and(
|
||||||
|
ImmutableSet.of(osFamilyPredicate, osNamePredicate, osDescriptionPredicate, osVersionPredicate,
|
||||||
|
os64BitPredicate, osArchPredicate)).apply(input.getOperatingSystem());
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
predicates.add(imageArchPredicate);
|
predicates.add(imageArchPredicate);
|
||||||
predicates.add(osDescriptionPredicate);
|
|
||||||
predicates.add(imageVersionPredicate);
|
predicates.add(imageVersionPredicate);
|
||||||
predicates.add(imageNamePredicate);
|
predicates.add(imageNamePredicate);
|
||||||
predicates.add(imageDescriptionPredicate);
|
predicates.add(imageDescriptionPredicate);
|
||||||
|
@ -516,8 +604,12 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
this.imageDescription = null;
|
this.imageDescription = null;
|
||||||
this.imageVersion = null;
|
this.imageVersion = null;
|
||||||
this.arch = null;
|
this.arch = null;
|
||||||
this.os = null;
|
this.osFamily = null;
|
||||||
|
this.osName = null;
|
||||||
this.osDescription = null;
|
this.osDescription = null;
|
||||||
|
this.osVersion = null;
|
||||||
|
this.os64Bit = null;
|
||||||
|
this.osArch = null;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -548,6 +640,24 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public TemplateBuilder osVersionMatches(String osVersionRegex) {
|
||||||
|
this.osVersion = osVersionRegex;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public TemplateBuilder osArchMatches(String osArchitectureRegex) {
|
||||||
|
this.osArch = osArchitectureRegex;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -566,6 +676,15 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public TemplateBuilder osNameMatches(String osNameRegex) {
|
||||||
|
this.osName = osNameRegex;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -613,9 +732,10 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
boolean nothingChangedExceptOptions() {
|
boolean nothingChangedExceptOptions() {
|
||||||
return os == null && arch == null && location == null && imageId == null && sizeId == null
|
return osFamily == null && arch == null && location == null && imageId == null && sizeId == null
|
||||||
&& osDescription == null && imageVersion == null && imageName == null && imageDescription == null
|
&& osName == null && osDescription == null && imageVersion == null && osVersion == null && osArch == null
|
||||||
&& minCores == 0 && minRam == 0 && !biggest && !fastest;
|
&& os64Bit == null && imageName == null && imageDescription == null && minCores == 0 && minRam == 0
|
||||||
|
&& !biggest && !fastest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -630,8 +750,15 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[arch=" + arch + ", biggest=" + biggest + ", fastest=" + fastest + ", imageName=" + imageName
|
return "[arch=" + arch + ", biggest=" + biggest + ", fastest=" + fastest + ", imageName=" + imageName
|
||||||
+ ", imageDescription=" + imageDescription + ", imageId=" + imageId + ", imageVersion=" + imageVersion
|
+ ", imageDescription=" + imageDescription + ", imageId=" + imageId + ", imageVersion=" + imageVersion
|
||||||
+ ", location=" + location + ", minCores=" + minCores + ", minRam=" + minRam + ", os=" + os
|
+ ", location=" + location + ", minCores=" + minCores + ", minRam=" + minRam + ", osFamily=" + osFamily
|
||||||
+ ", osDescription=" + osDescription + ", sizeId=" + sizeId + "]";
|
+ ", osName=" + osName + ", osDescription=" + osDescription + ", osVersion=" + osVersion + ", osArch=" + osArch + ", os64Bit="
|
||||||
|
+ os64Bit + ", sizeId=" + sizeId + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TemplateBuilder os64bit(boolean is64Bit) {
|
||||||
|
this.os64Bit = is64Bit;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,294 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.compute.domain.os;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
|
|
||||||
|
import com.google.common.annotations.Beta;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Operating system based on DMTF CIM model.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
* @see <a href="http://dmtf.org/standards/cim/cim_schema_v2260">DMTF CIM
|
||||||
|
* model</a>
|
||||||
|
*/
|
||||||
|
@Beta
|
||||||
|
public class CIMOperatingSystem extends OperatingSystem {
|
||||||
|
|
||||||
|
public enum OSType {
|
||||||
|
/**
|
||||||
|
* Other
|
||||||
|
*/
|
||||||
|
OTHER(0, "Other", OsFamily.UNKNOWN, false),
|
||||||
|
/**
|
||||||
|
* MACOS
|
||||||
|
*/
|
||||||
|
MACOS(1, "MACOS", OsFamily.DARWIN, false),
|
||||||
|
/**
|
||||||
|
* Solaris
|
||||||
|
*/
|
||||||
|
SOLARIS(28, "Solaris", OsFamily.SOLARIS, false),
|
||||||
|
/**
|
||||||
|
* LINUX
|
||||||
|
*/
|
||||||
|
LINUX(35, "LINUX", OsFamily.LINUX, false),
|
||||||
|
/**
|
||||||
|
* FreeBSD
|
||||||
|
*/
|
||||||
|
FREEBSD(41, "FreeBSD", OsFamily.FREEBSD, false),
|
||||||
|
/**
|
||||||
|
* NetBSD
|
||||||
|
*/
|
||||||
|
NETBSD(42, "NetBSD", OsFamily.NETBSD, false),
|
||||||
|
/**
|
||||||
|
* OpenBSD
|
||||||
|
*/
|
||||||
|
OPENBSD(64, "OpenBSD", OsFamily.OPENBSD, false),
|
||||||
|
/**
|
||||||
|
* Not Applicable
|
||||||
|
*/
|
||||||
|
NOT_APPLICABLE(65, "Not Applicable", OsFamily.UNKNOWN, false),
|
||||||
|
/**
|
||||||
|
* Microsoft Windows Server 2003
|
||||||
|
*/
|
||||||
|
WINDOWS_SERVER_2003(68, "Microsoft Windows Server 2003", OsFamily.WINDOWS, false),
|
||||||
|
/**
|
||||||
|
* Microsoft Windows Server 2003 64-Bit
|
||||||
|
*/
|
||||||
|
WINDOWS_SERVER_2003_64(69, "Microsoft Windows Server 2003 64-Bit", OsFamily.WINDOWS, true),
|
||||||
|
/**
|
||||||
|
* Microsoft Windows Server 2008
|
||||||
|
*/
|
||||||
|
WINDOWS_SERVER_2008(75, "Microsoft Windows Server 2008", OsFamily.WINDOWS, false),
|
||||||
|
/**
|
||||||
|
* Microsoft Windows Server 2008 64-Bit
|
||||||
|
*/
|
||||||
|
WINDOWS_SERVER_2008_64(76, "Microsoft Windows Server 2008 64-Bit", OsFamily.WINDOWS, true),
|
||||||
|
/**
|
||||||
|
* FreeBSD 64-Bit
|
||||||
|
*/
|
||||||
|
FREEBSD_64(77, "FreeBSD 64-Bit", OsFamily.FREEBSD, true),
|
||||||
|
/**
|
||||||
|
* RedHat Enterprise Linux
|
||||||
|
*/
|
||||||
|
RHEL(78, "RedHat Enterprise Linux", OsFamily.RHEL, false),
|
||||||
|
/**
|
||||||
|
* RedHat Enterprise Linux 64-Bit
|
||||||
|
*/
|
||||||
|
RHEL_64(79, "RedHat Enterprise Linux 64-Bit", OsFamily.RHEL, true),
|
||||||
|
/**
|
||||||
|
* Solaris 64-Bit
|
||||||
|
*/
|
||||||
|
SOLARIS_64(80, "Solaris 64-Bit", OsFamily.SOLARIS, true),
|
||||||
|
/**
|
||||||
|
* SUSE
|
||||||
|
*/
|
||||||
|
SUSE(81, "SUSE", OsFamily.SUSE, false),
|
||||||
|
/**
|
||||||
|
* SUSE 64-Bit
|
||||||
|
*/
|
||||||
|
SUSE_64(82, "SUSE 64-Bit", OsFamily.SUSE, true),
|
||||||
|
/**
|
||||||
|
* SLES
|
||||||
|
*/
|
||||||
|
SLES(83, "SLES", OsFamily.SUSE, false),
|
||||||
|
/**
|
||||||
|
* SLES 64-Bit
|
||||||
|
*/
|
||||||
|
SLES_64(84, "SLES 64-Bit", OsFamily.SUSE, true),
|
||||||
|
/**
|
||||||
|
* Novell OES
|
||||||
|
*/
|
||||||
|
NOVELL_OES(85, "Novell OES", OsFamily.SUSE, true),
|
||||||
|
/**
|
||||||
|
* Mandriva
|
||||||
|
*/
|
||||||
|
MANDRIVA(88, "Mandriva", OsFamily.MANDRIVA, false),
|
||||||
|
/**
|
||||||
|
* Mandriva 64-Bit
|
||||||
|
*/
|
||||||
|
MANDRIVA_64(89, "Mandriva 64-Bit", OsFamily.MANDRIVA, true),
|
||||||
|
/**
|
||||||
|
* TurboLinux
|
||||||
|
*/
|
||||||
|
TURBOLINUX(90, "TurboLinux", OsFamily.TURBOLINUX, false),
|
||||||
|
/**
|
||||||
|
* TurboLinux 64-Bit
|
||||||
|
*/
|
||||||
|
TURBOLINUX_64(91, "TurboLinux 64-Bit", OsFamily.TURBOLINUX, true),
|
||||||
|
/**
|
||||||
|
* Ubuntu
|
||||||
|
*/
|
||||||
|
UBUNTU(92, "Ubuntu", OsFamily.UBUNTU, false),
|
||||||
|
/**
|
||||||
|
* Ubuntu 64-Bit
|
||||||
|
*/
|
||||||
|
UBUNTU_64(93, "Ubuntu 64-Bit", OsFamily.UBUNTU, true),
|
||||||
|
/**
|
||||||
|
* Debian
|
||||||
|
*/
|
||||||
|
DEBIAN(94, "Debian", OsFamily.DEBIAN, false),
|
||||||
|
/**
|
||||||
|
* Debian 64-Bit
|
||||||
|
*/
|
||||||
|
DEBIAN_64(95, "Debian 64-Bit", OsFamily.DEBIAN, false),
|
||||||
|
/**
|
||||||
|
* Linux 2.4.x
|
||||||
|
*/
|
||||||
|
LINUX_2_4(96, "Linux 2.4.x", OsFamily.LINUX, false),
|
||||||
|
/**
|
||||||
|
* Linux 2.4.x 64-Bi
|
||||||
|
*/
|
||||||
|
LINUX_2_4_64(97, "Linux 2.4.x 64-Bit", OsFamily.LINUX, true),
|
||||||
|
/**
|
||||||
|
* Linux 2.6.x
|
||||||
|
*/
|
||||||
|
LINUX_2_6(98, "Linux 2.6.x", OsFamily.LINUX, false),
|
||||||
|
/**
|
||||||
|
* Linux 2.6.x 64-Bit
|
||||||
|
*/
|
||||||
|
LINUX_2_6_64(99, "Linux 2.6.x 64-Bit", OsFamily.LINUX, true),
|
||||||
|
/**
|
||||||
|
* Linux 64-Bit
|
||||||
|
*/
|
||||||
|
LINUX_64(100, "Linux 64-Bit", OsFamily.LINUX, true),
|
||||||
|
/**
|
||||||
|
* Other 64-Bit
|
||||||
|
*/
|
||||||
|
OTHER_64(101, "Other 64-Bit", OsFamily.UNKNOWN, true),
|
||||||
|
/**
|
||||||
|
* Microsoft Windows Server 2008 R2
|
||||||
|
*/
|
||||||
|
WINDOWS_SERVER_2008_R2(102, "Microsoft Windows Server 2008 R2", OsFamily.WINDOWS, true),
|
||||||
|
/**
|
||||||
|
* VMware ESXi
|
||||||
|
*/
|
||||||
|
ESXI(103, "VMware ESXi", OsFamily.ESX, true),
|
||||||
|
/**
|
||||||
|
* Microsoft Windows 7
|
||||||
|
*/
|
||||||
|
WINDOWS_7(104, "Microsoft Windows 7", OsFamily.WINDOWS, false),
|
||||||
|
/**
|
||||||
|
* CentOS 32-bit
|
||||||
|
*/
|
||||||
|
CENTOS(105, "CentOS 32-bit", OsFamily.CENTOS, false),
|
||||||
|
/**
|
||||||
|
* CentOS 64-bit
|
||||||
|
*/
|
||||||
|
CENTOS_64(106, "CentOS 64-bit", OsFamily.CENTOS, true),
|
||||||
|
/**
|
||||||
|
* Oracle Enterprise Linux 32-bit
|
||||||
|
*/
|
||||||
|
ORACLE_ENTERPRISE_LINUX(107, "Oracle Enterprise Linux 32-bit", OsFamily.OEL, false),
|
||||||
|
/**
|
||||||
|
* Oracle Enterprise Linux 64-bit
|
||||||
|
*/
|
||||||
|
ORACLE_ENTERPRISE_LINUX_64(108, "Oracle Enterprise Linux 64-bit", OsFamily.OEL, true);
|
||||||
|
|
||||||
|
private final int code;
|
||||||
|
|
||||||
|
public int getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OsFamily getFamily() {
|
||||||
|
return family;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean is64Bit() {
|
||||||
|
return is64Bit;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String value;
|
||||||
|
private final OsFamily family;
|
||||||
|
private final boolean is64Bit;
|
||||||
|
|
||||||
|
OSType(int code, String value, OsFamily family, boolean is64Bit) {
|
||||||
|
this.code = code;
|
||||||
|
this.value = value;
|
||||||
|
this.family = family;
|
||||||
|
this.is64Bit = is64Bit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static OSType fromValue(int code) {
|
||||||
|
for (OSType type : values()) {
|
||||||
|
if (type.code == code)
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
return OTHER;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private OSType osType;
|
||||||
|
|
||||||
|
protected CIMOperatingSystem() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CIMOperatingSystem(OSType osType, String version, String arch, String description) {
|
||||||
|
super(osType.getFamily(), osType.getValue(), version, arch, description, osType.is64Bit());
|
||||||
|
this.osType = osType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CIM OSType of the image
|
||||||
|
*/
|
||||||
|
public OSType getOsType() {
|
||||||
|
return osType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = super.hashCode();
|
||||||
|
result = prime * result + ((osType == null) ? 0 : osType.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (!super.equals(obj))
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
CIMOperatingSystem other = (CIMOperatingSystem) obj;
|
||||||
|
if (osType == null) {
|
||||||
|
if (other.osType != null)
|
||||||
|
return false;
|
||||||
|
} else if (!osType.equals(other.osType))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[osType=" + osType + ", version=" + getVersion() + ", arch=" + getArch() + ", description="
|
||||||
|
+ getDescription() + "]";
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,7 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.Architecture;
|
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
|
@ -84,19 +83,19 @@ public class ImagePredicates {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Predicate<Image> architectureIn(
|
/**
|
||||||
Iterable<Architecture> architectures) {
|
* return true if this is a 64bit image.
|
||||||
checkNotNull(architectures, "architectures must be defined");
|
*/
|
||||||
final Set<Architecture> search = Sets.newHashSet(architectures);
|
public static Predicate<Image> is64Bit() {
|
||||||
return new Predicate<Image>() {
|
return new Predicate<Image>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Image image) {
|
public boolean apply(Image image) {
|
||||||
return search.contains(image.getArchitecture());
|
return image.getOperatingSystem().is64Bit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "architectureIn(" + search + ")";
|
return "is64Bit()";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,115 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.compute.predicates;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.base.Predicates;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Container for operating system filters (predicates).
|
||||||
|
*
|
||||||
|
* This class has static methods that create customized predicates to use with
|
||||||
|
* {@link org.jclouds.compute.ComputeService}.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class OperatingSystemPredicates {
|
||||||
|
/**
|
||||||
|
* evaluates true if the OperatingSystem supports the apt installer
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static Predicate<OperatingSystem> supportsApt() {
|
||||||
|
return new Predicate<OperatingSystem>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(OperatingSystem os) {
|
||||||
|
if (os.getFamily() != null) {
|
||||||
|
switch (os.getFamily()) {
|
||||||
|
case DEBIAN:
|
||||||
|
case UBUNTU:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String toMatch = os.getName() != null ? os.getName() : os.getDescription();
|
||||||
|
return (toMatch.toLowerCase().indexOf("ubuntu") != -1 || toMatch.toLowerCase().indexOf("debian") != -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "supportsApt()";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* evaluates true if the OperatingSystem supports the yum installer
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static Predicate<OperatingSystem> supportsYum() {
|
||||||
|
return new Predicate<OperatingSystem>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(OperatingSystem os) {
|
||||||
|
if (os.getFamily() != null) {
|
||||||
|
switch (os.getFamily()) {
|
||||||
|
case CENTOS:
|
||||||
|
case FEDORA:
|
||||||
|
case RHEL:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String toMatch = os.getName() != null ? os.getName() : os.getDescription();
|
||||||
|
return (toMatch.toLowerCase().indexOf("centos") != -1 || toMatch.toLowerCase().indexOf("rhel") != -1
|
||||||
|
|| toMatch.toLowerCase().replace(" ", "").indexOf("redhate") != -1 || toMatch.toLowerCase().indexOf(
|
||||||
|
"fedora") != -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "supportsYum()";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return everything.
|
||||||
|
*/
|
||||||
|
public static Predicate<OperatingSystem> any() {
|
||||||
|
return Predicates.<OperatingSystem> alwaysTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return true if this is a 64bit os.
|
||||||
|
*/
|
||||||
|
public static Predicate<OperatingSystem> is64Bit() {
|
||||||
|
return new Predicate<OperatingSystem>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(OperatingSystem os) {
|
||||||
|
return os.is64Bit();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "is64Bit()";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -20,7 +20,7 @@
|
||||||
package org.jclouds.compute.stub.config;
|
package org.jclouds.compute.stub.config;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static org.jclouds.compute.predicates.ImagePredicates.architectureIn;
|
import static org.jclouds.compute.predicates.ImagePredicates.any;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -41,11 +41,11 @@ import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.compute.LoadBalancerService;
|
import org.jclouds.compute.LoadBalancerService;
|
||||||
import org.jclouds.compute.config.BaseComputeServiceContextModule;
|
import org.jclouds.compute.config.BaseComputeServiceContextModule;
|
||||||
import org.jclouds.compute.config.ComputeServiceTimeoutsModule;
|
import org.jclouds.compute.config.ComputeServiceTimeoutsModule;
|
||||||
import org.jclouds.compute.domain.Architecture;
|
|
||||||
import org.jclouds.compute.domain.ComputeMetadata;
|
import org.jclouds.compute.domain.ComputeMetadata;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeState;
|
||||||
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
import org.jclouds.compute.domain.Size;
|
import org.jclouds.compute.domain.Size;
|
||||||
import org.jclouds.compute.domain.Template;
|
import org.jclouds.compute.domain.Template;
|
||||||
|
@ -351,14 +351,19 @@ public class StubComputeServiceContextModule extends BaseComputeServiceContextMo
|
||||||
}));
|
}));
|
||||||
Location zone = defaultLocation.get().getParent();
|
Location zone = defaultLocation.get().getParent();
|
||||||
String parentId = zone.getId();
|
String parentId = zone.getId();
|
||||||
return Suppliers.<Set<? extends Image>> ofInstance(ImmutableSet.<Image> of(new ImageImpl("1", OsFamily.UBUNTU
|
return Suppliers.<Set<? extends Image>> ofInstance(ImmutableSet.<Image> of(//
|
||||||
.name(), parentId + "/1", zone, null, ImmutableMap.<String, String> of(), "stub ubuntu 32", "",
|
new ImageImpl("1", OsFamily.UBUNTU.name(), parentId + "/1", zone, null,
|
||||||
OsFamily.UBUNTU, "ubuntu 64", Architecture.X86_64, new Credentials("root", null)), new ImageImpl("2",
|
ImmutableMap.<String, String> of(), //
|
||||||
OsFamily.UBUNTU.name(), parentId + "/2", zone, null, ImmutableMap.<String, String> of(),
|
new OperatingSystem(OsFamily.UBUNTU, "ubuntu 32", null, "X86_32", "ubuntu 32", false),
|
||||||
"stub ubuntu 64", "", OsFamily.UBUNTU, "ubuntu 64", Architecture.X86_64, new Credentials("root", null)),
|
"stub ubuntu 32", "", null, new Credentials("root", null)), //
|
||||||
new ImageImpl("3", OsFamily.CENTOS.name(), parentId + "/3", zone, null, ImmutableMap
|
new ImageImpl("2", OsFamily.UBUNTU.name(), parentId + "/2", zone, null,
|
||||||
.<String, String> of(), "stub centos 64", "", OsFamily.CENTOS, "centos 64",
|
ImmutableMap.<String, String> of(),//
|
||||||
Architecture.X86_64, new Credentials("root", null))));
|
new OperatingSystem(OsFamily.UBUNTU, "ubuntu 64", null, "X86_64", "ubuntu 64", true),
|
||||||
|
"stub ubuntu 64", "", null, new Credentials("root", null)),//
|
||||||
|
new ImageImpl("3", OsFamily.CENTOS.name(), parentId + "/3", zone, null,
|
||||||
|
ImmutableMap.<String, String> of(), //
|
||||||
|
new OperatingSystem(OsFamily.CENTOS, "centos 64", null, "X86_64", "centos 64", true),
|
||||||
|
"stub centos 64", "", null, new Credentials("root", null))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
@ -373,18 +378,16 @@ public class StubComputeServiceContextModule extends BaseComputeServiceContextMo
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Supplier<Set<? extends Size>> getSourceSizeSupplier(Injector injector) {
|
protected Supplier<Set<? extends Size>> getSourceSizeSupplier(Injector injector) {
|
||||||
return Suppliers.<Set<? extends Size>> ofInstance(ImmutableSet.<Size> of(new StubSize("small", 1, 1740, 160,
|
return Suppliers.<Set<? extends Size>> ofInstance(ImmutableSet.<Size> of(new StubSize("small", 1, 1740, 160),
|
||||||
ImmutableSet.of(Architecture.X86_32)), new StubSize("medium", 4, 7680, 850, ImmutableSet
|
new StubSize("medium", 4, 7680, 850), new StubSize("large", 8, 15360, 1690)));
|
||||||
.of(Architecture.X86_64)), new StubSize("large", 8, 15360, 1690, ImmutableSet.of(Architecture.X86_64))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class StubSize extends org.jclouds.compute.domain.internal.SizeImpl {
|
private static class StubSize extends org.jclouds.compute.domain.internal.SizeImpl {
|
||||||
/** The serialVersionUID */
|
/** The serialVersionUID */
|
||||||
private static final long serialVersionUID = -1842135761654973637L;
|
private static final long serialVersionUID = -1842135761654973637L;
|
||||||
|
|
||||||
StubSize(String type, int cores, int ram, int disk, Iterable<Architecture> supportedArchitectures) {
|
StubSize(String type, int cores, int ram, int disk) {
|
||||||
super(type, type, type, null, null, ImmutableMap.<String, String> of(), cores, ram, disk,
|
super(type, type, type, null, null, ImmutableMap.<String, String> of(), cores, ram, disk, any());
|
||||||
architectureIn(supportedArchitectures));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,6 @@ import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import org.easymock.IArgumentMatcher;
|
import org.easymock.IArgumentMatcher;
|
||||||
import org.jclouds.compute.domain.Architecture;
|
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
import org.jclouds.compute.domain.Template;
|
import org.jclouds.compute.domain.Template;
|
||||||
|
@ -87,10 +86,10 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes
|
||||||
@Test
|
@Test
|
||||||
public void testTemplateBuilder() {
|
public void testTemplateBuilder() {
|
||||||
Template defaultTemplate = client.templateBuilder().build();
|
Template defaultTemplate = client.templateBuilder().build();
|
||||||
assertEquals(defaultTemplate.getImage().getArchitecture(), Architecture.X86_64);
|
assertEquals(defaultTemplate.getImage().getOperatingSystem().getArch(), "X86_64");
|
||||||
assertEquals(defaultTemplate.getImage().getOsFamily(), OsFamily.UBUNTU);
|
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
|
||||||
assertEquals(defaultTemplate.getLocation().getId(), provider + "zone");
|
assertEquals(defaultTemplate.getLocation().getId(), provider + "zone");
|
||||||
assertEquals(defaultTemplate.getSize().getCores(), 4.0d);
|
assertEquals(defaultTemplate.getSize().getCores(), 1.0d);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.compute.internal;
|
package org.jclouds.compute.domain.internal;
|
||||||
|
|
||||||
import static org.easymock.EasyMock.expect;
|
import static org.easymock.EasyMock.expect;
|
||||||
import static org.easymock.classextension.EasyMock.createMock;
|
import static org.easymock.classextension.EasyMock.createMock;
|
||||||
|
@ -32,10 +32,10 @@ import javax.inject.Provider;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.Architecture;
|
import org.jclouds.compute.domain.Architecture;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
import org.jclouds.compute.domain.Size;
|
import org.jclouds.compute.domain.Size;
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
import org.jclouds.compute.domain.TemplateBuilder;
|
||||||
import org.jclouds.compute.domain.internal.SizeImpl;
|
|
||||||
import org.jclouds.compute.options.TemplateOptions;
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
import org.jclouds.compute.predicates.ImagePredicates;
|
import org.jclouds.compute.predicates.ImagePredicates;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
|
@ -58,7 +58,9 @@ public class TemplateBuilderImplTest {
|
||||||
public void tesResolveImages() {
|
public void tesResolveImages() {
|
||||||
Location defaultLocation = createMock(Location.class);
|
Location defaultLocation = createMock(Location.class);
|
||||||
Image image = createMock(Image.class);
|
Image image = createMock(Image.class);
|
||||||
|
OperatingSystem os = createMock(OperatingSystem.class);
|
||||||
Image image2 = createMock(Image.class);
|
Image image2 = createMock(Image.class);
|
||||||
|
OperatingSystem os2 = createMock(OperatingSystem.class);
|
||||||
|
|
||||||
Size size = new SizeImpl("sizeId", null, "sizeId", defaultLocation, null, ImmutableMap.<String, String> of(),
|
Size size = new SizeImpl("sizeId", null, "sizeId", defaultLocation, null, ImmutableMap.<String, String> of(),
|
||||||
1.0, 0, 0, ImagePredicates.any());
|
1.0, 0, 0, ImagePredicates.any());
|
||||||
|
@ -72,29 +74,39 @@ public class TemplateBuilderImplTest {
|
||||||
Provider<TemplateBuilder> templateBuilderProvider = createMock(Provider.class);
|
Provider<TemplateBuilder> templateBuilderProvider = createMock(Provider.class);
|
||||||
TemplateBuilder defaultTemplate = createMock(TemplateBuilder.class);
|
TemplateBuilder defaultTemplate = createMock(TemplateBuilder.class);
|
||||||
|
|
||||||
expect(image.getName()).andReturn("image");
|
expect(image.getName()).andReturn("imageName");
|
||||||
expect(image2.getName()).andReturn("image");
|
expect(image2.getName()).andReturn("imageName");
|
||||||
expect(image.getVersion()).andReturn("version");
|
expect(image.getVersion()).andReturn("imageVersion");
|
||||||
expect(image2.getVersion()).andReturn("version");
|
expect(image2.getVersion()).andReturn("imageVersion");
|
||||||
expect(image.getOsDescription()).andReturn("osDescription");
|
expect(image.getOperatingSystem()).andReturn(os).atLeastOnce();
|
||||||
expect(image2.getOsDescription()).andReturn("osDescription");
|
expect(image2.getOperatingSystem()).andReturn(os2).atLeastOnce();
|
||||||
expect(image.getArchitecture()).andReturn(Architecture.X86_64).atLeastOnce();
|
expect(os.getName()).andReturn("osName");
|
||||||
expect(image2.getArchitecture()).andReturn(Architecture.X86_64).atLeastOnce();
|
expect(os2.getName()).andReturn("osName");
|
||||||
|
expect(os.getVersion()).andReturn("osVersion");
|
||||||
|
expect(os2.getVersion()).andReturn("osVersion");
|
||||||
|
expect(os.getDescription()).andReturn("osDescription");
|
||||||
|
expect(os2.getDescription()).andReturn("osDescription");
|
||||||
|
expect(os.getArch()).andReturn("X86_64").atLeastOnce();
|
||||||
|
expect(os2.getArch()).andReturn("X86_64").atLeastOnce();
|
||||||
|
|
||||||
replay(image);
|
replay(image);
|
||||||
replay(image2);
|
replay(image2);
|
||||||
|
replay(os);
|
||||||
|
replay(os2);
|
||||||
replay(defaultTemplate);
|
replay(defaultTemplate);
|
||||||
replay(defaultLocation);
|
replay(defaultLocation);
|
||||||
replay(optionsProvider);
|
replay(optionsProvider);
|
||||||
replay(templateBuilderProvider);
|
replay(templateBuilderProvider);
|
||||||
|
|
||||||
TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation, optionsProvider,
|
TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation,
|
||||||
templateBuilderProvider);
|
optionsProvider, templateBuilderProvider);
|
||||||
|
|
||||||
assertEquals(template.resolveImage(size, images.get()), image2);
|
assertEquals(template.resolveImage(size, images.get()), image2);
|
||||||
|
|
||||||
verify(image);
|
verify(image);
|
||||||
verify(image2);
|
verify(image2);
|
||||||
|
verify(os);
|
||||||
|
verify(os2);
|
||||||
verify(defaultTemplate);
|
verify(defaultTemplate);
|
||||||
verify(defaultLocation);
|
verify(defaultLocation);
|
||||||
verify(optionsProvider);
|
verify(optionsProvider);
|
||||||
|
@ -107,6 +119,8 @@ public class TemplateBuilderImplTest {
|
||||||
Location defaultLocation = createMock(Location.class);
|
Location defaultLocation = createMock(Location.class);
|
||||||
Image image = createMock(Image.class);
|
Image image = createMock(Image.class);
|
||||||
Image image2 = createMock(Image.class);
|
Image image2 = createMock(Image.class);
|
||||||
|
OperatingSystem os = createMock(OperatingSystem.class);
|
||||||
|
OperatingSystem os2 = createMock(OperatingSystem.class);
|
||||||
|
|
||||||
Size size = new SizeImpl("sizeId", null, "sizeId", defaultLocation, null, ImmutableMap.<String, String> of(),
|
Size size = new SizeImpl("sizeId", null, "sizeId", defaultLocation, null, ImmutableMap.<String, String> of(),
|
||||||
1.0, 0, 0, ImagePredicates.any());
|
1.0, 0, 0, ImagePredicates.any());
|
||||||
|
@ -127,21 +141,27 @@ public class TemplateBuilderImplTest {
|
||||||
|
|
||||||
expect(image2.getLocation()).andReturn(defaultLocation).atLeastOnce();
|
expect(image2.getLocation()).andReturn(defaultLocation).atLeastOnce();
|
||||||
expect(image2.getArchitecture()).andReturn(Architecture.X86_64).atLeastOnce();
|
expect(image2.getArchitecture()).andReturn(Architecture.X86_64).atLeastOnce();
|
||||||
|
expect(image.getOperatingSystem()).andReturn(os).atLeastOnce();
|
||||||
|
expect(image2.getOperatingSystem()).andReturn(os2).atLeastOnce();
|
||||||
|
|
||||||
replay(image);
|
replay(image);
|
||||||
replay(image2);
|
replay(image2);
|
||||||
|
replay(os);
|
||||||
|
replay(os2);
|
||||||
replay(defaultTemplate);
|
replay(defaultTemplate);
|
||||||
replay(defaultLocation);
|
replay(defaultLocation);
|
||||||
replay(optionsProvider);
|
replay(optionsProvider);
|
||||||
replay(templateBuilderProvider);
|
replay(templateBuilderProvider);
|
||||||
|
|
||||||
TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation, optionsProvider,
|
TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation,
|
||||||
templateBuilderProvider);
|
optionsProvider, templateBuilderProvider);
|
||||||
|
|
||||||
assertEquals(template.smallest().architecture(Architecture.X86_32).build().getImage(), image);
|
assertEquals(template.smallest().architecture(Architecture.X86_32).build().getImage(), image);
|
||||||
|
|
||||||
verify(image);
|
verify(image);
|
||||||
verify(image2);
|
verify(image2);
|
||||||
|
verify(os);
|
||||||
|
verify(os2);
|
||||||
verify(defaultTemplate);
|
verify(defaultTemplate);
|
||||||
verify(defaultLocation);
|
verify(defaultLocation);
|
||||||
verify(optionsProvider);
|
verify(optionsProvider);
|
||||||
|
@ -153,6 +173,8 @@ public class TemplateBuilderImplTest {
|
||||||
public void testSizeWithImageIdPredicateOnlyAcceptsImage() {
|
public void testSizeWithImageIdPredicateOnlyAcceptsImage() {
|
||||||
Location defaultLocation = createMock(Location.class);
|
Location defaultLocation = createMock(Location.class);
|
||||||
Image image = createMock(Image.class);
|
Image image = createMock(Image.class);
|
||||||
|
OperatingSystem os = createMock(OperatingSystem.class);
|
||||||
|
|
||||||
Size size = new SizeImpl("sizeId", null, "sizeId", defaultLocation, null, ImmutableMap.<String, String> of(), 0,
|
Size size = new SizeImpl("sizeId", null, "sizeId", defaultLocation, null, ImmutableMap.<String, String> of(), 0,
|
||||||
0, 0, ImagePredicates.idEquals("imageId"));
|
0, 0, ImagePredicates.idEquals("imageId"));
|
||||||
|
|
||||||
|
@ -168,25 +190,33 @@ public class TemplateBuilderImplTest {
|
||||||
expect(optionsProvider.get()).andReturn(new TemplateOptions());
|
expect(optionsProvider.get()).andReturn(new TemplateOptions());
|
||||||
expect(image.getId()).andReturn("imageId").atLeastOnce();
|
expect(image.getId()).andReturn("imageId").atLeastOnce();
|
||||||
expect(image.getLocation()).andReturn(defaultLocation).atLeastOnce();
|
expect(image.getLocation()).andReturn(defaultLocation).atLeastOnce();
|
||||||
expect(image.getOsFamily()).andReturn(null).atLeastOnce();
|
|
||||||
expect(image.getName()).andReturn(null).atLeastOnce();
|
expect(image.getName()).andReturn(null).atLeastOnce();
|
||||||
expect(image.getDescription()).andReturn(null).atLeastOnce();
|
expect(image.getDescription()).andReturn(null).atLeastOnce();
|
||||||
expect(image.getOsDescription()).andReturn(null).atLeastOnce();
|
|
||||||
expect(image.getVersion()).andReturn(null).atLeastOnce();
|
expect(image.getVersion()).andReturn(null).atLeastOnce();
|
||||||
expect(image.getArchitecture()).andReturn(null).atLeastOnce();
|
expect(image.getArchitecture()).andReturn(null).atLeastOnce();
|
||||||
|
expect(image.getOperatingSystem()).andReturn(os).atLeastOnce();
|
||||||
|
|
||||||
|
expect(os.getName()).andReturn(null).atLeastOnce();
|
||||||
|
expect(os.getVersion()).andReturn(null).atLeastOnce();
|
||||||
|
expect(os.getFamily()).andReturn(null).atLeastOnce();
|
||||||
|
expect(os.getDescription()).andReturn(null).atLeastOnce();
|
||||||
|
expect(os.getArch()).andReturn(null).atLeastOnce();
|
||||||
|
expect(os.is64Bit()).andReturn(false).atLeastOnce();
|
||||||
|
|
||||||
replay(image);
|
replay(image);
|
||||||
|
replay(os);
|
||||||
replay(defaultTemplate);
|
replay(defaultTemplate);
|
||||||
replay(defaultLocation);
|
replay(defaultLocation);
|
||||||
replay(optionsProvider);
|
replay(optionsProvider);
|
||||||
replay(templateBuilderProvider);
|
replay(templateBuilderProvider);
|
||||||
|
|
||||||
TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation, optionsProvider,
|
TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation,
|
||||||
templateBuilderProvider);
|
optionsProvider, templateBuilderProvider);
|
||||||
|
|
||||||
template.imageId("imageId").build();
|
template.imageId("imageId").build();
|
||||||
|
|
||||||
verify(image);
|
verify(image);
|
||||||
|
verify(os);
|
||||||
verify(defaultTemplate);
|
verify(defaultTemplate);
|
||||||
verify(defaultLocation);
|
verify(defaultLocation);
|
||||||
verify(optionsProvider);
|
verify(optionsProvider);
|
||||||
|
@ -198,6 +228,8 @@ public class TemplateBuilderImplTest {
|
||||||
public void testSizeWithImageIdPredicateOnlyDoesntImage() {
|
public void testSizeWithImageIdPredicateOnlyDoesntImage() {
|
||||||
Location defaultLocation = createMock(Location.class);
|
Location defaultLocation = createMock(Location.class);
|
||||||
Image image = createMock(Image.class);
|
Image image = createMock(Image.class);
|
||||||
|
OperatingSystem os = createMock(OperatingSystem.class);
|
||||||
|
|
||||||
Size size = new SizeImpl("sizeId", null, "sizeId", defaultLocation, null, ImmutableMap.<String, String> of(), 0,
|
Size size = new SizeImpl("sizeId", null, "sizeId", defaultLocation, null, ImmutableMap.<String, String> of(), 0,
|
||||||
0, 0, ImagePredicates.idEquals("imageId"));
|
0, 0, ImagePredicates.idEquals("imageId"));
|
||||||
|
|
||||||
|
@ -213,26 +245,34 @@ public class TemplateBuilderImplTest {
|
||||||
expect(optionsProvider.get()).andReturn(new TemplateOptions());
|
expect(optionsProvider.get()).andReturn(new TemplateOptions());
|
||||||
expect(image.getId()).andReturn("notImageId").atLeastOnce();
|
expect(image.getId()).andReturn("notImageId").atLeastOnce();
|
||||||
expect(image.getLocation()).andReturn(defaultLocation).atLeastOnce();
|
expect(image.getLocation()).andReturn(defaultLocation).atLeastOnce();
|
||||||
expect(image.getOsFamily()).andReturn(null).atLeastOnce();
|
expect(image.getOperatingSystem()).andReturn(os).atLeastOnce();
|
||||||
expect(image.getName()).andReturn(null).atLeastOnce();
|
expect(image.getName()).andReturn(null).atLeastOnce();
|
||||||
expect(image.getDescription()).andReturn(null).atLeastOnce();
|
expect(image.getDescription()).andReturn(null).atLeastOnce();
|
||||||
expect(image.getOsDescription()).andReturn(null).atLeastOnce();
|
|
||||||
expect(image.getVersion()).andReturn(null).atLeastOnce();
|
expect(image.getVersion()).andReturn(null).atLeastOnce();
|
||||||
expect(image.getArchitecture()).andReturn(null).atLeastOnce();
|
expect(image.getArchitecture()).andReturn(null).atLeastOnce();
|
||||||
|
|
||||||
|
expect(os.getName()).andReturn(null).atLeastOnce();
|
||||||
|
expect(os.getVersion()).andReturn(null).atLeastOnce();
|
||||||
|
expect(os.getFamily()).andReturn(null).atLeastOnce();
|
||||||
|
expect(os.getDescription()).andReturn(null).atLeastOnce();
|
||||||
|
expect(os.getArch()).andReturn(null).atLeastOnce();
|
||||||
|
expect(os.is64Bit()).andReturn(false).atLeastOnce();
|
||||||
|
|
||||||
replay(image);
|
replay(image);
|
||||||
|
replay(os);
|
||||||
replay(defaultTemplate);
|
replay(defaultTemplate);
|
||||||
replay(defaultLocation);
|
replay(defaultLocation);
|
||||||
replay(optionsProvider);
|
replay(optionsProvider);
|
||||||
replay(templateBuilderProvider);
|
replay(templateBuilderProvider);
|
||||||
|
|
||||||
TemplateBuilderImpl template = createTemplateBuilder(image, locations, images, sizes, defaultLocation, optionsProvider,
|
TemplateBuilderImpl template = createTemplateBuilder(image, locations, images, sizes, defaultLocation,
|
||||||
templateBuilderProvider);
|
optionsProvider, templateBuilderProvider);
|
||||||
try {
|
try {
|
||||||
template.imageId("notImageId").build();
|
template.imageId("notImageId").build();
|
||||||
assert false;
|
assert false;
|
||||||
} catch (NoSuchElementException e) {
|
} catch (NoSuchElementException e) {
|
||||||
verify(image);
|
verify(image);
|
||||||
|
verify(os);
|
||||||
verify(defaultTemplate);
|
verify(defaultTemplate);
|
||||||
verify(defaultLocation);
|
verify(defaultLocation);
|
||||||
verify(optionsProvider);
|
verify(optionsProvider);
|
||||||
|
@ -265,8 +305,8 @@ public class TemplateBuilderImplTest {
|
||||||
replay(optionsProvider);
|
replay(optionsProvider);
|
||||||
replay(templateBuilderProvider);
|
replay(templateBuilderProvider);
|
||||||
|
|
||||||
TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation, optionsProvider,
|
TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation,
|
||||||
templateBuilderProvider);
|
optionsProvider, templateBuilderProvider);
|
||||||
|
|
||||||
template.options(options).build();
|
template.options(options).build();
|
||||||
|
|
||||||
|
@ -298,8 +338,8 @@ public class TemplateBuilderImplTest {
|
||||||
replay(optionsProvider);
|
replay(optionsProvider);
|
||||||
replay(templateBuilderProvider);
|
replay(templateBuilderProvider);
|
||||||
|
|
||||||
TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation, optionsProvider,
|
TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation,
|
||||||
templateBuilderProvider);
|
optionsProvider, templateBuilderProvider);
|
||||||
|
|
||||||
template.build();
|
template.build();
|
||||||
|
|
||||||
|
@ -334,8 +374,8 @@ public class TemplateBuilderImplTest {
|
||||||
replay(optionsProvider);
|
replay(optionsProvider);
|
||||||
replay(templateBuilderProvider);
|
replay(templateBuilderProvider);
|
||||||
|
|
||||||
TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation, optionsProvider,
|
TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation,
|
||||||
templateBuilderProvider);
|
optionsProvider, templateBuilderProvider);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
template.imageId("foo").locationId("location").build();
|
template.imageId("foo").locationId("location").build();
|
||||||
|
@ -369,8 +409,8 @@ public class TemplateBuilderImplTest {
|
||||||
replay(optionsProvider);
|
replay(optionsProvider);
|
||||||
replay(templateBuilderProvider);
|
replay(templateBuilderProvider);
|
||||||
|
|
||||||
TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation, optionsProvider,
|
TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation,
|
||||||
templateBuilderProvider);
|
optionsProvider, templateBuilderProvider);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
template.imageId("foo").options(provideTemplateOptions()).locationId("location").build();
|
template.imageId("foo").options(provideTemplateOptions()).locationId("location").build();
|
||||||
|
@ -403,8 +443,8 @@ public class TemplateBuilderImplTest {
|
||||||
replay(optionsProvider);
|
replay(optionsProvider);
|
||||||
replay(templateBuilderProvider);
|
replay(templateBuilderProvider);
|
||||||
|
|
||||||
TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation, optionsProvider,
|
TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation,
|
||||||
templateBuilderProvider);
|
optionsProvider, templateBuilderProvider);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
template.imageId("region/ami").build();
|
template.imageId("region/ami").build();
|
||||||
|
@ -443,8 +483,8 @@ public class TemplateBuilderImplTest {
|
||||||
replay(optionsProvider);
|
replay(optionsProvider);
|
||||||
replay(templateBuilderProvider);
|
replay(templateBuilderProvider);
|
||||||
|
|
||||||
TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation, optionsProvider,
|
TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation,
|
||||||
templateBuilderProvider);
|
optionsProvider, templateBuilderProvider);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
template.imageId("region/ami").options(provideTemplateOptions()).build();
|
template.imageId("region/ami").options(provideTemplateOptions()).build();
|
||||||
|
@ -473,8 +513,8 @@ public class TemplateBuilderImplTest {
|
||||||
replay(optionsProvider);
|
replay(optionsProvider);
|
||||||
replay(templateBuilderProvider);
|
replay(templateBuilderProvider);
|
||||||
|
|
||||||
TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation, optionsProvider,
|
TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, sizes, defaultLocation,
|
||||||
templateBuilderProvider);
|
optionsProvider, templateBuilderProvider);
|
||||||
|
|
||||||
template.architecture(Architecture.X86_32);
|
template.architecture(Architecture.X86_32);
|
||||||
template.imageDescriptionMatches("imageDescriptionMatches");
|
template.imageDescriptionMatches("imageDescriptionMatches");
|
||||||
|
@ -488,7 +528,7 @@ public class TemplateBuilderImplTest {
|
||||||
assertEquals(template.imageName, "imageNameMatches");
|
assertEquals(template.imageName, "imageNameMatches");
|
||||||
assertEquals(template.imageVersion, "imageVersionMatches");
|
assertEquals(template.imageVersion, "imageVersionMatches");
|
||||||
assertEquals(template.osDescription, "osDescriptionMatches");
|
assertEquals(template.osDescription, "osDescriptionMatches");
|
||||||
assertEquals(template.os, OsFamily.CENTOS);
|
assertEquals(template.osFamily, OsFamily.CENTOS);
|
||||||
assertEquals(template.imageId, null);
|
assertEquals(template.imageId, null);
|
||||||
|
|
||||||
template.imageId("myid");
|
template.imageId("myid");
|
||||||
|
@ -497,7 +537,7 @@ public class TemplateBuilderImplTest {
|
||||||
assertEquals(template.imageName, null);
|
assertEquals(template.imageName, null);
|
||||||
assertEquals(template.imageVersion, null);
|
assertEquals(template.imageVersion, null);
|
||||||
assertEquals(template.osDescription, null);
|
assertEquals(template.osDescription, null);
|
||||||
assertEquals(template.os, null);
|
assertEquals(template.osFamily, null);
|
||||||
assertEquals(template.imageId, "myid");
|
assertEquals(template.imageId, "myid");
|
||||||
|
|
||||||
verify(defaultLocation);
|
verify(defaultLocation);
|
|
@ -0,0 +1,127 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.compute.predicates;
|
||||||
|
|
||||||
|
import static org.jclouds.compute.predicates.OperatingSystemPredicates.supportsApt;
|
||||||
|
import static org.jclouds.compute.predicates.OperatingSystemPredicates.supportsYum;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
|
import org.jclouds.compute.domain.os.CIMOperatingSystem;
|
||||||
|
import org.jclouds.compute.domain.os.CIMOperatingSystem.OSType;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests possible uses of OperatingSystemPredicates
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public class OperatingSystemPredicatesTest {
|
||||||
|
|
||||||
|
public void testCIMCENTOSDoesntSupportApt() {
|
||||||
|
assert !supportsApt().apply(new CIMOperatingSystem(OSType.CENTOS, null, null, "description"));
|
||||||
|
assert !supportsApt().apply(new CIMOperatingSystem(OSType.CENTOS_64, null, null, "description"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testCIMRHELDoesntSupportApt() {
|
||||||
|
assert !supportsApt().apply(new CIMOperatingSystem(OSType.RHEL, null, null, "description"));
|
||||||
|
assert !supportsApt().apply(new CIMOperatingSystem(OSType.RHEL_64, null, null, "description"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testCIMDEBIANSupportsApt() {
|
||||||
|
assert supportsApt().apply(new CIMOperatingSystem(OSType.DEBIAN, null, null, "description"));
|
||||||
|
assert supportsApt().apply(new CIMOperatingSystem(OSType.DEBIAN_64, null, null, "description"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testCIMUBUNTUSupportsApt() {
|
||||||
|
assert supportsApt().apply(new CIMOperatingSystem(OSType.UBUNTU, null, null, "description"));
|
||||||
|
assert supportsApt().apply(new CIMOperatingSystem(OSType.UBUNTU_64, null, null, "description"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testUbuntuNameSupportsApt() {
|
||||||
|
assert supportsApt().apply(new OperatingSystem(null, "Ubuntu", null, null, "description", false));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testCIMCENTOSSupportsYum() {
|
||||||
|
assert supportsYum().apply(new CIMOperatingSystem(OSType.CENTOS, null, null, "description"));
|
||||||
|
assert supportsYum().apply(new CIMOperatingSystem(OSType.CENTOS_64, null, null, "description"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testCIMRHELSupportsYum() {
|
||||||
|
assert supportsYum().apply(new CIMOperatingSystem(OSType.RHEL, null, null, "description"));
|
||||||
|
assert supportsYum().apply(new CIMOperatingSystem(OSType.RHEL_64, null, null, "description"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testCIMDEBIANDoesntSupportYum() {
|
||||||
|
assert !supportsYum().apply(new CIMOperatingSystem(OSType.DEBIAN, null, null, "description"));
|
||||||
|
assert !supportsYum().apply(new CIMOperatingSystem(OSType.DEBIAN_64, null, null, "description"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testCIMUBUNTUDoesntSupportYum() {
|
||||||
|
assert !supportsYum().apply(new CIMOperatingSystem(OSType.UBUNTU, null, null, "description"));
|
||||||
|
assert !supportsYum().apply(new CIMOperatingSystem(OSType.UBUNTU_64, null, null, "description"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testCentosTypeSupportsYum() {
|
||||||
|
assert supportsYum().apply(new OperatingSystem(OsFamily.CENTOS, null, null, null, "description", false));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testRhelTypeSupportsYum() {
|
||||||
|
assert supportsYum().apply(new OperatingSystem(OsFamily.RHEL, null, null, null, "description", false));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFedoraTypeSupportsYum() {
|
||||||
|
assert supportsYum().apply(new OperatingSystem(OsFamily.FEDORA, null, null, null, "description", false));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testCentosNameSupportsYum() {
|
||||||
|
assert supportsYum().apply(new OperatingSystem(null, "Centos", null, null, "description", false));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testRhelNameSupportsYum() {
|
||||||
|
assert supportsYum().apply(new OperatingSystem(null, "RHEL", null, null, "description", false));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFedoraNameSupportsYum() {
|
||||||
|
assert supportsYum().apply(new OperatingSystem(null, "Fedora", null, null, "description", false));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testRedHatEnterpriseLinuxNameSupportsYum() {
|
||||||
|
assert supportsYum().apply(
|
||||||
|
new OperatingSystem(null, "Red Hat Enterprise Linux", null, null, "description", false));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testCentosDescriptionSupportsYum() {
|
||||||
|
assert supportsYum().apply(new OperatingSystem(null, null, null, null, "Centos", false));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testRhelDescriptionSupportsYum() {
|
||||||
|
assert supportsYum().apply(new OperatingSystem(null, null, null, null, "RHEL", false));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFedoraDescriptionSupportsYum() {
|
||||||
|
assert supportsYum().apply(new OperatingSystem(null, null, null, null, "Fedora", false));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testRedHatEnterpriseLinuxDescriptionSupportsYum() {
|
||||||
|
assert supportsYum().apply(new OperatingSystem(null, null, null, null, "Red Hat Enterprise Linux", false));
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,19 +19,17 @@
|
||||||
|
|
||||||
package org.jclouds.gogrid.compute.suppliers;
|
package org.jclouds.gogrid.compute.suppliers;
|
||||||
|
|
||||||
import static org.jclouds.compute.predicates.ImagePredicates.architectureIn;
|
import static org.jclouds.compute.predicates.ImagePredicates.any;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.Architecture;
|
|
||||||
import org.jclouds.compute.domain.Size;
|
import org.jclouds.compute.domain.Size;
|
||||||
import org.jclouds.compute.domain.internal.SizeImpl;
|
import org.jclouds.compute.domain.internal.SizeImpl;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,16 +43,11 @@ public class GoGridSizeSupplier implements Supplier<Set<? extends Size>> {
|
||||||
public Set<? extends Size> get() {
|
public Set<? extends Size> get() {
|
||||||
final Set<Size> sizes = Sets.newHashSet();
|
final Set<Size> sizes = Sets.newHashSet();
|
||||||
|
|
||||||
sizes.add(new SizeImpl("1", "1", "1", null, null, ImmutableMap.<String, String> of(), 0.5, 512, 30,
|
sizes.add(new SizeImpl("1", "1", "1", null, null, ImmutableMap.<String, String> of(), 0.5, 512, 30, any()));
|
||||||
architectureIn(ImmutableSet.<Architecture> of(Architecture.X86_32, Architecture.X86_64))));
|
sizes.add(new SizeImpl("2", "2", "2", null, null, ImmutableMap.<String, String> of(), 1, 1024, 60, any()));
|
||||||
sizes.add(new SizeImpl("2", "2", "2", null, null, ImmutableMap.<String, String> of(), 1, 1024, 60,
|
sizes.add(new SizeImpl("3", "3", "3", null, null, ImmutableMap.<String, String> of(), 2, 2048, 120, any()));
|
||||||
architectureIn(ImmutableSet.<Architecture> of(Architecture.X86_32, Architecture.X86_64))));
|
sizes.add(new SizeImpl("4", "4", "4", null, null, ImmutableMap.<String, String> of(), 4, 4096, 240, any()));
|
||||||
sizes.add(new SizeImpl("3", "3", "3", null, null, ImmutableMap.<String, String> of(), 2, 2048, 120,
|
sizes.add(new SizeImpl("5", "5", "5", null, null, ImmutableMap.<String, String> of(), 8, 8192, 480, any()));
|
||||||
architectureIn(ImmutableSet.<Architecture> of(Architecture.X86_32, Architecture.X86_64))));
|
|
||||||
sizes.add(new SizeImpl("4", "4", "4", null, null, ImmutableMap.<String, String> of(), 4, 4096, 240,
|
|
||||||
architectureIn(ImmutableSet.<Architecture> of(Architecture.X86_32, Architecture.X86_64))));
|
|
||||||
sizes.add(new SizeImpl("5", "5", "5", null, null, ImmutableMap.<String, String> of(), 8, 8192, 480,
|
|
||||||
architectureIn(ImmutableSet.<Architecture> of(Architecture.X86_32, Architecture.X86_64))));
|
|
||||||
return sizes;
|
return sizes;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue