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


Java ActionResponse.getCode方法代码示例

本文整理汇总了Java中org.openstack4j.model.common.ActionResponse.getCode方法的典型用法代码示例。如果您正苦于以下问题:Java ActionResponse.getCode方法的具体用法?Java ActionResponse.getCode怎么用?Java ActionResponse.getCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openstack4j.model.common.ActionResponse的用法示例。


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

示例1: doRequest

import org.openstack4j.model.common.ActionResponse; //导入方法依赖的package包/类
@Override
public Void doRequest(OSClient api) throws NotFoundException, ResponseException {
    // look for victim server in all regions
    ServerService serverApi = api.compute().servers();
    Server victimServer = serverApi.get(this.victimId);
    if (victimServer == null) {
        throw new NotFoundException(format("delete failed: server with id '%s' could not be found in region %s",
                this.victimId, getApiAccessConfig().getRegion()));
    }

    releaseFloatingIps(api, victimServer);
    ActionResponse response = serverApi.delete(this.victimId);
    if (!response.isSuccess()) {
        throw new ResponseException(
                String.format("delete failed: server %s: %s", this.victimId, response.getFault()),
                response.getCode());
    }

    awaitTermination(victimServer.getId());
    return null;
}
 
开发者ID:elastisys,项目名称:scale.cloudpool,代码行数:22,代码来源:DeleteServerRequest.java

示例2: deleteFloatingIp

import org.openstack4j.model.common.ActionResponse; //导入方法依赖的package包/类
public synchronized void deleteFloatingIp(String region, String floatingIpId) {
    getOs().useRegion(region);
    log.info("Deleting Floating ip with id: " + floatingIpId);
    ActionResponse actionResponse = getOs().networking().floatingip().delete(floatingIpId);
    if (!actionResponse.isSuccess()) {
        String message = String.format("Deleting floating ip with id: %s in region: %s failed with message: %s",
                floatingIpId, region, actionResponse.getFault());
        log.warn(message);
        if (actionResponse.getCode() != Response.Status.NOT_FOUND.getStatusCode()) {
            throw new ResponseException(message, actionResponse.getCode());
        }
    }
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:14,代码来源:Openstack4JNeutron.java

示例3: uploadImage

import org.openstack4j.model.common.ActionResponse; //导入方法依赖的package包/类
public String uploadImage(String region, String imageName, File imageFile, Map<String, String> imageProperties)
        throws IOException, VmidcBrokerValidationException {
    log.info("Uploading Image " + imageName + " to region " + region);
    getOs().useRegion(region);

    String fileExtension = FilenameUtils.getExtension(imageFile.getName());

    ImageBuilder imageBuilder = Builders.imageV2()
            .name(imageName)
            .containerFormat(ContainerFormat.BARE)
            .visibility(Image.ImageVisibility.PRIVATE)
            .diskFormat(getDiskFormat(fileExtension));

    if (imageProperties != null) {
        imageProperties.forEach(imageBuilder::additionalProperty);
    }

    Image createdImage = getOs().imagesV2().create(imageBuilder.build());
    String imageId = createdImage.getId();

    Payload<File> payload = Payloads.create(imageFile);

    ActionResponse actionResponse = getOs().imagesV2().upload(imageId, payload, createdImage);
    if (actionResponse.isSuccess()) {
        log.info("Image uploaded with Id: " + imageId);
    } else {
        String message = String.format("Failed to upload image: %s to region: %s. error: %s", imageName, region,
                actionResponse.getFault());
        log.warn(message);
        throw new ResponseException(message, actionResponse.getCode());
    }

    return imageId;
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:35,代码来源:Openstack4jGlance.java

示例4: deleteImageById

import org.openstack4j.model.common.ActionResponse; //导入方法依赖的package包/类
public boolean deleteImageById(String region, String id) {
    getOs().useRegion(region);
    ActionResponse actionResponse = getOs().imagesV2().delete(id);
    if (!actionResponse.isSuccess()) {
        String message = String.format("Image Id: %s in region: %s cannot be removed. Error: %s", id, region,
                actionResponse.getFault());
        log.warn(message);
        throw new ResponseException(message, actionResponse.getCode());
    }
    return actionResponse.isSuccess();
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:12,代码来源:Openstack4jGlance.java

示例5: deleteFlavorById

import org.openstack4j.model.common.ActionResponse; //导入方法依赖的package包/类
public void deleteFlavorById(String region, String id) {
    getOs().useRegion(region);
    ActionResponse actionResponse = getOs().compute().flavors().delete(id);
    if (!actionResponse.isSuccess()) {
        String message = String.format("Deleting flavor Id: %s failed. Error: %s", id, actionResponse.getFault());
        log.warn(message);
        throw new ResponseException(message, actionResponse.getCode());
    }
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:10,代码来源:Openstack4JNova.java

示例6: checkDeleteResponse

import org.openstack4j.model.common.ActionResponse; //导入方法依赖的package包/类
protected CloudResource checkDeleteResponse(ActionResponse response, ResourceType resourceType, AuthenticatedContext auth, CloudResource resource,
        String faultMsg) {
    if (!response.isSuccess()) {
        if (response.getCode() != StatusCode.NOT_FOUND.getCode()) {
            throw new OpenStackResourceException(faultMsg, resourceType, resource.getName(), auth.getCloudContext().getId(),
                    response.getFault());
        } else {
            return null;
        }
    }
    return resource;
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:13,代码来源:AbstractOpenStackResourceBuilder.java


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