Merge branch 'master' of https://github.com/jclouds/jclouds into ebs2_elastic-ip2

This commit is contained in:
Mattias Holmqvist 2011-06-03 09:29:41 +02:00
commit 02391ce2b5
393 changed files with 2883 additions and 801 deletions

1
.gitignore vendored
View File

@ -2,6 +2,7 @@
syntax: glob syntax: glob
target/ target/
test-output/ test-output/
bin/
.settings/ .settings/
.classpath .classpath
.project .project

View File

@ -33,7 +33,7 @@ our compute api supports: aws-ec2, gogrid, cloudservers-us, stub (in-memory), de
cloudservers-uk, vcloud (generic), ec2 (generic), byon, nova, cloudservers-uk, vcloud (generic), ec2 (generic), byon, nova,
trmk-ecloud, trmk-vcloudexpress, eucalyptus (generic), trmk-ecloud, trmk-vcloudexpress, eucalyptus (generic),
cloudsigma-zrh, elasticstack(generic), bluelock-vcloud-vcenterprise, cloudsigma-zrh, elasticstack(generic), bluelock-vcloud-vcenterprise,
bluelock-vcloud-zone01, stratogen-vcloud-mycloud, bluelock-vcloud-zone01, stratogen-vcloud-mycloud, rimuhosting,
slicehost, eucalyptus-partnercloud-ec2, elastichosts-lon-p (Peer 1), slicehost, eucalyptus-partnercloud-ec2, elastichosts-lon-p (Peer 1),
elastichosts-sat-p (Peer 1), elastichosts-lon-b (BlueSquare), elastichosts-sat-p (Peer 1), elastichosts-lon-b (BlueSquare),
openhosting-east1, serverlove-z1-man, skalicloud-sdg-my openhosting-east1, serverlove-z1-man, skalicloud-sdg-my
@ -42,9 +42,8 @@ our compute api supports: aws-ec2, gogrid, cloudservers-us, stub (in-memory), de
to all of these providers to all of these providers
our blobstore api supports: aws-s3, cloudfiles-us, cloudfiles-uk, filesystem, our blobstore api supports: aws-s3, cloudfiles-us, cloudfiles-uk, filesystem,
azureblob, atmos (generic), synaptic-storage, scaleup-storage, azureblob, atmos (generic), synaptic-storage,
cloudonestorage, walrus(generic), googlestorage, ninefold-storage, cloudonestorage, walrus(generic), ninefold-storage,
scality-rs2 (generic), hosteurope-storage, tiscali-storage,
eucalyptus-partnercloud-s3, swift (generic), transient (in-mem) eucalyptus-partnercloud-s3, swift (generic), transient (in-mem)
* note * the pom dependency org.jclouds/jclouds-allblobstore gives you access to * note * the pom dependency org.jclouds/jclouds-allblobstore gives you access to
@ -55,7 +54,8 @@ our loadbalancer api supports: cloudloadbalancers-us
* note * the pom dependency org.jclouds/jclouds-allloadbalancer gives you access to * note * the pom dependency org.jclouds/jclouds-allloadbalancer gives you access to
to all of these providers to all of these providers
we also have support for: ibmdev, mezeo, nirvanix, boxdotnet, rimuhosting, openstack nova, we also have support for: ibmdev, mezeo, nirvanix, boxdotnet, openstack nova, scality ring,
hosteurope-storage, tiscali-storage, scaleup-storage, googlestorage,
azurequeue, simpledb, cloudstack as well as a async-http-client azurequeue, simpledb, cloudstack as well as a async-http-client
driver in the sandbox driver in the sandbox

View File

@ -39,36 +39,11 @@
<artifactId>aws-s3</artifactId> <artifactId>aws-s3</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.jclouds.provider</groupId>
<artifactId>googlestorage</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jclouds.api</groupId>
<artifactId>scality-rs2</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.jclouds.provider</groupId> <groupId>org.jclouds.provider</groupId>
<artifactId>ninefold-storage</artifactId> <artifactId>ninefold-storage</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.jclouds.provider</groupId>
<artifactId>scaleup-storage</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jclouds.provider</groupId>
<artifactId>tiscali-storage</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jclouds.provider</groupId>
<artifactId>hosteurope-storage</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.jclouds.provider</groupId> <groupId>org.jclouds.provider</groupId>
<artifactId>synaptic-storage</artifactId> <artifactId>synaptic-storage</artifactId>

View File

@ -49,6 +49,11 @@
<artifactId>aws-ec2</artifactId> <artifactId>aws-ec2</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.jclouds.provider</groupId>
<artifactId>rimuhosting</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.jclouds.api</groupId> <groupId>org.jclouds.api</groupId>
<artifactId>nova</artifactId> <artifactId>nova</artifactId>

0
antcontrib/samples/javaoverssh/README.txt Executable file → Normal file
View File

0
apis/atmos/src/test/resources/log4j.xml Executable file → Normal file
View File

0
apis/byon/src/test/resources/log4j.xml Executable file → Normal file
View File

0
apis/cloudservers/src/test/resources/log4j.xml Executable file → Normal file
View File

View File

@ -209,13 +209,23 @@ public class EC2HardwareBuilder extends HardwareBuilder {
/** /**
* @see InstanceType#M1_SMALL * @see InstanceType#M1_SMALL
*/ */
public static EC2HardwareBuilder m1_small() { public static EC2HardwareBuilder m1_small32() {
return new EC2HardwareBuilder(InstanceType.M1_SMALL).ram(1740).processors( return new EC2HardwareBuilder(InstanceType.M1_SMALL).ram(1740).processors(
ImmutableList.of(new Processor(1.0, 1.0))).volumes( ImmutableList.of(new Processor(1.0, 1.0))).volumes(
ImmutableList.<Volume> of(new VolumeImpl(10.0f, "/dev/sda1", true, false), new VolumeImpl(150.0f, ImmutableList.<Volume> of(new VolumeImpl(10.0f, "/dev/sda1", true, false), new VolumeImpl(150.0f,
"/dev/sda2", false, false))).is64Bit(false); "/dev/sda2", false, false))).is64Bit(false);
} }
/**
* @see InstanceType#M1_SMALL
*/
public static EC2HardwareBuilder m1_small() {
return new EC2HardwareBuilder(InstanceType.M1_SMALL).ram(1740).processors(
ImmutableList.of(new Processor(1.0, 1.0))).volumes(
ImmutableList.<Volume> of(new VolumeImpl(10.0f, "/dev/sda1", true, false), new VolumeImpl(150.0f,
"/dev/sda2", false, false)));
}
/** /**
* @see InstanceType#T1_MICRO * @see InstanceType#T1_MICRO
*/ */

View File

@ -509,6 +509,6 @@ public class EC2TemplateOptions extends TemplateOptions implements Cloneable {
@Override @Override
public String toString() { public String toString() {
return "[groupIds=" + groupIds + ", keyPair=" + keyPair + ", noKeyPair=" + noKeyPair + ", userData=" return "[groupIds=" + groupIds + ", keyPair=" + keyPair + ", noKeyPair=" + noKeyPair + ", userData="
+ Arrays.toString(userData) + ", blockDeviceMappings=" + blockDeviceMappings + "]"; + Arrays.toString(userData) + ", blockDeviceMappings=" + blockDeviceMappings.build() + "]";
} }
} }

View File

@ -18,7 +18,6 @@
*/ */
package org.jclouds.ec2.compute.suppliers; package org.jclouds.ec2.compute.suppliers;
import static org.jclouds.compute.predicates.ImagePredicates.any;
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c1_medium; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c1_medium;
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c1_xlarge; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c1_xlarge;
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_large; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_large;
@ -43,7 +42,7 @@ public class EC2HardwareSupplier implements Supplier<Set<? extends Hardware>> {
@Override @Override
public Set<? extends Hardware> get() { public Set<? extends Hardware> get() {
return ImmutableSet.<Hardware> of(m1_small().supportsImage(any()).build(), c1_medium().build(), c1_xlarge() return ImmutableSet.<Hardware> of(m1_small().build(), c1_medium().build(), c1_xlarge()
.build(), m1_large().build(), m1_xlarge().build()); .build(), m1_large().build(), m1_xlarge().build());
} }
} }

View File

@ -26,7 +26,7 @@ import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c1_medium;
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c1_xlarge; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c1_xlarge;
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.cc1_4xlarge; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.cc1_4xlarge;
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_large; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_large;
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_small; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_small32;
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_xlarge; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_xlarge;
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m2_2xlarge; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m2_2xlarge;
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m2_4xlarge; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m2_4xlarge;
@ -161,7 +161,7 @@ public class EC2TemplateBuilderTest {
.build())); .build()));
Supplier<Set<? extends Hardware>> sizes = Suppliers.<Set<? extends Hardware>> ofInstance(ImmutableSet Supplier<Set<? extends Hardware>> sizes = Suppliers.<Set<? extends Hardware>> ofInstance(ImmutableSet
.<Hardware> of(t1_micro().build(), c1_medium().build(), c1_xlarge().build(), m1_large().build(), .<Hardware> of(t1_micro().build(), c1_medium().build(), c1_xlarge().build(), m1_large().build(),
m1_small().build(), m1_xlarge().build(), m2_xlarge().build(), m2_2xlarge().build(), m1_small32().build(), m1_xlarge().build(), m2_xlarge().build(), m2_2xlarge().build(),
m2_4xlarge().build(), CC1_4XLARGE)); m2_4xlarge().build(), CC1_4XLARGE));
return new TemplateBuilderImpl(locations, images, sizes, Suppliers.ofInstance(location), optionsProvider, return new TemplateBuilderImpl(locations, images, sizes, Suppliers.ofInstance(location), optionsProvider,

View File

@ -18,7 +18,7 @@
*/ */
package org.jclouds.ec2.compute.functions; package org.jclouds.ec2.compute.functions;
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_small; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_small32;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.net.UnknownHostException; import java.net.UnknownHostException;
@ -129,7 +129,7 @@ public class RunningInstanceToNodeMetadataTest {
@Test @Test
public void testApplyWhereTagDoesntMatchAndImageHardwareAndLocationFound() throws UnknownHostException { public void testApplyWhereTagDoesntMatchAndImageHardwareAndLocationFound() throws UnknownHostException {
RunningInstanceToNodeMetadata parser = createNodeParser(ImmutableSet.of(m1_small().build()), ImmutableSet RunningInstanceToNodeMetadata parser = createNodeParser(ImmutableSet.of(m1_small32().build()), ImmutableSet
.of(provider), EC2ImageParserTest.convertImages("/amzn_images.xml"), ImmutableMap .of(provider), EC2ImageParserTest.convertImages("/amzn_images.xml"), ImmutableMap
.<String, Credentials> of()); .<String, Credentials> of());
@ -137,7 +137,7 @@ public class RunningInstanceToNodeMetadataTest {
assertEquals(parser.apply(server), new NodeMetadataBuilder().state(NodeState.RUNNING).privateAddresses( assertEquals(parser.apply(server), new NodeMetadataBuilder().state(NodeState.RUNNING).privateAddresses(
ImmutableSet.of("10.243.42.70")).publicAddresses(ImmutableSet.of("174.129.81.68")).imageId( ImmutableSet.of("10.243.42.70")).publicAddresses(ImmutableSet.of("174.129.81.68")).imageId(
"us-east-1/ami-82e4b5c7").hardware(m1_small().build()).operatingSystem( "us-east-1/ami-82e4b5c7").hardware(m1_small32().build()).operatingSystem(
new OperatingSystem.Builder().family(OsFamily.UNRECOGNIZED).version("").arch("paravirtual").description( new OperatingSystem.Builder().family(OsFamily.UNRECOGNIZED).version("").arch("paravirtual").description(
"137112412989/amzn-ami-0.9.7-beta.i386-ebs").is64Bit(false).build()).id("us-east-1/i-0799056f") "137112412989/amzn-ami-0.9.7-beta.i386-ebs").is64Bit(false).build()).id("us-east-1/i-0799056f")
.providerId("i-0799056f").location(provider).build()); .providerId("i-0799056f").location(provider).build());
@ -158,7 +158,7 @@ public class RunningInstanceToNodeMetadataTest {
}; };
Map<RegionAndName, Image> instanceToImage = new MapMaker().makeComputingMap(nullReturningFunction); Map<RegionAndName, Image> instanceToImage = new MapMaker().makeComputingMap(nullReturningFunction);
RunningInstanceToNodeMetadata parser = createNodeParser(ImmutableSet.of(m1_small().build()), ImmutableSet RunningInstanceToNodeMetadata parser = createNodeParser(ImmutableSet.of(m1_small32().build()), ImmutableSet
.of(provider), ImmutableMap.<String, Credentials> of(), .of(provider), ImmutableMap.<String, Credentials> of(),
EC2ComputeServiceDependenciesModule.instanceToNodeState, instanceToImage); EC2ComputeServiceDependenciesModule.instanceToNodeState, instanceToImage);
@ -167,7 +167,7 @@ public class RunningInstanceToNodeMetadataTest {
assertEquals(parser.apply(server), new NodeMetadataBuilder().state(NodeState.RUNNING).privateAddresses( assertEquals(parser.apply(server), new NodeMetadataBuilder().state(NodeState.RUNNING).privateAddresses(
ImmutableSet.of("10.243.42.70")).publicAddresses(ImmutableSet.of("174.129.81.68")).imageId( ImmutableSet.of("10.243.42.70")).publicAddresses(ImmutableSet.of("174.129.81.68")).imageId(
"us-east-1/ami-82e4b5c7").id("us-east-1/i-0799056f").providerId("i-0799056f").hardware( "us-east-1/ami-82e4b5c7").id("us-east-1/i-0799056f").providerId("i-0799056f").hardware(
m1_small().build()).location(provider).build()); m1_small32().build()).location(provider).build());
} }
protected RunningInstance firstInstanceFromResource(String resource) { protected RunningInstance firstInstanceFromResource(String resource) {

View File

@ -69,7 +69,7 @@ public class CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest {
// setup constants // setup constants
String region = Region.AP_SOUTHEAST_1; String region = Region.AP_SOUTHEAST_1;
String tag = "tag"; String tag = "tag";
Hardware size = EC2HardwareBuilder.m1_small().build(); Hardware size = EC2HardwareBuilder.m1_small32().build();
String systemGeneratedKeyPairName = "systemGeneratedKeyPair"; String systemGeneratedKeyPairName = "systemGeneratedKeyPair";
String generatedGroup = "group"; String generatedGroup = "group";
Set<String> generatedGroups = ImmutableSet.of(generatedGroup); Set<String> generatedGroups = ImmutableSet.of(generatedGroup);
@ -124,7 +124,7 @@ public class CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest {
// setup constants // setup constants
String region = Region.AP_SOUTHEAST_1; String region = Region.AP_SOUTHEAST_1;
String tag = "tag"; String tag = "tag";
Hardware size = EC2HardwareBuilder.m1_small().build(); Hardware size = EC2HardwareBuilder.m1_small32().build();
String systemGeneratedKeyPairName = "systemGeneratedKeyPair"; String systemGeneratedKeyPairName = "systemGeneratedKeyPair";
String generatedGroup = "group"; String generatedGroup = "group";
Set<String> generatedGroups = ImmutableSet.of(generatedGroup); Set<String> generatedGroups = ImmutableSet.of(generatedGroup);

View File

@ -159,8 +159,8 @@ public class ElasticStackClientLiveTest {
@Test @Test
public void testGetDrive() throws Exception { public void testGetDrive() throws Exception {
for (String driveUUID : client.listDrives()) { for (String driveUUID : client.listDrives()) {
assert !"".equals(driveUUID); assert !"".equals(driveUUID) : driveUUID;
assertNotNull(client.getDriveInfo(driveUUID)); assert client.getDriveInfo(driveUUID) != null : driveUUID;
} }
} }

View File

@ -0,0 +1,75 @@
/**
*
* Copyright (C) 2011 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.openstack.nova.functions;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.TypeLiteral;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
import org.jclouds.io.Payloads;
import org.jclouds.json.config.GsonModule;
import org.jclouds.openstack.nova.domain.Server;
import org.jclouds.openstack.nova.domain.ServerStatus;
import org.testng.annotations.Test;
import java.io.InputStream;
import java.net.UnknownHostException;
import java.text.ParseException;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
@Test(groups = "unit")
public class ParseServerFromJsonNoAddressesResponseTest {
@Test
public void testApplyInputStreamDetails() throws UnknownHostException, NoSuchMethodException, ClassNotFoundException, ParseException {
Server response = parseServer();
assertEquals(response.getId(), 847);
assertEquals(response.getName(), "cmsNode-fa2");
assertEquals(response.getImageRef(), "http://dragon004.hw.griddynamics.net:8774/v1.1/images/106");
assertEquals(response.getFlavorRef(), "http://dragon004.hw.griddynamics.net:8774/v1.1/flavors/2");
assertEquals(response.getStatus(), ServerStatus.BUILD);
assertTrue(response.getAddresses().getPublicAddresses().isEmpty());
assertTrue(response.getAddresses().getPrivateAddresses().isEmpty());
}
public static Server parseServer() throws NoSuchMethodException, ClassNotFoundException {
Injector i = Guice.createInjector(new GsonModule() {
@Override
protected void configure() {
super.configure();
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
}
});
InputStream is = ParseServerFromJsonNoAddressesResponseTest.class.getResourceAsStream("/test_get_server_detail_no_addresses.json");
UnwrapOnlyJsonValue<Server> parser = i.getInstance(Key.get(new TypeLiteral<UnwrapOnlyJsonValue<Server>>() {
}));
return parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
}
}

View File

@ -1,23 +1,23 @@
/** /**
* *
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com> * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
* *
* ==================================================================== * ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.openstack.nova.functions; package org.jclouds.openstack.nova.functions;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
@ -45,63 +45,63 @@ import java.util.Locale;
import java.util.SimpleTimeZone; import java.util.SimpleTimeZone;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
/** /**
* Tests behavior of {@code ParseServerFromJsonResponse} * Tests behavior of {@code ParseServerFromJsonResponse}
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "unit") @Test(groups = "unit")
public class ParseServerFromJsonResponseTest { public class ParseServerFromJsonResponseTest {
@Test @Test
public void testApplyInputStreamDetails() throws UnknownHostException, NoSuchMethodException, ClassNotFoundException, ParseException { public void testApplyInputStreamDetails() throws UnknownHostException, NoSuchMethodException, ClassNotFoundException, ParseException {
Server response = parseServer(); Server response = parseServer();
assertEquals(response.getId(), 1234); assertEquals(response.getId(), 1234);
assertEquals(response.getName(), "sample-server"); assertEquals(response.getName(), "sample-server");
assertEquals(response.getImageRef(), "https://servers.api.rackspacecloud.com/v1.1/1234/images/1"); assertEquals(response.getImageRef(), "https://servers.api.rackspacecloud.com/v1.1/1234/images/1");
assertEquals(response.getFlavorRef(), "http://servers.api.openstack.org/1234/flavors/1"); assertEquals(response.getFlavorRef(), "http://servers.api.openstack.org/1234/flavors/1");
assertEquals(response.getHostId(), "e4d909c290d0fb1ca068ffaddf22cbd0"); assertEquals(response.getHostId(), "e4d909c290d0fb1ca068ffaddf22cbd0");
assertEquals(response.getStatus(), ServerStatus.BUILD); assertEquals(response.getStatus(), ServerStatus.BUILD);
assertEquals(response.getProgress(), new Integer(60)); assertEquals(response.getProgress(), new Integer(60));
SimpleDateFormat dateFormat = new SimpleDateFormat( SimpleDateFormat dateFormat = new SimpleDateFormat(
"yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US); "yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
dateFormat.setTimeZone(new SimpleTimeZone(0, "GMT")); dateFormat.setTimeZone(new SimpleTimeZone(0, "GMT"));
assertEquals(response.getCreated(), assertEquals(response.getCreated(),
dateFormat.parse("2010-08-10T12:00:00Z")); dateFormat.parse("2010-08-10T12:00:00Z"));
assertEquals(response.getUpdated(), assertEquals(response.getUpdated(),
dateFormat.parse("2010-10-10T12:00:00Z")); dateFormat.parse("2010-10-10T12:00:00Z"));
List<Address> publicAddresses = ImmutableList.copyOf(Iterables.transform( List<Address> publicAddresses = ImmutableList.copyOf(Iterables.transform(
ImmutableList.of("67.23.10.132", "::babe:67.23.10.132", "67.23.10.131", "::babe:4317:0A83"), ImmutableList.of("67.23.10.132", "::babe:67.23.10.132", "67.23.10.131", "::babe:4317:0A83"),
Address.newString2AddressFunction())); Address.newString2AddressFunction()));
List<Address> privateAddresses = ImmutableList.copyOf(Iterables.transform( List<Address> privateAddresses = ImmutableList.copyOf(Iterables.transform(
ImmutableList.of("10.176.42.16", "::babe:10.176.42.16"), ImmutableList.of("10.176.42.16", "::babe:10.176.42.16"),
Address.newString2AddressFunction())); Address.newString2AddressFunction()));
Addresses addresses1 = new Addresses(new HashSet<Address>(publicAddresses), new HashSet<Address>(privateAddresses)); Addresses addresses1 = new Addresses(new HashSet<Address>(publicAddresses), new HashSet<Address>(privateAddresses));
assertEquals(response.getAddresses(), addresses1); assertEquals(response.getAddresses(), addresses1);
assertEquals(response.getMetadata(), ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")); assertEquals(response.getMetadata(), ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1"));
assertEquals(response.getAddresses(), addresses1); assertEquals(response.getAddresses(), addresses1);
} }
public static Server parseServer() throws NoSuchMethodException, ClassNotFoundException { public static Server parseServer() throws NoSuchMethodException, ClassNotFoundException {
Injector i = Guice.createInjector(new GsonModule() { Injector i = Guice.createInjector(new GsonModule() {
@Override @Override
protected void configure() { protected void configure() {
super.configure(); super.configure();
bind(DateAdapter.class).to(Iso8601DateAdapter.class); bind(DateAdapter.class).to(Iso8601DateAdapter.class);
} }
}); });
InputStream is = ParseServerFromJsonResponseTest.class.getResourceAsStream("/test_get_server_detail.json"); InputStream is = ParseServerFromJsonResponseTest.class.getResourceAsStream("/test_get_server_detail.json");
UnwrapOnlyJsonValue<Server> parser = i.getInstance(Key.get(new TypeLiteral<UnwrapOnlyJsonValue<Server>>() { UnwrapOnlyJsonValue<Server> parser = i.getInstance(Key.get(new TypeLiteral<UnwrapOnlyJsonValue<Server>>() {
})); }));
return (Server) parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))); return parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
} }
} }

View File

@ -18,18 +18,18 @@
*/ */
package org.jclouds.openstack.nova.live; package org.jclouds.openstack.nova.live;
import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableMap;
import com.google.common.io.Files;
import org.jclouds.Constants;
import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import org.jclouds.Constants;
import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableMap;
import com.google.common.io.Resources;
/** /**
* @author Victor Galkin * @author Victor Galkin
*/ */
@ -44,8 +44,8 @@ public class PropertyHelper {
public static Map<String, String> setupKeyPair(Properties properties) throws FileNotFoundException, IOException { public static Map<String, String> setupKeyPair(Properties properties) throws FileNotFoundException, IOException {
return ImmutableMap.<String, String>of( return ImmutableMap.<String, String>of(
"private", Files.toString(new File(properties.getProperty("test.ssh.keyfile.private")), Charsets.UTF_8), "private", Resources.toString(Resources.getResource(properties.getProperty("test.ssh.keyfile.private")), Charsets.UTF_8),
"public", Files.toString(new File(properties.getProperty("test.ssh.keyfile.public")), Charsets.UTF_8)); "public", Resources.toString(Resources.getResource(properties.getProperty("test.ssh.keyfile.public")), Charsets.UTF_8));
} }
public static Properties setupProperties(Class<?> clazz) throws IOException { public static Properties setupProperties(Class<?> clazz) throws IOException {

View File

@ -129,7 +129,7 @@ public class NovaComputeServiceLiveTest extends ComputeBase {
.family(OsFamily.UBUNTU).description("ffoo").build())); .family(OsFamily.UBUNTU).description("ffoo").build()));
} }
@Test(expectedExceptions = JSchException.class, expectedExceptionsMessageRegExp = "Auth fail", timeOut = 60000) @Test(expectedExceptions = JSchException.class, expectedExceptionsMessageRegExp = "Auth fail", timeOut = 120000)
void testScriptExecutionWithWrongCredentials() throws Throwable, RunScriptOnNodesException, URISyntaxException, InterruptedException { void testScriptExecutionWithWrongCredentials() throws Throwable, RunScriptOnNodesException, URISyntaxException, InterruptedException {
NodeMetadata node = getDefaultNodeImmediately(group); NodeMetadata node = getDefaultNodeImmediately(group);
String address = awaitForPublicAddressAssigned(node.getId()); String address = awaitForPublicAddressAssigned(node.getId());
@ -144,7 +144,7 @@ public class NovaComputeServiceLiveTest extends ComputeBase {
} }
} }
@Test(timeOut = 60000) @Test(timeOut = 120000)
public void testScriptExecutionAfterBootWithBasicTemplate() throws InterruptedException, RunNodesException, RunScriptOnNodesException, URISyntaxException, IOException { public void testScriptExecutionAfterBootWithBasicTemplate() throws InterruptedException, RunNodesException, RunScriptOnNodesException, URISyntaxException, IOException {
NodeMetadata node = getDefaultNodeImmediately(group); NodeMetadata node = getDefaultNodeImmediately(group);
@ -159,7 +159,8 @@ public class NovaComputeServiceLiveTest extends ComputeBase {
//TODO runJavaInstallationScriptWithCreds(group, os, new Credentials("root", keyPair.get("private"))); //TODO runJavaInstallationScriptWithCreds(group, os, new Credentials("root", keyPair.get("private")));
//TODO no response? if os is null (ZYPPER) //TODO no response? if os is null (ZYPPER)
checkNodes(Sets.<NodeMetadata>newHashSet(node), group); node = computeService.getNodeMetadata(node.getId());
checkNodes(Sets.newHashSet(node), group);
@SuppressWarnings("unused") @SuppressWarnings("unused")
Credentials good = node.getCredentials(); Credentials good = node.getCredentials();
@ -242,7 +243,7 @@ public class NovaComputeServiceLiveTest extends ComputeBase {
return templateBuilder.build(); return templateBuilder.build();
} }
@Test(timeOut = 60000) @Test(timeOut = 120000)
public void testGetNodeMetadata() throws Exception { public void testGetNodeMetadata() throws Exception {
Set<NodeMetadata> nodes = Sets.newHashSet(getDefaultNodeImmediately(group)); Set<NodeMetadata> nodes = Sets.newHashSet(getDefaultNodeImmediately(group));
awaitForPublicAddressAssigned(nodes.iterator().next().getId()); awaitForPublicAddressAssigned(nodes.iterator().next().getId());
@ -391,8 +392,9 @@ public class NovaComputeServiceLiveTest extends ComputeBase {
assertEquals(provider.getParent(), null); assertEquals(provider.getParent(), null);
} }
@Test(timeOut = 60000) @Test(timeOut = 60000, enabled = false)
public void testListHardwareProfiles() throws Exception { public void testListHardwareProfiles() throws Exception {
//TODO: failing, OpenStack returns a hardware with 0 CPU cores
for (Hardware hardware : computeService.listHardwareProfiles()) { for (Hardware hardware : computeService.listHardwareProfiles()) {
assert hardware.getProviderId() != null; assert hardware.getProviderId() != null;
assert getCores(hardware) > 0; assert getCores(hardware) > 0;

View File

@ -56,8 +56,9 @@ public class ServiceActionsLiveTest extends ComputeBase {
//testGetNodeMetadata(); //testGetNodeMetadata();
} }
@Test @Test(enabled = false)
public void testSuspendResume() throws Exception { public void testSuspendResume() throws Exception {
//TODO: failing, suspend is not supported by the nova provider yet
getDefaultNodeImmediately(group); getDefaultNodeImmediately(group);
computeService.suspendNodesMatching(inGroup(group)); computeService.suspendNodesMatching(inGroup(group));

View File

@ -23,6 +23,8 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.inject.Injector; import com.google.inject.Injector;
import com.google.inject.Module; import com.google.inject.Module;
import org.jclouds.domain.Credentials;
import org.jclouds.http.handlers.BackoffLimitedRetryHandler;
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule; import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
import org.jclouds.net.IPSocket; import org.jclouds.net.IPSocket;
import org.jclouds.openstack.nova.NovaClient; import org.jclouds.openstack.nova.NovaClient;
@ -32,12 +34,16 @@ import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.predicates.SocketOpen; import org.jclouds.predicates.SocketOpen;
import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory;
import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshClient;
import org.jclouds.ssh.SshException;
import org.jclouds.ssh.jsch.JschSshClient;
import org.jclouds.ssh.jsch.config.JschSshClientModule; import org.jclouds.ssh.jsch.config.JschSshClientModule;
import org.testng.annotations.BeforeTest; import org.testng.annotations.BeforeTest;
import java.io.IOException; import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import static org.jclouds.openstack.nova.live.PropertyHelper.*; import static org.jclouds.openstack.nova.live.PropertyHelper.*;
@ -84,7 +90,7 @@ public class ClientBase {
return createDefaultServer(defaultName); return createDefaultServer(defaultName);
} }
private Server createDefaultServer(String serverName) { protected Server createDefaultServer(String serverName) {
String imageRef = client.getImage(testImageId).getURI().toASCIIString(); String imageRef = client.getImage(testImageId).getURI().toASCIIString();
String flavorRef = client.getFlavor(1).getURI().toASCIIString(); String flavorRef = client.getFlavor(1).getURI().toASCIIString();

View File

@ -1,382 +1,388 @@
/** /**
* *
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com> * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
* *
* ==================================================================== * ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.openstack.nova.live.novaclient; package org.jclouds.openstack.nova.live.novaclient;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import org.jclouds.domain.Credentials; import org.jclouds.domain.Credentials;
import org.jclouds.http.HttpResponseException; import org.jclouds.http.HttpResponseException;
import org.jclouds.io.Payload; import org.jclouds.io.Payload;
import org.jclouds.net.IPSocket; import org.jclouds.net.IPSocket;
import org.jclouds.openstack.nova.domain.*; import org.jclouds.openstack.nova.domain.*;
import org.jclouds.openstack.nova.options.RebuildServerOptions; import org.jclouds.openstack.nova.options.RebuildServerOptions;
import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshClient;
import org.jclouds.util.Strings2; import org.jclouds.util.Strings2;
import org.testng.annotations.AfterTest; import org.testng.annotations.AfterTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import java.io.IOException; import java.io.IOException;
import java.util.Set; import java.util.Set;
import static org.jclouds.openstack.nova.options.ListOptions.Builder.withDetails; import static org.jclouds.openstack.nova.options.ListOptions.Builder.withDetails;
import static org.testng.Assert.*; import static org.testng.Assert.*;
/** /**
* Tests behavior of {@code NovaClient} * Tests behavior of {@code NovaClient}
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
// disabled [Web Hosting #129069 // disabled [Web Hosting #129069
@Test(groups = "live", sequential = true) @Test(groups = "live", sequential = true)
public class NovaClientLiveTest extends ClientBase { public class NovaClientLiveTest extends ClientBase {
@Test @Test
public void testListServers() throws Exception { public void testListServers() throws Exception {
Set<Server> response = client.listServers(); Set<Server> response = client.listServers();
assert null != response; assert null != response;
long initialContainerCount = response.size(); long initialContainerCount = response.size();
assertTrue(initialContainerCount >= 0); assertTrue(initialContainerCount >= 0);
} }
@Test @Test
public void testListServersDetail() throws Exception { public void testListServersDetail() throws Exception {
Set<Server> response = client.listServers(withDetails()); Set<Server> response = client.listServers(withDetails());
assert null != response; assert null != response;
long initialContainerCount = response.size(); long initialContainerCount = response.size();
assertTrue(initialContainerCount >= 0); assertTrue(initialContainerCount >= 0);
} }
@Test @Test(enabled = false)
public void testListImages() throws Exception { public void testListImages() throws Exception {
Set<Image> response = client.listImages(); //TODO: failing, image name should not be null (issue in the OpenStack)
assert null != response; Set<Image> response = client.listImages();
long imageCount = response.size(); assert null != response;
assertTrue(imageCount >= 1); long imageCount = response.size();
for (Image image : response) { assertTrue(imageCount >= 1);
assertTrue(image.getId() >= 0); for (Image image : response) {
assert null != image.getName() : image; assertTrue(image.getId() >= 0);
} assert null != image.getName() : image;
}
}
}
@Test
public void testListImagesDetail() throws Exception { @Test(enabled = false)
Set<Image> response = client.listImages(withDetails()); public void testListImagesDetail() throws Exception {
assert null != response; //TODO: failing, image name should not be null (issue in the OpenStack)
long imageCount = response.size(); Set<Image> response = client.listImages(withDetails());
assertTrue(imageCount >= 0); assert null != response;
for (Image image : response) { long imageCount = response.size();
assertTrue(image.getId() >= 1); assertTrue(imageCount >= 0);
assert null != image.getName() : image; for (Image image : response) {
assert null != image.getStatus() : image; assertTrue(image.getId() >= 1);
} assert null != image.getName() : image;
} assert null != image.getStatus() : image;
}
@Test }
public void testGetImagesDetail() throws Exception {
Set<Image> response = client.listImages(withDetails()); @Test
assert null != response; public void testGetImagesDetail() throws Exception {
long imageCount = response.size(); Set<Image> response = client.listImages(withDetails());
assertTrue(imageCount >= 0); assert null != response;
for (Image image : response) { long imageCount = response.size();
try { assertTrue(imageCount >= 0);
Image newDetails = client.getImage(image.getId()); for (Image image : response) {
assertEquals(image, newDetails); try {
} catch (HttpResponseException e) {// Ticket #9867 Image newDetails = client.getImage(image.getId());
if (e.getResponse().getStatusCode() != 400) assertEquals(image, newDetails);
throw e; } catch (HttpResponseException e) {// Ticket #9867
} if (e.getResponse().getStatusCode() != 400)
} throw e;
} }
}
@Test }
public void testGetImageDetailsNotFound() throws Exception {
assert client.getImage(12312987) == null; @Test
} public void testGetImageDetailsNotFound() throws Exception {
assert client.getImage(12312987) == null;
@Test }
public void testGetServerDetailsNotFound() throws Exception {
assert client.getServer(12312987) == null; @Test
} public void testGetServerDetailsNotFound() throws Exception {
assert client.getServer(12312987) == null;
@Test }
public void testGetServersDetail() throws Exception {
Set<Server> response = client.listServers(withDetails()); @Test
assert null != response; public void testGetServersDetail() throws Exception {
assertTrue(response.size() >= 0); Set<Server> response = client.listServers(withDetails());
for (Server server : response) { assert null != response;
Server newDetails = client.getServer(server.getId()); assertTrue(response.size() >= 0);
System.out.println("===="); for (Server server : response) {
Server newDetails = client.getServer(server.getId());
System.out.println(server); System.out.println("====");
System.out.println(newDetails);
System.out.println("===="); System.out.println(server);
} System.out.println(newDetails);
for (Server server : response) { System.out.println("====");
Server newDetails = client.getServer(server.getId()); }
assertEquals(server, newDetails); for (Server server : response) {
} Server newDetails = client.getServer(server.getId());
} assertEquals(server, newDetails);
}
@Test }
public void testListFlavors() throws Exception {
Set<Flavor> response = client.listFlavors(); @Test
assert null != response; public void testListFlavors() throws Exception {
long flavorCount = response.size(); Set<Flavor> response = client.listFlavors();
assertTrue(flavorCount >= 1); assert null != response;
for (Flavor flavor : response) { long flavorCount = response.size();
assertTrue(flavor.getId() >= 0); assertTrue(flavorCount >= 1);
assert null != flavor.getName() : flavor; for (Flavor flavor : response) {
} assertTrue(flavor.getId() >= 0);
assert null != flavor.getName() : flavor;
} }
@Test }
public void testListFlavorsDetail() throws Exception {
Set<Flavor> response = client.listFlavors(withDetails()); @Test
assert null != response; public void testListFlavorsDetail() throws Exception {
long flavorCount = response.size(); Set<Flavor> response = client.listFlavors(withDetails());
assertTrue(flavorCount >= 0); assert null != response;
for (Flavor flavor : response) { long flavorCount = response.size();
assertTrue(flavor.getId() >= 1); assertTrue(flavorCount >= 0);
assert null != flavor.getName() : flavor; for (Flavor flavor : response) {
assert null != flavor.getDisk() : flavor; assertTrue(flavor.getId() >= 1);
assert null != flavor.getRam() : flavor; assert null != flavor.getName() : flavor;
} assert null != flavor.getDisk() : flavor;
} assert null != flavor.getRam() : flavor;
}
@Test }
public void testGetFlavorsDetail() throws Exception {
Set<Flavor> response = client.listFlavors(withDetails()); @Test
assert null != response; public void testGetFlavorsDetail() throws Exception {
long flavorCount = response.size(); Set<Flavor> response = client.listFlavors(withDetails());
assertTrue(flavorCount >= 0); assert null != response;
for (Flavor flavor : response) { long flavorCount = response.size();
Flavor newDetails = client.getFlavor(flavor.getId()); assertTrue(flavorCount >= 0);
assertEquals(flavor, newDetails); for (Flavor flavor : response) {
} Flavor newDetails = client.getFlavor(flavor.getId());
} assertEquals(flavor, newDetails);
}
@Test }
public void testGetFlavorDetailsNotFound() throws Exception {
assert client.getFlavor(12312987) == null; @Test
} public void testGetFlavorDetailsNotFound() throws Exception {
assert client.getFlavor(12312987) == null;
}
@Test(enabled = true)
public void testCreateServer() throws Exception {
Server server = getDefaultServerImmediately(); @Test(enabled = true)
assertNotNull(server.getAdminPass()); public void testCreateServer() throws Exception {
assertEquals(server.getStatus(), ServerStatus.BUILD); Server server = createDefaultServer(serverPrefix + "for_create");
int serverId = server.getId(); assertNotNull(server.getAdminPass());
@SuppressWarnings("unused") int serverId = server.getId();
String adminPass = server.getAdminPass(); @SuppressWarnings("unused")
blockUntilServerActive(serverId); String adminPass = server.getAdminPass();
blockUntilPublicAddress(serverId); blockUntilServerActive(serverId);
client.getServer(serverId).getAddresses().getPublicAddresses().iterator().next().getAddress(); blockUntilPublicAddress(serverId);
} client.getServer(serverId).getAddresses().getPublicAddresses().iterator().next().getAddress();
}
private void blockUntilPublicAddress(int serverId) throws InterruptedException {
while (client.getServer(serverId).getAddresses().getPublicAddresses().isEmpty()) { private void blockUntilPublicAddress(int serverId) throws InterruptedException {
System.out.println("Awaiting public address"); while (client.getServer(serverId).getAddresses().getPublicAddresses().isEmpty()) {
Thread.sleep(1000); System.out.println("Awaiting public address");
} Thread.sleep(1000);
} }
}
private void blockUntilServerActive(int serverId) throws InterruptedException {
Server currentDetails; private void blockUntilServerActive(int serverId) throws InterruptedException {
for (currentDetails = client.getServer(serverId); currentDetails.getStatus() != ServerStatus.ACTIVE; currentDetails = client Server currentDetails;
.getServer(serverId)) { for (currentDetails = client.getServer(serverId); currentDetails.getStatus() != ServerStatus.ACTIVE; currentDetails = client
System.out.printf("blocking on status active%n%s%n", currentDetails); .getServer(serverId)) {
Thread.sleep(5 * 1000); System.out.printf("blocking on status active%n%s%n", currentDetails);
} Thread.sleep(5 * 1000);
} }
}
private void blockUntilServerVerifyResize(int serverId) throws InterruptedException {
Server currentDetails; private void blockUntilServerVerifyResize(int serverId) throws InterruptedException {
for (currentDetails = client.getServer(serverId); currentDetails.getStatus() != ServerStatus.VERIFY_RESIZE; currentDetails = client Server currentDetails;
.getServer(serverId)) { for (currentDetails = client.getServer(serverId); currentDetails.getStatus() != ServerStatus.VERIFY_RESIZE; currentDetails = client
System.out.printf("blocking on status verify resize%n%s%n", currentDetails); .getServer(serverId)) {
Thread.sleep(5 * 1000); System.out.printf("blocking on status verify resize%n%s%n", currentDetails);
} Thread.sleep(5 * 1000);
} }
}
private void blockUntilImageActive(int createdImageId) throws InterruptedException {
Image currentDetails; private void blockUntilImageActive(int createdImageId) throws InterruptedException {
for (currentDetails = client.getImage(createdImageId); currentDetails.getStatus() != ImageStatus.ACTIVE; currentDetails = client Image currentDetails;
.getImage(createdImageId)) { for (currentDetails = client.getImage(createdImageId); currentDetails.getStatus() != ImageStatus.ACTIVE; currentDetails = client
System.out.printf("blocking on status active%n%s%n", currentDetails); .getImage(createdImageId)) {
Thread.sleep(5 * 1000); System.out.printf("blocking on status active%n%s%n", currentDetails);
} Thread.sleep(5 * 1000);
} }
}
@Test(enabled = true, timeOut = 300000)
public void testServerDetails() throws Exception { @Test(enabled = false, timeOut = 300000)
Server server = getDefaultServerImmediately(); public void testServerDetails() throws Exception {
assertNotNull(server.getHostId(), "Host id: "); //TODO: failing, /v1.1/servers/{server id}/ips URL is not available (issue in the OpenStack)
assertEquals(server.getStatus(), ServerStatus.ACTIVE); Server server = getDefaultServerImmediately();
assertNotNull(server.getAddresses()); assertNotNull(server.getHostId(), "Host id: ");
// check metadata assertNotNull(server.getAddresses());
assertEquals(server.getMetadata(), metadata); // check metadata
assertTrue(server.getImageRef().endsWith(String.valueOf(testImageId))); assertEquals(server.getMetadata(), metadata);
// listAddresses tests.. assertTrue(server.getImageRef().endsWith(String.valueOf(testImageId)));
assertEquals(client.getAddresses(server.getId()), server.getAddresses()); // listAddresses tests..
assertEquals(server.getAddresses().getPublicAddresses().size(), 1); assertEquals(client.getAddresses(server.getId()), server.getAddresses());
assertEquals(client.listPublicAddresses(server.getId()), server.getAddresses().getPublicAddresses()); assertEquals(server.getAddresses().getPublicAddresses().size(), 1);
assertEquals(server.getAddresses().getPrivateAddresses().size(), 1); assertEquals(client.listPublicAddresses(server.getId()), server.getAddresses().getPublicAddresses());
assertEquals(client.listPrivateAddresses(server.getId()), server.getAddresses().getPrivateAddresses()); assertEquals(server.getAddresses().getPrivateAddresses().size(), 1);
assertPassword(server, server.getAdminPass()); assertEquals(client.listPrivateAddresses(server.getId()), server.getAddresses().getPrivateAddresses());
assertTrue(server.getFlavorRef().endsWith("1")); assertPassword(server, server.getAdminPass());
assert server.getProgress() >= 0 : "newDetails.getProgress()" + server.getProgress(); assertTrue(server.getFlavorRef().endsWith("1"));
} assert server.getProgress() >= 0 : "newDetails.getProgress()" + server.getProgress();
}
private void assertPassword(Server server, String pass) throws IOException { private void assertPassword(Server server, String pass) throws IOException {
IPSocket socket = new IPSocket(Iterables.get(server.getAddresses().getPublicAddresses(), 0).getAddress(), 22); IPSocket socket = new IPSocket(Iterables.get(server.getAddresses().getPublicAddresses(), 0).getAddress(), 22);
//socketTester.apply(socket); //socketTester.apply(socket);
SshClient client = sshFactory.create(socket, new Credentials("root", keyPair.get("private"))); SshClient client = sshFactory.create(socket, new Credentials("root", keyPair.get("private")));
try { try {
client.connect(); client.connect();
Payload etcPasswd = client.get("/etc/jclouds.txt"); Payload etcPasswd = client.get("/etc/jclouds.txt");
String etcPasswdContents = Strings2.toStringAndClose(etcPasswd.getInput()); String etcPasswdContents = Strings2.toStringAndClose(etcPasswd.getInput());
assertEquals("rackspace", etcPasswdContents.trim()); assertEquals("rackspace", etcPasswdContents.trim());
} finally { } finally {
if (client != null) if (client != null)
client.disconnect(); client.disconnect();
} }
} }
@Test(enabled = true, timeOut = 5 * 60 * 1000) @Test(enabled = true, timeOut = 5 * 60 * 1000)
public void testRenameServer() throws Exception { public void testRenameServer() throws Exception {
Server server = getDefaultServerImmediately(); Server server = getDefaultServerImmediately();
int serverId = server.getId(); int serverId = server.getId();
String oldName = server.getName(); String oldName = server.getName();
client.renameServer(serverId, oldName + "new"); client.renameServer(serverId, oldName + "new");
blockUntilServerActive(serverId); blockUntilServerActive(serverId);
assertEquals(oldName + "new", client.getServer(serverId).getName()); assertEquals(oldName + "new", client.getServer(serverId).getName());
} }
@Test(enabled = true, timeOut = 5 * 60 * 1000) @Test(enabled = false, timeOut = 5 * 60 * 1000)
public void testChangePassword() throws Exception { public void testChangePassword() throws Exception {
int serverId = getDefaultServerImmediately().getId(); //TODO: failing, fix acceptPassword method logic, however password is not changed by OpenStack
blockUntilServerActive(serverId); int serverId = getDefaultServerImmediately().getId();
client.changeAdminPass(serverId, "elmo"); blockUntilServerActive(serverId);
assertPassword(client.getServer(serverId), "elmo"); blockUntilPublicAddress(serverId);
client.changeAdminPass(serverId, "elmo");
} //TODO: wait until SSH is available
assertPassword(client.getServer(serverId), "elmo");
@Test(enabled = true, timeOut = 10 * 600 * 1000)
public void testCreateImage() throws Exception { }
Server server = getDefaultServerImmediately();
Image image = getDefaultImageImmediately(server); @Test(enabled = false, timeOut = 10 * 600 * 1000)
blockUntilImageActive(image.getId()); public void testCreateImage() throws Exception {
assertEquals("hoofie", image.getName()); //TODO: failing, create image from instance returns incorrect JSON
assertEquals(image.getServerRef(), ""); Server server = getDefaultServerImmediately();
} Image image = getDefaultImageImmediately(server);
blockUntilImageActive(image.getId());
assertEquals("hoofie", image.getName());
@Test(enabled = true, timeOut = 10 * 60 * 1000) assertEquals(image.getServerRef(), "");
public void testRebuildServer() throws Exception { }
Server server = getDefaultServerImmediately();
Image image = getDefaultImageImmediately(server);
client.rebuildServer(server.getId(), new RebuildServerOptions().withImage(String.valueOf(image.getId()))); @Test(enabled = false, timeOut = 10 * 60 * 1000)
blockUntilServerActive(server.getId()); public void testRebuildServer() throws Exception {
// issue Web Hosting #119580 createdImageId comes back incorrect after rebuild //TODO: failing, create image from instance returns incorrect JSON
assertEquals(image.getURI(), client.getServer(server.getId()).getImageRef()); Server server = getDefaultServerImmediately();
} Image image = getDefaultImageImmediately(server);
client.rebuildServer(server.getId(), new RebuildServerOptions().withImage(String.valueOf(image.getId())));
@Test(enabled = true, timeOut = 10 * 60 * 1000) blockUntilServerActive(server.getId());
public void testRebootHard() throws Exception { // issue Web Hosting #119580 createdImageId comes back incorrect after rebuild
Server server = getDefaultServerImmediately(); assertEquals(image.getURI(), client.getServer(server.getId()).getImageRef());
client.rebootServer(server.getId(), RebootType.HARD); }
blockUntilServerActive(server.getId());
//TODO check @Test(enabled = true, timeOut = 10 * 60 * 1000)
} public void testRebootHard() throws Exception {
Server server = getDefaultServerImmediately();
@Test(enabled = true, timeOut = 10 * 60 * 1000) client.rebootServer(server.getId(), RebootType.HARD);
public void testRebootSoft() throws Exception { blockUntilServerActive(server.getId());
Server server = getDefaultServerImmediately(); //TODO check
client.rebootServer(server.getId(), RebootType.SOFT); }
blockUntilServerActive(server.getId());
//TODO check @Test(enabled = true, timeOut = 10 * 60 * 1000)
} public void testRebootSoft() throws Exception {
Server server = getDefaultServerImmediately();
@Test(enabled = false, timeOut = 60000, dependsOnMethods = "testRebootSoft") client.rebootServer(server.getId(), RebootType.SOFT);
public void testRevertResize() throws Exception { blockUntilServerActive(server.getId());
Server server = getDefaultServerImmediately(); //TODO check
int serverId = server.getId(); }
client.resizeServer(serverId, 2);
blockUntilServerVerifyResize(serverId); @Test(enabled = false, timeOut = 60000, dependsOnMethods = "testRebootSoft")
client.revertResizeServer(serverId); public void testRevertResize() throws Exception {
blockUntilServerActive(serverId); Server server = getDefaultServerImmediately();
assertEquals(1, client.getServer(serverId).getFlavorRef()); int serverId = server.getId();
} client.resizeServer(serverId, 2);
blockUntilServerVerifyResize(serverId);
@Test(enabled = false, timeOut = 10 * 60 * 1000) client.revertResizeServer(serverId);
public void testConfirmResize() throws Exception { blockUntilServerActive(serverId);
Server server = getDefaultServerImmediately(); assertEquals(1, client.getServer(serverId).getFlavorRef());
int serverId = server.getId(); }
client.resizeServer(serverId, 2);
blockUntilServerVerifyResize(serverId); @Test(enabled = false, timeOut = 10 * 60 * 1000)
client.confirmResizeServer(serverId); public void testConfirmResize() throws Exception {
blockUntilServerActive(serverId); Server server = getDefaultServerImmediately();
assertEquals(2, client.getServer(serverId).getFlavorRef()); int serverId = server.getId();
} client.resizeServer(serverId, 2);
blockUntilServerVerifyResize(serverId);
@Test(enabled = true, timeOut = 60000) client.confirmResizeServer(serverId);
void deleteServer2() throws Exception { blockUntilServerActive(serverId);
Server server = getDefaultServerImmediately(); assertEquals(2, client.getServer(serverId).getFlavorRef());
int serverId = server.getId(); }
client.deleteServer(serverId);
waitServerDeleted(serverId); @Test(enabled = true, timeOut = 60000)
} void deleteServer2() throws Exception {
Server server = getDefaultServerImmediately();
@Test(enabled = true, timeOut = 60000) int serverId = server.getId();
void testDeleteImage() throws Exception { client.deleteServer(serverId);
Image image = getDefaultImageImmediately(getDefaultServerImmediately()); waitServerDeleted(serverId);
client.deleteImage(image.getId()); }
assert client.getImage(image.getId()) == null;
} @Test(enabled = false, timeOut = 60000)
void testDeleteImage() throws Exception {
@Test(enabled = true, timeOut = 60000) //TODO: failing, create image from instance returns incorrect JSON
void deleteServer1() throws Exception { Image image = getDefaultImageImmediately(getDefaultServerImmediately());
Server server = getDefaultServerImmediately(); client.deleteImage(image.getId());
int serverId = server.getId(); assert client.getImage(image.getId()) == null;
client.deleteServer(serverId); }
waitServerDeleted(serverId);
} @Test(enabled = true, timeOut = 60000)
void deleteServer1() throws Exception {
@Test Server server = getDefaultServerImmediately();
public void testDeleteAllCreatedServers() { int serverId = server.getId();
for (Server server : client.listServers()) { client.deleteServer(serverId);
if (server.getName().startsWith(serverPrefix)) { waitServerDeleted(serverId);
client.deleteServer(server.getId()); }
System.out.println("Deleted server: " + server);
} @Test
} public void testDeleteAllCreatedServers() {
} for (Server server : client.listServers()) {
if (server.getName().startsWith(serverPrefix)) {
@AfterTest client.deleteServer(server.getId());
void deleteServersOnEnd() { System.out.println("Deleted server: " + server);
testDeleteAllCreatedServers(); }
} }
}
}
@AfterTest
void deleteServersOnEnd() {
testDeleteAllCreatedServers();
}
}

View File

@ -12,4 +12,7 @@
</root> </root>
<logger name="org.jclouds" level="debug" /> <logger name="org.jclouds" level="debug" />
<logger name="jclouds.wire" level="debug" />
<logger name="jclouds.headers" level="debug" />
<logger name="jclouds.ssh" level="debug" />
</configuration> </configuration>

View File

@ -0,0 +1,20 @@
{
"server" : {
"status":"BUILD",
"hostId":"",
"addresses": {
"public":[],
"private":[]
},
"imageRef":"http://dragon004.hw.griddynamics.net:8774/v1.1/images/106",
"adminPass":"MHfyHXPoj88on737",
"flavorRef":"http://dragon004.hw.griddynamics.net:8774/v1.1/flavors/2",
"links" : [
{"href":"http://dragon004.hw.griddynamics.net:8774/v1.1/servers/847","rel":"self"},
{"href":"http://dragon004.hw.griddynamics.net:8774/v1.1/servers/847","type":"application/json","rel":"bookmark"},
{"href":"http://dragon004.hw.griddynamics.net:8774/v1.1/servers/847","type":"application/xml","rel":"bookmark"}],
"name" : "cmsNode-fa2",
"id":847,
"metadata" : {}
}
}

View File

@ -39,7 +39,6 @@
<module>ec2</module> <module>ec2</module>
<module>deltacloud</module> <module>deltacloud</module>
<module>walrus</module> <module>walrus</module>
<module>scality-rs2</module>
<module>eucalyptus</module> <module>eucalyptus</module>
<module>swift</module> <module>swift</module>
<module>cloudfiles</module> <module>cloudfiles</module>

View File

0
apis/swift/src/test/resources/log4j.xml Executable file → Normal file
View File

View File

View File

View File

View File

@ -94,8 +94,7 @@ public class ParseSystemAndUserMetadataFromHeaders implements Function<HttpRespo
if (lastModified == null) { if (lastModified == null) {
// scaleup-storage uses the wrong case for the last modified header // scaleup-storage uses the wrong case for the last modified header
if ((lastModified = from.getFirstHeaderOrNull("Last-modified")) == null) if ((lastModified = from.getFirstHeaderOrNull("Last-modified")) == null)
throw new HttpException(HttpHeaders.LAST_MODIFIED + " header not present in response: " throw new HttpException(HttpHeaders.LAST_MODIFIED + " header not present in response: " + from);
+ from.getStatusLine());
} }
// Walrus // Walrus

View File

View File

View File

View File

0
common/azure/src/test/resources/log4j.xml Executable file → Normal file
View File

0
common/trmk/src/test/resources/log4j.xml Executable file → Normal file
View File

View File

@ -18,10 +18,10 @@
*/ */
package org.jclouds.vcloud.functions; package org.jclouds.vcloud.functions;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.http.HttpUtils.releasePayload; import static org.jclouds.http.HttpUtils.releasePayload;
import java.util.Map; import java.util.Map;
import java.util.NoSuchElementException;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -41,6 +41,8 @@ import org.jclouds.vcloud.endpoints.Org;
import org.jclouds.vcloud.xml.OrgListHandler; import org.jclouds.vcloud.xml.OrgListHandler;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.base.Predicates;
import com.google.common.collect.Iterables;
/** /**
* This parses {@link VCloudSession} from HTTP headers. * This parses {@link VCloudSession} from HTTP headers.
@ -49,7 +51,7 @@ import com.google.common.base.Function;
*/ */
@Singleton @Singleton
public class ParseLoginResponseFromHeaders implements Function<HttpResponse, VCloudSession> { public class ParseLoginResponseFromHeaders implements Function<HttpResponse, VCloudSession> {
static final Pattern pattern = Pattern.compile("(vcloud-token=)?([^;]+)(;.*)?"); static final Pattern pattern = Pattern.compile("(vcloud-token)=?([^;]+)(;.*)?");
private final ParseSax.Factory factory; private final ParseSax.Factory factory;
private final Provider<OrgListHandler> orgHandlerProvider; private final Provider<OrgListHandler> orgHandlerProvider;
@ -61,38 +63,45 @@ public class ParseLoginResponseFromHeaders implements Function<HttpResponse, VCl
} }
/** /**
* parses the http response headers to create a new {@link VCloudSession} * parses the http response headers to create a new {@link VCloudSession} object.
* object.
*/ */
public VCloudSession apply(HttpResponse from) { public VCloudSession apply(HttpResponse from) {
String cookieHeader = from.getFirstHeaderOrNull("x-vcloud-authorization");
if (cookieHeader == null)
cookieHeader = from.getFirstHeaderOrNull(HttpHeaders.SET_COOKIE);
checkNotNull(cookieHeader, "Header %s or %s must be present", "x-vcloud-authorization", HttpHeaders.SET_COOKIE);
final Matcher matcher = pattern.matcher(cookieHeader);
boolean matchFound = matcher.find();
try { try {
if (matchFound) { final String token = parseTokenFromHeaders(from);
final Map<String, ReferenceType> org = factory.create(orgHandlerProvider.get()).parse( final Map<String, ReferenceType> org = factory.create(orgHandlerProvider.get()).parse(
from.getPayload().getInput()); from.getPayload().getInput());
return new VCloudSession() { return new VCloudSession() {
@VCloudToken @VCloudToken
public String getVCloudToken() { public String getVCloudToken() {
return matcher.group(2); return token;
} }
@Org @Org
public Map<String, ReferenceType> getOrgs() { public Map<String, ReferenceType> getOrgs() {
return org; return org;
} }
}; };
}
} finally { } finally {
releasePayload(from); releasePayload(from);
} }
throw new HttpResponseException("x-vcloud-authorization not found ", null, from); }
public String parseTokenFromHeaders(HttpResponse from) {
String cookieHeader = from.getFirstHeaderOrNull("x-vcloud-authorization");
if (cookieHeader != null) {
Matcher matcher = pattern.matcher(cookieHeader);
return matcher.find() ? matcher.group(2) : cookieHeader;
} else {
try {
cookieHeader = Iterables.find(from.getHeaders().get(HttpHeaders.SET_COOKIE), Predicates.contains(pattern));
Matcher matcher = pattern.matcher(cookieHeader);
matcher.find();
return matcher.group(2);
} catch (NoSuchElementException e) {
throw new HttpResponseException(String.format("Header %s or %s must be present", "x-vcloud-authorization",
HttpHeaders.SET_COOKIE), null, from);
}
}
} }
} }

View File

View File

@ -23,6 +23,7 @@ import static org.testng.Assert.assertEquals;
import java.net.URI; import java.net.URI;
import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpResponse;
import org.jclouds.http.HttpResponseException;
import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.io.Payloads; import org.jclouds.io.Payloads;
import org.jclouds.vcloud.VCloudMediaType; import org.jclouds.vcloud.VCloudMediaType;
@ -54,60 +55,98 @@ public class ParseLoginResponseFromHeadersTest extends BaseHandlerTest {
@Test @Test
public void testApply() { public void testApply() {
HttpResponse response = new HttpResponse(200, "OK", Payloads.newInputStreamPayload(getClass() HttpResponse response = new HttpResponse(200, "OK", Payloads.newInputStreamPayload(getClass()
.getResourceAsStream("/orglist.xml")), ImmutableMultimap.<String, String> of("x-vcloud-authorization", .getResourceAsStream("/orglist.xml")), ImmutableMultimap.<String, String> of("x-vcloud-authorization",
"vcloud-token=9er4d061-4bff-48fa-84b1-5da7166764d2; path=/")); "vcloud-token=9er4d061-4bff-48fa-84b1-5da7166764d2; path=/"));
response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8"); response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8");
response.getPayload().getContentMetadata().setContentLength(307l); response.getPayload().getContentMetadata().setContentLength(307l);
VCloudSession reply = parser.apply(response); VCloudSession reply = parser.apply(response);
assertEquals(reply.getVCloudToken(), "9er4d061-4bff-48fa-84b1-5da7166764d2"); assertEquals(reply.getVCloudToken(), "9er4d061-4bff-48fa-84b1-5da7166764d2");
assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org", assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org",
VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48")))); VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
} }
@Test @Test
public void testApplyBlueLock() { public void testApplyBlueLock() {
HttpResponse response = new HttpResponse(200, "OK", Payloads.newInputStreamPayload(getClass() HttpResponse response = new HttpResponse(200, "OK", Payloads.newInputStreamPayload(getClass()
.getResourceAsStream("/orglist.xml")), ImmutableMultimap.<String, String> of("x-vcloud-authorization", .getResourceAsStream("/orglist.xml")), ImmutableMultimap.<String, String> of("x-vcloud-authorization",
"MUKOJ2HoAfoMmLnHRp4esNb2MtWscCLLhVysnsIsCG0=")); "MUKOJ2HoAfoMmLnHRp4esNb2MtWscCLLhVysnsIsCG0="));
response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8"); response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8");
response.getPayload().getContentMetadata().setContentLength(307l); response.getPayload().getContentMetadata().setContentLength(307l);
VCloudSession reply = parser.apply(response); VCloudSession reply = parser.apply(response);
assertEquals(reply.getVCloudToken(), "MUKOJ2HoAfoMmLnHRp4esNb2MtWscCLLhVysnsIsCG0="); assertEquals(reply.getVCloudToken(), "MUKOJ2HoAfoMmLnHRp4esNb2MtWscCLLhVysnsIsCG0=");
assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org", assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org",
VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48")))); VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
} }
@Test @Test
public void testApplyTerremark() { public void testApplyTerremark() {
HttpResponse response = new HttpResponse(200, "OK", Payloads.newInputStreamPayload(getClass() HttpResponse response = new HttpResponse(200, "OK", Payloads.newInputStreamPayload(getClass()
.getResourceAsStream("/orglist.xml")), ImmutableMultimap.<String, String> of("Set-Cookie", .getResourceAsStream("/orglist.xml")), ImmutableMultimap.<String, String> of("Set-Cookie",
"vcloud-token=37ce2715-9aba-4f48-8e45-2db8a8da702d; path=/")); "vcloud-token=37ce2715-9aba-4f48-8e45-2db8a8da702d; path=/"));
response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8"); response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8");
response.getPayload().getContentMetadata().setContentLength(307l); response.getPayload().getContentMetadata().setContentLength(307l);
VCloudSession reply = parser.apply(response); VCloudSession reply = parser.apply(response);
assertEquals(reply.getVCloudToken(), "37ce2715-9aba-4f48-8e45-2db8a8da702d"); assertEquals(reply.getVCloudToken(), "37ce2715-9aba-4f48-8e45-2db8a8da702d");
assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org", assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org",
VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48")))); VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
} }
@Test
public void testApplyTerremarkMultipleCookies() {
HttpResponse response = new HttpResponse(200, "OK", Payloads.newInputStreamPayload(getClass()
.getResourceAsStream("/orglist.xml")), ImmutableMultimap.<String, String> builder().put("Set-Cookie",
"NSC_ESUO_21654_72.46.239.132_443=fooo;expires=Thu, 02-Jun-2011 17:19:26 GMT;path=/;secure;httponly")
.put("Set-Cookie", "vcloud-token=37ce2715-9aba-4f48-8e45-2db8a8da702d; path=/").build());
response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8");
response.getPayload().getContentMetadata().setContentLength(307l);
VCloudSession reply = parser.apply(response);
assertEquals(reply.getVCloudToken(), "37ce2715-9aba-4f48-8e45-2db8a8da702d");
assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org",
VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
}
@Test(expectedExceptions = HttpResponseException.class)
public void testUnmatchedCookieThrowsHttpResponseException() {
HttpResponse response = new HttpResponse(200, "OK", Payloads.newInputStreamPayload(getClass()
.getResourceAsStream("/orglist.xml")), ImmutableMultimap.<String, String> builder().put("Set-Cookie",
"NSC_ESUO_21654_72.46.239.132_443=fooo;expires=Thu, 02-Jun-2011 17:19:26 GMT;path=/;secure;httponly")
.build());
response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8");
response.getPayload().getContentMetadata().setContentLength(307l);
parser.apply(response);
}
@Test(expectedExceptions = HttpResponseException.class)
public void testNoThrowsHttpResponseException() {
HttpResponse response = new HttpResponse(200, "OK", Payloads.newInputStreamPayload(getClass()
.getResourceAsStream("/orglist.xml")), ImmutableMultimap.<String, String> of());
response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8");
response.getPayload().getContentMetadata().setContentLength(307l);
parser.apply(response);
}
@Test @Test
public void testApplyVirtacore() { public void testApplyVirtacore() {
HttpResponse response = new HttpResponse(200, "OK", Payloads.newInputStreamPayload(getClass() HttpResponse response = new HttpResponse(200, "OK", Payloads.newInputStreamPayload(getClass()
.getResourceAsStream("/orglist.xml")), ImmutableMultimap.<String, String> of("x-vcloud-authorization", .getResourceAsStream("/orglist.xml")), ImmutableMultimap.<String, String> of("x-vcloud-authorization",
"vcloud-token=IPy0w7UGD4lwtdWAK/ZVzfuLK+dztxGRqsOhWqV0i48=")); "vcloud-token=IPy0w7UGD4lwtdWAK/ZVzfuLK+dztxGRqsOhWqV0i48="));
response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8"); response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8");
response.getPayload().getContentMetadata().setContentLength(307l); response.getPayload().getContentMetadata().setContentLength(307l);
VCloudSession reply = parser.apply(response); VCloudSession reply = parser.apply(response);
assertEquals(reply.getVCloudToken(), "IPy0w7UGD4lwtdWAK/ZVzfuLK+dztxGRqsOhWqV0i48="); assertEquals(reply.getVCloudToken(), "IPy0w7UGD4lwtdWAK/ZVzfuLK+dztxGRqsOhWqV0i48=");
assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org", assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org",
VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48")))); VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
} }
} }

0
common/vcloud/src/test/resources/log4j.xml Executable file → Normal file
View File

View File

@ -18,11 +18,12 @@
; ;
(ns org.jclouds.predicate) (ns org.jclouds.predicate)
(defprotocol Predicate (defprotocol Coercions
"Protocol for making a com.google.common.base.Predicate." "Protocol for coercing between predicate-like things, like
Clojure fns and com.google.common.base.Predicate."
(to-predicate [p])) (to-predicate [p]))
(extend-protocol Predicate (extend-protocol Coercions
clojure.lang.IFn clojure.lang.IFn
(to-predicate [p] (to-predicate [p]
(reify com.google.common.base.Predicate (reify com.google.common.base.Predicate

View File

View File

@ -416,6 +416,7 @@ public class TemplateBuilderImpl implements TemplateBuilder {
*/ */
@Override @Override
public TemplateBuilder fromTemplate(Template template) { public TemplateBuilder fromTemplate(Template template) {
location = template.getLocation();
fromHardware(template.getHardware()); fromHardware(template.getHardware());
fromImage(template.getImage()); fromImage(template.getImage());
options(template.getOptions()); options(template.getOptions());

View File

View File

@ -33,6 +33,7 @@ import java.util.concurrent.TimeoutException;
import org.jclouds.Constants; import org.jclouds.Constants;
import org.jclouds.compute.config.BaseComputeServiceContextModule; import org.jclouds.compute.config.BaseComputeServiceContextModule;
import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.OsFamilyVersion64Bit;
import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.Template;
@ -77,6 +78,35 @@ public abstract class BaseTemplateBuilderLiveTest {
apiversion = System.getProperty("test." + provider + ".apiversion"); apiversion = System.getProperty("test." + provider + ".apiversion");
} }
public void testCompareSizes() throws Exception {
Hardware defaultSize = context.getComputeService().templateBuilder().build().getHardware();
Hardware smallest = context.getComputeService().templateBuilder().smallest().build().getHardware();
Hardware fastest = context.getComputeService().templateBuilder().fastest().build().getHardware();
Hardware biggest = context.getComputeService().templateBuilder().biggest().build().getHardware();
System.out.printf("smallest %s%n", smallest);
System.out.printf("fastest %s%n", fastest);
System.out.printf("biggest %s%n", biggest);
assertEquals(defaultSize, smallest);
assert getCores(smallest) <= getCores(fastest) : String.format("%s ! <= %s", smallest, fastest);
assert getCores(biggest) <= getCores(fastest) : String.format("%s ! <= %s", biggest, fastest);
assert biggest.getRam() >= fastest.getRam() : String.format("%s ! >= %s", biggest, fastest);
assert biggest.getRam() >= smallest.getRam() : String.format("%s ! >= %s", biggest, smallest);
assert getCores(fastest) >= getCores(biggest) : String.format("%s ! >= %s", fastest, biggest);
assert getCores(fastest) >= getCores(smallest) : String.format("%s ! >= %s", fastest, smallest);
}
public void testFromTemplate() {
Template defaultTemplate = context.getComputeService().templateBuilder().build();
assertEquals(context.getComputeService().templateBuilder().fromTemplate(defaultTemplate).build().toString(),
defaultTemplate.toString());
}
protected Properties setupProperties() { protected Properties setupProperties() {
Properties overrides = new Properties(); Properties overrides = new Properties();
overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true");

0
core/src/main/java/org/jclouds/PropertiesBuilder.java Executable file → Normal file
View File

0
core/src/main/java/org/jclouds/collect/Memoized.java Executable file → Normal file
View File

View File

0
core/src/main/java/org/jclouds/date/DateService.java Executable file → Normal file
View File

View File

0
core/src/main/java/org/jclouds/rest/Binder.java Executable file → Normal file
View File

View File

0
core/src/main/java/org/jclouds/rest/RestContext.java Executable file → Normal file
View File

Some files were not shown because too many files have changed in this diff Show More