• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ActionResponse类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



ActionResponse类属于org.openstack4j.model.common包,在下文中一共展示了ActionResponse类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: build

import org.openstack4j.model.common.ActionResponse; //导入依赖的package包/类
@Override
public List<CloudResource> build(OpenStackContext context, long privateId, AuthenticatedContext auth, Group group, Image image,
        List<CloudResource> buildableResource, Map<String, String> tags) throws Exception {
    CloudResource resource = buildableResource.get(0);
    try {
        String publicNetId = context.getStringParameter(OpenStackConstants.PUBLIC_NET_ID);
        if (publicNetId != null) {
            OSClient osClient = createOSClient(auth);
            List<CloudResource> computeResources = context.getComputeResources(privateId);
            CloudResource instance = getInstance(computeResources);
            FloatingIP unusedIp = osClient.compute().floatingIps().allocateIP(publicNetId);
            ActionResponse response = osClient.compute().floatingIps().addFloatingIP(instance.getParameter(OpenStackConstants.SERVER, Server.class),
                    unusedIp.getFloatingIpAddress());
            if (!response.isSuccess()) {
                throw new OpenStackResourceException("Add floating-ip to server failed", resourceType(), resource.getName(),
                        auth.getCloudContext().getId(), response.getFault());
            }
            return Collections.singletonList(createPersistedResource(resource, group.getName(), unusedIp.getId()));
        }
        return Collections.emptyList();
    } catch (OS4JException ex) {
        throw new OpenStackResourceException("Add floating-ip to server failed", resourceType(), resource.getName(), ex);
    }
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:25,代码来源:OpenStackFloatingIPBuilder.java


示例3: delete

import org.openstack4j.model.common.ActionResponse; //导入依赖的package包/类
@Override
public CloudResource delete(OpenStackContext context, AuthenticatedContext auth, CloudResource resource, Network network) throws Exception {
    try {
        OSClient osClient = createOSClient(auth);
        NeutronNetworkView networkView = new NeutronNetworkView(network);
        if (!networkView.isExistingSubnet()) {
            String subnetId = context.getStringParameter(OpenStackConstants.SUBNET_ID);
            osClient.networking().router().detachInterface(resource.getReference(), subnetId, null);
        }
        if (!networkView.isExistingNetwork()) {
            ActionResponse response = osClient.networking().router().delete(resource.getReference());
            return checkDeleteResponse(response, resourceType(), auth, resource, "Router deletion failed");
        }
        return null;
    } catch (OS4JException ex) {
        throw new OpenStackResourceException("Router deletion failed", resourceType(), resource.getName(), ex);
    }
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:19,代码来源:OpenStackRouterResourceBuilder.java


示例4: deletePortById

import org.openstack4j.model.common.ActionResponse; //导入依赖的package包/类
/**
 * Deletes the port given an Id. Returns true if the port is successfully deleted. Does not throw any error
 * if the port does not exist.
 *
 * @param region region
 * @param portId non-null port id
 * @return true if successfully deleted
 */
public boolean deletePortById(String region, String portId) {
    boolean success = true;
    getOs().useRegion(region);

    Port port = getOs().networking().port().get(portId);
    if (port != null) {
        ActionResponse delete = getOs().networking().port().delete(portId);
        success = delete.isSuccess();
    } else {
        log.warn(String.format("No port: %s found in region: %s", portId, region));
    }
    return success;
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:22,代码来源:Openstack4JNeutron.java


示例5: deleteSecurityGroupById

import org.openstack4j.model.common.ActionResponse; //导入依赖的package包/类
public boolean deleteSecurityGroupById(String region, String sgRefId) throws IllegalStateException {
    getOs().useRegion(region);
    ActionResponse actionResponse = getOs().networking().securitygroup().delete(sgRefId);
    if (!actionResponse.isSuccess()) {
        String message = String.format("Deleting Security group: %s in region: %s failed. Error: %s", sgRefId,
                region, actionResponse.getFault());
        log.warn(message);
        throw new IllegalStateException(message);
    }
    return actionResponse.isSuccess();
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:12,代码来源:Openstack4JNeutron.java


示例6: 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


示例7: 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


示例8: 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


示例9: 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


示例10: doDelete

import org.openstack4j.model.common.ActionResponse; //导入依赖的package包/类
@Override
protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	ObjectStorageService objectStorage = authenticateAndGetObjectStorageService();

	System.out.println("Deleting file from ObjectStorage...");

	String containerName = request.getParameter("container");

	String fileName = request.getParameter("file");

	if(containerName == null || fileName == null){ //No file was specified to be found, or container name is missing
		response.sendError(HttpServletResponse.SC_NOT_FOUND);
		System.out.println("File not found.");
		return;
	}

	ActionResponse deleteResponse = objectStorage.objects().delete(containerName,fileName);

	if(!deleteResponse.isSuccess()){
		response.sendError(deleteResponse.getCode());
		System.out.println("Delete failed: " + deleteResponse.getFault());
		return;
	}
	else{
		response.setStatus(HttpServletResponse.SC_OK);
	}

	System.out.println("Successfully deleted file from ObjectStorage!");
}
 
开发者ID:ibm-bluemix-mobile-services,项目名称:bluemix-objectstorage-sample-liberty,代码行数:30,代码来源:SimpleServlet.java


示例11: detachVolume

import org.openstack4j.model.common.ActionResponse; //导入依赖的package包/类
public static void detachVolume(String serverId, String volumeId) throws Exception {
    BlockVolumeService volService=Osp4jSession.getOspSession().blockStorage().volumes();
    volumeId=CommonAPI.takeFromMemory(CinderKey.VOLUME_ID, volumeId);
    serverId=CommonAPI.takeFromMemory(NovaKey.NOVA_SERVERID, serverId);
    ServerService serverService = Osp4jSession.getOspSession().compute().servers();
    Volume volume = volService.get(volumeId);
    if (volume != null) {
        // Detach volume from server
        final ActionResponse response = serverService.detachVolume(serverId, volumeId);
        waitUntilVolumeStatus(volService, volume.getId(), Volume.Status.AVAILABLE);        
    }
}
 
开发者ID:vinodborole,项目名称:openstack4j-shell,代码行数:13,代码来源:CinderAPI.java


示例12: uploadSshPublicKey

import org.openstack4j.model.common.ActionResponse; //导入依赖的package包/类
public boolean uploadSshPublicKey(String keyPairName, Nova nova, boolean removeOld) {

    if (removeOld) {
      ActionResponse res = this.novaContext.getCompute().keypairs().delete(keyPairName);
      if (!res.isSuccess())
        logger.info(String.format("Could not remove key maube it does not exist '%s'", keyPairName));
    }

    logger.info(String.format("New keypair '%s' is being uploaded to Nova OpenStack", keyPairName));
    this.novaContext.getCompute().keypairs().create(keyPairName, sshKeyPair.getPublicKey());
    
    return true;
  }
 
开发者ID:karamelchef,项目名称:karamel,代码行数:14,代码来源:NovaV3Launcher.java


示例13: main

import org.openstack4j.model.common.ActionResponse; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    HttpLoggingFilter.toggleLogging(false);
    CloudApiSettings driverConfig = DriverConfigLoader.loadDefault();

    OSClient client = new OSClientFactory(driverConfig).authenticatedClient();
    KeypairService keyApi = client.compute().keypairs();

    ActionResponse response = keyApi.delete(keyPairName);
    LOG.info("deleted keypair {}: {}", keyPairName, response);
}
 
开发者ID:elastisys,项目名称:scale.cloudpool,代码行数:11,代码来源:DeleteKeypairMain.java


示例14: executeAction

import org.openstack4j.model.common.ActionResponse; //导入依赖的package包/类
private List<CloudVmInstanceStatus> executeAction(AuthenticatedContext ac, List<CloudInstance> cloudInstances, Action action) {
    List<CloudVmInstanceStatus> statuses = new ArrayList<>();
    OSClient osClient = openStackClient.createOSClient(ac);
    for (CloudInstance cloudInstance : cloudInstances) {
        ActionResponse actionResponse = osClient.compute().servers().action(cloudInstance.getInstanceId(), action);
        if (actionResponse.isSuccess()) {
            statuses.add(new CloudVmInstanceStatus(cloudInstance, InstanceStatus.IN_PROGRESS));
        } else {
            statuses.add(new CloudVmInstanceStatus(cloudInstance, InstanceStatus.FAILED, actionResponse.getFault()));
        }
    }
    return statuses;
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:14,代码来源:OpenStackInstanceConnector.java


示例15: delete

import org.openstack4j.model.common.ActionResponse; //导入依赖的package包/类
@Override
public CloudResource delete(OpenStackContext context, AuthenticatedContext auth, CloudResource resource) throws Exception {
    try {
        OSClient osClient = createOSClient(auth);
        ActionResponse response = osClient.compute().servers().delete(resource.getReference());
        return checkDeleteResponse(response, resourceType(), auth, resource, "Instance deletion failed");
    } catch (OS4JException ex) {
        throw new OpenStackResourceException("Instance deletion failed", resourceType(), resource.getName(), ex);
    }
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:11,代码来源:OpenStackInstanceBuilder.java


示例16: executeAction

import org.openstack4j.model.common.ActionResponse; //导入依赖的package包/类
private CloudVmInstanceStatus executeAction(AuthenticatedContext auth, CloudInstance instance, Action action) {
    OSClient osClient = createOSClient(auth);
    ActionResponse actionResponse = osClient.compute().servers().action(instance.getInstanceId(), action);
    if (actionResponse.isSuccess()) {
        return new CloudVmInstanceStatus(instance, InstanceStatus.IN_PROGRESS);
    }
    return new CloudVmInstanceStatus(instance, InstanceStatus.FAILED, actionResponse.getFault());
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:9,代码来源:OpenStackInstanceBuilder.java


示例17: delete

import org.openstack4j.model.common.ActionResponse; //导入依赖的package包/类
@Override
public CloudResource delete(OpenStackContext context, AuthenticatedContext auth, CloudResource resource) throws Exception {
    try {
        OSClient osClient = createOSClient(auth);
        ActionResponse response = osClient.blockStorage().volumes().delete(resource.getReference());
        return checkDeleteResponse(response, resourceType(), auth, resource, "Volume deletion failed");
    } catch (OS4JException ex) {
        throw new OpenStackResourceException("Volume deletion failed", resourceType(), resource.getName(), ex);
    }
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:11,代码来源:OpenStackAttachedDiskResourceBuilder.java


示例18: delete

import org.openstack4j.model.common.ActionResponse; //导入依赖的package包/类
@Override
public CloudResource delete(OpenStackContext context, AuthenticatedContext auth, CloudResource resource) throws Exception {
    try {
        OSClient osClient = createOSClient(auth);
        ActionResponse response = osClient.networking().port().delete(resource.getReference());
        return checkDeleteResponse(response, resourceType(), auth, resource, "Port deletion failed");
    } catch (OS4JException ex) {
        throw new OpenStackResourceException("Port deletion failed", resourceType(), resource.getName(), ex);
    }
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:11,代码来源:OpenStackPortBuilder.java


示例19: delete

import org.openstack4j.model.common.ActionResponse; //导入依赖的package包/类
@Override
public CloudResource delete(OpenStackContext context, AuthenticatedContext auth, CloudResource resource, Network network) throws Exception {
    try {
        OSClient osClient = createOSClient(auth);
        deAllocateFloatingIps(context, osClient);
        NeutronNetworkView neutronView = new NeutronNetworkView(network);
        if (!neutronView.isExistingNetwork()) {
            ActionResponse response = osClient.networking().network().delete(resource.getReference());
            return checkDeleteResponse(response, resourceType(), auth, resource, "Network deletion failed");
        }
        return null;
    } catch (OS4JException ex) {
        throw new OpenStackResourceException("Network deletion failed", resourceType(), resource.getName(), ex);
    }
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:16,代码来源:OpenStackNetworkResourceBuilder.java


示例20: deAllocateFloatingIps

import org.openstack4j.model.common.ActionResponse; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void deAllocateFloatingIps(OpenStackContext context, OSClient osClient) {
    List<String> floatingIpIds = context.getParameter(OpenStackConstants.FLOATING_IP_IDS, List.class);
    for (String floatingIpId : floatingIpIds) {
        try {
            ActionResponse response = osClient.compute().floatingIps().deallocateIP(floatingIpId);
            if (!response.isSuccess()) {
                LOGGER.warn("FloatingIp {} cannot be deallocated: {}", floatingIpId, response.getFault());
            }
        } catch (OS4JException ex) {
            LOGGER.warn("FloatingIp {} cannot be deallocated: {}", floatingIpId, ex.getMessage());
        }
    }
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:15,代码来源:OpenStackNetworkResourceBuilder.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java XAQueueConnectionFactory类代码示例发布时间:2022-05-23
下一篇:
Java PGPPrivateKey类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap