mirror of https://github.com/apache/jclouds.git
added better logging to softlayer tests
This commit is contained in:
parent
d5e243f396
commit
98b28d7873
|
@ -36,9 +36,8 @@ import java.util.Set;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a ProductOrder into a json string
|
* Converts a ProductOrder into a json string valid for placing an order via the softlayer api The
|
||||||
* valid for placing an order via the softlayer api
|
* String is set into the payload of the HttpRequest
|
||||||
* The String is set into the payload of the HttpRequest
|
|
||||||
*
|
*
|
||||||
* @author Jason King
|
* @author Jason King
|
||||||
*/
|
*/
|
||||||
|
@ -61,13 +60,13 @@ public class ProductOrderToJson implements Binder {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a Json string suitable for sending to the softlayer api
|
* Builds a Json string suitable for sending to the softlayer api
|
||||||
|
*
|
||||||
* @param order
|
* @param order
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
String buildJson(ProductOrder order) {
|
String buildJson(ProductOrder order) {
|
||||||
|
|
||||||
Iterable<Price> prices = Iterables.transform(order.getPrices(),
|
Iterable<Price> prices = Iterables.transform(order.getPrices(), new Function<ProductItemPrice, Price>() {
|
||||||
new Function<ProductItemPrice,Price>() {
|
|
||||||
@Override
|
@Override
|
||||||
public Price apply(ProductItemPrice productItemPrice) {
|
public Price apply(ProductItemPrice productItemPrice) {
|
||||||
return new Price(productItemPrice.getId());
|
return new Price(productItemPrice.getId());
|
||||||
|
@ -82,13 +81,13 @@ public class ProductOrderToJson implements Binder {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
OrderData data = new OrderData(order.getPackageId(),order.getLocation(),
|
OrderData data = new OrderData(order.getPackageId(), order.getLocation(), Sets.newLinkedHashSet(prices), Sets
|
||||||
Sets.newLinkedHashSet(prices),Sets.newLinkedHashSet(hosts),
|
.newLinkedHashSet(hosts), order.getQuantity(), order.getUseHourlyPricing());
|
||||||
order.getQuantity(),order.getUseHourlyPricing());
|
|
||||||
|
|
||||||
return json.toJson(ImmutableMap.of("parameters", ImmutableList.<OrderData> of(data)));
|
return json.toJson(ImmutableMap.of("parameters", ImmutableList.<OrderData> of(data)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private static class OrderData {
|
private static class OrderData {
|
||||||
private String complexType = "SoftLayer_Container_Product_Order_Virtual_Guest";
|
private String complexType = "SoftLayer_Container_Product_Order_Virtual_Guest";
|
||||||
private long packageId = -1;
|
private long packageId = -1;
|
||||||
|
@ -98,8 +97,7 @@ public class ProductOrderToJson implements Binder {
|
||||||
private long quantity;
|
private long quantity;
|
||||||
private boolean useHourlyPricing;
|
private boolean useHourlyPricing;
|
||||||
|
|
||||||
public OrderData( long packageId, String location,
|
public OrderData(long packageId, String location, Set<Price> prices, Set<HostnameAndDomain> virtualGuests,
|
||||||
Set<Price> prices,Set<HostnameAndDomain> virtualGuests,
|
|
||||||
long quantity, boolean useHourlyPricing) {
|
long quantity, boolean useHourlyPricing) {
|
||||||
this.packageId = packageId;
|
this.packageId = packageId;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
|
@ -107,10 +105,11 @@ public class ProductOrderToJson implements Binder {
|
||||||
this.virtualGuests = virtualGuests;
|
this.virtualGuests = virtualGuests;
|
||||||
this.quantity = quantity;
|
this.quantity = quantity;
|
||||||
this.useHourlyPricing = useHourlyPricing;
|
this.useHourlyPricing = useHourlyPricing;
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private static class HostnameAndDomain {
|
private static class HostnameAndDomain {
|
||||||
private String hostname;
|
private String hostname;
|
||||||
private String domain;
|
private String domain;
|
||||||
|
@ -122,6 +121,7 @@ public class ProductOrderToJson implements Binder {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private static class Price {
|
private static class Price {
|
||||||
private long id;
|
private long id;
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.jclouds.softlayer.compute.functions;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.compute.util.ComputeServiceUtils.parseGroupFromName;
|
import static org.jclouds.compute.util.ComputeServiceUtils.parseGroupFromName;
|
||||||
import static org.jclouds.softlayer.compute.functions.ProductItemsToHardware.CORE_SPEED;
|
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -28,11 +27,13 @@ import java.util.Set;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
import org.jclouds.collect.FindResourceInSet;
|
import org.jclouds.collect.FindResourceInSet;
|
||||||
import org.jclouds.collect.Memoized;
|
import org.jclouds.collect.Memoized;
|
||||||
import org.jclouds.compute.domain.*;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
|
import org.jclouds.compute.domain.Image;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
|
import org.jclouds.compute.domain.NodeState;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.http.HttpResponseException;
|
import org.jclouds.http.HttpResponseException;
|
||||||
|
@ -41,12 +42,14 @@ import org.jclouds.softlayer.domain.Datacenter;
|
||||||
import org.jclouds.softlayer.domain.ProductItem;
|
import org.jclouds.softlayer.domain.ProductItem;
|
||||||
import org.jclouds.softlayer.domain.ProductOrder;
|
import org.jclouds.softlayer.domain.ProductOrder;
|
||||||
import org.jclouds.softlayer.domain.VirtualGuest;
|
import org.jclouds.softlayer.domain.VirtualGuest;
|
||||||
|
import org.jclouds.softlayer.predicates.ProductItemPredicates;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
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.ImmutableSet;
|
||||||
import org.jclouds.softlayer.predicates.ProductItemPredicates;
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
@ -67,9 +70,7 @@ public class VirtualGuestToNodeMetadata implements Function<VirtualGuest, NodeMe
|
||||||
@Inject
|
@Inject
|
||||||
VirtualGuestToNodeMetadata(Map<String, Credentials> credentialStore,
|
VirtualGuestToNodeMetadata(Map<String, Credentials> credentialStore,
|
||||||
FindLocationForVirtualGuest findLocationForVirtualGuest,
|
FindLocationForVirtualGuest findLocationForVirtualGuest,
|
||||||
GetHardwareForVirtualGuest getHardwareForVirtualGuest,
|
GetHardwareForVirtualGuest getHardwareForVirtualGuest, GetImageForVirtualGuest getImageForVirtualGuest) {
|
||||||
GetImageForVirtualGuest getImageForVirtualGuest
|
|
||||||
) {
|
|
||||||
this.credentialStore = checkNotNull(credentialStore, "credentialStore");
|
this.credentialStore = checkNotNull(credentialStore, "credentialStore");
|
||||||
this.findLocationForVirtualGuest = checkNotNull(findLocationForVirtualGuest, "findLocationForVirtualGuest");
|
this.findLocationForVirtualGuest = checkNotNull(findLocationForVirtualGuest, "findLocationForVirtualGuest");
|
||||||
this.getHardwareForVirtualGuest = checkNotNull(getHardwareForVirtualGuest, "getHardwareForVirtualGuest");
|
this.getHardwareForVirtualGuest = checkNotNull(getHardwareForVirtualGuest, "getHardwareForVirtualGuest");
|
||||||
|
@ -93,7 +94,8 @@ public class VirtualGuestToNodeMetadata implements Function<VirtualGuest, NodeMe
|
||||||
}
|
}
|
||||||
|
|
||||||
Hardware hardware = getHardwareForVirtualGuest.getHardware(from);
|
Hardware hardware = getHardwareForVirtualGuest.getHardware(from);
|
||||||
if (hardware!=null) builder.hardware(hardware);
|
if (hardware != null)
|
||||||
|
builder.hardware(hardware);
|
||||||
|
|
||||||
builder.state(serverStateToNodeState.get(from.getPowerState().getKeyName()));
|
builder.state(serverStateToNodeState.get(from.getPowerState().getKeyName()));
|
||||||
|
|
||||||
|
@ -136,7 +138,8 @@ public class VirtualGuestToNodeMetadata implements Function<VirtualGuest, NodeMe
|
||||||
|
|
||||||
public Hardware getHardware(VirtualGuest guest) {
|
public Hardware getHardware(VirtualGuest guest) {
|
||||||
// 'bad' orders have no start cpu's and cause the order lookup to fail.
|
// 'bad' orders have no start cpu's and cause the order lookup to fail.
|
||||||
if (guest.getStartCpus()<1) return null;
|
if (guest.getStartCpus() < 1)
|
||||||
|
return null;
|
||||||
try {
|
try {
|
||||||
ProductOrder order = client.getVirtualGuestClient().getOrderTemplate(guest.getId());
|
ProductOrder order = client.getVirtualGuestClient().getOrderTemplate(guest.getId());
|
||||||
Iterable<ProductItem> items = Iterables.transform(order.getPrices(), ProductItems.item());
|
Iterable<ProductItem> items = Iterables.transform(order.getPrices(), ProductItems.item());
|
||||||
|
@ -160,7 +163,8 @@ public class VirtualGuestToNodeMetadata implements Function<VirtualGuest, NodeMe
|
||||||
|
|
||||||
public Image getImage(VirtualGuest guest) {
|
public Image getImage(VirtualGuest guest) {
|
||||||
// 'bad' orders have no start cpu's and cause the order lookup to fail.
|
// 'bad' orders have no start cpu's and cause the order lookup to fail.
|
||||||
if (guest.getStartCpus()<1) return null;
|
if (guest.getStartCpus() < 1)
|
||||||
|
return null;
|
||||||
try {
|
try {
|
||||||
ProductOrder order = client.getVirtualGuestClient().getOrderTemplate(guest.getId());
|
ProductOrder order = client.getVirtualGuestClient().getOrderTemplate(guest.getId());
|
||||||
Iterable<ProductItem> items = Iterables.transform(order.getPrices(), ProductItems.item());
|
Iterable<ProductItem> items = Iterables.transform(order.getPrices(), ProductItems.item());
|
||||||
|
|
|
@ -18,13 +18,12 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.softlayer.domain;
|
package org.jclouds.softlayer.domain;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import static com.google.common.base.Strings.emptyToNull;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -18,20 +18,15 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.softlayer.compute;
|
package org.jclouds.softlayer.compute;
|
||||||
|
|
||||||
import com.google.inject.Module;
|
|
||||||
import org.jclouds.compute.BaseComputeServiceLiveTest;
|
import org.jclouds.compute.BaseComputeServiceLiveTest;
|
||||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
|
||||||
import org.jclouds.domain.LocationScope;
|
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
import org.jclouds.softlayer.SoftLayerAsyncClient;
|
import org.jclouds.softlayer.SoftLayerAsyncClient;
|
||||||
import org.jclouds.softlayer.SoftLayerClient;
|
import org.jclouds.softlayer.SoftLayerClient;
|
||||||
import org.jclouds.sshj.config.SshjSshClientModule;
|
import org.jclouds.sshj.config.SshjSshClientModule;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
For more configuration infromation and examples see the Apache Log4j
|
For more configuration infromation and examples see the Apache
|
||||||
website: http://logging.apache.org/log4j/
|
Log4j website: http://logging.apache.org/log4j/
|
||||||
-->
|
-->
|
||||||
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
|
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
|
||||||
debug="false">
|
debug="false">
|
||||||
|
@ -19,13 +19,13 @@
|
||||||
<param name="Threshold" value="TRACE" />
|
<param name="Threshold" value="TRACE" />
|
||||||
|
|
||||||
<layout class="org.apache.log4j.PatternLayout">
|
<layout class="org.apache.log4j.PatternLayout">
|
||||||
<!-- The default pattern: Date Priority [Category] Message${symbol_escape}n -->
|
<!-- The default pattern: Date Priority [Category] Message\n -->
|
||||||
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
|
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
The full pattern: Date MS Priority [Category] (Thread:NDC) Message${symbol_escape}n
|
The full pattern: Date MS Priority [Category]
|
||||||
<param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x)
|
(Thread:NDC) Message\n <param name="ConversionPattern"
|
||||||
%m%n"/>
|
value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
|
||||||
-->
|
-->
|
||||||
</layout>
|
</layout>
|
||||||
</appender>
|
</appender>
|
||||||
|
@ -41,17 +41,69 @@
|
||||||
<param name="Threshold" value="TRACE" />
|
<param name="Threshold" value="TRACE" />
|
||||||
|
|
||||||
<layout class="org.apache.log4j.PatternLayout">
|
<layout class="org.apache.log4j.PatternLayout">
|
||||||
<!-- The default pattern: Date Priority [Category] Message${symbol_escape}n -->
|
<!-- The default pattern: Date Priority [Category] Message\n -->
|
||||||
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
|
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
The full pattern: Date MS Priority [Category] (Thread:NDC) Message${symbol_escape}n
|
The full pattern: Date MS Priority [Category]
|
||||||
<param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x)
|
(Thread:NDC) Message\n <param name="ConversionPattern"
|
||||||
%m%n"/>
|
value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
|
||||||
-->
|
-->
|
||||||
</layout>
|
</layout>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
|
<!-- A time/date based rolling appender -->
|
||||||
|
<appender name="COMPUTEFILE" class="org.apache.log4j.DailyRollingFileAppender">
|
||||||
|
<param name="File" value="target/test-data/jclouds-compute.log" />
|
||||||
|
<param name="Append" value="true" />
|
||||||
|
|
||||||
|
<!-- Rollover at midnight each day -->
|
||||||
|
<param name="DatePattern" value="'.'yyyy-MM-dd" />
|
||||||
|
|
||||||
|
<param name="Threshold" value="TRACE" />
|
||||||
|
|
||||||
|
<layout class="org.apache.log4j.PatternLayout">
|
||||||
|
<!-- The default pattern: Date Priority [Category] Message\n -->
|
||||||
|
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
|
||||||
|
|
||||||
|
<!--
|
||||||
|
The full pattern: Date MS Priority [Category]
|
||||||
|
(Thread:NDC) Message\n <param name="ConversionPattern"
|
||||||
|
value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
|
||||||
|
-->
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- A time/date based rolling appender -->
|
||||||
|
<appender name="SSHFILE" class="org.apache.log4j.DailyRollingFileAppender">
|
||||||
|
<param name="File" value="target/test-data/jclouds-ssh.log" />
|
||||||
|
<param name="Append" value="true" />
|
||||||
|
|
||||||
|
<!-- Rollover at midnight each day -->
|
||||||
|
<param name="DatePattern" value="'.'yyyy-MM-dd" />
|
||||||
|
|
||||||
|
<param name="Threshold" value="TRACE" />
|
||||||
|
|
||||||
|
<layout class="org.apache.log4j.PatternLayout">
|
||||||
|
<!-- The default pattern: Date Priority [Category] Message\n -->
|
||||||
|
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
|
||||||
|
|
||||||
|
<!--
|
||||||
|
The full pattern: Date MS Priority [Category]
|
||||||
|
(Thread:NDC) Message\n <param name="ConversionPattern"
|
||||||
|
value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
|
||||||
|
-->
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="ASYNCCOMPUTE" class="org.apache.log4j.AsyncAppender">
|
||||||
|
<appender-ref ref="COMPUTEFILE" />
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="ASYNCSSH" class="org.apache.log4j.AsyncAppender">
|
||||||
|
<appender-ref ref="SSHFILE" />
|
||||||
|
</appender>
|
||||||
|
|
||||||
<appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
|
<appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
|
||||||
<appender-ref ref="FILE" />
|
<appender-ref ref="FILE" />
|
||||||
</appender>
|
</appender>
|
||||||
|
@ -74,11 +126,20 @@
|
||||||
<appender-ref ref="ASYNCWIRE" />
|
<appender-ref ref="ASYNCWIRE" />
|
||||||
</category>
|
</category>
|
||||||
|
|
||||||
|
<category name="jclouds.ssh">
|
||||||
|
<priority value="DEBUG" />
|
||||||
|
<appender-ref ref="ASYNCSSH" />
|
||||||
|
</category>
|
||||||
|
|
||||||
<category name="jclouds.wire">
|
<category name="jclouds.wire">
|
||||||
<priority value="DEBUG" />
|
<priority value="DEBUG" />
|
||||||
<appender-ref ref="ASYNCWIRE" />
|
<appender-ref ref="ASYNCWIRE" />
|
||||||
</category>
|
</category>
|
||||||
|
|
||||||
|
<category name="jclouds.compute">
|
||||||
|
<priority value="TRACE" />
|
||||||
|
<appender-ref ref="ASYNCCOMPUTE" />
|
||||||
|
</category>
|
||||||
<!-- ======================= -->
|
<!-- ======================= -->
|
||||||
<!-- Setup the Root category -->
|
<!-- Setup the Root category -->
|
||||||
<!-- ======================= -->
|
<!-- ======================= -->
|
||||||
|
|
Loading…
Reference in New Issue