本文整理汇总了Java中org.openstack4j.model.common.ActionResponse.isSuccess方法的典型用法代码示例。如果您正苦于以下问题:Java ActionResponse.isSuccess方法的具体用法?Java ActionResponse.isSuccess怎么用?Java ActionResponse.isSuccess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openstack4j.model.common.ActionResponse
的用法示例。
在下文中一共展示了ActionResponse.isSuccess方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
}
示例3: 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;
}
示例4: 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();
}
示例5: 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());
}
}
}
示例6: 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;
}
示例7: 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();
}
示例8: 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());
}
}
示例9: 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
示例10: 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;
}
示例11: 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;
}
示例12: 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());
}
示例13: 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());
}
}
}
示例14: 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;
}
示例15: startServer
import org.openstack4j.model.common.ActionResponse; //导入方法依赖的package包/类
public boolean startServer(String region, String serverId) {
getOs().useRegion(region);
ActionResponse action = getOs().compute().servers().action(serverId, Action.START);
return action.isSuccess();
}