mirror of https://github.com/apache/jclouds.git
Merge pull request #1198 from jclouds/easy-deprecation-cleaning
removed deprecated methods which were easy to do
This commit is contained in:
commit
28e29c3756
|
@ -33,10 +33,6 @@ import com.google.inject.ImplementedBy;
|
|||
@ImplementedBy(CloudStackContextImpl.class)
|
||||
public interface CloudStackContext extends ComputeServiceContext {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
RestContext<CloudStackClient, CloudStackAsyncClient> getProviderSpecificContext();
|
||||
|
||||
RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> getDomainContext();
|
||||
|
||||
RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> getGlobalContext();
|
||||
|
|
|
@ -22,8 +22,6 @@ import javax.inject.Inject;
|
|||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.Context;
|
||||
import org.jclouds.cloudstack.CloudStackAsyncClient;
|
||||
import org.jclouds.cloudstack.CloudStackClient;
|
||||
import org.jclouds.cloudstack.CloudStackContext;
|
||||
import org.jclouds.cloudstack.CloudStackDomainAsyncClient;
|
||||
import org.jclouds.cloudstack.CloudStackDomainClient;
|
||||
|
@ -55,11 +53,6 @@ public class CloudStackContextImpl extends ComputeServiceContextImpl implements
|
|||
this.globalContext = globalContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestContext<CloudStackClient, CloudStackAsyncClient> getProviderSpecificContext() {
|
||||
return unwrap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> getDomainContext() {
|
||||
return domainContext;
|
||||
|
|
|
@ -67,7 +67,7 @@ public class ApiKeyPairs {
|
|||
.credentials(String.format("%s/%s", checkNotNull(domain, "domain"), checkNotNull(username, "username")), password)
|
||||
.overrides(overrides).build(CloudStackContext.class);
|
||||
|
||||
CloudStackClient client = context.getProviderSpecificContext().getApi();
|
||||
CloudStackClient client = context.unwrap(CloudStackApiMetadata.CONTEXT_TOKEN).getApi();
|
||||
Set<Account> listOfAccounts = client.getAccountClient().listAccounts();
|
||||
|
||||
domain = (domain.equals("") || domain.equals("/")) ? "ROOT" : domain;
|
||||
|
|
|
@ -38,7 +38,7 @@ import com.google.common.net.HttpHeaders;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "PasswordAuthenticationExpectTest")
|
||||
public class PasswordAuthenticationExpectTest extends BaseCloudStackExpectTest<CloudStackContext> {
|
||||
public class PasswordAuthenticationExpectTest extends BaseCloudStackExpectTest<AccountClient> {
|
||||
|
||||
/**
|
||||
* this reflects the properties that a user would pass to createContext
|
||||
|
@ -52,7 +52,7 @@ public class PasswordAuthenticationExpectTest extends BaseCloudStackExpectTest<C
|
|||
|
||||
public void testLoginWithPasswordSetsSessionKeyAndCookie() {
|
||||
|
||||
CloudStackContext context = requestsSendResponses(
|
||||
AccountClient client = requestsSendResponses(
|
||||
login, loginResponse,
|
||||
HttpRequest.builder()
|
||||
.method("GET")
|
||||
|
@ -65,16 +65,12 @@ public class PasswordAuthenticationExpectTest extends BaseCloudStackExpectTest<C
|
|||
.payload(payloadFromResource("/listaccountsresponse.json"))
|
||||
.build()
|
||||
,logout, logoutResponse);
|
||||
|
||||
AccountClient client = context.getProviderSpecificContext().getApi().getAccountClient();
|
||||
|
||||
assertNotNull(client.listAccounts());
|
||||
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CloudStackContext clientFrom(CloudStackContext context) {
|
||||
return context;
|
||||
protected AccountClient clientFrom(CloudStackContext context) {
|
||||
return context.unwrap(CloudStackApiMetadata.CONTEXT_TOKEN).getApi().getAccountClient();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import static org.testng.Assert.assertEquals;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.cloudstack.CloudStackApiMetadata;
|
||||
import org.jclouds.cloudstack.CloudStackContext;
|
||||
import org.jclouds.cloudstack.domain.Account;
|
||||
import org.jclouds.cloudstack.domain.User;
|
||||
|
@ -104,6 +105,6 @@ public class AccountClientExpectTest extends BaseCloudStackExpectTest<AccountCli
|
|||
|
||||
@Override
|
||||
protected AccountClient clientFrom(CloudStackContext context) {
|
||||
return context.getProviderSpecificContext().getApi().getAccountClient();
|
||||
return context.unwrap(CloudStackApiMetadata.CONTEXT_TOKEN).getApi().getAccountClient();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import static org.testng.Assert.assertNull;
|
|||
import java.net.URI;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.cloudstack.CloudStackApiMetadata;
|
||||
import org.jclouds.cloudstack.CloudStackContext;
|
||||
import org.jclouds.cloudstack.domain.AsyncCreateResponse;
|
||||
import org.jclouds.cloudstack.domain.FirewallRule;
|
||||
|
@ -285,6 +286,6 @@ public class FirewallClientExpectTest extends BaseCloudStackExpectTest<FirewallC
|
|||
|
||||
@Override
|
||||
protected FirewallClient clientFrom(CloudStackContext context) {
|
||||
return context.getProviderSpecificContext().getApi().getFirewallClient();
|
||||
return context.unwrap(CloudStackApiMetadata.CONTEXT_TOKEN).getApi().getFirewallClient();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,12 +31,12 @@ import org.jclouds.http.HttpRequest;
|
|||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||
import com.google.common.reflect.Invokable;
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.reflect.Invokable;
|
||||
/**
|
||||
* Tests the behaviour of ISOAsyncClient.
|
||||
*
|
||||
|
|
|
@ -19,10 +19,10 @@
|
|||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import static org.jclouds.cloudstack.options.ListISOsOptions.Builder.accountInDomain;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
||||
import org.jclouds.cloudstack.CloudStackApiMetadata;
|
||||
import org.jclouds.cloudstack.CloudStackContext;
|
||||
import org.jclouds.cloudstack.domain.ISO;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackExpectTest;
|
||||
|
@ -221,6 +221,6 @@ public class ISOClientExpectTest extends BaseCloudStackExpectTest<ISOClient> {
|
|||
|
||||
@Override
|
||||
protected ISOClient clientFrom(CloudStackContext context) {
|
||||
return context.getProviderSpecificContext().getApi().getISOClient();
|
||||
return context.unwrap(CloudStackApiMetadata.CONTEXT_TOKEN).getApi().getISOClient();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import static org.testng.Assert.assertTrue;
|
|||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.cloudstack.CloudStackApiMetadata;
|
||||
import org.jclouds.cloudstack.CloudStackContext;
|
||||
import org.jclouds.cloudstack.domain.SshKeyPair;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackExpectTest;
|
||||
|
@ -181,6 +182,6 @@ public class SSHKeyPairClientExpectTest extends BaseCloudStackExpectTest<SSHKeyP
|
|||
|
||||
@Override
|
||||
protected SSHKeyPairClient clientFrom(CloudStackContext context) {
|
||||
return context.getProviderSpecificContext().getApi().getSSHKeyPairClient();
|
||||
return context.unwrap(CloudStackApiMetadata.CONTEXT_TOKEN).getApi().getSSHKeyPairClient();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import static org.testng.Assert.assertEquals;
|
|||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.cloudstack.CloudStackApiMetadata;
|
||||
import org.jclouds.cloudstack.CloudStackContext;
|
||||
import org.jclouds.cloudstack.domain.Account;
|
||||
import org.jclouds.cloudstack.domain.LoginResponse;
|
||||
|
@ -94,6 +95,6 @@ public class SessionClientExpectTest extends BaseCloudStackExpectTest<SessionCli
|
|||
|
||||
@Override
|
||||
protected SessionClient clientFrom(CloudStackContext context) {
|
||||
return context.getProviderSpecificContext().getApi().getSessionClient();
|
||||
return context.unwrap(CloudStackApiMetadata.CONTEXT_TOKEN).getApi().getSessionClient();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.net.URI;
|
|||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.cert.CertificateException;
|
||||
|
||||
import org.jclouds.cloudstack.CloudStackApiMetadata;
|
||||
import org.jclouds.cloudstack.CloudStackContext;
|
||||
import org.jclouds.cloudstack.domain.EncryptedPasswordAndPrivateKey;
|
||||
import org.jclouds.cloudstack.functions.WindowsLoginCredentialsFromEncryptedData;
|
||||
|
@ -86,6 +87,6 @@ public class VirtualMachineClientExpectTest extends BaseCloudStackExpectTest<Vir
|
|||
|
||||
@Override
|
||||
protected VirtualMachineClient clientFrom(CloudStackContext context) {
|
||||
return context.getProviderSpecificContext().getApi().getVirtualMachineClient();
|
||||
return context.unwrap(CloudStackApiMetadata.CONTEXT_TOKEN).getApi().getVirtualMachineClient();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import static org.testng.Assert.assertEquals;
|
|||
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.cloudstack.CloudStackApiMetadata;
|
||||
import org.jclouds.cloudstack.CloudStackContext;
|
||||
import org.jclouds.cloudstack.domain.NetworkType;
|
||||
import org.jclouds.cloudstack.domain.Zone;
|
||||
|
@ -89,6 +90,6 @@ public class ZoneClientExpectTest extends BaseCloudStackExpectTest<ZoneClient> {
|
|||
|
||||
@Override
|
||||
protected ZoneClient clientFrom(CloudStackContext context) {
|
||||
return context.getProviderSpecificContext().getApi().getZoneClient();
|
||||
return context.unwrap(CloudStackApiMetadata.CONTEXT_TOKEN).getApi().getZoneClient();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -165,14 +165,6 @@ public class Reservation<T extends RunningInstance> extends ForwardingSet<T> imp
|
|||
public String getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #getGroupNames()
|
||||
*/
|
||||
@Deprecated
|
||||
public Set<String> getGroupIds() {
|
||||
return groupNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Names of the security groups.
|
||||
|
|
|
@ -473,14 +473,6 @@ public class RunningInstance implements Comparable<RunningInstance> {
|
|||
public Map<String, BlockDevice> getEbsBlockDevices() {
|
||||
return ebsBlockDevices;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #getGroupNames()
|
||||
*/
|
||||
@Deprecated
|
||||
public Set<String> getGroupIds() {
|
||||
return getGroupNames();
|
||||
}
|
||||
|
||||
/**
|
||||
* Names of the security groups.
|
||||
|
|
|
@ -194,14 +194,6 @@ public class SecurityGroup extends ForwardingSet<IpPermission> {
|
|||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Please use this class as a collection
|
||||
*/
|
||||
@Deprecated
|
||||
public Set<IpPermission> getIpPermissions() {
|
||||
return ipPermissions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(region, id, name, ownerId);
|
||||
|
|
|
@ -158,7 +158,7 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
|||
// make sure our dummy group has no rules
|
||||
SecurityGroup secgroup = Iterables.getOnlyElement(securityGroupClient.describeSecurityGroupsInRegion(null,
|
||||
"jclouds#" + group + "#" + instance.getRegion()));
|
||||
assert secgroup.getIpPermissions().size() == 0 : secgroup;
|
||||
assert secgroup.size() == 0 : secgroup;
|
||||
|
||||
// try to run a script with the original keyPair
|
||||
runScriptWithCreds(group, first.getOperatingSystem(),
|
||||
|
|
|
@ -87,23 +87,6 @@ public class Access extends ForwardingSet<Service> implements Comparable<Access>
|
|||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #services(Iterable)
|
||||
*/
|
||||
@Deprecated
|
||||
public T serviceCatalog(Set<Service> serviceCatalog) {
|
||||
this.serviceCatalog.addAll(serviceCatalog);
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #services(Iterable)
|
||||
*/
|
||||
@Deprecated
|
||||
public T serviceCatalog(Service... in) {
|
||||
return serviceCatalog(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
public Access build() {
|
||||
return new Access(token, user, serviceCatalog.build());
|
||||
}
|
||||
|
@ -145,14 +128,6 @@ public class Access extends ForwardingSet<Service> implements Comparable<Access>
|
|||
return this.user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Please access the service catalog via normal collection mechanisms
|
||||
*/
|
||||
@Deprecated
|
||||
public Set<Service> getServiceCatalog() {
|
||||
return this.serviceCatalog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(token, user, serviceCatalog);
|
||||
|
|
|
@ -86,14 +86,6 @@ public class Service extends ForwardingSet<Endpoint> {
|
|||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #endpoints(Iterable)
|
||||
*/
|
||||
@Deprecated
|
||||
public T endpoints(Endpoint... in) {
|
||||
return endpoints(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
public Service build() {
|
||||
return new Service(type, name, endpoints.build());
|
||||
}
|
||||
|
@ -141,14 +133,6 @@ public class Service extends ForwardingSet<Endpoint> {
|
|||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Please use this as a Set
|
||||
*/
|
||||
@Deprecated
|
||||
public Set<Endpoint> getEndpoints() {
|
||||
return this.endpoints;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(type, name, endpoints);
|
||||
|
|
|
@ -90,14 +90,6 @@ public class User extends ForwardingSet<Role> {
|
|||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #roles(Iterable)
|
||||
*/
|
||||
@Deprecated
|
||||
public T roles(Role... in) {
|
||||
return roles(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
public User build() {
|
||||
return new User(id, name, roles.build());
|
||||
}
|
||||
|
@ -146,15 +138,6 @@ public class User extends ForwardingSet<Role> {
|
|||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Please use User as a Set
|
||||
* @return the roles assigned to the user
|
||||
*/
|
||||
@Deprecated
|
||||
public Set<Role> getRoles() {
|
||||
return this.roles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(id, name, roles);
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.jclouds.View;
|
|||
import org.jclouds.blobstore.attr.ConsistencyModel;
|
||||
import org.jclouds.blobstore.internal.BlobStoreContextImpl;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.Utils;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
|
@ -116,15 +115,6 @@ public interface BlobStoreContext extends Closeable, View {
|
|||
*/
|
||||
Utils utils();
|
||||
|
||||
/**
|
||||
* will be removed in jclouds 1.6
|
||||
*
|
||||
* @see View#getInputType
|
||||
* @see View#unwrap
|
||||
*/
|
||||
@Deprecated
|
||||
<S, A> RestContext<S, A> getProviderSpecificContext();
|
||||
|
||||
/**
|
||||
* closes threads and resources related to this connection.
|
||||
*
|
||||
|
|
|
@ -1,131 +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.blobstore;
|
||||
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.ContextBuilder;
|
||||
import org.jclouds.apis.Apis;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.providers.ProviderMetadata;
|
||||
import org.jclouds.providers.Providers;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* This class is deprecated in favor of {@link ContextBuilder}. Please view
|
||||
* sample usage below:
|
||||
*
|
||||
* <pre>
|
||||
* context = ContextBuilder.newBuilder("aws-s3")
|
||||
* .credentials(apikey, secret)
|
||||
* .buildView(BlobStoreContext.class);
|
||||
* </pre>
|
||||
*
|
||||
* @see ContextBuilder
|
||||
* @deprecated As of version 1.5, replaced by {@link ContextBuilder}
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Deprecated
|
||||
public class BlobStoreContextFactory {
|
||||
|
||||
/**
|
||||
* for porting old code to {@link ContextBuilder}
|
||||
*/
|
||||
public BlobStoreContextFactory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* for porting old code to {@link ContextBuilder}
|
||||
*/
|
||||
public BlobStoreContextFactory(Properties properties) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #createContext(String, String,String, Iterable, Properties)
|
||||
*/
|
||||
public BlobStoreContext createContext(String providerOrApi, String identity, String credential) {
|
||||
return createContext(providerOrApi, identity, credential, ImmutableSet.<Module> of(), new Properties());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #createContext(String, String, String, Iterable, Properties)
|
||||
*/
|
||||
public BlobStoreContext createContext(String providerOrApi, Properties overrides) {
|
||||
return createContext(providerOrApi, null, null, ImmutableSet.<Module> of(), overrides);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #createContext(String, String,String, Iterable, Properties)
|
||||
*/
|
||||
public BlobStoreContext createContext(String providerOrApi, Iterable<? extends Module> wiring,
|
||||
Properties overrides) {
|
||||
return createContext(providerOrApi, null, null, wiring, overrides);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #createContext(String, String,String, Iterable, Properties)
|
||||
*/
|
||||
public BlobStoreContext createContext(String providerOrApi, @Nullable String identity,
|
||||
@Nullable String credential, Properties overrides) {
|
||||
return createContext(providerOrApi, identity, credential, ImmutableSet.<Module> of(), overrides);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see createContext(String, String,String, Iterable, Properties)
|
||||
*/
|
||||
public BlobStoreContext createContext(String providerOrApi, @Nullable String identity,
|
||||
@Nullable String credential, Iterable<? extends Module> wiring) {
|
||||
return createContext(providerOrApi, identity, credential, wiring, new Properties());
|
||||
}
|
||||
|
||||
/**
|
||||
* for porting old code to {@link ContextBuilder}
|
||||
*
|
||||
* @param providerOrApi
|
||||
* @param identity
|
||||
* nullable, if credentials are present in the overrides
|
||||
* @param credential
|
||||
* nullable, if credentials are present in the overrides
|
||||
* @param wiring
|
||||
* Configuration you'd like to pass to the context. Ex.
|
||||
* ImmutableSet.<Module>of(new ExecutorServiceModule(myexecutor))
|
||||
* @param overrides
|
||||
* properties to override defaults with.
|
||||
* @return initialized context ready for use
|
||||
*/
|
||||
public BlobStoreContext createContext(String providerOrApi, @Nullable String identity,
|
||||
@Nullable String credential, Iterable<? extends Module> wiring, Properties overrides) {
|
||||
ContextBuilder builder = null;
|
||||
try {
|
||||
ProviderMetadata pm = Providers.withId(providerOrApi);
|
||||
builder = ContextBuilder.newBuilder(pm);
|
||||
} catch (NoSuchElementException e) {
|
||||
builder = ContextBuilder.newBuilder(Apis.withId(providerOrApi));
|
||||
}
|
||||
builder.modules(wiring);
|
||||
builder.overrides(overrides);
|
||||
if (identity != null)
|
||||
builder.credentials(identity, credential);
|
||||
return builder.build(BlobStoreContext.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -118,12 +118,6 @@ public class BlobStoreContextImpl extends BaseView implements BlobStoreContext {
|
|||
return blobRequestSigner;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <S, A> RestContext<S, A> getProviderSpecificContext() {
|
||||
return (RestContext<S, A>) delegate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
Closeables.closeQuietly(delegate());
|
||||
|
|
|
@ -26,7 +26,6 @@ import java.util.regex.Matcher;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
import org.jclouds.blobstore.AsyncBlobStore;
|
||||
import org.jclouds.blobstore.BlobStoreContext;
|
||||
import org.jclouds.blobstore.domain.Blob;
|
||||
import org.jclouds.blobstore.domain.MutableBlobMetadata;
|
||||
import org.jclouds.blobstore.domain.internal.MutableBlobMetadataImpl;
|
||||
|
@ -36,7 +35,6 @@ import org.jclouds.http.HttpRequestFilter;
|
|||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
|
@ -93,11 +91,6 @@ public class BlobStoreUtils {
|
|||
return Futures.immediateFuture(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Iterable<String> getSupportedProviders() {
|
||||
return org.jclouds.rest.Providers.getSupportedProvidersOfType(TypeToken.of(BlobStoreContext.class));
|
||||
}
|
||||
|
||||
public static MutableBlobMetadata copy(MutableBlobMetadata in) {
|
||||
MutableBlobMetadata metadata = new MutableBlobMetadataImpl(in);
|
||||
|
|
|
@ -20,8 +20,7 @@
|
|||
(ns org.jclouds.blobstore2-test
|
||||
(:use [org.jclouds.blobstore2] :reload-all)
|
||||
(:use [clojure.test])
|
||||
(:import [org.jclouds.blobstore BlobStoreContextFactory]
|
||||
[java.io ByteArrayInputStream ByteArrayOutputStream
|
||||
(:import [java.io ByteArrayInputStream ByteArrayOutputStream
|
||||
StringBufferInputStream]
|
||||
[org.jclouds.util Strings2]))
|
||||
|
||||
|
|
|
@ -33,14 +33,12 @@ import org.jclouds.blobstore.AsyncBlobStore;
|
|||
import org.jclouds.blobstore.domain.Blob;
|
||||
import org.jclouds.blobstore.domain.MutableBlobMetadata;
|
||||
import org.jclouds.reflect.Invocation;
|
||||
import com.google.common.reflect.Invokable;
|
||||
import org.jclouds.rest.Providers;
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code BlobStoreUtils}
|
||||
|
@ -50,18 +48,6 @@ import com.google.common.collect.Iterables;
|
|||
@Test(groups = "unit")
|
||||
public class BlobStoreUtilsTest {
|
||||
|
||||
@Test
|
||||
public void testSupportedBlobStoreProviders() {
|
||||
Iterable<String> providers = BlobStoreUtils.getSupportedProviders();
|
||||
assert Iterables.contains(providers, "transient") : providers;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSupportedProviders() {
|
||||
Iterable<String> providers = Providers.getSupportedProviders();
|
||||
assert Iterables.contains(providers, "transient") : providers;
|
||||
}
|
||||
|
||||
public void testCreateParentIfNeededAsyncNoPath() {
|
||||
AsyncBlobStore asyncBlobStore = createMock(AsyncBlobStore.class);
|
||||
String container = "container";
|
||||
|
|
|
@ -87,14 +87,11 @@ public class Resource implements Comparable<Resource> {
|
|||
}
|
||||
|
||||
public Resource build() {
|
||||
return new Resource(this);
|
||||
return new Resource(id, name, links);
|
||||
}
|
||||
|
||||
public T fromResource(Resource in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.name(in.getName())
|
||||
.links(in.getLinks());
|
||||
return id(in.getId()).name(in.getName()).links(in.getLinks());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,13 +112,6 @@ public class Resource implements Comparable<Resource> {
|
|||
this.links = links == null ? ImmutableSet.<Link>of() : ImmutableSet.copyOf(links);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected Resource(Builder<?> builder) {
|
||||
this.id = checkNotNull(builder.id, "id");
|
||||
this.name = builder.name;
|
||||
this.links = ImmutableSet.copyOf(checkNotNull(builder.links, "links"));
|
||||
}
|
||||
|
||||
/**
|
||||
* When providing an ID, it is assumed that the resource exists in the current OpenStack
|
||||
* deployment
|
||||
|
|
|
@ -22,13 +22,8 @@ import static com.google.common.base.Objects.equal;
|
|||
import static com.google.common.base.Objects.toStringHelper;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
/**
|
||||
|
@ -77,49 +72,15 @@ public class Auth implements Comparable<Auth> {
|
|||
return token(from.getToken()).serviceCatalog(from.getServiceCatalog());
|
||||
}
|
||||
}
|
||||
|
||||
protected Auth() {
|
||||
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
|
||||
// prohibited in GAE. This also implies fields are not final.
|
||||
// see http://code.google.com/p/jclouds/issues/detail?id=925
|
||||
}
|
||||
|
||||
protected Token token;
|
||||
// TODO: get gson multimap adapter!
|
||||
protected Map<String, Set<Endpoint>> serviceCatalog = ImmutableMap.of();
|
||||
protected final Token token;
|
||||
protected final Multimap<String, Endpoint> serviceCatalog;
|
||||
|
||||
public Auth(Token token, Multimap<String, Endpoint> serviceCatalog) {
|
||||
this.token = checkNotNull(token, "token");
|
||||
this.serviceCatalog = toOldSchool(ImmutableMultimap.copyOf(checkNotNull(serviceCatalog, "serviceCatalog")));
|
||||
this.serviceCatalog = ImmutableMultimap.copyOf(checkNotNull(serviceCatalog, "serviceCatalog"));
|
||||
}
|
||||
|
||||
/**
|
||||
* The traditional way to represent a graph in Java is Map<V, Set<V>>, which is awkward in a number of ways. Guava's
|
||||
* Multimap framework makes it easy to handle a mapping from keys to multiple values.
|
||||
* <p/>
|
||||
* Until we write or discover a gson Multimap deserializer, we may be stuck with this.
|
||||
*
|
||||
* TODO: ask on stackoverflow and/or jesse wilson
|
||||
*/
|
||||
@Deprecated
|
||||
private static <K, V> Map<K, Set<V>> toOldSchool(Multimap<K, V> in) {
|
||||
ImmutableMap.Builder<K, Set<V>> out = ImmutableMap.builder();
|
||||
for (K type : in.keySet())
|
||||
out.put(type, ImmutableSet.copyOf(in.get(type)));
|
||||
return out.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #toOldSchool
|
||||
*/
|
||||
@Deprecated
|
||||
private static <K, V> ImmutableMultimap<K, V> fromOldSchool(Map<K, Set<V>> in) {
|
||||
ImmutableMultimap.Builder<K, V> out = ImmutableMultimap.builder();
|
||||
for (K type : in.keySet())
|
||||
out.putAll(type, ImmutableSet.copyOf(in.get(type)));
|
||||
return out.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
|
@ -131,7 +92,7 @@ public class Auth implements Comparable<Auth> {
|
|||
* TODO
|
||||
*/
|
||||
public Multimap<String, Endpoint> getServiceCatalog() {
|
||||
return fromOldSchool(serviceCatalog);
|
||||
return serviceCatalog;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,14 +19,10 @@
|
|||
package org.jclouds.compute;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.View;
|
||||
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.rest.RestContext;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.google.inject.ImplementedBy;
|
||||
|
||||
/**
|
||||
|
@ -41,24 +37,6 @@ public interface ComputeServiceContext extends Closeable, View {
|
|||
|
||||
ComputeService getComputeService();
|
||||
|
||||
/**
|
||||
* will be removed in jclouds 1.6
|
||||
*
|
||||
* @see Utils#getCredentialStore()
|
||||
*/
|
||||
@Deprecated
|
||||
@Beta
|
||||
Map<String, Credentials> getCredentialStore();
|
||||
|
||||
/**
|
||||
* will be removed in jclouds 1.6
|
||||
*
|
||||
* @see Utils#credentialStore()
|
||||
*/
|
||||
@Deprecated
|
||||
@Beta
|
||||
Map<String, Credentials> credentialStore();
|
||||
|
||||
Utils getUtils();
|
||||
|
||||
/**
|
||||
|
@ -66,15 +44,6 @@ public interface ComputeServiceContext extends Closeable, View {
|
|||
*/
|
||||
Utils utils();
|
||||
|
||||
/**
|
||||
* will be removed in jclouds 1.6
|
||||
*
|
||||
* @see View#getInputType
|
||||
* @see View#unwrap
|
||||
*/
|
||||
@Deprecated
|
||||
<S, A> RestContext<S, A> getProviderSpecificContext();
|
||||
|
||||
@Override
|
||||
void close();
|
||||
}
|
||||
|
|
|
@ -1,133 +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.compute;
|
||||
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.ContextBuilder;
|
||||
import org.jclouds.apis.Apis;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.providers.ProviderMetadata;
|
||||
import org.jclouds.providers.Providers;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* This class is deprecated in favor of {@link ContextBuilder}. Please view
|
||||
* sample usage below:
|
||||
*
|
||||
* <pre>
|
||||
* context = ContextBuilder.newBuilder("openstack-nova")
|
||||
* .endpoint("http://10.10.10.10:5000/v2.0")
|
||||
* .credentials(user, pass)
|
||||
* .modules(singleton(new SshjSshClientModule()))
|
||||
* .buildView(ComputeServiceContext.class);
|
||||
* </pre>
|
||||
*
|
||||
* @see ContextBuilder
|
||||
* @deprecated As of version 1.5, replaced by {@link ContextBuilder}
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Deprecated
|
||||
public class ComputeServiceContextFactory {
|
||||
|
||||
/**
|
||||
* for porting old code to {@link ContextBuilder}
|
||||
*/
|
||||
public ComputeServiceContextFactory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* for porting old code to {@link ContextBuilder}
|
||||
*/
|
||||
public ComputeServiceContextFactory(Properties properties) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #createContext(String, String,String, Iterable, Properties)
|
||||
*/
|
||||
public ComputeServiceContext createContext(String providerOrApi, String identity, String credential) {
|
||||
return createContext(providerOrApi, identity, credential, ImmutableSet.<Module> of(), new Properties());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #createContext(String, String, String, Iterable, Properties)
|
||||
*/
|
||||
public ComputeServiceContext createContext(String providerOrApi, Properties overrides) {
|
||||
return createContext(providerOrApi, null, null, ImmutableSet.<Module> of(), overrides);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #createContext(String, String,String, Iterable, Properties)
|
||||
*/
|
||||
public ComputeServiceContext createContext(String providerOrApi, Iterable<? extends Module> wiring,
|
||||
Properties overrides) {
|
||||
return createContext(providerOrApi, null, null, wiring, overrides);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #createContext(String, String,String, Iterable, Properties)
|
||||
*/
|
||||
public ComputeServiceContext createContext(String providerOrApi, @Nullable String identity,
|
||||
@Nullable String credential, Properties overrides) {
|
||||
return createContext(providerOrApi, identity, credential, ImmutableSet.<Module> of(), overrides);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see createContext(String, String,String, Iterable, Properties)
|
||||
*/
|
||||
public ComputeServiceContext createContext(String providerOrApi, @Nullable String identity,
|
||||
@Nullable String credential, Iterable<? extends Module> wiring) {
|
||||
return createContext(providerOrApi, identity, credential, wiring, new Properties());
|
||||
}
|
||||
|
||||
/**
|
||||
* for porting old code to {@link ContextBuilder}
|
||||
*
|
||||
* @param providerOrApi
|
||||
* @param identity
|
||||
* nullable, if credentials are present in the overrides
|
||||
* @param credential
|
||||
* nullable, if credentials are present in the overrides
|
||||
* @param wiring
|
||||
* Configuration you'd like to pass to the context. Ex.
|
||||
* ImmutableSet.<Module>of(new ExecutorServiceModule(myexecutor))
|
||||
* @param overrides
|
||||
* properties to override defaults with.
|
||||
* @return initialized context ready for use
|
||||
*/
|
||||
public ComputeServiceContext createContext(String providerOrApi, @Nullable String identity,
|
||||
@Nullable String credential, Iterable<? extends Module> wiring, Properties overrides) {
|
||||
ContextBuilder builder = null;
|
||||
try {
|
||||
ProviderMetadata pm = Providers.withId(providerOrApi);
|
||||
builder = ContextBuilder.newBuilder(pm);
|
||||
} catch (NoSuchElementException e) {
|
||||
builder = ContextBuilder.newBuilder(Apis.withId(providerOrApi));
|
||||
}
|
||||
builder.modules(wiring);
|
||||
builder.overrides(overrides);
|
||||
if (identity != null)
|
||||
builder.credentials(identity, credential);
|
||||
return builder.build(ComputeServiceContext.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -45,16 +45,6 @@ public class ExecResponse implements CustomizationResponse {
|
|||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* <h4>will be removed in jclouds 1.6.0</h4> <br/>
|
||||
*
|
||||
* @see #getExitStatus
|
||||
*/
|
||||
@Deprecated
|
||||
public int getExitCode() {
|
||||
return exitStatus;
|
||||
}
|
||||
|
||||
public int getExitStatus() {
|
||||
return exitStatus;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.jclouds.compute.domain;
|
|||
|
||||
import org.jclouds.compute.domain.internal.ImageImpl;
|
||||
import org.jclouds.domain.LoginCredentials;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.google.inject.ImplementedBy;
|
||||
|
@ -73,22 +72,6 @@ public interface Image extends ComputeMetadataIncludingStatus<Image.Status> {
|
|||
*/
|
||||
String getDescription();
|
||||
|
||||
/**
|
||||
* <h4>will be removed in jclouds 1.4.0</h4>
|
||||
*
|
||||
* secures access to root with a password. This password is required to access either the console
|
||||
* or run sudo as root.
|
||||
* <p/>
|
||||
* ex. {@code echo 'password' |sudo -S command}
|
||||
*
|
||||
*
|
||||
* @return root or console password, if configured, or null.
|
||||
* @see LoginCredentials#shouldAuthenticateSudo
|
||||
*/
|
||||
@Nullable
|
||||
@Deprecated
|
||||
String getAdminPassword();
|
||||
|
||||
/**
|
||||
* Default credentials for the current image
|
||||
*/
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.jclouds.compute.domain;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.domain.internal.NodeMetadataImpl;
|
||||
import org.jclouds.domain.LoginCredentials;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
@ -102,35 +103,11 @@ public interface NodeMetadata extends ComputeMetadataIncludingStatus<NodeMetadat
|
|||
@Nullable
|
||||
OperatingSystem getOperatingSystem();
|
||||
|
||||
/**
|
||||
* Current State of the node; replaced by {@link #getStatus()}
|
||||
* <h3>Note</h3>
|
||||
* will be removed in jclouds 1.6!
|
||||
* @see #getStatus()
|
||||
*/
|
||||
@Deprecated
|
||||
NodeState getState();
|
||||
|
||||
/**
|
||||
* @return the TCP port used for terminal connections. Generally, this is port 22 for ssh.
|
||||
*/
|
||||
int getLoginPort();
|
||||
|
||||
/**
|
||||
* <h4>will be removed in jclouds 1.4.0</h4>
|
||||
*
|
||||
* secures access to root with a password. This password is required to access either the console
|
||||
* or run sudo as root.
|
||||
* <p/>
|
||||
* ex. {@code echo 'password' |sudo -S command}
|
||||
*
|
||||
* @return root or console password, if configured, or null.
|
||||
* @see LoginCredentials#shouldAuthenticateSudo
|
||||
*/
|
||||
@Nullable
|
||||
@Deprecated
|
||||
String getAdminPassword();
|
||||
|
||||
/**
|
||||
* If possible, these are returned upon all detail requests. However, it is often the case that
|
||||
* credentials are only available when a node is initially created.
|
||||
|
|
|
@ -73,17 +73,6 @@ public class NodeMetadataBuilder extends ComputeMetadataBuilder {
|
|||
this.backendStatus = backendStatus;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* <h3>Note</h3>
|
||||
* will be removed in jclouds 1.6!
|
||||
* @see #status
|
||||
*/
|
||||
@Deprecated
|
||||
public NodeMetadataBuilder state(NodeState state) {
|
||||
this.status = checkNotNull(state, "state").toStatus();
|
||||
return this;
|
||||
}
|
||||
|
||||
public NodeMetadataBuilder publicAddresses(Iterable<String> publicAddresses) {
|
||||
this.publicAddresses = ImmutableSet.copyOf(checkNotNull(publicAddresses, "publicAddresses"));
|
||||
|
|
|
@ -1,101 +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.compute.domain;
|
||||
|
||||
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||
|
||||
/**
|
||||
* Indicates the status of a node. Replaced by {@link Status}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
* @see NodeMetadata#getStatus()
|
||||
*/
|
||||
@Deprecated
|
||||
public enum NodeState {
|
||||
/**
|
||||
* The node is in transition
|
||||
*
|
||||
* @see Status#PENDING
|
||||
*/
|
||||
PENDING,
|
||||
/**
|
||||
* The node is visible, and in the process of being deleted.
|
||||
*
|
||||
* @see Status#TERMINATED
|
||||
*/
|
||||
TERMINATED,
|
||||
/**
|
||||
* The node is deployed, but suspended or stopped.
|
||||
*
|
||||
* @see Status#SUSPENDED
|
||||
*/
|
||||
SUSPENDED,
|
||||
/**
|
||||
* The node is available for requests
|
||||
*
|
||||
* @see Status#RUNNING
|
||||
*/
|
||||
RUNNING,
|
||||
/**
|
||||
* There is an error on the node
|
||||
*
|
||||
* @see Status#ERROR
|
||||
*/
|
||||
ERROR,
|
||||
/**
|
||||
* The state of the node is unrecognized.
|
||||
*
|
||||
* @see Status#UNRECOGNIZED
|
||||
*/
|
||||
UNRECOGNIZED;
|
||||
|
||||
public static NodeState from(Status in) {
|
||||
switch (in) {
|
||||
case PENDING:
|
||||
return PENDING;
|
||||
case TERMINATED:
|
||||
return TERMINATED;
|
||||
case SUSPENDED:
|
||||
return SUSPENDED;
|
||||
case RUNNING:
|
||||
return RUNNING;
|
||||
case ERROR:
|
||||
return ERROR;
|
||||
default:
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
}
|
||||
|
||||
public Status toStatus() {
|
||||
switch (this) {
|
||||
case PENDING:
|
||||
return Status.PENDING;
|
||||
case TERMINATED:
|
||||
return Status.TERMINATED;
|
||||
case SUSPENDED:
|
||||
return Status.SUSPENDED;
|
||||
case RUNNING:
|
||||
return Status.RUNNING;
|
||||
case ERROR:
|
||||
return Status.ERROR;
|
||||
default:
|
||||
return Status.UNRECOGNIZED;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -107,16 +107,6 @@ public class ImageImpl extends ComputeMetadataImpl implements Image {
|
|||
return defaultCredentials;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getAdminPassword() {
|
||||
return (defaultCredentials != null && defaultCredentials.shouldAuthenticateSudo()) ? defaultCredentials
|
||||
.getPassword() : null;
|
||||
}
|
||||
|
||||
// equals and toString from super are sufficient to establish identity equivalence
|
||||
|
||||
protected ToStringHelper string() {
|
||||
|
|
|
@ -95,15 +95,6 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat
|
|||
return hardware;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getAdminPassword() {
|
||||
return (credentials != null && credentials.shouldAuthenticateSudo()) ? credentials.getPassword() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -128,15 +119,6 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat
|
|||
return privateAddresses;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public org.jclouds.compute.domain.NodeState getState() {
|
||||
return org.jclouds.compute.domain.NodeState.from(status);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
|
|
@ -20,8 +20,6 @@ package org.jclouds.compute.internal;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
|
@ -29,10 +27,8 @@ import org.jclouds.Context;
|
|||
import org.jclouds.compute.ComputeService;
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.Utils;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.internal.BaseView;
|
||||
import org.jclouds.location.Provider;
|
||||
import org.jclouds.rest.RestContext;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
|
||||
|
@ -57,12 +53,6 @@ public class ComputeServiceContextImpl extends BaseView implements ComputeServic
|
|||
return computeService;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <S, A> RestContext<S, A> getProviderSpecificContext() {
|
||||
return (RestContext<S, A>) delegate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
delegate().close();
|
||||
|
@ -77,15 +67,4 @@ public class ComputeServiceContextImpl extends BaseView implements ComputeServic
|
|||
public Utils utils() {
|
||||
return utils;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Credentials> credentialStore() {
|
||||
return utils().credentialStore();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Credentials> getCredentialStore() {
|
||||
return utils().credentialStore();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
* under the License.
|
||||
*/
|
||||
package org.jclouds.compute.reference;
|
||||
import static org.jclouds.compute.config.ComputeServiceProperties.BLACKLIST_NODES;
|
||||
import static org.jclouds.compute.config.ComputeServiceProperties.IMAGE_AUTHENTICATE_SUDO;
|
||||
import static org.jclouds.compute.config.ComputeServiceProperties.IMAGE_ID;
|
||||
import static org.jclouds.compute.config.ComputeServiceProperties.IMAGE_LOGIN_USER;
|
||||
import static org.jclouds.compute.config.ComputeServiceProperties.INIT_STATUS_INITIAL_PERIOD;
|
||||
import static org.jclouds.compute.config.ComputeServiceProperties.INIT_STATUS_MAX_PERIOD;
|
||||
import static org.jclouds.compute.config.ComputeServiceProperties.OS_VERSION_MAP_JSON;
|
||||
|
@ -54,67 +50,6 @@ public interface ComputeServiceConstants {
|
|||
|
||||
public static final String COMPUTE_LOGGER = "jclouds.compute";
|
||||
public static final String LOCAL_PARTITION_GB_PATTERN = "disk_drive/%s/gb";
|
||||
|
||||
/**
|
||||
* @see ComputeServiceProperties#TIMEOUT_NODE_TERMINATED
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String PROPERTY_TIMEOUT_NODE_TERMINATED = TIMEOUT_NODE_TERMINATED;
|
||||
/**
|
||||
* @see ComputeServiceProperties#TIMEOUT_NODE_RUNNING
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String PROPERTY_TIMEOUT_NODE_RUNNING = TIMEOUT_NODE_RUNNING;
|
||||
/**
|
||||
* @see ComputeServiceProperties#TIMEOUT_NODE_SUSPENDED
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String PROPERTY_TIMEOUT_NODE_SUSPENDED = TIMEOUT_NODE_SUSPENDED;
|
||||
/**
|
||||
* @see ComputeServiceProperties#TIMEOUT_SCRIPT_COMPLETE
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String PROPERTY_TIMEOUT_SCRIPT_COMPLETE = TIMEOUT_SCRIPT_COMPLETE;
|
||||
/**
|
||||
* @see ComputeServiceProperties#TIMEOUT_PORT_OPEN
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String PROPERTY_TIMEOUT_PORT_OPEN = TIMEOUT_PORT_OPEN;
|
||||
/**
|
||||
* @see ComputeServiceProperties#INIT_STATUS_INITIAL_PERIOD
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String PROPERTY_INIT_STATUS_INITIAL_PERIOD = INIT_STATUS_INITIAL_PERIOD;
|
||||
/**
|
||||
* @see ComputeServiceProperties#INIT_STATUS_MAX_PERIOD
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String PROPERTY_INIT_STATUS_MAX_PERIOD = INIT_STATUS_MAX_PERIOD;
|
||||
/**
|
||||
* @see ComputeServiceProperties#IMAGE_ID
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String PROPERTY_IMAGE_ID = IMAGE_ID;
|
||||
/**
|
||||
* @see ComputeServiceProperties#IMAGE_LOGIN_USER
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String PROPERTY_IMAGE_LOGIN_USER = IMAGE_LOGIN_USER;
|
||||
/**
|
||||
* @see ComputeServiceProperties#IMAGE_AUTHENTICATE_SUDO
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String PROPERTY_IMAGE_AUTHENTICATE_SUDO = IMAGE_AUTHENTICATE_SUDO;
|
||||
/**
|
||||
* @see ComputeServiceProperties#BLACKLIST_NODES
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String PROPERTY_BLACKLIST_NODES = BLACKLIST_NODES;
|
||||
/**
|
||||
* @see ComputeServiceProperties#OS_VERSION_MAP_JSON
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String PROPERTY_OS_VERSION_MAP_JSON = OS_VERSION_MAP_JSON;
|
||||
|
||||
@Singleton
|
||||
public static class NamingConvention {
|
||||
|
|
|
@ -29,11 +29,10 @@ import static org.jclouds.scriptbuilder.domain.Statements.pipeHttpResponseToBash
|
|||
import java.net.URI;
|
||||
import java.util.Formatter;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.domain.ComputeMetadata;
|
||||
import org.jclouds.compute.domain.ComputeMetadataIncludingStatus;
|
||||
import org.jclouds.compute.domain.Hardware;
|
||||
|
@ -51,9 +50,8 @@ import com.google.common.base.Joiner;
|
|||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -172,11 +170,6 @@ public class ComputeServiceUtils {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Iterable<String> getSupportedProviders() {
|
||||
return org.jclouds.rest.Providers.getSupportedProvidersOfType(TypeToken.of(ComputeServiceContext.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* For cloud apis that have a pattern of using empty strings as tags, return a map that contains
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.jclouds.ssh;
|
|||
|
||||
import org.jclouds.compute.domain.ExecChannel;
|
||||
import org.jclouds.compute.domain.ExecResponse;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.domain.LoginCredentials;
|
||||
import org.jclouds.io.Payload;
|
||||
|
||||
|
@ -33,14 +32,6 @@ public interface SshClient {
|
|||
|
||||
interface Factory {
|
||||
|
||||
/**
|
||||
* To be removed in jclouds 1.5.0
|
||||
*
|
||||
* @see #create(com.google.common.net.HostAndPort, LoginCredentials)
|
||||
*/
|
||||
@Deprecated
|
||||
SshClient create(HostAndPort socket, Credentials credentials);
|
||||
|
||||
SshClient create(HostAndPort socket, LoginCredentials credentials);
|
||||
|
||||
}
|
||||
|
|
|
@ -77,10 +77,6 @@
|
|||
(deftype SshClientFactory
|
||||
[factory-fn]
|
||||
org.jclouds.ssh.SshClient$Factory
|
||||
(^org.jclouds.ssh.SshClient
|
||||
create
|
||||
[_ ^HostAndPort socket ^Credentials credentials]
|
||||
(factory-fn socket (.identity credentials) (.credential credentials)))
|
||||
(^org.jclouds.ssh.SshClient
|
||||
create
|
||||
[_ ^HostAndPort socket ^LoginCredentials credentials]
|
||||
|
|
|
@ -19,17 +19,13 @@
|
|||
package org.jclouds;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.apis.ApiMetadata;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.internal.ContextImpl;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.providers.ProviderMetadata;
|
||||
import org.jclouds.rest.Utils;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.google.inject.ImplementedBy;
|
||||
|
||||
/**
|
||||
|
@ -53,24 +49,6 @@ public interface Context extends Location, Closeable {
|
|||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* will be removed in jclouds 1.6
|
||||
*
|
||||
* @see Utils#getCredentialStore()
|
||||
*/
|
||||
@Deprecated
|
||||
@Beta
|
||||
Map<String, Credentials> getCredentialStore();
|
||||
|
||||
/**
|
||||
* will be removed in jclouds 1.6
|
||||
*
|
||||
* @see Utils#credentialStore()
|
||||
*/
|
||||
@Deprecated
|
||||
@Beta
|
||||
Map<String, Credentials> credentialStore();
|
||||
|
||||
/**
|
||||
* @return the providerMetadata used to create this context
|
||||
* @see ContextBuilder#newBuilder(org.jclouds.providers.ProviderMetadata)
|
||||
|
@ -82,33 +60,6 @@ public interface Context extends Location, Closeable {
|
|||
* @see ApiMetadata#getDefaultIdentity
|
||||
*/
|
||||
String getIdentity();
|
||||
|
||||
/**
|
||||
* will be removed in jclouds 1.6
|
||||
* @see #getProviderMetadata()
|
||||
* @see ProviderMetadata#getEndpoint()
|
||||
*/
|
||||
@Deprecated
|
||||
URI getEndpoint();
|
||||
|
||||
/**
|
||||
* will be removed in jclouds 1.6
|
||||
* @see #getProviderMetadata()
|
||||
* @see ProviderMetadata#getApiMetadata()
|
||||
* @see ApiMetadata#getVersion()
|
||||
*/
|
||||
@Deprecated
|
||||
String getApiVersion();
|
||||
|
||||
/**
|
||||
* will be removed in jclouds 1.6
|
||||
* @see #getProviderMetadata()
|
||||
* @see ProviderMetadata#getApiMetadata()
|
||||
* @see ApiMetadata#getBuildVersion()
|
||||
*/
|
||||
@Deprecated
|
||||
@Nullable
|
||||
String getBuildVersion();
|
||||
|
||||
Utils getUtils();
|
||||
|
||||
|
|
|
@ -98,14 +98,6 @@ public class ContextImpl implements Context {
|
|||
return creds.get().identity;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public URI getEndpoint() {
|
||||
return URI.create(providerMetadata.getEndpoint());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -119,22 +111,6 @@ public class ContextImpl implements Context {
|
|||
return utils;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getApiVersion() {
|
||||
return providerMetadata.getApiMetadata().getVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getBuildVersion() {
|
||||
return providerMetadata.getApiMetadata().getBuildVersion().orNull();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -216,20 +192,4 @@ public class ContextImpl implements Context {
|
|||
return LocationScope.PROVIDER;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Credentials> credentialStore() {
|
||||
return utils().credentialStore();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Credentials> getCredentialStore() {
|
||||
return utils().credentialStore();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,59 +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.rest;
|
||||
|
||||
import org.jclouds.Context;
|
||||
import org.jclouds.View;
|
||||
import org.jclouds.apis.Apis;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.ImmutableSet.Builder;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
|
||||
/**
|
||||
* @see org.jclouds.providers.Providers
|
||||
* @see org.jclouds.apis.Apis
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Deprecated
|
||||
public class Providers {
|
||||
|
||||
/**
|
||||
* Gets a set of supported providers. Idea stolen from pallets (supported-clouds).
|
||||
*/
|
||||
public static Iterable<String> getSupportedProviders() {
|
||||
return getSupportedProvidersOfType(TypeToken.of(View.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a set of supported providers. Idea stolen from pallets
|
||||
* (supported-clouds).
|
||||
*
|
||||
*/
|
||||
public static <C extends Context> Iterable<String> getSupportedProvidersOfType(TypeToken<? extends View> type) {
|
||||
Builder<String> builder = ImmutableSet.<String> builder();
|
||||
builder.addAll(Iterables.transform(Apis.viewableAs(type), Apis.idFunction()));
|
||||
builder.addAll(Iterables.transform(org.jclouds.providers.Providers.viewableAs(type),
|
||||
org.jclouds.providers.Providers.idFunction()));
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,135 +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.rest;
|
||||
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.ContextBuilder;
|
||||
import org.jclouds.View;
|
||||
import org.jclouds.apis.Apis;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.providers.ProviderMetadata;
|
||||
import org.jclouds.providers.Providers;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
*
|
||||
* @see ContextBuilder
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Deprecated
|
||||
public class RestContextFactory {
|
||||
|
||||
/**
|
||||
* for porting old code to {@link ContextBuilder}
|
||||
*/
|
||||
public RestContextFactory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* for porting old code to {@link ContextBuilder}
|
||||
*/
|
||||
public RestContextFactory(Properties properties) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #createContext(String, String,String, Iterable, Properties)
|
||||
*/
|
||||
public <S, A> RestContext<S, A> createContext(String providerOrApi, String identity, String credential) {
|
||||
return createContext(providerOrApi, identity, credential, ImmutableSet.<Module> of(), new Properties());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #createContext(String, String, String, Iterable, Properties)
|
||||
*/
|
||||
public <S, A> RestContext<S, A> createContext(String providerOrApi, Properties overrides) {
|
||||
return createContext(providerOrApi, null, null, ImmutableSet.<Module> of(), overrides);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #createContext(String, String,String, Iterable, Properties)
|
||||
*/
|
||||
public <S, A> RestContext<S, A> createContext(String providerOrApi, Iterable<? extends Module> wiring,
|
||||
Properties overrides) {
|
||||
return createContext(providerOrApi, null, null, wiring, overrides);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #createContext(String, String,String, Iterable, Properties)
|
||||
*/
|
||||
public <S, A> RestContext<S, A> createContext(String providerOrApi, @Nullable String identity,
|
||||
@Nullable String credential, Properties overrides) {
|
||||
return createContext(providerOrApi, identity, credential, ImmutableSet.<Module> of(), overrides);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see createContext(String, String,String, Iterable, Properties)
|
||||
*/
|
||||
public <S, A> RestContext<S, A> createContext(String providerOrApi, @Nullable String identity,
|
||||
@Nullable String credential, Iterable<? extends Module> wiring) {
|
||||
return createContext(providerOrApi, identity, credential, wiring, new Properties());
|
||||
}
|
||||
|
||||
/**
|
||||
* for porting old code to {@link ContextBuilder}
|
||||
*
|
||||
* @param providerOrApi
|
||||
* @param identity
|
||||
* nullable, if credentials are present in the overrides
|
||||
* @param credential
|
||||
* nullable, if credentials are present in the overrides
|
||||
* @param wiring
|
||||
* Configuration you'd like to pass to the context. Ex.
|
||||
* ImmutableSet.<Module>of(new ExecutorServiceModule(myexecutor))
|
||||
* @param overrides
|
||||
* properties to override defaults with.
|
||||
* @return initialized context ready for use
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <S, A> RestContext<S, A> createContext(String providerOrApi, @Nullable String identity,
|
||||
@Nullable String credential, Iterable<? extends Module> wiring, Properties overrides) {
|
||||
ContextBuilder builder = null;
|
||||
try {
|
||||
ProviderMetadata pm = Providers.withId(providerOrApi);
|
||||
builder = ContextBuilder.newBuilder(pm);
|
||||
} catch (NoSuchElementException e) {
|
||||
builder = ContextBuilder.newBuilder(Apis.withId(providerOrApi));
|
||||
}
|
||||
builder.modules(Iterable.class.cast(wiring));
|
||||
builder.overrides(overrides);
|
||||
if (identity != null)
|
||||
builder.credentials(identity, credential);
|
||||
Object context = builder.build();
|
||||
if (context instanceof RestContext) {
|
||||
return RestContext.class.cast(context);
|
||||
} else if (context instanceof View) {
|
||||
View tctx = View.class.cast(context);
|
||||
return (RestContext<S, A>) tctx.unwrap(TypeToken.of(RestContext.class));
|
||||
} else {
|
||||
throw new IllegalArgumentException("provider " + providerOrApi + " contains an unknown context type: "
|
||||
+ context.getClass().getSimpleName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,42 +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.util;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ProvidersTest {
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
public void testSupportedProviders() {
|
||||
Iterable<String> providers = org.jclouds.rest.Providers.getSupportedProviders();
|
||||
assertEquals(Sets.newLinkedHashSet(providers), ImmutableSet.<String> of("test-blobstore-api", "test-compute-api",
|
||||
"test-yet-another-compute-api", "test-yet-another-compute-provider"));
|
||||
}
|
||||
|
||||
}
|
|
@ -21,7 +21,6 @@ package org.jclouds.ssh.jsch.config;
|
|||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.domain.LoginCredentials;
|
||||
import org.jclouds.http.handlers.BackoffLimitedRetryHandler;
|
||||
import org.jclouds.ssh.SshClient;
|
||||
|
@ -65,10 +64,5 @@ public class JschSshClientModule extends AbstractModule {
|
|||
injector.injectMembers(client);// add logger
|
||||
return client;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SshClient create(HostAndPort socket, Credentials credentials) {
|
||||
return create(socket, LoginCredentials.fromCredentials(credentials));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,10 +65,5 @@ public class SshjSshClientModule extends AbstractModule {
|
|||
injector.injectMembers(client);// add logger
|
||||
return client;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SshClient create(HostAndPort socket, Credentials credentials) {
|
||||
return create(socket, LoginCredentials.fromCredentials(credentials));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,8 +52,6 @@ import com.google.inject.TypeLiteral;
|
|||
*/
|
||||
@EnterpriseEdition
|
||||
public class StoragePool extends DomainWrapper<StoragePoolDto> {
|
||||
/** The default value for the used space. */
|
||||
private static final long DEFAULT_USED_SIZE = 0;
|
||||
|
||||
/** The datacenter where the storage device is. */
|
||||
// Package protected to allow the storage device to be set automatically when
|
||||
|
@ -185,22 +183,10 @@ public class StoragePool extends DomainWrapper<StoragePoolDto> {
|
|||
|
||||
public static class Builder {
|
||||
private RestContext<AbiquoApi, AbiquoAsyncApi> context;
|
||||
|
||||
private StorageDevice storageDevice;
|
||||
|
||||
private Long availableSizeInMb;
|
||||
|
||||
// The enabled flag is still not used. It will be added when Abiquo
|
||||
// includes anstorage
|
||||
// allocator
|
||||
|
||||
// private Boolean enabled;
|
||||
|
||||
private String name;
|
||||
|
||||
private Long totalSizeInMb;
|
||||
|
||||
private Long usedSizeInMb = DEFAULT_USED_SIZE;
|
||||
|
||||
public Builder(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final StorageDevice storageDevice) {
|
||||
super();
|
||||
|
@ -215,61 +201,22 @@ public class StoragePool extends DomainWrapper<StoragePoolDto> {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This value is no longer used in Abiquo and will be removed
|
||||
* in future versions.
|
||||
*/
|
||||
@Deprecated
|
||||
public Builder availableSizeInMb(final long availableSizeInMb) {
|
||||
this.availableSizeInMb = availableSizeInMb;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder name(final String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
// The enabled flag is still not used. It will be added when Abiquo
|
||||
// includes anstorage
|
||||
// allocator
|
||||
|
||||
// public Builder enabled(final boolean enabled)
|
||||
// {
|
||||
// this.enabled = enabled;
|
||||
// return this;
|
||||
// }
|
||||
|
||||
public Builder totalSizeInMb(final long totalSizeInMb) {
|
||||
this.totalSizeInMb = totalSizeInMb;
|
||||
if (availableSizeInMb == null) {
|
||||
availableSizeInMb = totalSizeInMb;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This value is no longer used in Abiquo and will be removed
|
||||
* in future versions.
|
||||
*/
|
||||
@Deprecated
|
||||
public Builder usedSizeInMb(final long usedSizeInMb) {
|
||||
this.usedSizeInMb = usedSizeInMb;
|
||||
return this;
|
||||
}
|
||||
|
||||
public StoragePool build() {
|
||||
StoragePoolDto dto = new StoragePoolDto();
|
||||
dto.setAvailableSizeInMb(availableSizeInMb);
|
||||
|
||||
// The enabled flag is still not used. It will be added when Abiquo
|
||||
// includes anstorage
|
||||
// allocator
|
||||
// dto.setEnabled(enabled);
|
||||
|
||||
dto.setName(name);
|
||||
dto.setTotalSizeInMb(totalSizeInMb);
|
||||
dto.setUsedSizeInMb(usedSizeInMb);
|
||||
StoragePool storagePool = new StoragePool(context, dto);
|
||||
storagePool.storageDevice = storageDevice;
|
||||
return storagePool;
|
||||
|
@ -277,11 +224,7 @@ public class StoragePool extends DomainWrapper<StoragePoolDto> {
|
|||
|
||||
public static Builder fromStoragePool(final StoragePool in) {
|
||||
Builder builder = StoragePool.builder(in.context, in.getStorageDevice())
|
||||
.availableSizeInMb(in.getAvailableSizeInMb())/*
|
||||
* .enabled(in.
|
||||
* getEnabled())
|
||||
*/
|
||||
.totalSizeInMb(in.getTotalSizeInMb()).usedSizeInMb(in.getUsedSizeInMb());
|
||||
.totalSizeInMb(in.getTotalSizeInMb());
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
@ -289,24 +232,6 @@ public class StoragePool extends DomainWrapper<StoragePoolDto> {
|
|||
|
||||
// Delegate methods
|
||||
|
||||
/**
|
||||
* @deprecated This value is no longer used in Abiquo and will be removed in
|
||||
* future versions.
|
||||
*/
|
||||
@Deprecated
|
||||
public long getAvailableSizeInMb() {
|
||||
return target.getAvailableSizeInMb();
|
||||
}
|
||||
|
||||
// The enabled flag is still not used. It will be added when Abiquo includes
|
||||
// anstorage
|
||||
// allocator
|
||||
|
||||
// public boolean getEnabled()
|
||||
// {
|
||||
// return target.getEnabled();
|
||||
// }
|
||||
|
||||
public String getName() {
|
||||
return target.getName();
|
||||
}
|
||||
|
@ -315,24 +240,6 @@ public class StoragePool extends DomainWrapper<StoragePoolDto> {
|
|||
return target.getTotalSizeInMb();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This value is no longer used in Abiquo and will be removed in
|
||||
* future versions.
|
||||
*/
|
||||
@Deprecated
|
||||
public long getUsedSizeInMb() {
|
||||
return target.getUsedSizeInMb();
|
||||
}
|
||||
|
||||
// The enabled flag is still not used. It will be added when Abiquo includes
|
||||
// anstorage
|
||||
// allocator
|
||||
|
||||
// public void setEnabled(final boolean enabled)
|
||||
// {
|
||||
// target.setEnabled(enabled);
|
||||
// }
|
||||
|
||||
public void setName(final String name) {
|
||||
target.setName(name);
|
||||
}
|
||||
|
|
|
@ -31,61 +31,45 @@ import org.jclouds.azure.management.domain.role.PersistentVMRole;
|
|||
*/
|
||||
public interface RoleApi {
|
||||
|
||||
// FUUUUUU this is not the good REST call !!! Use getDeployment instead :@
|
||||
PersistentVMRole getRole(String serviceName, String deploymentName,
|
||||
String roleName);
|
||||
// TODO: this is not the good REST call !!! Use getDeployment instead :@
|
||||
PersistentVMRole getRole(String serviceName, String deploymentName, String roleName);
|
||||
|
||||
// This is a PaaS REST service !
|
||||
// void addRole(String serviceName, String deploymentName, PersistentVMRole
|
||||
// role);
|
||||
String restartRole(String serviceName, String deploymentName, String roleName);
|
||||
|
||||
// This is a PaaS REST service ! => Delete the deployment instead
|
||||
// void deleteRole(String serviceName, String deploymentName, String
|
||||
// roleName);
|
||||
/**
|
||||
* http://msdn.microsoft.com/en-us/library/jj157194
|
||||
*
|
||||
* @param serviceName
|
||||
* @param deploymentParams
|
||||
* @return
|
||||
*/
|
||||
String createDeployment(String serviceName, DeploymentParams deploymentParams);
|
||||
|
||||
String restartRole(String serviceName, String deploymentName,
|
||||
String roleName);
|
||||
/**
|
||||
* http://msdn.microsoft.com/en-us/library/jj157201
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String captureRole(String serviceName, String deploymentName, String roleName, String imageName, String imageLabel);
|
||||
|
||||
// @Deprecated
|
||||
// String createVirtualMachineDeployment(String serviceName,
|
||||
// Deployment deployment);
|
||||
/**
|
||||
* http://msdn.microsoft.com/en-us/library/jj157195
|
||||
*
|
||||
* @param serviceName
|
||||
* @param deploymentName
|
||||
* @param roleName
|
||||
* @return
|
||||
*/
|
||||
String shutdownRole(String serviceName, String deploymentName, String roleName);
|
||||
|
||||
/**
|
||||
* http://msdn.microsoft.com/en-us/library/jj157194
|
||||
*
|
||||
* @param serviceName
|
||||
* @param deploymentParams
|
||||
* @return
|
||||
*/
|
||||
String createDeployment(String serviceName,
|
||||
DeploymentParams deploymentParams);
|
||||
|
||||
/**
|
||||
* http://msdn.microsoft.com/en-us/library/jj157201
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String captureRole(String serviceName, String deploymentName,
|
||||
String roleName, String imageName, String imageLabel);
|
||||
|
||||
/**
|
||||
* http://msdn.microsoft.com/en-us/library/jj157195
|
||||
* @param serviceName
|
||||
* @param deploymentName
|
||||
* @param roleName
|
||||
* @return
|
||||
*/
|
||||
String shutdownRole(String serviceName, String deploymentName,
|
||||
String roleName);
|
||||
|
||||
/**
|
||||
* http://msdn.microsoft.com/en-us/library/jj157189
|
||||
* @param serviceName
|
||||
* @param deploymentName
|
||||
* @param roleName
|
||||
* @return
|
||||
*/
|
||||
String startRole(String serviceName, String deploymentName,
|
||||
String roleName);
|
||||
/**
|
||||
* http://msdn.microsoft.com/en-us/library/jj157189
|
||||
*
|
||||
* @param serviceName
|
||||
* @param deploymentName
|
||||
* @param roleName
|
||||
* @return
|
||||
*/
|
||||
String startRole(String serviceName, String deploymentName, String roleName);
|
||||
|
||||
}
|
||||
|
|
|
@ -52,109 +52,76 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
@Headers(keys = "x-ms-version", values = "2012-03-01")
|
||||
public interface RoleAsyncApi {
|
||||
|
||||
@GET
|
||||
@Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}/roles/{roleName}")
|
||||
@Consumes(MediaType.APPLICATION_ATOM_XML)
|
||||
@JAXBResponseParser
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
ListenableFuture<PersistentVMRole> getRole(@PathParam("serviceName")
|
||||
String serviceName,
|
||||
@PathParam("deploymentName") String deploymentName,
|
||||
@PathParam("roleName") String roleName);
|
||||
@GET
|
||||
@Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}/roles/{roleName}")
|
||||
@Consumes(MediaType.APPLICATION_ATOM_XML)
|
||||
@JAXBResponseParser
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
ListenableFuture<PersistentVMRole> getRole(@PathParam("serviceName")
|
||||
String serviceName,
|
||||
@PathParam("deploymentName") String deploymentName,
|
||||
@PathParam("roleName") String roleName);
|
||||
|
||||
// This is a PaaS REST service ! => Delete the deployment instead
|
||||
// @DELETE
|
||||
// @Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}/roles/{roleName}")
|
||||
// @Consumes(MediaType.APPLICATION_ATOM_XML)
|
||||
// @JAXBResponseParser
|
||||
// @Fallback(NullOnNotFoundOr404.class)
|
||||
// ListenableFuture<Void> deleteRole(@PathParam("serviceName") String
|
||||
// serviceName,
|
||||
// @PathParam("deploymentName") String deploymentName,
|
||||
// @PathParam("roleName") String roleName);
|
||||
@POST
|
||||
// Warning : the url in the documentation is WRONG ! @see
|
||||
// http://social.msdn.microsoft.com/Forums/pl-PL/WAVirtualMachinesforWindows/thread/7ba2367b-e450-49e0-89e4-46c240e9d213
|
||||
@Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}/roleInstances/{roleName}/Operations")
|
||||
@Consumes(MediaType.APPLICATION_ATOM_XML)
|
||||
@Produces(MediaType.APPLICATION_ATOM_XML)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@ResponseParser(ParseRequestIdHeader.class)
|
||||
@Payload(value = "<RestartRoleOperation xmlns=\"http://schemas.microsoft.com/windowsazure\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><OperationType>RestartRoleOperation</OperationType></RestartRoleOperation>")
|
||||
ListenableFuture<String> restartRole(
|
||||
@PathParam("serviceName") String serviceName,
|
||||
@PathParam("deploymentName") String deploymentName,
|
||||
@PathParam("roleName") String roleName);
|
||||
|
||||
@POST
|
||||
// Warning : the url in the documentation is WRONG ! @see
|
||||
// http://social.msdn.microsoft.com/Forums/pl-PL/WAVirtualMachinesforWindows/thread/7ba2367b-e450-49e0-89e4-46c240e9d213
|
||||
@Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}/roleInstances/{roleName}/Operations")
|
||||
@Consumes(MediaType.APPLICATION_ATOM_XML)
|
||||
@Produces(MediaType.APPLICATION_ATOM_XML)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@ResponseParser(ParseRequestIdHeader.class)
|
||||
@Payload(value = "<RestartRoleOperation xmlns=\"http://schemas.microsoft.com/windowsazure\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><OperationType>RestartRoleOperation</OperationType></RestartRoleOperation>")
|
||||
ListenableFuture<String> restartRole(
|
||||
@PathParam("serviceName") String serviceName,
|
||||
@PathParam("deploymentName") String deploymentName,
|
||||
@PathParam("roleName") String roleName);
|
||||
@POST
|
||||
@Path("/services/hostedservices/{serviceName}/deployments")
|
||||
@Produces(MediaType.APPLICATION_ATOM_XML)
|
||||
@Consumes(MediaType.APPLICATION_ATOM_XML)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@ResponseParser(ParseRequestIdHeader.class)
|
||||
ListenableFuture<String> createDeployment(
|
||||
@PathParam("serviceName") String serviceName,
|
||||
@BinderParam(BindDeploymentParamsToXmlPayload.class) DeploymentParams deploymentParams);
|
||||
|
||||
// This is a PaaS REST service !
|
||||
// @POST
|
||||
// @Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}/roles")
|
||||
// @Produces(MediaType.APPLICATION_ATOM_XML)
|
||||
// @Consumes(MediaType.TEXT_PLAIN)
|
||||
// @Fallback(NullOnNotFoundOr404.class)
|
||||
// ListenableFuture<Void> addRole(@PathParam("serviceName") String
|
||||
// serviceName,
|
||||
// @PathParam("deploymentName") String deploymentName,
|
||||
// @BinderParam(BindToXMLPayload.class) PersistentVMRole role);
|
||||
|
||||
// @Deprecated
|
||||
// @POST
|
||||
// @Path("/services/hostedservices/{serviceName}/deployments")
|
||||
// @Produces(MediaType.APPLICATION_ATOM_XML)
|
||||
// @Consumes(MediaType.TEXT_PLAIN)
|
||||
// @Fallback(NullOnNotFoundOr404.class)
|
||||
// @ResponseParser(ParseRequestIdHeader.class)
|
||||
// ListenableFuture<String> createVirtualMachineDeployment(
|
||||
// @PathParam("serviceName") String serviceName,
|
||||
// @BinderParam(BindToXMLPayload.class) Deployment deployment);
|
||||
|
||||
@POST
|
||||
@Path("/services/hostedservices/{serviceName}/deployments")
|
||||
@Produces(MediaType.APPLICATION_ATOM_XML)
|
||||
@Consumes(MediaType.APPLICATION_ATOM_XML)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@ResponseParser(ParseRequestIdHeader.class)
|
||||
ListenableFuture<String> createDeployment(
|
||||
@PathParam("serviceName") String serviceName,
|
||||
@BinderParam(BindDeploymentParamsToXmlPayload.class) DeploymentParams deploymentParams);
|
||||
|
||||
@POST
|
||||
@Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}/roleInstances/{roleName}/Operations")
|
||||
@Consumes(MediaType.APPLICATION_ATOM_XML)
|
||||
@Produces(MediaType.APPLICATION_ATOM_XML)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@ResponseParser(ParseRequestIdHeader.class)
|
||||
@Payload(value = "<CaptureRoleOperation xmlns=\"http://schemas.microsoft.com/windowsazure\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><OperationType>CaptureRoleOperation</OperationType><PostCaptureAction>Delete</PostCaptureAction><TargetImageLabel>{imageLabel}</TargetImageLabel><TargetImageName>{imageName}</TargetImageName></CaptureRoleOperation>")
|
||||
ListenableFuture<String> captureRole(
|
||||
@PathParam("serviceName") String serviceName,
|
||||
@PathParam("deploymentName") String deploymentName,
|
||||
@PathParam("roleName") String roleName,
|
||||
@PayloadParam("imageName") String imageName,
|
||||
@PayloadParam("imageLabel") String imageLabel);
|
||||
|
||||
@POST
|
||||
@Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}/roleInstances/{roleName}/Operations")
|
||||
@Consumes(MediaType.APPLICATION_ATOM_XML)
|
||||
@Produces(MediaType.APPLICATION_ATOM_XML)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@ResponseParser(ParseRequestIdHeader.class)
|
||||
@Payload(value = "<ShutdownRoleOperation xmlns=\"http://schemas.microsoft.com/windowsazure\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><OperationType>ShutdownRoleOperation</OperationType></ShutdownRoleOperation>")
|
||||
ListenableFuture<String> shutdownRole(
|
||||
@PathParam("serviceName") String serviceName,
|
||||
@PathParam("deploymentName") String deploymentName,
|
||||
@PathParam("roleName") String roleName);
|
||||
|
||||
@POST
|
||||
@Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}/roleInstances/{roleName}/Operations")
|
||||
@Consumes(MediaType.APPLICATION_ATOM_XML)
|
||||
@Produces(MediaType.APPLICATION_ATOM_XML)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@ResponseParser(ParseRequestIdHeader.class)
|
||||
@Payload(value = "<StartRoleOperation xmlns=\"http://schemas.microsoft.com/windowsazure\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><OperationType>StartRoleOperation</OperationType></StartRoleOperation>")
|
||||
ListenableFuture<String> startRole(
|
||||
@PathParam("serviceName") String serviceName,
|
||||
@PathParam("deploymentName") String deploymentName,
|
||||
@PathParam("roleName") String roleName);
|
||||
@POST
|
||||
@Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}/roleInstances/{roleName}/Operations")
|
||||
@Consumes(MediaType.APPLICATION_ATOM_XML)
|
||||
@Produces(MediaType.APPLICATION_ATOM_XML)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@ResponseParser(ParseRequestIdHeader.class)
|
||||
@Payload(value = "<CaptureRoleOperation xmlns=\"http://schemas.microsoft.com/windowsazure\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><OperationType>CaptureRoleOperation</OperationType><PostCaptureAction>Delete</PostCaptureAction><TargetImageLabel>{imageLabel}</TargetImageLabel><TargetImageName>{imageName}</TargetImageName></CaptureRoleOperation>")
|
||||
ListenableFuture<String> captureRole(
|
||||
@PathParam("serviceName") String serviceName,
|
||||
@PathParam("deploymentName") String deploymentName,
|
||||
@PathParam("roleName") String roleName,
|
||||
@PayloadParam("imageName") String imageName,
|
||||
@PayloadParam("imageLabel") String imageLabel);
|
||||
|
||||
@POST
|
||||
@Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}/roleInstances/{roleName}/Operations")
|
||||
@Consumes(MediaType.APPLICATION_ATOM_XML)
|
||||
@Produces(MediaType.APPLICATION_ATOM_XML)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@ResponseParser(ParseRequestIdHeader.class)
|
||||
@Payload(value = "<ShutdownRoleOperation xmlns=\"http://schemas.microsoft.com/windowsazure\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><OperationType>ShutdownRoleOperation</OperationType></ShutdownRoleOperation>")
|
||||
ListenableFuture<String> shutdownRole(
|
||||
@PathParam("serviceName") String serviceName,
|
||||
@PathParam("deploymentName") String deploymentName,
|
||||
@PathParam("roleName") String roleName);
|
||||
|
||||
@POST
|
||||
@Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}/roleInstances/{roleName}/Operations")
|
||||
@Consumes(MediaType.APPLICATION_ATOM_XML)
|
||||
@Produces(MediaType.APPLICATION_ATOM_XML)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@ResponseParser(ParseRequestIdHeader.class)
|
||||
@Payload(value = "<StartRoleOperation xmlns=\"http://schemas.microsoft.com/windowsazure\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><OperationType>StartRoleOperation</OperationType></StartRoleOperation>")
|
||||
ListenableFuture<String> startRole(
|
||||
@PathParam("serviceName") String serviceName,
|
||||
@PathParam("deploymentName") String deploymentName,
|
||||
@PathParam("roleName") String roleName);
|
||||
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ import java.util.Properties;
|
|||
|
||||
import org.jclouds.ContextBuilder;
|
||||
import org.jclouds.compute.ComputeService;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.domain.LoginCredentials;
|
||||
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
|
||||
import org.jclouds.nodepool.Backend;
|
||||
|
@ -80,16 +79,9 @@ public class BindBackendComputeServiceTest {
|
|||
}
|
||||
|
||||
private static class Factory implements SshClient.Factory {
|
||||
|
||||
@Override
|
||||
public SshClient create(HostAndPort socket, LoginCredentials credentials) {
|
||||
return createNiceMock(SshClient.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SshClient create(HostAndPort socket, Credentials credentials) {
|
||||
return createNiceMock(SshClient.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -204,12 +204,4 @@ public class Reference {
|
|||
return Objects.toStringHelper("").add("href", href).add("name", name).add("type", type);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VCloudDirectorApi#resolveEntity
|
||||
*/
|
||||
@Deprecated
|
||||
public Reference toAdminReference(String endpoint) {
|
||||
return toBuilder().type(null).href(URI.create(getHref().toASCIIString().replace(endpoint, endpoint + "/admin")))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -567,16 +567,6 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest<
|
|||
return vAppTemplate;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public URI toAdminUri(Reference ref) {
|
||||
return toAdminUri(ref.getHref());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public URI toAdminUri(URI uri) {
|
||||
return Reference.builder().href(uri).build().toAdminReference(endpoint).getHref();
|
||||
}
|
||||
|
||||
protected void assertTaskSucceeds(Task task) {
|
||||
assertTrue(retryTaskSuccess.apply(task), String.format(TASK_COMPLETE_TIMELY, task));
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.vcloud.director.v1_5.internal;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
|
@ -97,90 +96,6 @@ public abstract class BaseVCloudDirectorExpectTest<T> extends BaseRestApiExpectT
|
|||
.build())
|
||||
.payload(payloadFromResourceWithContentType("/session.xml", VCloudDirectorMediaType.SESSION + ";version=1.5"))
|
||||
.build();
|
||||
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequest(String method, String path) {
|
||||
return getStandardRequest(method, path, VCloudDirectorMediaType.ANY);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequest(String method, URI uri) {
|
||||
return getStandardRequest(method, uri, VCloudDirectorMediaType.ANY);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequest(String method, String path, String mediaType) {
|
||||
return getStandardRequest(method, URI.create(endpoint + path), VCloudDirectorMediaType.ANY);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardPayloadRequest(String method, String command, String relativeFilePath,
|
||||
String postMediaType) {
|
||||
return getStandardPayloadRequest(method, URI.create(endpoint + command), relativeFilePath, postMediaType);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardPayloadRequest(String method, URI uri, String relativeFilePath,
|
||||
String postMediaType) {
|
||||
return getStandardRequestWithPayload(method, uri, VCloudDirectorMediaType.ANY, relativeFilePath, postMediaType);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequest(String method, URI uri, String mediaType) {
|
||||
return HttpRequest.builder()
|
||||
.method(method)
|
||||
.endpoint(uri)
|
||||
.headers(ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", mediaType)
|
||||
.put("x-vcloud-authorization", token)
|
||||
.put(HttpHeaders.COOKIE, "vcloud-token=" + token)
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequestWithPayload(String method, String path, String relativeFilePath, String mediaType) {
|
||||
return getStandardRequestWithPayload(method, path, VCloudDirectorMediaType.ANY, relativeFilePath, mediaType);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequestWithPayload(String method, URI uri, String relativeFilePath, String mediaType) {
|
||||
return getStandardRequestWithPayload(method, uri, VCloudDirectorMediaType.ANY, relativeFilePath, mediaType);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequestWithPayload(String method, String path, String acceptType, String relativeFilePath, String mediaType) {
|
||||
URI uri = URI.create(endpoint + path);
|
||||
return getStandardRequestWithPayload(method, uri, acceptType, relativeFilePath, mediaType);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequestWithPayload(String method, URI uri, String acceptType, String relativeFilePath, String mediaType) {
|
||||
return HttpRequest.builder()
|
||||
.method(method)
|
||||
.endpoint(uri)
|
||||
.headers(ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", acceptType)
|
||||
.put("x-vcloud-authorization", token)
|
||||
.put(HttpHeaders.COOKIE, "vcloud-token=" + token)
|
||||
.build())
|
||||
.payload(payloadFromResourceWithContentType(relativeFilePath, mediaType))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpResponse getStandardPayloadResponse(String relativeFilePath, String mediaType) {
|
||||
return getStandardPayloadResponse(200, relativeFilePath, mediaType);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpResponse getStandardPayloadResponse(int statusCode, String relativeFilePath, String mediaType) {
|
||||
return HttpResponse.builder()
|
||||
.statusCode(statusCode)
|
||||
.payload(payloadFromResourceWithContentType(relativeFilePath, mediaType + ";version=1.5"))
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implicitly adds x-vcloud-authorization header with token.
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.io.Closeable;
|
|||
|
||||
import org.jclouds.View;
|
||||
import org.jclouds.loadbalancer.internal.LoadBalancerServiceContextImpl;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.Utils;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
|
@ -46,15 +45,6 @@ public interface LoadBalancerServiceContext extends Closeable, View {
|
|||
* @see #getUtils
|
||||
*/
|
||||
Utils utils();
|
||||
|
||||
/**
|
||||
* will be removed in jclouds 1.6
|
||||
*
|
||||
* @see View#getInputType
|
||||
* @see View#unwrap
|
||||
*/
|
||||
@Deprecated
|
||||
<S, A> RestContext<S, A> getProviderSpecificContext();
|
||||
|
||||
@Override
|
||||
void close();
|
||||
|
|
|
@ -1,131 +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.loadbalancer;
|
||||
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.ContextBuilder;
|
||||
import org.jclouds.apis.Apis;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.providers.ProviderMetadata;
|
||||
import org.jclouds.providers.Providers;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* This class is deprecated in favor of {@link ContextBuilder}. Please view
|
||||
* sample usage below:
|
||||
*
|
||||
* <pre>
|
||||
* context = ContextBuilder.newBuilder("aws-elb")
|
||||
* .credentials(apikey, secret)
|
||||
* .buildView(LoadBalancerServiceContext.class);
|
||||
* </pre>
|
||||
*
|
||||
* @see ContextBuilder
|
||||
* @deprecated As of version 1.5, replaced by {@link ContextBuilder}
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Deprecated
|
||||
public class LoadBalancerServiceContextFactory {
|
||||
|
||||
/**
|
||||
* for porting old code to {@link ContextBuilder}
|
||||
*/
|
||||
public LoadBalancerServiceContextFactory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* for porting old code to {@link ContextBuilder}
|
||||
*/
|
||||
public LoadBalancerServiceContextFactory(Properties properties) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #createContext(String, String,String, Iterable, Properties)
|
||||
*/
|
||||
public LoadBalancerServiceContext createContext(String providerOrApi, String identity, String credential) {
|
||||
return createContext(providerOrApi, identity, credential, ImmutableSet.<Module> of(), new Properties());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #createContext(String, String, String, Iterable, Properties)
|
||||
*/
|
||||
public LoadBalancerServiceContext createContext(String providerOrApi, Properties overrides) {
|
||||
return createContext(providerOrApi, null, null, ImmutableSet.<Module> of(), overrides);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #createContext(String, String,String, Iterable, Properties)
|
||||
*/
|
||||
public LoadBalancerServiceContext createContext(String providerOrApi, Iterable<? extends Module> wiring,
|
||||
Properties overrides) {
|
||||
return createContext(providerOrApi, null, null, wiring, overrides);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #createContext(String, String,String, Iterable, Properties)
|
||||
*/
|
||||
public LoadBalancerServiceContext createContext(String providerOrApi, @Nullable String identity,
|
||||
@Nullable String credential, Properties overrides) {
|
||||
return createContext(providerOrApi, identity, credential, ImmutableSet.<Module> of(), overrides);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see createContext(String, String,String, Iterable, Properties)
|
||||
*/
|
||||
public LoadBalancerServiceContext createContext(String providerOrApi, @Nullable String identity,
|
||||
@Nullable String credential, Iterable<? extends Module> wiring) {
|
||||
return createContext(providerOrApi, identity, credential, wiring, new Properties());
|
||||
}
|
||||
|
||||
/**
|
||||
* for porting old code to {@link ContextBuilder}
|
||||
*
|
||||
* @param providerOrApi
|
||||
* @param identity
|
||||
* nullable, if credentials are present in the overrides
|
||||
* @param credential
|
||||
* nullable, if credentials are present in the overrides
|
||||
* @param wiring
|
||||
* Configuration you'd like to pass to the context. Ex.
|
||||
* ImmutableSet.<Module>of(new ExecutorServiceModule(myexecutor))
|
||||
* @param overrides
|
||||
* properties to override defaults with.
|
||||
* @return initialized context ready for use
|
||||
*/
|
||||
public LoadBalancerServiceContext createContext(String providerOrApi, @Nullable String identity,
|
||||
@Nullable String credential, Iterable<? extends Module> wiring, Properties overrides) {
|
||||
ContextBuilder builder = null;
|
||||
try {
|
||||
ProviderMetadata pm = Providers.withId(providerOrApi);
|
||||
builder = ContextBuilder.newBuilder(pm);
|
||||
} catch (NoSuchElementException e) {
|
||||
builder = ContextBuilder.newBuilder(Apis.withId(providerOrApi));
|
||||
}
|
||||
builder.modules(wiring);
|
||||
builder.overrides(overrides);
|
||||
if (identity != null)
|
||||
builder.credentials(identity, credential);
|
||||
return builder.build(LoadBalancerServiceContext.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -28,7 +28,6 @@ import org.jclouds.internal.BaseView;
|
|||
import org.jclouds.loadbalancer.LoadBalancerService;
|
||||
import org.jclouds.loadbalancer.LoadBalancerServiceContext;
|
||||
import org.jclouds.location.Provider;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.Utils;
|
||||
|
||||
import com.google.common.io.Closeables;
|
||||
|
@ -65,12 +64,6 @@ public class LoadBalancerServiceContextImpl extends BaseView implements LoadBala
|
|||
return utils;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <S, A> RestContext<S, A> getProviderSpecificContext() {
|
||||
return (RestContext<S, A>) delegate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
Closeables.closeQuietly(delegate());
|
||||
|
|
|
@ -1,159 +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.aws.ec2.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import org.jclouds.aws.ec2.util.TagFilters.ResourceType;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ComparisonChain;
|
||||
|
||||
/**
|
||||
* <h3>Important</h3>
|
||||
* This will be removed in jclouds version 1.6
|
||||
*
|
||||
* @see <a href= "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-TagSetItemType.html" />
|
||||
* @see org.jclouds.ec2.domain.Tag
|
||||
* @author grkvlt@apache.org
|
||||
*/
|
||||
@Deprecated
|
||||
public class Tag implements Comparable<Tag> {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String resourceId;
|
||||
private ResourceType resourceType;
|
||||
private String key;
|
||||
private String value;
|
||||
|
||||
public void clear() {
|
||||
this.resourceId = null;
|
||||
this.resourceType = null;
|
||||
this.key = null;
|
||||
this.value = null;
|
||||
}
|
||||
|
||||
public Builder resourceId(String resourceId) {
|
||||
this.resourceId = resourceId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder resourceType(ResourceType resourceType) {
|
||||
this.resourceType = resourceType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder key(String key) {
|
||||
this.key = key;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder value(String value) {
|
||||
this.value = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Tag build() {
|
||||
return new Tag(resourceId, resourceType, key, value);
|
||||
}
|
||||
}
|
||||
|
||||
private final String resourceId;
|
||||
private final ResourceType resourceType;
|
||||
private final String key;
|
||||
private final String value;
|
||||
|
||||
public Tag(String resourceId, ResourceType resourceType, String key, String value) {
|
||||
this.resourceId = checkNotNull(resourceId, "resourceId");
|
||||
this.resourceType = checkNotNull(resourceType, "resourceType");
|
||||
this.key = checkNotNull(key, "key");
|
||||
this.value = checkNotNull(value, "value");
|
||||
}
|
||||
|
||||
public String getResourceId() {
|
||||
return resourceId;
|
||||
}
|
||||
|
||||
public ResourceType getResourceType() {
|
||||
return resourceType;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Tag t) {
|
||||
return ComparisonChain.start()
|
||||
.compare(resourceId, t.resourceId)
|
||||
.compare(resourceType, t.resourceType)
|
||||
.compare(key, t.key)
|
||||
.compare(value, t.value)
|
||||
.result();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(resourceId, resourceType, key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Tag other = (Tag) obj;
|
||||
if (resourceId == null) {
|
||||
if (other.resourceId != null)
|
||||
return false;
|
||||
} else if (!resourceId.equals(other.resourceId))
|
||||
return false;
|
||||
if (resourceType == null) {
|
||||
if (other.resourceType != null)
|
||||
return false;
|
||||
} else if (!resourceType.equals(other.resourceType))
|
||||
return false;
|
||||
if (value == null) {
|
||||
if (other.value != null)
|
||||
return false;
|
||||
} else if (!value.equals(other.value))
|
||||
return false;
|
||||
if (key == null) {
|
||||
if (other.key != null)
|
||||
return false;
|
||||
} else if (!key.equals(other.key))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[resourceId=" + resourceId + ", resourceType=" + resourceType + ", key=" + key + ", value=" + value + "]";
|
||||
}
|
||||
}
|
|
@ -1,312 +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.aws.ec2.util;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.ec2.features.TagApi;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* <h3>Important</h3>
|
||||
* This will be removed in jclouds version 1.6
|
||||
*
|
||||
* @author grkvlt@apache.org
|
||||
*
|
||||
* @see TagApi
|
||||
*/
|
||||
@Deprecated
|
||||
public class TagFilters {
|
||||
public static enum FilterName {
|
||||
KEY, RESOURCE_ID, RESOURCE_TYPE, VALUE;
|
||||
|
||||
public String value() {
|
||||
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value();
|
||||
}
|
||||
|
||||
public static FilterName fromValue(String name) {
|
||||
try {
|
||||
return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(name, "name")));
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <h3>Important</h3> This will be removed in jclouds version 1.6
|
||||
*
|
||||
* @see TagApi
|
||||
*/
|
||||
@Deprecated
|
||||
public static enum ResourceType {
|
||||
CUSTOMER_GATEWAY, DHCP_OPTIONS, IMAGE, INSTANCE, INTERNET_GATEWAY, NETWORK_ACL, RESERVED_INSTANCES, ROUTE_TABLE, SECURITY_GROUP, SNAPSHOT, SPOT_INSTANCES_REQUEST, SUBNET, VOLUME, VPC, VPN_CONNECTION, VPN_GATEWAY;
|
||||
|
||||
public String value() {
|
||||
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value();
|
||||
}
|
||||
|
||||
public static ResourceType fromValue(String name) {
|
||||
try {
|
||||
return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(name, "name")));
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected final Map<FilterName, Iterable<?>> map;
|
||||
|
||||
protected TagFilters() {
|
||||
map = Maps.<FilterName, Iterable<?>> newLinkedHashMap();
|
||||
}
|
||||
|
||||
public static TagFilters filters() {
|
||||
return new TagFilters();
|
||||
}
|
||||
|
||||
public Map<FilterName, Iterable<?>> build() {
|
||||
return ImmutableMap.copyOf(map);
|
||||
}
|
||||
|
||||
public TagFilters resourceId(String resourceId) {
|
||||
put(FilterName.RESOURCE_ID, resourceId);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TagFilters key(String key) {
|
||||
put(FilterName.KEY, key);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TagFilters keys(String... keys) {
|
||||
put(FilterName.KEY, ImmutableSet.<String> copyOf(keys));
|
||||
return this;
|
||||
}
|
||||
|
||||
public TagFilters keys(Iterable<String> keys) {
|
||||
putAll(FilterName.KEY, ImmutableSet.<String> copyOf(keys));
|
||||
return this;
|
||||
}
|
||||
|
||||
public TagFilters value(String value) {
|
||||
put(FilterName.VALUE, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TagFilters values(String... values) {
|
||||
putAll(FilterName.VALUE, ImmutableSet.<String> copyOf(values));
|
||||
return this;
|
||||
}
|
||||
|
||||
public TagFilters values(Iterable<String> values) {
|
||||
putAll(FilterName.VALUE, ImmutableSet.<String> copyOf(values));
|
||||
return this;
|
||||
}
|
||||
|
||||
public TagFilters keyContains(String key) {
|
||||
return key(String.format("*%s*", key));
|
||||
}
|
||||
|
||||
public TagFilters valueContains(String value) {
|
||||
return value(String.format("*%s*", value));
|
||||
}
|
||||
|
||||
public TagFilters resourceIdContains(String value) {
|
||||
return resourceId(String.format("*%s*", value));
|
||||
}
|
||||
|
||||
public TagFilters keyStartsWith(String key) {
|
||||
return key(String.format("%s*", key));
|
||||
}
|
||||
|
||||
public TagFilters valueStartsWith(String value) {
|
||||
return value(String.format("%s*", value));
|
||||
}
|
||||
|
||||
public TagFilters resourceIdStartsWith(String value) {
|
||||
return resourceId(String.format("%s*", value));
|
||||
}
|
||||
|
||||
public TagFilters keyEndsWith(String key) {
|
||||
return key(String.format("*%s", key));
|
||||
}
|
||||
|
||||
public TagFilters valueEndsWith(String value) {
|
||||
return value(String.format("*%s", value));
|
||||
}
|
||||
|
||||
public TagFilters resourceIdEndsWith(String value) {
|
||||
return resourceId(String.format("*%s", value));
|
||||
}
|
||||
|
||||
public TagFilters keyValuePair(String key, String value) {
|
||||
return key(key).value(value);
|
||||
}
|
||||
|
||||
public TagFilters keyValueSet(String key, Iterable<String> values) {
|
||||
return key(key).values(values);
|
||||
}
|
||||
|
||||
public TagFilters keyValueSet(String key, String... values) {
|
||||
return key(key).values(values);
|
||||
}
|
||||
|
||||
public TagFilters anyKey() {
|
||||
putAll(FilterName.KEY, ImmutableSet.<String> of());
|
||||
return this;
|
||||
}
|
||||
|
||||
public TagFilters anyValue() {
|
||||
putAll(FilterName.VALUE, ImmutableSet.<String> of());
|
||||
return this;
|
||||
}
|
||||
|
||||
public TagFilters anyResourceId() {
|
||||
putAll(FilterName.RESOURCE_TYPE, ImmutableSet.<String> of());
|
||||
return this;
|
||||
}
|
||||
|
||||
public TagFilters anyResourceType() {
|
||||
putAll(FilterName.RESOURCE_TYPE, ImmutableSet.<ResourceType> of());
|
||||
return this;
|
||||
}
|
||||
|
||||
public TagFilters resourceType(ResourceType resourceType) {
|
||||
put(FilterName.RESOURCE_TYPE, resourceType);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TagFilters customerGateway() {
|
||||
put(FilterName.RESOURCE_TYPE, ResourceType.CUSTOMER_GATEWAY);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TagFilters dhcpOptions() {
|
||||
put(FilterName.RESOURCE_TYPE, ResourceType.DHCP_OPTIONS);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TagFilters image() {
|
||||
put(FilterName.RESOURCE_TYPE, ResourceType.IMAGE);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TagFilters instance() {
|
||||
put(FilterName.RESOURCE_TYPE, ResourceType.INSTANCE);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TagFilters internetGateway() {
|
||||
put(FilterName.RESOURCE_TYPE, ResourceType.INTERNET_GATEWAY);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TagFilters networkAcl() {
|
||||
put(FilterName.RESOURCE_TYPE, ResourceType.NETWORK_ACL);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TagFilters reservedInstance() {
|
||||
put(FilterName.RESOURCE_TYPE, ResourceType.RESERVED_INSTANCES);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TagFilters routeTable() {
|
||||
put(FilterName.RESOURCE_TYPE, ResourceType.ROUTE_TABLE);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TagFilters securityGroup() {
|
||||
put(FilterName.RESOURCE_TYPE, ResourceType.SECURITY_GROUP);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TagFilters snapshot() {
|
||||
put(FilterName.RESOURCE_TYPE, ResourceType.SNAPSHOT);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TagFilters instancesRequest() {
|
||||
put(FilterName.RESOURCE_TYPE, ResourceType.SPOT_INSTANCES_REQUEST);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TagFilters subnet() {
|
||||
put(FilterName.RESOURCE_TYPE, ResourceType.SUBNET);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TagFilters volume() {
|
||||
put(FilterName.RESOURCE_TYPE, ResourceType.VOLUME);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TagFilters vpc() {
|
||||
put(FilterName.RESOURCE_TYPE, ResourceType.VPC);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TagFilters vpnConnection() {
|
||||
put(FilterName.RESOURCE_TYPE, ResourceType.VPN_CONNECTION);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TagFilters vpnGateway() {
|
||||
put(FilterName.RESOURCE_TYPE, ResourceType.VPN_GATEWAY);
|
||||
return this;
|
||||
}
|
||||
|
||||
private void put(FilterName key, Object value) {
|
||||
putAll(key, Sets.newHashSet(value));
|
||||
}
|
||||
|
||||
private void putAll(FilterName key, Iterable<?> values) {
|
||||
if (values == null || Iterables.isEmpty(values)) {
|
||||
// If we add an empty or null set of values, replace the value in the
|
||||
// map entirely
|
||||
map.put(key, ImmutableSet.of());
|
||||
} else {
|
||||
// Add the values, to a new set if required
|
||||
if (!map.containsKey(key)) {
|
||||
map.put(key, Sets.newHashSet());
|
||||
}
|
||||
Iterable<?> entries = map.get(key);
|
||||
map.put(key, Iterables.concat(entries, values));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,105 +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.aws.ec2.binders;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.jclouds.aws.ec2.util.TagFilters;
|
||||
import org.jclouds.aws.ec2.util.TagFilters.FilterName;
|
||||
import org.jclouds.aws.ec2.util.TagFilters.ResourceType;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code BindTagFiltersToIndexedFormParams}
|
||||
*
|
||||
* @author grkvlt@apache.org
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class BindTagFiltersToIndexedFormParamsTest {
|
||||
Injector injector = Guice.createInjector();
|
||||
BindTagFiltersToIndexedFormParams binder = injector.getInstance(BindTagFiltersToIndexedFormParams.class);
|
||||
|
||||
public void testMultipleResourceTypes() {
|
||||
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
|
||||
request = binder.bindToRequest(request, ImmutableMap.<FilterName, Iterable<ResourceType>>builder().put(FilterName.RESOURCE_TYPE, ImmutableSet.<ResourceType>of(ResourceType.VPN_GATEWAY, ResourceType.INTERNET_GATEWAY)).build());
|
||||
assertEquals(request.getPayload().getRawContent(), "Filter.1.Name=resource-type&Filter.1.Value.1=vpn-gateway&Filter.1.Value.2=internet-gateway");
|
||||
}
|
||||
|
||||
public void testMultipleKeys() {
|
||||
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
|
||||
request = binder.bindToRequest(request, ImmutableMap.<FilterName, Iterable<String>>builder().put(FilterName.KEY, ImmutableSet.<String>of("one", "two")).build());
|
||||
assertEquals(request.getPayload().getRawContent(), "Filter.1.Name=key&Filter.1.Value.1=one&Filter.1.Value.2=two");
|
||||
}
|
||||
|
||||
public void testkeyWithValue() {
|
||||
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
|
||||
request = binder.bindToRequest(request, ImmutableMap.<FilterName, Iterable<String>>builder().put(FilterName.KEY, ImmutableSet.<String>of("one")).put(FilterName.VALUE, ImmutableSet.<String>of("alpha")).build());
|
||||
assertEquals(request.getPayload().getRawContent(), "Filter.1.Name=key&Filter.1.Value.1=one&Filter.2.Name=value&Filter.2.Value.1=alpha");
|
||||
}
|
||||
|
||||
public void testAnyKey() {
|
||||
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
|
||||
request = binder.bindToRequest(request, ImmutableMap.<FilterName, Iterable<String>>builder().put(FilterName.KEY, ImmutableSet.<String>of()).build());
|
||||
assertEquals(request.getPayload().getRawContent(), "Filter.1.Name=key");
|
||||
}
|
||||
|
||||
public void testMultipleResourceTypesBuilder() {
|
||||
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
|
||||
request = binder.bindToRequest(request, TagFilters.filters().vpnGateway().internetGateway().build());
|
||||
assertEquals(request.getPayload().getRawContent(), "Filter.1.Name=resource-type&Filter.1.Value.1=vpn-gateway&Filter.1.Value.2=internet-gateway");
|
||||
}
|
||||
|
||||
public void testMultipleKeysBuilder() {
|
||||
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
|
||||
request = binder.bindToRequest(request, TagFilters.filters().key("one").key("two").build());
|
||||
assertEquals(request.getPayload().getRawContent(), "Filter.1.Name=key&Filter.1.Value.1=one&Filter.1.Value.2=two");
|
||||
}
|
||||
|
||||
public void testKeyWithValueBuilder() {
|
||||
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
|
||||
request = binder.bindToRequest(request, TagFilters.filters().keyValuePair("one", "alpha").build());
|
||||
assertEquals(request.getPayload().getRawContent(), "Filter.1.Name=key&Filter.1.Value.1=one&Filter.2.Name=value&Filter.2.Value.1=alpha");
|
||||
}
|
||||
|
||||
public void testAnyKeyBuilder() {
|
||||
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
|
||||
request = binder.bindToRequest(request, TagFilters.filters().anyKey().build());
|
||||
assertEquals(request.getPayload().getRawContent(), "Filter.1.Name=key");
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
public void testMustBeArray() {
|
||||
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();;
|
||||
binder.bindToRequest(request, new File("foo"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = NullPointerException.class)
|
||||
public void testNullIsBad() {
|
||||
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://momma").build();
|
||||
binder.bindToRequest(request, null);
|
||||
}
|
||||
}
|
|
@ -186,7 +186,7 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest {
|
|||
SecurityGroup secgroup = getOnlyElement(securityGroupClient.describeSecurityGroupsInRegion(instance
|
||||
.getRegion(), "jclouds#" + group));
|
||||
|
||||
assert secgroup.getIpPermissions().size() == 0 : secgroup;
|
||||
assert secgroup.size() == 0 : secgroup;
|
||||
|
||||
// try to run a script with the original keyPair
|
||||
runScriptWithCreds(group, first.getOperatingSystem(), LoginCredentials.builder().user(
|
||||
|
|
|
@ -1,182 +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.scriptbuilder;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.scriptbuilder.domain.Statements.createRunScript;
|
||||
import static org.jclouds.scriptbuilder.domain.Statements.interpret;
|
||||
import static org.jclouds.scriptbuilder.domain.Statements.kill;
|
||||
import static org.jclouds.scriptbuilder.domain.Statements.newStatementList;
|
||||
import static org.jclouds.scriptbuilder.domain.Statements.switchArg;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.scriptbuilder.domain.CreateRunScript;
|
||||
import org.jclouds.scriptbuilder.domain.Statement;
|
||||
import org.jclouds.scriptbuilder.domain.StatementList;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
* will be removed in jclouds 1.6
|
||||
*
|
||||
* Creates an init script file
|
||||
*
|
||||
* @see InitScript
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Deprecated
|
||||
public class InitBuilder extends ScriptBuilder {
|
||||
|
||||
private final String instanceName;
|
||||
private final String instanceHome;
|
||||
private final String logDir;
|
||||
private final StatementList initStatement;
|
||||
private final CreateRunScript createRunScript;
|
||||
|
||||
public InitBuilder(String instanceName, Statement initStatement, Statement runStatement) {
|
||||
this(instanceName, ImmutableSet.of(initStatement), ImmutableSet.of(runStatement));
|
||||
}
|
||||
|
||||
public InitBuilder(String instanceName, Iterable<Statement> initStatements, Iterable<Statement> statements) {
|
||||
this(instanceName, String.format("{tmp}{fs}{varl}INSTANCE_NAME{varr}", instanceName), String.format(
|
||||
"{tmp}{fs}{varl}INSTANCE_NAME{varr}", instanceName), ImmutableMap.<String, String> of(), initStatements,
|
||||
statements);
|
||||
}
|
||||
|
||||
public InitBuilder(String instanceName, String instanceHome, String logDir, Map<String, String> variables,
|
||||
Iterable<Statement> statements) {
|
||||
this(instanceName, instanceHome, logDir, variables, ImmutableSet.<Statement> of(), statements);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param variables keys are the variables to export in UPPER_UNDERSCORE case format
|
||||
*/
|
||||
public InitBuilder(String instanceName, String instanceHome, String logDir, Map<String, String> variables,
|
||||
Iterable<Statement> initStatements, Iterable<Statement> statements) {
|
||||
Map<String, String> defaultVariables = ImmutableMap.of("INSTANCE_NAME", instanceName, "INSTANCE_HOME",
|
||||
instanceHome, "LOG_DIR", logDir);
|
||||
this.initStatement = new StatementList(initStatements);
|
||||
this.createRunScript = createRunScript(instanceName,// TODO: convert
|
||||
// so
|
||||
// that
|
||||
// createRunScript
|
||||
// can take from a
|
||||
// variable
|
||||
Iterables.concat(variables.keySet(), defaultVariables.keySet()), "{varl}INSTANCE_HOME{varr}", statements);
|
||||
this.instanceName = checkNotNull(instanceName, "INSTANCE_NAME");
|
||||
this.instanceHome = checkNotNull(instanceHome, "INSTANCE_HOME");
|
||||
this.logDir = checkNotNull(logDir, "LOG_DIR");
|
||||
|
||||
addEnvironmentVariableScope("default", defaultVariables)
|
||||
.addEnvironmentVariableScope(instanceName, variables)
|
||||
.addStatement(
|
||||
switchArg(
|
||||
1,
|
||||
new ImmutableMap.Builder<String, Statement>()
|
||||
.put("init",
|
||||
newStatementList(call("default"), call(instanceName), initStatement,
|
||||
createRunScript))
|
||||
.put("status",
|
||||
newStatementList(call("default"), findPid("{varl}INSTANCE_NAME{varr}"),
|
||||
interpret("echo {varl}FOUND_PID{varr}{lf}")))
|
||||
.put("stop",
|
||||
newStatementList(call("default"), findPid("{varl}INSTANCE_NAME{varr}"), kill()))
|
||||
.put("start",
|
||||
newStatementList(
|
||||
call("default"),
|
||||
forget("{varl}INSTANCE_NAME{varr}",
|
||||
"{varl}INSTANCE_HOME{varr}{fs}{varl}INSTANCE_NAME{varr}.{sh}",
|
||||
"{varl}LOG_DIR{varr}")))
|
||||
.put("tail",
|
||||
newStatementList(call("default"),
|
||||
interpret("tail {varl}LOG_DIR{varr}{fs}stdout.log{lf}")))
|
||||
.put("tailerr",
|
||||
newStatementList(call("default"),
|
||||
interpret("tail {varl}LOG_DIR{varr}{fs}stderr.log{lf}")))
|
||||
.put("run",
|
||||
newStatementList(call("default"),
|
||||
interpret("{varl}INSTANCE_HOME{varr}{fs}{varl}INSTANCE_NAME{varr}.{sh}{lf}")))
|
||||
.build()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((instanceHome == null) ? 0 : instanceHome.hashCode());
|
||||
result = prime * result + ((instanceName == null) ? 0 : instanceName.hashCode());
|
||||
result = prime * result + ((logDir == null) ? 0 : logDir.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
InitBuilder other = (InitBuilder) obj;
|
||||
if (instanceHome == null) {
|
||||
if (other.instanceHome != null)
|
||||
return false;
|
||||
} else if (!instanceHome.equals(other.instanceHome))
|
||||
return false;
|
||||
if (instanceName == null) {
|
||||
if (other.instanceName != null)
|
||||
return false;
|
||||
} else if (!instanceName.equals(other.instanceName))
|
||||
return false;
|
||||
if (logDir == null) {
|
||||
if (other.logDir != null)
|
||||
return false;
|
||||
} else if (!logDir.equals(other.logDir))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getInstanceName() {
|
||||
return instanceName;
|
||||
}
|
||||
|
||||
public String getInstanceHome() {
|
||||
return instanceHome;
|
||||
}
|
||||
|
||||
public String getLogDir() {
|
||||
return logDir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[instanceName=" + instanceName + ", instanceHome=" + instanceHome + ", logDir=" + logDir + "]";
|
||||
}
|
||||
|
||||
public StatementList getInitStatement() {
|
||||
return initStatement;
|
||||
}
|
||||
|
||||
public CreateRunScript getCreateRunScript() {
|
||||
return createRunScript;
|
||||
}
|
||||
}
|
|
@ -31,23 +31,11 @@ import org.jclouds.scriptbuilder.domain.StatementList;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
public class InstallJDK {
|
||||
// TODO: this doesn't work
|
||||
public static Statement fromOracle() {
|
||||
throw new UnsupportedOperationException("Oracle JDK install doesn't currently work due to license agreement");
|
||||
}
|
||||
|
||||
public static Statement fromOpenJDK() {
|
||||
return new FromOpenJDK();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see fromOpenJDK
|
||||
*/
|
||||
@Deprecated
|
||||
public static Statement fromURL() {
|
||||
return fromOpenJDK();
|
||||
}
|
||||
|
||||
public static Statement fromURL(URI url) {
|
||||
return new FromURL(url);
|
||||
}
|
||||
|
|
|
@ -1,96 +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.scriptbuilder;
|
||||
|
||||
import static org.jclouds.scriptbuilder.domain.Statements.appendFile;
|
||||
import static org.jclouds.scriptbuilder.domain.Statements.exec;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
import org.jclouds.scriptbuilder.domain.OsFamily;
|
||||
import org.jclouds.scriptbuilder.domain.ShellToken;
|
||||
import org.jclouds.scriptbuilder.domain.Statement;
|
||||
import org.jclouds.scriptbuilder.domain.Statements;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.io.Resources;
|
||||
|
||||
/**
|
||||
* Tests possible uses of InitBuilder
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Deprecated
|
||||
public class InitBuilderTest {
|
||||
|
||||
InitBuilder testInitBuilder = new InitBuilder("mkebsboot", "/mnt/tmp", "/mnt/tmp", ImmutableMap.of("TMP_DIR",
|
||||
"/mnt/tmp"), ImmutableList.<Statement> of(
|
||||
appendFile("{tmp}{fs}{uid}{fs}scripttest{fs}temp.txt", ImmutableList.<String> of("hello world")),
|
||||
exec("find /")));
|
||||
|
||||
@Test(expectedExceptions = UnsupportedOperationException.class)
|
||||
public void testBuildSimpleWindows() throws MalformedURLException, IOException {
|
||||
testInitBuilder.render(OsFamily.WINDOWS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildSimpleUNIX() throws MalformedURLException, IOException {
|
||||
assertEquals(
|
||||
testInitBuilder.render(OsFamily.UNIX),
|
||||
Resources.toString(Resources.getResource("test_init." + ShellToken.SH.to(OsFamily.UNIX)), Charsets.UTF_8));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildEBS() throws MalformedURLException, IOException {
|
||||
assertEquals(
|
||||
new InitBuilder("mkebsboot",// name of the script
|
||||
"/tmp",// working directory
|
||||
"/tmp/logs",// location of stdout.log and stderr.log
|
||||
ImmutableMap.of("IMAGE_DIR", "/mnt/tmp", "EBS_DEVICE", "/dev/sdh", "EBS_MOUNT_POINT", "/mnt/ebs"),// variables
|
||||
// used
|
||||
// inside
|
||||
// of
|
||||
// the
|
||||
// script
|
||||
ImmutableList.<Statement> of(Statements
|
||||
.interpret(
|
||||
"echo creating a filesystem and mounting the ebs volume",// what
|
||||
// to
|
||||
// execute
|
||||
"{md} {varl}IMAGE_DIR{varr} {varl}EBS_MOUNT_POINT{varr}",
|
||||
"rm -rf {varl}IMAGE_DIR{varr}/*",
|
||||
"yes| mkfs -t ext3 {varl}EBS_DEVICE{varr} 2>&-",
|
||||
"mount {varl}EBS_DEVICE{varr} {varl}EBS_MOUNT_POINT{varr}",
|
||||
"echo making a local working copy of the boot disk",
|
||||
"rsync -ax --exclude /ubuntu/.bash_history --exclude /home/*/.bash_history --exclude /etc/ssh/ssh_host_* --exclude /etc/ssh/moduli --exclude /etc/udev/rules.d/*persistent-net.rules --exclude /var/lib/ec2/* --exclude=/mnt/* --exclude=/proc/* --exclude=/tmp/* --exclude=/dev/log / {varl}IMAGE_DIR{varr}",
|
||||
"echo preparing the local working copy",
|
||||
"touch {varl}IMAGE_DIR{varr}/etc/init.d/ec2-init-user-data",
|
||||
"echo copying the local working copy to the ebs mount", "{cd} {varl}IMAGE_DIR{varr}",
|
||||
"tar -cSf - * | tar xf - -C {varl}EBS_MOUNT_POINT{varr}", "echo size of ebs",
|
||||
"du -sk {varl}EBS_MOUNT_POINT{varr}", "echo size of source",
|
||||
"du -sk {varl}IMAGE_DIR{varr}", "rm -rf {varl}IMAGE_DIR{varr}/*",
|
||||
"umount {varl}EBS_MOUNT_POINT{varr}", "echo ----COMPLETE----"))).render(OsFamily.UNIX),
|
||||
Resources.toString(Resources.getResource("test_ebs." + ShellToken.SH.to(OsFamily.UNIX)), Charsets.UTF_8));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue