本文整理汇总了Java中org.jclouds.domain.LocationScope类的典型用法代码示例。如果您正苦于以下问题:Java LocationScope类的具体用法?Java LocationScope怎么用?Java LocationScope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LocationScope类属于org.jclouds.domain包,在下文中一共展示了LocationScope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import org.jclouds.domain.LocationScope; //导入依赖的package包/类
@Override
public NodeMetadata apply(Instance input) {
NodeMetadataBuilder builder = new NodeMetadataBuilder();
builder.id(api.encodeToId(input.getRegionId(), input.getInstanceId()));
builder.providerId(input.getInstanceId());
builder.name(input.getInstanceName());
builder.group(input.getRegionId());
builder.status(status.get(input.getStatus()));
builder.imageId(input.getImageId());
Hardware hardware = new HardwareBuilder()
.id(input.getInstanceType())
.build();
builder.hardware(hardware);
Location location = new LocationBuilder()
.scope(LocationScope.REGION)
.id(input.getRegionId())
.description(input.getRegionId())
.build();
builder.location(location);
builder.publicAddresses(input.getPublicIpAddress());
builder.privateAddresses(input.getInnerIpAddress());
return builder.build();
}
示例2: getLoadBalancer
import org.jclouds.domain.LocationScope; //导入依赖的package包/类
@Override
public LoadBalancerMetadata getLoadBalancer(String id) {
IAcsClient client = api.getAcsClient(SLBApi.DEFAULT_REGION);
DescribeLoadBalancerAttributeRequest req = new DescribeLoadBalancerAttributeRequest();
req.setLoadBalancerId(id);
LoadBalancerMetadata lbm = null;
try {
DescribeLoadBalancerAttributeResponse resp = client.getAcsResponse(req);
LocationBuilder location = new LocationBuilder()
.scope(LocationScope.REGION)
.id(resp.getRegionId())
.description(resp.getRegionId());
lbm = new LoadBalancerMetadataImpl(
loadBalancerTypes.get(resp.getAddressType()),
resp.getLoadBalancerId(),
resp.getLoadBalancerName(),
resp.getLoadBalancerId(),
location.build(),
null,
ImmutableMap.<String, String>builder().build(),
ImmutableSet.<String> builder().add(resp.getAddress()).build());
} catch (Exception e) {
logger.warn(e.getMessage());
}
return lbm;
}
示例3: apply
import org.jclouds.domain.LocationScope; //导入依赖的package包/类
@Override
public LoadBalancerMetadata apply(LoadBalancer input) {
DescribeLoadBalancerAttributeRequest req = new DescribeLoadBalancerAttributeRequest();
req.setLoadBalancerId(input.getLoadBalancerId());
DescribeLoadBalancerAttributeResponse resp = null;
try {
resp = client.getAcsResponse(req);
} catch (Exception e) {
logger.warn(e.getMessage());
}
LocationBuilder location = new LocationBuilder()
.scope(LocationScope.REGION)
.id(resp.getRegionId())
.description(resp.getRegionId());
return new LoadBalancerMetadataImpl(
loadBalancerTypes.get(resp.getAddressType()),
input.getLoadBalancerId(),
input.getLoadBalancerName(),
input.getLoadBalancerId(),
location.build(),
null,
ImmutableMap.<String, String>builder().build(),
ImmutableSet.<String> builder().add(resp.getAddress()).build());
}
示例4: beforeClass
import org.jclouds.domain.LocationScope; //导入依赖的package包/类
@BeforeClass
public void beforeClass() {
LocationBuilder location = new LocationBuilder()
.scope(LocationScope.REGION)
.id(testRegion)
.description(testRegion);
Set<NodeMetadata> nodes = ImmutableSet.<NodeMetadata> builder()
.add(new NodeMetadataBuilder()
.status(Status.RUNNING)
.id("cn-hangzhou:i-233ehfkdv")
.build())
.build();
lbm = loadBalancerService
.createLoadBalancerInLocation(
location.build(),
testLoadBalancer,
"http", 80, 80, nodes);
}
示例5: testShouldFetchHostMetadataWithoutDiscoverNodes
import org.jclouds.domain.LocationScope; //导入依赖的package包/类
@Test
public void testShouldFetchHostMetadataWithoutDiscoverNodes() {
ComputeServiceBuilder mockComputeServiceBuilder = mock(ComputeServiceBuilder.class);
JCloudsDiscoveryStrategy jCloudsDiscoveryStrategy = new JCloudsDiscoveryStrategy(mockComputeServiceBuilder);
Set<NodeMetadata> nodes = new HashSet<NodeMetadata>();
HashSet<String> privateAddresses = new HashSet<String>();
privateAddresses.add(jCloudsDiscoveryStrategy.getLocalHostAddress());
LocationImpl location = new LocationImpl(LocationScope.ZONE, "eu-west-1", "dummy", null, new ArrayList<String>(),
new HashMap<String, Object>());
nodes.add(new NodeMetadataImpl("", "", "dummy",
location,
null,
new HashMap<String, String>(),
new HashSet<String>(),
null, null, null, null,
NodeMetadata.Status.RUNNING, "",
99999, privateAddresses, privateAddresses, null, "dummyHostName"));
doReturn(nodes).when(mockComputeServiceBuilder).getFilteredNodes();
Map<String, Object> localMetadata = jCloudsDiscoveryStrategy.discoverLocalMetadata();
assertEquals(localMetadata.get(PARTITION_GROUP_HOST), "dummyHostName");
assertEquals(localMetadata.get(PARTITION_GROUP_ZONE), "eu-west-1");
}
示例6: getClusters
import org.jclouds.domain.LocationScope; //导入依赖的package包/类
private Set<? extends Location> getClusters() {
Set<Location> hosts = Sets.newHashSet();
try (VSphereServiceInstance instance = serviceInstance.get();) {
ManagedEntity[] clusterEntities = new InventoryNavigator(instance.getInstance().getRootFolder()).searchManagedEntities("ClusterComputeResource");
for (ManagedEntity cluster : clusterEntities) {
Location location = new LocationImpl(LocationScope.ZONE, cluster.getName(), cluster.getName(), null, ImmutableSet.of(""), Maps.<String, Object>newHashMap());
hosts.add(location);
}
hosts.add(new LocationImpl(LocationScope.ZONE, "default", "default", null, ImmutableSet.of(""), Maps.<String, Object>newHashMap()));
return hosts;
} catch (Exception e) {
logger.error("Problem in finding a valid cluster", e);
Throwables.propagateIfPossible(e);
}
return hosts;
}
示例7: setUp
import org.jclouds.domain.LocationScope; //导入依赖的package包/类
@Before
public void setUp(){
indexShardRepository = mock(BlobStoreIndexShardRepository.class);
cloudFilesService = mock(CloudFilesService.class);
RegionScopedBlobStoreContext blobStoreContext = mock(RegionScopedBlobStoreContext.class);
BlobStore blobStore = mock(BlobStore.class);
Set<Location> locations = new HashSet<Location>();
Set<String> isoCodes = new HashSet<String>();
isoCodes.add("US-IL");
locations.add(new LocationBuilder().id("ORD").description("ORD").scope(LocationScope.REGION).iso3166Codes(isoCodes).build());
when(blobStore.listAssignableLocations()).thenReturn((Set) locations);
when(blobStoreContext.getBlobStore(anyString())).thenReturn(blobStore);
when(cloudFilesService.context()).thenReturn(blobStoreContext);
}
示例8: listLocations
import org.jclouds.domain.LocationScope; //导入依赖的package包/类
@Override
public Set<? extends AssignableLocation> listLocations() {
Set<AssignableLocation> locations = new HashSet<>();
for (AssignableLocation location : delegate.listLocations()) {
locations.add(location);
if (location.getScope().equals(LocationScope.REGION)) {
final Set<AssignableLocation> availabilityZones =
new AvailabilityZoneSupplierForRegion(location).get();
locations.addAll(availabilityZones);
for (Location availabilityZone : availabilityZones) {
locations.addAll(new HostSupplierForAvailabilityZone(availabilityZone).get());
}
}
}
return locations;
}
示例9: getRegion
import org.jclouds.domain.LocationScope; //导入依赖的package包/类
/**
* Returns the region as string for the given {@link Location}.
*
* @param location the location
*
* @return the region or null if the region cannot be found
*/
private static String getRegion(Location location) {
// Just to be safe
if (location == null) {
return null;
}
String region = null;
while(region == null && location.getParent() != null) {
if (location.getScope() == LocationScope.REGION) {
region = location.getId();
} else {
location = location.getParent();
}
}
return region;
}
示例10: acceptLocation
import org.jclouds.domain.LocationScope; //导入依赖的package包/类
private boolean acceptLocation(Location location, Set<String> names, LocationScope scope) {
if (names.isEmpty()) {
return true;
}
while (location != null) {
if (location.getScope() == scope && names.contains(location.getId())) {
return true;
}
location = location.getParent();
}
return false;
}
示例11: list
import org.jclouds.domain.LocationScope; //导入依赖的package包/类
@Override
public PageSet<? extends StorageMetadata> list() {
OSS oss = api.getOSSClient(OSSApi.DEFAULT_REGION);
PageSetImpl<StorageMetadata> pageSet = new PageSetImpl<StorageMetadata>(
transform(oss.listBuckets(), new Function<Bucket, StorageMetadata>() {
@Override
public StorageMetadata apply(Bucket input) {
String bucketLocation = input.getLocation();
Location location = new LocationBuilder()
.id(bucketLocation)
.scope(LocationScope.REGION)
.description(bucketLocation)
.build();
StorageMetadata storageMetadata = new StorageMetadataImpl(
StorageType.CONTAINER,
input.getName(),
input.getName(),
location,
null,
null,
input.getCreationDate(),
input.getCreationDate(),
ImmutableMap.<String, String>builder().build(),
0L);
return storageMetadata;
}
}), null);
return pageSet;
}
示例12: apply
import org.jclouds.domain.LocationScope; //导入依赖的package包/类
@Override
public Location apply(String input) {
LocationBuilder builder = new LocationBuilder();
builder.scope(LocationScope.REGION);
builder.id(input);
builder.description(input);
return builder.build();
}
示例13: beforeClass
import org.jclouds.domain.LocationScope; //导入依赖的package包/类
@BeforeClass
public void beforeClass() {
LocationBuilder location = new LocationBuilder()
.scope(LocationScope.REGION)
.id(testRegion)
.description(testRegion);
blobStore.createContainerInLocation(
location.build(), testBucket);
}
示例14: createContainerInLocation
import org.jclouds.domain.LocationScope; //导入依赖的package包/类
@Test
public void createContainerInLocation() {
LocationBuilder location = new LocationBuilder()
.scope(LocationScope.REGION)
.id(testRegion)
.description(testRegion);
blobStore.createContainerInLocation(location.build(), "bucket-to-delete", CreateContainerOptions.NONE);
blobStore.createDirectory("bucket-to-delete", "test-directory");
blobStore.clearContainer("bucket-to-delete");
blobStore.deleteContainerIfEmpty("bucket-to-delete");
}
示例15: apply
import org.jclouds.domain.LocationScope; //导入依赖的package包/类
@Override
public Location apply(final Datacenter datacenter) {
return new LocationBuilder()
.id(datacenter.id())
.description(datacenter.displayName())
.parent(getOnlyElement(justProvider.get()))
.scope(LocationScope.ZONE)
.iso3166Codes(ImmutableSet.of(datacenter.country()))
.metadata(ImmutableMap.<String, Object>of("name", datacenter.displayName()))
.build();
}