mirror of https://github.com/apache/jclouds.git
Issue 130, 129, 112: added ability for terremark to remove its dependencies. added profile and image objects. refactored ant to include logger
git-svn-id: http://jclouds.googlecode.com/svn/trunk@2396 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
0f835d1fdb
commit
2fddd3223e
|
@ -35,7 +35,11 @@ import org.jclouds.compute.domain.CreateServerResponse;
|
||||||
public interface ComputeService {
|
public interface ComputeService {
|
||||||
SortedSet<Server> listServers();
|
SortedSet<Server> listServers();
|
||||||
|
|
||||||
CreateServerResponse createServer(String name, String profile, String image);
|
/**
|
||||||
|
*
|
||||||
|
* @see Image
|
||||||
|
*/
|
||||||
|
CreateServerResponse createServer(String name, Profile profile, Image image);
|
||||||
|
|
||||||
Server getServerById(String id);
|
Server getServerById(String id);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
package org.jclouds.compute;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public enum Image {
|
||||||
|
CENTOS_53, RHEL_53, UMBUNTU_90, UMBUNTU_JEOS
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
package org.jclouds.compute;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public enum Profile {
|
||||||
|
SMALLEST
|
||||||
|
}
|
|
@ -165,6 +165,9 @@ public class HttpUtils {
|
||||||
if (uriPath.indexOf('@') != 1) {
|
if (uriPath.indexOf('@') != 1) {
|
||||||
List<String> parts = Lists.newArrayList(Splitter.on('@').split(uriPath));
|
List<String> parts = Lists.newArrayList(Splitter.on('@').split(uriPath));
|
||||||
String path = parts.remove(parts.size() - 1);
|
String path = parts.remove(parts.size() - 1);
|
||||||
|
if (parts.size() == 2) {
|
||||||
|
parts = Lists.newArrayList(urlEncode(parts.get(0) + "@" + parts.get(1), '/', ':'));
|
||||||
|
}
|
||||||
parts.add(urlEncode(path, '/', ':'));
|
parts.add(urlEncode(path, '/', ':'));
|
||||||
uriPath = Joiner.on('@').join(parts);
|
uriPath = Joiner.on('@').join(parts);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,2 +1,4 @@
|
||||||
rimuhosting.contextbuilder=org.jclouds.rimuhosting.miro.RimuHostingContextBuilder
|
rimuhosting.contextbuilder=org.jclouds.rimuhosting.miro.RimuHostingContextBuilder
|
||||||
rimuhosting.propertiesbuilder=org.jclouds.rimuhosting.miro.RimuHostingPropertiesBuilder
|
rimuhosting.propertiesbuilder=org.jclouds.rimuhosting.miro.RimuHostingPropertiesBuilder
|
||||||
|
terremark.contextbuilder=org.jclouds.vcloud.terremark.TerremarkVCloudContextBuilder
|
||||||
|
terremark.propertiesbuilder=org.jclouds.vcloud.terremark.TerremarkVCloudPropertiesBuilder
|
|
@ -67,6 +67,12 @@ public class HttpUtilsTest extends PerformanceTest {
|
||||||
.create("blobstore://account:Base64==@azureblob/container-hyphen/prefix"));
|
.create("blobstore://account:Base64==@azureblob/container-hyphen/prefix"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testTerremark() {
|
||||||
|
URI creds = HttpUtils.createUri("compute://user@domain:password@terremark");
|
||||||
|
assertEquals(creds.getUserInfo(), "user@domain:password");
|
||||||
|
assertEquals(creds, URI.create("compute://user%40domain:password@terremark"));
|
||||||
|
}
|
||||||
|
|
||||||
public void testCloudFiles() {
|
public void testCloudFiles() {
|
||||||
URI creds = HttpUtils.createUri("blobstore://account:h3c@cloudfiles/container-hyphen/prefix");
|
URI creds = HttpUtils.createUri("blobstore://account:h3c@cloudfiles/container-hyphen/prefix");
|
||||||
assertEquals(creds, URI.create("blobstore://account:h3c@cloudfiles/container-hyphen/prefix"));
|
assertEquals(creds, URI.create("blobstore://account:h3c@cloudfiles/container-hyphen/prefix"));
|
||||||
|
|
|
@ -23,6 +23,9 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.rimuhosting.miro.servers;
|
package org.jclouds.rimuhosting.miro.servers;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
@ -30,11 +33,15 @@ import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.compute.ComputeService;
|
import org.jclouds.compute.ComputeService;
|
||||||
|
import org.jclouds.compute.Image;
|
||||||
|
import org.jclouds.compute.Profile;
|
||||||
import org.jclouds.compute.domain.CreateServerResponse;
|
import org.jclouds.compute.domain.CreateServerResponse;
|
||||||
import org.jclouds.rimuhosting.miro.RimuHostingClient;
|
import org.jclouds.rimuhosting.miro.RimuHostingClient;
|
||||||
import org.jclouds.rimuhosting.miro.domain.NewServerResponse;
|
import org.jclouds.rimuhosting.miro.domain.NewServerResponse;
|
||||||
import org.jclouds.rimuhosting.miro.domain.Server;
|
import org.jclouds.rimuhosting.miro.domain.Server;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ivan Meredith
|
* @author Ivan Meredith
|
||||||
*/
|
*/
|
||||||
|
@ -47,9 +54,16 @@ public class RimuHostingComputeService implements ComputeService {
|
||||||
this.rhClient = rhClient;
|
this.rhClient = rhClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<Image, String> imageNameMap = ImmutableMap.<Image, String> builder().put(
|
||||||
|
Image.CENTOS_53, "centos53").put(Image.UMBUNTU_90, "ubuntu904").build();
|
||||||
|
private Map<Profile, String> profileNameMap = ImmutableMap.<Profile, String> builder().put(
|
||||||
|
Profile.SMALLEST, "MIRO1B").build();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CreateServerResponse createServer(String name, String profile, String image) {
|
public CreateServerResponse createServer(String name, Profile profile, Image image) {
|
||||||
NewServerResponse serverResponse = rhClient.createInstance(name, image, profile);
|
NewServerResponse serverResponse = rhClient.createInstance(name, checkNotNull(imageNameMap
|
||||||
|
.get(image), "image not supported: " + image), checkNotNull(profileNameMap
|
||||||
|
.get(profile), "profile not supported: " + profile));
|
||||||
return new RimuHostingCreateServerResponse(serverResponse);
|
return new RimuHostingCreateServerResponse(serverResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,8 +83,8 @@ public class RimuHostingComputeService implements ComputeService {
|
||||||
@Override
|
@Override
|
||||||
public SortedSet<org.jclouds.compute.Server> getServerByName(String id) {
|
public SortedSet<org.jclouds.compute.Server> getServerByName(String id) {
|
||||||
SortedSet<org.jclouds.compute.Server> serverSet = new TreeSet<org.jclouds.compute.Server>();
|
SortedSet<org.jclouds.compute.Server> serverSet = new TreeSet<org.jclouds.compute.Server>();
|
||||||
for(Server rhServer : rhClient.getInstanceList()){
|
for (Server rhServer : rhClient.getInstanceList()) {
|
||||||
serverSet.add(new RimuHostingServer(rhServer, rhClient));
|
serverSet.add(new RimuHostingServer(rhServer, rhClient));
|
||||||
}
|
}
|
||||||
return serverSet;
|
return serverSet;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@ package org.jclouds.rimuhosting.miro.servers;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
|
import org.jclouds.compute.Image;
|
||||||
|
import org.jclouds.compute.Profile;
|
||||||
import org.jclouds.compute.domain.CreateServerResponse;
|
import org.jclouds.compute.domain.CreateServerResponse;
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||||
import org.jclouds.rimuhosting.miro.RimuHostingClient;
|
import org.jclouds.rimuhosting.miro.RimuHostingClient;
|
||||||
|
@ -58,7 +60,8 @@ public class RimuHostingComputeServiceLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testServerCreate() {
|
public void testServerCreate() {
|
||||||
CreateServerResponse server = rhServerService.createServer("test.com", "MIRO1B", "lenny");
|
CreateServerResponse server = rhServerService.createServer("test.com", Profile.SMALLEST,
|
||||||
|
Image.CENTOS_53);
|
||||||
assertNotNull(rhClient.getInstance(Long.valueOf(server.getId())));
|
assertNotNull(rhClient.getInstance(Long.valueOf(server.getId())));
|
||||||
rhServerService.getServerById(server.getId()).destroy();
|
rhServerService.getServerById(server.getId()).destroy();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,17 +23,37 @@
|
||||||
====================================================================
|
====================================================================
|
||||||
|
|
||||||
-->
|
-->
|
||||||
<project name="ex6" default="demo" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
|
<project name="ex6" default="list" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
|
||||||
<artifact:localRepository id="jclouds.repository" path="${user.home}/.m2/repository" />
|
<artifact:localRepository id="local.repository" path="${user.home}/.m2/repository" />
|
||||||
|
<artifact:remoteRepository id="jclouds-snapshot.repository" url="http://jclouds.rimuhosting.com/maven2/snapshots" />
|
||||||
|
|
||||||
<artifact:dependencies pathId="jclouds.classpath">
|
<artifact:dependencies pathId="jclouds.classpath">
|
||||||
<dependency groupId="org.jclouds" artifactId="jclouds-ant-plugin" version="1.0-SNAPSHOT" />
|
<dependency groupId="org.jclouds" artifactId="jclouds-ant-plugin" version="1.0-SNAPSHOT" />
|
||||||
<localRepository refid="jclouds.repository" />
|
<dependency groupId="org.jclouds" artifactId="jclouds-terremark" version="1.0-SNAPSHOT" />
|
||||||
|
<dependency groupId="org.jclouds" artifactId="jclouds-rimuhosting" version="1.0-SNAPSHOT" />
|
||||||
|
<localRepository refid="local.repository" />
|
||||||
|
<remoteRepository refid="jclouds-snapshot.repository" />
|
||||||
</artifact:dependencies>
|
</artifact:dependencies>
|
||||||
|
|
||||||
|
|
||||||
<typedef name="compute" classname="org.jclouds.tools.ant.ComputeTask" classpathref="jclouds.classpath" />
|
<typedef name="compute" classname="org.jclouds.tools.ant.ComputeTask" classpathref="jclouds.classpath" />
|
||||||
|
|
||||||
<target name="demo">
|
<property name="jclouds.compute.provider" value="compute://${jclouds.compute.account}:${jclouds.compute.key}@${jclouds.compute.provider}" />
|
||||||
<compute action="create" provider="compute://accountkey:accountkey@rimuhosting" />
|
<property name="jclouds.compute.servername" value="testforjcloud2" />
|
||||||
|
|
||||||
|
<target name="list">
|
||||||
|
<compute action="list" provider="${jclouds.compute.provider}" />
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="clean">
|
||||||
|
<compute action="destroy" provider="${jclouds.compute.provider}" >
|
||||||
|
<server name="${jclouds.compute.servername}"/>
|
||||||
|
</compute>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="create">
|
||||||
|
<compute action="create" provider="${jclouds.compute.provider}" >
|
||||||
|
<server name="${jclouds.compute.servername}" image="CENTOS_53" profile="SMALLEST" />
|
||||||
|
</compute>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -1,32 +1,27 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!--
|
<!--
|
||||||
$HeadURL$
|
$HeadURL$ $Revision$ $Date$ Copyright (C) 2009 Adrian Cole
|
||||||
$Revision$
|
<adrian@jclouds.org>
|
||||||
$Date$
|
|
||||||
|
|
||||||
Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
|
====================================================================
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or
|
||||||
|
more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information regarding
|
||||||
|
copyright ownership. The ASF licenses this file to you 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.html Unless required
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
by applicable law or agreed to in writing, software distributed
|
||||||
or more contributor license agreements. See the NOTICE file
|
under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
distributed with this work for additional information
|
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
regarding copyright ownership. The ASF licenses this file
|
See the License for the specific language governing permissions
|
||||||
to you under the Apache License, Version 2.0 (the
|
and limitations under the License.
|
||||||
"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.html
|
|
||||||
|
|
||||||
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.
|
|
||||||
====================================================================
|
|
||||||
-->
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.jclouds</groupId>
|
<groupId>org.jclouds</groupId>
|
||||||
|
@ -45,7 +40,12 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>jclouds-rimuhosting</artifactId>
|
<artifactId>jclouds-core</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>jclouds-jsch</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -27,22 +27,44 @@ import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
import java.util.SortedSet;
|
||||||
|
|
||||||
import org.apache.tools.ant.BuildException;
|
import org.apache.tools.ant.BuildException;
|
||||||
|
import org.apache.tools.ant.Project;
|
||||||
import org.apache.tools.ant.Task;
|
import org.apache.tools.ant.Task;
|
||||||
import org.jclouds.compute.ComputeService;
|
import org.jclouds.compute.ComputeService;
|
||||||
import org.jclouds.compute.ComputeServiceFactory;
|
import org.jclouds.compute.ComputeServiceFactory;
|
||||||
|
import org.jclouds.compute.Image;
|
||||||
|
import org.jclouds.compute.Profile;
|
||||||
|
import org.jclouds.compute.Server;
|
||||||
|
import org.jclouds.compute.domain.CreateServerResponse;
|
||||||
import org.jclouds.http.HttpUtils;
|
import org.jclouds.http.HttpUtils;
|
||||||
|
import org.jclouds.tools.ant.logging.config.AntLoggingModule;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.collect.MapMaker;
|
import com.google.common.collect.MapMaker;
|
||||||
import com.google.common.io.Resources;
|
import com.google.common.io.Resources;
|
||||||
|
import com.google.inject.Module;
|
||||||
|
import com.google.inject.Provider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ivan Meredith
|
* @author Ivan Meredith
|
||||||
*/
|
*/
|
||||||
public class ComputeTask extends Task {
|
public class ComputeTask extends Task {
|
||||||
private final Map<URI, ComputeService> computeMap;
|
private final Map<URI, ComputeService> computeMap;
|
||||||
|
private static Project project;
|
||||||
|
/**
|
||||||
|
* we don't have a reference to the project during the constructor, so we need to defer expansion
|
||||||
|
* with a Provider.
|
||||||
|
*/
|
||||||
|
private static Provider<Module[]> defaultModulesProvider = new Provider<Module[]>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Module[] get() {
|
||||||
|
return new Module[] { new AntLoggingModule(project) };
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
public ComputeTask() throws IOException {
|
public ComputeTask() throws IOException {
|
||||||
this(buildComputeMap(loadDefaultProperties()));
|
this(buildComputeMap(loadDefaultProperties()));
|
||||||
|
@ -60,7 +82,7 @@ public class ComputeTask extends Task {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ComputeService apply(URI from) {
|
public ComputeService apply(URI from) {
|
||||||
return new ComputeServiceFactory(props).create(from);
|
return new ComputeServiceFactory(props).create(from, defaultModulesProvider.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -71,17 +93,84 @@ public class ComputeTask extends Task {
|
||||||
this.computeMap = computeMap;
|
this.computeMap = computeMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String ACTION_CREATE = "create";
|
public static enum Action {
|
||||||
|
CREATE, LIST, DESTROY
|
||||||
|
}
|
||||||
|
|
||||||
private String provider;
|
private String provider;
|
||||||
private String action;
|
private String action;
|
||||||
private ServerElement serverElement;
|
private ServerElement serverElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the configured {@link ServerElement} element
|
||||||
|
*/
|
||||||
|
public final ServerElement createServer() {
|
||||||
|
if (getServer() == null) {
|
||||||
|
this.serverElement = new ServerElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.serverElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServerElement getServer() {
|
||||||
|
return this.serverElement;
|
||||||
|
}
|
||||||
|
|
||||||
public void execute() throws BuildException {
|
public void execute() throws BuildException {
|
||||||
if (ACTION_CREATE.equalsIgnoreCase(action)) {
|
ComputeTask.project = getProject();
|
||||||
ComputeService computeService = computeMap.get(HttpUtils.createUri(provider));
|
Action action = Action.valueOf(this.action.toUpperCase());
|
||||||
log("hello");
|
ComputeService computeService = computeMap.get(HttpUtils.createUri(provider));
|
||||||
computeService.createServer("test.com", "MIRO1B", "lenny");
|
switch (action) {
|
||||||
|
case CREATE:
|
||||||
|
case DESTROY:
|
||||||
|
if (serverElement != null) {
|
||||||
|
switch (action) {
|
||||||
|
case CREATE:
|
||||||
|
create(computeService);
|
||||||
|
break;
|
||||||
|
case DESTROY:
|
||||||
|
destroy(computeService);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.log("missing server element for action: " + action, Project.MSG_ERR);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case LIST:
|
||||||
|
log("list");
|
||||||
|
for (Server server : computeService.listServers()) {
|
||||||
|
log(String.format(" id=%s, name=%s", server.getId(), server.getName()));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
this.log("bad action: " + action, Project.MSG_ERR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void create(ComputeService computeService) {
|
||||||
|
log(String.format("create name: %s, profile: %s, image: %s", serverElement.getName(),
|
||||||
|
serverElement.getProfile(), serverElement.getImage()));
|
||||||
|
CreateServerResponse createdServer = computeService.createServer(serverElement.getName(),
|
||||||
|
Profile.valueOf(serverElement.getProfile().toUpperCase()), Image
|
||||||
|
.valueOf(serverElement.getImage().toUpperCase()));
|
||||||
|
log(String.format(" id=%s, name=%s, connection=%s://%s:%s@%s:%d", createdServer.getId(),
|
||||||
|
createdServer.getName(), createdServer.getLoginType().toString().toLowerCase(),
|
||||||
|
createdServer.getCredentials().account, createdServer.getCredentials().key,
|
||||||
|
createdServer.getPublicAddresses().first().getHostAddress(), createdServer
|
||||||
|
.getLoginPort()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void destroy(ComputeService computeService) {
|
||||||
|
log(String.format("destroy name: %s", serverElement.getName()));
|
||||||
|
SortedSet<Server> serversThatMatch = computeService.getServerByName(serverElement.getName());
|
||||||
|
if (serversThatMatch.size() > 0) {
|
||||||
|
for (Server server : serversThatMatch) {
|
||||||
|
log(String.format(" destroying id=%s, name=%s", server.getId(), server.getName()));
|
||||||
|
if (!server.destroy()) {
|
||||||
|
log(String.format(" could not destroy id=%s, name=%s", server.getId(), server
|
||||||
|
.getName()), Project.MSG_ERR);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,93 @@
|
||||||
|
package org.jclouds.tools.ant.logging;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import org.apache.tools.ant.Project;
|
||||||
|
import org.jclouds.logging.BaseLogger;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link org.apache.tools.ant.Project} implementation of {@link Logger}.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class AntLogger extends BaseLogger {
|
||||||
|
private final Project project;
|
||||||
|
private final String category;
|
||||||
|
|
||||||
|
public static class AntLoggerFactory implements LoggerFactory {
|
||||||
|
private final Project project;
|
||||||
|
|
||||||
|
public AntLoggerFactory(Project project) {
|
||||||
|
this.project = checkNotNull(project, "project");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Logger getLogger(String category) {
|
||||||
|
return new AntLogger(project, category);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public AntLogger(Project project, String category) {
|
||||||
|
this.project = checkNotNull(project, "project");
|
||||||
|
this.category = category;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void logTrace(String message) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTraceEnabled() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void logDebug(String message) {
|
||||||
|
project.log(message, Project.MSG_DEBUG);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDebugEnabled() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void logInfo(String message) {
|
||||||
|
project.log(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isInfoEnabled() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void logWarn(String message) {
|
||||||
|
project.log(message, Project.MSG_WARN);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void logWarn(String message, Throwable e) {
|
||||||
|
project.log(message, e, Project.MSG_WARN);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWarnEnabled() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void logError(String message) {
|
||||||
|
project.log(message, Project.MSG_ERR);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void logError(String message, Throwable e) {
|
||||||
|
project.log(message, e, Project.MSG_ERR);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isErrorEnabled() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCategory() {
|
||||||
|
return category;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package org.jclouds.tools.ant.logging.config;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import org.apache.tools.ant.Project;
|
||||||
|
import org.jclouds.logging.Logger.LoggerFactory;
|
||||||
|
import org.jclouds.logging.config.LoggingModule;
|
||||||
|
import org.jclouds.tools.ant.logging.AntLogger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures logging of type {@link AntLogger}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class AntLoggingModule extends LoggingModule {
|
||||||
|
|
||||||
|
private final Project project;
|
||||||
|
|
||||||
|
public AntLoggingModule(Project project) {
|
||||||
|
this.project = project;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LoggerFactory createLoggerFactory() {
|
||||||
|
return new AntLogger.AntLoggerFactory(checkNotNull(project, "project"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,37 +1,35 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
|
|
||||||
Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
Copyright (C) 2009 Cloud Conscious, LLC.
|
||||||
|
<info@cloudconscious.com>
|
||||||
|
|
||||||
====================================================================
|
====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one or
|
||||||
or more contributor license agreements. See the NOTICE file
|
more contributor license agreements. See the NOTICE file
|
||||||
distributed with this work for additional information
|
distributed with this work for additional information regarding
|
||||||
regarding copyright ownership. The ASF licenses this file
|
copyright ownership. The ASF licenses this file to you under the
|
||||||
to you under the Apache License, Version 2.0 (the
|
Apache License, Version 2.0 (the "License"); you may not use
|
||||||
"License"); you may not use this file except in compliance
|
this file except in compliance with the License. You may obtain
|
||||||
with the License. You may obtain a copy of the License at
|
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 distributed
|
||||||
Unless required by applicable law or agreed to in writing,
|
under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
software distributed under the License is distributed on an
|
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
See the License for the specific language governing permissions
|
||||||
KIND, either express or implied. See the License for the
|
and limitations under the License.
|
||||||
specific language governing permissions and limitations
|
====================================================================
|
||||||
under the License.
|
-->
|
||||||
====================================================================
|
|
||||||
|
|
||||||
-->
|
|
||||||
<!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">
|
||||||
|
|
||||||
<!-- A time/date based rolling appender -->
|
<!-- A time/date based rolling appender -->
|
||||||
<appender name="WIREFILE" class="org.apache.log4j.DailyRollingFileAppender">
|
<appender name="WIREFILE" class="org.apache.log4j.DailyRollingFileAppender">
|
||||||
|
@ -48,37 +46,37 @@
|
||||||
<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\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 -->
|
<!-- A time/date based rolling appender -->
|
||||||
<appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
|
<appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
|
||||||
<param name="File" value="target/test-data/jclouds.log" />
|
<param name="File" value="target/test-data/jclouds.log" />
|
||||||
<param name="Append" value="true" />
|
<param name="Append" value="true" />
|
||||||
|
|
||||||
<!-- Rollover at midnight each day -->
|
<!-- Rollover at midnight each day -->
|
||||||
<param name="DatePattern" value="'.'yyyy-MM-dd" />
|
<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>
|
||||||
|
|
||||||
<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 -->
|
<!-- A time/date based rolling appender -->
|
||||||
<appender name="VCLOUDFILE" class="org.apache.log4j.DailyRollingFileAppender">
|
<appender name="VCLOUDFILE" class="org.apache.log4j.DailyRollingFileAppender">
|
||||||
<param name="File" value="target/test-data/jclouds-vcloud.log" />
|
<param name="File" value="target/test-data/jclouds-vcloud.log" />
|
||||||
|
@ -94,70 +92,70 @@
|
||||||
<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\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>
|
||||||
|
|
||||||
|
|
||||||
<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>
|
||||||
|
|
||||||
<appender name="ASYNCWIRE" class="org.apache.log4j.AsyncAppender">
|
<appender name="ASYNCWIRE" class="org.apache.log4j.AsyncAppender">
|
||||||
<appender-ref ref="WIREFILE" />
|
<appender-ref ref="WIREFILE" />
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
<appender name="ASYNCVCLOUD" class="org.apache.log4j.AsyncAppender">
|
<appender name="ASYNCVCLOUD" class="org.apache.log4j.AsyncAppender">
|
||||||
<appender-ref ref="VCLOUDFILE" />
|
<appender-ref ref="VCLOUDFILE" />
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
<!-- ================ -->
|
|
||||||
<!-- Limit categories -->
|
|
||||||
<!-- ================ -->
|
|
||||||
|
|
||||||
<category name="org.jclouds">
|
<!-- ================ -->
|
||||||
<priority value="DEBUG" />
|
<!-- Limit categories -->
|
||||||
|
<!-- ================ -->
|
||||||
|
|
||||||
|
<category name="org.jclouds">
|
||||||
|
<priority value="DEBUG" />
|
||||||
<appender-ref ref="ASYNC" />
|
<appender-ref ref="ASYNC" />
|
||||||
</category>
|
</category>
|
||||||
|
|
||||||
<category name="jclouds.http.headers">
|
<category name="jclouds.http.headers">
|
||||||
<priority value="DEBUG" />
|
<priority value="DEBUG" />
|
||||||
<appender-ref ref="ASYNCWIRE" />
|
<appender-ref ref="ASYNCWIRE" />
|
||||||
</category>
|
</category>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<category name="org.jclouds.vcloud.terremark.VCloudComputeClient">
|
<category name="org.jclouds.vcloud.VCloudComputeClient">
|
||||||
<priority value="TRACE" />
|
<priority value="TRACE" />
|
||||||
<appender-ref ref="ASYNCVCLOUD" />
|
<appender-ref ref="ASYNCVCLOUD" />
|
||||||
</category>
|
</category>
|
||||||
|
|
||||||
|
|
||||||
<category name="org.jclouds.predicates.SocketOpen">
|
<category name="org.jclouds.predicates.SocketOpen">
|
||||||
<priority value="TRACE" />
|
<priority value="TRACE" />
|
||||||
<appender-ref ref="ASYNCWIRE" />
|
<appender-ref ref="ASYNCWIRE" />
|
||||||
</category>
|
</category>
|
||||||
|
|
||||||
<category name="org.jclouds.vcloud.predicates.TaskSuccess">
|
<category name="org.jclouds.vcloud.predicates.TaskSuccess">
|
||||||
<priority value="TRACE" />
|
<priority value="TRACE" />
|
||||||
<appender-ref ref="ASYNCWIRE" />
|
<appender-ref ref="ASYNCWIRE" />
|
||||||
</category>
|
</category>
|
||||||
|
|
||||||
|
|
||||||
<category name="jclouds.http.wire">
|
<category name="jclouds.http.wire">
|
||||||
<priority value="DEBUG" />
|
<priority value="DEBUG" />
|
||||||
<appender-ref ref="ASYNCWIRE" />
|
<appender-ref ref="ASYNCWIRE" />
|
||||||
</category>
|
</category>
|
||||||
|
|
||||||
<!-- ======================= -->
|
|
||||||
<!-- Setup the Root category -->
|
|
||||||
<!-- ======================= -->
|
|
||||||
|
|
||||||
<root>
|
<!-- ======================= -->
|
||||||
<priority value="WARN" />
|
<!-- Setup the Root category -->
|
||||||
</root>
|
<!-- ======================= -->
|
||||||
|
|
||||||
|
<root>
|
||||||
|
<priority value="WARN" />
|
||||||
|
</root>
|
||||||
|
|
||||||
</log4j:configuration>
|
</log4j:configuration>
|
|
@ -27,6 +27,7 @@ import static org.jclouds.vcloud.VCloudMediaType.VAPP_XML;
|
||||||
import static org.jclouds.vcloud.VCloudMediaType.VDC_XML;
|
import static org.jclouds.vcloud.VCloudMediaType.VDC_XML;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
import java.util.SortedSet;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import javax.ws.rs.Consumes;
|
import javax.ws.rs.Consumes;
|
||||||
|
@ -57,7 +58,9 @@ import org.jclouds.vcloud.terremark.domain.TerremarkVApp;
|
||||||
import org.jclouds.vcloud.terremark.options.AddInternetServiceOptions;
|
import org.jclouds.vcloud.terremark.options.AddInternetServiceOptions;
|
||||||
import org.jclouds.vcloud.terremark.options.AddNodeOptions;
|
import org.jclouds.vcloud.terremark.options.AddNodeOptions;
|
||||||
import org.jclouds.vcloud.terremark.xml.InternetServiceHandler;
|
import org.jclouds.vcloud.terremark.xml.InternetServiceHandler;
|
||||||
|
import org.jclouds.vcloud.terremark.xml.InternetServicesHandler;
|
||||||
import org.jclouds.vcloud.terremark.xml.NodeHandler;
|
import org.jclouds.vcloud.terremark.xml.NodeHandler;
|
||||||
|
import org.jclouds.vcloud.terremark.xml.NodesHandler;
|
||||||
import org.jclouds.vcloud.terremark.xml.TerremarkVAppHandler;
|
import org.jclouds.vcloud.terremark.xml.TerremarkVAppHandler;
|
||||||
import org.jclouds.vcloud.terremark.xml.TerremarkVDCHandler;
|
import org.jclouds.vcloud.terremark.xml.TerremarkVDCHandler;
|
||||||
|
|
||||||
|
@ -98,6 +101,12 @@ public interface TerremarkVCloudAsyncClient extends VCloudAsyncClient {
|
||||||
@MapEntityParam("protocol") String protocol, @MapEntityParam("port") int port,
|
@MapEntityParam("protocol") String protocol, @MapEntityParam("port") int port,
|
||||||
AddInternetServiceOptions... options);
|
AddInternetServiceOptions... options);
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VDC.class)
|
||||||
|
@Path("/internetServices")
|
||||||
|
@XMLResponseParser(InternetServicesHandler.class)
|
||||||
|
Future<? extends SortedSet<InternetService>> getAllInternetServices();
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
@Path("/publicIps/{ipId}/InternetServices")
|
@Path("/publicIps/{ipId}/InternetServices")
|
||||||
|
@ -133,6 +142,13 @@ public interface TerremarkVCloudAsyncClient extends VCloudAsyncClient {
|
||||||
@MapEntityParam("name") String name, @MapEntityParam("port") int port,
|
@MapEntityParam("name") String name, @MapEntityParam("port") int port,
|
||||||
AddNodeOptions... options);
|
AddNodeOptions... options);
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
|
@Path("/internetServices/{internetServiceId}/nodes")
|
||||||
|
@XMLResponseParser(NodesHandler.class)
|
||||||
|
Future<? extends SortedSet<InternetService>> getNodes(
|
||||||
|
@PathParam("internetServiceId") String internetServiceId);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
@Path("/nodeServices/{nodeId}")
|
@Path("/nodeServices/{nodeId}")
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
package org.jclouds.vcloud.terremark;
|
package org.jclouds.vcloud.terremark;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
import java.util.SortedSet;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.jclouds.concurrent.Timeout;
|
import org.jclouds.concurrent.Timeout;
|
||||||
|
@ -69,4 +70,8 @@ public interface TerremarkVCloudClient extends VCloudClient {
|
||||||
@Override
|
@Override
|
||||||
TerremarkVApp getVApp(String vAppId);
|
TerremarkVApp getVApp(String vAppId);
|
||||||
|
|
||||||
|
SortedSet<InternetService> getAllInternetServices();
|
||||||
|
|
||||||
|
SortedSet<Node> getNodes(String internetServiceId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.terremark;
|
package org.jclouds.vcloud.terremark.compute;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
|
||||||
|
@ -29,16 +29,18 @@ import java.net.InetAddress;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.SortedSet;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.jclouds.compute.Image;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.ssh.ExecResponse;
|
|
||||||
import org.jclouds.ssh.SshClient;
|
|
||||||
import org.jclouds.ssh.SshClient.Factory;
|
|
||||||
import org.jclouds.vcloud.domain.Task;
|
import org.jclouds.vcloud.domain.Task;
|
||||||
import org.jclouds.vcloud.domain.VAppStatus;
|
import org.jclouds.vcloud.domain.VAppStatus;
|
||||||
|
import org.jclouds.vcloud.terremark.TerremarkVCloudClient;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.InternetService;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.Node;
|
||||||
import org.jclouds.vcloud.terremark.domain.TerremarkVApp;
|
import org.jclouds.vcloud.terremark.domain.TerremarkVApp;
|
||||||
import org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions;
|
import org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions;
|
||||||
|
|
||||||
|
@ -50,31 +52,22 @@ import com.google.common.collect.Iterables;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class VCloudComputeClient {
|
public class TerremarkVCloudComputeClient {
|
||||||
@Resource
|
@Resource
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
private final Predicate<InetSocketAddress> socketTester;
|
|
||||||
private final Predicate<URI> taskTester;
|
private final Predicate<URI> taskTester;
|
||||||
private final TerremarkVCloudClient tmClient;
|
private final TerremarkVCloudClient tmClient;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public VCloudComputeClient(TerremarkVCloudClient tmClient, Factory sshFactory,
|
public TerremarkVCloudComputeClient(TerremarkVCloudClient tmClient, Predicate<URI> successTester) {
|
||||||
Predicate<InetSocketAddress> socketTester, Predicate<URI> successTester) {
|
|
||||||
this.tmClient = tmClient;
|
this.tmClient = tmClient;
|
||||||
this.sshFactory = sshFactory;
|
|
||||||
this.socketTester = socketTester;
|
|
||||||
this.taskTester = successTester;
|
this.taskTester = successTester;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Factory sshFactory;
|
|
||||||
|
|
||||||
public enum Image {
|
|
||||||
CENTOS_53, RHEL_53, UMBUNTU_90, UMBUNTU_JEOS
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<Image, String> imageCatalogIdMap = ImmutableMap.<Image, String> builder().put(
|
private Map<Image, String> imageCatalogIdMap = ImmutableMap.<Image, String> builder().put(
|
||||||
Image.CENTOS_53, "6").put(Image.RHEL_53, "8").put(Image.UMBUNTU_90, "10").put(Image.UMBUNTU_JEOS, "11").build();
|
Image.CENTOS_53, "6").put(Image.RHEL_53, "8").put(Image.UMBUNTU_90, "10").put(
|
||||||
|
Image.UMBUNTU_JEOS, "11").build();
|
||||||
|
|
||||||
public String start(String name, int minCores, int minMegs, Image image) {
|
public String start(String name, int minCores, int minMegs, Image image) {
|
||||||
checkArgument(imageCatalogIdMap.containsKey(image), "image not configured: " + image);
|
checkArgument(imageCatalogIdMap.containsKey(image), "image not configured: " + image);
|
||||||
|
@ -83,7 +76,8 @@ public class VCloudComputeClient {
|
||||||
logger.debug(">> instantiating vApp name(%s) minCores(%d) minMegs(%d) template(%s)", name,
|
logger.debug(">> instantiating vApp name(%s) minCores(%d) minMegs(%d) template(%s)", name,
|
||||||
minCores, minMegs, templateId);
|
minCores, minMegs, templateId);
|
||||||
TerremarkVApp vApp = tmClient.instantiateVAppTemplate(name, templateId,
|
TerremarkVApp vApp = tmClient.instantiateVAppTemplate(name, templateId,
|
||||||
TerremarkInstantiateVAppTemplateOptions.Builder.cpuCount(minCores).megabytes(minMegs));
|
TerremarkInstantiateVAppTemplateOptions.Builder.cpuCount(minCores)
|
||||||
|
.megabytes(minMegs));
|
||||||
logger.debug("<< instantiated VApp(%s)", vApp.getId());
|
logger.debug("<< instantiated VApp(%s)", vApp.getId());
|
||||||
|
|
||||||
logger.debug(">> deploying vApp(%s)", vApp.getId());
|
logger.debug(">> deploying vApp(%s)", vApp.getId());
|
||||||
|
@ -109,16 +103,6 @@ public class VCloudComputeClient {
|
||||||
return Iterables.getLast(vApp.getNetworkToAddresses().values());
|
return Iterables.getLast(vApp.getNetworkToAddresses().values());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExecResponse exec(InetAddress address, String command) {
|
|
||||||
InetSocketAddress sshSocket = new InetSocketAddress(address, 22);
|
|
||||||
String username = "vcloud";
|
|
||||||
String password = "p4ssw0rd";
|
|
||||||
logger.debug(">> exec ssh://%s@%s/%s", username, sshSocket, command);
|
|
||||||
ExecResponse exec = exec(sshSocket, username, password, command);
|
|
||||||
logger.debug("<< output(%s) error(%s)", exec.getOutput(), exec.getError());
|
|
||||||
return exec;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reboot(String id) {
|
public void reboot(String id) {
|
||||||
TerremarkVApp vApp = tmClient.getVApp(id);
|
TerremarkVApp vApp = tmClient.getVApp(id);
|
||||||
logger.debug(">> rebooting vApp(%s)", vApp.getId());
|
logger.debug(">> rebooting vApp(%s)", vApp.getId());
|
||||||
|
@ -129,6 +113,24 @@ public class VCloudComputeClient {
|
||||||
|
|
||||||
public void stop(String id) {
|
public void stop(String id) {
|
||||||
TerremarkVApp vApp = tmClient.getVApp(id);
|
TerremarkVApp vApp = tmClient.getVApp(id);
|
||||||
|
|
||||||
|
SERVICE: for (InternetService service : tmClient.getAllInternetServices()) {
|
||||||
|
for (Node node : tmClient.getNodes(service.getId())) {
|
||||||
|
if (vApp.getNetworkToAddresses().containsValue(node.getIpAddress())) {
|
||||||
|
logger.debug(">> deleting Node(%s)", node.getId());
|
||||||
|
tmClient.deleteNode(node.getId());
|
||||||
|
logger.debug("<< deleted Node(%s)", node.getId());
|
||||||
|
SortedSet<Node> nodes = tmClient.getNodes(service.getId());
|
||||||
|
if (nodes.size() == 0) {
|
||||||
|
logger.debug(">> deleting InternetService(%s)", service.getId());
|
||||||
|
tmClient.deleteInternetService(service.getId());
|
||||||
|
logger.debug("<< deleted InternetService(%s)", service.getId());
|
||||||
|
continue SERVICE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (vApp.getStatus() != VAppStatus.OFF) {
|
if (vApp.getStatus() != VAppStatus.OFF) {
|
||||||
logger.debug(">> powering off vApp(%s)", vApp.getId());
|
logger.debug(">> powering off vApp(%s)", vApp.getId());
|
||||||
blockUntilVAppStatusOrThrowException(vApp, tmClient.powerOffVApp(vApp.getId()),
|
blockUntilVAppStatusOrThrowException(vApp, tmClient.powerOffVApp(vApp.getId()),
|
||||||
|
@ -140,23 +142,8 @@ public class VCloudComputeClient {
|
||||||
logger.debug("<< deleted vApp(%s)", vApp.getId());
|
logger.debug("<< deleted vApp(%s)", vApp.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private ExecResponse exec(InetSocketAddress socket, String username, String password,
|
private TerremarkVApp blockUntilVAppStatusOrThrowException(TerremarkVApp vApp, Task deployTask,
|
||||||
String command) {
|
String taskType, VAppStatus expectedStatus) {
|
||||||
if (!socketTester.apply(socket)) {
|
|
||||||
throw new SocketNotOpenException(socket);
|
|
||||||
}
|
|
||||||
SshClient connection = sshFactory.create(socket, username, password);
|
|
||||||
try {
|
|
||||||
connection.connect();
|
|
||||||
return connection.exec(command);
|
|
||||||
} finally {
|
|
||||||
if (connection != null)
|
|
||||||
connection.disconnect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private TerremarkVApp blockUntilVAppStatusOrThrowException(TerremarkVApp vApp, Task deployTask, String taskType,
|
|
||||||
VAppStatus expectedStatus) {
|
|
||||||
if (!taskTester.apply(deployTask.getLocation())) {
|
if (!taskTester.apply(deployTask.getLocation())) {
|
||||||
throw new TaskException(taskType, vApp, deployTask);
|
throw new TaskException(taskType, vApp, deployTask);
|
||||||
}
|
}
|
|
@ -0,0 +1,125 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you 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.vcloud.terremark.compute;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.util.SortedSet;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.compute.ComputeService;
|
||||||
|
import org.jclouds.compute.Image;
|
||||||
|
import org.jclouds.compute.Profile;
|
||||||
|
import org.jclouds.compute.Server;
|
||||||
|
import org.jclouds.compute.domain.CreateServerResponse;
|
||||||
|
import org.jclouds.compute.domain.LoginType;
|
||||||
|
import org.jclouds.compute.domain.internal.CreateServerResponseImpl;
|
||||||
|
import org.jclouds.domain.Credentials;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
import org.jclouds.rest.domain.NamedResource;
|
||||||
|
import org.jclouds.vcloud.VCloudMediaType;
|
||||||
|
import org.jclouds.vcloud.domain.VApp;
|
||||||
|
import org.jclouds.vcloud.terremark.TerremarkVCloudClient;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.InternetService;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
import com.google.inject.internal.ImmutableSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Singleton
|
||||||
|
public class TerremarkVCloudComputeService implements ComputeService {
|
||||||
|
@Resource
|
||||||
|
protected Logger logger = Logger.NULL;
|
||||||
|
private final TerremarkVCloudComputeClient computeClient;
|
||||||
|
private final TerremarkVCloudClient tmClient;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public TerremarkVCloudComputeService(TerremarkVCloudClient tmClient,
|
||||||
|
TerremarkVCloudComputeClient computeClient) {
|
||||||
|
this.tmClient = tmClient;
|
||||||
|
this.computeClient = computeClient;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CreateServerResponse createServer(String name, Profile profile, Image image) {
|
||||||
|
String id = computeClient.start(name, 1, 512, image);
|
||||||
|
VApp vApp = tmClient.getVApp(id);
|
||||||
|
Iterable<InetAddress> privateAddresses = vApp.getNetworkToAddresses().values();
|
||||||
|
|
||||||
|
InetAddress sshIp = null;
|
||||||
|
InternetService is;
|
||||||
|
for (int port : new int[] { 22, 80, 8080 }) {
|
||||||
|
is = tmClient.addInternetService(id + "-" + port, "TCP", port);
|
||||||
|
tmClient.addNode(is.getId(), Iterables.getLast(privateAddresses), id + "-" + port, port);
|
||||||
|
if (port == 22) {
|
||||||
|
is.getPublicIpAddress().getAddress();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new CreateServerResponseImpl(id, vApp.getName(), ImmutableSet.<InetAddress> of(sshIp),
|
||||||
|
privateAddresses, 22, LoginType.SSH, new Credentials("vcloud", "p4ssw0rd"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Server getServerById(String id) {
|
||||||
|
return new TerremarkVCloudServer(computeClient, tmClient.getVApp(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public SortedSet<InternetService> getInternetServicesByName(final String name) {
|
||||||
|
return Sets.newTreeSet(Iterables.filter(tmClient.getAllInternetServices(),
|
||||||
|
new Predicate<InternetService>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(InternetService input) {
|
||||||
|
return input.getName().equalsIgnoreCase(name);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SortedSet<Server> getServerByName(final String name) {
|
||||||
|
return Sets.newTreeSet(Iterables.filter(listServers(), new Predicate<Server>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(Server input) {
|
||||||
|
return input.getName().equalsIgnoreCase(name);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SortedSet<Server> listServers() {
|
||||||
|
SortedSet<Server> servers = Sets.newTreeSet();
|
||||||
|
for (NamedResource resource : tmClient.getDefaultVDC().getResourceEntities().values()) {
|
||||||
|
if (resource.getType().equals(VCloudMediaType.VAPP_XML)) {
|
||||||
|
servers.add(getServerById(resource.getId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return servers;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you 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.vcloud.terremark.compute;
|
||||||
|
|
||||||
|
import org.jclouds.compute.Server;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.TerremarkVApp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class TerremarkVCloudServer implements Server {
|
||||||
|
|
||||||
|
private final TerremarkVCloudComputeClient computeClient;
|
||||||
|
|
||||||
|
private final TerremarkVApp vApp;
|
||||||
|
|
||||||
|
public TerremarkVCloudServer(TerremarkVCloudComputeClient computeClient, TerremarkVApp vApp) {
|
||||||
|
this.vApp = vApp;
|
||||||
|
this.computeClient = computeClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return vApp.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean destroy() {
|
||||||
|
computeClient.stop(getId());
|
||||||
|
return Boolean.TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return vApp.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(Server o) {
|
||||||
|
return (this == o) ? 0 : getId().compareTo(o.getId());
|
||||||
|
}
|
||||||
|
}
|
|
@ -28,6 +28,7 @@ import java.net.URI;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.compute.ComputeService;
|
||||||
import org.jclouds.lifecycle.Closer;
|
import org.jclouds.lifecycle.Closer;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
import org.jclouds.rest.internal.RestContextImpl;
|
import org.jclouds.rest.internal.RestContextImpl;
|
||||||
|
@ -35,6 +36,7 @@ import org.jclouds.vcloud.endpoints.Org;
|
||||||
import org.jclouds.vcloud.reference.VCloudConstants;
|
import org.jclouds.vcloud.reference.VCloudConstants;
|
||||||
import org.jclouds.vcloud.terremark.TerremarkVCloudAsyncClient;
|
import org.jclouds.vcloud.terremark.TerremarkVCloudAsyncClient;
|
||||||
import org.jclouds.vcloud.terremark.TerremarkVCloudClient;
|
import org.jclouds.vcloud.terremark.TerremarkVCloudClient;
|
||||||
|
import org.jclouds.vcloud.terremark.compute.TerremarkVCloudComputeService;
|
||||||
|
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
@ -45,6 +47,7 @@ import com.google.inject.Provides;
|
||||||
public class TerremarkVCloudContextModule extends AbstractModule {
|
public class TerremarkVCloudContextModule extends AbstractModule {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
|
bind(ComputeService.class).to(TerremarkVCloudComputeService.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
|
|
@ -25,21 +25,30 @@ package org.jclouds.vcloud.terremark.config;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.concurrent.internal.SyncProxy;
|
import org.jclouds.concurrent.internal.SyncProxy;
|
||||||
import org.jclouds.http.RequiresHttp;
|
import org.jclouds.http.RequiresHttp;
|
||||||
|
import org.jclouds.predicates.AddressReachable;
|
||||||
|
import org.jclouds.predicates.RetryablePredicate;
|
||||||
|
import org.jclouds.predicates.SocketOpen;
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
import org.jclouds.rest.RestClientFactory;
|
import org.jclouds.rest.RestClientFactory;
|
||||||
import org.jclouds.util.Utils;
|
import org.jclouds.util.Utils;
|
||||||
import org.jclouds.vcloud.VCloudAsyncClient;
|
import org.jclouds.vcloud.VCloudAsyncClient;
|
||||||
import org.jclouds.vcloud.VCloudClient;
|
import org.jclouds.vcloud.VCloudClient;
|
||||||
import org.jclouds.vcloud.config.VCloudRestClientModule;
|
import org.jclouds.vcloud.config.VCloudRestClientModule;
|
||||||
|
import org.jclouds.vcloud.predicates.TaskSuccess;
|
||||||
import org.jclouds.vcloud.terremark.TerremarkVCloudAsyncClient;
|
import org.jclouds.vcloud.terremark.TerremarkVCloudAsyncClient;
|
||||||
import org.jclouds.vcloud.terremark.TerremarkVCloudClient;
|
import org.jclouds.vcloud.terremark.TerremarkVCloudClient;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,6 +59,26 @@ import com.google.inject.Provides;
|
||||||
@RequiresHttp
|
@RequiresHttp
|
||||||
@ConfiguresRestClient
|
@ConfiguresRestClient
|
||||||
public class TerremarkVCloudRestClientModule extends VCloudRestClientModule {
|
public class TerremarkVCloudRestClientModule extends VCloudRestClientModule {
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
protected Predicate<InetSocketAddress> socketTester(SocketOpen open) {
|
||||||
|
return new RetryablePredicate<InetSocketAddress>(open, 130, 10, TimeUnit.SECONDS);// make it
|
||||||
|
// longer
|
||||||
|
// then
|
||||||
|
// default internet
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
protected Predicate<InetAddress> addressTester(AddressReachable reachable) {
|
||||||
|
return new RetryablePredicate<InetAddress>(reachable, 60, 5, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
protected Predicate<URI> successTester(TaskSuccess success) {
|
||||||
|
return new RetryablePredicate<URI>(success, 300, 10, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
|
|
|
@ -0,0 +1,76 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you 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.vcloud.terremark.xml;
|
||||||
|
|
||||||
|
import java.util.SortedSet;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.ParseSax.HandlerWithResult;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.InternetService;
|
||||||
|
import org.xml.sax.Attributes;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class InternetServicesHandler extends HandlerWithResult<SortedSet<InternetService>> {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
protected Logger logger = Logger.NULL;
|
||||||
|
private final InternetServiceHandler handler;
|
||||||
|
SortedSet<InternetService> result = Sets.newTreeSet();
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public InternetServicesHandler(InternetServiceHandler handler) {
|
||||||
|
this.handler = handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SortedSet<InternetService> getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startElement(String uri, String localName, String qName, Attributes attributes)
|
||||||
|
throws SAXException {
|
||||||
|
handler.startElement(uri, localName, qName, attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void endElement(String uri, String name, String qName) {
|
||||||
|
handler.endElement(uri, name, qName);
|
||||||
|
if (qName.equals("InternetService")) {
|
||||||
|
result.add(handler.getResult());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void characters(char ch[], int start, int length) {
|
||||||
|
handler.characters(ch, start, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you 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.vcloud.terremark.xml;
|
||||||
|
|
||||||
|
import java.util.SortedSet;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.ParseSax.HandlerWithResult;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.Node;
|
||||||
|
import org.xml.sax.Attributes;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class NodesHandler extends HandlerWithResult<SortedSet<Node>> {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
protected Logger logger = Logger.NULL;
|
||||||
|
private final NodeHandler handler;
|
||||||
|
SortedSet<Node> result = Sets.newTreeSet();
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public NodesHandler(NodeHandler handler) {
|
||||||
|
this.handler = handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SortedSet<Node> getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startElement(String uri, String localName, String qName, Attributes attributes)
|
||||||
|
throws SAXException {
|
||||||
|
handler.startElement(uri, localName, qName, attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void endElement(String uri, String name, String qName) {
|
||||||
|
handler.endElement(uri, name, qName);
|
||||||
|
if (qName.equals("NodeService")) {
|
||||||
|
result.add(handler.getResult());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void characters(char ch[], int start, int length) {
|
||||||
|
handler.characters(ch, start, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -64,7 +64,9 @@ import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||||
import org.jclouds.vcloud.terremark.options.AddInternetServiceOptions;
|
import org.jclouds.vcloud.terremark.options.AddInternetServiceOptions;
|
||||||
import org.jclouds.vcloud.terremark.options.AddNodeOptions;
|
import org.jclouds.vcloud.terremark.options.AddNodeOptions;
|
||||||
import org.jclouds.vcloud.terremark.xml.InternetServiceHandler;
|
import org.jclouds.vcloud.terremark.xml.InternetServiceHandler;
|
||||||
|
import org.jclouds.vcloud.terremark.xml.InternetServicesHandler;
|
||||||
import org.jclouds.vcloud.terremark.xml.NodeHandler;
|
import org.jclouds.vcloud.terremark.xml.NodeHandler;
|
||||||
|
import org.jclouds.vcloud.terremark.xml.NodesHandler;
|
||||||
import org.jclouds.vcloud.terremark.xml.TerremarkVAppHandler;
|
import org.jclouds.vcloud.terremark.xml.TerremarkVAppHandler;
|
||||||
import org.jclouds.vcloud.terremark.xml.TerremarkVDCHandler;
|
import org.jclouds.vcloud.terremark.xml.TerremarkVDCHandler;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -81,400 +83,367 @@ import com.google.inject.util.Providers;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", sequential = true, testName = "vcloud.TerremarkVCloudAsyncClientTest")
|
@Test(groups = "unit", sequential = true, testName = "vcloud.TerremarkVCloudAsyncClientTest")
|
||||||
public class TerremarkVCloudAsyncClientTest extends
|
public class TerremarkVCloudAsyncClientTest extends RestClientTest<TerremarkVCloudAsyncClient> {
|
||||||
RestClientTest<TerremarkVCloudAsyncClient> {
|
|
||||||
|
|
||||||
public void testGetDefaultVDC() throws SecurityException,
|
public void testGetDefaultVDC() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
NoSuchMethodException, IOException {
|
Method method = TerremarkVCloudAsyncClient.class.getMethod("getDefaultVDC");
|
||||||
Method method = TerremarkVCloudAsyncClient.class
|
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method);
|
||||||
.getMethod("getDefaultVDC");
|
|
||||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor
|
|
||||||
.createRequest(method);
|
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "GET http://vdc HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "GET http://vdc HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
|
||||||
"Accept: application/vnd.vmware.vcloud.vdc+xml\n");
|
assertEntityEquals(httpMethod, null);
|
||||||
assertEntityEquals(httpMethod, null);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
assertSaxResponseParserClassEquals(method, TerremarkVDCHandler.class);
|
assertSaxResponseParserClassEquals(method, TerremarkVDCHandler.class);
|
||||||
assertExceptionParserClassEquals(method, null);
|
assertExceptionParserClassEquals(method, null);
|
||||||
|
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testInstantiateVAppTemplate() throws SecurityException,
|
public void testInstantiateVAppTemplate() throws SecurityException, NoSuchMethodException,
|
||||||
NoSuchMethodException, IOException {
|
IOException {
|
||||||
Method method = TerremarkVCloudAsyncClient.class.getMethod(
|
Method method = TerremarkVCloudAsyncClient.class.getMethod("instantiateVAppTemplate",
|
||||||
"instantiateVAppTemplate", String.class, String.class, Array
|
String.class, String.class, Array.newInstance(InstantiateVAppTemplateOptions.class,
|
||||||
.newInstance(InstantiateVAppTemplateOptions.class, 0)
|
0).getClass());
|
||||||
.getClass());
|
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor
|
"name", 3 + "");
|
||||||
.createRequest(method, "name", 3 + "");
|
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod,
|
assertRequestLineEquals(httpMethod, "POST http://vdc/action/instantiatevAppTemplate HTTP/1.1");
|
||||||
"POST http://vdc/action/instantiatevAppTemplate HTTP/1.1");
|
assertHeadersEqual(
|
||||||
assertHeadersEqual(
|
httpMethod,
|
||||||
httpMethod,
|
"Content-Length: 2270\nContent-Type: application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml\n");
|
||||||
"Content-Length: 2270\nContent-Type: application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml\n");
|
assertEntityEquals(httpMethod, IOUtils.toString(getClass().getResourceAsStream(
|
||||||
assertEntityEquals(httpMethod, IOUtils.toString(getClass()
|
"/terremark/InstantiateVAppTemplateParams-test.xml")));
|
||||||
.getResourceAsStream(
|
|
||||||
"/terremark/InstantiateVAppTemplateParams-test.xml")));
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
assertSaxResponseParserClassEquals(method, TerremarkVAppHandler.class);
|
assertSaxResponseParserClassEquals(method, TerremarkVAppHandler.class);
|
||||||
assertExceptionParserClassEquals(method, null);
|
assertExceptionParserClassEquals(method, null);
|
||||||
|
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testInstantiateVAppTemplateOptions() throws SecurityException,
|
public void testInstantiateVAppTemplateOptions() throws SecurityException,
|
||||||
NoSuchMethodException, IOException {
|
NoSuchMethodException, IOException {
|
||||||
Method method = TerremarkVCloudAsyncClient.class.getMethod(
|
Method method = TerremarkVCloudAsyncClient.class.getMethod("instantiateVAppTemplate",
|
||||||
"instantiateVAppTemplate", String.class, String.class, Array
|
String.class, String.class, Array.newInstance(InstantiateVAppTemplateOptions.class,
|
||||||
.newInstance(
|
0).getClass());
|
||||||
InstantiateVAppTemplateOptions.class,
|
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
0).getClass());
|
"name", 3 + "", cpuCount(4).megabytes(1024).inNetwork(URI.create("http://newnet")));
|
||||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor
|
|
||||||
.createRequest(method, "name", 3 + "", cpuCount(4).megabytes(
|
|
||||||
1024).inNetwork(URI.create("http://newnet")));
|
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod,
|
assertRequestLineEquals(httpMethod, "POST http://vdc/action/instantiatevAppTemplate HTTP/1.1");
|
||||||
"POST http://vdc/action/instantiatevAppTemplate HTTP/1.1");
|
assertHeadersEqual(
|
||||||
assertHeadersEqual(
|
httpMethod,
|
||||||
httpMethod,
|
"Content-Length: 2239\nContent-Type: application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml\n");
|
||||||
"Content-Length: 2239\nContent-Type: application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml\n");
|
assertEntityEquals(httpMethod, IOUtils.toString(getClass().getResourceAsStream(
|
||||||
assertEntityEquals(
|
"/terremark/InstantiateVAppTemplateParams-options-test.xml")));
|
||||||
httpMethod,
|
|
||||||
IOUtils
|
|
||||||
.toString(getClass()
|
|
||||||
.getResourceAsStream(
|
|
||||||
"/terremark/InstantiateVAppTemplateParams-options-test.xml")));
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
assertSaxResponseParserClassEquals(method, TerremarkVAppHandler.class);
|
assertSaxResponseParserClassEquals(method, TerremarkVAppHandler.class);
|
||||||
assertExceptionParserClassEquals(method, null);
|
assertExceptionParserClassEquals(method, null);
|
||||||
|
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAddInternetService() throws SecurityException,
|
public void testAddInternetService() throws SecurityException, NoSuchMethodException,
|
||||||
NoSuchMethodException, IOException {
|
IOException {
|
||||||
Method method = TerremarkVCloudAsyncClient.class.getMethod(
|
Method method = TerremarkVCloudAsyncClient.class.getMethod("addInternetService",
|
||||||
"addInternetService", String.class, String.class, int.class,
|
String.class, String.class, int.class, Array.newInstance(
|
||||||
Array.newInstance(AddInternetServiceOptions.class, 0)
|
AddInternetServiceOptions.class, 0).getClass());
|
||||||
.getClass());
|
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor
|
"name", "tcp", 22);
|
||||||
.createRequest(method, "name", "tcp", 22);
|
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod,
|
assertRequestLineEquals(httpMethod, "POST http://vdc/internetServices HTTP/1.1");
|
||||||
"POST http://vdc/internetServices HTTP/1.1");
|
assertHeadersEqual(httpMethod, "Content-Length: 303\nContent-Type: application/xml\n");
|
||||||
assertHeadersEqual(httpMethod,
|
assertEntityEquals(httpMethod, IOUtils.toString(getClass().getResourceAsStream(
|
||||||
"Content-Length: 303\nContent-Type: application/xml\n");
|
"/terremark/CreateInternetService-test2.xml")));
|
||||||
assertEntityEquals(httpMethod, IOUtils.toString(getClass()
|
|
||||||
.getResourceAsStream(
|
|
||||||
"/terremark/CreateInternetService-test2.xml")));
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
assertSaxResponseParserClassEquals(method, InternetServiceHandler.class);
|
assertSaxResponseParserClassEquals(method, InternetServiceHandler.class);
|
||||||
assertExceptionParserClassEquals(method, null);
|
assertExceptionParserClassEquals(method, null);
|
||||||
|
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAddInternetServiceOptions() throws SecurityException,
|
public void testAddInternetServiceOptions() throws SecurityException, NoSuchMethodException,
|
||||||
NoSuchMethodException, IOException {
|
IOException {
|
||||||
Method method = TerremarkVCloudAsyncClient.class.getMethod(
|
Method method = TerremarkVCloudAsyncClient.class.getMethod("addInternetService",
|
||||||
"addInternetService", String.class, String.class, int.class,
|
String.class, String.class, int.class, Array.newInstance(
|
||||||
Array.newInstance(AddInternetServiceOptions.class, 0)
|
AddInternetServiceOptions.class, 0).getClass());
|
||||||
.getClass());
|
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor
|
"name", "tcp", 22, disabled().withDescription("yahoo"));
|
||||||
.createRequest(method, "name", "tcp", 22, disabled()
|
|
||||||
.withDescription("yahoo"));
|
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod,
|
assertRequestLineEquals(httpMethod, "POST http://vdc/internetServices HTTP/1.1");
|
||||||
"POST http://vdc/internetServices HTTP/1.1");
|
assertHeadersEqual(httpMethod, "Content-Length: 341\nContent-Type: application/xml\n");
|
||||||
assertHeadersEqual(httpMethod,
|
assertEntityEquals(httpMethod, IOUtils.toString(getClass().getResourceAsStream(
|
||||||
"Content-Length: 341\nContent-Type: application/xml\n");
|
"/terremark/CreateInternetService-options-test.xml")));
|
||||||
assertEntityEquals(httpMethod, IOUtils.toString(getClass()
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
.getResourceAsStream(
|
assertSaxResponseParserClassEquals(method, InternetServiceHandler.class);
|
||||||
"/terremark/CreateInternetService-options-test.xml")));
|
assertExceptionParserClassEquals(method, null);
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, InternetServiceHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, null);
|
|
||||||
|
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetInternetService() throws SecurityException,
|
public void testGetAllInternetServices() throws SecurityException, NoSuchMethodException,
|
||||||
NoSuchMethodException, IOException {
|
IOException {
|
||||||
Method method = TerremarkVCloudAsyncClient.class.getMethod(
|
Method method = TerremarkVCloudAsyncClient.class.getMethod("getAllInternetServices");
|
||||||
"getInternetService", String.class);
|
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method);
|
||||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor
|
|
||||||
.createRequest(method, 12);
|
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod,
|
assertRequestLineEquals(httpMethod, "GET http://vdc/internetServices HTTP/1.1");
|
||||||
"GET http://vcloud/internetServices/12 HTTP/1.1");
|
assertHeadersEqual(httpMethod, "");
|
||||||
assertHeadersEqual(httpMethod, "");
|
assertEntityEquals(httpMethod, null);
|
||||||
assertEntityEquals(httpMethod, null);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
assertSaxResponseParserClassEquals(method, InternetServiceHandler.class);
|
assertSaxResponseParserClassEquals(method, InternetServicesHandler.class);
|
||||||
assertExceptionParserClassEquals(method, null);
|
assertExceptionParserClassEquals(method, null);
|
||||||
|
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDeleteInternetService() throws SecurityException,
|
public void testGetInternetService() throws SecurityException, NoSuchMethodException,
|
||||||
NoSuchMethodException, IOException {
|
IOException {
|
||||||
Method method = TerremarkVCloudAsyncClient.class.getMethod(
|
Method method = TerremarkVCloudAsyncClient.class
|
||||||
"deleteInternetService", String.class);
|
.getMethod("getInternetService", String.class);
|
||||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor
|
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
.createRequest(method, 12);
|
12);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod,
|
assertRequestLineEquals(httpMethod, "GET http://vcloud/internetServices/12 HTTP/1.1");
|
||||||
"DELETE http://vcloud/internetServices/12 HTTP/1.1");
|
assertHeadersEqual(httpMethod, "");
|
||||||
assertHeadersEqual(httpMethod, "");
|
assertEntityEquals(httpMethod, null);
|
||||||
assertEntityEquals(httpMethod, null);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod,
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
ReturnVoidIf2xx.class);
|
assertSaxResponseParserClassEquals(method, InternetServiceHandler.class);
|
||||||
assertSaxResponseParserClassEquals(method, null);
|
assertExceptionParserClassEquals(method, null);
|
||||||
assertExceptionParserClassEquals(method, null);
|
|
||||||
|
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAddInternetServiceToExistingIp() throws SecurityException,
|
public void testDeleteInternetService() throws SecurityException, NoSuchMethodException,
|
||||||
NoSuchMethodException, IOException {
|
IOException {
|
||||||
Method method = TerremarkVCloudAsyncClient.class.getMethod(
|
Method method = TerremarkVCloudAsyncClient.class.getMethod("deleteInternetService",
|
||||||
"addInternetServiceToExistingIp", String.class, String.class,
|
String.class);
|
||||||
String.class, int.class, Array.newInstance(
|
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
AddInternetServiceOptions.class, 0).getClass());
|
12);
|
||||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor
|
|
||||||
.createRequest(method, 12, "name", "tcp", 22);
|
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod,
|
assertRequestLineEquals(httpMethod, "DELETE http://vcloud/internetServices/12 HTTP/1.1");
|
||||||
"POST http://vcloud/publicIps/12/InternetServices HTTP/1.1");
|
assertHeadersEqual(httpMethod, "");
|
||||||
assertHeadersEqual(httpMethod,
|
assertEntityEquals(httpMethod, null);
|
||||||
"Content-Length: 303\nContent-Type: application/xml\n");
|
|
||||||
assertEntityEquals(httpMethod, IOUtils.toString(getClass()
|
|
||||||
.getResourceAsStream(
|
|
||||||
"/terremark/CreateInternetService-test2.xml")));
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ReturnVoidIf2xx.class);
|
||||||
assertSaxResponseParserClassEquals(method, InternetServiceHandler.class);
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
assertExceptionParserClassEquals(method, null);
|
assertExceptionParserClassEquals(method, null);
|
||||||
|
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAddInternetServiceToExistingIpOptions()
|
public void testAddInternetServiceToExistingIp() throws SecurityException,
|
||||||
throws SecurityException, NoSuchMethodException, IOException {
|
NoSuchMethodException, IOException {
|
||||||
Method method = TerremarkVCloudAsyncClient.class.getMethod(
|
Method method = TerremarkVCloudAsyncClient.class.getMethod("addInternetServiceToExistingIp",
|
||||||
"addInternetServiceToExistingIp", String.class, String.class,
|
String.class, String.class, String.class, int.class, Array.newInstance(
|
||||||
String.class, int.class, Array.newInstance(
|
AddInternetServiceOptions.class, 0).getClass());
|
||||||
AddInternetServiceOptions.class, 0).getClass());
|
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor
|
12, "name", "tcp", 22);
|
||||||
.createRequest(method, 12, "name", "tcp", 22, disabled()
|
|
||||||
.withDescription("yahoo"));
|
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod,
|
assertRequestLineEquals(httpMethod,
|
||||||
"POST http://vcloud/publicIps/12/InternetServices HTTP/1.1");
|
"POST http://vcloud/publicIps/12/InternetServices HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod,
|
assertHeadersEqual(httpMethod, "Content-Length: 303\nContent-Type: application/xml\n");
|
||||||
"Content-Length: 341\nContent-Type: application/xml\n");
|
assertEntityEquals(httpMethod, IOUtils.toString(getClass().getResourceAsStream(
|
||||||
assertEntityEquals(httpMethod, IOUtils.toString(getClass()
|
"/terremark/CreateInternetService-test2.xml")));
|
||||||
.getResourceAsStream(
|
|
||||||
"/terremark/CreateInternetService-options-test.xml")));
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, InternetServiceHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, null);
|
|
||||||
|
|
||||||
checkFilters(httpMethod);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
}
|
assertSaxResponseParserClassEquals(method, InternetServiceHandler.class);
|
||||||
|
assertExceptionParserClassEquals(method, null);
|
||||||
|
|
||||||
public void testAddNode() throws SecurityException, NoSuchMethodException,
|
checkFilters(httpMethod);
|
||||||
IOException {
|
}
|
||||||
Method method = TerremarkVCloudAsyncClient.class.getMethod("addNode",
|
|
||||||
String.class, InetAddress.class, String.class, int.class, Array
|
|
||||||
.newInstance(AddNodeOptions.class, 0).getClass());
|
|
||||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor
|
|
||||||
.createRequest(method, 12, InetAddress.getByName("10.2.2.2"),
|
|
||||||
"name", 22);
|
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod,
|
public void testAddInternetServiceToExistingIpOptions() throws SecurityException,
|
||||||
"POST http://vcloud/internetServices/12/nodes HTTP/1.1");
|
NoSuchMethodException, IOException {
|
||||||
assertHeadersEqual(httpMethod,
|
Method method = TerremarkVCloudAsyncClient.class.getMethod("addInternetServiceToExistingIp",
|
||||||
"Content-Length: 298\nContent-Type: application/xml\n");
|
String.class, String.class, String.class, int.class, Array.newInstance(
|
||||||
assertEntityEquals(httpMethod, IOUtils.toString(getClass()
|
AddInternetServiceOptions.class, 0).getClass());
|
||||||
.getResourceAsStream("/terremark/CreateNodeService-test2.xml")));
|
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
|
12, "name", "tcp", 22, disabled().withDescription("yahoo"));
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertRequestLineEquals(httpMethod,
|
||||||
assertSaxResponseParserClassEquals(method, NodeHandler.class);
|
"POST http://vcloud/publicIps/12/InternetServices HTTP/1.1");
|
||||||
assertExceptionParserClassEquals(method, null);
|
assertHeadersEqual(httpMethod, "Content-Length: 341\nContent-Type: application/xml\n");
|
||||||
|
assertEntityEquals(httpMethod, IOUtils.toString(getClass().getResourceAsStream(
|
||||||
|
"/terremark/CreateInternetService-options-test.xml")));
|
||||||
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, InternetServiceHandler.class);
|
||||||
|
assertExceptionParserClassEquals(method, null);
|
||||||
|
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAddNodeOptions() throws SecurityException,
|
public void testAddNode() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
NoSuchMethodException, IOException {
|
Method method = TerremarkVCloudAsyncClient.class.getMethod("addNode", String.class,
|
||||||
Method method = TerremarkVCloudAsyncClient.class.getMethod("addNode",
|
InetAddress.class, String.class, int.class, Array.newInstance(AddNodeOptions.class,
|
||||||
String.class, InetAddress.class, String.class, int.class, Array
|
0).getClass());
|
||||||
.newInstance(AddNodeOptions.class, 0).getClass());
|
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor
|
12, InetAddress.getByName("10.2.2.2"), "name", 22);
|
||||||
.createRequest(method, 12, InetAddress.getByName("10.2.2.2"),
|
|
||||||
"name", 22, AddNodeOptions.Builder.disabled()
|
|
||||||
.withDescription("yahoo"));
|
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod,
|
assertRequestLineEquals(httpMethod, "POST http://vcloud/internetServices/12/nodes HTTP/1.1");
|
||||||
"POST http://vcloud/internetServices/12/nodes HTTP/1.1");
|
assertHeadersEqual(httpMethod, "Content-Length: 298\nContent-Type: application/xml\n");
|
||||||
assertHeadersEqual(httpMethod,
|
assertEntityEquals(httpMethod, IOUtils.toString(getClass().getResourceAsStream(
|
||||||
"Content-Length: 336\nContent-Type: application/xml\n");
|
"/terremark/CreateNodeService-test2.xml")));
|
||||||
assertEntityEquals(httpMethod, IOUtils.toString(getClass()
|
|
||||||
.getResourceAsStream(
|
|
||||||
"/terremark/CreateNodeService-options-test.xml")));
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, NodeHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, null);
|
|
||||||
|
|
||||||
checkFilters(httpMethod);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
}
|
assertSaxResponseParserClassEquals(method, NodeHandler.class);
|
||||||
|
assertExceptionParserClassEquals(method, null);
|
||||||
|
|
||||||
public void testGetNode() throws SecurityException, NoSuchMethodException,
|
checkFilters(httpMethod);
|
||||||
IOException {
|
}
|
||||||
Method method = TerremarkVCloudAsyncClient.class.getMethod("getNode",
|
|
||||||
String.class);
|
|
||||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor
|
|
||||||
.createRequest(method, 12);
|
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod,
|
public void testAddNodeOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
"GET http://vcloud/nodeServices/12 HTTP/1.1");
|
Method method = TerremarkVCloudAsyncClient.class.getMethod("addNode", String.class,
|
||||||
assertHeadersEqual(httpMethod, "");
|
InetAddress.class, String.class, int.class, Array.newInstance(AddNodeOptions.class,
|
||||||
assertEntityEquals(httpMethod, null);
|
0).getClass());
|
||||||
|
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
|
12, InetAddress.getByName("10.2.2.2"), "name", 22, AddNodeOptions.Builder.disabled()
|
||||||
|
.withDescription("yahoo"));
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertRequestLineEquals(httpMethod, "POST http://vcloud/internetServices/12/nodes HTTP/1.1");
|
||||||
assertSaxResponseParserClassEquals(method, NodeHandler.class);
|
assertHeadersEqual(httpMethod, "Content-Length: 336\nContent-Type: application/xml\n");
|
||||||
assertExceptionParserClassEquals(method, null);
|
assertEntityEquals(httpMethod, IOUtils.toString(getClass().getResourceAsStream(
|
||||||
|
"/terremark/CreateNodeService-options-test.xml")));
|
||||||
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, NodeHandler.class);
|
||||||
|
assertExceptionParserClassEquals(method, null);
|
||||||
|
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDeleteNode() throws SecurityException,
|
public void testGetNode() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
NoSuchMethodException, IOException {
|
Method method = TerremarkVCloudAsyncClient.class.getMethod("getNode", String.class);
|
||||||
Method method = TerremarkVCloudAsyncClient.class.getMethod(
|
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
"deleteNode", String.class);
|
12);
|
||||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor
|
|
||||||
.createRequest(method, 12);
|
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod,
|
assertRequestLineEquals(httpMethod, "GET http://vcloud/nodeServices/12 HTTP/1.1");
|
||||||
"DELETE http://vcloud/nodeServices/12 HTTP/1.1");
|
assertHeadersEqual(httpMethod, "");
|
||||||
assertHeadersEqual(httpMethod, "");
|
assertEntityEquals(httpMethod, null);
|
||||||
assertEntityEquals(httpMethod, null);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod,
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
ReturnVoidIf2xx.class);
|
assertSaxResponseParserClassEquals(method, NodeHandler.class);
|
||||||
assertSaxResponseParserClassEquals(method, null);
|
assertExceptionParserClassEquals(method, null);
|
||||||
assertExceptionParserClassEquals(method, null);
|
|
||||||
|
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void testGetNodes() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
protected void checkFilters(
|
Method method = TerremarkVCloudAsyncClient.class.getMethod("getNodes", String.class);
|
||||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod) {
|
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
assertEquals(httpMethod.getFilters().size(), 1);
|
12);
|
||||||
assertEquals(httpMethod.getFilters().get(0).getClass(),
|
|
||||||
SetVCloudTokenCookie.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
assertRequestLineEquals(httpMethod, "GET http://vcloud/internetServices/12/nodes HTTP/1.1");
|
||||||
protected TypeLiteral<RestAnnotationProcessor<TerremarkVCloudAsyncClient>> createTypeLiteral() {
|
assertHeadersEqual(httpMethod, "");
|
||||||
return new TypeLiteral<RestAnnotationProcessor<TerremarkVCloudAsyncClient>>() {
|
assertEntityEquals(httpMethod, null);
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
protected Module createModule() {
|
assertSaxResponseParserClassEquals(method, NodesHandler.class);
|
||||||
return new AbstractModule() {
|
assertExceptionParserClassEquals(method, null);
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
bind(String.class).annotatedWith(
|
|
||||||
Jsr330.named(PROPERTY_TERREMARK_DEFAULTGROUP))
|
|
||||||
.toProvider(Providers.<String> of("group"));
|
|
||||||
bind(String.class).annotatedWith(
|
|
||||||
Jsr330.named(PROPERTY_TERREMARK_DEFAULTROW))
|
|
||||||
.toProvider(Providers.<String> of("row"));
|
|
||||||
bind(String.class).annotatedWith(
|
|
||||||
Jsr330.named(PROPERTY_TERREMARK_DEFAULTPASSWORD))
|
|
||||||
.toProvider(Providers.<String> of("password"));
|
|
||||||
bind(String.class).annotatedWith(
|
|
||||||
Jsr330.named(PROPERTY_VCLOUD_DEFAULTCPUCOUNT))
|
|
||||||
.toProvider(Providers.<String> of("1"));
|
|
||||||
bind(String.class).annotatedWith(
|
|
||||||
Jsr330.named(PROPERTY_VCLOUD_DEFAULTMEMORY))
|
|
||||||
.toProvider(Providers.<String> of("512"));
|
|
||||||
bind(String.class)
|
|
||||||
.annotatedWith(
|
|
||||||
Jsr330.named(PROPERTY_VCLOUD_DEFAULTNETWORK))
|
|
||||||
.toProvider(
|
|
||||||
Providers
|
|
||||||
.<String> of("https://vcloud.safesecureweb.com/network/1990"));
|
|
||||||
bind(URI.class).annotatedWith(Catalog.class).toInstance(
|
|
||||||
URI.create("http://catalog"));
|
|
||||||
bind(String.class).annotatedWith(CatalogItemRoot.class)
|
|
||||||
.toInstance("http://catalogItem");
|
|
||||||
bind(URI.class).annotatedWith(VCloudApi.class).toInstance(
|
|
||||||
URI.create("http://vcloud"));
|
|
||||||
bind(String.class).annotatedWith(VAppRoot.class).toInstance(
|
|
||||||
"http://vapp");
|
|
||||||
bind(URI.class).annotatedWith(VDC.class).toInstance(
|
|
||||||
URI.create("http://vdc"));
|
|
||||||
bind(URI.class).annotatedWith(Network.class).toInstance(
|
|
||||||
URI.create("http://network"));
|
|
||||||
bind(SetVCloudTokenCookie.class).toInstance(
|
|
||||||
new SetVCloudTokenCookie(new Provider<String>() {
|
|
||||||
|
|
||||||
public String get() {
|
checkFilters(httpMethod);
|
||||||
return "token";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}));
|
public void testDeleteNode() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = TerremarkVCloudAsyncClient.class.getMethod("deleteNode", String.class);
|
||||||
|
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
|
12);
|
||||||
|
|
||||||
bind(Logger.LoggerFactory.class).toInstance(
|
assertRequestLineEquals(httpMethod, "DELETE http://vcloud/nodeServices/12 HTTP/1.1");
|
||||||
new LoggerFactory() {
|
assertHeadersEqual(httpMethod, "");
|
||||||
public Logger getLogger(String category) {
|
assertEntityEquals(httpMethod, null);
|
||||||
return Logger.NULL;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
assertResponseParserClassEquals(method, httpMethod, ReturnVoidIf2xx.class);
|
||||||
@Singleton
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
@Provides
|
assertExceptionParserClassEquals(method, null);
|
||||||
@Named("InstantiateVAppTemplateParams")
|
|
||||||
String provideInstantiateVAppTemplateParams() throws IOException {
|
|
||||||
return Utils.toStringAndClose(getClass().getResourceAsStream(
|
|
||||||
"/terremark/InstantiateVAppTemplateParams.xml"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
checkFilters(httpMethod);
|
||||||
@Singleton
|
}
|
||||||
@Provides
|
|
||||||
@Named("CreateInternetService")
|
|
||||||
String provideCreateInternetService() throws IOException {
|
|
||||||
return Utils.toStringAndClose(getClass().getResourceAsStream(
|
|
||||||
"/terremark/CreateInternetService.xml"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@Override
|
||||||
@Singleton
|
protected void checkFilters(GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod) {
|
||||||
@Provides
|
assertEquals(httpMethod.getFilters().size(), 1);
|
||||||
@Named("CreateNodeService")
|
assertEquals(httpMethod.getFilters().get(0).getClass(), SetVCloudTokenCookie.class);
|
||||||
String provideCreateNodeService() throws IOException {
|
}
|
||||||
return Utils.toStringAndClose(getClass().getResourceAsStream(
|
|
||||||
"/terremark/CreateNodeService.xml"));
|
@Override
|
||||||
}
|
protected TypeLiteral<RestAnnotationProcessor<TerremarkVCloudAsyncClient>> createTypeLiteral() {
|
||||||
};
|
return new TypeLiteral<RestAnnotationProcessor<TerremarkVCloudAsyncClient>>() {
|
||||||
}
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Module createModule() {
|
||||||
|
return new AbstractModule() {
|
||||||
|
@Override
|
||||||
|
protected void configure() {
|
||||||
|
bind(String.class).annotatedWith(Jsr330.named(PROPERTY_TERREMARK_DEFAULTGROUP))
|
||||||
|
.toProvider(Providers.<String> of("group"));
|
||||||
|
bind(String.class).annotatedWith(Jsr330.named(PROPERTY_TERREMARK_DEFAULTROW))
|
||||||
|
.toProvider(Providers.<String> of("row"));
|
||||||
|
bind(String.class).annotatedWith(Jsr330.named(PROPERTY_TERREMARK_DEFAULTPASSWORD))
|
||||||
|
.toProvider(Providers.<String> of("password"));
|
||||||
|
bind(String.class).annotatedWith(Jsr330.named(PROPERTY_VCLOUD_DEFAULTCPUCOUNT))
|
||||||
|
.toProvider(Providers.<String> of("1"));
|
||||||
|
bind(String.class).annotatedWith(Jsr330.named(PROPERTY_VCLOUD_DEFAULTMEMORY))
|
||||||
|
.toProvider(Providers.<String> of("512"));
|
||||||
|
bind(String.class)
|
||||||
|
.annotatedWith(Jsr330.named(PROPERTY_VCLOUD_DEFAULTNETWORK))
|
||||||
|
.toProvider(
|
||||||
|
Providers
|
||||||
|
.<String> of("https://vcloud.safesecureweb.com/network/1990"));
|
||||||
|
bind(URI.class).annotatedWith(Catalog.class).toInstance(URI.create("http://catalog"));
|
||||||
|
bind(String.class).annotatedWith(CatalogItemRoot.class)
|
||||||
|
.toInstance("http://catalogItem");
|
||||||
|
bind(URI.class).annotatedWith(VCloudApi.class).toInstance(URI.create("http://vcloud"));
|
||||||
|
bind(String.class).annotatedWith(VAppRoot.class).toInstance("http://vapp");
|
||||||
|
bind(URI.class).annotatedWith(VDC.class).toInstance(URI.create("http://vdc"));
|
||||||
|
bind(URI.class).annotatedWith(Network.class).toInstance(URI.create("http://network"));
|
||||||
|
bind(SetVCloudTokenCookie.class).toInstance(
|
||||||
|
new SetVCloudTokenCookie(new Provider<String>() {
|
||||||
|
|
||||||
|
public String get() {
|
||||||
|
return "token";
|
||||||
|
}
|
||||||
|
|
||||||
|
}));
|
||||||
|
|
||||||
|
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
||||||
|
public Logger getLogger(String category) {
|
||||||
|
return Logger.NULL;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
@Singleton
|
||||||
|
@Provides
|
||||||
|
@Named("InstantiateVAppTemplateParams")
|
||||||
|
String provideInstantiateVAppTemplateParams() throws IOException {
|
||||||
|
return Utils.toStringAndClose(getClass().getResourceAsStream(
|
||||||
|
"/terremark/InstantiateVAppTemplateParams.xml"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
@Singleton
|
||||||
|
@Provides
|
||||||
|
@Named("CreateInternetService")
|
||||||
|
String provideCreateInternetService() throws IOException {
|
||||||
|
return Utils.toStringAndClose(getClass().getResourceAsStream(
|
||||||
|
"/terremark/CreateInternetService.xml"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
@Singleton
|
||||||
|
@Provides
|
||||||
|
@Named("CreateNodeService")
|
||||||
|
String provideCreateNodeService() throws IOException {
|
||||||
|
return Utils.toStringAndClose(getClass().getResourceAsStream(
|
||||||
|
"/terremark/CreateNodeService.xml"));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,13 @@ public class TerremarkVCloudClientLiveTest extends VCloudClientLiveTest {
|
||||||
|
|
||||||
public static final String PREFIX = System.getProperty("user.name") + "-terremark";
|
public static final String PREFIX = System.getProperty("user.name") + "-terremark";
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetAllInternetServices() throws Exception {
|
||||||
|
for (InternetService service : tmClient.getAllInternetServices()) {
|
||||||
|
System.out.println(tmClient.getNodes(service.getId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDefaultVDC() throws Exception {
|
public void testDefaultVDC() throws Exception {
|
||||||
super.testDefaultVDC();
|
super.testDefaultVDC();
|
||||||
|
|
|
@ -1,205 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
|
||||||
*
|
|
||||||
* ====================================================================
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
* or more contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
|
||||||
* to you 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.vcloud.terremark;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.InetAddress;
|
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
|
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
|
||||||
import org.jclouds.predicates.AddressReachable;
|
|
||||||
import org.jclouds.predicates.RetryablePredicate;
|
|
||||||
import org.jclouds.predicates.SocketOpen;
|
|
||||||
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
|
||||||
import org.jclouds.vcloud.domain.ResourceType;
|
|
||||||
import org.jclouds.vcloud.domain.VAppStatus;
|
|
||||||
import org.jclouds.vcloud.predicates.TaskSuccess;
|
|
||||||
import org.jclouds.vcloud.terremark.VCloudComputeClient.Image;
|
|
||||||
import org.jclouds.vcloud.terremark.domain.InternetService;
|
|
||||||
import org.jclouds.vcloud.terremark.domain.Node;
|
|
||||||
import org.jclouds.vcloud.terremark.domain.TerremarkVApp;
|
|
||||||
import org.testng.annotations.AfterTest;
|
|
||||||
import org.testng.annotations.BeforeGroups;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
|
||||||
import com.google.inject.AbstractModule;
|
|
||||||
import com.google.inject.Injector;
|
|
||||||
import com.google.inject.Key;
|
|
||||||
import com.google.inject.Provides;
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
import com.google.inject.internal.ImmutableMap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests behavior of {@code TerremarkVCloudClient}
|
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
@Test(groups = "live", sequential = true, testName = "vcloud.TerremarkVCloudClientLiveTest")
|
|
||||||
public class TerremarkVCloudComputeClientLiveTest {
|
|
||||||
VCloudComputeClient client;
|
|
||||||
TerremarkVCloudClient tmClient;
|
|
||||||
|
|
||||||
private String id;
|
|
||||||
private InetAddress privateAddress;
|
|
||||||
|
|
||||||
public static final String PREFIX = System.getProperty("user.name") + "-terremark";
|
|
||||||
|
|
||||||
private static class Expectation {
|
|
||||||
final long hardDisk;
|
|
||||||
final String os;
|
|
||||||
|
|
||||||
public Expectation(long hardDisk, String os) {
|
|
||||||
this.hardDisk = hardDisk;
|
|
||||||
this.os = os;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<Image, Expectation> expectationMap = ImmutableMap.<Image, Expectation> builder()
|
|
||||||
.put(Image.CENTOS_53,
|
|
||||||
new Expectation(4194304 / 4 * 10, "Red Hat Enterprise Linux 5 (64-bit)")).put(
|
|
||||||
Image.RHEL_53,
|
|
||||||
new Expectation(4194304 / 4 * 10, "Red Hat Enterprise Linux 5 (64-bit)")).put(
|
|
||||||
Image.UMBUNTU_90, new Expectation(4194304, "Ubuntu Linux (64-bit)")).put(
|
|
||||||
Image.UMBUNTU_JEOS, new Expectation(4194304, "Ubuntu Linux (32-bit)")).build();
|
|
||||||
|
|
||||||
private InternetService is;
|
|
||||||
private Node node;
|
|
||||||
private InetAddress publicIp;
|
|
||||||
private Predicate<InetAddress> addressTester;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPowerOn() throws InterruptedException, ExecutionException, TimeoutException,
|
|
||||||
IOException {
|
|
||||||
Image toTest = Image.CENTOS_53;
|
|
||||||
|
|
||||||
String serverName = getCompatibleServerName(toTest);
|
|
||||||
int processorCount = 1;
|
|
||||||
int memory = 512;
|
|
||||||
|
|
||||||
id = client.start(serverName, processorCount, memory, toTest);
|
|
||||||
Expectation expectation = expectationMap.get(toTest);
|
|
||||||
|
|
||||||
TerremarkVApp vApp = tmClient.getVApp(id);
|
|
||||||
verifyConfigurationOfVApp(vApp, serverName, expectation.os, processorCount, memory,
|
|
||||||
expectation.hardDisk);
|
|
||||||
assertEquals(vApp.getStatus(), VAppStatus.ON);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getCompatibleServerName(Image toTest) {
|
|
||||||
String serverName = toTest.toString().toLowerCase().replaceAll("_", "-").substring(0,
|
|
||||||
toTest.toString().length() <= 15 ? toTest.toString().length() : 14);
|
|
||||||
return serverName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testPowerOn")
|
|
||||||
public void testGetAnyPrivateAddress() {
|
|
||||||
privateAddress = client.getAnyPrivateAddress(id);
|
|
||||||
assert !addressTester.apply(privateAddress);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testGetAnyPrivateAddress")
|
|
||||||
public void testSshLoadBalanceIp() {
|
|
||||||
is = tmClient.addInternetService("SSH", "TCP", 22);
|
|
||||||
node = tmClient.addNode(is.getId(), privateAddress, id + "-SSH", 22);
|
|
||||||
publicIp = is.getPublicIpAddress().getAddress();
|
|
||||||
// assert addressTester.apply(publicIp);
|
|
||||||
client.exec(publicIp, "uname -a");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void verifyConfigurationOfVApp(TerremarkVApp vApp, String serverName, String expectedOs,
|
|
||||||
int processorCount, int memory, long hardDisk) {
|
|
||||||
assertEquals(vApp.getName(), serverName);
|
|
||||||
assertEquals(vApp.getOperatingSystemDescription(), expectedOs);
|
|
||||||
assertEquals(vApp.getResourceAllocationByType().get(ResourceType.PROCESSOR)
|
|
||||||
.getVirtualQuantity(), processorCount);
|
|
||||||
assertEquals(vApp.getResourceAllocationByType().get(ResourceType.SCSI_CONTROLLER)
|
|
||||||
.getVirtualQuantity(), 1);
|
|
||||||
assertEquals(
|
|
||||||
vApp.getResourceAllocationByType().get(ResourceType.MEMORY).getVirtualQuantity(),
|
|
||||||
memory);
|
|
||||||
assertEquals(vApp.getResourceAllocationByType().get(ResourceType.DISK_DRIVE)
|
|
||||||
.getVirtualQuantity(), hardDisk);
|
|
||||||
assertEquals(vApp.getSize().longValue(), vApp.getResourceAllocationByType().get(ResourceType.DISK_DRIVE)
|
|
||||||
.getVirtualQuantity());
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterTest
|
|
||||||
void cleanup() throws InterruptedException, ExecutionException, TimeoutException {
|
|
||||||
if (node != null)
|
|
||||||
tmClient.deleteNode(node.getId());
|
|
||||||
if (is != null)
|
|
||||||
tmClient.deleteInternetService(is.getId());
|
|
||||||
if (id != null)
|
|
||||||
client.stop(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeGroups(groups = { "live" })
|
|
||||||
public void setupClient() {
|
|
||||||
String account = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user");
|
|
||||||
String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key");
|
|
||||||
Injector injector = new TerremarkVCloudContextBuilder(new TerremarkVCloudPropertiesBuilder(
|
|
||||||
account, key).relaxSSLHostname().build()).withModules(new Log4JLoggingModule(),
|
|
||||||
new JschSshClientModule(), new AbstractModule() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Provides
|
|
||||||
private Predicate<InetSocketAddress> socketTester(SocketOpen open) {
|
|
||||||
return new RetryablePredicate<InetSocketAddress>(open, 130, 10,
|
|
||||||
TimeUnit.SECONDS);// make it longer then
|
|
||||||
// default internet
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Provides
|
|
||||||
private Predicate<InetAddress> addressTester(AddressReachable reachable) {
|
|
||||||
return new RetryablePredicate<InetAddress>(reachable, 60, 5, TimeUnit.SECONDS);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Provides
|
|
||||||
private Predicate<URI> successTester(TaskSuccess success) {
|
|
||||||
return new RetryablePredicate<URI>(success, 300, 10, TimeUnit.SECONDS);
|
|
||||||
}
|
|
||||||
|
|
||||||
}).buildInjector();
|
|
||||||
client = injector.getInstance(VCloudComputeClient.class);
|
|
||||||
tmClient = injector.getInstance(TerremarkVCloudClient.class);
|
|
||||||
addressTester = injector.getInstance(Key.get(new TypeLiteral<Predicate<InetAddress>>() {
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you 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.vcloud.terremark.xml;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
import java.util.SortedSet;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.BaseHandlerTest;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.InternetService;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.PublicIpAddress;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSortedSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code InternetServicesHandler}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit", testName = "vcloud.InternetServicesHandlerTest")
|
||||||
|
public class InternetServicesHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
|
public void test2() throws UnknownHostException {
|
||||||
|
InputStream is = getClass().getResourceAsStream("/terremark/InternetServices.xml");
|
||||||
|
|
||||||
|
SortedSet<InternetService> result = factory.create(
|
||||||
|
injector.getInstance(InternetServicesHandler.class)).parse(is);
|
||||||
|
assertEquals(
|
||||||
|
result,
|
||||||
|
ImmutableSortedSet
|
||||||
|
.of(new InternetService(
|
||||||
|
524 + "",
|
||||||
|
"IS_for_Jim2",
|
||||||
|
URI
|
||||||
|
.create("https://services.vcloudexpress.terremark.com/api/v0.8/InternetServices/524"),
|
||||||
|
new PublicIpAddress(
|
||||||
|
4208,
|
||||||
|
InetAddress.getByName("10.1.22.159"),
|
||||||
|
URI
|
||||||
|
.create("https://services.vcloudexpress.terremark.com/api/v0.8/PublicIps/4208")),
|
||||||
|
45, "HTTP", false, 1, "Some test service")));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you 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.vcloud.terremark.xml;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
import java.util.SortedSet;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.BaseHandlerTest;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.Node;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSortedSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code NodesHandler}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit", testName = "vcloud.NodesHandlerTest")
|
||||||
|
public class NodesHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
|
public void test1() throws UnknownHostException {
|
||||||
|
InputStream is = getClass().getResourceAsStream("/terremark/NodeServices.xml");
|
||||||
|
|
||||||
|
SortedSet<Node> result = factory.create(injector.getInstance(NodesHandler.class)).parse(is);
|
||||||
|
assertEquals(result, ImmutableSortedSet.of(new Node(242 + "", "Node for Jim", URI
|
||||||
|
.create("https://services.vcloudexpress.terremark.com/api/v0.8/NodeServices/242"),
|
||||||
|
InetAddress.getByName("172.16.20.3"), 80, false, "Some test node")));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,163 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
|
||||||
|
Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
|
||||||
|
====================================================================
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you 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.
|
||||||
|
====================================================================
|
||||||
|
|
||||||
|
-->
|
||||||
|
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
For more configuration infromation and examples see the Apache Log4j
|
||||||
|
website: http://logging.apache.org/log4j/
|
||||||
|
-->
|
||||||
|
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
|
||||||
|
debug="false">
|
||||||
|
|
||||||
|
<!-- A time/date based rolling appender -->
|
||||||
|
<appender name="WIREFILE" class="org.apache.log4j.DailyRollingFileAppender">
|
||||||
|
<param name="File" value="target/test-data/jclouds-wire.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="FILE" class="org.apache.log4j.DailyRollingFileAppender">
|
||||||
|
<param name="File" value="target/test-data/jclouds.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="VCLOUDFILE" class="org.apache.log4j.DailyRollingFileAppender">
|
||||||
|
<param name="File" value="target/test-data/jclouds-vcloud.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="ASYNC" class="org.apache.log4j.AsyncAppender">
|
||||||
|
<appender-ref ref="FILE" />
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="ASYNCWIRE" class="org.apache.log4j.AsyncAppender">
|
||||||
|
<appender-ref ref="WIREFILE" />
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="ASYNCVCLOUD" class="org.apache.log4j.AsyncAppender">
|
||||||
|
<appender-ref ref="VCLOUDFILE" />
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- ================ -->
|
||||||
|
<!-- Limit categories -->
|
||||||
|
<!-- ================ -->
|
||||||
|
|
||||||
|
<category name="org.jclouds">
|
||||||
|
<priority value="DEBUG" />
|
||||||
|
<appender-ref ref="ASYNC" />
|
||||||
|
</category>
|
||||||
|
|
||||||
|
<category name="jclouds.http.headers">
|
||||||
|
<priority value="DEBUG" />
|
||||||
|
<appender-ref ref="ASYNCWIRE" />
|
||||||
|
</category>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<category name="org.jclouds.vcloud.terremark.compute.TerremarkVCloudComputeClient">
|
||||||
|
<priority value="TRACE" />
|
||||||
|
<appender-ref ref="ASYNCVCLOUD" />
|
||||||
|
</category>
|
||||||
|
|
||||||
|
|
||||||
|
<category name="org.jclouds.predicates.SocketOpen">
|
||||||
|
<priority value="TRACE" />
|
||||||
|
<appender-ref ref="ASYNCWIRE" />
|
||||||
|
</category>
|
||||||
|
|
||||||
|
<category name="org.jclouds.vcloud.predicates.TaskSuccess">
|
||||||
|
<priority value="TRACE" />
|
||||||
|
<appender-ref ref="ASYNCWIRE" />
|
||||||
|
</category>
|
||||||
|
|
||||||
|
|
||||||
|
<category name="jclouds.http.wire">
|
||||||
|
<priority value="DEBUG" />
|
||||||
|
<appender-ref ref="ASYNCWIRE" />
|
||||||
|
</category>
|
||||||
|
|
||||||
|
<!-- ======================= -->
|
||||||
|
<!-- Setup the Root category -->
|
||||||
|
<!-- ======================= -->
|
||||||
|
|
||||||
|
<root>
|
||||||
|
<priority value="WARN" />
|
||||||
|
</root>
|
||||||
|
|
||||||
|
</log4j:configuration>
|
|
@ -0,0 +1,20 @@
|
||||||
|
<InternetServices xmlns="urn:tmrk:vCloudExpress-1.0"
|
||||||
|
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<InternetService>
|
||||||
|
<Id>524</Id>
|
||||||
|
<Href>https://services.vcloudexpress.terremark.com/api/v0.8/InternetServices/524
|
||||||
|
</Href>
|
||||||
|
<Name>IS_for_Jim2</Name>
|
||||||
|
<PublicIpAddress>
|
||||||
|
<Id>4208</Id>
|
||||||
|
<Href>https://services.vcloudexpress.terremark.com/api/v0.8/PublicIps/4208
|
||||||
|
</Href>
|
||||||
|
<Name>10.1.22.159</Name>
|
||||||
|
</PublicIpAddress>
|
||||||
|
<Port>45</Port>
|
||||||
|
<Protocol>HTTP</Protocol>
|
||||||
|
<Enabled>false</Enabled>
|
||||||
|
<Timeout>1</Timeout>
|
||||||
|
<Description>Some test service</Description>
|
||||||
|
</InternetService>
|
||||||
|
</InternetServices>
|
|
@ -0,0 +1,13 @@
|
||||||
|
<NodeServices xmlns="urn:tmrk:vCloudExpress-1.0"
|
||||||
|
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<NodeService>
|
||||||
|
<Id>242</Id>
|
||||||
|
<Href>https://services.vcloudexpress.terremark.com/api/v0.8/NodeServices/242
|
||||||
|
</Href>
|
||||||
|
<Name>Node for Jim</Name>
|
||||||
|
<IpAddress>172.16.20.3</IpAddress>
|
||||||
|
<Port>80</Port>
|
||||||
|
<Enabled>false</Enabled>
|
||||||
|
<Description>Some test node</Description>
|
||||||
|
</NodeService>
|
||||||
|
</NodeServices>
|
Loading…
Reference in New Issue