Merge branches 'master' and 'jclouds-vbox-nat-host-only-working-cluster-and-live-test' into jclouds-vbox-nat-host-only-working-cluster-and-live-test

This commit is contained in:
David Ribeiro Alves 2012-03-12 11:00:15 +00:00
commit 52514a77a5
162 changed files with 3561 additions and 1067 deletions

View File

@ -123,7 +123,7 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
try { try {
return Iterables.find(hardwares.get(), new FindHardwareForServer(from)); return Iterables.find(hardwares.get(), new FindHardwareForServer(from));
} catch (NoSuchElementException e) { } catch (NoSuchElementException e) {
logger.warn("could not find a matching hardware for server %s", from); logger.debug("could not find a matching hardware for server %s", from);
} }
return null; return null;
} }
@ -132,7 +132,7 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
try { try {
return Iterables.find(images.get(), new FindImageForServer(from)).getOperatingSystem(); return Iterables.find(images.get(), new FindImageForServer(from)).getOperatingSystem();
} catch (NoSuchElementException e) { } catch (NoSuchElementException e) {
logger.warn("could not find a matching image for server %s in location %s", from, location.get()); logger.debug("could not find a matching image for server %s in location %s", from, location.get());
} }
return null; return null;
} }

View File

@ -98,7 +98,7 @@ public class InstanceToNodeMetadata implements Function<Instance, NodeMetadata>
try { try {
return Iterables.find(hardwares.get(), new FindHardwareForInstance(from)); return Iterables.find(hardwares.get(), new FindHardwareForInstance(from));
} catch (NoSuchElementException e) { } catch (NoSuchElementException e) {
logger.warn("could not find a matching hardware for instance %s", from); logger.debug("could not find a matching hardware for instance %s", from);
} }
return null; return null;
} }
@ -107,7 +107,7 @@ public class InstanceToNodeMetadata implements Function<Instance, NodeMetadata>
try { try {
return Iterables.find(images.get(), new FindImageForInstance(from)).getOperatingSystem(); return Iterables.find(images.get(), new FindImageForInstance(from)).getOperatingSystem();
} catch (NoSuchElementException e) { } catch (NoSuchElementException e) {
logger.warn("could not find a matching image for instance %s", from); logger.debug("could not find a matching image for instance %s", from);
} }
return null; return null;
} }
@ -129,7 +129,7 @@ public class InstanceToNodeMetadata implements Function<Instance, NodeMetadata>
try { try {
return Iterables.find(locations.get(), new FindLocationForInstance(from)); return Iterables.find(locations.get(), new FindLocationForInstance(from));
} catch (NoSuchElementException e) { } catch (NoSuchElementException e) {
logger.warn("could not find a matching realm for instance %s", from); logger.debug("could not find a matching realm for instance %s", from);
} }
return null; return null;
} }

View File

@ -126,7 +126,7 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
try { try {
return Iterables.find(hardwares.get(), new FindHardwareForServer(from)); return Iterables.find(hardwares.get(), new FindHardwareForServer(from));
} catch (NoSuchElementException e) { } catch (NoSuchElementException e) {
logger.warn("could not find a matching hardware for server %s", from); logger.debug("could not find a matching hardware for server %s", from);
} }
return null; return null;
} }
@ -135,7 +135,7 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
try { try {
return Iterables.find(images.get(), new FindImageForServer(from)); return Iterables.find(images.get(), new FindImageForServer(from));
} catch (NoSuchElementException e) { } catch (NoSuchElementException e) {
logger.warn("could not find a matching image for server %s in location %s", from, location.get()); logger.debug("could not find a matching image for server %s in location %s", from, location.get());
} }
return null; return null;
} }

View File

