mirror of https://github.com/apache/jclouds.git
Issue 484:Add ability to disable the monitor on Terremark eCloud Internet Service
This commit is contained in:
parent
c83eb2e395
commit
63b6f21044
|
@ -25,7 +25,7 @@ import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.vcloud.terremark.binders.BindAddInternetServiceToXmlPayload;
|
import org.jclouds.vcloud.terremark.binders.BindAddInternetServiceToXmlPayload;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -40,26 +40,29 @@ public class AddInternetServiceOptions extends BindAddInternetServiceToXmlPayloa
|
||||||
String enabled = "true";
|
String enabled = "true";
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
Boolean monitorEnabled = null;
|
Boolean monitorEnabled = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <R extends HttpRequest> R bindToRequest(R request, Map<String, String> postParams) {
|
public <R extends HttpRequest> R bindToRequest(R request, Map<String, String> postParams) {
|
||||||
Map<String, String> copy = Maps.newHashMap();
|
ImmutableMap.Builder<String, String> copy = ImmutableMap.<String, String> builder();
|
||||||
copy.putAll(postParams);
|
copy.putAll(postParams);
|
||||||
|
if (description != null)
|
||||||
copy.put("description", description);
|
copy.put("description", description);
|
||||||
copy.put("enabled", enabled);
|
copy.put("enabled", enabled);
|
||||||
if (monitorEnabled != null) {
|
if (monitorEnabled != null)
|
||||||
copy.put("monitor", monitorEnabled.toString());
|
copy.put("monitor", monitorEnabled.toString());
|
||||||
}
|
return super.bindToRequest(request, copy.build());
|
||||||
return super.bindToRequest(request, copy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AddInternetServiceOptions disabled() {
|
public AddInternetServiceOptions disabled() {
|
||||||
this.enabled = "false";
|
this.enabled = "false";
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AddInternetServiceOptions monitorDisabled() {
|
public AddInternetServiceOptions monitorDisabled() {
|
||||||
this.monitorEnabled = false;
|
this.monitorEnabled = false;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AddInternetServiceOptions withDescription(String description) {
|
public AddInternetServiceOptions withDescription(String description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -112,10 +112,10 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes
|
||||||
VDC vdc = tmClient.findVDCInOrgNamed(null, null);
|
VDC vdc = tmClient.findVDCInOrgNamed(null, null);
|
||||||
Set<PublicIpAddress> publicIpAddresses = tmClient.getPublicIpsAssociatedWithVDC(vdc.getHref());
|
Set<PublicIpAddress> publicIpAddresses = tmClient.getPublicIpsAssociatedWithVDC(vdc.getHref());
|
||||||
PublicIpAddress publicIp = publicIpAddresses.iterator().next();
|
PublicIpAddress publicIp = publicIpAddresses.iterator().next();
|
||||||
System.out.println("PublicIP: " + publicIp.getAddress());
|
|
||||||
|
|
||||||
tmClient.addInternetServiceToExistingIp(publicIp.getId(), PREFIX + "-no-monitoring", Protocol.TCP, 1234,
|
InternetService service = tmClient.addInternetServiceToExistingIp(publicIp.getId(), PREFIX + "-no-monitoring",
|
||||||
AddInternetServiceOptions.Builder.monitorDisabled());
|
Protocol.TCP, 1234, AddInternetServiceOptions.Builder.monitorDisabled());
|
||||||
|
tmClient.deleteInternetService(service.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -381,8 +381,8 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes
|
||||||
assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.MEMORY)).getVirtualQuantity(), memory);
|
assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.MEMORY)).getVirtualQuantity(), memory);
|
||||||
assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.DISK_DRIVE)).getVirtualQuantity(),
|
assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.DISK_DRIVE)).getVirtualQuantity(),
|
||||||
hardDisk);
|
hardDisk);
|
||||||
assertEquals(vApp.getSize().longValue(), find(vApp.getResourceAllocations(),
|
assertEquals(vApp.getSize().longValue(),
|
||||||
resourceType(ResourceType.DISK_DRIVE)).getVirtualQuantity());
|
find(vApp.getResourceAllocations(), resourceType(ResourceType.DISK_DRIVE)).getVirtualQuantity());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doCheckPass(String address) throws IOException {
|
private void doCheckPass(String address) throws IOException {
|
||||||
|
@ -465,8 +465,7 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes
|
||||||
Properties overrides = setupProperties();
|
Properties overrides = setupProperties();
|
||||||
|
|
||||||
Injector injector = new RestContextFactory().createContextBuilder(provider,
|
Injector injector = new RestContextFactory().createContextBuilder(provider,
|
||||||
ImmutableSet.<Module> of(new Log4JLoggingModule(), new JschSshClientModule()), overrides)
|
ImmutableSet.<Module> of(new Log4JLoggingModule(), new JschSshClientModule()), overrides).buildInjector();
|
||||||
.buildInjector();
|
|
||||||
|
|
||||||
connection = tmClient = injector.getInstance(TerremarkVCloudClient.class);
|
connection = tmClient = injector.getInstance(TerremarkVCloudClient.class);
|
||||||
|
|
||||||
|
|
|
@ -7,5 +7,5 @@
|
||||||
<Enabled>false</Enabled>
|
<Enabled>false</Enabled>
|
||||||
|
|
||||||
<Description>yahoo</Description>
|
<Description>yahoo</Description>
|
||||||
<Monitor><MonitorType>Disabled</MonitorType></Monitor>
|
|
||||||
</CreateInternetServiceRequest>
|
</CreateInternetServiceRequest>
|
||||||
|
|
|
@ -299,12 +299,12 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkEClo
|
||||||
Method method = TerremarkECloudAsyncClient.class.getMethod("addInternetServiceToExistingIp", URI.class,
|
Method method = TerremarkECloudAsyncClient.class.getMethod("addInternetServiceToExistingIp", URI.class,
|
||||||
String.class, Protocol.class, int.class, AddInternetServiceOptions[].class);
|
String.class, Protocol.class, int.class, AddInternetServiceOptions[].class);
|
||||||
HttpRequest request = processor.createRequest(method, URI.create("https://vcloud/extensions/publicIp/12"),
|
HttpRequest request = processor.createRequest(method, URI.create("https://vcloud/extensions/publicIp/12"),
|
||||||
"name", Protocol.TCP, 22, disabled().withDescription("yahoo"), AddInternetServiceOptions.Builder.monitorDisabled());
|
"name", Protocol.TCP, 22, disabled().withDescription("yahoo").monitorDisabled());
|
||||||
|
|
||||||
assertRequestLineEquals(request, "POST https://vcloud/extensions/publicIp/12/internetServices HTTP/1.1");
|
assertRequestLineEquals(request, "POST https://vcloud/extensions/publicIp/12/internetServices HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.ecloud.internetService+xml\n");
|
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.ecloud.internetService+xml\n");
|
||||||
assertPayloadEquals(request, Strings2.toStringAndClose(
|
assertPayloadEquals(request, Strings2.toStringAndClose(
|
||||||
getClass().getResourceAsStream("/terremark/CreateInternetService-options-test.xml")).replace(
|
getClass().getResourceAsStream("/CreateInternetService-options-test.xml")).replace(
|
||||||
"vCloudExpressExtensions-1.6", "eCloudExtensions-2.7"),
|
"vCloudExpressExtensions-1.6", "eCloudExtensions-2.7"),
|
||||||
"application/vnd.tmrk.ecloud.internetService+xml", false);
|
"application/vnd.tmrk.ecloud.internetService+xml", false);
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
<CreateInternetServiceRequest
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||||
|
xmlns="urn:tmrk:vCloudExpressExtensions-1.6">
|
||||||
|
<Name>name</Name>
|
||||||
|
<Protocol>TCP</Protocol>
|
||||||
|
<Port>22</Port>
|
||||||
|
<Enabled>false</Enabled>
|
||||||
|
|
||||||
|
<Description>yahoo</Description>
|
||||||
|
|
||||||
|
<Monitor><MonitorType>Disabled</MonitorType></Monitor>
|
||||||
|
</CreateInternetServiceRequest>
|
Loading…
Reference in New Issue