mirror of https://github.com/apache/jclouds.git
refactored and slimmed vcloud compute impl
This commit is contained in:
parent
c6d1f2d56e
commit
535c035ae6
|
@ -103,7 +103,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
|
||||||
boolean powerOn = true;
|
boolean powerOn = true;
|
||||||
Boolean customizeOnInstantiate = null;
|
Boolean customizeOnInstantiate = null;
|
||||||
|
|
||||||
Set<? extends NetworkConfig> networkConfig = null;
|
Set<NetworkConfig> networkConfig = null;
|
||||||
|
|
||||||
NetworkConfigDecorator networknetworkConfigDecorator = new NetworkConfigDecorator(template,
|
NetworkConfigDecorator networknetworkConfigDecorator = new NetworkConfigDecorator(template,
|
||||||
defaultNetwork.getHref(), defaultFenceMode, defaultNetworkNameInTemplate);
|
defaultNetwork.getHref(), defaultFenceMode, defaultNetworkNameInTemplate);
|
||||||
|
@ -138,8 +138,8 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
Set<? extends Vm> ifCustomizationScriptIsSetGetVmsInTemplate(String customizationScript, final URI template) {
|
Set<Vm> ifCustomizationScriptIsSetGetVmsInTemplate(String customizationScript, final URI template) {
|
||||||
Set<? extends Vm> vms = Sets.newLinkedHashSet();
|
Set<Vm> vms = Sets.newLinkedHashSet();
|
||||||
if (customizationScript != null) {
|
if (customizationScript != null) {
|
||||||
VAppTemplate vAppTemplate = client.getVAppTemplateClient().getVAppTemplate(template);
|
VAppTemplate vAppTemplate = client.getVAppTemplateClient().getVAppTemplate(template);
|
||||||
checkArgument(vAppTemplate != null, "vAppTemplate %s not found!", 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,
|
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 {
|
throws ParserConfigurationException, FactoryConfigurationError, TransformerException {
|
||||||
XMLBuilder rootBuilder = buildRoot(name).a("deploy", deploy + "").a("powerOn", powerOn + "");
|
XMLBuilder rootBuilder = buildRoot(name).a("deploy", deploy + "").a("powerOn", powerOn + "");
|
||||||
if (description != null)
|
if (description != null)
|
||||||
|
@ -228,7 +228,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addNetworkConfig(XMLBuilder instantiationParamsBuilder,
|
protected void addNetworkConfig(XMLBuilder instantiationParamsBuilder,
|
||||||
Iterable<? extends NetworkConfig> networkConfig) {
|
Iterable<NetworkConfig> networkConfig) {
|
||||||
XMLBuilder networkConfigBuilder = instantiationParamsBuilder.e("NetworkConfigSection");
|
XMLBuilder networkConfigBuilder = instantiationParamsBuilder.e("NetworkConfigSection");
|
||||||
networkConfigBuilder.e("ovf:Info").t("Configuration parameters for logical networks");
|
networkConfigBuilder.e("ovf:Info").t("Configuration parameters for logical networks");
|
||||||
for (NetworkConfig n : networkConfig) {
|
for (NetworkConfig n : networkConfig) {
|
||||||
|
|
|
@ -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()";
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -18,46 +18,17 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.compute.config;
|
package org.jclouds.vcloud.compute.config;
|
||||||
|
|
||||||
|
|
||||||
import static org.jclouds.compute.domain.OsFamily.UBUNTU;
|
import static org.jclouds.compute.domain.OsFamily.UBUNTU;
|
||||||
|
|
||||||
import java.util.Map;
|
import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
|
||||||
|
|
||||||
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.domain.TemplateBuilder;
|
import org.jclouds.compute.domain.TemplateBuilder;
|
||||||
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.compute.options.TemplateOptions;
|
import org.jclouds.vcloud.VCloudAsyncClient;
|
||||||
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
|
|
||||||
import org.jclouds.rest.RestContext;
|
|
||||||
import org.jclouds.rest.internal.RestContextImpl;
|
|
||||||
import org.jclouds.vcloud.VCloudClient;
|
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.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.Injector;
|
||||||
import com.google.inject.Provides;
|
|
||||||
import com.google.inject.Scopes;
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures the {@link VCloudComputeServiceContext}; requires {@link VCloudComputeClientImpl}
|
* Configures the {@link VCloudComputeServiceContext}; requires {@link VCloudComputeClientImpl}
|
||||||
|
@ -65,61 +36,23 @@ import com.google.inject.TypeLiteral;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class VCloudComputeServiceContextModule extends BaseComputeServiceContextModule {
|
public class VCloudComputeServiceContextModule
|
||||||
|
extends
|
||||||
@VisibleForTesting
|
ComputeServiceAdapterContextModule<VCloudClient, VCloudAsyncClient, VApp, VAppTemplate, VAppTemplate, Location> {
|
||||||
public static final Map<Status, NodeState> VAPPSTATUS_TO_NODESTATE = ImmutableMap.<Status, NodeState> builder()
|
public VCloudComputeServiceContextModule() {
|
||||||
.put(Status.OFF, NodeState.SUSPENDED).put(Status.ON, NodeState.RUNNING)
|
super(VCloudClient.class, VCloudAsyncClient.class);
|
||||||
.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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
super.configure();
|
super.configure();
|
||||||
install(defineComputeStrategyModule());
|
install(new VCloudComputeServiceDependenciesModule());
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//CIM ostype does not include version info
|
// CIM ostype does not include version info
|
||||||
@Override
|
@Override
|
||||||
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
||||||
return template.osFamily(UBUNTU).os64Bit(true);
|
return template.osFamily(UBUNTU).os64Bit(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BindComputeStrategiesByClass defineComputeStrategyModule() {
|
|
||||||
return new VCloudBindComputeStrategiesByClass();
|
|
||||||
}
|
|
||||||
|
|
||||||
public BindComputeSuppliersByClass defineComputeSupplierModule() {
|
|
||||||
return new VCloudBindComputeSuppliersByClass();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -22,6 +22,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.Hardware;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.HardwareBuilder;
|
import org.jclouds.compute.domain.HardwareBuilder;
|
||||||
|
@ -30,7 +31,6 @@ import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.ovf.Envelope;
|
import org.jclouds.ovf.Envelope;
|
||||||
import org.jclouds.ovf.VirtualHardwareSection;
|
import org.jclouds.ovf.VirtualHardwareSection;
|
||||||
import org.jclouds.vcloud.VCloudClient;
|
import org.jclouds.vcloud.VCloudClient;
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
|
||||||
import org.jclouds.vcloud.domain.VAppTemplate;
|
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
@ -39,6 +39,7 @@ import com.google.common.collect.Iterables;
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
|
@Singleton
|
||||||
public class HardwareForVAppTemplate implements Function<VAppTemplate, Hardware> {
|
public class HardwareForVAppTemplate implements Function<VAppTemplate, Hardware> {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -48,8 +49,6 @@ public class HardwareForVAppTemplate implements Function<VAppTemplate, Hardware>
|
||||||
private final FindLocationForResource findLocationForResource;
|
private final FindLocationForResource findLocationForResource;
|
||||||
private final VCloudHardwareBuilderFromResourceAllocations rasdToHardwareBuilder;
|
private final VCloudHardwareBuilderFromResourceAllocations rasdToHardwareBuilder;
|
||||||
|
|
||||||
private ReferenceType parent;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected HardwareForVAppTemplate(VCloudClient client, FindLocationForResource findLocationForResource,
|
protected HardwareForVAppTemplate(VCloudClient client, FindLocationForResource findLocationForResource,
|
||||||
VCloudHardwareBuilderFromResourceAllocations rasdToHardwareBuilder) {
|
VCloudHardwareBuilderFromResourceAllocations rasdToHardwareBuilder) {
|
||||||
|
@ -58,10 +57,6 @@ public class HardwareForVAppTemplate implements Function<VAppTemplate, Hardware>
|
||||||
this.rasdToHardwareBuilder = checkNotNull(rasdToHardwareBuilder, "rasdToHardwareBuilder");
|
this.rasdToHardwareBuilder = checkNotNull(rasdToHardwareBuilder, "rasdToHardwareBuilder");
|
||||||
}
|
}
|
||||||
|
|
||||||
public HardwareForVAppTemplate withParent(ReferenceType parent) {
|
|
||||||
this.parent = parent;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Hardware apply(VAppTemplate from) {
|
public Hardware apply(VAppTemplate from) {
|
||||||
|
@ -86,7 +81,7 @@ public class HardwareForVAppTemplate implements Function<VAppTemplate, Hardware>
|
||||||
}
|
}
|
||||||
VirtualHardwareSection hardware = Iterables.get(ovf.getVirtualSystem().getVirtualHardwareSections(), 0);
|
VirtualHardwareSection hardware = Iterables.get(ovf.getVirtualSystem().getVirtualHardwareSections(), 0);
|
||||||
HardwareBuilder builder = rasdToHardwareBuilder.apply(hardware.getItems());
|
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(
|
builder.ids(from.getHref().toASCIIString()).name(from.getName()).supportsImage(
|
||||||
ImagePredicates.idEquals(from.getHref().toASCIIString()));
|
ImagePredicates.idEquals(from.getHref().toASCIIString()));
|
||||||
return builder.build();
|
return builder.build();
|
||||||
|
|
|
@ -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));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -21,14 +21,13 @@ package org.jclouds.vcloud.compute.functions;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.CIMOperatingSystem;
|
import org.jclouds.compute.domain.CIMOperatingSystem;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.ImageBuilder;
|
import org.jclouds.compute.domain.ImageBuilder;
|
||||||
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
|
|
||||||
import org.jclouds.ovf.Envelope;
|
import org.jclouds.ovf.Envelope;
|
||||||
import org.jclouds.vcloud.VCloudClient;
|
import org.jclouds.vcloud.VCloudClient;
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
|
||||||
import org.jclouds.vcloud.domain.VAppTemplate;
|
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
@ -36,24 +35,17 @@ import com.google.common.base.Function;
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
|
@Singleton
|
||||||
public class ImageForVAppTemplate implements Function<VAppTemplate, Image> {
|
public class ImageForVAppTemplate implements Function<VAppTemplate, Image> {
|
||||||
private final VCloudClient client;
|
private final VCloudClient client;
|
||||||
private final FindLocationForResource findLocationForResource;
|
private final FindLocationForResource findLocationForResource;
|
||||||
private final PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider;
|
|
||||||
private ReferenceType parent;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected ImageForVAppTemplate(VCloudClient client, FindLocationForResource findLocationForResource,
|
protected ImageForVAppTemplate(VCloudClient client, FindLocationForResource findLocationForResource) {
|
||||||
PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider) {
|
|
||||||
this.client = checkNotNull(client, "client");
|
this.client = checkNotNull(client, "client");
|
||||||
this.findLocationForResource = checkNotNull(findLocationForResource, "findLocationForResource");
|
this.findLocationForResource = checkNotNull(findLocationForResource, "findLocationForResource");
|
||||||
this.credentialsProvider = checkNotNull(credentialsProvider, "credentialsProvider");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImageForVAppTemplate withParent(ReferenceType parent) {
|
|
||||||
this.parent = parent;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image apply(VAppTemplate from) {
|
public Image apply(VAppTemplate from) {
|
||||||
|
@ -61,11 +53,10 @@ public class ImageForVAppTemplate implements Function<VAppTemplate, Image> {
|
||||||
builder.ids(from.getHref().toASCIIString());
|
builder.ids(from.getHref().toASCIIString());
|
||||||
builder.uri(from.getHref());
|
builder.uri(from.getHref());
|
||||||
builder.name(from.getName());
|
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());
|
builder.description(from.getDescription() != null ? from.getDescription() : from.getName());
|
||||||
Envelope ovf = client.getVAppTemplateClient().getOvfEnvelopeForVAppTemplate(from.getHref());
|
Envelope ovf = client.getVAppTemplateClient().getOvfEnvelopeForVAppTemplate(from.getHref());
|
||||||
builder.operatingSystem(CIMOperatingSystem.toComputeOs(ovf));
|
builder.operatingSystem(CIMOperatingSystem.toComputeOs(ovf));
|
||||||
builder.defaultCredentials(credentialsProvider.apply(from));
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,11 +18,15 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.compute.functions;
|
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.Inject;
|
||||||
import javax.inject.Provider;
|
|
||||||
import javax.inject.Singleton;
|
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.CatalogItem;
|
||||||
import org.jclouds.vcloud.domain.Org;
|
import org.jclouds.vcloud.domain.Org;
|
||||||
import org.jclouds.vcloud.domain.VAppTemplate;
|
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||||
|
@ -36,26 +40,39 @@ import com.google.common.collect.Iterables;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ImagesInOrg implements Function<Org, Iterable<? extends Image>> {
|
public class VAppTemplatesInOrg implements Function<Org, Iterable<VAppTemplate>> {
|
||||||
|
|
||||||
private final AllCatalogItemsInOrg allCatalogItemsInOrg;
|
private final AllCatalogItemsInOrg allCatalogItemsInOrg;
|
||||||
private final Function<Iterable<? extends CatalogItem>, Iterable<? extends VAppTemplate>> vAppTemplatesForCatalogItems;
|
private final Function<Iterable<CatalogItem>, Iterable<VAppTemplate>> vAppTemplatesForCatalogItems;
|
||||||
private final Provider<ImageForVAppTemplate> imageForVAppTemplateProvider;
|
private final Map<String, Credentials> credentialStore;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ImagesInOrg(AllCatalogItemsInOrg allCatalogItemsInOrg,
|
VAppTemplatesInOrg(AllCatalogItemsInOrg allCatalogItemsInOrg,
|
||||||
Provider<ImageForVAppTemplate> imageForVAppTemplateProvider,
|
Function<Iterable<CatalogItem>, Iterable<VAppTemplate>> vAppTemplatesForCatalogItems,
|
||||||
Function<Iterable<? extends CatalogItem>, Iterable<? extends VAppTemplate>> vAppTemplatesForCatalogItems) {
|
Map<String, Credentials> credentialStore) {
|
||||||
this.imageForVAppTemplateProvider = imageForVAppTemplateProvider;
|
|
||||||
this.allCatalogItemsInOrg = allCatalogItemsInOrg;
|
this.allCatalogItemsInOrg = allCatalogItemsInOrg;
|
||||||
this.vAppTemplatesForCatalogItems = vAppTemplatesForCatalogItems;
|
this.vAppTemplatesForCatalogItems = vAppTemplatesForCatalogItems;
|
||||||
|
this.credentialStore = credentialStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<? extends Image> apply(Org from) {
|
public Iterable<VAppTemplate> apply(Org from) {
|
||||||
Iterable<? extends CatalogItem> catalogs = allCatalogItemsInOrg.apply(from);
|
Iterable<CatalogItem> catalogs = allCatalogItemsInOrg.apply(from);
|
||||||
Iterable<? extends VAppTemplate> vAppTemplates = vAppTemplatesForCatalogItems.apply(catalogs);
|
Iterable<VAppTemplate> vAppTemplates = vAppTemplatesForCatalogItems.apply(catalogs);
|
||||||
return Iterables.transform(Iterables.filter(vAppTemplates, Predicates.notNull()), imageForVAppTemplateProvider.get().withParent(from));
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -81,6 +81,9 @@ public class VAppToNodeMetadata implements Function<VApp, NodeMetadata> {
|
||||||
Set<String> addresses = getIpsFromVApp(from);
|
Set<String> addresses = getIpsFromVApp(from);
|
||||||
builder.publicAddresses(filter(addresses, not(IsPrivateIPAddress.INSTANCE)));
|
builder.publicAddresses(filter(addresses, not(IsPrivateIPAddress.INSTANCE)));
|
||||||
builder.privateAddresses(filter(addresses, 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);
|
Credentials fromApi = getCredentialsFrom(from);
|
||||||
if (fromApi != null && !credentialStore.containsKey("node#" + from.getHref().toASCIIString()))
|
if (fromApi != null && !credentialStore.containsKey("node#" + from.getHref().toASCIIString()))
|
||||||
credentialStore.put("node#" + from.getHref().toASCIIString(), fromApi);
|
credentialStore.put("node#" + from.getHref().toASCIIString(), fromApi);
|
||||||
|
|
|
@ -38,7 +38,7 @@ import org.jclouds.vcloud.domain.network.IpAddressAllocationMode;
|
||||||
* <p/>
|
* <p/>
|
||||||
* ComputeService client = // get connection
|
* ComputeService client = // get connection
|
||||||
* templateBuilder.options(inboundPorts(22, 80, 8080, 443));
|
* 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>
|
* <code>
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
|
|
@ -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));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -19,6 +19,7 @@
|
||||||
package org.jclouds.vcloud.compute.strategy;
|
package org.jclouds.vcloud.compute.strategy;
|
||||||
|
|
||||||
import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
|
import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
|
||||||
|
import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.getCredentialsFrom;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
|
@ -27,11 +28,9 @@ import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
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.domain.Template;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
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.logging.Logger;
|
||||||
import org.jclouds.vcloud.VCloudClient;
|
import org.jclouds.vcloud.VCloudClient;
|
||||||
import org.jclouds.vcloud.compute.options.VCloudTemplateOptions;
|
import org.jclouds.vcloud.compute.options.VCloudTemplateOptions;
|
||||||
|
@ -53,26 +52,22 @@ import com.google.common.collect.Iterables;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn implements
|
public class InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn {
|
||||||
CreateNodeWithGroupEncodedIntoName {
|
|
||||||
@Resource
|
@Resource
|
||||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
protected final VCloudClient client;
|
protected final VCloudClient client;
|
||||||
protected final GetNodeMetadataStrategy getNode;
|
|
||||||
protected final Predicate<URI> successTester;
|
protected final Predicate<URI> successTester;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn(Predicate<URI> successTester,
|
protected InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn(Predicate<URI> successTester,
|
||||||
VCloudClient client, GetNodeMetadataStrategy getNode) {
|
VCloudClient client) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.successTester = successTester;
|
this.successTester = successTester;
|
||||||
this.getNode = getNode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public NodeAndInitialCredentials<VApp> createNodeWithGroupEncodedIntoName(String tag, String name, Template template) {
|
||||||
public NodeMetadata createNodeWithGroupEncodedIntoName(String tag, String name, Template template) {
|
|
||||||
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
|
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
|
||||||
|
|
||||||
// TODO make disk size specifiable
|
// TODO make disk size specifiable
|
||||||
|
@ -122,8 +117,10 @@ public class InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployA
|
||||||
waitForTask(updateMemoryMBOfVm(vm, memoryMB), vAppResponse);
|
waitForTask(updateMemoryMBOfVm(vm, memoryMB), vAppResponse);
|
||||||
logger.trace("<< updated memoryMB vm(%s) ", vm.getName());
|
logger.trace("<< updated memoryMB vm(%s) ", vm.getName());
|
||||||
logger.trace(">> deploying and powering on vApp(%s) ", vAppResponse.getName());
|
logger.trace(">> deploying and powering on vApp(%s) ", vAppResponse.getName());
|
||||||
return blockOnDeployAndPowerOnIfConfigured(options, vAppResponse, client.getVAppClient().deployAndPowerOnVApp(
|
vAppResponse = blockOnDeployAndPowerOnIfConfigured(options, vAppResponse, client.getVAppClient()
|
||||||
vAppResponse.getHref()));
|
.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());
|
return client.getVmClient().updateMemoryMBOfVm(memoryInMB, vm.getHref());
|
||||||
}
|
}
|
||||||
|
|
||||||
private NodeMetadata blockOnDeployAndPowerOnIfConfigured(InstantiateVAppTemplateOptions options, VApp vAppResponse,
|
private VApp blockOnDeployAndPowerOnIfConfigured(InstantiateVAppTemplateOptions options, VApp vAppResponse, Task task) {
|
||||||
Task task) {
|
|
||||||
if (options.shouldBlock()) {
|
if (options.shouldBlock()) {
|
||||||
waitForTask(task, vAppResponse);
|
waitForTask(task, vAppResponse);
|
||||||
logger.debug("<< ready vApp(%s)", vAppResponse.getName());
|
logger.debug("<< ready vApp(%s)", vAppResponse.getName());
|
||||||
}
|
}
|
||||||
return getNode.getNode(vAppResponse.getHref().toASCIIString());
|
return client.getVAppClient().getVApp(vAppResponse.getHref());
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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());
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -48,13 +48,13 @@ import com.google.common.collect.ImmutableSet.Builder;
|
||||||
public class OrgAndVDCToLocationSupplier extends JustProvider {
|
public class OrgAndVDCToLocationSupplier extends JustProvider {
|
||||||
|
|
||||||
private final Supplier<Map<String, ReferenceType>> orgNameToResource;
|
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;
|
private final Map<String, Set<String>> isoCodesById;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
OrgAndVDCToLocationSupplier(@Iso3166 Set<String> isoCodes, @Provider String providerName, @Provider URI endpoint,
|
OrgAndVDCToLocationSupplier(@Iso3166 Set<String> isoCodes, @Provider String providerName, @Provider URI endpoint,
|
||||||
@org.jclouds.vcloud.endpoints.Org Supplier<Map<String, ReferenceType>> orgNameToResource,
|
@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);
|
super(providerName, endpoint, isoCodes);
|
||||||
this.orgNameToResource = checkNotNull(orgNameToResource, "orgNameToResource");
|
this.orgNameToResource = checkNotNull(orgNameToResource, "orgNameToResource");
|
||||||
this.orgNameToVDCResource = checkNotNull(orgNameToVDCResource, "orgNameToVDCResource");
|
this.orgNameToVDCResource = checkNotNull(orgNameToVDCResource, "orgNameToVDCResource");
|
||||||
|
@ -62,7 +62,7 @@ public class OrgAndVDCToLocationSupplier extends JustProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<? extends Location> get() {
|
public Set<Location> get() {
|
||||||
return buildJustProviderOrVDCs().build();
|
return buildJustProviderOrVDCs().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -44,20 +44,20 @@ import com.google.common.base.Supplier;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class DefaultCatalogForOrg implements Function<ReferenceType, ReferenceType> {
|
public class DefaultCatalogForOrg implements Function<ReferenceType, ReferenceType> {
|
||||||
private final OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault selector;
|
private final OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault selector;
|
||||||
private final Supplier<Map<String, ? extends Org>> nameToOrg;
|
private final Supplier<Map<String, Org>> nameToOrg;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public DefaultCatalogForOrg(ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull,
|
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(
|
this.selector = new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(checkNotNull(
|
||||||
valueOfConfigurationKeyOrNull, "valueOfConfigurationKeyOrNull"), PROPERTY_VCLOUD_DEFAULT_CATALOG,
|
valueOfConfigurationKeyOrNull, "valueOfConfigurationKeyOrNull"), PROPERTY_VCLOUD_DEFAULT_CATALOG,
|
||||||
checkNotNull(defaultSelector, "defaultSelector"));
|
checkNotNull(defaultSelector, "defaultSelector"));
|
||||||
this.nameToOrg = checkNotNull(nameToOrg, "nameToOrg");
|
this.nameToOrg = checkNotNull(nameToOrg, "nameToOrg");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReferenceType apply(ReferenceType defaultOrg) {
|
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);
|
checkState(org != null, "could not retrieve Org at %s", defaultOrg);
|
||||||
return selector.apply(org.getCatalogs().values());
|
return selector.apply(org.getCatalogs().values());
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,15 +46,14 @@ import com.google.common.base.Supplier;
|
||||||
public class DefaultNetworkForVDC implements Function<ReferenceType, ReferenceType> {
|
public class DefaultNetworkForVDC implements Function<ReferenceType, ReferenceType> {
|
||||||
|
|
||||||
private final OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault selector;
|
private final OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault selector;
|
||||||
private final Supplier<Map<URI, ? extends VDC>> uriToVDC;
|
private final Supplier<Map<URI, VDC>> uriToVDC;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public DefaultNetworkForVDC(ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull,
|
public DefaultNetworkForVDC(ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull,
|
||||||
@Network Predicate<ReferenceType> defaultSelector,
|
@Network Predicate<ReferenceType> defaultSelector, Supplier<Map<URI, VDC>> uriToVDC) {
|
||||||
Supplier<Map<URI, ? extends org.jclouds.vcloud.domain.VDC>> uriToVDC) {
|
|
||||||
this.selector = new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(checkNotNull(
|
this.selector = new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(checkNotNull(
|
||||||
valueOfConfigurationKeyOrNull, "valueOfConfigurationKeyOrNull"), PROPERTY_VCLOUD_DEFAULT_NETWORK,
|
valueOfConfigurationKeyOrNull, "valueOfConfigurationKeyOrNull"), PROPERTY_VCLOUD_DEFAULT_NETWORK,
|
||||||
checkNotNull(defaultSelector, "defaultSelector"));
|
checkNotNull(defaultSelector, "defaultSelector"));
|
||||||
this.uriToVDC = checkNotNull(uriToVDC, "uriToVDC");
|
this.uriToVDC = checkNotNull(uriToVDC, "uriToVDC");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,10 +38,10 @@ import com.google.common.base.Supplier;
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class DefaultTasksListForOrg implements Function<ReferenceType, ReferenceType> {
|
public class DefaultTasksListForOrg implements Function<ReferenceType, ReferenceType> {
|
||||||
private final Supplier<Map<String, ? extends Org>> nameToOrg;
|
private final Supplier<Map<String, Org>> nameToOrg;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public DefaultTasksListForOrg(Supplier<Map<String, ? extends Org>> nameToOrg) {
|
public DefaultTasksListForOrg(Supplier<Map<String, Org>> nameToOrg) {
|
||||||
this.nameToOrg = checkNotNull(nameToOrg, "nameToOrg");
|
this.nameToOrg = checkNotNull(nameToOrg, "nameToOrg");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class DefaultVCloudReferencesModule extends AbstractModule {
|
||||||
@org.jclouds.vcloud.endpoints.Org
|
@org.jclouds.vcloud.endpoints.Org
|
||||||
@Singleton
|
@Singleton
|
||||||
protected ReferenceType provideDefaultOrg(DefaultOrgForUser defaultOrgURIForUser,
|
protected ReferenceType provideDefaultOrg(DefaultOrgForUser defaultOrgURIForUser,
|
||||||
@Named(PROPERTY_IDENTITY) String user) {
|
@Named(PROPERTY_IDENTITY) String user) {
|
||||||
return defaultOrgURIForUser.apply(user);
|
return defaultOrgURIForUser.apply(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ public class DefaultVCloudReferencesModule extends AbstractModule {
|
||||||
@org.jclouds.vcloud.endpoints.TasksList
|
@org.jclouds.vcloud.endpoints.TasksList
|
||||||
@Singleton
|
@Singleton
|
||||||
protected ReferenceType provideDefaultTasksList(DefaultTasksListForOrg defaultTasksListURIForOrg,
|
protected ReferenceType provideDefaultTasksList(DefaultTasksListForOrg defaultTasksListURIForOrg,
|
||||||
@org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) {
|
@org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) {
|
||||||
return defaultTasksListURIForOrg.apply(defaultOrg);
|
return defaultTasksListURIForOrg.apply(defaultOrg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ public class DefaultVCloudReferencesModule extends AbstractModule {
|
||||||
@org.jclouds.vcloud.endpoints.Catalog
|
@org.jclouds.vcloud.endpoints.Catalog
|
||||||
@Singleton
|
@Singleton
|
||||||
protected ReferenceType provideDefaultCatalog(DefaultCatalogForOrg defaultCatalogURIForOrg,
|
protected ReferenceType provideDefaultCatalog(DefaultCatalogForOrg defaultCatalogURIForOrg,
|
||||||
@org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) {
|
@org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) {
|
||||||
return defaultCatalogURIForOrg.apply(defaultOrg);
|
return defaultCatalogURIForOrg.apply(defaultOrg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,24 +94,24 @@ public class DefaultVCloudReferencesModule extends AbstractModule {
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Supplier<Map<URI, ? extends org.jclouds.vcloud.domain.Catalog>> provideCatalogsById(
|
protected Supplier<Map<URI, org.jclouds.vcloud.domain.Catalog>> provideCatalogsById(
|
||||||
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> supplier) {
|
Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.Catalog>>> supplier) {
|
||||||
return Suppliers
|
return Suppliers
|
||||||
.compose(
|
.compose(
|
||||||
new Function<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>, Map<URI, ? extends org.jclouds.vcloud.domain.Catalog>>() {
|
new Function<Map<String, Map<String, org.jclouds.vcloud.domain.Catalog>>, Map<URI, org.jclouds.vcloud.domain.Catalog>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<URI, ? extends Catalog> apply(Map<String, Map<String, ? extends Catalog>> arg0) {
|
public Map<URI, Catalog> apply(Map<String, Map<String, Catalog>> arg0) {
|
||||||
Builder<URI, Catalog> builder = ImmutableMap.<URI, Catalog> builder();
|
Builder<URI, Catalog> builder = ImmutableMap.<URI, Catalog> builder();
|
||||||
for (Map<String, ? extends Catalog> v1 : arg0.values()) {
|
for (Map<String, Catalog> v1 : arg0.values()) {
|
||||||
for (Catalog v2 : v1.values()) {
|
for (Catalog v2 : v1.values()) {
|
||||||
builder.put(v2.getHref(), v2);
|
builder.put(v2.getHref(), v2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return builder.build();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
}, supplier);
|
}, supplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
|
@ -120,10 +120,10 @@ public class DefaultVCloudReferencesModule extends AbstractModule {
|
||||||
@Resource
|
@Resource
|
||||||
protected Logger logger = Logger.NULL;
|
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
|
@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;
|
this.catalogsByIdSupplier = catalogsByIdSupplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ public class DefaultVCloudReferencesModule extends AbstractModule {
|
||||||
// TODO: this is inefficient, calculating the index each time, but
|
// TODO: this is inefficient, calculating the index each time, but
|
||||||
// shouldn't be added to constructor as the supplier is an expensive
|
// shouldn't be added to constructor as the supplier is an expensive
|
||||||
// call
|
// call
|
||||||
Map<URI, ? extends Catalog> index = catalogsByIdSupplier.get();
|
Map<URI, Catalog> index = catalogsByIdSupplier.get();
|
||||||
Catalog catalog = index.get(arg0.getHref());
|
Catalog catalog = index.get(arg0.getHref());
|
||||||
if (catalog == null) {
|
if (catalog == null) {
|
||||||
if (logger.isTraceEnabled())
|
if (logger.isTraceEnabled())
|
||||||
|
@ -147,7 +147,7 @@ public class DefaultVCloudReferencesModule extends AbstractModule {
|
||||||
@org.jclouds.vcloud.endpoints.VDC
|
@org.jclouds.vcloud.endpoints.VDC
|
||||||
@Singleton
|
@Singleton
|
||||||
protected ReferenceType provideDefaultVDC(DefaultVDCForOrg defaultVDCURIForOrg,
|
protected ReferenceType provideDefaultVDC(DefaultVDCForOrg defaultVDCURIForOrg,
|
||||||
@org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) {
|
@org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) {
|
||||||
return defaultVDCURIForOrg.apply(defaultOrg);
|
return defaultVDCURIForOrg.apply(defaultOrg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ public class DefaultVCloudReferencesModule extends AbstractModule {
|
||||||
@org.jclouds.vcloud.endpoints.Network
|
@org.jclouds.vcloud.endpoints.Network
|
||||||
@Singleton
|
@Singleton
|
||||||
protected ReferenceType provideDefaultNetwork(DefaultNetworkForVDC defaultNetworkURIForVDC,
|
protected ReferenceType provideDefaultNetwork(DefaultNetworkForVDC defaultNetworkURIForVDC,
|
||||||
@org.jclouds.vcloud.endpoints.VDC ReferenceType defaultVDC) {
|
@org.jclouds.vcloud.endpoints.VDC ReferenceType defaultVDC) {
|
||||||
return defaultNetworkURIForVDC.apply(defaultVDC);
|
return defaultNetworkURIForVDC.apply(defaultVDC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,20 +44,20 @@ import com.google.common.base.Supplier;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class DefaultVDCForOrg implements Function<ReferenceType, ReferenceType> {
|
public class DefaultVDCForOrg implements Function<ReferenceType, ReferenceType> {
|
||||||
private final OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault selector;
|
private final OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault selector;
|
||||||
private final Supplier<Map<String, ? extends Org>> nameToOrg;
|
private final Supplier<Map<String, Org>> nameToOrg;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public DefaultVDCForOrg(ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull,
|
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(
|
this.selector = new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(checkNotNull(
|
||||||
valueOfConfigurationKeyOrNull, "valueOfConfigurationKeyOrNull"), PROPERTY_VCLOUD_DEFAULT_VDC, checkNotNull(
|
valueOfConfigurationKeyOrNull, "valueOfConfigurationKeyOrNull"), PROPERTY_VCLOUD_DEFAULT_VDC,
|
||||||
defaultSelector, "defaultSelector"));
|
checkNotNull(defaultSelector, "defaultSelector"));
|
||||||
this.nameToOrg = checkNotNull(nameToOrg, "nameToOrg");
|
this.nameToOrg = checkNotNull(nameToOrg, "nameToOrg");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReferenceType apply(ReferenceType defaultOrg) {
|
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);
|
checkState(org != null, "could not retrieve Org at %s", defaultOrg);
|
||||||
return selector.apply(org.getVDCs().values());
|
return selector.apply(org.getVDCs().values());
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,8 +110,7 @@ import com.google.inject.Provides;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures the VCloud authentication service connection, including logging
|
* Configures the VCloud authentication service connection, including logging and http transport.
|
||||||
* and http transport.
|
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
|
@ -143,28 +142,28 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
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,
|
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<VCloudSession>(authException, seconds,
|
||||||
new Supplier<VCloudSession>() {
|
new Supplier<VCloudSession>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VCloudSession get() {
|
public VCloudSession get() {
|
||||||
try {
|
try {
|
||||||
return login.login().get(10, TimeUnit.SECONDS);
|
return login.login().get(10, TimeUnit.SECONDS);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
propagate(e);
|
propagate(e);
|
||||||
assert false : e;
|
assert false : e;
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
super.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>() {
|
}).to(new TypeLiteral<VAppTemplatesForCatalogItems>() {
|
||||||
});
|
});
|
||||||
bind(ResourceAllocationSettingDataHandler.class).to(VCloudResourceAllocationSettingDataHandler.class);
|
bind(ResourceAllocationSettingDataHandler.class).to(VCloudResourceAllocationSettingDataHandler.class);
|
||||||
|
@ -175,22 +174,22 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
|
||||||
bind(new TypeLiteral<Function<ReferenceType, Location>>() {
|
bind(new TypeLiteral<Function<ReferenceType, Location>>() {
|
||||||
}).to(new TypeLiteral<FindLocationForResource>() {
|
}).to(new TypeLiteral<FindLocationForResource>() {
|
||||||
});
|
});
|
||||||
bind(new TypeLiteral<Function<Org, Iterable<? extends Catalog>>>() {
|
bind(new TypeLiteral<Function<Org, Iterable<Catalog>>>() {
|
||||||
}).to(new TypeLiteral<AllCatalogsInOrg>() {
|
}).to(new TypeLiteral<AllCatalogsInOrg>() {
|
||||||
});
|
});
|
||||||
bind(new TypeLiteral<Function<Org, Iterable<? extends VDC>>>() {
|
bind(new TypeLiteral<Function<Org, Iterable<VDC>>>() {
|
||||||
}).to(new TypeLiteral<AllVDCsInOrg>() {
|
}).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>() {
|
}).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>() {
|
}).to(new TypeLiteral<OrgsForLocations>() {
|
||||||
});
|
});
|
||||||
bind(new TypeLiteral<Function<Catalog, Iterable<? extends CatalogItem>>>() {
|
bind(new TypeLiteral<Function<Catalog, Iterable<CatalogItem>>>() {
|
||||||
}).to(new TypeLiteral<AllCatalogItemsInCatalog>() {
|
}).to(new TypeLiteral<AllCatalogItemsInCatalog>() {
|
||||||
});
|
});
|
||||||
bind(new TypeLiteral<Function<Org, Iterable<? extends CatalogItem>>>() {
|
bind(new TypeLiteral<Function<Org, Iterable<CatalogItem>>>() {
|
||||||
}).to(new TypeLiteral<AllCatalogItemsInOrg>() {
|
}).to(new TypeLiteral<AllCatalogItemsInOrg>() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -198,13 +197,13 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
@org.jclouds.vcloud.endpoints.VDC
|
@org.jclouds.vcloud.endpoints.VDC
|
||||||
protected Supplier<Map<String, String>> provideVDCtoORG(Supplier<Map<String, ? extends Org>> orgNameToOrgSuppier) {
|
protected Supplier<Map<String, String>> provideVDCtoORG(Supplier<Map<String, Org>> orgNameToOrgSuppier) {
|
||||||
return compose(new Function<Map<String, ? extends Org>, Map<String, String>>() {
|
return compose(new Function<Map<String, Org>, Map<String, String>>() {
|
||||||
|
|
||||||
@Override
|
@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();
|
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()) {
|
for (String vdc : orgr.getValue().getVDCs().keySet()) {
|
||||||
returnVal.put(vdc, orgr.getKey());
|
returnVal.put(vdc, orgr.getKey());
|
||||||
}
|
}
|
||||||
|
@ -217,10 +216,10 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Supplier<Map<String, ? extends Org>> provideOrgMapCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
protected Supplier<Map<String, Org>> provideOrgMapCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
||||||
AtomicReference<AuthorizationException> authException, OrgMapSupplier supplier) {
|
AtomicReference<AuthorizationException> authException, OrgMapSupplier supplier) {
|
||||||
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, ? extends Org>>(
|
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, Org>>(authException, seconds,
|
||||||
authException, seconds, supplier);
|
supplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
@ -232,19 +231,19 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
|
||||||
}
|
}
|
||||||
|
|
||||||
@Singleton
|
@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 Supplier<VCloudSession> sessionSupplier;
|
||||||
protected final Function<Iterable<String>, Iterable<? extends Org>> organizationsForNames;
|
protected final Function<Iterable<String>, Iterable<Org>> organizationsForNames;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected OrgMapSupplier(Supplier<VCloudSession> sessionSupplier,
|
protected OrgMapSupplier(Supplier<VCloudSession> sessionSupplier,
|
||||||
Function<Iterable<String>, Iterable<? extends Org>> organizationsForNames) {
|
Function<Iterable<String>, Iterable<Org>> organizationsForNames) {
|
||||||
this.sessionSupplier = sessionSupplier;
|
this.sessionSupplier = sessionSupplier;
|
||||||
this.organizationsForNames = organizationsForNames;
|
this.organizationsForNames = organizationsForNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, ? extends Org> get() {
|
public Map<String, Org> get() {
|
||||||
return uniqueIndex(organizationsForNames.apply(sessionSupplier.get().getOrgs().keySet()), name);
|
return uniqueIndex(organizationsForNames.apply(sessionSupplier.get().getOrgs().keySet()), name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -255,30 +254,30 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public static class OrgCatalogSupplier implements
|
public static class OrgCatalogSupplier implements
|
||||||
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> {
|
Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.Catalog>>> {
|
||||||
protected final Supplier<Map<String, ? extends Org>> orgSupplier;
|
protected final Supplier<Map<String, Org>> orgSupplier;
|
||||||
protected final Function<Org, Iterable<? extends org.jclouds.vcloud.domain.Catalog>> allCatalogsInOrg;
|
protected final Function<Org, Iterable<org.jclouds.vcloud.domain.Catalog>> allCatalogsInOrg;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected OrgCatalogSupplier(Supplier<Map<String, ? extends Org>> orgSupplier,
|
protected OrgCatalogSupplier(Supplier<Map<String, Org>> orgSupplier,
|
||||||
Function<Org, Iterable<? extends org.jclouds.vcloud.domain.Catalog>> allCatalogsInOrg) {
|
Function<Org, Iterable<org.jclouds.vcloud.domain.Catalog>> allCatalogsInOrg) {
|
||||||
this.orgSupplier = orgSupplier;
|
this.orgSupplier = orgSupplier;
|
||||||
this.allCatalogsInOrg = allCatalogsInOrg;
|
this.allCatalogsInOrg = allCatalogsInOrg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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(
|
return transformValues(
|
||||||
transformValues(orgSupplier.get(), allCatalogsInOrg),
|
transformValues(orgSupplier.get(), allCatalogsInOrg),
|
||||||
new Function<Iterable<? extends org.jclouds.vcloud.domain.Catalog>, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>() {
|
new Function<Iterable<org.jclouds.vcloud.domain.Catalog>, Map<String, org.jclouds.vcloud.domain.Catalog>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, ? extends org.jclouds.vcloud.domain.Catalog> apply(
|
public Map<String, org.jclouds.vcloud.domain.Catalog> apply(
|
||||||
Iterable<? extends org.jclouds.vcloud.domain.Catalog> from) {
|
Iterable<org.jclouds.vcloud.domain.Catalog> from) {
|
||||||
return uniqueIndex(from, name);
|
return uniqueIndex(from, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,50 +291,48 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
|
||||||
@org.jclouds.vcloud.endpoints.Org
|
@org.jclouds.vcloud.endpoints.Org
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Supplier<Map<String, ReferenceType>> provideVDCtoORG(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
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>>(
|
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, ReferenceType>>(
|
||||||
authException, seconds, supplier);
|
authException, seconds, supplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Supplier<Map<URI, ? extends org.jclouds.vcloud.domain.VDC>> provideURIToVDC(
|
protected Supplier<Map<URI, org.jclouds.vcloud.domain.VDC>> provideURIToVDC(
|
||||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference<AuthorizationException> authException,
|
@Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference<AuthorizationException> authException,
|
||||||
URItoVDC supplier) {
|
URItoVDC supplier) {
|
||||||
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<URI, ? extends org.jclouds.vcloud.domain.VDC>>(
|
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<URI, org.jclouds.vcloud.domain.VDC>>(
|
||||||
authException, seconds, supplier);
|
authException, seconds, supplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public static class URItoVDC implements Supplier<Map<URI, ? extends org.jclouds.vcloud.domain.VDC>> {
|
public static class URItoVDC implements Supplier<Map<URI, org.jclouds.vcloud.domain.VDC>> {
|
||||||
private final Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> orgVDCMap;
|
private final Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.VDC>>> orgVDCMap;
|
||||||
|
|
||||||
@Inject
|
@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;
|
this.orgVDCMap = orgVDCMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<URI, ? extends org.jclouds.vcloud.domain.VDC> get() {
|
public Map<URI, org.jclouds.vcloud.domain.VDC> get() {
|
||||||
return uniqueIndex(
|
return uniqueIndex(concat(transform(orgVDCMap.get().values(),
|
||||||
concat(transform(
|
new Function<Map<String, org.jclouds.vcloud.domain.VDC>, Iterable<org.jclouds.vcloud.domain.VDC>>() {
|
||||||
orgVDCMap.get().values(),
|
|
||||||
new Function<Map<String, ? extends org.jclouds.vcloud.domain.VDC>, Iterable<? extends org.jclouds.vcloud.domain.VDC>>() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<? extends org.jclouds.vcloud.domain.VDC> apply(
|
public Iterable<org.jclouds.vcloud.domain.VDC> apply(
|
||||||
Map<String, ? extends org.jclouds.vcloud.domain.VDC> from) {
|
Map<String, org.jclouds.vcloud.domain.VDC> from) {
|
||||||
return from.values();
|
return from.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
})), new Function<org.jclouds.vcloud.domain.VDC, URI>() {
|
})), new Function<org.jclouds.vcloud.domain.VDC, URI>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URI apply(org.jclouds.vcloud.domain.VDC from) {
|
public URI apply(org.jclouds.vcloud.domain.VDC from) {
|
||||||
return from.getHref();
|
return from.getHref();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -353,7 +350,8 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
|
||||||
@Singleton
|
@Singleton
|
||||||
@org.jclouds.vcloud.endpoints.VCloudLogin
|
@org.jclouds.vcloud.endpoints.VCloudLogin
|
||||||
protected URI provideAuthenticationURI(VCloudVersionsAsyncClient versionService,
|
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);
|
SortedMap<String, URI> versions = versionService.getSupportedVersions().get(180, TimeUnit.SECONDS);
|
||||||
checkState(versions.size() > 0, "No versions present");
|
checkState(versions.size() > 0, "No versions present");
|
||||||
checkState(versions.containsKey(version), "version " + version + " not present in: " + versions);
|
checkState(versions.containsKey(version), "version " + version + " not present in: " + versions);
|
||||||
|
@ -385,110 +383,108 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Org provideOrg(Supplier<Map<String, ? extends Org>> orgSupplier,
|
protected Org provideOrg(Supplier<Map<String, Org>> orgSupplier,
|
||||||
@org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) {
|
@org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) {
|
||||||
return orgSupplier.get().get(defaultOrg.getName());
|
return orgSupplier.get().get(defaultOrg.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Predicate<URI> successTester(Injector injector,
|
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);
|
return new RetryablePredicate<URI>(injector.getInstance(TaskSuccess.class), completed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> provideOrgCatalogItemMapSupplierCache(
|
protected Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.Catalog>>> provideOrgCatalogItemMapSupplierCache(
|
||||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference<AuthorizationException> authException,
|
@Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference<AuthorizationException> authException,
|
||||||
OrgCatalogSupplier supplier) {
|
OrgCatalogSupplier supplier) {
|
||||||
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>>(
|
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, Map<String, org.jclouds.vcloud.domain.Catalog>>>(
|
||||||
authException, seconds, supplier);
|
authException, seconds, supplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
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,
|
@Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference<AuthorizationException> authException,
|
||||||
OrgVDCSupplier supplier) {
|
OrgVDCSupplier supplier) {
|
||||||
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>>(
|
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, Map<String, org.jclouds.vcloud.domain.VDC>>>(
|
||||||
authException, seconds, supplier);
|
authException, seconds, supplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public static class OrgVDCSupplier implements
|
public static class OrgVDCSupplier implements Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.VDC>>> {
|
||||||
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> {
|
protected final Supplier<Map<String, Org>> orgSupplier;
|
||||||
protected final Supplier<Map<String, ? extends Org>> orgSupplier;
|
private final Function<Org, Iterable<org.jclouds.vcloud.domain.VDC>> allVDCsInOrg;
|
||||||
private final Function<Org, Iterable<? extends org.jclouds.vcloud.domain.VDC>> allVDCsInOrg;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected OrgVDCSupplier(Supplier<Map<String, ? extends Org>> orgSupplier,
|
protected OrgVDCSupplier(Supplier<Map<String, Org>> orgSupplier,
|
||||||
Function<Org, Iterable<? extends org.jclouds.vcloud.domain.VDC>> allVDCsInOrg) {
|
Function<Org, Iterable<org.jclouds.vcloud.domain.VDC>> allVDCsInOrg) {
|
||||||
this.orgSupplier = orgSupplier;
|
this.orgSupplier = orgSupplier;
|
||||||
this.allVDCsInOrg = allVDCsInOrg;
|
this.allVDCsInOrg = allVDCsInOrg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> get() {
|
public Map<String, Map<String, org.jclouds.vcloud.domain.VDC>> get() {
|
||||||
return transformValues(
|
return transformValues(transformValues(orgSupplier.get(), allVDCsInOrg),
|
||||||
transformValues(orgSupplier.get(), allVDCsInOrg),
|
new Function<Iterable<org.jclouds.vcloud.domain.VDC>, Map<String, org.jclouds.vcloud.domain.VDC>>() {
|
||||||
new Function<Iterable<? extends org.jclouds.vcloud.domain.VDC>, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, ? extends org.jclouds.vcloud.domain.VDC> apply(
|
public Map<String, org.jclouds.vcloud.domain.VDC> apply(
|
||||||
Iterable<? extends org.jclouds.vcloud.domain.VDC> from) {
|
Iterable<org.jclouds.vcloud.domain.VDC> from) {
|
||||||
return uniqueIndex(from, name);
|
return uniqueIndex(from, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public static class OrgCatalogItemSupplier implements
|
public static class OrgCatalogItemSupplier implements
|
||||||
Supplier<Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>> {
|
Supplier<Map<String, Map<String, Map<String, org.jclouds.vcloud.domain.CatalogItem>>>> {
|
||||||
protected final Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> catalogSupplier;
|
protected final Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.Catalog>>> catalogSupplier;
|
||||||
protected final Function<org.jclouds.vcloud.domain.Catalog, Iterable<? extends CatalogItem>> allCatalogItemsInCatalog;
|
protected final Function<org.jclouds.vcloud.domain.Catalog, Iterable<CatalogItem>> allCatalogItemsInCatalog;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected OrgCatalogItemSupplier(
|
protected OrgCatalogItemSupplier(
|
||||||
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> catalogSupplier,
|
Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.Catalog>>> catalogSupplier,
|
||||||
Function<org.jclouds.vcloud.domain.Catalog, Iterable<? extends CatalogItem>> allCatalogItemsInCatalog) {
|
Function<org.jclouds.vcloud.domain.Catalog, Iterable<CatalogItem>> allCatalogItemsInCatalog) {
|
||||||
this.catalogSupplier = catalogSupplier;
|
this.catalogSupplier = catalogSupplier;
|
||||||
this.allCatalogItemsInCatalog = allCatalogItemsInCatalog;
|
this.allCatalogItemsInCatalog = allCatalogItemsInCatalog;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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(
|
return transformValues(
|
||||||
catalogSupplier.get(),
|
catalogSupplier.get(),
|
||||||
new Function<Map<String, ? extends org.jclouds.vcloud.domain.Catalog>, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>() {
|
new Function<Map<String, org.jclouds.vcloud.domain.Catalog>, Map<String, Map<String, org.jclouds.vcloud.domain.CatalogItem>>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Map<String, ? extends CatalogItem>> apply(
|
public Map<String, Map<String, CatalogItem>> apply(
|
||||||
Map<String, ? extends org.jclouds.vcloud.domain.Catalog> from) {
|
Map<String, org.jclouds.vcloud.domain.Catalog> from) {
|
||||||
return transformValues(
|
return transformValues(
|
||||||
from,
|
from,
|
||||||
new Function<org.jclouds.vcloud.domain.Catalog, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>() {
|
new Function<org.jclouds.vcloud.domain.Catalog, Map<String, org.jclouds.vcloud.domain.CatalogItem>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, ? extends CatalogItem> apply(org.jclouds.vcloud.domain.Catalog from) {
|
public Map<String, CatalogItem> apply(org.jclouds.vcloud.domain.Catalog from) {
|
||||||
return uniqueIndex(filter(allCatalogItemsInCatalog.apply(from), notNull()), name);
|
return uniqueIndex(filter(allCatalogItemsInCatalog.apply(from), notNull()), name);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Supplier<Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>> provideOrgCatalogItemSupplierCache(
|
protected Supplier<Map<String, Map<String, Map<String, org.jclouds.vcloud.domain.CatalogItem>>>> provideOrgCatalogItemSupplierCache(
|
||||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference<AuthorizationException> authException,
|
@Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference<AuthorizationException> authException,
|
||||||
OrgCatalogItemSupplier supplier) {
|
OrgCatalogItemSupplier supplier) {
|
||||||
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>>(
|
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, Map<String, Map<String, org.jclouds.vcloud.domain.CatalogItem>>>>(
|
||||||
authException, seconds, supplier);
|
authException, seconds, supplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class InstantiateVAppTemplateParams {
|
||||||
protected final VirtualSystemSettingData virtualSystem;
|
protected final VirtualSystemSettingData virtualSystem;
|
||||||
protected final Set<ResourceAllocationSettingData> resourceAllocations = Sets.newLinkedHashSet();
|
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.info = info;
|
||||||
this.virtualSystem = virtualSystem;
|
this.virtualSystem = virtualSystem;
|
||||||
Iterables.addAll(this.resourceAllocations, resourceAllocations);
|
Iterables.addAll(this.resourceAllocations, resourceAllocations);
|
||||||
|
@ -49,7 +49,7 @@ public class InstantiateVAppTemplateParams {
|
||||||
return virtualSystem;
|
return virtualSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<? extends ResourceAllocationSettingData> getResourceAllocationSettingDatas() {
|
public Set<ResourceAllocationSettingData> getResourceAllocationSettingDatas() {
|
||||||
return resourceAllocations;
|
return resourceAllocations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class NetworkConnectionSection {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder connections(Iterable<? extends NetworkConnection> connections) {
|
public Builder connections(Iterable<NetworkConnection> connections) {
|
||||||
this.connections = ImmutableSet.copyOf(checkNotNull(connections, "connections"));
|
this.connections = ImmutableSet.copyOf(checkNotNull(connections, "connections"));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ public class NetworkConnectionSection {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public Set<? extends NetworkConnection> getConnections() {
|
public Set<NetworkConnection> getConnections() {
|
||||||
return connections;
|
return connections;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,6 @@ public interface VApp extends ReferenceType {
|
||||||
*
|
*
|
||||||
* @since vcloud api 1.0
|
* @since vcloud api 1.0
|
||||||
*/
|
*/
|
||||||
Set<? extends Vm> getChildren();
|
Set<Vm> getChildren();
|
||||||
|
|
||||||
}
|
}
|
|
@ -87,7 +87,7 @@ public interface VAppTemplate extends ReferenceType {
|
||||||
*
|
*
|
||||||
* @since vcloud api 1.0
|
* @since vcloud api 1.0
|
||||||
*/
|
*/
|
||||||
Set<? extends Vm> getChildren();
|
Set<Vm> getChildren();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* description of the predefined vApp internal networks in this template
|
* description of the predefined vApp internal networks in this template
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class VAppImpl extends ReferenceTypeImpl implements VApp {
|
||||||
private final Set<Vm> children = Sets.newLinkedHashSet();
|
private final Set<Vm> children = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
public VAppImpl(String name, String type, URI id, Status status, ReferenceType vdc, @Nullable String description,
|
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);
|
super(name, type, id);
|
||||||
this.status = checkNotNull(status, "status");
|
this.status = checkNotNull(status, "status");
|
||||||
this.vdc = vdc;// TODO: once <1.0 is killed check not null
|
this.vdc = vdc;// TODO: once <1.0 is killed check not null
|
||||||
|
@ -107,7 +107,7 @@ public class VAppImpl extends ReferenceTypeImpl implements VApp {
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Set<? extends Vm> getChildren() {
|
public Set<Vm> getChildren() {
|
||||||
return children;
|
return children;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class VAppTemplateImpl extends ReferenceTypeImpl implements VAppTemplate
|
||||||
|
|
||||||
public VAppTemplateImpl(String name, String type, URI id, Status status, ReferenceType vdc,
|
public VAppTemplateImpl(String name, String type, URI id, Status status, ReferenceType vdc,
|
||||||
@Nullable String description, Iterable<Task> tasks, boolean ovfDescriptorUploaded,
|
@Nullable String description, Iterable<Task> tasks, boolean ovfDescriptorUploaded,
|
||||||
@Nullable String vAppScopedLocalId, Iterable<? extends Vm> children,
|
@Nullable String vAppScopedLocalId, Iterable<Vm> children,
|
||||||
@Nullable VCloudNetworkSection networkSection) {
|
@Nullable VCloudNetworkSection networkSection) {
|
||||||
super(name, type, id);
|
super(name, type, id);
|
||||||
this.status = checkNotNull(status, "status");
|
this.status = checkNotNull(status, "status");
|
||||||
|
@ -123,7 +123,7 @@ public class VAppTemplateImpl extends ReferenceTypeImpl implements VAppTemplate
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Set<? extends Vm> getChildren() {
|
public Set<Vm> getChildren() {
|
||||||
return children;
|
return children;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class FirewallService {
|
||||||
|
|
||||||
List<FirewallRule> firewallRules = Lists.newArrayList();
|
List<FirewallRule> firewallRules = Lists.newArrayList();
|
||||||
|
|
||||||
public FirewallService(boolean enabled, Iterable<? extends FirewallRule> firewallRules) {
|
public FirewallService(boolean enabled, Iterable<FirewallRule> firewallRules) {
|
||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
Iterables.addAll(this.firewallRules, checkNotNull(firewallRules, "firewallRules"));
|
Iterables.addAll(this.firewallRules, checkNotNull(firewallRules, "firewallRules"));
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public class FirewallService {
|
||||||
*
|
*
|
||||||
* @since vcloud api 0.8
|
* @since vcloud api 0.8
|
||||||
*/
|
*/
|
||||||
public List<? extends FirewallRule> getFirewallRules() {
|
public List<FirewallRule> getFirewallRules() {
|
||||||
return firewallRules;
|
return firewallRules;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class NatService {
|
||||||
private final List<NatRule> natRules = Lists.newArrayList();
|
private final List<NatRule> natRules = Lists.newArrayList();
|
||||||
|
|
||||||
public NatService(boolean enabled, @Nullable NatType type, @Nullable NatPolicy policy,
|
public NatService(boolean enabled, @Nullable NatType type, @Nullable NatPolicy policy,
|
||||||
Iterable<? extends NatRule> natRules) {
|
Iterable<NatRule> natRules) {
|
||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.policy = policy;
|
this.policy = policy;
|
||||||
|
@ -55,7 +55,7 @@ public class NatService {
|
||||||
*
|
*
|
||||||
* @since vcloud api 0.8
|
* @since vcloud api 0.8
|
||||||
*/
|
*/
|
||||||
public List<? extends NatRule> getNatRules() {
|
public List<NatRule> getNatRules() {
|
||||||
return natRules;
|
return natRules;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ public interface CatalogAsyncClient {
|
||||||
@XMLResponseParser(CatalogHandler.class)
|
@XMLResponseParser(CatalogHandler.class)
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
@Consumes(CATALOG_XML)
|
@Consumes(CATALOG_XML)
|
||||||
ListenableFuture<? extends Catalog> getCatalog(@EndpointParam URI catalogId);
|
ListenableFuture<Catalog> getCatalog(@EndpointParam URI catalogId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see CatalogClient#findCatalogInOrgNamed
|
* @see CatalogClient#findCatalogInOrgNamed
|
||||||
|
@ -76,7 +76,7 @@ public interface CatalogAsyncClient {
|
||||||
@XMLResponseParser(CatalogHandler.class)
|
@XMLResponseParser(CatalogHandler.class)
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
@Consumes(CATALOG_XML)
|
@Consumes(CATALOG_XML)
|
||||||
ListenableFuture<? extends Catalog> findCatalogInOrgNamed(
|
ListenableFuture<Catalog> findCatalogInOrgNamed(
|
||||||
@Nullable @EndpointParam(parser = OrgNameAndCatalogNameToEndpoint.class) String orgName,
|
@Nullable @EndpointParam(parser = OrgNameAndCatalogNameToEndpoint.class) String orgName,
|
||||||
@Nullable @EndpointParam(parser = OrgNameAndCatalogNameToEndpoint.class) String catalogName);
|
@Nullable @EndpointParam(parser = OrgNameAndCatalogNameToEndpoint.class) String catalogName);
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ public interface CatalogAsyncClient {
|
||||||
@Consumes(CATALOGITEM_XML)
|
@Consumes(CATALOGITEM_XML)
|
||||||
@XMLResponseParser(CatalogItemHandler.class)
|
@XMLResponseParser(CatalogItemHandler.class)
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
ListenableFuture<? extends CatalogItem> getCatalogItem(@EndpointParam URI catalogItem);
|
ListenableFuture<CatalogItem> getCatalogItem(@EndpointParam URI catalogItem);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see CatalogClient#getCatalogItemInOrg
|
* @see CatalogClient#getCatalogItemInOrg
|
||||||
|
@ -96,7 +96,7 @@ public interface CatalogAsyncClient {
|
||||||
@Consumes(CATALOGITEM_XML)
|
@Consumes(CATALOGITEM_XML)
|
||||||
@XMLResponseParser(CatalogItemHandler.class)
|
@XMLResponseParser(CatalogItemHandler.class)
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
ListenableFuture<? extends CatalogItem> findCatalogItemInOrgCatalogNamed(
|
ListenableFuture<CatalogItem> findCatalogItemInOrgCatalogNamed(
|
||||||
@Nullable @EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String orgName,
|
@Nullable @EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String orgName,
|
||||||
@Nullable @EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String catalogName,
|
@Nullable @EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String catalogName,
|
||||||
@EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String itemName);
|
@EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String itemName);
|
||||||
|
@ -110,7 +110,7 @@ public interface CatalogAsyncClient {
|
||||||
@Produces(CATALOGITEM_XML)
|
@Produces(CATALOGITEM_XML)
|
||||||
@MapBinder(BindCatalogItemToXmlPayload.class)
|
@MapBinder(BindCatalogItemToXmlPayload.class)
|
||||||
@XMLResponseParser(CatalogItemHandler.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);
|
@EndpointParam URI catalog, @PayloadParam("name") String name, CatalogItemOptions... options);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ public interface NetworkAsyncClient {
|
||||||
@Consumes(NETWORK_XML)
|
@Consumes(NETWORK_XML)
|
||||||
@XMLResponseParser(OrgNetworkHandler.class)
|
@XMLResponseParser(OrgNetworkHandler.class)
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
ListenableFuture<? extends OrgNetwork> findNetworkInOrgVDCNamed(
|
ListenableFuture<OrgNetwork> findNetworkInOrgVDCNamed(
|
||||||
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String orgName,
|
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String orgName,
|
||||||
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String catalogName,
|
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String catalogName,
|
||||||
@EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String networkName);
|
@EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String networkName);
|
||||||
|
@ -66,6 +66,6 @@ public interface NetworkAsyncClient {
|
||||||
@Consumes(NETWORK_XML)
|
@Consumes(NETWORK_XML)
|
||||||
@XMLResponseParser(OrgNetworkHandler.class)
|
@XMLResponseParser(OrgNetworkHandler.class)
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
ListenableFuture<? extends OrgNetwork> getNetwork(@EndpointParam URI network);
|
ListenableFuture<OrgNetwork> getNetwork(@EndpointParam URI network);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ public interface OrgAsyncClient {
|
||||||
@XMLResponseParser(OrgHandler.class)
|
@XMLResponseParser(OrgHandler.class)
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
@Consumes(ORG_XML)
|
@Consumes(ORG_XML)
|
||||||
ListenableFuture<? extends Org> getOrg(@EndpointParam URI orgId);
|
ListenableFuture<Org> getOrg(@EndpointParam URI orgId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see OrgClient#getOrgNamed
|
* @see OrgClient#getOrgNamed
|
||||||
|
@ -79,6 +79,6 @@ public interface OrgAsyncClient {
|
||||||
@XMLResponseParser(OrgHandler.class)
|
@XMLResponseParser(OrgHandler.class)
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
@Consumes(ORG_XML)
|
@Consumes(ORG_XML)
|
||||||
ListenableFuture<? extends Org> findOrgNamed(
|
ListenableFuture<Org> findOrgNamed(
|
||||||
@Nullable @EndpointParam(parser = OrgNameToEndpoint.class) String orgName);
|
@Nullable @EndpointParam(parser = OrgNameToEndpoint.class) String orgName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ public interface TaskAsyncClient {
|
||||||
@Consumes(TASKSLIST_XML)
|
@Consumes(TASKSLIST_XML)
|
||||||
@XMLResponseParser(TasksListHandler.class)
|
@XMLResponseParser(TasksListHandler.class)
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
ListenableFuture<? extends TasksList> getTasksList(@EndpointParam URI tasksListId);
|
ListenableFuture<TasksList> getTasksList(@EndpointParam URI tasksListId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see TaskClient#findTasksListInOrgNamed
|
* @see TaskClient#findTasksListInOrgNamed
|
||||||
|
@ -68,7 +68,7 @@ public interface TaskAsyncClient {
|
||||||
@Consumes(TASKSLIST_XML)
|
@Consumes(TASKSLIST_XML)
|
||||||
@XMLResponseParser(TasksListHandler.class)
|
@XMLResponseParser(TasksListHandler.class)
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
ListenableFuture<? extends TasksList> findTasksListInOrgNamed(
|
ListenableFuture<TasksList> findTasksListInOrgNamed(
|
||||||
@Nullable @EndpointParam(parser = OrgNameToTasksListEndpoint.class) String orgName);
|
@Nullable @EndpointParam(parser = OrgNameToTasksListEndpoint.class) String orgName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,7 +78,7 @@ public interface TaskAsyncClient {
|
||||||
@Consumes(TASK_XML)
|
@Consumes(TASK_XML)
|
||||||
@XMLResponseParser(TaskHandler.class)
|
@XMLResponseParser(TaskHandler.class)
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
ListenableFuture<? extends Task> getTask(@EndpointParam URI taskId);
|
ListenableFuture<Task> getTask(@EndpointParam URI taskId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see TaskClient#cancelTask
|
* @see TaskClient#cancelTask
|
||||||
|
|
|
@ -75,7 +75,7 @@ public interface VAppAsyncClient {
|
||||||
@Consumes(TASK_XML)
|
@Consumes(TASK_XML)
|
||||||
@XMLResponseParser(TaskHandler.class)
|
@XMLResponseParser(TaskHandler.class)
|
||||||
@MapBinder(BindCloneVAppParamsToXmlPayload.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,
|
@EndpointParam URI vdc, @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String newName,
|
||||||
CloneVAppOptions... options);
|
CloneVAppOptions... options);
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ public interface VAppAsyncClient {
|
||||||
@XMLResponseParser(TaskHandler.class)
|
@XMLResponseParser(TaskHandler.class)
|
||||||
@PayloadParams(keys = "IsSourceDelete", values = "true")
|
@PayloadParams(keys = "IsSourceDelete", values = "true")
|
||||||
@MapBinder(BindCloneVAppParamsToXmlPayload.class)
|
@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,
|
@EndpointParam URI vdc, @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String newName,
|
||||||
CloneVAppOptions... options);
|
CloneVAppOptions... options);
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ public interface VAppAsyncClient {
|
||||||
@Consumes(VAPP_XML)
|
@Consumes(VAPP_XML)
|
||||||
@XMLResponseParser(VAppHandler.class)
|
@XMLResponseParser(VAppHandler.class)
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
ListenableFuture<? extends VApp> findVAppInOrgVDCNamed(
|
ListenableFuture<VApp> findVAppInOrgVDCNamed(
|
||||||
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String orgName,
|
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String orgName,
|
||||||
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String catalogName,
|
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String catalogName,
|
||||||
@EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String vAppName);
|
@EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String vAppName);
|
||||||
|
@ -112,7 +112,7 @@ public interface VAppAsyncClient {
|
||||||
@Consumes(VAPP_XML)
|
@Consumes(VAPP_XML)
|
||||||
@XMLResponseParser(VAppHandler.class)
|
@XMLResponseParser(VAppHandler.class)
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
ListenableFuture<? extends VApp> getVApp(@EndpointParam URI href);
|
ListenableFuture<VApp> getVApp(@EndpointParam URI href);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VAppClient#deployVApp
|
* @see VAppClient#deployVApp
|
||||||
|
@ -123,7 +123,7 @@ public interface VAppAsyncClient {
|
||||||
@Path("/action/deploy")
|
@Path("/action/deploy")
|
||||||
@MapBinder(BindDeployVAppParamsToXmlPayload.class)
|
@MapBinder(BindDeployVAppParamsToXmlPayload.class)
|
||||||
@XMLResponseParser(TaskHandler.class)
|
@XMLResponseParser(TaskHandler.class)
|
||||||
ListenableFuture<? extends Task> deployVApp(@EndpointParam URI href);
|
ListenableFuture<Task> deployVApp(@EndpointParam URI href);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VAppClient#deployAndPowerOnVApp
|
* @see VAppClient#deployAndPowerOnVApp
|
||||||
|
@ -135,7 +135,7 @@ public interface VAppAsyncClient {
|
||||||
@MapBinder(BindDeployVAppParamsToXmlPayload.class)
|
@MapBinder(BindDeployVAppParamsToXmlPayload.class)
|
||||||
@PayloadParams(keys = "powerOn", values = "true")
|
@PayloadParams(keys = "powerOn", values = "true")
|
||||||
@XMLResponseParser(TaskHandler.class)
|
@XMLResponseParser(TaskHandler.class)
|
||||||
ListenableFuture<? extends Task> deployAndPowerOnVApp(@EndpointParam URI href);
|
ListenableFuture<Task> deployAndPowerOnVApp(@EndpointParam URI href);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VAppClient#undeployVApp
|
* @see VAppClient#undeployVApp
|
||||||
|
@ -146,7 +146,7 @@ public interface VAppAsyncClient {
|
||||||
@Path("/action/undeploy")
|
@Path("/action/undeploy")
|
||||||
@MapBinder(BindUndeployVAppParamsToXmlPayload.class)
|
@MapBinder(BindUndeployVAppParamsToXmlPayload.class)
|
||||||
@XMLResponseParser(TaskHandler.class)
|
@XMLResponseParser(TaskHandler.class)
|
||||||
ListenableFuture<? extends Task> undeployVApp(@EndpointParam URI href);
|
ListenableFuture<Task> undeployVApp(@EndpointParam URI href);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VAppClient#undeployAndSaveStateOfVApp
|
* @see VAppClient#undeployAndSaveStateOfVApp
|
||||||
|
@ -158,7 +158,7 @@ public interface VAppAsyncClient {
|
||||||
@MapBinder(BindUndeployVAppParamsToXmlPayload.class)
|
@MapBinder(BindUndeployVAppParamsToXmlPayload.class)
|
||||||
@PayloadParams(keys = "saveState", values = "true")
|
@PayloadParams(keys = "saveState", values = "true")
|
||||||
@XMLResponseParser(TaskHandler.class)
|
@XMLResponseParser(TaskHandler.class)
|
||||||
ListenableFuture<? extends Task> undeployAndSaveStateOfVApp(@EndpointParam URI href);
|
ListenableFuture<Task> undeployAndSaveStateOfVApp(@EndpointParam URI href);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VAppClient#powerOnVApp
|
* @see VAppClient#powerOnVApp
|
||||||
|
@ -167,7 +167,7 @@ public interface VAppAsyncClient {
|
||||||
@Consumes(TASK_XML)
|
@Consumes(TASK_XML)
|
||||||
@Path("/power/action/powerOn")
|
@Path("/power/action/powerOn")
|
||||||
@XMLResponseParser(TaskHandler.class)
|
@XMLResponseParser(TaskHandler.class)
|
||||||
ListenableFuture<? extends Task> powerOnVApp(@EndpointParam URI href);
|
ListenableFuture<Task> powerOnVApp(@EndpointParam URI href);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VAppClient#powerOffVApp
|
* @see VAppClient#powerOffVApp
|
||||||
|
@ -176,7 +176,7 @@ public interface VAppAsyncClient {
|
||||||
@Consumes(TASK_XML)
|
@Consumes(TASK_XML)
|
||||||
@Path("/power/action/powerOff")
|
@Path("/power/action/powerOff")
|
||||||
@XMLResponseParser(TaskHandler.class)
|
@XMLResponseParser(TaskHandler.class)
|
||||||
ListenableFuture<? extends Task> powerOffVApp(@EndpointParam URI href);
|
ListenableFuture<Task> powerOffVApp(@EndpointParam URI href);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VAppClient#shutdownVApp
|
* @see VAppClient#shutdownVApp
|
||||||
|
@ -192,7 +192,7 @@ public interface VAppAsyncClient {
|
||||||
@Consumes(TASK_XML)
|
@Consumes(TASK_XML)
|
||||||
@Path("/power/action/reset")
|
@Path("/power/action/reset")
|
||||||
@XMLResponseParser(TaskHandler.class)
|
@XMLResponseParser(TaskHandler.class)
|
||||||
ListenableFuture<? extends Task> resetVApp(@EndpointParam URI href);
|
ListenableFuture<Task> resetVApp(@EndpointParam URI href);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VAppClient#rebootVApp
|
* @see VAppClient#rebootVApp
|
||||||
|
@ -208,7 +208,7 @@ public interface VAppAsyncClient {
|
||||||
@Consumes(TASK_XML)
|
@Consumes(TASK_XML)
|
||||||
@Path("/power/action/suspend")
|
@Path("/power/action/suspend")
|
||||||
@XMLResponseParser(TaskHandler.class)
|
@XMLResponseParser(TaskHandler.class)
|
||||||
ListenableFuture<? extends Task> suspendVApp(@EndpointParam URI href);
|
ListenableFuture<Task> suspendVApp(@EndpointParam URI href);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VAppClient#deleteVApp
|
* @see VAppClient#deleteVApp
|
||||||
|
@ -217,6 +217,6 @@ public interface VAppAsyncClient {
|
||||||
@Consumes(TASK_XML)
|
@Consumes(TASK_XML)
|
||||||
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
||||||
@XMLResponseParser(TaskHandler.class)
|
@XMLResponseParser(TaskHandler.class)
|
||||||
ListenableFuture<? extends Task> deleteVApp(@EndpointParam URI href);
|
ListenableFuture<Task> deleteVApp(@EndpointParam URI href);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ public interface VAppTemplateAsyncClient {
|
||||||
@Consumes(VAPP_XML)
|
@Consumes(VAPP_XML)
|
||||||
@XMLResponseParser(VAppHandler.class)
|
@XMLResponseParser(VAppHandler.class)
|
||||||
@MapBinder(BindInstantiateVAppTemplateParamsToXmlPayload.class)
|
@MapBinder(BindInstantiateVAppTemplateParamsToXmlPayload.class)
|
||||||
ListenableFuture<? extends VApp> createVAppInVDCByInstantiatingTemplate(
|
ListenableFuture<VApp> createVAppInVDCByInstantiatingTemplate(
|
||||||
@PayloadParam("name") @ParamValidators(DnsNameValidator.class) String appName, @EndpointParam URI vdc,
|
@PayloadParam("name") @ParamValidators(DnsNameValidator.class) String appName, @EndpointParam URI vdc,
|
||||||
@PayloadParam("template") URI template, InstantiateVAppTemplateOptions... options);
|
@PayloadParam("template") URI template, InstantiateVAppTemplateOptions... options);
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ public interface VAppTemplateAsyncClient {
|
||||||
@Path("/ovf")
|
@Path("/ovf")
|
||||||
@XMLResponseParser(EnvelopeHandler.class)
|
@XMLResponseParser(EnvelopeHandler.class)
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
ListenableFuture<? extends Envelope> getOvfEnvelopeForVAppTemplate(@EndpointParam URI href);
|
ListenableFuture<Envelope> getOvfEnvelopeForVAppTemplate(@EndpointParam URI href);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VAppTemplateClient#captureVAppAsTemplateInVDC
|
* @see VAppTemplateClient#captureVAppAsTemplateInVDC
|
||||||
|
@ -104,7 +104,7 @@ public interface VAppTemplateAsyncClient {
|
||||||
@Consumes(VAPPTEMPLATE_XML)
|
@Consumes(VAPPTEMPLATE_XML)
|
||||||
@XMLResponseParser(VAppTemplateHandler.class)
|
@XMLResponseParser(VAppTemplateHandler.class)
|
||||||
@MapBinder(BindCaptureVAppParamsToXmlPayload.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,
|
@PayloadParam("templateName") @ParamValidators(DnsNameValidator.class) String templateName,
|
||||||
@EndpointParam URI vdc, CaptureVAppOptions... options);
|
@EndpointParam URI vdc, CaptureVAppOptions... options);
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ public interface VAppTemplateAsyncClient {
|
||||||
@Consumes(TASK_XML)
|
@Consumes(TASK_XML)
|
||||||
@XMLResponseParser(TaskHandler.class)
|
@XMLResponseParser(TaskHandler.class)
|
||||||
@MapBinder(BindCloneVAppTemplateParamsToXmlPayload.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,
|
@EndpointParam URI vdc, @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String newName,
|
||||||
CloneVAppTemplateOptions... options);
|
CloneVAppTemplateOptions... options);
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ public interface VAppTemplateAsyncClient {
|
||||||
@XMLResponseParser(TaskHandler.class)
|
@XMLResponseParser(TaskHandler.class)
|
||||||
@PayloadParams(keys = "IsSourceDelete", values = "true")
|
@PayloadParams(keys = "IsSourceDelete", values = "true")
|
||||||
@MapBinder(BindCloneVAppTemplateParamsToXmlPayload.class)
|
@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,
|
@EndpointParam URI vdc, @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String newName,
|
||||||
CloneVAppTemplateOptions... options);
|
CloneVAppTemplateOptions... options);
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ public interface VAppTemplateAsyncClient {
|
||||||
@Consumes(VAPPTEMPLATE_XML)
|
@Consumes(VAPPTEMPLATE_XML)
|
||||||
@XMLResponseParser(VAppTemplateHandler.class)
|
@XMLResponseParser(VAppTemplateHandler.class)
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
ListenableFuture<? extends VAppTemplate> findVAppTemplateInOrgCatalogNamed(
|
ListenableFuture<VAppTemplate> findVAppTemplateInOrgCatalogNamed(
|
||||||
@Nullable @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String orgName,
|
@Nullable @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String orgName,
|
||||||
@Nullable @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String catalogName,
|
@Nullable @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String catalogName,
|
||||||
@EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String itemName);
|
@EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String itemName);
|
||||||
|
@ -154,7 +154,7 @@ public interface VAppTemplateAsyncClient {
|
||||||
@Consumes(VAPPTEMPLATE_XML)
|
@Consumes(VAPPTEMPLATE_XML)
|
||||||
@XMLResponseParser(VAppTemplateHandler.class)
|
@XMLResponseParser(VAppTemplateHandler.class)
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
ListenableFuture<? extends VAppTemplate> getVAppTemplate(@EndpointParam URI vAppTemplate);
|
ListenableFuture<VAppTemplate> getVAppTemplate(@EndpointParam URI vAppTemplate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VAppTemplateClient#deleteVAppTemplate
|
* @see VAppTemplateClient#deleteVAppTemplate
|
||||||
|
@ -163,6 +163,6 @@ public interface VAppTemplateAsyncClient {
|
||||||
@Consumes(TASK_XML)
|
@Consumes(TASK_XML)
|
||||||
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
||||||
@XMLResponseParser(TaskHandler.class)
|
@XMLResponseParser(TaskHandler.class)
|
||||||
ListenableFuture<? extends Task> deleteVAppTemplate(@EndpointParam URI href);
|
ListenableFuture<Task> deleteVAppTemplate(@EndpointParam URI href);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ public interface VDCAsyncClient {
|
||||||
@XMLResponseParser(VDCHandler.class)
|
@XMLResponseParser(VDCHandler.class)
|
||||||
@Consumes(VDC_XML)
|
@Consumes(VDC_XML)
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
ListenableFuture<? extends VDC> getVDC(@EndpointParam URI vdc);
|
ListenableFuture<VDC> getVDC(@EndpointParam URI vdc);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VDCClient#findVDCInOrgNamed(String, String)
|
* @see VDCClient#findVDCInOrgNamed(String, String)
|
||||||
|
@ -63,7 +63,7 @@ public interface VDCAsyncClient {
|
||||||
@XMLResponseParser(VDCHandler.class)
|
@XMLResponseParser(VDCHandler.class)
|
||||||
@Consumes(VDC_XML)
|
@Consumes(VDC_XML)
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
ListenableFuture<? extends VDC> findVDCInOrgNamed(
|
ListenableFuture<VDC> findVDCInOrgNamed(
|
||||||
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String orgName,
|
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String orgName,
|
||||||
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String vdcName);
|
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String vdcName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ public interface VmAsyncClient {
|
||||||
@Consumes(VM_XML)
|
@Consumes(VM_XML)
|
||||||
@XMLResponseParser(VmHandler.class)
|
@XMLResponseParser(VmHandler.class)
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
ListenableFuture<? extends Vm> getVm(@EndpointParam URI href);
|
ListenableFuture<Vm> getVm(@EndpointParam URI href);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VmClient#deployVm
|
* @see VmClient#deployVm
|
||||||
|
@ -87,7 +87,7 @@ public interface VmAsyncClient {
|
||||||
@Path("/action/deploy")
|
@Path("/action/deploy")
|
||||||
@MapBinder(BindDeployVAppParamsToXmlPayload.class)
|
@MapBinder(BindDeployVAppParamsToXmlPayload.class)
|
||||||
@XMLResponseParser(TaskHandler.class)
|
@XMLResponseParser(TaskHandler.class)
|
||||||
ListenableFuture<? extends Task> deployVm(@EndpointParam URI href);
|
ListenableFuture<Task> deployVm(@EndpointParam URI href);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VmClient#deployAndPowerOnVm
|
* @see VmClient#deployAndPowerOnVm
|
||||||
|
@ -99,7 +99,7 @@ public interface VmAsyncClient {
|
||||||
@MapBinder(BindDeployVAppParamsToXmlPayload.class)
|
@MapBinder(BindDeployVAppParamsToXmlPayload.class)
|
||||||
@PayloadParams(keys = "powerOn", values = "true")
|
@PayloadParams(keys = "powerOn", values = "true")
|
||||||
@XMLResponseParser(TaskHandler.class)
|
@XMLResponseParser(TaskHandler.class)
|
||||||
ListenableFuture<? extends Task> deployAndPowerOnVm(@EndpointParam URI href);
|
ListenableFuture<Task> deployAndPowerOnVm(@EndpointParam URI href);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VmClient#undeployVm
|
* @see VmClient#undeployVm
|
||||||
|
@ -110,7 +110,7 @@ public interface VmAsyncClient {
|
||||||
@Path("/action/undeploy")
|
@Path("/action/undeploy")
|
||||||
@MapBinder(BindUndeployVAppParamsToXmlPayload.class)
|
@MapBinder(BindUndeployVAppParamsToXmlPayload.class)
|
||||||
@XMLResponseParser(TaskHandler.class)
|
@XMLResponseParser(TaskHandler.class)
|
||||||
ListenableFuture<? extends Task> undeployVm(@EndpointParam URI href);
|
ListenableFuture<Task> undeployVm(@EndpointParam URI href);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VmClient#undeployAndSaveStateOfVm
|
* @see VmClient#undeployAndSaveStateOfVm
|
||||||
|
@ -122,7 +122,7 @@ public interface VmAsyncClient {
|
||||||
@MapBinder(BindUndeployVAppParamsToXmlPayload.class)
|
@MapBinder(BindUndeployVAppParamsToXmlPayload.class)
|
||||||
@PayloadParams(keys = "saveState", values = "true")
|
@PayloadParams(keys = "saveState", values = "true")
|
||||||
@XMLResponseParser(TaskHandler.class)
|
@XMLResponseParser(TaskHandler.class)
|
||||||
ListenableFuture<? extends Task> undeployAndSaveStateOfVm(@EndpointParam URI href);
|
ListenableFuture<Task> undeployAndSaveStateOfVm(@EndpointParam URI href);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VmClient#powerOnVm
|
* @see VmClient#powerOnVm
|
||||||
|
@ -131,7 +131,7 @@ public interface VmAsyncClient {
|
||||||
@Consumes(TASK_XML)
|
@Consumes(TASK_XML)
|
||||||
@Path("/power/action/powerOn")
|
@Path("/power/action/powerOn")
|
||||||
@XMLResponseParser(TaskHandler.class)
|
@XMLResponseParser(TaskHandler.class)
|
||||||
ListenableFuture<? extends Task> powerOnVm(@EndpointParam URI href);
|
ListenableFuture<Task> powerOnVm(@EndpointParam URI href);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VmClient#powerOffVm
|
* @see VmClient#powerOffVm
|
||||||
|
@ -140,7 +140,7 @@ public interface VmAsyncClient {
|
||||||
@Consumes(TASK_XML)
|
@Consumes(TASK_XML)
|
||||||
@Path("/power/action/powerOff")
|
@Path("/power/action/powerOff")
|
||||||
@XMLResponseParser(TaskHandler.class)
|
@XMLResponseParser(TaskHandler.class)
|
||||||
ListenableFuture<? extends Task> powerOffVm(@EndpointParam URI href);
|
ListenableFuture<Task> powerOffVm(@EndpointParam URI href);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VmClient#shutdownVm
|
* @see VmClient#shutdownVm
|
||||||
|
@ -156,7 +156,7 @@ public interface VmAsyncClient {
|
||||||
@Consumes(TASK_XML)
|
@Consumes(TASK_XML)
|
||||||
@Path("/power/action/reset")
|
@Path("/power/action/reset")
|
||||||
@XMLResponseParser(TaskHandler.class)
|
@XMLResponseParser(TaskHandler.class)
|
||||||
ListenableFuture<? extends Task> resetVm(@EndpointParam URI href);
|
ListenableFuture<Task> resetVm(@EndpointParam URI href);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VmClient#rebootVm
|
* @see VmClient#rebootVm
|
||||||
|
@ -172,7 +172,7 @@ public interface VmAsyncClient {
|
||||||
@Consumes(TASK_XML)
|
@Consumes(TASK_XML)
|
||||||
@Path("/power/action/suspend")
|
@Path("/power/action/suspend")
|
||||||
@XMLResponseParser(TaskHandler.class)
|
@XMLResponseParser(TaskHandler.class)
|
||||||
ListenableFuture<? extends Task> suspendVm(@EndpointParam URI href);
|
ListenableFuture<Task> suspendVm(@EndpointParam URI href);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VmClient#updateCPUCountOfVm
|
* @see VmClient#updateCPUCountOfVm
|
||||||
|
@ -182,7 +182,7 @@ public interface VmAsyncClient {
|
||||||
@Produces(RASDITEM_XML)
|
@Produces(RASDITEM_XML)
|
||||||
@Path("/virtualHardwareSection/cpu")
|
@Path("/virtualHardwareSection/cpu")
|
||||||
@XMLResponseParser(TaskHandler.class)
|
@XMLResponseParser(TaskHandler.class)
|
||||||
ListenableFuture<? extends Task> updateCPUCountOfVm(@BinderParam(BindCPUCountToXmlPayload.class) int cpuCount,
|
ListenableFuture<Task> updateCPUCountOfVm(@BinderParam(BindCPUCountToXmlPayload.class) int cpuCount,
|
||||||
@EndpointParam URI href);
|
@EndpointParam URI href);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -193,7 +193,7 @@ public interface VmAsyncClient {
|
||||||
@Produces(RASDITEM_XML)
|
@Produces(RASDITEM_XML)
|
||||||
@Path("/virtualHardwareSection/memory")
|
@Path("/virtualHardwareSection/memory")
|
||||||
@XMLResponseParser(TaskHandler.class)
|
@XMLResponseParser(TaskHandler.class)
|
||||||
ListenableFuture<? extends Task> updateMemoryMBOfVm(@BinderParam(BindMemoryToXmlPayload.class) int memoryInMB,
|
ListenableFuture<Task> updateMemoryMBOfVm(@BinderParam(BindMemoryToXmlPayload.class) int memoryInMB,
|
||||||
@EndpointParam URI href);
|
@EndpointParam URI href);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -204,7 +204,7 @@ public interface VmAsyncClient {
|
||||||
@Produces(GUESTCUSTOMIZATIONSECTION_XML)
|
@Produces(GUESTCUSTOMIZATIONSECTION_XML)
|
||||||
@Path("/guestCustomizationSection")
|
@Path("/guestCustomizationSection")
|
||||||
@XMLResponseParser(TaskHandler.class)
|
@XMLResponseParser(TaskHandler.class)
|
||||||
ListenableFuture<? extends Task> updateGuestCustomizationOfVm(
|
ListenableFuture<Task> updateGuestCustomizationOfVm(
|
||||||
@BinderParam(BindGuestCustomizationSectionToXmlPayload.class) GuestCustomizationSection guestCustomizationSection,
|
@BinderParam(BindGuestCustomizationSectionToXmlPayload.class) GuestCustomizationSection guestCustomizationSection,
|
||||||
@EndpointParam URI href);
|
@EndpointParam URI href);
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ public interface VmAsyncClient {
|
||||||
@Produces(NETWORKCONNECTIONSECTION_XML)
|
@Produces(NETWORKCONNECTIONSECTION_XML)
|
||||||
@Path("/networkConnectionSection")
|
@Path("/networkConnectionSection")
|
||||||
@XMLResponseParser(TaskHandler.class)
|
@XMLResponseParser(TaskHandler.class)
|
||||||
ListenableFuture<? extends Task> updateNetworkConnectionOfVm(
|
ListenableFuture<Task> updateNetworkConnectionOfVm(
|
||||||
@BinderParam(BindNetworkConnectionSectionToXmlPayload.class) NetworkConnectionSection networkConnectionSection,
|
@BinderParam(BindNetworkConnectionSectionToXmlPayload.class) NetworkConnectionSection networkConnectionSection,
|
||||||
@EndpointParam URI href);
|
@EndpointParam URI href);
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ import com.google.common.base.Predicate;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class AllCatalogItemsInCatalog implements Function<Catalog, Iterable<? extends CatalogItem>> {
|
public class AllCatalogItemsInCatalog implements Function<Catalog, Iterable<CatalogItem>> {
|
||||||
@Resource
|
@Resource
|
||||||
public Logger logger = Logger.NULL;
|
public Logger logger = Logger.NULL;
|
||||||
|
|
||||||
|
@ -52,14 +52,13 @@ public class AllCatalogItemsInCatalog implements Function<Catalog, Iterable<? ex
|
||||||
private final ExecutorService executor;
|
private final ExecutorService executor;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
AllCatalogItemsInCatalog(VCloudAsyncClient aclient,
|
AllCatalogItemsInCatalog(VCloudAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
||||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
|
||||||
this.aclient = aclient;
|
this.aclient = aclient;
|
||||||
this.executor = executor;
|
this.executor = executor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<? extends CatalogItem> apply(Catalog from) {
|
public Iterable<CatalogItem> apply(Catalog from) {
|
||||||
|
|
||||||
Iterable<CatalogItem> catalogItems = transformParallel(filter(from.values(), new Predicate<ReferenceType>() {
|
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>>() {
|
}), new Function<ReferenceType, Future<CatalogItem>>() {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
@Override
|
||||||
public Future<CatalogItem> apply(ReferenceType from) {
|
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());
|
}, executor, null, logger, "catalogItems in " + from.getHref());
|
||||||
|
|
|
@ -34,28 +34,28 @@ import com.google.common.collect.Iterables;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class AllCatalogItemsInOrg implements Function<Org, Iterable<? extends CatalogItem>> {
|
public class AllCatalogItemsInOrg implements Function<Org, Iterable<CatalogItem>> {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
public Logger logger = Logger.NULL;
|
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
|
@Inject
|
||||||
AllCatalogItemsInOrg(Function<Org, Iterable<? extends Catalog>> allCatalogsInOrg,
|
AllCatalogItemsInOrg(Function<Org, Iterable<Catalog>> allCatalogsInOrg,
|
||||||
Function<Catalog, Iterable<? extends CatalogItem>> allCatalogItemsInCatalog) {
|
Function<Catalog, Iterable<CatalogItem>> allCatalogItemsInCatalog) {
|
||||||
this.allCatalogsInOrg = allCatalogsInOrg;
|
this.allCatalogsInOrg = allCatalogsInOrg;
|
||||||
this.allCatalogItemsInCatalog = allCatalogItemsInCatalog;
|
this.allCatalogItemsInCatalog = allCatalogItemsInCatalog;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<? extends CatalogItem> apply(Org from) {
|
public Iterable<CatalogItem> apply(Org from) {
|
||||||
return Iterables.concat(Iterables.transform(allCatalogsInOrg.apply(from),
|
return Iterables.concat(Iterables.transform(allCatalogsInOrg.apply(from),
|
||||||
new Function<Catalog, Iterable<? extends CatalogItem>>() {
|
new Function<Catalog, Iterable<CatalogItem>>() {
|
||||||
@Override
|
@Override
|
||||||
public Iterable<? extends CatalogItem> apply(Catalog from) {
|
public Iterable<CatalogItem> apply(Catalog from) {
|
||||||
return allCatalogItemsInCatalog.apply(from);
|
return allCatalogItemsInCatalog.apply(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ import com.google.common.base.Function;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class AllCatalogsInOrg implements Function<Org, Iterable<? extends Catalog>> {
|
public class AllCatalogsInOrg implements Function<Org, Iterable<Catalog>> {
|
||||||
@Resource
|
@Resource
|
||||||
public Logger logger = Logger.NULL;
|
public Logger logger = Logger.NULL;
|
||||||
|
|
||||||
|
@ -55,10 +55,9 @@ public class AllCatalogsInOrg implements Function<Org, Iterable<? extends Catalo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<? extends Catalog> apply(final Org org) {
|
public Iterable<Catalog> apply(final Org org) {
|
||||||
Iterable<Catalog> catalogs = transformParallel(org.getCatalogs().values(),
|
Iterable<Catalog> catalogs = transformParallel(org.getCatalogs().values(),
|
||||||
new Function<ReferenceType, Future<Catalog>>() {
|
new Function<ReferenceType, Future<Catalog>>() {
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
@Override
|
||||||
public Future<Catalog> apply(ReferenceType from) {
|
public Future<Catalog> apply(ReferenceType from) {
|
||||||
return (Future<Catalog>) aclient.getCatalogClient().getCatalog(from.getHref());
|
return (Future<Catalog>) aclient.getCatalogClient().getCatalog(from.getHref());
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.vcloud.VCloudAsyncClient;
|
import org.jclouds.vcloud.VCloudAsyncClient;
|
||||||
import org.jclouds.vcloud.domain.Org;
|
import org.jclouds.vcloud.domain.Org;
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
import org.jclouds.vcloud.domain.ReferenceType;
|
||||||
|
import org.jclouds.vcloud.domain.VDC;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@ import com.google.common.base.Function;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@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
|
@Resource
|
||||||
public Logger logger = Logger.NULL;
|
public Logger logger = Logger.NULL;
|
||||||
|
|
||||||
|
@ -54,14 +55,13 @@ public class AllVDCsInOrg implements Function<Org, Iterable<? extends org.jcloud
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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>>() {
|
new Function<ReferenceType, Future<org.jclouds.vcloud.domain.VDC>>() {
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
@Override
|
||||||
public Future<org.jclouds.vcloud.domain.VDC> apply(ReferenceType from) {
|
public Future<VDC> apply(ReferenceType from) {
|
||||||
return (Future<org.jclouds.vcloud.domain.VDC>) aclient.getVDCClient().getVDC(from.getHref());
|
return aclient.getVDCClient().getVDC(from.getHref());
|
||||||
}
|
}
|
||||||
|
|
||||||
}, executor, null, logger, "vdcs in org " + org.getName());
|
}, executor, null, logger, "vdcs in org " + org.getName());
|
||||||
|
|
|
@ -41,12 +41,12 @@ import com.google.common.collect.Iterables;
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class OrgNameAndCatalogNameToEndpoint implements Function<Object, URI> {
|
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 defaultOrg;
|
||||||
private final ReferenceType defaultCatalog;
|
private final ReferenceType defaultCatalog;
|
||||||
|
|
||||||
@Inject
|
@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) {
|
@org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg, @Catalog ReferenceType defaultCatalog) {
|
||||||
this.orgMap = orgMap;
|
this.orgMap = orgMap;
|
||||||
this.defaultOrg = defaultOrg;
|
this.defaultOrg = defaultOrg;
|
||||||
|
|
|
@ -41,12 +41,12 @@ import com.google.common.collect.Iterables;
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class OrgNameAndVDCNameToEndpoint implements Function<Object, URI> {
|
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 defaultOrg;
|
||||||
private final ReferenceType defaultVDC;
|
private final ReferenceType defaultVDC;
|
||||||
|
|
||||||
@Inject
|
@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) {
|
@org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg, @VDC ReferenceType defaultVDC) {
|
||||||
this.orgNameToVDCEndpoint = orgNameToVDCEndpoint;
|
this.orgNameToVDCEndpoint = orgNameToVDCEndpoint;
|
||||||
this.defaultOrg = defaultOrg;
|
this.defaultOrg = defaultOrg;
|
||||||
|
|
|
@ -41,13 +41,13 @@ import com.google.common.collect.Iterables;
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class OrgNameCatalogNameItemNameToEndpoint implements Function<Object, URI> {
|
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 defaultOrg;
|
||||||
private final ReferenceType defaultCatalog;
|
private final ReferenceType defaultCatalog;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public OrgNameCatalogNameItemNameToEndpoint(
|
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) {
|
@Org ReferenceType defaultOrg, @Catalog ReferenceType defaultCatalog) {
|
||||||
this.orgCatalogMap = orgCatalogMap;
|
this.orgCatalogMap = orgCatalogMap;
|
||||||
this.defaultOrg = defaultOrg;
|
this.defaultOrg = defaultOrg;
|
||||||
|
@ -65,7 +65,7 @@ public class OrgNameCatalogNameItemNameToEndpoint implements Function<Object, UR
|
||||||
if (catalog == null)
|
if (catalog == null)
|
||||||
catalog = defaultCatalog.getName();
|
catalog = defaultCatalog.getName();
|
||||||
try {
|
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();
|
return catalogs.get(catalog).get(catalogItem).getHref();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
throw new NoSuchElementException(org + "/" + catalog + "/" + catalogItem + " not found in "
|
throw new NoSuchElementException(org + "/" + catalog + "/" + catalogItem + " not found in "
|
||||||
|
|
|
@ -42,13 +42,13 @@ import com.google.common.collect.Iterables;
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements Function<Object, URI> {
|
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 defaultOrg;
|
||||||
private final ReferenceType defaultCatalog;
|
private final ReferenceType defaultCatalog;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public OrgNameCatalogNameVAppTemplateNameToEndpoint(
|
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) {
|
@Org ReferenceType defaultOrg, @Catalog ReferenceType defaultCatalog) {
|
||||||
this.orgCatalogItemMap = orgCatalogItemMap;
|
this.orgCatalogItemMap = orgCatalogItemMap;
|
||||||
this.defaultOrg = defaultOrg;
|
this.defaultOrg = defaultOrg;
|
||||||
|
@ -65,15 +65,15 @@ public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements Function<Ob
|
||||||
org = defaultOrg.getName();
|
org = defaultOrg.getName();
|
||||||
if (catalog == null)
|
if (catalog == null)
|
||||||
catalog = defaultCatalog.getName();
|
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))
|
if (!orgCatalogItemMap.containsKey(org))
|
||||||
throw new NoSuchElementException("org: " + org + " not found in " + orgCatalogItemMap.keySet());
|
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))
|
if (!catalogs.containsKey(catalog))
|
||||||
throw new NoSuchElementException("catalog: " + org + "/" + catalog + " not found in " + catalogs.keySet());
|
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))
|
if (!catalogMap.containsKey(catalogItem))
|
||||||
throw new NoSuchElementException("item: " + org + "/" + catalog + "/" + catalogItem + " not found in "
|
throw new NoSuchElementException("item: " + org + "/" + catalog + "/" + catalogItem + " not found in "
|
||||||
|
|
|
@ -40,11 +40,11 @@ import com.google.common.base.Supplier;
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class OrgNameToTasksListEndpoint implements Function<Object, URI> {
|
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;
|
private final ReferenceType defaultTasksList;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public OrgNameToTasksListEndpoint(Supplier<Map<String, ? extends Org>> orgMap,
|
public OrgNameToTasksListEndpoint(Supplier<Map<String, Org>> orgMap,
|
||||||
@TasksList ReferenceType defaultTasksList) {
|
@TasksList ReferenceType defaultTasksList) {
|
||||||
this.orgMap = orgMap;
|
this.orgMap = orgMap;
|
||||||
this.defaultTasksList = defaultTasksList;
|
this.defaultTasksList = defaultTasksList;
|
||||||
|
|
|
@ -39,7 +39,7 @@ import com.google.common.base.Supplier;
|
||||||
public class OrgNameVDCNameNetworkNameToEndpoint extends OrgNameVDCNameResourceNameToEndpoint {
|
public class OrgNameVDCNameNetworkNameToEndpoint extends OrgNameVDCNameResourceNameToEndpoint {
|
||||||
@Inject
|
@Inject
|
||||||
public OrgNameVDCNameNetworkNameToEndpoint(
|
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) {
|
@Org ReferenceType defaultOrg, @VDC ReferenceType defaultVDC) {
|
||||||
super(orgVDCMap, defaultOrg, defaultVDC);
|
super(orgVDCMap, defaultOrg, defaultVDC);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ import com.google.common.base.Supplier;
|
||||||
public class OrgNameVDCNameResourceEntityNameToEndpoint extends OrgNameVDCNameResourceNameToEndpoint {
|
public class OrgNameVDCNameResourceEntityNameToEndpoint extends OrgNameVDCNameResourceNameToEndpoint {
|
||||||
@Inject
|
@Inject
|
||||||
public OrgNameVDCNameResourceEntityNameToEndpoint(
|
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) {
|
@Org ReferenceType defaultOrg, @VDC ReferenceType defaultVDC) {
|
||||||
super(orgVDCMap, defaultOrg, defaultVDC);
|
super(orgVDCMap, defaultOrg, defaultVDC);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,13 +40,13 @@ import com.google.common.collect.Iterables;
|
||||||
*/
|
*/
|
||||||
public abstract class OrgNameVDCNameResourceNameToEndpoint implements Function<Object, URI>{
|
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 defaultOrg;
|
||||||
protected final ReferenceType defaultVDC;
|
protected final ReferenceType defaultVDC;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public OrgNameVDCNameResourceNameToEndpoint(
|
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) {
|
@Org ReferenceType defaultOrg, @org.jclouds.vcloud.endpoints.VDC ReferenceType defaultVDC) {
|
||||||
this.orgVDCMap = orgVDCMap;
|
this.orgVDCMap = orgVDCMap;
|
||||||
this.defaultOrg = defaultOrg;
|
this.defaultOrg = defaultOrg;
|
||||||
|
@ -63,9 +63,9 @@ public abstract class OrgNameVDCNameResourceNameToEndpoint implements Function<
|
||||||
org = defaultOrg.getName();
|
org = defaultOrg.getName();
|
||||||
if (vDC == null)
|
if (vDC == null)
|
||||||
vDC = defaultVDC.getName();
|
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!");
|
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)
|
if (vDCs == null)
|
||||||
throw new NoSuchElementException("org " + org + " not found in " + orgToVDCs.keySet());
|
throw new NoSuchElementException("org " + org + " not found in " + orgToVDCs.keySet());
|
||||||
org.jclouds.vcloud.domain.VDC vDCObject = vDCs.get(vDC);
|
org.jclouds.vcloud.domain.VDC vDCObject = vDCs.get(vDC);
|
||||||
|
|
|
@ -46,7 +46,7 @@ import com.google.common.collect.Sets;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class OrgsForLocations implements Function<Iterable<? extends Location>, Iterable<? extends Org>> {
|
public class OrgsForLocations implements Function<Iterable<Location>, Iterable< Org>> {
|
||||||
@Resource
|
@Resource
|
||||||
public Logger logger = Logger.NULL;
|
public Logger logger = Logger.NULL;
|
||||||
private final VCloudAsyncClient aclient;
|
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.
|
* parent is region. then, we use a set to extract the unique set.
|
||||||
*/
|
*/
|
||||||
@Override
|
@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>() {
|
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>>() {
|
})), new Function<URI, Future<Org>>() {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
@Override
|
||||||
public Future<Org> apply(URI from) {
|
public Future<Org> apply(URI from) {
|
||||||
return (Future<Org>) aclient.getOrgClient().getOrg(from);
|
return aclient.getOrgClient().getOrg(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
}, executor, null, logger, "organizations for uris");
|
}, executor, null, logger, "organizations for uris");
|
||||||
|
|
|
@ -39,7 +39,7 @@ import com.google.common.base.Function;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class OrgsForNames implements Function<Iterable<String>, Iterable<? extends Org>> {
|
public class OrgsForNames implements Function<Iterable<String>, Iterable<Org>> {
|
||||||
@Resource
|
@Resource
|
||||||
public Logger logger = Logger.NULL;
|
public Logger logger = Logger.NULL;
|
||||||
private final VCloudAsyncClient aclient;
|
private final VCloudAsyncClient aclient;
|
||||||
|
@ -52,13 +52,12 @@ public class OrgsForNames implements Function<Iterable<String>, Iterable<? exten
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<? extends Org> apply(Iterable<String> from) {
|
public Iterable<Org> apply(Iterable<String> from) {
|
||||||
return transformParallel(from, new Function<String, Future<Org>>() {
|
return transformParallel(from, new Function<String, Future<Org>>() {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
@Override
|
||||||
public Future<Org> apply(String from) {
|
public Future<Org> apply(String from) {
|
||||||
return (Future<Org>) aclient.getOrgClient().findOrgNamed(from);
|
return aclient.getOrgClient().findOrgNamed(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
}, executor, null, logger, "organizations for names");
|
}, executor, null, logger, "organizations for names");
|
||||||
|
|
|
@ -48,8 +48,7 @@ import com.google.common.base.Predicate;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class VAppTemplatesForCatalogItems implements
|
public class VAppTemplatesForCatalogItems implements Function<Iterable<CatalogItem>, Iterable<VAppTemplate>> {
|
||||||
Function<Iterable<? extends CatalogItem>, Iterable<? extends VAppTemplate>> {
|
|
||||||
@Resource
|
@Resource
|
||||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
public Logger logger = Logger.NULL;
|
public Logger logger = Logger.NULL;
|
||||||
|
@ -78,7 +77,7 @@ public class VAppTemplatesForCatalogItems implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<? extends VAppTemplate> apply(Iterable<? extends CatalogItem> from) {
|
public Iterable<VAppTemplate> apply(Iterable<CatalogItem> from) {
|
||||||
return transformParallel(filter(from, new Predicate<CatalogItem>() {
|
return transformParallel(filter(from, new Predicate<CatalogItem>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -88,12 +87,11 @@ public class VAppTemplatesForCatalogItems implements
|
||||||
|
|
||||||
}), new Function<CatalogItem, Future<VAppTemplate>>() {
|
}), new Function<CatalogItem, Future<VAppTemplate>>() {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
@Override
|
||||||
public Future<VAppTemplate> apply(CatalogItem from) {
|
public Future<VAppTemplate> apply(CatalogItem from) {
|
||||||
return new ExceptionParsingListenableFuture<VAppTemplate>(Futures.makeListenable(
|
return new ExceptionParsingListenableFuture<VAppTemplate>(Futures.makeListenable(VCloudAsyncClient.class
|
||||||
(Future<VAppTemplate>) VCloudAsyncClient.class.cast(aclient).getVAppTemplateClient().getVAppTemplate(
|
.cast(aclient).getVAppTemplateClient().getVAppTemplate(from.getEntity().getHref()), executor),
|
||||||
from.getEntity().getHref()), executor), returnNullOnAuthorizationException);
|
returnNullOnAuthorizationException);
|
||||||
}
|
}
|
||||||
|
|
||||||
}, executor, null, logger, "vappTemplates in");
|
}, executor, null, logger, "vappTemplates in");
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* 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.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.collect.Iterables.concat;
|
import static com.google.common.collect.Iterables.concat;
|
||||||
|
@ -35,10 +35,10 @@ import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.Constants;
|
||||||
import org.jclouds.compute.domain.Image;
|
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.vcloud.domain.Org;
|
import org.jclouds.vcloud.domain.Org;
|
||||||
|
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
@ -47,19 +47,19 @@ import com.google.common.base.Supplier;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class VCloudImageSupplier implements Supplier<Set<? extends Image>> {
|
public class VAppTemplatesSupplier implements Supplier<Set<VAppTemplate>> {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
public Logger logger = Logger.NULL;
|
public Logger logger = Logger.NULL;
|
||||||
|
|
||||||
private final Supplier<Map<String, ? extends Org>> orgMap;
|
private final Supplier<Map<String, Org>> orgMap;
|
||||||
private final Function<Org, Iterable<? extends Image>> imagesInOrg;
|
private final Function<Org, Iterable<VAppTemplate>> imagesInOrg;
|
||||||
private final ExecutorService executor;
|
private final ExecutorService executor;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
VCloudImageSupplier(Supplier<Map<String, ? extends Org>> orgMap,
|
VAppTemplatesSupplier(Supplier<Map<String, Org>> orgMap,
|
||||||
Function<Org, Iterable<? extends Image>> imagesInOrg,
|
Function<Org, Iterable<VAppTemplate>> imagesInOrg,
|
||||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
||||||
this.orgMap = checkNotNull(orgMap, "orgMap");
|
this.orgMap = checkNotNull(orgMap, "orgMap");
|
||||||
this.imagesInOrg = checkNotNull(imagesInOrg, "imagesInOrg");
|
this.imagesInOrg = checkNotNull(imagesInOrg, "imagesInOrg");
|
||||||
|
@ -67,18 +67,18 @@ public class VCloudImageSupplier implements Supplier<Set<? extends Image>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<? extends Image> get() {
|
public Set<VAppTemplate> get() {
|
||||||
Iterable<? extends Org> orgs = checkNotNull(orgMap.get().values(), "orgs");
|
Iterable<Org> orgs = checkNotNull(orgMap.get().values(), "orgs");
|
||||||
Iterable<Iterable<? extends Image>> images = transformParallel(orgs,
|
Iterable<Iterable<VAppTemplate>> images = transformParallel(orgs,
|
||||||
new Function<Org, Future<Iterable<? extends Image>>>() {
|
new Function<Org, Future<Iterable<VAppTemplate>>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Future<Iterable<? extends Image>> apply(final Org from) {
|
public Future<Iterable<VAppTemplate>> apply(final Org from) {
|
||||||
checkNotNull(from, "org");
|
checkNotNull(from, "org");
|
||||||
return executor.submit(new Callable<Iterable<? extends Image>>() {
|
return executor.submit(new Callable<Iterable<VAppTemplate>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<? extends Image> call() throws Exception {
|
public Iterable<VAppTemplate> call() throws Exception {
|
||||||
return imagesInOrg.apply(from);
|
return imagesInOrg.apply(from);
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,12 +60,6 @@ public class VCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
"node userMetadata did not match %s %s", userMetadata, node);
|
"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
|
@Override
|
||||||
public void testListNodes() throws Exception {
|
public void testListNodes() throws Exception {
|
||||||
for (ComputeMetadata node : client.listNodes()) {
|
for (ComputeMetadata node : client.listNodes()) {
|
||||||
|
|
|
@ -42,7 +42,7 @@ import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.http.functions.ParseSax.Factory;
|
import org.jclouds.http.functions.ParseSax.Factory;
|
||||||
import org.jclouds.http.functions.config.SaxParserModule;
|
import org.jclouds.http.functions.config.SaxParserModule;
|
||||||
import org.jclouds.vcloud.VCloudPropertiesBuilder;
|
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.ReferenceType;
|
||||||
import org.jclouds.vcloud.domain.Status;
|
import org.jclouds.vcloud.domain.Status;
|
||||||
import org.jclouds.vcloud.domain.VApp;
|
import org.jclouds.vcloud.domain.VApp;
|
||||||
|
@ -105,7 +105,7 @@ public class VAppToNodeMetadataTest {
|
||||||
@Singleton
|
@Singleton
|
||||||
@Provides
|
@Provides
|
||||||
protected Map<Status, NodeState> provideVAppStatusToNodeState() {
|
protected Map<Status, NodeState> provideVAppStatusToNodeState() {
|
||||||
return VCloudComputeServiceContextModule.VAPPSTATUS_TO_NODESTATE;
|
return VCloudComputeServiceDependenciesModule.VAPPSTATUS_TO_NODESTATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -132,7 +132,7 @@ public abstract class BaseVCloudAsyncClientTest<T> extends RestClientTest<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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) {
|
@org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) {
|
||||||
return ORG;
|
return ORG;
|
||||||
}
|
}
|
||||||
|
@ -184,11 +184,11 @@ public abstract class BaseVCloudAsyncClientTest<T> extends RestClientTest<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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,
|
@Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference<AuthorizationException> authException,
|
||||||
OrgVDCSupplier supplier) {
|
OrgVDCSupplier supplier) {
|
||||||
return Suppliers.<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> ofInstance(ImmutableMap
|
return Suppliers.<Map<String, Map<String, org.jclouds.vcloud.domain.VDC>>> ofInstance(ImmutableMap
|
||||||
.<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> of(ORG_REF.getName(),
|
.<String, Map<String, org.jclouds.vcloud.domain.VDC>> of(ORG_REF.getName(),
|
||||||
ImmutableMap.<String, org.jclouds.vcloud.domain.VDC> of(VDC.getName(), VDC)));
|
ImmutableMap.<String, org.jclouds.vcloud.domain.VDC> of(VDC.getName(), VDC)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,8 +214,8 @@ public abstract class BaseVCloudAsyncClientTest<T> extends RestClientTest<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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 ImmutableMap.<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> of(
|
return ImmutableMap.<String, Map<String, org.jclouds.vcloud.domain.Catalog>> of(
|
||||||
ORG_REF.getName(), ImmutableMap.<String, org.jclouds.vcloud.domain.Catalog> of(
|
ORG_REF.getName(), ImmutableMap.<String, org.jclouds.vcloud.domain.Catalog> of(
|
||||||
CATALOG_REF.getName(),
|
CATALOG_REF.getName(),
|
||||||
new CatalogImpl(CATALOG_REF.getName(), CATALOG_REF.getType(), CATALOG_REF.getHref(), null,
|
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
|
@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 ImmutableMap.<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> of(
|
return ImmutableMap.<String, Map<String, Map<String, org.jclouds.vcloud.domain.CatalogItem>>> of(
|
||||||
ORG_REF.getName(), ImmutableMap
|
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(
|
.getName(), ImmutableMap.<String, org.jclouds.vcloud.domain.CatalogItem> of(
|
||||||
"template",
|
"template",
|
||||||
new CatalogItemImpl("template", URI
|
new CatalogItemImpl("template", URI
|
||||||
|
|
Loading…
Reference in New Issue