@ -39,7 +39,7 @@ public interface SshClient {
*/ */
@Deprecated @Deprecated
SshClient create(IPSocket socket, Credentials credentials); SshClient create(IPSocket socket, Credentials credentials);
SshClient create(IPSocket socket, LoginCredentials credentials); SshClient create(IPSocket socket, LoginCredentials credentials);
} }
@ -51,19 +51,23 @@ public interface SshClient {
void put(String path, Payload contents); void put(String path, Payload contents);
Payload get(String path); Payload get(String path);
/** /**
* Execute a process and block until it is complete * Execute a process and block until it is complete
* *
* @param command command line to invoke * @param command
* command line to invoke
* @return output of the command * @return output of the command
*/ */
ExecResponse exec(String command); ExecResponse exec(String command);
/** /**
* Execute a process and allow the user to interact with it * Execute a process and allow the user to interact with it. Note that this will allow the
* session to exist indefinitely, and its connection is not closed when {@link #disconnect()} is
* called.
* *
* @param command command line to invoke * @param command
* command line to invoke
* @return reference to the running process * @return reference to the running process
* @since 1.5.0 * @since 1.5.0
*/ */

View File

@ -34,7 +34,6 @@ import java.io.Closeable;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.ConnectException; import java.net.ConnectException;
import java.util.Arrays;
import javax.annotation.PreDestroy; import javax.annotation.PreDestroy;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -44,6 +43,7 @@ import org.apache.commons.io.input.ProxyInputStream;
import org.apache.commons.io.output.ByteArrayOutputStream; import org.apache.commons.io.output.ByteArrayOutputStream;
import org.jclouds.compute.domain.ExecChannel; import org.jclouds.compute.domain.ExecChannel;
import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.http.handlers.BackoffLimitedRetryHandler; import org.jclouds.http.handlers.BackoffLimitedRetryHandler;
import org.jclouds.io.Payload; import org.jclouds.io.Payload;
import org.jclouds.io.Payloads; import org.jclouds.io.Payloads;
@ -52,7 +52,6 @@ import org.jclouds.net.IPSocket;
import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.AuthorizationException;
import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshClient;
import org.jclouds.ssh.SshException; import org.jclouds.ssh.SshException;
import org.jclouds.util.CredentialUtils;
import org.jclouds.util.Strings2; import org.jclouds.util.Strings2;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
@ -61,10 +60,10 @@ import com.google.common.base.Predicates;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.io.Closeables; import com.google.common.io.Closeables;
import com.google.common.net.HostAndPort;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.jcraft.jsch.ChannelExec; import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.ChannelSftp; import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException; import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session; import com.jcraft.jsch.Session;
@ -91,11 +90,7 @@ public class JschSshClient implements SshClient {
sftp.disconnect(); sftp.disconnect();
} }
} }
private final String host;
private final int port;
private final String username;
private final String password;
private final String toString; private final String toString;
@Inject(optional = true) @Inject(optional = true)
@ -121,31 +116,31 @@ public class JschSshClient implements SshClient {
@Named("jclouds.ssh") @Named("jclouds.ssh")
protected Logger logger = Logger.NULL; protected Logger logger = Logger.NULL;
private Session session;
private final byte[] privateKey;
final byte[] emptyPassPhrase = new byte[0];
private final int timeout;
private final BackoffLimitedRetryHandler backoffLimitedRetryHandler; private final BackoffLimitedRetryHandler backoffLimitedRetryHandler;
public JschSshClient(BackoffLimitedRetryHandler backoffLimitedRetryHandler, IPSocket socket, int timeout, final SessionConnection sessionConnection;
String username, String password, byte[] privateKey) { final String user;
final String host;
public JschSshClient(BackoffLimitedRetryHandler backoffLimitedRetryHandler, IPSocket socket,
LoginCredentials loginCredentials, int timeout) {
this.user = checkNotNull(loginCredentials, "loginCredentials").getUser();
this.host = checkNotNull(socket, "socket").getAddress(); this.host = checkNotNull(socket, "socket").getAddress();
checkArgument(socket.getPort() > 0, "ssh port must be greater then zero" + socket.getPort()); checkArgument(socket.getPort() > 0, "ssh port must be greater then zero" + socket.getPort());
checkArgument(password != null || privateKey != null, "you must specify a password or a key"); checkArgument(loginCredentials.getPassword() != null || loginCredentials.getPrivateKey() != null,
this.port = socket.getPort(); "you must specify a password or a key");
this.username = checkNotNull(username, "username");
this.backoffLimitedRetryHandler = checkNotNull(backoffLimitedRetryHandler, "backoffLimitedRetryHandler"); this.backoffLimitedRetryHandler = checkNotNull(backoffLimitedRetryHandler, "backoffLimitedRetryHandler");
this.timeout = timeout; if (loginCredentials.getPrivateKey() == null) {
this.password = password; this.toString = String.format("%s:pw[%s]@%s:%d", loginCredentials.getUser(), hex(md5(loginCredentials
this.privateKey = privateKey; .getPassword().getBytes())), host, socket.getPort());
if (privateKey == null) {
this.toString = String.format("%s:pw[%s]@%s:%d", username, hex(md5(password.getBytes())), host, port);
} else { } else {
String fingerPrint = fingerprintPrivateKey(new String(privateKey)); String fingerPrint = fingerprintPrivateKey(loginCredentials.getPrivateKey());
String sha1 = sha1PrivateKey(new String(privateKey)); String sha1 = sha1PrivateKey(loginCredentials.getPrivateKey());
this.toString = String.format("%s:rsa[fingerprint(%s),sha1(%s)]@%s:%d", username, fingerPrint, sha1, host, this.toString = String.format("%s:rsa[fingerprint(%s),sha1(%s)]@%s:%d", loginCredentials.getUser(),
port); fingerPrint, sha1, host, socket.getPort());
} }
sessionConnection = SessionConnection.builder().hostAndPort(HostAndPort.fromParts(host, socket.getPort())).loginCredentials(
loginCredentials).connectTimeout(timeout).sessionTimeout(timeout).build();
} }
@Override @Override
@ -154,7 +149,8 @@ public class JschSshClient implements SshClient {
} }
private void checkConnected() { private void checkConnected() {
checkState(session != null && session.isConnected(), String.format("(%s) Session not connected!", toString())); checkState(sessionConnection.getSession() != null && sessionConnection.getSession().isConnected(), String.format(
"(%s) Session not connected!", toString()));
} }
public static interface Connection<T> { public static interface Connection<T> {
@ -163,45 +159,6 @@ public class JschSshClient implements SshClient {
T create() throws Exception; T create() throws Exception;
} }
Connection<Session> sessionConnection = new Connection<Session>() {
@Override
public void clear() {
if (session != null && session.isConnected()) {
session.disconnect();
session = null;
}
}
@Override
public Session create() throws Exception {
JSch jsch = new JSch();
session = jsch.getSession(username, host, port);
if (timeout != 0)
session.setTimeout(timeout);
if (password != null) {
session.setPassword(password);
} else {
// jsch wipes out your private key
if (CredentialUtils.isPrivateKeyEncrypted(privateKey)) {
throw new IllegalArgumentException(
"JschSshClientModule does not support private keys that require a passphrase");
}
jsch.addIdentity(username, Arrays.copyOf(privateKey, privateKey.length), null, emptyPassPhrase);
}
java.util.Properties config = new java.util.Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.connect(timeout);
return session;
}
@Override
public String toString() {
return String.format("Session(timeout=%d)", timeout);
}
};
protected <T, C extends Connection<T>> T acquire(C connection) { protected <T, C extends Connection<T>> T acquire(C connection) {
connection.clear(); connection.clear();
String errorMessage = String.format("(%s) error acquiring %s", toString(), connection); String errorMessage = String.format("(%s) error acquiring %s", toString(), connection);
@ -245,7 +202,7 @@ public class JschSshClient implements SshClient {
public ChannelSftp create() throws JSchException { public ChannelSftp create() throws JSchException {
checkConnected(); checkConnected();
String channel = "sftp"; String channel = "sftp";
sftp = (ChannelSftp) session.openChannel(channel); sftp = (ChannelSftp) sessionConnection.getSession().openChannel(channel);
sftp.connect(); sftp.connect();
return sftp; return sftp;
} }
@ -394,7 +351,7 @@ public class JschSshClient implements SshClient {
public ChannelExec create() throws Exception { public ChannelExec create() throws Exception {
checkConnected(); checkConnected();
String channel = "exec"; String channel = "exec";
executor = (ChannelExec) session.openChannel(channel); executor = (ChannelExec) sessionConnection.getSession().openChannel(channel);
executor.setPty(true); executor.setPty(true);
executor.setCommand(command); executor.setCommand(command);
ByteArrayOutputStream error = new ByteArrayOutputStream(); ByteArrayOutputStream error = new ByteArrayOutputStream();
@ -468,13 +425,13 @@ public class JschSshClient implements SshClient {
@Override @Override
public String getUsername() { public String getUsername() {
return this.username; return this.user;
} }
class ExecChannelConnection implements Connection<ExecChannel> { class ExecChannelConnection implements Connection<ExecChannel> {
private final String command; private final String command;
private ChannelExec executor = null; private ChannelExec executor = null;
private Session sessionConnection;
ExecChannelConnection(String command) { ExecChannelConnection(String command) {
this.command = checkNotNull(command, "command"); this.command = checkNotNull(command, "command");
@ -484,14 +441,16 @@ public class JschSshClient implements SshClient {
public void clear() { public void clear() {
if (executor != null) if (executor != null)
executor.disconnect(); executor.disconnect();
if (sessionConnection != null)
sessionConnection.disconnect();
} }
@Override @Override
public ExecChannel create() throws Exception { public ExecChannel create() throws Exception {
checkConnected(); this.sessionConnection = acquire(SessionConnection.builder().fromSessionConnection(
JschSshClient.this.sessionConnection).sessionTimeout(0).build());
String channel = "exec"; String channel = "exec";
executor = (ChannelExec) session.openChannel(channel); executor = (ChannelExec) sessionConnection.openChannel(channel);
executor.setPty(true);
executor.setCommand(command); executor.setCommand(command);
ByteArrayOutputStream error = new ByteArrayOutputStream(); ByteArrayOutputStream error = new ByteArrayOutputStream();
executor.setErrStream(error); executor.setErrStream(error);
@ -521,7 +480,6 @@ public class JschSshClient implements SshClient {
} }
}; };
@Override @Override
public ExecChannel execChannel(String command) { public ExecChannel execChannel(String command) {
return acquire(new ExecChannelConnection(command)); return acquire(new ExecChannelConnection(command));

View File

@ -0,0 +1,201 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.ssh.jsch;
import static com.google.common.base.Objects.equal;
import java.util.Arrays;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.ssh.jsch.JschSshClient.Connection;
import org.jclouds.util.CredentialUtils;
import com.google.common.base.Objects;
import com.google.common.net.HostAndPort;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;
public class SessionConnection implements Connection<Session> {
public static Builder builder() {
return new Builder();
}
public static class Builder {
protected HostAndPort hostAndPort;
protected LoginCredentials loginCredentials;
protected int connectTimeout;
protected int sessionTimeout;
/**
* @see SessionConnection#getHostAndPort()
*/
public Builder hostAndPort(HostAndPort hostAndPort) {
this.hostAndPort = hostAndPort;
return this;
}
/**
* @see SessionConnection#getLoginCredentials()
*/
public Builder loginCredentials(LoginCredentials loginCredentials) {
this.loginCredentials = loginCredentials;
return this;
}
/**
* @see SessionConnection#getConnectTimeout()
*/
public Builder connectTimeout(int connectTimeout) {
this.connectTimeout = connectTimeout;
return this;
}
/**
* @see SessionConnection#getConnectTimeout()
*/
public Builder sessionTimeout(int sessionTimeout) {
this.sessionTimeout = sessionTimeout;
return this;
}
public SessionConnection build() {
return new SessionConnection(hostAndPort, loginCredentials, connectTimeout, sessionTimeout);
}
protected Builder fromSessionConnection(SessionConnection in) {
return hostAndPort(in.getHostAndPort()).connectTimeout(in.getConnectTimeout()).loginCredentials(
in.getLoginCredentials());
}
}
private SessionConnection(HostAndPort hostAndPort, LoginCredentials loginCredentials, int connectTimeout,
int sessionTimeout) {
this.hostAndPort = hostAndPort;
this.loginCredentials = loginCredentials;
this.connectTimeout = connectTimeout;
this.sessionTimeout = sessionTimeout;
}
private static final byte[] emptyPassPhrase = new byte[0];
private final HostAndPort hostAndPort;
private final LoginCredentials loginCredentials;
private final int connectTimeout;
private final int sessionTimeout;
private transient Session session;
@Override
public void clear() {
if (session != null && session.isConnected()) {
session.disconnect();
session = null;
}
}
@Override
public Session create() throws Exception {
JSch jsch = new JSch();
session = jsch
.getSession(loginCredentials.getUser(), hostAndPort.getHostText(), hostAndPort.getPortOrDefault(22));
if (sessionTimeout != 0)
session.setTimeout(sessionTimeout);
if (loginCredentials.getPrivateKey() == null) {
session.setPassword(loginCredentials.getPassword());
} else {
byte[] privateKey = loginCredentials.getPrivateKey().getBytes();
if (CredentialUtils.isPrivateKeyEncrypted(privateKey)) {
throw new IllegalArgumentException(
"JschSshClientModule does not support private keys that require a passphrase");
}
jsch.addIdentity(loginCredentials.getUser(), Arrays.copyOf(privateKey, privateKey.length), null,
emptyPassPhrase);
}
java.util.Properties config = new java.util.Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.connect(connectTimeout);
return session;
}
/**
* @return host and port, where port if not present defaults to {@code 22}
*/
public HostAndPort getHostAndPort() {
return hostAndPort;
}
/**
*
* @return login used in this session
*/
public LoginCredentials getLoginCredentials() {
return loginCredentials;
}
/**
*
* @return how long to wait for the initial connection to be made
*/
public int getConnectTimeout() {
return connectTimeout;
}
/**
*
* @return how long to keep the session open, or {@code 0} for indefinitely
*/
public int getSessionTimeout() {
return sessionTimeout;
}
/**
*
* @return the current session or {@code null} if not connected
*/
public Session getSession() {
return session;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
SessionConnection that = SessionConnection.class.cast(o);
return equal(this.hostAndPort, that.hostAndPort) && equal(this.loginCredentials, that.loginCredentials)
&& equal(this.session, that.session);
}
@Override
public int hashCode() {
return Objects.hashCode(hostAndPort, loginCredentials, session);
}
@Override
public String toString() {
return Objects.toStringHelper("").add("hostAndPort", hostAndPort).add("loginUser", loginCredentials.getUser())
.add("session", session != null ? session.hashCode() : null).add("connectTimeout", connectTimeout).add(
"sessionTimeout", sessionTimeout).toString();
}
}

View File

@ -65,9 +65,7 @@ public class JschSshClientModule extends AbstractModule {
@Override @Override
public SshClient create(IPSocket socket, LoginCredentials credentials) { public SshClient create(IPSocket socket, LoginCredentials credentials) {
SshClient client = new JschSshClient(backoffLimitedRetryHandler, socket, timeout, credentials.getUser(), SshClient client = new JschSshClient(backoffLimitedRetryHandler, socket, credentials, timeout);
(credentials.getPrivateKey() == null) ? credentials.getPassword() : null,
credentials.getPrivateKey() != null ? credentials.getPrivateKey().getBytes() : null);
injector.injectMembers(client);// add logger injector.injectMembers(client);// add logger
return client; return client;
} }

View File

@ -170,8 +170,10 @@ public class JschSshClientLiveTest {
: sshHost); : sshHost);
} }
public void testExecChannelTakesStdinAndEchosBack() throws IOException { public void testExecChannelTakesStdinAndNoEchoOfCharsInOuputAndOutlivesClient() throws IOException {
ExecChannel response = setupClient().execChannel("cat <<EOF"); SshClient client = setupClient();
ExecChannel response = client.execChannel("cat <<EOF");
client.disconnect();
assertEquals(response.getExitStatus().get(), null); assertEquals(response.getExitStatus().get(), null);
try { try {
PrintStream printStream = new PrintStream(response.getInput()); PrintStream printStream = new PrintStream(response.getInput());
@ -179,12 +181,10 @@ public class JschSshClientLiveTest {
printStream.append("EOF\n"); printStream.append("EOF\n");
printStream.close(); printStream.close();
assertEquals(Strings2.toStringAndClose(response.getError()), ""); assertEquals(Strings2.toStringAndClose(response.getError()), "");
// local echo assertEquals(Strings2.toStringAndClose(response.getOutput()), "");
assertEquals(Strings2.toStringAndClose(response.getOutput()), "foo\r\nEOF\r\n");
} finally { } finally {
Closeables.closeQuietly(response); Closeables.closeQuietly(response);
} }
assertEquals(response.getExitStatus().get(), new Integer(0)); assertEquals(response.getExitStatus().get(), new Integer(0));
} }
} }

View File

@ -0,0 +1,209 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.sshj;
import static com.google.common.base.Objects.equal;
import java.io.IOException;
import javax.annotation.Resource;
import javax.inject.Named;
import net.schmizz.sshj.SSHClient;
import net.schmizz.sshj.transport.verification.PromiscuousVerifier;
import net.schmizz.sshj.userauth.keyprovider.OpenSSHKeyFile;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.logging.Logger;
import org.jclouds.sshj.SshjSshClient.Connection;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Objects;
import com.google.common.net.HostAndPort;
public class SSHClientConnection implements Connection<SSHClient> {
public static Builder builder() {
return new Builder();
}
public static class Builder {
protected HostAndPort hostAndPort;
protected LoginCredentials loginCredentials;
protected int connectTimeout;
protected int sessionTimeout;
/**
* @see SSHClientConnection#getHostAndPort()
*/
public Builder hostAndPort(HostAndPort hostAndPort) {
this.hostAndPort = hostAndPort;
return this;
}
/**
* @see SSHClientConnection#getLoginCredentials()
*/
public Builder loginCredentials(LoginCredentials loginCredentials) {
this.loginCredentials = loginCredentials;
return this;
}
/**
* @see SSHClientConnection#getConnectTimeout()
*/
public Builder connectTimeout(int connectTimeout) {
this.connectTimeout = connectTimeout;
return this;
}
/**
* @see SSHClientConnection#getConnectTimeout()
*/
public Builder sessionTimeout(int sessionTimeout) {
this.sessionTimeout = sessionTimeout;
return this;
}
public SSHClientConnection build() {
return new SSHClientConnection(hostAndPort, loginCredentials, connectTimeout, sessionTimeout);
}
protected Builder fromSSHClientConnection(SSHClientConnection in) {
return hostAndPort(in.getHostAndPort()).connectTimeout(in.getConnectTimeout()).loginCredentials(
in.getLoginCredentials());
}
}
private SSHClientConnection(HostAndPort hostAndPort, LoginCredentials loginCredentials, int connectTimeout,
int sessionTimeout) {
this.hostAndPort = hostAndPort;
this.loginCredentials = loginCredentials;
this.connectTimeout = connectTimeout;
this.sessionTimeout = sessionTimeout;
}
@Resource
@Named("jclouds.ssh")
protected Logger logger = Logger.NULL;
private final HostAndPort hostAndPort;
private final LoginCredentials loginCredentials;
private final int connectTimeout;
private final int sessionTimeout;
@VisibleForTesting
transient SSHClient ssh;
@Override
public void clear() {
if (ssh != null && ssh.isConnected()) {
try {
ssh.disconnect();
} catch (IOException e) {
logger.debug("<< exception disconnecting from %s: %s", e, e.getMessage());
}
ssh = null;
}
}
@Override
public SSHClient create() throws Exception {
ssh = new net.schmizz.sshj.SSHClient();
ssh.addHostKeyVerifier(new PromiscuousVerifier());
if (connectTimeout != 0) {
ssh.setConnectTimeout(connectTimeout);
}
if (sessionTimeout != 0) {
ssh.setTimeout(sessionTimeout);
}
ssh.connect(hostAndPort.getHostText(), hostAndPort.getPortOrDefault(22));
if (loginCredentials.getPassword() != null) {
ssh.authPassword(loginCredentials.getUser(), loginCredentials.getPassword());
} else {
OpenSSHKeyFile key = new OpenSSHKeyFile();
key.init(loginCredentials.getPrivateKey(), null);
ssh.authPublickey(loginCredentials.getUser(), key);
}
return ssh;
}
/**
* @return host and port, where port if not present defaults to {@code 22}
*/
public HostAndPort getHostAndPort() {
return hostAndPort;
}
/**
*
* @return login used in this ssh
*/
public LoginCredentials getLoginCredentials() {
return loginCredentials;
}
/**
*
* @return how long to wait for the initial connection to be made
*/
public int getConnectTimeout() {
return connectTimeout;
}
/**
*
* @return how long to keep the ssh open, or {@code 0} for indefinitely
*/
public int getSessionTimeout() {
return sessionTimeout;
}
/**
*
* @return the current ssh or {@code null} if not connected
*/
public SSHClient getSSHClient() {
return ssh;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
SSHClientConnection that = SSHClientConnection.class.cast(o);
return equal(this.hostAndPort, that.hostAndPort) && equal(this.loginCredentials, that.loginCredentials)
&& equal(this.ssh, that.ssh);
}
@Override
public int hashCode() {
return Objects.hashCode(hostAndPort, loginCredentials, ssh);
}
@Override
public String toString() {
return Objects.toStringHelper("").add("hostAndPort", hostAndPort).add("loginUser", loginCredentials.getUser())
.add("ssh", ssh != null ? ssh.hashCode() : null).add("connectTimeout", connectTimeout).add(
"sessionTimeout", sessionTimeout).toString();
}
}

View File

@ -52,14 +52,13 @@ import net.schmizz.sshj.connection.channel.direct.Session.Command;
import net.schmizz.sshj.sftp.SFTPClient; import net.schmizz.sshj.sftp.SFTPClient;
import net.schmizz.sshj.sftp.SFTPException; import net.schmizz.sshj.sftp.SFTPException;
import net.schmizz.sshj.transport.TransportException; import net.schmizz.sshj.transport.TransportException;
import net.schmizz.sshj.transport.verification.PromiscuousVerifier;
import net.schmizz.sshj.userauth.UserAuthException; import net.schmizz.sshj.userauth.UserAuthException;
import net.schmizz.sshj.userauth.keyprovider.OpenSSHKeyFile;
import net.schmizz.sshj.xfer.InMemorySourceFile; import net.schmizz.sshj.xfer.InMemorySourceFile;
import org.apache.commons.io.input.ProxyInputStream; import org.apache.commons.io.input.ProxyInputStream;
import org.jclouds.compute.domain.ExecChannel; import org.jclouds.compute.domain.ExecChannel;
import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.http.handlers.BackoffLimitedRetryHandler; import org.jclouds.http.handlers.BackoffLimitedRetryHandler;
import org.jclouds.io.Payload; import org.jclouds.io.Payload;
import org.jclouds.io.Payloads; import org.jclouds.io.Payloads;
@ -77,6 +76,7 @@ import com.google.common.base.Splitter;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.google.common.io.Closeables; import com.google.common.io.Closeables;
import com.google.common.net.HostAndPort;
import com.google.inject.Inject; import com.google.inject.Inject;
/** /**
@ -104,10 +104,6 @@ public class SshjSshClient implements SshClient {
} }
} }
private final String host;
private final int port;
private final String username;
private final String password;
private final String toString; private final String toString;
@Inject(optional = true) @Inject(optional = true)
@ -129,41 +125,42 @@ public class SshjSshClient implements SshClient {
@Named("jclouds.ssh.retry-predicate") @Named("jclouds.ssh.retry-predicate")
// NOTE cannot retry io exceptions, as SSHException is a part of the chain // NOTE cannot retry io exceptions, as SSHException is a part of the chain
private Predicate<Throwable> retryPredicate = or(instanceOf(ConnectionException.class), private Predicate<Throwable> retryPredicate = or(instanceOf(ConnectionException.class),
instanceOf(ConnectException.class), instanceOf(SocketTimeoutException.class), instanceOf(ConnectException.class), instanceOf(SocketTimeoutException.class),
instanceOf(TransportException.class), instanceOf(TransportException.class),
// safe to retry sftp exceptions as they are idempotent // safe to retry sftp exceptions as they are idempotent
instanceOf(SFTPException.class)); instanceOf(SFTPException.class));
@Resource @Resource
@Named("jclouds.ssh") @Named("jclouds.ssh")
protected Logger logger = Logger.NULL; protected Logger logger = Logger.NULL;
@VisibleForTesting @VisibleForTesting
SSHClient ssh; SSHClientConnection sshClientConnection;
private final byte[] privateKey;
final byte[] emptyPassPhrase = new byte[0]; final String user;
private final int timeoutMillis; final String host;
private final BackoffLimitedRetryHandler backoffLimitedRetryHandler; private final BackoffLimitedRetryHandler backoffLimitedRetryHandler;
public SshjSshClient(BackoffLimitedRetryHandler backoffLimitedRetryHandler, IPSocket socket, int timeout, public SshjSshClient(BackoffLimitedRetryHandler backoffLimitedRetryHandler, IPSocket socket,
String username, String password, byte[] privateKey) { LoginCredentials loginCredentials, int timeout) {
this.user = checkNotNull(loginCredentials, "loginCredentials").getUser();
this.host = checkNotNull(socket, "socket").getAddress(); this.host = checkNotNull(socket, "socket").getAddress();
checkArgument(socket.getPort() > 0, "ssh port must be greater then zero" + socket.getPort()); checkArgument(socket.getPort() > 0, "ssh port must be greater then zero" + socket.getPort());
checkArgument(password != null || privateKey != null, "you must specify a password or a key"); checkArgument(loginCredentials.getPassword() != null || loginCredentials.getPrivateKey() != null,
this.port = socket.getPort(); "you must specify a password or a key");
this.username = checkNotNull(username, "username");
this.backoffLimitedRetryHandler = checkNotNull(backoffLimitedRetryHandler, "backoffLimitedRetryHandler"); this.backoffLimitedRetryHandler = checkNotNull(backoffLimitedRetryHandler, "backoffLimitedRetryHandler");
this.timeoutMillis = timeout; if (loginCredentials.getPrivateKey() == null) {
this.password = password; this.toString = String.format("%s:pw[%s]@%s:%d", loginCredentials.getUser(), hex(md5(loginCredentials
this.privateKey = privateKey; .getPassword().getBytes())), host, socket.getPort());
if (privateKey == null) {
this.toString = String.format("%s:pw[%s]@%s:%d", username, hex(md5(password.getBytes())), host, port);
} else { } else {
String fingerPrint = fingerprintPrivateKey(new String(privateKey)); String fingerPrint = fingerprintPrivateKey(loginCredentials.getPrivateKey());
String sha1 = sha1PrivateKey(new String(privateKey)); String sha1 = sha1PrivateKey(loginCredentials.getPrivateKey());
this.toString = String.format("%s:rsa[fingerprint(%s),sha1(%s)]@%s:%d", username, fingerPrint, sha1, host, this.toString = String.format("%s:rsa[fingerprint(%s),sha1(%s)]@%s:%d", loginCredentials.getUser(),
port); fingerPrint, sha1, host, socket.getPort());
} }
sshClientConnection = SSHClientConnection.builder().hostAndPort(HostAndPort.fromParts(host, socket.getPort()))
.loginCredentials(loginCredentials).connectTimeout(timeout).sessionTimeout(timeout).build();
} }
@Override @Override
@ -172,7 +169,8 @@ public class SshjSshClient implements SshClient {
} }
private void checkConnected() { private void checkConnected() {
checkState(ssh != null && ssh.isConnected(), String.format("(%s) ssh not connected!", toString())); checkState(sshClientConnection.ssh != null && sshClientConnection.ssh.isConnected(), String
.format("(%s) ssh not connected!", toString()));
} }
public static interface Connection<T> { public static interface Connection<T> {
@ -181,45 +179,6 @@ public class SshjSshClient implements SshClient {
T create() throws Exception; T create() throws Exception;
} }
Connection<net.schmizz.sshj.SSHClient> sshConnection = new Connection<net.schmizz.sshj.SSHClient>() {
@Override
public void clear() {
if (ssh != null && ssh.isConnected()) {
try {
ssh.disconnect();
} catch (IOException e) {
logger.warn(e, "<< exception disconnecting from %s: %s", e, e.getMessage());
}
ssh = null;
}
}
@Override
public net.schmizz.sshj.SSHClient create() throws Exception {
net.schmizz.sshj.SSHClient ssh = new net.schmizz.sshj.SSHClient();
ssh.addHostKeyVerifier(new PromiscuousVerifier());
if (timeoutMillis != 0) {
ssh.setTimeout(timeoutMillis);
ssh.setConnectTimeout(timeoutMillis);
}
ssh.connect(host, port);
if (password != null) {
ssh.authPassword(username, password);
} else {
OpenSSHKeyFile key = new OpenSSHKeyFile();
key.init(new String(privateKey), null);
ssh.authPublickey(username, key);
}
return ssh;
}
@Override
public String toString() {
return String.format("SSHClient(timeout=%d)", timeoutMillis);
}
};
private void backoffForAttempt(int retryAttempt, String message) { private void backoffForAttempt(int retryAttempt, String message) {
backoffLimitedRetryHandler.imposeBackoffExponentialDelay(200L, 2, retryAttempt, sshRetries, message); backoffLimitedRetryHandler.imposeBackoffExponentialDelay(200L, 2, retryAttempt, sshRetries, message);
} }
@ -240,16 +199,17 @@ public class SshjSshClient implements SshClient {
logger.warn(from, "<< (%s) error closing connection", toString()); logger.warn(from, "<< (%s) error closing connection", toString());
} }
if (i + 1 == sshRetries) { if (i + 1 == sshRetries) {
throw propagate(from, errorMessage+" (out of retries - max "+sshRetries+")"); throw propagate(from, errorMessage + " (out of retries - max " + sshRetries + ")");
} else if (shouldRetry(from) || } else if (shouldRetry(from)
(Throwables2.getFirstThrowableOfType(from, IllegalStateException.class) != null)) { || (Throwables2.getFirstThrowableOfType(from, IllegalStateException.class) != null)) {
logger.info("<< " + errorMessage + " (attempt " + (i + 1) + " of " + sshRetries + "): " + from.getMessage()); logger.info("<< " + errorMessage + " (attempt " + (i + 1) + " of " + sshRetries + "): "
+ from.getMessage());
backoffForAttempt(i + 1, errorMessage + ": " + from.getMessage()); backoffForAttempt(i + 1, errorMessage + ": " + from.getMessage());
if (connection != sshConnection) if (connection != sshClientConnection)
connect(); connect();
continue; continue;
} else { } else {
throw propagate(from, errorMessage+" (not retryable)"); throw propagate(from, errorMessage + " (not retryable)");
} }
} }
} }
@ -259,7 +219,7 @@ public class SshjSshClient implements SshClient {
public void connect() { public void connect() {
try { try {
ssh = acquire(sshConnection); acquire(sshClientConnection);
} catch (Exception e) { } catch (Exception e) {
Throwables.propagate(e); Throwables.propagate(e);
} }
@ -282,7 +242,7 @@ public class SshjSshClient implements SshClient {
@Override @Override
public SFTPClient create() throws IOException { public SFTPClient create() throws IOException {
checkConnected(); checkConnected();
sftp = ssh.newSFTPClient(); sftp = sshClientConnection.ssh.newSFTPClient();
return sftp; return sftp;
} }
@ -310,7 +270,7 @@ public class SshjSshClient implements SshClient {
public Payload create() throws Exception { public Payload create() throws Exception {
sftp = acquire(sftpConnection); sftp = acquire(sftpConnection);
return Payloads.newInputStreamPayload(new CloseFtpChannelOnCloseInputStream(sftp.getSFTPEngine().open(path) return Payloads.newInputStreamPayload(new CloseFtpChannelOnCloseInputStream(sftp.getSFTPEngine().open(path)
.getInputStream(), sftp)); .getInputStream(), sftp));
} }
@Override @Override
@ -385,7 +345,7 @@ public class SshjSshClient implements SshClient {
@VisibleForTesting @VisibleForTesting
boolean shouldRetry(Exception from) { boolean shouldRetry(Exception from) {
Predicate<Throwable> predicate = retryAuth ? Predicates.<Throwable> or(retryPredicate, Predicate<Throwable> predicate = retryAuth ? Predicates.<Throwable> or(retryPredicate,
instanceOf(AuthorizationException.class), instanceOf(UserAuthException.class)) : retryPredicate; instanceOf(AuthorizationException.class), instanceOf(UserAuthException.class)) : retryPredicate;
if (any(getCausalChain(from), predicate)) if (any(getCausalChain(from), predicate))
return true; return true;
if (!retryableMessages.equals("")) if (!retryableMessages.equals(""))
@ -404,7 +364,7 @@ public class SshjSshClient implements SshClient {
@Override @Override
public boolean apply(Throwable arg0) { public boolean apply(Throwable arg0) {
return (arg0.toString().indexOf(input) != -1) return (arg0.toString().indexOf(input) != -1)
|| (arg0.getMessage() != null && arg0.getMessage().indexOf(input) != -1); || (arg0.getMessage() != null && arg0.getMessage().indexOf(input) != -1);
} }
}); });
@ -420,7 +380,7 @@ public class SshjSshClient implements SshClient {
if (e instanceof UserAuthException) if (e instanceof UserAuthException)
throw new AuthorizationException("(" + toString() + ") " + message, e); throw new AuthorizationException("(" + toString() + ") " + message, e);
throw e instanceof SshException ? SshException.class.cast(e) : new SshException( throw e instanceof SshException ? SshException.class.cast(e) : new SshException(
"(" + toString() + ") " + message, e); "(" + toString() + ") " + message, e);
} }
@Override @Override
@ -431,7 +391,7 @@ public class SshjSshClient implements SshClient {
@PreDestroy @PreDestroy
public void disconnect() { public void disconnect() {
try { try {
sshConnection.clear(); sshClientConnection.clear();
} catch (Exception e) { } catch (Exception e) {
Throwables.propagate(e); Throwables.propagate(e);
} }
@ -452,8 +412,8 @@ public class SshjSshClient implements SshClient {
@Override @Override
public Session create() throws Exception { public Session create() throws Exception {
checkConnected(); checkConnected();
session = ssh.startSession(); session = sshClientConnection.ssh.startSession();
session.allocatePTY("vt100", 80, 24, 0, 0, Collections.<PTYMode, Integer>emptyMap()); session.allocatePTY("vt100", 80, 24, 0, 0, Collections.<PTYMode, Integer> emptyMap());
return session; return session;
} }
@ -485,7 +445,7 @@ public class SshjSshClient implements SshClient {
session = acquire(execConnection()); session = acquire(execConnection());
Command output = session.exec(checkNotNull(command, "command")); Command output = session.exec(checkNotNull(command, "command"));
String outputString = IOUtils.readFully(output.getInputStream()).toString(); String outputString = IOUtils.readFully(output.getInputStream()).toString();
output.join(timeoutMillis, TimeUnit.SECONDS); output.join(sshClientConnection.getSessionTimeout(), TimeUnit.MILLISECONDS);
int errorStatus = output.getExitStatus(); int errorStatus = output.getExitStatus();
String errorString = IOUtils.readFully(output.getErrorStream()).toString(); String errorString = IOUtils.readFully(output.getErrorStream()).toString();
return new ExecResponse(outputString, errorString, errorStatus); return new ExecResponse(outputString, errorString, errorStatus);
@ -504,6 +464,37 @@ public class SshjSshClient implements SshClient {
return acquire(new ExecConnection(command)); return acquire(new ExecConnection(command));
} }
protected Connection<Session> noPTYConnection() {
return new Connection<Session>() {
private Session session = null;
private SSHClient sshClientConnection;
@Override
public void clear() throws TransportException, ConnectionException {
if (session != null)
session.close();
if (sshClientConnection != null)
Closeables.closeQuietly(sshClientConnection);
}
@Override
public Session create() throws Exception {
this.sshClientConnection = acquire(SSHClientConnection.builder().fromSSHClientConnection(
SshjSshClient.this.sshClientConnection).sessionTimeout(0).build());
session = sshClientConnection.startSession();
return session;
}
@Override
public String toString() {
return "Session()";
}
};
}
class ExecChannelConnection implements Connection<ExecChannel> { class ExecChannelConnection implements Connection<ExecChannel> {
private final String command; private final String command;
private SessionChannel session; private SessionChannel session;
@ -521,7 +512,7 @@ public class SshjSshClient implements SshClient {
@Override @Override
public ExecChannel create() throws Exception { public ExecChannel create() throws Exception {
session = SessionChannel.class.cast(acquire(execConnection())); session = SessionChannel.class.cast(acquire(noPTYConnection()));
output = session.exec(command); output = session.exec(command);
return new ExecChannel(output.getOutputStream(), output.getInputStream(), output.getErrorStream(), return new ExecChannel(output.getOutputStream(), output.getInputStream(), output.getErrorStream(),
new Supplier<Integer>() { new Supplier<Integer>() {
@ -552,7 +543,7 @@ public class SshjSshClient implements SshClient {
public ExecChannel execChannel(String command) { public ExecChannel execChannel(String command) {
return acquire(new ExecChannelConnection(command)); return acquire(new ExecChannelConnection(command));
} }
@Override @Override
public String getHostAddress() { public String getHostAddress() {
return this.host; return this.host;
@ -560,7 +551,7 @@ public class SshjSshClient implements SshClient {
@Override @Override
public String getUsername() { public String getUsername() {
return this.username; return this.user;
} }
} }

View File

@ -65,9 +65,7 @@ public class SshjSshClientModule extends AbstractModule {
@Override @Override
public SshClient create(IPSocket socket, LoginCredentials credentials) { public SshClient create(IPSocket socket, LoginCredentials credentials) {
SshClient client = new SshjSshClient(backoffLimitedRetryHandler, socket, timeout, credentials.getUser(), SshClient client = new SshjSshClient(backoffLimitedRetryHandler, socket, credentials, timeout);
(credentials.getPrivateKey() == null) ? credentials.getPassword() : null,
credentials.getPrivateKey() != null ? credentials.getPrivateKey().getBytes() : null);
injector.injectMembers(client);// add logger injector.injectMembers(client);// add logger
return client; return client;
} }

View File

@ -169,9 +169,11 @@ public class SshjSshClientLiveTest {
assertEquals(response.getOutput().trim(), "localhost".equals(sshHost) ? InetAddress.getLocalHost().getHostName() assertEquals(response.getOutput().trim(), "localhost".equals(sshHost) ? InetAddress.getLocalHost().getHostName()
: sshHost); : sshHost);
} }
public void testExecChannelTakesStdinAndEchosBack() throws IOException { public void testExecChannelTakesStdinAndNoEchoOfCharsInOuputAndOutlivesClient() throws IOException {
ExecChannel response = setupClient().execChannel("cat <<EOF"); SshClient client = setupClient();
ExecChannel response = client.execChannel("cat <<EOF");
client.disconnect();
assertEquals(response.getExitStatus().get(), null); assertEquals(response.getExitStatus().get(), null);
try { try {
PrintStream printStream = new PrintStream(response.getInput()); PrintStream printStream = new PrintStream(response.getInput());
@ -179,8 +181,7 @@ public class SshjSshClientLiveTest {
printStream.append("EOF\n"); printStream.append("EOF\n");
printStream.close(); printStream.close();
assertEquals(Strings2.toStringAndClose(response.getError()), ""); assertEquals(Strings2.toStringAndClose(response.getError()), "");
// local echo assertEquals(Strings2.toStringAndClose(response.getOutput()), "");
assertEquals(Strings2.toStringAndClose(response.getOutput()), "foo\r\nEOF\r\n");
} finally { } finally {
Closeables.closeQuietly(response); Closeables.closeQuietly(response);
} }

View File

@ -172,8 +172,8 @@ public class SshjSshClientTest {
ssh.disconnect(); ssh.disconnect();
expectLastCall().andThrow(new ConnectionException("disconnected")); expectLastCall().andThrow(new ConnectionException("disconnected"));
replay(ssh); replay(ssh);
ssh1.ssh = ssh; ssh1.sshClientConnection.ssh = ssh;
ssh1.sshConnection.clear(); ssh1.sshClientConnection.clear();
verify(ssh); verify(ssh);
} }
@ -186,10 +186,9 @@ public class SshjSshClientTest {
} }
public void testRetriesLoggedAtInfoWithCount() throws Exception { public void testRetriesLoggedAtInfoWithCount() throws Exception {
@SuppressWarnings("unchecked") SSHClientConnection mockConnection = createMock(SSHClientConnection.class);
SshjSshClient.Connection<net.schmizz.sshj.SSHClient> mockConnection = createMock(SshjSshClient.Connection.class);
net.schmizz.sshj.SSHClient mockClient = createMock(net.schmizz.sshj.SSHClient.class); net.schmizz.sshj.SSHClient mockClient = createMock(net.schmizz.sshj.SSHClient.class);
mockConnection.clear(); expectLastCall(); mockConnection.clear(); expectLastCall();
mockConnection.create(); expectLastCall().andThrow(new ConnectionException("test1")); mockConnection.create(); expectLastCall().andThrow(new ConnectionException("test1"));
mockConnection.clear(); expectLastCall(); mockConnection.clear(); expectLastCall();
@ -199,14 +198,14 @@ public class SshjSshClientTest {
replay(mockConnection); replay(mockConnection);
replay(mockClient); replay(mockClient);
ssh.sshConnection = mockConnection; ssh.sshClientConnection = mockConnection;
BufferLogger logcheck = new BufferLogger(ssh.getClass().getCanonicalName()); BufferLogger logcheck = new BufferLogger(ssh.getClass().getCanonicalName());
ssh.logger = logcheck; ssh.logger = logcheck;
logcheck.setLevel(Level.INFO); logcheck.setLevel(Level.INFO);
ssh.connect(); ssh.connect();
Assert.assertEquals(ssh.ssh, mockClient); Assert.assertEquals(ssh.sshClientConnection, mockConnection);
verify(mockConnection); verify(mockConnection);
verify(mockClient); verify(mockClient);
Record r = logcheck.assertLogContains("attempt 1 of 5"); Record r = logcheck.assertLogContains("attempt 1 of 5");

View File

@ -127,7 +127,7 @@ public class ServerDetailsToNodeMetadata implements Function<ServerDetails, Node
try { try {
return Iterables.find(images.get(), new FindImageForServer(from)).getOperatingSystem(); return Iterables.find(images.get(), new FindImageForServer(from)).getOperatingSystem();
} catch (NoSuchElementException e) { } catch (NoSuchElementException e) {
logger.warn("could not find a matching image for server %s", from); logger.debug("could not find a matching image for server %s", from);
} }
return null; return null;
} }

View File

@ -19,6 +19,7 @@
package org.jclouds.vcloud.director.v1_5; package org.jclouds.vcloud.director.v1_5;
import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.Delegate;
import org.jclouds.vcloud.director.v1_5.domain.AdminOrg;
import org.jclouds.vcloud.director.v1_5.domain.Catalog; import org.jclouds.vcloud.director.v1_5.domain.Catalog;
import org.jclouds.vcloud.director.v1_5.domain.Group; import org.jclouds.vcloud.director.v1_5.domain.Group;
import org.jclouds.vcloud.director.v1_5.domain.Media; import org.jclouds.vcloud.director.v1_5.domain.Media;

View File

@ -22,6 +22,7 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.Delegate;
import org.jclouds.vcloud.director.v1_5.domain.AdminOrg;
import org.jclouds.vcloud.director.v1_5.domain.Catalog; import org.jclouds.vcloud.director.v1_5.domain.Catalog;
import org.jclouds.vcloud.director.v1_5.domain.Group; import org.jclouds.vcloud.director.v1_5.domain.Group;
import org.jclouds.vcloud.director.v1_5.domain.Media; import org.jclouds.vcloud.director.v1_5.domain.Media;

View File

@ -129,14 +129,31 @@ public class VCloudDirectorMediaType {
public static final String ADMIN_CATALOG = "application/vnd.vmware.admin.catalog+xml"; public static final String ADMIN_CATALOG = "application/vnd.vmware.admin.catalog+xml";
public static final String ADMIN_ORGANIZATION = "application/vnd.vmware.admin.organization+xml"; public static final String ADMIN_ORG = "application/vnd.vmware.admin.organization+xml";
public static final String PUBLISH_CATALOG_PARAMS = "application/vnd.vmware.admin.publishCatalogParams+xml"; public static final String PUBLISH_CATALOG_PARAMS = "application/vnd.vmware.admin.publishCatalogParams+xml";
public static final String GROUP = "application/vnd.vmware.admin.group+xml"; public static final String GROUP = "application/vnd.vmware.admin.group+xml";
public static final String ORG_VAPP_TEMPLATE_LEASE_SETTINGS = "application/vnd.vmware.admin.vAppTemplateLeaseSettings+xml";
public static final String ORG_LEASE_SETTINGS = "application/vnd.vmware.admin.vAppLeaseSettings+xml";
public static final String ORG_PASSWORD_POLICY_SETTINGS = "application/vnd.vmware.admin.organizationPasswordPolicySettings+xml";
public static final String ORG_LDAP_SETTINGS = "application/vnd.vmware.admin.organizationLdapSettings+xml";
public static final String ORG_GENERAL_SETTINGS = "application/vnd.vmware.admin.organizationGeneralSettings+xml";
public static final String ORG_EMAIL_SETTINGS = "application/vnd.vmware.admin.organizationEmailSettings+xml";
public static final String ORG_SETTINGS = "application/vnd.vmware.admin.orgSettings+xml";
public static final String ADMIN_NETWORK = "application/vnd.vmware.admin.network+xml";
public static final String ADMIN_ORG_NETWORK = "application/vnd.vmware.admin.orgNetwork+xml";
/** /**
*
* All acceptable media types. * All acceptable media types.
* *
* This list must be updated whenever a new media type constant is added. * This list must be updated whenever a new media type constant is added.
@ -148,11 +165,14 @@ public class VCloudDirectorMediaType {
MEDIA, OWNER, VDC, ADMIN_USER, V_APP, V_APP_TEMPLATE, MEDIA, OWNER, VDC, ADMIN_USER, V_APP, V_APP_TEMPLATE,
CAPTURE_VAPP_PARAMS, CLONE_V_APP_PARAMS, CLONE_V_APP_TEMPLATE_PARAMS, CAPTURE_VAPP_PARAMS, CLONE_V_APP_PARAMS, CLONE_V_APP_TEMPLATE_PARAMS,
COMPOSE_VAPP_PARAMS, INSTANTIATE_VAPP_TEMPLATE_PARAMS, COMPOSE_VAPP_PARAMS, INSTANTIATE_VAPP_TEMPLATE_PARAMS,
UPLOAD_VAPP_TEMPLATE_PARAMS, ADMIN_CATALOG, ADMIN_ORGANIZATION, UPLOAD_VAPP_TEMPLATE_PARAMS, ADMIN_CATALOG, ADMIN_ORG,
QUERY_RESULT_RECORDS, QUERY_RESULT_REFERENCES, QUERY_RESULT_ID_RECORDS, QUERY_RESULT_RECORDS, QUERY_RESULT_REFERENCES, QUERY_RESULT_ID_RECORDS,
CONTROL_ACCESS, VAPP_TEMPLATE, CUSTOMIZATION_SECTION, GUEST_CUSTOMIZATION_SECTION, CONTROL_ACCESS, VAPP_TEMPLATE, CUSTOMIZATION_SECTION, GUEST_CUSTOMIZATION_SECTION,
NETWORK_SECTION, NETWORK_CONFIG_SECTION, NETWORK_CONNECTION_SECTION, NETWORK_SECTION, NETWORK_CONFIG_SECTION, NETWORK_CONNECTION_SECTION,
CLONE_MEDIA_PARAMS, LEASE_SETTINGS_SECTION, RELOCATE_TEMPLATE, ENVELOPE, CLONE_MEDIA_PARAMS, LEASE_SETTINGS_SECTION, RELOCATE_TEMPLATE, ENVELOPE,
PUBLISH_CATALOG_PARAMS, GROUP PUBLISH_CATALOG_PARAMS, GROUP, ORG_VAPP_TEMPLATE_LEASE_SETTINGS,
ORG_LEASE_SETTINGS, ORG_PASSWORD_POLICY_SETTINGS, ORG_LDAP_SETTINGS,
ORG_GENERAL_SETTINGS, ORG_EMAIL_SETTINGS, ORG_SETTINGS, ADMIN_NETWORK,
ADMIN_ORG_NETWORK
); );
} }

View File

@ -42,11 +42,32 @@ import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
import org.jclouds.vcloud.director.v1_5.annotations.Login; import org.jclouds.vcloud.director.v1_5.annotations.Login;
import org.jclouds.vcloud.director.v1_5.domain.Session; import org.jclouds.vcloud.director.v1_5.domain.Session;
import org.jclouds.vcloud.director.v1_5.domain.SessionWithToken; import org.jclouds.vcloud.director.v1_5.domain.SessionWithToken;
import org.jclouds.vcloud.director.v1_5.features.*; import org.jclouds.vcloud.director.v1_5.features.AdminCatalogAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.AdminCatalogClient;
import org.jclouds.vcloud.director.v1_5.features.AdminOrgAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.AdminOrgClient;
import org.jclouds.vcloud.director.v1_5.features.CatalogAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.CatalogClient;
import org.jclouds.vcloud.director.v1_5.features.GroupAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.GroupClient;
import org.jclouds.vcloud.director.v1_5.features.MediaAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.MediaClient;
import org.jclouds.vcloud.director.v1_5.features.MetadataAsyncClient; import org.jclouds.vcloud.director.v1_5.features.MetadataAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.MetadataClient; import org.jclouds.vcloud.director.v1_5.features.MetadataClient;
import org.jclouds.vcloud.director.v1_5.features.NetworkAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.NetworkClient;
import org.jclouds.vcloud.director.v1_5.features.OrgAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.OrgClient;
import org.jclouds.vcloud.director.v1_5.features.QueryAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.QueryClient;
import org.jclouds.vcloud.director.v1_5.features.TaskAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.TaskClient;
import org.jclouds.vcloud.director.v1_5.features.UploadAsyncClient; import org.jclouds.vcloud.director.v1_5.features.UploadAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.UploadClient; import org.jclouds.vcloud.director.v1_5.features.UploadClient;
import org.jclouds.vcloud.director.v1_5.features.VAppTemplateAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.VAppTemplateClient;
import org.jclouds.vcloud.director.v1_5.features.VdcAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.VdcClient;
import org.jclouds.vcloud.director.v1_5.functions.LoginUserInOrgWithPassword; import org.jclouds.vcloud.director.v1_5.functions.LoginUserInOrgWithPassword;
import org.jclouds.vcloud.director.v1_5.handlers.InvalidateSessionAndRetryOn401AndLogoutOnClose; import org.jclouds.vcloud.director.v1_5.handlers.InvalidateSessionAndRetryOn401AndLogoutOnClose;
import org.jclouds.vcloud.director.v1_5.handlers.VCloudDirectorErrorHandler; import org.jclouds.vcloud.director.v1_5.handlers.VCloudDirectorErrorHandler;
@ -86,6 +107,7 @@ public class VCloudDirectorRestClientModule extends RestClientModule<VCloudDirec
.put(MetadataClient.Readable.class, MetadataAsyncClient.Readable.class) .put(MetadataClient.Readable.class, MetadataAsyncClient.Readable.class)
.put(MetadataClient.Writeable.class, MetadataAsyncClient.Writable.class) .put(MetadataClient.Writeable.class, MetadataAsyncClient.Writable.class)
.put(AdminCatalogClient.class, AdminCatalogAsyncClient.class) .put(AdminCatalogClient.class, AdminCatalogAsyncClient.class)
.put(AdminOrgClient.class, AdminOrgAsyncClient.class)
.put(GroupClient.class, GroupAsyncClient.class) .put(GroupClient.class, GroupAsyncClient.class)
.build(); .build();

View File

@ -19,8 +19,6 @@
package org.jclouds.vcloud.director.v1_5.domain; package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Set; import java.util.Set;
@ -28,8 +26,6 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import com.google.common.collect.Sets;
/** /**
* *
@ -69,7 +65,7 @@ public class AdminCatalog extends CatalogType<AdminCatalog> {
public static class Builder extends CatalogType.Builder<AdminCatalog> { public static class Builder extends CatalogType.Builder<AdminCatalog> {
public AdminCatalog build() { public AdminCatalog build() {
return new AdminCatalog(href, type, links, description, tasksInProgress, id, name, owner, catalogItems, isPublished); return new AdminCatalog(href, type, links, description, tasks, id, name, owner, catalogItems, isPublished);
} }
/** /**
@ -132,14 +128,14 @@ public class AdminCatalog extends CatalogType<AdminCatalog> {
} }
/** /**
* @see EntityType#getTasksInProgress() * @see EntityType#getTasks()
*/ */
@Override @Override
public Builder tasksInProgress(TasksInProgress tasksInProgress) { public Builder tasks(Set<Task> tasks) {
this.tasksInProgress = tasksInProgress; super.tasks(tasks);
return this; return this;
} }
/** /**
* @see ReferenceType#getHref() * @see ReferenceType#getHref()
*/ */
@ -157,25 +153,24 @@ public class AdminCatalog extends CatalogType<AdminCatalog> {
this.type = type; this.type = type;
return this; return this;
} }
/** /**
* @see EntityType#getLinks() * @see ResourceType#getLinks()
*/ */
@Override @Override
public Builder links(Set<Link> links) { public Builder links(Set<Link> links) {
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); return Builder.class.cast(super.links(links));
return this;
} }
/** /**
* @see EntityType#getLinks() * @see ResourceType#getLinks()
*/ */
@Override @Override
public Builder link(Link link) { public Builder link(Link link) {
this.links.add(checkNotNull(link, "link")); return Builder.class.cast(super.link(link));
return this;
} }
@Override @Override
public Builder fromCatalogType(CatalogType<AdminCatalog> in) { public Builder fromCatalogType(CatalogType<AdminCatalog> in) {
return Builder.class.cast(super.fromCatalogType(in)); return Builder.class.cast(super.fromCatalogType(in));
@ -190,8 +185,8 @@ public class AdminCatalog extends CatalogType<AdminCatalog> {
// For JAXB // For JAXB
} }
public AdminCatalog(URI href, String type, Set<Link> links, String description, TasksInProgress tasksInProgress, String id, public AdminCatalog(URI href, String type, Set<Link> links, String description, Set<Task> tasks, String id,
String name, Owner owner, CatalogItems catalogItems, Boolean published) { String name, Owner owner, CatalogItems catalogItems, Boolean published) {
super(href, type, links, description, tasksInProgress, id, name, owner, catalogItems, published); super(href, type, links, description, tasks, id, name, owner, catalogItems, published);
} }
} }

View File

@ -21,6 +21,9 @@ package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal; import static com.google.common.base.Objects.equal;
import java.net.URI;
import java.util.Set;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
@ -145,7 +148,8 @@ public class AdminOrg extends Org {
} }
public AdminOrg build() { public AdminOrg build() {
return new AdminOrg(settings, users, groups, catalogs, vdcs, networks); return new AdminOrg(href, type, links, description, tasks, id,
name, fullName, isEnabled, settings, users, groups, catalogs, vdcs, networks);
} }
public T fromAdminOrg(AdminOrg in) { public T fromAdminOrg(AdminOrg in) {
@ -175,8 +179,11 @@ public class AdminOrg extends Org {
// For JAXB // For JAXB
} }
protected AdminOrg(OrgSettings settings, UsersList users, GroupsList groups, protected AdminOrg(URI href, String type, Set<Link> links, String description,
Set<Task> tasks, String id, String name, String fullName,
Boolean enabled, OrgSettings settings, UsersList users, GroupsList groups,
CatalogsList catalogs, Vdcs vdcs, Networks networks) { CatalogsList catalogs, Vdcs vdcs, Networks networks) {
super(href, type, links, description, tasks, id, name, fullName, enabled);
this.settings = settings; this.settings = settings;
this.users = users; this.users = users;
this.groups = groups; this.groups = groups;

View File

@ -25,6 +25,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;

View File

@ -57,7 +57,7 @@ public class Catalog extends CatalogType<Catalog> {
@Override @Override
public Catalog build() { public Catalog build() {
return new Catalog(href, type, links, description, tasksInProgress, id, name, owner, catalogItems, isPublished); return new Catalog(href, type, links, description, tasks, id, name, owner, catalogItems, isPublished);
} }
/** /**
@ -120,11 +120,11 @@ public class Catalog extends CatalogType<Catalog> {
} }
/** /**
* @see EntityType#getTasksInProgress() * @see EntityType#getTasks()
*/ */
@Override @Override
public Builder tasksInProgress(TasksInProgress tasksInProgress) { public Builder tasks(Set<Task> tasks) {
this.tasksInProgress = tasksInProgress; super.tasks(tasks);
return this; return this;
} }
@ -174,9 +174,9 @@ public class Catalog extends CatalogType<Catalog> {
} }
} }
public Catalog(URI href, String type, Set<Link> links, String description, TasksInProgress tasksInProgress, String id, public Catalog(URI href, String type, Set<Link> links, String description, Set<Task> tasks, String id,
String name, Owner owner, CatalogItems catalogItems, Boolean published) { String name, Owner owner, CatalogItems catalogItems, Boolean published) {
super(href, type, links, description, tasksInProgress, id, name, owner, catalogItems, published); super(href, type, links, description, tasks, id, name, owner, catalogItems, published);
} }
@SuppressWarnings("unused") @SuppressWarnings("unused")

View File

@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Collections; import java.util.Collections;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@ -45,7 +46,6 @@ public class CatalogItem extends EntityType<CatalogItem> {
public static final String MEDIA_TYPE = VCloudDirectorMediaType.CATALOG_ITEM; public static final String MEDIA_TYPE = VCloudDirectorMediaType.CATALOG_ITEM;
@SuppressWarnings("unchecked")
public static Builder builder() { public static Builder builder() {
return new Builder(); return new Builder();
} }
@ -86,7 +86,7 @@ public class CatalogItem extends EntityType<CatalogItem> {
@Override @Override
public CatalogItem build() { public CatalogItem build() {
return new CatalogItem(href, type, links, description, tasksInProgress, id, name, entity, properties); return new CatalogItem(href, type, links, description, tasks, id, name, entity, properties);
} }
/** /**
@ -115,13 +115,13 @@ public class CatalogItem extends EntityType<CatalogItem> {
this.id = id; this.id = id;
return this; return this;
} }
/** /**
* @see EntityType#getTasksInProgress() * @see EntityType#getTasks()
*/ */
@Override @Override
public Builder tasksInProgress(TasksInProgress tasksInProgress) { public Builder tasks(Set<Task> tasks) {
this.tasksInProgress = tasksInProgress; super.tasks(tasks);
return this; return this;
} }
@ -144,21 +144,19 @@ public class CatalogItem extends EntityType<CatalogItem> {
} }
/** /**
* @see EntityType#getLinks() * @see ResourceType#getLinks()
*/ */
@Override @Override
public Builder links(Set<Link> links) { public Builder links(Set<Link> links) {
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); return Builder.class.cast(super.links(links));
return this;
} }
/** /**
* @see EntityType#getLinks() * @see ResourceType#getLinks()
*/ */
@Override @Override
public Builder link(Link link) { public Builder link(Link link) {
this.links.add(checkNotNull(link, "link")); return Builder.class.cast(super.link(link));
return this;
} }
@Override @Override
@ -171,8 +169,8 @@ public class CatalogItem extends EntityType<CatalogItem> {
} }
} }
private CatalogItem(URI href, String type, Set<Link> links, String description, TasksInProgress tasksInProgress, String id, String name, Reference entity, Set<Property> properties) { private CatalogItem(URI href, String type, Set<Link> links, String description, Set<Task> tasks, String id, String name, Reference entity, Set<Property> properties) {
super(href, type, links, description, tasksInProgress, id, name); super(href, type, links, description, tasks, id, name);
this.entity = entity; this.entity = entity;
this.properties = ImmutableSet.copyOf(properties); this.properties = ImmutableSet.copyOf(properties);
} }

View File

@ -1,6 +1,7 @@
package org.jclouds.vcloud.director.v1_5.domain; package org.jclouds.vcloud.director.v1_5.domain;
import java.net.URI; import java.net.URI;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "CatalogReference") @XmlRootElement(name = "CatalogReference")

View File

@ -90,7 +90,7 @@ public class CatalogType<T extends CatalogType<T>> extends EntityType<T> {
@Override @Override
public CatalogType<T> build() { public CatalogType<T> build() {
return new CatalogType<T>(href, type, links, description, tasksInProgress, id, name, owner, catalogItems, isPublished); return new CatalogType<T>(href, type, links, description, tasks, id, name, owner, catalogItems, isPublished);
} }
/** /**
@ -121,11 +121,11 @@ public class CatalogType<T extends CatalogType<T>> extends EntityType<T> {
} }
/** /**
* @see EntityType#getTasksInProgress() * @see EntityType#getTasks()
*/ */
@Override @Override
public Builder<T> tasksInProgress(TasksInProgress tasksInProgress) { public Builder<T> tasks(Set<Task> tasks) {
super.tasksInProgress(tasksInProgress); super.tasks(tasks);
return this; return this;
} }
@ -176,9 +176,9 @@ public class CatalogType<T extends CatalogType<T>> extends EntityType<T> {
} }
} }
public CatalogType(URI href, String type, Set<Link> links, String description, TasksInProgress tasksInProgress, String id, public CatalogType(URI href, String type, Set<Link> links, String description, Set<Task> tasks, String id,
String name, Owner owner, CatalogItems catalogItems, Boolean published) { String name, Owner owner, CatalogItems catalogItems, Boolean published) {
super(href, type, links, description, tasksInProgress, id, name); super(href, type, links, description, tasks, id, name);
this.owner = owner; this.owner = owner;
this.catalogItems = catalogItems; this.catalogItems = catalogItems;
this.isPublished = published; this.isPublished = published;

View File

@ -21,9 +21,9 @@ package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal; import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@ -67,6 +67,14 @@ public class CatalogsList {
this.catalogReferences = checkNotNull(catalogReferences, "catalogReferences"); this.catalogReferences = checkNotNull(catalogReferences, "catalogReferences");
return this; return this;
} }
/**
* @see CatalogsList#getCatalogItems()
*/
public Builder catalog(Reference catalog) {
this.catalogReferences.add(checkNotNull(catalog, "catalog"));
return this;
}
public CatalogsList build() { public CatalogsList build() {
return new CatalogsList(catalogReferences); return new CatalogsList(catalogReferences);
@ -81,7 +89,7 @@ public class CatalogsList {
// for JAXB // for JAXB
} }
private CatalogsList(Set<Reference> tasks) { private CatalogsList(Set<Reference> catalogReferences) {
this.catalogReferences = ImmutableSet.copyOf(checkNotNull(catalogReferences, "catalogReferences")); this.catalogReferences = ImmutableSet.copyOf(checkNotNull(catalogReferences, "catalogReferences"));
} }

View File

@ -21,8 +21,6 @@ package org.jclouds.vcloud.director.v1_5.domain;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects;
/** /**
* Represents parameters for copying a vApp and optionally deleting the source. * Represents parameters for copying a vApp and optionally deleting the source.

View File

@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collections; import java.util.Collections;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSeeAlso; import javax.xml.bind.annotation.XmlSeeAlso;

View File

@ -21,6 +21,9 @@ package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal; import static com.google.common.base.Objects.equal;
import java.util.Arrays;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
@ -86,6 +89,36 @@ import com.google.common.base.Objects.ToStringHelper;
"groupAttributes" "groupAttributes"
}) })
public class CustomOrgLdapSettings { public class CustomOrgLdapSettings {
public static final class AuthenticationMechanism {
public static final String SIMPLE = "simple";
public static final String KERBEROS = "kerberos";
public static final String MD5DIGEST = "md5digest";
public static final String NTLM = "ntlm";
/**
* All acceptable {@link CustomOrgLdapSettings#getAuthenticationMechanism()} values.
* <p/>
* This list must be updated whenever a new authentication mechanism is added.
*/
public static final List<String> ALL = Arrays.asList(
SIMPLE, KERBEROS, MD5DIGEST, NTLM
);
}
public static final class ConnectorType {
public static final String ACTIVE_DIRECTORY = "ACTIVE_DIRECTORY";
public static final String OPEN_LDAP = "OPEN_LDAP";
/**
* All acceptable {@link OrgLdapSettings#getLdapMode()} values.
* <p/>
* This list must be updated whenever a new mode is added.
*/
public static final List<String> ALL = Arrays.asList(
ACTIVE_DIRECTORY, OPEN_LDAP
);
}
public static Builder<?> builder() { public static Builder<?> builder() {
return new ConcreteBuilder(); return new ConcreteBuilder();
} }

View File

@ -25,6 +25,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Collections; import java.util.Collections;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;

View File

@ -46,7 +46,7 @@ public class Entity extends EntityType<Entity> {
@Override @Override
public Entity build() { public Entity build() {
return new Entity(href, type, links, description, tasksInProgress, id, name); return new Entity(href, type, links, description, tasks, id, name);
} }
/** /**
@ -77,11 +77,11 @@ public class Entity extends EntityType<Entity> {
} }
/** /**
* @see EntityType#getTasksInProgress() * @see EntityType#getTasks()
*/ */
@Override @Override
public Builder tasksInProgress(TasksInProgress tasksInProgress) { public Builder tasks(Set<Task> tasks) {
this.tasksInProgress = tasksInProgress; super.tasks(tasks);
return this; return this;
} }
@ -131,8 +131,8 @@ public class Entity extends EntityType<Entity> {
} }
} }
private Entity(URI href, String type, Set<Link> links, String description, TasksInProgress tasksInProgress, String id, String name) { private Entity(URI href, String type, Set<Link> links, String description, Set<Task> tasks, String id, String name) {
super(href, type, links, description, tasksInProgress, id, name); super(href, type, links, description, tasks, id, name);
} }
private Entity() { private Entity() {

View File

@ -22,13 +22,18 @@ import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Collections;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
/** /**
@ -48,7 +53,7 @@ public abstract class EntityType<T extends EntityType<T>> extends ResourceType<T
public static abstract class NewBuilder<T extends NewBuilder<T>> extends ResourceType.NewBuilder<T> { public static abstract class NewBuilder<T extends NewBuilder<T>> extends ResourceType.NewBuilder<T> {
protected String description; protected String description;
protected TasksInProgress tasksInProgress; protected Set<Task> tasks;
protected String name; protected String name;
protected String id; protected String id;
@ -77,16 +82,16 @@ public abstract class EntityType<T extends EntityType<T>> extends ResourceType<T
} }
/** /**
* @see EntityType#getTasksInProgress() * @see EntityType#getTasks()
*/ */
public T tasksInProgress(TasksInProgress tasksInProgress) { public T tasks(Set<Task> tasks) {
this.tasksInProgress = tasksInProgress; this.tasks = tasks;
return self(); return self();
} }
public T fromEntityType(EntityType<?> in) { public T fromEntityType(EntityType<?> in) {
return fromResourceType(in) return fromResourceType(in)
.description(in.getDescription()).tasksInProgress(in.getTasksInProgress()) .description(in.getDescription()).tasks(in.getTasks())
.id(in.getId()).name(in.getName()); .id(in.getId()).name(in.getName());
} }
} }
@ -94,7 +99,7 @@ public abstract class EntityType<T extends EntityType<T>> extends ResourceType<T
public static abstract class Builder<T extends EntityType<T>> extends ResourceType.Builder<T> { public static abstract class Builder<T extends EntityType<T>> extends ResourceType.Builder<T> {
protected String description; protected String description;
protected TasksInProgress tasksInProgress; protected Set<Task> tasks;
protected String name; protected String name;
protected String id; protected String id;
@ -121,12 +126,23 @@ public abstract class EntityType<T extends EntityType<T>> extends ResourceType<T
this.id = id; this.id = id;
return this; return this;
} }
/**
* @see EntityType#getTasks()
*/
public Builder<T> tasks(Set<Task> tasks) {
if (checkNotNull(tasks, "tasks").size() > 0)
this.tasks = Sets.newLinkedHashSet(tasks);
return this;
}
/** /**
* @see EntityType#getTasksInProgress() * @see EntityType#getTasks()
*/ */
public Builder<T> tasksInProgress(TasksInProgress tasksInProgress) { public Builder<T> task(Task task) {
this.tasksInProgress = tasksInProgress; if (tasks == null)
tasks = Sets.newLinkedHashSet();
this.tasks.add(checkNotNull(task, "task"));
return this; return this;
} }
@ -151,19 +167,19 @@ public abstract class EntityType<T extends EntityType<T>> extends ResourceType<T
/** /**
* @see ResourceType#getLinks() * @see ResourceType#getLinks()
*/ */
@SuppressWarnings("unchecked")
@Override @Override
public Builder<T> links(Set<Link> links) { public Builder<T> links(Set<Link> links) {
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); return Builder.class.cast(super.links(links));
return this;
} }
/** /**
* @see ResourceType#getLinks() * @see ResourceType#getLinks()
*/ */
@SuppressWarnings("unchecked")
@Override @Override
public Builder<T> link(Link link) { public Builder<T> link(Link link) {
this.links.add(checkNotNull(link, "link")); return Builder.class.cast(super.link(link));
return this;
} }
/** /**
@ -177,24 +193,26 @@ public abstract class EntityType<T extends EntityType<T>> extends ResourceType<T
public Builder<T> fromEntityType(EntityType<T> in) { public Builder<T> fromEntityType(EntityType<T> in) {
return fromResourceType(in) return fromResourceType(in)
.description(in.getDescription()).tasksInProgress(in.getTasksInProgress()) .description(in.getDescription()).tasks(in.getTasks())
.id(in.getId()).name(in.getName()); .id(in.getId()).name(in.getName());
} }
} }
@XmlElement(name = "Description") @XmlElement(name = "Description")
private String description; private String description;
@XmlElement(name = "Tasks") @XmlElementWrapper(name = "Tasks")
private TasksInProgress tasksInProgress; @XmlElement(name = "Task")
private Set<Task> tasks;
@XmlAttribute @XmlAttribute
private String id; private String id;
@XmlAttribute(required = true) @XmlAttribute(required = true)
private String name; private String name;
public EntityType(URI href, String type, Set<Link> links, String description, TasksInProgress tasksInProgress, String id, String name) { public EntityType(URI href, String type, @Nullable Set<Link> links, String description, @Nullable Set<Task> tasks, String id, String name) {
super(href, type, links); super(href, type, links);
this.description = description; this.description = description;
this.tasksInProgress = tasksInProgress; // nullable so that jaxb wont persist empty collections
this.tasks = tasks != null && tasks.size() == 0 ? null : tasks;
this.id = id; this.id = id;
this.name = name; this.name = name;
} }
@ -213,8 +231,8 @@ public abstract class EntityType<T extends EntityType<T>> extends ResourceType<T
/** /**
* A list of queued, running, or recently completed tasks associated with this entity. * A list of queued, running, or recently completed tasks associated with this entity.
*/ */
public TasksInProgress getTasksInProgress() { public Set<Task> getTasks() {
return tasksInProgress; return tasks == null ? ImmutableSet.<Task>of() : Collections.unmodifiableSet(tasks);
} }
/** /**
@ -243,7 +261,7 @@ public abstract class EntityType<T extends EntityType<T>> extends ResourceType<T
EntityType<?> that = EntityType.class.cast(o); EntityType<?> that = EntityType.class.cast(o);
return super.equals(that) && return super.equals(that) &&
equal(this.id, that.id) && equal(this.description, that.description) && equal(this.id, that.id) && equal(this.description, that.description) &&
equal(this.tasksInProgress, that.tasksInProgress) && equal(this.name, that.name); equal(this.tasks, that.tasks) && equal(this.name, that.name);
} }
@Override @Override
@ -258,11 +276,11 @@ public abstract class EntityType<T extends EntityType<T>> extends ResourceType<T
@Override @Override
public int hashCode() { public int hashCode() {
return super.hashCode() + Objects.hashCode(description, tasksInProgress, id, name); return super.hashCode() + Objects.hashCode(description, tasks, id, name);
} }
@Override @Override
public ToStringHelper string() { public ToStringHelper string() {
return super.string().add("description", description).add("tasksInProgress", tasksInProgress).add("id", id).add("name", name); return super.string().add("description", description).add("tasks", tasks).add("id", id).add("name", name);
} }
} }

View File

@ -20,10 +20,10 @@
package org.jclouds.vcloud.director.v1_5.domain; package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal; import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlSchemaType; import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
@ -32,7 +32,6 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.Sets;
/** /**
@ -98,7 +97,7 @@ public class File extends EntityType<File> {
} }
public File build() { public File build() {
return new File(href, type, links, description, tasksInProgress, id, name, size, bytesTransferred, checksum); return new File(href, type, links, description, tasks, id, name, size, bytesTransferred, checksum);
} }
@ -127,11 +126,11 @@ public class File extends EntityType<File> {
} }
/** /**
* @see EntityType#getTasksInProgress() * @see EntityType#getTasks()
*/ */
@Override @Override
public Builder tasksInProgress(TasksInProgress tasksInProgress) { public Builder tasks(Set<Task> tasks) {
super.tasksInProgress (tasksInProgress); super.tasks (tasks);
return this; return this;
} }
@ -158,7 +157,7 @@ public class File extends EntityType<File> {
*/ */
@Override @Override
public Builder links(Set<Link> links) { public Builder links(Set<Link> links) {
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); super.links(links);
return this; return this;
} }
@ -167,7 +166,7 @@ public class File extends EntityType<File> {
*/ */
@Override @Override
public Builder link(Link link) { public Builder link(Link link) {
this.links.add(checkNotNull(link, "link")); super.link(link);
return this; return this;
} }
@ -185,9 +184,9 @@ public class File extends EntityType<File> {
} }
} }
public File(URI href, String type, Set<Link> links, String description, TasksInProgress tasksInProgress, String id, public File(URI href, String type, Set<Link> links, String description, Set<Task> tasks, String id,
String name, Long size, Long bytesTransferred, String checksum) { String name, Long size, Long bytesTransferred, String checksum) {
super(href, type, links, description, tasksInProgress, id, name); super(href, type, links, description, tasks, id, name);
this.size = size; this.size = size;
this.bytesTransferred = bytesTransferred; this.bytesTransferred = bytesTransferred;
this.checksum = checksum; this.checksum = checksum;

View File

@ -21,8 +21,6 @@ package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal; import static com.google.common.base.Objects.equal;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;

View File

@ -22,7 +22,6 @@ package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal; import static com.google.common.base.Objects.equal;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects; import com.google.common.base.Objects;

View File

@ -106,7 +106,7 @@ public class Group extends EntityType<Group> {
} }
public Group build() { public Group build() {
return new Group(href, type, links, description, tasksInProgress, id, name, return new Group(href, type, links, description, tasks, id, name,
nameInSource, usersList, role); nameInSource, usersList, role);
} }
@ -138,11 +138,11 @@ public class Group extends EntityType<Group> {
} }
/** /**
* @see EntityType#getTasksInProgress() * @see EntityType#getTasks()
*/ */
@Override @Override
public Builder tasksInProgress(TasksInProgress tasksInProgress) { public Builder tasks(Set<Task> tasks) {
super.tasksInProgress(tasksInProgress); super.tasks(tasks);
return this; return this;
} }
@ -200,9 +200,9 @@ public class Group extends EntityType<Group> {
} }
public Group(URI href, String type, Set<Link> links, String description, public Group(URI href, String type, Set<Link> links, String description,
TasksInProgress tasksInProgress, String id, String name, String nameInSource, Set<Task> tasks, String id, String name, String nameInSource,
UsersList usersList, Reference role) { UsersList usersList, Reference role) {
super(href, type, links, description, tasksInProgress, id, name); super(href, type, links, description, tasks, id, name);
this.nameInSource = nameInSource; this.nameInSource = nameInSource;
this.usersList = usersList; this.usersList = usersList;
this.role = role; this.role = role;

View File

@ -62,7 +62,7 @@ import com.google.common.collect.ImmutableList;
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "GroupsList") @XmlRootElement(name = "GroupsList")
@XmlType(propOrder = { @XmlType(propOrder = {
"groupReference" "groups"
}) })
public class GroupsList { public class GroupsList {
public static Builder builder() { public static Builder builder() {

View File

@ -25,6 +25,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Collections; import java.util.Collections;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;

View File

@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collections; import java.util.Collections;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;

View File

@ -20,7 +20,6 @@
package org.jclouds.vcloud.director.v1_5.domain; package org.jclouds.vcloud.director.v1_5.domain;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/** /**

View File

@ -25,6 +25,7 @@ import java.net.URI;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;

View File

@ -24,6 +24,7 @@ import java.net.URI;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@ -89,7 +90,7 @@ public class Media extends ResourceEntityType<Media> {
@Override @Override
public Media build() { public Media build() {
return new Media(href, type, links, description, tasksInProgress, id, name, files, status, owner, imageType, size); return new Media(href, type, links, description, tasks, id, name, files, status, owner, imageType, size);
} }
/** /**
@ -138,11 +139,11 @@ public class Media extends ResourceEntityType<Media> {
} }
/** /**
* @see EntityType#getTasksInProgress() * @see EntityType#getTasks()
*/ */
@Override @Override
public Builder tasksInProgress(TasksInProgress tasksInProgress) { public Builder tasks(Set<Task> tasks) {
super.tasksInProgress(tasksInProgress); super.tasks(tasks);
return this; return this;
} }
@ -193,9 +194,9 @@ public class Media extends ResourceEntityType<Media> {
} }
public Media(URI href, String type, Set<Link> links, String description, TasksInProgress tasksInProgress, String id, public Media(URI href, String type, Set<Link> links, String description, Set<Task> tasks, String id,
String name, FilesList files, Integer status, Owner owner, String imageType, long size) { String name, FilesList files, Integer status, Owner owner, String imageType, long size) {
super(href, type, links, description, tasksInProgress, id, name, files, status); super(href, type, links, description, tasks, id, name, files, status);
this.owner = owner; this.owner = owner;
this.imageType = imageType; this.imageType = imageType;
this.size = size; this.size = size;

View File

@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Collections; import java.util.Collections;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;

View File

@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;

View File

@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;

View File

@ -22,9 +22,7 @@ package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal; import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;

View File

@ -25,6 +25,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Collections; import java.util.Collections;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;

View File

@ -25,6 +25,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Collections; import java.util.Collections;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;

View File

@ -19,16 +19,15 @@
package org.jclouds.vcloud.director.v1_5.domain; package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal; import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.Sets;
@XmlRootElement(name = "NetworkType") @XmlRootElement(name = "NetworkType")
public class NetworkType<T extends NetworkType<T>> extends EntityType<T> { public class NetworkType<T extends NetworkType<T>> extends EntityType<T> {
@ -56,7 +55,7 @@ public class NetworkType<T extends NetworkType<T>> extends EntityType<T> {
@Override @Override
public NetworkType<T> build() { public NetworkType<T> build() {
return new NetworkType<T>(href, type, links, description, tasksInProgress, id, name, networkConfiguration); return new NetworkType<T>(href, type, links, description, tasks, id, name, networkConfiguration);
} }
/** /**
@ -85,13 +84,13 @@ public class NetworkType<T extends NetworkType<T>> extends EntityType<T> {
this.id = id; this.id = id;
return this; return this;
} }
/** /**
* @see EntityType#getTasksInProgress() * @see EntityType#getTasks()
*/ */
@Override @Override
public Builder<T> tasksInProgress(TasksInProgress tasksInProgress) { public Builder<T> tasks(Set<Task> tasks) {
this.tasksInProgress = tasksInProgress; super.tasks(tasks);
return this; return this;
} }
@ -118,7 +117,7 @@ public class NetworkType<T extends NetworkType<T>> extends EntityType<T> {
*/ */
@Override @Override
public Builder<T> links(Set<Link> links) { public Builder<T> links(Set<Link> links) {
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); super.links(links);
return this; return this;
} }
@ -127,7 +126,7 @@ public class NetworkType<T extends NetworkType<T>> extends EntityType<T> {
*/ */
@Override @Override
public Builder<T> link(Link link) { public Builder<T> link(Link link) {
this.links.add(checkNotNull(link, "link")); super.link(link);
return this; return this;
} }
@ -145,9 +144,9 @@ public class NetworkType<T extends NetworkType<T>> extends EntityType<T> {
} }
} }
public NetworkType(URI href, String type, Set<Link> links, String description, TasksInProgress tasksInProgress, public NetworkType(URI href, String type, Set<Link> links, String description, Set<Task> tasks,
String id, String name, NetworkConfiguration networkConfiguration) { String id, String name, NetworkConfiguration networkConfiguration) {
super(href, type, links, description, tasksInProgress, id, name); super(href, type, links, description, tasks, id, name);
this.networkConfiguration = networkConfiguration; this.networkConfiguration = networkConfiguration;
} }

View File

@ -33,6 +33,7 @@ import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
/** /**
@ -62,7 +63,7 @@ import com.google.common.collect.ImmutableList;
*/ */
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Networks", propOrder = { @XmlType(name = "Networks", propOrder = {
"network" "networks"
}) })
public class Networks { public class Networks {
public static Builder builder() { public static Builder builder() {
@ -75,7 +76,7 @@ public class Networks {
public static class Builder { public static class Builder {
private List<Reference> networks; private List<Reference> networks = Lists.newArrayList();
/** /**
* @see Networks#getNetwork() * @see Networks#getNetwork()

View File

@ -59,8 +59,8 @@ public class Org extends EntityType<Org> {
public static abstract class NewBuilder<T extends NewBuilder<T>> extends EntityType.NewBuilder<T> { public static abstract class NewBuilder<T extends NewBuilder<T>> extends EntityType.NewBuilder<T> {
private String fullName; protected String fullName;
private Boolean isEnabled; protected Boolean isEnabled;
/** /**
* @see Org#getFullName() * @see Org#getFullName()
@ -80,7 +80,7 @@ public class Org extends EntityType<Org> {
@Override @Override
public Org build() { public Org build() {
return new Org(href, type, links, description, tasksInProgress, id, name, fullName, isEnabled); return new Org(href, type, links, description, tasks, id, name, fullName, isEnabled);
} }
public T fromOrg(Org in) { public T fromOrg(Org in) {
@ -143,7 +143,7 @@ public class Org extends EntityType<Org> {
@Override @Override
public Org build() { public Org build() {
return new Org(href, type, links, description, tasksInProgress, id, name, fullName, isEnabled); return new Org(href, type, links, description, tasks, id, name, fullName, isEnabled);
} }
/** /**
@ -174,11 +174,11 @@ public class Org extends EntityType<Org> {
} }
/** /**
* @see EntityType#getTasksInProgress() * @see EntityType#getTasks()
*/ */
@Override @Override
public Builder tasksInProgress(TasksInProgress tasksInProgress) { public Builder tasks(Set<Task> tasks) {
this.tasksInProgress = tasksInProgress; super.tasks(tasks);
return this; return this;
} }
@ -232,7 +232,9 @@ public class Org extends EntityType<Org> {
// for JAXB // for JAXB
} }
public Org(URI href, String type, Set<Link> links, String description, TasksInProgress tasksInProgress, String id, String name, String fullName, Boolean enabled) { public Org(URI href, String type, Set<Link> links, String description,
Set<Task> tasksInProgress, String id, String name,
String fullName, Boolean enabled) {
super(href, type, links, description, tasksInProgress, id, name); super(href, type, links, description, tasksInProgress, id, name);
this.fullName = fullName; this.fullName = fullName;
isEnabled = enabled; isEnabled = enabled;

View File

@ -76,7 +76,7 @@ import com.google.common.collect.ImmutableList;
"fromEmailAddress", "fromEmailAddress",
"defaultSubjectPrefix", "defaultSubjectPrefix",
"isAlertEmailToAllAdmins", "isAlertEmailToAllAdmins",
"alertEmailTo", "alertEmailsTo",
"smtpServerSettings" "smtpServerSettings"
}) })
public class OrgEmailSettings extends ResourceType<OrgEmailSettings> { public class OrgEmailSettings extends ResourceType<OrgEmailSettings> {
@ -142,7 +142,7 @@ public class OrgEmailSettings extends ResourceType<OrgEmailSettings> {
* @see OrgEmailSettings#getAlertEmailTo() * @see OrgEmailSettings#getAlertEmailTo()
*/ */
public Builder alertEmailsTo(List<String> alertEmailsTo) { public Builder alertEmailsTo(List<String> alertEmailsTo) {
this.alertEmailTo = ImmutableList.copyOf(alertEmailsTo); this.alertEmailTo = alertEmailsTo == null ? null : ImmutableList.copyOf(alertEmailsTo);
return this; return this;
} }
@ -163,7 +163,8 @@ public class OrgEmailSettings extends ResourceType<OrgEmailSettings> {
} }
public OrgEmailSettings build() { public OrgEmailSettings build() {
return new OrgEmailSettings(isDefaultSmtpServer, isDefaultOrgEmail, fromEmailAddress, defaultSubjectPrefix, return new OrgEmailSettings(href, type, links, isDefaultSmtpServer,
isDefaultOrgEmail, fromEmailAddress, defaultSubjectPrefix,
isAlertEmailToAllAdmins, alertEmailTo, smtpServerSettings); isAlertEmailToAllAdmins, alertEmailTo, smtpServerSettings);
} }
@ -225,9 +226,11 @@ public class OrgEmailSettings extends ResourceType<OrgEmailSettings> {
// For JAXB // For JAXB
} }
private OrgEmailSettings(boolean isDefaultSmtpServer, boolean isDefaultOrgEmail, private OrgEmailSettings(URI href, String type, Set<Link> links,
boolean isDefaultSmtpServer, boolean isDefaultOrgEmail,
String fromEmailAddress, String defaultSubjectPrefix, boolean isAlertEmailToAllAdmins, String fromEmailAddress, String defaultSubjectPrefix, boolean isAlertEmailToAllAdmins,
List<String> alertEmailTo, SmtpServerSettings smtpServerSettings) { List<String> alertEmailTo, SmtpServerSettings smtpServerSettings) {
super(href, type, links);
this.isDefaultSmtpServer = isDefaultSmtpServer; this.isDefaultSmtpServer = isDefaultSmtpServer;
this.isDefaultOrgEmail = isDefaultOrgEmail; this.isDefaultOrgEmail = isDefaultOrgEmail;
this.fromEmailAddress = fromEmailAddress; this.fromEmailAddress = fromEmailAddress;
@ -323,9 +326,6 @@ public class OrgEmailSettings extends ResourceType<OrgEmailSettings> {
* *
*/ */
public List<String> getAlertEmailsTo() { public List<String> getAlertEmailsTo() {
if (alertEmailsTo == null) {
alertEmailsTo = new ArrayList<String>();
}
return this.alertEmailsTo; return this.alertEmailsTo;
} }

View File

@ -63,7 +63,7 @@ import com.google.common.base.Objects.ToStringHelper;
* *
*/ */
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "OrgGeneralSettings") @XmlRootElement(name = "GeneralOrgSettings")
@XmlType(propOrder = { @XmlType(propOrder = {
"canPublishCatalogs", "canPublishCatalogs",
"deployedVMQuota", "deployedVMQuota",

View File

@ -22,11 +22,14 @@ package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal; import static com.google.common.base.Objects.equal;
import java.net.URI; import java.net.URI;
import java.util.Arrays;
import java.util.List;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects; import com.google.common.base.Objects;
@ -60,12 +63,28 @@ import com.google.common.base.Objects.ToStringHelper;
* *
*/ */
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "OrgLdapSettings", propOrder = { @XmlRootElement(name = "OrgLdapSettings")
"orgLdapMode", @XmlType(propOrder = {
"ldapMode",
"customUsersOu", "customUsersOu",
"customOrgLdapSettings" "customOrgLdapSettings"
}) })
public class OrgLdapSettings extends ResourceType<OrgLdapSettings> { public class OrgLdapSettings extends ResourceType<OrgLdapSettings> {
public static final class LdapMode {
public static final String NONE = "NONE";
public static final String SYSTEM = "SYSTEM";
public static final String CUSTOM = "CUSTOM";
/**
* All acceptable {@link OrgLdapSettings#getLdapMode()} values.
* <p/>
* This list must be updated whenever a new mode is added.
*/
public static final List<String> ALL = Arrays.asList(
NONE, SYSTEM, CUSTOM
);
}
public static Builder builder() { public static Builder builder() {
return new Builder(); return new Builder();
} }
@ -76,15 +95,15 @@ public class OrgLdapSettings extends ResourceType<OrgLdapSettings> {
public static class Builder extends ResourceType.Builder<OrgLdapSettings> { public static class Builder extends ResourceType.Builder<OrgLdapSettings> {
private String orgLdapMode; private String ldapMode;
private String customUsersOu; private String customUsersOu;
private CustomOrgLdapSettings customOrgLdapSettings; private CustomOrgLdapSettings customOrgLdapSettings;
/** /**
* @see OrgLdapSettings#getOrgLdapMode() * @see OrgLdapSettings#getLdapMode()
*/ */
public Builder orgLdapMode(String orgLdapMode) { public Builder ldapMode(String ldapMode) {
this.orgLdapMode = orgLdapMode; this.ldapMode = ldapMode;
return this; return this;
} }
@ -106,7 +125,7 @@ public class OrgLdapSettings extends ResourceType<OrgLdapSettings> {
public OrgLdapSettings build() { public OrgLdapSettings build() {
OrgLdapSettings orgLdapSettings = new OrgLdapSettings(href, type, links, OrgLdapSettings orgLdapSettings = new OrgLdapSettings(href, type, links,
orgLdapMode, customUsersOu, customOrgLdapSettings); ldapMode, customUsersOu, customOrgLdapSettings);
return orgLdapSettings; return orgLdapSettings;
} }
@ -154,7 +173,7 @@ public class OrgLdapSettings extends ResourceType<OrgLdapSettings> {
} }
public Builder fromOrgLdapSettings(OrgLdapSettings in) { public Builder fromOrgLdapSettings(OrgLdapSettings in) {
return fromResourceType(in) return fromResourceType(in)
.orgLdapMode(in.getOrgLdapMode()) .ldapMode(in.getLdapMode())
.customUsersOu(in.getCustomUsersOu()) .customUsersOu(in.getCustomUsersOu())
.customOrgLdapSettings(in.getCustomOrgLdapSettings()); .customOrgLdapSettings(in.getCustomOrgLdapSettings());
} }
@ -166,9 +185,9 @@ public class OrgLdapSettings extends ResourceType<OrgLdapSettings> {
} }
public OrgLdapSettings(URI href, String type, Set<Link> links, public OrgLdapSettings(URI href, String type, Set<Link> links,
String orgLdapMode, String customUsersOu, CustomOrgLdapSettings customOrgLdapSettings) { String ldapMode, String customUsersOu, CustomOrgLdapSettings customOrgLdapSettings) {
super(href, type, links); super(href, type, links);
this.orgLdapMode = orgLdapMode; this.ldapMode = ldapMode;
this.customUsersOu = customUsersOu; this.customUsersOu = customUsersOu;
this.customOrgLdapSettings = customOrgLdapSettings; this.customOrgLdapSettings = customOrgLdapSettings;
} }
@ -176,7 +195,7 @@ public class OrgLdapSettings extends ResourceType<OrgLdapSettings> {
@XmlElement(name = "OrgLdapMode") @XmlElement(name = "OrgLdapMode")
protected String orgLdapMode; protected String ldapMode;
@XmlElement(name = "CustomUsersOu") @XmlElement(name = "CustomUsersOu")
protected String customUsersOu; protected String customUsersOu;
@XmlElement(name = "CustomOrgLdapSettings") @XmlElement(name = "CustomOrgLdapSettings")
@ -190,8 +209,8 @@ public class OrgLdapSettings extends ResourceType<OrgLdapSettings> {
* {@link String } * {@link String }
* *
*/ */
public String getOrgLdapMode() { public String getLdapMode() {
return orgLdapMode; return ldapMode;
} }
/** /**
@ -226,7 +245,7 @@ public class OrgLdapSettings extends ResourceType<OrgLdapSettings> {
return false; return false;
OrgLdapSettings that = OrgLdapSettings.class.cast(o); OrgLdapSettings that = OrgLdapSettings.class.cast(o);
return super.equals(that) && return super.equals(that) &&
equal(orgLdapMode, that.orgLdapMode) && equal(ldapMode, that.ldapMode) &&
equal(customUsersOu, that.customUsersOu) && equal(customUsersOu, that.customUsersOu) &&
equal(customOrgLdapSettings, that.customOrgLdapSettings); equal(customOrgLdapSettings, that.customOrgLdapSettings);
} }
@ -234,7 +253,7 @@ public class OrgLdapSettings extends ResourceType<OrgLdapSettings> {
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(super.hashCode(), return Objects.hashCode(super.hashCode(),
orgLdapMode, ldapMode,
customUsersOu, customUsersOu,
customOrgLdapSettings); customOrgLdapSettings);
} }
@ -242,7 +261,7 @@ public class OrgLdapSettings extends ResourceType<OrgLdapSettings> {
@Override @Override
public ToStringHelper string() { public ToStringHelper string() {
return super.string() return super.string()
.add("orgLdapMode", orgLdapMode) .add("orgLdapMode", ldapMode)
.add("customUsersOu", customUsersOu) .add("customUsersOu", customUsersOu)
.add("customOrgLdapSettings", customOrgLdapSettings); .add("customOrgLdapSettings", customOrgLdapSettings);
} }

View File

@ -27,6 +27,7 @@ import java.util.Set;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects; import com.google.common.base.Objects;
@ -60,7 +61,8 @@ import com.google.common.base.Objects.ToStringHelper;
* *
*/ */
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "OrgLeaseSettings", propOrder = { @XmlRootElement(name = "VAppLeaseSettings")
@XmlType(propOrder = {
"deleteOnStorageLeaseExpiration", "deleteOnStorageLeaseExpiration",
"deploymentLeaseSeconds", "deploymentLeaseSeconds",
"storageLeaseSeconds" "storageLeaseSeconds"

View File

@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collections; import java.util.Collections;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;

View File

@ -19,16 +19,15 @@
package org.jclouds.vcloud.director.v1_5.domain; package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal; import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.Sets;
@XmlRootElement(name = "OrgNetwork") @XmlRootElement(name = "OrgNetwork")
public class OrgNetwork extends NetworkType<OrgNetwork> { public class OrgNetwork extends NetworkType<OrgNetwork> {
@ -66,7 +65,7 @@ public class OrgNetwork extends NetworkType<OrgNetwork> {
@Override @Override
public OrgNetwork build() { public OrgNetwork build() {
return new OrgNetwork(href, type, links, description, tasksInProgress, id, name, networkConfiguration, return new OrgNetwork(href, type, links, description, tasks, id, name, networkConfiguration,
networkPool, allowedExternalIpAddresses); networkPool, allowedExternalIpAddresses);
} }
@ -104,13 +103,13 @@ public class OrgNetwork extends NetworkType<OrgNetwork> {
this.id = id; this.id = id;
return this; return this;
} }
/** /**
* @see EntityType#getTasksInProgress() * @see EntityType#getTasks()
*/ */
@Override @Override
public Builder tasksInProgress(TasksInProgress tasksInProgress) { public Builder tasks(Set<Task> tasks) {
this.tasksInProgress = tasksInProgress; super.tasks(tasks);
return this; return this;
} }
@ -137,7 +136,7 @@ public class OrgNetwork extends NetworkType<OrgNetwork> {
*/ */
@Override @Override
public Builder links(Set<Link> links) { public Builder links(Set<Link> links) {
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); super.links(links);
return this; return this;
} }
@ -146,7 +145,7 @@ public class OrgNetwork extends NetworkType<OrgNetwork> {
*/ */
@Override @Override
public Builder link(Link link) { public Builder link(Link link) {
this.links.add(checkNotNull(link, "link")); super.link(link);
return this; return this;
} }
@ -166,9 +165,9 @@ public class OrgNetwork extends NetworkType<OrgNetwork> {
// For JAXB // For JAXB
} }
private OrgNetwork(URI href, String type, Set<Link> links, String description, TasksInProgress tasksInProgress, private OrgNetwork(URI href, String type, Set<Link> links, String description, Set<Task> tasks,
String id, String name, NetworkConfiguration networkConfiguration, ReferenceType<?> networkPool, IpAddresses allowedExternalIpAddresses) { String id, String name, NetworkConfiguration networkConfiguration, ReferenceType<?> networkPool, IpAddresses allowedExternalIpAddresses) {
super(href, type, links, description, tasksInProgress, id, name, networkConfiguration); super(href, type, links, description, tasks, id, name, networkConfiguration);
this.networkPool = networkPool; this.networkPool = networkPool;
this.allowedExternalIpAddresses = allowedExternalIpAddresses; this.allowedExternalIpAddresses = allowedExternalIpAddresses;
} }

View File

@ -193,7 +193,7 @@ public class OrgPasswordPolicySettings extends ResourceType<OrgPasswordPolicySet
* Gets the value of the invalidLoginsBeforeLockout property. * Gets the value of the invalidLoginsBeforeLockout property.
* *
*/ */
public int getInvalidLoginsBeforeLockout() { public Integer getInvalidLoginsBeforeLockout() {
return invalidLoginsBeforeLockout; return invalidLoginsBeforeLockout;
} }
@ -201,7 +201,7 @@ public class OrgPasswordPolicySettings extends ResourceType<OrgPasswordPolicySet
* Gets the value of the accountLockoutIntervalMinutes property. * Gets the value of the accountLockoutIntervalMinutes property.
* *
*/ */
public int getAccountLockoutIntervalMinutes() { public Integer getAccountLockoutIntervalMinutes() {
return accountLockoutIntervalMinutes; return accountLockoutIntervalMinutes;
} }

View File

@ -69,12 +69,12 @@ import com.google.common.base.Objects.ToStringHelper;
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "OrgSettings") @XmlRootElement(name = "OrgSettings")
@XmlType(propOrder = { @XmlType(propOrder = {
"orgGeneralSettings", "generalSettings",
"vAppLeaseSettings", "vAppLeaseSettings",
"vAppTemplateLeaseSettings", "vAppTemplateLeaseSettings",
"orgLdapSettings", "ldapSettings",
"orgEmailSettings", "emailSettings",
"orgPasswordPolicySettings" "passwordPolicy"
}) })
public class OrgSettings extends ResourceType<OrgSettings> { public class OrgSettings extends ResourceType<OrgSettings> {
public static Builder builder() { public static Builder builder() {
@ -87,18 +87,18 @@ public class OrgSettings extends ResourceType<OrgSettings> {
public static class Builder extends ResourceType.Builder<OrgSettings> { public static class Builder extends ResourceType.Builder<OrgSettings> {
private OrgGeneralSettings orgGeneralSettings; private OrgGeneralSettings generalSettings;
private OrgLeaseSettings vAppLeaseSettings; private OrgLeaseSettings vAppLeaseSettings;
private OrgVAppTemplateLeaseSettings vAppTemplateLeaseSettings; private OrgVAppTemplateLeaseSettings vAppTemplateLeaseSettings;
private OrgLdapSettings orgLdapSettings; private OrgLdapSettings ldapSettings;
private OrgEmailSettings orgEmailSettings; private OrgEmailSettings emailSettings;
private OrgPasswordPolicySettings orgPasswordPolicySettings; private OrgPasswordPolicySettings passwordPolicy;
/** /**
* @see OrgSettings#getOrgGeneralSettings() * @see OrgSettings#getGeneralSettings()
*/ */
public Builder orgGeneralSettings(OrgGeneralSettings orgGeneralSettings) { public Builder generalSettings(OrgGeneralSettings generalSettings) {
this.orgGeneralSettings = orgGeneralSettings; this.generalSettings = generalSettings;
return this; return this;
} }
@ -119,32 +119,32 @@ public class OrgSettings extends ResourceType<OrgSettings> {
} }
/** /**
* @see OrgSettings#getOrgLdapSettings() * @see OrgSettings#getLdapSettings()
*/ */
public Builder orgLdapSettings(OrgLdapSettings orgLdapSettings) { public Builder ldapSettings(OrgLdapSettings ldapSettings) {
this.orgLdapSettings = orgLdapSettings; this.ldapSettings = ldapSettings;
return this; return this;
} }
/** /**
* @see OrgSettings#getOrgEmailSettings() * @see OrgSettings#getEmailSettings()
*/ */
public Builder orgEmailSettings(OrgEmailSettings orgEmailSettings) { public Builder emailSettings(OrgEmailSettings emailSettings) {
this.orgEmailSettings = orgEmailSettings; this.emailSettings = emailSettings;
return this; return this;
} }
/** /**
* @see OrgSettings#getOrgPasswordPolicySettings() * @see OrgSettings#getPasswordPolicy()
*/ */
public Builder orgPasswordPolicySettings(OrgPasswordPolicySettings orgPasswordPolicySettings) { public Builder passwordPolicy(OrgPasswordPolicySettings passwordPolicy) {
this.orgPasswordPolicySettings = orgPasswordPolicySettings; this.passwordPolicy = passwordPolicy;
return this; return this;
} }
public OrgSettings build() { public OrgSettings build() {
return new OrgSettings(href, type, links, orgGeneralSettings, vAppLeaseSettings, return new OrgSettings(href, type, links, generalSettings, vAppLeaseSettings,
vAppTemplateLeaseSettings, orgLdapSettings, orgEmailSettings, orgPasswordPolicySettings); vAppTemplateLeaseSettings, ldapSettings, emailSettings, passwordPolicy);
} }
@ -191,12 +191,12 @@ public class OrgSettings extends ResourceType<OrgSettings> {
} }
public Builder fromOrgSettings(OrgSettings in) { public Builder fromOrgSettings(OrgSettings in) {
return fromResourceType(in) return fromResourceType(in)
.orgGeneralSettings(in.getOrgGeneralSettings()) .generalSettings(in.getGeneralSettings())
.vAppLeaseSettings(in.getVAppLeaseSettings()) .vAppLeaseSettings(in.getVAppLeaseSettings())
.vAppTemplateLeaseSettings(in.getVAppTemplateLeaseSettings()) .vAppTemplateLeaseSettings(in.getVAppTemplateLeaseSettings())
.orgLdapSettings(in.getOrgLdapSettings()) .ldapSettings(in.getLdapSettings())
.orgEmailSettings(in.getOrgEmailSettings()) .emailSettings(in.getEmailSettings())
.orgPasswordPolicySettings(in.getOrgPasswordPolicySettings()); .passwordPolicy(in.getPasswordPolicy());
} }
} }
@ -205,32 +205,33 @@ public class OrgSettings extends ResourceType<OrgSettings> {
// For JAXB // For JAXB
} }
public OrgSettings(URI href, String type, Set<Link> links, public OrgSettings(URI href, String type, Set<Link> links,
OrgGeneralSettings orgGeneralSettings, OrgGeneralSettings generalSettings,
OrgLeaseSettings vAppLeaseSettings, OrgLeaseSettings vAppLeaseSettings,
OrgVAppTemplateLeaseSettings vAppTemplateLeaseSettings, OrgVAppTemplateLeaseSettings vAppTemplateLeaseSettings,
OrgLdapSettings orgLdapSettings, OrgEmailSettings orgEmailSettings, OrgLdapSettings ldapSettings, OrgEmailSettings emailSettings,
OrgPasswordPolicySettings orgPasswordPolicySettings) { OrgPasswordPolicySettings passwordPolicy) {
super(href, type, links); super(href, type, links);
this.orgGeneralSettings = orgGeneralSettings; this.generalSettings = generalSettings;
this.vAppLeaseSettings = vAppLeaseSettings; this.vAppLeaseSettings = vAppLeaseSettings;
this.vAppTemplateLeaseSettings = vAppTemplateLeaseSettings; this.vAppTemplateLeaseSettings = vAppTemplateLeaseSettings;
this.orgLdapSettings = orgLdapSettings; this.ldapSettings = ldapSettings;
this.orgPasswordPolicySettings = orgPasswordPolicySettings; this.emailSettings = emailSettings;
this.passwordPolicy = passwordPolicy;
} }
@XmlElement(name = "OrgGeneralSettings") @XmlElement(name = "OrgGeneralSettings")
protected OrgGeneralSettings orgGeneralSettings; protected OrgGeneralSettings generalSettings;
@XmlElement(name = "VAppLeaseSettings") @XmlElement(name = "VAppLeaseSettings")
protected OrgLeaseSettings vAppLeaseSettings; protected OrgLeaseSettings vAppLeaseSettings;
@XmlElement(name = "VAppTemplateLeaseSettings") @XmlElement(name = "VAppTemplateLeaseSettings")
protected OrgVAppTemplateLeaseSettings vAppTemplateLeaseSettings; protected OrgVAppTemplateLeaseSettings vAppTemplateLeaseSettings;
@XmlElement(name = "OrgLdapSettings") @XmlElement(name = "OrgLdapSettings")
protected OrgLdapSettings orgLdapSettings; protected OrgLdapSettings ldapSettings;
@XmlElement(name = "OrgEmailSettings") @XmlElement(name = "OrgEmailSettings")
protected OrgEmailSettings orgEmailSettings; protected OrgEmailSettings emailSettings;
@XmlElement(name = "OrgPasswordPolicySettings") @XmlElement(name = "OrgPasswordPolicySettings")
protected OrgPasswordPolicySettings orgPasswordPolicySettings; protected OrgPasswordPolicySettings passwordPolicy;
/** /**
* Gets the value of the orgGeneralSettings property. * Gets the value of the orgGeneralSettings property.
@ -240,8 +241,8 @@ public class OrgSettings extends ResourceType<OrgSettings> {
* {@link OrgGeneralSettings } * {@link OrgGeneralSettings }
* *
*/ */
public OrgGeneralSettings getOrgGeneralSettings() { public OrgGeneralSettings getGeneralSettings() {
return orgGeneralSettings; return generalSettings;
} }
/** /**
@ -276,8 +277,8 @@ public class OrgSettings extends ResourceType<OrgSettings> {
* {@link OrgLdapSettings } * {@link OrgLdapSettings }
* *
*/ */
public OrgLdapSettings getOrgLdapSettings() { public OrgLdapSettings getLdapSettings() {
return orgLdapSettings; return ldapSettings;
} }
/** /**
@ -288,8 +289,8 @@ public class OrgSettings extends ResourceType<OrgSettings> {
* {@link OrgEmailSettings } * {@link OrgEmailSettings }
* *
*/ */
public OrgEmailSettings getOrgEmailSettings() { public OrgEmailSettings getEmailSettings() {
return orgEmailSettings; return emailSettings;
} }
/** /**
@ -300,8 +301,8 @@ public class OrgSettings extends ResourceType<OrgSettings> {
* {@link OrgPasswordPolicySettings } * {@link OrgPasswordPolicySettings }
* *
*/ */
public OrgPasswordPolicySettings getOrgPasswordPolicySettings() { public OrgPasswordPolicySettings getPasswordPolicy() {
return orgPasswordPolicySettings; return passwordPolicy;
} }
@Override @Override
@ -312,34 +313,34 @@ public class OrgSettings extends ResourceType<OrgSettings> {
return false; return false;
OrgSettings that = OrgSettings.class.cast(o); OrgSettings that = OrgSettings.class.cast(o);
return super.equals(that) && return super.equals(that) &&
equal(orgGeneralSettings, that.orgGeneralSettings) && equal(generalSettings, that.generalSettings) &&
equal(vAppLeaseSettings, that.vAppLeaseSettings) && equal(vAppLeaseSettings, that.vAppLeaseSettings) &&
equal(vAppTemplateLeaseSettings, that.vAppTemplateLeaseSettings) && equal(vAppTemplateLeaseSettings, that.vAppTemplateLeaseSettings) &&
equal(orgLdapSettings, that.orgLdapSettings) && equal(ldapSettings, that.ldapSettings) &&
equal(orgEmailSettings, that.orgEmailSettings) && equal(emailSettings, that.emailSettings) &&
equal(orgPasswordPolicySettings, that.orgPasswordPolicySettings); equal(passwordPolicy, that.passwordPolicy);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(super.hashCode(), return Objects.hashCode(super.hashCode(),
orgGeneralSettings, generalSettings,
vAppLeaseSettings, vAppLeaseSettings,
vAppTemplateLeaseSettings, vAppTemplateLeaseSettings,
orgLdapSettings, ldapSettings,
orgEmailSettings, emailSettings,
orgPasswordPolicySettings); passwordPolicy);
} }
@Override @Override
public ToStringHelper string() { public ToStringHelper string() {
return super.string() return super.string()
.add("orgGeneralSettings", orgGeneralSettings) .add("generalSettings", generalSettings)
.add("vAppLeaseSettings", vAppLeaseSettings) .add("vAppLeaseSettings", vAppLeaseSettings)
.add("vAppTemplateLeaseSettings", vAppTemplateLeaseSettings) .add("vAppTemplateLeaseSettings", vAppTemplateLeaseSettings)
.add("orgLdapSettings", orgLdapSettings) .add("ldapSettings", ldapSettings)
.add("orgEmailSettings", orgEmailSettings) .add("emailSettings", emailSettings)
.add("orgPasswordPolicySettings", orgPasswordPolicySettings); .add("passwordPolicy", passwordPolicy);
} }
} }

View File

@ -19,17 +19,18 @@
package org.jclouds.vcloud.director.v1_5.domain; package org.jclouds.vcloud.director.v1_5.domain;
import com.google.common.base.Objects; import static com.google.common.base.Objects.equal;
import com.google.common.collect.Sets; import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
import java.net.URI;
import java.util.Set;
import static com.google.common.base.Objects.equal; import com.google.common.base.Objects;
import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.collect.Sets;
/** /**

View File

@ -25,6 +25,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Collections; import java.util.Collections;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;

View File

@ -111,4 +111,11 @@ public class Reference extends ReferenceType<Reference> {
Reference that = Reference.class.cast(o); Reference that = Reference.class.cast(o);
return super.equals(that); return super.equals(that);
} }
}
public ReferenceType<?> toAdminReference(String endpoint) {
return toBuilder()
.type(null)
.href(URI.create(getHref().toASCIIString().replace(endpoint, endpoint+"/admin")))
.build();
}
}

View File

@ -22,6 +22,7 @@ import static com.google.common.base.Objects.equal;
import java.net.URI; import java.net.URI;
import java.util.Map; import java.util.Map;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlSeeAlso; import javax.xml.bind.annotation.XmlSeeAlso;
@ -43,7 +44,7 @@ import com.google.common.base.Objects.ToStringHelper;
CatalogReference.class, CatalogReference.class,
Reference.class Reference.class
}) })
public class ReferenceType<T extends ReferenceType<T>> implements URISupplier { public class ReferenceType<T extends ReferenceType<T>> {
public static <T extends ReferenceType<T>> Builder<T> builder() { public static <T extends ReferenceType<T>> Builder<T> builder() {
return new Builder<T>(); return new Builder<T>();
@ -176,14 +177,6 @@ public class ReferenceType<T extends ReferenceType<T>> implements URISupplier {
return type; return type;
} }
/**
* @see URISupplier#getURI()
*/
@Override
public URI getURI() {
return getHref();
}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) if (this == o)

View File

@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collections; import java.util.Collections;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;

View File

@ -20,16 +20,15 @@
package org.jclouds.vcloud.director.v1_5.domain; package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal; import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.Sets;
/** /**
* Base type that represents a resource entity such as a vApp template or virtual media. * Base type that represents a resource entity such as a vApp template or virtual media.
@ -71,13 +70,13 @@ public abstract class ResourceEntityType<T extends ResourceEntityType<T>> extend
this.id = id; this.id = id;
return this; return this;
} }
/** /**
* @see EntityType#getTasksInProgress() * @see EntityType#getTasks()
*/ */
@Override @Override
public Builder<T> tasksInProgress(TasksInProgress tasksInProgress) { public Builder<T> tasks(Set<Task> tasks) {
this.tasksInProgress = tasksInProgress; super.tasks(tasks);
return this; return this;
} }
@ -100,20 +99,18 @@ public abstract class ResourceEntityType<T extends ResourceEntityType<T>> extend
} }
/** /**
* @see EntityType#getLinks() * @see ResourceEntityType#getLinks()
*/ */
@Override
public Builder<T> links(Set<Link> links) { public Builder<T> links(Set<Link> links) {
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); super.links(links);
return this; return this;
} }
/** /**
* @see EntityType#getLinks() * @see ResourceEntityType#getLinks()
*/ */
@Override
public Builder<T> link(Link link) { public Builder<T> link(Link link) {
this.links.add(checkNotNull(link, "link")); super.link(link);
return this; return this;
} }
@ -133,8 +130,8 @@ public abstract class ResourceEntityType<T extends ResourceEntityType<T>> extend
@XmlAttribute @XmlAttribute
protected Integer status; protected Integer status;
public ResourceEntityType(URI href, String type, Set<Link> links, String description, TasksInProgress tasksInProgress, String id, String name, FilesList files, Integer status) { public ResourceEntityType(URI href, String type, Set<Link> links, String description, Set<Task> tasks, String id, String name, FilesList files, Integer status) {
super(href, type, links, description, tasksInProgress, id, name); super(href, type, links, description, tasks, id, name);
this.files = files; this.files = files;
this.status = status; this.status = status;
} }

View File

@ -28,7 +28,7 @@ import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import org.jclouds.vcloud.director.v1_5.domain.EntityType.NewBuilder; import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Objects.ToStringHelper;
@ -46,7 +46,7 @@ import com.google.common.collect.Sets;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public abstract class ResourceType<T extends ResourceType<T>> implements URISupplier { public abstract class ResourceType<T extends ResourceType<T>> {
public NewBuilder<?> toNewBuilder() { public NewBuilder<?> toNewBuilder() {
throw new UnsupportedOperationException("New builder not yet implemented for this class"); throw new UnsupportedOperationException("New builder not yet implemented for this class");
@ -57,7 +57,7 @@ public abstract class ResourceType<T extends ResourceType<T>> implements URISupp
protected URI href; protected URI href;
protected String type; protected String type;
protected Set<Link> links = Sets.newLinkedHashSet(); protected Set<Link> links;
/** /**
* @see ResourceType#getHref() * @see ResourceType#getHref()
@ -87,6 +87,8 @@ public abstract class ResourceType<T extends ResourceType<T>> implements URISupp
* @see ResourceType#getLinks() * @see ResourceType#getLinks()
*/ */
public T link(Link link) { public T link(Link link) {
if (links == null)
links = Sets.newLinkedHashSet();
this.links.add(checkNotNull(link, "link")); this.links.add(checkNotNull(link, "link"));
return self(); return self();
} }
@ -104,7 +106,7 @@ public abstract class ResourceType<T extends ResourceType<T>> implements URISupp
protected URI href; protected URI href;
protected String type; protected String type;
protected Set<Link> links = Sets.newLinkedHashSet(); protected Set<Link> links;
/** /**
* @see ResourceType#getHref() * @see ResourceType#getHref()
@ -134,6 +136,8 @@ public abstract class ResourceType<T extends ResourceType<T>> implements URISupp
* @see ResourceType#getLinks() * @see ResourceType#getLinks()
*/ */
public Builder<T> link(Link link) { public Builder<T> link(Link link) {
if (links == null)
links = Sets.newLinkedHashSet();
this.links.add(checkNotNull(link, "link")); this.links.add(checkNotNull(link, "link"));
return this; return this;
} }
@ -150,12 +154,13 @@ public abstract class ResourceType<T extends ResourceType<T>> implements URISupp
@XmlAttribute @XmlAttribute
private String type; private String type;
@XmlElement(name = "Link") @XmlElement(name = "Link")
private Set<Link> links = Sets.newLinkedHashSet(); private Set<Link> links;
protected ResourceType(URI href, String type, Set<Link> links) { protected ResourceType(URI href, String type, @Nullable Set<Link> links) {
this.href = href; this.href = href;
this.type = type; this.type = type;
this.links = ImmutableSet.copyOf(links); // nullable so that jaxb wont persist empty collections
this.links = links != null && links.size() == 0 ? null : links;
} }
protected ResourceType() { protected ResourceType() {
@ -179,14 +184,6 @@ public abstract class ResourceType<T extends ResourceType<T>> implements URISupp
return href; return href;
} }
/**
* @see URISupplier#getURI()
*/
@Override
public URI getURI() {
return getHref();
}
/** /**
* Contains the type of the the entity. * Contains the type of the the entity.
* <p/> * <p/>
@ -203,7 +200,7 @@ public abstract class ResourceType<T extends ResourceType<T>> implements URISupp
* Set of optional links to an entity or operation associated with this object. * Set of optional links to an entity or operation associated with this object.
*/ */
public Set<Link> getLinks() { public Set<Link> getLinks() {
return Collections.unmodifiableSet(links); return links == null ? ImmutableSet.<Link>of() : Collections.unmodifiableSet(links);
} }
@Override @Override

View File

@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Collections; import java.util.Collections;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;

View File

@ -61,7 +61,7 @@ import com.google.common.base.Objects.ToStringHelper;
*/ */
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "SmtpServerSettings", propOrder = { @XmlType(name = "SmtpServerSettings", propOrder = {
"isUseAuthentication", "useAuthentication",
"host", "host",
"username", "username",
"password" "password"
@ -200,8 +200,7 @@ public class SmtpServerSettings {
if (o == null || getClass() != o.getClass()) if (o == null || getClass() != o.getClass())
return false; return false;
SmtpServerSettings that = SmtpServerSettings.class.cast(o); SmtpServerSettings that = SmtpServerSettings.class.cast(o);
return super.equals(that) && return equal(useAuthentication, that.useAuthentication) &&
equal(useAuthentication, that.useAuthentication) &&
equal(host, that.host) && equal(host, that.host) &&
equal(username, that.username) && equal(username, that.username) &&
equal(password, that.password); equal(password, that.password);
@ -209,8 +208,7 @@ public class SmtpServerSettings {
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(super.hashCode(), return Objects.hashCode(useAuthentication,
useAuthentication,
host, host,
username, username,
password); password);

View File

@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collections; import java.util.Collections;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;

View File

@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collections; import java.util.Collections;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;

View File

@ -19,13 +19,13 @@
package org.jclouds.vcloud.director.v1_5.domain; package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal; import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@ -34,7 +34,6 @@ import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.Sets;
/** /**
* Represents an asynchronous or long-running task in the vCloud environment. * Represents an asynchronous or long-running task in the vCloud environment.
@ -43,6 +42,8 @@ import com.google.common.collect.Sets;
* &lt;xs:complexType name="TaskType"&gt; * &lt;xs:complexType name="TaskType"&gt;
* </pre> * </pre>
* *
* TODO: this object and the hierarchy is wrong. it is literally a Task with a Task container. please review class diagram
*
* @author grkvlt@apache.org * @author grkvlt@apache.org
*/ */
@XmlRootElement(name = "Task") @XmlRootElement(name = "Task")
@ -187,7 +188,7 @@ public class Task extends EntityType<Task> {
@Override @Override
public Task build() { public Task build() {
return new Task(href, type, links, description, tasksInProgress, id, name, return new Task(href, type, links, description, tasks, id, name,
error, org, progress, owner, user, params, status, operation, operationName, startTime, endTime, expiryTime); error, org, progress, owner, user, params, status, operation, operationName, startTime, endTime, expiryTime);
} }
@ -217,13 +218,13 @@ public class Task extends EntityType<Task> {
this.id = id; this.id = id;
return this; return this;
} }
/** /**
* @see EntityType#getTasksInProgress() * @see EntityType#getTasks()
*/ */
@Override @Override
public Builder tasksInProgress(TasksInProgress tasksInProgress) { public Builder tasks(Set<Task> tasks) {
this.tasksInProgress = tasksInProgress; super.tasks(tasks);
return this; return this;
} }
@ -246,23 +247,22 @@ public class Task extends EntityType<Task> {
} }
/** /**
* @see EntityType#getLinks() * @see ResourceType#getLinks()
*/ */
@Override @Override
public Builder links(Set<Link> links) { public Builder links(Set<Link> links) {
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); return Builder.class.cast(super.links(links));
return this;
} }
/** /**
* @see EntityType#getLinks() * @see ResourceType#getLinks()
*/ */
@Override @Override
public Builder link(Link link) { public Builder link(Link link) {
this.links.add(checkNotNull(link, "link")); return Builder.class.cast(super.link(link));
return this;
} }
@Override @Override
public Builder fromEntityType(EntityType<Task> in) { public Builder fromEntityType(EntityType<Task> in) {
return Builder.class.cast(super.fromEntityType(in)); return Builder.class.cast(super.fromEntityType(in));
@ -275,11 +275,11 @@ public class Task extends EntityType<Task> {
} }
} }
public Task(URI href, String type, Set<Link> links, String description, TasksInProgress tasksInProgress, public Task(URI href, String type, Set<Link> links, String description, Set<Task> tasks,
String id, String name, Error error, Reference org, Integer progress, Reference owner, String id, String name, Error error, Reference org, Integer progress, Reference owner,
Reference user, Object params, String status, String operation, String operationName, Reference user, Object params, String status, String operation, String operationName,
Date startTime, Date endTime, Date expiryTime) { Date startTime, Date endTime, Date expiryTime) {
super(href, type, links, description, tasksInProgress, id, name); super(href, type, links, description, tasks, id, name);
this.error = error; this.error = error;
this.org = org; this.org = org;
this.progress = progress; this.progress = progress;
@ -383,6 +383,7 @@ public class Task extends EntityType<Task> {
* <li>aborted - The task was aborted by an administrative action. * <li>aborted - The task was aborted by an administrative action.
* </ul> * </ul>
*/ */
// TODO: enum!!!
public String getStatus() { public String getStatus() {
return status; return status;
} }

View File

@ -1,112 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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 CONDITIOXMLNS 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.director.v1_5.domain;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
/**
* @author grkvlt@apache.org
*/
@XmlRootElement(name = "TasksInProgress")
public class TasksInProgress {
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder();
}
public static class Builder {
protected Set<Task> tasks = Sets.newLinkedHashSet();
/**
* @see TasksInProgress#getTasks()
*/
public Builder tasks(Set<Task> tasks) {
this.tasks = ImmutableSet.copyOf(checkNotNull(tasks, "tasks"));
return this;
}
/**
* @see TasksInProgress#getTasks()
*/
public Builder task(Task task) {
this.tasks.add(checkNotNull(task, "task"));
return this;
}
public TasksInProgress build() {
return new TasksInProgress(tasks);
}
public Builder fromTasksInProgress(TasksInProgress in) {
return tasks(in.getTasks());
}
}
private TasksInProgress() {
// for JAXB
}
private TasksInProgress(Collection<Task> tasks) {
this.tasks = ImmutableSet.copyOf(tasks);
}
@XmlElement(name = "Task")
private Set<Task> tasks = Sets.newLinkedHashSet();
public Set<Task> getTasks() {
return Collections.unmodifiableSet(tasks);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
TasksInProgress that = TasksInProgress.class.cast(o);
return equal(this.tasks, that.tasks);
}
@Override
public int hashCode() {
return Objects.hashCode(tasks);
}
@Override
public String toString() {
return Objects.toStringHelper("").add("tasks", tasks).toString();
}
}

View File

@ -22,12 +22,16 @@ import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Objects.ToStringHelper;
@ -35,33 +39,36 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
/** /**
* A list of tasks. * Task List
* *
*
* @author Adrian Cole * @author Adrian Cole
*/ */
@XmlRootElement(name = "TasksList") @XmlRootElement(name = "TasksList")
public class TasksList extends EntityType<TasksList> { public class TasksList extends ResourceType<TasksList> implements Set<Task> {
public static final String MEDIA_TYPE = VCloudDirectorMediaType.TASKS_LIST;
public static Builder builder() { public static Builder builder() {
return new Builder(); return new Builder();
} }
@Override public static class Builder extends ResourceType.Builder<TasksList> {
public Builder toBuilder() { protected String name;
return new Builder();
}
public static class Builder extends EntityType.Builder<TasksList> { private Set<Task> tasks;
protected Set<Task> tasks = Sets.newLinkedHashSet(); /**
* @see TasksList#getName()
*/
public Builder name(String name) {
this.name = name;
return this;
}
/** /**
* @see TasksList#getTasks() * @see TasksList#getTasks()
*/ */
public Builder tasks(Set<Task> tasks) { public Builder tasks(Set<Task> tasks) {
this.tasks = Sets.newLinkedHashSet(checkNotNull(tasks, "tasks")); if (checkNotNull(tasks, "tasks").size() > 0)
this.tasks = Sets.newLinkedHashSet(tasks);
return this; return this;
} }
@ -69,111 +76,86 @@ public class TasksList extends EntityType<TasksList> {
* @see TasksList#getTasks() * @see TasksList#getTasks()
*/ */
public Builder task(Task task) { public Builder task(Task task) {
if (tasks == null)
tasks = Sets.newLinkedHashSet();
this.tasks.add(checkNotNull(task, "task")); this.tasks.add(checkNotNull(task, "task"));
return this; return this;
} }
@Override @Override
public TasksList build() { public TasksList build() {
return new TasksList(href, type, links, description, tasksInProgress, id, name, tasks); return new TasksList(href, type, links, name, tasks);
} }
/** /**
* @see EntityType#getName() * @see ResourceType#getHref()
*/
@Override
public Builder name(String name) {
this.name = name;
return this;
}
/**
* @see EntityType#getDescription()
*/
@Override
public Builder description(String description) {
this.description = description;
return this;
}
/**
* @see EntityType#getId()
*/
@Override
public Builder id(String id) {
this.id = id;
return this;
}
/**
* @see EntityType#getTasksInProgress()
*/
@Override
public Builder tasksInProgress(TasksInProgress tasksInProgress) {
this.tasksInProgress = tasksInProgress;
return this;
}
/**
* @see ReferenceType#getHref()
*/ */
@Override @Override
public Builder href(URI href) { public Builder href(URI href) {
this.href = href; super.href(href);
return this; return this;
} }
/** /**
* @see ReferenceType#getType() * @see ResourceType#getType()
*/ */
@Override @Override
public Builder type(String type) { public Builder type(String type) {
this.type = type; super.type(type);
return this; return this;
} }
/** /**
* @see EntityType#getLinks() * @see ResourceType#getLinks()
*/ */
@Override @Override
public Builder links(Set<Link> links) { public Builder links(Set<Link> links) {
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); return Builder.class.cast(super.links(links));
return this;
} }
/** /**
* @see EntityType#getLinks() * @see ResourceType#getLinks()
*/ */
@Override @Override
public Builder link(Link link) { public Builder link(Link link) {
this.links.add(checkNotNull(link, "link")); super.link(link);
return this; return this;
} }
@Override public Builder fromTasksList(TasksList in) {
public Builder fromEntityType(EntityType<TasksList> in) { return fromResourceType(in).tasks(in);
return Builder.class.cast(super.fromEntityType(in));
} }
public Builder fromTasksList(TasksList in) { /**
return fromEntityType(in).tasks(in.getTasks()); * {@inheritDoc}
*/
@Override
public Builder fromResourceType(ResourceType<TasksList> in) {
return Builder.class.cast(super.fromResourceType(in));
} }
} }
@XmlAttribute(required = true)
private String name;
@XmlElement(name = "Task")
private Set<Task> tasks;
public TasksList(URI href, String type, @Nullable Set<Link> links, String name, @Nullable Set<Task> tasks) {
super(href, type, links);
this.tasks = tasks;
this.name = name;
}
protected TasksList() { protected TasksList() {
// for JAXB // For JAXB
} }
public TasksList(URI href, String type, Set<Link> links, String description, TasksInProgress tasksInProgress, String id, String name, Set<Task> tasks) {
super(href, type, links, description, tasksInProgress, id, name);
this.tasks = ImmutableSet.copyOf(tasks);
}
@XmlElement(name = "Task") /**
private Set<Task> tasks = Sets.newLinkedHashSet(); * Contains the name of the the entity.
*/
public Set<Task> getTasks() { public String getName() {
return Collections.unmodifiableSet(tasks); return name;
} }
@Override @Override
@ -183,16 +165,91 @@ public class TasksList extends EntityType<TasksList> {
if (o == null || getClass() != o.getClass()) if (o == null || getClass() != o.getClass())
return false; return false;
TasksList that = TasksList.class.cast(o); TasksList that = TasksList.class.cast(o);
return super.equals(that) && equal(this.tasks, that.tasks); return super.equals(that) && equal(this.delegate(), that.delegate()) && equal(this.name, that.name);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return super.hashCode() + Objects.hashCode(tasks); return super.hashCode() + Objects.hashCode(delegate(), name);
}
private Set<Task> delegate() {
return tasks == null ? ImmutableSet.<Task>of() : Collections.unmodifiableSet(tasks);
} }
@Override @Override
public ToStringHelper string() { public ToStringHelper string() {
return super.string().add("tasks", tasks); return super.string().add("name", name).add("tasks", delegate());
} }
}
@Override
public Builder toBuilder() {
return new Builder().fromTasksList(this);
}
@Override
public Iterator<Task> iterator() {
return delegate().iterator();
}
@Override
public int size() {
return delegate().size();
}
@Override
public boolean removeAll(Collection<?> collection) {
return delegate().removeAll(collection);
}
@Override
public boolean isEmpty() {
return delegate().isEmpty();
}
@Override
public boolean contains(Object object) {
return delegate().contains(object);
}
@Override
public boolean add(Task element) {
return delegate().add(element);
}
@Override
public boolean remove(Object object) {
return delegate().remove(object);
}
@Override
public boolean containsAll(Collection<?> collection) {
return delegate().containsAll(collection);
}
@Override
public boolean addAll(Collection<? extends Task> collection) {
return delegate().addAll(collection);
}
@Override
public boolean retainAll(Collection<?> collection) {
return delegate().retainAll(collection);
}
@Override
public void clear() {
delegate().clear();
}
@Override
public Object[] toArray() {
return delegate().toArray();
}
@Override
public <T> T[] toArray(T[] array) {
return delegate().toArray(array);
}
}

View File

@ -1,47 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.director.v1_5.domain;
import java.net.URI;
/**
* @author grkvlt@apache.org
*/
public interface URISupplier {
/**
* This returns the {@link URI} for a particular {@link ReferenceType} or {@link ResourceType} object.
*
* @see ResourceType#getHref()
* @see ReferenceType#getHref()
*/
public URI getURI();
public static class SingleURI {
public static URISupplier fromURI(final URI uri) {
return new URISupplier(){
@Override
public URI getURI() {
return uri;
}
};
}
}
}

View File

@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
@ -269,7 +270,7 @@ public class User
public User build() { public User build() {
return new User(href, type, links, description, tasksInProgress, id, return new User(href, type, links, description, tasks, id,
name, fullName, emailAddress, telephone, isEnabled, isLocked, name, fullName, emailAddress, telephone, isEnabled, isLocked,
im, nameInSource, isAlertEnabled, alertEmailPrefix, alertEmail, im, nameInSource, isAlertEnabled, alertEmailPrefix, alertEmail,
isExternal, isDefaultCached, isGroupRole, storedVmQuota, deployedVmQuota, isExternal, isDefaultCached, isGroupRole, storedVmQuota, deployedVmQuota,
@ -285,13 +286,13 @@ public class User
this.id = id; this.id = id;
return this; return this;
} }
/** /**
* @see EntityType#getTasksInProgress() * @see EntityType#getTasks()
*/ */
@Override @Override
public Builder tasksInProgress(TasksInProgress tasksInProgress) { public Builder tasks(Set<Task> tasks) {
this.tasksInProgress = tasksInProgress; super.tasks(tasks);
return this; return this;
} }
@ -397,12 +398,12 @@ public class User
@XmlElement(name = "GroupReferences") @XmlElement(name = "GroupReferences")
protected Object /* GroupsList */ groupReferences; protected Object /* GroupsList */ groupReferences;
public User(URI href, String type, Set<Link> links, String description, TasksInProgress tasksInProgress, String id, public User(URI href, String type, Set<Link> links, String description, Set<Task> tasks, String id,
String name, String fullName, String emailAddress, String telephone, Boolean enabled, Boolean locked, String name, String fullName, String emailAddress, String telephone, Boolean enabled, Boolean locked,
String im, String nameInSource, Boolean alertEnabled, String alertEmailPrefix, String alertEmail, String im, String nameInSource, Boolean alertEnabled, String alertEmailPrefix, String alertEmail,
Boolean external, Boolean defaultCached, Boolean groupRole, Integer storedVmQuota, Integer deployedVmQuota, Boolean external, Boolean defaultCached, Boolean groupRole, Integer storedVmQuota, Integer deployedVmQuota,
Reference role, String password, Object groupReferences) { Reference role, String password, Object groupReferences) {
super(href, type, links, description, tasksInProgress, id, name); super(href, type, links, description, tasks, id, name);
this.fullName = fullName; this.fullName = fullName;
this.emailAddress = emailAddress; this.emailAddress = emailAddress;
this.telephone = telephone; this.telephone = telephone;

View File

@ -33,6 +33,7 @@ import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
/** /**
@ -62,7 +63,7 @@ import com.google.common.collect.ImmutableList;
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "UsersList") @XmlRootElement(name = "UsersList")
@XmlType(propOrder = { @XmlType(propOrder = {
"userReference" "users"
}) })
public class UsersList { public class UsersList {
public static Builder builder() { public static Builder builder() {
@ -74,7 +75,7 @@ public class UsersList {
} }
public static class Builder { public static class Builder {
private List<Reference> users; private List<Reference> users = Lists.newArrayList();
/** /**
* @see UsersList#getUsers() * @see UsersList#getUsers()

View File

@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;

View File

@ -25,6 +25,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Collections; import java.util.Collections;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementRef; import javax.xml.bind.annotation.XmlElementRef;
@ -144,7 +145,7 @@ public class VAppTemplate extends ResourceEntityType<VAppTemplate> {
@Override @Override
public VAppTemplate build() { public VAppTemplate build() {
return new VAppTemplate(href, type, links, description, tasksInProgress, id, name, files, status, owner, children, sections, vAppScopedLocalId, ovfDescriptorUploaded, goldMaster); return new VAppTemplate(href, type, links, description, tasks, id, name, files, status, owner, children, sections, vAppScopedLocalId, ovfDescriptorUploaded, goldMaster);
} }
@Override @Override
@ -209,11 +210,11 @@ public class VAppTemplate extends ResourceEntityType<VAppTemplate> {
} }
/** /**
* @see EntityType#getTasksInProgress() * @see EntityType#getTasks()
*/ */
@Override @Override
public Builder tasksInProgress(TasksInProgress tasksInProgress) { public Builder tasks(Set<Task> tasks) {
super.tasksInProgress(tasksInProgress); super.tasks(tasks);
return this; return this;
} }
@ -267,10 +268,10 @@ public class VAppTemplate extends ResourceEntityType<VAppTemplate> {
@XmlAttribute @XmlAttribute
protected Boolean goldMaster; protected Boolean goldMaster;
private VAppTemplate(URI href, String type, Set<Link> links, String description, TasksInProgress tasksInProgress, private VAppTemplate(URI href, String type, Set<Link> links, String description, Set<Task> tasks,
String id, String name, FilesList files, Integer status, Owner owner, Set<VAppTemplate> children, String id, String name, FilesList files, Integer status, Owner owner, Set<VAppTemplate> children,
Set<? extends SectionType<?>> sections, String vAppScopedLocalId, Boolean ovfDescriptorUploaded, Boolean goldMaster) { Set<? extends SectionType<?>> sections, String vAppScopedLocalId, Boolean ovfDescriptorUploaded, Boolean goldMaster) {
super(href, type, links, description, tasksInProgress, id, name, files, status); super(href, type, links, description, tasks, id, name, files, status);
this.owner = owner; this.owner = owner;
this.children = VAppTemplateChildren.builder().vms(children).build(); this.children = VAppTemplateChildren.builder().vms(children).build();
this.sections = ImmutableSet.copyOf(sections); this.sections = ImmutableSet.copyOf(sections);

View File

@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collections; import java.util.Collections;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;

View File

@ -20,10 +20,10 @@
package org.jclouds.vcloud.director.v1_5.domain; package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal; import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@ -31,7 +31,6 @@ import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.collect.Sets;
/** /**
@ -198,7 +197,7 @@ public class Vdc
public Vdc build() { public Vdc build() {
return new Vdc( return new Vdc(
href, type, links, description, tasksInProgress, id, name, allocationModel, storageCapacity, href, type, links, description, tasks, id, name, allocationModel, storageCapacity,
computeCapacity, resourceEntities, availableNetworks, capabilities, nicQuota, networkQuota, computeCapacity, resourceEntities, availableNetworks, capabilities, nicQuota, networkQuota,
vmQuota, isEnabled, status); vmQuota, isEnabled, status);
} }
@ -227,13 +226,13 @@ public class Vdc
this.id = id; this.id = id;
return this; return this;
} }
/** /**
* @see EntityType#getTasksInProgress() * @see EntityType#getTasks()
*/ */
@Override @Override
public Builder tasksInProgress(TasksInProgress tasksInProgress) { public Builder tasks(Set<Task> tasks) {
this.tasksInProgress = tasksInProgress; super.tasks(tasks);
return this; return this;
} }
@ -254,13 +253,13 @@ public class Vdc
this.type = type; this.type = type;
return this; return this;
} }
/** /**
* @see EntityType#getLinks() * @see EntityType#getLinks()
*/ */
@Override @Override
public Builder links(Set<Link> links) { public Builder links(Set<Link> links) {
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); super.links(links);
return this; return this;
} }
@ -269,11 +268,10 @@ public class Vdc
*/ */
@Override @Override
public Builder link(Link link) { public Builder link(Link link) {
this.links.add(checkNotNull(link, "link")); super.link(link);
return this; return this;
} }
@Override @Override
public Builder fromEntityType(EntityType<Vdc> in) { public Builder fromEntityType(EntityType<Vdc> in) {
return Builder.class.cast(super.fromEntityType(in)); return Builder.class.cast(super.fromEntityType(in));
@ -295,8 +293,8 @@ public class Vdc
} }
} }
public Vdc(URI href, String type, Set<Link> links, String description, TasksInProgress tasksInProgress, String id, String name, String allocationModel, CapacityWithUsage storageCapacity, ComputeCapacity computeCapacity, ResourceEntities resourceEntities, AvailableNetworks availableNetworks, Capabilities capabilities, int nicQuota, int networkQuota, Integer vmQuota, Boolean enabled, Integer status) { public Vdc(URI href, String type, Set<Link> links, String description, Set<Task> tasks, String id, String name, String allocationModel, CapacityWithUsage storageCapacity, ComputeCapacity computeCapacity, ResourceEntities resourceEntities, AvailableNetworks availableNetworks, Capabilities capabilities, int nicQuota, int networkQuota, Integer vmQuota, Boolean enabled, Integer status) {
super(href, type, links, description, tasksInProgress, id, name); super(href, type, links, description, tasks, id, name);
this.allocationModel = allocationModel; this.allocationModel = allocationModel;
this.storageCapacity = storageCapacity; this.storageCapacity = storageCapacity;
this.computeCapacity = computeCapacity; this.computeCapacity = computeCapacity;

View File

@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
@ -33,6 +34,7 @@ import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
/** /**
@ -75,7 +77,7 @@ public class Vdcs {
public static class Builder { public static class Builder {
private List<Reference> vdcs; private List<Reference> vdcs = Lists.newArrayList();
/** /**
* @see Vdcs#getVdc() * @see Vdcs#getVdc()

View File

@ -25,7 +25,10 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.*; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
/** /**
* *

View File

@ -22,4 +22,5 @@ package org.jclouds.vcloud.director.v1_5.domain.cim;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_CIM_NS; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_CIM_NS;
import javax.xml.bind.annotation.XmlNsForm; import javax.xml.bind.annotation.XmlNsForm;
import javax.xml.bind.annotation.XmlSchema; import javax.xml.bind.annotation.XmlSchema;

View File

@ -22,6 +22,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collections; import java.util.Collections;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;

View File

@ -19,8 +19,8 @@
package org.jclouds.vcloud.director.v1_5.domain.ovf; package org.jclouds.vcloud.director.v1_5.domain.ovf;
import java.net.URI; import java.net.URI;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/** /**
* @author Adrian Cole * @author Adrian Cole

View File

@ -21,6 +21,7 @@ package org.jclouds.vcloud.director.v1_5.domain.ovf;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import org.jclouds.javax.annotation.Nullable; import org.jclouds.javax.annotation.Nullable;

View File

@ -22,6 +22,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_NS; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_NS;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import org.jclouds.javax.annotation.Nullable; import org.jclouds.javax.annotation.Nullable;

View File

@ -22,6 +22,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_NS; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_NS;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import org.jclouds.javax.annotation.Nullable; import org.jclouds.javax.annotation.Nullable;

View File

@ -29,4 +29,5 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OV
import javax.xml.bind.annotation.XmlNs; import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlNsForm; import javax.xml.bind.annotation.XmlNsForm;
import javax.xml.bind.annotation.XmlSchema; import javax.xml.bind.annotation.XmlSchema;

View File

@ -29,4 +29,5 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OV
import javax.xml.bind.annotation.XmlNs; import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlNsForm; import javax.xml.bind.annotation.XmlNsForm;
import javax.xml.bind.annotation.XmlSchema; import javax.xml.bind.annotation.XmlSchema;

View File

@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import org.jclouds.vcloud.director.v1_5.domain.CatalogReference; import org.jclouds.vcloud.director.v1_5.domain.CatalogReference;

View File

@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Link;

View File

@ -25,6 +25,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Date; import java.util.Date;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSchemaType; import javax.xml.bind.annotation.XmlSchemaType;

View File

@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Link;

View File

@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSchemaType; import javax.xml.bind.annotation.XmlSchemaType;

View File

@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElementRef; import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;

View File

@ -24,11 +24,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElementRef; import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlElementRefs;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.CatalogReference;
import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Link;
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType; import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;

View File

@ -25,8 +25,8 @@ package org.jclouds.vcloud.director.v1_5.domain.query;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_CIM_NS; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_CIM_NS;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_NS;
import javax.xml.bind.annotation.XmlNs; import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlNsForm; import javax.xml.bind.annotation.XmlNsForm;
import javax.xml.bind.annotation.XmlSchema; import javax.xml.bind.annotation.XmlSchema;

View File

@ -30,4 +30,5 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OV
import javax.xml.bind.annotation.XmlNs; import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlNsForm; import javax.xml.bind.annotation.XmlNsForm;
import javax.xml.bind.annotation.XmlSchema; import javax.xml.bind.annotation.XmlSchema;

View File

@ -49,6 +49,18 @@ import com.google.common.util.concurrent.ListenableFuture;
*/ */
@RequestFilters(AddVCloudAuthorizationToRequest.class) @RequestFilters(AddVCloudAuthorizationToRequest.class)
public interface AdminCatalogAsyncClient extends CatalogAsyncClient { public interface AdminCatalogAsyncClient extends CatalogAsyncClient {
/**
* @see AdminClient#createCatalog(URI, AdminCatalog)
*/
@POST
@Path("/catalogs")
@Consumes(VCloudDirectorMediaType.ADMIN_CATALOG)
@Produces(VCloudDirectorMediaType.ADMIN_CATALOG)
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<AdminCatalog> createCatalog(@EndpointParam URI orgRef,
@BinderParam(BindToXMLPayload.class) AdminCatalog catalog);
/** /**
* @see AdminClient#getCatalog(URI) * @see AdminClient#getCatalog(URI)

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