@Override public void run(Compute compute, SubnetworkId subnetwork) throws InterruptedException { Operation operation = compute.deleteSubnetwork(subnetwork); if (operation == null) { System.out.printf("Subnetwork %s does not exist%n", subnetwork); return; } while (!operation.isDone()) { System.out.printf( "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); if (operation.getErrors() == null) { System.out.printf("Subnetwork %s was deleted%n", subnetwork); } else { System.out.printf("Deletion of subnetwork %s failed%n", subnetwork); System.out.printf("Error: %s%n", operation.getErrors()); } } }
@Override public void run(Compute compute, InstanceId instance) throws InterruptedException { Operation operation = compute.reset(instance); if (operation == null) { System.out.printf("Instance %s does not exist%n", instance); return; } while (!operation.isDone()) { System.out.printf( "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); if (operation.getErrors() == null) { System.out.printf("Instance %s was reset%n", instance); } else { System.out.printf("Attempt to reset instance %s failed%n", instance); System.out.printf("Error: %s%n", operation.getErrors()); } } }
@Override public void run(Compute compute, InstanceId instance) throws InterruptedException { Operation operation = compute.start(instance); if (operation == null) { System.out.printf("Instance %s does not exist%n", instance); return; } while (!operation.isDone()) { System.out.printf( "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); if (operation.getErrors() == null) { System.out.printf("Instance %s was started%n", instance); } else { System.out.printf("Attempt to start instance %s failed%n", instance); System.out.printf("Error: %s%n", operation.getErrors()); } } }
@Override public void run(Compute compute, DiskId disk) throws InterruptedException { Operation operation = compute.deleteDisk(disk); if (operation == null) { System.out.printf("Disk %s does not exist%n", disk); return; } while (!operation.isDone()) { System.out.printf( "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); if (operation.getErrors() == null) { System.out.printf("Disk %s was deleted%n", disk); } else { System.out.printf("Deletion of disk %s failed%n", disk); System.out.printf("Error: %s%n", operation.getErrors()); } } }
@Override public void run(Compute compute, InstanceId instance) throws InterruptedException { Operation operation = compute.deleteInstance(instance); if (operation == null) { System.out.printf("Instance %s does not exist%n", instance); return; } while (!operation.isDone()) { System.out.printf( "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); if (operation.getErrors() == null) { System.out.printf("Instance %s was deleted%n", instance); } else { System.out.printf("Deletion of instance %s failed%n", instance); System.out.printf("Error: %s%n", operation.getErrors()); } } }
@Override public void run(Compute compute, NetworkId network) throws InterruptedException { Operation operation = compute.deleteNetwork(network.getNetwork()); if (operation == null) { System.out.printf("Network %s does not exist%n", network); return; } while (!operation.isDone()) { System.out.printf( "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); if (operation.getErrors() == null) { System.out.printf("Network %s was deleted%n", network); } else { System.out.printf("Deletion of network %s failed%n", network); System.out.printf("Error: %s%n", operation.getErrors()); } } }
@Override public void run(Compute compute, AddressId address) throws InterruptedException { Operation operation = compute.create(AddressInfo.of(address)); while (!operation.isDone()) { System.out.printf( "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); if (operation.getErrors() == null) { System.out.printf("Address %s was created%n", address); } else { System.out.printf("Creation of address %s failed%n", address); System.out.printf("Error: %s%n", operation.getErrors()); } } }
@Override public void run(Compute compute, SubnetworkInfo subnetwork) throws InterruptedException { Operation operation = compute.create(subnetwork); while (!operation.isDone()) { System.out.printf( "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); if (operation.getErrors() == null) { System.out.printf("Subnetwork %s was created%n", subnetwork.getSubnetworkId()); } else { System.out.printf("Creation of subnetwork %s failed%n", subnetwork.getSubnetworkId()); System.out.printf("Error: %s%n", operation.getErrors()); } }
@Override public void run(Compute compute, SnapshotInfo snapshot) throws InterruptedException { Operation operation = compute.create(snapshot); while (!operation.isDone()) { System.out.printf( "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); if (operation.getErrors() == null) { System.out.printf("Snapshot %s was created%n", snapshot.getSnapshotId()); } else { System.out.printf("Creation of snapshot %s failed%n", snapshot.getSnapshotId()); System.out.printf("Error: %s%n", operation.getErrors()); } }
@Override public void run(Compute compute, ImageInfo image) throws InterruptedException { Operation operation = compute.create(image); while (!operation.isDone()) { System.out.printf( "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); if (operation.getErrors() == null) { System.out.printf("Image %s was created%n", image.getImageId()); } else { System.out.printf("Creation of image %s failed%n", image.getImageId()); System.out.printf("Error: %s%n", operation.getErrors()); } }
@Override public void run(Compute compute, DiskInfo disk) throws InterruptedException { Operation operation = compute.create(disk); while (!operation.isDone()) { System.out.printf( "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); if (operation.getErrors() == null) { System.out.printf("Disk %s was created%n", disk.getDiskId()); } else { System.out.printf("Creation of disk %s failed%n", disk.getDiskId()); System.out.printf("Error: %s%n", operation.getErrors()); } }
@Override public void run(Compute compute, InstanceInfo instance) throws InterruptedException { Operation operation = compute.create(instance); while (!operation.isDone()) { System.out.printf( "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); if (operation.getErrors() == null) { System.out.printf("Instance %s was created%n", instance.getInstanceId()); } else { System.out.printf("Creation of instance %s failed%n", instance.getInstanceId()); System.out.printf("Error: %s%n", operation.getErrors()); } }
@Override public void run(Compute compute, NetworkInfo network) throws InterruptedException { Operation operation = compute.create(network); while (!operation.isDone()) { System.out.printf( "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); if (operation.getErrors() == null) { System.out.printf("Network %s was created%n", network.getNetworkId()); } else { System.out.printf("Creation of network %s failed%n", network.getNetworkId()); System.out.printf("Error: %s%n", operation.getErrors()); } } }
@Override public void run(Compute compute, Tuple<InstanceId, String> instanceAndDevice) throws InterruptedException { InstanceId instance = instanceAndDevice.x(); String deviceName = instanceAndDevice.y(); Operation operation = compute.detachDisk(instance, deviceName); if (operation == null) { System.out.printf("Instance %s does not exist%n", instance); return; } while (!operation.isDone()) { System.out.printf( "Waiting for operation %s to complete%n", operation.getOperationId().getOperation()); Thread.sleep(1000L); } operation = operation.reload(); if (operation.getErrors() == null) { System.out.printf("Disk detached from instance %s%n", instance); } else { System.out.printf("Attempt to detach disk from instance %s failed%n", instance); System.out.printf("Error: %s%n", operation.getErrors()); } }
@Test public void testListZoneOperations() { Page<Operation> operationPage = compute.listZoneOperations(ZONE); Iterator<Operation> operationIterator = operationPage.iterateAll().iterator(); while (operationIterator.hasNext()) { Operation operation = operationIterator.next(); assertNotNull(operation.getGeneratedId()); assertNotNull(operation.getOperationId()); assertEquals(ZONE, operation.<ZoneOperationId>getOperationId().getZone()); // todo(mziccard): uncomment or remove once #727 is closed // assertNotNull(operation.getCreationTimestamp()); assertNotNull(operation.getOperationType()); assertNotNull(operation.getStatus()); assertNotNull(operation.getUser()); } }
@Test public void testListRegionOperations() { Page<Operation> operationPage = compute.listRegionOperations(REGION); Iterator<Operation> operationIterator = operationPage.iterateAll().iterator(); while (operationIterator.hasNext()) { Operation operation = operationIterator.next(); assertNotNull(operation.getGeneratedId()); assertNotNull(operation.getOperationId()); assertEquals(REGION, operation.<RegionOperationId>getOperationId().getRegion()); // todo(mziccard): uncomment or remove once #727 is closed // assertNotNull(operation.getCreationTimestamp()); assertNotNull(operation.getOperationType()); assertNotNull(operation.getStatus()); assertNotNull(operation.getUser()); } }
@Test public void testListGlobalOperations() { Page<Operation> operationPage = compute.listGlobalOperations(); Iterator<Operation> operationIterator = operationPage.iterateAll().iterator(); while (operationIterator.hasNext()) { Operation operation = operationIterator.next(); assertNotNull(operation.getGeneratedId()); assertNotNull(operation.getOperationId()); // todo(mziccard): uncomment or remove once #727 is closed // assertNotNull(operation.getCreationTimestamp()); assertNotNull(operation.getOperationType()); assertNotNull(operation.getStatus()); assertNotNull(operation.getUser()); } }
@Test public void testListRegionOperationsWithFilter() { Page<Operation> operationPage = compute.listRegionOperations( REGION, Compute.OperationListOption.filter( Compute.OperationFilter.equals(Compute.OperationField.STATUS, "DONE"))); Iterator<Operation> operationIterator = operationPage.iterateAll().iterator(); while (operationIterator.hasNext()) { Operation operation = operationIterator.next(); assertNotNull(operation.getGeneratedId()); assertNotNull(operation.getOperationId()); assertEquals(REGION, operation.<RegionOperationId>getOperationId().getRegion()); // todo(mziccard): uncomment or remove once #727 is closed // assertNotNull(operation.getCreationTimestamp()); assertNotNull(operation.getOperationType()); assertEquals(Operation.Status.DONE, operation.getStatus()); assertNotNull(operation.getUser()); } }
@Test public void testListZoneOperationsWithFilter() { Page<Operation> operationPage = compute.listZoneOperations( ZONE, Compute.OperationListOption.filter( Compute.OperationFilter.equals(Compute.OperationField.STATUS, "DONE"))); Iterator<Operation> operationIterator = operationPage.iterateAll().iterator(); while (operationIterator.hasNext()) { Operation operation = operationIterator.next(); assertNotNull(operation.getGeneratedId()); assertNotNull(operation.getOperationId()); assertEquals(ZONE, operation.<ZoneOperationId>getOperationId().getZone()); // todo(mziccard): uncomment or remove once #727 is closed // assertNotNull(operation.getCreationTimestamp()); assertNotNull(operation.getOperationType()); assertEquals(Operation.Status.DONE, operation.getStatus()); assertNotNull(operation.getUser()); } }
@Test public void testListGlobalOperationsWithFilter() { Page<Operation> operationPage = compute.listGlobalOperations( Compute.OperationListOption.filter( Compute.OperationFilter.equals(Compute.OperationField.STATUS, "DONE"))); Iterator<Operation> operationIterator = operationPage.iterateAll().iterator(); while (operationIterator.hasNext()) { Operation operation = operationIterator.next(); assertNotNull(operation.getGeneratedId()); assertNotNull(operation.getOperationId()); // todo(mziccard): uncomment or remove once #727 is closed // assertNotNull(operation.getCreationTimestamp()); assertNotNull(operation.getOperationType()); assertEquals(Operation.Status.DONE, operation.getStatus()); assertNotNull(operation.getUser()); } }