@Test public void testFromOpenStackComputeState() { OpenStackParser parser = new OpenStackParser(); try { assertEquals(ComputeState.ACTIVE, parser.fromOpenStackComputeState("ACTIVE")); assertEquals(ComputeState.PENDING, parser.fromOpenStackComputeState("BUILDING")); assertEquals(ComputeState.DONE, parser.fromOpenStackComputeState("DELETED")); assertEquals(ComputeState.FAILED, parser.fromOpenStackComputeState("ERROR")); assertEquals(ComputeState.RESET, parser.fromOpenStackComputeState("HARD_REBOOT")); assertEquals(ComputeState.RESET, parser.fromOpenStackComputeState("PASSWORD")); assertEquals(ComputeState.SUSPENDED, parser.fromOpenStackComputeState("PAUSED")); assertEquals(ComputeState.REBOOT, parser.fromOpenStackComputeState("REBOOT")); assertEquals(ComputeState.PENDING, parser.fromOpenStackComputeState("REBUILD")); assertEquals(ComputeState.RESET, parser.fromOpenStackComputeState("RESCUED")); assertEquals(ComputeState.RESET, parser.fromOpenStackComputeState("RESIZED")); assertEquals(ComputeState.RESET, parser.fromOpenStackComputeState("REVERT_RESIZE")); assertEquals(ComputeState.SHUTDOWN, parser.fromOpenStackComputeState("SHUTOFF")); assertEquals(ComputeState.DONE, parser.fromOpenStackComputeState("SOFT_DELETED")); assertEquals(ComputeState.STOPPED, parser.fromOpenStackComputeState("STOPPED")); assertEquals(ComputeState.SUSPENDED, parser.fromOpenStackComputeState("SUSPENDED")); assertEquals(ComputeState.FAILED, parser.fromOpenStackComputeState("UNKNOWN")); assertEquals(ComputeState.RESET, parser.fromOpenStackComputeState("VERIFY_RESIZE")); parser.fromOpenStackComputeState("NOT EXISTING ONE"); fail(); } catch (OCCIException e) { assertTrue(true); } }
public ComputeState fromOpenStackComputeState(String state) throws OCCIException { if (state.equals(OSSTATE_ACTIVE)) { return ComputeState.ACTIVE; } else if (state.equals(OSSTATE_BUILDING)) { return ComputeState.PENDING; } else if (state.equals(OSSTATE_DELETED)) { return ComputeState.DONE; } else if (state.equals(OSSTATE_ERROR)) { return ComputeState.FAILED; } else if (state.equals(OSSTATE_HARD_REBOOT)) { return ComputeState.RESET; } else if (state.equals(OSSTATE_PASSWORD)) { return ComputeState.RESET; } else if (state.equals(OSSTATE_PAUSED)) { return ComputeState.SUSPENDED; } else if (state.equals(OSSTATE_REBOOT)) { return ComputeState.REBOOT; } else if (state.equals(OSSTATE_REBUILD)) { return ComputeState.PENDING; } else if (state.equals(OSSTATE_RESCUED)) { return ComputeState.RESET; } else if (state.equals(OSSTATE_RESIZED)) { return ComputeState.RESET; } else if (state.equals(OSSTATE_REVERT_RESIZE)) { return ComputeState.RESET; } else if (state.equals(OSSTATE_SHUTOFF)) { return ComputeState.SHUTDOWN; } else if (state.equals(OSSTATE_SOFT_DELETED)) { return ComputeState.DONE; } else if (state.equals(OSSTATE_STOPPED)) { return ComputeState.STOPPED; } else if (state.equals(OSSTATE_SUSPENDED)) { return ComputeState.SUSPENDED; } else if (state.equals(OSSTATE_UNKNOWN)) { return ComputeState.FAILED; } else if (state.equals(OSSTATE_VERIFY_RESIZE)) { return ComputeState.RESET; } else { OCCIException exception = new OCCIException(); exception.setMessage(String.format(BADSTATE, state)); log.error(String.format(BADSTATE, state)); throw exception; } }
OpenStackParser { public ComputeState fromOpenStackComputeState(String state) throws OCCIException { if (state.equals(OSSTATE_ACTIVE)) { return ComputeState.ACTIVE; } else if (state.equals(OSSTATE_BUILDING)) { return ComputeState.PENDING; } else if (state.equals(OSSTATE_DELETED)) { return ComputeState.DONE; } else if (state.equals(OSSTATE_ERROR)) { return ComputeState.FAILED; } else if (state.equals(OSSTATE_HARD_REBOOT)) { return ComputeState.RESET; } else if (state.equals(OSSTATE_PASSWORD)) { return ComputeState.RESET; } else if (state.equals(OSSTATE_PAUSED)) { return ComputeState.SUSPENDED; } else if (state.equals(OSSTATE_REBOOT)) { return ComputeState.REBOOT; } else if (state.equals(OSSTATE_REBUILD)) { return ComputeState.PENDING; } else if (state.equals(OSSTATE_RESCUED)) { return ComputeState.RESET; } else if (state.equals(OSSTATE_RESIZED)) { return ComputeState.RESET; } else if (state.equals(OSSTATE_REVERT_RESIZE)) { return ComputeState.RESET; } else if (state.equals(OSSTATE_SHUTOFF)) { return ComputeState.SHUTDOWN; } else if (state.equals(OSSTATE_SOFT_DELETED)) { return ComputeState.DONE; } else if (state.equals(OSSTATE_STOPPED)) { return ComputeState.STOPPED; } else if (state.equals(OSSTATE_SUSPENDED)) { return ComputeState.SUSPENDED; } else if (state.equals(OSSTATE_UNKNOWN)) { return ComputeState.FAILED; } else if (state.equals(OSSTATE_VERIFY_RESIZE)) { return ComputeState.RESET; } else { OCCIException exception = new OCCIException(); exception.setMessage(String.format(BADSTATE, state)); log.error(String.format(BADSTATE, state)); throw exception; } } }
OpenStackParser { public ComputeState fromOpenStackComputeState(String state) throws OCCIException { if (state.equals(OSSTATE_ACTIVE)) { return ComputeState.ACTIVE; } else if (state.equals(OSSTATE_BUILDING)) { return ComputeState.PENDING; } else if (state.equals(OSSTATE_DELETED)) { return ComputeState.DONE; } else if (state.equals(OSSTATE_ERROR)) { return ComputeState.FAILED; } else if (state.equals(OSSTATE_HARD_REBOOT)) { return ComputeState.RESET; } else if (state.equals(OSSTATE_PASSWORD)) { return ComputeState.RESET; } else if (state.equals(OSSTATE_PAUSED)) { return ComputeState.SUSPENDED; } else if (state.equals(OSSTATE_REBOOT)) { return ComputeState.REBOOT; } else if (state.equals(OSSTATE_REBUILD)) { return ComputeState.PENDING; } else if (state.equals(OSSTATE_RESCUED)) { return ComputeState.RESET; } else if (state.equals(OSSTATE_RESIZED)) { return ComputeState.RESET; } else if (state.equals(OSSTATE_REVERT_RESIZE)) { return ComputeState.RESET; } else if (state.equals(OSSTATE_SHUTOFF)) { return ComputeState.SHUTDOWN; } else if (state.equals(OSSTATE_SOFT_DELETED)) { return ComputeState.DONE; } else if (state.equals(OSSTATE_STOPPED)) { return ComputeState.STOPPED; } else if (state.equals(OSSTATE_SUSPENDED)) { return ComputeState.SUSPENDED; } else if (state.equals(OSSTATE_UNKNOWN)) { return ComputeState.FAILED; } else if (state.equals(OSSTATE_VERIFY_RESIZE)) { return ComputeState.RESET; } else { OCCIException exception = new OCCIException(); exception.setMessage(String.format(BADSTATE, state)); log.error(String.format(BADSTATE, state)); throw exception; } }  }
OpenStackParser { public ComputeState fromOpenStackComputeState(String state) throws OCCIException { if (state.equals(OSSTATE_ACTIVE)) { return ComputeState.ACTIVE; } else if (state.equals(OSSTATE_BUILDING)) { return ComputeState.PENDING; } else if (state.equals(OSSTATE_DELETED)) { return ComputeState.DONE; } else if (state.equals(OSSTATE_ERROR)) { return ComputeState.FAILED; } else if (state.equals(OSSTATE_HARD_REBOOT)) { return ComputeState.RESET; } else if (state.equals(OSSTATE_PASSWORD)) { return ComputeState.RESET; } else if (state.equals(OSSTATE_PAUSED)) { return ComputeState.SUSPENDED; } else if (state.equals(OSSTATE_REBOOT)) { return ComputeState.REBOOT; } else if (state.equals(OSSTATE_REBUILD)) { return ComputeState.PENDING; } else if (state.equals(OSSTATE_RESCUED)) { return ComputeState.RESET; } else if (state.equals(OSSTATE_RESIZED)) { return ComputeState.RESET; } else if (state.equals(OSSTATE_REVERT_RESIZE)) { return ComputeState.RESET; } else if (state.equals(OSSTATE_SHUTOFF)) { return ComputeState.SHUTDOWN; } else if (state.equals(OSSTATE_SOFT_DELETED)) { return ComputeState.DONE; } else if (state.equals(OSSTATE_STOPPED)) { return ComputeState.STOPPED; } else if (state.equals(OSSTATE_SUSPENDED)) { return ComputeState.SUSPENDED; } else if (state.equals(OSSTATE_UNKNOWN)) { return ComputeState.FAILED; } else if (state.equals(OSSTATE_VERIFY_RESIZE)) { return ComputeState.RESET; } else { OCCIException exception = new OCCIException(); exception.setMessage(String.format(BADSTATE, state)); log.error(String.format(BADSTATE, state)); throw exception; } }  String[] parseAuthorizationResponse(String response); String[][] parseNetworkCollectionResponse(String response); String[] parseCreatedNetworkResponse(String response); NetworkCollection parseSubnetCollectionResponse(String response); Network parseSubnetResponse(String response); StorageCollection parseStorageCollectionResponse(String response); Storage parseStorageResponse(String response); StorageCollection parseImageCollectionResponse(String response); Storage parseImageResponse(String response); ComputeCollection parseComputeCollectionResponse(String response); Compute parseComputeResponse(String response); String parseComputeInstanceTypeId(
    		String response,
    		HashMap<String, InstanceType> instanceTypes); List<Disk> parseAttachedStoragesResponse(String response); List<Nic> parseVirtualInterfacesResponse(String response); InstanceTypeCollection parseInstanceTypeCollectionResponse(String response); InstanceType parseInstanceTypeResponse(String response); Quota parseComputeQuotaResponse(String response); int parseStorageQuotaResponse(String response); ComputeState fromOpenStackComputeState(String state); String toOpenStackComputeState(ComputeState state); }
OpenStackParser { public ComputeState fromOpenStackComputeState(String state) throws OCCIException { if (state.equals(OSSTATE_ACTIVE)) { return ComputeState.ACTIVE; } else if (state.equals(OSSTATE_BUILDING)) { return ComputeState.PENDING; } else if (state.equals(OSSTATE_DELETED)) { return ComputeState.DONE; } else if (state.equals(OSSTATE_ERROR)) { return ComputeState.FAILED; } else if (state.equals(OSSTATE_HARD_REBOOT)) { return ComputeState.RESET; } else if (state.equals(OSSTATE_PASSWORD)) { return ComputeState.RESET; } else if (state.equals(OSSTATE_PAUSED)) { return ComputeState.SUSPENDED; } else if (state.equals(OSSTATE_REBOOT)) { return ComputeState.REBOOT; } else if (state.equals(OSSTATE_REBUILD)) { return ComputeState.PENDING; } else if (state.equals(OSSTATE_RESCUED)) { return ComputeState.RESET; } else if (state.equals(OSSTATE_RESIZED)) { return ComputeState.RESET; } else if (state.equals(OSSTATE_REVERT_RESIZE)) { return ComputeState.RESET; } else if (state.equals(OSSTATE_SHUTOFF)) { return ComputeState.SHUTDOWN; } else if (state.equals(OSSTATE_SOFT_DELETED)) { return ComputeState.DONE; } else if (state.equals(OSSTATE_STOPPED)) { return ComputeState.STOPPED; } else if (state.equals(OSSTATE_SUSPENDED)) { return ComputeState.SUSPENDED; } else if (state.equals(OSSTATE_UNKNOWN)) { return ComputeState.FAILED; } else if (state.equals(OSSTATE_VERIFY_RESIZE)) { return ComputeState.RESET; } else { OCCIException exception = new OCCIException(); exception.setMessage(String.format(BADSTATE, state)); log.error(String.format(BADSTATE, state)); throw exception; } }  String[] parseAuthorizationResponse(String response); String[][] parseNetworkCollectionResponse(String response); String[] parseCreatedNetworkResponse(String response); NetworkCollection parseSubnetCollectionResponse(String response); Network parseSubnetResponse(String response); StorageCollection parseStorageCollectionResponse(String response); Storage parseStorageResponse(String response); StorageCollection parseImageCollectionResponse(String response); Storage parseImageResponse(String response); ComputeCollection parseComputeCollectionResponse(String response); Compute parseComputeResponse(String response); String parseComputeInstanceTypeId(
    		String response,
    		HashMap<String, InstanceType> instanceTypes); List<Disk> parseAttachedStoragesResponse(String response); List<Nic> parseVirtualInterfacesResponse(String response); InstanceTypeCollection parseInstanceTypeCollectionResponse(String response); InstanceType parseInstanceTypeResponse(String response); Quota parseComputeQuotaResponse(String response); int parseStorageQuotaResponse(String response); ComputeState fromOpenStackComputeState(String state); String toOpenStackComputeState(ComputeState state); static final String KEYSTONENAMESPACE; static final String QUANTUMNAMESPACE; static final String PROVIDERNAMESPACE; static final String ROUTERNAMESPACE; static final String XSINAMESPACE; static final String VOLUMENAMESPACE; static final String ATOMNAMESPACE; static final String COMPUTENAMESPACE; static final String VIFNAMESPACE; static final String COMMONNAMESPACE; static final String BLOCKNAMESPACE; static final String OSVOLHOSTATTRNAMESPACE; static final String OSVOLIMAGEMETANAMESPACE; static final String OSVOLTENANTATTRNAMESPACE; }