mirror of https://github.com/apache/jclouds.git
Issue 381: removed unnecessary VCloudLocation class
This commit is contained in:
parent
a9de959146
commit
7f02bd8929
|
@ -1,49 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.domain.LocationScope;
|
||||
import org.jclouds.domain.internal.LocationImpl;
|
||||
import org.jclouds.vcloud.domain.ReferenceType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class VCloudLocation extends LocationImpl {
|
||||
|
||||
private static final long serialVersionUID = -5052812549904524841L;
|
||||
|
||||
private final ReferenceType resource;
|
||||
|
||||
public VCloudLocation(ReferenceType resource, Location parent) {
|
||||
super(checkNotNull(resource, "resource").getType().endsWith("org+xml") ? LocationScope.REGION
|
||||
: LocationScope.ZONE, resource.getHref().toASCIIString(), resource.getName(), parent);
|
||||
this.resource = resource;
|
||||
}
|
||||
|
||||
public ReferenceType getResource() {
|
||||
return resource;
|
||||
}
|
||||
|
||||
}
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package org.jclouds.vcloud.compute.functions;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -28,7 +29,6 @@ import javax.inject.Singleton;
|
|||
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.vcloud.compute.domain.VCloudLocation;
|
||||
import org.jclouds.vcloud.domain.ReferenceType;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
|
@ -60,7 +60,7 @@ public class FindLocationForResource {
|
|||
do {
|
||||
// The "name" isn't always present, ex inside a vApp we have a rel
|
||||
// link that only includes href and type.
|
||||
if (VCloudLocation.class.cast(input).getResource().getHref().equals(resource.getHref()))
|
||||
if (URI.create(input.getId()).equals(resource.getHref()))
|
||||
return input;
|
||||
input = input.getParent();
|
||||
} while (input.getParent() != null);
|
||||
|
|
|
@ -28,9 +28,8 @@ import javax.inject.Singleton;
|
|||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.domain.LocationScope;
|
||||
import org.jclouds.domain.internal.LocationImpl;
|
||||
import org.jclouds.vcloud.compute.domain.VCloudLocation;
|
||||
import org.jclouds.vcloud.domain.ReferenceType;
|
||||
import org.jclouds.vcloud.domain.Org;
|
||||
import org.jclouds.vcloud.domain.ReferenceType;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.Sets;
|
||||
|
@ -59,9 +58,9 @@ public class OrgAndVDCToLocationSupplier implements Supplier<Set<? extends Locat
|
|||
Set<Location> locations = Sets.newLinkedHashSet();
|
||||
|
||||
for (ReferenceType org : orgNameToResource.get().values()) {
|
||||
Location orgL = new VCloudLocation(org, provider);
|
||||
Location orgL = new LocationImpl(LocationScope.REGION, org.getHref().toASCIIString(), org.getName(), provider);
|
||||
for (ReferenceType vdc : orgNameToVDCResource.get().get(org.getName()).getVDCs().values()) {
|
||||
locations.add(new VCloudLocation(vdc, orgL));
|
||||
locations.add(new LocationImpl(LocationScope.ZONE, vdc.getHref().toASCIIString(), vdc.getName(), orgL));
|
||||
}
|
||||
}
|
||||
return locations;
|
||||
|
|
|
@ -38,7 +38,6 @@ import org.jclouds.domain.Location;
|
|||
import org.jclouds.domain.LocationScope;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.vcloud.CommonVCloudAsyncClient;
|
||||
import org.jclouds.vcloud.compute.domain.VCloudLocation;
|
||||
import org.jclouds.vcloud.domain.Org;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
@ -80,7 +79,7 @@ public class OrgsForLocations implements Function<Iterable<? extends Location>,
|
|||
|
||||
@Override
|
||||
public URI apply(Location from) {
|
||||
return VCloudLocation.class.cast(from.getParent()).getResource().getHref();
|
||||
return URI.create(from.getParent().getId());
|
||||
}
|
||||
|
||||
})), new Function<URI, Future<Org>>() {
|
||||
|
|
|
@ -35,7 +35,6 @@ import org.jclouds.compute.domain.NodeMetadataBuilder;
|
|||
import org.jclouds.compute.domain.NodeState;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.vcloud.compute.VCloudExpressComputeClient;
|
||||
import org.jclouds.vcloud.compute.domain.VCloudLocation;
|
||||
import org.jclouds.vcloud.compute.functions.FindLocationForResource;
|
||||
import org.jclouds.vcloud.compute.functions.HardwareForVCloudExpressVApp;
|
||||
import org.jclouds.vcloud.compute.functions.VCloudExpressVAppToNodeMetadata;
|
||||
|
@ -86,7 +85,7 @@ public class TerremarkVCloudExpressVAppToNodeMetadata extends VCloudExpressVAppT
|
|||
}
|
||||
|
||||
OrgAndName getOrgAndNameFromNode(NodeMetadata node) {
|
||||
URI orgId = VCloudLocation.class.cast(node.getLocation().getParent()).getResource().getHref();
|
||||
URI orgId = URI.create(node.getLocation().getParent().getId());
|
||||
OrgAndName orgAndName = new OrgAndName(orgId, node.getTag());
|
||||
return orgAndName;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package org.jclouds.vcloud.terremark.compute.strategy;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
@ -36,7 +37,6 @@ import org.jclouds.compute.strategy.ListNodesStrategy;
|
|||
import org.jclouds.compute.strategy.impl.EncodeTagIntoNameRunNodesAndAddToSetStrategy;
|
||||
import org.jclouds.compute.util.ComputeUtils;
|
||||
import org.jclouds.domain.LocationScope;
|
||||
import org.jclouds.vcloud.compute.domain.VCloudLocation;
|
||||
import org.jclouds.vcloud.terremark.compute.options.TerremarkVCloudTemplateOptions;
|
||||
|
||||
/**
|
||||
|
@ -63,9 +63,9 @@ public class TerremarkEncodeTagIntoNameRunNodesAndAddToSetStrategy extends Encod
|
|||
Map<NodeMetadata, Exception> badNodes) {
|
||||
assert template.getLocation().getParent().getScope() == LocationScope.REGION : "template location should have a parent of org, which should be mapped to region: "
|
||||
+ template.getLocation();
|
||||
createNewKeyPairUnlessUserSpecifiedOtherwise.execute(VCloudLocation.class
|
||||
.cast(template.getLocation().getParent()).getResource().getHref(), tag, template.getImage()
|
||||
.getDefaultCredentials().identity, template.getOptions().as(TerremarkVCloudTemplateOptions.class));
|
||||
createNewKeyPairUnlessUserSpecifiedOtherwise.execute(URI.create(template.getLocation().getParent().getId()), tag,
|
||||
template.getImage().getDefaultCredentials().identity, template.getOptions().as(
|
||||
TerremarkVCloudTemplateOptions.class));
|
||||
return super.execute(tag, count, template, nodes, badNodes);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue