refactored and slimmed vcloud compute impl

This commit is contained in:
Adrian Cole 2011-12-22 02:18:51 -08:00
parent c6d1f2d56e
commit 535c035ae6
63 changed files with 770 additions and 1293 deletions

View File

@ -103,7 +103,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
boolean powerOn = true;
Boolean customizeOnInstantiate = null;
Set<? extends NetworkConfig> networkConfig = null;
Set<NetworkConfig> networkConfig = null;
NetworkConfigDecorator networknetworkConfigDecorator = new NetworkConfigDecorator(template,
defaultNetwork.getHref(), defaultFenceMode, defaultNetworkNameInTemplate);
@ -138,8 +138,8 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
}
@VisibleForTesting
Set<? extends Vm> ifCustomizationScriptIsSetGetVmsInTemplate(String customizationScript, final URI template) {
Set<? extends Vm> vms = Sets.newLinkedHashSet();
Set<Vm> ifCustomizationScriptIsSetGetVmsInTemplate(String customizationScript, final URI template) {
Set<Vm> vms = Sets.newLinkedHashSet();
if (customizationScript != null) {
VAppTemplate vAppTemplate = client.getVAppTemplateClient().getVAppTemplate(template);
checkArgument(vAppTemplate != null, "vAppTemplate %s not found!", template);
@ -202,7 +202,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
}
protected String generateXml(String name, @Nullable String description, boolean deploy, boolean powerOn,
URI template, Iterable<? extends NetworkConfig> networkConfig, @Nullable Boolean customizeOnInstantiate)
URI template, Iterable<NetworkConfig> networkConfig, @Nullable Boolean customizeOnInstantiate)
throws ParserConfigurationException, FactoryConfigurationError, TransformerException {
XMLBuilder rootBuilder = buildRoot(name).a("deploy", deploy + "").a("powerOn", powerOn + "");
if (description != null)
@ -228,7 +228,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
}
protected void addNetworkConfig(XMLBuilder instantiationParamsBuilder,
Iterable<? extends NetworkConfig> networkConfig) {
Iterable<NetworkConfig> networkConfig) {
XMLBuilder networkConfigBuilder = instantiationParamsBuilder.e("NetworkConfigSection");
networkConfigBuilder.e("ovf:Info").t("Configuration parameters for logical networks");
for (NetworkConfig n : networkConfig) {

View File

@ -0,0 +1,56 @@
/**
*
* Copyright (C) 2009 Global Cloud Specialists, Inc. <info@globalcloudspecialists.com>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*/
package org.jclouds.vcloud.compute.config;
import static com.google.common.base.Preconditions.checkNotNull;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.domain.Location;
import org.jclouds.domain.LocationScope;
import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.endpoints.VDC;
import com.google.common.base.Predicate;
@Singleton
public final class IsDefaultVDC implements Predicate<Location> {
private final ReferenceType defaultVDC;
@Inject
IsDefaultVDC(@VDC ReferenceType defaultVDC) {
this.defaultVDC = checkNotNull(defaultVDC, "defaultVDC");
}
@Override
public boolean apply(Location input) {
return input.getScope() == LocationScope.ZONE && input.getId().equals(defaultVDC.getHref().toASCIIString());
}
@Override
public String toString() {
return "isDefaultVDC()";
}
}

View File

@ -1,80 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.compute.config;
import org.jclouds.compute.config.BindComputeStrategiesByClass;
import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName;
import org.jclouds.compute.strategy.CreateNodesInGroupThenAddToSet;
import org.jclouds.compute.strategy.DestroyNodeStrategy;
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
import org.jclouds.compute.strategy.ListNodesStrategy;
import org.jclouds.compute.strategy.RebootNodeStrategy;
import org.jclouds.compute.strategy.ResumeNodeStrategy;
import org.jclouds.compute.strategy.SuspendNodeStrategy;
import org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet;
import org.jclouds.vcloud.compute.strategy.InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn;
import org.jclouds.vcloud.compute.strategy.VCloudDestroyNodeStrategy;
import org.jclouds.vcloud.compute.strategy.VCloudGetNodeMetadataStrategy;
import org.jclouds.vcloud.compute.strategy.VCloudLifeCycleStrategy;
import org.jclouds.vcloud.compute.strategy.VCloudListNodesStrategy;
/**
* @author Adrian Cole
*/
public class VCloudBindComputeStrategiesByClass extends BindComputeStrategiesByClass {
@Override
protected Class<? extends CreateNodesInGroupThenAddToSet> defineRunNodesAndAddToSetStrategy() {
return CreateNodesWithGroupEncodedIntoNameThenAddToSet.class;
}
@Override
protected Class<? extends CreateNodeWithGroupEncodedIntoName> defineAddNodeWithTagStrategy() {
return InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.class;
}
@Override
protected Class<? extends DestroyNodeStrategy> defineDestroyNodeStrategy() {
return VCloudDestroyNodeStrategy.class;
}
@Override
protected Class<? extends GetNodeMetadataStrategy> defineGetNodeMetadataStrategy() {
return VCloudGetNodeMetadataStrategy.class;
}
@Override
protected Class<? extends ListNodesStrategy> defineListNodesStrategy() {
return VCloudListNodesStrategy.class;
}
@Override
protected Class<? extends RebootNodeStrategy> defineRebootNodeStrategy() {
return VCloudLifeCycleStrategy.class;
}
@Override
protected Class<? extends ResumeNodeStrategy> defineStartNodeStrategy() {
return VCloudLifeCycleStrategy.class;
}
@Override
protected Class<? extends SuspendNodeStrategy> defineStopNodeStrategy() {
return VCloudLifeCycleStrategy.class;
}
}

View File

@ -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.vcloud.compute.config;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Iterables.find;
import java.util.Set;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.collect.Memoized;
import org.jclouds.compute.config.BindComputeSuppliersByClass;
import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.Image;
import org.jclouds.domain.Location;
import org.jclouds.domain.LocationScope;
import org.jclouds.vcloud.compute.suppliers.OrgAndVDCToLocationSupplier;
import org.jclouds.vcloud.compute.suppliers.VCloudHardwareSupplier;
import org.jclouds.vcloud.compute.suppliers.VCloudImageSupplier;
import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.endpoints.VDC;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
/**
* @author Adrian Cole
*/
public class VCloudBindComputeSuppliersByClass extends BindComputeSuppliersByClass {
@Override
protected Class<? extends Supplier<Set<? extends Image>>> defineImageSupplier() {
return VCloudImageSupplier.class;
}
@Override
protected Class<? extends Supplier<Set<? extends Location>>> defineLocationSupplier() {
return OrgAndVDCToLocationSupplier.class;
}
@Override
protected Class<? extends Supplier<Location>> defineDefaultLocationSupplier() {
return DefaultVDC.class;
}
@Singleton
public static class DefaultVDC implements Supplier<Location> {
@Singleton
public static final class IsDefaultVDC implements Predicate<Location> {
private final ReferenceType defaultVDC;
@Inject
IsDefaultVDC(@VDC ReferenceType defaultVDC) {
this.defaultVDC = checkNotNull(defaultVDC, "defaultVDC");
}
@Override
public boolean apply(Location input) {
return input.getScope() == LocationScope.ZONE && input.getId().equals(defaultVDC.getHref().toASCIIString());
}
@Override
public String toString() {
return "isDefaultVDC()";
}
}
private final Supplier<Set<? extends Location>> locationsSupplier;
private final IsDefaultVDC isDefaultVDC;
@Inject
DefaultVDC(@Memoized Supplier<Set<? extends Location>> locationsSupplier, IsDefaultVDC isDefaultVDC) {
this.locationsSupplier = checkNotNull(locationsSupplier, "locationsSupplierSupplier");
this.isDefaultVDC = checkNotNull(isDefaultVDC, "isDefaultVDC");
}
@Override
public Location get() {
return find(locationsSupplier.get(), isDefaultVDC);
}
}
@Override
protected Class<? extends Supplier<Set<? extends Hardware>>> defineHardwareSupplier() {
return VCloudHardwareSupplier.class;
}
}

View File

@ -18,46 +18,17 @@
*/
package org.jclouds.vcloud.compute.config;
import static org.jclouds.compute.domain.OsFamily.UBUNTU;
import java.util.Map;
import javax.inject.Singleton;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.config.BaseComputeServiceContextModule;
import org.jclouds.compute.config.BindComputeStrategiesByClass;
import org.jclouds.compute.config.BindComputeSuppliersByClass;
import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.NodeState;
import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
import org.jclouds.compute.domain.TemplateBuilder;
import org.jclouds.compute.internal.ComputeServiceContextImpl;
import org.jclouds.compute.options.TemplateOptions;
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.RestContextImpl;
import org.jclouds.domain.Location;
import org.jclouds.vcloud.VCloudAsyncClient;
import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.compute.functions.HardwareForVApp;
import org.jclouds.vcloud.compute.functions.HardwareInOrg;
import org.jclouds.vcloud.compute.functions.ImagesInOrg;
import org.jclouds.vcloud.compute.functions.VAppToNodeMetadata;
import org.jclouds.vcloud.compute.internal.VCloudTemplateBuilderImpl;
import org.jclouds.vcloud.compute.options.VCloudTemplateOptions;
import org.jclouds.vcloud.compute.strategy.GetLoginCredentialsFromGuestConfiguration;
import org.jclouds.vcloud.domain.Org;
import org.jclouds.vcloud.domain.Status;
import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.VAppTemplate;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableMap;
import com.google.inject.Injector;
import com.google.inject.Provides;
import com.google.inject.Scopes;
import com.google.inject.TypeLiteral;
/**
* Configures the {@link VCloudComputeServiceContext}; requires {@link VCloudComputeClientImpl}
@ -65,61 +36,23 @@ import com.google.inject.TypeLiteral;
*
* @author Adrian Cole
*/
public class VCloudComputeServiceContextModule extends BaseComputeServiceContextModule {
@VisibleForTesting
public static final Map<Status, NodeState> VAPPSTATUS_TO_NODESTATE = ImmutableMap.<Status, NodeState> builder()
.put(Status.OFF, NodeState.SUSPENDED).put(Status.ON, NodeState.RUNNING)
.put(Status.RESOLVED, NodeState.PENDING).put(Status.ERROR, NodeState.ERROR)
.put(Status.UNRECOGNIZED, NodeState.UNRECOGNIZED).put(Status.DEPLOYED, NodeState.PENDING)
.put(Status.INCONSISTENT, NodeState.PENDING).put(Status.UNKNOWN, NodeState.UNRECOGNIZED)
.put(Status.MIXED, NodeState.PENDING).put(Status.WAITING_FOR_INPUT, NodeState.PENDING)
.put(Status.SUSPENDED, NodeState.SUSPENDED).put(Status.UNRESOLVED, NodeState.PENDING).build();
@Singleton
@Provides
protected Map<Status, NodeState> provideVAppStatusToNodeState() {
return VAPPSTATUS_TO_NODESTATE;
public class VCloudComputeServiceContextModule
extends
ComputeServiceAdapterContextModule<VCloudClient, VCloudAsyncClient, VApp, VAppTemplate, VAppTemplate, Location> {
public VCloudComputeServiceContextModule() {
super(VCloudClient.class, VCloudAsyncClient.class);
}
@Override
protected void configure() {
super.configure();
install(defineComputeStrategyModule());
install(defineComputeSupplierModule());
bind(new TypeLiteral<Function<VApp, NodeMetadata>>() {
}).to(VAppToNodeMetadata.class);
bind(TemplateOptions.class).to(VCloudTemplateOptions.class);
bind(TemplateBuilder.class).to(VCloudTemplateBuilderImpl.class);
bind(new TypeLiteral<Function<VApp, Hardware>>() {
}).to(new TypeLiteral<HardwareForVApp>() {
});
bind(new TypeLiteral<ComputeServiceContext>() {
}).to(new TypeLiteral<ComputeServiceContextImpl<VCloudClient, VCloudClient>>() {
}).in(Scopes.SINGLETON);
bind(new TypeLiteral<RestContext<VCloudClient, VCloudClient>>() {
}).to(new TypeLiteral<RestContextImpl<VCloudClient, VCloudClient>>() {
}).in(Scopes.SINGLETON);
bind(new TypeLiteral<Function<Org, Iterable<? extends Image>>>() {
}).to(new TypeLiteral<ImagesInOrg>() {
});
bind(new TypeLiteral<Function<Org, Iterable<? extends Hardware>>>() {
}).to(new TypeLiteral<HardwareInOrg>() {
});
bind(PopulateDefaultLoginCredentialsForImageStrategy.class).to(GetLoginCredentialsFromGuestConfiguration.class);
install(new VCloudComputeServiceDependenciesModule());
}
//CIM ostype does not include version info
// CIM ostype does not include version info
@Override
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
return template.osFamily(UBUNTU).os64Bit(true);
}
public BindComputeStrategiesByClass defineComputeStrategyModule() {
return new VCloudBindComputeStrategiesByClass();
}
public BindComputeSuppliersByClass defineComputeSupplierModule() {
return new VCloudBindComputeSuppliersByClass();
}
}

View File

@ -0,0 +1,131 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.compute.config;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Iterables.find;
import java.util.Map;
import java.util.Set;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.collect.Memoized;
import org.jclouds.compute.ComputeServiceAdapter;
import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.NodeState;
import org.jclouds.compute.domain.TemplateBuilder;
import org.jclouds.compute.options.TemplateOptions;
import org.jclouds.domain.Location;
import org.jclouds.functions.IdentityFunction;
import org.jclouds.vcloud.compute.functions.HardwareForVApp;
import org.jclouds.vcloud.compute.functions.HardwareForVAppTemplate;
import org.jclouds.vcloud.compute.functions.ImageForVAppTemplate;
import org.jclouds.vcloud.compute.functions.VAppTemplatesInOrg;
import org.jclouds.vcloud.compute.functions.VAppToNodeMetadata;
import org.jclouds.vcloud.compute.internal.VCloudTemplateBuilderImpl;
import org.jclouds.vcloud.compute.options.VCloudTemplateOptions;
import org.jclouds.vcloud.compute.strategy.VCloudComputeServiceAdapter;
import org.jclouds.vcloud.domain.Org;
import org.jclouds.vcloud.domain.Status;
import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.VAppTemplate;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMap;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.google.inject.Scopes;
import com.google.inject.TypeLiteral;
/**
*
* @author Adrian Cole
*/
public class VCloudComputeServiceDependenciesModule extends AbstractModule {
@VisibleForTesting
public static final Map<Status, NodeState> VAPPSTATUS_TO_NODESTATE = ImmutableMap.<Status, NodeState> builder().put(
Status.OFF, NodeState.SUSPENDED).put(Status.ON, NodeState.RUNNING).put(Status.RESOLVED, NodeState.PENDING)
.put(Status.ERROR, NodeState.ERROR).put(Status.UNRECOGNIZED, NodeState.UNRECOGNIZED).put(Status.DEPLOYED,
NodeState.PENDING).put(Status.INCONSISTENT, NodeState.PENDING).put(Status.UNKNOWN,
NodeState.UNRECOGNIZED).put(Status.MIXED, NodeState.PENDING).put(Status.WAITING_FOR_INPUT,
NodeState.PENDING).put(Status.SUSPENDED, NodeState.SUSPENDED).put(Status.UNRESOLVED,
NodeState.PENDING).build();
@Singleton
@Provides
protected Map<Status, NodeState> provideVAppStatusToNodeState() {
return VAPPSTATUS_TO_NODESTATE;
}
@SuppressWarnings("unchecked")
@Override
protected void configure() {
bind(new TypeLiteral<Supplier<Location>>() {
}).to(DefaultVDC.class).in(Scopes.SINGLETON);
bind(new TypeLiteral<ComputeServiceAdapter<VApp, VAppTemplate, VAppTemplate, Location>>() {
}).to(VCloudComputeServiceAdapter.class);
bind(new TypeLiteral<Function<VApp, NodeMetadata>>() {
}).to(VAppToNodeMetadata.class);
bind(TemplateOptions.class).to(VCloudTemplateOptions.class);
bind(TemplateBuilder.class).to(VCloudTemplateBuilderImpl.class);
bind(new TypeLiteral<Function<VApp, Hardware>>() {
}).to(new TypeLiteral<HardwareForVApp>() {
});
bind(new TypeLiteral<Function<Org, Iterable<VAppTemplate>>>() {
}).to(VAppTemplatesInOrg.class);
bind(new TypeLiteral<Function<VAppTemplate, Image>>() {
}).to(ImageForVAppTemplate.class);
bind(new TypeLiteral<Function<VAppTemplate, Hardware>>() {
}).to(HardwareForVAppTemplate.class);
// we aren't converting from a provider-specific type
bind(new TypeLiteral<Function<Location, Location>>() {
}).to((Class) IdentityFunction.class);
}
@Singleton
public static class DefaultVDC implements Supplier<Location> {
private final Supplier<Set<? extends Location>> locationsSupplier;
private final IsDefaultVDC isDefaultVDC;
@Inject
DefaultVDC(@Memoized Supplier<Set<? extends Location>> locationsSupplier, IsDefaultVDC isDefaultVDC) {
this.locationsSupplier = checkNotNull(locationsSupplier, "locationsSupplierSupplier");
this.isDefaultVDC = checkNotNull(isDefaultVDC, "isDefaultVDC");
}
@Override
public Location get() {
return find(locationsSupplier.get(), isDefaultVDC);
}
}
}

View File

@ -22,6 +22,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.HardwareBuilder;
@ -30,7 +31,6 @@ import org.jclouds.logging.Logger;
import org.jclouds.ovf.Envelope;
import org.jclouds.ovf.VirtualHardwareSection;
import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.domain.VAppTemplate;
import com.google.common.base.Function;
@ -39,6 +39,7 @@ import com.google.common.collect.Iterables;
/**
* @author Adrian Cole
*/
@Singleton
public class HardwareForVAppTemplate implements Function<VAppTemplate, Hardware> {
@Resource
@ -48,8 +49,6 @@ public class HardwareForVAppTemplate implements Function<VAppTemplate, Hardware>
private final FindLocationForResource findLocationForResource;
private final VCloudHardwareBuilderFromResourceAllocations rasdToHardwareBuilder;
private ReferenceType parent;
@Inject
protected HardwareForVAppTemplate(VCloudClient client, FindLocationForResource findLocationForResource,
VCloudHardwareBuilderFromResourceAllocations rasdToHardwareBuilder) {
@ -58,10 +57,6 @@ public class HardwareForVAppTemplate implements Function<VAppTemplate, Hardware>
this.rasdToHardwareBuilder = checkNotNull(rasdToHardwareBuilder, "rasdToHardwareBuilder");
}
public HardwareForVAppTemplate withParent(ReferenceType parent) {
this.parent = parent;
return this;
}
@Override
public Hardware apply(VAppTemplate from) {
@ -86,7 +81,7 @@ public class HardwareForVAppTemplate implements Function<VAppTemplate, Hardware>
}
VirtualHardwareSection hardware = Iterables.get(ovf.getVirtualSystem().getVirtualHardwareSections(), 0);
HardwareBuilder builder = rasdToHardwareBuilder.apply(hardware.getItems());
builder.location(findLocationForResource.apply(checkNotNull(parent, "parent")));
builder.location(findLocationForResource.apply(checkNotNull(from.getVDC(), "VDC")));
builder.ids(from.getHref().toASCIIString()).name(from.getName()).supportsImage(
ImagePredicates.idEquals(from.getHref().toASCIIString()));
return builder.build();

View File

@ -1,61 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.compute.functions;
import javax.inject.Inject;
import javax.inject.Provider;
import javax.inject.Singleton;
import org.jclouds.compute.domain.Hardware;
import org.jclouds.vcloud.domain.CatalogItem;
import org.jclouds.vcloud.domain.Org;
import org.jclouds.vcloud.domain.VAppTemplate;
import org.jclouds.vcloud.functions.AllCatalogItemsInOrg;
import com.google.common.base.Function;
import com.google.common.base.Predicates;
import com.google.common.collect.Iterables;
/**
* @author Adrian Cole
*/
@Singleton
public class HardwareInOrg implements Function<Org, Iterable<? extends Hardware>> {
private final Function<Org, Iterable<? extends CatalogItem>> allCatalogItemsInOrg;
private final Function<Iterable<? extends CatalogItem>, Iterable<? extends VAppTemplate>> vAppTemplatesForCatalogItems;
private final Provider<HardwareForVAppTemplate> sizeForVAppTemplateProvider;
@Inject
HardwareInOrg(AllCatalogItemsInOrg allCatalogItemsInOrg,
Provider<HardwareForVAppTemplate> sizeForVAppTemplateProvider,
Function<Iterable<? extends CatalogItem>, Iterable<? extends VAppTemplate>> vAppTemplatesForCatalogItems) {
this.sizeForVAppTemplateProvider = sizeForVAppTemplateProvider;
this.allCatalogItemsInOrg = allCatalogItemsInOrg;
this.vAppTemplatesForCatalogItems = vAppTemplatesForCatalogItems;
}
@Override
public Iterable<? extends Hardware> apply(Org from) {
Iterable<? extends CatalogItem> catalogs = allCatalogItemsInOrg.apply(from);
Iterable<? extends VAppTemplate> vAppTemplates = vAppTemplatesForCatalogItems.apply(catalogs);
return Iterables.transform(Iterables.filter(vAppTemplates, Predicates.notNull()), sizeForVAppTemplateProvider.get().withParent(from));
}
}

View File

@ -21,14 +21,13 @@ package org.jclouds.vcloud.compute.functions;
import static com.google.common.base.Preconditions.checkNotNull;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.compute.domain.CIMOperatingSystem;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.ImageBuilder;
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
import org.jclouds.ovf.Envelope;
import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.domain.VAppTemplate;
import com.google.common.base.Function;
@ -36,24 +35,17 @@ import com.google.common.base.Function;
/**
* @author Adrian Cole
*/
@Singleton
public class ImageForVAppTemplate implements Function<VAppTemplate, Image> {
private final VCloudClient client;
private final FindLocationForResource findLocationForResource;
private final PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider;
private ReferenceType parent;
@Inject
protected ImageForVAppTemplate(VCloudClient client, FindLocationForResource findLocationForResource,
PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider) {
protected ImageForVAppTemplate(VCloudClient client, FindLocationForResource findLocationForResource) {
this.client = checkNotNull(client, "client");
this.findLocationForResource = checkNotNull(findLocationForResource, "findLocationForResource");
this.credentialsProvider = checkNotNull(credentialsProvider, "credentialsProvider");
}
public ImageForVAppTemplate withParent(ReferenceType parent) {
this.parent = parent;
return this;
}
@Override
public Image apply(VAppTemplate from) {
@ -61,11 +53,10 @@ public class ImageForVAppTemplate implements Function<VAppTemplate, Image> {
builder.ids(from.getHref().toASCIIString());
builder.uri(from.getHref());
builder.name(from.getName());
builder.location(findLocationForResource.apply(checkNotNull(parent, "parent")));
builder.location(findLocationForResource.apply(checkNotNull(from.getVDC(), "VDC")));
builder.description(from.getDescription() != null ? from.getDescription() : from.getName());
Envelope ovf = client.getVAppTemplateClient().getOvfEnvelopeForVAppTemplate(from.getHref());
builder.operatingSystem(CIMOperatingSystem.toComputeOs(ovf));
builder.defaultCredentials(credentialsProvider.apply(from));
return builder.build();
}

View File

@ -18,11 +18,15 @@
*/
package org.jclouds.vcloud.compute.functions;
import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.getCredentialsFrom;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Provider;
import javax.inject.Singleton;
import org.jclouds.compute.domain.Image;
import org.jclouds.domain.Credentials;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.vcloud.domain.CatalogItem;
import org.jclouds.vcloud.domain.Org;
import org.jclouds.vcloud.domain.VAppTemplate;
@ -36,26 +40,39 @@ import com.google.common.collect.Iterables;
* @author Adrian Cole
*/
@Singleton
public class ImagesInOrg implements Function<Org, Iterable<? extends Image>> {
public class VAppTemplatesInOrg implements Function<Org, Iterable<VAppTemplate>> {
private final AllCatalogItemsInOrg allCatalogItemsInOrg;
private final Function<Iterable<? extends CatalogItem>, Iterable<? extends VAppTemplate>> vAppTemplatesForCatalogItems;
private final Provider<ImageForVAppTemplate> imageForVAppTemplateProvider;
private final Function<Iterable<CatalogItem>, Iterable<VAppTemplate>> vAppTemplatesForCatalogItems;
private final Map<String, Credentials> credentialStore;
@Inject
ImagesInOrg(AllCatalogItemsInOrg allCatalogItemsInOrg,
Provider<ImageForVAppTemplate> imageForVAppTemplateProvider,
Function<Iterable<? extends CatalogItem>, Iterable<? extends VAppTemplate>> vAppTemplatesForCatalogItems) {
this.imageForVAppTemplateProvider = imageForVAppTemplateProvider;
VAppTemplatesInOrg(AllCatalogItemsInOrg allCatalogItemsInOrg,
Function<Iterable<CatalogItem>, Iterable<VAppTemplate>> vAppTemplatesForCatalogItems,
Map<String, Credentials> credentialStore) {
this.allCatalogItemsInOrg = allCatalogItemsInOrg;
this.vAppTemplatesForCatalogItems = vAppTemplatesForCatalogItems;
this.credentialStore = credentialStore;
}
@Override
public Iterable<? extends Image> apply(Org from) {
Iterable<? extends CatalogItem> catalogs = allCatalogItemsInOrg.apply(from);
Iterable<? extends VAppTemplate> vAppTemplates = vAppTemplatesForCatalogItems.apply(catalogs);
return Iterables.transform(Iterables.filter(vAppTemplates, Predicates.notNull()), imageForVAppTemplateProvider.get().withParent(from));
public Iterable<VAppTemplate> apply(Org from) {
Iterable<CatalogItem> catalogs = allCatalogItemsInOrg.apply(from);
Iterable<VAppTemplate> vAppTemplates = vAppTemplatesForCatalogItems.apply(catalogs);
return Iterables.transform(Iterables.filter(vAppTemplates, Predicates.notNull()),
new Function<VAppTemplate, VAppTemplate>() {
@Override
public VAppTemplate apply(VAppTemplate arg0) {
LoginCredentials creds = getCredentialsFrom(arg0);
if (creds == null)
credentialStore.remove("image#" + arg0.getHref().toASCIIString());
else
credentialStore.put("image#" + arg0.getHref().toASCIIString(), creds);
return arg0;
}
});
}
}

View File

@ -81,6 +81,9 @@ public class VAppToNodeMetadata implements Function<VApp, NodeMetadata> {
Set<String> addresses = getIpsFromVApp(from);
builder.publicAddresses(filter(addresses, not(IsPrivateIPAddress.INSTANCE)));
builder.privateAddresses(filter(addresses, IsPrivateIPAddress.INSTANCE));
// normally, we don't affect the credential store when reading vApps.
// However, login user, etc, is actually in the metadata, so lets see
Credentials fromApi = getCredentialsFrom(from);
if (fromApi != null && !credentialStore.containsKey("node#" + from.getHref().toASCIIString()))
credentialStore.put("node#" + from.getHref().toASCIIString(), fromApi);

View File

@ -38,7 +38,7 @@ import org.jclouds.vcloud.domain.network.IpAddressAllocationMode;
* <p/>
* ComputeService client = // get connection
* templateBuilder.options(inboundPorts(22, 80, 8080, 443));
* Set<? extends NodeMetadata> set = client.createNodesInGroup(tag, 2, templateBuilder.build());
* Set<NodeMetadata> set = client.createNodesInGroup(tag, 2, templateBuilder.build());
* <code>
*
* @author Adrian Cole

View File

@ -1,52 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.compute.strategy;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.getCredentialsFrom;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.compute.strategy.impl.ReturnCredentialsBoundToImage;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.vcloud.domain.VAppTemplate;
/**
* @author Adrian Cole
*/
@Singleton
public class GetLoginCredentialsFromGuestConfiguration extends ReturnCredentialsBoundToImage {
@Inject
public GetLoginCredentialsFromGuestConfiguration(@Nullable @Named("image") LoginCredentials creds) {
super(creds);
}
@Override
public LoginCredentials apply(Object resourceToAuthenticate) {
if (creds != null)
return creds;
checkNotNull(resourceToAuthenticate);
checkArgument(resourceToAuthenticate instanceof VAppTemplate, "Resource must be an VAppTemplate");
return getCredentialsFrom(VAppTemplate.class.cast(resourceToAuthenticate));
}
}

View File

@ -19,6 +19,7 @@
package org.jclouds.vcloud.compute.strategy;
import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.getCredentialsFrom;
import java.net.URI;
@ -27,11 +28,9 @@ import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials;
import org.jclouds.compute.domain.Template;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName;
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
import org.jclouds.logging.Logger;
import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.compute.options.VCloudTemplateOptions;
@ -53,26 +52,22 @@ import com.google.common.collect.Iterables;
* @author Adrian Cole
*/
@Singleton
public class InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn implements
CreateNodeWithGroupEncodedIntoName {
public class InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn {
@Resource
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
protected Logger logger = Logger.NULL;
protected final VCloudClient client;
protected final GetNodeMetadataStrategy getNode;
protected final Predicate<URI> successTester;
@Inject
protected InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn(Predicate<URI> successTester,
VCloudClient client, GetNodeMetadataStrategy getNode) {
VCloudClient client) {
this.client = client;
this.successTester = successTester;
this.getNode = getNode;
}
@Override
public NodeMetadata createNodeWithGroupEncodedIntoName(String tag, String name, Template template) {
public NodeAndInitialCredentials<VApp> createNodeWithGroupEncodedIntoName(String tag, String name, Template template) {
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
// TODO make disk size specifiable
@ -122,8 +117,10 @@ public class InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployA
waitForTask(updateMemoryMBOfVm(vm, memoryMB), vAppResponse);
logger.trace("<< updated memoryMB vm(%s) ", vm.getName());
logger.trace(">> deploying and powering on vApp(%s) ", vAppResponse.getName());
return blockOnDeployAndPowerOnIfConfigured(options, vAppResponse, client.getVAppClient().deployAndPowerOnVApp(
vAppResponse.getHref()));
vAppResponse = blockOnDeployAndPowerOnIfConfigured(options, vAppResponse, client.getVAppClient()
.deployAndPowerOnVApp(vAppResponse.getHref()));
return new NodeAndInitialCredentials<VApp>(vAppResponse, vAppResponse.getHref().toASCIIString(),
getCredentialsFrom(vAppResponse));
}
@ -167,12 +164,11 @@ public class InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployA
return client.getVmClient().updateMemoryMBOfVm(memoryInMB, vm.getHref());
}
private NodeMetadata blockOnDeployAndPowerOnIfConfigured(InstantiateVAppTemplateOptions options, VApp vAppResponse,
Task task) {
private VApp blockOnDeployAndPowerOnIfConfigured(InstantiateVAppTemplateOptions options, VApp vAppResponse, Task task) {
if (options.shouldBlock()) {
waitForTask(task, vAppResponse);
logger.debug("<< ready vApp(%s)", vAppResponse.getName());
}
return getNode.getNode(vAppResponse.getHref().toASCIIString());
return client.getVAppClient().getVApp(vAppResponse.getHref());
}
}

View File

@ -0,0 +1,209 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.compute.strategy;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import java.util.Map;
import java.util.Set;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.compute.ComputeService;
import org.jclouds.compute.ComputeServiceAdapter;
import org.jclouds.compute.domain.Template;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.domain.Location;
import org.jclouds.logging.Logger;
import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.compute.suppliers.OrgAndVDCToLocationSupplier;
import org.jclouds.vcloud.domain.Org;
import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.domain.Status;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.VAppTemplate;
import org.jclouds.vcloud.suppliers.VAppTemplatesSupplier;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSet.Builder;
/**
* defines the connection between the {@link VCloudClient} implementation and the jclouds
* {@link ComputeService}
*
*/
@Singleton
public class VCloudComputeServiceAdapter implements ComputeServiceAdapter<VApp, VAppTemplate, VAppTemplate, Location> {
@Resource
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
protected Logger logger = Logger.NULL;
protected final VCloudClient client;
protected final Predicate<URI> successTester;
protected final InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn booter;
protected final Supplier<Map<String, Org>> nameToOrg;
protected final Supplier<Set<VAppTemplate>> templates;
protected final Supplier<Set<? extends Location>> locations;
@Inject
protected VCloudComputeServiceAdapter(VCloudClient client, Predicate<URI> successTester,
InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn booter,
Supplier<Map<String, Org>> nameToOrg, VAppTemplatesSupplier templates,
OrgAndVDCToLocationSupplier locations) {
this.client = checkNotNull(client, "client");
this.successTester = checkNotNull(successTester, "successTester");
this.booter = checkNotNull(booter, "booter");
this.nameToOrg = checkNotNull(nameToOrg, "nameToOrg");
this.templates = checkNotNull(templates, "templates");
this.locations = checkNotNull(locations, "locations");
}
@Override
public NodeAndInitialCredentials<VApp> createNodeWithGroupEncodedIntoName(String group, String name,
Template template) {
return booter.createNodeWithGroupEncodedIntoName(group, name, template);
}
@Override
public Iterable<VAppTemplate> listHardwareProfiles() {
return templates.get();
}
@Override
public Iterable<VAppTemplate> listImages() {
return templates.get();
}
@Override
public Iterable<VApp> listNodes() {
// TODO: parallel or cache
Builder<VApp> nodes = ImmutableSet.<VApp> builder();
for (Org org : nameToOrg.get().values()) {
for (ReferenceType vdc : org.getVDCs().values()) {
for (ReferenceType resource : client.getVDCClient().getVDC(vdc.getHref()).getResourceEntities().values()) {
if (resource.getType().equals(VCloudMediaType.VAPP_XML)) {
addVAppToSetRetryingIfNotYetPresent(nodes, vdc, resource);
}
}
}
}
return nodes.build();
}
@VisibleForTesting
void addVAppToSetRetryingIfNotYetPresent(Builder<VApp> nodes, ReferenceType vdc, ReferenceType resource) {
VApp node = null;
int i = 0;
while (node == null && i++ < 3) {
try {
node = client.getVAppClient().getVApp(resource.getHref());
nodes.add(node);
} catch (NullPointerException e) {
logger.warn("vApp %s not yet present in vdc %s", resource.getName(), vdc.getName());
}
}
}
@SuppressWarnings("unchecked")
@Override
public Iterable<Location> listLocations() {
return (Iterable<Location>) locations.get();
}
@Override
public VApp getNode(String in) {
URI id = URI.create(in);
return client.getVAppClient().getVApp(id);
}
@Override
public void destroyNode(String id) {
URI vappId = URI.create(checkNotNull(id, "node.id"));
VApp vApp = client.getVAppClient().getVApp(vappId);
waitForPendingTasksToComplete(vApp);
vApp = undeployVAppIfDeployed(vApp);
deleteVApp(vApp);
}
void waitForPendingTasksToComplete(VApp vApp) {
for (Task task : vApp.getTasks())
waitForTask(task, vApp);
}
public void waitForTask(Task task, VApp vAppResponse) {
if (!successTester.apply(task.getHref())) {
throw new RuntimeException(String.format("failed to %s %s: %s", task.getName(), vAppResponse.getName(), task));
}
}
void deleteVApp(VApp vApp) {
logger.debug(">> deleting vApp(%s)", vApp.getHref());
waitForTask(client.getVAppClient().deleteVApp(vApp.getHref()), vApp);
logger.debug("<< deleted vApp(%s)", vApp.getHref());
}
VApp undeployVAppIfDeployed(VApp vApp) {
if (vApp.getStatus() != Status.OFF) {
logger.debug(">> undeploying vApp(%s), current status: %s", vApp.getName(), vApp.getStatus());
try {
waitForTask(client.getVAppClient().undeployVApp(vApp.getHref()), vApp);
vApp = client.getVAppClient().getVApp(vApp.getHref());
logger.debug("<< %s vApp(%s)", vApp.getStatus(), vApp.getName());
} catch (IllegalStateException e) {
logger.warn(e, "<< %s vApp(%s)", vApp.getStatus(), vApp.getName());
}
}
return vApp;
}
@Override
public void rebootNode(String in) {
URI id = URI.create(checkNotNull(in, "node.id"));
Task task = client.getVAppClient().resetVApp(id);
successTester.apply(task.getHref());
}
@Override
public void resumeNode(String in) {
URI id = URI.create(checkNotNull(in, "node.id"));
Task task = client.getVAppClient().powerOnVApp(id);
successTester.apply(task.getHref());
}
@Override
public void suspendNode(String in) {
URI id = URI.create(checkNotNull(in, "node.id"));
Task task = client.getVAppClient().powerOffVApp(id);
successTester.apply(task.getHref());
}
}

View File

@ -1,114 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.compute.strategy;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.compute.strategy.DestroyNodeStrategy;
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
import org.jclouds.logging.Logger;
import org.jclouds.rest.AuthorizationException;
import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.domain.Status;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.VApp;
import com.google.common.base.Predicate;
/**
* @author Adrian Cole
*/
@Singleton
public class VCloudDestroyNodeStrategy implements DestroyNodeStrategy {
@Resource
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
protected Logger logger = Logger.NULL;
protected final Predicate<URI> successTester;
protected final VCloudClient client;
protected final GetNodeMetadataStrategy getNode;
@Inject
protected VCloudDestroyNodeStrategy(Predicate<URI> successTester, VCloudClient client,
GetNodeMetadataStrategy getNode) {
this.successTester = successTester;
this.client = client;
this.getNode = getNode;
}
@Override
public NodeMetadata destroyNode(String id) {
URI vappId = URI.create(checkNotNull(id, "node.id"));
VApp vApp = client.getVAppClient().getVApp(vappId);
if (vApp == null)
return null;
waitForPendingTasksToComplete(vApp);
vApp = undeployVAppIfDeployed(vApp);
deleteVApp(vApp);
try {
return getNode.getNode(id);
} catch (AuthorizationException e) {
// vcloud bug will sometimes throw an exception getting the vapp right after deleting it.
logger.trace("authorization error getting %s after deletion: %s", id, e.getMessage());
return null;
}
}
void waitForPendingTasksToComplete(VApp vApp) {
for (Task task : vApp.getTasks())
waitForTask(task, vApp);
}
public void waitForTask(Task task, VApp vAppResponse) {
if (!successTester.apply(task.getHref())) {
throw new RuntimeException(String.format("failed to %s %s: %s", task.getName(), vAppResponse.getName(), task));
}
}
void deleteVApp(VApp vApp) {
logger.debug(">> deleting vApp(%s)", vApp.getHref());
waitForTask(client.getVAppClient().deleteVApp(vApp.getHref()), vApp);
logger.debug("<< deleted vApp(%s)", vApp.getHref());
}
VApp undeployVAppIfDeployed(VApp vApp) {
if (vApp.getStatus() != Status.OFF) {
logger.debug(">> undeploying vApp(%s), current status: %s", vApp.getName(), vApp.getStatus());
try {
waitForTask(client.getVAppClient().undeployVApp(vApp.getHref()), vApp);
vApp = client.getVAppClient().getVApp(vApp.getHref());
logger.debug("<< %s vApp(%s)", vApp.getStatus(), vApp.getName());
} catch (IllegalStateException e) {
logger.warn(e, "<< %s vApp(%s)", vApp.getStatus(), vApp.getName());
}
}
return vApp;
}
}

View File

@ -1,57 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.compute.strategy;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.domain.VApp;
import com.google.common.base.Function;
/**
* @author Adrian Cole
*/
@Singleton
public class VCloudGetNodeMetadataStrategy implements GetNodeMetadataStrategy {
protected final VCloudClient client;
protected final Function<VApp, NodeMetadata> vAppToNodeMetadata;
@Inject
protected VCloudGetNodeMetadataStrategy(VCloudClient client, Function<VApp, NodeMetadata> vAppToNodeMetadata) {
this.client = checkNotNull(client, "client");
this.vAppToNodeMetadata = checkNotNull(vAppToNodeMetadata, "vAppToNodeMetadata");
}
public NodeMetadata getNode(String in) {
URI id = URI.create(in);
VApp from = client.getVAppClient().getVApp(id);
if (from == null)
return null;
return vAppToNodeMetadata.apply(from);
}
}

View File

@ -1,80 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.compute.strategy;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
import org.jclouds.compute.strategy.RebootNodeStrategy;
import org.jclouds.compute.strategy.ResumeNodeStrategy;
import org.jclouds.compute.strategy.SuspendNodeStrategy;
import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.domain.Task;
import com.google.common.base.Predicate;
/**
* @author Adrian Cole
*/
@Singleton
public class VCloudLifeCycleStrategy implements RebootNodeStrategy, ResumeNodeStrategy, SuspendNodeStrategy {
@Resource
private final VCloudClient client;
protected final Predicate<URI> taskTester;
protected final GetNodeMetadataStrategy getNode;
@Inject
protected VCloudLifeCycleStrategy(VCloudClient client, Predicate<URI> taskTester,
GetNodeMetadataStrategy getNode) {
this.client = client;
this.taskTester = taskTester;
this.getNode = getNode;
}
@Override
public NodeMetadata rebootNode(String in) {
URI id = URI.create(checkNotNull(in, "node.id"));
Task task = client.getVAppClient().resetVApp(id);
return returnWhenTaskCompletes(in, task);
}
private NodeMetadata returnWhenTaskCompletes(String in, Task task) {
taskTester.apply(task.getHref());
return getNode.getNode(in);
}
@Override
public NodeMetadata resumeNode(String in) {
Task task = client.getVAppClient().powerOnVApp(URI.create(checkNotNull(in, "node.id")));
return returnWhenTaskCompletes(in, task);
}
@Override
public NodeMetadata suspendNode(String in) {
Task task = client.getVAppClient().powerOffVApp(URI.create(checkNotNull(in, "node.id")));
return returnWhenTaskCompletes(in, task);
}
}

View File

@ -1,140 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.compute.strategy;
import static org.jclouds.compute.reference.ComputeServiceConstants.COMPUTE_LOGGER;
import static org.jclouds.compute.reference.ComputeServiceConstants.PROPERTY_BLACKLIST_NODES;
import java.util.Map;
import java.util.Set;
import javax.annotation.Resource;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.compute.domain.ComputeMetadata;
import org.jclouds.compute.domain.ComputeMetadataBuilder;
import org.jclouds.compute.domain.ComputeType;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.strategy.ListNodesStrategy;
import org.jclouds.logging.Logger;
import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.compute.functions.FindLocationForResource;
import org.jclouds.vcloud.domain.Org;
import org.jclouds.vcloud.domain.ReferenceType;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Predicate;
import com.google.common.base.Splitter;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSet.Builder;
import com.google.inject.Inject;
/**
* @author Adrian Cole
*/
// TODO REFACTOR!!! needs to be parallel
@Singleton
public class VCloudListNodesStrategy implements ListNodesStrategy {
@Resource
@Named(COMPUTE_LOGGER)
public Logger logger = Logger.NULL;
protected final VCloudClient client;
protected final Supplier<Map<String, ? extends Org>> nameToOrg;
protected final VCloudGetNodeMetadataStrategy getNodeMetadata;
protected final FindLocationForResource findLocationForResourceInVDC;
Set<String> blackListVAppNames = ImmutableSet.<String> of();
@Inject(optional = true)
void setBlackList(@Named(PROPERTY_BLACKLIST_NODES) String blackListNodes) {
if (blackListNodes != null && !"".equals(blackListNodes))
this.blackListVAppNames = ImmutableSet.copyOf(Splitter.on(',').split(blackListNodes));
}
@Inject
protected VCloudListNodesStrategy(VCloudClient client, Supplier<Map<String, ? extends Org>> nameToOrg,
VCloudGetNodeMetadataStrategy getNodeMetadata, FindLocationForResource findLocationForResourceInVDC) {
this.client = client;
this.nameToOrg = nameToOrg;
this.getNodeMetadata = getNodeMetadata;
this.findLocationForResourceInVDC = findLocationForResourceInVDC;
}
@Override
public Iterable<ComputeMetadata> listNodes() {
Builder<ComputeMetadata> nodes = ImmutableSet.<ComputeMetadata> builder();
for (Org org : nameToOrg.get().values()) {
for (ReferenceType vdc : org.getVDCs().values()) {
for (ReferenceType resource : client.getVDCClient().getVDC(vdc.getHref()).getResourceEntities().values()) {
if (validVApp(resource)) {
nodes.add(convertVAppToComputeMetadata(vdc, resource));
}
}
}
}
return nodes.build();
}
private boolean validVApp(ReferenceType resource) {
return resource.getType().equals(VCloudMediaType.VAPP_XML) && !blackListVAppNames.contains(resource.getName());
}
private ComputeMetadata convertVAppToComputeMetadata(ReferenceType vdc, ReferenceType resource) {
ComputeMetadataBuilder builder = new ComputeMetadataBuilder(ComputeType.NODE);
builder.providerId(resource.getHref().toASCIIString());
builder.name(resource.getName());
builder.id(resource.getHref().toASCIIString());
builder.location(findLocationForResourceInVDC.apply(vdc));
return builder.build();
}
@Override
public Iterable<NodeMetadata> listDetailsOnNodesMatching(Predicate<ComputeMetadata> filter) {
Builder<NodeMetadata> nodes = ImmutableSet.<NodeMetadata> builder();
for (Org org : nameToOrg.get().values()) {
for (ReferenceType vdc : org.getVDCs().values()) {
for (ReferenceType resource : client.getVDCClient().getVDC(vdc.getHref()).getResourceEntities().values()) {
if (validVApp(resource) && filter.apply(convertVAppToComputeMetadata(vdc, resource))) {
addVAppToSetRetryingIfNotYetPresent(nodes, vdc, resource);
}
}
}
}
return nodes.build();
}
@VisibleForTesting
void addVAppToSetRetryingIfNotYetPresent(Builder<NodeMetadata> nodes, ReferenceType vdc, ReferenceType resource) {
NodeMetadata node = null;
int i = 0;
while (node == null && i++ < 3) {
try {
node = getNodeMetadata.getNode(resource.getHref().toASCIIString());
nodes.add(node);
} catch (NullPointerException e) {
logger.warn("vApp %s not yet present in vdc %s", resource.getName(), vdc.getName());
}
}
}
}

View File

@ -48,13 +48,13 @@ import com.google.common.collect.ImmutableSet.Builder;
public class OrgAndVDCToLocationSupplier extends JustProvider {
private final Supplier<Map<String, ReferenceType>> orgNameToResource;
private final Supplier<Map<String, ? extends Org>> orgNameToVDCResource;
private final Supplier<Map<String, Org>> orgNameToVDCResource;
private final Map<String, Set<String>> isoCodesById;
@Inject
OrgAndVDCToLocationSupplier(@Iso3166 Set<String> isoCodes, @Provider String providerName, @Provider URI endpoint,
@org.jclouds.vcloud.endpoints.Org Supplier<Map<String, ReferenceType>> orgNameToResource,
Supplier<Map<String, ? extends Org>> orgNameToVDCResource, @Iso3166 Map<String, Set<String>> isoCodesById) {
Supplier<Map<String, Org>> orgNameToVDCResource, @Iso3166 Map<String, Set<String>> isoCodesById) {
super(providerName, endpoint, isoCodes);
this.orgNameToResource = checkNotNull(orgNameToResource, "orgNameToResource");
this.orgNameToVDCResource = checkNotNull(orgNameToVDCResource, "orgNameToVDCResource");
@ -62,7 +62,7 @@ public class OrgAndVDCToLocationSupplier extends JustProvider {
}
@Override
public Set<? extends Location> get() {
public Set<Location> get() {
return buildJustProviderOrVDCs().build();
}

View File

@ -1,52 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.compute.suppliers;
import java.util.Set;
import javax.inject.Singleton;
import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.HardwareBuilder;
import org.jclouds.compute.domain.Processor;
import org.jclouds.compute.domain.Volume;
import org.jclouds.compute.domain.internal.VolumeImpl;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Sets;
/**
* @author Adrian Cole
*/
@Singleton
public class StaticHardwareSupplier implements Supplier<Set<? extends Hardware>> {
@Override
public Set<? extends Hardware> get() {
Set<Hardware> hardware = Sets.newHashSet();
for (int cpus : new int[] { 1, 2, 4, 8 })
for (int ram : new int[] { 512, 1024, 2048, 4096, 8192, 16384 }) {
String id = String.format("cpu=%d,ram=%s,disk=%d", cpus, ram, 10);
hardware.add(new HardwareBuilder().ids(id).ram(ram).processors(ImmutableList.of(new Processor(cpus, 1.0)))
.volumes(ImmutableList.<Volume> of(new VolumeImpl(10f, true, true))).build());
}
return hardware;
}
}

View File

@ -1,95 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.compute.suppliers;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Iterables.concat;
import static com.google.common.collect.Sets.newLinkedHashSet;
import static org.jclouds.concurrent.FutureIterables.transformParallel;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.Constants;
import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.logging.Logger;
import org.jclouds.vcloud.domain.Org;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
/**
* @author Adrian Cole
*/
@Singleton
public class VCloudHardwareSupplier implements Supplier<Set<? extends Hardware>> {
@Resource
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
public Logger logger = Logger.NULL;
private final Supplier<Map<String, ? extends Org>> orgMap;
private final Function<Org, Iterable<? extends Hardware>> sizesInOrg;
private final ExecutorService executor;
@Inject
VCloudHardwareSupplier(Supplier<Map<String, ? extends Org>> orgMap,
Function<Org, Iterable<? extends Hardware>> sizesInOrg,
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
this.orgMap = checkNotNull(orgMap, "orgMap");
this.sizesInOrg = checkNotNull(sizesInOrg, "sizesInOrg");
this.executor = checkNotNull(executor, "executor");
}
@Override
public Set<? extends Hardware> get() {
Iterable<? extends Org> orgs = checkNotNull(orgMap.get().values(), "orgs");
Iterable<Iterable<? extends Hardware>> sizes = transformParallel(orgs,
new Function<Org, Future<Iterable<? extends Hardware>>>() {
@Override
public Future<Iterable<? extends Hardware>> apply(final Org from) {
checkNotNull(from, "org");
return executor.submit(new Callable<Iterable<? extends Hardware>>() {
@Override
public Iterable<? extends Hardware> call() throws Exception {
return sizesInOrg.apply(from);
}
@Override
public String toString() {
return "sizesInOrg(" + from.getHref() + ")";
}
});
}
}, executor, null, logger, "sizes in " + orgs);
return newLinkedHashSet(concat(sizes));
}
}

View File

@ -44,20 +44,20 @@ import com.google.common.base.Supplier;
@Singleton
public class DefaultCatalogForOrg implements Function<ReferenceType, ReferenceType> {
private final OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault selector;
private final Supplier<Map<String, ? extends Org>> nameToOrg;
private final Supplier<Map<String, Org>> nameToOrg;
@Inject
public DefaultCatalogForOrg(ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull,
@Catalog Predicate<ReferenceType> defaultSelector, Supplier<Map<String, ? extends Org>> nameToOrg) {
@Catalog Predicate<ReferenceType> defaultSelector, Supplier<Map<String, Org>> nameToOrg) {
this.selector = new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(checkNotNull(
valueOfConfigurationKeyOrNull, "valueOfConfigurationKeyOrNull"), PROPERTY_VCLOUD_DEFAULT_CATALOG,
checkNotNull(defaultSelector, "defaultSelector"));
valueOfConfigurationKeyOrNull, "valueOfConfigurationKeyOrNull"), PROPERTY_VCLOUD_DEFAULT_CATALOG,
checkNotNull(defaultSelector, "defaultSelector"));
this.nameToOrg = checkNotNull(nameToOrg, "nameToOrg");
}
@Override
public ReferenceType apply(ReferenceType defaultOrg) {
org.jclouds.vcloud.domain.Org org = nameToOrg.get().get(defaultOrg.getName());
Org org = nameToOrg.get().get(defaultOrg.getName());
checkState(org != null, "could not retrieve Org at %s", defaultOrg);
return selector.apply(org.getCatalogs().values());
}

View File

@ -46,15 +46,14 @@ import com.google.common.base.Supplier;
public class DefaultNetworkForVDC implements Function<ReferenceType, ReferenceType> {
private final OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault selector;
private final Supplier<Map<URI, ? extends VDC>> uriToVDC;
private final Supplier<Map<URI, VDC>> uriToVDC;
@Inject
public DefaultNetworkForVDC(ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull,
@Network Predicate<ReferenceType> defaultSelector,
Supplier<Map<URI, ? extends org.jclouds.vcloud.domain.VDC>> uriToVDC) {
@Network Predicate<ReferenceType> defaultSelector, Supplier<Map<URI, VDC>> uriToVDC) {
this.selector = new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(checkNotNull(
valueOfConfigurationKeyOrNull, "valueOfConfigurationKeyOrNull"), PROPERTY_VCLOUD_DEFAULT_NETWORK,
checkNotNull(defaultSelector, "defaultSelector"));
valueOfConfigurationKeyOrNull, "valueOfConfigurationKeyOrNull"), PROPERTY_VCLOUD_DEFAULT_NETWORK,
checkNotNull(defaultSelector, "defaultSelector"));
this.uriToVDC = checkNotNull(uriToVDC, "uriToVDC");
}

View File

@ -38,10 +38,10 @@ import com.google.common.base.Supplier;
*/
@Singleton
public class DefaultTasksListForOrg implements Function<ReferenceType, ReferenceType> {
private final Supplier<Map<String, ? extends Org>> nameToOrg;
private final Supplier<Map<String, Org>> nameToOrg;
@Inject
public DefaultTasksListForOrg(Supplier<Map<String, ? extends Org>> nameToOrg) {
public DefaultTasksListForOrg(Supplier<Map<String, Org>> nameToOrg) {
this.nameToOrg = checkNotNull(nameToOrg, "nameToOrg");
}

View File

@ -58,7 +58,7 @@ public class DefaultVCloudReferencesModule extends AbstractModule {
@org.jclouds.vcloud.endpoints.Org
@Singleton
protected ReferenceType provideDefaultOrg(DefaultOrgForUser defaultOrgURIForUser,
@Named(PROPERTY_IDENTITY) String user) {
@Named(PROPERTY_IDENTITY) String user) {
return defaultOrgURIForUser.apply(user);
}
@ -73,7 +73,7 @@ public class DefaultVCloudReferencesModule extends AbstractModule {
@org.jclouds.vcloud.endpoints.TasksList
@Singleton
protected ReferenceType provideDefaultTasksList(DefaultTasksListForOrg defaultTasksListURIForOrg,
@org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) {
@org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) {
return defaultTasksListURIForOrg.apply(defaultOrg);
}
@ -81,7 +81,7 @@ public class DefaultVCloudReferencesModule extends AbstractModule {
@org.jclouds.vcloud.endpoints.Catalog
@Singleton
protected ReferenceType provideDefaultCatalog(DefaultCatalogForOrg defaultCatalogURIForOrg,
@org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) {
@org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) {
return defaultCatalogURIForOrg.apply(defaultOrg);
}
@ -94,24 +94,24 @@ public class DefaultVCloudReferencesModule extends AbstractModule {
@Provides
@Singleton
protected Supplier<Map<URI, ? extends org.jclouds.vcloud.domain.Catalog>> provideCatalogsById(
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> supplier) {
protected Supplier<Map<URI, org.jclouds.vcloud.domain.Catalog>> provideCatalogsById(
Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.Catalog>>> supplier) {
return Suppliers
.compose(
new Function<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>, Map<URI, ? extends org.jclouds.vcloud.domain.Catalog>>() {
.compose(
new Function<Map<String, Map<String, org.jclouds.vcloud.domain.Catalog>>, Map<URI, org.jclouds.vcloud.domain.Catalog>>() {
@Override
public Map<URI, ? extends Catalog> apply(Map<String, Map<String, ? extends Catalog>> arg0) {
Builder<URI, Catalog> builder = ImmutableMap.<URI, Catalog> builder();
for (Map<String, ? extends Catalog> v1 : arg0.values()) {
for (Catalog v2 : v1.values()) {
builder.put(v2.getHref(), v2);
@Override
public Map<URI, Catalog> apply(Map<String, Map<String, Catalog>> arg0) {
Builder<URI, Catalog> builder = ImmutableMap.<URI, Catalog> builder();
for (Map<String, Catalog> v1 : arg0.values()) {
for (Catalog v2 : v1.values()) {
builder.put(v2.getHref(), v2);
}
}
return builder.build();
}
}
return builder.build();
}
}, supplier);
}, supplier);
}
@Singleton
@ -120,10 +120,10 @@ public class DefaultVCloudReferencesModule extends AbstractModule {
@Resource
protected Logger logger = Logger.NULL;
private final Supplier<Map<URI, ? extends org.jclouds.vcloud.domain.Catalog>> catalogsByIdSupplier;
private final Supplier<Map<URI, org.jclouds.vcloud.domain.Catalog>> catalogsByIdSupplier;
@Inject
public WriteableCatalog(Supplier<Map<URI, ? extends org.jclouds.vcloud.domain.Catalog>> catalogsByIdSupplier) {
public WriteableCatalog(Supplier<Map<URI, org.jclouds.vcloud.domain.Catalog>> catalogsByIdSupplier) {
this.catalogsByIdSupplier = catalogsByIdSupplier;
}
@ -132,7 +132,7 @@ public class DefaultVCloudReferencesModule extends AbstractModule {
// TODO: this is inefficient, calculating the index each time, but
// shouldn't be added to constructor as the supplier is an expensive
// call
Map<URI, ? extends Catalog> index = catalogsByIdSupplier.get();
Map<URI, Catalog> index = catalogsByIdSupplier.get();
Catalog catalog = index.get(arg0.getHref());
if (catalog == null) {
if (logger.isTraceEnabled())
@ -147,7 +147,7 @@ public class DefaultVCloudReferencesModule extends AbstractModule {
@org.jclouds.vcloud.endpoints.VDC
@Singleton
protected ReferenceType provideDefaultVDC(DefaultVDCForOrg defaultVDCURIForOrg,
@org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) {
@org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) {
return defaultVDCURIForOrg.apply(defaultOrg);
}
@ -162,7 +162,7 @@ public class DefaultVCloudReferencesModule extends AbstractModule {
@org.jclouds.vcloud.endpoints.Network
@Singleton
protected ReferenceType provideDefaultNetwork(DefaultNetworkForVDC defaultNetworkURIForVDC,
@org.jclouds.vcloud.endpoints.VDC ReferenceType defaultVDC) {
@org.jclouds.vcloud.endpoints.VDC ReferenceType defaultVDC) {
return defaultNetworkURIForVDC.apply(defaultVDC);
}

View File

@ -44,20 +44,20 @@ import com.google.common.base.Supplier;
@Singleton
public class DefaultVDCForOrg implements Function<ReferenceType, ReferenceType> {
private final OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault selector;
private final Supplier<Map<String, ? extends Org>> nameToOrg;
private final Supplier<Map<String, Org>> nameToOrg;
@Inject
public DefaultVDCForOrg(ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull,
@VDC Predicate<ReferenceType> defaultSelector, Supplier<Map<String, ? extends Org>> nameToOrg) {
@VDC Predicate<ReferenceType> defaultSelector, Supplier<Map<String, Org>> nameToOrg) {
this.selector = new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(checkNotNull(
valueOfConfigurationKeyOrNull, "valueOfConfigurationKeyOrNull"), PROPERTY_VCLOUD_DEFAULT_VDC, checkNotNull(
defaultSelector, "defaultSelector"));
valueOfConfigurationKeyOrNull, "valueOfConfigurationKeyOrNull"), PROPERTY_VCLOUD_DEFAULT_VDC,
checkNotNull(defaultSelector, "defaultSelector"));
this.nameToOrg = checkNotNull(nameToOrg, "nameToOrg");
}
@Override
public ReferenceType apply(ReferenceType defaultOrg) {
org.jclouds.vcloud.domain.Org org = nameToOrg.get().get(defaultOrg.getName());
Org org = nameToOrg.get().get(defaultOrg.getName());
checkState(org != null, "could not retrieve Org at %s", defaultOrg);
return selector.apply(org.getVDCs().values());
}

View File

@ -110,8 +110,7 @@ import com.google.inject.Provides;
import com.google.inject.TypeLiteral;
/**
* Configures the VCloud authentication service connection, including logging
* and http transport.
* Configures the VCloud authentication service connection, including logging and http transport.
*
* @author Adrian Cole
*/
@ -143,28 +142,28 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
@Provides
@Singleton
protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
AtomicReference<AuthorizationException> authException, final VCloudLoginAsyncClient login) {
AtomicReference<AuthorizationException> authException, final VCloudLoginAsyncClient login) {
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<VCloudSession>(authException, seconds,
new Supplier<VCloudSession>() {
new Supplier<VCloudSession>() {
@Override
public VCloudSession get() {
try {
return login.login().get(10, TimeUnit.SECONDS);
} catch (Exception e) {
propagate(e);
assert false : e;
return null;
@Override
public VCloudSession get() {
try {
return login.login().get(10, TimeUnit.SECONDS);
} catch (Exception e) {
propagate(e);
assert false : e;
return null;
}
}
}
});
});
}
@Override
protected void configure() {
super.configure();
bind(new TypeLiteral<Function<Iterable<? extends CatalogItem>, Iterable<? extends VAppTemplate>>>() {
bind(new TypeLiteral<Function<Iterable<CatalogItem>, Iterable<VAppTemplate>>>() {
}).to(new TypeLiteral<VAppTemplatesForCatalogItems>() {
});
bind(ResourceAllocationSettingDataHandler.class).to(VCloudResourceAllocationSettingDataHandler.class);
@ -175,22 +174,22 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
bind(new TypeLiteral<Function<ReferenceType, Location>>() {
}).to(new TypeLiteral<FindLocationForResource>() {
});
bind(new TypeLiteral<Function<Org, Iterable<? extends Catalog>>>() {
bind(new TypeLiteral<Function<Org, Iterable<Catalog>>>() {
}).to(new TypeLiteral<AllCatalogsInOrg>() {
});
bind(new TypeLiteral<Function<Org, Iterable<? extends VDC>>>() {
bind(new TypeLiteral<Function<Org, Iterable<VDC>>>() {
}).to(new TypeLiteral<AllVDCsInOrg>() {
});
bind(new TypeLiteral<Function<Iterable<String>, Iterable<? extends Org>>>() {
bind(new TypeLiteral<Function<Iterable<String>, Iterable<Org>>>() {
}).to(new TypeLiteral<OrgsForNames>() {
});
bind(new TypeLiteral<Function<Iterable<? extends Location>, Iterable<? extends Org>>>() {
bind(new TypeLiteral<Function<Iterable<Location>, Iterable<Org>>>() {
}).to(new TypeLiteral<OrgsForLocations>() {
});
bind(new TypeLiteral<Function<Catalog, Iterable<? extends CatalogItem>>>() {
bind(new TypeLiteral<Function<Catalog, Iterable<CatalogItem>>>() {
}).to(new TypeLiteral<AllCatalogItemsInCatalog>() {
});
bind(new TypeLiteral<Function<Org, Iterable<? extends CatalogItem>>>() {
bind(new TypeLiteral<Function<Org, Iterable<CatalogItem>>>() {
}).to(new TypeLiteral<AllCatalogItemsInOrg>() {
});
}
@ -198,13 +197,13 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
@Provides
@Singleton
@org.jclouds.vcloud.endpoints.VDC
protected Supplier<Map<String, String>> provideVDCtoORG(Supplier<Map<String, ? extends Org>> orgNameToOrgSuppier) {
return compose(new Function<Map<String, ? extends Org>, Map<String, String>>() {
protected Supplier<Map<String, String>> provideVDCtoORG(Supplier<Map<String, Org>> orgNameToOrgSuppier) {
return compose(new Function<Map<String, Org>, Map<String, String>>() {
@Override
public Map<String, String> apply(Map<String, ? extends Org> arg0) {
public Map<String, String> apply(Map<String, Org> arg0) {
Builder<String, String> returnVal = ImmutableMap.<String, String> builder();
for (Entry<String, ? extends Org> orgr : arg0.entrySet()) {
for (Entry<String, Org> orgr : arg0.entrySet()) {
for (String vdc : orgr.getValue().getVDCs().keySet()) {
returnVal.put(vdc, orgr.getKey());
}
@ -217,10 +216,10 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
@Provides
@Singleton
protected Supplier<Map<String, ? extends Org>> provideOrgMapCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
AtomicReference<AuthorizationException> authException, OrgMapSupplier supplier) {
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, ? extends Org>>(
authException, seconds, supplier);
protected Supplier<Map<String, Org>> provideOrgMapCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
AtomicReference<AuthorizationException> authException, OrgMapSupplier supplier) {
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, Org>>(authException, seconds,
supplier);
}
@Provides
@ -232,19 +231,19 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
}
@Singleton
public static class OrgMapSupplier implements Supplier<Map<String, ? extends Org>> {
public static class OrgMapSupplier implements Supplier<Map<String, Org>> {
protected final Supplier<VCloudSession> sessionSupplier;
protected final Function<Iterable<String>, Iterable<? extends Org>> organizationsForNames;
protected final Function<Iterable<String>, Iterable<Org>> organizationsForNames;
@Inject
protected OrgMapSupplier(Supplier<VCloudSession> sessionSupplier,
Function<Iterable<String>, Iterable<? extends Org>> organizationsForNames) {
Function<Iterable<String>, Iterable<Org>> organizationsForNames) {
this.sessionSupplier = sessionSupplier;
this.organizationsForNames = organizationsForNames;
}
@Override
public Map<String, ? extends Org> get() {
public Map<String, Org> get() {
return uniqueIndex(organizationsForNames.apply(sessionSupplier.get().getOrgs().keySet()), name);
}
}
@ -255,30 +254,30 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
@Singleton
public static class OrgCatalogSupplier implements
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> {
protected final Supplier<Map<String, ? extends Org>> orgSupplier;
protected final Function<Org, Iterable<? extends org.jclouds.vcloud.domain.Catalog>> allCatalogsInOrg;
Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.Catalog>>> {
protected final Supplier<Map<String, Org>> orgSupplier;
protected final Function<Org, Iterable<org.jclouds.vcloud.domain.Catalog>> allCatalogsInOrg;
@Inject
protected OrgCatalogSupplier(Supplier<Map<String, ? extends Org>> orgSupplier,
Function<Org, Iterable<? extends org.jclouds.vcloud.domain.Catalog>> allCatalogsInOrg) {
protected OrgCatalogSupplier(Supplier<Map<String, Org>> orgSupplier,
Function<Org, Iterable<org.jclouds.vcloud.domain.Catalog>> allCatalogsInOrg) {
this.orgSupplier = orgSupplier;
this.allCatalogsInOrg = allCatalogsInOrg;
}
@Override
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> get() {
public Map<String, Map<String, org.jclouds.vcloud.domain.Catalog>> get() {
return transformValues(
transformValues(orgSupplier.get(), allCatalogsInOrg),
new Function<Iterable<? extends org.jclouds.vcloud.domain.Catalog>, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>() {
transformValues(orgSupplier.get(), allCatalogsInOrg),
new Function<Iterable<org.jclouds.vcloud.domain.Catalog>, Map<String, org.jclouds.vcloud.domain.Catalog>>() {
@Override
public Map<String, ? extends org.jclouds.vcloud.domain.Catalog> apply(
Iterable<? extends org.jclouds.vcloud.domain.Catalog> from) {
return uniqueIndex(from, name);
}
@Override
public Map<String, org.jclouds.vcloud.domain.Catalog> apply(
Iterable<org.jclouds.vcloud.domain.Catalog> from) {
return uniqueIndex(from, name);
}
});
});
}
}
@ -292,50 +291,48 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
@org.jclouds.vcloud.endpoints.Org
@Singleton
protected Supplier<Map<String, ReferenceType>> provideVDCtoORG(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
AtomicReference<AuthorizationException> authException, OrgNameToOrgSupplier supplier) {
AtomicReference<AuthorizationException> authException, OrgNameToOrgSupplier supplier) {
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, ReferenceType>>(
authException, seconds, supplier);
authException, seconds, supplier);
}
@Provides
@Singleton
protected Supplier<Map<URI, ? extends org.jclouds.vcloud.domain.VDC>> provideURIToVDC(
@Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference<AuthorizationException> authException,
URItoVDC supplier) {
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<URI, ? extends org.jclouds.vcloud.domain.VDC>>(
authException, seconds, supplier);
protected Supplier<Map<URI, org.jclouds.vcloud.domain.VDC>> provideURIToVDC(
@Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference<AuthorizationException> authException,
URItoVDC supplier) {
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<URI, org.jclouds.vcloud.domain.VDC>>(
authException, seconds, supplier);
}
@Singleton
public static class URItoVDC implements Supplier<Map<URI, ? extends org.jclouds.vcloud.domain.VDC>> {
private final Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> orgVDCMap;
public static class URItoVDC implements Supplier<Map<URI, org.jclouds.vcloud.domain.VDC>> {
private final Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.VDC>>> orgVDCMap;
@Inject
URItoVDC(Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> orgVDCMap) {
URItoVDC(Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.VDC>>> orgVDCMap) {
this.orgVDCMap = orgVDCMap;
}
@Override
public Map<URI, ? extends org.jclouds.vcloud.domain.VDC> get() {
return uniqueIndex(
concat(transform(
orgVDCMap.get().values(),
new Function<Map<String, ? extends org.jclouds.vcloud.domain.VDC>, Iterable<? extends org.jclouds.vcloud.domain.VDC>>() {
public Map<URI, org.jclouds.vcloud.domain.VDC> get() {
return uniqueIndex(concat(transform(orgVDCMap.get().values(),
new Function<Map<String, org.jclouds.vcloud.domain.VDC>, Iterable<org.jclouds.vcloud.domain.VDC>>() {
@Override
public Iterable<? extends org.jclouds.vcloud.domain.VDC> apply(
Map<String, ? extends org.jclouds.vcloud.domain.VDC> from) {
return from.values();
}
@Override
public Iterable<org.jclouds.vcloud.domain.VDC> apply(
Map<String, org.jclouds.vcloud.domain.VDC> from) {
return from.values();
}
})), new Function<org.jclouds.vcloud.domain.VDC, URI>() {
})), new Function<org.jclouds.vcloud.domain.VDC, URI>() {
@Override
public URI apply(org.jclouds.vcloud.domain.VDC from) {
return from.getHref();
}
@Override
public URI apply(org.jclouds.vcloud.domain.VDC from) {
return from.getHref();
}
});
});
}
}
@ -353,7 +350,8 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
@Singleton
@org.jclouds.vcloud.endpoints.VCloudLogin
protected URI provideAuthenticationURI(VCloudVersionsAsyncClient versionService,
@Named(PROPERTY_API_VERSION) String version) throws InterruptedException, ExecutionException, TimeoutException {
@Named(PROPERTY_API_VERSION) String version) throws InterruptedException, ExecutionException,
TimeoutException {
SortedMap<String, URI> versions = versionService.getSupportedVersions().get(180, TimeUnit.SECONDS);
checkState(versions.size() > 0, "No versions present");
checkState(versions.containsKey(version), "version " + version + " not present in: " + versions);
@ -385,110 +383,108 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
@Provides
@Singleton
protected Org provideOrg(Supplier<Map<String, ? extends Org>> orgSupplier,
@org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) {
protected Org provideOrg(Supplier<Map<String, Org>> orgSupplier,
@org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) {
return orgSupplier.get().get(defaultOrg.getName());
}
@Provides
@Singleton
protected Predicate<URI> successTester(Injector injector,
@Named(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED) long completed) {
@Named(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED) long completed) {
return new RetryablePredicate<URI>(injector.getInstance(TaskSuccess.class), completed);
}
@Provides
@Singleton
protected Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> provideOrgCatalogItemMapSupplierCache(
@Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference<AuthorizationException> authException,
OrgCatalogSupplier supplier) {
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>>(
authException, seconds, supplier);
protected Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.Catalog>>> provideOrgCatalogItemMapSupplierCache(
@Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference<AuthorizationException> authException,
OrgCatalogSupplier supplier) {
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, Map<String, org.jclouds.vcloud.domain.Catalog>>>(
authException, seconds, supplier);
}
@Provides
@Singleton
protected Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> provideOrgVDCSupplierCache(
@Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference<AuthorizationException> authException,
OrgVDCSupplier supplier) {
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>>(
authException, seconds, supplier);
protected Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.VDC>>> provideOrgVDCSupplierCache(
@Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference<AuthorizationException> authException,
OrgVDCSupplier supplier) {
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, Map<String, org.jclouds.vcloud.domain.VDC>>>(
authException, seconds, supplier);
}
@Singleton
public static class OrgVDCSupplier implements
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> {
protected final Supplier<Map<String, ? extends Org>> orgSupplier;
private final Function<Org, Iterable<? extends org.jclouds.vcloud.domain.VDC>> allVDCsInOrg;
public static class OrgVDCSupplier implements Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.VDC>>> {
protected final Supplier<Map<String, Org>> orgSupplier;
private final Function<Org, Iterable<org.jclouds.vcloud.domain.VDC>> allVDCsInOrg;
@Inject
protected OrgVDCSupplier(Supplier<Map<String, ? extends Org>> orgSupplier,
Function<Org, Iterable<? extends org.jclouds.vcloud.domain.VDC>> allVDCsInOrg) {
protected OrgVDCSupplier(Supplier<Map<String, Org>> orgSupplier,
Function<Org, Iterable<org.jclouds.vcloud.domain.VDC>> allVDCsInOrg) {
this.orgSupplier = orgSupplier;
this.allVDCsInOrg = allVDCsInOrg;
}
@Override
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> get() {
return transformValues(
transformValues(orgSupplier.get(), allVDCsInOrg),
new Function<Iterable<? extends org.jclouds.vcloud.domain.VDC>, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>() {
public Map<String, Map<String, org.jclouds.vcloud.domain.VDC>> get() {
return transformValues(transformValues(orgSupplier.get(), allVDCsInOrg),
new Function<Iterable<org.jclouds.vcloud.domain.VDC>, Map<String, org.jclouds.vcloud.domain.VDC>>() {
@Override
public Map<String, ? extends org.jclouds.vcloud.domain.VDC> apply(
Iterable<? extends org.jclouds.vcloud.domain.VDC> from) {
return uniqueIndex(from, name);
}
@Override
public Map<String, org.jclouds.vcloud.domain.VDC> apply(
Iterable<org.jclouds.vcloud.domain.VDC> from) {
return uniqueIndex(from, name);
}
});
});
}
}
@Singleton
public static class OrgCatalogItemSupplier implements
Supplier<Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>> {
protected final Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> catalogSupplier;
protected final Function<org.jclouds.vcloud.domain.Catalog, Iterable<? extends CatalogItem>> allCatalogItemsInCatalog;
Supplier<Map<String, Map<String, Map<String, org.jclouds.vcloud.domain.CatalogItem>>>> {
protected final Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.Catalog>>> catalogSupplier;
protected final Function<org.jclouds.vcloud.domain.Catalog, Iterable<CatalogItem>> allCatalogItemsInCatalog;
@Inject
protected OrgCatalogItemSupplier(
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> catalogSupplier,
Function<org.jclouds.vcloud.domain.Catalog, Iterable<? extends CatalogItem>> allCatalogItemsInCatalog) {
Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.Catalog>>> catalogSupplier,
Function<org.jclouds.vcloud.domain.Catalog, Iterable<CatalogItem>> allCatalogItemsInCatalog) {
this.catalogSupplier = catalogSupplier;
this.allCatalogItemsInCatalog = allCatalogItemsInCatalog;
}
@Override
public Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> get() {
public Map<String, Map<String, Map<String, org.jclouds.vcloud.domain.CatalogItem>>> get() {
return transformValues(
catalogSupplier.get(),
new Function<Map<String, ? extends org.jclouds.vcloud.domain.Catalog>, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>() {
catalogSupplier.get(),
new Function<Map<String, org.jclouds.vcloud.domain.Catalog>, Map<String, Map<String, org.jclouds.vcloud.domain.CatalogItem>>>() {
@Override
public Map<String, Map<String, ? extends CatalogItem>> apply(
Map<String, ? extends org.jclouds.vcloud.domain.Catalog> from) {
return transformValues(
from,
new Function<org.jclouds.vcloud.domain.Catalog, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>() {
@Override
public Map<String, Map<String, CatalogItem>> apply(
Map<String, org.jclouds.vcloud.domain.Catalog> from) {
return transformValues(
from,
new Function<org.jclouds.vcloud.domain.Catalog, Map<String, org.jclouds.vcloud.domain.CatalogItem>>() {
@Override
public Map<String, ? extends CatalogItem> apply(org.jclouds.vcloud.domain.Catalog from) {
return uniqueIndex(filter(allCatalogItemsInCatalog.apply(from), notNull()), name);
}
});
@Override
public Map<String, CatalogItem> apply(org.jclouds.vcloud.domain.Catalog from) {
return uniqueIndex(filter(allCatalogItemsInCatalog.apply(from), notNull()), name);
}
});
}
});
}
});
}
}
@Provides
@Singleton
protected Supplier<Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>> provideOrgCatalogItemSupplierCache(
@Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference<AuthorizationException> authException,
OrgCatalogItemSupplier supplier) {
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>>(
authException, seconds, supplier);
protected Supplier<Map<String, Map<String, Map<String, org.jclouds.vcloud.domain.CatalogItem>>>> provideOrgCatalogItemSupplierCache(
@Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference<AuthorizationException> authException,
OrgCatalogItemSupplier supplier) {
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, Map<String, Map<String, org.jclouds.vcloud.domain.CatalogItem>>>>(
authException, seconds, supplier);
}
@Override

View File

@ -35,7 +35,7 @@ public class InstantiateVAppTemplateParams {
protected final VirtualSystemSettingData virtualSystem;
protected final Set<ResourceAllocationSettingData> resourceAllocations = Sets.newLinkedHashSet();
public InstantiateVAppTemplateParams(String info, VirtualSystemSettingData virtualSystem, Iterable<? extends ResourceAllocationSettingData> resourceAllocations) {
public InstantiateVAppTemplateParams(String info, VirtualSystemSettingData virtualSystem, Iterable<ResourceAllocationSettingData> resourceAllocations) {
this.info = info;
this.virtualSystem = virtualSystem;
Iterables.addAll(this.resourceAllocations, resourceAllocations);
@ -49,7 +49,7 @@ public class InstantiateVAppTemplateParams {
return virtualSystem;
}
public Set<? extends ResourceAllocationSettingData> getResourceAllocationSettingDatas() {
public Set<ResourceAllocationSettingData> getResourceAllocationSettingDatas() {
return resourceAllocations;
}

View File

@ -66,7 +66,7 @@ public class NetworkConnectionSection {
return this;
}
public Builder connections(Iterable<? extends NetworkConnection> connections) {
public Builder connections(Iterable<NetworkConnection> connections) {
this.connections = ImmutableSet.copyOf(checkNotNull(connections, "connections"));
return this;
}
@ -140,7 +140,7 @@ public class NetworkConnectionSection {
/**
*
*/
public Set<? extends NetworkConnection> getConnections() {
public Set<NetworkConnection> getConnections() {
return connections;
}

View File

@ -75,6 +75,6 @@ public interface VApp extends ReferenceType {
*
* @since vcloud api 1.0
*/
Set<? extends Vm> getChildren();
Set<Vm> getChildren();
}

View File

@ -87,7 +87,7 @@ public interface VAppTemplate extends ReferenceType {
*
* @since vcloud api 1.0
*/
Set<? extends Vm> getChildren();
Set<Vm> getChildren();
/**
* description of the predefined vApp internal networks in this template

View File

@ -53,7 +53,7 @@ public class VAppImpl extends ReferenceTypeImpl implements VApp {
private final Set<Vm> children = Sets.newLinkedHashSet();
public VAppImpl(String name, String type, URI id, Status status, ReferenceType vdc, @Nullable String description,
Iterable<Task> tasks, boolean ovfDescriptorUploaded, Iterable<? extends Vm> children) {
Iterable<Task> tasks, boolean ovfDescriptorUploaded, Iterable<Vm> children) {
super(name, type, id);
this.status = checkNotNull(status, "status");
this.vdc = vdc;// TODO: once <1.0 is killed check not null
@ -107,7 +107,7 @@ public class VAppImpl extends ReferenceTypeImpl implements VApp {
* {@inheritDoc}
*/
@Override
public Set<? extends Vm> getChildren() {
public Set<Vm> getChildren() {
return children;
}

View File

@ -58,7 +58,7 @@ public class VAppTemplateImpl extends ReferenceTypeImpl implements VAppTemplate
public VAppTemplateImpl(String name, String type, URI id, Status status, ReferenceType vdc,
@Nullable String description, Iterable<Task> tasks, boolean ovfDescriptorUploaded,
@Nullable String vAppScopedLocalId, Iterable<? extends Vm> children,
@Nullable String vAppScopedLocalId, Iterable<Vm> children,
@Nullable VCloudNetworkSection networkSection) {
super(name, type, id);
this.status = checkNotNull(status, "status");
@ -123,7 +123,7 @@ public class VAppTemplateImpl extends ReferenceTypeImpl implements VAppTemplate
* {@inheritDoc}
*/
@Override
public Set<? extends Vm> getChildren() {
public Set<Vm> getChildren() {
return children;
}

View File

@ -37,7 +37,7 @@ public class FirewallService {
List<FirewallRule> firewallRules = Lists.newArrayList();
public FirewallService(boolean enabled, Iterable<? extends FirewallRule> firewallRules) {
public FirewallService(boolean enabled, Iterable<FirewallRule> firewallRules) {
this.enabled = enabled;
Iterables.addAll(this.firewallRules, checkNotNull(firewallRules, "firewallRules"));
}
@ -47,7 +47,7 @@ public class FirewallService {
*
* @since vcloud api 0.8
*/
public List<? extends FirewallRule> getFirewallRules() {
public List<FirewallRule> getFirewallRules() {
return firewallRules;
}

View File

@ -43,7 +43,7 @@ public class NatService {
private final List<NatRule> natRules = Lists.newArrayList();
public NatService(boolean enabled, @Nullable NatType type, @Nullable NatPolicy policy,
Iterable<? extends NatRule> natRules) {
Iterable<NatRule> natRules) {
this.enabled = enabled;
this.type = type;
this.policy = policy;
@ -55,7 +55,7 @@ public class NatService {
*
* @since vcloud api 0.8
*/
public List<? extends NatRule> getNatRules() {
public List<NatRule> getNatRules() {
return natRules;
}

View File

@ -67,7 +67,7 @@ public interface CatalogAsyncClient {
@XMLResponseParser(CatalogHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
@Consumes(CATALOG_XML)
ListenableFuture<? extends Catalog> getCatalog(@EndpointParam URI catalogId);
ListenableFuture<Catalog> getCatalog(@EndpointParam URI catalogId);
/**
* @see CatalogClient#findCatalogInOrgNamed
@ -76,7 +76,7 @@ public interface CatalogAsyncClient {
@XMLResponseParser(CatalogHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
@Consumes(CATALOG_XML)
ListenableFuture<? extends Catalog> findCatalogInOrgNamed(
ListenableFuture<Catalog> findCatalogInOrgNamed(
@Nullable @EndpointParam(parser = OrgNameAndCatalogNameToEndpoint.class) String orgName,
@Nullable @EndpointParam(parser = OrgNameAndCatalogNameToEndpoint.class) String catalogName);
@ -87,7 +87,7 @@ public interface CatalogAsyncClient {
@Consumes(CATALOGITEM_XML)
@XMLResponseParser(CatalogItemHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends CatalogItem> getCatalogItem(@EndpointParam URI catalogItem);
ListenableFuture<CatalogItem> getCatalogItem(@EndpointParam URI catalogItem);
/**
* @see CatalogClient#getCatalogItemInOrg
@ -96,7 +96,7 @@ public interface CatalogAsyncClient {
@Consumes(CATALOGITEM_XML)
@XMLResponseParser(CatalogItemHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends CatalogItem> findCatalogItemInOrgCatalogNamed(
ListenableFuture<CatalogItem> findCatalogItemInOrgCatalogNamed(
@Nullable @EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String orgName,
@Nullable @EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String catalogName,
@EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String itemName);
@ -110,7 +110,7 @@ public interface CatalogAsyncClient {
@Produces(CATALOGITEM_XML)
@MapBinder(BindCatalogItemToXmlPayload.class)
@XMLResponseParser(CatalogItemHandler.class)
ListenableFuture<? extends CatalogItem> addVAppTemplateOrMediaImageToCatalogAndNameItem(@PayloadParam("Entity") URI entity,
ListenableFuture<CatalogItem> addVAppTemplateOrMediaImageToCatalogAndNameItem(@PayloadParam("Entity") URI entity,
@EndpointParam URI catalog, @PayloadParam("name") String name, CatalogItemOptions... options);

View File

@ -54,7 +54,7 @@ public interface NetworkAsyncClient {
@Consumes(NETWORK_XML)
@XMLResponseParser(OrgNetworkHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends OrgNetwork> findNetworkInOrgVDCNamed(
ListenableFuture<OrgNetwork> findNetworkInOrgVDCNamed(
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String orgName,
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String catalogName,
@EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String networkName);
@ -66,6 +66,6 @@ public interface NetworkAsyncClient {
@Consumes(NETWORK_XML)
@XMLResponseParser(OrgNetworkHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends OrgNetwork> getNetwork(@EndpointParam URI network);
ListenableFuture<OrgNetwork> getNetwork(@EndpointParam URI network);
}

View File

@ -70,7 +70,7 @@ public interface OrgAsyncClient {
@XMLResponseParser(OrgHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
@Consumes(ORG_XML)
ListenableFuture<? extends Org> getOrg(@EndpointParam URI orgId);
ListenableFuture<Org> getOrg(@EndpointParam URI orgId);
/**
* @see OrgClient#getOrgNamed
@ -79,6 +79,6 @@ public interface OrgAsyncClient {
@XMLResponseParser(OrgHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
@Consumes(ORG_XML)
ListenableFuture<? extends Org> findOrgNamed(
ListenableFuture<Org> findOrgNamed(
@Nullable @EndpointParam(parser = OrgNameToEndpoint.class) String orgName);
}

View File

@ -59,7 +59,7 @@ public interface TaskAsyncClient {
@Consumes(TASKSLIST_XML)
@XMLResponseParser(TasksListHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends TasksList> getTasksList(@EndpointParam URI tasksListId);
ListenableFuture<TasksList> getTasksList(@EndpointParam URI tasksListId);
/**
* @see TaskClient#findTasksListInOrgNamed
@ -68,7 +68,7 @@ public interface TaskAsyncClient {
@Consumes(TASKSLIST_XML)
@XMLResponseParser(TasksListHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends TasksList> findTasksListInOrgNamed(
ListenableFuture<TasksList> findTasksListInOrgNamed(
@Nullable @EndpointParam(parser = OrgNameToTasksListEndpoint.class) String orgName);
/**
@ -78,7 +78,7 @@ public interface TaskAsyncClient {
@Consumes(TASK_XML)
@XMLResponseParser(TaskHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends Task> getTask(@EndpointParam URI taskId);
ListenableFuture<Task> getTask(@EndpointParam URI taskId);
/**
* @see TaskClient#cancelTask

View File

@ -75,7 +75,7 @@ public interface VAppAsyncClient {
@Consumes(TASK_XML)
@XMLResponseParser(TaskHandler.class)
@MapBinder(BindCloneVAppParamsToXmlPayload.class)
ListenableFuture<? extends Task> copyVAppToVDCAndName(@PayloadParam("Source") URI sourceVApp,
ListenableFuture<Task> copyVAppToVDCAndName(@PayloadParam("Source") URI sourceVApp,
@EndpointParam URI vdc, @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String newName,
CloneVAppOptions... options);
@ -89,7 +89,7 @@ public interface VAppAsyncClient {
@XMLResponseParser(TaskHandler.class)
@PayloadParams(keys = "IsSourceDelete", values = "true")
@MapBinder(BindCloneVAppParamsToXmlPayload.class)
ListenableFuture<? extends Task> moveVAppToVDCAndRename(@PayloadParam("Source") URI sourceVApp,
ListenableFuture<Task> moveVAppToVDCAndRename(@PayloadParam("Source") URI sourceVApp,
@EndpointParam URI vdc, @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String newName,
CloneVAppOptions... options);
@ -100,7 +100,7 @@ public interface VAppAsyncClient {
@Consumes(VAPP_XML)
@XMLResponseParser(VAppHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends VApp> findVAppInOrgVDCNamed(
ListenableFuture<VApp> findVAppInOrgVDCNamed(
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String orgName,
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String catalogName,
@EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String vAppName);
@ -112,7 +112,7 @@ public interface VAppAsyncClient {
@Consumes(VAPP_XML)
@XMLResponseParser(VAppHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends VApp> getVApp(@EndpointParam URI href);
ListenableFuture<VApp> getVApp(@EndpointParam URI href);
/**
* @see VAppClient#deployVApp
@ -123,7 +123,7 @@ public interface VAppAsyncClient {
@Path("/action/deploy")
@MapBinder(BindDeployVAppParamsToXmlPayload.class)
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> deployVApp(@EndpointParam URI href);
ListenableFuture<Task> deployVApp(@EndpointParam URI href);
/**
* @see VAppClient#deployAndPowerOnVApp
@ -135,7 +135,7 @@ public interface VAppAsyncClient {
@MapBinder(BindDeployVAppParamsToXmlPayload.class)
@PayloadParams(keys = "powerOn", values = "true")
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> deployAndPowerOnVApp(@EndpointParam URI href);
ListenableFuture<Task> deployAndPowerOnVApp(@EndpointParam URI href);
/**
* @see VAppClient#undeployVApp
@ -146,7 +146,7 @@ public interface VAppAsyncClient {
@Path("/action/undeploy")
@MapBinder(BindUndeployVAppParamsToXmlPayload.class)
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> undeployVApp(@EndpointParam URI href);
ListenableFuture<Task> undeployVApp(@EndpointParam URI href);
/**
* @see VAppClient#undeployAndSaveStateOfVApp
@ -158,7 +158,7 @@ public interface VAppAsyncClient {
@MapBinder(BindUndeployVAppParamsToXmlPayload.class)
@PayloadParams(keys = "saveState", values = "true")
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> undeployAndSaveStateOfVApp(@EndpointParam URI href);
ListenableFuture<Task> undeployAndSaveStateOfVApp(@EndpointParam URI href);
/**
* @see VAppClient#powerOnVApp
@ -167,7 +167,7 @@ public interface VAppAsyncClient {
@Consumes(TASK_XML)
@Path("/power/action/powerOn")
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> powerOnVApp(@EndpointParam URI href);
ListenableFuture<Task> powerOnVApp(@EndpointParam URI href);
/**
* @see VAppClient#powerOffVApp
@ -176,7 +176,7 @@ public interface VAppAsyncClient {
@Consumes(TASK_XML)
@Path("/power/action/powerOff")
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> powerOffVApp(@EndpointParam URI href);
ListenableFuture<Task> powerOffVApp(@EndpointParam URI href);
/**
* @see VAppClient#shutdownVApp
@ -192,7 +192,7 @@ public interface VAppAsyncClient {
@Consumes(TASK_XML)
@Path("/power/action/reset")
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> resetVApp(@EndpointParam URI href);
ListenableFuture<Task> resetVApp(@EndpointParam URI href);
/**
* @see VAppClient#rebootVApp
@ -208,7 +208,7 @@ public interface VAppAsyncClient {
@Consumes(TASK_XML)
@Path("/power/action/suspend")
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> suspendVApp(@EndpointParam URI href);
ListenableFuture<Task> suspendVApp(@EndpointParam URI href);
/**
* @see VAppClient#deleteVApp
@ -217,6 +217,6 @@ public interface VAppAsyncClient {
@Consumes(TASK_XML)
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> deleteVApp(@EndpointParam URI href);
ListenableFuture<Task> deleteVApp(@EndpointParam URI href);
}

View File

@ -81,7 +81,7 @@ public interface VAppTemplateAsyncClient {
@Consumes(VAPP_XML)
@XMLResponseParser(VAppHandler.class)
@MapBinder(BindInstantiateVAppTemplateParamsToXmlPayload.class)
ListenableFuture<? extends VApp> createVAppInVDCByInstantiatingTemplate(
ListenableFuture<VApp> createVAppInVDCByInstantiatingTemplate(
@PayloadParam("name") @ParamValidators(DnsNameValidator.class) String appName, @EndpointParam URI vdc,
@PayloadParam("template") URI template, InstantiateVAppTemplateOptions... options);
@ -93,7 +93,7 @@ public interface VAppTemplateAsyncClient {
@Path("/ovf")
@XMLResponseParser(EnvelopeHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends Envelope> getOvfEnvelopeForVAppTemplate(@EndpointParam URI href);
ListenableFuture<Envelope> getOvfEnvelopeForVAppTemplate(@EndpointParam URI href);
/**
* @see VAppTemplateClient#captureVAppAsTemplateInVDC
@ -104,7 +104,7 @@ public interface VAppTemplateAsyncClient {
@Consumes(VAPPTEMPLATE_XML)
@XMLResponseParser(VAppTemplateHandler.class)
@MapBinder(BindCaptureVAppParamsToXmlPayload.class)
ListenableFuture<? extends VAppTemplate> captureVAppAsTemplateInVDC(@PayloadParam("vApp") URI toCapture,
ListenableFuture<VAppTemplate> captureVAppAsTemplateInVDC(@PayloadParam("vApp") URI toCapture,
@PayloadParam("templateName") @ParamValidators(DnsNameValidator.class) String templateName,
@EndpointParam URI vdc, CaptureVAppOptions... options);
@ -117,7 +117,7 @@ public interface VAppTemplateAsyncClient {
@Consumes(TASK_XML)
@XMLResponseParser(TaskHandler.class)
@MapBinder(BindCloneVAppTemplateParamsToXmlPayload.class)
ListenableFuture<? extends Task> copyVAppTemplateToVDCAndName(@PayloadParam("Source") URI sourceVAppTemplate,
ListenableFuture<Task> copyVAppTemplateToVDCAndName(@PayloadParam("Source") URI sourceVAppTemplate,
@EndpointParam URI vdc, @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String newName,
CloneVAppTemplateOptions... options);
@ -131,7 +131,7 @@ public interface VAppTemplateAsyncClient {
@XMLResponseParser(TaskHandler.class)
@PayloadParams(keys = "IsSourceDelete", values = "true")
@MapBinder(BindCloneVAppTemplateParamsToXmlPayload.class)
ListenableFuture<? extends Task> moveVAppTemplateToVDCAndRename(@PayloadParam("Source") URI toClone,
ListenableFuture<Task> moveVAppTemplateToVDCAndRename(@PayloadParam("Source") URI toClone,
@EndpointParam URI vdc, @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String newName,
CloneVAppTemplateOptions... options);
@ -142,7 +142,7 @@ public interface VAppTemplateAsyncClient {
@Consumes(VAPPTEMPLATE_XML)
@XMLResponseParser(VAppTemplateHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends VAppTemplate> findVAppTemplateInOrgCatalogNamed(
ListenableFuture<VAppTemplate> findVAppTemplateInOrgCatalogNamed(
@Nullable @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String orgName,
@Nullable @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String catalogName,
@EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String itemName);
@ -154,7 +154,7 @@ public interface VAppTemplateAsyncClient {
@Consumes(VAPPTEMPLATE_XML)
@XMLResponseParser(VAppTemplateHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends VAppTemplate> getVAppTemplate(@EndpointParam URI vAppTemplate);
ListenableFuture<VAppTemplate> getVAppTemplate(@EndpointParam URI vAppTemplate);
/**
* @see VAppTemplateClient#deleteVAppTemplate
@ -163,6 +163,6 @@ public interface VAppTemplateAsyncClient {
@Consumes(TASK_XML)
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> deleteVAppTemplate(@EndpointParam URI href);
ListenableFuture<Task> deleteVAppTemplate(@EndpointParam URI href);
}

View File

@ -54,7 +54,7 @@ public interface VDCAsyncClient {
@XMLResponseParser(VDCHandler.class)
@Consumes(VDC_XML)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends VDC> getVDC(@EndpointParam URI vdc);
ListenableFuture<VDC> getVDC(@EndpointParam URI vdc);
/**
* @see VDCClient#findVDCInOrgNamed(String, String)
@ -63,7 +63,7 @@ public interface VDCAsyncClient {
@XMLResponseParser(VDCHandler.class)
@Consumes(VDC_XML)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends VDC> findVDCInOrgNamed(
ListenableFuture<VDC> findVDCInOrgNamed(
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String orgName,
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String vdcName);
}

View File

@ -76,7 +76,7 @@ public interface VmAsyncClient {
@Consumes(VM_XML)
@XMLResponseParser(VmHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends Vm> getVm(@EndpointParam URI href);
ListenableFuture<Vm> getVm(@EndpointParam URI href);
/**
* @see VmClient#deployVm
@ -87,7 +87,7 @@ public interface VmAsyncClient {
@Path("/action/deploy")
@MapBinder(BindDeployVAppParamsToXmlPayload.class)
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> deployVm(@EndpointParam URI href);
ListenableFuture<Task> deployVm(@EndpointParam URI href);
/**
* @see VmClient#deployAndPowerOnVm
@ -99,7 +99,7 @@ public interface VmAsyncClient {
@MapBinder(BindDeployVAppParamsToXmlPayload.class)
@PayloadParams(keys = "powerOn", values = "true")
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> deployAndPowerOnVm(@EndpointParam URI href);
ListenableFuture<Task> deployAndPowerOnVm(@EndpointParam URI href);
/**
* @see VmClient#undeployVm
@ -110,7 +110,7 @@ public interface VmAsyncClient {
@Path("/action/undeploy")
@MapBinder(BindUndeployVAppParamsToXmlPayload.class)
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> undeployVm(@EndpointParam URI href);
ListenableFuture<Task> undeployVm(@EndpointParam URI href);
/**
* @see VmClient#undeployAndSaveStateOfVm
@ -122,7 +122,7 @@ public interface VmAsyncClient {
@MapBinder(BindUndeployVAppParamsToXmlPayload.class)
@PayloadParams(keys = "saveState", values = "true")
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> undeployAndSaveStateOfVm(@EndpointParam URI href);
ListenableFuture<Task> undeployAndSaveStateOfVm(@EndpointParam URI href);
/**
* @see VmClient#powerOnVm
@ -131,7 +131,7 @@ public interface VmAsyncClient {
@Consumes(TASK_XML)
@Path("/power/action/powerOn")
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> powerOnVm(@EndpointParam URI href);
ListenableFuture<Task> powerOnVm(@EndpointParam URI href);
/**
* @see VmClient#powerOffVm
@ -140,7 +140,7 @@ public interface VmAsyncClient {
@Consumes(TASK_XML)
@Path("/power/action/powerOff")
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> powerOffVm(@EndpointParam URI href);
ListenableFuture<Task> powerOffVm(@EndpointParam URI href);
/**
* @see VmClient#shutdownVm
@ -156,7 +156,7 @@ public interface VmAsyncClient {
@Consumes(TASK_XML)
@Path("/power/action/reset")
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> resetVm(@EndpointParam URI href);
ListenableFuture<Task> resetVm(@EndpointParam URI href);
/**
* @see VmClient#rebootVm
@ -172,7 +172,7 @@ public interface VmAsyncClient {
@Consumes(TASK_XML)
@Path("/power/action/suspend")
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> suspendVm(@EndpointParam URI href);
ListenableFuture<Task> suspendVm(@EndpointParam URI href);
/**
* @see VmClient#updateCPUCountOfVm
@ -182,7 +182,7 @@ public interface VmAsyncClient {
@Produces(RASDITEM_XML)
@Path("/virtualHardwareSection/cpu")
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> updateCPUCountOfVm(@BinderParam(BindCPUCountToXmlPayload.class) int cpuCount,
ListenableFuture<Task> updateCPUCountOfVm(@BinderParam(BindCPUCountToXmlPayload.class) int cpuCount,
@EndpointParam URI href);
/**
@ -193,7 +193,7 @@ public interface VmAsyncClient {
@Produces(RASDITEM_XML)
@Path("/virtualHardwareSection/memory")
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> updateMemoryMBOfVm(@BinderParam(BindMemoryToXmlPayload.class) int memoryInMB,
ListenableFuture<Task> updateMemoryMBOfVm(@BinderParam(BindMemoryToXmlPayload.class) int memoryInMB,
@EndpointParam URI href);
/**
@ -204,7 +204,7 @@ public interface VmAsyncClient {
@Produces(GUESTCUSTOMIZATIONSECTION_XML)
@Path("/guestCustomizationSection")
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> updateGuestCustomizationOfVm(
ListenableFuture<Task> updateGuestCustomizationOfVm(
@BinderParam(BindGuestCustomizationSectionToXmlPayload.class) GuestCustomizationSection guestCustomizationSection,
@EndpointParam URI href);
@ -216,7 +216,7 @@ public interface VmAsyncClient {
@Produces(NETWORKCONNECTIONSECTION_XML)
@Path("/networkConnectionSection")
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> updateNetworkConnectionOfVm(
ListenableFuture<Task> updateNetworkConnectionOfVm(
@BinderParam(BindNetworkConnectionSectionToXmlPayload.class) NetworkConnectionSection networkConnectionSection,
@EndpointParam URI href);

View File

@ -44,7 +44,7 @@ import com.google.common.base.Predicate;
* @author Adrian Cole
*/
@Singleton
public class AllCatalogItemsInCatalog implements Function<Catalog, Iterable<? extends CatalogItem>> {
public class AllCatalogItemsInCatalog implements Function<Catalog, Iterable<CatalogItem>> {
@Resource
public Logger logger = Logger.NULL;
@ -52,14 +52,13 @@ public class AllCatalogItemsInCatalog implements Function<Catalog, Iterable<? ex
private final ExecutorService executor;
@Inject
AllCatalogItemsInCatalog(VCloudAsyncClient aclient,
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
AllCatalogItemsInCatalog(VCloudAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
this.aclient = aclient;
this.executor = executor;
}
@Override
public Iterable<? extends CatalogItem> apply(Catalog from) {
public Iterable<CatalogItem> apply(Catalog from) {
Iterable<CatalogItem> catalogItems = transformParallel(filter(from.values(), new Predicate<ReferenceType>() {
@ -70,10 +69,9 @@ public class AllCatalogItemsInCatalog implements Function<Catalog, Iterable<? ex
}), new Function<ReferenceType, Future<CatalogItem>>() {
@SuppressWarnings("unchecked")
@Override
public Future<CatalogItem> apply(ReferenceType from) {
return (Future<CatalogItem>) aclient.getCatalogClient().getCatalogItem(from.getHref());
return aclient.getCatalogClient().getCatalogItem(from.getHref());
}
}, executor, null, logger, "catalogItems in " + from.getHref());

View File

@ -34,28 +34,28 @@ import com.google.common.collect.Iterables;
* @author Adrian Cole
*/
@Singleton
public class AllCatalogItemsInOrg implements Function<Org, Iterable<? extends CatalogItem>> {
public class AllCatalogItemsInOrg implements Function<Org, Iterable<CatalogItem>> {
@Resource
public Logger logger = Logger.NULL;
private final Function<Org, Iterable<? extends Catalog>> allCatalogsInOrg;
private final Function<Org, Iterable<Catalog>> allCatalogsInOrg;
private final Function<Catalog, Iterable<? extends CatalogItem>> allCatalogItemsInCatalog;
private final Function<Catalog, Iterable<CatalogItem>> allCatalogItemsInCatalog;
@Inject
AllCatalogItemsInOrg(Function<Org, Iterable<? extends Catalog>> allCatalogsInOrg,
Function<Catalog, Iterable<? extends CatalogItem>> allCatalogItemsInCatalog) {
AllCatalogItemsInOrg(Function<Org, Iterable<Catalog>> allCatalogsInOrg,
Function<Catalog, Iterable<CatalogItem>> allCatalogItemsInCatalog) {
this.allCatalogsInOrg = allCatalogsInOrg;
this.allCatalogItemsInCatalog = allCatalogItemsInCatalog;
}
@Override
public Iterable<? extends CatalogItem> apply(Org from) {
public Iterable<CatalogItem> apply(Org from) {
return Iterables.concat(Iterables.transform(allCatalogsInOrg.apply(from),
new Function<Catalog, Iterable<? extends CatalogItem>>() {
new Function<Catalog, Iterable<CatalogItem>>() {
@Override
public Iterable<? extends CatalogItem> apply(Catalog from) {
public Iterable<CatalogItem> apply(Catalog from) {
return allCatalogItemsInCatalog.apply(from);
}

View File

@ -41,7 +41,7 @@ import com.google.common.base.Function;
* @author Adrian Cole
*/
@Singleton
public class AllCatalogsInOrg implements Function<Org, Iterable<? extends Catalog>> {
public class AllCatalogsInOrg implements Function<Org, Iterable<Catalog>> {
@Resource
public Logger logger = Logger.NULL;
@ -55,10 +55,9 @@ public class AllCatalogsInOrg implements Function<Org, Iterable<? extends Catalo
}
@Override
public Iterable<? extends Catalog> apply(final Org org) {
public Iterable<Catalog> apply(final Org org) {
Iterable<Catalog> catalogs = transformParallel(org.getCatalogs().values(),
new Function<ReferenceType, Future<Catalog>>() {
@SuppressWarnings("unchecked")
@Override
public Future<Catalog> apply(ReferenceType from) {
return (Future<Catalog>) aclient.getCatalogClient().getCatalog(from.getHref());

View File

@ -33,6 +33,7 @@ import org.jclouds.logging.Logger;
import org.jclouds.vcloud.VCloudAsyncClient;
import org.jclouds.vcloud.domain.Org;
import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.domain.VDC;
import com.google.common.base.Function;
@ -40,7 +41,7 @@ import com.google.common.base.Function;
* @author Adrian Cole
*/
@Singleton
public class AllVDCsInOrg implements Function<Org, Iterable<? extends org.jclouds.vcloud.domain.VDC>> {
public class AllVDCsInOrg implements Function<Org, Iterable<org.jclouds.vcloud.domain.VDC>> {
@Resource
public Logger logger = Logger.NULL;
@ -54,14 +55,13 @@ public class AllVDCsInOrg implements Function<Org, Iterable<? extends org.jcloud
}
@Override
public Iterable<? extends org.jclouds.vcloud.domain.VDC> apply(final Org org) {
public Iterable<VDC> apply(final Org org) {
Iterable<org.jclouds.vcloud.domain.VDC> catalogItems = transformParallel(org.getVDCs().values(),
Iterable<VDC> catalogItems = transformParallel(org.getVDCs().values(),
new Function<ReferenceType, Future<org.jclouds.vcloud.domain.VDC>>() {
@SuppressWarnings("unchecked")
@Override
public Future<org.jclouds.vcloud.domain.VDC> apply(ReferenceType from) {
return (Future<org.jclouds.vcloud.domain.VDC>) aclient.getVDCClient().getVDC(from.getHref());
public Future<VDC> apply(ReferenceType from) {
return aclient.getVDCClient().getVDC(from.getHref());
}
}, executor, null, logger, "vdcs in org " + org.getName());

View File

@ -41,12 +41,12 @@ import com.google.common.collect.Iterables;
*/
@Singleton
public class OrgNameAndCatalogNameToEndpoint implements Function<Object, URI> {
private final Supplier<Map<String, ? extends Org>> orgMap;
private final Supplier<Map<String, Org>> orgMap;
private final ReferenceType defaultOrg;
private final ReferenceType defaultCatalog;
@Inject
public OrgNameAndCatalogNameToEndpoint(Supplier<Map<String, ? extends Org>> orgMap,
public OrgNameAndCatalogNameToEndpoint(Supplier<Map<String, Org>> orgMap,
@org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg, @Catalog ReferenceType defaultCatalog) {
this.orgMap = orgMap;
this.defaultOrg = defaultOrg;

View File

@ -41,12 +41,12 @@ import com.google.common.collect.Iterables;
*/
@Singleton
public class OrgNameAndVDCNameToEndpoint implements Function<Object, URI> {
private final Supplier<Map<String, ? extends Org>> orgNameToVDCEndpoint;
private final Supplier<Map<String, Org>> orgNameToVDCEndpoint;
private final ReferenceType defaultOrg;
private final ReferenceType defaultVDC;
@Inject
public OrgNameAndVDCNameToEndpoint(Supplier<Map<String, ? extends Org>> orgNameToVDCEndpoint,
public OrgNameAndVDCNameToEndpoint(Supplier<Map<String, Org>> orgNameToVDCEndpoint,
@org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg, @VDC ReferenceType defaultVDC) {
this.orgNameToVDCEndpoint = orgNameToVDCEndpoint;
this.defaultOrg = defaultOrg;

View File

@ -41,13 +41,13 @@ import com.google.common.collect.Iterables;
*/
@Singleton
public class OrgNameCatalogNameItemNameToEndpoint implements Function<Object, URI> {
private final Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> orgCatalogMap;
private final Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.Catalog>>> orgCatalogMap;
private final ReferenceType defaultOrg;
private final ReferenceType defaultCatalog;
@Inject
public OrgNameCatalogNameItemNameToEndpoint(
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> orgCatalogMap,
Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.Catalog>>> orgCatalogMap,
@Org ReferenceType defaultOrg, @Catalog ReferenceType defaultCatalog) {
this.orgCatalogMap = orgCatalogMap;
this.defaultOrg = defaultOrg;
@ -65,7 +65,7 @@ public class OrgNameCatalogNameItemNameToEndpoint implements Function<Object, UR
if (catalog == null)
catalog = defaultCatalog.getName();
try {
Map<String, ? extends org.jclouds.vcloud.domain.Catalog> catalogs = checkNotNull(orgCatalogMap.get().get(org));
Map<String, org.jclouds.vcloud.domain.Catalog> catalogs = checkNotNull(orgCatalogMap.get().get(org));
return catalogs.get(catalog).get(catalogItem).getHref();
} catch (NullPointerException e) {
throw new NoSuchElementException(org + "/" + catalog + "/" + catalogItem + " not found in "

View File

@ -42,13 +42,13 @@ import com.google.common.collect.Iterables;
*/
@Singleton
public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements Function<Object, URI> {
private final Supplier<Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>> orgCatalogItemMap;
private final Supplier<Map<String, Map<String, Map<String, CatalogItem>>>> orgCatalogItemMap;
private final ReferenceType defaultOrg;
private final ReferenceType defaultCatalog;
@Inject
public OrgNameCatalogNameVAppTemplateNameToEndpoint(
Supplier<Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>> orgCatalogItemMap,
Supplier<Map<String, Map<String, Map<String, CatalogItem>>>> orgCatalogItemMap,
@Org ReferenceType defaultOrg, @Catalog ReferenceType defaultCatalog) {
this.orgCatalogItemMap = orgCatalogItemMap;
this.defaultOrg = defaultOrg;
@ -65,15 +65,15 @@ public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements Function<Ob
org = defaultOrg.getName();
if (catalog == null)
catalog = defaultCatalog.getName();
Map<String, Map<String, Map<String, ? extends CatalogItem>>> orgCatalogItemMap = this.orgCatalogItemMap.get();
Map<String, Map<String, Map<String, CatalogItem>>> orgCatalogItemMap = this.orgCatalogItemMap.get();
if (!orgCatalogItemMap.containsKey(org))
throw new NoSuchElementException("org: " + org + " not found in " + orgCatalogItemMap.keySet());
Map<String, Map<String, ? extends CatalogItem>> catalogs = orgCatalogItemMap.get(org);
Map<String, Map<String, CatalogItem>> catalogs = orgCatalogItemMap.get(org);
if (!catalogs.containsKey(catalog))
throw new NoSuchElementException("catalog: " + org + "/" + catalog + " not found in " + catalogs.keySet());
Map<String, ? extends CatalogItem> catalogMap = catalogs.get(catalog);
Map<String, CatalogItem> catalogMap = catalogs.get(catalog);
if (!catalogMap.containsKey(catalogItem))
throw new NoSuchElementException("item: " + org + "/" + catalog + "/" + catalogItem + " not found in "

View File

@ -40,11 +40,11 @@ import com.google.common.base.Supplier;
*/
@Singleton
public class OrgNameToTasksListEndpoint implements Function<Object, URI> {
private final Supplier<Map<String, ? extends Org>> orgMap;
private final Supplier<Map<String, Org>> orgMap;
private final ReferenceType defaultTasksList;
@Inject
public OrgNameToTasksListEndpoint(Supplier<Map<String, ? extends Org>> orgMap,
public OrgNameToTasksListEndpoint(Supplier<Map<String, Org>> orgMap,
@TasksList ReferenceType defaultTasksList) {
this.orgMap = orgMap;
this.defaultTasksList = defaultTasksList;

View File

@ -39,7 +39,7 @@ import com.google.common.base.Supplier;
public class OrgNameVDCNameNetworkNameToEndpoint extends OrgNameVDCNameResourceNameToEndpoint {
@Inject
public OrgNameVDCNameNetworkNameToEndpoint(
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> orgVDCMap,
Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.VDC>>> orgVDCMap,
@Org ReferenceType defaultOrg, @VDC ReferenceType defaultVDC) {
super(orgVDCMap, defaultOrg, defaultVDC);
}

View File

@ -39,7 +39,7 @@ import com.google.common.base.Supplier;
public class OrgNameVDCNameResourceEntityNameToEndpoint extends OrgNameVDCNameResourceNameToEndpoint {
@Inject
public OrgNameVDCNameResourceEntityNameToEndpoint(
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> orgVDCMap,
Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.VDC>>> orgVDCMap,
@Org ReferenceType defaultOrg, @VDC ReferenceType defaultVDC) {
super(orgVDCMap, defaultOrg, defaultVDC);
}

View File

@ -40,13 +40,13 @@ import com.google.common.collect.Iterables;
*/
public abstract class OrgNameVDCNameResourceNameToEndpoint implements Function<Object, URI>{
protected final Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> orgVDCMap;
protected final Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.VDC>>> orgVDCMap;
protected final ReferenceType defaultOrg;
protected final ReferenceType defaultVDC;
@Inject
public OrgNameVDCNameResourceNameToEndpoint(
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> orgVDCMap,
Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.VDC>>> orgVDCMap,
@Org ReferenceType defaultOrg, @org.jclouds.vcloud.endpoints.VDC ReferenceType defaultVDC) {
this.orgVDCMap = orgVDCMap;
this.defaultOrg = defaultOrg;
@ -63,9 +63,9 @@ public abstract class OrgNameVDCNameResourceNameToEndpoint implements Function<
org = defaultOrg.getName();
if (vDC == null)
vDC = defaultVDC.getName();
Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> orgToVDCs = orgVDCMap.get();
Map<String, Map<String, org.jclouds.vcloud.domain.VDC>> orgToVDCs = orgVDCMap.get();
checkState(orgToVDCs != null, "could not get map of org name to vdcs!");
Map<String, ? extends org.jclouds.vcloud.domain.VDC> vDCs = orgToVDCs.get(org);
Map<String, org.jclouds.vcloud.domain.VDC> vDCs = orgToVDCs.get(org);
if (vDCs == null)
throw new NoSuchElementException("org " + org + " not found in " + orgToVDCs.keySet());
org.jclouds.vcloud.domain.VDC vDCObject = vDCs.get(vDC);

View File

@ -46,7 +46,7 @@ import com.google.common.collect.Sets;
* @author Adrian Cole
*/
@Singleton
public class OrgsForLocations implements Function<Iterable<? extends Location>, Iterable<? extends Org>> {
public class OrgsForLocations implements Function<Iterable<Location>, Iterable< Org>> {
@Resource
public Logger logger = Logger.NULL;
private final VCloudAsyncClient aclient;
@ -63,7 +63,7 @@ public class OrgsForLocations implements Function<Iterable<? extends Location>,
* parent is region. then, we use a set to extract the unique set.
*/
@Override
public Iterable<? extends Org> apply(Iterable<? extends Location> from) {
public Iterable<Org> apply(Iterable<Location> from) {
return transformParallel(Sets.newLinkedHashSet(transform(filter(from, new Predicate<Location>() {
@ -81,10 +81,9 @@ public class OrgsForLocations implements Function<Iterable<? extends Location>,
})), new Function<URI, Future<Org>>() {
@SuppressWarnings("unchecked")
@Override
public Future<Org> apply(URI from) {
return (Future<Org>) aclient.getOrgClient().getOrg(from);
return aclient.getOrgClient().getOrg(from);
}
}, executor, null, logger, "organizations for uris");

View File

@ -39,7 +39,7 @@ import com.google.common.base.Function;
* @author Adrian Cole
*/
@Singleton
public class OrgsForNames implements Function<Iterable<String>, Iterable<? extends Org>> {
public class OrgsForNames implements Function<Iterable<String>, Iterable<Org>> {
@Resource
public Logger logger = Logger.NULL;
private final VCloudAsyncClient aclient;
@ -52,13 +52,12 @@ public class OrgsForNames implements Function<Iterable<String>, Iterable<? exten
}
@Override
public Iterable<? extends Org> apply(Iterable<String> from) {
public Iterable<Org> apply(Iterable<String> from) {
return transformParallel(from, new Function<String, Future<Org>>() {
@SuppressWarnings("unchecked")
@Override
public Future<Org> apply(String from) {
return (Future<Org>) aclient.getOrgClient().findOrgNamed(from);
return aclient.getOrgClient().findOrgNamed(from);
}
}, executor, null, logger, "organizations for names");

View File

@ -48,8 +48,7 @@ import com.google.common.base.Predicate;
* @author Adrian Cole
*/
@Singleton
public class VAppTemplatesForCatalogItems implements
Function<Iterable<? extends CatalogItem>, Iterable<? extends VAppTemplate>> {
public class VAppTemplatesForCatalogItems implements Function<Iterable<CatalogItem>, Iterable<VAppTemplate>> {
@Resource
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
public Logger logger = Logger.NULL;
@ -78,7 +77,7 @@ public class VAppTemplatesForCatalogItems implements
}
@Override
public Iterable<? extends VAppTemplate> apply(Iterable<? extends CatalogItem> from) {
public Iterable<VAppTemplate> apply(Iterable<CatalogItem> from) {
return transformParallel(filter(from, new Predicate<CatalogItem>() {
@Override
@ -88,12 +87,11 @@ public class VAppTemplatesForCatalogItems implements
}), new Function<CatalogItem, Future<VAppTemplate>>() {
@SuppressWarnings("unchecked")
@Override
public Future<VAppTemplate> apply(CatalogItem from) {
return new ExceptionParsingListenableFuture<VAppTemplate>(Futures.makeListenable(
(Future<VAppTemplate>) VCloudAsyncClient.class.cast(aclient).getVAppTemplateClient().getVAppTemplate(
from.getEntity().getHref()), executor), returnNullOnAuthorizationException);
return new ExceptionParsingListenableFuture<VAppTemplate>(Futures.makeListenable(VCloudAsyncClient.class
.cast(aclient).getVAppTemplateClient().getVAppTemplate(from.getEntity().getHref()), executor),
returnNullOnAuthorizationException);
}
}, executor, null, logger, "vappTemplates in");

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.compute.suppliers;
package org.jclouds.vcloud.suppliers;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Iterables.concat;
@ -35,10 +35,10 @@ import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.Constants;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.logging.Logger;
import org.jclouds.vcloud.domain.Org;
import org.jclouds.vcloud.domain.VAppTemplate;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
@ -47,19 +47,19 @@ import com.google.common.base.Supplier;
* @author Adrian Cole
*/
@Singleton
public class VCloudImageSupplier implements Supplier<Set<? extends Image>> {
public class VAppTemplatesSupplier implements Supplier<Set<VAppTemplate>> {
@Resource
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
public Logger logger = Logger.NULL;
private final Supplier<Map<String, ? extends Org>> orgMap;
private final Function<Org, Iterable<? extends Image>> imagesInOrg;
private final Supplier<Map<String, Org>> orgMap;
private final Function<Org, Iterable<VAppTemplate>> imagesInOrg;
private final ExecutorService executor;
@Inject
VCloudImageSupplier(Supplier<Map<String, ? extends Org>> orgMap,
Function<Org, Iterable<? extends Image>> imagesInOrg,
VAppTemplatesSupplier(Supplier<Map<String, Org>> orgMap,
Function<Org, Iterable<VAppTemplate>> imagesInOrg,
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
this.orgMap = checkNotNull(orgMap, "orgMap");
this.imagesInOrg = checkNotNull(imagesInOrg, "imagesInOrg");
@ -67,18 +67,18 @@ public class VCloudImageSupplier implements Supplier<Set<? extends Image>> {
}
@Override
public Set<? extends Image> get() {
Iterable<? extends Org> orgs = checkNotNull(orgMap.get().values(), "orgs");
Iterable<Iterable<? extends Image>> images = transformParallel(orgs,
new Function<Org, Future<Iterable<? extends Image>>>() {
public Set<VAppTemplate> get() {
Iterable<Org> orgs = checkNotNull(orgMap.get().values(), "orgs");
Iterable<Iterable<VAppTemplate>> images = transformParallel(orgs,
new Function<Org, Future<Iterable<VAppTemplate>>>() {
@Override
public Future<Iterable<? extends Image>> apply(final Org from) {
public Future<Iterable<VAppTemplate>> apply(final Org from) {
checkNotNull(from, "org");
return executor.submit(new Callable<Iterable<? extends Image>>() {
return executor.submit(new Callable<Iterable<VAppTemplate>>() {
@Override
public Iterable<? extends Image> call() throws Exception {
public Iterable<VAppTemplate> call() throws Exception {
return imagesInOrg.apply(from);
}

View File

@ -60,12 +60,6 @@ public class VCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest {
"node userMetadata did not match %s %s", userMetadata, node);
}
public void testAssignability() throws Exception {
@SuppressWarnings("unused")
RestContext<VCloudClient, VCloudAsyncClient> tmContext = new ComputeServiceContextFactory(setupRestProperties())
.createContext(provider, identity, credential).getProviderSpecificContext();
}
@Override
public void testListNodes() throws Exception {
for (ComputeMetadata node : client.listNodes()) {

View File

@ -42,7 +42,7 @@ import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ParseSax.Factory;
import org.jclouds.http.functions.config.SaxParserModule;
import org.jclouds.vcloud.VCloudPropertiesBuilder;
import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule;
import org.jclouds.vcloud.compute.config.VCloudComputeServiceDependenciesModule;
import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.domain.Status;
import org.jclouds.vcloud.domain.VApp;
@ -105,7 +105,7 @@ public class VAppToNodeMetadataTest {
@Singleton
@Provides
protected Map<Status, NodeState> provideVAppStatusToNodeState() {
return VCloudComputeServiceContextModule.VAPPSTATUS_TO_NODESTATE;
return VCloudComputeServiceDependenciesModule.VAPPSTATUS_TO_NODESTATE;
}
});

View File

@ -132,7 +132,7 @@ public abstract class BaseVCloudAsyncClientTest<T> extends RestClientTest<T> {
}
@Override
protected Org provideOrg(Supplier<Map<String, ? extends Org>> orgSupplier,
protected Org provideOrg(Supplier<Map<String, Org>> orgSupplier,
@org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) {
return ORG;
}
@ -184,11 +184,11 @@ public abstract class BaseVCloudAsyncClientTest<T> extends RestClientTest<T> {
}
@Override
protected Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> provideOrgVDCSupplierCache(
protected Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.VDC>>> provideOrgVDCSupplierCache(
@Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference<AuthorizationException> authException,
OrgVDCSupplier supplier) {
return Suppliers.<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> ofInstance(ImmutableMap
.<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> of(ORG_REF.getName(),
return Suppliers.<Map<String, Map<String, org.jclouds.vcloud.domain.VDC>>> ofInstance(ImmutableMap
.<String, Map<String, org.jclouds.vcloud.domain.VDC>> of(ORG_REF.getName(),
ImmutableMap.<String, org.jclouds.vcloud.domain.VDC> of(VDC.getName(), VDC)));
}
@ -214,8 +214,8 @@ public abstract class BaseVCloudAsyncClientTest<T> extends RestClientTest<T> {
}
@Override
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> get() {
return ImmutableMap.<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> of(
public Map<String, Map<String, org.jclouds.vcloud.domain.Catalog>> get() {
return ImmutableMap.<String, Map<String, org.jclouds.vcloud.domain.Catalog>> of(
ORG_REF.getName(), ImmutableMap.<String, org.jclouds.vcloud.domain.Catalog> of(
CATALOG_REF.getName(),
new CatalogImpl(CATALOG_REF.getName(), CATALOG_REF.getType(), CATALOG_REF.getHref(), null,
@ -237,10 +237,10 @@ public abstract class BaseVCloudAsyncClientTest<T> extends RestClientTest<T> {
}
@Override
public Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> get() {
return ImmutableMap.<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> of(
public Map<String, Map<String, Map<String, org.jclouds.vcloud.domain.CatalogItem>>> get() {
return ImmutableMap.<String, Map<String, Map<String, org.jclouds.vcloud.domain.CatalogItem>>> of(
ORG_REF.getName(), ImmutableMap
.<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>> of(CATALOG_REF
.<String, Map<String, org.jclouds.vcloud.domain.CatalogItem>> of(CATALOG_REF
.getName(), ImmutableMap.<String, org.jclouds.vcloud.domain.CatalogItem> of(
"template",
new CatalogItemImpl("template", URI