当前位置: 首页>>代码示例>>Java>>正文


Java InstanceApi类代码示例

本文整理汇总了Java中org.jclouds.googlecomputeengine.features.InstanceApi的典型用法代码示例。如果您正苦于以下问题:Java InstanceApi类的具体用法?Java InstanceApi怎么用?Java InstanceApi使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


InstanceApi类属于org.jclouds.googlecomputeengine.features包,在下文中一共展示了InstanceApi类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: detachVolume

import org.jclouds.googlecomputeengine.features.InstanceApi; //导入依赖的package包/类
@Override
public void detachVolume(String instanceId, String volumeId) {
    InstanceApi instApi = getGCEInstanceApi();
    String zone = getZone();
    Instance inst = instApi.get(instanceId);
    log.info("Trying to detach volume: " + volumeId + " from instance: " + instanceId + " in zone: " + zone);
    if (inst == null) {
        log.error("Failed to find instance: " + instanceId + " in zone: " + zone);
        return;
    }
    for (Instance.AttachedDisk disk : inst.disks()) {
        if (disk.deviceName().equals(volumeId)) {
            log.info("Found disk to be detached. Source: " + disk.source() + " devicename: " + disk.deviceName());
            Operation oper = instApi.detachDisk(instanceId, disk.deviceName());
            oper = waitGCEOperationDone(oper);
            if (!oper.status().equals(Operation.Status.DONE)) {
                log.error("Failed to detach volume: " + volumeId + " to instance: " + instanceId +
                        " in zone: " + zone + " at device: " + disk.deviceName() + " result operation: " + oper);
            }
            return;
        }
    }
    log.error("Cannot find volume: " + volumeId + " in instance: " + instanceId);
}
 
开发者ID:apache,项目名称:stratos,代码行数:25,代码来源:GCEIaas.java

示例2: attachVolume

import org.jclouds.googlecomputeengine.features.InstanceApi; //导入依赖的package包/类
@Override
public String attachVolume(String instanceId, String volumeId, String deviceName) {
    DiskApi diskApi = getGCEDiskApi();
    InstanceApi instApi = getGCEInstanceApi();
    String zone = getZone();

    log.info("Trying to attach volume: " + volumeId + " to instance: " + instanceId +
            " in zone: " + zone + " at devicename: " + deviceName);

    Disk disk = diskApi.get(volumeId);
    if (disk == null) {
        log.error("Failed to get volume: " + volumeId + " in zone: " + zone);
        return null;
    }
    log.debug("Found volumeId: " + volumeId + " volume: " + disk);
    try {
        Operation oper =
                instApi.attachDisk(instanceId, AttachDisk.create(AttachDisk.Type.PERSISTENT, AttachDisk.Mode
                        .READ_WRITE, disk.selfLink(), deviceName, true, null, false, null, null));
        oper = waitGCEOperationDone(oper);
        if (!oper.status().equals(Operation.Status.DONE)) {
            log.error("Failed to attach volume: " + volumeId + " to instance: " + instanceId +
                    " in zone: " + zone + " at device: " + deviceName + " operation: " + oper);
            return null;
        }
        return volumeId;
    }
    catch (Exception e) {
        log.error("Error attaching volume", e);
    }
    return null;
}
 
开发者ID:apache,项目名称:stratos,代码行数:33,代码来源:GCEIaas.java

示例3: getGCEInstanceApi

import org.jclouds.googlecomputeengine.features.InstanceApi; //导入依赖的package包/类
private InstanceApi getGCEInstanceApi() {
    return getGCEApi().instancesInZone(getZone());
}
 
开发者ID:apache,项目名称:stratos,代码行数:4,代码来源:GCEIaas.java


注:本文中的org.jclouds.googlecomputeengine.features.InstanceApi类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。