mirror of https://github.com/apache/jclouds.git
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:
commit
52514a77a5
|
@ -123,7 +123,7 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
|
|||
try {
|
||||
return Iterables.find(hardwares.get(), new FindHardwareForServer(from));
|
||||
} 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;
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
|
|||
try {
|
||||
return Iterables.find(images.get(), new FindImageForServer(from)).getOperatingSystem();
|
||||
} 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;
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ public class InstanceToNodeMetadata implements Function<Instance, NodeMetadata>
|
|||
try {
|
||||
return Iterables.find(hardwares.get(), new FindHardwareForInstance(from));
|
||||
} 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;
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ public class InstanceToNodeMetadata implements Function<Instance, NodeMetadata>
|
|||
try {
|
||||
return Iterables.find(images.get(), new FindImageForInstance(from)).getOperatingSystem();
|
||||
} 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;
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ public class InstanceToNodeMetadata implements Function<Instance, NodeMetadata>
|
|||
try {
|
||||
return Iterables.find(locations.get(), new FindLocationForInstance(from));
|
||||
} 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;
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
|
|||
try {
|
||||
return Iterables.find(hardwares.get(), new FindHardwareForServer(from));
|
||||
} 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;
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
|
|||
try {
|
||||
return Iterables.find(images.get(), new FindImageForServer(from));
|
||||
} 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;
|
||||
}
|
||||
|
|
|
@ -55,15 +55,19 @@ public interface SshClient {
|
|||
/**
|
||||
* 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
|
||||
*/
|
||||
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
|
||||
* @since 1.5.0
|
||||
*/
|
||||
|
|
|
@ -34,7 +34,6 @@ import java.io.Closeable;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.ConnectException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import javax.annotation.Resource;
|
||||
|
@ -44,6 +43,7 @@ import org.apache.commons.io.input.ProxyInputStream;
|
|||
import org.apache.commons.io.output.ByteArrayOutputStream;
|
||||
import org.jclouds.compute.domain.ExecChannel;
|
||||
import org.jclouds.compute.domain.ExecResponse;
|
||||
import org.jclouds.domain.LoginCredentials;
|
||||
import org.jclouds.http.handlers.BackoffLimitedRetryHandler;
|
||||
import org.jclouds.io.Payload;
|
||||
import org.jclouds.io.Payloads;
|
||||
|
@ -52,7 +52,6 @@ import org.jclouds.net.IPSocket;
|
|||
import org.jclouds.rest.AuthorizationException;
|
||||
import org.jclouds.ssh.SshClient;
|
||||
import org.jclouds.ssh.SshException;
|
||||
import org.jclouds.util.CredentialUtils;
|
||||
import org.jclouds.util.Strings2;
|
||||
|
||||
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.Supplier;
|
||||
import com.google.common.io.Closeables;
|
||||
import com.google.common.net.HostAndPort;
|
||||
import com.google.inject.Inject;
|
||||
import com.jcraft.jsch.ChannelExec;
|
||||
import com.jcraft.jsch.ChannelSftp;
|
||||
import com.jcraft.jsch.JSch;
|
||||
import com.jcraft.jsch.JSchException;
|
||||
import com.jcraft.jsch.Session;
|
||||
|
||||
|
@ -92,10 +91,6 @@ public class JschSshClient implements SshClient {
|
|||
}
|
||||
}
|
||||
|
||||
private final String host;
|
||||
private final int port;
|
||||
private final String username;
|
||||
private final String password;
|
||||
private final String toString;
|
||||
|
||||
@Inject(optional = true)
|
||||
|
@ -121,31 +116,31 @@ public class JschSshClient implements SshClient {
|
|||
@Named("jclouds.ssh")
|
||||
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;
|
||||
|
||||
public JschSshClient(BackoffLimitedRetryHandler backoffLimitedRetryHandler, IPSocket socket, int timeout,
|
||||
String username, String password, byte[] privateKey) {
|
||||
final SessionConnection sessionConnection;
|
||||
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();
|
||||
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");
|
||||
this.port = socket.getPort();
|
||||
this.username = checkNotNull(username, "username");
|
||||
checkArgument(loginCredentials.getPassword() != null || loginCredentials.getPrivateKey() != null,
|
||||
"you must specify a password or a key");
|
||||
this.backoffLimitedRetryHandler = checkNotNull(backoffLimitedRetryHandler, "backoffLimitedRetryHandler");
|
||||
this.timeout = timeout;
|
||||
this.password = password;
|
||||
this.privateKey = privateKey;
|
||||
if (privateKey == null) {
|
||||
this.toString = String.format("%s:pw[%s]@%s:%d", username, hex(md5(password.getBytes())), host, port);
|
||||
if (loginCredentials.getPrivateKey() == null) {
|
||||
this.toString = String.format("%s:pw[%s]@%s:%d", loginCredentials.getUser(), hex(md5(loginCredentials
|
||||
.getPassword().getBytes())), host, socket.getPort());
|
||||
} else {
|
||||
String fingerPrint = fingerprintPrivateKey(new String(privateKey));
|
||||
String sha1 = sha1PrivateKey(new String(privateKey));
|
||||
this.toString = String.format("%s:rsa[fingerprint(%s),sha1(%s)]@%s:%d", username, fingerPrint, sha1, host,
|
||||
port);
|
||||
String fingerPrint = fingerprintPrivateKey(loginCredentials.getPrivateKey());
|
||||
String sha1 = sha1PrivateKey(loginCredentials.getPrivateKey());
|
||||
this.toString = String.format("%s:rsa[fingerprint(%s),sha1(%s)]@%s:%d", loginCredentials.getUser(),
|
||||
fingerPrint, sha1, host, socket.getPort());
|
||||
}
|
||||
sessionConnection = SessionConnection.builder().hostAndPort(HostAndPort.fromParts(host, socket.getPort())).loginCredentials(
|
||||
loginCredentials).connectTimeout(timeout).sessionTimeout(timeout).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -154,7 +149,8 @@ public class JschSshClient implements SshClient {
|
|||
}
|
||||
|
||||
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> {
|
||||
|
@ -163,45 +159,6 @@ public class JschSshClient implements SshClient {
|
|||
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) {
|
||||
connection.clear();
|
||||
String errorMessage = String.format("(%s) error acquiring %s", toString(), connection);
|
||||
|
@ -245,7 +202,7 @@ public class JschSshClient implements SshClient {
|
|||
public ChannelSftp create() throws JSchException {
|
||||
checkConnected();
|
||||
String channel = "sftp";
|
||||
sftp = (ChannelSftp) session.openChannel(channel);
|
||||
sftp = (ChannelSftp) sessionConnection.getSession().openChannel(channel);
|
||||
sftp.connect();
|
||||
return sftp;
|
||||
}
|
||||
|
@ -394,7 +351,7 @@ public class JschSshClient implements SshClient {
|
|||
public ChannelExec create() throws Exception {
|
||||
checkConnected();
|
||||
String channel = "exec";
|
||||
executor = (ChannelExec) session.openChannel(channel);
|
||||
executor = (ChannelExec) sessionConnection.getSession().openChannel(channel);
|
||||
executor.setPty(true);
|
||||
executor.setCommand(command);
|
||||
ByteArrayOutputStream error = new ByteArrayOutputStream();
|
||||
|
@ -468,13 +425,13 @@ public class JschSshClient implements SshClient {
|
|||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
return this.user;
|
||||
}
|
||||
|
||||
|
||||
class ExecChannelConnection implements Connection<ExecChannel> {
|
||||
private final String command;
|
||||
private ChannelExec executor = null;
|
||||
private Session sessionConnection;
|
||||
|
||||
ExecChannelConnection(String command) {
|
||||
this.command = checkNotNull(command, "command");
|
||||
|
@ -484,14 +441,16 @@ public class JschSshClient implements SshClient {
|
|||
public void clear() {
|
||||
if (executor != null)
|
||||
executor.disconnect();
|
||||
if (sessionConnection != null)
|
||||
sessionConnection.disconnect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExecChannel create() throws Exception {
|
||||
checkConnected();
|
||||
this.sessionConnection = acquire(SessionConnection.builder().fromSessionConnection(
|
||||
JschSshClient.this.sessionConnection).sessionTimeout(0).build());
|
||||
String channel = "exec";
|
||||
executor = (ChannelExec) session.openChannel(channel);
|
||||
executor.setPty(true);
|
||||
executor = (ChannelExec) sessionConnection.openChannel(channel);
|
||||
executor.setCommand(command);
|
||||
ByteArrayOutputStream error = new ByteArrayOutputStream();
|
||||
executor.setErrStream(error);
|
||||
|
@ -521,7 +480,6 @@ public class JschSshClient implements SshClient {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
@Override
|
||||
public ExecChannel execChannel(String command) {
|
||||
return acquire(new ExecChannelConnection(command));
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -65,9 +65,7 @@ public class JschSshClientModule extends AbstractModule {
|
|||
|
||||
@Override
|
||||
public SshClient create(IPSocket socket, LoginCredentials credentials) {
|
||||
SshClient client = new JschSshClient(backoffLimitedRetryHandler, socket, timeout, credentials.getUser(),
|
||||
(credentials.getPrivateKey() == null) ? credentials.getPassword() : null,
|
||||
credentials.getPrivateKey() != null ? credentials.getPrivateKey().getBytes() : null);
|
||||
SshClient client = new JschSshClient(backoffLimitedRetryHandler, socket, credentials, timeout);
|
||||
injector.injectMembers(client);// add logger
|
||||
return client;
|
||||
}
|
||||
|
|
|
@ -170,8 +170,10 @@ public class JschSshClientLiveTest {
|
|||
: sshHost);
|
||||
}
|
||||
|
||||
public void testExecChannelTakesStdinAndEchosBack() throws IOException {
|
||||
ExecChannel response = setupClient().execChannel("cat <<EOF");
|
||||
public void testExecChannelTakesStdinAndNoEchoOfCharsInOuputAndOutlivesClient() throws IOException {
|
||||
SshClient client = setupClient();
|
||||
ExecChannel response = client.execChannel("cat <<EOF");
|
||||
client.disconnect();
|
||||
assertEquals(response.getExitStatus().get(), null);
|
||||
try {
|
||||
PrintStream printStream = new PrintStream(response.getInput());
|
||||
|
@ -179,12 +181,10 @@ public class JschSshClientLiveTest {
|
|||
printStream.append("EOF\n");
|
||||
printStream.close();
|
||||
assertEquals(Strings2.toStringAndClose(response.getError()), "");
|
||||
// local echo
|
||||
assertEquals(Strings2.toStringAndClose(response.getOutput()), "foo\r\nEOF\r\n");
|
||||
assertEquals(Strings2.toStringAndClose(response.getOutput()), "");
|
||||
} finally {
|
||||
Closeables.closeQuietly(response);
|
||||
}
|
||||
assertEquals(response.getExitStatus().get(), new Integer(0));
|
||||
}
|
||||
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
|
@ -52,14 +52,13 @@ import net.schmizz.sshj.connection.channel.direct.Session.Command;
|
|||
import net.schmizz.sshj.sftp.SFTPClient;
|
||||
import net.schmizz.sshj.sftp.SFTPException;
|
||||
import net.schmizz.sshj.transport.TransportException;
|
||||
import net.schmizz.sshj.transport.verification.PromiscuousVerifier;
|
||||
import net.schmizz.sshj.userauth.UserAuthException;
|
||||
import net.schmizz.sshj.userauth.keyprovider.OpenSSHKeyFile;
|
||||
import net.schmizz.sshj.xfer.InMemorySourceFile;
|
||||
|
||||
import org.apache.commons.io.input.ProxyInputStream;
|
||||
import org.jclouds.compute.domain.ExecChannel;
|
||||
import org.jclouds.compute.domain.ExecResponse;
|
||||
import org.jclouds.domain.LoginCredentials;
|
||||
import org.jclouds.http.handlers.BackoffLimitedRetryHandler;
|
||||
import org.jclouds.io.Payload;
|
||||
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.Throwables;
|
||||
import com.google.common.io.Closeables;
|
||||
import com.google.common.net.HostAndPort;
|
||||
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;
|
||||
|
||||
@Inject(optional = true)
|
||||
|
@ -139,31 +135,32 @@ public class SshjSshClient implements SshClient {
|
|||
protected Logger logger = Logger.NULL;
|
||||
|
||||
@VisibleForTesting
|
||||
SSHClient ssh;
|
||||
private final byte[] privateKey;
|
||||
final byte[] emptyPassPhrase = new byte[0];
|
||||
private final int timeoutMillis;
|
||||
SSHClientConnection sshClientConnection;
|
||||
|
||||
final String user;
|
||||
final String host;
|
||||
|
||||
private final BackoffLimitedRetryHandler backoffLimitedRetryHandler;
|
||||
|
||||
public SshjSshClient(BackoffLimitedRetryHandler backoffLimitedRetryHandler, IPSocket socket, int timeout,
|
||||
String username, String password, byte[] privateKey) {
|
||||
public SshjSshClient(BackoffLimitedRetryHandler backoffLimitedRetryHandler, IPSocket socket,
|
||||
LoginCredentials loginCredentials, int timeout) {
|
||||
this.user = checkNotNull(loginCredentials, "loginCredentials").getUser();
|
||||
this.host = checkNotNull(socket, "socket").getAddress();
|
||||
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");
|
||||
this.port = socket.getPort();
|
||||
this.username = checkNotNull(username, "username");
|
||||
checkArgument(loginCredentials.getPassword() != null || loginCredentials.getPrivateKey() != null,
|
||||
"you must specify a password or a key");
|
||||
this.backoffLimitedRetryHandler = checkNotNull(backoffLimitedRetryHandler, "backoffLimitedRetryHandler");
|
||||
this.timeoutMillis = timeout;
|
||||
this.password = password;
|
||||
this.privateKey = privateKey;
|
||||
if (privateKey == null) {
|
||||
this.toString = String.format("%s:pw[%s]@%s:%d", username, hex(md5(password.getBytes())), host, port);
|
||||
if (loginCredentials.getPrivateKey() == null) {
|
||||
this.toString = String.format("%s:pw[%s]@%s:%d", loginCredentials.getUser(), hex(md5(loginCredentials
|
||||
.getPassword().getBytes())), host, socket.getPort());
|
||||
} else {
|
||||
String fingerPrint = fingerprintPrivateKey(new String(privateKey));
|
||||
String sha1 = sha1PrivateKey(new String(privateKey));
|
||||
this.toString = String.format("%s:rsa[fingerprint(%s),sha1(%s)]@%s:%d", username, fingerPrint, sha1, host,
|
||||
port);
|
||||
String fingerPrint = fingerprintPrivateKey(loginCredentials.getPrivateKey());
|
||||
String sha1 = sha1PrivateKey(loginCredentials.getPrivateKey());
|
||||
this.toString = String.format("%s:rsa[fingerprint(%s),sha1(%s)]@%s:%d", loginCredentials.getUser(),
|
||||
fingerPrint, sha1, host, socket.getPort());
|
||||
}
|
||||
sshClientConnection = SSHClientConnection.builder().hostAndPort(HostAndPort.fromParts(host, socket.getPort()))
|
||||
.loginCredentials(loginCredentials).connectTimeout(timeout).sessionTimeout(timeout).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -172,7 +169,8 @@ public class SshjSshClient implements SshClient {
|
|||
}
|
||||
|
||||
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> {
|
||||
|
@ -181,45 +179,6 @@ public class SshjSshClient implements SshClient {
|
|||
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) {
|
||||
backoffLimitedRetryHandler.imposeBackoffExponentialDelay(200L, 2, retryAttempt, sshRetries, message);
|
||||
}
|
||||
|
@ -240,16 +199,17 @@ public class SshjSshClient implements SshClient {
|
|||
logger.warn(from, "<< (%s) error closing connection", toString());
|
||||
}
|
||||
if (i + 1 == sshRetries) {
|
||||
throw propagate(from, errorMessage+" (out of retries - max "+sshRetries+")");
|
||||
} else if (shouldRetry(from) ||
|
||||
(Throwables2.getFirstThrowableOfType(from, IllegalStateException.class) != null)) {
|
||||
logger.info("<< " + errorMessage + " (attempt " + (i + 1) + " of " + sshRetries + "): " + from.getMessage());
|
||||
throw propagate(from, errorMessage + " (out of retries - max " + sshRetries + ")");
|
||||
} else if (shouldRetry(from)
|
||||
|| (Throwables2.getFirstThrowableOfType(from, IllegalStateException.class) != null)) {
|
||||
logger.info("<< " + errorMessage + " (attempt " + (i + 1) + " of " + sshRetries + "): "
|
||||
+ from.getMessage());
|
||||
backoffForAttempt(i + 1, errorMessage + ": " + from.getMessage());
|
||||
if (connection != sshConnection)
|
||||
if (connection != sshClientConnection)
|
||||
connect();
|
||||
continue;
|
||||
} 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() {
|
||||
try {
|
||||
ssh = acquire(sshConnection);
|
||||
acquire(sshClientConnection);
|
||||
} catch (Exception e) {
|
||||
Throwables.propagate(e);
|
||||
}
|
||||
|
@ -282,7 +242,7 @@ public class SshjSshClient implements SshClient {
|
|||
@Override
|
||||
public SFTPClient create() throws IOException {
|
||||
checkConnected();
|
||||
sftp = ssh.newSFTPClient();
|
||||
sftp = sshClientConnection.ssh.newSFTPClient();
|
||||
return sftp;
|
||||
}
|
||||
|
||||
|
@ -431,7 +391,7 @@ public class SshjSshClient implements SshClient {
|
|||
@PreDestroy
|
||||
public void disconnect() {
|
||||
try {
|
||||
sshConnection.clear();
|
||||
sshClientConnection.clear();
|
||||
} catch (Exception e) {
|
||||
Throwables.propagate(e);
|
||||
}
|
||||
|
@ -452,8 +412,8 @@ public class SshjSshClient implements SshClient {
|
|||
@Override
|
||||
public Session create() throws Exception {
|
||||
checkConnected();
|
||||
session = ssh.startSession();
|
||||
session.allocatePTY("vt100", 80, 24, 0, 0, Collections.<PTYMode, Integer>emptyMap());
|
||||
session = sshClientConnection.ssh.startSession();
|
||||
session.allocatePTY("vt100", 80, 24, 0, 0, Collections.<PTYMode, Integer> emptyMap());
|
||||
return session;
|
||||
}
|
||||
|
||||
|
@ -485,7 +445,7 @@ public class SshjSshClient implements SshClient {
|
|||
session = acquire(execConnection());
|
||||
Command output = session.exec(checkNotNull(command, "command"));
|
||||
String outputString = IOUtils.readFully(output.getInputStream()).toString();
|
||||
output.join(timeoutMillis, TimeUnit.SECONDS);
|
||||
output.join(sshClientConnection.getSessionTimeout(), TimeUnit.MILLISECONDS);
|
||||
int errorStatus = output.getExitStatus();
|
||||
String errorString = IOUtils.readFully(output.getErrorStream()).toString();
|
||||
return new ExecResponse(outputString, errorString, errorStatus);
|
||||
|
@ -504,6 +464,37 @@ public class SshjSshClient implements SshClient {
|
|||
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> {
|
||||
private final String command;
|
||||
private SessionChannel session;
|
||||
|
@ -521,7 +512,7 @@ public class SshjSshClient implements SshClient {
|
|||
|
||||
@Override
|
||||
public ExecChannel create() throws Exception {
|
||||
session = SessionChannel.class.cast(acquire(execConnection()));
|
||||
session = SessionChannel.class.cast(acquire(noPTYConnection()));
|
||||
output = session.exec(command);
|
||||
return new ExecChannel(output.getOutputStream(), output.getInputStream(), output.getErrorStream(),
|
||||
new Supplier<Integer>() {
|
||||
|
@ -560,7 +551,7 @@ public class SshjSshClient implements SshClient {
|
|||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
return this.user;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -65,9 +65,7 @@ public class SshjSshClientModule extends AbstractModule {
|
|||
|
||||
@Override
|
||||
public SshClient create(IPSocket socket, LoginCredentials credentials) {
|
||||
SshClient client = new SshjSshClient(backoffLimitedRetryHandler, socket, timeout, credentials.getUser(),
|
||||
(credentials.getPrivateKey() == null) ? credentials.getPassword() : null,
|
||||
credentials.getPrivateKey() != null ? credentials.getPrivateKey().getBytes() : null);
|
||||
SshClient client = new SshjSshClient(backoffLimitedRetryHandler, socket, credentials, timeout);
|
||||
injector.injectMembers(client);// add logger
|
||||
return client;
|
||||
}
|
||||
|
|
|
@ -170,8 +170,10 @@ public class SshjSshClientLiveTest {
|
|||
: sshHost);
|
||||
}
|
||||
|
||||
public void testExecChannelTakesStdinAndEchosBack() throws IOException {
|
||||
ExecChannel response = setupClient().execChannel("cat <<EOF");
|
||||
public void testExecChannelTakesStdinAndNoEchoOfCharsInOuputAndOutlivesClient() throws IOException {
|
||||
SshClient client = setupClient();
|
||||
ExecChannel response = client.execChannel("cat <<EOF");
|
||||
client.disconnect();
|
||||
assertEquals(response.getExitStatus().get(), null);
|
||||
try {
|
||||
PrintStream printStream = new PrintStream(response.getInput());
|
||||
|
@ -179,8 +181,7 @@ public class SshjSshClientLiveTest {
|
|||
printStream.append("EOF\n");
|
||||
printStream.close();
|
||||
assertEquals(Strings2.toStringAndClose(response.getError()), "");
|
||||
// local echo
|
||||
assertEquals(Strings2.toStringAndClose(response.getOutput()), "foo\r\nEOF\r\n");
|
||||
assertEquals(Strings2.toStringAndClose(response.getOutput()), "");
|
||||
} finally {
|
||||
Closeables.closeQuietly(response);
|
||||
}
|
||||
|
|
|
@ -172,8 +172,8 @@ public class SshjSshClientTest {
|
|||
ssh.disconnect();
|
||||
expectLastCall().andThrow(new ConnectionException("disconnected"));
|
||||
replay(ssh);
|
||||
ssh1.ssh = ssh;
|
||||
ssh1.sshConnection.clear();
|
||||
ssh1.sshClientConnection.ssh = ssh;
|
||||
ssh1.sshClientConnection.clear();
|
||||
verify(ssh);
|
||||
}
|
||||
|
||||
|
@ -186,8 +186,7 @@ public class SshjSshClientTest {
|
|||
}
|
||||
|
||||
public void testRetriesLoggedAtInfoWithCount() throws Exception {
|
||||
@SuppressWarnings("unchecked")
|
||||
SshjSshClient.Connection<net.schmizz.sshj.SSHClient> mockConnection = createMock(SshjSshClient.Connection.class);
|
||||
SSHClientConnection mockConnection = createMock(SSHClientConnection.class);
|
||||
net.schmizz.sshj.SSHClient mockClient = createMock(net.schmizz.sshj.SSHClient.class);
|
||||
|
||||
mockConnection.clear(); expectLastCall();
|
||||
|
@ -199,14 +198,14 @@ public class SshjSshClientTest {
|
|||
replay(mockConnection);
|
||||
replay(mockClient);
|
||||
|
||||
ssh.sshConnection = mockConnection;
|
||||
ssh.sshClientConnection = mockConnection;
|
||||
BufferLogger logcheck = new BufferLogger(ssh.getClass().getCanonicalName());
|
||||
ssh.logger = logcheck;
|
||||
logcheck.setLevel(Level.INFO);
|
||||
|
||||
ssh.connect();
|
||||
|
||||
Assert.assertEquals(ssh.ssh, mockClient);
|
||||
Assert.assertEquals(ssh.sshClientConnection, mockConnection);
|
||||
verify(mockConnection);
|
||||
verify(mockClient);
|
||||
Record r = logcheck.assertLogContains("attempt 1 of 5");
|
||||
|
|
|
@ -127,7 +127,7 @@ public class ServerDetailsToNodeMetadata implements Function<ServerDetails, Node
|
|||
try {
|
||||
return Iterables.find(images.get(), new FindImageForServer(from)).getOperatingSystem();
|
||||
} 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;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.jclouds.vcloud.director.v1_5;
|
||||
|
||||
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.Group;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Media;
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
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.Group;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Media;
|
||||
|
|
|
@ -129,14 +129,31 @@ public class VCloudDirectorMediaType {
|
|||
|
||||
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 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.
|
||||
*
|
||||
* 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,
|
||||
CAPTURE_VAPP_PARAMS, CLONE_V_APP_PARAMS, CLONE_V_APP_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,
|
||||
CONTROL_ACCESS, VAPP_TEMPLATE, CUSTOMIZATION_SECTION, GUEST_CUSTOMIZATION_SECTION,
|
||||
NETWORK_SECTION, NETWORK_CONFIG_SECTION, NETWORK_CONNECTION_SECTION,
|
||||
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
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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.domain.Session;
|
||||
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.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.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.handlers.InvalidateSessionAndRetryOn401AndLogoutOnClose;
|
||||
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.Writeable.class, MetadataAsyncClient.Writable.class)
|
||||
.put(AdminCatalogClient.class, AdminCatalogAsyncClient.class)
|
||||
.put(AdminOrgClient.class, AdminOrgAsyncClient.class)
|
||||
.put(GroupClient.class, GroupAsyncClient.class)
|
||||
.build();
|
||||
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
|
||||
package org.jclouds.vcloud.director.v1_5.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.net.URI;
|
||||
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.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 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,11 +128,11 @@ public class AdminCatalog extends CatalogType<AdminCatalog> {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see EntityType#getTasksInProgress()
|
||||
* @see EntityType#getTasks()
|
||||
*/
|
||||
@Override
|
||||
public Builder tasksInProgress(TasksInProgress tasksInProgress) {
|
||||
this.tasksInProgress = tasksInProgress;
|
||||
public Builder tasks(Set<Task> tasks) {
|
||||
super.tasks(tasks);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -159,23 +155,22 @@ public class AdminCatalog extends CatalogType<AdminCatalog> {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see EntityType#getLinks()
|
||||
* @see ResourceType#getLinks()
|
||||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links"));
|
||||
return this;
|
||||
return Builder.class.cast(super.links(links));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EntityType#getLinks()
|
||||
* @see ResourceType#getLinks()
|
||||
*/
|
||||
@Override
|
||||
public Builder link(Link link) {
|
||||
this.links.add(checkNotNull(link, "link"));
|
||||
return this;
|
||||
return Builder.class.cast(super.link(link));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Builder fromCatalogType(CatalogType<AdminCatalog> in) {
|
||||
return Builder.class.cast(super.fromCatalogType(in));
|
||||
|
@ -190,8 +185,8 @@ public class AdminCatalog extends CatalogType<AdminCatalog> {
|
|||
// 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) {
|
||||
super(href, type, links, description, tasksInProgress, id, name, owner, catalogItems, published);
|
||||
super(href, type, links, description, tasks, id, name, owner, catalogItems, published);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,9 @@ package org.jclouds.vcloud.director.v1_5.domain;
|
|||
|
||||
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.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
@ -145,7 +148,8 @@ public class AdminOrg extends Org {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -175,8 +179,11 @@ public class AdminOrg extends Org {
|
|||
// 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) {
|
||||
super(href, type, links, description, tasks, id, name, fullName, enabled);
|
||||
this.settings = settings;
|
||||
this.users = users;
|
||||
this.groups = groups;
|
||||
|
|
|
@ -25,6 +25,7 @@ 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.XmlType;
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ public class Catalog extends CatalogType<Catalog> {
|
|||
|
||||
@Override
|
||||
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
|
||||
public Builder tasksInProgress(TasksInProgress tasksInProgress) {
|
||||
this.tasksInProgress = tasksInProgress;
|
||||
public Builder tasks(Set<Task> tasks) {
|
||||
super.tasks(tasks);
|
||||
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) {
|
||||
super(href, type, links, description, tasksInProgress, id, name, owner, catalogItems, published);
|
||||
super(href, type, links, description, tasks, id, name, owner, catalogItems, published);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
|
|
@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
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;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ public class CatalogItem extends EntityType<CatalogItem> {
|
|||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -117,11 +117,11 @@ public class CatalogItem extends EntityType<CatalogItem> {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see EntityType#getTasksInProgress()
|
||||
* @see EntityType#getTasks()
|
||||
*/
|
||||
@Override
|
||||
public Builder tasksInProgress(TasksInProgress tasksInProgress) {
|
||||
this.tasksInProgress = tasksInProgress;
|
||||
public Builder tasks(Set<Task> tasks) {
|
||||
super.tasks(tasks);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -144,21 +144,19 @@ public class CatalogItem extends EntityType<CatalogItem> {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see EntityType#getLinks()
|
||||
* @see ResourceType#getLinks()
|
||||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links"));
|
||||
return this;
|
||||
return Builder.class.cast(super.links(links));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EntityType#getLinks()
|
||||
* @see ResourceType#getLinks()
|
||||
*/
|
||||
@Override
|
||||
public Builder link(Link link) {
|
||||
this.links.add(checkNotNull(link, "link"));
|
||||
return this;
|
||||
return Builder.class.cast(super.link(link));
|
||||
}
|
||||
|
||||
@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) {
|
||||
super(href, type, links, description, tasksInProgress, id, name);
|
||||
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, tasks, id, name);
|
||||
this.entity = entity;
|
||||
this.properties = ImmutableSet.copyOf(properties);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.jclouds.vcloud.director.v1_5.domain;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "CatalogReference")
|
||||
|
|
|
@ -90,7 +90,7 @@ public class CatalogType<T extends CatalogType<T>> extends EntityType<T> {
|
|||
|
||||
@Override
|
||||
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
|
||||
public Builder<T> tasksInProgress(TasksInProgress tasksInProgress) {
|
||||
super.tasksInProgress(tasksInProgress);
|
||||
public Builder<T> tasks(Set<Task> tasks) {
|
||||
super.tasks(tasks);
|
||||
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) {
|
||||
super(href, type, links, description, tasksInProgress, id, name);
|
||||
super(href, type, links, description, tasks, id, name);
|
||||
this.owner = owner;
|
||||
this.catalogItems = catalogItems;
|
||||
this.isPublished = published;
|
||||
|
|
|
@ -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.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;
|
||||
|
||||
|
@ -68,6 +68,14 @@ public class CatalogsList {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see CatalogsList#getCatalogItems()
|
||||
*/
|
||||
public Builder catalog(Reference catalog) {
|
||||
this.catalogReferences.add(checkNotNull(catalog, "catalog"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public CatalogsList build() {
|
||||
return new CatalogsList(catalogReferences);
|
||||
}
|
||||
|
@ -81,7 +89,7 @@ public class CatalogsList {
|
|||
// for JAXB
|
||||
}
|
||||
|
||||
private CatalogsList(Set<Reference> tasks) {
|
||||
private CatalogsList(Set<Reference> catalogReferences) {
|
||||
this.catalogReferences = ImmutableSet.copyOf(checkNotNull(catalogReferences, "catalogReferences"));
|
||||
}
|
||||
|
||||
|
|
|
@ -21,8 +21,6 @@ package org.jclouds.vcloud.director.v1_5.domain;
|
|||
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
|
||||
/**
|
||||
* Represents parameters for copying a vApp and optionally deleting the source.
|
||||
|
|
|
@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||
|
|
|
@ -21,6 +21,9 @@ package org.jclouds.vcloud.director.v1_5.domain;
|
|||
|
||||
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.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
@ -86,6 +89,36 @@ import com.google.common.base.Objects.ToStringHelper;
|
|||
"groupAttributes"
|
||||
})
|
||||
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() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
|
|
@ -46,7 +46,7 @@ public class Entity extends EntityType<Entity> {
|
|||
|
||||
@Override
|
||||
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
|
||||
public Builder tasksInProgress(TasksInProgress tasksInProgress) {
|
||||
this.tasksInProgress = tasksInProgress;
|
||||
public Builder tasks(Set<Task> tasks) {
|
||||
super.tasks(tasks);
|
||||
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) {
|
||||
super(href, type, links, description, tasksInProgress, id, name);
|
||||
private Entity(URI href, String type, Set<Link> links, String description, Set<Task> tasks, String id, String name) {
|
||||
super(href, type, links, description, tasks, id, name);
|
||||
}
|
||||
|
||||
private Entity() {
|
||||
|
|
|
@ -22,13 +22,18 @@ import static com.google.common.base.Objects.equal;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
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.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
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> {
|
||||
|
||||
protected String description;
|
||||
protected TasksInProgress tasksInProgress;
|
||||
protected Set<Task> tasks;
|
||||
protected String name;
|
||||
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) {
|
||||
this.tasksInProgress = tasksInProgress;
|
||||
public T tasks(Set<Task> tasks) {
|
||||
this.tasks = tasks;
|
||||
return self();
|
||||
}
|
||||
|
||||
public T fromEntityType(EntityType<?> in) {
|
||||
return fromResourceType(in)
|
||||
.description(in.getDescription()).tasksInProgress(in.getTasksInProgress())
|
||||
.description(in.getDescription()).tasks(in.getTasks())
|
||||
.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> {
|
||||
|
||||
protected String description;
|
||||
protected TasksInProgress tasksInProgress;
|
||||
protected Set<Task> tasks;
|
||||
protected String name;
|
||||
protected String id;
|
||||
|
||||
|
@ -123,10 +128,21 @@ public abstract class EntityType<T extends EntityType<T>> extends ResourceType<T
|
|||
}
|
||||
|
||||
/**
|
||||
* @see EntityType#getTasksInProgress()
|
||||
* @see EntityType#getTasks()
|
||||
*/
|
||||
public Builder<T> tasksInProgress(TasksInProgress tasksInProgress) {
|
||||
this.tasksInProgress = tasksInProgress;
|
||||
public Builder<T> tasks(Set<Task> tasks) {
|
||||
if (checkNotNull(tasks, "tasks").size() > 0)
|
||||
this.tasks = Sets.newLinkedHashSet(tasks);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EntityType#getTasks()
|
||||
*/
|
||||
public Builder<T> task(Task task) {
|
||||
if (tasks == null)
|
||||
tasks = Sets.newLinkedHashSet();
|
||||
this.tasks.add(checkNotNull(task, "task"));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -151,19 +167,19 @@ public abstract class EntityType<T extends EntityType<T>> extends ResourceType<T
|
|||
/**
|
||||
* @see ResourceType#getLinks()
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Builder<T> links(Set<Link> links) {
|
||||
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links"));
|
||||
return this;
|
||||
return Builder.class.cast(super.links(links));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ResourceType#getLinks()
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Builder<T> link(Link link) {
|
||||
this.links.add(checkNotNull(link, "link"));
|
||||
return this;
|
||||
return Builder.class.cast(super.link(link));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -177,24 +193,26 @@ public abstract class EntityType<T extends EntityType<T>> extends ResourceType<T
|
|||
|
||||
public Builder<T> fromEntityType(EntityType<T> in) {
|
||||
return fromResourceType(in)
|
||||
.description(in.getDescription()).tasksInProgress(in.getTasksInProgress())
|
||||
.description(in.getDescription()).tasks(in.getTasks())
|
||||
.id(in.getId()).name(in.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@XmlElement(name = "Description")
|
||||
private String description;
|
||||
@XmlElement(name = "Tasks")
|
||||
private TasksInProgress tasksInProgress;
|
||||
@XmlElementWrapper(name = "Tasks")
|
||||
@XmlElement(name = "Task")
|
||||
private Set<Task> tasks;
|
||||
@XmlAttribute
|
||||
private String id;
|
||||
@XmlAttribute(required = true)
|
||||
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);
|
||||
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.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.
|
||||
*/
|
||||
public TasksInProgress getTasksInProgress() {
|
||||
return tasksInProgress;
|
||||
public Set<Task> getTasks() {
|
||||
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);
|
||||
return super.equals(that) &&
|
||||
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
|
||||
|
@ -258,11 +276,11 @@ public abstract class EntityType<T extends EntityType<T>> extends ResourceType<T
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode() + Objects.hashCode(description, tasksInProgress, id, name);
|
||||
return super.hashCode() + Objects.hashCode(description, tasks, id, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -20,10 +20,10 @@
|
|||
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.net.URI;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlSchemaType;
|
||||
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.ToStringHelper;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -98,7 +97,7 @@ public class File extends EntityType<File> {
|
|||
}
|
||||
|
||||
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
|
||||
public Builder tasksInProgress(TasksInProgress tasksInProgress) {
|
||||
super.tasksInProgress (tasksInProgress);
|
||||
public Builder tasks(Set<Task> tasks) {
|
||||
super.tasks (tasks);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -158,7 +157,7 @@ public class File extends EntityType<File> {
|
|||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links"));
|
||||
super.links(links);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -167,7 +166,7 @@ public class File extends EntityType<File> {
|
|||
*/
|
||||
@Override
|
||||
public Builder link(Link link) {
|
||||
this.links.add(checkNotNull(link, "link"));
|
||||
super.link(link);
|
||||
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) {
|
||||
super(href, type, links, description, tasksInProgress, id, name);
|
||||
super(href, type, links, description, tasks, id, name);
|
||||
this.size = size;
|
||||
this.bytesTransferred = bytesTransferred;
|
||||
this.checksum = checksum;
|
||||
|
|
|
@ -21,8 +21,6 @@ package org.jclouds.vcloud.director.v1_5.domain;
|
|||
|
||||
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.XmlType;
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.jclouds.vcloud.director.v1_5.domain;
|
|||
import static com.google.common.base.Objects.equal;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
|
|
@ -106,7 +106,7 @@ public class Group extends EntityType<Group> {
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -138,11 +138,11 @@ public class Group extends EntityType<Group> {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see EntityType#getTasksInProgress()
|
||||
* @see EntityType#getTasks()
|
||||
*/
|
||||
@Override
|
||||
public Builder tasksInProgress(TasksInProgress tasksInProgress) {
|
||||
super.tasksInProgress(tasksInProgress);
|
||||
public Builder tasks(Set<Task> tasks) {
|
||||
super.tasks(tasks);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -200,9 +200,9 @@ public class Group extends EntityType<Group> {
|
|||
}
|
||||
|
||||
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) {
|
||||
super(href, type, links, description, tasksInProgress, id, name);
|
||||
super(href, type, links, description, tasks, id, name);
|
||||
this.nameInSource = nameInSource;
|
||||
this.usersList = usersList;
|
||||
this.role = role;
|
||||
|
|
|
@ -62,7 +62,7 @@ import com.google.common.collect.ImmutableList;
|
|||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlRootElement(name = "GroupsList")
|
||||
@XmlType(propOrder = {
|
||||
"groupReference"
|
||||
"groups"
|
||||
})
|
||||
public class GroupsList {
|
||||
public static Builder builder() {
|
||||
|
|
|
@ -25,6 +25,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
|
|
@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
package org.jclouds.vcloud.director.v1_5.domain;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.net.URI;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.net.URI;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
@ -89,7 +90,7 @@ public class Media extends ResourceEntityType<Media> {
|
|||
|
||||
@Override
|
||||
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
|
||||
public Builder tasksInProgress(TasksInProgress tasksInProgress) {
|
||||
super.tasksInProgress(tasksInProgress);
|
||||
public Builder tasks(Set<Task> tasks) {
|
||||
super.tasks(tasks);
|
||||
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) {
|
||||
super(href, type, links, description, tasksInProgress, id, name, files, status);
|
||||
super(href, type, links, description, tasks, id, name, files, status);
|
||||
this.owner = owner;
|
||||
this.imageType = imageType;
|
||||
this.size = size;
|
||||
|
|
|
@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ 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.XmlRootElement;
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ 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.XmlRootElement;
|
||||
|
||||
|
|
|
@ -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.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
|
|
@ -25,6 +25,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
|
|
@ -25,6 +25,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
|
|
@ -19,16 +19,15 @@
|
|||
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.net.URI;
|
||||
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.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
@XmlRootElement(name = "NetworkType")
|
||||
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
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -87,11 +86,11 @@ public class NetworkType<T extends NetworkType<T>> extends EntityType<T> {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see EntityType#getTasksInProgress()
|
||||
* @see EntityType#getTasks()
|
||||
*/
|
||||
@Override
|
||||
public Builder<T> tasksInProgress(TasksInProgress tasksInProgress) {
|
||||
this.tasksInProgress = tasksInProgress;
|
||||
public Builder<T> tasks(Set<Task> tasks) {
|
||||
super.tasks(tasks);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -118,7 +117,7 @@ public class NetworkType<T extends NetworkType<T>> extends EntityType<T> {
|
|||
*/
|
||||
@Override
|
||||
public Builder<T> links(Set<Link> links) {
|
||||
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links"));
|
||||
super.links(links);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -127,7 +126,7 @@ public class NetworkType<T extends NetworkType<T>> extends EntityType<T> {
|
|||
*/
|
||||
@Override
|
||||
public Builder<T> link(Link link) {
|
||||
this.links.add(checkNotNull(link, "link"));
|
||||
super.link(link);
|
||||
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) {
|
||||
super(href, type, links, description, tasksInProgress, id, name);
|
||||
super(href, type, links, description, tasks, id, name);
|
||||
this.networkConfiguration = networkConfiguration;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ import javax.xml.bind.annotation.XmlType;
|
|||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
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)
|
||||
@XmlType(name = "Networks", propOrder = {
|
||||
"network"
|
||||
"networks"
|
||||
})
|
||||
public class Networks {
|
||||
public static Builder builder() {
|
||||
|
@ -75,7 +76,7 @@ public class Networks {
|
|||
|
||||
public static class Builder {
|
||||
|
||||
private List<Reference> networks;
|
||||
private List<Reference> networks = Lists.newArrayList();
|
||||
|
||||
/**
|
||||
* @see Networks#getNetwork()
|
||||
|
|
|
@ -59,8 +59,8 @@ public class Org extends EntityType<Org> {
|
|||
|
||||
public static abstract class NewBuilder<T extends NewBuilder<T>> extends EntityType.NewBuilder<T> {
|
||||
|
||||
private String fullName;
|
||||
private Boolean isEnabled;
|
||||
protected String fullName;
|
||||
protected Boolean isEnabled;
|
||||
|
||||
/**
|
||||
* @see Org#getFullName()
|
||||
|
@ -80,7 +80,7 @@ public class Org extends EntityType<Org> {
|
|||
|
||||
@Override
|
||||
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) {
|
||||
|
@ -143,7 +143,7 @@ public class Org extends EntityType<Org> {
|
|||
|
||||
@Override
|
||||
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
|
||||
public Builder tasksInProgress(TasksInProgress tasksInProgress) {
|
||||
this.tasksInProgress = tasksInProgress;
|
||||
public Builder tasks(Set<Task> tasks) {
|
||||
super.tasks(tasks);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -232,7 +232,9 @@ public class Org extends EntityType<Org> {
|
|||
// 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);
|
||||
this.fullName = fullName;
|
||||
isEnabled = enabled;
|
||||
|
|
|
@ -76,7 +76,7 @@ import com.google.common.collect.ImmutableList;
|
|||
"fromEmailAddress",
|
||||
"defaultSubjectPrefix",
|
||||
"isAlertEmailToAllAdmins",
|
||||
"alertEmailTo",
|
||||
"alertEmailsTo",
|
||||
"smtpServerSettings"
|
||||
})
|
||||
public class OrgEmailSettings extends ResourceType<OrgEmailSettings> {
|
||||
|
@ -142,7 +142,7 @@ public class OrgEmailSettings extends ResourceType<OrgEmailSettings> {
|
|||
* @see OrgEmailSettings#getAlertEmailTo()
|
||||
*/
|
||||
public Builder alertEmailsTo(List<String> alertEmailsTo) {
|
||||
this.alertEmailTo = ImmutableList.copyOf(alertEmailsTo);
|
||||
this.alertEmailTo = alertEmailsTo == null ? null : ImmutableList.copyOf(alertEmailsTo);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,8 @@ public class OrgEmailSettings extends ResourceType<OrgEmailSettings> {
|
|||
}
|
||||
|
||||
public OrgEmailSettings build() {
|
||||
return new OrgEmailSettings(isDefaultSmtpServer, isDefaultOrgEmail, fromEmailAddress, defaultSubjectPrefix,
|
||||
return new OrgEmailSettings(href, type, links, isDefaultSmtpServer,
|
||||
isDefaultOrgEmail, fromEmailAddress, defaultSubjectPrefix,
|
||||
isAlertEmailToAllAdmins, alertEmailTo, smtpServerSettings);
|
||||
}
|
||||
|
||||
|
@ -225,9 +226,11 @@ public class OrgEmailSettings extends ResourceType<OrgEmailSettings> {
|
|||
// 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,
|
||||
List<String> alertEmailTo, SmtpServerSettings smtpServerSettings) {
|
||||
super(href, type, links);
|
||||
this.isDefaultSmtpServer = isDefaultSmtpServer;
|
||||
this.isDefaultOrgEmail = isDefaultOrgEmail;
|
||||
this.fromEmailAddress = fromEmailAddress;
|
||||
|
@ -323,9 +326,6 @@ public class OrgEmailSettings extends ResourceType<OrgEmailSettings> {
|
|||
*
|
||||
*/
|
||||
public List<String> getAlertEmailsTo() {
|
||||
if (alertEmailsTo == null) {
|
||||
alertEmailsTo = new ArrayList<String>();
|
||||
}
|
||||
return this.alertEmailsTo;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ import com.google.common.base.Objects.ToStringHelper;
|
|||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlRootElement(name = "OrgGeneralSettings")
|
||||
@XmlRootElement(name = "GeneralOrgSettings")
|
||||
@XmlType(propOrder = {
|
||||
"canPublishCatalogs",
|
||||
"deployedVMQuota",
|
||||
|
|
|
@ -22,11 +22,14 @@ package org.jclouds.vcloud.director.v1_5.domain;
|
|||
import static com.google.common.base.Objects.equal;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
@ -60,12 +63,28 @@ import com.google.common.base.Objects.ToStringHelper;
|
|||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "OrgLdapSettings", propOrder = {
|
||||
"orgLdapMode",
|
||||
@XmlRootElement(name = "OrgLdapSettings")
|
||||
@XmlType(propOrder = {
|
||||
"ldapMode",
|
||||
"customUsersOu",
|
||||
"customOrgLdapSettings"
|
||||
})
|
||||
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() {
|
||||
return new Builder();
|
||||
}
|
||||
|
@ -76,15 +95,15 @@ public class OrgLdapSettings extends ResourceType<OrgLdapSettings> {
|
|||
|
||||
public static class Builder extends ResourceType.Builder<OrgLdapSettings> {
|
||||
|
||||
private String orgLdapMode;
|
||||
private String ldapMode;
|
||||
private String customUsersOu;
|
||||
private CustomOrgLdapSettings customOrgLdapSettings;
|
||||
|
||||
/**
|
||||
* @see OrgLdapSettings#getOrgLdapMode()
|
||||
* @see OrgLdapSettings#getLdapMode()
|
||||
*/
|
||||
public Builder orgLdapMode(String orgLdapMode) {
|
||||
this.orgLdapMode = orgLdapMode;
|
||||
public Builder ldapMode(String ldapMode) {
|
||||
this.ldapMode = ldapMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -106,7 +125,7 @@ public class OrgLdapSettings extends ResourceType<OrgLdapSettings> {
|
|||
|
||||
public OrgLdapSettings build() {
|
||||
OrgLdapSettings orgLdapSettings = new OrgLdapSettings(href, type, links,
|
||||
orgLdapMode, customUsersOu, customOrgLdapSettings);
|
||||
ldapMode, customUsersOu, customOrgLdapSettings);
|
||||
return orgLdapSettings;
|
||||
}
|
||||
|
||||
|
@ -154,7 +173,7 @@ public class OrgLdapSettings extends ResourceType<OrgLdapSettings> {
|
|||
}
|
||||
public Builder fromOrgLdapSettings(OrgLdapSettings in) {
|
||||
return fromResourceType(in)
|
||||
.orgLdapMode(in.getOrgLdapMode())
|
||||
.ldapMode(in.getLdapMode())
|
||||
.customUsersOu(in.getCustomUsersOu())
|
||||
.customOrgLdapSettings(in.getCustomOrgLdapSettings());
|
||||
}
|
||||
|
@ -166,9 +185,9 @@ public class OrgLdapSettings extends ResourceType<OrgLdapSettings> {
|
|||
}
|
||||
|
||||
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);
|
||||
this.orgLdapMode = orgLdapMode;
|
||||
this.ldapMode = ldapMode;
|
||||
this.customUsersOu = customUsersOu;
|
||||
this.customOrgLdapSettings = customOrgLdapSettings;
|
||||
}
|
||||
|
@ -176,7 +195,7 @@ public class OrgLdapSettings extends ResourceType<OrgLdapSettings> {
|
|||
|
||||
|
||||
@XmlElement(name = "OrgLdapMode")
|
||||
protected String orgLdapMode;
|
||||
protected String ldapMode;
|
||||
@XmlElement(name = "CustomUsersOu")
|
||||
protected String customUsersOu;
|
||||
@XmlElement(name = "CustomOrgLdapSettings")
|
||||
|
@ -190,8 +209,8 @@ public class OrgLdapSettings extends ResourceType<OrgLdapSettings> {
|
|||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getOrgLdapMode() {
|
||||
return orgLdapMode;
|
||||
public String getLdapMode() {
|
||||
return ldapMode;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -226,7 +245,7 @@ public class OrgLdapSettings extends ResourceType<OrgLdapSettings> {
|
|||
return false;
|
||||
OrgLdapSettings that = OrgLdapSettings.class.cast(o);
|
||||
return super.equals(that) &&
|
||||
equal(orgLdapMode, that.orgLdapMode) &&
|
||||
equal(ldapMode, that.ldapMode) &&
|
||||
equal(customUsersOu, that.customUsersOu) &&
|
||||
equal(customOrgLdapSettings, that.customOrgLdapSettings);
|
||||
}
|
||||
|
@ -234,7 +253,7 @@ public class OrgLdapSettings extends ResourceType<OrgLdapSettings> {
|
|||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(super.hashCode(),
|
||||
orgLdapMode,
|
||||
ldapMode,
|
||||
customUsersOu,
|
||||
customOrgLdapSettings);
|
||||
}
|
||||
|
@ -242,7 +261,7 @@ public class OrgLdapSettings extends ResourceType<OrgLdapSettings> {
|
|||
@Override
|
||||
public ToStringHelper string() {
|
||||
return super.string()
|
||||
.add("orgLdapMode", orgLdapMode)
|
||||
.add("orgLdapMode", ldapMode)
|
||||
.add("customUsersOu", customUsersOu)
|
||||
.add("customOrgLdapSettings", customOrgLdapSettings);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.util.Set;
|
|||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
@ -60,7 +61,8 @@ import com.google.common.base.Objects.ToStringHelper;
|
|||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "OrgLeaseSettings", propOrder = {
|
||||
@XmlRootElement(name = "VAppLeaseSettings")
|
||||
@XmlType(propOrder = {
|
||||
"deleteOnStorageLeaseExpiration",
|
||||
"deploymentLeaseSeconds",
|
||||
"storageLeaseSeconds"
|
||||
|
|
|
@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
|
|
|
@ -19,16 +19,15 @@
|
|||
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.net.URI;
|
||||
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.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
@XmlRootElement(name = "OrgNetwork")
|
||||
public class OrgNetwork extends NetworkType<OrgNetwork> {
|
||||
|
@ -66,7 +65,7 @@ public class OrgNetwork extends NetworkType<OrgNetwork> {
|
|||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -106,11 +105,11 @@ public class OrgNetwork extends NetworkType<OrgNetwork> {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see EntityType#getTasksInProgress()
|
||||
* @see EntityType#getTasks()
|
||||
*/
|
||||
@Override
|
||||
public Builder tasksInProgress(TasksInProgress tasksInProgress) {
|
||||
this.tasksInProgress = tasksInProgress;
|
||||
public Builder tasks(Set<Task> tasks) {
|
||||
super.tasks(tasks);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -137,7 +136,7 @@ public class OrgNetwork extends NetworkType<OrgNetwork> {
|
|||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links"));
|
||||
super.links(links);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -146,7 +145,7 @@ public class OrgNetwork extends NetworkType<OrgNetwork> {
|
|||
*/
|
||||
@Override
|
||||
public Builder link(Link link) {
|
||||
this.links.add(checkNotNull(link, "link"));
|
||||
super.link(link);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -166,9 +165,9 @@ public class OrgNetwork extends NetworkType<OrgNetwork> {
|
|||
// 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) {
|
||||
super(href, type, links, description, tasksInProgress, id, name, networkConfiguration);
|
||||
super(href, type, links, description, tasks, id, name, networkConfiguration);
|
||||
this.networkPool = networkPool;
|
||||
this.allowedExternalIpAddresses = allowedExternalIpAddresses;
|
||||
}
|
||||
|
|
|
@ -193,7 +193,7 @@ public class OrgPasswordPolicySettings extends ResourceType<OrgPasswordPolicySet
|
|||
* Gets the value of the invalidLoginsBeforeLockout property.
|
||||
*
|
||||
*/
|
||||
public int getInvalidLoginsBeforeLockout() {
|
||||
public Integer getInvalidLoginsBeforeLockout() {
|
||||
return invalidLoginsBeforeLockout;
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ public class OrgPasswordPolicySettings extends ResourceType<OrgPasswordPolicySet
|
|||
* Gets the value of the accountLockoutIntervalMinutes property.
|
||||
*
|
||||
*/
|
||||
public int getAccountLockoutIntervalMinutes() {
|
||||
public Integer getAccountLockoutIntervalMinutes() {
|
||||
return accountLockoutIntervalMinutes;
|
||||
}
|
||||
|
||||
|
|
|
@ -69,12 +69,12 @@ import com.google.common.base.Objects.ToStringHelper;
|
|||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlRootElement(name = "OrgSettings")
|
||||
@XmlType(propOrder = {
|
||||
"orgGeneralSettings",
|
||||
"generalSettings",
|
||||
"vAppLeaseSettings",
|
||||
"vAppTemplateLeaseSettings",
|
||||
"orgLdapSettings",
|
||||
"orgEmailSettings",
|
||||
"orgPasswordPolicySettings"
|
||||
"ldapSettings",
|
||||
"emailSettings",
|
||||
"passwordPolicy"
|
||||
})
|
||||
public class OrgSettings extends ResourceType<OrgSettings> {
|
||||
public static Builder builder() {
|
||||
|
@ -87,18 +87,18 @@ public class OrgSettings extends ResourceType<OrgSettings> {
|
|||
|
||||
public static class Builder extends ResourceType.Builder<OrgSettings> {
|
||||
|
||||
private OrgGeneralSettings orgGeneralSettings;
|
||||
private OrgGeneralSettings generalSettings;
|
||||
private OrgLeaseSettings vAppLeaseSettings;
|
||||
private OrgVAppTemplateLeaseSettings vAppTemplateLeaseSettings;
|
||||
private OrgLdapSettings orgLdapSettings;
|
||||
private OrgEmailSettings orgEmailSettings;
|
||||
private OrgPasswordPolicySettings orgPasswordPolicySettings;
|
||||
private OrgLdapSettings ldapSettings;
|
||||
private OrgEmailSettings emailSettings;
|
||||
private OrgPasswordPolicySettings passwordPolicy;
|
||||
|
||||
/**
|
||||
* @see OrgSettings#getOrgGeneralSettings()
|
||||
* @see OrgSettings#getGeneralSettings()
|
||||
*/
|
||||
public Builder orgGeneralSettings(OrgGeneralSettings orgGeneralSettings) {
|
||||
this.orgGeneralSettings = orgGeneralSettings;
|
||||
public Builder generalSettings(OrgGeneralSettings generalSettings) {
|
||||
this.generalSettings = generalSettings;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -119,32 +119,32 @@ public class OrgSettings extends ResourceType<OrgSettings> {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see OrgSettings#getOrgLdapSettings()
|
||||
* @see OrgSettings#getLdapSettings()
|
||||
*/
|
||||
public Builder orgLdapSettings(OrgLdapSettings orgLdapSettings) {
|
||||
this.orgLdapSettings = orgLdapSettings;
|
||||
public Builder ldapSettings(OrgLdapSettings ldapSettings) {
|
||||
this.ldapSettings = ldapSettings;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see OrgSettings#getOrgEmailSettings()
|
||||
* @see OrgSettings#getEmailSettings()
|
||||
*/
|
||||
public Builder orgEmailSettings(OrgEmailSettings orgEmailSettings) {
|
||||
this.orgEmailSettings = orgEmailSettings;
|
||||
public Builder emailSettings(OrgEmailSettings emailSettings) {
|
||||
this.emailSettings = emailSettings;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see OrgSettings#getOrgPasswordPolicySettings()
|
||||
* @see OrgSettings#getPasswordPolicy()
|
||||
*/
|
||||
public Builder orgPasswordPolicySettings(OrgPasswordPolicySettings orgPasswordPolicySettings) {
|
||||
this.orgPasswordPolicySettings = orgPasswordPolicySettings;
|
||||
public Builder passwordPolicy(OrgPasswordPolicySettings passwordPolicy) {
|
||||
this.passwordPolicy = passwordPolicy;
|
||||
return this;
|
||||
}
|
||||
|
||||
public OrgSettings build() {
|
||||
return new OrgSettings(href, type, links, orgGeneralSettings, vAppLeaseSettings,
|
||||
vAppTemplateLeaseSettings, orgLdapSettings, orgEmailSettings, orgPasswordPolicySettings);
|
||||
return new OrgSettings(href, type, links, generalSettings, vAppLeaseSettings,
|
||||
vAppTemplateLeaseSettings, ldapSettings, emailSettings, passwordPolicy);
|
||||
}
|
||||
|
||||
|
||||
|
@ -191,12 +191,12 @@ public class OrgSettings extends ResourceType<OrgSettings> {
|
|||
}
|
||||
public Builder fromOrgSettings(OrgSettings in) {
|
||||
return fromResourceType(in)
|
||||
.orgGeneralSettings(in.getOrgGeneralSettings())
|
||||
.generalSettings(in.getGeneralSettings())
|
||||
.vAppLeaseSettings(in.getVAppLeaseSettings())
|
||||
.vAppTemplateLeaseSettings(in.getVAppTemplateLeaseSettings())
|
||||
.orgLdapSettings(in.getOrgLdapSettings())
|
||||
.orgEmailSettings(in.getOrgEmailSettings())
|
||||
.orgPasswordPolicySettings(in.getOrgPasswordPolicySettings());
|
||||
.ldapSettings(in.getLdapSettings())
|
||||
.emailSettings(in.getEmailSettings())
|
||||
.passwordPolicy(in.getPasswordPolicy());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,31 +206,32 @@ public class OrgSettings extends ResourceType<OrgSettings> {
|
|||
}
|
||||
|
||||
public OrgSettings(URI href, String type, Set<Link> links,
|
||||
OrgGeneralSettings orgGeneralSettings,
|
||||
OrgGeneralSettings generalSettings,
|
||||
OrgLeaseSettings vAppLeaseSettings,
|
||||
OrgVAppTemplateLeaseSettings vAppTemplateLeaseSettings,
|
||||
OrgLdapSettings orgLdapSettings, OrgEmailSettings orgEmailSettings,
|
||||
OrgPasswordPolicySettings orgPasswordPolicySettings) {
|
||||
OrgLdapSettings ldapSettings, OrgEmailSettings emailSettings,
|
||||
OrgPasswordPolicySettings passwordPolicy) {
|
||||
super(href, type, links);
|
||||
this.orgGeneralSettings = orgGeneralSettings;
|
||||
this.generalSettings = generalSettings;
|
||||
this.vAppLeaseSettings = vAppLeaseSettings;
|
||||
this.vAppTemplateLeaseSettings = vAppTemplateLeaseSettings;
|
||||
this.orgLdapSettings = orgLdapSettings;
|
||||
this.orgPasswordPolicySettings = orgPasswordPolicySettings;
|
||||
this.ldapSettings = ldapSettings;
|
||||
this.emailSettings = emailSettings;
|
||||
this.passwordPolicy = passwordPolicy;
|
||||
}
|
||||
|
||||
@XmlElement(name = "OrgGeneralSettings")
|
||||
protected OrgGeneralSettings orgGeneralSettings;
|
||||
protected OrgGeneralSettings generalSettings;
|
||||
@XmlElement(name = "VAppLeaseSettings")
|
||||
protected OrgLeaseSettings vAppLeaseSettings;
|
||||
@XmlElement(name = "VAppTemplateLeaseSettings")
|
||||
protected OrgVAppTemplateLeaseSettings vAppTemplateLeaseSettings;
|
||||
@XmlElement(name = "OrgLdapSettings")
|
||||
protected OrgLdapSettings orgLdapSettings;
|
||||
protected OrgLdapSettings ldapSettings;
|
||||
@XmlElement(name = "OrgEmailSettings")
|
||||
protected OrgEmailSettings orgEmailSettings;
|
||||
protected OrgEmailSettings emailSettings;
|
||||
@XmlElement(name = "OrgPasswordPolicySettings")
|
||||
protected OrgPasswordPolicySettings orgPasswordPolicySettings;
|
||||
protected OrgPasswordPolicySettings passwordPolicy;
|
||||
|
||||
/**
|
||||
* Gets the value of the orgGeneralSettings property.
|
||||
|
@ -240,8 +241,8 @@ public class OrgSettings extends ResourceType<OrgSettings> {
|
|||
* {@link OrgGeneralSettings }
|
||||
*
|
||||
*/
|
||||
public OrgGeneralSettings getOrgGeneralSettings() {
|
||||
return orgGeneralSettings;
|
||||
public OrgGeneralSettings getGeneralSettings() {
|
||||
return generalSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -276,8 +277,8 @@ public class OrgSettings extends ResourceType<OrgSettings> {
|
|||
* {@link OrgLdapSettings }
|
||||
*
|
||||
*/
|
||||
public OrgLdapSettings getOrgLdapSettings() {
|
||||
return orgLdapSettings;
|
||||
public OrgLdapSettings getLdapSettings() {
|
||||
return ldapSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -288,8 +289,8 @@ public class OrgSettings extends ResourceType<OrgSettings> {
|
|||
* {@link OrgEmailSettings }
|
||||
*
|
||||
*/
|
||||
public OrgEmailSettings getOrgEmailSettings() {
|
||||
return orgEmailSettings;
|
||||
public OrgEmailSettings getEmailSettings() {
|
||||
return emailSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -300,8 +301,8 @@ public class OrgSettings extends ResourceType<OrgSettings> {
|
|||
* {@link OrgPasswordPolicySettings }
|
||||
*
|
||||
*/
|
||||
public OrgPasswordPolicySettings getOrgPasswordPolicySettings() {
|
||||
return orgPasswordPolicySettings;
|
||||
public OrgPasswordPolicySettings getPasswordPolicy() {
|
||||
return passwordPolicy;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -312,34 +313,34 @@ public class OrgSettings extends ResourceType<OrgSettings> {
|
|||
return false;
|
||||
OrgSettings that = OrgSettings.class.cast(o);
|
||||
return super.equals(that) &&
|
||||
equal(orgGeneralSettings, that.orgGeneralSettings) &&
|
||||
equal(generalSettings, that.generalSettings) &&
|
||||
equal(vAppLeaseSettings, that.vAppLeaseSettings) &&
|
||||
equal(vAppTemplateLeaseSettings, that.vAppTemplateLeaseSettings) &&
|
||||
equal(orgLdapSettings, that.orgLdapSettings) &&
|
||||
equal(orgEmailSettings, that.orgEmailSettings) &&
|
||||
equal(orgPasswordPolicySettings, that.orgPasswordPolicySettings);
|
||||
equal(ldapSettings, that.ldapSettings) &&
|
||||
equal(emailSettings, that.emailSettings) &&
|
||||
equal(passwordPolicy, that.passwordPolicy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(super.hashCode(),
|
||||
orgGeneralSettings,
|
||||
generalSettings,
|
||||
vAppLeaseSettings,
|
||||
vAppTemplateLeaseSettings,
|
||||
orgLdapSettings,
|
||||
orgEmailSettings,
|
||||
orgPasswordPolicySettings);
|
||||
ldapSettings,
|
||||
emailSettings,
|
||||
passwordPolicy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ToStringHelper string() {
|
||||
return super.string()
|
||||
.add("orgGeneralSettings", orgGeneralSettings)
|
||||
.add("generalSettings", generalSettings)
|
||||
.add("vAppLeaseSettings", vAppLeaseSettings)
|
||||
.add("vAppTemplateLeaseSettings", vAppTemplateLeaseSettings)
|
||||
.add("orgLdapSettings", orgLdapSettings)
|
||||
.add("orgEmailSettings", orgEmailSettings)
|
||||
.add("orgPasswordPolicySettings", orgPasswordPolicySettings);
|
||||
.add("ldapSettings", ldapSettings)
|
||||
.add("emailSettings", emailSettings)
|
||||
.add("passwordPolicy", passwordPolicy);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,17 +19,18 @@
|
|||
|
||||
package org.jclouds.vcloud.director.v1_5.domain;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.Sets;
|
||||
import static com.google.common.base.Objects.equal;
|
||||
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.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import java.net.URI;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -25,6 +25,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
|
|
@ -111,4 +111,11 @@ public class Reference extends ReferenceType<Reference> {
|
|||
Reference that = Reference.class.cast(o);
|
||||
return super.equals(that);
|
||||
}
|
||||
|
||||
public ReferenceType<?> toAdminReference(String endpoint) {
|
||||
return toBuilder()
|
||||
.type(null)
|
||||
.href(URI.create(getHref().toASCIIString().replace(endpoint, endpoint+"/admin")))
|
||||
.build();
|
||||
}
|
||||
}
|
|
@ -22,6 +22,7 @@ import static com.google.common.base.Objects.equal;
|
|||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||
|
||||
|
@ -43,7 +44,7 @@ import com.google.common.base.Objects.ToStringHelper;
|
|||
CatalogReference.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() {
|
||||
return new Builder<T>();
|
||||
|
@ -176,14 +177,6 @@ public class ReferenceType<T extends ReferenceType<T>> implements URISupplier {
|
|||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see URISupplier#getURI()
|
||||
*/
|
||||
@Override
|
||||
public URI getURI() {
|
||||
return getHref();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
|
|
|
@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
|
|
@ -20,16 +20,15 @@
|
|||
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.net.URI;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
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.
|
||||
|
@ -73,11 +72,11 @@ public abstract class ResourceEntityType<T extends ResourceEntityType<T>> extend
|
|||
}
|
||||
|
||||
/**
|
||||
* @see EntityType#getTasksInProgress()
|
||||
* @see EntityType#getTasks()
|
||||
*/
|
||||
@Override
|
||||
public Builder<T> tasksInProgress(TasksInProgress tasksInProgress) {
|
||||
this.tasksInProgress = tasksInProgress;
|
||||
public Builder<T> tasks(Set<Task> tasks) {
|
||||
super.tasks(tasks);
|
||||
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) {
|
||||
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links"));
|
||||
super.links(links);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EntityType#getLinks()
|
||||
* @see ResourceEntityType#getLinks()
|
||||
*/
|
||||
@Override
|
||||
public Builder<T> link(Link link) {
|
||||
this.links.add(checkNotNull(link, "link"));
|
||||
super.link(link);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -133,8 +130,8 @@ public abstract class ResourceEntityType<T extends ResourceEntityType<T>> extend
|
|||
@XmlAttribute
|
||||
protected Integer status;
|
||||
|
||||
public ResourceEntityType(URI href, String type, Set<Link> links, String description, TasksInProgress tasksInProgress, String id, String name, FilesList files, Integer status) {
|
||||
super(href, type, links, description, tasksInProgress, id, name);
|
||||
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, tasks, id, name);
|
||||
this.files = files;
|
||||
this.status = status;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ import java.util.Set;
|
|||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
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.ToStringHelper;
|
||||
|
@ -46,7 +46,7 @@ import com.google.common.collect.Sets;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public abstract class ResourceType<T extends ResourceType<T>> implements URISupplier {
|
||||
public abstract class ResourceType<T extends ResourceType<T>> {
|
||||
|
||||
public NewBuilder<?> toNewBuilder() {
|
||||
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 String type;
|
||||
protected Set<Link> links = Sets.newLinkedHashSet();
|
||||
protected Set<Link> links;
|
||||
|
||||
/**
|
||||
* @see ResourceType#getHref()
|
||||
|
@ -87,6 +87,8 @@ public abstract class ResourceType<T extends ResourceType<T>> implements URISupp
|
|||
* @see ResourceType#getLinks()
|
||||
*/
|
||||
public T link(Link link) {
|
||||
if (links == null)
|
||||
links = Sets.newLinkedHashSet();
|
||||
this.links.add(checkNotNull(link, "link"));
|
||||
return self();
|
||||
}
|
||||
|
@ -104,7 +106,7 @@ public abstract class ResourceType<T extends ResourceType<T>> implements URISupp
|
|||
|
||||
protected URI href;
|
||||
protected String type;
|
||||
protected Set<Link> links = Sets.newLinkedHashSet();
|
||||
protected Set<Link> links;
|
||||
|
||||
/**
|
||||
* @see ResourceType#getHref()
|
||||
|
@ -134,6 +136,8 @@ public abstract class ResourceType<T extends ResourceType<T>> implements URISupp
|
|||
* @see ResourceType#getLinks()
|
||||
*/
|
||||
public Builder<T> link(Link link) {
|
||||
if (links == null)
|
||||
links = Sets.newLinkedHashSet();
|
||||
this.links.add(checkNotNull(link, "link"));
|
||||
return this;
|
||||
}
|
||||
|
@ -150,12 +154,13 @@ public abstract class ResourceType<T extends ResourceType<T>> implements URISupp
|
|||
@XmlAttribute
|
||||
private String type;
|
||||
@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.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() {
|
||||
|
@ -179,14 +184,6 @@ public abstract class ResourceType<T extends ResourceType<T>> implements URISupp
|
|||
return href;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see URISupplier#getURI()
|
||||
*/
|
||||
@Override
|
||||
public URI getURI() {
|
||||
return getHref();
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains the type of the the entity.
|
||||
* <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.
|
||||
*/
|
||||
public Set<Link> getLinks() {
|
||||
return Collections.unmodifiableSet(links);
|
||||
return links == null ? ImmutableSet.<Link>of() : Collections.unmodifiableSet(links);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
|
|
@ -61,7 +61,7 @@ import com.google.common.base.Objects.ToStringHelper;
|
|||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "SmtpServerSettings", propOrder = {
|
||||
"isUseAuthentication",
|
||||
"useAuthentication",
|
||||
"host",
|
||||
"username",
|
||||
"password"
|
||||
|
@ -200,8 +200,7 @@ public class SmtpServerSettings {
|
|||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
SmtpServerSettings that = SmtpServerSettings.class.cast(o);
|
||||
return super.equals(that) &&
|
||||
equal(useAuthentication, that.useAuthentication) &&
|
||||
return equal(useAuthentication, that.useAuthentication) &&
|
||||
equal(host, that.host) &&
|
||||
equal(username, that.username) &&
|
||||
equal(password, that.password);
|
||||
|
@ -209,8 +208,7 @@ public class SmtpServerSettings {
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(super.hashCode(),
|
||||
useAuthentication,
|
||||
return Objects.hashCode(useAuthentication,
|
||||
host,
|
||||
username,
|
||||
password);
|
||||
|
|
|
@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
|
|
@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
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.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
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.ToStringHelper;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* Represents an asynchronous or long-running task in the vCloud environment.
|
||||
|
@ -43,6 +42,8 @@ import com.google.common.collect.Sets;
|
|||
* <xs:complexType name="TaskType">
|
||||
* </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
|
||||
*/
|
||||
@XmlRootElement(name = "Task")
|
||||
|
@ -187,7 +188,7 @@ public class Task extends EntityType<Task> {
|
|||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -219,11 +220,11 @@ public class Task extends EntityType<Task> {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see EntityType#getTasksInProgress()
|
||||
* @see EntityType#getTasks()
|
||||
*/
|
||||
@Override
|
||||
public Builder tasksInProgress(TasksInProgress tasksInProgress) {
|
||||
this.tasksInProgress = tasksInProgress;
|
||||
public Builder tasks(Set<Task> tasks) {
|
||||
super.tasks(tasks);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -246,23 +247,22 @@ public class Task extends EntityType<Task> {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see EntityType#getLinks()
|
||||
* @see ResourceType#getLinks()
|
||||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links"));
|
||||
return this;
|
||||
return Builder.class.cast(super.links(links));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EntityType#getLinks()
|
||||
* @see ResourceType#getLinks()
|
||||
*/
|
||||
@Override
|
||||
public Builder link(Link link) {
|
||||
this.links.add(checkNotNull(link, "link"));
|
||||
return this;
|
||||
return Builder.class.cast(super.link(link));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Builder fromEntityType(EntityType<Task> 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,
|
||||
Reference user, Object params, String status, String operation, String operationName,
|
||||
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.org = org;
|
||||
this.progress = progress;
|
||||
|
@ -383,6 +383,7 @@ public class Task extends EntityType<Task> {
|
|||
* <li>aborted - The task was aborted by an administrative action.
|
||||
* </ul>
|
||||
*/
|
||||
// TODO: enum!!!
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -22,12 +22,16 @@ import static com.google.common.base.Objects.equal;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
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.ToStringHelper;
|
||||
|
@ -35,33 +39,36 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* A list of tasks.
|
||||
* Task List
|
||||
*
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@XmlRootElement(name = "TasksList")
|
||||
public class TasksList extends EntityType<TasksList> {
|
||||
|
||||
public static final String MEDIA_TYPE = VCloudDirectorMediaType.TASKS_LIST;
|
||||
|
||||
public class TasksList extends ResourceType<TasksList> implements Set<Task> {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder toBuilder() {
|
||||
return new Builder();
|
||||
public static class Builder extends ResourceType.Builder<TasksList> {
|
||||
protected String name;
|
||||
|
||||
private Set<Task> tasks;
|
||||
|
||||
/**
|
||||
* @see TasksList#getName()
|
||||
*/
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public static class Builder extends EntityType.Builder<TasksList> {
|
||||
|
||||
protected Set<Task> tasks = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* @see TasksList#getTasks()
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -69,111 +76,86 @@ public class TasksList extends EntityType<TasksList> {
|
|||
* @see TasksList#getTasks()
|
||||
*/
|
||||
public Builder task(Task task) {
|
||||
if (tasks == null)
|
||||
tasks = Sets.newLinkedHashSet();
|
||||
this.tasks.add(checkNotNull(task, "task"));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
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()
|
||||
*/
|
||||
@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()
|
||||
* @see ResourceType#getHref()
|
||||
*/
|
||||
@Override
|
||||
public Builder href(URI href) {
|
||||
this.href = href;
|
||||
super.href(href);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ReferenceType#getType()
|
||||
* @see ResourceType#getType()
|
||||
*/
|
||||
@Override
|
||||
public Builder type(String type) {
|
||||
this.type = type;
|
||||
super.type(type);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EntityType#getLinks()
|
||||
* @see ResourceType#getLinks()
|
||||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links"));
|
||||
return this;
|
||||
return Builder.class.cast(super.links(links));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EntityType#getLinks()
|
||||
* @see ResourceType#getLinks()
|
||||
*/
|
||||
@Override
|
||||
public Builder link(Link link) {
|
||||
this.links.add(checkNotNull(link, "link"));
|
||||
super.link(link);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder fromEntityType(EntityType<TasksList> in) {
|
||||
return Builder.class.cast(super.fromEntityType(in));
|
||||
public Builder fromTasksList(TasksList in) {
|
||||
return fromResourceType(in).tasks(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() {
|
||||
// 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();
|
||||
|
||||
public Set<Task> getTasks() {
|
||||
return Collections.unmodifiableSet(tasks);
|
||||
/**
|
||||
* Contains the name of the the entity.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -183,16 +165,91 @@ public class TasksList extends EntityType<TasksList> {
|
|||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
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
|
||||
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
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -23,6 +23,7 @@ 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.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
@ -269,7 +270,7 @@ public class User
|
|||
|
||||
|
||||
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,
|
||||
im, nameInSource, isAlertEnabled, alertEmailPrefix, alertEmail,
|
||||
isExternal, isDefaultCached, isGroupRole, storedVmQuota, deployedVmQuota,
|
||||
|
@ -287,11 +288,11 @@ public class User
|
|||
}
|
||||
|
||||
/**
|
||||
* @see EntityType#getTasksInProgress()
|
||||
* @see EntityType#getTasks()
|
||||
*/
|
||||
@Override
|
||||
public Builder tasksInProgress(TasksInProgress tasksInProgress) {
|
||||
this.tasksInProgress = tasksInProgress;
|
||||
public Builder tasks(Set<Task> tasks) {
|
||||
super.tasks(tasks);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -397,12 +398,12 @@ public class User
|
|||
@XmlElement(name = "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 im, String nameInSource, Boolean alertEnabled, String alertEmailPrefix, String alertEmail,
|
||||
Boolean external, Boolean defaultCached, Boolean groupRole, Integer storedVmQuota, Integer deployedVmQuota,
|
||||
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.emailAddress = emailAddress;
|
||||
this.telephone = telephone;
|
||||
|
|
|
@ -33,6 +33,7 @@ import javax.xml.bind.annotation.XmlType;
|
|||
|
||||
import com.google.common.base.Objects;
|
||||
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)
|
||||
@XmlRootElement(name = "UsersList")
|
||||
@XmlType(propOrder = {
|
||||
"userReference"
|
||||
"users"
|
||||
})
|
||||
public class UsersList {
|
||||
public static Builder builder() {
|
||||
|
@ -74,7 +75,7 @@ public class UsersList {
|
|||
}
|
||||
|
||||
public static class Builder {
|
||||
private List<Reference> users;
|
||||
private List<Reference> users = Lists.newArrayList();
|
||||
|
||||
/**
|
||||
* @see UsersList#getUsers()
|
||||
|
|
|
@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
|
||||
import java.net.URI;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
|
|
@ -25,6 +25,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementRef;
|
||||
|
@ -144,7 +145,7 @@ public class VAppTemplate extends ResourceEntityType<VAppTemplate> {
|
|||
|
||||
@Override
|
||||
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
|
||||
|
@ -209,11 +210,11 @@ public class VAppTemplate extends ResourceEntityType<VAppTemplate> {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see EntityType#getTasksInProgress()
|
||||
* @see EntityType#getTasks()
|
||||
*/
|
||||
@Override
|
||||
public Builder tasksInProgress(TasksInProgress tasksInProgress) {
|
||||
super.tasksInProgress(tasksInProgress);
|
||||
public Builder tasks(Set<Task> tasks) {
|
||||
super.tasks(tasks);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -267,10 +268,10 @@ public class VAppTemplate extends ResourceEntityType<VAppTemplate> {
|
|||
@XmlAttribute
|
||||
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,
|
||||
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.children = VAppTemplateChildren.builder().vms(children).build();
|
||||
this.sections = ImmutableSet.copyOf(sections);
|
||||
|
|
|
@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
|
|
@ -20,10 +20,10 @@
|
|||
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.net.URI;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
@ -31,7 +31,6 @@ import javax.xml.bind.annotation.XmlSeeAlso;
|
|||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -198,7 +197,7 @@ public class Vdc
|
|||
|
||||
public Vdc build() {
|
||||
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,
|
||||
vmQuota, isEnabled, status);
|
||||
}
|
||||
|
@ -229,11 +228,11 @@ public class Vdc
|
|||
}
|
||||
|
||||
/**
|
||||
* @see EntityType#getTasksInProgress()
|
||||
* @see EntityType#getTasks()
|
||||
*/
|
||||
@Override
|
||||
public Builder tasksInProgress(TasksInProgress tasksInProgress) {
|
||||
this.tasksInProgress = tasksInProgress;
|
||||
public Builder tasks(Set<Task> tasks) {
|
||||
super.tasks(tasks);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -260,7 +259,7 @@ public class Vdc
|
|||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links"));
|
||||
super.links(links);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -269,11 +268,10 @@ public class Vdc
|
|||
*/
|
||||
@Override
|
||||
public Builder link(Link link) {
|
||||
this.links.add(checkNotNull(link, "link"));
|
||||
super.link(link);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Builder fromEntityType(EntityType<Vdc> 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) {
|
||||
super(href, type, links, description, tasksInProgress, id, name);
|
||||
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, tasks, id, name);
|
||||
this.allocationModel = allocationModel;
|
||||
this.storageCapacity = storageCapacity;
|
||||
this.computeCapacity = computeCapacity;
|
||||
|
|
|
@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
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.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -75,7 +77,7 @@ public class Vdcs {
|
|||
|
||||
public static class Builder {
|
||||
|
||||
private List<Reference> vdcs;
|
||||
private List<Reference> vdcs = Lists.newArrayList();
|
||||
|
||||
/**
|
||||
* @see Vdcs#getVdc()
|
||||
|
|
|
@ -25,7 +25,10 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -23,3 +23,4 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_CI
|
|||
|
||||
import javax.xml.bind.annotation.XmlNsForm;
|
||||
import javax.xml.bind.annotation.XmlSchema;
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
package org.jclouds.vcloud.director.v1_5.domain.ovf;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.jclouds.vcloud.director.v1_5.domain.ovf;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
|
|
@ -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 java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
|
|
@ -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 java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
|
|
@ -30,3 +30,4 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OV
|
|||
import javax.xml.bind.annotation.XmlNs;
|
||||
import javax.xml.bind.annotation.XmlNsForm;
|
||||
import javax.xml.bind.annotation.XmlSchema;
|
||||
|
||||
|
|
|
@ -30,3 +30,4 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OV
|
|||
import javax.xml.bind.annotation.XmlNs;
|
||||
import javax.xml.bind.annotation.XmlNsForm;
|
||||
import javax.xml.bind.annotation.XmlSchema;
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
|
||||
import java.net.URI;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.jclouds.vcloud.director.v1_5.domain.CatalogReference;
|
||||
|
|
|
@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
|
||||
import java.net.URI;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Link;
|
||||
|
|
|
@ -25,6 +25,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlSchemaType;
|
||||
|
|
|
@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
|
||||
import java.net.URI;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Link;
|
||||
|
|
|
@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
|
||||
import java.net.URI;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlSchemaType;
|
||||
|
|
|
@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
|
||||
import java.net.URI;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElementRef;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
|
|
|
@ -24,11 +24,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
|
||||
import java.net.URI;
|
||||
import java.util.Set;
|
||||
|
||||
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.domain.CatalogReference;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Link;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
|
||||
|
||||
|
|
|
@ -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_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.XmlNsForm;
|
||||
import javax.xml.bind.annotation.XmlSchema;
|
||||
|
||||
|
|
|
@ -31,3 +31,4 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OV
|
|||
import javax.xml.bind.annotation.XmlNs;
|
||||
import javax.xml.bind.annotation.XmlNsForm;
|
||||
import javax.xml.bind.annotation.XmlSchema;
|
||||
|
||||
|
|
|
@ -50,6 +50,18 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
@RequestFilters(AddVCloudAuthorizationToRequest.class)
|
||||
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)
|
||||
*/
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue