mirror of https://github.com/apache/jclouds.git
Issue 327: introduced VCloudLocation which hides the Resource corresponding to the org or vdc
This commit is contained in:
parent
d8a8c38e4f
commit
3289871c14
|
@ -28,6 +28,7 @@ import javax.inject.Singleton;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.domain.LocationScope;
|
import org.jclouds.domain.LocationScope;
|
||||||
import org.jclouds.domain.internal.LocationImpl;
|
import org.jclouds.domain.internal.LocationImpl;
|
||||||
|
import org.jclouds.vcloud.compute.domain.VCloudLocation;
|
||||||
import org.jclouds.vcloud.domain.NamedResource;
|
import org.jclouds.vcloud.domain.NamedResource;
|
||||||
import org.jclouds.vcloud.endpoints.Org;
|
import org.jclouds.vcloud.endpoints.Org;
|
||||||
import org.jclouds.vcloud.endpoints.VDC;
|
import org.jclouds.vcloud.endpoints.VDC;
|
||||||
|
@ -59,10 +60,9 @@ public class OrgAndVDCToLocationProvider implements Provider<Set<? extends Locat
|
||||||
Set<Location> locations = Sets.newLinkedHashSet();
|
Set<Location> locations = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
for (NamedResource org : orgNameToResource.get().values()) {
|
for (NamedResource org : orgNameToResource.get().values()) {
|
||||||
Location orgL = new LocationImpl(LocationScope.REGION, org.getName(), org.getLocation().toASCIIString(),
|
Location orgL = new VCloudLocation(org, provider);
|
||||||
provider);
|
|
||||||
for (NamedResource vdc : orgNameToVDCResource.get().get(org.getName()).values()) {
|
for (NamedResource vdc : orgNameToVDCResource.get().get(org.getName()).values()) {
|
||||||
locations.add(new LocationImpl(LocationScope.ZONE, vdc.getName(), vdc.getLocation().toASCIIString(), orgL));
|
locations.add(new VCloudLocation(vdc, orgL));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return locations;
|
return locations;
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.NamedResource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class VCloudLocation extends LocationImpl {
|
||||||
|
|
||||||
|
private final NamedResource resource;
|
||||||
|
|
||||||
|
public NamedResource getResource() {
|
||||||
|
return resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VCloudLocation(NamedResource resource, Location parent) {
|
||||||
|
super(checkNotNull(resource, "resource").getType().endsWith("org+xml") ? LocationScope.REGION
|
||||||
|
: LocationScope.ZONE, resource.getName(), resource.getName(), parent);
|
||||||
|
this.resource = resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -5052812549904524841L;
|
||||||
|
|
||||||
|
}
|
|
@ -28,6 +28,7 @@ import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
|
import org.jclouds.vcloud.compute.domain.VCloudLocation;
|
||||||
import org.jclouds.vcloud.domain.NamedResource;
|
import org.jclouds.vcloud.domain.NamedResource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -59,7 +60,7 @@ public class FindLocationForResource {
|
||||||
do {
|
do {
|
||||||
// The "name" isn't always present, ex inside a vApp we have a rel
|
// The "name" isn't always present, ex inside a vApp we have a rel
|
||||||
// link that only includes href and type.
|
// link that only includes href and type.
|
||||||
if (input.getDescription().equals(resource.getLocation().toASCIIString()))
|
if (VCloudLocation.class.cast(input).getResource().getLocation().equals(resource.getLocation()))
|
||||||
return input;
|
return input;
|
||||||
input = input.getParent();
|
input = input.getParent();
|
||||||
} while (input.getParent() != null);
|
} while (input.getParent() != null);
|
||||||
|
|
|
@ -31,14 +31,13 @@ import org.jclouds.vcloud.compute.functions.VCloudGetNodeMetadata;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class VCloudGetNodeMetadataStrategy implements
|
public class VCloudGetNodeMetadataStrategy implements GetNodeMetadataStrategy {
|
||||||
GetNodeMetadataStrategy {
|
|
||||||
|
|
||||||
protected final VCloudGetNodeMetadata getNodeMetadata;
|
protected final VCloudGetNodeMetadata getNodeMetadata;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected VCloudGetNodeMetadataStrategy(VCloudGetNodeMetadata getNodeMetadata) {
|
protected VCloudGetNodeMetadataStrategy(VCloudGetNodeMetadata getNodeMetadata) {
|
||||||
this.getNodeMetadata=getNodeMetadata;
|
this.getNodeMetadata = getNodeMetadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class TerremarkVCloudComputeServiceLiveTest extends VCloudComputeServiceL
|
||||||
Template defaultTemplate = client.templateBuilder().build();
|
Template defaultTemplate = client.templateBuilder().build();
|
||||||
assertEquals(defaultTemplate.getImage().getArchitecture(), Architecture.X86_64);
|
assertEquals(defaultTemplate.getImage().getArchitecture(), Architecture.X86_64);
|
||||||
assertEquals(defaultTemplate.getImage().getOsFamily(), OsFamily.UBUNTU);
|
assertEquals(defaultTemplate.getImage().getOsFamily(), OsFamily.UBUNTU);
|
||||||
assertEquals(defaultTemplate.getLocation().getId(), "32");
|
assertEquals(defaultTemplate.getLocation().getId(), "Miami Environment 1");
|
||||||
assertEquals(defaultTemplate.getSize().getCores(), 1.0d);
|
assertEquals(defaultTemplate.getSize().getCores(), 1.0d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue